From ab35d30ff5371b1f572ebc69012238b809ad33ec Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 8 Jan 2018 14:48:00 +0100 Subject: [PATCH 0001/1027] #2348 Elm Props: "Import Element Property Table" command --- .../Commands/CMakeLists_files.cmake | 2 + .../RicImportElementPropertyFeature.cpp | 68 +++++++++++++++++++ .../RicImportElementPropertyFeature.h | 34 ++++++++++ .../UserInterface/RiuMainPlotWindow.cpp | 1 + .../UserInterface/RiuMainWindow.cpp | 1 + 5 files changed, 106 insertions(+) create mode 100644 ApplicationCode/Commands/RicImportElementPropertyFeature.cpp create mode 100644 ApplicationCode/Commands/RicImportElementPropertyFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 9673c13eaa..cfda894e19 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -34,6 +34,7 @@ ${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h +${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.h ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h @@ -112,6 +113,7 @@ ${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.cpp ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp new file mode 100644 index 0000000000..9064e42abf --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportElementPropertyFeature.h" + +#include "RiaApplication.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportElementPropertyFeature, "RicImportElementPropertyFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportElementPropertyFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + + QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); + QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); + + if (fileNames.size()) + { + defaultDir = QFileInfo(fileNames.last()).absolutePath(); + } + + app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir); + + for (int i = 0; i < fileNames.size(); i++) + { + QString fileName = fileNames[i]; + + //TODO + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/GeoMechCase48x48.png")); + actionToSetup->setText("Import &Element Property Table"); +} diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.h b/ApplicationCode/Commands/RicImportElementPropertyFeature.h new file mode 100644 index 0000000000..781af3fc47 --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicImportElementPropertyFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 747c1ad3b5..df865f785c 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -192,6 +192,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); #endif importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index f8969ee52a..cb5d67a2ca 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -358,6 +358,7 @@ void RiuMainWindow::createMenus() importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); #endif importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); From 038914dc0121f1c01106f8740127150ea70eccf2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Jan 2018 21:47:23 +0100 Subject: [PATCH 0002/1027] Delete octave tests, moved to test repository See https://github.com/OPM/ResInsight-regression-test --- .../OctaveScripts/OctaveInterfaceTest.m | 325 ------------------ .../ResInsightIterfaceUnitTest.m | 154 --------- 2 files changed, 479 deletions(-) delete mode 100644 OctavePlugin/OctaveScripts/OctaveInterfaceTest.m delete mode 100644 OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m diff --git a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m b/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m deleted file mode 100644 index 182b99c1c6..0000000000 --- a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m +++ /dev/null @@ -1,325 +0,0 @@ -### The case with caseid 1 has to be selected/active in ResInsight when running this test-script -### Coarsening and Dual porosity is not exercised by this tes yet. We need models - - -### CaseInfo riGetCurrentCase() -%!test -%! printf ("===== Testing ====> riGetCurrentCase\n"); -%! caseInfo = riGetCurrentCase(); -%! assert ( caseInfo.CaseId == 1 ); -%! assert ( caseInfo.CaseName == "BRUGGE_0000" ); -%! assert ( caseInfo.CaseType == "SourceCase" ); -%! assert ( caseInfo.CaseGroupId == 0 ); - -### Vector[CaseInfo] riGetSelectedCases() -%!test -%! printf ("===== Testing ====> riGetSelectedCases\n"); -%! caseInfoVector1 = riGetSelectedCases(); -%! assert ( caseInfoVector1.CaseId == 1 ); -%! assert ( caseInfoVector1.CaseName == "BRUGGE_0000" ); -%! assert ( caseInfoVector1.CaseType == "SourceCase" ); -%! assert ( caseInfoVector1.CaseGroupId == 0 ); - - -### Vector[CaseGroupInfo] riGetCaseGroups() -%!test -%! printf ("===== Testing ====> riGetCaseGroups\n"); -%! caseGroupInfoVector = riGetCaseGroups(); -%! assert (rows(caseGroupInfoVector) == 2); -%! assert (caseGroupInfoVector(2).CaseGroupId == 1); -%! assert (caseGroupInfoVector(2).CaseGroupName == "Grid Case Group 2"); - -### Vector[CaseInfo] riGetCases([CaseGroupId]) -%!test -%! printf ("===== Testing ====> riGetCases\n"); -%! caseInfoVector3 = riGetCases(); -%! assert(rows(caseInfoVector3) == 10); -%! assert(caseInfoVector3(2).CaseName == "BRUGGE_0040"); -%! assert(caseInfoVector3(2).CaseType == "ResultCase"); -%! assert(caseInfoVector3(3).CaseType == "StatisticsCase"); -%! assert(caseInfoVector3(4).CaseType == "SourceCase"); -%! caseinfoVector3 = riGetCases(1); -%! assert(rows(caseinfoVector3) == 3); - - -### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] ) -%!test -%! printf ("===== Testing ====> riGetActiveCellInfo\n"); -%! ACInfo1 = riGetActiveCellInfo(); -%! assert(rows(ACInfo1) == 43374); -%! assert(columns(ACInfo1) == 9); -%! ACInfo2 = riGetActiveCellInfo("Matrix"); -%! assert(ACInfo1 == ACInfo2); -%! ACInfo3 = riGetActiveCellInfo(1, "Matrix"); -%! assert(ACInfo1 == ACInfo3); -%! ACInfo4 = riGetActiveCellInfo(1); -%! assert(ACInfo1 == ACInfo4); - -### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId]) -%!test -%! printf ("===== Testing ====> riGetCoarseningInfo\n"); -%! CoarseInfo1 = riGetCoarseningInfo(); -%! assert(rows(CoarseInfo1) == 0); -%! assert(columns(CoarseInfo1) == 6); - - -### Matrix[numGrids][3] riGetGridDimensions([CaseId]) -%!test -%! printf ("===== Testing ====> riGetGridDimensions\n"); -%! GridDims1 = riGetGridDimensions(); -%! assert(rows(GridDims1) == 1); -%! assert(columns(GridDims1) == 3); - -%! GridDims2 = riGetGridDimensions(0); -%! assert(rows(GridDims2) == 2); -%! assert(columns(GridDims2) == 3); -%! assert( GridDims2(2,1) == 12); -%! assert( GridDims2(2,3) == 36); - -### Vector[TimeStepDate] riGetTimestepDates([CaseId]) -%!test -%! printf ("===== Testing ====> riGetTimestepDates\n"); -%! TimeStepDates1 = riGetTimeStepDates(); -%! assert(rows(TimeStepDates1) == 11); -%! assert(TimeStepDates1(2).Year == 1997); -%! assert(TimeStepDates1(2).Month == 01); -%! assert(TimeStepDates1(2).Day == 31); -%! assert(TimeStepDates1(2).Hour == 0); -%! assert(TimeStepDates1(2).Minute == 0); -%! assert(TimeStepDates1(2).Second == 0); -%! TimeStepDates2 = riGetTimeStepDates(1); -%! assert(TimeStepDates2(7).Year == 1997); -%! assert(TimeStepDates2(7).Month == 06); -%! assert(TimeStepDates2(7).Day == 30); -%! assert(TimeStepDates2(7).Hour == 0); -%! assert(TimeStepDates2(7).Minute == 0); -%! assert(TimeStepDates2(7).Second == 0); - -### Vector[DecimalDay] riGetTimestepDays([CaseId]) -%!test -%! printf ("===== Testing ====> riGetTimestepDays\n"); -%! TimeStepDays1 = riGetTimeStepDays(); -%! assert(TimeStepDays1(1) == 0); -%! assert(TimeStepDays1(2) == 30); -%! assert(rows(TimeStepDays1) == 11); -%! TimeStepDays2 = riGetTimeStepDays(1); -%! assert(rows(TimeStepDays2) == 11); - - -### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"]) -%!xtest -%! printf ("===== Testing ====> riGetPropertyNames\n"); -%! PropertyInfos1 = riGetPropertyNames(); -%! PropertyInfos2 = riGetPropertyNames(1); -%! PropertyInfos3 = riGetPropertyNames("Matrix"); -%! PropertyInfos4 = riGetPropertyNames(1, "Matrix"); -%! assert(PropertyInfos1(1).PropName == "PRESSURE"); -%! assert(PropertyInfos1(1).PropType == "DynamicNative"); -%! assert(PropertyInfos1(26).PropType == "StaticNative"); - -### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellProperty\n"); -%! ActivePropData1 = riGetActiveCellProperty("SWAT"); -%! assert (rows(ActivePropData1) == rows(riGetActiveCellInfo())); -%! assert (columns(ActivePropData1) == rows(riGetTimeStepDays())); -%! ActivePropData2 = riGetActiveCellProperty("SWAT", "Matrix"); -%! assert (ActivePropData2 == ActivePropData1); -%! ActivePropData3 = riGetActiveCellProperty("SWAT", [1,3]); -%! assert (columns(ActivePropData3) == 2); -%! assert (ActivePropData3(:,2) == ActivePropData1(:,3)); -%! ActivePropData4 = riGetActiveCellProperty("SWAT", [1,3], "Matrix"); -%! assert (ActivePropData3 == ActivePropData4); -%! ActivePropData5 = riGetActiveCellProperty(1, "SWAT"); -%! assert (ActivePropData5 == ActivePropData1); -%! ActivePropData6 = riGetActiveCellProperty(1, "SWAT", [1,3]); -%! assert (ActivePropData6 == ActivePropData3); -%! ActivePropData7 = riGetActiveCellProperty(1, "SWAT", [1,3], "Matrix"); -%! assert (ActivePropData7 == ActivePropData3); -%! ActivePropData8 = riGetActiveCellProperty(1, "SWAT", "Matrix"); -%! assert (ActivePropData8 == ActivePropData1); - -### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetGridProperty\n"); -%! GridProps1 = riGetGridProperty( 0 , "SWAT" ); -%! assert( ndims (GridProps1) == 4); -%! [ni, nj, nk, nts ] = size(GridProps1); -%! disp(nts); -%! assert(nts == 11); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(GridProps1(62,30,1,3), 0.40942, 0.00001); - -%! GridProps2 = riGetGridProperty( 0 , "SWAT", [1,3]); -%! assert( ndims (GridProps2) == 4); -%! [ni, nj, nk, nts ] = size(GridProps2); -%! assert(nts == 2); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(GridProps2(62,30,1,2), 0.40942, 0.00001); - -%! GridProps3 = riGetGridProperty( 0 , "SWAT", [1,3], "Matrix"); -%! GridProps4 = riGetGridProperty( 0 , "SWAT", "Matrix"); -%! GridProps5 = riGetGridProperty(1, 0 , "SWAT" ); -%! GridProps6 = riGetGridProperty(1, 0 , "SWAT", [1,3]); -%! GridProps7 = riGetGridProperty(1, 0 , "SWAT", [1,3], "Matrix"); -%! GridProps8 = riGetGridProperty(1, 0 , "SWAT", "Matrix"); - -%! assert(GridProps3 == GridProps2); -%! assert(GridProps4 == GridProps1); -%! assert(GridProps5 == GridProps1); -%! assert(GridProps6 == GridProps2); -%! assert(GridProps7 == GridProps2); -%! assert(GridProps8 == GridProps1); - - - ### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riSetActiveCellProperty\n"); -%! ActivePropData1 = riGetActiveCellProperty("SWAT"); -%! ActivePropData3 = riGetActiveCellProperty("SWAT", [1,3]); - -%! riSetActiveCellProperty( ActivePropData1, "PropertyName1" ); -%! riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]); -%! riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" ); -%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]); -%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); - -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName1")); -%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName2", [1,3])); -%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName3", [1,3])); -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName4", "Matrix")); -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName5")); -%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName6", [1,3])); -%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName7", [1,3], "Matrix")); -%! assert(ActivePropData1 == riGetActiveCellProperty( 1, "PropertyName8", "Matrix")); - -### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riSetGridProperty\n"); -%! GridProps1 = riGetGridProperty( 0 , "SWAT" ); -%! GridProps2 = riGetGridProperty( 0 , "SWAT", [1,3]); - -%! riSetGridProperty( GridProps1, 0, "PropertyName11" ); -%! riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]); -%! riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix"); -%! riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); -%! riSetGridProperty( GridProps1, 1, 0, "PropertyName15" ); -%! riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]); -%! riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix"); -%! riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); - -%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName11")); -%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName12", [1,3])); -%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName13", [1,3], "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName14", "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName15")); -%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName16", [1,3])); -%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName17", [1,3], "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName18", "Matrix")); - - -### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex) -%!test -%! printf ("===== Testing ====> riGetCellCenters\n"); -%! CellCenters1 = riGetCellCenters(0); -%! CellCenters2 = riGetCellCenters(1, 0); -%! assert( ndims (CellCenters1) == 4); -%! [ni, nj, nk, idx ] = size(CellCenters1); -%! assert(idx == 3); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(CellCenters1(62,30,1, 1), 3489.2, 0.1); -%! assert(CellCenters1(62,30,1, 2), 1.5909e+004, 0.1); -%! assert(CellCenters1(62,30,1, 3), -5458.8, 0.1); -%! assert(CellCenters1 == CellCenters2); - - - -### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellCenters\n"); -%! ActiveCellCenters1 = riGetActiveCellCenters(); -%! ActiveCellCenters2 = riGetActiveCellCenters("Matrix"); -%! ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix"); - -%! assert (rows(ActiveCellCenters1), rows(riGetActiveCellInfo())); -%! assert (columns(ActiveCellCenters1) == 3); -%! assert (ActiveCellCenters1(500,:) ,[3493.7, 9184.6, -6074.4], [0.1, 0.1, 0.1]); -%! assert (ActiveCellCenters1 == ActiveCellCenters2); -%! assert (ActiveCellCenters1 == ActiveCellCenters3); - - -### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex) -%!test -%! printf ("===== Testing ====> riGetCellCorners\n"); -%! CellCorners1 = riGetCellCorners(0); -%! CellCorners2 = riGetCellCorners(1, 0); - -%! assert( ndims (CellCorners1) == 5); -%! [ni, nj, nk, cidx, idx ] = size(CellCorners1); -%! assert(idx == 3); -%! assert(cidx == 8); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(CellCorners1(62,30,1, 1, 1), 3207.4, 0.1); -%! assert(CellCorners1(62,30,1, 1, 2), 1.5781e+004, 1); -%! assert(CellCorners1(62,30,1, 1, 3), -5466.1, 0.1); -%! assert (CellCorners1 == CellCorners2); - - -### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellCorners\n"); -%! ActiveCellCorners1 = riGetActiveCellCorners(); -%! ActiveCellCorners2 = riGetActiveCellCorners(1); -%! ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix"); -%! ActiveCellCorners4 = riGetActiveCellCorners("Matrix"); - -%! assert( ndims (ActiveCellCorners1) == 3); -%! [nactive, cidx, idx ] = size(ActiveCellCorners1); -%! assert(idx == 3); -%! assert(cidx == 8); -%! assert(nactive , rows(riGetActiveCellInfo())); - -%! assert(ActiveCellCorners1(500,1, 1), 3207.2, 0.1); -%! assert(ActiveCellCorners1(500,1, 2), 9080.7, 0.1); -%! assert(ActiveCellCorners1(500,1, 3), -6076.8, 0.1); -%! assert (ActiveCellCorners1 , ActiveCellCorners2); -%! assert (ActiveCellCorners1 , ActiveCellCorners3); -%! assert (ActiveCellCorners1 , ActiveCellCorners4); - -### Vector[WellNames] riGetWellNames([CaseId]) -%!xtest -%! printf ("===== Testing ====> riGetWellNames\n"); -%! WellNames1 = riGetWellNames(); -%! WellNames2 = riGetWellNames(1); -%! assert (rows(WellNames1), 113); -%! assert (rows(WellNames1) == rows(WellNames2)); - -### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep) -%!test -%! printf ("===== Testing ====> riGetWellCells\n"); -%! WellNames1 = riGetWellNames(); -%! WellCellInfos1 = riGetWellCells(1, WellNames1{1}, 3); -%! WellCellInfos2 = riGetWellCells(WellNames1{1}, 3); - - -### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps]) -%!test -%! printf ("===== Testing ====> riGetWellStatus\n"); -%! WellNames1 = riGetWellNames(); -%! WellStatuses1 = riGetWellStatus(1, WellNames1{1}, [1,3]); -%! disp(WellStatuses1(1)); -%! WellStatuses2 = riGetWellStatus( WellNames1{1}, [1,3]); -%! WellStatuses3 = riGetWellStatus(WellNames1{1}); - -endif \ No newline at end of file diff --git a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m b/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m deleted file mode 100644 index ef2855d5ae..0000000000 --- a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m +++ /dev/null @@ -1,154 +0,0 @@ -### The case with caseid 1 has to be selected/active in ResInsight when running this test-script -### Coarsening and Dual porosity is not exercised by this tes yet. We need models - -if (1) -test OctaveInterfaceTest.m -else - -### CaseInfo riGetCurrentCase() -printf ("===== Testing ====> riGetCurrentCase\n"); -caseInfo = riGetCurrentCase(); -disp(caseInfo); - - -### Vector[CaseInfo] riGetSelectedCases() -printf ("===== Testing ====> riGetSelectedCases\n"); -caseInfoVector1 = riGetSelectedCases(); -disp(caseInfoVector1); - -if(0) - -### Vector[CaseGroupInfo] riGetCaseGroups() -printf ("===== Testing ====> riGetCaseGroups\n"); -caseGroupInfoVector = riGetCaseGroups(); - -### Vector[CaseInfo] riGetCases([CaseGroupId]) -printf ("===== Testing ====> riGetCases\n"); -caseinfoVector2 = riGetCases(); -caseinfoVector3 = riGetCases(caseGroupInfoVector(2).CaseGroupId); - -### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] ) -printf ("===== Testing ====> riGetActiveCellInfo\n"); -ACInfo1 = riGetActiveCellInfo(); -ACInfo2 = riGetActiveCellInfo("Matrix"); -ACInfo3 = riGetActiveCellInfo(1, "Matrix"); - -### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId]) -printf ("===== Testing ====> riGetCoarseningInfo\n"); -CoarseInfo1 = riGetCoarseningInfo(); -CoarseInfo2 = riGetCoarseningInfo(1); - -### Matrix[numGrids][3] riGetGridDimensions([CaseId]) -printf ("===== Testing ====> riGetGridDimensions\n"); -GridDims1 = riGetGridDimensions(); -GridDims2 = riGetGridDimensions(1); - -### Vector[TimeStepDate] riGetTimestepDates([CaseId]) -printf ("===== Testing ====> riGetTimestepDates\n"); -TimeStepDates1 = riGetTimeStepDates(); -TimeStepDates2 = riGetTimeStepDates(1); - -### Vector[DecimalDay] riGetTimestepDays([CaseId]) -printf ("===== Testing ====> riGetTimestepDays\n"); -TimeStepDays1 = riGetTimeStepDays(); -TimeStepDays2 = riGetTimeStepDays(1); - -### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetPropertyNames\n"); -PropertyInfos1 = riGetPropertyNames(); -PropertyInfos2 = riGetPropertyNames(1); -PropertyInfos3 = riGetPropertyNames("Matrix"); -PropertyInfos4 = riGetPropertyNames(1, "Matrix"); - -### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellProperty\n"); -ActivePropData1 = riGetActiveCellProperty("SOIL"); -ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix"); -ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]); -ActivePropData4 = riGetActiveCellProperty("SOIL", [1,3], "Matrix"); - -ActivePropData5 = riGetActiveCellProperty(1, "SOIL"); -ActivePropData6 = riGetActiveCellProperty(1, "SOIL", [1,3]); -ActivePropData7 = riGetActiveCellProperty(1, "SOIL", [1,3], "Matrix"); -ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix"); - -### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetGridProperty\n"); -GridProps1 = riGetGridProperty( 0 , "SOIL" ); -GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]); -GridProps3 = riGetGridProperty( 0 , "SOIL", [1,3], "Matrix"); -GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix"); -GridProps5 = riGetGridProperty(1, 0 , "SOIL" ); -GridProps6 = riGetGridProperty(1, 0 , "SOIL", [1,3]); -GridProps7 = riGetGridProperty(1, 0 , "SOIL", [1,3], "Matrix"); -GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix"); - - -### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riSetActiveCellProperty\n"); -riSetActiveCellProperty( ActivePropData1, "PropertyName1" ); - -riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]); -riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix"); -riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); -riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" ); -riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]); -riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix"); -riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); - -### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riSetGridProperty\n"); -riSetGridProperty( GridProps1, 0, "PropertyName11" ); -riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]); -riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix"); -riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); -riSetGridProperty( GridProps1, 1, 0, "PropertyName15" ); -riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]); -riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix"); -riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); - - -### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex) -printf ("===== Testing ====> riGetCellCenters\n"); -CellCenters1 = riGetCellCenters(0); -CellCenters2 = riGetCellCenters(1, 0); - -### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellCenters\n"); -ActiveCellCenters1 = riGetActiveCellCenters(); -ActiveCellCenters2 = riGetActiveCellCenters("Matrix"); -ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix"); - -### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex) -printf ("===== Testing ====> riGetCellCorners\n"); -CellCorners1 = riGetCellCorners(0); -CellCorners2 = riGetCellCorners(1, 0); - -### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellCorners\n"); -ActiveCellCorners1 = riGetActiveCellCorners(); -ActiveCellCorners2 = riGetActiveCellCorners(1); -ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix"); -ActiveCellCorners4 = riGetActiveCellCorners("Matrix"); - -### Vector[WellNames] riGetWellNames([CaseId]) -printf ("===== Testing ====> riGetWellNames\n"); - -WellNames1 = riGetWellNames(); -WellNames2 = riGetWellNames(1); - -### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep) -printf ("===== Testing ====> riGetWellCells\n"); -WellCellInfos1 = riGetWellCells(1, WellNames1(1,:), 3); -WellCellInfos2 = riGetWellCells(WellNames1(1,:), 3); - - -### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps]) -printf ("===== Testing ====> riGetWellStatus\n"); -WellStatuses1 = riGetWellStatus(1, WellNames1(1,:), [1,3]); -disp(WellStatuses1(1)); -WellStatuses2 = riGetWellStatus( WellNames1(1,:), [1,3]); -WellStatuses3 = riGetWellStatus(WellNames1(1,:)); - -endif -endif \ No newline at end of file From 397168df1713ac4434d6ffac96c7ad21c28f9ac3 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 8 Jan 2018 16:07:23 +0100 Subject: [PATCH 0003/1027] #2347 Elm Props: Create new Result Position entry called Element --- ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h | 3 ++- .../ProjectDataModel/RimGeoMechResultDefinition.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h index 5120601f82..242535f750 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h @@ -24,5 +24,6 @@ enum RigFemResultPosEnum { RIG_ELEMENT_NODAL, RIG_INTEGRATION_POINT, RIG_ELEMENT_NODAL_FACE, - RIG_FORMATION_NAMES + RIG_FORMATION_NAMES, + RIG_ELEMENT }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 77decdf994..9831af68a0 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -45,6 +45,7 @@ void caf::AppEnum< RigFemResultPosEnum >::setUp() addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); addItem(RIG_ELEMENT_NODAL_FACE, "ELEMENT_NODAL_FACE", "Element Nodal On Face"); addItem(RIG_FORMATION_NAMES, "FORMATION_NAMES", "Formation Names"); + addItem(RIG_ELEMENT, "ELEMENT", "Element"); setDefault(RIG_NODAL); } } From ab67ddfecb885212ebe90e7107f14d0843d1dbad Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 9 Jan 2018 08:45:47 +0100 Subject: [PATCH 0004/1027] #2348 Elm Props: Import command on case --- ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 399b21c256..92808e2428 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -176,6 +176,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicNewViewFeature"; menuBuilder << "Separator"; + menuBuilder << "RicImportElementPropertyFeature"; + menuBuilder << "Separator"; } else if (dynamic_cast(uiItem)) { From 9513cb61d5402aa201891dbb7cdf938c4ba9d1c0 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 9 Jan 2018 08:46:52 +0100 Subject: [PATCH 0005/1027] #2348 Elm prop: Add ELEMENT to set of valid resultPosTypes --- ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index 02dd5372b0..bcf3a8df8e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -66,7 +66,8 @@ class RigFemResultAddress || resultPosType == RIG_ELEMENT_NODAL || resultPosType == RIG_INTEGRATION_POINT || resultPosType == RIG_ELEMENT_NODAL_FACE - || resultPosType == RIG_FORMATION_NAMES; + || resultPosType == RIG_FORMATION_NAMES + || resultPosType == RIG_ELEMENT; bool isFieldValid = fieldName != ""; return isTypeValid && isFieldValid; From 57ae1953721dfa1af86bb8c9a74e6b9b5f56b3ec Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 9 Jan 2018 09:50:00 +0100 Subject: [PATCH 0006/1027] #2349 Elm Props: Create list of imported files in Geomech Case prop pan --- ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp | 11 +++++++---- ApplicationCode/ProjectDataModel/RimGeoMechCase.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 2032fe6ab1..14a69e2c5f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -60,6 +60,7 @@ RimGeoMechCase::RimGeoMechCase(void) CAF_PDM_InitField(&m_cohesion, "CaseCohesion", 10.0, "Cohesion", "", "Used to calculate the SE:SFI result", ""); CAF_PDM_InitField(&m_frictionAngleDeg, "FrctionAngleDeg", 30.0, "Friction Angle [Deg]", "", "Used to calculate the SE:SFI result", ""); + CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -470,10 +471,12 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add(&caseId); uiOrdering.add(&m_caseFileName); - auto group = uiOrdering.addNewGroup("Case Options"); - group->add(&activeFormationNames); - group->add(&m_cohesion); - group->add(&m_frictionAngleDeg); + caf::PdmUiGroup* caseGroup = uiOrdering.addNewGroup("Case Options"); + caseGroup->add(&activeFormationNames); + caseGroup->add(&m_cohesion); + caseGroup->add(&m_frictionAngleDeg); + caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties"); + elmPropGroup->add(&m_elementPropertyFileNames); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index b16f458535..a0ec1ca691 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -89,4 +89,5 @@ class RimGeoMechCase : public RimCase caf::PdmField m_caseFileName; caf::PdmField m_cohesion; caf::PdmField m_frictionAngleDeg; + caf::PdmField > m_elementPropertyFileNames; }; From cb6d49a61191bf8e8d7c926edf83618daa2f2fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 9 Jan 2018 10:11:28 +0100 Subject: [PATCH 0007/1027] #2331 Renamed RimView to Rim3dView --- .../Application/RiaApplication.cpp | 28 +- ApplicationCode/Application/RiaApplication.h | 16 +- .../RicfComputeCaseGroupStatistics.cpp | 2 +- .../RicfExportProperty.cpp | 2 +- .../RicfExportSimWellCompletions.cpp | 2 +- .../CommandFileInterface/RicfSetTimeStep.cpp | 4 +- .../RicNewFishbonesSubsFeature.cpp | 4 +- .../RicAppendIntersectionFeature.cpp | 4 +- .../RicNewAzimuthDipIntersectionFeature.cpp | 4 +- .../RicNewPolylineIntersectionFeature.cpp | 4 +- .../RicNewWellPathIntersectionFeature.cpp | 4 +- .../RicEclipseHideFaultFeature.cpp | 6 +- .../RicEclipsePropertyFilterFeatureImpl.cpp | 2 +- .../RicEclipsePropertyFilterNewExec.cpp | 4 +- ...cEclipsePropertyFilterNewInViewFeature.cpp | 6 +- .../RicExportMultipleSnapshotsFeature.cpp | 12 +- .../RicExportMultipleSnapshotsFeature.h | 8 +- ...RicSaveEclipseInputVisibleCellsFeature.cpp | 4 +- ...aveEclipseResultAsInputPropertyFeature.cpp | 2 +- .../RicSnapshotAllViewsToFileFeature.cpp | 6 +- .../RicSnapshotFilenameGenerator.cpp | 8 +- .../RicSnapshotFilenameGenerator.h | 6 +- .../RicPlotProductionRateFeature.cpp | 4 +- .../Commands/FlowCommands/RicSelectViewUI.cpp | 2 +- .../RicShowContributingWellsFeature.cpp | 2 +- .../RicShowFlowCharacteristicsPlotFeature.cpp | 6 +- .../RicShowWellAllocationPlotFeature.cpp | 6 +- .../RicAppendIntersectionBoxFeature.cpp | 4 +- .../RicIntersectionBoxAtPosFeature.cpp | 6 +- .../RicIntersectionBoxXSliceFeature.cpp | 6 +- .../RicIntersectionBoxYSliceFeature.cpp | 6 +- .../RicIntersectionBoxZSliceFeature.cpp | 6 +- ...vertAllFractureTemplatesToFieldFeature.cpp | 2 +- ...ertAllFractureTemplatesToMetricFeature.cpp | 2 +- .../RicConvertFractureTemplateUnitFeature.cpp | 2 +- .../Commands/RicDeleteItemExec.cpp | 4 +- .../Commands/RicFlyToObjectFeature.cpp | 4 +- ...cGeoMechPropertyFilterNewInViewFeature.cpp | 6 +- .../Commands/RicGridStatisticsDialog.cpp | 6 +- .../Commands/RicGridStatisticsDialog.h | 8 +- .../RicHideIntersectionBoxFeature.cpp | 6 +- .../Commands/RicHideIntersectionFeature.cpp | 6 +- .../RicImportFormationNamesFeature.cpp | 4 +- .../RicNewSimWellFractureAtPosFeature.cpp | 4 +- .../RicNewSliceRangeFilterFeature.cpp | 6 +- .../Commands/RicNewViewFeature.cpp | 8 +- ApplicationCode/Commands/RicNewViewFeature.h | 4 +- .../Commands/RicRangeFilterFeatureImpl.cpp | 6 +- .../Commands/RicRangeFilterInsertExec.cpp | 2 +- .../Commands/RicRangeFilterNewExec.cpp | 4 +- .../Commands/RicShowGridStatisticsFeature.cpp | 2 +- .../RicTogglePerspectiveViewFeature.cpp | 2 +- ApplicationCode/Commands/RicWellLogTools.cpp | 4 +- ApplicationCode/Commands/RicWellLogTools.h | 4 +- .../RicNewGridTimeHistoryCurveFeature.cpp | 2 +- .../RicViewZoomAllFeature.cpp | 2 +- .../Commands/ViewLink/RicLinkViewFeature.cpp | 8 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 22 +- .../ViewLink/RicLinkVisibleViewsFeature.h | 8 +- .../ViewLink/RicLinkVisibleViewsFeatureUi.cpp | 10 +- .../ViewLink/RicLinkVisibleViewsFeatureUi.h | 10 +- .../ViewLink/RicSetMasterViewFeature.cpp | 8 +- .../ViewLink/RicShowAllLinkedViewsFeature.cpp | 4 +- .../ViewLink/RicShowLinkOptionsFeature.cpp | 6 +- .../ViewLink/RicUnLinkViewFeature.cpp | 6 +- .../WellLogCommands/RicNewPltPlotFeature.cpp | 2 +- .../WellLogCommands/RicNewPltPlotFeature.h | 2 +- .../RicNewWellLogCurveExtractionFeature.cpp | 2 +- .../RicIntersectionViewerEventHandler.cpp | 4 +- .../RicWellPathViewerEventHandler.cpp | 4 +- .../RivFemElmVisibilityCalculator.cpp | 2 +- .../RivFemPartPartMgr.cpp | 2 +- .../RivGeoMechVizLogic.cpp | 2 +- .../RivReservoirViewPartMgr.cpp | 2 +- .../ProjectDataModel/CMakeLists_files.cmake | 4 +- .../RimFishboneWellPathCollection.cpp | 2 +- .../Completions/RimFracture.cpp | 6 +- .../Completions/RimPerforationCollection.cpp | 2 +- .../Rim3dOverlayInfoConfig.cpp | 4 +- .../ProjectDataModel/Rim3dOverlayInfoConfig.h | 6 +- .../ProjectDataModel/Rim3dView.cpp | 1093 +++++++++++++++++ .../{RimView.h => Rim3dView.h} | 6 +- ApplicationCode/ProjectDataModel/RimCase.h | 4 +- .../ProjectDataModel/RimCellRangeFilter.cpp | 6 +- .../RimCellRangeFilterCollection.cpp | 8 +- .../RimCellRangeFilterCollection.h | 4 +- .../RimContextCommandBuilder.cpp | 2 +- .../ProjectDataModel/RimEclipseCase.cpp | 10 +- .../ProjectDataModel/RimEclipseCase.h | 2 +- .../RimEclipsePropertyFilter.cpp | 6 +- .../ProjectDataModel/RimEclipseResultCase.cpp | 2 +- .../RimEclipseResultDefinition.cpp | 6 +- .../ProjectDataModel/RimEclipseView.cpp | 4 +- .../ProjectDataModel/RimEclipseView.h | 4 +- .../ProjectDataModel/RimFormationNames.cpp | 2 +- .../ProjectDataModel/RimGeoMechCase.cpp | 12 +- .../ProjectDataModel/RimGeoMechCase.h | 2 +- .../ProjectDataModel/RimGeoMechCellColors.cpp | 4 +- .../RimGeoMechPropertyFilter.cpp | 2 +- .../RimGeoMechResultDefinition.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.h | 4 +- .../ProjectDataModel/RimGridCollection.cpp | 4 +- .../ProjectDataModel/RimIntersection.cpp | 4 +- .../ProjectDataModel/RimIntersectionBox.cpp | 12 +- .../RimIntersectionCollection.cpp | 6 +- .../ProjectDataModel/RimLegendConfig.cpp | 2 +- .../ProjectDataModel/RimLegendConfig.h | 2 +- .../RimMultiSnapshotDefinition.cpp | 8 +- .../RimMultiSnapshotDefinition.h | 4 +- .../ProjectDataModel/RimProject.cpp | 16 +- ApplicationCode/ProjectDataModel/RimProject.h | 6 +- .../RimPropertyFilterCollection.cpp | 6 +- .../RimTernaryLegendConfig.cpp | 2 +- .../ProjectDataModel/RimViewController.cpp | 26 +- .../ProjectDataModel/RimViewController.h | 12 +- .../ProjectDataModel/RimViewLinker.cpp | 38 +- .../ProjectDataModel/RimViewLinker.h | 26 +- .../ProjectDataModel/RimViewManipulator.cpp | 6 +- .../ProjectDataModel/RimViewManipulator.h | 4 +- .../ProjectDataModel/RimViewWindow.cpp | 4 +- .../RimWellLogExtractionCurve.cpp | 2 +- .../RimWellLogExtractionCurve.h | 4 +- .../RigReservoirGridTools.cpp | 2 +- .../RigReservoirGridTools.h | 4 +- .../RiuExportMultipleSnapshotsWidget.cpp | 4 +- .../UserInterface/RiuMainWindow.cpp | 18 +- .../UserInterface/RiuMdiSubWindow.cpp | 2 +- .../UserInterface/RiuPvtPlotUpdater.cpp | 4 +- .../UserInterface/RiuPvtPlotUpdater.h | 6 +- .../RiuRelativePermeabilityPlotUpdater.cpp | 4 +- .../RiuRelativePermeabilityPlotUpdater.h | 6 +- .../RiuSelectionChangedHandler.cpp | 2 +- .../RiuTimeStepChangedHandler.cpp | 4 +- .../UserInterface/RiuTimeStepChangedHandler.h | 4 +- ApplicationCode/UserInterface/RiuViewer.cpp | 8 +- ApplicationCode/UserInterface/RiuViewer.h | 8 +- .../UserInterface/RiuViewerCommands.cpp | 4 +- .../UserInterface/RiuViewerCommands.h | 6 +- 139 files changed, 1487 insertions(+), 394 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Rim3dView.cpp rename ApplicationCode/ProjectDataModel/{RimView.h => Rim3dView.h} (99%) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 232ee9f0b9..cd1b93099d 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -557,14 +557,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi CVF_ASSERT(cas); caseProgress.setProgressDescription(cas->caseUserDescription()); - std::vector views = cas->views(); + std::vector views = cas->views(); { // To delete the view progress before incrementing the caseProgress caf::ProgressInfo viewProgress(views.size(), "Creating Views"); size_t j; for ( j = 0; j < views.size(); j++ ) { - RimView* riv = views[j]; + Rim3dView* riv = views[j]; CVF_ASSERT(riv); viewProgress.setProgressDescription(riv->name()); @@ -1152,7 +1152,7 @@ void RiaApplication::createInputMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimView* RiaApplication::activeReservoirView() const +const Rim3dView* RiaApplication::activeReservoirView() const { return m_activeReservoirView; } @@ -1160,7 +1160,7 @@ const RimView* RiaApplication::activeReservoirView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RiaApplication::activeReservoirView() +Rim3dView* RiaApplication::activeReservoirView() { return m_activeReservoirView; } @@ -1187,7 +1187,7 @@ RimViewWindow* RiaApplication::activePlotWindow() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaApplication::setActiveReservoirView(RimView* rv) +void RiaApplication::setActiveReservoirView(Rim3dView* rv) { m_activeReservoirView = rv; } @@ -1765,7 +1765,7 @@ void RiaApplication::applyPreferences() this->project()->setScriptDirectories(m_preferences->scriptDirectories()); this->project()->updateConnectedEditors(); - std::vector visibleViews; + std::vector visibleViews; this->project()->allVisibleViews(visibleViews); for (auto view : visibleViews) @@ -2312,7 +2312,7 @@ QString RiaApplication::commandLineParameterHelp() const /// Schedule a creation of the Display model and redraw of the reservoir view /// The redraw will happen as soon as the event loop is entered //-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate) +void RiaApplication::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate) { m_resViewsToUpdate.push_back(resViewToUpdate); @@ -2375,8 +2375,8 @@ void RiaApplication::slotUpdateScheduledDisplayModels() // Compress to remove duplicates // and update dependent views after independent views - std::set independent3DViewsToUpdate; - std::set dependent3DViewsToUpdate; + std::set independent3DViewsToUpdate; + std::set dependent3DViewsToUpdate; for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) { @@ -2388,7 +2388,7 @@ void RiaApplication::slotUpdateScheduledDisplayModels() independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); } - for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) + for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) { if (*it) { @@ -2396,7 +2396,7 @@ void RiaApplication::slotUpdateScheduledDisplayModels() } } - for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) + for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) { if (*it) { @@ -2414,7 +2414,7 @@ void RiaApplication::slotRecalculateCompletionType() { std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); for (RimEclipseCase* eclipseCase : uniqueCases) @@ -2551,11 +2551,11 @@ void RiaApplication::regressionTestConfigureProject() RimCase* cas = projectCases[i]; if (!cas) continue; - std::vector views = cas->views(); + std::vector views = cas->views(); for (size_t j = 0; j < views.size(); j++) { - RimView* riv = views[j]; + Rim3dView* riv = views[j]; if (riv && riv->viewer()) { diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 9c239d83f0..780cc10b48 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -50,7 +50,7 @@ class RimEclipseCase; class RimEclipseView; class RimProject; class RimSummaryPlot; -class RimView; +class Rim3dView; class RimViewWindow; class RimWellLogPlot; class RimWellAllocationPlot; @@ -99,13 +99,13 @@ class RiaApplication : public QApplication void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr); - void setActiveReservoirView(RimView*); - RimView* activeReservoirView(); - const RimView* activeReservoirView() const; + void setActiveReservoirView(Rim3dView*); + Rim3dView* activeReservoirView(); + const Rim3dView* activeReservoirView() const; RimViewWindow* activePlotWindow() const; - void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate); + void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate); void scheduleRecalculateCompletionTypeAndRedrawAllViews(); void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); @@ -234,16 +234,16 @@ private slots: // Friend classes required to have access to slotUpdateScheduledDisplayModels // As snapshots are produced fast in sequence, the feature must have access to force redraw // of scheduled redraws - friend class RimView; + friend class Rim3dView; friend class RicExportMultipleSnapshotsFeature; friend class RiaArgumentParser; private: - caf::PdmPointer m_activeReservoirView; + caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; - std::vector > m_resViewsToUpdate; + std::vector > m_resViewsToUpdate; QTimer* m_resViewUpdateTimer; std::vector > m_eclipseCasesToRecalculate; QTimer* m_recalculateCompletionTypeTimer; diff --git a/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp b/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp index 7754c52a89..115481cc78 100644 --- a/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp +++ b/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp @@ -25,7 +25,7 @@ #include "RimEclipseStatisticsCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimCaseCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaApplication.h" #include "RiaLogging.h" diff --git a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp index 758f1a03b3..325b129b20 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp @@ -88,7 +88,7 @@ void RicfExportProperty::execute() // FIXME : Select correct view? RimEclipseView* view; - for (RimView* v : eclipseCase->views()) + for (Rim3dView* v : eclipseCase->views()) { view = dynamic_cast(v); if (view) break; diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 362d9c6351..08969123bb 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -91,7 +91,7 @@ void RicfExportSimWellCompletions::execute() // FIXME : Select correct view? RimEclipseView* view; - for (RimView* v : exportSettings->caseToApply->views()) + for (Rim3dView* v : exportSettings->caseToApply->views()) { view = dynamic_cast(v); if (view) break; diff --git a/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp b/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp index 12b5434bd5..07630d0cad 100644 --- a/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp +++ b/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp @@ -22,7 +22,7 @@ #include "RimOilField.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseCase.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaApplication.h" #include "RiaLogging.h" @@ -63,7 +63,7 @@ void RicfSetTimeStep::execute() } } - for (RimView* view : eclipseCase->views()) + for (Rim3dView* view : eclipseCase->views()) { view->setCurrentTimeStepAndUpdate(m_timeStepIndex); } diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index 0032938466..93ae30e992 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -28,7 +28,7 @@ #include "RimFishboneWellPathCollection.h" #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -150,7 +150,7 @@ void RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(RimFishbonesCollectio fishboneCollection->firstAncestorOrThisOfTypeAsserted(wellPathColl); wellPathColl->wellPathRadiusScaleFactor = 0.01; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiaApplication* app = RiaApplication::instance(); diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index 71acc20341..01fa08d060 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -21,7 +21,7 @@ #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -102,7 +102,7 @@ void RicAppendIntersectionFeatureCmd::redo() intersection->name = QString("Intersection"); m_intersectionCollection->appendIntersection(intersection); - RimView* view = nullptr; + Rim3dView* view = nullptr; m_intersectionCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 049500112a..47b405c038 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -61,7 +61,7 @@ bool RicNewAzimuthDipIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewAzimuthDipIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection); diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index 7d7ea02d34..e403671f63 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -60,7 +60,7 @@ bool RicNewPolylineIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewPolylineIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection); diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index fcb0a3b455..fbaef46784 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimIntersection.h" #include "RimIntersectionCollection.h" #include "RimWellPath.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -56,7 +56,7 @@ bool RicNewWellPathIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellPathIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; std::vector collection; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp index 633d82576c..7d6396e101 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp @@ -28,7 +28,7 @@ #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigFault.h" #include "RigMainGrid.h" @@ -45,7 +45,7 @@ CAF_CMD_SOURCE_INIT(RicEclipseHideFaultFeature, "RicEclipseHideFaultFeature"); //-------------------------------------------------------------------------------------------------- bool RicEclipseHideFaultFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); @@ -63,7 +63,7 @@ void RicEclipseHideFaultFeature::onActionTriggered(bool isChecked) if (!userData.isNull() && userData.type() == QVariant::List) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index 193f16204c..6d1fb95e72 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -91,7 +91,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert //-------------------------------------------------------------------------------------------------- bool RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable(caf::PdmObjectHandle* object) { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; object->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index d2e652c2eb..0730f40765 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -23,7 +23,7 @@ #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" //-------------------------------------------------------------------------------------------------- @@ -58,7 +58,7 @@ void RicEclipsePropertyFilterNewExec::redo() { RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(m_propertyFilterCollection); - RimView* view = nullptr; + Rim3dView* view = nullptr; m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp index b601566289..ede703b84a 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp @@ -26,7 +26,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterNewInViewFeature, "RicEclipsePropert //-------------------------------------------------------------------------------------------------- bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); @@ -64,7 +64,7 @@ bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicEclipsePropertyFilterNewInViewFeature::onActionTriggered(bool isChecked) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp index f035c88abc..91098d0d63 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp @@ -36,7 +36,7 @@ #include "RimGeoMechView.h" #include "RimMultiSnapshotDefinition.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuExportMultipleSnapshotsWidget.h" #include "RiuViewer.h" @@ -79,7 +79,7 @@ void RicExportMultipleSnapshotsFeature::onActionTriggered(bool isChecked) RiuExportMultipleSnapshotsWidget dlg(nullptr, proj); - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && proj->multiSnapshotDefinitions.size() == 0) { dlg.addSnapshotItemFromActiveView(); @@ -116,7 +116,7 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f { if (!msd->isActive()) continue; - RimView* sourceView = msd->view(); + Rim3dView* sourceView = msd->view(); if (!sourceView) continue; if (!sourceView->viewer()) continue; @@ -178,7 +178,7 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportMultipleSnapshotsFeature::exportViewVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) +void RicExportMultipleSnapshotsFeature::exportViewVariations(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) { if (msd->selectedEclipseResults().size() > 0) { @@ -206,7 +206,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariations(RimView* rimView, R //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) +void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) { RimCase* rimCase = rimView->ownerCase(); CVF_ASSERT(rimCase); @@ -293,7 +293,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicExportMultipleSnapshotsFeature::resultName(RimView* rimView) +QString RicExportMultipleSnapshotsFeature::resultName(Rim3dView* rimView) { if (dynamic_cast(rimView)) { diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h index 8073afbe0d..4d5809c176 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h @@ -22,7 +22,7 @@ class RimMultiSnapshotDefinition; class RimProject; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -39,10 +39,10 @@ class RicExportMultipleSnapshotsFeature : public caf::CmdFeature public: static void exportMultipleSnapshots(const QString& folder, RimProject* project); - static void exportViewVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); + static void exportViewVariations(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); private: - static void exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); - static QString resultName(RimView* rimView); + static void exportViewVariationsToFolder(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); + static QString resultName(Rim3dView* rimView); }; diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp index f8dbf19272..b901e8b549 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp @@ -30,7 +30,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigActiveCellInfo.h" #include "RigEclipseCaseData.h" @@ -174,7 +174,7 @@ void RicSaveEclipseInputActiveVisibleCellsFeature::setupActionLook(QAction* acti //-------------------------------------------------------------------------------------------------- RimEclipseView* RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); return dynamic_cast(activeView); } diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp index 52d4f4a443..6306931474 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp @@ -22,7 +22,7 @@ #include "RicSaveEclipseResultAsInputPropertyExec.h" #include "RimEclipseCellColors.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafSelectionManager.h" #include "cafCmdExecCommandManager.h" diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 48ca2cf578..b1f81b4a08 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -24,7 +24,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimCase.h" #include "Rim3dOverlayInfoConfig.h" @@ -97,11 +97,11 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RimCase* cas = projectCases[i]; if (!cas) continue; - std::vector views = cas->views(); + std::vector views = cas->views(); for (size_t j = 0; j < views.size(); j++) { - RimView* riv = views[j]; + Rim3dView* riv = views[j]; if (riv && riv->viewer()) { diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp index 30edda7a76..2170f39141 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp @@ -19,7 +19,7 @@ #include "RicSnapshotFilenameGenerator.h" #include "RimViewWindow.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimEclipseView.h" #include "RimEclipseCellColors.h" @@ -35,7 +35,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* viewWindow) { { - RimView* view = dynamic_cast(viewWindow); + Rim3dView* view = dynamic_cast(viewWindow); if (view != nullptr) { return generateSnapshotFilenameForRimView(view); @@ -59,7 +59,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* vi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView* rimView) +QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(Rim3dView* rimView) { QStringList timeSteps = rimView->ownerCase()->timeStepStrings(); int timeStep = rimView->currentTimeStep(); @@ -79,7 +79,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSnapshotFilenameGenerator::resultName(RimView * rimView) +QString RicSnapshotFilenameGenerator::resultName(Rim3dView * rimView) { if (dynamic_cast(rimView)) { diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h index 37916b7697..2862d64e3e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h @@ -21,7 +21,7 @@ #include class RimViewWindow; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -32,6 +32,6 @@ class RicSnapshotFilenameGenerator static QString generateSnapshotFileName(RimViewWindow* viewWindow); private: - static QString generateSnapshotFilenameForRimView(RimView* rimView); - static QString resultName(RimView* rimView); + static QString generateSnapshotFilenameForRimView(Rim3dView* rimView); + static QString resultName(Rim3dView* rimView); }; diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index d6b19ae5fb..847628be2a 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -37,7 +37,7 @@ #include "RimSummaryCurveAppearanceCalculator.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaSummaryTools.h" #include "RiuMainPlotWindow.h" @@ -238,7 +238,7 @@ bool RicPlotProductionRateFeature::isInjector(RimSimWellInView* well) RigSimWellData* wRes = well->simWellData(); if (wRes) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; well->firstAncestorOrThisOfTypeAsserted(rimView); int currentTimeStep = rimView->currentTimeStep(); diff --git a/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp b/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp index 158439567a..f645cd9625 100644 --- a/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp @@ -94,7 +94,7 @@ QList RicSelectViewUI::calculateValueOptions(const caf:: { if (m_currentCase) { - for (RimView* v : m_currentCase->views()) + for (Rim3dView* v : m_currentCase->views()) { QIcon icon = v->uiCapability()->uiIcon(); QString displayName = v->name; diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp index 7c3ad6a965..091ec51298 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -94,7 +94,7 @@ void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) { modifiedView->createDisplayModelAndRedraw(); - std::vector viewsToUpdate; + std::vector viewsToUpdate; viewsToUpdate.push_back(modifiedView); RimViewManipulator::applySourceViewCameraOnDestinationViews(eclipseView, viewsToUpdate); diff --git a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp index c42777535e..c335267fb9 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp @@ -30,7 +30,7 @@ #include "RimFlowPlotCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainPlotWindow.h" @@ -40,7 +40,7 @@ CAF_CMD_SOURCE_INIT(RicShowFlowCharacteristicsPlotFeature, "RicShowFlowCharacter RimEclipseResultCase* activeEclipseResultCase() { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); RimEclipseView* eclView = dynamic_cast(activeView); @@ -78,7 +78,7 @@ void RicShowFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecked) { // Make sure flow results for the the active timestep is calculated, to avoid an empty plot { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && eclCase->defaultFlowDiagSolution()->flowDiagResults()) { // Trigger calculation diff --git a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 463242a504..ab4f6d8e8b 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -25,7 +25,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellAllocationPlot.h" #include "RiuMainPlotWindow.h" @@ -57,7 +57,7 @@ bool RicShowWellAllocationPlotFeature::isCommandEnabled() if (wellPathCollection.empty()) return false; - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return false; @@ -91,7 +91,7 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) } else if (wellPathCollection.size() > 0) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index 226292ed97..3d234af256 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -21,7 +21,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "cafCmdExecCommandManager.h" @@ -63,7 +63,7 @@ void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; coll->firstAncestorOrThisOfTypeAsserted(rimView); rimView->showGridCells(false); } diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp index 3ad0570eb5..4cab83feee 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxAtPosFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index fbf17a62e8..3136cba9bc 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxXSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index aea7a5d115..6769bcbbaf 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxYSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index 68d65a23e0..c256eba8ac 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxZSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -66,7 +66,7 @@ void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp index 6934214627..cf63ff6c4e 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp @@ -27,7 +27,7 @@ #include "RimFracture.h" #include "RimFractureExportSettings.h" #include "RimFractureTemplateCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp index 617f91c9f0..e5d4feefaf 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp @@ -27,7 +27,7 @@ #include "RimFracture.h" #include "RimFractureExportSettings.h" #include "RimFractureTemplateCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp index c0e81c537a..3e4e07a2e5 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp @@ -27,7 +27,7 @@ #include "RimEllipseFractureTemplate.h" #include "RimFracture.h" #include "RimFractureExportSettings.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 05d3c6a472..1f39ef9d28 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -33,7 +33,7 @@ #include "RimSimWellInView.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinkerCollection.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -95,7 +95,7 @@ void RicDeleteItemExec::redo() caf::PdmObjectHandle* parentObj = listField->ownerObject(); parentObj->uiCapability()->updateConnectedEditors(); - RimView* view = NULL; + Rim3dView* view = NULL; parentObj->firstAncestorOrThisOfType(view); // Range Filters diff --git a/ApplicationCode/Commands/RicFlyToObjectFeature.cpp b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp index 885a65742b..12c16c2ca3 100644 --- a/ApplicationCode/Commands/RicFlyToObjectFeature.cpp +++ b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "Rim3dPropertiesInterface.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuViewer.h" @@ -59,7 +59,7 @@ bool RicFlyToObjectFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicFlyToObjectFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuViewer* destinationViewer = activeView->viewer(); diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp index 822555def3..fbcc9be75d 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp @@ -26,7 +26,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicGeoMechPropertyFilterNewInViewFeature, "RicGeoMechPropert //-------------------------------------------------------------------------------------------------- bool RicGeoMechPropertyFilterNewInViewFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimGeoMechView* geoMechView = dynamic_cast(view); @@ -62,7 +62,7 @@ bool RicGeoMechPropertyFilterNewInViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicGeoMechPropertyFilterNewInViewFeature::onActionTriggered(bool isChecked) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimGeoMechView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp index 88f9a7edd4..24c7a3838b 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp @@ -115,7 +115,7 @@ void RicGridStatisticsDialog::setLabel(const QString& labelText) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::updateFromRimView(RimView* rimView) +void RicGridStatisticsDialog::updateFromRimView(Rim3dView* rimView) { m_currentRimView = rimView; setInfoText(m_currentRimView); @@ -134,7 +134,7 @@ QImage RicGridStatisticsDialog::screenShotImage() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setInfoText(RimView* view) +void RicGridStatisticsDialog::setInfoText(Rim3dView* view) { Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig(); if (view && overlayInfo) @@ -151,7 +151,7 @@ void RicGridStatisticsDialog::setInfoText(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setHistogramData(RimView* view) +void RicGridStatisticsDialog::setHistogramData(Rim3dView* view) { deletePlotItems(m_historgramPlot); deletePlotItems(m_aggregatedPlot); diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.h b/ApplicationCode/Commands/RicGridStatisticsDialog.h index 06b3c35456..2e9c701d1e 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.h +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.h @@ -46,12 +46,12 @@ class RicGridStatisticsDialog : public QDialog ~RicGridStatisticsDialog(); void setLabel(const QString& labelText); - void updateFromRimView(RimView* rimView); + void updateFromRimView(Rim3dView* rimView); QImage screenShotImage(); private: - void setInfoText(RimView* eclipseView); - void setHistogramData(RimView* eclipseView); + void setInfoText(Rim3dView* eclipseView); + void setHistogramData(Rim3dView* eclipseView); private: void createAndConnectToolbarActions(); @@ -74,5 +74,5 @@ private slots: QwtPlot* m_aggregatedPlot; QDialogButtonBox* m_buttons; - caf::PdmPointer m_currentRimView; + caf::PdmPointer m_currentRimView; }; diff --git a/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp b/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp index 7d3823c7b0..266c8376e6 100644 --- a/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimIntersectionBox.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuSelectionManager.h" @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicHideIntersectionBoxFeature, "RicHideIntersectionBoxFeatur //-------------------------------------------------------------------------------------------------- bool RicHideIntersectionBoxFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); @@ -56,7 +56,7 @@ bool RicHideIntersectionBoxFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicHideIntersectionBoxFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); diff --git a/ApplicationCode/Commands/RicHideIntersectionFeature.cpp b/ApplicationCode/Commands/RicHideIntersectionFeature.cpp index 5dd9f968e1..845432a9f9 100644 --- a/ApplicationCode/Commands/RicHideIntersectionFeature.cpp +++ b/ApplicationCode/Commands/RicHideIntersectionFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimIntersection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuSelectionManager.h" @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicHideIntersectionFeature, "RicHideIntersectionFeature"); //-------------------------------------------------------------------------------------------------- bool RicHideIntersectionFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); @@ -56,7 +56,7 @@ bool RicHideIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicHideIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index aac802428e..0ee5e2f794 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -27,7 +27,7 @@ #include "RimGeoMechCase.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigEclipseCaseData.h" #include "RigFemPartResultsCollection.h" @@ -83,7 +83,7 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) if (!cases.empty()) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); RimCase* ownerCase = activeView->ownerCase(); if (ownerCase) diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp index b2f00babc1..3c055ffa93 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp @@ -30,7 +30,7 @@ #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -49,7 +49,7 @@ CAF_CMD_SOURCE_INIT(RicNewSimWellFractureAtPosFeature, "RicNewSimWellFractureAtP //-------------------------------------------------------------------------------------------------- void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); diff --git a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp index 13aac245b9..64e4462145 100644 --- a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp +++ b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp @@ -23,7 +23,7 @@ #include "RicRangeFilterFeatureImpl.h" #include "RicRangeFilterNewExec.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "cafCmdExecCommandManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewSliceRangeFilterFeature, "RicNewSliceRangeFilterFeatur //-------------------------------------------------------------------------------------------------- bool RicNewSliceRangeFilterFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimViewController* vc = view->viewController(); @@ -57,7 +57,7 @@ void RicNewSliceRangeFilterFeature::onActionTriggered(bool isChecked) if (!userData.isNull() && userData.type() == QVariant::List) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); RimCellRangeFilterCollection* rangeFilterCollection = view->rangeFilterCollection(); RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection); diff --git a/ApplicationCode/Commands/RicNewViewFeature.cpp b/ApplicationCode/Commands/RicNewViewFeature.cpp index 0e0213579e..916f2f10a0 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationCode/Commands/RicNewViewFeature.cpp @@ -23,7 +23,7 @@ #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiaLogging.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewViewFeature, "RicNewViewFeature"); //-------------------------------------------------------------------------------------------------- void RicNewViewFeature::addReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) { - RimView* newView = createReservoirView(eclipseCase, geomCase); + Rim3dView* newView = createReservoirView(eclipseCase, geomCase); if (newView) { @@ -89,9 +89,9 @@ void RicNewViewFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RicNewViewFeature::createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) +Rim3dView* RicNewViewFeature::createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) { - RimView* insertedView = NULL; + Rim3dView* insertedView = NULL; if (eclipseCase) { diff --git a/ApplicationCode/Commands/RicNewViewFeature.h b/ApplicationCode/Commands/RicNewViewFeature.h index a8153086fe..b94dbc1dae 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.h +++ b/ApplicationCode/Commands/RicNewViewFeature.h @@ -25,7 +25,7 @@ class RimEclipseCase; class RimEclipseView; class RimGeoMechCase; class RimGeoMechView; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -44,7 +44,7 @@ class RicNewViewFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ); private: - static RimView* createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase); + static Rim3dView* createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase); static RimEclipseCase* selectedEclipseCase(); static RimGeoMechCase* selectedGeoMechCase(); diff --git a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp index bb10613c7a..de14e5a390 100644 --- a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp @@ -25,7 +25,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "cafSelectionManager.h" @@ -40,7 +40,7 @@ bool RicRangeFilterFeatureImpl::isRangeFilterCommandAvailable() RimCellRangeFilterCollection* rangeFilterCollection = findRangeFilterCollection(); if (!rangeFilterCollection) return false; - RimView* view; + Rim3dView* view; rangeFilterCollection->firstAncestorOrThisOfType(view); if (view) { @@ -86,7 +86,7 @@ RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollecti selectedRangeFilter[0]->firstAncestorOrThisOfType(rangeFilterCollection); } - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (view) { rangeFilterCollection = view->rangeFilterCollection(); diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp index 1e06760071..fd71c5720a 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index f71d4d15ab..06a73ba4da 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -23,7 +23,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" @@ -77,7 +77,7 @@ void RicRangeFilterNewExec::redo() RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); - RimView* view = nullptr; + Rim3dView* view = nullptr; m_cellRangeFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated range filter diff --git a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp index d56a52e3df..510a83d539 100644 --- a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp +++ b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp @@ -50,7 +50,7 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowGridStatisticsFeature::onActionTriggered(bool isChecked) { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { diff --git a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp index 28fff621b1..7e8fa7c21d 100644 --- a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp +++ b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp @@ -20,7 +20,7 @@ #include "RicTogglePerspectiveViewFeature.h" #include "RiuViewer.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiaApplication.h" diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index 32a95c6724..25e1675df3 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -24,7 +24,7 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileChannel.h" #include "RimWellLogFileCurve.h" @@ -173,7 +173,7 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection) +RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection) { CVF_ASSERT(plotTrack); RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve(); diff --git a/ApplicationCode/Commands/RicWellLogTools.h b/ApplicationCode/Commands/RicWellLogTools.h index e3b3ea0fd6..1543a821e3 100644 --- a/ApplicationCode/Commands/RicWellLogTools.h +++ b/ApplicationCode/Commands/RicWellLogTools.h @@ -23,7 +23,7 @@ #include class RimSimWellInView; -class RimView; +class Rim3dView; class RimWellLogExtractionCurve; class RimWellLogFileChannel; class RimWellLogFileCurve; @@ -45,7 +45,7 @@ class RicWellLogTools static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels); static RimWellPath* selectedWellPathWithLogFile(); - static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, + static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection); static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index 9b1a683ea1..e5abd5d6da 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -147,7 +147,7 @@ QString RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName() QString resultName; { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); RimEclipseView* eclView = dynamic_cast(activeView); if (eclView) { diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp index 72aa5f52f6..8e7e903b61 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimSummaryPlot.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewWindow.h" #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" diff --git a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp index bd866b10a8..10933c0ae5 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp @@ -24,7 +24,7 @@ #include "RicLinkVisibleViewsFeature.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinkerCollection.h" #include "RimViewLinker.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicLinkViewFeature, "RicLinkViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicLinkViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimProject* proj = RiaApplication::instance()->project(); @@ -71,10 +71,10 @@ bool RicLinkViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; - std::vector views; + std::vector views; views.push_back(activeView); RicLinkVisibleViewsFeature::linkViews(views); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index 3a2cf3e5df..a765405ca2 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -25,7 +25,7 @@ #include "RimViewController.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -46,8 +46,8 @@ CAF_CMD_SOURCE_INIT(RicLinkVisibleViewsFeature, "RicLinkVisibleViewsFeature"); bool RicLinkVisibleViewsFeature::isCommandEnabled() { RimProject* proj = RiaApplication::instance()->project(); - std::vector visibleViews; - std::vector linkedviews; + std::vector visibleViews; + std::vector linkedviews; proj->allVisibleViews(visibleViews); if (proj->viewLinkerCollection() && proj->viewLinkerCollection()->viewLinker()) @@ -66,7 +66,7 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked) { - std::vector views; + std::vector views; findNotLinkedVisibleViews(views); linkViews(views); @@ -85,7 +85,7 @@ void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) +void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); if (proj->viewLinkerCollection()->viewLinker()) @@ -97,14 +97,14 @@ void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) +void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) { RimProject* proj = RiaApplication::instance()->project(); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; allLinkedViews(alreadyLinkedViews); - std::vector visibleViews; + std::vector visibleViews; proj->allVisibleViews(visibleViews); for (size_t i = 0; i < visibleViews.size(); i++) @@ -128,7 +128,7 @@ void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::linkViews(std::vector& views) +void RicLinkVisibleViewsFeature::linkViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); RimViewLinker* viewLinker = proj->viewLinkerCollection->viewLinker(); @@ -149,7 +149,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) propertyDialog.setWindowIcon(QIcon(":/chain.png")); if (propertyDialog.exec() != QDialog::Accepted) return; - RimView* masterView = featureUi.masterView(); + Rim3dView* masterView = featureUi.masterView(); viewLinker = new RimViewLinker; proj->viewLinkerCollection()->viewLinker = viewLinker; viewLinker->setMasterView(masterView); @@ -157,7 +157,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) for (size_t i = 0; i < views.size(); i++) { - RimView* rimView = views[i]; + Rim3dView* rimView = views[i]; if (rimView == viewLinker->masterView()) continue; viewLinker->addDependentView(rimView); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h index 07a1a954ff..401442a528 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h @@ -23,7 +23,7 @@ #include -class RimView; +class Rim3dView; //================================================================================================== /// @@ -33,7 +33,7 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void linkViews(std::vector &views); + static void linkViews(std::vector &views); protected: // Overrides @@ -44,6 +44,6 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature virtual void setupActionLook(QAction* actionToSetup); private: - void findNotLinkedVisibleViews(std::vector &views); - void allLinkedViews(std::vector& views); + void findNotLinkedVisibleViews(std::vector &views); + void allLinkedViews(std::vector& views); }; diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp index 048e55811f..020071cd11 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimCase.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" CAF_PDM_SOURCE_INIT(RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi"); @@ -40,11 +40,11 @@ RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) +void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) { m_allViews = allViews; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); // Set Active view as master view for (size_t i = 0; i < allViews.size(); i++) @@ -65,7 +65,7 @@ void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allView //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RicLinkVisibleViewsFeatureUi::masterView() +Rim3dView* RicLinkVisibleViewsFeatureUi::masterView() { return m_masterView; } @@ -79,7 +79,7 @@ QList RicLinkVisibleViewsFeatureUi::calculateValueOption if (fieldNeedingOptions == &m_masterView) { - for (RimView* v : m_allViews) + for (Rim3dView* v : m_allViews) { RimCase* rimCase = nullptr; v->firstAncestorOrThisOfType(rimCase); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h index e7b84a20aa..082f052c3f 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h @@ -25,7 +25,7 @@ #include -class RimView; +class Rim3dView; //================================================================================================== /// @@ -37,14 +37,14 @@ class RicLinkVisibleViewsFeatureUi : public caf::PdmObject public: RicLinkVisibleViewsFeatureUi(void); - void setViews(const std::vector& allViews); - RimView* masterView(); + void setViews(const std::vector& allViews); + Rim3dView* masterView(); protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); private: - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; - std::vector m_allViews; + std::vector m_allViews; }; diff --git a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index 50814a3d45..791dd958d6 100644 --- a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicSetMasterViewFeature, "RicSetMasterViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicSetMasterViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimProject* proj = RiaApplication::instance()->project(); @@ -62,7 +62,7 @@ bool RicSetMasterViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicSetMasterViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RimProject* proj = RiaApplication::instance()->project(); @@ -70,7 +70,7 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked) viewLinker->applyRangeFilterCollectionByUserChoice(); - RimView* previousMasterView = viewLinker->masterView(); + Rim3dView* previousMasterView = viewLinker->masterView(); viewLinker->setMasterView(activeView); viewLinker->updateDependentViews(); diff --git a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index cfd8678b77..212fe86afe 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -20,7 +20,7 @@ #include "RicShowAllLinkedViewsFeature.h" #include "RimViewController.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "cafSelectionManager.h" @@ -58,7 +58,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked) for (size_t i = 0; i < linkedViews.size(); i++) { - std::vector views; + std::vector views; linkedViews[i]->allViews(views); for (size_t j = 0; j < views.size(); j++) diff --git a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp index 0c958d247c..4982b889d0 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RiuMainWindow.h" @@ -38,7 +38,7 @@ CAF_CMD_SOURCE_INIT(RicShowLinkOptionsFeature, "RicShowLinkOptionsFeature"); //-------------------------------------------------------------------------------------------------- bool RicShowLinkOptionsFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimViewController* viewController = activeView->viewController(); @@ -56,7 +56,7 @@ bool RicShowLinkOptionsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RimViewController* viewController = activeView->viewController(); diff --git a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp index c56ba64971..38d46eba72 100644 --- a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicUnLinkViewFeature, "RicUnLinkViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicUnLinkViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimViewController* viewController = activeView->viewController(); @@ -58,7 +58,7 @@ bool RicUnLinkViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicUnLinkViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RimViewController* viewController = activeView->viewController(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index 88224e2017..3f70847cd7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -28,7 +28,7 @@ #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogExtractionCurve.h" #include "RimWellPltPlot.h" #include "RimWellLogPlot.h" diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h index 140e7d5b78..28137d38a9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h @@ -22,7 +22,7 @@ #include "cafCmdFeature.h" class RimSimWellInView; -class RimView; +class Rim3dView; class RimWellLogExtractionCurve; class RimWellLogTrack; class RimWellPath; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index df328acf3e..bd4915a7bb 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -29,7 +29,7 @@ #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" diff --git a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp index f7554d6e62..a83dc266f2 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp @@ -18,7 +18,7 @@ #include "RicIntersectionViewerEventHandler.h" #include "RimIntersection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafDisplayCoordTransform.h" #include "cafSelectionManager.h" @@ -49,7 +49,7 @@ bool RicIntersectionViewerEventHandler::handleEvent(cvf::Object* eventObject) { RimIntersection* intersection = selection[0]; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; intersection->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index dd3b3adbe3..6f95204113 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPath.h" #include "RiuMainWindow.h" @@ -56,7 +56,7 @@ bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject) const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast(uiEvent->firstHitPart->sourceInfo()); if (wellPathSourceInfo) { - RimView* rimView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); if (!rimView) return false; cvf::ref transForm = rimView->displayCoordTransform(); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 564d2ffd58..c46bff3f00 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -254,7 +254,7 @@ void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(cvf::UByteAr CVF_ASSERT(elmVisibilities != NULL); CVF_ASSERT(femPart != NULL); - RimView* masterView = masterViewLink->ownerViewLinker()->masterView(); + Rim3dView* masterView = masterViewLink->ownerViewLinker()->masterView(); cvf::ref totCellVisibility = masterView->currentTotalCellVisibility(); int elmCount = femPart->elementCount(); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index ac119ce1c7..890a4f7e24 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -299,7 +299,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe } } - RimView* view = NULL; + Rim3dView* view = NULL; cellResultColors->firstAncestorOrThisOfType(view); CVF_ASSERT(view); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 72c32a601e..da657fbd3e 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -28,7 +28,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RivCellSetEnum.h" diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 254a9bae3f..4c2fd99ea1 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -604,7 +604,7 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c CVF_ASSERT(masterViewLink); - RimView* masterView = masterViewLink->ownerViewLinker()->masterView(); + Rim3dView* masterView = masterViewLink->ownerViewLinker()->masterView(); // get cell visibility #if 1 diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index b0207bc356..4b13d70ed9 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -59,7 +59,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.h ${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h ${CEE_CURRENT_LIST_DIR}RimViewWindow.h -${CEE_CURRENT_LIST_DIR}RimView.h +${CEE_CURRENT_LIST_DIR}Rim3dView.h ${CEE_CURRENT_LIST_DIR}RimViewManipulator.h ${CEE_CURRENT_LIST_DIR}RimCase.h ${CEE_CURRENT_LIST_DIR}RimViewController.h @@ -160,7 +160,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp ${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp -${CEE_CURRENT_LIST_DIR}RimView.cpp +${CEE_CURRENT_LIST_DIR}Rim3dView.cpp ${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp ${CEE_CURRENT_LIST_DIR}RimCase.cpp ${CEE_CURRENT_LIST_DIR}RimViewController.cpp diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp index 9908933ab8..0ad7710f13 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp @@ -22,7 +22,7 @@ #include "RimFishboneWellPath.h" #include "RimFishbonesCollection.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigWellPath.h" diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index f44a3b0d4f..989202e087 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -47,7 +47,7 @@ #include "RimReservoirCellResultsStorage.h" #include "RimStimPlanFractureTemplate.h" #include "RimStimPlanColors.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RivWellFracturePartMgr.h" @@ -80,7 +80,7 @@ void setDefaultFractureColorResult() for (RimEclipseCase* const eclCase : proj->eclipseCases()) { - for (RimView* const view : eclCase->views()) + for (Rim3dView* const view : eclCase->views()) { std::vector fractureColors; view->descendantsIncludingThisOfType(fractureColors); @@ -183,7 +183,7 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons changedField == &dip || changedField == &tilt) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp index 4d90f97f36..59339ad035 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp @@ -21,7 +21,7 @@ #include "RimPerforationInterval.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigWellPath.h" diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 3f1cbfafe3..3222e35a54 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -47,7 +47,7 @@ #include "RimGeoMechView.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimTools.h" #include "RiuViewer.h" @@ -729,7 +729,7 @@ void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView) +void Rim3dOverlayInfoConfig::setReservoirView(Rim3dView* ownerReservoirView) { m_viewDef = ownerReservoirView; } diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 302a6e4eb5..407bada1b0 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -32,7 +32,7 @@ class RimEclipseView; class RimGeoMechView; -class RimView; +class Rim3dView; class RigStatisticsDataCache; class RicGridStatisticsDialog; @@ -67,7 +67,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void update3DInfo(); - void setReservoirView(RimView* ownerView); + void setReservoirView(Rim3dView* ownerView); void setPosition(cvf::Vec2ui position); @@ -120,7 +120,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject caf::PdmField > m_statisticsTimeRange; caf::PdmField > m_statisticsCellRange; - caf::PdmPointer m_viewDef; + caf::PdmPointer m_viewDef; cvf::Vec2ui m_position; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp new file mode 100644 index 0000000000..c2301beed0 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -0,0 +1,1093 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dView.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimGridCollection.h" +#include "RimIntersectionCollection.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimPropertyFilterCollection.h" +#include "RimViewController.h" +#include "RimViewLinker.h" +#include "RimViewLinkerCollection.h" +#include "RimWellPathCollection.h" + +#include "RiuMainWindow.h" +#include "RiuViewer.h" +#include "RiuTimeStepChangedHandler.h" + +#include "cafDisplayCoordTransform.h" +#include "cafFrameAnimationControl.h" +#include "cafPdmObjectFactory.h" + +#include "cvfCamera.h" +#include "cvfModel.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" +#include "cvfScene.h" +#include "cvfViewport.h" + +#include + +#include +#include "cvfTransform.h" + + +namespace caf { + +template<> +void caf::AppEnum< Rim3dView::MeshModeType >::setUp() +{ + addItem(Rim3dView::FULL_MESH, "FULL_MESH", "All"); + addItem(Rim3dView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); + addItem(Rim3dView::NO_MESH, "NO_MESH", "None"); + setDefault(Rim3dView::FULL_MESH); +} + +template<> +void caf::AppEnum< Rim3dView::SurfaceModeType >::setUp() +{ + addItem(Rim3dView::SURFACE, "SURFACE", "All"); + addItem(Rim3dView::FAULTS, "FAULTS", "Faults only"); + addItem(Rim3dView::NO_SURFACE, "NO_SURFACE", "None"); + setDefault(Rim3dView::SURFACE); +} + +} // End namespace caf + + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim3dView, "GenericView"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView::Rim3dView(void) +{ + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + CVF_ASSERT(preferences); + + + CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); + + CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); + cameraPosition.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); + cameraPointOfInterest.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", ""); + + double defaultScaleFactor = preferences->defaultScaleFactorZ; + CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); + + cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); + CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); + + CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); + maximumFrameRate.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", ""); + hasUserRequestedAnimation.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); + m_currentTimeStep.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); + m_overlayInfoConfig->setReservoirView(this); + m_overlayInfoConfig.uiCapability()->setUiHidden(true); + + caf::AppEnum defaultMeshType = NO_MESH; + if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; + CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); + CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", ""); + + CAF_PDM_InitField(&showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); + + CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); + + + CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); + m_rangeFilterCollection.uiCapability()->setUiHidden(true); + m_rangeFilterCollection = new RimCellRangeFilterCollection(); + + CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); + m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); + m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); + m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); + crossSectionCollection.uiCapability()->setUiHidden(true); + crossSectionCollection = new RimIntersectionCollection(); + + CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); + m_gridCollection.uiCapability()->setUiHidden(true); + m_gridCollection = new RimGridCollection(); + + m_previousGridModeMeshLinesWasFaults = false; + + m_crossSectionVizModel = new cvf::ModelBasicList; + m_crossSectionVizModel->setName("CrossSectionModel"); + + m_highlightVizModel = new cvf::ModelBasicList; + m_highlightVizModel->setName("HighlightModel"); + + m_wellPathPipeVizModel = new cvf::ModelBasicList; + m_wellPathPipeVizModel->setName("WellPathPipeModel"); + + this->setAs3DViewMdiWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView::~Rim3dView(void) +{ + RimProject* proj = RiaApplication::instance()->project(); + + if (proj && this->isMasterView()) + { + delete proj->viewLinkerCollection->viewLinker(); + proj->viewLinkerCollection->viewLinker = NULL; + + proj->uiCapability()->updateConnectedEditors(); + } + + RimViewController* vController = this->viewController(); + if (proj && vController) + { + vController->setManagedView(NULL); + vController->ownerViewLinker()->removeViewController(vController); + delete vController; + + proj->uiCapability()->updateConnectedEditors(); + } + + delete this->m_overlayInfoConfig(); + + removeMdiWindowFromMdiArea(); + + deleteViewWidget(); + + delete m_rangeFilterCollection; + delete m_overrideRangeFilterCollection; + delete crossSectionCollection; + delete m_gridCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewer* Rim3dView::viewer() +{ + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Rim3dView::createViewWidget(QWidget* mainWindowParent) +{ + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + m_viewer = new RiuViewer(glFormat, NULL); + m_viewer->setOwnerReservoirView(this); + + return m_viewer->layoutWidget(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateViewWidgetAfterCreation() +{ + m_viewer->setDefaultPerspectiveNearPlaneDistance(10); + + this->resetLegendsInViewer(); + + m_viewer->updateNavigationPolicy(); + m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); + + m_viewer->mainCamera()->setViewMatrix(cameraPosition); + m_viewer->setPointOfInterest(cameraPointOfInterest()); + m_viewer->enableParallelProjection(!isPerspectiveView()); + + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + + this->updateGridBoxData(); + this->updateAnnotationItems(); + this->createHighlightAndGridBoxDisplayModel(); + + m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateMdiWindowTitle() +{ + if (m_viewer) + { + QString windowTitle; + if (ownerCase()) + { + windowTitle = QString("%1 - %2").arg(ownerCase()->caseUserDescription()).arg(name); + } + else + { + windowTitle = name; + } + + m_viewer->layoutWidget()->setWindowTitle(windowTitle); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::deleteViewWidget() +{ + if (m_viewer) + { + m_viewer->deleteLater(); + m_viewer = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); + viewGroup->add(&name); + viewGroup->add(&backgroundColor); + viewGroup->add(&showGridBox); + viewGroup->add(&isPerspectiveView); + viewGroup->add(&m_disableLighting); + + caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Grid Appearance"); + gridGroup->add(&scaleZ); + gridGroup->add(&meshMode); + gridGroup->add(&surfaceMode); + + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QImage Rim3dView::snapshotWindowContent() +{ + if (m_viewer) + { + // Force update of scheduled display models before snapshotting + RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + + m_viewer->repaint(); + + return m_viewer->snapshotImage(); + } + + return QImage(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::scheduleCreateDisplayModelAndRedraw() +{ + RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); + if (this->isMasterView()) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setCurrentTimeStepAndUpdate(int frameIndex) +{ + setCurrentTimeStep(frameIndex); + + this->updateCurrentTimeStep(); + + RimProject* project; + firstAncestorOrThisOfTypeAsserted(project); + project->mainPlotCollection()->updateCurrentTimeStepInPlots(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setCurrentTimeStep(int frameIndex) +{ + const int oldTimeStep = m_currentTimeStep; + + m_currentTimeStep = frameIndex; + clampCurrentTimestep(); + + if (m_currentTimeStep != oldTimeStep) + { + RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); + } + + this->hasUserRequestedAnimation = true; + if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) + { + m_currentReservoirCellVisibility = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateCurrentTimeStepAndRedraw() +{ + this->updateCurrentTimeStep(); + + RimProject* project; + firstAncestorOrThisOfTypeAsserted(project); + project->mainPlotCollection()->updateCurrentTimeStepInPlots(); + + if (m_viewer) m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::createDisplayModelAndRedraw() +{ + if (m_viewer) + { + this->clampCurrentTimestep(); + + createDisplayModel(); + createHighlightAndGridBoxDisplayModel(); + updateDisplayModelVisibility(); + + if (cameraPosition().isIdentity()) + { + setDefaultView(); + cameraPosition = m_viewer->mainCamera()->viewMatrix(); + cameraPointOfInterest = m_viewer->pointOfInterest(); + } + } + + RiuMainWindow::instance()->refreshAnimationActions(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setDefaultView() +{ + if (m_viewer) + { + m_viewer->setDefaultView(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::endAnimation() +{ + this->hasUserRequestedAnimation = false; + this->updateStaticCellColors(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathCollection* Rim3dView::wellPathCollection() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfTypeAsserted(proj); + CVF_ASSERT(proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()); + + return proj->activeOilField()->wellPathCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setupBeforeSave() +{ + if (m_viewer) + { + hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... + cameraPosition = m_viewer->mainCamera()->viewMatrix(); + cameraPointOfInterest = m_viewer->pointOfInterest(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +// Surf: No Fault Surf +// Mesh ------------- +// No F F G +// Fault F F G +// Mesh G G G +// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::isGridVisualizationMode() const +{ + return ( this->surfaceMode() == SURFACE + || this->meshMode() == FULL_MESH); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setMeshOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + meshMode.setValueWithFieldChanged(FULL_MESH); + } + else + { + meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + + surfaceMode.setValueWithFieldChanged(NO_SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setMeshSurfDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + meshMode.setValueWithFieldChanged(FULL_MESH); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + meshMode.setValueWithFieldChanged(FAULTS_MESH); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setFaultMeshSurfDrawstyle() +{ + // Surf: No Fault Surf + // Mesh ------------- + // No FF FF SF + // Fault FF FF SF + // Mesh SF SF SF + if (this->isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + } + + meshMode.setValueWithFieldChanged(FAULTS_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setSurfOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + } + + meshMode.setValueWithFieldChanged(NO_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::showGridCells(bool enableGridCells) +{ + if (!enableGridCells) + { + m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + else + { + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); + } + + m_gridCollection->isActive = enableGridCells; + m_gridCollection->updateConnectedEditors(); + m_gridCollection->updateUiIconFromState(enableGridCells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setSurfaceDrawstyle() +{ + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::disableLighting(bool disable) +{ + m_disableLighting = disable; + updateCurrentTimeStepAndRedraw(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::isLightingDisabled() const +{ + return m_disableLighting(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); + + if (changedField == &meshMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &isPerspectiveView) + { + if (m_viewer) m_viewer->enableParallelProjection(!isPerspectiveView()); + } + else if (changedField == &scaleZ) + { + if (scaleZ < 1) scaleZ = 1; + + this->updateGridBoxData(); + + // Regenerate well paths + RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; + RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; + + crossSectionCollection->updateIntersectionBoxGeometry(); + + if (m_viewer) + { + cvf::Vec3d poi = m_viewer->pointOfInterest(); + cvf::Vec3d eye, dir, up; + eye = m_viewer->mainCamera()->position(); + dir = m_viewer->mainCamera()->direction(); + up = m_viewer->mainCamera()->up(); + + eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]); + poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2); + + m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); + m_viewer->setPointOfInterest(poi); + + updateScaleTransform(); + createDisplayModelAndRedraw(); + + m_viewer->update(); + + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateScaleZ(this, scaleZ); + viewLinker->updateCamera(this); + } + } + + RiuMainWindow::instance()->updateScaleValue(); + } + else if (changedField == &surfaceMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &showGridBox) + { + createHighlightAndGridBoxDisplayModelWithRedraw(); + } + else if (changedField == &m_disableLighting) + { + createDisplayModel(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &name) + { + updateMdiWindowTitle(); + + if (viewController()) + { + viewController()->updateDisplayNameAndIcon(); + viewController()->updateConnectedEditors(); + } + else + { + if (isMasterView()) + { + assosiatedViewLinker()->updateUiNameAndIcon(); + assosiatedViewLinker()->updateConnectedEditors(); + } + } + } + else if (changedField == &m_currentTimeStep) + { + if (m_viewer) + { + m_viewer->update(); + + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateTimeStep(this, m_currentTimeStep); + } + } + } + else if (changedField == &backgroundColor) + { + if (m_viewer != nullptr) + { + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + } + updateGridBoxData(); + updateAnnotationItems(); + } + else if (changedField == &maximumFrameRate) + { + // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? + // !! Should be able to specify legal range for number properties + if (m_viewer) + { + m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!this->ownerCase()) return; + + cvf::ref transForm = displayCoordTransform(); + + wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, + transForm.p()); + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!this->ownerCase()) return; + + cvf::ref transForm = displayCoordTransform(); + + QDateTime currentTimeStamp; + std::vector timeStamps = ownerCase()->timeStepDates(); + if (currentTimeStep() < static_cast(timeStamps.size())) + { + currentTimeStamp = timeStamps[currentTimeStep()]; + } + + wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, + currentTimeStamp, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, + transForm.p()); + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellRangeFilterCollection* Rim3dView::rangeFilterCollection() +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimCellRangeFilterCollection* Rim3dView::rangeFilterCollection() const +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) +{ + if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); + + m_overrideRangeFilterCollection = rfc; + this->scheduleGeometryRegen(RANGE_FILTERED); + this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + this->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setScaleZAndUpdate(double scaleZ) +{ + this->scaleZ = scaleZ; + updateScaleTransform(); + + this->updateGridBoxData(); + + this->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewController* Rim3dView::viewController() const +{ + RimViewController* viewController = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewController = dynamic_cast(reffingObjs[i]); + if (viewController) break; + } + + return viewController; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* Rim3dView::viewLinkerIfMasterView() const +{ + RimViewLinker* viewLinker = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewLinker = dynamic_cast(reffingObjs[i]); + if (viewLinker) break; + } + + return viewLinker; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* Rim3dView::assosiatedViewLinker() const +{ + RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); + if (!viewLinker) + { + RimViewController* viewController = this->viewController(); + if (viewController) + { + viewLinker = viewController->ownerViewLinker(); + } + } + + return viewLinker; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim3dView::currentTotalCellVisibility() +{ + if (m_currentReservoirCellVisibility.isNull()) + { + m_currentReservoirCellVisibility = new cvf::UByteArray; + this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); + } + + return m_currentReservoirCellVisibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::isMasterView() const +{ + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker && this == viewLinker->masterView()) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::hasOverridenRangeFilterCollection() +{ + return m_overrideRangeFilterCollection() != NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::replaceRangeFilterCollectionWithOverride() +{ + RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; + CVF_ASSERT(overrideRfc); + + RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; + if (currentRfc) + { + delete currentRfc; + } + + // Must call removeChildObject() to make sure the object has no parent + // No parent is required when assigning a object into a field + m_overrideRangeFilterCollection.removeChildObject(overrideRfc); + + m_rangeFilterCollection = overrideRfc; + + this->uiCapability()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +{ + std::vector modelsToBeRemoved; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == modelName) + { + modelsToBeRemoved.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + { + scene->removeModel(modelsToBeRemoved[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateGridBoxData() +{ + if (m_viewer) + { + m_viewer->updateGridBoxData(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateAnnotationItems() +{ + if (m_viewer) + { + m_viewer->updateAnnotationItems(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dOverlayInfoConfig* Rim3dView::overlayInfoConfig() const +{ + return m_overlayInfoConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::createHighlightAndGridBoxDisplayModelWithRedraw() +{ + createHighlightAndGridBoxDisplayModel(); + + if (m_viewer) + { + m_viewer->update(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::createHighlightAndGridBoxDisplayModel() +{ + m_viewer->removeStaticModel(m_highlightVizModel.p()); + m_viewer->removeStaticModel(m_viewer->gridBoxModel()); + + m_highlightVizModel->removeAllParts(); + + cvf::Collection parts; + createPartCollectionFromSelection(&parts); + if (parts.size() > 0) + { + for (size_t i = 0; i < parts.size(); i++) + { + m_highlightVizModel->addPart(parts[i].p()); + } + + m_highlightVizModel->updateBoundingBoxesRecursive(); + m_viewer->addStaticModelOnce(m_highlightVizModel.p()); + } + + if (showGridBox) + { + m_viewer->addStaticModelOnce(m_viewer->gridBoxModel()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::showActiveCellsOnly() +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::selectOverlayInfoConfig() +{ + RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::zoomAll() +{ + if (m_viewer) + { + m_viewer->zoomAll(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim3dView::displayCoordTransform() const +{ + cvf::ref coordTrans = new caf::DisplayCoordTransform; + + cvf::Vec3d scale(1.0, 1.0, scaleZ); + coordTrans->setScale(scale); + + RimCase* rimCase = ownerCase(); + if (rimCase) + { + coordTrans->setTranslation(rimCase->displayModelOffset()); + } + + return coordTrans; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Rim3dView::viewWidget() +{ + if ( m_viewer ) return m_viewer->layoutWidget(); + else return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::forceShowWindowOn() +{ + m_showWindow.setValueWithFieldChanged(true); +} + diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h similarity index 99% rename from ApplicationCode/ProjectDataModel/RimView.h rename to ApplicationCode/ProjectDataModel/Rim3dView.h index 8bd337cebb..48f8d4c63a 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -70,12 +70,12 @@ namespace caf /// /// //================================================================================================== -class RimView : public RimViewWindow +class Rim3dView : public RimViewWindow { CAF_PDM_HEADER_INIT; public: - RimView(void); - virtual ~RimView(void); + Rim3dView(void); + virtual ~Rim3dView(void); // 3D Viewer RiuViewer* viewer(); diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 5b151baae6..a7c13d0404 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -29,7 +29,7 @@ #include -class RimView; +class Rim3dView; class RimFormationNames; class RimTimeStepFilter; @@ -49,7 +49,7 @@ class RimCase : public caf::PdmObject caf::PdmPtrField activeFormationNames; - virtual std::vector views() = 0; + virtual std::vector views() = 0; virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index d0538fc992..82c4edc2ee 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -147,7 +147,7 @@ void RimCellRangeFilter::setDefaultValues() const cvf::StructGridInterface* grid = selectedGrid(); - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); @@ -246,7 +246,7 @@ void RimCellRangeFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi this->firstAncestorOrThisOfTypeAsserted(rimCase); const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase); - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); @@ -332,7 +332,7 @@ QList RimCellRangeFilter::calculateValueOptions(const ca //-------------------------------------------------------------------------------------------------- bool RimCellRangeFilter::isRangeFilterControlled() const { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfTypeAsserted(rimView); bool isRangeFilterControlled = false; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index d975e4739c..60fc016f4b 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilterCollection.h" #include "RimCellRangeFilter.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -110,7 +110,7 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter) { - RimView* view = NULL; + Rim3dView* view = NULL; firstAncestorOrThisOfType(view); if (!view) return; @@ -173,9 +173,9 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimCellRangeFilterCollection::baseView() const +Rim3dView* RimCellRangeFilterCollection::baseView() const { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; firstAncestorOrThisOfType(rimView); return rimView; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h index 00983fd659..57c65d6dbf 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h @@ -22,7 +22,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" -class RimView; +class Rim3dView; class RimCellRangeFilter; namespace cvf { @@ -58,5 +58,5 @@ class RimCellRangeFilterCollection : public caf::PdmObject virtual caf::PdmFieldHandle* objectToggleField(); private: - RimView* baseView() const; + Rim3dView* baseView() const; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 399b21c256..82f6fd3154 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -531,7 +531,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() #endif // USE_PROTOTYPE_FEATURE_FRACTURES - if (dynamic_cast(uiItem)) + if (dynamic_cast(uiItem)) { menuBuilder << "Separator"; menuBuilder << "RicLinkVisibleViewsFeature"; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index d5a68c1d81..f04988b310 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -266,7 +266,7 @@ void RimEclipseCase::recalculateCompletionTypeAndRedrawAllViews() { results(RiaDefines::MATRIX_MODEL)->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); - for (RimView* view : views()) + for (Rim3dView* view : views()) { RimEclipseView* eclipseView = dynamic_cast(view); if (eclipseView) @@ -329,8 +329,8 @@ void RimEclipseCase::updateFormationNamesData() { rigEclipseCase->setActiveFormationNames(nullptr); } - std::vector views = this->views(); - for(RimView* view : views) + std::vector views = this->views(); + for(Rim3dView* view : views) { RimEclipseView* eclView = dynamic_cast(view); @@ -655,9 +655,9 @@ bool RimEclipseCase::openReserviorCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEclipseCase::views() +std::vector RimEclipseCase::views() { - std::vector views; + std::vector views; for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx) { views.push_back(reservoirViews[vIdx]); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 5e8710df62..bba69a056c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -91,7 +91,7 @@ class RimEclipseCase : public RimCase RimCaseCollection* parentCaseCollection(); - virtual std::vector views(); + virtual std::vector views(); virtual QStringList timeStepStrings() const override; virtual QString timeStepName(int frameIdx) const override; virtual std::vector timeStepDates() const override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index 497ad0fc3d..c3ea14ccd4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -267,7 +267,7 @@ void RimEclipsePropertyFilter::updateRangeLabel() //-------------------------------------------------------------------------------------------------- bool RimEclipsePropertyFilter::isPropertyFilterControlled() { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfTypeAsserted(rimView); bool isPropertyFilterControlled = false; @@ -350,7 +350,7 @@ void RimEclipsePropertyFilter::computeResultValueRange() if (resultDefinition->isFlowDiagOrInjectionFlooding()) { - RimView* view; + Rim3dView* view; this->firstAncestorOrThisOfType(view); int timeStep = 0; @@ -446,7 +446,7 @@ void RimEclipsePropertyFilter::updateFromCurrentTimeStep() clearCategories(); - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfTypeAsserted(view); int timeStep = view->currentTimeStep(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 6f4a067b95..f5a3e976d7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -306,7 +306,7 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() if (!hasSourSimFile()) { // Deselect SourSimRL cell results - for (RimView* view : views()) + for (Rim3dView* view : views()) { RimEclipseView* eclipseView = dynamic_cast(view); if (eclipseView != nullptr) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 52bdcbcbd1..4003913ba9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -35,7 +35,7 @@ #include "RimFlowDiagSolution.h" #include "RimPlotCurve.h" #include "RimReservoirCellResultsStorage.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "RimGridTimeHistoryCurve.h" #include "RimWellLogExtractionCurve.h" @@ -377,7 +377,7 @@ void RimEclipseResultDefinition::assignFlowSolutionFromCase() //-------------------------------------------------------------------------------------------------- void RimEclipseResultDefinition::loadDataAndUpdate() { - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); loadResult(); @@ -737,7 +737,7 @@ RigFlowDiagResultAddress RimEclipseResultDefinition::flowDiagResAddress() const { size_t timeStep = 0; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index c2d86ec21b..ee1a547c46 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -215,7 +215,7 @@ void RimEclipseView::setVisibleGridPartsWatertight() //-------------------------------------------------------------------------------------------------- void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimView::fieldChangedByUi(changedField, oldValue, newValue); + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); if (changedField == &showInvalidCells) { @@ -1449,7 +1449,7 @@ const std::vector& RimEclipseView::visibleGridParts() const //-------------------------------------------------------------------------------------------------- void RimEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimView::defineUiOrdering(uiConfigName, uiOrdering); + Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup("Cell Visibility"); cellGroup->add(&showMainGrid); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index ddc07daabd..cb423fc2df 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -33,7 +33,7 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" -#include "RimView.h" +#include "Rim3dView.h" class RigActiveCellInfo; class RigCaseCellResultsData; @@ -81,7 +81,7 @@ enum PartRenderMaskEnum /// /// //================================================================================================== -class RimEclipseView : public RimView +class RimEclipseView : public Rim3dView { CAF_PDM_HEADER_INIT; public: diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index 5d91738cb7..803b63caac 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -22,7 +22,7 @@ #include "RimCase.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafPdmUiFilePathEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 2032fe6ab1..a0c601f767 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -194,9 +194,9 @@ void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPat //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGeoMechCase::views() +std::vector RimGeoMechCase::views() { - std::vector views; + std::vector views; for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx) { views.push_back(geoMechViews[vIdx]); @@ -360,8 +360,8 @@ void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c rigCaseData->femPartResults()->setCalculationParameters(m_cohesion(), cvf::Math::toRadians(m_frictionAngleDeg())); } - std::vector views = this->views(); - for ( RimView* view : views ) + std::vector views = this->views(); + for ( Rim3dView* view : views ) { if ( view ) // Todo: only those using the variable actively { @@ -388,8 +388,8 @@ void RimGeoMechCase::updateFormationNamesData() rigCaseData->femPartResults()->setActiveFormationNames(nullptr); } - std::vector views = this->views(); - for(RimView* view : views) + std::vector views = this->views(); + for(Rim3dView* view : views) { RimGeoMechView* geomView = dynamic_cast(view); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index b16f458535..4622201fde 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -56,7 +56,7 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); - virtual std::vector views(); + virtual std::vector views(); virtual std::vector timeStepDates() const override; virtual QStringList timeStepStrings() const override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index 6798c2e7ef..5901632e3e 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -20,7 +20,7 @@ #include "RimGeoMechCellColors.h" #include "RimLegendConfig.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -51,7 +51,7 @@ RimGeoMechCellColors::~RimGeoMechCellColors(void) //-------------------------------------------------------------------------------------------------- void RimGeoMechCellColors::updateIconState() { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp index c12847f834..b8d7fcb25c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -193,7 +193,7 @@ bool RimGeoMechPropertyFilter::isPropertyFilterControlled() { bool isPropertyFilterControlled = false; - RimView* rimView = NULL; + Rim3dView* rimView = NULL; firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); if (rimView) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 77decdf994..3610cf3d1a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -212,7 +212,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha // Get the possible property filter owner RimGeoMechPropertyFilter* propFilter = dynamic_cast(this->parentField()->ownerObject()); - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index f318180a83..c56cb95534 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -490,7 +490,7 @@ cvf::Transform* RimGeoMechView::scaleTransform() //-------------------------------------------------------------------------------------------------- void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimView::fieldChangedByUi(changedField, oldValue, newValue); + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index a432329ed3..34f14985b5 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -19,7 +19,7 @@ #pragma once -#include "RimView.h" +#include "Rim3dView.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -51,7 +51,7 @@ namespace cvf { /// /// //================================================================================================== -class RimGeoMechView : public RimView +class RimGeoMechView : public Rim3dView { CAF_PDM_HEADER_INIT; diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 051aa6eef5..06cdc79cc8 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGridCollection.h" -#include "RimView.h" +#include "Rim3dView.h" CAF_PDM_SOURCE_INIT(RimGridCollection, "GridCollection"); @@ -57,7 +57,7 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (changedField == &isActive) { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 06344c2cc0..c7bc4f3c29 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -32,7 +32,7 @@ #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPath.h" #include "RiuViewer.h" @@ -845,7 +845,7 @@ void RimIntersection::rebuildGeometryAndScheduleCreateDisplayModel() { m_crossSectionPartMgr = nullptr; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp index 7b6d6b8b5a..fe37b088c4 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp @@ -20,7 +20,7 @@ #include "RimCase.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "IntersectionBoxCommands/RicBoxManipulatorEventHandler.h" @@ -318,7 +318,7 @@ void RimIntersectionBox::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel { if (m_boxManipulator) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) @@ -345,7 +345,7 @@ void RimIntersectionBox::updateBoxManipulatorGeometry() { if (m_boxManipulator.isNull()) return; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (!rimView) return; @@ -470,7 +470,7 @@ void RimIntersectionBox::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimIntersectionBox::slotScheduleRedraw() { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; this->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -483,7 +483,7 @@ void RimIntersectionBox::slotScheduleRedraw() //-------------------------------------------------------------------------------------------------- void RimIntersectionBox::slotUpdateGeometry(const cvf::Vec3d& origin, const cvf::Vec3d& size) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) @@ -654,7 +654,7 @@ cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() //-------------------------------------------------------------------------------------------------- RiuViewer* RimIntersectionBox::viewer() { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); RiuViewer* riuViewer = nullptr; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index eaebab0d58..bdbc82d0e5 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -22,7 +22,7 @@ #include "RimIntersection.h" #include "RimIntersectionBox.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" @@ -156,7 +156,7 @@ void RimIntersectionCollection::appendIntersection(RimIntersection* intersection updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersection); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; firstAncestorOrThisOfType(rimView); if (rimView) { @@ -179,7 +179,7 @@ void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* chan { if (changedField == &isActive) { - RimView* rimView = NULL; + Rim3dView* rimView = NULL; firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 0207ce94d2..9cb5b85d36 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -191,7 +191,7 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateLegend(); - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 072f66b8ad..2755264acf 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -46,7 +46,7 @@ namespace caf class CategoryMapper; } -class RimView; +class Rim3dView; //================================================================================================== /// diff --git a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp index 0e9bc19aaa..d3075e792c 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp @@ -29,7 +29,7 @@ #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafPdmPointer.h" @@ -92,7 +92,7 @@ QList RimMultiSnapshotDefinition::calculateValueOptions( { options.push_back(caf::PdmOptionItemInfo("None", nullptr)); - std::vector views; + std::vector views; RimProject* proj = RiaApplication::instance()->project(); std::vector cases; @@ -100,13 +100,13 @@ QList RimMultiSnapshotDefinition::calculateValueOptions( for (RimCase* rimCase : cases) { - for (RimView* rimView : rimCase->views()) + for (Rim3dView* rimView : rimCase->views()) { views.push_back(rimView); } } - for (RimView* view : views) + for (Rim3dView* view : views) { QString caseAndView = view->ownerCase()->caseUserDescription() + " - " + view->name(); options.push_back(caf::PdmOptionItemInfo(caseAndView, view)); diff --git a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h index 6b32dec272..cbfc10d715 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h @@ -27,7 +27,7 @@ #include "cafPdmPtrArrayField.h" class RimCase; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -42,7 +42,7 @@ class RimMultiSnapshotDefinition : public caf::PdmObject caf::PdmField isActive; - caf::PdmPtrField view; + caf::PdmPtrField view; caf::PdmField< caf::AppEnum< RiaDefines::ResultCatType > > eclipseResultType; caf::PdmField< std::vector > selectedEclipseResults; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 4f435d01d1..34cedabbc3 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -58,7 +58,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimWellLogFile.h" @@ -597,12 +597,12 @@ std::vector RimProject::allSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allNotLinkedViews(std::vector& views) +void RimProject::allNotLinkedViews(std::vector& views) { std::vector cases; allCases(cases); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; if (viewLinkerCollection->viewLinker()) { viewLinkerCollection->viewLinker()->allViews(alreadyLinkedViews); @@ -613,7 +613,7 @@ void RimProject::allNotLinkedViews(std::vector& views) RimCase* rimCase = cases[caseIdx]; if (!rimCase) continue; - std::vector caseViews = rimCase->views(); + std::vector caseViews = rimCase->views(); for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++) { bool isLinked = false; @@ -635,7 +635,7 @@ void RimProject::allNotLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleViews(std::vector& views) +void RimProject::allVisibleViews(std::vector& views) { std::vector cases; allCases(cases); @@ -645,7 +645,7 @@ void RimProject::allVisibleViews(std::vector& views) RimCase* rimCase = cases[caseIdx]; if (!rimCase) continue; - std::vector caseViews = rimCase->views(); + std::vector caseViews = rimCase->views(); for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++) { if (caseViews[viewIdx] && caseViews[viewIdx]->viewer()) @@ -667,7 +667,7 @@ void RimProject::createDisplayModelAndRedrawAllViews() { RimCase* rimCase = cases[caseIdx]; if (rimCase == NULL) continue; - std::vector views = rimCase->views(); + std::vector views = rimCase->views(); for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) { @@ -948,7 +948,7 @@ std::vector RimProject::allFractureTemplates() const //-------------------------------------------------------------------------------------------------- void RimProject::reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclipseCase) { - std::vector views = eclipseCase->views(); + std::vector views = eclipseCase->views(); for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) { diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index b8dc8c3b3b..677a7bd75a 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -47,7 +47,7 @@ class RimObservedData; class RimOilField; class RimScriptCollection; class RimSummaryCase; -class RimView; +class Rim3dView; class RimViewLinker; class RimViewLinkerCollection; class RimWellPath; @@ -106,8 +106,8 @@ class RimProject : public caf::PdmDocument std::vector allSummaryCases() const; - void allNotLinkedViews(std::vector& views); - void allVisibleViews(std::vector& views); + void allNotLinkedViews(std::vector& views); + void allVisibleViews(std::vector& views); void createDisplayModelAndRedrawAllViews(); diff --git a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp index fb083d3eb4..3440d6614b 100644 --- a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPropertyFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimPropertyFilterCollection, "RimPropertyFilterCollection"); // Abstract class @@ -46,7 +46,7 @@ RimPropertyFilterCollection::~RimPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews() const { - RimView* view = NULL; + Rim3dView* view = NULL; this->firstAncestorOrThisOfType(view); CVF_ASSERT(view); if (!view) return; @@ -83,7 +83,7 @@ void RimPropertyFilterCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& u { PdmObject::defineUiTreeOrdering(uiTreeOrdering, uiConfigName); - RimView* rimView = NULL; + Rim3dView* rimView = NULL; this->firstAncestorOrThisOfType(rimView); RimViewController* viewController = rimView->viewController(); if (viewController && (viewController->isPropertyFilterOveridden() diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index ccc902c53f..3df9ac7d55 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -145,7 +145,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed updateLabelText(); updateLegend(); - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index fa28191803..eb3a407a64 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -39,7 +39,7 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -101,7 +101,7 @@ QList RimViewController::calculateValueOptions(const caf if (fieldNeedingOptions == &m_managedView) { RimProject* proj = RiaApplication::instance()->project(); - std::vector views; + std::vector views; proj->allNotLinkedViews(views); // Add currently linked view to list @@ -114,7 +114,7 @@ QList RimViewController::calculateValueOptions(const caf this->firstAncestorOrThisOfType(viewLinker); CVF_ASSERT(viewLinker); - for (RimView* view : views) + for (Rim3dView* view : views) { if (view != viewLinker->masterView()) { @@ -212,7 +212,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField else if (changedField == &m_managedView) { PdmObjectHandle* prevValue = oldValue.value >().rawPtr(); - RimView* previousManagedView = dynamic_cast(prevValue); + Rim3dView* previousManagedView = dynamic_cast(prevValue); RimViewController::removeOverrides(previousManagedView); setManagedView(m_managedView()); @@ -232,7 +232,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- RimEclipseView* RimViewController::managedEclipseView() const { - RimView* rimView = m_managedView; + Rim3dView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -242,7 +242,7 @@ RimEclipseView* RimViewController::managedEclipseView() const //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimViewController::managedGeoView() const { - RimView* rimView = m_managedView; + Rim3dView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -254,7 +254,7 @@ void RimViewController::updateOverrides() { RimViewLinker* viewLinker = ownerViewLinker(); - RimView* masterView = viewLinker->masterView(); + Rim3dView* masterView = viewLinker->masterView(); CVF_ASSERT(masterView); @@ -343,7 +343,7 @@ void RimViewController::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::removeOverrides(RimView* view) +void RimViewController::removeOverrides(Rim3dView* view) { if (view) { @@ -362,7 +362,7 @@ void RimViewController::removeOverrides(RimView* view) //-------------------------------------------------------------------------------------------------- void RimViewController::updateOptionSensitivity() { - RimView* mainView = nullptr; + Rim3dView* mainView = nullptr; { RimViewLinker* linkedViews = nullptr; @@ -448,7 +448,7 @@ void RimViewController::updateOptionSensitivity() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewController::managedView() const +Rim3dView* RimViewController::managedView() const { return m_managedView; } @@ -456,7 +456,7 @@ RimView* RimViewController::managedView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::setManagedView(RimView* view) +void RimViewController::setManagedView(Rim3dView* view) { m_managedView = view; @@ -644,7 +644,7 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewController::masterView() const +Rim3dView* RimViewController::masterView() const { return ownerViewLinker()->masterView(); } @@ -1041,7 +1041,7 @@ void RimViewController::applyRangeFilterCollectionByUserChoice() //-------------------------------------------------------------------------------------------------- bool RimViewController::askUserToRestoreOriginalRangeFilterCollection(const QString& viewName) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); QMessageBox msgBox(activeView->viewer()->layoutWidget()); msgBox.setIcon(QMessageBox::Question); diff --git a/ApplicationCode/ProjectDataModel/RimViewController.h b/ApplicationCode/ProjectDataModel/RimViewController.h index e8eda82175..9bc3d233d3 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.h +++ b/ApplicationCode/ProjectDataModel/RimViewController.h @@ -28,7 +28,7 @@ #include "RivCellSetEnum.h" -class RimView; +class Rim3dView; class RimEclipseView; class RimGeoMechView; class RimViewLinker; @@ -49,10 +49,10 @@ class RimViewController : public caf::PdmObject bool isActive() const; - RimView* managedView() const; - void setManagedView(RimView* view); + Rim3dView* managedView() const; + void setManagedView(Rim3dView* view); - RimView* masterView() const; + Rim3dView* masterView() const; RimViewLinker* ownerViewLinker() const; const RigCaseToCaseCellMapper* cellMapper(); @@ -102,12 +102,12 @@ class RimViewController : public caf::PdmObject RimEclipseView* managedEclipseView() const; RimGeoMechView* managedGeoView() const; - static void removeOverrides(RimView* view); + static void removeOverrides(Rim3dView* view); static bool askUserToRestoreOriginalRangeFilterCollection(const QString& viewName); private: caf::PdmField m_name; - caf::PdmPtrField m_managedView; + caf::PdmPtrField m_managedView; caf::PdmField m_isActive; caf::PdmField m_syncCamera; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index ae2cb4687a..bd2b508adc 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -36,7 +36,7 @@ #include "RimLegendConfig.h" #include "RimProject.h" #include "RimTernaryLegendConfig.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinkerCollection.h" #include "RimViewManipulator.h" @@ -83,7 +83,7 @@ RimViewLinker::~RimViewLinker(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep) +void RimViewLinker::updateTimeStep(Rim3dView* sourceView, int timeStep) { CVF_ASSERT(sourceView); @@ -125,7 +125,7 @@ void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep) //-------------------------------------------------------------------------------------------------- void RimViewLinker::updateCellResult() { - RimView* rimView = m_masterView; + Rim3dView* rimView = m_masterView; RimEclipseView* masterEclipseView = dynamic_cast(rimView); if (masterEclipseView && masterEclipseView->cellResult()) { @@ -137,7 +137,7 @@ void RimViewLinker::updateCellResult() if (viewLink->managedView()) { - RimView* rimView = viewLink->managedView(); + Rim3dView* rimView = viewLink->managedView(); RimEclipseView* eclipseView = dynamic_cast(rimView); if (eclipseView) { @@ -175,7 +175,7 @@ void RimViewLinker::updateCellResult() if (viewLink->managedView()) { - RimView* rimView = viewLink->managedView(); + Rim3dView* rimView = viewLink->managedView(); RimGeoMechView* geoView = dynamic_cast(rimView); if (geoView) { @@ -247,7 +247,7 @@ void RimViewLinker::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViewsForCameraSync(const RimView* source, std::vector& views) const +void RimViewLinker::allViewsForCameraSync(const Rim3dView* source, std::vector& views) const { if (!isActive()) return; @@ -283,7 +283,7 @@ void RimViewLinker::updateDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimViewLinker::displayNameForView(RimView* view) +QString RimViewLinker::displayNameForView(Rim3dView* view) { QString displayName = "None"; @@ -303,7 +303,7 @@ QString RimViewLinker::displayNameForView(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::setMasterView(RimView* view) +void RimViewLinker::setMasterView(Rim3dView* view) { RimViewController* previousViewController = view->viewController(); @@ -324,7 +324,7 @@ void RimViewLinker::setMasterView(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewLinker::masterView() const +Rim3dView* RimViewLinker::masterView() const { return m_masterView; } @@ -332,7 +332,7 @@ RimView* RimViewLinker::masterView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViews(std::vector& views) const +void RimViewLinker::allViews(std::vector& views) const { views.push_back(m_masterView()); @@ -356,7 +356,7 @@ void RimViewLinker::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ) +void RimViewLinker::updateScaleZ(Rim3dView* sourceView, double scaleZ) { if (!isActive()) return; @@ -371,7 +371,7 @@ void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ) } } - std::vector views; + std::vector views; allViewsForCameraSync(sourceView, views); // Make sure scale factors are identical @@ -454,7 +454,7 @@ void RimViewLinker::scheduleCreateDisplayModelAndRedrawForDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* view) +void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, Rim3dView* view) { CVF_ASSERT(name && icon); @@ -487,7 +487,7 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord) +void RimViewLinker::updateCursorPosition(const Rim3dView* sourceView, const cvf::Vec3d& domainCoord) { RimViewController* sourceViewLink = sourceView->viewController(); if (sourceViewLink && !sourceViewLink->showCursor()) @@ -495,10 +495,10 @@ void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::V return; } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); - for (RimView* destinationView : viewsToUpdate) + for (Rim3dView* destinationView : viewsToUpdate) { if (destinationView == sourceView) continue; @@ -521,7 +521,7 @@ void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::V //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCamera(RimView* sourceView) +void RimViewLinker::updateCamera(Rim3dView* sourceView) { if (!sourceView->viewer()) return; @@ -536,7 +536,7 @@ void RimViewLinker::updateCamera(RimView* sourceView) } } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); RimViewManipulator::applySourceViewCameraOnDestinationViews(sourceView, viewsToUpdate); @@ -545,7 +545,7 @@ void RimViewLinker::updateCamera(RimView* sourceView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::addDependentView(RimView* view) +void RimViewLinker::addDependentView(Rim3dView* view) { CVF_ASSERT(view && view != m_masterView); diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.h b/ApplicationCode/ProjectDataModel/RimViewLinker.h index 39df28f97b..d3cfd07400 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.h +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.h @@ -36,7 +36,7 @@ namespace cvf class RimViewController; class RiuViewer; -class RimView; +class Rim3dView; class RimCellRangeFilter; //================================================================================================== @@ -53,18 +53,18 @@ class RimViewLinker : public caf::PdmObject bool isActive() const; - void setMasterView(RimView* view); - RimView* masterView() const; + void setMasterView(Rim3dView* view); + Rim3dView* masterView() const; - void addDependentView(RimView* view); + void addDependentView(Rim3dView* view); void updateDependentViews(); void removeViewController(RimViewController* viewController); void updateOverrides(); - void updateCamera(RimView* sourceView); - void updateTimeStep(RimView* sourceView, int timeStep); - void updateScaleZ(RimView* sourceView, double scaleZ); + void updateCamera(Rim3dView* sourceView); + void updateTimeStep(Rim3dView* sourceView, int timeStep); + void updateScaleZ(Rim3dView* sourceView, double scaleZ); void updateCellResult(); @@ -74,32 +74,32 @@ class RimViewLinker : public caf::PdmObject void scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType); void scheduleCreateDisplayModelAndRedrawForDependentViews(); - void allViews(std::vector& views) const; + void allViews(std::vector& views) const; void updateUiNameAndIcon(); void addViewControllers(caf::PdmUiTreeOrdering& uiTreeOrdering) const; static void applyIconEnabledState(caf::PdmObject* obj, const QIcon& icon, bool disable); - static void findNameAndIconFromView(QString* name, QIcon* icon, RimView* view); + static void findNameAndIconFromView(QString* name, QIcon* icon, Rim3dView* view); - void updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord); + void updateCursorPosition(const Rim3dView* sourceView, const cvf::Vec3d& domainCoord); public: - static QString displayNameForView(RimView* view); + static QString displayNameForView(Rim3dView* view); protected: virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } virtual void initAfterRead(); private: - void allViewsForCameraSync(const RimView* source, std::vector& views) const; + void allViewsForCameraSync(const Rim3dView* source, std::vector& views) const; void removeOverrides(); private: caf::PdmChildArrayField m_viewControllers; - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; caf::PdmField m_name; QIcon m_originalIcon; }; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp index ac8712139c..664c90e8e2 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp @@ -21,7 +21,7 @@ #include "RigMainGrid.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RiuViewer.h" @@ -35,7 +35,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimView* sourceView, std::vector& destinationViews) +void RimViewManipulator::applySourceViewCameraOnDestinationViews(Rim3dView* sourceView, std::vector& destinationViews) { bool setPointOfInterest = false; cvf::Vec3d sourceCamUp; @@ -72,7 +72,7 @@ void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimView* source sourceSceneBB.transform(trans); } - for (RimView* destinationView : destinationViews) + for (Rim3dView* destinationView : destinationViews) { if (!destinationView) continue; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.h b/ApplicationCode/ProjectDataModel/RimViewManipulator.h index 0c6ee4026e..4263534bad 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.h +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.h @@ -24,12 +24,12 @@ namespace cvf { class BoundingBox; } -class RimView; +class Rim3dView; class RimViewManipulator { public: - static void applySourceViewCameraOnDestinationViews(RimView* sourceView, std::vector& destinationViews); + static void applySourceViewCameraOnDestinationViews(Rim3dView* sourceView, std::vector& destinationViews); private: static bool isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB, const cvf::BoundingBox& destBB); diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index c9d7bf5d03..68e4ed20ef 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -198,7 +198,7 @@ void RimViewWindow::setAsMdiWindow(int mainWindowID) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#include "RimView.h" +#include "Rim3dView.h" void RimViewWindow::initAfterRead() { @@ -207,7 +207,7 @@ void RimViewWindow::initAfterRead() RimMdiWindowGeometry wg; int mainWindowID = -1; - if (dynamic_cast (this)) + if (dynamic_cast (this)) mainWindowID = 0; else mainWindowID = 1; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 24f8822ecf..3d1bb5b95e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -183,7 +183,7 @@ RimCase* RimWellLogExtractionCurve::rimCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogExtractionCurve::setPropertiesFromView(RimView* view) +void RimWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) { m_case = view ? view->ownerCase() : NULL; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index 27578ebe5a..f01dd1d056 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -28,7 +28,7 @@ class RigWellPath; class RimCase; class RimEclipseResultDefinition; class RimGeoMechResultDefinition; -class RimView; +class Rim3dView; class RimWellPath; //================================================================================================== @@ -52,7 +52,7 @@ class RimWellLogExtractionCurve : public RimWellLogCurve void setCase(RimCase* rimCase); RimCase* rimCase() const; - void setPropertiesFromView(RimView* view); + void setPropertiesFromView(Rim3dView* view); virtual QString wellName() const; virtual QString wellLogChannelName() const; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp index 5ba709567a..08b6d551a5 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp @@ -103,7 +103,7 @@ QString RigReservoirGridTools::gridName(RimCase* rimCase, int gridIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(RimView* rimView) +RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(Rim3dView* rimView) { RimEclipseView* eclipseView = dynamic_cast(rimView); if (eclipseView) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h index 1e56fade1b..4682a0c396 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h @@ -22,7 +22,7 @@ class RigActiveCellInfo; class RigFemPartCollection; class RigMainGrid; class RimCase; -class RimView; +class Rim3dView; namespace cvf { @@ -43,7 +43,7 @@ class RigReservoirGridTools static const cvf::StructGridInterface* gridByIndex(RimCase* rimCase, int gridIndex); static QString gridName(RimCase* rimCase, int gridIndex); - static RigActiveCellInfo* activeCellInfo(RimView* rimView); + static RigActiveCellInfo* activeCellInfo(Rim3dView* rimView); private: static RigMainGrid* eclipseMainGrid(RimCase* rimCase); diff --git a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp index d93d3b32ca..3f79dc26c0 100644 --- a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp +++ b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp @@ -27,7 +27,7 @@ #include "RimEclipseView.h" #include "RimMultiSnapshotDefinition.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuTools.h" @@ -138,7 +138,7 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItemFromActiveView() { if (!m_rimProject) return; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index cb5d67a2ca..cd52715233 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -33,7 +33,7 @@ #include "RimGeoMechView.h" #include "RimProject.h" #include "RimSimWellInViewCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" @@ -751,7 +751,7 @@ void RiuMainWindow::refreshAnimationActions() int currentTimeStepIndex = 0; bool enableAnimControls = false; - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && activeView->viewer() && activeView->viewer()->frameCount()) @@ -1078,7 +1078,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) // Find the activated 3D view - RimView* activatedView = NULL; + Rim3dView* activatedView = NULL; std::vector allCases; proj->allCases(allCases); @@ -1088,12 +1088,12 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) RimCase* reservoirCase = allCases[caseIdx]; if (reservoirCase == NULL) continue; - std::vector views = reservoirCase->views(); + std::vector views = reservoirCase->views(); size_t viewIdx; for (viewIdx = 0; viewIdx < views.size(); viewIdx++) { - RimView* riv = views[viewIdx]; + Rim3dView* riv = views[viewIdx]; if (riv && riv->viewer() && @@ -1107,7 +1107,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) } { - RimView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); RiaApplication::instance()->setActiveReservoirView(activatedView); if (previousActiveReservoirView != activatedView) @@ -1282,7 +1282,7 @@ void RiuMainWindow::selectedObjectsChanged() if (!firstSelectedObject) return; // First check if we are within a RimView - RimView* selectedReservoirView = dynamic_cast(firstSelectedObject); + Rim3dView* selectedReservoirView = dynamic_cast(firstSelectedObject); if (!selectedReservoirView) { firstSelectedObject->firstAncestorOrThisOfType(selectedReservoirView); @@ -1452,7 +1452,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshDrawStyleActions() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); bool enable = view != NULL; m_drawStyleLinesAction->setEnabled(enable); @@ -1500,7 +1500,7 @@ void RiuMainWindow::refreshDrawStyleActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotDisableLightingAction(bool disable) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (view) { view->disableLighting(disable); diff --git a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp index fc20f0fa30..a55c073c9f 100644 --- a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimSummaryPlot.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogPlot.h" #include "RiuMainPlotWindow.h" diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index af275653c7..ef97c9fbe4 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -28,7 +28,7 @@ #include "RigResultAccessorFactory.h" #include "RigCaseCellResultsData.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" @@ -91,7 +91,7 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selecti //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotUpdater::updateOnTimeStepChanged(RimView* changedView) +void RiuPvtPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView) { if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible()) { diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h index 5bcf60517d..bcdb18670a 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h @@ -23,7 +23,7 @@ class RiuSelectionItem; class RiuPvtPlotPanel; -class RimView; +class Rim3dView; class RimEclipseView; class RigEclipseCaseData; @@ -39,7 +39,7 @@ class RiuPvtPlotUpdater RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); - void updateOnTimeStepChanged(RimView* changedView); + void updateOnTimeStepChanged(Rim3dView* changedView); private: static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel); @@ -47,7 +47,7 @@ class RiuPvtPlotUpdater private: QPointer m_targetPlotPanel; - const RimView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_sourceEclipseViewOfLastPlot; }; diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 49bf3e53ac..eb0a96c593 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -27,7 +27,7 @@ #include "RigResultAccessorFactory.h" #include "RigCaseCellResultsData.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" @@ -91,7 +91,7 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged(RimView* changedView) +void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView) { if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible()) { diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h index 5682cbf086..b45a74cae8 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h @@ -23,7 +23,7 @@ class RiuSelectionItem; class RiuRelativePermeabilityPlotPanel; -class RimView; +class Rim3dView; class RimEclipseView; class RigEclipseCaseData; @@ -39,7 +39,7 @@ class RiuRelativePermeabilityPlotUpdater RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); - void updateOnTimeStepChanged(RimView* changedView); + void updateOnTimeStepChanged(Rim3dView* changedView); private: static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel); @@ -47,7 +47,7 @@ class RiuRelativePermeabilityPlotUpdater private: QPointer m_targetPlotPanel; - const RimView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_sourceEclipseViewOfLastPlot; }; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index d75604513f..233a5281dd 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -265,7 +265,7 @@ void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const RimProject* proj = RiaApplication::instance()->project(); if (proj) { - std::vector visibleViews; + std::vector visibleViews; proj->allVisibleViews(visibleViews); for (size_t i = 0; i < visibleViews.size(); i++) diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp index f8cf6cf52b..72206926b7 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp @@ -23,7 +23,7 @@ #include "RiuPvtPlotPanel.h" #include "RiuPvtPlotUpdater.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cvfBase.h" #include "cvfTrace.h" @@ -60,7 +60,7 @@ RiuTimeStepChangedHandler* RiuTimeStepChangedHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuTimeStepChangedHandler::handleTimeStepChanged(RimView* changedView) const +void RiuTimeStepChangedHandler::handleTimeStepChanged(Rim3dView* changedView) const { //cvf::Trace::show("handleTimeStepChanged() viewName: %s timeStep:%d", changedView->name().toLatin1().data(), changedView->currentTimeStep()); //cvf::DebugTimer tim("handleTimeStepChanged()"); diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h index da961d691c..bd5c236836 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h @@ -18,7 +18,7 @@ #pragma once -class RimView; +class Rim3dView; //================================================================================================== @@ -31,7 +31,7 @@ class RiuTimeStepChangedHandler public: static RiuTimeStepChangedHandler* instance(); - void handleTimeStepChanged(RimView* changedView) const; + void handleTimeStepChanged(Rim3dView* changedView) const; private: RiuTimeStepChangedHandler(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index a3a8fcfa19..19a47501b6 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -26,7 +26,7 @@ #include "RimCase.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -321,7 +321,7 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::setOwnerReservoirView(RimView * owner) +void RiuViewer::setOwnerReservoirView(Rim3dView * owner) { m_rimView = owner; m_viewerCommands->setOwnerView(owner); @@ -645,7 +645,7 @@ void RiuViewer::setCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RiuViewer::ownerReservoirView() +Rim3dView* RiuViewer::ownerReservoirView() { return m_rimView; } @@ -746,7 +746,7 @@ void RiuViewer::updateGridBoxData() { if (ownerReservoirView() && ownerReservoirView()->ownerCase()) { - RimView* rimView = ownerReservoirView(); + Rim3dView* rimView = ownerReservoirView(); RimCase* rimCase = rimView->ownerCase(); m_gridBoxGenerator->setScaleZ(rimView->scaleZ); diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 353a8f3a86..81c8349932 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -30,7 +30,7 @@ #include "RiuInterfaceToViewWindow.h" class RicCommandFeature; -class RimView; +class Rim3dView; class RiuSimpleHistogramWidget; class RiuViewerCommands; class RivGridBoxGenerator; @@ -64,8 +64,8 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setDefaultView(); cvf::Vec3d pointOfInterest(); void setPointOfInterest(cvf::Vec3d poi); - void setOwnerReservoirView(RimView * owner); - RimView* ownerReservoirView(); + void setOwnerReservoirView(Rim3dView * owner); + Rim3dView* ownerReservoirView(); RimViewWindow* ownerViewWindow() const override; void setEnableMask(unsigned int mask); @@ -141,7 +141,7 @@ public slots: cvf::ref m_axisCross; cvf::Collection m_visibleLegends; - caf::PdmPointer m_rimView; + caf::PdmPointer m_rimView; QPoint m_lastMousePressPosition; RiuViewerCommands* m_viewerCommands; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 09583061a8..cf7af25498 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -125,7 +125,7 @@ RiuViewerCommands::~RiuViewerCommands() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewerCommands::setOwnerView(RimView * owner) +void RiuViewerCommands::setOwnerView(Rim3dView * owner) { m_reservoirView = owner; } @@ -160,7 +160,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); CVF_ASSERT(activeView); cvf::ref transForm = activeView->displayCoordTransform(); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index 970cb7bf62..da3cb16a1c 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -29,7 +29,7 @@ class RicViewerEventInterface; class RimEclipseView; class RimGeoMechView; class RimIntersection; -class RimView; +class Rim3dView; class RiuViewer; class RivIntersectionBoxSourceInfo; class RivIntersectionSourceInfo; @@ -53,7 +53,7 @@ class RiuViewerCommands: public QObject explicit RiuViewerCommands(RiuViewer* ownerViewer); ~RiuViewerCommands(); - void setOwnerView(RimView * owner); + void setOwnerView(Rim3dView * owner); void displayContextMenu(QMouseEvent* event); void handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers); @@ -73,7 +73,7 @@ class RiuViewerCommands: public QObject cvf::StructGridInterface::FaceType m_currentFaceIndex; cvf::Vec3d m_currentPickPositionInDomainCoords; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; QPointer m_viewer; From 55147e5b70c3ad6bf9fa526ea4969d8851580916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 9 Jan 2018 11:33:02 +0100 Subject: [PATCH 0008/1027] #2350. Implement ElementPropertyTable file reader for single file --- .../FileInterface/CMakeLists_files.cmake | 2 + .../RifElementPropertyTableReader.cpp | 196 ++++++++++++++++++ .../RifElementPropertyTableReader.h | 79 +++++++ 3 files changed, 277 insertions(+) create mode 100644 ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp create mode 100644 ApplicationCode/FileInterface/RifElementPropertyTableReader.h diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index e437ee7c5b..96f3ba89cd 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -40,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RifCsvUserData.h ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h +${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h ) @@ -84,6 +85,7 @@ ${CEE_CURRENT_LIST_DIR}RifCsvUserData.cpp ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp +${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp new file mode 100644 index 0000000000..68a5a99291 --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp @@ -0,0 +1,196 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifElementPropertyTableReader.h" + +#include "RiaLogging.h" +#include "RiuMainWindow.h" + +#include +#include +#include +#include + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +static QFile* openFile(const QString &fileName); +static void closeFile(QFile *file); +static QStringList splitLineAndTrim(const QString& line, const QString& separator); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QString& fileName) +{ + ElementPropertyMetadata metadata; + QFile* file = openFile(fileName); + + if (file) + { + QTextStream stream(file); + bool metadataBlockFound = false; + int maxLinesToRead = 50; + int lineNo = 0; + + while (lineNo < maxLinesToRead) + { + QString line = stream.readLine(); + lineNo++; + + if (line.toUpper().startsWith("*DISTRIBUTION TABLE")) + { + metadataBlockFound = true; + continue; + } + + if (!metadataBlockFound) continue; + + QStringList cols = splitLineAndTrim(line, ","); + + metadata.fileName = fileName; + for (QString s : cols) + { + metadata.dataColumns.push_back(s); + } + break; + } + + closeFile(file); + } + + return metadata; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyTableReader::readData(const ElementPropertyMetadata *metadata, ElementPropertyTable *table) +{ + CVF_ASSERT(metadata && table); + + QFile* file = openFile(metadata->fileName); + int expectedColumnCount = (int)metadata->dataColumns.size() + 1; + + if (file && expectedColumnCount > 0) + { + QTextStream stream(file); + bool dataBlockFound = false; + int lineNo = 0; + + // Init data vectors + table->elementIds.clear(); + table->data = std::vector>(metadata->dataColumns.size()); + + while (!stream.atEnd()) + { + QString line = stream.readLine(); + QStringList cols = splitLineAndTrim(line, ","); + lineNo++; + + if (!dataBlockFound) + { + if (!line.startsWith("*") && cols.size() == expectedColumnCount) dataBlockFound = true; + else continue; + } + + if (cols.size() != expectedColumnCount) + { + throw FileParseException(QString("Number of columns mismatch at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + + for (int c = 0; c < expectedColumnCount; c++) + { + bool parseOk; + + if (c == 0) + { + // Remove elementId column prefix + QStringList parts = cols[0].split("."); + + int elementId = parts.last().toInt(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->elementIds.push_back(elementId); + } + else + { + float value = cols[c].toFloat(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->data[c - 1].push_back(value); + } + } + } + + table->hasData = true; + } + + closeFile(file); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QFile* openFile(const QString &fileName) +{ + QFile *file; + file = new QFile(fileName); + if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error(QString("Failed to open %1").arg(fileName)); + + delete file; + return nullptr; + } + return file; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void closeFile(QFile *file) +{ + if (file) + { + file->close(); + delete file; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList splitLineAndTrim(const QString& line, const QString& separator) +{ + QStringList cols = line.split(separator); + for (QString& col : cols) + { + col = col.trimmed(); + } + return cols; +} diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h new file mode 100644 index 0000000000..fc58e53a6b --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RigWellPathFormations.h" + +#include +#include +#include + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class ElementPropertyTable; +class ElementPropertyMetadata; + +//================================================================================================== +/// +//================================================================================================== +class RifElementPropertyTableReader : cvf::Object +{ +public: + static ElementPropertyMetadata readMetadata(const QString& filePath); + static void readData(const ElementPropertyMetadata *metadata, ElementPropertyTable *table); +}; + +//================================================================================================== +/// +//================================================================================================== +class FileParseException +{ +public: + FileParseException(const QString &message) : message(message) {} + QString message; +}; + +//================================================================================================== +/// +//================================================================================================== +class ElementPropertyMetadata +{ +public: + QString fileName; + std::vector dataColumns; +}; + + +//================================================================================================== +/// +//================================================================================================== +class ElementPropertyTable +{ +public: + ElementPropertyTable() : hasData(false) {} + + ElementPropertyMetadata metadata; + bool hasData; + std::vector elementIds; + std::vector> data; +}; + From 766f4da48b75e962ccbad6bbc344d10b1aa37f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 9 Jan 2018 11:59:43 +0100 Subject: [PATCH 0009/1027] #2350. Renaming, robustify --- .../RifElementPropertyTableReader.cpp | 150 ++++++++++-------- .../RifElementPropertyTableReader.h | 16 +- 2 files changed, 93 insertions(+), 73 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp index 68a5a99291..eac61d4c9b 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp @@ -41,42 +41,52 @@ static QStringList splitLineAndTrim(const QString& line, const QString& separato //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -ElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QString& fileName) +RifElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QString& fileName) { - ElementPropertyMetadata metadata; - QFile* file = openFile(fileName); + RifElementPropertyMetadata metadata; + QFile* file = nullptr; - if (file) + try { - QTextStream stream(file); - bool metadataBlockFound = false; - int maxLinesToRead = 50; - int lineNo = 0; + file = openFile(fileName); - while (lineNo < maxLinesToRead) + if (file) { - QString line = stream.readLine(); - lineNo++; + QTextStream stream(file); + bool metadataBlockFound = false; + int maxLinesToRead = 50; + int lineNo = 0; - if (line.toUpper().startsWith("*DISTRIBUTION TABLE")) + while (lineNo < maxLinesToRead) { - metadataBlockFound = true; - continue; - } + QString line = stream.readLine(); + lineNo++; + + if (line.toUpper().startsWith("*DISTRIBUTION TABLE")) + { + metadataBlockFound = true; + continue; + } - if (!metadataBlockFound) continue; + if (!metadataBlockFound) continue; - QStringList cols = splitLineAndTrim(line, ","); + QStringList cols = splitLineAndTrim(line, ","); - metadata.fileName = fileName; - for (QString s : cols) - { - metadata.dataColumns.push_back(s); + metadata.fileName = fileName; + for (QString s : cols) + { + metadata.dataColumns.push_back(s); + } + break; } - break; - } + closeFile(file); + } + } + catch(...) + { closeFile(file); + throw; } return metadata; @@ -85,72 +95,82 @@ ElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifElementPropertyTableReader::readData(const ElementPropertyMetadata *metadata, ElementPropertyTable *table) +void RifElementPropertyTableReader::readData(const RifElementPropertyMetadata *metadata, RifElementPropertyTable *table) { CVF_ASSERT(metadata && table); - QFile* file = openFile(metadata->fileName); int expectedColumnCount = (int)metadata->dataColumns.size() + 1; + QFile* file = nullptr; - if (file && expectedColumnCount > 0) + try { - QTextStream stream(file); - bool dataBlockFound = false; - int lineNo = 0; + file = openFile(metadata->fileName); - // Init data vectors - table->elementIds.clear(); - table->data = std::vector>(metadata->dataColumns.size()); - - while (!stream.atEnd()) + if (file && expectedColumnCount > 0) { - QString line = stream.readLine(); - QStringList cols = splitLineAndTrim(line, ","); - lineNo++; + QTextStream stream(file); + bool dataBlockFound = false; + int lineNo = 0; - if (!dataBlockFound) - { - if (!line.startsWith("*") && cols.size() == expectedColumnCount) dataBlockFound = true; - else continue; - } + // Init data vectors + table->elementIds.clear(); + table->data = std::vector>(metadata->dataColumns.size()); - if (cols.size() != expectedColumnCount) + while (!stream.atEnd()) { - throw FileParseException(QString("Number of columns mismatch at %1:%2").arg(metadata->fileName).arg(lineNo)); - } + QString line = stream.readLine(); + QStringList cols = splitLineAndTrim(line, ","); + lineNo++; - for (int c = 0; c < expectedColumnCount; c++) - { - bool parseOk; + if (!dataBlockFound) + { + if (!line.startsWith("*") && cols.size() == expectedColumnCount) dataBlockFound = true; + else continue; + } - if (c == 0) + if (cols.size() != expectedColumnCount) { - // Remove elementId column prefix - QStringList parts = cols[0].split("."); + throw FileParseException(QString("Number of columns mismatch at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + + for (int c = 0; c < expectedColumnCount; c++) + { + bool parseOk; - int elementId = parts.last().toInt(&parseOk); - if (!parseOk) + if (c == 0) { - throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + // Remove elementId column prefix + QStringList parts = cols[0].split("."); + + int elementId = parts.last().toInt(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->elementIds.push_back(elementId); } - table->elementIds.push_back(elementId); - } - else - { - float value = cols[c].toFloat(&parseOk); - if (!parseOk) + else { - throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + float value = cols[c].toFloat(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->data[c - 1].push_back(value); } - table->data[c - 1].push_back(value); } } + + table->hasData = true; } - table->hasData = true; + closeFile(file); + } + catch (...) + { + closeFile(file); + throw; } - - closeFile(file); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h index fc58e53a6b..f6765212de 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h @@ -29,8 +29,8 @@ #include -class ElementPropertyTable; -class ElementPropertyMetadata; +class RifElementPropertyTable; +class RifElementPropertyMetadata; //================================================================================================== /// @@ -38,8 +38,8 @@ class ElementPropertyMetadata; class RifElementPropertyTableReader : cvf::Object { public: - static ElementPropertyMetadata readMetadata(const QString& filePath); - static void readData(const ElementPropertyMetadata *metadata, ElementPropertyTable *table); + static RifElementPropertyMetadata readMetadata(const QString& filePath); + static void readData(const RifElementPropertyMetadata *metadata, RifElementPropertyTable *table); }; //================================================================================================== @@ -55,7 +55,7 @@ class FileParseException //================================================================================================== /// //================================================================================================== -class ElementPropertyMetadata +class RifElementPropertyMetadata { public: QString fileName; @@ -66,12 +66,12 @@ class ElementPropertyMetadata //================================================================================================== /// //================================================================================================== -class ElementPropertyTable +class RifElementPropertyTable { public: - ElementPropertyTable() : hasData(false) {} + RifElementPropertyTable() : hasData(false) {} - ElementPropertyMetadata metadata; + RifElementPropertyMetadata metadata; bool hasData; std::vector elementIds; std::vector> data; From f632b36993bb99e070032ad38f4710d8b7b27a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 9 Jan 2018 15:13:44 +0100 Subject: [PATCH 0010/1027] Implement support for reading test files from unit tests --- ApplicationCode/UnitTests/CMakeLists_files.cmake | 4 ++++ ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 685d3d2b24..95494e2b6d 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -4,6 +4,10 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) endif() +CONFIGURE_FILE( ${CEE_CURRENT_LIST_DIR}RiaTestDataDirectory.h.cmake + ${CMAKE_BINARY_DIR}/Generated/RiaTestDataDirectory.h +) + set (SOURCE_GROUP_HEADER_FILES ) diff --git a/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake b/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake new file mode 100644 index 0000000000..cc9abc663e --- /dev/null +++ b/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake @@ -0,0 +1,3 @@ +// Test data directory used by unit tests + +#define TEST_DATA_DIR "${CMAKE_CURRENT_LIST_DIR}/TestData" From 3e11f9fbd6dc1ce1e6cdea7b547e671de689ca07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 9 Jan 2018 15:39:17 +0100 Subject: [PATCH 0011/1027] RifElementPropertyTableReader unit tests --- .../UnitTests/CMakeLists_files.cmake | 1 + .../RicElementPropertyTableReader-Test.cpp | 53 + .../ElementPropertyTable/ELASTIC_TABLE.inp | 4326 +++++++++++++++++ .../ELASTIC_TABLE_error.inp | 4326 +++++++++++++++++ 4 files changed, 8706 insertions(+) create mode 100644 ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp create mode 100644 ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp create mode 100644 ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 95494e2b6d..7744bd48bf 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -40,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp ${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp ${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp ${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp +${CEE_CURRENT_LIST_DIR}RicElementPropertyTableReader-Test.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp new file mode 100644 index 0000000000..cc19c06c12 --- /dev/null +++ b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp @@ -0,0 +1,53 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifElementPropertyTableReader.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/ElementPropertyTable/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, BasicUsage) +{ + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(table.hasData); + + EXPECT_EQ(2, metadata.dataColumns.size()); + EXPECT_STREQ("MODULUS", metadata.dataColumns[0].toStdString().c_str()); + EXPECT_STREQ("RATIO", metadata.dataColumns[1].toStdString().c_str()); + + EXPECT_EQ(2, table.data.size()); + EXPECT_EQ(4320, table.elementIds.size()); + EXPECT_EQ(4320, table.data[0].size()); + EXPECT_EQ(4320, table.data[1].size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, ParseFailed) +{ + try + { + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE_error.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.startsWith("Number of columns mismatch")); + } +} diff --git a/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp b/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp new file mode 100644 index 0000000000..7d6600ed43 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp @@ -0,0 +1,4326 @@ +** ELASTIC SETTING FOR EACH ELEMENT +*Distribution Table, name=RSV_Res-1_Elastic_Table +MODULUS, RATIO +*Distribution, name=RSV_Res-1_ELASTICS, location=ELEMENT, Table=RSV_Res-1_Elastic_Table +** Description: Element-by-Element Elastic properties +, 2. +Res-1.210, 11198814808.2538, 0.19041 +Res-1.209, 11207002032.1436, 0.19063 +Res-1.208, 11222989223.0933, 0.19104 +Res-1.207, 11202549454.349, 0.19051 +Res-1.206, 11201018277.2135, 0.19047 +Res-1.205, 11199452457.2289, 0.19043 +Res-1.204, 11211165066.8084, 0.19073 +Res-1.203, 11211396173.5037, 0.19074 +Res-1.202, 11222952734.6236, 0.19104 +Res-1.201, 11212868930.9558, 0.19078 +Res-1.200, 11211827541.4726, 0.19075 +Res-1.199, 11223293389.2923, 0.19105 +Res-1.198, 11213461278.5775, 0.19079 +Res-1.197, 11212227164.9418, 0.19076 +Res-1.196, 11222290540.4229, 0.19102 +Res-1.195, 11209591214.3024, 0.19069 +Res-1.194, 11227448401.9317, 0.19116 +Res-1.193, 11218701110.7378, 0.19093 +Res-1.192, 11212290325.2544, 0.19076 +Res-1.191, 11218462357.8173, 0.19092 +Res-1.190, 11210219341.6298, 0.19071 +Res-1.189, 11217410056.2303, 0.1909 +Res-1.188, 11224201059.3023, 0.19107 +Res-1.187, 11200886151.7449, 0.19047 +Res-1.186, 11209070545.6809, 0.19068 +Res-1.185, 11208525302.8397, 0.19067 +Res-1.184, 11208029443.911, 0.19065 +Res-1.183, 11205956268.7052, 0.1906 +Res-1.182, 11203032646.1219, 0.19052 +Res-1.181, 11212779732.2076, 0.19078 +Res-1.180, 11223694446.8691, 0.19106 +Res-1.179, 11216849610.9899, 0.19088 +Res-1.178, 11203666189.6647, 0.19054 +Res-1.177, 11223110950.263, 0.19104 +Res-1.176, 11218366316.8438, 0.19092 +Res-1.175, 11199308629.4248, 0.19043 +Res-1.174, 11204107404.8935, 0.19055 +Res-1.173, 11221591221.1029, 0.191 +Res-1.172, 11198310779.2562, 0.1904 +Res-1.171, 11226329567.8196, 0.19113 +Res-1.170, 11215508691.1034, 0.19085 +Res-1.169, 11216141613.3394, 0.19086 +Res-1.168, 11216262209.1321, 0.19087 +Res-1.167, 11224888572.4446, 0.19109 +Res-1.166, 11215543405.3856, 0.19085 +Res-1.165, 11209879234.5934, 0.1907 +Res-1.164, 11198661683.8392, 0.19041 +Res-1.163, 11221659419.8899, 0.19101 +Res-1.162, 11217644939.1724, 0.1909 +Res-1.161, 11220272938.4351, 0.19097 +Res-1.160, 11219517563.9646, 0.19095 +Res-1.159, 11222601901.6144, 0.19103 +Res-1.158, 11227551848.7474, 0.19116 +Res-1.157, 11214792538.2525, 0.19083 +Res-1.156, 11220949297.0432, 0.19099 +Res-1.155, 11202237002.5308, 0.1905 +Res-1.154, 11212422032.9539, 0.19077 +Res-1.153, 11200876863.9619, 0.19047 +Res-1.152, 11199085093.8181, 0.19042 +Res-1.151, 11210721102.6531, 0.19072 +Res-1.150, 11224677747.0098, 0.19108 +Res-1.149, 11200505347.0814, 0.19046 +Res-1.148, 11210477709.1165, 0.19072 +Res-1.147, 11201790929.0597, 0.19049 +Res-1.146, 11215538617.2144, 0.19085 +Res-1.145, 11210067552.0255, 0.19071 +Res-1.144, 11226119663.3263, 0.19112 +Res-1.143, 11200558079.1704, 0.19046 +Res-1.142, 11209025034.8169, 0.19068 +Res-1.141, 11225111056.7698, 0.1911 +Res-1.140, 11207283822.5306, 0.19063 +Res-1.139, 11216396568.854, 0.19087 +Res-1.138, 11225696853.721, 0.19111 +Res-1.137, 11221821540.0987, 0.19101 +Res-1.136, 11220794943.2728, 0.19098 +Res-1.135, 11221457514.5243, 0.191 +Res-1.134, 11207200873.1928, 0.19063 +Res-1.133, 11205669058.0237, 0.19059 +Res-1.132, 11211863163.8498, 0.19075 +Res-1.131, 11211677567.1763, 0.19075 +Res-1.130, 11209369356.3868, 0.19069 +Res-1.129, 11198739894.387, 0.19041 +Res-1.128, 11209258875.0902, 0.19068 +Res-1.127, 11210271135.3011, 0.19071 +Res-1.126, 11201024868.4708, 0.19047 +Res-1.125, 11211157882.0769, 0.19073 +Res-1.124, 11218203554.1602, 0.19092 +Res-1.123, 11199588193.2274, 0.19043 +Res-1.122, 11215076550.207, 0.19084 +Res-1.121, 11210238801.7044, 0.19071 +Res-1.120, 11206683700.3163, 0.19062 +Res-1.119, 11207926137.5337, 0.19065 +Res-1.118, 11221872987.408, 0.19101 +Res-1.117, 11225794932.4499, 0.19111 +Res-1.116, 11220026437.0079, 0.19096 +Res-1.115, 11202273250.9302, 0.1905 +Res-1.114, 11211501846.5387, 0.19074 +Res-1.113, 11214337327.7756, 0.19082 +Res-1.112, 11215364146.9954, 0.19084 +Res-1.111, 11205074849.7447, 0.19058 +Res-1.110, 11208670822.9857, 0.19067 +Res-1.109, 11208556443.0933, 0.19067 +Res-1.108, 11223420197.8288, 0.19105 +Res-1.107, 11215302199.0174, 0.19084 +Res-1.106, 11213126346.6531, 0.19078 +Res-1.105, 11217009099.524, 0.19089 +Res-1.104, 11213865938.8012, 0.1908 +Res-1.103, 11217994113.817, 0.19091 +Res-1.102, 11204980205.137, 0.19057 +Res-1.101, 11216751463.2051, 0.19088 +Res-1.100, 11206944834.8203, 0.19062 +Res-1.99, 11213849177.9825, 0.1908 +Res-1.98, 11206416870.416, 0.19061 +Res-1.97, 11200174867.7047, 0.19045 +Res-1.96, 11212761772.6524, 0.19078 +Res-1.95, 11201207924.2968, 0.19048 +Res-1.94, 11221710568.74, 0.19101 +Res-1.93, 11202102792.6819, 0.1905 +Res-1.92, 11225762937.338, 0.19111 +Res-1.91, 11214313983.2092, 0.19082 +Res-1.90, 11227579653.6727, 0.19116 +Res-1.89, 11204048097.8306, 0.19055 +Res-1.88, 11222876467.402, 0.19104 +Res-1.87, 11223289800.353, 0.19105 +Res-1.86, 11222804686.0695, 0.19104 +Res-1.85, 11207547340.3029, 0.19064 +Res-1.84, 11221843076.207, 0.19101 +Res-1.83, 11219320112.1476, 0.19095 +Res-1.82, 11205244070.1516, 0.19058 +Res-1.81, 11213243977.9053, 0.19079 +Res-1.80, 11201016479.5973, 0.19047 +Res-1.79, 11226505681.5926, 0.19113 +Res-1.78, 11215171119.692, 0.19084 +Res-1.77, 11211115372.3329, 0.19073 +Res-1.76, 11211330613.8706, 0.19074 +Res-1.75, 11203582318.1003, 0.19054 +Res-1.74, 11224464824.7228, 0.19108 +Res-1.73, 11219259679.3117, 0.19094 +Res-1.72, 11228171914.0288, 0.19117 +Res-1.71, 11199769172.3056, 0.19044 +Res-1.70, 11205305168.6479, 0.19058 +Res-1.69, 11205754113.792, 0.19059 +Res-1.68, 11224082931.2902, 0.19107 +Res-1.67, 11217787662.1013, 0.19091 +Res-1.66, 11223709998.4367, 0.19106 +Res-1.65, 11213376573.6608, 0.19079 +Res-1.64, 11204036715.6354, 0.19055 +Res-1.63, 11209300792.2263, 0.19069 +Res-1.62, 11207638372.4461, 0.19064 +Res-1.61, 11209100486.9499, 0.19068 +Res-1.60, 11206412378.2822, 0.19061 +Res-1.59, 11202503021.4388, 0.19051 +Res-1.58, 11209477740.8993, 0.19069 +Res-1.57, 11222835193.1853, 0.19104 +Res-1.56, 11211083938.9801, 0.19073 +Res-1.55, 11223344531.5666, 0.19105 +Res-1.54, 11201118643.7157, 0.19047 +Res-1.53, 11225922912.0918, 0.19112 +Res-1.52, 11218110503.2337, 0.19091 +Res-1.51, 11210865400.1882, 0.19073 +Res-1.50, 11214019778.1402, 0.19081 +Res-1.49, 11204136459.2628, 0.19055 +Res-1.48, 11212356777.9461, 0.19076 +Res-1.47, 11221437772.4942, 0.191 +Res-1.46, 11207006823.5308, 0.19063 +Res-1.45, 11223791045.7213, 0.19106 +Res-1.44, 11208544765.5071, 0.19067 +Res-1.43, 11209267557.9369, 0.19068 +Res-1.42, 11221377947.9732, 0.191 +Res-1.41, 11222786142.4926, 0.19104 +Res-1.40, 11223261088.8025, 0.19105 +Res-1.39, 11223761737.1688, 0.19106 +Res-1.38, 11222172394.6506, 0.19102 +Res-1.37, 11199653513.7877, 0.19044 +Res-1.36, 11227759636.7716, 0.19116 +Res-1.35, 11199577106.677, 0.19043 +Res-1.34, 11227466938.7063, 0.19116 +Res-1.33, 11199169594.335, 0.19042 +Res-1.32, 11219335070.7259, 0.19095 +Res-1.31, 11212527697.4628, 0.19077 +Res-1.30, 11202428428.8604, 0.19051 +Res-1.29, 11201408054.3293, 0.19048 +Res-1.28, 11222583357.7417, 0.19103 +Res-1.27, 11208466914.6587, 0.19066 +Res-1.26, 11200064606.1293, 0.19045 +Res-1.25, 11199032055.973, 0.19042 +Res-1.24, 11225007889.1195, 0.19109 +Res-1.23, 11222886038.2157, 0.19104 +Res-1.22, 11205896670.776, 0.1906 +Res-1.21, 11226756542.3277, 0.19114 +Res-1.20, 11226104114.7074, 0.19112 +Res-1.19, 11213604048.4849, 0.1908 +Res-1.18, 11202801387.3778, 0.19052 +Res-1.17, 11198392587.9363, 0.1904 +Res-1.16, 11228104049.1491, 0.19117 +Res-1.15, 11212003257.6089, 0.19076 +Res-1.14, 11202458086.203, 0.19051 +Res-1.13, 11201026366.4833, 0.19047 +Res-1.12, 11202937387.2003, 0.19052 +Res-1.11, 11201932931.3114, 0.19049 +Res-1.10, 11205907751.8191, 0.1906 +Res-1.9, 11224722304.7336, 0.19109 +Res-1.8, 11213008714.3126, 0.19078 +Res-1.7, 11223186617.916, 0.19105 +Res-1.6, 11203363650.3495, 0.19053 +Res-1.5, 11200461004.0192, 0.19046 +Res-1.4, 11223167476.7341, 0.19105 +Res-1.3, 11201787633.63, 0.19049 +Res-1.2, 11216634163.6389, 0.19088 +Res-1.1, 11216793056.4137, 0.19088 +Res-1.211, 10072000000, 0.25 +Res-1.212, 10072000000, 0.25 +Res-1.213, 10072000000, 0.25 +Res-1.214, 10072000000, 0.25 +Res-1.215, 10072000000, 0.25 +Res-1.216, 10072000000, 0.25 +Res-1.217, 10216000000, 0.25 +Res-1.218, 10216000000, 0.25 +Res-1.219, 10216000000, 0.25 +Res-1.220, 10216000000, 0.25 +Res-1.221, 10216000000, 0.25 +Res-1.222, 10216000000, 0.25 +Res-1.223, 10360000000, 0.25 +Res-1.224, 10360000000, 0.25 +Res-1.225, 10360000000, 0.25 +Res-1.226, 10360000000, 0.25 +Res-1.227, 10360000000, 0.25 +Res-1.228, 10360000000, 0.25 +Res-1.229, 10504000000, 0.25 +Res-1.230, 10504000000, 0.25 +Res-1.231, 10504000000, 0.25 +Res-1.232, 10504000000, 0.25 +Res-1.233, 10504000000, 0.25 +Res-1.234, 10504000000, 0.25 +Res-1.235, 10648000000, 0.25 +Res-1.236, 10648000000, 0.25 +Res-1.237, 10648000000, 0.25 +Res-1.238, 10648000000, 0.25 +Res-1.239, 10648000000, 0.25 +Res-1.240, 10648000000, 0.25 +Res-1.241, 10072000000, 0.25 +Res-1.242, 10072000000, 0.25 +Res-1.243, 10072000000, 0.25 +Res-1.244, 10072000000, 0.25 +Res-1.245, 10072000000, 0.25 +Res-1.246, 10072000000, 0.25 +Res-1.247, 10072000000, 0.25 +Res-1.248, 10216000000, 0.25 +Res-1.249, 10216000000, 0.25 +Res-1.250, 10216000000, 0.25 +Res-1.251, 10216000000, 0.25 +Res-1.252, 10216000000, 0.25 +Res-1.253, 10216000000, 0.25 +Res-1.254, 10216000000, 0.25 +Res-1.255, 10360000000, 0.25 +Res-1.256, 10360000000, 0.25 +Res-1.257, 10360000000, 0.25 +Res-1.258, 10360000000, 0.25 +Res-1.259, 10360000000, 0.25 +Res-1.260, 10360000000, 0.25 +Res-1.261, 10360000000, 0.25 +Res-1.262, 10504000000, 0.25 +Res-1.263, 10504000000, 0.25 +Res-1.264, 10504000000, 0.25 +Res-1.265, 10504000000, 0.25 +Res-1.266, 10504000000, 0.25 +Res-1.267, 10504000000, 0.25 +Res-1.268, 10504000000, 0.25 +Res-1.269, 10648000000, 0.25 +Res-1.270, 10648000000, 0.25 +Res-1.271, 10648000000, 0.25 +Res-1.272, 10648000000, 0.25 +Res-1.273, 10648000000, 0.25 +Res-1.274, 10648000000, 0.25 +Res-1.275, 10648000000, 0.25 +Res-1.276, 10072000000, 0.25 +Res-1.277, 10216000000, 0.25 +Res-1.278, 10360000000, 0.25 +Res-1.279, 10504000000, 0.25 +Res-1.280, 10648000000, 0.25 +Res-1.281, 10072000000, 0.25 +Res-1.282, 10072000000, 0.25 +Res-1.283, 10072000000, 0.25 +Res-1.284, 10072000000, 0.25 +Res-1.285, 10072000000, 0.25 +Res-1.286, 10072000000, 0.25 +Res-1.287, 10072000000, 0.25 +Res-1.288, 10216000000, 0.25 +Res-1.289, 10216000000, 0.25 +Res-1.290, 10216000000, 0.25 +Res-1.291, 10216000000, 0.25 +Res-1.292, 10216000000, 0.25 +Res-1.293, 10216000000, 0.25 +Res-1.294, 10216000000, 0.25 +Res-1.295, 10360000000, 0.25 +Res-1.296, 10360000000, 0.25 +Res-1.297, 10360000000, 0.25 +Res-1.298, 10360000000, 0.25 +Res-1.299, 10360000000, 0.25 +Res-1.300, 10360000000, 0.25 +Res-1.301, 10360000000, 0.25 +Res-1.302, 10504000000, 0.25 +Res-1.303, 10504000000, 0.25 +Res-1.304, 10504000000, 0.25 +Res-1.305, 10504000000, 0.25 +Res-1.306, 10504000000, 0.25 +Res-1.307, 10504000000, 0.25 +Res-1.308, 10504000000, 0.25 +Res-1.309, 10648000000, 0.25 +Res-1.310, 10648000000, 0.25 +Res-1.311, 10648000000, 0.25 +Res-1.312, 10648000000, 0.25 +Res-1.313, 10648000000, 0.25 +Res-1.314, 10648000000, 0.25 +Res-1.315, 10648000000, 0.25 +Res-1.316, 10072000000, 0.25 +Res-1.317, 10216000000, 0.25 +Res-1.318, 10360000000, 0.25 +Res-1.319, 10504000000, 0.25 +Res-1.320, 10648000000, 0.25 +Res-1.321, 10072000000, 0.25 +Res-1.322, 10072000000, 0.25 +Res-1.323, 10072000000, 0.25 +Res-1.324, 10072000000, 0.25 +Res-1.325, 10072000000, 0.25 +Res-1.326, 10072000000, 0.25 +Res-1.327, 10072000000, 0.25 +Res-1.328, 10216000000, 0.25 +Res-1.329, 10216000000, 0.25 +Res-1.330, 10216000000, 0.25 +Res-1.331, 10216000000, 0.25 +Res-1.332, 10216000000, 0.25 +Res-1.333, 10216000000, 0.25 +Res-1.334, 10216000000, 0.25 +Res-1.335, 10360000000, 0.25 +Res-1.336, 10360000000, 0.25 +Res-1.337, 10360000000, 0.25 +Res-1.338, 10360000000, 0.25 +Res-1.339, 10360000000, 0.25 +Res-1.340, 10360000000, 0.25 +Res-1.341, 10360000000, 0.25 +Res-1.342, 10504000000, 0.25 +Res-1.343, 10504000000, 0.25 +Res-1.344, 10504000000, 0.25 +Res-1.345, 10504000000, 0.25 +Res-1.346, 10504000000, 0.25 +Res-1.347, 10504000000, 0.25 +Res-1.348, 10504000000, 0.25 +Res-1.349, 10648000000, 0.25 +Res-1.350, 10648000000, 0.25 +Res-1.351, 10648000000, 0.25 +Res-1.352, 10648000000, 0.25 +Res-1.353, 10648000000, 0.25 +Res-1.354, 10648000000, 0.25 +Res-1.355, 10648000000, 0.25 +Res-1.356, 10072000000, 0.25 +Res-1.357, 10216000000, 0.25 +Res-1.358, 10360000000, 0.25 +Res-1.359, 10504000000, 0.25 +Res-1.360, 10648000000, 0.25 +Res-1.361, 10072000000, 0.25 +Res-1.362, 10072000000, 0.25 +Res-1.363, 10072000000, 0.25 +Res-1.364, 10072000000, 0.25 +Res-1.365, 10072000000, 0.25 +Res-1.366, 10072000000, 0.25 +Res-1.367, 10072000000, 0.25 +Res-1.368, 10216000000, 0.25 +Res-1.369, 10216000000, 0.25 +Res-1.370, 10216000000, 0.25 +Res-1.371, 10216000000, 0.25 +Res-1.372, 10216000000, 0.25 +Res-1.373, 10216000000, 0.25 +Res-1.374, 10216000000, 0.25 +Res-1.375, 10360000000, 0.25 +Res-1.376, 10360000000, 0.25 +Res-1.377, 10360000000, 0.25 +Res-1.378, 10360000000, 0.25 +Res-1.379, 10360000000, 0.25 +Res-1.380, 10360000000, 0.25 +Res-1.381, 10360000000, 0.25 +Res-1.382, 10504000000, 0.25 +Res-1.383, 10504000000, 0.25 +Res-1.384, 10504000000, 0.25 +Res-1.385, 10504000000, 0.25 +Res-1.386, 10504000000, 0.25 +Res-1.387, 10504000000, 0.25 +Res-1.388, 10504000000, 0.25 +Res-1.389, 10648000000, 0.25 +Res-1.390, 10648000000, 0.25 +Res-1.391, 10648000000, 0.25 +Res-1.392, 10648000000, 0.25 +Res-1.393, 10648000000, 0.25 +Res-1.394, 10648000000, 0.25 +Res-1.395, 10648000000, 0.25 +Res-1.396, 10072000000, 0.25 +Res-1.397, 10216000000, 0.25 +Res-1.398, 10360000000, 0.25 +Res-1.399, 10504000000, 0.25 +Res-1.400, 10648000000, 0.25 +Res-1.401, 10072000000, 0.25 +Res-1.402, 10072000000, 0.25 +Res-1.403, 10072000000, 0.25 +Res-1.404, 10072000000, 0.25 +Res-1.405, 10072000000, 0.25 +Res-1.406, 10072000000, 0.25 +Res-1.407, 10072000000, 0.25 +Res-1.408, 10216000000, 0.25 +Res-1.409, 10216000000, 0.25 +Res-1.410, 10216000000, 0.25 +Res-1.411, 10216000000, 0.25 +Res-1.412, 10216000000, 0.25 +Res-1.413, 10216000000, 0.25 +Res-1.414, 10216000000, 0.25 +Res-1.415, 10360000000, 0.25 +Res-1.416, 10360000000, 0.25 +Res-1.417, 10360000000, 0.25 +Res-1.418, 10360000000, 0.25 +Res-1.419, 10360000000, 0.25 +Res-1.420, 10360000000, 0.25 +Res-1.421, 10360000000, 0.25 +Res-1.422, 10504000000, 0.25 +Res-1.423, 10504000000, 0.25 +Res-1.424, 10504000000, 0.25 +Res-1.425, 10504000000, 0.25 +Res-1.426, 10504000000, 0.25 +Res-1.427, 10504000000, 0.25 +Res-1.428, 10504000000, 0.25 +Res-1.429, 10648000000, 0.25 +Res-1.430, 10648000000, 0.25 +Res-1.431, 10648000000, 0.25 +Res-1.432, 10648000000, 0.25 +Res-1.433, 10648000000, 0.25 +Res-1.434, 10648000000, 0.25 +Res-1.435, 10648000000, 0.25 +Res-1.436, 10072000000, 0.25 +Res-1.437, 10216000000, 0.25 +Res-1.438, 10360000000, 0.25 +Res-1.439, 10504000000, 0.25 +Res-1.440, 10648000000, 0.25 +Res-1.441, 10072000000, 0.25 +Res-1.442, 10072000000, 0.25 +Res-1.443, 10072000000, 0.25 +Res-1.444, 10072000000, 0.25 +Res-1.445, 10072000000, 0.25 +Res-1.446, 10072000000, 0.25 +Res-1.447, 10072000000, 0.25 +Res-1.448, 10216000000, 0.25 +Res-1.449, 10216000000, 0.25 +Res-1.450, 10216000000, 0.25 +Res-1.451, 10216000000, 0.25 +Res-1.452, 10216000000, 0.25 +Res-1.453, 10216000000, 0.25 +Res-1.454, 10216000000, 0.25 +Res-1.455, 10360000000, 0.25 +Res-1.456, 10360000000, 0.25 +Res-1.457, 10360000000, 0.25 +Res-1.458, 10360000000, 0.25 +Res-1.459, 10360000000, 0.25 +Res-1.460, 10360000000, 0.25 +Res-1.461, 10360000000, 0.25 +Res-1.462, 10504000000, 0.25 +Res-1.463, 10504000000, 0.25 +Res-1.464, 10504000000, 0.25 +Res-1.465, 10504000000, 0.25 +Res-1.466, 10504000000, 0.25 +Res-1.467, 10504000000, 0.25 +Res-1.468, 10504000000, 0.25 +Res-1.469, 10648000000, 0.25 +Res-1.470, 10648000000, 0.25 +Res-1.471, 10648000000, 0.25 +Res-1.472, 10648000000, 0.25 +Res-1.473, 10648000000, 0.25 +Res-1.474, 10648000000, 0.25 +Res-1.475, 10648000000, 0.25 +Res-1.476, 10072000000, 0.25 +Res-1.477, 10216000000, 0.25 +Res-1.478, 10360000000, 0.25 +Res-1.479, 10504000000, 0.25 +Res-1.480, 10648000000, 0.25 +Res-1.481, 10072000000, 0.25 +Res-1.482, 10072000000, 0.25 +Res-1.483, 10072000000, 0.25 +Res-1.484, 10072000000, 0.25 +Res-1.485, 10072000000, 0.25 +Res-1.486, 10072000000, 0.25 +Res-1.487, 10072000000, 0.25 +Res-1.488, 10216000000, 0.25 +Res-1.489, 10216000000, 0.25 +Res-1.490, 10216000000, 0.25 +Res-1.491, 10216000000, 0.25 +Res-1.492, 10216000000, 0.25 +Res-1.493, 10216000000, 0.25 +Res-1.494, 10216000000, 0.25 +Res-1.495, 10360000000, 0.25 +Res-1.496, 10360000000, 0.25 +Res-1.497, 10360000000, 0.25 +Res-1.498, 10360000000, 0.25 +Res-1.499, 10360000000, 0.25 +Res-1.500, 10360000000, 0.25 +Res-1.501, 10360000000, 0.25 +Res-1.502, 10504000000, 0.25 +Res-1.503, 10504000000, 0.25 +Res-1.504, 10504000000, 0.25 +Res-1.505, 10504000000, 0.25 +Res-1.506, 10504000000, 0.25 +Res-1.507, 10504000000, 0.25 +Res-1.508, 10504000000, 0.25 +Res-1.509, 10648000000, 0.25 +Res-1.510, 10648000000, 0.25 +Res-1.511, 10648000000, 0.25 +Res-1.512, 10648000000, 0.25 +Res-1.513, 10648000000, 0.25 +Res-1.514, 10648000000, 0.25 +Res-1.515, 10648000000, 0.25 +Res-1.516, 10072000000, 0.25 +Res-1.517, 10216000000, 0.25 +Res-1.518, 10360000000, 0.25 +Res-1.519, 10504000000, 0.25 +Res-1.520, 10648000000, 0.25 +Res-1.521, 10072000000, 0.25 +Res-1.522, 10072000000, 0.25 +Res-1.523, 10072000000, 0.25 +Res-1.524, 10072000000, 0.25 +Res-1.525, 10072000000, 0.25 +Res-1.526, 10072000000, 0.25 +Res-1.527, 10072000000, 0.25 +Res-1.528, 10216000000, 0.25 +Res-1.529, 10216000000, 0.25 +Res-1.530, 10216000000, 0.25 +Res-1.531, 10216000000, 0.25 +Res-1.532, 10216000000, 0.25 +Res-1.533, 10216000000, 0.25 +Res-1.534, 10216000000, 0.25 +Res-1.535, 10360000000, 0.25 +Res-1.536, 10360000000, 0.25 +Res-1.537, 10360000000, 0.25 +Res-1.538, 10360000000, 0.25 +Res-1.539, 10360000000, 0.25 +Res-1.540, 10360000000, 0.25 +Res-1.541, 10360000000, 0.25 +Res-1.542, 10504000000, 0.25 +Res-1.543, 10504000000, 0.25 +Res-1.544, 10504000000, 0.25 +Res-1.545, 10504000000, 0.25 +Res-1.546, 10504000000, 0.25 +Res-1.547, 10504000000, 0.25 +Res-1.548, 10504000000, 0.25 +Res-1.549, 10648000000, 0.25 +Res-1.550, 10648000000, 0.25 +Res-1.551, 10648000000, 0.25 +Res-1.552, 10648000000, 0.25 +Res-1.553, 10648000000, 0.25 +Res-1.554, 10648000000, 0.25 +Res-1.555, 10648000000, 0.25 +Res-1.556, 10072000000, 0.25 +Res-1.557, 10216000000, 0.25 +Res-1.558, 10360000000, 0.25 +Res-1.559, 10504000000, 0.25 +Res-1.560, 10648000000, 0.25 +Res-1.561, 10072000000, 0.25 +Res-1.562, 10072000000, 0.25 +Res-1.563, 10072000000, 0.25 +Res-1.564, 10072000000, 0.25 +Res-1.565, 10072000000, 0.25 +Res-1.566, 10072000000, 0.25 +Res-1.567, 10072000000, 0.25 +Res-1.568, 10216000000, 0.25 +Res-1.569, 10216000000, 0.25 +Res-1.570, 10216000000, 0.25 +Res-1.571, 10216000000, 0.25 +Res-1.572, 10216000000, 0.25 +Res-1.573, 10216000000, 0.25 +Res-1.574, 10216000000, 0.25 +Res-1.575, 10360000000, 0.25 +Res-1.576, 10360000000, 0.25 +Res-1.577, 10360000000, 0.25 +Res-1.578, 10360000000, 0.25 +Res-1.579, 10360000000, 0.25 +Res-1.580, 10360000000, 0.25 +Res-1.581, 10360000000, 0.25 +Res-1.582, 10504000000, 0.25 +Res-1.583, 10504000000, 0.25 +Res-1.584, 10504000000, 0.25 +Res-1.585, 10504000000, 0.25 +Res-1.586, 10504000000, 0.25 +Res-1.587, 10504000000, 0.25 +Res-1.588, 10504000000, 0.25 +Res-1.589, 10648000000, 0.25 +Res-1.590, 10648000000, 0.25 +Res-1.591, 10648000000, 0.25 +Res-1.592, 10648000000, 0.25 +Res-1.593, 10648000000, 0.25 +Res-1.594, 10648000000, 0.25 +Res-1.595, 10648000000, 0.25 +Res-1.596, 10072000000, 0.25 +Res-1.597, 10216000000, 0.25 +Res-1.598, 10360000000, 0.25 +Res-1.599, 10504000000, 0.25 +Res-1.600, 10648000000, 0.25 +Res-1.601, 10072000000, 0.25 +Res-1.602, 10072000000, 0.25 +Res-1.603, 10072000000, 0.25 +Res-1.604, 10072000000, 0.25 +Res-1.605, 10072000000, 0.25 +Res-1.606, 10072000000, 0.25 +Res-1.607, 10072000000, 0.25 +Res-1.608, 10216000000, 0.25 +Res-1.609, 10216000000, 0.25 +Res-1.610, 10216000000, 0.25 +Res-1.611, 10216000000, 0.25 +Res-1.612, 10216000000, 0.25 +Res-1.613, 10216000000, 0.25 +Res-1.614, 10216000000, 0.25 +Res-1.615, 10360000000, 0.25 +Res-1.616, 10360000000, 0.25 +Res-1.617, 10360000000, 0.25 +Res-1.618, 10360000000, 0.25 +Res-1.619, 10360000000, 0.25 +Res-1.620, 10360000000, 0.25 +Res-1.621, 10360000000, 0.25 +Res-1.622, 10504000000, 0.25 +Res-1.623, 10504000000, 0.25 +Res-1.624, 10504000000, 0.25 +Res-1.625, 10504000000, 0.25 +Res-1.626, 10504000000, 0.25 +Res-1.627, 10504000000, 0.25 +Res-1.628, 10504000000, 0.25 +Res-1.629, 10648000000, 0.25 +Res-1.630, 10648000000, 0.25 +Res-1.631, 10648000000, 0.25 +Res-1.632, 10648000000, 0.25 +Res-1.633, 10648000000, 0.25 +Res-1.634, 10648000000, 0.25 +Res-1.635, 10648000000, 0.25 +Res-1.636, 10072000000, 0.25 +Res-1.637, 10216000000, 0.25 +Res-1.638, 10360000000, 0.25 +Res-1.639, 10504000000, 0.25 +Res-1.640, 10648000000, 0.25 +Res-1.641, 10072000000, 0.25 +Res-1.642, 10072000000, 0.25 +Res-1.643, 10072000000, 0.25 +Res-1.644, 10072000000, 0.25 +Res-1.645, 10072000000, 0.25 +Res-1.646, 10072000000, 0.25 +Res-1.647, 10216000000, 0.25 +Res-1.648, 10216000000, 0.25 +Res-1.649, 10216000000, 0.25 +Res-1.650, 10216000000, 0.25 +Res-1.651, 10216000000, 0.25 +Res-1.652, 10216000000, 0.25 +Res-1.653, 10360000000, 0.25 +Res-1.654, 10360000000, 0.25 +Res-1.655, 10360000000, 0.25 +Res-1.656, 10360000000, 0.25 +Res-1.657, 10360000000, 0.25 +Res-1.658, 10360000000, 0.25 +Res-1.659, 10504000000, 0.25 +Res-1.660, 10504000000, 0.25 +Res-1.661, 10504000000, 0.25 +Res-1.662, 10504000000, 0.25 +Res-1.663, 10504000000, 0.25 +Res-1.664, 10504000000, 0.25 +Res-1.665, 10648000000, 0.25 +Res-1.666, 10648000000, 0.25 +Res-1.667, 10648000000, 0.25 +Res-1.668, 10648000000, 0.25 +Res-1.669, 10648000000, 0.25 +Res-1.670, 10648000000, 0.25 +Res-1.671, 10072000000, 0.25 +Res-1.672, 10216000000, 0.25 +Res-1.673, 10360000000, 0.25 +Res-1.674, 10504000000, 0.25 +Res-1.675, 10648000000, 0.25 +Res-1.676, 10072000000, 0.25 +Res-1.677, 10216000000, 0.25 +Res-1.678, 10360000000, 0.25 +Res-1.679, 10504000000, 0.25 +Res-1.680, 10648000000, 0.25 +Res-1.681, 10072000000, 0.25 +Res-1.682, 10216000000, 0.25 +Res-1.683, 10360000000, 0.25 +Res-1.684, 10504000000, 0.25 +Res-1.685, 10648000000, 0.25 +Res-1.686, 10072000000, 0.25 +Res-1.687, 10216000000, 0.25 +Res-1.688, 10360000000, 0.25 +Res-1.689, 10504000000, 0.25 +Res-1.690, 10648000000, 0.25 +Res-1.691, 10072000000, 0.25 +Res-1.692, 10216000000, 0.25 +Res-1.693, 10360000000, 0.25 +Res-1.694, 10504000000, 0.25 +Res-1.695, 10648000000, 0.25 +Res-1.696, 10072000000, 0.25 +Res-1.697, 10216000000, 0.25 +Res-1.698, 10360000000, 0.25 +Res-1.699, 10504000000, 0.25 +Res-1.700, 10648000000, 0.25 +Res-1.701, 10072000000, 0.25 +Res-1.702, 10216000000, 0.25 +Res-1.703, 10360000000, 0.25 +Res-1.704, 10504000000, 0.25 +Res-1.705, 10648000000, 0.25 +Res-1.706, 10072000000, 0.25 +Res-1.707, 10216000000, 0.25 +Res-1.708, 10360000000, 0.25 +Res-1.709, 10504000000, 0.25 +Res-1.710, 10648000000, 0.25 +Res-1.711, 10072000000, 0.25 +Res-1.712, 10216000000, 0.25 +Res-1.713, 10360000000, 0.25 +Res-1.714, 10504000000, 0.25 +Res-1.715, 10648000000, 0.25 +Res-1.716, 10072000000, 0.25 +Res-1.717, 10216000000, 0.25 +Res-1.718, 10360000000, 0.25 +Res-1.719, 10504000000, 0.25 +Res-1.720, 10648000000, 0.25 +Res-1.721, 10072000000, 0.25 +Res-1.722, 10072000000, 0.25 +Res-1.723, 10072000000, 0.25 +Res-1.724, 10072000000, 0.25 +Res-1.725, 10072000000, 0.25 +Res-1.726, 10072000000, 0.25 +Res-1.727, 10216000000, 0.25 +Res-1.728, 10216000000, 0.25 +Res-1.729, 10216000000, 0.25 +Res-1.730, 10216000000, 0.25 +Res-1.731, 10216000000, 0.25 +Res-1.732, 10216000000, 0.25 +Res-1.733, 10360000000, 0.25 +Res-1.734, 10360000000, 0.25 +Res-1.735, 10360000000, 0.25 +Res-1.736, 10360000000, 0.25 +Res-1.737, 10360000000, 0.25 +Res-1.738, 10360000000, 0.25 +Res-1.739, 10504000000, 0.25 +Res-1.740, 10504000000, 0.25 +Res-1.741, 10504000000, 0.25 +Res-1.742, 10504000000, 0.25 +Res-1.743, 10504000000, 0.25 +Res-1.744, 10504000000, 0.25 +Res-1.745, 10648000000, 0.25 +Res-1.746, 10648000000, 0.25 +Res-1.747, 10648000000, 0.25 +Res-1.748, 10648000000, 0.25 +Res-1.749, 10648000000, 0.25 +Res-1.750, 10648000000, 0.25 +Res-1.751, 10072000000, 0.25 +Res-1.752, 10216000000, 0.25 +Res-1.753, 10360000000, 0.25 +Res-1.754, 10504000000, 0.25 +Res-1.755, 10648000000, 0.25 +Res-1.756, 10072000000, 0.25 +Res-1.757, 10216000000, 0.25 +Res-1.758, 10360000000, 0.25 +Res-1.759, 10504000000, 0.25 +Res-1.760, 10648000000, 0.25 +Res-1.761, 10072000000, 0.25 +Res-1.762, 10216000000, 0.25 +Res-1.763, 10360000000, 0.25 +Res-1.764, 10504000000, 0.25 +Res-1.765, 10648000000, 0.25 +Res-1.766, 10072000000, 0.25 +Res-1.767, 10216000000, 0.25 +Res-1.768, 10360000000, 0.25 +Res-1.769, 10504000000, 0.25 +Res-1.770, 10648000000, 0.25 +Res-1.771, 10072000000, 0.25 +Res-1.772, 10216000000, 0.25 +Res-1.773, 10360000000, 0.25 +Res-1.774, 10504000000, 0.25 +Res-1.775, 10648000000, 0.25 +Res-1.776, 10072000000, 0.25 +Res-1.777, 10216000000, 0.25 +Res-1.778, 10360000000, 0.25 +Res-1.779, 10504000000, 0.25 +Res-1.780, 10648000000, 0.25 +Res-1.781, 10072000000, 0.25 +Res-1.782, 10216000000, 0.25 +Res-1.783, 10360000000, 0.25 +Res-1.784, 10504000000, 0.25 +Res-1.785, 10648000000, 0.25 +Res-1.786, 10072000000, 0.25 +Res-1.787, 10216000000, 0.25 +Res-1.788, 10360000000, 0.25 +Res-1.789, 10504000000, 0.25 +Res-1.790, 10648000000, 0.25 +Res-1.791, 10072000000, 0.25 +Res-1.792, 10216000000, 0.25 +Res-1.793, 10360000000, 0.25 +Res-1.794, 10504000000, 0.25 +Res-1.795, 10648000000, 0.25 +Res-1.796, 10072000000, 0.25 +Res-1.797, 10216000000, 0.25 +Res-1.798, 10360000000, 0.25 +Res-1.799, 10504000000, 0.25 +Res-1.800, 10648000000, 0.25 +Res-1.801, 10072000000, 0.25 +Res-1.802, 10072000000, 0.25 +Res-1.803, 10072000000, 0.25 +Res-1.804, 10072000000, 0.25 +Res-1.805, 10072000000, 0.25 +Res-1.806, 10072000000, 0.25 +Res-1.807, 10216000000, 0.25 +Res-1.808, 10216000000, 0.25 +Res-1.809, 10216000000, 0.25 +Res-1.810, 10216000000, 0.25 +Res-1.811, 10216000000, 0.25 +Res-1.812, 10216000000, 0.25 +Res-1.813, 10360000000, 0.25 +Res-1.814, 10360000000, 0.25 +Res-1.815, 10360000000, 0.25 +Res-1.816, 10360000000, 0.25 +Res-1.817, 10360000000, 0.25 +Res-1.818, 10360000000, 0.25 +Res-1.819, 10504000000, 0.25 +Res-1.820, 10504000000, 0.25 +Res-1.821, 10504000000, 0.25 +Res-1.822, 10504000000, 0.25 +Res-1.823, 10504000000, 0.25 +Res-1.824, 10504000000, 0.25 +Res-1.825, 10648000000, 0.25 +Res-1.826, 10648000000, 0.25 +Res-1.827, 10648000000, 0.25 +Res-1.828, 10648000000, 0.25 +Res-1.829, 10648000000, 0.25 +Res-1.830, 10648000000, 0.25 +Res-1.831, 10072000000, 0.25 +Res-1.832, 10216000000, 0.25 +Res-1.833, 10360000000, 0.25 +Res-1.834, 10504000000, 0.25 +Res-1.835, 10648000000, 0.25 +Res-1.836, 10072000000, 0.25 +Res-1.837, 10216000000, 0.25 +Res-1.838, 10360000000, 0.25 +Res-1.839, 10504000000, 0.25 +Res-1.840, 10648000000, 0.25 +Res-1.841, 10072000000, 0.25 +Res-1.842, 10216000000, 0.25 +Res-1.843, 10360000000, 0.25 +Res-1.844, 10504000000, 0.25 +Res-1.845, 10648000000, 0.25 +Res-1.846, 10072000000, 0.25 +Res-1.847, 10216000000, 0.25 +Res-1.848, 10360000000, 0.25 +Res-1.849, 10504000000, 0.25 +Res-1.850, 10648000000, 0.25 +Res-1.851, 10072000000, 0.25 +Res-1.852, 10216000000, 0.25 +Res-1.853, 10360000000, 0.25 +Res-1.854, 10504000000, 0.25 +Res-1.855, 10648000000, 0.25 +Res-1.856, 10072000000, 0.25 +Res-1.857, 10216000000, 0.25 +Res-1.858, 10360000000, 0.25 +Res-1.859, 10504000000, 0.25 +Res-1.860, 10648000000, 0.25 +Res-1.861, 10072000000, 0.25 +Res-1.862, 10216000000, 0.25 +Res-1.863, 10360000000, 0.25 +Res-1.864, 10504000000, 0.25 +Res-1.865, 10648000000, 0.25 +Res-1.866, 10072000000, 0.25 +Res-1.867, 10216000000, 0.25 +Res-1.868, 10360000000, 0.25 +Res-1.869, 10504000000, 0.25 +Res-1.870, 10648000000, 0.25 +Res-1.871, 10072000000, 0.25 +Res-1.872, 10216000000, 0.25 +Res-1.873, 10360000000, 0.25 +Res-1.874, 10504000000, 0.25 +Res-1.875, 10648000000, 0.25 +Res-1.876, 10072000000, 0.25 +Res-1.877, 10216000000, 0.25 +Res-1.878, 10360000000, 0.25 +Res-1.879, 10504000000, 0.25 +Res-1.880, 10648000000, 0.25 +Res-1.881, 10072000000, 0.25 +Res-1.882, 10072000000, 0.25 +Res-1.883, 10072000000, 0.25 +Res-1.884, 10072000000, 0.25 +Res-1.885, 10072000000, 0.25 +Res-1.886, 10072000000, 0.25 +Res-1.887, 10216000000, 0.25 +Res-1.888, 10216000000, 0.25 +Res-1.889, 10216000000, 0.25 +Res-1.890, 10216000000, 0.25 +Res-1.891, 10216000000, 0.25 +Res-1.892, 10216000000, 0.25 +Res-1.893, 10360000000, 0.25 +Res-1.894, 10360000000, 0.25 +Res-1.895, 10360000000, 0.25 +Res-1.896, 10360000000, 0.25 +Res-1.897, 10360000000, 0.25 +Res-1.898, 10360000000, 0.25 +Res-1.899, 10504000000, 0.25 +Res-1.900, 10504000000, 0.25 +Res-1.901, 10504000000, 0.25 +Res-1.902, 10504000000, 0.25 +Res-1.903, 10504000000, 0.25 +Res-1.904, 10504000000, 0.25 +Res-1.905, 10648000000, 0.25 +Res-1.906, 10648000000, 0.25 +Res-1.907, 10648000000, 0.25 +Res-1.908, 10648000000, 0.25 +Res-1.909, 10648000000, 0.25 +Res-1.910, 10648000000, 0.25 +Res-1.911, 10072000000, 0.25 +Res-1.912, 10216000000, 0.25 +Res-1.913, 10360000000, 0.25 +Res-1.914, 10504000000, 0.25 +Res-1.915, 10648000000, 0.25 +Res-1.916, 10072000000, 0.25 +Res-1.917, 10216000000, 0.25 +Res-1.918, 10360000000, 0.25 +Res-1.919, 10504000000, 0.25 +Res-1.920, 10648000000, 0.25 +Res-1.921, 10072000000, 0.25 +Res-1.922, 10216000000, 0.25 +Res-1.923, 10360000000, 0.25 +Res-1.924, 10504000000, 0.25 +Res-1.925, 10648000000, 0.25 +Res-1.926, 10072000000, 0.25 +Res-1.927, 10216000000, 0.25 +Res-1.928, 10360000000, 0.25 +Res-1.929, 10504000000, 0.25 +Res-1.930, 10648000000, 0.25 +Res-1.931, 10072000000, 0.25 +Res-1.932, 10216000000, 0.25 +Res-1.933, 10360000000, 0.25 +Res-1.934, 10504000000, 0.25 +Res-1.935, 10648000000, 0.25 +Res-1.936, 10072000000, 0.25 +Res-1.937, 10216000000, 0.25 +Res-1.938, 10360000000, 0.25 +Res-1.939, 10504000000, 0.25 +Res-1.940, 10648000000, 0.25 +Res-1.941, 10072000000, 0.25 +Res-1.942, 10216000000, 0.25 +Res-1.943, 10360000000, 0.25 +Res-1.944, 10504000000, 0.25 +Res-1.945, 10648000000, 0.25 +Res-1.946, 10072000000, 0.25 +Res-1.947, 10216000000, 0.25 +Res-1.948, 10360000000, 0.25 +Res-1.949, 10504000000, 0.25 +Res-1.950, 10648000000, 0.25 +Res-1.951, 10072000000, 0.25 +Res-1.952, 10216000000, 0.25 +Res-1.953, 10360000000, 0.25 +Res-1.954, 10504000000, 0.25 +Res-1.955, 10648000000, 0.25 +Res-1.956, 10072000000, 0.25 +Res-1.957, 10216000000, 0.25 +Res-1.958, 10360000000, 0.25 +Res-1.959, 10504000000, 0.25 +Res-1.960, 10648000000, 0.25 +Res-1.961, 10072000000, 0.25 +Res-1.962, 10072000000, 0.25 +Res-1.963, 10072000000, 0.25 +Res-1.964, 10072000000, 0.25 +Res-1.965, 10072000000, 0.25 +Res-1.966, 10072000000, 0.25 +Res-1.967, 10216000000, 0.25 +Res-1.968, 10216000000, 0.25 +Res-1.969, 10216000000, 0.25 +Res-1.970, 10216000000, 0.25 +Res-1.971, 10216000000, 0.25 +Res-1.972, 10216000000, 0.25 +Res-1.973, 10360000000, 0.25 +Res-1.974, 10360000000, 0.25 +Res-1.975, 10360000000, 0.25 +Res-1.976, 10360000000, 0.25 +Res-1.977, 10360000000, 0.25 +Res-1.978, 10360000000, 0.25 +Res-1.979, 10504000000, 0.25 +Res-1.980, 10504000000, 0.25 +Res-1.981, 10504000000, 0.25 +Res-1.982, 10504000000, 0.25 +Res-1.983, 10504000000, 0.25 +Res-1.984, 10504000000, 0.25 +Res-1.985, 10648000000, 0.25 +Res-1.986, 10648000000, 0.25 +Res-1.987, 10648000000, 0.25 +Res-1.988, 10648000000, 0.25 +Res-1.989, 10648000000, 0.25 +Res-1.990, 10648000000, 0.25 +Res-1.991, 10072000000, 0.25 +Res-1.992, 10216000000, 0.25 +Res-1.993, 10360000000, 0.25 +Res-1.994, 10504000000, 0.25 +Res-1.995, 10648000000, 0.25 +Res-1.996, 10072000000, 0.25 +Res-1.997, 10216000000, 0.25 +Res-1.998, 10360000000, 0.25 +Res-1.999, 10504000000, 0.25 +Res-1.1000, 10648000000, 0.25 +Res-1.1001, 10072000000, 0.25 +Res-1.1002, 10216000000, 0.25 +Res-1.1003, 10360000000, 0.25 +Res-1.1004, 10504000000, 0.25 +Res-1.1005, 10648000000, 0.25 +Res-1.1006, 10072000000, 0.25 +Res-1.1007, 10216000000, 0.25 +Res-1.1008, 10360000000, 0.25 +Res-1.1009, 10504000000, 0.25 +Res-1.1010, 10648000000, 0.25 +Res-1.1011, 10072000000, 0.25 +Res-1.1012, 10216000000, 0.25 +Res-1.1013, 10360000000, 0.25 +Res-1.1014, 10504000000, 0.25 +Res-1.1015, 10648000000, 0.25 +Res-1.1016, 10072000000, 0.25 +Res-1.1017, 10216000000, 0.25 +Res-1.1018, 10360000000, 0.25 +Res-1.1019, 10504000000, 0.25 +Res-1.1020, 10648000000, 0.25 +Res-1.1021, 10072000000, 0.25 +Res-1.1022, 10216000000, 0.25 +Res-1.1023, 10360000000, 0.25 +Res-1.1024, 10504000000, 0.25 +Res-1.1025, 10648000000, 0.25 +Res-1.1026, 10072000000, 0.25 +Res-1.1027, 10216000000, 0.25 +Res-1.1028, 10360000000, 0.25 +Res-1.1029, 10504000000, 0.25 +Res-1.1030, 10648000000, 0.25 +Res-1.1031, 10072000000, 0.25 +Res-1.1032, 10216000000, 0.25 +Res-1.1033, 10360000000, 0.25 +Res-1.1034, 10504000000, 0.25 +Res-1.1035, 10648000000, 0.25 +Res-1.1036, 10072000000, 0.25 +Res-1.1037, 10216000000, 0.25 +Res-1.1038, 10360000000, 0.25 +Res-1.1039, 10504000000, 0.25 +Res-1.1040, 10648000000, 0.25 +Res-1.1041, 10072000000, 0.25 +Res-1.1042, 10072000000, 0.25 +Res-1.1043, 10072000000, 0.25 +Res-1.1044, 10072000000, 0.25 +Res-1.1045, 10072000000, 0.25 +Res-1.1046, 10072000000, 0.25 +Res-1.1047, 10216000000, 0.25 +Res-1.1048, 10216000000, 0.25 +Res-1.1049, 10216000000, 0.25 +Res-1.1050, 10216000000, 0.25 +Res-1.1051, 10216000000, 0.25 +Res-1.1052, 10216000000, 0.25 +Res-1.1053, 10360000000, 0.25 +Res-1.1054, 10360000000, 0.25 +Res-1.1055, 10360000000, 0.25 +Res-1.1056, 10360000000, 0.25 +Res-1.1057, 10360000000, 0.25 +Res-1.1058, 10360000000, 0.25 +Res-1.1059, 10504000000, 0.25 +Res-1.1060, 10504000000, 0.25 +Res-1.1061, 10504000000, 0.25 +Res-1.1062, 10504000000, 0.25 +Res-1.1063, 10504000000, 0.25 +Res-1.1064, 10504000000, 0.25 +Res-1.1065, 10648000000, 0.25 +Res-1.1066, 10648000000, 0.25 +Res-1.1067, 10648000000, 0.25 +Res-1.1068, 10648000000, 0.25 +Res-1.1069, 10648000000, 0.25 +Res-1.1070, 10648000000, 0.25 +Res-1.1071, 10072000000, 0.25 +Res-1.1072, 10216000000, 0.25 +Res-1.1073, 10360000000, 0.25 +Res-1.1074, 10504000000, 0.25 +Res-1.1075, 10648000000, 0.25 +Res-1.1076, 10072000000, 0.25 +Res-1.1077, 10216000000, 0.25 +Res-1.1078, 10360000000, 0.25 +Res-1.1079, 10504000000, 0.25 +Res-1.1080, 10648000000, 0.25 +Res-1.1081, 10072000000, 0.25 +Res-1.1082, 10216000000, 0.25 +Res-1.1083, 10360000000, 0.25 +Res-1.1084, 10504000000, 0.25 +Res-1.1085, 10648000000, 0.25 +Res-1.1086, 10072000000, 0.25 +Res-1.1087, 10216000000, 0.25 +Res-1.1088, 10360000000, 0.25 +Res-1.1089, 10504000000, 0.25 +Res-1.1090, 10648000000, 0.25 +Res-1.1091, 10072000000, 0.25 +Res-1.1092, 10216000000, 0.25 +Res-1.1093, 10360000000, 0.25 +Res-1.1094, 10504000000, 0.25 +Res-1.1095, 10648000000, 0.25 +Res-1.1096, 10072000000, 0.25 +Res-1.1097, 10216000000, 0.25 +Res-1.1098, 10360000000, 0.25 +Res-1.1099, 10504000000, 0.25 +Res-1.1100, 10648000000, 0.25 +Res-1.1101, 10072000000, 0.25 +Res-1.1102, 10216000000, 0.25 +Res-1.1103, 10360000000, 0.25 +Res-1.1104, 10504000000, 0.25 +Res-1.1105, 10648000000, 0.25 +Res-1.1106, 10072000000, 0.25 +Res-1.1107, 10216000000, 0.25 +Res-1.1108, 10360000000, 0.25 +Res-1.1109, 10504000000, 0.25 +Res-1.1110, 10648000000, 0.25 +Res-1.1111, 10072000000, 0.25 +Res-1.1112, 10216000000, 0.25 +Res-1.1113, 10360000000, 0.25 +Res-1.1114, 10504000000, 0.25 +Res-1.1115, 10648000000, 0.25 +Res-1.1116, 10072000000, 0.25 +Res-1.1117, 10216000000, 0.25 +Res-1.1118, 10360000000, 0.25 +Res-1.1119, 10504000000, 0.25 +Res-1.1120, 10648000000, 0.25 +Res-1.1121, 10072000000, 0.25 +Res-1.1122, 10072000000, 0.25 +Res-1.1123, 10072000000, 0.25 +Res-1.1124, 10072000000, 0.25 +Res-1.1125, 10072000000, 0.25 +Res-1.1126, 10072000000, 0.25 +Res-1.1127, 10216000000, 0.25 +Res-1.1128, 10216000000, 0.25 +Res-1.1129, 10216000000, 0.25 +Res-1.1130, 10216000000, 0.25 +Res-1.1131, 10216000000, 0.25 +Res-1.1132, 10216000000, 0.25 +Res-1.1133, 10360000000, 0.25 +Res-1.1134, 10360000000, 0.25 +Res-1.1135, 10360000000, 0.25 +Res-1.1136, 10360000000, 0.25 +Res-1.1137, 10360000000, 0.25 +Res-1.1138, 10360000000, 0.25 +Res-1.1139, 10504000000, 0.25 +Res-1.1140, 10504000000, 0.25 +Res-1.1141, 10504000000, 0.25 +Res-1.1142, 10504000000, 0.25 +Res-1.1143, 10504000000, 0.25 +Res-1.1144, 10504000000, 0.25 +Res-1.1145, 10648000000, 0.25 +Res-1.1146, 10648000000, 0.25 +Res-1.1147, 10648000000, 0.25 +Res-1.1148, 10648000000, 0.25 +Res-1.1149, 10648000000, 0.25 +Res-1.1150, 10648000000, 0.25 +Res-1.1151, 10072000000, 0.25 +Res-1.1152, 10216000000, 0.25 +Res-1.1153, 10360000000, 0.25 +Res-1.1154, 10504000000, 0.25 +Res-1.1155, 10648000000, 0.25 +Res-1.1156, 10072000000, 0.25 +Res-1.1157, 10216000000, 0.25 +Res-1.1158, 10360000000, 0.25 +Res-1.1159, 10504000000, 0.25 +Res-1.1160, 10648000000, 0.25 +Res-1.1161, 10072000000, 0.25 +Res-1.1162, 10216000000, 0.25 +Res-1.1163, 10360000000, 0.25 +Res-1.1164, 10504000000, 0.25 +Res-1.1165, 10648000000, 0.25 +Res-1.1166, 10072000000, 0.25 +Res-1.1167, 10216000000, 0.25 +Res-1.1168, 10360000000, 0.25 +Res-1.1169, 10504000000, 0.25 +Res-1.1170, 10648000000, 0.25 +Res-1.1171, 10072000000, 0.25 +Res-1.1172, 10216000000, 0.25 +Res-1.1173, 10360000000, 0.25 +Res-1.1174, 10504000000, 0.25 +Res-1.1175, 10648000000, 0.25 +Res-1.1176, 10072000000, 0.25 +Res-1.1177, 10216000000, 0.25 +Res-1.1178, 10360000000, 0.25 +Res-1.1179, 10504000000, 0.25 +Res-1.1180, 10648000000, 0.25 +Res-1.1181, 10072000000, 0.25 +Res-1.1182, 10216000000, 0.25 +Res-1.1183, 10360000000, 0.25 +Res-1.1184, 10504000000, 0.25 +Res-1.1185, 10648000000, 0.25 +Res-1.1186, 10072000000, 0.25 +Res-1.1187, 10216000000, 0.25 +Res-1.1188, 10360000000, 0.25 +Res-1.1189, 10504000000, 0.25 +Res-1.1190, 10648000000, 0.25 +Res-1.1191, 10072000000, 0.25 +Res-1.1192, 10216000000, 0.25 +Res-1.1193, 10360000000, 0.25 +Res-1.1194, 10504000000, 0.25 +Res-1.1195, 10648000000, 0.25 +Res-1.1196, 10072000000, 0.25 +Res-1.1197, 10216000000, 0.25 +Res-1.1198, 10360000000, 0.25 +Res-1.1199, 10504000000, 0.25 +Res-1.1200, 10648000000, 0.25 +Res-1.1201, 10072000000, 0.25 +Res-1.1202, 10072000000, 0.25 +Res-1.1203, 10072000000, 0.25 +Res-1.1204, 10072000000, 0.25 +Res-1.1205, 10072000000, 0.25 +Res-1.1206, 10072000000, 0.25 +Res-1.1207, 10216000000, 0.25 +Res-1.1208, 10216000000, 0.25 +Res-1.1209, 10216000000, 0.25 +Res-1.1210, 10216000000, 0.25 +Res-1.1211, 10216000000, 0.25 +Res-1.1212, 10216000000, 0.25 +Res-1.1213, 10360000000, 0.25 +Res-1.1214, 10360000000, 0.25 +Res-1.1215, 10360000000, 0.25 +Res-1.1216, 10360000000, 0.25 +Res-1.1217, 10360000000, 0.25 +Res-1.1218, 10360000000, 0.25 +Res-1.1219, 10504000000, 0.25 +Res-1.1220, 10504000000, 0.25 +Res-1.1221, 10504000000, 0.25 +Res-1.1222, 10504000000, 0.25 +Res-1.1223, 10504000000, 0.25 +Res-1.1224, 10504000000, 0.25 +Res-1.1225, 10648000000, 0.25 +Res-1.1226, 10648000000, 0.25 +Res-1.1227, 10648000000, 0.25 +Res-1.1228, 10648000000, 0.25 +Res-1.1229, 10648000000, 0.25 +Res-1.1230, 10648000000, 0.25 +Res-1.1231, 10072000000, 0.25 +Res-1.1232, 10216000000, 0.25 +Res-1.1233, 10360000000, 0.25 +Res-1.1234, 10504000000, 0.25 +Res-1.1235, 10648000000, 0.25 +Res-1.1236, 10072000000, 0.25 +Res-1.1237, 10216000000, 0.25 +Res-1.1238, 10360000000, 0.25 +Res-1.1239, 10504000000, 0.25 +Res-1.1240, 10648000000, 0.25 +Res-1.1241, 10072000000, 0.25 +Res-1.1242, 10216000000, 0.25 +Res-1.1243, 10360000000, 0.25 +Res-1.1244, 10504000000, 0.25 +Res-1.1245, 10648000000, 0.25 +Res-1.1246, 10072000000, 0.25 +Res-1.1247, 10216000000, 0.25 +Res-1.1248, 10360000000, 0.25 +Res-1.1249, 10504000000, 0.25 +Res-1.1250, 10648000000, 0.25 +Res-1.1251, 10072000000, 0.25 +Res-1.1252, 10216000000, 0.25 +Res-1.1253, 10360000000, 0.25 +Res-1.1254, 10504000000, 0.25 +Res-1.1255, 10648000000, 0.25 +Res-1.1256, 10072000000, 0.25 +Res-1.1257, 10216000000, 0.25 +Res-1.1258, 10360000000, 0.25 +Res-1.1259, 10504000000, 0.25 +Res-1.1260, 10648000000, 0.25 +Res-1.1261, 10072000000, 0.25 +Res-1.1262, 10216000000, 0.25 +Res-1.1263, 10360000000, 0.25 +Res-1.1264, 10504000000, 0.25 +Res-1.1265, 10648000000, 0.25 +Res-1.1266, 10072000000, 0.25 +Res-1.1267, 10216000000, 0.25 +Res-1.1268, 10360000000, 0.25 +Res-1.1269, 10504000000, 0.25 +Res-1.1270, 10648000000, 0.25 +Res-1.1271, 10072000000, 0.25 +Res-1.1272, 10216000000, 0.25 +Res-1.1273, 10360000000, 0.25 +Res-1.1274, 10504000000, 0.25 +Res-1.1275, 10648000000, 0.25 +Res-1.1276, 10072000000, 0.25 +Res-1.1277, 10216000000, 0.25 +Res-1.1278, 10360000000, 0.25 +Res-1.1279, 10504000000, 0.25 +Res-1.1280, 10648000000, 0.25 +Res-1.1281, 10072000000, 0.25 +Res-1.1282, 10072000000, 0.25 +Res-1.1283, 10072000000, 0.25 +Res-1.1284, 10072000000, 0.25 +Res-1.1285, 10072000000, 0.25 +Res-1.1286, 10072000000, 0.25 +Res-1.1287, 10216000000, 0.25 +Res-1.1288, 10216000000, 0.25 +Res-1.1289, 10216000000, 0.25 +Res-1.1290, 10216000000, 0.25 +Res-1.1291, 10216000000, 0.25 +Res-1.1292, 10216000000, 0.25 +Res-1.1293, 10360000000, 0.25 +Res-1.1294, 10360000000, 0.25 +Res-1.1295, 10360000000, 0.25 +Res-1.1296, 10360000000, 0.25 +Res-1.1297, 10360000000, 0.25 +Res-1.1298, 10360000000, 0.25 +Res-1.1299, 10504000000, 0.25 +Res-1.1300, 10504000000, 0.25 +Res-1.1301, 10504000000, 0.25 +Res-1.1302, 10504000000, 0.25 +Res-1.1303, 10504000000, 0.25 +Res-1.1304, 10504000000, 0.25 +Res-1.1305, 10648000000, 0.25 +Res-1.1306, 10648000000, 0.25 +Res-1.1307, 10648000000, 0.25 +Res-1.1308, 10648000000, 0.25 +Res-1.1309, 10648000000, 0.25 +Res-1.1310, 10648000000, 0.25 +Res-1.1311, 10072000000, 0.25 +Res-1.1312, 10216000000, 0.25 +Res-1.1313, 10360000000, 0.25 +Res-1.1314, 10504000000, 0.25 +Res-1.1315, 10648000000, 0.25 +Res-1.1316, 10072000000, 0.25 +Res-1.1317, 10216000000, 0.25 +Res-1.1318, 10360000000, 0.25 +Res-1.1319, 10504000000, 0.25 +Res-1.1320, 10648000000, 0.25 +Res-1.1321, 10072000000, 0.25 +Res-1.1322, 10216000000, 0.25 +Res-1.1323, 10360000000, 0.25 +Res-1.1324, 10504000000, 0.25 +Res-1.1325, 10648000000, 0.25 +Res-1.1326, 10072000000, 0.25 +Res-1.1327, 10216000000, 0.25 +Res-1.1328, 10360000000, 0.25 +Res-1.1329, 10504000000, 0.25 +Res-1.1330, 10648000000, 0.25 +Res-1.1331, 10072000000, 0.25 +Res-1.1332, 10216000000, 0.25 +Res-1.1333, 10360000000, 0.25 +Res-1.1334, 10504000000, 0.25 +Res-1.1335, 10648000000, 0.25 +Res-1.1336, 10072000000, 0.25 +Res-1.1337, 10216000000, 0.25 +Res-1.1338, 10360000000, 0.25 +Res-1.1339, 10504000000, 0.25 +Res-1.1340, 10648000000, 0.25 +Res-1.1341, 10072000000, 0.25 +Res-1.1342, 10216000000, 0.25 +Res-1.1343, 10360000000, 0.25 +Res-1.1344, 10504000000, 0.25 +Res-1.1345, 10648000000, 0.25 +Res-1.1346, 10072000000, 0.25 +Res-1.1347, 10216000000, 0.25 +Res-1.1348, 10360000000, 0.25 +Res-1.1349, 10504000000, 0.25 +Res-1.1350, 10648000000, 0.25 +Res-1.1351, 10072000000, 0.25 +Res-1.1352, 10216000000, 0.25 +Res-1.1353, 10360000000, 0.25 +Res-1.1354, 10504000000, 0.25 +Res-1.1355, 10648000000, 0.25 +Res-1.1356, 10072000000, 0.25 +Res-1.1357, 10216000000, 0.25 +Res-1.1358, 10360000000, 0.25 +Res-1.1359, 10504000000, 0.25 +Res-1.1360, 10648000000, 0.25 +Res-1.1361, 10072000000, 0.25 +Res-1.1362, 10072000000, 0.25 +Res-1.1363, 10072000000, 0.25 +Res-1.1364, 10072000000, 0.25 +Res-1.1365, 10072000000, 0.25 +Res-1.1366, 10072000000, 0.25 +Res-1.1367, 10216000000, 0.25 +Res-1.1368, 10216000000, 0.25 +Res-1.1369, 10216000000, 0.25 +Res-1.1370, 10216000000, 0.25 +Res-1.1371, 10216000000, 0.25 +Res-1.1372, 10216000000, 0.25 +Res-1.1373, 10360000000, 0.25 +Res-1.1374, 10360000000, 0.25 +Res-1.1375, 10360000000, 0.25 +Res-1.1376, 10360000000, 0.25 +Res-1.1377, 10360000000, 0.25 +Res-1.1378, 10360000000, 0.25 +Res-1.1379, 10504000000, 0.25 +Res-1.1380, 10504000000, 0.25 +Res-1.1381, 10504000000, 0.25 +Res-1.1382, 10504000000, 0.25 +Res-1.1383, 10504000000, 0.25 +Res-1.1384, 10504000000, 0.25 +Res-1.1385, 10648000000, 0.25 +Res-1.1386, 10648000000, 0.25 +Res-1.1387, 10648000000, 0.25 +Res-1.1388, 10648000000, 0.25 +Res-1.1389, 10648000000, 0.25 +Res-1.1390, 10648000000, 0.25 +Res-1.1391, 10072000000, 0.25 +Res-1.1392, 10216000000, 0.25 +Res-1.1393, 10360000000, 0.25 +Res-1.1394, 10504000000, 0.25 +Res-1.1395, 10648000000, 0.25 +Res-1.1396, 10072000000, 0.25 +Res-1.1397, 10216000000, 0.25 +Res-1.1398, 10360000000, 0.25 +Res-1.1399, 10504000000, 0.25 +Res-1.1400, 10648000000, 0.25 +Res-1.1401, 10072000000, 0.25 +Res-1.1402, 10216000000, 0.25 +Res-1.1403, 10360000000, 0.25 +Res-1.1404, 10504000000, 0.25 +Res-1.1405, 10648000000, 0.25 +Res-1.1406, 10072000000, 0.25 +Res-1.1407, 10216000000, 0.25 +Res-1.1408, 10360000000, 0.25 +Res-1.1409, 10504000000, 0.25 +Res-1.1410, 10648000000, 0.25 +Res-1.1411, 10072000000, 0.25 +Res-1.1412, 10216000000, 0.25 +Res-1.1413, 10360000000, 0.25 +Res-1.1414, 10504000000, 0.25 +Res-1.1415, 10648000000, 0.25 +Res-1.1416, 10072000000, 0.25 +Res-1.1417, 10216000000, 0.25 +Res-1.1418, 10360000000, 0.25 +Res-1.1419, 10504000000, 0.25 +Res-1.1420, 10648000000, 0.25 +Res-1.1421, 10072000000, 0.25 +Res-1.1422, 10216000000, 0.25 +Res-1.1423, 10360000000, 0.25 +Res-1.1424, 10504000000, 0.25 +Res-1.1425, 10648000000, 0.25 +Res-1.1426, 10072000000, 0.25 +Res-1.1427, 10216000000, 0.25 +Res-1.1428, 10360000000, 0.25 +Res-1.1429, 10504000000, 0.25 +Res-1.1430, 10648000000, 0.25 +Res-1.1431, 10072000000, 0.25 +Res-1.1432, 10216000000, 0.25 +Res-1.1433, 10360000000, 0.25 +Res-1.1434, 10504000000, 0.25 +Res-1.1435, 10648000000, 0.25 +Res-1.1436, 10072000000, 0.25 +Res-1.1437, 10216000000, 0.25 +Res-1.1438, 10360000000, 0.25 +Res-1.1439, 10504000000, 0.25 +Res-1.1440, 10648000000, 0.25 +Res-1.1441, 10478007200, 0.25 +Res-1.1442, 10478007200, 0.25 +Res-1.1443, 10478007200, 0.25 +Res-1.1444, 10478007200, 0.25 +Res-1.1445, 10478007200, 0.25 +Res-1.1446, 10478007200, 0.25 +Res-1.1447, 10478007200, 0.25 +Res-1.1448, 10478007200, 0.25 +Res-1.1449, 10478007200, 0.25 +Res-1.1450, 10478007200, 0.25 +Res-1.1451, 10478007200, 0.25 +Res-1.1452, 10478007200, 0.25 +Res-1.1453, 10478007200, 0.25 +Res-1.1454, 10478007200, 0.25 +Res-1.1455, 10478007200, 0.25 +Res-1.1456, 10478007200, 0.25 +Res-1.1457, 10478007200, 0.25 +Res-1.1458, 10478007200, 0.25 +Res-1.1459, 10478007200, 0.25 +Res-1.1460, 10478007200, 0.25 +Res-1.1461, 10478007200, 0.25 +Res-1.1462, 10478007200, 0.25 +Res-1.1463, 10478007200, 0.25 +Res-1.1464, 10478007200, 0.25 +Res-1.1465, 10478007200, 0.25 +Res-1.1466, 10478007200, 0.25 +Res-1.1467, 10478007200, 0.25 +Res-1.1468, 10478007200, 0.25 +Res-1.1469, 10478007200, 0.25 +Res-1.1470, 10478007200, 0.25 +Res-1.1471, 10478007200, 0.25 +Res-1.1472, 10478007200, 0.25 +Res-1.1473, 10478007200, 0.25 +Res-1.1474, 10478007200, 0.25 +Res-1.1475, 10478007200, 0.25 +Res-1.1476, 10478007200, 0.25 +Res-1.1477, 10478007200, 0.25 +Res-1.1478, 10478007200, 0.25 +Res-1.1479, 10478007200, 0.25 +Res-1.1480, 10478007200, 0.25 +Res-1.1481, 10478007200, 0.25 +Res-1.1482, 10478007200, 0.25 +Res-1.1483, 10478007200, 0.25 +Res-1.1484, 10478007200, 0.25 +Res-1.1485, 10478007200, 0.25 +Res-1.1486, 10478007200, 0.25 +Res-1.1487, 10478007200, 0.25 +Res-1.1488, 10478007200, 0.25 +Res-1.1489, 10478007200, 0.25 +Res-1.1490, 10478007200, 0.25 +Res-1.1491, 10478007200, 0.25 +Res-1.1492, 10478007200, 0.25 +Res-1.1493, 10478007200, 0.25 +Res-1.1494, 10478007200, 0.25 +Res-1.1495, 10478007200, 0.25 +Res-1.1496, 10478007200, 0.25 +Res-1.1497, 10478007200, 0.25 +Res-1.1498, 10478007200, 0.25 +Res-1.1499, 10478007200, 0.25 +Res-1.1500, 10478007200, 0.25 +Res-1.1501, 10478007200, 0.25 +Res-1.1502, 10478007200, 0.25 +Res-1.1503, 10478007200, 0.25 +Res-1.1504, 10478007200, 0.25 +Res-1.1505, 10478007200, 0.25 +Res-1.1506, 10478007200, 0.25 +Res-1.1507, 10478007200, 0.25 +Res-1.1508, 10478007200, 0.25 +Res-1.1509, 10478007200, 0.25 +Res-1.1510, 10478007200, 0.25 +Res-1.1511, 10478007200, 0.25 +Res-1.1512, 10478007200, 0.25 +Res-1.1513, 10478007200, 0.25 +Res-1.1514, 10478007200, 0.25 +Res-1.1515, 10478007200, 0.25 +Res-1.1516, 10478007200, 0.25 +Res-1.1517, 10478007200, 0.25 +Res-1.1518, 10478007200, 0.25 +Res-1.1519, 10478007200, 0.25 +Res-1.1520, 10478007200, 0.25 +Res-1.1521, 10478007200, 0.25 +Res-1.1522, 10478007200, 0.25 +Res-1.1523, 10478007200, 0.25 +Res-1.1524, 10478007200, 0.25 +Res-1.1525, 10478007200, 0.25 +Res-1.1526, 10478007200, 0.25 +Res-1.1527, 10478007200, 0.25 +Res-1.1528, 10478007200, 0.25 +Res-1.1529, 10478007200, 0.25 +Res-1.1530, 10478007200, 0.25 +Res-1.1531, 10478007200, 0.25 +Res-1.1532, 10478007200, 0.25 +Res-1.1533, 10478007200, 0.25 +Res-1.1534, 10478007200, 0.25 +Res-1.1535, 10478007200, 0.25 +Res-1.1536, 10478007200, 0.25 +Res-1.1537, 10478007200, 0.25 +Res-1.1538, 10478007200, 0.25 +Res-1.1539, 10478007200, 0.25 +Res-1.1540, 10478007200, 0.25 +Res-1.1541, 10478007200, 0.25 +Res-1.1542, 10478007200, 0.25 +Res-1.1543, 10478007200, 0.25 +Res-1.1544, 10478007200, 0.25 +Res-1.1545, 10478007200, 0.25 +Res-1.1546, 10478007200, 0.25 +Res-1.1547, 10478007200, 0.25 +Res-1.1548, 10478007200, 0.25 +Res-1.1549, 10478007200, 0.25 +Res-1.1550, 10478007200, 0.25 +Res-1.1551, 10478007200, 0.25 +Res-1.1552, 10478007200, 0.25 +Res-1.1553, 10478007200, 0.25 +Res-1.1554, 10478007200, 0.25 +Res-1.1555, 10478007200, 0.25 +Res-1.1556, 10478007200, 0.25 +Res-1.1557, 10478007200, 0.25 +Res-1.1558, 10478007200, 0.25 +Res-1.1559, 10478007200, 0.25 +Res-1.1560, 10478007200, 0.25 +Res-1.1561, 10478007200, 0.25 +Res-1.1562, 10478007200, 0.25 +Res-1.1563, 10478007200, 0.25 +Res-1.1564, 10478007200, 0.25 +Res-1.1565, 10478007200, 0.25 +Res-1.1566, 10478007200, 0.25 +Res-1.1567, 10478007200, 0.25 +Res-1.1568, 10478007200, 0.25 +Res-1.1569, 10478007200, 0.25 +Res-1.1570, 10478007200, 0.25 +Res-1.1571, 10478007200, 0.25 +Res-1.1572, 10478007200, 0.25 +Res-1.1573, 10478007200, 0.25 +Res-1.1574, 10478007200, 0.25 +Res-1.1575, 10478007200, 0.25 +Res-1.1576, 10478007200, 0.25 +Res-1.1577, 10478007200, 0.25 +Res-1.1578, 10478007200, 0.25 +Res-1.1579, 10478007200, 0.25 +Res-1.1580, 10478007200, 0.25 +Res-1.1581, 10478007200, 0.25 +Res-1.1582, 10478007200, 0.25 +Res-1.1583, 10478007200, 0.25 +Res-1.1584, 10478007200, 0.25 +Res-1.1585, 10478007200, 0.25 +Res-1.1586, 10478007200, 0.25 +Res-1.1587, 10478007200, 0.25 +Res-1.1588, 10478007200, 0.25 +Res-1.1589, 10478007200, 0.25 +Res-1.1590, 10478007200, 0.25 +Res-1.1591, 10478007200, 0.25 +Res-1.1592, 10478007200, 0.25 +Res-1.1593, 10478007200, 0.25 +Res-1.1594, 10478007200, 0.25 +Res-1.1595, 10478007200, 0.25 +Res-1.1596, 10478007200, 0.25 +Res-1.1597, 10478007200, 0.25 +Res-1.1598, 10478007200, 0.25 +Res-1.1599, 10478007200, 0.25 +Res-1.1600, 10478007200, 0.25 +Res-1.1601, 10478007200, 0.25 +Res-1.1602, 10478007200, 0.25 +Res-1.1603, 10478007200, 0.25 +Res-1.1604, 10478007200, 0.25 +Res-1.1605, 10478007200, 0.25 +Res-1.1606, 10478007200, 0.25 +Res-1.1607, 10478007200, 0.25 +Res-1.1608, 10478007200, 0.25 +Res-1.1609, 10478007200, 0.25 +Res-1.1610, 10478007200, 0.25 +Res-1.1611, 10478007200, 0.25 +Res-1.1612, 10478007200, 0.25 +Res-1.1613, 10478007200, 0.25 +Res-1.1614, 10478007200, 0.25 +Res-1.1615, 10478007200, 0.25 +Res-1.1616, 10478007200, 0.25 +Res-1.1617, 10478007200, 0.25 +Res-1.1618, 10478007200, 0.25 +Res-1.1619, 10478007200, 0.25 +Res-1.1620, 10478007200, 0.25 +Res-1.1621, 10478007200, 0.25 +Res-1.1622, 10478007200, 0.25 +Res-1.1623, 10478007200, 0.25 +Res-1.1624, 10478007200, 0.25 +Res-1.1625, 10478007200, 0.25 +Res-1.1626, 10478007200, 0.25 +Res-1.1627, 10478007200, 0.25 +Res-1.1628, 10478007200, 0.25 +Res-1.1629, 10478007200, 0.25 +Res-1.1630, 10478007200, 0.25 +Res-1.1631, 10478007200, 0.25 +Res-1.1632, 10478007200, 0.25 +Res-1.1633, 10478007200, 0.25 +Res-1.1634, 10478007200, 0.25 +Res-1.1635, 10478007200, 0.25 +Res-1.1636, 10478007200, 0.25 +Res-1.1637, 10478007200, 0.25 +Res-1.1638, 10478007200, 0.25 +Res-1.1639, 10478007200, 0.25 +Res-1.1640, 10478007200, 0.25 +Res-1.1641, 10478007200, 0.25 +Res-1.1642, 10478007200, 0.25 +Res-1.1643, 10478007200, 0.25 +Res-1.1644, 10478007200, 0.25 +Res-1.1645, 10478007200, 0.25 +Res-1.1646, 10478007200, 0.25 +Res-1.1647, 10478007200, 0.25 +Res-1.1648, 10478007200, 0.25 +Res-1.1649, 10478007200, 0.25 +Res-1.1650, 10478007200, 0.25 +Res-1.1651, 10478007200, 0.25 +Res-1.1652, 10478007200, 0.25 +Res-1.1653, 10478007200, 0.25 +Res-1.1654, 10478007200, 0.25 +Res-1.1655, 10478007200, 0.25 +Res-1.1656, 10478007200, 0.25 +Res-1.1657, 10478007200, 0.25 +Res-1.1658, 10478007200, 0.25 +Res-1.1659, 10478007200, 0.25 +Res-1.1660, 10478007200, 0.25 +Res-1.1661, 10478007200, 0.25 +Res-1.1662, 10478007200, 0.25 +Res-1.1663, 10478007200, 0.25 +Res-1.1664, 10478007200, 0.25 +Res-1.1665, 10478007200, 0.25 +Res-1.1666, 10478007200, 0.25 +Res-1.1667, 10478007200, 0.25 +Res-1.1668, 10478007200, 0.25 +Res-1.1669, 10478007200, 0.25 +Res-1.1670, 10478007200, 0.25 +Res-1.1671, 10478007200, 0.25 +Res-1.1672, 10478007200, 0.25 +Res-1.1673, 10478007200, 0.25 +Res-1.1674, 10478007200, 0.25 +Res-1.1675, 10478007200, 0.25 +Res-1.1676, 10478007200, 0.25 +Res-1.1677, 10478007200, 0.25 +Res-1.1678, 10478007200, 0.25 +Res-1.1679, 10478007200, 0.25 +Res-1.1680, 10478007200, 0.25 +Res-1.1681, 10478007200, 0.25 +Res-1.1682, 10478007200, 0.25 +Res-1.1683, 10478007200, 0.25 +Res-1.1684, 10478007200, 0.25 +Res-1.1685, 10478007200, 0.25 +Res-1.1686, 10478007200, 0.25 +Res-1.1687, 10478007200, 0.25 +Res-1.1688, 10478007200, 0.25 +Res-1.1689, 10478007200, 0.25 +Res-1.1690, 10478007200, 0.25 +Res-1.1691, 10478007200, 0.25 +Res-1.1692, 10478007200, 0.25 +Res-1.1693, 10478007200, 0.25 +Res-1.1694, 10478007200, 0.25 +Res-1.1695, 10478007200, 0.25 +Res-1.1696, 10478007200, 0.25 +Res-1.1697, 10478007200, 0.25 +Res-1.1698, 10478007200, 0.25 +Res-1.1699, 10478007200, 0.25 +Res-1.1700, 10478007200, 0.25 +Res-1.1701, 10478007200, 0.25 +Res-1.1702, 10478007200, 0.25 +Res-1.1703, 10478007200, 0.25 +Res-1.1704, 10478007200, 0.25 +Res-1.1705, 10478007200, 0.25 +Res-1.1706, 10478007200, 0.25 +Res-1.1707, 10478007200, 0.25 +Res-1.1708, 10478007200, 0.25 +Res-1.1709, 10478007200, 0.25 +Res-1.1710, 10478007200, 0.25 +Res-1.1711, 10478007200, 0.25 +Res-1.1712, 10478007200, 0.25 +Res-1.1713, 10478007200, 0.25 +Res-1.1714, 10478007200, 0.25 +Res-1.1715, 10478007200, 0.25 +Res-1.1716, 10478007200, 0.25 +Res-1.1717, 10478007200, 0.25 +Res-1.1718, 10478007200, 0.25 +Res-1.1719, 10478007200, 0.25 +Res-1.1720, 10478007200, 0.25 +Res-1.1721, 10478007200, 0.25 +Res-1.1722, 10478007200, 0.25 +Res-1.1723, 10478007200, 0.25 +Res-1.1724, 10478007200, 0.25 +Res-1.1725, 10478007200, 0.25 +Res-1.1726, 10478007200, 0.25 +Res-1.1727, 10478007200, 0.25 +Res-1.1728, 10478007200, 0.25 +Res-1.1729, 11670801700, 0.25 +Res-1.1730, 11670801700, 0.25 +Res-1.1731, 11670801700, 0.25 +Res-1.1732, 11670801700, 0.25 +Res-1.1733, 11670801700, 0.25 +Res-1.1734, 11670801700, 0.25 +Res-1.1735, 11670801700, 0.25 +Res-1.1736, 11670801700, 0.25 +Res-1.1737, 11670801700, 0.25 +Res-1.1738, 11670801700, 0.25 +Res-1.1739, 11670801700, 0.25 +Res-1.1740, 11670801700, 0.25 +Res-1.1741, 11670801700, 0.25 +Res-1.1742, 11670801700, 0.25 +Res-1.1743, 11670801700, 0.25 +Res-1.1744, 11670801700, 0.25 +Res-1.1745, 11670801700, 0.25 +Res-1.1746, 11670801700, 0.25 +Res-1.1747, 11670801700, 0.25 +Res-1.1748, 11670801700, 0.25 +Res-1.1749, 11670801700, 0.25 +Res-1.1750, 11670801700, 0.25 +Res-1.1751, 11670801700, 0.25 +Res-1.1752, 11670801700, 0.25 +Res-1.1753, 11670801700, 0.25 +Res-1.1754, 11670801700, 0.25 +Res-1.1755, 11670801700, 0.25 +Res-1.1756, 11670801700, 0.25 +Res-1.1757, 11670801700, 0.25 +Res-1.1758, 11670801700, 0.25 +Res-1.1759, 11670801700, 0.25 +Res-1.1760, 11670801700, 0.25 +Res-1.1761, 11670801700, 0.25 +Res-1.1762, 11670801700, 0.25 +Res-1.1763, 11670801700, 0.25 +Res-1.1764, 11670801700, 0.25 +Res-1.1765, 11670801700, 0.25 +Res-1.1766, 11670801700, 0.25 +Res-1.1767, 11670801700, 0.25 +Res-1.1768, 11670801700, 0.25 +Res-1.1769, 11670801700, 0.25 +Res-1.1770, 11670801700, 0.25 +Res-1.1771, 11670801700, 0.25 +Res-1.1772, 11670801700, 0.25 +Res-1.1773, 11670801700, 0.25 +Res-1.1774, 11670801700, 0.25 +Res-1.1775, 11670801700, 0.25 +Res-1.1776, 11670801700, 0.25 +Res-1.1777, 11670801700, 0.25 +Res-1.1778, 11670801700, 0.25 +Res-1.1779, 11670801700, 0.25 +Res-1.1780, 11670801700, 0.25 +Res-1.1781, 11670801700, 0.25 +Res-1.1782, 11670801700, 0.25 +Res-1.1783, 11670801700, 0.25 +Res-1.1784, 11670801700, 0.25 +Res-1.1785, 11670801700, 0.25 +Res-1.1786, 11670801700, 0.25 +Res-1.1787, 11670801700, 0.25 +Res-1.1788, 11670801700, 0.25 +Res-1.1789, 11670801700, 0.25 +Res-1.1790, 11670801700, 0.25 +Res-1.1791, 11670801700, 0.25 +Res-1.1792, 11670801700, 0.25 +Res-1.1793, 11670801700, 0.25 +Res-1.1794, 11670801700, 0.25 +Res-1.1795, 11670801700, 0.25 +Res-1.1796, 11670801700, 0.25 +Res-1.1797, 11670801700, 0.25 +Res-1.1798, 11670801700, 0.25 +Res-1.1799, 11670801700, 0.25 +Res-1.1800, 11670801700, 0.25 +Res-1.1801, 11670801700, 0.25 +Res-1.1802, 11670801700, 0.25 +Res-1.1803, 11670801700, 0.25 +Res-1.1804, 11670801700, 0.25 +Res-1.1805, 11670801700, 0.25 +Res-1.1806, 11670801700, 0.25 +Res-1.1807, 11670801700, 0.25 +Res-1.1808, 11670801700, 0.25 +Res-1.1809, 11670801700, 0.25 +Res-1.1810, 11670801700, 0.25 +Res-1.1811, 11670801700, 0.25 +Res-1.1812, 11670801700, 0.25 +Res-1.1813, 11670801700, 0.25 +Res-1.1814, 11670801700, 0.25 +Res-1.1815, 11670801700, 0.25 +Res-1.1816, 11670801700, 0.25 +Res-1.1817, 11670801700, 0.25 +Res-1.1818, 11670801700, 0.25 +Res-1.1819, 11670801700, 0.25 +Res-1.1820, 11670801700, 0.25 +Res-1.1821, 11670801700, 0.25 +Res-1.1822, 11670801700, 0.25 +Res-1.1823, 11670801700, 0.25 +Res-1.1824, 11670801700, 0.25 +Res-1.1825, 11670801700, 0.25 +Res-1.1826, 11670801700, 0.25 +Res-1.1827, 11670801700, 0.25 +Res-1.1828, 11670801700, 0.25 +Res-1.1829, 11670801700, 0.25 +Res-1.1830, 11670801700, 0.25 +Res-1.1831, 11670801700, 0.25 +Res-1.1832, 11670801700, 0.25 +Res-1.1833, 11670801700, 0.25 +Res-1.1834, 11670801700, 0.25 +Res-1.1835, 11670801700, 0.25 +Res-1.1836, 11670801700, 0.25 +Res-1.1837, 11670801700, 0.25 +Res-1.1838, 11670801700, 0.25 +Res-1.1839, 11670801700, 0.25 +Res-1.1840, 11670801700, 0.25 +Res-1.1841, 11670801700, 0.25 +Res-1.1842, 11670801700, 0.25 +Res-1.1843, 11670801700, 0.25 +Res-1.1844, 11670801700, 0.25 +Res-1.1845, 11670801700, 0.25 +Res-1.1846, 11670801700, 0.25 +Res-1.1847, 11670801700, 0.25 +Res-1.1848, 11670801700, 0.25 +Res-1.1849, 11670801700, 0.25 +Res-1.1850, 11670801700, 0.25 +Res-1.1851, 11670801700, 0.25 +Res-1.1852, 11670801700, 0.25 +Res-1.1853, 11670801700, 0.25 +Res-1.1854, 11670801700, 0.25 +Res-1.1855, 11670801700, 0.25 +Res-1.1856, 11670801700, 0.25 +Res-1.1857, 11670801700, 0.25 +Res-1.1858, 11670801700, 0.25 +Res-1.1859, 11670801700, 0.25 +Res-1.1860, 11670801700, 0.25 +Res-1.1861, 11670801700, 0.25 +Res-1.1862, 11670801700, 0.25 +Res-1.1863, 11670801700, 0.25 +Res-1.1864, 11670801700, 0.25 +Res-1.1865, 11670801700, 0.25 +Res-1.1866, 11670801700, 0.25 +Res-1.1867, 11670801700, 0.25 +Res-1.1868, 11670801700, 0.25 +Res-1.1869, 11670801700, 0.25 +Res-1.1870, 11670801700, 0.25 +Res-1.1871, 11670801700, 0.25 +Res-1.1872, 11670801700, 0.25 +Res-1.1873, 11670801700, 0.25 +Res-1.1874, 11670801700, 0.25 +Res-1.1875, 11670801700, 0.25 +Res-1.1876, 11670801700, 0.25 +Res-1.1877, 11670801700, 0.25 +Res-1.1878, 11670801700, 0.25 +Res-1.1879, 11670801700, 0.25 +Res-1.1880, 11670801700, 0.25 +Res-1.1881, 11670801700, 0.25 +Res-1.1882, 11670801700, 0.25 +Res-1.1883, 11670801700, 0.25 +Res-1.1884, 11670801700, 0.25 +Res-1.1885, 11670801700, 0.25 +Res-1.1886, 11670801700, 0.25 +Res-1.1887, 11670801700, 0.25 +Res-1.1888, 11670801700, 0.25 +Res-1.1889, 11670801700, 0.25 +Res-1.1890, 11670801700, 0.25 +Res-1.1891, 11670801700, 0.25 +Res-1.1892, 11670801700, 0.25 +Res-1.1893, 11670801700, 0.25 +Res-1.1894, 11670801700, 0.25 +Res-1.1895, 11670801700, 0.25 +Res-1.1896, 11670801700, 0.25 +Res-1.1897, 11670801700, 0.25 +Res-1.1898, 11670801700, 0.25 +Res-1.1899, 11670801700, 0.25 +Res-1.1900, 11670801700, 0.25 +Res-1.1901, 11670801700, 0.25 +Res-1.1902, 11670801700, 0.25 +Res-1.1903, 11670801700, 0.25 +Res-1.1904, 11670801700, 0.25 +Res-1.1905, 11670801700, 0.25 +Res-1.1906, 11670801700, 0.25 +Res-1.1907, 11670801700, 0.25 +Res-1.1908, 11670801700, 0.25 +Res-1.1909, 11670801700, 0.25 +Res-1.1910, 11670801700, 0.25 +Res-1.1911, 11670801700, 0.25 +Res-1.1912, 11670801700, 0.25 +Res-1.1913, 11670801700, 0.25 +Res-1.1914, 11670801700, 0.25 +Res-1.1915, 11670801700, 0.25 +Res-1.1916, 11670801700, 0.25 +Res-1.1917, 11670801700, 0.25 +Res-1.1918, 11670801700, 0.25 +Res-1.1919, 11670801700, 0.25 +Res-1.1920, 11670801700, 0.25 +Res-1.1921, 11670801700, 0.25 +Res-1.1922, 11670801700, 0.25 +Res-1.1923, 11670801700, 0.25 +Res-1.1924, 11670801700, 0.25 +Res-1.1925, 11670801700, 0.25 +Res-1.1926, 11670801700, 0.25 +Res-1.1927, 11670801700, 0.25 +Res-1.1928, 11670801700, 0.25 +Res-1.1929, 11670801700, 0.25 +Res-1.1930, 11670801700, 0.25 +Res-1.1931, 11670801700, 0.25 +Res-1.1932, 11670801700, 0.25 +Res-1.1933, 11670801700, 0.25 +Res-1.1934, 11670801700, 0.25 +Res-1.1935, 11670801700, 0.25 +Res-1.1936, 11670801700, 0.25 +Res-1.1937, 11670801700, 0.25 +Res-1.1938, 11670801700, 0.25 +Res-1.1939, 11670801700, 0.25 +Res-1.1940, 11670801700, 0.25 +Res-1.1941, 11670801700, 0.25 +Res-1.1942, 11670801700, 0.25 +Res-1.1943, 11670801700, 0.25 +Res-1.1944, 11670801700, 0.25 +Res-1.1945, 11670801700, 0.25 +Res-1.1946, 11670801700, 0.25 +Res-1.1947, 11670801700, 0.25 +Res-1.1948, 11670801700, 0.25 +Res-1.1949, 11670801700, 0.25 +Res-1.1950, 11670801700, 0.25 +Res-1.1951, 11670801700, 0.25 +Res-1.1952, 11670801700, 0.25 +Res-1.1953, 11670801700, 0.25 +Res-1.1954, 11670801700, 0.25 +Res-1.1955, 11670801700, 0.25 +Res-1.1956, 11670801700, 0.25 +Res-1.1957, 11670801700, 0.25 +Res-1.1958, 11670801700, 0.25 +Res-1.1959, 11670801700, 0.25 +Res-1.1960, 11670801700, 0.25 +Res-1.1961, 11670801700, 0.25 +Res-1.1962, 11670801700, 0.25 +Res-1.1963, 11670801700, 0.25 +Res-1.1964, 11670801700, 0.25 +Res-1.1965, 11670801700, 0.25 +Res-1.1966, 11670801700, 0.25 +Res-1.1967, 11670801700, 0.25 +Res-1.1968, 11670801700, 0.25 +Res-1.1969, 11670801700, 0.25 +Res-1.1970, 11670801700, 0.25 +Res-1.1971, 11670801700, 0.25 +Res-1.1972, 11670801700, 0.25 +Res-1.1973, 11670801700, 0.25 +Res-1.1974, 11670801700, 0.25 +Res-1.1975, 11670801700, 0.25 +Res-1.1976, 11670801700, 0.25 +Res-1.1977, 11670801700, 0.25 +Res-1.1978, 11670801700, 0.25 +Res-1.1979, 11670801700, 0.25 +Res-1.1980, 11670801700, 0.25 +Res-1.1981, 11670801700, 0.25 +Res-1.1982, 11670801700, 0.25 +Res-1.1983, 11670801700, 0.25 +Res-1.1984, 11670801700, 0.25 +Res-1.1985, 11670801700, 0.25 +Res-1.1986, 11670801700, 0.25 +Res-1.1987, 11670801700, 0.25 +Res-1.1988, 11670801700, 0.25 +Res-1.1989, 11670801700, 0.25 +Res-1.1990, 11670801700, 0.25 +Res-1.1991, 11670801700, 0.25 +Res-1.1992, 11670801700, 0.25 +Res-1.1993, 11670801700, 0.25 +Res-1.1994, 11670801700, 0.25 +Res-1.1995, 11670801700, 0.25 +Res-1.1996, 11670801700, 0.25 +Res-1.1997, 11670801700, 0.25 +Res-1.1998, 11670801700, 0.25 +Res-1.1999, 11670801700, 0.25 +Res-1.2000, 11670801700, 0.25 +Res-1.2001, 11670801700, 0.25 +Res-1.2002, 11670801700, 0.25 +Res-1.2003, 11670801700, 0.25 +Res-1.2004, 11670801700, 0.25 +Res-1.2005, 11670801700, 0.25 +Res-1.2006, 11670801700, 0.25 +Res-1.2007, 11670801700, 0.25 +Res-1.2008, 11670801700, 0.25 +Res-1.2009, 11670801700, 0.25 +Res-1.2010, 11670801700, 0.25 +Res-1.2011, 11670801700, 0.25 +Res-1.2012, 11670801700, 0.25 +Res-1.2013, 11670801700, 0.25 +Res-1.2014, 11670801700, 0.25 +Res-1.2015, 11670801700, 0.25 +Res-1.2016, 11670801700, 0.25 +Res-1.2017, 6227222750, 0.25 +Res-1.2018, 6227222750, 0.25 +Res-1.2019, 6227222750, 0.25 +Res-1.2020, 6227222750, 0.25 +Res-1.2021, 6227222750, 0.25 +Res-1.2022, 6227222750, 0.25 +Res-1.2023, 6227222750, 0.25 +Res-1.2024, 6227222750, 0.25 +Res-1.2025, 6227222750, 0.25 +Res-1.2026, 6227222750, 0.25 +Res-1.2027, 6227222750, 0.25 +Res-1.2028, 6227222750, 0.25 +Res-1.2029, 6227222750, 0.25 +Res-1.2030, 6227222750, 0.25 +Res-1.2031, 6227222750, 0.25 +Res-1.2032, 6227222750, 0.25 +Res-1.2033, 6227222750, 0.25 +Res-1.2034, 6227222750, 0.25 +Res-1.2035, 6227222750, 0.25 +Res-1.2036, 6227222750, 0.25 +Res-1.2037, 6227222750, 0.25 +Res-1.2038, 6227222750, 0.25 +Res-1.2039, 6227222750, 0.25 +Res-1.2040, 6227222750, 0.25 +Res-1.2041, 6227222750, 0.25 +Res-1.2042, 6227222750, 0.25 +Res-1.2043, 6227222750, 0.25 +Res-1.2044, 6227222750, 0.25 +Res-1.2045, 6227222750, 0.25 +Res-1.2046, 6227222750, 0.25 +Res-1.2047, 6227222750, 0.25 +Res-1.2048, 6227222750, 0.25 +Res-1.2049, 6227222750, 0.25 +Res-1.2050, 6227222750, 0.25 +Res-1.2051, 6227222750, 0.25 +Res-1.2052, 6227222750, 0.25 +Res-1.2053, 6227222750, 0.25 +Res-1.2054, 6227222750, 0.25 +Res-1.2055, 6227222750, 0.25 +Res-1.2056, 6227222750, 0.25 +Res-1.2057, 6227222750, 0.25 +Res-1.2058, 6227222750, 0.25 +Res-1.2059, 6227222750, 0.25 +Res-1.2060, 6227222750, 0.25 +Res-1.2061, 6227222750, 0.25 +Res-1.2062, 6227222750, 0.25 +Res-1.2063, 6227222750, 0.25 +Res-1.2064, 6227222750, 0.25 +Res-1.2065, 6227222750, 0.25 +Res-1.2066, 6227222750, 0.25 +Res-1.2067, 6227222750, 0.25 +Res-1.2068, 6227222750, 0.25 +Res-1.2069, 6227222750, 0.25 +Res-1.2070, 6227222750, 0.25 +Res-1.2071, 6227222750, 0.25 +Res-1.2072, 6227222750, 0.25 +Res-1.2073, 6227222750, 0.25 +Res-1.2074, 6227222750, 0.25 +Res-1.2075, 6227222750, 0.25 +Res-1.2076, 6227222750, 0.25 +Res-1.2077, 6227222750, 0.25 +Res-1.2078, 6227222750, 0.25 +Res-1.2079, 6227222750, 0.25 +Res-1.2080, 6227222750, 0.25 +Res-1.2081, 6227222750, 0.25 +Res-1.2082, 6227222750, 0.25 +Res-1.2083, 6227222750, 0.25 +Res-1.2084, 6227222750, 0.25 +Res-1.2085, 6227222750, 0.25 +Res-1.2086, 6227222750, 0.25 +Res-1.2087, 6227222750, 0.25 +Res-1.2088, 6227222750, 0.25 +Res-1.2089, 6227222750, 0.25 +Res-1.2090, 6227222750, 0.25 +Res-1.2091, 6227222750, 0.25 +Res-1.2092, 6227222750, 0.25 +Res-1.2093, 6227222750, 0.25 +Res-1.2094, 6227222750, 0.25 +Res-1.2095, 6227222750, 0.25 +Res-1.2096, 6227222750, 0.25 +Res-1.2097, 6227222750, 0.25 +Res-1.2098, 6227222750, 0.25 +Res-1.2099, 6227222750, 0.25 +Res-1.2100, 6227222750, 0.25 +Res-1.2101, 6227222750, 0.25 +Res-1.2102, 6227222750, 0.25 +Res-1.2103, 6227222750, 0.25 +Res-1.2104, 6227222750, 0.25 +Res-1.2105, 6227222750, 0.25 +Res-1.2106, 6227222750, 0.25 +Res-1.2107, 6227222750, 0.25 +Res-1.2108, 6227222750, 0.25 +Res-1.2109, 6227222750, 0.25 +Res-1.2110, 6227222750, 0.25 +Res-1.2111, 6227222750, 0.25 +Res-1.2112, 6227222750, 0.25 +Res-1.2113, 6227222750, 0.25 +Res-1.2114, 6227222750, 0.25 +Res-1.2115, 6227222750, 0.25 +Res-1.2116, 6227222750, 0.25 +Res-1.2117, 6227222750, 0.25 +Res-1.2118, 6227222750, 0.25 +Res-1.2119, 6227222750, 0.25 +Res-1.2120, 6227222750, 0.25 +Res-1.2121, 6227222750, 0.25 +Res-1.2122, 6227222750, 0.25 +Res-1.2123, 6227222750, 0.25 +Res-1.2124, 6227222750, 0.25 +Res-1.2125, 6227222750, 0.25 +Res-1.2126, 6227222750, 0.25 +Res-1.2127, 6227222750, 0.25 +Res-1.2128, 6227222750, 0.25 +Res-1.2129, 6227222750, 0.25 +Res-1.2130, 6227222750, 0.25 +Res-1.2131, 6227222750, 0.25 +Res-1.2132, 6227222750, 0.25 +Res-1.2133, 6227222750, 0.25 +Res-1.2134, 6227222750, 0.25 +Res-1.2135, 6227222750, 0.25 +Res-1.2136, 6227222750, 0.25 +Res-1.2137, 6227222750, 0.25 +Res-1.2138, 6227222750, 0.25 +Res-1.2139, 6227222750, 0.25 +Res-1.2140, 6227222750, 0.25 +Res-1.2141, 6227222750, 0.25 +Res-1.2142, 6227222750, 0.25 +Res-1.2143, 6227222750, 0.25 +Res-1.2144, 6227222750, 0.25 +Res-1.2145, 6227222750, 0.25 +Res-1.2146, 6227222750, 0.25 +Res-1.2147, 6227222750, 0.25 +Res-1.2148, 6227222750, 0.25 +Res-1.2149, 6227222750, 0.25 +Res-1.2150, 6227222750, 0.25 +Res-1.2151, 6227222750, 0.25 +Res-1.2152, 6227222750, 0.25 +Res-1.2153, 6227222750, 0.25 +Res-1.2154, 6227222750, 0.25 +Res-1.2155, 6227222750, 0.25 +Res-1.2156, 6227222750, 0.25 +Res-1.2157, 6227222750, 0.25 +Res-1.2158, 6227222750, 0.25 +Res-1.2159, 6227222750, 0.25 +Res-1.2160, 6227222750, 0.25 +Res-1.2161, 6227222750, 0.25 +Res-1.2162, 6227222750, 0.25 +Res-1.2163, 6227222750, 0.25 +Res-1.2164, 6227222750, 0.25 +Res-1.2165, 6227222750, 0.25 +Res-1.2166, 6227222750, 0.25 +Res-1.2167, 6227222750, 0.25 +Res-1.2168, 6227222750, 0.25 +Res-1.2169, 6227222750, 0.25 +Res-1.2170, 6227222750, 0.25 +Res-1.2171, 6227222750, 0.25 +Res-1.2172, 6227222750, 0.25 +Res-1.2173, 6227222750, 0.25 +Res-1.2174, 6227222750, 0.25 +Res-1.2175, 6227222750, 0.25 +Res-1.2176, 6227222750, 0.25 +Res-1.2177, 6227222750, 0.25 +Res-1.2178, 6227222750, 0.25 +Res-1.2179, 6227222750, 0.25 +Res-1.2180, 6227222750, 0.25 +Res-1.2181, 6227222750, 0.25 +Res-1.2182, 6227222750, 0.25 +Res-1.2183, 6227222750, 0.25 +Res-1.2184, 6227222750, 0.25 +Res-1.2185, 6227222750, 0.25 +Res-1.2186, 6227222750, 0.25 +Res-1.2187, 6227222750, 0.25 +Res-1.2188, 6227222750, 0.25 +Res-1.2189, 6227222750, 0.25 +Res-1.2190, 6227222750, 0.25 +Res-1.2191, 6227222750, 0.25 +Res-1.2192, 6227222750, 0.25 +Res-1.2193, 6227222750, 0.25 +Res-1.2194, 6227222750, 0.25 +Res-1.2195, 6227222750, 0.25 +Res-1.2196, 6227222750, 0.25 +Res-1.2197, 6227222750, 0.25 +Res-1.2198, 6227222750, 0.25 +Res-1.2199, 6227222750, 0.25 +Res-1.2200, 6227222750, 0.25 +Res-1.2201, 6227222750, 0.25 +Res-1.2202, 6227222750, 0.25 +Res-1.2203, 6227222750, 0.25 +Res-1.2204, 6227222750, 0.25 +Res-1.2205, 6227222750, 0.25 +Res-1.2206, 6227222750, 0.25 +Res-1.2207, 6227222750, 0.25 +Res-1.2208, 6227222750, 0.25 +Res-1.2209, 6227222750, 0.25 +Res-1.2210, 6227222750, 0.25 +Res-1.2211, 6227222750, 0.25 +Res-1.2212, 6227222750, 0.25 +Res-1.2213, 6227222750, 0.25 +Res-1.2214, 6227222750, 0.25 +Res-1.2215, 6227222750, 0.25 +Res-1.2216, 6227222750, 0.25 +Res-1.2217, 6227222750, 0.25 +Res-1.2218, 6227222750, 0.25 +Res-1.2219, 6227222750, 0.25 +Res-1.2220, 6227222750, 0.25 +Res-1.2221, 6227222750, 0.25 +Res-1.2222, 6227222750, 0.25 +Res-1.2223, 6227222750, 0.25 +Res-1.2224, 6227222750, 0.25 +Res-1.2225, 6227222750, 0.25 +Res-1.2226, 6227222750, 0.25 +Res-1.2227, 6227222750, 0.25 +Res-1.2228, 6227222750, 0.25 +Res-1.2229, 6227222750, 0.25 +Res-1.2230, 6227222750, 0.25 +Res-1.2231, 6227222750, 0.25 +Res-1.2232, 6227222750, 0.25 +Res-1.2233, 6227222750, 0.25 +Res-1.2234, 6227222750, 0.25 +Res-1.2235, 6227222750, 0.25 +Res-1.2236, 6227222750, 0.25 +Res-1.2237, 6227222750, 0.25 +Res-1.2238, 6227222750, 0.25 +Res-1.2239, 6227222750, 0.25 +Res-1.2240, 6227222750, 0.25 +Res-1.2241, 6227222750, 0.25 +Res-1.2242, 6227222750, 0.25 +Res-1.2243, 6227222750, 0.25 +Res-1.2244, 6227222750, 0.25 +Res-1.2245, 6227222750, 0.25 +Res-1.2246, 6227222750, 0.25 +Res-1.2247, 6227222750, 0.25 +Res-1.2248, 6227222750, 0.25 +Res-1.2249, 6227222750, 0.25 +Res-1.2250, 6227222750, 0.25 +Res-1.2251, 6227222750, 0.25 +Res-1.2252, 6227222750, 0.25 +Res-1.2253, 6227222750, 0.25 +Res-1.2254, 6227222750, 0.25 +Res-1.2255, 6227222750, 0.25 +Res-1.2256, 6227222750, 0.25 +Res-1.2257, 6227222750, 0.25 +Res-1.2258, 6227222750, 0.25 +Res-1.2259, 6227222750, 0.25 +Res-1.2260, 6227222750, 0.25 +Res-1.2261, 6227222750, 0.25 +Res-1.2262, 6227222750, 0.25 +Res-1.2263, 6227222750, 0.25 +Res-1.2264, 6227222750, 0.25 +Res-1.2265, 6227222750, 0.25 +Res-1.2266, 6227222750, 0.25 +Res-1.2267, 6227222750, 0.25 +Res-1.2268, 6227222750, 0.25 +Res-1.2269, 6227222750, 0.25 +Res-1.2270, 6227222750, 0.25 +Res-1.2271, 6227222750, 0.25 +Res-1.2272, 6227222750, 0.25 +Res-1.2273, 6227222750, 0.25 +Res-1.2274, 6227222750, 0.25 +Res-1.2275, 6227222750, 0.25 +Res-1.2276, 6227222750, 0.25 +Res-1.2277, 6227222750, 0.25 +Res-1.2278, 6227222750, 0.25 +Res-1.2279, 6227222750, 0.25 +Res-1.2280, 6227222750, 0.25 +Res-1.2281, 6227222750, 0.25 +Res-1.2282, 6227222750, 0.25 +Res-1.2283, 6227222750, 0.25 +Res-1.2284, 6227222750, 0.25 +Res-1.2285, 6227222750, 0.25 +Res-1.2286, 6227222750, 0.25 +Res-1.2287, 6227222750, 0.25 +Res-1.2288, 6227222750, 0.25 +Res-1.2289, 6227222750, 0.25 +Res-1.2290, 6227222750, 0.25 +Res-1.2291, 6227222750, 0.25 +Res-1.2292, 6227222750, 0.25 +Res-1.2293, 6227222750, 0.25 +Res-1.2294, 6227222750, 0.25 +Res-1.2295, 6227222750, 0.25 +Res-1.2296, 6227222750, 0.25 +Res-1.2297, 6227222750, 0.25 +Res-1.2298, 6227222750, 0.25 +Res-1.2299, 6227222750, 0.25 +Res-1.2300, 6227222750, 0.25 +Res-1.2301, 6227222750, 0.25 +Res-1.2302, 6227222750, 0.25 +Res-1.2303, 6227222750, 0.25 +Res-1.2304, 6227222750, 0.25 +Res-1.2305, 6439192352.5, 0.25 +Res-1.2306, 6439192352.5, 0.25 +Res-1.2307, 6439192352.5, 0.25 +Res-1.2308, 6439192352.5, 0.25 +Res-1.2309, 6439192352.5, 0.25 +Res-1.2310, 6439192352.5, 0.25 +Res-1.2311, 6439192352.5, 0.25 +Res-1.2312, 6439192352.5, 0.25 +Res-1.2313, 6439192352.5, 0.25 +Res-1.2314, 6439192352.5, 0.25 +Res-1.2315, 6439192352.5, 0.25 +Res-1.2316, 6439192352.5, 0.25 +Res-1.2317, 6439192352.5, 0.25 +Res-1.2318, 6439192352.5, 0.25 +Res-1.2319, 6439192352.5, 0.25 +Res-1.2320, 6439192352.5, 0.25 +Res-1.2321, 6439192352.5, 0.25 +Res-1.2322, 6439192352.5, 0.25 +Res-1.2323, 6439192352.5, 0.25 +Res-1.2324, 6439192352.5, 0.25 +Res-1.2325, 6439192352.5, 0.25 +Res-1.2326, 6439192352.5, 0.25 +Res-1.2327, 6439192352.5, 0.25 +Res-1.2328, 6439192352.5, 0.25 +Res-1.2329, 6439192352.5, 0.25 +Res-1.2330, 6439192352.5, 0.25 +Res-1.2331, 6439192352.5, 0.25 +Res-1.2332, 6439192352.5, 0.25 +Res-1.2333, 6439192352.5, 0.25 +Res-1.2334, 6439192352.5, 0.25 +Res-1.2335, 6439192352.5, 0.25 +Res-1.2336, 6439192352.5, 0.25 +Res-1.2337, 6439192352.5, 0.25 +Res-1.2338, 6439192352.5, 0.25 +Res-1.2339, 6439192352.5, 0.25 +Res-1.2340, 6439192352.5, 0.25 +Res-1.2341, 6439192352.5, 0.25 +Res-1.2342, 6439192352.5, 0.25 +Res-1.2343, 6439192352.5, 0.25 +Res-1.2344, 6439192352.5, 0.25 +Res-1.2345, 6439192352.5, 0.25 +Res-1.2346, 6439192352.5, 0.25 +Res-1.2347, 6439192352.5, 0.25 +Res-1.2348, 6439192352.5, 0.25 +Res-1.2349, 6439192352.5, 0.25 +Res-1.2350, 6439192352.5, 0.25 +Res-1.2351, 6439192352.5, 0.25 +Res-1.2352, 6439192352.5, 0.25 +Res-1.2353, 6439192352.5, 0.25 +Res-1.2354, 6439192352.5, 0.25 +Res-1.2355, 6439192352.5, 0.25 +Res-1.2356, 6439192352.5, 0.25 +Res-1.2357, 6439192352.5, 0.25 +Res-1.2358, 6439192352.5, 0.25 +Res-1.2359, 6439192352.5, 0.25 +Res-1.2360, 6439192352.5, 0.25 +Res-1.2361, 6439192352.5, 0.25 +Res-1.2362, 6439192352.5, 0.25 +Res-1.2363, 6439192352.5, 0.25 +Res-1.2364, 6439192352.5, 0.25 +Res-1.2365, 6439192352.5, 0.25 +Res-1.2366, 6439192352.5, 0.25 +Res-1.2367, 6439192352.5, 0.25 +Res-1.2368, 6439192352.5, 0.25 +Res-1.2369, 6439192352.5, 0.25 +Res-1.2370, 6439192352.5, 0.25 +Res-1.2371, 6439192352.5, 0.25 +Res-1.2372, 6439192352.5, 0.25 +Res-1.2373, 6439192352.5, 0.25 +Res-1.2374, 6439192352.5, 0.25 +Res-1.2375, 6439192352.5, 0.25 +Res-1.2376, 6439192352.5, 0.25 +Res-1.2377, 6439192352.5, 0.25 +Res-1.2378, 6439192352.5, 0.25 +Res-1.2379, 6439192352.5, 0.25 +Res-1.2380, 6439192352.5, 0.25 +Res-1.2381, 6439192352.5, 0.25 +Res-1.2382, 6439192352.5, 0.25 +Res-1.2383, 6439192352.5, 0.25 +Res-1.2384, 6439192352.5, 0.25 +Res-1.2385, 6439192352.5, 0.25 +Res-1.2386, 6439192352.5, 0.25 +Res-1.2387, 6439192352.5, 0.25 +Res-1.2388, 6439192352.5, 0.25 +Res-1.2389, 6439192352.5, 0.25 +Res-1.2390, 6439192352.5, 0.25 +Res-1.2391, 6439192352.5, 0.25 +Res-1.2392, 6439192352.5, 0.25 +Res-1.2393, 6439192352.5, 0.25 +Res-1.2394, 6439192352.5, 0.25 +Res-1.2395, 6439192352.5, 0.25 +Res-1.2396, 6439192352.5, 0.25 +Res-1.2397, 6439192352.5, 0.25 +Res-1.2398, 6439192352.5, 0.25 +Res-1.2399, 6439192352.5, 0.25 +Res-1.2400, 6439192352.5, 0.25 +Res-1.2401, 6439192352.5, 0.25 +Res-1.2402, 6439192352.5, 0.25 +Res-1.2403, 6439192352.5, 0.25 +Res-1.2404, 6439192352.5, 0.25 +Res-1.2405, 6439192352.5, 0.25 +Res-1.2406, 6439192352.5, 0.25 +Res-1.2407, 6439192352.5, 0.25 +Res-1.2408, 6439192352.5, 0.25 +Res-1.2409, 6439192352.5, 0.25 +Res-1.2410, 6439192352.5, 0.25 +Res-1.2411, 6439192352.5, 0.25 +Res-1.2412, 6439192352.5, 0.25 +Res-1.2413, 6439192352.5, 0.25 +Res-1.2414, 6439192352.5, 0.25 +Res-1.2415, 6439192352.5, 0.25 +Res-1.2416, 6439192352.5, 0.25 +Res-1.2417, 6439192352.5, 0.25 +Res-1.2418, 6439192352.5, 0.25 +Res-1.2419, 6439192352.5, 0.25 +Res-1.2420, 6439192352.5, 0.25 +Res-1.2421, 6439192352.5, 0.25 +Res-1.2422, 6439192352.5, 0.25 +Res-1.2423, 6439192352.5, 0.25 +Res-1.2424, 6439192352.5, 0.25 +Res-1.2425, 6439192352.5, 0.25 +Res-1.2426, 6439192352.5, 0.25 +Res-1.2427, 6439192352.5, 0.25 +Res-1.2428, 6439192352.5, 0.25 +Res-1.2429, 6439192352.5, 0.25 +Res-1.2430, 6439192352.5, 0.25 +Res-1.2431, 6439192352.5, 0.25 +Res-1.2432, 6439192352.5, 0.25 +Res-1.2433, 6439192352.5, 0.25 +Res-1.2434, 6439192352.5, 0.25 +Res-1.2435, 6439192352.5, 0.25 +Res-1.2436, 6439192352.5, 0.25 +Res-1.2437, 6439192352.5, 0.25 +Res-1.2438, 6439192352.5, 0.25 +Res-1.2439, 6439192352.5, 0.25 +Res-1.2440, 6439192352.5, 0.25 +Res-1.2441, 6439192352.5, 0.25 +Res-1.2442, 6439192352.5, 0.25 +Res-1.2443, 6439192352.5, 0.25 +Res-1.2444, 6439192352.5, 0.25 +Res-1.2445, 6439192352.5, 0.25 +Res-1.2446, 6439192352.5, 0.25 +Res-1.2447, 6439192352.5, 0.25 +Res-1.2448, 6439192352.5, 0.25 +Res-1.2449, 6439192352.5, 0.25 +Res-1.2450, 6439192352.5, 0.25 +Res-1.2451, 6439192352.5, 0.25 +Res-1.2452, 6439192352.5, 0.25 +Res-1.2453, 6439192352.5, 0.25 +Res-1.2454, 6439192352.5, 0.25 +Res-1.2455, 6439192352.5, 0.25 +Res-1.2456, 6439192352.5, 0.25 +Res-1.2457, 6439192352.5, 0.25 +Res-1.2458, 6439192352.5, 0.25 +Res-1.2459, 6439192352.5, 0.25 +Res-1.2460, 6439192352.5, 0.25 +Res-1.2461, 6439192352.5, 0.25 +Res-1.2462, 6439192352.5, 0.25 +Res-1.2463, 6439192352.5, 0.25 +Res-1.2464, 6439192352.5, 0.25 +Res-1.2465, 6439192352.5, 0.25 +Res-1.2466, 6439192352.5, 0.25 +Res-1.2467, 6439192352.5, 0.25 +Res-1.2468, 6439192352.5, 0.25 +Res-1.2469, 6439192352.5, 0.25 +Res-1.2470, 6439192352.5, 0.25 +Res-1.2471, 6439192352.5, 0.25 +Res-1.2472, 6439192352.5, 0.25 +Res-1.2473, 6439192352.5, 0.25 +Res-1.2474, 6439192352.5, 0.25 +Res-1.2475, 6439192352.5, 0.25 +Res-1.2476, 6439192352.5, 0.25 +Res-1.2477, 6439192352.5, 0.25 +Res-1.2478, 6439192352.5, 0.25 +Res-1.2479, 6439192352.5, 0.25 +Res-1.2480, 6439192352.5, 0.25 +Res-1.2481, 6439192352.5, 0.25 +Res-1.2482, 6439192352.5, 0.25 +Res-1.2483, 6439192352.5, 0.25 +Res-1.2484, 6439192352.5, 0.25 +Res-1.2485, 6439192352.5, 0.25 +Res-1.2486, 6439192352.5, 0.25 +Res-1.2487, 6439192352.5, 0.25 +Res-1.2488, 6439192352.5, 0.25 +Res-1.2489, 6439192352.5, 0.25 +Res-1.2490, 6439192352.5, 0.25 +Res-1.2491, 6439192352.5, 0.25 +Res-1.2492, 6439192352.5, 0.25 +Res-1.2493, 6439192352.5, 0.25 +Res-1.2494, 6439192352.5, 0.25 +Res-1.2495, 6439192352.5, 0.25 +Res-1.2496, 6439192352.5, 0.25 +Res-1.2497, 6439192352.5, 0.25 +Res-1.2498, 6439192352.5, 0.25 +Res-1.2499, 6439192352.5, 0.25 +Res-1.2500, 6439192352.5, 0.25 +Res-1.2501, 6439192352.5, 0.25 +Res-1.2502, 6439192352.5, 0.25 +Res-1.2503, 6439192352.5, 0.25 +Res-1.2504, 6439192352.5, 0.25 +Res-1.2505, 6439192352.5, 0.25 +Res-1.2506, 6439192352.5, 0.25 +Res-1.2507, 6439192352.5, 0.25 +Res-1.2508, 6439192352.5, 0.25 +Res-1.2509, 6439192352.5, 0.25 +Res-1.2510, 6439192352.5, 0.25 +Res-1.2511, 6439192352.5, 0.25 +Res-1.2512, 6439192352.5, 0.25 +Res-1.2513, 6439192352.5, 0.25 +Res-1.2514, 6439192352.5, 0.25 +Res-1.2515, 6439192352.5, 0.25 +Res-1.2516, 6439192352.5, 0.25 +Res-1.2517, 6439192352.5, 0.25 +Res-1.2518, 6439192352.5, 0.25 +Res-1.2519, 6439192352.5, 0.25 +Res-1.2520, 6439192352.5, 0.25 +Res-1.2521, 6439192352.5, 0.25 +Res-1.2522, 6439192352.5, 0.25 +Res-1.2523, 6439192352.5, 0.25 +Res-1.2524, 6439192352.5, 0.25 +Res-1.2525, 6439192352.5, 0.25 +Res-1.2526, 6439192352.5, 0.25 +Res-1.2527, 6439192352.5, 0.25 +Res-1.2528, 6439192352.5, 0.25 +Res-1.2529, 6439192352.5, 0.25 +Res-1.2530, 6439192352.5, 0.25 +Res-1.2531, 6439192352.5, 0.25 +Res-1.2532, 6439192352.5, 0.25 +Res-1.2533, 6439192352.5, 0.25 +Res-1.2534, 6439192352.5, 0.25 +Res-1.2535, 6439192352.5, 0.25 +Res-1.2536, 6439192352.5, 0.25 +Res-1.2537, 6439192352.5, 0.25 +Res-1.2538, 6439192352.5, 0.25 +Res-1.2539, 6439192352.5, 0.25 +Res-1.2540, 6439192352.5, 0.25 +Res-1.2541, 6439192352.5, 0.25 +Res-1.2542, 6439192352.5, 0.25 +Res-1.2543, 6439192352.5, 0.25 +Res-1.2544, 6439192352.5, 0.25 +Res-1.2545, 6439192352.5, 0.25 +Res-1.2546, 6439192352.5, 0.25 +Res-1.2547, 6439192352.5, 0.25 +Res-1.2548, 6439192352.5, 0.25 +Res-1.2549, 6439192352.5, 0.25 +Res-1.2550, 6439192352.5, 0.25 +Res-1.2551, 6439192352.5, 0.25 +Res-1.2552, 6439192352.5, 0.25 +Res-1.2553, 6439192352.5, 0.25 +Res-1.2554, 6439192352.5, 0.25 +Res-1.2555, 6439192352.5, 0.25 +Res-1.2556, 6439192352.5, 0.25 +Res-1.2557, 6439192352.5, 0.25 +Res-1.2558, 6439192352.5, 0.25 +Res-1.2559, 6439192352.5, 0.25 +Res-1.2560, 6439192352.5, 0.25 +Res-1.2561, 6439192352.5, 0.25 +Res-1.2562, 6439192352.5, 0.25 +Res-1.2563, 6439192352.5, 0.25 +Res-1.2564, 6439192352.5, 0.25 +Res-1.2565, 6439192352.5, 0.25 +Res-1.2566, 6439192352.5, 0.25 +Res-1.2567, 6439192352.5, 0.25 +Res-1.2568, 6439192352.5, 0.25 +Res-1.2569, 6439192352.5, 0.25 +Res-1.2570, 6439192352.5, 0.25 +Res-1.2571, 6439192352.5, 0.25 +Res-1.2572, 6439192352.5, 0.25 +Res-1.2573, 6439192352.5, 0.25 +Res-1.2574, 6439192352.5, 0.25 +Res-1.2575, 6439192352.5, 0.25 +Res-1.2576, 6439192352.5, 0.25 +Res-1.2577, 6439192352.5, 0.25 +Res-1.2578, 6439192352.5, 0.25 +Res-1.2579, 6439192352.5, 0.25 +Res-1.2580, 6439192352.5, 0.25 +Res-1.2581, 6439192352.5, 0.25 +Res-1.2582, 6439192352.5, 0.25 +Res-1.2583, 6439192352.5, 0.25 +Res-1.2584, 6439192352.5, 0.25 +Res-1.2585, 6439192352.5, 0.25 +Res-1.2586, 6439192352.5, 0.25 +Res-1.2587, 6439192352.5, 0.25 +Res-1.2588, 6439192352.5, 0.25 +Res-1.2589, 6439192352.5, 0.25 +Res-1.2590, 6439192352.5, 0.25 +Res-1.2591, 6439192352.5, 0.25 +Res-1.2592, 6439192352.5, 0.25 +Res-1.2593, 5316491363.7363, 0.25 +Res-1.2594, 5316491363.7363, 0.25 +Res-1.2595, 5316491363.7363, 0.25 +Res-1.2596, 5316491363.7363, 0.25 +Res-1.2597, 5316491363.7363, 0.25 +Res-1.2598, 5316491363.7363, 0.25 +Res-1.2599, 5316491363.7363, 0.25 +Res-1.2600, 5316491363.7363, 0.25 +Res-1.2601, 5316491363.7363, 0.25 +Res-1.2602, 5316491363.7363, 0.25 +Res-1.2603, 5316491363.7363, 0.25 +Res-1.2604, 5316491363.7363, 0.25 +Res-1.2605, 5316491363.7363, 0.25 +Res-1.2606, 5316491363.7363, 0.25 +Res-1.2607, 5316491363.7363, 0.25 +Res-1.2608, 5316491363.7363, 0.25 +Res-1.2609, 5316491363.7363, 0.25 +Res-1.2610, 5316491363.7363, 0.25 +Res-1.2611, 5316491363.7363, 0.25 +Res-1.2612, 5316491363.7363, 0.25 +Res-1.2613, 5316491363.7363, 0.25 +Res-1.2614, 5316491363.7363, 0.25 +Res-1.2615, 5316491363.7363, 0.25 +Res-1.2616, 5316491363.7363, 0.25 +Res-1.2617, 5316491363.7363, 0.25 +Res-1.2618, 5316491363.7363, 0.25 +Res-1.2619, 5316491363.7363, 0.25 +Res-1.2620, 5316491363.7363, 0.25 +Res-1.2621, 5316491363.7363, 0.25 +Res-1.2622, 5316491363.7363, 0.25 +Res-1.2623, 5316491363.7363, 0.25 +Res-1.2624, 5316491363.7363, 0.25 +Res-1.2625, 5316491363.7363, 0.25 +Res-1.2626, 5316491363.7363, 0.25 +Res-1.2627, 5316491363.7363, 0.25 +Res-1.2628, 5316491363.7363, 0.25 +Res-1.2629, 5316491363.7363, 0.25 +Res-1.2630, 5316491363.7363, 0.25 +Res-1.2631, 5316491363.7363, 0.25 +Res-1.2632, 5316491363.7363, 0.25 +Res-1.2633, 5316491363.7363, 0.25 +Res-1.2634, 5316491363.7363, 0.25 +Res-1.2635, 5316491363.7363, 0.25 +Res-1.2636, 5316491363.7363, 0.25 +Res-1.2637, 5316491363.7363, 0.25 +Res-1.2638, 5316491363.7363, 0.25 +Res-1.2639, 5316491363.7363, 0.25 +Res-1.2640, 5316491363.7363, 0.25 +Res-1.2641, 5316491363.7363, 0.25 +Res-1.2642, 5316491363.7363, 0.25 +Res-1.2643, 5316491363.7363, 0.25 +Res-1.2644, 5316491363.7363, 0.25 +Res-1.2645, 5316491363.7363, 0.25 +Res-1.2646, 5316491363.7363, 0.25 +Res-1.2647, 5316491363.7363, 0.25 +Res-1.2648, 5316491363.7363, 0.25 +Res-1.2649, 5316491363.7363, 0.25 +Res-1.2650, 5316491363.7363, 0.25 +Res-1.2651, 5316491363.7363, 0.25 +Res-1.2652, 5316491363.7363, 0.25 +Res-1.2653, 5316491363.7363, 0.25 +Res-1.2654, 5316491363.7363, 0.25 +Res-1.2655, 5316491363.7363, 0.25 +Res-1.2656, 5316491363.7363, 0.25 +Res-1.2657, 5316491363.7363, 0.25 +Res-1.2658, 5316491363.7363, 0.25 +Res-1.2659, 5316491363.7363, 0.25 +Res-1.2660, 5316491363.7363, 0.25 +Res-1.2661, 5316491363.7363, 0.25 +Res-1.2662, 5316491363.7363, 0.25 +Res-1.2663, 5316491363.7363, 0.25 +Res-1.2664, 5316491363.7363, 0.25 +Res-1.2665, 5316491363.7363, 0.25 +Res-1.2666, 5316491363.7363, 0.25 +Res-1.2667, 5316491363.7363, 0.25 +Res-1.2668, 5316491363.7363, 0.25 +Res-1.2669, 5316491363.7363, 0.25 +Res-1.2670, 5316491363.7363, 0.25 +Res-1.2671, 5316491363.7363, 0.25 +Res-1.2672, 5316491363.7363, 0.25 +Res-1.2673, 5316491363.7363, 0.25 +Res-1.2674, 5316491363.7363, 0.25 +Res-1.2675, 5316491363.7363, 0.25 +Res-1.2676, 5316491363.7363, 0.25 +Res-1.2677, 5316491363.7363, 0.25 +Res-1.2678, 5316491363.7363, 0.25 +Res-1.2679, 5316491363.7363, 0.25 +Res-1.2680, 5316491363.7363, 0.25 +Res-1.2681, 5316491363.7363, 0.25 +Res-1.2682, 5316491363.7363, 0.25 +Res-1.2683, 5316491363.7363, 0.25 +Res-1.2684, 5316491363.7363, 0.25 +Res-1.2685, 5316491363.7363, 0.25 +Res-1.2686, 5316491363.7363, 0.25 +Res-1.2687, 5316491363.7363, 0.25 +Res-1.2688, 5316491363.7363, 0.25 +Res-1.2689, 5316491363.7363, 0.25 +Res-1.2690, 5316491363.7363, 0.25 +Res-1.2691, 5316491363.7363, 0.25 +Res-1.2692, 5316491363.7363, 0.25 +Res-1.2693, 5316491363.7363, 0.25 +Res-1.2694, 5316491363.7363, 0.25 +Res-1.2695, 5316491363.7363, 0.25 +Res-1.2696, 5316491363.7363, 0.25 +Res-1.2697, 5316491363.7363, 0.25 +Res-1.2698, 5316491363.7363, 0.25 +Res-1.2699, 5316491363.7363, 0.25 +Res-1.2700, 5316491363.7363, 0.25 +Res-1.2701, 5316491363.7363, 0.25 +Res-1.2702, 5316491363.7363, 0.25 +Res-1.2703, 5316491363.7363, 0.25 +Res-1.2704, 5316491363.7363, 0.25 +Res-1.2705, 5316491363.7363, 0.25 +Res-1.2706, 5316491363.7363, 0.25 +Res-1.2707, 5316491363.7363, 0.25 +Res-1.2708, 5316491363.7363, 0.25 +Res-1.2709, 5316491363.7363, 0.25 +Res-1.2710, 5316491363.7363, 0.25 +Res-1.2711, 5316491363.7363, 0.25 +Res-1.2712, 5316491363.7363, 0.25 +Res-1.2713, 5316491363.7363, 0.25 +Res-1.2714, 5316491363.7363, 0.25 +Res-1.2715, 5316491363.7363, 0.25 +Res-1.2716, 5316491363.7363, 0.25 +Res-1.2717, 5316491363.7363, 0.25 +Res-1.2718, 5316491363.7363, 0.25 +Res-1.2719, 5316491363.7363, 0.25 +Res-1.2720, 5316491363.7363, 0.25 +Res-1.2721, 5316491363.7363, 0.25 +Res-1.2722, 5316491363.7363, 0.25 +Res-1.2723, 5316491363.7363, 0.25 +Res-1.2724, 5316491363.7363, 0.25 +Res-1.2725, 5316491363.7363, 0.25 +Res-1.2726, 5316491363.7363, 0.25 +Res-1.2727, 5316491363.7363, 0.25 +Res-1.2728, 5316491363.7363, 0.25 +Res-1.2729, 5316491363.7363, 0.25 +Res-1.2730, 5316491363.7363, 0.25 +Res-1.2731, 5316491363.7363, 0.25 +Res-1.2732, 5316491363.7363, 0.25 +Res-1.2733, 5316491363.7363, 0.25 +Res-1.2734, 5316491363.7363, 0.25 +Res-1.2735, 5316491363.7363, 0.25 +Res-1.2736, 5316491363.7363, 0.25 +Res-1.2737, 5316491363.7363, 0.25 +Res-1.2738, 5316491363.7363, 0.25 +Res-1.2739, 5316491363.7363, 0.25 +Res-1.2740, 5316491363.7363, 0.25 +Res-1.2741, 5316491363.7363, 0.25 +Res-1.2742, 5316491363.7363, 0.25 +Res-1.2743, 5316491363.7363, 0.25 +Res-1.2744, 5316491363.7363, 0.25 +Res-1.2745, 5316491363.7363, 0.25 +Res-1.2746, 5316491363.7363, 0.25 +Res-1.2747, 5316491363.7363, 0.25 +Res-1.2748, 5316491363.7363, 0.25 +Res-1.2749, 5316491363.7363, 0.25 +Res-1.2750, 5316491363.7363, 0.25 +Res-1.2751, 5316491363.7363, 0.25 +Res-1.2752, 5316491363.7363, 0.25 +Res-1.2753, 5316491363.7363, 0.25 +Res-1.2754, 5316491363.7363, 0.25 +Res-1.2755, 5316491363.7363, 0.25 +Res-1.2756, 5316491363.7363, 0.25 +Res-1.2757, 5316491363.7363, 0.25 +Res-1.2758, 5316491363.7363, 0.25 +Res-1.2759, 5316491363.7363, 0.25 +Res-1.2760, 5316491363.7363, 0.25 +Res-1.2761, 5316491363.7363, 0.25 +Res-1.2762, 5316491363.7363, 0.25 +Res-1.2763, 5316491363.7363, 0.25 +Res-1.2764, 5316491363.7363, 0.25 +Res-1.2765, 5316491363.7363, 0.25 +Res-1.2766, 5316491363.7363, 0.25 +Res-1.2767, 5316491363.7363, 0.25 +Res-1.2768, 5316491363.7363, 0.25 +Res-1.2769, 5316491363.7363, 0.25 +Res-1.2770, 5316491363.7363, 0.25 +Res-1.2771, 5316491363.7363, 0.25 +Res-1.2772, 5316491363.7363, 0.25 +Res-1.2773, 5316491363.7363, 0.25 +Res-1.2774, 5316491363.7363, 0.25 +Res-1.2775, 5316491363.7363, 0.25 +Res-1.2776, 5316491363.7363, 0.25 +Res-1.2777, 5316491363.7363, 0.25 +Res-1.2778, 5316491363.7363, 0.25 +Res-1.2779, 5316491363.7363, 0.25 +Res-1.2780, 5316491363.7363, 0.25 +Res-1.2781, 5316491363.7363, 0.25 +Res-1.2782, 5316491363.7363, 0.25 +Res-1.2783, 5316491363.7363, 0.25 +Res-1.2784, 5316491363.7363, 0.25 +Res-1.2785, 5316491363.7363, 0.25 +Res-1.2786, 5316491363.7363, 0.25 +Res-1.2787, 5316491363.7363, 0.25 +Res-1.2788, 5316491363.7363, 0.25 +Res-1.2789, 5316491363.7363, 0.25 +Res-1.2790, 5316491363.7363, 0.25 +Res-1.2791, 5316491363.7363, 0.25 +Res-1.2792, 5316491363.7363, 0.25 +Res-1.2793, 5316491363.7363, 0.25 +Res-1.2794, 5316491363.7363, 0.25 +Res-1.2795, 5316491363.7363, 0.25 +Res-1.2796, 5316491363.7363, 0.25 +Res-1.2797, 5316491363.7363, 0.25 +Res-1.2798, 5316491363.7363, 0.25 +Res-1.2799, 5316491363.7363, 0.25 +Res-1.2800, 5316491363.7363, 0.25 +Res-1.2801, 5316491363.7363, 0.25 +Res-1.2802, 5316491363.7363, 0.25 +Res-1.2803, 5316491363.7363, 0.25 +Res-1.2804, 5316491363.7363, 0.25 +Res-1.2805, 5316491363.7363, 0.25 +Res-1.2806, 5316491363.7363, 0.25 +Res-1.2807, 5316491363.7363, 0.25 +Res-1.2808, 5316491363.7363, 0.25 +Res-1.2809, 5316491363.7363, 0.25 +Res-1.2810, 5316491363.7363, 0.25 +Res-1.2811, 5316491363.7363, 0.25 +Res-1.2812, 5316491363.7363, 0.25 +Res-1.2813, 5316491363.7363, 0.25 +Res-1.2814, 5316491363.7363, 0.25 +Res-1.2815, 5316491363.7363, 0.25 +Res-1.2816, 5316491363.7363, 0.25 +Res-1.2817, 5316491363.7363, 0.25 +Res-1.2818, 5316491363.7363, 0.25 +Res-1.2819, 5316491363.7363, 0.25 +Res-1.2820, 5316491363.7363, 0.25 +Res-1.2821, 5316491363.7363, 0.25 +Res-1.2822, 5316491363.7363, 0.25 +Res-1.2823, 5316491363.7363, 0.25 +Res-1.2824, 5316491363.7363, 0.25 +Res-1.2825, 5316491363.7363, 0.25 +Res-1.2826, 5316491363.7363, 0.25 +Res-1.2827, 5316491363.7363, 0.25 +Res-1.2828, 5316491363.7363, 0.25 +Res-1.2829, 5316491363.7363, 0.25 +Res-1.2830, 5316491363.7363, 0.25 +Res-1.2831, 5316491363.7363, 0.25 +Res-1.2832, 5316491363.7363, 0.25 +Res-1.2833, 5316491363.7363, 0.25 +Res-1.2834, 5316491363.7363, 0.25 +Res-1.2835, 5316491363.7363, 0.25 +Res-1.2836, 5316491363.7363, 0.25 +Res-1.2837, 5316491363.7363, 0.25 +Res-1.2838, 5316491363.7363, 0.25 +Res-1.2839, 5316491363.7363, 0.25 +Res-1.2840, 5316491363.7363, 0.25 +Res-1.2841, 5316491363.7363, 0.25 +Res-1.2842, 5316491363.7363, 0.25 +Res-1.2843, 5316491363.7363, 0.25 +Res-1.2844, 5316491363.7363, 0.25 +Res-1.2845, 5316491363.7363, 0.25 +Res-1.2846, 5316491363.7363, 0.25 +Res-1.2847, 5316491363.7363, 0.25 +Res-1.2848, 5316491363.7363, 0.25 +Res-1.2849, 5316491363.7363, 0.25 +Res-1.2850, 5316491363.7363, 0.25 +Res-1.2851, 5316491363.7363, 0.25 +Res-1.2852, 5316491363.7363, 0.25 +Res-1.2853, 5316491363.7363, 0.25 +Res-1.2854, 5316491363.7363, 0.25 +Res-1.2855, 5316491363.7363, 0.25 +Res-1.2856, 5316491363.7363, 0.25 +Res-1.2857, 5316491363.7363, 0.25 +Res-1.2858, 5316491363.7363, 0.25 +Res-1.2859, 5316491363.7363, 0.25 +Res-1.2860, 5316491363.7363, 0.25 +Res-1.2861, 5316491363.7363, 0.25 +Res-1.2862, 5316491363.7363, 0.25 +Res-1.2863, 5316491363.7363, 0.25 +Res-1.2864, 5316491363.7363, 0.25 +Res-1.2865, 5316491363.7363, 0.25 +Res-1.2866, 5316491363.7363, 0.25 +Res-1.2867, 5316491363.7363, 0.25 +Res-1.2868, 5316491363.7363, 0.25 +Res-1.2869, 5316491363.7363, 0.25 +Res-1.2870, 5316491363.7363, 0.25 +Res-1.2871, 5316491363.7363, 0.25 +Res-1.2872, 5316491363.7363, 0.25 +Res-1.2873, 5316491363.7363, 0.25 +Res-1.2874, 5316491363.7363, 0.25 +Res-1.2875, 5316491363.7363, 0.25 +Res-1.2876, 5316491363.7363, 0.25 +Res-1.2877, 5316491363.7363, 0.25 +Res-1.2878, 5316491363.7363, 0.25 +Res-1.2879, 5316491363.7363, 0.25 +Res-1.2880, 5316491363.7363, 0.25 +Res-1.2881, 11552880115, 0.25 +Res-1.2882, 11552880115, 0.25 +Res-1.2883, 11552880115, 0.25 +Res-1.2884, 11552880115, 0.25 +Res-1.2885, 11552880115, 0.25 +Res-1.2886, 11552880115, 0.25 +Res-1.2887, 11552880115, 0.25 +Res-1.2888, 11552880115, 0.25 +Res-1.2889, 11552880115, 0.25 +Res-1.2890, 11552880115, 0.25 +Res-1.2891, 11552880115, 0.25 +Res-1.2892, 11552880115, 0.25 +Res-1.2893, 11552880115, 0.25 +Res-1.2894, 11552880115, 0.25 +Res-1.2895, 11552880115, 0.25 +Res-1.2896, 11552880115, 0.25 +Res-1.2897, 11552880115, 0.25 +Res-1.2898, 11552880115, 0.25 +Res-1.2899, 11552880115, 0.25 +Res-1.2900, 11552880115, 0.25 +Res-1.2901, 11552880115, 0.25 +Res-1.2902, 11552880115, 0.25 +Res-1.2903, 11552880115, 0.25 +Res-1.2904, 11552880115, 0.25 +Res-1.2905, 11552880115, 0.25 +Res-1.2906, 11552880115, 0.25 +Res-1.2907, 11552880115, 0.25 +Res-1.2908, 11552880115, 0.25 +Res-1.2909, 11552880115, 0.25 +Res-1.2910, 11552880115, 0.25 +Res-1.2911, 11552880115, 0.25 +Res-1.2912, 11552880115, 0.25 +Res-1.2913, 11552880115, 0.25 +Res-1.2914, 11552880115, 0.25 +Res-1.2915, 11552880115, 0.25 +Res-1.2916, 11552880115, 0.25 +Res-1.2917, 11552880115, 0.25 +Res-1.2918, 11552880115, 0.25 +Res-1.2919, 11552880115, 0.25 +Res-1.2920, 11552880115, 0.25 +Res-1.2921, 11552880115, 0.25 +Res-1.2922, 11552880115, 0.25 +Res-1.2923, 11552880115, 0.25 +Res-1.2924, 11552880115, 0.25 +Res-1.2925, 11552880115, 0.25 +Res-1.2926, 11552880115, 0.25 +Res-1.2927, 11552880115, 0.25 +Res-1.2928, 11552880115, 0.25 +Res-1.2929, 11552880115, 0.25 +Res-1.2930, 11552880115, 0.25 +Res-1.2931, 11552880115, 0.25 +Res-1.2932, 11552880115, 0.25 +Res-1.2933, 11552880115, 0.25 +Res-1.2934, 11552880115, 0.25 +Res-1.2935, 11552880115, 0.25 +Res-1.2936, 11552880115, 0.25 +Res-1.2937, 11552880115, 0.25 +Res-1.2938, 11552880115, 0.25 +Res-1.2939, 11552880115, 0.25 +Res-1.2940, 11552880115, 0.25 +Res-1.2941, 11552880115, 0.25 +Res-1.2942, 11552880115, 0.25 +Res-1.2943, 11552880115, 0.25 +Res-1.2944, 11552880115, 0.25 +Res-1.2945, 11552880115, 0.25 +Res-1.2946, 11552880115, 0.25 +Res-1.2947, 11552880115, 0.25 +Res-1.2948, 11552880115, 0.25 +Res-1.2949, 11552880115, 0.25 +Res-1.2950, 11552880115, 0.25 +Res-1.2951, 11552880115, 0.25 +Res-1.2952, 11552880115, 0.25 +Res-1.2953, 11552880115, 0.25 +Res-1.2954, 11552880115, 0.25 +Res-1.2955, 11552880115, 0.25 +Res-1.2956, 11552880115, 0.25 +Res-1.2957, 11552880115, 0.25 +Res-1.2958, 11552880115, 0.25 +Res-1.2959, 11552880115, 0.25 +Res-1.2960, 11552880115, 0.25 +Res-1.2961, 11552880115, 0.25 +Res-1.2962, 11552880115, 0.25 +Res-1.2963, 11552880115, 0.25 +Res-1.2964, 11552880115, 0.25 +Res-1.2965, 11552880115, 0.25 +Res-1.2966, 11552880115, 0.25 +Res-1.2967, 11552880115, 0.25 +Res-1.2968, 11552880115, 0.25 +Res-1.2969, 11552880115, 0.25 +Res-1.2970, 11552880115, 0.25 +Res-1.2971, 11552880115, 0.25 +Res-1.2972, 11552880115, 0.25 +Res-1.2973, 11552880115, 0.25 +Res-1.2974, 11552880115, 0.25 +Res-1.2975, 11552880115, 0.25 +Res-1.2976, 11552880115, 0.25 +Res-1.2977, 11552880115, 0.25 +Res-1.2978, 11552880115, 0.25 +Res-1.2979, 11552880115, 0.25 +Res-1.2980, 11552880115, 0.25 +Res-1.2981, 11552880115, 0.25 +Res-1.2982, 11552880115, 0.25 +Res-1.2983, 11552880115, 0.25 +Res-1.2984, 11552880115, 0.25 +Res-1.2985, 11552880115, 0.25 +Res-1.2986, 11552880115, 0.25 +Res-1.2987, 11552880115, 0.25 +Res-1.2988, 11552880115, 0.25 +Res-1.2989, 11552880115, 0.25 +Res-1.2990, 11552880115, 0.25 +Res-1.2991, 11552880115, 0.25 +Res-1.2992, 11552880115, 0.25 +Res-1.2993, 11552880115, 0.25 +Res-1.2994, 11552880115, 0.25 +Res-1.2995, 11552880115, 0.25 +Res-1.2996, 11552880115, 0.25 +Res-1.2997, 11552880115, 0.25 +Res-1.2998, 11552880115, 0.25 +Res-1.2999, 11552880115, 0.25 +Res-1.3000, 11552880115, 0.25 +Res-1.3001, 11552880115, 0.25 +Res-1.3002, 11552880115, 0.25 +Res-1.3003, 11552880115, 0.25 +Res-1.3004, 11552880115, 0.25 +Res-1.3005, 11552880115, 0.25 +Res-1.3006, 11552880115, 0.25 +Res-1.3007, 11552880115, 0.25 +Res-1.3008, 11552880115, 0.25 +Res-1.3009, 11552880115, 0.25 +Res-1.3010, 11552880115, 0.25 +Res-1.3011, 11552880115, 0.25 +Res-1.3012, 11552880115, 0.25 +Res-1.3013, 11552880115, 0.25 +Res-1.3014, 11552880115, 0.25 +Res-1.3015, 11552880115, 0.25 +Res-1.3016, 11552880115, 0.25 +Res-1.3017, 11552880115, 0.25 +Res-1.3018, 11552880115, 0.25 +Res-1.3019, 11552880115, 0.25 +Res-1.3020, 11552880115, 0.25 +Res-1.3021, 11552880115, 0.25 +Res-1.3022, 11552880115, 0.25 +Res-1.3023, 11552880115, 0.25 +Res-1.3024, 11552880115, 0.25 +Res-1.3025, 11552880115, 0.25 +Res-1.3026, 11552880115, 0.25 +Res-1.3027, 11552880115, 0.25 +Res-1.3028, 11552880115, 0.25 +Res-1.3029, 11552880115, 0.25 +Res-1.3030, 11552880115, 0.25 +Res-1.3031, 11552880115, 0.25 +Res-1.3032, 11552880115, 0.25 +Res-1.3033, 11552880115, 0.25 +Res-1.3034, 11552880115, 0.25 +Res-1.3035, 11552880115, 0.25 +Res-1.3036, 11552880115, 0.25 +Res-1.3037, 11552880115, 0.25 +Res-1.3038, 11552880115, 0.25 +Res-1.3039, 11552880115, 0.25 +Res-1.3040, 11552880115, 0.25 +Res-1.3041, 11552880115, 0.25 +Res-1.3042, 11552880115, 0.25 +Res-1.3043, 11552880115, 0.25 +Res-1.3044, 11552880115, 0.25 +Res-1.3045, 11552880115, 0.25 +Res-1.3046, 11552880115, 0.25 +Res-1.3047, 11552880115, 0.25 +Res-1.3048, 11552880115, 0.25 +Res-1.3049, 11552880115, 0.25 +Res-1.3050, 11552880115, 0.25 +Res-1.3051, 11552880115, 0.25 +Res-1.3052, 11552880115, 0.25 +Res-1.3053, 11552880115, 0.25 +Res-1.3054, 11552880115, 0.25 +Res-1.3055, 11552880115, 0.25 +Res-1.3056, 11552880115, 0.25 +Res-1.3057, 11552880115, 0.25 +Res-1.3058, 11552880115, 0.25 +Res-1.3059, 11552880115, 0.25 +Res-1.3060, 11552880115, 0.25 +Res-1.3061, 11552880115, 0.25 +Res-1.3062, 11552880115, 0.25 +Res-1.3063, 11552880115, 0.25 +Res-1.3064, 11552880115, 0.25 +Res-1.3065, 11552880115, 0.25 +Res-1.3066, 11552880115, 0.25 +Res-1.3067, 11552880115, 0.25 +Res-1.3068, 11552880115, 0.25 +Res-1.3069, 11552880115, 0.25 +Res-1.3070, 11552880115, 0.25 +Res-1.3071, 11552880115, 0.25 +Res-1.3072, 11552880115, 0.25 +Res-1.3073, 11552880115, 0.25 +Res-1.3074, 11552880115, 0.25 +Res-1.3075, 11552880115, 0.25 +Res-1.3076, 11552880115, 0.25 +Res-1.3077, 11552880115, 0.25 +Res-1.3078, 11552880115, 0.25 +Res-1.3079, 11552880115, 0.25 +Res-1.3080, 11552880115, 0.25 +Res-1.3081, 11552880115, 0.25 +Res-1.3082, 11552880115, 0.25 +Res-1.3083, 11552880115, 0.25 +Res-1.3084, 11552880115, 0.25 +Res-1.3085, 11552880115, 0.25 +Res-1.3086, 11552880115, 0.25 +Res-1.3087, 11552880115, 0.25 +Res-1.3088, 11552880115, 0.25 +Res-1.3089, 11552880115, 0.25 +Res-1.3090, 11552880115, 0.25 +Res-1.3091, 11552880115, 0.25 +Res-1.3092, 11552880115, 0.25 +Res-1.3093, 11552880115, 0.25 +Res-1.3094, 11552880115, 0.25 +Res-1.3095, 11552880115, 0.25 +Res-1.3096, 11552880115, 0.25 +Res-1.3097, 11552880115, 0.25 +Res-1.3098, 11552880115, 0.25 +Res-1.3099, 11552880115, 0.25 +Res-1.3100, 11552880115, 0.25 +Res-1.3101, 11552880115, 0.25 +Res-1.3102, 11552880115, 0.25 +Res-1.3103, 11552880115, 0.25 +Res-1.3104, 11552880115, 0.25 +Res-1.3105, 11552880115, 0.25 +Res-1.3106, 11552880115, 0.25 +Res-1.3107, 11552880115, 0.25 +Res-1.3108, 11552880115, 0.25 +Res-1.3109, 11552880115, 0.25 +Res-1.3110, 11552880115, 0.25 +Res-1.3111, 11552880115, 0.25 +Res-1.3112, 11552880115, 0.25 +Res-1.3113, 11552880115, 0.25 +Res-1.3114, 11552880115, 0.25 +Res-1.3115, 11552880115, 0.25 +Res-1.3116, 11552880115, 0.25 +Res-1.3117, 11552880115, 0.25 +Res-1.3118, 11552880115, 0.25 +Res-1.3119, 11552880115, 0.25 +Res-1.3120, 11552880115, 0.25 +Res-1.3121, 11552880115, 0.25 +Res-1.3122, 11552880115, 0.25 +Res-1.3123, 11552880115, 0.25 +Res-1.3124, 11552880115, 0.25 +Res-1.3125, 11552880115, 0.25 +Res-1.3126, 11552880115, 0.25 +Res-1.3127, 11552880115, 0.25 +Res-1.3128, 11552880115, 0.25 +Res-1.3129, 11552880115, 0.25 +Res-1.3130, 11552880115, 0.25 +Res-1.3131, 11552880115, 0.25 +Res-1.3132, 11552880115, 0.25 +Res-1.3133, 11552880115, 0.25 +Res-1.3134, 11552880115, 0.25 +Res-1.3135, 11552880115, 0.25 +Res-1.3136, 11552880115, 0.25 +Res-1.3137, 11552880115, 0.25 +Res-1.3138, 11552880115, 0.25 +Res-1.3139, 11552880115, 0.25 +Res-1.3140, 11552880115, 0.25 +Res-1.3141, 11552880115, 0.25 +Res-1.3142, 11552880115, 0.25 +Res-1.3143, 11552880115, 0.25 +Res-1.3144, 11552880115, 0.25 +Res-1.3145, 11552880115, 0.25 +Res-1.3146, 11552880115, 0.25 +Res-1.3147, 11552880115, 0.25 +Res-1.3148, 11552880115, 0.25 +Res-1.3149, 11552880115, 0.25 +Res-1.3150, 11552880115, 0.25 +Res-1.3151, 11552880115, 0.25 +Res-1.3152, 11552880115, 0.25 +Res-1.3153, 11552880115, 0.25 +Res-1.3154, 11552880115, 0.25 +Res-1.3155, 11552880115, 0.25 +Res-1.3156, 11552880115, 0.25 +Res-1.3157, 11552880115, 0.25 +Res-1.3158, 11552880115, 0.25 +Res-1.3159, 11552880115, 0.25 +Res-1.3160, 11552880115, 0.25 +Res-1.3161, 11552880115, 0.25 +Res-1.3162, 11552880115, 0.25 +Res-1.3163, 11552880115, 0.25 +Res-1.3164, 11552880115, 0.25 +Res-1.3165, 11552880115, 0.25 +Res-1.3166, 11552880115, 0.25 +Res-1.3167, 11552880115, 0.25 +Res-1.3168, 11552880115, 0.25 +Res-1.3169, 13631205565, 0.25 +Res-1.3170, 13631205565, 0.25 +Res-1.3171, 13631205565, 0.25 +Res-1.3172, 13631205565, 0.25 +Res-1.3173, 13631205565, 0.25 +Res-1.3174, 13631205565, 0.25 +Res-1.3175, 13631205565, 0.25 +Res-1.3176, 13631205565, 0.25 +Res-1.3177, 13631205565, 0.25 +Res-1.3178, 13631205565, 0.25 +Res-1.3179, 13631205565, 0.25 +Res-1.3180, 13631205565, 0.25 +Res-1.3181, 13631205565, 0.25 +Res-1.3182, 13631205565, 0.25 +Res-1.3183, 13631205565, 0.25 +Res-1.3184, 13631205565, 0.25 +Res-1.3185, 13631205565, 0.25 +Res-1.3186, 13631205565, 0.25 +Res-1.3187, 13631205565, 0.25 +Res-1.3188, 13631205565, 0.25 +Res-1.3189, 13631205565, 0.25 +Res-1.3190, 13631205565, 0.25 +Res-1.3191, 13631205565, 0.25 +Res-1.3192, 13631205565, 0.25 +Res-1.3193, 13631205565, 0.25 +Res-1.3194, 13631205565, 0.25 +Res-1.3195, 13631205565, 0.25 +Res-1.3196, 13631205565, 0.25 +Res-1.3197, 13631205565, 0.25 +Res-1.3198, 13631205565, 0.25 +Res-1.3199, 13631205565, 0.25 +Res-1.3200, 13631205565, 0.25 +Res-1.3201, 13631205565, 0.25 +Res-1.3202, 13631205565, 0.25 +Res-1.3203, 13631205565, 0.25 +Res-1.3204, 13631205565, 0.25 +Res-1.3205, 13631205565, 0.25 +Res-1.3206, 13631205565, 0.25 +Res-1.3207, 13631205565, 0.25 +Res-1.3208, 13631205565, 0.25 +Res-1.3209, 13631205565, 0.25 +Res-1.3210, 13631205565, 0.25 +Res-1.3211, 13631205565, 0.25 +Res-1.3212, 13631205565, 0.25 +Res-1.3213, 13631205565, 0.25 +Res-1.3214, 13631205565, 0.25 +Res-1.3215, 13631205565, 0.25 +Res-1.3216, 13631205565, 0.25 +Res-1.3217, 13631205565, 0.25 +Res-1.3218, 13631205565, 0.25 +Res-1.3219, 13631205565, 0.25 +Res-1.3220, 13631205565, 0.25 +Res-1.3221, 13631205565, 0.25 +Res-1.3222, 13631205565, 0.25 +Res-1.3223, 13631205565, 0.25 +Res-1.3224, 13631205565, 0.25 +Res-1.3225, 13631205565, 0.25 +Res-1.3226, 13631205565, 0.25 +Res-1.3227, 13631205565, 0.25 +Res-1.3228, 13631205565, 0.25 +Res-1.3229, 13631205565, 0.25 +Res-1.3230, 13631205565, 0.25 +Res-1.3231, 13631205565, 0.25 +Res-1.3232, 13631205565, 0.25 +Res-1.3233, 13631205565, 0.25 +Res-1.3234, 13631205565, 0.25 +Res-1.3235, 13631205565, 0.25 +Res-1.3236, 13631205565, 0.25 +Res-1.3237, 13631205565, 0.25 +Res-1.3238, 13631205565, 0.25 +Res-1.3239, 13631205565, 0.25 +Res-1.3240, 13631205565, 0.25 +Res-1.3241, 13631205565, 0.25 +Res-1.3242, 13631205565, 0.25 +Res-1.3243, 13631205565, 0.25 +Res-1.3244, 13631205565, 0.25 +Res-1.3245, 13631205565, 0.25 +Res-1.3246, 13631205565, 0.25 +Res-1.3247, 13631205565, 0.25 +Res-1.3248, 13631205565, 0.25 +Res-1.3249, 13631205565, 0.25 +Res-1.3250, 13631205565, 0.25 +Res-1.3251, 13631205565, 0.25 +Res-1.3252, 13631205565, 0.25 +Res-1.3253, 13631205565, 0.25 +Res-1.3254, 13631205565, 0.25 +Res-1.3255, 13631205565, 0.25 +Res-1.3256, 13631205565, 0.25 +Res-1.3257, 13631205565, 0.25 +Res-1.3258, 13631205565, 0.25 +Res-1.3259, 13631205565, 0.25 +Res-1.3260, 13631205565, 0.25 +Res-1.3261, 13631205565, 0.25 +Res-1.3262, 13631205565, 0.25 +Res-1.3263, 13631205565, 0.25 +Res-1.3264, 13631205565, 0.25 +Res-1.3265, 13631205565, 0.25 +Res-1.3266, 13631205565, 0.25 +Res-1.3267, 13631205565, 0.25 +Res-1.3268, 13631205565, 0.25 +Res-1.3269, 13631205565, 0.25 +Res-1.3270, 13631205565, 0.25 +Res-1.3271, 13631205565, 0.25 +Res-1.3272, 13631205565, 0.25 +Res-1.3273, 13631205565, 0.25 +Res-1.3274, 13631205565, 0.25 +Res-1.3275, 13631205565, 0.25 +Res-1.3276, 13631205565, 0.25 +Res-1.3277, 13631205565, 0.25 +Res-1.3278, 13631205565, 0.25 +Res-1.3279, 13631205565, 0.25 +Res-1.3280, 13631205565, 0.25 +Res-1.3281, 13631205565, 0.25 +Res-1.3282, 13631205565, 0.25 +Res-1.3283, 13631205565, 0.25 +Res-1.3284, 13631205565, 0.25 +Res-1.3285, 13631205565, 0.25 +Res-1.3286, 13631205565, 0.25 +Res-1.3287, 13631205565, 0.25 +Res-1.3288, 13631205565, 0.25 +Res-1.3289, 13631205565, 0.25 +Res-1.3290, 13631205565, 0.25 +Res-1.3291, 13631205565, 0.25 +Res-1.3292, 13631205565, 0.25 +Res-1.3293, 13631205565, 0.25 +Res-1.3294, 13631205565, 0.25 +Res-1.3295, 13631205565, 0.25 +Res-1.3296, 13631205565, 0.25 +Res-1.3297, 13631205565, 0.25 +Res-1.3298, 13631205565, 0.25 +Res-1.3299, 13631205565, 0.25 +Res-1.3300, 13631205565, 0.25 +Res-1.3301, 13631205565, 0.25 +Res-1.3302, 13631205565, 0.25 +Res-1.3303, 13631205565, 0.25 +Res-1.3304, 13631205565, 0.25 +Res-1.3305, 13631205565, 0.25 +Res-1.3306, 13631205565, 0.25 +Res-1.3307, 13631205565, 0.25 +Res-1.3308, 13631205565, 0.25 +Res-1.3309, 13631205565, 0.25 +Res-1.3310, 13631205565, 0.25 +Res-1.3311, 13631205565, 0.25 +Res-1.3312, 13631205565, 0.25 +Res-1.3313, 13631205565, 0.25 +Res-1.3314, 13631205565, 0.25 +Res-1.3315, 13631205565, 0.25 +Res-1.3316, 13631205565, 0.25 +Res-1.3317, 13631205565, 0.25 +Res-1.3318, 13631205565, 0.25 +Res-1.3319, 13631205565, 0.25 +Res-1.3320, 13631205565, 0.25 +Res-1.3321, 13631205565, 0.25 +Res-1.3322, 13631205565, 0.25 +Res-1.3323, 13631205565, 0.25 +Res-1.3324, 13631205565, 0.25 +Res-1.3325, 13631205565, 0.25 +Res-1.3326, 13631205565, 0.25 +Res-1.3327, 13631205565, 0.25 +Res-1.3328, 13631205565, 0.25 +Res-1.3329, 13631205565, 0.25 +Res-1.3330, 13631205565, 0.25 +Res-1.3331, 13631205565, 0.25 +Res-1.3332, 13631205565, 0.25 +Res-1.3333, 13631205565, 0.25 +Res-1.3334, 13631205565, 0.25 +Res-1.3335, 13631205565, 0.25 +Res-1.3336, 13631205565, 0.25 +Res-1.3337, 13631205565, 0.25 +Res-1.3338, 13631205565, 0.25 +Res-1.3339, 13631205565, 0.25 +Res-1.3340, 13631205565, 0.25 +Res-1.3341, 13631205565, 0.25 +Res-1.3342, 13631205565, 0.25 +Res-1.3343, 13631205565, 0.25 +Res-1.3344, 13631205565, 0.25 +Res-1.3345, 13631205565, 0.25 +Res-1.3346, 13631205565, 0.25 +Res-1.3347, 13631205565, 0.25 +Res-1.3348, 13631205565, 0.25 +Res-1.3349, 13631205565, 0.25 +Res-1.3350, 13631205565, 0.25 +Res-1.3351, 13631205565, 0.25 +Res-1.3352, 13631205565, 0.25 +Res-1.3353, 13631205565, 0.25 +Res-1.3354, 13631205565, 0.25 +Res-1.3355, 13631205565, 0.25 +Res-1.3356, 13631205565, 0.25 +Res-1.3357, 13631205565, 0.25 +Res-1.3358, 13631205565, 0.25 +Res-1.3359, 13631205565, 0.25 +Res-1.3360, 13631205565, 0.25 +Res-1.3361, 13631205565, 0.25 +Res-1.3362, 13631205565, 0.25 +Res-1.3363, 13631205565, 0.25 +Res-1.3364, 13631205565, 0.25 +Res-1.3365, 13631205565, 0.25 +Res-1.3366, 13631205565, 0.25 +Res-1.3367, 13631205565, 0.25 +Res-1.3368, 13631205565, 0.25 +Res-1.3369, 13631205565, 0.25 +Res-1.3370, 13631205565, 0.25 +Res-1.3371, 13631205565, 0.25 +Res-1.3372, 13631205565, 0.25 +Res-1.3373, 13631205565, 0.25 +Res-1.3374, 13631205565, 0.25 +Res-1.3375, 13631205565, 0.25 +Res-1.3376, 13631205565, 0.25 +Res-1.3377, 13631205565, 0.25 +Res-1.3378, 13631205565, 0.25 +Res-1.3379, 13631205565, 0.25 +Res-1.3380, 13631205565, 0.25 +Res-1.3381, 13631205565, 0.25 +Res-1.3382, 13631205565, 0.25 +Res-1.3383, 13631205565, 0.25 +Res-1.3384, 13631205565, 0.25 +Res-1.3385, 13631205565, 0.25 +Res-1.3386, 13631205565, 0.25 +Res-1.3387, 13631205565, 0.25 +Res-1.3388, 13631205565, 0.25 +Res-1.3389, 13631205565, 0.25 +Res-1.3390, 13631205565, 0.25 +Res-1.3391, 13631205565, 0.25 +Res-1.3392, 13631205565, 0.25 +Res-1.3393, 13631205565, 0.25 +Res-1.3394, 13631205565, 0.25 +Res-1.3395, 13631205565, 0.25 +Res-1.3396, 13631205565, 0.25 +Res-1.3397, 13631205565, 0.25 +Res-1.3398, 13631205565, 0.25 +Res-1.3399, 13631205565, 0.25 +Res-1.3400, 13631205565, 0.25 +Res-1.3401, 13631205565, 0.25 +Res-1.3402, 13631205565, 0.25 +Res-1.3403, 13631205565, 0.25 +Res-1.3404, 13631205565, 0.25 +Res-1.3405, 13631205565, 0.25 +Res-1.3406, 13631205565, 0.25 +Res-1.3407, 13631205565, 0.25 +Res-1.3408, 13631205565, 0.25 +Res-1.3409, 13631205565, 0.25 +Res-1.3410, 13631205565, 0.25 +Res-1.3411, 13631205565, 0.25 +Res-1.3412, 13631205565, 0.25 +Res-1.3413, 13631205565, 0.25 +Res-1.3414, 13631205565, 0.25 +Res-1.3415, 13631205565, 0.25 +Res-1.3416, 13631205565, 0.25 +Res-1.3417, 13631205565, 0.25 +Res-1.3418, 13631205565, 0.25 +Res-1.3419, 13631205565, 0.25 +Res-1.3420, 13631205565, 0.25 +Res-1.3421, 13631205565, 0.25 +Res-1.3422, 13631205565, 0.25 +Res-1.3423, 13631205565, 0.25 +Res-1.3424, 13631205565, 0.25 +Res-1.3425, 13631205565, 0.25 +Res-1.3426, 13631205565, 0.25 +Res-1.3427, 13631205565, 0.25 +Res-1.3428, 13631205565, 0.25 +Res-1.3429, 13631205565, 0.25 +Res-1.3430, 13631205565, 0.25 +Res-1.3431, 13631205565, 0.25 +Res-1.3432, 13631205565, 0.25 +Res-1.3433, 13631205565, 0.25 +Res-1.3434, 13631205565, 0.25 +Res-1.3435, 13631205565, 0.25 +Res-1.3436, 13631205565, 0.25 +Res-1.3437, 13631205565, 0.25 +Res-1.3438, 13631205565, 0.25 +Res-1.3439, 13631205565, 0.25 +Res-1.3440, 13631205565, 0.25 +Res-1.3441, 13631205565, 0.25 +Res-1.3442, 13631205565, 0.25 +Res-1.3443, 13631205565, 0.25 +Res-1.3444, 13631205565, 0.25 +Res-1.3445, 13631205565, 0.25 +Res-1.3446, 13631205565, 0.25 +Res-1.3447, 13631205565, 0.25 +Res-1.3448, 13631205565, 0.25 +Res-1.3449, 13631205565, 0.25 +Res-1.3450, 13631205565, 0.25 +Res-1.3451, 13631205565, 0.25 +Res-1.3452, 13631205565, 0.25 +Res-1.3453, 13631205565, 0.25 +Res-1.3454, 13631205565, 0.25 +Res-1.3455, 13631205565, 0.25 +Res-1.3456, 13631205565, 0.25 +Res-1.3457, 16739025760, 0.25 +Res-1.3458, 16739025760, 0.25 +Res-1.3459, 16739025760, 0.25 +Res-1.3460, 16739025760, 0.25 +Res-1.3461, 16739025760, 0.25 +Res-1.3462, 16739025760, 0.25 +Res-1.3463, 16739025760, 0.25 +Res-1.3464, 16739025760, 0.25 +Res-1.3465, 16739025760, 0.25 +Res-1.3466, 16739025760, 0.25 +Res-1.3467, 16739025760, 0.25 +Res-1.3468, 16739025760, 0.25 +Res-1.3469, 16739025760, 0.25 +Res-1.3470, 16739025760, 0.25 +Res-1.3471, 16739025760, 0.25 +Res-1.3472, 16739025760, 0.25 +Res-1.3473, 16739025760, 0.25 +Res-1.3474, 16739025760, 0.25 +Res-1.3475, 16739025760, 0.25 +Res-1.3476, 16739025760, 0.25 +Res-1.3477, 16739025760, 0.25 +Res-1.3478, 16739025760, 0.25 +Res-1.3479, 16739025760, 0.25 +Res-1.3480, 16739025760, 0.25 +Res-1.3481, 16739025760, 0.25 +Res-1.3482, 16739025760, 0.25 +Res-1.3483, 16739025760, 0.25 +Res-1.3484, 16739025760, 0.25 +Res-1.3485, 16739025760, 0.25 +Res-1.3486, 16739025760, 0.25 +Res-1.3487, 16739025760, 0.25 +Res-1.3488, 16739025760, 0.25 +Res-1.3489, 16739025760, 0.25 +Res-1.3490, 16739025760, 0.25 +Res-1.3491, 16739025760, 0.25 +Res-1.3492, 16739025760, 0.25 +Res-1.3493, 16739025760, 0.25 +Res-1.3494, 16739025760, 0.25 +Res-1.3495, 16739025760, 0.25 +Res-1.3496, 16739025760, 0.25 +Res-1.3497, 16739025760, 0.25 +Res-1.3498, 16739025760, 0.25 +Res-1.3499, 16739025760, 0.25 +Res-1.3500, 16739025760, 0.25 +Res-1.3501, 16739025760, 0.25 +Res-1.3502, 16739025760, 0.25 +Res-1.3503, 16739025760, 0.25 +Res-1.3504, 16739025760, 0.25 +Res-1.3505, 16739025760, 0.25 +Res-1.3506, 16739025760, 0.25 +Res-1.3507, 16739025760, 0.25 +Res-1.3508, 16739025760, 0.25 +Res-1.3509, 16739025760, 0.25 +Res-1.3510, 16739025760, 0.25 +Res-1.3511, 16739025760, 0.25 +Res-1.3512, 16739025760, 0.25 +Res-1.3513, 16739025760, 0.25 +Res-1.3514, 16739025760, 0.25 +Res-1.3515, 16739025760, 0.25 +Res-1.3516, 16739025760, 0.25 +Res-1.3517, 16739025760, 0.25 +Res-1.3518, 16739025760, 0.25 +Res-1.3519, 16739025760, 0.25 +Res-1.3520, 16739025760, 0.25 +Res-1.3521, 16739025760, 0.25 +Res-1.3522, 16739025760, 0.25 +Res-1.3523, 16739025760, 0.25 +Res-1.3524, 16739025760, 0.25 +Res-1.3525, 16739025760, 0.25 +Res-1.3526, 16739025760, 0.25 +Res-1.3527, 16739025760, 0.25 +Res-1.3528, 16739025760, 0.25 +Res-1.3529, 16739025760, 0.25 +Res-1.3530, 16739025760, 0.25 +Res-1.3531, 16739025760, 0.25 +Res-1.3532, 16739025760, 0.25 +Res-1.3533, 16739025760, 0.25 +Res-1.3534, 16739025760, 0.25 +Res-1.3535, 16739025760, 0.25 +Res-1.3536, 16739025760, 0.25 +Res-1.3537, 16739025760, 0.25 +Res-1.3538, 16739025760, 0.25 +Res-1.3539, 16739025760, 0.25 +Res-1.3540, 16739025760, 0.25 +Res-1.3541, 16739025760, 0.25 +Res-1.3542, 16739025760, 0.25 +Res-1.3543, 16739025760, 0.25 +Res-1.3544, 16739025760, 0.25 +Res-1.3545, 16739025760, 0.25 +Res-1.3546, 16739025760, 0.25 +Res-1.3547, 16739025760, 0.25 +Res-1.3548, 16739025760, 0.25 +Res-1.3549, 16739025760, 0.25 +Res-1.3550, 16739025760, 0.25 +Res-1.3551, 16739025760, 0.25 +Res-1.3552, 16739025760, 0.25 +Res-1.3553, 16739025760, 0.25 +Res-1.3554, 16739025760, 0.25 +Res-1.3555, 16739025760, 0.25 +Res-1.3556, 16739025760, 0.25 +Res-1.3557, 16739025760, 0.25 +Res-1.3558, 16739025760, 0.25 +Res-1.3559, 16739025760, 0.25 +Res-1.3560, 16739025760, 0.25 +Res-1.3561, 16739025760, 0.25 +Res-1.3562, 16739025760, 0.25 +Res-1.3563, 16739025760, 0.25 +Res-1.3564, 16739025760, 0.25 +Res-1.3565, 16739025760, 0.25 +Res-1.3566, 16739025760, 0.25 +Res-1.3567, 16739025760, 0.25 +Res-1.3568, 16739025760, 0.25 +Res-1.3569, 16739025760, 0.25 +Res-1.3570, 16739025760, 0.25 +Res-1.3571, 16739025760, 0.25 +Res-1.3572, 16739025760, 0.25 +Res-1.3573, 16739025760, 0.25 +Res-1.3574, 16739025760, 0.25 +Res-1.3575, 16739025760, 0.25 +Res-1.3576, 16739025760, 0.25 +Res-1.3577, 16739025760, 0.25 +Res-1.3578, 16739025760, 0.25 +Res-1.3579, 16739025760, 0.25 +Res-1.3580, 16739025760, 0.25 +Res-1.3581, 16739025760, 0.25 +Res-1.3582, 16739025760, 0.25 +Res-1.3583, 16739025760, 0.25 +Res-1.3584, 16739025760, 0.25 +Res-1.3585, 16739025760, 0.25 +Res-1.3586, 16739025760, 0.25 +Res-1.3587, 16739025760, 0.25 +Res-1.3588, 16739025760, 0.25 +Res-1.3589, 16739025760, 0.25 +Res-1.3590, 16739025760, 0.25 +Res-1.3591, 16739025760, 0.25 +Res-1.3592, 16739025760, 0.25 +Res-1.3593, 16739025760, 0.25 +Res-1.3594, 16739025760, 0.25 +Res-1.3595, 16739025760, 0.25 +Res-1.3596, 16739025760, 0.25 +Res-1.3597, 16739025760, 0.25 +Res-1.3598, 16739025760, 0.25 +Res-1.3599, 16739025760, 0.25 +Res-1.3600, 16739025760, 0.25 +Res-1.3601, 16739025760, 0.25 +Res-1.3602, 16739025760, 0.25 +Res-1.3603, 16739025760, 0.25 +Res-1.3604, 16739025760, 0.25 +Res-1.3605, 16739025760, 0.25 +Res-1.3606, 16739025760, 0.25 +Res-1.3607, 16739025760, 0.25 +Res-1.3608, 16739025760, 0.25 +Res-1.3609, 16739025760, 0.25 +Res-1.3610, 16739025760, 0.25 +Res-1.3611, 16739025760, 0.25 +Res-1.3612, 16739025760, 0.25 +Res-1.3613, 16739025760, 0.25 +Res-1.3614, 16739025760, 0.25 +Res-1.3615, 16739025760, 0.25 +Res-1.3616, 16739025760, 0.25 +Res-1.3617, 16739025760, 0.25 +Res-1.3618, 16739025760, 0.25 +Res-1.3619, 16739025760, 0.25 +Res-1.3620, 16739025760, 0.25 +Res-1.3621, 16739025760, 0.25 +Res-1.3622, 16739025760, 0.25 +Res-1.3623, 16739025760, 0.25 +Res-1.3624, 16739025760, 0.25 +Res-1.3625, 16739025760, 0.25 +Res-1.3626, 16739025760, 0.25 +Res-1.3627, 16739025760, 0.25 +Res-1.3628, 16739025760, 0.25 +Res-1.3629, 16739025760, 0.25 +Res-1.3630, 16739025760, 0.25 +Res-1.3631, 16739025760, 0.25 +Res-1.3632, 16739025760, 0.25 +Res-1.3633, 16739025760, 0.25 +Res-1.3634, 16739025760, 0.25 +Res-1.3635, 16739025760, 0.25 +Res-1.3636, 16739025760, 0.25 +Res-1.3637, 16739025760, 0.25 +Res-1.3638, 16739025760, 0.25 +Res-1.3639, 16739025760, 0.25 +Res-1.3640, 16739025760, 0.25 +Res-1.3641, 16739025760, 0.25 +Res-1.3642, 16739025760, 0.25 +Res-1.3643, 16739025760, 0.25 +Res-1.3644, 16739025760, 0.25 +Res-1.3645, 16739025760, 0.25 +Res-1.3646, 16739025760, 0.25 +Res-1.3647, 16739025760, 0.25 +Res-1.3648, 16739025760, 0.25 +Res-1.3649, 16739025760, 0.25 +Res-1.3650, 16739025760, 0.25 +Res-1.3651, 16739025760, 0.25 +Res-1.3652, 16739025760, 0.25 +Res-1.3653, 16739025760, 0.25 +Res-1.3654, 16739025760, 0.25 +Res-1.3655, 16739025760, 0.25 +Res-1.3656, 16739025760, 0.25 +Res-1.3657, 16739025760, 0.25 +Res-1.3658, 16739025760, 0.25 +Res-1.3659, 16739025760, 0.25 +Res-1.3660, 16739025760, 0.25 +Res-1.3661, 16739025760, 0.25 +Res-1.3662, 16739025760, 0.25 +Res-1.3663, 16739025760, 0.25 +Res-1.3664, 16739025760, 0.25 +Res-1.3665, 16739025760, 0.25 +Res-1.3666, 16739025760, 0.25 +Res-1.3667, 16739025760, 0.25 +Res-1.3668, 16739025760, 0.25 +Res-1.3669, 16739025760, 0.25 +Res-1.3670, 16739025760, 0.25 +Res-1.3671, 16739025760, 0.25 +Res-1.3672, 16739025760, 0.25 +Res-1.3673, 16739025760, 0.25 +Res-1.3674, 16739025760, 0.25 +Res-1.3675, 16739025760, 0.25 +Res-1.3676, 16739025760, 0.25 +Res-1.3677, 16739025760, 0.25 +Res-1.3678, 16739025760, 0.25 +Res-1.3679, 16739025760, 0.25 +Res-1.3680, 16739025760, 0.25 +Res-1.3681, 16739025760, 0.25 +Res-1.3682, 16739025760, 0.25 +Res-1.3683, 16739025760, 0.25 +Res-1.3684, 16739025760, 0.25 +Res-1.3685, 16739025760, 0.25 +Res-1.3686, 16739025760, 0.25 +Res-1.3687, 16739025760, 0.25 +Res-1.3688, 16739025760, 0.25 +Res-1.3689, 16739025760, 0.25 +Res-1.3690, 16739025760, 0.25 +Res-1.3691, 16739025760, 0.25 +Res-1.3692, 16739025760, 0.25 +Res-1.3693, 16739025760, 0.25 +Res-1.3694, 16739025760, 0.25 +Res-1.3695, 16739025760, 0.25 +Res-1.3696, 16739025760, 0.25 +Res-1.3697, 16739025760, 0.25 +Res-1.3698, 16739025760, 0.25 +Res-1.3699, 16739025760, 0.25 +Res-1.3700, 16739025760, 0.25 +Res-1.3701, 16739025760, 0.25 +Res-1.3702, 16739025760, 0.25 +Res-1.3703, 16739025760, 0.25 +Res-1.3704, 16739025760, 0.25 +Res-1.3705, 16739025760, 0.25 +Res-1.3706, 16739025760, 0.25 +Res-1.3707, 16739025760, 0.25 +Res-1.3708, 16739025760, 0.25 +Res-1.3709, 16739025760, 0.25 +Res-1.3710, 16739025760, 0.25 +Res-1.3711, 16739025760, 0.25 +Res-1.3712, 16739025760, 0.25 +Res-1.3713, 16739025760, 0.25 +Res-1.3714, 16739025760, 0.25 +Res-1.3715, 16739025760, 0.25 +Res-1.3716, 16739025760, 0.25 +Res-1.3717, 16739025760, 0.25 +Res-1.3718, 16739025760, 0.25 +Res-1.3719, 16739025760, 0.25 +Res-1.3720, 16739025760, 0.25 +Res-1.3721, 16739025760, 0.25 +Res-1.3722, 16739025760, 0.25 +Res-1.3723, 16739025760, 0.25 +Res-1.3724, 16739025760, 0.25 +Res-1.3725, 16739025760, 0.25 +Res-1.3726, 16739025760, 0.25 +Res-1.3727, 16739025760, 0.25 +Res-1.3728, 16739025760, 0.25 +Res-1.3729, 16739025760, 0.25 +Res-1.3730, 16739025760, 0.25 +Res-1.3731, 16739025760, 0.25 +Res-1.3732, 16739025760, 0.25 +Res-1.3733, 16739025760, 0.25 +Res-1.3734, 16739025760, 0.25 +Res-1.3735, 16739025760, 0.25 +Res-1.3736, 16739025760, 0.25 +Res-1.3737, 16739025760, 0.25 +Res-1.3738, 16739025760, 0.25 +Res-1.3739, 16739025760, 0.25 +Res-1.3740, 16739025760, 0.25 +Res-1.3741, 16739025760, 0.25 +Res-1.3742, 16739025760, 0.25 +Res-1.3743, 16739025760, 0.25 +Res-1.3744, 16739025760, 0.25 +Res-1.3745, 17409132100, 0.25 +Res-1.3746, 17409132100, 0.25 +Res-1.3747, 17409132100, 0.25 +Res-1.3748, 17409132100, 0.25 +Res-1.3749, 17409132100, 0.25 +Res-1.3750, 17409132100, 0.25 +Res-1.3751, 17409132100, 0.25 +Res-1.3752, 17409132100, 0.25 +Res-1.3753, 17409132100, 0.25 +Res-1.3754, 17409132100, 0.25 +Res-1.3755, 17409132100, 0.25 +Res-1.3756, 17409132100, 0.25 +Res-1.3757, 17409132100, 0.25 +Res-1.3758, 17409132100, 0.25 +Res-1.3759, 17409132100, 0.25 +Res-1.3760, 17409132100, 0.25 +Res-1.3761, 17409132100, 0.25 +Res-1.3762, 17409132100, 0.25 +Res-1.3763, 17409132100, 0.25 +Res-1.3764, 17409132100, 0.25 +Res-1.3765, 17409132100, 0.25 +Res-1.3766, 17409132100, 0.25 +Res-1.3767, 17409132100, 0.25 +Res-1.3768, 17409132100, 0.25 +Res-1.3769, 17409132100, 0.25 +Res-1.3770, 17409132100, 0.25 +Res-1.3771, 17409132100, 0.25 +Res-1.3772, 17409132100, 0.25 +Res-1.3773, 17409132100, 0.25 +Res-1.3774, 17409132100, 0.25 +Res-1.3775, 17409132100, 0.25 +Res-1.3776, 17409132100, 0.25 +Res-1.3777, 17409132100, 0.25 +Res-1.3778, 17409132100, 0.25 +Res-1.3779, 17409132100, 0.25 +Res-1.3780, 17409132100, 0.25 +Res-1.3781, 17409132100, 0.25 +Res-1.3782, 17409132100, 0.25 +Res-1.3783, 17409132100, 0.25 +Res-1.3784, 17409132100, 0.25 +Res-1.3785, 17409132100, 0.25 +Res-1.3786, 17409132100, 0.25 +Res-1.3787, 17409132100, 0.25 +Res-1.3788, 17409132100, 0.25 +Res-1.3789, 17409132100, 0.25 +Res-1.3790, 17409132100, 0.25 +Res-1.3791, 17409132100, 0.25 +Res-1.3792, 17409132100, 0.25 +Res-1.3793, 17409132100, 0.25 +Res-1.3794, 17409132100, 0.25 +Res-1.3795, 17409132100, 0.25 +Res-1.3796, 17409132100, 0.25 +Res-1.3797, 17409132100, 0.25 +Res-1.3798, 17409132100, 0.25 +Res-1.3799, 17409132100, 0.25 +Res-1.3800, 17409132100, 0.25 +Res-1.3801, 17409132100, 0.25 +Res-1.3802, 17409132100, 0.25 +Res-1.3803, 17409132100, 0.25 +Res-1.3804, 17409132100, 0.25 +Res-1.3805, 17409132100, 0.25 +Res-1.3806, 17409132100, 0.25 +Res-1.3807, 17409132100, 0.25 +Res-1.3808, 17409132100, 0.25 +Res-1.3809, 17409132100, 0.25 +Res-1.3810, 17409132100, 0.25 +Res-1.3811, 17409132100, 0.25 +Res-1.3812, 17409132100, 0.25 +Res-1.3813, 17409132100, 0.25 +Res-1.3814, 17409132100, 0.25 +Res-1.3815, 17409132100, 0.25 +Res-1.3816, 17409132100, 0.25 +Res-1.3817, 17409132100, 0.25 +Res-1.3818, 17409132100, 0.25 +Res-1.3819, 17409132100, 0.25 +Res-1.3820, 17409132100, 0.25 +Res-1.3821, 17409132100, 0.25 +Res-1.3822, 17409132100, 0.25 +Res-1.3823, 17409132100, 0.25 +Res-1.3824, 17409132100, 0.25 +Res-1.3825, 17409132100, 0.25 +Res-1.3826, 17409132100, 0.25 +Res-1.3827, 17409132100, 0.25 +Res-1.3828, 17409132100, 0.25 +Res-1.3829, 17409132100, 0.25 +Res-1.3830, 17409132100, 0.25 +Res-1.3831, 17409132100, 0.25 +Res-1.3832, 17409132100, 0.25 +Res-1.3833, 17409132100, 0.25 +Res-1.3834, 17409132100, 0.25 +Res-1.3835, 17409132100, 0.25 +Res-1.3836, 17409132100, 0.25 +Res-1.3837, 17409132100, 0.25 +Res-1.3838, 17409132100, 0.25 +Res-1.3839, 17409132100, 0.25 +Res-1.3840, 17409132100, 0.25 +Res-1.3841, 17409132100, 0.25 +Res-1.3842, 17409132100, 0.25 +Res-1.3843, 17409132100, 0.25 +Res-1.3844, 17409132100, 0.25 +Res-1.3845, 17409132100, 0.25 +Res-1.3846, 17409132100, 0.25 +Res-1.3847, 17409132100, 0.25 +Res-1.3848, 17409132100, 0.25 +Res-1.3849, 17409132100, 0.25 +Res-1.3850, 17409132100, 0.25 +Res-1.3851, 17409132100, 0.25 +Res-1.3852, 17409132100, 0.25 +Res-1.3853, 17409132100, 0.25 +Res-1.3854, 17409132100, 0.25 +Res-1.3855, 17409132100, 0.25 +Res-1.3856, 17409132100, 0.25 +Res-1.3857, 17409132100, 0.25 +Res-1.3858, 17409132100, 0.25 +Res-1.3859, 17409132100, 0.25 +Res-1.3860, 17409132100, 0.25 +Res-1.3861, 17409132100, 0.25 +Res-1.3862, 17409132100, 0.25 +Res-1.3863, 17409132100, 0.25 +Res-1.3864, 17409132100, 0.25 +Res-1.3865, 17409132100, 0.25 +Res-1.3866, 17409132100, 0.25 +Res-1.3867, 17409132100, 0.25 +Res-1.3868, 17409132100, 0.25 +Res-1.3869, 17409132100, 0.25 +Res-1.3870, 17409132100, 0.25 +Res-1.3871, 17409132100, 0.25 +Res-1.3872, 17409132100, 0.25 +Res-1.3873, 17409132100, 0.25 +Res-1.3874, 17409132100, 0.25 +Res-1.3875, 17409132100, 0.25 +Res-1.3876, 17409132100, 0.25 +Res-1.3877, 17409132100, 0.25 +Res-1.3878, 17409132100, 0.25 +Res-1.3879, 17409132100, 0.25 +Res-1.3880, 17409132100, 0.25 +Res-1.3881, 17409132100, 0.25 +Res-1.3882, 17409132100, 0.25 +Res-1.3883, 17409132100, 0.25 +Res-1.3884, 17409132100, 0.25 +Res-1.3885, 17409132100, 0.25 +Res-1.3886, 17409132100, 0.25 +Res-1.3887, 17409132100, 0.25 +Res-1.3888, 17409132100, 0.25 +Res-1.3889, 17409132100, 0.25 +Res-1.3890, 17409132100, 0.25 +Res-1.3891, 17409132100, 0.25 +Res-1.3892, 17409132100, 0.25 +Res-1.3893, 17409132100, 0.25 +Res-1.3894, 17409132100, 0.25 +Res-1.3895, 17409132100, 0.25 +Res-1.3896, 17409132100, 0.25 +Res-1.3897, 17409132100, 0.25 +Res-1.3898, 17409132100, 0.25 +Res-1.3899, 17409132100, 0.25 +Res-1.3900, 17409132100, 0.25 +Res-1.3901, 17409132100, 0.25 +Res-1.3902, 17409132100, 0.25 +Res-1.3903, 17409132100, 0.25 +Res-1.3904, 17409132100, 0.25 +Res-1.3905, 17409132100, 0.25 +Res-1.3906, 17409132100, 0.25 +Res-1.3907, 17409132100, 0.25 +Res-1.3908, 17409132100, 0.25 +Res-1.3909, 17409132100, 0.25 +Res-1.3910, 17409132100, 0.25 +Res-1.3911, 17409132100, 0.25 +Res-1.3912, 17409132100, 0.25 +Res-1.3913, 17409132100, 0.25 +Res-1.3914, 17409132100, 0.25 +Res-1.3915, 17409132100, 0.25 +Res-1.3916, 17409132100, 0.25 +Res-1.3917, 17409132100, 0.25 +Res-1.3918, 17409132100, 0.25 +Res-1.3919, 17409132100, 0.25 +Res-1.3920, 17409132100, 0.25 +Res-1.3921, 17409132100, 0.25 +Res-1.3922, 17409132100, 0.25 +Res-1.3923, 17409132100, 0.25 +Res-1.3924, 17409132100, 0.25 +Res-1.3925, 17409132100, 0.25 +Res-1.3926, 17409132100, 0.25 +Res-1.3927, 17409132100, 0.25 +Res-1.3928, 17409132100, 0.25 +Res-1.3929, 17409132100, 0.25 +Res-1.3930, 17409132100, 0.25 +Res-1.3931, 17409132100, 0.25 +Res-1.3932, 17409132100, 0.25 +Res-1.3933, 17409132100, 0.25 +Res-1.3934, 17409132100, 0.25 +Res-1.3935, 17409132100, 0.25 +Res-1.3936, 17409132100, 0.25 +Res-1.3937, 17409132100, 0.25 +Res-1.3938, 17409132100, 0.25 +Res-1.3939, 17409132100, 0.25 +Res-1.3940, 17409132100, 0.25 +Res-1.3941, 17409132100, 0.25 +Res-1.3942, 17409132100, 0.25 +Res-1.3943, 17409132100, 0.25 +Res-1.3944, 17409132100, 0.25 +Res-1.3945, 17409132100, 0.25 +Res-1.3946, 17409132100, 0.25 +Res-1.3947, 17409132100, 0.25 +Res-1.3948, 17409132100, 0.25 +Res-1.3949, 17409132100, 0.25 +Res-1.3950, 17409132100, 0.25 +Res-1.3951, 17409132100, 0.25 +Res-1.3952, 17409132100, 0.25 +Res-1.3953, 17409132100, 0.25 +Res-1.3954, 17409132100, 0.25 +Res-1.3955, 17409132100, 0.25 +Res-1.3956, 17409132100, 0.25 +Res-1.3957, 17409132100, 0.25 +Res-1.3958, 17409132100, 0.25 +Res-1.3959, 17409132100, 0.25 +Res-1.3960, 17409132100, 0.25 +Res-1.3961, 17409132100, 0.25 +Res-1.3962, 17409132100, 0.25 +Res-1.3963, 17409132100, 0.25 +Res-1.3964, 17409132100, 0.25 +Res-1.3965, 17409132100, 0.25 +Res-1.3966, 17409132100, 0.25 +Res-1.3967, 17409132100, 0.25 +Res-1.3968, 17409132100, 0.25 +Res-1.3969, 17409132100, 0.25 +Res-1.3970, 17409132100, 0.25 +Res-1.3971, 17409132100, 0.25 +Res-1.3972, 17409132100, 0.25 +Res-1.3973, 17409132100, 0.25 +Res-1.3974, 17409132100, 0.25 +Res-1.3975, 17409132100, 0.25 +Res-1.3976, 17409132100, 0.25 +Res-1.3977, 17409132100, 0.25 +Res-1.3978, 17409132100, 0.25 +Res-1.3979, 17409132100, 0.25 +Res-1.3980, 17409132100, 0.25 +Res-1.3981, 17409132100, 0.25 +Res-1.3982, 17409132100, 0.25 +Res-1.3983, 17409132100, 0.25 +Res-1.3984, 17409132100, 0.25 +Res-1.3985, 17409132100, 0.25 +Res-1.3986, 17409132100, 0.25 +Res-1.3987, 17409132100, 0.25 +Res-1.3988, 17409132100, 0.25 +Res-1.3989, 17409132100, 0.25 +Res-1.3990, 17409132100, 0.25 +Res-1.3991, 17409132100, 0.25 +Res-1.3992, 17409132100, 0.25 +Res-1.3993, 17409132100, 0.25 +Res-1.3994, 17409132100, 0.25 +Res-1.3995, 17409132100, 0.25 +Res-1.3996, 17409132100, 0.25 +Res-1.3997, 17409132100, 0.25 +Res-1.3998, 17409132100, 0.25 +Res-1.3999, 17409132100, 0.25 +Res-1.4000, 17409132100, 0.25 +Res-1.4001, 17409132100, 0.25 +Res-1.4002, 17409132100, 0.25 +Res-1.4003, 17409132100, 0.25 +Res-1.4004, 17409132100, 0.25 +Res-1.4005, 17409132100, 0.25 +Res-1.4006, 17409132100, 0.25 +Res-1.4007, 17409132100, 0.25 +Res-1.4008, 17409132100, 0.25 +Res-1.4009, 17409132100, 0.25 +Res-1.4010, 17409132100, 0.25 +Res-1.4011, 17409132100, 0.25 +Res-1.4012, 17409132100, 0.25 +Res-1.4013, 17409132100, 0.25 +Res-1.4014, 17409132100, 0.25 +Res-1.4015, 17409132100, 0.25 +Res-1.4016, 17409132100, 0.25 +Res-1.4017, 17409132100, 0.25 +Res-1.4018, 17409132100, 0.25 +Res-1.4019, 17409132100, 0.25 +Res-1.4020, 17409132100, 0.25 +Res-1.4021, 17409132100, 0.25 +Res-1.4022, 17409132100, 0.25 +Res-1.4023, 17409132100, 0.25 +Res-1.4024, 17409132100, 0.25 +Res-1.4025, 17409132100, 0.25 +Res-1.4026, 17409132100, 0.25 +Res-1.4027, 17409132100, 0.25 +Res-1.4028, 17409132100, 0.25 +Res-1.4029, 17409132100, 0.25 +Res-1.4030, 17409132100, 0.25 +Res-1.4031, 17409132100, 0.25 +Res-1.4032, 17409132100, 0.25 +Res-1.4033, 13250853676.3636, 0.25 +Res-1.4034, 13250853676.3636, 0.25 +Res-1.4035, 13250853676.3636, 0.25 +Res-1.4036, 13250853676.3636, 0.25 +Res-1.4037, 13250853676.3636, 0.25 +Res-1.4038, 13250853676.3636, 0.25 +Res-1.4039, 13250853676.3636, 0.25 +Res-1.4040, 13250853676.3636, 0.25 +Res-1.4041, 13250853676.3636, 0.25 +Res-1.4042, 13250853676.3636, 0.25 +Res-1.4043, 13250853676.3636, 0.25 +Res-1.4044, 13250853676.3636, 0.25 +Res-1.4045, 13250853676.3636, 0.25 +Res-1.4046, 13250853676.3636, 0.25 +Res-1.4047, 13250853676.3636, 0.25 +Res-1.4048, 13250853676.3636, 0.25 +Res-1.4049, 13250853676.3636, 0.25 +Res-1.4050, 13250853676.3636, 0.25 +Res-1.4051, 13250853676.3636, 0.25 +Res-1.4052, 13250853676.3636, 0.25 +Res-1.4053, 13250853676.3636, 0.25 +Res-1.4054, 13250853676.3636, 0.25 +Res-1.4055, 13250853676.3636, 0.25 +Res-1.4056, 13250853676.3636, 0.25 +Res-1.4057, 13250853676.3636, 0.25 +Res-1.4058, 13250853676.3636, 0.25 +Res-1.4059, 13250853676.3636, 0.25 +Res-1.4060, 13250853676.3636, 0.25 +Res-1.4061, 13250853676.3636, 0.25 +Res-1.4062, 13250853676.3636, 0.25 +Res-1.4063, 13250853676.3636, 0.25 +Res-1.4064, 13250853676.3636, 0.25 +Res-1.4065, 13250853676.3636, 0.25 +Res-1.4066, 13250853676.3636, 0.25 +Res-1.4067, 13250853676.3636, 0.25 +Res-1.4068, 13250853676.3636, 0.25 +Res-1.4069, 13250853676.3636, 0.25 +Res-1.4070, 13250853676.3636, 0.25 +Res-1.4071, 13250853676.3636, 0.25 +Res-1.4072, 13250853676.3636, 0.25 +Res-1.4073, 13250853676.3636, 0.25 +Res-1.4074, 13250853676.3636, 0.25 +Res-1.4075, 13250853676.3636, 0.25 +Res-1.4076, 13250853676.3636, 0.25 +Res-1.4077, 13250853676.3636, 0.25 +Res-1.4078, 13250853676.3636, 0.25 +Res-1.4079, 13250853676.3636, 0.25 +Res-1.4080, 13250853676.3636, 0.25 +Res-1.4081, 13250853676.3636, 0.25 +Res-1.4082, 13250853676.3636, 0.25 +Res-1.4083, 13250853676.3636, 0.25 +Res-1.4084, 13250853676.3636, 0.25 +Res-1.4085, 13250853676.3636, 0.25 +Res-1.4086, 13250853676.3636, 0.25 +Res-1.4087, 13250853676.3636, 0.25 +Res-1.4088, 13250853676.3636, 0.25 +Res-1.4089, 13250853676.3636, 0.25 +Res-1.4090, 13250853676.3636, 0.25 +Res-1.4091, 13250853676.3636, 0.25 +Res-1.4092, 13250853676.3636, 0.25 +Res-1.4093, 13250853676.3636, 0.25 +Res-1.4094, 13250853676.3636, 0.25 +Res-1.4095, 13250853676.3636, 0.25 +Res-1.4096, 13250853676.3636, 0.25 +Res-1.4097, 13250853676.3636, 0.25 +Res-1.4098, 13250853676.3636, 0.25 +Res-1.4099, 13250853676.3636, 0.25 +Res-1.4100, 13250853676.3636, 0.25 +Res-1.4101, 13250853676.3636, 0.25 +Res-1.4102, 13250853676.3636, 0.25 +Res-1.4103, 13250853676.3636, 0.25 +Res-1.4104, 13250853676.3636, 0.25 +Res-1.4105, 13250853676.3636, 0.25 +Res-1.4106, 13250853676.3636, 0.25 +Res-1.4107, 13250853676.3636, 0.25 +Res-1.4108, 13250853676.3636, 0.25 +Res-1.4109, 13250853676.3636, 0.25 +Res-1.4110, 13250853676.3636, 0.25 +Res-1.4111, 13250853676.3636, 0.25 +Res-1.4112, 13250853676.3636, 0.25 +Res-1.4113, 13250853676.3636, 0.25 +Res-1.4114, 13250853676.3636, 0.25 +Res-1.4115, 13250853676.3636, 0.25 +Res-1.4116, 13250853676.3636, 0.25 +Res-1.4117, 13250853676.3636, 0.25 +Res-1.4118, 13250853676.3636, 0.25 +Res-1.4119, 13250853676.3636, 0.25 +Res-1.4120, 13250853676.3636, 0.25 +Res-1.4121, 13250853676.3636, 0.25 +Res-1.4122, 13250853676.3636, 0.25 +Res-1.4123, 13250853676.3636, 0.25 +Res-1.4124, 13250853676.3636, 0.25 +Res-1.4125, 13250853676.3636, 0.25 +Res-1.4126, 13250853676.3636, 0.25 +Res-1.4127, 13250853676.3636, 0.25 +Res-1.4128, 13250853676.3636, 0.25 +Res-1.4129, 13250853676.3636, 0.25 +Res-1.4130, 13250853676.3636, 0.25 +Res-1.4131, 13250853676.3636, 0.25 +Res-1.4132, 13250853676.3636, 0.25 +Res-1.4133, 13250853676.3636, 0.25 +Res-1.4134, 13250853676.3636, 0.25 +Res-1.4135, 13250853676.3636, 0.25 +Res-1.4136, 13250853676.3636, 0.25 +Res-1.4137, 13250853676.3636, 0.25 +Res-1.4138, 13250853676.3636, 0.25 +Res-1.4139, 13250853676.3636, 0.25 +Res-1.4140, 13250853676.3636, 0.25 +Res-1.4141, 13250853676.3636, 0.25 +Res-1.4142, 13250853676.3636, 0.25 +Res-1.4143, 13250853676.3636, 0.25 +Res-1.4144, 13250853676.3636, 0.25 +Res-1.4145, 13250853676.3636, 0.25 +Res-1.4146, 13250853676.3636, 0.25 +Res-1.4147, 13250853676.3636, 0.25 +Res-1.4148, 13250853676.3636, 0.25 +Res-1.4149, 13250853676.3636, 0.25 +Res-1.4150, 13250853676.3636, 0.25 +Res-1.4151, 13250853676.3636, 0.25 +Res-1.4152, 13250853676.3636, 0.25 +Res-1.4153, 13250853676.3636, 0.25 +Res-1.4154, 13250853676.3636, 0.25 +Res-1.4155, 13250853676.3636, 0.25 +Res-1.4156, 13250853676.3636, 0.25 +Res-1.4157, 13250853676.3636, 0.25 +Res-1.4158, 13250853676.3636, 0.25 +Res-1.4159, 13250853676.3636, 0.25 +Res-1.4160, 13250853676.3636, 0.25 +Res-1.4161, 13250853676.3636, 0.25 +Res-1.4162, 13250853676.3636, 0.25 +Res-1.4163, 13250853676.3636, 0.25 +Res-1.4164, 13250853676.3636, 0.25 +Res-1.4165, 13250853676.3636, 0.25 +Res-1.4166, 13250853676.3636, 0.25 +Res-1.4167, 13250853676.3636, 0.25 +Res-1.4168, 13250853676.3636, 0.25 +Res-1.4169, 13250853676.3636, 0.25 +Res-1.4170, 13250853676.3636, 0.25 +Res-1.4171, 13250853676.3636, 0.25 +Res-1.4172, 13250853676.3636, 0.25 +Res-1.4173, 13250853676.3636, 0.25 +Res-1.4174, 13250853676.3636, 0.25 +Res-1.4175, 13250853676.3636, 0.25 +Res-1.4176, 13250853676.3636, 0.25 +Res-1.4177, 13250853676.3636, 0.25 +Res-1.4178, 13250853676.3636, 0.25 +Res-1.4179, 13250853676.3636, 0.25 +Res-1.4180, 13250853676.3636, 0.25 +Res-1.4181, 13250853676.3636, 0.25 +Res-1.4182, 13250853676.3636, 0.25 +Res-1.4183, 13250853676.3636, 0.25 +Res-1.4184, 13250853676.3636, 0.25 +Res-1.4185, 13250853676.3636, 0.25 +Res-1.4186, 13250853676.3636, 0.25 +Res-1.4187, 13250853676.3636, 0.25 +Res-1.4188, 13250853676.3636, 0.25 +Res-1.4189, 13250853676.3636, 0.25 +Res-1.4190, 13250853676.3636, 0.25 +Res-1.4191, 13250853676.3636, 0.25 +Res-1.4192, 13250853676.3636, 0.25 +Res-1.4193, 13250853676.3636, 0.25 +Res-1.4194, 13250853676.3636, 0.25 +Res-1.4195, 13250853676.3636, 0.25 +Res-1.4196, 13250853676.3636, 0.25 +Res-1.4197, 13250853676.3636, 0.25 +Res-1.4198, 13250853676.3636, 0.25 +Res-1.4199, 13250853676.3636, 0.25 +Res-1.4200, 13250853676.3636, 0.25 +Res-1.4201, 13250853676.3636, 0.25 +Res-1.4202, 13250853676.3636, 0.25 +Res-1.4203, 13250853676.3636, 0.25 +Res-1.4204, 13250853676.3636, 0.25 +Res-1.4205, 13250853676.3636, 0.25 +Res-1.4206, 13250853676.3636, 0.25 +Res-1.4207, 13250853676.3636, 0.25 +Res-1.4208, 13250853676.3636, 0.25 +Res-1.4209, 13250853676.3636, 0.25 +Res-1.4210, 13250853676.3636, 0.25 +Res-1.4211, 13250853676.3636, 0.25 +Res-1.4212, 13250853676.3636, 0.25 +Res-1.4213, 13250853676.3636, 0.25 +Res-1.4214, 13250853676.3636, 0.25 +Res-1.4215, 13250853676.3636, 0.25 +Res-1.4216, 13250853676.3636, 0.25 +Res-1.4217, 13250853676.3636, 0.25 +Res-1.4218, 13250853676.3636, 0.25 +Res-1.4219, 13250853676.3636, 0.25 +Res-1.4220, 13250853676.3636, 0.25 +Res-1.4221, 13250853676.3636, 0.25 +Res-1.4222, 13250853676.3636, 0.25 +Res-1.4223, 13250853676.3636, 0.25 +Res-1.4224, 13250853676.3636, 0.25 +Res-1.4225, 13250853676.3636, 0.25 +Res-1.4226, 13250853676.3636, 0.25 +Res-1.4227, 13250853676.3636, 0.25 +Res-1.4228, 13250853676.3636, 0.25 +Res-1.4229, 13250853676.3636, 0.25 +Res-1.4230, 13250853676.3636, 0.25 +Res-1.4231, 13250853676.3636, 0.25 +Res-1.4232, 13250853676.3636, 0.25 +Res-1.4233, 13250853676.3636, 0.25 +Res-1.4234, 13250853676.3636, 0.25 +Res-1.4235, 13250853676.3636, 0.25 +Res-1.4236, 13250853676.3636, 0.25 +Res-1.4237, 13250853676.3636, 0.25 +Res-1.4238, 13250853676.3636, 0.25 +Res-1.4239, 13250853676.3636, 0.25 +Res-1.4240, 13250853676.3636, 0.25 +Res-1.4241, 13250853676.3636, 0.25 +Res-1.4242, 13250853676.3636, 0.25 +Res-1.4243, 13250853676.3636, 0.25 +Res-1.4244, 13250853676.3636, 0.25 +Res-1.4245, 13250853676.3636, 0.25 +Res-1.4246, 13250853676.3636, 0.25 +Res-1.4247, 13250853676.3636, 0.25 +Res-1.4248, 13250853676.3636, 0.25 +Res-1.4249, 13250853676.3636, 0.25 +Res-1.4250, 13250853676.3636, 0.25 +Res-1.4251, 13250853676.3636, 0.25 +Res-1.4252, 13250853676.3636, 0.25 +Res-1.4253, 13250853676.3636, 0.25 +Res-1.4254, 13250853676.3636, 0.25 +Res-1.4255, 13250853676.3636, 0.25 +Res-1.4256, 13250853676.3636, 0.25 +Res-1.4257, 13250853676.3636, 0.25 +Res-1.4258, 13250853676.3636, 0.25 +Res-1.4259, 13250853676.3636, 0.25 +Res-1.4260, 13250853676.3636, 0.25 +Res-1.4261, 13250853676.3636, 0.25 +Res-1.4262, 13250853676.3636, 0.25 +Res-1.4263, 13250853676.3636, 0.25 +Res-1.4264, 13250853676.3636, 0.25 +Res-1.4265, 13250853676.3636, 0.25 +Res-1.4266, 13250853676.3636, 0.25 +Res-1.4267, 13250853676.3636, 0.25 +Res-1.4268, 13250853676.3636, 0.25 +Res-1.4269, 13250853676.3636, 0.25 +Res-1.4270, 13250853676.3636, 0.25 +Res-1.4271, 13250853676.3636, 0.25 +Res-1.4272, 13250853676.3636, 0.25 +Res-1.4273, 13250853676.3636, 0.25 +Res-1.4274, 13250853676.3636, 0.25 +Res-1.4275, 13250853676.3636, 0.25 +Res-1.4276, 13250853676.3636, 0.25 +Res-1.4277, 13250853676.3636, 0.25 +Res-1.4278, 13250853676.3636, 0.25 +Res-1.4279, 13250853676.3636, 0.25 +Res-1.4280, 13250853676.3636, 0.25 +Res-1.4281, 13250853676.3636, 0.25 +Res-1.4282, 13250853676.3636, 0.25 +Res-1.4283, 13250853676.3636, 0.25 +Res-1.4284, 13250853676.3636, 0.25 +Res-1.4285, 13250853676.3636, 0.25 +Res-1.4286, 13250853676.3636, 0.25 +Res-1.4287, 13250853676.3636, 0.25 +Res-1.4288, 13250853676.3636, 0.25 +Res-1.4289, 13250853676.3636, 0.25 +Res-1.4290, 13250853676.3636, 0.25 +Res-1.4291, 13250853676.3636, 0.25 +Res-1.4292, 13250853676.3636, 0.25 +Res-1.4293, 13250853676.3636, 0.25 +Res-1.4294, 13250853676.3636, 0.25 +Res-1.4295, 13250853676.3636, 0.25 +Res-1.4296, 13250853676.3636, 0.25 +Res-1.4297, 13250853676.3636, 0.25 +Res-1.4298, 13250853676.3636, 0.25 +Res-1.4299, 13250853676.3636, 0.25 +Res-1.4300, 13250853676.3636, 0.25 +Res-1.4301, 13250853676.3636, 0.25 +Res-1.4302, 13250853676.3636, 0.25 +Res-1.4303, 13250853676.3636, 0.25 +Res-1.4304, 13250853676.3636, 0.25 +Res-1.4305, 13250853676.3636, 0.25 +Res-1.4306, 13250853676.3636, 0.25 +Res-1.4307, 13250853676.3636, 0.25 +Res-1.4308, 13250853676.3636, 0.25 +Res-1.4309, 13250853676.3636, 0.25 +Res-1.4310, 13250853676.3636, 0.25 +Res-1.4311, 13250853676.3636, 0.25 +Res-1.4312, 13250853676.3636, 0.25 +Res-1.4313, 13250853676.3636, 0.25 +Res-1.4314, 13250853676.3636, 0.25 +Res-1.4315, 13250853676.3636, 0.25 +Res-1.4316, 13250853676.3636, 0.25 +Res-1.4317, 13250853676.3636, 0.25 +Res-1.4318, 13250853676.3636, 0.25 +Res-1.4319, 13250853676.3636, 0.25 +Res-1.4320, 13250853676.3636, 0.25 \ No newline at end of file diff --git a/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp b/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp new file mode 100644 index 0000000000..9d59069643 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp @@ -0,0 +1,4326 @@ +** ELASTIC SETTING FOR EACH ELEMENT +*Distribution Table, name=RSV_Res-1_Elastic_Table +MODULUS, RATIO +*Distribution, name=RSV_Res-1_ELASTICS, location=ELEMENT, Table=RSV_Res-1_Elastic_Table +** Description: Element-by-Element Elastic properties +, 2. +Res-1.210, 11198814808.2538, 0.19041 +Res-1.209, 11207002032.1436, 0.19063 +Res-1.208, 11222989223.0933, 0.19104 +Res-1.207, 11202549454.349, 0.19051 +Res-1.206, 11201018277.2135, 0.19047 +Res-1.205, 11199452457.2289, 0.19043 +Res-1.204, 11211165066.8084, 0.19073 +Res-1.203, 11211396173.5037, 0.19074 +Res-1.202, 11222952734.6236, 0.19104 +Res-1.201, 11212868930.9558, 0.19078, 1234 +Res-1.200, 11211827541.4726, 0.19075 +Res-1.199, 11223293389.2923, 0.19105 +Res-1.198, 11213461278.5775, 0.19079 +Res-1.197, 11212227164.9418, 0.19076 +Res-1.196, 11222290540.4229, 0.19102 +Res-1.195, 11209591214.3024, 0.19069 +Res-1.194, 11227448401.9317, 0.19116 +Res-1.193, 11218701110.7378, 0.19093 +Res-1.192, 11212290325.2544, 0.19076 +Res-1.191, 11218462357.8173, 0.19092 +Res-1.190, 11210219341.6298, 0.19071 +Res-1.189, 11217410056.2303, 0.1909 +Res-1.188, 11224201059.3023, 0.19107 +Res-1.187, 11200886151.7449, 0.19047 +Res-1.186, 11209070545.6809, 0.19068 +Res-1.185, 11208525302.8397, 0.19067 +Res-1.184, 11208029443.911, 0.19065 +Res-1.183, 11205956268.7052, 0.1906 +Res-1.182, 11203032646.1219, 0.19052 +Res-1.181, 11212779732.2076, 0.19078 +Res-1.180, 11223694446.8691, 0.19106 +Res-1.179, 11216849610.9899, 0.19088 +Res-1.178, 11203666189.6647, 0.19054 +Res-1.177, 11223110950.263, 0.19104 +Res-1.176, 11218366316.8438, 0.19092 +Res-1.175, 11199308629.4248, 0.19043 +Res-1.174, 11204107404.8935, 0.19055 +Res-1.173, 11221591221.1029, 0.191 +Res-1.172, 11198310779.2562, 0.1904 +Res-1.171, 11226329567.8196, 0.19113 +Res-1.170, 11215508691.1034, 0.19085 +Res-1.169, 11216141613.3394, 0.19086 +Res-1.168, 11216262209.1321, 0.19087 +Res-1.167, 11224888572.4446, 0.19109 +Res-1.166, 11215543405.3856, 0.19085 +Res-1.165, 11209879234.5934, 0.1907 +Res-1.164, 11198661683.8392, 0.19041 +Res-1.163, 11221659419.8899, 0.19101 +Res-1.162, 11217644939.1724, 0.1909 +Res-1.161, 11220272938.4351, 0.19097 +Res-1.160, 11219517563.9646, 0.19095 +Res-1.159, 11222601901.6144, 0.19103 +Res-1.158, 11227551848.7474, 0.19116 +Res-1.157, 11214792538.2525, 0.19083 +Res-1.156, 11220949297.0432, 0.19099 +Res-1.155, 11202237002.5308, 0.1905 +Res-1.154, 11212422032.9539, 0.19077 +Res-1.153, 11200876863.9619, 0.19047 +Res-1.152, 11199085093.8181, 0.19042 +Res-1.151, 11210721102.6531, 0.19072 +Res-1.150, 11224677747.0098, 0.19108 +Res-1.149, 11200505347.0814, 0.19046 +Res-1.148, 11210477709.1165, 0.19072 +Res-1.147, 11201790929.0597, 0.19049 +Res-1.146, 11215538617.2144, 0.19085 +Res-1.145, 11210067552.0255, 0.19071 +Res-1.144, 11226119663.3263, 0.19112 +Res-1.143, 11200558079.1704, 0.19046 +Res-1.142, 11209025034.8169, 0.19068 +Res-1.141, 11225111056.7698, 0.1911 +Res-1.140, 11207283822.5306, 0.19063 +Res-1.139, 11216396568.854, 0.19087 +Res-1.138, 11225696853.721, 0.19111 +Res-1.137, 11221821540.0987, 0.19101 +Res-1.136, 11220794943.2728, 0.19098 +Res-1.135, 11221457514.5243, 0.191 +Res-1.134, 11207200873.1928, 0.19063 +Res-1.133, 11205669058.0237, 0.19059 +Res-1.132, 11211863163.8498, 0.19075 +Res-1.131, 11211677567.1763, 0.19075 +Res-1.130, 11209369356.3868, 0.19069 +Res-1.129, 11198739894.387, 0.19041 +Res-1.128, 11209258875.0902, 0.19068 +Res-1.127, 11210271135.3011, 0.19071 +Res-1.126, 11201024868.4708, 0.19047 +Res-1.125, 11211157882.0769, 0.19073 +Res-1.124, 11218203554.1602, 0.19092 +Res-1.123, 11199588193.2274, 0.19043 +Res-1.122, 11215076550.207, 0.19084 +Res-1.121, 11210238801.7044, 0.19071 +Res-1.120, 11206683700.3163, 0.19062 +Res-1.119, 11207926137.5337, 0.19065 +Res-1.118, 11221872987.408, 0.19101 +Res-1.117, 11225794932.4499, 0.19111 +Res-1.116, 11220026437.0079, 0.19096 +Res-1.115, 11202273250.9302, 0.1905 +Res-1.114, 11211501846.5387, 0.19074 +Res-1.113, 11214337327.7756, 0.19082 +Res-1.112, 11215364146.9954, 0.19084 +Res-1.111, 11205074849.7447, 0.19058 +Res-1.110, 11208670822.9857, 0.19067 +Res-1.109, 11208556443.0933, 0.19067 +Res-1.108, 11223420197.8288, 0.19105 +Res-1.107, 11215302199.0174, 0.19084 +Res-1.106, 11213126346.6531, 0.19078 +Res-1.105, 11217009099.524, 0.19089 +Res-1.104, 11213865938.8012, 0.1908 +Res-1.103, 11217994113.817, 0.19091 +Res-1.102, 11204980205.137, 0.19057 +Res-1.101, 11216751463.2051, 0.19088 +Res-1.100, 11206944834.8203, 0.19062 +Res-1.99, 11213849177.9825, 0.1908 +Res-1.98, 11206416870.416, 0.19061 +Res-1.97, 11200174867.7047, 0.19045 +Res-1.96, 11212761772.6524, 0.19078 +Res-1.95, 11201207924.2968, 0.19048 +Res-1.94, 11221710568.74, 0.19101 +Res-1.93, 11202102792.6819, 0.1905 +Res-1.92, 11225762937.338, 0.19111 +Res-1.91, 11214313983.2092, 0.19082 +Res-1.90, 11227579653.6727, 0.19116 +Res-1.89, 11204048097.8306, 0.19055 +Res-1.88, 11222876467.402, 0.19104 +Res-1.87, 11223289800.353, 0.19105 +Res-1.86, 11222804686.0695, 0.19104 +Res-1.85, 11207547340.3029, 0.19064 +Res-1.84, 11221843076.207, 0.19101 +Res-1.83, 11219320112.1476, 0.19095 +Res-1.82, 11205244070.1516, 0.19058 +Res-1.81, 11213243977.9053, 0.19079 +Res-1.80, 11201016479.5973, 0.19047 +Res-1.79, 11226505681.5926, 0.19113 +Res-1.78, 11215171119.692, 0.19084 +Res-1.77, 11211115372.3329, 0.19073 +Res-1.76, 11211330613.8706, 0.19074 +Res-1.75, 11203582318.1003, 0.19054 +Res-1.74, 11224464824.7228, 0.19108 +Res-1.73, 11219259679.3117, 0.19094 +Res-1.72, 11228171914.0288, 0.19117 +Res-1.71, 11199769172.3056, 0.19044 +Res-1.70, 11205305168.6479, 0.19058 +Res-1.69, 11205754113.792, 0.19059 +Res-1.68, 11224082931.2902, 0.19107 +Res-1.67, 11217787662.1013, 0.19091 +Res-1.66, 11223709998.4367, 0.19106 +Res-1.65, 11213376573.6608, 0.19079 +Res-1.64, 11204036715.6354, 0.19055 +Res-1.63, 11209300792.2263, 0.19069 +Res-1.62, 11207638372.4461, 0.19064 +Res-1.61, 11209100486.9499, 0.19068 +Res-1.60, 11206412378.2822, 0.19061 +Res-1.59, 11202503021.4388, 0.19051 +Res-1.58, 11209477740.8993, 0.19069 +Res-1.57, 11222835193.1853, 0.19104 +Res-1.56, 11211083938.9801, 0.19073 +Res-1.55, 11223344531.5666, 0.19105 +Res-1.54, 11201118643.7157, 0.19047 +Res-1.53, 11225922912.0918, 0.19112 +Res-1.52, 11218110503.2337, 0.19091 +Res-1.51, 11210865400.1882, 0.19073 +Res-1.50, 11214019778.1402, 0.19081 +Res-1.49, 11204136459.2628, 0.19055 +Res-1.48, 11212356777.9461, 0.19076 +Res-1.47, 11221437772.4942, 0.191 +Res-1.46, 11207006823.5308, 0.19063 +Res-1.45, 11223791045.7213, 0.19106 +Res-1.44, 11208544765.5071, 0.19067 +Res-1.43, 11209267557.9369, 0.19068 +Res-1.42, 11221377947.9732, 0.191 +Res-1.41, 11222786142.4926, 0.19104 +Res-1.40, 11223261088.8025, 0.19105 +Res-1.39, 11223761737.1688, 0.19106 +Res-1.38, 11222172394.6506, 0.19102 +Res-1.37, 11199653513.7877, 0.19044 +Res-1.36, 11227759636.7716, 0.19116 +Res-1.35, 11199577106.677, 0.19043 +Res-1.34, 11227466938.7063, 0.19116 +Res-1.33, 11199169594.335, 0.19042 +Res-1.32, 11219335070.7259, 0.19095 +Res-1.31, 11212527697.4628, 0.19077 +Res-1.30, 11202428428.8604, 0.19051 +Res-1.29, 11201408054.3293, 0.19048 +Res-1.28, 11222583357.7417, 0.19103 +Res-1.27, 11208466914.6587, 0.19066 +Res-1.26, 11200064606.1293, 0.19045 +Res-1.25, 11199032055.973, 0.19042 +Res-1.24, 11225007889.1195, 0.19109 +Res-1.23, 11222886038.2157, 0.19104 +Res-1.22, 11205896670.776, 0.1906 +Res-1.21, 11226756542.3277, 0.19114 +Res-1.20, 11226104114.7074, 0.19112 +Res-1.19, 11213604048.4849, 0.1908 +Res-1.18, 11202801387.3778, 0.19052 +Res-1.17, 11198392587.9363, 0.1904 +Res-1.16, 11228104049.1491, 0.19117 +Res-1.15, 11212003257.6089, 0.19076 +Res-1.14, 11202458086.203, 0.19051 +Res-1.13, 11201026366.4833, 0.19047 +Res-1.12, 11202937387.2003, 0.19052 +Res-1.11, 11201932931.3114, 0.19049 +Res-1.10, 11205907751.8191, 0.1906 +Res-1.9, 11224722304.7336, 0.19109 +Res-1.8, 11213008714.3126, 0.19078 +Res-1.7, 11223186617.916, 0.19105 +Res-1.6, 11203363650.3495, 0.19053 +Res-1.5, 11200461004.0192, 0.19046 +Res-1.4, 11223167476.7341, 0.19105 +Res-1.3, 11201787633.63, 0.19049 +Res-1.2, 11216634163.6389, 0.19088 +Res-1.1, 11216793056.4137, 0.19088 +Res-1.211, 10072000000, 0.25 +Res-1.212, 10072000000, 0.25 +Res-1.213, 10072000000, 0.25 +Res-1.214, 10072000000, 0.25 +Res-1.215, 10072000000, 0.25 +Res-1.216, 10072000000, 0.25 +Res-1.217, 10216000000, 0.25 +Res-1.218, 10216000000, 0.25 +Res-1.219, 10216000000, 0.25 +Res-1.220, 10216000000, 0.25 +Res-1.221, 10216000000, 0.25 +Res-1.222, 10216000000, 0.25 +Res-1.223, 10360000000, 0.25 +Res-1.224, 10360000000, 0.25 +Res-1.225, 10360000000, 0.25 +Res-1.226, 10360000000, 0.25 +Res-1.227, 10360000000, 0.25 +Res-1.228, 10360000000, 0.25 +Res-1.229, 10504000000, 0.25 +Res-1.230, 10504000000, 0.25 +Res-1.231, 10504000000, 0.25 +Res-1.232, 10504000000, 0.25 +Res-1.233, 10504000000, 0.25 +Res-1.234, 10504000000, 0.25 +Res-1.235, 10648000000, 0.25 +Res-1.236, 10648000000, 0.25 +Res-1.237, 10648000000, 0.25 +Res-1.238, 10648000000, 0.25 +Res-1.239, 10648000000, 0.25 +Res-1.240, 10648000000, 0.25 +Res-1.241, 10072000000, 0.25 +Res-1.242, 10072000000, 0.25 +Res-1.243, 10072000000, 0.25 +Res-1.244, 10072000000, 0.25 +Res-1.245, 10072000000, 0.25 +Res-1.246, 10072000000, 0.25 +Res-1.247, 10072000000, 0.25 +Res-1.248, 10216000000, 0.25 +Res-1.249, 10216000000, 0.25 +Res-1.250, 10216000000, 0.25 +Res-1.251, 10216000000, 0.25 +Res-1.252, 10216000000, 0.25 +Res-1.253, 10216000000, 0.25 +Res-1.254, 10216000000, 0.25 +Res-1.255, 10360000000, 0.25 +Res-1.256, 10360000000, 0.25 +Res-1.257, 10360000000, 0.25 +Res-1.258, 10360000000, 0.25 +Res-1.259, 10360000000, 0.25 +Res-1.260, 10360000000, 0.25 +Res-1.261, 10360000000, 0.25 +Res-1.262, 10504000000, 0.25 +Res-1.263, 10504000000, 0.25 +Res-1.264, 10504000000, 0.25 +Res-1.265, 10504000000, 0.25 +Res-1.266, 10504000000, 0.25 +Res-1.267, 10504000000, 0.25 +Res-1.268, 10504000000, 0.25 +Res-1.269, 10648000000, 0.25 +Res-1.270, 10648000000, 0.25 +Res-1.271, 10648000000, 0.25 +Res-1.272, 10648000000, 0.25 +Res-1.273, 10648000000, 0.25 +Res-1.274, 10648000000, 0.25 +Res-1.275, 10648000000, 0.25 +Res-1.276, 10072000000, 0.25 +Res-1.277, 10216000000, 0.25 +Res-1.278, 10360000000, 0.25 +Res-1.279, 10504000000, 0.25 +Res-1.280, 10648000000, 0.25 +Res-1.281, 10072000000, 0.25 +Res-1.282, 10072000000, 0.25 +Res-1.283, 10072000000, 0.25 +Res-1.284, 10072000000, 0.25 +Res-1.285, 10072000000, 0.25 +Res-1.286, 10072000000, 0.25 +Res-1.287, 10072000000, 0.25 +Res-1.288, 10216000000, 0.25 +Res-1.289, 10216000000, 0.25 +Res-1.290, 10216000000, 0.25 +Res-1.291, 10216000000, 0.25 +Res-1.292, 10216000000, 0.25 +Res-1.293, 10216000000, 0.25 +Res-1.294, 10216000000, 0.25 +Res-1.295, 10360000000, 0.25 +Res-1.296, 10360000000, 0.25 +Res-1.297, 10360000000, 0.25 +Res-1.298, 10360000000, 0.25 +Res-1.299, 10360000000, 0.25 +Res-1.300, 10360000000, 0.25 +Res-1.301, 10360000000, 0.25 +Res-1.302, 10504000000, 0.25 +Res-1.303, 10504000000, 0.25 +Res-1.304, 10504000000, 0.25 +Res-1.305, 10504000000, 0.25 +Res-1.306, 10504000000, 0.25 +Res-1.307, 10504000000, 0.25 +Res-1.308, 10504000000, 0.25 +Res-1.309, 10648000000, 0.25 +Res-1.310, 10648000000, 0.25 +Res-1.311, 10648000000, 0.25 +Res-1.312, 10648000000, 0.25 +Res-1.313, 10648000000, 0.25 +Res-1.314, 10648000000, 0.25 +Res-1.315, 10648000000, 0.25 +Res-1.316, 10072000000, 0.25 +Res-1.317, 10216000000, 0.25 +Res-1.318, 10360000000, 0.25 +Res-1.319, 10504000000, 0.25 +Res-1.320, 10648000000, 0.25 +Res-1.321, 10072000000, 0.25 +Res-1.322, 10072000000, 0.25 +Res-1.323, 10072000000, 0.25 +Res-1.324, 10072000000, 0.25 +Res-1.325, 10072000000, 0.25 +Res-1.326, 10072000000, 0.25 +Res-1.327, 10072000000, 0.25 +Res-1.328, 10216000000, 0.25 +Res-1.329, 10216000000, 0.25 +Res-1.330, 10216000000, 0.25 +Res-1.331, 10216000000, 0.25 +Res-1.332, 10216000000, 0.25 +Res-1.333, 10216000000, 0.25 +Res-1.334, 10216000000, 0.25 +Res-1.335, 10360000000, 0.25 +Res-1.336, 10360000000, 0.25 +Res-1.337, 10360000000, 0.25 +Res-1.338, 10360000000, 0.25 +Res-1.339, 10360000000, 0.25 +Res-1.340, 10360000000, 0.25 +Res-1.341, 10360000000, 0.25 +Res-1.342, 10504000000, 0.25 +Res-1.343, 10504000000, 0.25 +Res-1.344, 10504000000, 0.25 +Res-1.345, 10504000000, 0.25 +Res-1.346, 10504000000, 0.25 +Res-1.347, 10504000000, 0.25 +Res-1.348, 10504000000, 0.25 +Res-1.349, 10648000000, 0.25 +Res-1.350, 10648000000, 0.25 +Res-1.351, 10648000000, 0.25 +Res-1.352, 10648000000, 0.25 +Res-1.353, 10648000000, 0.25 +Res-1.354, 10648000000, 0.25 +Res-1.355, 10648000000, 0.25 +Res-1.356, 10072000000, 0.25 +Res-1.357, 10216000000, 0.25 +Res-1.358, 10360000000, 0.25 +Res-1.359, 10504000000, 0.25 +Res-1.360, 10648000000, 0.25 +Res-1.361, 10072000000, 0.25 +Res-1.362, 10072000000, 0.25 +Res-1.363, 10072000000, 0.25 +Res-1.364, 10072000000, 0.25 +Res-1.365, 10072000000, 0.25 +Res-1.366, 10072000000, 0.25 +Res-1.367, 10072000000, 0.25 +Res-1.368, 10216000000, 0.25 +Res-1.369, 10216000000, 0.25 +Res-1.370, 10216000000, 0.25 +Res-1.371, 10216000000, 0.25 +Res-1.372, 10216000000, 0.25 +Res-1.373, 10216000000, 0.25 +Res-1.374, 10216000000, 0.25 +Res-1.375, 10360000000, 0.25 +Res-1.376, 10360000000, 0.25 +Res-1.377, 10360000000, 0.25 +Res-1.378, 10360000000, 0.25 +Res-1.379, 10360000000, 0.25 +Res-1.380, 10360000000, 0.25 +Res-1.381, 10360000000, 0.25 +Res-1.382, 10504000000, 0.25 +Res-1.383, 10504000000, 0.25 +Res-1.384, 10504000000, 0.25 +Res-1.385, 10504000000, 0.25 +Res-1.386, 10504000000, 0.25 +Res-1.387, 10504000000, 0.25 +Res-1.388, 10504000000, 0.25 +Res-1.389, 10648000000, 0.25 +Res-1.390, 10648000000, 0.25 +Res-1.391, 10648000000, 0.25 +Res-1.392, 10648000000, 0.25 +Res-1.393, 10648000000, 0.25 +Res-1.394, 10648000000, 0.25 +Res-1.395, 10648000000, 0.25 +Res-1.396, 10072000000, 0.25 +Res-1.397, 10216000000, 0.25 +Res-1.398, 10360000000, 0.25 +Res-1.399, 10504000000, 0.25 +Res-1.400, 10648000000, 0.25 +Res-1.401, 10072000000, 0.25 +Res-1.402, 10072000000, 0.25 +Res-1.403, 10072000000, 0.25 +Res-1.404, 10072000000, 0.25 +Res-1.405, 10072000000, 0.25 +Res-1.406, 10072000000, 0.25 +Res-1.407, 10072000000, 0.25 +Res-1.408, 10216000000, 0.25 +Res-1.409, 10216000000, 0.25 +Res-1.410, 10216000000, 0.25 +Res-1.411, 10216000000, 0.25 +Res-1.412, 10216000000, 0.25 +Res-1.413, 10216000000, 0.25 +Res-1.414, 10216000000, 0.25 +Res-1.415, 10360000000, 0.25 +Res-1.416, 10360000000, 0.25 +Res-1.417, 10360000000, 0.25 +Res-1.418, 10360000000, 0.25 +Res-1.419, 10360000000, 0.25 +Res-1.420, 10360000000, 0.25 +Res-1.421, 10360000000, 0.25 +Res-1.422, 10504000000, 0.25 +Res-1.423, 10504000000, 0.25 +Res-1.424, 10504000000, 0.25 +Res-1.425, 10504000000, 0.25 +Res-1.426, 10504000000, 0.25 +Res-1.427, 10504000000, 0.25 +Res-1.428, 10504000000, 0.25 +Res-1.429, 10648000000, 0.25 +Res-1.430, 10648000000, 0.25 +Res-1.431, 10648000000, 0.25 +Res-1.432, 10648000000, 0.25 +Res-1.433, 10648000000, 0.25 +Res-1.434, 10648000000, 0.25 +Res-1.435, 10648000000, 0.25 +Res-1.436, 10072000000, 0.25 +Res-1.437, 10216000000, 0.25 +Res-1.438, 10360000000, 0.25 +Res-1.439, 10504000000, 0.25 +Res-1.440, 10648000000, 0.25 +Res-1.441, 10072000000, 0.25 +Res-1.442, 10072000000, 0.25 +Res-1.443, 10072000000, 0.25 +Res-1.444, 10072000000, 0.25 +Res-1.445, 10072000000, 0.25 +Res-1.446, 10072000000, 0.25 +Res-1.447, 10072000000, 0.25 +Res-1.448, 10216000000, 0.25 +Res-1.449, 10216000000, 0.25 +Res-1.450, 10216000000, 0.25 +Res-1.451, 10216000000, 0.25 +Res-1.452, 10216000000, 0.25 +Res-1.453, 10216000000, 0.25 +Res-1.454, 10216000000, 0.25 +Res-1.455, 10360000000, 0.25 +Res-1.456, 10360000000, 0.25 +Res-1.457, 10360000000, 0.25 +Res-1.458, 10360000000, 0.25 +Res-1.459, 10360000000, 0.25 +Res-1.460, 10360000000, 0.25 +Res-1.461, 10360000000, 0.25 +Res-1.462, 10504000000, 0.25 +Res-1.463, 10504000000, 0.25 +Res-1.464, 10504000000, 0.25 +Res-1.465, 10504000000, 0.25 +Res-1.466, 10504000000, 0.25 +Res-1.467, 10504000000, 0.25 +Res-1.468, 10504000000, 0.25 +Res-1.469, 10648000000, 0.25 +Res-1.470, 10648000000, 0.25 +Res-1.471, 10648000000, 0.25 +Res-1.472, 10648000000, 0.25 +Res-1.473, 10648000000, 0.25 +Res-1.474, 10648000000, 0.25 +Res-1.475, 10648000000, 0.25 +Res-1.476, 10072000000, 0.25 +Res-1.477, 10216000000, 0.25 +Res-1.478, 10360000000, 0.25 +Res-1.479, 10504000000, 0.25 +Res-1.480, 10648000000, 0.25 +Res-1.481, 10072000000, 0.25 +Res-1.482, 10072000000, 0.25 +Res-1.483, 10072000000, 0.25 +Res-1.484, 10072000000, 0.25 +Res-1.485, 10072000000, 0.25 +Res-1.486, 10072000000, 0.25 +Res-1.487, 10072000000, 0.25 +Res-1.488, 10216000000, 0.25 +Res-1.489, 10216000000, 0.25 +Res-1.490, 10216000000, 0.25 +Res-1.491, 10216000000, 0.25 +Res-1.492, 10216000000, 0.25 +Res-1.493, 10216000000, 0.25 +Res-1.494, 10216000000, 0.25 +Res-1.495, 10360000000, 0.25 +Res-1.496, 10360000000, 0.25 +Res-1.497, 10360000000, 0.25 +Res-1.498, 10360000000, 0.25 +Res-1.499, 10360000000, 0.25 +Res-1.500, 10360000000, 0.25 +Res-1.501, 10360000000, 0.25 +Res-1.502, 10504000000, 0.25 +Res-1.503, 10504000000, 0.25 +Res-1.504, 10504000000, 0.25 +Res-1.505, 10504000000, 0.25 +Res-1.506, 10504000000, 0.25 +Res-1.507, 10504000000, 0.25 +Res-1.508, 10504000000, 0.25 +Res-1.509, 10648000000, 0.25 +Res-1.510, 10648000000, 0.25 +Res-1.511, 10648000000, 0.25 +Res-1.512, 10648000000, 0.25 +Res-1.513, 10648000000, 0.25 +Res-1.514, 10648000000, 0.25 +Res-1.515, 10648000000, 0.25 +Res-1.516, 10072000000, 0.25 +Res-1.517, 10216000000, 0.25 +Res-1.518, 10360000000, 0.25 +Res-1.519, 10504000000, 0.25 +Res-1.520, 10648000000, 0.25 +Res-1.521, 10072000000, 0.25 +Res-1.522, 10072000000, 0.25 +Res-1.523, 10072000000, 0.25 +Res-1.524, 10072000000, 0.25 +Res-1.525, 10072000000, 0.25 +Res-1.526, 10072000000, 0.25 +Res-1.527, 10072000000, 0.25 +Res-1.528, 10216000000, 0.25 +Res-1.529, 10216000000, 0.25 +Res-1.530, 10216000000, 0.25 +Res-1.531, 10216000000, 0.25 +Res-1.532, 10216000000, 0.25 +Res-1.533, 10216000000, 0.25 +Res-1.534, 10216000000, 0.25 +Res-1.535, 10360000000, 0.25 +Res-1.536, 10360000000, 0.25 +Res-1.537, 10360000000, 0.25 +Res-1.538, 10360000000, 0.25 +Res-1.539, 10360000000, 0.25 +Res-1.540, 10360000000, 0.25 +Res-1.541, 10360000000, 0.25 +Res-1.542, 10504000000, 0.25 +Res-1.543, 10504000000, 0.25 +Res-1.544, 10504000000, 0.25 +Res-1.545, 10504000000, 0.25 +Res-1.546, 10504000000, 0.25 +Res-1.547, 10504000000, 0.25 +Res-1.548, 10504000000, 0.25 +Res-1.549, 10648000000, 0.25 +Res-1.550, 10648000000, 0.25 +Res-1.551, 10648000000, 0.25 +Res-1.552, 10648000000, 0.25 +Res-1.553, 10648000000, 0.25 +Res-1.554, 10648000000, 0.25 +Res-1.555, 10648000000, 0.25 +Res-1.556, 10072000000, 0.25 +Res-1.557, 10216000000, 0.25 +Res-1.558, 10360000000, 0.25 +Res-1.559, 10504000000, 0.25 +Res-1.560, 10648000000, 0.25 +Res-1.561, 10072000000, 0.25 +Res-1.562, 10072000000, 0.25 +Res-1.563, 10072000000, 0.25 +Res-1.564, 10072000000, 0.25 +Res-1.565, 10072000000, 0.25 +Res-1.566, 10072000000, 0.25 +Res-1.567, 10072000000, 0.25 +Res-1.568, 10216000000, 0.25 +Res-1.569, 10216000000, 0.25 +Res-1.570, 10216000000, 0.25 +Res-1.571, 10216000000, 0.25 +Res-1.572, 10216000000, 0.25 +Res-1.573, 10216000000, 0.25 +Res-1.574, 10216000000, 0.25 +Res-1.575, 10360000000, 0.25 +Res-1.576, 10360000000, 0.25 +Res-1.577, 10360000000, 0.25 +Res-1.578, 10360000000, 0.25 +Res-1.579, 10360000000, 0.25 +Res-1.580, 10360000000, 0.25 +Res-1.581, 10360000000, 0.25 +Res-1.582, 10504000000, 0.25 +Res-1.583, 10504000000, 0.25 +Res-1.584, 10504000000, 0.25 +Res-1.585, 10504000000, 0.25 +Res-1.586, 10504000000, 0.25 +Res-1.587, 10504000000, 0.25 +Res-1.588, 10504000000, 0.25 +Res-1.589, 10648000000, 0.25 +Res-1.590, 10648000000, 0.25 +Res-1.591, 10648000000, 0.25 +Res-1.592, 10648000000, 0.25 +Res-1.593, 10648000000, 0.25 +Res-1.594, 10648000000, 0.25 +Res-1.595, 10648000000, 0.25 +Res-1.596, 10072000000, 0.25 +Res-1.597, 10216000000, 0.25 +Res-1.598, 10360000000, 0.25 +Res-1.599, 10504000000, 0.25 +Res-1.600, 10648000000, 0.25 +Res-1.601, 10072000000, 0.25 +Res-1.602, 10072000000, 0.25 +Res-1.603, 10072000000, 0.25 +Res-1.604, 10072000000, 0.25 +Res-1.605, 10072000000, 0.25 +Res-1.606, 10072000000, 0.25 +Res-1.607, 10072000000, 0.25 +Res-1.608, 10216000000, 0.25 +Res-1.609, 10216000000, 0.25 +Res-1.610, 10216000000, 0.25 +Res-1.611, 10216000000, 0.25 +Res-1.612, 10216000000, 0.25 +Res-1.613, 10216000000, 0.25 +Res-1.614, 10216000000, 0.25 +Res-1.615, 10360000000, 0.25 +Res-1.616, 10360000000, 0.25 +Res-1.617, 10360000000, 0.25 +Res-1.618, 10360000000, 0.25 +Res-1.619, 10360000000, 0.25 +Res-1.620, 10360000000, 0.25 +Res-1.621, 10360000000, 0.25 +Res-1.622, 10504000000, 0.25 +Res-1.623, 10504000000, 0.25 +Res-1.624, 10504000000, 0.25 +Res-1.625, 10504000000, 0.25 +Res-1.626, 10504000000, 0.25 +Res-1.627, 10504000000, 0.25 +Res-1.628, 10504000000, 0.25 +Res-1.629, 10648000000, 0.25 +Res-1.630, 10648000000, 0.25 +Res-1.631, 10648000000, 0.25 +Res-1.632, 10648000000, 0.25 +Res-1.633, 10648000000, 0.25 +Res-1.634, 10648000000, 0.25 +Res-1.635, 10648000000, 0.25 +Res-1.636, 10072000000, 0.25 +Res-1.637, 10216000000, 0.25 +Res-1.638, 10360000000, 0.25 +Res-1.639, 10504000000, 0.25 +Res-1.640, 10648000000, 0.25 +Res-1.641, 10072000000, 0.25 +Res-1.642, 10072000000, 0.25 +Res-1.643, 10072000000, 0.25 +Res-1.644, 10072000000, 0.25 +Res-1.645, 10072000000, 0.25 +Res-1.646, 10072000000, 0.25 +Res-1.647, 10216000000, 0.25 +Res-1.648, 10216000000, 0.25 +Res-1.649, 10216000000, 0.25 +Res-1.650, 10216000000, 0.25 +Res-1.651, 10216000000, 0.25 +Res-1.652, 10216000000, 0.25 +Res-1.653, 10360000000, 0.25 +Res-1.654, 10360000000, 0.25 +Res-1.655, 10360000000, 0.25 +Res-1.656, 10360000000, 0.25 +Res-1.657, 10360000000, 0.25 +Res-1.658, 10360000000, 0.25 +Res-1.659, 10504000000, 0.25 +Res-1.660, 10504000000, 0.25 +Res-1.661, 10504000000, 0.25 +Res-1.662, 10504000000, 0.25 +Res-1.663, 10504000000, 0.25 +Res-1.664, 10504000000, 0.25 +Res-1.665, 10648000000, 0.25 +Res-1.666, 10648000000, 0.25 +Res-1.667, 10648000000, 0.25 +Res-1.668, 10648000000, 0.25 +Res-1.669, 10648000000, 0.25 +Res-1.670, 10648000000, 0.25 +Res-1.671, 10072000000, 0.25 +Res-1.672, 10216000000, 0.25 +Res-1.673, 10360000000, 0.25 +Res-1.674, 10504000000, 0.25 +Res-1.675, 10648000000, 0.25 +Res-1.676, 10072000000, 0.25 +Res-1.677, 10216000000, 0.25 +Res-1.678, 10360000000, 0.25 +Res-1.679, 10504000000, 0.25 +Res-1.680, 10648000000, 0.25 +Res-1.681, 10072000000, 0.25 +Res-1.682, 10216000000, 0.25 +Res-1.683, 10360000000, 0.25 +Res-1.684, 10504000000, 0.25 +Res-1.685, 10648000000, 0.25 +Res-1.686, 10072000000, 0.25 +Res-1.687, 10216000000, 0.25 +Res-1.688, 10360000000, 0.25 +Res-1.689, 10504000000, 0.25 +Res-1.690, 10648000000, 0.25 +Res-1.691, 10072000000, 0.25 +Res-1.692, 10216000000, 0.25 +Res-1.693, 10360000000, 0.25 +Res-1.694, 10504000000, 0.25 +Res-1.695, 10648000000, 0.25 +Res-1.696, 10072000000, 0.25 +Res-1.697, 10216000000, 0.25 +Res-1.698, 10360000000, 0.25 +Res-1.699, 10504000000, 0.25 +Res-1.700, 10648000000, 0.25 +Res-1.701, 10072000000, 0.25 +Res-1.702, 10216000000, 0.25 +Res-1.703, 10360000000, 0.25 +Res-1.704, 10504000000, 0.25 +Res-1.705, 10648000000, 0.25 +Res-1.706, 10072000000, 0.25 +Res-1.707, 10216000000, 0.25 +Res-1.708, 10360000000, 0.25 +Res-1.709, 10504000000, 0.25 +Res-1.710, 10648000000, 0.25 +Res-1.711, 10072000000, 0.25 +Res-1.712, 10216000000, 0.25 +Res-1.713, 10360000000, 0.25 +Res-1.714, 10504000000, 0.25 +Res-1.715, 10648000000, 0.25 +Res-1.716, 10072000000, 0.25 +Res-1.717, 10216000000, 0.25 +Res-1.718, 10360000000, 0.25 +Res-1.719, 10504000000, 0.25 +Res-1.720, 10648000000, 0.25 +Res-1.721, 10072000000, 0.25 +Res-1.722, 10072000000, 0.25 +Res-1.723, 10072000000, 0.25 +Res-1.724, 10072000000, 0.25 +Res-1.725, 10072000000, 0.25 +Res-1.726, 10072000000, 0.25 +Res-1.727, 10216000000, 0.25 +Res-1.728, 10216000000, 0.25 +Res-1.729, 10216000000, 0.25 +Res-1.730, 10216000000, 0.25 +Res-1.731, 10216000000, 0.25 +Res-1.732, 10216000000, 0.25 +Res-1.733, 10360000000, 0.25 +Res-1.734, 10360000000, 0.25 +Res-1.735, 10360000000, 0.25 +Res-1.736, 10360000000, 0.25 +Res-1.737, 10360000000, 0.25 +Res-1.738, 10360000000, 0.25 +Res-1.739, 10504000000, 0.25 +Res-1.740, 10504000000, 0.25 +Res-1.741, 10504000000, 0.25 +Res-1.742, 10504000000, 0.25 +Res-1.743, 10504000000, 0.25 +Res-1.744, 10504000000, 0.25 +Res-1.745, 10648000000, 0.25 +Res-1.746, 10648000000, 0.25 +Res-1.747, 10648000000, 0.25 +Res-1.748, 10648000000, 0.25 +Res-1.749, 10648000000, 0.25 +Res-1.750, 10648000000, 0.25 +Res-1.751, 10072000000, 0.25 +Res-1.752, 10216000000, 0.25 +Res-1.753, 10360000000, 0.25 +Res-1.754, 10504000000, 0.25 +Res-1.755, 10648000000, 0.25 +Res-1.756, 10072000000, 0.25 +Res-1.757, 10216000000, 0.25 +Res-1.758, 10360000000, 0.25 +Res-1.759, 10504000000, 0.25 +Res-1.760, 10648000000, 0.25 +Res-1.761, 10072000000, 0.25 +Res-1.762, 10216000000, 0.25 +Res-1.763, 10360000000, 0.25 +Res-1.764, 10504000000, 0.25 +Res-1.765, 10648000000, 0.25 +Res-1.766, 10072000000, 0.25 +Res-1.767, 10216000000, 0.25 +Res-1.768, 10360000000, 0.25 +Res-1.769, 10504000000, 0.25 +Res-1.770, 10648000000, 0.25 +Res-1.771, 10072000000, 0.25 +Res-1.772, 10216000000, 0.25 +Res-1.773, 10360000000, 0.25 +Res-1.774, 10504000000, 0.25 +Res-1.775, 10648000000, 0.25 +Res-1.776, 10072000000, 0.25 +Res-1.777, 10216000000, 0.25 +Res-1.778, 10360000000, 0.25 +Res-1.779, 10504000000, 0.25 +Res-1.780, 10648000000, 0.25 +Res-1.781, 10072000000, 0.25 +Res-1.782, 10216000000, 0.25 +Res-1.783, 10360000000, 0.25 +Res-1.784, 10504000000, 0.25 +Res-1.785, 10648000000, 0.25 +Res-1.786, 10072000000, 0.25 +Res-1.787, 10216000000, 0.25 +Res-1.788, 10360000000, 0.25 +Res-1.789, 10504000000, 0.25 +Res-1.790, 10648000000, 0.25 +Res-1.791, 10072000000, 0.25 +Res-1.792, 10216000000, 0.25 +Res-1.793, 10360000000, 0.25 +Res-1.794, 10504000000, 0.25 +Res-1.795, 10648000000, 0.25 +Res-1.796, 10072000000, 0.25 +Res-1.797, 10216000000, 0.25 +Res-1.798, 10360000000, 0.25 +Res-1.799, 10504000000, 0.25 +Res-1.800, 10648000000, 0.25 +Res-1.801, 10072000000, 0.25 +Res-1.802, 10072000000, 0.25 +Res-1.803, 10072000000, 0.25 +Res-1.804, 10072000000, 0.25 +Res-1.805, 10072000000, 0.25 +Res-1.806, 10072000000, 0.25 +Res-1.807, 10216000000, 0.25 +Res-1.808, 10216000000, 0.25 +Res-1.809, 10216000000, 0.25 +Res-1.810, 10216000000, 0.25 +Res-1.811, 10216000000, 0.25 +Res-1.812, 10216000000, 0.25 +Res-1.813, 10360000000, 0.25 +Res-1.814, 10360000000, 0.25 +Res-1.815, 10360000000, 0.25 +Res-1.816, 10360000000, 0.25 +Res-1.817, 10360000000, 0.25 +Res-1.818, 10360000000, 0.25 +Res-1.819, 10504000000, 0.25 +Res-1.820, 10504000000, 0.25 +Res-1.821, 10504000000, 0.25 +Res-1.822, 10504000000, 0.25 +Res-1.823, 10504000000, 0.25 +Res-1.824, 10504000000, 0.25 +Res-1.825, 10648000000, 0.25 +Res-1.826, 10648000000, 0.25 +Res-1.827, 10648000000, 0.25 +Res-1.828, 10648000000, 0.25 +Res-1.829, 10648000000, 0.25 +Res-1.830, 10648000000, 0.25 +Res-1.831, 10072000000, 0.25 +Res-1.832, 10216000000, 0.25 +Res-1.833, 10360000000, 0.25 +Res-1.834, 10504000000, 0.25 +Res-1.835, 10648000000, 0.25 +Res-1.836, 10072000000, 0.25 +Res-1.837, 10216000000, 0.25 +Res-1.838, 10360000000, 0.25 +Res-1.839, 10504000000, 0.25 +Res-1.840, 10648000000, 0.25 +Res-1.841, 10072000000, 0.25 +Res-1.842, 10216000000, 0.25 +Res-1.843, 10360000000, 0.25 +Res-1.844, 10504000000, 0.25 +Res-1.845, 10648000000, 0.25 +Res-1.846, 10072000000, 0.25 +Res-1.847, 10216000000, 0.25 +Res-1.848, 10360000000, 0.25 +Res-1.849, 10504000000, 0.25 +Res-1.850, 10648000000, 0.25 +Res-1.851, 10072000000, 0.25 +Res-1.852, 10216000000, 0.25 +Res-1.853, 10360000000, 0.25 +Res-1.854, 10504000000, 0.25 +Res-1.855, 10648000000, 0.25 +Res-1.856, 10072000000, 0.25 +Res-1.857, 10216000000, 0.25 +Res-1.858, 10360000000, 0.25 +Res-1.859, 10504000000, 0.25 +Res-1.860, 10648000000, 0.25 +Res-1.861, 10072000000, 0.25 +Res-1.862, 10216000000, 0.25 +Res-1.863, 10360000000, 0.25 +Res-1.864, 10504000000, 0.25 +Res-1.865, 10648000000, 0.25 +Res-1.866, 10072000000, 0.25 +Res-1.867, 10216000000, 0.25 +Res-1.868, 10360000000, 0.25 +Res-1.869, 10504000000, 0.25 +Res-1.870, 10648000000, 0.25 +Res-1.871, 10072000000, 0.25 +Res-1.872, 10216000000, 0.25 +Res-1.873, 10360000000, 0.25 +Res-1.874, 10504000000, 0.25 +Res-1.875, 10648000000, 0.25 +Res-1.876, 10072000000, 0.25 +Res-1.877, 10216000000, 0.25 +Res-1.878, 10360000000, 0.25 +Res-1.879, 10504000000, 0.25 +Res-1.880, 10648000000, 0.25 +Res-1.881, 10072000000, 0.25 +Res-1.882, 10072000000, 0.25 +Res-1.883, 10072000000, 0.25 +Res-1.884, 10072000000, 0.25 +Res-1.885, 10072000000, 0.25 +Res-1.886, 10072000000, 0.25 +Res-1.887, 10216000000, 0.25 +Res-1.888, 10216000000, 0.25 +Res-1.889, 10216000000, 0.25 +Res-1.890, 10216000000, 0.25 +Res-1.891, 10216000000, 0.25 +Res-1.892, 10216000000, 0.25 +Res-1.893, 10360000000, 0.25 +Res-1.894, 10360000000, 0.25 +Res-1.895, 10360000000, 0.25 +Res-1.896, 10360000000, 0.25 +Res-1.897, 10360000000, 0.25 +Res-1.898, 10360000000, 0.25 +Res-1.899, 10504000000, 0.25 +Res-1.900, 10504000000, 0.25 +Res-1.901, 10504000000, 0.25 +Res-1.902, 10504000000, 0.25 +Res-1.903, 10504000000, 0.25 +Res-1.904, 10504000000, 0.25 +Res-1.905, 10648000000, 0.25 +Res-1.906, 10648000000, 0.25 +Res-1.907, 10648000000, 0.25 +Res-1.908, 10648000000, 0.25 +Res-1.909, 10648000000, 0.25 +Res-1.910, 10648000000, 0.25 +Res-1.911, 10072000000, 0.25 +Res-1.912, 10216000000, 0.25 +Res-1.913, 10360000000, 0.25 +Res-1.914, 10504000000, 0.25 +Res-1.915, 10648000000, 0.25 +Res-1.916, 10072000000, 0.25 +Res-1.917, 10216000000, 0.25 +Res-1.918, 10360000000, 0.25 +Res-1.919, 10504000000, 0.25 +Res-1.920, 10648000000, 0.25 +Res-1.921, 10072000000, 0.25 +Res-1.922, 10216000000, 0.25 +Res-1.923, 10360000000, 0.25 +Res-1.924, 10504000000, 0.25 +Res-1.925, 10648000000, 0.25 +Res-1.926, 10072000000, 0.25 +Res-1.927, 10216000000, 0.25 +Res-1.928, 10360000000, 0.25 +Res-1.929, 10504000000, 0.25 +Res-1.930, 10648000000, 0.25 +Res-1.931, 10072000000, 0.25 +Res-1.932, 10216000000, 0.25 +Res-1.933, 10360000000, 0.25 +Res-1.934, 10504000000, 0.25 +Res-1.935, 10648000000, 0.25 +Res-1.936, 10072000000, 0.25 +Res-1.937, 10216000000, 0.25 +Res-1.938, 10360000000, 0.25 +Res-1.939, 10504000000, 0.25 +Res-1.940, 10648000000, 0.25 +Res-1.941, 10072000000, 0.25 +Res-1.942, 10216000000, 0.25 +Res-1.943, 10360000000, 0.25 +Res-1.944, 10504000000, 0.25 +Res-1.945, 10648000000, 0.25 +Res-1.946, 10072000000, 0.25 +Res-1.947, 10216000000, 0.25 +Res-1.948, 10360000000, 0.25 +Res-1.949, 10504000000, 0.25 +Res-1.950, 10648000000, 0.25 +Res-1.951, 10072000000, 0.25 +Res-1.952, 10216000000, 0.25 +Res-1.953, 10360000000, 0.25 +Res-1.954, 10504000000, 0.25 +Res-1.955, 10648000000, 0.25 +Res-1.956, 10072000000, 0.25 +Res-1.957, 10216000000, 0.25 +Res-1.958, 10360000000, 0.25 +Res-1.959, 10504000000, 0.25 +Res-1.960, 10648000000, 0.25 +Res-1.961, 10072000000, 0.25 +Res-1.962, 10072000000, 0.25 +Res-1.963, 10072000000, 0.25 +Res-1.964, 10072000000, 0.25 +Res-1.965, 10072000000, 0.25 +Res-1.966, 10072000000, 0.25 +Res-1.967, 10216000000, 0.25 +Res-1.968, 10216000000, 0.25 +Res-1.969, 10216000000, 0.25 +Res-1.970, 10216000000, 0.25 +Res-1.971, 10216000000, 0.25 +Res-1.972, 10216000000, 0.25 +Res-1.973, 10360000000, 0.25 +Res-1.974, 10360000000, 0.25 +Res-1.975, 10360000000, 0.25 +Res-1.976, 10360000000, 0.25 +Res-1.977, 10360000000, 0.25 +Res-1.978, 10360000000, 0.25 +Res-1.979, 10504000000, 0.25 +Res-1.980, 10504000000, 0.25 +Res-1.981, 10504000000, 0.25 +Res-1.982, 10504000000, 0.25 +Res-1.983, 10504000000, 0.25 +Res-1.984, 10504000000, 0.25 +Res-1.985, 10648000000, 0.25 +Res-1.986, 10648000000, 0.25 +Res-1.987, 10648000000, 0.25 +Res-1.988, 10648000000, 0.25 +Res-1.989, 10648000000, 0.25 +Res-1.990, 10648000000, 0.25 +Res-1.991, 10072000000, 0.25 +Res-1.992, 10216000000, 0.25 +Res-1.993, 10360000000, 0.25 +Res-1.994, 10504000000, 0.25 +Res-1.995, 10648000000, 0.25 +Res-1.996, 10072000000, 0.25 +Res-1.997, 10216000000, 0.25 +Res-1.998, 10360000000, 0.25 +Res-1.999, 10504000000, 0.25 +Res-1.1000, 10648000000, 0.25 +Res-1.1001, 10072000000, 0.25 +Res-1.1002, 10216000000, 0.25 +Res-1.1003, 10360000000, 0.25 +Res-1.1004, 10504000000, 0.25 +Res-1.1005, 10648000000, 0.25 +Res-1.1006, 10072000000, 0.25 +Res-1.1007, 10216000000, 0.25 +Res-1.1008, 10360000000, 0.25 +Res-1.1009, 10504000000, 0.25 +Res-1.1010, 10648000000, 0.25 +Res-1.1011, 10072000000, 0.25 +Res-1.1012, 10216000000, 0.25 +Res-1.1013, 10360000000, 0.25 +Res-1.1014, 10504000000, 0.25 +Res-1.1015, 10648000000, 0.25 +Res-1.1016, 10072000000, 0.25 +Res-1.1017, 10216000000, 0.25 +Res-1.1018, 10360000000, 0.25 +Res-1.1019, 10504000000, 0.25 +Res-1.1020, 10648000000, 0.25 +Res-1.1021, 10072000000, 0.25 +Res-1.1022, 10216000000, 0.25 +Res-1.1023, 10360000000, 0.25 +Res-1.1024, 10504000000, 0.25 +Res-1.1025, 10648000000, 0.25 +Res-1.1026, 10072000000, 0.25 +Res-1.1027, 10216000000, 0.25 +Res-1.1028, 10360000000, 0.25 +Res-1.1029, 10504000000, 0.25 +Res-1.1030, 10648000000, 0.25 +Res-1.1031, 10072000000, 0.25 +Res-1.1032, 10216000000, 0.25 +Res-1.1033, 10360000000, 0.25 +Res-1.1034, 10504000000, 0.25 +Res-1.1035, 10648000000, 0.25 +Res-1.1036, 10072000000, 0.25 +Res-1.1037, 10216000000, 0.25 +Res-1.1038, 10360000000, 0.25 +Res-1.1039, 10504000000, 0.25 +Res-1.1040, 10648000000, 0.25 +Res-1.1041, 10072000000, 0.25 +Res-1.1042, 10072000000, 0.25 +Res-1.1043, 10072000000, 0.25 +Res-1.1044, 10072000000, 0.25 +Res-1.1045, 10072000000, 0.25 +Res-1.1046, 10072000000, 0.25 +Res-1.1047, 10216000000, 0.25 +Res-1.1048, 10216000000, 0.25 +Res-1.1049, 10216000000, 0.25 +Res-1.1050, 10216000000, 0.25 +Res-1.1051, 10216000000, 0.25 +Res-1.1052, 10216000000, 0.25 +Res-1.1053, 10360000000, 0.25 +Res-1.1054, 10360000000, 0.25 +Res-1.1055, 10360000000, 0.25 +Res-1.1056, 10360000000, 0.25 +Res-1.1057, 10360000000, 0.25 +Res-1.1058, 10360000000, 0.25 +Res-1.1059, 10504000000, 0.25 +Res-1.1060, 10504000000, 0.25 +Res-1.1061, 10504000000, 0.25 +Res-1.1062, 10504000000, 0.25 +Res-1.1063, 10504000000, 0.25 +Res-1.1064, 10504000000, 0.25 +Res-1.1065, 10648000000, 0.25 +Res-1.1066, 10648000000, 0.25 +Res-1.1067, 10648000000, 0.25 +Res-1.1068, 10648000000, 0.25 +Res-1.1069, 10648000000, 0.25 +Res-1.1070, 10648000000, 0.25 +Res-1.1071, 10072000000, 0.25 +Res-1.1072, 10216000000, 0.25 +Res-1.1073, 10360000000, 0.25 +Res-1.1074, 10504000000, 0.25 +Res-1.1075, 10648000000, 0.25 +Res-1.1076, 10072000000, 0.25 +Res-1.1077, 10216000000, 0.25 +Res-1.1078, 10360000000, 0.25 +Res-1.1079, 10504000000, 0.25 +Res-1.1080, 10648000000, 0.25 +Res-1.1081, 10072000000, 0.25 +Res-1.1082, 10216000000, 0.25 +Res-1.1083, 10360000000, 0.25 +Res-1.1084, 10504000000, 0.25 +Res-1.1085, 10648000000, 0.25 +Res-1.1086, 10072000000, 0.25 +Res-1.1087, 10216000000, 0.25 +Res-1.1088, 10360000000, 0.25 +Res-1.1089, 10504000000, 0.25 +Res-1.1090, 10648000000, 0.25 +Res-1.1091, 10072000000, 0.25 +Res-1.1092, 10216000000, 0.25 +Res-1.1093, 10360000000, 0.25 +Res-1.1094, 10504000000, 0.25 +Res-1.1095, 10648000000, 0.25 +Res-1.1096, 10072000000, 0.25 +Res-1.1097, 10216000000, 0.25 +Res-1.1098, 10360000000, 0.25 +Res-1.1099, 10504000000, 0.25 +Res-1.1100, 10648000000, 0.25 +Res-1.1101, 10072000000, 0.25 +Res-1.1102, 10216000000, 0.25 +Res-1.1103, 10360000000, 0.25 +Res-1.1104, 10504000000, 0.25 +Res-1.1105, 10648000000, 0.25 +Res-1.1106, 10072000000, 0.25 +Res-1.1107, 10216000000, 0.25 +Res-1.1108, 10360000000, 0.25 +Res-1.1109, 10504000000, 0.25 +Res-1.1110, 10648000000, 0.25 +Res-1.1111, 10072000000, 0.25 +Res-1.1112, 10216000000, 0.25 +Res-1.1113, 10360000000, 0.25 +Res-1.1114, 10504000000, 0.25 +Res-1.1115, 10648000000, 0.25 +Res-1.1116, 10072000000, 0.25 +Res-1.1117, 10216000000, 0.25 +Res-1.1118, 10360000000, 0.25 +Res-1.1119, 10504000000, 0.25 +Res-1.1120, 10648000000, 0.25 +Res-1.1121, 10072000000, 0.25 +Res-1.1122, 10072000000, 0.25 +Res-1.1123, 10072000000, 0.25 +Res-1.1124, 10072000000, 0.25 +Res-1.1125, 10072000000, 0.25 +Res-1.1126, 10072000000, 0.25 +Res-1.1127, 10216000000, 0.25 +Res-1.1128, 10216000000, 0.25 +Res-1.1129, 10216000000, 0.25 +Res-1.1130, 10216000000, 0.25 +Res-1.1131, 10216000000, 0.25 +Res-1.1132, 10216000000, 0.25 +Res-1.1133, 10360000000, 0.25 +Res-1.1134, 10360000000, 0.25 +Res-1.1135, 10360000000, 0.25 +Res-1.1136, 10360000000, 0.25 +Res-1.1137, 10360000000, 0.25 +Res-1.1138, 10360000000, 0.25 +Res-1.1139, 10504000000, 0.25 +Res-1.1140, 10504000000, 0.25 +Res-1.1141, 10504000000, 0.25 +Res-1.1142, 10504000000, 0.25 +Res-1.1143, 10504000000, 0.25 +Res-1.1144, 10504000000, 0.25 +Res-1.1145, 10648000000, 0.25 +Res-1.1146, 10648000000, 0.25 +Res-1.1147, 10648000000, 0.25 +Res-1.1148, 10648000000, 0.25 +Res-1.1149, 10648000000, 0.25 +Res-1.1150, 10648000000, 0.25 +Res-1.1151, 10072000000, 0.25 +Res-1.1152, 10216000000, 0.25 +Res-1.1153, 10360000000, 0.25 +Res-1.1154, 10504000000, 0.25 +Res-1.1155, 10648000000, 0.25 +Res-1.1156, 10072000000, 0.25 +Res-1.1157, 10216000000, 0.25 +Res-1.1158, 10360000000, 0.25 +Res-1.1159, 10504000000, 0.25 +Res-1.1160, 10648000000, 0.25 +Res-1.1161, 10072000000, 0.25 +Res-1.1162, 10216000000, 0.25 +Res-1.1163, 10360000000, 0.25 +Res-1.1164, 10504000000, 0.25 +Res-1.1165, 10648000000, 0.25 +Res-1.1166, 10072000000, 0.25 +Res-1.1167, 10216000000, 0.25 +Res-1.1168, 10360000000, 0.25 +Res-1.1169, 10504000000, 0.25 +Res-1.1170, 10648000000, 0.25 +Res-1.1171, 10072000000, 0.25 +Res-1.1172, 10216000000, 0.25 +Res-1.1173, 10360000000, 0.25 +Res-1.1174, 10504000000, 0.25 +Res-1.1175, 10648000000, 0.25 +Res-1.1176, 10072000000, 0.25 +Res-1.1177, 10216000000, 0.25 +Res-1.1178, 10360000000, 0.25 +Res-1.1179, 10504000000, 0.25 +Res-1.1180, 10648000000, 0.25 +Res-1.1181, 10072000000, 0.25 +Res-1.1182, 10216000000, 0.25 +Res-1.1183, 10360000000, 0.25 +Res-1.1184, 10504000000, 0.25 +Res-1.1185, 10648000000, 0.25 +Res-1.1186, 10072000000, 0.25 +Res-1.1187, 10216000000, 0.25 +Res-1.1188, 10360000000, 0.25 +Res-1.1189, 10504000000, 0.25 +Res-1.1190, 10648000000, 0.25 +Res-1.1191, 10072000000, 0.25 +Res-1.1192, 10216000000, 0.25 +Res-1.1193, 10360000000, 0.25 +Res-1.1194, 10504000000, 0.25 +Res-1.1195, 10648000000, 0.25 +Res-1.1196, 10072000000, 0.25 +Res-1.1197, 10216000000, 0.25 +Res-1.1198, 10360000000, 0.25 +Res-1.1199, 10504000000, 0.25 +Res-1.1200, 10648000000, 0.25 +Res-1.1201, 10072000000, 0.25 +Res-1.1202, 10072000000, 0.25 +Res-1.1203, 10072000000, 0.25 +Res-1.1204, 10072000000, 0.25 +Res-1.1205, 10072000000, 0.25 +Res-1.1206, 10072000000, 0.25 +Res-1.1207, 10216000000, 0.25 +Res-1.1208, 10216000000, 0.25 +Res-1.1209, 10216000000, 0.25 +Res-1.1210, 10216000000, 0.25 +Res-1.1211, 10216000000, 0.25 +Res-1.1212, 10216000000, 0.25 +Res-1.1213, 10360000000, 0.25 +Res-1.1214, 10360000000, 0.25 +Res-1.1215, 10360000000, 0.25 +Res-1.1216, 10360000000, 0.25 +Res-1.1217, 10360000000, 0.25 +Res-1.1218, 10360000000, 0.25 +Res-1.1219, 10504000000, 0.25 +Res-1.1220, 10504000000, 0.25 +Res-1.1221, 10504000000, 0.25 +Res-1.1222, 10504000000, 0.25 +Res-1.1223, 10504000000, 0.25 +Res-1.1224, 10504000000, 0.25 +Res-1.1225, 10648000000, 0.25 +Res-1.1226, 10648000000, 0.25 +Res-1.1227, 10648000000, 0.25 +Res-1.1228, 10648000000, 0.25 +Res-1.1229, 10648000000, 0.25 +Res-1.1230, 10648000000, 0.25 +Res-1.1231, 10072000000, 0.25 +Res-1.1232, 10216000000, 0.25 +Res-1.1233, 10360000000, 0.25 +Res-1.1234, 10504000000, 0.25 +Res-1.1235, 10648000000, 0.25 +Res-1.1236, 10072000000, 0.25 +Res-1.1237, 10216000000, 0.25 +Res-1.1238, 10360000000, 0.25 +Res-1.1239, 10504000000, 0.25 +Res-1.1240, 10648000000, 0.25 +Res-1.1241, 10072000000, 0.25 +Res-1.1242, 10216000000, 0.25 +Res-1.1243, 10360000000, 0.25 +Res-1.1244, 10504000000, 0.25 +Res-1.1245, 10648000000, 0.25 +Res-1.1246, 10072000000, 0.25 +Res-1.1247, 10216000000, 0.25 +Res-1.1248, 10360000000, 0.25 +Res-1.1249, 10504000000, 0.25 +Res-1.1250, 10648000000, 0.25 +Res-1.1251, 10072000000, 0.25 +Res-1.1252, 10216000000, 0.25 +Res-1.1253, 10360000000, 0.25 +Res-1.1254, 10504000000, 0.25 +Res-1.1255, 10648000000, 0.25 +Res-1.1256, 10072000000, 0.25 +Res-1.1257, 10216000000, 0.25 +Res-1.1258, 10360000000, 0.25 +Res-1.1259, 10504000000, 0.25 +Res-1.1260, 10648000000, 0.25 +Res-1.1261, 10072000000, 0.25 +Res-1.1262, 10216000000, 0.25 +Res-1.1263, 10360000000, 0.25 +Res-1.1264, 10504000000, 0.25 +Res-1.1265, 10648000000, 0.25 +Res-1.1266, 10072000000, 0.25 +Res-1.1267, 10216000000, 0.25 +Res-1.1268, 10360000000, 0.25 +Res-1.1269, 10504000000, 0.25 +Res-1.1270, 10648000000, 0.25 +Res-1.1271, 10072000000, 0.25 +Res-1.1272, 10216000000, 0.25 +Res-1.1273, 10360000000, 0.25 +Res-1.1274, 10504000000, 0.25 +Res-1.1275, 10648000000, 0.25 +Res-1.1276, 10072000000, 0.25 +Res-1.1277, 10216000000, 0.25 +Res-1.1278, 10360000000, 0.25 +Res-1.1279, 10504000000, 0.25 +Res-1.1280, 10648000000, 0.25 +Res-1.1281, 10072000000, 0.25 +Res-1.1282, 10072000000, 0.25 +Res-1.1283, 10072000000, 0.25 +Res-1.1284, 10072000000, 0.25 +Res-1.1285, 10072000000, 0.25 +Res-1.1286, 10072000000, 0.25 +Res-1.1287, 10216000000, 0.25 +Res-1.1288, 10216000000, 0.25 +Res-1.1289, 10216000000, 0.25 +Res-1.1290, 10216000000, 0.25 +Res-1.1291, 10216000000, 0.25 +Res-1.1292, 10216000000, 0.25 +Res-1.1293, 10360000000, 0.25 +Res-1.1294, 10360000000, 0.25 +Res-1.1295, 10360000000, 0.25 +Res-1.1296, 10360000000, 0.25 +Res-1.1297, 10360000000, 0.25 +Res-1.1298, 10360000000, 0.25 +Res-1.1299, 10504000000, 0.25 +Res-1.1300, 10504000000, 0.25 +Res-1.1301, 10504000000, 0.25 +Res-1.1302, 10504000000, 0.25 +Res-1.1303, 10504000000, 0.25 +Res-1.1304, 10504000000, 0.25 +Res-1.1305, 10648000000, 0.25 +Res-1.1306, 10648000000, 0.25 +Res-1.1307, 10648000000, 0.25 +Res-1.1308, 10648000000, 0.25 +Res-1.1309, 10648000000, 0.25 +Res-1.1310, 10648000000, 0.25 +Res-1.1311, 10072000000, 0.25 +Res-1.1312, 10216000000, 0.25 +Res-1.1313, 10360000000, 0.25 +Res-1.1314, 10504000000, 0.25 +Res-1.1315, 10648000000, 0.25 +Res-1.1316, 10072000000, 0.25 +Res-1.1317, 10216000000, 0.25 +Res-1.1318, 10360000000, 0.25 +Res-1.1319, 10504000000, 0.25 +Res-1.1320, 10648000000, 0.25 +Res-1.1321, 10072000000, 0.25 +Res-1.1322, 10216000000, 0.25 +Res-1.1323, 10360000000, 0.25 +Res-1.1324, 10504000000, 0.25 +Res-1.1325, 10648000000, 0.25 +Res-1.1326, 10072000000, 0.25 +Res-1.1327, 10216000000, 0.25 +Res-1.1328, 10360000000, 0.25 +Res-1.1329, 10504000000, 0.25 +Res-1.1330, 10648000000, 0.25 +Res-1.1331, 10072000000, 0.25 +Res-1.1332, 10216000000, 0.25 +Res-1.1333, 10360000000, 0.25 +Res-1.1334, 10504000000, 0.25 +Res-1.1335, 10648000000, 0.25 +Res-1.1336, 10072000000, 0.25 +Res-1.1337, 10216000000, 0.25 +Res-1.1338, 10360000000, 0.25 +Res-1.1339, 10504000000, 0.25 +Res-1.1340, 10648000000, 0.25 +Res-1.1341, 10072000000, 0.25 +Res-1.1342, 10216000000, 0.25 +Res-1.1343, 10360000000, 0.25 +Res-1.1344, 10504000000, 0.25 +Res-1.1345, 10648000000, 0.25 +Res-1.1346, 10072000000, 0.25 +Res-1.1347, 10216000000, 0.25 +Res-1.1348, 10360000000, 0.25 +Res-1.1349, 10504000000, 0.25 +Res-1.1350, 10648000000, 0.25 +Res-1.1351, 10072000000, 0.25 +Res-1.1352, 10216000000, 0.25 +Res-1.1353, 10360000000, 0.25 +Res-1.1354, 10504000000, 0.25 +Res-1.1355, 10648000000, 0.25 +Res-1.1356, 10072000000, 0.25 +Res-1.1357, 10216000000, 0.25 +Res-1.1358, 10360000000, 0.25 +Res-1.1359, 10504000000, 0.25 +Res-1.1360, 10648000000, 0.25 +Res-1.1361, 10072000000, 0.25 +Res-1.1362, 10072000000, 0.25 +Res-1.1363, 10072000000, 0.25 +Res-1.1364, 10072000000, 0.25 +Res-1.1365, 10072000000, 0.25 +Res-1.1366, 10072000000, 0.25 +Res-1.1367, 10216000000, 0.25 +Res-1.1368, 10216000000, 0.25 +Res-1.1369, 10216000000, 0.25 +Res-1.1370, 10216000000, 0.25 +Res-1.1371, 10216000000, 0.25 +Res-1.1372, 10216000000, 0.25 +Res-1.1373, 10360000000, 0.25 +Res-1.1374, 10360000000, 0.25 +Res-1.1375, 10360000000, 0.25 +Res-1.1376, 10360000000, 0.25 +Res-1.1377, 10360000000, 0.25 +Res-1.1378, 10360000000, 0.25 +Res-1.1379, 10504000000, 0.25 +Res-1.1380, 10504000000, 0.25 +Res-1.1381, 10504000000, 0.25 +Res-1.1382, 10504000000, 0.25 +Res-1.1383, 10504000000, 0.25 +Res-1.1384, 10504000000, 0.25 +Res-1.1385, 10648000000, 0.25 +Res-1.1386, 10648000000, 0.25 +Res-1.1387, 10648000000, 0.25 +Res-1.1388, 10648000000, 0.25 +Res-1.1389, 10648000000, 0.25 +Res-1.1390, 10648000000, 0.25 +Res-1.1391, 10072000000, 0.25 +Res-1.1392, 10216000000, 0.25 +Res-1.1393, 10360000000, 0.25 +Res-1.1394, 10504000000, 0.25 +Res-1.1395, 10648000000, 0.25 +Res-1.1396, 10072000000, 0.25 +Res-1.1397, 10216000000, 0.25 +Res-1.1398, 10360000000, 0.25 +Res-1.1399, 10504000000, 0.25 +Res-1.1400, 10648000000, 0.25 +Res-1.1401, 10072000000, 0.25 +Res-1.1402, 10216000000, 0.25 +Res-1.1403, 10360000000, 0.25 +Res-1.1404, 10504000000, 0.25 +Res-1.1405, 10648000000, 0.25 +Res-1.1406, 10072000000, 0.25 +Res-1.1407, 10216000000, 0.25 +Res-1.1408, 10360000000, 0.25 +Res-1.1409, 10504000000, 0.25 +Res-1.1410, 10648000000, 0.25 +Res-1.1411, 10072000000, 0.25 +Res-1.1412, 10216000000, 0.25 +Res-1.1413, 10360000000, 0.25 +Res-1.1414, 10504000000, 0.25 +Res-1.1415, 10648000000, 0.25 +Res-1.1416, 10072000000, 0.25 +Res-1.1417, 10216000000, 0.25 +Res-1.1418, 10360000000, 0.25 +Res-1.1419, 10504000000, 0.25 +Res-1.1420, 10648000000, 0.25 +Res-1.1421, 10072000000, 0.25 +Res-1.1422, 10216000000, 0.25 +Res-1.1423, 10360000000, 0.25 +Res-1.1424, 10504000000, 0.25 +Res-1.1425, 10648000000, 0.25 +Res-1.1426, 10072000000, 0.25 +Res-1.1427, 10216000000, 0.25 +Res-1.1428, 10360000000, 0.25 +Res-1.1429, 10504000000, 0.25 +Res-1.1430, 10648000000, 0.25 +Res-1.1431, 10072000000, 0.25 +Res-1.1432, 10216000000, 0.25 +Res-1.1433, 10360000000, 0.25 +Res-1.1434, 10504000000, 0.25 +Res-1.1435, 10648000000, 0.25 +Res-1.1436, 10072000000, 0.25 +Res-1.1437, 10216000000, 0.25 +Res-1.1438, 10360000000, 0.25 +Res-1.1439, 10504000000, 0.25 +Res-1.1440, 10648000000, 0.25 +Res-1.1441, 10478007200, 0.25 +Res-1.1442, 10478007200, 0.25 +Res-1.1443, 10478007200, 0.25 +Res-1.1444, 10478007200, 0.25 +Res-1.1445, 10478007200, 0.25 +Res-1.1446, 10478007200, 0.25 +Res-1.1447, 10478007200, 0.25 +Res-1.1448, 10478007200, 0.25 +Res-1.1449, 10478007200, 0.25 +Res-1.1450, 10478007200, 0.25 +Res-1.1451, 10478007200, 0.25 +Res-1.1452, 10478007200, 0.25 +Res-1.1453, 10478007200, 0.25 +Res-1.1454, 10478007200, 0.25 +Res-1.1455, 10478007200, 0.25 +Res-1.1456, 10478007200, 0.25 +Res-1.1457, 10478007200, 0.25 +Res-1.1458, 10478007200, 0.25 +Res-1.1459, 10478007200, 0.25 +Res-1.1460, 10478007200, 0.25 +Res-1.1461, 10478007200, 0.25 +Res-1.1462, 10478007200, 0.25 +Res-1.1463, 10478007200, 0.25 +Res-1.1464, 10478007200, 0.25 +Res-1.1465, 10478007200, 0.25 +Res-1.1466, 10478007200, 0.25 +Res-1.1467, 10478007200, 0.25 +Res-1.1468, 10478007200, 0.25 +Res-1.1469, 10478007200, 0.25 +Res-1.1470, 10478007200, 0.25 +Res-1.1471, 10478007200, 0.25 +Res-1.1472, 10478007200, 0.25 +Res-1.1473, 10478007200, 0.25 +Res-1.1474, 10478007200, 0.25 +Res-1.1475, 10478007200, 0.25 +Res-1.1476, 10478007200, 0.25 +Res-1.1477, 10478007200, 0.25 +Res-1.1478, 10478007200, 0.25 +Res-1.1479, 10478007200, 0.25 +Res-1.1480, 10478007200, 0.25 +Res-1.1481, 10478007200, 0.25 +Res-1.1482, 10478007200, 0.25 +Res-1.1483, 10478007200, 0.25 +Res-1.1484, 10478007200, 0.25 +Res-1.1485, 10478007200, 0.25 +Res-1.1486, 10478007200, 0.25 +Res-1.1487, 10478007200, 0.25 +Res-1.1488, 10478007200, 0.25 +Res-1.1489, 10478007200, 0.25 +Res-1.1490, 10478007200, 0.25 +Res-1.1491, 10478007200, 0.25 +Res-1.1492, 10478007200, 0.25 +Res-1.1493, 10478007200, 0.25 +Res-1.1494, 10478007200, 0.25 +Res-1.1495, 10478007200, 0.25 +Res-1.1496, 10478007200, 0.25 +Res-1.1497, 10478007200, 0.25 +Res-1.1498, 10478007200, 0.25 +Res-1.1499, 10478007200, 0.25 +Res-1.1500, 10478007200, 0.25 +Res-1.1501, 10478007200, 0.25 +Res-1.1502, 10478007200, 0.25 +Res-1.1503, 10478007200, 0.25 +Res-1.1504, 10478007200, 0.25 +Res-1.1505, 10478007200, 0.25 +Res-1.1506, 10478007200, 0.25 +Res-1.1507, 10478007200, 0.25 +Res-1.1508, 10478007200, 0.25 +Res-1.1509, 10478007200, 0.25 +Res-1.1510, 10478007200, 0.25 +Res-1.1511, 10478007200, 0.25 +Res-1.1512, 10478007200, 0.25 +Res-1.1513, 10478007200, 0.25 +Res-1.1514, 10478007200, 0.25 +Res-1.1515, 10478007200, 0.25 +Res-1.1516, 10478007200, 0.25 +Res-1.1517, 10478007200, 0.25 +Res-1.1518, 10478007200, 0.25 +Res-1.1519, 10478007200, 0.25 +Res-1.1520, 10478007200, 0.25 +Res-1.1521, 10478007200, 0.25 +Res-1.1522, 10478007200, 0.25 +Res-1.1523, 10478007200, 0.25 +Res-1.1524, 10478007200, 0.25 +Res-1.1525, 10478007200, 0.25 +Res-1.1526, 10478007200, 0.25 +Res-1.1527, 10478007200, 0.25 +Res-1.1528, 10478007200, 0.25 +Res-1.1529, 10478007200, 0.25 +Res-1.1530, 10478007200, 0.25 +Res-1.1531, 10478007200, 0.25 +Res-1.1532, 10478007200, 0.25 +Res-1.1533, 10478007200, 0.25 +Res-1.1534, 10478007200, 0.25 +Res-1.1535, 10478007200, 0.25 +Res-1.1536, 10478007200, 0.25 +Res-1.1537, 10478007200, 0.25 +Res-1.1538, 10478007200, 0.25 +Res-1.1539, 10478007200, 0.25 +Res-1.1540, 10478007200, 0.25 +Res-1.1541, 10478007200, 0.25 +Res-1.1542, 10478007200, 0.25 +Res-1.1543, 10478007200, 0.25 +Res-1.1544, 10478007200, 0.25 +Res-1.1545, 10478007200, 0.25 +Res-1.1546, 10478007200, 0.25 +Res-1.1547, 10478007200, 0.25 +Res-1.1548, 10478007200, 0.25 +Res-1.1549, 10478007200, 0.25 +Res-1.1550, 10478007200, 0.25 +Res-1.1551, 10478007200, 0.25 +Res-1.1552, 10478007200, 0.25 +Res-1.1553, 10478007200, 0.25 +Res-1.1554, 10478007200, 0.25 +Res-1.1555, 10478007200, 0.25 +Res-1.1556, 10478007200, 0.25 +Res-1.1557, 10478007200, 0.25 +Res-1.1558, 10478007200, 0.25 +Res-1.1559, 10478007200, 0.25 +Res-1.1560, 10478007200, 0.25 +Res-1.1561, 10478007200, 0.25 +Res-1.1562, 10478007200, 0.25 +Res-1.1563, 10478007200, 0.25 +Res-1.1564, 10478007200, 0.25 +Res-1.1565, 10478007200, 0.25 +Res-1.1566, 10478007200, 0.25 +Res-1.1567, 10478007200, 0.25 +Res-1.1568, 10478007200, 0.25 +Res-1.1569, 10478007200, 0.25 +Res-1.1570, 10478007200, 0.25 +Res-1.1571, 10478007200, 0.25 +Res-1.1572, 10478007200, 0.25 +Res-1.1573, 10478007200, 0.25 +Res-1.1574, 10478007200, 0.25 +Res-1.1575, 10478007200, 0.25 +Res-1.1576, 10478007200, 0.25 +Res-1.1577, 10478007200, 0.25 +Res-1.1578, 10478007200, 0.25 +Res-1.1579, 10478007200, 0.25 +Res-1.1580, 10478007200, 0.25 +Res-1.1581, 10478007200, 0.25 +Res-1.1582, 10478007200, 0.25 +Res-1.1583, 10478007200, 0.25 +Res-1.1584, 10478007200, 0.25 +Res-1.1585, 10478007200, 0.25 +Res-1.1586, 10478007200, 0.25 +Res-1.1587, 10478007200, 0.25 +Res-1.1588, 10478007200, 0.25 +Res-1.1589, 10478007200, 0.25 +Res-1.1590, 10478007200, 0.25 +Res-1.1591, 10478007200, 0.25 +Res-1.1592, 10478007200, 0.25 +Res-1.1593, 10478007200, 0.25 +Res-1.1594, 10478007200, 0.25 +Res-1.1595, 10478007200, 0.25 +Res-1.1596, 10478007200, 0.25 +Res-1.1597, 10478007200, 0.25 +Res-1.1598, 10478007200, 0.25 +Res-1.1599, 10478007200, 0.25 +Res-1.1600, 10478007200, 0.25 +Res-1.1601, 10478007200, 0.25 +Res-1.1602, 10478007200, 0.25 +Res-1.1603, 10478007200, 0.25 +Res-1.1604, 10478007200, 0.25 +Res-1.1605, 10478007200, 0.25 +Res-1.1606, 10478007200, 0.25 +Res-1.1607, 10478007200, 0.25 +Res-1.1608, 10478007200, 0.25 +Res-1.1609, 10478007200, 0.25 +Res-1.1610, 10478007200, 0.25 +Res-1.1611, 10478007200, 0.25 +Res-1.1612, 10478007200, 0.25 +Res-1.1613, 10478007200, 0.25 +Res-1.1614, 10478007200, 0.25 +Res-1.1615, 10478007200, 0.25 +Res-1.1616, 10478007200, 0.25 +Res-1.1617, 10478007200, 0.25 +Res-1.1618, 10478007200, 0.25 +Res-1.1619, 10478007200, 0.25 +Res-1.1620, 10478007200, 0.25 +Res-1.1621, 10478007200, 0.25 +Res-1.1622, 10478007200, 0.25 +Res-1.1623, 10478007200, 0.25 +Res-1.1624, 10478007200, 0.25 +Res-1.1625, 10478007200, 0.25 +Res-1.1626, 10478007200, 0.25 +Res-1.1627, 10478007200, 0.25 +Res-1.1628, 10478007200, 0.25 +Res-1.1629, 10478007200, 0.25 +Res-1.1630, 10478007200, 0.25 +Res-1.1631, 10478007200, 0.25 +Res-1.1632, 10478007200, 0.25 +Res-1.1633, 10478007200, 0.25 +Res-1.1634, 10478007200, 0.25 +Res-1.1635, 10478007200, 0.25 +Res-1.1636, 10478007200, 0.25 +Res-1.1637, 10478007200, 0.25 +Res-1.1638, 10478007200, 0.25 +Res-1.1639, 10478007200, 0.25 +Res-1.1640, 10478007200, 0.25 +Res-1.1641, 10478007200, 0.25 +Res-1.1642, 10478007200, 0.25 +Res-1.1643, 10478007200, 0.25 +Res-1.1644, 10478007200, 0.25 +Res-1.1645, 10478007200, 0.25 +Res-1.1646, 10478007200, 0.25 +Res-1.1647, 10478007200, 0.25 +Res-1.1648, 10478007200, 0.25 +Res-1.1649, 10478007200, 0.25 +Res-1.1650, 10478007200, 0.25 +Res-1.1651, 10478007200, 0.25 +Res-1.1652, 10478007200, 0.25 +Res-1.1653, 10478007200, 0.25 +Res-1.1654, 10478007200, 0.25 +Res-1.1655, 10478007200, 0.25 +Res-1.1656, 10478007200, 0.25 +Res-1.1657, 10478007200, 0.25 +Res-1.1658, 10478007200, 0.25 +Res-1.1659, 10478007200, 0.25 +Res-1.1660, 10478007200, 0.25 +Res-1.1661, 10478007200, 0.25 +Res-1.1662, 10478007200, 0.25 +Res-1.1663, 10478007200, 0.25 +Res-1.1664, 10478007200, 0.25 +Res-1.1665, 10478007200, 0.25 +Res-1.1666, 10478007200, 0.25 +Res-1.1667, 10478007200, 0.25 +Res-1.1668, 10478007200, 0.25 +Res-1.1669, 10478007200, 0.25 +Res-1.1670, 10478007200, 0.25 +Res-1.1671, 10478007200, 0.25 +Res-1.1672, 10478007200, 0.25 +Res-1.1673, 10478007200, 0.25 +Res-1.1674, 10478007200, 0.25 +Res-1.1675, 10478007200, 0.25 +Res-1.1676, 10478007200, 0.25 +Res-1.1677, 10478007200, 0.25 +Res-1.1678, 10478007200, 0.25 +Res-1.1679, 10478007200, 0.25 +Res-1.1680, 10478007200, 0.25 +Res-1.1681, 10478007200, 0.25 +Res-1.1682, 10478007200, 0.25 +Res-1.1683, 10478007200, 0.25 +Res-1.1684, 10478007200, 0.25 +Res-1.1685, 10478007200, 0.25 +Res-1.1686, 10478007200, 0.25 +Res-1.1687, 10478007200, 0.25 +Res-1.1688, 10478007200, 0.25 +Res-1.1689, 10478007200, 0.25 +Res-1.1690, 10478007200, 0.25 +Res-1.1691, 10478007200, 0.25 +Res-1.1692, 10478007200, 0.25 +Res-1.1693, 10478007200, 0.25 +Res-1.1694, 10478007200, 0.25 +Res-1.1695, 10478007200, 0.25 +Res-1.1696, 10478007200, 0.25 +Res-1.1697, 10478007200, 0.25 +Res-1.1698, 10478007200, 0.25 +Res-1.1699, 10478007200, 0.25 +Res-1.1700, 10478007200, 0.25 +Res-1.1701, 10478007200, 0.25 +Res-1.1702, 10478007200, 0.25 +Res-1.1703, 10478007200, 0.25 +Res-1.1704, 10478007200, 0.25 +Res-1.1705, 10478007200, 0.25 +Res-1.1706, 10478007200, 0.25 +Res-1.1707, 10478007200, 0.25 +Res-1.1708, 10478007200, 0.25 +Res-1.1709, 10478007200, 0.25 +Res-1.1710, 10478007200, 0.25 +Res-1.1711, 10478007200, 0.25 +Res-1.1712, 10478007200, 0.25 +Res-1.1713, 10478007200, 0.25 +Res-1.1714, 10478007200, 0.25 +Res-1.1715, 10478007200, 0.25 +Res-1.1716, 10478007200, 0.25 +Res-1.1717, 10478007200, 0.25 +Res-1.1718, 10478007200, 0.25 +Res-1.1719, 10478007200, 0.25 +Res-1.1720, 10478007200, 0.25 +Res-1.1721, 10478007200, 0.25 +Res-1.1722, 10478007200, 0.25 +Res-1.1723, 10478007200, 0.25 +Res-1.1724, 10478007200, 0.25 +Res-1.1725, 10478007200, 0.25 +Res-1.1726, 10478007200, 0.25 +Res-1.1727, 10478007200, 0.25 +Res-1.1728, 10478007200, 0.25 +Res-1.1729, 11670801700, 0.25 +Res-1.1730, 11670801700, 0.25 +Res-1.1731, 11670801700, 0.25 +Res-1.1732, 11670801700, 0.25 +Res-1.1733, 11670801700, 0.25 +Res-1.1734, 11670801700, 0.25 +Res-1.1735, 11670801700, 0.25 +Res-1.1736, 11670801700, 0.25 +Res-1.1737, 11670801700, 0.25 +Res-1.1738, 11670801700, 0.25 +Res-1.1739, 11670801700, 0.25 +Res-1.1740, 11670801700, 0.25 +Res-1.1741, 11670801700, 0.25 +Res-1.1742, 11670801700, 0.25 +Res-1.1743, 11670801700, 0.25 +Res-1.1744, 11670801700, 0.25 +Res-1.1745, 11670801700, 0.25 +Res-1.1746, 11670801700, 0.25 +Res-1.1747, 11670801700, 0.25 +Res-1.1748, 11670801700, 0.25 +Res-1.1749, 11670801700, 0.25 +Res-1.1750, 11670801700, 0.25 +Res-1.1751, 11670801700, 0.25 +Res-1.1752, 11670801700, 0.25 +Res-1.1753, 11670801700, 0.25 +Res-1.1754, 11670801700, 0.25 +Res-1.1755, 11670801700, 0.25 +Res-1.1756, 11670801700, 0.25 +Res-1.1757, 11670801700, 0.25 +Res-1.1758, 11670801700, 0.25 +Res-1.1759, 11670801700, 0.25 +Res-1.1760, 11670801700, 0.25 +Res-1.1761, 11670801700, 0.25 +Res-1.1762, 11670801700, 0.25 +Res-1.1763, 11670801700, 0.25 +Res-1.1764, 11670801700, 0.25 +Res-1.1765, 11670801700, 0.25 +Res-1.1766, 11670801700, 0.25 +Res-1.1767, 11670801700, 0.25 +Res-1.1768, 11670801700, 0.25 +Res-1.1769, 11670801700, 0.25 +Res-1.1770, 11670801700, 0.25 +Res-1.1771, 11670801700, 0.25 +Res-1.1772, 11670801700, 0.25 +Res-1.1773, 11670801700, 0.25 +Res-1.1774, 11670801700, 0.25 +Res-1.1775, 11670801700, 0.25 +Res-1.1776, 11670801700, 0.25 +Res-1.1777, 11670801700, 0.25 +Res-1.1778, 11670801700, 0.25 +Res-1.1779, 11670801700, 0.25 +Res-1.1780, 11670801700, 0.25 +Res-1.1781, 11670801700, 0.25 +Res-1.1782, 11670801700, 0.25 +Res-1.1783, 11670801700, 0.25 +Res-1.1784, 11670801700, 0.25 +Res-1.1785, 11670801700, 0.25 +Res-1.1786, 11670801700, 0.25 +Res-1.1787, 11670801700, 0.25 +Res-1.1788, 11670801700, 0.25 +Res-1.1789, 11670801700, 0.25 +Res-1.1790, 11670801700, 0.25 +Res-1.1791, 11670801700, 0.25 +Res-1.1792, 11670801700, 0.25 +Res-1.1793, 11670801700, 0.25 +Res-1.1794, 11670801700, 0.25 +Res-1.1795, 11670801700, 0.25 +Res-1.1796, 11670801700, 0.25 +Res-1.1797, 11670801700, 0.25 +Res-1.1798, 11670801700, 0.25 +Res-1.1799, 11670801700, 0.25 +Res-1.1800, 11670801700, 0.25 +Res-1.1801, 11670801700, 0.25 +Res-1.1802, 11670801700, 0.25 +Res-1.1803, 11670801700, 0.25 +Res-1.1804, 11670801700, 0.25 +Res-1.1805, 11670801700, 0.25 +Res-1.1806, 11670801700, 0.25 +Res-1.1807, 11670801700, 0.25 +Res-1.1808, 11670801700, 0.25 +Res-1.1809, 11670801700, 0.25 +Res-1.1810, 11670801700, 0.25 +Res-1.1811, 11670801700, 0.25 +Res-1.1812, 11670801700, 0.25 +Res-1.1813, 11670801700, 0.25 +Res-1.1814, 11670801700, 0.25 +Res-1.1815, 11670801700, 0.25 +Res-1.1816, 11670801700, 0.25 +Res-1.1817, 11670801700, 0.25 +Res-1.1818, 11670801700, 0.25 +Res-1.1819, 11670801700, 0.25 +Res-1.1820, 11670801700, 0.25 +Res-1.1821, 11670801700, 0.25 +Res-1.1822, 11670801700, 0.25 +Res-1.1823, 11670801700, 0.25 +Res-1.1824, 11670801700, 0.25 +Res-1.1825, 11670801700, 0.25 +Res-1.1826, 11670801700, 0.25 +Res-1.1827, 11670801700, 0.25 +Res-1.1828, 11670801700, 0.25 +Res-1.1829, 11670801700, 0.25 +Res-1.1830, 11670801700, 0.25 +Res-1.1831, 11670801700, 0.25 +Res-1.1832, 11670801700, 0.25 +Res-1.1833, 11670801700, 0.25 +Res-1.1834, 11670801700, 0.25 +Res-1.1835, 11670801700, 0.25 +Res-1.1836, 11670801700, 0.25 +Res-1.1837, 11670801700, 0.25 +Res-1.1838, 11670801700, 0.25 +Res-1.1839, 11670801700, 0.25 +Res-1.1840, 11670801700, 0.25 +Res-1.1841, 11670801700, 0.25 +Res-1.1842, 11670801700, 0.25 +Res-1.1843, 11670801700, 0.25 +Res-1.1844, 11670801700, 0.25 +Res-1.1845, 11670801700, 0.25 +Res-1.1846, 11670801700, 0.25 +Res-1.1847, 11670801700, 0.25 +Res-1.1848, 11670801700, 0.25 +Res-1.1849, 11670801700, 0.25 +Res-1.1850, 11670801700, 0.25 +Res-1.1851, 11670801700, 0.25 +Res-1.1852, 11670801700, 0.25 +Res-1.1853, 11670801700, 0.25 +Res-1.1854, 11670801700, 0.25 +Res-1.1855, 11670801700, 0.25 +Res-1.1856, 11670801700, 0.25 +Res-1.1857, 11670801700, 0.25 +Res-1.1858, 11670801700, 0.25 +Res-1.1859, 11670801700, 0.25 +Res-1.1860, 11670801700, 0.25 +Res-1.1861, 11670801700, 0.25 +Res-1.1862, 11670801700, 0.25 +Res-1.1863, 11670801700, 0.25 +Res-1.1864, 11670801700, 0.25 +Res-1.1865, 11670801700, 0.25 +Res-1.1866, 11670801700, 0.25 +Res-1.1867, 11670801700, 0.25 +Res-1.1868, 11670801700, 0.25 +Res-1.1869, 11670801700, 0.25 +Res-1.1870, 11670801700, 0.25 +Res-1.1871, 11670801700, 0.25 +Res-1.1872, 11670801700, 0.25 +Res-1.1873, 11670801700, 0.25 +Res-1.1874, 11670801700, 0.25 +Res-1.1875, 11670801700, 0.25 +Res-1.1876, 11670801700, 0.25 +Res-1.1877, 11670801700, 0.25 +Res-1.1878, 11670801700, 0.25 +Res-1.1879, 11670801700, 0.25 +Res-1.1880, 11670801700, 0.25 +Res-1.1881, 11670801700, 0.25 +Res-1.1882, 11670801700, 0.25 +Res-1.1883, 11670801700, 0.25 +Res-1.1884, 11670801700, 0.25 +Res-1.1885, 11670801700, 0.25 +Res-1.1886, 11670801700, 0.25 +Res-1.1887, 11670801700, 0.25 +Res-1.1888, 11670801700, 0.25 +Res-1.1889, 11670801700, 0.25 +Res-1.1890, 11670801700, 0.25 +Res-1.1891, 11670801700, 0.25 +Res-1.1892, 11670801700, 0.25 +Res-1.1893, 11670801700, 0.25 +Res-1.1894, 11670801700, 0.25 +Res-1.1895, 11670801700, 0.25 +Res-1.1896, 11670801700, 0.25 +Res-1.1897, 11670801700, 0.25 +Res-1.1898, 11670801700, 0.25 +Res-1.1899, 11670801700, 0.25 +Res-1.1900, 11670801700, 0.25 +Res-1.1901, 11670801700, 0.25 +Res-1.1902, 11670801700, 0.25 +Res-1.1903, 11670801700, 0.25 +Res-1.1904, 11670801700, 0.25 +Res-1.1905, 11670801700, 0.25 +Res-1.1906, 11670801700, 0.25 +Res-1.1907, 11670801700, 0.25 +Res-1.1908, 11670801700, 0.25 +Res-1.1909, 11670801700, 0.25 +Res-1.1910, 11670801700, 0.25 +Res-1.1911, 11670801700, 0.25 +Res-1.1912, 11670801700, 0.25 +Res-1.1913, 11670801700, 0.25 +Res-1.1914, 11670801700, 0.25 +Res-1.1915, 11670801700, 0.25 +Res-1.1916, 11670801700, 0.25 +Res-1.1917, 11670801700, 0.25 +Res-1.1918, 11670801700, 0.25 +Res-1.1919, 11670801700, 0.25 +Res-1.1920, 11670801700, 0.25 +Res-1.1921, 11670801700, 0.25 +Res-1.1922, 11670801700, 0.25 +Res-1.1923, 11670801700, 0.25 +Res-1.1924, 11670801700, 0.25 +Res-1.1925, 11670801700, 0.25 +Res-1.1926, 11670801700, 0.25 +Res-1.1927, 11670801700, 0.25 +Res-1.1928, 11670801700, 0.25 +Res-1.1929, 11670801700, 0.25 +Res-1.1930, 11670801700, 0.25 +Res-1.1931, 11670801700, 0.25 +Res-1.1932, 11670801700, 0.25 +Res-1.1933, 11670801700, 0.25 +Res-1.1934, 11670801700, 0.25 +Res-1.1935, 11670801700, 0.25 +Res-1.1936, 11670801700, 0.25 +Res-1.1937, 11670801700, 0.25 +Res-1.1938, 11670801700, 0.25 +Res-1.1939, 11670801700, 0.25 +Res-1.1940, 11670801700, 0.25 +Res-1.1941, 11670801700, 0.25 +Res-1.1942, 11670801700, 0.25 +Res-1.1943, 11670801700, 0.25 +Res-1.1944, 11670801700, 0.25 +Res-1.1945, 11670801700, 0.25 +Res-1.1946, 11670801700, 0.25 +Res-1.1947, 11670801700, 0.25 +Res-1.1948, 11670801700, 0.25 +Res-1.1949, 11670801700, 0.25 +Res-1.1950, 11670801700, 0.25 +Res-1.1951, 11670801700, 0.25 +Res-1.1952, 11670801700, 0.25 +Res-1.1953, 11670801700, 0.25 +Res-1.1954, 11670801700, 0.25 +Res-1.1955, 11670801700, 0.25 +Res-1.1956, 11670801700, 0.25 +Res-1.1957, 11670801700, 0.25 +Res-1.1958, 11670801700, 0.25 +Res-1.1959, 11670801700, 0.25 +Res-1.1960, 11670801700, 0.25 +Res-1.1961, 11670801700, 0.25 +Res-1.1962, 11670801700, 0.25 +Res-1.1963, 11670801700, 0.25 +Res-1.1964, 11670801700, 0.25 +Res-1.1965, 11670801700, 0.25 +Res-1.1966, 11670801700, 0.25 +Res-1.1967, 11670801700, 0.25 +Res-1.1968, 11670801700, 0.25 +Res-1.1969, 11670801700, 0.25 +Res-1.1970, 11670801700, 0.25 +Res-1.1971, 11670801700, 0.25 +Res-1.1972, 11670801700, 0.25 +Res-1.1973, 11670801700, 0.25 +Res-1.1974, 11670801700, 0.25 +Res-1.1975, 11670801700, 0.25 +Res-1.1976, 11670801700, 0.25 +Res-1.1977, 11670801700, 0.25 +Res-1.1978, 11670801700, 0.25 +Res-1.1979, 11670801700, 0.25 +Res-1.1980, 11670801700, 0.25 +Res-1.1981, 11670801700, 0.25 +Res-1.1982, 11670801700, 0.25 +Res-1.1983, 11670801700, 0.25 +Res-1.1984, 11670801700, 0.25 +Res-1.1985, 11670801700, 0.25 +Res-1.1986, 11670801700, 0.25 +Res-1.1987, 11670801700, 0.25 +Res-1.1988, 11670801700, 0.25 +Res-1.1989, 11670801700, 0.25 +Res-1.1990, 11670801700, 0.25 +Res-1.1991, 11670801700, 0.25 +Res-1.1992, 11670801700, 0.25 +Res-1.1993, 11670801700, 0.25 +Res-1.1994, 11670801700, 0.25 +Res-1.1995, 11670801700, 0.25 +Res-1.1996, 11670801700, 0.25 +Res-1.1997, 11670801700, 0.25 +Res-1.1998, 11670801700, 0.25 +Res-1.1999, 11670801700, 0.25 +Res-1.2000, 11670801700, 0.25 +Res-1.2001, 11670801700, 0.25 +Res-1.2002, 11670801700, 0.25 +Res-1.2003, 11670801700, 0.25 +Res-1.2004, 11670801700, 0.25 +Res-1.2005, 11670801700, 0.25 +Res-1.2006, 11670801700, 0.25 +Res-1.2007, 11670801700, 0.25 +Res-1.2008, 11670801700, 0.25 +Res-1.2009, 11670801700, 0.25 +Res-1.2010, 11670801700, 0.25 +Res-1.2011, 11670801700, 0.25 +Res-1.2012, 11670801700, 0.25 +Res-1.2013, 11670801700, 0.25 +Res-1.2014, 11670801700, 0.25 +Res-1.2015, 11670801700, 0.25 +Res-1.2016, 11670801700, 0.25 +Res-1.2017, 6227222750, 0.25 +Res-1.2018, 6227222750, 0.25 +Res-1.2019, 6227222750, 0.25 +Res-1.2020, 6227222750, 0.25 +Res-1.2021, 6227222750, 0.25 +Res-1.2022, 6227222750, 0.25 +Res-1.2023, 6227222750, 0.25 +Res-1.2024, 6227222750, 0.25 +Res-1.2025, 6227222750, 0.25 +Res-1.2026, 6227222750, 0.25 +Res-1.2027, 6227222750, 0.25 +Res-1.2028, 6227222750, 0.25 +Res-1.2029, 6227222750, 0.25 +Res-1.2030, 6227222750, 0.25 +Res-1.2031, 6227222750, 0.25 +Res-1.2032, 6227222750, 0.25 +Res-1.2033, 6227222750, 0.25 +Res-1.2034, 6227222750, 0.25 +Res-1.2035, 6227222750, 0.25 +Res-1.2036, 6227222750, 0.25 +Res-1.2037, 6227222750, 0.25 +Res-1.2038, 6227222750, 0.25 +Res-1.2039, 6227222750, 0.25 +Res-1.2040, 6227222750, 0.25 +Res-1.2041, 6227222750, 0.25 +Res-1.2042, 6227222750, 0.25 +Res-1.2043, 6227222750, 0.25 +Res-1.2044, 6227222750, 0.25 +Res-1.2045, 6227222750, 0.25 +Res-1.2046, 6227222750, 0.25 +Res-1.2047, 6227222750, 0.25 +Res-1.2048, 6227222750, 0.25 +Res-1.2049, 6227222750, 0.25 +Res-1.2050, 6227222750, 0.25 +Res-1.2051, 6227222750, 0.25 +Res-1.2052, 6227222750, 0.25 +Res-1.2053, 6227222750, 0.25 +Res-1.2054, 6227222750, 0.25 +Res-1.2055, 6227222750, 0.25 +Res-1.2056, 6227222750, 0.25 +Res-1.2057, 6227222750, 0.25 +Res-1.2058, 6227222750, 0.25 +Res-1.2059, 6227222750, 0.25 +Res-1.2060, 6227222750, 0.25 +Res-1.2061, 6227222750, 0.25 +Res-1.2062, 6227222750, 0.25 +Res-1.2063, 6227222750, 0.25 +Res-1.2064, 6227222750, 0.25 +Res-1.2065, 6227222750, 0.25 +Res-1.2066, 6227222750, 0.25 +Res-1.2067, 6227222750, 0.25 +Res-1.2068, 6227222750, 0.25 +Res-1.2069, 6227222750, 0.25 +Res-1.2070, 6227222750, 0.25 +Res-1.2071, 6227222750, 0.25 +Res-1.2072, 6227222750, 0.25 +Res-1.2073, 6227222750, 0.25 +Res-1.2074, 6227222750, 0.25 +Res-1.2075, 6227222750, 0.25 +Res-1.2076, 6227222750, 0.25 +Res-1.2077, 6227222750, 0.25 +Res-1.2078, 6227222750, 0.25 +Res-1.2079, 6227222750, 0.25 +Res-1.2080, 6227222750, 0.25 +Res-1.2081, 6227222750, 0.25 +Res-1.2082, 6227222750, 0.25 +Res-1.2083, 6227222750, 0.25 +Res-1.2084, 6227222750, 0.25 +Res-1.2085, 6227222750, 0.25 +Res-1.2086, 6227222750, 0.25 +Res-1.2087, 6227222750, 0.25 +Res-1.2088, 6227222750, 0.25 +Res-1.2089, 6227222750, 0.25 +Res-1.2090, 6227222750, 0.25 +Res-1.2091, 6227222750, 0.25 +Res-1.2092, 6227222750, 0.25 +Res-1.2093, 6227222750, 0.25 +Res-1.2094, 6227222750, 0.25 +Res-1.2095, 6227222750, 0.25 +Res-1.2096, 6227222750, 0.25 +Res-1.2097, 6227222750, 0.25 +Res-1.2098, 6227222750, 0.25 +Res-1.2099, 6227222750, 0.25 +Res-1.2100, 6227222750, 0.25 +Res-1.2101, 6227222750, 0.25 +Res-1.2102, 6227222750, 0.25 +Res-1.2103, 6227222750, 0.25 +Res-1.2104, 6227222750, 0.25 +Res-1.2105, 6227222750, 0.25 +Res-1.2106, 6227222750, 0.25 +Res-1.2107, 6227222750, 0.25 +Res-1.2108, 6227222750, 0.25 +Res-1.2109, 6227222750, 0.25 +Res-1.2110, 6227222750, 0.25 +Res-1.2111, 6227222750, 0.25 +Res-1.2112, 6227222750, 0.25 +Res-1.2113, 6227222750, 0.25 +Res-1.2114, 6227222750, 0.25 +Res-1.2115, 6227222750, 0.25 +Res-1.2116, 6227222750, 0.25 +Res-1.2117, 6227222750, 0.25 +Res-1.2118, 6227222750, 0.25 +Res-1.2119, 6227222750, 0.25 +Res-1.2120, 6227222750, 0.25 +Res-1.2121, 6227222750, 0.25 +Res-1.2122, 6227222750, 0.25 +Res-1.2123, 6227222750, 0.25 +Res-1.2124, 6227222750, 0.25 +Res-1.2125, 6227222750, 0.25 +Res-1.2126, 6227222750, 0.25 +Res-1.2127, 6227222750, 0.25 +Res-1.2128, 6227222750, 0.25 +Res-1.2129, 6227222750, 0.25 +Res-1.2130, 6227222750, 0.25 +Res-1.2131, 6227222750, 0.25 +Res-1.2132, 6227222750, 0.25 +Res-1.2133, 6227222750, 0.25 +Res-1.2134, 6227222750, 0.25 +Res-1.2135, 6227222750, 0.25 +Res-1.2136, 6227222750, 0.25 +Res-1.2137, 6227222750, 0.25 +Res-1.2138, 6227222750, 0.25 +Res-1.2139, 6227222750, 0.25 +Res-1.2140, 6227222750, 0.25 +Res-1.2141, 6227222750, 0.25 +Res-1.2142, 6227222750, 0.25 +Res-1.2143, 6227222750, 0.25 +Res-1.2144, 6227222750, 0.25 +Res-1.2145, 6227222750, 0.25 +Res-1.2146, 6227222750, 0.25 +Res-1.2147, 6227222750, 0.25 +Res-1.2148, 6227222750, 0.25 +Res-1.2149, 6227222750, 0.25 +Res-1.2150, 6227222750, 0.25 +Res-1.2151, 6227222750, 0.25 +Res-1.2152, 6227222750, 0.25 +Res-1.2153, 6227222750, 0.25 +Res-1.2154, 6227222750, 0.25 +Res-1.2155, 6227222750, 0.25 +Res-1.2156, 6227222750, 0.25 +Res-1.2157, 6227222750, 0.25 +Res-1.2158, 6227222750, 0.25 +Res-1.2159, 6227222750, 0.25 +Res-1.2160, 6227222750, 0.25 +Res-1.2161, 6227222750, 0.25 +Res-1.2162, 6227222750, 0.25 +Res-1.2163, 6227222750, 0.25 +Res-1.2164, 6227222750, 0.25 +Res-1.2165, 6227222750, 0.25 +Res-1.2166, 6227222750, 0.25 +Res-1.2167, 6227222750, 0.25 +Res-1.2168, 6227222750, 0.25 +Res-1.2169, 6227222750, 0.25 +Res-1.2170, 6227222750, 0.25 +Res-1.2171, 6227222750, 0.25 +Res-1.2172, 6227222750, 0.25 +Res-1.2173, 6227222750, 0.25 +Res-1.2174, 6227222750, 0.25 +Res-1.2175, 6227222750, 0.25 +Res-1.2176, 6227222750, 0.25 +Res-1.2177, 6227222750, 0.25 +Res-1.2178, 6227222750, 0.25 +Res-1.2179, 6227222750, 0.25 +Res-1.2180, 6227222750, 0.25 +Res-1.2181, 6227222750, 0.25 +Res-1.2182, 6227222750, 0.25 +Res-1.2183, 6227222750, 0.25 +Res-1.2184, 6227222750, 0.25 +Res-1.2185, 6227222750, 0.25 +Res-1.2186, 6227222750, 0.25 +Res-1.2187, 6227222750, 0.25 +Res-1.2188, 6227222750, 0.25 +Res-1.2189, 6227222750, 0.25 +Res-1.2190, 6227222750, 0.25 +Res-1.2191, 6227222750, 0.25 +Res-1.2192, 6227222750, 0.25 +Res-1.2193, 6227222750, 0.25 +Res-1.2194, 6227222750, 0.25 +Res-1.2195, 6227222750, 0.25 +Res-1.2196, 6227222750, 0.25 +Res-1.2197, 6227222750, 0.25 +Res-1.2198, 6227222750, 0.25 +Res-1.2199, 6227222750, 0.25 +Res-1.2200, 6227222750, 0.25 +Res-1.2201, 6227222750, 0.25 +Res-1.2202, 6227222750, 0.25 +Res-1.2203, 6227222750, 0.25 +Res-1.2204, 6227222750, 0.25 +Res-1.2205, 6227222750, 0.25 +Res-1.2206, 6227222750, 0.25 +Res-1.2207, 6227222750, 0.25 +Res-1.2208, 6227222750, 0.25 +Res-1.2209, 6227222750, 0.25 +Res-1.2210, 6227222750, 0.25 +Res-1.2211, 6227222750, 0.25 +Res-1.2212, 6227222750, 0.25 +Res-1.2213, 6227222750, 0.25 +Res-1.2214, 6227222750, 0.25 +Res-1.2215, 6227222750, 0.25 +Res-1.2216, 6227222750, 0.25 +Res-1.2217, 6227222750, 0.25 +Res-1.2218, 6227222750, 0.25 +Res-1.2219, 6227222750, 0.25 +Res-1.2220, 6227222750, 0.25 +Res-1.2221, 6227222750, 0.25 +Res-1.2222, 6227222750, 0.25 +Res-1.2223, 6227222750, 0.25 +Res-1.2224, 6227222750, 0.25 +Res-1.2225, 6227222750, 0.25 +Res-1.2226, 6227222750, 0.25 +Res-1.2227, 6227222750, 0.25 +Res-1.2228, 6227222750, 0.25 +Res-1.2229, 6227222750, 0.25 +Res-1.2230, 6227222750, 0.25 +Res-1.2231, 6227222750, 0.25 +Res-1.2232, 6227222750, 0.25 +Res-1.2233, 6227222750, 0.25 +Res-1.2234, 6227222750, 0.25 +Res-1.2235, 6227222750, 0.25 +Res-1.2236, 6227222750, 0.25 +Res-1.2237, 6227222750, 0.25 +Res-1.2238, 6227222750, 0.25 +Res-1.2239, 6227222750, 0.25 +Res-1.2240, 6227222750, 0.25 +Res-1.2241, 6227222750, 0.25 +Res-1.2242, 6227222750, 0.25 +Res-1.2243, 6227222750, 0.25 +Res-1.2244, 6227222750, 0.25 +Res-1.2245, 6227222750, 0.25 +Res-1.2246, 6227222750, 0.25 +Res-1.2247, 6227222750, 0.25 +Res-1.2248, 6227222750, 0.25 +Res-1.2249, 6227222750, 0.25 +Res-1.2250, 6227222750, 0.25 +Res-1.2251, 6227222750, 0.25 +Res-1.2252, 6227222750, 0.25 +Res-1.2253, 6227222750, 0.25 +Res-1.2254, 6227222750, 0.25 +Res-1.2255, 6227222750, 0.25 +Res-1.2256, 6227222750, 0.25 +Res-1.2257, 6227222750, 0.25 +Res-1.2258, 6227222750, 0.25 +Res-1.2259, 6227222750, 0.25 +Res-1.2260, 6227222750, 0.25 +Res-1.2261, 6227222750, 0.25 +Res-1.2262, 6227222750, 0.25 +Res-1.2263, 6227222750, 0.25 +Res-1.2264, 6227222750, 0.25 +Res-1.2265, 6227222750, 0.25 +Res-1.2266, 6227222750, 0.25 +Res-1.2267, 6227222750, 0.25 +Res-1.2268, 6227222750, 0.25 +Res-1.2269, 6227222750, 0.25 +Res-1.2270, 6227222750, 0.25 +Res-1.2271, 6227222750, 0.25 +Res-1.2272, 6227222750, 0.25 +Res-1.2273, 6227222750, 0.25 +Res-1.2274, 6227222750, 0.25 +Res-1.2275, 6227222750, 0.25 +Res-1.2276, 6227222750, 0.25 +Res-1.2277, 6227222750, 0.25 +Res-1.2278, 6227222750, 0.25 +Res-1.2279, 6227222750, 0.25 +Res-1.2280, 6227222750, 0.25 +Res-1.2281, 6227222750, 0.25 +Res-1.2282, 6227222750, 0.25 +Res-1.2283, 6227222750, 0.25 +Res-1.2284, 6227222750, 0.25 +Res-1.2285, 6227222750, 0.25 +Res-1.2286, 6227222750, 0.25 +Res-1.2287, 6227222750, 0.25 +Res-1.2288, 6227222750, 0.25 +Res-1.2289, 6227222750, 0.25 +Res-1.2290, 6227222750, 0.25 +Res-1.2291, 6227222750, 0.25 +Res-1.2292, 6227222750, 0.25 +Res-1.2293, 6227222750, 0.25 +Res-1.2294, 6227222750, 0.25 +Res-1.2295, 6227222750, 0.25 +Res-1.2296, 6227222750, 0.25 +Res-1.2297, 6227222750, 0.25 +Res-1.2298, 6227222750, 0.25 +Res-1.2299, 6227222750, 0.25 +Res-1.2300, 6227222750, 0.25 +Res-1.2301, 6227222750, 0.25 +Res-1.2302, 6227222750, 0.25 +Res-1.2303, 6227222750, 0.25 +Res-1.2304, 6227222750, 0.25 +Res-1.2305, 6439192352.5, 0.25 +Res-1.2306, 6439192352.5, 0.25 +Res-1.2307, 6439192352.5, 0.25 +Res-1.2308, 6439192352.5, 0.25 +Res-1.2309, 6439192352.5, 0.25 +Res-1.2310, 6439192352.5, 0.25 +Res-1.2311, 6439192352.5, 0.25 +Res-1.2312, 6439192352.5, 0.25 +Res-1.2313, 6439192352.5, 0.25 +Res-1.2314, 6439192352.5, 0.25 +Res-1.2315, 6439192352.5, 0.25 +Res-1.2316, 6439192352.5, 0.25 +Res-1.2317, 6439192352.5, 0.25 +Res-1.2318, 6439192352.5, 0.25 +Res-1.2319, 6439192352.5, 0.25 +Res-1.2320, 6439192352.5, 0.25 +Res-1.2321, 6439192352.5, 0.25 +Res-1.2322, 6439192352.5, 0.25 +Res-1.2323, 6439192352.5, 0.25 +Res-1.2324, 6439192352.5, 0.25 +Res-1.2325, 6439192352.5, 0.25 +Res-1.2326, 6439192352.5, 0.25 +Res-1.2327, 6439192352.5, 0.25 +Res-1.2328, 6439192352.5, 0.25 +Res-1.2329, 6439192352.5, 0.25 +Res-1.2330, 6439192352.5, 0.25 +Res-1.2331, 6439192352.5, 0.25 +Res-1.2332, 6439192352.5, 0.25 +Res-1.2333, 6439192352.5, 0.25 +Res-1.2334, 6439192352.5, 0.25 +Res-1.2335, 6439192352.5, 0.25 +Res-1.2336, 6439192352.5, 0.25 +Res-1.2337, 6439192352.5, 0.25 +Res-1.2338, 6439192352.5, 0.25 +Res-1.2339, 6439192352.5, 0.25 +Res-1.2340, 6439192352.5, 0.25 +Res-1.2341, 6439192352.5, 0.25 +Res-1.2342, 6439192352.5, 0.25 +Res-1.2343, 6439192352.5, 0.25 +Res-1.2344, 6439192352.5, 0.25 +Res-1.2345, 6439192352.5, 0.25 +Res-1.2346, 6439192352.5, 0.25 +Res-1.2347, 6439192352.5, 0.25 +Res-1.2348, 6439192352.5, 0.25 +Res-1.2349, 6439192352.5, 0.25 +Res-1.2350, 6439192352.5, 0.25 +Res-1.2351, 6439192352.5, 0.25 +Res-1.2352, 6439192352.5, 0.25 +Res-1.2353, 6439192352.5, 0.25 +Res-1.2354, 6439192352.5, 0.25 +Res-1.2355, 6439192352.5, 0.25 +Res-1.2356, 6439192352.5, 0.25 +Res-1.2357, 6439192352.5, 0.25 +Res-1.2358, 6439192352.5, 0.25 +Res-1.2359, 6439192352.5, 0.25 +Res-1.2360, 6439192352.5, 0.25 +Res-1.2361, 6439192352.5, 0.25 +Res-1.2362, 6439192352.5, 0.25 +Res-1.2363, 6439192352.5, 0.25 +Res-1.2364, 6439192352.5, 0.25 +Res-1.2365, 6439192352.5, 0.25 +Res-1.2366, 6439192352.5, 0.25 +Res-1.2367, 6439192352.5, 0.25 +Res-1.2368, 6439192352.5, 0.25 +Res-1.2369, 6439192352.5, 0.25 +Res-1.2370, 6439192352.5, 0.25 +Res-1.2371, 6439192352.5, 0.25 +Res-1.2372, 6439192352.5, 0.25 +Res-1.2373, 6439192352.5, 0.25 +Res-1.2374, 6439192352.5, 0.25 +Res-1.2375, 6439192352.5, 0.25 +Res-1.2376, 6439192352.5, 0.25 +Res-1.2377, 6439192352.5, 0.25 +Res-1.2378, 6439192352.5, 0.25 +Res-1.2379, 6439192352.5, 0.25 +Res-1.2380, 6439192352.5, 0.25 +Res-1.2381, 6439192352.5, 0.25 +Res-1.2382, 6439192352.5, 0.25 +Res-1.2383, 6439192352.5, 0.25 +Res-1.2384, 6439192352.5, 0.25 +Res-1.2385, 6439192352.5, 0.25 +Res-1.2386, 6439192352.5, 0.25 +Res-1.2387, 6439192352.5, 0.25 +Res-1.2388, 6439192352.5, 0.25 +Res-1.2389, 6439192352.5, 0.25 +Res-1.2390, 6439192352.5, 0.25 +Res-1.2391, 6439192352.5, 0.25 +Res-1.2392, 6439192352.5, 0.25 +Res-1.2393, 6439192352.5, 0.25 +Res-1.2394, 6439192352.5, 0.25 +Res-1.2395, 6439192352.5, 0.25 +Res-1.2396, 6439192352.5, 0.25 +Res-1.2397, 6439192352.5, 0.25 +Res-1.2398, 6439192352.5, 0.25 +Res-1.2399, 6439192352.5, 0.25 +Res-1.2400, 6439192352.5, 0.25 +Res-1.2401, 6439192352.5, 0.25 +Res-1.2402, 6439192352.5, 0.25 +Res-1.2403, 6439192352.5, 0.25 +Res-1.2404, 6439192352.5, 0.25 +Res-1.2405, 6439192352.5, 0.25 +Res-1.2406, 6439192352.5, 0.25 +Res-1.2407, 6439192352.5, 0.25 +Res-1.2408, 6439192352.5, 0.25 +Res-1.2409, 6439192352.5, 0.25 +Res-1.2410, 6439192352.5, 0.25 +Res-1.2411, 6439192352.5, 0.25 +Res-1.2412, 6439192352.5, 0.25 +Res-1.2413, 6439192352.5, 0.25 +Res-1.2414, 6439192352.5, 0.25 +Res-1.2415, 6439192352.5, 0.25 +Res-1.2416, 6439192352.5, 0.25 +Res-1.2417, 6439192352.5, 0.25 +Res-1.2418, 6439192352.5, 0.25 +Res-1.2419, 6439192352.5, 0.25 +Res-1.2420, 6439192352.5, 0.25 +Res-1.2421, 6439192352.5, 0.25 +Res-1.2422, 6439192352.5, 0.25 +Res-1.2423, 6439192352.5, 0.25 +Res-1.2424, 6439192352.5, 0.25 +Res-1.2425, 6439192352.5, 0.25 +Res-1.2426, 6439192352.5, 0.25 +Res-1.2427, 6439192352.5, 0.25 +Res-1.2428, 6439192352.5, 0.25 +Res-1.2429, 6439192352.5, 0.25 +Res-1.2430, 6439192352.5, 0.25 +Res-1.2431, 6439192352.5, 0.25 +Res-1.2432, 6439192352.5, 0.25 +Res-1.2433, 6439192352.5, 0.25 +Res-1.2434, 6439192352.5, 0.25 +Res-1.2435, 6439192352.5, 0.25 +Res-1.2436, 6439192352.5, 0.25 +Res-1.2437, 6439192352.5, 0.25 +Res-1.2438, 6439192352.5, 0.25 +Res-1.2439, 6439192352.5, 0.25 +Res-1.2440, 6439192352.5, 0.25 +Res-1.2441, 6439192352.5, 0.25 +Res-1.2442, 6439192352.5, 0.25 +Res-1.2443, 6439192352.5, 0.25 +Res-1.2444, 6439192352.5, 0.25 +Res-1.2445, 6439192352.5, 0.25 +Res-1.2446, 6439192352.5, 0.25 +Res-1.2447, 6439192352.5, 0.25 +Res-1.2448, 6439192352.5, 0.25 +Res-1.2449, 6439192352.5, 0.25 +Res-1.2450, 6439192352.5, 0.25 +Res-1.2451, 6439192352.5, 0.25 +Res-1.2452, 6439192352.5, 0.25 +Res-1.2453, 6439192352.5, 0.25 +Res-1.2454, 6439192352.5, 0.25 +Res-1.2455, 6439192352.5, 0.25 +Res-1.2456, 6439192352.5, 0.25 +Res-1.2457, 6439192352.5, 0.25 +Res-1.2458, 6439192352.5, 0.25 +Res-1.2459, 6439192352.5, 0.25 +Res-1.2460, 6439192352.5, 0.25 +Res-1.2461, 6439192352.5, 0.25 +Res-1.2462, 6439192352.5, 0.25 +Res-1.2463, 6439192352.5, 0.25 +Res-1.2464, 6439192352.5, 0.25 +Res-1.2465, 6439192352.5, 0.25 +Res-1.2466, 6439192352.5, 0.25 +Res-1.2467, 6439192352.5, 0.25 +Res-1.2468, 6439192352.5, 0.25 +Res-1.2469, 6439192352.5, 0.25 +Res-1.2470, 6439192352.5, 0.25 +Res-1.2471, 6439192352.5, 0.25 +Res-1.2472, 6439192352.5, 0.25 +Res-1.2473, 6439192352.5, 0.25 +Res-1.2474, 6439192352.5, 0.25 +Res-1.2475, 6439192352.5, 0.25 +Res-1.2476, 6439192352.5, 0.25 +Res-1.2477, 6439192352.5, 0.25 +Res-1.2478, 6439192352.5, 0.25 +Res-1.2479, 6439192352.5, 0.25 +Res-1.2480, 6439192352.5, 0.25 +Res-1.2481, 6439192352.5, 0.25 +Res-1.2482, 6439192352.5, 0.25 +Res-1.2483, 6439192352.5, 0.25 +Res-1.2484, 6439192352.5, 0.25 +Res-1.2485, 6439192352.5, 0.25 +Res-1.2486, 6439192352.5, 0.25 +Res-1.2487, 6439192352.5, 0.25 +Res-1.2488, 6439192352.5, 0.25 +Res-1.2489, 6439192352.5, 0.25 +Res-1.2490, 6439192352.5, 0.25 +Res-1.2491, 6439192352.5, 0.25 +Res-1.2492, 6439192352.5, 0.25 +Res-1.2493, 6439192352.5, 0.25 +Res-1.2494, 6439192352.5, 0.25 +Res-1.2495, 6439192352.5, 0.25 +Res-1.2496, 6439192352.5, 0.25 +Res-1.2497, 6439192352.5, 0.25 +Res-1.2498, 6439192352.5, 0.25 +Res-1.2499, 6439192352.5, 0.25 +Res-1.2500, 6439192352.5, 0.25 +Res-1.2501, 6439192352.5, 0.25 +Res-1.2502, 6439192352.5, 0.25 +Res-1.2503, 6439192352.5, 0.25 +Res-1.2504, 6439192352.5, 0.25 +Res-1.2505, 6439192352.5, 0.25 +Res-1.2506, 6439192352.5, 0.25 +Res-1.2507, 6439192352.5, 0.25 +Res-1.2508, 6439192352.5, 0.25 +Res-1.2509, 6439192352.5, 0.25 +Res-1.2510, 6439192352.5, 0.25 +Res-1.2511, 6439192352.5, 0.25 +Res-1.2512, 6439192352.5, 0.25 +Res-1.2513, 6439192352.5, 0.25 +Res-1.2514, 6439192352.5, 0.25 +Res-1.2515, 6439192352.5, 0.25 +Res-1.2516, 6439192352.5, 0.25 +Res-1.2517, 6439192352.5, 0.25 +Res-1.2518, 6439192352.5, 0.25 +Res-1.2519, 6439192352.5, 0.25 +Res-1.2520, 6439192352.5, 0.25 +Res-1.2521, 6439192352.5, 0.25 +Res-1.2522, 6439192352.5, 0.25 +Res-1.2523, 6439192352.5, 0.25 +Res-1.2524, 6439192352.5, 0.25 +Res-1.2525, 6439192352.5, 0.25 +Res-1.2526, 6439192352.5, 0.25 +Res-1.2527, 6439192352.5, 0.25 +Res-1.2528, 6439192352.5, 0.25 +Res-1.2529, 6439192352.5, 0.25 +Res-1.2530, 6439192352.5, 0.25 +Res-1.2531, 6439192352.5, 0.25 +Res-1.2532, 6439192352.5, 0.25 +Res-1.2533, 6439192352.5, 0.25 +Res-1.2534, 6439192352.5, 0.25 +Res-1.2535, 6439192352.5, 0.25 +Res-1.2536, 6439192352.5, 0.25 +Res-1.2537, 6439192352.5, 0.25 +Res-1.2538, 6439192352.5, 0.25 +Res-1.2539, 6439192352.5, 0.25 +Res-1.2540, 6439192352.5, 0.25 +Res-1.2541, 6439192352.5, 0.25 +Res-1.2542, 6439192352.5, 0.25 +Res-1.2543, 6439192352.5, 0.25 +Res-1.2544, 6439192352.5, 0.25 +Res-1.2545, 6439192352.5, 0.25 +Res-1.2546, 6439192352.5, 0.25 +Res-1.2547, 6439192352.5, 0.25 +Res-1.2548, 6439192352.5, 0.25 +Res-1.2549, 6439192352.5, 0.25 +Res-1.2550, 6439192352.5, 0.25 +Res-1.2551, 6439192352.5, 0.25 +Res-1.2552, 6439192352.5, 0.25 +Res-1.2553, 6439192352.5, 0.25 +Res-1.2554, 6439192352.5, 0.25 +Res-1.2555, 6439192352.5, 0.25 +Res-1.2556, 6439192352.5, 0.25 +Res-1.2557, 6439192352.5, 0.25 +Res-1.2558, 6439192352.5, 0.25 +Res-1.2559, 6439192352.5, 0.25 +Res-1.2560, 6439192352.5, 0.25 +Res-1.2561, 6439192352.5, 0.25 +Res-1.2562, 6439192352.5, 0.25 +Res-1.2563, 6439192352.5, 0.25 +Res-1.2564, 6439192352.5, 0.25 +Res-1.2565, 6439192352.5, 0.25 +Res-1.2566, 6439192352.5, 0.25 +Res-1.2567, 6439192352.5, 0.25 +Res-1.2568, 6439192352.5, 0.25 +Res-1.2569, 6439192352.5, 0.25 +Res-1.2570, 6439192352.5, 0.25 +Res-1.2571, 6439192352.5, 0.25 +Res-1.2572, 6439192352.5, 0.25 +Res-1.2573, 6439192352.5, 0.25 +Res-1.2574, 6439192352.5, 0.25 +Res-1.2575, 6439192352.5, 0.25 +Res-1.2576, 6439192352.5, 0.25 +Res-1.2577, 6439192352.5, 0.25 +Res-1.2578, 6439192352.5, 0.25 +Res-1.2579, 6439192352.5, 0.25 +Res-1.2580, 6439192352.5, 0.25 +Res-1.2581, 6439192352.5, 0.25 +Res-1.2582, 6439192352.5, 0.25 +Res-1.2583, 6439192352.5, 0.25 +Res-1.2584, 6439192352.5, 0.25 +Res-1.2585, 6439192352.5, 0.25 +Res-1.2586, 6439192352.5, 0.25 +Res-1.2587, 6439192352.5, 0.25 +Res-1.2588, 6439192352.5, 0.25 +Res-1.2589, 6439192352.5, 0.25 +Res-1.2590, 6439192352.5, 0.25 +Res-1.2591, 6439192352.5, 0.25 +Res-1.2592, 6439192352.5, 0.25 +Res-1.2593, 5316491363.7363, 0.25 +Res-1.2594, 5316491363.7363, 0.25 +Res-1.2595, 5316491363.7363, 0.25 +Res-1.2596, 5316491363.7363, 0.25 +Res-1.2597, 5316491363.7363, 0.25 +Res-1.2598, 5316491363.7363, 0.25 +Res-1.2599, 5316491363.7363, 0.25 +Res-1.2600, 5316491363.7363, 0.25 +Res-1.2601, 5316491363.7363, 0.25 +Res-1.2602, 5316491363.7363, 0.25 +Res-1.2603, 5316491363.7363, 0.25 +Res-1.2604, 5316491363.7363, 0.25 +Res-1.2605, 5316491363.7363, 0.25 +Res-1.2606, 5316491363.7363, 0.25 +Res-1.2607, 5316491363.7363, 0.25 +Res-1.2608, 5316491363.7363, 0.25 +Res-1.2609, 5316491363.7363, 0.25 +Res-1.2610, 5316491363.7363, 0.25 +Res-1.2611, 5316491363.7363, 0.25 +Res-1.2612, 5316491363.7363, 0.25 +Res-1.2613, 5316491363.7363, 0.25 +Res-1.2614, 5316491363.7363, 0.25 +Res-1.2615, 5316491363.7363, 0.25 +Res-1.2616, 5316491363.7363, 0.25 +Res-1.2617, 5316491363.7363, 0.25 +Res-1.2618, 5316491363.7363, 0.25 +Res-1.2619, 5316491363.7363, 0.25 +Res-1.2620, 5316491363.7363, 0.25 +Res-1.2621, 5316491363.7363, 0.25 +Res-1.2622, 5316491363.7363, 0.25 +Res-1.2623, 5316491363.7363, 0.25 +Res-1.2624, 5316491363.7363, 0.25 +Res-1.2625, 5316491363.7363, 0.25 +Res-1.2626, 5316491363.7363, 0.25 +Res-1.2627, 5316491363.7363, 0.25 +Res-1.2628, 5316491363.7363, 0.25 +Res-1.2629, 5316491363.7363, 0.25 +Res-1.2630, 5316491363.7363, 0.25 +Res-1.2631, 5316491363.7363, 0.25 +Res-1.2632, 5316491363.7363, 0.25 +Res-1.2633, 5316491363.7363, 0.25 +Res-1.2634, 5316491363.7363, 0.25 +Res-1.2635, 5316491363.7363, 0.25 +Res-1.2636, 5316491363.7363, 0.25 +Res-1.2637, 5316491363.7363, 0.25 +Res-1.2638, 5316491363.7363, 0.25 +Res-1.2639, 5316491363.7363, 0.25 +Res-1.2640, 5316491363.7363, 0.25 +Res-1.2641, 5316491363.7363, 0.25 +Res-1.2642, 5316491363.7363, 0.25 +Res-1.2643, 5316491363.7363, 0.25 +Res-1.2644, 5316491363.7363, 0.25 +Res-1.2645, 5316491363.7363, 0.25 +Res-1.2646, 5316491363.7363, 0.25 +Res-1.2647, 5316491363.7363, 0.25 +Res-1.2648, 5316491363.7363, 0.25 +Res-1.2649, 5316491363.7363, 0.25 +Res-1.2650, 5316491363.7363, 0.25 +Res-1.2651, 5316491363.7363, 0.25 +Res-1.2652, 5316491363.7363, 0.25 +Res-1.2653, 5316491363.7363, 0.25 +Res-1.2654, 5316491363.7363, 0.25 +Res-1.2655, 5316491363.7363, 0.25 +Res-1.2656, 5316491363.7363, 0.25 +Res-1.2657, 5316491363.7363, 0.25 +Res-1.2658, 5316491363.7363, 0.25 +Res-1.2659, 5316491363.7363, 0.25 +Res-1.2660, 5316491363.7363, 0.25 +Res-1.2661, 5316491363.7363, 0.25 +Res-1.2662, 5316491363.7363, 0.25 +Res-1.2663, 5316491363.7363, 0.25 +Res-1.2664, 5316491363.7363, 0.25 +Res-1.2665, 5316491363.7363, 0.25 +Res-1.2666, 5316491363.7363, 0.25 +Res-1.2667, 5316491363.7363, 0.25 +Res-1.2668, 5316491363.7363, 0.25 +Res-1.2669, 5316491363.7363, 0.25 +Res-1.2670, 5316491363.7363, 0.25 +Res-1.2671, 5316491363.7363, 0.25 +Res-1.2672, 5316491363.7363, 0.25 +Res-1.2673, 5316491363.7363, 0.25 +Res-1.2674, 5316491363.7363, 0.25 +Res-1.2675, 5316491363.7363, 0.25 +Res-1.2676, 5316491363.7363, 0.25 +Res-1.2677, 5316491363.7363, 0.25 +Res-1.2678, 5316491363.7363, 0.25 +Res-1.2679, 5316491363.7363, 0.25 +Res-1.2680, 5316491363.7363, 0.25 +Res-1.2681, 5316491363.7363, 0.25 +Res-1.2682, 5316491363.7363, 0.25 +Res-1.2683, 5316491363.7363, 0.25 +Res-1.2684, 5316491363.7363, 0.25 +Res-1.2685, 5316491363.7363, 0.25 +Res-1.2686, 5316491363.7363, 0.25 +Res-1.2687, 5316491363.7363, 0.25 +Res-1.2688, 5316491363.7363, 0.25 +Res-1.2689, 5316491363.7363, 0.25 +Res-1.2690, 5316491363.7363, 0.25 +Res-1.2691, 5316491363.7363, 0.25 +Res-1.2692, 5316491363.7363, 0.25 +Res-1.2693, 5316491363.7363, 0.25 +Res-1.2694, 5316491363.7363, 0.25 +Res-1.2695, 5316491363.7363, 0.25 +Res-1.2696, 5316491363.7363, 0.25 +Res-1.2697, 5316491363.7363, 0.25 +Res-1.2698, 5316491363.7363, 0.25 +Res-1.2699, 5316491363.7363, 0.25 +Res-1.2700, 5316491363.7363, 0.25 +Res-1.2701, 5316491363.7363, 0.25 +Res-1.2702, 5316491363.7363, 0.25 +Res-1.2703, 5316491363.7363, 0.25 +Res-1.2704, 5316491363.7363, 0.25 +Res-1.2705, 5316491363.7363, 0.25 +Res-1.2706, 5316491363.7363, 0.25 +Res-1.2707, 5316491363.7363, 0.25 +Res-1.2708, 5316491363.7363, 0.25 +Res-1.2709, 5316491363.7363, 0.25 +Res-1.2710, 5316491363.7363, 0.25 +Res-1.2711, 5316491363.7363, 0.25 +Res-1.2712, 5316491363.7363, 0.25 +Res-1.2713, 5316491363.7363, 0.25 +Res-1.2714, 5316491363.7363, 0.25 +Res-1.2715, 5316491363.7363, 0.25 +Res-1.2716, 5316491363.7363, 0.25 +Res-1.2717, 5316491363.7363, 0.25 +Res-1.2718, 5316491363.7363, 0.25 +Res-1.2719, 5316491363.7363, 0.25 +Res-1.2720, 5316491363.7363, 0.25 +Res-1.2721, 5316491363.7363, 0.25 +Res-1.2722, 5316491363.7363, 0.25 +Res-1.2723, 5316491363.7363, 0.25 +Res-1.2724, 5316491363.7363, 0.25 +Res-1.2725, 5316491363.7363, 0.25 +Res-1.2726, 5316491363.7363, 0.25 +Res-1.2727, 5316491363.7363, 0.25 +Res-1.2728, 5316491363.7363, 0.25 +Res-1.2729, 5316491363.7363, 0.25 +Res-1.2730, 5316491363.7363, 0.25 +Res-1.2731, 5316491363.7363, 0.25 +Res-1.2732, 5316491363.7363, 0.25 +Res-1.2733, 5316491363.7363, 0.25 +Res-1.2734, 5316491363.7363, 0.25 +Res-1.2735, 5316491363.7363, 0.25 +Res-1.2736, 5316491363.7363, 0.25 +Res-1.2737, 5316491363.7363, 0.25 +Res-1.2738, 5316491363.7363, 0.25 +Res-1.2739, 5316491363.7363, 0.25 +Res-1.2740, 5316491363.7363, 0.25 +Res-1.2741, 5316491363.7363, 0.25 +Res-1.2742, 5316491363.7363, 0.25 +Res-1.2743, 5316491363.7363, 0.25 +Res-1.2744, 5316491363.7363, 0.25 +Res-1.2745, 5316491363.7363, 0.25 +Res-1.2746, 5316491363.7363, 0.25 +Res-1.2747, 5316491363.7363, 0.25 +Res-1.2748, 5316491363.7363, 0.25 +Res-1.2749, 5316491363.7363, 0.25 +Res-1.2750, 5316491363.7363, 0.25 +Res-1.2751, 5316491363.7363, 0.25 +Res-1.2752, 5316491363.7363, 0.25 +Res-1.2753, 5316491363.7363, 0.25 +Res-1.2754, 5316491363.7363, 0.25 +Res-1.2755, 5316491363.7363, 0.25 +Res-1.2756, 5316491363.7363, 0.25 +Res-1.2757, 5316491363.7363, 0.25 +Res-1.2758, 5316491363.7363, 0.25 +Res-1.2759, 5316491363.7363, 0.25 +Res-1.2760, 5316491363.7363, 0.25 +Res-1.2761, 5316491363.7363, 0.25 +Res-1.2762, 5316491363.7363, 0.25 +Res-1.2763, 5316491363.7363, 0.25 +Res-1.2764, 5316491363.7363, 0.25 +Res-1.2765, 5316491363.7363, 0.25 +Res-1.2766, 5316491363.7363, 0.25 +Res-1.2767, 5316491363.7363, 0.25 +Res-1.2768, 5316491363.7363, 0.25 +Res-1.2769, 5316491363.7363, 0.25 +Res-1.2770, 5316491363.7363, 0.25 +Res-1.2771, 5316491363.7363, 0.25 +Res-1.2772, 5316491363.7363, 0.25 +Res-1.2773, 5316491363.7363, 0.25 +Res-1.2774, 5316491363.7363, 0.25 +Res-1.2775, 5316491363.7363, 0.25 +Res-1.2776, 5316491363.7363, 0.25 +Res-1.2777, 5316491363.7363, 0.25 +Res-1.2778, 5316491363.7363, 0.25 +Res-1.2779, 5316491363.7363, 0.25 +Res-1.2780, 5316491363.7363, 0.25 +Res-1.2781, 5316491363.7363, 0.25 +Res-1.2782, 5316491363.7363, 0.25 +Res-1.2783, 5316491363.7363, 0.25 +Res-1.2784, 5316491363.7363, 0.25 +Res-1.2785, 5316491363.7363, 0.25 +Res-1.2786, 5316491363.7363, 0.25 +Res-1.2787, 5316491363.7363, 0.25 +Res-1.2788, 5316491363.7363, 0.25 +Res-1.2789, 5316491363.7363, 0.25 +Res-1.2790, 5316491363.7363, 0.25 +Res-1.2791, 5316491363.7363, 0.25 +Res-1.2792, 5316491363.7363, 0.25 +Res-1.2793, 5316491363.7363, 0.25 +Res-1.2794, 5316491363.7363, 0.25 +Res-1.2795, 5316491363.7363, 0.25 +Res-1.2796, 5316491363.7363, 0.25 +Res-1.2797, 5316491363.7363, 0.25 +Res-1.2798, 5316491363.7363, 0.25 +Res-1.2799, 5316491363.7363, 0.25 +Res-1.2800, 5316491363.7363, 0.25 +Res-1.2801, 5316491363.7363, 0.25 +Res-1.2802, 5316491363.7363, 0.25 +Res-1.2803, 5316491363.7363, 0.25 +Res-1.2804, 5316491363.7363, 0.25 +Res-1.2805, 5316491363.7363, 0.25 +Res-1.2806, 5316491363.7363, 0.25 +Res-1.2807, 5316491363.7363, 0.25 +Res-1.2808, 5316491363.7363, 0.25 +Res-1.2809, 5316491363.7363, 0.25 +Res-1.2810, 5316491363.7363, 0.25 +Res-1.2811, 5316491363.7363, 0.25 +Res-1.2812, 5316491363.7363, 0.25 +Res-1.2813, 5316491363.7363, 0.25 +Res-1.2814, 5316491363.7363, 0.25 +Res-1.2815, 5316491363.7363, 0.25 +Res-1.2816, 5316491363.7363, 0.25 +Res-1.2817, 5316491363.7363, 0.25 +Res-1.2818, 5316491363.7363, 0.25 +Res-1.2819, 5316491363.7363, 0.25 +Res-1.2820, 5316491363.7363, 0.25 +Res-1.2821, 5316491363.7363, 0.25 +Res-1.2822, 5316491363.7363, 0.25 +Res-1.2823, 5316491363.7363, 0.25 +Res-1.2824, 5316491363.7363, 0.25 +Res-1.2825, 5316491363.7363, 0.25 +Res-1.2826, 5316491363.7363, 0.25 +Res-1.2827, 5316491363.7363, 0.25 +Res-1.2828, 5316491363.7363, 0.25 +Res-1.2829, 5316491363.7363, 0.25 +Res-1.2830, 5316491363.7363, 0.25 +Res-1.2831, 5316491363.7363, 0.25 +Res-1.2832, 5316491363.7363, 0.25 +Res-1.2833, 5316491363.7363, 0.25 +Res-1.2834, 5316491363.7363, 0.25 +Res-1.2835, 5316491363.7363, 0.25 +Res-1.2836, 5316491363.7363, 0.25 +Res-1.2837, 5316491363.7363, 0.25 +Res-1.2838, 5316491363.7363, 0.25 +Res-1.2839, 5316491363.7363, 0.25 +Res-1.2840, 5316491363.7363, 0.25 +Res-1.2841, 5316491363.7363, 0.25 +Res-1.2842, 5316491363.7363, 0.25 +Res-1.2843, 5316491363.7363, 0.25 +Res-1.2844, 5316491363.7363, 0.25 +Res-1.2845, 5316491363.7363, 0.25 +Res-1.2846, 5316491363.7363, 0.25 +Res-1.2847, 5316491363.7363, 0.25 +Res-1.2848, 5316491363.7363, 0.25 +Res-1.2849, 5316491363.7363, 0.25 +Res-1.2850, 5316491363.7363, 0.25 +Res-1.2851, 5316491363.7363, 0.25 +Res-1.2852, 5316491363.7363, 0.25 +Res-1.2853, 5316491363.7363, 0.25 +Res-1.2854, 5316491363.7363, 0.25 +Res-1.2855, 5316491363.7363, 0.25 +Res-1.2856, 5316491363.7363, 0.25 +Res-1.2857, 5316491363.7363, 0.25 +Res-1.2858, 5316491363.7363, 0.25 +Res-1.2859, 5316491363.7363, 0.25 +Res-1.2860, 5316491363.7363, 0.25 +Res-1.2861, 5316491363.7363, 0.25 +Res-1.2862, 5316491363.7363, 0.25 +Res-1.2863, 5316491363.7363, 0.25 +Res-1.2864, 5316491363.7363, 0.25 +Res-1.2865, 5316491363.7363, 0.25 +Res-1.2866, 5316491363.7363, 0.25 +Res-1.2867, 5316491363.7363, 0.25 +Res-1.2868, 5316491363.7363, 0.25 +Res-1.2869, 5316491363.7363, 0.25 +Res-1.2870, 5316491363.7363, 0.25 +Res-1.2871, 5316491363.7363, 0.25 +Res-1.2872, 5316491363.7363, 0.25 +Res-1.2873, 5316491363.7363, 0.25 +Res-1.2874, 5316491363.7363, 0.25 +Res-1.2875, 5316491363.7363, 0.25 +Res-1.2876, 5316491363.7363, 0.25 +Res-1.2877, 5316491363.7363, 0.25 +Res-1.2878, 5316491363.7363, 0.25 +Res-1.2879, 5316491363.7363, 0.25 +Res-1.2880, 5316491363.7363, 0.25 +Res-1.2881, 11552880115, 0.25 +Res-1.2882, 11552880115, 0.25 +Res-1.2883, 11552880115, 0.25 +Res-1.2884, 11552880115, 0.25 +Res-1.2885, 11552880115, 0.25 +Res-1.2886, 11552880115, 0.25 +Res-1.2887, 11552880115, 0.25 +Res-1.2888, 11552880115, 0.25 +Res-1.2889, 11552880115, 0.25 +Res-1.2890, 11552880115, 0.25 +Res-1.2891, 11552880115, 0.25 +Res-1.2892, 11552880115, 0.25 +Res-1.2893, 11552880115, 0.25 +Res-1.2894, 11552880115, 0.25 +Res-1.2895, 11552880115, 0.25 +Res-1.2896, 11552880115, 0.25 +Res-1.2897, 11552880115, 0.25 +Res-1.2898, 11552880115, 0.25 +Res-1.2899, 11552880115, 0.25 +Res-1.2900, 11552880115, 0.25 +Res-1.2901, 11552880115, 0.25 +Res-1.2902, 11552880115, 0.25 +Res-1.2903, 11552880115, 0.25 +Res-1.2904, 11552880115, 0.25 +Res-1.2905, 11552880115, 0.25 +Res-1.2906, 11552880115, 0.25 +Res-1.2907, 11552880115, 0.25 +Res-1.2908, 11552880115, 0.25 +Res-1.2909, 11552880115, 0.25 +Res-1.2910, 11552880115, 0.25 +Res-1.2911, 11552880115, 0.25 +Res-1.2912, 11552880115, 0.25 +Res-1.2913, 11552880115, 0.25 +Res-1.2914, 11552880115, 0.25 +Res-1.2915, 11552880115, 0.25 +Res-1.2916, 11552880115, 0.25 +Res-1.2917, 11552880115, 0.25 +Res-1.2918, 11552880115, 0.25 +Res-1.2919, 11552880115, 0.25 +Res-1.2920, 11552880115, 0.25 +Res-1.2921, 11552880115, 0.25 +Res-1.2922, 11552880115, 0.25 +Res-1.2923, 11552880115, 0.25 +Res-1.2924, 11552880115, 0.25 +Res-1.2925, 11552880115, 0.25 +Res-1.2926, 11552880115, 0.25 +Res-1.2927, 11552880115, 0.25 +Res-1.2928, 11552880115, 0.25 +Res-1.2929, 11552880115, 0.25 +Res-1.2930, 11552880115, 0.25 +Res-1.2931, 11552880115, 0.25 +Res-1.2932, 11552880115, 0.25 +Res-1.2933, 11552880115, 0.25 +Res-1.2934, 11552880115, 0.25 +Res-1.2935, 11552880115, 0.25 +Res-1.2936, 11552880115, 0.25 +Res-1.2937, 11552880115, 0.25 +Res-1.2938, 11552880115, 0.25 +Res-1.2939, 11552880115, 0.25 +Res-1.2940, 11552880115, 0.25 +Res-1.2941, 11552880115, 0.25 +Res-1.2942, 11552880115, 0.25 +Res-1.2943, 11552880115, 0.25 +Res-1.2944, 11552880115, 0.25 +Res-1.2945, 11552880115, 0.25 +Res-1.2946, 11552880115, 0.25 +Res-1.2947, 11552880115, 0.25 +Res-1.2948, 11552880115, 0.25 +Res-1.2949, 11552880115, 0.25 +Res-1.2950, 11552880115, 0.25 +Res-1.2951, 11552880115, 0.25 +Res-1.2952, 11552880115, 0.25 +Res-1.2953, 11552880115, 0.25 +Res-1.2954, 11552880115, 0.25 +Res-1.2955, 11552880115, 0.25 +Res-1.2956, 11552880115, 0.25 +Res-1.2957, 11552880115, 0.25 +Res-1.2958, 11552880115, 0.25 +Res-1.2959, 11552880115, 0.25 +Res-1.2960, 11552880115, 0.25 +Res-1.2961, 11552880115, 0.25 +Res-1.2962, 11552880115, 0.25 +Res-1.2963, 11552880115, 0.25 +Res-1.2964, 11552880115, 0.25 +Res-1.2965, 11552880115, 0.25 +Res-1.2966, 11552880115, 0.25 +Res-1.2967, 11552880115, 0.25 +Res-1.2968, 11552880115, 0.25 +Res-1.2969, 11552880115, 0.25 +Res-1.2970, 11552880115, 0.25 +Res-1.2971, 11552880115, 0.25 +Res-1.2972, 11552880115, 0.25 +Res-1.2973, 11552880115, 0.25 +Res-1.2974, 11552880115, 0.25 +Res-1.2975, 11552880115, 0.25 +Res-1.2976, 11552880115, 0.25 +Res-1.2977, 11552880115, 0.25 +Res-1.2978, 11552880115, 0.25 +Res-1.2979, 11552880115, 0.25 +Res-1.2980, 11552880115, 0.25 +Res-1.2981, 11552880115, 0.25 +Res-1.2982, 11552880115, 0.25 +Res-1.2983, 11552880115, 0.25 +Res-1.2984, 11552880115, 0.25 +Res-1.2985, 11552880115, 0.25 +Res-1.2986, 11552880115, 0.25 +Res-1.2987, 11552880115, 0.25 +Res-1.2988, 11552880115, 0.25 +Res-1.2989, 11552880115, 0.25 +Res-1.2990, 11552880115, 0.25 +Res-1.2991, 11552880115, 0.25 +Res-1.2992, 11552880115, 0.25 +Res-1.2993, 11552880115, 0.25 +Res-1.2994, 11552880115, 0.25 +Res-1.2995, 11552880115, 0.25 +Res-1.2996, 11552880115, 0.25 +Res-1.2997, 11552880115, 0.25 +Res-1.2998, 11552880115, 0.25 +Res-1.2999, 11552880115, 0.25 +Res-1.3000, 11552880115, 0.25 +Res-1.3001, 11552880115, 0.25 +Res-1.3002, 11552880115, 0.25 +Res-1.3003, 11552880115, 0.25 +Res-1.3004, 11552880115, 0.25 +Res-1.3005, 11552880115, 0.25 +Res-1.3006, 11552880115, 0.25 +Res-1.3007, 11552880115, 0.25 +Res-1.3008, 11552880115, 0.25 +Res-1.3009, 11552880115, 0.25 +Res-1.3010, 11552880115, 0.25 +Res-1.3011, 11552880115, 0.25 +Res-1.3012, 11552880115, 0.25 +Res-1.3013, 11552880115, 0.25 +Res-1.3014, 11552880115, 0.25 +Res-1.3015, 11552880115, 0.25 +Res-1.3016, 11552880115, 0.25 +Res-1.3017, 11552880115, 0.25 +Res-1.3018, 11552880115, 0.25 +Res-1.3019, 11552880115, 0.25 +Res-1.3020, 11552880115, 0.25 +Res-1.3021, 11552880115, 0.25 +Res-1.3022, 11552880115, 0.25 +Res-1.3023, 11552880115, 0.25 +Res-1.3024, 11552880115, 0.25 +Res-1.3025, 11552880115, 0.25 +Res-1.3026, 11552880115, 0.25 +Res-1.3027, 11552880115, 0.25 +Res-1.3028, 11552880115, 0.25 +Res-1.3029, 11552880115, 0.25 +Res-1.3030, 11552880115, 0.25 +Res-1.3031, 11552880115, 0.25 +Res-1.3032, 11552880115, 0.25 +Res-1.3033, 11552880115, 0.25 +Res-1.3034, 11552880115, 0.25 +Res-1.3035, 11552880115, 0.25 +Res-1.3036, 11552880115, 0.25 +Res-1.3037, 11552880115, 0.25 +Res-1.3038, 11552880115, 0.25 +Res-1.3039, 11552880115, 0.25 +Res-1.3040, 11552880115, 0.25 +Res-1.3041, 11552880115, 0.25 +Res-1.3042, 11552880115, 0.25 +Res-1.3043, 11552880115, 0.25 +Res-1.3044, 11552880115, 0.25 +Res-1.3045, 11552880115, 0.25 +Res-1.3046, 11552880115, 0.25 +Res-1.3047, 11552880115, 0.25 +Res-1.3048, 11552880115, 0.25 +Res-1.3049, 11552880115, 0.25 +Res-1.3050, 11552880115, 0.25 +Res-1.3051, 11552880115, 0.25 +Res-1.3052, 11552880115, 0.25 +Res-1.3053, 11552880115, 0.25 +Res-1.3054, 11552880115, 0.25 +Res-1.3055, 11552880115, 0.25 +Res-1.3056, 11552880115, 0.25 +Res-1.3057, 11552880115, 0.25 +Res-1.3058, 11552880115, 0.25 +Res-1.3059, 11552880115, 0.25 +Res-1.3060, 11552880115, 0.25 +Res-1.3061, 11552880115, 0.25 +Res-1.3062, 11552880115, 0.25 +Res-1.3063, 11552880115, 0.25 +Res-1.3064, 11552880115, 0.25 +Res-1.3065, 11552880115, 0.25 +Res-1.3066, 11552880115, 0.25 +Res-1.3067, 11552880115, 0.25 +Res-1.3068, 11552880115, 0.25 +Res-1.3069, 11552880115, 0.25 +Res-1.3070, 11552880115, 0.25 +Res-1.3071, 11552880115, 0.25 +Res-1.3072, 11552880115, 0.25 +Res-1.3073, 11552880115, 0.25 +Res-1.3074, 11552880115, 0.25 +Res-1.3075, 11552880115, 0.25 +Res-1.3076, 11552880115, 0.25 +Res-1.3077, 11552880115, 0.25 +Res-1.3078, 11552880115, 0.25 +Res-1.3079, 11552880115, 0.25 +Res-1.3080, 11552880115, 0.25 +Res-1.3081, 11552880115, 0.25 +Res-1.3082, 11552880115, 0.25 +Res-1.3083, 11552880115, 0.25 +Res-1.3084, 11552880115, 0.25 +Res-1.3085, 11552880115, 0.25 +Res-1.3086, 11552880115, 0.25 +Res-1.3087, 11552880115, 0.25 +Res-1.3088, 11552880115, 0.25 +Res-1.3089, 11552880115, 0.25 +Res-1.3090, 11552880115, 0.25 +Res-1.3091, 11552880115, 0.25 +Res-1.3092, 11552880115, 0.25 +Res-1.3093, 11552880115, 0.25 +Res-1.3094, 11552880115, 0.25 +Res-1.3095, 11552880115, 0.25 +Res-1.3096, 11552880115, 0.25 +Res-1.3097, 11552880115, 0.25 +Res-1.3098, 11552880115, 0.25 +Res-1.3099, 11552880115, 0.25 +Res-1.3100, 11552880115, 0.25 +Res-1.3101, 11552880115, 0.25 +Res-1.3102, 11552880115, 0.25 +Res-1.3103, 11552880115, 0.25 +Res-1.3104, 11552880115, 0.25 +Res-1.3105, 11552880115, 0.25 +Res-1.3106, 11552880115, 0.25 +Res-1.3107, 11552880115, 0.25 +Res-1.3108, 11552880115, 0.25 +Res-1.3109, 11552880115, 0.25 +Res-1.3110, 11552880115, 0.25 +Res-1.3111, 11552880115, 0.25 +Res-1.3112, 11552880115, 0.25 +Res-1.3113, 11552880115, 0.25 +Res-1.3114, 11552880115, 0.25 +Res-1.3115, 11552880115, 0.25 +Res-1.3116, 11552880115, 0.25 +Res-1.3117, 11552880115, 0.25 +Res-1.3118, 11552880115, 0.25 +Res-1.3119, 11552880115, 0.25 +Res-1.3120, 11552880115, 0.25 +Res-1.3121, 11552880115, 0.25 +Res-1.3122, 11552880115, 0.25 +Res-1.3123, 11552880115, 0.25 +Res-1.3124, 11552880115, 0.25 +Res-1.3125, 11552880115, 0.25 +Res-1.3126, 11552880115, 0.25 +Res-1.3127, 11552880115, 0.25 +Res-1.3128, 11552880115, 0.25 +Res-1.3129, 11552880115, 0.25 +Res-1.3130, 11552880115, 0.25 +Res-1.3131, 11552880115, 0.25 +Res-1.3132, 11552880115, 0.25 +Res-1.3133, 11552880115, 0.25 +Res-1.3134, 11552880115, 0.25 +Res-1.3135, 11552880115, 0.25 +Res-1.3136, 11552880115, 0.25 +Res-1.3137, 11552880115, 0.25 +Res-1.3138, 11552880115, 0.25 +Res-1.3139, 11552880115, 0.25 +Res-1.3140, 11552880115, 0.25 +Res-1.3141, 11552880115, 0.25 +Res-1.3142, 11552880115, 0.25 +Res-1.3143, 11552880115, 0.25 +Res-1.3144, 11552880115, 0.25 +Res-1.3145, 11552880115, 0.25 +Res-1.3146, 11552880115, 0.25 +Res-1.3147, 11552880115, 0.25 +Res-1.3148, 11552880115, 0.25 +Res-1.3149, 11552880115, 0.25 +Res-1.3150, 11552880115, 0.25 +Res-1.3151, 11552880115, 0.25 +Res-1.3152, 11552880115, 0.25 +Res-1.3153, 11552880115, 0.25 +Res-1.3154, 11552880115, 0.25 +Res-1.3155, 11552880115, 0.25 +Res-1.3156, 11552880115, 0.25 +Res-1.3157, 11552880115, 0.25 +Res-1.3158, 11552880115, 0.25 +Res-1.3159, 11552880115, 0.25 +Res-1.3160, 11552880115, 0.25 +Res-1.3161, 11552880115, 0.25 +Res-1.3162, 11552880115, 0.25 +Res-1.3163, 11552880115, 0.25 +Res-1.3164, 11552880115, 0.25 +Res-1.3165, 11552880115, 0.25 +Res-1.3166, 11552880115, 0.25 +Res-1.3167, 11552880115, 0.25 +Res-1.3168, 11552880115, 0.25 +Res-1.3169, 13631205565, 0.25 +Res-1.3170, 13631205565, 0.25 +Res-1.3171, 13631205565, 0.25 +Res-1.3172, 13631205565, 0.25 +Res-1.3173, 13631205565, 0.25 +Res-1.3174, 13631205565, 0.25 +Res-1.3175, 13631205565, 0.25 +Res-1.3176, 13631205565, 0.25 +Res-1.3177, 13631205565, 0.25 +Res-1.3178, 13631205565, 0.25 +Res-1.3179, 13631205565, 0.25 +Res-1.3180, 13631205565, 0.25 +Res-1.3181, 13631205565, 0.25 +Res-1.3182, 13631205565, 0.25 +Res-1.3183, 13631205565, 0.25 +Res-1.3184, 13631205565, 0.25 +Res-1.3185, 13631205565, 0.25 +Res-1.3186, 13631205565, 0.25 +Res-1.3187, 13631205565, 0.25 +Res-1.3188, 13631205565, 0.25 +Res-1.3189, 13631205565, 0.25 +Res-1.3190, 13631205565, 0.25 +Res-1.3191, 13631205565, 0.25 +Res-1.3192, 13631205565, 0.25 +Res-1.3193, 13631205565, 0.25 +Res-1.3194, 13631205565, 0.25 +Res-1.3195, 13631205565, 0.25 +Res-1.3196, 13631205565, 0.25 +Res-1.3197, 13631205565, 0.25 +Res-1.3198, 13631205565, 0.25 +Res-1.3199, 13631205565, 0.25 +Res-1.3200, 13631205565, 0.25 +Res-1.3201, 13631205565, 0.25 +Res-1.3202, 13631205565, 0.25 +Res-1.3203, 13631205565, 0.25 +Res-1.3204, 13631205565, 0.25 +Res-1.3205, 13631205565, 0.25 +Res-1.3206, 13631205565, 0.25 +Res-1.3207, 13631205565, 0.25 +Res-1.3208, 13631205565, 0.25 +Res-1.3209, 13631205565, 0.25 +Res-1.3210, 13631205565, 0.25 +Res-1.3211, 13631205565, 0.25 +Res-1.3212, 13631205565, 0.25 +Res-1.3213, 13631205565, 0.25 +Res-1.3214, 13631205565, 0.25 +Res-1.3215, 13631205565, 0.25 +Res-1.3216, 13631205565, 0.25 +Res-1.3217, 13631205565, 0.25 +Res-1.3218, 13631205565, 0.25 +Res-1.3219, 13631205565, 0.25 +Res-1.3220, 13631205565, 0.25 +Res-1.3221, 13631205565, 0.25 +Res-1.3222, 13631205565, 0.25 +Res-1.3223, 13631205565, 0.25 +Res-1.3224, 13631205565, 0.25 +Res-1.3225, 13631205565, 0.25 +Res-1.3226, 13631205565, 0.25 +Res-1.3227, 13631205565, 0.25 +Res-1.3228, 13631205565, 0.25 +Res-1.3229, 13631205565, 0.25 +Res-1.3230, 13631205565, 0.25 +Res-1.3231, 13631205565, 0.25 +Res-1.3232, 13631205565, 0.25 +Res-1.3233, 13631205565, 0.25 +Res-1.3234, 13631205565, 0.25 +Res-1.3235, 13631205565, 0.25 +Res-1.3236, 13631205565, 0.25 +Res-1.3237, 13631205565, 0.25 +Res-1.3238, 13631205565, 0.25 +Res-1.3239, 13631205565, 0.25 +Res-1.3240, 13631205565, 0.25 +Res-1.3241, 13631205565, 0.25 +Res-1.3242, 13631205565, 0.25 +Res-1.3243, 13631205565, 0.25 +Res-1.3244, 13631205565, 0.25 +Res-1.3245, 13631205565, 0.25 +Res-1.3246, 13631205565, 0.25 +Res-1.3247, 13631205565, 0.25 +Res-1.3248, 13631205565, 0.25 +Res-1.3249, 13631205565, 0.25 +Res-1.3250, 13631205565, 0.25 +Res-1.3251, 13631205565, 0.25 +Res-1.3252, 13631205565, 0.25 +Res-1.3253, 13631205565, 0.25 +Res-1.3254, 13631205565, 0.25 +Res-1.3255, 13631205565, 0.25 +Res-1.3256, 13631205565, 0.25 +Res-1.3257, 13631205565, 0.25 +Res-1.3258, 13631205565, 0.25 +Res-1.3259, 13631205565, 0.25 +Res-1.3260, 13631205565, 0.25 +Res-1.3261, 13631205565, 0.25 +Res-1.3262, 13631205565, 0.25 +Res-1.3263, 13631205565, 0.25 +Res-1.3264, 13631205565, 0.25 +Res-1.3265, 13631205565, 0.25 +Res-1.3266, 13631205565, 0.25 +Res-1.3267, 13631205565, 0.25 +Res-1.3268, 13631205565, 0.25 +Res-1.3269, 13631205565, 0.25 +Res-1.3270, 13631205565, 0.25 +Res-1.3271, 13631205565, 0.25 +Res-1.3272, 13631205565, 0.25 +Res-1.3273, 13631205565, 0.25 +Res-1.3274, 13631205565, 0.25 +Res-1.3275, 13631205565, 0.25 +Res-1.3276, 13631205565, 0.25 +Res-1.3277, 13631205565, 0.25 +Res-1.3278, 13631205565, 0.25 +Res-1.3279, 13631205565, 0.25 +Res-1.3280, 13631205565, 0.25 +Res-1.3281, 13631205565, 0.25 +Res-1.3282, 13631205565, 0.25 +Res-1.3283, 13631205565, 0.25 +Res-1.3284, 13631205565, 0.25 +Res-1.3285, 13631205565, 0.25 +Res-1.3286, 13631205565, 0.25 +Res-1.3287, 13631205565, 0.25 +Res-1.3288, 13631205565, 0.25 +Res-1.3289, 13631205565, 0.25 +Res-1.3290, 13631205565, 0.25 +Res-1.3291, 13631205565, 0.25 +Res-1.3292, 13631205565, 0.25 +Res-1.3293, 13631205565, 0.25 +Res-1.3294, 13631205565, 0.25 +Res-1.3295, 13631205565, 0.25 +Res-1.3296, 13631205565, 0.25 +Res-1.3297, 13631205565, 0.25 +Res-1.3298, 13631205565, 0.25 +Res-1.3299, 13631205565, 0.25 +Res-1.3300, 13631205565, 0.25 +Res-1.3301, 13631205565, 0.25 +Res-1.3302, 13631205565, 0.25 +Res-1.3303, 13631205565, 0.25 +Res-1.3304, 13631205565, 0.25 +Res-1.3305, 13631205565, 0.25 +Res-1.3306, 13631205565, 0.25 +Res-1.3307, 13631205565, 0.25 +Res-1.3308, 13631205565, 0.25 +Res-1.3309, 13631205565, 0.25 +Res-1.3310, 13631205565, 0.25 +Res-1.3311, 13631205565, 0.25 +Res-1.3312, 13631205565, 0.25 +Res-1.3313, 13631205565, 0.25 +Res-1.3314, 13631205565, 0.25 +Res-1.3315, 13631205565, 0.25 +Res-1.3316, 13631205565, 0.25 +Res-1.3317, 13631205565, 0.25 +Res-1.3318, 13631205565, 0.25 +Res-1.3319, 13631205565, 0.25 +Res-1.3320, 13631205565, 0.25 +Res-1.3321, 13631205565, 0.25 +Res-1.3322, 13631205565, 0.25 +Res-1.3323, 13631205565, 0.25 +Res-1.3324, 13631205565, 0.25 +Res-1.3325, 13631205565, 0.25 +Res-1.3326, 13631205565, 0.25 +Res-1.3327, 13631205565, 0.25 +Res-1.3328, 13631205565, 0.25 +Res-1.3329, 13631205565, 0.25 +Res-1.3330, 13631205565, 0.25 +Res-1.3331, 13631205565, 0.25 +Res-1.3332, 13631205565, 0.25 +Res-1.3333, 13631205565, 0.25 +Res-1.3334, 13631205565, 0.25 +Res-1.3335, 13631205565, 0.25 +Res-1.3336, 13631205565, 0.25 +Res-1.3337, 13631205565, 0.25 +Res-1.3338, 13631205565, 0.25 +Res-1.3339, 13631205565, 0.25 +Res-1.3340, 13631205565, 0.25 +Res-1.3341, 13631205565, 0.25 +Res-1.3342, 13631205565, 0.25 +Res-1.3343, 13631205565, 0.25 +Res-1.3344, 13631205565, 0.25 +Res-1.3345, 13631205565, 0.25 +Res-1.3346, 13631205565, 0.25 +Res-1.3347, 13631205565, 0.25 +Res-1.3348, 13631205565, 0.25 +Res-1.3349, 13631205565, 0.25 +Res-1.3350, 13631205565, 0.25 +Res-1.3351, 13631205565, 0.25 +Res-1.3352, 13631205565, 0.25 +Res-1.3353, 13631205565, 0.25 +Res-1.3354, 13631205565, 0.25 +Res-1.3355, 13631205565, 0.25 +Res-1.3356, 13631205565, 0.25 +Res-1.3357, 13631205565, 0.25 +Res-1.3358, 13631205565, 0.25 +Res-1.3359, 13631205565, 0.25 +Res-1.3360, 13631205565, 0.25 +Res-1.3361, 13631205565, 0.25 +Res-1.3362, 13631205565, 0.25 +Res-1.3363, 13631205565, 0.25 +Res-1.3364, 13631205565, 0.25 +Res-1.3365, 13631205565, 0.25 +Res-1.3366, 13631205565, 0.25 +Res-1.3367, 13631205565, 0.25 +Res-1.3368, 13631205565, 0.25 +Res-1.3369, 13631205565, 0.25 +Res-1.3370, 13631205565, 0.25 +Res-1.3371, 13631205565, 0.25 +Res-1.3372, 13631205565, 0.25 +Res-1.3373, 13631205565, 0.25 +Res-1.3374, 13631205565, 0.25 +Res-1.3375, 13631205565, 0.25 +Res-1.3376, 13631205565, 0.25 +Res-1.3377, 13631205565, 0.25 +Res-1.3378, 13631205565, 0.25 +Res-1.3379, 13631205565, 0.25 +Res-1.3380, 13631205565, 0.25 +Res-1.3381, 13631205565, 0.25 +Res-1.3382, 13631205565, 0.25 +Res-1.3383, 13631205565, 0.25 +Res-1.3384, 13631205565, 0.25 +Res-1.3385, 13631205565, 0.25 +Res-1.3386, 13631205565, 0.25 +Res-1.3387, 13631205565, 0.25 +Res-1.3388, 13631205565, 0.25 +Res-1.3389, 13631205565, 0.25 +Res-1.3390, 13631205565, 0.25 +Res-1.3391, 13631205565, 0.25 +Res-1.3392, 13631205565, 0.25 +Res-1.3393, 13631205565, 0.25 +Res-1.3394, 13631205565, 0.25 +Res-1.3395, 13631205565, 0.25 +Res-1.3396, 13631205565, 0.25 +Res-1.3397, 13631205565, 0.25 +Res-1.3398, 13631205565, 0.25 +Res-1.3399, 13631205565, 0.25 +Res-1.3400, 13631205565, 0.25 +Res-1.3401, 13631205565, 0.25 +Res-1.3402, 13631205565, 0.25 +Res-1.3403, 13631205565, 0.25 +Res-1.3404, 13631205565, 0.25 +Res-1.3405, 13631205565, 0.25 +Res-1.3406, 13631205565, 0.25 +Res-1.3407, 13631205565, 0.25 +Res-1.3408, 13631205565, 0.25 +Res-1.3409, 13631205565, 0.25 +Res-1.3410, 13631205565, 0.25 +Res-1.3411, 13631205565, 0.25 +Res-1.3412, 13631205565, 0.25 +Res-1.3413, 13631205565, 0.25 +Res-1.3414, 13631205565, 0.25 +Res-1.3415, 13631205565, 0.25 +Res-1.3416, 13631205565, 0.25 +Res-1.3417, 13631205565, 0.25 +Res-1.3418, 13631205565, 0.25 +Res-1.3419, 13631205565, 0.25 +Res-1.3420, 13631205565, 0.25 +Res-1.3421, 13631205565, 0.25 +Res-1.3422, 13631205565, 0.25 +Res-1.3423, 13631205565, 0.25 +Res-1.3424, 13631205565, 0.25 +Res-1.3425, 13631205565, 0.25 +Res-1.3426, 13631205565, 0.25 +Res-1.3427, 13631205565, 0.25 +Res-1.3428, 13631205565, 0.25 +Res-1.3429, 13631205565, 0.25 +Res-1.3430, 13631205565, 0.25 +Res-1.3431, 13631205565, 0.25 +Res-1.3432, 13631205565, 0.25 +Res-1.3433, 13631205565, 0.25 +Res-1.3434, 13631205565, 0.25 +Res-1.3435, 13631205565, 0.25 +Res-1.3436, 13631205565, 0.25 +Res-1.3437, 13631205565, 0.25 +Res-1.3438, 13631205565, 0.25 +Res-1.3439, 13631205565, 0.25 +Res-1.3440, 13631205565, 0.25 +Res-1.3441, 13631205565, 0.25 +Res-1.3442, 13631205565, 0.25 +Res-1.3443, 13631205565, 0.25 +Res-1.3444, 13631205565, 0.25 +Res-1.3445, 13631205565, 0.25 +Res-1.3446, 13631205565, 0.25 +Res-1.3447, 13631205565, 0.25 +Res-1.3448, 13631205565, 0.25 +Res-1.3449, 13631205565, 0.25 +Res-1.3450, 13631205565, 0.25 +Res-1.3451, 13631205565, 0.25 +Res-1.3452, 13631205565, 0.25 +Res-1.3453, 13631205565, 0.25 +Res-1.3454, 13631205565, 0.25 +Res-1.3455, 13631205565, 0.25 +Res-1.3456, 13631205565, 0.25 +Res-1.3457, 16739025760, 0.25 +Res-1.3458, 16739025760, 0.25 +Res-1.3459, 16739025760, 0.25 +Res-1.3460, 16739025760, 0.25 +Res-1.3461, 16739025760, 0.25 +Res-1.3462, 16739025760, 0.25 +Res-1.3463, 16739025760, 0.25 +Res-1.3464, 16739025760, 0.25 +Res-1.3465, 16739025760, 0.25 +Res-1.3466, 16739025760, 0.25 +Res-1.3467, 16739025760, 0.25 +Res-1.3468, 16739025760, 0.25 +Res-1.3469, 16739025760, 0.25 +Res-1.3470, 16739025760, 0.25 +Res-1.3471, 16739025760, 0.25 +Res-1.3472, 16739025760, 0.25 +Res-1.3473, 16739025760, 0.25 +Res-1.3474, 16739025760, 0.25 +Res-1.3475, 16739025760, 0.25 +Res-1.3476, 16739025760, 0.25 +Res-1.3477, 16739025760, 0.25 +Res-1.3478, 16739025760, 0.25 +Res-1.3479, 16739025760, 0.25 +Res-1.3480, 16739025760, 0.25 +Res-1.3481, 16739025760, 0.25 +Res-1.3482, 16739025760, 0.25 +Res-1.3483, 16739025760, 0.25 +Res-1.3484, 16739025760, 0.25 +Res-1.3485, 16739025760, 0.25 +Res-1.3486, 16739025760, 0.25 +Res-1.3487, 16739025760, 0.25 +Res-1.3488, 16739025760, 0.25 +Res-1.3489, 16739025760, 0.25 +Res-1.3490, 16739025760, 0.25 +Res-1.3491, 16739025760, 0.25 +Res-1.3492, 16739025760, 0.25 +Res-1.3493, 16739025760, 0.25 +Res-1.3494, 16739025760, 0.25 +Res-1.3495, 16739025760, 0.25 +Res-1.3496, 16739025760, 0.25 +Res-1.3497, 16739025760, 0.25 +Res-1.3498, 16739025760, 0.25 +Res-1.3499, 16739025760, 0.25 +Res-1.3500, 16739025760, 0.25 +Res-1.3501, 16739025760, 0.25 +Res-1.3502, 16739025760, 0.25 +Res-1.3503, 16739025760, 0.25 +Res-1.3504, 16739025760, 0.25 +Res-1.3505, 16739025760, 0.25 +Res-1.3506, 16739025760, 0.25 +Res-1.3507, 16739025760, 0.25 +Res-1.3508, 16739025760, 0.25 +Res-1.3509, 16739025760, 0.25 +Res-1.3510, 16739025760, 0.25 +Res-1.3511, 16739025760, 0.25 +Res-1.3512, 16739025760, 0.25 +Res-1.3513, 16739025760, 0.25 +Res-1.3514, 16739025760, 0.25 +Res-1.3515, 16739025760, 0.25 +Res-1.3516, 16739025760, 0.25 +Res-1.3517, 16739025760, 0.25 +Res-1.3518, 16739025760, 0.25 +Res-1.3519, 16739025760, 0.25 +Res-1.3520, 16739025760, 0.25 +Res-1.3521, 16739025760, 0.25 +Res-1.3522, 16739025760, 0.25 +Res-1.3523, 16739025760, 0.25 +Res-1.3524, 16739025760, 0.25 +Res-1.3525, 16739025760, 0.25 +Res-1.3526, 16739025760, 0.25 +Res-1.3527, 16739025760, 0.25 +Res-1.3528, 16739025760, 0.25 +Res-1.3529, 16739025760, 0.25 +Res-1.3530, 16739025760, 0.25 +Res-1.3531, 16739025760, 0.25 +Res-1.3532, 16739025760, 0.25 +Res-1.3533, 16739025760, 0.25 +Res-1.3534, 16739025760, 0.25 +Res-1.3535, 16739025760, 0.25 +Res-1.3536, 16739025760, 0.25 +Res-1.3537, 16739025760, 0.25 +Res-1.3538, 16739025760, 0.25 +Res-1.3539, 16739025760, 0.25 +Res-1.3540, 16739025760, 0.25 +Res-1.3541, 16739025760, 0.25 +Res-1.3542, 16739025760, 0.25 +Res-1.3543, 16739025760, 0.25 +Res-1.3544, 16739025760, 0.25 +Res-1.3545, 16739025760, 0.25 +Res-1.3546, 16739025760, 0.25 +Res-1.3547, 16739025760, 0.25 +Res-1.3548, 16739025760, 0.25 +Res-1.3549, 16739025760, 0.25 +Res-1.3550, 16739025760, 0.25 +Res-1.3551, 16739025760, 0.25 +Res-1.3552, 16739025760, 0.25 +Res-1.3553, 16739025760, 0.25 +Res-1.3554, 16739025760, 0.25 +Res-1.3555, 16739025760, 0.25 +Res-1.3556, 16739025760, 0.25 +Res-1.3557, 16739025760, 0.25 +Res-1.3558, 16739025760, 0.25 +Res-1.3559, 16739025760, 0.25 +Res-1.3560, 16739025760, 0.25 +Res-1.3561, 16739025760, 0.25 +Res-1.3562, 16739025760, 0.25 +Res-1.3563, 16739025760, 0.25 +Res-1.3564, 16739025760, 0.25 +Res-1.3565, 16739025760, 0.25 +Res-1.3566, 16739025760, 0.25 +Res-1.3567, 16739025760, 0.25 +Res-1.3568, 16739025760, 0.25 +Res-1.3569, 16739025760, 0.25 +Res-1.3570, 16739025760, 0.25 +Res-1.3571, 16739025760, 0.25 +Res-1.3572, 16739025760, 0.25 +Res-1.3573, 16739025760, 0.25 +Res-1.3574, 16739025760, 0.25 +Res-1.3575, 16739025760, 0.25 +Res-1.3576, 16739025760, 0.25 +Res-1.3577, 16739025760, 0.25 +Res-1.3578, 16739025760, 0.25 +Res-1.3579, 16739025760, 0.25 +Res-1.3580, 16739025760, 0.25 +Res-1.3581, 16739025760, 0.25 +Res-1.3582, 16739025760, 0.25 +Res-1.3583, 16739025760, 0.25 +Res-1.3584, 16739025760, 0.25 +Res-1.3585, 16739025760, 0.25 +Res-1.3586, 16739025760, 0.25 +Res-1.3587, 16739025760, 0.25 +Res-1.3588, 16739025760, 0.25 +Res-1.3589, 16739025760, 0.25 +Res-1.3590, 16739025760, 0.25 +Res-1.3591, 16739025760, 0.25 +Res-1.3592, 16739025760, 0.25 +Res-1.3593, 16739025760, 0.25 +Res-1.3594, 16739025760, 0.25 +Res-1.3595, 16739025760, 0.25 +Res-1.3596, 16739025760, 0.25 +Res-1.3597, 16739025760, 0.25 +Res-1.3598, 16739025760, 0.25 +Res-1.3599, 16739025760, 0.25 +Res-1.3600, 16739025760, 0.25 +Res-1.3601, 16739025760, 0.25 +Res-1.3602, 16739025760, 0.25 +Res-1.3603, 16739025760, 0.25 +Res-1.3604, 16739025760, 0.25 +Res-1.3605, 16739025760, 0.25 +Res-1.3606, 16739025760, 0.25 +Res-1.3607, 16739025760, 0.25 +Res-1.3608, 16739025760, 0.25 +Res-1.3609, 16739025760, 0.25 +Res-1.3610, 16739025760, 0.25 +Res-1.3611, 16739025760, 0.25 +Res-1.3612, 16739025760, 0.25 +Res-1.3613, 16739025760, 0.25 +Res-1.3614, 16739025760, 0.25 +Res-1.3615, 16739025760, 0.25 +Res-1.3616, 16739025760, 0.25 +Res-1.3617, 16739025760, 0.25 +Res-1.3618, 16739025760, 0.25 +Res-1.3619, 16739025760, 0.25 +Res-1.3620, 16739025760, 0.25 +Res-1.3621, 16739025760, 0.25 +Res-1.3622, 16739025760, 0.25 +Res-1.3623, 16739025760, 0.25 +Res-1.3624, 16739025760, 0.25 +Res-1.3625, 16739025760, 0.25 +Res-1.3626, 16739025760, 0.25 +Res-1.3627, 16739025760, 0.25 +Res-1.3628, 16739025760, 0.25 +Res-1.3629, 16739025760, 0.25 +Res-1.3630, 16739025760, 0.25 +Res-1.3631, 16739025760, 0.25 +Res-1.3632, 16739025760, 0.25 +Res-1.3633, 16739025760, 0.25 +Res-1.3634, 16739025760, 0.25 +Res-1.3635, 16739025760, 0.25 +Res-1.3636, 16739025760, 0.25 +Res-1.3637, 16739025760, 0.25 +Res-1.3638, 16739025760, 0.25 +Res-1.3639, 16739025760, 0.25 +Res-1.3640, 16739025760, 0.25 +Res-1.3641, 16739025760, 0.25 +Res-1.3642, 16739025760, 0.25 +Res-1.3643, 16739025760, 0.25 +Res-1.3644, 16739025760, 0.25 +Res-1.3645, 16739025760, 0.25 +Res-1.3646, 16739025760, 0.25 +Res-1.3647, 16739025760, 0.25 +Res-1.3648, 16739025760, 0.25 +Res-1.3649, 16739025760, 0.25 +Res-1.3650, 16739025760, 0.25 +Res-1.3651, 16739025760, 0.25 +Res-1.3652, 16739025760, 0.25 +Res-1.3653, 16739025760, 0.25 +Res-1.3654, 16739025760, 0.25 +Res-1.3655, 16739025760, 0.25 +Res-1.3656, 16739025760, 0.25 +Res-1.3657, 16739025760, 0.25 +Res-1.3658, 16739025760, 0.25 +Res-1.3659, 16739025760, 0.25 +Res-1.3660, 16739025760, 0.25 +Res-1.3661, 16739025760, 0.25 +Res-1.3662, 16739025760, 0.25 +Res-1.3663, 16739025760, 0.25 +Res-1.3664, 16739025760, 0.25 +Res-1.3665, 16739025760, 0.25 +Res-1.3666, 16739025760, 0.25 +Res-1.3667, 16739025760, 0.25 +Res-1.3668, 16739025760, 0.25 +Res-1.3669, 16739025760, 0.25 +Res-1.3670, 16739025760, 0.25 +Res-1.3671, 16739025760, 0.25 +Res-1.3672, 16739025760, 0.25 +Res-1.3673, 16739025760, 0.25 +Res-1.3674, 16739025760, 0.25 +Res-1.3675, 16739025760, 0.25 +Res-1.3676, 16739025760, 0.25 +Res-1.3677, 16739025760, 0.25 +Res-1.3678, 16739025760, 0.25 +Res-1.3679, 16739025760, 0.25 +Res-1.3680, 16739025760, 0.25 +Res-1.3681, 16739025760, 0.25 +Res-1.3682, 16739025760, 0.25 +Res-1.3683, 16739025760, 0.25 +Res-1.3684, 16739025760, 0.25 +Res-1.3685, 16739025760, 0.25 +Res-1.3686, 16739025760, 0.25 +Res-1.3687, 16739025760, 0.25 +Res-1.3688, 16739025760, 0.25 +Res-1.3689, 16739025760, 0.25 +Res-1.3690, 16739025760, 0.25 +Res-1.3691, 16739025760, 0.25 +Res-1.3692, 16739025760, 0.25 +Res-1.3693, 16739025760, 0.25 +Res-1.3694, 16739025760, 0.25 +Res-1.3695, 16739025760, 0.25 +Res-1.3696, 16739025760, 0.25 +Res-1.3697, 16739025760, 0.25 +Res-1.3698, 16739025760, 0.25 +Res-1.3699, 16739025760, 0.25 +Res-1.3700, 16739025760, 0.25 +Res-1.3701, 16739025760, 0.25 +Res-1.3702, 16739025760, 0.25 +Res-1.3703, 16739025760, 0.25 +Res-1.3704, 16739025760, 0.25 +Res-1.3705, 16739025760, 0.25 +Res-1.3706, 16739025760, 0.25 +Res-1.3707, 16739025760, 0.25 +Res-1.3708, 16739025760, 0.25 +Res-1.3709, 16739025760, 0.25 +Res-1.3710, 16739025760, 0.25 +Res-1.3711, 16739025760, 0.25 +Res-1.3712, 16739025760, 0.25 +Res-1.3713, 16739025760, 0.25 +Res-1.3714, 16739025760, 0.25 +Res-1.3715, 16739025760, 0.25 +Res-1.3716, 16739025760, 0.25 +Res-1.3717, 16739025760, 0.25 +Res-1.3718, 16739025760, 0.25 +Res-1.3719, 16739025760, 0.25 +Res-1.3720, 16739025760, 0.25 +Res-1.3721, 16739025760, 0.25 +Res-1.3722, 16739025760, 0.25 +Res-1.3723, 16739025760, 0.25 +Res-1.3724, 16739025760, 0.25 +Res-1.3725, 16739025760, 0.25 +Res-1.3726, 16739025760, 0.25 +Res-1.3727, 16739025760, 0.25 +Res-1.3728, 16739025760, 0.25 +Res-1.3729, 16739025760, 0.25 +Res-1.3730, 16739025760, 0.25 +Res-1.3731, 16739025760, 0.25 +Res-1.3732, 16739025760, 0.25 +Res-1.3733, 16739025760, 0.25 +Res-1.3734, 16739025760, 0.25 +Res-1.3735, 16739025760, 0.25 +Res-1.3736, 16739025760, 0.25 +Res-1.3737, 16739025760, 0.25 +Res-1.3738, 16739025760, 0.25 +Res-1.3739, 16739025760, 0.25 +Res-1.3740, 16739025760, 0.25 +Res-1.3741, 16739025760, 0.25 +Res-1.3742, 16739025760, 0.25 +Res-1.3743, 16739025760, 0.25 +Res-1.3744, 16739025760, 0.25 +Res-1.3745, 17409132100, 0.25 +Res-1.3746, 17409132100, 0.25 +Res-1.3747, 17409132100, 0.25 +Res-1.3748, 17409132100, 0.25 +Res-1.3749, 17409132100, 0.25 +Res-1.3750, 17409132100, 0.25 +Res-1.3751, 17409132100, 0.25 +Res-1.3752, 17409132100, 0.25 +Res-1.3753, 17409132100, 0.25 +Res-1.3754, 17409132100, 0.25 +Res-1.3755, 17409132100, 0.25 +Res-1.3756, 17409132100, 0.25 +Res-1.3757, 17409132100, 0.25 +Res-1.3758, 17409132100, 0.25 +Res-1.3759, 17409132100, 0.25 +Res-1.3760, 17409132100, 0.25 +Res-1.3761, 17409132100, 0.25 +Res-1.3762, 17409132100, 0.25 +Res-1.3763, 17409132100, 0.25 +Res-1.3764, 17409132100, 0.25 +Res-1.3765, 17409132100, 0.25 +Res-1.3766, 17409132100, 0.25 +Res-1.3767, 17409132100, 0.25 +Res-1.3768, 17409132100, 0.25 +Res-1.3769, 17409132100, 0.25 +Res-1.3770, 17409132100, 0.25 +Res-1.3771, 17409132100, 0.25 +Res-1.3772, 17409132100, 0.25 +Res-1.3773, 17409132100, 0.25 +Res-1.3774, 17409132100, 0.25 +Res-1.3775, 17409132100, 0.25 +Res-1.3776, 17409132100, 0.25 +Res-1.3777, 17409132100, 0.25 +Res-1.3778, 17409132100, 0.25 +Res-1.3779, 17409132100, 0.25 +Res-1.3780, 17409132100, 0.25 +Res-1.3781, 17409132100, 0.25 +Res-1.3782, 17409132100, 0.25 +Res-1.3783, 17409132100, 0.25 +Res-1.3784, 17409132100, 0.25 +Res-1.3785, 17409132100, 0.25 +Res-1.3786, 17409132100, 0.25 +Res-1.3787, 17409132100, 0.25 +Res-1.3788, 17409132100, 0.25 +Res-1.3789, 17409132100, 0.25 +Res-1.3790, 17409132100, 0.25 +Res-1.3791, 17409132100, 0.25 +Res-1.3792, 17409132100, 0.25 +Res-1.3793, 17409132100, 0.25 +Res-1.3794, 17409132100, 0.25 +Res-1.3795, 17409132100, 0.25 +Res-1.3796, 17409132100, 0.25 +Res-1.3797, 17409132100, 0.25 +Res-1.3798, 17409132100, 0.25 +Res-1.3799, 17409132100, 0.25 +Res-1.3800, 17409132100, 0.25 +Res-1.3801, 17409132100, 0.25 +Res-1.3802, 17409132100, 0.25 +Res-1.3803, 17409132100, 0.25 +Res-1.3804, 17409132100, 0.25 +Res-1.3805, 17409132100, 0.25 +Res-1.3806, 17409132100, 0.25 +Res-1.3807, 17409132100, 0.25 +Res-1.3808, 17409132100, 0.25 +Res-1.3809, 17409132100, 0.25 +Res-1.3810, 17409132100, 0.25 +Res-1.3811, 17409132100, 0.25 +Res-1.3812, 17409132100, 0.25 +Res-1.3813, 17409132100, 0.25 +Res-1.3814, 17409132100, 0.25 +Res-1.3815, 17409132100, 0.25 +Res-1.3816, 17409132100, 0.25 +Res-1.3817, 17409132100, 0.25 +Res-1.3818, 17409132100, 0.25 +Res-1.3819, 17409132100, 0.25 +Res-1.3820, 17409132100, 0.25 +Res-1.3821, 17409132100, 0.25 +Res-1.3822, 17409132100, 0.25 +Res-1.3823, 17409132100, 0.25 +Res-1.3824, 17409132100, 0.25 +Res-1.3825, 17409132100, 0.25 +Res-1.3826, 17409132100, 0.25 +Res-1.3827, 17409132100, 0.25 +Res-1.3828, 17409132100, 0.25 +Res-1.3829, 17409132100, 0.25 +Res-1.3830, 17409132100, 0.25 +Res-1.3831, 17409132100, 0.25 +Res-1.3832, 17409132100, 0.25 +Res-1.3833, 17409132100, 0.25 +Res-1.3834, 17409132100, 0.25 +Res-1.3835, 17409132100, 0.25 +Res-1.3836, 17409132100, 0.25 +Res-1.3837, 17409132100, 0.25 +Res-1.3838, 17409132100, 0.25 +Res-1.3839, 17409132100, 0.25 +Res-1.3840, 17409132100, 0.25 +Res-1.3841, 17409132100, 0.25 +Res-1.3842, 17409132100, 0.25 +Res-1.3843, 17409132100, 0.25 +Res-1.3844, 17409132100, 0.25 +Res-1.3845, 17409132100, 0.25 +Res-1.3846, 17409132100, 0.25 +Res-1.3847, 17409132100, 0.25 +Res-1.3848, 17409132100, 0.25 +Res-1.3849, 17409132100, 0.25 +Res-1.3850, 17409132100, 0.25 +Res-1.3851, 17409132100, 0.25 +Res-1.3852, 17409132100, 0.25 +Res-1.3853, 17409132100, 0.25 +Res-1.3854, 17409132100, 0.25 +Res-1.3855, 17409132100, 0.25 +Res-1.3856, 17409132100, 0.25 +Res-1.3857, 17409132100, 0.25 +Res-1.3858, 17409132100, 0.25 +Res-1.3859, 17409132100, 0.25 +Res-1.3860, 17409132100, 0.25 +Res-1.3861, 17409132100, 0.25 +Res-1.3862, 17409132100, 0.25 +Res-1.3863, 17409132100, 0.25 +Res-1.3864, 17409132100, 0.25 +Res-1.3865, 17409132100, 0.25 +Res-1.3866, 17409132100, 0.25 +Res-1.3867, 17409132100, 0.25 +Res-1.3868, 17409132100, 0.25 +Res-1.3869, 17409132100, 0.25 +Res-1.3870, 17409132100, 0.25 +Res-1.3871, 17409132100, 0.25 +Res-1.3872, 17409132100, 0.25 +Res-1.3873, 17409132100, 0.25 +Res-1.3874, 17409132100, 0.25 +Res-1.3875, 17409132100, 0.25 +Res-1.3876, 17409132100, 0.25 +Res-1.3877, 17409132100, 0.25 +Res-1.3878, 17409132100, 0.25 +Res-1.3879, 17409132100, 0.25 +Res-1.3880, 17409132100, 0.25 +Res-1.3881, 17409132100, 0.25 +Res-1.3882, 17409132100, 0.25 +Res-1.3883, 17409132100, 0.25 +Res-1.3884, 17409132100, 0.25 +Res-1.3885, 17409132100, 0.25 +Res-1.3886, 17409132100, 0.25 +Res-1.3887, 17409132100, 0.25 +Res-1.3888, 17409132100, 0.25 +Res-1.3889, 17409132100, 0.25 +Res-1.3890, 17409132100, 0.25 +Res-1.3891, 17409132100, 0.25 +Res-1.3892, 17409132100, 0.25 +Res-1.3893, 17409132100, 0.25 +Res-1.3894, 17409132100, 0.25 +Res-1.3895, 17409132100, 0.25 +Res-1.3896, 17409132100, 0.25 +Res-1.3897, 17409132100, 0.25 +Res-1.3898, 17409132100, 0.25 +Res-1.3899, 17409132100, 0.25 +Res-1.3900, 17409132100, 0.25 +Res-1.3901, 17409132100, 0.25 +Res-1.3902, 17409132100, 0.25 +Res-1.3903, 17409132100, 0.25 +Res-1.3904, 17409132100, 0.25 +Res-1.3905, 17409132100, 0.25 +Res-1.3906, 17409132100, 0.25 +Res-1.3907, 17409132100, 0.25 +Res-1.3908, 17409132100, 0.25 +Res-1.3909, 17409132100, 0.25 +Res-1.3910, 17409132100, 0.25 +Res-1.3911, 17409132100, 0.25 +Res-1.3912, 17409132100, 0.25 +Res-1.3913, 17409132100, 0.25 +Res-1.3914, 17409132100, 0.25 +Res-1.3915, 17409132100, 0.25 +Res-1.3916, 17409132100, 0.25 +Res-1.3917, 17409132100, 0.25 +Res-1.3918, 17409132100, 0.25 +Res-1.3919, 17409132100, 0.25 +Res-1.3920, 17409132100, 0.25 +Res-1.3921, 17409132100, 0.25 +Res-1.3922, 17409132100, 0.25 +Res-1.3923, 17409132100, 0.25 +Res-1.3924, 17409132100, 0.25 +Res-1.3925, 17409132100, 0.25 +Res-1.3926, 17409132100, 0.25 +Res-1.3927, 17409132100, 0.25 +Res-1.3928, 17409132100, 0.25 +Res-1.3929, 17409132100, 0.25 +Res-1.3930, 17409132100, 0.25 +Res-1.3931, 17409132100, 0.25 +Res-1.3932, 17409132100, 0.25 +Res-1.3933, 17409132100, 0.25 +Res-1.3934, 17409132100, 0.25 +Res-1.3935, 17409132100, 0.25 +Res-1.3936, 17409132100, 0.25 +Res-1.3937, 17409132100, 0.25 +Res-1.3938, 17409132100, 0.25 +Res-1.3939, 17409132100, 0.25 +Res-1.3940, 17409132100, 0.25 +Res-1.3941, 17409132100, 0.25 +Res-1.3942, 17409132100, 0.25 +Res-1.3943, 17409132100, 0.25 +Res-1.3944, 17409132100, 0.25 +Res-1.3945, 17409132100, 0.25 +Res-1.3946, 17409132100, 0.25 +Res-1.3947, 17409132100, 0.25 +Res-1.3948, 17409132100, 0.25 +Res-1.3949, 17409132100, 0.25 +Res-1.3950, 17409132100, 0.25 +Res-1.3951, 17409132100, 0.25 +Res-1.3952, 17409132100, 0.25 +Res-1.3953, 17409132100, 0.25 +Res-1.3954, 17409132100, 0.25 +Res-1.3955, 17409132100, 0.25 +Res-1.3956, 17409132100, 0.25 +Res-1.3957, 17409132100, 0.25 +Res-1.3958, 17409132100, 0.25 +Res-1.3959, 17409132100, 0.25 +Res-1.3960, 17409132100, 0.25 +Res-1.3961, 17409132100, 0.25 +Res-1.3962, 17409132100, 0.25 +Res-1.3963, 17409132100, 0.25 +Res-1.3964, 17409132100, 0.25 +Res-1.3965, 17409132100, 0.25 +Res-1.3966, 17409132100, 0.25 +Res-1.3967, 17409132100, 0.25 +Res-1.3968, 17409132100, 0.25 +Res-1.3969, 17409132100, 0.25 +Res-1.3970, 17409132100, 0.25 +Res-1.3971, 17409132100, 0.25 +Res-1.3972, 17409132100, 0.25 +Res-1.3973, 17409132100, 0.25 +Res-1.3974, 17409132100, 0.25 +Res-1.3975, 17409132100, 0.25 +Res-1.3976, 17409132100, 0.25 +Res-1.3977, 17409132100, 0.25 +Res-1.3978, 17409132100, 0.25 +Res-1.3979, 17409132100, 0.25 +Res-1.3980, 17409132100, 0.25 +Res-1.3981, 17409132100, 0.25 +Res-1.3982, 17409132100, 0.25 +Res-1.3983, 17409132100, 0.25 +Res-1.3984, 17409132100, 0.25 +Res-1.3985, 17409132100, 0.25 +Res-1.3986, 17409132100, 0.25 +Res-1.3987, 17409132100, 0.25 +Res-1.3988, 17409132100, 0.25 +Res-1.3989, 17409132100, 0.25 +Res-1.3990, 17409132100, 0.25 +Res-1.3991, 17409132100, 0.25 +Res-1.3992, 17409132100, 0.25 +Res-1.3993, 17409132100, 0.25 +Res-1.3994, 17409132100, 0.25 +Res-1.3995, 17409132100, 0.25 +Res-1.3996, 17409132100, 0.25 +Res-1.3997, 17409132100, 0.25 +Res-1.3998, 17409132100, 0.25 +Res-1.3999, 17409132100, 0.25 +Res-1.4000, 17409132100, 0.25 +Res-1.4001, 17409132100, 0.25 +Res-1.4002, 17409132100, 0.25 +Res-1.4003, 17409132100, 0.25 +Res-1.4004, 17409132100, 0.25 +Res-1.4005, 17409132100, 0.25 +Res-1.4006, 17409132100, 0.25 +Res-1.4007, 17409132100, 0.25 +Res-1.4008, 17409132100, 0.25 +Res-1.4009, 17409132100, 0.25 +Res-1.4010, 17409132100, 0.25 +Res-1.4011, 17409132100, 0.25 +Res-1.4012, 17409132100, 0.25 +Res-1.4013, 17409132100, 0.25 +Res-1.4014, 17409132100, 0.25 +Res-1.4015, 17409132100, 0.25 +Res-1.4016, 17409132100, 0.25 +Res-1.4017, 17409132100, 0.25 +Res-1.4018, 17409132100, 0.25 +Res-1.4019, 17409132100, 0.25 +Res-1.4020, 17409132100, 0.25 +Res-1.4021, 17409132100, 0.25 +Res-1.4022, 17409132100, 0.25 +Res-1.4023, 17409132100, 0.25 +Res-1.4024, 17409132100, 0.25 +Res-1.4025, 17409132100, 0.25 +Res-1.4026, 17409132100, 0.25 +Res-1.4027, 17409132100, 0.25 +Res-1.4028, 17409132100, 0.25 +Res-1.4029, 17409132100, 0.25 +Res-1.4030, 17409132100, 0.25 +Res-1.4031, 17409132100, 0.25 +Res-1.4032, 17409132100, 0.25 +Res-1.4033, 13250853676.3636, 0.25 +Res-1.4034, 13250853676.3636, 0.25 +Res-1.4035, 13250853676.3636, 0.25 +Res-1.4036, 13250853676.3636, 0.25 +Res-1.4037, 13250853676.3636, 0.25 +Res-1.4038, 13250853676.3636, 0.25 +Res-1.4039, 13250853676.3636, 0.25 +Res-1.4040, 13250853676.3636, 0.25 +Res-1.4041, 13250853676.3636, 0.25 +Res-1.4042, 13250853676.3636, 0.25 +Res-1.4043, 13250853676.3636, 0.25 +Res-1.4044, 13250853676.3636, 0.25 +Res-1.4045, 13250853676.3636, 0.25 +Res-1.4046, 13250853676.3636, 0.25 +Res-1.4047, 13250853676.3636, 0.25 +Res-1.4048, 13250853676.3636, 0.25 +Res-1.4049, 13250853676.3636, 0.25 +Res-1.4050, 13250853676.3636, 0.25 +Res-1.4051, 13250853676.3636, 0.25 +Res-1.4052, 13250853676.3636, 0.25 +Res-1.4053, 13250853676.3636, 0.25 +Res-1.4054, 13250853676.3636, 0.25 +Res-1.4055, 13250853676.3636, 0.25 +Res-1.4056, 13250853676.3636, 0.25 +Res-1.4057, 13250853676.3636, 0.25 +Res-1.4058, 13250853676.3636, 0.25 +Res-1.4059, 13250853676.3636, 0.25 +Res-1.4060, 13250853676.3636, 0.25 +Res-1.4061, 13250853676.3636, 0.25 +Res-1.4062, 13250853676.3636, 0.25 +Res-1.4063, 13250853676.3636, 0.25 +Res-1.4064, 13250853676.3636, 0.25 +Res-1.4065, 13250853676.3636, 0.25 +Res-1.4066, 13250853676.3636, 0.25 +Res-1.4067, 13250853676.3636, 0.25 +Res-1.4068, 13250853676.3636, 0.25 +Res-1.4069, 13250853676.3636, 0.25 +Res-1.4070, 13250853676.3636, 0.25 +Res-1.4071, 13250853676.3636, 0.25 +Res-1.4072, 13250853676.3636, 0.25 +Res-1.4073, 13250853676.3636, 0.25 +Res-1.4074, 13250853676.3636, 0.25 +Res-1.4075, 13250853676.3636, 0.25 +Res-1.4076, 13250853676.3636, 0.25 +Res-1.4077, 13250853676.3636, 0.25 +Res-1.4078, 13250853676.3636, 0.25 +Res-1.4079, 13250853676.3636, 0.25 +Res-1.4080, 13250853676.3636, 0.25 +Res-1.4081, 13250853676.3636, 0.25 +Res-1.4082, 13250853676.3636, 0.25 +Res-1.4083, 13250853676.3636, 0.25 +Res-1.4084, 13250853676.3636, 0.25 +Res-1.4085, 13250853676.3636, 0.25 +Res-1.4086, 13250853676.3636, 0.25 +Res-1.4087, 13250853676.3636, 0.25 +Res-1.4088, 13250853676.3636, 0.25 +Res-1.4089, 13250853676.3636, 0.25 +Res-1.4090, 13250853676.3636, 0.25 +Res-1.4091, 13250853676.3636, 0.25 +Res-1.4092, 13250853676.3636, 0.25 +Res-1.4093, 13250853676.3636, 0.25 +Res-1.4094, 13250853676.3636, 0.25 +Res-1.4095, 13250853676.3636, 0.25 +Res-1.4096, 13250853676.3636, 0.25 +Res-1.4097, 13250853676.3636, 0.25 +Res-1.4098, 13250853676.3636, 0.25 +Res-1.4099, 13250853676.3636, 0.25 +Res-1.4100, 13250853676.3636, 0.25 +Res-1.4101, 13250853676.3636, 0.25 +Res-1.4102, 13250853676.3636, 0.25 +Res-1.4103, 13250853676.3636, 0.25 +Res-1.4104, 13250853676.3636, 0.25 +Res-1.4105, 13250853676.3636, 0.25 +Res-1.4106, 13250853676.3636, 0.25 +Res-1.4107, 13250853676.3636, 0.25 +Res-1.4108, 13250853676.3636, 0.25 +Res-1.4109, 13250853676.3636, 0.25 +Res-1.4110, 13250853676.3636, 0.25 +Res-1.4111, 13250853676.3636, 0.25 +Res-1.4112, 13250853676.3636, 0.25 +Res-1.4113, 13250853676.3636, 0.25 +Res-1.4114, 13250853676.3636, 0.25 +Res-1.4115, 13250853676.3636, 0.25 +Res-1.4116, 13250853676.3636, 0.25 +Res-1.4117, 13250853676.3636, 0.25 +Res-1.4118, 13250853676.3636, 0.25 +Res-1.4119, 13250853676.3636, 0.25 +Res-1.4120, 13250853676.3636, 0.25 +Res-1.4121, 13250853676.3636, 0.25 +Res-1.4122, 13250853676.3636, 0.25 +Res-1.4123, 13250853676.3636, 0.25 +Res-1.4124, 13250853676.3636, 0.25 +Res-1.4125, 13250853676.3636, 0.25 +Res-1.4126, 13250853676.3636, 0.25 +Res-1.4127, 13250853676.3636, 0.25 +Res-1.4128, 13250853676.3636, 0.25 +Res-1.4129, 13250853676.3636, 0.25 +Res-1.4130, 13250853676.3636, 0.25 +Res-1.4131, 13250853676.3636, 0.25 +Res-1.4132, 13250853676.3636, 0.25 +Res-1.4133, 13250853676.3636, 0.25 +Res-1.4134, 13250853676.3636, 0.25 +Res-1.4135, 13250853676.3636, 0.25 +Res-1.4136, 13250853676.3636, 0.25 +Res-1.4137, 13250853676.3636, 0.25 +Res-1.4138, 13250853676.3636, 0.25 +Res-1.4139, 13250853676.3636, 0.25 +Res-1.4140, 13250853676.3636, 0.25 +Res-1.4141, 13250853676.3636, 0.25 +Res-1.4142, 13250853676.3636, 0.25 +Res-1.4143, 13250853676.3636, 0.25 +Res-1.4144, 13250853676.3636, 0.25 +Res-1.4145, 13250853676.3636, 0.25 +Res-1.4146, 13250853676.3636, 0.25 +Res-1.4147, 13250853676.3636, 0.25 +Res-1.4148, 13250853676.3636, 0.25 +Res-1.4149, 13250853676.3636, 0.25 +Res-1.4150, 13250853676.3636, 0.25 +Res-1.4151, 13250853676.3636, 0.25 +Res-1.4152, 13250853676.3636, 0.25 +Res-1.4153, 13250853676.3636, 0.25 +Res-1.4154, 13250853676.3636, 0.25 +Res-1.4155, 13250853676.3636, 0.25 +Res-1.4156, 13250853676.3636, 0.25 +Res-1.4157, 13250853676.3636, 0.25 +Res-1.4158, 13250853676.3636, 0.25 +Res-1.4159, 13250853676.3636, 0.25 +Res-1.4160, 13250853676.3636, 0.25 +Res-1.4161, 13250853676.3636, 0.25 +Res-1.4162, 13250853676.3636, 0.25 +Res-1.4163, 13250853676.3636, 0.25 +Res-1.4164, 13250853676.3636, 0.25 +Res-1.4165, 13250853676.3636, 0.25 +Res-1.4166, 13250853676.3636, 0.25 +Res-1.4167, 13250853676.3636, 0.25 +Res-1.4168, 13250853676.3636, 0.25 +Res-1.4169, 13250853676.3636, 0.25 +Res-1.4170, 13250853676.3636, 0.25 +Res-1.4171, 13250853676.3636, 0.25 +Res-1.4172, 13250853676.3636, 0.25 +Res-1.4173, 13250853676.3636, 0.25 +Res-1.4174, 13250853676.3636, 0.25 +Res-1.4175, 13250853676.3636, 0.25 +Res-1.4176, 13250853676.3636, 0.25 +Res-1.4177, 13250853676.3636, 0.25 +Res-1.4178, 13250853676.3636, 0.25 +Res-1.4179, 13250853676.3636, 0.25 +Res-1.4180, 13250853676.3636, 0.25 +Res-1.4181, 13250853676.3636, 0.25 +Res-1.4182, 13250853676.3636, 0.25 +Res-1.4183, 13250853676.3636, 0.25 +Res-1.4184, 13250853676.3636, 0.25 +Res-1.4185, 13250853676.3636, 0.25 +Res-1.4186, 13250853676.3636, 0.25 +Res-1.4187, 13250853676.3636, 0.25 +Res-1.4188, 13250853676.3636, 0.25 +Res-1.4189, 13250853676.3636, 0.25 +Res-1.4190, 13250853676.3636, 0.25 +Res-1.4191, 13250853676.3636, 0.25 +Res-1.4192, 13250853676.3636, 0.25 +Res-1.4193, 13250853676.3636, 0.25 +Res-1.4194, 13250853676.3636, 0.25 +Res-1.4195, 13250853676.3636, 0.25 +Res-1.4196, 13250853676.3636, 0.25 +Res-1.4197, 13250853676.3636, 0.25 +Res-1.4198, 13250853676.3636, 0.25 +Res-1.4199, 13250853676.3636, 0.25 +Res-1.4200, 13250853676.3636, 0.25 +Res-1.4201, 13250853676.3636, 0.25 +Res-1.4202, 13250853676.3636, 0.25 +Res-1.4203, 13250853676.3636, 0.25 +Res-1.4204, 13250853676.3636, 0.25 +Res-1.4205, 13250853676.3636, 0.25 +Res-1.4206, 13250853676.3636, 0.25 +Res-1.4207, 13250853676.3636, 0.25 +Res-1.4208, 13250853676.3636, 0.25 +Res-1.4209, 13250853676.3636, 0.25 +Res-1.4210, 13250853676.3636, 0.25 +Res-1.4211, 13250853676.3636, 0.25 +Res-1.4212, 13250853676.3636, 0.25 +Res-1.4213, 13250853676.3636, 0.25 +Res-1.4214, 13250853676.3636, 0.25 +Res-1.4215, 13250853676.3636, 0.25 +Res-1.4216, 13250853676.3636, 0.25 +Res-1.4217, 13250853676.3636, 0.25 +Res-1.4218, 13250853676.3636, 0.25 +Res-1.4219, 13250853676.3636, 0.25 +Res-1.4220, 13250853676.3636, 0.25 +Res-1.4221, 13250853676.3636, 0.25 +Res-1.4222, 13250853676.3636, 0.25 +Res-1.4223, 13250853676.3636, 0.25 +Res-1.4224, 13250853676.3636, 0.25 +Res-1.4225, 13250853676.3636, 0.25 +Res-1.4226, 13250853676.3636, 0.25 +Res-1.4227, 13250853676.3636, 0.25 +Res-1.4228, 13250853676.3636, 0.25 +Res-1.4229, 13250853676.3636, 0.25 +Res-1.4230, 13250853676.3636, 0.25 +Res-1.4231, 13250853676.3636, 0.25 +Res-1.4232, 13250853676.3636, 0.25 +Res-1.4233, 13250853676.3636, 0.25 +Res-1.4234, 13250853676.3636, 0.25 +Res-1.4235, 13250853676.3636, 0.25 +Res-1.4236, 13250853676.3636, 0.25 +Res-1.4237, 13250853676.3636, 0.25 +Res-1.4238, 13250853676.3636, 0.25 +Res-1.4239, 13250853676.3636, 0.25 +Res-1.4240, 13250853676.3636, 0.25 +Res-1.4241, 13250853676.3636, 0.25 +Res-1.4242, 13250853676.3636, 0.25 +Res-1.4243, 13250853676.3636, 0.25 +Res-1.4244, 13250853676.3636, 0.25 +Res-1.4245, 13250853676.3636, 0.25 +Res-1.4246, 13250853676.3636, 0.25 +Res-1.4247, 13250853676.3636, 0.25 +Res-1.4248, 13250853676.3636, 0.25 +Res-1.4249, 13250853676.3636, 0.25 +Res-1.4250, 13250853676.3636, 0.25 +Res-1.4251, 13250853676.3636, 0.25 +Res-1.4252, 13250853676.3636, 0.25 +Res-1.4253, 13250853676.3636, 0.25 +Res-1.4254, 13250853676.3636, 0.25 +Res-1.4255, 13250853676.3636, 0.25 +Res-1.4256, 13250853676.3636, 0.25 +Res-1.4257, 13250853676.3636, 0.25 +Res-1.4258, 13250853676.3636, 0.25 +Res-1.4259, 13250853676.3636, 0.25 +Res-1.4260, 13250853676.3636, 0.25 +Res-1.4261, 13250853676.3636, 0.25 +Res-1.4262, 13250853676.3636, 0.25 +Res-1.4263, 13250853676.3636, 0.25 +Res-1.4264, 13250853676.3636, 0.25 +Res-1.4265, 13250853676.3636, 0.25 +Res-1.4266, 13250853676.3636, 0.25 +Res-1.4267, 13250853676.3636, 0.25 +Res-1.4268, 13250853676.3636, 0.25 +Res-1.4269, 13250853676.3636, 0.25 +Res-1.4270, 13250853676.3636, 0.25 +Res-1.4271, 13250853676.3636, 0.25 +Res-1.4272, 13250853676.3636, 0.25 +Res-1.4273, 13250853676.3636, 0.25 +Res-1.4274, 13250853676.3636, 0.25 +Res-1.4275, 13250853676.3636, 0.25 +Res-1.4276, 13250853676.3636, 0.25 +Res-1.4277, 13250853676.3636, 0.25 +Res-1.4278, 13250853676.3636, 0.25 +Res-1.4279, 13250853676.3636, 0.25 +Res-1.4280, 13250853676.3636, 0.25 +Res-1.4281, 13250853676.3636, 0.25 +Res-1.4282, 13250853676.3636, 0.25 +Res-1.4283, 13250853676.3636, 0.25 +Res-1.4284, 13250853676.3636, 0.25 +Res-1.4285, 13250853676.3636, 0.25 +Res-1.4286, 13250853676.3636, 0.25 +Res-1.4287, 13250853676.3636, 0.25 +Res-1.4288, 13250853676.3636, 0.25 +Res-1.4289, 13250853676.3636, 0.25 +Res-1.4290, 13250853676.3636, 0.25 +Res-1.4291, 13250853676.3636, 0.25 +Res-1.4292, 13250853676.3636, 0.25 +Res-1.4293, 13250853676.3636, 0.25 +Res-1.4294, 13250853676.3636, 0.25 +Res-1.4295, 13250853676.3636, 0.25 +Res-1.4296, 13250853676.3636, 0.25 +Res-1.4297, 13250853676.3636, 0.25 +Res-1.4298, 13250853676.3636, 0.25 +Res-1.4299, 13250853676.3636, 0.25 +Res-1.4300, 13250853676.3636, 0.25 +Res-1.4301, 13250853676.3636, 0.25 +Res-1.4302, 13250853676.3636, 0.25 +Res-1.4303, 13250853676.3636, 0.25 +Res-1.4304, 13250853676.3636, 0.25 +Res-1.4305, 13250853676.3636, 0.25 +Res-1.4306, 13250853676.3636, 0.25 +Res-1.4307, 13250853676.3636, 0.25 +Res-1.4308, 13250853676.3636, 0.25 +Res-1.4309, 13250853676.3636, 0.25 +Res-1.4310, 13250853676.3636, 0.25 +Res-1.4311, 13250853676.3636, 0.25 +Res-1.4312, 13250853676.3636, 0.25 +Res-1.4313, 13250853676.3636, 0.25 +Res-1.4314, 13250853676.3636, 0.25 +Res-1.4315, 13250853676.3636, 0.25 +Res-1.4316, 13250853676.3636, 0.25 +Res-1.4317, 13250853676.3636, 0.25 +Res-1.4318, 13250853676.3636, 0.25 +Res-1.4319, 13250853676.3636, 0.25 +Res-1.4320, 13250853676.3636, 0.25 \ No newline at end of file From effe1f291a90912b3eb449aa2af1259be60dcd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 9 Jan 2018 15:44:54 +0100 Subject: [PATCH 0012/1027] RifElementPropertyTableReader-Test. Fix names --- .../UnitTests/CMakeLists_files.cmake | 2 +- .../RicElementPropertyTableReader-Test.cpp | 2 +- .../RifElementPropertyTableReader-Test.cpp | 53 +++++++++++++++++++ .../ELASTIC_TABLE.inp | 0 .../ELASTIC_TABLE_error.inp | 0 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp rename ApplicationCode/UnitTests/TestData/{ElementPropertyTable => RifElementPropertyTableReader}/ELASTIC_TABLE.inp (100%) rename ApplicationCode/UnitTests/TestData/{ElementPropertyTable => RifElementPropertyTableReader}/ELASTIC_TABLE_error.inp (100%) diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 7744bd48bf..c979307ca3 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -40,7 +40,7 @@ ${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp ${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp ${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp ${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RicElementPropertyTableReader-Test.cpp +${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader-Test.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp index cc19c06c12..6d4d42080b 100644 --- a/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp +++ b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp @@ -8,7 +8,7 @@ #include -static const QString TEST_DATA_DIRECTORY = QString("%1/ElementPropertyTable/").arg(TEST_DATA_DIR); +static const QString TEST_DATA_DIRECTORY = QString("%1/RifElementPropertyTableReader/").arg(TEST_DATA_DIR); //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp new file mode 100644 index 0000000000..6d4d42080b --- /dev/null +++ b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp @@ -0,0 +1,53 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifElementPropertyTableReader.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifElementPropertyTableReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, BasicUsage) +{ + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(table.hasData); + + EXPECT_EQ(2, metadata.dataColumns.size()); + EXPECT_STREQ("MODULUS", metadata.dataColumns[0].toStdString().c_str()); + EXPECT_STREQ("RATIO", metadata.dataColumns[1].toStdString().c_str()); + + EXPECT_EQ(2, table.data.size()); + EXPECT_EQ(4320, table.elementIds.size()); + EXPECT_EQ(4320, table.data[0].size()); + EXPECT_EQ(4320, table.data[1].size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, ParseFailed) +{ + try + { + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE_error.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.startsWith("Number of columns mismatch")); + } +} diff --git a/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE.inp similarity index 100% rename from ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE.inp rename to ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE.inp diff --git a/ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE_error.inp similarity index 100% rename from ApplicationCode/UnitTests/TestData/ElementPropertyTable/ELASTIC_TABLE_error.inp rename to ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE_error.inp From 49eebd0c28760c98fce113ed730d00fa0eb0f0b1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Jan 2018 07:34:45 +0100 Subject: [PATCH 0013/1027] #2359 Fracture : Adjust default parameters for ellipse fracture --- .../RicNewEllipseFractureTemplateFeature.cpp | 12 +++---- .../RimEllipseFractureTemplate.cpp | 32 ++++++++++++++++--- .../Completions/RimEllipseFractureTemplate.h | 1 + 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index 094c4c1039..2d521f37c0 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -51,14 +51,14 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) if (fracDefColl) { - RimEllipseFractureTemplate* fractureDef = new RimEllipseFractureTemplate(); - fracDefColl->fractureDefinitions.push_back(fractureDef); - fractureDef->name = "Ellipse Fracture Template"; - fractureDef->fractureTemplateUnit = fracDefColl->defaultUnitsForFracTemplates(); - fractureDef->setDefaultWellDiameterFromUnit(); + RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate(); + fracDefColl->fractureDefinitions.push_back(ellipseFractureTemplate); + ellipseFractureTemplate->name = "Ellipse Fracture Template"; + ellipseFractureTemplate->fractureTemplateUnit = fracDefColl->defaultUnitsForFracTemplates(); + ellipseFractureTemplate->setDefaultValuesFromUnit(); fracDefColl->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fractureDef); + RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 27c3c23c1d..b5c1b09fd3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -47,15 +47,14 @@ RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&halfLength, "HalfLength", 650.0f, "Halflength Xf", "", "", ""); - CAF_PDM_InitField(&height, "Height", 75.0f, "Height", "", "", ""); - CAF_PDM_InitField(&width, "Width", 1.0f, "Width", "", "", ""); + CAF_PDM_InitField(&halfLength, "HalfLength", 0.0f, "Halflength Xf", "", "", ""); + CAF_PDM_InitField(&height, "Height", 0.0f, "Height", "", "", ""); + CAF_PDM_InitField(&width, "Width", 0.0f, "Width", "", "", ""); - CAF_PDM_InitField(&permeability,"Permeability", 22000.f, "Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&permeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); setupFractureGridCells(); - } //-------------------------------------------------------------------------------------------------- @@ -276,6 +275,29 @@ const RigFractureGrid* RimEllipseFractureTemplate::fractureGrid() const return m_fractureGrid.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::setDefaultValuesFromUnit() +{ + if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + width = 0.5f; + permeability = 800000.0f; + halfLength = 300.0f; + height = 225.0f; + } + else + { + width = 0.01f; + permeability = 1000000.0f; + halfLength = 100.0f; + height = 75.0f; + } + + this->setDefaultWellDiameterFromUnit(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 48b0b4feae..f65f5ee1d6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -64,6 +64,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate const RigFractureGrid* fractureGrid() const; + void setDefaultValuesFromUnit(); protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); From 30cbd8018f23f5e0e79a77a13a3ab6350d4724cb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Jan 2018 07:44:26 +0100 Subject: [PATCH 0014/1027] #2359 Move fields to private, whitespace cleanup --- .../RimEllipseFractureTemplate.cpp | 104 +++++++++--------- .../Completions/RimEllipseFractureTemplate.h | 25 +++-- .../Completions/RimFractureTemplate.cpp | 6 +- .../Completions/RimFractureTemplate.h | 6 +- 4 files changed, 71 insertions(+), 70 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index b5c1b09fd3..e1448244c1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -47,11 +47,11 @@ RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&halfLength, "HalfLength", 0.0f, "Halflength Xf", "", "", ""); - CAF_PDM_InitField(&height, "Height", 0.0f, "Height", "", "", ""); - CAF_PDM_InitField(&width, "Width", 0.0f, "Width", "", "", ""); + CAF_PDM_InitField(&m_halfLength, "HalfLength", 0.0f, "Halflength Xf", "", "", ""); + CAF_PDM_InitField(&m_height, "Height", 0.0f, "Height", "", "", ""); + CAF_PDM_InitField(&m_width, "Width", 0.0f, "Width", "", "", ""); - CAF_PDM_InitField(&permeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&m_permeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); setupFractureGridCells(); @@ -79,7 +79,7 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha { RimFractureTemplate::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &halfLength || changedField == &height) + if (changedField == &m_halfLength || changedField == &m_height) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -91,7 +91,7 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha setupFractureGridCells(); } } - if (changedField == &width || changedField == &permeability) + if (changedField == &m_width || changedField == &m_permeability) { setupFractureGridCells(); } @@ -111,21 +111,21 @@ void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector cellPolygon; cellPolygon.push_back(cvf::Vec3d(X1, Y1, 0.0)); @@ -222,12 +222,12 @@ void RimEllipseFractureTemplate::setupFractureGridCells() if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { //Conductivity should be md-m, width is in m - cond = permeability * width; + cond = m_permeability * m_width; } else if(fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { //Conductivity should be md-ft, but width is in inches - cond = permeability * RiaEclipseUnitTools::inchToFeet(width); + cond = m_permeability * RiaEclipseUnitTools::inchToFeet(m_width); } std::vector ellipseFracPolygon = fractureBorderPolygon(fractureTemplateUnit()); @@ -282,17 +282,17 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() { if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - width = 0.5f; - permeability = 800000.0f; - halfLength = 300.0f; - height = 225.0f; + m_width = 0.5f; + m_permeability = 800000.0f; + m_halfLength = 300.0f; + m_height = 225.0f; } else { - width = 0.01f; - permeability = 1000000.0f; - halfLength = 100.0f; - height = 75.0f; + m_width = 0.01f; + m_permeability = 1000000.0f; + m_halfLength = 100.0f; + m_height = 75.0f; } this->setDefaultWellDiameterFromUnit(); @@ -307,37 +307,37 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { - halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); - height.uiCapability()->setUiName("Height [m]"); - width.uiCapability()->setUiName("Width [m]"); + m_halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); + m_height.uiCapability()->setUiName("Height [m]"); + m_width.uiCapability()->setUiName("Width [m]"); wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); - height.uiCapability()->setUiName("Height [Ft]"); - width.uiCapability()->setUiName("Width [inches]"); + m_halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); + m_height.uiCapability()->setUiName("Height [Ft]"); + m_width.uiCapability()->setUiName("Width [inches]"); wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); } if (conductivityType == FINITE_CONDUCTIVITY) { - permeability.uiCapability()->setUiHidden(false); - width.uiCapability()->setUiHidden(false); + m_permeability.uiCapability()->setUiHidden(false); + m_width.uiCapability()->setUiHidden(false); } else if (conductivityType == INFINITE_CONDUCTIVITY) { - permeability.uiCapability()->setUiHidden(true); - width.uiCapability()->setUiHidden(true); + m_permeability.uiCapability()->setUiHidden(true); + m_width.uiCapability()->setUiHidden(true); } uiOrdering.add(&name); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); - geometryGroup->add(&halfLength); - geometryGroup->add(&height); + geometryGroup->add(&m_halfLength); + geometryGroup->add(&m_height); geometryGroup->add(&orientationType); geometryGroup->add(&azimuthAngle); @@ -346,8 +346,8 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&conductivityType); - propertyGroup->add(&permeability); - propertyGroup->add(&width); + propertyGroup->add(&m_permeability); + propertyGroup->add(&m_width); propertyGroup->add(&skinFactor); propertyGroup->add(&perforationLength); propertyGroup->add(&perforationEfficiency); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index f65f5ee1d6..47ebcc2cb9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -46,15 +46,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate RimEllipseFractureTemplate(void); virtual ~RimEllipseFractureTemplate(void); - caf::PdmField halfLength; - caf::PdmField height; - - caf::PdmField width; - caf::PdmField permeability; - void loadDataAndUpdate(); - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* polygonIndices, @@ -64,11 +56,20 @@ class RimEllipseFractureTemplate : public RimFractureTemplate const RigFractureGrid* fractureGrid() const; - void setDefaultValuesFromUnit(); + void setDefaultValuesFromUnit(); + protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + +private: + void setupFractureGridCells(); private: - void setupFractureGridCells(); - cvf::ref m_fractureGrid; + cvf::ref m_fractureGrid; + + caf::PdmField m_halfLength; + caf::PdmField m_height; + caf::PdmField m_width; + caf::PdmField m_permeability; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index d03302b918..70125b54cd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -61,7 +61,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimFractureTemplate, "RimFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFractureTemplate::RimFractureTemplate(void) +RimFractureTemplate::RimFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); @@ -226,7 +226,7 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field { if (field == &perforationEfficiency) { - caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); + auto myAttr = dynamic_cast(attribute); if (myAttr) { myAttr->m_minimum = 0; @@ -303,4 +303,4 @@ void RimFractureTemplate::setDefaultWellDiameterFromUnit() { wellDiameter = 0.216; } -} \ No newline at end of file +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index e053b9e0b0..2227114c08 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -45,8 +45,8 @@ class RimFractureTemplate : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RimFractureTemplate(void); - virtual ~RimFractureTemplate(void); + RimFractureTemplate(); + virtual ~RimFractureTemplate(); caf::PdmField name; caf::PdmField azimuthAngle; @@ -91,7 +91,7 @@ class RimFractureTemplate : public caf::PdmObject virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; From e22ceb5cc24313325d49734d3be624bb0a4cd7e8 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 9 Jan 2018 15:16:24 +0100 Subject: [PATCH 0015/1027] add override keyword --- .../ProjectDataModel/RimGeoMechResultDefinition.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index 428406fe06..13f39eab9a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -70,11 +70,11 @@ class RimGeoMechResultDefinition : public caf::PdmObject // Overridden PDM methods virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool * useOptionsOnly); + bool * useOptionsOnly) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, - const QVariant& newValue); - virtual void initAfterRead(); + const QVariant& newValue) override; + virtual void initAfterRead() override; // Metadata and option build tools From 0dc05335014e46393f1e10597ecc5250a6fabaa8 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 10:21:14 +0100 Subject: [PATCH 0016/1027] #2350 Elm props: Fix crash when table has only one data column --- ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp index eac61d4c9b..9a1992b770 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp @@ -124,7 +124,7 @@ void RifElementPropertyTableReader::readData(const RifElementPropertyMetadata *m if (!dataBlockFound) { - if (!line.startsWith("*") && cols.size() == expectedColumnCount) dataBlockFound = true; + if (!line.startsWith("*") && !line.startsWith(",") && cols.size() == expectedColumnCount) dataBlockFound = true; else continue; } From 2cd006882f35511977a6e9cbff17747eb3679799 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 10:43:33 +0100 Subject: [PATCH 0017/1027] #2360 Elm Props: Wire up reading of elm prop data into data structures --- .../RicImportElementPropertyFeature.cpp | 37 ++++++--- .../FileInterface/CMakeLists_files.cmake | 3 + .../RifElementPropertyReader.cpp | 81 +++++++++++++++++++ .../FileInterface/RifElementPropertyReader.h | 49 +++++++++++ .../RifElementPropertyTableReader.h | 2 - .../RigFemPartResultsCollection.cpp | 36 ++++++++- .../RigFemPartResultsCollection.h | 11 ++- .../GeoMechDataModel/RigGeoMechCaseData.cpp | 16 ++-- .../GeoMechDataModel/RigGeoMechCaseData.h | 10 ++- .../RivFemPartPartMgr.cpp | 4 +- .../ProjectDataModel/RimGeoMechCase.cpp | 16 ++++ .../ProjectDataModel/RimGeoMechCase.h | 4 +- 12 files changed, 242 insertions(+), 27 deletions(-) create mode 100644 ApplicationCode/FileInterface/RifElementPropertyReader.cpp create mode 100644 ApplicationCode/FileInterface/RifElementPropertyReader.h diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp index 9064e42abf..1c1c59bbc4 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -20,13 +20,19 @@ #include "RiaApplication.h" +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" + #include #include CAF_CMD_SOURCE_INIT(RicImportElementPropertyFeature, "RicImportElementPropertyFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicImportElementPropertyFeature::isCommandEnabled() { @@ -34,32 +40,43 @@ bool RicImportElementPropertyFeature::isCommandEnabled() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); - + QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); + QStringList fileNames = + QFileDialog::getOpenFileNames(NULL, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); + if (fileNames.size()) { defaultDir = QFileInfo(fileNames.last()).absolutePath(); } + std::vector fileNamesStd; + for (QString filename : fileNames) + { + fileNamesStd.push_back(filename); + } + app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir); - for (int i = 0; i < fileNames.size(); i++) - { - QString fileName = fileNames[i]; + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + + RimGeoMechView* activeGmv = dynamic_cast(activeView); + if (!activeGmv) return; - //TODO + if (activeGmv->geoMechCase()) + { + activeGmv->geoMechCase()->addElementPropertyFiles(fileNamesStd); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicImportElementPropertyFeature::setupActionLook(QAction* actionToSetup) { diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 96f3ba89cd..3f2483b921 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -41,6 +41,8 @@ ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.h +${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.h + # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h ) @@ -86,6 +88,7 @@ ${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.cpp +${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp new file mode 100644 index 0000000000..31954b93a5 --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifElementPropertyReader.h" + +#include "cvfAssert.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifElementPropertyReader::RifElementPropertyReader() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifElementPropertyReader::~RifElementPropertyReader() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::addFile(const std::string& fileName) +{ + RifElementPropertyMetadata metaData = RifElementPropertyTableReader::readMetadata(QString::fromStdString(fileName)); + for (QString field : metaData.dataColumns) + { + m_fields[field.toStdString()] = metaData; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map> RifElementPropertyReader::scalarElementFields() +{ + std::map> fields; + + for (std::map::iterator field = m_fields.begin(); field != m_fields.end(); field++) + { + fields[field->first]; + } + + return fields; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map> + RifElementPropertyReader::readAllElementPropertiesInFileContainingField(const std::string& fieldName) +{ + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&m_fields[fieldName], &table); + + CVF_ASSERT(m_fields[fieldName].dataColumns.size() == table.data.size()); + + std::map> fieldAndData; + + for (size_t i = 0; i < table.data.size(); i++) + { + fieldAndData[m_fields[fieldName].dataColumns[i].toStdString()].swap(table.data[i]); + } + + return fieldAndData; +} diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h new file mode 100644 index 0000000000..3a84471f52 --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifElementPropertyTableReader.h" + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include +#include +#include + +//================================================================================================== +// +// +//================================================================================================== +class RifElementPropertyReader : public cvf::Object +{ +public: + RifElementPropertyReader(); + virtual ~RifElementPropertyReader(); + + void addFile(const std::string& fileName); + + std::map> scalarElementFields(); + + std::map> readAllElementPropertiesInFileContainingField(const std::string& fieldName); + +private: + std::map m_fields; +}; diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h index f6765212de..2de6289d7e 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h @@ -18,8 +18,6 @@ #pragma once -#include "RigWellPathFormations.h" - #include #include #include diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 45a5088a6f..1801ece7fa 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -19,6 +19,7 @@ #include "RigFemPartResultsCollection.h" +#include "RifElementPropertyReader.h" #include "RifGeoMechReaderInterface.h" #ifdef USE_ODB_API @@ -57,10 +58,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection) +RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, RifElementPropertyReader* elementPropertyReader, const RigFemPartCollection* femPartCollection) { CVF_ASSERT(readerInterface); + CVF_ASSERT(elementPropertyReader); m_readerInterface = readerInterface; + m_elementPropertyReader = elementPropertyReader; m_femParts = femPartCollection; m_femPartResults.resize(m_femParts->partCount()); @@ -118,6 +121,17 @@ RigFormationNames* RigFemPartResultsCollection::activeFormationNames() return m_activeFormationNamesData.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) +{ + for (const QString filename : filenames) + { + m_elementPropertyReader->addFile(filename.toStdString()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -133,7 +147,6 @@ void RigFemPartResultsCollection::setCalculationParameters(double cohesion, doub this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "DSM", RigFemResultAddress::ALL_TIME_LAPSES)); this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); - } //-------------------------------------------------------------------------------------------------- @@ -155,6 +168,20 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in frames = calculateDerivedResult(partIndex, resVarAddr); if (frames) return frames; + if (resVarAddr.resultPosType == RIG_ELEMENT) + { + std::map> elementProperties = m_elementPropertyReader->readAllElementPropertiesInFileContainingField(resVarAddr.fieldName); + + std::vector resultsForEachComponent; + for (auto elem : elementProperties) + { + RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + currentFrames->frameData(0).swap(elem.second); + } + + return m_femPartResults[partIndex]->findScalarResult(resVarAddr); + } + // We need to read the data as bulk fields, and populate the correct scalar caches std::vector< RigFemResultAddress> resultAddressOfComponents = this->getResAddrToComponentsToRead(resVarAddr); @@ -384,7 +411,10 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["ST"].push_back("TPQV"); fieldCompNames["ST"].push_back("FAULTMOB"); fieldCompNames["ST"].push_back("PCRIT"); - + } + else if (resPos == RIG_ELEMENT) + { + fieldCompNames = m_elementPropertyReader->scalarElementFields(); } } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index cf6e82620e..1489413cfb 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -23,16 +23,21 @@ #include "cvfCollection.h" #include "cvfObject.h" + +#include + #include #include class RifGeoMechReaderInterface; +class RifElementPropertyReader; class RigFemScalarResultFrames; class RigFemPartResultsCollection; class RigFemPartResults; class RigStatisticsDataCache; class RigFemPartCollection; class RigFormationNames; + namespace caf { class ProgressInfo; @@ -41,11 +46,14 @@ namespace caf class RigFemPartResultsCollection: public cvf::Object { public: - RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection); + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, RifElementPropertyReader* elementPropertyReader, const RigFemPartCollection * femPartCollection); ~RigFemPartResultsCollection(); void setActiveFormationNames(RigFormationNames* activeFormationNames); RigFormationNames* activeFormationNames(); + + void addElementPropertyFiles(const std::vector& filename); + void setCalculationParameters(double cohesion, double frictionAngleRad); double parameterCohesion() const { return m_cohesion;} double parameterFrictionAngleRad() const { return m_frictionAngleRad; } @@ -104,6 +112,7 @@ class RigFemPartResultsCollection: public cvf::Object cvf::Collection m_femPartResults; cvf::ref m_readerInterface; + cvf::ref m_elementPropertyReader; cvf::cref m_femParts; cvf::ref m_activeFormationNamesData; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index 6cc6ef6f70..c40b469430 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -19,20 +19,24 @@ #include +#include "RifElementPropertyReader.h" +#include "RifGeoMechReaderInterface.h" +#include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" -#include "RigFemPartCollection.h" -#include "RifGeoMechReaderInterface.h" #ifdef USE_ODB_API #include "RifOdbReader.h" #endif + #include "RigFemScalarResultFrames.h" #include "RigStatisticsDataCache.h" -#include -#include "cvfBoundingBox.h" + #include "cafProgressInfo.h" +#include "cvfBoundingBox.h" + #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -93,6 +97,8 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) m_readerInterface = new RifOdbReader; #endif + m_elementPropertyReader = new RifElementPropertyReader; + if (m_readerInterface.notNull() && m_readerInterface->openFile(m_geoMechCaseFileName, errorMessage)) { m_femParts = new RigFemPartCollection(); @@ -105,7 +111,7 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) progress.setProgressDescription("Calculating element neighbors"); // Initialize results containers - m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts.p()); + m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_elementPropertyReader.p(), m_femParts.p()); // Calculate derived Fem data for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h index 52f23a37ff..c76749e029 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -31,6 +31,7 @@ class RifGeoMechReaderInterface; class RigFemPartCollection; class RigFemScalarResultFrames; class RigFemPartResultsCollection; +class RifElementPropertyReader; class RigGeoMechCaseData: public cvf::Object { @@ -47,8 +48,9 @@ class RigGeoMechCaseData: public cvf::Object const RigFemPartResultsCollection* femPartResults() const; private: - std::string m_geoMechCaseFileName; - cvf::ref m_femParts; - cvf::ref m_femPartResultsColl; - cvf::ref m_readerInterface; + std::string m_geoMechCaseFileName; + cvf::ref m_femParts; + cvf::ref m_femPartResultsColl; + cvf::ref m_readerInterface; + cvf::ref m_elementPropertyReader; }; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index 890a4f7e24..3c327985d7 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -259,7 +259,9 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx()); } - + + if (!vxToResultMapping) return; + vxCount = static_cast(vxToResultMapping->size()); m_surfaceFacesTextureCoords->resize(vxCount); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index f63ee6faeb..5048af466c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -317,6 +317,22 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) +{ + for (const QString& fileName : fileNames) + { + m_elementPropertyFileNames.v().push_back(fileName); + } + this->updateConnectedEditors(); + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 030d09cf0a..278cd32bf5 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -56,7 +56,7 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); - virtual std::vector views(); + virtual std::vector views(); virtual std::vector timeStepDates() const override; virtual QStringList timeStepStrings() const override; @@ -69,6 +69,8 @@ class RimGeoMechCase : public RimCase virtual void setFormationNames(RimFormationNames* formationNames) override; + void addElementPropertyFiles(const std::vector& filenames); + // Fields: caf::PdmChildArrayField geoMechViews; From 118980d568a4a1b94f036604cb370099afb34825 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 12:55:36 +0100 Subject: [PATCH 0018/1027] #2360 Elm Props: read metadata on project load --- .../RigFemPartResultsCollection.cpp | 10 ++++++- .../ProjectDataModel/RimGeoMechCase.cpp | 30 +++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 1801ece7fa..4722662922 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -179,7 +179,15 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in currentFrames->frameData(0).swap(elem.second); } - return m_femPartResults[partIndex]->findScalarResult(resVarAddr); + frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr); + if (frames) + { + return frames; + } + else + { + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } } // We need to read the data as bulk fields, and populate the correct scalar caches diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 5048af466c..ec6c3a141f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -157,19 +157,24 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) { // If opening failed, release all data // Also, several places is checked for this data to validate availability of data - m_geoMechCaseData = NULL; + m_geoMechCaseData = nullptr; + return false; + } + + if (activeFormationNames()) + { + m_geoMechCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); } else { - if ( activeFormationNames() ) - { - m_geoMechCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); - } - else - { - m_geoMechCaseData->femPartResults()->setActiveFormationNames(nullptr); - } + m_geoMechCaseData->femPartResults()->setActiveFormationNames(nullptr); } + + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->addElementPropertyFiles(m_elementPropertyFileNames); + } + return fileOpenSuccess; } @@ -184,6 +189,11 @@ void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPat // Update filename and folder paths when opening project from a different file location m_caseFileName = RimTools::relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + for (QString& fileName : m_elementPropertyFileNames.v()) + { + fileName = RimTools::relocateFile(fileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + } + #if 0 // Output the search path for debugging for (size_t i = 0; i < searchedPaths.size(); ++i) qDebug() << searchedPaths[i]; @@ -326,7 +336,9 @@ void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNam { m_elementPropertyFileNames.v().push_back(fileName); } + this->updateConnectedEditors(); + if (m_geoMechCaseData.notNull()) { geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); From e743a61d5b81181342f80c6a5a5b69afc6fcff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 10 Jan 2018 13:55:48 +0100 Subject: [PATCH 0019/1027] #1752. Import multiple summary cases from a directory structure. Take 1 --- .../Commands/CMakeLists_files.cmake | 8 + .../Commands/RicFileHierarchyDialog.cpp | 271 ++++++++++++++++++ .../Commands/RicFileHierarchyDialog.h | 104 +++++++ .../Commands/RicImportSummaryCasesFeature.cpp | 122 ++++++++ .../Commands/RicImportSummaryCasesFeature.h | 42 +++ .../UserInterface/RiuMainPlotWindow.cpp | 1 + .../UserInterface/RiuMainWindow.cpp | 1 + 7 files changed, 549 insertions(+) create mode 100644 ApplicationCode/Commands/RicFileHierarchyDialog.cpp create mode 100644 ApplicationCode/Commands/RicFileHierarchyDialog.h create mode 100644 ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp create mode 100644 ApplicationCode/Commands/RicImportSummaryCasesFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index cfda894e19..f11b8143d1 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h +${CEE_CURRENT_LIST_DIR}RicImportSummaryCasesFeature.h ${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.h ${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.h ${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h @@ -61,10 +62,13 @@ ${CEE_CURRENT_LIST_DIR}RicCommandFeature.h ${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicReloadSummaryCaseFeature.h +${CEE_CURRENT_LIST_DIR}RicReloadSummaryCasesFeature.h ${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.h ${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h ${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.h + +${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) @@ -118,6 +122,7 @@ ${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.cpp ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportSummaryCasesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp @@ -140,6 +145,8 @@ ${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp ${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.cpp ${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.cpp + +${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.cpp ) @@ -169,6 +176,7 @@ ${SOURCE_GROUP_SOURCE_FILES} list(APPEND QT_MOC_HEADERS ${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h +${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.h ) source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp new file mode 100644 index 0000000000..07aba9a03a --- /dev/null +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -0,0 +1,271 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicFileHierarchyDialog.h" +#include "ExportCommands/RicSnapshotViewToClipboardFeature.h" +#include "ExportCommands/RicSnapshotViewToFileFeature.h" +#include "ExportCommands/RicSnapshotFilenameGenerator.h" + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "Rim3dOverlayInfoConfig.h" + +#include "RiuMainPlotWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +QStringList prefixStrings(const QStringList& strings, const QString& prefix); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) + : QDialog(parent, RiuTools::defaultDialogFlags()) +{ + // Create widgets + m_rootDirLabel = new QLabel(); + m_rootDir = new QLineEdit(); + m_browseButton = new QPushButton(); + m_pathFilterLabel = new QLabel(); + m_pathFilter = new QLineEdit(); + m_fileFilterLabel = new QLabel(); + m_fileFilter = new QLineEdit(); + m_fileExtension = new QLabel(); + + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + // Connect to close button signal + connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); + connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); + connect(m_browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked())); + + // Set widget properties + m_rootDirLabel->setText("Root folder"); + m_pathFilterLabel->setText("Path pattern"); + m_pathFilter->setText("*"); + m_fileFilterLabel->setText("File pattern"); + m_browseButton->setText("..."); + + m_browseButton->setFixedWidth(25); + + // Define layout + QVBoxLayout* dialogLayout = new QVBoxLayout(); + //dialogLayout->addWidget(m_rootDirLabel); + //dialogLayout->addWidget(m_rootDir); + //dialogLayout->addWidget(m_browseButton); + //dialogLayout->addWidget(m_pathFilterLabel); + //dialogLayout->addWidget(m_pathFilter); + //dialogLayout->addWidget(m_fileFilterLabel); + //dialogLayout->addWidget(m_fileFilter); + //dialogLayout->addWidget(m_fileExtension); + //dialogLayout->addWidget(m_buttons); + + QGridLayout* gridLayout = new QGridLayout(); + gridLayout->addWidget(m_rootDirLabel, 0, 0); + gridLayout->addWidget(m_rootDir, 0, 1); + gridLayout->addWidget(m_browseButton, 0, 2); + gridLayout->addWidget(m_pathFilterLabel, 1, 0); + gridLayout->addWidget(m_pathFilter, 1, 1); + gridLayout->addWidget(m_fileFilterLabel, 2, 0); + gridLayout->addWidget(m_fileFilter, 2, 1); + gridLayout->addWidget(m_fileExtension, 2, 2); + + dialogLayout->addLayout(gridLayout); + dialogLayout->addWidget(m_buttons); + + setLayout(dialogLayout); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialog::~RicFileHierarchyDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::files() const +{ + return m_files; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::rootDir() const +{ + return m_rootDir->text(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *parent /*= 0*/, + const QString &caption /*= QString()*/, + const QString &dir /*= QString()*/, + const QString &fileNameFilter /*= QString()*/, + const QStringList &fileExtensions /*= QStringList()*/) +{ + QStringList files; + RicFileHierarchyDialog dialog(parent); + + dialog.setWindowTitle(caption); + + dialog.m_rootDir->setText(dir); + dialog.m_fileFilter->setText(fileNameFilter); + dialog.m_fileExtension->setText(prefixStrings(fileExtensions, ".").join(" | ")); + + dialog.resize(600, 150); + dialog.exec(); + + return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::findMatchingFiles(const QString& rootDir, const QString& pathFilter, const QString& fileNameFilter, const QStringList& fileExtensions) +{ + QStringList files = findFilesRecursive(rootDir, fileNameFilter, fileExtensions); + return filterByPathFilter(files, pathFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::findFilesRecursive(const QString &dir, const QString &fileNameFilter, const QStringList &fileExtensions) +{ + QStringList allFiles; + + QDir qdir(dir); + QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + QStringList files = qdir.entryList(createNameFilterList(fileNameFilter, fileExtensions), QDir::Files); + + for (QString file : files) + { + allFiles.append(qdir.absoluteFilePath(file)); + } + + for (QString subDir : subDirs) + { + allFiles += findFilesRecursive(qdir.absoluteFilePath(subDir), fileNameFilter, fileExtensions); + } + return allFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileNameFilter, const QStringList &fileExtensions) +{ + QStringList nameFilter; + QString effectiveFileNameFilter = !fileNameFilter.isEmpty() ? fileNameFilter : "*"; + + if (fileExtensions.size() == 0) + { + nameFilter.append(effectiveFileNameFilter); + } + else + { + for (QString fileExtension : fileExtensions) + { + nameFilter.append(effectiveFileNameFilter + fileExtension); + } + } + return nameFilter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::filterByPathFilter(const QStringList& files, const QString& pathFilter) +{ + QStringList filteredFiles; + QRegExp regexp(pathFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + + for (QString file : files) + { + QFileInfo fileInfo(file); + QString path = fileInfo.absolutePath(); + + if (regexp.exactMatch(path)) + { + filteredFiles.append(file); + } + } + + return filteredFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotDialogOkClicked() +{ + m_files = findMatchingFiles(m_rootDir->text(), m_pathFilter->text(), m_fileFilter->text(), m_fileExtension->text().split("|")); + accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotDialogCancelClicked() +{ + m_files = QStringList(); + reject(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotBrowseButtonClicked() +{ + QString folder = QFileDialog::getExistingDirectory(this, "Select root folder", m_rootDir->text()); + m_rootDir->setText(folder); +} + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +QStringList prefixStrings(const QStringList& strings, const QString& prefix) +{ + QStringList prefixedStrings; + for (auto string : strings) + { + prefixedStrings.append(prefix + string); + } + return prefixedStrings; +} diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h new file mode 100644 index 0000000000..4fa162e433 --- /dev/null +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -0,0 +1,104 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dOverlayInfoConfig.h" + +#include "cafPdmPointer.h" + +#include + +class QLabel; +class QLineEdit; +class QDialogButtonBox; +class QPushButton; +class QMainWindow; +class RicFileHierarchyDialogResult; + +//================================================================================================== +/// +//================================================================================================== +class RicFileHierarchyDialog : public QDialog +{ + Q_OBJECT + +public: + RicFileHierarchyDialog(QWidget* parent); + ~RicFileHierarchyDialog(); + + QStringList files() const; + QString rootDir() const; + + static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, + const QString &caption = QString(), + const QString &dir = QString(), + const QString &fileNameFilter = QString(), + const QStringList &fileExtensions = QStringList()); + +private: + static QStringList findMatchingFiles(const QString &rootDir, + const QString& pathFilter, + const QString &fileNameFilter, + const QStringList &fileExtensions); + + static QStringList findFilesRecursive(const QString &dir, + const QString &fileNameFilter, + const QStringList &fileExtensions); + + static QStringList createNameFilterList(const QString &fileNameFilter, + const QStringList &fileExtensions); + + static QStringList filterByPathFilter(const QStringList& files, const QString& pathFilter); + +private slots: + void slotDialogOkClicked(); + void slotDialogCancelClicked(); + void slotBrowseButtonClicked(); + +private: + QLabel* m_rootDirLabel; + QLineEdit* m_rootDir; + QPushButton* m_browseButton; + + QLabel* m_pathFilterLabel; + QLineEdit* m_pathFilter; + + QLabel* m_fileFilterLabel; + QLineEdit* m_fileFilter; + + QLabel* m_fileExtension; + + QDialogButtonBox* m_buttons; + + QStringList m_files; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RicFileHierarchyDialogResult +{ +public: + RicFileHierarchyDialogResult(bool ok, const QStringList& files, const QString& rootDir) : + ok(ok), files(files), rootDir(rootDir) {} + bool ok; + QStringList files; + QString rootDir; +}; \ No newline at end of file diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp new file mode 100644 index 0000000000..6452c40fb9 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportSummaryCasesFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicFileHierarchyDialog.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuMainPlotWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportSummaryCasesFeature, "RicImportSummaryCasesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, "*", QStringList("SMSPEC")); + + if (!result.ok) return; + + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + + QStringList fileNames = result.files; + if (fileNames.isEmpty()) return; + + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + if (!sumCaseColl) return; + + for (auto f : fileNames) + { + RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(f); + } + + std::vector cases; + app->project()->allCases(cases); + + if (cases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); + actionToSetup->setText("Import Summary Cases Recursively"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + if (!sumCaseColl) return false; + + RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName); + sumCaseColl->updateAllRequiredEditors(); + + RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow) + { + mainPlotWindow->selectAsCurrentItem(sumCase); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + app->addToRecentFiles(fileName); + + return true; +} + diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h new file mode 100644 index 0000000000..3d47388bee --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicImportSummaryCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static bool createAndAddSummaryCaseFromFile(const QString& fileName); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index df865f785c..0a36a57abd 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -187,6 +187,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); importMenu->addSeparator(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index cd52715233..2d16aa7388 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -362,6 +362,7 @@ void RiuMainWindow::createMenus() importMenu->addSeparator(); #endif importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); From 3f4489c45fbb7f3814b1e827cbd95c18a122f5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 10 Jan 2018 14:11:57 +0100 Subject: [PATCH 0020/1027] #1752 Summary cases import. Minor refactoring --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 9 ++++++++- .../Commands/RicImportSummaryCasesFeature.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 07aba9a03a..0f039a642a 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -265,7 +265,14 @@ QStringList prefixStrings(const QStringList& strings, const QString& prefix) QStringList prefixedStrings; for (auto string : strings) { - prefixedStrings.append(prefix + string); + if (!string.startsWith(prefix)) + { + prefixedStrings.append(prefix + string); + } + else + { + prefixedStrings.append(string); + } } return prefixedStrings; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 6452c40fb9..72402cea31 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -57,7 +57,7 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, "*", QStringList("SMSPEC")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, "*", QStringList(".SMSPEC")); if (!result.ok) return; From 65d85b82f7cf2a49cd9802c6f003bc8bac20de7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 10 Jan 2018 14:43:01 +0100 Subject: [PATCH 0021/1027] #2272 fracture. Disable IO for anchor position --- ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 989202e087..d32ffc74d3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -104,6 +104,7 @@ RimFracture::RimFracture(void) CAF_PDM_InitFieldNoDefault(&m_anchorPosition, "AnchorPosition", "Anchor Position", "", "", ""); m_anchorPosition.uiCapability()->setUiHidden(true); + m_anchorPosition.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault(&m_uiAnchorPosition, "ui_positionAtWellpath", "Fracture Position", "", "", ""); m_uiAnchorPosition.registerGetMethod(this, &RimFracture::fracturePositionForUi); From 2ce7e2c3d2c5684f748e98710af1181fcd51ec2a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 14:14:36 +0100 Subject: [PATCH 0022/1027] #2360 Elm props: Use element index in closest result intex calc --- .../GeoMechDataModel/RigFemPartResultsCollection.cpp | 8 +++++++- .../GeoMechVisualization/RivFemPartGeometryGenerator.cpp | 7 +++++++ .../GeoMechVisualization/RivFemPartGeometryGenerator.h | 2 ++ .../GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 4722662922..0bababf189 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -175,7 +175,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in std::vector resultsForEachComponent; for (auto elem : elementProperties) { - RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + RigFemResultAddress addressForElement(RIG_ELEMENT, elem.first, ""); + RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult(addressForElement); + currentFrames->enableAsSingleFrameResult(); currentFrames->frameData(0).swap(elem.second); } @@ -2175,6 +2177,10 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar { m_resultIndexToClosestResult = -1; } + else if (resultPosition == RIG_ELEMENT) + { + m_resultIndexToClosestResult = elementIndex; + } else { m_resultIndexToClosestResult = m_closestElementNodeResIdx; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index 63058ce4ae..ef612df8ba 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -175,6 +175,7 @@ void RivFemPartGeometryGenerator::computeArrays() m_quadVerticesToNodeIdx.clear(); m_quadVerticesToGlobalElmNodeIdx.clear(); m_quadVerticesToGlobalElmFaceNodeIdx.clear(); + m_quadVerticesToGlobalElmIdx.clear(); trianglesToElements.clear(); trianglesToElementFaces.clear(); @@ -183,6 +184,7 @@ void RivFemPartGeometryGenerator::computeArrays() vertices.reserve(estimatedQuadVxCount); m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount); m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount); + m_quadVerticesToGlobalElmIdx.reserve(estimatedQuadVxCount); trianglesToElements.reserve(estimatedQuadVxCount/2); trianglesToElementFaces.reserve(estimatedQuadVxCount/2); @@ -258,6 +260,11 @@ void RivFemPartGeometryGenerator::computeArrays() m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 2); m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 3); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + trianglesToElements.push_back(elmIdx); trianglesToElements.push_back(elmIdx); trianglesToElementFaces.push_back(lfIdx); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h index 2d6edab282..c123ad8bbd 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h @@ -86,6 +86,7 @@ class RivFemPartGeometryGenerator : public cvf::Object const std::vector& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;} const std::vector& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;} const std::vector& quadVerticesToGlobalElmFaceNodeIdx() const { return m_quadVerticesToGlobalElmFaceNodeIdx; } + const std::vector& quadVerticesToGlobalElmIdx() const { return m_quadVerticesToGlobalElmIdx; } RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();} @@ -107,6 +108,7 @@ class RivFemPartGeometryGenerator : public cvf::Object std::vector m_quadVerticesToNodeIdx; std::vector m_quadVerticesToGlobalElmNodeIdx; std::vector m_quadVerticesToGlobalElmFaceNodeIdx; + std::vector m_quadVerticesToGlobalElmIdx; // Mappings cvf::ref m_triangleMapper; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index 3c327985d7..262b7affc5 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -259,6 +259,10 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx()); } + else if (resVarAddress.resultPosType == RIG_ELEMENT) + { + vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmIdx()); + } if (!vxToResultMapping) return; From 5751acf2b9eaf7ea2a84fb023f1491c6e3a9b302 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 15:23:00 +0100 Subject: [PATCH 0023/1027] #2347 Elm props: Evaluate result type ELEMENT in property visibility --- .../RivFemElmVisibilityCalculator.cpp | 218 +++++++++--------- .../RivFemElmVisibilityCalculator.h | 8 + 2 files changed, 116 insertions(+), 110 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index c46bff3f00..5ed6310504 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -107,143 +107,141 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility; const int elementCount = grid->elementCount(); - if (propFilterColl->hasActiveFilters()) + if (!propFilterColl->hasActiveFilters()) return; + + for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) { - for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) - { - RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; - if (!propertyFilter->isActiveAndHasResult()) continue; + RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; + if (!propertyFilter->isActiveAndHasResult()) continue; + + const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); - const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); + RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); - RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); + RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); - RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); + // Do a "Hack" to use elm nodal and not nodal POR results + if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - // Do a "Hack" to use elm nodal and not nodal POR results - if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + const std::vector& resVals = caseData->femPartResults()->resultValues(resVarAddress, + grid->elementPartId(), + timeStepIndex); - const std::vector& resVals = caseData->femPartResults()->resultValues(resVarAddress, - grid->elementPartId(), - timeStepIndex); + if (!propertyFilter->isActive()) continue; + if (!propertyFilter->resultDefinition->hasResult()) continue; + + const double lowerBound = propertyFilter->lowerBound(); + const double upperBound = propertyFilter->upperBound(); + + if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES) + { + std::vector integerVector = propertyFilter->selectedCategoryValues(); + std::set integerSet; + for (auto val : integerVector) + { + integerSet.insert(val); + } - if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) { - if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES) + if (!(*cellVisibility)[cellIndex]) continue; + + size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0); + double scalarValue = resVals[resultValueIndex]; + int intValue = nearbyint(scalarValue); + if (integerSet.find(intValue) != integerSet.end()) { - std::vector integerVector = propertyFilter->selectedCategoryValues(); - std::set integerSet; - for (auto val : integerVector) + if (filterType == RimCellFilter::EXCLUDE) { - integerSet.insert(val); + (*cellVisibility)[cellIndex] = false; } - - for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + } + else + { + if (filterType == RimCellFilter::INCLUDE) { - if ((*cellVisibility)[cellIndex]) - { - size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0); - double scalarValue = resVals[resultValueIndex]; - int intValue = nearbyint(scalarValue); - if (integerSet.find(intValue) != integerSet.end()) - { - if (filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if (filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } + (*cellVisibility)[cellIndex] = false; } } - else + } + } + else if (resVarAddress.resultPosType == RIG_ELEMENT) + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; + + double scalarValue = resVals[cellIndex]; + evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); + } + } + else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; + + for (int fpIdx = 0; fpIdx < 24; ++fpIdx) { - const double lowerBound = propertyFilter->lowerBound(); - const double upperBound = propertyFilter->upperBound(); + double scalarValue = resVals[cellIndex * 24 + fpIdx]; + evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); + } + } + } + else + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; - - if (resVarAddress.resultPosType != RIG_ELEMENT_NODAL_FACE) + RigElementType eType = grid->elementType(cellIndex); + int elmNodeCount = RigFemTypes::elmentNodeCount(eType); + + const int* elmNodeIndices = grid->connectivities(cellIndex); + for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx) + { + size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; + if (resVarAddress.resultPosType == RIG_NODAL) { - #pragma omp parallel for schedule(dynamic) - for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) - { - if ( (*cellVisibility)[cellIndex] ) - { - RigElementType eType = grid->elementType(cellIndex); - int elmNodeCount = RigFemTypes::elmentNodeCount(eType); - - const int* elmNodeIndices = grid->connectivities(cellIndex); - for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx) - { - size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; - if (resVarAddress.resultPosType == RIG_NODAL) - { - resultValueIndex = elmNodeIndices[enIdx]; - } - else - { - resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); - } - - double scalarValue = resVals[resultValueIndex]; - if (lowerBound <= scalarValue && scalarValue <= upperBound) - { - if (filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if (filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } - } - } + resultValueIndex = elmNodeIndices[enIdx]; } else { - #pragma omp parallel for schedule(dynamic) - for(int cellIndex = 0; cellIndex < elementCount; cellIndex++) - { - if((*cellVisibility)[cellIndex]) - { - for(int fpIdx = 0; fpIdx < 24; ++fpIdx) - { - double scalarValue = resVals[cellIndex*24 + fpIdx]; - if(lowerBound <= scalarValue && scalarValue <= upperBound) - { - if(filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if(filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } - } - } + resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); } + + double scalarValue = resVals[resultValueIndex]; + evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); } } } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound, const RimCellFilter::FilterModeType filterType, cvf::UByteArray* cellVisibility, int cellIndex) +{ + if (lowerBound <= scalarValue && scalarValue <= upperBound) + { + if (filterType == RimCellFilter::EXCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } + else + { + if (filterType == RimCellFilter::INCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h index adda2db74b..bd1cb66506 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -18,9 +18,12 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once + #include "cvfBase.h" #include "cvfArray.h" +#include "RimCellFilter.h" + namespace cvf { class CellRangeFilter; @@ -43,6 +46,11 @@ class RivFemElmVisibilityCalculator const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl); + static void evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound, + const RimCellFilter::FilterModeType filterType, + cvf::UByteArray* cellVisibility, int cellIndex); + + static void computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart , RimViewController* masterViewLink); From 81a7fb204dfdfe1950aaafb14071f2bf4438774e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 10 Jan 2018 16:32:59 +0100 Subject: [PATCH 0024/1027] #2360 Elm Props: Correct UI text --- .../RicNewGridTimeHistoryCurveFeature.cpp | 1 + ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 5 ++++- .../ProjectDataModel/RimGeoMechPropertyFilter.cpp | 1 + ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index e5abd5d6da..f938da37a4 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -177,6 +177,7 @@ QString RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName() case RIG_NODAL: posName = "N"; break; case RIG_ELEMENT_NODAL: posName = "EN"; break; case RIG_INTEGRATION_POINT: posName = "IP"; break; + case RIG_ELEMENT: posName = "E"; break; } QString fieldUiName = resultDefinition->resultFieldUiName(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 3222e35a54..c06112bdf6 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -597,7 +597,10 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, Ri case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; - + + case RIG_ELEMENT: + resultPos = "Element"; + break; default: break; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp index b8d7fcb25c..f19decd54d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -311,6 +311,7 @@ void RimGeoMechPropertyFilter::updateFilterName() case RIG_NODAL: posName = "N"; break; case RIG_ELEMENT_NODAL: posName = "EN"; break; case RIG_INTEGRATION_POINT: posName = "IP"; break; + case RIG_ELEMENT: posName = "E"; break; } QString fieldUiName = resultDefinition->resultFieldUiName(); diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 3f996f5af0..13f8c74c28 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -244,9 +244,12 @@ void RiuFemResultTextBuilder::appendTextFromResultColors(RigGeoMechCaseData* geo int nodeIdx = elmentConn[lNodeIdx]; if (resultDefinition->resultPositionType() == RIG_NODAL) { - scalarValue = scalarResults[nodeIdx]; } + else if (resultDefinition->resultPositionType() == RIG_ELEMENT) + { + scalarValue = cellIndex; + } else { size_t resIdx = femPart->elementNodeResultIdx(cellIndex, lNodeIdx); From cede66c8c059ea92e86ee4f2cfc69e9bff0961f0 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 11 Jan 2018 10:19:22 +0100 Subject: [PATCH 0025/1027] #2360 Elm Props: Correct UI text in 3d overlay info --- .../ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index c06112bdf6..d6e9a60a6b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -604,8 +604,14 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, Ri default: break; } - - infoText += QString("Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); + if (compName == "") + { + infoText += QString("Cell result: %1, %2").arg(resultPos).arg(fieldName); + } + else + { + infoText += QString("Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); + } infoText += QString("
Statistics: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("" From de95ee0a9aff8a11a7e013f3c27b4a7d0307d0b1 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 11 Jan 2018 10:58:24 +0100 Subject: [PATCH 0026/1027] #2347 Elm props: Traverse result type ELEMENT in stat calc --- .../RigFemNativeVisibleCellsStatCalc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h index bcc7c05df9..8653d2a7be 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h @@ -93,6 +93,22 @@ class RigFemNativeVisibleCellsStatCalc : public RigStatisticsCalculator } } } + else if (m_resVarAddr.resultPosType == RIG_ELEMENT) + { + for (int pIdx = 0; pIdx < partCount; ++pIdx) + { + RigFemPart* part = m_caseData->femParts()->part(pIdx); + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex); + int elmCount = part->elementCount(); + + for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx) + { + if (!(*m_cellVisibilities)[elmIdx]) continue; + + accumulator.addValue(values[elmIdx]); + } + } + } else { for (int pIdx = 0; pIdx < partCount; ++pIdx) From e0d91f90ae5b787d3064e5454cbc2f3a477ebe22 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 11 Jan 2018 10:58:52 +0100 Subject: [PATCH 0027/1027] #2360 Elm Props: Correct text in result info --- ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 13f8c74c28..6e7c050eeb 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -248,7 +248,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors(RigGeoMechCaseData* geo } else if (resultDefinition->resultPositionType() == RIG_ELEMENT) { - scalarValue = cellIndex; + scalarValue = scalarResults[cellIndex]; } else { From e4e160cdd47bfa9e866db533d580b3bb2660e1d9 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 11 Jan 2018 11:35:08 +0100 Subject: [PATCH 0028/1027] #2347 Elm Props: Evaluate result type ELEMENT for Intersections --- .../RivFemElmVisibilityCalculator.cpp | 14 ++- .../RivFemElmVisibilityCalculator.h | 9 +- .../RivIntersectionBoxPartMgr.cpp | 60 +++++---- .../Intersections/RivIntersectionPartMgr.cpp | 116 ++++++++++++++---- .../Intersections/RivIntersectionPartMgr.h | 17 ++- 5 files changed, 151 insertions(+), 65 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 5ed6310504..52cc6d65dd 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -112,6 +112,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) { RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; + if (!propertyFilter->isActiveAndHasResult()) continue; const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); @@ -173,7 +174,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c if (!(*cellVisibility)[cellIndex]) continue; double scalarValue = resVals[cellIndex]; - evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); } } else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) @@ -186,7 +187,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c for (int fpIdx = 0; fpIdx < 24; ++fpIdx) { double scalarValue = resVals[cellIndex * 24 + fpIdx]; - evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); } } } @@ -214,7 +215,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c } double scalarValue = resVals[resultValueIndex]; - evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex); + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); } } } @@ -224,7 +225,12 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound, const RimCellFilter::FilterModeType filterType, cvf::UByteArray* cellVisibility, int cellIndex) +void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy(int cellIndex, + double scalarValue, + double lowerBound, + double upperBound, + const RimCellFilter::FilterModeType filterType, + cvf::UByteArray* cellVisibility) { if (lowerBound <= scalarValue && scalarValue <= upperBound) { diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h index bd1cb66506..659661ac41 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -46,15 +46,16 @@ class RivFemElmVisibilityCalculator const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl); - static void evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound, + static void evaluateAndSetCellVisibiliy(int cellIndex, + double scalarValue, + double lowerBound, + double upperBound, const RimCellFilter::FilterModeType filterType, - cvf::UByteArray* cellVisibility, int cellIndex); - + cvf::UByteArray* cellVisibility); static void computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart , RimViewController* masterViewLink); - }; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index bff87fafa9..e2001740fa 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -160,31 +160,24 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - if (!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) ) + if (resVarAddress.resultPosType == RIG_ELEMENT) { - // Do a "Hack" to show elm nodal and not nodal POR results - if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - - const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); - RigFemPart* femPart = caseData->femParts()->part(0); - bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); - - RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), - vertexWeights, - resultValues, - isElementNodalResult, - femPart, - mapper); + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + const std::vector& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex(); + + RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), + resultValues, + triangleToCellIdx, + mapper); } - else + else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) { // Special direction sensitive result calculation const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes(); - if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") { RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_intersectionBoxFacesTextureCoords.p(), triangelVxes, @@ -193,15 +186,34 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) } else { + const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); + RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(), - triangelVxes, - vertexWeights, - caseData, - resVarAddress, - (int)timeStepIndex, - mapper); + triangelVxes, + vertexWeights, + caseData, + resVarAddress, + (int)timeStepIndex, + mapper); } } + else + { + // Do a "Hack" to show elm nodal and not nodal POR results + if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + RigFemPart* femPart = caseData->femParts()->part(0); + bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); + const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); + + RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), + vertexWeights, + resultValues, + isElementNodalResult, + femPart, + mapper); + } RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(), m_intersectionBoxFacesTextureCoords.p(), diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index f873631b24..c2c5276573 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -168,39 +168,35 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - if(!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) ) + if (resVarAddress.resultPosType == RIG_ELEMENT) { - // Do a "Hack" to show elm nodal and not nodal POR results - if(resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - - const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); - RigFemPart* femPart = caseData->femParts()->part(0); - bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); - - RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), - vertexWeights, - resultValues, - isElementNodalResult, - femPart, - mapper); + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + const std::vector& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex(); + + RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), + resultValues, + triangleToCellIdx, + mapper); + } - else + else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) { // Special direction sensitive result calculation const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes(); - if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") { RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(), - triangelVxes, + triangelVxes, resVarAddress, mapper); } else { + const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); + RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(), triangelVxes, vertexWeights, @@ -210,6 +206,23 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) mapper); } } + else + { + // Do a "Hack" to show elm nodal and not nodal POR results + if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + RigFemPart* femPart = caseData->femParts()->part(0); + bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); + const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); + + RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), + vertexWeights, + resultValues, + isElementNodalResult, + femPart, + mapper); + } RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), @@ -224,12 +237,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector &vertexWeights, - const std::vector &resultValues, - bool isElementNodalResult, - const RigFemPart* femPart, - const cvf::ScalarMapper* mapper) +void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &vertexWeights, + const std::vector &resultValues, + bool isElementNodalResult, + const RigFemPart* femPart, + const cvf::ScalarMapper* mapper) { textureCoords->resize(vertexWeights.size()); @@ -250,8 +263,16 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text int weightCount = vertexWeights[triangleVxIdx].size(); for (int wIdx = 0; wIdx < weightCount; ++wIdx) { - size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) : - femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx)); + size_t resIdx; + if (isElementNodalResult) + { + resIdx = vertexWeights[triangleVxIdx].vxId(wIdx); + } + else + { + resIdx = femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx)); + } + resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx); } @@ -267,6 +288,47 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &resultValues, + const std::vector& triangleToCellIdx, + const cvf::ScalarMapper* mapper) +{ + textureCoords->resize(triangleToCellIdx.size()*3); + + if (resultValues.size() == 0) + { + textureCoords->setAll(cvf::Vec2f(0.0, 1.0f)); + } + else + { + cvf::Vec2f* rawPtr = textureCoords->ptr(); + + for (int triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++) + { + size_t resIdx = triangleToCellIdx[triangleIdx]; + float resValue = resultValues[resIdx]; + + int triangleVxIdx = triangleIdx * 3; + + if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's + { + rawPtr[triangleVxIdx][1] = 1.0f; + rawPtr[triangleVxIdx + 1][1] = 1.0f; + rawPtr[triangleVxIdx + 2][1] = 1.0f; + } + else + { + rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue); + rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord(resValue); + rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord(resValue); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index b585178447..14cb3be11b 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -80,12 +80,17 @@ class RivIntersectionPartMgr : public cvf::Object const RigResultAccessor* resultAccessor, const cvf::ScalarMapper* mapper); - static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector &vertexWeights, - const std::vector &resultValues, - bool isElementNodalResult, - const RigFemPart* femPart, - const cvf::ScalarMapper* mapper); + static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &vertexWeights, + const std::vector &resultValues, + bool isElementNodalResult, + const RigFemPart* femPart, + const cvf::ScalarMapper* mapper); + + static void calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &resultValues, + const std::vector& triangleToCellIdx, + const cvf::ScalarMapper* mapper); static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords, const cvf::Vec3fArray* triangelVertices, From 3786adc9b79b39fe23c104c68b9df191f634742f Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 11 Jan 2018 11:35:31 +0100 Subject: [PATCH 0029/1027] #2347 Elm Props: Evaluate result type ELEMENT for WellLogExtractor --- .../ReservoirDataModel/RigGeoMechWellLogExtractor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 9c451682f3..e070dd9a1e 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -70,6 +70,12 @@ void RigGeoMechWellLogExtractor::curveData(const RigFemResultAddress& resAddr, i if (!(elmType == HEX8 || elmType == HEX8P)) continue; + if (convResAddr.resultPosType == RIG_ELEMENT) + { + (*values)[cpIdx] = resultValues[elmIdx]; + continue; + } + cvf::StructGridInterface::FaceType cellFace = m_intersectedCellFaces[cpIdx]; int faceNodeCount = 0; From 90f9b63b44177d4976de707e5575596aa95f4388 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Jan 2018 13:46:45 +0100 Subject: [PATCH 0030/1027] #2361 AppFwk : cafPdmuiListEditor : Refactor setting of strings to field --- .../cafUserInterface/cafPdmUiListEditor.cpp | 35 +++++++++---------- .../cafUserInterface/cafPdmUiListEditor.h | 7 ++-- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 513a9a8329..ea7bf022f0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -371,15 +371,7 @@ void PdmUiListEditor::slotListItemEdited(const QModelIndex&, const QModelIndex&) QStringList uiList = m_model->stringList(); - // Remove dummy elements specifically at the end of list. - - QStringList result; - foreach (const QString &str, uiList) - { - if (str != "" && str != " ") result += str; - } - - this->setValueToField(result); + trimAndSetValuesToField(uiList); } //-------------------------------------------------------------------------------------------------- @@ -406,7 +398,21 @@ void PdmUiListEditor::pasteFromString(const QString& content) { QStringList strList = content.split("\n"); - this->setValueToField(strList); + trimAndSetValuesToField(strList); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiListEditor::trimAndSetValuesToField(const QStringList& stringList) +{ + QStringList result; + for (const auto& str : stringList) + { + if (str != "" && str != " ") result += str; + } + + this->setValueToField(result); } //-------------------------------------------------------------------------------------------------- @@ -458,14 +464,7 @@ bool PdmUiListEditor::eventFilter(QObject* object, QEvent * event) { QStringList uiList = m_model->stringList(); - // Remove dummy elements specifically at the end of list. - - QStringList result; - foreach (const QString &str, uiList) - { - if (str != "" && str != " ") result += str; - } - this->setValueToField(result); + trimAndSetValuesToField(uiList); } return true; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h index c088bbf056..980622e259 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h @@ -39,11 +39,12 @@ #include "cafPdmUiFieldEditorHandle.h" -class QStringListModel; class QItemSelection; -class QListViewHeightHint; class QLabel; +class QListViewHeightHint; class QModelIndex; +class QStringList; +class QStringListModel; namespace caf { @@ -93,6 +94,8 @@ protected slots: private: QString contentAsString() const; void pasteFromString(const QString& content); + + void trimAndSetValuesToField(const QStringList& stringList); private: QPointer m_listView; From f86b13adc8e5bb49bdca5db84d34c8c1de2b5297 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Jan 2018 13:48:47 +0100 Subject: [PATCH 0031/1027] #2361 AppFwk : Add cafFilePath and conversion to QVariant --- .../cafPdmCore/CMakeLists.txt | 3 + .../cafPdmCore/cafFilePath.cpp | 67 +++++++++++++++++++ .../cafPdmCore/cafFilePath.h | 36 ++++++++++ .../cafInternalPdmValueFieldSpecializations.h | 24 +++++++ 4 files changed, 130 insertions(+) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 1108fc67e8..725ff7201f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -39,12 +39,15 @@ set( PROJECT_FILES cafPdmReferenceHelper.h cafPdmUiFieldHandleInterface.h cafPdmValueField.h + cafInternalPdmValueFieldSpecializations.h cafNotificationCenter.cpp cafNotificationCenter.h cafTristate.cpp cafTristate.h + cafFilePath.cpp + cafFilePath.h ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp new file mode 100644 index 0000000000..edc816de53 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp @@ -0,0 +1,67 @@ +#include "cafFilePath.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::FilePath::FilePath() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::FilePath::FilePath(const QString& filePath) : m_filePath(filePath) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString caf::FilePath::path() const +{ + return m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::FilePath::setPath(const QString& filePath) +{ + m_filePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::FilePath::operator=(const FilePath& other) +{ + m_filePath = other.m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::FilePath::operator==(const FilePath& other) const +{ + return m_filePath == other.m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator>>(QTextStream& str, caf::FilePath& filePath) +{ + QString text; + str >> text; + filePath.setPath(text); + + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& str, const caf::FilePath& filePath) +{ + str << filePath.path(); + + return str; +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h new file mode 100644 index 0000000000..e859bfe079 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +class QTextStream; + +namespace caf +{ +//================================================================================================== +// +//================================================================================================== +class FilePath +{ +public: + FilePath(); + FilePath(const QString& filePath); + + QString path() const; + void setPath(const QString& valueText); + + void operator=(const FilePath& other); + bool operator==(const FilePath& other) const; + +private: + QString m_filePath; +}; + +} // end namespace caf + +//================================================================================================== +// Overload of QTextStream +//================================================================================================== +QTextStream& operator>>(QTextStream& str, caf::FilePath& filePath); +QTextStream& operator<<(QTextStream& str, const caf::FilePath& filePath); + +Q_DECLARE_METATYPE(caf::FilePath); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h index 5aa3878e38..8aef1f8988 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h @@ -1,6 +1,7 @@ #pragma once #include "cafAppEnum.h" +#include "cafFilePath.h" #include "cafPdmPointer.h" #include @@ -141,4 +142,27 @@ class PdmValueFieldSpecialization > } }; +//================================================================================================== +/// Partial specialization for caf::FilePath +//================================================================================================== +template <> +class PdmValueFieldSpecialization +{ +public: + static QVariant convert(const FilePath& value) + { + return QVariant(value.path()); + } + + static void setFromVariant(const QVariant& variantValue, FilePath& value) + { + value.setPath(variantValue.toString()); + } + + static bool isEqual(const QVariant& variantValue, const QVariant& variantValue2) + { + return variantValue.value() == variantValue2.value(); + } +}; + } // End of namespace caf From 97822cbd2c1a0f4d34d0815aeb91929706c8f399 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Jan 2018 13:49:42 +0100 Subject: [PATCH 0032/1027] #2361 AppFwk : Template specialization of stream operator for vector of FilePath --- .../cafPdmXml/CMakeLists.txt | 3 ++ .../cafInternalPdmFilePathStreamOperators.cpp | 42 +++++++++++++++++++ .../cafInternalPdmFilePathStreamOperators.h | 10 +++++ .../cafInternalPdmXmlFieldReaderWriter.h | 1 + .../cafPdmUiDefaultObjectEditor.cpp | 4 ++ 5 files changed, 60 insertions(+) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt index c5a8585247..1ba575d743 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt @@ -14,12 +14,15 @@ include_directories ( set( PROJECT_FILES cafInternalPdmFieldIoHelper.cpp cafInternalPdmFieldIoHelper.h + cafInternalPdmFilePathStreamOperators.cpp + cafInternalPdmFilePathStreamOperators.h cafInternalPdmStreamOperators.cpp cafInternalPdmStreamOperators.h cafInternalPdmXmlFieldCapability.h cafInternalPdmXmlFieldCapability.inl cafInternalPdmXmlFieldReaderWriter.cpp cafInternalPdmXmlFieldReaderWriter.h + cafPdmXmlFieldHandle.cpp cafPdmXmlFieldHandle.h cafPdmXmlObjectHandle.cpp diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp new file mode 100644 index 0000000000..b4dc732802 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -0,0 +1,42 @@ +#include "cafInternalPdmFilePathStreamOperators.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& str, const std::vector& filePathObjects) +{ + for (const auto& filePath : filePathObjects) + { + str << filePath << ";"; + } + + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator>>(QTextStream& str, std::vector& filePathObjects) +{ + QString stringSeparatedBySemicolon; + + while (str.status() == QTextStream::Ok) + { + // Read QChar to avoid white space trimming when reading QString + QChar singleChar; + str >> singleChar; + + stringSeparatedBySemicolon += singleChar; + } + + QStringList splitBySemicolon = stringSeparatedBySemicolon.split(";"); + for (const auto& s : splitBySemicolon ) + { + filePathObjects.push_back(s); + } + + return str; +} + diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h new file mode 100644 index 0000000000..1e6a77daa4 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h @@ -0,0 +1,10 @@ +#pragma once + +#include "cafFilePath.h" + +#include + +#include + +QTextStream& operator << (QTextStream& str, const std::vector& sobj); +QTextStream& operator >> (QTextStream& str, std::vector& sobj); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h index 68cd701683..8e5ddb8736 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h @@ -5,6 +5,7 @@ #include #include "cafInternalPdmStreamOperators.h" +#include "cafInternalPdmFilePathStreamOperators.h" #include "cafPdmReferenceHelper.h" #include "cafInternalPdmFieldIoHelper.h" diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index 5ebf9a60f8..fb0916eede 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -36,11 +36,13 @@ #include "cafPdmUiDefaultObjectEditor.h" +#include "cafFilePath.h" #include "cafPdmField.h" #include "cafPdmProxyValueField.h" #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiDateEditor.h" #include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmUiFilePathEditor.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiListEditor.h" @@ -64,6 +66,8 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); +CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiFilePathEditor, FilePath); + //-------------------------------------------------------------------------------------------------- /// From e99cc663253d6aca55bcd1baeee55a7e37822fc2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Jan 2018 13:50:22 +0100 Subject: [PATCH 0033/1027] #2361 AppFwk : Test application adjustments to allow save and load of project --- Fwk/AppFwk/CMakeLists.txt | 6 + .../cafTestApplication/MainWindow.cpp | 145 +++++++++++++----- .../cafTests/cafTestApplication/MainWindow.h | 8 +- 3 files changed, 118 insertions(+), 41 deletions(-) diff --git a/Fwk/AppFwk/CMakeLists.txt b/Fwk/AppFwk/CMakeLists.txt index dc4851c78f..0bec5a502b 100644 --- a/Fwk/AppFwk/CMakeLists.txt +++ b/Fwk/AppFwk/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8) project (CeeApp) +if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) + # VS 2017 : Disable warnings from from gtest code, using deprecated code related to TR1 + add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) + message("Add flag to disable warings from gtest - _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING") +endif() + find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED) include (${QT_USE_FILE}) diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index cd13ee2862..4e43e4d42f 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -8,11 +8,6 @@ #include "WidgetLayoutTest.h" #include "MenuItemProducer.h" -#include -#include -#include -#include -#include #include "cafAppEnum.h" @@ -23,35 +18,47 @@ #include "cafCmdFeatureManager.h" #endif +#include "cafFilePath.h" +#include "cafPdmDocument.h" #include "cafPdmObject.h" #include "cafPdmObjectGroup.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" #include "cafPdmReferenceHelper.h" +#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiFilePathEditor.h" +#include "cafPdmUiItem.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiPropertyView.h" +#include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTableView.h" #include "cafPdmUiTextEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" #include "cafPdmUiTreeView.h" #include "cafSelectionManager.h" -#include "cafPdmUiTreeSelectionEditor.h" -#include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiItem.h" -#include "cafPdmUiComboBoxEditor.h" +#include +#include +#include +#include +#include +#include -class DemoPdmObjectGroup : public caf::PdmObjectCollection +class DemoPdmObjectGroup : public caf::PdmDocument { CAF_PDM_HEADER_INIT; public: DemoPdmObjectGroup() { + CAF_PDM_InitFieldNoDefault(&objects, "PdmObjects", "", "", "", "") + objects.uiCapability()->setUiHidden(true); - } + +public: + caf::PdmChildArrayField objects; }; CAF_PDM_SOURCE_INIT(DemoPdmObjectGroup, "DemoPdmObjectGroup"); @@ -73,6 +80,11 @@ class SmallDemoPdmObject: public caf::PdmObject m_proxyDoubleField.registerSetMethod(this, &SmallDemoPdmObject::setDoubleMember); m_proxyDoubleField.registerGetMethod(this, &SmallDemoPdmObject::doubleMember); CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double", "", "", ""); + + CAF_PDM_InitField(&m_fileName, "FileName", caf::FilePath("filename"), "File Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_fileNameList, "FileNameList", "File Name List", "", "", ""); + m_fileNameList.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_proxyDoubleField = 0; if (!(m_proxyDoubleField == 3)) { std::cout << "Double is not 3 " << std::endl; } @@ -92,10 +104,12 @@ class SmallDemoPdmObject: public caf::PdmObject caf::PdmField m_intField; caf::PdmField m_textField; caf::PdmProxyValueField m_proxyDoubleField; + caf::PdmField m_fileName; + caf::PdmField> m_fileNameList; caf::PdmField > m_multiSelectList; - + caf::PdmField m_toggleField; virtual caf::PdmFieldHandle* objectToggleField() { @@ -712,10 +726,8 @@ void MainWindow::buildTestModel() void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) { caf::PdmUiObjectHandle* uiObject = uiObj(pdmRoot); - if (uiObject) - { - m_pdmUiTreeView->setPdmItem(uiObject); - } + + m_pdmUiTreeView->setPdmItem(uiObject); connect(m_pdmUiTreeView, SIGNAL(selectionChanged()), SLOT(slotSimpleSelectionChanged())); @@ -723,7 +735,11 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) // Hack, because we know that pdmRoot is a PdmObjectGroup ... std::vector fields; - pdmRoot->fields(fields); + if (pdmRoot) + { + pdmRoot->fields(fields); + } + if (fields.size()) { caf::PdmFieldHandle* field = fields[0]; @@ -735,27 +751,37 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) } } - if (uiObject) - { - m_pdmUiTreeView2->setPdmItem(uiObject); - } + m_pdmUiTreeView2->setPdmItem(uiObject); connect(m_pdmUiTreeView2, SIGNAL(selectionChanged()), SLOT(slotShowTableView())); // Wire up ManyGroups object std::vector obj; - pdmRoot->descendantsIncludingThisOfType(obj); + if (pdmRoot) + { + pdmRoot->descendantsIncludingThisOfType(obj); + } + + m_customObjectEditor->removeWidget(m_plotLabel); + m_customObjectEditor->removeWidget(m_smallPlotLabel); + if (obj.size() == 1) { - m_customObjectEditor->defineGridLayout(5, 4); m_customObjectEditor->setPdmObject(obj[0]); + m_customObjectEditor->defineGridLayout(5, 4); + m_customObjectEditor->addBlankCell(0, 0); m_customObjectEditor->addWidget(m_plotLabel, 0, 1, 1, 2); m_customObjectEditor->addWidget(m_smallPlotLabel, 1, 2, 2, 1); - - m_customObjectEditor->updateUi(); } + else + { + m_customObjectEditor->setPdmObject(nullptr); + } + + + m_customObjectEditor->updateUi(); } //-------------------------------------------------------------------------------------------------- @@ -800,21 +826,32 @@ MainWindow* MainWindow::instance() //-------------------------------------------------------------------------------------------------- void MainWindow::createActions() { - // Create actions - QAction* editInsert = new QAction("&Insert", this); - QAction* editRemove = new QAction("&Remove", this); - QAction* editRemoveAll = new QAction("Remove all", this); + { + QAction* loadAction = new QAction("Load Project", this); + QAction* saveAction = new QAction("Save Project", this); - connect(editInsert, SIGNAL(triggered()), SLOT(slotInsert())); - connect(editRemove, SIGNAL(triggered()), SLOT(slotRemove())); - connect(editRemoveAll, SIGNAL(triggered()), SLOT(slotRemoveAll())); + connect(loadAction, SIGNAL(triggered()), SLOT(slotLoadProject())); + connect(saveAction, SIGNAL(triggered()), SLOT(slotSaveProject())); + QMenu* menu = menuBar()->addMenu("&File"); + menu->addAction(loadAction); + menu->addAction(saveAction); + } + + { + QAction* editInsert = new QAction("&Insert", this); + QAction* editRemove = new QAction("&Remove", this); + QAction* editRemoveAll = new QAction("Remove all", this); - // Create menus - QMenu* editMenu = menuBar()->addMenu("&Edit"); - editMenu->addAction(editInsert); - editMenu->addAction(editRemove); - editMenu->addAction(editRemoveAll); + connect(editInsert, SIGNAL(triggered()), SLOT(slotInsert())); + connect(editRemove, SIGNAL(triggered()), SLOT(slotRemove())); + connect(editRemoveAll, SIGNAL(triggered()), SLOT(slotRemoveAll())); + + QMenu* menu = menuBar()->addMenu("&Edit"); + menu->addAction(editInsert); + menu->addAction(editRemove); + menu->addAction(editRemoveAll); + } } //-------------------------------------------------------------------------------------------------- @@ -944,3 +981,37 @@ void MainWindow::slotShowTableView() listField->uiCapability()->updateConnectedEditors(); } } + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MainWindow::slotLoadProject() +{ + QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)"); + if (!fileName.isEmpty()) + { + setPdmRoot(nullptr); + releaseTestData(); + + m_testRoot = new DemoPdmObjectGroup; + m_testRoot->fileName = fileName; + m_testRoot->readFile(); + + setPdmRoot(m_testRoot); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MainWindow::slotSaveProject() +{ + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)"); + if (!fileName.isEmpty()) + { + m_testRoot->fileName = fileName; + m_testRoot->writeFile(); + } +} diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h index 7230bd233e..c70c625b23 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h @@ -5,6 +5,7 @@ #include class DemoPdmObject; +class DemoPdmObjectGroup; class QTreeView; class QUndoView; class QLabel; @@ -33,11 +34,8 @@ class MainWindow : public QMainWindow private: void createActions(); - void createMenus(); - void createToolBars(); void createDockPanels(); - void buildTestModel(); void releaseTestData(); @@ -49,6 +47,8 @@ private slots: void slotSimpleSelectionChanged(); void slotShowTableView(); + void slotLoadProject(); + void slotSaveProject(); private: static MainWindow* sm_mainWindowInstance; @@ -60,7 +60,7 @@ private slots: caf::PdmUiTreeView* m_pdmUiTreeView2; caf::PdmUiPropertyView* m_pdmUiPropertyView; caf::PdmUiTableView* m_pdmUiTableView; - caf::PdmObjectCollection* m_testRoot; + DemoPdmObjectGroup* m_testRoot; caf::CustomObjectEditor* m_customObjectEditor; From b70d39cc6cfbee5de3caa030195411b45b7c9343 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Jan 2018 14:04:25 +0100 Subject: [PATCH 0034/1027] System : Postfix with u to indicate unsigned value (avoid warning on linux) --- .../UnitTests/RifElementPropertyTableReader-Test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp index 6d4d42080b..fbfce67321 100644 --- a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp +++ b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp @@ -22,14 +22,14 @@ TEST(RicElementPropertyTableReaderTest, BasicUsage) EXPECT_TRUE(table.hasData); - EXPECT_EQ(2, metadata.dataColumns.size()); + EXPECT_EQ(2u, metadata.dataColumns.size()); EXPECT_STREQ("MODULUS", metadata.dataColumns[0].toStdString().c_str()); EXPECT_STREQ("RATIO", metadata.dataColumns[1].toStdString().c_str()); - EXPECT_EQ(2, table.data.size()); - EXPECT_EQ(4320, table.elementIds.size()); - EXPECT_EQ(4320, table.data[0].size()); - EXPECT_EQ(4320, table.data[1].size()); + EXPECT_EQ(2u, table.data.size()); + EXPECT_EQ(4320u, table.elementIds.size()); + EXPECT_EQ(4320u, table.data[0].size()); + EXPECT_EQ(4320u, table.data[1].size()); } //-------------------------------------------------------------------------------------------------- From f0270276188bc80f89c1487121e56c9fc0262fa6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 07:54:37 +0100 Subject: [PATCH 0035/1027] #1905 Perforation Intervals : Picking the well path pipe does not work at perforations Forward all parts intersected to 3d viewer event handler --- .../Commands/RicViewerEventInterface.h | 31 +++-- .../RicIntersectionViewerEventHandler.cpp | 6 +- .../RicIntersectionViewerEventHandler.h | 2 +- .../RicWellPathViewerEventHandler.cpp | 73 +++++++---- .../RicWellPathViewerEventHandler.h | 2 +- .../UserInterface/RiuViewerCommands.cpp | 118 ++++++++++++------ .../UserInterface/RiuViewerCommands.h | 3 +- 7 files changed, 150 insertions(+), 85 deletions(-) diff --git a/ApplicationCode/Commands/RicViewerEventInterface.h b/ApplicationCode/Commands/RicViewerEventInterface.h index 2e33707a7d..3e5fba9b07 100644 --- a/ApplicationCode/Commands/RicViewerEventInterface.h +++ b/ApplicationCode/Commands/RicViewerEventInterface.h @@ -25,29 +25,28 @@ #include "cvfObject.h" #include "cvfVector3.h" -namespace cvf { - class Part; -} +namespace cvf { + class Part; +} -class RicViewerEventInterface + +class RicViewerEventObject { public: - virtual bool handleEvent(cvf::Object* eventObject) = 0; + RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, const std::vector>& partAndTriangleIndexPairs) + : m_globalIntersectionPoint(globalIntersectionPoint), + m_partAndTriangleIndexPairs(partAndTriangleIndexPairs) + { + } + + cvf::Vec3d m_globalIntersectionPoint; + std::vector> m_partAndTriangleIndexPairs; }; -class RicViewerEventObject : public cvf::Object +class RicViewerEventInterface { public: - RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex) - : globalIntersectionPoint(globalIntersectionPoint), - firstHitPart(firstHitPart), - firstPartTriangleIndex(firstPartTriangleIndex) - { - } - - cvf::Vec3d globalIntersectionPoint; - cvf::Part* firstHitPart; - cvf::uint firstPartTriangleIndex; + virtual bool handleEvent(const RicViewerEventObject& eventObject) = 0; }; diff --git a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp index a83dc266f2..4c75202084 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp @@ -37,15 +37,13 @@ RicIntersectionViewerEventHandler* RicIntersectionViewerEventHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicIntersectionViewerEventHandler::handleEvent(cvf::Object* eventObject) +bool RicIntersectionViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) { std::vector selection; caf::SelectionManager::instance()->objectsByType(&selection); if (selection.size() == 1) { - RicViewerEventObject* polylineUiEvent = dynamic_cast(eventObject); - if (polylineUiEvent) { RimIntersection* intersection = selection[0]; @@ -54,7 +52,7 @@ bool RicIntersectionViewerEventHandler::handleEvent(cvf::Object* eventObject) CVF_ASSERT(rimView); cvf::ref transForm = rimView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord(polylineUiEvent->globalIntersectionPoint); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); if (intersection->inputPolyLineFromViewerEnabled()) { diff --git a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h index 6d7d3d0880..721d61b169 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h @@ -29,6 +29,6 @@ class RicIntersectionViewerEventHandler : public RicViewerEventInterface static RicIntersectionViewerEventHandler* instance(); protected: - virtual bool handleEvent(cvf::Object* eventObject) override; + virtual bool handleEvent(const RicViewerEventObject& eventObject) override; }; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index 6f95204113..f8b5e54f77 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -26,6 +26,7 @@ #include "RiuMainWindow.h" +#include "RivObjectSourceInfo.h" #include "RivWellPathSourceInfo.h" #include "cafDisplayCoordTransform.h" @@ -46,43 +47,67 @@ RicWellPathViewerEventHandler* RicWellPathViewerEventHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject) +bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) { - RicViewerEventObject* uiEvent = dynamic_cast(eventObject); - if (!uiEvent) return false; + if (eventObject.m_partAndTriangleIndexPairs.empty()) return false; - if (uiEvent->firstHitPart && uiEvent->firstHitPart->sourceInfo()) + const caf::PdmObject* objectToSelect = nullptr; + + cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT; + const RivWellPathSourceInfo* wellPathSourceInfo = nullptr; + for (const auto & partAndTriangleIndexPair : eventObject.m_partAndTriangleIndexPairs) { - const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast(uiEvent->firstHitPart->sourceInfo()); - if (wellPathSourceInfo) + const cvf::Part* part = partAndTriangleIndexPair.first; + + const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); + if (!objectToSelect && sourceInfo) { - Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); - if (!rimView) return false; + objectToSelect = sourceInfo->object(); + } - cvf::ref transForm = rimView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord(uiEvent->globalIntersectionPoint); + if (part && part->sourceInfo() && dynamic_cast(part->sourceInfo())) + { + wellPathSourceInfo = dynamic_cast(part->sourceInfo()); + wellPathTriangleIndex = partAndTriangleIndexPair.second; + break; + } + } - double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, domainCoord); + if (wellPathSourceInfo) + { + Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); + if (!rimView) return false; - // NOTE: This computation was used to find the location for a fracture when clicking on a well path - // It turned out that the computation was a bit inaccurate - // Consider to use code in RigSimulationWellCoordsAndMD instead - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, domainCoord); + cvf::ref transForm = rimView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); - QString wellPathText; - wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name()); - wellPathText += QString("Measured depth : %1\n").arg(measuredDepth); + double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, domainCoord); - QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z()); - wellPathText += formattedText; + // NOTE: This computation was used to find the location for a fracture when clicking on a well path + // It turned out that the computation was a bit inaccurate + // Consider to use code in RigSimulationWellCoordsAndMD instead + cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(wellPathTriangleIndex, domainCoord); - RiuMainWindow::instance()->setResultInfo(wellPathText); + QString wellPathText; + wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name()); + wellPathText += QString("Measured depth : %1\n").arg(measuredDepth); - RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath()); + QString formattedText; + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z()); + wellPathText += formattedText; - return true; + RiuMainWindow::instance()->setResultInfo(wellPathText); + + if (objectToSelect) + { + RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); + } + else + { + RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath()); } + + return true; } return false; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h index 305e856ab8..16dde93d89 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h @@ -30,6 +30,6 @@ class RicWellPathViewerEventHandler : public RicViewerEventInterface public: static RicWellPathViewerEventHandler* instance(); - virtual bool handleEvent(cvf::Object* eventObject); + virtual bool handleEvent(const RicViewerEventObject& eventObject); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index cf7af25498..2d54258375 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -148,15 +148,15 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO); - cvf::Part* firstHitPart = nullptr; - cvf::Part* nncFirstHitPart = nullptr; + const cvf::Part* firstHitPart = nullptr; + const cvf::Part* nncFirstHitPart = nullptr; m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED; cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { - extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, NULL); + extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, nullptr); cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; @@ -426,24 +426,31 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM // Extract all the above information from the pick { - cvf::Part* firstHitPart = nullptr; + const cvf::Part* firstHitPart = nullptr; uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; - cvf::Part* firstNncHitPart = nullptr; + const cvf::Part* firstNncHitPart = nullptr; uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { - extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex); + std::vector> partAndTriangleIndexPairs; + extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &partAndTriangleIndexPairs, &firstNncHitPart, &nncPartTriangleIndex); - cvf::ref eventObj = new RicViewerEventObject(globalIntersectionPoint, firstHitPart, firstPartTriangleIndex); - for (size_t i = 0; i < m_viewerEventHandlers.size(); i++) + if (!partAndTriangleIndexPairs.empty()) { - if (m_viewerEventHandlers[i]->handleEvent(eventObj.p())) + RicViewerEventObject viewerEventObject(globalIntersectionPoint, partAndTriangleIndexPairs); + for (size_t i = 0; i < m_viewerEventHandlers.size(); i++) { - return; + if (m_viewerEventHandlers[i]->handleEvent(viewerEventObject)) + { + return; + } } + + firstHitPart = partAndTriangleIndexPairs.front().first; + firstPartTriangleIndex = partAndTriangleIndexPairs.front().second; } } @@ -632,8 +639,35 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, - cvf::Part** firstPart, uint* firstPartFaceHit, - cvf::Part** nncPart, uint* nncPartFaceHit) + const cvf::Part** firstPart, uint* firstPartFaceHit, + const cvf::Part** nncPart, uint* nncPartFaceHit) +{ + std::vector> partAndTriangleIndexPairs; + extractIntersectionData(hitItems, localIntersectionPoint, globalIntersectionPoint, + &partAndTriangleIndexPairs, nncPart, nncPartFaceHit); + + if (!partAndTriangleIndexPairs.empty()) + { + if (firstPart) + { + *firstPart = partAndTriangleIndexPairs.front().first; + } + + if (firstPartFaceHit) + { + *firstPartFaceHit = partAndTriangleIndexPairs.front().second; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems, + cvf::Vec3d* localIntersectionPoint, + cvf::Vec3d*globalIntersectionPoint, + std::vector>* partAndTriangleIndexPairs, + const cvf::Part** nncPart, uint* nncPartFaceHit) { CVF_ASSERT(hitItems.count() > 0); @@ -649,7 +683,7 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi } } - const cvf::HitItem* firstNonNncHitItem = nullptr; + size_t firstNonNncPartIndex = cvf::UNDEFINED_SIZE_T; cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint(); // Check if we have a close hit item with NNC data @@ -684,58 +718,66 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi } } - if (!isNncpart && !firstNonNncHitItem) + if (!isNncpart && firstNonNncPartIndex == cvf::UNDEFINED_SIZE_T) { - firstNonNncHitItem = hitItemCandidate; - firstItemIntersectionPoint = firstNonNncHitItem->intersectionPoint(); + firstItemIntersectionPoint = hitItemCandidate->intersectionPoint(); + firstNonNncPartIndex = i; } - if (firstNonNncHitItem && *nncPart) + if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T && *nncPart) { break; } } - if (firstNonNncHitItem) + if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T) { - const cvf::Part* pickedPart = firstNonNncHitItem->part(); - CVF_ASSERT(pickedPart); - *firstPart = const_cast(pickedPart); - - const cvf::Transform* xf = pickedPart->transform(); - cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint(); - - if (globalIntersectionPoint) { - *globalIntersectionPoint = globalPickedPoint; - } + const cvf::HitItem* firstNonNncHitItem = hitItems.item(firstNonNncPartIndex); + const cvf::Part* pickedPart = firstNonNncHitItem->part(); + CVF_ASSERT(pickedPart); - if (localIntersectionPoint) - { - if (xf) + const cvf::Transform* xf = pickedPart->transform(); + const cvf::Vec3d& globalPickedPoint = firstNonNncHitItem->intersectionPoint(); + + if (globalIntersectionPoint) { - *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + *globalIntersectionPoint = globalPickedPoint; } - else + + if (localIntersectionPoint) { - *localIntersectionPoint = globalPickedPoint; + if (xf) + { + *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + } + else + { + *localIntersectionPoint = globalPickedPoint; + } } } - if (firstPartFaceHit) + for (size_t i = firstNonNncPartIndex; i < hitItems.count(); i++) { - const cvf::HitDetailDrawableGeo* detail = dynamic_cast(firstNonNncHitItem->detail()); + const cvf::HitItem* hitItem = hitItems.item(i); + const cvf::Part* pickedPart = hitItem->part(); + + cvf::uint faceIndex = cvf::UNDEFINED_UINT; + const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItem->detail()); if (detail) { - *firstPartFaceHit = detail->faceIndex(); + faceIndex = detail->faceIndex(); } + + partAndTriangleIndexPairs->push_back(std::make_pair(pickedPart, faceIndex)); } } else { if (localIntersectionPoint && nncPart && *nncPart) { - cvf::Vec3d globalPickedPoint = firstItemIntersectionPoint; + const cvf::Vec3d& globalPickedPoint = firstItemIntersectionPoint; if (globalIntersectionPoint) { diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index da3cb16a1c..fe2aae48bc 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -64,7 +64,8 @@ class RiuViewerCommands: public QObject void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex); void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k); - void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit); + void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, const cvf::Part** firstPart, uint* firstPartFaceHit, const cvf::Part** nncPart, uint* nncPartFaceHit); + void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, std::vector>* partAndTriangleIndexPairs, const cvf::Part** nncPart, uint* nncPartFaceHit); bool handleOverlayItemPicking(int winPosX, int winPosY); From 402a2607c41eeb313c89c8e69025a2ad1d97d154 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 08:43:32 +0100 Subject: [PATCH 0036/1027] #1905 Perforation Intervals : Make sure well path context menu is displayed when clicking a perforation interval --- .../UserInterface/RiuViewerCommands.cpp | 69 +++++++++---------- .../UserInterface/RiuViewerCommands.h | 1 - 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 2d54258375..efd295a8e5 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -86,6 +86,7 @@ #include #include #include +#include "RimPerforationInterval.h" @@ -149,14 +150,33 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO); const cvf::Part* firstHitPart = nullptr; - const cvf::Part* nncFirstHitPart = nullptr; m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED; cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { - extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, nullptr); + std::vector> partAndTriangleIndexPairs; + extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, + &partAndTriangleIndexPairs, nullptr, nullptr); + + for (const auto& partTringleIndex : partAndTriangleIndexPairs) + { + if (!firstHitPart) + { + auto part = partTringleIndex.first; + const RivObjectSourceInfo* objectSourceInfo = dynamic_cast(part->sourceInfo()); + if (objectSourceInfo && dynamic_cast(objectSourceInfo->object())) + { + // Skip picking on perforation interval, display well path context menu + continue; + } + + firstHitPart = part; + firstPartTriangleIndex = partTringleIndex.second; + break; + } + } cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; @@ -295,10 +315,13 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RimWellPath* wellPath = wellPathSourceInfo->wellPath(); if (wellPath) { - double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, m_currentPickPositionInDomainCoords); - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, globalIntersectionPoint); - RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, trueVerticalDepth, measuredDepth); - RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); + if (firstPartTriangleIndex != cvf::UNDEFINED_SIZE_T) + { + double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, m_currentPickPositionInDomainCoords); + cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, globalIntersectionPoint); + RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, trueVerticalDepth, measuredDepth); + RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); + } //TODO: Update so these also use RiuWellPathSelectionItem caf::SelectionManager::instance()->setSelectedItem(wellPath); @@ -633,33 +656,6 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* } } -//-------------------------------------------------------------------------------------------------- -/// Perform picking and return the index of the face that was hit, if a drawable geo was hit -//-------------------------------------------------------------------------------------------------- -void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems, - cvf::Vec3d* localIntersectionPoint, - cvf::Vec3d* globalIntersectionPoint, - const cvf::Part** firstPart, uint* firstPartFaceHit, - const cvf::Part** nncPart, uint* nncPartFaceHit) -{ - std::vector> partAndTriangleIndexPairs; - extractIntersectionData(hitItems, localIntersectionPoint, globalIntersectionPoint, - &partAndTriangleIndexPairs, nncPart, nncPartFaceHit); - - if (!partAndTriangleIndexPairs.empty()) - { - if (firstPart) - { - *firstPart = partAndTriangleIndexPairs.front().first; - } - - if (firstPartFaceHit) - { - *firstPartFaceHit = partAndTriangleIndexPairs.front().second; - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -705,7 +701,10 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi // Hit items are ordered by distance from eye if (diff.lengthSquared() < pickDepthThresholdSquared) { - *nncPart = const_cast(pickedPartCandidate); + if (nncPart) + { + *nncPart = pickedPartCandidate; + } const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItemCandidate->detail()); if (detail && nncPartFaceHit) @@ -724,7 +723,7 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi firstNonNncPartIndex = i; } - if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T && *nncPart) + if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T && nncPart && *nncPart) { break; } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index fe2aae48bc..a8e0a31fc3 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -64,7 +64,6 @@ class RiuViewerCommands: public QObject void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex); void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k); - void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, const cvf::Part** firstPart, uint* firstPartFaceHit, const cvf::Part** nncPart, uint* nncPartFaceHit); void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, std::vector>* partAndTriangleIndexPairs, const cvf::Part** nncPart, uint* nncPartFaceHit); bool handleOverlayItemPicking(int winPosX, int winPosY); From 337310c4976ac6e42fdb4162b8ec932b68464b20 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 10:20:09 +0100 Subject: [PATCH 0037/1027] Fix invalid compare --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index efd295a8e5..ebad8faad5 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -315,7 +315,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RimWellPath* wellPath = wellPathSourceInfo->wellPath(); if (wellPath) { - if (firstPartTriangleIndex != cvf::UNDEFINED_SIZE_T) + if (firstPartTriangleIndex != cvf::UNDEFINED_UINT) { double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, m_currentPickPositionInDomainCoords); cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, globalIntersectionPoint); From 9a2eebe8f558b4f4bde4537b740b2ac783ec3f23 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 10:21:10 +0100 Subject: [PATCH 0038/1027] Fracture : Move public fields to protected, and make RimFractureTemplate friend --- .../RicExportFractureCompletionsImpl.cpp | 2 +- .../Completions/RimFracture.cpp | 145 +++++++++++------- .../Completions/RimFracture.h | 35 +++-- .../Completions/RimFractureTemplate.cpp | 18 +-- .../Completions/RimSimWellFracture.cpp | 20 +-- .../RimStimPlanFractureTemplate.cpp | 2 +- .../Completions/RimWellPathFracture.cpp | 20 +-- 7 files changed, 138 insertions(+), 104 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index c121df89b7..1e83b0201a 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -319,7 +319,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat fractureWellCell.cellSizeZ(), intersection.vlength, intersection.hlength, - fracture->perforationEfficiency, + fracture->perforationEfficiency(), fracTemplate->skinFactor(), cDarcyInCorrectUnit); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index d32ffc74d3..a2a99e9130 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -111,21 +111,21 @@ RimFracture::RimFracture(void) m_uiAnchorPosition.uiCapability()->setUiReadOnly(true); m_uiAnchorPosition.xmlCapability()->disableIO(); - CAF_PDM_InitField(&azimuth, "Azimuth", 0.0, "Azimuth", "", "", ""); - azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_azimuth, "Azimuth", 0.0, "Azimuth", "", "", ""); + m_azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); - CAF_PDM_InitField(&perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); - perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); + CAF_PDM_InitField(&m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); + m_perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); - CAF_PDM_InitField(&dip, "Dip", 0.0, "Dip", "", "", ""); - CAF_PDM_InitField(&tilt, "Tilt", 0.0, "Tilt", "", "", ""); + CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitField(&m_dip, "Dip", 0.0, "Dip", "", "", ""); + CAF_PDM_InitField(&m_tilt, "Tilt", 0.0, "Tilt", "", "", ""); CAF_PDM_InitField(&m_fractureUnit, "FractureUnit", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Fracture Unit System", "", "", ""); m_fractureUnit.uiCapability()->setUiReadOnly(true); - CAF_PDM_InitField(&stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step", "", "", ""); + CAF_PDM_InitField(&m_stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_uiWellPathAzimuth, "WellPathAzimuth", "Well Path Azimuth", "", "", ""); m_uiWellPathAzimuth.registerGetMethod(this, &RimFracture::wellAzimuthAtFracturePositionText); @@ -151,6 +151,38 @@ RimFracture::~RimFracture() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFracture::perforationLength() const +{ + return m_perforationLength(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFracture::perforationEfficiency() const +{ + return m_perforationEfficiency(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFracture::stimPlanTimeIndexToPlot() const +{ + return m_stimPlanTimeIndexToPlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFracture::setStimPlanTimeIndexToPlot(int timeIndex) +{ + m_stimPlanTimeIndexToPlot = timeIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -177,12 +209,12 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons setDefaultFractureColorResult(); } - if (changedField == &azimuth || + if (changedField == &m_azimuth || changedField == &m_fractureTemplate || - changedField == &stimPlanTimeIndexToPlot || + changedField == &m_stimPlanTimeIndexToPlot || changedField == this->objectToggleField() || - changedField == &dip || - changedField == &tilt) + changedField == &m_dip || + changedField == &m_tilt) { Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); @@ -214,7 +246,7 @@ cvf::Vec3d RimFracture::fracturePosition() const //-------------------------------------------------------------------------------------------------- double RimFracture::wellFractureAzimuthDiff() const { - double wellDifference = fabs(wellAzimuthAtFracturePosition() - azimuth); + double wellDifference = fabs(wellAzimuthAtFracturePosition() - m_azimuth); return wellDifference; } @@ -259,22 +291,22 @@ double RimFracture::wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const { if (unitSystem == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::meterToFeet(wellDiameter / 2); + return RiaEclipseUnitTools::meterToFeet(m_wellDiameter / 2); } else { - return wellDiameter / 2; + return m_wellDiameter / 2; } } else if (m_fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { if (unitSystem == RiaEclipseUnitTools::UNITS_METRIC) { - return RiaEclipseUnitTools::inchToMeter(wellDiameter / 2); + return RiaEclipseUnitTools::inchToMeter(m_wellDiameter / 2); } else { - return RiaEclipseUnitTools::inchToFeet(wellDiameter / 2); + return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2); } } return cvf::UNDEFINED_DOUBLE; @@ -296,17 +328,17 @@ cvf::Mat4d RimFracture::transformMatrix() const cvf::Vec3d center = anchorPosition(); // Dip (in XY plane) - cvf::Mat4d dipRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(dip())); + cvf::Mat4d dipRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(m_dip())); // Dip (out of XY plane) - cvf::Mat4d tiltRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(tilt())); + cvf::Mat4d tiltRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(m_tilt())); // Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y cvf::Mat4d rotationFromTesselator = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(90.0f)); // Azimuth rotation - cvf::Mat4d azimuthRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(-azimuth()-90)); + cvf::Mat4d azimuthRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(-m_azimuth()-90)); cvf::Mat4d m = azimuthRotation * rotationFromTesselator * dipRotation * tiltRotation; m.setTranslation(center); @@ -319,25 +351,24 @@ cvf::Mat4d RimFracture::transformMatrix() const //-------------------------------------------------------------------------------------------------- void RimFracture::triangleGeometry(std::vector* triangleIndices, std::vector* nodeCoords) { - RimFractureTemplate* fractureDef = fractureTemplate(); - if (fractureDef ) - { - fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices, fractureUnit()); - } + RimFractureTemplate* fractureDef = fractureTemplate(); + if (fractureDef) + { + fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices, fractureUnit()); + } - cvf::Mat4d m = transformMatrix(); + cvf::Mat4d m = transformMatrix(); - for (cvf::Vec3f& v : *nodeCoords) - { - cvf::Vec3d vd(v); + for (cvf::Vec3f& v : *nodeCoords) + { + cvf::Vec3d vd(v); - vd.transformPoint(m); + vd.transformPoint(m); - v = cvf::Vec3f(vd); - } + v = cvf::Vec3f(vd); + } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -373,7 +404,7 @@ QList RimFracture::calculateValueOptions(const caf::PdmF options.push_back(caf::PdmOptionItemInfo(fracDef->name(), fracDef)); } } - else if (fieldNeedingOptions == &stimPlanTimeIndexToPlot) + else if (fieldNeedingOptions == &m_stimPlanTimeIndexToPlot) { if (fractureTemplate()) { @@ -403,13 +434,13 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO { if (m_fractureUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); - perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); } else if (m_fractureUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); } if (fractureTemplate()) @@ -441,47 +472,47 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - azimuth.uiCapability()->setUiReadOnly(true); + m_azimuth.uiCapability()->setUiReadOnly(true); } else if (fractureTemplate()->orientationType == RimFractureTemplate::AZIMUTH) { - azimuth.uiCapability()->setUiReadOnly(false); + m_azimuth.uiCapability()->setUiReadOnly(false); } if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) { - perforationEfficiency.uiCapability()->setUiHidden(false); - perforationLength.uiCapability()->setUiHidden(false); + m_perforationEfficiency.uiCapability()->setUiHidden(false); + m_perforationLength.uiCapability()->setUiHidden(false); } else { - perforationEfficiency.uiCapability()->setUiHidden(true); - perforationLength.uiCapability()->setUiHidden(true); + m_perforationEfficiency.uiCapability()->setUiHidden(true); + m_perforationLength.uiCapability()->setUiHidden(true); } if (fractureTemplate()->conductivityType == RimFractureTemplate::FINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(false); + m_wellDiameter.uiCapability()->setUiHidden(false); } else if (fractureTemplate()->conductivityType == RimFractureTemplate::INFINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(true); + m_wellDiameter.uiCapability()->setUiHidden(true); } RimFractureTemplate* fracTemplate = fractureTemplate(); if (dynamic_cast(fracTemplate)) { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); - stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); } else { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); } } else { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); } } @@ -490,7 +521,7 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO //-------------------------------------------------------------------------------------------------- void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { - if (field == &azimuth) + if (field == &m_azimuth) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -500,7 +531,7 @@ void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QStrin } } - if (field == &perforationEfficiency) + if (field == &m_perforationEfficiency) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -598,19 +629,19 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(fractureTemplate); if (stimPlanFracTemplate) { - stimPlanTimeIndexToPlot = stimPlanFracTemplate->activeTimeStepIndex(); + m_stimPlanTimeIndexToPlot = stimPlanFracTemplate->activeTimeStepIndex(); } if (fractureTemplate->orientationType == RimFractureTemplate::AZIMUTH) { - azimuth = fractureTemplate->azimuthAngle; + m_azimuth = fractureTemplate->azimuthAngle; } else { this->updateAzimuthBasedOnWellAzimuthAngle(); } - this->wellDiameter = fractureTemplate->wellDiameterInFractureUnit(m_fractureUnit()); - this->perforationLength = fractureTemplate->perforationLengthInFractureUnit(m_fractureUnit()); + this->m_wellDiameter = fractureTemplate->wellDiameterInFractureUnit(m_fractureUnit()); + this->m_perforationLength = fractureTemplate->perforationLengthInFractureUnit(m_fractureUnit()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 6d75ca5b0d..ef870afd5e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -55,16 +55,11 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf RimFracture(void); virtual ~RimFracture(void); - caf::PdmField azimuth; - caf::PdmField perforationLength; - caf::PdmField perforationEfficiency; - caf::PdmField wellDiameter; - - caf::PdmField dip; - caf::PdmField tilt; - - caf::PdmField stimPlanTimeIndexToPlot; - + double perforationLength() const; + double perforationEfficiency() const; + + int stimPlanTimeIndexToPlot() const; + void setStimPlanTimeIndexToPlot(int timeIndex); double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; cvf::Vec3d anchorPosition() const ; @@ -96,6 +91,8 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf virtual void loadDataAndUpdate() = 0; + friend class RimFractureTemplate; + protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; @@ -115,13 +112,19 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf caf::PdmProxyValueField m_uiAnchorPosition; caf::PdmField< RiaEclipseUnitTools::UnitSystemType > m_fractureUnit; - caf::PdmProxyValueField m_uiWellPathAzimuth; - caf::PdmProxyValueField m_uiWellFractureAzimuthDiff; - caf::PdmField m_wellFractureAzimuthAngleWarning; + caf::PdmProxyValueField m_uiWellPathAzimuth; + caf::PdmProxyValueField m_uiWellFractureAzimuthDiff; + caf::PdmField m_wellFractureAzimuthAngleWarning; + caf::PdmField m_dip; + caf::PdmField m_tilt; + caf::PdmField m_azimuth; + caf::PdmField m_perforationLength; + caf::PdmField m_perforationEfficiency; + caf::PdmField m_wellDiameter; + caf::PdmField m_stimPlanTimeIndexToPlot; private: - caf::PdmField m_anchorPosition; - - cvf::ref m_fracturePartMgr; + caf::PdmField m_anchorPosition; + cvf::ref m_fracturePartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 70125b54cd..cde7466846 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -121,16 +121,16 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &azimuthAngle && (fabs(oldValue.toDouble() - fracture->azimuth()) < 1e-5)) + if (changedField == &azimuthAngle && (fabs(oldValue.toDouble() - fracture->m_azimuth()) < 1e-5)) { - fracture->azimuth = azimuthAngle; + fracture->m_azimuth = azimuthAngle; } if (changedField == &orientationType) { if (newValue == AZIMUTH) { - fracture->azimuth = azimuthAngle; + fracture->m_azimuth = azimuthAngle; } else fracture->updateAzimuthBasedOnWellAzimuthAngle(); } @@ -153,17 +153,17 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &perforationLength && (fabs(oldValue.toDouble() - fracture->perforationLength()) < 1e-5)) + if (changedField == &perforationLength && (fabs(oldValue.toDouble() - fracture->m_perforationLength()) < 1e-5)) { - fracture->perforationLength = perforationLength; + fracture->m_perforationLength = perforationLength; } - if (changedField == &perforationEfficiency && (fabs(oldValue.toDouble() - fracture->perforationEfficiency()) < 1e-5)) + if (changedField == &perforationEfficiency && (fabs(oldValue.toDouble() - fracture->m_perforationEfficiency()) < 1e-5)) { - fracture->perforationEfficiency = perforationEfficiency; + fracture->m_perforationEfficiency = perforationEfficiency; } - if (changedField == &wellDiameter && (fabs(oldValue.toDouble() - fracture->wellDiameter()) < 1e-5)) + if (changedField == &wellDiameter && (fabs(oldValue.toDouble() - fracture->m_wellDiameter()) < 1e-5)) { - fracture->wellDiameter = wellDiameter; + fracture->m_wellDiameter = wellDiameter; } } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index e336b8d4fe..1877babb38 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -90,12 +90,12 @@ void RimSimWellFracture::updateAzimuthBasedOnWellAzimuthAngle() if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH ) { - azimuth = simWellAzimuth; + m_azimuth = simWellAzimuth; } else if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - if (simWellAzimuth + 90 < 360) azimuth = simWellAzimuth + 90; - else azimuth = simWellAzimuth - 90; + if (simWellAzimuth + 90 < 360) m_azimuth = simWellAzimuth + 90; + else m_azimuth = simWellAzimuth - 90; } } } @@ -201,20 +201,20 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_location); locationGroup->add(&m_branchIndex); - locationGroup->add(&azimuth); + locationGroup->add(&m_azimuth); locationGroup->add(&m_uiWellPathAzimuth); locationGroup->add(&m_uiWellFractureAzimuthDiff); locationGroup->add(&m_wellFractureAzimuthAngleWarning); - locationGroup->add(&dip); - locationGroup->add(&tilt); + locationGroup->add(&m_dip); + locationGroup->add(&m_tilt); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); propertyGroup->add(&m_fractureTemplate); - propertyGroup->add(&stimPlanTimeIndexToPlot); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); caf::PdmUiGroup* fractureCenterGroup = uiOrdering.addNewGroup("Fracture Center Info"); fractureCenterGroup->add(&m_uiAnchorPosition); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 7a3ad7d19b..c3f13df795 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -113,7 +113,7 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch { if (fracture->fractureTemplate() == this) { - fracture->stimPlanTimeIndexToPlot = m_activeTimeStepIndex; + fracture->setStimPlanTimeIndexToPlot(m_activeTimeStepIndex); } } proj->createDisplayModelAndRedrawAllViews(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index 1300e493ce..d532fe0b91 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -91,12 +91,12 @@ void RimWellPathFracture::updateAzimuthBasedOnWellAzimuthAngle() if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) { - azimuth = wellPathAzimuth; + m_azimuth = wellPathAzimuth; } if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - if (wellPathAzimuth + 90 < 360) azimuth = wellPathAzimuth + 90; - else azimuth = wellPathAzimuth - 90; + if (wellPathAzimuth + 90 < 360) m_azimuth = wellPathAzimuth + 90; + else m_azimuth = wellPathAzimuth - 90; } } } @@ -166,20 +166,20 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_measuredDepth); - locationGroup->add(&azimuth); + locationGroup->add(&m_azimuth); locationGroup->add(&m_uiWellPathAzimuth); locationGroup->add(&m_uiWellFractureAzimuthDiff); locationGroup->add(&m_wellFractureAzimuthAngleWarning); - locationGroup->add(&dip); - locationGroup->add(&tilt); + locationGroup->add(&m_dip); + locationGroup->add(&m_tilt); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); propertyGroup->add(&m_fractureTemplate); - propertyGroup->add(&stimPlanTimeIndexToPlot); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); caf::PdmUiGroup* fractureCenterGroup = uiOrdering.addNewGroup("Fracture Center Info"); fractureCenterGroup->add(&m_uiAnchorPosition); From d25f9d4b67b6e2967b054eecafe4112a024a7736 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 10:25:16 +0100 Subject: [PATCH 0039/1027] Use const reference --- ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index a2a99e9130..a2f63158a4 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -276,7 +276,7 @@ cvf::BoundingBox RimFracture::boundingBoxInDomainCoords() this->triangleGeometry(&triangleIndices, &nodeCoordVec); cvf::BoundingBox fractureBBox; - for (cvf::Vec3f nodeCoord : nodeCoordVec) fractureBBox.add(nodeCoord); + for (const auto& nodeCoord : nodeCoordVec) fractureBBox.add(nodeCoord); return fractureBBox; } From 7511e8a24388297366dd4b46067000d008889d25 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 10:55:00 +0100 Subject: [PATCH 0040/1027] #2322 New View : Improve default values when creating view --- .../Tools/RiaImportEclipseCaseTools.cpp | 9 --------- .../RicImportInputEclipseCaseFeature.cpp | 1 - .../ProjectDataModel/RimEclipseCase.cpp | 20 +++++++++++++++++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index d1b69a59d0..12336ec1cf 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -110,15 +110,6 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr RimEclipseView* riv = rimResultReservoir->createAndAddReservoirView(); - // Select SOIL as default result variable - riv->cellResult()->setResultType(RiaDefines::DYNAMIC_NATIVE); - - if (app->preferences()->loadAndShowSoil) - { - riv->cellResult()->setResultVariable("SOIL"); - } - riv->hasUserRequestedAnimation = true; - riv->loadDataAndUpdate(); // Add a corresponding summary case if it exists diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp index 243311309e..db29b90609 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp @@ -66,7 +66,6 @@ bool RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(const Q RimEclipseView* riv = rimInputReservoir->createAndAddReservoirView(); riv->cellResult()->setResultType(RiaDefines::INPUT_PROPERTY); - riv->hasUserRequestedAnimation = true; riv->loadDataAndUpdate(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 7bc635fc9a..a0755e0053 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -45,6 +45,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" +#include "RimStimPlanColors.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlot.h" @@ -223,8 +224,23 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() { RimEclipseView* rimEclipseView = new RimEclipseView(); rimEclipseView->setEclipseCase(this); - rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); - rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; + + // Set default values + { + rimEclipseView->cellResult()->setResultType(RiaDefines::DYNAMIC_NATIVE); + + if (RiaApplication::instance()->preferences()->loadAndShowSoil) + { + rimEclipseView->cellResult()->setResultVariable("SOIL"); + } + + rimEclipseView->hasUserRequestedAnimation = true; + + rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); + rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; + + rimEclipseView->stimPlanColors()->setDefaultResultNameForStimPlan(); + } caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView); From ded9cc6708f5152f77f38cd944ea434da44264a7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 11:56:33 +0100 Subject: [PATCH 0041/1027] #2322 Check define before using stimPlanColors --- ApplicationCode/ProjectDataModel/RimEclipseCase.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index a0755e0053..43213fcf62 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -239,7 +239,9 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES rimEclipseView->stimPlanColors()->setDefaultResultNameForStimPlan(); +#endif // USE_PROTOTYPE_FEATURE_FRACTURES } caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView); From 57b521c6d95b547cf0bff50992e3bc9de4ba6f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 11 Jan 2018 12:52:37 +0100 Subject: [PATCH 0042/1027] AppFwk: Add a guarded interface pointer class --- .../cafPdmCore/cafPdmInterfacePointer.h | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h new file mode 100644 index 0000000000..2125c9fe06 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h @@ -0,0 +1,86 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018 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 "cafPdmPointer.h" + +namespace caf +{ + +template +class PdmInterfacePointer +{ +public: + inline PdmInterfacePointer () : m_iface(nullptr) { } + inline PdmInterfacePointer ( T * iface ) { *this = iface; } + inline PdmInterfacePointer ( const PdmInterfacePointer & other ) { *this = other.p();} + + T* p() const + { + if ( m_implementingPdmObject.notNull() ) + { + return m_iface; + } + else + { + return nullptr; + } + } + + PdmInterfacePointer & operator= ( T* iface ) + { + m_implementingPdmObject = nullptr; + m_iface = nullptr; + if ( iface != nullptr ) + { + m_implementingPdmObject = iface->implementingPdmObject(); + m_iface = iface; + } + return *this; + } + + bool isNull() const { return m_implementingPdmObject.isNull(); } + bool notNull() const { return m_implementingPdmObject.notNull(); } + operator T* () const { return p(); } + T* operator->() const { return p(); } + PdmInterfacePointer & operator= ( const PdmInterfacePointer& other ) { return *this = other.p();} + +private: + T* m_iface; + PdmPointer m_implementingPdmObject; +}; + +} \ No newline at end of file From 564468460656a34afedb57facec76d88f59c8396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 11 Jan 2018 12:59:52 +0100 Subject: [PATCH 0043/1027] #2331 Refactor the viewer-view communication to pave way for 2dIntersection Views --- .../ProjectDataModel/Rim3dView.cpp | 74 ++++++++++----- ApplicationCode/ProjectDataModel/Rim3dView.h | 24 ++++- .../UserInterface/CMakeLists_files.cmake | 1 + ApplicationCode/UserInterface/RiuViewer.cpp | 94 ++++++++++--------- ApplicationCode/UserInterface/RiuViewer.h | 17 +++- .../UserInterface/RiuViewerToViewInterface.h | 64 +++++++++++++ 6 files changed, 197 insertions(+), 77 deletions(-) create mode 100644 ApplicationCode/UserInterface/RiuViewerToViewInterface.h diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index c2301beed0..75930a9963 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -95,11 +95,11 @@ Rim3dView::Rim3dView(void) CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); - cameraPosition.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); + m_cameraPosition.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); - cameraPointOfInterest.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); + m_cameraPointOfInterest.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", ""); @@ -107,7 +107,7 @@ Rim3dView::Rim3dView(void) CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); + CAF_PDM_InitField(&m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); maximumFrameRate.uiCapability()->setUiHidden(true); @@ -219,6 +219,13 @@ QWidget* Rim3dView::createViewWidget(QWidget* mainWindowParent) m_viewer = new RiuViewer(glFormat, NULL); m_viewer->setOwnerReservoirView(this); + cvf::String xLabel; + cvf::String yLabel; + cvf::String zLabel; + + this->axisLabels(&xLabel, &yLabel, &zLabel); + m_viewer->setAxisLabels(xLabel, yLabel, zLabel); + return m_viewer->layoutWidget(); } @@ -235,8 +242,8 @@ void Rim3dView::updateViewWidgetAfterCreation() m_viewer->updateNavigationPolicy(); m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); - m_viewer->mainCamera()->setViewMatrix(cameraPosition); - m_viewer->setPointOfInterest(cameraPointOfInterest()); + m_viewer->mainCamera()->setViewMatrix(m_cameraPosition); + m_viewer->setPointOfInterest(m_cameraPointOfInterest()); m_viewer->enableParallelProjection(!isPerspectiveView()); m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); @@ -289,7 +296,7 @@ void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrd { caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); viewGroup->add(&name); - viewGroup->add(&backgroundColor); + viewGroup->add(&m_backgroundColor); viewGroup->add(&showGridBox); viewGroup->add(&isPerspectiveView); viewGroup->add(&m_disableLighting); @@ -350,6 +357,14 @@ void Rim3dView::setCurrentTimeStepAndUpdate(int frameIndex) project->mainPlotCollection()->updateCurrentTimeStepInPlots(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dView::timeStepName(int frameIdx) const +{ + return this->ownerCase()->timeStepName(frameIdx); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -399,11 +414,11 @@ void Rim3dView::createDisplayModelAndRedraw() createHighlightAndGridBoxDisplayModel(); updateDisplayModelVisibility(); - if (cameraPosition().isIdentity()) + if (m_cameraPosition().isIdentity()) { setDefaultView(); - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); } } @@ -453,8 +468,8 @@ void Rim3dView::setupBeforeSave() if (m_viewer) { hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); } } @@ -702,7 +717,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const } } } - else if (changedField == &backgroundColor) + else if (changedField == &m_backgroundColor) { if (m_viewer != nullptr) { @@ -961,9 +976,14 @@ void Rim3dView::removeModelByName(cvf::Scene* scene, const cvf::String& modelNam //-------------------------------------------------------------------------------------------------- void Rim3dView::updateGridBoxData() { - if (m_viewer) + if (m_viewer && ownerCase()) { - m_viewer->updateGridBoxData(); + m_viewer->updateGridBoxData(scaleZ(), + ownerCase()->displayModelOffset(), + backgroundColor(), + showActiveCellsOnly() ? ownerCase()->activeCellsBoundingBox() + : ownerCase()->allCellsBoundingBox() + ); } } @@ -1005,7 +1025,6 @@ void Rim3dView::createHighlightAndGridBoxDisplayModelWithRedraw() void Rim3dView::createHighlightAndGridBoxDisplayModel() { m_viewer->removeStaticModel(m_highlightVizModel.p()); - m_viewer->removeStaticModel(m_viewer->gridBoxModel()); m_highlightVizModel->removeAllParts(); @@ -1022,10 +1041,7 @@ void Rim3dView::createHighlightAndGridBoxDisplayModel() m_viewer->addStaticModelOnce(m_highlightVizModel.p()); } - if (showGridBox) - { - m_viewer->addStaticModelOnce(m_viewer->gridBoxModel()); - } + m_viewer->showGridBox(showGridBox()); } //-------------------------------------------------------------------------------------------------- @@ -1091,3 +1107,19 @@ void Rim3dView::forceShowWindowOn() m_showWindow.setValueWithFieldChanged(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::handleMdiWindowClosed() +{ + RimViewWindow::handleMdiWindowClosed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) +{ + RimViewWindow::setMdiWindowGeometry(windowGeometry); +} + diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 48f8d4c63a..2255d49f8c 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -18,6 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RiuViewerToViewInterface.h" #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" @@ -70,7 +71,7 @@ namespace caf /// /// //================================================================================================== -class Rim3dView : public RimViewWindow +class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface { CAF_PDM_HEADER_INIT; public: @@ -82,11 +83,10 @@ class Rim3dView : public RimViewWindow caf::PdmField name; caf::PdmField scaleZ; - - caf::PdmField cameraPosition; - caf::PdmField cameraPointOfInterest; + void setCameraPosition(const cvf::Mat4d& cameraPosition) { m_cameraPosition = cameraPosition; } + void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) { m_cameraPointOfInterest = cameraPointOfInterest;} caf::PdmField isPerspectiveView; - caf::PdmField< cvf::Color3f > backgroundColor; + cvf::Color3f backgroundColor() const { return m_backgroundColor();} caf::PdmField maximumFrameRate; caf::PdmField hasUserRequestedAnimation; @@ -140,6 +140,7 @@ class Rim3dView : public RimViewWindow int currentTimeStep() const { return m_currentTimeStep;} void setCurrentTimeStep(int frameIdx); void setCurrentTimeStepAndUpdate(int frameIdx); + QString timeStepName(int frameIdx) const override; void updateCurrentTimeStepAndRedraw(); @@ -169,6 +170,8 @@ class Rim3dView : public RimViewWindow virtual QWidget* viewWidget() override; void forceShowWindowOn(); + + public: void updateGridBoxData(); void updateAnnotationItems(); @@ -243,10 +246,21 @@ class Rim3dView : public RimViewWindow friend class RiuViewer; void endAnimation(); + caf::PdmObjectHandle* implementingPdmObject() { return this; } + virtual void handleMdiWindowClosed() override; + virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; private: bool m_previousGridModeMeshLinesWasFaults; caf::PdmField m_disableLighting; + caf::PdmField m_cameraPosition; + caf::PdmField m_cameraPointOfInterest; + caf::PdmField< cvf::Color3f > m_backgroundColor; + + + + + }; diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index f6219706d6..b366a6f56b 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -43,6 +43,7 @@ ${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h ${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.h ${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h ${CEE_CURRENT_LIST_DIR}RiuViewer.h +${CEE_CURRENT_LIST_DIR}RiuViewerToViewInterface.h ${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h ${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h ${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 19a47501b6..98a63f66f0 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -186,9 +186,10 @@ RiuViewer::~RiuViewer() { m_rimView->handleMdiWindowClosed(); - m_rimView->cameraPosition = m_mainCamera->viewMatrix(); - m_rimView->cameraPointOfInterest = pointOfInterest(); + m_rimView->setCameraPosition(m_mainCamera->viewMatrix()); + m_rimView->setCameraPointOfInterest( pointOfInterest()); } + delete m_infoLabel; delete m_animationProgress; delete m_histogramWidget; @@ -297,7 +298,7 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex) RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateTimeStep(m_rimView, frameIndex); + viewLinker->updateTimeStep(dynamic_cast(m_rimView.p()), frameIndex); } } } @@ -321,17 +322,11 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::setOwnerReservoirView(Rim3dView * owner) +void RiuViewer::setOwnerReservoirView(RiuViewerToViewInterface * owner) { m_rimView = owner; - m_viewerCommands->setOwnerView(owner); - - cvf::String xLabel; - cvf::String yLabel; - cvf::String zLabel; - m_rimView->axisLabels(&xLabel, &yLabel, &zLabel); - setAxisLabels(xLabel, yLabel, zLabel); + m_viewerCommands->setOwnerView(dynamic_cast(owner)); } //-------------------------------------------------------------------------------------------------- @@ -367,7 +362,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) if (showAnimBar && m_showAnimProgress) { - QString stepName = m_rimView->ownerCase()->timeStepName(currentFrameIndex()); + QString stepName = m_rimView->timeStepName(currentFrameIndex()); m_animationProgress->setFormat("Time Step: %v/%m " + stepName); m_animationProgress->setMinimum(0); m_animationProgress->setMaximum(static_cast(frameCount()) - 1); @@ -468,6 +463,19 @@ void RiuViewer::setHistogramPercentiles(double pmin, double pmax, double mean) m_histogramWidget->setMean(mean); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::showGridBox(bool enable) +{ + this->removeStaticModel(m_gridBoxGenerator->model()); + + if (enable) + { + this->addStaticModelOnce(m_gridBoxGenerator->model()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -622,7 +630,7 @@ void RiuViewer::navigationPolicyUpdate() RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateCamera(m_rimView); + viewLinker->updateCamera(dynamic_cast(m_rimView.p())); } } } @@ -645,7 +653,20 @@ void RiuViewer::setCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RiuViewer::ownerReservoirView() +void RiuViewer::showAxisCross(bool enable) +{ + m_mainRendering->removeOverlayItem(m_axisCross.p()); + + if (enable) + { + m_mainRendering->addOverlayItem(m_axisCross.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewerToViewInterface* RiuViewer::ownerReservoirView() { return m_rimView; } @@ -655,7 +676,7 @@ Rim3dView* RiuViewer::ownerReservoirView() //-------------------------------------------------------------------------------------------------- RimViewWindow* RiuViewer::ownerViewWindow() const { - return m_rimView; + return dynamic_cast( m_rimView.p()); } //-------------------------------------------------------------------------------------------------- @@ -719,7 +740,7 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent) cvf::ref trans = m_rimView->displayCoordTransform(); cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord); - viewLinker->updateCursorPosition(m_rimView, domainCoord); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()) , domainCoord); } } } @@ -735,43 +756,24 @@ void RiuViewer::leaveEvent(QEvent *) if (m_rimView && m_rimView->assosiatedViewLinker()) { RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); - viewLinker->updateCursorPosition(m_rimView, cvf::Vec3d::UNDEFINED); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()), cvf::Vec3d::UNDEFINED); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::updateGridBoxData() +void RiuViewer::updateGridBoxData(double scaleZ, + const cvf::Vec3d& displayModelOffset, + const cvf::Color3f& backgroundColor, + const cvf::BoundingBox& domainCoordBoundingBox) { - if (ownerReservoirView() && ownerReservoirView()->ownerCase()) - { - Rim3dView* rimView = ownerReservoirView(); - RimCase* rimCase = rimView->ownerCase(); - - m_gridBoxGenerator->setScaleZ(rimView->scaleZ); - m_gridBoxGenerator->setDisplayModelOffset(rimCase->displayModelOffset()); - m_gridBoxGenerator->updateFromBackgroundColor(rimView->backgroundColor); - - if (rimView->showActiveCellsOnly()) - { - m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->activeCellsBoundingBox()); - } - else - { - m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->allCellsBoundingBox()); - } - - m_gridBoxGenerator->createGridBoxParts(); - } -} + m_gridBoxGenerator->setScaleZ(scaleZ); + m_gridBoxGenerator->setDisplayModelOffset(displayModelOffset); + m_gridBoxGenerator->updateFromBackgroundColor(backgroundColor); + m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(domainCoordBoundingBox); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Model* RiuViewer::gridBoxModel() const -{ - return m_gridBoxGenerator->model(); + m_gridBoxGenerator->createGridBoxParts(); } //-------------------------------------------------------------------------------------------------- @@ -907,7 +909,7 @@ cvf::Color3f RiuViewer::computeContrastColor() const if (m_rimView.notNull()) { - contrastColor = RiaColorTools::constrastColor(m_rimView->backgroundColor); + contrastColor = RiaColorTools::constrastColor(m_rimView->backgroundColor()); } return contrastColor; diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 81c8349932..35a8b6926e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -20,10 +20,12 @@ #pragma once +#include "RiuViewerToViewInterface.h" #include "cafViewer.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmInterfacePointer.h" #include "cafMouseState.h" #include "cvfStructGrid.h" @@ -46,6 +48,7 @@ namespace cvf class OverlayItem; class Part; class OverlayAxisCross; + class BoundingBox; } //================================================================================================== @@ -64,8 +67,8 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setDefaultView(); cvf::Vec3d pointOfInterest(); void setPointOfInterest(cvf::Vec3d poi); - void setOwnerReservoirView(Rim3dView * owner); - Rim3dView* ownerReservoirView(); + void setOwnerReservoirView(RiuViewerToViewInterface * owner); + RiuViewerToViewInterface* ownerReservoirView(); RimViewWindow* ownerViewWindow() const override; void setEnableMask(unsigned int mask); @@ -75,8 +78,11 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setHistogram(double min, double max, const std::vector& histogram); void setHistogramPercentiles(double pmin, double pmax, double mean); - void updateGridBoxData(); - cvf::Model* gridBoxModel() const; + void showGridBox(bool enable); + void updateGridBoxData(double scaleZ, + const cvf::Vec3d& displayModelOffset, + const cvf::Color3f& backgroundColor, + const cvf::BoundingBox& domainCoordBoundingBox); void updateAnnotationItems(); @@ -91,6 +97,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setCurrentFrame(int frameIndex); + void showAxisCross(bool enable); void setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel); cvf::Vec3d lastPickPositionInDomainCoords() const; @@ -141,7 +148,7 @@ public slots: cvf::ref m_axisCross; cvf::Collection m_visibleLegends; - caf::PdmPointer m_rimView; + caf::PdmInterfacePointer m_rimView; QPoint m_lastMousePressPosition; RiuViewerCommands* m_viewerCommands; diff --git a/ApplicationCode/UserInterface/RiuViewerToViewInterface.h b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h new file mode 100644 index 0000000000..fd71685bb2 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfColor3.h" +#include "cvfMatrix4.h" +#include "cvfVector3.h" + +#include + +class RimCase; +class RimViewLinker; +struct RimMdiWindowGeometry; +class RimViewController; + +namespace caf +{ + class PdmObjectHandle; + class DisplayCoordTransform; +} + + +class RiuViewerToViewInterface +{ +public: + virtual caf::PdmObjectHandle* implementingPdmObject() = 0; + + virtual void handleMdiWindowClosed() = 0; + virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) = 0; + + virtual void setCameraPosition(const cvf::Mat4d & cameraPosition) = 0; + virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) = 0; + + virtual cvf::Color3f backgroundColor() const = 0; + virtual void selectOverlayInfoConfig() = 0; + + virtual RimViewLinker* assosiatedViewLinker() const = 0; + virtual RimViewController* viewController() const = 0; + + virtual QString timeStepName( int ) const = 0; + virtual cvf::ref displayCoordTransform() const = 0; + + virtual void setCurrentTimeStepAndUpdate(int frameIndex) = 0; + virtual void updateCurrentTimeStepAndRedraw() = 0; + virtual void endAnimation() = 0; +}; From 591b72901f1098171627d2302ebfd32256487ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 11 Jan 2018 15:44:22 +0100 Subject: [PATCH 0044/1027] #2331 Reordered Rim3dView header to pave way for Rim2dIntersectionView --- ApplicationCode/ProjectDataModel/Rim3dView.h | 160 ++++++++----------- 1 file changed, 69 insertions(+), 91 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 2255d49f8c..9134c8cda9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -19,6 +19,7 @@ #pragma once #include "RiuViewerToViewInterface.h" +#include "RimViewWindow.h" #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" @@ -31,8 +32,6 @@ #include "RivCellSetEnum.h" -#include "RimViewWindow.h" - #include "cvfArray.h" #include "cvfBase.h" #include "cvfCollection.h" @@ -78,49 +77,25 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface Rim3dView(void); virtual ~Rim3dView(void); - // 3D Viewer - RiuViewer* viewer(); + // Public fields: caf::PdmField name; caf::PdmField scaleZ; - void setCameraPosition(const cvf::Mat4d& cameraPosition) { m_cameraPosition = cameraPosition; } - void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) { m_cameraPointOfInterest = cameraPointOfInterest;} caf::PdmField isPerspectiveView; - cvf::Color3f backgroundColor() const { return m_backgroundColor();} - caf::PdmField maximumFrameRate; caf::PdmField hasUserRequestedAnimation; - virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; - RimCellRangeFilterCollection* rangeFilterCollection(); - const RimCellRangeFilterCollection* rangeFilterCollection() const; - - bool hasOverridenRangeFilterCollection(); - void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); - void replaceRangeFilterCollectionWithOverride(); + // Draw style + enum MeshModeType { FULL_MESH, FAULTS_MESH, NO_MESH }; + enum SurfaceModeType { SURFACE, FAULTS, NO_SURFACE }; - caf::PdmChildField crossSectionCollection; + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; + caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - // Draw style + caf::PdmChildField crossSectionCollection; - enum MeshModeType - { - FULL_MESH, - FAULTS_MESH, - NO_MESH - }; - - enum SurfaceModeType - { - SURFACE, - FAULTS, - NO_SURFACE - }; - - caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; - caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - caf::PdmField showGridBox; + RiuViewer* viewer(); void setMeshOnlyDrawstyle(); void setMeshSurfDrawstyle(); @@ -135,56 +110,50 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface bool isGridVisualizationMode() const; void setScaleZAndUpdate(double scaleZ); + virtual bool showActiveCellsOnly(); + virtual bool isUsingFormationNames() const = 0; + cvf::ref currentTotalCellVisibility(); + + virtual QImage snapshotWindowContent() override; + virtual void zoomAll() override; + void forceShowWindowOn(); // Animation int currentTimeStep() const { return m_currentTimeStep;} void setCurrentTimeStep(int frameIdx); - void setCurrentTimeStepAndUpdate(int frameIdx); - QString timeStepName(int frameIdx) const override; - - void updateCurrentTimeStepAndRedraw(); + void setCurrentTimeStepAndUpdate(int frameIdx) override; + // Updating + void updateCurrentTimeStepAndRedraw() override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0; void scheduleCreateDisplayModelAndRedraw(); void createDisplayModelAndRedraw(); void createHighlightAndGridBoxDisplayModelWithRedraw(); + void updateGridBoxData(); + void updateAnnotationItems(); - RimViewController* viewController() const; - bool isMasterView() const; - RimViewLinker* assosiatedViewLinker() const; - - virtual bool isUsingFormationNames() const = 0; - cvf::ref currentTotalCellVisibility(); - - virtual bool showActiveCellsOnly(); - virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; - - void selectOverlayInfoConfig(); - - virtual QImage snapshotWindowContent() override; - - virtual void zoomAll() override; - - cvf::ref displayCoordTransform() const; + virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; + RimCellRangeFilterCollection* rangeFilterCollection(); + const RimCellRangeFilterCollection* rangeFilterCollection() const; - virtual QWidget* viewWidget() override; - void forceShowWindowOn(); + bool hasOverridenRangeFilterCollection(); + void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); + void replaceRangeFilterCollectionWithOverride(); + RimViewController* viewController() const override; + bool isMasterView() const; + RimViewLinker* assosiatedViewLinker() const override; + cvf::ref displayCoordTransform() const override; -public: - void updateGridBoxData(); - void updateAnnotationItems(); virtual RimCase* ownerCase() const = 0; - - virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } - Rim3dOverlayInfoConfig* overlayInfoConfig() const; protected: void setDefaultView(); + RimWellPathCollection* wellPathCollection(); void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox); @@ -193,10 +162,13 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - virtual void createDisplayModel() = 0; - void createHighlightAndGridBoxDisplayModel(); + // Abstract methods to implement in subclasses + + virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; + + virtual void createDisplayModel() = 0; virtual void createPartCollectionFromSelection(cvf::Collection* parts) = 0; virtual void updateDisplayModelVisibility() = 0; @@ -210,45 +182,54 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual void resetLegendsInViewer() = 0; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; - - virtual void onLoadDataAndUpdate() = 0; - - RimWellPathCollection* wellPathCollection(); - - QPointer m_viewer; - - caf::PdmField m_currentTimeStep; - caf::PdmChildField m_overlayInfoConfig; - - caf::PdmChildField m_rangeFilterCollection; - caf::PdmChildField m_overrideRangeFilterCollection; - caf::PdmChildField m_gridCollection; + // Overridden PdmObject methods: - // Overridden PDM methods: + virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } virtual void setupBeforeSave() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + // Overridden ViewWindow methods: + virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; virtual void updateViewWidgetAfterCreation() override; virtual void updateMdiWindowTitle() override; virtual void deleteViewWidget() override; + virtual QWidget* viewWidget() override; + +protected: // Fields + caf::PdmField m_currentTimeStep; + caf::PdmChildField m_overlayInfoConfig; - cvf::ref m_currentReservoirCellVisibility; + caf::PdmChildField m_rangeFilterCollection; + caf::PdmChildField m_overrideRangeFilterCollection; - cvf::ref m_wellPathPipeVizModel; - cvf::ref m_crossSectionVizModel; - cvf::ref m_highlightVizModel; + caf::PdmChildField m_gridCollection; + +protected: + QPointer m_viewer; + + cvf::ref m_currentReservoirCellVisibility; + + cvf::ref m_wellPathPipeVizModel; + cvf::ref m_crossSectionVizModel; + cvf::ref m_highlightVizModel; private: - RimViewLinker* viewLinkerIfMasterView() const; + RimViewLinker* viewLinkerIfMasterView() const; - friend class RiuViewer; - void endAnimation(); - caf::PdmObjectHandle* implementingPdmObject() { return this; } + // Implementation of RiuViewerToViewInterface + + virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();} + virtual void setCameraPosition(const cvf::Mat4d& cameraPosition) override { m_cameraPosition = cameraPosition; } + virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) override { m_cameraPointOfInterest = cameraPointOfInterest;} + virtual QString timeStepName(int frameIdx) const override; + virtual void endAnimation() override; + virtual caf::PdmObjectHandle* implementingPdmObject() override { return this; } virtual void handleMdiWindowClosed() override; virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; + virtual void selectOverlayInfoConfig() override; private: bool m_previousGridModeMeshLinesWasFaults; @@ -256,10 +237,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface caf::PdmField m_cameraPosition; caf::PdmField m_cameraPointOfInterest; caf::PdmField< cvf::Color3f > m_backgroundColor; - - - - + caf::PdmField showGridBox; }; From 4b26354b30afa47b766921320707b63213623e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Jan 2018 11:31:01 +0100 Subject: [PATCH 0045/1027] #2331 Moved redraw scheduling and completion type recalc out of RiaApplication --- .../Application/CMakeLists_files.cmake | 6 + .../Application/RiaApplication.cpp | 153 +----------------- ApplicationCode/Application/RiaApplication.h | 19 +-- .../RiaCompletionTypeCalculationScheduler.cpp | 121 ++++++++++++++ .../RiaCompletionTypeCalculationScheduler.h | 51 ++++++ .../Application/RiaViewRedrawScheduler.cpp | 122 ++++++++++++++ .../Application/RiaViewRedrawScheduler.h | 51 ++++++ .../RicExportMultipleSnapshotsFeature.cpp | 3 +- .../RicSnapshotAllViewsToFileFeature.cpp | 3 +- .../ProjectDataModel/Rim3dView.cpp | 5 +- ApplicationCode/ProjectDataModel/Rim3dView.h | 32 ++-- .../ProjectDataModel/RimProject.cpp | 5 +- 12 files changed, 383 insertions(+), 188 deletions(-) create mode 100644 ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp create mode 100644 ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h create mode 100644 ApplicationCode/Application/RiaViewRedrawScheduler.cpp create mode 100644 ApplicationCode/Application/RiaViewRedrawScheduler.h diff --git a/ApplicationCode/Application/CMakeLists_files.cmake b/ApplicationCode/Application/CMakeLists_files.cmake index 0554e64e36..308f8074cb 100644 --- a/ApplicationCode/Application/CMakeLists_files.cmake +++ b/ApplicationCode/Application/CMakeLists_files.cmake @@ -6,21 +6,25 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RiaApplication.h +${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h ${CEE_CURRENT_LIST_DIR}RiaDefines.h ${CEE_CURRENT_LIST_DIR}RiaPreferences.h ${CEE_CURRENT_LIST_DIR}RiaPorosityModel.h ${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.h ${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.h +${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RiaApplication.cpp +${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.cpp ${CEE_CURRENT_LIST_DIR}RiaDefines.cpp ${CEE_CURRENT_LIST_DIR}RiaMain.cpp ${CEE_CURRENT_LIST_DIR}RiaPreferences.cpp ${CEE_CURRENT_LIST_DIR}RiaPorosityModel.cpp ${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.cpp ${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.cpp +${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,6 +38,8 @@ ${SOURCE_GROUP_SOURCE_FILES} set (QT_MOC_HEADERS ${QT_MOC_HEADERS} ${CEE_CURRENT_LIST_DIR}RiaApplication.h +${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h +${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h ) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index cd1b93099d..804820e5c6 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" +#include "RiaArgumentParser.h" #include "RiaBaseDefs.h" #include "RiaImageCompareReporter.h" #include "RiaImageFileCompare.h" @@ -29,7 +30,7 @@ #include "RiaProjectModifier.h" #include "RiaSocketServer.h" #include "RiaVersionInfo.h" -#include "RiaArgumentParser.h" +#include "RiaViewRedrawScheduler.h" #include "RigGridManager.h" #include "RigEclipseCaseData.h" @@ -227,9 +228,6 @@ RiaApplication::RiaApplication(int& argc, char** argv) // instead of using the application font m_standardFont = new caf::FixedAtlasFont(caf::FixedAtlasFont::POINT_SIZE_8); - m_resViewUpdateTimer = nullptr; - m_recalculateCompletionTypeTimer = nullptr; - m_runningRegressionTests = false; m_runningWorkerProcess = false; @@ -970,7 +968,7 @@ void RiaApplication::closeProject() { RiuMainWindow* mainWnd = RiuMainWindow::instance(); - clearViewsScheduledForUpdate(); + RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); terminateProcess(); @@ -2221,21 +2219,6 @@ cvf::Font* RiaApplication::customFont() return m_customFont.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::clearViewsScheduledForUpdate() -{ - if (m_resViewUpdateTimer) - { - while (m_resViewUpdateTimer->isActive()) - { - QCoreApplication::processEvents(); - } - } - m_resViewsToUpdate.clear(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2308,136 +2291,6 @@ QString RiaApplication::commandLineParameterHelp() const */ } -//-------------------------------------------------------------------------------------------------- -/// Schedule a creation of the Display model and redraw of the reservoir view -/// The redraw will happen as soon as the event loop is entered -//-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate) -{ - m_resViewsToUpdate.push_back(resViewToUpdate); - - if (!m_resViewUpdateTimer) - { - m_resViewUpdateTimer = new QTimer(this); - connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels())); - } - - if (!m_resViewUpdateTimer->isActive()) - { - m_resViewUpdateTimer->setSingleShot(true); - m_resViewUpdateTimer->start(0); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawAllViews() -{ - for (RimEclipseCase* eclipseCase : project()->activeOilField()->analysisModels->cases()) - { - m_eclipseCasesToRecalculate.push_back(eclipseCase); - } - - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(1500); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) -{ - m_eclipseCasesToRecalculate.push_back(eclipseCase); - - - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(500); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::slotUpdateScheduledDisplayModels() -{ - // Compress to remove duplicates - // and update dependent views after independent views - - std::set independent3DViewsToUpdate; - std::set dependent3DViewsToUpdate; - - for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) - { - if (!m_resViewsToUpdate[i]) continue; - - if (m_resViewsToUpdate[i]->viewController()) - dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); - else - independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); - } - - for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) - { - if (*it) - { - (*it)->createDisplayModelAndRedraw(); - } - } - - for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) - { - if (*it) - { - (*it)->createDisplayModelAndRedraw(); - } - } - - m_resViewsToUpdate.clear(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::slotRecalculateCompletionType() -{ - std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); - - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); - - for (RimEclipseCase* eclipseCase : uniqueCases) - { - eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); - } - - m_eclipseCasesToRecalculate.clear(); - - // Recalculation of completion type causes active view to be set to potentially a different view - // Also current index in project tree is changed. Restore both to initial state. - - if (activeView && activeView->viewer()) - { - RiaApplication::instance()->setActiveReservoirView(activeView); - RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget()); - } - - if (mi.isValid()) - { - RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi); - } -} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 780cc10b48..aeaf2cde29 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -105,10 +105,6 @@ class RiaApplication : public QApplication RimViewWindow* activePlotWindow() const; - void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate); - void scheduleRecalculateCompletionTypeAndRedrawAllViews(); - void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); - RimProject* project(); void createMockModel(); @@ -205,7 +201,6 @@ class RiaApplication : public QApplication static std::vector readFileListFromTextFile(QString listFileName); - void clearViewsScheduledForUpdate(); private: @@ -224,29 +219,19 @@ class RiaApplication : public QApplication void regressionTestConfigureProject(); static QSize regressionDefaultImageSize(); + friend RiaArgumentParser; void setHelpText(const QString& helpText); private slots: void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - void slotUpdateScheduledDisplayModels(); - void slotRecalculateCompletionType(); - // Friend classes required to have access to slotUpdateScheduledDisplayModels - // As snapshots are produced fast in sequence, the feature must have access to force redraw - // of scheduled redraws - friend class Rim3dView; - friend class RicExportMultipleSnapshotsFeature; - friend class RiaArgumentParser; + private: caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; - std::vector > m_resViewsToUpdate; - QTimer* m_resViewUpdateTimer; - std::vector > m_eclipseCasesToRecalculate; - QTimer* m_recalculateCompletionTypeTimer; RiaSocketServer* m_socketServer; diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp new file mode 100644 index 0000000000..c0a6d10800 --- /dev/null +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaCompletionTypeCalculationScheduler.h" +#include "RimEclipseCase.h" +#include "RimEclipseCaseCollection.h" +#include "RiaApplication.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include +#include +#include "QAbstractItemModel" +#include "RiuMainWindow.h" +#include "cafPdmUiTreeView.h" +#include +#include "Rim3dView.h" +#include "RiuViewer.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::instance() +{ + static RiaCompletionTypeCalculationScheduler theInstance; + + return &theInstance; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() +{ + for (RimEclipseCase* eclipseCase : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases()) + { + m_eclipseCasesToRecalculate.push_back(eclipseCase); + } + + if (!m_recalculateCompletionTypeTimer) + { + m_recalculateCompletionTypeTimer = new QTimer(this); + m_recalculateCompletionTypeTimer->setSingleShot(true); + connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); + } + + m_recalculateCompletionTypeTimer->start(1500); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) +{ + m_eclipseCasesToRecalculate.push_back(eclipseCase); + + + if (!m_recalculateCompletionTypeTimer) + { + m_recalculateCompletionTypeTimer = new QTimer(this); + m_recalculateCompletionTypeTimer->setSingleShot(true); + connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); + } + + m_recalculateCompletionTypeTimer->start(1500); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() +{ + std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); + + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); + + for (RimEclipseCase* eclipseCase : uniqueCases) + { + eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); + } + + m_eclipseCasesToRecalculate.clear(); + + // Recalculation of completion type causes active view to be set to potentially a different view + // Also current index in project tree is changed. Restore both to initial state. + + if (activeView && activeView->viewer()) + { + RiaApplication::instance()->setActiveReservoirView(activeView); + RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget()); + } + + if (mi.isValid()) + { + RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() +{ + delete m_recalculateCompletionTypeTimer; +} diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h new file mode 100644 index 0000000000..256b864c53 --- /dev/null +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include "cafPdmPointer.h" + +class QTimer; +class RimEclipseCase; + + +class RiaCompletionTypeCalculationScheduler : public QObject +{ + Q_OBJECT; +public: + static RiaCompletionTypeCalculationScheduler* instance(); + void scheduleRecalculateCompletionTypeAndRedrawAllViews(); + void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); + +private slots: + void slotRecalculateCompletionType(); + +private: + RiaCompletionTypeCalculationScheduler() : m_recalculateCompletionTypeTimer(nullptr) {} + ~RiaCompletionTypeCalculationScheduler(); + + RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; + void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; + + std::vector > m_eclipseCasesToRecalculate; + QTimer* m_recalculateCompletionTypeTimer; +}; + + diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.cpp b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp new file mode 100644 index 0000000000..4262ea9814 --- /dev/null +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaViewRedrawScheduler.h" +#include "Rim3dView.h" + +#include +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler* RiaViewRedrawScheduler::instance() +{ + static RiaViewRedrawScheduler theInstance; + + return &theInstance; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::clearViewsScheduledForUpdate() +{ + if (m_resViewUpdateTimer) + { + while (m_resViewUpdateTimer->isActive()) + { + QCoreApplication::processEvents(); + } + } + m_resViewsToUpdate.clear(); +} + + +//-------------------------------------------------------------------------------------------------- +/// Schedule a creation of the Display model and redraw of the reservoir view +/// The redraw will happen as soon as the event loop is entered +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate) +{ + m_resViewsToUpdate.push_back(resViewToUpdate); + + if (!m_resViewUpdateTimer) + { + m_resViewUpdateTimer = new QTimer(this); + connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels())); + } + + if (!m_resViewUpdateTimer->isActive()) + { + m_resViewUpdateTimer->setSingleShot(true); + m_resViewUpdateTimer->start(0); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::slotUpdateScheduledDisplayModels() +{ + // Compress to remove duplicates + // and update dependent views after independent views + + std::set independent3DViewsToUpdate; + std::set dependent3DViewsToUpdate; + + for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) + { + if (!m_resViewsToUpdate[i]) continue; + + if (m_resViewsToUpdate[i]->viewController()) + dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); + else + independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); + } + + for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) + { + if (*it) + { + (*it)->createDisplayModelAndRedraw(); + } + } + + for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) + { + if (*it) + { + (*it)->createDisplayModelAndRedraw(); + } + } + + m_resViewsToUpdate.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler::~RiaViewRedrawScheduler() +{ + delete m_resViewUpdateTimer; +} diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.h b/ApplicationCode/Application/RiaViewRedrawScheduler.h new file mode 100644 index 0000000000..52b4246b63 --- /dev/null +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include "cafPdmPointer.h" + +class QTimer; +class Rim3dView; + + +class RiaViewRedrawScheduler : public QObject +{ + Q_OBJECT; +public: + static RiaViewRedrawScheduler* instance(); + void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate); + void clearViewsScheduledForUpdate(); + +public slots: + void slotUpdateScheduledDisplayModels(); + +private: + RiaViewRedrawScheduler() : m_resViewUpdateTimer(nullptr) {} + ~RiaViewRedrawScheduler(); + + RiaViewRedrawScheduler(const RiaViewRedrawScheduler& o) = delete; + void operator=(const RiaViewRedrawScheduler& o) = delete; + + std::vector > m_resViewsToUpdate; + QTimer* m_resViewUpdateTimer; +}; + + diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp index 91098d0d63..ef6ae4eaff 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp @@ -19,6 +19,7 @@ #include "RicExportMultipleSnapshotsFeature.h" #include "RiaApplication.h" +#include "RiaViewRedrawScheduler.h" #include "RicSnapshotViewToFileFeature.h" @@ -229,7 +230,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(Rim3dView* // Force update of scheduled display models modifying the time step // This is required due to visualization structures updated by the update functions, // and this is not triggered by changing time step only - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels(); viewer->setCurrentFrame(i); viewer->animationControl()->setCurrentFrameOnly(i); diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index b1f81b4a08..6f56ebdf5e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaLogging.h" +#include "RiaViewRedrawScheduler.h" #include "RimMainPlotCollection.h" #include "RimProject.h" @@ -110,7 +111,7 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RiuViewer* viewer = riv->viewer(); mainWnd->setActiveViewer(viewer->layoutWidget()); - RiaApplication::instance()->clearViewsScheduledForUpdate(); + RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); //riv->updateCurrentTimeStepAndRedraw(); riv->createDisplayModelAndRedraw(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 75930a9963..3cffac7562 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaViewRedrawScheduler.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellRangeFilterCollection.h" @@ -317,7 +318,7 @@ QImage Rim3dView::snapshotWindowContent() if (m_viewer) { // Force update of scheduled display models before snapshotting - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels(); m_viewer->repaint(); @@ -332,7 +333,7 @@ QImage Rim3dView::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void Rim3dView::scheduleCreateDisplayModelAndRedraw() { - RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); + RiaViewRedrawScheduler::instance()->scheduleDisplayModelUpdateAndRedraw(this); if (this->isMasterView()) { RimViewLinker* viewLinker = this->assosiatedViewLinker(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 9134c8cda9..4c92412123 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -182,21 +182,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual void resetLegendsInViewer() = 0; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; - - // Overridden PdmObject methods: - - virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } - virtual void setupBeforeSave() override; - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - - // Overridden ViewWindow methods: - - virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; - virtual void updateViewWidgetAfterCreation() override; - virtual void updateMdiWindowTitle() override; - virtual void deleteViewWidget() override; - virtual QWidget* viewWidget() override; protected: // Fields caf::PdmField m_currentTimeStep; @@ -219,6 +204,23 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface private: RimViewLinker* viewLinkerIfMasterView() const; + // Overridden PdmObject methods: + + virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } + virtual void setupBeforeSave() override; +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + // Overridden ViewWindow methods: + + virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; + virtual void updateViewWidgetAfterCreation() override; + virtual void updateMdiWindowTitle() override; + virtual void deleteViewWidget() override; + virtual QWidget* viewWidget() override; + // Implementation of RiuViewerToViewInterface virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();} diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 34cedabbc3..5f3418a677 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -80,6 +80,7 @@ #include #include +#include "RiaCompletionTypeCalculationScheduler.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); @@ -788,7 +789,7 @@ bool RimProject::showPlotWindow() const void RimProject::reloadCompletionTypeResultsInAllViews() { createDisplayModelAndRedrawAllViews(); - RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(); } //-------------------------------------------------------------------------------------------------- @@ -955,7 +956,7 @@ void RimProject::reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclip views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); } - RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase); } //-------------------------------------------------------------------------------------------------- From 0bba60f22ffb401e459cbb49c4370e735c2ed412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Jan 2018 11:47:58 +0100 Subject: [PATCH 0046/1027] Remove RimView.cpp due to some git strangeness --- ApplicationCode/ProjectDataModel/RimView.cpp | 1093 ------------------ 1 file changed, 1093 deletions(-) delete mode 100644 ApplicationCode/ProjectDataModel/RimView.cpp diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp deleted file mode 100644 index 00df6206a9..0000000000 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ /dev/null @@ -1,1093 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2015- Statoil ASA -// Copyright (C) 2015- Ceetron Solutions AS -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RimView.h" - -#include "RiaApplication.h" -#include "RiaPreferences.h" - -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellRangeFilterCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimGridCollection.h" -#include "RimIntersectionCollection.h" -#include "RimMainPlotCollection.h" -#include "RimOilField.h" -#include "RimProject.h" -#include "RimPropertyFilterCollection.h" -#include "RimViewController.h" -#include "RimViewLinker.h" -#include "RimViewLinkerCollection.h" -#include "RimWellPathCollection.h" - -#include "RiuMainWindow.h" -#include "RiuViewer.h" -#include "RiuTimeStepChangedHandler.h" - -#include "cafDisplayCoordTransform.h" -#include "cafFrameAnimationControl.h" -#include "cafPdmObjectFactory.h" - -#include "cvfCamera.h" -#include "cvfModel.h" -#include "cvfModelBasicList.h" -#include "cvfPart.h" -#include "cvfScene.h" -#include "cvfViewport.h" - -#include - -#include -#include "cvfTransform.h" - - -namespace caf { - -template<> -void caf::AppEnum< RimView::MeshModeType >::setUp() -{ - addItem(RimView::FULL_MESH, "FULL_MESH", "All"); - addItem(RimView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); - addItem(RimView::NO_MESH, "NO_MESH", "None"); - setDefault(RimView::FULL_MESH); -} - -template<> -void caf::AppEnum< RimView::SurfaceModeType >::setUp() -{ - addItem(RimView::SURFACE, "SURFACE", "All"); - addItem(RimView::FAULTS, "FAULTS", "Faults only"); - addItem(RimView::NO_SURFACE, "NO_SURFACE", "None"); - setDefault(RimView::SURFACE); -} - -} // End namespace caf - - -CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimView, "GenericView"); // Do not use. Abstract class - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimView::RimView(void) -{ - RiaApplication* app = RiaApplication::instance(); - RiaPreferences* preferences = app->preferences(); - CVF_ASSERT(preferences); - - - CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - - CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); - cameraPosition.uiCapability()->setUiHidden(true); - - CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); - cameraPointOfInterest.uiCapability()->setUiHidden(true); - - CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", ""); - - double defaultScaleFactor = preferences->defaultScaleFactorZ; - CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); - - cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); - - CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); - maximumFrameRate.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", ""); - hasUserRequestedAnimation.uiCapability()->setUiHidden(true); - - CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); - m_currentTimeStep.uiCapability()->setUiHidden(true); - - CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); - m_overlayInfoConfig->setReservoirView(this); - m_overlayInfoConfig.uiCapability()->setUiHidden(true); - - caf::AppEnum defaultMeshType = NO_MESH; - if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; - CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); - CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", ""); - - CAF_PDM_InitField(&showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); - - CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); - - - CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); - m_rangeFilterCollection.uiCapability()->setUiHidden(true); - m_rangeFilterCollection = new RimCellRangeFilterCollection(); - - CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); - m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); - m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); - m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - - CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); - crossSectionCollection.uiCapability()->setUiHidden(true); - crossSectionCollection = new RimIntersectionCollection(); - - CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); - m_gridCollection.uiCapability()->setUiHidden(true); - m_gridCollection = new RimGridCollection(); - - m_previousGridModeMeshLinesWasFaults = false; - - m_crossSectionVizModel = new cvf::ModelBasicList; - m_crossSectionVizModel->setName("CrossSectionModel"); - - m_highlightVizModel = new cvf::ModelBasicList; - m_highlightVizModel->setName("HighlightModel"); - - m_wellPathPipeVizModel = new cvf::ModelBasicList; - m_wellPathPipeVizModel->setName("WellPathPipeModel"); - - this->setAs3DViewMdiWindow(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimView::~RimView(void) -{ - RimProject* proj = RiaApplication::instance()->project(); - - if (proj && this->isMasterView()) - { - delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = NULL; - - proj->uiCapability()->updateConnectedEditors(); - } - - RimViewController* vController = this->viewController(); - if (proj && vController) - { - vController->setManagedView(NULL); - vController->ownerViewLinker()->removeViewController(vController); - delete vController; - - proj->uiCapability()->updateConnectedEditors(); - } - - delete this->m_overlayInfoConfig(); - - removeMdiWindowFromMdiArea(); - - deleteViewWidget(); - - delete m_rangeFilterCollection; - delete m_overrideRangeFilterCollection; - delete crossSectionCollection; - delete m_gridCollection; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuViewer* RimView::viewer() -{ - return m_viewer; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QWidget* RimView::createViewWidget(QWidget* mainWindowParent) -{ - QGLFormat glFormat; - glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - - m_viewer = new RiuViewer(glFormat, NULL); - m_viewer->setOwnerReservoirView(this); - - return m_viewer->layoutWidget(); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::updateViewWidgetAfterCreation() -{ - m_viewer->setDefaultPerspectiveNearPlaneDistance(10); - - this->resetLegendsInViewer(); - - m_viewer->updateNavigationPolicy(); - m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); - - m_viewer->mainCamera()->setViewMatrix(cameraPosition); - m_viewer->setPointOfInterest(cameraPointOfInterest()); - m_viewer->enableParallelProjection(!isPerspectiveView()); - - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - - this->updateGridBoxData(); - this->updateAnnotationItems(); - this->createHighlightAndGridBoxDisplayModel(); - - m_viewer->update(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::updateMdiWindowTitle() -{ - if (m_viewer) - { - QString windowTitle; - if (ownerCase()) - { - windowTitle = QString("%1 - %2").arg(ownerCase()->caseUserDescription()).arg(name); - } - else - { - windowTitle = name; - } - - m_viewer->layoutWidget()->setWindowTitle(windowTitle); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::deleteViewWidget() -{ - if (m_viewer) - { - m_viewer->deleteLater(); - m_viewer = nullptr; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); - viewGroup->add(&name); - viewGroup->add(&backgroundColor); - viewGroup->add(&showGridBox); - viewGroup->add(&isPerspectiveView); - viewGroup->add(&m_disableLighting); - - caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Grid Appearance"); - gridGroup->add(&scaleZ); - gridGroup->add(&meshMode); - gridGroup->add(&surfaceMode); - - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QImage RimView::snapshotWindowContent() -{ - if (m_viewer) - { - // Force update of scheduled display models before snapshotting - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); - - m_viewer->repaint(); - - return m_viewer->snapshotImage(); - } - - return QImage(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::scheduleCreateDisplayModelAndRedraw() -{ - RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); - if (this->isMasterView()) - { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setCurrentTimeStepAndUpdate(int frameIndex) -{ - setCurrentTimeStep(frameIndex); - - this->updateCurrentTimeStep(); - - RimProject* project; - firstAncestorOrThisOfTypeAsserted(project); - project->mainPlotCollection()->updateCurrentTimeStepInPlots(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setCurrentTimeStep(int frameIndex) -{ - const int oldTimeStep = m_currentTimeStep; - - m_currentTimeStep = frameIndex; - clampCurrentTimestep(); - - if (m_currentTimeStep != oldTimeStep) - { - RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); - } - - this->hasUserRequestedAnimation = true; - if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) - { - m_currentReservoirCellVisibility = NULL; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::updateCurrentTimeStepAndRedraw() -{ - this->updateCurrentTimeStep(); - - RimProject* project; - firstAncestorOrThisOfTypeAsserted(project); - project->mainPlotCollection()->updateCurrentTimeStepInPlots(); - - if (m_viewer) m_viewer->update(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::createDisplayModelAndRedraw() -{ - if (m_viewer) - { - this->clampCurrentTimestep(); - - createDisplayModel(); - createHighlightAndGridBoxDisplayModel(); - updateDisplayModelVisibility(); - - if (cameraPosition().isIdentity()) - { - setDefaultView(); - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); - } - } - - RiuMainWindow::instance()->refreshAnimationActions(); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setDefaultView() -{ - if (m_viewer) - { - m_viewer->setDefaultView(); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::endAnimation() -{ - this->hasUserRequestedAnimation = false; - this->updateStaticCellColors(); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPathCollection* RimView::wellPathCollection() -{ - RimProject* proj = nullptr; - this->firstAncestorOrThisOfTypeAsserted(proj); - CVF_ASSERT(proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()); - - return proj->activeOilField()->wellPathCollection(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setupBeforeSave() -{ - if (m_viewer) - { - hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -// Surf: No Fault Surf -// Mesh ------------- -// No F F G -// Fault F F G -// Mesh G G G -// -//-------------------------------------------------------------------------------------------------- -bool RimView::isGridVisualizationMode() const -{ - return ( this->surfaceMode() == SURFACE - || this->meshMode() == FULL_MESH); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setMeshOnlyDrawstyle() -{ - if (isGridVisualizationMode()) - { - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - - surfaceMode.setValueWithFieldChanged(NO_SURFACE); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setMeshSurfDrawstyle() -{ - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setFaultMeshSurfDrawstyle() -{ - // Surf: No Fault Surf - // Mesh ------------- - // No FF FF SF - // Fault FF FF SF - // Mesh SF SF SF - if (this->isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - - meshMode.setValueWithFieldChanged(FAULTS_MESH); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setSurfOnlyDrawstyle() -{ - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - - meshMode.setValueWithFieldChanged(NO_MESH); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::showGridCells(bool enableGridCells) -{ - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } - - m_gridCollection->isActive = enableGridCells; - m_gridCollection->updateConnectedEditors(); - m_gridCollection->updateUiIconFromState(enableGridCells); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setSurfaceDrawstyle() -{ - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::disableLighting(bool disable) -{ - m_disableLighting = disable; - updateCurrentTimeStepAndRedraw(); - updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimView::isLightingDisabled() const -{ - return m_disableLighting(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); - - if (changedField == &meshMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &isPerspectiveView) - { - if (m_viewer) m_viewer->enableParallelProjection(!isPerspectiveView()); - } - else if (changedField == &scaleZ) - { - if (scaleZ < 1) scaleZ = 1; - - this->updateGridBoxData(); - - // Regenerate well paths - RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - - crossSectionCollection->updateIntersectionBoxGeometry(); - - if (m_viewer) - { - cvf::Vec3d poi = m_viewer->pointOfInterest(); - cvf::Vec3d eye, dir, up; - eye = m_viewer->mainCamera()->position(); - dir = m_viewer->mainCamera()->direction(); - up = m_viewer->mainCamera()->up(); - - eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]); - poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2); - - m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); - m_viewer->setPointOfInterest(poi); - - updateScaleTransform(); - createDisplayModelAndRedraw(); - - m_viewer->update(); - - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateScaleZ(this, scaleZ); - viewLinker->updateCamera(this); - } - } - - RiuMainWindow::instance()->updateScaleValue(); - } - else if (changedField == &surfaceMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &showGridBox) - { - createHighlightAndGridBoxDisplayModelWithRedraw(); - } - else if (changedField == &m_disableLighting) - { - createDisplayModel(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &name) - { - updateMdiWindowTitle(); - - if (viewController()) - { - viewController()->updateDisplayNameAndIcon(); - viewController()->updateConnectedEditors(); - } - else - { - if (isMasterView()) - { - assosiatedViewLinker()->updateUiNameAndIcon(); - assosiatedViewLinker()->updateConnectedEditors(); - } - } - } - else if (changedField == &m_currentTimeStep) - { - if (m_viewer) - { - m_viewer->update(); - - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateTimeStep(this, m_currentTimeStep); - } - } - } - else if (changedField == &backgroundColor) - { - if (m_viewer != nullptr) - { - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - } - updateGridBoxData(); - updateAnnotationItems(); - } - else if (changedField == &maximumFrameRate) - { - // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? - // !! Should be able to specify legal range for number properties - if (m_viewer) - { - m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, - const cvf::BoundingBox& wellPathClipBoundingBox) -{ - if (!this->ownerCase()) return; - - cvf::ref transForm = displayCoordTransform(); - - wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); - - wellPathModelBasicList->updateBoundingBoxesRecursive(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) -{ - if (!this->ownerCase()) return; - - cvf::ref transForm = displayCoordTransform(); - - QDateTime currentTimeStamp; - std::vector timeStamps = ownerCase()->timeStepDates(); - if (currentTimeStep() < static_cast(timeStamps.size())) - { - currentTimeStamp = timeStamps[currentTimeStep()]; - } - - wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, - currentTimeStamp, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); - - wellPathModelBasicList->updateBoundingBoxesRecursive(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimCellRangeFilterCollection* RimView::rangeFilterCollection() -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RimCellRangeFilterCollection* RimView::rangeFilterCollection() const -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) -{ - if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); - - m_overrideRangeFilterCollection = rfc; - this->scheduleGeometryRegen(RANGE_FILTERED); - this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); - - this->scheduleCreateDisplayModelAndRedraw(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setScaleZAndUpdate(double scaleZ) -{ - this->scaleZ = scaleZ; - updateScaleTransform(); - - this->updateGridBoxData(); - - this->scheduleCreateDisplayModelAndRedraw(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewController* RimView::viewController() const -{ - RimViewController* viewController = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewController = dynamic_cast(reffingObjs[i]); - if (viewController) break; - } - - return viewController; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* RimView::viewLinkerIfMasterView() const -{ - RimViewLinker* viewLinker = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewLinker = dynamic_cast(reffingObjs[i]); - if (viewLinker) break; - } - - return viewLinker; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* RimView::assosiatedViewLinker() const -{ - RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); - if (!viewLinker) - { - RimViewController* viewController = this->viewController(); - if (viewController) - { - viewLinker = viewController->ownerViewLinker(); - } - } - - return viewLinker; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RimView::currentTotalCellVisibility() -{ - if (m_currentReservoirCellVisibility.isNull()) - { - m_currentReservoirCellVisibility = new cvf::UByteArray; - this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); - } - - return m_currentReservoirCellVisibility; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimView::isMasterView() const -{ - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker && this == viewLinker->masterView()) - { - return true; - } - - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimView::hasOverridenRangeFilterCollection() -{ - return m_overrideRangeFilterCollection() != NULL; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::replaceRangeFilterCollectionWithOverride() -{ - RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; - CVF_ASSERT(overrideRfc); - - RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; - if (currentRfc) - { - delete currentRfc; - } - - // Must call removeChildObject() to make sure the object has no parent - // No parent is required when assigning a object into a field - m_overrideRangeFilterCollection.removeChildObject(overrideRfc); - - m_rangeFilterCollection = overrideRfc; - - this->uiCapability()->updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) -{ - std::vector modelsToBeRemoved; - for (cvf::uint i = 0; i < scene->modelCount(); i++) - { - if (scene->model(i)->name() == modelName) - { - modelsToBeRemoved.push_back(scene->model(i)); - } - } - - for (size_t i = 0; i < modelsToBeRemoved.size(); i++) - { - scene->removeModel(modelsToBeRemoved[i]); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::updateGridBoxData() -{ - if (m_viewer) - { - m_viewer->updateGridBoxData(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::updateAnnotationItems() -{ - if (m_viewer) - { - m_viewer->updateAnnotationItems(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dOverlayInfoConfig* RimView::overlayInfoConfig() const -{ - return m_overlayInfoConfig; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::createHighlightAndGridBoxDisplayModelWithRedraw() -{ - createHighlightAndGridBoxDisplayModel(); - - if (m_viewer) - { - m_viewer->update(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::createHighlightAndGridBoxDisplayModel() -{ - m_viewer->removeStaticModel(m_highlightVizModel.p()); - m_viewer->removeStaticModel(m_viewer->gridBoxModel()); - - m_highlightVizModel->removeAllParts(); - - cvf::Collection parts; - createPartCollectionFromSelection(&parts); - if (parts.size() > 0) - { - for (size_t i = 0; i < parts.size(); i++) - { - m_highlightVizModel->addPart(parts[i].p()); - } - - m_highlightVizModel->updateBoundingBoxesRecursive(); - m_viewer->addStaticModelOnce(m_highlightVizModel.p()); - } - - if (showGridBox) - { - m_viewer->addStaticModelOnce(m_viewer->gridBoxModel()); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimView::showActiveCellsOnly() -{ - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::selectOverlayInfoConfig() -{ - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::zoomAll() -{ - if (m_viewer) - { - m_viewer->zoomAll(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RimView::displayCoordTransform() const -{ - cvf::ref coordTrans = new caf::DisplayCoordTransform; - - cvf::Vec3d scale(1.0, 1.0, scaleZ); - coordTrans->setScale(scale); - - RimCase* rimCase = ownerCase(); - if (rimCase) - { - coordTrans->setTranslation(rimCase->displayModelOffset()); - } - - return coordTrans; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QWidget* RimView::viewWidget() -{ - if ( m_viewer ) return m_viewer->layoutWidget(); - else return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::forceShowWindowOn() -{ - m_showWindow.setValueWithFieldChanged(true); -} - From fe17d0edd4e7ead6885f503241cb3d723f503fb3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 12:08:08 +0100 Subject: [PATCH 0047/1027] Remove unused function --- .../ProjectDataModel/Completions/RimFracture.cpp | 8 -------- .../ProjectDataModel/Completions/RimFracture.h | 1 - 2 files changed, 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index a2f63158a4..6ba8c1571f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -167,14 +167,6 @@ double RimFracture::perforationEfficiency() const return m_perforationEfficiency(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimFracture::stimPlanTimeIndexToPlot() const -{ - return m_stimPlanTimeIndexToPlot(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index ef870afd5e..94a5bbfb35 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -58,7 +58,6 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf double perforationLength() const; double perforationEfficiency() const; - int stimPlanTimeIndexToPlot() const; void setStimPlanTimeIndexToPlot(int timeIndex); double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; From 6aa2d9958767a3eb31e22fe29527f97b2427c990 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 11:00:46 +0100 Subject: [PATCH 0048/1027] #2349 Elm Props: Only add files which are not already added --- .../ProjectDataModel/RimGeoMechCase.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index ec6c3a141f..89ff2bc2fd 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -332,16 +332,32 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) { - for (const QString& fileName : fileNames) + std::vector newFileNames; + + for (const QString& newFileNameToPossiblyAdd : fileNames) { - m_elementPropertyFileNames.v().push_back(fileName); + bool fileAlreadyAdded = false; + + for (const QString& existingFileName : m_elementPropertyFileNames.v()) + { + if (existingFileName == newFileNameToPossiblyAdd) + { + fileAlreadyAdded = true; + break; + } + } + if (!fileAlreadyAdded) + { + newFileNames.push_back(newFileNameToPossiblyAdd); + m_elementPropertyFileNames.v().push_back(newFileNameToPossiblyAdd); + } } this->updateConnectedEditors(); if (m_geoMechCaseData.notNull()) { - geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); + geoMechData()->femPartResults()->addElementPropertyFiles(newFileNames); } } From b08e382daecae17cc435c8a1fc03025d4755aa67 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 11:21:59 +0100 Subject: [PATCH 0049/1027] #2360 Elm Props: Use correct index to id map --- .../RifElementPropertyReader.cpp | 102 ++++++++++++++++-- .../FileInterface/RifElementPropertyReader.h | 11 +- .../GeoMech/GeoMechDataModel/RigFemPart.h | 1 + .../GeoMechDataModel/RigGeoMechCaseData.cpp | 3 +- 4 files changed, 106 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 31954b93a5..bcfddc8668 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -20,12 +20,15 @@ #include "cvfAssert.h" +#include + +#include #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifElementPropertyReader::RifElementPropertyReader() {} +RifElementPropertyReader::RifElementPropertyReader(const std::vector& elementIdxToId) : m_elementIdxToId(elementIdxToId) {} //-------------------------------------------------------------------------------------------------- /// @@ -40,7 +43,7 @@ void RifElementPropertyReader::addFile(const std::string& fileName) RifElementPropertyMetadata metaData = RifElementPropertyTableReader::readMetadata(QString::fromStdString(fileName)); for (QString field : metaData.dataColumns) { - m_fields[field.toStdString()] = metaData; + m_fieldsMetaData[field.toStdString()] = metaData; } } @@ -51,7 +54,8 @@ std::map> RifElementPropertyReader::scalar { std::map> fields; - for (std::map::iterator field = m_fields.begin(); field != m_fields.end(); field++) + for (std::map::iterator field = m_fieldsMetaData.begin(); + field != m_fieldsMetaData.end(); field++) { fields[field->first]; } @@ -66,16 +70,100 @@ std::map> RifElementPropertyReader::readAllElementPropertiesInFileContainingField(const std::string& fieldName) { RifElementPropertyTable table; - RifElementPropertyTableReader::readData(&m_fields[fieldName], &table); + RifElementPropertyTableReader::readData(&m_fieldsMetaData[fieldName], &table); + + CVF_ASSERT(m_fieldsMetaData[fieldName].dataColumns.size() == table.data.size()); - CVF_ASSERT(m_fields[fieldName].dataColumns.size() == table.data.size()); + for (size_t i = 0; i < table.data.size(); i++) + { + CVF_ASSERT(table.data[i].size() == table.elementIds.size()); + } std::map> fieldAndData; - for (size_t i = 0; i < table.data.size(); i++) + const std::vector& elementIdsFromFile = table.elementIds; + + if (elementIdsFromFile == m_elementIdxToId) + { + for (size_t i = 0; i < table.data.size(); i++) + { + const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); + fieldAndData[currentFieldFromFile] = table.data[i]; + } + } + else if (elementIdsFromFile.size() > m_elementIdxToId.size()) { - fieldAndData[m_fields[fieldName].dataColumns[i].toStdString()].swap(table.data[i]); + RifElementPropertyReader::outputWarningAboutWrongFileData(); + return fieldAndData; + } + else + { + if (m_elementIdToIdx.size() == 0) + { + makeElementIdToIdxMap(); + } + + std::vector fileIdxToElementIdx; + fileIdxToElementIdx.reserve(elementIdsFromFile.size()); + + for (size_t i = 0; i < elementIdsFromFile.size(); i++) + { + std::unordered_map::const_iterator it = m_elementIdToIdx.find(elementIdsFromFile[i]); + if (it == m_elementIdToIdx.end()) + { + RifElementPropertyReader::outputWarningAboutWrongFileData(); + return fieldAndData; + } + + fileIdxToElementIdx.push_back(it->second); + } + + for (size_t i = 0; i < table.data.size(); i++) + { + std::string currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); + + const std::vector& currentColumn = table.data[i]; + + std::vector tempResult(m_elementIdToIdx.size(), HUGE_VAL); + + for (size_t j = 0; j < currentColumn.size(); j++) + { + tempResult[fileIdxToElementIdx[j]] = currentColumn[j]; + } + + fieldAndData[currentFieldFromFile].swap(tempResult); + } } return fieldAndData; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::makeElementIdToIdxMap() +{ + m_elementIdToIdx.reserve(m_elementIdxToId.size()); + + for (size_t i = 0; i < m_elementIdxToId.size(); i++) + { + m_elementIdToIdx[m_elementIdxToId[i]] = (int)i; + } + + std::vector tempVectorForDeletion; + m_elementIdxToId.swap(tempVectorForDeletion); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::outputWarningAboutWrongFileData() +{ + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + QString warningText; + warningText = QString("The chosen result property does not fit the model"); + msgBox.setText(warningText); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); +} diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h index 3a84471f52..1f6e4d627c 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -26,6 +26,7 @@ #include #include +#include #include //================================================================================================== @@ -35,7 +36,7 @@ class RifElementPropertyReader : public cvf::Object { public: - RifElementPropertyReader(); + RifElementPropertyReader(const std::vector& elementIdxToId); virtual ~RifElementPropertyReader(); void addFile(const std::string& fileName); @@ -45,5 +46,11 @@ class RifElementPropertyReader : public cvf::Object std::map> readAllElementPropertiesInFileContainingField(const std::string& fieldName); private: - std::map m_fields; + void makeElementIdToIdxMap(); + static void outputWarningAboutWrongFileData(); + +private: + std::map m_fieldsMetaData; + std::vector m_elementIdxToId; + std::unordered_map m_elementIdToIdx; }; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h index 5c856f5e45..09ae8d8dc6 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -85,6 +85,7 @@ class RigFemPart : public cvf::Object cvf::Vec3f faceNormal(int elmentIndex, int faceIndex) const; const RigFemPartGrid* structGrid() const; + const std::vector& elementIdxToId() const { return m_elementId; } private: int m_elementPartId; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index c40b469430..a354b73ad0 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -97,8 +97,6 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) m_readerInterface = new RifOdbReader; #endif - m_elementPropertyReader = new RifElementPropertyReader; - if (m_readerInterface.notNull() && m_readerInterface->openFile(m_geoMechCaseFileName, errorMessage)) { m_femParts = new RigFemPartCollection(); @@ -110,6 +108,7 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) progress.incrementProgress(); progress.setProgressDescription("Calculating element neighbors"); + m_elementPropertyReader = new RifElementPropertyReader(m_femParts->part(0)->elementIdxToId()); // Initialize results containers m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_elementPropertyReader.p(), m_femParts.p()); From 27f7f07ffd7fae156d4609111f53ad27ddfe6b72 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 12:43:36 +0100 Subject: [PATCH 0050/1027] Replace auto --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 0bababf189..06a21a9400 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -173,7 +173,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in std::map> elementProperties = m_elementPropertyReader->readAllElementPropertiesInFileContainingField(resVarAddr.fieldName); std::vector resultsForEachComponent; - for (auto elem : elementProperties) + for (std::pair< std::string, std::vector> elem : elementProperties) { RigFemResultAddress addressForElement(RIG_ELEMENT, elem.first, ""); RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult(addressForElement); From efaaab1dc6974aa5c2f1ff53acb8c0b8a89360b8 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 14:08:11 +0100 Subject: [PATCH 0051/1027] #2360 Elm Props: Make sure either elementIdxToId or elementIdToIdx is larger than elementIdsFromFile --- ApplicationCode/FileInterface/RifElementPropertyReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index bcfddc8668..6f95c24966 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -91,7 +91,7 @@ std::map> fieldAndData[currentFieldFromFile] = table.data[i]; } } - else if (elementIdsFromFile.size() > m_elementIdxToId.size()) + else if (elementIdsFromFile.size() > m_elementIdxToId.size() && elementIdsFromFile.size() > m_elementIdToIdx.size()) { RifElementPropertyReader::outputWarningAboutWrongFileData(); return fieldAndData; From a97dd087d62f45fc587c4fd73fcc01125a494eae Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 14:39:15 +0100 Subject: [PATCH 0052/1027] #2349 Elm Props: Use caf::FilePath instead of QString --- .../RicImportElementPropertyFeature.cpp | 6 +-- .../ProjectDataModel/RimGeoMechCase.cpp | 41 +++++++++++++++---- .../ProjectDataModel/RimGeoMechCase.h | 19 +++++---- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp index 1c1c59bbc4..72bda624e3 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -55,10 +55,10 @@ void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) defaultDir = QFileInfo(fileNames.last()).absolutePath(); } - std::vector fileNamesStd; + std::vector filePaths; for (QString filename : fileNames) { - fileNamesStd.push_back(filename); + filePaths.push_back(caf::FilePath(filename)); } app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir); @@ -71,7 +71,7 @@ void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) if (activeGmv->geoMechCase()) { - activeGmv->geoMechCase()->addElementPropertyFiles(fileNamesStd); + activeGmv->geoMechCase()->addElementPropertyFiles(filePaths); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 89ff2bc2fd..efd2f81319 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -61,6 +61,9 @@ RimGeoMechCase::RimGeoMechCase(void) CAF_PDM_InitField(&m_frictionAngleDeg, "FrctionAngleDeg", 30.0, "Friction Angle [Deg]", "", "Used to calculate the SE:SFI result", ""); CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNameUiSelection, "ElementPropertyFileNameSelection", "", "", "", ""); + m_elementPropertyFileNameUiSelection.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- @@ -172,7 +175,12 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) if (m_geoMechCaseData.notNull()) { - geoMechData()->femPartResults()->addElementPropertyFiles(m_elementPropertyFileNames); + std::vector fileNames; + for (const caf::FilePath& fileName : m_elementPropertyFileNames.v()) + { + fileNames.push_back(fileName.path()); + } + geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); } return fileOpenSuccess; @@ -189,9 +197,9 @@ void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPat // Update filename and folder paths when opening project from a different file location m_caseFileName = RimTools::relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); - for (QString& fileName : m_elementPropertyFileNames.v()) + for (caf::FilePath& fileName : m_elementPropertyFileNames.v()) { - fileName = RimTools::relocateFile(fileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + fileName = RimTools::relocateFile(fileName.path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); } #if 0 // Output the search path for debugging @@ -330,15 +338,15 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) +void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) { std::vector newFileNames; - for (const QString& newFileNameToPossiblyAdd : fileNames) + for (const caf::FilePath& newFileNameToPossiblyAdd : fileNames) { bool fileAlreadyAdded = false; - for (const QString& existingFileName : m_elementPropertyFileNames.v()) + for (const caf::FilePath& existingFileName : m_elementPropertyFileNames()) { if (existingFileName == newFileNameToPossiblyAdd) { @@ -348,7 +356,7 @@ void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNam } if (!fileAlreadyAdded) { - newFileNames.push_back(newFileNameToPossiblyAdd); + newFileNames.push_back(newFileNameToPossiblyAdd.path()); m_elementPropertyFileNames.v().push_back(newFileNameToPossiblyAdd); } } @@ -521,6 +529,23 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caseGroup->add(&m_frictionAngleDeg); caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties"); - elmPropGroup->add(&m_elementPropertyFileNames); + elmPropGroup->add(&m_elementPropertyFileNameUiSelection); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_elementPropertyFileNameUiSelection) + { + for (const caf::FilePath& fileName : m_elementPropertyFileNames.v()) + { + options.push_back(caf::PdmOptionItemInfo(fileName.path(), fileName.path() , true, QIcon())); + } + } + + return options; +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 278cd32bf5..b5eb24a002 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -21,6 +21,7 @@ #include "RimCase.h" +#include "cafFilePath.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -69,7 +70,7 @@ class RimGeoMechCase : public RimCase virtual void setFormationNames(RimFormationNames* formationNames) override; - void addElementPropertyFiles(const std::vector& filenames); + void addElementPropertyFiles(const std::vector& filenames); // Fields: caf::PdmChildArrayField geoMechViews; @@ -80,16 +81,20 @@ class RimGeoMechCase : public RimCase virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void updateFormationNamesData() override; - virtual void initAfterRead(); + virtual void initAfterRead() override; static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind); private: - cvf::ref m_geoMechCaseData; - caf::PdmField m_caseFileName; - caf::PdmField m_cohesion; - caf::PdmField m_frictionAngleDeg; - caf::PdmField > m_elementPropertyFileNames; + cvf::ref m_geoMechCaseData; + caf::PdmField m_caseFileName; + caf::PdmField m_cohesion; + caf::PdmField m_frictionAngleDeg; + caf::PdmField> m_elementPropertyFileNames; + caf::PdmField > m_elementPropertyFileNameUiSelection; + caf::PdmField m_closeElementPropertyFileCommand; + caf::PdmField m_reloadElementPropertyFileCommand; }; From ff03820a198172d5d191280191293fb7cda0481e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 12:40:45 +0100 Subject: [PATCH 0053/1027] #2152 Minor refactoring --- .../ModelVisualization/RivWellFracturePartMgr.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 0132d44d24..22b48cd0dd 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -93,7 +93,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc displayCoords.push_back(static_cast(displayCoordsDouble)); } - if (triangleIndices.size() == 0 || displayCoords.size() == 0) + if (triangleIndices.empty() || displayCoords.empty()) { return nullptr; } @@ -135,9 +135,9 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE std::vector triangleIndices; m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords); - if (triangleIndices.size() == 0 || nodeCoords.size() == 0) + if (triangleIndices.empty() || nodeCoords.empty()) { - return NULL; + return nullptr; } // Transforms the node coordinates for display @@ -198,7 +198,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE } } - if (triIndicesToInclude.size() == 0) + if (triIndicesToInclude.empty()) { return nullptr; } @@ -437,14 +437,14 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri { const RigFractureCell& stimPlanCell = stimPlanCells[cIdx]; std::vector stimPlanCellPolygon = stimPlanCell.getPolygon(); - for (cvf::Vec3d cellCorner : stimPlanCellPolygon) + for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon) { stimPlanMeshVertices.push_back(static_cast(cellCorner)); } } } - if (stimPlanMeshVertices.size() == 0) + if (stimPlanMeshVertices.empty()) { return nullptr; } From 5e3bc0e5eece973faec5c1bf19da23dbdfa43ed1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 13:20:54 +0100 Subject: [PATCH 0054/1027] #2152 Fracture : Add color interpolation mode --- .../Completions/RimFracture.cpp | 27 +++++++++++++++++++ .../Completions/RimFracture.h | 12 +++++++++ .../Completions/RimSimWellFracture.cpp | 1 + .../Completions/RimWellPathFracture.cpp | 1 + 4 files changed, 41 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 6ba8c1571f..aaecbe8b58 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -70,6 +70,19 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimFracture, "Fracture"); +namespace caf { + +template<> +void caf::AppEnum< RimFracture::StimPlanResultColorType >::setUp() +{ + addItem(RimFracture::INTERPOLATED, "INTERPOLATED", "Interpolated"); + addItem(RimFracture::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Single Element Cell"); + + setDefault(RimFracture::INTERPOLATED); +} + +} // End namespace caf + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -141,6 +154,8 @@ RimFracture::RimFracture(void) m_wellFractureAzimuthAngleWarning.uiCapability()->setUiReadOnly(true); m_wellFractureAzimuthAngleWarning.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "StimPlan Visualization mode", "", "", ""); + m_fracturePartMgr = new RivWellFracturePartMgr(this); } @@ -175,6 +190,14 @@ void RimFracture::setStimPlanTimeIndexToPlot(int timeIndex) m_stimPlanTimeIndexToPlot = timeIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFracture::StimPlanResultColorType RimFracture::stimPlanResultColorType() const +{ + return m_stimPlanCellVizMode(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -204,6 +227,7 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons if (changedField == &m_azimuth || changedField == &m_fractureTemplate || changedField == &m_stimPlanTimeIndexToPlot || + changedField == &m_stimPlanCellVizMode || changedField == this->objectToggleField() || changedField == &m_dip || changedField == &m_tilt) @@ -495,11 +519,14 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO if (dynamic_cast(fracTemplate)) { m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); + m_stimPlanCellVizMode.uiCapability()->setUiHidden(false); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); } else { m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); + m_stimPlanCellVizMode.uiCapability()->setUiHidden(true); } } else diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 94a5bbfb35..2b04753137 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -43,6 +43,7 @@ class RimFractureTemplate; class RigFracturedEclipseCellExportData; class RigMainGrid; + //================================================================================================== /// /// @@ -51,6 +52,13 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf { CAF_PDM_HEADER_INIT; +public: + enum StimPlanResultColorType + { + INTERPOLATED, + SINGLE_ELEMENT_COLOR + }; + public: RimFracture(void); virtual ~RimFracture(void); @@ -59,6 +67,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf double perforationEfficiency() const; void setStimPlanTimeIndexToPlot(int timeIndex); + StimPlanResultColorType stimPlanResultColorType() const; double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; cvf::Vec3d anchorPosition() const ; @@ -123,7 +132,10 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf caf::PdmField m_wellDiameter; caf::PdmField m_stimPlanTimeIndexToPlot; + caf::PdmField> m_stimPlanCellVizMode; + private: caf::PdmField m_anchorPosition; + cvf::ref m_fracturePartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index 1877babb38..8d9a5c5781 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -212,6 +212,7 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi propertyGroup->add(&m_fractureUnit); propertyGroup->add(&m_fractureTemplate); propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_stimPlanCellVizMode); propertyGroup->add(&m_perforationLength); propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index d532fe0b91..ca8b51ebff 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -177,6 +177,7 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder propertyGroup->add(&m_fractureUnit); propertyGroup->add(&m_fractureTemplate); propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_stimPlanCellVizMode); propertyGroup->add(&m_perforationLength); propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); From bf1b755dc8873278ff8ea0abe86fc0e0162b2d06 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 14:55:59 +0100 Subject: [PATCH 0055/1027] #2361 AppFwk : Improve robustness of load and save of FilePath --- .../cafInternalPdmFilePathStreamOperators.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp index b4dc732802..a634a0b57a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -7,9 +7,25 @@ //-------------------------------------------------------------------------------------------------- QTextStream& operator<<(QTextStream& str, const std::vector& filePathObjects) { + QStringList trimmedEntries; + for (const auto& filePath : filePathObjects) { - str << filePath << ";"; + QString text = filePath.path().trimmed(); + + if (text.isEmpty()) continue; + + trimmedEntries.push_back(text); + } + + for (const auto& s : trimmedEntries) + { + str << s; + + if (s != trimmedEntries.back()) + { + str << ";"; + } } return str; @@ -28,13 +44,20 @@ QTextStream& operator>>(QTextStream& str, std::vector& filePathOb QChar singleChar; str >> singleChar; - stringSeparatedBySemicolon += singleChar; + if (!singleChar.isNull()) + { + stringSeparatedBySemicolon += singleChar; + } } QStringList splitBySemicolon = stringSeparatedBySemicolon.split(";"); - for (const auto& s : splitBySemicolon ) + for (const auto& s : splitBySemicolon) { - filePathObjects.push_back(s); + QString trimmed = s.trimmed(); + if (!trimmed.isEmpty()) + { + filePathObjects.push_back(trimmed); + } } return str; From 3b46849c7980894bc35cd5e9c7e72627d8e3ef48 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 16:14:30 +0100 Subject: [PATCH 0056/1027] Fix warning --- .../Intersections/RivIntersectionPartMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index c2c5276573..5d7b017840 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -306,12 +306,12 @@ void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2 { cvf::Vec2f* rawPtr = textureCoords->ptr(); - for (int triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++) + for (size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++) { size_t resIdx = triangleToCellIdx[triangleIdx]; float resValue = resultValues[resIdx]; - int triangleVxIdx = triangleIdx * 3; + size_t triangleVxIdx = triangleIdx * 3; if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's { From 27901f426ca802dea6f7a080f062966eb7c12034 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 12 Jan 2018 16:18:54 +0100 Subject: [PATCH 0057/1027] #2369 Elm Props: Close selected files --- .../RifElementPropertyReader.cpp | 18 +++++ .../FileInterface/RifElementPropertyReader.h | 1 + .../RigFemPartResultsCollection.cpp | 11 ++++ .../RigFemPartResultsCollection.h | 3 +- .../ProjectDataModel/RimGeoMechCase.cpp | 65 +++++++++++++++++-- .../ProjectDataModel/RimGeoMechCase.h | 4 +- 6 files changed, 94 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 6f95c24966..769720af32 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -47,6 +47,24 @@ void RifElementPropertyReader::addFile(const std::string& fileName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::removeFile(const std::string& fileName) +{ + std::map tempMetaData; + + for (std::pair metaData : m_fieldsMetaData) + { + if (metaData.second.fileName.toStdString() != fileName) + { + tempMetaData[metaData.first] = metaData.second; + } + } + + m_fieldsMetaData.swap(tempMetaData); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h index 1f6e4d627c..7b38602236 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -40,6 +40,7 @@ class RifElementPropertyReader : public cvf::Object virtual ~RifElementPropertyReader(); void addFile(const std::string& fileName); + void removeFile(const std::string& fileName); std::map> scalarElementFields(); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 06a21a9400..f7ad11e115 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -132,6 +132,17 @@ void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) +{ + for (const QString filename : filenames) + { + m_elementPropertyReader->removeFile(filename.toStdString()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 1489413cfb..0c47068f70 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -52,7 +52,8 @@ class RigFemPartResultsCollection: public cvf::Object void setActiveFormationNames(RigFormationNames* activeFormationNames); RigFormationNames* activeFormationNames(); - void addElementPropertyFiles(const std::vector& filename); + void addElementPropertyFiles(const std::vector& filenames); + void removeElementPropertyFiles(const std::vector& filenames); void setCalculationParameters(double cohesion, double frictionAngleRad); double parameterCohesion() const { return m_cohesion;} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index efd2f81319..8921a5993e 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -40,9 +40,11 @@ #include "RimGeoMechResultDefinition.h" #include "RimGeoMechPropertyFilter.h" +#include "cafPdmUiPushButtonEditor.h" #include "cafUtils.h" #include +#include CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase"); //-------------------------------------------------------------------------------------------------- @@ -62,8 +64,14 @@ RimGeoMechCase::RimGeoMechCase(void) CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNameUiSelection, "ElementPropertyFileNameSelection", "", "", "", ""); - m_elementPropertyFileNameUiSelection.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNameIndexUiSelection, "ElementPropertyFileNameIndexUiSelection", "", "", "", ""); + m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_closeElementPropertyFileCommand); + + CAF_PDM_InitField(&m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_reloadElementPropertyFileCommand); } //-------------------------------------------------------------------------------------------------- @@ -422,6 +430,12 @@ void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } } } + else if (changedField == &m_closeElementPropertyFileCommand) + { + m_closeElementPropertyFileCommand = false; + closeSelectedElementPropertyFiles(); + updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -514,6 +528,33 @@ QString RimGeoMechCase::subStringOfDigits(const QString& inputString, int number return ""; } +struct descendingComparator +{ + template + bool operator()(T const &a, T const &b) const { return a > b; } +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::closeSelectedElementPropertyFiles() +{ + std::sort(m_elementPropertyFileNameIndexUiSelection.v().begin(), m_elementPropertyFileNameIndexUiSelection.v().end(), descendingComparator()); + + std::vector filesToClose; + + for (size_t idx : m_elementPropertyFileNameIndexUiSelection.v()) + { + filesToClose.push_back(m_elementPropertyFileNames.v().at(idx).path()); + m_elementPropertyFileNames.v().erase(m_elementPropertyFileNames.v().begin() + idx); + } + m_elementPropertyFileNameIndexUiSelection.v().clear(); + + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); + } +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -529,7 +570,19 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caseGroup->add(&m_frictionAngleDeg); caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties"); - elmPropGroup->add(&m_elementPropertyFileNameUiSelection); + elmPropGroup->add(&m_elementPropertyFileNameIndexUiSelection); + elmPropGroup->add(&m_closeElementPropertyFileCommand); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_closeElementPropertyFileCommand) + { + dynamic_cast (attribute)->m_buttonText = "Close Case(s)"; + } } //-------------------------------------------------------------------------------------------------- @@ -539,11 +592,11 @@ QList RimGeoMechCase::calculateValueOptions(const caf::P { QList options; - if (fieldNeedingOptions == &m_elementPropertyFileNameUiSelection) + if (fieldNeedingOptions == &m_elementPropertyFileNameIndexUiSelection) { - for (const caf::FilePath& fileName : m_elementPropertyFileNames.v()) + for (size_t i = 0; i < m_elementPropertyFileNames.v().size(); i++) { - options.push_back(caf::PdmOptionItemInfo(fileName.path(), fileName.path() , true, QIcon())); + options.push_back(caf::PdmOptionItemInfo(m_elementPropertyFileNames.v().at(i).path(), (int)i, true, QIcon())); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index b5eb24a002..16536252f8 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -81,6 +81,7 @@ class RimGeoMechCase : public RimCase virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void updateFormationNamesData() override; @@ -88,13 +89,14 @@ class RimGeoMechCase : public RimCase virtual void initAfterRead() override; static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind); + void closeSelectedElementPropertyFiles(); private: cvf::ref m_geoMechCaseData; caf::PdmField m_caseFileName; caf::PdmField m_cohesion; caf::PdmField m_frictionAngleDeg; caf::PdmField> m_elementPropertyFileNames; - caf::PdmField > m_elementPropertyFileNameUiSelection; + caf::PdmField > m_elementPropertyFileNameIndexUiSelection; caf::PdmField m_closeElementPropertyFileCommand; caf::PdmField m_reloadElementPropertyFileCommand; }; From a8039b856955bbcbc2a3123dfed2a3e03c0909cb Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Sat, 13 Jan 2018 12:38:08 +0100 Subject: [PATCH 0058/1027] #2369 Elm Props: Remove deleted field results from cache --- .../RifElementPropertyReader.cpp | 35 +++++++++++++++---- .../FileInterface/RifElementPropertyReader.h | 4 ++- .../RigFemPartResultsCollection.cpp | 14 ++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 769720af32..0188b2de38 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -48,7 +48,7 @@ void RifElementPropertyReader::addFile(const std::string& fileName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RifElementPropertyReader::removeFile(const std::string& fileName) { @@ -61,18 +61,18 @@ void RifElementPropertyReader::removeFile(const std::string& fileName) tempMetaData[metaData.first] = metaData.second; } } - + m_fieldsMetaData.swap(tempMetaData); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map> RifElementPropertyReader::scalarElementFields() +std::map> RifElementPropertyReader::scalarElementFields() const { std::map> fields; - for (std::map::iterator field = m_fieldsMetaData.begin(); + for (std::map::const_iterator field = m_fieldsMetaData.begin(); field != m_fieldsMetaData.end(); field++) { fields[field->first]; @@ -105,8 +105,8 @@ std::map> { for (size_t i = 0; i < table.data.size(); i++) { - const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); - fieldAndData[currentFieldFromFile] = table.data[i]; + const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); + fieldAndData[currentFieldFromFile] = table.data[i]; } } else if (elementIdsFromFile.size() > m_elementIdxToId.size() && elementIdsFromFile.size() > m_elementIdToIdx.size()) @@ -156,6 +156,27 @@ std::map> return fieldAndData; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifElementPropertyReader::fieldsInFile(const std::string& fileName) const +{ + std::vector fields; + + for (std::pair metaData : m_fieldsMetaData) + { + if (metaData.second.fileName.toStdString() == fileName) + { + for (const QString& column : metaData.second.dataColumns) + { + fields.push_back(column.toStdString()); + } + } + } + + return fields; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -173,7 +194,7 @@ void RifElementPropertyReader::makeElementIdToIdxMap() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RifElementPropertyReader::outputWarningAboutWrongFileData() { diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h index 7b38602236..2620ef96e4 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -42,10 +42,12 @@ class RifElementPropertyReader : public cvf::Object void addFile(const std::string& fileName); void removeFile(const std::string& fileName); - std::map> scalarElementFields(); + std::map> scalarElementFields() const; std::map> readAllElementPropertiesInFileContainingField(const std::string& fieldName); + std::vector fieldsInFile(const std::string& fileName) const; + private: void makeElementIdToIdxMap(); static void outputWarningAboutWrongFileData(); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index f7ad11e115..8e848ef113 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -137,10 +137,24 @@ void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) { + std::vector addressesToRemove; + for (const QString filename : filenames) { + std::vector fields = m_elementPropertyReader->fieldsInFile(filename.toStdString()); + + for (std::string field : fields) + { + addressesToRemove.push_back(RigFemResultAddress(RIG_ELEMENT, field, "")); + } + m_elementPropertyReader->removeFile(filename.toStdString()); } + + for (const RigFemResultAddress& address : addressesToRemove) + { + this->deleteResult(address); + } } //-------------------------------------------------------------------------------------------------- From 673ad12dee0a5616c49489b2993d4d8d5bed6258 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Sun, 14 Jan 2018 09:10:23 +0100 Subject: [PATCH 0059/1027] #2370 Elm Props: Reload selected files. Prop filters etc not updated --- .../ProjectDataModel/RimGeoMechCase.cpp | 39 +++++++++++++++++++ .../ProjectDataModel/RimGeoMechCase.h | 2 + 2 files changed, 41 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 8921a5993e..42254b1b78 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -430,6 +430,12 @@ void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } } } + else if (changedField == &m_reloadElementPropertyFileCommand) + { + m_reloadElementPropertyFileCommand = false; + reloadSelectedElementPropertyFiles(); + updateConnectedEditors(); + } else if (changedField == &m_closeElementPropertyFileCommand) { m_closeElementPropertyFileCommand = false; @@ -548,6 +554,7 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() filesToClose.push_back(m_elementPropertyFileNames.v().at(idx).path()); m_elementPropertyFileNames.v().erase(m_elementPropertyFileNames.v().begin() + idx); } + m_elementPropertyFileNameIndexUiSelection.v().clear(); if (m_geoMechCaseData.notNull()) @@ -555,6 +562,33 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::reloadSelectedElementPropertyFiles() +{ + std::vector filesToReload; + + for (size_t idx : m_elementPropertyFileNameIndexUiSelection.v()) + { + filesToReload.push_back(m_elementPropertyFileNames.v().at(idx).path()); + } + + m_elementPropertyFileNameIndexUiSelection.v().clear(); + + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->removeElementPropertyFiles(filesToReload); + geoMechData()->femPartResults()->addElementPropertyFiles(filesToReload); + } + + for (auto view : views()) + { + view->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -571,6 +605,7 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties"); elmPropGroup->add(&m_elementPropertyFileNameIndexUiSelection); + elmPropGroup->add(&m_reloadElementPropertyFileCommand); elmPropGroup->add(&m_closeElementPropertyFileCommand); } @@ -579,6 +614,10 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { + if (field == &m_reloadElementPropertyFileCommand) + { + dynamic_cast (attribute)->m_buttonText = "Reload Case(s)"; + } if (field == &m_closeElementPropertyFileCommand) { dynamic_cast (attribute)->m_buttonText = "Close Case(s)"; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 16536252f8..9de12c93d2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -90,6 +90,8 @@ class RimGeoMechCase : public RimCase static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind); void closeSelectedElementPropertyFiles(); + void reloadSelectedElementPropertyFiles(); + private: cvf::ref m_geoMechCaseData; caf::PdmField m_caseFileName; From 47e154bf533caaf01e62a0969fad5c01c795f20a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 15 Jan 2018 08:52:00 +0100 Subject: [PATCH 0060/1027] #2370 Elm props: Update prop filters + intersections on reload --- ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 42254b1b78..3a88a52077 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -582,10 +582,10 @@ void RimGeoMechCase::reloadSelectedElementPropertyFiles() geoMechData()->femPartResults()->removeElementPropertyFiles(filesToReload); geoMechData()->femPartResults()->addElementPropertyFiles(filesToReload); } - - for (auto view : views()) + + for (RimGeoMechView* view : geoMechViews()) { - view->scheduleCreateDisplayModelAndRedraw(); + view->loadDataAndUpdate(); } } From e5aaf73a84b2ea2edc53f19833c8ae829e1a91d1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jan 2018 17:21:28 +0100 Subject: [PATCH 0061/1027] #2152 Fracture : Add StimPlan cell element color --- .../RivWellFracturePartMgr.cpp | 157 ++++++++++++++++-- .../RivWellFracturePartMgr.h | 7 +- 2 files changed, 151 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 22b48cd0dd..c4cfa4593e 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -120,7 +120,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimEclipseView& activeView) +cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView) { CVF_ASSERT(m_rimFracture); RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); @@ -203,14 +203,12 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE return nullptr; } - cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeCoords); cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); surfacePart->setDrawable(geo.p()); surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper(); CVF_ASSERT(scalarMapper); cvf::ref textureCoords = new cvf::Vec2fArray(nodeCoords.size()); @@ -225,7 +223,6 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE } geo->setTextureCoordArray(textureCoords.p()); - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); effGen.disableLighting(activeView.isLightingDisabled()); cvf::ref eff = effGen.generateCachedEffect(); @@ -233,26 +230,155 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE return surfacePart; } - - // No result is mapped, show the entire StimPlan surface with default color else { - cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords); + // No result is mapped, show the entire StimPlan surface with default color + + return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.stimPlanColors->defaultColor()); + } + + return nullptr; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createSingleColorSurfacePart(const std::vector& triangleIndices, const std::vector& nodeCoords, const cvf::Color3f& color) +{ + cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords); + + cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); + surfacePart->setDrawable(geo.p()); + surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); + surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); + + cvf::Color4f fractureColor = cvf::Color4f(color); + caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); + surfacePart->setEffect(eff.p()); + + return surfacePart; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePart(const RimEclipseView& activeView) +{ + CVF_ASSERT(m_rimFracture); + RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + CVF_ASSERT(stimPlanFracTemplate); + + auto displayCoordTransform = activeView.displayCoordTransform(); + if (displayCoordTransform.isNull()) return nullptr; + + std::vector stimPlanMeshVertices; + cvf::ref textureCoords = new cvf::Vec2fArray; + const cvf::ScalarMapper* scalarMapper = nullptr; + + { + std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); + + RimLegendConfig* legendConfig = nullptr; + if (activeView.stimPlanColors() && + activeView.stimPlanColors()->isChecked() && + activeView.stimPlanColors()->activeLegend()) + { + legendConfig = activeView.stimPlanColors()->activeLegend(); + + scalarMapper = legendConfig->scalarMapper(); + + QString resultNameFromColors = activeView.stimPlanColors->resultName(); + QString resultUnitFromColors = activeView.stimPlanColors->unit(); + + std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, + resultUnitFromColors, + stimPlanFracTemplate->activeTimeStepIndex()); + + textureCoords->reserve(prCellResults.size() * 4); + + for (size_t cIdx = 0; cIdx < stimPlanCells.size(); ++cIdx) + { + if (prCellResults[cIdx] > 1e-7) + { + const RigFractureCell& stimPlanCell = stimPlanCells[cIdx]; + std::vector stimPlanCellPolygon = stimPlanCell.getPolygon(); + for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon) + { + stimPlanMeshVertices.push_back(static_cast(cellCorner)); + textureCoords->add(scalarMapper->mapToTextureCoord(prCellResults[cIdx])); + } + } + } + textureCoords->squeeze(); + } + else + { + for (const auto& stimPlanCell : stimPlanCells) + { + for (const auto& cellCorner : stimPlanCell.getPolygon()) + { + stimPlanMeshVertices.push_back(static_cast(cellCorner)); + } + } + } + } + + if (stimPlanMeshVertices.empty()) + { + return nullptr; + } + + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = + transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform); + + std::vector triIndicesToInclude; + + size_t cellCount = stimPlanMeshVertices.size() / 4; + for (cvf::uint i = 0; i < cellCount; i++) + { + triIndicesToInclude.push_back(i * 4 + 0); + triIndicesToInclude.push_back(i * 4 + 1); + triIndicesToInclude.push_back(i * 4 + 2); + + triIndicesToInclude.push_back(i * 4 + 0); + triIndicesToInclude.push_back(i * 4 + 2); + triIndicesToInclude.push_back(i * 4 + 3); + } + + // Show selected result on the surface geometry and filter out triangles that have result values near 0 + if (scalarMapper) + { + if (triIndicesToInclude.empty()) + { + return nullptr; + } + + cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); surfacePart->setDrawable(geo.p()); surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor()); - caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); - cvf::ref eff = surfaceGen.generateCachedEffect(); + geo->setTextureCoordArray(textureCoords.p()); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + effGen.disableLighting(activeView.isLightingDisabled()); + cvf::ref eff = effGen.generateCachedEffect(); surfacePart->setEffect(eff.p()); return surfacePart; } -} + else + { + // No result is mapped, show the entire StimPlan surface with default color + return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.stimPlanColors->defaultColor()); + } +} //-------------------------------------------------------------------------------------------------- /// @@ -525,7 +651,14 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod // StimPlan if (stimPlanFracTemplate) { - surfacePart = createStimPlanSurfacePart(eclView); + if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) + { + surfacePart = createStimPlanElementColorSurfacePart(eclView); + } + else + { + surfacePart = createStimPlanColorInterpolatedSurfacePart(eclView); + } if (stimPlanFracTemplate->showStimPlanMesh()) { diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 7a0805400d..36f1b9250b 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -32,6 +32,7 @@ namespace cvf class ModelBasicList; class DrawableGeo; class Part; + class Color3f; } namespace caf @@ -58,7 +59,11 @@ class RivWellFracturePartMgr : public cvf::Object private: cvf::ref createEllipseSurfacePart(const RimEclipseView& activeView); - cvf::ref createStimPlanSurfacePart(const RimEclipseView& activeView); + cvf::ref createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView); + + cvf::ref createSingleColorSurfacePart(const std::vector& triangleIndices, const std::vector& nodeCoords, const cvf::Color3f& color); + + cvf::ref createStimPlanElementColorSurfacePart(const RimEclipseView& activeView); cvf::ref createContainmentMaskPart(const RimEclipseView& activeView); From 9820cb45e403445dae3034fd1b174463e875fff7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jan 2018 08:58:15 +0100 Subject: [PATCH 0062/1027] #2371 Fracture Template : Avoid crash when StimPlan xml fails to load --- .../RimStimPlanFractureTemplate.cpp | 62 ++++++++++++++----- .../Completions/RimStimPlanFractureTemplate.h | 2 +- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index c3f13df795..c5273163e9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -191,6 +191,8 @@ void RimStimPlanFractureTemplate::updateFilePathsFromProjectPath(const QString& //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() { + if (m_stimPlanFractureDefinitionData.isNull()) return; + setDepthOfWellPathAtFracture(); RiaLogging::info(QString("Setting well/fracture intersection depth at %1").arg(m_wellPathDepthAtFracture)); m_activeTimeStepIndex = static_cast(m_stimPlanFractureDefinitionData->totalNumberTimeSteps() - 1); @@ -332,10 +334,14 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RimStimPlanFractureTemplate::timeSteps() +std::vector RimStimPlanFractureTemplate::timeSteps() { - if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate(); - return m_stimPlanFractureDefinitionData->timeSteps(); + if (m_stimPlanFractureDefinitionData.notNull()) + { + return m_stimPlanFractureDefinitionData->timeSteps(); + } + + return std::vector(); } //-------------------------------------------------------------------------------------------------- @@ -367,7 +373,12 @@ void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const //-------------------------------------------------------------------------------------------------- std::vector> RimStimPlanFractureTemplate::resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const { - return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex); + if (m_stimPlanFractureDefinitionData.notNull()) + { + return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex); + } + + return std::vector>(); } //-------------------------------------------------------------------------------------------------- @@ -375,7 +386,12 @@ std::vector> RimStimPlanFractureTemplate::resultValues(const //-------------------------------------------------------------------------------------------------- std::vector RimStimPlanFractureTemplate::fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const { - return m_stimPlanFractureDefinitionData->fractureGridResults(resultName, unitName, timeStepIndex); + if (m_stimPlanFractureDefinitionData.notNull()) + { + return m_stimPlanFractureDefinitionData->fractureGridResults(resultName, unitName, timeStepIndex); + } + + return std::vector(); } //-------------------------------------------------------------------------------------------------- @@ -405,9 +421,14 @@ const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::updateFractureGrid() { - m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_activeTimeStepIndex, - fractureTemplateUnit, - m_wellPathDepthAtFracture); + m_fractureGrid = nullptr; + + if (m_stimPlanFractureDefinitionData.notNull()) + { + m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_activeTimeStepIndex, + fractureTemplateUnit, + m_wellPathDepthAtFracture); + } } @@ -425,12 +446,14 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vectorcreateFractureTriangleGeometry(m_wellPathDepthAtFracture, - neededUnit, - name, - nodeCoords, - triangleIndices); - return; + if (m_stimPlanFractureDefinitionData.notNull()) + { + m_stimPlanFractureDefinitionData->createFractureTriangleGeometry(m_wellPathDepthAtFracture, + neededUnit, + name, + nodeCoords, + triangleIndices); + } } //-------------------------------------------------------------------------------------------------- @@ -442,12 +465,17 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEc QString parameterName = m_borderPolygonResultName; QString parameterUnit = getUnitForStimPlanParameter(parameterName); - return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName, - parameterUnit, - m_activeTimeStepIndex, + if (m_stimPlanFractureDefinitionData.notNull()) + { + return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName, + parameterUnit, + m_activeTimeStepIndex, m_wellPathDepthAtFracture, neededUnit, name); + } + + return std::vector(); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 52f1e5fc1b..a300481797 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -76,7 +76,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate // Result Access - const std::vector& timeSteps(); + std::vector timeSteps(); std::vector > resultNamesWithUnit() const; void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; std::vector> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; From 85ead20ec97c3b47ce479d347cd25e3a9bb9ca66 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jan 2018 08:58:51 +0100 Subject: [PATCH 0063/1027] #2371 Fracture : Guard for null pointer access --- .../RicExportFractureCompletionsImpl.cpp | 31 +++++++++++-------- .../RivWellFracturePartMgr.cpp | 3 ++ .../RimCompletionCellIntersectionCalc.cpp | 1 + 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index 1e83b0201a..da0e0c9152 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -145,8 +145,10 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat if (!fracTemplate) continue; - bool useFiniteConductivityInFracture = (fracTemplate->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY); const RigFractureGrid* fractureGrid = fracTemplate->fractureGrid(); + if (!fractureGrid) continue; + + bool useFiniteConductivityInFracture = (fracTemplate->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY); //If finite cond chosen and conductivity not present in stimplan file, do not calculate trans for this fracture if (useFiniteConductivityInFracture) @@ -278,21 +280,24 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat || fracture->fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { const RigFractureGrid* fracGrid = fracture->fractureTemplate()->fractureGrid(); - std::pair wellCellIJ = fracGrid->fractureCellAtWellCenter(); - size_t wellCellIndex = fracGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); + if (fracGrid) + { + std::pair wellCellIJ = fracGrid->fractureCellAtWellCenter(); + size_t wellCellIndex = fracGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); - const RigFractureCell& wellCell = fractureGrid->cellFromIndex(wellCellIndex); + const RigFractureCell& wellCell = fractureGrid->cellFromIndex(wellCellIndex); - double radialTrans = RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(wellCell.getConductivtyValue(), - wellCell.cellSizeX(), - wellCell.cellSizeZ(), - fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()), - fracTemplate->skinFactor(), - cDarcyInCorrectUnit); + double radialTrans = RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(wellCell.getConductivtyValue(), + wellCell.cellSizeX(), + wellCell.cellSizeZ(), + fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()), + fracTemplate->skinFactor(), + cDarcyInCorrectUnit); - transCondenser.addNeighborTransmissibility({ true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }, - { false, RigTransmissibilityCondenser::CellAddress::STIMPLAN, wellCellIndex }, - radialTrans); + transCondenser.addNeighborTransmissibility({ true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }, + { false, RigTransmissibilityCondenser::CellAddress::STIMPLAN, wellCellIndex }, + radialTrans); + } } else if (fracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index c4cfa4593e..a9481aeb82 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -270,6 +270,8 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); CVF_ASSERT(stimPlanFracTemplate); + if (!stimPlanFracTemplate->fractureGrid()) return nullptr; + auto displayCoordTransform = activeView.displayCoordTransform(); if (displayCoordTransform.isNull()) return nullptr; @@ -543,6 +545,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri //Should probably be moved, since it now is called twice in some cases... stimPlanFracTemplate->updateFractureGrid(); + if (!stimPlanFracTemplate->fractureGrid()) return nullptr; auto displayCoordTransform = activeView.displayCoordTransform(); if (displayCoordTransform.isNull()) return nullptr; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 9874da25c7..fc3c3162bd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -182,6 +182,7 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values) { if (!fracture->fractureTemplate()) return; + if (!fracture->fractureTemplate()->fractureGrid()) return; for (const RigFractureCell& fractureCell : fracture->fractureTemplate()->fractureGrid()->fractureCells()) { From b2e0f3df31074193ca8df6c00b27b4719c2fe48c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jan 2018 09:16:44 +0100 Subject: [PATCH 0064/1027] #2371 Fracture : Update views after change of stimplan xml file name --- .../Completions/RimStimPlanFractureTemplate.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index c5273163e9..687ead1cdf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -120,18 +120,18 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch } } + if (&m_conductivityScalingFactor == changedField) + { + loadDataAndUpdate(); + } if (&m_wellPathDepthAtFracture == changedField || &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField || &m_showStimPlanMesh == changedField - || &m_conductivityScalingFactor == changedField) + || &m_conductivityScalingFactor == changedField + || &m_stimPlanFileName == changedField) { - if (&m_conductivityScalingFactor == changedField) - { - loadDataAndUpdate(); - } - RimProject* proj; this->firstAncestorOrThisOfType(proj); if (proj) From ee50b0492dde057ec421ae23e9bfd249005d2e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 15 Jan 2018 09:23:20 +0100 Subject: [PATCH 0065/1027] #2151 fractures. Turn on/off fractures in views by toggling fracture colors --- ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index a9481aeb82..0d421067c4 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -641,7 +641,7 @@ std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector< //-------------------------------------------------------------------------------------------------- void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) { - if (!m_rimFracture->isChecked()) return; + if (!m_rimFracture->isChecked() || !eclView.stimPlanColors->isChecked()) return; cvf::ref surfacePart; cvf::ref stimPlanMeshPart; From 523c623d39de5c2c1cf203c5881d62d5ac7ceda8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jan 2018 09:41:00 +0100 Subject: [PATCH 0066/1027] #2152 Fracture : Rename UI text --- .../ProjectDataModel/Completions/RimFracture.cpp | 8 ++++---- .../ProjectDataModel/Completions/RimFracture.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index aaecbe8b58..8a05d4b072 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -75,10 +75,10 @@ namespace caf { template<> void caf::AppEnum< RimFracture::StimPlanResultColorType >::setUp() { - addItem(RimFracture::INTERPOLATED, "INTERPOLATED", "Interpolated"); - addItem(RimFracture::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Single Element Cell"); + addItem(RimFracture::COLOR_INTERPOLATION, "COLOR_INTERPOLATION", "On"); + addItem(RimFracture::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Off"); - setDefault(RimFracture::INTERPOLATED); + setDefault(RimFracture::COLOR_INTERPOLATION); } } // End namespace caf @@ -154,7 +154,7 @@ RimFracture::RimFracture(void) m_wellFractureAzimuthAngleWarning.uiCapability()->setUiReadOnly(true); m_wellFractureAzimuthAngleWarning.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "StimPlan Visualization mode", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "StimPlan Color Interpolation", "", "", ""); m_fracturePartMgr = new RivWellFracturePartMgr(this); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 2b04753137..0c4dea0a60 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -55,7 +55,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf public: enum StimPlanResultColorType { - INTERPOLATED, + COLOR_INTERPOLATION, SINGLE_ELEMENT_COLOR }; From ac59050824ba8bbbfe61ee52529cc8d7b3b68bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 15 Jan 2018 13:32:13 +0100 Subject: [PATCH 0067/1027] #2358 Ellipse fracture template. Extracted conductivity method --- .../RimEllipseFractureTemplate.cpp | 31 ++++++++++++------- .../Completions/RimEllipseFractureTemplate.h | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index e1448244c1..d69d25729a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -218,17 +218,7 @@ void RimEllipseFractureTemplate::setupFractureGridCells() cellPolygon.push_back(cvf::Vec3d(X2, Y2, 0.0)); cellPolygon.push_back(cvf::Vec3d(X1, Y2, 0.0)); - double cond = cvf::UNDEFINED_DOUBLE; - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - //Conductivity should be md-m, width is in m - cond = m_permeability * m_width; - } - else if(fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - //Conductivity should be md-ft, but width is in inches - cond = m_permeability * RiaEclipseUnitTools::inchToFeet(m_width); - } + double cond = conductivity(); std::vector ellipseFracPolygon = fractureBorderPolygon(fractureTemplateUnit()); std::vector ellipseFracPolygonDouble; @@ -298,6 +288,25 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() this->setDefaultWellDiameterFromUnit(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimEllipseFractureTemplate::conductivity() const +{ + double cond = cvf::UNDEFINED_DOUBLE; + if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + //Conductivity should be md-m, width is in m + cond = m_permeability * m_width; + } + else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + //Conductivity should be md-ft, but width is in inches + cond = m_permeability * RiaEclipseUnitTools::inchToFeet(m_width); + } + return cond; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 47ebcc2cb9..ff698a9e60 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -57,6 +57,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate const RigFractureGrid* fractureGrid() const; void setDefaultValuesFromUnit(); + double conductivity() const; protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); From 277bd496f11fb9cf771d1376fa7ad510de91d122 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 15 Jan 2018 10:12:14 +0100 Subject: [PATCH 0068/1027] Add override keyword --- ApplicationCode/ProjectDataModel/RimGeoMechCase.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 9de12c93d2..3bf3614760 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -57,14 +57,14 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); - virtual std::vector views(); + virtual std::vector views() override; virtual std::vector timeStepDates() const override; virtual QStringList timeStepStrings() const override; virtual QString timeStepName(int frameIdx) const override; - virtual cvf::BoundingBox activeCellsBoundingBox() const; - virtual cvf::BoundingBox allCellsBoundingBox() const; + virtual cvf::BoundingBox activeCellsBoundingBox() const override; + virtual cvf::BoundingBox allCellsBoundingBox() const override; virtual double characteristicCellSize() const override; From 4bf8de278704f17be6c7bd93f4f7149ea02cf971 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 15 Jan 2018 14:48:00 +0100 Subject: [PATCH 0069/1027] #2369 Elm props: Clear cell results on deletion --- .../Commands/RicImportElementPropertyFeature.cpp | 4 ++-- .../FileInterface/RifElementPropertyReader.cpp | 9 +++++++-- .../GeoMech/GeoMechDataModel/RigFemResultAddress.h | 7 +++++++ ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp | 11 +++++++++++ .../RimGeoMechPropertyFilterCollection.h | 10 +++++----- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp index 72bda624e3..6f33931e88 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -48,9 +48,9 @@ void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); QStringList fileNames = - QFileDialog::getOpenFileNames(NULL, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); + QFileDialog::getOpenFileNames(nullptr, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); - if (fileNames.size()) + if (!fileNames.empty()) { defaultDir = QFileInfo(fileNames.last()).absolutePath(); } diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 0188b2de38..6339aa8f0d 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -87,6 +87,13 @@ std::map> RifElementPropertyReader::scalar std::map> RifElementPropertyReader::readAllElementPropertiesInFileContainingField(const std::string& fieldName) { + std::map> fieldAndData; + + if (m_fieldsMetaData.find(fieldName) == m_fieldsMetaData.end()) + { + return fieldAndData; + } + RifElementPropertyTable table; RifElementPropertyTableReader::readData(&m_fieldsMetaData[fieldName], &table); @@ -97,8 +104,6 @@ std::map> CVF_ASSERT(table.data[i].size() == table.elementIds.size()); } - std::map> fieldAndData; - const std::vector& elementIdsFromFile = table.elementIds; if (elementIdsFromFile == m_elementIdxToId) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index bcf3a8df8e..f55e9426fd 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -29,6 +29,13 @@ class RigFemResultAddress { public: + RigFemResultAddress() + { + resultPosType = RIG_NODAL; + fieldName = ""; + componentName = ""; + } + RigFemResultAddress(RigFemResultPosEnum resPosType, const std::string& aFieldName, const std::string& aComponentName) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 3a88a52077..efd6fae769 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -561,6 +561,17 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() { geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); } + + for (RimGeoMechView* view : geoMechViews()) + { + view->cellResult()->setResultAddress(RigFemResultAddress()); + for (RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters()) + { + propertyFilter->resultDefinition().p()->setResultAddress(RigFemResultAddress()); + } + + view->loadDataAndUpdate(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h index 440f0a9d9e..d27fac7ec2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h @@ -45,14 +45,14 @@ class RimGeoMechPropertyFilterCollection : public RimPropertyFilterCollection caf::PdmChildArrayField propertyFilters; // Methods - bool hasActiveFilters() const; - bool hasActiveDynamicFilters() const; + bool hasActiveFilters() const override; + bool hasActiveDynamicFilters() const override; bool isUsingFormationNames() const; - void loadAndInitializePropertyFilters(); - void updateIconState(); + void loadAndInitializePropertyFilters() override; + void updateIconState() override; protected: // Overridden methods - virtual void initAfterRead(); + virtual void initAfterRead() override; }; From 1bbd3ade7b34e270b47b53993f50358d4a1a8d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Jan 2018 14:12:31 +0100 Subject: [PATCH 0070/1027] #2331 WIP: Creating new RimGridView base class --- .../ProjectDataModel/Rim3dView.cpp | 293 +++++++++++++++++- ApplicationCode/ProjectDataModel/Rim3dView.h | 53 ++++ .../ProjectDataModel/RimEclipseView.h | 2 +- .../ProjectDataModel/RimGeoMechView.h | 2 +- 4 files changed, 343 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 3cffac7562..645d2482c2 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -634,11 +634,6 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const if (scaleZ < 1) scaleZ = 1; this->updateGridBoxData(); - - // Regenerate well paths - RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - crossSectionCollection->updateIntersectionBoxGeometry(); if (m_viewer) @@ -1124,3 +1119,291 @@ void Rim3dView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) RimViewWindow::setMdiWindowGeometry(windowGeometry); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::RimGridView() +{ +#if 0 + CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); + m_rangeFilterCollection.uiCapability()->setUiHidden(true); + m_rangeFilterCollection = new RimCellRangeFilterCollection(); + + CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); + m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); + m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); + m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); + crossSectionCollection.uiCapability()->setUiHidden(true); + crossSectionCollection = new RimIntersectionCollection(); + + CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); + m_gridCollection.uiCapability()->setUiHidden(true); + m_gridCollection = new RimGridCollection(); + + m_previousGridModeMeshLinesWasFaults = false; + + CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); + m_overlayInfoConfig->setReservoirView(this); + m_overlayInfoConfig.uiCapability()->setUiHidden(true); +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::~RimGridView(void) +{ +#if 0 + delete this->m_overlayInfoConfig(); + + delete m_rangeFilterCollection; + delete m_overrideRangeFilterCollection; + delete crossSectionCollection; + delete m_gridCollection; + #endif +} +#if 0 + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::showGridCells(bool enableGridCells) +{ + if (!enableGridCells) + { + m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + else + { + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); + } + + m_gridCollection->isActive = enableGridCells; + m_gridCollection->updateConnectedEditors(); + m_gridCollection->updateUiIconFromState(enableGridCells); +} + +//-------------------------------------------------------------------------------------------------- +/// +// Surf: No Fault Surf +// Mesh ------------- +// No F F G +// Fault F F G +// Mesh G G G +// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::isGridVisualizationMode() const +{ + return ( this->surfaceMode() == SURFACE + || this->meshMode() == FULL_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &scaleZ) + { + crossSectionCollection->updateIntersectionBoxGeometry(); + } + + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimGridView::currentTotalCellVisibility() +{ + if (m_currentReservoirCellVisibility.isNull()) + { + m_currentReservoirCellVisibility = new cvf::UByteArray; + this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); + } + + return m_currentReservoirCellVisibility; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dView::hasOverridenRangeFilterCollection() +{ + return m_overrideRangeFilterCollection() != NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) +{ + if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); + + m_overrideRangeFilterCollection = rfc; + this->scheduleGeometryRegen(RANGE_FILTERED); + this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + this->scheduleCreateDisplayModelAndRedraw(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::replaceRangeFilterCollectionWithOverride() +{ + RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; + CVF_ASSERT(overrideRfc); + + RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; + if (currentRfc) + { + delete currentRfc; + } + + // Must call removeChildObject() to make sure the object has no parent + // No parent is required when assigning a object into a field + m_overrideRangeFilterCollection.removeChildObject(overrideRfc); + + m_rangeFilterCollection = overrideRfc; + + this->uiCapability()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewController* RimGridView::viewController() const +{ + RimViewController* viewController = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewController = dynamic_cast(reffingObjs[i]); + if (viewController) break; + } + + return viewController; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::isMasterView() const +{ + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker && this == viewLinker->masterView()) + { + return true; + } + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::assosiatedViewLinker() const +{ + RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); + if (!viewLinker) + { + RimViewController* viewController = this->viewController(); + if (viewController) + { + viewLinker = viewController->ownerViewLinker(); + } + } + + return viewLinker; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const +{ + return m_overlayInfoConfig; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::selectOverlayInfoConfig() +{ + RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +{ + std::vector modelsToBeRemoved; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == modelName) + { + modelsToBeRemoved.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + { + scene->removeModel(modelsToBeRemoved[i]); + } +} + +#endif \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 4c92412123..320463337b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -243,5 +243,58 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface }; +class RimGridView : public Rim3dView +{ + CAF_PDM_HEADER_INIT; +public: + RimGridView(); + virtual ~RimGridView(void); +#if 0 + + caf::PdmChildField crossSectionCollection; + + void showGridCells(bool enableGridCells); + bool isGridVisualizationMode() const; + + cvf::ref currentTotalCellVisibility(); + + virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; + RimCellRangeFilterCollection* rangeFilterCollection(); + const RimCellRangeFilterCollection* rangeFilterCollection() const; + + bool hasOverridenRangeFilterCollection(); + void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); + void replaceRangeFilterCollectionWithOverride(); + RimViewController* viewController() const override; + bool isMasterView() const; + RimViewLinker* assosiatedViewLinker() const override; + Rim3dOverlayInfoConfig* overlayInfoConfig() const; +protected: + static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); + + virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + + virtual void selectOverlayInfoConfig() override; + +protected: // Fields + caf::PdmChildField m_overlayInfoConfig; + + caf::PdmChildField m_rangeFilterCollection; + caf::PdmChildField m_overrideRangeFilterCollection; + + caf::PdmChildField m_gridCollection; + +protected: + cvf::ref m_currentReservoirCellVisibility; + +private: + RimViewLinker* viewLinkerIfMasterView() const; + bool m_previousGridModeMeshLinesWasFaults; + +#endif +}; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index cb423fc2df..47d3e3b5ce 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -81,7 +81,7 @@ enum PartRenderMaskEnum /// /// //================================================================================================== -class RimEclipseView : public Rim3dView +class RimEclipseView : public RimGridView { CAF_PDM_HEADER_INIT; public: diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 34f14985b5..fdb7a14835 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -51,7 +51,7 @@ namespace cvf { /// /// //================================================================================================== -class RimGeoMechView : public Rim3dView +class RimGeoMechView : public RimGridView { CAF_PDM_HEADER_INIT; From b092565a610d0c3d6fc51ce80a7d3168e4dbfeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 15 Jan 2018 14:52:22 +0100 Subject: [PATCH 0071/1027] #2331 Introduce new intermediate class RimGridView --- .../Application/RiaApplication.cpp | 11 +- ApplicationCode/Application/RiaApplication.h | 2 + .../RicAppendIntersectionFeature.cpp | 2 +- .../RicNewAzimuthDipIntersectionFeature.cpp | 2 +- .../RicNewPolylineIntersectionFeature.cpp | 2 +- .../RicNewWellPathIntersectionFeature.cpp | 2 +- .../RicEclipsePropertyFilterNewExec.cpp | 2 +- .../RicExportMultipleSnapshotsFeature.cpp | 2 +- .../RicExportMultipleSnapshotsFeature.h | 3 +- .../RicSnapshotAllViewsToFileFeature.cpp | 11 +- .../RicShowContributingWellsFeature.cpp | 2 +- .../RicAppendIntersectionBoxFeature.cpp | 2 +- .../RicIntersectionBoxAtPosFeature.cpp | 4 +- .../RicIntersectionBoxXSliceFeature.cpp | 4 +- .../RicIntersectionBoxYSliceFeature.cpp | 4 +- .../RicIntersectionBoxZSliceFeature.cpp | 4 +- .../Commands/RicGridStatisticsDialog.cpp | 6 +- .../Commands/RicGridStatisticsDialog.h | 9 +- .../RicNewSliceRangeFilterFeature.cpp | 4 +- .../Commands/RicRangeFilterFeatureImpl.cpp | 4 +- .../Commands/RicRangeFilterNewExec.cpp | 2 +- .../Commands/RicShowGridStatisticsFeature.cpp | 4 +- .../Commands/ViewLink/RicLinkViewFeature.cpp | 4 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 29 +- .../ViewLink/RicLinkVisibleViewsFeature.h | 8 +- .../ViewLink/RicLinkVisibleViewsFeatureUi.cpp | 11 +- .../ViewLink/RicLinkVisibleViewsFeatureUi.h | 13 +- .../ViewLink/RicSetMasterViewFeature.cpp | 6 +- .../ViewLink/RicShowAllLinkedViewsFeature.cpp | 2 +- .../RivFemElmVisibilityCalculator.cpp | 2 +- .../RivReservoirViewPartMgr.cpp | 2 +- .../Rim2dIntersectionView.cpp | 893 ++++++++++++++++++ .../ProjectDataModel/Rim2dIntersectionView.h | 211 +++++ .../Rim3dOverlayInfoConfig.cpp | 2 +- .../ProjectDataModel/Rim3dOverlayInfoConfig.h | 6 +- .../ProjectDataModel/Rim3dView.cpp | 433 ++------- ApplicationCode/ProjectDataModel/Rim3dView.h | 42 +- .../ProjectDataModel/RimGridCollection.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 26 +- ApplicationCode/ProjectDataModel/RimProject.h | 4 +- .../ProjectDataModel/RimViewController.cpp | 24 +- .../ProjectDataModel/RimViewController.h | 12 +- .../ProjectDataModel/RimViewLinker.cpp | 28 +- .../ProjectDataModel/RimViewLinker.h | 26 +- .../ProjectDataModel/RimViewManipulator.cpp | 4 +- .../ProjectDataModel/RimViewManipulator.h | 4 +- .../UserInterface/RiuMainWindow.cpp | 5 +- ApplicationCode/UserInterface/RiuViewer.cpp | 8 +- 48 files changed, 1387 insertions(+), 508 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 804820e5c6..2c2037ed31 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -570,7 +570,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi riv->loadDataAndUpdate(); this->setActiveReservoirView(riv); - riv->rangeFilterCollection()->updateIconState(); + RimGridView* rigv = dynamic_cast(riv); + if (rigv) rigv->rangeFilterCollection()->updateIconState(); viewProgress.incrementProgress(); } @@ -1163,6 +1164,14 @@ Rim3dView* RiaApplication::activeReservoirView() return m_activeReservoirView; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView* RiaApplication::activeGridView() +{ + return dynamic_cast( m_activeReservoirView.p()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index aeaf2cde29..04acc543f6 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -48,6 +48,7 @@ class RigEclipseCaseData; class RimCommandObject; class RimEclipseCase; class RimEclipseView; +class RimGridView; class RimProject; class RimSummaryPlot; class Rim3dView; @@ -102,6 +103,7 @@ class RiaApplication : public QApplication void setActiveReservoirView(Rim3dView*); Rim3dView* activeReservoirView(); const Rim3dView* activeReservoirView() const; + RimGridView* activeGridView(); RimViewWindow* activePlotWindow() const; diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index 01fa08d060..baf007f1ba 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -102,7 +102,7 @@ void RicAppendIntersectionFeatureCmd::redo() intersection->name = QString("Intersection"); m_intersectionCollection->appendIntersection(intersection); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; m_intersectionCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 47b405c038..6addd85669 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -61,7 +61,7 @@ bool RicNewAzimuthDipIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewAzimuthDipIntersectionFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection); diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index e403671f63..5ce3ae705b 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -60,7 +60,7 @@ bool RicNewPolylineIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewPolylineIntersectionFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection); diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index fbaef46784..14386ba0d9 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -56,7 +56,7 @@ bool RicNewWellPathIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellPathIntersectionFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; std::vector collection; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index 0730f40765..256f7c9ffc 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -58,7 +58,7 @@ void RicEclipsePropertyFilterNewExec::redo() { RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(m_propertyFilterCollection); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp index ef6ae4eaff..e4411113e3 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp @@ -207,7 +207,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariations(Rim3dView* rimView, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) +void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimGridView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) { RimCase* rimCase = rimView->ownerCase(); CVF_ASSERT(rimCase); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h index 4d5809c176..d241bd348c 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h @@ -23,6 +23,7 @@ class RimMultiSnapshotDefinition; class RimProject; class Rim3dView; +class RimGridView; //================================================================================================== /// @@ -42,7 +43,7 @@ class RicExportMultipleSnapshotsFeature : public caf::CmdFeature static void exportViewVariations(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); private: - static void exportViewVariationsToFolder(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); + static void exportViewVariationsToFolder(RimGridView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); static QString resultName(Rim3dView* rimView); }; diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 6f56ebdf5e..82acb088ac 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -124,9 +124,14 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv); // Statistics dialog - QImage img = riv->overlayInfoConfig()->statisticsDialogScreenShotImage(); - absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName + "_Statistics", ".png"); - RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, img); + + RimGridView* rigv = dynamic_cast(riv); + if ( rigv ) + { + QImage img = rigv->overlayInfoConfig()->statisticsDialogScreenShotImage(); + absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName + "_Statistics", ".png"); + RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, img); + } } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp index 091ec51298..19f30db1c7 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -94,7 +94,7 @@ void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) { modifiedView->createDisplayModelAndRedraw(); - std::vector viewsToUpdate; + std::vector viewsToUpdate; viewsToUpdate.push_back(modifiedView); RimViewManipulator::applySourceViewCameraOnDestinationViews(eclipseView, viewsToUpdate); diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index 3d234af256..0a7a89d0fb 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -63,7 +63,7 @@ void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = nullptr; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfTypeAsserted(rimView); rimView->showGridCells(false); } diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp index 4cab83feee..9237a9e492 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp @@ -50,7 +50,7 @@ bool RicIntersectionBoxAtPosFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = NULL; + RimGridView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index 3136cba9bc..a13e4c7fae 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -50,7 +50,7 @@ bool RicIntersectionBoxXSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = NULL; + RimGridView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index 6769bcbbaf..52bd2531c0 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -50,7 +50,7 @@ bool RicIntersectionBoxYSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = NULL; + RimGridView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index c256eba8ac..1cbf78f737 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -50,7 +50,7 @@ bool RicIntersectionBoxZSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -66,7 +66,7 @@ void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = NULL; + RimGridView* rimView = NULL; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp index 24c7a3838b..f290764a58 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp @@ -115,7 +115,7 @@ void RicGridStatisticsDialog::setLabel(const QString& labelText) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::updateFromRimView(Rim3dView* rimView) +void RicGridStatisticsDialog::updateFromRimView(RimGridView* rimView) { m_currentRimView = rimView; setInfoText(m_currentRimView); @@ -134,7 +134,7 @@ QImage RicGridStatisticsDialog::screenShotImage() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setInfoText(Rim3dView* view) +void RicGridStatisticsDialog::setInfoText(RimGridView* view) { Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig(); if (view && overlayInfo) @@ -151,7 +151,7 @@ void RicGridStatisticsDialog::setInfoText(Rim3dView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setHistogramData(Rim3dView* view) +void RicGridStatisticsDialog::setHistogramData(RimGridView* view) { deletePlotItems(m_historgramPlot); deletePlotItems(m_aggregatedPlot); diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.h b/ApplicationCode/Commands/RicGridStatisticsDialog.h index 2e9c701d1e..b71d369845 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.h +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.h @@ -32,6 +32,7 @@ class QwtPlotMarker; class QMainWindow; class QToolBar; class RimEclipseView; +class RimGridView; //================================================================================================== /// @@ -46,12 +47,12 @@ class RicGridStatisticsDialog : public QDialog ~RicGridStatisticsDialog(); void setLabel(const QString& labelText); - void updateFromRimView(Rim3dView* rimView); + void updateFromRimView(RimGridView* rimView); QImage screenShotImage(); private: - void setInfoText(Rim3dView* eclipseView); - void setHistogramData(Rim3dView* eclipseView); + void setInfoText(RimGridView* eclipseView); + void setHistogramData(RimGridView* eclipseView); private: void createAndConnectToolbarActions(); @@ -74,5 +75,5 @@ private slots: QwtPlot* m_aggregatedPlot; QDialogButtonBox* m_buttons; - caf::PdmPointer m_currentRimView; + caf::PdmPointer m_currentRimView; }; diff --git a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp index 64e4462145..084798ce65 100644 --- a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp +++ b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewSliceRangeFilterFeature, "RicNewSliceRangeFilterFeatur //-------------------------------------------------------------------------------------------------- bool RicNewSliceRangeFilterFeature::isCommandEnabled() { - Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); if (!view) return false; RimViewController* vc = view->viewController(); @@ -57,7 +57,7 @@ void RicNewSliceRangeFilterFeature::onActionTriggered(bool isChecked) if (!userData.isNull() && userData.type() == QVariant::List) { - Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); RimCellRangeFilterCollection* rangeFilterCollection = view->rangeFilterCollection(); RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection); diff --git a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp index de14e5a390..b2587b6a61 100644 --- a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp @@ -40,7 +40,7 @@ bool RicRangeFilterFeatureImpl::isRangeFilterCommandAvailable() RimCellRangeFilterCollection* rangeFilterCollection = findRangeFilterCollection(); if (!rangeFilterCollection) return false; - Rim3dView* view; + RimGridView* view; rangeFilterCollection->firstAncestorOrThisOfType(view); if (view) { @@ -86,7 +86,7 @@ RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollecti selectedRangeFilter[0]->firstAncestorOrThisOfType(rangeFilterCollection); } - Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); if (view) { rangeFilterCollection = view->rangeFilterCollection(); diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index 06a73ba4da..4e1e07e83c 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -77,7 +77,7 @@ void RicRangeFilterNewExec::redo() RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; m_cellRangeFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated range filter diff --git a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp index 510a83d539..64573af6aa 100644 --- a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp +++ b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp @@ -42,7 +42,7 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() { if (RicWellLogTools::isWellPathOrSimWellSelectedInView()) return false; - return RiaApplication::instance()->activeReservoirView() != nullptr; + return RiaApplication::instance()->activeGridView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -50,7 +50,7 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowGridStatisticsFeature::onActionTriggered(bool isChecked) { - Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView * activeView = RiaApplication::instance()->activeGridView(); if (activeView) { diff --git a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp index 10933c0ae5..4da5f3ca79 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp @@ -71,10 +71,10 @@ bool RicLinkViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkViewFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - std::vector views; + std::vector views; views.push_back(activeView); RicLinkVisibleViewsFeature::linkViews(views); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index a765405ca2..c48723eca0 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -47,16 +47,23 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() { RimProject* proj = RiaApplication::instance()->project(); std::vector visibleViews; - std::vector linkedviews; + std::vector linkedviews; + std::vector visibleGridViews; proj->allVisibleViews(visibleViews); + for (Rim3dView* view : visibleViews) + { + RimGridView* gridView = dynamic_cast(view); + if (gridView) visibleGridViews.push_back(gridView); + } + if (proj->viewLinkerCollection() && proj->viewLinkerCollection()->viewLinker()) { proj->viewLinkerCollection()->viewLinker()->allViews(linkedviews); } - if (visibleViews.size() >= 2 && (linkedviews.size() < visibleViews.size())) return true; + if (visibleGridViews.size() >= 2 && (linkedviews.size() < visibleGridViews.size())) return true; return false; } @@ -66,7 +73,7 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked) { - std::vector views; + std::vector views; findNotLinkedVisibleViews(views); linkViews(views); @@ -85,7 +92,7 @@ void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) +void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); if (proj->viewLinkerCollection()->viewLinker()) @@ -97,15 +104,15 @@ void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) +void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) { RimProject* proj = RiaApplication::instance()->project(); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; allLinkedViews(alreadyLinkedViews); - std::vector visibleViews; - proj->allVisibleViews(visibleViews); + std::vector visibleViews; + proj->allVisibleGridViews(visibleViews); for (size_t i = 0; i < visibleViews.size(); i++) { @@ -128,7 +135,7 @@ void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector& views) +void RicLinkVisibleViewsFeature::linkViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); RimViewLinker* viewLinker = proj->viewLinkerCollection->viewLinker(); @@ -149,7 +156,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) propertyDialog.setWindowIcon(QIcon(":/chain.png")); if (propertyDialog.exec() != QDialog::Accepted) return; - Rim3dView* masterView = featureUi.masterView(); + RimGridView* masterView = featureUi.masterView(); viewLinker = new RimViewLinker; proj->viewLinkerCollection()->viewLinker = viewLinker; viewLinker->setMasterView(masterView); @@ -157,7 +164,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) for (size_t i = 0; i < views.size(); i++) { - Rim3dView* rimView = views[i]; + RimGridView* rimView = views[i]; if (rimView == viewLinker->masterView()) continue; viewLinker->addDependentView(rimView); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h index 401442a528..255e86b837 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h @@ -23,7 +23,7 @@ #include -class Rim3dView; +class RimGridView; //================================================================================================== /// @@ -33,7 +33,7 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void linkViews(std::vector &views); + static void linkViews(std::vector &views); protected: // Overrides @@ -44,6 +44,6 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature virtual void setupActionLook(QAction* actionToSetup); private: - void findNotLinkedVisibleViews(std::vector &views); - void allLinkedViews(std::vector& views); + void findNotLinkedVisibleViews(std::vector &views); + void allLinkedViews(std::vector& views); }; diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp index 020071cd11..8d38bd3bfc 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp @@ -40,11 +40,11 @@ RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) +void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) { m_allViews = allViews; - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); // Set Active view as master view for (size_t i = 0; i < allViews.size(); i++) @@ -65,7 +65,7 @@ void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allVi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RicLinkVisibleViewsFeatureUi::masterView() +RimGridView* RicLinkVisibleViewsFeatureUi::masterView() { return m_masterView; } @@ -73,13 +73,14 @@ Rim3dView* RicLinkVisibleViewsFeatureUi::masterView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicLinkVisibleViewsFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RicLinkVisibleViewsFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly) { QList options; if (fieldNeedingOptions == &m_masterView) { - for (Rim3dView* v : m_allViews) + for (RimGridView* v : m_allViews) { RimCase* rimCase = nullptr; v->firstAncestorOrThisOfType(rimCase); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h index 082f052c3f..5ba94f305f 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h @@ -25,7 +25,7 @@ #include -class Rim3dView; +class RimGridView; //================================================================================================== /// @@ -37,14 +37,15 @@ class RicLinkVisibleViewsFeatureUi : public caf::PdmObject public: RicLinkVisibleViewsFeatureUi(void); - void setViews(const std::vector& allViews); - Rim3dView* masterView(); + void setViews(const std::vector& allViews); + RimGridView* masterView(); protected: - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly); private: - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; - std::vector m_allViews; + std::vector m_allViews; }; diff --git a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index 791dd958d6..d4ea41f61e 100644 --- a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicSetMasterViewFeature, "RicSetMasterViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicSetMasterViewFeature::isCommandEnabled() { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return false; RimProject* proj = RiaApplication::instance()->project(); @@ -62,7 +62,7 @@ bool RicSetMasterViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicSetMasterViewFeature::onActionTriggered(bool isChecked) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; RimProject* proj = RiaApplication::instance()->project(); @@ -70,7 +70,7 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked) viewLinker->applyRangeFilterCollectionByUserChoice(); - Rim3dView* previousMasterView = viewLinker->masterView(); + RimGridView* previousMasterView = viewLinker->masterView(); viewLinker->setMasterView(activeView); viewLinker->updateDependentViews(); diff --git a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index 212fe86afe..2ea4ce0366 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -58,7 +58,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked) for (size_t i = 0; i < linkedViews.size(); i++) { - std::vector views; + std::vector views; linkedViews[i]->allViews(views); for (size_t j = 0; j < views.size(); j++) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 52cc6d65dd..f53fd408b1 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -258,7 +258,7 @@ void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(cvf::UByteAr CVF_ASSERT(elmVisibilities != NULL); CVF_ASSERT(femPart != NULL); - Rim3dView* masterView = masterViewLink->ownerViewLinker()->masterView(); + RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView(); cvf::ref totCellVisibility = masterView->currentTotalCellVisibility(); int elmCount = femPart->elementCount(); diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 4c2fd99ea1..5d7d2839ef 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -604,7 +604,7 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c CVF_ASSERT(masterViewLink); - Rim3dView* masterView = masterViewLink->ownerViewLinker()->masterView(); + RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView(); // get cell visibility #if 1 diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp new file mode 100644 index 0000000000..c2e370fcb6 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -0,0 +1,893 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#if 0 +#include "Rim2dIntersectionView.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimGridCollection.h" +#include "RimIntersectionCollection.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimPropertyFilterCollection.h" +#include "RimViewController.h" +#include "RimViewLinker.h" +#include "RimViewLinkerCollection.h" +#include "RimWellPathCollection.h" + +#include "RiuMainWindow.h" +#include "RiuViewer.h" +#include "RiuTimeStepChangedHandler.h" + +#include "cafDisplayCoordTransform.h" +#include "cafFrameAnimationControl.h" +#include "cafPdmObjectFactory.h" + +#include "cvfCamera.h" +#include "cvfModel.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" +#include "cvfScene.h" +#include "cvfViewport.h" + +#include + +#include +#include "cvfTransform.h" + + +namespace caf { + +template<> +void caf::AppEnum< Rim2dIntersectionView::MeshModeType >::setUp() +{ + addItem(Rim2dIntersectionView::FULL_MESH, "FULL_MESH", "All"); + addItem(Rim2dIntersectionView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); + addItem(Rim2dIntersectionView::NO_MESH, "NO_MESH", "None"); + setDefault(Rim2dIntersectionView::FULL_MESH); +} + +template<> +void caf::AppEnum< Rim2dIntersectionView::SurfaceModeType >::setUp() +{ + addItem(Rim2dIntersectionView::SURFACE, "SURFACE", "All"); + addItem(Rim2dIntersectionView::NO_SURFACE, "NO_SURFACE", "None"); + setDefault(Rim2dIntersectionView::SURFACE); +} + +} // End namespace caf + + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "GenericView"); // Do not use. Abstract class + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView::Rim2dIntersectionView(void) +{ + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + CVF_ASSERT(preferences); + + + CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); + + CAF_PDM_InitField(&m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); + m_cameraPosition.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); + m_cameraPointOfInterest.uiCapability()->setUiHidden(true); + + double defaultScaleFactor = preferences->defaultScaleFactorZ; + CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); + + cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); + CAF_PDM_InitField(&m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); + + CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); + maximumFrameRate.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", ""); + hasUserRequestedAnimation.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); + m_currentTimeStep.uiCapability()->setUiHidden(true); + + //CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + //m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); + //m_overlayInfoConfig->setReservoirView(this); + //m_overlayInfoConfig.uiCapability()->setUiHidden(true); + + caf::AppEnum defaultMeshType = NO_MESH; + if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; + CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); + CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", ""); + + CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); + + m_previousGridModeMeshLinesWasFaults = false; + + m_crossSectionVizModel = new cvf::ModelBasicList; + m_crossSectionVizModel->setName("CrossSectionModel"); + + m_highlightVizModel = new cvf::ModelBasicList; + m_highlightVizModel->setName("HighlightModel"); + + m_wellPathPipeVizModel = new cvf::ModelBasicList; + m_wellPathPipeVizModel->setName("WellPathPipeModel"); + + this->setAs3DViewMdiWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView::~Rim2dIntersectionView(void) +{ + RimProject* proj = RiaApplication::instance()->project(); + + removeMdiWindowFromMdiArea(); + + deleteViewWidget(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewer* Rim2dIntersectionView::viewer() +{ + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Rim2dIntersectionView::createViewWidget(QWidget* mainWindowParent) +{ + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + m_viewer = new RiuViewer(glFormat, NULL); + m_viewer->setOwnerReservoirView(this); + + m_viewer->showAxisCross(false); + + return m_viewer->layoutWidget(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateViewWidgetAfterCreation() +{ + m_viewer->setDefaultPerspectiveNearPlaneDistance(10); + + this->resetLegendsInViewer(); + + m_viewer->updateNavigationPolicy(); + m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); + + m_viewer->mainCamera()->setViewMatrix(m_cameraPosition); + m_viewer->setPointOfInterest(m_cameraPointOfInterest()); + m_viewer->enableParallelProjection(true); + + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + + this->updateAnnotationItems(); + this->createHighlightDisplayModel(); + + m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateMdiWindowTitle() +{ + if (m_viewer) + { + QString windowTitle; + if (ownerCase()) + { + windowTitle = QString("%1 - %2").arg(ownerCase()->caseUserDescription()).arg(name); + } + else + { + windowTitle = name; + } + + m_viewer->layoutWidget()->setWindowTitle(windowTitle); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::deleteViewWidget() +{ + if (m_viewer) + { + m_viewer->deleteLater(); + m_viewer = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); + viewGroup->add(&name); + viewGroup->add(&m_backgroundColor); + viewGroup->add(&m_disableLighting); + + caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Grid Appearance"); + gridGroup->add(&scaleZ); + gridGroup->add(&meshMode); + gridGroup->add(&surfaceMode); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QImage Rim2dIntersectionView::snapshotWindowContent() +{ + if (m_viewer) + { + // Force update of scheduled display models before snapshotting + RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + + m_viewer->repaint(); + + return m_viewer->snapshotImage(); + } + + return QImage(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::scheduleCreateDisplayModelAndRedraw() +{ + RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); + if (this->isMasterView()) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setCurrentTimeStepAndUpdate(int frameIndex) +{ + setCurrentTimeStep(frameIndex); + + this->updateCurrentTimeStep(); + + RimProject* project; + firstAncestorOrThisOfTypeAsserted(project); + project->mainPlotCollection()->updateCurrentTimeStepInPlots(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim2dIntersectionView::timeStepName(int frameIdx) const +{ + return this->ownerCase()->timeStepName(frameIdx); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setCurrentTimeStep(int frameIndex) +{ + const int oldTimeStep = m_currentTimeStep; + + m_currentTimeStep = frameIndex; + clampCurrentTimestep(); + + if (m_currentTimeStep != oldTimeStep) + { + RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); + } + + this->hasUserRequestedAnimation = true; + if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) + { + m_currentReservoirCellVisibility = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateCurrentTimeStepAndRedraw() +{ + this->updateCurrentTimeStep(); + + RimProject* project; + firstAncestorOrThisOfTypeAsserted(project); + project->mainPlotCollection()->updateCurrentTimeStepInPlots(); + + if (m_viewer) m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createDisplayModelAndRedraw() +{ + if (m_viewer) + { + this->clampCurrentTimestep(); + + createDisplayModel(); + createHighlightDisplayModel(); + updateDisplayModelVisibility(); + + if (m_cameraPosition().isIdentity()) + { + setDefaultView(); + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); + } + } + + RiuMainWindow::instance()->refreshAnimationActions(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setDefaultView() +{ + if (m_viewer) + { + m_viewer->setDefaultView(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::endAnimation() +{ + this->hasUserRequestedAnimation = false; + this->updateStaticCellColors(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathCollection* Rim2dIntersectionView::wellPathCollection() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfTypeAsserted(proj); + CVF_ASSERT(proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()); + + return proj->activeOilField()->wellPathCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setupBeforeSave() +{ + if (m_viewer) + { + hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +// Surf: No Fault Surf +// Mesh ------------- +// No F F G +// Fault F F G +// Mesh G G G +// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isGridVisualizationMode() const +{ + return ( this->surfaceMode() == SURFACE + || this->meshMode() == FULL_MESH); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setMeshOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + meshMode.setValueWithFieldChanged(FULL_MESH); + } + else + { + meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + + surfaceMode.setValueWithFieldChanged(NO_SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setMeshSurfDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + meshMode.setValueWithFieldChanged(FULL_MESH); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + meshMode.setValueWithFieldChanged(FAULTS_MESH); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setFaultMeshSurfDrawstyle() +{ + // Surf: No Fault Surf + // Mesh ------------- + // No FF FF SF + // Fault FF FF SF + // Mesh SF SF SF + if (this->isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + } + + meshMode.setValueWithFieldChanged(FAULTS_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setSurfOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueWithFieldChanged(SURFACE); + } + else + { + surfaceMode.setValueWithFieldChanged(FAULTS); + } + + meshMode.setValueWithFieldChanged(NO_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::showGridCells(bool enableGridCells) +{ + if (!enableGridCells) + { + m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + else + { + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); + } + + m_gridCollection->isActive = enableGridCells; + m_gridCollection->updateConnectedEditors(); + m_gridCollection->updateUiIconFromState(enableGridCells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setSurfaceDrawstyle() +{ + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::disableLighting(bool disable) +{ + m_disableLighting = disable; + updateCurrentTimeStepAndRedraw(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isLightingDisabled() const +{ + return m_disableLighting(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); + + if (changedField == &meshMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &isPerspectiveView) + { + if (m_viewer) m_viewer->enableParallelProjection(!isPerspectiveView()); + } + else if (changedField == &scaleZ) + { + if (scaleZ < 1) scaleZ = 1; + + this->updateGridBoxData(); + + // Regenerate well paths + RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; + RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; + + crossSectionCollection->updateIntersectionBoxGeometry(); + + if (m_viewer) + { + cvf::Vec3d poi = m_viewer->pointOfInterest(); + cvf::Vec3d eye, dir, up; + eye = m_viewer->mainCamera()->position(); + dir = m_viewer->mainCamera()->direction(); + up = m_viewer->mainCamera()->up(); + + eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]); + poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2); + + m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); + m_viewer->setPointOfInterest(poi); + + updateScaleTransform(); + createDisplayModelAndRedraw(); + + m_viewer->update(); + + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateScaleZ(this, scaleZ); + viewLinker->updateCamera(this); + } + } + + RiuMainWindow::instance()->updateScaleValue(); + } + else if (changedField == &surfaceMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &showGridBox) + { + createHighlightAndGridBoxDisplayModelWithRedraw(); + } + else if (changedField == &m_disableLighting) + { + createDisplayModel(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + } + else if (changedField == &name) + { + updateMdiWindowTitle(); + + if (viewController()) + { + viewController()->updateDisplayNameAndIcon(); + viewController()->updateConnectedEditors(); + } + else + { + if (isMasterView()) + { + assosiatedViewLinker()->updateUiNameAndIcon(); + assosiatedViewLinker()->updateConnectedEditors(); + } + } + } + else if (changedField == &m_currentTimeStep) + { + if (m_viewer) + { + m_viewer->update(); + + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateTimeStep(this, m_currentTimeStep); + } + } + } + else if (changedField == &m_backgroundColor) + { + if (m_viewer != nullptr) + { + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + } + updateGridBoxData(); + updateAnnotationItems(); + } + else if (changedField == &maximumFrameRate) + { + // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? + // !! Should be able to specify legal range for number properties + if (m_viewer) + { + m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!this->ownerCase()) return; + + cvf::ref transForm = displayCoordTransform(); + + wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, + transForm.p()); + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!this->ownerCase()) return; + + cvf::ref transForm = displayCoordTransform(); + + QDateTime currentTimeStamp; + std::vector timeStamps = ownerCase()->timeStepDates(); + if (currentTimeStep() < static_cast(timeStamps.size())) + { + currentTimeStamp = timeStamps[currentTimeStep()]; + } + + wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, + currentTimeStamp, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, + transForm.p()); + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setScaleZAndUpdate(double scaleZ) +{ + this->scaleZ = scaleZ; + updateScaleTransform(); + + this->updateGridBoxData(); + + this->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* Rim2dIntersectionView::viewLinkerIfMasterView() const +{ + RimViewLinker* viewLinker = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewLinker = dynamic_cast(reffingObjs[i]); + if (viewLinker) break; + } + + return viewLinker; +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateAnnotationItems() +{ + if (m_viewer) + { + m_viewer->updateAnnotationItems(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//Rim3dOverlayInfoConfig* Rim2dIntersectionView::overlayInfoConfig() const +//{ +// return m_overlayInfoConfig; +//} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createHighlightDisplayModelWithRedraw() +{ + createHighlightDisplayModel(); + + if (m_viewer) + { + m_viewer->update(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createHighlightDisplayModel() +{ + m_viewer->removeStaticModel(m_highlightVizModel.p()); + + m_highlightVizModel->removeAllParts(); + + cvf::Collection parts; + createPartCollectionFromSelection(&parts); + if (parts.size() > 0) + { + for (size_t i = 0; i < parts.size(); i++) + { + m_highlightVizModel->addPart(parts[i].p()); + } + + m_highlightVizModel->updateBoundingBoxesRecursive(); + m_viewer->addStaticModelOnce(m_highlightVizModel.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::showActiveCellsOnly() +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::selectOverlayInfoConfig() +{ + //RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::zoomAll() +{ + if (m_viewer) + { + m_viewer->zoomAll(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim2dIntersectionView::displayCoordTransform() const +{ + cvf::ref coordTrans = new caf::DisplayCoordTransform; + + cvf::Vec3d scale(1.0, 1.0, scaleZ); + coordTrans->setScale(scale); + + RimCase* rimCase = ownerCase(); + if (rimCase) + { + coordTrans->setTranslation(rimCase->displayModelOffset()); + } + + return coordTrans; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Rim2dIntersectionView::viewWidget() +{ + if ( m_viewer ) return m_viewer->layoutWidget(); + else return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::forceShowWindowOn() +{ + m_showWindow.setValueWithFieldChanged(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::handleMdiWindowClosed() +{ + RimViewWindow::handleMdiWindowClosed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) +{ + RimViewWindow::setMdiWindowGeometry(windowGeometry); +} + +#endif \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h new file mode 100644 index 0000000000..8e01317205 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -0,0 +1,211 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once +#include "RiuViewerToViewInterface.h" +#include "RimViewWindow.h" + +#include "cafAppEnum.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" +#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmObject.h" + +#include "RivCellSetEnum.h" + +#include "cvfArray.h" +#include "cvfBase.h" +#include "cvfCollection.h" +#include "cvfObject.h" + +#include + + +class Rim3dOverlayInfoConfig; +class RimCase; +class RimCellRangeFilter; +class RimCellRangeFilterCollection; +class RimIntersectionCollection; +class RimGridCollection; +class RimPropertyFilterCollection; +class RimViewController; +class RimViewLinker; +class RiuViewer; +class RimWellPathCollection; + +namespace cvf +{ +class BoundingBox; +class ModelBasicList; +class Scene; +class String; +class Transform; +class Part; +} + +namespace caf +{ +class DisplayCoordTransform; +} +//================================================================================================== +/// +/// +//================================================================================================== +class Rim2dIntersectionView : public RimViewWindow, public RiuViewerToViewInterface +{ + CAF_PDM_HEADER_INIT; +public: + Rim2dIntersectionView(void); + virtual ~Rim2dIntersectionView(void); + + // Public fields: + + caf::PdmField name; + caf::PdmField scaleZ; + caf::PdmField maximumFrameRate; + caf::PdmField hasUserRequestedAnimation; + + // Draw style + + enum MeshModeType { FULL_MESH, FAULTS_MESH, NO_MESH }; + enum SurfaceModeType { SURFACE, NO_SURFACE }; + + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; + caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; + + RiuViewer* viewer(); + + void setMeshOnlyDrawstyle(); + void setMeshSurfDrawstyle(); + void setSurfOnlyDrawstyle(); + void setFaultMeshSurfDrawstyle(); + void setSurfaceDrawstyle(); + + void disableLighting(bool disable); + bool isLightingDisabled() const; + + void showGridCells(bool enableGridCells); + bool isGridVisualizationMode() const; + + void setScaleZAndUpdate(double scaleZ); + virtual bool showActiveCellsOnly(); + virtual bool isUsingFormationNames() const = 0; + + virtual QImage snapshotWindowContent() override; + virtual void zoomAll() override; + void forceShowWindowOn(); + + // Animation + int currentTimeStep() const { return m_currentTimeStep;} + void setCurrentTimeStep(int frameIdx); + void setCurrentTimeStepAndUpdate(int frameIdx) override; + + // Updating + void updateCurrentTimeStepAndRedraw() override; + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0; + void scheduleCreateDisplayModelAndRedraw(); + void createDisplayModelAndRedraw(); + void createHighlightDisplayModelWithRedraw(); + void updateAnnotationItems(); + + cvf::ref displayCoordTransform() const override; + + virtual RimCase* ownerCase() const = 0; + //Rim3dOverlayInfoConfig* overlayInfoConfig() const; + +protected: + + void setDefaultView(); + + RimWellPathCollection* wellPathCollection(); + void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void createHighlightDisplayModel(); + + // Abstract methods to implement in subclasses + + virtual void createDisplayModel() = 0; + virtual void createPartCollectionFromSelection(cvf::Collection* parts) = 0; + + virtual void updateDisplayModelVisibility() = 0; + virtual void clampCurrentTimestep() = 0; + + virtual void updateCurrentTimeStep() = 0; + virtual void updateStaticCellColors() = 0; + + virtual void updateScaleTransform() = 0; + virtual cvf::Transform* scaleTransform() = 0; + + virtual void resetLegendsInViewer() = 0; + + // Overridden PdmObject methods: + + virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } + virtual void setupBeforeSave() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + // Overridden ViewWindow methods: + + virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; + virtual void updateViewWidgetAfterCreation() override; + virtual void updateMdiWindowTitle() override; + virtual void deleteViewWidget() override; + virtual QWidget* viewWidget() override; + +protected: // Fields + caf::PdmField m_currentTimeStep; + //caf::PdmChildField m_overlayInfoConfig; + +protected: + QPointer m_viewer; + + cvf::ref m_wellPathPipeVizModel; + cvf::ref m_crossSectionVizModel; + cvf::ref m_highlightVizModel; + +private: + // Implementation of RiuViewerToViewInterface + + virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();} + virtual void setCameraPosition(const cvf::Mat4d& cameraPosition) override { m_cameraPosition = cameraPosition; } + virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) override { m_cameraPointOfInterest = cameraPointOfInterest;} + virtual QString timeStepName(int frameIdx) const override; + virtual void endAnimation() override; + virtual caf::PdmObjectHandle* implementingPdmObject() override { return this; } + virtual void handleMdiWindowClosed() override; + virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; + virtual void selectOverlayInfoConfig() override; + +private: + bool m_previousGridModeMeshLinesWasFaults; + caf::PdmField m_disableLighting; + caf::PdmField m_cameraPosition; + caf::PdmField m_cameraPointOfInterest; + caf::PdmField< cvf::Color3f > m_backgroundColor; +}; + + + diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index d6e9a60a6b..72e5a48be9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -738,7 +738,7 @@ void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dOverlayInfoConfig::setReservoirView(Rim3dView* ownerReservoirView) +void Rim3dOverlayInfoConfig::setReservoirView(RimGridView* ownerReservoirView) { m_viewDef = ownerReservoirView; } diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 407bada1b0..812a72828e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -32,7 +32,7 @@ class RimEclipseView; class RimGeoMechView; -class Rim3dView; +class RimGridView; class RigStatisticsDataCache; class RicGridStatisticsDialog; @@ -67,7 +67,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void update3DInfo(); - void setReservoirView(Rim3dView* ownerView); + void setReservoirView(RimGridView* ownerView); void setPosition(cvf::Vec2ui position); @@ -120,7 +120,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject caf::PdmField > m_statisticsTimeRange; caf::PdmField > m_statisticsCellRange; - caf::PdmPointer m_viewDef; + caf::PdmPointer m_viewDef; cvf::Vec2ui m_position; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 645d2482c2..e20475cc5e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -118,11 +118,6 @@ Rim3dView::Rim3dView(void) CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); m_currentTimeStep.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); - m_overlayInfoConfig->setReservoirView(this); - m_overlayInfoConfig.uiCapability()->setUiHidden(true); - caf::AppEnum defaultMeshType = NO_MESH; if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); @@ -132,26 +127,6 @@ Rim3dView::Rim3dView(void) CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); - - CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); - m_rangeFilterCollection.uiCapability()->setUiHidden(true); - m_rangeFilterCollection = new RimCellRangeFilterCollection(); - - CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); - m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); - m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); - m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - - CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); - crossSectionCollection.uiCapability()->setUiHidden(true); - crossSectionCollection = new RimIntersectionCollection(); - - CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); - m_gridCollection.uiCapability()->setUiHidden(true); - m_gridCollection = new RimGridCollection(); - - m_previousGridModeMeshLinesWasFaults = false; - m_crossSectionVizModel = new cvf::ModelBasicList; m_crossSectionVizModel->setName("CrossSectionModel"); @@ -169,36 +144,9 @@ Rim3dView::Rim3dView(void) //-------------------------------------------------------------------------------------------------- Rim3dView::~Rim3dView(void) { - RimProject* proj = RiaApplication::instance()->project(); - - if (proj && this->isMasterView()) - { - delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = NULL; - - proj->uiCapability()->updateConnectedEditors(); - } - - RimViewController* vController = this->viewController(); - if (proj && vController) - { - vController->setManagedView(NULL); - vController->ownerViewLinker()->removeViewController(vController); - delete vController; - - proj->uiCapability()->updateConnectedEditors(); - } - - delete this->m_overlayInfoConfig(); - removeMdiWindowFromMdiArea(); deleteViewWidget(); - - delete m_rangeFilterCollection; - delete m_overrideRangeFilterCollection; - delete crossSectionCollection; - delete m_gridCollection; } //-------------------------------------------------------------------------------------------------- @@ -230,7 +178,6 @@ QWidget* Rim3dView::createViewWidget(QWidget* mainWindowParent) return m_viewer->layoutWidget(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -277,7 +224,6 @@ void Rim3dView::updateMdiWindowTitle() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -306,8 +252,6 @@ void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrd gridGroup->add(&scaleZ); gridGroup->add(&meshMode); gridGroup->add(&surfaceMode); - - } //-------------------------------------------------------------------------------------------------- @@ -379,13 +323,11 @@ void Rim3dView::setCurrentTimeStep(int frameIndex) if (m_currentTimeStep != oldTimeStep) { RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); + this->onTimeStepChanged(); } this->hasUserRequestedAnimation = true; - if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) - { - m_currentReservoirCellVisibility = NULL; - } + } //-------------------------------------------------------------------------------------------------- @@ -426,7 +368,6 @@ void Rim3dView::createDisplayModelAndRedraw() RiuMainWindow::instance()->refreshAnimationActions(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -438,7 +379,6 @@ void Rim3dView::setDefaultView() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -448,7 +388,6 @@ void Rim3dView::endAnimation() this->updateStaticCellColors(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -489,7 +428,6 @@ bool Rim3dView::isGridVisualizationMode() const || this->meshMode() == FULL_MESH); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -563,28 +501,6 @@ void Rim3dView::setSurfOnlyDrawstyle() meshMode.setValueWithFieldChanged(NO_MESH); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::showGridCells(bool enableGridCells) -{ - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } - - m_gridCollection->isActive = enableGridCells; - m_gridCollection->updateConnectedEditors(); - m_gridCollection->updateUiIconFromState(enableGridCells); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -634,7 +550,6 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const if (scaleZ < 1) scaleZ = 1; this->updateGridBoxData(); - crossSectionCollection->updateIntersectionBoxGeometry(); if (m_viewer) { @@ -655,12 +570,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const m_viewer->update(); - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateScaleZ(this, scaleZ); - viewLinker->updateCamera(this); - } + } RiuMainWindow::instance()->updateScaleValue(); @@ -706,11 +616,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const { m_viewer->update(); - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateTimeStep(this, m_currentTimeStep); - } + } } else if (changedField == &m_backgroundColor) @@ -776,50 +682,6 @@ void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBas wellPathModelBasicList->updateBoundingBoxesRecursive(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimCellRangeFilterCollection* Rim3dView::rangeFilterCollection() -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RimCellRangeFilterCollection* Rim3dView::rangeFilterCollection() const -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) -{ - if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); - - m_overrideRangeFilterCollection = rfc; - this->scheduleGeometryRegen(RANGE_FILTERED); - this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); - - this->scheduleCreateDisplayModelAndRedraw(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -833,75 +695,6 @@ void Rim3dView::setScaleZAndUpdate(double scaleZ) this->scheduleCreateDisplayModelAndRedraw(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewController* Rim3dView::viewController() const -{ - RimViewController* viewController = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewController = dynamic_cast(reffingObjs[i]); - if (viewController) break; - } - - return viewController; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* Rim3dView::viewLinkerIfMasterView() const -{ - RimViewLinker* viewLinker = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewLinker = dynamic_cast(reffingObjs[i]); - if (viewLinker) break; - } - - return viewLinker; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* Rim3dView::assosiatedViewLinker() const -{ - RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); - if (!viewLinker) - { - RimViewController* viewController = this->viewController(); - if (viewController) - { - viewLinker = viewController->ownerViewLinker(); - } - } - - return viewLinker; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref Rim3dView::currentTotalCellVisibility() -{ - if (m_currentReservoirCellVisibility.isNull()) - { - m_currentReservoirCellVisibility = new cvf::UByteArray; - this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); - } - - return m_currentReservoirCellVisibility; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -916,57 +709,6 @@ bool Rim3dView::isMasterView() const return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool Rim3dView::hasOverridenRangeFilterCollection() -{ - return m_overrideRangeFilterCollection() != NULL; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::replaceRangeFilterCollectionWithOverride() -{ - RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; - CVF_ASSERT(overrideRfc); - - RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; - if (currentRfc) - { - delete currentRfc; - } - - // Must call removeChildObject() to make sure the object has no parent - // No parent is required when assigning a object into a field - m_overrideRangeFilterCollection.removeChildObject(overrideRfc); - - m_rangeFilterCollection = overrideRfc; - - this->uiCapability()->updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) -{ - std::vector modelsToBeRemoved; - for (cvf::uint i = 0; i < scene->modelCount(); i++) - { - if (scene->model(i)->name() == modelName) - { - modelsToBeRemoved.push_back(scene->model(i)); - } - } - - for (size_t i = 0; i < modelsToBeRemoved.size(); i++) - { - scene->removeModel(modelsToBeRemoved[i]); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -994,14 +736,6 @@ void Rim3dView::updateAnnotationItems() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dOverlayInfoConfig* Rim3dView::overlayInfoConfig() const -{ - return m_overlayInfoConfig; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1048,14 +782,6 @@ bool Rim3dView::showActiveCellsOnly() return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dView::selectOverlayInfoConfig() -{ - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1137,7 +863,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. //-------------------------------------------------------------------------------------------------- RimGridView::RimGridView() { -#if 0 + CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); m_rangeFilterCollection.uiCapability()->setUiHidden(true); m_rangeFilterCollection = new RimCellRangeFilterCollection(); @@ -1161,7 +887,6 @@ RimGridView::RimGridView() m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); m_overlayInfoConfig->setReservoirView(this); m_overlayInfoConfig.uiCapability()->setUiHidden(true); -#endif } //-------------------------------------------------------------------------------------------------- @@ -1169,16 +894,33 @@ RimGridView::RimGridView() //-------------------------------------------------------------------------------------------------- RimGridView::~RimGridView(void) { -#if 0 + RimProject* proj = RiaApplication::instance()->project(); + + if (proj && this->isMasterView()) + { + delete proj->viewLinkerCollection->viewLinker(); + proj->viewLinkerCollection->viewLinker = NULL; + + proj->uiCapability()->updateConnectedEditors(); + } + + RimViewController* vController = this->viewController(); + if (proj && vController) + { + vController->setManagedView(NULL); + vController->ownerViewLinker()->removeViewController(vController); + delete vController; + + proj->uiCapability()->updateConnectedEditors(); + } + delete this->m_overlayInfoConfig(); delete m_rangeFilterCollection; delete m_overrideRangeFilterCollection; delete crossSectionCollection; delete m_gridCollection; - #endif } -#if 0 //-------------------------------------------------------------------------------------------------- /// @@ -1202,34 +944,6 @@ void RimGridView::showGridCells(bool enableGridCells) m_gridCollection->updateUiIconFromState(enableGridCells); } -//-------------------------------------------------------------------------------------------------- -/// -// Surf: No Fault Surf -// Mesh ------------- -// No F F G -// Fault F F G -// Mesh G G G -// -//-------------------------------------------------------------------------------------------------- -bool RimGridView::isGridVisualizationMode() const -{ - return ( this->surfaceMode() == SURFACE - || this->meshMode() == FULL_MESH); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if (changedField == &scaleZ) - { - crossSectionCollection->updateIntersectionBoxGeometry(); - } - - Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1243,6 +957,7 @@ cvf::ref RimGridView::currentTotalCellVisibility() return m_currentReservoirCellVisibility; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1276,7 +991,7 @@ const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dView::hasOverridenRangeFilterCollection() +bool RimGridView::hasOverridenRangeFilterCollection() { return m_overrideRangeFilterCollection() != NULL; } @@ -1335,21 +1050,6 @@ RimViewController* RimGridView::viewController() const return viewController; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimGridView::isMasterView() const -{ - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker && this == viewLinker->masterView()) - { - return true; - } - - return false; -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1376,16 +1076,6 @@ Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const return m_overlayInfoConfig; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::selectOverlayInfoConfig() -{ - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1406,4 +1096,71 @@ void RimGridView::removeModelByName(cvf::Scene* scene, const cvf::String& modelN } } -#endif \ No newline at end of file +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::onTimeStepChanged() +{ + if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) + { + m_currentReservoirCellVisibility = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if ( changedField == &scaleZ ) + { + crossSectionCollection->updateIntersectionBoxGeometry(); + } + + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); + + if ( changedField == &scaleZ ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateScaleZ(this, scaleZ); + viewLinker->updateCamera(this); + } + } + else if ( changedField == &m_currentTimeStep ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateTimeStep(this, m_currentTimeStep); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::selectOverlayInfoConfig() +{ + RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::viewLinkerIfMasterView() const +{ + RimViewLinker* viewLinker = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewLinker = dynamic_cast(reffingObjs[i]); + if (viewLinker) break; + } + + return viewLinker; +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 320463337b..037bde6a37 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -93,8 +93,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - caf::PdmChildField crossSectionCollection; - RiuViewer* viewer(); void setMeshOnlyDrawstyle(); @@ -105,14 +103,12 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void disableLighting(bool disable); bool isLightingDisabled() const; - - void showGridCells(bool enableGridCells); + bool isGridVisualizationMode() const; void setScaleZAndUpdate(double scaleZ); virtual bool showActiveCellsOnly(); virtual bool isUsingFormationNames() const = 0; - cvf::ref currentTotalCellVisibility(); virtual QImage snapshotWindowContent() override; virtual void zoomAll() override; @@ -132,22 +128,11 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void updateGridBoxData(); void updateAnnotationItems(); - virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; - RimCellRangeFilterCollection* rangeFilterCollection(); - const RimCellRangeFilterCollection* rangeFilterCollection() const; - - bool hasOverridenRangeFilterCollection(); - void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); - void replaceRangeFilterCollectionWithOverride(); - - RimViewController* viewController() const override; bool isMasterView() const; - RimViewLinker* assosiatedViewLinker() const override; cvf::ref displayCoordTransform() const override; virtual RimCase* ownerCase() const = 0; - Rim3dOverlayInfoConfig* overlayInfoConfig() const; protected: @@ -160,8 +145,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox); - static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - void createHighlightAndGridBoxDisplayModel(); // Abstract methods to implement in subclasses @@ -175,35 +158,25 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual void clampCurrentTimestep() = 0; virtual void updateCurrentTimeStep() = 0; + virtual void onTimeStepChanged() = 0; virtual void updateStaticCellColors() = 0; virtual void updateScaleTransform() = 0; virtual cvf::Transform* scaleTransform() = 0; virtual void resetLegendsInViewer() = 0; - virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; protected: // Fields caf::PdmField m_currentTimeStep; - caf::PdmChildField m_overlayInfoConfig; - caf::PdmChildField m_rangeFilterCollection; - caf::PdmChildField m_overrideRangeFilterCollection; - - caf::PdmChildField m_gridCollection; - protected: QPointer m_viewer; - cvf::ref m_currentReservoirCellVisibility; - cvf::ref m_wellPathPipeVizModel; cvf::ref m_crossSectionVizModel; cvf::ref m_highlightVizModel; private: - RimViewLinker* viewLinkerIfMasterView() const; - // Overridden PdmObject methods: virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } @@ -231,10 +204,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual caf::PdmObjectHandle* implementingPdmObject() override { return this; } virtual void handleMdiWindowClosed() override; virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; - virtual void selectOverlayInfoConfig() override; private: - bool m_previousGridModeMeshLinesWasFaults; caf::PdmField m_disableLighting; caf::PdmField m_cameraPosition; caf::PdmField m_cameraPointOfInterest; @@ -249,12 +220,11 @@ class RimGridView : public Rim3dView public: RimGridView(); virtual ~RimGridView(void); -#if 0 +#if 1 caf::PdmChildField crossSectionCollection; - + void showGridCells(bool enableGridCells); - bool isGridVisualizationMode() const; cvf::ref currentTotalCellVisibility(); @@ -267,14 +237,14 @@ class RimGridView : public Rim3dView void replaceRangeFilterCollectionWithOverride(); RimViewController* viewController() const override; - bool isMasterView() const; RimViewLinker* assosiatedViewLinker() const override; Rim3dOverlayInfoConfig* overlayInfoConfig() const; protected: static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; + virtual void onTimeStepChanged() override; + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 06cdc79cc8..04c3bc31ea 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -57,7 +57,7 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (changedField == &isActive) { - Rim3dView* rimView = NULL; + RimGridView* rimView = NULL; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 5f3418a677..5839385b2b 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -598,12 +598,12 @@ std::vector RimProject::allSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allNotLinkedViews(std::vector& views) +void RimProject::allNotLinkedViews(std::vector& views) { std::vector cases; allCases(cases); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; if (viewLinkerCollection->viewLinker()) { viewLinkerCollection->viewLinker()->allViews(alreadyLinkedViews); @@ -617,17 +617,21 @@ void RimProject::allNotLinkedViews(std::vector& views) std::vector caseViews = rimCase->views(); for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++) { + RimGridView* gridView = dynamic_cast(caseViews[viewIdx]); + + if (!gridView) continue; + bool isLinked = false; for (size_t lnIdx = 0; lnIdx < alreadyLinkedViews.size(); lnIdx++) { - if (caseViews[viewIdx] == alreadyLinkedViews[lnIdx]) + if (gridView == alreadyLinkedViews[lnIdx]) { isLinked = true; } } if (!isLinked) { - views.push_back(caseViews[viewIdx]); + views.push_back(gridView); } } } @@ -657,6 +661,20 @@ void RimProject::allVisibleViews(std::vector& views) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::allVisibleGridViews(std::vector& views) +{ + std::vector visibleViews; + this->allVisibleViews(visibleViews); + for ( Rim3dView* view : visibleViews ) + { + RimGridView* gridView = dynamic_cast(view); + if ( gridView ) views.push_back(gridView); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 677a7bd75a..c29a17dc13 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -48,6 +48,7 @@ class RimOilField; class RimScriptCollection; class RimSummaryCase; class Rim3dView; +class RimGridView; class RimViewLinker; class RimViewLinkerCollection; class RimWellPath; @@ -106,8 +107,9 @@ class RimProject : public caf::PdmDocument std::vector allSummaryCases() const; - void allNotLinkedViews(std::vector& views); void allVisibleViews(std::vector& views); + void allVisibleGridViews(std::vector& views); + void allNotLinkedViews(std::vector& views); void createDisplayModelAndRedrawAllViews(); diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index eb3a407a64..18aa3a9f90 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -101,7 +101,7 @@ QList RimViewController::calculateValueOptions(const caf if (fieldNeedingOptions == &m_managedView) { RimProject* proj = RiaApplication::instance()->project(); - std::vector views; + std::vector views; proj->allNotLinkedViews(views); // Add currently linked view to list @@ -114,7 +114,7 @@ QList RimViewController::calculateValueOptions(const caf this->firstAncestorOrThisOfType(viewLinker); CVF_ASSERT(viewLinker); - for (Rim3dView* view : views) + for (RimGridView* view : views) { if (view != viewLinker->masterView()) { @@ -212,7 +212,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField else if (changedField == &m_managedView) { PdmObjectHandle* prevValue = oldValue.value >().rawPtr(); - Rim3dView* previousManagedView = dynamic_cast(prevValue); + RimGridView* previousManagedView = dynamic_cast(prevValue); RimViewController::removeOverrides(previousManagedView); setManagedView(m_managedView()); @@ -232,7 +232,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- RimEclipseView* RimViewController::managedEclipseView() const { - Rim3dView* rimView = m_managedView; + RimGridView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -242,7 +242,7 @@ RimEclipseView* RimViewController::managedEclipseView() const //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimViewController::managedGeoView() const { - Rim3dView* rimView = m_managedView; + RimGridView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -254,7 +254,7 @@ void RimViewController::updateOverrides() { RimViewLinker* viewLinker = ownerViewLinker(); - Rim3dView* masterView = viewLinker->masterView(); + RimGridView* masterView = viewLinker->masterView(); CVF_ASSERT(masterView); @@ -343,7 +343,7 @@ void RimViewController::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::removeOverrides(Rim3dView* view) +void RimViewController::removeOverrides(RimGridView* view) { if (view) { @@ -362,7 +362,7 @@ void RimViewController::removeOverrides(Rim3dView* view) //-------------------------------------------------------------------------------------------------- void RimViewController::updateOptionSensitivity() { - Rim3dView* mainView = nullptr; + RimGridView* mainView = nullptr; { RimViewLinker* linkedViews = nullptr; @@ -448,7 +448,7 @@ void RimViewController::updateOptionSensitivity() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RimViewController::managedView() const +RimGridView* RimViewController::managedView() const { return m_managedView; } @@ -456,7 +456,7 @@ Rim3dView* RimViewController::managedView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::setManagedView(Rim3dView* view) +void RimViewController::setManagedView(RimGridView* view) { m_managedView = view; @@ -644,7 +644,7 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RimViewController::masterView() const +RimGridView* RimViewController::masterView() const { return ownerViewLinker()->masterView(); } @@ -1041,7 +1041,7 @@ void RimViewController::applyRangeFilterCollectionByUserChoice() //-------------------------------------------------------------------------------------------------- bool RimViewController::askUserToRestoreOriginalRangeFilterCollection(const QString& viewName) { - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); QMessageBox msgBox(activeView->viewer()->layoutWidget()); msgBox.setIcon(QMessageBox::Question); diff --git a/ApplicationCode/ProjectDataModel/RimViewController.h b/ApplicationCode/ProjectDataModel/RimViewController.h index 9bc3d233d3..01003cbb7e 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.h +++ b/ApplicationCode/ProjectDataModel/RimViewController.h @@ -28,7 +28,7 @@ #include "RivCellSetEnum.h" -class Rim3dView; +class RimGridView; class RimEclipseView; class RimGeoMechView; class RimViewLinker; @@ -49,10 +49,10 @@ class RimViewController : public caf::PdmObject bool isActive() const; - Rim3dView* managedView() const; - void setManagedView(Rim3dView* view); + RimGridView* managedView() const; + void setManagedView(RimGridView* view); - Rim3dView* masterView() const; + RimGridView* masterView() const; RimViewLinker* ownerViewLinker() const; const RigCaseToCaseCellMapper* cellMapper(); @@ -102,12 +102,12 @@ class RimViewController : public caf::PdmObject RimEclipseView* managedEclipseView() const; RimGeoMechView* managedGeoView() const; - static void removeOverrides(Rim3dView* view); + static void removeOverrides(RimGridView* view); static bool askUserToRestoreOriginalRangeFilterCollection(const QString& viewName); private: caf::PdmField m_name; - caf::PdmPtrField m_managedView; + caf::PdmPtrField m_managedView; caf::PdmField m_isActive; caf::PdmField m_syncCamera; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index bd2b508adc..5e992a0bea 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -83,7 +83,7 @@ RimViewLinker::~RimViewLinker(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateTimeStep(Rim3dView* sourceView, int timeStep) +void RimViewLinker::updateTimeStep(RimGridView* sourceView, int timeStep) { CVF_ASSERT(sourceView); @@ -247,7 +247,7 @@ void RimViewLinker::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViewsForCameraSync(const Rim3dView* source, std::vector& views) const +void RimViewLinker::allViewsForCameraSync(const RimGridView* source, std::vector& views) const { if (!isActive()) return; @@ -283,7 +283,7 @@ void RimViewLinker::updateDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimViewLinker::displayNameForView(Rim3dView* view) +QString RimViewLinker::displayNameForView(RimGridView* view) { QString displayName = "None"; @@ -303,7 +303,7 @@ QString RimViewLinker::displayNameForView(Rim3dView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::setMasterView(Rim3dView* view) +void RimViewLinker::setMasterView(RimGridView* view) { RimViewController* previousViewController = view->viewController(); @@ -324,7 +324,7 @@ void RimViewLinker::setMasterView(Rim3dView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dView* RimViewLinker::masterView() const +RimGridView* RimViewLinker::masterView() const { return m_masterView; } @@ -332,7 +332,7 @@ Rim3dView* RimViewLinker::masterView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViews(std::vector& views) const +void RimViewLinker::allViews(std::vector& views) const { views.push_back(m_masterView()); @@ -356,7 +356,7 @@ void RimViewLinker::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateScaleZ(Rim3dView* sourceView, double scaleZ) +void RimViewLinker::updateScaleZ(RimGridView* sourceView, double scaleZ) { if (!isActive()) return; @@ -371,7 +371,7 @@ void RimViewLinker::updateScaleZ(Rim3dView* sourceView, double scaleZ) } } - std::vector views; + std::vector views; allViewsForCameraSync(sourceView, views); // Make sure scale factors are identical @@ -454,7 +454,7 @@ void RimViewLinker::scheduleCreateDisplayModelAndRedrawForDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, Rim3dView* view) +void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimGridView* view) { CVF_ASSERT(name && icon); @@ -487,7 +487,7 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, Rim3dVie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCursorPosition(const Rim3dView* sourceView, const cvf::Vec3d& domainCoord) +void RimViewLinker::updateCursorPosition(const RimGridView* sourceView, const cvf::Vec3d& domainCoord) { RimViewController* sourceViewLink = sourceView->viewController(); if (sourceViewLink && !sourceViewLink->showCursor()) @@ -495,7 +495,7 @@ void RimViewLinker::updateCursorPosition(const Rim3dView* sourceView, const cvf: return; } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); for (Rim3dView* destinationView : viewsToUpdate) @@ -521,7 +521,7 @@ void RimViewLinker::updateCursorPosition(const Rim3dView* sourceView, const cvf: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCamera(Rim3dView* sourceView) +void RimViewLinker::updateCamera(RimGridView* sourceView) { if (!sourceView->viewer()) return; @@ -536,7 +536,7 @@ void RimViewLinker::updateCamera(Rim3dView* sourceView) } } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); RimViewManipulator::applySourceViewCameraOnDestinationViews(sourceView, viewsToUpdate); @@ -545,7 +545,7 @@ void RimViewLinker::updateCamera(Rim3dView* sourceView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::addDependentView(Rim3dView* view) +void RimViewLinker::addDependentView(RimGridView* view) { CVF_ASSERT(view && view != m_masterView); diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.h b/ApplicationCode/ProjectDataModel/RimViewLinker.h index d3cfd07400..acffd56229 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.h +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.h @@ -36,7 +36,7 @@ namespace cvf class RimViewController; class RiuViewer; -class Rim3dView; +class RimGridView; class RimCellRangeFilter; //================================================================================================== @@ -53,18 +53,18 @@ class RimViewLinker : public caf::PdmObject bool isActive() const; - void setMasterView(Rim3dView* view); - Rim3dView* masterView() const; + void setMasterView(RimGridView* view); + RimGridView* masterView() const; - void addDependentView(Rim3dView* view); + void addDependentView(RimGridView* view); void updateDependentViews(); void removeViewController(RimViewController* viewController); void updateOverrides(); - void updateCamera(Rim3dView* sourceView); - void updateTimeStep(Rim3dView* sourceView, int timeStep); - void updateScaleZ(Rim3dView* sourceView, double scaleZ); + void updateCamera(RimGridView* sourceView); + void updateTimeStep(RimGridView* sourceView, int timeStep); + void updateScaleZ(RimGridView* sourceView, double scaleZ); void updateCellResult(); @@ -74,32 +74,32 @@ class RimViewLinker : public caf::PdmObject void scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType); void scheduleCreateDisplayModelAndRedrawForDependentViews(); - void allViews(std::vector& views) const; + void allViews(std::vector& views) const; void updateUiNameAndIcon(); void addViewControllers(caf::PdmUiTreeOrdering& uiTreeOrdering) const; static void applyIconEnabledState(caf::PdmObject* obj, const QIcon& icon, bool disable); - static void findNameAndIconFromView(QString* name, QIcon* icon, Rim3dView* view); + static void findNameAndIconFromView(QString* name, QIcon* icon, RimGridView* view); - void updateCursorPosition(const Rim3dView* sourceView, const cvf::Vec3d& domainCoord); + void updateCursorPosition(const RimGridView* sourceView, const cvf::Vec3d& domainCoord); public: - static QString displayNameForView(Rim3dView* view); + static QString displayNameForView(RimGridView* view); protected: virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } virtual void initAfterRead(); private: - void allViewsForCameraSync(const Rim3dView* source, std::vector& views) const; + void allViewsForCameraSync(const RimGridView* source, std::vector& views) const; void removeOverrides(); private: caf::PdmChildArrayField m_viewControllers; - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; caf::PdmField m_name; QIcon m_originalIcon; }; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp index 664c90e8e2..7cd14eda25 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp @@ -35,7 +35,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewManipulator::applySourceViewCameraOnDestinationViews(Rim3dView* sourceView, std::vector& destinationViews) +void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimGridView* sourceView, std::vector& destinationViews) { bool setPointOfInterest = false; cvf::Vec3d sourceCamUp; @@ -72,7 +72,7 @@ void RimViewManipulator::applySourceViewCameraOnDestinationViews(Rim3dView* sour sourceSceneBB.transform(trans); } - for (Rim3dView* destinationView : destinationViews) + for (RimGridView* destinationView : destinationViews) { if (!destinationView) continue; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.h b/ApplicationCode/ProjectDataModel/RimViewManipulator.h index 4263534bad..c474f58ae6 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.h +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.h @@ -24,12 +24,12 @@ namespace cvf { class BoundingBox; } -class Rim3dView; +class RimGridView; class RimViewManipulator { public: - static void applySourceViewCameraOnDestinationViews(Rim3dView* sourceView, std::vector& destinationViews); + static void applySourceViewCameraOnDestinationViews(RimGridView* sourceView, std::vector& destinationViews); private: static bool isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB, const cvf::BoundingBox& destBB); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 2d16aa7388..fdc74d6b71 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1430,8 +1430,9 @@ void RiuMainWindow::slotDrawStyleChanged(QAction* activatedAction) void RiuMainWindow::slotToggleHideGridCellsAction(bool hideGridCells) { if (!RiaApplication::instance()->activeReservoirView()) return; - - RiaApplication::instance()->activeReservoirView()->showGridCells(!hideGridCells); + + RimGridView* rigv = RiaApplication::instance()->activeGridView(); + if (rigv) rigv->showGridCells(!hideGridCells); } diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 98a63f66f0..80e99a3521 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -298,7 +298,7 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex) RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateTimeStep(dynamic_cast(m_rimView.p()), frameIndex); + viewLinker->updateTimeStep(dynamic_cast(m_rimView.p()), frameIndex); } } } @@ -630,7 +630,7 @@ void RiuViewer::navigationPolicyUpdate() RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateCamera(dynamic_cast(m_rimView.p())); + viewLinker->updateCamera(dynamic_cast(m_rimView.p())); } } } @@ -740,7 +740,7 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent) cvf::ref trans = m_rimView->displayCoordTransform(); cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord); - viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()) , domainCoord); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()) , domainCoord); } } } @@ -756,7 +756,7 @@ void RiuViewer::leaveEvent(QEvent *) if (m_rimView && m_rimView->assosiatedViewLinker()) { RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); - viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()), cvf::Vec3d::UNDEFINED); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()), cvf::Vec3d::UNDEFINED); } } From 58123f4a493152dbb3902588b02935a04e533932 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 15 Jan 2018 16:09:52 +0100 Subject: [PATCH 0072/1027] #2369 Elm props: Only delete results from the closed files --- .../RigFemPartResultsCollection.cpp | 4 +++- .../RigFemPartResultsCollection.h | 2 +- .../GeoMechDataModel/RigFemResultAddress.h | 13 +++++++++++ .../ProjectDataModel/RimGeoMechCase.cpp | 22 ++++++++++++++----- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 8e848ef113..d0ba561a41 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -135,7 +135,7 @@ void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) +std::vector RigFemPartResultsCollection::removeElementPropertyFiles(const std::vector& filenames) { std::vector addressesToRemove; @@ -155,6 +155,8 @@ void RigFemPartResultsCollection::removeElementPropertyFiles(const std::vectordeleteResult(address); } + + return addressesToRemove; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 0c47068f70..2aa854126b 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -53,7 +53,7 @@ class RigFemPartResultsCollection: public cvf::Object RigFormationNames* activeFormationNames(); void addElementPropertyFiles(const std::vector& filenames); - void removeElementPropertyFiles(const std::vector& filenames); + std::vector removeElementPropertyFiles(const std::vector& filenames); void setCalculationParameters(double cohesion, double frictionAngleRad); double parameterCohesion() const { return m_cohesion;} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index f55e9426fd..942b6e1fbb 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -98,6 +98,19 @@ class RigFemResultAddress } return (componentName < other.componentName); + } + + bool operator== (const RigFemResultAddress& other) const + { + if ( resultPosType != other.resultPosType + || fieldName != other.fieldName + || componentName != other.componentName + || timeLapseBaseFrameIdx != other.timeLapseBaseFrameIdx) + { + return false; + } + + return true; } }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index efd6fae769..d99d843920 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -557,19 +557,31 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() m_elementPropertyFileNameIndexUiSelection.v().clear(); + std::vector addressesToDelete; + if (m_geoMechCaseData.notNull()) { - geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); + addressesToDelete = geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); } for (RimGeoMechView* view : geoMechViews()) { - view->cellResult()->setResultAddress(RigFemResultAddress()); - for (RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters()) + for (RigFemResultAddress address : addressesToDelete) { - propertyFilter->resultDefinition().p()->setResultAddress(RigFemResultAddress()); + if (address == view->cellResultResultDefinition()->resultAddress()) + { + view->cellResult()->setResultAddress(RigFemResultAddress()); + } + + for (RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters()) + { + if (address == propertyFilter->resultDefinition->resultAddress()) + { + propertyFilter->resultDefinition->setResultAddress(RigFemResultAddress()); + } + } } - + view->loadDataAndUpdate(); } } From 96bff275195dc94478ab02f3541953cfac41b58c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 15 Jan 2018 17:40:39 +0100 Subject: [PATCH 0073/1027] #2372 Elm props: Map modulus and ratio ui names --- ApplicationCode/FileInterface/RifElementPropertyReader.cpp | 6 +++--- ApplicationCode/FileInterface/RifElementPropertyReader.h | 2 +- .../GeoMechDataModel/RigFemPartResultsCollection.cpp | 5 ++++- .../ProjectDataModel/RimGeoMechResultDefinition.cpp | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 6339aa8f0d..793884622e 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -68,14 +68,14 @@ void RifElementPropertyReader::removeFile(const std::string& fileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map> RifElementPropertyReader::scalarElementFields() const +std::vector RifElementPropertyReader::scalarElementFields() const { - std::map> fields; + std::vector fields; for (std::map::const_iterator field = m_fieldsMetaData.begin(); field != m_fieldsMetaData.end(); field++) { - fields[field->first]; + fields.push_back(field->first); } return fields; diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h index 2620ef96e4..34b6508d2f 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -42,7 +42,7 @@ class RifElementPropertyReader : public cvf::Object void addFile(const std::string& fileName); void removeFile(const std::string& fileName); - std::map> scalarElementFields() const; + std::vector scalarElementFields() const; std::map> readAllElementPropertiesInFileContainingField(const std::string& fieldName); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index d0ba561a41..fde4783e0d 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -451,7 +451,10 @@ std::map > RigFemPartResultsCollection::sc } else if (resPos == RIG_ELEMENT) { - fieldCompNames = m_elementPropertyReader->scalarElementFields(); + for (const std::string& field : m_elementPropertyReader->scalarElementFields()) + { + fieldCompNames[field]; + } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 0120e088db..9ff629b103 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -139,6 +139,7 @@ QList RimGeoMechResultDefinition::calculateValueOptions( if (&m_resultVariableUiField == fieldNeedingOptions) { std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; QStringList varNames; bool isNeedingTimeLapseStrings = m_isTimeLapseResultUiField() && (m_resultPositionTypeUiField() != RIG_FORMATION_NAMES); @@ -435,6 +436,8 @@ QString RimGeoMechResultDefinition::convertToUiResultFieldName(QString resultFie if (resultFieldName == "S") newName = "NativeAbaqus Stress"; if (resultFieldName == "NE") newName = "E"; // Make NE and NS appear as E and SE if (resultFieldName == "POR-Bar") newName = "POR"; // POR-Bar appear as POR + if (resultFieldName == "MODULUS") newName = "Young's Modulus"; + if (resultFieldName == "RATIO") newName = "Poisson's Ratio"; if (isTimeLapseResultList) newName += "_D" + QString::number(baseFrameIdx); From 2457f968cfa69c4f9145d339e837f2c7b4f9f92b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Jan 2018 07:54:03 +0100 Subject: [PATCH 0074/1027] #2374 Fracture : Incomplete results when computing intersected StimPlan cells --- .../ReservoirDataModel/RigWellPath.cpp | 26 ++++--- .../ReservoirDataModel/RigWellPath.h | 3 +- .../RigWellPathStimplanIntersector.cpp | 2 +- .../RigWellPathIntersectionTools-Test.cpp | 72 ++++++++++++++++++- 4 files changed, 89 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index f8b2bb072d..401160ebac 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -215,35 +215,41 @@ std::pair, std::vector > RigWellPath::clippedPoi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellPath::wellPathPointsIncludingFractureIntersection(double fractureIntersectionMD) const +std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const { std::vector points; if (m_measuredDepths.empty()) return points; - cvf::Vec3d fractureWellPathPpoint = interpolatedPointAlongWellPath(fractureIntersectionMD); + cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath(intersectionMeasuredDepth); - for (size_t i = 0; i < m_measuredDepths.size()-1; i++) + for (size_t i = 0; i < m_measuredDepths.size() - 1; i++) { - if (m_measuredDepths[i] < fractureIntersectionMD) + if (m_measuredDepths[i] == intersectionMeasuredDepth) { points.push_back(m_wellPathPoints[i]); - if (m_measuredDepths[i + 1] > fractureIntersectionMD) + } + else if (m_measuredDepths[i] < intersectionMeasuredDepth) + { + points.push_back(m_wellPathPoints[i]); + if (m_measuredDepths[i + 1] > intersectionMeasuredDepth) { - points.push_back(fractureWellPathPpoint); + points.push_back(interpolatedWellPathPoint); } } - else if (m_measuredDepths[i] < fractureIntersectionMD) + else if (m_measuredDepths[i] > intersectionMeasuredDepth) { if (i == 0) { - points.push_back(fractureWellPathPpoint); + points.push_back(interpolatedWellPathPoint); + } + else + { + points.push_back(m_wellPathPoints[i]); } - points.push_back(m_wellPathPoints[i]); } } points.push_back(m_wellPathPoints.back()); return points; - } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index 9f66d4d68a..94f39b026b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -47,7 +47,8 @@ class RigWellPath : public cvf::Object std::pair, std::vector > clippedPointSubset(double startMD, double endMD) const; - std::vector wellPathPointsIncludingFractureIntersection(double fractureIntersectionMD) const; + std::vector wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const; + private: bool m_hasDatumElevation; double m_datumElevation; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp index 44eb2181d3..46c7c821c3 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp @@ -37,7 +37,7 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, RimFracture* rimFracture) { - std::vector wellPathPoints = wellpathGeom->wellPathPointsIncludingFractureIntersection(rimFracture->fractureMD()); + std::vector wellPathPoints = wellpathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(rimFracture->fractureMD()); cvf::Mat4d fractureXf = rimFracture->transformMatrix(); double wellRadius = rimFracture->wellRadius(rimFracture->fractureUnit()); std::vector > stpCellPolygons; diff --git a/ApplicationCode/UnitTests/RigWellPathIntersectionTools-Test.cpp b/ApplicationCode/UnitTests/RigWellPathIntersectionTools-Test.cpp index 2ae678cf1f..777057a2ae 100644 --- a/ApplicationCode/UnitTests/RigWellPathIntersectionTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigWellPathIntersectionTools-Test.cpp @@ -18,7 +18,75 @@ #include "gtest/gtest.h" -#include "RigWellPathIntersectionTools.h" +#include "RigWellPath.h" -#include "cvfStructGrid.h" +#include "cvfBase.h" +#include "cvfVector3.h" + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigWellPathTest, FindWellPathCoordsIncludingIntersectionPoint) +{ + RigWellPath wellPathGeometry; + { + std::vector wellPathPoints; + std::vector mdValues; + + wellPathPoints.push_back(cvf::Vec3d(0.0, 0.0, 0.0)); + wellPathPoints.push_back(cvf::Vec3d(0.0, 1.0, 0.0)); + wellPathPoints.push_back(cvf::Vec3d(0.0, 2.0, 0.0)); + wellPathPoints.push_back(cvf::Vec3d(0.0, 3.0, 0.0)); + wellPathPoints.push_back(cvf::Vec3d(0.0, 4.0, 0.0)); + + mdValues.push_back(0.0); + mdValues.push_back(1.0); + mdValues.push_back(2.0); + mdValues.push_back(3.0); + mdValues.push_back(4.0); + + + wellPathGeometry.m_wellPathPoints = wellPathPoints; + wellPathGeometry.m_measuredDepths = mdValues; + } + + // Before first MD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(-1.0); + EXPECT_EQ(5u, wellPathPoints.size()); + } + + // Identical to first MD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(0.0); + EXPECT_EQ(5u, wellPathPoints.size()); + } + + // Identical to second MD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(1.0); + EXPECT_EQ(5u, wellPathPoints.size()); + } + + // Between first and second MD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(0.3); + EXPECT_EQ(6u, wellPathPoints.size()); + } + + // Identical to lastMD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(4.0); + EXPECT_EQ(5u, wellPathPoints.size()); + } + + // Larger than lastMD + { + auto wellPathPoints = wellPathGeometry.wellPathPointsIncludingInterpolatedIntersectionPoint(10.0); + EXPECT_EQ(5u, wellPathPoints.size()); + } +} From 424c6a46f641e82c990778d78ee88f583383944a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Jan 2018 08:02:40 +0100 Subject: [PATCH 0075/1027] Whitespace and function headers, move implementation to header --- .../RigWellPathStimplanIntersector.cpp | 17 +++++++++++++---- .../RigWellPathStimplanIntersector.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp index 46c7c821c3..f58a771c22 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp @@ -35,7 +35,10 @@ #include -RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, RimFracture* rimFracture) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture) { std::vector wellPathPoints = wellpathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(rimFracture->fractureMD()); cvf::Mat4d fractureXf = rimFracture->transformMatrix(); @@ -53,13 +56,19 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath double perforationLength = rimFracture->perforationLength(); calculate(fractureXf, wellPathPoints, wellRadius, perforationLength, stpCellPolygons, m_stimPlanCellIdxToIntersectionInfoMap); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map& RigWellPathStimplanIntersector::intersections() const +{ + return m_stimPlanCellIdxToIntersectionInfoMap; } //-------------------------------------------------------------------------------------------------- /// Todo: Use only the perforated parts of the well path //-------------------------------------------------------------------------------------------------- - void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, const std::vector& wellPathPointsOrg, double wellRadius, @@ -178,7 +187,7 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, currentIntersectingWpPart.push_back(part.back()); } - if ( currentIntersectingWpPart.size() ) + if ( !currentIntersectingWpPart.empty() ) { intersectingWellPathParts.push_back(currentIntersectingWpPart); } @@ -197,7 +206,7 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, RigCellGeometryTools::USE_HUGEVAL); for ( const auto& wellPathPartInCell: wellPathPartsInPolygon ) { - if ( wellPathPartInCell.size() ) + if ( !wellPathPartInCell.empty() ) { int endpointCount = 0; if ( wellPathPartInCell.front().z() != HUGE_VAL ) ++endpointCount; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h index cbfa003e8e..dc5d38e823 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h @@ -29,6 +29,9 @@ class RimFracture; class RigWellPathStimplanIntersectorTester; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigWellPathStimplanIntersector { public: @@ -40,9 +43,9 @@ class RigWellPathStimplanIntersector int endpointCount; }; - RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, RimFracture * rimFracture); + RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture); - const std::map& intersections() { return m_stimPlanCellIdxToIntersectionInfoMap; } + const std::map& intersections() const; private: friend class RigWellPathStimplanIntersectorTester; @@ -57,6 +60,9 @@ class RigWellPathStimplanIntersector }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigWellPathStimplanIntersectorTester { public: From b1cf7f6674f3bebb81d5c6b72e8797279ea70e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 16 Jan 2018 08:44:15 +0100 Subject: [PATCH 0076/1027] #2331 Cleaned up whitespace. Made crossectionCollection protected --- .../RicNewAzimuthDipIntersectionFeature.cpp | 2 +- .../RicNewPolylineIntersectionFeature.cpp | 2 +- .../RicNewSimWellIntersectionFeature.cpp | 2 +- .../RicNewWellPathIntersectionFeature.cpp | 2 +- .../ProjectDataModel/Rim3dView.cpp | 18 +++-- ApplicationCode/ProjectDataModel/Rim3dView.h | 72 +++++++++---------- .../ProjectDataModel/RimEclipseView.cpp | 8 +-- .../ProjectDataModel/RimGeoMechView.cpp | 12 ++-- 8 files changed, 60 insertions(+), 58 deletions(-) diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 6addd85669..cb869f1a26 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -64,7 +64,7 @@ void RicNewAzimuthDipIntersectionFeature::onActionTriggered(bool isChecked) RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection); + RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection()); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index 5ce3ae705b..7652bc9902 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -63,7 +63,7 @@ void RicNewPolylineIntersectionFeature::onActionTriggered(bool isChecked) RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection); + RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection()); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp index 2d20fd4ba3..95caabd24f 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp @@ -56,7 +56,7 @@ void RicNewSimWellIntersectionFeature::onActionTriggered(bool isChecked) simWell->firstAncestorOrThisOfType(eclView); CVF_ASSERT(eclView); - RicNewSimWellIntersectionCmd* cmd = new RicNewSimWellIntersectionCmd(eclView->crossSectionCollection, simWell); + RicNewSimWellIntersectionCmd* cmd = new RicNewSimWellIntersectionCmd(eclView->crossSectionCollection(), simWell); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index 14386ba0d9..4b78ad8591 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -65,7 +65,7 @@ void RicNewWellPathIntersectionFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = collection[0]; - RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd(activeView->crossSectionCollection, wellPath); + RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd(activeView->crossSectionCollection(), wellPath); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index e20475cc5e..c37abaa1be 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -873,9 +873,9 @@ RimGridView::RimGridView() m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); - crossSectionCollection.uiCapability()->setUiHidden(true); - crossSectionCollection = new RimIntersectionCollection(); + CAF_PDM_InitFieldNoDefault(&m_crossSectionCollection, "CrossSections", "Intersections", "", "", ""); + m_crossSectionCollection.uiCapability()->setUiHidden(true); + m_crossSectionCollection = new RimIntersectionCollection(); CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); m_gridCollection.uiCapability()->setUiHidden(true); @@ -918,7 +918,7 @@ RimGridView::~RimGridView(void) delete m_rangeFilterCollection; delete m_overrideRangeFilterCollection; - delete crossSectionCollection; + delete m_crossSectionCollection; delete m_gridCollection; } @@ -958,6 +958,14 @@ cvf::ref RimGridView::currentTotalCellVisibility() return m_currentReservoirCellVisibility; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* RimGridView::crossSectionCollection() const +{ + return m_crossSectionCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1114,7 +1122,7 @@ void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons { if ( changedField == &scaleZ ) { - crossSectionCollection->updateIntersectionBoxGeometry(); + m_crossSectionCollection->updateIntersectionBoxGeometry(); } Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 037bde6a37..154aeb53ae 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -135,7 +135,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual RimCase* ownerCase() const = 0; protected: - void setDefaultView(); RimWellPathCollection* wellPathCollection(); @@ -167,14 +166,14 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual void resetLegendsInViewer() = 0; protected: // Fields - caf::PdmField m_currentTimeStep; + caf::PdmField m_currentTimeStep; protected: - QPointer m_viewer; + QPointer m_viewer; - cvf::ref m_wellPathPipeVizModel; - cvf::ref m_crossSectionVizModel; - cvf::ref m_highlightVizModel; + cvf::ref m_wellPathPipeVizModel; + cvf::ref m_crossSectionVizModel; + cvf::ref m_highlightVizModel; private: // Overridden PdmObject methods: @@ -220,43 +219,40 @@ class RimGridView : public Rim3dView public: RimGridView(); virtual ~RimGridView(void); -#if 1 - - caf::PdmChildField crossSectionCollection; - - void showGridCells(bool enableGridCells); - - cvf::ref currentTotalCellVisibility(); - - virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; - RimCellRangeFilterCollection* rangeFilterCollection(); - const RimCellRangeFilterCollection* rangeFilterCollection() const; - - bool hasOverridenRangeFilterCollection(); - void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); - void replaceRangeFilterCollectionWithOverride(); - - RimViewController* viewController() const override; - RimViewLinker* assosiatedViewLinker() const override; - - Rim3dOverlayInfoConfig* overlayInfoConfig() const; -protected: - static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - - virtual void onTimeStepChanged() override; - - virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void selectOverlayInfoConfig() override; + void showGridCells(bool enableGridCells); + + Rim3dOverlayInfoConfig* overlayInfoConfig() const; + + cvf::ref currentTotalCellVisibility(); + + RimIntersectionCollection* crossSectionCollection() const; + + virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; + RimCellRangeFilterCollection* rangeFilterCollection(); + const RimCellRangeFilterCollection* rangeFilterCollection() const; + + bool hasOverridenRangeFilterCollection(); + void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); + void replaceRangeFilterCollectionWithOverride(); + + RimViewController* viewController() const override; + RimViewLinker* assosiatedViewLinker() const override; + +protected: + static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); + + virtual void onTimeStepChanged() override; + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; + virtual void selectOverlayInfoConfig() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; protected: // Fields + caf::PdmChildField m_crossSectionCollection; caf::PdmChildField m_overlayInfoConfig; - caf::PdmChildField m_rangeFilterCollection; caf::PdmChildField m_overrideRangeFilterCollection; - caf::PdmChildField m_gridCollection; protected: @@ -265,6 +261,4 @@ class RimGridView : public Rim3dView private: RimViewLinker* viewLinkerIfMasterView() const; bool m_previousGridModeMeshLinesWasFaults; - -#endif }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index ee1a547c46..a11c0b488b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -425,7 +425,7 @@ void RimEclipseView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); + m_crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); @@ -654,11 +654,11 @@ void RimEclipseView::updateCurrentTimeStep() if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) { - crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); } else { - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); } if (m_viewer) @@ -1474,7 +1474,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(wellCollection()); uiTreeOrdering.add(faultCollection()); - uiTreeOrdering.add(crossSectionCollection()); + uiTreeOrdering.add(m_crossSectionCollection()); uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index c56cb95534..844ada1509 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -221,7 +221,7 @@ void RimGeoMechView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), scaleTransform()); + m_crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); // If the animation was active before recreating everything, make viewer view current frame @@ -234,7 +234,7 @@ void RimGeoMechView::createDisplayModel() { updateLegends(); m_vizLogic->updateStaticCellColors(-1); - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); m_overlayInfoConfig()->update3DInfo(); } @@ -290,18 +290,18 @@ void RimGeoMechView::updateCurrentTimeStep() if (this->cellResult()->hasResult()) { - crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); } else { - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); } } else { m_vizLogic->updateStaticCellColors(-1); - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background } @@ -650,7 +650,7 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(cellResult()); - uiTreeOrdering.add(crossSectionCollection()); + uiTreeOrdering.add(m_crossSectionCollection()); uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); From 0debeafd68ca18eb5e917bfc441aaf2f2c525e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 16 Jan 2018 09:37:08 +0100 Subject: [PATCH 0077/1027] #2331 Move RimGridView to separate files --- .../RicAppendIntersectionFeature.cpp | 2 +- .../RicNewAzimuthDipIntersectionFeature.cpp | 2 +- .../RicNewPolylineIntersectionFeature.cpp | 2 +- .../RicNewWellPathIntersectionFeature.cpp | 2 +- .../RicEclipsePropertyFilterNewExec.cpp | 2 +- .../RicSnapshotAllViewsToFileFeature.cpp | 2 +- .../RicAppendIntersectionBoxFeature.cpp | 2 +- .../RicIntersectionBoxAtPosFeature.cpp | 2 +- .../RicIntersectionBoxXSliceFeature.cpp | 2 +- .../RicIntersectionBoxYSliceFeature.cpp | 2 +- .../RicIntersectionBoxZSliceFeature.cpp | 2 +- .../RicNewSliceRangeFilterFeature.cpp | 2 +- .../Commands/RicRangeFilterFeatureImpl.cpp | 2 +- .../Commands/RicRangeFilterNewExec.cpp | 2 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 2 +- .../ViewLink/RicLinkVisibleViewsFeatureUi.cpp | 2 +- .../ViewLink/RicSetMasterViewFeature.cpp | 2 +- .../ViewLink/RicShowAllLinkedViewsFeature.cpp | 2 +- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dView.cpp | 333 +--------------- ApplicationCode/ProjectDataModel/Rim3dView.h | 50 --- .../ProjectDataModel/RimEclipseView.h | 2 +- .../ProjectDataModel/RimGeoMechView.h | 2 +- .../ProjectDataModel/RimGridCollection.cpp | 2 +- .../ProjectDataModel/RimGridView.cpp | 356 ++++++++++++++++++ .../ProjectDataModel/RimGridView.h | 73 ++++ ApplicationCode/UserInterface/RiuViewer.cpp | 2 +- 27 files changed, 455 insertions(+), 403 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimGridView.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimGridView.h diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index baf007f1ba..f45723f67f 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -21,7 +21,7 @@ #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index cb869f1a26..ac575c9812 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index 7652bc9902..63fa17ff6e 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index 4b78ad8591..10395e3d04 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimIntersection.h" #include "RimIntersectionCollection.h" #include "RimWellPath.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index 256f7c9ffc..72db768450 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -23,7 +23,7 @@ #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 82acb088ac..bedff2daea 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -25,7 +25,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimCase.h" #include "Rim3dOverlayInfoConfig.h" diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index 0a7a89d0fb..f6cd3d4b9c 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -21,7 +21,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "cafCmdExecCommandManager.h" diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp index 9237a9e492..3bc9360eb2 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index a13e4c7fae..f16c17d9ce 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index 52bd2531c0..3476c42529 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index 1cbf78f737..0af08f733f 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" diff --git a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp index 084798ce65..f3262f58a5 100644 --- a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp +++ b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp @@ -23,7 +23,7 @@ #include "RicRangeFilterFeatureImpl.h" #include "RicRangeFilterNewExec.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "cafCmdExecCommandManager.h" diff --git a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp index b2587b6a61..92c19e2b09 100644 --- a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp @@ -25,7 +25,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index 4e1e07e83c..1e931dbfd6 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -23,7 +23,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index c48723eca0..bbef140ede 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -25,7 +25,7 @@ #include "RimViewController.h" #include "RimProject.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp index 8d38bd3bfc..1862ec6021 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimCase.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewLinker.h" CAF_PDM_SOURCE_INIT(RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi"); diff --git a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index d4ea41f61e..fd1c608383 100644 --- a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" diff --git a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index 2ea4ce0366..ea83e2387e 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -20,7 +20,7 @@ #include "RicShowAllLinkedViewsFeature.h" #include "RimViewController.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewLinker.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 4b13d70ed9..aa7d17564b 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -60,6 +60,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h ${CEE_CURRENT_LIST_DIR}RimViewWindow.h ${CEE_CURRENT_LIST_DIR}Rim3dView.h +${CEE_CURRENT_LIST_DIR}RimGridView.h ${CEE_CURRENT_LIST_DIR}RimViewManipulator.h ${CEE_CURRENT_LIST_DIR}RimCase.h ${CEE_CURRENT_LIST_DIR}RimViewController.h @@ -161,6 +162,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp ${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp ${CEE_CURRENT_LIST_DIR}Rim3dView.cpp +${CEE_CURRENT_LIST_DIR}RimGridView.cpp ${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp ${CEE_CURRENT_LIST_DIR}RimCase.cpp ${CEE_CURRENT_LIST_DIR}RimViewController.cpp diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index c37abaa1be..48c357851a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -23,19 +23,13 @@ #include "RiaPreferences.h" #include "RiaViewRedrawScheduler.h" -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellRangeFilterCollection.h" #include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimGridCollection.h" -#include "RimIntersectionCollection.h" +#include "RimGridView.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimPropertyFilterCollection.h" #include "RimViewController.h" #include "RimViewLinker.h" -#include "RimViewLinkerCollection.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -44,20 +38,15 @@ #include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" -#include "cafPdmObjectFactory.h" #include "cvfCamera.h" -#include "cvfModel.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfScene.h" +#include "cvfTransform.h" #include "cvfViewport.h" #include -#include -#include "cvfTransform.h" - namespace caf { @@ -854,321 +843,3 @@ void Rim3dView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - - -CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. Abstract class - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGridView::RimGridView() -{ - - CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); - m_rangeFilterCollection.uiCapability()->setUiHidden(true); - m_rangeFilterCollection = new RimCellRangeFilterCollection(); - - CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); - m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); - m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); - m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - - CAF_PDM_InitFieldNoDefault(&m_crossSectionCollection, "CrossSections", "Intersections", "", "", ""); - m_crossSectionCollection.uiCapability()->setUiHidden(true); - m_crossSectionCollection = new RimIntersectionCollection(); - - CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); - m_gridCollection.uiCapability()->setUiHidden(true); - m_gridCollection = new RimGridCollection(); - - m_previousGridModeMeshLinesWasFaults = false; - - CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); - m_overlayInfoConfig->setReservoirView(this); - m_overlayInfoConfig.uiCapability()->setUiHidden(true); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGridView::~RimGridView(void) -{ - RimProject* proj = RiaApplication::instance()->project(); - - if (proj && this->isMasterView()) - { - delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = NULL; - - proj->uiCapability()->updateConnectedEditors(); - } - - RimViewController* vController = this->viewController(); - if (proj && vController) - { - vController->setManagedView(NULL); - vController->ownerViewLinker()->removeViewController(vController); - delete vController; - - proj->uiCapability()->updateConnectedEditors(); - } - - delete this->m_overlayInfoConfig(); - - delete m_rangeFilterCollection; - delete m_overrideRangeFilterCollection; - delete m_crossSectionCollection; - delete m_gridCollection; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::showGridCells(bool enableGridCells) -{ - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } - - m_gridCollection->isActive = enableGridCells; - m_gridCollection->updateConnectedEditors(); - m_gridCollection->updateUiIconFromState(enableGridCells); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RimGridView::currentTotalCellVisibility() -{ - if (m_currentReservoirCellVisibility.isNull()) - { - m_currentReservoirCellVisibility = new cvf::UByteArray; - this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); - } - - return m_currentReservoirCellVisibility; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimIntersectionCollection* RimGridView::crossSectionCollection() const -{ - return m_crossSectionCollection(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const -{ - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimGridView::hasOverridenRangeFilterCollection() -{ - return m_overrideRangeFilterCollection() != NULL; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) -{ - if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); - - m_overrideRangeFilterCollection = rfc; - this->scheduleGeometryRegen(RANGE_FILTERED); - this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); - - this->scheduleCreateDisplayModelAndRedraw(); -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::replaceRangeFilterCollectionWithOverride() -{ - RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; - CVF_ASSERT(overrideRfc); - - RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; - if (currentRfc) - { - delete currentRfc; - } - - // Must call removeChildObject() to make sure the object has no parent - // No parent is required when assigning a object into a field - m_overrideRangeFilterCollection.removeChildObject(overrideRfc); - - m_rangeFilterCollection = overrideRfc; - - this->uiCapability()->updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewController* RimGridView::viewController() const -{ - RimViewController* viewController = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewController = dynamic_cast(reffingObjs[i]); - if (viewController) break; - } - - return viewController; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* RimGridView::assosiatedViewLinker() const -{ - RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); - if (!viewLinker) - { - RimViewController* viewController = this->viewController(); - if (viewController) - { - viewLinker = viewController->ownerViewLinker(); - } - } - - return viewLinker; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const -{ - return m_overlayInfoConfig; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) -{ - std::vector modelsToBeRemoved; - for (cvf::uint i = 0; i < scene->modelCount(); i++) - { - if (scene->model(i)->name() == modelName) - { - modelsToBeRemoved.push_back(scene->model(i)); - } - } - - for (size_t i = 0; i < modelsToBeRemoved.size(); i++) - { - scene->removeModel(modelsToBeRemoved[i]); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::onTimeStepChanged() -{ - if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) - { - m_currentReservoirCellVisibility = NULL; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if ( changedField == &scaleZ ) - { - m_crossSectionCollection->updateIntersectionBoxGeometry(); - } - - Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); - - if ( changedField == &scaleZ ) - { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if ( viewLinker ) - { - viewLinker->updateScaleZ(this, scaleZ); - viewLinker->updateCamera(this); - } - } - else if ( changedField == &m_currentTimeStep ) - { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if ( viewLinker ) - { - viewLinker->updateTimeStep(this, m_currentTimeStep); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::selectOverlayInfoConfig() -{ - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewLinker* RimGridView::viewLinkerIfMasterView() const -{ - RimViewLinker* viewLinker = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewLinker = dynamic_cast(reffingObjs[i]); - if (viewLinker) break; - } - - return viewLinker; -} diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 154aeb53ae..c976092bea 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -212,53 +212,3 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface caf::PdmField showGridBox; }; - -class RimGridView : public Rim3dView -{ - CAF_PDM_HEADER_INIT; -public: - RimGridView(); - virtual ~RimGridView(void); - - void showGridCells(bool enableGridCells); - - Rim3dOverlayInfoConfig* overlayInfoConfig() const; - - cvf::ref currentTotalCellVisibility(); - - RimIntersectionCollection* crossSectionCollection() const; - - virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; - RimCellRangeFilterCollection* rangeFilterCollection(); - const RimCellRangeFilterCollection* rangeFilterCollection() const; - - bool hasOverridenRangeFilterCollection(); - void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); - void replaceRangeFilterCollectionWithOverride(); - - RimViewController* viewController() const override; - RimViewLinker* assosiatedViewLinker() const override; - -protected: - static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - - virtual void onTimeStepChanged() override; - virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; - virtual void selectOverlayInfoConfig() override; - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - -protected: // Fields - caf::PdmChildField m_crossSectionCollection; - caf::PdmChildField m_overlayInfoConfig; - caf::PdmChildField m_rangeFilterCollection; - caf::PdmChildField m_overrideRangeFilterCollection; - caf::PdmChildField m_gridCollection; - -protected: - cvf::ref m_currentReservoirCellVisibility; - -private: - RimViewLinker* viewLinkerIfMasterView() const; - bool m_previousGridModeMeshLinesWasFaults; -}; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 47d3e3b5ce..5e661a3ac6 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -33,7 +33,7 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" -#include "Rim3dView.h" +#include "RimGridView.h" class RigActiveCellInfo; class RigCaseCellResultsData; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index fdb7a14835..1fda4ecb78 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -19,7 +19,7 @@ #pragma once -#include "Rim3dView.h" +#include "RimGridView.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 04c3bc31ea..50a30d6bf4 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGridCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" CAF_PDM_SOURCE_INIT(RimGridCollection, "GridCollection"); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp new file mode 100644 index 0000000000..489e663ed5 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -0,0 +1,356 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridView.h" + +#include "RiaApplication.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RimCellRangeFilterCollection.h" +#include "RimGridCollection.h" +#include "RimIntersectionCollection.h" +#include "RimProject.h" +#include "RimPropertyFilterCollection.h" +#include "RimViewController.h" +#include "RimViewLinker.h" +#include "RimViewLinkerCollection.h" + +#include "RiuMainWindow.h" + +#include "cvfModel.h" +#include "cvfScene.h" + + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::RimGridView() +{ + + CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); + m_rangeFilterCollection.uiCapability()->setUiHidden(true); + m_rangeFilterCollection = new RimCellRangeFilterCollection(); + + CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); + m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); + m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); + m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&m_crossSectionCollection, "CrossSections", "Intersections", "", "", ""); + m_crossSectionCollection.uiCapability()->setUiHidden(true); + m_crossSectionCollection = new RimIntersectionCollection(); + + CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); + m_gridCollection.uiCapability()->setUiHidden(true); + m_gridCollection = new RimGridCollection(); + + m_previousGridModeMeshLinesWasFaults = false; + + CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); + m_overlayInfoConfig->setReservoirView(this); + m_overlayInfoConfig.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::~RimGridView(void) +{ + RimProject* proj = RiaApplication::instance()->project(); + + if (proj && this->isMasterView()) + { + delete proj->viewLinkerCollection->viewLinker(); + proj->viewLinkerCollection->viewLinker = NULL; + + proj->uiCapability()->updateConnectedEditors(); + } + + RimViewController* vController = this->viewController(); + if (proj && vController) + { + vController->setManagedView(NULL); + vController->ownerViewLinker()->removeViewController(vController); + delete vController; + + proj->uiCapability()->updateConnectedEditors(); + } + + delete this->m_overlayInfoConfig(); + + delete m_rangeFilterCollection; + delete m_overrideRangeFilterCollection; + delete m_crossSectionCollection; + delete m_gridCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::showGridCells(bool enableGridCells) +{ + if (!enableGridCells) + { + m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); + } + else + { + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); + if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); + } + + m_gridCollection->isActive = enableGridCells; + m_gridCollection->updateConnectedEditors(); + m_gridCollection->updateUiIconFromState(enableGridCells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimGridView::currentTotalCellVisibility() +{ + if (m_currentReservoirCellVisibility.isNull()) + { + m_currentReservoirCellVisibility = new cvf::UByteArray; + this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); + } + + return m_currentReservoirCellVisibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* RimGridView::crossSectionCollection() const +{ + return m_crossSectionCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::hasOverridenRangeFilterCollection() +{ + return m_overrideRangeFilterCollection() != NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) +{ + if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); + + m_overrideRangeFilterCollection = rfc; + this->scheduleGeometryRegen(RANGE_FILTERED); + this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + this->scheduleCreateDisplayModelAndRedraw(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::replaceRangeFilterCollectionWithOverride() +{ + RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; + CVF_ASSERT(overrideRfc); + + RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; + if (currentRfc) + { + delete currentRfc; + } + + // Must call removeChildObject() to make sure the object has no parent + // No parent is required when assigning a object into a field + m_overrideRangeFilterCollection.removeChildObject(overrideRfc); + + m_rangeFilterCollection = overrideRfc; + + this->uiCapability()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewController* RimGridView::viewController() const +{ + RimViewController* viewController = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewController = dynamic_cast(reffingObjs[i]); + if (viewController) break; + } + + return viewController; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::assosiatedViewLinker() const +{ + RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); + if (!viewLinker) + { + RimViewController* viewController = this->viewController(); + if (viewController) + { + viewLinker = viewController->ownerViewLinker(); + } + } + + return viewLinker; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const +{ + return m_overlayInfoConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +{ + std::vector modelsToBeRemoved; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == modelName) + { + modelsToBeRemoved.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + { + scene->removeModel(modelsToBeRemoved[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::onTimeStepChanged() +{ + if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) + { + m_currentReservoirCellVisibility = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if ( changedField == &scaleZ ) + { + m_crossSectionCollection->updateIntersectionBoxGeometry(); + } + + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); + + if ( changedField == &scaleZ ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateScaleZ(this, scaleZ); + viewLinker->updateCamera(this); + } + } + else if ( changedField == &m_currentTimeStep ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateTimeStep(this, m_currentTimeStep); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::selectOverlayInfoConfig() +{ + RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::viewLinkerIfMasterView() const +{ + RimViewLinker* viewLinker = NULL; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewLinker = dynamic_cast(reffingObjs[i]); + if (viewLinker) break; + } + + return viewLinker; +} + + diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h new file mode 100644 index 0000000000..f4fc95f086 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dView.h" + +class RimGridView : public Rim3dView +{ + CAF_PDM_HEADER_INIT; +public: + RimGridView(); + virtual ~RimGridView(void); + + void showGridCells(bool enableGridCells); + + Rim3dOverlayInfoConfig* overlayInfoConfig() const; + + cvf::ref currentTotalCellVisibility(); + + RimIntersectionCollection* crossSectionCollection() const; + + virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; + RimCellRangeFilterCollection* rangeFilterCollection(); + const RimCellRangeFilterCollection* rangeFilterCollection() const; + + bool hasOverridenRangeFilterCollection(); + void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); + void replaceRangeFilterCollectionWithOverride(); + + RimViewController* viewController() const override; + RimViewLinker* assosiatedViewLinker() const override; + +protected: + static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); + + virtual void onTimeStepChanged() override; + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; + virtual void selectOverlayInfoConfig() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + +protected: // Fields + caf::PdmChildField m_crossSectionCollection; + caf::PdmChildField m_overlayInfoConfig; + caf::PdmChildField m_rangeFilterCollection; + caf::PdmChildField m_overrideRangeFilterCollection; + caf::PdmChildField m_gridCollection; + +protected: + cvf::ref m_currentReservoirCellVisibility; + +private: + RimViewLinker* viewLinkerIfMasterView() const; + bool m_previousGridModeMeshLinesWasFaults; +}; + + diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 80e99a3521..4b986c0ef1 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -26,7 +26,7 @@ #include "RimCase.h" #include "RimProject.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "RimViewLinker.h" From c3c2f3b75a7ee9153c1d8080f58e48634050b64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 16 Jan 2018 10:36:41 +0100 Subject: [PATCH 0078/1027] Fix missing include --- ApplicationCode/ProjectDataModel/RimProject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 5839385b2b..10898f4bda 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -58,7 +58,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" -#include "Rim3dView.h" +#include "RimGridView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimWellLogFile.h" From 305e2aee382fb8bd8a44646e0ec4c42d5f13c82a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 16 Jan 2018 10:08:17 +0100 Subject: [PATCH 0079/1027] #2372 Elm Props: Add unit [GPA] to Modulus --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 844ada1509..f7e85526f9 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -443,6 +443,11 @@ void RimGeoMechView::updateLegends() legendTitle += " [Bar]"; } + if (cellResult->resultFieldName() == "MODULUS") + { + legendTitle += " [GPa]"; + } + cellResult()->legendConfig->setTitle(legendTitle); } From dcff8c153673b985ee5b344d58dc7e372bfd950b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 16 Jan 2018 10:18:15 +0100 Subject: [PATCH 0080/1027] #2372 Elm Props: Scale Modulus by a factor of 1e-9 --- .../RifElementPropertyReader.cpp | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp index 793884622e..f3a339308c 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -72,10 +72,9 @@ std::vector RifElementPropertyReader::scalarElementFields() const { std::vector fields; - for (std::map::const_iterator field = m_fieldsMetaData.begin(); - field != m_fieldsMetaData.end(); field++) + for (const std::pair& field : m_fieldsMetaData) { - fields.push_back(field->first); + fields.push_back(field.first); } return fields; @@ -111,7 +110,23 @@ std::map> for (size_t i = 0; i < table.data.size(); i++) { const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); - fieldAndData[currentFieldFromFile] = table.data[i]; + + if (currentFieldFromFile == "MODULUS") + { + const std::vector& currentColumn = table.data[i]; + std::vector tempResult(currentColumn.size(), 0); + + for (float resultItem : currentColumn) + { + tempResult[i] = resultItem * 0.000000001; + } + + fieldAndData[currentFieldFromFile].swap(tempResult); + } + else + { + fieldAndData[currentFieldFromFile] = table.data[i]; + } } } else if (elementIdsFromFile.size() > m_elementIdxToId.size() && elementIdsFromFile.size() > m_elementIdToIdx.size()) @@ -121,7 +136,7 @@ std::map> } else { - if (m_elementIdToIdx.size() == 0) + if (m_elementIdToIdx.empty()) { makeElementIdToIdxMap(); } @@ -129,9 +144,9 @@ std::map> std::vector fileIdxToElementIdx; fileIdxToElementIdx.reserve(elementIdsFromFile.size()); - for (size_t i = 0; i < elementIdsFromFile.size(); i++) + for (int elementId : elementIdsFromFile) { - std::unordered_map::const_iterator it = m_elementIdToIdx.find(elementIdsFromFile[i]); + std::unordered_map::const_iterator it = m_elementIdToIdx.find(elementId); if (it == m_elementIdToIdx.end()) { RifElementPropertyReader::outputWarningAboutWrongFileData(); @@ -144,14 +159,24 @@ std::map> for (size_t i = 0; i < table.data.size(); i++) { std::string currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); - + const std::vector& currentColumn = table.data[i]; std::vector tempResult(m_elementIdToIdx.size(), HUGE_VAL); - for (size_t j = 0; j < currentColumn.size(); j++) + if (currentFieldFromFile == "MODULUS") + { + for (size_t j = 0; j < currentColumn.size(); j++) + { + tempResult[fileIdxToElementIdx[j]] = currentColumn[j] * 0.000000001; + } + } + else { - tempResult[fileIdxToElementIdx[j]] = currentColumn[j]; + for (size_t j = 0; j < currentColumn.size(); j++) + { + tempResult[fileIdxToElementIdx[j]] = currentColumn[j]; + } } fieldAndData[currentFieldFromFile].swap(tempResult); From d283f2c73397f0d88fe19b48b9b60251e366923a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 16 Jan 2018 11:21:02 +0100 Subject: [PATCH 0081/1027] Fix linux compile issue --- ApplicationCode/ProjectDataModel/Rim3dView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 48c357851a..ccfd7c3189 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -46,6 +46,7 @@ #include "cvfViewport.h" #include +#include namespace caf { From 735165bb2bc91f5800a34909e6a75d86051329b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 16 Jan 2018 13:37:57 +0100 Subject: [PATCH 0082/1027] #2379 import summary cases. Fixed dialog issues --- .../Commands/RicFileHierarchyDialog.cpp | 159 ++++++++++++++---- .../Commands/RicFileHierarchyDialog.h | 55 ++++-- .../Commands/RicImportSummaryCasesFeature.cpp | 6 +- .../Commands/RicImportSummaryCasesFeature.h | 6 + 4 files changed, 171 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 0f039a642a..2e2c474269 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -61,10 +62,18 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_fileFilterLabel = new QLabel(); m_fileFilter = new QLineEdit(); m_fileExtension = new QLabel(); + m_effectiveFilterLabel = new QLabel(); + m_effectiveFilter = new QLabel(); + m_fileListLabel = new QLabel(); + m_fileList = new QTextEdit(); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); // Connect to close button signal + connect(m_rootDir, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_pathFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_fileFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); connect(m_browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked())); @@ -72,23 +81,15 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) // Set widget properties m_rootDirLabel->setText("Root folder"); m_pathFilterLabel->setText("Path pattern"); - m_pathFilter->setText("*"); m_fileFilterLabel->setText("File pattern"); + m_effectiveFilterLabel->setText("Effective filter"); + m_fileListLabel->setText("Files found"); + m_fileList->setLineWrapMode(QTextEdit::NoWrap); m_browseButton->setText("..."); - m_browseButton->setFixedWidth(25); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); - //dialogLayout->addWidget(m_rootDirLabel); - //dialogLayout->addWidget(m_rootDir); - //dialogLayout->addWidget(m_browseButton); - //dialogLayout->addWidget(m_pathFilterLabel); - //dialogLayout->addWidget(m_pathFilter); - //dialogLayout->addWidget(m_fileFilterLabel); - //dialogLayout->addWidget(m_fileFilter); - //dialogLayout->addWidget(m_fileExtension); - //dialogLayout->addWidget(m_buttons); QGridLayout* gridLayout = new QGridLayout(); gridLayout->addWidget(m_rootDirLabel, 0, 0); @@ -99,6 +100,10 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) gridLayout->addWidget(m_fileFilterLabel, 2, 0); gridLayout->addWidget(m_fileFilter, 2, 1); gridLayout->addWidget(m_fileExtension, 2, 2); + gridLayout->addWidget(m_effectiveFilterLabel, 3, 0); + gridLayout->addWidget(m_effectiveFilter, 3, 1); + gridLayout->addWidget(m_fileListLabel, 4, 0); + gridLayout->addWidget(m_fileList, 4, 1); dialogLayout->addLayout(gridLayout); dialogLayout->addWidget(m_buttons); @@ -129,12 +134,54 @@ QString RicFileHierarchyDialog::rootDir() const return m_rootDir->text(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::pathFilter() const +{ + return m_pathFilter->text(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::fileNameFilter() const +{ + return m_fileFilter->text(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::fileExtensions() const +{ + return m_fileExtension->text().split("|"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicFileHierarchyDialog::cancelPressed() const +{ + return m_cancelPressed; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::appendToFileList(const QString& fileName) +{ + m_fileList->append(fileName); + QApplication::processEvents(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *parent /*= 0*/, const QString &caption /*= QString()*/, - const QString &dir /*= QString()*/, + const QString &dir /*= QString()*/, + const QString &pathFilter /*= QString()*/, const QString &fileNameFilter /*= QString()*/, const QStringList &fileExtensions /*= QStringList()*/) { @@ -143,46 +190,57 @@ RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *p dialog.setWindowTitle(caption); - dialog.m_rootDir->setText(dir); + dialog.m_rootDir->setText(QDir::toNativeSeparators(dir)); + dialog.m_pathFilter->setText(pathFilter); dialog.m_fileFilter->setText(fileNameFilter); dialog.m_fileExtension->setText(prefixStrings(fileExtensions, ".").join(" | ")); + + dialog.updateEffectiveFilter(); + dialog.m_fileList->setText(""); - dialog.resize(600, 150); + dialog.resize(600, 250); dialog.exec(); - return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir()); + return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir(), dialog.pathFilter(), dialog.fileNameFilter()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::findMatchingFiles(const QString& rootDir, const QString& pathFilter, const QString& fileNameFilter, const QStringList& fileExtensions) +QStringList RicFileHierarchyDialog::findMatchingFiles(RicFileHierarchyDialog& dialog) { - QStringList files = findFilesRecursive(rootDir, fileNameFilter, fileExtensions); - return filterByPathFilter(files, pathFilter); + return findFilesRecursive(dialog.rootDir(), dialog); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::findFilesRecursive(const QString &dir, const QString &fileNameFilter, const QStringList &fileExtensions) +QStringList RicFileHierarchyDialog::findFilesRecursive(const QString ¤tDir, RicFileHierarchyDialog& dialog) { QStringList allFiles; - QDir qdir(dir); + if (dialog.cancelPressed()) return allFiles; + + QDir qdir(currentDir); QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - QStringList files = qdir.entryList(createNameFilterList(fileNameFilter, fileExtensions), QDir::Files); + QStringList files = qdir.entryList(createNameFilterList(dialog.fileNameFilter(), dialog.fileExtensions()), QDir::Files); for (QString file : files) { - allFiles.append(qdir.absoluteFilePath(file)); + QString absFilePath = qdir.absoluteFilePath(file); + if (pathFilterMatch(absFilePath, dialog.pathFilter())) + { + allFiles.append(absFilePath); + dialog.appendToFileList(absFilePath); + } } for (QString subDir : subDirs) { - allFiles += findFilesRecursive(qdir.absoluteFilePath(subDir), fileNameFilter, fileExtensions); + QApplication::processEvents(); + allFiles += findFilesRecursive(qdir.absoluteFilePath(subDir), dialog); } - return allFiles; + return dialog.cancelPressed() ? QStringList() : allFiles; } //-------------------------------------------------------------------------------------------------- @@ -210,23 +268,48 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::filterByPathFilter(const QStringList& files, const QString& pathFilter) +bool RicFileHierarchyDialog::pathFilterMatch(const QString& file, const QString& pathFilter) { - QStringList filteredFiles; QRegExp regexp(pathFilter, Qt::CaseInsensitive, QRegExp::Wildcard); - for (QString file : files) + QFileInfo fileInfo(file); + QString path = fileInfo.absolutePath(); + + return regexp.exactMatch(path); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::updateEffectiveFilter() +{ + QString sep(QDir::separator()); + + QString effFilter = QString("%1/%2/%3%4") + .arg(m_rootDir->text()) + .arg(m_pathFilter->text()) + .arg(m_fileFilter->text()) + .arg(m_fileExtension->text()); + + QString native(QDir::toNativeSeparators(effFilter)); + + // Remove duplicate separators + int len; + do { - QFileInfo fileInfo(file); - QString path = fileInfo.absolutePath(); - - if (regexp.exactMatch(path)) - { - filteredFiles.append(file); - } - } + len = native.size(); + native.replace(sep + sep, sep); + } while (native.size() != len); - return filteredFiles; + m_effectiveFilter->setText(native); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFilterChanged(const QString& text) +{ + updateEffectiveFilter(); } //-------------------------------------------------------------------------------------------------- @@ -234,7 +317,8 @@ QStringList RicFileHierarchyDialog::filterByPathFilter(const QStringList& files, //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::slotDialogOkClicked() { - m_files = findMatchingFiles(m_rootDir->text(), m_pathFilter->text(), m_fileFilter->text(), m_fileExtension->text().split("|")); + m_cancelPressed = false; + m_files = findMatchingFiles(*this); accept(); } @@ -244,6 +328,7 @@ void RicFileHierarchyDialog::slotDialogOkClicked() void RicFileHierarchyDialog::slotDialogCancelClicked() { m_files = QStringList(); + m_cancelPressed = true; reject(); } diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 4fa162e433..488926ecd9 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -26,6 +26,7 @@ class QLabel; class QLineEdit; +class QTextEdit; class QDialogButtonBox; class QPushButton; class QMainWindow; @@ -44,29 +45,35 @@ class RicFileHierarchyDialog : public QDialog QStringList files() const; QString rootDir() const; + QString pathFilter() const; + QString fileNameFilter() const; + QStringList fileExtensions() const; + bool cancelPressed() const; + + void appendToFileList(const QString& fileName); static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, - const QString &caption = QString(), - const QString &dir = QString(), - const QString &fileNameFilter = QString(), - const QStringList &fileExtensions = QStringList()); + const QString& caption = QString(), + const QString& dir = QString(), + const QString& pathFilter = QString(), + const QString& fileNameFilter = QString(), + const QStringList& fileExtensions = QStringList()); private: - static QStringList findMatchingFiles(const QString &rootDir, - const QString& pathFilter, - const QString &fileNameFilter, - const QStringList &fileExtensions); + static QStringList findMatchingFiles(RicFileHierarchyDialog& dialog); + + static QStringList findFilesRecursive(const QString& currentDir, + RicFileHierarchyDialog& dialog); - static QStringList findFilesRecursive(const QString &dir, - const QString &fileNameFilter, - const QStringList &fileExtensions); + static QStringList createNameFilterList(const QString& fileNameFilter, + const QStringList& fileExtensions); - static QStringList createNameFilterList(const QString &fileNameFilter, - const QStringList &fileExtensions); + static bool pathFilterMatch(const QString& file, const QString& pathFilter); - static QStringList filterByPathFilter(const QStringList& files, const QString& pathFilter); + void updateEffectiveFilter(); private slots: + void slotFilterChanged(const QString& text); void slotDialogOkClicked(); void slotDialogCancelClicked(); void slotBrowseButtonClicked(); @@ -81,12 +88,19 @@ private slots: QLabel* m_fileFilterLabel; QLineEdit* m_fileFilter; - QLabel* m_fileExtension; + QLabel* m_effectiveFilterLabel; + QLabel* m_effectiveFilter; + + QLabel* m_fileListLabel; + QTextEdit* m_fileList; + QDialogButtonBox* m_buttons; QStringList m_files; + + bool m_cancelPressed; }; @@ -96,9 +110,16 @@ private slots: class RicFileHierarchyDialogResult { public: - RicFileHierarchyDialogResult(bool ok, const QStringList& files, const QString& rootDir) : - ok(ok), files(files), rootDir(rootDir) {} + RicFileHierarchyDialogResult(bool ok, + const QStringList& files, + const QString& rootDir, + const QString& pathFilter, + const QString& fileNameFilter) : + ok(ok), files(files), rootDir(rootDir), pathFilter(pathFilter), fileNameFilter(fileNameFilter) {} + bool ok; QStringList files; QString rootDir; + QString pathFilter; + QString fileNameFilter; }; \ No newline at end of file diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 72402cea31..da76ae1f3e 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -57,7 +57,11 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, "*", QStringList(".SMSPEC")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; if (!result.ok) return; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 3d47388bee..3f40088646 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -30,6 +30,8 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: + RicImportSummaryCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") { } + static bool createAndAddSummaryCaseFromFile(const QString& fileName); protected: @@ -37,6 +39,10 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature virtual bool isCommandEnabled() override; virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook( QAction* actionToSetup ) override; + +private: + QString m_pathFilter; + QString m_fileNameFilter; }; From 4adec8d2bf3f86d65cb8785ecfa2dbad71902855 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 16 Jan 2018 15:49:26 +0100 Subject: [PATCH 0083/1027] #2380 AppFwk: Make template function to find all PdmFields of a type --- .../UnitTests/CMakeLists_files.cmake | 1 + .../UnitTests/RimRelocatePath-Test.cpp | 70 +++ .../TestData/RimRelocatePath/RelocatePath.rsp | 534 ++++++++++++++++++ 3 files changed, 605 insertions(+) create mode 100644 ApplicationCode/UnitTests/RimRelocatePath-Test.cpp create mode 100644 ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index c979307ca3..cceb7d1db9 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp ${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp ${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader-Test.cpp +${CEE_CURRENT_LIST_DIR}RimRelocatePath-Test.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp new file mode 100644 index 0000000000..a66882283c --- /dev/null +++ b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp @@ -0,0 +1,70 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" +#include "RimProject.h" + +#include "cafPdmObjectHandle.h" +#include "cafFilePath.h" + +#include + +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RimRelocatePath/").arg(TEST_DATA_DIR); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void fieldByType(caf::PdmObjectHandle* object, std::vector< caf::PdmField* >* typedFields) +{ + if (!typedFields) return; + if (!object) return; + + std::vector fields; + object->fields(fields); + + std::vector children; + + for (const auto& field : fields) + { + caf::PdmField* typedField = dynamic_cast*>(field); + if (typedField) typedFields->push_back(typedField); + + field->childObjects(&children); + } + + for (const auto& child : children) + { + fieldByType(child, typedFields); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RimRelocatePathTest, findPathsInProjectFile) +{ + QString fileName = TEST_DATA_DIRECTORY + "RelocatePath.rsp"; + + if (fileName.isEmpty()) return; + + RimProject project; + + project.fileName = fileName; + project.readFile(); + + std::vector< caf::PdmField>* > filePathsVectors; + + fieldByType(&project, &filePathsVectors); + + for (auto fpVec : filePathsVectors) + { + for (auto fp : fpVec->v()) + { + std::cout << fp.path().toStdString() << std::endl; + } + } +} diff --git a/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp b/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp new file mode 100644 index 0000000000..9a7c58cb58 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp @@ -0,0 +1,534 @@ + + + C:/Users/Rebecca Cox/Desktop/regression-tests/ProjectFiles/element_properties.rsp + 2018.01.00-dev.01 + 0 + 0 + + + + + + + + + + + + + smal_synt + -1 + + + + + 0 + 0 + TS_ALL + 1 + + + C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\smal_synt.odb + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 1 + -0.594 -0.283646 -0.752801 -5819.28 -0.489311 0.870164 0.0582249 -656.548 0.638544 0.402939 -0.655668 -21775.3 0 0 0 1 + 3800 1686.01 -4633.9 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + Density + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + True + + + E, Density, (1500 .. 2652.75) + True + INCLUDE + + + + ELEMENT + Density + + False + 0 + + + 1500 + 2652.75 + + + + + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 2 + 0.843247 0.06208 -0.533929 -11599.1 -0.347573 0.820684 -0.45351 -7654.19 0.410033 0.568 0.713617 -9392.31 0 0 0 1 + 0 0 0 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + MODULUS + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + USER_DEFINED_MAX_MIN + 17.41 + 5.316 + + + + + + + + True + + + E, Young's Modulus, (10.4982 .. 17.4091) + True + INCLUDE + + + + ELEMENT + MODULUS + + False + 0 + + + 10.4982 + 17.4091 + + + + + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 3 + -0.541294 0.738323 0.402342 4749.47 0.834496 0.530356 0.14946 1161.22 -0.103035 0.416655 -0.903207 -41220.3 0 0 0 1 + 3800 -744.597 -10718 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + RATIO + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + True + + + + + + 10 + 30 + C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\DENSITY_TABLE.inp;C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\ELASTIC_TABLE.inp + + + + + + + True + True + 0.929412 0.929412 0.929412 + ALL_ON + 0.1 + True + 100 + + + + + + UNITS_METRIC + + + + + + + + + + + + + + + + + + + + + + + + + + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\InputPropTest.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\kaverage.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\kslice.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\LGRSOIL.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\SatNum.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + + + + + + + + + + True + True + UTM_FILTER_OFF + 0 + 0 + 0 + 0 + + + + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + 0 + -1 + -1 + False + + + False + + + SELECTED + + + 0.1 + True + CELLS_ACTIVE + + + + 0 + 146000 + + + + + + + + + + + + True + + + + + + + + + + + -1-110000050;-1-1100000;-1-110001050;-1-1100010;-1-1100020;-1-11000;-1-110 + 1 0;0 0;2 0;2 0 + + + True + False + + + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + + + + + 2 + 2 + 2 + 8 + + + + + + + UNIFIED_FILE + ALL_WELLS + TRANSMISSIBILITIES + 0 + False + True + True + True + False + + + + + From 548c0652908a06b58ed78d2af27d1d73e8201f8d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 16 Jan 2018 16:24:29 +0100 Subject: [PATCH 0084/1027] Fix cotire build --- ApplicationCode/UnitTests/RimRelocatePath-Test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp index a66882283c..2c437a23ef 100644 --- a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp +++ b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp @@ -11,8 +11,6 @@ #include -static const QString TEST_DATA_DIRECTORY = QString("%1/RimRelocatePath/").arg(TEST_DATA_DIR); - //-------------------------------------------------------------------------------------------------- /// @@ -47,7 +45,7 @@ void fieldByType(caf::PdmObjectHandle* object, std::vector< caf::PdmField* >* //-------------------------------------------------------------------------------------------------- TEST(RimRelocatePathTest, findPathsInProjectFile) { - QString fileName = TEST_DATA_DIRECTORY + "RelocatePath.rsp"; + QString fileName = QString("%1/RimRelocatePath/RelocatePath.rsp").arg(TEST_DATA_DIR); if (fileName.isEmpty()) return; From d616548cd07e5d051bbb4e3b3251ebace2b6c0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 17 Jan 2018 08:00:36 +0100 Subject: [PATCH 0085/1027] #2331 Shell of 2dIntersectionView shell added. Fixed access to views on a case including the intersection views also. --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../Rim2dIntersectionView.cpp | 797 ++---------------- .../ProjectDataModel/Rim2dIntersectionView.h | 192 +---- ApplicationCode/ProjectDataModel/RimCase.cpp | 25 +- ApplicationCode/ProjectDataModel/RimCase.h | 10 +- .../ProjectDataModel/RimEclipseCase.cpp | 3 +- .../ProjectDataModel/RimEclipseCase.h | 2 +- .../ProjectDataModel/RimGeoMechCase.cpp | 2 +- .../ProjectDataModel/RimGeoMechCase.h | 2 +- 9 files changed, 140 insertions(+), 895 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index aa7d17564b..bb8c37206c 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -61,6 +61,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h ${CEE_CURRENT_LIST_DIR}RimViewWindow.h ${CEE_CURRENT_LIST_DIR}Rim3dView.h ${CEE_CURRENT_LIST_DIR}RimGridView.h +${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.h ${CEE_CURRENT_LIST_DIR}RimViewManipulator.h ${CEE_CURRENT_LIST_DIR}RimCase.h ${CEE_CURRENT_LIST_DIR}RimViewController.h @@ -163,6 +164,7 @@ ${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp ${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp ${CEE_CURRENT_LIST_DIR}Rim3dView.cpp ${CEE_CURRENT_LIST_DIR}RimGridView.cpp +${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.cpp ${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp ${CEE_CURRENT_LIST_DIR}RimCase.cpp ${CEE_CURRENT_LIST_DIR}RimViewController.cpp diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index c2e370fcb6..fbf7889f05 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -15,722 +15,196 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// -#if 0 -#include "Rim2dIntersectionView.h" -#include "RiaApplication.h" -#include "RiaPreferences.h" - -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellRangeFilterCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimGridCollection.h" -#include "RimIntersectionCollection.h" -#include "RimMainPlotCollection.h" -#include "RimOilField.h" -#include "RimProject.h" -#include "RimPropertyFilterCollection.h" -#include "RimViewController.h" -#include "RimViewLinker.h" -#include "RimViewLinkerCollection.h" -#include "RimWellPathCollection.h" - -#include "RiuMainWindow.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" +#include "RimCase.h" #include "RiuViewer.h" -#include "RiuTimeStepChangedHandler.h" - -#include "cafDisplayCoordTransform.h" -#include "cafFrameAnimationControl.h" -#include "cafPdmObjectFactory.h" +#include "RimGridView.h" +#include "RivIntersectionPartMgr.h" -#include "cvfCamera.h" -#include "cvfModel.h" -#include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfScene.h" -#include "cvfViewport.h" - -#include - -#include +#include "cvfModelBasicList.h" #include "cvfTransform.h" +#include "cvfScene.h" - -namespace caf { - -template<> -void caf::AppEnum< Rim2dIntersectionView::MeshModeType >::setUp() -{ - addItem(Rim2dIntersectionView::FULL_MESH, "FULL_MESH", "All"); - addItem(Rim2dIntersectionView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); - addItem(Rim2dIntersectionView::NO_MESH, "NO_MESH", "None"); - setDefault(Rim2dIntersectionView::FULL_MESH); -} - -template<> -void caf::AppEnum< Rim2dIntersectionView::SurfaceModeType >::setUp() -{ - addItem(Rim2dIntersectionView::SURFACE, "SURFACE", "All"); - addItem(Rim2dIntersectionView::NO_SURFACE, "NO_SURFACE", "None"); - setDefault(Rim2dIntersectionView::SURFACE); -} - -} // End namespace caf - - -CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "GenericView"); // Do not use. Abstract class - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- -Rim2dIntersectionView::Rim2dIntersectionView(void) -{ - RiaApplication* app = RiaApplication::instance(); - RiaPreferences* preferences = app->preferences(); - CVF_ASSERT(preferences); - - - CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - - CAF_PDM_InitField(&m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); - m_cameraPosition.uiCapability()->setUiHidden(true); - - CAF_PDM_InitField(&m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); - m_cameraPointOfInterest.uiCapability()->setUiHidden(true); - - double defaultScaleFactor = preferences->defaultScaleFactorZ; - CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); - - cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - CAF_PDM_InitField(&m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); - - CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); - maximumFrameRate.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", ""); - hasUserRequestedAnimation.uiCapability()->setUiHidden(true); - - CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); - m_currentTimeStep.uiCapability()->setUiHidden(true); - - //CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - //m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); - //m_overlayInfoConfig->setReservoirView(this); - //m_overlayInfoConfig.uiCapability()->setUiHidden(true); - - caf::AppEnum defaultMeshType = NO_MESH; - if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; - CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); - CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", ""); - - CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); - - m_previousGridModeMeshLinesWasFaults = false; - - m_crossSectionVizModel = new cvf::ModelBasicList; - m_crossSectionVizModel->setName("CrossSectionModel"); - - m_highlightVizModel = new cvf::ModelBasicList; - m_highlightVizModel->setName("HighlightModel"); - - m_wellPathPipeVizModel = new cvf::ModelBasicList; - m_wellPathPipeVizModel->setName("WellPathPipeModel"); - - this->setAs3DViewMdiWindow(); -} +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim2dIntersectionView::~Rim2dIntersectionView(void) +Rim2dIntersectionView::Rim2dIntersectionView(void) { - RimProject* proj = RiaApplication::instance()->project(); - - removeMdiWindowFromMdiArea(); + CAF_PDM_InitObject("Intersection View", ":/CrossSection16x16.png", "", ""); - deleteViewWidget(); -} + CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", ""); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuViewer* Rim2dIntersectionView::viewer() -{ - return m_viewer; + m_scaleTransform = new cvf::Transform(); + m_intersectionVizModel = new cvf::ModelBasicList; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QWidget* Rim2dIntersectionView::createViewWidget(QWidget* mainWindowParent) +Rim2dIntersectionView::~Rim2dIntersectionView(void) { - QGLFormat glFormat; - glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - m_viewer = new RiuViewer(glFormat, NULL); - m_viewer->setOwnerReservoirView(this); - - m_viewer->showAxisCross(false); - - return m_viewer->layoutWidget(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::updateViewWidgetAfterCreation() +bool Rim2dIntersectionView::isUsingFormationNames() const { - m_viewer->setDefaultPerspectiveNearPlaneDistance(10); - - this->resetLegendsInViewer(); + // Todo: - m_viewer->updateNavigationPolicy(); - m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); - - m_viewer->mainCamera()->setViewMatrix(m_cameraPosition); - m_viewer->setPointOfInterest(m_cameraPointOfInterest()); - m_viewer->enableParallelProjection(true); - - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - - this->updateAnnotationItems(); - this->createHighlightDisplayModel(); - - m_viewer->update(); + return false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::updateMdiWindowTitle() +void Rim2dIntersectionView::scheduleGeometryRegen(RivCellSetEnum geometryType) { - if (m_viewer) - { - QString windowTitle; - if (ownerCase()) - { - windowTitle = QString("%1 - %2").arg(ownerCase()->caseUserDescription()).arg(name); - } - else - { - windowTitle = name; - } - - m_viewer->layoutWidget()->setWindowTitle(windowTitle); - } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::deleteViewWidget() +RimCase* Rim2dIntersectionView::ownerCase() const { - if (m_viewer) - { - m_viewer->deleteLater(); - m_viewer = nullptr; - } + RimCase* rimCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(rimCase); + return rimCase; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); - viewGroup->add(&name); - viewGroup->add(&m_backgroundColor); - viewGroup->add(&m_disableLighting); - - caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Grid Appearance"); - gridGroup->add(&scaleZ); - gridGroup->add(&meshMode); - gridGroup->add(&surfaceMode); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QImage Rim2dIntersectionView::snapshotWindowContent() +QList Rim2dIntersectionView::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { - if (m_viewer) + QList options; + if (fieldNeedingOptions == &m_intersection) { - // Force update of scheduled display models before snapshotting - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); - - m_viewer->repaint(); + std::vector intersections; + + this->ownerCase()->descendantsIncludingThisOfType(intersections); - return m_viewer->snapshotImage(); - } - - return QImage(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::scheduleCreateDisplayModelAndRedraw() -{ - RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); - if (this->isMasterView()) - { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) + for (auto intersection : intersections) { - viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews(); + options.push_back(caf::PdmOptionItemInfo(intersection->name(), intersection)); } } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setCurrentTimeStepAndUpdate(int frameIndex) -{ - setCurrentTimeStep(frameIndex); - - this->updateCurrentTimeStep(); - - RimProject* project; - firstAncestorOrThisOfTypeAsserted(project); - project->mainPlotCollection()->updateCurrentTimeStepInPlots(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString Rim2dIntersectionView::timeStepName(int frameIdx) const -{ - return this->ownerCase()->timeStepName(frameIdx); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setCurrentTimeStep(int frameIndex) -{ - const int oldTimeStep = m_currentTimeStep; - - m_currentTimeStep = frameIndex; - clampCurrentTimestep(); - - if (m_currentTimeStep != oldTimeStep) - { - RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); - } - this->hasUserRequestedAnimation = true; - if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) - { - m_currentReservoirCellVisibility = NULL; - } + return options; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::updateCurrentTimeStepAndRedraw() +void Rim2dIntersectionView::axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) { - this->updateCurrentTimeStep(); - - RimProject* project; - firstAncestorOrThisOfTypeAsserted(project); - project->mainPlotCollection()->updateCurrentTimeStepInPlots(); - - if (m_viewer) m_viewer->update(); + } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::createDisplayModelAndRedraw() +void Rim2dIntersectionView::createDisplayModel() { - if (m_viewer) - { - this->clampCurrentTimestep(); - - createDisplayModel(); - createHighlightDisplayModel(); - updateDisplayModelVisibility(); - - if (m_cameraPosition().isIdentity()) - { - setDefaultView(); - m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); - m_cameraPointOfInterest = m_viewer->pointOfInterest(); - } - } - - RiuMainWindow::instance()->refreshAnimationActions(); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setDefaultView() -{ - if (m_viewer) - { - m_viewer->setDefaultView(); - } -} + if (m_viewer.isNull()) return; + if (!m_intersection()) return; + + m_intersectionVizModel->removeAllParts(); + + m_intersection()->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); + m_intersection()->intersectionPartMgr()->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::endAnimation() -{ - this->hasUserRequestedAnimation = false; - this->updateStaticCellColors(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPathCollection* Rim2dIntersectionView::wellPathCollection() +void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) { - RimProject* proj = nullptr; - this->firstAncestorOrThisOfTypeAsserted(proj); - CVF_ASSERT(proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()); - - return proj->activeOilField()->wellPathCollection(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setupBeforeSave() +void Rim2dIntersectionView::updateDisplayModelVisibility() { - if (m_viewer) - { - hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... - m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); - m_cameraPointOfInterest = m_viewer->pointOfInterest(); - } } //-------------------------------------------------------------------------------------------------- /// -// Surf: No Fault Surf -// Mesh ------------- -// No F F G -// Fault F F G -// Mesh G G G -// //-------------------------------------------------------------------------------------------------- -bool Rim2dIntersectionView::isGridVisualizationMode() const +void Rim2dIntersectionView::clampCurrentTimestep() { - return ( this->surfaceMode() == SURFACE - || this->meshMode() == FULL_MESH); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setMeshOnlyDrawstyle() +void Rim2dIntersectionView::updateCurrentTimeStep() { - if (isGridVisualizationMode()) - { - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - - surfaceMode.setValueWithFieldChanged(NO_SURFACE); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setMeshSurfDrawstyle() +void Rim2dIntersectionView::onTimeStepChanged() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setFaultMeshSurfDrawstyle() +void Rim2dIntersectionView::updateStaticCellColors() { - // Surf: No Fault Surf - // Mesh ------------- - // No FF FF SF - // Fault FF FF SF - // Mesh SF SF SF - if (this->isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - - meshMode.setValueWithFieldChanged(FAULTS_MESH); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setSurfOnlyDrawstyle() +void Rim2dIntersectionView::updateScaleTransform() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } + cvf::Mat4d scale = cvf::Mat4d::IDENTITY; + scale(2, 2) = scaleZ(); - meshMode.setValueWithFieldChanged(NO_MESH); -} + this->scaleTransform()->setLocalTransform(scale); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::showGridCells(bool enableGridCells) -{ - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } - - m_gridCollection->isActive = enableGridCells; - m_gridCollection->updateConnectedEditors(); - m_gridCollection->updateUiIconFromState(enableGridCells); + if (m_viewer) m_viewer->updateCachedValuesInScene(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setSurfaceDrawstyle() +cvf::Transform* Rim2dIntersectionView::scaleTransform() { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); + return m_scaleTransform.p(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::disableLighting(bool disable) +void Rim2dIntersectionView::resetLegendsInViewer() { - m_disableLighting = disable; - updateCurrentTimeStepAndRedraw(); - updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool Rim2dIntersectionView::isLightingDisabled() const -{ - return m_disableLighting(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); - - if (changedField == &meshMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &isPerspectiveView) - { - if (m_viewer) m_viewer->enableParallelProjection(!isPerspectiveView()); - } - else if (changedField == &scaleZ) - { - if (scaleZ < 1) scaleZ = 1; - - this->updateGridBoxData(); - - // Regenerate well paths - RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - - crossSectionCollection->updateIntersectionBoxGeometry(); - - if (m_viewer) - { - cvf::Vec3d poi = m_viewer->pointOfInterest(); - cvf::Vec3d eye, dir, up; - eye = m_viewer->mainCamera()->position(); - dir = m_viewer->mainCamera()->direction(); - up = m_viewer->mainCamera()->up(); - - eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]); - poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2); - - m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); - m_viewer->setPointOfInterest(poi); - - updateScaleTransform(); - createDisplayModelAndRedraw(); - - m_viewer->update(); - - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateScaleZ(this, scaleZ); - viewLinker->updateCamera(this); - } - } - - RiuMainWindow::instance()->updateScaleValue(); - } - else if (changedField == &surfaceMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &showGridBox) - { - createHighlightAndGridBoxDisplayModelWithRedraw(); - } - else if (changedField == &m_disableLighting) - { - createDisplayModel(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - RiuMainWindow::instance()->refreshAnimationActions(); - } - else if (changedField == &name) - { - updateMdiWindowTitle(); - - if (viewController()) - { - viewController()->updateDisplayNameAndIcon(); - viewController()->updateConnectedEditors(); - } - else - { - if (isMasterView()) - { - assosiatedViewLinker()->updateUiNameAndIcon(); - assosiatedViewLinker()->updateConnectedEditors(); - } - } - } - else if (changedField == &m_currentTimeStep) - { - if (m_viewer) - { - m_viewer->update(); - - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateTimeStep(this, m_currentTimeStep); - } - } - } - else if (changedField == &m_backgroundColor) - { - if (m_viewer != nullptr) - { - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - } - updateGridBoxData(); - updateAnnotationItems(); - } - else if (changedField == &maximumFrameRate) - { - // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? - // !! Should be able to specify legal range for number properties - if (m_viewer) - { - m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, - const cvf::BoundingBox& wellPathClipBoundingBox) -{ - if (!this->ownerCase()) return; - - cvf::ref transForm = displayCoordTransform(); - - wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); - - wellPathModelBasicList->updateBoundingBoxesRecursive(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) -{ - if (!this->ownerCase()) return; - - cvf::ref transForm = displayCoordTransform(); - - QDateTime currentTimeStamp; - std::vector timeStamps = ownerCase()->timeStepDates(); - if (currentTimeStep() < static_cast(timeStamps.size())) - { - currentTimeStamp = timeStamps[currentTimeStep()]; - } - - wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, - currentTimeStamp, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); - - wellPathModelBasicList->updateBoundingBoxesRecursive(); + m_viewer->showAxisCross(false); + m_viewer->showAnimationProgress(false); + m_viewer->setMainScene(new cvf::Scene()); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setScaleZAndUpdate(double scaleZ) +void Rim2dIntersectionView::onLoadDataAndUpdate() { - this->scaleZ = scaleZ; - updateScaleTransform(); - - this->updateGridBoxData(); + updateMdiWindowVisibility(); this->scheduleCreateDisplayModelAndRedraw(); } @@ -738,156 +212,23 @@ void Rim2dIntersectionView::setScaleZAndUpdate(double scaleZ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimViewLinker* Rim2dIntersectionView::viewLinkerIfMasterView() const -{ - RimViewLinker* viewLinker = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - - for (size_t i = 0; i < reffingObjs.size(); ++i) - { - viewLinker = dynamic_cast(reffingObjs[i]); - if (viewLinker) break; - } - - return viewLinker; -} - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::updateAnnotationItems() -{ - if (m_viewer) - { - m_viewer->updateAnnotationItems(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -//Rim3dOverlayInfoConfig* Rim2dIntersectionView::overlayInfoConfig() const -//{ -// return m_overlayInfoConfig; -//} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::createHighlightDisplayModelWithRedraw() -{ - createHighlightDisplayModel(); - - if (m_viewer) - { - m_viewer->update(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::createHighlightDisplayModel() -{ - m_viewer->removeStaticModel(m_highlightVizModel.p()); - - m_highlightVizModel->removeAllParts(); - - cvf::Collection parts; - createPartCollectionFromSelection(&parts); - if (parts.size() > 0) - { - for (size_t i = 0; i < parts.size(); i++) - { - m_highlightVizModel->addPart(parts[i].p()); - } - - m_highlightVizModel->updateBoundingBoxesRecursive(); - m_viewer->addStaticModelOnce(m_highlightVizModel.p()); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool Rim2dIntersectionView::showActiveCellsOnly() -{ - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::selectOverlayInfoConfig() +void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - //RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); -} + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::zoomAll() -{ - if (m_viewer) + if (changedField == & m_intersection) { - m_viewer->zoomAll(); + this->loadDataAndUpdate(); } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref Rim2dIntersectionView::displayCoordTransform() const -{ - cvf::ref coordTrans = new caf::DisplayCoordTransform; - - cvf::Vec3d scale(1.0, 1.0, scaleZ); - coordTrans->setScale(scale); - - RimCase* rimCase = ownerCase(); - if (rimCase) - { - coordTrans->setTranslation(rimCase->displayModelOffset()); - } - - return coordTrans; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QWidget* Rim2dIntersectionView::viewWidget() -{ - if ( m_viewer ) return m_viewer->layoutWidget(); - else return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::forceShowWindowOn() -{ - m_showWindow.setValueWithFieldChanged(true); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::handleMdiWindowClosed() +void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimViewWindow::handleMdiWindowClosed(); -} + uiOrdering.add(&m_intersection); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) -{ - RimViewWindow::setMdiWindowGeometry(windowGeometry); + Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); } - -#endif \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 8e01317205..e7b0f654dd 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -17,194 +17,64 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "RiuViewerToViewInterface.h" -#include "RimViewWindow.h" - -#include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" -#include "cafPdmField.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" -#include "cafPdmFieldCvfVec3d.h" -#include "cafPdmObject.h" - -#include "RivCellSetEnum.h" - -#include "cvfArray.h" -#include "cvfBase.h" -#include "cvfCollection.h" -#include "cvfObject.h" - -#include - - -class Rim3dOverlayInfoConfig; -class RimCase; -class RimCellRangeFilter; -class RimCellRangeFilterCollection; -class RimIntersectionCollection; -class RimGridCollection; -class RimPropertyFilterCollection; -class RimViewController; -class RimViewLinker; -class RiuViewer; -class RimWellPathCollection; + +#include "Rim3dView.h" +#include "cafPdmPtrField.h" + +class RimIntersection; namespace cvf { -class BoundingBox; -class ModelBasicList; -class Scene; -class String; -class Transform; -class Part; + class ModelBasicList; } -namespace caf -{ -class DisplayCoordTransform; -} //================================================================================================== /// /// //================================================================================================== -class Rim2dIntersectionView : public RimViewWindow, public RiuViewerToViewInterface +class Rim2dIntersectionView : public Rim3dView { CAF_PDM_HEADER_INIT; public: Rim2dIntersectionView(void); virtual ~Rim2dIntersectionView(void); - // Public fields: - - caf::PdmField name; - caf::PdmField scaleZ; - caf::PdmField maximumFrameRate; - caf::PdmField hasUserRequestedAnimation; - - // Draw style - - enum MeshModeType { FULL_MESH, FAULTS_MESH, NO_MESH }; - enum SurfaceModeType { SURFACE, NO_SURFACE }; - - caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; - caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - - RiuViewer* viewer(); - - void setMeshOnlyDrawstyle(); - void setMeshSurfDrawstyle(); - void setSurfOnlyDrawstyle(); - void setFaultMeshSurfDrawstyle(); - void setSurfaceDrawstyle(); - - void disableLighting(bool disable); - bool isLightingDisabled() const; - - void showGridCells(bool enableGridCells); - bool isGridVisualizationMode() const; - - void setScaleZAndUpdate(double scaleZ); - virtual bool showActiveCellsOnly(); - virtual bool isUsingFormationNames() const = 0; - - virtual QImage snapshotWindowContent() override; - virtual void zoomAll() override; - void forceShowWindowOn(); - // Animation - int currentTimeStep() const { return m_currentTimeStep;} - void setCurrentTimeStep(int frameIdx); - void setCurrentTimeStepAndUpdate(int frameIdx) override; + virtual bool isUsingFormationNames() const override; + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; + virtual RimCase* ownerCase() const override; + virtual void selectOverlayInfoConfig() override {} - // Updating - void updateCurrentTimeStepAndRedraw() override; - virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0; - void scheduleCreateDisplayModelAndRedraw(); - void createDisplayModelAndRedraw(); - void createHighlightDisplayModelWithRedraw(); - void updateAnnotationItems(); + virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } + virtual RimViewController* viewController() const override { return nullptr; } - cvf::ref displayCoordTransform() const override; - virtual RimCase* ownerCase() const = 0; - //Rim3dOverlayInfoConfig* overlayInfoConfig() const; protected: - void setDefaultView(); - - RimWellPathCollection* wellPathCollection(); - void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, - const cvf::BoundingBox& wellPathClipBoundingBox); - - void addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, - const cvf::BoundingBox& wellPathClipBoundingBox); - - void createHighlightDisplayModel(); - - // Abstract methods to implement in subclasses - - virtual void createDisplayModel() = 0; - virtual void createPartCollectionFromSelection(cvf::Collection* parts) = 0; - - virtual void updateDisplayModelVisibility() = 0; - virtual void clampCurrentTimestep() = 0; - - virtual void updateCurrentTimeStep() = 0; - virtual void updateStaticCellColors() = 0; - - virtual void updateScaleTransform() = 0; - virtual cvf::Transform* scaleTransform() = 0; - - virtual void resetLegendsInViewer() = 0; - - // Overridden PdmObject methods: - - virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } - virtual void setupBeforeSave() override; - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - - // Overridden ViewWindow methods: - - virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; - virtual void updateViewWidgetAfterCreation() override; - virtual void updateMdiWindowTitle() override; - virtual void deleteViewWidget() override; - virtual QWidget* viewWidget() override; - -protected: // Fields - caf::PdmField m_currentTimeStep; - //caf::PdmChildField m_overlayInfoConfig; + caf::PdmPtrField m_intersection; -protected: - QPointer m_viewer; + virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; + virtual void createDisplayModel() override; + virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; + virtual void updateDisplayModelVisibility() override; + virtual void clampCurrentTimestep() override; + virtual void updateCurrentTimeStep() override; + virtual void onTimeStepChanged() override; + virtual void updateStaticCellColors() override; + virtual void updateScaleTransform() override; + virtual cvf::Transform* scaleTransform() override; + virtual void resetLegendsInViewer() override; + virtual void onLoadDataAndUpdate() override; - cvf::ref m_wellPathPipeVizModel; - cvf::ref m_crossSectionVizModel; - cvf::ref m_highlightVizModel; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; -private: - // Implementation of RiuViewerToViewInterface + cvf::ref m_intersectionVizModel; + cvf::ref m_scaleTransform; - virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();} - virtual void setCameraPosition(const cvf::Mat4d& cameraPosition) override { m_cameraPosition = cameraPosition; } - virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) override { m_cameraPointOfInterest = cameraPointOfInterest;} - virtual QString timeStepName(int frameIdx) const override; - virtual void endAnimation() override; - virtual caf::PdmObjectHandle* implementingPdmObject() override { return this; } - virtual void handleMdiWindowClosed() override; - virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; - virtual void selectOverlayInfoConfig() override; -private: - bool m_previousGridModeMeshLinesWasFaults; - caf::PdmField m_disableLighting; - caf::PdmField m_cameraPosition; - caf::PdmField m_cameraPointOfInterest; - caf::PdmField< cvf::Color3f > m_backgroundColor; }; diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 1382c40e11..f64d6d8bbf 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -28,6 +28,8 @@ #include "cafPdmObjectFactory.h" +#include "Rim2dIntersectionView.h" + CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); @@ -35,7 +37,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase::RimCase() +RimCase::RimCase() : m_isInActiveDestruction(false) { CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case Name", "", "" ,""); @@ -48,6 +50,11 @@ RimCase::RimCase() m_timeStepFilter.uiCapability()->setUiHidden(true); m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden(true); m_timeStepFilter = new RimTimeStepFilter; + + CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSections16x16.png", "", ""); + m_intersectionViews.uiCapability()->setUiTreeHidden(true); + //m_intersectionViews.push_back(new Rim2dIntersectionView()); + } //-------------------------------------------------------------------------------------------------- @@ -55,7 +62,23 @@ RimCase::RimCase() //-------------------------------------------------------------------------------------------------- RimCase::~RimCase() { + m_isInActiveDestruction = true; // Needed because destruction of m_intersectionViews results in call to views() +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCase::views() const +{ + if (m_isInActiveDestruction) return std::vector(); + + std::vector allViews = this->allSpecialViews(); + for (auto view: m_intersectionViews) + { + allViews.push_back(view); + } + return allViews; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index a7c13d0404..94721dd14d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -23,6 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmChildField.h" +#include "cafPdmChildArrayField.h" #include "cvfBase.h" #include "cvfVector3.h" @@ -32,6 +33,7 @@ class Rim3dView; class RimFormationNames; class RimTimeStepFilter; +class Rim2dIntersectionView; namespace cvf { class BoundingBox; @@ -49,7 +51,7 @@ class RimCase : public caf::PdmObject caf::PdmPtrField activeFormationNames; - virtual std::vector views() = 0; + std::vector views() const; virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0; @@ -71,11 +73,17 @@ class RimCase : public caf::PdmObject protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual std::vector allSpecialViews() const = 0; + private: virtual caf::PdmFieldHandle* userDescriptionField() override { return &caseUserDescription; } protected: caf::PdmChildField m_timeStepFilter; + caf::PdmChildArrayField m_intersectionViews; + +private: + bool m_isInActiveDestruction; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 43213fcf62..70c7da6a2a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -673,13 +673,14 @@ bool RimEclipseCase::openReserviorCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEclipseCase::views() +std::vector RimEclipseCase::allSpecialViews() const { std::vector views; for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx) { views.push_back(reservoirViews[vIdx]); } + return views; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index bff5f2c5d9..423b5f91cb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -91,7 +91,6 @@ class RimEclipseCase : public RimCase RimCaseCollection* parentCaseCollection(); - virtual std::vector views(); virtual QStringList timeStepStrings() const override; virtual QString timeStepName(int frameIdx) const override; virtual std::vector timeStepDates() const override; @@ -122,6 +121,7 @@ class RimEclipseCase : public RimCase private: void createTimeStepFormatString(); + virtual std::vector allSpecialViews() const override; private: cvf::ref m_rigEclipseCase; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index d99d843920..669a783dca 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -221,7 +221,7 @@ void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPat //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGeoMechCase::views() +std::vector RimGeoMechCase::allSpecialViews() const { std::vector views; for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 3bf3614760..9417e42631 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -57,7 +57,6 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); - virtual std::vector views() override; virtual std::vector timeStepDates() const override; virtual QStringList timeStepStrings() const override; @@ -91,6 +90,7 @@ class RimGeoMechCase : public RimCase void closeSelectedElementPropertyFiles(); void reloadSelectedElementPropertyFiles(); + virtual std::vector allSpecialViews() const override; private: cvf::ref m_geoMechCaseData; From 828557f71f6c59a7c37552d60b7d19b2af420927 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Jan 2018 11:09:03 +0100 Subject: [PATCH 0086/1027] Whitespace and include cleanup --- .../RiaCompletionTypeCalculationScheduler.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index c0a6d10800..2f9386c194 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -1,49 +1,50 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RiaCompletionTypeCalculationScheduler.h" +#include "RiaApplication.h" +#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" -#include "RiaApplication.h" #include "RimOilField.h" #include "RimProject.h" - -#include -#include -#include "QAbstractItemModel" #include "RiuMainWindow.h" +#include "RiuViewer.h" + #include "cafPdmUiTreeView.h" + +#include #include -#include "Rim3dView.h" -#include "RiuViewer.h" + +#include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::instance() { - static RiaCompletionTypeCalculationScheduler theInstance; - + static RiaCompletionTypeCalculationScheduler theInstance; + return &theInstance; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() { @@ -63,13 +64,12 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) { m_eclipseCasesToRecalculate.push_back(eclipseCase); - if (!m_recalculateCompletionTypeTimer) { m_recalculateCompletionTypeTimer = new QTimer(this); @@ -81,14 +81,14 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() { std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); for (RimEclipseCase* eclipseCase : uniqueCases) { @@ -113,7 +113,7 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() { From 673ae6b1ff6368b951349bf5c0fbc29a668f4694 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 08:15:12 +0100 Subject: [PATCH 0087/1027] #2150 Fracture : Create two parts of fracture geometry --- .../RivWellFracturePartMgr.cpp | 141 +++++++++++++----- 1 file changed, 103 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 0d421067c4..231f6d2a42 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -16,31 +16,34 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RivWellFracturePartMgr.h" - #include "RiaApplication.h" +#include "RigCellGeometryTools.h" +#include "RigFractureCell.h" #include "RigFractureGrid.h" -#include "RigMainGrid.h" #include "RigHexIntersectionTools.h" -#include "RigCellGeometryTools.h" +#include "RigMainGrid.h" -#include "RigFractureCell.h" +#include "RimCase.h" #include "RimEclipseView.h" #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" #include "RimLegendConfig.h" +#include "RimSimWellInView.h" #include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" +#include "RimWellPathCollection.h" #include "RivFaultGeometryGenerator.h" -#include "RivPartPriority.h" #include "RivObjectSourceInfo.h" +#include "RivPartPriority.h" +#include "RivWellFracturePartMgr.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" +#include "cvfAssert.h" #include "cvfDrawableGeo.h" #include "cvfGeometryTools.h" #include "cvfModelBasicList.h" @@ -48,11 +51,10 @@ #include "cvfPrimitiveSet.h" #include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetIndexedUInt.h" -#include "cvfScalarMapperContinuousLinear.h" #include "cvfRenderStateDepth.h" -#include "cvfAssert.h" +#include "cvfScalarMapperContinuousLinear.h" +#include "cvfTransform.h" -#include //-------------------------------------------------------------------------------------------------- /// @@ -643,57 +645,120 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod { if (!m_rimFracture->isChecked() || !eclView.stimPlanColors->isChecked()) return; - cvf::ref surfacePart; - cvf::ref stimPlanMeshPart; - cvf::ref containmentMaskPart; + if (!m_rimFracture->fractureTemplate()) return; + double characteristicCellSize = eclView.ownerCase()->characteristicCellSize(); + cvf::Collection parts; RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); - if (m_rimFracture->fractureTemplate()) + + if (stimPlanFracTemplate) { - // StimPlan - if (stimPlanFracTemplate) + if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) { - if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) - { - surfacePart = createStimPlanElementColorSurfacePart(eclView); - } - else - { - surfacePart = createStimPlanColorInterpolatedSurfacePart(eclView); - } + auto part = createStimPlanElementColorSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + else + { + auto part = createStimPlanColorInterpolatedSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } - if (stimPlanFracTemplate->showStimPlanMesh()) - { - stimPlanMeshPart = createStimPlanMeshPart(eclView); - } + if (stimPlanFracTemplate->showStimPlanMesh()) + { + auto part = createStimPlanMeshPart(eclView); + if (part.notNull()) parts.push_back(part.p()); } - // Ellipse - else + } + else + { + auto part = createEllipseSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + + double offsetDistanceToCenterLine = 1.0; + { + RimWellPathCollection* wellPathColl = nullptr; + m_rimFracture->firstAncestorOrThisOfType(wellPathColl); + if (wellPathColl) { - surfacePart = createEllipseSurfacePart(eclView); + offsetDistanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; } - if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) + RimSimWellInView* simWell = nullptr; + m_rimFracture->firstAncestorOrThisOfType(simWell); + if (simWell) { - containmentMaskPart = createContainmentMaskPart(eclView); + offsetDistanceToCenterLine = simWell->pipeRadius(); } } - if (surfacePart.notNull()) + // Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture + offsetDistanceToCenterLine *= 0.7; + + auto fractureMatrix = m_rimFracture->transformMatrix(); + cvf::Vec3d fractureNormal = offsetDistanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); + { - model->addPart(surfacePart.p()); + cvf::Mat4d m = cvf::Mat4d::fromTranslation(fractureNormal); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (auto& part : parts) + { + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } } - if (stimPlanMeshPart.notNull()) { - model->addPart(stimPlanMeshPart.p()); + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-fractureNormal); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (const auto& originalPart : parts) + { + auto part = originalPart->shallowCopy(); + + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } } - if (containmentMaskPart.notNull()) + if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) { - model->addPart(containmentMaskPart.p()); + // Position the containment mask outside the fracture parts + + auto originalPart = createContainmentMaskPart(eclView); + if (originalPart.notNull()) + { + auto containmentPartNormal = 1.5 * fractureNormal; + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(containmentPartNormal); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + originalPart->setTransform(partTransform.p()); + model->addPart(originalPart.p()); + } + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-containmentPartNormal); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + auto copy = originalPart->shallowCopy(); + copy->setTransform(partTransform.p()); + model->addPart(copy.p()); + } + } } } From 1523ce55f0aed575a1bc6862bed10dea6faa5ab4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 08:57:34 +0100 Subject: [PATCH 0088/1027] #2150 Fracture : Duplicate fracture geometry for along well pipe fractures --- .../RivWellFracturePartMgr.cpp | 76 +++++++++++-------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 231f6d2a42..e884ae9a7a 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -393,14 +393,12 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE cvf::Mat4d frMx = m_rimFracture->transformMatrix(); cvf::BoundingBox frBBox; - std::vector borderPolygonGlobCs; std::vector borderPolygonLocalCsd; for (const auto& pv: borderPolygonLocalCS) { cvf::Vec3d pvd(pv); borderPolygonLocalCsd.push_back(pvd); pvd.transformPoint(frMx); - borderPolygonGlobCs.push_back(pvd); frBBox.add(pvd); } @@ -437,7 +435,6 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE } cvf::Vec3d fractureNormal = cvf::Vec3d(frMx.col(2)); - cvf::Vec3d maskOffset = fractureNormal * 0.01 * frBBox.radius(); for (const std::vector& eclCellPolygon : eclCellPolygons) { // Clip Eclipse cell polygon with fracture border @@ -469,12 +466,7 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE for (size_t idx: triangleIndices) { - maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx] + maskOffset)) ); - } - - for (size_t idx: triangleIndices) - { - maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx] - maskOffset)) ); + maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx]) ) ); } } } @@ -677,54 +669,65 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (part.notNull()) parts.push_back(part.p()); } - double offsetDistanceToCenterLine = 1.0; + double distanceToCenterLine = 1.0; { RimWellPathCollection* wellPathColl = nullptr; m_rimFracture->firstAncestorOrThisOfType(wellPathColl); if (wellPathColl) { - offsetDistanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; + distanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; } RimSimWellInView* simWell = nullptr; m_rimFracture->firstAncestorOrThisOfType(simWell); if (simWell) { - offsetDistanceToCenterLine = simWell->pipeRadius(); + distanceToCenterLine = simWell->pipeRadius(); } } // Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture - offsetDistanceToCenterLine *= 0.7; + distanceToCenterLine *= 0.1; auto fractureMatrix = m_rimFracture->transformMatrix(); - cvf::Vec3d fractureNormal = offsetDistanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(fractureNormal); + cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - for (auto& part : parts) { - part->setTransform(partTransform.p()); - model->addPart(part.p()); - } - } + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-fractureNormal); + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); + for (auto& part : parts) + { + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } - for (const auto& originalPart : parts) { - auto part = originalPart->shallowCopy(); + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); - part->setTransform(partTransform.p()); + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (const auto& originalPart : parts) + { + auto part = originalPart->shallowCopy(); + + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } + } + else + { + for (auto& part : parts) + { model->addPart(part.p()); } } @@ -732,14 +735,21 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) { // Position the containment mask outside the fracture parts + // Always duplicate the containment mask parts auto originalPart = createContainmentMaskPart(eclView); if (originalPart.notNull()) { - auto containmentPartNormal = 1.5 * fractureNormal; + double scaleFactor = 0.03; + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + { + scaleFactor = 1.5 * distanceToCenterLine; + } + + cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(containmentPartNormal); + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); cvf::ref partTransform = new cvf::Transform; partTransform->setLocalTransform(m); @@ -749,7 +759,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod } { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-containmentPartNormal); + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); cvf::ref partTransform = new cvf::Transform; partTransform->setLocalTransform(m); From 0ecfdeee6b236bad160921393d9432b8be84280e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 09:15:44 +0100 Subject: [PATCH 0089/1027] Reorder functions, remove unused function --- .../RivWellFracturePartMgr.cpp | 353 ++++++++---------- .../RivWellFracturePartMgr.h | 10 - 2 files changed, 164 insertions(+), 199 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index e884ae9a7a..e84d2915e4 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -72,6 +72,170 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +{ + if (!m_rimFracture->isChecked() || !eclView.stimPlanColors->isChecked()) return; + + if (!m_rimFracture->fractureTemplate()) return; + + double characteristicCellSize = eclView.ownerCase()->characteristicCellSize(); + + cvf::Collection parts; + RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + + if (stimPlanFracTemplate) + { + if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) + { + auto part = createStimPlanElementColorSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + else + { + auto part = createStimPlanColorInterpolatedSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + + if (stimPlanFracTemplate->showStimPlanMesh()) + { + auto part = createStimPlanMeshPart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + } + else + { + auto part = createEllipseSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + + double distanceToCenterLine = 1.0; + { + RimWellPathCollection* wellPathColl = nullptr; + m_rimFracture->firstAncestorOrThisOfType(wellPathColl); + if (wellPathColl) + { + distanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; + } + + RimSimWellInView* simWell = nullptr; + m_rimFracture->firstAncestorOrThisOfType(simWell); + if (simWell) + { + distanceToCenterLine = simWell->pipeRadius(); + } + } + + + // Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture + distanceToCenterLine *= 0.1; + + if (distanceToCenterLine < 0.03) + { + distanceToCenterLine = 0.03; + } + + auto fractureMatrix = m_rimFracture->transformMatrix(); + + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + { + cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (auto& part : parts) + { + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (const auto& originalPart : parts) + { + auto part = originalPart->shallowCopy(); + + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } + } + else + { + for (auto& part : parts) + { + model->addPart(part.p()); + } + } + + if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) + { + // Position the containment mask outside the fracture parts + // Always duplicate the containment mask parts + + auto originalPart = createContainmentMaskPart(eclView); + if (originalPart.notNull()) + { + double scaleFactor = 0.03; + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + { + scaleFactor = 2 * distanceToCenterLine; + } + + cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + originalPart->setTransform(partTransform.p()); + model->addPart(originalPart.p()); + } + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + auto copy = originalPart->shallowCopy(); + copy->setTransform(partTransform.p()); + model->addPart(copy.p()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector depthData) +{ + std::vector mirroredValuesAtGivenDepth; + mirroredValuesAtGivenDepth.push_back(depthData[0]); + for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice + { + double valueAtGivenX = depthData[i]; + mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX); + mirroredValuesAtGivenDepth.push_back(valueAtGivenX); + } + + return mirroredValuesAtGivenDepth; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -613,165 +777,6 @@ std::vector RivWellFracturePartMgr::transformToFractureDisplayCoords return polygonInDisplayCoords; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector depthData) -{ - std::vector mirroredValuesAtGivenDepth; - mirroredValuesAtGivenDepth.push_back(depthData[0]); - for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice - { - double valueAtGivenX = depthData[i]; - mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX); - mirroredValuesAtGivenDepth.push_back(valueAtGivenX); - } - - return mirroredValuesAtGivenDepth; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) -{ - if (!m_rimFracture->isChecked() || !eclView.stimPlanColors->isChecked()) return; - - if (!m_rimFracture->fractureTemplate()) return; - - double characteristicCellSize = eclView.ownerCase()->characteristicCellSize(); - - cvf::Collection parts; - RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); - - if (stimPlanFracTemplate) - { - if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) - { - auto part = createStimPlanElementColorSurfacePart(eclView); - if (part.notNull()) parts.push_back(part.p()); - } - else - { - auto part = createStimPlanColorInterpolatedSurfacePart(eclView); - if (part.notNull()) parts.push_back(part.p()); - } - - if (stimPlanFracTemplate->showStimPlanMesh()) - { - auto part = createStimPlanMeshPart(eclView); - if (part.notNull()) parts.push_back(part.p()); - } - } - else - { - auto part = createEllipseSurfacePart(eclView); - if (part.notNull()) parts.push_back(part.p()); - } - - double distanceToCenterLine = 1.0; - { - RimWellPathCollection* wellPathColl = nullptr; - m_rimFracture->firstAncestorOrThisOfType(wellPathColl); - if (wellPathColl) - { - distanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; - } - - RimSimWellInView* simWell = nullptr; - m_rimFracture->firstAncestorOrThisOfType(simWell); - if (simWell) - { - distanceToCenterLine = simWell->pipeRadius(); - } - } - - - // Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture - distanceToCenterLine *= 0.1; - - auto fractureMatrix = m_rimFracture->transformMatrix(); - - if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) - { - cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - for (auto& part : parts) - { - part->setTransform(partTransform.p()); - model->addPart(part.p()); - } - } - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - for (const auto& originalPart : parts) - { - auto part = originalPart->shallowCopy(); - - part->setTransform(partTransform.p()); - model->addPart(part.p()); - } - } - } - else - { - for (auto& part : parts) - { - model->addPart(part.p()); - } - } - - if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) - { - // Position the containment mask outside the fracture parts - // Always duplicate the containment mask parts - - auto originalPart = createContainmentMaskPart(eclView); - if (originalPart.notNull()) - { - double scaleFactor = 0.03; - if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) - { - scaleFactor = 1.5 * distanceToCenterLine; - } - - cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - originalPart->setTransform(partTransform.p()); - model->addPart(originalPart.p()); - } - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - auto copy = originalPart->shallowCopy(); - copy->setTransform(partTransform.p()); - model->addPart(copy.p()); - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -792,33 +797,3 @@ cvf::ref RivWellFracturePartMgr::buildDrawableGeoFromTriangles return geo; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector& polygon, - double xMin, double xMax, double yMin, double yMax, - float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax) -{ - - if (static_cast(xMin) > polygonXmin && static_cast(xMax) < polygonXmax) - { - if (static_cast(yMin) > polygonYmin && static_cast(yMax) < polygonYmax) - { - return true; - } - } - - for (cvf::Vec3f v : polygon) - { - if (v.x() > xMin && v.x() < xMax) - { - if (v.y() > yMin && v.y() < yMax) - { - return true; - } - } - } - - return false; -} - diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 36f1b9250b..1dfd524ce3 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -74,16 +74,6 @@ class RivWellFracturePartMgr : public cvf::Object cvf::Mat4d m, const caf::DisplayCoordTransform& displayCoordTransform); - static bool stimPlanCellTouchesPolygon(const std::vector& polygon, - double xMin, - double xMax, - double yMin, - double yMax, - float polygonXmin, - float polygonXmax, - float polygonYmin, - float polygonYmax); - static cvf::ref buildDrawableGeoFromTriangles(const std::vector& triangleIndices, const std::vector& nodeCoords); private: From b53603e9068aaf3a2d0b94404feef6d985312a28 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 09:21:38 +0100 Subject: [PATCH 0090/1027] Use range based for --- .../ModelVisualization/RivWellFracturePartMgr.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index e84d2915e4..b040826190 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -252,9 +252,9 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc std::vector displayCoords; - for (size_t i = 0; i < nodeCoords.size(); i++) + for (const auto& nodeCoord : nodeCoords) { - cvf::Vec3d nodeCoordsDouble = static_cast(nodeCoords[i]); + cvf::Vec3d nodeCoordsDouble = static_cast(nodeCoord); cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble); displayCoords.push_back(static_cast(displayCoordsDouble)); } @@ -307,14 +307,13 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa } // Transforms the node coordinates for display - for (size_t i = 0; i < nodeCoords.size(); i++) + for (auto& nodeCoord : nodeCoords) { - cvf::Vec3d doubleCoord(nodeCoords[i]); + cvf::Vec3d doubleCoord(nodeCoord); doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord); - nodeCoords[i] = cvf::Vec3f(doubleCoord); + nodeCoord = cvf::Vec3f(doubleCoord); } - RimLegendConfig* legendConfig = nullptr; if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked()) { From 03de2aba5b48512a3d3288b749a30886a6154059 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 11:05:31 +0100 Subject: [PATCH 0091/1027] #2332 2D Intersection View: Command to create view --- ApplicationCode/CMakeLists.txt | 1 + .../CMakeLists_files.cmake | 23 ++++ .../RicNewIntersectionViewFeature.cpp | 106 ++++++++++++++++++ .../RicNewIntersectionViewFeature.h | 41 +++++++ .../Rim2dIntersectionView.cpp | 8 ++ .../ProjectDataModel/Rim2dIntersectionView.h | 2 + ApplicationCode/ProjectDataModel/RimCase.cpp | 17 +++ ApplicationCode/ProjectDataModel/RimCase.h | 3 + .../RimContextCommandBuilder.cpp | 2 + .../UserInterface/RiuViewerCommands.cpp | 2 + 10 files changed, 205 insertions(+) create mode 100644 ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake create mode 100644 ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp create mode 100644 ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 3ad68a64f1..89390cf952 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -123,6 +123,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/ExportCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake + Commands/IntersectionViewCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake Commands/OperationsUsingObjReferences/CMakeLists_files.cmake Commands/SummaryPlotCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..30d4a7728f --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\IntersectionView" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp new file mode 100644 index 0000000000..fca8cb7e0e --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -0,0 +1,106 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewIntersectionViewFeature.h" + +#include "Rim2dIntersectionView.h" +#include "RimCase.h" +#include "RimIntersection.h" + +#include "RiuMainWindow.h" +#include "RiuSelectionManager.h" + +#include "cafSelectionManagerTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewIntersectionViewFeature::isCommandEnabled() +{ + std::vector objects = selectedIntersections(); + + return !objects.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) +{ + std::vector intersections = selectedIntersections(); + + Rim2dIntersectionView* objectToSelect = nullptr; + + for (auto intersection : intersections) + { + if (!intersection) continue; + + RimCase* rimCase = nullptr; + intersection->firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection); + intersectionView->loadDataAndUpdate(); + + rimCase->updateConnectedEditors(); + + objectToSelect = intersectionView; + } + } + + if (objectToSelect) + { + RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Intersection View"); + // actionToSetup->setIcon(QIcon(":/chain.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicNewIntersectionViewFeature::selectedIntersections() +{ + std::vector objects = caf::selectedObjectsByType(); + + RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); + RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); + + RiuGeneralSelectionItem* generalSelectionItem = static_cast(selItem); + if (generalSelectionItem) + { + RimIntersection* intersection = dynamic_cast(generalSelectionItem->m_object); + if (intersection) + { + objects.push_back(intersection); + } + } + + return objects; +} diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h new file mode 100644 index 0000000000..f11fe6d2eb --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimIntersection; + +//================================================================================================== +/// +//================================================================================================== +class RicNewIntersectionViewFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; + +private: + static std::vector selectedIntersections(); +}; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index fbf7889f05..5eb600de7c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -51,6 +51,14 @@ Rim2dIntersectionView::~Rim2dIntersectionView(void) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) +{ + m_intersection = intersection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index e7b0f654dd..6948d4e91d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -39,6 +39,8 @@ class Rim2dIntersectionView : public Rim3dView Rim2dIntersectionView(void); virtual ~Rim2dIntersectionView(void); + void setIntersection(RimIntersection* intersection); + virtual bool isUsingFormationNames() const override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index f64d6d8bbf..e1fb8f6a37 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -29,6 +29,7 @@ #include "cafPdmObjectFactory.h" #include "Rim2dIntersectionView.h" +#include "RimIntersection.h" CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); @@ -112,6 +113,22 @@ size_t RimCase::uiToNativeTimeStepIndex(size_t uiTimeStepIndex) return uiTimeStepIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* RimCase::createAndAddIntersectionView(RimIntersection* intersection) +{ + Rim2dIntersectionView* intersectionView = new Rim2dIntersectionView; + intersectionView->setIntersection(intersection); + + QString name = QString("View of Intersection %1").arg(intersection->name()); + intersectionView->name = name; + + m_intersectionViews.push_back(intersectionView); + + return intersectionView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 94721dd14d..fb33a38f74 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -34,6 +34,7 @@ class Rim3dView; class RimFormationNames; class RimTimeStepFilter; class Rim2dIntersectionView; +class RimIntersection; namespace cvf { class BoundingBox; @@ -71,6 +72,8 @@ class RimCase : public caf::PdmObject size_t uiToNativeTimeStepIndex(size_t uiTimeStepIndex); + Rim2dIntersectionView* createAndAddIntersectionView(RimIntersection* intersection); + protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual std::vector allSpecialViews() const = 0; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 20706c13a9..c566fa08af 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -454,6 +454,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewIntersectionViewFeature"; } else if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index ebad8faad5..5ac048c879 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -221,6 +221,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder << "RicHideIntersectionFeature"; menuBuilder.addSeparator(); + menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder.addSeparator(); } else if (intersectionBoxSourceInfo) { From 3bcfc09baf86080d97ad72db7a5d05cea1d4966b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 11:29:06 +0100 Subject: [PATCH 0092/1027] #2332 2D Intersection View: Show warning if intersection is not vertical --- .../RicNewIntersectionViewFeature.cpp | 31 ++++++++++++++++--- .../RicNewIntersectionViewFeature.h | 4 +-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index fca8cb7e0e..07d5e9563f 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -28,6 +28,7 @@ #include "cafSelectionManagerTools.h" #include +#include CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); @@ -36,7 +37,7 @@ CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeatur //-------------------------------------------------------------------------------------------------- bool RicNewIntersectionViewFeature::isCommandEnabled() { - std::vector objects = selectedIntersections(); + std::set objects = selectedIntersections(); return !objects.empty(); } @@ -46,7 +47,7 @@ bool RicNewIntersectionViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) { - std::vector intersections = selectedIntersections(); + std::set intersections = selectedIntersections(); Rim2dIntersectionView* objectToSelect = nullptr; @@ -58,6 +59,14 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) intersection->firstAncestorOrThisOfType(rimCase); if (rimCase) { + if (intersection->direction() != RimIntersection::CS_VERTICAL) + { + QString text = QString("Intersection '%1' is not a vertical intersection. The intersection view supports" + "only vertical intersections.").arg(intersection->name()); + + QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text); + } + Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection); intersectionView->loadDataAndUpdate(); @@ -85,9 +94,9 @@ void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicNewIntersectionViewFeature::selectedIntersections() +std::set RicNewIntersectionViewFeature::selectedIntersections() { - std::vector objects = caf::selectedObjectsByType(); + std::set objects; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); @@ -98,7 +107,19 @@ std::vector RicNewIntersectionViewFeature::selectedIntersectio RimIntersection* intersection = dynamic_cast(generalSelectionItem->m_object); if (intersection) { - objects.push_back(intersection); + objects.insert(intersection); + + // Return only the intersection the user clicked on + + return objects; + } + } + + { + std::vector selectedObjects = caf::selectedObjectsByType(); + for (auto obj : selectedObjects) + { + objects.insert(obj); } } diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h index f11fe6d2eb..7f7a1af9d6 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h @@ -20,7 +20,7 @@ #include "cafCmdFeature.h" -#include +#include class RimIntersection; @@ -37,5 +37,5 @@ class RicNewIntersectionViewFeature : public caf::CmdFeature void setupActionLook(QAction* actionToSetup) override; private: - static std::vector selectedIntersections(); + static std::set selectedIntersections(); }; From b74dca8de89b0fddd8de16c56846dffce3123307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 17 Jan 2018 10:46:24 +0100 Subject: [PATCH 0093/1027] #2379 import summary cases. Fix path filtering --- .../Commands/RicFileHierarchyDialog.cpp | 136 ++++++++++++++---- .../Commands/RicFileHierarchyDialog.h | 16 ++- 2 files changed, 119 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 2e2c474269..754dccbf33 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -41,11 +41,19 @@ #include #include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// Internal variables +//-------------------------------------------------------------------------------------------------- +static QString separator = QString(QDir::separator()); //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -QStringList prefixStrings(const QStringList& strings, const QString& prefix); +static QStringList prefixStrings(const QStringList& strings, const QString& prefix); +static QString relativePath(const QString& rootDir, const QString& dir); //-------------------------------------------------------------------------------------------------- /// @@ -131,7 +139,12 @@ QStringList RicFileHierarchyDialog::files() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::rootDir() const { - return m_rootDir->text(); + QString rootDir = m_rootDir->text(); + if (!rootDir.endsWith(separator)) + { + rootDir.append(separator); + } + return QDir::toNativeSeparators(rootDir); } //-------------------------------------------------------------------------------------------------- @@ -139,7 +152,7 @@ QString RicFileHierarchyDialog::rootDir() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::pathFilter() const { - return m_pathFilter->text(); + return QDir::toNativeSeparators(m_pathFilter->text()); } //-------------------------------------------------------------------------------------------------- @@ -171,10 +184,31 @@ bool RicFileHierarchyDialog::cancelPressed() const //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { + QString text = m_fileList->toPlainText(); + if (text.startsWith("Working .")) m_fileList->setText(""); + m_fileList->append(fileName); QApplication::processEvents(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::updateStatus() +{ + static time_t lastStatusUpdate = 0; + time_t now = time(0); + + if (now == lastStatusUpdate) return; + lastStatusUpdate = now; + + QString currStatus = m_fileList->toPlainText(); + if (currStatus == "") m_fileList->setText("Working ."); + else if (currStatus == "Working .") m_fileList->setText("Working .."); + else if (currStatus == "Working ..") m_fileList->setText("Working ..."); + else if (currStatus == "Working ...") m_fileList->setText("Working ."); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -207,40 +241,71 @@ RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *p //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::findMatchingFiles(RicFileHierarchyDialog& dialog) +QStringList RicFileHierarchyDialog::findMatchingFiles() { - return findFilesRecursive(dialog.rootDir(), dialog); + QStringList dirs = buildDirectoryListRecursive(rootDir()); + + return findFilesInDirs(dirs); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::findFilesRecursive(const QString ¤tDir, RicFileHierarchyDialog& dialog) +QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& currentDir) { - QStringList allFiles; + QStringList allDirs; - if (dialog.cancelPressed()) return allFiles; + if (cancelPressed()) return allDirs; + + updateStatus(); QDir qdir(currentDir); QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - QStringList files = qdir.entryList(createNameFilterList(dialog.fileNameFilter(), dialog.fileExtensions()), QDir::Files); - for (QString file : files) + if (pathFilterMatch(currentDir)) { - QString absFilePath = qdir.absoluteFilePath(file); - if (pathFilterMatch(absFilePath, dialog.pathFilter())) + allDirs.push_back(currentDir); + } + else + { + // If there is no match and filter string does not start with a wildcard, there is no need to enter sub directories + if (!pathFilter().startsWith("*") && !relativePath(rootDir(), currentDir).isEmpty()) { - allFiles.append(absFilePath); - dialog.appendToFileList(absFilePath); + return QStringList(); } } for (QString subDir : subDirs) { QApplication::processEvents(); - allFiles += findFilesRecursive(qdir.absoluteFilePath(subDir), dialog); + allDirs += buildDirectoryListRecursive(QDir::toNativeSeparators(qdir.absoluteFilePath(subDir))); + } + return cancelPressed() ? QStringList() : allDirs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::findFilesInDirs(const QStringList& dirs) +{ + QStringList allFiles; + QStringList filters = createNameFilterList(fileNameFilter(), fileExtensions()); + + for (const auto& dir : dirs) + { + QDir qdir(dir); + QStringList files = qdir.entryList(filters, QDir::Files); + + updateStatus(); + + for (QString file : files) + { + QString absFilePath = QDir::toNativeSeparators(qdir.absoluteFilePath(file)); + allFiles.append(absFilePath); + appendToFileList(absFilePath); + } } - return dialog.cancelPressed() ? QStringList() : allFiles; + return allFiles; } //-------------------------------------------------------------------------------------------------- @@ -268,14 +333,12 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicFileHierarchyDialog::pathFilterMatch(const QString& file, const QString& pathFilter) +bool RicFileHierarchyDialog::pathFilterMatch(const QString& dir) { - QRegExp regexp(pathFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp regexp(pathFilter(), Qt::CaseInsensitive, QRegExp::Wildcard); + QString relPath = relativePath(rootDir(), dir); - QFileInfo fileInfo(file); - QString path = fileInfo.absolutePath(); - - return regexp.exactMatch(path); + return regexp.exactMatch(relPath); } //-------------------------------------------------------------------------------------------------- @@ -283,8 +346,6 @@ bool RicFileHierarchyDialog::pathFilterMatch(const QString& file, const QString& //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::updateEffectiveFilter() { - QString sep(QDir::separator()); - QString effFilter = QString("%1/%2/%3%4") .arg(m_rootDir->text()) .arg(m_pathFilter->text()) @@ -298,7 +359,7 @@ void RicFileHierarchyDialog::updateEffectiveFilter() do { len = native.size(); - native.replace(sep + sep, sep); + native.replace(separator + separator, separator); } while (native.size() != len); m_effectiveFilter->setText(native); @@ -318,7 +379,7 @@ void RicFileHierarchyDialog::slotFilterChanged(const QString& text) void RicFileHierarchyDialog::slotDialogOkClicked() { m_cancelPressed = false; - m_files = findMatchingFiles(*this); + m_files = findMatchingFiles(); accept(); } @@ -345,6 +406,10 @@ void RicFileHierarchyDialog::slotBrowseButtonClicked() //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- QStringList prefixStrings(const QStringList& strings, const QString& prefix) { QStringList prefixedStrings; @@ -361,3 +426,22 @@ QStringList prefixStrings(const QStringList& strings, const QString& prefix) } return prefixedStrings; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString relativePath(const QString& rootDir, const QString& dir) +{ + if (dir.startsWith(rootDir)) + { + QString relPath = dir; + relPath.remove(0, rootDir.size()); + + if (relPath.startsWith("/") || relPath.startsWith("\\")) relPath.remove(0, 1); + return relPath; + } + else + { + return dir; + } +} diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 488926ecd9..38f900347b 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -51,6 +51,7 @@ class RicFileHierarchyDialog : public QDialog bool cancelPressed() const; void appendToFileList(const QString& fileName); + void updateStatus(); static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, const QString& caption = QString(), @@ -60,17 +61,18 @@ class RicFileHierarchyDialog : public QDialog const QStringList& fileExtensions = QStringList()); private: - static QStringList findMatchingFiles(RicFileHierarchyDialog& dialog); + QStringList findMatchingFiles(); - static QStringList findFilesRecursive(const QString& currentDir, - RicFileHierarchyDialog& dialog); + QStringList buildDirectoryListRecursive(const QString& currentDir); - static QStringList createNameFilterList(const QString& fileNameFilter, - const QStringList& fileExtensions); + QStringList findFilesInDirs(const QStringList& dirs); - static bool pathFilterMatch(const QString& file, const QString& pathFilter); + QStringList createNameFilterList(const QString& fileNameFilter, + const QStringList& fileExtensions); - void updateEffectiveFilter(); + bool pathFilterMatch(const QString& dir); + + void updateEffectiveFilter(); private slots: void slotFilterChanged(const QString& text); From 8f384c975210aa50f307bea7757e334635ab5ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 17 Jan 2018 13:04:18 +0100 Subject: [PATCH 0094/1027] #2379 import summary cases. Dialog improvements, find button, grouping widgets --- .../Commands/RicFileHierarchyDialog.cpp | 119 +++++++++++++++--- .../Commands/RicFileHierarchyDialog.h | 5 + 2 files changed, 104 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 754dccbf33..97c4e8bf45 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -39,11 +39,17 @@ #include #include #include +#include #include #include #include + +#define FIND_BUTTON_FIND_TEXT "Find" +#define FIND_BUTTON_CANCEL_TEXT "Cancel" +#define NO_FILES_FOUND_TEXT "No files found" + //-------------------------------------------------------------------------------------------------- /// Internal variables //-------------------------------------------------------------------------------------------------- @@ -74,14 +80,16 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_effectiveFilter = new QLabel(); m_fileListLabel = new QLabel(); m_fileList = new QTextEdit(); + m_findOrCancelButton = new QPushButton(); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - // Connect to close button signal + // Connect to signals connect(m_rootDir, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); connect(m_pathFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); connect(m_fileFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_findOrCancelButton, SIGNAL(clicked()), this, SLOT(slotFindOrCancelButtonClicked())); connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); connect(m_browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked())); @@ -91,29 +99,42 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_pathFilterLabel->setText("Path pattern"); m_fileFilterLabel->setText("File pattern"); m_effectiveFilterLabel->setText("Effective filter"); + m_effectiveFilter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_fileListLabel->setText("Files found"); m_fileList->setLineWrapMode(QTextEdit::NoWrap); + m_fileListLabel->setVisible(false); + m_fileList->setVisible(false); m_browseButton->setText("..."); m_browseButton->setFixedWidth(25); + m_findOrCancelButton->setText("Find"); + m_findOrCancelButton->setFixedWidth(75); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); - QGridLayout* gridLayout = new QGridLayout(); - gridLayout->addWidget(m_rootDirLabel, 0, 0); - gridLayout->addWidget(m_rootDir, 0, 1); - gridLayout->addWidget(m_browseButton, 0, 2); - gridLayout->addWidget(m_pathFilterLabel, 1, 0); - gridLayout->addWidget(m_pathFilter, 1, 1); - gridLayout->addWidget(m_fileFilterLabel, 2, 0); - gridLayout->addWidget(m_fileFilter, 2, 1); - gridLayout->addWidget(m_fileExtension, 2, 2); - gridLayout->addWidget(m_effectiveFilterLabel, 3, 0); - gridLayout->addWidget(m_effectiveFilter, 3, 1); - gridLayout->addWidget(m_fileListLabel, 4, 0); - gridLayout->addWidget(m_fileList, 4, 1); - - dialogLayout->addLayout(gridLayout); + QGroupBox* inputGroup = new QGroupBox("Filter"); + QGridLayout* inputGridLayout = new QGridLayout(); + inputGridLayout->addWidget(m_rootDirLabel, 0, 0); + inputGridLayout->addWidget(m_rootDir, 0, 1); + inputGridLayout->addWidget(m_browseButton, 0, 2); + inputGridLayout->addWidget(m_pathFilterLabel, 1, 0); + inputGridLayout->addWidget(m_pathFilter, 1, 1); + inputGridLayout->addWidget(m_fileFilterLabel, 2, 0); + inputGridLayout->addWidget(m_fileFilter, 2, 1); + inputGridLayout->addWidget(m_fileExtension, 2, 2); + inputGroup->setLayout(inputGridLayout); + + QGroupBox* outputGroup = new QGroupBox("Files"); + QGridLayout* outputGridLayout = new QGridLayout(); + outputGridLayout->addWidget(m_effectiveFilterLabel, 0, 0); + outputGridLayout->addWidget(m_effectiveFilter, 0, 1); + outputGridLayout->addWidget(m_findOrCancelButton, 0, 2); + outputGridLayout->addWidget(m_fileListLabel, 1, 0); + outputGridLayout->addWidget(m_fileList, 1, 1, 1, 2); + outputGroup->setLayout(outputGridLayout); + + dialogLayout->addWidget(inputGroup); + dialogLayout->addWidget(outputGroup); dialogLayout->addWidget(m_buttons); setLayout(dialogLayout); @@ -185,12 +206,22 @@ bool RicFileHierarchyDialog::cancelPressed() const void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { QString text = m_fileList->toPlainText(); - if (text.startsWith("Working .")) m_fileList->setText(""); + if (text.startsWith("Working .")) clearFileList(); m_fileList->append(fileName); QApplication::processEvents(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::clearFileList() +{ + m_files.clear(); + m_fileList->setText(""); + setOkButtonEnabled(false); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -231,8 +262,9 @@ RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *p dialog.updateEffectiveFilter(); dialog.m_fileList->setText(""); + dialog.setOkButtonEnabled(false); - dialog.resize(600, 250); + dialog.resize(600, 150); dialog.exec(); return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir(), dialog.pathFilter(), dialog.fileNameFilter()); @@ -365,21 +397,68 @@ void RicFileHierarchyDialog::updateEffectiveFilter() m_effectiveFilter->setText(native); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::setOkButtonEnabled(bool enabled) +{ + m_buttons->button(QDialogButtonBox::Ok)->setEnabled(enabled); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::slotFilterChanged(const QString& text) { + clearFileList(); updateEffectiveFilter(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() +{ + if (m_findOrCancelButton->text() == FIND_BUTTON_FIND_TEXT) + { + clearFileList(); + + if (!m_fileList->isVisible()) + { + m_fileListLabel->setVisible(true); + m_fileList->setVisible(true); + resize(600, 350); + } + + m_findOrCancelButton->setText(FIND_BUTTON_CANCEL_TEXT); + + m_cancelPressed = false; + m_files = findMatchingFiles(); + + m_findOrCancelButton->setText(FIND_BUTTON_FIND_TEXT); + + if (m_cancelPressed) + { + clearFileList(); + } + else if(m_files.isEmpty()) + { + m_fileList->setText(NO_FILES_FOUND_TEXT); + } + + setOkButtonEnabled(!m_files.isEmpty()); + } + else + { + m_cancelPressed = true; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::slotDialogOkClicked() { - m_cancelPressed = false; - m_files = findMatchingFiles(); accept(); } diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 38f900347b..fe9cb628ea 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -51,6 +51,7 @@ class RicFileHierarchyDialog : public QDialog bool cancelPressed() const; void appendToFileList(const QString& fileName); + void clearFileList(); void updateStatus(); static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, @@ -74,8 +75,11 @@ class RicFileHierarchyDialog : public QDialog void updateEffectiveFilter(); + void setOkButtonEnabled(bool enabled); + private slots: void slotFilterChanged(const QString& text); + void slotFindOrCancelButtonClicked(); void slotDialogOkClicked(); void slotDialogCancelClicked(); void slotBrowseButtonClicked(); @@ -98,6 +102,7 @@ private slots: QLabel* m_fileListLabel; QTextEdit* m_fileList; + QPushButton* m_findOrCancelButton; QDialogButtonBox* m_buttons; QStringList m_files; From 50c3e5f0d2ccdc8cf9571cea66c64d7007cfd3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 17 Jan 2018 13:15:04 +0100 Subject: [PATCH 0095/1027] #2379 import summary cases. Minor refactoring --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 97c4e8bf45..a7828af085 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -49,6 +49,9 @@ #define FIND_BUTTON_FIND_TEXT "Find" #define FIND_BUTTON_CANCEL_TEXT "Cancel" #define NO_FILES_FOUND_TEXT "No files found" +#define WORKING_TEXT_1 "Working ." +#define WORKING_TEXT_2 "Working .." +#define WORKING_TEXT_3 "Working ..." //-------------------------------------------------------------------------------------------------- /// Internal variables @@ -206,7 +209,7 @@ bool RicFileHierarchyDialog::cancelPressed() const void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { QString text = m_fileList->toPlainText(); - if (text.startsWith("Working .")) clearFileList(); + if (text.startsWith(WORKING_TEXT_1)) clearFileList(); m_fileList->append(fileName); QApplication::processEvents(); @@ -234,10 +237,10 @@ void RicFileHierarchyDialog::updateStatus() lastStatusUpdate = now; QString currStatus = m_fileList->toPlainText(); - if (currStatus == "") m_fileList->setText("Working ."); - else if (currStatus == "Working .") m_fileList->setText("Working .."); - else if (currStatus == "Working ..") m_fileList->setText("Working ..."); - else if (currStatus == "Working ...") m_fileList->setText("Working ."); + if (currStatus == "") m_fileList->setText(WORKING_TEXT_1); + else if (currStatus == WORKING_TEXT_1) m_fileList->setText(WORKING_TEXT_2); + else if (currStatus == WORKING_TEXT_2) m_fileList->setText(WORKING_TEXT_3); + else if (currStatus == WORKING_TEXT_3) m_fileList->setText(WORKING_TEXT_1); } //-------------------------------------------------------------------------------------------------- From c0d9ef67fa0946bf88d04f48110f6c47c8cceadb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 13:37:41 +0100 Subject: [PATCH 0096/1027] #2361 AppFwk : Make sure identical strings are separated by semicolon --- .../cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp index a634a0b57a..443dc469a5 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -18,11 +18,11 @@ QTextStream& operator<<(QTextStream& str, const std::vector& file trimmedEntries.push_back(text); } - for (const auto& s : trimmedEntries) + for (size_t i = 0; i < trimmedEntries.size(); i++) { - str << s; + str << trimmedEntries[i]; - if (s != trimmedEntries.back()) + if (i < trimmedEntries.size() - 1) { str << ";"; } From 76b84cbb173fe5378b8293797b44765049ace221 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 14:32:44 +0100 Subject: [PATCH 0097/1027] #2361 AppFwk : Make sure field of FilePath supports space, add more tests --- .../cafPdmCore/cafFilePath.cpp | 14 +++++- .../cafPdmCoreBasicTest.cpp | 43 +++++++++++++++++++ .../cafInternalPdmFieldTypeSpecializations.h | 38 ++++++++++++++++ .../cafInternalPdmFilePathStreamOperators.cpp | 2 +- .../cafPdmAdvancedTemplateTest.cpp | 4 ++ .../cafPdmXmlBasicTest.cpp | 42 +++++++++++++++++- 6 files changed, 139 insertions(+), 4 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp index edc816de53..b95a274108 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp @@ -50,7 +50,19 @@ bool caf::FilePath::operator==(const FilePath& other) const QTextStream& operator>>(QTextStream& str, caf::FilePath& filePath) { QString text; - str >> text; + + while (str.status() == QTextStream::Ok) + { + // Read QChar to avoid white space trimming when reading QString + QChar singleChar; + str >> singleChar; + + if (!singleChar.isNull()) + { + text += singleChar; + } + } + filePath.setPath(text); return str; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp index 23175f8796..b4e51874dc 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp @@ -12,6 +12,8 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmValueField.h" +#include + class DemoPdmObject: public caf::PdmObjectHandle { @@ -36,6 +38,7 @@ class DemoPdmObject: public caf::PdmObjectHandle this->addField(&m_memberStringField, "m_memberStringField"); + // Default values m_doubleMember = 2.1; m_intMember = 7; @@ -87,12 +90,18 @@ class InheritedDemoObj : public DemoPdmObject this->addField(&m_texts, "Texts"); this->addField(&m_childArrayField, "DemoPdmObjectects"); this->addField(&m_ptrField, "m_ptrField"); + + this->addField(&m_singleFilePath, "m_singleFilePath"); + this->addField(&m_multipleFilePath, "m_multipleFilePath"); } caf::PdmDataValueField m_texts; caf::PdmChildArrayField m_childArrayField; caf::PdmPtrField m_ptrField; + + caf::PdmDataValueField m_singleFilePath; + caf::PdmDataValueField> m_multipleFilePath; }; @@ -589,3 +598,37 @@ TEST(BaseTest, PdmPointer) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, PdmFilePath) +{ + InheritedDemoObj* d = new InheritedDemoObj; + + QVariant newVal = "path with space"; + d->m_singleFilePath.setFromQVariant(newVal); + + QVariant var = d->m_singleFilePath.toQVariant(); + ASSERT_TRUE(newVal == var); + + delete d; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, MultiplePdmFilePath) +{ + InheritedDemoObj* d = new InheritedDemoObj; + + QString newVal = "path with space"; + d->m_multipleFilePath.v().push_back(newVal); + d->m_multipleFilePath.v().push_back(newVal); + + QVariant var = d->m_multipleFilePath.toQVariant(); + QStringList str = var.toStringList(); + + EXPECT_EQ(2, str.size()); + + delete d; +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h index 387bea9263..ee2baa15cb 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h @@ -186,4 +186,42 @@ class PdmUiFieldSpecialization < caf::AppEnum > }; + +//================================================================================================== +/// Partial specialization for FilePath +//================================================================================================== + +template <> +class PdmUiFieldSpecialization +{ +public: + /// Convert the field value into a QVariant + static QVariant convert(const caf::FilePath& value) + { + return PdmValueFieldSpecialization::convert(value); + } + + /// Set the field value from a QVariant + static void setFromVariant(const QVariant& variantValue, caf::FilePath& value) + { + return PdmValueFieldSpecialization::setFromVariant(variantValue, value); + } + + static bool isDataElementEqual(const QVariant& variantValue, const QVariant& variantValue2) + { + return PdmValueFieldSpecialization::isEqual(variantValue, variantValue2); + } + + /// Methods to get a list of options for a field, specialized for AppEnum + static QList valueOptions( bool* useOptionsOnly, const caf::FilePath& ) + { + return QList(); + } + + /// Methods to retrieve the possible PdmObject pointed to by a field + static void childObjects(const PdmDataValueField< caf::FilePath > & field, std::vector* objects) + { } + +}; + } // End namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp index 443dc469a5..a738d16b9a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -18,7 +18,7 @@ QTextStream& operator<<(QTextStream& str, const std::vector& file trimmedEntries.push_back(text); } - for (size_t i = 0; i < trimmedEntries.size(); i++) + for (int i = 0; i < trimmedEntries.size(); i++) { str << trimmedEntries[i]; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp index ae9acc4301..ea0be7c31b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp @@ -11,6 +11,7 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmXmlObjectHandle.h" #include "cafPdmXmlObjectHandleMacros.h" +#include "cafFilePath.h" #include @@ -100,6 +101,9 @@ class DemoPdmObjectA : public caf::PdmObjectHandle, public caf::PdmXmlObjectHand caf::PdmPtrField< caf::PdmObjectHandle* > m_pointerToItem; caf::PdmPtrField< caf::PdmObjectHandle* > m_pointerToDemoObj; + caf::PdmDataValueField< caf::FilePath > m_singleFilePath; + + void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; } double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; } double m_doubleMember; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp index 86078bacf8..00507bb0b0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp @@ -198,13 +198,20 @@ class SimpleObj : public caf::PdmObjectHandle, public caf::PdmXmlObjectHandle CAF_PDM_XML_InitField(&m_position, "Position"); CAF_PDM_XML_InitField(&m_dir, "Dir"); CAF_PDM_XML_InitField(&m_up, "Up"); - } + + CAF_PDM_XML_InitField(&m_singleFilePath, "m_singleFilePath"); + CAF_PDM_XML_InitField(&m_multipleFilePath, "m_multipleFilePath"); + } caf::PdmDataValueField m_position; caf::PdmDataValueField m_dir; caf::PdmDataValueField m_up; caf::PdmProxyValueField m_proxyDouble; + caf::PdmDataValueField m_singleFilePath; + caf::PdmDataValueField> m_multipleFilePath; + + void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; } double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; } @@ -349,6 +356,37 @@ TEST(BaseTest, QXMLStreamTest) tt = inputStream.readNext(); std::cout << inputStream.name().toString().toStdString() << std::endl; } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, FilePathSerializing) +{ + SimpleObj* s1 = new SimpleObj; + + QString newVal = "path with space"; + s1->m_multipleFilePath.v().push_back(newVal); + s1->m_multipleFilePath.v().push_back(newVal); + + s1->m_singleFilePath = newVal; + + QString serializedString = s1->writeObjectToXmlString(); + + { + SimpleObj* ihd1 = new SimpleObj; + + QXmlStreamReader xmlStream(serializedString); + + ihd1->readObjectFromXmlString(serializedString, caf::PdmDefaultObjectFactory::instance()); + + EXPECT_EQ(2, ihd1->m_multipleFilePath.v().size()); + EXPECT_EQ(newVal.toStdString(), ihd1->m_singleFilePath().path().toStdString()); + + delete ihd1; + } + delete s1; +} -} \ No newline at end of file From b6a7dcb7b58e5af4094123d9550840739a4570f6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 17 Jan 2018 14:44:21 +0100 Subject: [PATCH 0098/1027] Upped version to 2018.01.00-dev.02 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 10aaf91004..efce40c205 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".01") +set(RESINSIGHT_DEV_VERSION ".02") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From bbda7f30a2d5784276db26b7f79570baff55928d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 16 Jan 2018 16:49:28 +0100 Subject: [PATCH 0099/1027] NULL -> nullptr --- .../ProjectDataModel/RimProject.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 10898f4bda..fbf8cffe88 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -206,7 +206,7 @@ void RimProject::close() calculationCollection->deleteAllContainedObjects(); delete viewLinkerCollection->viewLinker(); - viewLinkerCollection->viewLinker = NULL; + viewLinkerCollection->viewLinker = nullptr; fileName = ""; @@ -262,7 +262,7 @@ void RimProject::initScriptDirectories() } // Find largest used groupId read from file and make sure all groups have a valid groupId - RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr; if (analysisModels) { int largestGroupId = -1; @@ -311,7 +311,7 @@ void RimProject::initAfterRead() // Handle old project files with obsolete structure. // Move caseGroupsObsolete and casesObsolete to oilFields()[idx]->analysisModels() - RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr; bool movedOneRimIdenticalGridCaseGroup = false; for (size_t cgIdx = 0; cgIdx < caseGroupsObsolete.size(); ++cgIdx) { @@ -335,7 +335,7 @@ void RimProject::initAfterRead() if (analysisModels) { RimEclipseCase* sourceCase = casesObsolete[cIdx]; - casesObsolete.set(cIdx, NULL); + casesObsolete.set(cIdx, nullptr); analysisModels->cases.push_back(sourceCase); //printf("Moved m_project->casesObsolete[%i] to first oil fields analysis models\n", cIdx); movedOneRimCase = true; // moved at least one so assume the others will be moved too... @@ -357,7 +357,7 @@ void RimProject::initAfterRead() for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++) { RimOilField* oilField = oilFields[oilFieldIdx]; - if (oilField == NULL || oilField->wellPathCollection == NULL) continue; + if (oilField == nullptr || oilField->wellPathCollection == nullptr) continue; } } @@ -458,16 +458,16 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName // Update path to well path file cache for(RimOilField* oilField: oilFields) { - if (oilField == NULL) continue; - if (oilField->wellPathCollection() != NULL) + if (oilField == nullptr) continue; + if (oilField->wellPathCollection() != nullptr) { oilField->wellPathCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } - if (oilField->formationNamesCollection() != NULL) + if (oilField->formationNamesCollection() != nullptr) { oilField->formationNamesCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } - if (oilField->summaryCaseMainCollection() != NULL) { + if (oilField->summaryCaseMainCollection() != nullptr) { oilField->summaryCaseMainCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } @@ -537,7 +537,7 @@ void RimProject::allCases(std::vector& cases) { // Load the Main case of each IdenticalGridCaseGroup RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx]; - if (cg == NULL) continue; + if (cg == nullptr) continue; if (cg->statisticsCaseCollection()) { @@ -685,7 +685,7 @@ void RimProject::createDisplayModelAndRedrawAllViews() for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++) { RimCase* rimCase = cases[caseIdx]; - if (rimCase == NULL) continue; + if (rimCase == nullptr) continue; std::vector views = rimCase->views(); for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) From 39cf8e8b0d7f0c5f5ac143ca4e7a114b02fec0d1 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 18 Jan 2018 11:42:29 +0100 Subject: [PATCH 0100/1027] #2378 Fractures: Hide "Fracture Colors" in Project tree when not in use --- ApplicationCode/Commands/RicDeleteItemExec.cpp | 15 +++++++++++++-- .../RicNewEllipseFractureTemplateFeature.cpp | 15 ++++++++++++++- .../RicNewStimPlanFractureTemplateFeature.cpp | 17 +++++++++++++++-- .../ProjectDataModel/RimEclipseView.cpp | 14 +++++++++++++- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 1f39ef9d28..e3fdf1a4a6 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -23,17 +23,18 @@ #include "RiaApplication.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellRangeFilterCollection.h" #include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseView.h" #include "RimFormationNamesCollection.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimIntersectionCollection.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimSummaryPlotCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "Rim3dView.h" +#include "RimSummaryPlotCollection.h" #include "RimViewLinkerCollection.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -150,6 +151,16 @@ void RicDeleteItemExec::redo() { proj->createDisplayModelAndRedrawAllViews(); } + + std::vector views; + proj->allVisibleViews(views); + for (Rim3dView* view : views) + { + if (dynamic_cast(view)) + { + view->updateConnectedEditors(); + } + } } #endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index 2d521f37c0..1b7d124b6e 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -20,9 +20,10 @@ #include "RiaApplication.h" -#include "RimOilField.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" +#include "RimOilField.h" #include "RimProject.h" #include "RiuMainWindow.h" @@ -58,6 +59,18 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) ellipseFractureTemplate->setDefaultValuesFromUnit(); fracDefColl->updateConnectedEditors(); + + std::vector views; + project->allVisibleViews(views); + + for (Rim3dView* view : views) + { + if (dynamic_cast(view)) + { + view->updateConnectedEditors(); + } + } + RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate); } } diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp index 440ce22623..76419b3d3b 100644 --- a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp @@ -20,8 +20,9 @@ #include "RiaApplication.h" -#include "RimOilField.h" +#include "RimEclipseView.h" #include "RimFractureTemplateCollection.h" +#include "RimOilField.h" #include "RimProject.h" #include "RimStimPlanFractureTemplate.h" @@ -44,7 +45,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QString fileName = QFileDialog::getOpenFileName(NULL, "Open StimPlan XML File", defaultDir, "StimPlan XML File (*.xml);;All files(*.*)"); + QString fileName = QFileDialog::getOpenFileName(nullptr, "Open StimPlan XML File", defaultDir, "StimPlan XML File (*.xml);;All files(*.*)"); if (fileName.isEmpty()) return; @@ -67,6 +68,18 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) fractureDef->setDefaultWellDiameterFromUnit(); fracDefColl->updateConnectedEditors(); + + std::vector views; + project->allVisibleViews(views); + + for (Rim3dView* view : views) + { + if (dynamic_cast(view)) + { + view->updateConnectedEditors(); + } + } + RiuMainWindow::instance()->selectAsCurrentItem(fractureDef); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index a11c0b488b..04ca6f17e9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -71,6 +71,7 @@ #ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFracture.h" +#include "RimFractureTemplateCollection.h" #include "RimSimWellFracture.h" #include "RivWellFracturePartMgr.h" #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -1469,7 +1470,18 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(cellEdgeResult()); uiTreeOrdering.add(faultResultSettings()); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - uiTreeOrdering.add(stimPlanColors()); + + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + RimOilField* oilfield = project->activeOilField(); + + if (oilfield && oilfield->fractureDefinitionCollection().notNull()) + { + if (!oilfield->fractureDefinitionCollection()->fractureDefinitions.empty()) + { + uiTreeOrdering.add(stimPlanColors()); + } + } #endif // USE_PROTOTYPE_FEATURE_FRACTURES uiTreeOrdering.add(wellCollection()); From cdfe7f51d3b2de5a58bf35631d8ddb2cd35a5e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 18 Jan 2018 13:24:04 +0100 Subject: [PATCH 0101/1027] #2377 summary plot. Add missing curve update --- .../Commands/FlowCommands/RicPlotProductionRateFeature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index 847628be2a..542033b28a 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -295,6 +295,7 @@ RimSummaryCurve* RicPlotProductionRateFeature::addSummaryCurve( RimSummaryPlot* newCurve->setSummaryAddressY(addr); newCurve->setColor(color); newCurve->setLeftOrRightAxisY(plotAxis); + newCurve->loadDataAndUpdate(true); return newCurve; } From ed930da11d866c9e3181faea3ca76bca02e3e054 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 19 Jan 2018 08:02:09 +0100 Subject: [PATCH 0102/1027] #2380 AppFwk: Take vector* as argument, not vector>* --- .../UnitTests/RimRelocatePath-Test.cpp | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp index 2c437a23ef..32fa925bf8 100644 --- a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp +++ b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp @@ -16,27 +16,36 @@ /// //-------------------------------------------------------------------------------------------------- template -void fieldByType(caf::PdmObjectHandle* object, std::vector< caf::PdmField* >* typedFields) +void fieldsByType(caf::PdmObjectHandle* object, std::vector* typedFields) { if (!typedFields) return; if (!object) return; - std::vector fields; - object->fields(fields); + std::vector allFieldsInObject; + object->fields(allFieldsInObject); std::vector children; - for (const auto& field : fields) + for (const auto& field : allFieldsInObject) { caf::PdmField* typedField = dynamic_cast*>(field); - if (typedField) typedFields->push_back(typedField); + if (typedField) typedFields->push_back(&typedField->v()); + + caf::PdmField< std::vector >* typedFieldInVector = dynamic_cast >*>(field); + if (typedFieldInVector) + { + for (T& typedFieldFromVector : typedFieldInVector->v()) + { + typedFields->push_back(&typedFieldFromVector); + } + } field->childObjects(&children); } for (const auto& child : children) { - fieldByType(child, typedFields); + fieldsByType(child, typedFields); } } @@ -54,15 +63,12 @@ TEST(RimRelocatePathTest, findPathsInProjectFile) project.fileName = fileName; project.readFile(); - std::vector< caf::PdmField>* > filePathsVectors; + std::vector< caf::FilePath* > filePaths; - fieldByType(&project, &filePathsVectors); + fieldsByType(&project, &filePaths); - for (auto fpVec : filePathsVectors) + for (auto filePath : filePaths) { - for (auto fp : fpVec->v()) - { - std::cout << fp.path().toStdString() << std::endl; - } + std::cout << filePath->path().toStdString() << std::endl; } } From 56188c8f3f7be6c45c69cd460c7c351dbc048dee Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 19 Jan 2018 12:52:50 +0100 Subject: [PATCH 0103/1027] #2380 AppFwk: Move fieldsByType to RimProject --- .../ProjectDataModel/RimProject.cpp | 21 ++++++++-- ApplicationCode/ProjectDataModel/RimProject.h | 40 +++++++++++++++++++ .../UnitTests/RimRelocatePath-Test.cpp | 9 ++--- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index fbf8cffe88..56436e0227 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -28,7 +28,6 @@ #include "RigGridBase.h" #include "RimCalcScript.h" -#include "RimSummaryCalculationCollection.h" #include "RimCase.h" #include "RimCaseCollection.h" #include "RimCommandObject.h" @@ -38,6 +37,7 @@ #include "RimEclipseCaseCollection.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" +#include "RimSummaryCalculationCollection.h" #ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" @@ -47,6 +47,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" #include "RimGridSummaryCase.h" +#include "RimGridView.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimMultiSnapshotDefinition.h" @@ -58,7 +59,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" -#include "RimGridView.h" +#include "RimTools.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimWellLogFile.h" @@ -67,15 +68,15 @@ #include "RimWellPathCollection.h" #include "RimWellPathImport.h" -#include "RiuMainWindow.h" #include "RiuMainPlotWindow.h" +#include "RiuMainWindow.h" #include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" -#include "cafPdmUiTreeOrdering.h" #include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTreeOrdering.h" #include "cvfBoundingBox.h" #include @@ -440,6 +441,18 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName QFileInfo fileInfoOld(oldProjectFileName); QString oldProjectPath = fileInfoOld.path(); + + std::vector filePaths; + fieldsByType(this, filePaths); + + for (caf::FilePath* filePath : filePaths) + { + bool foundFile = false; + std::vector searchedPaths; + + QString newFilePath = RimTools::relocateFile(filePath->path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + filePath->setPath(newFilePath); + } // Loop over all cases and update file path diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index c29a17dc13..427324a4ec 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -151,6 +151,10 @@ class RimProject : public caf::PdmDocument virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); +private: + template + void fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields); + private: caf::PdmField m_projectFileVersionString; @@ -166,3 +170,39 @@ class RimProject : public caf::PdmDocument caf::PdmChildArrayField casesObsolete; // obsolete caf::PdmChildArrayField caseGroupsObsolete; // obsolete }; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void RimProject::fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields) +{ + if (!object) return; + + std::vector allFieldsInObject; + object->fields(allFieldsInObject); + + std::vector children; + + for (const auto& field : allFieldsInObject) + { + caf::PdmField* typedField = dynamic_cast*>(field); + if (typedField) typedFields.push_back(&typedField->v()); + + caf::PdmField< std::vector >* typedFieldInVector = dynamic_cast >*>(field); + if (typedFieldInVector) + { + for (T& typedFieldFromVector : typedFieldInVector->v()) + { + typedFields.push_back(&typedFieldFromVector); + } + } + + field->childObjects(&children); + } + + for (const auto& child : children) + { + fieldsByType(child, typedFields); + } +} diff --git a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp index 32fa925bf8..7a54760e80 100644 --- a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp +++ b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp @@ -16,9 +16,8 @@ /// //-------------------------------------------------------------------------------------------------- template -void fieldsByType(caf::PdmObjectHandle* object, std::vector* typedFields) +void fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields) { - if (!typedFields) return; if (!object) return; std::vector allFieldsInObject; @@ -29,14 +28,14 @@ void fieldsByType(caf::PdmObjectHandle* object, std::vector* typedFields) for (const auto& field : allFieldsInObject) { caf::PdmField* typedField = dynamic_cast*>(field); - if (typedField) typedFields->push_back(&typedField->v()); + if (typedField) typedFields.push_back(&typedField->v()); caf::PdmField< std::vector >* typedFieldInVector = dynamic_cast >*>(field); if (typedFieldInVector) { for (T& typedFieldFromVector : typedFieldInVector->v()) { - typedFields->push_back(&typedFieldFromVector); + typedFields.push_back(&typedFieldFromVector); } } @@ -65,7 +64,7 @@ TEST(RimRelocatePathTest, findPathsInProjectFile) std::vector< caf::FilePath* > filePaths; - fieldsByType(&project, &filePaths); + fieldsByType(&project, filePaths); for (auto filePath : filePaths) { From 7726ed16106d215ba2111f4dbdb347dd51a6ee20 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 19 Jan 2018 12:53:37 +0100 Subject: [PATCH 0104/1027] #2366 AppFwk: Use caf::FilePath for odb-file --- .../ProjectDataModel/RimGeoMechCase.cpp | 27 +++++-------------- .../ProjectDataModel/RimGeoMechCase.h | 2 +- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 669a783dca..b0c7b6157f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -54,7 +54,7 @@ RimGeoMechCase::RimGeoMechCase(void) { CAF_PDM_InitObject("Geomechanical Case", ":/GeoMechCase48x48.png", "", ""); - CAF_PDM_InitField(&m_caseFileName, "CaseFileName", QString(), "Case File Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_caseFileName, "CaseFileName", "Case File Name", "", "", ""); m_caseFileName.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&geoMechViews, "GeoMechViews", "", "", "", ""); geoMechViews.uiCapability()->setUiHidden(true); @@ -106,7 +106,7 @@ RimGeoMechCase::~RimGeoMechCase(void) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::setFileName(const QString& fileName) { - m_caseFileName = fileName; + m_caseFileName.v().setPath(fileName); } //-------------------------------------------------------------------------------------------------- @@ -114,7 +114,7 @@ void RimGeoMechCase::setFileName(const QString& fileName) //-------------------------------------------------------------------------------------------------- QString RimGeoMechCase::caseFileName() const { - return m_caseFileName(); + return m_caseFileName().path(); } //-------------------------------------------------------------------------------------------------- @@ -156,12 +156,12 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) // If read already, return if (this->m_geoMechCaseData.notNull()) return true; - if (!caf::Utils::fileExists(m_caseFileName())) + if (!caf::Utils::fileExists(m_caseFileName().path())) { return false; } - m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().toStdString()); + m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().path().toStdString()); bool fileOpenSuccess = m_geoMechCaseData->openAndReadFemParts(errorMessage); if (!fileOpenSuccess) @@ -199,22 +199,7 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - bool foundFile = false; - std::vector searchedPaths; - - // Update filename and folder paths when opening project from a different file location - m_caseFileName = RimTools::relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); - - for (caf::FilePath& fileName : m_elementPropertyFileNames.v()) - { - fileName = RimTools::relocateFile(fileName.path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); - } - -#if 0 // Output the search path for debugging - for (size_t i = 0; i < searchedPaths.size(); ++i) - qDebug() << searchedPaths[i]; -#endif - + //No longer in use. Filepaths are now of type caf::FilePath, and updated in RimProject on load. } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 9417e42631..2fc819d06b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -94,7 +94,7 @@ class RimGeoMechCase : public RimCase private: cvf::ref m_geoMechCaseData; - caf::PdmField m_caseFileName; + caf::PdmField m_caseFileName; caf::PdmField m_cohesion; caf::PdmField m_frictionAngleDeg; caf::PdmField> m_elementPropertyFileNames; From fbb6f56bd340164994915502d07dd16f5936fe38 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 19 Jan 2018 13:36:51 +0100 Subject: [PATCH 0105/1027] #2382 Elm props: Update Result Info to show relevant Element Result info --- .../UserInterface/RiuFemResultTextBuilder.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 6e7c050eeb..e9d8584d96 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -85,7 +85,9 @@ QString RiuFemResultTextBuilder::mainResultText() { QString text; - text = closestNodeResultText(m_reservoirView->cellResultResultDefinition()); + RimGeoMechResultDefinition* cellResultDefinition = m_reservoirView->cellResultResultDefinition(); + + text = closestNodeResultText(cellResultDefinition); if (!text.isEmpty()) text += "\n"; @@ -94,7 +96,10 @@ QString RiuFemResultTextBuilder::mainResultText() appendDetails(text, formationDetails()); text += "\n"; - appendDetails(text, gridResultDetails()); + if (cellResultDefinition->resultPositionType() != RIG_ELEMENT) + { + appendDetails(text, gridResultDetails()); + } return text; } @@ -363,7 +368,11 @@ QString RiuFemResultTextBuilder::closestNodeResultText(RimGeoMechResultDefinitio float scalarValue = (resultIndex >= 0) ? scalarResults[resultIndex]: std::numeric_limits::infinity(); - if (activeResultPosition != RIG_ELEMENT_NODAL_FACE) + if (activeResultPosition == RIG_ELEMENT) + { + text.append(QString("Element result: %1\n").arg(scalarValue)); + } + else if (activeResultPosition != RIG_ELEMENT_NODAL_FACE) { text.append(QString("Closest result: N[%1], %2\n").arg(closestNodeId) .arg(scalarValue)); From b4b1dfa0f97834c0ec453f581549bbd212159a17 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 08:23:19 +0100 Subject: [PATCH 0106/1027] #2141 Fixed wrong default values for MinMaxAccumulator --- ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h index 34079596a0..e583533b9c 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h @@ -62,7 +62,7 @@ class RigHistogramCalculator class MinMaxAccumulator { public: - MinMaxAccumulator(double initMin = -HUGE_VAL, double initMax = HUGE_VAL): max(initMax), min(initMin) {} + MinMaxAccumulator(double initMin = HUGE_VAL, double initMax = -HUGE_VAL): max(initMax), min(initMin) {} void addData(const std::vector& values) { From 2da5f8cf54d5a67c6e8896d05d563a6d0f00e3f0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 09:10:30 +0100 Subject: [PATCH 0107/1027] #2141 Use accumulators to compute min/max used to configure legend --- .../RimEllipseFractureTemplate.cpp | 13 ++++++ .../Completions/RimEllipseFractureTemplate.h | 4 ++ .../Completions/RimFractureTemplate.h | 6 +++ .../RimFractureTemplateCollection.cpp | 18 ++++++-- .../RimStimPlanFractureTemplate.cpp | 26 ++++++----- .../Completions/RimStimPlanFractureTemplate.h | 5 +- .../RigStimPlanFractureDefinition.cpp | 46 ++++++------------- .../RigStimPlanFractureDefinition.h | 7 ++- 8 files changed, 75 insertions(+), 50 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index d69d25729a..11d33dc8a3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -24,6 +24,7 @@ #include "RigCellGeometryTools.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" +#include "RigStatisticsMath.h" #include "RigTesselatorTools.h" #include "RimFracture.h" @@ -307,6 +308,18 @@ double RimEllipseFractureTemplate::conductivity() const return cond; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const +{ + if (resultName.startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) + { + minMaxAccumulator.addValue(conductivity()); + posNegAccumulator.addValue(conductivity()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index ff698a9e60..726fa0f737 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -59,6 +59,10 @@ class RimEllipseFractureTemplate : public RimFractureTemplate void setDefaultValuesFromUnit(); double conductivity() const; + virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 2227114c08..6524cebedc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -35,6 +35,8 @@ class RigEclipseCaseData; class RigFractureGrid; class RimFractureContainment; +class MinMaxAccumulator; +class PosNegAccumulator; //================================================================================================== /// @@ -86,6 +88,10 @@ class RimFractureTemplate : public caf::PdmObject const RimFractureContainment * fractureContainment(); + virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const = 0; + protected: caf::PdmChildField m_fractureContainment; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 81960b5880..847fbd26f0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -18,6 +18,8 @@ #include "RimFractureTemplateCollection.h" +#include "RigStatisticsMath.h" + #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplate.h" #include "RimStimPlanFractureTemplate.h" @@ -95,16 +97,24 @@ std::vector RimFractureTemplateCollection::stimPlanResultNames() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const +void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, + double* maxValue, double* posClosestToZero, double* negClosestToZero) const { + MinMaxAccumulator minMaxAccumulator; + PosNegAccumulator posNegAccumulator; + for (const RimFractureTemplate* f : fractureDefinitions()) { - auto stimPlanFracture = dynamic_cast(f); - if (stimPlanFracture) + if (f) { - stimPlanFracture->computeMinMax(resultName, unit, minValue, maxValue, posClosestToZero, negClosestToZero); + f->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator); } } + + if (*minValue) *minValue = minMaxAccumulator.min; + if (*maxValue) *maxValue = minMaxAccumulator.max; + if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos; + if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 687ead1cdf..eca6f90440 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -357,17 +357,6 @@ std::vector > RimStimPlanFractureTemplate::resultNam return propertyNamesUnits; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const -{ - if (m_stimPlanFractureDefinitionData.notNull()) - { - m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue, posClosestToZero, negClosestToZero); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -409,7 +398,20 @@ bool RimStimPlanFractureTemplate::hasConductivity() const } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const +{ + if (m_stimPlanFractureDefinitionData.notNull()) + { + m_stimPlanFractureDefinitionData->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator); + } +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index a300481797..b94bd23184 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -78,11 +78,14 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate std::vector timeSteps(); std::vector > resultNamesWithUnit() const; - void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; std::vector> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; + virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index bf3b17d63b..9afc1f7933 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -18,13 +18,16 @@ #include "RigStimPlanFractureDefinition.h" -#include -#include "cvfMath.h" -#include "RivWellFracturePartMgr.h" -#include "RigFractureCell.h" #include "RiaLogging.h" +#include "RigFractureCell.h" #include "RigFractureGrid.h" +#include "RigStatisticsMath.h" + +#include "RivWellFracturePartMgr.h" + +#include "cvfMath.h" + #include //-------------------------------------------------------------------------------------------------- @@ -574,7 +577,8 @@ const std::vector>& RigStimPlanFractureDefinition::getDataAt } } - qDebug() << "ERROR: Requested parameter does not exists in stimPlan data"; + RiaLogging::error("Requested parameter does not exists in stimPlan data"); + static std::vector> emptyVector; return emptyVector; } @@ -582,12 +586,10 @@ const std::vector>& RigStimPlanFractureDefinition::getDataAt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, const QString& unit, - double* minValue, double* maxValue, - double* posClosestToZero, double* negClosestToZero) const +void RigStimPlanFractureDefinition::appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const { - CVF_ASSERT(minValue && maxValue && posClosestToZero && negClosestToZero); - size_t resIndex = resultIndex(resultName, unit); if (resIndex == cvf::UNDEFINED_SIZE_T) return; @@ -595,28 +597,8 @@ void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, con { for (const auto& values : timeValues) { - for (double resultValue : values) - { - if (resultValue < *minValue) - { - *minValue = resultValue; - } - - if (resultValue > *maxValue) - { - *maxValue = resultValue; - } - - if (resultValue > 0 && resultValue < *posClosestToZero) - { - *posClosestToZero = resultValue; - } - - if (resultValue < 0 && resultValue > *negClosestToZero) - { - *posClosestToZero = resultValue; - } - } + minMaxAccumulator.addData(values); + posNegAccumulator.addData(values); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 4d80477994..0964a7a5d9 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -27,6 +27,8 @@ #include "cvfVector3.h" class RigFractureGrid; +class MinMaxAccumulator; +class PosNegAccumulator; class RigStimPlanResultFrames { @@ -102,7 +104,10 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; - void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; + + void appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const; QString conductivityResultName() const; From 04a91b92f4be638d13cf21205404c68d01bf0413 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 09:43:18 +0100 Subject: [PATCH 0108/1027] Remove unused function --- .../Completions/RimFractureTemplateCollection.cpp | 15 --------------- .../Completions/RimFractureTemplateCollection.h | 1 - 2 files changed, 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 847fbd26f0..6d8e8d3e36 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -79,21 +79,6 @@ std::vector > RimFractureTemplateCollection::stimPla return names; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimFractureTemplateCollection::stimPlanResultNames() const -{ - std::vector names; - - for (auto nameAndUnit : stimPlanResultNamesAndUnits()) - { - names.push_back(nameAndUnit.first); - } - - return names; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index c6f71ec9c9..7dbfd2ec30 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -42,7 +42,6 @@ class RimFractureTemplateCollection : public caf::PdmObject caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; std::vector > stimPlanResultNamesAndUnits() const; - std::vector stimPlanResultNames() const; void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; void deleteFractureDefinitions(); From 0674eaefbfd4cf4c7261b9c555a8797c7f2ea11d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 09:49:26 +0100 Subject: [PATCH 0109/1027] #2141 Fracture Legend : Update model when ellipse conductivity changes --- .../Completions/RimEllipseFractureTemplate.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 11d33dc8a3..8e6e811b6c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -80,7 +80,10 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha { RimFractureTemplate::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &m_halfLength || changedField == &m_height) + if ( changedField == &m_halfLength + || changedField == &m_height + || changedField == &m_width + || changedField == &m_permeability) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; From ef3d9f109547a282e64c7d61d3a27680d695d8ec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 10:04:29 +0100 Subject: [PATCH 0110/1027] #2141 Fracture Legend : If conductivity, use legend to set ellipse fracture color --- .../RivWellFracturePartMgr.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index b040826190..a421b7e71a 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -26,6 +26,7 @@ #include "RimCase.h" #include "RimEclipseView.h" +#include "RimEllipseFractureTemplate.h" #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" @@ -55,6 +56,8 @@ #include "cvfScalarMapperContinuousLinear.h" #include "cvfTransform.h" +#include + //-------------------------------------------------------------------------------------------------- /// @@ -272,6 +275,30 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor()); + + RimLegendConfig* legendConfig = nullptr; + if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked()) + { + legendConfig = activeView.stimPlanColors()->activeLegend(); + } + + if (legendConfig && legendConfig->scalarMapper()) + { + cvf::Color3ub resultColor = cvf::Color3ub(cvf::Color3::LIGHT_GRAY); + + if (activeView.stimPlanColors->resultName().startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) + { + RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + if (ellipseFractureTemplate) + { + double conductivity = ellipseFractureTemplate->conductivity(); + resultColor = legendConfig->scalarMapper()->mapToColor(conductivity); + } + } + + fractureColor.set(cvf::Color3f::fromByteColor(resultColor.r(), resultColor.g(), resultColor.b())); + } + caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); surfacePart->setEffect(eff.p()); From ba437c605daeb648d649196db55428cf8ad74cba Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 10:30:33 +0100 Subject: [PATCH 0111/1027] #2385 Main Window: More flexible docking restrictions --- ApplicationCode/UserInterface/RiuMainWindowBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp index 0bada423d5..0c09d6e193 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp @@ -27,7 +27,7 @@ //-------------------------------------------------------------------------------------------------- RiuMainWindowBase::RiuMainWindowBase() { - + setDockNestingEnabled(true); } //-------------------------------------------------------------------------------------------------- From 8e5bcef7c76f21cd029afed25dff0522de87dd69 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 12:28:12 +0100 Subject: [PATCH 0112/1027] #1544 Removed unused functions and other minor improvements --- .../RivReservoirSimWellsPartMgr.cpp | 19 ++--------- .../RivReservoirSimWellsPartMgr.h | 33 +++++++++---------- .../RivSimWellPipesPartMgr.cpp | 18 ++++++++++ .../RivSimWellPipesPartMgr.h | 6 ++-- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp index 4a47e2c857..71c694a1b3 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp @@ -29,15 +29,15 @@ #include "RimSimWellInViewCollection.h" #include "RimSimWellInView.h" -#include "RivWellHeadPartMgr.h" #include "RivSimWellPipesPartMgr.h" +#include "RivWellConnectionsPartMgr.h" +#include "RivWellHeadPartMgr.h" +#include "RivWellSpheresPartMgr.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" #include "cvfTransform.h" -#include "RivWellSpheresPartMgr.h" -#include "RivWellConnectionsPartMgr.h" //-------------------------------------------------------------------------------------------------- /// @@ -176,16 +176,3 @@ void RivReservoirSimWellsPartMgr::updatePipeResultColor(size_t frameIndex) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector< std::vector >* RivReservoirSimWellsPartMgr::centerLineOfWellBranches(int wellIdx) -{ - if (wellIdx < static_cast(m_wellPipesPartMgrs.size())) - { - return &(m_wellPipesPartMgrs[wellIdx]->centerLineOfWellBranches()); - } - - return NULL; -} - diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h index 459b77ab0b..71bcaac087 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h @@ -1,24 +1,23 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once - #include "cvfBase.h" #include "cvfCollection.h" #include "cvfVector3.h" @@ -27,9 +26,9 @@ namespace cvf { - class Transform; - class ModelBasicList; -} +class Transform; +class ModelBasicList; +} // namespace cvf class RimEclipseView; class RivSimWellPipesPartMgr; @@ -37,6 +36,9 @@ class RivWellHeadPartMgr; class RivWellSpheresPartMgr; class RivWellConnectionsPartMgr; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RivReservoirSimWellsPartMgr : public cvf::Object { public: @@ -51,15 +53,12 @@ class RivReservoirSimWellsPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); void updatePipeResultColor(size_t frameIndex); - const std::vector< std::vector >* centerLineOfWellBranches(int wellIdx); - private: - caf::PdmPointer m_reservoirView; - cvf::ref m_scaleTransform; - - cvf::Collection< RivSimWellPipesPartMgr > m_wellPipesPartMgrs; - cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs; - cvf::Collection< RivWellSpheresPartMgr > m_wellSpheresPartMgrs; - cvf::Collection< RivWellConnectionsPartMgr > m_wellConnPartMgrs; + caf::PdmPointer m_reservoirView; + cvf::ref m_scaleTransform; + cvf::Collection m_wellPipesPartMgrs; + cvf::Collection m_wellHeadPartMgrs; + cvf::Collection m_wellSpheresPartMgrs; + cvf::Collection m_wellConnPartMgrs; }; diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 8632baf474..fb8d62303b 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -70,6 +70,24 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform) +{ + m_scaleTransform = scaleTransform; + + scheduleGeometryRegen(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::scheduleGeometryRegen() +{ + m_needsTransformUpdate = true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 8917981163..6fff0946dd 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -47,15 +47,13 @@ class RivSimWellPipesPartMgr : public cvf::Object RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); ~RivSimWellPipesPartMgr(); - void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; scheduleGeometryRegen();} + void setScaleTransform(cvf::Transform * scaleTransform); - void scheduleGeometryRegen() { m_needsTransformUpdate = true; } + void scheduleGeometryRegen(); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); void updatePipeResultColor(size_t frameIndex); - const std::vector< std::vector >& centerLineOfWellBranches() { return m_pipeBranchesCLCoords;} - private: caf::PdmPointer m_rimReservoirView; caf::PdmPointer m_rimWell; From c7d61ed7f42cf6d30a84de7af16544dadea3349f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 13:30:58 +0100 Subject: [PATCH 0113/1027] #1544 : Move well path radius to RimWellPath --- .../ModelVisualization/RivWellPathPartMgr.cpp | 14 ++------------ .../ModelVisualization/RivWellPathPartMgr.h | 1 - .../ProjectDataModel/RimWellPath.cpp | 17 +++++++++++++++++ ApplicationCode/ProjectDataModel/RimWellPath.h | 3 +++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 7c96a7cad9..6583c9cd70 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -178,16 +178,13 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD { if (!m_rimWellPath || !m_rimWellPath->perforationIntervalCollection()->isChecked()) return; - RimWellPathCollection* wellPathCollection = this->wellPathCollection(); - if (!wellPathCollection) return; - RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; // Since we're using the index of measured depths to find the index of a point, ensure they're equal CVF_ASSERT(wellPathGeometry->m_measuredDepths.size() == wellPathGeometry->m_wellPathPoints.size()); - double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); + double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); double perforationRadius = wellPathRadius * 1.1; RivPipeGeometryGenerator geoGenerator; @@ -236,7 +233,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di if (wellPathGeometry->m_wellPathPoints.size() < 2) return; clearAllBranchData(); - double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); + double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); cvf::Vec3d textPosition; @@ -473,10 +470,3 @@ RimWellPathCollection* RivWellPathPartMgr::wellPathCollection() return wellPathCollection; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RivWellPathPartMgr::wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection) -{ - return wellPathCollection->wellPathRadiusScaleFactor() * m_rimWellPath->wellPathRadiusScaleFactor() * characteristicCellSize; -} diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index e6da91630a..e05204acc4 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -93,7 +93,6 @@ class RivWellPathPartMgr : public cvf::Object void clearAllBranchData(); inline RimWellPathCollection* wellPathCollection(); - inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); private: caf::PdmPointer m_rimWellPath; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 6c703b76b2..e92f474504 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -195,6 +195,23 @@ void RimWellPath::setSurveyType(QString surveyType) wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPath::wellPathRadius(double characteristicCellSize) const +{ + double radius = characteristicCellSize * wellPathRadiusScaleFactor(); + + RimWellPathCollection* coll = nullptr; + this->firstAncestorOrThisOfType(coll); + if (coll) + { + radius *= coll->wellPathRadiusScaleFactor(); + } + + return radius; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index e858141232..13f1c6e5ba 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -100,6 +100,9 @@ class RimWellPath : public caf::PdmObject caf::PdmField showWellPath; caf::PdmField wellPathColor; + + double wellPathRadius(double characteristicCellSize) const; + caf::PdmField wellPathRadiusScaleFactor; RimFishbonesCollection* fishbonesCollection(); From 53418179baf507aeaa3547752c11723baf737401 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 14:05:57 +0100 Subject: [PATCH 0114/1027] #1544 Fracture : Add function used to compute perforation length coords --- .../Completions/RimFracture.h | 1 + .../Completions/RimSimWellFracture.cpp | 24 +++++++++++++++++++ .../Completions/RimSimWellFracture.h | 2 ++ .../Completions/RimWellPathFracture.cpp | 22 +++++++++++++++++ .../Completions/RimWellPathFracture.h | 2 ++ 5 files changed, 51 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 0c4dea0a60..8ce6f74901 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -98,6 +98,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf virtual double fractureMD() const = 0; virtual void loadDataAndUpdate() = 0; + virtual std::vector perforationLengthCenterLineCoords() const = 0; friend class RimFractureTemplate; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index 8d9a5c5781..2c42b1028e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -30,6 +30,7 @@ #include "RimSimWellInView.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "RigWellPath.h" @@ -131,6 +132,29 @@ void RimSimWellFracture::loadDataAndUpdate() updateAzimuthBasedOnWellAzimuthAngle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSimWellFracture::perforationLengthCenterLineCoords() const +{ + std::vector coords; + + if (!m_branchCenterLines.empty() && m_branchIndex < m_branchCenterLines.size()) + { + RigWellPath wellPathGeometry; + + wellPathGeometry.m_wellPathPoints = m_branchCenterLines[m_branchIndex].wellPathPoints(); + wellPathGeometry.m_measuredDepths = m_branchCenterLines[m_branchIndex].measuredDepths(); + + double startMd = m_location - perforationLength() / 2.0; + double endMd = m_location + perforationLength() / 2.0; + + coords = wellPathGeometry.clippedPointSubset(startMd, endMd).first; + } + + return coords; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h index 2c4e474310..7b7f074d11 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h @@ -52,6 +52,8 @@ class RimSimWellFracture : public RimFracture virtual void loadDataAndUpdate() override; + virtual std::vector perforationLengthCenterLineCoords() const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index ca8b51ebff..33d5d1f11b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -132,6 +132,28 @@ void RimWellPathFracture::loadDataAndUpdate() updateAzimuthBasedOnWellAzimuthAngle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPathFracture::perforationLengthCenterLineCoords() const +{ + std::vector wellPathCoords; + + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfType(wellPath); + if (wellPath && wellPath->wellPathGeometry()) + { + double startMd = m_measuredDepth - perforationLength() / 2.0; + double endMd = m_measuredDepth + perforationLength() / 2.0; + + auto coordsAndMd = wellPath->wellPathGeometry()->clippedPointSubset(startMd, endMd); + + wellPathCoords = coordsAndMd.first; + } + + return wellPathCoords; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h index 5ff63787b3..44f0457b17 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h @@ -47,6 +47,8 @@ class RimWellPathFracture : public RimFracture virtual void loadDataAndUpdate() override; + virtual std::vector perforationLengthCenterLineCoords() const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; From 5c1f5326a0eee67f0d5a1fcd89d09204f0fcb2a8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 15:08:28 +0100 Subject: [PATCH 0115/1027] #1544 Fracture : Show perforation length for along well path fractures --- .../RivWellFracturePartMgr.cpp | 65 +++++++++++++++++++ .../RivWellFracturePartMgr.h | 2 + .../Completions/RimFracture.cpp | 3 +- .../Completions/RimFractureTemplate.cpp | 10 +++ 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index a421b7e71a..827725abf6 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -23,6 +23,7 @@ #include "RigFractureGrid.h" #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" +#include "RigWellPath.h" #include "RimCase.h" #include "RimEclipseView.h" @@ -34,11 +35,13 @@ #include "RimSimWellInView.h" #include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RivFaultGeometryGenerator.h" #include "RivObjectSourceInfo.h" #include "RivPartPriority.h" +#include "RivPipeGeometryGenerator.h" #include "RivWellFracturePartMgr.h" #include "cafDisplayCoordTransform.h" @@ -220,6 +223,8 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod } } } + + appendFracturePerforationLengthParts(eclView, model); } //-------------------------------------------------------------------------------------------------- @@ -689,6 +694,66 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model) +{ + if (!m_rimFracture->isChecked()) return; + + if (!m_rimFracture->fractureTemplate()) return; + if (m_rimFracture->fractureTemplate()->orientationType() != RimFractureTemplate::ALONG_WELL_PATH) return; + + auto displayCoordTransform = activeView.displayCoordTransform(); + if (displayCoordTransform.isNull()) return; + + double characteristicCellSize = activeView.ownerCase()->characteristicCellSize(); + double wellPathRadius = 1.0; + + { + RimWellPath* rimWellPath = nullptr; + m_rimFracture->firstAncestorOrThisOfType(rimWellPath); + if (rimWellPath) + { + wellPathRadius = rimWellPath->wellPathRadius(characteristicCellSize); + } + } + + { + RimSimWellInView* simWell = nullptr; + m_rimFracture->firstAncestorOrThisOfType(simWell); + if (simWell) + { + wellPathRadius = simWell->pipeRadius(); + } + } + + std::vector displayCoords; + { + std::vector perforationLengthCoord = m_rimFracture->perforationLengthCenterLineCoords(); + for (const cvf::Vec3d& point : perforationLengthCoord) + { + displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(point)); + } + } + + if (!displayCoords.empty()) + { + cvf::ref objectSourceInfo = new RivObjectSourceInfo(m_rimFracture); + double perforationRadius = wellPathRadius * 1.2; + cvf::Collection parts; + + RivPipeGeometryGenerator geoGenerator; + geoGenerator.cylinderWithCenterLineParts(&parts, displayCoords, cvf::Color3f::ORANGE, perforationRadius); + + for (auto part : parts) + { + part->setSourceInfo(objectSourceInfo.p()); + model->addPart(part.p()); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 1dfd524ce3..d053cc1569 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -66,6 +66,8 @@ class RivWellFracturePartMgr : public cvf::Object cvf::ref createStimPlanElementColorSurfacePart(const RimEclipseView& activeView); cvf::ref createContainmentMaskPart(const RimEclipseView& activeView); + + void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model); cvf::ref createStimPlanMeshPart(const RimEclipseView& activeView); cvf::ref createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 8a05d4b072..9a63c139dc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -230,7 +230,8 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons changedField == &m_stimPlanCellVizMode || changedField == this->objectToggleField() || changedField == &m_dip || - changedField == &m_tilt) + changedField == &m_tilt || + changedField == &m_perforationLength) { Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index cde7466846..8b4e78913d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -168,6 +168,16 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } } } + + if (changedField == &perforationLength) + { + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + } } //-------------------------------------------------------------------------------------------------- From 245d10c5c1049db8038a756b4e7812fdcdcee0fc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 19 Jan 2018 16:55:16 +0100 Subject: [PATCH 0116/1027] Fix compiler warnings related to converting time_t to double --- .../ReservoirDataModel/RigTimeHistoryCurveMerger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp b/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp index 37e88709d4..19d7b4634d 100644 --- a/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp +++ b/ApplicationCode/ReservoirDataModel/RigTimeHistoryCurveMerger.cpp @@ -196,8 +196,8 @@ double RigTimeHistoryCurveMerger::interpolationValue(const time_t& interpolation bool isSecondValid = RigCurveDataTools::isValidValue(secondValue, removeInterpolatedValues); if (!isSecondValid) return HUGE_VAL; - double firstDiff = interpolationTimeStep - curveTimeSteps.at(firstI); - double secondDiff = curveTimeSteps.at(secondI) - interpolationTimeStep; + double firstDiff = fabs(difftime(interpolationTimeStep, curveTimeSteps.at(firstI))); + double secondDiff = fabs(difftime(curveTimeSteps.at(secondI), interpolationTimeStep)); double firstWeight = secondDiff / (firstDiff + secondDiff); double secondWeight = firstDiff / (firstDiff + secondDiff); From 9a420183e1de15d2d241926f92d642c6c38715b3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jan 2018 11:09:37 +0100 Subject: [PATCH 0117/1027] Remove unused code --- .../ModelVisualization/RivWellPathPartMgr.cpp | 22 ------------------- .../ModelVisualization/RivWellPathPartMgr.h | 8 ------- 2 files changed, 30 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 6583c9cd70..5e20adcc48 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -57,8 +57,6 @@ #include "cvfFont.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfScalarMapperDiscreteLinear.h" -#include "cvfTransform.h" #include "cvfqtUtils.h" @@ -68,26 +66,6 @@ RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath) { m_rimWellPath = wellPath; - - // Setup a scalar mapper - cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; - cvf::Color3ubArray legendColors; - legendColors.resize(4); - legendColors[0] = cvf::Color3::GRAY; - legendColors[1] = cvf::Color3::GREEN; - legendColors[2] = cvf::Color3::BLUE; - legendColors[3] = cvf::Color3::RED; - scalarMapper->setColors(legendColors); - scalarMapper->setRange(0.0 , 4.0); - scalarMapper->setLevelCount(4, true); - - m_scalarMapper = scalarMapper; - - caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); - m_scalarMapperSurfaceEffect = surfEffGen.generateCachedEffect(); - - caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); - m_scalarMapperMeshEffect = meshEffGen.generateCachedEffect(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index e05204acc4..a41768c2e8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -28,10 +28,7 @@ namespace cvf { class Part; class ModelBasicList; - class Transform; - class Effect; class DrawableGeo; - class ScalarMapper; } namespace caf @@ -108,9 +105,4 @@ class RivWellPathPartMgr : public cvf::Object RivPipeBranchData m_pipeBranchData; cvf::ref m_wellLabelPart; - - cvf::ref m_scalarMapper; - cvf::ref m_scalarMapperSurfaceEffect; - cvf::ref m_scalarMapperMeshEffect; - }; From 348b492cc162a90080832299a230d1cd7a8d5044 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jan 2018 11:18:45 +0100 Subject: [PATCH 0118/1027] RiaColorTables : Add and use undefinedCellColor() --- ApplicationCode/Application/Tools/RiaColorTables.cpp | 8 ++++++++ ApplicationCode/Application/Tools/RiaColorTables.h | 1 + .../ModelVisualization/RivScalarMapperUtils.cpp | 5 +++++ .../RivTernaryScalarMapperEffectGenerator.cpp | 4 +++- .../ModelVisualization/RivWellFracturePartMgr.cpp | 3 ++- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 5 +++-- .../ProjectDataModel/RimTernaryLegendConfig.cpp | 3 ++- 7 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 0d10a3ede4..9bdfcd9781 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -451,3 +451,11 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors() return colorTable; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::undefinedCellColor() +{ + return cvf::Color3::GRAY; +} diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 623ab8d6d9..a81ce234e1 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -51,4 +51,5 @@ class RiaColorTables static const caf::ColorTable& selectionPaletteColors(); static const caf::ColorTable& timestepsPaletteColors(); + static cvf::Color3f undefinedCellColor(); }; diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index 11ff995deb..54c74bb5af 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -19,6 +19,8 @@ #include "RivScalarMapperUtils.h" +#include "RiaColorTables.h" + #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" @@ -128,6 +130,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor()); scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateCachedEffect(); @@ -146,7 +149,9 @@ cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(cons RivTernaryScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor()); scalarEffgen.disableLighting(disableLighting); + cvf::ref scalarEffect = scalarEffgen.generateCachedEffect(); return scalarEffect; diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp index e1d09b88cb..279efc60c6 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp @@ -19,6 +19,8 @@ #include "RivTernaryScalarMapperEffectGenerator.h" +#include "RiaColorTables.h" + #include "RivTernaryScalarMapper.h" #include "cvfRenderStateBlending.h" @@ -48,7 +50,7 @@ /// //-------------------------------------------------------------------------------------------------- RivTernaryScalarMapperEffectGenerator::RivTernaryScalarMapperEffectGenerator(const RivTernaryScalarMapper* scalarMapper, caf::PolygonOffset polygonOffset) - : m_undefinedColor(cvf::Color3::GRAY) + : m_undefinedColor(RiaColorTables::undefinedCellColor()) { m_scalarMapper = scalarMapper; m_polygonOffset = polygonOffset; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 827725abf6..c2a6ddb619 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RigCellGeometryTools.h" #include "RigFractureCell.h" @@ -289,7 +290,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc if (legendConfig && legendConfig->scalarMapper()) { - cvf::Color3ub resultColor = cvf::Color3ub(cvf::Color3::LIGHT_GRAY); + cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); if (activeView.stimPlanColors->resultName().startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 04ca6f17e9..81f91d2a5d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -21,6 +21,7 @@ #include "RimEclipseView.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaPreferences.h" #include "RigActiveCellInfo.h" @@ -851,10 +852,10 @@ void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType) color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; case VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case INACTIVE: color = cvf::Color4f(RiaColorTables::undefinedCellColor()); break; case RANGE_FILTERED: color = cvf::Color4f(cvf::Color3::ORANGE); break; case RANGE_FILTERED_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(RiaColorTables::undefinedCellColor()); break; } if (geometryType == PROPERTY_FILTERED || geometryType == PROPERTY_FILTERED_WELL_CELLS) diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 3df9ac7d55..38613fde4e 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -20,6 +20,7 @@ #include "RimTernaryLegendConfig.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RimEclipseView.h" #include "RimViewLinker.h" @@ -89,7 +90,7 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() m_localAutoMin.resize(3, 0.0); m_localAutoMax.resize(3, 1.0); - m_scalarMapper = new RivTernaryScalarMapper(cvf::Color3f::GRAY); + m_scalarMapper = new RivTernaryScalarMapper(RiaColorTables::undefinedCellColor()); recreateLegend(); updateLegend(); From 759d46813d5c4621ad7302c16f36c6faf5c73f92 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jan 2018 13:00:11 +0100 Subject: [PATCH 0119/1027] #1544 Fracture Perforation Length : Set color to deep green --- ApplicationCode/Application/Tools/RiaColorTables.cpp | 12 ++++++++++++ ApplicationCode/Application/Tools/RiaColorTables.h | 1 + .../ModelVisualization/RivWellFracturePartMgr.cpp | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 9bdfcd9781..b69e279bc1 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -459,3 +459,15 @@ cvf::Color3f RiaColorTables::undefinedCellColor() { return cvf::Color3::GRAY; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::perforationLengthColor() +{ + // based on hwb ( 85, 9%, 67%) dark_olive_green + // added 10 to each component + cvf::Color3ub color(69, 94, 33); + + return cvf::Color3f(color); +} diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index a81ce234e1..6b35226b57 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -52,4 +52,5 @@ class RiaColorTables static const caf::ColorTable& timestepsPaletteColors(); static cvf::Color3f undefinedCellColor(); + static cvf::Color3f perforationLengthColor(); }; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index c2a6ddb619..fe0b3eda60 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -745,7 +745,7 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclip cvf::Collection parts; RivPipeGeometryGenerator geoGenerator; - geoGenerator.cylinderWithCenterLineParts(&parts, displayCoords, cvf::Color3f::ORANGE, perforationRadius); + geoGenerator.cylinderWithCenterLineParts(&parts, displayCoords, RiaColorTables::perforationLengthColor(), perforationRadius); for (auto part : parts) { From f0554d85af3fc99e0e64df8909c37ab9521b3d7a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jan 2018 15:07:59 +0100 Subject: [PATCH 0120/1027] #2402 Fracture Conductivity : Add result name define --- .../Application/CMakeLists_files.cmake | 2 ++ .../Application/RiaFractureDefines.cpp | 27 +++++++++++++++++++ .../Application/RiaFractureDefines.h | 26 ++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 ApplicationCode/Application/RiaFractureDefines.cpp create mode 100644 ApplicationCode/Application/RiaFractureDefines.h diff --git a/ApplicationCode/Application/CMakeLists_files.cmake b/ApplicationCode/Application/CMakeLists_files.cmake index 308f8074cb..e8bf0d2989 100644 --- a/ApplicationCode/Application/CMakeLists_files.cmake +++ b/ApplicationCode/Application/CMakeLists_files.cmake @@ -8,6 +8,7 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RiaApplication.h ${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h ${CEE_CURRENT_LIST_DIR}RiaDefines.h +${CEE_CURRENT_LIST_DIR}RiaFractureDefines.h ${CEE_CURRENT_LIST_DIR}RiaPreferences.h ${CEE_CURRENT_LIST_DIR}RiaPorosityModel.h ${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.h @@ -19,6 +20,7 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RiaApplication.cpp ${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.cpp ${CEE_CURRENT_LIST_DIR}RiaDefines.cpp +${CEE_CURRENT_LIST_DIR}RiaFractureDefines.cpp ${CEE_CURRENT_LIST_DIR}RiaMain.cpp ${CEE_CURRENT_LIST_DIR}RiaPreferences.cpp ${CEE_CURRENT_LIST_DIR}RiaPorosityModel.cpp diff --git a/ApplicationCode/Application/RiaFractureDefines.cpp b/ApplicationCode/Application/RiaFractureDefines.cpp new file mode 100644 index 0000000000..30bfcda658 --- /dev/null +++ b/ApplicationCode/Application/RiaFractureDefines.cpp @@ -0,0 +1,27 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaFractureDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::conductivityResultName() +{ + return "CONDUCTIVITY"; +} diff --git a/ApplicationCode/Application/RiaFractureDefines.h b/ApplicationCode/Application/RiaFractureDefines.h new file mode 100644 index 0000000000..9854d41621 --- /dev/null +++ b/ApplicationCode/Application/RiaFractureDefines.h @@ -0,0 +1,26 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +namespace RiaDefines +{ +static QString conductivityResultName(); +}; From bc5139257f7a7528e4b5328b9073bd68bc162fb9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jan 2018 15:10:49 +0100 Subject: [PATCH 0121/1027] #2141 Fracture : Remove Stimplan from UI text --- ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 03b5aef9fa..c3899cbb8a 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -52,7 +52,7 @@ RimStimPlanColors::RimStimPlanColors() { CAF_PDM_InitObject("StimPlan Colors", ":/FractureSymbol16x16.png", "", ""); - CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "StimPlan Result Variable", "", "", ""); + CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "Result Variable", "", "", ""); CAF_PDM_InitField(&m_defaultColor, "DefaultColor", cvf::Color3f(cvf::Color3::BROWN), "Default Color", "", "", ""); From 1c668ce3b49d10e008f47ee34d0583d2186a724c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 23 Jan 2018 14:13:45 +0100 Subject: [PATCH 0122/1027] #2358 fracture. Display values in resultInfo panel when clicking on stim plan fracture cell --- .../RicWellPathViewerEventHandler.cpp | 5 +- .../RivWellFracturePartMgr.cpp | 94 +++++++++++++++++++ .../RivWellFracturePartMgr.h | 8 +- .../UserInterface/RiuViewerCommands.cpp | 27 ++++++ 4 files changed, 131 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index f8b5e54f77..b6726a94a2 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -55,8 +55,10 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT; const RivWellPathSourceInfo* wellPathSourceInfo = nullptr; - for (const auto & partAndTriangleIndexPair : eventObject.m_partAndTriangleIndexPairs) + + if(eventObject.m_partAndTriangleIndexPairs.size() > 0) { + const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); const cvf::Part* part = partAndTriangleIndexPair.first; const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); @@ -69,7 +71,6 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even { wellPathSourceInfo = dynamic_cast(part->sourceInfo()); wellPathTriangleIndex = partAndTriangleIndexPair.second; - break; } } diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index fe0b3eda60..43eba41d94 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -245,6 +245,100 @@ std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector< return mirroredValuesAtGivenDepth; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const +{ + QString text; + + if (m_rimFracture.isNull()) return text; + + RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + RimStimPlanFractureTemplate* stimPlanTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + if (ellipseFractureTemplate) + { + text.append("Result value: "); + text.append(QString::number(ellipseFractureTemplate->conductivity()) + "\n"); + + } + else if (stimPlanTemplate) + { +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + + const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); + RimStimPlanColors* stimPlanColors = activeView.stimPlanColors; + + QString condValueText = cell ? QString::number(cell->getConductivtyValue()) : "-"; + QString iText = cell ? QString::number(cell->getI()) : "-"; + QString jText = cell ? QString::number(cell->getJ()) : "-"; + + // Conductivity + text.append("Result value: "); + text.append(stimPlanColors->resultName() + " "); + text.append(condValueText + "\n"); + + // Cell index + text.append("Cell Index: "); + text.append(iText + ", " + jText + "\n"); + +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + } + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const +{ + if (!m_rimFracture) return nullptr; + + cvf::Mat4d toFractureXf = m_rimFracture->transformMatrix().getInverted(); + cvf::Vec3d fractureCoord = domainCoord.getTransformedPoint(toFractureXf); + + const RimStimPlanFractureTemplate* stimPlanTempl = dynamic_cast(m_rimFracture->fractureTemplate()); + if (!stimPlanTempl) return nullptr; + + const RigFractureGrid* grid = stimPlanTempl->fractureGrid(); + size_t cellI = cvf::UNDEFINED_SIZE_T; + size_t cellJ = cvf::UNDEFINED_SIZE_T; + const std::vector& cells = grid->fractureCells(); + + for (int i = 0; i < grid->iCellCount(); i++) + { + const RigFractureCell& cell = cells[i * grid->jCellCount()]; + std::vector polygon = cell.getPolygon(); + double xmin = polygon[0].x(); + double xmax = polygon[2].x(); + if (fractureCoord.x() >= xmin && fractureCoord.x() <= xmax) + { + cellI = cell.getI(); + break; + } + } + + for (int j = 0; j < grid->jCellCount(); j++) + { + const RigFractureCell& cell = cells[j]; + std::vector polygon = cell.getPolygon(); + double ymin = polygon[2].y(); + double ymax = polygon[0].y(); + if (fractureCoord.y() >= ymin && fractureCoord.y() <= ymax) + { + cellJ = cell.getJ(); + break; + } + } + + if (cellI != cvf::UNDEFINED_SIZE_T && cellJ != cvf::UNDEFINED_SIZE_T) + { + return &grid->cellFromIndex(grid->getGlobalIndexFromIJ(cellI, cellJ)); + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index d053cc1569..955a1b220a 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -25,6 +25,7 @@ #include "cafPdmPointer.h" +#include #include namespace cvf @@ -43,6 +44,7 @@ namespace caf class RimFracture; class RimStimPlanFractureTemplate; class RimEclipseView; +class RigFractureCell; //-------------------------------------------------------------------------------------------------- /// @@ -57,6 +59,10 @@ class RivWellFracturePartMgr : public cvf::Object static std::vector mirrorDataAtSingleDepth(std::vector depthData); + const QString resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const; + + const RigFractureCell* getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const; + private: cvf::ref createEllipseSurfacePart(const RimEclipseView& activeView); cvf::ref createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView); @@ -79,5 +85,5 @@ class RivWellFracturePartMgr : public cvf::Object static cvf::ref buildDrawableGeoFromTriangles(const std::vector& triangleIndices, const std::vector& nodeCoords); private: - caf::PdmPointer m_rimFracture; + caf::PdmPointer m_rimFracture; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 5ac048c879..05ba6697b4 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -44,6 +44,7 @@ #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" +#include "RimFracture.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" @@ -68,6 +69,7 @@ #include "RivSourceInfo.h" #include "RivTernarySaturationOverlayItem.h" #include "RivWellPathSourceInfo.h" +#include "RivWellFracturePartMgr.h" #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" @@ -87,6 +89,7 @@ #include #include #include "RimPerforationInterval.h" +#include "RimStimPlanFractureTemplate.h" @@ -491,6 +494,30 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (rivObjectSourceInfo) { RiuMainWindow::instance()->selectAsCurrentItem(rivObjectSourceInfo->object()); + + RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); + RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; + if (stimPlanTempl) + { + // Set fracture resultInfo text + QString resultInfoText; + + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord(globalIntersectionPoint); + + RimEclipseView* eclView = dynamic_cast(m_reservoirView.p()); + RivWellFracturePartMgr* partMgr = fracture->fracturePartManager(); + if (eclView) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord); + + // Set intersection point result text + QString intersectionPointText; + + intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + resultInfoText.append(intersectionPointText); + + // Display result info text + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } } if (rivSourceInfo) From 9cfd2ff3cf10b4ea7ae7e3a28960ae9023da99f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 23 Jan 2018 14:30:58 +0100 Subject: [PATCH 0123/1027] #2358 fracture. When clicking on an ellipse fracture, display info in result into panel --- .../ModelVisualization/RivWellFracturePartMgr.cpp | 2 +- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 43eba41d94..2110fa8ed9 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -258,7 +258,7 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ RimStimPlanFractureTemplate* stimPlanTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); if (ellipseFractureTemplate) { - text.append("Result value: "); + text.append("Result value: CONDUCTIVITY "); text.append(QString::number(ellipseFractureTemplate->conductivity()) + "\n"); } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 05ba6697b4..5f6ea36501 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -55,6 +55,9 @@ #include "RimTernaryLegendConfig.h" #include "RimViewController.h" #include "RimWellPath.h" +#include "RimPerforationInterval.h" +#include "RimStimPlanFractureTemplate.h" +#include "RimEllipseFractureTemplate.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -88,8 +91,6 @@ #include #include #include -#include "RimPerforationInterval.h" -#include "RimStimPlanFractureTemplate.h" @@ -497,7 +498,8 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; - if (stimPlanTempl) + RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; + if (stimPlanTempl || ellipseTempl) { // Set fracture resultInfo text QString resultInfoText; From d34b3a7c74fe7821687c1ca9da84927b37eba237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 23 Jan 2018 14:23:28 +0100 Subject: [PATCH 0124/1027] #2331 Add 2d Intersection View collection with automatic views. The create command is adjusted into a "Show" command. --- .../Application/RiaApplication.cpp | 9 ++ .../RicNewIntersectionViewFeature.cpp | 21 ++- .../Commands/RicDeleteItemExec.cpp | 1 + .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../Rim2dIntersectionView.cpp | 39 ++++++ .../ProjectDataModel/Rim2dIntersectionView.h | 18 ++- .../Rim2dIntersectionViewCollection.cpp | 130 ++++++++++++++++++ .../Rim2dIntersectionViewCollection.h | 48 +++++++ ApplicationCode/ProjectDataModel/RimCase.cpp | 25 ++-- ApplicationCode/ProjectDataModel/RimCase.h | 6 +- .../ProjectDataModel/RimEclipseCase.cpp | 14 ++ .../ProjectDataModel/RimEclipseCase.h | 1 + .../ProjectDataModel/RimGeoMechCase.cpp | 14 ++ .../ProjectDataModel/RimGeoMechCase.h | 1 + .../RimIntersectionCollection.cpp | 16 ++- .../RimIntersectionCollection.h | 3 + .../RimMdiWindowController.cpp | 2 +- .../ProjectDataModel/RimViewWindow.cpp | 4 +- .../ProjectDataModel/RimViewWindow.h | 3 +- 19 files changed, 321 insertions(+), 36 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 2c2037ed31..bb2ab2fd58 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -36,6 +36,7 @@ #include "RigEclipseCaseData.h" +#include "Rim2dIntersectionViewCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCaseCollection.h" #include "RimCellEdgeColors.h" @@ -584,6 +585,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { m_project->viewLinkerCollection()->viewLinker()->updateOverrides(); } + + // Intersection Views: Sync from intersections in the case. + + for (RimCase* cas: casesToLoad) + { + cas->intersectionViewCollection()->syncFromExistingIntersections(false); + } + loadAndUpdatePlotData(); diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index 07d5e9563f..b97518ca4b 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -42,6 +42,20 @@ bool RicNewIntersectionViewFeature::isCommandEnabled() return !objects.empty(); } +Rim2dIntersectionView* correspondingIntersectionView(RimIntersection* intersection) +{ + std::vector objects; + + intersection->objectsWithReferringPtrFields(objects); + Rim2dIntersectionView* isectView = nullptr; + for (auto obj : objects) + { + isectView = dynamic_cast(obj); + if (isectView) break; + } + return isectView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -67,10 +81,11 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text); } - Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection); + Rim2dIntersectionView* intersectionView = correspondingIntersectionView(intersection); + intersectionView->setVisible(true); intersectionView->loadDataAndUpdate(); - rimCase->updateConnectedEditors(); + intersectionView->updateConnectedEditors(); objectToSelect = intersectionView; } @@ -87,7 +102,7 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("New Intersection View"); + actionToSetup->setText("Show 2D Intersection View"); // actionToSetup->setIcon(QIcon(":/chain.png")); } diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index e3fdf1a4a6..74e304a82f 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -129,6 +129,7 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(crossSectionColl); if (view && crossSectionColl) { + crossSectionColl->syncronize2dIntersectionViews(); view->scheduleCreateDisplayModelAndRedraw(); } diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index bb8c37206c..845ed151fb 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -62,6 +62,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewWindow.h ${CEE_CURRENT_LIST_DIR}Rim3dView.h ${CEE_CURRENT_LIST_DIR}RimGridView.h ${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.h +${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.h ${CEE_CURRENT_LIST_DIR}RimViewManipulator.h ${CEE_CURRENT_LIST_DIR}RimCase.h ${CEE_CURRENT_LIST_DIR}RimViewController.h @@ -165,6 +166,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp ${CEE_CURRENT_LIST_DIR}Rim3dView.cpp ${CEE_CURRENT_LIST_DIR}RimGridView.cpp ${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.cpp +${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.cpp ${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp ${CEE_CURRENT_LIST_DIR}RimCase.cpp ${CEE_CURRENT_LIST_DIR}RimViewController.cpp diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 5eb600de7c..a2123ea6a3 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" #include "RimIntersection.h" #include "RimCase.h" #include "RiuViewer.h" @@ -38,7 +39,9 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) CAF_PDM_InitObject("Intersection View", ":/CrossSection16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", ""); + m_intersection.uiCapability()->setUiHidden(true); + m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; } @@ -51,12 +54,31 @@ Rim2dIntersectionView::~Rim2dIntersectionView(void) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setVisible(bool isVisible) +{ + m_showWindow = isVisible; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) { m_intersection = intersection; + Rim3dView * parentView = nullptr; + intersection->firstAncestorOrThisOfTypeAsserted(parentView); + name = parentView->name() + ": " + intersection->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersection* Rim2dIntersectionView::intersection() +{ + return m_intersection(); } //-------------------------------------------------------------------------------------------------- @@ -109,6 +131,23 @@ QList Rim2dIntersectionView::calculateValueOptions(const return options; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isWindowVisible() +{ + if (m_showWindow()) + { + Rim2dIntersectionViewCollection* viewColl = nullptr; + this->firstAncestorOrThisOfTypeAsserted(viewColl); + return viewColl->isActive(); + } + else + { + return false; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 6948d4e91d..4516ebaec4 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -39,8 +39,9 @@ class Rim2dIntersectionView : public Rim3dView Rim2dIntersectionView(void); virtual ~Rim2dIntersectionView(void); - void setIntersection(RimIntersection* intersection); - + void setVisible(bool isVisible); + void setIntersection(RimIntersection* intersection); + RimIntersection* intersection(); virtual bool isUsingFormationNames() const override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; @@ -50,11 +51,8 @@ class Rim2dIntersectionView : public Rim3dView virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } virtual RimViewController* viewController() const override { return nullptr; } - - protected: - caf::PdmPtrField m_intersection; virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; virtual void createDisplayModel() override; @@ -68,16 +66,16 @@ class Rim2dIntersectionView : public Rim3dView virtual cvf::Transform* scaleTransform() override; virtual void resetLegendsInViewer() override; virtual void onLoadDataAndUpdate() override; + virtual bool isWindowVisible() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - cvf::ref m_intersectionVizModel; - cvf::ref m_scaleTransform; - - -}; + caf::PdmPtrField m_intersection; + cvf::ref m_intersectionVizModel; + cvf::ref m_scaleTransform; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp new file mode 100644 index 0000000000..fa91a0780e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -0,0 +1,130 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim2dIntersectionViewCollection.h" + +#include "Rim2dIntersectionView.h" +#include "RimCase.h" +#include "RimIntersection.h" + +CAF_PDM_SOURCE_INIT(Rim2dIntersectionViewCollection, "Intersection2dViewCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection() +{ + CAF_PDM_InitObject("2D Intersection Views", ":/CrossSection16x16.png", "", ""); + + CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show", "","",""); + + CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png", "", ""); + m_intersectionViews.uiCapability()->setUiTreeHidden(true); + //m_intersectionViews.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present. +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionViewCollection::~Rim2dIntersectionViewCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim2dIntersectionViewCollection::views() +{ + return m_intersectionViews.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate ) +{ + RimCase* parentCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(parentCase); + + std::vector allOrderedIntersectionsInCase; + parentCase->descendantsIncludingThisOfType(allOrderedIntersectionsInCase); + + std::set currentIntersections(allOrderedIntersectionsInCase.begin(), allOrderedIntersectionsInCase.end()); + std::set intersectionsNeedingViews = currentIntersections; + + // Delete views without a valid intersection + + for ( Rim2dIntersectionView* iv: m_intersectionViews ) + { + if ( iv && !iv->intersection() ) + { + delete iv; + } + } + + // Clean up the container by removing nullptr's + + m_intersectionViews.removeChildObject(nullptr); + + // Build map from intersection to view + + std::map intersectionToViewMap; + for (Rim2dIntersectionView* iv: m_intersectionViews) + { + CVF_ASSERT (iv && iv->intersection()); + intersectionToViewMap[iv->intersection()] = iv; + } + + m_intersectionViews.clear(); // Not deleting the views. The are managed by the map + + // Insert the old views in correct order, and create new views as we go + + for (RimIntersection* intersection : allOrderedIntersectionsInCase) + { + auto it = intersectionToViewMap.find(intersection); + if (it == intersectionToViewMap.end()) + { + Rim2dIntersectionView* newView = new Rim2dIntersectionView(); + newView->setIntersection(intersection); + m_intersectionViews.push_back(newView); + } + else + { + m_intersectionViews.push_back(it->second); + } + } + + if (doUpdate) this->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_isActive) + { + for (auto view : m_intersectionViews) + { + view->updateMdiWindowVisibility(); + } + } +} diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h new file mode 100644 index 0000000000..2bf1ca68f7 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmChildArrayField.h" + +class Rim2dIntersectionView; + +class Rim2dIntersectionViewCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + Rim2dIntersectionViewCollection(); + virtual ~Rim2dIntersectionViewCollection(); + + bool isActive() { return m_isActive();} + void syncFromExistingIntersections( bool doUpdate ); + + std::vector views(); + +private: + virtual caf::PdmFieldHandle* objectToggleField() override { return &m_isActive; } + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + + caf::PdmField m_isActive; + caf::PdmChildArrayField m_intersectionViews; +}; + + + diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index e1fb8f6a37..1d26e788c5 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -29,6 +29,7 @@ #include "cafPdmObjectFactory.h" #include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" #include "RimIntersection.h" @@ -52,10 +53,10 @@ RimCase::RimCase() : m_isInActiveDestruction(false) m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden(true); m_timeStepFilter = new RimTimeStepFilter; - CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSections16x16.png", "", ""); - m_intersectionViews.uiCapability()->setUiTreeHidden(true); - //m_intersectionViews.push_back(new Rim2dIntersectionView()); - + CAF_PDM_InitFieldNoDefault(&m_2dIntersectionViewCollection, "IntersectionViewCollection", "2D Intersection Views", ":/CrossSections16x16.png", "", ""); + m_2dIntersectionViewCollection.uiCapability()->setUiTreeHidden(true); + m_2dIntersectionViewCollection.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present. + m_2dIntersectionViewCollection = new Rim2dIntersectionViewCollection(); } //-------------------------------------------------------------------------------------------------- @@ -74,7 +75,9 @@ std::vector RimCase::views() const if (m_isInActiveDestruction) return std::vector(); std::vector allViews = this->allSpecialViews(); - for (auto view: m_intersectionViews) + std::vector isectViews = m_2dIntersectionViewCollection->views(); + + for (auto view: isectViews) { allViews.push_back(view); } @@ -116,17 +119,9 @@ size_t RimCase::uiToNativeTimeStepIndex(size_t uiTimeStepIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim2dIntersectionView* RimCase::createAndAddIntersectionView(RimIntersection* intersection) +Rim2dIntersectionViewCollection* RimCase::intersectionViewCollection() { - Rim2dIntersectionView* intersectionView = new Rim2dIntersectionView; - intersectionView->setIntersection(intersection); - - QString name = QString("View of Intersection %1").arg(intersection->name()); - intersectionView->name = name; - - m_intersectionViews.push_back(intersectionView); - - return intersectionView; + return m_2dIntersectionViewCollection; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index fb33a38f74..029079cd9d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -35,6 +35,7 @@ class RimFormationNames; class RimTimeStepFilter; class Rim2dIntersectionView; class RimIntersection; +class Rim2dIntersectionViewCollection; namespace cvf { class BoundingBox; @@ -72,8 +73,7 @@ class RimCase : public caf::PdmObject size_t uiToNativeTimeStepIndex(size_t uiTimeStepIndex); - Rim2dIntersectionView* createAndAddIntersectionView(RimIntersection* intersection); - + Rim2dIntersectionViewCollection* intersectionViewCollection(); protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual std::vector allSpecialViews() const = 0; @@ -83,7 +83,7 @@ class RimCase : public caf::PdmObject protected: caf::PdmChildField m_timeStepFilter; - caf::PdmChildArrayField m_intersectionViews; + caf::PdmChildField m_2dIntersectionViewCollection; private: bool m_isInActiveDestruction; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 70c7da6a2a..de60daac41 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -59,6 +59,7 @@ #include "cafPdmDocument.h" #include "cafProgressInfo.h" +#include "cafPdmUiTreeOrdering.h" #include #include @@ -389,6 +390,19 @@ void RimEclipseCase::updateFormationNamesData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + reservoirViews.childObjects(&children); + + for (auto child : children) uiTreeOrdering.add(child); + + uiTreeOrdering.add(&m_2dIntersectionViewCollection); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 423b5f91cb..a4673b1927 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -111,6 +111,7 @@ class RimEclipseCase : public RimCase protected: virtual void initAfterRead(); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void updateFormationNamesData() override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index b0c7b6157f..2760eac9d4 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -41,6 +41,7 @@ #include "RimGeoMechPropertyFilter.h" #include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" #include @@ -216,6 +217,19 @@ std::vector RimGeoMechCase::allSpecialViews() const return views; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + geoMechViews.childObjects(&children); + + for ( auto child : children ) uiTreeOrdering.add(child); + + uiTreeOrdering.add(&m_2dIntersectionViewCollection); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 2fc819d06b..7d55de5861 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -80,6 +80,7 @@ class RimGeoMechCase : public RimCase virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index bdbc82d0e5..3a70143d66 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -19,10 +19,12 @@ #include "RimIntersectionCollection.h" +#include "Rim2dIntersectionViewCollection.h" +#include "Rim3dView.h" +#include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" #include "RimSimWellInView.h" -#include "Rim3dView.h" #include "RiuMainWindow.h" @@ -153,6 +155,8 @@ void RimIntersectionCollection::appendIntersection(RimIntersection* intersection { m_intersections.push_back(intersection); + syncronize2dIntersectionViews(); + updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersection); @@ -164,6 +168,16 @@ void RimIntersectionCollection::appendIntersection(RimIntersection* intersection } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::syncronize2dIntersectionViews() +{ + RimCase* ownerCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(ownerCase); + ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 2575250b64..afd4d58cce 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -49,12 +49,15 @@ class RimIntersectionCollection : public caf::PdmObject caf::PdmField isActive; void appendIntersection(RimIntersection* intersection); + void appendIntersectionBox(RimIntersectionBox* intersectionBox); bool hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const; void updateIntersectionBoxGeometry(); + void syncronize2dIntersectionViews(); + // Visualization interface void applySingleColorEffect(); diff --git a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp index 5064c83b1e..689dcb5ca5 100644 --- a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp +++ b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp @@ -140,7 +140,7 @@ void RimMdiWindowController::updateViewerWidget() RiuMainWindowBase* mainWindow = getMainWindow(); if ( !mainWindow ) return; - if ( viewPdmObject()->m_showWindow() ) + if ( viewPdmObject()->isWindowVisible() ) { if ( !viewWidget() ) { diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index 68e4ed20ef..b0e995cee3 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -86,7 +86,7 @@ void RimViewWindow::updateMdiWindowVisibility() { if (viewWidget()) { - if (m_showWindow) + if (isWindowVisible()) { viewWidget()->show(); } @@ -149,7 +149,7 @@ void RimViewWindow::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co { if ( changedField == &m_showWindow ) { - if (m_showWindow) + if (isWindowVisible()) { onLoadDataAndUpdate(); } diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.h b/ApplicationCode/ProjectDataModel/RimViewWindow.h index f869994792..3583aea248 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.h @@ -49,6 +49,7 @@ class RimViewWindow : public caf::PdmObject void loadDataAndUpdate(); void handleMdiWindowClosed(); + void updateMdiWindowVisibility(); void setAs3DViewMdiWindow() { setAsMdiWindow(0); } void setAsPlotMdiWindow() { setAsMdiWindow(1); } @@ -64,7 +65,6 @@ class RimViewWindow : public caf::PdmObject protected: void removeMdiWindowFromMdiArea(); - void updateMdiWindowVisibility(); ///////// Interface for the Window controller friend class RimMdiWindowController; @@ -74,6 +74,7 @@ class RimViewWindow : public caf::PdmObject virtual void updateMdiWindowTitle(); // Has real default implementation virtual void deleteViewWidget() = 0; virtual void onLoadDataAndUpdate() = 0; + virtual bool isWindowVisible() { return m_showWindow();} // Virtual To allow special visibility control ////////// // Derived classes are not supposed to override this function. The intention is to always use m_showWindow From e98d969e628eb9fc59c4eacb1c38d6dc5a1c5034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 23 Jan 2018 20:51:41 +0100 Subject: [PATCH 0125/1027] #2358 fracture. Fix linker errors by adding fracture support ifdefs --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 5f6ea36501..994580f888 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -494,6 +494,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (rivObjectSourceInfo) { +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RiuMainWindow::instance()->selectAsCurrentItem(rivObjectSourceInfo->object()); RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); @@ -520,6 +521,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM // Display result info text RiuMainWindow::instance()->setResultInfo(resultInfoText); } +#endif //USE_PROTOTYPE_FEATURE_FRACTURES } if (rivSourceInfo) From 7c47783e3ab8e0f290665534a0de3118dc618f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 10:43:31 +0100 Subject: [PATCH 0126/1027] #2384 multi case import. Add check box for each file --- .../Commands/RicFileHierarchyDialog.cpp | 138 +++++++++++------- .../Commands/RicFileHierarchyDialog.h | 27 ++-- 2 files changed, 104 insertions(+), 61 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index a7828af085..3936106ab4 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -40,12 +40,16 @@ #include #include #include +#include +#include #include #include #include - +#define DEFAULT_DIALOG_WIDTH 750 +#define DEFAULT_DIALOG_INIT_HEIGHT 150 +#define DEFAULT_DIALOG_FIND_HEIGHT 350 #define FIND_BUTTON_FIND_TEXT "Find" #define FIND_BUTTON_CANCEL_TEXT "Cancel" #define NO_FILES_FOUND_TEXT "No files found" @@ -82,7 +86,7 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_effectiveFilterLabel = new QLabel(); m_effectiveFilter = new QLabel(); m_fileListLabel = new QLabel(); - m_fileList = new QTextEdit(); + m_fileList = new QListWidget(); m_findOrCancelButton = new QPushButton(); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -104,12 +108,12 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_effectiveFilterLabel->setText("Effective filter"); m_effectiveFilter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_fileListLabel->setText("Files found"); - m_fileList->setLineWrapMode(QTextEdit::NoWrap); m_fileListLabel->setVisible(false); + m_fileList->setSelectionMode(QAbstractItemView::NoSelection); m_fileList->setVisible(false); m_browseButton->setText("..."); m_browseButton->setFixedWidth(25); - m_findOrCancelButton->setText("Find"); + m_findOrCancelButton->setText(FIND_BUTTON_FIND_TEXT); m_findOrCancelButton->setFixedWidth(75); // Define layout @@ -150,6 +154,36 @@ RicFileHierarchyDialog::~RicFileHierarchyDialog() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *parent /*= 0*/, + const QString &caption /*= QString()*/, + const QString &dir /*= QString()*/, + const QString &pathFilter /*= QString()*/, + const QString &fileNameFilter /*= QString()*/, + const QStringList &fileExtensions /*= QStringList()*/) +{ + QStringList files; + RicFileHierarchyDialog dialog(parent); + + dialog.setWindowTitle(caption); + + dialog.m_rootDir->setText(QDir::toNativeSeparators(dir)); + dialog.m_pathFilter->setText(pathFilter); + dialog.m_fileFilter->setText(fileNameFilter); + dialog.m_fileExtension->setText(prefixStrings(fileExtensions, ".").join(" | ")); + + dialog.updateEffectiveFilter(); + dialog.clearFileList(); + dialog.setOkButtonEnabled(false); + + dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + dialog.exec(); + + return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir(), dialog.pathFilter(), dialog.fileNameFilter()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -208,11 +242,11 @@ bool RicFileHierarchyDialog::cancelPressed() const //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { - QString text = m_fileList->toPlainText(); - if (text.startsWith(WORKING_TEXT_1)) clearFileList(); + if (currentStatus().startsWith(WORKING_TEXT_1)) clearFileList(); - m_fileList->append(fileName); - QApplication::processEvents(); + QListWidgetItem* item = new QListWidgetItem(fileName, m_fileList); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); } //-------------------------------------------------------------------------------------------------- @@ -221,56 +255,46 @@ void RicFileHierarchyDialog::appendToFileList(const QString& fileName) void RicFileHierarchyDialog::clearFileList() { m_files.clear(); - m_fileList->setText(""); + m_fileList->clear(); setOkButtonEnabled(false); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicFileHierarchyDialog::updateStatus() +void RicFileHierarchyDialog::updateStatus(Status status, bool force) { static time_t lastStatusUpdate = 0; time_t now = time(0); - if (now == lastStatusUpdate) return; + // If less than one second since last update, then return + if (!force && now == lastStatusUpdate) return; lastStatusUpdate = now; - QString currStatus = m_fileList->toPlainText(); - if (currStatus == "") m_fileList->setText(WORKING_TEXT_1); - else if (currStatus == WORKING_TEXT_1) m_fileList->setText(WORKING_TEXT_2); - else if (currStatus == WORKING_TEXT_2) m_fileList->setText(WORKING_TEXT_3); - else if (currStatus == WORKING_TEXT_3) m_fileList->setText(WORKING_TEXT_1); + QString newStatus; + if (status == WORKING) + { + QString currStatus = currentStatus(); + if (currStatus == "") newStatus = WORKING_TEXT_1; + else if (currStatus == WORKING_TEXT_1) newStatus = WORKING_TEXT_2; + else if (currStatus == WORKING_TEXT_2) newStatus = WORKING_TEXT_3; + else if (currStatus == WORKING_TEXT_3) newStatus = WORKING_TEXT_1; + } + else if (status == NO_FILES_FOUND) + { + newStatus = NO_FILES_FOUND_TEXT; + } + + m_fileList->clear(); + new QListWidgetItem(newStatus, m_fileList); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *parent /*= 0*/, - const QString &caption /*= QString()*/, - const QString &dir /*= QString()*/, - const QString &pathFilter /*= QString()*/, - const QString &fileNameFilter /*= QString()*/, - const QStringList &fileExtensions /*= QStringList()*/) +QString RicFileHierarchyDialog::currentStatus() const { - QStringList files; - RicFileHierarchyDialog dialog(parent); - - dialog.setWindowTitle(caption); - - dialog.m_rootDir->setText(QDir::toNativeSeparators(dir)); - dialog.m_pathFilter->setText(pathFilter); - dialog.m_fileFilter->setText(fileNameFilter); - dialog.m_fileExtension->setText(prefixStrings(fileExtensions, ".").join(" | ")); - - dialog.updateEffectiveFilter(); - dialog.m_fileList->setText(""); - dialog.setOkButtonEnabled(false); - - dialog.resize(600, 150); - dialog.exec(); - - return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir(), dialog.pathFilter(), dialog.fileNameFilter()); + return m_fileList->item(0) ? m_fileList->item(0)->text() : ""; } //-------------------------------------------------------------------------------------------------- @@ -278,9 +302,14 @@ RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *p //-------------------------------------------------------------------------------------------------- QStringList RicFileHierarchyDialog::findMatchingFiles() { - QStringList dirs = buildDirectoryListRecursive(rootDir()); + const QStringList& dirs = buildDirectoryListRecursive(rootDir()); + const QStringList& files = findFilesInDirs(dirs); - return findFilesInDirs(dirs); + for (const auto& file : files) + { + appendToFileList(file); + } + return files; } //-------------------------------------------------------------------------------------------------- @@ -292,8 +321,6 @@ QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& c if (cancelPressed()) return allDirs; - updateStatus(); - QDir qdir(currentDir); QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); @@ -312,6 +339,7 @@ QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& c for (QString subDir : subDirs) { + updateStatus(WORKING); QApplication::processEvents(); allDirs += buildDirectoryListRecursive(QDir::toNativeSeparators(qdir.absoluteFilePath(subDir))); } @@ -331,13 +359,13 @@ QStringList RicFileHierarchyDialog::findFilesInDirs(const QStringList& dirs) QDir qdir(dir); QStringList files = qdir.entryList(filters, QDir::Files); - updateStatus(); + updateStatus(WORKING); + QApplication::processEvents(); for (QString file : files) { QString absFilePath = QDir::toNativeSeparators(qdir.absoluteFilePath(file)); allFiles.append(absFilePath); - appendToFileList(absFilePath); } } return allFiles; @@ -426,11 +454,12 @@ void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() { clearFileList(); - if (!m_fileList->isVisible()) + if(!m_fileList->isVisible()) { m_fileListLabel->setVisible(true); m_fileList->setVisible(true); - resize(600, 350); + + if(height() < DEFAULT_DIALOG_FIND_HEIGHT) resize(width(), DEFAULT_DIALOG_FIND_HEIGHT); } m_findOrCancelButton->setText(FIND_BUTTON_CANCEL_TEXT); @@ -446,7 +475,7 @@ void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() } else if(m_files.isEmpty()) { - m_fileList->setText(NO_FILES_FOUND_TEXT); + updateStatus(NO_FILES_FOUND, true); } setOkButtonEnabled(!m_files.isEmpty()); @@ -462,6 +491,17 @@ void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::slotDialogOkClicked() { + m_files.clear(); + + int itemCount = m_fileList->count(); + for (int i = 0; i < itemCount; i++) + { + const QListWidgetItem* item = m_fileList->item(i); + if ((item->flags() & Qt::ItemIsUserCheckable) != 0 && item->checkState()) + { + m_files.push_back(item->text()); + } + } accept(); } diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index fe9cb628ea..0a179ac753 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -30,6 +30,7 @@ class QTextEdit; class QDialogButtonBox; class QPushButton; class QMainWindow; +class QListWidget; class RicFileHierarchyDialogResult; //================================================================================================== @@ -39,21 +40,12 @@ class RicFileHierarchyDialog : public QDialog { Q_OBJECT + enum Status {WORKING, NO_FILES_FOUND}; + public: RicFileHierarchyDialog(QWidget* parent); ~RicFileHierarchyDialog(); - QStringList files() const; - QString rootDir() const; - QString pathFilter() const; - QString fileNameFilter() const; - QStringList fileExtensions() const; - bool cancelPressed() const; - - void appendToFileList(const QString& fileName); - void clearFileList(); - void updateStatus(); - static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, const QString& caption = QString(), const QString& dir = QString(), @@ -62,6 +54,17 @@ class RicFileHierarchyDialog : public QDialog const QStringList& fileExtensions = QStringList()); private: + QStringList files() const; + QString rootDir() const; + QString pathFilter() const; + QString fileNameFilter() const; + QStringList fileExtensions() const; + bool cancelPressed() const; + void appendToFileList(const QString& fileName); + void clearFileList(); + void updateStatus(Status status, bool force = false); + QString currentStatus() const; + QStringList findMatchingFiles(); QStringList buildDirectoryListRecursive(const QString& currentDir); @@ -100,7 +103,7 @@ private slots: QLabel* m_effectiveFilter; QLabel* m_fileListLabel; - QTextEdit* m_fileList; + QListWidget* m_fileList; QPushButton* m_findOrCancelButton; QDialogButtonBox* m_buttons; From 140b75df88349c2c3787e28554230cd306bfabb8 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 24 Jan 2018 11:30:39 +0100 Subject: [PATCH 0127/1027] #2390 Intersections: Add noUpdate-version of appendIntersection and appendIntersectionBox --- .../RimIntersectionCollection.cpp | 22 ++++++++++++++++--- .../RimIntersectionCollection.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index 98078b7a9a..a1f7eed239 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -160,7 +160,7 @@ void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* int updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersection); - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { @@ -168,6 +168,14 @@ void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* int } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::appendIntersectionNoUpdate(RimIntersection* intersection) +{ + m_intersections.push_back(intersection); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -188,7 +196,7 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBo updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { @@ -196,6 +204,14 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBo } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::appendIntersectionBoxNoUpdate(RimIntersectionBox* intersectionBox) +{ + m_intersectionBoxes.push_back(intersectionBox); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -203,7 +219,7 @@ void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* chan { if (changedField == &isActive) { - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 2f964dfe21..167338c1e7 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -49,8 +49,10 @@ class RimIntersectionCollection : public caf::PdmObject caf::PdmField isActive; void appendIntersectionAndUpdate(RimIntersection* intersection); + void appendIntersectionNoUpdate(RimIntersection* intersection); void appendIntersectionBoxAndUpdate(RimIntersectionBox* intersectionBox); + void appendIntersectionBoxNoUpdate(RimIntersectionBox* intersectionBox); bool hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const; From 8b4a1f05bcbd4f2d89fbd09bbfd754c225db558c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 24 Jan 2018 11:44:20 +0100 Subject: [PATCH 0128/1027] #2390 Intersections: Add Copy/Paste --- .../CMakeLists_files.cmake | 2 + .../RicCopyReferencesToClipboardFeature.cpp | 10 ++ .../RicPasteIntersectionsFeature.cpp | 163 ++++++++++++++++++ .../RicPasteIntersectionsFeature.h | 41 +++++ .../RimContextCommandBuilder.cpp | 3 + 5 files changed, 219 insertions(+) create mode 100644 ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp create mode 100644 ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake index 5a4634cd4e..ce29835af3 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake @@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h ${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteIntersectionsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -22,6 +23,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp ${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteIntersectionsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index 58ae9b9734..d99c3a8c34 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -22,6 +22,8 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimGeoMechView.h" +#include "RimIntersection.h" +#include "RimIntersectionBox.h" #include "RimMimeData.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" @@ -136,6 +138,14 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { return true; } + else if (dynamic_cast(pdmObject)) + { + return true; + } + else if (dynamic_cast(pdmObject)) + { + return true; + } else if (dynamic_cast(pdmObject)) { return true; diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp new file mode 100644 index 0000000000..b7ed0e8e1c --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp @@ -0,0 +1,163 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteIntersectionsFeature.h" + +#include "RicPasteFeatureImpl.h" + +#include "RimIntersection.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" + +#include "RiuMainWindow.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicPasteIntersectionsFeature, "RicPasteIntersectionsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteIntersectionsFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> intersectionObjects; + objectGroup.objectsByType(&intersectionObjects); + + std::vector> intersectionBoxObjects; + objectGroup.objectsByType(&intersectionBoxObjects); + + if (intersectionObjects.empty() && intersectionBoxObjects.empty()) + { + return false; + } + + caf::PdmObjectHandle* destinationObject = + dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + if (findIntersectionCollection(destinationObject)) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteIntersectionsFeature::onActionTriggered(bool isChecked) +{ + caf::PdmObjectHandle* destinationObject = + dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimIntersectionCollection* intersectionCollection = + RicPasteIntersectionsFeature::findIntersectionCollection(destinationObject); + + CAF_ASSERT(intersectionCollection); + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + if (objectGroup.objects.size() == 0) return; + + std::vector> intersectionObjects; + objectGroup.objectsByType(&intersectionObjects); + + for (size_t i = 0; i < intersectionObjects.size(); i++) + { + RimIntersection* intersection = dynamic_cast( + intersectionObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + QString nameOfCopy = QString("Copy of ") + intersection->name; + intersection->name = nameOfCopy; + + if (i == intersectionObjects.size() - 1) + { + intersectionCollection->appendIntersectionAndUpdate(intersection); + } + else + { + intersectionCollection->appendIntersectionNoUpdate(intersection); + } + } + + std::vector> intersectionBoxObjects; + objectGroup.objectsByType(&intersectionBoxObjects); + + for (size_t i = 0; i < intersectionBoxObjects.size(); i++) + { + RimIntersectionBox* intersectionBox = dynamic_cast( + intersectionBoxObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + QString nameOfCopy = QString("Copy of ") + intersectionBox->name; + intersectionBox->name = nameOfCopy; + + if (i == intersectionBoxObjects.size() - 1) + { + intersectionCollection->appendIntersectionBoxAndUpdate(intersectionBox); + } + else + { + intersectionCollection->appendIntersectionBoxNoUpdate(intersectionBox); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteIntersectionsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (Intersections)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* RicPasteIntersectionsFeature::findIntersectionCollection(caf::PdmObjectHandle* objectHandle) +{ + RimIntersectionCollection* intersectionCollection = dynamic_cast(objectHandle); + if (intersectionCollection) + { + return intersectionCollection; + } + + RimIntersection* intersection = dynamic_cast(objectHandle); + if (intersection) + { + intersection->firstAncestorOrThisOfType(intersectionCollection); + return intersectionCollection; + } + + RimIntersectionBox* intersectionBox = dynamic_cast(objectHandle); + if (intersectionBox) + { + intersectionBox->firstAncestorOrThisOfType(intersectionCollection); + return intersectionCollection; + } + + return nullptr; +} diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h new file mode 100644 index 0000000000..15a770b7b7 --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmObjectHandle.h" + +class RimIntersectionCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteIntersectionsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimIntersectionCollection* findIntersectionCollection(caf::PdmObjectHandle* objectHandle); +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index c566fa08af..e331ec37f8 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -449,6 +449,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { @@ -456,11 +457,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicAppendIntersectionBoxFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { From d646af85146077a03ee15214e49c8ee398663780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 12:35:47 +0100 Subject: [PATCH 0129/1027] #2384 multi case import. Context menu for on/off/toggle files --- .../Commands/RicFileHierarchyDialog.cpp | 74 ++++++++++++++++++- .../Commands/RicFileHierarchyDialog.h | 4 + 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 3936106ab4..922e32dd66 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,7 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) connect(m_rootDir, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); connect(m_pathFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); connect(m_fileFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_fileList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotFileListCustomMenuRequested(const QPoint&))); connect(m_findOrCancelButton, SIGNAL(clicked()), this, SLOT(slotFindOrCancelButtonClicked())); connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); @@ -109,8 +111,9 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_effectiveFilter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_fileListLabel->setText("Files found"); m_fileListLabel->setVisible(false); - m_fileList->setSelectionMode(QAbstractItemView::NoSelection); + m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection); m_fileList->setVisible(false); + m_fileList->setContextMenuPolicy(Qt::CustomContextMenu); m_browseButton->setText("..."); m_browseButton->setFixedWidth(25); m_findOrCancelButton->setText(FIND_BUTTON_FIND_TEXT); @@ -419,7 +422,7 @@ void RicFileHierarchyDialog::updateEffectiveFilter() // Remove duplicate separators int len; - do + do { len = native.size(); native.replace(separator + separator, separator); @@ -445,6 +448,73 @@ void RicFileHierarchyDialog::slotFilterChanged(const QString& text) updateEffectiveFilter(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFileListCustomMenuRequested(const QPoint& point) +{ + QMenu menu; + QPoint globalPoint = point; + QAction* action; + + action = new QAction("On", this); + connect(action, SIGNAL(triggered()), SLOT(slotTurnOnFileListItems())); + menu.addAction(action); + + action = new QAction("Off", this); + connect(action, SIGNAL(triggered()), SLOT(slotTurnOffFileListItems())); + menu.addAction(action); + + action = new QAction("Toggle", this); + connect(action, SIGNAL(triggered()), SLOT(slotToggleFileListItems())); + menu.addAction(action); + + globalPoint = m_fileList->mapToGlobal(point); + menu.exec(globalPoint); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotToggleFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotTurnOffFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(Qt::Unchecked); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotTurnOnFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(Qt::Checked); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 0a179ac753..abe5f5c3ea 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -82,6 +82,10 @@ class RicFileHierarchyDialog : public QDialog private slots: void slotFilterChanged(const QString& text); + void slotFileListCustomMenuRequested(const QPoint& point); + void slotToggleFileListItems(); + void slotTurnOffFileListItems(); + void slotTurnOnFileListItems(); void slotFindOrCancelButtonClicked(); void slotDialogOkClicked(); void slotDialogCancelClicked(); From 5d840368b19fdfb1976e1346da895d8f9e909733 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 24 Jan 2018 13:10:14 +0100 Subject: [PATCH 0130/1027] #2390 Intersections: Move paste command to the top in the context menus --- .../ProjectDataModel/RimContextCommandBuilder.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e331ec37f8..d89c4d3c47 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -447,23 +447,26 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; - menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewIntersectionViewFeature"; - menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; - menuBuilder << "RicPasteIntersectionsFeature"; } else if (dynamic_cast(uiItem)) { @@ -561,6 +564,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPasteTimeHistoryCurveFeature"; menuBuilder << "RicPasteAsciiDataCurveFeature"; + menuBuilder << "RicPasteSummaryCaseFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicCopyReferencesToClipboardFeature"; menuBuilder << "RicShowPlotDataFeature"; @@ -586,7 +591,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicExportCarfin"; menuBuilder << "RicImportObservedDataFeature"; - menuBuilder << "RicPasteSummaryCaseFeature"; menuBuilder << "RicReloadSummaryCaseFeature"; menuBuilder << "RicCreateSummaryCaseCollectionFeature"; menuBuilder << "Separator"; From a039bcd0a953bfd84a30bcfeb0c115a6f3152ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 13:00:31 +0100 Subject: [PATCH 0131/1027] File hierarchy dialog. Stop if no root dir --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 922e32dd66..814c1d5847 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -305,6 +305,8 @@ QString RicFileHierarchyDialog::currentStatus() const //-------------------------------------------------------------------------------------------------- QStringList RicFileHierarchyDialog::findMatchingFiles() { + if (m_rootDir->text().isEmpty()) return QStringList(); + const QStringList& dirs = buildDirectoryListRecursive(rootDir()); const QStringList& files = findFilesInDirs(dirs); From 5e46a378aa0cd6d4cc5ca7a8cf07af105f68292d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 13:18:25 +0100 Subject: [PATCH 0132/1027] #2384 multi case import. New command feature for importing cases into group recursively --- .../EclipseCommands/CMakeLists_files.cmake | 2 + ...RicCreateGridCaseGroupFromFilesFeature.cpp | 75 +++++++++++++++++++ .../RicCreateGridCaseGroupFromFilesFeature.h | 47 ++++++++++++ .../RimContextCommandBuilder.cpp | 1 + .../UserInterface/RiuMainPlotWindow.cpp | 1 + .../UserInterface/RiuMainWindow.cpp | 1 + 6 files changed, 127 insertions(+) create mode 100644 ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp create mode 100644 ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h diff --git a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake index c0e17230fe..eb145a3515 100644 --- a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -8,6 +8,7 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.h ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h ${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.h +${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFromFilesFeature.h ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.h @@ -28,6 +29,7 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.cpp ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp +${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFromFilesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp ${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.cpp diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp new file mode 100644 index 0000000000..0518025b8c --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCreateGridCaseGroupFromFilesFeature.h" + +#include "RiaApplication.h" +#include "RiaImportEclipseCaseTools.h" + +#include "RicFileHierarchyDialog.h" + +#include "RimEclipseCaseCollection.h" +#include "RiuMultiCaseImportDialog.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicCreateGridCaseGroupFromFilesFeature, "RicCreateGridCaseGroupFromFilesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateGridCaseGroupFromFilesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseGroupFromFilesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Create Grid Case Group from Files", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".EGRID")); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (result.ok) + { + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + + RiaImportEclipseCaseTools::addEclipseCases(result.files); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseGroupFromFilesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/CreateGridCaseGroup16x16.png")); + actionToSetup->setText("&Create Grid Case Group from Files Recursively"); +} diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h new file mode 100644 index 0000000000..94ef8a8bb5 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicCreateGridCaseGroupFromFilesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + + RicCreateGridCaseGroupFromFilesFeature() : m_pathFilter("*"), m_fileNameFilter("*") {} + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + QString m_pathFilter; + QString m_fileNameFilter; + +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index d89c4d3c47..13b119fe5b 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -125,6 +125,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicImportEclipseCaseFeature"; menuBuilder << "RicImportInputEclipseCaseFeature"; menuBuilder << "RicCreateGridCaseGroupFeature"; + menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; menuBuilder << "RicEclipseCaseNewGroupFeature"; } else if (dynamic_cast(uiItem)) diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 0a36a57abd..6c3bf525d5 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -190,6 +190,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index fdc74d6b71..4e132ed731 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -355,6 +355,7 @@ void RiuMainWindow::createMenus() importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); importMenu->addSeparator(); #ifdef USE_ODB_API importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); From 3f96ad7ad980f125fc4055c5a1aaeb6d67a3c2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 14:37:52 +0100 Subject: [PATCH 0133/1027] File hierarchy dialog. Trim extensions --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 814c1d5847..4128051ff9 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -229,7 +229,12 @@ QString RicFileHierarchyDialog::fileNameFilter() const //-------------------------------------------------------------------------------------------------- QStringList RicFileHierarchyDialog::fileExtensions() const { - return m_fileExtension->text().split("|"); + QStringList exts = m_fileExtension->text().split("|"); + for (QString& ext : exts) + { + ext = ext.trimmed(); + } + return exts; } //-------------------------------------------------------------------------------------------------- From 3d2e5b60881400e83f9c9307b4897f0f6efad4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 24 Jan 2018 14:39:06 +0100 Subject: [PATCH 0134/1027] #2383 Eclipse cases import. New command feature using file hierarchy dialog --- .../EclipseCommands/CMakeLists_files.cmake | 2 + .../RicImportEclipseCaseFeature.cpp | 2 +- .../RicImportEclipseCasesFeature.cpp | 93 +++++++++++++++++++ .../RicImportEclipseCasesFeature.h | 47 ++++++++++ .../RimContextCommandBuilder.cpp | 1 + .../UserInterface/RiuMainPlotWindow.cpp | 2 + .../UserInterface/RiuMainWindow.cpp | 1 + 7 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp create mode 100644 ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h diff --git a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake index eb145a3515..c3c1cd1e66 100644 --- a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -17,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.h ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h ${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h +${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.h ${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h @@ -38,6 +39,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.cpp ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index b208bed484..8b700f4092 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -59,7 +59,7 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked) { QString fileName = fileNames[i]; - if (!fileNames.isEmpty()) + if (!fileName.isEmpty()) { if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName)) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp new file mode 100644 index 0000000000..61d26dc959 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportEclipseCasesFeature.h" + +#include "RiaImportEclipseCaseTools.h" + +#include "RiaApplication.h" + +#include "RicFileHierarchyDialog.h" + +#include "RimEclipseCaseCollection.h" + +#include "RiuMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportEclipseCasesFeature, "RicImportEclipseCasesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEclipseCasesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, + "Import Eclipse Cases", + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList() << ".EGRID" << ".GRID"); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (!result.ok) return; + + // Remember the path to next time + app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(result.rootDir).absoluteFilePath()); + + int i; + for (i = 0; i < result.files.size(); i++) + { + QString fileName = result.files[i]; + + if (!fileName.isEmpty()) + { + if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName)) + { + app->addToRecentFiles(fileName); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEclipseCasesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Case48x48.png")); + actionToSetup->setText("Import Eclipse Cases Recursively"); +} diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h new file mode 100644 index 0000000000..ac1c49f8c7 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicImportEclipseCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + RicImportEclipseCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") {} + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + QString m_pathFilter; + QString m_fileNameFilter; +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 13b119fe5b..ddff018635 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -123,6 +123,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if (dynamic_cast(uiItem)) { menuBuilder << "RicImportEclipseCaseFeature"; + menuBuilder << "RicImportEclipseCasesFeature"; menuBuilder << "RicImportInputEclipseCaseFeature"; menuBuilder << "RicCreateGridCaseGroupFeature"; menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 6c3bf525d5..66820de6e4 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -185,6 +185,7 @@ void RiuMainPlotWindow::createMenus() QMenu* importMenu = fileMenu->addMenu("&Import"); importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); @@ -257,6 +258,7 @@ QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) if (toolbarName.isEmpty() || toolbarName == "Standard") { commandIds << "RicImportEclipseCaseFeature"; + commandIds << "RicImportEclipseCasesFeature"; commandIds << "RicImportInputEclipseCaseFeature"; commandIds << "RicImportSummaryCaseFeature"; commandIds << "RicOpenProjectFeature"; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 4e132ed731..31b2b2b8f6 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -352,6 +352,7 @@ void RiuMainWindow::createMenus() QMenu* importMenu = fileMenu->addMenu("&Import"); importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); From 95db322f578b1fc36032553fd93e00c956f92c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 25 Jan 2018 13:56:51 +0100 Subject: [PATCH 0135/1027] #2384 multi case import. Fix path filtering. Display relative file names --- .../Commands/RicFileHierarchyDialog.cpp | 125 +++++++++++++----- .../Commands/RicFileHierarchyDialog.h | 4 +- .../UserInterface/RiuMainPlotWindow.cpp | 1 - 3 files changed, 92 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 4128051ff9..09e5765c11 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -61,13 +61,16 @@ //-------------------------------------------------------------------------------------------------- /// Internal variables //-------------------------------------------------------------------------------------------------- -static QString separator = QString(QDir::separator()); +static QString SEPARATOR = "/"; //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -static QStringList prefixStrings(const QStringList& strings, const QString& prefix); -static QString relativePath(const QString& rootDir, const QString& dir); +static QString toInternalSeparator(const QString& path); +static QString& appendSeparatorIfNo(QString& path); +static QStringList prefixStrings(const QStringList& strings, const QString& prefix); +static QString relativePath(const QString& rootDir, const QString& dir); +static bool equalPaths(const QString& path1, const QString& path2); //-------------------------------------------------------------------------------------------------- /// @@ -200,12 +203,8 @@ QStringList RicFileHierarchyDialog::files() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::rootDir() const { - QString rootDir = m_rootDir->text(); - if (!rootDir.endsWith(separator)) - { - rootDir.append(separator); - } - return QDir::toNativeSeparators(rootDir); + QString rootDir = toInternalSeparator(m_rootDir->text()); + return appendSeparatorIfNo(rootDir); } //-------------------------------------------------------------------------------------------------- @@ -213,7 +212,7 @@ QString RicFileHierarchyDialog::rootDir() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::pathFilter() const { - return QDir::toNativeSeparators(m_pathFilter->text()); + return toInternalSeparator(m_pathFilter->text()); } //-------------------------------------------------------------------------------------------------- @@ -252,7 +251,8 @@ void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { if (currentStatus().startsWith(WORKING_TEXT_1)) clearFileList(); - QListWidgetItem* item = new QListWidgetItem(fileName, m_fileList); + QString itemText = fileName; + QListWidgetItem* item = new QListWidgetItem(itemText.remove(0, rootDir().size()), m_fileList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(Qt::Checked); } @@ -325,33 +325,47 @@ QStringList RicFileHierarchyDialog::findMatchingFiles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& currentDir) +QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& currentDir, int level) { QStringList allDirs; if (cancelPressed()) return allDirs; - QDir qdir(currentDir); - QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + QString currPathFilter = pathFilter(); + bool subStringFilter = false; + + // Optimizing for speed by a refined match at first directory level + if (level == 1) + { + QString pathFilter = this->pathFilter(); + if (!pathFilter.startsWith("*")) + { + int wildcardIndex = pathFilter.indexOf(QRegExp(QString("[*%1]").arg(SEPARATOR))); + if (wildcardIndex >= 0) + { + currPathFilter = pathFilter.left(wildcardIndex + 1); + subStringFilter = true; + } + } + } - if (pathFilterMatch(currentDir)) + QString currRelPath = relativePath(rootDir(), currentDir); + if (pathFilterMatch(currPathFilter, currRelPath)) { allDirs.push_back(currentDir); } - else + else if(level == 1 && subStringFilter) { - // If there is no match and filter string does not start with a wildcard, there is no need to enter sub directories - if (!pathFilter().startsWith("*") && !relativePath(rootDir(), currentDir).isEmpty()) - { - return QStringList(); - } + return QStringList(); } + QDir qdir(currentDir); + QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (QString subDir : subDirs) { updateStatus(WORKING); QApplication::processEvents(); - allDirs += buildDirectoryListRecursive(QDir::toNativeSeparators(qdir.absoluteFilePath(subDir))); + allDirs += buildDirectoryListRecursive(qdir.absoluteFilePath(subDir), level + 1); } return cancelPressed() ? QStringList() : allDirs; } @@ -374,7 +388,7 @@ QStringList RicFileHierarchyDialog::findFilesInDirs(const QStringList& dirs) for (QString file : files) { - QString absFilePath = QDir::toNativeSeparators(qdir.absoluteFilePath(file)); + QString absFilePath = qdir.absoluteFilePath(file); allFiles.append(absFilePath); } } @@ -406,11 +420,9 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicFileHierarchyDialog::pathFilterMatch(const QString& dir) +bool RicFileHierarchyDialog::pathFilterMatch(const QString& pathFilter, const QString& relPath) { - QRegExp regexp(pathFilter(), Qt::CaseInsensitive, QRegExp::Wildcard); - QString relPath = relativePath(rootDir(), dir); - + QRegExp regexp(pathFilter, Qt::CaseInsensitive, QRegExp::Wildcard); return regexp.exactMatch(relPath); } @@ -425,17 +437,18 @@ void RicFileHierarchyDialog::updateEffectiveFilter() .arg(m_fileFilter->text()) .arg(m_fileExtension->text()); - QString native(QDir::toNativeSeparators(effFilter)); + QString internalFilter(toInternalSeparator(effFilter)); // Remove duplicate separators int len; do { - len = native.size(); - native.replace(separator + separator, separator); - } while (native.size() != len); + len = internalFilter.size(); + internalFilter.replace(SEPARATOR + SEPARATOR, SEPARATOR); + } while (internalFilter.size() != len); - m_effectiveFilter->setText(native); + // Present native separators to the user + m_effectiveFilter->setText(QDir::toNativeSeparators(internalFilter)); } //-------------------------------------------------------------------------------------------------- @@ -576,7 +589,7 @@ void RicFileHierarchyDialog::slotDialogOkClicked() const QListWidgetItem* item = m_fileList->item(i); if ((item->flags() & Qt::ItemIsUserCheckable) != 0 && item->checkState()) { - m_files.push_back(item->text()); + m_files.push_back(rootDir() + item->text()); } } accept(); @@ -606,6 +619,36 @@ void RicFileHierarchyDialog::slotBrowseButtonClicked() /// Internal functions //-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString toInternalSeparator(const QString& path) +{ + QString currNativeSep = QDir::separator(); + + if (currNativeSep == "/") + { + // On Linux like system -> Do not convert separators + return path; + } + + // On other systems (i.e. Windows) -> Convert to internal separator (/) + QString output = path; + return output.replace(QString("\\"), SEPARATOR); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString& appendSeparatorIfNo(QString& path) +{ + if (!path.endsWith(SEPARATOR)) + { + path.append(SEPARATOR); + } + return path; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -636,11 +679,23 @@ QString relativePath(const QString& rootDir, const QString& dir) QString relPath = dir; relPath.remove(0, rootDir.size()); - if (relPath.startsWith("/") || relPath.startsWith("\\")) relPath.remove(0, 1); - return relPath; + if (relPath.startsWith(SEPARATOR)) relPath.remove(0, 1); + return appendSeparatorIfNo(relPath); } else { return dir; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool equalPaths(const QString& path1, const QString& path2) +{ + QString p1 = path1; + QString p2 = path2; + appendSeparatorIfNo(p1); + appendSeparatorIfNo(p2); + return p1 == p2; +} diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index abe5f5c3ea..c18a387550 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -67,14 +67,14 @@ class RicFileHierarchyDialog : public QDialog QStringList findMatchingFiles(); - QStringList buildDirectoryListRecursive(const QString& currentDir); + QStringList buildDirectoryListRecursive(const QString& currentDir, int level = 0); QStringList findFilesInDirs(const QStringList& dirs); QStringList createNameFilterList(const QString& fileNameFilter, const QStringList& fileExtensions); - bool pathFilterMatch(const QString& dir); + bool pathFilterMatch(const QString& pathFilter, const QString& relPath); void updateEffectiveFilter(); diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 66820de6e4..fea99aa384 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -258,7 +258,6 @@ QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) if (toolbarName.isEmpty() || toolbarName == "Standard") { commandIds << "RicImportEclipseCaseFeature"; - commandIds << "RicImportEclipseCasesFeature"; commandIds << "RicImportInputEclipseCaseFeature"; commandIds << "RicImportSummaryCaseFeature"; commandIds << "RicOpenProjectFeature"; From 001742cbd3b5f8b7020f5eb1e472e58178073866 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 12:14:54 +0100 Subject: [PATCH 0136/1027] #2402 Fracture : Add support for multiple conductivities on a template --- .../Application/RiaFractureDefines.h | 2 +- .../RivWellFracturePartMgr.cpp | 10 +- .../RimFractureTemplateCollection.cpp | 6 +- .../RimFractureTemplateCollection.h | 2 +- .../RimStimPlanFractureTemplate.cpp | 107 ++++++++++++++---- .../Completions/RimStimPlanFractureTemplate.h | 10 +- .../ProjectDataModel/RimStimPlanColors.cpp | 4 +- .../ProjectDataModel/RimStimPlanColors.h | 2 +- .../RigStimPlanFractureDefinition.cpp | 23 +++- .../RigStimPlanFractureDefinition.h | 15 ++- 10 files changed, 136 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/Application/RiaFractureDefines.h b/ApplicationCode/Application/RiaFractureDefines.h index 9854d41621..5c7562cab4 100644 --- a/ApplicationCode/Application/RiaFractureDefines.h +++ b/ApplicationCode/Application/RiaFractureDefines.h @@ -22,5 +22,5 @@ namespace RiaDefines { -static QString conductivityResultName(); +QString conductivityResultName(); }; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 2110fa8ed9..7ef5ada6a6 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -275,7 +275,7 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ // Conductivity text.append("Result value: "); - text.append(stimPlanColors->resultName() + " "); + text.append(stimPlanColors->uiResultName() + " "); text.append(condValueText + "\n"); // Cell index @@ -386,7 +386,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc { cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); - if (activeView.stimPlanColors->resultName().startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) + if (activeView.stimPlanColors->uiResultName().startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) { RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); if (ellipseFractureTemplate) @@ -455,7 +455,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa std::vector perNodeResultValues(nodeCoords.size(), HUGE_VAL); { size_t idx = 0; - const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.stimPlanColors->resultName(), activeView.stimPlanColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); + const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.stimPlanColors->uiResultName(), activeView.stimPlanColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); for (const std::vector& unmirroredDataAtDepth : dataToPlot) { const std::vector mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth); @@ -583,7 +583,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar scalarMapper = legendConfig->scalarMapper(); - QString resultNameFromColors = activeView.stimPlanColors->resultName(); + QString resultNameFromColors = activeView.stimPlanColors->uiResultName(); QString resultUnitFromColors = activeView.stimPlanColors->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, @@ -897,7 +897,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); std::vector stimPlanMeshVertices; - QString resultNameFromColors = activeView.stimPlanColors->resultName(); + QString resultNameFromColors = activeView.stimPlanColors->uiResultName(); QString resultUnitFromColors = activeView.stimPlanColors->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 6d8e8d3e36..cc0e1f5387 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -65,7 +65,7 @@ std::vector > RimFractureTemplateCollection::stimPla auto stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) { - std::vector > namesAndUnits = stimPlanFracture->resultNamesWithUnit(); + std::vector > namesAndUnits = stimPlanFracture->uiResultNamesWithUnit(); for (auto nameAndUnit : namesAndUnits) { @@ -82,7 +82,7 @@ std::vector > RimFractureTemplateCollection::stimPla //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, +void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const { MinMaxAccumulator minMaxAccumulator; @@ -92,7 +92,7 @@ void RimFractureTemplateCollection::computeMinMax(const QString& resultName, con { if (f) { - f->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator); + f->appendDataToResultStatistics(uiResultName, unit, minMaxAccumulator, posNegAccumulator); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 7dbfd2ec30..9bb9a8c2a6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -42,7 +42,7 @@ class RimFractureTemplateCollection : public caf::PdmObject caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; std::vector > stimPlanResultNamesAndUnits() const; - void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; + void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; void deleteFractureDefinitions(); void loadAndUpdateData(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index eca6f90440..b035bc7c02 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -19,6 +19,7 @@ #include "RimStimPlanFractureTemplate.h" #include "RiaApplication.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" #include "RifStimPlanXmlReader.h" @@ -70,9 +71,10 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void) CAF_PDM_InitField(&m_borderPolygonResultName, "BorderPolygonResultName", QString(""), "Parameter", "", "", ""); m_borderPolygonResultName.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); - CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show StimPlan Mesh", "", "", ""); - CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); + CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); + CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show StimPlan Mesh", "", "", ""); + CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); + CAF_PDM_InitField(&m_conductivityResultNameOnFile, "ConductivityResultName", QString(""), "Active Conductivity Result Name", "", "", ""); m_fractureGrid = new RigFractureGrid(); } @@ -130,13 +132,13 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch || &m_activeTimeStepIndex == changedField || &m_showStimPlanMesh == changedField || &m_conductivityScalingFactor == changedField - || &m_stimPlanFileName == changedField) + || &m_stimPlanFileName == changedField + || &m_conductivityResultNameOnFile == changedField) { RimProject* proj; this->firstAncestorOrThisOfType(proj); if (proj) { - //Regenerate geometry proj->createDisplayModelAndRedrawAllViews(); } } @@ -208,7 +210,7 @@ void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() { // first option: Width - for (std::pair property : resultNamesWithUnit()) + for (std::pair property : uiResultNamesWithUnit()) { if (property.first == "WIDTH") { @@ -225,9 +227,9 @@ bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() } // else: Set to first property - if (resultNamesWithUnit().size() > 0) + if (uiResultNamesWithUnit().size() > 0) { - m_borderPolygonResultName = resultNamesWithUnit()[0].first; + m_borderPolygonResultName = uiResultNamesWithUnit()[0].first; return true; } return false; @@ -269,13 +271,12 @@ QList RimStimPlanFractureTemplate::calculateValueOptions if (fieldNeedingOptions == &m_borderPolygonResultName) { - for (std::pair nameUnit : resultNamesWithUnit()) + for (std::pair nameUnit : uiResultNamesWithUnit()) { //options.push_back(caf::PdmOptionItemInfo(nameUnit.first + " [" + nameUnit.second + "]", nameUnit.first + " " + nameUnit.second)); options.push_back(caf::PdmOptionItemInfo(nameUnit.first, nameUnit.first)); } } - else if (fieldNeedingOptions == &m_activeTimeStepIndex) { std::vector timeValues = timeSteps(); @@ -287,6 +288,17 @@ QList RimStimPlanFractureTemplate::calculateValueOptions } } + else if (fieldNeedingOptions == &m_conductivityResultNameOnFile) + { + if (m_stimPlanFractureDefinitionData.notNull()) + { + QStringList conductivityResultNames = m_stimPlanFractureDefinitionData->conductivityResultNames(); + for (const auto& resultName : conductivityResultNames) + { + options.push_back(caf::PdmOptionItemInfo(resultName, resultName)); + } + } + } return options; @@ -315,7 +327,7 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet bool found = false; bool foundMultiple = false; - for (std::pair nameUnit : resultNamesWithUnit()) + for (std::pair nameUnit : uiResultNamesWithUnit()) { if (nameUnit.first == parameterName) { @@ -331,6 +343,25 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimStimPlanFractureTemplate::mapUiResultNameToFileResultName(const QString& uiResultName) const +{ + QString fileResultName; + + if (uiResultName == RiaDefines::conductivityResultName()) + { + fileResultName = m_conductivityResultNameOnFile(); + } + else + { + fileResultName = uiResultName; + } + + return fileResultName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -347,24 +378,50 @@ std::vector RimStimPlanFractureTemplate::timeSteps() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RimStimPlanFractureTemplate::resultNamesWithUnit() const +std::vector > RimStimPlanFractureTemplate::uiResultNamesWithUnit() const { - std::vector > propertyNamesUnits; + std::vector > propertyNamesAndUnits; + if (m_stimPlanFractureDefinitionData.notNull()) { - propertyNamesUnits = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + QString conductivityUnit = "mD/s"; + + std::vector > tmp; + + std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + for (const auto& nameUnitPair : propertyNamesUnitsOnFile) + { + if (nameUnitPair.first.contains("conductivity", Qt::CaseInsensitive)) + { + conductivityUnit = nameUnitPair.second; + } + else + { + tmp.push_back(nameUnitPair); + } + } + + propertyNamesAndUnits.push_back(std::make_pair(RiaDefines::conductivityResultName(), conductivityUnit)); + + for (const auto& nameUnitPair : tmp) + { + propertyNamesAndUnits.push_back(nameUnitPair); + } } - return propertyNamesUnits; + + return propertyNamesAndUnits; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> RimStimPlanFractureTemplate::resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const +std::vector> RimStimPlanFractureTemplate::resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const { if (m_stimPlanFractureDefinitionData.notNull()) { - return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex); + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(fileResultName, unitName, timeStepIndex); } return std::vector>(); @@ -373,11 +430,13 @@ std::vector> RimStimPlanFractureTemplate::resultValues(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimStimPlanFractureTemplate::fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const +std::vector RimStimPlanFractureTemplate::fractureGridResults(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const { if (m_stimPlanFractureDefinitionData.notNull()) { - return m_stimPlanFractureDefinitionData->fractureGridResults(resultName, unitName, timeStepIndex); + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + return m_stimPlanFractureDefinitionData->fractureGridResults(fileResultName, unitName, timeStepIndex); } return std::vector(); @@ -400,13 +459,15 @@ bool RimStimPlanFractureTemplate::hasConductivity() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit, +void RimStimPlanFractureTemplate::appendDataToResultStatistics(const QString& uiResultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const { if (m_stimPlanFractureDefinitionData.notNull()) { - m_stimPlanFractureDefinitionData->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator); + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + m_stimPlanFractureDefinitionData->appendDataToResultStatistics(fileResultName, unit, minMaxAccumulator, posNegAccumulator); } } @@ -427,7 +488,8 @@ void RimStimPlanFractureTemplate::updateFractureGrid() if (m_stimPlanFractureDefinitionData.notNull()) { - m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_activeTimeStepIndex, + m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_conductivityResultNameOnFile, + m_activeTimeStepIndex, fractureTemplateUnit, m_wellPathDepthAtFracture); } @@ -504,6 +566,7 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd m_fractureContainment()->defineUiOrdering(uiConfigName, *trGr); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); + propertyGroup->add(&m_conductivityResultNameOnFile); propertyGroup->add(&m_conductivityScalingFactor); propertyGroup->add(&conductivityType); propertyGroup->add(&skinFactor); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index b94bd23184..d70290aadf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -77,12 +77,12 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate // Result Access std::vector timeSteps(); - std::vector > resultNamesWithUnit() const; - std::vector> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; + std::vector > uiResultNamesWithUnit() const; + std::vector> resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; - virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, + virtual void appendDataToResultStatistics(const QString& uiResultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const override; @@ -99,7 +99,11 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void setDepthOfWellPathAtFracture(); QString getUnitForStimPlanParameter(QString parameterName); + QString mapUiResultNameToFileResultName(const QString& uiResultName) const; + +private: caf::PdmField m_activeTimeStepIndex; + caf::PdmField m_conductivityResultNameOnFile; caf::PdmField m_showStimPlanMesh; caf::PdmField m_wellPathDepthAtFracture; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index c3899cbb8a..6be6807361 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -199,7 +199,7 @@ RimLegendConfig* RimStimPlanColors::activeLegend() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimStimPlanColors::resultName() const +QString RimStimPlanColors::uiResultName() const { return RimStimPlanColors::toResultName(m_resultNameAndUnit()); } @@ -243,7 +243,7 @@ void RimStimPlanColors::updateLegendData() RimFractureTemplateCollection* fracTemplateColl = fractureTemplateCollection(); - fracTemplateColl->computeMinMax(resultName(), unit(), &minValue, &maxValue, &posClosestToZero, &negClosestToZero); + fracTemplateColl->computeMinMax(uiResultName(), unit(), &minValue, &maxValue, &posClosestToZero, &negClosestToZero); if (minValue != HUGE_VAL) { diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index f923a32137..4b74f9d038 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -49,7 +49,7 @@ class RimStimPlanColors : public RimCheckableNamedObject virtual ~RimStimPlanColors(); RimLegendConfig* activeLegend() const; - QString resultName() const; + QString uiResultName() const; void setDefaultResultNameForStimPlan(); QString unit() const; cvf::Color3f defaultColor() const; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 9afc1f7933..481b6942a0 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -147,7 +147,8 @@ std::vector> RigStimPlanFractureDefinition::getMirroredDataA //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigStimPlanFractureDefinition::createFractureGrid(int m_activeTimeStepIndex, +cvf::ref RigStimPlanFractureDefinition::createFractureGrid(const QString& resultName, + int m_activeTimeStepIndex, RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, double m_wellPathDepthAtFracture) { @@ -159,7 +160,7 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(int QString condUnit; if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC ) condUnit = "md-m"; if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD ) condUnit = "md-ft"; - std::vector> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex(this->conductivityResultName(), + std::vector> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultName, condUnit, m_activeTimeStepIndex); @@ -631,3 +632,21 @@ QString RigStimPlanFractureDefinition::conductivityResultName() const return ""; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RigStimPlanFractureDefinition::conductivityResultNames() const +{ + QStringList resultNames; + + for (const auto& stimPlanResult : m_stimPlanResults) + { + if (stimPlanResult.resultName.contains("conductivity", Qt::CaseInsensitive)) + { + resultNames.push_back(stimPlanResult.resultName); + } + } + + return resultNames; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 0964a7a5d9..6b792cb42c 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -69,12 +69,9 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector getNegAndPosXcoords() const; std::vector adjustedDepthCoordsAroundWellPathPosition(double wellPathDepthAtFracture) const; - std::vector> getMirroredDataAtTimeIndex(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const; - - cvf::ref createFractureGrid(int m_activeTimeStepIndex, + cvf::ref createFractureGrid(const QString& resultName, + int m_activeTimeStepIndex, RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, double m_wellPathDepthAtFracture); @@ -110,15 +107,23 @@ class RigStimPlanFractureDefinition: public cvf::Object PosNegAccumulator& posNegAccumulator) const; QString conductivityResultName() const; + QStringList conductivityResultNames() const; // Setup void reorderYgridToDepths(); + private: bool timeStepExisist(double timeStepValue); size_t getTimeStepIndex(double timeStepValue); size_t resultIndex(const QString& resultName, const QString& unit) const; size_t mirroredGridXCount() const { return m_gridXs.size() ? m_gridXs.size() + m_gridXs.size() - 1 : 0 ;} + std::vector> getMirroredDataAtTimeIndex(const QString& resultName, + const QString& unitName, + size_t timeStepIndex) const; + + +private: RiaEclipseUnitTools::UnitSystem m_unitSet; std::vector m_gridXs; std::vector m_gridYs; From 827468b764fa3ff804ee79489d5b6549600b2843 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 12:27:36 +0100 Subject: [PATCH 0137/1027] #2402 Code cleanup --- .../RimStimPlanFractureTemplate.cpp | 20 +++++++++++++++++-- .../Completions/RimStimPlanFractureTemplate.h | 15 +++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index b035bc7c02..e6a3694b12 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -58,7 +58,7 @@ CAF_PDM_SOURCE_INIT(RimStimPlanFractureTemplate, "RimStimPlanFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void) +RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); @@ -86,6 +86,22 @@ RimStimPlanFractureTemplate::~RimStimPlanFractureTemplate() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimStimPlanFractureTemplate::activeTimeStepIndex() +{ + return m_activeTimeStepIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStimPlanFractureTemplate::showStimPlanMesh() +{ + return m_showStimPlanMesh; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -227,7 +243,7 @@ bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() } // else: Set to first property - if (uiResultNamesWithUnit().size() > 0) + if (!uiResultNamesWithUnit().empty()) { m_borderPolygonResultName = uiResultNamesWithUnit()[0].first; return true; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index d70290aadf..34a8056460 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -49,11 +49,11 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate CAF_PDM_HEADER_INIT; public: - RimStimPlanFractureTemplate(void); - virtual ~RimStimPlanFractureTemplate(void); + RimStimPlanFractureTemplate(); + virtual ~RimStimPlanFractureTemplate(); - int activeTimeStepIndex() { return m_activeTimeStepIndex; } - bool showStimPlanMesh() { return m_showStimPlanMesh;} + int activeTimeStepIndex(); + bool showStimPlanMesh(); void loadDataAndUpdate(); void setDefaultsBasedOnXMLfile(); @@ -67,12 +67,12 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate // Fracture geometry - const RigFractureGrid* fractureGrid() const; + const RigFractureGrid* fractureGrid() const override; void updateFractureGrid(); void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* triangleIndices, RiaEclipseUnitTools::UnitSystem neededUnit) override; - std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit); + std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) override; // Result Access @@ -89,7 +89,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; private: @@ -113,5 +113,4 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate cvf::ref m_stimPlanFractureDefinitionData; caf::PdmField m_conductivityScalingFactor; cvf::ref m_fractureGrid; - }; From 430b193437e8ecad087d7142ecc24ffbd03f9a68 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 13:30:36 +0100 Subject: [PATCH 0138/1027] #2402 Fracture : Compute conductivity scaling for all conductivity variants --- .../FileInterface/RifStimPlanXmlReader.cpp | 19 +++++++-- .../RivWellFracturePartMgr.cpp | 3 +- .../RimEllipseFractureTemplate.cpp | 5 ++- .../Completions/RimEllipseFractureTemplate.h | 2 +- .../RimStimPlanFractureTemplate.cpp | 6 +-- .../ProjectDataModel/RimStimPlanColors.cpp | 3 +- .../RigStimPlanFractureDefinition.cpp | 42 +------------------ .../RigStimPlanFractureDefinition.h | 3 +- 8 files changed, 29 insertions(+), 54 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index ab99c3747b..dc8a7c0543 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -19,8 +19,9 @@ #include "RifStimPlanXmlReader.h" #include "RiaEclipseUnitTools.h" -#include "RigStimPlanFractureDefinition.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" +#include "RigStimPlanFractureDefinition.h" #include #include @@ -117,8 +118,20 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil return nullptr; } - stimPlanFileData->setDataAtTimeValue(parameter, unit, propertyValuesAtTimestep, timeStepValue, conductivityScalingFactor); - + if (parameter.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) + { + // Scale all parameters containing conductivity + + for (auto& dataAtDepth : propertyValuesAtTimestep) + { + for (auto& dataValue : dataAtDepth) + { + dataValue *= conductivityScalingFactor; + } + } + } + + stimPlanFileData->setDataAtTimeValue(parameter, unit, propertyValuesAtTimestep, timeStepValue); } } } diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 7ef5ada6a6..aa2397fb76 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -18,6 +18,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaFractureDefines.h" #include "RigCellGeometryTools.h" #include "RigFractureCell.h" @@ -386,7 +387,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc { cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); - if (activeView.stimPlanColors->uiResultName().startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) + if (activeView.stimPlanColors->uiResultName() == RiaDefines::conductivityResultName()) { RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); if (ellipseFractureTemplate) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 8e6e811b6c..ea99f27828 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -19,6 +19,7 @@ #include "RimEllipseFractureTemplate.h" #include "RiaEclipseUnitTools.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" #include "RigCellGeometryTools.h" @@ -314,9 +315,9 @@ double RimEllipseFractureTemplate::conductivity() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const +void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& uiResultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const { - if (resultName.startsWith("CONDUCTIVITY", Qt::CaseInsensitive)) + if (uiResultName == RiaDefines::conductivityResultName()) { minMaxAccumulator.addValue(conductivity()); posNegAccumulator.addValue(conductivity()); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 726fa0f737..d9a73dfd24 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -59,7 +59,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate void setDefaultValuesFromUnit(); double conductivity() const; - virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, + virtual void appendDataToResultStatistics(const QString& uiResultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index e6a3694b12..1f880a4806 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -238,7 +238,7 @@ bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() // if width not found, use conductivity if (hasConductivity()) { - m_borderPolygonResultName = m_stimPlanFractureDefinitionData->conductivityResultName(); + m_borderPolygonResultName = m_stimPlanFractureDefinitionData->conductivityResultNames().first(); return true; } @@ -407,7 +407,7 @@ std::vector > RimStimPlanFractureTemplate::uiResultN std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); for (const auto& nameUnitPair : propertyNamesUnitsOnFile) { - if (nameUnitPair.first.contains("conductivity", Qt::CaseInsensitive)) + if (nameUnitPair.first.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) { conductivityUnit = nameUnitPair.second; } @@ -464,7 +464,7 @@ std::vector RimStimPlanFractureTemplate::fractureGridResults(const QStri bool RimStimPlanFractureTemplate::hasConductivity() const { if (m_stimPlanFractureDefinitionData.notNull() && - !m_stimPlanFractureDefinitionData->conductivityResultName().isEmpty()) + !m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) { return true; } diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 6be6807361..851fa14fc6 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -19,6 +19,7 @@ #include "RimStimPlanColors.h" #include "RiaApplication.h" +#include "RiaFractureDefines.h" #include "RimEclipseView.h" #include "RimFractureTemplateCollection.h" @@ -371,7 +372,7 @@ void setDefaultResultIfStimPlan(caf::PdmField &field) for (auto resultNameAndUnit : templColl->stimPlanResultNamesAndUnits()) { - if (resultNameAndUnit.first == "CONDUCTIVITY") + if (resultNameAndUnit.first.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) { field = toString(resultNameAndUnit); break; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 481b6942a0..3b2aad96f0 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -528,20 +528,8 @@ size_t RigStimPlanFractureDefinition::resultIndex(const QString& resultName, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue, double condScalingFactor) +void RigStimPlanFractureDefinition::setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue) { - if (resultName == conductivityResultName()) - { - for (std::vector &dataAtDepth : data) - { - for (double &dataValue : dataAtDepth) - { - dataValue = dataValue * condScalingFactor; - } - } - } - - size_t resIndex = resultIndex(resultName, unit); if (resIndex != cvf::UNDEFINED_SIZE_T) @@ -604,34 +592,6 @@ void RigStimPlanFractureDefinition::appendDataToResultStatistics(const QString& } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RigStimPlanFractureDefinition::conductivityResultName() const -{ - static const QString conductivity_text("CONDUCTIVITY"); - static const QString conductivity_propped_text("Conductivity-Propped"); - - // By intention we have two for loops here, as "CONDUCTIVITY" has priority over "Conductivity-Propped" - for (auto stimPlanResult : m_stimPlanResults) - { - if (stimPlanResult.resultName.compare(conductivity_text, Qt::CaseInsensitive) == 0) - { - return stimPlanResult.resultName; - } - } - - for (auto stimPlanResult : m_stimPlanResults) - { - if (stimPlanResult.resultName.compare(conductivity_propped_text, Qt::CaseInsensitive) == 0) - { - return stimPlanResult.resultName; - } - } - - return ""; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 6b792cb42c..f6c730647c 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -96,7 +96,7 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector > getStimPlanPropertyNamesUnits() const; bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); size_t totalNumberTimeSteps(); - void setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue, double condScalingFactor); + void setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue); const std::vector>& getDataAtTimeIndex(const QString& resultName, const QString& unit, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, @@ -106,7 +106,6 @@ class RigStimPlanFractureDefinition: public cvf::Object MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const; - QString conductivityResultName() const; QStringList conductivityResultNames() const; // Setup From 6ce00377336d1ebf2e85df8b4f4f5831ca8cd168 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 13:53:14 +0100 Subject: [PATCH 0139/1027] #2141 : Fracture : Make sure a new StimPlan fracture get valid defaults --- .../Commands/RicNewStimPlanFractureTemplateFeature.cpp | 1 + .../Completions/RimStimPlanFractureTemplate.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp index 76419b3d3b..c4073bde48 100644 --- a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp @@ -66,6 +66,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) fractureDef->loadDataAndUpdate(); fractureDef->setDefaultsBasedOnXMLfile(); fractureDef->setDefaultWellDiameterFromUnit(); + fractureDef->updateFractureGrid(); fracDefColl->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 1f880a4806..88197bbdda 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -218,6 +218,11 @@ void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() if (polygonPropertySet) RiaLogging::info(QString("Calculating polygon outline based on %1 at timestep %2").arg(m_borderPolygonResultName).arg(m_stimPlanFractureDefinitionData->timeSteps()[m_activeTimeStepIndex])); else RiaLogging::info(QString("Property for polygon calculation not set.")); + + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } } //-------------------------------------------------------------------------------------------------- From 6ff354c7ec5b5673eb00a168f629c12b5338def1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 14:15:38 +0100 Subject: [PATCH 0140/1027] Fix signed/insigned compare --- ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index aa2397fb76..4cb79a651d 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -307,7 +307,7 @@ const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf: size_t cellJ = cvf::UNDEFINED_SIZE_T; const std::vector& cells = grid->fractureCells(); - for (int i = 0; i < grid->iCellCount(); i++) + for (size_t i = 0; i < grid->iCellCount(); i++) { const RigFractureCell& cell = cells[i * grid->jCellCount()]; std::vector polygon = cell.getPolygon(); @@ -320,7 +320,7 @@ const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf: } } - for (int j = 0; j < grid->jCellCount(); j++) + for (size_t j = 0; j < grid->jCellCount(); j++) { const RigFractureCell& cell = cells[j]; std::vector polygon = cell.getPolygon(); From aa6b657027b8e16afa89d5702c1c0c4e0dc9bff5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jan 2018 14:24:54 +0100 Subject: [PATCH 0141/1027] #2141 : Fracture : Show conductivity result name from file --- ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp | 4 +++- .../Completions/RimStimPlanFractureTemplate.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 4cb79a651d..b6b19d2884 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -276,7 +276,9 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ // Conductivity text.append("Result value: "); - text.append(stimPlanColors->uiResultName() + " "); + + QString resultName = stimPlanTemplate->mapUiResultNameToFileResultName(stimPlanColors->uiResultName()); + text.append(resultName + " "); text.append(condValueText + "\n"); // Cell index diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 34a8056460..719446169c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -86,6 +86,8 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const override; + QString mapUiResultNameToFileResultName(const QString& uiResultName) const; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; @@ -99,8 +101,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void setDepthOfWellPathAtFracture(); QString getUnitForStimPlanParameter(QString parameterName); - QString mapUiResultNameToFileResultName(const QString& uiResultName) const; - private: caf::PdmField m_activeTimeStepIndex; caf::PdmField m_conductivityResultNameOnFile; From 0bd3f4e74c4fac6bdbf0f6a2e008f583f1cc1274 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 25 Jan 2018 11:59:43 +0100 Subject: [PATCH 0142/1027] #2328 Give warning when user tries to calculate injection flooding without available fluxes --- .../ProjectDataModel/RimEclipseCellColors.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 0e30d696a6..d377a51c32 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -40,6 +40,8 @@ #include "cafPdmUiTreeOrdering.h" +#include "QMessageBox" + CAF_PDM_SOURCE_INIT(RimEclipseCellColors, "ResultSlot"); //-------------------------------------------------------------------------------------------------- @@ -275,6 +277,22 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep) { if (this->isFlowDiagOrInjectionFlooding()) { + RimEclipseCase* rimEclipseCase = nullptr; + this->firstAncestorOrThisOfType(rimEclipseCase); + CVF_ASSERT(rimEclipseCase); + if (!rimEclipseCase) return; + + RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT(eclipseCase); + if (!eclipseCase) return; + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); + + if (!cellResultsData->hasFlowDiagUsableFluxes()) + { + QMessageBox::warning(RiuMainWindow::instance(), "Injection Flooding", "Cannot calculate any injection flooding properties, since no fluxes are available"); + return; + } + double globalMin, globalMax; double globalPosClosestToZero, globalNegClosestToZero; RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); From eb03096c1cce51a87417437cf3eeaf7a57751c1d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 25 Jan 2018 12:00:48 +0100 Subject: [PATCH 0143/1027] Change "QMessageBox" to --- ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index d377a51c32..891798e060 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -40,7 +40,7 @@ #include "cafPdmUiTreeOrdering.h" -#include "QMessageBox" +#include CAF_PDM_SOURCE_INIT(RimEclipseCellColors, "ResultSlot"); From 868e1ef075a4dd583bd945a0064c5cfb5007e1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 25 Jan 2018 14:53:51 +0100 Subject: [PATCH 0144/1027] #2406 delete plot crash. Guard pointer to view --- ApplicationCode/UserInterface/RiuMainPlotWindow.cpp | 2 +- ApplicationCode/UserInterface/RiuMainPlotWindow.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index fea99aa384..4ac2d724e7 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -426,7 +426,7 @@ void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) //-------------------------------------------------------------------------------------------------- void RiuMainPlotWindow::updateSummaryPlotToolBar() { - RimSummaryPlot* summaryPlot = dynamic_cast(m_activePlotViewWindow); + RimSummaryPlot* summaryPlot = dynamic_cast(m_activePlotViewWindow.p()); if (summaryPlot) { std::vector toolBarFields; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index 697a0f7fc7..214df5ef2c 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -21,6 +21,7 @@ #include "RiuMainWindowBase.h" #include "cafPdmUiDragDropInterface.h" +#include "cafPdmPointer.h" #include @@ -116,7 +117,7 @@ private slots: QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI QMdiArea* m_mdiArea; - RimViewWindow* m_activePlotViewWindow; + caf::PdmPointer m_activePlotViewWindow; QMenu* m_windowMenu; From 02f6b9595996e94008b6928aebb218f2b62373e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 25 Jan 2018 17:37:22 +0100 Subject: [PATCH 0145/1027] #2333 Add flattened intersectino geometry. Some view modifications to move towards a final 2D view experience --- .../RicNewIntersectionViewFeature.cpp | 16 +-- .../RivIntersectionGeometryGenerator.cpp | 102 +++++++++++--- .../RivIntersectionGeometryGenerator.h | 4 +- .../Intersections/RivIntersectionPartMgr.cpp | 15 +- .../Intersections/RivIntersectionPartMgr.h | 11 +- .../Rim2dIntersectionView.cpp | 131 +++++++++++++++--- .../ProjectDataModel/Rim2dIntersectionView.h | 9 +- .../Rim2dIntersectionViewCollection.cpp | 1 - .../ProjectDataModel/Rim3dView.cpp | 57 +++++++- ApplicationCode/ProjectDataModel/Rim3dView.h | 19 ++- .../ProjectDataModel/RimEclipseView.cpp | 35 +---- .../ProjectDataModel/RimEclipseView.h | 8 -- .../ProjectDataModel/RimGeoMechView.cpp | 42 +----- .../ProjectDataModel/RimGeoMechView.h | 3 +- .../ProjectDataModel/RimIntersection.cpp | 26 ++++ .../ProjectDataModel/RimIntersection.h | 2 + .../UserInterface/RiuMainWindow.cpp | 33 ++--- 17 files changed, 335 insertions(+), 179 deletions(-) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index b97518ca4b..2ad5593af2 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -42,20 +42,6 @@ bool RicNewIntersectionViewFeature::isCommandEnabled() return !objects.empty(); } -Rim2dIntersectionView* correspondingIntersectionView(RimIntersection* intersection) -{ - std::vector objects; - - intersection->objectsWithReferringPtrFields(objects); - Rim2dIntersectionView* isectView = nullptr; - for (auto obj : objects) - { - isectView = dynamic_cast(obj); - if (isectView) break; - } - return isectView; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -81,7 +67,7 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text); } - Rim2dIntersectionView* intersectionView = correspondingIntersectionView(intersection); + Rim2dIntersectionView* intersectionView = intersection->correspondingIntersectionView(); intersectionView->setVisible(true); intersectionView->loadDataAndUpdate(); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index f6ff7b167d..8a361e4e3f 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -34,22 +34,27 @@ #include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapper.h" +#include "cvfRay.h" //-------------------------------------------------------------------------------------------------- -/// +/// isFlattened means to transform each flat section of the intersection onto the XZ plane +/// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge //-------------------------------------------------------------------------------------------------- RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersection* crossSection, std::vector > &polylines, const cvf::Vec3d& extrusionDirection, - const RivIntersectionHexGridInterface* grid) + const RivIntersectionHexGridInterface* grid, + bool isFlattened) : m_crossSection(crossSection), m_polyLines(polylines), m_extrusionDirection(extrusionDirection), - m_hexGrid(grid) + m_hexGrid(grid), + m_isFlattened(isFlattened) { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; + if (m_isFlattened) m_extrusionDirection = -cvf::Vec3d::Z_AXIS; } //-------------------------------------------------------------------------------------------------- @@ -60,6 +65,41 @@ RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator() } +//-------------------------------------------------------------------------------------------------- +/// Origo in the intersection of the ray P1-ExtrDir with the XY plane +/// Ez in upwards extrusionDir +/// Ey normal tio the section pplane +/// Ex in plane along p1-p2 +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir) +{ + using namespace cvf; + + Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; + + Vec3d sectionLineDir = p2 - p1; + sectionLineDir.normalize(); + + Vec3d Ey = Ez ^ sectionLineDir; + Vec3d Ex = Ey ^ Ez; + + Ray extrusionRay; + extrusionRay.setOrigin(p1); + + if (p1.z() > 0) extrusionRay.setDirection(-Ez); + else extrusionRay.setDirection(Ez); + + + Vec3d tr(Vec3d::ZERO); + extrusionRay.planeIntersect(Plane(0.0, 0.0 , 1.0, 0.0), &tr); + + return Mat4d(Ex[0], Ey[0], Ez[0], tr[0], + Ex[1], Ey[1], Ez[1], tr[1], + Ex[2], Ey[2], Ez[2], tr[2], + 0.0, 0.0, 0.0, 1.0); +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -73,6 +113,9 @@ void RivIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); + double previousSectionFlattenedEndPosX = 0.0; + cvf::Vec3d previousSectionOrigo(cvf::Vec3d::ZERO); + for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx) { const std::vector& m_polyLine = m_polyLines[pLineIdx]; @@ -88,6 +131,11 @@ void RivIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d p1 = m_adjustedPolyline[lIdx]; cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1]; + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, m_extrusionDirection); + if (pLineIdx == 0 && lIdx == 0) previousSectionOrigo = sectionLocalCS.translation(); + previousSectionFlattenedEndPosX += (sectionLocalCS.translation() - previousSectionOrigo).length(); + previousSectionOrigo = sectionLocalCS.translation(); + cvf::BoundingBox sectionBBox; sectionBBox.add(p1); sectionBBox.add(p2); @@ -196,8 +244,12 @@ void RivIntersectionGeometryGenerator::calculateArrays() std::vector clippedTriangleVxes; std::vector isClippedTriEdgeCellContour; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, - &clippedTriangleVxes, &isClippedTriEdgeCellContour); + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, + isTriangleEdgeCellContour, + p1Plane, + p2Plane, + &clippedTriangleVxes, + &isClippedTriEdgeCellContour); size_t clippedTriangleCount = clippedTriangleVxes.size()/3; @@ -206,32 +258,47 @@ void RivIntersectionGeometryGenerator::calculateArrays() uint triVxIdx = tIdx*3; // Accumulate triangle vertices + cvf::Vec3d p0(clippedTriangleVxes[triVxIdx+0].vx); + cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx); + cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx); - cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset); - cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset); - cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset); + if (m_isFlattened) + { + cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); + cvf::Vec3d flattenedTranslation(previousSectionFlattenedEndPosX, 0.0,0.0); - triangleVertices.push_back(p0); - triangleVertices.push_back(p1); - triangleVertices.push_back(p2); + p0 = p0.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; + p1 = p1.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; + p2 = p2.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; + } + else + { + p0 -= displayOffset; + p1 -= displayOffset; + p2 -= displayOffset; + } + + triangleVertices.emplace_back(p0); + triangleVertices.emplace_back(p1); + triangleVertices.emplace_back(p2); // Accumulate mesh lines if (isClippedTriEdgeCellContour[triVxIdx]) { - cellBorderLineVxes.push_back(p0); - cellBorderLineVxes.push_back(p1); + cellBorderLineVxes.emplace_back(p0); + cellBorderLineVxes.emplace_back(p1); } if (isClippedTriEdgeCellContour[triVxIdx+1]) { - cellBorderLineVxes.push_back(p1); - cellBorderLineVxes.push_back(p2); + cellBorderLineVxes.emplace_back(p1); + cellBorderLineVxes.emplace_back(p2); } if (isClippedTriEdgeCellContour[triVxIdx+2]) { - cellBorderLineVxes.push_back(p2); - cellBorderLineVxes.push_back(p0); + cellBorderLineVxes.emplace_back(p2); + cellBorderLineVxes.emplace_back(p0); } // Mapping to cell index @@ -267,7 +334,6 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_cellBorderLineVxes->assign(cellBorderLineVxes); } - //-------------------------------------------------------------------------------------------------- /// Generate surface drawable geo from the specified region /// diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 28b8cdbdbd..17ee66a49b 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -49,7 +49,8 @@ class RivIntersectionGeometryGenerator : public cvf::Object RivIntersectionGeometryGenerator(RimIntersection* crossSection, std::vector > &polylines, const cvf::Vec3d& extrusionDirection, - const RivIntersectionHexGridInterface* grid ); + const RivIntersectionHexGridInterface* grid, + bool isFlattened ); ~RivIntersectionGeometryGenerator(); @@ -81,6 +82,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object cvf::cref m_hexGrid; const std::vector > m_polyLines; cvf::Vec3d m_extrusionDirection; + bool m_isFlattened; // Output arrays cvf::ref m_triangleVxes; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 5d7b017840..445bf3c63e 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -63,9 +63,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection) +RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened) : m_rimCrossSection(rimCrossSection), - m_defaultColor(cvf::Color3::WHITE) + m_defaultColor(cvf::Color3::WHITE), + m_isFlattened(isFlattened) { CVF_ASSERT(m_rimCrossSection); @@ -790,6 +791,14 @@ void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* mod } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimIntersection* RivIntersectionPartMgr::intersection() const +{ + return m_rimCrossSection.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -800,7 +809,7 @@ void RivIntersectionPartMgr::computeData() { cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); cvf::ref hexGrid = createHexGridInterface(); - m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p()); + m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p(), m_isFlattened); } } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 14cb3be11b..f1bd98d5c6 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -24,6 +24,7 @@ #include "cvfColor4.h" #include "cvfVector3.h" #include "cvfArray.h" +#include "cafPdmPointer.h" namespace cvf @@ -55,7 +56,7 @@ class RivIntersectionVertexWeights; class RivIntersectionPartMgr : public cvf::Object { public: - explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection); + explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false); void applySingleColorEffect(); void updateCellResultColor(size_t timeStepIndex); @@ -64,6 +65,8 @@ class RivIntersectionPartMgr : public cvf::Object void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + + const RimIntersection* intersection() const; private: void updatePartEffect(); @@ -105,10 +108,10 @@ class RivIntersectionPartMgr : public cvf::Object const RigFemResultAddress& resVarAddress, const cvf::ScalarMapper* mapper); - cvf::ref createHexGridInterface(); private: + cvf::ref createHexGridInterface(); - RimIntersection* m_rimCrossSection; + caf::PdmPointer m_rimCrossSection; cvf::Color3f m_defaultColor; @@ -122,5 +125,7 @@ class RivIntersectionPartMgr : public cvf::Object cvf::ref m_highlightLineAlongExtrusionDir; cvf::ref m_highlightPointsForExtrusionDir; + + bool m_isFlattened; }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index a2123ea6a3..168e62d026 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -28,6 +28,12 @@ #include "cvfModelBasicList.h" #include "cvfTransform.h" #include "cvfScene.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCellColors.h" + +#include CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); @@ -44,6 +50,16 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; + hasUserRequestedAnimation = true; + + isPerspectiveView = false; + cvf::Mat4d mx( 1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 100, + 0, 0, 0, 1); + + ((RiuViewerToViewInterface*)this)->setCameraPosition(mx ); + disableGridBox(); } //-------------------------------------------------------------------------------------------------- @@ -67,10 +83,14 @@ void Rim2dIntersectionView::setVisible(bool isVisible) //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) { + CAF_ASSERT(intersection); + m_intersection = intersection; Rim3dView * parentView = nullptr; intersection->firstAncestorOrThisOfTypeAsserted(parentView); name = parentView->name() + ": " + intersection->name(); + + } //-------------------------------------------------------------------------------------------------- @@ -96,6 +116,7 @@ bool Rim2dIntersectionView::isUsingFormationNames() const //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::scheduleGeometryRegen(RivCellSetEnum geometryType) { + m_flatIntersectionPartMgr = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -109,6 +130,21 @@ RimCase* Rim2dIntersectionView::ownerCase() const } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isTimeStepDependentDataVisible() const +{ + if ( m_intersection() ) + { + RimGridView * gridView = nullptr; + m_intersection->firstAncestorOrThisOfTypeAsserted(gridView); + return gridView->isTimeStepDependentDataVisible(); + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -116,19 +152,45 @@ QList Rim2dIntersectionView::calculateValueOptions(const bool* useOptionsOnly) { QList options; - if (fieldNeedingOptions == &m_intersection) + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::hasResults() +{ + if (!m_intersection()) return false; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView) { - std::vector intersections; - - this->ownerCase()->descendantsIncludingThisOfType(intersections); - - for (auto intersection : intersections) - { - options.push_back(caf::PdmOptionItemInfo(intersection->name(), intersection)); - } + return (eclView->cellResult()->hasResult() || eclView->cellResult()->isTernarySaturationSelected()); } - return options; + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView) + { + return geoView->cellResult()->hasResult(); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int Rim2dIntersectionView::timeStepCount() +{ + if ( isTimeStepDependentDataVisible() ) + { + return static_cast( this->ownerCase()->timeStepDates().size()); + } + + return 0; } //-------------------------------------------------------------------------------------------------- @@ -163,14 +225,37 @@ void Rim2dIntersectionView::createDisplayModel() { if (m_viewer.isNull()) return; if (!m_intersection()) return; - + + updateScaleTransform(); + + m_viewer->removeAllFrames(); + + int tsCount = this->timeStepCount(); + + for (int i = 0; i < tsCount; ++i) + { + m_viewer->addFrame(new cvf::Scene()); + } + + + if ( m_flatIntersectionPartMgr.isNull() || m_intersection() != m_flatIntersectionPartMgr->intersection()) + { + m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true); + } + m_intersectionVizModel->removeAllParts(); - m_intersection()->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); - m_intersection()->intersectionPartMgr()->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + + m_flatIntersectionPartMgr->applySingleColorEffect(); m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); + if ( this->hasUserRequestedAnimation() ) + { + m_viewer->setCurrentFrame(m_currentTimeStep); + } } //-------------------------------------------------------------------------------------------------- @@ -180,13 +265,6 @@ void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::CollectionhasUserRequestedAnimation() && this->hasResults())) + { + m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep); + } + else + { + m_flatIntersectionPartMgr->applySingleColorEffect(); + } } //-------------------------------------------------------------------------------------------------- @@ -242,7 +328,10 @@ cvf::Transform* Rim2dIntersectionView::scaleTransform() void Rim2dIntersectionView::resetLegendsInViewer() { m_viewer->showAxisCross(false); - m_viewer->showAnimationProgress(false); + m_viewer->showAnimationProgress(true); + m_viewer->showHistogram(false); + m_viewer->showInfoText(false); + m_viewer->setMainScene(new cvf::Scene()); } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 4516ebaec4..98da585f17 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -22,6 +22,7 @@ #include "cafPdmPtrField.h" class RimIntersection; +class RivIntersectionPartMgr; namespace cvf { @@ -51,13 +52,13 @@ class Rim2dIntersectionView : public Rim3dView virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } virtual RimViewController* viewController() const override { return nullptr; } -protected: + virtual bool isTimeStepDependentDataVisible() const override; +protected: virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; virtual void createDisplayModel() override; virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; - virtual void updateDisplayModelVisibility() override; virtual void clampCurrentTimestep() override; virtual void updateCurrentTimeStep() override; virtual void onTimeStepChanged() override; @@ -72,8 +73,12 @@ class Rim2dIntersectionView : public Rim3dView virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + bool hasResults(); + int timeStepCount(); + caf::PdmPtrField m_intersection; + cvf::ref m_flatIntersectionPartMgr; cvf::ref m_intersectionVizModel; cvf::ref m_scaleTransform; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index fa91a0780e..f9c6e7cf26 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -35,7 +35,6 @@ Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection() CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png", "", ""); m_intersectionViews.uiCapability()->setUiTreeHidden(true); - //m_intersectionViews.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present. } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index ccfd7c3189..b7dbbee695 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -113,7 +113,7 @@ Rim3dView::Rim3dView(void) CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", ""); CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", ""); - CAF_PDM_InitField(&showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); + CAF_PDM_InitField(&m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); @@ -234,7 +234,7 @@ void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrd caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); viewGroup->add(&name); viewGroup->add(&m_backgroundColor); - viewGroup->add(&showGridBox); + viewGroup->add(&m_showGridBox); viewGroup->add(&isPerspectiveView); viewGroup->add(&m_disableLighting); @@ -572,7 +572,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const RiuMainWindow::instance()->refreshDrawStyleActions(); RiuMainWindow::instance()->refreshAnimationActions(); } - else if (changedField == &showGridBox) + else if (changedField == &m_showGridBox) { createHighlightAndGridBoxDisplayModelWithRedraw(); } @@ -761,7 +761,48 @@ void Rim3dView::createHighlightAndGridBoxDisplayModel() m_viewer->addStaticModelOnce(m_highlightVizModel.p()); } - m_viewer->showGridBox(showGridBox()); + m_viewer->showGridBox(m_showGridBox()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::updateDisplayModelVisibility() +{ + if (m_viewer.isNull()) return; + + const cvf::uint uintSurfaceBit = surfaceBit; + const cvf::uint uintMeshSurfaceBit = meshSurfaceBit; + const cvf::uint uintFaultBit = faultBit; + const cvf::uint uintMeshFaultBit = meshFaultBit; + + // Initialize the mask to show everything except the the bits controlled here + unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ; + + // Then turn the appropriate bits on according to the user settings + + if (surfaceMode == SURFACE) + { + mask |= uintSurfaceBit; + mask |= uintFaultBit; + } + else if (surfaceMode == FAULTS) + { + mask |= uintFaultBit; + } + + if (meshMode == FULL_MESH) + { + mask |= uintMeshSurfaceBit; + mask |= uintMeshFaultBit; + } + else if (meshMode == FAULTS_MESH) + { + mask |= uintMeshFaultBit; + } + + m_viewer->setEnableMask(mask); + m_viewer->update(); } //-------------------------------------------------------------------------------------------------- @@ -819,6 +860,14 @@ void Rim3dView::forceShowWindowOn() m_showWindow.setValueWithFieldChanged(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::disableGridBox() +{ + m_showGridBox = false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index c976092bea..5aa6f4a69b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -66,6 +66,17 @@ namespace caf { class DisplayCoordTransform; } + + +enum PartRenderMaskEnum +{ + surfaceBit = 0x00000001, + meshSurfaceBit = 0x00000002, + faultBit = 0x00000004, + meshFaultBit = 0x00000008, +}; + + //================================================================================================== /// /// @@ -118,6 +129,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface int currentTimeStep() const { return m_currentTimeStep;} void setCurrentTimeStep(int frameIdx); void setCurrentTimeStepAndUpdate(int frameIdx) override; + virtual bool isTimeStepDependentDataVisible() const = 0; // Updating void updateCurrentTimeStepAndRedraw() override; @@ -135,7 +147,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual RimCase* ownerCase() const = 0; protected: - void setDefaultView(); + virtual void setDefaultView(); + void disableGridBox(); RimWellPathCollection* wellPathCollection(); void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, @@ -153,7 +166,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual void createDisplayModel() = 0; virtual void createPartCollectionFromSelection(cvf::Collection* parts) = 0; - virtual void updateDisplayModelVisibility() = 0; + virtual void updateDisplayModelVisibility(); virtual void clampCurrentTimestep() = 0; virtual void updateCurrentTimeStep() = 0; @@ -209,6 +222,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface caf::PdmField m_cameraPosition; caf::PdmField m_cameraPointOfInterest; caf::PdmField< cvf::Color3f > m_backgroundColor; - caf::PdmField showGridBox; + caf::PdmField m_showGridBox; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 81f91d2a5d..a04119f33f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -875,40 +875,7 @@ void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType) //-------------------------------------------------------------------------------------------------- void RimEclipseView::updateDisplayModelVisibility() { - if (m_viewer.isNull()) return; - - const cvf::uint uintSurfaceBit = surfaceBit; - const cvf::uint uintMeshSurfaceBit = meshSurfaceBit; - const cvf::uint uintFaultBit = faultBit; - const cvf::uint uintMeshFaultBit = meshFaultBit; - - // Initialize the mask to show everything except the the bits controlled here - unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ; - - // Then turn the appropriate bits on according to the user settings - - if (surfaceMode == SURFACE) - { - mask |= uintSurfaceBit; - mask |= uintFaultBit; - } - else if (surfaceMode == FAULTS) - { - mask |= uintFaultBit; - } - - if (meshMode == FULL_MESH) - { - mask |= uintMeshSurfaceBit; - mask |= uintMeshFaultBit; - } - else if (meshMode == FAULTS_MESH) - { - mask |= uintMeshFaultBit; - } - - m_viewer->setEnableMask(mask); - m_viewer->update(); + Rim3dView::updateDisplayModelVisibility(); faultCollection->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 5e661a3ac6..7503f1a73b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -69,14 +69,6 @@ namespace cvf class OverlayItem; } -enum PartRenderMaskEnum -{ - surfaceBit = 0x00000001, - meshSurfaceBit = 0x00000002, - faultBit = 0x00000004, - meshFaultBit = 0x00000008, -}; - //================================================================================================== /// /// diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index f7e85526f9..c0cf4e57f5 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -317,46 +317,6 @@ void RimGeoMechView::updateStaticCellColors() m_vizLogic->updateStaticCellColors(-1); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechView::updateDisplayModelVisibility() -{ - if (m_viewer.isNull()) return; - - const cvf::uint uintSurfaceBit = surfaceBit; - const cvf::uint uintMeshSurfaceBit = meshSurfaceBit; - const cvf::uint uintFaultBit = faultBit; - const cvf::uint uintMeshFaultBit = meshFaultBit; - - // Initialize the mask to show everything except the the bits controlled here - unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ; - - // Then turn the appropriate bits on according to the user settings - - if (surfaceMode == SURFACE) - { - mask |= uintSurfaceBit; - mask |= uintFaultBit; - } - else if (surfaceMode == FAULTS) - { - mask |= uintFaultBit; - } - - if (meshMode == FULL_MESH) - { - mask |= uintMeshSurfaceBit; - mask |= uintMeshFaultBit; - } - else if (meshMode == FAULTS_MESH) - { - mask |= uintMeshFaultBit; - } - - m_viewer->setEnableMask(mask); - m_viewer->update(); -} //-------------------------------------------------------------------------------------------------- /// @@ -477,7 +437,7 @@ void RimGeoMechView::clampCurrentTimestep() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimGeoMechView::isTimeStepDependentDataVisible() +bool RimGeoMechView::isTimeStepDependentDataVisible() const { return this->hasUserRequestedAnimation() && (this->cellResult()->hasResult() || this->geoMechPropertyFilterCollection()->hasActiveFilters()); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 1fda4ecb78..92b9d2b4e1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -72,7 +72,7 @@ class RimGeoMechView : public RimGridView const RimGeoMechPropertyFilterCollection* geoMechPropertyFilterCollection() const; void setOverridePropertyFilterCollection(RimGeoMechPropertyFilterCollection* pfc); - bool isTimeStepDependentDataVisible(); + bool isTimeStepDependentDataVisible() const override ; virtual cvf::Transform* scaleTransform() override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; @@ -92,7 +92,6 @@ class RimGeoMechView : public RimGridView private: virtual void createDisplayModel() override; - virtual void updateDisplayModelVisibility() override; virtual void updateScaleTransform() override; virtual void clampCurrentTimestep() override; diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index c7bc4f3c29..7755774eed 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -47,6 +47,7 @@ #include "cvfBoundingBox.h" #include "cvfGeometryTools.h" #include "cvfPlane.h" +#include "Rim2dIntersectionView.h" namespace caf { @@ -723,6 +724,24 @@ void RimIntersection::appendPointToPolyLine(const cvf::Vec3d& point) rebuildGeometryAndScheduleCreateDisplayModel(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* RimIntersection::correspondingIntersectionView() +{ + std::vector objects; + + this->objectsWithReferringPtrFields(objects); + Rim2dIntersectionView* isectView = nullptr; + for (auto obj : objects) + { + isectView = dynamic_cast(obj); + if (isectView) break; + } + return isectView; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -851,6 +870,13 @@ void RimIntersection::rebuildGeometryAndScheduleCreateDisplayModel() { rimView->scheduleCreateDisplayModelAndRedraw(); } + + Rim2dIntersectionView * iview = correspondingIntersectionView(); + if (iview) + { + iview->scheduleGeometryRegen(RivCellSetEnum::ALL_CELLS); + iview->scheduleCreateDisplayModelAndRedraw(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 9de727ec40..80b72836bc 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -33,6 +33,7 @@ class RimWellPath; class RivIntersectionPartMgr; class RimSimWellInView; class RimSimWellInViewCollection; +class Rim2dIntersectionView; namespace caf { @@ -86,6 +87,7 @@ class RimIntersection : public caf::PdmObject std::vector< std::vector > polyLines() const; void appendPointToPolyLine(const cvf::Vec3d& point); + Rim2dIntersectionView* correspondingIntersectionView(); RivIntersectionPartMgr* intersectionPartMgr(); std::vector< std::vector > polyLinesForExtrusionDirection() const; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 31b2b2b8f6..3af5d819a3 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -742,9 +742,11 @@ void RiuMainWindow::slotRefreshViewActions() void RiuMainWindow::refreshAnimationActions() { caf::FrameAnimationControl* animationControl = NULL; - if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); + + if (activeView && activeView->viewer()) { - animationControl = RiaApplication::instance()->activeReservoirView()->viewer()->animationControl(); + animationControl = activeView->viewer()->animationControl(); } m_animationToolBar->connectAnimationControl(animationControl); @@ -754,37 +756,22 @@ void RiuMainWindow::refreshAnimationActions() int currentTimeStepIndex = 0; bool enableAnimControls = false; - Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && activeView->viewer() && activeView->viewer()->frameCount()) { enableAnimControls = true; - RimEclipseView * activeRiv = dynamic_cast(activeView); - - if (activeRiv) + + if ( activeView->isTimeStepDependentDataVisible() ) { - if (activeRiv->currentGridCellResults()) - { - if (activeRiv->isTimeStepDependentDataVisible()) - { - timeStepStrings = activeRiv->eclipseCase()->timeStepStrings(); - } - else - { - timeStepStrings.push_back(tr("Static Property")); - } - } + timeStepStrings = activeView->ownerCase()->timeStepStrings(); } else { - RimGeoMechView * activeGmv = dynamic_cast(activeView); - if (activeGmv) + RimEclipseView * activeRiv = dynamic_cast(activeView); + if ( activeRiv->currentGridCellResults() ) { - if (activeGmv->isTimeStepDependentDataVisible()) - { - timeStepStrings = activeGmv->geoMechCase()->timeStepStrings(); - } + timeStepStrings.push_back(tr("Static Property")); } } From d8d2076deaa2c1d86c456e6b3a5edba67efda63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 08:40:47 +0100 Subject: [PATCH 0146/1027] #2333 New Intersection View: Update vertical warningtext. Avoid selecting view in tree. --- .../RicNewIntersectionViewFeature.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index 2ad5593af2..2e947eb41d 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -30,6 +30,9 @@ #include #include +#include "RiuViewer.h" +#include "cvfCamera.h" + CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); //-------------------------------------------------------------------------------------------------- @@ -61,8 +64,8 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) { if (intersection->direction() != RimIntersection::CS_VERTICAL) { - QString text = QString("Intersection '%1' is not a vertical intersection. The intersection view supports" - "only vertical intersections.").arg(intersection->name()); + QString text = QString("The intersection view only supports vertical intersections.\n" + "The intersection '%1' is not vertical but a converted version will be shown in the view .").arg(intersection->name()); QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text); } @@ -79,7 +82,7 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) if (objectToSelect) { - RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); + //RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); } } From 1de088ccbaa81eda561e344da17649d8f20762e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 08:41:44 +0100 Subject: [PATCH 0147/1027] #2333 Intersection View: Made default view and near/far clip planes behave --- .../Rim2dIntersectionView.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 168e62d026..09c144a97b 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -37,6 +37,11 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); +const cvf::Mat4d defaultIntersectinoViewMatrix(1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 1000, + 0, 0, 0, 1); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -53,12 +58,7 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) hasUserRequestedAnimation = true; isPerspectiveView = false; - cvf::Mat4d mx( 1, 0, 0, 0, - 0, 0, 1, 0, - 0, -1, 0, 100, - 0, 0, 0, 1); - - ((RiuViewerToViewInterface*)this)->setCameraPosition(mx ); + ((RiuViewerToViewInterface*)this)->setCameraPosition(defaultIntersectinoViewMatrix ); disableGridBox(); } @@ -251,11 +251,18 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->applySingleColorEffect(); m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); + + m_intersectionVizModel->updateBoundingBoxesRecursive(); if ( this->hasUserRequestedAnimation() ) { m_viewer->setCurrentFrame(m_currentTimeStep); } + + if ( this->viewer()->mainCamera()->viewMatrix() == defaultIntersectinoViewMatrix ) + { + this->zoomAll(); + } } //-------------------------------------------------------------------------------------------------- From c7185649ce3573e617c64b14b3c5c42d6046d681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 11:15:32 +0100 Subject: [PATCH 0148/1027] Caf: Guard against crash when point of interest is not set correctly --- Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp index 519b5d8534..48c9be65f5 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp @@ -190,7 +190,7 @@ cvf::ref caf::TrackBallBasedNavigation::createZoomRay(int cvfXPos, int cvf::Camera* cam = m_viewer->mainCamera(); ray = cam->rayFromWindowCoordinates(cvfXPos, cvfYPos); - if (cam->projection() == cvf::Camera::ORTHO) + if (ray.notNull() && cam->projection() == cvf::Camera::ORTHO) { cvf::Vec3d camDir = cam->direction(); cvf::Plane focusPlane; From 369afcfbbbf110f486947a25bb4cde3a287cd7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 11:16:03 +0100 Subject: [PATCH 0149/1027] Caf: Set point of interes when doing "Zoom All" --- Fwk/AppFwk/cafViewer/cafViewer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafViewer/cafViewer.cpp b/Fwk/AppFwk/cafViewer/cafViewer.cpp index c872596b77..5ec746ebe9 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.cpp +++ b/Fwk/AppFwk/cafViewer/cafViewer.cpp @@ -676,9 +676,11 @@ void caf::Viewer::zoomAll() cvf::Vec3d newEye = m_mainCamera->computeFitViewEyePosition(bb, vrp-eye, up, 0.9, m_cameraFieldOfViewYDeg, m_mainCamera->viewport()->aspectRatio()); m_mainCamera->setFromLookAt(newEye, bb.center(), up); - + updateParallelProjectionHeightFromMoveZoom(bb.center()); + if (m_navigationPolicy.notNull()) m_navigationPolicy->setPointOfInterest(bb.center()); + navigationPolicyUpdate(); } From b1bbbc2aeb0e93418afdb765bf0890b7411858ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 14:31:05 +0100 Subject: [PATCH 0150/1027] Ignore the Resinsight generated index files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9ce453e6f7..ae1ef61545 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ Ankh.NoLoad /Resinsight_Host.files /Resinsight_Host.creator /Resinsight_Host.config +*.RESINSIGHT_IDX From 5640f91b68a5b69c6a63676253562190ee319309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 26 Jan 2018 14:33:32 +0100 Subject: [PATCH 0151/1027] #2412 2D Navigation only for Intersectino Views --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 1 + .../UserInterface/RiuCadNavigation.cpp | 2 +- .../UserInterface/RiuGeoQuestNavigation.cpp | 2 +- .../UserInterface/RiuRmsNavigation.cpp | 2 +- ApplicationCode/UserInterface/RiuViewer.cpp | 15 ++++++++++++++- ApplicationCode/UserInterface/RiuViewer.h | 2 ++ Fwk/AppFwk/cafViewer/cafCadNavigation.cpp | 2 +- Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp | 2 +- .../cafViewer/cafTrackBallBasedNavigation.cpp | 1 + .../cafViewer/cafTrackBallBasedNavigation.h | 3 +++ 10 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 09c144a97b..da58fa2922 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -340,6 +340,7 @@ void Rim2dIntersectionView::resetLegendsInViewer() m_viewer->showInfoText(false); m_viewer->setMainScene(new cvf::Scene()); + m_viewer->enableNavigationRotation(false); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.cpp b/ApplicationCode/UserInterface/RiuCadNavigation.cpp index 721b1ad323..d9f7cdf413 100644 --- a/ApplicationCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuCadNavigation.cpp @@ -59,7 +59,7 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier) + if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); diff --git a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp index 27112bb00d..e9eafe6e34 100644 --- a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -59,7 +59,7 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::LeftButton) + if (me->button() == Qt::LeftButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); diff --git a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp index 2e3e0faafd..1b80a97535 100644 --- a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp @@ -59,7 +59,7 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton) + if (me->button() == Qt::MidButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 4b986c0ef1..aca6e1eba7 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -79,7 +79,7 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1; /// //-------------------------------------------------------------------------------------------------- RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) -: caf::Viewer(format, parent) +: caf::Viewer(format, parent), m_isNavigationRotationEnabled(true) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont); @@ -589,6 +589,17 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::enableNavigationRotation(bool enable) +{ + auto tbNavPol = dynamic_cast(m_navigationPolicy.p()); + m_isNavigationRotationEnabled = enable; + + if (tbNavPol) tbNavPol->enableRotation(m_isNavigationRotationEnabled); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -616,6 +627,8 @@ void RiuViewer::updateNavigationPolicy() CVF_ASSERT(0); break; } + + enableNavigationRotation(m_isNavigationRotationEnabled); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 35a8b6926e..70545ae480 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -91,6 +91,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void removeAllColorLegends(); void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend); + void enableNavigationRotation(bool disable); void updateNavigationPolicy(); virtual void navigationPolicyUpdate(); // Override of caf::Viewer::navigationPolicyUpdate() @@ -156,5 +157,6 @@ public slots: RivGridBoxGenerator* m_gridBoxGenerator; cvf::Vec3d m_cursorPositionDomainCoords; + bool m_isNavigationRotationEnabled; }; diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index 9c56d13f07..ae4542ea73 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -77,7 +77,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier) + if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index 5a7bcd780e..ace62919f8 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -77,7 +77,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::RightButton) + if (me->button() == Qt::RightButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp index 48c9be65f5..7352ff7994 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp @@ -78,6 +78,7 @@ void caf::TrackBallBasedNavigation::init() m_trackball = new cvf::ManipulatorTrackball; m_trackball->setCamera(m_viewer->mainCamera()); m_isRotCenterInitialized = false; + m_isRotationEnabled = true; m_hasMovedMouseDuringNavigation = false; m_isNavigating = false; m_isZooming = false; diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h index 0157e48b4f..a27596fb12 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h @@ -59,6 +59,7 @@ class TrackBallBasedNavigation: public NavigationPolicy TrackBallBasedNavigation(); virtual ~TrackBallBasedNavigation(); void enableEventEating(bool enable) { m_consumeEvents = enable; } + void enableRotation(bool enable) { m_isRotationEnabled = enable; } protected: // General navigation policy overrides @@ -88,9 +89,11 @@ class TrackBallBasedNavigation: public NavigationPolicy int m_lastPosY; bool isSupposedToConsumeEvents() { return m_consumeEvents; } + bool isRotationEnabled() { return m_isRotationEnabled; } private: bool m_consumeEvents; + bool m_isRotationEnabled; }; } // End namespace caf From 1419865b89d4eeb1e40a4c52d8ca474b75edb34d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 26 Jan 2018 13:46:15 +0100 Subject: [PATCH 0152/1027] #2411 AppFwk : Increase precision when writing real numbers to XML --- .../cafInternalPdmXmlFieldReaderWriter.h | 5 + .../cafPdmXml_UnitTests/CMakeLists.txt | 1 + .../cafPdmXmlNumberTest.cpp | 110 ++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h index 8e5ddb8736..864294268f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h @@ -30,6 +30,11 @@ struct PdmFieldWriter { QString dataString; QTextStream data(&dataString, QIODevice::WriteOnly); + + // Use precision of 15 to cover most value ranges for double values + // Default Qt behavior is precision of 6 + data.setRealNumberPrecision(15); + data << fieldValue; xmlStream.writeCharacters(dataString); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt index 468c827c18..7a56128283 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable (${PROJECT_NAME} cafPdmXmlBasicTest.cpp cafPdmAdvancedTemplateTest.cpp + cafPdmXmlNumberTest.cpp ) message(STATUS ${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp new file mode 100644 index 0000000000..50f5db1294 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp @@ -0,0 +1,110 @@ + +#include "gtest/gtest.h" + +#include "cafPdmDataValueField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmXmlObjectHandle.h" +#include "cafPdmXmlObjectHandleMacros.h" + +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class SimpleObjectWithNumbers : public caf::PdmObjectHandle, public caf::PdmXmlObjectHandle +{ + CAF_PDM_XML_HEADER_INIT; + +public: + SimpleObjectWithNumbers() : PdmObjectHandle(), PdmXmlObjectHandle(this, false) + { + CAF_PDM_XML_InitField(&m_valueA, "ValueA"); + CAF_PDM_XML_InitField(&m_valueB, "ValueB"); + + CAF_PDM_XML_InitField(&m_floatValueA, "FloatValueA"); + CAF_PDM_XML_InitField(&m_floatValueB, "FloatValueB"); + } + + caf::PdmDataValueField m_valueA; + caf::PdmDataValueField m_valueB; + + caf::PdmDataValueField m_floatValueA; + caf::PdmDataValueField m_floatValueB; +}; +CAF_PDM_XML_SOURCE_INIT(SimpleObjectWithNumbers, "SimpleObjectWithNumbers"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(SerializeNumbers, SimpleObjectWithDoubleValues) +{ + double valueA = 0.123456789; + double valueB = 123456789 + valueA; + + QString objectAsText; + + { + SimpleObjectWithNumbers obj1; + + obj1.m_valueA = valueA; + obj1.m_valueB = valueB; + + objectAsText = obj1.writeObjectToXmlString(); + } + + { + SimpleObjectWithNumbers obj1; + + obj1.readObjectFromXmlString(objectAsText, caf::PdmDefaultObjectFactory::instance()); + + { + double epsilon = 1e-7; + + double diffA = fabs(obj1.m_valueA - valueA); + EXPECT_TRUE(diffA < epsilon); + } + + { + double epsilon = 3e-7; + + double diffB = fabs(obj1.m_valueB - valueB); + EXPECT_TRUE(diffB < epsilon); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(SerializeNumbers, SimpleObjectWithFloatValues) +{ + float valueA = 0.123456789; + float valueB = 123456 + valueA; + + QString objectAsText; + + { + SimpleObjectWithNumbers obj1; + + obj1.m_floatValueA = valueA; + obj1.m_floatValueB = valueB; + + objectAsText = obj1.writeObjectToXmlString(); + } + + { + SimpleObjectWithNumbers obj1; + + obj1.readObjectFromXmlString(objectAsText, caf::PdmDefaultObjectFactory::instance()); + + double epsilon = 1e-7; + + double diffA = fabs(obj1.m_floatValueA - valueA); + EXPECT_TRUE(diffA < epsilon); + + double diffB = fabs(obj1.m_floatValueB - valueB); + EXPECT_TRUE(diffB < epsilon); + } +} From 7c7a54f5aa14f334ea4bdec92c49baf0858b0341 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 26 Jan 2018 14:30:06 +0100 Subject: [PATCH 0153/1027] #2414 AppFwk : Do not overwrite field double value with UI text representation --- .../cafPdmUiDoubleSliderEditor.cpp | 28 ++++++++----------- .../cafPdmUiDoubleSliderEditor.h | 4 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index 9385044e88..f92ad6bc30 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -106,6 +106,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName) uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &m_attributes); } + double doubleValue = field()->uiValue().toDouble(); QString textValue = field()->uiValue().toString(); m_slider->blockSignals(true); @@ -118,7 +119,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName) m_lineEdit->setValidator(pdmValidator); m_lineEdit->setText(textValue); - updateSliderPosition(); + updateSliderPosition(doubleValue); } //-------------------------------------------------------------------------------------------------- @@ -161,9 +162,12 @@ QWidget* PdmUiDoubleSliderEditor::createLabelWidget(QWidget * parent) //-------------------------------------------------------------------------------------------------- void PdmUiDoubleSliderEditor::slotEditingFinished() { - updateSliderPosition(); + QString textValue = m_lineEdit->text(); + + double doubleVal = textValue.toDouble(); + doubleVal = qBound(m_attributes.m_minimum, doubleVal, m_attributes.m_maximum); - writeValueToField(); + writeValueToField(doubleVal); } //-------------------------------------------------------------------------------------------------- @@ -172,22 +176,16 @@ void PdmUiDoubleSliderEditor::slotEditingFinished() void PdmUiDoubleSliderEditor::slotSliderValueChanged(int value) { double newDoubleValue = convertFromSliderValue(value); - m_lineEdit->setText(QString::number(newDoubleValue)); - writeValueToField(); + writeValueToField(newDoubleValue); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiDoubleSliderEditor::updateSliderPosition() +void PdmUiDoubleSliderEditor::updateSliderPosition(double value) { - QString textValue = m_lineEdit->text(); - - bool convertOk = false; - double newSliderValue = textValue.toDouble(&convertOk); - - int newSliderPosition = convertToSliderValue(newSliderValue); + int newSliderPosition = convertToSliderValue(value); if (m_slider->value() != newSliderPosition) { m_slider->blockSignals(true); @@ -199,11 +197,9 @@ void PdmUiDoubleSliderEditor::updateSliderPosition() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiDoubleSliderEditor::writeValueToField() +void PdmUiDoubleSliderEditor::writeValueToField(double value) { - QString textValue = m_lineEdit->text(); - QVariant v; - v = textValue; + QVariant v = value; this->setValueToField(v); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h index dba27056c8..21b85bdd63 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h @@ -92,8 +92,8 @@ protected slots: void slotSliderValueChanged(int value); private: - void updateSliderPosition(); - void writeValueToField(); + void updateSliderPosition(double value); + void writeValueToField(double value); int convertToSliderValue(double value); double convertFromSliderValue(int sliderValue); From 22c49ebe371375d386dbc42a14b59911e192ab44 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 26 Jan 2018 14:50:15 +0100 Subject: [PATCH 0154/1027] #2414 AppFwk : Cleaned up includes --- .../cafUserInterface/cafPdmUiDoubleSliderEditor.cpp | 11 ++--------- .../cafUserInterface/cafPdmUiDoubleSliderEditor.h | 5 +++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index f92ad6bc30..a875ac4721 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -37,20 +37,13 @@ #include "cafPdmUiDoubleSliderEditor.h" -#include "cafPdmUiDefaultObjectEditor.h" -#include "cafPdmObject.h" -#include "cafPdmUiFieldEditorHandle.h" #include "cafPdmField.h" +#include "cafPdmUiFieldHandle.h" +#include "cafPdmUiObjectHandle.h" -#include "cafFactory.h" - -#include -#include #include #include -#include - //-------------------------------------------------------------------------------------------------- /// diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h index 21b85bdd63..a616831c9a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.h @@ -43,7 +43,6 @@ #include #include #include -#include #include @@ -53,7 +52,6 @@ namespace caf //================================================================================================== /// //================================================================================================== - class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute { public: @@ -73,6 +71,9 @@ class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute }; +//================================================================================================== +/// +//================================================================================================== class PdmUiDoubleSliderEditor : public PdmUiFieldEditorHandle { Q_OBJECT From e416d6557aac90c915a9f5c6254092615a2f1d55 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 29 Jan 2018 10:16:12 +0100 Subject: [PATCH 0155/1027] Add option to avoid updating parent plot --- ApplicationCode/ProjectDataModel/RimPlotCurve.cpp | 11 +++++++---- ApplicationCode/ProjectDataModel/RimPlotCurve.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 208c921970..d5a3f5d08f 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -135,7 +135,7 @@ void RimPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con { if (changedField == &m_showCurve) { - this->updateCurveVisibility(); + this->updateCurveVisibility(true); if (m_showCurve()) loadDataAndUpdate(true); } else if (changedField == &m_curveName) @@ -180,7 +180,7 @@ caf::PdmFieldHandle* RimPlotCurve::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateCurveVisibility() +void RimPlotCurve::updateCurveVisibility(bool updateParent) { bool isVisibleInPossibleParent = true; @@ -199,7 +199,10 @@ void RimPlotCurve::updateCurveVisibility() m_qwtPlotCurve->detach(); } - updateZoomInParentPlot(); + if (updateParent) + { + updateZoomInParentPlot(); + } } //-------------------------------------------------------------------------------------------------- @@ -207,7 +210,7 @@ void RimPlotCurve::updateCurveVisibility() //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateCurvePresentation(bool updatePlotLegend) { - this->updateCurveVisibility(); + this->updateCurveVisibility(updatePlotLegend); if (updatePlotLegend) { diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index ee58669c7e..f3c6126389 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -92,7 +92,7 @@ class RimPlotCurve : public caf::PdmObject QString curveName() const { return m_curveName; } - void updateCurveVisibility(); + void updateCurveVisibility(bool updateParent); void updateLegendEntryVisibilityAndPlotLegend(); void updateLegendEntryVisibilityNoPlotUpdate(); From 17e38130fcb9b1d65c2decd2451c5c6c661c9b66 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 29 Jan 2018 10:17:38 +0100 Subject: [PATCH 0156/1027] #2319 PLT/Well log plot: Remove auto scale on scroll. Make auto scale from file work --- .../ProjectDataModel/RimWellLogPlot.cpp | 27 ++++++++++++++----- .../ProjectDataModel/RimWellLogPlot.h | 2 ++ .../UserInterface/RiuWellLogPlot.cpp | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index cfe4e53150..9be63af1f9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -147,6 +147,14 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c { rftPlot->updateConnectedEditors(); } + + RimWellPltPlot* pltPlot(nullptr); + this->firstAncestorOrThisOfType(pltPlot); + + if (pltPlot) + { + pltPlot->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -294,6 +302,7 @@ void RimWellLogPlot::setDepthZoomByFactorAndCenter(double zoomFactor, double zoo double newMaximum = zoomCenter + (m_maxVisibleDepth - zoomCenter)*zoomFactor; setDepthZoomMinMax(newMinimum, newMaximum); + setDepthAutoZoom(false); } //-------------------------------------------------------------------------------------------------- @@ -303,6 +312,7 @@ void RimWellLogPlot::panDepth(double panFactor) { double delta = panFactor*(m_maxVisibleDepth - m_minVisibleDepth); setDepthZoomMinMax(m_minVisibleDepth + delta, m_maxVisibleDepth + delta); + setDepthAutoZoom(false); } //-------------------------------------------------------------------------------------------------- @@ -383,9 +393,7 @@ bool RimWellLogPlot::hasAvailableDepthRange() const //-------------------------------------------------------------------------------------------------- void RimWellLogPlot::zoomAll() { - m_isAutoScaleDepthEnabled = true; - m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors(); - + setDepthAutoZoom(true); updateDepthZoom(); } @@ -397,6 +405,15 @@ QWidget* RimWellLogPlot::viewWidget() return m_viewer; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlot::setDepthAutoZoom(bool on) +{ + m_isAutoScaleDepthEnabled = on; + m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -594,11 +611,7 @@ void RimWellLogPlot::onLoadDataAndUpdate() { updateMdiWindowVisibility(); - bool tempAutoScale = m_isAutoScaleDepthEnabled; - m_isAutoScaleDepthEnabled = false; updateTracks(); - - m_isAutoScaleDepthEnabled = tempAutoScale; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index b92ac0d402..da12f14bff 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -99,6 +99,8 @@ class RimWellLogPlot : public RimViewWindow virtual void zoomAll() override; virtual QWidget* viewWidget() override; + void setDepthAutoZoom(bool on); + QString asciiDataForPlotExport() const; diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index eaa8fb7819..34a3f8484d 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -264,6 +264,7 @@ void RiuWellLogPlot::slotSetMinDepth(int value) double delta = value - minimumDepth; m_plotDefinition->setDepthZoomMinMax(minimumDepth + delta, maximumDepth + delta); + m_plotDefinition->setDepthAutoZoom(false); } //-------------------------------------------------------------------------------------------------- From 27192e80966b02f3f2c671e35c2e3c4909c1247d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 29 Jan 2018 10:47:54 +0100 Subject: [PATCH 0157/1027] Rename variable --- ApplicationCode/ProjectDataModel/RimPlotCurve.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimPlotCurve.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index d5a3f5d08f..b856cc3633 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -180,7 +180,7 @@ caf::PdmFieldHandle* RimPlotCurve::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::updateCurveVisibility(bool updateParent) +void RimPlotCurve::updateCurveVisibility(bool updateParentPlot) { bool isVisibleInPossibleParent = true; @@ -199,7 +199,7 @@ void RimPlotCurve::updateCurveVisibility(bool updateParent) m_qwtPlotCurve->detach(); } - if (updateParent) + if (updateParentPlot) { updateZoomInParentPlot(); } diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index f3c6126389..0cd9c4495a 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -92,7 +92,7 @@ class RimPlotCurve : public caf::PdmObject QString curveName() const { return m_curveName; } - void updateCurveVisibility(bool updateParent); + void updateCurveVisibility(bool updateParentPlot); void updateLegendEntryVisibilityAndPlotLegend(); void updateLegendEntryVisibilityNoPlotUpdate(); From 20e5c2720968b5458f0437316613403b8e5b5298 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 29 Jan 2018 11:24:12 +0100 Subject: [PATCH 0158/1027] #2261 Well Paths: Change newestAddedWellPath to mostRecentlyUpdatedWellPath --- .../RicWellPathFormationsImportFileFeature.cpp | 2 +- .../RicWellPathsImportFileFeature.cpp | 2 +- .../ProjectDataModel/RimWellPathCollection.cpp | 15 ++++++--------- .../ProjectDataModel/RimWellPathCollection.h | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp index 71aeba0909..43bf2004ed 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp @@ -77,7 +77,7 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) if (oilField->wellPathCollection->wellPaths().size() > 0) { - RimWellPath* wellPath = oilField->wellPathCollection->newestAddedWellPath(); + RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { RiuMainWindow::instance()->selectAsCurrentItem(wellPath); diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp index bb8cbda1ae..3168992c9c 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp @@ -70,7 +70,7 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) if (oilField->wellPathCollection->wellPaths().size() > 0) { - RimWellPath* wellPath = oilField->wellPathCollection->newestAddedWellPath(); + RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { RiuMainWindow::instance()->selectAsCurrentItem(wellPath); diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 95d17ab4d8..6b0a745863 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -101,7 +101,7 @@ RimWellPathCollection::RimWellPathCollection() m_wellPathImporter = new RifWellPathImporter; m_wellPathFormationsImporter = new RifWellPathFormationsImporter; - m_newestAddedWellPath = nullptr; + m_mostRecentlyUpdatedWellPath = nullptr; } @@ -268,23 +268,20 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP // Let name from well path file override name from well log file existingWellPath->setName(wellPath->name()); + m_mostRecentlyUpdatedWellPath = existingWellPath; delete wellPath; } else { wellPath->wellPathColor = cvf::Color3f(interpolatedWellColors[wpIdx]); wellPath->setUnitSystem(findUnitSystemForWellPath(wellPath)); + m_mostRecentlyUpdatedWellPath = wellPath; wellPaths.push_back(wellPath); } progress.incrementProgress(); } - if (!wellPaths.empty()) - { - m_newestAddedWellPath = wellPaths[wellPaths.size() - 1]; - } - this->sortWellsByName(); } @@ -360,7 +357,7 @@ void RimWellPathCollection::addWellPathFormations(const QStringList& filePaths) QString wellFormationsCount = QString("%1").arg(it->second->formationNamesCount()); - m_newestAddedWellPath = wellPath; + m_mostRecentlyUpdatedWellPath = wellPath; outputMessage += it->first + "\t\t"; outputMessage += wellPath->name() + " \t\t\t"; @@ -520,9 +517,9 @@ void RimWellPathCollection::deleteAllWellPaths() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPath* RimWellPathCollection::newestAddedWellPath() +RimWellPath* RimWellPathCollection::mostRecentlyUpdatedWellPath() { - return m_newestAddedWellPath; + return m_mostRecentlyUpdatedWellPath; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index b798c2a689..a4b4c87479 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -93,7 +93,7 @@ class RimWellPathCollection : public caf::PdmObject void removeWellPath(RimWellPath* wellPath); void deleteAllWellPaths(); - RimWellPath* newestAddedWellPath(); + RimWellPath* mostRecentlyUpdatedWellPath(); void readWellPathFormationFiles(); void reloadAllWellPathFormations(); @@ -136,5 +136,5 @@ class RimWellPathCollection : public caf::PdmObject RifWellPathImporter* m_wellPathImporter; RifWellPathFormationsImporter* m_wellPathFormationsImporter; - caf::PdmPointer m_newestAddedWellPath; + caf::PdmPointer m_mostRecentlyUpdatedWellPath; }; From 065aa92d16f635e14a3059878df4c5358dac5c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 29 Jan 2018 11:23:21 +0100 Subject: [PATCH 0159/1027] #2408 summary plot. Update qwt axis when duplicating curves --- .../ProjectDataModel/Summary/RimSummaryCurveCollection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 28c4af2a5c..e8a7c4670e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -98,6 +98,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate(bool updateParentPlot) for (RimSummaryCurve* curve : m_curves) { curve->loadDataAndUpdate(false); + curve->updateQwtPlotAxis(); } if ( updateParentPlot ) From ebabefcd2c55542b82c2c7f21178fb546bc766b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 29 Jan 2018 12:46:10 +0100 Subject: [PATCH 0160/1027] #2368 summary plot. Fix right axis properties update issue --- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index d25812a444..7e13a3facd 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -140,7 +140,9 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte zoomWindow.setTop(leftAxis.maxValue()); zoomWindow.setBottom(leftAxis.minValue()); + m_zoomerLeft->blockSignals(true); m_zoomerLeft->zoom(zoomWindow); + m_zoomerLeft->blockSignals(false); } { @@ -150,8 +152,10 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte zoomWindow.setTop(rightAxis.maxValue()); zoomWindow.setBottom(rightAxis.minValue()); + // No need to block signal since there is no connected slot m_zoomerRight->zoom(zoomWindow); } + } //-------------------------------------------------------------------------------------------------- From 6dead054c4f0abfebf50c3bbbfe3d8ba4e683069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 29 Jan 2018 11:24:53 +0100 Subject: [PATCH 0161/1027] #2331 Save the 2D Intersection views. Turn off unneccesary fields --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 9 ++++++--- ApplicationCode/ProjectDataModel/Rim3dView.cpp | 14 +++++++++++++- ApplicationCode/ProjectDataModel/Rim3dView.h | 3 ++- ApplicationCode/ProjectDataModel/RimCase.cpp | 1 - 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index da58fa2922..537d94952c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -35,7 +35,7 @@ #include -CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); +CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); const cvf::Mat4d defaultIntersectinoViewMatrix(1, 0, 0, 0, 0, 0, 1, 0, @@ -55,11 +55,13 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; + hasUserRequestedAnimation = true; - isPerspectiveView = false; ((RiuViewerToViewInterface*)this)->setCameraPosition(defaultIntersectinoViewMatrix ); - disableGridBox(); + + disableGridBoxField(); + disablePerspectiveProjectionField(); } //-------------------------------------------------------------------------------------------------- @@ -257,6 +259,7 @@ void Rim2dIntersectionView::createDisplayModel() if ( this->hasUserRequestedAnimation() ) { m_viewer->setCurrentFrame(m_currentTimeStep); + updateCurrentTimeStep(); } if ( this->viewer()->mainCamera()->viewMatrix() == defaultIntersectinoViewMatrix ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index b7dbbee695..1aed74ce86 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -863,9 +863,21 @@ void Rim3dView::forceShowWindowOn() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dView::disableGridBox() +void Rim3dView::disableGridBoxField() { m_showGridBox = false; + m_showGridBox.uiCapability()->setUiHidden(true); + m_showGridBox.xmlCapability()->setIOWritable(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::disablePerspectiveProjectionField() +{ + isPerspectiveView = false; + isPerspectiveView.uiCapability()->setUiHidden(true); + isPerspectiveView.xmlCapability()->setIOWritable(false); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 5aa6f4a69b..06166f50b9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -148,7 +148,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface protected: virtual void setDefaultView(); - void disableGridBox(); + void disableGridBoxField(); + void disablePerspectiveProjectionField(); RimWellPathCollection* wellPathCollection(); void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 1d26e788c5..34b94d6fc2 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -55,7 +55,6 @@ RimCase::RimCase() : m_isInActiveDestruction(false) CAF_PDM_InitFieldNoDefault(&m_2dIntersectionViewCollection, "IntersectionViewCollection", "2D Intersection Views", ":/CrossSections16x16.png", "", ""); m_2dIntersectionViewCollection.uiCapability()->setUiTreeHidden(true); - m_2dIntersectionViewCollection.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present. m_2dIntersectionViewCollection = new Rim2dIntersectionViewCollection(); } From f931b9234185dac2338731d4a1c32bf142ce07a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 29 Jan 2018 12:23:30 +0100 Subject: [PATCH 0162/1027] #2412 Disable irrelevant toolbar commands --- .../Commands/RicTogglePerspectiveViewFeature.cpp | 4 ++-- ApplicationCode/UserInterface/RiuMainWindow.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp index 7e8fa7c21d..404c8a46bc 100644 --- a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp +++ b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFe bool RicTogglePerspectiveViewFeature::isCommandEnabled() { this->action(); // Retrieve the action to update the looks - return RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer(); + return RiaApplication::instance()->activeGridView() && RiaApplication::instance()->activeReservoirView()->viewer(); } //-------------------------------------------------------------------------------------------------- @@ -42,7 +42,7 @@ bool RicTogglePerspectiveViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicTogglePerspectiveViewFeature::onActionTriggered(bool isChecked) { - if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) + if(RiaApplication::instance()->activeGridView() && RiaApplication::instance()->activeReservoirView()->viewer()) { bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView(); RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 3af5d819a3..e4b1099b7e 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -723,7 +723,7 @@ void RiuMainWindow::slotRefreshEditActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotRefreshViewActions() { - bool enabled = true; + bool enabled = RiaApplication::instance()->activeGridView() != nullptr; m_viewFromNorth->setEnabled(enabled); m_viewFromSouth->setEnabled(enabled); m_viewFromEast->setEnabled(enabled); @@ -1445,6 +1445,7 @@ void RiuMainWindow::refreshDrawStyleActions() { Rim3dView* view = RiaApplication::instance()->activeReservoirView(); bool enable = view != NULL; + bool isGridView = RiaApplication::instance()->activeGridView() != nullptr; m_drawStyleLinesAction->setEnabled(enable); m_drawStyleLinesSolidAction->setEnabled(enable); @@ -1458,9 +1459,9 @@ void RiuMainWindow::refreshDrawStyleActions() m_disableLightingAction->setChecked(lightingDisabledInView); m_disableLightingAction->blockSignals(false); - if (enable) + m_drawStyleHideGridCellsAction->setEnabled(isGridView); + if (isGridView) { - m_drawStyleHideGridCellsAction->setEnabled(true); m_drawStyleHideGridCellsAction->blockSignals(true); m_drawStyleHideGridCellsAction->setChecked(!view->isGridVisualizationMode()); m_drawStyleHideGridCellsAction->blockSignals(false); From 287992df91bba5c7a7edac99cef671606194bc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 29 Jan 2018 12:41:55 +0100 Subject: [PATCH 0163/1027] #2331 Update Intersection View List when copying and deleting views --- .../RicPasteEclipseViewsFeature.cpp | 2 ++ ApplicationCode/Commands/RicDeleteItemExec.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index 5dac65253a..d5e8892ee3 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -28,6 +28,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" +#include "Rim2dIntersectionViewCollection.h" #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" @@ -102,6 +103,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked) rimReservoirView->resolveReferencesRecursively(); rimReservoirView->initAfterReadRecursively(); + eclipseCase->intersectionViewCollection()->syncFromExistingIntersections(false); rimReservoirView->loadDataAndUpdate(); caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView); diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 74e304a82f..8cb1531789 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -55,6 +55,7 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmUiFieldHandle.h" #include "cafSelectionManager.h" +#include "Rim2dIntersectionViewCollection.h" //-------------------------------------------------------------------------------------------------- @@ -132,6 +133,14 @@ void RicDeleteItemExec::redo() crossSectionColl->syncronize2dIntersectionViews(); view->scheduleCreateDisplayModelAndRedraw(); } + else + { + RimCase* parentCase = dynamic_cast(parentObj); + if ( parentCase ) // A view was deleted. Need to update the list of intersection views + { + parentCase->intersectionViewCollection()->syncFromExistingIntersections(true); + } + } // SimWell Fractures RimSimWellInView* simWell; From c9d6d6093108ba4c8b8849c762fb8e0318b5f0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 29 Jan 2018 16:14:11 +0100 Subject: [PATCH 0164/1027] #2331 GeoMech fixes for intersection view. Paste view and animation of synthetic cases. --- .../RicPasteGeoMechViewsFeature.cpp | 2 ++ ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp index cf1b63151f..a95f02ca72 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp @@ -31,6 +31,7 @@ #include "cafSelectionManager.h" #include +#include "Rim2dIntersectionViewCollection.h" CAF_CMD_SOURCE_INIT(RicPasteGeoMechViewsFeature, "RicPasteGeoMechViewsFeature"); @@ -98,6 +99,7 @@ void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked) rimReservoirView->loadDataAndUpdate(); + geomCase->intersectionViewCollection()->syncFromExistingIntersections(false); geomCase->updateConnectedEditors(); lastViewCopy = rimReservoirView; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 537d94952c..8962e28ed2 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -189,7 +189,7 @@ int Rim2dIntersectionView::timeStepCount() { if ( isTimeStepDependentDataVisible() ) { - return static_cast( this->ownerCase()->timeStepDates().size()); + return static_cast( this->ownerCase()->timeStepStrings().size()); } return 0; From d5c1e1e898748ab76f2abfbf2bb7e101e9142bf8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 29 Jan 2018 12:22:59 +0100 Subject: [PATCH 0165/1027] #1758 Moved implementation to source and improved formatting --- .../ReservoirDataModel/RigCompletionData.cpp | 128 ++++++++++++++++++ .../ReservoirDataModel/RigCompletionData.h | 80 +++++------ 2 files changed, 168 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 030cfd857a..805a0f1183 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -212,6 +212,134 @@ bool RigCompletionData::isDefaultValue(double val) return val == HUGE_VAL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigCompletionData::metadata() const +{ + return m_metadata; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RigCompletionData::wellName() const +{ + return m_wellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const IJKCellIndex& RigCompletionData::cellIndex() const +{ + return m_cellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +WellConnectionState RigCompletionData::connectionState() const +{ + return m_connectionState; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::saturation() const +{ + return m_saturation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::transmissibility() const +{ + return m_transmissibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::diameter() const +{ + return m_diameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::kh() const +{ + return m_kh; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::skinFactor() const +{ + return m_skinFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::dFactor() const +{ + return m_dFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CellDirection RigCompletionData::direction() const +{ + return m_direction; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionData::count() const +{ + return m_count; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::wpimult() const +{ + return m_wpimult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionData::CompletionType RigCompletionData::completionType() const +{ + return m_completionType; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionData::isMainBore() const +{ + return m_isMainBore; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionData::readyForExport() const +{ + return m_readyForExport; +} + //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index 98eb42e893..db398c9fb5 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -105,46 +105,46 @@ class RigCompletionData bool operator<(const RigCompletionData& other) const; RigCompletionData& operator=(const RigCompletionData& other); - void setFromFracture(double transmissibility, double skinFactor); - - void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, - double skinFactor, - double diameter, - CellDirection direction, - bool isMainBore); - - void setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, - double skinFactor, - double diameter, - CellDirection direction); - - void setCombinedValuesExplicitTrans(double transmissibility, - CompletionType completionType); - void setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, - double skinFactor, - double wellDiameter, - CompletionType completionType); - - void addMetadata(const QString& name, const QString& comment); - static bool isDefaultValue(double val); - - const std::vector& metadata() const { return m_metadata; } - const QString& wellName() const { return m_wellName; } - const IJKCellIndex& cellIndex() const { return m_cellIndex; } - WellConnectionState connectionState() const { return m_connectionState; } - double saturation() const { return m_saturation; } - double transmissibility() const { return m_transmissibility; } - double diameter() const { return m_diameter; } //TODO: should be ft or m - double kh() const { return m_kh; } - double skinFactor() const { return m_skinFactor; } - double dFactor() const { return m_dFactor; } - CellDirection direction() const { return m_direction; } - size_t count() const { return m_count; } - double wpimult() const { return m_wpimult; } - CompletionType completionType() const { return m_completionType; } - bool isMainBore() const { return m_isMainBore; } - bool readyForExport() const { return m_readyForExport; } + void setFromFracture(double transmissibility, double skinFactor); + + void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction, + bool isMainBore); + + void setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction); + + void setCombinedValuesExplicitTrans(double transmissibility, CompletionType completionType); + + void setCombinedValuesImplicitTransWPImult(double wpimult, + CellDirection celldirection, + double skinFactor, + double wellDiameter, + CompletionType completionType); + + void addMetadata(const QString& name, const QString& comment); + static bool isDefaultValue(double val); + + const std::vector& metadata() const; + const QString& wellName() const; + const IJKCellIndex& cellIndex() const; + WellConnectionState connectionState() const; + double saturation() const; + double transmissibility() const; + double diameter() const; //TODO: should be ft or m + double kh() const; + double skinFactor() const; + double dFactor() const; + CellDirection direction() const; + size_t count() const; + double wpimult() const; + CompletionType completionType() const; + bool isMainBore() const; + bool readyForExport() const; std::vector m_metadata; From 85d9d21bb6b20b63fb78a1975ddbb836de5c140d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 29 Jan 2018 15:27:17 +0100 Subject: [PATCH 0166/1027] #1758 Rename to globalCellIndex --- .../RicExportFishbonesWellSegmentsFeature.cpp | 2 +- ...sTransmissibilityCalculationFeatureImp.cpp | 2 +- ...RicWellPathExportCompletionDataFeature.cpp | 42 +++++++++---------- .../RicWellPathExportCompletionDataFeature.h | 29 ++++--------- 4 files changed, 31 insertions(+), 44 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp index 1431b059a2..21bfed8804 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -365,7 +365,7 @@ void RicExportFishbonesWellSegmentsFeature::generateCompsegsTable(RifEclipseData for (const WellSegmentLateralIntersection& intersection : lateral.intersections) { size_t i, j, k; - grid->ijkFromCellIndex(intersection.cellIndex, &i, &j, &k); + grid->ijkFromCellIndex(intersection.globalCellIndex, &i, &j, &k); formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k); formatter.add(lateral.branchNumber); diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index de2f92fe33..5920b73087 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -63,7 +63,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell isMainBore, completionMetaData); - wellBorePartsInCells[intersection.cellIndex].push_back(wellBorePart); + wellBorePartsInCells[intersection.globalCellIndex].push_back(wellBorePart); } } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index f14b8d6f37..e1a974241f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -856,7 +856,7 @@ void RicWellPathExportCompletionDataFeature::markWellPathCells(const std::vector { for (WellSegmentLateralIntersection& intersection : lateral.intersections) { - if (wellPathCellSet.find(intersection.cellIndex) != wellPathCellSet.end()) + if (wellPathCellSet.find(intersection.globalCellIndex) != wellPathCellSet.end()) { intersection.mainBoreCell = true; } @@ -1034,7 +1034,7 @@ void RicWellPathExportCompletionDataFeature::appendCompletionData(std::mapeclipseCaseData(); @@ -1045,9 +1045,9 @@ CellDirection RicWellPathExportCompletionDataFeature::calculateDirectionInCell(R eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(cellIndex)); - double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(cellIndex)); - double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(cellIndex)); + double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(globalCellIndex)); + double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(globalCellIndex)); + double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(globalCellIndex)); if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction) { @@ -1071,7 +1071,7 @@ double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEcli const cvf::Vec3d& internalCellLengths, double skinFactor, double wellRadius, - size_t cellIndex, + size_t globalCellIndex, bool useLateralNTG, size_t volumeScaleConstant, CellDirection directionForVolumeScaling) @@ -1097,16 +1097,16 @@ double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEcli if (ntgResIdx != cvf::UNDEFINED_SIZE_T) { cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(cellIndex); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); } double latNtg = useLateralNTG ? ntg : 1.0; - double dx = dxAccessObject->cellScalarGlobIdx(cellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(cellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(cellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(cellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(cellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(cellIndex); + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); double darcy = RiaEclipseUnitTools::darcysConstant(wellPath->unitSystem()); @@ -1131,7 +1131,7 @@ double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEcli double RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, double wellRadius, - size_t cellIndex, + size_t globalCellIndex, CellDirection direction) { RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); @@ -1155,15 +1155,15 @@ double RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclips if (ntgResIdx != cvf::UNDEFINED_SIZE_T) { cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(cellIndex); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); } - double dx = dxAccessObject->cellScalarGlobIdx(cellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(cellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(cellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(cellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(cellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(cellIndex); + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); double darcy = RiaEclipseUnitTools::darcysConstant(units); diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 6979e31443..27a83f0d03 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -45,13 +45,13 @@ class RimWellPath; struct WellSegmentLateralIntersection { WellSegmentLateralIntersection(int segmentNumber, int attachedSegmentNumber, - size_t cellIndex, + size_t globalCellIndex, double length, double depth, const cvf::Vec3d& lengthsInCell) : segmentNumber(segmentNumber), attachedSegmentNumber(attachedSegmentNumber), - cellIndex(cellIndex), + globalCellIndex(globalCellIndex), mdFromPreviousIntersection(length), tvdChangeFromPreviousIntersection(depth), lengthsInCell(lengthsInCell), @@ -60,7 +60,7 @@ struct WellSegmentLateralIntersection { int segmentNumber; int attachedSegmentNumber; - size_t cellIndex; + size_t globalCellIndex; bool mainBoreCell; double mdFromPreviousIntersection; double tvdChangeFromPreviousIntersection; @@ -106,21 +106,6 @@ struct WellSegmentLocation { std::vector laterals; }; -//================================================================================================== -/// -//================================================================================================== -struct EclipseCellIndexRange { - size_t i; - size_t j; - size_t k1; - size_t k2; -}; - -//================================================================================================== -/// -//================================================================================================== -typedef std::tuple EclipseCellIndex; - //================================================================================================== /// //================================================================================================== @@ -146,22 +131,24 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature //functions also used by RicFishbonesTransmissibilityCalculationFeatureImp static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); static void markWellPathCells(const std::vector& wellPathCells, std::vector* locations); - static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t cellIndex, const cvf::Vec3d& lengthsInCell); + static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); static double calculateTransmissibility(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, const cvf::Vec3d& internalCellLengths, double skinFactor, double wellRadius, - size_t cellIndex, + size_t globalCellIndex, bool useLateralNTG, size_t volumeScaleConstant = 1, CellDirection directionForVolumeScaling = CellDirection::DIR_I); + static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, double wellRadius, - size_t cellIndex, + size_t globalCellIndex, CellDirection direction); + static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); private: From c0359f1776c5a1b6568a2dd3bcbfd8a2675d780c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 29 Jan 2018 20:01:35 +0100 Subject: [PATCH 0167/1027] #1758 Refactor IJKCellIndex --- .../RicExportFractureCompletionsImpl.cpp | 4 +- ...sTransmissibilityCalculationFeatureImp.cpp | 17 ++-- ...RicWellPathExportCompletionDataFeature.cpp | 19 ++--- .../ReservoirDataModel/RigCompletionData.cpp | 79 ++++++++++++++++++- .../ReservoirDataModel/RigCompletionData.h | 38 ++++++--- 5 files changed, 120 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index da0e0c9152..fd1c1df8e2 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -353,10 +353,8 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - size_t i, j, k; - mainGrid->ijkFromCellIndex(externalCell.m_globalCellIdx, &i, &j, &k); - RigCompletionData compDat(wellPathName, {i,j,k}); + RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 5920b73087..33334c8b27 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -87,17 +87,14 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp std::vector completionData; - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); for (const auto& cellAndWellBoreParts : wellBorePartsInCells) { - size_t cellIndex = cellAndWellBoreParts.first; + size_t globalCellIndex = cellAndWellBoreParts.first; const std::vector& wellBoreParts = cellAndWellBoreParts.second; - size_t i, j, k; - grid->ijkFromCellIndex(cellIndex, &i, &j, &k); - bool cellIsActive = activeCellInfo->isActive(cellIndex); + bool cellIsActive = activeCellInfo->isActive(globalCellIndex); if (!cellIsActive) continue; // Find main bore and number of laterals @@ -113,14 +110,14 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp else { mainBoreDirection = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + globalCellIndex, wellBorePart.lengthsInCell); } } for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(globalCellIndex, settings.caseToApply)); double transmissibility = 0.0; if (wellBorePart.isMainBore) @@ -131,7 +128,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG); } @@ -143,7 +140,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG, numberOfLaterals, mainBoreDirection); @@ -151,7 +148,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp } CellDirection direction = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + globalCellIndex, wellBorePart.lengthsInCell); completion.setTransAndWPImultBackgroundDataFromFishbone(transmissibility, diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index e1a974241f..c2d7302c3c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -482,8 +482,6 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp CVF_ASSERT(!completions.empty()); QString wellName = completions[0].wellName(); IJKCellIndex cellIndexIJK = completions[0].cellIndex(); - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); - size_t cellIndex = grid->cellIndexFromIJK(cellIndexIJK.i, cellIndexIJK.j, cellIndexIJK.k); RigCompletionData::CompletionType completionType = completions[0].completionType(); //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, @@ -515,7 +513,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.completionType() != completions[0].completionType()) { - QString errorMessage = QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -523,7 +521,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.wellName() != completions[0].wellName()) { - QString errorMessage = QString("Cannot combine completions from different wells in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -531,7 +529,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp if (completion.transmissibility() == HUGE_VAL) { - QString errorMessage = QString("Transmissibility calculation has failed for cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); + QString errorMessage = QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); return resultCompletion; //Returning empty completion, should not be exported @@ -556,7 +554,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), skinfactor, wellBoreDiameter / 2, - cellIndex, + cellIndexIJK.globalCellIndex(), cellDirection); double wpimult = totalTrans / transmissibilityEclipseCalculation; @@ -692,7 +690,7 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); } formatter.add(data.wellName()); - formatter.addZeroBasedCellIndex(data.cellIndex().i).addZeroBasedCellIndex(data.cellIndex().j).addZeroBasedCellIndex(data.cellIndex().k).addZeroBasedCellIndex(data.cellIndex().k); + formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()); switch (data.connectionState()) { case OPEN: @@ -765,7 +763,7 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData formatter.add(completion.wellName()); formatter.add(completion.wpimult()); - formatter.addZeroBasedCellIndex(completion.cellIndex().i).addZeroBasedCellIndex(completion.cellIndex().j).addZeroBasedCellIndex(completion.cellIndex().k); + formatter.addZeroBasedCellIndex(completion.cellIndex().localCellIndexI()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexK()); formatter.rowCompleted(); } @@ -782,7 +780,6 @@ std::vector RicWellPathExportCompletionDataFeature::generateP std::vector completionData; const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); - if (wellPath->perforationIntervalCollection()->isChecked()) { for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) @@ -800,9 +797,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); if (!cellIsActive) continue; - size_t i, j, k; - settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.globCellIndex, &i, &j, &k); - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(cell.globCellIndex, settings.caseToApply)); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 805a0f1183..9ed28d6361 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -18,6 +18,10 @@ #include "RigCompletionData.h" +#include "RimEclipseCase.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" + #include "RiaLogging.h" #include "cvfAssert.h" @@ -79,7 +83,7 @@ RigCompletionData RigCompletionData::combine(const std::vectorcompletionType() != result.completionType()) { - RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k)); + RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.localCellIndexI()).arg(result.m_cellIndex.localCellIndexJ()).arg(result.m_cellIndex.localCellIndexK())); continue; } if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility)) @@ -390,3 +394,76 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& target.m_wpimult = from.m_wpimult; target.m_completionType = from.m_completionType; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +IJKCellIndex::IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase) : m_globalCellIndex(globalCellIndex) +{ + if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid()) + { + const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); + const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + RigGridBase* grid = cell.hostGrid(); + if (grid) + { + size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + + size_t i = 0; + size_t j = 0; + size_t k = 0; + grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); + + m_localCellIndexI = i; + m_localCellIndexJ = j; + m_localCellIndexK = k; + + if (grid != mainGrid) + { + m_lgrName = QString::fromStdString(grid->gridName()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::globalCellIndex() const +{ + return m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexI() const +{ + return m_localCellIndexI; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexJ() const +{ + return m_localCellIndexJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t IJKCellIndex::localCellIndexK() const +{ + return m_localCellIndexK; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString IJKCellIndex::oneBasedLocalCellIndexString() const +{ + QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1); + + return text; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index db398c9fb5..e10657d1bf 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -22,6 +22,8 @@ #include +class RimEclipseCase; + //================================================================================================== /// //================================================================================================== @@ -47,30 +49,44 @@ enum CellDirection { class IJKCellIndex { public: IJKCellIndex() {}; - IJKCellIndex(size_t i, size_t j, size_t k) : i(i), j(j), k(k) {}; + + IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase); + IJKCellIndex(const IJKCellIndex& other) { - i = other.i; - j = other.j; - k = other.k; + m_localCellIndexI = other.m_localCellIndexI; + m_localCellIndexJ = other.m_localCellIndexJ; + m_localCellIndexK = other.m_localCellIndexK; } bool operator==(const IJKCellIndex& other) const { - return i == other.i && j == other.j && k == other.k; + return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK; } bool operator<(const IJKCellIndex& other) const { - if (i != other.i) return i < other.i; - if (j != other.j) return j < other.j; - if (k != other.k) return k < other.k; + if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; + if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; + if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; return false; } - size_t i; - size_t j; - size_t k; + size_t globalCellIndex() const; + + size_t localCellIndexI() const; + size_t localCellIndexJ() const; + size_t localCellIndexK() const; + + QString oneBasedLocalCellIndexString() const; + +private: + size_t m_globalCellIndex; + QString m_lgrName; + + size_t m_localCellIndexI; + size_t m_localCellIndexJ; + size_t m_localCellIndexK; }; //================================================================================================== From 028b5303a798464d589386ff2f3700bcfb9628c4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 09:08:26 +0100 Subject: [PATCH 0168/1027] #1758 Add support for export of COMPDATL for LGR grid --- .../RicExportFractureCompletionsImpl.cpp | 20 +--- ...RicWellPathExportCompletionDataFeature.cpp | 113 ++++++++++++++---- .../RicWellPathExportCompletionDataFeature.h | 5 +- .../ReservoirDataModel/RigCompletionData.cpp | 8 ++ .../ReservoirDataModel/RigCompletionData.h | 9 +- 5 files changed, 110 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index fd1c1df8e2..87bfde9a8f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -344,21 +344,14 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat { if (externalCell.m_cellIndexSpace == RigTransmissibilityCondenser::CellAddress::ECLIPSE) { - if (externalCell.m_globalCellIdx > mainGrid->cellCount()) - { - RiaLogging::error(QString("LGR cells (not supported) found in export of COMPDAT values for fracture %1").arg(fracture->name())); - } - else - { - double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); + double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); - eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; + eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); - compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); - compDat.addMetadata(fracture->name(), QString::number(trans)); - fractureCompletions.push_back(compDat); - } + RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); + compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); + compDat.addMetadata(fracture->name(), QString::number(trans)); + fractureCompletions.push_back(compDat); } } @@ -375,4 +368,3 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat return fractureCompletions; } - diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index c2d7302c3c..07d58ceb8a 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -576,9 +576,44 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) { - //TODO: Check that completion is ready for export + std::set gridNames; - QDir exportFolder = QDir(folderName); + for (const auto& c : completions) + { + gridNames.insert(c.cellIndex().lgrName()); + } + + for (const auto& gridName : gridNames) + { + std::vector completionsForGrid; + + for (const auto& c : completions) + { + if (gridName == c.cellIndex().lgrName()) + { + completionsForGrid.push_back(c); + } + } + + QString lgrFileName = fileName; + if (!gridName.isEmpty()) + { + lgrFileName += "_"; + lgrFileName += gridName; + } + + printCompletionsToFileLgr(folderName, lgrFileName, completionsForGrid, exportType); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + if (completions.empty()) return; + + QDir exportFolder(folderName); if (!exportFolder.exists()) { @@ -589,7 +624,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin QString filePath = exportFolder.filePath(fileName); QFile exportFile(filePath); - if (!exportFile.open(QIODevice::WriteOnly)) + if (!exportFile.open(QIODevice::WriteOnly)) { RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); return; @@ -602,8 +637,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin std::sort(completions.begin(), completions.end()); // Print completion data - generateCompdatTable(formatter, completions); - + generateCompdatTable(formatter, completions[0].cellIndex().lgrName(), completions); if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { @@ -655,26 +689,53 @@ std::map > RicWellPathExportComplet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData) +void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData) { - std::vector header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; + std::vector header; - formatter.keyword("COMPDAT"); + if (lgrName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDAT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDATL"); + } formatter.header(header); for (const RigCompletionData& data : completionData) @@ -690,6 +751,12 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); } formatter.add(data.wellName()); + + if (!lgrName.isEmpty()) + { + formatter.add(lgrName); + } + formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()); switch (data.connectionState()) { diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 27a83f0d03..39ddf22a6c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -154,11 +154,14 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature private: static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); + static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); + static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData); static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 9ed28d6361..821b03631c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -467,3 +467,11 @@ QString IJKCellIndex::oneBasedLocalCellIndexString() const return text; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString IJKCellIndex::lgrName() const +{ + return m_lgrName; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index e10657d1bf..fee3505ceb 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -52,13 +52,6 @@ class IJKCellIndex { IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase); - IJKCellIndex(const IJKCellIndex& other) - { - m_localCellIndexI = other.m_localCellIndexI; - m_localCellIndexJ = other.m_localCellIndexJ; - m_localCellIndexK = other.m_localCellIndexK; - } - bool operator==(const IJKCellIndex& other) const { return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK; @@ -80,6 +73,8 @@ class IJKCellIndex { QString oneBasedLocalCellIndexString() const; + QString lgrName() const; + private: size_t m_globalCellIndex; QString m_lgrName; From 4516941d2c7a70b1755c144504213ba1a8ebe892 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 09:20:21 +0100 Subject: [PATCH 0169/1027] #1758 Add RigCompletionDataGridCell --- .../RicExportFractureCompletionsImpl.cpp | 2 +- ...sTransmissibilityCalculationFeatureImp.cpp | 2 +- ...RicWellPathExportCompletionDataFeature.cpp | 32 ++--- .../RicWellPathExportCompletionDataFeature.h | 4 +- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigCompletionData.cpp | 88 +----------- .../ReservoirDataModel/RigCompletionData.h | 49 +------ .../RigCompletionDataGridCell.cpp | 131 ++++++++++++++++++ .../RigCompletionDataGridCell.h | 56 ++++++++ 9 files changed, 216 insertions(+), 150 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index 87bfde9a8f..8bd682b037 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -348,7 +348,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); + RigCompletionData compDat(wellPathName, RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply)); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 33334c8b27..6ef0dc1294 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -117,7 +117,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(globalCellIndex, settings.caseToApply)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply)); double transmissibility = 0.0; if (wellBorePart.isMainBore) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 07d58ceb8a..0dc0c4d18f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -288,7 +288,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector } } - std::map > completionsPerEclipseCell; + std::map > completionsPerEclipseCell; // FractureTransmissibilityExportInformation std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; @@ -378,7 +378,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector { for (auto wellPath : usedWellPaths) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); std::vector completions; for (auto& data : filteredWellCompletions) { @@ -404,7 +404,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector { for (auto wellPath : usedWellPaths) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); std::vector completions; for (auto& data : filteredWellCompletions) { @@ -446,7 +446,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector { for (auto simWell : simWells) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); std::vector completions; for (auto& data : filteredWellCompletions) { @@ -481,7 +481,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp { CVF_ASSERT(!completions.empty()); QString wellName = completions[0].wellName(); - IJKCellIndex cellIndexIJK = completions[0].cellIndex(); + RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); RigCompletionData::CompletionType completionType = completions[0].completionType(); //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, @@ -580,7 +580,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin for (const auto& c : completions) { - gridNames.insert(c.cellIndex().lgrName()); + gridNames.insert(c.completionDataGridCell().lgrName()); } for (const auto& gridName : gridNames) @@ -589,7 +589,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin for (const auto& c : completions) { - if (gridName == c.cellIndex().lgrName()) + if (gridName == c.completionDataGridCell().lgrName()) { completionsForGrid.push_back(c); } @@ -637,7 +637,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QSt std::sort(completions.begin(), completions.end()); // Print completion data - generateCompdatTable(formatter, completions[0].cellIndex().lgrName(), completions); + generateCompdatTable(formatter, completions[0].completionDataGridCell().lgrName(), completions); if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { @@ -668,9 +668,9 @@ std::vector RicWellPathExportCompletionDataFeature::getComple //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) +std::map > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) { - std::map > wellCompletions; + std::map > wellCompletions; for (const auto& it : cellToCompletionMap) { @@ -757,7 +757,7 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData formatter.add(lgrName); } - formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()); + formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); switch (data.connectionState()) { case OPEN: @@ -830,7 +830,7 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData formatter.add(completion.wellName()); formatter.add(completion.wpimult()); - formatter.addZeroBasedCellIndex(completion.cellIndex().localCellIndexI()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(completion.cellIndex().localCellIndexK()); + formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); formatter.rowCompleted(); } @@ -864,7 +864,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); if (!cellIsActive) continue; - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(cell.globCellIndex, settings.caseToApply)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply)); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, @@ -1077,18 +1077,18 @@ void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranch //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map >* completionData, const std::vector& data) +void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map >* completionData, const std::vector& data) { for (auto& completion : data) { - auto it = completionData->find(completion.cellIndex()); + auto it = completionData->find(completion.completionDataGridCell()); if (it != completionData->end()) { it->second.push_back(completion); } else { - completionData->insert(std::pair >(completion.cellIndex(), std::vector {completion})); + completionData->insert(std::pair >(completion.completionDataGridCell(), std::vector {completion})); } } } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 39ddf22a6c..bf24aa2a63 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -159,7 +159,7 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); - static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); + static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData); static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); @@ -171,7 +171,7 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); - static void appendCompletionData(std::map >* completionData, const std::vector& data); + static void appendCompletionData(std::map >* completionData, const std::vector& data); }; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index fbf1f44934..0187b28358 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -66,6 +66,7 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h +${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) @@ -138,6 +139,7 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp +${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 821b03631c..e8d611afae 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -18,10 +18,6 @@ #include "RigCompletionData.h" -#include "RimEclipseCase.h" -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" - #include "RiaLogging.h" #include "cvfAssert.h" @@ -34,7 +30,7 @@ //================================================================================================== /// //================================================================================================== -RigCompletionData::RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex) +RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex) : m_wellName(wellName), m_cellIndex(cellIndex), m_saturation(HUGE_VAL), @@ -235,7 +231,7 @@ const QString& RigCompletionData::wellName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const IJKCellIndex& RigCompletionData::cellIndex() const +const RigCompletionDataGridCell& RigCompletionData::completionDataGridCell() const { return m_cellIndex; } @@ -395,83 +391,3 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& target.m_completionType = from.m_completionType; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -IJKCellIndex::IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase) : m_globalCellIndex(globalCellIndex) -{ - if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid()) - { - const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; - RigGridBase* grid = cell.hostGrid(); - if (grid) - { - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); - - size_t i = 0; - size_t j = 0; - size_t k = 0; - grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); - - m_localCellIndexI = i; - m_localCellIndexJ = j; - m_localCellIndexK = k; - - if (grid != mainGrid) - { - m_lgrName = QString::fromStdString(grid->gridName()); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t IJKCellIndex::globalCellIndex() const -{ - return m_globalCellIndex; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t IJKCellIndex::localCellIndexI() const -{ - return m_localCellIndexI; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t IJKCellIndex::localCellIndexJ() const -{ - return m_localCellIndexJ; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t IJKCellIndex::localCellIndexK() const -{ - return m_localCellIndexK; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString IJKCellIndex::oneBasedLocalCellIndexString() const -{ - QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1); - - return text; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString IJKCellIndex::lgrName() const -{ - return m_lgrName; -} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index fee3505ceb..709a64f68e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -18,6 +18,8 @@ #pragma once +#include "RigCompletionDataGridCell.h" + #include #include @@ -43,47 +45,6 @@ enum CellDirection { DIR_UNDEF, }; -//================================================================================================== -/// -//================================================================================================== -class IJKCellIndex { -public: - IJKCellIndex() {}; - - IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase); - - bool operator==(const IJKCellIndex& other) const - { - return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK; - } - - bool operator<(const IJKCellIndex& other) const - { - if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; - if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; - if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; - return false; - } - - size_t globalCellIndex() const; - - size_t localCellIndexI() const; - size_t localCellIndexJ() const; - size_t localCellIndexK() const; - - QString oneBasedLocalCellIndexString() const; - - QString lgrName() const; - -private: - size_t m_globalCellIndex; - QString m_lgrName; - - size_t m_localCellIndexI; - size_t m_localCellIndexJ; - size_t m_localCellIndexK; -}; - //================================================================================================== /// //================================================================================================== @@ -107,7 +68,7 @@ class RigCompletionData CT_UNDEFINED }; - RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex); + RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex); ~RigCompletionData(); RigCompletionData(const RigCompletionData& other); @@ -142,7 +103,7 @@ class RigCompletionData const std::vector& metadata() const; const QString& wellName() const; - const IJKCellIndex& cellIndex() const; + const RigCompletionDataGridCell& completionDataGridCell() const; WellConnectionState connectionState() const; double saturation() const; double transmissibility() const; @@ -161,7 +122,7 @@ class RigCompletionData private: QString m_wellName; - IJKCellIndex m_cellIndex; + RigCompletionDataGridCell m_cellIndex; WellConnectionState m_connectionState; double m_saturation; //TODO: remove, always use default in Eclipse? double m_transmissibility; diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp new file mode 100644 index 0000000000..eccbbe07a1 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCompletionDataGridCell.h" + +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" + +#include "RimEclipseCase.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionDataGridCell::RigCompletionDataGridCell() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, const RimEclipseCase* eclipseCase) + : m_globalCellIndex(globalCellIndex) +{ + if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid()) + { + const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); + const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + RigGridBase* grid = cell.hostGrid(); + if (grid) + { + size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + + size_t i = 0; + size_t j = 0; + size_t k = 0; + grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); + + m_localCellIndexI = i; + m_localCellIndexJ = j; + m_localCellIndexK = k; + + if (grid != mainGrid) + { + m_lgrName = QString::fromStdString(grid->gridName()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionDataGridCell::operator==(const RigCompletionDataGridCell& other) const +{ + return m_globalCellIndex == other.m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionDataGridCell::operator<(const RigCompletionDataGridCell& other) const +{ + if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; + if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; + if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::globalCellIndex() const +{ + return m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexI() const +{ + return m_localCellIndexI; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexJ() const +{ + return m_localCellIndexJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexK() const +{ + return m_localCellIndexK; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigCompletionDataGridCell::oneBasedLocalCellIndexString() const +{ + QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1); + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigCompletionDataGridCell::lgrName() const +{ + return m_lgrName; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h new file mode 100644 index 0000000000..dd1e674b58 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RimEclipseCase; + +//================================================================================================== +/// +//================================================================================================== +class RigCompletionDataGridCell +{ +public: + RigCompletionDataGridCell(); + + RigCompletionDataGridCell(size_t globalCellIndex, const RimEclipseCase* eclipseCase); + + bool operator==(const RigCompletionDataGridCell& other) const; + + bool operator<(const RigCompletionDataGridCell& other) const; + + size_t globalCellIndex() const; + + size_t localCellIndexI() const; + size_t localCellIndexJ() const; + size_t localCellIndexK() const; + + QString oneBasedLocalCellIndexString() const; + + QString lgrName() const; + +private: + size_t m_globalCellIndex; + QString m_lgrName; + + size_t m_localCellIndexI; + size_t m_localCellIndexJ; + size_t m_localCellIndexK; +}; From 5cc6877afac779faa121820bda837105520d22e9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 10:34:37 +0100 Subject: [PATCH 0170/1027] #1758 Use map to sort RigCompletionDataGridCell based on grid --- ...RicWellPathExportCompletionDataFeature.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 0dc0c4d18f..abaad52a6b 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -576,33 +576,36 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) { - std::set gridNames; + // Sort completions based on grid they belong to + std::map> completionsForGrid; - for (const auto& c : completions) + for (const auto& completion : completions) { - gridNames.insert(c.completionDataGridCell().lgrName()); - } - - for (const auto& gridName : gridNames) - { - std::vector completionsForGrid; + QString gridName = completion.completionDataGridCell().lgrName(); - for (const auto& c : completions) + auto it = completionsForGrid.find(gridName); + if (it == completionsForGrid.end()) { - if (gridName == c.completionDataGridCell().lgrName()) - { - completionsForGrid.push_back(c); - } + completionsForGrid.insert(std::pair>(gridName, std::vector{completion})); + } + else + { + it->second.push_back(completion); } + } + for (auto& it : completionsForGrid) + { QString lgrFileName = fileName; + QString gridName = it.first; + if (!gridName.isEmpty()) { lgrFileName += "_"; lgrFileName += gridName; } - printCompletionsToFileLgr(folderName, lgrFileName, completionsForGrid, exportType); + printCompletionsToFileLgr(folderName, lgrFileName, it.second, exportType); } } From c7b5e091c68c368f330f2535bd7457872969e700 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 10:41:51 +0100 Subject: [PATCH 0171/1027] #1758 Rename to gridName --- .../RicWellPathExportCompletionDataFeature.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index abaad52a6b..693474bd45 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -605,14 +605,18 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin lgrFileName += gridName; } - printCompletionsToFileLgr(folderName, lgrFileName, it.second, exportType); + printCompletionsToFileLgr(folderName, lgrFileName, gridName, it.second, exportType); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) +void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QString& folderName, + const QString& fileName, + const QString& gridName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) { if (completions.empty()) return; @@ -640,7 +644,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QSt std::sort(completions.begin(), completions.end()); // Print completion data - generateCompdatTable(formatter, completions[0].completionDataGridCell().lgrName(), completions); + generateCompdatTable(formatter, gridName, completions); if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { @@ -692,11 +696,11 @@ std::map > RicWellPath //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData) +void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) { std::vector header; - if (lgrName.isEmpty()) + if (gridName.isEmpty()) { header = { RifEclipseOutputTableColumn("Well"), @@ -755,9 +759,9 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData } formatter.add(data.wellName()); - if (!lgrName.isEmpty()) + if (!gridName.isEmpty()) { - formatter.add(lgrName); + formatter.add(gridName); } formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); From 38f18dbecb3ade9a467f5c9f899cdef7f484073e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 11:03:17 +0100 Subject: [PATCH 0172/1027] #1758 Add support for export of WPIMULTL --- ...RicWellPathExportCompletionDataFeature.cpp | 45 ++++++++++++++----- .../RicWellPathExportCompletionDataFeature.h | 6 +-- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 693474bd45..3361eaf0fb 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -648,7 +648,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QSt if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { - generateWpimultTable(formatter, completions); + generateWpimultTable(formatter, gridName, completions); } RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); @@ -816,16 +816,35 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData) +void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) { - std::vector header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("Mult"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K"), - }; - formatter.keyword("WPIMULT"); + std::vector header; + + if (gridName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULTL"); + } formatter.header(header); for (auto& completion : completionData) @@ -837,6 +856,12 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData formatter.add(completion.wellName()); formatter.add(completion.wpimult()); + + if (!gridName.isEmpty()) + { + formatter.add(gridName); + } + formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); formatter.rowCompleted(); } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index bf24aa2a63..abc3b8de73 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -156,13 +156,13 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature const RicExportCompletionDataSettingsUi& settings); static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, const QString& gridName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData); - static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); + static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); + static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); From 54a7320b5905de41b1b75b3e0860b4a9cde210b3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 13:09:45 +0100 Subject: [PATCH 0173/1027] #1758 Export main grid data to one file and LGR data to one file --- ...RicWellPathExportCompletionDataFeature.cpp | 79 +++++++++++-------- .../RicWellPathExportCompletionDataFeature.h | 4 +- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 3361eaf0fb..c5beaebedf 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -371,7 +371,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector } const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, completions, exportSettings.compdatExport); progress.incrementProgress(); } else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) @@ -396,7 +396,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector if (wellCompletions.empty()) continue; QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); progress.incrementProgress(); } } @@ -415,7 +415,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector if (!fishbonesCompletions.empty()) { QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); } progress.incrementProgress(); } @@ -424,7 +424,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector if (!perforationCompletions.empty()) { QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); } progress.incrementProgress(); } @@ -433,7 +433,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector if (!fractureCompletions.empty()) { QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); } progress.incrementProgress(); } @@ -466,7 +466,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) : QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); progress.incrementProgress(); } } @@ -571,54 +571,61 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& folderName, +void RicWellPathExportCompletionDataFeature::printCompletionsToFiles(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) { // Sort completions based on grid they belong to - std::map> completionsForGrid; + std::vector completionsForMainGrid; + + std::map> completionsForSubGrids; for (const auto& completion : completions) { QString gridName = completion.completionDataGridCell().lgrName(); - - auto it = completionsForGrid.find(gridName); - if (it == completionsForGrid.end()) + if (gridName.isEmpty()) { - completionsForGrid.insert(std::pair>(gridName, std::vector{completion})); + completionsForMainGrid.push_back(completion); } else { - it->second.push_back(completion); + auto it = completionsForSubGrids.find(gridName); + if (it == completionsForSubGrids.end()) + { + completionsForSubGrids.insert(std::pair>(gridName, std::vector{completion})); + } + else + { + it->second.push_back(completion); + } } } - for (auto& it : completionsForGrid) + if (!completionsForMainGrid.empty()) { - QString lgrFileName = fileName; - QString gridName = it.first; + std::map> completionsForGrid; + completionsForGrid.insert(std::pair>("", completionsForMainGrid)); - if (!gridName.isEmpty()) - { - lgrFileName += "_"; - lgrFileName += gridName; - } + printCompletionsToFile(folderName, fileName, completionsForGrid, exportType); + } - printCompletionsToFileLgr(folderName, lgrFileName, gridName, it.second, exportType); + if (!completionsForSubGrids.empty()) + { + QString lgrFileName = fileName + "_LGR"; + printCompletionsToFile(folderName, lgrFileName, completionsForSubGrids, exportType); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QString& folderName, +void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& folderName, const QString& fileName, - const QString& gridName, - std::vector& completions, + const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType) { - if (completions.empty()) return; + if (completionsPerGrid.empty()) return; QDir exportFolder(folderName); @@ -640,15 +647,21 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QSt QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); - // Sort by well name / cell index - std::sort(completions.begin(), completions.end()); + for (const auto& gridCompletions : completionsPerGrid) + { + std::vector completions = gridCompletions.second; + + // Sort by well name / cell index + std::sort(completions.begin(), completions.end()); - // Print completion data - generateCompdatTable(formatter, gridName, completions); + // Print completion data + QString gridName = gridCompletions.first; + generateCompdatTable(formatter, gridName, completions); - if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) - { - generateWpimultTable(formatter, gridName, completions); + if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + generateWpimultTable(formatter, gridName, completions); + } } RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index abc3b8de73..df8d977bbf 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -155,8 +155,8 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); - static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, const QString& gridName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFiles(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); From 6f0f73a0179bbae36b0bd26149e6baf59169c020 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 13:29:14 +0100 Subject: [PATCH 0174/1027] #1758 Add direct access to RigMainGrid from RimEclipseCase --- ApplicationCode/ProjectDataModel/RimEclipseCase.cpp | 13 +++++++++++++ ApplicationCode/ProjectDataModel/RimEclipseCase.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index de60daac41..ab9802971e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -198,6 +198,19 @@ cvf::Color3f RimEclipseCase::defaultWellColor(const QString& wellName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigMainGrid* RimEclipseCase::mainGrid() const +{ + if (eclipseCaseData()) + { + return eclipseCaseData()->mainGrid(); + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index a4673b1927..bb0704f7c5 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -39,6 +39,7 @@ class QString; class RigEclipseCaseData; class RigCaseCellResultsData; class RigGridBase; +class RigMainGrid; class RimCaseCollection; class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; @@ -74,6 +75,8 @@ class RimEclipseCase : public RimCase const RigEclipseCaseData* eclipseCaseData() const; cvf::Color3f defaultWellColor(const QString& wellName); + const RigMainGrid* mainGrid() const; + RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel); const RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel) const; From e18a08a42576f1c1a09c2d0e3ca0145852690ea6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 13:29:45 +0100 Subject: [PATCH 0175/1027] #1758 Use RigMainGrid in interface to CompletionDataGridCell --- .../RicExportFractureCompletionsImpl.cpp | 2 +- ...hbonesTransmissibilityCalculationFeatureImp.cpp | 2 +- .../RicWellPathExportCompletionDataFeature.cpp | 2 +- .../RigCompletionDataGridCell.cpp | 14 +++++--------- .../ReservoirDataModel/RigCompletionDataGridCell.h | 4 ++-- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index 8bd682b037..0542884a03 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -348,7 +348,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - RigCompletionData compDat(wellPathName, RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply)); + RigCompletionData compDat(wellPathName, RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid())); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 6ef0dc1294..eda7fbd622 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -117,7 +117,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply->mainGrid())); double transmissibility = 0.0; if (wellBorePart.isMainBore) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index c5beaebedf..b35aa8b42f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -909,7 +909,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); if (!cellIsActive) continue; - RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp index eccbbe07a1..ea48f8c42c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp @@ -18,11 +18,8 @@ #include "RigCompletionDataGridCell.h" -#include "RigEclipseCaseData.h" #include "RigMainGrid.h" -#include "RimEclipseCase.h" - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -31,14 +28,13 @@ RigCompletionDataGridCell::RigCompletionDataGridCell() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, const RimEclipseCase* eclipseCase) +RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid) : m_globalCellIndex(globalCellIndex) { - if (eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid()) + if (mainGrid) { - const RigMainGrid* mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; - RigGridBase* grid = cell.hostGrid(); + const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + RigGridBase* grid = cell.hostGrid(); if (grid) { size_t gridLocalCellIndex = cell.gridLocalCellIndex(); @@ -76,7 +72,7 @@ bool RigCompletionDataGridCell::operator<(const RigCompletionDataGridCell& other if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; - + return false; } diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h index dd1e674b58..91637fa48c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h @@ -20,7 +20,7 @@ #include -class RimEclipseCase; +class RigMainGrid; //================================================================================================== /// @@ -30,7 +30,7 @@ class RigCompletionDataGridCell public: RigCompletionDataGridCell(); - RigCompletionDataGridCell(size_t globalCellIndex, const RimEclipseCase* eclipseCase); + RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid); bool operator==(const RigCompletionDataGridCell& other) const; From f0f7c954ccdaf9aea6ce8c7509355bf61fa465aa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 14:24:12 +0100 Subject: [PATCH 0176/1027] #2423 Export Completions : Move files to separate folder --- ApplicationCode/CMakeLists.txt | 1 + .../CompletionCommands/CMakeLists_files.cmake | 19 --------- .../CMakeLists_files.cmake | 41 +++++++++++++++++++ .../RicExportCompletionDataSettingsUi.cpp | 0 .../RicExportCompletionDataSettingsUi.h | 2 +- .../RicExportFractureCompletionsImpl.cpp | 0 .../RicExportFractureCompletionsImpl.h | 0 ...sTransmissibilityCalculationFeatureImp.cpp | 0 ...nesTransmissibilityCalculationFeatureImp.h | 0 ...RicWellPathExportCompletionDataFeature.cpp | 0 .../RicWellPathExportCompletionDataFeature.h | 0 11 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportCompletionDataSettingsUi.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportCompletionDataSettingsUi.h (98%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportFractureCompletionsImpl.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportFractureCompletionsImpl.h (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicFishbonesTransmissibilityCalculationFeatureImp.h (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicWellPathExportCompletionDataFeature.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicWellPathExportCompletionDataFeature.h (100%) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 89390cf952..506532d2e1 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -117,6 +117,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/CMakeLists_files.cmake Commands/ApplicationCommands/CMakeLists_files.cmake Commands/CompletionCommands/CMakeLists_files.cmake + Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake Commands/CrossSectionCommands/CMakeLists_files.cmake Commands/EclipseCommands/CMakeLists_files.cmake Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake index 88ee6e511f..b9842ca471 100644 --- a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake @@ -7,48 +7,29 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h ${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.h -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..8702bb8a68 --- /dev/null +++ b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake @@ -0,0 +1,41 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h +${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h +${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h +) + +if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) + list (APPEND SOURCE_GROUP_HEADER_FILES + ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h + ) +endif() + + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp +${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp +${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp +) + +if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) + list (APPEND SOURCE_GROUP_SOURCE_FILES + ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp + ) +endif() + + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\CompletionExport" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h similarity index 98% rename from ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 1224b44435..ff24170ef1 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -18,7 +18,7 @@ #pragma once -#include "RicCaseAndFileExportSettingsUi.h" +#include "../RicCaseAndFileExportSettingsUi.h" #include "cafPdmField.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h From e989b3afc967a8a47c4c212c3d801b9b89ef5fc9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 15:35:03 +0100 Subject: [PATCH 0177/1027] #2423 Export Completions : Move Rig*-files to completion export folder --- .../CommandFileInterface/RicfExportMsw.cpp | 2 +- .../RicfExportSimWellCompletions.cpp | 2 +- .../RicfExportSimWellCompletions.h | 2 +- .../CompletionCommands/CMakeLists_files.cmake | 4 ---- .../CMakeLists_files.cmake | 16 ++++++++++++++++ .../RicCaseAndFileExportSettingsUi.cpp | 0 .../RicCaseAndFileExportSettingsUi.h | 0 .../RicExportCompletionDataSettingsUi.h | 2 +- .../RicExportFishbonesWellSegmentsFeature.cpp | 0 .../RicExportFishbonesWellSegmentsFeature.h | 2 +- .../RigCompletionData.cpp | 0 .../RigCompletionData.h | 0 .../RigCompletionDataGridCell.cpp | 0 .../RigCompletionDataGridCell.h | 0 ...eToStimPlanCellTransmissibilityCalculator.cpp | 0 ...pseToStimPlanCellTransmissibilityCalculator.h | 0 .../RigFractureTransmissibilityEquations.cpp | 0 .../RigFractureTransmissibilityEquations.h | 0 .../RigTransmissibilityCondenser.cpp | 0 .../RigTransmissibilityCondenser.h | 0 .../RigWellPathStimplanIntersector.cpp | 0 .../RigWellPathStimplanIntersector.h | 0 .../ReservoirDataModel/CMakeLists_files.cmake | 12 ------------ .../UnitTests/RigCellGeometryTools-Test.cpp | 2 +- .../RigTransmissibilityCondenser-Test.cpp | 2 +- 25 files changed, 23 insertions(+), 23 deletions(-) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicCaseAndFileExportSettingsUi.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicCaseAndFileExportSettingsUi.h (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportFishbonesWellSegmentsFeature.cpp (100%) rename ApplicationCode/Commands/CompletionCommands/{ => CompletionExportCommands}/RicExportFishbonesWellSegmentsFeature.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigCompletionData.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigCompletionData.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigCompletionDataGridCell.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigCompletionDataGridCell.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigEclipseToStimPlanCellTransmissibilityCalculator.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigFractureTransmissibilityEquations.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigFractureTransmissibilityEquations.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigTransmissibilityCondenser.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigTransmissibilityCondenser.h (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigWellPathStimplanIntersector.cpp (100%) rename ApplicationCode/{ReservoirDataModel => Commands/CompletionCommands/CompletionExportCommands}/RigWellPathStimplanIntersector.h (100%) diff --git a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp index 1c6489ebce..88f8bce6c0 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp @@ -32,7 +32,7 @@ #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" -#include "CompletionCommands/RicExportFishbonesWellSegmentsFeature.h" +#include "CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h" CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 08969123bb..be64876864 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -35,7 +35,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "CompletionCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" CAF_PDM_SOURCE_INIT(RicfExportSimWellCompletions, "exportSimWellCompletions"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h index 3a28475a47..96f5993f93 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "cafAppEnum.h" #include "cafPdmField.h" diff --git a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake index b9842ca471..43d1959445 100644 --- a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake @@ -5,10 +5,8 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") endif() set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.h ${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h @@ -18,10 +16,8 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake index 8702bb8a68..0290009c87 100644 --- a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake @@ -8,11 +8,19 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h ${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h +${CEE_CURRENT_LIST_DIR}RigCompletionData.h +${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h +${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h +${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h + ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h + ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h + ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h + ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h ) endif() @@ -21,11 +29,19 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp ${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp +${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp +${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp +${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp +${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp + ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp + ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp + ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp + ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp ) endif() diff --git a/ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index ff24170ef1..1224b44435 100644 --- a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -18,7 +18,7 @@ #pragma once -#include "../RicCaseAndFileExportSettingsUi.h" +#include "RicCaseAndFileExportSettingsUi.h" #include "cafPdmField.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h index 338ed30c3e..13b8409cc3 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h @@ -21,9 +21,9 @@ #include "RifEclipseDataTableFormatter.h" #include "RicCaseAndFileExportSettingsUi.h" - #include "RicWellPathExportCompletionDataFeature.h" + #include "cafCmdFeature.h" class RimFishbonesCollection; diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigCompletionData.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigCompletionData.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.h diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigCompletionDataGridCell.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.h diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h diff --git a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.h diff --git a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h b/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h rename to ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 0187b28358..7e50d6080c 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -18,7 +18,6 @@ ${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h ${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCompletionData.h ${CEE_CURRENT_LIST_DIR}RigResultModifier.h ${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.h ${CEE_CURRENT_LIST_DIR}RigFormationNames.h @@ -66,18 +65,13 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h -${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.h ${CEE_CURRENT_LIST_DIR}RigFractureGrid.h ${CEE_CURRENT_LIST_DIR}RigFractureCell.h - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h ) endif() @@ -96,7 +90,6 @@ ${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp ${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp ${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.cpp ${CEE_CURRENT_LIST_DIR}RigFormationNames.cpp ${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.cpp @@ -139,18 +132,13 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp -${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.cpp ${CEE_CURRENT_LIST_DIR}RigFractureGrid.cpp ${CEE_CURRENT_LIST_DIR}RigFractureCell.cpp - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp ) endif() diff --git a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp index 641d7e69ff..7ab6825ff3 100644 --- a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp @@ -296,7 +296,7 @@ TEST(RigCellGeometryTools, polylinePolygonIntersectionTest2) } -#include "RigWellPathStimplanIntersector.h" +#include "CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp index 54d7a9bcd1..8087b53eb7 100644 --- a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp +++ b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include "RigTransmissibilityCondenser.h" +#include "CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h" //-------------------------------------------------------------------------------------------------- /// From 20652a05977b4ce5870ab91432c61c4b898c4da1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 17:25:41 +0100 Subject: [PATCH 0178/1027] #2423 Export Completions : Move folder one level up --- ApplicationCode/CMakeLists.txt | 2 +- ApplicationCode/CommandFileInterface/RicfExportMsw.cpp | 2 +- .../CommandFileInterface/RicfExportSimWellCompletions.cpp | 2 +- .../CommandFileInterface/RicfExportSimWellCompletions.h | 2 +- .../CompletionExportCommands/CMakeLists_files.cmake | 0 .../CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp | 0 .../CompletionExportCommands/RicCaseAndFileExportSettingsUi.h | 0 .../RicExportCompletionDataSettingsUi.cpp | 0 .../RicExportCompletionDataSettingsUi.h | 0 .../RicExportFishbonesWellSegmentsFeature.cpp | 0 .../RicExportFishbonesWellSegmentsFeature.h | 0 .../RicExportFractureCompletionsImpl.cpp | 0 .../CompletionExportCommands/RicExportFractureCompletionsImpl.h | 0 .../RicFishbonesTransmissibilityCalculationFeatureImp.cpp | 0 .../RicFishbonesTransmissibilityCalculationFeatureImp.h | 0 .../RicWellPathExportCompletionDataFeature.cpp | 0 .../RicWellPathExportCompletionDataFeature.h | 0 .../CompletionExportCommands/RigCompletionData.cpp | 0 .../CompletionExportCommands/RigCompletionData.h | 0 .../CompletionExportCommands/RigCompletionDataGridCell.cpp | 0 .../CompletionExportCommands/RigCompletionDataGridCell.h | 0 .../RigEclipseToStimPlanCellTransmissibilityCalculator.cpp | 0 .../RigEclipseToStimPlanCellTransmissibilityCalculator.h | 0 .../RigFractureTransmissibilityEquations.cpp | 0 .../RigFractureTransmissibilityEquations.h | 0 .../CompletionExportCommands/RigTransmissibilityCondenser.cpp | 0 .../CompletionExportCommands/RigTransmissibilityCondenser.h | 0 .../CompletionExportCommands/RigWellPathStimplanIntersector.cpp | 0 .../CompletionExportCommands/RigWellPathStimplanIntersector.h | 0 ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp | 2 +- ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp | 2 +- 31 files changed, 6 insertions(+), 6 deletions(-) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/CMakeLists_files.cmake (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportCompletionDataSettingsUi.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicExportFractureCompletionsImpl.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigCompletionData.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigCompletionData.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigCompletionDataGridCell.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigCompletionDataGridCell.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigFractureTransmissibilityEquations.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigTransmissibilityCondenser.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigTransmissibilityCondenser.h (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigWellPathStimplanIntersector.cpp (100%) rename ApplicationCode/Commands/{CompletionCommands => }/CompletionExportCommands/RigWellPathStimplanIntersector.h (100%) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 506532d2e1..1bbeff0696 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -117,7 +117,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/CMakeLists_files.cmake Commands/ApplicationCommands/CMakeLists_files.cmake Commands/CompletionCommands/CMakeLists_files.cmake - Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake + Commands/CompletionExportCommands/CMakeLists_files.cmake Commands/CrossSectionCommands/CMakeLists_files.cmake Commands/EclipseCommands/CMakeLists_files.cmake Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake diff --git a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp index 88f8bce6c0..694d159006 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp @@ -32,7 +32,7 @@ #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" -#include "CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h" +#include "CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h" CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index be64876864..4289ec3bf9 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -35,7 +35,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" CAF_PDM_SOURCE_INIT(RicfExportSimWellCompletions, "exportSimWellCompletions"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h index 96f5993f93..e639d939c2 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "cafAppEnum.h" #include "cafPdmField.h" diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/CMakeLists_files.cmake rename to ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h rename to ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicExportFractureCompletionsImpl.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h rename to ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h rename to ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionData.h rename to ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigCompletionDataGridCell.h rename to ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h b/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h rename to ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.h b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigFractureTransmissibilityEquations.h rename to ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h b/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h rename to ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h b/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h rename to ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.h diff --git a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp index 7ab6825ff3..52d3241478 100644 --- a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp @@ -296,7 +296,7 @@ TEST(RigCellGeometryTools, polylinePolygonIntersectionTest2) } -#include "CompletionCommands/CompletionExportCommands/RigWellPathStimplanIntersector.h" +#include "CompletionExportCommands/RigWellPathStimplanIntersector.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp index 8087b53eb7..32e6283a51 100644 --- a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp +++ b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include "CompletionCommands/CompletionExportCommands/RigTransmissibilityCondenser.h" +#include "CompletionExportCommands/RigTransmissibilityCondenser.h" //-------------------------------------------------------------------------------------------------- /// From 52875a57dc85cfb5f68e58e4c5ab3d32b067c246 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 18:41:29 +0100 Subject: [PATCH 0179/1027] #2423 Export Completions : Cleaned up private functions, moved to cpp and improved whitespace --- .../RicfExportWellPathCompletions.cpp | 2 +- .../RicfExportWellPathCompletions.h | 2 +- ...sTransmissibilityCalculationFeatureImp.cpp | 17 ++++ ...nesTransmissibilityCalculationFeatureImp.h | 54 ++++--------- .../RicWellPathExportCompletionDataFeature.h | 24 +++--- ...ToStimPlanCellTransmissibilityCalculator.h | 16 ++-- .../RigFractureTransmissibilityEquations.cpp | 27 ++++--- .../RigFractureTransmissibilityEquations.h | 78 ++++++++++--------- .../RigTransmissibilityCondenser.h | 3 + 9 files changed, 111 insertions(+), 112 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index ec8d8f5a94..b5936e5bb8 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -31,7 +31,7 @@ #include "RimWellPathCollection.h" #include "RimWellPath.h" -#include "CompletionCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" CAF_PDM_SOURCE_INIT(RicfExportWellPathCompletions, "exportWellPathCompletions"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h index 3cbdfc9195..fc5454ed41 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "cafAppEnum.h" #include "cafPdmField.h" diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index eda7fbd622..11aa06b4c8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -35,6 +35,23 @@ #include "RimWellPathCompletions.h" #include "RigWellLogExtractor.h" +//================================================================================================== +/// +//================================================================================================== +struct WellBorePartForTransCalc +{ + WellBorePartForTransCalc(cvf::Vec3d lengthsInCell, double wellRadius, double skinFactor, bool isMainBore, QString metaData) + : lengthsInCell(lengthsInCell), wellRadius(wellRadius), skinFactor(skinFactor), isMainBore(isMainBore), metaData(metaData) + { + } + + cvf::Vec3d lengthsInCell; + double wellRadius; + double skinFactor; + QString metaData; + bool isMainBore; +}; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h index c6566e3f9b..19df74e89e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h @@ -18,40 +18,15 @@ #pragma once -#include "cvfBase.h" -#include "cvfVector3.h" - #include #include -#include class RigCompletionData; class RimWellPath; class RicExportCompletionDataSettingsUi; +struct WellBorePartForTransCalc; -//================================================================================================== -/// -//================================================================================================== -struct WellBorePartForTransCalc { - WellBorePartForTransCalc(cvf::Vec3d lengthsInCell, - double wellRadius, - double skinFactor, - bool isMainBore, - QString metaData) - : lengthsInCell(lengthsInCell), - wellRadius(wellRadius), - skinFactor(skinFactor), - isMainBore(isMainBore), - metaData(metaData) - {} - - cvf::Vec3d lengthsInCell; - double wellRadius; - double skinFactor; - QString metaData; - bool isMainBore; -}; //================================================================================================== /// @@ -59,20 +34,21 @@ struct WellBorePartForTransCalc { class RicFishbonesTransmissibilityCalculationFeatureImp { public: - static std::vector generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - + static std::vector generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); private: - static void findFishboneLateralsWellBoreParts(std::map >& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - static void findFishboneImportedLateralsWellBoreParts(std::map >& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - static void findMainWellBoreParts(std::map>& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); + static void findFishboneLateralsWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + static void findFishboneImportedLateralsWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + static void findMainWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); }; - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index df8d977bbf..1f700c0459 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -112,25 +112,18 @@ struct WellSegmentLocation { class RicWellPathExportCompletionDataFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -protected: - // Overrides +protected: virtual bool isCommandEnabled() override; virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; - std::vector selectedWellPaths(); - std::vector selectedSimWells(); - - bool noWellPathsSelectedDirectly(); - public: static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); //functions also used by RicFishbonesTransmissibilityCalculationFeatureImp static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); - static void markWellPathCells(const std::vector& wellPathCells, std::vector* locations); static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); static double calculateTransmissibility(RimEclipseCase* eclipseCase, @@ -143,15 +136,21 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature size_t volumeScaleConstant = 1, CellDirection directionForVolumeScaling = CellDirection::DIR_I); + + static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); + +private: + std::vector selectedWellPaths(); + std::vector selectedSimWells(); + + bool noWellPathsSelectedDirectly(); + static void markWellPathCells(const std::vector& wellPathCells, std::vector* locations); + static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, double wellRadius, size_t globalCellIndex, CellDirection direction); - - static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); - -private: static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); @@ -172,6 +171,5 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); static void appendCompletionData(std::map >* completionData, const std::vector& data); - }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h b/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h index cd4dcc402f..6800ebc301 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h @@ -59,13 +59,11 @@ class RigEclipseToStimPlanCellTransmissibilityCalculator const QString& uiResultName); private: - RimEclipseCase* m_case; - double m_cDarcy; - double m_fractureSkinFactor; - cvf::Mat4d m_fractureTransform; - const RigFractureCell& m_stimPlanCell; - - std::vector m_globalIndeciesToContributingEclipseCells; - std::vector m_contributingEclipseCellTransmissibilities; + RimEclipseCase* m_case; + double m_cDarcy; + double m_fractureSkinFactor; + cvf::Mat4d m_fractureTransform; + const RigFractureCell& m_stimPlanCell; + std::vector m_globalIndeciesToContributingEclipseCells; + std::vector m_contributingEclipseCellTransmissibilities; }; - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp index b92ebece1f..fd7aa599a6 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp @@ -17,22 +17,12 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigFractureTransmissibilityEquations.h" + #include "cvfBase.h" #include "cvfMath.h" -#include +#include -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans(double conductivity, - double sideLengthParallellTrans, - double sideLengthNormalTrans, - double cDarcyForRelevantUnit) -{ - double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans / (sideLengthParallellTrans / 2); - return transmissibility; -} //-------------------------------------------------------------------------------------------------- /// @@ -130,3 +120,16 @@ double RigFractureTransmissibilityEquations::matrixToFractureTrans(double perm, CVF_ASSERT(transmissibility == transmissibility); return transmissibility; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans(double conductivity, + double sideLengthParallellTrans, + double sideLengthNormalTrans, + double cDarcyForRelevantUnit) +{ + double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans / (sideLengthParallellTrans / 2); + return transmissibility; +} + diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h index c6b02179b8..48073997e0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h @@ -19,45 +19,49 @@ #pragma once +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigFractureTransmissibilityEquations { public: - static double centerToEdgeFractureCellTrans(double conductivity, - double sideLengthParallellTrans, - double sideLengthNormalTrans, - double cDarcyForRelevantUnit); - - static double centerToCenterFractureCellTrans(double conductivityCell1, - double sideLengthParallellTransCell1, - double sideLengthNormalTransCell1, - double conductivityCell2, - double sideLengthParallellTransCell2, - double sideLengthNormalTransCell2, - double cDarcyForRelevantUnit); - - static double fractureCellToWellRadialTrans(double fractureCellConductivity, - double fractureCellSizeX, - double fractureCellSizeZ, - double wellRadius, - double skinFactor, - double cDarcyForRelevantUnit); - - static double fractureCellToWellLinearTrans(double fractureConductivity, - double fractureCellSizeX, - double fractureCellSizeZ, - double perforationLengthVertical, - double perforationLengthHorizontal, - double perforationEfficiency, - double skinfactor, - double cDarcyForRelevantUnit); - - static double matrixToFractureTrans(double permX, - double NTG, - double Ay, - double dx, - double skinfactor, - double fractureAreaWeightedlength, - double cDarcy); + static double centerToCenterFractureCellTrans(double conductivityCell1, + double sideLengthParallellTransCell1, + double sideLengthNormalTransCell1, + double conductivityCell2, + double sideLengthParallellTransCell2, + double sideLengthNormalTransCell2, + double cDarcyForRelevantUnit); -}; + static double fractureCellToWellRadialTrans(double fractureCellConductivity, + double fractureCellSizeX, + double fractureCellSizeZ, + double wellRadius, + double skinFactor, + double cDarcyForRelevantUnit); + + static double fractureCellToWellLinearTrans(double fractureConductivity, + double fractureCellSizeX, + double fractureCellSizeZ, + double perforationLengthVertical, + double perforationLengthHorizontal, + double perforationEfficiency, + double skinfactor, + double cDarcyForRelevantUnit); + + static double matrixToFractureTrans(double permX, + double NTG, + double Ay, + double dx, + double skinfactor, + double fractureAreaWeightedlength, + double cDarcy); +private: + static double centerToEdgeFractureCellTrans(double conductivity, + double sideLengthParallellTrans, + double sideLengthNormalTrans, + double cDarcyForRelevantUnit); + + +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h b/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h index e8277cdd3c..7664b5f87c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h @@ -28,6 +28,9 @@ class RigMainGrid; class RimStimPlanFractureTemplate; class RigFractureGrid; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigTransmissibilityCondenser { public: From 965deeb67abda047dbf4ba70e97b14de65f3fb51 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 07:42:19 +0100 Subject: [PATCH 0180/1027] #2425 Export Completions : Separated feature UI from app logic --- .../RicfExportSimWellCompletions.cpp | 2 +- .../RicfExportWellPathCompletions.cpp | 2 +- .../RicExportFishbonesWellSegmentsFeature.cpp | 2 +- ...sTransmissibilityCalculationFeatureImp.cpp | 12 +-- ...RicWellPathExportCompletionDataFeature.cpp | 98 +++++++++---------- .../RicWellPathExportCompletionDataFeature.h | 30 ++++-- 6 files changed, 76 insertions(+), 70 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 4289ec3bf9..9e70b90452 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -127,5 +127,5 @@ void RicfExportSimWellCompletions::execute() std::vector wellPaths; - RicWellPathExportCompletionDataFeature::exportCompletions(wellPaths, simWells, *exportSettings); + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index b5936e5bb8..acbc9f493e 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -116,5 +116,5 @@ void RicfExportWellPathCompletions::execute() std::vector simWells; - RicWellPathExportCompletionDataFeature::exportCompletions(wellPaths, simWells, *exportSettings); + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp index 21bfed8804..17aee81b0c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -175,7 +175,7 @@ void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath return; } - std::vector locations = RicWellPathExportCompletionDataFeature::findWellSegmentLocations(settings.caseToApply, wellPath, fishbonesSubs); + std::vector locations = RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(settings.caseToApply, wellPath, fishbonesSubs); QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 11aa06b4c8..d4e5c2af3b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -61,7 +61,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell { // Generate data const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); - std::vector locations = RicWellPathExportCompletionDataFeature::findWellSegmentLocations(settings.caseToApply, wellPath); + std::vector locations = RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(settings.caseToApply, wellPath); RiaEclipseUnitTools::UnitSystem unitSystem = caseData->unitsType(); bool isMainBore = false; @@ -126,7 +126,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp } else { - mainBoreDirection = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, + mainBoreDirection = RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(settings.caseToApply, globalCellIndex, wellBorePart.lengthsInCell); } @@ -140,7 +140,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp if (wellBorePart.isMainBore) { //No change in transmissibility for main bore - transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, + transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, wellPath, wellBorePart.lengthsInCell, wellBorePart.skinFactor, @@ -152,7 +152,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp else { //Adjust transmissibility for fishbone laterals - transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, + transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, wellPath, wellBorePart.lengthsInCell, wellBorePart.skinFactor, @@ -164,7 +164,7 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp } - CellDirection direction = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, + CellDirection direction = RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(settings.caseToApply, globalCellIndex, wellBorePart.lengthsInCell); @@ -190,7 +190,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); - std::set wellPathCells = RicWellPathExportCompletionDataFeature::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), + std::set wellPathCells = RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), wellPath->wellPathGeometry()->m_wellPathPoints); bool isMainBore = false; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index b35aa8b42f..b0331130aa 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -154,7 +154,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) { RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); - exportCompletions(wellPaths, simWells, *exportSettings); + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } } @@ -230,10 +230,33 @@ std::vector RicWellPathExportCompletionDataFeature::selectedS return simWells; } + + + + + + + + + + + + + + + + + + + + + + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector& wellPaths, +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings) { @@ -476,7 +499,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector //================================================================================================== /// //================================================================================================== -RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellCompletions(const std::vector& completions, +RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings) { CVF_ASSERT(!completions.empty()); @@ -551,7 +574,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { //calculate trans for main bore - but as Eclipse will do it! - double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), + double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), skinfactor, wellBoreDiameter / 2, cellIndexIJK.globalCellIndex(), @@ -571,7 +594,7 @@ RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellComp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFiles(const QString& folderName, +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) @@ -620,7 +643,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFiles(const QStri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& folderName, +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType) @@ -670,7 +693,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::getCompletionsForWellAndCompletionType(const std::vector& completions, +std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType) { @@ -688,7 +711,7 @@ std::vector RicWellPathExportCompletionDataFeature::getComple //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) +std::map > RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) { std::map > wellCompletions; @@ -709,7 +732,7 @@ std::map > RicWellPath //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) +void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) { std::vector header; @@ -829,7 +852,7 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseDataTableFormatter& formatter, +void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) { @@ -885,7 +908,7 @@ void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) +std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); @@ -912,7 +935,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); - double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, + double transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, wellPath, cell.intersectionLengthsInCellCS, interval->skinFactor(), @@ -938,7 +961,7 @@ std::vector RicWellPathExportCompletionDataFeature::generateP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RicWellPathExportCompletionDataFeature::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) +std::set RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) { std::set cells; @@ -951,31 +974,10 @@ std::set RicWellPathExportCompletionDataFeature::findIntersectedCells(co return cells; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::markWellPathCells(const std::vector& wellPathCells, std::vector* locations) -{ - std::set wellPathCellSet(wellPathCells.begin(), wellPathCells.end()); - for (WellSegmentLocation& location : *locations) - { - for (WellSegmentLateral& lateral : location.laterals) - { - for (WellSegmentLateralIntersection& intersection : lateral.intersections) - { - if (wellPathCellSet.find(intersection.globalCellIndex) != wellPathCellSet.end()) - { - intersection.mainBoreCell = true; - } - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) +bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) { return first.measuredDepth < second.measuredDepth; } @@ -983,17 +985,7 @@ bool RicWellPathExportCompletionDataFeature::wellSegmentLocationOrdering(const W //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::isPointBetween(const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint, const cvf::Vec3d& pointToCheck) -{ - cvf::Plane plane; - plane.setFromPointAndNormal(pointToCheck, endPoint - startPoint); - return plane.side(startPoint) != plane.side(endPoint); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) { std::vector fishbonesSubs; @@ -1014,7 +1006,7 @@ std::vector RicWellPathExportCompletionDataFeature::findWel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) { std::vector wellSegmentLocations; for (RimFishbonesMultipleSubs* subs : fishbonesSubs) @@ -1041,7 +1033,7 @@ std::vector RicWellPathExportCompletionDataFeature::findWel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::assignLateralIntersections(const RimEclipseCase* caseToApply, +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum) @@ -1099,7 +1091,7 @@ void RicWellPathExportCompletionDataFeature::assignLateralIntersections(const Ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) { int segmentNumber = 1; int branchNumber = 1; @@ -1122,7 +1114,7 @@ void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranch //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map >* completionData, const std::vector& data) +void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData(std::map >* completionData, const std::vector& data) { for (auto& completion : data) { @@ -1141,7 +1133,7 @@ void RicWellPathExportCompletionDataFeature::appendCompletionData(std::mapeclipseCaseData(); @@ -1173,7 +1165,7 @@ CellDirection RicWellPathExportCompletionDataFeature::calculateDirectionInCell(R //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEclipseCase* eclipseCase, +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, const cvf::Vec3d& internalCellLengths, double skinFactor, @@ -1235,7 +1227,7 @@ double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEcli //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, double wellRadius, size_t globalCellIndex, diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index 1f700c0459..314916ffc1 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -118,12 +118,30 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; +private: + std::vector selectedWellPaths(); + std::vector selectedSimWells(); + + bool noWellPathsSelectedDirectly(); +}; + + + + + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathExportCompletionDataFeatureImpl +{ + public: static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); - //functions also used by RicFishbonesTransmissibilityCalculationFeatureImp + // TODO : Move static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); + static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); static double calculateTransmissibility(RimEclipseCase* eclipseCase, @@ -140,24 +158,21 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); private: - std::vector selectedWellPaths(); - std::vector selectedSimWells(); - - bool noWellPathsSelectedDirectly(); - static void markWellPathCells(const std::vector& wellPathCells, std::vector* locations); - static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, double wellRadius, size_t globalCellIndex, CellDirection direction); + static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); static void printCompletionsToFiles(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); + static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); @@ -166,7 +181,6 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); - static bool isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle); static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); From c04ef6bbbf733e5afc8c25bc5dc6ddd9a79611a8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 07:55:24 +0100 Subject: [PATCH 0181/1027] #2425 Export Completions : Move app logic into separate file --- .../RicfExportSimWellCompletions.cpp | 2 +- .../RicfExportWellPathCompletions.cpp | 2 +- .../CMakeLists_files.cmake | 2 + .../RicExportFishbonesWellSegmentsFeature.h | 2 +- ...sTransmissibilityCalculationFeatureImp.cpp | 2 +- ...RicWellPathExportCompletionDataFeature.cpp | 1037 +--------------- .../RicWellPathExportCompletionDataFeature.h | 128 -- ...ellPathExportCompletionDataFeatureImpl.cpp | 1103 +++++++++++++++++ ...cWellPathExportCompletionDataFeatureImpl.h | 168 +++ 9 files changed, 1278 insertions(+), 1168 deletions(-) create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 9e70b90452..15f917e0e2 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -35,7 +35,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" CAF_PDM_SOURCE_INIT(RicfExportSimWellCompletions, "exportSimWellCompletions"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index acbc9f493e..3e89a57d98 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -31,7 +31,7 @@ #include "RimWellPathCollection.h" #include "RimWellPath.h" -#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" CAF_PDM_SOURCE_INIT(RicfExportWellPathCompletions, "exportWellPathCompletions"); diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 0290009c87..647b7d6ba0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -7,6 +7,7 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h +${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeatureImpl.h ${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h ${CEE_CURRENT_LIST_DIR}RigCompletionData.h ${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h @@ -28,6 +29,7 @@ endif() set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp +${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeatureImpl.cpp ${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp ${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp ${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h index 13b8409cc3..fe125abb2c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h @@ -21,7 +21,7 @@ #include "RifEclipseDataTableFormatter.h" #include "RicCaseAndFileExportSettingsUi.h" -#include "RicWellPathExportCompletionDataFeature.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" #include "cafCmdFeature.h" diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index d4e5c2af3b..08acd6925d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -19,7 +19,7 @@ #include "RicFishbonesTransmissibilityCalculationFeatureImp.h" #include "RicExportCompletionDataSettingsUi.h" -#include "RicWellPathExportCompletionDataFeature.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" #include "RigActiveCellInfo.h" #include "RigCompletionData.h" diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index b0331130aa..6c9f251c14 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RicWellPathExportCompletionDataFeature.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" #include "RiaApplication.h" #include "RiaLogging.h" @@ -247,1039 +248,3 @@ std::vector RicWellPathExportCompletionDataFeature::selectedS - - - - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, - const std::vector& simWells, - const RicExportCompletionDataSettingsUi& exportSettings) -{ - if (exportSettings.caseToApply() == nullptr) - { - RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case"); - return; - } - - std::vector usedWellPaths; - if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS - || exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) - { - usedWellPaths = wellPaths; - } - else if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::CHECKED_WELLS) - { - for (auto wellPath : wellPaths) - { - if (wellPath->showWellPath) - { - usedWellPaths.push_back(wellPath); - } - } - } - - { - bool unitSystemMismatch = false; - for (const RimWellPath* wellPath : usedWellPaths) - { - if (wellPath->unitSystem() != exportSettings.caseToApply->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } - } - - for (const RimSimWellInView* simWell : simWells) - { - RimEclipseCase* eclipseCase; - simWell->firstAncestorOrThisOfType(eclipseCase); - if (exportSettings.caseToApply->eclipseCaseData()->unitsType() != eclipseCase->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } - } - if (unitSystemMismatch) - { - RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); - return; - } - } - - std::map > completionsPerEclipseCell; - - // FractureTransmissibilityExportInformation - std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; - - QString fractureTransmisibillityExportInformationPath = QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); - QFile fractureTransmissibilityExportInformationFile(fractureTransmisibillityExportInformationPath); - - RiaPreferences* prefs = RiaApplication::instance()->preferences(); - if (prefs->includeFractureDebugInfoFile()) - { - if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) - { - RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(fractureTransmisibillityExportInformationPath)); - return; - } - - fractureTransmissibilityExportInformationStream = std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); - } - - size_t maxProgress = - usedWellPaths.size() * 3 + -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - simWells.size() + -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + - simWells.size(); - - caf::ProgressInfo progress(maxProgress, "Export Completions"); - - progress.setProgressDescription("Read Completion Data"); - for (auto wellPath : usedWellPaths) - { - // Generate completion data - - if (exportSettings.includePerforations) - { - std::vector perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, perforationCompletionData); - } - progress.incrementProgress(); - - if (exportSettings.includeFishbones) - { - std::vector fishbonesCompletionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, fishbonesCompletionData); - } - progress.incrementProgress(); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - if (exportSettings.includeFractures()) - { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); - appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - progress.incrementProgress(); - } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - for (auto simWell : simWells) - { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(exportSettings.caseToApply(), - simWell, - fractureTransmissibilityExportInformationStream.get()); - appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); - progress.incrementProgress(); - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); - - progress.setProgressDescription("Write Export Files"); - if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE) - { - std::vector completions; - for (auto& data : completionsPerEclipseCell) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - - const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, completions, exportSettings.compdatExport); - progress.incrementProgress(); - } - else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) - { - for (auto wellPath : usedWellPaths) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - std::vector wellCompletions; - for (auto completion : completions) - { - if (completion.wellName() == wellPath->completions()->wellNameForExport()) - { - wellCompletions.push_back(completion); - } - } - - if (wellCompletions.empty()) continue; - - QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); - progress.incrementProgress(); - } - } - else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) - { - for (auto wellPath : usedWellPaths) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - { - std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); - if (!fishbonesCompletions.empty()) - { - QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - { - std::vector perforationCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); - if (!perforationCompletions.empty()) - { - QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - { - std::vector fractureCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); - if (!fractureCompletions.empty()) - { - QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - } - } - - // Export sim wells - if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) - { - for (auto simWell : simWells) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - std::vector wellCompletions; - for (auto completion : completions) - { - if (completion.wellName() == simWell->name()) - { - wellCompletions.push_back(completion); - } - } - - if (wellCompletions.empty()) continue; - - QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? - QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) : - QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); - progress.incrementProgress(); - } - } - -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, - const RicExportCompletionDataSettingsUi& settings) -{ - CVF_ASSERT(!completions.empty()); - QString wellName = completions[0].wellName(); - RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); - RigCompletionData::CompletionType completionType = completions[0].completionType(); - - //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, - //if no main bore they are taken from first completion - double skinfactor = completions[0].skinFactor(); - double wellBoreDiameter = completions[0].diameter(); - CellDirection cellDirection = completions[0].direction(); - - for (const RigCompletionData& completion : completions) - { - if (completion.isMainBore()) - { - skinfactor = completion.skinFactor(); - wellBoreDiameter = completion.diameter(); - cellDirection = completion.direction(); - break; - } - } - - - RigCompletionData resultCompletion(wellName, cellIndexIJK); - - double totalTrans = 0.0; - - for (const RigCompletionData& completion : completions) - { - resultCompletion.m_metadata.reserve(resultCompletion.m_metadata.size() + completion.m_metadata.size()); - resultCompletion.m_metadata.insert(resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); - - if (completion.completionType() != completions[0].completionType()) - { - QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - if (completion.wellName() != completions[0].wellName()) - { - QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - if (completion.transmissibility() == HUGE_VAL) - { - QString errorMessage = QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - if (settings.excludeMainBoreForFishbones && completionType == RigCompletionData::FISHBONES && completion.isMainBore()) - { - continue; - } - - totalTrans = totalTrans + completion.transmissibility(); - } - - - if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) - { - resultCompletion.setCombinedValuesExplicitTrans(totalTrans, completionType); - } - else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) - { - //calculate trans for main bore - but as Eclipse will do it! - double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), - skinfactor, - wellBoreDiameter / 2, - cellIndexIJK.globalCellIndex(), - cellDirection); - - double wpimult = totalTrans / transmissibilityEclipseCalculation; - resultCompletion.setCombinedValuesImplicitTransWPImult(wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); - } - - return resultCompletion; -} - - - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const QString& folderName, - const QString& fileName, - std::vector& completions, - RicExportCompletionDataSettingsUi::CompdatExportType exportType) -{ - // Sort completions based on grid they belong to - std::vector completionsForMainGrid; - - std::map> completionsForSubGrids; - - for (const auto& completion : completions) - { - QString gridName = completion.completionDataGridCell().lgrName(); - if (gridName.isEmpty()) - { - completionsForMainGrid.push_back(completion); - } - else - { - auto it = completionsForSubGrids.find(gridName); - if (it == completionsForSubGrids.end()) - { - completionsForSubGrids.insert(std::pair>(gridName, std::vector{completion})); - } - else - { - it->second.push_back(completion); - } - } - } - - if (!completionsForMainGrid.empty()) - { - std::map> completionsForGrid; - completionsForGrid.insert(std::pair>("", completionsForMainGrid)); - - printCompletionsToFile(folderName, fileName, completionsForGrid, exportType); - } - - if (!completionsForSubGrids.empty()) - { - QString lgrFileName = fileName + "_LGR"; - printCompletionsToFile(folderName, lgrFileName, completionsForSubGrids, exportType); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QString& folderName, - const QString& fileName, - const std::map>& completionsPerGrid, - RicExportCompletionDataSettingsUi::CompdatExportType exportType) -{ - if (completionsPerGrid.empty()) return; - - QDir exportFolder(folderName); - - if (!exportFolder.exists()) - { - bool createdPath = exportFolder.mkpath(folderName); - if (createdPath) RiaLogging::info("Created export folder " + folderName); - else RiaLogging::error("Selected output folder does not exist, and could not be created."); - } - - QString filePath = exportFolder.filePath(fileName); - QFile exportFile(filePath); - if (!exportFile.open(QIODevice::WriteOnly)) - { - RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); - return; - } - - QTextStream stream(&exportFile); - RifEclipseDataTableFormatter formatter(stream); - - for (const auto& gridCompletions : completionsPerGrid) - { - std::vector completions = gridCompletions.second; - - // Sort by well name / cell index - std::sort(completions.begin(), completions.end()); - - // Print completion data - QString gridName = gridCompletions.first; - generateCompdatTable(formatter, gridName, completions); - - if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) - { - generateWpimultTable(formatter, gridName, completions); - } - } - - RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType(const std::vector& completions, - const QString& wellName, - RigCompletionData::CompletionType completionType) -{ - std::vector filteredCompletions; - for (auto completion : completions) - { - if (completion.wellName() == wellName && completion.completionType() == completionType) - { - filteredCompletions.push_back(completion); - } - } - return filteredCompletions; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map > RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) -{ - std::map > wellCompletions; - - for (const auto& it : cellToCompletionMap) - { - for (auto& completion : it.second) - { - if (completion.wellName() == wellName) - { - wellCompletions[it.first].push_back(completion); - } - } - } - - return wellCompletions; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) -{ - std::vector header; - - if (gridName.isEmpty()) - { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; - - formatter.keyword("COMPDAT"); - } - else - { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("LgrName"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; - - formatter.keyword("COMPDATL"); - } - formatter.header(header); - - for (const RigCompletionData& data : completionData) - { - if (data.transmissibility() == 0.0 || data.wpimult()==0.0) - { - //Don't export completions without transmissibility - continue; - } - - for (const RigCompletionMetaData& metadata : data.metadata()) - { - formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); - } - formatter.add(data.wellName()); - - if (!gridName.isEmpty()) - { - formatter.add(gridName); - } - - formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); - switch (data.connectionState()) - { - case OPEN: - formatter.add("OPEN"); - break; - case SHUT: - formatter.add("SHUT"); - break; - case AUTO: - formatter.add("AUTO"); - break; - } - if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); - if (RigCompletionData::isDefaultValue(data.transmissibility())) - { - formatter.add("1*"); // Transmissibility - - if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); else formatter.add(data.diameter()); - if (RigCompletionData::isDefaultValue(data.kh())) formatter.add("1*"); else formatter.add(data.kh()); - if (RigCompletionData::isDefaultValue(data.skinFactor())) formatter.add("1*"); else formatter.add(data.skinFactor()); - if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else formatter.add(data.dFactor()); - - switch (data.direction()) - { - case DIR_I: - formatter.add("'X'"); - break; - case DIR_J: - formatter.add("'Y'"); - break; - case DIR_K: - formatter.add("'Z'"); - break; - default: - formatter.add("'Z'"); - break; - } - } - else - { - formatter.add(data.transmissibility()); - } - - formatter.rowCompleted(); - } - formatter.tableCompleted(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, - const QString& gridName, - const std::vector& completionData) -{ - std::vector header; - - if (gridName.isEmpty()) - { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("Mult"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K"), - }; - formatter.keyword("WPIMULT"); - } - else - { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("LgrName"), - RifEclipseOutputTableColumn("Mult"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K"), - }; - formatter.keyword("WPIMULTL"); - } - formatter.header(header); - - for (auto& completion : completionData) - { - if (completion.wpimult() == 0.0 || completion.isDefaultValue(completion.wpimult())) - { - continue; - } - - formatter.add(completion.wellName()); - formatter.add(completion.wpimult()); - - if (!gridName.isEmpty()) - { - formatter.add(gridName); - } - - formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); - formatter.rowCompleted(); - } - - formatter.tableCompleted(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) -{ - RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); - - std::vector completionData; - const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); - - if (wellPath->perforationIntervalCollection()->isChecked()) - { - for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) - { - if (!interval->isChecked()) continue; - if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue; - - using namespace std; - pair, vector > perforationPointsAndMD = wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); - std::vector intersectedCells = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(settings.caseToApply->eclipseCaseData(), - perforationPointsAndMD.first, - perforationPointsAndMD.second); - for (auto& cell : intersectedCells) - { - bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); - if (!cellIsActive) continue; - - RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); - CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); - - double transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, - wellPath, - cell.intersectionLengthsInCellCS, - interval->skinFactor(), - interval->diameter(unitSystem) / 2, - cell.globCellIndex, - settings.useLateralNTG); - - - - completion.setTransAndWPImultBackgroundDataFromPerforation(transmissibility, - interval->skinFactor(), - interval->diameter(unitSystem), - direction); - completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + QString(" : ") + QString::number(transmissibility)); - completionData.push_back(completion); - } - } - } - - return completionData; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) -{ - std::set cells; - - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); - for (auto intersection : intersections) - { - cells.insert(intersection.m_hexIndex); - } - - return cells; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) -{ - return first.measuredDepth < second.measuredDepth; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) -{ - std::vector fishbonesSubs; - - if (wellPath->fishbonesCollection()->isChecked()) - { - for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs()) - { - if (subs->isActive()) - { - fishbonesSubs.push_back(subs); - } - } - } - - return findWellSegmentLocations(caseToApply, wellPath, fishbonesSubs); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) -{ - std::vector wellSegmentLocations; - for (RimFishbonesMultipleSubs* subs : fishbonesSubs) - { - for (auto& sub : subs->installedLateralIndices()) - { - double measuredDepth = subs->measuredDepth(sub.subIndex); - cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); - WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); - for (size_t lateralIndex : sub.lateralIndices) - { - location.laterals.push_back(WellSegmentLateral(lateralIndex)); - } - wellSegmentLocations.push_back(location); - } - } - std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering); - - assignLateralIntersectionsAndBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); - - return wellSegmentLocations; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, - WellSegmentLocation* location, - int* branchNum, - int* segmentNum) -{ - for (WellSegmentLateral& lateral : location->laterals) - { - ++(*branchNum); - lateral.branchNumber = (*branchNum); - - std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); - - if ( !lateralCoordMDPairs.size() ) - { - continue; - } - - std::vector lateralCoords; - std::vector lateralMDs; - - lateralCoords.reserve(lateralCoordMDPairs.size()); - lateralMDs.reserve(lateralCoordMDPairs.size()); - - for (auto& coordMD : lateralCoordMDPairs) - { - lateralCoords.push_back(coordMD.first); - lateralMDs.push_back(coordMD.second); - } - - std::vector intersections = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(caseToApply->eclipseCaseData(), - lateralCoords, - lateralMDs); - double previousExitMD = lateralMDs.front(); - double previousExitTVD = lateralCoords.front().z(); - - int attachedSegmentNumber = location->icdSegmentNumber; - for (const auto& cellIntInfo: intersections) - { - ++(*segmentNum); - WellSegmentLateralIntersection lateralIntersection((*segmentNum), - attachedSegmentNumber, - cellIntInfo.globCellIndex, - cellIntInfo.endMD - previousExitMD, - cellIntInfo.endPoint.z() - previousExitTVD, - cellIntInfo.intersectionLengthsInCellCS); - - lateral.intersections.push_back(lateralIntersection); - - attachedSegmentNumber = (*segmentNum); - previousExitMD = cellIntInfo.endMD; - previousExitTVD = cellIntInfo.endPoint.z(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) -{ - int segmentNumber = 1; - int branchNumber = 1; - - // First loop over the locations so that each segment on the main stem is an incremental number - for (WellSegmentLocation& location : *locations) - { - location.segmentNumber = ++segmentNumber; - location.icdBranchNumber = ++branchNumber; - location.icdSegmentNumber = ++segmentNumber; - } - - // Then assign branch and segment numbers to each lateral parts - for (WellSegmentLocation& location : *locations) - { - assignLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData(std::map >* completionData, const std::vector& data) -{ - for (auto& completion : data) - { - auto it = completionData->find(completion.completionDataGridCell()); - if (it != completionData->end()) - { - it->second.push_back(completion); - } - else - { - completionData->insert(std::pair >(completion.completionDataGridCell(), std::vector {completion})); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(globalCellIndex)); - double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(globalCellIndex)); - double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(globalCellIndex)); - - if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction) - { - return CellDirection::DIR_I; - } - else if (yLengthFraction > xLengthFraction && yLengthFraction > zLengthFraction) - { - return CellDirection::DIR_J; - } - else - { - return CellDirection::DIR_K; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - const cvf::Vec3d& internalCellLengths, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - bool useLateralNTG, - size_t volumeScaleConstant, - CellDirection directionForVolumeScaling) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); - if (ntgResIdx != cvf::UNDEFINED_SIZE_T) - { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); - } - double latNtg = useLateralNTG ? ntg : 1.0; - - double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); - - double darcy = RiaEclipseUnitTools::darcysConstant(wellPath->unitSystem()); - - if (volumeScaleConstant != 1) - { - if (directionForVolumeScaling == CellDirection::DIR_I) dx = dx / volumeScaleConstant; - if (directionForVolumeScaling == CellDirection::DIR_J) dy = dy / volumeScaleConstant; - if (directionForVolumeScaling == CellDirection::DIR_K) dz = dz / volumeScaleConstant; - } - - double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); - double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); - double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); - - return RigTransmissibilityEquations::totalConnectionFactor(transx, transy, transz); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - CellDirection direction) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); - if (ntgResIdx != cvf::UNDEFINED_SIZE_T) - { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); - } - - double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); - - RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); - double darcy = RiaEclipseUnitTools::darcysConstant(units); - - double trans = cvf::UNDEFINED_DOUBLE; - if (direction == CellDirection::DIR_I) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); - } - else if (direction == CellDirection::DIR_J) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); - } - else if (direction == CellDirection::DIR_K) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); - } - - return trans; -} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index 314916ffc1..aba8591a30 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -39,73 +39,6 @@ class RimFishbonesMultipleSubs; class RimSimWellInView; class RimWellPath; -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLateralIntersection { - WellSegmentLateralIntersection(int segmentNumber, - int attachedSegmentNumber, - size_t globalCellIndex, - double length, - double depth, - const cvf::Vec3d& lengthsInCell) - : segmentNumber(segmentNumber), - attachedSegmentNumber(attachedSegmentNumber), - globalCellIndex(globalCellIndex), - mdFromPreviousIntersection(length), - tvdChangeFromPreviousIntersection(depth), - lengthsInCell(lengthsInCell), - mainBoreCell(false) - {} - - int segmentNumber; - int attachedSegmentNumber; - size_t globalCellIndex; - bool mainBoreCell; - double mdFromPreviousIntersection; - double tvdChangeFromPreviousIntersection; - cvf::Vec3d lengthsInCell; -}; - -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLateral { - WellSegmentLateral(size_t lateralIndex) - : lateralIndex(lateralIndex), - branchNumber(0) - {} - - size_t lateralIndex; - int branchNumber; - std::vector intersections; -}; - -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLocation { - WellSegmentLocation(const RimFishbonesMultipleSubs* subs, double measuredDepth, double trueVerticalDepth, size_t subIndex, int segmentNumber = -1) - : fishbonesSubs(subs), - measuredDepth(measuredDepth), - trueVerticalDepth(trueVerticalDepth), - subIndex(subIndex), - segmentNumber(segmentNumber), - icdBranchNumber(-1), - icdSegmentNumber(-1) - { - } - - const RimFishbonesMultipleSubs* fishbonesSubs; - double measuredDepth; - double trueVerticalDepth; - size_t subIndex; - int segmentNumber; - int icdBranchNumber; - int icdSegmentNumber; - std::vector laterals; -}; - //================================================================================================== /// //================================================================================================== @@ -126,64 +59,3 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature }; - - - -//================================================================================================== -/// -//================================================================================================== -class RicWellPathExportCompletionDataFeatureImpl -{ - -public: - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); - - // TODO : Move - static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); - - static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); - - static double calculateTransmissibility(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - const cvf::Vec3d& internalCellLengths, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - bool useLateralNTG, - size_t volumeScaleConstant = 1, - CellDirection directionForVolumeScaling = CellDirection::DIR_I); - - - static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); - -private: - static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - CellDirection direction); - - static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, - const RicExportCompletionDataSettingsUi& settings); - - static void printCompletionsToFiles(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - - static void printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - - static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); - - static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); - static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); - - static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); - - static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); - static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); - static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); - - static void appendCompletionData(std::map >* completionData, const std::vector& data); -}; - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp new file mode 100644 index 0000000000..07ab32530d --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -0,0 +1,1103 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "RicExportCompletionDataSettingsUi.h" +#include "RicExportFeatureImpl.h" +#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" +#include "RicExportFractureCompletionsImpl.h" + +#include "RigActiveCellInfo.h" +#include "RigCaseCellResultsData.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" +#include "RigResultAccessorFactory.h" + +#include "RigTransmissibilityEquations.h" + +#include "RigWellLogExtractionTools.h" +#include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" + +#include "RimDialogData.h" +#include "RimSimWellInViewCollection.h" +#include "RimFishboneWellPath.h" +#include "RimFishboneWellPathCollection.h" +#include "RimFishbonesCollection.h" +#include "RimFishbonesMultipleSubs.h" +#include "RimPerforationCollection.h" +#include "RimPerforationInterval.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RimWellPathCompletions.h" + +#include "RiuMainWindow.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManager.h" + +#include "cvfPlane.h" + +#include +#include +#include +#include +#include "RigWellLogExtractor.h" + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, + const RicExportCompletionDataSettingsUi& exportSettings) +{ + if (exportSettings.caseToApply() == nullptr) + { + RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case"); + return; + } + + std::vector usedWellPaths; + if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS + || exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) + { + usedWellPaths = wellPaths; + } + else if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::CHECKED_WELLS) + { + for (auto wellPath : wellPaths) + { + if (wellPath->showWellPath) + { + usedWellPaths.push_back(wellPath); + } + } + } + + { + bool unitSystemMismatch = false; + for (const RimWellPath* wellPath : usedWellPaths) + { + if (wellPath->unitSystem() != exportSettings.caseToApply->eclipseCaseData()->unitsType()) + { + unitSystemMismatch = true; + break; + } + } + + for (const RimSimWellInView* simWell : simWells) + { + RimEclipseCase* eclipseCase; + simWell->firstAncestorOrThisOfType(eclipseCase); + if (exportSettings.caseToApply->eclipseCaseData()->unitsType() != eclipseCase->eclipseCaseData()->unitsType()) + { + unitSystemMismatch = true; + break; + } + } + if (unitSystemMismatch) + { + RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); + return; + } + } + + std::map > completionsPerEclipseCell; + + // FractureTransmissibilityExportInformation + std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; + + QString fractureTransmisibillityExportInformationPath = QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); + QFile fractureTransmissibilityExportInformationFile(fractureTransmisibillityExportInformationPath); + + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + if (prefs->includeFractureDebugInfoFile()) + { + if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) + { + RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(fractureTransmisibillityExportInformationPath)); + return; + } + + fractureTransmissibilityExportInformationStream = std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); + } + + size_t maxProgress = + usedWellPaths.size() * 3 + +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + simWells.size() + +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : + exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + + simWells.size(); + + caf::ProgressInfo progress(maxProgress, "Export Completions"); + + progress.setProgressDescription("Read Completion Data"); + for (auto wellPath : usedWellPaths) + { + // Generate completion data + + if (exportSettings.includePerforations) + { + std::vector perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings); + appendCompletionData(&completionsPerEclipseCell, perforationCompletionData); + } + progress.incrementProgress(); + + if (exportSettings.includeFishbones) + { + std::vector fishbonesCompletionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(wellPath, exportSettings); + appendCompletionData(&completionsPerEclipseCell, fishbonesCompletionData); + } + progress.incrementProgress(); + +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + if (exportSettings.includeFractures()) + { + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); + appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); + } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + progress.incrementProgress(); + } + +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + for (auto simWell : simWells) + { + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(exportSettings.caseToApply(), + simWell, + fractureTransmissibilityExportInformationStream.get()); + appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); + progress.incrementProgress(); + } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + + const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); + + progress.setProgressDescription("Write Export Files"); + if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE) + { + std::vector completions; + for (auto& data : completionsPerEclipseCell) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, completions, exportSettings.compdatExport); + progress.incrementProgress(); + } + else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) + { + for (auto wellPath : usedWellPaths) + { + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::vector completions; + for (auto& data : filteredWellCompletions) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + std::vector wellCompletions; + for (auto completion : completions) + { + if (completion.wellName() == wellPath->completions()->wellNameForExport()) + { + wellCompletions.push_back(completion); + } + } + + if (wellCompletions.empty()) continue; + + QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + progress.incrementProgress(); + } + } + else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) + { + for (auto wellPath : usedWellPaths) + { + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::vector completions; + for (auto& data : filteredWellCompletions) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + { + std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); + if (!fishbonesCompletions.empty()) + { + QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); + } + progress.incrementProgress(); + } + { + std::vector perforationCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); + if (!perforationCompletions.empty()) + { + QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); + } + progress.incrementProgress(); + } + { + std::vector fractureCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); + if (!fractureCompletions.empty()) + { + QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); + } + progress.incrementProgress(); + } + } + } + + // Export sim wells + if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || + exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) + { + for (auto simWell : simWells) + { + std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); + std::vector completions; + for (auto& data : filteredWellCompletions) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + std::vector wellCompletions; + for (auto completion : completions) + { + if (completion.wellName() == simWell->name()) + { + wellCompletions.push_back(completion); + } + } + + if (wellCompletions.empty()) continue; + + QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? + QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) : + QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); + printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + progress.incrementProgress(); + } + } + +} + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, + const RicExportCompletionDataSettingsUi& settings) +{ + CVF_ASSERT(!completions.empty()); + QString wellName = completions[0].wellName(); + RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); + RigCompletionData::CompletionType completionType = completions[0].completionType(); + + //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, + //if no main bore they are taken from first completion + double skinfactor = completions[0].skinFactor(); + double wellBoreDiameter = completions[0].diameter(); + CellDirection cellDirection = completions[0].direction(); + + for (const RigCompletionData& completion : completions) + { + if (completion.isMainBore()) + { + skinfactor = completion.skinFactor(); + wellBoreDiameter = completion.diameter(); + cellDirection = completion.direction(); + break; + } + } + + + RigCompletionData resultCompletion(wellName, cellIndexIJK); + + double totalTrans = 0.0; + + for (const RigCompletionData& completion : completions) + { + resultCompletion.m_metadata.reserve(resultCompletion.m_metadata.size() + completion.m_metadata.size()); + resultCompletion.m_metadata.insert(resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); + + if (completion.completionType() != completions[0].completionType()) + { + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; //Returning empty completion, should not be exported + } + + if (completion.wellName() != completions[0].wellName()) + { + QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; //Returning empty completion, should not be exported + } + + if (completion.transmissibility() == HUGE_VAL) + { + QString errorMessage = QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; //Returning empty completion, should not be exported + } + + if (settings.excludeMainBoreForFishbones && completionType == RigCompletionData::FISHBONES && completion.isMainBore()) + { + continue; + } + + totalTrans = totalTrans + completion.transmissibility(); + } + + + if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) + { + resultCompletion.setCombinedValuesExplicitTrans(totalTrans, completionType); + } + else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + //calculate trans for main bore - but as Eclipse will do it! + double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), + skinfactor, + wellBoreDiameter / 2, + cellIndexIJK.globalCellIndex(), + cellDirection); + + double wpimult = totalTrans / transmissibilityEclipseCalculation; + resultCompletion.setCombinedValuesImplicitTransWPImult(wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); + } + + return resultCompletion; +} + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const QString& folderName, + const QString& fileName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + // Sort completions based on grid they belong to + std::vector completionsForMainGrid; + + std::map> completionsForSubGrids; + + for (const auto& completion : completions) + { + QString gridName = completion.completionDataGridCell().lgrName(); + if (gridName.isEmpty()) + { + completionsForMainGrid.push_back(completion); + } + else + { + auto it = completionsForSubGrids.find(gridName); + if (it == completionsForSubGrids.end()) + { + completionsForSubGrids.insert(std::pair>(gridName, std::vector{completion})); + } + else + { + it->second.push_back(completion); + } + } + } + + if (!completionsForMainGrid.empty()) + { + std::map> completionsForGrid; + completionsForGrid.insert(std::pair>("", completionsForMainGrid)); + + printCompletionsToFile(folderName, fileName, completionsForGrid, exportType); + } + + if (!completionsForSubGrids.empty()) + { + QString lgrFileName = fileName + "_LGR"; + printCompletionsToFile(folderName, lgrFileName, completionsForSubGrids, exportType); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QString& folderName, + const QString& fileName, + const std::map>& completionsPerGrid, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + if (completionsPerGrid.empty()) return; + + QDir exportFolder(folderName); + + if (!exportFolder.exists()) + { + bool createdPath = exportFolder.mkpath(folderName); + if (createdPath) RiaLogging::info("Created export folder " + folderName); + else RiaLogging::error("Selected output folder does not exist, and could not be created."); + } + + QString filePath = exportFolder.filePath(fileName); + QFile exportFile(filePath); + if (!exportFile.open(QIODevice::WriteOnly)) + { + RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); + return; + } + + QTextStream stream(&exportFile); + RifEclipseDataTableFormatter formatter(stream); + + for (const auto& gridCompletions : completionsPerGrid) + { + std::vector completions = gridCompletions.second; + + // Sort by well name / cell index + std::sort(completions.begin(), completions.end()); + + // Print completion data + QString gridName = gridCompletions.first; + generateCompdatTable(formatter, gridName, completions); + + if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + generateWpimultTable(formatter, gridName, completions); + } + } + + RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType(const std::vector& completions, + const QString& wellName, + RigCompletionData::CompletionType completionType) +{ + std::vector filteredCompletions; + for (auto completion : completions) + { + if (completion.wellName() == wellName && completion.completionType() == completionType) + { + filteredCompletions.push_back(completion); + } + } + return filteredCompletions; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) +{ + std::map > wellCompletions; + + for (const auto& it : cellToCompletionMap) + { + for (auto& completion : it.second) + { + if (completion.wellName() == wellName) + { + wellCompletions[it.first].push_back(completion); + } + } + } + + return wellCompletions; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) +{ + std::vector header; + + if (gridName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDAT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDATL"); + } + formatter.header(header); + + for (const RigCompletionData& data : completionData) + { + if (data.transmissibility() == 0.0 || data.wpimult()==0.0) + { + //Don't export completions without transmissibility + continue; + } + + for (const RigCompletionMetaData& metadata : data.metadata()) + { + formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); + } + formatter.add(data.wellName()); + + if (!gridName.isEmpty()) + { + formatter.add(gridName); + } + + formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); + switch (data.connectionState()) + { + case OPEN: + formatter.add("OPEN"); + break; + case SHUT: + formatter.add("SHUT"); + break; + case AUTO: + formatter.add("AUTO"); + break; + } + if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); + if (RigCompletionData::isDefaultValue(data.transmissibility())) + { + formatter.add("1*"); // Transmissibility + + if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); else formatter.add(data.diameter()); + if (RigCompletionData::isDefaultValue(data.kh())) formatter.add("1*"); else formatter.add(data.kh()); + if (RigCompletionData::isDefaultValue(data.skinFactor())) formatter.add("1*"); else formatter.add(data.skinFactor()); + if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else formatter.add(data.dFactor()); + + switch (data.direction()) + { + case DIR_I: + formatter.add("'X'"); + break; + case DIR_J: + formatter.add("'Y'"); + break; + case DIR_K: + formatter.add("'Z'"); + break; + default: + formatter.add("'Z'"); + break; + } + } + else + { + formatter.add(data.transmissibility()); + } + + formatter.rowCompleted(); + } + formatter.tableCompleted(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) +{ + std::vector header; + + if (gridName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULTL"); + } + formatter.header(header); + + for (auto& completion : completionData) + { + if (completion.wpimult() == 0.0 || completion.isDefaultValue(completion.wpimult())) + { + continue; + } + + formatter.add(completion.wellName()); + formatter.add(completion.wpimult()); + + if (!gridName.isEmpty()) + { + formatter.add(gridName); + } + + formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); + formatter.rowCompleted(); + } + + formatter.tableCompleted(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) +{ + RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); + + std::vector completionData; + const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); + + if (wellPath->perforationIntervalCollection()->isChecked()) + { + for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) + { + if (!interval->isChecked()) continue; + if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue; + + using namespace std; + pair, vector > perforationPointsAndMD = wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); + std::vector intersectedCells = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(settings.caseToApply->eclipseCaseData(), + perforationPointsAndMD.first, + perforationPointsAndMD.second); + for (auto& cell : intersectedCells) + { + bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); + if (!cellIsActive) continue; + + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); + CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); + + double transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, + wellPath, + cell.intersectionLengthsInCellCS, + interval->skinFactor(), + interval->diameter(unitSystem) / 2, + cell.globCellIndex, + settings.useLateralNTG); + + + + completion.setTransAndWPImultBackgroundDataFromPerforation(transmissibility, + interval->skinFactor(), + interval->diameter(unitSystem), + direction); + completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + QString(" : ") + QString::number(transmissibility)); + completionData.push_back(completion); + } + } + } + + return completionData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) +{ + std::set cells; + + std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); + for (auto intersection : intersections) + { + cells.insert(intersection.m_hexIndex); + } + + return cells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) +{ + return first.measuredDepth < second.measuredDepth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) +{ + std::vector fishbonesSubs; + + if (wellPath->fishbonesCollection()->isChecked()) + { + for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs()) + { + if (subs->isActive()) + { + fishbonesSubs.push_back(subs); + } + } + } + + return findWellSegmentLocations(caseToApply, wellPath, fishbonesSubs); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) +{ + std::vector wellSegmentLocations; + for (RimFishbonesMultipleSubs* subs : fishbonesSubs) + { + for (auto& sub : subs->installedLateralIndices()) + { + double measuredDepth = subs->measuredDepth(sub.subIndex); + cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); + WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); + for (size_t lateralIndex : sub.lateralIndices) + { + location.laterals.push_back(WellSegmentLateral(lateralIndex)); + } + wellSegmentLocations.push_back(location); + } + } + std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering); + + assignLateralIntersectionsAndBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); + + return wellSegmentLocations; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, + WellSegmentLocation* location, + int* branchNum, + int* segmentNum) +{ + for (WellSegmentLateral& lateral : location->laterals) + { + ++(*branchNum); + lateral.branchNumber = (*branchNum); + + std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); + + if ( !lateralCoordMDPairs.size() ) + { + continue; + } + + std::vector lateralCoords; + std::vector lateralMDs; + + lateralCoords.reserve(lateralCoordMDPairs.size()); + lateralMDs.reserve(lateralCoordMDPairs.size()); + + for (auto& coordMD : lateralCoordMDPairs) + { + lateralCoords.push_back(coordMD.first); + lateralMDs.push_back(coordMD.second); + } + + std::vector intersections = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(caseToApply->eclipseCaseData(), + lateralCoords, + lateralMDs); + double previousExitMD = lateralMDs.front(); + double previousExitTVD = lateralCoords.front().z(); + + int attachedSegmentNumber = location->icdSegmentNumber; + for (const auto& cellIntInfo: intersections) + { + ++(*segmentNum); + WellSegmentLateralIntersection lateralIntersection((*segmentNum), + attachedSegmentNumber, + cellIntInfo.globCellIndex, + cellIntInfo.endMD - previousExitMD, + cellIntInfo.endPoint.z() - previousExitTVD, + cellIntInfo.intersectionLengthsInCellCS); + + lateral.intersections.push_back(lateralIntersection); + + attachedSegmentNumber = (*segmentNum); + previousExitMD = cellIntInfo.endMD; + previousExitTVD = cellIntInfo.endPoint.z(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) +{ + int segmentNumber = 1; + int branchNumber = 1; + + // First loop over the locations so that each segment on the main stem is an incremental number + for (WellSegmentLocation& location : *locations) + { + location.segmentNumber = ++segmentNumber; + location.icdBranchNumber = ++branchNumber; + location.icdSegmentNumber = ++segmentNumber; + } + + // Then assign branch and segment numbers to each lateral parts + for (WellSegmentLocation& location : *locations) + { + assignLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData(std::map >* completionData, const std::vector& data) +{ + for (auto& completion : data) + { + auto it = completionData->find(completion.completionDataGridCell()); + if (it != completionData->end()) + { + it->second.push_back(completion); + } + else + { + completionData->insert(std::pair >(completion.completionDataGridCell(), std::vector {completion})); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(globalCellIndex)); + double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(globalCellIndex)); + double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(globalCellIndex)); + + if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction) + { + return CellDirection::DIR_I; + } + else if (yLengthFraction > xLengthFraction && yLengthFraction > zLengthFraction) + { + return CellDirection::DIR_J; + } + else + { + return CellDirection::DIR_K; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + const cvf::Vec3d& internalCellLengths, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + bool useLateralNTG, + size_t volumeScaleConstant, + CellDirection directionForVolumeScaling) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); + cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); + cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); + cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + if (ntgResIdx != cvf::UNDEFINED_SIZE_T) + { + cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); + } + double latNtg = useLateralNTG ? ntg : 1.0; + + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); + + double darcy = RiaEclipseUnitTools::darcysConstant(wellPath->unitSystem()); + + if (volumeScaleConstant != 1) + { + if (directionForVolumeScaling == CellDirection::DIR_I) dx = dx / volumeScaleConstant; + if (directionForVolumeScaling == CellDirection::DIR_J) dy = dy / volumeScaleConstant; + if (directionForVolumeScaling == CellDirection::DIR_K) dz = dz / volumeScaleConstant; + } + + double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + + return RigTransmissibilityEquations::totalConnectionFactor(transx, transy, transz); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + CellDirection direction) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); + cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); + cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); + cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + if (ntgResIdx != cvf::UNDEFINED_SIZE_T) + { + cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); + } + + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); + + RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); + double darcy = RiaEclipseUnitTools::darcysConstant(units); + + double trans = cvf::UNDEFINED_DOUBLE; + if (direction == CellDirection::DIR_I) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + } + else if (direction == CellDirection::DIR_J) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + } + else if (direction == CellDirection::DIR_K) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + } + + return trans; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h new file mode 100644 index 0000000000..ed4b6dfb64 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -0,0 +1,168 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifEclipseDataTableFormatter.h" + +#include "RigWellLogExtractionTools.h" +#include "RigWellPathIntersectionTools.h" +#include "RigCompletionData.h" + +#include "RicExportCompletionDataSettingsUi.h" + +#include "cafCmdFeature.h" + +#include "cvfBoundingBox.h" + + +class RigCell; +class RigEclipseCaseData; +class RigMainGrid; +class RimEclipseCase; +class RimFishbonesMultipleSubs; +class RimSimWellInView; +class RimWellPath; + + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLateralIntersection { + WellSegmentLateralIntersection(int segmentNumber, + int attachedSegmentNumber, + size_t globalCellIndex, + double length, + double depth, + const cvf::Vec3d& lengthsInCell) + : segmentNumber(segmentNumber), + attachedSegmentNumber(attachedSegmentNumber), + globalCellIndex(globalCellIndex), + mdFromPreviousIntersection(length), + tvdChangeFromPreviousIntersection(depth), + lengthsInCell(lengthsInCell), + mainBoreCell(false) + {} + + int segmentNumber; + int attachedSegmentNumber; + size_t globalCellIndex; + bool mainBoreCell; + double mdFromPreviousIntersection; + double tvdChangeFromPreviousIntersection; + cvf::Vec3d lengthsInCell; +}; + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLateral { + WellSegmentLateral(size_t lateralIndex) + : lateralIndex(lateralIndex), + branchNumber(0) + {} + + size_t lateralIndex; + int branchNumber; + std::vector intersections; +}; + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLocation { + WellSegmentLocation(const RimFishbonesMultipleSubs* subs, double measuredDepth, double trueVerticalDepth, size_t subIndex, int segmentNumber = -1) + : fishbonesSubs(subs), + measuredDepth(measuredDepth), + trueVerticalDepth(trueVerticalDepth), + subIndex(subIndex), + segmentNumber(segmentNumber), + icdBranchNumber(-1), + icdSegmentNumber(-1) + { + } + + const RimFishbonesMultipleSubs* fishbonesSubs; + double measuredDepth; + double trueVerticalDepth; + size_t subIndex; + int segmentNumber; + int icdBranchNumber; + int icdSegmentNumber; + std::vector laterals; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathExportCompletionDataFeatureImpl +{ + +public: + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); + + // TODO : Move + static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); + + static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); + + static double calculateTransmissibility(RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + const cvf::Vec3d& internalCellLengths, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + bool useLateralNTG, + size_t volumeScaleConstant = 1, + CellDirection directionForVolumeScaling = CellDirection::DIR_I); + + + static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); + +private: + static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + CellDirection direction); + + static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, + const RicExportCompletionDataSettingsUi& settings); + + static void printCompletionsToFiles(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + + static void printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + + static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); + + static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); + + static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); + static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); + + static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); + + static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); + static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); + static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); + + static void appendCompletionData(std::map >* completionData, const std::vector& data); +}; + From f8b020e36421643dfcb70974d2308d16e88162cd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 08:41:23 +0100 Subject: [PATCH 0182/1027] #2425 Export Completions : Whitespace --- ...RicWellPathExportCompletionDataFeature.cpp | 98 +++++-------------- .../RicWellPathExportCompletionDataFeature.h | 34 ++----- 2 files changed, 34 insertions(+), 98 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index 6c9f251c14..a3b38c5c4d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -20,63 +20,32 @@ #include "RicWellPathExportCompletionDataFeatureImpl.h" #include "RiaApplication.h" -#include "RiaLogging.h" -#include "RiaPreferences.h" -#include "RicExportCompletionDataSettingsUi.h" #include "RicExportFeatureImpl.h" -#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" -#include "RicExportFractureCompletionsImpl.h" - -#include "RigActiveCellInfo.h" -#include "RigCaseCellResultsData.h" -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" -#include "RigResultAccessorFactory.h" - -#include "RigTransmissibilityEquations.h" - -#include "RigWellLogExtractionTools.h" -#include "RigWellPath.h" -#include "RigWellPathIntersectionTools.h" #include "RimDialogData.h" -#include "RimSimWellInViewCollection.h" -#include "RimFishboneWellPath.h" -#include "RimFishboneWellPathCollection.h" -#include "RimFishbonesCollection.h" -#include "RimFishbonesMultipleSubs.h" -#include "RimPerforationCollection.h" -#include "RimPerforationInterval.h" #include "RimProject.h" #include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RimWellPathCompletions.h" #include "RiuMainWindow.h" #include "cafPdmUiPropertyViewDialog.h" -#include "cafProgressInfo.h" #include "cafSelectionManager.h" -#include "cvfPlane.h" - #include -#include -#include -#include -#include "RigWellLogExtractor.h" CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicWellPathExportCompletionDataFeature::isCommandEnabled() { - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); + std::vector wellPaths = selectedWellPaths(); + std::vector simWells = selectedSimWells(); if (wellPaths.empty() && simWells.empty()) { @@ -104,23 +73,24 @@ bool RicWellPathExportCompletionDataFeature::isCommandEnabled() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) { - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); + std::vector wellPaths = selectedWellPaths(); + std::vector simWells = selectedSimWells(); CVF_ASSERT(wellPaths.size() > 0 || simWells.size() > 0); - RiaApplication* app = RiaApplication::instance(); - RimProject* project = app->project(); + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); QString projectFolder = app->currentProjectPath(); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - bool onlyWellPathCollectionSelected = noWellPathsSelectedDirectly(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(onlyWellPathCollectionSelected); + bool onlyWellPathCollectionSelected = noWellPathsSelectedDirectly(); + RicExportCompletionDataSettingsUi* exportSettings = + project->dialogData()->exportCompletionData(onlyWellPathCollectionSelected); if (wellPaths.empty()) { @@ -146,7 +116,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) } } - if(exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), exportSettings, "Export Completion Data", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); @@ -160,7 +130,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup) { @@ -168,7 +138,7 @@ void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSe } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicWellPathExportCompletionDataFeature::selectedWellPaths() { @@ -195,19 +165,21 @@ std::vector RicWellPathExportCompletionDataFeature::selectedWellPa } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicWellPathExportCompletionDataFeature::noWellPathsSelectedDirectly() { std::vector wellPaths; caf::SelectionManager::instance()->objectsByType(&wellPaths); - if (wellPaths.empty()) return true; - else return false; + if (wellPaths.empty()) + return true; + else + return false; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicWellPathExportCompletionDataFeature::selectedSimWells() { @@ -230,21 +202,3 @@ std::vector RicWellPathExportCompletionDataFeature::selectedS return simWells; } - - - - - - - - - - - - - - - - - - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index aba8591a30..574365894e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -1,46 +1,30 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "RifEclipseDataTableFormatter.h" - -#include "RigWellLogExtractionTools.h" -#include "RigWellPathIntersectionTools.h" -#include "RigCompletionData.h" - -#include "RicExportCompletionDataSettingsUi.h" - #include "cafCmdFeature.h" -#include "cvfBoundingBox.h" - - -class RigCell; -class RigEclipseCaseData; -class RigMainGrid; -class RimEclipseCase; -class RimFishbonesMultipleSubs; class RimSimWellInView; class RimWellPath; //================================================================================================== -/// +/// //================================================================================================== class RicWellPathExportCompletionDataFeature : public caf::CmdFeature { @@ -52,10 +36,8 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature virtual void setupActionLook(QAction* actionToSetup) override; private: - std::vector selectedWellPaths(); - std::vector selectedSimWells(); + std::vector selectedWellPaths(); + std::vector selectedSimWells(); - bool noWellPathsSelectedDirectly(); + bool noWellPathsSelectedDirectly(); }; - - From 8fbd417c4f08255335f038adc325afcccda5282f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 08:41:43 +0100 Subject: [PATCH 0183/1027] #2425 Export Completions : Move function --- ...esTransmissibilityCalculationFeatureImp.cpp | 18 +++++++++++++++++- ...onesTransmissibilityCalculationFeatureImp.h | 7 +++++++ ...WellPathExportCompletionDataFeatureImpl.cpp | 16 ---------------- ...icWellPathExportCompletionDataFeatureImpl.h | 3 --- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 08acd6925d..07d093a898 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -190,7 +190,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); - std::set wellPathCells = RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), + std::set wellPathCells = RicFishbonesTransmissibilityCalculationFeatureImp::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), wellPath->wellPathGeometry()->m_wellPathPoints); bool isMainBore = false; @@ -251,3 +251,19 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st wellBorePartsInCells[cell.globCellIndex].push_back(wellBorePart); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RicFishbonesTransmissibilityCalculationFeatureImp::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) +{ + std::set cells; + + std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); + for (auto intersection : intersections) + { + cells.insert(intersection.m_hexIndex); + } + + return cells; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h index 19df74e89e..cb2c9b6752 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h @@ -18,12 +18,17 @@ #pragma once +#include "cvfBase.h" +#include "cvfVector3.h" + #include #include +#include class RigCompletionData; class RimWellPath; class RicExportCompletionDataSettingsUi; +class RigEclipseCaseData; struct WellBorePartForTransCalc; @@ -51,4 +56,6 @@ class RicFishbonesTransmissibilityCalculationFeatureImp static void findMainWellBoreParts(std::map>& wellBorePartsInCells, const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); + + static std::set findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords); }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 07ab32530d..51facfece8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -776,22 +776,6 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener return completionData; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RicWellPathExportCompletionDataFeatureImpl::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) -{ - std::set cells; - - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); - for (auto intersection : intersections) - { - cells.insert(intersection.m_hexIndex); - } - - return cells; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index ed4b6dfb64..517b223c06 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -118,9 +118,6 @@ class RicWellPathExportCompletionDataFeatureImpl static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); - // TODO : Move - static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); - static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); static double calculateTransmissibility(RimEclipseCase* eclipseCase, From d111fde68b1a6b913e6746dea8906b3e4cfd9133 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 10:18:37 +0100 Subject: [PATCH 0184/1027] #2425 Export Completions : Include cleanup --- ...sTransmissibilityCalculationFeatureImp.cpp | 1 + ...ellPathExportCompletionDataFeatureImpl.cpp | 26 ++++++------------- ...cWellPathExportCompletionDataFeatureImpl.h | 12 +++------ 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 07d093a898..198df3f88b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -26,6 +26,7 @@ #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" #include "RimFishboneWellPath.h" #include "RimFishboneWellPathCollection.h" diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 51facfece8..32f088ef81 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -24,30 +24,26 @@ #include "RicExportCompletionDataSettingsUi.h" #include "RicExportFeatureImpl.h" -#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" #include "RicExportFractureCompletionsImpl.h" +#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" + +#include "RifEclipseDataTableFormatter.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigResultAccessorFactory.h" - #include "RigTransmissibilityEquations.h" - #include "RigWellLogExtractionTools.h" +#include "RigWellLogExtractor.h" #include "RigWellPath.h" #include "RigWellPathIntersectionTools.h" -#include "RimDialogData.h" -#include "RimSimWellInViewCollection.h" -#include "RimFishboneWellPath.h" -#include "RimFishboneWellPathCollection.h" #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" -#include "RimProject.h" #include "RimSimWellInView.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -61,13 +57,7 @@ #include "cvfPlane.h" -#include #include -#include -#include -#include "RigWellLogExtractor.h" - - @@ -226,7 +216,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); } std::vector wellCompletions; - for (auto completion : completions) + for (const auto& completion : completions) { if (completion.wellName() == wellPath->completions()->wellNameForExport()) { @@ -294,7 +284,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); } std::vector wellCompletions; - for (auto completion : completions) + for (const auto& completion : completions) { if (completion.wellName() == simWell->name()) { @@ -516,7 +506,7 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::getCo RigCompletionData::CompletionType completionType) { std::vector filteredCompletions; - for (auto completion : completions) + for (const auto& completion : completions) { if (completion.wellName() == wellName && completion.completionType() == completionType) { @@ -847,7 +837,7 @@ void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(cons std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); - if ( !lateralCoordMDPairs.size() ) + if ( lateralCoordMDPairs.empty() ) { continue; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 517b223c06..160422fc91 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -18,18 +18,14 @@ #pragma once -#include "RifEclipseDataTableFormatter.h" - -#include "RigWellLogExtractionTools.h" -#include "RigWellPathIntersectionTools.h" #include "RigCompletionData.h" #include "RicExportCompletionDataSettingsUi.h" -#include "cafCmdFeature.h" - -#include "cvfBoundingBox.h" +#include "cvfBase.h" +#include "cvfVector3.h" +#include class RigCell; class RigEclipseCaseData; @@ -38,7 +34,7 @@ class RimEclipseCase; class RimFishbonesMultipleSubs; class RimSimWellInView; class RimWellPath; - +class RifEclipseDataTableFormatter; //================================================================================================== /// From b2bdd996d2a356bfe9ff12c5c8625a0b376545cb Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 31 Jan 2018 12:25:58 +0100 Subject: [PATCH 0185/1027] #2389 Fracture: Set perforation length and depth from file values --- .../FileInterface/RifStimPlanXmlReader.cpp | 22 ++++--- .../FileInterface/RifStimPlanXmlReader.h | 2 +- .../RimStimPlanFractureTemplate.cpp | 39 ++++++++++-- .../Completions/RimStimPlanFractureTemplate.h | 1 + .../RigStimPlanFractureDefinition.cpp | 62 ++++++++++++++++++- .../RigStimPlanFractureDefinition.h | 8 +++ 6 files changed, 119 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index dc8a7c0543..095c214e77 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -36,7 +36,6 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil QString * errorMessage) { RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName)); - RiaEclipseUnitTools::UnitSystemType unitSystem = RiaEclipseUnitTools::UNITS_UNKNOWN; cvf::ref stimPlanFileData = new RigStimPlanFractureDefinition; size_t startingNegXsValues = 0; @@ -51,9 +50,10 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil QXmlStreamReader xmlStream; xmlStream.setDevice(&dataFile); xmlStream.readNext(); - startingNegXsValues = readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), unitSystem); + startingNegXsValues = readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p()); + + RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet(); - stimPlanFileData->setUnitSet(unitSystem); if (unitSystem != RiaEclipseUnitTools::UNITS_UNKNOWN) RiaLogging::info(QString("Setting unit system for StimPlan fracture template %1 to %2").arg(stimPlanFileName).arg(unitSystem.uiText())); else @@ -160,7 +160,7 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData, RiaEclipseUnitTools::UnitSystemType& unit) +size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData) { size_t startNegValuesXs = 0; @@ -179,6 +179,16 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS if (xmlStream.name() == "grid") { gridunit = getAttributeValueString(xmlStream, "uom"); + + if (gridunit == "m") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_METRIC); + else if (gridunit == "ft") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_FIELD); + else stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_UNKNOWN); + + double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); + double tvdToBottomPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + + stimPlanFileData->setTvdToTopPerf(tvdToTopPerfFt, RiaDefines::UNIT_FEET); + stimPlanFileData->setTvdToBottomPerf(tvdToBottomPerfFt, RiaDefines::UNIT_FEET); } if (xmlStream.name() == "xs") @@ -205,10 +215,6 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS } } - if (gridunit == "m") unit = RiaEclipseUnitTools::UNITS_METRIC; - else if (gridunit == "ft") unit = RiaEclipseUnitTools::UNITS_FIELD; - else unit = RiaEclipseUnitTools::UNITS_UNKNOWN; - if (startNegValuesYs > 0) { RiaLogging::error(QString("Negative depth values detected in XML file")); diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index 0f0c54b5dd..95070a8c7b 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -36,7 +36,7 @@ class RifStimPlanXmlReader static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, QString * errorMessage); private: - static size_t readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData, RiaEclipseUnitTools::UnitSystemType& unit); + static size_t readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData); static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName); static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 87383d4d0b..b0c263e14d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -214,6 +214,7 @@ void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() if (m_stimPlanFractureDefinitionData.isNull()) return; setDepthOfWellPathAtFracture(); + setPerforationLength(); RiaLogging::info(QString("Setting well/fracture intersection depth at %1").arg(m_wellPathDepthAtFracture)); m_activeTimeStepIndex = static_cast(m_stimPlanFractureDefinitionData->totalNumberTimeSteps() - 1); bool polygonPropertySet = setBorderPolygonResultNameToDefault(); @@ -339,10 +340,40 @@ void RimStimPlanFractureTemplate::setDepthOfWellPathAtFracture() { if (!m_stimPlanFractureDefinitionData.isNull()) { - double firstDepth = m_stimPlanFractureDefinitionData->minDepth(); - double lastDepth = m_stimPlanFractureDefinitionData->maxDepth(); - double averageDepth = (firstDepth + lastDepth) / 2; - m_wellPathDepthAtFracture = averageDepth; + double firstTvd = m_stimPlanFractureDefinitionData->topPerfTvd(); + double lastTvd = m_stimPlanFractureDefinitionData->bottomPerfTvd(); + + if (firstTvd != HUGE_VAL && lastTvd != HUGE_VAL) + { + m_wellPathDepthAtFracture = (firstTvd + lastTvd) / 2; + } + else + { + firstTvd = m_stimPlanFractureDefinitionData->minDepth(); + lastTvd = m_stimPlanFractureDefinitionData->maxDepth(); + m_wellPathDepthAtFracture = (firstTvd + lastTvd) / 2; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::setPerforationLength() +{ + if (!m_stimPlanFractureDefinitionData.isNull()) + { + double firstTvd = m_stimPlanFractureDefinitionData->topPerfTvd(); + double lastTvd = m_stimPlanFractureDefinitionData->bottomPerfTvd(); + + if (firstTvd != HUGE_VAL && lastTvd != HUGE_VAL) + { + perforationLength = std::round(cvf::Math::abs(firstTvd - lastTvd)); + } + else + { + perforationLength = 1; + } } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index cbb5727c8c..11b15c9af5 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -99,6 +99,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate bool setBorderPolygonResultNameToDefault(); void setDepthOfWellPathAtFracture(); + void setPerforationLength(); QString getUnitForStimPlanParameter(QString parameterName); private: diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 3b2aad96f0..482f697f6a 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -42,9 +42,9 @@ RigStimPlanResultFrames::RigStimPlanResultFrames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigStimPlanFractureDefinition::RigStimPlanFractureDefinition() : m_unitSet(RiaEclipseUnitTools::UNITS_UNKNOWN) +RigStimPlanFractureDefinition::RigStimPlanFractureDefinition() : + m_unitSet(RiaEclipseUnitTools::UNITS_UNKNOWN), m_topPerfTvd(HUGE_VAL), m_bottomPerfTvd(HUGE_VAL) { - } //-------------------------------------------------------------------------------------------------- @@ -55,6 +55,64 @@ RigStimPlanFractureDefinition::~RigStimPlanFractureDefinition() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit) +{ + if (unit == RiaDefines::UNIT_METER) + { + if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + m_topPerfTvd = RiaEclipseUnitTools::meterToFeet(topPerfTvd); + } + else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + m_topPerfTvd = topPerfTvd; + } + } + else if (unit == RiaDefines::UNIT_FEET) + { + if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + m_topPerfTvd = topPerfTvd; + } + else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + m_topPerfTvd = RiaEclipseUnitTools::feetToMeter(topPerfTvd); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit) +{ + if (unit == RiaDefines::UNIT_METER) + { + if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + m_bottomPerfTvd = RiaEclipseUnitTools::meterToFeet(bottomPerfTvd); + } + else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + m_bottomPerfTvd = bottomPerfTvd; + } + } + else if (unit == RiaDefines::UNIT_FEET) + { + if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + m_bottomPerfTvd = bottomPerfTvd; + } + else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + m_bottomPerfTvd = RiaEclipseUnitTools::feetToMeter(bottomPerfTvd); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index f6c730647c..4181d4691f 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -65,6 +65,11 @@ class RigStimPlanFractureDefinition: public cvf::Object double maxDepth() const { return depths.back(); } size_t depthCount() const { return depths.size(); } + double topPerfTvd() const { return m_topPerfTvd; } + double bottomPerfTvd() const { return m_bottomPerfTvd; } + void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); + void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); + // Grid Geometry std::vector getNegAndPosXcoords() const; @@ -128,6 +133,9 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector m_gridYs; std::vector depths; + double m_topPerfTvd; + double m_bottomPerfTvd; + std::vector m_timeSteps; std::vector m_stimPlanResults; }; From 61d8a765872449df677fe7317ec960d67339757a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 31 Jan 2018 12:43:42 +0100 Subject: [PATCH 0186/1027] #2390 Fracture: Set minimum 10 m perf length --- .../Completions/RimStimPlanFractureTemplate.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index b0c263e14d..ae141a16ec 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -370,10 +370,15 @@ void RimStimPlanFractureTemplate::setPerforationLength() { perforationLength = std::round(cvf::Math::abs(firstTvd - lastTvd)); } - else - { - perforationLength = 1; - } + } + + if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && perforationLength < 10) + { + perforationLength = 10; + } + else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && perforationLength < RiaEclipseUnitTools::meterToFeet(10)) + { + perforationLength = std::round(RiaEclipseUnitTools::meterToFeet(10)); } } From d7fa97f052431da0ba2f62206615ca135d16b6e2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 31 Jan 2018 13:54:58 +0100 Subject: [PATCH 0187/1027] Fix wrong include path --- ApplicationCode/ProjectDataModel/RimDialogData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index 1d0b3d81e5..d9ed687faf 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -19,7 +19,7 @@ #include "RimDialogData.h" #include "ExportCommands/RicExportCarfinUi.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" CAF_PDM_SOURCE_INIT(RimDialogData, "RimDialogData"); From e50f7bf66fd8862ad71fb602def6fa11db017f92 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 31 Jan 2018 15:11:42 +0100 Subject: [PATCH 0188/1027] #2428 Fracture: Reorganize Fracture Colors tree item --- .../RivWellFracturePartMgr.cpp | 4 +- .../Completions/RimFracture.cpp | 26 -------- .../Completions/RimFracture.h | 10 --- .../Completions/RimSimWellFracture.cpp | 3 +- .../RimStimPlanFractureTemplate.cpp | 11 ---- .../Completions/RimStimPlanFractureTemplate.h | 2 - .../Completions/RimWellPathFracture.cpp | 3 +- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimStimPlanColors.cpp | 65 ++++++++++++++++++- .../ProjectDataModel/RimStimPlanColors.h | 11 ++++ 10 files changed, 78 insertions(+), 59 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index b6b19d2884..47ddf15d52 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -96,7 +96,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (stimPlanFracTemplate) { - if (m_rimFracture->stimPlanResultColorType() == RimFracture::SINGLE_ELEMENT_COLOR) + if (eclView.stimPlanColors->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) { auto part = createStimPlanElementColorSurfacePart(eclView); if (part.notNull()) parts.push_back(part.p()); @@ -107,7 +107,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (part.notNull()) parts.push_back(part.p()); } - if (stimPlanFracTemplate->showStimPlanMesh()) + if (eclView.stimPlanColors->showStimPlanMesh()) { auto part = createStimPlanMeshPart(eclView); if (part.notNull()) parts.push_back(part.p()); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 9a63c139dc..c1019aa681 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -70,19 +70,6 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimFracture, "Fracture"); -namespace caf { - -template<> -void caf::AppEnum< RimFracture::StimPlanResultColorType >::setUp() -{ - addItem(RimFracture::COLOR_INTERPOLATION, "COLOR_INTERPOLATION", "On"); - addItem(RimFracture::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Off"); - - setDefault(RimFracture::COLOR_INTERPOLATION); -} - -} // End namespace caf - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -154,8 +141,6 @@ RimFracture::RimFracture(void) m_wellFractureAzimuthAngleWarning.uiCapability()->setUiReadOnly(true); m_wellFractureAzimuthAngleWarning.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "StimPlan Color Interpolation", "", "", ""); - m_fracturePartMgr = new RivWellFracturePartMgr(this); } @@ -190,14 +175,6 @@ void RimFracture::setStimPlanTimeIndexToPlot(int timeIndex) m_stimPlanTimeIndexToPlot = timeIndex; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFracture::StimPlanResultColorType RimFracture::stimPlanResultColorType() const -{ - return m_stimPlanCellVizMode(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -227,7 +204,6 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons if (changedField == &m_azimuth || changedField == &m_fractureTemplate || changedField == &m_stimPlanTimeIndexToPlot || - changedField == &m_stimPlanCellVizMode || changedField == this->objectToggleField() || changedField == &m_dip || changedField == &m_tilt || @@ -520,14 +496,12 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO if (dynamic_cast(fracTemplate)) { m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); - m_stimPlanCellVizMode.uiCapability()->setUiHidden(false); m_stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); } else { m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); - m_stimPlanCellVizMode.uiCapability()->setUiHidden(true); } } else diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 8ce6f74901..66d8d04827 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -52,13 +52,6 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf { CAF_PDM_HEADER_INIT; -public: - enum StimPlanResultColorType - { - COLOR_INTERPOLATION, - SINGLE_ELEMENT_COLOR - }; - public: RimFracture(void); virtual ~RimFracture(void); @@ -67,7 +60,6 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf double perforationEfficiency() const; void setStimPlanTimeIndexToPlot(int timeIndex); - StimPlanResultColorType stimPlanResultColorType() const; double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; cvf::Vec3d anchorPosition() const ; @@ -133,8 +125,6 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf caf::PdmField m_wellDiameter; caf::PdmField m_stimPlanTimeIndexToPlot; - caf::PdmField> m_stimPlanCellVizMode; - private: caf::PdmField m_anchorPosition; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index 2c42b1028e..afcd5615d8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -221,6 +221,7 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi RimFracture::defineUiOrdering(uiConfigName, uiOrdering); uiOrdering.add(nameField()); + uiOrdering.add(&m_fractureTemplate); caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_location); @@ -234,9 +235,7 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); - propertyGroup->add(&m_fractureTemplate); propertyGroup->add(&m_stimPlanTimeIndexToPlot); - propertyGroup->add(&m_stimPlanCellVizMode); propertyGroup->add(&m_perforationLength); propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index ae141a16ec..25df77ce51 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -72,7 +72,6 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() m_borderPolygonResultName.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); - CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show StimPlan Mesh", "", "", ""); CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); CAF_PDM_InitField(&m_conductivityResultNameOnFile, "ConductivityResultName", QString(""), "Active Conductivity Result Name", "", "", ""); @@ -95,14 +94,6 @@ int RimStimPlanFractureTemplate::activeTimeStepIndex() return m_activeTimeStepIndex; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimStimPlanFractureTemplate::showStimPlanMesh() -{ - return m_showStimPlanMesh; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -148,7 +139,6 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch if (&m_wellPathDepthAtFracture == changedField || &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField - || &m_showStimPlanMesh == changedField || &m_conductivityScalingFactor == changedField || &m_stimPlanFileName == changedField || &m_conductivityResultNameOnFile == changedField) @@ -615,7 +605,6 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); uiOrdering.add(&name); - uiOrdering.add(&m_showStimPlanMesh); caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("Input"); fileGroup->add(&m_stimPlanFileName); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 11b15c9af5..ff81f7e5cd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -53,7 +53,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate virtual ~RimStimPlanFractureTemplate(); int activeTimeStepIndex(); - bool showStimPlanMesh(); void loadDataAndUpdate(); void setDefaultsBasedOnXMLfile(); @@ -105,7 +104,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate private: caf::PdmField m_activeTimeStepIndex; caf::PdmField m_conductivityResultNameOnFile; - caf::PdmField m_showStimPlanMesh; caf::PdmField m_wellPathDepthAtFracture; caf::PdmField m_borderPolygonResultName; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index 33d5d1f11b..c01bcbe6e9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -185,6 +185,7 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder RimFracture::defineUiOrdering(uiConfigName, uiOrdering); uiOrdering.add(nameField()); + uiOrdering.add(&m_fractureTemplate); caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_measuredDepth); @@ -197,9 +198,7 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); - propertyGroup->add(&m_fractureTemplate); propertyGroup->add(&m_stimPlanTimeIndexToPlot); - propertyGroup->add(&m_stimPlanCellVizMode); propertyGroup->add(&m_perforationLength); propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index a04119f33f..d07bf58900 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -123,7 +123,7 @@ RimEclipseView::RimEclipseView() faultResultSettings.uiCapability()->setUiHidden(true); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - CAF_PDM_InitFieldNoDefault(&stimPlanColors, "StimPlanColors", "Fracture Colors", "", "", ""); + CAF_PDM_InitFieldNoDefault(&stimPlanColors, "StimPlanColors", "Fracture", "", "", ""); stimPlanColors = new RimStimPlanColors(); stimPlanColors.uiCapability()->setUiHidden(true); #endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 851fa14fc6..481e41156b 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -40,6 +40,19 @@ CAF_PDM_SOURCE_INIT(RimStimPlanColors, "RimStimPlanColors"); +namespace caf { + + template<> + void caf::AppEnum< RimStimPlanColors::StimPlanResultColorType >::setUp() + { + addItem(RimStimPlanColors::COLOR_INTERPOLATION, "COLOR_INTERPOLATION", "On"); + addItem(RimStimPlanColors::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Off"); + + setDefault(RimStimPlanColors::COLOR_INTERPOLATION); + } + +} // End namespace caf + //-------------------------------------------------------------------------------------------------- /// Internal methods //-------------------------------------------------------------------------------------------------- @@ -60,7 +73,11 @@ RimStimPlanColors::RimStimPlanColors() CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", ""); m_legendConfigurations.uiCapability()->setUiTreeHidden(true); - setName("Fracture Colors"); + CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show Mesh", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation", "", "", ""); + + setName("Fracture"); nameField()->uiCapability()->setUiReadOnly(true); } @@ -179,6 +196,26 @@ void RimStimPlanColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField { updateStimPlanTemplates(); } + + if (changedField == &m_showStimPlanMesh) + { + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + } + + if(changedField == &m_stimPlanCellVizMode) + { + Rim3dView* rimView = nullptr; + this->firstAncestorOrThisOfType(rimView); + if (rimView) + { + rimView->createDisplayModelAndRedraw(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -336,8 +373,30 @@ void RimStimPlanColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrder //-------------------------------------------------------------------------------------------------- void RimStimPlanColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_resultNameAndUnit); - uiOrdering.add(&m_defaultColor); + caf::PdmUiGroup* colorGroup = uiOrdering.addNewGroup("Colors"); + colorGroup->add(&m_resultNameAndUnit); + colorGroup->add(&m_defaultColor); + + bool stimPlanExists = false; + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + std::vector fracTemplates = proj->allFractureTemplates(); + + for (auto fractemplate : fracTemplates) + { + if (dynamic_cast(fractemplate)) + { + stimPlanExists = true; + break; + } + } + + if (stimPlanExists) + { + caf::PdmUiGroup* stimPlanGroup = uiOrdering.addNewGroup("StimPlan"); + stimPlanGroup->add(&m_showStimPlanMesh); + stimPlanGroup->add(&m_stimPlanCellVizMode); + } uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index 4b74f9d038..944fe88aee 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -44,6 +44,12 @@ class RimStimPlanColors : public RimCheckableNamedObject { CAF_PDM_HEADER_INIT; +public: + enum StimPlanResultColorType + { + COLOR_INTERPOLATION, + SINGLE_ELEMENT_COLOR + }; public: RimStimPlanColors(); virtual ~RimStimPlanColors(); @@ -53,11 +59,13 @@ class RimStimPlanColors : public RimCheckableNamedObject void setDefaultResultNameForStimPlan(); QString unit() const; cvf::Color3f defaultColor() const; + bool showStimPlanMesh() const { return m_showStimPlanMesh; } void loadDataAndUpdate(); void updateLegendData(); void updateStimPlanTemplates() const; + StimPlanResultColorType stimPlanResultColorType() const { return m_stimPlanCellVizMode(); }; protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; @@ -75,5 +83,8 @@ class RimStimPlanColors : public RimCheckableNamedObject caf::PdmField m_defaultColor; caf::PdmField m_resultNameAndUnit; caf::PdmChildArrayField m_legendConfigurations; + caf::PdmField m_showStimPlanMesh; + caf::PdmField> m_stimPlanCellVizMode; + }; From 226916c60f86b0caf157356258c36d9669b32eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 31 Jan 2018 15:57:18 +0100 Subject: [PATCH 0189/1027] Upped dev to 2018.01.00-dev.104 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 74ef4c3254..017720bf9b 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".104") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 5b083bf9743ca75478140c6331d62ef64129299d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 31 Jan 2018 15:51:08 +0100 Subject: [PATCH 0190/1027] Remove unused include --- ApplicationCode/ProjectDataModel/Completions/RimFracture.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 66d8d04827..d1513ca7bc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -29,7 +29,6 @@ #include "cvfMatrix4.h" #include "cvfPlane.h" -#include "cafAppEnum.h" #include "cafPdmChildField.h" #include "cafPdmFieldCvfVec3d.h" #include "cafPdmProxyValueField.h" From aa18ee9aa4c86339f3f7d48d133bc1caeb4d86d7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 31 Jan 2018 16:37:43 +0100 Subject: [PATCH 0191/1027] Fix build --- ApplicationCode/ProjectDataModel/Rim3dView.h | 2 +- ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 06166f50b9..70c8203db5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -151,7 +151,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void disableGridBoxField(); void disablePerspectiveProjectionField(); - RimWellPathCollection* wellPathCollection(); + RimWellPathCollection* wellPathCollection() const; void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox); diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 66c298c664..d7b36b0d9c 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -321,7 +321,7 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha { this->updateUiIconFromToggleField(); - RimView* view; + Rim3dView* view; firstAncestorOrThisOfType(view); if (view) { From a4eb16883b2ab556874cc0fa62a618d4c9357e60 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 1 Feb 2018 15:37:05 +0100 Subject: [PATCH 0192/1027] #2441: Fracture Colors : Make sure conductivity result is set on template for old project files --- .../Application/RiaApplication.cpp | 16 ++++++++++++++ .../RimFractureTemplateCollection.cpp | 15 +++++++++++++ .../RimFractureTemplateCollection.h | 1 + .../RimStimPlanFractureTemplate.cpp | 14 ++++++++++++ .../Completions/RimStimPlanFractureTemplate.h | 1 + .../ProjectDataModel/RimStimPlanColors.cpp | 22 +++++++++++++++++++ .../ProjectDataModel/RimStimPlanColors.h | 2 ++ 7 files changed, 71 insertions(+) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index bb2ab2fd58..f0650b85fb 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -96,6 +96,7 @@ #ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" #include "RimWellPathFracture.h" +#include "RimStimPlanColors.h" #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -512,7 +513,9 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi } #ifdef USE_PROTOTYPE_FEATURE_FRACTURES + oilField->fractureDefinitionCollection()->loadAndUpdateData(); + oilField->fractureDefinitionCollection()->setDefaultConductivityResultIfEmpty(); { std::vector wellPathFractures; @@ -543,6 +546,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi } + // Now load the ReservoirViews for the cases // Add all "native" cases in the project std::vector casesToLoad; @@ -568,6 +572,18 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi viewProgress.setProgressDescription(riv->name()); +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + if (m_project->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) + { + std::vector stimPlanColors; + riv->descendantsIncludingThisOfType(stimPlanColors); + if (stimPlanColors.size() == 1) + { + stimPlanColors[0]->updateConductivityResultName(); + } + } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + riv->loadDataAndUpdate(); this->setActiveReservoirView(riv); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index cc0e1f5387..aeefedc187 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -125,6 +125,21 @@ void RimFractureTemplateCollection::loadAndUpdateData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::setDefaultConductivityResultIfEmpty() +{ + for (RimFractureTemplate* f : fractureDefinitions()) + { + RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); + if (stimPlanFracture) + { + stimPlanFracture->setDefaultConductivityResultIfEmpty(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 9bb9a8c2a6..cbac6868eb 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -46,6 +46,7 @@ class RimFractureTemplateCollection : public caf::PdmObject void deleteFractureDefinitions(); void loadAndUpdateData(); + void setDefaultConductivityResultIfEmpty(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 25df77ce51..8c782df2ef 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -397,6 +397,20 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::setDefaultConductivityResultIfEmpty() +{ + if (m_conductivityResultNameOnFile().isEmpty()) + { + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index ff81f7e5cd..375da36450 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -86,6 +86,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate PosNegAccumulator& posNegAccumulator) const override; QString mapUiResultNameToFileResultName(const QString& uiResultName) const; + void setDefaultConductivityResultIfEmpty(); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 481e41156b..e2254f286f 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -313,6 +313,28 @@ void RimStimPlanColors::updateStimPlanTemplates() const } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanColors::updateConductivityResultName() +{ + // Conductivity result name as reported from the XML file was moved to the fracture template + // Replace all conductivity names with the one and only conductivity uiName reported from by fracture template + + if (m_resultNameAndUnit().contains("conductivity", Qt::CaseInsensitive)) + { + RimFractureTemplateCollection* fractureTemplates = fractureTemplateCollection(); + for (auto resultNameAndUnit : fractureTemplates->stimPlanResultNamesAndUnits()) + { + if (resultNameAndUnit.first.contains("conductivity", Qt::CaseInsensitive)) + { + QString resultNameAndUnitString = toString(resultNameAndUnit); + m_resultNameAndUnit = resultNameAndUnitString; + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index 944fe88aee..414efc5bb2 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -67,6 +67,8 @@ class RimStimPlanColors : public RimCheckableNamedObject void updateStimPlanTemplates() const; StimPlanResultColorType stimPlanResultColorType() const { return m_stimPlanCellVizMode(); }; + void updateConductivityResultName(); + protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From 29ac24f3dd16c5d0d4b5b73265e39f1033f23540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 1 Feb 2018 17:45:22 +0100 Subject: [PATCH 0193/1027] #2426 Add working legends to 2D intersection Views. Refactor to make legend update code work from a separate view with separate legend configs. Make sure legend and results are updated as the main view is updated. Adjust legendconfig->setTitle to use QString --- .../RivIntersectionBoxPartMgr.cpp | 4 +- .../Intersections/RivIntersectionPartMgr.cpp | 29 +- .../Intersections/RivIntersectionPartMgr.h | 5 +- .../RivScalarMapperUtils.cpp | 2 +- .../RivTernaryTextureCoordsCreator.cpp | 6 +- .../RivTernaryTextureCoordsCreator.h | 2 +- .../Rim2dIntersectionView.cpp | 104 +++++-- .../ProjectDataModel/Rim2dIntersectionView.h | 9 +- .../ProjectDataModel/RimEclipseCase.cpp | 2 + .../ProjectDataModel/RimEclipseCellColors.cpp | 261 ++++++++++++------ .../ProjectDataModel/RimEclipseCellColors.h | 4 +- .../RimEclipseResultDefinition.cpp | 3 + .../RimEclipseStatisticsCase.cpp | 2 + .../ProjectDataModel/RimEclipseView.cpp | 67 +---- .../ProjectDataModel/RimGeoMechCase.cpp | 2 + .../RimGeoMechResultDefinition.cpp | 9 +- .../ProjectDataModel/RimGeoMechView.cpp | 40 ++- .../ProjectDataModel/RimGeoMechView.h | 3 + .../RimIntersectionCollection.cpp | 18 +- .../RimIntersectionCollection.h | 7 +- .../ProjectDataModel/RimLegendConfig.cpp | 13 +- .../ProjectDataModel/RimLegendConfig.h | 5 +- .../ProjectDataModel/RimStimPlanColors.cpp | 2 +- .../RimTernaryLegendConfig.cpp | 23 +- .../ProjectDataModel/RimTernaryLegendConfig.h | 11 +- .../ProjectDataModel/RimViewController.cpp | 6 + .../ProjectDataModel/RimViewLinker.cpp | 4 +- .../SocketInterface/RiaNNCCommands.cpp | 2 + .../RiaPropertyDataCommands.cpp | 4 + 29 files changed, 426 insertions(+), 223 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index e2001740fa..a64fbc2cb3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -101,7 +101,9 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, + cellResultColors->ternaryLegendConfig()->scalarMapper(), + timeStepIndex); texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxGenerator->triangleToCellIndex()); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 445bf3c63e..9cfca35775 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -89,8 +89,12 @@ void RivIntersectionPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) +void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { + CVF_ASSERT(scalarColorMapper); + if (m_crossSectionGenerator.isNull()) return; if (!m_crossSectionGenerator->isAnyGeometryPresent()) return; @@ -102,6 +106,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); CVF_ASSERT(cellResultColors); + CVF_ASSERT(ternaryColorMapper); RigEclipseCaseData* eclipseCase = eclipseView->eclipseCase()->eclipseCaseData(); @@ -110,14 +115,13 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, ternaryColorMapper, timeStepIndex); texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex()); - const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + ternaryColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -126,7 +130,6 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { CVF_ASSERT(m_crossSectionGenerator.notNull()); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); cvf::ref resultAccessor; if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable())) @@ -144,12 +147,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex(), resultAccessor.p(), - mapper); + scalarColorMapper); RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -169,8 +172,6 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - if (resVarAddress.resultPosType == RIG_ELEMENT) { const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); @@ -179,7 +180,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), resultValues, triangleToCellIdx, - mapper); + scalarColorMapper); } else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) @@ -192,7 +193,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(), triangelVxes, resVarAddress, - mapper); + scalarColorMapper); } else { @@ -204,7 +205,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) caseData, resVarAddress, (int)timeStepIndex, - mapper); + scalarColorMapper); } } else @@ -222,12 +223,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) resultValues, isElementNodalResult, femPart, - mapper); + scalarColorMapper); } RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, geoView->isLightingDisabled()); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index f1bd98d5c6..0daa56f475 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -43,6 +43,7 @@ class RigResultAccessor; class RimCellEdgeColors; class RimEclipseCellColors; class RimIntersection; +class RivTernaryScalarMapper; class RivIntersectionGeometryGenerator; class RivIntersectionHexGridInterface; class RivIntersectionVertexWeights; @@ -59,7 +60,9 @@ class RivIntersectionPartMgr : public cvf::Object explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false); void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index 54c74bb5af..fdbf6a1f4b 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -87,7 +87,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultColors, cellEdgeResultColors, quadToCellFaceMapper, dg, gridIndex, opacityLevel); - RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + const RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); cellFaceEffectGen.setTernaryScalarMapper(ternaryCellScalarMapper); } else diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index 37d6c3434f..9e443bf675 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -79,7 +79,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( //-------------------------------------------------------------------------------------------------- RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex) : m_quadMapper(NULL) { @@ -99,10 +99,8 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p()); - const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper(); - // Create a texture mapper without detecting transparency using RigPipeInCellEvaluator - m_texMapper = new RivTernaryResultToTextureMapper(mapper, NULL); + m_texMapper = new RivTernaryResultToTextureMapper(ternaryColorMapper, NULL); CVF_ASSERT(m_texMapper.notNull()); } diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h index d9e767ab0c..b85ea520c0 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h @@ -48,7 +48,7 @@ class RivTernaryTextureCoordsCreator const cvf::StructGridQuadToCellFaceMapper* quadMapper); RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex); void createTextureCoords(cvf::Vec2fArray* quadTextureCoords); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 8962e28ed2..bcb28881cf 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -23,6 +23,7 @@ #include "RiuViewer.h" #include "RimGridView.h" #include "RivIntersectionPartMgr.h" +#include "RivTernarySaturationOverlayItem.h" #include "cvfPart.h" #include "cvfModelBasicList.h" @@ -32,6 +33,8 @@ #include "RimEclipseCellColors.h" #include "RimGeoMechView.h" #include "RimGeoMechCellColors.h" +#include "RimLegendConfig.h" +#include "RimTernaryLegendConfig.h" #include @@ -52,6 +55,18 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", ""); m_intersection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + m_legendConfig.uiCapability()->setUiHidden(true); + m_legendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_legendConfig.xmlCapability()->disableIO(); + m_legendConfig = new RimLegendConfig(); + + CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", ""); + m_ternaryLegendConfig.uiCapability()->setUiTreeHidden(true); + m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_ternaryLegendConfig.xmlCapability()->disableIO(); + m_ternaryLegendConfig = new RimTernaryLegendConfig(); + m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; @@ -274,6 +289,12 @@ void Rim2dIntersectionView::createDisplayModel() void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onTimeStepChanged() +{ +} //-------------------------------------------------------------------------------------------------- /// @@ -287,23 +308,88 @@ void Rim2dIntersectionView::clampCurrentTimestep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateCurrentTimeStep() { + updateLegends(); + if ((this->hasUserRequestedAnimation() && this->hasResults())) { - m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep); + m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep, + m_legendConfig->scalarMapper(), + m_ternaryLegendConfig()->scalarMapper()); } else { m_flatIntersectionPartMgr->applySingleColorEffect(); } + +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateLegends() +{ + if (m_viewer) + { + m_viewer->removeAllColorLegends(); + } + + if (!hasResults()) return ; + + cvf::OverlayItem* legend = nullptr; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView) + { + m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); + m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); + eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); + + if ( eclView->cellResult()->isTernarySaturationSelected() ) + { + m_ternaryLegendConfig()->setTitle("Cell Result:"); + legend = m_ternaryLegendConfig()->legend(); + } + else + { + m_legendConfig()->setTitle("Cell Result:" + eclView->cellResult()->resultVariableUiShortName()); + legend = m_legendConfig()->legend(); + } + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView) + { + m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); + + geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); + legend = m_legendConfig()->legend(); + } + + if ( legend ) + { + m_viewer->addColorLegendToBottomLeftCorner(legend); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::onTimeStepChanged() +void Rim2dIntersectionView::resetLegendsInViewer() { + m_viewer->showAxisCross(false); + m_viewer->showAnimationProgress(true); + m_viewer->showHistogram(false); + m_viewer->showInfoText(false); + + m_viewer->setMainScene(new cvf::Scene()); + m_viewer->enableNavigationRotation(false); + + m_ternaryLegendConfig()->recreateLegend(); + m_legendConfig()->recreateLegend(); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -332,20 +418,6 @@ cvf::Transform* Rim2dIntersectionView::scaleTransform() return m_scaleTransform.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::resetLegendsInViewer() -{ - m_viewer->showAxisCross(false); - m_viewer->showAnimationProgress(true); - m_viewer->showHistogram(false); - m_viewer->showInfoText(false); - - m_viewer->setMainScene(new cvf::Scene()); - m_viewer->enableNavigationRotation(false); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 98da585f17..ec3ec5361d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -23,6 +23,8 @@ class RimIntersection; class RivIntersectionPartMgr; +class RimLegendConfig; +class RimTernaryLegendConfig; namespace cvf { @@ -50,7 +52,7 @@ class Rim2dIntersectionView : public Rim3dView virtual void selectOverlayInfoConfig() override {} virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } - virtual RimViewController* viewController() const override { return nullptr; } + virtual RimViewController* viewController() const override { return nullptr; } virtual bool isTimeStepDependentDataVisible() const override; @@ -76,6 +78,11 @@ class Rim2dIntersectionView : public Rim3dView bool hasResults(); int timeStepCount(); + void updateLegends(); + + caf::PdmChildField m_legendConfig; + caf::PdmChildField m_ternaryLegendConfig; + caf::PdmPtrField m_intersection; cvf::ref m_flatIntersectionPartMgr; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index ab9802971e..84cf383f49 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -41,6 +41,7 @@ #include "RimFlowCharacteristicsPlot.h" #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" +#include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" @@ -398,6 +399,7 @@ void RimEclipseCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index db6bf8bf95..a5af468764 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -273,135 +273,212 @@ public : //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCellColors::updateLegendData(size_t currentTimeStep) +void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, + RimLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig) { - if (this->isFlowDiagOrInjectionFlooding()) + if (!legendConfig) legendConfig = this->legendConfig(); + if (!ternaryLegendConfig) ternaryLegendConfig = this->ternaryLegendConfig(); + + if ( this->hasResult() ) { - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); - RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); + if ( this->isFlowDiagOrInjectionFlooding() ) + { + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); + RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); - int integerTimeStep = static_cast(currentTimeStep); + int integerTimeStep = static_cast(currentTimeStep); - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) - { - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); - } - else - { - localMin = globalMin; - localMax = globalMax; + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) + { + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); + } + else + { + localMin = globalMin; + localMax = globalMax; - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; + } - CVF_ASSERT(this->legendConfig()); + CVF_ASSERT(legendConfig); - this->legendConfig()->disableAllTimeStepsRange(true); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + legendConfig->disableAllTimeStepsRange(true); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, + localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - if (this->hasCategoryResult()) - { - std::set, TupleCompare > categories; - //std::set > categories; + if ( this->hasCategoryResult() ) + { + std::set, TupleCompare > categories; + //std::set > categories; + + std::vector tracerNames = this->flowDiagSolution()->tracerNames(); + int tracerIndex = 0; + for ( const auto& tracerName : tracerNames ) + { + RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); + cvf::Color3ub color(cvf::Color3::GRAY); + if ( well ) color = cvf::Color3ub(well->wellPipeColor()); - std::vector tracerNames = this->flowDiagSolution()->tracerNames(); - int tracerIndex = 0; - for (const auto& tracerName : tracerNames) + categories.insert(std::make_tuple(tracerName, tracerIndex, color)); + ++tracerIndex; + } + + std::vector> reverseCategories; + for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt ) + { + reverseCategories.push_back(*tupIt); + } + + legendConfig->setCategoryItems(reverseCategories); + } + } + else + { + RimEclipseCase* rimEclipseCase = nullptr; + this->firstAncestorOrThisOfType(rimEclipseCase); + CVF_ASSERT(rimEclipseCase); + if ( !rimEclipseCase ) return; + + RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT(eclipseCase); + if ( !eclipseCase ) return; + + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); + CVF_ASSERT(cellResultsData); + + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) + { + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); + } + else { - RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); - cvf::Color3ub color(cvf::Color3::GRAY); - if (well) color = cvf::Color3ub(well->wellPipeColor()); + localMin = globalMin; + localMax = globalMax; - categories.insert(std::make_tuple(tracerName, tracerIndex, color)); - ++tracerIndex; + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; } - std::vector> reverseCategories; - for (auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt) + CVF_ASSERT(legendConfig); + + legendConfig->disableAllTimeStepsRange(false); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + if ( this->hasCategoryResult() ) { - reverseCategories.push_back(*tupIt); + if ( this->resultType() == RiaDefines::FORMATION_NAMES ) + { + const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); + legendConfig->setNamedCategoriesInverse(fnVector); + } + else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName() ) + { + std::vector< std::tuple > categories; + + caf::AppEnum wellPath(RiaDefines::WELL_PATH); + caf::AppEnum fishbone(RiaDefines::FISHBONES); + caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); + caf::AppEnum fracture(RiaDefines::FRACTURE); + + categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); + categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); + categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); + categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + + legendConfig->setCategoryItems(categories); + } + else + { + legendConfig->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + } } - - this->legendConfig()->setCategoryItems(reverseCategories); } } - else + + // Ternary legend update { RimEclipseCase* rimEclipseCase = nullptr; this->firstAncestorOrThisOfType(rimEclipseCase); CVF_ASSERT(rimEclipseCase); - if (!rimEclipseCase) return; + if ( !rimEclipseCase ) return; RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); CVF_ASSERT(eclipseCase); - if (!eclipseCase) return; + if ( !eclipseCase ) return; - RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); - CVF_ASSERT(cellResultsData); - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) - { - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); - } - else + size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); + if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 ) { - localMin = globalMin; - localMax = globalMax; - - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } - - CVF_ASSERT(this->legendConfig()); + RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); + { + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; - this->legendConfig()->disableAllTimeStepsRange(false); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); - if (this->hasCategoryResult()) - { - if (this->resultType() == RiaDefines::FORMATION_NAMES) - { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - this->legendConfig()->setNamedCategoriesInverse(fnVector); + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); + } } - else if (this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName()) - { - std::vector< std::tuple > categories; - caf::AppEnum wellPath(RiaDefines::WELL_PATH); - caf::AppEnum fishbone(RiaDefines::FISHBONES); - caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); - caf::AppEnum fracture(RiaDefines::FRACTURE); + { + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; - categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); - categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); - categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); - categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); - legendConfig()->setCategoryItems(categories); + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); + } } - else + { - this->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); + + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 184be112e3..9812e8cbdb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -43,7 +43,9 @@ class RimEclipseCellColors : public RimEclipseResultDefinition void setReservoirView(RimEclipseView* ownerReservoirView); RimEclipseView* reservoirView(); - void updateLegendData(size_t timestep); + void updateLegendData(size_t timestep, + RimLegendConfig* legendConfig = nullptr, + RimTernaryLegendConfig* ternaryLegendConfig = nullptr); RimLegendConfig* legendConfig(); caf::PdmChildField ternaryLegendConfig; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 998992f1cb..b42f0bb858 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -33,6 +33,7 @@ #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimReservoirCellResultsStorage.h" #include "Rim3dView.h" @@ -409,6 +410,8 @@ void RimEclipseResultDefinition::loadDataAndUpdate() { viewLinker->updateCellResult(); } + RimGridView* eclView = dynamic_cast(view); + if (eclView) eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index e03df89591..ce556d43d9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -39,6 +39,7 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTextEditor.h" #include "cafProgressInfo.h" +#include "RimIntersectionCollection.h" namespace caf { template<> @@ -691,6 +692,7 @@ void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() // a full display model rebuild is required reservoirViews[i]->hasUserRequestedAnimation = true; reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 209e894c39..4f3b3ffea1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -656,7 +656,9 @@ void RimEclipseView::updateCurrentTimeStep() if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) { - m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + this->cellResult()->ternaryLegendConfig()->scalarMapper()); } else { @@ -1035,7 +1037,7 @@ void RimEclipseView::updateLegends() } m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); - this->cellEdgeResult()->legendConfig()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName())); + this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); } else { @@ -1060,71 +1062,24 @@ void RimEclipseView::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData) +void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, + RimEclipseCellColors* resultColors, + RigCaseCellResultsData* cellResultsData) { + resultColors->updateLegendData(m_currentTimeStep); + if (resultColors->hasResult()) { - resultColors->updateLegendData(m_currentTimeStep); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); - resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariableUiShortName())); + resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - RigCaseCellResultsData* gridCellResults = resultColors->currentGridCellResults(); - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); - } - } - if (resultColors->ternaryLegendConfig->legend()) { - resultColors->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel)); + resultColors->ternaryLegendConfig->setTitle(legendLabel); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 2760eac9d4..6f510952fe 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -30,6 +30,7 @@ #include "RigFormationNames.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimTools.h" @@ -499,6 +500,7 @@ void RimGeoMechCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + geomView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 9ff629b103..ed5f0599ee 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -30,6 +30,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilter.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimViewLinker.h" @@ -214,7 +215,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha // Get the possible property filter owner RimGeoMechPropertyFilter* propFilter = dynamic_cast(this->parentField()->ownerObject()); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); @@ -261,7 +262,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha if (view) view->scheduleGeometryRegen(PROPERTY_FILTERED); } - if (view) view->scheduleCreateDisplayModelAndRedraw(); + if ( view ) + { + view->scheduleCreateDisplayModelAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } if (dynamic_cast(this)) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index c0cf4e57f5..1498ffde5d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -290,7 +290,9 @@ void RimGeoMechView::updateCurrentTimeStep() if (this->cellResult()->hasResult()) { - m_crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + nullptr); } else { @@ -344,12 +346,22 @@ void RimGeoMechView::resetLegendsInViewer() //-------------------------------------------------------------------------------------------------- void RimGeoMechView::updateLegends() { - if (m_viewer) + if ( m_viewer ) { m_viewer->removeAllColorLegends(); + + this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); + + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } +} - if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex) +{ + if (!m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() || !(cellResult()->resultAddress().isValid()) ) { @@ -366,16 +378,16 @@ void RimGeoMechView::updateLegends() RigFemResultAddress resVarAddress = cellResult()->resultAddress(); - gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); - gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, timeStepIndex, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero); gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); - cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + if (cellResult()->hasCategoryResult()) { std::vector fnVector; @@ -383,18 +395,16 @@ void RimGeoMechView::updateLegends() { fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames(); } - cellResult()->legendConfig->setNamedCategoriesInverse(fnVector); + legendConfig->setNamedCategoriesInverse(fnVector); } - - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); - cvf::String legendTitle = cvfqt::Utils::toString( + QString legendTitle = caf::AppEnum(cellResult->resultPositionType()).uiText() + "\n" - + cellResult->resultFieldUiName()); + + cellResult->resultFieldUiName(); if (!cellResult->resultComponentUiName().isEmpty()) { - legendTitle += ", " + cvfqt::Utils::toString(cellResult->resultComponentUiName()); + legendTitle += ", " + cellResult->resultComponentUiName(); } if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || cellResult->resultFieldName() == "POR-Bar" @@ -408,7 +418,7 @@ void RimGeoMechView::updateLegends() legendTitle += " [GPa]"; } - cellResult()->legendConfig->setTitle(legendTitle); + legendConfig->setTitle(legendTitle); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 92b9d2b4e1..f874145529 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -41,6 +41,7 @@ class RimGeoMechPropertyFilterCollection; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; +class RimLegendConfig; namespace cvf { class CellRangeFilter; @@ -84,6 +85,8 @@ class RimGeoMechView : public RimGridView virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; + void updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index a1f7eed239..4a5b47eaeb 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -20,6 +20,7 @@ #include "RimIntersectionCollection.h" #include "Rim2dIntersectionViewCollection.h" +#include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCase.h" #include "RimIntersection.h" @@ -95,7 +96,9 @@ void RimIntersectionCollection::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) +void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { if(!this->isActive()) return; @@ -103,7 +106,7 @@ void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) { if(cs->isActive) { - cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex); + cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex, scalarColorMapper, ternaryColorMapper); } } @@ -186,6 +189,17 @@ void RimIntersectionCollection::syncronize2dIntersectionViews() ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::scheduleCreateDisplayModelAndRedraw2dIntersectionViews() +{ + for (RimIntersection* isection: m_intersections) + { + isection->correspondingIntersectionView()->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 167338c1e7..ec46b1e714 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -27,10 +27,12 @@ class RimIntersection; class RimIntersectionBox; class RimEclipseCellColors; class RimSimWellInView; +class RivTernaryScalarMapper; namespace cvf { class ModelBasicList; class Transform; + class ScalarMapper; } //================================================================================================== @@ -59,11 +61,14 @@ class RimIntersectionCollection : public caf::PdmObject void updateIntersectionBoxGeometry(); void syncronize2dIntersectionViews(); + void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); // Visualization interface void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); protected: diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 9cb5b85d36..6baafb6d97 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -51,6 +51,7 @@ #include "cvfqtUtils.h" #include +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -191,7 +192,7 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateLegend(); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) @@ -203,6 +204,8 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, } view->updateCurrentTimeStepAndRedraw(); + + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } #ifdef USE_PROTOTYPE_FEATURE_FRACTURES @@ -664,10 +667,11 @@ QString RimLegendConfig::categoryNameFromCategoryValue(double categoryResultValu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setTitle(const cvf::String& title) +void RimLegendConfig::setTitle(const QString& title) { - m_scalarMapperLegend->setTitle(title); - m_categoryLegend->setTitle(title); + auto cvfTitle = cvfqt::Utils::toString(title); + m_scalarMapperLegend->setTitle(cvfTitle); + m_categoryLegend->setTitle(cvfTitle); } //-------------------------------------------------------------------------------------------------- @@ -692,6 +696,7 @@ void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLe { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 2755264acf..41f0da15e8 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -114,7 +114,9 @@ class RimLegendConfig: public caf::PdmObject void setCategoryItems(const std::vector>& categories); QString categoryNameFromCategoryValue(double categoryResultValue) const; - void setTitle(const cvf::String& title); + void setTitle(const QString& title); + + void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } cvf::OverlayItem* legend(); @@ -134,7 +136,6 @@ class RimLegendConfig: public caf::PdmObject double roundToNumSignificantDigits(double value, double precision); friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); static cvf::Color3ubArray colorArrayFromColorType(ColorRangesType colorType); diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index e2254f286f..46bbf80131 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -289,7 +289,7 @@ void RimStimPlanColors::updateLegendData() legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); } - legendConfig->setTitle(cvfqt::Utils::toString(m_resultNameAndUnit())); + legendConfig->setTitle(m_resultNameAndUnit()); } } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 38613fde4e..b507afc267 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -23,6 +23,7 @@ #include "RiaColorTables.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimViewLinker.h" #include "RivTernarySaturationOverlayItem.h" @@ -146,7 +147,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed updateLabelText(); updateLegend(); - Rim3dView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) @@ -158,6 +159,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed } view->updateCurrentTimeStepAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -244,6 +246,7 @@ void RimTernaryLegendConfig::setUiValuesFromLegendConfig(const RimTernaryLegendC { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -316,6 +319,14 @@ void RimTernaryLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr uiOrdering.skipRemainingFields(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() const +{ + return m_legend.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -324,6 +335,14 @@ RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() return m_legend.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTernaryLegendConfig::setTitle(const QString& title) +{ + m_legend->setTitle(cvfqt::Utils::toString(title)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -462,7 +481,7 @@ void RimTernaryLegendConfig::updateLabelText() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() +const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const { return m_scalarMapper.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 544a980f36..de4bf7bb06 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -65,13 +65,17 @@ class RimTernaryLegendConfig : public caf::PdmObject RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); + void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const; void recreateLegend(); - RivTernarySaturationOverlayItem* legend(); - RivTernaryScalarMapper* scalarMapper(); + const RivTernarySaturationOverlayItem* legend() const; + RivTernarySaturationOverlayItem* legend(); + void setTitle(const QString& title); + + const RivTernaryScalarMapper* scalarMapper() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -83,9 +87,6 @@ class RimTernaryLegendConfig : public caf::PdmObject void updateLabelText(); double roundToNumSignificantDigits(double value, double precision); - friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); - private: caf::PdmField precision; caf::PdmField rangeMode; diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index 18aa3a9f90..63e3f98886 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -48,6 +48,7 @@ #include "cafPdmUiTreeOrdering.h" #include +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimViewController, "ViewController"); //-------------------------------------------------------------------------------------------------- @@ -688,6 +689,11 @@ void RimViewController::scheduleCreateDisplayModelAndRedrawForDependentView() co this->managedView()->scheduleCreateDisplayModelAndRedraw(); } } + + if (this->isResultColorControlled() && this->managedView() ) + { + this->managedView()->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 5e992a0bea..5a05568c83 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -33,6 +33,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimLegendConfig.h" #include "RimProject.h" #include "RimTernaryLegendConfig.h" @@ -152,10 +153,10 @@ void RimViewLinker::updateCellResult() eclipseView->cellResult()->legendConfig()->updateLegend(); eclipseView->cellResult()->ternaryLegendConfig()->setUiValuesFromLegendConfig(masterEclipseView->cellResult()->ternaryLegendConfig()); - eclipseView->cellResult()->ternaryLegendConfig()->updateLegend(); } eclipseView->scheduleCreateDisplayModelAndRedraw(); + eclipseView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } eclipseView->cellResult()->updateIconState(); @@ -190,6 +191,7 @@ void RimViewLinker::updateCellResult() } geoView->scheduleCreateDisplayModelAndRedraw(); + geoView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } geoView->cellResult()->updateIconState(); diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 2b62407c09..529f5adebe 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -39,6 +39,7 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" @@ -550,6 +551,7 @@ class RiaSetNNCProperty: public RiaSocketCommand // 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]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index ce3749ca88..3dad4c480b 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -38,6 +38,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimGeoMechView.h" #include "RimGeoMechCase.h" @@ -690,6 +691,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // 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]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } @@ -1053,6 +1055,8 @@ class RiaSetGridProperty : public RiaSocketCommand // 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]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } } From f21f6e969f01f2232e91fc4768093df004013bfb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Feb 2018 08:20:54 +0100 Subject: [PATCH 0194/1027] #1905 : Make sure picking on perforation intervals reports well path MD --- .../Commands/RicViewerEventInterface.h | 6 ++++ .../RicWellPathViewerEventHandler.cpp | 32 ++++++++++++++++--- .../RicWellPathViewerEventHandler.h | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/RicViewerEventInterface.h b/ApplicationCode/Commands/RicViewerEventInterface.h index 3e5fba9b07..bb0cefc42a 100644 --- a/ApplicationCode/Commands/RicViewerEventInterface.h +++ b/ApplicationCode/Commands/RicViewerEventInterface.h @@ -30,6 +30,9 @@ namespace cvf { } +//================================================================================================== +/// +//================================================================================================== class RicViewerEventObject { public: @@ -44,6 +47,9 @@ class RicViewerEventObject }; +//================================================================================================== +/// +//================================================================================================== class RicViewerEventInterface { public: diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index b6726a94a2..10b96ff7b5 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -22,6 +22,7 @@ #include "RiaApplication.h" #include "Rim3dView.h" +#include "RimPerforationInterval.h" #include "RimWellPath.h" #include "RiuMainWindow.h" @@ -56,18 +57,41 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT; const RivWellPathSourceInfo* wellPathSourceInfo = nullptr; - if(eventObject.m_partAndTriangleIndexPairs.size() > 0) + if(!eventObject.m_partAndTriangleIndexPairs.empty()) { const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); const cvf::Part* part = partAndTriangleIndexPair.first; const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); - if (!objectToSelect && sourceInfo) + if (sourceInfo) { - objectToSelect = sourceInfo->object(); + if (dynamic_cast(sourceInfo->object())) + { + objectToSelect = sourceInfo->object(); + + if (eventObject.m_partAndTriangleIndexPairs.size() > 1) + { + const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1]; + const cvf::Part* secondPickedPart = secondPair.first; + if (secondPickedPart) + { + auto wellPathSourceCandidate = dynamic_cast(secondPickedPart->sourceInfo()); + if (wellPathSourceCandidate) + { + RimWellPath* perforationWellPath = nullptr; + objectToSelect->firstAncestorOrThisOfType(perforationWellPath); + if (perforationWellPath == wellPathSourceCandidate->wellPath()) + { + wellPathSourceInfo = dynamic_cast(secondPickedPart->sourceInfo()); + wellPathTriangleIndex = secondPair.second; + } + } + } + } + } } - if (part && part->sourceInfo() && dynamic_cast(part->sourceInfo())) + if (part && dynamic_cast(part->sourceInfo())) { wellPathSourceInfo = dynamic_cast(part->sourceInfo()); wellPathTriangleIndex = partAndTriangleIndexPair.second; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h index 16dde93d89..a60d598229 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h @@ -30,6 +30,6 @@ class RicWellPathViewerEventHandler : public RicViewerEventInterface public: static RicWellPathViewerEventHandler* instance(); - virtual bool handleEvent(const RicViewerEventObject& eventObject); + bool handleEvent(const RicViewerEventObject& eventObject) override; }; From eef5fe6e55f63a0ad7f65ef83bcc785f1c1bb115 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 2 Feb 2018 09:06:24 +0100 Subject: [PATCH 0195/1027] #2428 Fracture: backwards compatibility of "Show mesh"-toggle --- .../RimFractureTemplateCollection.cpp | 117 ++++++++++++++++++ .../RimFractureTemplateCollection.h | 3 + .../RimStimPlanFractureTemplate.cpp | 11 ++ .../Completions/RimStimPlanFractureTemplate.h | 4 + .../ProjectDataModel/RimStimPlanColors.cpp | 8 ++ .../ProjectDataModel/RimStimPlanColors.h | 1 + 6 files changed, 144 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index aeefedc187..8469e6121e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -20,12 +20,25 @@ #include "RigStatisticsMath.h" +#include "RimCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" +#include "RimFracture.h" #include "RimFractureTemplate.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSimWellInViewCollection.h" +#include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RimWellPathFracture.h" +#include "RimWellPathFractureCollection.h" #include "cafPdmObject.h" +#include + CAF_PDM_SOURCE_INIT(RimFractureTemplateCollection, "FractureDefinitionCollection"); @@ -161,3 +174,107 @@ void RimFractureTemplateCollection::updateFilePathsFromProjectPath(const QString } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::initAfterRead() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj && proj->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) + { + bool setAllShowMeshToFalseOnAllEclipseViews = false; + + std::vector wellPathFractures; + RimWellPathCollection* wellPathCollection = proj->activeOilField()->wellPathCollection(); + wellPathCollection->descendantsIncludingThisOfType(wellPathFractures); + + for (RimWellPathFracture* fracture : wellPathFractures) + { + RimStimPlanFractureTemplate* stimPlanFractureTemplate = dynamic_cast(fracture->fractureTemplate()); + if (stimPlanFractureTemplate) + { + if (stimPlanFractureTemplate->showStimPlanMesh() == false) + { + setAllShowMeshToFalseOnAllEclipseViews = true; + break; + } + } + } + + std::vector eclipseViews; + + std::vector rimCases; + proj->allCases(rimCases); + + for (RimCase* rimCase : rimCases) + { + for (Rim3dView* view : rimCase->views()) + { + RimEclipseView* eclView = dynamic_cast(view); + if (eclView) + { + eclipseViews.push_back(eclView); + } + } + } + + for (RimEclipseView* eclipseView : eclipseViews) + { + if (setAllShowMeshToFalseOnAllEclipseViews) + { + eclipseView->stimPlanColors->setShowStimPlanMesh(false); + continue; + } + + //Find all fractures in all simWells + std::map stimPlanFractureTemplatesInView; + + std::vector fractures; + if (eclipseView->wellCollection) + { + eclipseView->wellCollection->descendantsIncludingThisOfType(fractures); + } + if (fractures.empty()) continue; + + for (RimFracture* fracture : fractures) + { + RimStimPlanFractureTemplate* stimPlanFractureTemplate = dynamic_cast(fracture->fractureTemplate()); + if (stimPlanFractureTemplate) + { + stimPlanFractureTemplatesInView[stimPlanFractureTemplate]; + } + } + + if (stimPlanFractureTemplatesInView.empty()) continue; + + auto templateIt = stimPlanFractureTemplatesInView.begin(); + + if (stimPlanFractureTemplatesInView.size() == 1) + { + eclipseView->stimPlanColors->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); + } + else + { + bool anySetShowStimPlanMeshIsSetToFalse = false; + for (templateIt; templateIt != stimPlanFractureTemplatesInView.end(); templateIt++) + { + if (templateIt->first->showStimPlanMesh() == false) + { + anySetShowStimPlanMeshIsSetToFalse = true; + break; + } + } + if (anySetShowStimPlanMeshIsSetToFalse) + { + eclipseView->stimPlanColors->setShowStimPlanMesh(false); + } + else + { + eclipseView->stimPlanColors->setShowStimPlanMesh(true); + } + } + } + } +} + diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index cbac6868eb..564c55ef9a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -49,4 +49,7 @@ class RimFractureTemplateCollection : public caf::PdmObject void setDefaultConductivityResultIfEmpty(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); +protected: + virtual void initAfterRead() override; + }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 8c782df2ef..0e2f858ced 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -75,6 +75,9 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); CAF_PDM_InitField(&m_conductivityResultNameOnFile, "ConductivityResultName", QString(""), "Active Conductivity Result Name", "", "", ""); + CAF_PDM_InitField(&m_showStimPlanMesh_OBSOLETE, "ShowStimPlanMesh", true, "", "", "", ""); + m_showStimPlanMesh_OBSOLETE.uiCapability()->setUiHidden(true); + m_fractureGrid = new RigFractureGrid(); m_readError = false; } @@ -430,6 +433,14 @@ QString RimStimPlanFractureTemplate::mapUiResultNameToFileResultName(const QStri return fileResultName; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStimPlanFractureTemplate::showStimPlanMesh() const +{ + return m_showStimPlanMesh_OBSOLETE(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 375da36450..9b2ddf7eef 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -88,6 +88,8 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate QString mapUiResultNameToFileResultName(const QString& uiResultName) const; void setDefaultConductivityResultIfEmpty(); + bool showStimPlanMesh() const; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; @@ -114,4 +116,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate caf::PdmField m_conductivityScalingFactor; cvf::ref m_fractureGrid; bool m_readError; + + caf::PdmField m_showStimPlanMesh_OBSOLETE; }; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 46bbf80131..d37ff6e2cb 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -89,6 +89,14 @@ RimStimPlanColors::~RimStimPlanColors() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanColors::setShowStimPlanMesh(bool showStimPlanMesh) +{ + m_showStimPlanMesh = showStimPlanMesh; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index 414efc5bb2..4473cf4ad3 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -60,6 +60,7 @@ class RimStimPlanColors : public RimCheckableNamedObject QString unit() const; cvf::Color3f defaultColor() const; bool showStimPlanMesh() const { return m_showStimPlanMesh; } + void setShowStimPlanMesh(bool showStimPlanMesh); void loadDataAndUpdate(); void updateLegendData(); From 0db32df1c487dd06ac48d16f14e7176ec53dc2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Sat, 3 Feb 2018 19:33:27 +0100 Subject: [PATCH 0196/1027] Add comment to describe usage of the weighted blended transparency system --- .../cafTransparentWBRenderConfiguration.cpp | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp index 9e05655d84..dd99dd03df 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp @@ -51,6 +51,73 @@ using namespace cvf; P4 Combination pass + ==================================== + Usage + ==================================== + class MyViewer : public caf::Viewer + { + Q_OBJECT; + public: + MyViewer(const QGLFormat& format, QWidget* parent) + : caf::Viewer(format, parent) + { + m_renderConf = new caf::TransparentWBRenderConfiguration; + m_renderConf->setUpRenderSequence(m_renderingSequence.p()); + + // Cerate overly item if needed + cvf::OverlyItem* overlayItem; // = new someTtem + m_renderConf->overlayRendering()->addOverlayItem(overlayItem); + } + + ~MyViewer(); + + virtual void optimizeClippingPlanes() + { + // ... Do ordinary clipplane adjustments + + m_renderConf->prepareForRendering(); + } + virtual void resizeGL(int width, int height) + { + m_renderConf->resize(width, height); + caf::Viewer::resizeGL(width, height); + } + + private: + cvf::ref m_renderConf; + }; + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + + ref createFacePartFromDrawableGeo(cvf::DrawableGeo* geo, + const Color3f& color, + float opacity, + bool useSpecularReflection) + { + ref part = new Part; + part->setDrawable(geo); + + cvf::Color4f colorWithAlpha(color); + colorWithAlpha.a() = opacity; + + caf::WBTransparencySurfaceEffectGenerator effGen(colorWithAlpha, caf::PO_NONE, useSpecularReflection); + ref eff = effGen.generateEffectFromCache(); + + if (opacity < 1.0) + { + part->setPriority(100); + } + + part->setEffect(eff.p()); + + return part; + } + + + + */ class RenderPassPreparator : public cvf::DynamicUniformSet From c6f8c957de0d4cdc05db927207535059bb767c5b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 5 Feb 2018 09:28:16 +0100 Subject: [PATCH 0197/1027] #2316 Tensor Vectors: Create Object in Project tree --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimGeoMechView.cpp | 10 +- .../ProjectDataModel/RimGeoMechView.h | 3 +- .../ProjectDataModel/RimTensorResults.cpp | 194 ++++++++++++++++++ .../ProjectDataModel/RimTensorResults.h | 72 +++++++ 5 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimTensorResults.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimTensorResults.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 845ed151fb..337ea62e44 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -37,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RimCalcScript.h ${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.h ${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.h ${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.h +${CEE_CURRENT_LIST_DIR}RimTensorResults.h ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.h ${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.h ${CEE_CURRENT_LIST_DIR}RimMimeData.h @@ -141,6 +142,7 @@ ${CEE_CURRENT_LIST_DIR}RimCalcScript.cpp ${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.cpp ${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.cpp ${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.cpp +${CEE_CURRENT_LIST_DIR}RimTensorResults.cpp ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.cpp ${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.cpp ${CEE_CURRENT_LIST_DIR}RimMimeData.cpp diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 1498ffde5d..af1d2a56d1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -30,13 +30,14 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimCellRangeFilterCollection.h" -#include "RimIntersectionCollection.h" #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" +#include "RimIntersectionCollection.h" #include "RimLegendConfig.h" +#include "RimTensorResults.h" #include "RimViewLinker.h" #include "RiuMainWindow.h" @@ -81,6 +82,11 @@ RimGeoMechView::RimGeoMechView(void) cellResult = new RimGeoMechCellColors(); cellResult.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_tensorResults, "TensorResults", "Tensor Results", "", "", ""); + m_tensorResults = new RimTensorResults(); + m_tensorResults.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiHidden(true); @@ -96,6 +102,7 @@ RimGeoMechView::~RimGeoMechView(void) { m_geomechCase = NULL; + delete m_tensorResults; delete cellResult; delete m_propertyFilterCollection; } @@ -624,6 +631,7 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_gridCollection()); uiTreeOrdering.add(cellResult()); + uiTreeOrdering.add(m_tensorResults()); uiTreeOrdering.add(m_crossSectionCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index f874145529..33d2bb5115 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -38,6 +38,7 @@ class RimGeoMechCase; class RimGeoMechCellColors; class RimGeoMechResultDefinition; class RimGeoMechPropertyFilterCollection; +class RimTensorResults; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; @@ -110,7 +111,7 @@ class RimGeoMechView : public RimGridView virtual void initAfterRead() override; - + caf::PdmChildField m_tensorResults; caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp new file mode 100644 index 0000000000..c3d14da831 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -0,0 +1,194 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimTensorResults.h" + +#include "RimGeoMechResultDefinition.h" + +#include "cafPdmUiListEditor.h" + + +CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::RimTensorResults() +{ + CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", ""); + m_resultPositionType.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", ""); + m_resultFieldName.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); + m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false); + m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); + m_resultFieldNameUiField.xmlCapability()->setIOWritable(false); + m_resultFieldNameUiField.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitField(&m_showTensors, "ShowTensors", true, "", "", "", ""); + + CAF_PDM_InitField(&m_principal1, "Principal1", true, "Principal 1", "", "", ""); + CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", ""); + CAF_PDM_InitField(&m_principal3, "Principal3", true, "Principal 3", "", "", ""); + + CAF_PDM_InitField(&m_threshold, "Threshold", 0.0, "Threshold", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", ""); + CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0, "Size Scale", "", "", ""); + + m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); + + m_resultPositionTypeUiField = RIG_ELEMENT_NODAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::~RimTensorResults() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimTensorResults::getResultMetaDataForUIFieldSetting() +{ + std::vector fieldNames; + fieldNames.push_back("SE"); + fieldNames.push_back("ST"); + fieldNames.push_back("E"); + + return fieldNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_resultPositionTypeUiField) + { + std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); + if (m_resultPositionTypeUiField() == m_resultPositionType()) + { + m_resultFieldNameUiField = m_resultFieldName(); + } + else + { + m_resultFieldNameUiField = ""; + } + } + + if (changedField == &m_resultFieldNameUiField) + { + m_resultPositionType = m_resultPositionTypeUiField; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimTensorResults::objectToggleField() +{ + return &m_showTensors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimTensorResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + *useOptionsOnly = true; + + if ( fieldNeedingOptions == &m_resultPositionTypeUiField) + { + using ResultEnum = caf::AppEnum; + + options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_ELEMENT_NODAL), + RigFemResultPosEnum::RIG_ELEMENT_NODAL)); + + options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_INTEGRATION_POINT), + RigFemResultPosEnum::RIG_INTEGRATION_POINT)); + } + else if (fieldNeedingOptions == &m_resultFieldNameUiField) + { + std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); + + for (int oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), QString::fromStdString(fieldCompNames[oIdx]))); + } + + } + else if (fieldNeedingOptions == &m_vectorColor) + { + options.push_back(caf::PdmOptionItemInfo("White, Gray, Black", nullptr)); + options.push_back(caf::PdmOptionItemInfo("Magenta, Brown, Black", nullptr)); + options.push_back(caf::PdmOptionItemInfo("Result Colors", nullptr)); + } + else if (fieldNeedingOptions == &m_scaleMethod) + { + options.push_back(caf::PdmOptionItemInfo("Result", nullptr)); + options.push_back(caf::PdmOptionItemInfo("Constant", nullptr)); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_resultPositionTypeUiField); + uiOrdering.add(&m_resultFieldNameUiField); + + caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility"); + visibilityGroup->add(&m_principal1); + visibilityGroup->add(&m_principal2); + visibilityGroup->add(&m_principal3); + visibilityGroup->add(&m_threshold); + + caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup("Vector Colors"); + vectorColorsGroup->add(&m_vectorColor); + + caf::PdmUiGroup* vectorSizeGroup = uiOrdering.addNewGroup("Vector Size"); + vectorSizeGroup->add(&m_scaleMethod); + vectorSizeGroup->add(&m_sizeScale); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::initAfterRead() +{ + m_resultPositionTypeUiField = m_resultPositionType; + m_resultFieldNameUiField = m_resultFieldName(); +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h new file mode 100644 index 0000000000..afb13c228d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RigFemResultPosEnum.h" + +#include + +#include + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimTensorResults : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimTensorResults(); + virtual ~RimTensorResults(); + +private: + std::vector getResultMetaDataForUIFieldSetting(); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + +private: + + caf::PdmField m_showTensors; + + caf::PdmField> m_resultPositionType; + caf::PdmField m_resultFieldName; + + caf::PdmField> m_resultPositionTypeUiField; + caf::PdmField m_resultFieldNameUiField; + + caf::PdmField m_principal1; + caf::PdmField m_principal2; + caf::PdmField m_principal3; + + caf::PdmField m_threshold; + + caf::PdmField m_vectorColor; + + caf::PdmField m_scaleMethod; + caf::PdmField m_sizeScale; + +}; From 8c4cad894f4478088b897ff313455266a99a3776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Feb 2018 13:23:44 +0100 Subject: [PATCH 0198/1027] #2391 intersections. New copy to all views command feature --- .../CMakeLists_files.cmake | 2 + ...pyIntersectionsToAllViewsInCaseFeature.cpp | 228 ++++++++++++++++++ ...CopyIntersectionsToAllViewsInCaseFeature.h | 49 ++++ ApplicationCode/ProjectDataModel/RimCase.cpp | 16 ++ ApplicationCode/ProjectDataModel/RimCase.h | 2 + .../RimContextCommandBuilder.cpp | 8 + .../RimIntersectionCollection.cpp | 16 ++ .../RimIntersectionCollection.h | 3 + 8 files changed, 324 insertions(+) create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp create mode 100644 ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h diff --git a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index 9795ba6966..3ec39b00dc 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.h +${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -18,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.cpp +${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp new file mode 100644 index 0000000000..04b831c4f5 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -0,0 +1,228 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCopyIntersectionsToAllViewsInCaseFeature.h" + +#include "RimIntersection.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" +#include "RimGridView.h" +#include "RimCase.h" +#include "RimGridView.h" +#include "RimEclipseCase.h" + +#include "cafCmdExecCommandManager.h" +#include "cafSelectionManagerTools.h" +#include "cafPdmUiItem.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT(RicCopyIntersectionsToAllViewsInCaseFeature, "RicCopyIntersectionsToAllViewsInCaseFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// Internal definitions +//-------------------------------------------------------------------------------------------------- +enum SelectionComposition {SEL_INVALID, SEL_COLLECTION, SEL_INTERSECTIONS, SEL_INTERSECTION_BOXES, SEL_BOTH_INTERSECTION_TYPES }; + +static RimIntersectionCollection* selectedIntersectionCollection(); +static std::vector selectedIntersections(); +static std::vector selectedIntersectionBoxes(); +static SelectionComposition selectionComposition(); +static RimCase* commonGridCase(std::vector selectedItems); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCopyIntersectionsToAllViewsInCaseFeature::isCommandEnabled() +{ + return selectionComposition() != SEL_INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered(bool isChecked) +{ + RimCase* gridCase = nullptr; + std::vector selItems; + caf::SelectionManager::instance()->selectedItems(selItems); + caf::PdmObjectHandle* objHandle = dynamic_cast(selItems.front()); + if (objHandle) objHandle->firstAncestorOrThisOfType(gridCase); + + if (gridCase) + { + SelectionComposition compostion = selectionComposition(); + if (compostion == SEL_COLLECTION) + { + RimIntersectionCollection* coll = selectedIntersectionCollection(); + copyIntersectionsToOtherViews(*gridCase, coll->intersections()); + copyIntersectionBoxesToOtherViews(*gridCase, coll->intersectionBoxes()); + } + + std::vector selIntersections = selectedIntersections(); + std::vector selIntersectionBoxes = selectedIntersectionBoxes(); + + if (compostion == SEL_INTERSECTIONS || compostion == SEL_BOTH_INTERSECTION_TYPES) + { + copyIntersectionsToOtherViews(*gridCase, selIntersections); + } + if (compostion == SEL_INTERSECTION_BOXES || compostion == SEL_BOTH_INTERSECTION_TYPES) + { + copyIntersectionBoxesToOtherViews(*gridCase, selIntersectionBoxes); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Copy.png")); + actionToSetup->setText("Copy intersections to all views in case"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews(RimCase& gridCase, std::vector intersections) +{ + for (RimIntersection* intersection : intersections) + { + for (Rim3dView* const view : gridCase.views()) + { + RimGridView* currGridView = dynamic_cast(view); + RimGridView* parentView = nullptr; + intersection->firstAncestorOrThisOfType(parentView); + + if (currGridView && parentView != nullptr && parentView != currGridView) + { + RimIntersectionCollection* destCollection = currGridView->crossSectionCollection(); + + RimIntersection* copy = dynamic_cast(intersection->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(copy); + + destCollection->appendIntersectionAndUpdate(copy); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector intersectionBoxes) +{ + for (RimIntersectionBox* intersectionBox : intersectionBoxes) + { + for (Rim3dView* const view : gridCase.views()) + { + RimGridView* currGridView = dynamic_cast(view); + RimGridView* parentView = nullptr; + intersectionBox->firstAncestorOrThisOfType(parentView); + + if (currGridView && parentView != nullptr && parentView != currGridView) + { + RimIntersectionCollection* destCollection = currGridView->crossSectionCollection(); + + RimIntersectionBox* copy = dynamic_cast(intersectionBox->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(copy); + + destCollection->appendIntersectionBoxAndUpdate(copy); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* selectedIntersectionCollection() +{ + std::vector selObjects = caf::selectedObjectsByType(); + return !selObjects.empty() ? selObjects[0] : nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector selectedIntersections() +{ + return caf::selectedObjectsByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector selectedIntersectionBoxes() +{ + return caf::selectedObjectsByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +SelectionComposition selectionComposition() +{ + std::vector allSelectedObjects; + caf::SelectionManager::instance()->selectedItems(allSelectedObjects); + + RimCase* gridCase = commonGridCase(allSelectedObjects); + if (gridCase && gridCase->gridViews().size() > 1) + { + RimIntersectionCollection* selColl = selectedIntersectionCollection(); + std::vector selIntersections = selectedIntersections(); + std::vector selIntersectionBoxes = selectedIntersectionBoxes(); + + if (selColl) + { + if (allSelectedObjects.size() == 1) return SEL_COLLECTION; + } + else + { + if (!selIntersections.empty() && !selIntersectionBoxes.empty()) return SEL_BOTH_INTERSECTION_TYPES; + else if (!selIntersections.empty()) return SEL_INTERSECTIONS; + else if (!selIntersectionBoxes.empty()) return SEL_INTERSECTION_BOXES; + } + } + return SEL_INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* commonGridCase(std::vector selectedItems) +{ + RimCase* gridCase = nullptr; + + for (caf::PdmUiItem* item : selectedItems) + { + caf::PdmObjectHandle* obj = dynamic_cast(item); + RimCase* itemCase = nullptr; + obj->firstAncestorOrThisOfType(itemCase); + + if (gridCase == nullptr) gridCase = itemCase; + else if (gridCase != itemCase) return nullptr; + } + return gridCase; +} diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h new file mode 100644 index 0000000000..17de22fb44 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafCmdExecuteCommand.h" +#include "cafPdmPointer.h" + +class RimCase; +class RimIntersection; +class RimIntersectionBox; +class RimIntersectionCollection; + + +//================================================================================================== +/// +//================================================================================================== +class RicCopyIntersectionsToAllViewsInCaseFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + + void copyIntersectionsToOtherViews(RimCase& gridCase, std::vector intersections); + void copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector intersectionBoxes); +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 34b94d6fc2..ee0ce66da0 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -31,6 +31,7 @@ #include "Rim2dIntersectionView.h" #include "Rim2dIntersectionViewCollection.h" #include "RimIntersection.h" +#include "RimGridView.h" CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); @@ -84,6 +85,21 @@ std::vector RimCase::views() const return allViews; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCase::gridViews() const +{ + std::vector grViews; + + for (Rim3dView* const view : views()) + { + RimGridView* grView = dynamic_cast(view); + if (grView) grViews.push_back(grView); + } + return grViews; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 029079cd9d..d13f3a908d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -31,6 +31,7 @@ #include class Rim3dView; +class RimGridView; class RimFormationNames; class RimTimeStepFilter; class Rim2dIntersectionView; @@ -54,6 +55,7 @@ class RimCase : public caf::PdmObject caf::PdmPtrField activeFormationNames; std::vector views() const; + std::vector gridViews() const; virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index ddff018635..00e1b39b19 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -453,6 +453,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { @@ -462,6 +464,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicAppendIntersectionBoxFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { @@ -469,6 +473,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { @@ -662,6 +668,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSimWellFractureFeature"; #endif // USE_PROTOTYPE_FEATURE_FRACTURES } + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } { diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index 4a5b47eaeb..cbb308b15c 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -151,6 +151,22 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimIntersectionCollection::intersections() const +{ + return m_intersections.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimIntersectionCollection::intersectionBoxes() const +{ + return m_intersectionBoxes.childObjects(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index ec46b1e714..5a0f362e1a 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -71,6 +71,9 @@ class RimIntersectionCollection : public caf::PdmObject const RivTernaryScalarMapper* ternaryColorMapper); void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + std::vector intersections() const; + std::vector intersectionBoxes() const; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual caf::PdmFieldHandle* objectToggleField(); From 7dbffd00759a4fca8ac40288d7fa554628741835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 5 Feb 2018 16:09:44 +0100 Subject: [PATCH 0199/1027] Add error to messages window if a requested regression test is not found. --- ApplicationCode/Application/RiaApplication.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index f0650b85fb..e24da9fa98 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -2155,6 +2155,10 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath()); } + else + { + RiaLogging::error("Could not find a regression test file named : " + testCaseFolder.absolutePath() + "/" + regTestProjectName + ".rsp"); + } } RiaLogging::info("\n"); From e8b29f7279c1b7c5bfbcceb2b2bed6e491619e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 5 Feb 2018 16:13:07 +0100 Subject: [PATCH 0200/1027] #2334 Add polyline visualization to 2D intersection view as a preparation for showing the main well. --- .../RivIntersectionGeometryGenerator.cpp | 164 +++++++++++++----- .../RivIntersectionGeometryGenerator.h | 37 ++-- .../Rim2dIntersectionView.cpp | 1 + 3 files changed, 141 insertions(+), 61 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 8a361e4e3f..981b1edee4 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -99,6 +99,90 @@ cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Ve 0.0, 0.0, 0.0, 1.0); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() +{ + cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); + cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation(-displayOffset); + + m_segementTransformPrLinePoint.clear(); + + double previousSectionFlattenedEndPosX = 0.0; + cvf::Vec3d previousSectionOrigo(cvf::Vec3d::ZERO); + + + for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) + { + m_segementTransformPrLinePoint.emplace_back(); + const std::vector& polyLine = m_polyLines[pLineIdx]; + + size_t pointCount = polyLine.size(); + + size_t lIdx = 0; + while ( lIdx < pointCount ) + { + size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); + if (idxToNextP == size_t(-1)) + { + size_t inc = 0; + while ((lIdx + inc) < pointCount) + { + m_segementTransformPrLinePoint.back().push_back(invSectionCS); + ++inc; + } + break; + } + + if (m_isFlattened) + { + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, m_extrusionDirection); + if ( pLineIdx == 0 && lIdx == 0 ) previousSectionOrigo = sectionLocalCS.translation(); + previousSectionFlattenedEndPosX += (sectionLocalCS.translation() - previousSectionOrigo).length(); + previousSectionOrigo = sectionLocalCS.translation(); + + invSectionCS = sectionLocalCS.getInverted(); + cvf::Vec3d flattenedTranslation(previousSectionFlattenedEndPosX, 0.0, 0.0); + + invSectionCS.setTranslation(invSectionCS.translation() + flattenedTranslation - displayOffset); + } + + size_t inc = 0; + while ((lIdx + inc) < idxToNextP) + { + m_segementTransformPrLinePoint.back().push_back(invSectionCS); + inc++; + } + + lIdx = idxToNextP; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline() +{ + CVF_ASSERT(m_segementTransformPrLinePoint.size() == m_polyLines.size()); + + for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) + { + m_flattenedOrOffsettedPolyLines.emplace_back(); + const std::vector& polyLine = m_polyLines[pLineIdx]; + + CVF_ASSERT(polyLine.size() == m_polyLines[pLineIdx].size()); + + for ( size_t pIdx = 0; pIdx < polyLine.size(); ++pIdx ) + { + m_flattenedOrOffsettedPolyLines.back().push_back(polyLine[pIdx].getTransformedPoint(m_segementTransformPrLinePoint[pLineIdx][pIdx])); + } + } +} //-------------------------------------------------------------------------------------------------- /// @@ -112,29 +196,26 @@ void RivIntersectionGeometryGenerator::calculateArrays() std::vector cellBorderLineVxes; cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); - - double previousSectionFlattenedEndPosX = 0.0; - cvf::Vec3d previousSectionOrigo(cvf::Vec3d::ZERO); + + calculateSegementTransformPrLinePoint(); + calculateFlattenedOrOffsetedPolyline(); for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx) { - const std::vector& m_polyLine = m_polyLines[pLineIdx]; - - if (m_polyLine.size() < 2) continue; + const std::vector& polyLine = m_polyLines[pLineIdx]; - std::vector m_adjustedPolyline; - adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline); + if (polyLine.size() < 2) continue; - size_t lineCount = m_adjustedPolyline.size(); + size_t lineCount = polyLine.size(); for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx) { - cvf::Vec3d p1 = m_adjustedPolyline[lIdx]; - cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1]; + size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); + + if (idxToNextP == size_t(-1)) break; + + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; - cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, m_extrusionDirection); - if (pLineIdx == 0 && lIdx == 0) previousSectionOrigo = sectionLocalCS.translation(); - previousSectionFlattenedEndPosX += (sectionLocalCS.translation() - previousSectionOrigo).length(); - previousSectionOrigo = sectionLocalCS.translation(); cvf::BoundingBox sectionBBox; sectionBBox.add(p1); @@ -194,6 +275,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d cellCorners[8]; size_t cornerIndices[8]; + cvf::Mat4d invSectionCS = m_segementTransformPrLinePoint[pLineIdx][lIdx]; + for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx) { size_t globalCellIdx = columnCellCandidates[cccIdx]; @@ -262,21 +345,9 @@ void RivIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx); cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx); - if (m_isFlattened) - { - cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); - cvf::Vec3d flattenedTranslation(previousSectionFlattenedEndPosX, 0.0,0.0); - - p0 = p0.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; - p1 = p1.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; - p2 = p2.getTransformedPoint(invSectionCS) + flattenedTranslation - displayOffset; - } - else - { - p0 -= displayOffset; - p1 -= displayOffset; - p2 -= displayOffset; - } + p0 = p0.getTransformedPoint(invSectionCS); + p1 = p1.getTransformedPoint(invSectionCS); + p2 = p2.getTransformedPoint(invSectionCS); triangleVertices.emplace_back(p0); triangleVertices.emplace_back(p1); @@ -334,6 +405,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_cellBorderLineVxes->assign(cellBorderLineVxes); } + //-------------------------------------------------------------------------------------------------- /// Generate surface drawable geo from the specified region /// @@ -377,7 +449,7 @@ cvf::ref RivIntersectionGeometryGenerator::createMeshDrawable( //-------------------------------------------------------------------------------------------------- cvf::ref RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable() { - return createLineAlongPolylineDrawable(m_polyLines); + return createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines); } //-------------------------------------------------------------------------------------------------- @@ -397,7 +469,7 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly for (size_t i = 0; i < polyLine.size(); ++i) { - vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset)); + vertices.push_back(cvf::Vec3f(polyLine[i])); if (i < polyLine.size() - 1) { lineIndices.push_back(static_cast(i)); @@ -428,7 +500,7 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly //-------------------------------------------------------------------------------------------------- cvf::ref RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable() { - return createPointsFromPolylineDrawable(m_polyLines); + return createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines); } @@ -446,7 +518,7 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol const std::vector& polyLine = polyLines[pLineIdx]; for (size_t i = 0; i < polyLine.size(); ++i) { - vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset)); + vertices.push_back(cvf::Vec3f(polyLine[i])); } } @@ -467,29 +539,31 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol } //-------------------------------------------------------------------------------------------------- -/// Remove the lines from the polyline that is nearly parallel to the extrusion direction +/// Find the next point in the polyline that avoids making the line nearly parallel to the extrusion direction +/// Returns size_t(-1) if no point is found //-------------------------------------------------------------------------------------------------- -void RivIntersectionGeometryGenerator::adjustPolyline(const std::vector& polyLine, - const cvf::Vec3d extrDir, - std::vector* adjustedPolyline) +size_t RivIntersectionGeometryGenerator::indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment) { size_t lineCount = polyLine.size(); - if (!polyLine.size()) return; + if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; + - adjustedPolyline->push_back(polyLine[0]); - cvf::Vec3d p1 = polyLine[0]; + cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; - for (size_t lIdx = 1; lIdx < lineCount; ++lIdx) + for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) { cvf::Vec3d p2 = polyLine[lIdx]; cvf::Vec3d p1p2 = p2 - p1; - if ((p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) + if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) { - adjustedPolyline->push_back(p2); - p1 = p2; + return lIdx; } } + + return -1; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 17ee66a49b..99ee9ec7f5 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -75,21 +75,26 @@ class RivIntersectionGeometryGenerator : public cvf::Object private: void calculateArrays(); - static void adjustPolyline(const std::vector& polyLine, - const cvf::Vec3d extrDir, - std::vector* adjustedPolyline); - - cvf::cref m_hexGrid; - const std::vector > m_polyLines; - cvf::Vec3d m_extrusionDirection; - bool m_isFlattened; - - // Output arrays - cvf::ref m_triangleVxes; - cvf::ref m_cellBorderLineVxes; - std::vector m_triangleToCellIdxMap; - std::vector m_triVxToCellCornerWeights; - - RimIntersection* m_crossSection; + void calculateSegementTransformPrLinePoint(); + void calculateFlattenedOrOffsetedPolyline(); + + static size_t indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment); + + RimIntersection* m_crossSection; + cvf::cref m_hexGrid; + const std::vector > m_polyLines; + cvf::Vec3d m_extrusionDirection; + bool m_isFlattened; + + // Output arrays + cvf::ref m_triangleVxes; + cvf::ref m_cellBorderLineVxes; + std::vector m_triangleToCellIdxMap; + std::vector m_triVxToCellCornerWeights; + std::vector > m_flattenedOrOffsettedPolyLines; + std::vector > m_segementTransformPrLinePoint; + }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index bcb28881cf..611e6155af 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -264,6 +264,7 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendPolylinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->applySingleColorEffect(); From 0679ec4ba58660eaf9c31b50514d9c0d88f5e218 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 13:13:55 +0100 Subject: [PATCH 0201/1027] #2431 : Add part manager for all well paths WIP --- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivWellPathsPartMgr.cpp | 164 ++++++++++++++++++ .../ModelVisualization/RivWellPathsPartMgr.h | 89 ++++++++++ 3 files changed, 255 insertions(+) create mode 100644 ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 8f5abe05ac..ec2778bea2 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -19,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.h ${CEE_CURRENT_LIST_DIR}RivSourceInfo.h ${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.h ${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h +${CEE_CURRENT_LIST_DIR}RivWellPathsPartMgr.h ${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.h ${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h ${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h @@ -63,6 +64,7 @@ ${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivSourceInfo.cpp ${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.cpp ${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp +${CEE_CURRENT_LIST_DIR}RivWellPathsPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp new file mode 100644 index 0000000000..1bd9d23399 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -0,0 +1,164 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellPathsPartMgr.h" + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimWellPathCollection.h" + +#include "RivWellPathPartMgr.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathsPartMgr::RivWellPathsPartMgr(Rim3dView* view) : m_rimView(view) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathsPartMgr::~RivWellPathsPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform) +{ + auto wellPathColl = wellPathCollection(); + + if (!wellPathColl->isActive()) return; + if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; + + buildPartManagers(); + + for (auto& partMgr : m_wellPatshsPartMgrs) + { + partMgr->appendStaticGeometryPartsToModel(model, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES +void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) +{ +/* + // Display of fractures is not supported in geomech view + const RimEclipseView* eclView = dynamic_cast(rimView); + if (!eclView) return; + + auto wellPathColl = wellPathCollection(); + + if (!wellPathColl->isActive()) return; + if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; + + buildPartManagers(); + + for (auto& partMgr : m_wellPatshsPartMgrs) + { + partMgr->appendStaticFracturePartsToModel(model, eclView); + } +*/ +} +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, const QDateTime& timeStamp, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform) +{ + auto wellPathColl = wellPathCollection(); + + if (!wellPathColl->isActive()) return; + if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; + + buildPartManagers(); + + for (auto& partMgr : m_wellPatshsPartMgrs) + { + partMgr->appendDynamicGeometryPartsToModel(model, timeStamp, characteristicCellSize, wellPathClipBoundingBox, + displayCoordTransform); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellPathsPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const +{ + auto it = m_mapFromViewToIndex.find(wellPath); + if (it == m_mapFromViewToIndex.end()) return -1; + + return it->second->segmentIndexFromTriangleIndex(triangleIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::clearGeometryCache() +{ + m_wellPatshsPartMgrs.clear(); + m_mapFromViewToIndex.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::scheduleGeometryRegen() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::buildPartManagers() +{ +/* + RimProject* proj = RiaApplication::instance()->project(); + auto wellPaths = proj->allWellPaths(); + + if (m_wellPatshsPartMgrs.size() != wellPaths.size()) + { + clearGeometryCache(); + + for (auto wellPath : wellPaths) + { + RivWellPathPartMgr* wppm = new RivWellPathPartMgr(wellPath, m_rimView); + m_wellPatshsPartMgrs.push_back(wppm); + m_mapFromViewToIndex[wellPath] = wppm; + } + } +*/ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathCollection* RivWellPathsPartMgr::wellPathCollection() const +{ + RimProject* proj = RiaApplication::instance()->project(); + + return proj->activeOilField()->wellPathCollection(); +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h new file mode 100644 index 0000000000..b2dc6cf6ff --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + + +#include "cvfBase.h" +#include "cvfCollection.h" +#include "cvfObject.h" + +#include +#include +#include "cafPdmPointer.h" + + +namespace cvf +{ + class BoundingBox; + class Transform; + class ModelBasicList; +} + +namespace caf +{ + class DisplayCoordTransform; +} + +class Rim3dView; +class RivWellPathPartMgr; +class RimWellPathCollection; +class RimWellPath; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RivWellPathsPartMgr : public cvf::Object +{ +public: + explicit RivWellPathsPartMgr(Rim3dView* view); + ~RivWellPathsPartMgr(); + + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform); + +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, + const Rim3dView* rimView); +#endif // USE_PROTOTYPE_FEATURE_FRACTURES + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + const QDateTime& timeStamp, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform); + + size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; + + + + +private: + void clearGeometryCache(); + void scheduleGeometryRegen(); + void buildPartManagers(); + RimWellPathCollection* wellPathCollection() const; + +private: + caf::PdmPointer m_rimView; + + cvf::Collection m_wellPatshsPartMgrs; + std::map m_mapFromViewToIndex; +}; From 5919cb20fb3fb934bf0f0aebf919e9e079beb942 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 13:23:14 +0100 Subject: [PATCH 0202/1027] #2431 : Refactor of well part manager --- .../ModelVisualization/RivWellPathPartMgr.cpp | 28 +++++++++++++++---- .../ModelVisualization/RivWellPathPartMgr.h | 11 ++++++-- .../RivWellPathSourceInfo.cpp | 8 ++++-- .../RivWellPathSourceInfo.h | 4 ++- .../ProjectDataModel/RimWellPath.cpp | 3 ++ .../RimWellPathCollection.cpp | 2 ++ 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 5e20adcc48..723d005145 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -57,15 +57,18 @@ #include "cvfFont.h" #include "cvfModelBasicList.h" #include "cvfPart.h" +#include "cvfScalarMapperDiscreteLinear.h" +#include "cvfTransform.h" #include "cvfqtUtils.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath) +RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view) { m_rimWellPath = wellPath; + m_rimView = view; } //-------------------------------------------------------------------------------------------------- @@ -80,15 +83,18 @@ RivWellPathPartMgr::~RivWellPathPartMgr() /// //-------------------------------------------------------------------------------------------------- #ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) { + const RimEclipseView* eclView = dynamic_cast(rimView); + if (!eclView) return; + if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return; for (RimWellPathFracture* f : m_rimWellPath->fractureCollection()->fractures()) { CVF_ASSERT(f); - f->fracturePartManager()->appendGeometryPartsToModel(model, eclView); + f->fracturePartManager()->appendGeometryPartsToModel(model, *eclView); } } #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -156,13 +162,16 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD { if (!m_rimWellPath || !m_rimWellPath->perforationIntervalCollection()->isChecked()) return; + RimWellPathCollection* wellPathCollection = this->wellPathCollection(); + if (!wellPathCollection) return; + RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; // Since we're using the index of measured depths to find the index of a point, ensure they're equal CVF_ASSERT(wellPathGeometry->m_measuredDepths.size() == wellPathGeometry->m_wellPathPoints.size()); - double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); double perforationRadius = wellPathRadius * 1.1; RivPipeGeometryGenerator geoGenerator; @@ -211,7 +220,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di if (wellPathGeometry->m_wellPathPoints.size() < 2) return; clearAllBranchData(); - double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); cvf::Vec3d textPosition; @@ -293,7 +302,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di pbd.m_surfacePart = new cvf::Part; pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath); + RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); pbd.m_surfacePart->setSourceInfo(sourceInfo); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); @@ -448,3 +457,10 @@ RimWellPathCollection* RivWellPathPartMgr::wellPathCollection() return wellPathCollection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellPathPartMgr::wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection) +{ + return wellPathCollection->wellPathRadiusScaleFactor() * m_rimWellPath->wellPathRadiusScaleFactor() * characteristicCellSize; +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index a41768c2e8..d5cbcaea15 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -28,7 +28,10 @@ namespace cvf { class Part; class ModelBasicList; + class Transform; + class Effect; class DrawableGeo; + class ScalarMapper; } namespace caf @@ -41,14 +44,14 @@ class RimProject; class RimWellPath; class RivFishbonesSubsPartMgr; class RimWellPathCollection; -class RimEclipseView; +class Rim3dView; class QDateTime; class RivWellPathPartMgr : public cvf::Object { public: - explicit RivWellPathPartMgr(RimWellPath* wellPath); + explicit RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view); ~RivWellPathPartMgr(); void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, @@ -58,7 +61,7 @@ class RivWellPathPartMgr : public cvf::Object #ifdef USE_PROTOTYPE_FEATURE_FRACTURES void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView); + const Rim3dView* eclView); #endif // USE_PROTOTYPE_FEATURE_FRACTURES void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, @@ -90,9 +93,11 @@ class RivWellPathPartMgr : public cvf::Object void clearAllBranchData(); inline RimWellPathCollection* wellPathCollection(); + inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); private: caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_rimView; struct RivPipeBranchData { diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp index 41b008e230..5637ef32bb 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp @@ -23,6 +23,7 @@ #include "RimCase.h" #include "RimWellPath.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RivWellPathPartMgr.h" @@ -32,9 +33,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath) +RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view) { m_wellPath = wellPath; + m_view = view; } //-------------------------------------------------------------------------------------------------- @@ -103,6 +105,8 @@ void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const c //-------------------------------------------------------------------------------------------------- size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const { - return m_wellPath->partMgr()->segmentIndexFromTriangleIndex(triangleIndex); + return -1; + + //return m_view->wellPathSegmentIndexFromTriangleIndex(triangleIndex, m_wellPath); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h index 6bb3935cdf..716bf92ee5 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h @@ -26,6 +26,7 @@ #include "cvfVector3.h" class RimWellPath; +class Rim3dView; //================================================================================================== /// @@ -33,7 +34,7 @@ class RimWellPath; class RivWellPathSourceInfo : public cvf::Object { public: - explicit RivWellPathSourceInfo(RimWellPath* wellPath); + explicit RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view); RimWellPath* wellPath() const; @@ -47,4 +48,5 @@ class RivWellPathSourceInfo : public cvf::Object private: caf::PdmPointer m_wellPath; + caf::PdmPointer m_view; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index e92f474504..d5fa25138e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -305,6 +305,7 @@ const RigWellPath* RimWellPath::wellPathGeometry() const //-------------------------------------------------------------------------------------------------- RivWellPathPartMgr* RimWellPath::partMgr() { +/* if (m_wellPathPartMgr.isNull()) { RimWellPathCollection* wpColl; @@ -313,6 +314,8 @@ RivWellPathPartMgr* RimWellPath::partMgr() } return m_wellPathPartMgr.p(); +*/ + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index f02e2528af..af136d4da1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -437,6 +437,7 @@ void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) { +/* if (!this->isActive()) return; if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; @@ -445,6 +446,7 @@ void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); partMgr->appendStaticFracturePartsToModel(model, eclView); } +*/ } #endif // USE_PROTOTYPE_FEATURE_FRACTURES From 91e062fd936e90e855e81990b1e24456da4f7757 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 13:26:33 +0100 Subject: [PATCH 0203/1027] #2431 : Add Rim3dView to event interface object --- ApplicationCode/Commands/RicViewerEventInterface.h | 7 +++++-- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicViewerEventInterface.h b/ApplicationCode/Commands/RicViewerEventInterface.h index bb0cefc42a..690597e7a5 100644 --- a/ApplicationCode/Commands/RicViewerEventInterface.h +++ b/ApplicationCode/Commands/RicViewerEventInterface.h @@ -29,6 +29,7 @@ namespace cvf { class Part; } +class Rim3dView; //================================================================================================== /// @@ -36,14 +37,16 @@ namespace cvf { class RicViewerEventObject { public: - RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, const std::vector>& partAndTriangleIndexPairs) + RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, const std::vector>& partAndTriangleIndexPairs, Rim3dView* view) : m_globalIntersectionPoint(globalIntersectionPoint), - m_partAndTriangleIndexPairs(partAndTriangleIndexPairs) + m_partAndTriangleIndexPairs(partAndTriangleIndexPairs), + m_view(view) { } cvf::Vec3d m_globalIntersectionPoint; std::vector> m_partAndTriangleIndexPairs; + Rim3dView* m_view; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 994580f888..39ed07d8b1 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -469,7 +469,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (!partAndTriangleIndexPairs.empty()) { - RicViewerEventObject viewerEventObject(globalIntersectionPoint, partAndTriangleIndexPairs); + RicViewerEventObject viewerEventObject(globalIntersectionPoint, partAndTriangleIndexPairs, m_reservoirView); for (size_t i = 0; i < m_viewerEventHandlers.size(); i++) { if (m_viewerEventHandlers[i]->handleEvent(viewerEventObject)) From cd575ef9c117b929909c9e4aff17d0f6b731f631 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 14:11:23 +0100 Subject: [PATCH 0204/1027] #2431 : Use well path part manager in Rim3dView --- .../RivWellPathSourceInfo.cpp | 4 +- .../RivWellPathsPartMgr.cpp | 4 -- .../ProjectDataModel/Rim3dView.cpp | 20 +++++-- ApplicationCode/ProjectDataModel/Rim3dView.h | 6 ++ .../ProjectDataModel/RimEclipseView.cpp | 3 +- .../RimWellPathCollection.cpp | 60 ------------------- .../ProjectDataModel/RimWellPathCollection.h | 15 ----- 7 files changed, 25 insertions(+), 87 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp index 5637ef32bb..82d459e092 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp @@ -105,8 +105,6 @@ void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const c //-------------------------------------------------------------------------------------------------- size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const { - return -1; - - //return m_view->wellPathSegmentIndexFromTriangleIndex(triangleIndex, m_wellPath); + return m_view->wellPathSegmentIndexFromTriangleIndex(triangleIndex, m_wellPath); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index 1bd9d23399..77fca1e308 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -63,7 +63,6 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* #ifdef USE_PROTOTYPE_FEATURE_FRACTURES void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) { -/* // Display of fractures is not supported in geomech view const RimEclipseView* eclView = dynamic_cast(rimView); if (!eclView) return; @@ -79,7 +78,6 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* { partMgr->appendStaticFracturePartsToModel(model, eclView); } -*/ } #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -135,7 +133,6 @@ void RivWellPathsPartMgr::scheduleGeometryRegen() {} //-------------------------------------------------------------------------------------------------- void RivWellPathsPartMgr::buildPartManagers() { -/* RimProject* proj = RiaApplication::instance()->project(); auto wellPaths = proj->allWellPaths(); @@ -150,7 +147,6 @@ void RivWellPathsPartMgr::buildPartManagers() m_mapFromViewToIndex[wellPath] = wppm; } } -*/ } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index e7afe8eb87..ec65ec1299 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -32,6 +32,8 @@ #include "RimViewLinker.h" #include "RimWellPathCollection.h" +#include "RivWellPathsPartMgr.h" + #include "RiuMainWindow.h" #include "RiuViewer.h" #include "RiuTimeStepChangedHandler.h" @@ -126,6 +128,8 @@ Rim3dView::Rim3dView(void) m_wellPathPipeVizModel = new cvf::ModelBasicList; m_wellPathPipeVizModel->setName("WellPathPipeModel"); + m_wellPathsPartManager = new RivWellPathsPartMgr(this); + this->setAs3DViewMdiWindow(); } @@ -639,9 +643,9 @@ void Rim3dView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, cvf::ref transForm = displayCoordTransform(); - wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, + m_wellPathsPartManager->appendStaticGeometryPartsToModel(wellPathModelBasicList, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, transForm.p()); wellPathModelBasicList->updateBoundingBoxesRecursive(); @@ -663,7 +667,7 @@ void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBas currentTimeStamp = timeStamps[currentTimeStep()]; } - wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, + m_wellPathsPartManager->appendDynamicGeometryPartsToModel(wellPathModelBasicList, currentTimeStamp, this->ownerCase()->characteristicCellSize(), wellPathClipBoundingBox, @@ -843,6 +847,14 @@ cvf::ref Rim3dView::displayCoordTransform() const return coordTrans; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t Rim3dView::wellPathSegmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const +{ + return m_wellPathsPartManager->segmentIndexFromTriangleIndex(triangleIndex, wellPath); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 70c8203db5..3b12a240e4 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -51,6 +51,8 @@ class RimViewController; class RimViewLinker; class RiuViewer; class RimWellPathCollection; +class RivWellPathsPartMgr; +class RimWellPath; namespace cvf { @@ -144,6 +146,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface cvf::ref displayCoordTransform() const override; + size_t wellPathSegmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; + virtual RimCase* ownerCase() const = 0; protected: @@ -189,6 +193,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface cvf::ref m_crossSectionVizModel; cvf::ref m_highlightVizModel; + cvf::ref m_wellPathsPartManager; + private: // Overridden PdmObject methods: diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 4f3b3ffea1..046f07373f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -69,6 +69,7 @@ #include "RivReservoirViewPartMgr.h" #include "RivSingleCellPartGenerator.h" #include "RivTernarySaturationOverlayItem.h" +#include "RivWellPathsPartMgr.h" #ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFracture.h" @@ -468,7 +469,7 @@ void RimEclipseView::createDisplayModel() addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - wellPathCollection()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), *this); + m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), this); #endif // USE_PROTOTYPE_FEATURE_FRACTURES m_wellPathPipeVizModel->updateBoundingBoxesRecursive(); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index af136d4da1..d0199227d5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -44,8 +44,6 @@ #include "RifWellPathFormationsImporter.h" #include "RifWellPathImporter.h" -#include "RivWellPathPartMgr.h" - #include "cafPdmUiEditorHandle.h" #include "cafProgressInfo.h" @@ -412,64 +410,6 @@ void RimWellPathCollection::scheduleRedrawAffectedViews() if (proj) proj->createDisplayModelAndRedrawAllViews(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) -{ - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendStaticGeometryPartsToModel(model, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView) -{ -/* - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendStaticFracturePartsToModel(model, eclView); - } -*/ -} -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) - -{ - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendDynamicGeometryPartsToModel(model, timeStamp, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index 904b705c3d..10bef47eaa 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -106,21 +106,6 @@ class RimWellPathCollection : public caf::PdmObject void scheduleRedrawAffectedViews(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); bool anyWellsContainingPerforationIntervals() const; From df231ab50afa74db9d27ef357a0371c6af326653 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 14:25:44 +0100 Subject: [PATCH 0205/1027] #2431 : Remove RivWellPathPartMgr from RimWellPath --- .../ProjectDataModel/RimWellPath.cpp | 20 ------------------- .../ProjectDataModel/RimWellPath.h | 6 ------ 2 files changed, 26 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index d5fa25138e..13a3114346 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -42,8 +42,6 @@ #include "RiuMainWindow.h" -#include "RivWellPathPartMgr.h" - #include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" @@ -300,24 +298,6 @@ const RigWellPath* RimWellPath::wellPathGeometry() const return m_wellPath.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivWellPathPartMgr* RimWellPath::partMgr() -{ -/* - if (m_wellPathPartMgr.isNull()) - { - RimWellPathCollection* wpColl; - this->firstAncestorOrThisOfType(wpColl); - if (wpColl) m_wellPathPartMgr = new RivWellPathPartMgr(this); - } - - return m_wellPathPartMgr.p(); -*/ - return nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 13f1c6e5ba..e8ae84c308 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -42,7 +42,6 @@ class RigWellPath; class RimProject; class RimWellLogFile; class RimFishboneWellPathCollection; -class RivWellPathPartMgr; class RimFishbonesCollection; class RimPerforationCollection; @@ -119,8 +118,6 @@ class RimWellPath : public caf::PdmObject RigWellPath* wellPathGeometry(); const RigWellPath* wellPathGeometry() const; - RivWellPathPartMgr* partMgr(); - bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); @@ -172,15 +169,12 @@ class RimWellPath : public caf::PdmObject cvf::ref m_wellPath; cvf::ref m_wellPathFormations; - cvf::ref m_wellPathPartMgr; caf::PdmField m_name; caf::PdmField m_wellPathFormationFilePath; caf::PdmField m_formationKeyInFile; caf::PdmChildArrayField m_wellLogFiles; - caf::PdmChildField m_wellLogFile_OBSOLETE; - }; From b69fc7836193b28748d82c22c933a7d87bccfe6f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 14:47:08 +0100 Subject: [PATCH 0206/1027] #2431 : Remove Rim3dView from function parameters --- .../ModelVisualization/RivWellPathPartMgr.cpp | 6 ++- .../ModelVisualization/RivWellPathPartMgr.h | 3 +- .../RivWellPathsPartMgr.cpp | 44 +++++++++---------- .../ModelVisualization/RivWellPathsPartMgr.h | 39 ++++++++-------- .../ProjectDataModel/RimEclipseView.cpp | 2 +- 5 files changed, 48 insertions(+), 46 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 723d005145..6dd075d461 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -83,9 +83,11 @@ RivWellPathPartMgr::~RivWellPathPartMgr() /// //-------------------------------------------------------------------------------------------------- #ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) +void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) { - const RimEclipseView* eclView = dynamic_cast(rimView); + if (m_rimView.isNull()) return; + + const RimEclipseView* eclView = dynamic_cast(m_rimView.p()); if (!eclView) return; if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index d5cbcaea15..0e96521871 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -60,8 +60,7 @@ class RivWellPathPartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const Rim3dView* eclView); + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); #endif // USE_PROTOTYPE_FEATURE_FRACTURES void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index 77fca1e308..ddccacc331 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -44,12 +44,9 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) { - auto wellPathColl = wellPathCollection(); - - if (!wellPathColl->isActive()) return; - if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; + if (!isWellPathVisible()) return; - buildPartManagers(); + createPartManagersIfRequired(); for (auto& partMgr : m_wellPatshsPartMgrs) { @@ -61,22 +58,15 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* /// //-------------------------------------------------------------------------------------------------- #ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) +void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) { - // Display of fractures is not supported in geomech view - const RimEclipseView* eclView = dynamic_cast(rimView); - if (!eclView) return; - - auto wellPathColl = wellPathCollection(); + if (!isWellPathVisible()) return; - if (!wellPathColl->isActive()) return; - if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - buildPartManagers(); + createPartManagersIfRequired(); for (auto& partMgr : m_wellPatshsPartMgrs) { - partMgr->appendStaticFracturePartsToModel(model, eclView); + partMgr->appendStaticFracturePartsToModel(model); } } #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -89,12 +79,9 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) { - auto wellPathColl = wellPathCollection(); + if (!isWellPathVisible()) return; - if (!wellPathColl->isActive()) return; - if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - buildPartManagers(); + createPartManagersIfRequired(); for (auto& partMgr : m_wellPatshsPartMgrs) { @@ -131,7 +118,7 @@ void RivWellPathsPartMgr::scheduleGeometryRegen() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::buildPartManagers() +void RivWellPathsPartMgr::createPartManagersIfRequired() { RimProject* proj = RiaApplication::instance()->project(); auto wellPaths = proj->allWellPaths(); @@ -158,3 +145,16 @@ RimWellPathCollection* RivWellPathsPartMgr::wellPathCollection() const return proj->activeOilField()->wellPathCollection(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivWellPathsPartMgr::isWellPathVisible() const +{ + auto wellPathColl = wellPathCollection(); + + if (!wellPathColl->isActive()) return false; + if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return false; + + return true; +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index b2dc6cf6ff..f1bab94ee7 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -23,9 +23,11 @@ #include "cvfCollection.h" #include "cvfObject.h" +#include "cafPdmPointer.h" + #include + #include -#include "cafPdmPointer.h" namespace cvf @@ -54,36 +56,35 @@ class RivWellPathsPartMgr : public cvf::Object explicit RivWellPathsPartMgr(Rim3dView* view); ~RivWellPathsPartMgr(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const Rim3dView* rimView); + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); #endif // USE_PROTOTYPE_FEATURE_FRACTURES - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + const QDateTime& timeStamp, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + const caf::DisplayCoordTransform* displayCoordTransform); - size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; + size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; private: - void clearGeometryCache(); - void scheduleGeometryRegen(); - void buildPartManagers(); + void clearGeometryCache(); + void scheduleGeometryRegen(); + void createPartManagersIfRequired(); RimWellPathCollection* wellPathCollection() const; + bool isWellPathVisible() const; private: - caf::PdmPointer m_rimView; - - cvf::Collection m_wellPatshsPartMgrs; + caf::PdmPointer m_rimView; + cvf::Collection m_wellPatshsPartMgrs; std::map m_mapFromViewToIndex; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 046f07373f..8c5294d94b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -469,7 +469,7 @@ void RimEclipseView::createDisplayModel() addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), this); + m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p()); #endif // USE_PROTOTYPE_FEATURE_FRACTURES m_wellPathPipeVizModel->updateBoundingBoxesRecursive(); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); From 67da4af831bd0b3fa5e8ccd5b0b09ee3e69fe99c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 14:50:50 +0100 Subject: [PATCH 0207/1027] #2431 : Use const ref and nullptr --- .../ModelVisualization/RivWellPathPartMgr.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 6dd075d461..806c258c83 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -110,7 +110,7 @@ void RivWellPathPartMgr::appendFishboneSubsPartsToModel(cvf::ModelBasicList* mod { if ( !m_rimWellPath || !m_rimWellPath->fishbonesCollection()->isChecked() ) return; - for ( auto rimFishboneSubs : m_rimWellPath->fishbonesCollection()->fishbonesSubs() ) + for (const auto& rimFishboneSubs : m_rimWellPath->fishbonesCollection()->fishbonesSubs() ) { cvf::ref fishbSubPartMgr = new RivFishbonesSubsPartMgr(rimFishboneSubs); fishbSubPartMgr->appendGeometryPartsToModel(model, displayCoordTransform, characteristicCellSize); @@ -134,7 +134,7 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod if (!fbWellPath->isChecked()) continue; std::vector displayCoords; - for (auto lateralDomainCoords : fbWellPath->coordinates()) + for (const auto& lateralDomainCoords : fbWellPath->coordinates()) { displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(lateralDomainCoords)); } @@ -329,7 +329,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di textPosition.z() += 2.2 * characteristicCellSize; - m_wellLabelPart = NULL; + m_wellLabelPart = nullptr; if (wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty()) { cvf::Font* font = RiaApplication::instance()->customFont(); @@ -431,11 +431,11 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::clearAllBranchData() { - m_pipeBranchData.m_pipeGeomGenerator = NULL; - m_pipeBranchData.m_surfacePart = NULL; - m_pipeBranchData.m_surfaceDrawable = NULL; - m_pipeBranchData.m_centerLinePart = NULL; - m_pipeBranchData.m_centerLineDrawable = NULL; + m_pipeBranchData.m_pipeGeomGenerator = nullptr; + m_pipeBranchData.m_surfacePart = nullptr; + m_pipeBranchData.m_surfaceDrawable = nullptr; + m_pipeBranchData.m_centerLinePart = nullptr; + m_pipeBranchData.m_centerLineDrawable = nullptr; } //-------------------------------------------------------------------------------------------------- From 9734774e21fcd2f951cee88a15007b32299c88a9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 20:39:42 +0100 Subject: [PATCH 0208/1027] #2439 Fracture : Set default permeability to 1e5 --- .../Completions/RimEllipseFractureTemplate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index ea99f27828..1d85043e1b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -278,14 +278,14 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_width = 0.5f; - m_permeability = 800000.0f; + m_permeability = 80000.0f; m_halfLength = 300.0f; m_height = 225.0f; } else { m_width = 0.01f; - m_permeability = 1000000.0f; + m_permeability = 100000.0f; m_halfLength = 100.0f; m_height = 75.0f; } From daad891b24cc1c25845094dc7d223a455430e4ae Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 07:27:21 +0100 Subject: [PATCH 0209/1027] System : Show grid name and global cell index in result info --- .../UserInterface/RiuResultTextBuilder.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index e06e48692e..9adf6ff8b6 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -148,7 +148,9 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) size_t i = 0; size_t j = 0; size_t k = 0; - if (eclipseCase->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) + + const RigGridBase* grid = eclipseCase->grid(m_gridIndex); + if (grid->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) { // Adjust to 1-based Eclipse indexing i++; @@ -160,11 +162,16 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) QString faceText = faceEnum.text(); text += QString("Face : %1").arg(faceText) + itemSeparator; - text += QString("Hit grid %1").arg(m_gridIndex) + itemSeparator; + + QString gridName = QString::fromStdString(grid->gridName()); + text += QString("Grid : %1 [%2]").arg(gridName).arg(m_gridIndex) + itemSeparator; + text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; + + size_t globalCellIndex = grid->reservoirCellIndex(m_cellIndex); + text += QString("Global Cell Index : %4").arg(globalCellIndex) + itemSeparator; } } - cvf::ref transForm = m_reservoirView->displayCoordTransform(); cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); From 4fdb7671a867a43ece6daf9a1f896d934faddaf3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 11:09:22 +0100 Subject: [PATCH 0210/1027] #2431 : Removed obsolete struct --- .../ModelVisualization/RivWellPathPartMgr.cpp | 60 +++++++++---------- .../ModelVisualization/RivWellPathPartMgr.h | 24 ++++---- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 806c258c83..1ce0af9c8a 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -228,13 +228,11 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di // Generate the well path geometry as a line and pipe structure { - RivPipeBranchData& pbd = m_pipeBranchData; + m_pipeGeomGenerator = new RivPipeGeometryGenerator; - pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; - - pbd.m_pipeGeomGenerator->setRadius(wellPathRadius); - pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - pbd.m_pipeGeomGenerator->setPipeColor( m_rimWellPath->wellPathColor()); + m_pipeGeomGenerator->setRadius(wellPathRadius); + m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); + m_pipeGeomGenerator->setPipeColor( m_rimWellPath->wellPathColor()); cvf::ref cvfCoords = new cvf::Vec3dArray; if (wellPathCollection->wellPathClip) @@ -264,11 +262,11 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]); clippedPoints.push_back(newPoint); - pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); } else { - pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); } for (size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) @@ -295,33 +293,33 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di textPosition = cvfCoords->get(0); - pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); - pbd.m_surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); - pbd.m_centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); + m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); + m_surfaceDrawable = m_pipeGeomGenerator->createPipeSurface(); + m_centerLineDrawable = m_pipeGeomGenerator->createCenterLine(); - if (pbd.m_surfaceDrawable.notNull()) + if (m_surfaceDrawable.notNull()) { - pbd.m_surfacePart = new cvf::Part; - pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); + m_surfacePart = new cvf::Part; + m_surfacePart->setDrawable(m_surfaceDrawable.p()); RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); - pbd.m_surfacePart->setSourceInfo(sourceInfo); + m_surfacePart->setSourceInfo(sourceInfo); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); - pbd.m_surfacePart->setEffect(eff.p()); + m_surfacePart->setEffect(eff.p()); } - if (pbd.m_centerLineDrawable.notNull()) + if (m_centerLineDrawable.notNull()) { - pbd.m_centerLinePart = new cvf::Part; - pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); + m_centerLinePart = new cvf::Part; + m_centerLinePart->setDrawable(m_centerLineDrawable.p()); caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); cvf::ref eff = gen.generateCachedEffect(); - pbd.m_centerLinePart->setEffect(eff.p()); + m_centerLinePart->setEffect(eff.p()); } } @@ -329,7 +327,6 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di textPosition.z() += 2.2 * characteristicCellSize; - m_wellLabelPart = nullptr; if (wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty()) { cvf::Font* font = RiaApplication::instance()->customFont(); @@ -382,14 +379,14 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m // The pipe geometry needs to be rebuilt on scale change to keep the pipes round buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); - if (m_pipeBranchData.m_surfacePart.notNull()) + if (m_surfacePart.notNull()) { - model->addPart(m_pipeBranchData.m_surfacePart.p()); + model->addPart(m_surfacePart.p()); } - if (m_pipeBranchData.m_centerLinePart.notNull()) + if (m_centerLinePart.notNull()) { - model->addPart(m_pipeBranchData.m_centerLinePart.p()); + model->addPart(m_centerLinePart.p()); } if (m_wellLabelPart.notNull()) @@ -431,11 +428,12 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::clearAllBranchData() { - m_pipeBranchData.m_pipeGeomGenerator = nullptr; - m_pipeBranchData.m_surfacePart = nullptr; - m_pipeBranchData.m_surfaceDrawable = nullptr; - m_pipeBranchData.m_centerLinePart = nullptr; - m_pipeBranchData.m_centerLineDrawable = nullptr; + m_pipeGeomGenerator = nullptr; + m_surfacePart = nullptr; + m_surfaceDrawable = nullptr; + m_centerLinePart = nullptr; + m_centerLineDrawable = nullptr; + m_wellLabelPart = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -443,7 +441,7 @@ void RivWellPathPartMgr::clearAllBranchData() //-------------------------------------------------------------------------------------------------- size_t RivWellPathPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex) { - return m_pipeBranchData.m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex); + return m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 0e96521871..79e83d7f0d 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -48,6 +48,9 @@ class Rim3dView; class QDateTime; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RivWellPathPartMgr : public cvf::Object { public: @@ -95,18 +98,13 @@ class RivWellPathPartMgr : public cvf::Object inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); private: - caf::PdmPointer m_rimWellPath; - caf::PdmPointer m_rimView; + caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_rimView; - struct RivPipeBranchData - { - cvf::ref m_pipeGeomGenerator; - cvf::ref m_surfacePart; - cvf::ref m_surfaceDrawable; - cvf::ref m_centerLinePart; - cvf::ref m_centerLineDrawable; - }; - - RivPipeBranchData m_pipeBranchData; - cvf::ref m_wellLabelPart; + cvf::ref m_pipeGeomGenerator; + cvf::ref m_surfacePart; + cvf::ref m_surfaceDrawable; + cvf::ref m_centerLinePart; + cvf::ref m_centerLineDrawable; + cvf::ref m_wellLabelPart; }; From d420b7432603ba3a31e630197245b87b40cb893d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 12:27:55 +0100 Subject: [PATCH 0211/1027] Remove unused function --- .../Completions/RimFractureTemplateCollection.cpp | 8 -------- .../Completions/RimFractureTemplateCollection.h | 1 - 2 files changed, 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 8469e6121e..efa09368a9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -115,14 +115,6 @@ void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, c if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::deleteFractureDefinitions() -{ - fractureDefinitions.deleteAllChildObjects(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 564c55ef9a..94ed9a4eec 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -44,7 +44,6 @@ class RimFractureTemplateCollection : public caf::PdmObject std::vector > stimPlanResultNamesAndUnits() const; void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; - void deleteFractureDefinitions(); void loadAndUpdateData(); void setDefaultConductivityResultIfEmpty(); From a283a468c2f2069e875a5b0b1a82d1f21d282131 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 12:42:13 +0100 Subject: [PATCH 0212/1027] #2447 Fracture : Show fracture legend when only ellipse fractures are present --- .../Application/RiaFractureDefines.cpp | 13 +++++++++++++ .../Application/RiaFractureDefines.h | 3 +++ .../RicNewEllipseFractureTemplateFeature.cpp | 1 + .../RimEllipseFractureTemplate.cpp | 19 +++++++++++++++++++ .../Completions/RimEllipseFractureTemplate.h | 3 +++ .../Completions/RimFractureTemplate.h | 3 +++ .../RimFractureTemplateCollection.cpp | 12 ++++-------- .../Completions/RimStimPlanFractureTemplate.h | 2 +- .../RigStimPlanFractureDefinition.cpp | 7 +++---- 9 files changed, 50 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Application/RiaFractureDefines.cpp b/ApplicationCode/Application/RiaFractureDefines.cpp index 30bfcda658..6fdbd19253 100644 --- a/ApplicationCode/Application/RiaFractureDefines.cpp +++ b/ApplicationCode/Application/RiaFractureDefines.cpp @@ -25,3 +25,16 @@ QString RiaDefines::conductivityResultName() { return "CONDUCTIVITY"; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitSystem) +{ + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "md-m"; + case RiaEclipseUnitTools::UNITS_FIELD: return "md-ft"; + default: return ""; + } +} diff --git a/ApplicationCode/Application/RiaFractureDefines.h b/ApplicationCode/Application/RiaFractureDefines.h index 5c7562cab4..7263302b2a 100644 --- a/ApplicationCode/Application/RiaFractureDefines.h +++ b/ApplicationCode/Application/RiaFractureDefines.h @@ -18,9 +18,12 @@ #pragma once +#include "RiaEclipseUnitTools.h" + #include namespace RiaDefines { QString conductivityResultName(); +QString unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitSystem); }; diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index 68d76eb9d2..cfadcdd889 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -57,6 +57,7 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) ellipseFractureTemplate->name = "Ellipse Fracture Template"; ellipseFractureTemplate->fractureTemplateUnit = fracDefColl->defaultUnitsForFracTemplates(); ellipseFractureTemplate->setDefaultValuesFromUnit(); + ellipseFractureTemplate->loadDataAndUpdate(); fracDefColl->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 1d85043e1b..ceeeaa6df1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -18,6 +18,7 @@ #include "RimEllipseFractureTemplate.h" +#include "RiaApplication.h" #include "RiaEclipseUnitTools.h" #include "RiaFractureDefines.h" #include "RiaLogging.h" @@ -28,10 +29,12 @@ #include "RigStatisticsMath.h" #include "RigTesselatorTools.h" +#include "RimEclipseView.h" #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" #include "RimProject.h" +#include "RimStimPlanColors.h" #include "cafPdmObject.h" @@ -72,6 +75,9 @@ RimEllipseFractureTemplate::~RimEllipseFractureTemplate() void RimEllipseFractureTemplate::loadDataAndUpdate() { setupFractureGridCells(); + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) activeView->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -324,6 +330,19 @@ void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& uiR } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RimEllipseFractureTemplate::uiResultNamesWithUnit() const +{ + std::vector> propertyNamesAndUnits; + + QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit()); + propertyNamesAndUnits.push_back(std::make_pair(RiaDefines::conductivityResultName(), condUnit)); + + return propertyNamesAndUnits; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index d9a73dfd24..842da494a6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -63,6 +63,9 @@ class RimEllipseFractureTemplate : public RimFractureTemplate MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const override; + + virtual std::vector> uiResultNamesWithUnit() const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 6524cebedc..dbb906c76f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -92,6 +92,9 @@ class RimFractureTemplate : public caf::PdmObject MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const = 0; + virtual std::vector > uiResultNamesWithUnit() const = 0; + + protected: caf::PdmChildField m_fractureContainment; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index efa09368a9..1c7f29891a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -75,15 +75,11 @@ std::vector > RimFractureTemplateCollection::stimPla for (const RimFractureTemplate* f : fractureDefinitions()) { - auto stimPlanFracture = dynamic_cast(f); - if (stimPlanFracture) - { - std::vector > namesAndUnits = stimPlanFracture->uiResultNamesWithUnit(); + std::vector > namesAndUnits = f->uiResultNamesWithUnit(); - for (auto nameAndUnit : namesAndUnits) - { - nameSet.insert(nameAndUnit); - } + for (const auto& nameAndUnit : namesAndUnits) + { + nameSet.insert(nameAndUnit); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 9b2ddf7eef..3d03ed2d86 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -76,7 +76,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate // Result Access std::vector timeSteps(); - std::vector > uiResultNamesWithUnit() const; + std::vector > uiResultNamesWithUnit() const override; std::vector> resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 482f697f6a..1df1b09e1d 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -18,7 +18,7 @@ #include "RigStimPlanFractureDefinition.h" - +#include "RiaFractureDefines.h" #include "RiaLogging.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" @@ -215,9 +215,8 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons bool wellCenterStimPlanCellFound = false; - QString condUnit; - if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC ) condUnit = "md-m"; - if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD ) condUnit = "md-ft"; + QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit); + std::vector> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultName, condUnit, m_activeTimeStepIndex); From 519771cb3803992d336a68e228bf4bce2fb9640a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 12:57:50 +0100 Subject: [PATCH 0213/1027] #2447 Fracture : Rename to fractureColors --- .../RivWellFracturePartMgr.cpp | 42 +++++++++---------- .../Completions/RimFracture.cpp | 2 +- .../RimFractureTemplateCollection.cpp | 10 ++--- .../RimFractureTemplateCollection.h | 2 +- .../RimStimPlanFractureTemplate.cpp | 2 +- .../ProjectDataModel/RimEclipseCase.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 18 ++++---- .../ProjectDataModel/RimEclipseView.h | 2 +- .../ProjectDataModel/RimStimPlanColors.cpp | 16 +++---- .../ProjectDataModel/RimStimPlanColors.h | 2 +- 10 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 47ddf15d52..261f8b8f51 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -85,7 +85,7 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr() //-------------------------------------------------------------------------------------------------- void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) { - if (!m_rimFracture->isChecked() || !eclView.stimPlanColors->isChecked()) return; + if (!m_rimFracture->isChecked() || !eclView.fractureColors->isChecked()) return; if (!m_rimFracture->fractureTemplate()) return; @@ -96,7 +96,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (stimPlanFracTemplate) { - if (eclView.stimPlanColors->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) + if (eclView.fractureColors->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) { auto part = createStimPlanElementColorSurfacePart(eclView); if (part.notNull()) parts.push_back(part.p()); @@ -107,7 +107,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (part.notNull()) parts.push_back(part.p()); } - if (eclView.stimPlanColors->showStimPlanMesh()) + if (eclView.fractureColors->showStimPlanMesh()) { auto part = createStimPlanMeshPart(eclView); if (part.notNull()) parts.push_back(part.p()); @@ -268,7 +268,7 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ #ifdef USE_PROTOTYPE_FEATURE_FRACTURES const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); - RimStimPlanColors* stimPlanColors = activeView.stimPlanColors; + RimStimPlanColors* stimPlanColors = activeView.fractureColors; QString condValueText = cell ? QString::number(cell->getConductivtyValue()) : "-"; QString iText = cell ? QString::number(cell->getI()) : "-"; @@ -377,19 +377,19 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc surfacePart->setDrawable(geo.p()); surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor()); + cvf::Color4f fractureColor = cvf::Color4f(activeView.fractureColors->defaultColor()); RimLegendConfig* legendConfig = nullptr; - if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked()) + if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { - legendConfig = activeView.stimPlanColors()->activeLegend(); + legendConfig = activeView.fractureColors()->activeLegend(); } if (legendConfig && legendConfig->scalarMapper()) { cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); - if (activeView.stimPlanColors->uiResultName() == RiaDefines::conductivityResultName()) + if (activeView.fractureColors->uiResultName() == RiaDefines::conductivityResultName()) { RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); if (ellipseFractureTemplate) @@ -445,9 +445,9 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa } RimLegendConfig* legendConfig = nullptr; - if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked()) + if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { - legendConfig = activeView.stimPlanColors()->activeLegend(); + legendConfig = activeView.fractureColors()->activeLegend(); } // Show selected result on the surface geometry and filter out triangles that have result values near 0 @@ -458,7 +458,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa std::vector perNodeResultValues(nodeCoords.size(), HUGE_VAL); { size_t idx = 0; - const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.stimPlanColors->uiResultName(), activeView.stimPlanColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); + const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors->uiResultName(), activeView.fractureColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); for (const std::vector& unmirroredDataAtDepth : dataToPlot) { const std::vector mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth); @@ -529,7 +529,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa { // No result is mapped, show the entire StimPlan surface with default color - return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.stimPlanColors->defaultColor()); + return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.fractureColors->defaultColor()); } return nullptr; @@ -578,16 +578,16 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); RimLegendConfig* legendConfig = nullptr; - if (activeView.stimPlanColors() && - activeView.stimPlanColors()->isChecked() && - activeView.stimPlanColors()->activeLegend()) + if (activeView.fractureColors() && + activeView.fractureColors()->isChecked() && + activeView.fractureColors()->activeLegend()) { - legendConfig = activeView.stimPlanColors()->activeLegend(); + legendConfig = activeView.fractureColors()->activeLegend(); scalarMapper = legendConfig->scalarMapper(); - QString resultNameFromColors = activeView.stimPlanColors->uiResultName(); - QString resultUnitFromColors = activeView.stimPlanColors->unit(); + QString resultNameFromColors = activeView.fractureColors->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, resultUnitFromColors, @@ -673,7 +673,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar { // No result is mapped, show the entire StimPlan surface with default color - return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.stimPlanColors->defaultColor()); + return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.fractureColors->defaultColor()); } } @@ -900,8 +900,8 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); std::vector stimPlanMeshVertices; - QString resultNameFromColors = activeView.stimPlanColors->uiResultName(); - QString resultUnitFromColors = activeView.stimPlanColors->unit(); + QString resultNameFromColors = activeView.fractureColors->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, resultUnitFromColors, diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index c1019aa681..01adeee8c7 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -87,7 +87,7 @@ void setDefaultFractureColorResult() for (RimStimPlanColors* const stimPlanColors : fractureColors) { - stimPlanColors->setDefaultResultNameForStimPlan(); + stimPlanColors->setDefaultResultName(); } } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 1c7f29891a..c3a87c0caf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -69,7 +69,7 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RimFractureTemplateCollection::stimPlanResultNamesAndUnits() const +std::vector > RimFractureTemplateCollection::resultNamesAndUnits() const { std::set > nameSet; @@ -211,7 +211,7 @@ void RimFractureTemplateCollection::initAfterRead() { if (setAllShowMeshToFalseOnAllEclipseViews) { - eclipseView->stimPlanColors->setShowStimPlanMesh(false); + eclipseView->fractureColors->setShowStimPlanMesh(false); continue; } @@ -240,7 +240,7 @@ void RimFractureTemplateCollection::initAfterRead() if (stimPlanFractureTemplatesInView.size() == 1) { - eclipseView->stimPlanColors->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); + eclipseView->fractureColors->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); } else { @@ -255,11 +255,11 @@ void RimFractureTemplateCollection::initAfterRead() } if (anySetShowStimPlanMeshIsSetToFalse) { - eclipseView->stimPlanColors->setShowStimPlanMesh(false); + eclipseView->fractureColors->setShowStimPlanMesh(false); } else { - eclipseView->stimPlanColors->setShowStimPlanMesh(true); + eclipseView->fractureColors->setShowStimPlanMesh(true); } } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 94ed9a4eec..b1116ccbbd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -41,7 +41,7 @@ class RimFractureTemplateCollection : public caf::PdmObject caf::PdmChildArrayField fractureDefinitions; caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; - std::vector > stimPlanResultNamesAndUnits() const; + std::vector > resultNamesAndUnits() const; void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; void loadAndUpdateData(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 19d5c6e507..68ab5b19d1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -278,7 +278,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() // Todo: Must update all views using this fracture template RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); - if (activeView) activeView->stimPlanColors->loadDataAndUpdate(); + if (activeView) activeView->fractureColors->loadDataAndUpdate(); updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 84cf383f49..34006434d7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -255,7 +255,7 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - rimEclipseView->stimPlanColors()->setDefaultResultNameForStimPlan(); + rimEclipseView->fractureColors()->setDefaultResultName(); #endif // USE_PROTOTYPE_FEATURE_FRACTURES } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 8c5294d94b..ca5e0ba07c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -124,9 +124,9 @@ RimEclipseView::RimEclipseView() faultResultSettings.uiCapability()->setUiHidden(true); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - CAF_PDM_InitFieldNoDefault(&stimPlanColors, "StimPlanColors", "Fracture", "", "", ""); - stimPlanColors = new RimStimPlanColors(); - stimPlanColors.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&fractureColors, "StimPlanColors", "Fracture", "", "", ""); + fractureColors = new RimStimPlanColors(); + fractureColors.uiCapability()->setUiHidden(true); #endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", ""); @@ -463,7 +463,7 @@ void RimEclipseView::createDisplayModel() // NB! StimPlan legend colors must be updated before well path geometry is added to the model // as the fracture geometry depends on the StimPlan legend colors #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - stimPlanColors->updateLegendData(); + fractureColors->updateLegendData(); #endif // USE_PROTOTYPE_FEATURE_FRACTURES addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); @@ -771,7 +771,7 @@ void RimEclipseView::onLoadDataAndUpdate() this->faultResultSettings()->customFaultResult()->loadResult(); #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - this->stimPlanColors->loadDataAndUpdate(); + this->fractureColors->loadDataAndUpdate(); #endif // USE_PROTOTYPE_FEATURE_FRACTURES updateMdiWindowVisibility(); @@ -1047,12 +1047,12 @@ void RimEclipseView::updateLegends() } #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - RimLegendConfig* stimPlanLegend = stimPlanColors()->activeLegend(); + RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); if (stimPlanLegend) { - stimPlanColors->updateLegendData(); + fractureColors->updateLegendData(); - if (stimPlanColors()->isChecked() && stimPlanLegend->legend()) + if (fractureColors()->isChecked() && stimPlanLegend->legend()) { m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); } @@ -1403,7 +1403,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering { if (!oilfield->fractureDefinitionCollection()->fractureDefinitions.empty()) { - uiTreeOrdering.add(stimPlanColors()); + uiTreeOrdering.add(fractureColors()); } } #endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 7503f1a73b..260cee92a1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -86,7 +86,7 @@ class RimEclipseView : public RimGridView caf::PdmChildField cellEdgeResult; caf::PdmChildField faultResultSettings; #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - caf::PdmChildField stimPlanColors; + caf::PdmChildField fractureColors; #endif // USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField wellCollection; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index d37ff6e2cb..d59ca4ddd3 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -56,7 +56,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- /// Internal methods //-------------------------------------------------------------------------------------------------- -static void setDefaultResultIfStimPlan(caf::PdmField &field); +static void setDefaultFractureResult(caf::PdmField &field); static QString toString(const std::pair& resultNameAndUnit); //-------------------------------------------------------------------------------------------------- @@ -104,7 +104,7 @@ void RimStimPlanColors::loadDataAndUpdate() { RimFractureTemplateCollection* fractureTemplates = fractureTemplateCollection(); - std::vector > resultNameAndUnits = fractureTemplates->stimPlanResultNamesAndUnits(); + std::vector > resultNameAndUnits = fractureTemplates->resultNamesAndUnits(); // Delete legends referencing results not present on file { @@ -178,7 +178,7 @@ QList RimStimPlanColors::calculateValueOptions(const caf options.push_back(caf::PdmOptionItemInfo("None", "")); - for (auto resultNameAndUnit : fractureTemplates->stimPlanResultNamesAndUnits()) + for (auto resultNameAndUnit : fractureTemplates->resultNamesAndUnits()) { QString resultNameAndUnitString = toString(resultNameAndUnit); options.push_back(caf::PdmOptionItemInfo(resultNameAndUnitString, resultNameAndUnitString)); @@ -253,9 +253,9 @@ QString RimStimPlanColors::uiResultName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStimPlanColors::setDefaultResultNameForStimPlan() +void RimStimPlanColors::setDefaultResultName() { - setDefaultResultIfStimPlan(m_resultNameAndUnit); + setDefaultFractureResult(m_resultNameAndUnit); } //-------------------------------------------------------------------------------------------------- @@ -332,7 +332,7 @@ void RimStimPlanColors::updateConductivityResultName() if (m_resultNameAndUnit().contains("conductivity", Qt::CaseInsensitive)) { RimFractureTemplateCollection* fractureTemplates = fractureTemplateCollection(); - for (auto resultNameAndUnit : fractureTemplates->stimPlanResultNamesAndUnits()) + for (auto resultNameAndUnit : fractureTemplates->resultNamesAndUnits()) { if (resultNameAndUnit.first.contains("conductivity", Qt::CaseInsensitive)) { @@ -447,7 +447,7 @@ QString toString(const std::pair& resultNameAndUnit) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void setDefaultResultIfStimPlan(caf::PdmField &field) +void setDefaultFractureResult(caf::PdmField &field) { RimProject* proj = RiaApplication::instance()->project(); @@ -459,7 +459,7 @@ void setDefaultResultIfStimPlan(caf::PdmField &field) { RimFractureTemplateCollection* templColl = proj->allFractureTemplateCollections().front(); - for (auto resultNameAndUnit : templColl->stimPlanResultNamesAndUnits()) + for (auto resultNameAndUnit : templColl->resultNamesAndUnits()) { if (resultNameAndUnit.first.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) { diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index 4473cf4ad3..8da9052202 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -56,7 +56,7 @@ class RimStimPlanColors : public RimCheckableNamedObject RimLegendConfig* activeLegend() const; QString uiResultName() const; - void setDefaultResultNameForStimPlan(); + void setDefaultResultName(); QString unit() const; cvf::Color3f defaultColor() const; bool showStimPlanMesh() const { return m_showStimPlanMesh; } From c695d40266e5ea3cb639b42e66b2bed058977f77 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Feb 2018 13:15:36 +0100 Subject: [PATCH 0214/1027] #2447 Fracture : Set default conductivity result when creating the first fracture --- .../RicNewSimWellFractureAtPosFeature.cpp | 13 ++++++++++++- .../Commands/RicNewSimWellFractureFeature.cpp | 10 ++++++++++ .../Commands/RicNewWellPathFractureFeature.cpp | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp index 2e8682e277..a7dca470f9 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp @@ -21,8 +21,10 @@ #include "RiaApplication.h" #include "RigEclipseCaseData.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimEclipseResultCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" #include "RimOilField.h" @@ -30,7 +32,7 @@ #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" -#include "Rim3dView.h" +#include "RimStimPlanColors.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -68,6 +70,15 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) if (!fractureCollection) return; RimSimWellFracture* fracture = new RimSimWellFracture(); + if (fractureCollection->simwellFractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors->setDefaultResultName(); + } + } + fractureCollection->simwellFractures.push_back(fracture); fracture->setClosestWellCoord(simWellItem->m_domainCoord, simWellItem->m_branchIndex); diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp index 789d212924..d9b0dd9362 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp @@ -32,6 +32,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSimWellFracture.h" +#include "RimStimPlanColors.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" @@ -63,6 +64,15 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) objHandle->firstAncestorOrThisOfType(eclipseWell); RimSimWellFracture* fracture = new RimSimWellFracture(); + if (eclipseWell->simwellFractureCollection()->simwellFractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors->setDefaultResultName(); + } + } + eclipseWell->simwellFractureCollection()->simwellFractures.push_back(fracture); RimOilField* oilfield = nullptr; diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp index 4918c73bc1..30a4c3c4ad 100644 --- a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp @@ -18,21 +18,24 @@ #include "RicNewWellPathFractureFeature.h" -#include "RicFractureNameGenerator.h" - #include "RiaApplication.h" +#include "RicFractureNameGenerator.h" + #include "RigWellPath.h" #include "RimCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimStimPlanColors.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" + #include "RiuMainWindow.h" #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" @@ -58,6 +61,15 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection(); CVF_ASSERT(fractureCollection); + if (fractureCollection->fractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors->setDefaultResultName(); + } + } + RimWellPathFracture* fracture = new RimWellPathFracture(); fractureCollection->fractures.push_back(fracture); From 69cc77e02604ea9fdffe5952e8b52286e216e35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Feb 2018 14:39:38 +0100 Subject: [PATCH 0215/1027] #2427 2d intersection view. Display result info and curves --- .../UserInterface/RiuPvtPlotUpdater.cpp | 16 ++++++- .../RiuRelativePermeabilityPlotUpdater.cpp | 16 ++++++- .../RiuSelectionChangedHandler.cpp | 42 +++++++++++++++--- .../RiuSelectionChangedHandler.h | 2 + .../UserInterface/RiuSelectionManager.cpp | 44 ++++++++++++++++++- .../UserInterface/RiuSelectionManager.h | 41 +++++++++++++++-- .../UserInterface/RiuViewerCommands.cpp | 31 +++++++++---- 7 files changed, 171 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index ef97c9fbe4..082a0f683c 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -31,6 +31,8 @@ #include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "cvfBase.h" //#include "cvfTrace.h" @@ -68,8 +70,18 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selecti m_sourceEclipseViewOfLastPlot = NULL; bool mustClearPlot = true; - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(selectionItem); - const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + + if (!eclipseSelectionItem && !eclipseView) + { + const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast(selectionItem); + if (intersectionSelItem && intersectionSelItem->eclipseSelectionItem()) + { + eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); + eclipseView = eclipseSelectionItem->m_view; + } + } if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView) { diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index eb0a96c593..92c89b7c3b 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -30,6 +30,8 @@ #include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "cvfBase.h" //#include "cvfTrace.h" @@ -68,8 +70,18 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelec m_sourceEclipseViewOfLastPlot = NULL; bool mustClearPlot = true; - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(selectionItem); - const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + + if (!eclipseSelectionItem && !eclipseView) + { + const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast(selectionItem); + if (intersectionSelItem && intersectionSelItem->eclipseSelectionItem()) + { + eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); + eclipseView = eclipseSelectionItem->m_view; + } + } if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView) { diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 233a5281dd..40818f6243 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -35,6 +35,8 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "RimProject.h" #include "RiuFemResultTextBuilder.h" @@ -238,6 +240,21 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelec } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSelectionChangedHandler::addCurveFromSelectionItem(const Riu2dIntersectionSelectionItem* selectionItem) const +{ + if (selectionItem->eclipseSelectionItem()) + { + addCurveFromSelectionItem(selectionItem->eclipseSelectionItem()); + } + else if (selectionItem->geoMechSelectionItem()) + { + addCurveFromSelectionItem(selectionItem->geoMechSelectionItem()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -255,6 +272,13 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuSelectionIte addCurveFromSelectionItem(geomSelectionItem); } + else if (itemAdded->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) + { + const Riu2dIntersectionSelectionItem* _2dSelectionItem = static_cast(itemAdded); + + addCurveFromSelectionItem(_2dSelectionItem); + } + } //-------------------------------------------------------------------------------------------------- @@ -283,11 +307,19 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd QString resultInfo; QString pickInfo; - if (itemAdded != NULL) + RiuSelectionItem* selItem = const_cast(itemAdded); + if (selItem != NULL) { - if (itemAdded->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT) + if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) + { + const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast(selItem); + if (wrapperSelItem && wrapperSelItem->eclipseSelectionItem()) selItem = wrapperSelItem->eclipseSelectionItem(); + else if (wrapperSelItem && wrapperSelItem->geoMechSelectionItem()) selItem = wrapperSelItem->geoMechSelectionItem(); + } + + if (selItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT) { - const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast(itemAdded); + const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast(selItem); RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); @@ -300,9 +332,9 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd pickInfo = textBuilder.geometrySelectionText(", "); } - else if (itemAdded->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT) + else if (selItem->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT) { - const RiuGeoMechSelectionItem* geomSelectionItem = static_cast(itemAdded); + const RiuGeoMechSelectionItem* geomSelectionItem = static_cast(selItem); RimGeoMechView* geomView = geomSelectionItem->m_view.p(); RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep()); diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h index 9d6e4c9865..f9d876e95b 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h @@ -22,6 +22,7 @@ class RiuSelectionItem; class RiuEclipseSelectionItem; class RiuGeoMechSelectionItem; +class Riu2dIntersectionSelectionItem; //-------------------------------------------------------------------------------------------------- /// @@ -40,6 +41,7 @@ class RiuSelectionChangedHandler void addCurveFromSelectionItem(const RiuSelectionItem* itemAdded) const; void addCurveFromSelectionItem(const RiuEclipseSelectionItem* selectionItem) const; void addCurveFromSelectionItem(const RiuGeoMechSelectionItem* selectionItem) const; + void addCurveFromSelectionItem(const Riu2dIntersectionSelectionItem* selectionItem) const; void scheduleUpdateForAllVisibleViews() const; void updateResultInfo(const RiuSelectionItem* itemAdded) const; diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.cpp b/ApplicationCode/UserInterface/RiuSelectionManager.cpp index c18555d2a2..2406531454 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionManager.cpp @@ -19,9 +19,11 @@ #include "RiuSelectionManager.h" +#include "RimGridView.h" #include "RimEclipseView.h" #include "RimGeoMechView.h" #include "RimSimWellInView.h" +#include "Rim2dIntersectionView.h" #include "RimWellPath.h" #include "RivSimWellPipeSourceInfo.h" @@ -155,7 +157,13 @@ void RiuSelectionManager::deleteAllItemsFromSelection(int role) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex, cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint) +RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, + size_t gridIndex, + size_t cellIndex, + size_t nncIndex, + cvf::Color3f color, + cvf::StructGridInterface::FaceType face, + const cvf::Vec3d& localIntersectionPoint) : m_view(view), m_gridIndex(gridIndex), m_gridLocalCellIndex(cellIndex), @@ -207,6 +215,40 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem) +{ + m_eclipseSelItem = dynamic_cast(selItem); + m_geoMechSelItem = dynamic_cast(selItem); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riu2dIntersectionSelectionItem::~Riu2dIntersectionSelectionItem() +{ + if (m_eclipseSelItem) delete m_eclipseSelItem; + if (m_geoMechSelItem) delete m_geoMechSelItem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuEclipseSelectionItem* Riu2dIntersectionSelectionItem::eclipseSelectionItem() const +{ + return m_eclipseSelItem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuGeoMechSelectionItem* Riu2dIntersectionSelectionItem::geoMechSelectionItem() const +{ + return m_geoMechSelItem; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.h b/ApplicationCode/UserInterface/RiuSelectionManager.h index 9b2798db7a..3b731731a5 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.h +++ b/ApplicationCode/UserInterface/RiuSelectionManager.h @@ -32,9 +32,11 @@ // #include "RivWellPathSourceInfo.h" // #include "RivWellPipeSourceInfo.h" +class RimGridView; class RimEclipseView; class RimGeoMechView; class RimSimWellInView; +class Rim2dIntersectionView; class RimWellPath; class RiuSelectionChangedHandler; class RiuSelectionItem; @@ -109,7 +111,8 @@ class RiuSelectionItem GEOMECH_SELECTION_OBJECT, WELLPATH_SELECTION_OBJECT, SIMWELL_SELECTION_OBJECT, - GENERAL_SELECTION_OBJECT + GENERAL_SELECTION_OBJECT, + INTERSECTION_SELECTION_OBJECT }; public: @@ -128,8 +131,13 @@ class RiuSelectionItem class RiuEclipseSelectionItem : public RiuSelectionItem { public: - explicit RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex, - cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint); + explicit RiuEclipseSelectionItem(RimEclipseView* view, + size_t gridIndex, + size_t cellIndex, + size_t nncIndex, + cvf::Color3f color, + cvf::StructGridInterface::FaceType face, + const cvf::Vec3d& localIntersectionPoint); virtual ~RiuEclipseSelectionItem() {}; @@ -190,6 +198,33 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem }; +//================================================================================================== +// +// +// +//================================================================================================== +class Riu2dIntersectionSelectionItem : public RiuSelectionItem +{ +public: + explicit Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem); + + virtual ~Riu2dIntersectionSelectionItem(); + + virtual RiuSelectionType type() const + { + return INTERSECTION_SELECTION_OBJECT; + } + +public: + RiuEclipseSelectionItem* eclipseSelectionItem() const; + RiuGeoMechSelectionItem* geoMechSelectionItem() const; + +private: + RiuEclipseSelectionItem* m_eclipseSelItem; + RiuGeoMechSelectionItem* m_geoMechSelItem; +}; + + //================================================================================================== // // diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 39ed07d8b1..b422f82915 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -58,6 +58,7 @@ #include "RimPerforationInterval.h" #include "RimStimPlanFractureTemplate.h" #include "RimEllipseFractureTemplate.h" +#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" #include "RiuSelectionManager.h" @@ -605,27 +606,35 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM RiuSelectionItem* selItem = nullptr; { + Rim2dIntersectionView* intersectionView = dynamic_cast(m_reservoirView.p()); RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); + + if (intersectionView) + { + intersectionView->intersection()->firstAncestorOrThisOfType(eclipseView); + intersectionView->intersection()->firstAncestorOrThisOfType(geomView); + } + if (eclipseView) { selItem = new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, nncIndex, curveColor, face, localIntersectionPoint); } - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (geomView ) + if (geomView) { if(intersectionHit) selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint, intersectionTriangleHit); else selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint); } - + if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(selItem); } if (appendToSelection) { RiuSelectionManager::instance()->appendItemToSelection(selItem); } - else + else if(selItem) { RiuSelectionManager::instance()->setSelectedItem(selItem); } @@ -648,17 +657,23 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* cr { CVF_ASSERT(cellIndex && gridIndex); - RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (eclipseView) + RimCase* ownerCase = m_reservoirView->ownerCase(); + RimEclipseCase* eclipseCase = dynamic_cast(ownerCase); + RimGeoMechCase* geomCase = dynamic_cast(ownerCase); + if (eclipseCase) { + //RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimEclipseView* eclipseView; + crossSectionSourceInfo->crossSection()->firstAncestorOrThisOfType(eclipseView); + size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex]; + *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } - else if (geomView) + else if (geomCase) { *cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; *gridIndex = 0; From 59b0a4bd1e4119494d8facbf608ce486641f5ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 6 Feb 2018 14:39:19 +0100 Subject: [PATCH 0216/1027] Remove obsolete code --- ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h | 2 -- ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp | 1 - ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp | 1 - ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp | 3 +-- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h index 82e685a509..368f9c8fe1 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h @@ -54,7 +54,6 @@ class RivPipeGeometryGenerator : public cvf::Object // Appearance void setRadius(double radius); void setCrossSectionVertexCount(size_t vertexCount); - void setPipeColor(cvf::Color3f val) { m_pipeColor = val; } cvf::ref createPipeSurface(); cvf::ref createCenterLine(); @@ -100,5 +99,4 @@ class RivPipeGeometryGenerator : public cvf::Object double m_minimumBendAngle; double m_bendScalingFactor; size_t m_crossSectionNodeCount; - cvf::Color3f m_pipeColor; }; diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index fb8d62303b..ac1df3fd54 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -117,7 +117,6 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() pbd.m_pipeGeomGenerator->setRadius(pipeRadius); pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); - pbd.m_pipeGeomGenerator->setPipeColor( m_rimWell->wellPipeColor()); cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index f2e91fdc4c..e641f079d6 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -125,7 +125,6 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) cvf::ref pipeGeomGenerator = new RivPipeGeometryGenerator; pipeGeomGenerator->setPipeCenterCoords(wellHeadPipeCoords.p()); - pipeGeomGenerator->setPipeColor(well->wellPipeColor()); pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 1ce0af9c8a..a92dbd9b07 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -231,8 +231,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di m_pipeGeomGenerator = new RivPipeGeometryGenerator; m_pipeGeomGenerator->setRadius(wellPathRadius); - m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - m_pipeGeomGenerator->setPipeColor( m_rimWellPath->wellPathColor()); + m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); cvf::ref cvfCoords = new cvf::Vec3dArray; if (wellPathCollection->wellPathClip) From d208f6325503510e06ce3c237fcd79d248d2d6e7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 08:54:53 +0100 Subject: [PATCH 0217/1027] Add .clang-format to cmakelist --- .clang-format | 2 +- ApplicationCode/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 96165b38cd..c65a72342f 100644 --- a/.clang-format +++ b/.clang-format @@ -35,7 +35,7 @@ BraceWrapping: BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializersBeforeComma: true BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 130 diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 1bbeff0696..8f942d5a1f 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -278,6 +278,7 @@ set( EXE_FILES ${HEADER_FILES} ${REFERENCED_CMAKE_FILES} ../ResInsightVersion.cmake + ../.clang-format ) add_executable( ResInsight ${EXE_FILES} ) From 598d2c9b964c8eba03e5558657ccc380f02152ee Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 09:55:28 +0100 Subject: [PATCH 0218/1027] System : clang-format : One parameter per line --- .clang-format | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-format b/.clang-format index c65a72342f..f3a6bf266c 100644 --- a/.clang-format +++ b/.clang-format @@ -8,7 +8,7 @@ AlignConsecutiveDeclarations: true AlignEscapedNewlinesLeft: true AlignOperands: true AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true @@ -18,8 +18,8 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true +BinPackArguments: false +BinPackParameters: false BraceWrapping: AfterClass: true AfterControlStatement: true From bd14c65678211e2a5b3d65bbe3b6fc9810cd77ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 7 Feb 2018 11:40:48 +0100 Subject: [PATCH 0219/1027] #2334 Add visualization of well paths and simulation wells to Intersection Views. --- .../RivIntersectionGeometryGenerator.h | 1 + .../Intersections/RivIntersectionPartMgr.cpp | 216 +++++++++++++++--- .../Intersections/RivIntersectionPartMgr.h | 31 +-- .../Rim2dIntersectionView.cpp | 1 + 4 files changed, 201 insertions(+), 48 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 99ee9ec7f5..5feedf30fe 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -65,6 +65,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object cvf::ref createLineAlongPolylineDrawable(const std::vector >& polyLines); cvf::ref createPointsFromPolylineDrawable(const std::vector >& polyLines); + const std::vector >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; } // Mapping between cells and geometry const std::vector& triangleToCellIndex() const; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 9cfca35775..83d3c90f1e 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -26,6 +26,7 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" +#include "Rim2dIntersectionView.h" #include "RimIntersection.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -34,16 +35,23 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimLegendConfig.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" #include "RimTernaryLegendConfig.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" #include "RivHexGridIntersectionTools.h" #include "RivIntersectionGeometryGenerator.h" #include "RivIntersectionSourceInfo.h" #include "RivPartPriority.h" +#include "RivPipeGeometryGenerator.h" #include "RivResultToTextureMapper.h" #include "RivScalarMapperUtils.h" +#include "RivSimWellPipeSourceInfo.h" #include "RivTernaryScalarMapper.h" #include "RivTernaryTextureCoordsCreator.h" +#include "RivWellPathSourceInfo.h" #include "RiuGeoMechXfTensorResultAccessor.h" @@ -58,6 +66,9 @@ #include "cvfRenderStateDepth.h" #include "cvfRenderStatePoint.h" #include "cvfStructGridGeometryGenerator.h" +#include "cvfTransform.h" + +#include //-------------------------------------------------------------------------------------------------- @@ -65,14 +76,19 @@ //-------------------------------------------------------------------------------------------------- RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened) : m_rimCrossSection(rimCrossSection), - m_defaultColor(cvf::Color3::WHITE), m_isFlattened(isFlattened) { CVF_ASSERT(m_rimCrossSection); m_crossSectionFacesTextureCoords = new cvf::Vec2fArray; - computeData(); + std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(); + if (polyLines.size() > 0) + { + cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); + cvf::ref hexGrid = createHexGridInterface(); + m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p(), m_isFlattened); + } } //-------------------------------------------------------------------------------------------------- @@ -82,8 +98,26 @@ void RivIntersectionPartMgr::applySingleColorEffect() { if (m_crossSectionGenerator.isNull()) return; - m_defaultColor = cvf::Color3f::OLIVE;//m_rimCrossSection->CrossSectionColor(); - this->updatePartEffect(); + caf::SurfaceEffectGenerator geometryEffgen(cvf::Color3f::OLIVE, caf::PO_1); + + cvf::ref geometryOnlyEffect = geometryEffgen.generateCachedEffect(); + + if (m_crossSectionFaces.notNull()) + { + m_crossSectionFaces->setEffect(geometryOnlyEffect.p()); + } + + // Update mesh colors as well, in case of change + //RiaPreferences* prefs = RiaApplication::instance()->preferences(); + + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + + if (m_crossSectionGridLines.notNull()) + { + m_crossSectionGridLines->setEffect(eff.p()); + } } //-------------------------------------------------------------------------------------------------- @@ -508,7 +542,7 @@ void RivIntersectionPartMgr::generatePartGeometry() createExtrusionDirParts(useBufferObjects); - updatePartEffect(); + applySingleColorEffect(); } @@ -677,32 +711,158 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::updatePartEffect() +cvf::ref createStdSurfacePart(cvf::DrawableGeo* geometry, + const cvf::Color3f& color, + cvf::String name, + cvf::Object* sourceInfo) { - if (m_crossSectionGenerator.isNull()) return; + if (!geometry) return nullptr; - // Set deCrossSection effect - caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1); - - cvf::ref geometryOnlyEffect = geometryEffgen.generateCachedEffect(); + cvf::ref part = new cvf::Part; + part->setName(name); + part->setDrawable(geometry); - if (m_crossSectionFaces.notNull()) + caf::SurfaceEffectGenerator surfaceGen(color, caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); + part->setEffect(eff.p()); + + part->setSourceInfo(sourceInfo); + part->updateBoundingBox(); + + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref createStdLinePart(cvf::DrawableGeo* geometry, + const cvf::Color3f& color, + cvf::String name) +{ + if ( !geometry ) return nullptr; + + + cvf::ref part = new cvf::Part; + part->setName(name); + part->setDrawable(geometry); + + caf::MeshEffectGenerator gen(color); + cvf::ref eff = gen.generateCachedEffect(); + + part->setEffect(eff.p()); + part->updateBoundingBox(); + + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +{ + if (m_rimCrossSection.isNull()) return; + + // Get information on how to draw the pipe + + std::function< cvf::ref< cvf::Object > ( size_t ) > createSourceInfoFunc; + double pipeRadius = 1; + int pipeCrossSectionVxCount = 6; + cvf::Color3f wellPipeColor = cvf::Color3f::GRAY; + + if ( m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL ) { - m_crossSectionFaces->setEffect(geometryOnlyEffect.p()); - } + RimSimWellInView * simWellInView = m_rimCrossSection->simulationWell(); - // Update mesh colors as well, in case of change - //RiaPreferences* prefs = RiaApplication::instance()->preferences(); + if (!simWellInView) return; - cvf::ref eff; - caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); - eff = CrossSectionEffGen.generateCachedEffect(); + RimEclipseView* eclView = nullptr; + simWellInView->firstAncestorOrThisOfTypeAsserted(eclView); - if (m_crossSectionGridLines.notNull()) + pipeRadius = simWellInView->pipeRadius(); + pipeCrossSectionVxCount = eclView->wellCollection()->pipeCrossSectionVertexCount(); + wellPipeColor = simWellInView->wellPipeColor(); + + createSourceInfoFunc = [&](size_t brIdx) { return new RivSimWellPipeSourceInfo(simWellInView, brIdx); }; + + } + else if (m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH) { - m_crossSectionGridLines->setEffect(eff.p()); + RimWellPath* wellPath = m_rimCrossSection->wellPath(); + + if (!wellPath) return; + + RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); + + RimGridView* gridView = nullptr; + m_rimCrossSection->firstAncestorOrThisOfTypeAsserted(gridView); + double cellSize = gridView->ownerCase()->characteristicCellSize(); + + RimWellPathCollection* wellPathColl = nullptr; + wellPath->firstAncestorOrThisOfTypeAsserted(wellPathColl); + + pipeRadius = wellPath->wellPathRadius(cellSize); + pipeCrossSectionVxCount = wellPathColl->wellPathCrossSectionVertexCount(); + wellPipeColor = wellPath->wellPathColor(); + + createSourceInfoFunc = [&](size_t brIdx) { return new RivWellPathSourceInfo(wellPath, m_rimCrossSection->correspondingIntersectionView()); }; } + // Create pipe geometry + + if ( m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL + || m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH ) + { + std::vector > polyLines = m_crossSectionGenerator->flattenedOrOffsettedPolyLines(); + + // Remove intersectino extents from the polyline + for (auto & polyLine: polyLines) + { + if ( polyLine.size() > 2 ) + { + polyLine.pop_back(); + polyLine.erase(polyLine.begin()); + } + } + + m_wellBranches.clear(); + + for ( size_t brIdx = 0; brIdx < polyLines.size(); ++brIdx ) + { + cvf::ref sourceInfo = createSourceInfoFunc(brIdx); + + m_wellBranches.emplace_back(); + RivPipeBranchData& pbd = m_wellBranches.back(); + + pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; + pbd.m_pipeGeomGenerator->setRadius(pipeRadius); + pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(pipeCrossSectionVxCount); + + cvf::ref cvfCoords = new cvf::Vec3dArray; + cvfCoords->assign(polyLines[brIdx]); + + // Scale the centerline coordinates using the Z-scale transform of the grid. + + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) + { + (*cvfCoords)[cIdx].transformPoint(scaleTransform->worldTransform()); + } + + pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); + auto surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); + auto centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); + + pbd.m_surfacePart = createStdSurfacePart(surfaceDrawable.p(), + wellPipeColor, + "FlattenedSimWellPipe", + sourceInfo.p()); + + pbd.m_centerLinePart = createStdLinePart(centerLineDrawable.p(), + wellPipeColor, + "FlattenedSimWellPipeCenterLine"); + model->addPart(pbd.m_surfacePart.p()); + model->addPart(pbd.m_centerLinePart.p()); + } + } } //-------------------------------------------------------------------------------------------------- @@ -800,20 +960,6 @@ const RimIntersection* RivIntersectionPartMgr::intersection() const return m_rimCrossSection.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::computeData() -{ - std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(); - if (polyLines.size() > 0) - { - cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); - cvf::ref hexGrid = createHexGridInterface(); - m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p(), m_isFlattened); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 0daa56f475..6527c970f2 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -26,6 +26,7 @@ #include "cvfArray.h" #include "cafPdmPointer.h" +#include namespace cvf { @@ -33,6 +34,7 @@ namespace cvf class Transform; class Part; class ScalarMapper; + class DrawableGeo; } class RigFemPart; @@ -47,7 +49,7 @@ class RivTernaryScalarMapper; class RivIntersectionGeometryGenerator; class RivIntersectionHexGridInterface; class RivIntersectionVertexWeights; - +class RivPipeGeometryGenerator; //================================================================================================== /// @@ -68,17 +70,10 @@ class RivIntersectionPartMgr : public cvf::Object void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - - const RimIntersection* intersection() const; - -private: - void updatePartEffect(); - void generatePartGeometry(); + void appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - void createPolyLineParts(bool useBufferObjects); - void createExtrusionDirParts(bool useBufferObjects); + const RimIntersection* intersection() const; - void computeData(); public: static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, @@ -110,14 +105,16 @@ class RivIntersectionPartMgr : public cvf::Object const cvf::Vec3fArray* triangelVertices, const RigFemResultAddress& resVarAddress, const cvf::ScalarMapper* mapper); - private: + void generatePartGeometry(); + void createPolyLineParts(bool useBufferObjects); + void createExtrusionDirParts(bool useBufferObjects); + cvf::ref createHexGridInterface(); +private: caf::PdmPointer m_rimCrossSection; - cvf::Color3f m_defaultColor; - cvf::ref m_crossSectionGenerator; cvf::ref m_crossSectionFaces; cvf::ref m_crossSectionGridLines; @@ -129,6 +126,14 @@ class RivIntersectionPartMgr : public cvf::Object cvf::ref m_highlightLineAlongExtrusionDir; cvf::ref m_highlightPointsForExtrusionDir; + struct RivPipeBranchData + { + cvf::ref m_pipeGeomGenerator; + cvf::ref m_surfacePart; + cvf::ref m_centerLinePart; + }; + std::list m_wellBranches; + bool m_isFlattened; }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 611e6155af..cfb20fe8c9 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -265,6 +265,7 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendPolylinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendWellPipePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->applySingleColorEffect(); From bb53b926bf7e0c844965f61c889ebbc4884f1100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 7 Feb 2018 13:10:36 +0100 Subject: [PATCH 0220/1027] #2345 Add + and * operators to the tensor class, to make averaging possible. --- .../UnitTests/ScalarMapper-Test.cpp | 30 +++++++++++++++- Fwk/AppFwk/cafTensor/cafTensor3.h | 2 ++ Fwk/AppFwk/cafTensor/cafTensor3.inl | 36 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp index 71ef74b9f9..1e13ec3d40 100644 --- a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp +++ b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp @@ -124,7 +124,7 @@ TEST(OffshoreSphericalCoords, OffshoreSphericalCoords) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST(TensorRotation, TensorRotation) +TEST(Tensor, TensorRotation) { { @@ -232,4 +232,32 @@ TEST(TensorRotation, TensorRotation) EXPECT_NEAR(0.0f, rotT[caf::Ten3f::SYZ], 1e-4); } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(Tensor, TensorAddScale) +{ + caf::Ten3f orgT1(1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f); + caf::Ten3f orgT2(1.6f, 1.5f, 1.4f, 1.3f, 1.2f, 1.1f); + + caf::Ten3f newT = orgT1 + orgT2; + + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SXX], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SYY], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SZZ], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SXY], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SZX], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SYZ], 1e-4); + + newT = newT*0.5; + + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SXX], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SYY], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SZZ], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SXY], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SZX], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SYZ], 1e-4); + } \ No newline at end of file diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.h b/Fwk/AppFwk/cafTensor/cafTensor3.h index 8e3af7030c..c943821cb8 100644 --- a/Fwk/AppFwk/cafTensor/cafTensor3.h +++ b/Fwk/AppFwk/cafTensor/cafTensor3.h @@ -34,6 +34,8 @@ class Tensor3 Tensor3(const Tensor3& other); inline Tensor3& operator=(const Tensor3& rhs); + inline Tensor3 operator+(const Tensor3& rhs) const; + inline Tensor3 operator*(S scale) const; bool equals(const Tensor3& mat) const; bool operator==(const Tensor3& rhs) const; diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.inl b/Fwk/AppFwk/cafTensor/cafTensor3.inl index ed24808baa..8a55e55e40 100644 --- a/Fwk/AppFwk/cafTensor/cafTensor3.inl +++ b/Fwk/AppFwk/cafTensor/cafTensor3.inl @@ -62,6 +62,42 @@ inline Tensor3& Tensor3::operator=(const Tensor3& obj) return *this; } +//-------------------------------------------------------------------------------------------------- +/// Component-wise addition +//-------------------------------------------------------------------------------------------------- +template< typename S> +Tensor3 caf::Tensor3::operator+(const Tensor3& rhs) const +{ + Tensor3 result(*this); + + result.m_tensor[0] += rhs.m_tensor[0]; + result.m_tensor[1] += rhs.m_tensor[1]; + result.m_tensor[2] += rhs.m_tensor[2]; + result.m_tensor[3] += rhs.m_tensor[3]; + result.m_tensor[4] += rhs.m_tensor[4]; + result.m_tensor[5] += rhs.m_tensor[5]; + + return result; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template< typename S> +Tensor3 caf::Tensor3::operator*(S scale) const +{ + Tensor3 result(*this); + + result.m_tensor[0] *= scale; + result.m_tensor[1] *= scale; + result.m_tensor[2] *= scale; + result.m_tensor[3] *= scale; + result.m_tensor[4] *= scale; + result.m_tensor[5] *= scale; + + return result; +} + //---------------------------------------------------------------------------------------------------- /// Check if matrices are equal using exact comparisons. From dd34b0111adae8da6992ec92f5aa44fdeb21428e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 10:12:07 +0100 Subject: [PATCH 0221/1027] #1968 Readability : Major whitespace changes --- ...ellPathExportCompletionDataFeatureImpl.cpp | 642 ++++++++++-------- ...cWellPathExportCompletionDataFeatureImpl.h | 159 +++-- 2 files changed, 455 insertions(+), 346 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 32f088ef81..65369a7b0a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -59,14 +59,12 @@ #include - - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, - const std::vector& simWells, - const RicExportCompletionDataSettingsUi& exportSettings) +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, + const RicExportCompletionDataSettingsUi& exportSettings) { if (exportSettings.caseToApply() == nullptr) { @@ -75,8 +73,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } std::vector usedWellPaths; - if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS - || exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) + if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS || + exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) { usedWellPaths = wellPaths; } @@ -119,12 +117,13 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } - std::map > completionsPerEclipseCell; + std::map> completionsPerEclipseCell; // FractureTransmissibilityExportInformation std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; - QString fractureTransmisibillityExportInformationPath = QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); + QString fractureTransmisibillityExportInformationPath = + QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); QFile fractureTransmissibilityExportInformationFile(fractureTransmisibillityExportInformationPath); RiaPreferences* prefs = RiaApplication::instance()->preferences(); @@ -132,21 +131,25 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve { if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) { - RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(fractureTransmisibillityExportInformationPath)); + RiaLogging::error(QString("Export Completions Data: Could not open the file: %1") + .arg(fractureTransmisibillityExportInformationPath)); return; } - fractureTransmissibilityExportInformationStream = std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); + fractureTransmissibilityExportInformationStream = + std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); } - size_t maxProgress = - usedWellPaths.size() * 3 + + size_t maxProgress = usedWellPaths.size() * 3 + #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - simWells.size() + + simWells.size() + #endif // USE_PROTOTYPE_FEATURE_FRACTURES - (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + - simWells.size(); + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL + ? usedWellPaths.size() + : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE + ? usedWellPaths.size() * 3 + : 1) + + simWells.size(); caf::ProgressInfo progress(maxProgress, "Export Completions"); @@ -157,14 +160,17 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (exportSettings.includePerforations) { - std::vector perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings); + std::vector perforationCompletionData = + generatePerforationsCompdatValues(wellPath, exportSettings); appendCompletionData(&completionsPerEclipseCell, perforationCompletionData); } progress.incrementProgress(); if (exportSettings.includeFishbones) { - std::vector fishbonesCompletionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(wellPath, exportSettings); + std::vector fishbonesCompletionData = + RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( + wellPath, exportSettings); appendCompletionData(&completionsPerEclipseCell, fishbonesCompletionData); } progress.incrementProgress(); @@ -172,7 +178,9 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve #ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (exportSettings.includeFractures()) { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); + std::vector fractureCompletionData = + RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath( + wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); } #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -182,9 +190,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve #ifdef USE_PROTOTYPE_FEATURE_FRACTURES for (auto simWell : simWells) { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(exportSettings.caseToApply(), - simWell, - fractureTransmissibilityExportInformationStream.get()); + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell( + exportSettings.caseToApply(), simWell, fractureTransmissibilityExportInformationStream.get()); appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); progress.incrementProgress(); } @@ -209,7 +216,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve { for (auto wellPath : usedWellPaths) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::map> filteredWellCompletions = + getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); std::vector completions; for (auto& data : filteredWellCompletions) { @@ -235,14 +243,16 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve { for (auto wellPath : usedWellPaths) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); + std::map> filteredWellCompletions = + getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); std::vector completions; for (auto& data : filteredWellCompletions) { completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); } { - std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); + std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType( + completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); if (!fishbonesCompletions.empty()) { QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); @@ -251,16 +261,19 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve progress.incrementProgress(); } { - std::vector perforationCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); + std::vector perforationCompletions = getCompletionsForWellAndCompletionType( + completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); if (!perforationCompletions.empty()) { QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); + printCompletionsToFiles( + exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); } progress.incrementProgress(); } { - std::vector fractureCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); + std::vector fractureCompletions = getCompletionsForWellAndCompletionType( + completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); if (!fractureCompletions.empty()) { QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); @@ -277,7 +290,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve { for (auto simWell : simWells) { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); + std::map> filteredWellCompletions = + getCompletionsForWell(completionsPerEclipseCell, simWell->name()); std::vector completions; for (auto& data : filteredWellCompletions) { @@ -294,45 +308,44 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (wellCompletions.empty()) continue; - QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? - QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) : - QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); + QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL + ? QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) + : QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); progress.incrementProgress(); } } - } //================================================================================================== -/// +/// //================================================================================================== -RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, - const RicExportCompletionDataSettingsUi& settings) +RigCompletionData + RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, + const RicExportCompletionDataSettingsUi& settings) { CVF_ASSERT(!completions.empty()); - QString wellName = completions[0].wellName(); - RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); + QString wellName = completions[0].wellName(); + RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); RigCompletionData::CompletionType completionType = completions[0].completionType(); - //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, - //if no main bore they are taken from first completion - double skinfactor = completions[0].skinFactor(); - double wellBoreDiameter = completions[0].diameter(); - CellDirection cellDirection = completions[0].direction(); - + // completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, + // if no main bore they are taken from first completion + double skinfactor = completions[0].skinFactor(); + double wellBoreDiameter = completions[0].diameter(); + CellDirection cellDirection = completions[0].direction(); + for (const RigCompletionData& completion : completions) { if (completion.isMainBore()) { - skinfactor = completion.skinFactor(); + skinfactor = completion.skinFactor(); wellBoreDiameter = completion.diameter(); - cellDirection = completion.direction(); + cellDirection = completion.direction(); break; } } - RigCompletionData resultCompletion(wellName, cellIndexIJK); double totalTrans = 0.0; @@ -340,31 +353,35 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell for (const RigCompletionData& completion : completions) { resultCompletion.m_metadata.reserve(resultCompletion.m_metadata.size() + completion.m_metadata.size()); - resultCompletion.m_metadata.insert(resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); + resultCompletion.m_metadata.insert( + resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); if (completion.completionType() != completions[0].completionType()) { - QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported + return resultCompletion; // Returning empty completion, should not be exported } if (completion.wellName() != completions[0].wellName()) { - QString errorMessage = QString("Cannot combine completions of different types in same cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + QString errorMessage = QString("Cannot combine completions of different types in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported + return resultCompletion; // Returning empty completion, should not be exported } - + if (completion.transmissibility() == HUGE_VAL) { - QString errorMessage = QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + QString errorMessage = + QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); RiaLogging::error(errorMessage); resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } + return resultCompletion; // Returning empty completion, should not be exported + } if (settings.excludeMainBoreForFishbones && completionType == RigCompletionData::FISHBONES && completion.isMainBore()) { @@ -374,38 +391,33 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell totalTrans = totalTrans + completion.transmissibility(); } - - if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) + if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) { resultCompletion.setCombinedValuesExplicitTrans(totalTrans, completionType); } - else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { - //calculate trans for main bore - but as Eclipse will do it! - double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), - skinfactor, - wellBoreDiameter / 2, - cellIndexIJK.globalCellIndex(), - cellDirection); + // calculate trans for main bore - but as Eclipse will do it! + double transmissibilityEclipseCalculation = + RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes( + settings.caseToApply(), skinfactor, wellBoreDiameter / 2, cellIndexIJK.globalCellIndex(), cellDirection); double wpimult = totalTrans / transmissibilityEclipseCalculation; - resultCompletion.setCombinedValuesImplicitTransWPImult(wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); + resultCompletion.setCombinedValuesImplicitTransWPImult( + wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); } - + return resultCompletion; } - - - - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const QString& folderName, - const QString& fileName, - std::vector& completions, - RicExportCompletionDataSettingsUi::CompdatExportType exportType) +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles( + const QString& folderName, + const QString& fileName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) { // Sort completions based on grid they belong to std::vector completionsForMainGrid; @@ -424,7 +436,8 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const Q auto it = completionsForSubGrids.find(gridName); if (it == completionsForSubGrids.end()) { - completionsForSubGrids.insert(std::pair>(gridName, std::vector{completion})); + completionsForSubGrids.insert( + std::pair>(gridName, std::vector{completion})); } else { @@ -449,12 +462,13 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles(const Q } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QString& folderName, - const QString& fileName, - const std::map>& completionsPerGrid, - RicExportCompletionDataSettingsUi::CompdatExportType exportType) +void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile( + const QString& folderName, + const QString& fileName, + const std::map>& completionsPerGrid, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) { if (completionsPerGrid.empty()) return; @@ -463,19 +477,21 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QS if (!exportFolder.exists()) { bool createdPath = exportFolder.mkpath(folderName); - if (createdPath) RiaLogging::info("Created export folder " + folderName); - else RiaLogging::error("Selected output folder does not exist, and could not be created."); + if (createdPath) + RiaLogging::info("Created export folder " + folderName); + else + RiaLogging::error("Selected output folder does not exist, and could not be created."); } QString filePath = exportFolder.filePath(fileName); - QFile exportFile(filePath); + QFile exportFile(filePath); if (!exportFile.open(QIODevice::WriteOnly)) { RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); return; } - QTextStream stream(&exportFile); + QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); for (const auto& gridCompletions : completionsPerGrid) @@ -488,7 +504,7 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QS // Print completion data QString gridName = gridCompletions.first; generateCompdatTable(formatter, gridName, completions); - + if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { generateWpimultTable(formatter, gridName, completions); @@ -499,11 +515,12 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile(const QS } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType(const std::vector& completions, - const QString& wellName, - RigCompletionData::CompletionType completionType) +std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType( + const std::vector& completions, + const QString& wellName, + RigCompletionData::CompletionType completionType) { std::vector filteredCompletions; for (const auto& completion : completions) @@ -517,11 +534,14 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::getCo } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::map > RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) +std::map> + RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell( + const std::map>& cellToCompletionMap, + const QString& wellName) { - std::map > wellCompletions; + std::map> wellCompletions; for (const auto& it : cellToCompletionMap) { @@ -538,52 +558,52 @@ std::map > RicWellPath } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData) +void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) { std::vector header; if (gridName.isEmpty()) { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; + header = {RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn( + "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0")}; formatter.keyword("COMPDAT"); } else { - header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("LgrName"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; + header = {RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn( + "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0")}; formatter.keyword("COMPDATL"); } @@ -591,9 +611,9 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse for (const RigCompletionData& data : completionData) { - if (data.transmissibility() == 0.0 || data.wpimult()==0.0) + if (data.transmissibility() == 0.0 || data.wpimult() == 0.0) { - //Don't export completions without transmissibility + // Don't export completions without transmissibility continue; } @@ -608,43 +628,47 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse formatter.add(gridName); } - formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()).addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); + formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); switch (data.connectionState()) { - case OPEN: - formatter.add("OPEN"); - break; - case SHUT: - formatter.add("SHUT"); - break; - case AUTO: - formatter.add("AUTO"); - break; + case OPEN: formatter.add("OPEN"); break; + case SHUT: formatter.add("SHUT"); break; + case AUTO: formatter.add("AUTO"); break; } - if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); + if (RigCompletionData::isDefaultValue(data.saturation())) + formatter.add("1*"); + else + formatter.add(data.saturation()); if (RigCompletionData::isDefaultValue(data.transmissibility())) { formatter.add("1*"); // Transmissibility - if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); else formatter.add(data.diameter()); - if (RigCompletionData::isDefaultValue(data.kh())) formatter.add("1*"); else formatter.add(data.kh()); - if (RigCompletionData::isDefaultValue(data.skinFactor())) formatter.add("1*"); else formatter.add(data.skinFactor()); - if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else formatter.add(data.dFactor()); + if (RigCompletionData::isDefaultValue(data.diameter())) + formatter.add("1*"); + else + formatter.add(data.diameter()); + if (RigCompletionData::isDefaultValue(data.kh())) + formatter.add("1*"); + else + formatter.add(data.kh()); + if (RigCompletionData::isDefaultValue(data.skinFactor())) + formatter.add("1*"); + else + formatter.add(data.skinFactor()); + if (RigCompletionData::isDefaultValue(data.dFactor())) + formatter.add("1*"); + else + formatter.add(data.dFactor()); switch (data.direction()) { - case DIR_I: - formatter.add("'X'"); - break; - case DIR_J: - formatter.add("'Y'"); - break; - case DIR_K: - formatter.add("'Z'"); - break; - default: - formatter.add("'Z'"); - break; + case DIR_I: formatter.add("'X'"); break; + case DIR_J: formatter.add("'Y'"); break; + case DIR_K: formatter.add("'Z'"); break; + default: formatter.add("'Z'"); break; } } else @@ -658,11 +682,11 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, - const QString& gridName, - const std::vector& completionData) +void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) { std::vector header; @@ -706,7 +730,9 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipse formatter.add(gridName); } - formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()).addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); + formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()) + .addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()) + .addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); formatter.rowCompleted(); } @@ -714,9 +740,11 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipse } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) +std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues( + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); @@ -731,33 +759,38 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue; using namespace std; - pair, vector > perforationPointsAndMD = wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); - std::vector intersectedCells = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(settings.caseToApply->eclipseCaseData(), - perforationPointsAndMD.first, - perforationPointsAndMD.second); + pair, vector> perforationPointsAndMD = + wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); + + std::vector intersectedCells = + RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( + settings.caseToApply->eclipseCaseData(), perforationPointsAndMD.first, perforationPointsAndMD.second); + for (auto& cell : intersectedCells) { bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); if (!cellIsActive) continue; - RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); - CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); - - double transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, - wellPath, - cell.intersectionLengthsInCellCS, - interval->skinFactor(), - interval->diameter(unitSystem) / 2, - cell.globCellIndex, - settings.useLateralNTG); - - - - completion.setTransAndWPImultBackgroundDataFromPerforation(transmissibility, - interval->skinFactor(), - interval->diameter(unitSystem), - direction); - completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + QString(" : ") + QString::number(transmissibility)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), + RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); + + CellDirection direction = + calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); + + double transmissibility = + RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, + wellPath, + cell.intersectionLengthsInCellCS, + interval->skinFactor(), + interval->diameter(unitSystem) / 2, + cell.globCellIndex, + settings.useLateralNTG); + + completion.setTransAndWPImultBackgroundDataFromPerforation( + transmissibility, interval->skinFactor(), interval->diameter(unitSystem), direction); + completion.addMetadata("Perforation", + QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + + QString(" : ") + QString::number(transmissibility)); completionData.push_back(completion); } } @@ -767,20 +800,23 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) +bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, + const WellSegmentLocation& second) { return first.measuredDepth < second.measuredDepth; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) +std::vector + RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath) { std::vector fishbonesSubs; - + if (wellPath->fishbonesCollection()->isChecked()) { for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs()) @@ -796,18 +832,22 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::fin } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations( + const RimEclipseCase* caseToApply, + const RimWellPath* wellPath, + const std::vector& fishbonesSubs) { std::vector wellSegmentLocations; for (RimFishbonesMultipleSubs* subs : fishbonesSubs) { for (auto& sub : subs->installedLateralIndices()) { - double measuredDepth = subs->measuredDepth(sub.subIndex); - cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); - WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); + double measuredDepth = subs->measuredDepth(sub.subIndex); + cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); + WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); + for (size_t lateralIndex : sub.lateralIndices) { location.laterals.push_back(WellSegmentLateral(lateralIndex)); @@ -823,27 +863,28 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::fin } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, - WellSegmentLocation* location, - int* branchNum, - int* segmentNum) +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, + WellSegmentLocation* location, + int* branchNum, + int* segmentNum) { for (WellSegmentLateral& lateral : location->laterals) { ++(*branchNum); lateral.branchNumber = (*branchNum); - std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); - - if ( lateralCoordMDPairs.empty() ) + std::vector> lateralCoordMDPairs = + location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); + + if (lateralCoordMDPairs.empty()) { continue; } std::vector lateralCoords; - std::vector lateralMDs; + std::vector lateralMDs; lateralCoords.reserve(lateralCoordMDPairs.size()); lateralMDs.reserve(lateralCoordMDPairs.size()); @@ -854,45 +895,47 @@ void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(cons lateralMDs.push_back(coordMD.second); } - std::vector intersections = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(caseToApply->eclipseCaseData(), - lateralCoords, - lateralMDs); - double previousExitMD = lateralMDs.front(); + std::vector intersections = + RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( + caseToApply->eclipseCaseData(), lateralCoords, lateralMDs); + double previousExitMD = lateralMDs.front(); double previousExitTVD = lateralCoords.front().z(); int attachedSegmentNumber = location->icdSegmentNumber; - for (const auto& cellIntInfo: intersections) + for (const auto& cellIntInfo : intersections) { ++(*segmentNum); - WellSegmentLateralIntersection lateralIntersection((*segmentNum), - attachedSegmentNumber, - cellIntInfo.globCellIndex, - cellIntInfo.endMD - previousExitMD, - cellIntInfo.endPoint.z() - previousExitTVD, + WellSegmentLateralIntersection lateralIntersection((*segmentNum), + attachedSegmentNumber, + cellIntInfo.globCellIndex, + cellIntInfo.endMD - previousExitMD, + cellIntInfo.endPoint.z() - previousExitTVD, cellIntInfo.intersectionLengthsInCellCS); - + lateral.intersections.push_back(lateralIntersection); attachedSegmentNumber = (*segmentNum); - previousExitMD = cellIntInfo.endMD; - previousExitTVD = cellIntInfo.endPoint.z(); + previousExitMD = cellIntInfo.endMD; + previousExitTVD = cellIntInfo.endPoint.z(); } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers( + const RimEclipseCase* caseToApply, + std::vector* locations) { int segmentNumber = 1; - int branchNumber = 1; - + int branchNumber = 1; + // First loop over the locations so that each segment on the main stem is an incremental number for (WellSegmentLocation& location : *locations) { - location.segmentNumber = ++segmentNumber; - location.icdBranchNumber = ++branchNumber; + location.segmentNumber = ++segmentNumber; + location.icdBranchNumber = ++branchNumber; location.icdSegmentNumber = ++segmentNumber; } @@ -904,9 +947,11 @@ void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBr } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData(std::map >* completionData, const std::vector& data) +void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData( + std::map>* completionData, + const std::vector& data) { for (auto& completion : data) { @@ -917,24 +962,30 @@ void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData(std::mapinsert(std::pair >(completion.completionDataGridCell(), std::vector {completion})); + completionData->insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell) +CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(RimEclipseCase* eclipseCase, + size_t globalCellIndex, + const cvf::Vec3d& lengthsInCell) { RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(globalCellIndex)); double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(globalCellIndex)); @@ -955,46 +1006,53 @@ CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCe } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - const cvf::Vec3d& internalCellLengths, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - bool useLateralNTG, - size_t volumeScaleConstant, - CellDirection directionForVolumeScaling) +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + const cvf::Vec3d& internalCellLengths, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + bool useLateralNTG, + size_t volumeScaleConstant, + CellDirection directionForVolumeScaling) { RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + cvf::ref permxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + cvf::ref permyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + cvf::ref permzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); if (ntgResIdx != cvf::UNDEFINED_SIZE_T) { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + cvf::ref ntgAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); } double latNtg = useLateralNTG ? ntg : 1.0; - double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); @@ -1008,69 +1066,81 @@ double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(Rim if (directionForVolumeScaling == CellDirection::DIR_K) dz = dz / volumeScaleConstant; } - double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); - double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); - double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); return RigTransmissibilityEquations::totalConnectionFactor(transx, transy, transz); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, - double skinFactor, - double wellRadius, - size_t globalCellIndex, - CellDirection direction) + double skinFactor, + double wellRadius, + size_t globalCellIndex, + CellDirection direction) { RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + cvf::ref permxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + cvf::ref permyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + cvf::ref permzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); if (ntgResIdx != cvf::UNDEFINED_SIZE_T) { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + cvf::ref ntgAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); } - double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); - double darcy = RiaEclipseUnitTools::darcysConstant(units); + double darcy = RiaEclipseUnitTools::darcysConstant(units); double trans = cvf::UNDEFINED_DOUBLE; if (direction == CellDirection::DIR_I) { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); } else if (direction == CellDirection::DIR_J) { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); } else if (direction == CellDirection::DIR_K) { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); } return trans; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 160422fc91..fa576949d9 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -39,39 +39,43 @@ class RifEclipseDataTableFormatter; //================================================================================================== /// //================================================================================================== -struct WellSegmentLateralIntersection { - WellSegmentLateralIntersection(int segmentNumber, - int attachedSegmentNumber, - size_t globalCellIndex, - double length, - double depth, +struct WellSegmentLateralIntersection +{ + WellSegmentLateralIntersection(int segmentNumber, + int attachedSegmentNumber, + size_t globalCellIndex, + double length, + double depth, const cvf::Vec3d& lengthsInCell) - : segmentNumber(segmentNumber), - attachedSegmentNumber(attachedSegmentNumber), - globalCellIndex(globalCellIndex), - mdFromPreviousIntersection(length), - tvdChangeFromPreviousIntersection(depth), - lengthsInCell(lengthsInCell), - mainBoreCell(false) - {} - - int segmentNumber; - int attachedSegmentNumber; - size_t globalCellIndex; - bool mainBoreCell; - double mdFromPreviousIntersection; - double tvdChangeFromPreviousIntersection; - cvf::Vec3d lengthsInCell; + : segmentNumber(segmentNumber) + , attachedSegmentNumber(attachedSegmentNumber) + , globalCellIndex(globalCellIndex) + , mdFromPreviousIntersection(length) + , tvdChangeFromPreviousIntersection(depth) + , lengthsInCell(lengthsInCell) + , mainBoreCell(false) + { + } + + int segmentNumber; + int attachedSegmentNumber; + size_t globalCellIndex; + bool mainBoreCell; + double mdFromPreviousIntersection; + double tvdChangeFromPreviousIntersection; + cvf::Vec3d lengthsInCell; }; //================================================================================================== /// //================================================================================================== -struct WellSegmentLateral { +struct WellSegmentLateral +{ WellSegmentLateral(size_t lateralIndex) - : lateralIndex(lateralIndex), - branchNumber(0) - {} + : lateralIndex(lateralIndex) + , branchNumber(0) + { + } size_t lateralIndex; int branchNumber; @@ -81,29 +85,33 @@ struct WellSegmentLateral { //================================================================================================== /// //================================================================================================== -struct WellSegmentLocation { - WellSegmentLocation(const RimFishbonesMultipleSubs* subs, double measuredDepth, double trueVerticalDepth, size_t subIndex, int segmentNumber = -1) - : fishbonesSubs(subs), - measuredDepth(measuredDepth), - trueVerticalDepth(trueVerticalDepth), - subIndex(subIndex), - segmentNumber(segmentNumber), - icdBranchNumber(-1), - icdSegmentNumber(-1) +struct WellSegmentLocation +{ + WellSegmentLocation(const RimFishbonesMultipleSubs* subs, + double measuredDepth, + double trueVerticalDepth, + size_t subIndex, + int segmentNumber = -1) + : fishbonesSubs(subs) + , measuredDepth(measuredDepth) + , trueVerticalDepth(trueVerticalDepth) + , subIndex(subIndex) + , segmentNumber(segmentNumber) + , icdBranchNumber(-1) + , icdSegmentNumber(-1) { } - const RimFishbonesMultipleSubs* fishbonesSubs; - double measuredDepth; - double trueVerticalDepth; - size_t subIndex; - int segmentNumber; - int icdBranchNumber; - int icdSegmentNumber; - std::vector laterals; + const RimFishbonesMultipleSubs* fishbonesSubs; + double measuredDepth; + double trueVerticalDepth; + size_t subIndex; + int segmentNumber; + int icdBranchNumber; + int icdSegmentNumber; + std::vector laterals; }; - //================================================================================================== /// //================================================================================================== @@ -111,10 +119,16 @@ class RicWellPathExportCompletionDataFeatureImpl { public: - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath); - static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t globalCellIndex, const cvf::Vec3d& lengthsInCell); + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath, + const std::vector& fishbonesSubs); + + static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, + size_t globalCellIndex, + const cvf::Vec3d& lengthsInCell); static double calculateTransmissibility(RimEclipseCase* eclipseCase, const RimWellPath* wellPath, @@ -127,7 +141,9 @@ class RicWellPathExportCompletionDataFeatureImpl CellDirection directionForVolumeScaling = CellDirection::DIR_I); - static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); + static void exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, + const RicExportCompletionDataSettingsUi& exportSettings); private: static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, @@ -139,23 +155,46 @@ class RicWellPathExportCompletionDataFeatureImpl static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); - static void printCompletionsToFiles(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFiles(const QString& exportFolder, + const QString& fileName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static void printCompletionsToFile(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFile(const QString& folderName, + const QString& fileName, + const std::map>& completionsPerGrid, + RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); + static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, + const QString& wellName, + RigCompletionData::CompletionType completionType); - static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); + static std::map > + getCompletionsForWell(const std::map>& cellToCompletionMap, + const QString& wellName); - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); - static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); + static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData); - static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); + static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData); - static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); - static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); - static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); + static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); - static void appendCompletionData(std::map >* completionData, const std::vector& data); -}; + static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, + const WellSegmentLocation& second); + static void assignLateralIntersections(const RimEclipseCase* caseToApply, + WellSegmentLocation* location, + int* branchNum, + int* segmentNum); + + static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, + std::vector* locations); + + static void appendCompletionData(std::map>* completionData, + const std::vector& data); +}; From 76e6ec3aef9880c2a18c8590cbfe55a0a5b344b3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 10:20:55 +0100 Subject: [PATCH 0222/1027] Remove unused function --- .../RigCompletionData.cpp | 36 ------------------- .../RigCompletionData.h | 2 -- 2 files changed, 38 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index e8d611afae..dc75864f29 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -64,42 +64,6 @@ RigCompletionData::RigCompletionData(const RigCompletionData& other) copy(*this, other); } -//================================================================================================== -/// -//================================================================================================== -RigCompletionData RigCompletionData::combine(const std::vector& completions) -{ - CVF_ASSERT(!completions.empty()); - - auto it = completions.cbegin(); - RigCompletionData result(*it); - ++it; - - for (; it != completions.cend(); ++it) - { - if (it->completionType() != result.completionType()) - { - RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.localCellIndexI()).arg(result.m_cellIndex.localCellIndexJ()).arg(result.m_cellIndex.localCellIndexK())); - continue; - } - if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility)) - { - RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result"); - } - else - { - result.m_transmissibility += it->m_transmissibility; - } - - result.m_metadata.reserve(result.m_metadata.size() + it->m_metadata.size()); - result.m_metadata.insert(result.m_metadata.end(), it->m_metadata.begin(), it->m_metadata.end()); - - result.m_count += it->m_count; - } - - return result; -} - //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index 709a64f68e..035142906e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -72,8 +72,6 @@ class RigCompletionData ~RigCompletionData(); RigCompletionData(const RigCompletionData& other); - static RigCompletionData combine(const std::vector& completions); - bool operator<(const RigCompletionData& other) const; RigCompletionData& operator=(const RigCompletionData& other); From 68c21e117b30f4dc6714153714250b8cd0841297 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 10:21:31 +0100 Subject: [PATCH 0223/1027] #1968 Readability : Whitespace changes --- .../RigCompletionData.cpp | 201 +++++++++--------- 1 file changed, 98 insertions(+), 103 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index dc75864f29..5f78a3a90c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -26,38 +26,35 @@ #include // Needed for HUGE_VAL on Linux - //================================================================================================== -/// +/// //================================================================================================== RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex) - : m_wellName(wellName), - m_cellIndex(cellIndex), - m_saturation(HUGE_VAL), - m_transmissibility(HUGE_VAL), - m_diameter(HUGE_VAL), - m_kh(HUGE_VAL), - m_skinFactor(HUGE_VAL), - m_dFactor(HUGE_VAL), - m_direction(DIR_UNDEF), - m_connectionState(OPEN), - m_count(1), - m_wpimult(HUGE_VAL), - m_isMainBore(false), - m_readyForExport(false), - m_completionType(CT_UNDEFINED) + : m_wellName(wellName) + , m_cellIndex(cellIndex) + , m_saturation(HUGE_VAL) + , m_transmissibility(HUGE_VAL) + , m_diameter(HUGE_VAL) + , m_kh(HUGE_VAL) + , m_skinFactor(HUGE_VAL) + , m_dFactor(HUGE_VAL) + , m_direction(DIR_UNDEF) + , m_connectionState(OPEN) + , m_count(1) + , m_wpimult(HUGE_VAL) + , m_isMainBore(false) + , m_readyForExport(false) + , m_completionType(CT_UNDEFINED) { } //================================================================================================== -/// +/// //================================================================================================== -RigCompletionData::~RigCompletionData() -{ -} +RigCompletionData::~RigCompletionData() {} //================================================================================================== -/// +/// //================================================================================================== RigCompletionData::RigCompletionData(const RigCompletionData& other) { @@ -65,12 +62,12 @@ RigCompletionData::RigCompletionData(const RigCompletionData& other) } //================================================================================================== -/// +/// //================================================================================================== bool RigCompletionData::operator<(const RigCompletionData& other) const { - if (m_wellName != other.m_wellName) - { + if (m_wellName != other.m_wellName) + { return (m_wellName < other.m_wellName); } @@ -78,7 +75,7 @@ bool RigCompletionData::operator<(const RigCompletionData& other) const } //================================================================================================== -/// +/// //================================================================================================== RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) { @@ -90,78 +87,77 @@ RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) } //================================================================================================== -/// +/// //================================================================================================== void RigCompletionData::setFromFracture(double transmissibility, double skinFactor) { - m_completionType = FRACTURE; + m_completionType = FRACTURE; m_transmissibility = transmissibility; - m_skinFactor = skinFactor; + m_skinFactor = skinFactor; } //================================================================================================== -/// +/// //================================================================================================== -void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, - double skinFactor, - double diameter, +void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, + double skinFactor, + double diameter, CellDirection direction, - bool isMainBore) + bool isMainBore) { - m_completionType = FISHBONES; + m_completionType = FISHBONES; m_transmissibility = transmissibility; - m_skinFactor = skinFactor; - m_diameter = diameter; - m_direction = direction; - m_isMainBore = isMainBore; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = direction; + m_isMainBore = isMainBore; } //================================================================================================== -/// +/// //================================================================================================== -void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, - double skinFactor, - double diameter, +void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, + double skinFactor, + double diameter, CellDirection direction) { - m_completionType = PERFORATION; + m_completionType = PERFORATION; m_transmissibility = transmissibility; - m_skinFactor = skinFactor; - m_diameter = diameter; - m_direction = direction; - m_isMainBore = true; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = direction; + m_isMainBore = true; } //================================================================================================== -/// +/// //================================================================================================== -void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, - CompletionType completionType) +void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, CompletionType completionType) { - m_completionType = completionType; + m_completionType = completionType; m_transmissibility = transmissibility; - m_readyForExport = true; + m_readyForExport = true; } //================================================================================================== -/// +/// //================================================================================================== -void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, - double skinFactor, - double wellDiameter, +void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult, + CellDirection celldirection, + double skinFactor, + double wellDiameter, CompletionType completionType) { - m_wpimult = wpimult; - m_direction = celldirection; + m_wpimult = wpimult; + m_direction = celldirection; m_completionType = completionType; - m_skinFactor = skinFactor; - m_diameter = wellDiameter; + m_skinFactor = skinFactor; + m_diameter = wellDiameter; m_readyForExport = true; } //================================================================================================== -/// +/// //================================================================================================== void RigCompletionData::addMetadata(const QString& name, const QString& comment) { @@ -169,7 +165,7 @@ void RigCompletionData::addMetadata(const QString& name, const QString& comment) } //================================================================================================== -/// +/// //================================================================================================== bool RigCompletionData::isDefaultValue(double val) { @@ -177,7 +173,7 @@ bool RigCompletionData::isDefaultValue(double val) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const std::vector& RigCompletionData::metadata() const { @@ -185,7 +181,7 @@ const std::vector& RigCompletionData::metadata() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const QString& RigCompletionData::wellName() const { @@ -193,7 +189,7 @@ const QString& RigCompletionData::wellName() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const RigCompletionDataGridCell& RigCompletionData::completionDataGridCell() const { @@ -201,7 +197,7 @@ const RigCompletionDataGridCell& RigCompletionData::completionDataGridCell() con } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- WellConnectionState RigCompletionData::connectionState() const { @@ -209,7 +205,7 @@ WellConnectionState RigCompletionData::connectionState() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::saturation() const { @@ -217,7 +213,7 @@ double RigCompletionData::saturation() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::transmissibility() const { @@ -225,7 +221,7 @@ double RigCompletionData::transmissibility() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::diameter() const { @@ -233,7 +229,7 @@ double RigCompletionData::diameter() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::kh() const { @@ -241,7 +237,7 @@ double RigCompletionData::kh() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::skinFactor() const { @@ -249,7 +245,7 @@ double RigCompletionData::skinFactor() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::dFactor() const { @@ -257,7 +253,7 @@ double RigCompletionData::dFactor() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- CellDirection RigCompletionData::direction() const { @@ -265,7 +261,7 @@ CellDirection RigCompletionData::direction() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigCompletionData::count() const { @@ -273,7 +269,7 @@ size_t RigCompletionData::count() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::wpimult() const { @@ -281,7 +277,7 @@ double RigCompletionData::wpimult() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigCompletionData::CompletionType RigCompletionData::completionType() const { @@ -289,7 +285,7 @@ RigCompletionData::CompletionType RigCompletionData::completionType() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RigCompletionData::isMainBore() const { @@ -297,7 +293,7 @@ bool RigCompletionData::isMainBore() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RigCompletionData::readyForExport() const { @@ -305,7 +301,7 @@ bool RigCompletionData::readyForExport() const } //================================================================================================== -/// +/// //================================================================================================== bool RigCompletionData::onlyOneIsDefaulted(double first, double second) { @@ -327,31 +323,30 @@ bool RigCompletionData::onlyOneIsDefaulted(double first, double second) // Second has default value, first does not return true; } - + // Neither has default values return false; } //================================================================================================== -/// +/// //================================================================================================== void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& from) { - target.m_metadata = from.m_metadata; - target.m_wellName = from.m_wellName; - target.m_cellIndex = from.m_cellIndex; - target.m_connectionState = from.m_connectionState; - target.m_saturation = from.m_saturation; + target.m_metadata = from.m_metadata; + target.m_wellName = from.m_wellName; + target.m_cellIndex = from.m_cellIndex; + target.m_connectionState = from.m_connectionState; + target.m_saturation = from.m_saturation; target.m_transmissibility = from.m_transmissibility; - target.m_diameter = from.m_diameter; - target.m_kh = from.m_kh; - target.m_skinFactor = from.m_skinFactor; - target.m_dFactor = from.m_dFactor; - target.m_direction = from.m_direction; - target.m_isMainBore = from.m_isMainBore; - target.m_readyForExport = from.m_readyForExport; - target.m_count = from.m_count; - target.m_wpimult = from.m_wpimult; - target.m_completionType = from.m_completionType; + target.m_diameter = from.m_diameter; + target.m_kh = from.m_kh; + target.m_skinFactor = from.m_skinFactor; + target.m_dFactor = from.m_dFactor; + target.m_direction = from.m_direction; + target.m_isMainBore = from.m_isMainBore; + target.m_readyForExport = from.m_readyForExport; + target.m_count = from.m_count; + target.m_wpimult = from.m_wpimult; + target.m_completionType = from.m_completionType; } - From 53a1de91d733d08b390702a5e8640e52199978e8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Feb 2018 14:07:49 +0100 Subject: [PATCH 0224/1027] #1968 Export Completions : Improve ordering --- .../RicExportFractureCompletionsImpl.cpp | 5 +- ...sTransmissibilityCalculationFeatureImp.cpp | 15 +++- ...ellPathExportCompletionDataFeatureImpl.cpp | 6 +- .../RigCompletionData.cpp | 77 +++++++++++++++---- .../RigCompletionData.h | 9 ++- 5 files changed, 90 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 0542884a03..850bb76a0d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -348,7 +348,10 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - RigCompletionData compDat(wellPathName, RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid())); + RigCompletionData compDat(wellPathName, + RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid()), + fracture->fractureMD()); + compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 198df3f88b..80381aae26 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -44,6 +44,8 @@ struct WellBorePartForTransCalc WellBorePartForTransCalc(cvf::Vec3d lengthsInCell, double wellRadius, double skinFactor, bool isMainBore, QString metaData) : lengthsInCell(lengthsInCell), wellRadius(wellRadius), skinFactor(skinFactor), isMainBore(isMainBore), metaData(metaData) { + intersectionWithWellMeasuredDepth = HUGE_VAL; + lateralIndex = cvf::UNDEFINED_SIZE_T; } cvf::Vec3d lengthsInCell; @@ -51,6 +53,9 @@ struct WellBorePartForTransCalc double skinFactor; QString metaData; bool isMainBore; + + double intersectionWithWellMeasuredDepth; + size_t lateralIndex; }; //-------------------------------------------------------------------------------------------------- @@ -81,6 +86,9 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell isMainBore, completionMetaData); + wellBorePart.intersectionWithWellMeasuredDepth = location.measuredDepth; + wellBorePart.lateralIndex = lateral.lateralIndex; + wellBorePartsInCells[intersection.globalCellIndex].push_back(wellBorePart); } @@ -135,7 +143,8 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply->mainGrid())); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply->mainGrid()), wellBorePart.intersectionWithWellMeasuredDepth); + completion.setSecondOrderingValue(wellBorePart.lateralIndex); double transmissibility = 0.0; if (wellBorePart.isMainBore) @@ -212,6 +221,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate skinFactor, isMainBore, completionMetaData); + wellBorePart.intersectionWithWellMeasuredDepth = cell.startMD; + wellBorePartsInCells[cell.globCellIndex].push_back(wellBorePart); } } @@ -249,6 +260,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st isMainBore, completionMetaData); + wellBorePart.intersectionWithWellMeasuredDepth = cell.startMD; + wellBorePartsInCells[cell.globCellIndex].push_back(wellBorePart); } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 65369a7b0a..51cffb77a0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -346,7 +346,8 @@ RigCompletionData } } - RigCompletionData resultCompletion(wellName, cellIndexIJK); + RigCompletionData resultCompletion(wellName, cellIndexIJK, completions[0].firstOrderingValue()); + resultCompletion.setSecondOrderingValue(completions[0].secondOrderingValue()); double totalTrans = 0.0; @@ -772,7 +773,8 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener if (!cellIsActive) continue; RigCompletionData completion(wellPath->completions()->wellNameForExport(), - RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid())); + RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid()), + cell.startMD); CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index 5f78a3a90c..e502641881 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -29,7 +29,7 @@ //================================================================================================== /// //================================================================================================== -RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex) +RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue) : m_wellName(wellName) , m_cellIndex(cellIndex) , m_saturation(HUGE_VAL) @@ -45,6 +45,8 @@ RigCompletionData::RigCompletionData(const QString wellName, const RigCompletion , m_isMainBore(false) , m_readyForExport(false) , m_completionType(CT_UNDEFINED) + , m_firstOrderingValue(orderingValue) + , m_secondOrderingValue(HUGE_VAL) { } @@ -71,6 +73,21 @@ bool RigCompletionData::operator<(const RigCompletionData& other) const return (m_wellName < other.m_wellName); } + if (m_completionType != other.m_completionType) + { + return (m_completionType < other.m_completionType); + } + + if (m_firstOrderingValue != other.m_firstOrderingValue) + { + return (m_firstOrderingValue < other.m_firstOrderingValue); + } + + if (m_secondOrderingValue != other.m_secondOrderingValue) + { + return (m_secondOrderingValue < other.m_secondOrderingValue); + } + return m_cellIndex < other.m_cellIndex; } @@ -96,6 +113,14 @@ void RigCompletionData::setFromFracture(double transmissibility, double skinFact m_skinFactor = skinFactor; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setSecondOrderingValue(double orderingValue) +{ + m_secondOrderingValue = orderingValue; +} + //================================================================================================== /// //================================================================================================== @@ -300,6 +325,22 @@ bool RigCompletionData::readyForExport() const return m_readyForExport; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::firstOrderingValue() const +{ + return m_firstOrderingValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::secondOrderingValue() const +{ + return m_secondOrderingValue; +} + //================================================================================================== /// //================================================================================================== @@ -333,20 +374,22 @@ bool RigCompletionData::onlyOneIsDefaulted(double first, double second) //================================================================================================== void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& from) { - target.m_metadata = from.m_metadata; - target.m_wellName = from.m_wellName; - target.m_cellIndex = from.m_cellIndex; - target.m_connectionState = from.m_connectionState; - target.m_saturation = from.m_saturation; - target.m_transmissibility = from.m_transmissibility; - target.m_diameter = from.m_diameter; - target.m_kh = from.m_kh; - target.m_skinFactor = from.m_skinFactor; - target.m_dFactor = from.m_dFactor; - target.m_direction = from.m_direction; - target.m_isMainBore = from.m_isMainBore; - target.m_readyForExport = from.m_readyForExport; - target.m_count = from.m_count; - target.m_wpimult = from.m_wpimult; - target.m_completionType = from.m_completionType; + target.m_metadata = from.m_metadata; + target.m_wellName = from.m_wellName; + target.m_cellIndex = from.m_cellIndex; + target.m_connectionState = from.m_connectionState; + target.m_saturation = from.m_saturation; + target.m_transmissibility = from.m_transmissibility; + target.m_diameter = from.m_diameter; + target.m_kh = from.m_kh; + target.m_skinFactor = from.m_skinFactor; + target.m_dFactor = from.m_dFactor; + target.m_direction = from.m_direction; + target.m_isMainBore = from.m_isMainBore; + target.m_readyForExport = from.m_readyForExport; + target.m_count = from.m_count; + target.m_wpimult = from.m_wpimult; + target.m_completionType = from.m_completionType; + target.m_firstOrderingValue = from.m_firstOrderingValue; + target.m_secondOrderingValue = from.m_secondOrderingValue; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index 035142906e..8fb30ae498 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -68,7 +68,7 @@ class RigCompletionData CT_UNDEFINED }; - RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex); + RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue); ~RigCompletionData(); RigCompletionData(const RigCompletionData& other); @@ -76,6 +76,7 @@ class RigCompletionData RigCompletionData& operator=(const RigCompletionData& other); void setFromFracture(double transmissibility, double skinFactor); + void setSecondOrderingValue(double orderingValue); void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, double skinFactor, @@ -116,6 +117,9 @@ class RigCompletionData bool isMainBore() const; bool readyForExport() const; + double firstOrderingValue() const; + double secondOrderingValue() const; + std::vector m_metadata; private: @@ -138,6 +142,9 @@ class RigCompletionData CompletionType m_completionType; + double m_firstOrderingValue; + double m_secondOrderingValue; + private: static bool onlyOneIsDefaulted(double first, double second); static void copy(RigCompletionData& target, const RigCompletionData& from); From 7ddfaeb2347fc1d233e9c1af11c5800c13ca0ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 8 Feb 2018 11:05:01 +0100 Subject: [PATCH 0225/1027] #2388 fractures. Support for asymmetric stim plan --- .../FileInterface/RifStimPlanXmlReader.cpp | 80 ++++--- .../FileInterface/RifStimPlanXmlReader.h | 13 +- .../RivWellFracturePartMgr.cpp | 24 +- .../RivWellFracturePartMgr.h | 2 - .../RimStimPlanFractureTemplate.cpp | 7 +- .../RigStimPlanFractureDefinition.cpp | 209 ++++++++++-------- .../RigStimPlanFractureDefinition.h | 97 ++++---- doc/fracture_clases.plantuml | 11 +- 8 files changed, 232 insertions(+), 211 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index 095c214e77..c3deeeec33 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -28,17 +28,23 @@ #include // Needed for HUGE_VAL on Linux + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +bool hasNegativeValues(std::vector xs); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, + MirrorMode mirrorMode, QString * errorMessage) { RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName)); cvf::ref stimPlanFileData = new RigStimPlanFractureDefinition; - size_t startingNegXsValues = 0; { QFile dataFile(stimPlanFileName); if (!dataFile.open(QFile::ReadOnly)) @@ -50,7 +56,7 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil QXmlStreamReader xmlStream; xmlStream.setDevice(&dataFile); xmlStream.readNext(); - startingNegXsValues = readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p()); + readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode); RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet(); @@ -69,9 +75,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil } - size_t numberOfDepthValues = stimPlanFileData->depthCount(); - RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->gridXCount()), - QString::number(numberOfDepthValues))); + size_t numberOfYValues = stimPlanFileData->yCount(); + RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->xCount()), + QString::number(numberOfYValues))); size_t numberOfTimeSteps = stimPlanFileData->timeSteps().size(); RiaLogging::debug(QString("Number of time-steps: %1").arg(numberOfTimeSteps)); @@ -109,8 +115,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil { double timeStepValue = getAttributeValueDouble(xmlStream2, "value"); - std::vector> propertyValuesAtTimestep = getAllDepthDataAtTimeStep(xmlStream2, startingNegXsValues); - + std::vector> propertyValuesAtTimestep = + stimPlanFileData->generateDataLayoutFromFileDataLayout(getAllDepthDataAtTimeStep(xmlStream2)); + bool valuesOK = stimPlanFileData->numberOfParameterValuesOK(propertyValuesAtTimestep); if (!valuesOK) { @@ -153,17 +160,16 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil RiaLogging::info(QString("Successfully read XML file: '%1'").arg(stimPlanFileName)); } - return stimPlanFileData; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData) +void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, + RigStimPlanFractureDefinition* stimPlanFileData, + MirrorMode mirrorMode) { - - size_t startNegValuesXs = 0; size_t startNegValuesYs = 0; QString gridunit = "unknown"; @@ -180,9 +186,9 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS { gridunit = getAttributeValueString(xmlStream, "uom"); - if (gridunit == "m") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_METRIC); - else if (gridunit == "ft") stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_FIELD); - else stimPlanFileData->setUnitSet(RiaEclipseUnitTools::UNITS_UNKNOWN); + if (gridunit == "m") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_METRIC; + else if (gridunit == "ft") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_FIELD; + else stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); double tvdToBottomPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); @@ -193,18 +199,26 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS if (xmlStream.name() == "xs") { + size_t dummy; std::vector gridValues; - getGriddingValues(xmlStream, gridValues, startNegValuesXs); - stimPlanFileData->setGridXs(gridValues); + getGriddingValues(xmlStream, gridValues, dummy); + stimPlanFileData->m_fileXs = gridValues; + + stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValues) : (bool)mirrorMode); } else if (xmlStream.name() == "ys") { std::vector gridValues; getGriddingValues(xmlStream, gridValues, startNegValuesYs); - stimPlanFileData->setGridYs(gridValues); - stimPlanFileData->reorderYgridToDepths(); + // Reorder and change sign + std::vector ys; + for (double y : gridValues) + { + ys.insert(ys.begin(), -y); + } + stimPlanFileData->m_Ys = ys; } else if (xmlStream.name() == "time") @@ -219,13 +233,12 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS { RiaLogging::error(QString("Negative depth values detected in XML file")); } - return startNegValuesXs; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs) +std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream) { std::vector> propertyValuesAtTimestep; @@ -245,14 +258,10 @@ std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeSte QString depthDataStr = xmlStream.text().toString(); for (int i = 0; i < depthDataStr.split(' ').size(); i++) { - if (i < static_cast(startingNegValuesXs)) continue; - else + QString value = depthDataStr.split(' ')[i]; + if ( value != "") { - QString value = depthDataStr.split(' ')[i]; - if ( value != "") - { - propertyValuesAtDepth.push_back(value.toDouble()); - } + propertyValuesAtDepth.push_back(value.toDouble()); } } } @@ -274,11 +283,8 @@ void RifStimPlanXmlReader::getGriddingValues(QXmlStreamReader &xmlStream, std::v if (value.size() > 0) { double gridValue = value.toDouble(); - if (gridValue > -1e-5) //tolerance of 1e-5 - { - gridValues.push_back(gridValue); - } - else startNegValues++; + gridValues.push_back(gridValue); + if(gridValue < -RigStimPlanFractureDefinition::THRESHOLD_VALUE) startNegValues++; } } } @@ -315,6 +321,10 @@ QString RifStimPlanXmlReader::getAttributeValueString(QXmlStreamReader &xmlStrea return parameterValue; } - - - +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +bool hasNegativeValues(std::vector xs) +{ + return xs[0] < -RigStimPlanFractureDefinition::THRESHOLD_VALUE; +} diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index 95070a8c7b..7521323f1a 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -33,16 +33,23 @@ class QXmlStreamReader; class RifStimPlanXmlReader { public: - static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, QString * errorMessage); + enum MirrorMode { MIRROR_OFF = 0, MIRROR_ON = 1, MIRROR_AUTO = 2}; + + static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, + double conductivityScalingFactor, + MirrorMode mirrorMode, + QString * errorMessage); private: - static size_t readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData); + static void readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, + RigStimPlanFractureDefinition* stimPlanFileData, + MirrorMode mirrorMode); static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName); static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName); static void getGriddingValues(QXmlStreamReader &xmlStream, std::vector& gridValues, size_t& startNegValues); - static std::vector> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs); + static std::vector> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream); }; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 261f8b8f51..419af4ac66 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -229,23 +229,6 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod appendFracturePerforationLengthParts(eclView, model); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector depthData) -{ - std::vector mirroredValuesAtGivenDepth; - mirroredValuesAtGivenDepth.push_back(depthData[0]); - for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice - { - double valueAtGivenX = depthData[i]; - mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX); - mirroredValuesAtGivenDepth.push_back(valueAtGivenX); - } - - return mirroredValuesAtGivenDepth; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -443,7 +426,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord); nodeCoord = cvf::Vec3f(doubleCoord); } - + RimLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { @@ -459,10 +442,9 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa { size_t idx = 0; const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors->uiResultName(), activeView.fractureColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); - for (const std::vector& unmirroredDataAtDepth : dataToPlot) + for (const std::vector& dataAtY : dataToPlot) { - const std::vector mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth); - for (double val : mirroredValuesAtDepth) + for (double val : dataAtY) { perNodeResultValues[idx++] = val; } diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 955a1b220a..614344f226 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -57,8 +57,6 @@ class RivWellFracturePartMgr : public cvf::Object void appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView); - static std::vector mirrorDataAtSingleDepth(std::vector depthData); - const QString resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const; const RigFractureCell* getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 68ab5b19d1..a49beec6e2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -260,7 +260,10 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() if (m_readError) return; - m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_conductivityScalingFactor(), &errorMessage); + m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), + m_conductivityScalingFactor(), + RifStimPlanXmlReader::MIRROR_AUTO, + &errorMessage); if (errorMessage.size() > 0) RiaLogging::error(errorMessage); if (m_stimPlanFractureDefinitionData.notNull()) @@ -670,7 +673,7 @@ void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandl if (field == &m_wellPathDepthAtFracture) { - if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->depthCount() > 0) ) + if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->yCount() > 0) ) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if ( myAttr ) diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 1df1b09e1d..d0f3e6bbf2 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -30,14 +30,16 @@ #include + //-------------------------------------------------------------------------------------------------- -/// +/// Internal functions //-------------------------------------------------------------------------------------------------- -RigStimPlanResultFrames::RigStimPlanResultFrames() -{ - -} +size_t findMirrorXIndex(std::vector xs); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const double RigStimPlanFractureDefinition::THRESHOLD_VALUE = 1e-5; //-------------------------------------------------------------------------------------------------- /// @@ -116,23 +118,60 @@ void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd, Ria //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigStimPlanFractureDefinition::getNegAndPosXcoords() const +void RigStimPlanFractureDefinition::generateXsFromFileXs(bool xMirrorMode) { - std::vector allXcoords; - for ( const double& xCoord : m_gridXs ) + m_xMirrorMode = xMirrorMode; + m_Xs.clear(); + + if (m_xMirrorMode) { - if ( xCoord > 1e-5 ) + size_t mirrorIndex = findMirrorXIndex(m_fileXs); + std::list xs; + + // Mirror positive X values + xs.push_back(m_fileXs[mirrorIndex]); + for (size_t i = mirrorIndex + 1; i < m_fileXs.size(); i++) { - double negXcoord = -xCoord; - allXcoords.insert(allXcoords.begin(), negXcoord); + xs.push_front(-m_fileXs[i]); + xs.push_back(m_fileXs[i]); } + m_Xs = std::vector(xs.begin(), xs.end()); } - for ( const double& xCoord : m_gridXs ) + else { - allXcoords.push_back(xCoord); + m_Xs = m_fileXs; } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RigStimPlanFractureDefinition::generateDataLayoutFromFileDataLayout(std::vector> fileXYData) +{ + if (m_xMirrorMode) + { + std::vector> xyData; + size_t mirrorIndex = findMirrorXIndex(m_fileXs); - return allXcoords; + for (const auto& yData : fileXYData) + { + std::list xValues; + + // Mirror positive X values + xValues.push_back(yData[mirrorIndex]); + for (size_t x = mirrorIndex + 1; x < yData.size(); x++) + { + xValues.push_front(yData[x]); + xValues.push_back(yData[x]); + } + xyData.push_back(std::vector(xValues.begin(), xValues.end())); + } + return xyData; + } + else + { + return fileXYData; + } } //-------------------------------------------------------------------------------------------------- @@ -140,13 +179,12 @@ std::vector RigStimPlanFractureDefinition::getNegAndPosXcoords() const //-------------------------------------------------------------------------------------------------- bool RigStimPlanFractureDefinition::numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep) { - size_t depths = this->depths.size(); - size_t gridXvalues = this->m_gridXs.size(); + size_t xCount = m_Xs.size(); - if ( propertyValuesAtTimestep.size() != depths ) return false; + if ( propertyValuesAtTimestep.size() != yCount()) return false; for ( std::vector valuesAtDepthVector : propertyValuesAtTimestep ) { - if ( valuesAtDepthVector.size() != gridXvalues ) return false; + if ( valuesAtDepthVector.size() != xCount ) return false; } return true; @@ -155,17 +193,16 @@ bool RigStimPlanFractureDefinition::numberOfParameterValuesOK(std::vector RigStimPlanFractureDefinition::adjustedDepthCoordsAroundWellPathPosition(double wellPathDepthAtFracture) const +std::vector RigStimPlanFractureDefinition::adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const { - std::vector depthRelativeToWellPath; + std::vector yRelativeToWellPath; - for ( const double& depth : this->depths ) + for ( const double& y : m_Ys ) { - double adjustedDepth = depth - wellPathDepthAtFracture; - adjustedDepth = -adjustedDepth; - depthRelativeToWellPath.push_back(adjustedDepth); + double adjustedDepth = y + wellPathIntersectionAtFractureDepth; + yRelativeToWellPath.push_back(adjustedDepth); } - return depthRelativeToWellPath; + return yRelativeToWellPath; } //-------------------------------------------------------------------------------------------------- @@ -183,32 +220,13 @@ std::vector > RigStimPlanFractureDefinition::getStim return propertyNamesUnits; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector> RigStimPlanFractureDefinition::getMirroredDataAtTimeIndex(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const -{ - std::vector> notMirrordedData = this->getDataAtTimeIndex(resultName, unitName, timeStepIndex); - std::vector> mirroredData; - - for ( std::vector depthData : notMirrordedData ) - { - std::vector mirrordDepthData = RivWellFracturePartMgr::mirrorDataAtSingleDepth(depthData); - mirroredData.push_back(mirrordDepthData); - } - - return mirroredData; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RigStimPlanFractureDefinition::createFractureGrid(const QString& resultName, - int m_activeTimeStepIndex, + int activeTimeStepIndex, RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, - double m_wellPathDepthAtFracture) + double wellPathIntersectionAtFractureDepth) { std::vector stimPlanCells; std::pair wellCenterStimPlanCellIJ = std::make_pair(0, 0); @@ -217,17 +235,17 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit); - std::vector> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultName, - condUnit, - m_activeTimeStepIndex); + std::vector> conductivityValuesAtTimeStep = this->getDataAtTimeIndex(resultName, + condUnit, + activeTimeStepIndex); - std::vector depthCoordsAtNodes = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); - std::vector xCoordsAtNodes = this->getNegAndPosXcoords(); + std::vector yCoordsAtNodes = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); + std::vector xCoordsAtNodes = this->m_Xs; std::vector xCoords; for ( int i = 0; i < static_cast(xCoordsAtNodes.size()) - 1; i++ ) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2); std::vector depthCoords; - for ( int i = 0; i < static_cast(depthCoordsAtNodes.size()) - 1; i++ ) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2); + for ( int i = 0; i < static_cast(yCoordsAtNodes.size()) - 1; i++ ) depthCoords.push_back((yCoordsAtNodes[i] + yCoordsAtNodes[i + 1]) / 2); for ( int i = 0; i < static_cast(xCoords.size()) - 1; i++ ) { @@ -276,8 +294,8 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons cvf::ref m_fractureGrid = new RigFractureGrid; m_fractureGrid->setFractureCells(stimPlanCells); m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ); - m_fractureGrid->setICellCount(this->getNegAndPosXcoords().size() - 2); - m_fractureGrid->setJCellCount(this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture).size() - 2); + m_fractureGrid->setICellCount(this->m_Xs.size() - 2); + m_fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2); return m_fractureGrid; } @@ -290,13 +308,13 @@ std::vector RigStimPlanFractureDefinition::fractureGridResults(const QSt size_t timeStepIndex) const { std::vector fractureGridResults; - std::vector> resultValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultName, - unitName, - timeStepIndex); + const std::vector>& resultValuesAtTimeStep = this->getDataAtTimeIndex(resultName, + unitName, + timeStepIndex); - for ( int i = 0; i < static_cast(mirroredGridXCount()) - 2; i++ ) + for ( int i = 0; i < static_cast(xCount()) - 2; i++ ) { - for ( int j = 0; j < static_cast(depthCount()) - 2; j++ ) + for ( int j = 0; j < static_cast(yCount()) - 2; j++ ) { if ( j+1 < static_cast(resultValuesAtTimeStep.size()) && i+1 < static_cast(resultValuesAtTimeStep[j + 1].size()) ) { @@ -315,16 +333,16 @@ std::vector RigStimPlanFractureDefinition::fractureGridResults(const QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_wellPathDepthAtFracture, +void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName, std::vector* vertices, std::vector* triangleIndices) { - std::vector xCoords = this->getNegAndPosXcoords(); + std::vector xCoords = this->m_Xs; cvf::uint lenXcoords = static_cast(xCoords.size()); - std::vector adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); + std::vector adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); if ( neededUnit == m_unitSet ) { @@ -334,13 +352,13 @@ void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_well else if ( m_unitSet == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD ) { RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedDepths ) value = RiaEclipseUnitTools::meterToFeet(value); + for ( double& value : adjustedYs ) value = RiaEclipseUnitTools::meterToFeet(value); for ( double& value : xCoords ) value = RiaEclipseUnitTools::meterToFeet(value); } else if ( m_unitSet == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC ) { RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedDepths ) value = RiaEclipseUnitTools::feetToMeter(value); + for ( double& value : adjustedYs ) value = RiaEclipseUnitTools::feetToMeter(value); for ( double& value : xCoords ) value = RiaEclipseUnitTools::feetToMeter(value); } else @@ -350,16 +368,16 @@ void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_well return; } - for ( cvf::uint k = 0; k < adjustedDepths.size(); k++ ) + for ( cvf::uint k = 0; k < adjustedYs.size(); k++ ) { for ( cvf::uint i = 0; i < lenXcoords; i++ ) { - cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0); + cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedYs[k], 0); vertices->push_back(node); - if ( i < lenXcoords - 1 && k < adjustedDepths.size() - 1 ) + if ( i < lenXcoords - 1 && k < adjustedYs.size() - 1 ) { - if ( xCoords[i] < 1e-5 ) + if ( xCoords[i] < THRESHOLD_VALUE ) { //Upper triangle triangleIndices->push_back(i + k*lenXcoords); @@ -423,16 +441,16 @@ void sortPolygon(std::vector &polygon) //-------------------------------------------------------------------------------------------------- std::vector RigStimPlanFractureDefinition::createFractureBorderPolygon(const QString& resultName, const QString& resultUnit, - int m_activeTimeStepIndex, - double m_wellPathDepthAtFracture, + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName) { std::vector polygon; - std::vector> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, m_activeTimeStepIndex); + std::vector> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, activeTimeStepIndex); - std::vector adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); + std::vector adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); for ( int k = 0; k < static_cast(dataAtTimeStep.size()); k++ ) { @@ -442,18 +460,18 @@ std::vector RigStimPlanFractureDefinition::createFractureBorderPolyg { if ( (i > 0) && ((dataAtTimeStep[k])[(i - 1)] > 1e-7) ) //side neighbour cell different from 0 { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); + polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), + static_cast(adjustedYs[k]), 0.0f)); } else if ( (k < static_cast(dataAtTimeStep.size()) - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7) )//cell below different from 0 { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); + polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), + static_cast(adjustedYs[k]), 0.0f)); } else if ( (k > 0) && ((dataAtTimeStep[k - 1])[(i)] > 1e-7) )//cell above different from 0 { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); + polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), + static_cast(adjustedYs[k]), 0.0f)); } } } @@ -518,28 +536,15 @@ std::vector RigStimPlanFractureDefinition::createFractureBorderPolyg //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigStimPlanFractureDefinition::timeStepExisist(double timeStepValueToCheck) +bool RigStimPlanFractureDefinition::timeStepExists(double timeStepValueToCheck) { for (double timeStep : m_timeSteps) { - if (fabs(timeStepValueToCheck - timeStep) < 1e-5) return true; + if (fabs(timeStepValueToCheck - timeStep) < THRESHOLD_VALUE) return true; } return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::reorderYgridToDepths() -{ - std::vector depthsInIncreasingOrder; - for (double gridYvalue : m_gridYs) - { - depthsInIncreasingOrder.insert(depthsInIncreasingOrder.begin(), gridYvalue); - } - depths = depthsInIncreasingOrder; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -667,3 +672,21 @@ QStringList RigStimPlanFractureDefinition::conductivityResultNames() const return resultNames; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t findMirrorXIndex(std::vector xs) +{ + size_t mirrorIndex = cvf::UNDEFINED_SIZE_T; + + for (size_t i = 0; i < xs.size(); i++) + { + if (xs[i] > -RigStimPlanFractureDefinition::THRESHOLD_VALUE) + { + mirrorIndex = i; + break; + } + } + + return mirrorIndex; +} diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 4181d4691f..3a667d2f31 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -33,55 +33,58 @@ class PosNegAccumulator; class RigStimPlanResultFrames { public: - RigStimPlanResultFrames(); + RigStimPlanResultFrames() {} QString resultName; QString unit; - // Vector for each time step, for each depth and for each x-value + // Vector for each time step, for each y and for each x-value std::vector< std::vector< std::vector > > parameterValues; }; class RigStimPlanFractureDefinition: public cvf::Object { + friend class RifStimPlanXmlReader; + public: + static const double THRESHOLD_VALUE; + RigStimPlanFractureDefinition(); ~RigStimPlanFractureDefinition(); RiaEclipseUnitTools::UnitSystem unitSet() const { return m_unitSet; } - void setUnitSet(RiaEclipseUnitTools::UnitSystem unitset) { m_unitSet = unitset;} - - size_t gridXCount() const { return m_gridXs.size();} - void setGridXs(const std::vector& gridXs) { m_gridXs = gridXs; } - - - //TODO: Consider removing gridYs or depths, - //In example file these are the same, but can there be examples where not all gridY values are included in depths? - - void setGridYs(const std::vector& gridYs) { m_gridYs = gridYs; } + size_t xCount() const { return m_Xs.size(); } + size_t yCount() const { return m_Ys.size(); } + double minY() const { return m_Ys[0]; } + double maxY() const { return m_Ys.back(); } - double minDepth() const { return depths[0]; } - double maxDepth() const { return depths.back(); } - size_t depthCount() const { return depths.size(); } + double minDepth() const { return -minY(); } + double maxDepth() const { return -maxY(); } double topPerfTvd() const { return m_topPerfTvd; } double bottomPerfTvd() const { return m_bottomPerfTvd; } void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); - // Grid Geometry + void enableXMirrorMode(bool enable) { m_xMirrorMode = enable; } + bool xMirrorModeEnabled() const { return m_xMirrorMode; } + +private: + void generateXsFromFileXs(bool xMirrorMode); + std::vector> generateDataLayoutFromFileDataLayout(std::vector> rawXYData); + + + std::vector adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const; +public: - std::vector getNegAndPosXcoords() const; - std::vector adjustedDepthCoordsAroundWellPathPosition(double wellPathDepthAtFracture) const; - cvf::ref createFractureGrid(const QString& resultName, - int m_activeTimeStepIndex, + int activeTimeStepIndex, RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, - double m_wellPathDepthAtFracture); + double wellPathIntersectionAtFractureDepth); - void createFractureTriangleGeometry(double m_wellPathDepthAtFracture, + void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName, std::vector* vertices, @@ -89,17 +92,19 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector createFractureBorderPolygon(const QString& resultName, const QString& resultUnit, - int m_activeTimeStepIndex, - double m_wellPathDepthAtFracture, + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName); // Result Access const std::vector& timeSteps() const { return m_timeSteps; } - void addTimeStep(double time) { if (!timeStepExisist(time)) m_timeSteps.push_back(time); } + void addTimeStep(double time) { if (!timeStepExists(time)) m_timeSteps.push_back(time); } std::vector > getStimPlanPropertyNamesUnits() const; +private: bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); +public: size_t totalNumberTimeSteps(); void setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue); const std::vector>& getDataAtTimeIndex(const QString& resultName, const QString& unit, size_t timeStepIndex) const; @@ -107,37 +112,29 @@ class RigStimPlanFractureDefinition: public cvf::Object const QString& unitName, size_t timeStepIndex) const; - void appendDataToResultStatistics(const QString& resultName, const QString& unit, - MinMaxAccumulator& minMaxAccumulator, - PosNegAccumulator& posNegAccumulator) const; + void appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const; QStringList conductivityResultNames() const; - - // Setup - void reorderYgridToDepths(); private: - bool timeStepExisist(double timeStepValue); + bool timeStepExists(double timeStepValue); size_t getTimeStepIndex(double timeStepValue); size_t resultIndex(const QString& resultName, const QString& unit) const; - size_t mirroredGridXCount() const { return m_gridXs.size() ? m_gridXs.size() + m_gridXs.size() - 1 : 0 ;} - - std::vector> getMirroredDataAtTimeIndex(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const; - private: - RiaEclipseUnitTools::UnitSystem m_unitSet; - std::vector m_gridXs; - std::vector m_gridYs; - std::vector depths; - - double m_topPerfTvd; - double m_bottomPerfTvd; - - std::vector m_timeSteps; - std::vector m_stimPlanResults; + // Data read from file + RiaEclipseUnitTools::UnitSystem m_unitSet; + std::vector m_fileXs; + std::vector m_Ys; + std::vector m_timeSteps; + + // Modified file data + std::vector m_stimPlanResults; + std::vector m_Xs; + bool m_xMirrorMode; + + double m_topPerfTvd; + double m_bottomPerfTvd; }; - - diff --git a/doc/fracture_clases.plantuml b/doc/fracture_clases.plantuml index f6fd1ddedc..b4e0b2dd83 100644 --- a/doc/fracture_clases.plantuml +++ b/doc/fracture_clases.plantuml @@ -3,7 +3,7 @@ Title Classes related to fractures note as N1 - Updated 2017-06-09 + Updated 2018-02-07 end note class RimFracture { @@ -29,6 +29,9 @@ class RimEllipseFractureTemplate { class RimStimPlanFractureTemplate { } +class RifStimPlanXmlReader { + <> readStimPlanXMLFile() +} RimFractureTemplate <|-- RimEllipseFractureTemplate RimFractureTemplate <|-- RimStimPlanFractureTemplate @@ -80,9 +83,7 @@ class RicExportFractureCompletionsImpl{ generateFracturesCompdatValues() } - - - - +RimStimPlanFractureTemplate ---> RifStimPlanXmlReader +RifStimPlanXmlReader ...> "create" RigStimPlanFractureDefinition @enduml From beb122c6d0d5a37e4a48f4477ec4964f870aa88b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2018 11:32:15 +0100 Subject: [PATCH 0226/1027] System : Fix compiler warning --- .../ProjectDataModel/Completions/RimSimWellFracture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index afcd5615d8..fe7740300a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -139,7 +139,7 @@ std::vector RimSimWellFracture::perforationLengthCenterLineCoords() { std::vector coords; - if (!m_branchCenterLines.empty() && m_branchIndex < m_branchCenterLines.size()) + if (!m_branchCenterLines.empty() && m_branchIndex < static_cast(m_branchCenterLines.size())) { RigWellPath wellPathGeometry; From 80eefb3141ee6d344bc4dafd074c9e9294158037 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2018 11:34:18 +0100 Subject: [PATCH 0227/1027] #2442 Fracture Template : Move several fields from public to protected --- .../RicExportFractureCompletionsImpl.cpp | 2 +- .../RimEllipseFractureTemplate.cpp | 28 ++--- .../Completions/RimFracture.cpp | 6 +- .../Completions/RimFractureTemplate.cpp | 110 +++++++++++------- .../Completions/RimFractureTemplate.h | 59 +++++----- .../RimStimPlanFractureTemplate.cpp | 22 ++-- 6 files changed, 126 insertions(+), 101 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 850bb76a0d..6a75be05f1 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -181,7 +181,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat RigEclipseToStimPlanCellTransmissibilityCalculator eclToFractureTransCalc(caseToApply, fracture->transformMatrix(), - fracture->fractureTemplate()->skinFactor, + fracture->fractureTemplate()->skinFactor(), cDarcyInCorrectUnit, fractureCell); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index ceeeaa6df1..4fbce33aa3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -178,8 +178,8 @@ void RimEllipseFractureTemplate::changeUnits() m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); m_height = RiaEclipseUnitTools::meterToFeet(m_height); m_width = RiaEclipseUnitTools::meterToInch(m_width); - wellDiameter = RiaEclipseUnitTools::meterToInch(wellDiameter); - perforationLength = RiaEclipseUnitTools::meterToFeet(perforationLength); + m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); + m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); fractureTemplateUnit = RiaEclipseUnitTools::UNITS_FIELD; } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) @@ -187,8 +187,8 @@ void RimEllipseFractureTemplate::changeUnits() m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); m_height = RiaEclipseUnitTools::feetToMeter(m_height); m_width = RiaEclipseUnitTools::inchToMeter(m_width); - wellDiameter = RiaEclipseUnitTools::inchToMeter(wellDiameter); - perforationLength = RiaEclipseUnitTools::feetToMeter(perforationLength); + m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); + m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); fractureTemplateUnit = RiaEclipseUnitTools::UNITS_METRIC; } @@ -355,23 +355,23 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm m_halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); m_height.uiCapability()->setUiName("Height [m]"); m_width.uiCapability()->setUiName("Width [m]"); - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); m_height.uiCapability()->setUiName("Height [Ft]"); m_width.uiCapability()->setUiName("Width [inches]"); - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); } - if (conductivityType == FINITE_CONDUCTIVITY) + if (conductivityType() == FINITE_CONDUCTIVITY) { m_permeability.uiCapability()->setUiHidden(false); m_width.uiCapability()->setUiHidden(false); } - else if (conductivityType == INFINITE_CONDUCTIVITY) + else if (conductivityType() == INFINITE_CONDUCTIVITY) { m_permeability.uiCapability()->setUiHidden(true); m_width.uiCapability()->setUiHidden(true); @@ -384,19 +384,19 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm geometryGroup->add(&m_halfLength); geometryGroup->add(&m_height); geometryGroup->add(&orientationType); - geometryGroup->add(&azimuthAngle); + geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); m_fractureContainment()->defineUiOrdering(uiConfigName, *trGr); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); - propertyGroup->add(&conductivityType); + propertyGroup->add(&m_conductivityType); propertyGroup->add(&m_permeability); propertyGroup->add(&m_width); - propertyGroup->add(&skinFactor); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_skinFactor); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); uiOrdering.add(&fractureTemplateUnit); uiOrdering.skipRemainingFields(true); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 01adeee8c7..e2931f9b3c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -483,11 +483,11 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO m_perforationLength.uiCapability()->setUiHidden(true); } - if (fractureTemplate()->conductivityType == RimFractureTemplate::FINITE_CONDUCTIVITY) + if (fractureTemplate()->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY) { m_wellDiameter.uiCapability()->setUiHidden(false); } - else if (fractureTemplate()->conductivityType == RimFractureTemplate::INFINITE_CONDUCTIVITY) + else if (fractureTemplate()->conductivityType() == RimFractureTemplate::INFINITE_CONDUCTIVITY) { m_wellDiameter.uiCapability()->setUiHidden(true); } @@ -628,7 +628,7 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) if (fractureTemplate->orientationType == RimFractureTemplate::AZIMUTH) { - m_azimuth = fractureTemplate->azimuthAngle; + m_azimuth = fractureTemplate->azimuthAngle(); } else { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 8b4e78913d..5226f8c525 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -69,16 +69,16 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); fractureTemplateUnit.uiCapability()->setUiReadOnly(true); - CAF_PDM_InitField(&orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); - CAF_PDM_InitField(&azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", ""); //Is this correct description? - CAF_PDM_InitField(&skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); + CAF_PDM_InitField(&orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); + CAF_PDM_InitField(&m_azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", ""); //Is this correct description? + CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); - CAF_PDM_InitField(&perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); - CAF_PDM_InitField(&perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); - perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitField(&m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); + CAF_PDM_InitField(&m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); + m_perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); - CAF_PDM_InitField(&conductivityType, "ConductivityType", caf::AppEnum(FINITE_CONDUCTIVITY), "Conductivity in Fracture", "", "", ""); + CAF_PDM_InitField(&m_conductivityType, "ConductivityType", caf::AppEnum(FINITE_CONDUCTIVITY), "Conductivity in Fracture", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_fractureContainment, "FractureContainmentField", "Fracture Containment", "", "", ""); m_fractureContainment = new RimFractureContainment(); @@ -106,7 +106,7 @@ caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &azimuthAngle || changedField == &orientationType) + if (changedField == &m_azimuthAngle || changedField == &orientationType) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -121,16 +121,16 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &azimuthAngle && (fabs(oldValue.toDouble() - fracture->m_azimuth()) < 1e-5)) + if (changedField == &m_azimuthAngle && (fabs(oldValue.toDouble() - fracture->m_azimuth()) < 1e-5)) { - fracture->m_azimuth = azimuthAngle; + fracture->m_azimuth = m_azimuthAngle; } if (changedField == &orientationType) { if (newValue == AZIMUTH) { - fracture->m_azimuth = azimuthAngle; + fracture->m_azimuth = m_azimuthAngle; } else fracture->updateAzimuthBasedOnWellAzimuthAngle(); } @@ -141,7 +141,7 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } } - if (changedField == &perforationLength || changedField == &perforationEfficiency || changedField == &wellDiameter) + if (changedField == &m_perforationLength || changedField == &m_perforationEfficiency || changedField == &m_wellDiameter) { RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -153,23 +153,23 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &perforationLength && (fabs(oldValue.toDouble() - fracture->m_perforationLength()) < 1e-5)) + if (changedField == &m_perforationLength && (fabs(oldValue.toDouble() - fracture->m_perforationLength()) < 1e-5)) { - fracture->m_perforationLength = perforationLength; + fracture->m_perforationLength = m_perforationLength; } - if (changedField == &perforationEfficiency && (fabs(oldValue.toDouble() - fracture->m_perforationEfficiency()) < 1e-5)) + if (changedField == &m_perforationEfficiency && (fabs(oldValue.toDouble() - fracture->m_perforationEfficiency()) < 1e-5)) { - fracture->m_perforationEfficiency = perforationEfficiency; + fracture->m_perforationEfficiency = m_perforationEfficiency; } - if (changedField == &wellDiameter && (fabs(oldValue.toDouble() - fracture->m_wellDiameter()) < 1e-5)) + if (changedField == &m_wellDiameter && (fabs(oldValue.toDouble() - fracture->m_wellDiameter()) < 1e-5)) { - fracture->m_wellDiameter = wellDiameter; + fracture->m_wellDiameter = m_wellDiameter; } } } } - if (changedField == &perforationLength) + if (changedField == &m_perforationLength) { RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -188,43 +188,43 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); - perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); } if (orientationType == RimFractureTemplate::ALONG_WELL_PATH || orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - azimuthAngle.uiCapability()->setUiHidden(true); + m_azimuthAngle.uiCapability()->setUiHidden(true); } else if (orientationType == RimFractureTemplate::AZIMUTH) { - azimuthAngle.uiCapability()->setUiHidden(false); + m_azimuthAngle.uiCapability()->setUiHidden(false); } if (orientationType == RimFractureTemplate::ALONG_WELL_PATH) { - perforationEfficiency.uiCapability()->setUiHidden(false); - perforationLength.uiCapability()->setUiHidden(false); + m_perforationEfficiency.uiCapability()->setUiHidden(false); + m_perforationLength.uiCapability()->setUiHidden(false); } else { - perforationEfficiency.uiCapability()->setUiHidden(true); - perforationLength.uiCapability()->setUiHidden(true); + m_perforationEfficiency.uiCapability()->setUiHidden(true); + m_perforationLength.uiCapability()->setUiHidden(true); } - if (conductivityType == FINITE_CONDUCTIVITY) + if (m_conductivityType == FINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(false); + m_wellDiameter.uiCapability()->setUiHidden(false); } - else if (conductivityType == INFINITE_CONDUCTIVITY) + else if (m_conductivityType == INFINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(true); + m_wellDiameter.uiCapability()->setUiHidden(true); } } @@ -234,7 +234,7 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - if (field == &perforationEfficiency) + if (field == &m_perforationEfficiency) { auto myAttr = dynamic_cast(attribute); if (myAttr) @@ -253,17 +253,17 @@ double RimFractureTemplate::wellDiameterInFractureUnit(RiaEclipseUnitTools::Unit { if (fractureUnit == fractureTemplateUnit()) { - return wellDiameter; + return m_wellDiameter; } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::meterToInch(wellDiameter); + return RiaEclipseUnitTools::meterToInch(m_wellDiameter); } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { - return RiaEclipseUnitTools::inchToMeter(wellDiameter); + return RiaEclipseUnitTools::inchToMeter(m_wellDiameter); } return cvf::UNDEFINED_DOUBLE; @@ -276,17 +276,17 @@ double RimFractureTemplate::perforationLengthInFractureUnit(RiaEclipseUnitTools: { if (fractureUnit == fractureTemplateUnit()) { - return perforationLength; + return m_perforationLength; } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::meterToFeet(perforationLength); + return RiaEclipseUnitTools::meterToFeet(m_perforationLength); } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { - return RiaEclipseUnitTools::feetToMeter(perforationLength); + return RiaEclipseUnitTools::feetToMeter(m_perforationLength); } return cvf::UNDEFINED_DOUBLE; @@ -300,6 +300,30 @@ const RimFractureContainment * RimFractureTemplate::fractureContainment() return m_fractureContainment(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate::FracConductivityEnum RimFractureTemplate::conductivityType() const +{ + return m_conductivityType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimFractureTemplate::azimuthAngle() const +{ + return m_azimuthAngle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimFractureTemplate::skinFactor() const +{ + return m_skinFactor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -307,10 +331,10 @@ void RimFractureTemplate::setDefaultWellDiameterFromUnit() { if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter = 8.5; + m_wellDiameter = 8.5; } else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { - wellDiameter = 0.216; + m_wellDiameter = 0.216; } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index dbb906c76f..c4427d3c38 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -47,61 +47,62 @@ class RimFractureTemplate : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RimFractureTemplate(); - virtual ~RimFractureTemplate(); - - caf::PdmField name; - caf::PdmField azimuthAngle; - caf::PdmField skinFactor; - - caf::PdmField perforationLength; - caf::PdmField perforationEfficiency; - caf::PdmField wellDiameter; - enum FracOrientationEnum { AZIMUTH, ALONG_WELL_PATH, TRANSVERSE_WELL_PATH }; - caf::PdmField< caf::AppEnum< FracOrientationEnum > > orientationType; enum FracConductivityEnum { INFINITE_CONDUCTIVITY, FINITE_CONDUCTIVITY, }; - caf::PdmField< caf::AppEnum< FracConductivityEnum > > conductivityType; - caf::PdmField< RiaEclipseUnitTools::UnitSystemType > fractureTemplateUnit; +public: + RimFractureTemplate(); + virtual ~RimFractureTemplate(); + + caf::PdmField name; + caf::PdmField> orientationType; + caf::PdmField fractureTemplateUnit; + FracConductivityEnum conductivityType() const; + float azimuthAngle() const; + float skinFactor() const; void setDefaultWellDiameterFromUnit(); double wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); double perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); - - virtual void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual const RigFractureGrid* fractureGrid() const = 0; - - const RimFractureContainment * fractureContainment(); + virtual void fractureTriangleGeometry(std::vector* nodeCoords, + std::vector* triangleIndices, + RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit, - MinMaxAccumulator& minMaxAccumulator, - PosNegAccumulator& posNegAccumulator) const = 0; + virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + virtual const RigFractureGrid* fractureGrid() const = 0; + const RimFractureContainment* fractureContainment(); - virtual std::vector > uiResultNamesWithUnit() const = 0; + virtual void appendDataToResultStatistics(const QString& resultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const = 0; + virtual std::vector> uiResultNamesWithUnit() const = 0; protected: - caf::PdmChildField m_fractureContainment; - virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; +protected: + caf::PdmField m_wellDiameter; + caf::PdmField m_perforationLength; + caf::PdmField m_perforationEfficiency; + caf::PdmField m_skinFactor; + caf::PdmField m_azimuthAngle; + + caf::PdmChildField m_fractureContainment; + caf::PdmField> m_conductivityType; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index a49beec6e2..f8179b1704 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -363,17 +363,17 @@ void RimStimPlanFractureTemplate::setPerforationLength() if (firstTvd != HUGE_VAL && lastTvd != HUGE_VAL) { - perforationLength = std::round(cvf::Math::abs(firstTvd - lastTvd)); + m_perforationLength = std::round(cvf::Math::abs(firstTvd - lastTvd)); } } - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && perforationLength < 10) + if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && m_perforationLength < 10) { - perforationLength = 10; + m_perforationLength = 10; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && perforationLength < RiaEclipseUnitTools::meterToFeet(10)) + else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && m_perforationLength < RiaEclipseUnitTools::meterToFeet(10)) { - perforationLength = std::round(RiaEclipseUnitTools::meterToFeet(10)); + m_perforationLength = std::round(RiaEclipseUnitTools::meterToFeet(10)); } } @@ -640,7 +640,7 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); geometryGroup->add(&orientationType); - geometryGroup->add(&azimuthAngle); + geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); m_fractureContainment()->defineUiOrdering(uiConfigName, *trGr); @@ -648,11 +648,11 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_conductivityResultNameOnFile); propertyGroup->add(&m_conductivityScalingFactor); - propertyGroup->add(&conductivityType); - propertyGroup->add(&skinFactor); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_conductivityType); + propertyGroup->add(&m_skinFactor); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); } //-------------------------------------------------------------------------------------------------- From 778119bf621107a99a316069f1aed14c1d81e3e5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Feb 2018 13:57:43 +0100 Subject: [PATCH 0228/1027] #2442 Fracture Template : Move more fields from public to protected --- ...vertAllFractureTemplatesToFieldFeature.cpp | 2 +- ...ertAllFractureTemplatesToMetricFeature.cpp | 2 +- .../RicConvertFractureTemplateUnitFeature.cpp | 4 +- .../RicNewEllipseFractureTemplateFeature.cpp | 4 +- .../RicNewStimPlanFractureTemplateFeature.cpp | 2 +- .../RimEllipseFractureTemplate.cpp | 26 +++--- .../Completions/RimFracture.cpp | 16 ++-- .../Completions/RimFractureTemplate.cpp | 82 ++++++++++++++----- .../Completions/RimFractureTemplate.h | 39 +++++---- .../Completions/RimSimWellFracture.cpp | 8 +- .../RimStimPlanFractureTemplate.cpp | 18 ++-- .../Completions/RimWellPathFracture.cpp | 8 +- 12 files changed, 128 insertions(+), 83 deletions(-) diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp index 0689c25fd8..de93e781f1 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp @@ -63,7 +63,7 @@ void RicConvertAllFractureTemplatesToFieldFeature::onActionTriggered(bool isChec for (auto ellipseFracTemplate : ellipseFracTemplates) { - if (ellipseFracTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { ellipseFracTemplate->changeUnits(); } diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp index 42d6353b7d..78627f2e54 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp @@ -63,7 +63,7 @@ void RicConvertAllFractureTemplatesToMetricFeature::onActionTriggered(bool isChe for (auto ellipseFracTemplate : ellipseFracTemplates) { - if (ellipseFracTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { ellipseFracTemplate->changeUnits(); } diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp index 22da9504e9..8dfb865e07 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp @@ -78,11 +78,11 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet if (!ellipseFractureTemplate) return; QString text = "Convert Values to "; - if (ellipseFractureTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (ellipseFractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { text += "Field"; } - else if (ellipseFractureTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (ellipseFractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { text += "Metric"; } diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index cfadcdd889..c4ceee429d 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -54,8 +54,8 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) { RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate(); fracDefColl->fractureDefinitions.push_back(ellipseFractureTemplate); - ellipseFractureTemplate->name = "Ellipse Fracture Template"; - ellipseFractureTemplate->fractureTemplateUnit = fracDefColl->defaultUnitsForFracTemplates(); + ellipseFractureTemplate->setName("Ellipse Fracture Template"); + ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitsForFracTemplates()); ellipseFractureTemplate->setDefaultValuesFromUnit(); ellipseFractureTemplate->loadDataAndUpdate(); diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp index c4073bde48..d0ac1ad13b 100644 --- a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp @@ -61,7 +61,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) { RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate(); fracDefColl->fractureDefinitions.push_back(fractureDef); - fractureDef->name = "StimPlan Fracture Template"; + fractureDef->setName("StimPlan Fracture Template"); fractureDef->setFileName(fileName); fractureDef->loadDataAndUpdate(); fractureDef->setDefaultsBasedOnXMLfile(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 4fbce33aa3..2472a0a7ea 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -173,23 +173,25 @@ std::vector RimEllipseFractureTemplate::fractureBorderPolygon(RiaEcl //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::changeUnits() { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); m_height = RiaEclipseUnitTools::meterToFeet(m_height); m_width = RiaEclipseUnitTools::meterToInch(m_width); m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_FIELD; + + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_FIELD); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); m_height = RiaEclipseUnitTools::feetToMeter(m_height); m_width = RiaEclipseUnitTools::inchToMeter(m_width); m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_METRIC; + + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_METRIC); } this->updateConnectedEditors(); @@ -281,7 +283,7 @@ const RigFractureGrid* RimEllipseFractureTemplate::fractureGrid() const //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::setDefaultValuesFromUnit() { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_width = 0.5f; m_permeability = 80000.0f; @@ -305,12 +307,12 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() double RimEllipseFractureTemplate::conductivity() const { double cond = cvf::UNDEFINED_DOUBLE; - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { //Conductivity should be md-m, width is in m cond = m_permeability * m_width; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { //Conductivity should be md-ft, but width is in inches cond = m_permeability * RiaEclipseUnitTools::inchToFeet(m_width); @@ -350,14 +352,14 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm { RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { m_halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); m_height.uiCapability()->setUiName("Height [m]"); m_width.uiCapability()->setUiName("Width [m]"); m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); m_height.uiCapability()->setUiName("Height [Ft]"); @@ -378,12 +380,12 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm } - uiOrdering.add(&name); + uiOrdering.add(&m_name); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); geometryGroup->add(&m_halfLength); geometryGroup->add(&m_height); - geometryGroup->add(&orientationType); + geometryGroup->add(&m_orientationType); geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); @@ -398,7 +400,7 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); - uiOrdering.add(&fractureTemplateUnit); + uiOrdering.add(&m_fractureTemplateUnit); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index e2931f9b3c..826cc094ac 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -438,15 +438,15 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO if (fractureTemplate()) { - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { m_uiWellPathAzimuth.uiCapability()->setUiHidden(true); m_uiWellFractureAzimuthDiff.uiCapability()->setUiHidden(true); m_wellFractureAzimuthAngleWarning.uiCapability()->setUiHidden(true); } - else if (fractureTemplate()->orientationType == RimFractureTemplate::AZIMUTH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::AZIMUTH) { m_uiWellPathAzimuth.uiCapability()->setUiHidden(false); m_uiWellFractureAzimuthDiff.uiCapability()->setUiHidden(false); @@ -462,17 +462,17 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO } } - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { m_azimuth.uiCapability()->setUiReadOnly(true); } - else if (fractureTemplate()->orientationType == RimFractureTemplate::AZIMUTH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::AZIMUTH) { m_azimuth.uiCapability()->setUiReadOnly(false); } - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { m_perforationEfficiency.uiCapability()->setUiHidden(false); m_perforationLength.uiCapability()->setUiHidden(false); @@ -626,7 +626,7 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) m_stimPlanTimeIndexToPlot = stimPlanFracTemplate->activeTimeStepIndex(); } - if (fractureTemplate->orientationType == RimFractureTemplate::AZIMUTH) + if (fractureTemplate->orientationType() == RimFractureTemplate::AZIMUTH) { m_azimuth = fractureTemplate->azimuthAngle(); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 5226f8c525..86e17ddc55 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -65,11 +65,11 @@ RimFractureTemplate::RimFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); - CAF_PDM_InitField(&fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); - fractureTemplateUnit.uiCapability()->setUiReadOnly(true); + CAF_PDM_InitField(&m_name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); + CAF_PDM_InitField(&m_fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); + m_fractureTemplateUnit.uiCapability()->setUiReadOnly(true); - CAF_PDM_InitField(&orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); + CAF_PDM_InitField(&m_orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); CAF_PDM_InitField(&m_azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", ""); //Is this correct description? CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); @@ -93,12 +93,52 @@ RimFractureTemplate::~RimFractureTemplate() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setName(const QString& name) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setFractureTemplateUnit(RiaEclipseUnitTools::UnitSystemType unitSystem) +{ + m_fractureTemplateUnit = unitSystem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFractureTemplate::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate::FracOrientationEnum RimFractureTemplate::orientationType() const +{ + return m_orientationType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaEclipseUnitTools::UnitSystemType RimFractureTemplate::fractureTemplateUnit() const +{ + return m_fractureTemplateUnit(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() { - return &name; + return &m_name; } //-------------------------------------------------------------------------------------------------- @@ -106,7 +146,7 @@ caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &m_azimuthAngle || changedField == &orientationType) + if (changedField == &m_azimuthAngle || changedField == &m_orientationType) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -126,7 +166,7 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie fracture->m_azimuth = m_azimuthAngle; } - if (changedField == &orientationType) + if (changedField == &m_orientationType) { if (newValue == AZIMUTH) { @@ -186,28 +226,28 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); m_perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); } - if (orientationType == RimFractureTemplate::ALONG_WELL_PATH - || orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH + || m_orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { m_azimuthAngle.uiCapability()->setUiHidden(true); } - else if (orientationType == RimFractureTemplate::AZIMUTH) + else if (m_orientationType == RimFractureTemplate::AZIMUTH) { m_azimuthAngle.uiCapability()->setUiHidden(false); } - if (orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH) { m_perforationEfficiency.uiCapability()->setUiHidden(false); m_perforationLength.uiCapability()->setUiHidden(false); @@ -251,16 +291,16 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field //-------------------------------------------------------------------------------------------------- double RimFractureTemplate::wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) { - if (fractureUnit == fractureTemplateUnit()) + if (fractureUnit == m_fractureTemplateUnit()) { return m_wellDiameter; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { return RiaEclipseUnitTools::meterToInch(m_wellDiameter); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { return RiaEclipseUnitTools::inchToMeter(m_wellDiameter); @@ -274,16 +314,16 @@ double RimFractureTemplate::wellDiameterInFractureUnit(RiaEclipseUnitTools::Unit //-------------------------------------------------------------------------------------------------- double RimFractureTemplate::perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) { - if (fractureUnit == fractureTemplateUnit()) + if (fractureUnit == m_fractureTemplateUnit()) { return m_perforationLength; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { return RiaEclipseUnitTools::meterToFeet(m_perforationLength); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { return RiaEclipseUnitTools::feetToMeter(m_perforationLength); @@ -329,11 +369,11 @@ float RimFractureTemplate::skinFactor() const //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::setDefaultWellDiameterFromUnit() { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_wellDiameter = 8.5; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_wellDiameter = 0.216; } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index c4427d3c38..c5e167bb56 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -32,7 +32,6 @@ #include -class RigEclipseCaseData; class RigFractureGrid; class RimFractureContainment; class MinMaxAccumulator; @@ -64,23 +63,21 @@ class RimFractureTemplate : public caf::PdmObject RimFractureTemplate(); virtual ~RimFractureTemplate(); - caf::PdmField name; - caf::PdmField> orientationType; - caf::PdmField fractureTemplateUnit; - - FracConductivityEnum conductivityType() const; + QString name() const; + RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit() const; + FracOrientationEnum orientationType() const; float azimuthAngle() const; float skinFactor() const; - void setDefaultWellDiameterFromUnit(); double wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); + FracConductivityEnum conductivityType() const; double perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); virtual void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* triangleIndices, RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual const RigFractureGrid* fractureGrid() const = 0; + virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + virtual const RigFractureGrid* fractureGrid() const = 0; const RimFractureContainment* fractureContainment(); virtual void appendDataToResultStatistics(const QString& resultName, @@ -88,7 +85,11 @@ class RimFractureTemplate : public caf::PdmObject MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const = 0; - virtual std::vector> uiResultNamesWithUnit() const = 0; + virtual std::vector> uiResultNamesWithUnit() const = 0; + + void setName(const QString& name); + void setFractureTemplateUnit(RiaEclipseUnitTools::UnitSystemType unitSystem); + void setDefaultWellDiameterFromUnit(); protected: virtual caf::PdmFieldHandle* userDescriptionField() override; @@ -97,12 +98,14 @@ class RimFractureTemplate : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; protected: - caf::PdmField m_wellDiameter; - caf::PdmField m_perforationLength; - caf::PdmField m_perforationEfficiency; - caf::PdmField m_skinFactor; - caf::PdmField m_azimuthAngle; - - caf::PdmChildField m_fractureContainment; - caf::PdmField> m_conductivityType; + caf::PdmField m_name; + caf::PdmField m_fractureTemplateUnit; + caf::PdmField> m_orientationType; + caf::PdmField m_azimuthAngle; + caf::PdmField m_skinFactor; + caf::PdmField m_perforationLength; + caf::PdmField m_perforationEfficiency; + caf::PdmField m_wellDiameter; + caf::PdmField> m_conductivityType; + caf::PdmChildField m_fractureContainment; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index fe7740300a..a77806724d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -84,16 +84,16 @@ void RimSimWellFracture::updateAzimuthBasedOnWellAzimuthAngle() updateBranchGeometry(); if (!fractureTemplate()) return; - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { double simWellAzimuth = wellAzimuthAtFracturePosition(); - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH ) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH ) { m_azimuth = simWellAzimuth; } - else if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { if (simWellAzimuth + 90 < 360) m_azimuth = simWellAzimuth + 90; else m_azimuth = simWellAzimuth - 90; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index f8179b1704..81aa9b5fb0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -268,12 +268,12 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() if (m_stimPlanFractureDefinitionData.notNull()) { - fractureTemplateUnit = m_stimPlanFractureDefinitionData->unitSet(); + setFractureTemplateUnit(m_stimPlanFractureDefinitionData->unitSet()); m_readError = false; } else { - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_UNKNOWN; + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_UNKNOWN); m_readError = true; } @@ -367,11 +367,11 @@ void RimStimPlanFractureTemplate::setPerforationLength() } } - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC && m_perforationLength < 10) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC && m_perforationLength < 10) { m_perforationLength = 10; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD && m_perforationLength < RiaEclipseUnitTools::meterToFeet(10)) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD && m_perforationLength < RiaEclipseUnitTools::meterToFeet(10)) { m_perforationLength = std::round(RiaEclipseUnitTools::meterToFeet(10)); } @@ -571,7 +571,7 @@ void RimStimPlanFractureTemplate::updateFractureGrid() { m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_conductivityResultNameOnFile, m_activeTimeStepIndex, - fractureTemplateUnit, + fractureTemplateUnit(), m_wellPathDepthAtFracture); } } @@ -594,7 +594,7 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vectorcreateFractureTriangleGeometry(m_wellPathDepthAtFracture, neededUnit, - name, + name(), nodeCoords, triangleIndices); } @@ -617,7 +617,7 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEc m_activeTimeStepIndex, m_wellPathDepthAtFracture, neededUnit, - name); + name()); } return std::vector(); @@ -631,7 +631,7 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd { RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); - uiOrdering.add(&name); + uiOrdering.add(&m_name); caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("Input"); fileGroup->add(&m_stimPlanFileName); @@ -639,7 +639,7 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd fileGroup->add(&m_wellPathDepthAtFracture); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); - geometryGroup->add(&orientationType); + geometryGroup->add(&m_orientationType); geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index c01bcbe6e9..9284429f6a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -83,17 +83,17 @@ void RimWellPathFracture::updateAzimuthBasedOnWellAzimuthAngle() { if (!fractureTemplate()) return; - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { double wellPathAzimuth = wellAzimuthAtFracturePosition(); - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { m_azimuth = wellPathAzimuth; } - if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { if (wellPathAzimuth + 90 < 360) m_azimuth = wellPathAzimuth + 90; else m_azimuth = wellPathAzimuth - 90; From bd0d23520b6046218e0b0a9c30fe9ac25115c5b2 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 8 Feb 2018 16:43:12 +0100 Subject: [PATCH 0229/1027] #2344 Tensor Vectors: Vector visualization code --- .../RigFemPartResultsCollection.cpp | 111 ++++++ .../RigFemPartResultsCollection.h | 7 +- .../RivFemPartPartMgr.cpp | 8 + .../GeoMechVisualization/RivFemPartPartMgr.h | 2 + .../RivGeoMechPartMgr.cpp | 8 + .../GeoMechVisualization/RivGeoMechPartMgr.h | 1 + .../RivGeoMechVizLogic.cpp | 10 +- .../GeoMechVisualization/RivGeoMechVizLogic.h | 19 +- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivTensorResultPartMgr.cpp | 359 ++++++++++++++++++ .../RivTensorResultPartMgr.h | 67 ++++ .../ProjectDataModel/RimGeoMechView.cpp | 32 ++ .../ProjectDataModel/RimGeoMechView.h | 5 + .../ProjectDataModel/RimTensorResults.cpp | 139 ++++++- .../ProjectDataModel/RimTensorResults.h | 36 +- 15 files changed, 774 insertions(+), 32 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index fde4783e0d..d46f9f9b60 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -2031,6 +2031,62 @@ const std::vector& RigFemPartResultsCollection::resultValues(const RigFem return scalarResults->frameData(frameIndex); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFemPartResultsCollection::tensors(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex) +{ + CVF_ASSERT(resVarAddr.resultPosType == RIG_ELEMENT_NODAL || resVarAddr.resultPosType == RIG_INTEGRATION_POINT); + + std::vector outputTensors; + + RigFemResultAddress address11(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address22(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address33(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address12(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address13(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address23(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + + if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST") + { + address11.componentName = "S11"; + address22.componentName = "S22"; + address33.componentName = "S33"; + address12.componentName = "S12"; + address13.componentName = "S13"; + address23.componentName = "S23"; + } + else if (resVarAddr.fieldName == "E") + { + address11.componentName = "E11"; + address22.componentName = "E22"; + address33.componentName = "E33"; + address12.componentName = "E12"; + address13.componentName = "E13"; + address23.componentName = "E23"; + } + else + return outputTensors; + + const std::vector& v11 = resultValues(address11, partIndex, frameIndex); + const std::vector& v22 = resultValues(address22, partIndex, frameIndex); + const std::vector& v33 = resultValues(address33, partIndex, frameIndex); + const std::vector& v12 = resultValues(address12, partIndex, frameIndex); + const std::vector& v13 = resultValues(address13, partIndex, frameIndex); + const std::vector& v23 = resultValues(address23, partIndex, frameIndex); + + size_t valCount = v11.size(); + outputTensors.resize(valCount); + + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + caf::Ten3f tensor(v11[vIdx], v22[vIdx], v33[vIdx], v12[vIdx], v23[vIdx], v13[vIdx]); + outputTensors[vIdx] = tensor; + } + + return outputTensors; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2151,6 +2207,61 @@ const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(co return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax) +{ + double currentMin = HUGE_VAL; + double currentMax = -HUGE_VAL; + + double min; + double max; + + std::vector addresses; + + for (size_t i = 0; i < 6; ++i) + { + addresses.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "")); + } + + if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST") + { + addresses[0].componentName = "S11"; + addresses[1].componentName = "S22"; + addresses[2].componentName = "S33"; + addresses[3].componentName = "S12"; + addresses[4].componentName = "S13"; + addresses[5].componentName = "S23"; + } + else if (resVarAddr.fieldName == "E") + { + addresses[0].componentName = "E11"; + addresses[1].componentName = "E22"; + addresses[2].componentName = "E33"; + addresses[3].componentName = "E12"; + addresses[4].componentName = "E13"; + addresses[5].componentName = "E23"; + } + else return; + + for (auto address : addresses) + { + this->statistics(address)->minMaxCellScalarValues(frameIndex, min, max); + if (min < currentMin) + { + currentMin = min; + } + if (max > currentMax) + { + currentMax = max; + } + } + + *localMin = currentMin; + *localMax = currentMax; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 2aa854126b..2cf9f147b8 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -21,6 +21,8 @@ #include "RigFemResultAddress.h" +#include "cafTensor3.h" + #include "cvfCollection.h" #include "cvfObject.h" @@ -64,7 +66,8 @@ class RigFemPartResultsCollection: public cvf::Object bool assertResultsLoaded(const RigFemResultAddress& resVarAddr); void deleteResult(const RigFemResultAddress& resVarAddr); - const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); + const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); + std::vector tensors(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); int partCount() const; int frameCount(); @@ -82,6 +85,8 @@ class RigFemPartResultsCollection: public cvf::Object const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr); const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex); + void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); + private: RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, const RigFemResultAddress& resVarAddr); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index 262b7affc5..91849f76c8 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -182,6 +182,14 @@ void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model) if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const +{ + return &m_surfaceGenerator; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h index bdb1a7ad22..9d49715cc5 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h @@ -57,6 +57,8 @@ class RivFemPartPartMgr: public cvf::Object void updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors); void appendPartsToModel(cvf::ModelBasicList* model); + + const RivFemPartGeometryGenerator* surfaceGenerator() const; private: void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp index 25f3920c0a..3d5401af6f 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp @@ -139,3 +139,11 @@ void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, const } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::Collection RivGeoMechPartMgr::femPartMgrs() const +{ + return m_femPartPartMgrs; +} diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h index bfdcc552c0..ddaad50a0c 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h @@ -61,6 +61,7 @@ class RivGeoMechPartMgr: public cvf::Object void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector& partIndices); void appendGridPartsToModel(cvf::ModelBasicList* model); + const cvf::Collection femPartMgrs() const; private: cvf::Collection m_femPartPartMgrs; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index da657fbd3e..89d0a9771f 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -140,7 +140,7 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex) +std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex) const { std::vector visiblePartMgrs; if (m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden()) @@ -163,6 +163,14 @@ std::vector RivGeoMechVizLogic::keysToVisiblePartMg return visiblePartMgrs; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::ref RivGeoMechVizLogic::partMgrCache() const +{ + return m_partMgrCache; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h index 2d0dde9af8..189838fe69 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h @@ -43,17 +43,18 @@ class RivGeoMechVizLogic : public cvf::Object explicit RivGeoMechVizLogic(RimGeoMechView * geomView); virtual ~RivGeoMechVizLogic(); - void appendNoAnimPartsToModel(cvf::ModelBasicList* model); - void appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model); - void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors); - void updateStaticCellColors(int timeStepIndex); - void scheduleGeometryRegen(RivCellSetEnum geometryType); - void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex); + void appendNoAnimPartsToModel(cvf::ModelBasicList* model); + void appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model); + void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors); + void updateStaticCellColors(int timeStepIndex); + void scheduleGeometryRegen(RivCellSetEnum geometryType); + void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex); + std::vector keysToVisiblePartMgrs(int timeStepIndex) const; + const cvf::ref partMgrCache() const; private: - std::vector keysToVisiblePartMgrs(int timeStepIndex); - RivGeoMechPartMgr* getUpdatedPartMgr(RivGeoMechPartMgrCache::Key partMgrKey); - void scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType); + RivGeoMechPartMgr* getUpdatedPartMgr(RivGeoMechPartMgrCache::Key partMgrKey); + void scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType); cvf::ref m_partMgrCache; RimGeoMechView* m_geomechView; diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index ec2778bea2..a575ad5258 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -40,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RivPartPriority.h ${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h ${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h ${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.h +${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) @@ -80,6 +81,7 @@ ${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.cpp ${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.cpp +${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp new file mode 100644 index 0000000000..8914194f16 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -0,0 +1,359 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivTensorResultPartMgr.h" + +#include "RiaApplication.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" +#include "RimTensorResults.h" + +#include "RiuViewer.h" + +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" +#include "RigFemResultAddress.h" +#include "RigFemPartResultsCollection.h" +#include "RigFemTypes.h" +#include "RigGeoMechCaseData.h" + +#include "RivFemPartGeometryGenerator.h" +#include "RivGeoMechPartMgr.h" +#include "RivGeoMechPartMgrCache.h" +#include "RivGeoMechVizLogic.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" +#include "cafPdmFieldCvfColor.h" +#include "cafTensor3.h" + +#include "cvfArrowGenerator.h" +#include "cvfDrawableGeo.h" +#include "cvfDrawableVectors.h" +#include "cvfGeometryBuilderFaceList.h" +#include "cvfGeometryBuilderTriangles.h" +#include "cvfGeometryUtils.h" +#include "cvfModelBasicList.h" +#include "cvfObject.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfPart.h" +#include "cvfShaderProgram.h" +#include "cvfStructGridGeometryGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivTensorResultPartMgr::RivTensorResultPartMgr(RimGeoMechView* reservoirView) +{ + m_rimReservoirView = reservoirView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivTensorResultPartMgr::~RivTensorResultPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const +{ + if (m_rimReservoirView.isNull()) return; + if (!m_rimReservoirView->geoMechCase()) return; + if (!m_rimReservoirView->geoMechCase()->geoMechData()) return; + + if (!m_rimReservoirView->tensorResults()->showTensors()) return; + + RigFemPartCollection* femParts = m_rimReservoirView->geoMechCase()->geoMechData()->femParts(); + if (!femParts) return; + + std::vector tensorVisualizations; + + RigFemResultAddress address = m_rimReservoirView->tensorResults()->selectedTensorResult(); + if (!isTensorAddress(address)) return; + + RigFemPartResultsCollection* resultCollection = m_rimReservoirView->geoMechCase()->geoMechData()->femPartResults(); + if (!resultCollection) return; + + RimTensorResults::TensorColors tensorColor = m_rimReservoirView->tensorResults()->vectorColors(); + cvf::Color3f color1; + cvf::Color3f color2; + cvf::Color3f color3; + + if (tensorColor == RimTensorResults::WHITE_GRAY_BLACK) + { + color1 = cvf::Color3f(cvf::Color3::WHITE); + color2 = cvf::Color3f(cvf::Color3::GRAY); + color3 = cvf::Color3f(cvf::Color3::BLACK); + } + else if (tensorColor == RimTensorResults::MAGENTA_BROWN_BLACK) + { + color1 = cvf::Color3f(cvf::Color3::MAGENTA); + color2 = cvf::Color3f(cvf::Color3::BROWN); + color3 = cvf::Color3f(cvf::Color3::BLACK); + } + else + { + color1 = cvf::Color3f(cvf::Color3::BLACK); + color2 = cvf::Color3f(cvf::Color3::BLACK); + color3 = cvf::Color3f(cvf::Color3::BLACK); + } + + for (int partIdx = 0; partIdx < femParts->partCount(); partIdx++) + { + std::vector tensors = resultCollection->tensors(address, partIdx, (int)frameIndex); + + const RigFemPart* part = femParts->part(partIdx); + size_t elmCount = part->elementCount(); + std::vector elmTensors; + elmTensors.resize(elmCount); + + for (int elmIdx = 0; elmIdx < elmCount; elmIdx++) + { + if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) + { + caf::Ten3f tensorSumOfElmNodes = tensors[part->elementNodeResultIdx(elmIdx, 0)]; + for (int i = 1; i < 8; i++) + { + tensorSumOfElmNodes = tensorSumOfElmNodes + tensors[part->elementNodeResultIdx(elmIdx, i)]; + } + + elmTensors[elmIdx] = tensorSumOfElmNodes * (1.0 / 8.0); + } + } + + std::array, 3> elmPrincipals; + std::vector> elmPrincipalDirections; + + elmPrincipals[0].resize(elmCount); + elmPrincipals[1].resize(elmCount); + elmPrincipals[2].resize(elmCount); + + elmPrincipalDirections.resize(elmCount); + + for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) + { + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principalValues = elmTensors[nIdx].calculatePrincipals(principalDirs); + + elmPrincipals[0][nIdx] = principalValues[0]; + elmPrincipals[1][nIdx] = principalValues[1]; + elmPrincipals[2][nIdx] = principalValues[2]; + + elmPrincipalDirections[nIdx][0] = principalDirs[0]; + elmPrincipalDirections[nIdx][1] = principalDirs[1]; + elmPrincipalDirections[nIdx][2] = principalDirs[2]; + } + + RigFemPartNodes nodes = part->nodes(); + + double min; + double max; + resultCollection->minMaxScalarValuesOverAllTensorComponents(address, (int)frameIndex, &min, &max); + + if (max == 0) max = 1; + float arrowResultScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize() / cvf::Math::abs(max); + float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); + + std::vector partKeys = + m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs((int)frameIndex); + + cvf::ref partMgrCache = m_rimReservoirView->vizLogic()->partMgrCache(); + + for (const RivGeoMechPartMgrCache::Key& partKey : partKeys) + { + const RivGeoMechPartMgr* partMgr = partMgrCache->partMgr(partKey); + + for (auto mgr : partMgr->femPartMgrs()) + { + const RivFemPartGeometryGenerator* surfaceGenerator = mgr->surfaceGenerator(); + const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); + const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); + + for (int quadIdx = 0; quadIdx < quadVerticesToNodeIdxMapping.size(); quadIdx = quadIdx + 4) + { + cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx]) + + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx + 2]); + + cvf::Vec3d center3d(center / 2); + + cvf::Vec3d displayCoord = m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(center3d); + + size_t elmIdx = quadVerticesToElmIdx[quadIdx]; + + cvf::Vec3f result1; + cvf::Vec3f result2; + cvf::Vec3f result3; + + if (m_rimReservoirView->tensorResults()->scaleMethod() == RimTensorResults::RESULT) + { + result1.set(elmPrincipalDirections[elmIdx][0] * arrowResultScaling * elmPrincipals[0][elmIdx]); + result2.set(elmPrincipalDirections[elmIdx][1] * arrowResultScaling * elmPrincipals[1][elmIdx]); + result3.set(elmPrincipalDirections[elmIdx][2] * arrowResultScaling * elmPrincipals[2][elmIdx]); + } + else + { + result1.set(elmPrincipalDirections[elmIdx][0] * arrowConstantScaling); + result2.set(elmPrincipalDirections[elmIdx][1] * arrowConstantScaling); + result3.set(elmPrincipalDirections[elmIdx][2] * arrowConstantScaling); + } + + if (m_rimReservoirView->tensorResults()->showPrincipal1()) + { + if (cvf::Math::abs(elmPrincipals[0][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + { + bool isPressure = true; + if (elmPrincipals[0][elmIdx] < 0) + { + isPressure = false; + } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure)); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result1, color1, isPressure)); + } + } + if (m_rimReservoirView->tensorResults()->showPrincipal2()) + { + bool isPressure = true; + if (elmPrincipals[1][elmIdx] < 0) + { + isPressure = false; + } + if (cvf::Math::abs(elmPrincipals[1][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + { + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure)); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result2, color2, isPressure)); + } + } + if (m_rimReservoirView->tensorResults()->showPrincipal3()) + { + bool isPressure = true; + if (elmPrincipals[2][elmIdx] < 0) + { + isPressure = false; + } + if (cvf::Math::abs(elmPrincipals[2][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + { + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure)); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result3, color3, isPressure)); + } + } + } + } + } + } + + if (!tensorVisualizations.empty()) + { + cvf::ref partIdx = createPart(tensorVisualizations); + model->addPart(partIdx.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivTensorResultPartMgr::createPart(std::vector& tensorVisualizations) const +{ + cvf::ref vertices = new cvf::Vec3fArray; + cvf::ref vecRes = new cvf::Vec3fArray; + cvf::ref colors = new cvf::Color3fArray; + + size_t numVecs = tensorVisualizations.size(); + vertices->reserve(numVecs); + vecRes->reserve(numVecs); + colors->reserve(numVecs); + + for (TensorVisualization tensorVisualization : tensorVisualizations) + { + if (tensorVisualization.isPressure) + { + vertices->add(tensorVisualization.vertex - tensorVisualization.result); + } + else + { + vertices->add(tensorVisualization.vertex); + } + vecRes->add(tensorVisualization.result); + colors->add(tensorVisualization.color); + } + + cvf::ref vectorDrawable; + if (RiaApplication::instance()->useShaders()) + { + // NOTE: Drawable vectors must be rendered using shaders when the rest of the application is rendered using shaders + // Drawing vectors using fixed function when rest of the application uses shaders causes visual artifacts + vectorDrawable = new cvf::DrawableVectors("u_transformationMatrix", "u_color"); + } + else + { + vectorDrawable = new cvf::DrawableVectors(); + } + + // Create the arrow glyph for the vector drawer + cvf::GeometryBuilderTriangles arrowBuilder; + cvf::ArrowGenerator gen; + gen.setShaftRelativeRadius(0.020f); + gen.setHeadRelativeRadius(0.05f); + gen.setHeadRelativeLength(0.1f); + gen.setNumSlices(30); + gen.generate(&arrowBuilder); + + vectorDrawable->setVectors(vertices.p(), vecRes.p()); + vectorDrawable->setColors(colors.p()); + vectorDrawable->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); + + cvf::ref part = new cvf::Part; + part->setDrawable(vectorDrawable.p()); + + cvf::ref eff = new cvf::Effect; + if (RiaApplication::instance()->useShaders()) + { + if (m_rimReservoirView->viewer()) + { + cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); + cvf::OpenGLResourceManager* resourceManager = oglContext->resourceManager(); + cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram(oglContext.p()); + + eff->setShaderProgram(vectorProgram.p()); + } + } + + part->setEffect(eff.p()); + + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isTensorAddress(RigFemResultAddress address) +{ + if (!(address.resultPosType == RIG_ELEMENT_NODAL || address.resultPosType == RIG_INTEGRATION_POINT)) + { + return false; + } + if (!(address.fieldName == "SE" + || address.fieldName == "ST" + || address.fieldName == "E")) + { + return false; + } + + return true; +} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h new file mode 100644 index 0000000000..e6a1a8952a --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfColor3.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cafPdmPointer.h" + +#include +#include + +namespace cvf +{ +class Part; +class ModelBasicList; +} + +class RigFemResultAddress; +class RimGeoMechView; + +class RivTensorResultPartMgr : public cvf::Object +{ +public: + RivTensorResultPartMgr(RimGeoMechView* reservoirView); + ~RivTensorResultPartMgr(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const; + +private: + + struct TensorVisualization + { + TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Color3f color, bool isPressure) + : vertex(vertex), result(result), color(color), isPressure(isPressure) {}; + + cvf::Vec3f vertex; + cvf::Vec3f result; + cvf::Color3f color; + bool isPressure; + }; +private: + cvf::ref createPart(std::vector& tensorVisualizations) const; + + static bool isTensorAddress(RigFemResultAddress address); + +private: + caf::PdmPointer m_rimReservoirView; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index af1d2a56d1..dd0c40e46f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -48,6 +48,7 @@ #include "RivGeoMechPartMgrCache.h" #include "RivGeoMechVizLogic.h" #include "RivSingleCellPartGenerator.h" +#include "RivTensorResultPartMgr.h" #include "cafCadNavigation.h" #include "cafCeetronPlusNavigation.h" @@ -93,6 +94,7 @@ RimGeoMechView::RimGeoMechView(void) m_scaleTransform = new cvf::Transform(); m_vizLogic = new RivGeoMechVizLogic(this); + m_tensorPartMgr = new RivTensorResultPartMgr(this); } //-------------------------------------------------------------------------------------------------- @@ -212,6 +214,7 @@ void RimGeoMechView::createDisplayModel() cvf::ref mainSceneGridVizModel = new cvf::ModelBasicList; mainSceneGridVizModel->setName("GridModel"); m_vizLogic->appendNoAnimPartsToModel(mainSceneGridVizModel.p()); + mainSceneGridVizModel->updateBoundingBoxesRecursive(); mainScene->addModel(mainSceneGridVizModel.p()); @@ -287,6 +290,19 @@ void RimGeoMechView::updateCurrentTimeStep() frameScene->addModel(wellPathModelBasicList.p()); } + + { + // Tensors + cvf::String name = "Tensor"; + this->removeModelByName(frameScene, name); + + cvf::ref frameParts = new cvf::ModelBasicList; + frameParts->setName(name); + m_tensorPartMgr->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep); + frameParts->updateBoundingBoxesRecursive(); + + frameScene->addModel(frameParts.p()); + } } } @@ -428,6 +444,22 @@ void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, in legendConfig->setTitle(legendTitle); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::ref RimGeoMechView::vizLogic() const +{ + return m_vizLogic; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimTensorResults* RimGeoMechView::tensorResults() const +{ + return m_tensorResults; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 33d2bb5115..429672243b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -43,6 +43,7 @@ class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; class RimLegendConfig; +class RivTensorResultPartMgr; namespace cvf { class CellRangeFilter; @@ -88,6 +89,9 @@ class RimGeoMechView : public RimGridView void updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + const cvf::ref vizLogic() const; + const RimTensorResults* tensorResults() const; + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; @@ -119,5 +123,6 @@ class RimGeoMechView : public RimGridView cvf::ref m_vizLogic; cvf::ref m_scaleTransform; + cvf::ref m_tensorPartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index c3d14da831..cc8baaeaea 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -18,13 +18,40 @@ #include "RimTensorResults.h" +#include "RigFemResultAddress.h" #include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "cafAppEnum.h" #include "cafPdmUiListEditor.h" CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults"); + +namespace caf +{ + template<> + void AppEnum< RimTensorResults::TensorColors >::setUp() + { + addItem(RimTensorResults::WHITE_GRAY_BLACK , "WHITE_GRAY_BLACK", "White, Gray, Black"); + addItem(RimTensorResults::MAGENTA_BROWN_BLACK, "MAGENTA_BROWN_BLACK", "Magenta, Brown, Black"); + addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors"); + + setDefault(RimTensorResults::WHITE_GRAY_BLACK); + } + + template<> + void AppEnum< RimTensorResults::ScaleMethod >::setUp() + { + addItem(RimTensorResults::RESULT, "RESULT", "Result"); + addItem(RimTensorResults::CONSTANT, "CONSTANT", "Constant"); + + setDefault(RimTensorResults::RESULT); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -52,16 +79,17 @@ RimTensorResults::RimTensorResults() CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", ""); CAF_PDM_InitField(&m_principal3, "Principal3", true, "Principal 3", "", "", ""); - CAF_PDM_InitField(&m_threshold, "Threshold", 0.0, "Threshold", "", "", ""); + CAF_PDM_InitField(&m_threshold, "Threshold", 0.0f, "Threshold", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", ""); - CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0, "Size Scale", "", "", ""); + CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", ""); m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - m_resultPositionTypeUiField = RIG_ELEMENT_NODAL; + m_resultPositionType = RIG_ELEMENT_NODAL; + m_resultPositionTypeUiField = m_resultPositionType; } //-------------------------------------------------------------------------------------------------- @@ -72,6 +100,78 @@ RimTensorResults::~RimTensorResults() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemResultAddress RimTensorResults::selectedTensorResult() const +{ + return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showTensors() const +{ + return m_showTensors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal1() const +{ + return m_principal1(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal2() const +{ + return m_principal2(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal3() const +{ + return m_principal3(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimTensorResults::threshold() const +{ + return m_threshold(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimTensorResults::sizeScale() const +{ + return m_sizeScale(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::TensorColors RimTensorResults::vectorColors() const +{ + return m_vectorColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const +{ + return m_scaleMethod(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -106,7 +206,12 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, if (changedField == &m_resultFieldNameUiField) { m_resultPositionType = m_resultPositionTypeUiField; + m_resultFieldName = m_resultFieldNameUiField; } + + RimGeoMechView* view; + firstAncestorOrThisOfType(view); + view->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -145,17 +250,6 @@ QList RimTensorResults::calculateValueOptions(const caf: } } - else if (fieldNeedingOptions == &m_vectorColor) - { - options.push_back(caf::PdmOptionItemInfo("White, Gray, Black", nullptr)); - options.push_back(caf::PdmOptionItemInfo("Magenta, Brown, Black", nullptr)); - options.push_back(caf::PdmOptionItemInfo("Result Colors", nullptr)); - } - else if (fieldNeedingOptions == &m_scaleMethod) - { - options.push_back(caf::PdmOptionItemInfo("Result", nullptr)); - options.push_back(caf::PdmOptionItemInfo("Constant", nullptr)); - } return options; } @@ -191,4 +285,19 @@ void RimTensorResults::initAfterRead() { m_resultPositionTypeUiField = m_resultPositionType; m_resultFieldNameUiField = m_resultFieldName(); -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_resultFieldNameUiField) + { + caf::PdmUiListEditorAttribute* listEditAttr = dynamic_cast(attribute); + if (listEditAttr) + { + listEditAttr->m_heightHint = 50; + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index afb13c228d..fa3f59514f 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -27,6 +27,7 @@ #include +class RigFemResultAddress; //================================================================================================== /// @@ -36,10 +37,34 @@ class RimTensorResults : public caf::PdmObject { CAF_PDM_HEADER_INIT; +public: + enum TensorColors + { + WHITE_GRAY_BLACK, + MAGENTA_BROWN_BLACK, + RESULT_COLORS + }; + + enum ScaleMethod + { + RESULT, + CONSTANT + }; + public: RimTensorResults(); virtual ~RimTensorResults(); + RigFemResultAddress selectedTensorResult() const; + bool showTensors() const; + bool showPrincipal1() const; + bool showPrincipal2() const; + bool showPrincipal3() const; + float threshold() const; + float sizeScale() const; + TensorColors vectorColors() const; + ScaleMethod scaleMethod() const; + private: std::vector getResultMetaDataForUIFieldSetting(); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -47,9 +72,9 @@ class RimTensorResults : public caf::PdmObject virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; private: - caf::PdmField m_showTensors; caf::PdmField> m_resultPositionType; @@ -62,11 +87,10 @@ class RimTensorResults : public caf::PdmObject caf::PdmField m_principal2; caf::PdmField m_principal3; - caf::PdmField m_threshold; - - caf::PdmField m_vectorColor; + caf::PdmField m_threshold; - caf::PdmField m_scaleMethod; - caf::PdmField m_sizeScale; + caf::PdmField> m_vectorColor; + caf::PdmField> m_scaleMethod; + caf::PdmField m_sizeScale; }; From b068296afd10574150b6400a0570dea20e9c1d1a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Feb 2018 07:26:48 +0100 Subject: [PATCH 0230/1027] #2455 Non-Darcy Flow: Add fields to fracture template --- .../RimEllipseFractureTemplate.cpp | 6 +- .../Completions/RimFractureTemplate.cpp | 74 +++++++++++++++---- .../Completions/RimFractureTemplate.h | 10 +++ .../RimStimPlanFractureTemplate.cpp | 4 +- 4 files changed, 72 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 2472a0a7ea..0dbb68d214 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -350,7 +350,6 @@ std::vector> RimEllipseFractureTemplate::uiResultNam //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { @@ -367,7 +366,6 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); } - if (conductivityType() == FINITE_CONDUCTIVITY) { m_permeability.uiCapability()->setUiHidden(false); @@ -378,7 +376,6 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm m_permeability.uiCapability()->setUiHidden(true); m_width.uiCapability()->setUiHidden(true); } - uiOrdering.add(&m_name); @@ -400,7 +397,6 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); - uiOrdering.add(&m_fractureTemplateUnit); - uiOrdering.skipRemainingFields(true); + RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 86e17ddc55..bc907c7146 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -55,6 +55,9 @@ namespace caf } +// TODO Move to cafPdmObject.h +#define CAF_PDM_InitField_Basic(field, keyword, default, uiName) CAF_PDM_InitField(field, keyword, default, uiName, "", "", "") + CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimFractureTemplate, "RimFractureTemplate"); @@ -84,6 +87,14 @@ RimFractureTemplate::RimFractureTemplate() m_fractureContainment = new RimFractureContainment(); m_fractureContainment.uiCapability()->setUiTreeHidden(true); m_fractureContainment.uiCapability()->setUiTreeChildrenHidden(true); + + // Non-Darcy Flow options + CAF_PDM_InitField_Basic(&m_useNonDarcyFlow, "UseNonDarcyFlow", false, "Use Non-Darcy Flow"); + CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.0, "Fracture Width"); + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.0, "Inertial Coefficient (beta)"); + CAF_PDM_InitField_Basic(&m_effectivePermeability, "EffectivePermeability",0.0, "Effective Permeability"); + CAF_PDM_InitField_Basic(&m_specificGasGravity, "SpecificGasGravity", 0.0, "Specific Gas Gravity"); + CAF_PDM_InitField_Basic(&m_gasViscosity, "GasViscosity", 0.0, "Gas Viscosity"); } //-------------------------------------------------------------------------------------------------- @@ -225,7 +236,42 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + prepareFieldsForUiDisplay(); + + auto group = uiOrdering.addNewGroup("Non-Darcy Flow"); + group->setCollapsedByDefault(true); + group->add(&m_useNonDarcyFlow); + group->add(&m_fractureWidth); + group->add(&m_inertialCoefficient); + group->add(&m_effectivePermeability); + group->add(&m_specificGasGravity); + group->add(&m_gasViscosity); + + uiOrdering.add(&m_fractureTemplateUnit); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_perforationEfficiency) + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->m_minimum = 0; + myAttr->m_maximum = 1.0; + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::prepareFieldsForUiDisplay() +{ if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); @@ -266,26 +312,24 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { m_wellDiameter.uiCapability()->setUiHidden(true); } - -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) -{ - if (field == &m_perforationEfficiency) + // Non Darcy Flow + m_fractureWidth.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_inertialCoefficient.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_effectivePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_specificGasGravity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_gasViscosity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + + if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH) { - auto myAttr = dynamic_cast(attribute); - if (myAttr) - { - myAttr->m_minimum = 0; - myAttr->m_maximum = 1.0; - } + m_fractureWidth.uiCapability()->setUiHidden(true); + } + else + { + m_fractureWidth.uiCapability()->setUiHidden(false); } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index c5e167bb56..a12b897f8b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -97,6 +97,9 @@ class RimFractureTemplate : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; +private: + void prepareFieldsForUiDisplay(); + protected: caf::PdmField m_name; caf::PdmField m_fractureTemplateUnit; @@ -108,4 +111,11 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmField m_wellDiameter; caf::PdmField> m_conductivityType; caf::PdmChildField m_fractureContainment; + + caf::PdmField m_useNonDarcyFlow; + caf::PdmField m_fractureWidth; + caf::PdmField m_inertialCoefficient; + caf::PdmField m_effectivePermeability; + caf::PdmField m_specificGasGravity; + caf::PdmField m_gasViscosity; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 81aa9b5fb0..cea4b35538 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -629,8 +629,6 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEc //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); - uiOrdering.add(&m_name); caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("Input"); @@ -653,6 +651,8 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd propertyGroup->add(&m_perforationLength); propertyGroup->add(&m_perforationEfficiency); propertyGroup->add(&m_wellDiameter); + + RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); } //-------------------------------------------------------------------------------------------------- From f747c22fd31609f5c285f3aa46c868029b10118e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Feb 2018 10:10:09 +0100 Subject: [PATCH 0231/1027] #2344 Tensor vectors: Avoid creating vectors of Infinity result values --- .../RivTensorResultPartMgr.cpp | 58 ++++++++++++++----- .../RivTensorResultPartMgr.h | 1 + 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 8914194f16..679af8ba4d 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -214,41 +214,44 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi result3.set(elmPrincipalDirections[elmIdx][2] * arrowConstantScaling); } - if (m_rimReservoirView->tensorResults()->showPrincipal1()) + if (isValid(result1) && m_rimReservoirView->tensorResults()->showPrincipal1()) { - if (cvf::Math::abs(elmPrincipals[0][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + if (result1.length() > m_rimReservoirView->tensorResults()->threshold()) { bool isPressure = true; if (elmPrincipals[0][elmIdx] < 0) { isPressure = false; } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure)); tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result1, color1, isPressure)); } } - if (m_rimReservoirView->tensorResults()->showPrincipal2()) + if (isValid(result2) && m_rimReservoirView->tensorResults()->showPrincipal2()) { - bool isPressure = true; - if (elmPrincipals[1][elmIdx] < 0) - { - isPressure = false; - } - if (cvf::Math::abs(elmPrincipals[1][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + if (result2.length() > m_rimReservoirView->tensorResults()->threshold()) { + bool isPressure = true; + if (elmPrincipals[1][elmIdx] < 0) + { + isPressure = false; + } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure)); tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result2, color2, isPressure)); } } - if (m_rimReservoirView->tensorResults()->showPrincipal3()) + if (isValid(result3) && m_rimReservoirView->tensorResults()->showPrincipal3()) { - bool isPressure = true; - if (elmPrincipals[2][elmIdx] < 0) - { - isPressure = false; - } - if (cvf::Math::abs(elmPrincipals[2][elmIdx]) > m_rimReservoirView->tensorResults()->threshold()) + if (result3.length() > m_rimReservoirView->tensorResults()->threshold()) { + bool isPressure = true; + if (elmPrincipals[2][elmIdx] < 0) + { + isPressure = false; + } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure)); tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result3, color3, isPressure)); } @@ -357,3 +360,26 @@ bool RivTensorResultPartMgr::isTensorAddress(RigFemResultAddress address) return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isValid(cvf::Vec3f resultVector) +{ + if ( resultVector.x() == HUGE_VAL + || resultVector.y() == HUGE_VAL + || resultVector.z() == HUGE_VAL + || resultVector.x() == -HUGE_VAL + || resultVector.y() == -HUGE_VAL + || resultVector.z() == -HUGE_VAL) + { + return false; + } + + if (resultVector.length() == 0) + { + return false; + } + + return true; +} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index e6a1a8952a..c20782a7ec 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -61,6 +61,7 @@ class RivTensorResultPartMgr : public cvf::Object cvf::ref createPart(std::vector& tensorVisualizations) const; static bool isTensorAddress(RigFemResultAddress address); + static bool isValid(cvf::Vec3f resultVector); private: caf::PdmPointer m_rimReservoirView; From c3ea8f3415493dd63a682981684407b8d3fc7df7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Feb 2018 11:33:27 +0100 Subject: [PATCH 0232/1027] 2344 Tensor vectors: Code cleanup --- .../RivTensorResultPartMgr.cpp | 166 ++++++++++-------- .../RivTensorResultPartMgr.h | 5 + 2 files changed, 100 insertions(+), 71 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 679af8ba4d..91a6fc8e5d 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -56,6 +56,8 @@ #include "cvfShaderProgram.h" #include "cvfStructGridGeometryGenerator.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -85,36 +87,17 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi std::vector tensorVisualizations; + RimTensorResults::TensorColors tensorColor = m_rimReservoirView->tensorResults()->vectorColors(); + cvf::Color3f color1, color2, color3; + + assignColorVectors(tensorColor, color1, color2, color3); + RigFemResultAddress address = m_rimReservoirView->tensorResults()->selectedTensorResult(); if (!isTensorAddress(address)) return; RigFemPartResultsCollection* resultCollection = m_rimReservoirView->geoMechCase()->geoMechData()->femPartResults(); if (!resultCollection) return; - RimTensorResults::TensorColors tensorColor = m_rimReservoirView->tensorResults()->vectorColors(); - cvf::Color3f color1; - cvf::Color3f color2; - cvf::Color3f color3; - - if (tensorColor == RimTensorResults::WHITE_GRAY_BLACK) - { - color1 = cvf::Color3f(cvf::Color3::WHITE); - color2 = cvf::Color3f(cvf::Color3::GRAY); - color3 = cvf::Color3f(cvf::Color3::BLACK); - } - else if (tensorColor == RimTensorResults::MAGENTA_BROWN_BLACK) - { - color1 = cvf::Color3f(cvf::Color3::MAGENTA); - color2 = cvf::Color3f(cvf::Color3::BROWN); - color3 = cvf::Color3f(cvf::Color3::BLACK); - } - else - { - color1 = cvf::Color3f(cvf::Color3::BLACK); - color2 = cvf::Color3f(cvf::Color3::BLACK); - color3 = cvf::Color3f(cvf::Color3::BLACK); - } - for (int partIdx = 0; partIdx < femParts->partCount(); partIdx++) { std::vector tensors = resultCollection->tensors(address, partIdx, (int)frameIndex); @@ -123,7 +106,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi size_t elmCount = part->elementCount(); std::vector elmTensors; elmTensors.resize(elmCount); - + for (int elmIdx = 0; elmIdx < elmCount; elmIdx++) { if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) @@ -161,18 +144,17 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi elmPrincipalDirections[nIdx][2] = principalDirs[2]; } + std::vector partKeys = + m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs((int)frameIndex); + RigFemPartNodes nodes = part->nodes(); - double min; - double max; + double min, max; resultCollection->minMaxScalarValuesOverAllTensorComponents(address, (int)frameIndex, &min, &max); if (max == 0) max = 1; - float arrowResultScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize() / cvf::Math::abs(max); float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); - - std::vector partKeys = - m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs((int)frameIndex); + float arrowResultScaling = arrowConstantScaling / cvf::Math::abs(max); cvf::ref partMgrCache = m_rimReservoirView->vizLogic()->partMgrCache(); @@ -197,9 +179,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi size_t elmIdx = quadVerticesToElmIdx[quadIdx]; - cvf::Vec3f result1; - cvf::Vec3f result2; - cvf::Vec3f result3; + cvf::Vec3f result1, result2, result3; if (m_rimReservoirView->tensorResults()->scaleMethod() == RimTensorResults::RESULT) { @@ -214,47 +194,21 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi result3.set(elmPrincipalDirections[elmIdx][2] * arrowConstantScaling); } - if (isValid(result1) && m_rimReservoirView->tensorResults()->showPrincipal1()) + if (isDrawable(result1, m_rimReservoirView->tensorResults()->showPrincipal1())) { - if (result1.length() > m_rimReservoirView->tensorResults()->threshold()) - { - bool isPressure = true; - if (elmPrincipals[0][elmIdx] < 0) - { - isPressure = false; - } - - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure)); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result1, color1, isPressure)); - } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure(elmPrincipals[0][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result1, color1, isPressure(elmPrincipals[0][elmIdx]))); } - if (isValid(result2) && m_rimReservoirView->tensorResults()->showPrincipal2()) + + if (isDrawable(result2, m_rimReservoirView->tensorResults()->showPrincipal2())) { - if (result2.length() > m_rimReservoirView->tensorResults()->threshold()) - { - bool isPressure = true; - if (elmPrincipals[1][elmIdx] < 0) - { - isPressure = false; - } - - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure)); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result2, color2, isPressure)); - } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure(elmPrincipals[1][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result2, color2, isPressure(elmPrincipals[1][elmIdx]))); } - if (isValid(result3) && m_rimReservoirView->tensorResults()->showPrincipal3()) + if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) { - if (result3.length() > m_rimReservoirView->tensorResults()->threshold()) - { - bool isPressure = true; - if (elmPrincipals[2][elmIdx] < 0) - { - isPressure = false; - } - - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure)); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result3, color3, isPressure)); - } + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure(elmPrincipals[2][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result3, color3, isPressure(elmPrincipals[2][elmIdx]))); } } } @@ -342,6 +296,31 @@ cvf::ref RivTensorResultPartMgr::createPart(std::vectortensorResults()->threshold()) { return false; } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index c20782a7ec..94b0a1303b 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -25,6 +25,8 @@ #include "cafPdmPointer.h" +#include "RimTensorResults.h" + #include #include @@ -60,8 +62,11 @@ class RivTensorResultPartMgr : public cvf::Object private: cvf::ref createPart(std::vector& tensorVisualizations) const; + static void assignColorVectors(RimTensorResults::TensorColors tensorColor, cvf::Color3f color1, cvf::Color3f color2, cvf::Color3f color3); static bool isTensorAddress(RigFemResultAddress address); static bool isValid(cvf::Vec3f resultVector); + static bool isPressure(float principalValue); + bool isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const; private: caf::PdmPointer m_rimReservoirView; From 911571e2674ae1e4d6014f32a83a9b31d3274a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Feb 2018 19:42:34 +0100 Subject: [PATCH 0233/1027] #2337 Window Edge axis overlay item working. --- ApplicationCode/CMakeLists.txt | 1 + .../CMakeLists_files.cmake | 24 + .../RivWindowEdgeAxesOverlayItem.cpp | 480 ++++++++++++++++++ .../RivWindowEdgeAxesOverlayItem.h | 130 +++++ .../Rim2dIntersectionView.cpp | 1 + ApplicationCode/UserInterface/RiuViewer.cpp | 19 +- ApplicationCode/UserInterface/RiuViewer.h | 3 + 7 files changed, 657 insertions(+), 1 deletion(-) create mode 100644 ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake create mode 100644 ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp create mode 100644 ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 8f942d5a1f..228bdf6d06 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -111,6 +111,7 @@ list( APPEND REFERENCED_CMAKE_FILES ModelVisualization/CMakeLists_files.cmake ModelVisualization/GridBox/CMakeLists_files.cmake ModelVisualization/Intersections/CMakeLists_files.cmake + ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake UserInterface/CMakeLists_files.cmake diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake new file mode 100644 index 0000000000..8b861106db --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake @@ -0,0 +1,24 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RivWindowEdgeAxesOverlayItem.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RivWindowEdgeAxesOverlayItem.cpp + +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ModelVisualization\\WindowEdgeAxesOverlayItem" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp new file mode 100644 index 0000000000..aecfa6bdcd --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -0,0 +1,480 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RivWindowEdgeAxesOverlayItem.h" + +#include "cvfBase.h" +#include "cvfOpenGL.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfGeometryBuilderDrawableGeo.h" +#include "cvfGeometryUtils.h" +#include "cvfViewport.h" +#include "cvfCamera.h" +#include "cvfTextDrawer.h" +#include "cvfFont.h" +#include "cvfShaderProgram.h" +#include "cvfShaderProgramGenerator.h" +#include "cvfShaderSourceProvider.h" +#include "cvfShaderSourceRepository.h" +#include "cvfUniform.h" +#include "cvfMatrixState.h" +#include "cvfBufferObjectManaged.h" +#include "cvfGlyph.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" + +#ifndef CVF_OPENGL_ES +#include "cvfRenderState_FF.h" +#endif + +#include "cvfScalarMapper.h" +#include "cvfRenderStateBlending.h" +#include "cvfScalarMapperDiscreteLinear.h" + +using namespace cvf; + + +//================================================================================================== +/// +/// \class cvf::OverlayColorLegend +/// \ingroup Render +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +RivWindowEdgeAxesOverlayItem::RivWindowEdgeAxesOverlayItem(Font* font) +: m_windowSize(600, 600), + m_textColor(Color3::BLACK), + m_lineColor(Color3::BLACK), + m_lineWidth(1), + m_font(font), + m_isSwitchingYAxisValueSign(true) +{ + CVF_ASSERT(font); + CVF_ASSERT(!font->isEmpty()); + + m_tickValues.reserve(3); + m_tickValues.add(0.0); + m_tickValues.add(0.5); + m_tickValues.add(1.0); + + setLayoutFixedPosition({0,0}); + updateGeomerySizes(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWindowEdgeAxesOverlayItem::~RivWindowEdgeAxesOverlayItem() +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setDisplayCoordTransform(const caf::DisplayCoordTransform* displayCoordTransform) +{ + m_dispalyCoordsTransform = displayCoordTransform; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::updateGeomerySizes() +{ + String str = String::number(99999.0); + m_textSize = m_font->textExtent(str); + m_pixelSpacing = 2.0f; + m_tickLineLength = m_textSize.y() *0.3f; + m_frameHeight = m_pixelSpacing + m_textSize.y() + m_pixelSpacing + m_tickLineLength + m_lineWidth; + m_frameWidth = m_pixelSpacing + m_textSize.x() + m_pixelSpacing + m_tickLineLength + m_lineWidth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::updateFromCamera(const Camera* camera) +{ + m_windowSize = Vec2ui( camera->viewport()->width(), camera->viewport()->height()); + Vec3d windowOrigoInDomain; + Vec3d windowMaxInDomain; + camera->unproject(Vec3d(0,0,0), &windowOrigoInDomain ); + camera->unproject(Vec3d(m_windowSize.x(),m_windowSize.y(),0), &windowMaxInDomain ); + + if (m_dispalyCoordsTransform.notNull()) + { + windowOrigoInDomain = m_dispalyCoordsTransform->transformToDomainCoord(windowOrigoInDomain); + windowMaxInDomain = m_dispalyCoordsTransform->transformToDomainCoord(windowMaxInDomain); + } + + double domainMinX = windowOrigoInDomain.x(); + double domainMaxX = windowMaxInDomain.x(); + + double domainMinY = windowOrigoInDomain.z(); + double domainMaxY = windowMaxInDomain.z(); + + int xTickMaxCount = m_windowSize.x()/(2*m_textSize.x()); + int yTickMaxCount = m_windowSize.y()/(2*m_textSize.x()); + + m_domainCoordsXValues.clear(); + cvf::ScalarMapperDiscreteLinear linDiscreteScalarMapper; + linDiscreteScalarMapper.setRange(domainMinX, domainMaxX); + linDiscreteScalarMapper.setLevelCount(xTickMaxCount, true); + linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues); + + m_domainCoordsYValues.clear(); + linDiscreteScalarMapper.setRange(domainMinY, domainMaxY); + linDiscreteScalarMapper.setLevelCount(yTickMaxCount, true); + linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues); + + m_windowTickXValues.clear(); + Vec3d windowPoint; + double domainYValue0 = m_domainCoordsYValues[0]; + for (double domainX : m_domainCoordsXValues) + { + Vec3d displayDomainTick(domainX, 0, domainYValue0); + if ( m_dispalyCoordsTransform.notNull() ) + { + displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); + } + camera->project(displayDomainTick, &windowPoint); + m_windowTickXValues.push_back(windowPoint.x()); + } + + m_windowTickYValues.clear(); + double domainXValue0 = m_domainCoordsXValues[0]; + for (double domainY : m_domainCoordsYValues) + { + Vec3d displayDomainTick(domainXValue0, 0, domainY); + if ( m_dispalyCoordsTransform.notNull() ) + { + displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); + } + camera->project(displayDomainTick, &windowPoint); + m_windowTickYValues.push_back(windowPoint.y()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui RivWindowEdgeAxesOverlayItem::sizeHint() +{ + return m_windowSize; +} + +//-------------------------------------------------------------------------------------------------- +/// Set color of the text and lines to be rendered +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setTextColor(const Color3f& color) +{ + m_textColor = color; +} + + +//-------------------------------------------------------------------------------------------------- +/// Returns the color of the text and lines +//-------------------------------------------------------------------------------------------------- +const Color3f& RivWindowEdgeAxesOverlayItem::textColor() const +{ + return m_textColor; +} + +//-------------------------------------------------------------------------------------------------- +/// Hardware rendering using shader programs +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + render(oglContext, position, size, false); +} + + +//-------------------------------------------------------------------------------------------------- +/// Software rendering using software +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + render(oglContext, position, size, true); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivWindowEdgeAxesOverlayItem::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) +{ + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set up camera/viewport and render +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +{ + if (size.x() <= 0 || size.y() <= 0) + { + return; + } + + Camera camera; + camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setProjectionAsPixelExact2D(); + camera.setViewMatrix(Mat4d::IDENTITY); + camera.applyOpenGL(); + camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); + + TextDrawer textDrawer(m_font.p()); + addTextToTextDrawer(&textDrawer); + + renderLegendImmediateMode(oglContext); + + if (software) + { + textDrawer.renderSoftware(oglContext, camera); + } + else + { + textDrawer.render(oglContext, camera); + } + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) +{ + textDrawer->setVerticalAlignment(TextDrawer::CENTER); + textDrawer->setTextColor(m_textColor); + + // Bottom X - axis text + { + const float textY = m_pixelSpacing + m_textSize.y()*0.5f; + size_t numTicks = m_domainCoordsXValues.size(); + size_t i; + for ( i = 0; i < numTicks; i++ ) + { + float textX = static_cast(m_windowTickXValues[i]); + + double tickValue = m_domainCoordsXValues[i]; + String valueString; + + valueString = String::number(tickValue); + auto labelSize = m_font->textExtent(valueString); + + Vec2f pos(textX - labelSize.x()*0.5f, textY); + textDrawer->addText(valueString, pos); + } + } + + // Right Y - axis texts + { + const float textX = m_windowSize.x() - m_pixelSpacing - m_textSize.x(); + + size_t numTicks = m_domainCoordsYValues.size(); + size_t i; + for ( i = 0; i < numTicks; i++ ) + { + float textY = static_cast(m_windowTickYValues[i]); + + double tickValue = m_isSwitchingYAxisValueSign ? -m_domainCoordsYValues[i]: m_domainCoordsYValues[i]; + String valueString; + + valueString = String::number(tickValue); + auto labelSize = m_font->textExtent(valueString); + + Vec2f pos(textX, textY); + textDrawer->addText(valueString, pos); + } + } + + // Left Y - axis texts + { + const float textX = m_frameWidth - m_tickLineLength - m_pixelSpacing; + + size_t numTicks = m_domainCoordsYValues.size(); + size_t i; + for ( i = 0; i < numTicks; i++ ) + { + float textY = static_cast(m_windowTickYValues[i]); + + double tickValue = m_isSwitchingYAxisValueSign ? -m_domainCoordsYValues[i]: m_domainCoordsYValues[i]; + String valueString; + + valueString = String::number(tickValue); + auto labelSize = m_font->textExtent(valueString); + + Vec2f pos(textX - labelSize.x(), textY); + textDrawer->addText(valueString, pos); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using immediate mode OpenGL +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderLegendImmediateMode(OpenGLContext* oglContext) +{ + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Frame vertices + + Vec3f v0(Vec3f::ZERO); + Vec3f v1(Vec3f::ZERO); + Vec3f v2(Vec3f::ZERO); + Vec3f v3(Vec3f::ZERO); + Vec3f v4(Vec3f::ZERO); + Vec3f v5(Vec3f::ZERO); + Vec3f v6(Vec3f::ZERO); + Vec3f v7(Vec3f::ZERO); + + v1[0] = static_cast(m_windowSize.x()); + v2[0] = static_cast(m_windowSize.x()); + v2[1] = static_cast(m_windowSize.y()); + v3[1] = static_cast(m_windowSize.y()); + + v4[0] = m_frameWidth; + v4[1] = m_frameHeight; + + v5[0] = v1[0] - m_frameWidth; + v5[1] = m_frameHeight; + + v6[0] = v2[0] - m_frameWidth; + v6[1] = v2[1]; + + v7[0] = m_frameWidth; + v7[1] = v3[1]; + + glColor4fv(Vec4f(1.0f,1.0f,1.0f,0.5f).ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(v0.ptr()); + glVertex3fv(v1.ptr()); + glVertex3fv(v5.ptr()); + glVertex3fv(v4.ptr()); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(v1.ptr()); + glVertex3fv(v2.ptr()); + glVertex3fv(v6.ptr()); + glVertex3fv(v5.ptr()); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(v3.ptr()); + glVertex3fv(v0.ptr()); + glVertex3fv(v4.ptr()); + glVertex3fv(v7.ptr()); + glEnd(); + + + // Render Line around + + { + glColor3fv(m_lineColor.ptr()); + glBegin(GL_LINES); + // Frame lines + glVertex3fv(v7.ptr()); + glVertex3fv(v4.ptr()); + glVertex3fv(v4.ptr()); + glVertex3fv(v5.ptr()); + glVertex3fv(v5.ptr()); + glVertex3fv(v6.ptr()); + + // X - axis Tick lines + for (double txpos : m_windowTickXValues) + { + Vec3f p1(Vec3f::ZERO); + Vec3f p2(Vec3f::ZERO); + + p1[0] = (float)txpos; + p1[1] = m_frameHeight; + p2[0] = (float)txpos; + p2[1] = m_frameHeight - m_tickLineLength; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + } + + // Left Y - axis Tick lines + for (double typos : m_windowTickYValues) + { + Vec3f p1(Vec3f::ZERO); + Vec3f p2(Vec3f::ZERO); + + p1[0] = m_frameWidth; + p1[1] = (float)typos; + p2[0] = m_frameWidth - m_tickLineLength; + p2[1] = (float)typos; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + + p1[0] = m_windowSize.x() - m_frameWidth; + p1[1] = (float)typos; + p2[0] = m_windowSize.x() - m_frameWidth + m_tickLineLength; + p2[1] = (float)typos; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + } + + glEnd(); + } + + // Reset render states + + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + CVF_CHECK_OGL(oglContext); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setLineColor(const Color3f& lineColor) +{ + m_lineColor = lineColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const Color3f& RivWindowEdgeAxesOverlayItem::lineColor() const +{ + return m_lineColor; +} + diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h new file mode 100644 index 0000000000..5665ed4965 --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -0,0 +1,130 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cvfOverlayItem.h" +#include "cvfArray.h" +#include "cvfCamera.h" +#include "cvfString.h" +#include "cvfRect.h" +#include "cafDisplayCoordTransform.h" + +namespace caf +{ + class DisplayCoordTransform; +} + +namespace cvf +{ +class Font; +class ShaderProgram; +class MatrixState; +class TextDrawer; +class ScalarMapper; +} + +//================================================================================================== +// +// Overlay color legend +// +//================================================================================================== +class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem +{ + using Font = cvf::Font; + using Vec2ui = cvf::Vec2ui; + using ScalarMapper = cvf::ScalarMapper; + using OpenGLContext = cvf::OpenGLContext; + using Vec2i = cvf::Vec2i; + using Color3f = cvf::Color3f; + using String = cvf::String; + using Vec2f = cvf::Vec2f; + using Rectf = cvf::Rectf; + using DoubleArray = cvf::DoubleArray; + using MatrixState = cvf::MatrixState; + using TextDrawer = cvf::TextDrawer; + using Camera = cvf::Camera; +public: + RivWindowEdgeAxesOverlayItem(Font* font); + virtual ~RivWindowEdgeAxesOverlayItem(); + + void setDisplayCoordTransform(const caf::DisplayCoordTransform* displayCoordTransform); + void updateFromCamera(const Camera* camera); + + void setTextColor(const Color3f& color); + const Color3f& textColor() const; + void setLineColor(const Color3f& lineColor); + const Color3f& lineColor() const; + +protected: + virtual Vec2ui sizeHint(); + virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); + virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); + virtual bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size); + +protected: + void updateGeomerySizes(); + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); + void renderLegendImmediateMode(OpenGLContext* oglContext); + void addTextToTextDrawer(TextDrawer* textDrawer); + +protected: + cvf::cref m_dispalyCoordsTransform; + + DoubleArray m_tickValues; // Ticks between each level + top and bottom of legend (n+1 entries) + std::vector m_visibleTickLabels; // Skip tick labels ending up on top of previous visible label + + Vec2ui m_windowSize; // Pixel size of the window + Vec2ui m_textSize; + Color3f m_textColor; + Color3f m_lineColor; + int m_lineWidth; + cvf::ref m_font; + + float m_frameHeight; + float m_frameWidth; + float m_tickLineLength; + float m_pixelSpacing; + bool m_isSwitchingYAxisValueSign; + + std::vector m_domainCoordsXValues; + std::vector m_domainCoordsYValues; + std::vector m_windowTickXValues; + std::vector m_windowTickYValues; +}; + + diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index cfb20fe8c9..7c28f53f48 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -383,6 +383,7 @@ void Rim2dIntersectionView::resetLegendsInViewer() m_viewer->showAnimationProgress(true); m_viewer->showHistogram(false); m_viewer->showInfoText(false); + m_viewer->showEdgeTickMarks(false); m_viewer->setMainScene(new cvf::Scene()); m_viewer->enableNavigationRotation(false); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index aca6e1eba7..6b03547d5b 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -59,6 +59,7 @@ #include #include #include +#include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h" using cvf::ManipulatorTrackball; @@ -175,6 +176,8 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_gridBoxGenerator = new RivGridBoxGenerator; m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED; + m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont); + } //-------------------------------------------------------------------------------------------------- @@ -697,8 +700,9 @@ RimViewWindow* RiuViewer::ownerViewWindow() const //-------------------------------------------------------------------------------------------------- void RiuViewer::optimizeClippingPlanes() { + m_windowEdgeAxisOverlay->setDisplayCoordTransform(m_rimView->displayCoordTransform().p()); m_gridBoxGenerator->updateFromCamera(mainCamera()); - + m_windowEdgeAxisOverlay->updateFromCamera(this->mainCamera()); caf::Viewer::optimizeClippingPlanes(); } @@ -789,6 +793,19 @@ void RiuViewer::updateGridBoxData(double scaleZ, m_gridBoxGenerator->createGridBoxParts(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::showEdgeTickMarks(bool enable) +{ + m_mainRendering->removeOverlayItem(m_windowEdgeAxisOverlay.p()); + + if (enable) + { + m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 70545ae480..dbc51eeb7a 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -36,6 +36,7 @@ class Rim3dView; class RiuSimpleHistogramWidget; class RiuViewerCommands; class RivGridBoxGenerator; +class RivWindowEdgeAxesOverlayItem; class QCDEStyle; class QLabel; @@ -83,6 +84,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow const cvf::Vec3d& displayModelOffset, const cvf::Color3f& backgroundColor, const cvf::BoundingBox& domainCoordBoundingBox); + void showEdgeTickMarks(bool enable); void updateAnnotationItems(); @@ -155,6 +157,7 @@ public slots: RiuViewerCommands* m_viewerCommands; RivGridBoxGenerator* m_gridBoxGenerator; + cvf::ref m_windowEdgeAxisOverlay; cvf::Vec3d m_cursorPositionDomainCoords; bool m_isNavigationRotationEnabled; From e76f8cfbccef214df4005932a302bf5c6f58091d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Feb 2018 11:01:00 +0100 Subject: [PATCH 0234/1027] #2337 Add an improved tick mark generator --- .../UnitTests/ScalarMapper-Test.cpp | 68 +++++++++ Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h | 132 ++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h diff --git a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp index 1e13ec3d40..b376a32205 100644 --- a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp +++ b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp @@ -5,6 +5,74 @@ #include #include "RigFemPartResultsCollection.h" +#include "cafTickMarkGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(ScalarMapperTest, TickMarkGenerator) +{ + EXPECT_EQ(10.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(5.5e6) ); + EXPECT_EQ(5.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(2.1e6) ); + EXPECT_EQ(2.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.1e6) ); + EXPECT_EQ(1.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.0e6) ); + EXPECT_EQ(1.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.9e6) ); + + EXPECT_EQ(50.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(50.0) ); + EXPECT_EQ(50.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(21.00023) ); + EXPECT_EQ(20.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(11.2324556) ); + EXPECT_EQ(10.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(5.5) ); + EXPECT_EQ(5.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(2.1) ); + EXPECT_EQ(2.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.1) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.0) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.9) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.7) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.5) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.435) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.200001) ); + EXPECT_EQ(0.2, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.20000) ); + EXPECT_EQ(0.2, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.12) ); + EXPECT_EQ(0.1, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.056) ); + + EXPECT_EQ(0.5e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.200001e-6) ); + EXPECT_EQ(0.2e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.20000e-6) ); + EXPECT_EQ(0.2e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.12e-6) ); + EXPECT_EQ(0.1e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.056e-6) ); + + { + caf::TickMarkGenerator tickGen(1234.34521, 2346.67293, 104.2768); + + EXPECT_EQ(size_t(5), tickGen.tickMarkValues().size()); + + EXPECT_EQ(1400, tickGen.tickMarkValues()[0]); + EXPECT_EQ(1600, tickGen.tickMarkValues()[1]); + EXPECT_EQ(1800, tickGen.tickMarkValues()[2]); + EXPECT_EQ(2000, tickGen.tickMarkValues()[3]); + EXPECT_EQ(2200, tickGen.tickMarkValues()[4]); + } + { + caf::TickMarkGenerator tickGen(0.02134, 0.17829, 0.03267); + + EXPECT_EQ(size_t(3), tickGen.tickMarkValues().size()); + + EXPECT_NEAR(0.05, tickGen.tickMarkValues()[0], 1e-15); + EXPECT_NEAR(0.1, tickGen.tickMarkValues()[1], 1e-15); + EXPECT_NEAR(0.15, tickGen.tickMarkValues()[2], 1e-15); + } + + { + caf::TickMarkGenerator tickGen(0.02134, 0.0335, 0.001267); + + EXPECT_EQ(size_t(6), tickGen.tickMarkValues().size()); + + EXPECT_EQ(0.022, tickGen.tickMarkValues()[0]); + EXPECT_EQ(0.024, tickGen.tickMarkValues()[1]); + EXPECT_NEAR(0.026, tickGen.tickMarkValues()[2], 1e-15); + EXPECT_EQ(0.028, tickGen.tickMarkValues()[3]); + EXPECT_EQ(0.03, tickGen.tickMarkValues()[4]); + EXPECT_EQ(0.032, tickGen.tickMarkValues()[5]); + } +} //-------------------------------------------------------------------------------------------------- /// diff --git a/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h new file mode 100644 index 0000000000..88084ff9f0 --- /dev/null +++ b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h @@ -0,0 +1,132 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 +#include +#include "cafAssert.h" + +namespace caf +{ +class TickMarkGenerator +{ +public: + TickMarkGenerator(double min, double max, double minAllowedStepSize) + { + double step = roundUpToLog_1_2_5_10(minAllowedStepSize); + + double startStepCount = ceil(min / step); + + if ( startStepCount*step < (min + 0.5*minAllowedStepSize) ) + { + ++startStepCount; + } + + double tick = startStepCount*step; + double currentStepCount = startStepCount; + while ( tick < (max - 0.5*minAllowedStepSize) ) + { + m_tickMarkValues.push_back(tick); + ++currentStepCount; + tick = currentStepCount*step; + } + } + + const std::vector& tickMarkValues() { return m_tickMarkValues; } + + static double roundUpToLog_1_2_5_10(double val) + { + CAF_ASSERT(val >= 0.0); + + const static double logOf5 = log10(5.0); + const static double logOf2 = log10(2.0); + const static double logOf0_5 = log10(0.5); + const static double logOf0_2 = log10(0.2); + + double logValue = log10(val); + double intPart = 0.0; + double fraction = modf(logValue, &intPart); + + double factor = 1.0; + + if (fraction == 0.0) + { + factor = 1.0; + } + else if (fraction > 0.0) + { + if ( fraction > logOf5 ) + { + factor = 10.0; + } + else if ( fraction > logOf2 ) + { + factor = 5.0; + } + else + { + factor = 2.0; + } + } + else + { + if (fraction > logOf0_5) + { + factor = 1; + } + else if ( fraction > logOf0_2 ) + { + factor = 0.5; + } + else + { + factor = 0.2; + } + } + + double roundedValue = pow(10.0, intPart) * factor; + + return roundedValue; + } + +private: + std::vector m_tickMarkValues; +}; + +} + + From 068adf6aa2b5b69c44364d66fe5dd7297f443fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Feb 2018 11:03:36 +0100 Subject: [PATCH 0235/1027] #2337 Fix crash when having too few tickmarks. Some rename --- .../RivWindowEdgeAxesOverlayItem.cpp | 54 +++++++++---------- .../RivWindowEdgeAxesOverlayItem.h | 7 ++- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index aecfa6bdcd..17d2b59ef9 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -43,7 +43,7 @@ #include "cvfScalarMapper.h" #include "cvfRenderStateBlending.h" -#include "cvfScalarMapperDiscreteLinear.h" +#include "cafTickMarkGenerator.h" using namespace cvf; @@ -106,8 +106,8 @@ void RivWindowEdgeAxesOverlayItem::updateGeomerySizes() m_textSize = m_font->textExtent(str); m_pixelSpacing = 2.0f; m_tickLineLength = m_textSize.y() *0.3f; - m_frameHeight = m_pixelSpacing + m_textSize.y() + m_pixelSpacing + m_tickLineLength + m_lineWidth; - m_frameWidth = m_pixelSpacing + m_textSize.x() + m_pixelSpacing + m_tickLineLength + m_lineWidth; + m_frameBorderHeight = m_pixelSpacing + m_textSize.y() + m_pixelSpacing + m_tickLineLength + m_lineWidth; + m_frameBorderWidth = m_pixelSpacing + m_textSize.x() + m_pixelSpacing + m_tickLineLength + m_lineWidth; } //-------------------------------------------------------------------------------------------------- @@ -136,23 +136,20 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera(const Camera* camera) int xTickMaxCount = m_windowSize.x()/(2*m_textSize.x()); int yTickMaxCount = m_windowSize.y()/(2*m_textSize.x()); - m_domainCoordsXValues.clear(); - cvf::ScalarMapperDiscreteLinear linDiscreteScalarMapper; - linDiscreteScalarMapper.setRange(domainMinX, domainMaxX); - linDiscreteScalarMapper.setLevelCount(xTickMaxCount, true); - linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues); + double minDomainXStepSize = (domainMaxX - domainMinX)/xTickMaxCount; + caf::TickMarkGenerator xTickCreator(domainMinX, domainMaxX, minDomainXStepSize); + m_domainCoordsXValues = xTickCreator.tickMarkValues(); - m_domainCoordsYValues.clear(); - linDiscreteScalarMapper.setRange(domainMinY, domainMaxY); - linDiscreteScalarMapper.setLevelCount(yTickMaxCount, true); - linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues); + double minDomainYStepSize = (domainMaxY - domainMinY)/yTickMaxCount; + caf::TickMarkGenerator yTickCreator(domainMinY, domainMaxY, minDomainYStepSize); + m_domainCoordsYValues = yTickCreator.tickMarkValues(); + m_windowTickXValues.clear(); Vec3d windowPoint; - double domainYValue0 = m_domainCoordsYValues[0]; for (double domainX : m_domainCoordsXValues) { - Vec3d displayDomainTick(domainX, 0, domainYValue0); + Vec3d displayDomainTick(domainX, 0, domainMinY); if ( m_dispalyCoordsTransform.notNull() ) { displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); @@ -162,10 +159,9 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera(const Camera* camera) } m_windowTickYValues.clear(); - double domainXValue0 = m_domainCoordsXValues[0]; for (double domainY : m_domainCoordsYValues) { - Vec3d displayDomainTick(domainXValue0, 0, domainY); + Vec3d displayDomainTick(domainMinX, 0, domainY); if ( m_dispalyCoordsTransform.notNull() ) { displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); @@ -313,7 +309,7 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) // Left Y - axis texts { - const float textX = m_frameWidth - m_tickLineLength - m_pixelSpacing; + const float textX = m_frameBorderWidth - m_tickLineLength - m_pixelSpacing; size_t numTicks = m_domainCoordsYValues.size(); size_t i; @@ -364,16 +360,16 @@ void RivWindowEdgeAxesOverlayItem::renderLegendImmediateMode(OpenGLContext* oglC v2[1] = static_cast(m_windowSize.y()); v3[1] = static_cast(m_windowSize.y()); - v4[0] = m_frameWidth; - v4[1] = m_frameHeight; + v4[0] = m_frameBorderWidth; + v4[1] = m_frameBorderHeight; - v5[0] = v1[0] - m_frameWidth; - v5[1] = m_frameHeight; + v5[0] = v1[0] - m_frameBorderWidth; + v5[1] = m_frameBorderHeight; - v6[0] = v2[0] - m_frameWidth; + v6[0] = v2[0] - m_frameBorderWidth; v6[1] = v2[1]; - v7[0] = m_frameWidth; + v7[0] = m_frameBorderWidth; v7[1] = v3[1]; glColor4fv(Vec4f(1.0f,1.0f,1.0f,0.5f).ptr()); @@ -417,9 +413,9 @@ void RivWindowEdgeAxesOverlayItem::renderLegendImmediateMode(OpenGLContext* oglC Vec3f p2(Vec3f::ZERO); p1[0] = (float)txpos; - p1[1] = m_frameHeight; + p1[1] = m_frameBorderHeight; p2[0] = (float)txpos; - p2[1] = m_frameHeight - m_tickLineLength; + p2[1] = m_frameBorderHeight - m_tickLineLength; glVertex3fv(p1.ptr()); glVertex3fv(p2.ptr()); @@ -431,17 +427,17 @@ void RivWindowEdgeAxesOverlayItem::renderLegendImmediateMode(OpenGLContext* oglC Vec3f p1(Vec3f::ZERO); Vec3f p2(Vec3f::ZERO); - p1[0] = m_frameWidth; + p1[0] = m_frameBorderWidth; p1[1] = (float)typos; - p2[0] = m_frameWidth - m_tickLineLength; + p2[0] = m_frameBorderWidth - m_tickLineLength; p2[1] = (float)typos; glVertex3fv(p1.ptr()); glVertex3fv(p2.ptr()); - p1[0] = m_windowSize.x() - m_frameWidth; + p1[0] = m_windowSize.x() - m_frameBorderWidth; p1[1] = (float)typos; - p2[0] = m_windowSize.x() - m_frameWidth + m_tickLineLength; + p2[0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength; p2[1] = (float)typos; glVertex3fv(p1.ptr()); diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 5665ed4965..924fdda761 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -90,6 +90,9 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem void setLineColor(const Color3f& lineColor); const Color3f& lineColor() const; + int frameBorderWidth() { return static_cast( m_frameBorderWidth); } + int frameBorderHeight() { return static_cast( m_frameBorderHeight); } + protected: virtual Vec2ui sizeHint(); virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); @@ -115,8 +118,8 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem int m_lineWidth; cvf::ref m_font; - float m_frameHeight; - float m_frameWidth; + float m_frameBorderHeight; + float m_frameBorderWidth; float m_tickLineLength; float m_pixelSpacing; bool m_isSwitchingYAxisValueSign; From d86b6f690e644d3c3528d005e4ab8e8048e03a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Feb 2018 13:30:18 +0100 Subject: [PATCH 0236/1027] #2337 Place legends aware of the possible edge axis border and enable the border by default in Intersection views --- .../Rim2dIntersectionView.cpp | 2 +- ApplicationCode/UserInterface/RiuViewer.cpp | 39 +++++++++++++++---- ApplicationCode/UserInterface/RiuViewer.h | 4 ++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 7c28f53f48..9202d68142 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -383,7 +383,7 @@ void Rim2dIntersectionView::resetLegendsInViewer() m_viewer->showAnimationProgress(true); m_viewer->showHistogram(false); m_viewer->showInfoText(false); - m_viewer->showEdgeTickMarks(false); + m_viewer->showEdgeTickMarks(true); m_viewer->setMainScene(new cvf::Scene()); m_viewer->enableNavigationRotation(false); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 6b03547d5b..66be9f6478 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -87,6 +87,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_axisCross->setAxisLabels("X", "Y", "Z"); m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); m_mainRendering->addOverlayItem(m_axisCross.p()); + m_showAxisCross = true; this->enableOverlyPainting(true); this->setReleaseOGLResourcesEachFrame(true); @@ -177,6 +178,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED; m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont); + m_showWindowEdgeAxes = false; } @@ -352,6 +354,8 @@ void RiuViewer::paintOverlayItems(QPainter* painter) //} int columnWidth = 200; + int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; int margin = 5; int yPos = margin; @@ -361,7 +365,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) //if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width()); if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_infoLabel->sizeHint().width()); - int columnPos = this->width() - columnWidth - margin; + int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth; if (showAnimBar && m_showAnimProgress) { @@ -404,7 +408,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) if (m_showInfoText) // Version Label { QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height()); - QPoint pos(this->width() - size.width() - margin, this->height() - size.height() - margin); + QPoint pos(this->width() - size.width() - margin - edgeAxisFrameBorderWidth, this->height() - size.height() - margin - edgeAxisFrameBorderHeight); m_versionInfoLabel->resize(size.width(), size.height()); m_versionInfoLabel->render(painter, pos); } @@ -505,6 +509,19 @@ void RiuViewer::mousePressEvent(QMouseEvent* event) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Collection RiuViewer::allOverlayItems() +{ + cvf::Collection allOverLays; + for (size_t oIdx = 0; oIdx < m_mainRendering->overlayItemCount(); ++oIdx) + { + allOverLays.push_back(m_mainRendering->overlayItem(oIdx)); + } + return allOverLays; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -544,6 +561,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) { legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); if (catLegend) { @@ -562,23 +580,25 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) } } - if (categoryLegends.size() > 0) + if (categoryLegends.size() > 0 || m_showWindowEdgeAxes) { const int border = 3; const int categoryWidth = 150; + int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; // This value is taken from OverlayAxisCross, as the axis cross is always shown in the lower left corner - const int axisCrossHeight = 120; + const int axisCrossHeight = m_showAxisCross? 120 : 0; int height = static_cast(m_mainCamera->viewport()->height()); - int xPos = border; + int xPos = border + edgeAxisBorderWidth; - int yPos = axisCrossHeight + 2*border; + int yPos = axisCrossHeight + 2*border + edgeAxisBorderHeight; for (auto catLegend : categoryLegends) { catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight)); + catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight - edgeAxisBorderHeight)); xPos += categoryWidth + border; } @@ -587,7 +607,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) { item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - yPos += item->sizeHint().y() + border; + yPos += item->sizeHint().y() + border + edgeAxisBorderHeight; } } } @@ -677,6 +697,7 @@ void RiuViewer::showAxisCross(bool enable) { m_mainRendering->addOverlayItem(m_axisCross.p()); } + m_showAxisCross = enable; } //-------------------------------------------------------------------------------------------------- @@ -804,6 +825,8 @@ void RiuViewer::showEdgeTickMarks(bool enable) { m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p()); } + + m_showWindowEdgeAxes = enable; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index dbc51eeb7a..ebee202195 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -149,7 +149,10 @@ public slots: QCDEStyle* m_progressBarStyle; cvf::ref m_axisCross; + bool m_showAxisCross; cvf::Collection m_visibleLegends; + cvf::Collection allOverlayItems(); + caf::PdmInterfacePointer m_rimView; QPoint m_lastMousePressPosition; @@ -158,6 +161,7 @@ public slots: RivGridBoxGenerator* m_gridBoxGenerator; cvf::ref m_windowEdgeAxisOverlay; + bool m_showWindowEdgeAxes; cvf::Vec3d m_cursorPositionDomainCoords; bool m_isNavigationRotationEnabled; From c6846f0d57e05c4bc719d7bbf0e550ff00105243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Feb 2018 16:47:24 +0100 Subject: [PATCH 0237/1027] Fix linux compile issues --- .../WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h | 1 + ApplicationCode/ProjectDataModel/RimTensorResults.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 924fdda761..08d35a2a77 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -37,6 +37,7 @@ #pragma once +#include "cvfBase.h" #include "cvfOverlayItem.h" #include "cvfArray.h" #include "cvfCamera.h" diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index cc8baaeaea..fbe561aceb 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -244,7 +244,7 @@ QList RimTensorResults::calculateValueOptions(const caf: { std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); - for (int oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx) + for (size_t oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx) { options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), QString::fromStdString(fieldCompNames[oIdx]))); } From cf3a1ad43f2fab57390c58a42b1dc8c09a5e8af0 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 12 Feb 2018 08:42:05 +0100 Subject: [PATCH 0238/1027] #2392 3D View Context command: "Color Result" --- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicSelectColorResult.cpp | 72 +++++++++++++++++++ .../Commands/RicSelectColorResult.h | 34 +++++++++ .../UserInterface/RiuViewerCommands.cpp | 1 + 4 files changed, 109 insertions(+) create mode 100644 ApplicationCode/Commands/RicSelectColorResult.cpp create mode 100644 ApplicationCode/Commands/RicSelectColorResult.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index f11b8143d1..f5b964cd48 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -35,6 +35,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h ${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.h +${CEE_CURRENT_LIST_DIR}RicSelectColorResult.h ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h @@ -118,6 +119,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.cpp +${CEE_CURRENT_LIST_DIR}RicSelectColorResult.cpp ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp diff --git a/ApplicationCode/Commands/RicSelectColorResult.cpp b/ApplicationCode/Commands/RicSelectColorResult.cpp new file mode 100644 index 0000000000..f335afc067 --- /dev/null +++ b/ApplicationCode/Commands/RicSelectColorResult.cpp @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSelectColorResult.h" + +#include "RiaApplication.h" +#include "RicWellLogTools.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" +#include "RiuMainWindow.h" + +#include + +CAF_CMD_SOURCE_INIT(RicSelectColorResult, "RicSelectColorResult"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectColorResult::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Color Result"); + actionToSetup->setIcon(QIcon(":/CellResult.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSelectColorResult::isCommandEnabled() +{ + if (RicWellLogTools::isWellPathOrSimWellSelectedInView()) return false; + + return RiaApplication::instance()->activeGridView() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectColorResult::onActionTriggered(bool isChecked) +{ + RimGridView* activeView = RiaApplication::instance()->activeGridView(); + + RimEclipseView* eclView = dynamic_cast(activeView); + if (eclView) + { + RiuMainWindow::instance()->selectAsCurrentItem(eclView->cellResult()); + return; + } + + RimGeoMechView* geoMechView = dynamic_cast(activeView); + if (geoMechView) + { + RiuMainWindow::instance()->selectAsCurrentItem(geoMechView->cellResult()); + } +} diff --git a/ApplicationCode/Commands/RicSelectColorResult.h b/ApplicationCode/Commands/RicSelectColorResult.h new file mode 100644 index 0000000000..d46ec5e87e --- /dev/null +++ b/ApplicationCode/Commands/RicSelectColorResult.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicSelectColorResult : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index b422f82915..759d5dfc26 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -421,6 +421,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; menuBuilder << "RicShowGridStatisticsFeature"; + menuBuilder << "RicSelectColorResult"; menuBuilder.appendToMenu(&menu); From 063802130cdc7bd25ffb75956f4a530c66e29f41 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 12 Feb 2018 09:05:58 +0100 Subject: [PATCH 0239/1027] Fix window edge axis crash --- ApplicationCode/UserInterface/RiuViewer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 66be9f6478..41877fc8fe 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -721,9 +721,13 @@ RimViewWindow* RiuViewer::ownerViewWindow() const //-------------------------------------------------------------------------------------------------- void RiuViewer::optimizeClippingPlanes() { - m_windowEdgeAxisOverlay->setDisplayCoordTransform(m_rimView->displayCoordTransform().p()); + if (m_showWindowEdgeAxes) + { + m_windowEdgeAxisOverlay->setDisplayCoordTransform(m_rimView->displayCoordTransform().p()); + m_windowEdgeAxisOverlay->updateFromCamera(this->mainCamera()); + } + m_gridBoxGenerator->updateFromCamera(mainCamera()); - m_windowEdgeAxisOverlay->updateFromCamera(this->mainCamera()); caf::Viewer::optimizeClippingPlanes(); } From c3c2dfc67839e01b68c1092aac339cb218334192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Feb 2018 10:07:07 +0100 Subject: [PATCH 0240/1027] #2337 Made EdgeAxis overly item more robust. Some cleanup and renaming. --- .../RivWindowEdgeAxesOverlayItem.cpp | 28 +++++++++++-------- .../RivWindowEdgeAxesOverlayItem.h | 11 +++----- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 17d2b59ef9..367ebab31a 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -71,11 +71,6 @@ RivWindowEdgeAxesOverlayItem::RivWindowEdgeAxesOverlayItem(Font* font) CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); - m_tickValues.reserve(3); - m_tickValues.add(0.0); - m_tickValues.add(0.5); - m_tickValues.add(1.0); - setLayoutFixedPosition({0,0}); updateGeomerySizes(); } @@ -115,6 +110,16 @@ void RivWindowEdgeAxesOverlayItem::updateGeomerySizes() //-------------------------------------------------------------------------------------------------- void RivWindowEdgeAxesOverlayItem::updateFromCamera(const Camera* camera) { + if (!camera || camera->projection() != Camera::ORTHO ) + { + m_domainCoordsXValues.clear(); + m_domainCoordsYValues.clear(); + m_windowTickXValues.clear(); + m_windowTickYValues.clear(); + + return; + } + m_windowSize = Vec2ui( camera->viewport()->width(), camera->viewport()->height()); Vec3d windowOrigoInDomain; Vec3d windowMaxInDomain; @@ -201,7 +206,7 @@ const Color3f& RivWindowEdgeAxesOverlayItem::textColor() const //-------------------------------------------------------------------------------------------------- void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, false); + renderGeneric(oglContext, position, size, false); } @@ -210,7 +215,7 @@ void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i //-------------------------------------------------------------------------------------------------- void RivWindowEdgeAxesOverlayItem::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, true); + renderGeneric(oglContext, position, size, true); } @@ -226,9 +231,10 @@ bool RivWindowEdgeAxesOverlayItem::pick(int oglXCoord, int oglYCoord, const Vec2 //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +void RivWindowEdgeAxesOverlayItem::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) { - if (size.x() <= 0 || size.y() <= 0) + if (size.x() <= 0 || size.y() <= 0 + || (m_windowTickXValues.size() == 0 && m_windowTickYValues.size() == 0 ) ) { return; } @@ -243,7 +249,7 @@ void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i TextDrawer textDrawer(m_font.p()); addTextToTextDrawer(&textDrawer); - renderLegendImmediateMode(oglContext); + renderSoftwareFrameAndTickLines(oglContext); if (software) { @@ -332,7 +338,7 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) //-------------------------------------------------------------------------------------------------- /// Draw the legend using immediate mode OpenGL //-------------------------------------------------------------------------------------------------- -void RivWindowEdgeAxesOverlayItem::renderLegendImmediateMode(OpenGLContext* oglContext) +void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext* oglContext) { RenderStateDepth depth(false); depth.applyOpenGL(oglContext); diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 08d35a2a77..8cd449bc81 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -100,18 +100,15 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); virtual bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size); -protected: +private: void updateGeomerySizes(); - void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); - void renderLegendImmediateMode(OpenGLContext* oglContext); + void renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); + void renderSoftwareFrameAndTickLines(OpenGLContext* oglContext); void addTextToTextDrawer(TextDrawer* textDrawer); -protected: +private: cvf::cref m_dispalyCoordsTransform; - DoubleArray m_tickValues; // Ticks between each level + top and bottom of legend (n+1 entries) - std::vector m_visibleTickLabels; // Skip tick labels ending up on top of previous visible label - Vec2ui m_windowSize; // Pixel size of the window Vec2ui m_textSize; Color3f m_textColor; From 7222a6ba46526cb5b30a5d804acba19353d0ca77 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 12 Feb 2018 13:06:47 +0100 Subject: [PATCH 0241/1027] Fix colors on tensor glyphs --- .../RivTensorResultPartMgr.cpp | 115 +++++++++--------- .../RivTensorResultPartMgr.h | 2 +- 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 91a6fc8e5d..1678fc81f0 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -28,8 +28,8 @@ #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" -#include "RigFemResultAddress.h" #include "RigFemPartResultsCollection.h" +#include "RigFemResultAddress.h" #include "RigFemTypes.h" #include "RigGeoMechCaseData.h" @@ -81,16 +81,16 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (!m_rimReservoirView->geoMechCase()->geoMechData()) return; if (!m_rimReservoirView->tensorResults()->showTensors()) return; - + RigFemPartCollection* femParts = m_rimReservoirView->geoMechCase()->geoMechData()->femParts(); if (!femParts) return; - + std::vector tensorVisualizations; RimTensorResults::TensorColors tensorColor = m_rimReservoirView->tensorResults()->vectorColors(); - cvf::Color3f color1, color2, color3; + cvf::Color3f color1, color2, color3; - assignColorVectors(tensorColor, color1, color2, color3); + assignColorVectors(tensorColor, &color1, &color2, &color3); RigFemResultAddress address = m_rimReservoirView->tensorResults()->selectedTensorResult(); if (!isTensorAddress(address)) return; @@ -102,15 +102,15 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi { std::vector tensors = resultCollection->tensors(address, partIdx, (int)frameIndex); - const RigFemPart* part = femParts->part(partIdx); - size_t elmCount = part->elementCount(); + const RigFemPart* part = femParts->part(partIdx); + size_t elmCount = part->elementCount(); std::vector elmTensors; elmTensors.resize(elmCount); - + for (int elmIdx = 0; elmIdx < elmCount; elmIdx++) { - if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) - { + if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) + { caf::Ten3f tensorSumOfElmNodes = tensors[part->elementNodeResultIdx(elmIdx, 0)]; for (int i = 1; i < 8; i++) { @@ -151,10 +151,10 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi double min, max; resultCollection->minMaxScalarValuesOverAllTensorComponents(address, (int)frameIndex, &min, &max); - + if (max == 0) max = 1; float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); - float arrowResultScaling = arrowConstantScaling / cvf::Math::abs(max); + float arrowResultScaling = arrowConstantScaling / cvf::Math::abs(max); cvf::ref partMgrCache = m_rimReservoirView->vizLogic()->partMgrCache(); @@ -164,9 +164,9 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi for (auto mgr : partMgr->femPartMgrs()) { - const RivFemPartGeometryGenerator* surfaceGenerator = mgr->surfaceGenerator(); - const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); - const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); + const RivFemPartGeometryGenerator* surfaceGenerator = mgr->surfaceGenerator(); + const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); + const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); for (int quadIdx = 0; quadIdx < quadVerticesToNodeIdxMapping.size(); quadIdx = quadIdx + 4) { @@ -196,19 +196,25 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (isDrawable(result1, m_rimReservoirView->tensorResults()->showPrincipal1())) { - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure(elmPrincipals[0][elmIdx]))); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result1, color1, isPressure(elmPrincipals[0][elmIdx]))); + tensorVisualizations.push_back( + TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure(elmPrincipals[0][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result1, color1, isPressure(elmPrincipals[0][elmIdx]))); } if (isDrawable(result2, m_rimReservoirView->tensorResults()->showPrincipal2())) { - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure(elmPrincipals[1][elmIdx]))); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result2, color2, isPressure(elmPrincipals[1][elmIdx]))); + tensorVisualizations.push_back( + TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure(elmPrincipals[1][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result2, color2, isPressure(elmPrincipals[1][elmIdx]))); } if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) { - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure(elmPrincipals[2][elmIdx]))); - tensorVisualizations.push_back(TensorVisualization(cvf::Vec3f(displayCoord), -result3, color3, isPressure(elmPrincipals[2][elmIdx]))); + tensorVisualizations.push_back( + TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure(elmPrincipals[2][elmIdx]))); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result3, color3, isPressure(elmPrincipals[2][elmIdx]))); } } } @@ -223,13 +229,13 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- cvf::ref RivTensorResultPartMgr::createPart(std::vector& tensorVisualizations) const { cvf::ref vertices = new cvf::Vec3fArray; - cvf::ref vecRes = new cvf::Vec3fArray; - cvf::ref colors = new cvf::Color3fArray; + cvf::ref vecRes = new cvf::Vec3fArray; + cvf::ref colors = new cvf::Color3fArray; size_t numVecs = tensorVisualizations.size(); vertices->reserve(numVecs); @@ -283,9 +289,9 @@ cvf::ref RivTensorResultPartMgr::createPart(std::vectorviewer()) { - cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); + cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); cvf::OpenGLResourceManager* resourceManager = oglContext->resourceManager(); - cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram(oglContext.p()); + cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram(oglContext.p()); eff->setShaderProgram(vectorProgram.p()); } @@ -297,32 +303,35 @@ cvf::ref RivTensorResultPartMgr::createPart(std::vector createPart(std::vector& tensorVisualizations) const; - static void assignColorVectors(RimTensorResults::TensorColors tensorColor, cvf::Color3f color1, cvf::Color3f color2, cvf::Color3f color3); + static void assignColorVectors(RimTensorResults::TensorColors tensorColor, cvf::Color3f* color1, cvf::Color3f* color2, cvf::Color3f* color3); static bool isTensorAddress(RigFemResultAddress address); static bool isValid(cvf::Vec3f resultVector); static bool isPressure(float principalValue); From 5195ea502ac45c0fe3d7c384233f5794db491f0d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 12 Feb 2018 15:58:47 +0100 Subject: [PATCH 0242/1027] #2413 2D Intersection View: Add Text info --- .../Rim2dIntersectionView.cpp | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 9202d68142..8bb1ed001d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -29,12 +29,16 @@ #include "cvfModelBasicList.h" #include "cvfTransform.h" #include "cvfScene.h" + +#include "Rim3dOverlayInfoConfig.h" #include "RimEclipseView.h" #include "RimEclipseCellColors.h" #include "RimGeoMechView.h" #include "RimGeoMechCellColors.h" #include "RimLegendConfig.h" #include "RimTernaryLegendConfig.h" +#include "RimSimWellInView.h" +#include "RimWellPath.h" #include @@ -334,7 +338,25 @@ void Rim2dIntersectionView::updateLegends() m_viewer->removeAllColorLegends(); } - if (!hasResults()) return ; + if (!hasResults()) return; + + RimCase* rimCase = nullptr; + m_intersection->firstAncestorOrThisOfType(rimCase); + + QString overlayInfoText; + + overlayInfoText += "Case: " + ownerCase()->caseUserDescription() + "
"; + + overlayInfoText += "Intersection: " + m_intersection->name() + "
"; + + if (m_intersection->simulationWell()) + { + overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
";; + } + else if (m_intersection->wellPath()) + { + overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
";; + } cvf::OverlayItem* legend = nullptr; @@ -342,6 +364,8 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(eclView); if (eclView) { + overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); @@ -362,6 +386,8 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(geoView); if (geoView) { + overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->resultVariableName() + "
"; + m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); @@ -372,6 +398,9 @@ void Rim2dIntersectionView::updateLegends() { m_viewer->addColorLegendToBottomLeftCorner(legend); } + + m_viewer->setInfoText(overlayInfoText); + m_viewer->showInfoText(true); } //-------------------------------------------------------------------------------------------------- From 59958dcc3ac1b395f47470386039be6c2e3a59b0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 Feb 2018 11:08:14 +0100 Subject: [PATCH 0243/1027] Fix picking on fracture geometry when scale factor is different to 1.0 --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 759d5dfc26..41dd149ced 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -508,7 +508,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM QString resultInfoText; cvf::ref transForm = m_reservoirView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->translateToDomainCoord(globalIntersectionPoint); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(globalIntersectionPoint); RimEclipseView* eclView = dynamic_cast(m_reservoirView.p()); RivWellFracturePartMgr* partMgr = fracture->fracturePartManager(); From c208569fb691793c67c8e73a4e99f58314e58230 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 10 Feb 2018 17:34:13 +0100 Subject: [PATCH 0244/1027] Clang : Remove inline from template function --- Fwk/VizFwk/LibCore/cvfVector2.h | 2 +- Fwk/VizFwk/LibCore/cvfVector3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Fwk/VizFwk/LibCore/cvfVector2.h b/Fwk/VizFwk/LibCore/cvfVector2.h index 720dceab45..c80c087e20 100644 --- a/Fwk/VizFwk/LibCore/cvfVector2.h +++ b/Fwk/VizFwk/LibCore/cvfVector2.h @@ -118,7 +118,7 @@ class Vector2 private: template - friend inline const Vector2 operator*(T scalar, const Vector2& rhs); + friend const Vector2 operator*(T scalar, const Vector2& rhs); private: S m_v[2]; diff --git a/Fwk/VizFwk/LibCore/cvfVector3.h b/Fwk/VizFwk/LibCore/cvfVector3.h index 25d4c9533e..0a31071367 100644 --- a/Fwk/VizFwk/LibCore/cvfVector3.h +++ b/Fwk/VizFwk/LibCore/cvfVector3.h @@ -144,7 +144,7 @@ class Vector3 private: template - friend inline const Vector3 operator*(T scalar, const Vector3& rhs); + friend const Vector3 operator*(T scalar, const Vector3& rhs); private: S m_v[3]; From 13606f0295a54b7b7e0447bc23d96f1f852b570c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 10 Feb 2018 17:37:22 +0100 Subject: [PATCH 0245/1027] Clang : Exclude special code in release() to avoid warning --- Fwk/VizFwk/LibCore/cvfObject.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Fwk/VizFwk/LibCore/cvfObject.inl b/Fwk/VizFwk/LibCore/cvfObject.inl index 59bf9dbf38..25ea5cefec 100644 --- a/Fwk/VizFwk/LibCore/cvfObject.inl +++ b/Fwk/VizFwk/LibCore/cvfObject.inl @@ -87,8 +87,9 @@ inline int Object::release() const { // Release on a NULL object ok, just return 0 // This is symmetric with being able to call delete on a NULL pointer +#ifndef __clang__ if (!this) return 0; - +#endif CVF_TIGHT_ASSERT(m_refCount > 0); if (--m_refCount == 0) From 2ff5842f2849b32ea4cfb451bfd68c3f18344c0b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 10 Feb 2018 18:04:25 +0100 Subject: [PATCH 0246/1027] Clang : Avoid special template helper on Windows --- Fwk/AppFwk/cafProjectDataModel/cafPdmField.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h index f74aa9f72e..8a6821a710 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h @@ -6,6 +6,7 @@ #undef PdmDataValueField #undef CAF_IS_DEFINING_PDM_FIELD +#ifndef __clang__ namespace caf { @@ -18,6 +19,7 @@ namespace caf { }; -#endif +#endif // WIN32 } +#endif // __clang__ From fa4535a18e9fa1e993f6b77112dbc70b1d6cbeec Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Feb 2018 08:48:12 +0100 Subject: [PATCH 0247/1027] #2413 2D Intersection View: Create more space in info text --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 8bb1ed001d..b00b9626d2 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -345,8 +345,9 @@ void Rim2dIntersectionView::updateLegends() QString overlayInfoText; - overlayInfoText += "Case: " + ownerCase()->caseUserDescription() + "
"; + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + overlayInfoText += "

"; overlayInfoText += "Intersection: " + m_intersection->name() + "
"; if (m_intersection->simulationWell()) @@ -364,7 +365,7 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(eclView); if (eclView) { - overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); @@ -386,7 +387,7 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(geoView); if (geoView) { - overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->resultVariableName() + "
"; + overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->resultVariableName() + "
"; m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); @@ -399,6 +400,7 @@ void Rim2dIntersectionView::updateLegends() m_viewer->addColorLegendToBottomLeftCorner(legend); } + overlayInfoText += "

"; m_viewer->setInfoText(overlayInfoText); m_viewer->showInfoText(true); } From ab27efcb7deccdfcca4c53c03507aa50849bf8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 13 Feb 2018 12:12:55 +0100 Subject: [PATCH 0248/1027] #2461 Add explicit render code for shader based rendering. Should solve the issue. --- .../RivWindowEdgeAxesOverlayItem.cpp | 134 +++++++++++++++++- .../RivWindowEdgeAxesOverlayItem.h | 1 + 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 367ebab31a..be10ebe03d 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -44,6 +44,7 @@ #include "cvfScalarMapper.h" #include "cvfRenderStateBlending.h" #include "cafTickMarkGenerator.h" +#include using namespace cvf; @@ -249,14 +250,17 @@ void RivWindowEdgeAxesOverlayItem::renderGeneric(OpenGLContext* oglContext, cons TextDrawer textDrawer(m_font.p()); addTextToTextDrawer(&textDrawer); - renderSoftwareFrameAndTickLines(oglContext); if (software) { + renderSoftwareFrameAndTickLines(oglContext); textDrawer.renderSoftware(oglContext, camera); } else { + const MatrixState matrixState(camera); + renderShaderFrameAndTickLines(oglContext, matrixState); + textDrawer.render(oglContext, camera); } @@ -464,6 +468,134 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext CVF_CHECK_OGL(oglContext); } +//-------------------------------------------------------------------------------------------------- +/// Draw the frame using shader programs +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState) +{ + CVF_CALLSITE_OPENGL(oglContext); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLine line(static_cast(m_lineWidth)); + line.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Shader program + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + // Frame vertices + + float windowWidth = static_cast(m_windowSize.x()); + float windowHeight = static_cast(m_windowSize.y()); + + std::array vertexArray = { + + Vec3f( 0.0f , 0.0f , 0.0f), + Vec3f( windowWidth , 0.0f , 0.0f), + Vec3f( windowWidth , windowHeight , 0.0f), + Vec3f( 0.0f , windowHeight , 0.0f), + Vec3f( m_frameBorderWidth , m_frameBorderHeight, 0.0f), + Vec3f( windowWidth - m_frameBorderWidth, m_frameBorderHeight, 0.0f), + Vec3f( windowWidth - m_frameBorderWidth, windowHeight , 0.0f), + Vec3f( m_frameBorderWidth , windowHeight , 0.0f), + + }; + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray.data()); + + // Draw frame background + + UniformFloat backgroundColorUniform("u_color", Color4f(1.0f, 1.0f, 1.0f, 0.5f)); + shaderProgram->applyUniform(oglContext, backgroundColorUniform); + + // Triangle indices for the frame background + + static const ushort trianglesConnects[] = { 0, 1, 5, 0, 5, 4, + 1, 2, 6, 1, 6, 5, + 3, 0, 4, 3, 4, 7 }; + + glDrawRangeElements(GL_TRIANGLES, 0, 7, 18, GL_UNSIGNED_SHORT, trianglesConnects); + + + // Draw frame border lines + + UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + shaderProgram->applyUniform(oglContext, uniformColor); + + static const ushort frameLineIndices[] = { 7, 4, + 4, 5, + 5, 6 }; + + glDrawRangeElements(GL_LINES, 0, 7, 6, GL_UNSIGNED_SHORT, frameLineIndices); + + // Render tickmarks + + static const ushort tickLineIndices[] = { 0, 1 }; + + // X - axis Tick lines + + for (double txpos : m_windowTickXValues) + { + vertexArray[0][0] = (float)txpos; + vertexArray[0][1] = m_frameBorderHeight; + vertexArray[1][0] = (float)txpos; + vertexArray[1][1] = m_frameBorderHeight - m_tickLineLength; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + } + + // Left Y - axis Tick lines + + for (double typos : m_windowTickYValues) + { + vertexArray[0][0] = m_frameBorderWidth; + vertexArray[0][1] = (float)typos; + vertexArray[1][0] = m_frameBorderWidth - m_tickLineLength; + vertexArray[1][1] = (float)typos; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + + vertexArray[0][0] = m_windowSize.x() - m_frameBorderWidth; + vertexArray[0][1] = (float)typos; + vertexArray[1][0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength; + vertexArray[1][1] = (float)typos; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + } + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 8cd449bc81..8acc466cfe 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -104,6 +104,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem void updateGeomerySizes(); void renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); void renderSoftwareFrameAndTickLines(OpenGLContext* oglContext); + void renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState); void addTextToTextDrawer(TextDrawer* textDrawer); private: From 2e8a497989738bb67a0e0a8ce66e2b9a3205f341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 13 Feb 2018 12:53:50 +0100 Subject: [PATCH 0249/1027] #2461 Align the vertices between shader and fixed function rendering methods. --- .../RivWindowEdgeAxesOverlayItem.cpp | 109 ++++++++---------- .../RivWindowEdgeAxesOverlayItem.h | 20 ++-- 2 files changed, 57 insertions(+), 72 deletions(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index be10ebe03d..88e2717939 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -339,6 +339,28 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivWindowEdgeAxesOverlayItem::frameVertexArray() +{ + float windowWidth = static_cast(m_windowSize.x()); + float windowHeight = static_cast(m_windowSize.y()); + + std::array vertexArray ={ + Vec3f(0.0f , 0.0f , 0.0f), + Vec3f(windowWidth , 0.0f , 0.0f), + Vec3f(windowWidth , windowHeight , 0.0f), + Vec3f(0.0f , windowHeight , 0.0f), + Vec3f(m_frameBorderWidth , m_frameBorderHeight, 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, m_frameBorderHeight, 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, windowHeight , 0.0f), + Vec3f(m_frameBorderWidth , windowHeight , 0.0f), + }; + + return vertexArray; +} + //-------------------------------------------------------------------------------------------------- /// Draw the legend using immediate mode OpenGL //-------------------------------------------------------------------------------------------------- @@ -355,51 +377,27 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext blend.applyOpenGL(oglContext); // Frame vertices - - Vec3f v0(Vec3f::ZERO); - Vec3f v1(Vec3f::ZERO); - Vec3f v2(Vec3f::ZERO); - Vec3f v3(Vec3f::ZERO); - Vec3f v4(Vec3f::ZERO); - Vec3f v5(Vec3f::ZERO); - Vec3f v6(Vec3f::ZERO); - Vec3f v7(Vec3f::ZERO); - - v1[0] = static_cast(m_windowSize.x()); - v2[0] = static_cast(m_windowSize.x()); - v2[1] = static_cast(m_windowSize.y()); - v3[1] = static_cast(m_windowSize.y()); - - v4[0] = m_frameBorderWidth; - v4[1] = m_frameBorderHeight; - - v5[0] = v1[0] - m_frameBorderWidth; - v5[1] = m_frameBorderHeight; - v6[0] = v2[0] - m_frameBorderWidth; - v6[1] = v2[1]; - - v7[0] = m_frameBorderWidth; - v7[1] = v3[1]; + std::array vertexArray = frameVertexArray(); glColor4fv(Vec4f(1.0f,1.0f,1.0f,0.5f).ptr()); glBegin(GL_TRIANGLE_FAN); - glVertex3fv(v0.ptr()); - glVertex3fv(v1.ptr()); - glVertex3fv(v5.ptr()); - glVertex3fv(v4.ptr()); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[4].ptr()); glEnd(); glBegin(GL_TRIANGLE_FAN); - glVertex3fv(v1.ptr()); - glVertex3fv(v2.ptr()); - glVertex3fv(v6.ptr()); - glVertex3fv(v5.ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[5].ptr()); glEnd(); glBegin(GL_TRIANGLE_FAN); - glVertex3fv(v3.ptr()); - glVertex3fv(v0.ptr()); - glVertex3fv(v4.ptr()); - glVertex3fv(v7.ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[7].ptr()); glEnd(); @@ -409,12 +407,12 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext glColor3fv(m_lineColor.ptr()); glBegin(GL_LINES); // Frame lines - glVertex3fv(v7.ptr()); - glVertex3fv(v4.ptr()); - glVertex3fv(v4.ptr()); - glVertex3fv(v5.ptr()); - glVertex3fv(v5.ptr()); - glVertex3fv(v6.ptr()); + glVertex3fv(vertexArray[7].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[6].ptr()); // X - axis Tick lines for (double txpos : m_windowTickXValues) @@ -497,22 +495,7 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* } // Frame vertices - - float windowWidth = static_cast(m_windowSize.x()); - float windowHeight = static_cast(m_windowSize.y()); - - std::array vertexArray = { - - Vec3f( 0.0f , 0.0f , 0.0f), - Vec3f( windowWidth , 0.0f , 0.0f), - Vec3f( windowWidth , windowHeight , 0.0f), - Vec3f( 0.0f , windowHeight , 0.0f), - Vec3f( m_frameBorderWidth , m_frameBorderHeight, 0.0f), - Vec3f( windowWidth - m_frameBorderWidth, m_frameBorderHeight, 0.0f), - Vec3f( windowWidth - m_frameBorderWidth, windowHeight , 0.0f), - Vec3f( m_frameBorderWidth , windowHeight , 0.0f), - - }; + std::array vertexArray = frameVertexArray(); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray(ShaderProgram::VERTEX); @@ -525,11 +508,11 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* // Triangle indices for the frame background - static const ushort trianglesConnects[] = { 0, 1, 5, 0, 5, 4, - 1, 2, 6, 1, 6, 5, - 3, 0, 4, 3, 4, 7 }; + static const ushort backgroundTriangleIndices[] = { 0, 1, 5, 0, 5, 4, + 1, 2, 6, 1, 6, 5, + 3, 0, 4, 3, 4, 7 }; - glDrawRangeElements(GL_TRIANGLES, 0, 7, 18, GL_UNSIGNED_SHORT, trianglesConnects); + glDrawRangeElements(GL_TRIANGLES, 0, 7, 18, GL_UNSIGNED_SHORT, backgroundTriangleIndices); // Draw frame border lines diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 8acc466cfe..229906929f 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -74,6 +74,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem using Color3f = cvf::Color3f; using String = cvf::String; using Vec2f = cvf::Vec2f; + using Vec3f = cvf::Vec3f; using Rectf = cvf::Rectf; using DoubleArray = cvf::DoubleArray; using MatrixState = cvf::MatrixState; @@ -95,18 +96,19 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem int frameBorderHeight() { return static_cast( m_frameBorderHeight); } protected: - virtual Vec2ui sizeHint(); - virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); - virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); - virtual bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size); + Vec2ui sizeHint() override; + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) override; private: - void updateGeomerySizes(); - void renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); - void renderSoftwareFrameAndTickLines(OpenGLContext* oglContext); - void renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState); - void addTextToTextDrawer(TextDrawer* textDrawer); + void updateGeomerySizes(); + void renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); + void renderSoftwareFrameAndTickLines(OpenGLContext* oglContext); + void renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState); + void addTextToTextDrawer(TextDrawer* textDrawer); + std::array frameVertexArray(); private: cvf::cref m_dispalyCoordsTransform; From 4eb80e83bb7f9f9775571e36a0843a21e25ef451 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Feb 2018 13:29:44 +0100 Subject: [PATCH 0250/1027] #2465 Property panel: Update UI fields from selected result on tree view object changed --- .../ProjectDataModel/RimCellEdgeColors.cpp | 8 ++++ .../ProjectDataModel/RimCellEdgeColors.h | 3 ++ .../RimEclipseFaultColors.cpp | 8 ++++ .../ProjectDataModel/RimEclipseFaultColors.h | 2 + .../RimEclipsePropertyFilter.cpp | 8 ++++ .../RimEclipsePropertyFilter.h | 6 ++- .../RimEclipseResultDefinition.cpp | 9 ++++ .../RimEclipseResultDefinition.h | 1 + .../UserInterface/RiuMainWindow.cpp | 47 +++++++++++++++++-- ApplicationCode/UserInterface/RiuMainWindow.h | 3 ++ 10 files changed, 90 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp index 3263a4ed79..b42817b761 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -497,6 +497,14 @@ void RimCellEdgeColors::posNegClosestToZero(double& pos, double& neg) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellEdgeColors::updateUiFieldsFromActiveResult() +{ + m_singleVarEdgeResultColors->updateUiFieldsFromActiveResult(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h index 409208e767..b427a94ea7 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h @@ -91,6 +91,9 @@ class RimCellEdgeColors : public caf::PdmObject void minMaxCellEdgeValues(double& min, double& max); void posNegClosestToZero(double& pos, double& neg); + + void updateUiFieldsFromActiveResult(); + protected: virtual void initAfterRead(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index 32a9b6918a..f9d8e2f982 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -97,6 +97,14 @@ RimEclipseCellColors* RimEclipseFaultColors::customFaultResult() return this->m_customFaultResultColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseFaultColors::updateUiFieldsFromActiveResult() +{ + m_customFaultResultColors->updateUiFieldsFromActiveResult(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h index 458f185e45..2856bf484e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h @@ -46,6 +46,8 @@ class RimEclipseFaultColors : public caf::PdmObject bool hasValidCustomResult(); RimEclipseCellColors* customFaultResult(); + void updateUiFieldsFromActiveResult(); + protected: virtual void initAfterRead(); virtual caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index c3ea14ccd4..f771a2cebf 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -548,3 +548,11 @@ void RimEclipsePropertyFilter::initAfterRead() resultDefinition->setEclipseCase(parentContainer()->reservoirView()->eclipseCase()); updateIconState(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipsePropertyFilter::updateUiFieldsFromActiveResult() +{ + resultDefinition->updateUiFieldsFromActiveResult(); +} diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h index 36562035d8..506fb9a1b1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h @@ -49,8 +49,10 @@ class RimEclipsePropertyFilter : public RimPropertyFilter void computeResultValueRange(); void updateFromCurrentTimeStep(); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void initAfterRead(); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void initAfterRead() override; + + void updateUiFieldsFromActiveResult(); protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index b42f0bb858..cab12ec2de 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1060,6 +1060,15 @@ void RimEclipseResultDefinition::setSelectedSouringTracers(const std::vectorm_selectedSouringTracersUiField = selectedTracers; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateUiFieldsFromActiveResult() +{ + m_resultTypeUiField = m_resultType; + m_resultVariableUiField = resultVariable(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 8e7aeb4058..d9d1ff188b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -99,6 +99,7 @@ class RimEclipseResultDefinition : public caf::PdmObject void setSelectedTracers(const std::vector& selectedTracers); void setSelectedSouringTracers(const std::vector& selectedTracers); + void updateUiFieldsFromActiveResult(); protected: virtual void updateLegendCategorySettings() {}; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e4b1099b7e..25a115c2df 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -25,15 +25,19 @@ #include "RiaPreferences.h" #include "RiaRegressionTest.h" +#include "Rim3dView.h" +#include "RimCellEdgeColors.h" #include "RimCommandObject.h" #include "RimEclipseCase.h" +#include "RimEclipseFaultColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" #include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" #include "RimProject.h" #include "RimSimWellInViewCollection.h" -#include "Rim3dView.h" #include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" @@ -41,13 +45,13 @@ #include "RiuProcessMonitor.h" #include "RiuProjectPropertyView.h" #include "RiuPropertyViewTabWidget.h" +#include "RiuPvtPlotPanel.h" +#include "RiuRelativePermeabilityPlotPanel.h" #include "RiuResultInfoPanel.h" #include "RiuResultQwtPlot.h" #include "RiuToolTipMenu.h" #include "RiuTreeViewEventFilter.h" #include "RiuViewer.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuPvtPlotPanel.h" #include "cafAnimationToolBar.h" #include "cafCmdExecCommandManager.h" @@ -1257,6 +1261,9 @@ void RiuMainWindow::selectedObjectsChanged() { firstSelectedObject = dynamic_cast(uiItems[0]); } + + updateUiFieldsFromActiveResult(firstSelectedObject); + m_pdmUiPropertyView->showProperties(firstSelectedObject); if (uiItems.size() == 1) @@ -1539,6 +1546,40 @@ void RiuMainWindow::showDockPanel(const QString &dockPanelName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectToUpdate) +{ + RimEclipseResultDefinition* resultDefinition = nullptr; + resultDefinition = dynamic_cast(objectToUpdate); + if (resultDefinition) + { + resultDefinition->updateUiFieldsFromActiveResult(); + } + + RimEclipsePropertyFilter* eclPropFilter = nullptr; + eclPropFilter = dynamic_cast(objectToUpdate); + if (eclPropFilter) + { + eclPropFilter->updateUiFieldsFromActiveResult(); + } + + RimEclipseFaultColors* eclFaultColors = nullptr; + eclFaultColors = dynamic_cast(objectToUpdate); + if (eclFaultColors) + { + eclFaultColors->updateUiFieldsFromActiveResult(); + } + + RimCellEdgeColors* cellEdgeColors = nullptr; + cellEdgeColors = dynamic_cast(objectToUpdate); + if (cellEdgeColors) + { + cellEdgeColors->updateUiFieldsFromActiveResult(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 0d1c6f1df1..8a6c4ff3b9 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -23,6 +23,7 @@ #include "RiuMainWindowBase.h" #include "cafPdmUiDragDropInterface.h" +#include "cafPdmObjectHandle.h" #include #include @@ -133,6 +134,8 @@ class RiuMainWindow : public RiuMainWindowBase void showDockPanel(const QString& dockPanelName); + void updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectToUpdate); + private: static RiuMainWindow* sm_mainWindowInstance; From 3b627ce1c4ab7e0d30f2d90ae6b75478250d8ba7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Feb 2018 14:01:37 +0100 Subject: [PATCH 0251/1027] #2413 2D Intersection View: Add geoMech result title to infoText --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 2 +- .../ProjectDataModel/RimLegendConfig.cpp | 15 +++++++++++++++ .../ProjectDataModel/RimLegendConfig.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index b00b9626d2..b15d08dc4e 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -387,7 +387,7 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(geoView); if (geoView) { - overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->resultVariableName() + "
"; + overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->title() + "
"; m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 6baafb6d97..3457a5dec1 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -674,6 +674,21 @@ void RimLegendConfig::setTitle(const QString& title) m_categoryLegend->setTitle(cvfTitle); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimLegendConfig::title() const +{ + if (m_currentScalarMapper == m_categoryMapper) + { + return cvfqt::Utils::toQString(m_categoryLegend->title()); + } + else + { + return cvfqt::Utils::toQString(m_scalarMapperLegend->title()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 41f0da15e8..24a9dd7d05 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -115,6 +115,7 @@ class RimLegendConfig: public caf::PdmObject QString categoryNameFromCategoryValue(double categoryResultValue) const; void setTitle(const QString& title); + QString title() const; void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); From cb38d435cd3588d7999b34b58c87bd69365aeab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 13 Feb 2018 16:56:48 +0100 Subject: [PATCH 0252/1027] #2457 Make 2d intersection view length start at well start --- .../RivIntersectionGeometryGenerator.cpp | 8 ++++-- .../RivIntersectionGeometryGenerator.h | 4 ++- .../Intersections/RivIntersectionPartMgr.cpp | 11 ++++++-- .../ProjectDataModel/RimIntersection.cpp | 28 +++++++++++++++++-- .../ProjectDataModel/RimIntersection.h | 4 +-- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 981b1edee4..6a0216e485 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -45,12 +45,14 @@ RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersect std::vector > &polylines, const cvf::Vec3d& extrusionDirection, const RivIntersectionHexGridInterface* grid, - bool isFlattened) + bool isFlattened, + double horizontalLengthAlongWellToPolylineStart) : m_crossSection(crossSection), m_polyLines(polylines), m_extrusionDirection(extrusionDirection), m_hexGrid(grid), - m_isFlattened(isFlattened) + m_isFlattened(isFlattened), + m_horizontalLengthAlongWellToPolylineStart(horizontalLengthAlongWellToPolylineStart) { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; @@ -109,7 +111,7 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() m_segementTransformPrLinePoint.clear(); - double previousSectionFlattenedEndPosX = 0.0; + double previousSectionFlattenedEndPosX = m_horizontalLengthAlongWellToPolylineStart; cvf::Vec3d previousSectionOrigo(cvf::Vec3d::ZERO); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 5feedf30fe..edf1676894 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -50,7 +50,8 @@ class RivIntersectionGeometryGenerator : public cvf::Object std::vector > &polylines, const cvf::Vec3d& extrusionDirection, const RivIntersectionHexGridInterface* grid, - bool isFlattened ); + bool isFlattened, + double horizontalLengthAlongWellToPolylineStart); ~RivIntersectionGeometryGenerator(); @@ -88,6 +89,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object const std::vector > m_polyLines; cvf::Vec3d m_extrusionDirection; bool m_isFlattened; + double m_horizontalLengthAlongWellToPolylineStart; // Output arrays cvf::ref m_triangleVxes; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 83d3c90f1e..1139025620 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -81,13 +81,20 @@ RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, CVF_ASSERT(m_rimCrossSection); m_crossSectionFacesTextureCoords = new cvf::Vec2fArray; + + double horizontalLengthAlongWellToPolylineStart; - std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(); + std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(&horizontalLengthAlongWellToPolylineStart); if (polyLines.size() > 0) { cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); cvf::ref hexGrid = createHexGridInterface(); - m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p(), m_isFlattened); + m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, + polyLines, + direction, + hexGrid.p(), + m_isFlattened, + horizontalLengthAlongWellToPolylineStart); } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 7755774eed..091ef10bdf 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -392,15 +392,19 @@ void RimIntersection::updateAzimuthLine() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > RimIntersection::polyLines() const +std::vector< std::vector > RimIntersection::polyLines(double * horizontalLengthAlongWellToPolylineStart) const { + CVF_ASSERT(horizontalLengthAlongWellToPolylineStart != nullptr); + std::vector< std::vector > lines; + double horizontalProjectedLengthAlongWellPathToClipPoint = 0.0; + if (horizontalLengthAlongWellToPolylineStart) *horizontalLengthAlongWellToPolylineStart = 0.0; if (type == CS_WELL_PATH) { if (wellPath() && wellPath->wellPathGeometry() ) { lines.push_back(wellPath->wellPathGeometry()->m_wellPathPoints); - clipToReservoir(lines[0]); + clipToReservoir(lines[0], &horizontalProjectedLengthAlongWellPathToClipPoint); } } else if (type == CS_SIMULATION_WELL) @@ -436,6 +440,11 @@ std::vector< std::vector > RimIntersection::polyLines() const std::vector& polyLine = lines[lIdx]; addExtents(polyLine); } + + if (horizontalLengthAlongWellToPolylineStart) + { + *horizontalLengthAlongWellToPolylineStart = horizontalProjectedLengthAlongWellPathToClipPoint - m_extentLength; + } } return lines; @@ -592,8 +601,11 @@ void RimIntersection::updateName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersection::clipToReservoir(std::vector &polyLine) const +void RimIntersection::clipToReservoir(std::vector &polyLine, double * horizontalLengthAlongWellToClipPoint) const { + CVF_ASSERT(horizontalLengthAlongWellToClipPoint != nullptr); + + *horizontalLengthAlongWellToClipPoint = 0.0; RimCase* ownerCase = nullptr; firstAncestorOrThisOfType(ownerCase); @@ -607,6 +619,12 @@ void RimIntersection::clipToReservoir(std::vector &polyLine) const { if (!caseBB.contains(polyLine[vxIdx])) { + if (vxIdx > 0) + { + cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + } continue; } @@ -621,6 +639,10 @@ void RimIntersection::clipToReservoir(std::vector &polyLine) const if (topPlane.intersect(polyLine[vxIdx-1], polyLine[vxIdx], &intersection)) { + cvf::Vec3d segment = intersection - polyLine[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + clippedPolyLine.push_back(intersection); } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 80b72836bc..7942eaa659 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -84,7 +84,7 @@ class RimIntersection : public caf::PdmObject caf::PdmField< bool > inputExtrusionPointsFromViewerEnabled; caf::PdmField< bool > inputTwoAzimuthPointsFromViewerEnabled; - std::vector< std::vector > polyLines() const; + std::vector< std::vector > polyLines(double * horizontalLengthAlongWellToPolylineStart = nullptr) const; void appendPointToPolyLine(const cvf::Vec3d& point); Rim2dIntersectionView* correspondingIntersectionView(); @@ -133,7 +133,7 @@ class RimIntersection : public caf::PdmObject void updateWellCenterline() const; void updateWellExtentDefaultValue(); void addExtents(std::vector &polyLine) const; - void clipToReservoir(std::vector &polyLine) const; + void clipToReservoir(std::vector &polyLinee, double * horizontalLengthAlongWellToClipPoint) const; void updateName(); void rebuildGeometryAndScheduleCreateDisplayModel(); static double azimuthInRadians(cvf::Vec3d vec); From eedf1826203e51f155b2c5728d6903eabc678c78 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 14 Feb 2018 10:54:28 +0100 Subject: [PATCH 0253/1027] #2413 2D intersection view: Use correct cell result in infoText --- .../Rim2dIntersectionView.cpp | 36 ++++++++++++++++--- .../ProjectDataModel/RimLegendConfig.cpp | 15 -------- .../ProjectDataModel/RimLegendConfig.h | 1 - 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index b15d08dc4e..6da4b6a41d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -340,9 +340,6 @@ void Rim2dIntersectionView::updateLegends() if (!hasResults()) return; - RimCase* rimCase = nullptr; - m_intersection->firstAncestorOrThisOfType(rimCase); - QString overlayInfoText; overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; @@ -387,7 +384,38 @@ void Rim2dIntersectionView::updateLegends() m_intersection->firstAncestorOrThisOfType(geoView); if (geoView) { - overlayInfoText += "Cell Result: " + geoView->cellResult()->legendConfig()->title() + "
"; + QString resultPos; + QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); + QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); + + switch (geoView->cellResultResultDefinition()->resultPositionType()) + { + case RIG_NODAL: + resultPos = "Nodal"; + break; + + case RIG_ELEMENT_NODAL: + resultPos = "Element nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration point"; + break; + + case RIG_ELEMENT: + resultPos = "Element"; + break; + default: + break; + } + if (compName == "") + { + overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); + } + else + { + overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); + } m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 3457a5dec1..6baafb6d97 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -674,21 +674,6 @@ void RimLegendConfig::setTitle(const QString& title) m_categoryLegend->setTitle(cvfTitle); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimLegendConfig::title() const -{ - if (m_currentScalarMapper == m_categoryMapper) - { - return cvfqt::Utils::toQString(m_categoryLegend->title()); - } - else - { - return cvfqt::Utils::toQString(m_scalarMapperLegend->title()); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 24a9dd7d05..41f0da15e8 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -115,7 +115,6 @@ class RimLegendConfig: public caf::PdmObject QString categoryNameFromCategoryValue(double categoryResultValue) const; void setTitle(const QString& title); - QString title() const; void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); From 302edc56774d3e17563672529b84f0ff1649d8b8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 08:14:49 +0100 Subject: [PATCH 0254/1027] System : Guard null pointer access --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 41dd149ced..81454a3b5f 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -186,10 +186,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - CVF_ASSERT(activeView); + if (activeView) + { + cvf::ref transForm = activeView->displayCoordTransform(); + m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint); + } - cvf::ref transForm = activeView->displayCoordTransform(); - m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint); } if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT) From 646eb8fee4fcd20696bdd097c5b9927ac9bb8c2b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 09:35:02 +0100 Subject: [PATCH 0255/1027] StimPlan Fracture : Make sure geometry is recomputed when required --- ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp | 4 ---- .../Completions/RimStimPlanFractureTemplate.cpp | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 419af4ac66..d7ab81bd53 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -870,10 +870,6 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshPart(const RimEcli //-------------------------------------------------------------------------------------------------- cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const { - //TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps. - //Should probably be moved, since it now is called twice in some cases... - stimPlanFracTemplate->updateFractureGrid(); - if (!stimPlanFracTemplate->fractureGrid()) return nullptr; auto displayCoordTransform = activeView.displayCoordTransform(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index cea4b35538..50d31e665f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -113,8 +113,6 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch if (&m_activeTimeStepIndex == changedField) { - updateFractureGrid(); - //Changes to this parameters should change all fractures with this fracture template attached. RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -145,6 +143,8 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch || &m_stimPlanFileName == changedField || &m_conductivityResultNameOnFile == changedField) { + updateFractureGrid(); + RimProject* proj; this->firstAncestorOrThisOfType(proj); if (proj) From 03f4b778cce9bea6b6b6d20c9517929598ccd8b8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 10:55:06 +0100 Subject: [PATCH 0256/1027] #2471 Fracture : Block selection of fracture if fracture template is selected in Project Tree --- .../UserInterface/RiuViewerCommands.cpp | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 81454a3b5f..f70fff7fa4 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -77,9 +77,10 @@ #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" +#include "cafCmdFeatureMenuBuilder.h" #include "cafDisplayCoordTransform.h" +#include "cafPdmUiTreeView.h" #include "cafSelectionManager.h" -#include "cafCmdFeatureMenuBuilder.h" #include "cvfDrawableGeo.h" #include "cvfHitItemCollection.h" @@ -499,9 +500,32 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (rivObjectSourceInfo) { #ifdef USE_PROTOTYPE_FEATURE_FRACTURES - RiuMainWindow::instance()->selectAsCurrentItem(rivObjectSourceInfo->object()); - RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); + { + bool blockSelectionOfFracture = false; + if (fracture) + { + std::vector uiItems; + RiuMainWindow::instance()->projectTreeView()->selectedUiItems(uiItems); + + if (uiItems.size() == 1) + { + auto selectedFractureTemplate = dynamic_cast(uiItems[0]); + + if (selectedFractureTemplate != nullptr && selectedFractureTemplate == fracture->fractureTemplate()) + { + blockSelectionOfFracture = true; + } + } + } + + if (!blockSelectionOfFracture) + { + RiuMainWindow::instance()->selectAsCurrentItem(fracture); + } + } + + RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; if (stimPlanTempl || ellipseTempl) From 1a78490991ca4cca5e1618033f26020799990099 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 13:27:50 +0100 Subject: [PATCH 0257/1027] Fix warnings related to signed / unsigned compare --- ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 1678fc81f0..183da9b2e5 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -107,7 +107,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi std::vector elmTensors; elmTensors.resize(elmCount); - for (int elmIdx = 0; elmIdx < elmCount; elmIdx++) + for (int elmIdx = 0; elmIdx < static_cast(elmCount); elmIdx++) { if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) { @@ -168,7 +168,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); - for (int quadIdx = 0; quadIdx < quadVerticesToNodeIdxMapping.size(); quadIdx = quadIdx + 4) + for (int quadIdx = 0; quadIdx < static_cast(quadVerticesToNodeIdxMapping.size()); quadIdx = quadIdx + 4) { cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx]) + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx + 2]); From f9bded9c13453d951cdcb62df94de1d3c1890efb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 13:34:38 +0100 Subject: [PATCH 0258/1027] #2455 Fracture : Move code to cpp and restructure header --- .../RigStimPlanFractureDefinition.cpp | 89 ++++++++++++ .../RigStimPlanFractureDefinition.h | 131 +++++++++--------- 2 files changed, 154 insertions(+), 66 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index d0f3e6bbf2..758ccfb488 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -20,6 +20,7 @@ #include "RiaFractureDefines.h" #include "RiaLogging.h" + #include "RigFractureCell.h" #include "RigFractureGrid.h" #include "RigStatisticsMath.h" @@ -57,6 +58,78 @@ RigStimPlanFractureDefinition::~RigStimPlanFractureDefinition() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaEclipseUnitTools::UnitSystem RigStimPlanFractureDefinition::unitSet() const +{ + return m_unitSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigStimPlanFractureDefinition::xCount() const +{ + return m_Xs.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigStimPlanFractureDefinition::yCount() const +{ + return m_Ys.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::minDepth() const +{ + return -minY(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::maxDepth() const +{ + return -maxY(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::topPerfTvd() const +{ + return m_topPerfTvd; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::bottomPerfTvd() const +{ + return m_bottomPerfTvd; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::minY() const +{ + return m_Ys[0]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::maxY() const +{ + return m_Ys.back(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -533,6 +606,22 @@ std::vector RigStimPlanFractureDefinition::createFractureBorderPolyg return polygon; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigStimPlanFractureDefinition::timeSteps() const +{ + return m_timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::addTimeStep(double time) +{ + if (!timeStepExists(time)) m_timeSteps.push_back(time); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 3a667d2f31..c0e5788903 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -18,18 +18,23 @@ #pragma once +#include "RiaEclipseUnitTools.h" + #include "cvfBase.h" #include "cvfObject.h" +#include "cvfVector3.h" + #include #include -#include "RiaEclipseUnitTools.h" -#include "cvfVector3.h" class RigFractureGrid; class MinMaxAccumulator; class PosNegAccumulator; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigStimPlanResultFrames { public: @@ -43,6 +48,9 @@ class RigStimPlanResultFrames }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigStimPlanFractureDefinition: public cvf::Object { friend class RifStimPlanXmlReader; @@ -53,84 +61,75 @@ class RigStimPlanFractureDefinition: public cvf::Object RigStimPlanFractureDefinition(); ~RigStimPlanFractureDefinition(); - RiaEclipseUnitTools::UnitSystem unitSet() const { return m_unitSet; } - size_t xCount() const { return m_Xs.size(); } - size_t yCount() const { return m_Ys.size(); } - double minY() const { return m_Ys[0]; } - double maxY() const { return m_Ys.back(); } + RiaEclipseUnitTools::UnitSystem unitSet() const; + size_t xCount() const; + size_t yCount() const; + double minDepth() const; + double maxDepth() const; + double topPerfTvd() const; + double bottomPerfTvd() const; + void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); + void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); + + cvf::ref createFractureGrid(const QString& resultName, + int activeTimeStepIndex, + RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, + double wellPathIntersectionAtFractureDepth); + + void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem neededUnit, + const QString& fractureUserName, + std::vector* vertices, + std::vector* triangleIndices); + + std::vector createFractureBorderPolygon(const QString& resultName, + const QString& resultUnit, + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem neededUnit, + const QString& fractureUserName); + + const std::vector& timeSteps() const; + void addTimeStep(double time); + size_t totalNumberTimeSteps(); + + std::vector> getStimPlanPropertyNamesUnits() const; + + void setDataAtTimeValue(QString resultName, + QString unit, + std::vector> data, + double timeStepValue); + + const std::vector>& getDataAtTimeIndex(const QString& resultName, + const QString& unit, + size_t timeStepIndex) const; - double minDepth() const { return -minY(); } - double maxDepth() const { return -maxY(); } + std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; - double topPerfTvd() const { return m_topPerfTvd; } - double bottomPerfTvd() const { return m_bottomPerfTvd; } - void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); - void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); + void appendDataToResultStatistics(const QString& resultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const; - void enableXMirrorMode(bool enable) { m_xMirrorMode = enable; } - bool xMirrorModeEnabled() const { return m_xMirrorMode; } + QStringList conductivityResultNames() const; private: + bool timeStepExists(double timeStepValue); + size_t getTimeStepIndex(double timeStepValue); + size_t resultIndex(const QString& resultName, const QString& unit) const; void generateXsFromFileXs(bool xMirrorMode); std::vector> generateDataLayoutFromFileDataLayout(std::vector> rawXYData); - - - std::vector adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const; -public: - - cvf::ref createFractureGrid(const QString& resultName, - int activeTimeStepIndex, - RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, - double wellPathIntersectionAtFractureDepth); - - - void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, - const QString& fractureUserName, - std::vector* vertices, - std::vector* triangleIndices); - - std::vector createFractureBorderPolygon(const QString& resultName, - const QString& resultUnit, - int activeTimeStepIndex, - double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, - const QString& fractureUserName); - // Result Access - - const std::vector& timeSteps() const { return m_timeSteps; } - void addTimeStep(double time) { if (!timeStepExists(time)) m_timeSteps.push_back(time); } - - std::vector > getStimPlanPropertyNamesUnits() const; -private: - bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); -public: - size_t totalNumberTimeSteps(); - void setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue); - const std::vector>& getDataAtTimeIndex(const QString& resultName, const QString& unit, size_t timeStepIndex) const; - std::vector fractureGridResults(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const; - - void appendDataToResultStatistics(const QString& resultName, const QString& unit, - MinMaxAccumulator& minMaxAccumulator, - PosNegAccumulator& posNegAccumulator) const; - - QStringList conductivityResultNames() const; - -private: - bool timeStepExists(double timeStepValue); - size_t getTimeStepIndex(double timeStepValue); - size_t resultIndex(const QString& resultName, const QString& unit) const; + std::vector adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const; + bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); + double minY() const; + double maxY() const; private: - // Data read from file RiaEclipseUnitTools::UnitSystem m_unitSet; std::vector m_fileXs; std::vector m_Ys; std::vector m_timeSteps; - // Modified file data std::vector m_stimPlanResults; std::vector m_Xs; bool m_xMirrorMode; From 8e1a7b2bbb5669acc5f360074d5cdb27a2ed03f7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Feb 2018 13:35:35 +0100 Subject: [PATCH 0259/1027] #2455 Non-Darcy Flow : Compute D-factor and show in UI --- .../Application/RiaFractureDefines.cpp | 13 ++ .../Application/RiaFractureDefines.h | 2 + .../RimEllipseFractureTemplate.cpp | 12 ++ .../Completions/RimEllipseFractureTemplate.h | 3 + .../Completions/RimFractureTemplate.cpp | 187 ++++++++++++++++-- .../Completions/RimFractureTemplate.h | 45 ++++- .../RimStimPlanFractureTemplate.cpp | 36 ++++ .../Completions/RimStimPlanFractureTemplate.h | 3 + 8 files changed, 281 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Application/RiaFractureDefines.cpp b/ApplicationCode/Application/RiaFractureDefines.cpp index 6fdbd19253..74f3b87d49 100644 --- a/ApplicationCode/Application/RiaFractureDefines.cpp +++ b/ApplicationCode/Application/RiaFractureDefines.cpp @@ -38,3 +38,16 @@ QString RiaDefines::unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitS default: return ""; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::nonDarcyFlowAlpha(RiaEclipseUnitTools::UnitSystem unitSystem) +{ + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return 2.24460e-10; + case RiaEclipseUnitTools::UNITS_FIELD: return 6.83352e-8; + default: return 0.0; + } +} diff --git a/ApplicationCode/Application/RiaFractureDefines.h b/ApplicationCode/Application/RiaFractureDefines.h index 7263302b2a..a87bbe5acf 100644 --- a/ApplicationCode/Application/RiaFractureDefines.h +++ b/ApplicationCode/Application/RiaFractureDefines.h @@ -26,4 +26,6 @@ namespace RiaDefines { QString conductivityResultName(); QString unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitSystem); + +double nonDarcyFlowAlpha(RiaEclipseUnitTools::UnitSystem unitSystem); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 0dbb68d214..9b5b2f46a4 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -270,6 +270,18 @@ void RimEllipseFractureTemplate::setupFractureGridCells() m_fractureGrid->setJCellCount(numberOfCellsY); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +FractureWidthAndConductivity RimEllipseFractureTemplate::widthAndConductivityAtWellPathIntersection() const +{ + FractureWidthAndConductivity values; + values.m_width = m_width; + values.m_permeability = m_permeability; + + return values; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 842da494a6..6b400456b1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -73,6 +73,9 @@ class RimEllipseFractureTemplate : public RimFractureTemplate private: void setupFractureGridCells(); + + virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; + private: cvf::ref m_fractureGrid; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index bc907c7146..9806acf644 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -18,6 +18,7 @@ #include "RimFractureTemplate.h" +#include "RiaFractureDefines.h" #include "RigTesselatorTools.h" #include "RimFracture.h" @@ -26,6 +27,7 @@ #include "cafPdmObject.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "cafPdmUiTextEditor.h" #include "cvfVector3.h" @@ -52,6 +54,15 @@ namespace caf setDefault(RimFractureTemplate::INFINITE_CONDUCTIVITY); } + template<> + void caf::AppEnum< RimFractureTemplate::EffectivePermeabilityEnum>::setUp() + { + addItem(RimFractureTemplate::USER_DEFINED_PERMEABILITY, "UserDefinedPermeability", "User Defined"); + addItem(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE, "FractureConductivity", "Use Fracture Conductivity"); + + setDefault(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE); + } + } @@ -90,11 +101,24 @@ RimFractureTemplate::RimFractureTemplate() // Non-Darcy Flow options CAF_PDM_InitField_Basic(&m_useNonDarcyFlow, "UseNonDarcyFlow", false, "Use Non-Darcy Flow"); - CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.0, "Fracture Width"); - CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.0, "Inertial Coefficient (beta)"); - CAF_PDM_InitField_Basic(&m_effectivePermeability, "EffectivePermeability",0.0, "Effective Permeability"); - CAF_PDM_InitField_Basic(&m_specificGasGravity, "SpecificGasGravity", 0.0, "Specific Gas Gravity"); - CAF_PDM_InitField_Basic(&m_gasViscosity, "GasViscosity", 0.0, "Gas Viscosity"); + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient"); + + CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); + CAF_PDM_InitField_Basic(&m_permeabilityScaleFactor,"EffectivePermeabilityScaleFactor", 1.0, "Scale Factor [0..1]"); + CAF_PDM_InitField(&m_permeability, "EffectivePermeability", 0.0, "Effective Permeability", "", "", ""); + + CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density", "", "Relative density of gas at surface conditions with respect to air at STP", ""); + CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity", "", "Gas viscosity at bottom hole pressure", ""); + + CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); + m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::computeDFactor); + m_dFactorDisplayField.uiCapability()->setUiReadOnly(true); + + CAF_PDM_InitFieldNoDefault(&m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", ""); + m_dFactorSummaryText.registerGetMethod(this, &RimFractureTemplate::dFactorSummary); + m_dFactorSummaryText.uiCapability()->setUiReadOnly(true); + m_dFactorSummaryText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); + m_dFactorSummaryText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP); } //-------------------------------------------------------------------------------------------------- @@ -241,11 +265,24 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder auto group = uiOrdering.addNewGroup("Non-Darcy Flow"); group->setCollapsedByDefault(true); group->add(&m_useNonDarcyFlow); - group->add(&m_fractureWidth); group->add(&m_inertialCoefficient); - group->add(&m_effectivePermeability); - group->add(&m_specificGasGravity); + + { + auto permGroup = group->addNewGroup("Effective Permeability"); + permGroup->add(&m_permeabilityType); + permGroup->add(&m_permeabilityScaleFactor); + permGroup->add(&m_permeability); + } + + group->add(&m_relativeGasDensity); group->add(&m_gasViscosity); + group->add(&m_dFactorDisplayField); + + { + auto dFactorGroup = group->addNewGroup("D Factor Details"); + dFactorGroup->setCollapsedByDefault(true); + dFactorGroup->add(&m_dFactorSummaryText); + } uiOrdering.add(&m_fractureTemplateUnit); } @@ -264,8 +301,20 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field myAttr->m_maximum = 1.0; } } -} + if (field == &m_dFactorSummaryText) + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap; + + QFont font("Monospace", 10); + myAttr->font = font; + myAttr->textMode = caf::PdmUiTextEditorAttribute::HTML; + } + } +} //-------------------------------------------------------------------------------------------------- /// @@ -314,19 +363,127 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() } // Non Darcy Flow - m_fractureWidth.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_inertialCoefficient.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_effectivePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_specificGasGravity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + + m_permeabilityType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_permeabilityScaleFactor.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_permeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + + m_relativeGasDensity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_gasViscosity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (m_useNonDarcyFlow) + { + if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) + { + m_permeabilityScaleFactor.uiCapability()->setUiHidden(true); + m_permeability.uiCapability()->setUiReadOnly(false); + } + else + { + m_permeabilityScaleFactor.uiCapability()->setUiHidden(false); + m_permeability.uiCapability()->setUiHidden(true); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFractureTemplate::dFactorSummary() const +{ + QString text; + + auto dFactor = computeDFactor(); + text += QString("D-factor : %1").arg(dFactor); + + text += "
"; + text += "
"; + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); + text += QString("α : %1").arg(alpha); + + text += "
"; + auto beta = m_inertialCoefficient; + text += QString("β : %1").arg(beta); + + text += "
"; + double effPerm = effectivePermeability(); + text += QString("Ke : %1").arg(effPerm); + + text += "
"; + double gamma = m_relativeGasDensity; + text += QString("γ : %1").arg(gamma); + + text += "
"; + auto h = nonDarcyH(); + text += QString("h : %1").arg(h); + + text += "
"; + auto wellRadius = m_wellDiameter / 2.0; + text += QString("rw : %1").arg(wellRadius); + + text += "
"; + auto mu = m_gasViscosity; + text += QString("μ : %1").arg(mu); + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::effectivePermeability() const +{ + if (m_permeabilityType() == RimFractureTemplate::USER_DEFINED_PERMEABILITY) + { + return m_permeability; + } + else + { + auto values = widthAndConductivityAtWellPathIntersection(); + + auto fracPermeability = values.m_permeability; + + return fracPermeability * m_permeabilityScaleFactor; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::computeDFactor() const +{ + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); + auto beta = m_inertialCoefficient; + auto effPerm = effectivePermeability(); + auto gamma = m_relativeGasDensity; + + auto radius = m_wellDiameter / 2.0; + auto mu = m_gasViscosity; + auto h = nonDarcyH(); + + double numerator = alpha * beta * effPerm * gamma; + double denumerator = h * radius * mu; + + if (denumerator < 1e-10) return HUGE_VAL; + + return numerator / denumerator; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::nonDarcyH() const +{ + if (m_orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { - m_fractureWidth.uiCapability()->setUiHidden(true); + return m_perforationLength(); } else { - m_fractureWidth.uiCapability()->setUiHidden(false); + auto values = widthAndConductivityAtWellPathIntersection(); + + return values.m_width; } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index a12b897f8b..3e1f60e774 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -21,11 +21,12 @@ #include "RiaEclipseUnitTools.h" #include "cafAppEnum.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmFieldCvfVec3d.h" #include "cafPdmFieldHandle.h" #include "cafPdmObject.h" -#include "cafPdmChildField.h" -#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmProxyValueField.h" #include "cvfBase.h" #include "cvfVector3.h" @@ -37,6 +38,19 @@ class RimFractureContainment; class MinMaxAccumulator; class PosNegAccumulator; +class FractureWidthAndConductivity +{ +public: + FractureWidthAndConductivity() + : m_width(0.0) + , m_permeability(0.0) + { + } + + double m_width; + double m_permeability; +}; + //================================================================================================== /// /// @@ -59,6 +73,12 @@ class RimFractureTemplate : public caf::PdmObject FINITE_CONDUCTIVITY, }; + enum EffectivePermeabilityEnum + { + USER_DEFINED_PERMEABILITY, + CONDUCTIVITY_FROM_FRACTURE, + }; + public: RimFractureTemplate(); virtual ~RimFractureTemplate(); @@ -99,6 +119,14 @@ class RimFractureTemplate : public caf::PdmObject private: void prepareFieldsForUiDisplay(); + virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const = 0; + + QString dFactorSummary() const; + double effectivePermeability() const; + + double computeDFactor() const; + double nonDarcyH() const; + protected: caf::PdmField m_name; @@ -113,9 +141,16 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmChildField m_fractureContainment; caf::PdmField m_useNonDarcyFlow; - caf::PdmField m_fractureWidth; caf::PdmField m_inertialCoefficient; - caf::PdmField m_effectivePermeability; - caf::PdmField m_specificGasGravity; + + caf::PdmField> + m_permeabilityType; + caf::PdmField m_permeabilityScaleFactor; + caf::PdmField m_permeability; + + caf::PdmField m_relativeGasDensity; caf::PdmField m_gasViscosity; + + caf::PdmProxyValueField m_dFactorDisplayField; + caf::PdmProxyValueField m_dFactorSummaryText; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 50d31e665f..be3061b0b4 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -402,6 +402,42 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +FractureWidthAndConductivity RimStimPlanFractureTemplate::widthAndConductivityAtWellPathIntersection() const +{ + FractureWidthAndConductivity values; + + if (m_fractureGrid.notNull()) + { + std::pair wellCellIJ = m_fractureGrid->fractureCellAtWellCenter(); + size_t wellCellIndex = m_fractureGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); + const RigFractureCell& wellCell = m_fractureGrid->cellFromIndex(wellCellIndex); + + double conductivity = wellCell.getConductivtyValue(); + + std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + for (const auto& nameUnit : propertyNamesUnitsOnFile) + { + if (nameUnit.first.contains("Width", Qt::CaseInsensitive)) + { + auto data = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + + double width = data[wellCellIndex]; + + if (fabs(width) > 1e-7) + { + values.m_width = width; + values.m_permeability = conductivity / width; + } + } + } + } + + return values; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 3d03ed2d86..f4e0cd4f6b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -104,6 +104,9 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void setPerforationLength(); QString getUnitForStimPlanParameter(QString parameterName); + + virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; + private: caf::PdmField m_activeTimeStepIndex; caf::PdmField m_conductivityResultNameOnFile; From 917857104d53a706f5a4cc2edaefa31497c06a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Feb 2018 18:39:14 +0100 Subject: [PATCH 0260/1027] Upped to version 2018.01.00-dev105 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 017720bf9b..df66bc3a6f 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".104") +set(RESINSIGHT_DEV_VERSION ".105") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 22ba541145adb2026f684f05d7c5684f7fb481f5 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 10:47:14 +0100 Subject: [PATCH 0261/1027] #2359 Tensor Vectors: Use lines to draw the vectors --- .../RivTensorResultPartMgr.cpp | 385 ++++++++++++------ .../RivTensorResultPartMgr.h | 48 ++- 2 files changed, 287 insertions(+), 146 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 183da9b2e5..c7e218a58c 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -18,14 +18,10 @@ #include "RivTensorResultPartMgr.h" -#include "RiaApplication.h" - #include "RimGeoMechCase.h" #include "RimGeoMechView.h" #include "RimTensorResults.h" -#include "RiuViewer.h" - #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" @@ -40,19 +36,14 @@ #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" -#include "cafPdmFieldCvfColor.h" #include "cafTensor3.h" -#include "cvfArrowGenerator.h" #include "cvfDrawableGeo.h" -#include "cvfDrawableVectors.h" -#include "cvfGeometryBuilderFaceList.h" -#include "cvfGeometryBuilderTriangles.h" -#include "cvfGeometryUtils.h" #include "cvfModelBasicList.h" -#include "cvfObject.h" #include "cvfOpenGLResourceManager.h" #include "cvfPart.h" +#include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfScalarMapperDiscreteLinear.h" #include "cvfShaderProgram.h" #include "cvfStructGridGeometryGenerator.h" @@ -76,6 +67,8 @@ RivTensorResultPartMgr::~RivTensorResultPartMgr() {} //-------------------------------------------------------------------------------------------------- void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const { + CVF_ASSERT(model); + if (m_rimReservoirView.isNull()) return; if (!m_rimReservoirView->geoMechCase()) return; if (!m_rimReservoirView->geoMechCase()->geoMechData()) return; @@ -87,11 +80,6 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi std::vector tensorVisualizations; - RimTensorResults::TensorColors tensorColor = m_rimReservoirView->tensorResults()->vectorColors(); - cvf::Color3f color1, color2, color3; - - assignColorVectors(tensorColor, &color1, &color2, &color3); - RigFemResultAddress address = m_rimReservoirView->tensorResults()->selectedTensorResult(); if (!isTensorAddress(address)) return; @@ -100,49 +88,17 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi for (int partIdx = 0; partIdx < femParts->partCount(); partIdx++) { - std::vector tensors = resultCollection->tensors(address, partIdx, (int)frameIndex); + std::vector vertexTensors = resultCollection->tensors(address, partIdx, (int)frameIndex); - const RigFemPart* part = femParts->part(partIdx); - size_t elmCount = part->elementCount(); + const RigFemPart* part = femParts->part(partIdx); std::vector elmTensors; - elmTensors.resize(elmCount); - for (int elmIdx = 0; elmIdx < static_cast(elmCount); elmIdx++) - { - if (RigFemTypes::elmentNodeCount(part->elementType(elmIdx)) == 8) - { - caf::Ten3f tensorSumOfElmNodes = tensors[part->elementNodeResultIdx(elmIdx, 0)]; - for (int i = 1; i < 8; i++) - { - tensorSumOfElmNodes = tensorSumOfElmNodes + tensors[part->elementNodeResultIdx(elmIdx, i)]; - } - - elmTensors[elmIdx] = tensorSumOfElmNodes * (1.0 / 8.0); - } - } + calculateElementTensors(*part, vertexTensors, &elmTensors); std::array, 3> elmPrincipals; std::vector> elmPrincipalDirections; - elmPrincipals[0].resize(elmCount); - elmPrincipals[1].resize(elmCount); - elmPrincipals[2].resize(elmCount); - - elmPrincipalDirections.resize(elmCount); - - for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) - { - cvf::Vec3f principalDirs[3]; - cvf::Vec3f principalValues = elmTensors[nIdx].calculatePrincipals(principalDirs); - - elmPrincipals[0][nIdx] = principalValues[0]; - elmPrincipals[1][nIdx] = principalValues[1]; - elmPrincipals[2][nIdx] = principalValues[2]; - - elmPrincipalDirections[nIdx][0] = principalDirs[0]; - elmPrincipalDirections[nIdx][1] = principalDirs[1]; - elmPrincipalDirections[nIdx][2] = principalDirs[2]; - } + calculatePrincipalsAndDirections(elmTensors, &elmPrincipals, &elmPrincipalDirections); std::vector partKeys = m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs((int)frameIndex); @@ -161,23 +117,23 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi for (const RivGeoMechPartMgrCache::Key& partKey : partKeys) { const RivGeoMechPartMgr* partMgr = partMgrCache->partMgr(partKey); - for (auto mgr : partMgr->femPartMgrs()) { const RivFemPartGeometryGenerator* surfaceGenerator = mgr->surfaceGenerator(); const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); - for (int quadIdx = 0; quadIdx < static_cast(quadVerticesToNodeIdxMapping.size()); quadIdx = quadIdx + 4) + for (int quadVertex = 0; quadVertex < static_cast(quadVerticesToNodeIdxMapping.size()); + quadVertex = quadVertex + 4) { - cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx]) + - nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadIdx + 2]); + cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) + + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); - cvf::Vec3d center3d(center / 2); + cvf::Vec3d displayCoord = m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(cvf::Vec3d(center/2)); - cvf::Vec3d displayCoord = m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(center3d); + cvf::Vec3f faceNormal = calculateFaceNormal(nodes, quadVerticesToNodeIdxMapping, quadVertex); - size_t elmIdx = quadVerticesToElmIdx[quadIdx]; + size_t elmIdx = quadVerticesToElmIdx[quadVertex]; cvf::Vec3f result1, result2, result3; @@ -196,25 +152,25 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (isDrawable(result1, m_rimReservoirView->tensorResults()->showPrincipal1())) { - tensorVisualizations.push_back( - TensorVisualization(cvf::Vec3f(displayCoord), result1, color1, isPressure(elmPrincipals[0][elmIdx]))); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result1, color1, isPressure(elmPrincipals[0][elmIdx]))); + cvf::Vec3f(displayCoord), result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1)); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1)); } if (isDrawable(result2, m_rimReservoirView->tensorResults()->showPrincipal2())) { - tensorVisualizations.push_back( - TensorVisualization(cvf::Vec3f(displayCoord), result2, color2, isPressure(elmPrincipals[1][elmIdx]))); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result2, color2, isPressure(elmPrincipals[1][elmIdx]))); + cvf::Vec3f(displayCoord), result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2)); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2)); } if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) { - tensorVisualizations.push_back( - TensorVisualization(cvf::Vec3f(displayCoord), result3, color3, isPressure(elmPrincipals[2][elmIdx]))); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result3, color3, isPressure(elmPrincipals[2][elmIdx]))); + cvf::Vec3f(displayCoord), result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3)); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3)); } } } @@ -231,103 +187,204 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivTensorResultPartMgr::createPart(std::vector& tensorVisualizations) const +void RivTensorResultPartMgr::calculateElementTensors(const RigFemPart& part, + const std::vector& vertexTensors, + std::vector* elmTensors) { - cvf::ref vertices = new cvf::Vec3fArray; - cvf::ref vecRes = new cvf::Vec3fArray; - cvf::ref colors = new cvf::Color3fArray; + CVF_ASSERT(elmTensors); - size_t numVecs = tensorVisualizations.size(); - vertices->reserve(numVecs); - vecRes->reserve(numVecs); - colors->reserve(numVecs); + size_t elmCount = part.elementCount(); + elmTensors->resize(elmCount); - for (TensorVisualization tensorVisualization : tensorVisualizations) + for (int elmIdx = 0; elmIdx < static_cast(elmCount); elmIdx++) { - if (tensorVisualization.isPressure) + if (RigFemTypes::elmentNodeCount(part.elementType(elmIdx)) == 8) { - vertices->add(tensorVisualization.vertex - tensorVisualization.result); - } - else - { - vertices->add(tensorVisualization.vertex); + caf::Ten3f tensorSumOfElmNodes = vertexTensors[part.elementNodeResultIdx(elmIdx, 0)]; + for (int i = 1; i < 8; i++) + { + tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[part.elementNodeResultIdx(elmIdx, i)]; + } + + (*elmTensors)[elmIdx] = tensorSumOfElmNodes * (1.0 / 8.0); } - vecRes->add(tensorVisualization.result); - colors->add(tensorVisualization.color); } - cvf::ref vectorDrawable; - if (RiaApplication::instance()->useShaders()) - { - // NOTE: Drawable vectors must be rendered using shaders when the rest of the application is rendered using shaders - // Drawing vectors using fixed function when rest of the application uses shaders causes visual artifacts - vectorDrawable = new cvf::DrawableVectors("u_transformationMatrix", "u_color"); - } - else + std::array, 3> elmPrincipals; + std::vector> elmPrincipalDirections; + + elmPrincipals[0].resize(elmCount); + elmPrincipals[1].resize(elmCount); + elmPrincipals[2].resize(elmCount); + + elmPrincipalDirections.resize(elmCount); + + for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) { - vectorDrawable = new cvf::DrawableVectors(); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principalValues = (*elmTensors)[nIdx].calculatePrincipals(principalDirs); + + elmPrincipals[0][nIdx] = principalValues[0]; + elmPrincipals[1][nIdx] = principalValues[1]; + elmPrincipals[2][nIdx] = principalValues[2]; + + elmPrincipalDirections[nIdx][0] = principalDirs[0]; + elmPrincipalDirections[nIdx][1] = principalDirs[1]; + elmPrincipalDirections[nIdx][2] = principalDirs[2]; } +} - // Create the arrow glyph for the vector drawer - cvf::GeometryBuilderTriangles arrowBuilder; - cvf::ArrowGenerator gen; - gen.setShaftRelativeRadius(0.020f); - gen.setHeadRelativeRadius(0.05f); - gen.setHeadRelativeLength(0.1f); - gen.setNumSlices(30); - gen.generate(&arrowBuilder); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::calculatePrincipalsAndDirections(const std::vector& tensors, + std::array, 3>* principals, + std::vector>* principalDirections) +{ + CVF_ASSERT(principals); + CVF_ASSERT(principalDirections); - vectorDrawable->setVectors(vertices.p(), vecRes.p()); - vectorDrawable->setColors(colors.p()); - vectorDrawable->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); + size_t elmCount = tensors.size(); - cvf::ref part = new cvf::Part; - part->setDrawable(vectorDrawable.p()); + (*principals)[0].resize(elmCount); + (*principals)[1].resize(elmCount); + (*principals)[2].resize(elmCount); - cvf::ref eff = new cvf::Effect; - if (RiaApplication::instance()->useShaders()) + (*principalDirections).resize(elmCount); + + for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) { - if (m_rimReservoirView->viewer()) - { - cvf::ref oglContext = m_rimReservoirView->viewer()->cvfOpenGLContext(); - cvf::OpenGLResourceManager* resourceManager = oglContext->resourceManager(); - cvf::ref vectorProgram = resourceManager->getLinkedVectorDrawerShaderProgram(oglContext.p()); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principalValues = tensors[nIdx].calculatePrincipals(principalDirs); - eff->setShaderProgram(vectorProgram.p()); - } + (*principals)[0][nIdx] = principalValues[0]; + (*principals)[1][nIdx] = principalValues[1]; + (*principals)[2][nIdx] = principalValues[2]; + + (*principalDirections)[nIdx][0] = principalDirs[0]; + (*principalDirections)[nIdx][1] = principalDirs[1]; + (*principalDirections)[nIdx][2] = principalDirs[2]; } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3f RivTensorResultPartMgr::calculateFaceNormal(const RigFemPartNodes& nodes, + const std::vector& quadVerticesToNodeIdxMapping, + int quadVertex) +{ + cvf::Vec3f diag1 = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) - + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); - part->setEffect(eff.p()); + cvf::Vec3f diag2 = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 1]) - + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 3]); - return part; + return (diag1 ^ diag2).getNormalized(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivTensorResultPartMgr::assignColorVectors(RimTensorResults::TensorColors tensorColor, - cvf::Color3f* color1, - cvf::Color3f* color2, - cvf::Color3f* color3) +cvf::ref RivTensorResultPartMgr::createPart(const std::vector& tensorVisualizations) const { - if (tensorColor == RimTensorResults::WHITE_GRAY_BLACK) + std::vector indices; + indices.reserve(tensorVisualizations.size() * 5); + + std::vector vertices; + vertices.reserve(tensorVisualizations.size() * 5); + + cvf::ref colors = new cvf::Color3ubArray(); + colors->reserve(tensorVisualizations.size() * 5); + + uint counter = 0; + for (TensorVisualization tensor : tensorVisualizations) { - *color1 = cvf::Color3f(cvf::Color3::WHITE); - *color2 = cvf::Color3f(cvf::Color3::GRAY); - *color3 = cvf::Color3f(cvf::Color3::BLACK); + for (const cvf::Vec3f& vertex : createArrowVertices(tensor)) + { + vertices.push_back(vertex); + } + + indices.push_back(counter); + indices.push_back(counter + 1); + indices.push_back(counter + 2); + indices.push_back(counter + 3); + indices.push_back(counter + 3); + indices.push_back(counter + 4); + indices.push_back(counter + 4); + indices.push_back(counter + 2); + + counter += 5; } - else if (tensorColor == RimTensorResults::MAGENTA_BROWN_BLACK) + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref drawable = new cvf::DrawableGeo(); + + drawable->setColorArray(colors.p()); + + indexedUInt->setIndices(indexArray.p()); + drawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + drawable->setVertexArray(vertexArray.p()); + + // Setup a scalar mapper + cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; { - *color1 = cvf::Color3f(cvf::Color3::MAGENTA); - *color2 = cvf::Color3f(cvf::Color3::BROWN); - *color3 = cvf::Color3f(cvf::Color3::BLACK); + cvf::Color3ubArray legendColors; + legendColors.resize(3); + if (m_rimReservoirView->tensorResults()->vectorColors() == RimTensorResults::MAGENTA_BROWN_BLACK) + { + legendColors[0] = cvf::Color3::MAGENTA; + legendColors[1] = cvf::Color3::BROWN; + legendColors[2] = cvf::Color3::BLACK; + } + else if (m_rimReservoirView->tensorResults()->vectorColors() == RimTensorResults::WHITE_GRAY_BLACK) + { + legendColors[0] = cvf::Color3::WHITE; + legendColors[1] = cvf::Color3::GRAY; + legendColors[2] = cvf::Color3::BLACK; + } + else + { + legendColors[0] = cvf::Color3::BLACK; + legendColors[1] = cvf::Color3::BLACK; + legendColors[2] = cvf::Color3::BLACK; + } + + scalarMapper->setColors(legendColors); + scalarMapper->setRange(0.5, 3.5); + scalarMapper->setLevelCount(3, true); } - else + + caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); + + if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + { + surfEffGen.disableLighting(true); + } + + caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); + cvf::ref scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); + + cvf::ref lineTexCoords = const_cast(drawable->textureCoordArray()); + + if (lineTexCoords.isNull()) { - *color1 = cvf::Color3f(cvf::Color3::BLACK); - *color2 = cvf::Color3f(cvf::Color3::BLACK); - *color3 = cvf::Color3f(cvf::Color3::BLACK); + lineTexCoords = new cvf::Vec2fArray; } + + // Calculate new texture coordinates + createTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); + + drawable->setTextureCoordArray(lineTexCoords.p()); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + part->setEffect(scalarMapperMeshEffect.p()); + + return part; } //-------------------------------------------------------------------------------------------------- @@ -408,3 +465,63 @@ bool RivTensorResultPartMgr::isDrawable(cvf::Vec3f resultVector, bool showPrinci return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivTensorResultPartMgr::createArrowVertices(const TensorVisualization &tensorVisualization) const +{ + std::array vertices; + + cvf::Vec3f headTop; + cvf::Vec3f shaftStart; + + if (tensorVisualization.isPressure) + { + headTop = tensorVisualization.vertex; + shaftStart = tensorVisualization.vertex + tensorVisualization.result; + } + else + { + headTop = tensorVisualization.vertex + tensorVisualization.result; + shaftStart = tensorVisualization.vertex; + } + + float headWidth = 0.05 * tensorVisualization.result.length(); + + cvf::Vec3f headBottom = headTop - (headTop - shaftStart) * 0.2f; + + cvf::Vec3f headBottomDirection = tensorVisualization.result ^ tensorVisualization.faceNormal; + cvf::Vec3f arrowBottomSegment = headBottomDirection.getNormalized() * headWidth; + + vertices[0] = shaftStart; + vertices[1] = headBottom; + vertices[2] = headBottom + arrowBottomSegment; + vertices[3] = headBottom - arrowBottomSegment; + vertices[4] = headTop; + + return vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper) const +{ + CVF_ASSERT(textureCoords); + CVF_ASSERT(mapper); + + size_t vertexCount = tensorVisualizations.size() * 5; + if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); + + for (auto tensor : tensorVisualizations) + { + for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) + { + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princial); + textureCoords->add(texCoord); + } + } +} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index 74751a6a3b..999dd79777 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -19,13 +19,13 @@ #pragma once #include "cvfBase.h" +#include "cvfArray.h" #include "cvfColor3.h" #include "cvfObject.h" #include "cvfVector3.h" #include "cafPdmPointer.h" - -#include "RimTensorResults.h" +#include "cafTensor3.h" #include #include @@ -34,10 +34,13 @@ namespace cvf { class Part; class ModelBasicList; -} +class ScalarMapper; +} // namespace cvf class RigFemResultAddress; class RimGeoMechView; +class RigFemPartNodes; +class RigFemPart; class RivTensorResultPartMgr : public cvf::Object { @@ -48,26 +51,47 @@ class RivTensorResultPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const; private: - struct TensorVisualization { - TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Color3f color, bool isPressure) - : vertex(vertex), result(result), color(color), isPressure(isPressure) {}; + TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, size_t princial) + : vertex(vertex) + , result(result) + , faceNormal(faceNormal) + , isPressure(isPressure) + , princial(princial){}; - cvf::Vec3f vertex; - cvf::Vec3f result; - cvf::Color3f color; - bool isPressure; + cvf::Vec3f vertex; + cvf::Vec3f result; + cvf::Vec3f faceNormal; + bool isPressure; + size_t princial; }; + private: - cvf::ref createPart(std::vector& tensorVisualizations) const; + static void calculateElementTensors(const RigFemPart& part, + const std::vector& vertexTensors, + std::vector* elmTensors); + + static void calculatePrincipalsAndDirections(const std::vector& tensors, + std::array, 3>* principals, + std::vector>* principalDirections); + + static cvf::Vec3f calculateFaceNormal(const RigFemPartNodes& nodes, + const std::vector& quadVerticesToNodeIdxMapping, + int quadVertex); + + cvf::ref createPart(const std::vector& tensorVisualizations) const; - static void assignColorVectors(RimTensorResults::TensorColors tensorColor, cvf::Color3f* color1, cvf::Color3f* color2, cvf::Color3f* color3); static bool isTensorAddress(RigFemResultAddress address); static bool isValid(cvf::Vec3f resultVector); static bool isPressure(float principalValue); bool isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const; + std::array createArrowVertices(const TensorVisualization &tensorVisualization) const; + void createTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualization, + const cvf::ScalarMapper* mapper) const; + private: caf::PdmPointer m_rimReservoirView; }; From 0e53c4b8bd70b098af197dc392e7764b5a69334f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 14 Feb 2018 14:49:28 +0100 Subject: [PATCH 0262/1027] RuiMainWindow. Null pointer guard --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 25a115c2df..82412c8a9f 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -773,7 +773,7 @@ void RiuMainWindow::refreshAnimationActions() else { RimEclipseView * activeRiv = dynamic_cast(activeView); - if ( activeRiv->currentGridCellResults() ) + if ( activeRiv && activeRiv->currentGridCellResults() ) { timeStepStrings.push_back(tr("Static Property")); } From 3fd5d3a3a7952f89450586ba2933aca74c3c8919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Feb 2018 10:58:13 +0100 Subject: [PATCH 0263/1027] #2393 Reservoir compaction derived result --- .../RigFemPartResultsCollection.cpp | 181 +++++++++++++++++- .../RigFemPartResultsCollection.h | 3 + .../GeoMechDataModel/RigFemResultAddress.h | 28 +-- .../RimGeoMechResultDefinition.cpp | 60 +++++- .../RimGeoMechResultDefinition.h | 5 +- 5 files changed, 252 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index d46f9f9b60..0f6bdead28 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -53,8 +53,31 @@ #include #include +#include "RigHexIntersectionTools.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::string RigFemPartResultsCollection::FIELD_NAME_COMPACTION = "COMPACTION"; + +//-------------------------------------------------------------------------------------------------- +/// Internal definitions +//-------------------------------------------------------------------------------------------------- +class RefElement +{ +public: + size_t elementIdx; + float intersectionPointToCurrentNodeDistance; + cvf::Vec3f intersectionPoint; + std::vector elementFaceNodeIdxs; +}; + +static std::vector coordsFromNodeIndices(const RigFemPart& part, const std::vector& nodeIdxs); +static std::vector nodesForElement(const RigFemPart& part, size_t elementIdx); +static float horizontalDistance(const cvf::Vec3f& p1, const cvf::Vec3f& p2); +static void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t kRefLayer, RefElement *refElement); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -295,6 +318,7 @@ std::map > RigFemPartResultsCollection::sc { fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames(); fieldCompNames["POR-Bar"]; + fieldCompNames[FIELD_NAME_COMPACTION]; } else if (resPos == RIG_ELEMENT_NODAL) { @@ -559,7 +583,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult( frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName); + RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName, RigFemResultAddress::NO_TIME_LAPSE, resVarAddr.refKLayerIndex); RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, resVarNative); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); @@ -1427,6 +1451,63 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStrainV return requestedPrincipal; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr) +{ + CVF_ASSERT(resVarAddr.fieldName == FIELD_NAME_COMPACTION); + + caf::ProgressInfo frameCountProgress(this->frameCount() + 1, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName)); + + RigFemScalarResultFrames * u3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "U", "U3")); + frameCountProgress.incrementProgress(); + + RigFemScalarResultFrames* compactionFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + const RigFemPart* part = m_femParts->part(partIndex); + for (int t = 0; t < u3Frames->frameCount(); t++) + { + std::vector& compactionFrame = compactionFrames->frameData(t); + size_t nodeCount = part->nodes().nodeIds.size(); + + frameCountProgress.incrementProgress(); + + compactionFrame.resize(nodeCount); + for (int n = 0; n < nodeCount; n++) + { + RefElement refElement; + findReferenceElementForNode(*part, n, resVarAddr.refKLayerIndex, &refElement); + + if (refElement.elementIdx != cvf::UNDEFINED_SIZE_T) + { + float shortestDist = HUGE_VALF; + size_t closestNodeIdx = cvf::UNDEFINED_SIZE_T; + + for (size_t nodeIdx : refElement.elementFaceNodeIdxs) + { + float dist = horizontalDistance(refElement.intersectionPoint, part->nodes().coordinates[nodeIdx]); + if (dist < shortestDist) + { + shortestDist = dist; + closestNodeIdx = nodeIdx; + } + } + + compactionFrame[n] = u3Frames->frameData(t)[n] - u3Frames->frameData(t)[closestNodeIdx]; + } + else + { + compactionFrame[n] = HUGE_VAL; + } + } + } + + RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex, resVarAddr); + return requestedPrincipal; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1453,6 +1534,11 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in } } + if (resVarAddr.fieldName == FIELD_NAME_COMPACTION) + { + return calculateCompactionValues(partIndex, resVarAddr); + } + if (resVarAddr.fieldName == "SE" && resVarAddr.componentName == "SFI") { return calculateSFI(partIndex, resVarAddr); @@ -2372,4 +2458,95 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar m_resultIndexToClosestResult = elmNodFaceResIdx; m_closestNodeId = femPart->nodes().nodeIds[closestNodeIdx]; } -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector coordsFromNodeIndices(const RigFemPart& part, const std::vector& nodeIdxs) +{ + std::vector out; + for (const auto& nodeIdx : nodeIdxs) out.push_back(cvf::Vec3d(part.nodes().coordinates[nodeIdx])); + return out; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector nodesForElement(const RigFemPart& part, size_t elementIdx) +{ + std::vector nodeIdxs; + const int* nodeConn = part.connectivities(elementIdx); + for (int n = 0; n < 8; n++) nodeIdxs.push_back(nodeConn[n]); + return nodeIdxs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float horizontalDistance(const cvf::Vec3f& p1, const cvf::Vec3f& p2) +{ + cvf::Vec3f p1_ = p1; + cvf::Vec3f p2_ = p2; + p1_.z() = p2_.z() = 0; + return p1_.pointDistance(p2_); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t kRefLayer, RefElement *refElement) +{ + static const double zMin = -1e6, zMax = 1e6; + + cvf::BoundingBox bb; + cvf::Vec3f currentNodeCoord = part.nodes().coordinates[nodeIdx]; + cvf::Vec3f p1 = cvf::Vec3f(currentNodeCoord.x(), currentNodeCoord.y(), zMin); + cvf::Vec3f p2 = cvf::Vec3f(currentNodeCoord.x(), currentNodeCoord.y(), zMax); + bb.add(p1); + bb.add(p2); + + std::vector refElementCandidates; + part.findIntersectingCells(bb, &refElementCandidates); + + const RigFemPartGrid* grid = part.structGrid(); + const std::vector& nodeCoords = part.nodes().coordinates; + + refElement->elementIdx = cvf::UNDEFINED_SIZE_T; + refElement->intersectionPointToCurrentNodeDistance = HUGE_VALF; + size_t i, j, k; + for (const size_t elemIdx : refElementCandidates) + { + grid->ijkFromCellIndex(elemIdx, &i, &j, &k); + if (k == kRefLayer) + { + const std::vector nodeIndices = nodesForElement(part, elemIdx); + CVF_ASSERT(nodeIndices.size() == 8); + + std::vector intersections; + RigHexIntersectionTools::lineHexCellIntersection(cvf::Vec3d(p1), cvf::Vec3d(p2), coordsFromNodeIndices(part, nodeIndices).data(), elemIdx, &intersections); + + for (const auto& intersection : intersections) + { + cvf::Vec3f intersectionPoint = cvf::Vec3f(intersection.m_intersectionPoint); + + float nodeToIntersectionDistance = currentNodeCoord.pointDistance(intersectionPoint); + if (nodeToIntersectionDistance < refElement->intersectionPointToCurrentNodeDistance) + { + cvf::ubyte faceNodes[4]; + grid->cellFaceVertexIndices(intersection.m_face, faceNodes); + std::vector topFaceCoords({ nodeIndices[faceNodes[0]], nodeIndices[faceNodes[1]], nodeIndices[faceNodes[2]], nodeIndices[faceNodes[3]] }); + + refElement->elementIdx = elemIdx; + refElement->intersectionPointToCurrentNodeDistance = nodeToIntersectionDistance; + refElement->intersectionPoint = intersectionPoint; + refElement->elementFaceNodeIdxs = topFaceCoords; + } + } + } + } +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 2cf9f147b8..b494d177be 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -48,6 +48,8 @@ namespace caf class RigFemPartResultsCollection: public cvf::Object { public: + static const std::string FIELD_NAME_COMPACTION; + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, RifElementPropertyReader* elementPropertyReader, const RigFemPartCollection * femPartCollection); ~RigFemPartResultsCollection(); @@ -115,6 +117,7 @@ class RigFemPartResultsCollection: public cvf::Object RigFemScalarResultFrames* calculateSurfaceAngles(int partIndex, const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* calculatePrincipalStressValues(int partIndex, const RigFemResultAddress &resVarAddr); RigFemScalarResultFrames* calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr); cvf::Collection m_femPartResults; cvf::ref m_readerInterface; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index 942b6e1fbb..2e9f4d92f9 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -36,24 +36,16 @@ class RigFemResultAddress componentName = ""; } - RigFemResultAddress(RigFemResultPosEnum resPosType, - const std::string& aFieldName, - const std::string& aComponentName) - : resultPosType(resPosType), - fieldName(aFieldName), - componentName(aComponentName), - timeLapseBaseFrameIdx(-1) - { - } - RigFemResultAddress(RigFemResultPosEnum resPosType, const std::string& aFieldName, const std::string& aComponentName, - int aTimeLapseBaseFrame) + int timeLapseBaseFrameIdx = NO_TIME_LAPSE, + int refKLayerIndex = NO_COMPACTION) : resultPosType(resPosType), fieldName(aFieldName), componentName(aComponentName), - timeLapseBaseFrameIdx(aTimeLapseBaseFrame) + timeLapseBaseFrameIdx(timeLapseBaseFrameIdx), + refKLayerIndex(refKLayerIndex) { } @@ -61,12 +53,17 @@ class RigFemResultAddress std::string fieldName; std::string componentName; int timeLapseBaseFrameIdx; + int refKLayerIndex; static const int ALL_TIME_LAPSES = -2; + static const int NO_TIME_LAPSE = -1; + static const int NO_COMPACTION = -1; - bool isTimeLapse() const { return timeLapseBaseFrameIdx >= 0;} + bool isTimeLapse() const { return timeLapseBaseFrameIdx > NO_TIME_LAPSE;} bool representsAllTimeLapses() const { return timeLapseBaseFrameIdx == ALL_TIME_LAPSES;} + bool isCompaction() const { return refKLayerIndex > NO_COMPACTION; } + bool isValid() const { bool isTypeValid = resultPosType == RIG_NODAL @@ -97,6 +94,11 @@ class RigFemResultAddress return (fieldName < other.fieldName); } + if (refKLayerIndex != other.refKLayerIndex) + { + return refKLayerIndex < other.refKLayerIndex; + } + return (componentName < other.componentName); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index d799a8846a..7e306b7341 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -24,6 +24,8 @@ #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" #include "RiaDefines.h" #include "RimGeoMechCase.h" @@ -77,6 +79,12 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", 0, "Base Time Step", "", "", ""); m_timeLapseBaseTimestep.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_isCompaction, "IsCompaction", false, "Compaction", "", "", ""); + m_isCompaction.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer", "", "", ""); + m_compactionRefLayer.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false); m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false); @@ -96,6 +104,14 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); + CAF_PDM_InitField(&m_isCompactionUiField, "IsCompactionUi", false, "Enable Compaction", "", "", ""); + m_isCompactionUiField.xmlCapability()->setIOWritable(false); + m_isCompactionUiField.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "", ""); + m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); + m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); + m_isChangedByField = false; } @@ -123,6 +139,14 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm timeLapseGr->add(&m_timeLapseBaseTimestepUiField); } + if (m_resultPositionTypeUiField() == RIG_NODAL) + { + caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); + compactionGroup->add(&m_isCompactionUiField); + if (m_isCompactionUiField()) + compactionGroup->add(&m_compactionRefLayerUiField); + } + if (!m_isChangedByField) { m_resultPositionTypeUiField = m_resultPositionType; @@ -156,6 +180,8 @@ QList RimGeoMechResultDefinition::calculateValueOptions( for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx) { + if (uiVarNames[oIdx].startsWith(RigFemPartResultsCollection::FIELD_NAME_COMPACTION.data()) && !m_isCompactionUiField()) continue; + options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); } } @@ -177,6 +203,14 @@ QList RimGeoMechResultDefinition::calculateValueOptions( options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(stepNames[stepIdx]), static_cast(stepIdx))); } } + else if (&m_compactionRefLayerUiField == fieldNeedingOptions) + { + size_t kCount = m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->gridPointCountK() - 1; + for (size_t layerIdx = 0; layerIdx < kCount; ++layerIdx) + { + options.push_back(caf::PdmOptionItemInfo(QString::number(layerIdx + 1), (int)layerIdx)); + } + } } return options; @@ -229,7 +263,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); - if (&m_resultVariableUiField == changedField) + if (&m_resultVariableUiField == changedField || &m_compactionRefLayerUiField == changedField) { QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+")); if (fieldComponentNames.size() > 0) @@ -255,8 +289,10 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha m_resultComponentName = ""; } - m_isTimeLapseResult = m_isTimeLapseResultUiField(); + m_isTimeLapseResult = m_isTimeLapseResultUiField(); m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField(); + m_isCompaction = m_isCompactionUiField(); + m_compactionRefLayer = m_compactionRefLayerUiField(); } if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) @@ -378,6 +414,8 @@ void RimGeoMechResultDefinition::initAfterRead() m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; + m_isCompactionUiField = m_isCompaction; + m_compactionRefLayerUiField = m_compactionRefLayer; } @@ -392,16 +430,16 @@ void RimGeoMechResultDefinition::loadResult() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemResultAddress RimGeoMechResultDefinition::resultAddress() { - if(m_isTimeLapseResult) - return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString(), m_timeLapseBaseTimestep); - else - return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString()); + return RigFemResultAddress(resultPositionType(), + resultFieldName().toStdString(), + resultComponentName().toStdString(), + m_isTimeLapseResult() ? m_timeLapseBaseTimestep() : RigFemResultAddress::NO_TIME_LAPSE, + m_isCompaction() && resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION); } //-------------------------------------------------------------------------------------------------- @@ -479,11 +517,15 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re m_resultFieldName = QString::fromStdString(resultAddress.fieldName); m_resultComponentName = QString::fromStdString(resultAddress.componentName); m_isTimeLapseResult = resultAddress.isTimeLapse(); - - m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: 0; + m_isCompaction = resultAddress.isCompaction(); + + m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: -1; + m_compactionRefLayer = m_isCompaction ? resultAddress.refKLayerIndex : -1; m_resultPositionTypeUiField = m_resultPositionType; m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; + m_isCompactionUiField = m_isCompaction; + m_compactionRefLayerUiField = m_compactionRefLayer; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index e8e2b3da5b..dd10008d92 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -101,6 +101,8 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultComponentName; caf::PdmField m_isTimeLapseResult; caf::PdmField m_timeLapseBaseTimestep; + caf::PdmField m_isCompaction; + caf::PdmField m_compactionRefLayer; // UI Fields only @@ -112,7 +114,8 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultVariableUiField; caf::PdmField m_isTimeLapseResultUiField; caf::PdmField m_timeLapseBaseTimestepUiField; - + caf::PdmField m_isCompactionUiField; + caf::PdmField m_compactionRefLayerUiField; caf::PdmPointer m_geomCase; bool m_isChangedByField; From de498a71c20eb51874d748b395b8bce4b111c010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Feb 2018 12:34:34 +0100 Subject: [PATCH 0264/1027] #2474 fractures. Added plural form of fracture. Moved below sim wells --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 3 ++- ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index ca5e0ba07c..7ce6996f3a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1393,6 +1393,8 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(cellResult()); uiTreeOrdering.add(cellEdgeResult()); uiTreeOrdering.add(faultResultSettings()); + uiTreeOrdering.add(wellCollection()); + #ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimProject* project = RiaApplication::instance()->project(); @@ -1408,7 +1410,6 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } #endif // USE_PROTOTYPE_FEATURE_FRACTURES - uiTreeOrdering.add(wellCollection()); uiTreeOrdering.add(faultCollection()); uiTreeOrdering.add(m_crossSectionCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index d59ca4ddd3..5f064f4869 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -77,7 +77,7 @@ RimStimPlanColors::RimStimPlanColors() CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation", "", "", ""); - setName("Fracture"); + setName("Fractures"); nameField()->uiCapability()->setUiReadOnly(true); } From 1076384ce076299f3093f4879d8e1ee1efe8d867 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 13:00:33 +0100 Subject: [PATCH 0265/1027] #2438 2D Intersection View: 3D Info Box items must follow settings in the main view --- .../Rim2dIntersectionView.cpp | 102 +++++++++++------ .../ProjectDataModel/Rim2dIntersectionView.h | 3 +- .../Rim3dOverlayInfoConfig.cpp | 103 ++++++++++++------ .../ProjectDataModel/Rim3dOverlayInfoConfig.h | 28 +++-- 4 files changed, 155 insertions(+), 81 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 6da4b6a41d..889afbc09f 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -333,16 +333,29 @@ void Rim2dIntersectionView::updateCurrentTimeStep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateLegends() { - if (m_viewer) + if (!m_viewer) { - m_viewer->removeAllColorLegends(); + return; } + m_viewer->removeAllColorLegends(); if (!hasResults()) return; QString overlayInfoText; - overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView && eclView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView && geoView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } overlayInfoText += "

"; overlayInfoText += "Intersection: " + m_intersection->name() + "
"; @@ -358,15 +371,24 @@ void Rim2dIntersectionView::updateLegends() cvf::OverlayItem* legend = nullptr; - RimEclipseView * eclView = nullptr; - m_intersection->firstAncestorOrThisOfType(eclView); if (eclView) { - overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + if (eclView->overlayInfoConfig()->showAnimProgress()) + { + m_viewer->showAnimationProgress(true); + } + else + { + m_viewer->showAnimationProgress(false); + } + + if (eclView->overlayInfoConfig()->showResultInfo()) + { + overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + } m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); - eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); if ( eclView->cellResult()->isTernarySaturationSelected() ) { @@ -380,41 +402,51 @@ void Rim2dIntersectionView::updateLegends() } } - RimGeoMechView * geoView = nullptr; - m_intersection->firstAncestorOrThisOfType(geoView); if (geoView) { - QString resultPos; - QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); - QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); - - switch (geoView->cellResultResultDefinition()->resultPositionType()) + if (geoView->overlayInfoConfig()->showAnimProgress()) { - case RIG_NODAL: - resultPos = "Nodal"; - break; - - case RIG_ELEMENT_NODAL: - resultPos = "Element nodal"; - break; - - case RIG_INTEGRATION_POINT: - resultPos = "Integration point"; - break; - - case RIG_ELEMENT: - resultPos = "Element"; - break; - default: - break; + m_viewer->showAnimationProgress(true); } - if (compName == "") + else { - overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); + m_viewer->showAnimationProgress(false); } - else + + if (geoView->overlayInfoConfig()->showResultInfo()) { - overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); + QString resultPos; + QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); + QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); + + switch (geoView->cellResultResultDefinition()->resultPositionType()) + { + case RIG_NODAL: + resultPos = "Nodal"; + break; + + case RIG_ELEMENT_NODAL: + resultPos = "Element nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration point"; + break; + + case RIG_ELEMENT: + resultPos = "Element"; + break; + default: + break; + } + if (compName == "") + { + overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); + } + else + { + overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); + } } m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index ec3ec5361d..b5a50e4fa0 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -56,6 +56,8 @@ class Rim2dIntersectionView : public Rim3dView virtual bool isTimeStepDependentDataVisible() const override; + void updateLegends(); + protected: virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; @@ -78,7 +80,6 @@ class Rim2dIntersectionView : public Rim3dView bool hasResults(); int timeStepCount(); - void updateLegends(); caf::PdmChildField m_legendConfig; caf::PdmChildField m_ternaryLegendConfig; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index e3897061d2..1ef1a6605b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -35,6 +35,10 @@ #include "RigMainGrid.h" #include "RigStatisticsDataCache.h" +#include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" +#include "Rim3dView.h" +#include "RimCase.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -47,7 +51,6 @@ #include "RimGeoMechView.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" -#include "Rim3dView.h" #include "RimTools.h" #include "RiuViewer.h" @@ -92,14 +95,14 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig() { CAF_PDM_InitObject("Info Box", ":/InfoBox16x16.png", "", ""); - CAF_PDM_InitField(&active, "Active", true, "Active", "", "", ""); - active.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_active, "Active", true, "Active", "", "", ""); + m_active.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&showAnimProgress, "ShowAnimProgress", true, "Animation progress", "", "", ""); - CAF_PDM_InitField(&showCaseInfo, "ShowInfoText", true, "Case Info", "", "", ""); - CAF_PDM_InitField(&showResultInfo, "ShowResultInfo", true, "Result Info", "", "", ""); - CAF_PDM_InitField(&showHistogram, "ShowHistogram", true, "Histogram", "", "", ""); - CAF_PDM_InitField(&showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean", "", "", ""); + CAF_PDM_InitField(&m_showAnimProgress, "ShowAnimProgress", true, "Animation progress", "", "", ""); + CAF_PDM_InitField(&m_showCaseInfo, "ShowInfoText", true, "Case Info", "", "", ""); + CAF_PDM_InitField(&m_showResultInfo, "ShowResultInfo", true, "Result Info", "", "", ""); + CAF_PDM_InitField(&m_showHistogram, "ShowHistogram", true, "Histogram", "", "", ""); + CAF_PDM_InitField(&m_showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_statisticsTimeRange, "StatisticsTimeRange", "Statistics Time Range", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_statisticsCellRange, "StatisticsCellRange", "Statistics Cell Range", "", "", ""); @@ -131,17 +134,17 @@ void Rim3dOverlayInfoConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed if ( changedField == &m_statisticsCellRange ) m_statisticsCellRange = ALL_CELLS; } - if (changedField == &showResultInfo) + if (changedField == &m_showResultInfo) { - if (!showResultInfo()) + if (!m_showResultInfo()) { - showVolumeWeightedMean = false; - showVolumeWeightedMean.uiCapability()->setUiReadOnly(true); + m_showVolumeWeightedMean = false; + m_showVolumeWeightedMean.uiCapability()->setUiReadOnly(true); } else { - showVolumeWeightedMean = true; - showVolumeWeightedMean.uiCapability()->setUiReadOnly(false); + m_showVolumeWeightedMean = true; + m_showVolumeWeightedMean.uiCapability()->setUiReadOnly(false); } } @@ -209,7 +212,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData) auto eclipseView = dynamic_cast(m_viewDef.p()); auto geoMechView = dynamic_cast(m_viewDef.p()); - if (eclipseView) return resultInfoText(histData, eclipseView, showVolumeWeightedMean()); + if (eclipseView) return resultInfoText(histData, eclipseView, m_showVolumeWeightedMean()); if (geoMechView) return resultInfoText(histData, geoMechView); return ""; } @@ -226,6 +229,30 @@ QImage Rim3dOverlayInfoConfig::statisticsDialogScreenShotImage() return QImage(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showAnimProgress() +{ + return m_showAnimProgress; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showCaseInfo() +{ + return m_showCaseInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showResultInfo() +{ + return m_showResultInfo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -654,7 +681,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() if (!m_viewDef) return; if (!m_viewDef->viewer()) return; - if (!this->active()) + if (!this->m_active()) { m_viewDef->viewer()->showInfoText(false); m_viewDef->viewer()->showHistogram(false); @@ -663,9 +690,9 @@ void Rim3dOverlayInfoConfig::update3DInfo() return; } - m_viewDef->viewer()->showInfoText(showCaseInfo() || showResultInfo()); + m_viewDef->viewer()->showInfoText(m_showCaseInfo() || m_showResultInfo()); m_viewDef->viewer()->showHistogram(false); - m_viewDef->viewer()->showAnimationProgress(showAnimProgress()); + m_viewDef->viewer()->showAnimationProgress(m_showAnimProgress()); m_isVisCellStatUpToDate = false; @@ -687,13 +714,23 @@ void Rim3dOverlayInfoConfig::update3DInfo() RimGeoMechView * geoMechView = dynamic_cast(m_viewDef.p()); if (geoMechView) { - showVolumeWeightedMean = false; + m_showVolumeWeightedMean = false; updateGeoMech3DInfo(geoMechView); // Update statistics dialog m_gridStatisticsDialog->updateFromRimView(geoMechView); } + + RimCase* rimCase; + firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + for (Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views()) + { + view->updateLegends(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -701,7 +738,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField() { - return &active; + return &m_active; } @@ -712,16 +749,16 @@ void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr { caf::PdmUiGroup* visGroup = uiOrdering.addNewGroup("Visibility"); - visGroup->add(&showAnimProgress); - visGroup->add(&showCaseInfo); - visGroup->add(&showResultInfo); + visGroup->add(&m_showAnimProgress); + visGroup->add(&m_showCaseInfo); + visGroup->add(&m_showResultInfo); RimGeoMechView * geoMechView = dynamic_cast(m_viewDef.p()); if (!geoMechView) { - visGroup->add(&showVolumeWeightedMean); + visGroup->add(&m_showVolumeWeightedMean); } - visGroup->add(&showHistogram); + visGroup->add(&m_showHistogram); caf::PdmUiGroup* statGroup = uiOrdering.addNewGroup("Statistics Options"); RimEclipseView * eclipseView = dynamic_cast(m_viewDef.p()); @@ -750,19 +787,19 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) { HistogramData histData; - if (showHistogram() || showResultInfo()) + if (m_showHistogram() || m_showResultInfo()) { histData = histogramData(); } QString infoText; - if (showCaseInfo()) + if (m_showCaseInfo()) { infoText = caseInfoText(); } - if (showResultInfo()) + if (m_showResultInfo()) { infoText += resultInfoText(histData); } @@ -772,7 +809,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) eclipseView->viewer()->setInfoText(infoText); } - if (showHistogram()) + if (m_showHistogram()) { bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult(); @@ -792,7 +829,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { HistogramData histData; - if (showResultInfo() || showHistogram()) + if (m_showResultInfo() || m_showHistogram()) { histData = histogramData(geoMechView); } @@ -801,12 +838,12 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) QString infoText; - if (showCaseInfo()) + if (m_showCaseInfo()) { infoText = caseInfoText(geoMechView); } - if (showResultInfo()) + if (m_showResultInfo()) { infoText += resultInfoText(histData, geoMechView); } @@ -818,7 +855,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) // Populate histogram - if (showHistogram()) + if (m_showHistogram()) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index e2c6f0c9e8..9938a05558 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -71,13 +71,17 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void setPosition(cvf::Vec2ui position); - HistogramData histogramData(); - QString timeStepText(); - QString caseInfoText(); - QString resultInfoText(const HistogramData& histData); + HistogramData histogramData(); + QString timeStepText(); + QString caseInfoText(); + QString resultInfoText(const HistogramData& histData); - void showStatisticsInfoDialog(bool raise = true); - QImage statisticsDialogScreenShotImage(); + void showStatisticsInfoDialog(bool raise = true); + QImage statisticsDialogScreenShotImage(); + + bool showAnimProgress(); + bool showCaseInfo(); + bool showResultInfo(); enum StatisticsTimeRangeType { @@ -110,12 +114,12 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject QString resultInfoText(const HistogramData& histData, RimEclipseView* eclipseView, bool showVolumeWeightedMean); QString resultInfoText(const HistogramData& histData, RimGeoMechView* geoMechView); - caf::PdmField active; - caf::PdmField showAnimProgress; - caf::PdmField showCaseInfo; - caf::PdmField showResultInfo; - caf::PdmField showVolumeWeightedMean; - caf::PdmField showHistogram; + caf::PdmField m_active; + caf::PdmField m_showAnimProgress; + caf::PdmField m_showCaseInfo; + caf::PdmField m_showResultInfo; + caf::PdmField m_showVolumeWeightedMean; + caf::PdmField m_showHistogram; caf::PdmField > m_statisticsTimeRange; caf::PdmField > m_statisticsCellRange; From 022d2ffd2d4f9a27af2732e35573a9f43c393f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Feb 2018 13:05:25 +0100 Subject: [PATCH 0266/1027] #2473 copy intersections. Resolve references and update connected editors --- .../RicCopyIntersectionsToAllViewsInCaseFeature.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp index 04b831c4f5..05928db5e0 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -123,6 +123,10 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews( CVF_ASSERT(copy); destCollection->appendIntersectionAndUpdate(copy); + + // Resolve references after object has been inserted into the project data model + copy->resolveReferencesRecursively(); + copy->updateConnectedEditors(); } } } From f909a7ea273e0dce4a32fc943307a264c96f650f Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 14:31:08 +0100 Subject: [PATCH 0267/1027] #2438 2d Intersection View: Update intersection view on 3dOverlayInfo update --- .../Rim2dIntersectionView.cpp | 193 ++++++++++-------- .../ProjectDataModel/Rim2dIntersectionView.h | 3 +- .../Rim3dOverlayInfoConfig.cpp | 2 +- 3 files changed, 111 insertions(+), 87 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 889afbc09f..2832b0e13a 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -166,6 +166,113 @@ bool Rim2dIntersectionView::isTimeStepDependentDataVisible() const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::update3dInfo() +{ + if (!m_viewer) return; + + QString overlayInfoText; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView && eclView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView && geoView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } + + overlayInfoText += "

"; + overlayInfoText += "Intersection: " + m_intersection->name() + "
"; + + if (m_intersection->simulationWell()) + { + overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
";; + } + else if (m_intersection->wellPath()) + { + overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
";; + } + + if (eclView) + { + if (eclView->overlayInfoConfig()->showAnimProgress()) + { + m_viewer->showAnimationProgress(true); + } + else + { + m_viewer->showAnimationProgress(false); + } + + if (eclView->overlayInfoConfig()->showResultInfo()) + { + overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + } + } + + if (geoView) + { + if (geoView->overlayInfoConfig()->showAnimProgress()) + { + m_viewer->showAnimationProgress(true); + } + else + { + m_viewer->showAnimationProgress(false); + } + + if (geoView->overlayInfoConfig()->showResultInfo()) + { + QString resultPos; + QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); + QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); + + switch (geoView->cellResultResultDefinition()->resultPositionType()) + { + case RIG_NODAL: + resultPos = "Nodal"; + break; + + case RIG_ELEMENT_NODAL: + resultPos = "Element nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration point"; + break; + + case RIG_ELEMENT: + resultPos = "Element"; + break; + default: + break; + } + if (compName == "") + { + overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); + } + else + { + overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); + } + } + } + + + overlayInfoText += "

"; + m_viewer->setInfoText(overlayInfoText); + m_viewer->showInfoText(true); + m_viewer->update(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -315,6 +422,7 @@ void Rim2dIntersectionView::clampCurrentTimestep() void Rim2dIntersectionView::updateCurrentTimeStep() { updateLegends(); + update3dInfo(); if ((this->hasUserRequestedAnimation() && this->hasResults())) { @@ -341,52 +449,16 @@ void Rim2dIntersectionView::updateLegends() if (!hasResults()) return; - QString overlayInfoText; - RimEclipseView * eclView = nullptr; m_intersection->firstAncestorOrThisOfType(eclView); - if (eclView && eclView->overlayInfoConfig()->showCaseInfo()) - { - overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; - } RimGeoMechView * geoView = nullptr; m_intersection->firstAncestorOrThisOfType(geoView); - if (geoView && geoView->overlayInfoConfig()->showCaseInfo()) - { - overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; - } - - overlayInfoText += "

"; - overlayInfoText += "Intersection: " + m_intersection->name() + "
"; - - if (m_intersection->simulationWell()) - { - overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
";; - } - else if (m_intersection->wellPath()) - { - overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
";; - } cvf::OverlayItem* legend = nullptr; if (eclView) { - if (eclView->overlayInfoConfig()->showAnimProgress()) - { - m_viewer->showAnimationProgress(true); - } - else - { - m_viewer->showAnimationProgress(false); - } - - if (eclView->overlayInfoConfig()->showResultInfo()) - { - overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; - } - m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); @@ -404,51 +476,6 @@ void Rim2dIntersectionView::updateLegends() if (geoView) { - if (geoView->overlayInfoConfig()->showAnimProgress()) - { - m_viewer->showAnimationProgress(true); - } - else - { - m_viewer->showAnimationProgress(false); - } - - if (geoView->overlayInfoConfig()->showResultInfo()) - { - QString resultPos; - QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); - QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); - - switch (geoView->cellResultResultDefinition()->resultPositionType()) - { - case RIG_NODAL: - resultPos = "Nodal"; - break; - - case RIG_ELEMENT_NODAL: - resultPos = "Element nodal"; - break; - - case RIG_INTEGRATION_POINT: - resultPos = "Integration point"; - break; - - case RIG_ELEMENT: - resultPos = "Element"; - break; - default: - break; - } - if (compName == "") - { - overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); - } - else - { - overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); - } - } - m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); @@ -459,10 +486,6 @@ void Rim2dIntersectionView::updateLegends() { m_viewer->addColorLegendToBottomLeftCorner(legend); } - - overlayInfoText += "

"; - m_viewer->setInfoText(overlayInfoText); - m_viewer->showInfoText(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index b5a50e4fa0..13a65aada3 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -56,9 +56,10 @@ class Rim2dIntersectionView : public Rim3dView virtual bool isTimeStepDependentDataVisible() const override; - void updateLegends(); + void update3dInfo(); protected: + void updateLegends(); virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; virtual void createDisplayModel() override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 1ef1a6605b..65fd77ac90 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -728,7 +728,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() { for (Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views()) { - view->updateLegends(); + view->update3dInfo(); } } } From 0fece2447a92fbe74c0ebc7c9080d5b12555e35c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 14:37:38 +0100 Subject: [PATCH 0268/1027] #2470 2D Intersection Views: Hide the item when no intersections are present --- .../Rim2dIntersectionViewCollection.cpp | 5 +++++ .../ProjectDataModel/RimEclipseCase.cpp | 8 +++++++- .../ProjectDataModel/RimGeoMechCase.cpp | 20 ++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index f9c6e7cf26..909ee19164 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -110,6 +110,11 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda } if (doUpdate) this->updateConnectedEditors(); + + RimCase* rimCase = nullptr; + firstAncestorOrThisOfType(rimCase); + + if (rimCase) rimCase->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 34006434d7..12dc16c9f4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -30,6 +30,7 @@ #include "RigMainGrid.h" #include "RigSimWellData.h" +#include "Rim2dIntersectionViewCollection.h" #include "RimCaseCollection.h" #include "RimCellEdgeColors.h" #include "RimCommandObject.h" @@ -415,7 +416,12 @@ void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering for (auto child : children) uiTreeOrdering.add(child); - uiTreeOrdering.add(&m_2dIntersectionViewCollection); + if (!m_2dIntersectionViewCollection->views().empty()) + { + uiTreeOrdering.add(&m_2dIntersectionViewCollection); + } + + uiTreeOrdering.skipRemainingChildren(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 6f510952fe..68a3a45c75 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -26,20 +26,21 @@ #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" -#include "RigGeoMechCaseData.h" #include "RigFormationNames.h" +#include "RigGeoMechCaseData.h" +#include "Rim2dIntersectionViewCollection.h" +#include "RimFormationNames.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimTools.h" #include "RimWellLogPlotCollection.h" -#include "RimFormationNames.h" -#include "RimGeoMechPropertyFilterCollection.h" -#include "RimGeoMechCellColors.h" -#include "RimGeoMechResultDefinition.h" -#include "RimGeoMechPropertyFilter.h" #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTreeOrdering.h" @@ -228,7 +229,12 @@ void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering for ( auto child : children ) uiTreeOrdering.add(child); - uiTreeOrdering.add(&m_2dIntersectionViewCollection); + if (!m_2dIntersectionViewCollection->views().empty()) + { + uiTreeOrdering.add(&m_2dIntersectionViewCollection); + } + + uiTreeOrdering.skipRemainingChildren(true); } //-------------------------------------------------------------------------------------------------- From cdfe6e3000476bcc7b4ac30842173e14db316fc9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Feb 2018 15:00:09 +0100 Subject: [PATCH 0269/1027] #2475 Fractures: Use filename as default name when importing a StimPlan fracture --- .../RicNewStimPlanFractureTemplateFeature.cpp | 11 +++++++++- .../RimStimPlanFractureTemplate.cpp | 21 ------------------- .../Completions/RimStimPlanFractureTemplate.h | 2 -- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp index d0ac1ad13b..5d4913afcb 100644 --- a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp @@ -61,7 +61,16 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) { RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate(); fracDefColl->fractureDefinitions.push_back(fractureDef); - fractureDef->setName("StimPlan Fracture Template"); + + QFileInfo stimplanfileFileInfo(fileName); + QString name = stimplanfileFileInfo.baseName(); + if (name.isEmpty()) + { + name = "StimPlan Fracture Template"; + } + + fractureDef->setName(name); + fractureDef->setFileName(fileName); fractureDef->loadDataAndUpdate(); fractureDef->setDefaultsBasedOnXMLfile(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index be3061b0b4..66bbcc91d3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -106,7 +106,6 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch if (&m_stimPlanFileName == changedField) { m_readError = false; - updateUiTreeName(); loadDataAndUpdate(); setDefaultsBasedOnXMLfile(); } @@ -154,23 +153,12 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::updateUiTreeName() -{ - this->uiCapability()->setUiName(fileNameWithOutPath()); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::setFileName(const QString& fileName) { m_stimPlanFileName = fileName; - - updateUiTreeName(); } //-------------------------------------------------------------------------------------------------- @@ -181,15 +169,6 @@ const QString& RimStimPlanFractureTemplate::fileName() return m_stimPlanFileName(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimStimPlanFractureTemplate::fileNameWithOutPath() -{ - QFileInfo stimplanfileFileInfo(m_stimPlanFileName()); - return stimplanfileFileInfo.fileName(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index f4e0cd4f6b..302cca1009 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -97,8 +97,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; private: - void updateUiTreeName(); - bool setBorderPolygonResultNameToDefault(); void setDepthOfWellPathAtFracture(); void setPerforationLength(); From 67040d757fdc1b39f680c01ede4f9f8c3a2519f6 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 15:10:59 +0100 Subject: [PATCH 0270/1027] #2477 2D intersection view: add legend update --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 2832b0e13a..04b04f51c1 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -421,8 +421,8 @@ void Rim2dIntersectionView::clampCurrentTimestep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateCurrentTimeStep() { - updateLegends(); update3dInfo(); + updateLegends(); if ((this->hasUserRequestedAnimation() && this->hasResults())) { @@ -441,10 +441,8 @@ void Rim2dIntersectionView::updateCurrentTimeStep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateLegends() { - if (!m_viewer) - { - return; - } + if (!m_viewer) return; + m_viewer->removeAllColorLegends(); if (!hasResults()) return; @@ -461,6 +459,7 @@ void Rim2dIntersectionView::updateLegends() { m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); + eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); if ( eclView->cellResult()->isTernarySaturationSelected() ) { @@ -477,7 +476,7 @@ void Rim2dIntersectionView::updateLegends() if (geoView) { m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); - + geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); legend = m_legendConfig()->legend(); } From 1fd6d10b69b291cfc96a080efb54e35b862d97ae Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Feb 2018 15:45:40 +0100 Subject: [PATCH 0271/1027] #2460 Tensor vectors: Put scalar mapper code in separate functions --- .../RivTensorResultPartMgr.cpp | 139 ++++++++++-------- .../RivTensorResultPartMgr.h | 13 +- 2 files changed, 85 insertions(+), 67 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index c7e218a58c..3742dc14c0 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -129,7 +129,8 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); - cvf::Vec3d displayCoord = m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(cvf::Vec3d(center/2)); + cvf::Vec3d displayCoord = + m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(cvf::Vec3d(center / 2)); cvf::Vec3f faceNormal = calculateFaceNormal(nodes, quadVerticesToNodeIdxMapping, quadVertex); @@ -293,9 +294,6 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector vertices; vertices.reserve(tensorVisualizations.size() * 5); - cvf::ref colors = new cvf::Color3ubArray(); - colors->reserve(tensorVisualizations.size() * 5); - uint counter = 0; for (TensorVisualization tensor : tensorVisualizations) { @@ -321,41 +319,38 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector drawable = new cvf::DrawableGeo(); - drawable->setColorArray(colors.p()); - indexedUInt->setIndices(indexArray.p()); drawable->addPrimitiveSet(indexedUInt.p()); cvf::ref vertexArray = new cvf::Vec3fArray(vertices); drawable->setVertexArray(vertexArray.p()); - // Setup a scalar mapper - cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; + cvf::ref lineTexCoords = const_cast(drawable->textureCoordArray()); + + if (lineTexCoords.isNull()) { - cvf::Color3ubArray legendColors; - legendColors.resize(3); - if (m_rimReservoirView->tensorResults()->vectorColors() == RimTensorResults::MAGENTA_BROWN_BLACK) - { - legendColors[0] = cvf::Color3::MAGENTA; - legendColors[1] = cvf::Color3::BROWN; - legendColors[2] = cvf::Color3::BLACK; - } - else if (m_rimReservoirView->tensorResults()->vectorColors() == RimTensorResults::WHITE_GRAY_BLACK) - { - legendColors[0] = cvf::Color3::WHITE; - legendColors[1] = cvf::Color3::GRAY; - legendColors[2] = cvf::Color3::BLACK; - } - else - { - legendColors[0] = cvf::Color3::BLACK; - legendColors[1] = cvf::Color3::BLACK; - legendColors[2] = cvf::Color3::BLACK; - } + lineTexCoords = new cvf::Vec2fArray; + } + cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; - scalarMapper->setColors(legendColors); + auto vectorColors = m_rimReservoirView->tensorResults()->vectorColors(); + if (vectorColors == RimTensorResults::MAGENTA_BROWN_BLACK || vectorColors == RimTensorResults::WHITE_GRAY_BLACK) + { + createOneColorPerPrincipalScalarMapper(m_rimReservoirView->tensorResults()->vectorColors(), scalarMapper.p()); + createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); + } + else + { + // THIS WILL BE REPLACED BY REAL RESULT COLOR MAPPER + cvf::Color3ubArray arrowColors; + arrowColors.resize(3); + arrowColors[0] = cvf::Color3::BLACK; + arrowColors[1] = cvf::Color3::BLACK; + arrowColors[2] = cvf::Color3::BLACK; + scalarMapper->setColors(arrowColors); scalarMapper->setRange(0.5, 3.5); scalarMapper->setLevelCount(3, true); + createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); } caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); @@ -368,16 +363,6 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); - cvf::ref lineTexCoords = const_cast(drawable->textureCoordArray()); - - if (lineTexCoords.isNull()) - { - lineTexCoords = new cvf::Vec2fArray; - } - - // Calculate new texture coordinates - createTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); - drawable->setTextureCoordArray(lineTexCoords.p()); cvf::ref part = new cvf::Part; @@ -387,6 +372,57 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vectorsetColors(arrowColors); + scalarMapper->setRange(0.5, 3.5); + scalarMapper->setLevelCount(3, true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createOneColorPerPrincipalTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper) +{ + CVF_ASSERT(textureCoords); + CVF_ASSERT(mapper); + + size_t vertexCount = tensorVisualizations.size() * 5; + if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); + + for (auto tensor : tensorVisualizations) + { + for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) + { + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princial); + textureCoords->add(texCoord); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -469,7 +505,7 @@ bool RivTensorResultPartMgr::isDrawable(cvf::Vec3f resultVector, bool showPrinci //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::array RivTensorResultPartMgr::createArrowVertices(const TensorVisualization &tensorVisualization) const +std::array RivTensorResultPartMgr::createArrowVertices(const TensorVisualization& tensorVisualization) const { std::array vertices; @@ -502,26 +538,3 @@ std::array RivTensorResultPartMgr::createArrowVertices(const Tens return vertices; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTensorResultPartMgr::createTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector& tensorVisualizations, - const cvf::ScalarMapper* mapper) const -{ - CVF_ASSERT(textureCoords); - CVF_ASSERT(mapper); - - size_t vertexCount = tensorVisualizations.size() * 5; - if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); - - for (auto tensor : tensorVisualizations) - { - for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) - { - cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princial); - textureCoords->add(texCoord); - } - } -} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index 999dd79777..f1ab24d75e 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -27,14 +27,17 @@ #include "cafPdmPointer.h" #include "cafTensor3.h" +#include "RimTensorResults.h" + #include #include namespace cvf { -class Part; class ModelBasicList; +class Part; class ScalarMapper; +class ScalarMapperDiscreteLinear; } // namespace cvf class RigFemResultAddress; @@ -82,15 +85,17 @@ class RivTensorResultPartMgr : public cvf::Object cvf::ref createPart(const std::vector& tensorVisualizations) const; + static void createOneColorPerPrincipalScalarMapper(const RimTensorResults::TensorColors& colorSet, cvf::ScalarMapperDiscreteLinear* scalarMapper); + static void createOneColorPerPrincipalTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualization, + const cvf::ScalarMapper* mapper); + static bool isTensorAddress(RigFemResultAddress address); static bool isValid(cvf::Vec3f resultVector); static bool isPressure(float principalValue); bool isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const; std::array createArrowVertices(const TensorVisualization &tensorVisualization) const; - void createTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector& tensorVisualization, - const cvf::ScalarMapper* mapper) const; private: caf::PdmPointer m_rimReservoirView; From 82343d6680800e2dec747b22b91522f8cb63d023 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 16 Feb 2018 09:11:45 +0100 Subject: [PATCH 0272/1027] #2489 Geo mech cases: Hide legend when result is not valid --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index dd0c40e46f..047e51f4a1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -375,7 +375,10 @@ void RimGeoMechView::updateLegends() this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + if (cellResult()->hasResult()) + { + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + } } } From e1619d3d62e88d6148b00a2ff3fab945071c3bce Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Feb 2018 15:38:27 +0100 Subject: [PATCH 0273/1027] #2455 Non-Darcy Flow : Show user defined permeability and rename --- .../RimEllipseFractureTemplate.cpp | 22 ++++++++-------- .../Completions/RimEllipseFractureTemplate.h | 2 +- .../Completions/RimFractureTemplate.cpp | 26 +++++++++---------- .../Completions/RimFractureTemplate.h | 4 +-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 9b5b2f46a4..69515ab20f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -56,7 +56,7 @@ RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) CAF_PDM_InitField(&m_height, "Height", 0.0f, "Height", "", "", ""); CAF_PDM_InitField(&m_width, "Width", 0.0f, "Width", "", "", ""); - CAF_PDM_InitField(&m_permeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); setupFractureGridCells(); @@ -90,7 +90,7 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha if ( changedField == &m_halfLength || changedField == &m_height || changedField == &m_width - || changedField == &m_permeability) + || changedField == &m_userDefinedEffectivePermeability) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -102,7 +102,7 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha setupFractureGridCells(); } } - if (changedField == &m_width || changedField == &m_permeability) + if (changedField == &m_width || changedField == &m_userDefinedEffectivePermeability) { setupFractureGridCells(); } @@ -277,7 +277,7 @@ FractureWidthAndConductivity RimEllipseFractureTemplate::widthAndConductivityAtW { FractureWidthAndConductivity values; values.m_width = m_width; - values.m_permeability = m_permeability; + values.m_permeability = m_userDefinedEffectivePermeability; return values; } @@ -298,14 +298,14 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_width = 0.5f; - m_permeability = 80000.0f; + m_userDefinedEffectivePermeability = 80000.0f; m_halfLength = 300.0f; m_height = 225.0f; } else { m_width = 0.01f; - m_permeability = 100000.0f; + m_userDefinedEffectivePermeability = 100000.0f; m_halfLength = 100.0f; m_height = 75.0f; } @@ -322,12 +322,12 @@ double RimEllipseFractureTemplate::conductivity() const if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { //Conductivity should be md-m, width is in m - cond = m_permeability * m_width; + cond = m_userDefinedEffectivePermeability * m_width; } else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { //Conductivity should be md-ft, but width is in inches - cond = m_permeability * RiaEclipseUnitTools::inchToFeet(m_width); + cond = m_userDefinedEffectivePermeability * RiaEclipseUnitTools::inchToFeet(m_width); } return cond; } @@ -380,12 +380,12 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm if (conductivityType() == FINITE_CONDUCTIVITY) { - m_permeability.uiCapability()->setUiHidden(false); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); m_width.uiCapability()->setUiHidden(false); } else if (conductivityType() == INFINITE_CONDUCTIVITY) { - m_permeability.uiCapability()->setUiHidden(true); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); m_width.uiCapability()->setUiHidden(true); } @@ -402,7 +402,7 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_conductivityType); - propertyGroup->add(&m_permeability); + propertyGroup->add(&m_userDefinedEffectivePermeability); propertyGroup->add(&m_width); propertyGroup->add(&m_skinFactor); propertyGroup->add(&m_perforationLength); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 6b400456b1..aadd7116b3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -82,5 +82,5 @@ class RimEllipseFractureTemplate : public RimFractureTemplate caf::PdmField m_halfLength; caf::PdmField m_height; caf::PdmField m_width; - caf::PdmField m_permeability; + caf::PdmField m_userDefinedEffectivePermeability; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 9806acf644..771bcc10c2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -103,9 +103,9 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField_Basic(&m_useNonDarcyFlow, "UseNonDarcyFlow", false, "Use Non-Darcy Flow"); CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient"); - CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); - CAF_PDM_InitField_Basic(&m_permeabilityScaleFactor,"EffectivePermeabilityScaleFactor", 1.0, "Scale Factor [0..1]"); - CAF_PDM_InitField(&m_permeability, "EffectivePermeability", 0.0, "Effective Permeability", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); + CAF_PDM_InitField_Basic(&m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability"); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability [mD]", "", "", ""); CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density", "", "Relative density of gas at surface conditions with respect to air at STP", ""); CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity", "", "Gas viscosity at bottom hole pressure", ""); @@ -270,8 +270,8 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { auto permGroup = group->addNewGroup("Effective Permeability"); permGroup->add(&m_permeabilityType); - permGroup->add(&m_permeabilityScaleFactor); - permGroup->add(&m_permeability); + permGroup->add(&m_relativePermeability); + permGroup->add(&m_userDefinedEffectivePermeability); } group->add(&m_relativeGasDensity); @@ -366,8 +366,8 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() m_inertialCoefficient.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_permeabilityType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_permeabilityScaleFactor.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_permeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_relativePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_userDefinedEffectivePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_relativeGasDensity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_gasViscosity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); @@ -376,13 +376,13 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() { if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { - m_permeabilityScaleFactor.uiCapability()->setUiHidden(true); - m_permeability.uiCapability()->setUiReadOnly(false); + m_relativePermeability.uiCapability()->setUiHidden(true); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); } else { - m_permeabilityScaleFactor.uiCapability()->setUiHidden(false); - m_permeability.uiCapability()->setUiHidden(true); + m_relativePermeability.uiCapability()->setUiHidden(false); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); } } } @@ -436,7 +436,7 @@ double RimFractureTemplate::effectivePermeability() const { if (m_permeabilityType() == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { - return m_permeability; + return m_userDefinedEffectivePermeability; } else { @@ -444,7 +444,7 @@ double RimFractureTemplate::effectivePermeability() const auto fracPermeability = values.m_permeability; - return fracPermeability * m_permeabilityScaleFactor; + return fracPermeability * m_relativePermeability; } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 3e1f60e774..9f7c425d7c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -145,8 +145,8 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmField> m_permeabilityType; - caf::PdmField m_permeabilityScaleFactor; - caf::PdmField m_permeability; + caf::PdmField m_relativePermeability; + caf::PdmField m_userDefinedEffectivePermeability; caf::PdmField m_relativeGasDensity; caf::PdmField m_gasViscosity; From dda9bd11ea2eac5556a69db9f51cac0d0f961007 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Feb 2018 20:01:41 +0100 Subject: [PATCH 0274/1027] #2455 Non-Darcy Flow : Add fracture width --- .../Completions/RimFractureTemplate.cpp | 84 +++++++++++++------ .../Completions/RimFractureTemplate.h | 17 ++-- 2 files changed, 69 insertions(+), 32 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 771bcc10c2..fe021e13fa 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -55,7 +55,7 @@ namespace caf } template<> - void caf::AppEnum< RimFractureTemplate::EffectivePermeabilityEnum>::setUp() + void caf::AppEnum< RimFractureTemplate::PermeabilityEnum>::setUp() { addItem(RimFractureTemplate::USER_DEFINED_PERMEABILITY, "UserDefinedPermeability", "User Defined"); addItem(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE, "FractureConductivity", "Use Fracture Conductivity"); @@ -63,7 +63,14 @@ namespace caf setDefault(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE); } + template<> + void caf::AppEnum::setUp() + { + addItem(RimFractureTemplate::USER_DEFINED_WIDTH, "UserDefinedWidth", "User Defined"); + addItem(RimFractureTemplate::WIDTH_FROM_FRACTURE, "FractureWidth", "Use Fracture Width"); + setDefault(RimFractureTemplate::WIDTH_FROM_FRACTURE); + } } // TODO Move to cafPdmObject.h @@ -101,14 +108,18 @@ RimFractureTemplate::RimFractureTemplate() // Non-Darcy Flow options CAF_PDM_InitField_Basic(&m_useNonDarcyFlow, "UseNonDarcyFlow", false, "Use Non-Darcy Flow"); - CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient"); + + CAF_PDM_InitFieldNoDefault(&m_fractureWidthType, "FractureWidthType", "Type", "", "", ""); + CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.1, "Fracture Width (h)"); + + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β)"); CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); CAF_PDM_InitField_Basic(&m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability"); - CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability (Ke) [mD]", "", "", ""); - CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density", "", "Relative density of gas at surface conditions with respect to air at STP", ""); - CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity", "", "Gas viscosity at bottom hole pressure", ""); + CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density (γ)", "", "Relative density of gas at surface conditions with respect to air at STP", ""); + CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ)", "", "Gas viscosity at bottom hole pressure", ""); CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::computeDFactor); @@ -262,26 +273,32 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { prepareFieldsForUiDisplay(); - auto group = uiOrdering.addNewGroup("Non-Darcy Flow"); - group->setCollapsedByDefault(true); - group->add(&m_useNonDarcyFlow); - group->add(&m_inertialCoefficient); + auto nonDarcyFlowGroup = uiOrdering.addNewGroup("Non-Darcy Flow"); + nonDarcyFlowGroup->setCollapsedByDefault(true); + nonDarcyFlowGroup->add(&m_useNonDarcyFlow); + nonDarcyFlowGroup->add(&m_inertialCoefficient); { - auto permGroup = group->addNewGroup("Effective Permeability"); - permGroup->add(&m_permeabilityType); - permGroup->add(&m_relativePermeability); - permGroup->add(&m_userDefinedEffectivePermeability); + auto group = nonDarcyFlowGroup->addNewGroup("Effective Permeability"); + group->add(&m_permeabilityType); + group->add(&m_relativePermeability); + group->add(&m_userDefinedEffectivePermeability); } - group->add(&m_relativeGasDensity); - group->add(&m_gasViscosity); - group->add(&m_dFactorDisplayField); + { + auto group = nonDarcyFlowGroup->addNewGroup("Width"); + group->add(&m_fractureWidthType); + group->add(&m_fractureWidth); + } + + nonDarcyFlowGroup->add(&m_relativeGasDensity); + nonDarcyFlowGroup->add(&m_gasViscosity); + nonDarcyFlowGroup->add(&m_dFactorDisplayField); { - auto dFactorGroup = group->addNewGroup("D Factor Details"); - dFactorGroup->setCollapsedByDefault(true); - dFactorGroup->add(&m_dFactorSummaryText); + auto group = nonDarcyFlowGroup->addNewGroup("D Factor Details"); + group->setCollapsedByDefault(true); + group->add(&m_dFactorSummaryText); } uiOrdering.add(&m_fractureTemplateUnit); @@ -365,6 +382,9 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() // Non Darcy Flow m_inertialCoefficient.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_fractureWidthType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_fractureWidth.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_permeabilityType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_relativePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); m_userDefinedEffectivePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); @@ -374,6 +394,18 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() if (m_useNonDarcyFlow) { + if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) + { + m_fractureWidth.uiCapability()->setUiReadOnly(false); + } + else + { + auto values = widthAndConductivityAtWellPathIntersection(); + m_fractureWidth = values.m_width; + + m_fractureWidth.uiCapability()->setUiReadOnly(true); + } + if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { m_relativePermeability.uiCapability()->setUiHidden(true); @@ -415,7 +447,7 @@ QString RimFractureTemplate::dFactorSummary() const text += QString("γ : %1").arg(gamma); text += "
"; - auto h = nonDarcyH(); + auto h = fractureWidth(); text += QString("h : %1").arg(h); text += "
"; @@ -460,7 +492,7 @@ double RimFractureTemplate::computeDFactor() const auto radius = m_wellDiameter / 2.0; auto mu = m_gasViscosity; - auto h = nonDarcyH(); + auto h = fractureWidth(); double numerator = alpha * beta * effPerm * gamma; double denumerator = h * radius * mu; @@ -473,18 +505,16 @@ double RimFractureTemplate::computeDFactor() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::nonDarcyH() const +double RimFractureTemplate::fractureWidth() const { - if (m_orientationType() == RimFractureTemplate::ALONG_WELL_PATH) - { - return m_perforationLength(); - } - else + if (m_fractureWidthType == RimFractureTemplate::WIDTH_FROM_FRACTURE) { auto values = widthAndConductivityAtWellPathIntersection(); return values.m_width; } + + return m_fractureWidth; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 9f7c425d7c..a7a168a2c7 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -73,12 +73,18 @@ class RimFractureTemplate : public caf::PdmObject FINITE_CONDUCTIVITY, }; - enum EffectivePermeabilityEnum + enum PermeabilityEnum { USER_DEFINED_PERMEABILITY, CONDUCTIVITY_FROM_FRACTURE, }; + enum WidthEnum + { + USER_DEFINED_WIDTH, + WIDTH_FROM_FRACTURE, + }; + public: RimFractureTemplate(); virtual ~RimFractureTemplate(); @@ -125,8 +131,7 @@ class RimFractureTemplate : public caf::PdmObject double effectivePermeability() const; double computeDFactor() const; - double nonDarcyH() const; - + double fractureWidth() const; protected: caf::PdmField m_name; @@ -141,10 +146,12 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmChildField m_fractureContainment; caf::PdmField m_useNonDarcyFlow; + + caf::PdmField> m_fractureWidthType; + caf::PdmField m_fractureWidth; caf::PdmField m_inertialCoefficient; - caf::PdmField> - m_permeabilityType; + caf::PdmField> m_permeabilityType; caf::PdmField m_relativePermeability; caf::PdmField m_userDefinedEffectivePermeability; From 8dfe181cc3ffe80c357a27840756ca4dc47b99f1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Feb 2018 21:43:35 +0100 Subject: [PATCH 0275/1027] #2455 Non-Darcy Flow : Add support for user defined D-factor --- .../Completions/RimFractureTemplate.cpp | 125 ++++++++++++------ .../Completions/RimFractureTemplate.h | 11 +- 2 files changed, 92 insertions(+), 44 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index fe021e13fa..162e783a97 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -71,6 +71,16 @@ namespace caf setDefault(RimFractureTemplate::WIDTH_FROM_FRACTURE); } + + template<> + void caf::AppEnum::setUp() + { + addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); + addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Computed by Parameters"); + addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED, "UserDefined", "User Defined Value"); + + setDefault(RimFractureTemplate::NON_DARCY_NONE); + } } // TODO Move to cafPdmObject.h @@ -107,19 +117,21 @@ RimFractureTemplate::RimFractureTemplate() m_fractureContainment.uiCapability()->setUiTreeChildrenHidden(true); // Non-Darcy Flow options - CAF_PDM_InitField_Basic(&m_useNonDarcyFlow, "UseNonDarcyFlow", false, "Use Non-Darcy Flow"); + CAF_PDM_InitFieldNoDefault(&m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow", "", "", ""); + + CAF_PDM_InitField(&m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_fractureWidthType, "FractureWidthType", "Type", "", "", ""); - CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.1, "Fracture Width (h)"); + CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.1, "Fracture Width (h)"); - CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β)"); + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β)"); CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); CAF_PDM_InitField_Basic(&m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability"); CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability (Ke) [mD]", "", "", ""); - CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density (γ)", "", "Relative density of gas at surface conditions with respect to air at STP", ""); - CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ)", "", "Gas viscosity at bottom hole pressure", ""); + CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density (γ)", "", "Relative density of gas at surface conditions with respect to air at STP", ""); + CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ)", "", "Gas viscosity at bottom hole pressure", ""); CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::computeDFactor); @@ -274,34 +286,43 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder prepareFieldsForUiDisplay(); auto nonDarcyFlowGroup = uiOrdering.addNewGroup("Non-Darcy Flow"); - nonDarcyFlowGroup->setCollapsedByDefault(true); - nonDarcyFlowGroup->add(&m_useNonDarcyFlow); - nonDarcyFlowGroup->add(&m_inertialCoefficient); - + nonDarcyFlowGroup->add(&m_nonDarcyFlowType); + + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) { - auto group = nonDarcyFlowGroup->addNewGroup("Effective Permeability"); - group->add(&m_permeabilityType); - group->add(&m_relativePermeability); - group->add(&m_userDefinedEffectivePermeability); + nonDarcyFlowGroup->add(&m_userDefinedDFactor); } + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_COMPUTED) { - auto group = nonDarcyFlowGroup->addNewGroup("Width"); - group->add(&m_fractureWidthType); - group->add(&m_fractureWidth); - } + nonDarcyFlowGroup->add(&m_inertialCoefficient); + + { + auto group = nonDarcyFlowGroup->addNewGroup("Effective Permeability"); + group->add(&m_permeabilityType); + group->add(&m_relativePermeability); + group->add(&m_userDefinedEffectivePermeability); + } - nonDarcyFlowGroup->add(&m_relativeGasDensity); - nonDarcyFlowGroup->add(&m_gasViscosity); - nonDarcyFlowGroup->add(&m_dFactorDisplayField); + { + auto group = nonDarcyFlowGroup->addNewGroup("Width"); + group->add(&m_fractureWidthType); + group->add(&m_fractureWidth); + } - { - auto group = nonDarcyFlowGroup->addNewGroup("D Factor Details"); - group->setCollapsedByDefault(true); - group->add(&m_dFactorSummaryText); + nonDarcyFlowGroup->add(&m_relativeGasDensity); + nonDarcyFlowGroup->add(&m_gasViscosity); + nonDarcyFlowGroup->add(&m_dFactorDisplayField); + + { + auto group = nonDarcyFlowGroup->addNewGroup("D Factor Details"); + group->setCollapsedByDefault(true); + group->add(&m_dFactorSummaryText); + } } uiOrdering.add(&m_fractureTemplateUnit); + uiOrdering.skipRemainingFields(true); } //-------------------------------------------------------------------------------------------------- @@ -380,32 +401,45 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() } // Non Darcy Flow - m_inertialCoefficient.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_fractureWidthType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_fractureWidth.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + bool hideNonDarcyFlowParams = false; + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_COMPUTED) hideNonDarcyFlowParams = false; + + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) + { + m_userDefinedDFactor.uiCapability()->setUiHidden(false); + } + else + { + m_userDefinedDFactor.uiCapability()->setUiHidden(true); + } + + m_inertialCoefficient.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_permeabilityType.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_relativePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_userDefinedEffectivePermeability.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_fractureWidthType.uiCapability()->setUiHidden(hideNonDarcyFlowParams); + m_fractureWidth.uiCapability()->setUiHidden(hideNonDarcyFlowParams); + + m_permeabilityType.uiCapability()->setUiHidden(hideNonDarcyFlowParams); + m_relativePermeability.uiCapability()->setUiHidden(hideNonDarcyFlowParams); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_relativeGasDensity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); - m_gasViscosity.uiCapability()->setUiReadOnly(!m_useNonDarcyFlow); + m_relativeGasDensity.uiCapability()->setUiHidden(hideNonDarcyFlowParams); + m_gasViscosity.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - if (m_useNonDarcyFlow) + if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) { - if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) - { - m_fractureWidth.uiCapability()->setUiReadOnly(false); - } - else - { - auto values = widthAndConductivityAtWellPathIntersection(); - m_fractureWidth = values.m_width; + m_fractureWidth.uiCapability()->setUiReadOnly(false); + } + else + { + auto values = widthAndConductivityAtWellPathIntersection(); + m_fractureWidth = values.m_width; - m_fractureWidth.uiCapability()->setUiReadOnly(true); - } + m_fractureWidth.uiCapability()->setUiReadOnly(true); + } + if (hideNonDarcyFlowParams) + { if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { m_relativePermeability.uiCapability()->setUiHidden(true); @@ -485,6 +519,11 @@ double RimFractureTemplate::effectivePermeability() const //-------------------------------------------------------------------------------------------------- double RimFractureTemplate::computeDFactor() const { + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) + { + return m_userDefinedDFactor; + } + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); auto beta = m_inertialCoefficient; auto effPerm = effectivePermeability(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index a7a168a2c7..8b60fc7de6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -85,6 +85,14 @@ class RimFractureTemplate : public caf::PdmObject WIDTH_FROM_FRACTURE, }; + enum NonDarcyFlowEnum + { + NON_DARCY_NONE, + NON_DARCY_COMPUTED, + NON_DARCY_USER_DEFINED, + }; + + public: RimFractureTemplate(); virtual ~RimFractureTemplate(); @@ -145,7 +153,8 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmField> m_conductivityType; caf::PdmChildField m_fractureContainment; - caf::PdmField m_useNonDarcyFlow; + caf::PdmField> m_nonDarcyFlowType; + caf::PdmField m_userDefinedDFactor; caf::PdmField> m_fractureWidthType; caf::PdmField m_fractureWidth; From 6b246f467110b4a2f225f35eeeb909e76a5b6fcb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Feb 2018 21:58:46 +0100 Subject: [PATCH 0276/1027] Remove unused function --- .../CompletionExportCommands/RigCompletionData.cpp | 14 +------------- .../CompletionExportCommands/RigCompletionData.h | 2 -- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index e502641881..6a611287d2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -43,7 +43,6 @@ RigCompletionData::RigCompletionData(const QString wellName, const RigCompletion , m_count(1) , m_wpimult(HUGE_VAL) , m_isMainBore(false) - , m_readyForExport(false) , m_completionType(CT_UNDEFINED) , m_firstOrderingValue(orderingValue) , m_secondOrderingValue(HUGE_VAL) @@ -161,7 +160,6 @@ void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, { m_completionType = completionType; m_transmissibility = transmissibility; - m_readyForExport = true; } //================================================================================================== @@ -178,7 +176,6 @@ void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpi m_completionType = completionType; m_skinFactor = skinFactor; m_diameter = wellDiameter; - m_readyForExport = true; } //================================================================================================== @@ -320,21 +317,13 @@ bool RigCompletionData::isMainBore() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigCompletionData::readyForExport() const -{ - return m_readyForExport; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- double RigCompletionData::firstOrderingValue() const { return m_firstOrderingValue; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigCompletionData::secondOrderingValue() const { @@ -386,7 +375,6 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& target.m_dFactor = from.m_dFactor; target.m_direction = from.m_direction; target.m_isMainBore = from.m_isMainBore; - target.m_readyForExport = from.m_readyForExport; target.m_count = from.m_count; target.m_wpimult = from.m_wpimult; target.m_completionType = from.m_completionType; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index 8fb30ae498..86d5d02683 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -115,7 +115,6 @@ class RigCompletionData double wpimult() const; CompletionType completionType() const; bool isMainBore() const; - bool readyForExport() const; double firstOrderingValue() const; double secondOrderingValue() const; @@ -135,7 +134,6 @@ class RigCompletionData CellDirection m_direction; bool m_isMainBore; //to use mainbore for Eclipse calculation - bool m_readyForExport; size_t m_count; //TODO: Remove, usage replaced by WPImult double m_wpimult; From ac96824640c7e492467ea0c16b0ae71b4ce09492 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 07:58:07 +0100 Subject: [PATCH 0277/1027] #2455 Non-Darcy Flow : Add fields to fracture template --- .../RicExportFractureCompletionsImpl.cpp | 37 ++++++++++++++- ...ellPathExportCompletionDataFeatureImpl.cpp | 17 +++++-- .../RigCompletionData.cpp | 18 ++++++- .../RigCompletionData.h | 3 ++ .../Completions/RimFractureTemplate.cpp | 47 ++++++++++++------- .../Completions/RimFractureTemplate.h | 5 +- 6 files changed, 104 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 6a75be05f1..10645c68f1 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -339,6 +339,8 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat ///// // Insert total transmissibility from eclipse-cell to well for this fracture into the map + std::vector allCompletionsForOneFracture; + std::set externalCells = transCondenser.externalCells(); for (RigTransmissibilityCondenser::CellAddress externalCell : externalCells) { @@ -354,10 +356,43 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); - fractureCompletions.push_back(compDat); + allCompletionsForOneFracture.push_back(compDat); } } + ///// + // Compute Non-Dracy Flow parameters + + if (fracture->fractureTemplate()->isNonDarcyFlowEnabled()) + { + double dFactorForFracture = fracture->fractureTemplate()->dFactor(); + double khForFracture = fracture->fractureTemplate()->kh(); + + double sumOfTransmissibilitiesInFracture = 0.0; + for (const auto& c : allCompletionsForOneFracture) + { + sumOfTransmissibilitiesInFracture += c.transmissibility(); + } + + if (fabs(sumOfTransmissibilitiesInFracture) > 1e-10) + { + for (auto& c : allCompletionsForOneFracture) + { + if (fabs(c.transmissibility()) > 1e-10) + { + double dFactorForOneConnection = dFactorForFracture * sumOfTransmissibilitiesInFracture / c.transmissibility(); + c.setDFactor(dFactorForOneConnection); + } + + double khForOneConnection = khForFracture * c.transmissibility() / sumOfTransmissibilitiesInFracture; + + c.setKh(khForOneConnection); + } + } + } + + std::copy(allCompletionsForOneFracture.begin(), allCompletionsForOneFracture.end(), std::back_inserter(fractureCompletions)); + if ( outputStreamForIntermediateResultsText ) { (*outputStreamForIntermediateResultsText) << "\n" << "\n" << "\n----------- All Transimissibilities " << fracture->name() << " -------------------- \n\n"; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 7e6cd83b8e..ac4fd05d07 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -325,6 +325,7 @@ RigCompletionData const RicExportCompletionDataSettingsUi& settings) { CVF_ASSERT(!completions.empty()); + QString wellName = completions[0].wellName(); RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); RigCompletionData::CompletionType completionType = completions[0].completionType(); @@ -349,6 +350,10 @@ RigCompletionData RigCompletionData resultCompletion(wellName, cellIndexIJK, completions[0].firstOrderingValue()); resultCompletion.setSecondOrderingValue(completions[0].secondOrderingValue()); + // NOTE : Kh and DFactor is taken from the first completion + resultCompletion.setKh(completions[0].kh()); + resultCompletion.setDFactor(completions[0].dFactor()); + double totalTrans = 0.0; for (const RigCompletionData& completion : completions) @@ -634,13 +639,19 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse case SHUT: formatter.add("SHUT"); break; case AUTO: formatter.add("AUTO"); break; } + if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); - if (RigCompletionData::isDefaultValue(data.transmissibility())) + + if (!RigCompletionData::isDefaultValue(data.dFactor()) || + RigCompletionData::isDefaultValue(data.transmissibility())) { - formatter.add("1*"); // Transmissibility + if (RigCompletionData::isDefaultValue(data.transmissibility())) + formatter.add("1*"); + else + formatter.add(data.transmissibility()); if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); @@ -657,7 +668,7 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else - formatter.add(data.dFactor()); + formatter.add(-data.dFactor()); switch (data.direction()) { diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index 6a611287d2..94b1ba0c3a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -113,7 +113,7 @@ void RigCompletionData::setFromFracture(double transmissibility, double skinFact } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCompletionData::setSecondOrderingValue(double orderingValue) { @@ -178,6 +178,22 @@ void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpi m_diameter = wellDiameter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setDFactor(double dFactor) +{ + m_dFactor = dFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setKh(double kh) +{ + m_kh = kh; +} + //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index 86d5d02683..ca5226ca3b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -97,6 +97,9 @@ class RigCompletionData double wellDiameter, CompletionType completionType); + void setDFactor(double dFactor); + void setKh(double kh); + void addMetadata(const QString& name, const QString& comment); static bool isDefaultValue(double val); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 162e783a97..f8c956f05c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -76,8 +76,8 @@ namespace caf void caf::AppEnum::setUp() { addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); - addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Computed by Parameters"); - addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED, "UserDefined", "User Defined Value"); + addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor from Parameters"); + addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED, "UserDefined", "By User Defined D-factor"); setDefault(RimFractureTemplate::NON_DARCY_NONE); } @@ -134,7 +134,7 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ)", "", "Gas viscosity at bottom hole pressure", ""); CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); - m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::computeDFactor); + m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::dFactor); m_dFactorDisplayField.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", ""); @@ -438,18 +438,15 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() m_fractureWidth.uiCapability()->setUiReadOnly(true); } - if (hideNonDarcyFlowParams) + if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { - if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) - { - m_relativePermeability.uiCapability()->setUiHidden(true); - m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); - } - else - { - m_relativePermeability.uiCapability()->setUiHidden(false); - m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); - } + m_relativePermeability.uiCapability()->setUiHidden(true); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); + } + else + { + m_relativePermeability.uiCapability()->setUiHidden(false); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); } } @@ -460,8 +457,8 @@ QString RimFractureTemplate::dFactorSummary() const { QString text; - auto dFactor = computeDFactor(); - text += QString("D-factor : %1").arg(dFactor); + auto val = dFactor(); + text += QString("D-factor : %1").arg(val); text += "
"; text += "
"; @@ -517,7 +514,7 @@ double RimFractureTemplate::effectivePermeability() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::computeDFactor() const +double RimFractureTemplate::dFactor() const { if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) { @@ -541,6 +538,14 @@ double RimFractureTemplate::computeDFactor() const return numerator / denumerator; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::kh() const +{ + return effectivePermeability() * fractureWidth(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -648,3 +653,11 @@ void RimFractureTemplate::setDefaultWellDiameterFromUnit() m_wellDiameter = 0.216; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFractureTemplate::isNonDarcyFlowEnabled() const +{ + return m_nonDarcyFlowType() != RimFractureTemplate::NON_DARCY_NONE; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 8b60fc7de6..aa7fc79b8b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -125,6 +125,10 @@ class RimFractureTemplate : public caf::PdmObject void setFractureTemplateUnit(RiaEclipseUnitTools::UnitSystemType unitSystem); void setDefaultWellDiameterFromUnit(); + bool isNonDarcyFlowEnabled() const; + double dFactor() const; + double kh() const; + protected: virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -138,7 +142,6 @@ class RimFractureTemplate : public caf::PdmObject QString dFactorSummary() const; double effectivePermeability() const; - double computeDFactor() const; double fractureWidth() const; protected: From 7f5ff7be0fcf1e765c2d53e6d1636301e631f6fb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 08:26:36 +0100 Subject: [PATCH 0278/1027] #2455 Non-Darcy Flow : Use double in fields to avoid many decimals when converting from float to double --- .../RimEllipseFractureTemplate.cpp | 24 +++++++++---------- .../Completions/RimEllipseFractureTemplate.h | 8 +++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 69515ab20f..fe4e6a0a3c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -52,11 +52,11 @@ RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&m_halfLength, "HalfLength", 0.0f, "Halflength Xf", "", "", ""); - CAF_PDM_InitField(&m_height, "Height", 0.0f, "Height", "", "", ""); - CAF_PDM_InitField(&m_width, "Width", 0.0f, "Width", "", "", ""); + CAF_PDM_InitField(&m_halfLength, "HalfLength", 0.0, "Halflength Xf", "", "", ""); + CAF_PDM_InitField(&m_height, "Height", 0.0, "Height", "", "", ""); + CAF_PDM_InitField(&m_width, "Width", 0.0, "Width", "", "", ""); - CAF_PDM_InitField(&m_userDefinedEffectivePermeability,"Permeability", 0.0f, "Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability,"Permeability", 0.0, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); setupFractureGridCells(); @@ -297,17 +297,17 @@ void RimEllipseFractureTemplate::setDefaultValuesFromUnit() { if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - m_width = 0.5f; - m_userDefinedEffectivePermeability = 80000.0f; - m_halfLength = 300.0f; - m_height = 225.0f; + m_width = 0.5; + m_userDefinedEffectivePermeability = 80000.0; + m_halfLength = 300.0; + m_height = 225.0; } else { - m_width = 0.01f; - m_userDefinedEffectivePermeability = 100000.0f; - m_halfLength = 100.0f; - m_height = 75.0f; + m_width = 0.01; + m_userDefinedEffectivePermeability = 100000.0; + m_halfLength = 100.0; + m_height = 75.0; } this->setDefaultWellDiameterFromUnit(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index aadd7116b3..5c7072b38c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -79,8 +79,8 @@ class RimEllipseFractureTemplate : public RimFractureTemplate private: cvf::ref m_fractureGrid; - caf::PdmField m_halfLength; - caf::PdmField m_height; - caf::PdmField m_width; - caf::PdmField m_userDefinedEffectivePermeability; + caf::PdmField m_halfLength; + caf::PdmField m_height; + caf::PdmField m_width; + caf::PdmField m_userDefinedEffectivePermeability; }; From db20cf4b5bfe754bbdcd4c90c604f1ad8053dbe4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 09:33:55 +0100 Subject: [PATCH 0279/1027] #2492 : Non-Darcy Flow : Ignore WPIMULT export setting if non-Darcy Flow is active --- ...ellPathExportCompletionDataFeatureImpl.cpp | 63 +++++++++++++------ .../RigCompletionData.cpp | 11 ++++ .../RigCompletionData.h | 1 + 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index ac4fd05d07..fee142dd2c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -326,15 +326,48 @@ RigCompletionData { CVF_ASSERT(!completions.empty()); - QString wellName = completions[0].wellName(); - RigCompletionDataGridCell cellIndexIJK = completions[0].completionDataGridCell(); - RigCompletionData::CompletionType completionType = completions[0].completionType(); + const RigCompletionData& firstCompletion = completions[0]; + + const QString& wellName = firstCompletion.wellName(); + const RigCompletionDataGridCell& cellIndexIJK = firstCompletion.completionDataGridCell(); + RigCompletionData::CompletionType completionType = firstCompletion.completionType(); + + RigCompletionData resultCompletion(wellName, cellIndexIJK, firstCompletion.firstOrderingValue()); + resultCompletion.setSecondOrderingValue(firstCompletion.secondOrderingValue()); + + bool anyNonDarcyFlowPresent = false; + for (const auto& c : completions) + { + if (c.isNonDarcyFlow()) anyNonDarcyFlowPresent = true; + } + + if (anyNonDarcyFlowPresent && completions.size() > 1) + { + QString errorMessage = + QString("Cannot combine multiple completions when Non-Darcy Flow contribution is present in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; // Returning empty completion, should not be exported + } + + if (firstCompletion.isNonDarcyFlow()) + { + resultCompletion.setKh(firstCompletion.kh()); + resultCompletion.setDFactor(firstCompletion.dFactor()); + + resultCompletion.setCombinedValuesExplicitTrans(firstCompletion.transmissibility(), completionType); + + resultCompletion.m_metadata = firstCompletion.m_metadata; + + return resultCompletion; + } // completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, // if no main bore they are taken from first completion - double skinfactor = completions[0].skinFactor(); - double wellBoreDiameter = completions[0].diameter(); - CellDirection cellDirection = completions[0].direction(); + double skinfactor = firstCompletion.skinFactor(); + double wellBoreDiameter = firstCompletion.diameter(); + CellDirection cellDirection = firstCompletion.direction(); for (const RigCompletionData& completion : completions) { @@ -347,13 +380,6 @@ RigCompletionData } } - RigCompletionData resultCompletion(wellName, cellIndexIJK, completions[0].firstOrderingValue()); - resultCompletion.setSecondOrderingValue(completions[0].secondOrderingValue()); - - // NOTE : Kh and DFactor is taken from the first completion - resultCompletion.setKh(completions[0].kh()); - resultCompletion.setDFactor(completions[0].dFactor()); - double totalTrans = 0.0; for (const RigCompletionData& completion : completions) @@ -362,7 +388,7 @@ RigCompletionData resultCompletion.m_metadata.insert( resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); - if (completion.completionType() != completions[0].completionType()) + if (completion.completionType() != firstCompletion.completionType()) { QString errorMessage = QString("Cannot combine completions of different types in same cell %1") .arg(cellIndexIJK.oneBasedLocalCellIndexString()); @@ -371,7 +397,7 @@ RigCompletionData return resultCompletion; // Returning empty completion, should not be exported } - if (completion.wellName() != completions[0].wellName()) + if (completion.wellName() != firstCompletion.wellName()) { QString errorMessage = QString("Cannot combine completions of different types in same cell %1") .arg(cellIndexIJK.oneBasedLocalCellIndexString()); @@ -639,14 +665,13 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse case SHUT: formatter.add("SHUT"); break; case AUTO: formatter.add("AUTO"); break; } - + if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); - - if (!RigCompletionData::isDefaultValue(data.dFactor()) || - RigCompletionData::isDefaultValue(data.transmissibility())) + + if (data.isNonDarcyFlow() || RigCompletionData::isDefaultValue(data.transmissibility())) { if (RigCompletionData::isDefaultValue(data.transmissibility())) formatter.add("1*"); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index 94b1ba0c3a..33a92550af 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -178,6 +178,17 @@ void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpi m_diameter = wellDiameter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionData::isNonDarcyFlow() const +{ + if (!isDefaultValue(m_kh)) return true; + if (!isDefaultValue(m_dFactor)) return true; + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index ca5226ca3b..b946602f2e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -97,6 +97,7 @@ class RigCompletionData double wellDiameter, CompletionType completionType); + bool isNonDarcyFlow() const; void setDFactor(double dFactor); void setKh(double kh); From ec70639a8f24d279b0d6aa42f38665a108d8ade7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 09:54:51 +0100 Subject: [PATCH 0280/1027] Remove obsolete code --- .../Completions/RimFractureTemplate.cpp | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index f8c956f05c..a724e0949c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -402,30 +402,6 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() // Non Darcy Flow - bool hideNonDarcyFlowParams = false; - if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_COMPUTED) hideNonDarcyFlowParams = false; - - if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) - { - m_userDefinedDFactor.uiCapability()->setUiHidden(false); - } - else - { - m_userDefinedDFactor.uiCapability()->setUiHidden(true); - } - - m_inertialCoefficient.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - - m_fractureWidthType.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_fractureWidth.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - - m_permeabilityType.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_relativePermeability.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - - m_relativeGasDensity.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - m_gasViscosity.uiCapability()->setUiHidden(hideNonDarcyFlowParams); - if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) { m_fractureWidth.uiCapability()->setUiReadOnly(false); From 9184ef14ca125fcf6ccb016a8b993350c6b56984 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 10:14:08 +0100 Subject: [PATCH 0281/1027] AppFwk : Use 'g' instead of 'f' to create text from double values --- Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp index 65bf59e2e8..0ef047576e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp @@ -84,7 +84,7 @@ void PdmUiDoubleValueEditor::configureAndUpdateUi(const QString& uiConfigName) QString textValue; if (valueOk) { - textValue = QString::number(value, 'f', m_attributes.m_decimals); + textValue = QString::number(value, 'g', m_attributes.m_decimals); } else { From b06d33c5e90e744c2434cb3ab29741afd5d3a46a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 10:14:41 +0100 Subject: [PATCH 0282/1027] #2455 Non-Darcy Flow : Use DoubleValueEditor --- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index a724e0949c..45d3a19f7f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -27,6 +27,7 @@ #include "cafPdmObject.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "cafPdmUiDoubleValueEditor.h" #include "cafPdmUiTextEditor.h" #include "cvfVector3.h" @@ -135,6 +136,7 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::dFactor); + m_dFactorDisplayField.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName()); m_dFactorDisplayField.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", ""); From dab73009e731a10e8627ff5fea8b650d6de45a07 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 10:49:53 +0100 Subject: [PATCH 0283/1027] #2456 Non-Darcy Flow : Return the one and only (unmodified) completion --- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index fee142dd2c..4e8e050ff2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -353,14 +353,7 @@ RigCompletionData if (firstCompletion.isNonDarcyFlow()) { - resultCompletion.setKh(firstCompletion.kh()); - resultCompletion.setDFactor(firstCompletion.dFactor()); - - resultCompletion.setCombinedValuesExplicitTrans(firstCompletion.transmissibility(), completionType); - - resultCompletion.m_metadata = firstCompletion.m_metadata; - - return resultCompletion; + return firstCompletion; } // completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, From 52621bae6cf8cad26e3df4ad55dbc071100d30ea Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 10:51:04 +0100 Subject: [PATCH 0284/1027] #2456 Non-Darcy Flow : Include diameter for fracture completions --- .../RicExportFractureCompletionsImpl.cpp | 3 ++- .../Commands/CompletionExportCommands/RigCompletionData.cpp | 3 ++- .../Commands/CompletionExportCommands/RigCompletionData.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 10645c68f1..16a2633334 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -354,7 +354,8 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid()), fracture->fractureMD()); - compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); + double diameter = 2.0 * fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()); + compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor(), diameter); compDat.addMetadata(fracture->name(), QString::number(trans)); allCompletionsForOneFracture.push_back(compDat); } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index 33a92550af..bce30c25e3 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -105,11 +105,12 @@ RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) //================================================================================================== /// //================================================================================================== -void RigCompletionData::setFromFracture(double transmissibility, double skinFactor) +void RigCompletionData::setFromFracture(double transmissibility, double skinFactor, double diameter) { m_completionType = FRACTURE; m_transmissibility = transmissibility; m_skinFactor = skinFactor; + m_diameter = diameter; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index b946602f2e..bf6a9c196e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -75,7 +75,7 @@ class RigCompletionData bool operator<(const RigCompletionData& other) const; RigCompletionData& operator=(const RigCompletionData& other); - void setFromFracture(double transmissibility, double skinFactor); + void setFromFracture(double transmissibility, double skinFactor, double diameter); void setSecondOrderingValue(double orderingValue); void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, From 504e80534bd9cccefdd780a4d4091e7f7a20b6cb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 11:02:50 +0100 Subject: [PATCH 0285/1027] #2456 Non-Darcy Flow : Export : Use scientific formatting for kh and d-factor --- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 4e8e050ff2..087b7c962f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -598,9 +598,11 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse RifEclipseOutputTableColumn( "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn( + "KH", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn( + "Df", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("DIR"), RifEclipseOutputTableColumn("r0")}; @@ -619,9 +621,11 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse RifEclipseOutputTableColumn( "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn( + "KH", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn( + "Df", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), RifEclipseOutputTableColumn("DIR"), RifEclipseOutputTableColumn("r0")}; From cf11eff31993b8e008e1f53d419454fd1e39d876 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 11:22:13 +0100 Subject: [PATCH 0286/1027] #2456 Non-Darcy Flow : Allow transmissibilities close to zero when computing d-factor --- .../RicExportFractureCompletionsImpl.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 16a2633334..8e3384a2a1 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -375,20 +375,16 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat sumOfTransmissibilitiesInFracture += c.transmissibility(); } - if (fabs(sumOfTransmissibilitiesInFracture) > 1e-10) + for (auto& c : allCompletionsForOneFracture) { - for (auto& c : allCompletionsForOneFracture) - { - if (fabs(c.transmissibility()) > 1e-10) - { - double dFactorForOneConnection = dFactorForFracture * sumOfTransmissibilitiesInFracture / c.transmissibility(); - c.setDFactor(dFactorForOneConnection); - } + // NOTE : What is supposed to happen when the transmissibility is close to zero? - double khForOneConnection = khForFracture * c.transmissibility() / sumOfTransmissibilitiesInFracture; + double dFactorForOneConnection = dFactorForFracture * sumOfTransmissibilitiesInFracture / c.transmissibility(); + c.setDFactor(dFactorForOneConnection); - c.setKh(khForOneConnection); - } + double khForOneConnection = khForFracture * c.transmissibility() / sumOfTransmissibilitiesInFracture; + + c.setKh(khForOneConnection); } } From 917cae9e2d69e16712448c6d0744f1b3fca3ddf3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 14:17:28 +0100 Subject: [PATCH 0287/1027] #2455 Non-Darcy Flow : Hide "From Fracture" if no width is available --- .../Completions/RimFractureTemplate.cpp | 35 +++++++++++++- .../Completions/RimFractureTemplate.h | 11 +++++ .../RimStimPlanFractureTemplate.cpp | 47 ++++++++++++++++--- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 45d3a19f7f..907b8f8ee1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -357,7 +357,33 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +QList RimFractureTemplate::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_fractureWidthType) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(USER_DEFINED_WIDTH), USER_DEFINED_WIDTH)); + + auto widthAndCond = widthAndConductivityAtWellPathIntersection(); + if (widthAndCond.isValid()) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(WIDTH_FROM_FRACTURE), WIDTH_FROM_FRACTURE)); + } + else + { + m_fractureWidthType = USER_DEFINED_WIDTH; + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::prepareFieldsForUiDisplay() { @@ -404,13 +430,18 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() // Non Darcy Flow + auto values = widthAndConductivityAtWellPathIntersection(); + if (!values.isValid()) + { + m_fractureWidthType = RimFractureTemplate::USER_DEFINED_WIDTH; + } + if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) { m_fractureWidth.uiCapability()->setUiReadOnly(false); } else { - auto values = widthAndConductivityAtWellPathIntersection(); m_fractureWidth = values.m_width; m_fractureWidth.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index aa7fc79b8b..92aa6cd545 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -47,6 +47,14 @@ class FractureWidthAndConductivity { } + bool isValid() const + { + if (m_width != 0.0) return true; + if (m_permeability != 0.0) return true; + + return false; + } + double m_width; double m_permeability; }; @@ -93,6 +101,8 @@ class RimFractureTemplate : public caf::PdmObject }; + + public: RimFractureTemplate(); virtual ~RimFractureTemplate(); @@ -134,6 +144,7 @@ class RimFractureTemplate : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; private: void prepareFieldsForUiDisplay(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 66bbcc91d3..f33992e33d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -272,6 +272,8 @@ QList RimStimPlanFractureTemplate::calculateValueOptions { QList options; + options = RimFractureTemplate::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + if (fieldNeedingOptions == &m_borderPolygonResultName) { for (std::pair nameUnit : uiResultNamesWithUnit()) @@ -397,18 +399,49 @@ FractureWidthAndConductivity RimStimPlanFractureTemplate::widthAndConductivityAt double conductivity = wellCell.getConductivtyValue(); std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); - for (const auto& nameUnit : propertyNamesUnitsOnFile) + + QString propertyNameForFractureWidth; { - if (nameUnit.first.contains("Width", Qt::CaseInsensitive)) + QString widthParameterName; + QString effWidthParameterName; + for (const auto& nameUnit : propertyNamesUnitsOnFile) { - auto data = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + if (effWidthParameterName.isEmpty() && nameUnit.first.contains("effective width", Qt::CaseInsensitive)) + { + effWidthParameterName = nameUnit.first; + } - double width = data[wellCellIndex]; + if (widthParameterName.isEmpty() && nameUnit.first.contains("width", Qt::CaseInsensitive)) + { + widthParameterName = nameUnit.first; + } + } + + if (!effWidthParameterName.isEmpty()) + { + propertyNameForFractureWidth = effWidthParameterName; + } + else + { + propertyNameForFractureWidth = widthParameterName; + } + } - if (fabs(width) > 1e-7) + if (!propertyNameForFractureWidth.isEmpty()) + { + for (const auto& nameUnit : propertyNamesUnitsOnFile) + { + if (nameUnit.first == propertyNameForFractureWidth) { - values.m_width = width; - values.m_permeability = conductivity / width; + auto data = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + + double width = data[wellCellIndex]; + + if (fabs(width) > 1e-20) + { + values.m_width = width; + values.m_permeability = conductivity / width; + } } } } From 772ba788adb8a443208785e00918fcf5bd8cffb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 16 Feb 2018 14:37:59 +0100 Subject: [PATCH 0288/1027] #2449 2d intersection view. Show UTM intersection point in result info window --- .../RivIntersectionGeometryGenerator.cpp | 36 +++++++++++++++++++ .../RivIntersectionGeometryGenerator.h | 2 ++ .../Intersections/RivIntersectionPartMgr.cpp | 8 +++++ .../Intersections/RivIntersectionPartMgr.h | 3 ++ .../ProjectDataModel/Rim2dIntersectionView.h | 4 ++- .../UserInterface/RiuFemResultTextBuilder.cpp | 28 +++++++++++++-- .../UserInterface/RiuFemResultTextBuilder.h | 3 ++ .../UserInterface/RiuResultTextBuilder.cpp | 31 ++++++++++++++-- .../UserInterface/RiuResultTextBuilder.h | 3 ++ .../RiuSelectionChangedHandler.cpp | 5 +++ .../UserInterface/RiuSelectionManager.cpp | 11 +++++- .../UserInterface/RiuSelectionManager.h | 4 ++- .../UserInterface/RiuViewerCommands.cpp | 2 +- 13 files changed, 132 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 6a0216e485..b605ea648f 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -25,6 +25,7 @@ #include "RimIntersection.h" #include "RivHexGridIntersectionTools.h" +#include "RivIntersectionPartMgr.h" #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" @@ -603,6 +604,41 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const return m_crossSection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +{ + cvf::Vec3d startPt = cvf::Vec3d::ZERO; + + int polyLineIdx = -1; + int segIdx = -1; + for (int i = 0; i < m_flattenedOrOffsettedPolyLines.size(); i++) + { + std::vector pts = m_flattenedOrOffsettedPolyLines[i]; + for(int j = 0; j < pts.size(); j++) + { + // Assumes ascending sorted list + if (j > 0 && intersectionPointUtm.x() < pts[j].x()) + { + polyLineIdx = i; + segIdx = j - 1; + startPt = pts[segIdx]; + break; + } + } + + if (!startPt.isZero()) break; + } + + if (polyLineIdx > -1 && segIdx > -1) + { + cvf::Mat4d t = m_segementTransformPrLinePoint[polyLineIdx][segIdx]; + return t.getInverted(); // Check for invertible? + } + return cvf::Mat4d::ZERO; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index edf1676894..e92cb0b41d 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -75,6 +75,8 @@ class RivIntersectionGeometryGenerator : public cvf::Object RimIntersection* crossSection() const; + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); + private: void calculateArrays(); void calculateSegementTransformPrLinePoint(); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 1139025620..ca794d6b73 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -967,6 +967,14 @@ const RimIntersection* RivIntersectionPartMgr::intersection() const return m_rimCrossSection.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +{ + return m_crossSectionGenerator->unflattenTransformMatrix(intersectionPointUtm); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 6527c970f2..933532b5b3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -24,6 +24,8 @@ #include "cvfColor4.h" #include "cvfVector3.h" #include "cvfArray.h" +#include "cvfMatrix4.h" + #include "cafPdmPointer.h" #include @@ -74,6 +76,7 @@ class RivIntersectionPartMgr : public cvf::Object const RimIntersection* intersection() const; + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); public: static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 13a65aada3..4ed2befb49 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -19,10 +19,10 @@ #pragma once #include "Rim3dView.h" +#include "RivIntersectionPartMgr.h" #include "cafPdmPtrField.h" class RimIntersection; -class RivIntersectionPartMgr; class RimLegendConfig; class RimTernaryLegendConfig; @@ -58,6 +58,8 @@ class Rim2dIntersectionView : public Rim3dView void update3dInfo(); + cvf::ref flatIntersectionPartMgr() const { return m_flatIntersectionPartMgr; } + protected: void updateLegends(); diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index e9d8584d96..343fd71bc8 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -29,6 +29,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "Rim2dIntersectionView.h" #include "RiuGeoMechXfTensorResultAccessor.h" @@ -70,6 +71,14 @@ void RiuFemResultTextBuilder::setIntersectionTriangle(const std::arrayflatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } } } } diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h index dd81d9bea0..9754516c9d 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h @@ -30,6 +30,7 @@ class RigGeoMechCaseData; class RimEclipseCellColors; class RimGeoMechResultDefinition; class RimGeoMechView; +class Rim2dIntersectionView; namespace cvf { class Part; @@ -46,6 +47,7 @@ class RiuFemResultTextBuilder void setFace(int face); void setIntersectionPoint(cvf::Vec3d intersectionPoint); void setIntersectionTriangle(const std::array& triangle); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -63,6 +65,7 @@ class RiuFemResultTextBuilder private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; int m_gridIndex; int m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index 9adf6ff8b6..bc7af30898 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -27,6 +27,8 @@ #include "RigResultAccessorFactory.h" #include "RigSimWellData.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -36,6 +38,8 @@ #include "RimLegendConfig.h" #include "RimReservoirCellResultsStorage.h" +#include "RivIntersectionPartMgr.h" + #include "cafDisplayCoordTransform.h" @@ -73,6 +77,14 @@ void RiuResultTextBuilder::setIntersectionPoint(cvf::Vec3d intersectionPoint) m_intersectionPoint = intersectionPoint; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuResultTextBuilder::set2dIntersectionView(Rim2dIntersectionView* intersectionView) +{ + m_2dIntersectionView = intersectionView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -177,9 +189,24 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + if (m_2dIntersectionView) + { + formattedText.sprintf("Horizontal length from well start: %.2f", domainCoord.x()); + text += formattedText + itemSeparator; - text += formattedText; + cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } } } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index 7f58c8eaad..b3464529c6 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -26,6 +26,7 @@ class RimEclipseView; class RimEclipseCellColors; +class Rim2dIntersectionView; class QString; class RigEclipseCaseData; @@ -44,6 +45,7 @@ class RiuResultTextBuilder void setFace(cvf::StructGridInterface::FaceType face); void setNncIndex(size_t nncIndex); void setIntersectionPoint(cvf::Vec3d intersectionPoint); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -69,6 +71,7 @@ class RiuResultTextBuilder private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; size_t m_gridIndex; size_t m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 40818f6243..2652a71052 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -310,9 +310,12 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd RiuSelectionItem* selItem = const_cast(itemAdded); if (selItem != NULL) { + Rim2dIntersectionView* intersectionView = nullptr; + if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) { const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast(selItem); + intersectionView = wrapperSelItem->view(); if (wrapperSelItem && wrapperSelItem->eclipseSelectionItem()) selItem = wrapperSelItem->eclipseSelectionItem(); else if (wrapperSelItem && wrapperSelItem->geoMechSelectionItem()) selItem = wrapperSelItem->geoMechSelectionItem(); } @@ -327,6 +330,7 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd textBuilder.setFace(eclipseSelectionItem->m_face); textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex); textBuilder.setIntersectionPoint(eclipseSelectionItem->m_localIntersectionPoint); + textBuilder.set2dIntersectionView(intersectionView); resultInfo = textBuilder.mainResultText(); @@ -340,6 +344,7 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep()); textBuilder.setIntersectionPoint(geomSelectionItem->m_localIntersectionPoint); textBuilder.setFace(geomSelectionItem->m_elementFace); + textBuilder.set2dIntersectionView(intersectionView); if (geomSelectionItem->m_hasIntersectionTriangle) textBuilder.setIntersectionTriangle(geomSelectionItem->m_intersectionTriangle); resultInfo = textBuilder.mainResultText(); diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.cpp b/ApplicationCode/UserInterface/RiuSelectionManager.cpp index 2406531454..ca10deb431 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionManager.cpp @@ -218,8 +218,9 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem) +Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem) { + m_view = view; m_eclipseSelItem = dynamic_cast(selItem); m_geoMechSelItem = dynamic_cast(selItem); } @@ -233,6 +234,14 @@ Riu2dIntersectionSelectionItem::~Riu2dIntersectionSelectionItem() if (m_geoMechSelItem) delete m_geoMechSelItem; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmPointer Riu2dIntersectionSelectionItem::view() const +{ + return m_view; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.h b/ApplicationCode/UserInterface/RiuSelectionManager.h index 3b731731a5..a736bc5a61 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.h +++ b/ApplicationCode/UserInterface/RiuSelectionManager.h @@ -206,7 +206,7 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem class Riu2dIntersectionSelectionItem : public RiuSelectionItem { public: - explicit Riu2dIntersectionSelectionItem(RiuSelectionItem *selItem); + explicit Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem); virtual ~Riu2dIntersectionSelectionItem(); @@ -216,10 +216,12 @@ class Riu2dIntersectionSelectionItem : public RiuSelectionItem } public: + caf::PdmPointer view() const; RiuEclipseSelectionItem* eclipseSelectionItem() const; RiuGeoMechSelectionItem* geoMechSelectionItem() const; private: + caf::PdmPointer m_view; RiuEclipseSelectionItem* m_eclipseSelItem; RiuGeoMechSelectionItem* m_geoMechSelItem; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index f70fff7fa4..5af5b8f1c9 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -654,7 +654,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM else selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint); } - if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(selItem); + if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(intersectionView, selItem); } if (appendToSelection) From 88ead1f986574aab1117465a0701d6e4593a80c1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Feb 2018 16:56:39 +0100 Subject: [PATCH 0289/1027] Fix signed /unsigned compare --- .../Intersections/RivIntersectionGeometryGenerator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index b605ea648f..bfe95eaab7 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -613,16 +613,16 @@ cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf: int polyLineIdx = -1; int segIdx = -1; - for (int i = 0; i < m_flattenedOrOffsettedPolyLines.size(); i++) + for (size_t i = 0; i < m_flattenedOrOffsettedPolyLines.size(); i++) { std::vector pts = m_flattenedOrOffsettedPolyLines[i]; - for(int j = 0; j < pts.size(); j++) + for(size_t j = 0; j < pts.size(); j++) { // Assumes ascending sorted list if (j > 0 && intersectionPointUtm.x() < pts[j].x()) { - polyLineIdx = i; - segIdx = j - 1; + polyLineIdx = static_cast(i); + segIdx = static_cast(j) - 1; startPt = pts[segIdx]; break; } From 950617af96eebda2c6dd3723f837bb256f97af5f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 12:34:08 +0100 Subject: [PATCH 0290/1027] AppFwk : Fix assignment of float value --- .../cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp index 50f5db1294..8b7369d21d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp @@ -80,7 +80,7 @@ TEST(SerializeNumbers, SimpleObjectWithDoubleValues) //-------------------------------------------------------------------------------------------------- TEST(SerializeNumbers, SimpleObjectWithFloatValues) { - float valueA = 0.123456789; + float valueA = 0.123456789f; float valueB = 123456 + valueA; QString objectAsText; From 5a2072e6ecd937e687c388687df63d3bba968c21 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 17:55:20 +0100 Subject: [PATCH 0291/1027] clang-tidy : Add minimal config file --- .clang-tidy | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..9f1852b258 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,6 @@ +--- +Checks: '-*,modernize-use-nullptr' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +... From 3239c66f54327bd50abacf5eeed821a644932c30 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 18:05:08 +0100 Subject: [PATCH 0292/1027] AppFwk (clang-tidy) : modernize-use-nullptr --- .../cafCommand/cafCmdExecCommandManager.cpp | 4 +- Fwk/AppFwk/cafCommand/cafCmdFeature.cpp | 2 +- .../cafCommand/cafCmdFeatureManager.cpp | 4 +- .../defaultfeatures/cafCmdAddItemFeature.cpp | 2 +- .../cafCmdDeleteItemFeature.cpp | 6 +-- .../cafPdmCore/cafNotificationCenter.cpp | 2 +- .../cafPdmCore/cafPdmFieldHandle.h | 4 +- .../cafPdmCore/cafPdmObjectHandle.cpp | 14 +++---- .../cafPdmCore/cafPdmReferenceHelper.cpp | 36 ++++++++--------- .../cafProjectDataModel/cafPdmDocument.cpp | 2 +- .../cafPdmUiCommandSystemProxy.cpp | 2 +- .../cafPdmUiCore/cafPdmUiEditorHandle.cpp | 2 +- .../cafPdmUiCore/cafPdmUiFieldEditorHandle.h | 6 +-- .../cafPdmUiCore/cafPdmUiItem.cpp | 8 ++-- .../cafPdmUiCore/cafPdmUiItem.h | 2 +- .../cafPdmUiObjectEditorHandle.cpp | 2 +- .../cafPdmUiCore/cafPdmUiObjectHandle.cpp | 4 +- .../cafPdmUiCore/cafPdmUiObjectHandle.h | 4 +- .../cafPdmUiCore/cafPdmUiTreeOrdering.cpp | 40 +++++++++---------- .../cafPdmUiCore/cafPdmUiTreeOrdering.h | 8 ++-- .../cafPdmUiCore/cafSelectionManager.cpp | 6 +-- .../cafPdmXml/cafPdmDefaultObjectFactory.cpp | 2 +- .../cafPdmXml/cafPdmXmlObjectHandle.cpp | 8 ++-- .../cafTestApplication/CustomObjectEditor.cpp | 2 +- .../cafTestApplication/CustomObjectEditor.h | 2 +- .../cafTestApplication/MainWindow.cpp | 22 +++++----- .../cafTestApplication/WidgetLayoutTest.cpp | 2 +- .../cafTestApplication/WidgetLayoutTest.h | 2 +- Fwk/AppFwk/cafUserInterface/QMinimizePanel.h | 4 +- .../cafPdmUiCheckBoxDelegate.h | 2 +- .../cafPdmUiComboBoxEditor.cpp | 2 +- .../cafPdmUiDoubleSliderEditor.cpp | 2 +- .../cafPdmUiFieldEditorHelper.cpp | 2 +- .../cafUserInterface/cafPdmUiLineEditor.cpp | 2 +- .../cafUserInterface/cafPdmUiListEditor.cpp | 4 +- .../cafUserInterface/cafPdmUiListView.h | 2 +- .../cafPdmUiListViewEditor.cpp | 2 +- .../cafUserInterface/cafPdmUiPropertyView.cpp | 8 ++-- .../cafUserInterface/cafPdmUiPropertyView.h | 4 +- .../cafPdmUiPropertyViewDialog.cpp | 2 +- .../cafUserInterface/cafPdmUiTableView.h | 2 +- .../cafPdmUiTableViewEditor.cpp | 22 +++++----- .../cafPdmUiTableViewModel.cpp | 20 +++++----- .../cafUserInterface/cafPdmUiTableViewModel.h | 2 +- .../cafUserInterface/cafPdmUiTextEditor.h | 2 +- .../cafPdmUiToolButtonEditor.cpp | 2 +- .../cafPdmUiTreeItemEditor.cpp | 2 +- .../cafPdmUiTreeSelectionEditor.cpp | 6 +-- .../cafPdmUiTreeSelectionQModel.h | 2 +- .../cafUserInterface/cafPdmUiTreeView.cpp | 2 +- .../cafUserInterface/cafPdmUiTreeView.h | 2 +- .../cafPdmUiTreeViewEditor.cpp | 8 ++-- .../cafPdmUiTreeViewModel.cpp | 16 ++++---- .../cafPdmUiWidgetBasedObjectEditor.cpp | 10 ++--- .../cafUserInterface/cafProgressInfo.cpp | 4 +- Fwk/AppFwk/cafUserInterface/cafUiProcess.h | 2 +- 56 files changed, 170 insertions(+), 170 deletions(-) diff --git a/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp index a62872d559..2c7ae60011 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp @@ -92,7 +92,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- CmdExecCommandManager::CmdExecCommandManager() { - m_commandFeatureInterface = NULL; + m_commandFeatureInterface = nullptr; m_undoStack = new QUndoStack(); } @@ -124,7 +124,7 @@ void CmdExecCommandManager::activateCommandSystem() //-------------------------------------------------------------------------------------------------- void CmdExecCommandManager::deactivateCommandSystem() { - PdmUiCommandSystemProxy::instance()->setCommandInterface(NULL); + PdmUiCommandSystemProxy::instance()->setCommandInterface(nullptr); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp index 33c50f3a7e..5eaa86f56f 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp @@ -84,7 +84,7 @@ QAction* CmdFeature::actionWithCustomText(const QString& customText) //-------------------------------------------------------------------------------------------------- QAction* CmdFeature::actionWithUserData(const QString& customText, const QVariant& userData) { - QAction* action = NULL; + QAction* action = nullptr; std::map::iterator it; it = m_customTextToActionMap.find(customText); diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp index 0758645d05..d90c1cad7a 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp @@ -170,7 +170,7 @@ std::pair CmdFeatureManager::findExistingCmdFeature(const } else { - return std::make_pair(static_cast(NULL), -1); + return std::make_pair(static_cast(nullptr), -1); } } @@ -191,7 +191,7 @@ caf::CmdFeature* CmdFeatureManager::commandFeature(const std::string& commandId) return item; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp index 031209f85e..b7a006c650 100644 --- a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp +++ b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp @@ -65,7 +65,7 @@ namespace caf CmdExecuteCommand* CmdAddItemFeature::createExecuteCommand() { caf::PdmChildArrayFieldHandle* childArrayFieldHandle = SelectionManager::instance()->activeChildArrayFieldHandle(); - if (!childArrayFieldHandle) return NULL; + if (!childArrayFieldHandle) return nullptr; int indexAfter = -1; CmdAddItemExec* addItemExec = new CmdAddItemExec(SelectionManager::instance()->notificationCenter()); diff --git a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp index c3731af51e..09ae65ca65 100644 --- a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp +++ b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp @@ -61,9 +61,9 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() SelectionManager::instance()->selectedItems(items, SelectionManager::CURRENT); caf::PdmChildArrayFieldHandle* childArrayFieldHandle = caf::SelectionManager::instance()->activeChildArrayFieldHandle(); - if (!childArrayFieldHandle) return NULL; + if (!childArrayFieldHandle) return nullptr; - caf::PdmObjectHandle* currentPdmObject = NULL; + caf::PdmObjectHandle* currentPdmObject = nullptr; for (size_t i = 0; i < items.size(); i++) { @@ -73,7 +73,7 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() } } - if (!currentPdmObject) return NULL; + if (!currentPdmObject) return nullptr; int indexAfter = -1; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp index 6789e4cbdb..9f9241b29c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp @@ -95,7 +95,7 @@ void NotificationCenter::notifyObservers() { foreach(DataModelObserver* o, m_observers) { - o->handleModelNotification(NULL); + o->handleModelNotification(nullptr); } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h index 6a06ec06d2..f0080f9eec 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h @@ -19,7 +19,7 @@ class PdmFieldCapability; class PdmFieldHandle { public: - PdmFieldHandle() { m_ownerObject = NULL; } + PdmFieldHandle() { m_ownerObject = nullptr; } virtual ~PdmFieldHandle(); QString keyword() const { return m_keyword; } @@ -45,7 +45,7 @@ class PdmFieldHandle PdmXmlFieldHandle* xmlCapability(); protected: - bool isInitializedByInitFieldMacro() const { return m_ownerObject != NULL; } + bool isInitializedByInitFieldMacro() const { return m_ownerObject != nullptr; } private: PDM_DISABLE_COPY_AND_ASSIGN(PdmFieldHandle); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp index 6c859f530a..ea72d25d38 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp @@ -24,7 +24,7 @@ PdmObjectHandle::~PdmObjectHandle() std::set::iterator it; for (it = m_pointersReferencingMe.begin(); it != m_pointersReferencingMe.end() ; ++it) { - (**it) = NULL; + (**it) = nullptr; } } @@ -41,7 +41,7 @@ void PdmObjectHandle::fields(std::vector& fields) const //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::setAsParentField(PdmFieldHandle* parentField) { - CAF_ASSERT(m_parentField == NULL); + CAF_ASSERT(m_parentField == nullptr); m_parentField = parentField; } @@ -53,7 +53,7 @@ void PdmObjectHandle::removeAsParentField(PdmFieldHandle* parentField) { CAF_ASSERT(m_parentField == parentField); - m_parentField = NULL; + m_parentField = nullptr; } @@ -62,7 +62,7 @@ void PdmObjectHandle::removeAsParentField(PdmFieldHandle* parentField) //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::addReferencingPtrField(PdmFieldHandle* fieldReferringToMe) { - if (fieldReferringToMe != NULL) m_referencingPtrFields.insert(fieldReferringToMe); + if (fieldReferringToMe != nullptr) m_referencingPtrFields.insert(fieldReferringToMe); } //-------------------------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ void PdmObjectHandle::addReferencingPtrField(PdmFieldHandle* fieldReferringToMe) //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::removeReferencingPtrField(PdmFieldHandle* fieldReferringToMe) { - if (fieldReferringToMe != NULL) m_referencingPtrFields.erase(fieldReferringToMe); + if (fieldReferringToMe != nullptr) m_referencingPtrFields.erase(fieldReferringToMe); } //-------------------------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void PdmObjectHandle::addField(PdmFieldHandle* field, const QString& keyword) field->m_ownerObject = this; CAF_ASSERT(!keyword.isEmpty()); - CAF_ASSERT(this->findField(keyword) == NULL); + CAF_ASSERT(this->findField(keyword) == nullptr); field->setKeyword(keyword); m_fields.push_back(field); @@ -134,7 +134,7 @@ PdmFieldHandle* PdmObjectHandle::findField(const QString& keyword) const } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index b62453472e..b7442a3776 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -54,7 +54,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- QString PdmReferenceHelper::referenceFromRootToObject(PdmObjectHandle* root, PdmObjectHandle* obj) { - if (obj == NULL || root == NULL) return QString(); + if (obj == nullptr || root == nullptr) return QString(); QStringList objectNames = referenceFromRootToObjectAsStringList(root, obj); @@ -67,7 +67,7 @@ QString PdmReferenceHelper::referenceFromRootToObject(PdmObjectHandle* root, Pdm //-------------------------------------------------------------------------------------------------- QString PdmReferenceHelper::referenceFromRootToField(PdmObjectHandle* root, PdmFieldHandle* field) { - if (field == NULL || root == NULL) return QString(); + if (field == nullptr || root == nullptr) return QString(); PdmObjectHandle* owner = field->ownerObject(); if (!owner) return QString(); // Should be assert ? @@ -97,7 +97,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReference(PdmObjectHandle* root, //-------------------------------------------------------------------------------------------------- PdmFieldHandle* PdmReferenceHelper::findField(PdmObjectHandle* object, const QString& fieldKeyword) { - if (object == NULL) return NULL; + if (object == nullptr) return nullptr; std::vector fields; object->fields(fields); @@ -110,7 +110,7 @@ PdmFieldHandle* PdmReferenceHelper::findField(PdmObjectHandle* object, const QSt } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList(PdmObjectH { QStringList objectNames; - if (obj != NULL && root) + if (obj != nullptr && root) { if (obj == root) return objectNames; @@ -186,7 +186,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList(PdmObjectH PdmFieldHandle* PdmReferenceHelper::fieldFromReference(PdmObjectHandle* root, const QString& reference) { QStringList decodedReference = reference.split(" "); - if (decodedReference.size() == 0) return NULL; + if (decodedReference.size() == 0) return nullptr; QString fieldKeyword = decodedReference[0]; decodedReference.pop_front(); @@ -200,7 +200,7 @@ PdmFieldHandle* PdmReferenceHelper::fieldFromReference(PdmObjectHandle* root, co //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHandle* root, const QStringList& reference) { - if (!root) return NULL; + if (!root) return nullptr; PdmObjectHandle* currentObject = root; @@ -212,7 +212,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand PdmFieldHandle* fieldHandle = findField(currentObject, fieldKeyword); if (!fieldHandle) { - return NULL; + return nullptr; } std::vector childObjects; @@ -220,7 +220,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand if (childObjects.size() == 0) { - return NULL; + return nullptr; } QString fieldIndex = reference.at(i++); @@ -228,12 +228,12 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand int index = fieldIndex.toInt(&conversionOk); if (!conversionOk) { - return NULL; + return nullptr; } if (index < 0 || index > ((int)childObjects.size()) - 1) { - return NULL; + return nullptr; } currentObject = childObjects[index]; @@ -258,7 +258,7 @@ std::vector findPathToObjectFromRoot(PdmObjectHandle* obj) } else { - currentObj = NULL; + currentObj = nullptr; } } @@ -281,7 +281,7 @@ QString PdmReferenceHelper::referenceFromFieldToObject(PdmFieldHandle* fromField std::vector toObjPath = findPathToObjectFromRoot(toObj); // Make sure the objects actually have at least one common ancestor - if (fromObjPath.front() != toObjPath.front()) return NULL; + if (fromObjPath.front() != toObjPath.front()) return nullptr; bool anchestorIsEqual = true; size_t idxToLastCommonAnchestor = 0; @@ -318,8 +318,8 @@ QString PdmReferenceHelper::referenceFromFieldToObject(PdmFieldHandle* fromField //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference(PdmFieldHandle* fromField, const QString& reference) { - if (!fromField) return NULL; - if (reference.isEmpty()) return NULL; + if (!fromField) return nullptr; + if (reference.isEmpty()) return nullptr; QStringList decodedReference = reference.split(QRegExp("\\s+"), QString::SkipEmptyParts); PdmObjectHandle* lastCommonAnchestor = fromField->ownerObject(); @@ -332,7 +332,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference(PdmFieldHandle* fr if (!parentField) { // Error: Relative object reference has an invalid number of parent levels - return NULL; + return nullptr; } lastCommonAnchestor = parentField->ownerObject(); @@ -351,7 +351,7 @@ PdmObjectHandle* PdmReferenceHelper::findRoot(PdmObjectHandle* obj) std::vector path = findPathToObjectFromRoot(obj); if (path.size()) return path[0]; - else return NULL; + else return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -365,7 +365,7 @@ PdmObjectHandle* PdmReferenceHelper::findRoot(PdmFieldHandle* field) return findRoot(ownerObject); } - return NULL; + return nullptr; } } // end namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp index 606c07c773..ca3169abf8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp @@ -135,7 +135,7 @@ void PdmDocument::writeFile(QIODevice* xmlFile) //-------------------------------------------------------------------------------------------------- void PdmDocument::updateUiIconStateRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index f813767149..810ad8a96d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -64,7 +64,7 @@ PdmUiCommandSystemProxy* PdmUiCommandSystemProxy::instance() //-------------------------------------------------------------------------------------------------- PdmUiCommandSystemProxy::PdmUiCommandSystemProxy() { - m_commandInterface = NULL; + m_commandInterface = nullptr; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp index 2b7bf1c3d2..74009476b4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp @@ -43,7 +43,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -PdmUiEditorHandle::PdmUiEditorHandle() : m_pdmItem(NULL) +PdmUiEditorHandle::PdmUiEditorHandle() : m_pdmItem(nullptr) { } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h index 4f34bfbbd5..e18b411dc7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h @@ -114,9 +114,9 @@ class PdmUiFieldEditorHandle : public PdmUiEditorHandle /// Implement one of these, or both editor and label. The widgets will be used in the parent layout according to /// being "Label" Editor" or a single combined widget. - virtual QWidget* createCombinedWidget(QWidget * parent) { return NULL; } - virtual QWidget* createEditorWidget(QWidget * parent) { return NULL; } - virtual QWidget* createLabelWidget(QWidget * parent) { return NULL; } + virtual QWidget* createCombinedWidget(QWidget * parent) { return nullptr; } + virtual QWidget* createEditorWidget(QWidget * parent) { return nullptr; } + virtual QWidget* createLabelWidget(QWidget * parent) { return nullptr; } void setValueToField(const QVariant& value); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 7d20464388..2bf1678d20 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -341,14 +341,14 @@ PdmUiItemInfo::LabelPosType PdmUiItem::uiLabelPosition(QString uiConfigName) con const PdmUiItemInfo* PdmUiItem::configInfo(QString uiConfigName) const { - if (uiConfigName == "" || uiConfigName.isNull()) return NULL; + if (uiConfigName == "" || uiConfigName.isNull()) return nullptr; std::map::const_iterator it; it = m_configItemInfos.find(uiConfigName); if (it != m_configItemInfos.end()) return &(it->second); - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -362,7 +362,7 @@ const PdmUiItemInfo* PdmUiItem::defaultInfo() const if (it != m_configItemInfos.end()) return &(it->second); - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -395,7 +395,7 @@ PdmUiItem::~PdmUiItem() std::set::iterator it; for (it = m_editors.begin(); it != m_editors.end(); ++it) { - (*it)->m_pdmItem = NULL; + (*it)->m_pdmItem = nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 4f08a63cf0..91bd07da34 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -191,7 +191,7 @@ bool PdmOptionItemInfo::findValues(const QList& optionList, Q class PdmUiItem { public: - PdmUiItem() : m_staticItemInfo(NULL) { } + PdmUiItem() : m_staticItemInfo(nullptr) { } virtual ~PdmUiItem(); PdmUiItem(const PdmUiItem&) = delete; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp index 4e7afdbf45..711ad73a91 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp @@ -104,7 +104,7 @@ PdmObjectHandle* PdmUiObjectEditorHandle::pdmObject() } else { - return NULL; + return nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp index 7b82d496c5..38fea693ff 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp @@ -25,7 +25,7 @@ PdmUiObjectHandle::PdmUiObjectHandle(PdmObjectHandle* owner, bool giveOwnership) //-------------------------------------------------------------------------------------------------- PdmUiObjectHandle* uiObj(PdmObjectHandle* obj) { - if (!obj) return NULL; + if (!obj) return nullptr; PdmUiObjectHandle* uiObject = obj->capability(); CAF_ASSERT(uiObject); return uiObject; @@ -92,7 +92,7 @@ PdmUiTreeOrdering* PdmUiObjectHandle::uiTreeOrdering(QString uiConfigName /*= "" { CAF_ASSERT(this); // This method actually is possible to call on a NULL ptr without getting a crash, so we assert instead. - PdmUiTreeOrdering* uiTreeOrdering = new PdmUiTreeOrdering(NULL, m_owner); + PdmUiTreeOrdering* uiTreeOrdering = new PdmUiTreeOrdering(nullptr, m_owner); expandUiTree(uiTreeOrdering, uiConfigName); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index 68e6b86dd6..7bfe542b3a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -48,10 +48,10 @@ class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability // Virtual interface to override in subclasses to support special behaviour if needed public: // Virtual - virtual caf::PdmFieldHandle* userDescriptionField() { return NULL; } + virtual caf::PdmFieldHandle* userDescriptionField() { return nullptr; } /// Field used to toggle object on/off in UI-related uses of the object (ie checkbox in treeview) - virtual caf::PdmFieldHandle* objectToggleField() { return NULL; } + virtual caf::PdmFieldHandle* objectToggleField() { return nullptr; } /// Method to reimplement to catch when the field has changed due to setUiValue() virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) {} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp index b46913a8b9..8afceb66c4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp @@ -140,13 +140,13 @@ bool PdmUiTreeOrdering::containsObject(const PdmObjectHandle* object) /// Creates an new root PdmUiTreeOrdering item, pointing at a PdmObject //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : - m_parentItem(NULL), - m_field(NULL), + m_parentItem(nullptr), + m_field(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), + m_uiItem(nullptr), m_object(pdmObject), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr) { } @@ -154,13 +154,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : /// Creates an new root PdmUiTreeOrdering item, pointing at a field //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : - m_parentItem(NULL), + m_parentItem(nullptr), m_field(pdmField), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_uiItem(nullptr), + m_object(nullptr), + m_treeItemEditor(nullptr) { if (pdmField) m_object = pdmField->ownerObject(); } @@ -169,13 +169,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : /// Creates an new root PdmUiTreeOrdering item, as a display item only //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconResourceName) : - m_parentItem(NULL), - m_field(NULL), + m_parentItem(nullptr), + m_field(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_uiItem(nullptr), + m_object(nullptr), + m_treeItemEditor(nullptr) { m_uiItem = new PdmUiItem(); m_uiItem->setUiName(title); @@ -188,12 +188,12 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconR //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent, PdmObjectHandle* pdmObject) : m_parentItem(parent), - m_field(NULL), + m_field(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), + m_uiItem(nullptr), m_object(pdmObject), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr) { if (m_parentItem) { @@ -210,9 +210,9 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent , PdmFieldHandle* m_field(pdmField), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_uiItem(nullptr), + m_object(nullptr), + m_treeItemEditor(nullptr) { if (m_parentItem) { @@ -274,7 +274,7 @@ PdmUiItem* PdmUiTreeOrdering::activeItem() const if (isRepresentingObject()) return uiObj(m_object); if (isRepresentingField()) return m_field->uiCapability(); if (isDisplayItemOnly()) return m_uiItem; - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h index c9a622d248..6528a97af4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h @@ -82,10 +82,10 @@ class PdmUiTreeOrdering void setIgnoreSubTree(bool doIgnoreSubTree ) { m_isToIgnoreSubTree = doIgnoreSubTree; } // Testing for the PdmItem being represented - bool isRepresentingObject() const { return !isRepresentingField() && (m_object != NULL); } - bool isRepresentingField() const { return (m_object != NULL) && (m_field != NULL);} - bool isDisplayItemOnly() const { return (m_uiItem != NULL); } - bool isValid() const { return (this->activeItem() != NULL); } + bool isRepresentingObject() const { return !isRepresentingField() && (m_object != nullptr); } + bool isRepresentingField() const { return (m_object != nullptr) && (m_field != nullptr);} + bool isDisplayItemOnly() const { return (m_uiItem != nullptr); } + bool isValid() const { return (this->activeItem() != nullptr); } // Access to the PdmItem being represented PdmUiItem* activeItem() const; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp index 9233b71ac7..42c8195fad 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp @@ -119,7 +119,7 @@ PdmUiItem* SelectionManager::selectedItem(int role /*= SelectionManager::APPLICA } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -140,8 +140,8 @@ SelectionManager::SelectionManager() { m_selectionForRole.resize(UNDEFINED); - m_notificationCenter = NULL; - m_activeChildArrayFieldHandle = NULL; + m_notificationCenter = nullptr; + m_activeChildArrayFieldHandle = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp index 422e3eb8b7..b6dc8b0dfe 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp @@ -20,7 +20,7 @@ PdmObjectHandle * PdmDefaultObjectFactory::create(const QString& classNameKeywor } else { - return NULL; + return nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp index 645f8aff3a..52e6ae55de 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp @@ -28,7 +28,7 @@ PdmXmlObjectHandle::PdmXmlObjectHandle(PdmObjectHandle* owner, bool giveOwnershi //-------------------------------------------------------------------------------------------------- PdmXmlObjectHandle* xmlObj(PdmObjectHandle* obj) { - if (!obj) return NULL; + if (!obj) return nullptr; PdmXmlObjectHandle* xmlObject = obj->capability(); CAF_ASSERT(xmlObject); return xmlObject; @@ -248,7 +248,7 @@ bool PdmXmlObjectHandle::isValidXmlElementName(const QString& name) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::initAfterReadRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); @@ -278,7 +278,7 @@ void PdmXmlObjectHandle::initAfterReadRecursively(PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::resolveReferencesRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); @@ -308,7 +308,7 @@ void PdmXmlObjectHandle::resolveReferencesRecursively(PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::setupBeforeSaveRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp index 3982460086..9085e7bbe7 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp @@ -155,7 +155,7 @@ void CustomObjectEditor::recursivelyConfigureAndUpdateTopLevelUiItems(const std: { resetCellId(); - QWidget* previousTabOrderWidget = NULL; + QWidget* previousTabOrderWidget = nullptr; for (size_t i = 0; i < topLevelUiItems.size(); ++i) { diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h index c6a945c686..cb5e88593c 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h @@ -71,7 +71,7 @@ class CustomObjectEditor : public PdmUiWidgetBasedObjectEditor void defineGridLayout(int rowCount, int columnCount); // See QGridLayout::addWidget - void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0); + void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = nullptr); void removeWidget(QWidget* widget); void addBlankCell(int row, int column); diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index 4e43e4d42f..b7ef99938a 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -559,7 +559,7 @@ CAF_PDM_SOURCE_INIT(DemoPdmObject, "DemoPdmObject"); -MainWindow* MainWindow::sm_mainWindowInstance = NULL; +MainWindow* MainWindow::sm_mainWindowInstance = nullptr; //-------------------------------------------------------------------------------------------------- /// @@ -789,10 +789,10 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) //-------------------------------------------------------------------------------------------------- MainWindow::~MainWindow() { - m_pdmUiTreeView->setPdmItem(NULL); - m_pdmUiTreeView2->setPdmItem(NULL); - m_pdmUiPropertyView->showProperties(NULL); - m_pdmUiTableView->setListField(NULL); + m_pdmUiTreeView->setPdmItem(nullptr); + m_pdmUiTreeView2->setPdmItem(nullptr); + m_pdmUiPropertyView->showProperties(nullptr); + m_pdmUiTableView->setListField(nullptr); delete m_pdmUiTreeView; delete m_pdmUiTreeView2; @@ -865,7 +865,7 @@ void MainWindow::slotInsert() for (size_t i = 0; i < selection.size(); ++i) { caf::PdmUiFieldHandle* uiFh = dynamic_cast(selection[i]); - caf::PdmChildArrayField< caf::PdmObjectHandle*> * field = NULL; + caf::PdmChildArrayField< caf::PdmObjectHandle*> * field = nullptr; if (uiFh) field = dynamic_cast *>(uiFh->fieldHandle()); @@ -935,8 +935,8 @@ void MainWindow::slotSimpleSelectionChanged() { std::vector selection; m_pdmUiTreeView->selectedUiItems(selection); - caf::PdmObjectHandle* obj = NULL; - caf::PdmChildArrayFieldHandle* listField = NULL; + caf::PdmObjectHandle* obj = nullptr; + caf::PdmChildArrayFieldHandle* listField = nullptr; if (selection.size()) { @@ -954,8 +954,8 @@ void MainWindow::slotShowTableView() { std::vector selection; m_pdmUiTreeView2->selectedUiItems(selection); - caf::PdmObjectHandle* obj = NULL; - caf::PdmChildArrayFieldHandle* listField = NULL; + caf::PdmObjectHandle* obj = nullptr; + caf::PdmChildArrayFieldHandle* listField = nullptr; if (selection.size()) { @@ -969,7 +969,7 @@ void MainWindow::slotShowTableView() { if (!listField->hasSameFieldCountForAllObjects()) { - listField = NULL; + listField = nullptr; } } } diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp index ce5e33eca1..0953e82eaa 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp @@ -96,7 +96,7 @@ void WidgetLayoutTest::setUpInitialConfigurationA() m_mainLayout->addWidget(m_widget2); delete m_widget3; - m_widget3 = NULL; + m_widget3 = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h index 662765c544..2099e34c90 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h @@ -13,7 +13,7 @@ class WidgetLayoutTest : public QWidget Q_OBJECT public: - WidgetLayoutTest(QWidget* parent = 0, Qt::WindowFlags f = 0); + WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~WidgetLayoutTest(); private: diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h index f1738b58d8..670ffbb7c1 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h @@ -51,8 +51,8 @@ class QMinimizePanel : public QWidget { Q_OBJECT public: - explicit QMinimizePanel(QWidget* parent=0); - explicit QMinimizePanel(const QString &title, QWidget* parent=0); + explicit QMinimizePanel(QWidget* parent=nullptr); + explicit QMinimizePanel(const QString &title, QWidget* parent=nullptr); ~QMinimizePanel(); QFrame* contentFrame() { return m_contentFrame; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h index ca50434112..b13b8a0bfe 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h @@ -52,7 +52,7 @@ class PdmUiCheckBoxDelegate : public QStyledItemDelegate Q_OBJECT public: - explicit PdmUiCheckBoxDelegate( QObject* pParent = 0 ); + explicit PdmUiCheckBoxDelegate( QObject* pParent = nullptr ); virtual ~PdmUiCheckBoxDelegate(); virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index 5efac2f178..02eef60c6e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -182,7 +182,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName) class CustomQComboBox : public QComboBox { public: - explicit CustomQComboBox(QWidget* parent = 0) + explicit CustomQComboBox(QWidget* parent = nullptr) : QComboBox(parent) {} diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index a875ac4721..92a06dc0bd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -51,7 +51,7 @@ class PdmDoubleValidator : public QDoubleValidator { public: - explicit PdmDoubleValidator(QObject * parent = 0) : QDoubleValidator(parent) + explicit PdmDoubleValidator(QObject * parent = nullptr) : QDoubleValidator(parent) { } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp index 35f21b0a89..174afc9c6d 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp @@ -49,7 +49,7 @@ //-------------------------------------------------------------------------------------------------- caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::fieldEditorForField(caf::PdmUiFieldHandle* field, const QString& uiConfigName) { - caf::PdmUiFieldEditorHandle* fieldEditor = NULL; + caf::PdmUiFieldEditorHandle* fieldEditor = nullptr; // If editor type is specified, find in factory if (!field->uiEditorTypeName(uiConfigName).isEmpty()) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 0f37949f40..dcea9d4c1e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -208,7 +208,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) { if (isMultipleFieldsWithSameKeywordSelected(field()->fieldHandle())) { - QMessageBox::information(NULL, "Invalid operation", "The field you are manipulating is defined to have unique values. A selection of multiple fields is detected. Please select a single item."); + QMessageBox::information(nullptr, "Invalid operation", "The field you are manipulating is defined to have unique values. A selection of multiple fields is detected. Please select a single item."); } m_lineEdit->setValidator(new PdmUniqueIdValidator(leab.usedIds, isMultipleFieldsWithSameKeywordSelected(field()->fieldHandle()), leab.errorMessage, this)); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index ea7bf022f0..73e985ad0e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -64,7 +64,7 @@ class MyStringListModel : public QStringListModel { public: - explicit MyStringListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent) { } + explicit MyStringListModel(QObject *parent = nullptr) : m_isItemsEditable(false), QStringListModel(parent) { } virtual Qt::ItemFlags flags (const QModelIndex& index) const { @@ -90,7 +90,7 @@ class MyStringListModel : public QStringListModel class QListViewHeightHint : public QListView { public: - explicit QListViewHeightHint(QWidget *parent = 0) + explicit QListViewHeightHint(QWidget *parent = nullptr) : m_heightHint(-1) { } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h index f2a4f12e69..8ec2a9303f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h @@ -54,7 +54,7 @@ class PdmUiListView : public QWidget { Q_OBJECT public: - PdmUiListView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiListView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiListView(); void setPdmObject(caf::PdmObjectCollection* object); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp index 014efad09e..f850ee4482 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp @@ -59,7 +59,7 @@ UiListViewModelPdm::UiListViewModelPdm(QObject* parent) : QAbstractTableModel(parent) { m_columnCount = 0; - m_pdmObjectGroup = NULL; + m_pdmObjectGroup = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index 1f9408cd1b..c8b61f693c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -98,7 +98,7 @@ PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f) dummy->setContentsMargins(0,0,0,0); dummy->addWidget(scrollArea); - m_currentObjectView = NULL; + m_currentObjectView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -123,7 +123,7 @@ void PdmUiPropertyView::setUiConfigurationName(QString uiConfigName) { PdmObjectHandle* object = m_currentObjectView->pdmObject(); delete m_currentObjectView; - m_currentObjectView = NULL; + m_currentObjectView = nullptr; this->showProperties(object); } } @@ -163,7 +163,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) { this->m_placeHolderLayout->removeWidget(m_currentObjectView->widget()); delete m_currentObjectView; - m_currentObjectView = NULL; + m_currentObjectView = nullptr; } if (!m_currentObjectView) @@ -192,7 +192,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmUiPropertyView::currentObject() { - if (!m_currentObjectView) return NULL; + if (!m_currentObjectView) return nullptr; return m_currentObjectView->pdmObject(); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h index c7883b611b..9e50433023 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h @@ -53,7 +53,7 @@ class QVerticalScrollArea : public QScrollArea { Q_OBJECT public: - explicit QVerticalScrollArea(QWidget* parent = 0); + explicit QVerticalScrollArea(QWidget* parent = nullptr); virtual bool eventFilter(QObject* object, QEvent* event) override; }; @@ -72,7 +72,7 @@ class PdmUiPropertyView : public QWidget { Q_OBJECT public: - PdmUiPropertyView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiPropertyView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiPropertyView(); void setUiConfigurationName(QString uiConfigName); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp index f20874fe55..e5febf3df8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp @@ -75,7 +75,7 @@ PdmUiPropertyViewDialog::PdmUiPropertyViewDialog(QWidget* parent, PdmObject* obj //-------------------------------------------------------------------------------------------------- PdmUiPropertyViewDialog::~PdmUiPropertyViewDialog() { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h index ba6e6299e4..855562ee4e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h @@ -76,7 +76,7 @@ class PdmUiTableView : public QWidget, public DataModelObserver { Q_OBJECT public: - PdmUiTableView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiTableView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiTableView(); PdmObjectHandle* pdmObjectFromModelIndex(const QModelIndex& mi); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 238ca9dcc4..05c89f41e5 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -91,13 +91,13 @@ class FocusEventHandler : public QObject //-------------------------------------------------------------------------------------------------- PdmUiTableViewEditor::PdmUiTableViewEditor() { - m_layout = NULL;; - m_tableView = NULL; - m_tableHeading = NULL; - m_tableModelPdm = NULL; - m_tableHeadingIcon = NULL; - m_pdmListField = NULL; - m_delegate = NULL; + m_layout = nullptr;; + m_tableView = nullptr; + m_tableHeading = nullptr; + m_tableModelPdm = nullptr; + m_tableHeadingIcon = nullptr; + m_pdmListField = nullptr; + m_delegate = nullptr; m_useDefaultContextMenu = false; @@ -201,7 +201,7 @@ void PdmUiTableViewEditor::setListField(PdmChildArrayFieldHandle* pdmListField) { m_pdmListField = pdmListField; - caf::PdmUiFieldHandle* uifield = NULL; + caf::PdmUiFieldHandle* uifield = nullptr; if (m_pdmListField) { uifield = m_pdmListField->uiCapability(); @@ -210,7 +210,7 @@ void PdmUiTableViewEditor::setListField(PdmChildArrayFieldHandle* pdmListField) if (!m_pdmListField) { - m_tableModelPdm->setPdmData(NULL, ""); + m_tableModelPdm->setPdmData(nullptr, ""); m_tableHeading->setText(""); m_tableHeadingIcon->setPixmap(QPixmap()); } @@ -297,7 +297,7 @@ void PdmUiTableViewEditor::updateContextMenuSignals() else { m_tableView->setContextMenuPolicy(Qt::DefaultContextMenu); - disconnect(m_tableView, 0, this, 0); + disconnect(m_tableView, nullptr, this, nullptr); } } @@ -375,7 +375,7 @@ PdmObjectHandle* PdmUiTableViewEditor::pdmObjectFromModelIndex(const QModelIndex return m_tableModelPdm->pdmObjectForRow(mi.row()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp index b4da6f43d2..eb5e0c2b61 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp @@ -62,7 +62,7 @@ namespace caf PdmUiTableViewModel::PdmUiTableViewModel(QWidget* parent) : QAbstractTableModel(parent) { - m_pdmList = NULL; + m_pdmList = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -353,7 +353,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const std::map::iterator it; for (it = m_fieldEditors.begin(); it != m_fieldEditors.end(); ++it) { - it->second->setField(NULL); + it->second->setField(nullptr); } m_modelColumnIndexToFieldIndex.clear(); @@ -366,7 +366,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const { PdmUiFieldHandle* field = dynamic_cast(uiItems[i]); - PdmUiFieldEditorHandle* fieldEditor = NULL; + PdmUiFieldEditorHandle* fieldEditor = nullptr; // Find or create FieldEditor std::map::iterator it; @@ -392,7 +392,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const //TODO: Create/update is not required at this point, as UI is recreated in getEditorWidgetAndTransferOwnership() // Can be moved, but a move will require changes in PdmUiFieldEditorHandle - fieldEditor->createWidgets(NULL); + fieldEditor->createWidgets(nullptr); fieldEditor->updateUi(configName); int fieldIndex = getFieldIndex(field->fieldHandle()); @@ -407,7 +407,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const std::vector< QString > fvhToRemoveFromMap; for (it = m_fieldEditors.begin(); it != m_fieldEditors.end(); ++it) { - if (it->second->field() == 0) + if (it->second->field() == nullptr) { PdmUiFieldEditorHandle* fvh = it->second; delete fvh; @@ -451,7 +451,7 @@ PdmFieldHandle* PdmUiTableViewModel::getField(const QModelIndex &index) const } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -462,10 +462,10 @@ PdmUiFieldEditorHandle* PdmUiTableViewModel::getEditor(const QModelIndex &index) PdmFieldHandle* field = getField(index); if (!field) { - return NULL; + return nullptr; } - PdmUiFieldEditorHandle* editor = NULL; + PdmUiFieldEditorHandle* editor = nullptr; std::map::iterator it; it = m_fieldEditors.find(field->keyword()); @@ -503,7 +503,7 @@ QWidget* PdmUiTableViewModel::getEditorWidgetAndTransferOwnership(QWidget* paren return editorWidget; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -559,7 +559,7 @@ PdmObjectHandle* PdmUiTableViewModel::pdmObjectForRow(int row) const return m_pdmList->at(row); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h index cd6904272e..18cde6c980 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h @@ -64,7 +64,7 @@ class TableViewPushButton : public QPushButton { Q_OBJECT public: - explicit TableViewPushButton(caf::PdmUiFieldHandle* field, const QString& text, QWidget* parent = 0); + explicit TableViewPushButton(caf::PdmUiFieldHandle* field, const QString& text, QWidget* parent = nullptr); private slots: void slotPressed(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h index de898ed881..e0e9fc07a0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h @@ -92,7 +92,7 @@ class TextEdit : public QTextEdit { Q_OBJECT public: - explicit TextEdit(QWidget *parent = 0); + explicit TextEdit(QWidget *parent = nullptr); virtual QSize sizeHint() const override; void setHeightHint(int heightHint); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp index 50b18bf29f..872565ffbf 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp @@ -101,7 +101,7 @@ QWidget* PdmUiToolButtonEditor::createEditorWidget(QWidget * parent) //-------------------------------------------------------------------------------------------------- QWidget* PdmUiToolButtonEditor::createLabelWidget(QWidget * parent) { - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp index 011abca12a..3e6d148890 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp @@ -46,7 +46,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- PdmUiTreeItemEditor::PdmUiTreeItemEditor(PdmUiItem* uiItem) { - m_treeViewEditor = NULL; + m_treeViewEditor = nullptr; this->bindToPdmItem(uiItem); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index ca3caf59d7..c481bfd86e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -61,7 +61,7 @@ class QTreeViewHeightHint : public QTreeView { public: - explicit QTreeViewHeightHint(QWidget *parent = 0) + explicit QTreeViewHeightHint(QWidget *parent = nullptr) : m_heightHint(-1) { } @@ -100,7 +100,7 @@ class QTreeViewHeightHint : public QTreeView class FilterLeafNodesOnlyProxyModel : public QSortFilterProxyModel { public: - FilterLeafNodesOnlyProxyModel(QObject *parent = 0) + FilterLeafNodesOnlyProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) { } @@ -131,7 +131,7 @@ class FilterLeafNodesOnlyProxyModel : public QSortFilterProxyModel class PlaceholderLineEdit : public QLineEdit { public: - explicit PlaceholderLineEdit(const QString& placeholderText, QWidget* parent = 0) + explicit PlaceholderLineEdit(const QString& placeholderText, QWidget* parent = nullptr) : QLineEdit(parent), m_placeholderText(placeholderText) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h index a80f788422..9b4191a793 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h @@ -58,7 +58,7 @@ class PdmUiTreeSelectionQModel : public QAbstractItemModel { Q_OBJECT public: - explicit PdmUiTreeSelectionQModel(QObject *parent = 0); + explicit PdmUiTreeSelectionQModel(QObject *parent = nullptr); ~PdmUiTreeSelectionQModel(); static int headingRole(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp index 6867a4133c..a0b0e7c16e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp @@ -132,7 +132,7 @@ void PdmUiTreeView::slotOnSelectionChanged() std::vector objects; m_treeViewEditor->selectedUiItems(objects); - PdmObjectHandle* objHandle = NULL; + PdmObjectHandle* objHandle = nullptr; if (objects.size()) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h index 91685bbc11..366e0baaf2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h @@ -61,7 +61,7 @@ class PdmUiTreeView : public QWidget { Q_OBJECT public: - PdmUiTreeView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiTreeView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiTreeView(); void enableDefaultContextMenu(bool enable); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index 3cd2538941..e6dbc4cacf 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -64,7 +64,7 @@ namespace caf class PdmUiTreeViewWidget : public QTreeView { public: - explicit PdmUiTreeViewWidget(QWidget* parent = 0) : QTreeView(parent) {}; + explicit PdmUiTreeViewWidget(QWidget* parent = nullptr) : QTreeView(parent) {}; virtual ~PdmUiTreeViewWidget() {}; bool isTreeItemEditWidgetActive() const @@ -115,7 +115,7 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor() //-------------------------------------------------------------------------------------------------- PdmUiTreeViewEditor::~PdmUiTreeViewEditor() { - m_treeViewModel->setPdmItemRoot(NULL); + m_treeViewModel->setPdmItemRoot(nullptr); } //-------------------------------------------------------------------------------------------------- @@ -249,7 +249,7 @@ void PdmUiTreeViewEditor::updateContextMenuSignals() else { m_treeView->setContextMenuPolicy(Qt::DefaultContextMenu); - disconnect(m_treeView, 0, this, 0); + disconnect(m_treeView, nullptr, this, nullptr); } } @@ -303,7 +303,7 @@ PdmChildArrayFieldHandle* PdmUiTreeViewEditor::currentChildArrayFieldHandle() } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp index 2cb1ef0cda..846581f362 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp @@ -56,8 +56,8 @@ namespace caf //-------------------------------------------------------------------------------------------------- PdmUiTreeViewModel::PdmUiTreeViewModel(PdmUiTreeViewEditor* treeViewEditor) { - m_treeOrderingRoot = NULL; - m_dragDropInterface = NULL; + m_treeOrderingRoot = nullptr; + m_dragDropInterface = nullptr; m_treeViewEditor = treeViewEditor; } @@ -75,7 +75,7 @@ void PdmUiTreeViewModel::setPdmItemRoot(PdmUiItem* rootItem) return; } - PdmUiTreeOrdering* newRoot = NULL; + PdmUiTreeOrdering* newRoot = nullptr; PdmUiFieldHandle* field = dynamic_cast (rootItem); if (field) @@ -92,7 +92,7 @@ void PdmUiTreeViewModel::setPdmItemRoot(PdmUiItem* rootItem) } } - CAF_ASSERT( newRoot || rootItem == NULL ); // Only fields, objects or NULL is allowed. + CAF_ASSERT( newRoot || rootItem == nullptr ); // Only fields, objects or NULL is allowed. //if (newRoot) newRoot->debugDump(0); @@ -141,7 +141,7 @@ void PdmUiTreeViewModel::updateSubTree(PdmUiItem* pdmRoot) { // Build the new "Correct" Tree - PdmUiTreeOrdering* newTreeRootTmp = NULL; + PdmUiTreeOrdering* newTreeRootTmp = nullptr; PdmUiFieldHandle* field = dynamic_cast (pdmRoot); if (field) { @@ -167,7 +167,7 @@ void PdmUiTreeViewModel::updateSubTree(PdmUiItem* pdmRoot) QModelIndex existingSubTreeRootModIdx = findModelIndex(pdmRoot); - PdmUiTreeOrdering* existingSubTreeRoot = NULL; + PdmUiTreeOrdering* existingSubTreeRoot = nullptr; if (existingSubTreeRootModIdx.isValid()) { existingSubTreeRoot = treeItemFromIndex(existingSubTreeRootModIdx); @@ -460,7 +460,7 @@ QModelIndex PdmUiTreeViewModel::index(int row, int column, const QModelIndex &pa if (!m_treeOrderingRoot) return QModelIndex(); - PdmUiTreeOrdering* parentItem = NULL; + PdmUiTreeOrdering* parentItem = nullptr; if (!parentIndex.isValid()) parentItem = m_treeOrderingRoot; @@ -794,7 +794,7 @@ PdmUiItem* PdmUiTreeViewModel::uiItemFromModelIndex(const QModelIndex& index) co return treeItem->activeItem(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp index 6419e3b31d..4d725388c4 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp @@ -76,7 +76,7 @@ void caf::PdmUiWidgetBasedObjectEditor::recursivelyConfigureAndUpdateUiItemsInGr CAF_ASSERT(containerWidgetWithGridLayout); int currentRowIndex = 0; - QWidget* previousTabOrderWidget = NULL; + QWidget* previousTabOrderWidget = nullptr; // Currently, only QGridLayout is supported QGridLayout* parentLayout = dynamic_cast(containerWidgetWithGridLayout->layout()); @@ -204,8 +204,8 @@ bool caf::PdmUiWidgetBasedObjectEditor::isUiGroupExpanded(const PdmUiGroup* uiGr QMinimizePanel* caf::PdmUiWidgetBasedObjectEditor::findOrCreateGroupBox(QWidget* parent, PdmUiGroup* group, const QString& uiConfigName) { QString groupBoxKey = group->keyword(); - QMinimizePanel* groupBox = NULL; - QGridLayout* groupBoxLayout = NULL; + QMinimizePanel* groupBox = nullptr; + QGridLayout* groupBoxLayout = nullptr; // Find or create groupBox std::map >::iterator it; @@ -338,7 +338,7 @@ void caf::PdmUiWidgetBasedObjectEditor::configureAndUpdateUi(const QString& uiCo std::map::iterator it; for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it) { - it->second->setField(NULL); + it->second->setField(nullptr); } // Set all group Boxes to be unvisited @@ -352,7 +352,7 @@ void caf::PdmUiWidgetBasedObjectEditor::configureAndUpdateUi(const QString& uiCo std::vector< PdmFieldHandle* > fvhToRemoveFromMap; for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it) { - if (it->second->field() == 0) + if (it->second->field() == nullptr) { PdmUiFieldEditorHandle* fvh = it->second; delete fvh; diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index f93989f57a..a288998d7a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -407,7 +407,7 @@ namespace caf { //progressDialog()->setWindowModality(Qt::ApplicationModal); progressDialog()->setMinimum(0); progressDialog()->setWindowTitle(title); - progressDialog()->setCancelButton(NULL); + progressDialog()->setCancelButton(nullptr); progressDialog()->show(); } @@ -557,7 +557,7 @@ namespace caf { // If we are finishing the last level, clean up if (!maxProgressStack_v.size()) { - if (progressDialog() != NULL) + if (progressDialog() != nullptr) { progressDialog()->reset(); progressDialog()->close(); diff --git a/Fwk/AppFwk/cafUserInterface/cafUiProcess.h b/Fwk/AppFwk/cafUserInterface/cafUiProcess.h index b7d365cddb..cdae59e947 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUiProcess.h +++ b/Fwk/AppFwk/cafUserInterface/cafUiProcess.h @@ -60,7 +60,7 @@ class UiProcess : public QProcess QTime m_timer; public: - explicit UiProcess(QObject* pParent = 0); + explicit UiProcess(QObject* pParent = nullptr); private: void doEmitStatusMsg(const QString& msg, int statusMsgType); From cfb75ecc34dd7a5c4e033f256c5b8078d390e7ce Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 18:17:50 +0100 Subject: [PATCH 0293/1027] AppFwk (clang-tidy) : modernize-use-nullptr --- Fwk/AppFwk/CommonCode/cafEffectCache.cpp | 4 ++-- Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp | 14 +++++++------- Fwk/AppFwk/CommonCode/cafMessagePanel.cpp | 2 +- Fwk/AppFwk/CommonCode/cafUtils.cpp | 2 +- .../CommonCode/cvfStructGridGeometryGenerator.cpp | 10 +++++----- Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h | 4 ++-- .../cafAnimControl/cafFrameAnimationControl.h | 2 +- Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp | 4 ++-- Fwk/AppFwk/cafViewer/cafOpenGLWidget.h | 4 ++-- Fwk/AppFwk/cafViewer/cafViewer.cpp | 10 +++++----- .../cafBoxManipulatorGeometryGenerator.cpp | 2 +- Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp | 10 +++++----- .../cafTransparentWBRenderConfiguration.cpp | 2 +- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Fwk/AppFwk/CommonCode/cafEffectCache.cpp b/Fwk/AppFwk/CommonCode/cafEffectCache.cpp index 18bf9e7986..64f33b3e10 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectCache.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectCache.cpp @@ -90,7 +90,7 @@ cvf::Effect* EffectCache::findEffect(const EffectGenerator* generator) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -128,7 +128,7 @@ void EffectCache::releaseUnreferencedEffects() { if (m_effectCache[i].second.p()->refCount() <= 1 ) { - m_effectCache[i].second = NULL; + m_effectCache[i].second = nullptr; delete m_effectCache[i].first; m_effectCache[i].first = NULL; } diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index 4916b004a5..c4c5c265e3 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -214,13 +214,13 @@ cvf::ref EffectGenerator::generateUnCachedEffect() const //-------------------------------------------------------------------------------------------------- void EffectGenerator::updateEffect(cvf::Effect* effect) const { - CVF_ASSERT(effect != NULL); + CVF_ASSERT(effect != nullptr); // Clear effect - effect->setRenderStateSet(NULL); - effect->setUniformSet(NULL); - effect->setShaderProgram(NULL); + effect->setRenderStateSet(nullptr); + effect->setUniformSet(nullptr); + effect->setShaderProgram(nullptr); if (sm_renderingMode == SHADER_BASED) { @@ -629,7 +629,7 @@ EffectGenerator* ScalarMapperEffectGenerator::copy() const cvf::ref ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel) { - CVF_ASSERT(texImg != NULL); + CVF_ASSERT(texImg != nullptr); CVF_ASSERT(texImg->height() == 1); cvf::ref modTexImg = new cvf::TextureImage; @@ -655,9 +655,9 @@ ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* te //-------------------------------------------------------------------------------------------------- bool ScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1, const cvf::TextureImage* texImg2) { - if (texImg1 == NULL && texImg2 == NULL ) return true; + if (texImg1 == nullptr && texImg2 == nullptr ) return true; - if ( texImg1 != NULL && texImg2 != NULL + if ( texImg1 != nullptr && texImg2 != nullptr && texImg1->height() == texImg2->height() && texImg1->width() == texImg2->width() && texImg1->width() > 0 && texImg1->height() > 0 diff --git a/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp b/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp index 53a8ea9725..b6945ef7da 100644 --- a/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp +++ b/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp @@ -45,7 +45,7 @@ namespace caf { -MessagePanel* MessagePanel::sm_messagePanelInstance = NULL; +MessagePanel* MessagePanel::sm_messagePanelInstance = nullptr; //================================================================================================== /// diff --git a/Fwk/AppFwk/CommonCode/cafUtils.cpp b/Fwk/AppFwk/CommonCode/cafUtils.cpp index 10821837de..4922396a6c 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.cpp +++ b/Fwk/AppFwk/CommonCode/cafUtils.cpp @@ -170,7 +170,7 @@ QString Utils::indentString(int numSpacesToIndent, const QString& str) bool Utils::getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector fileNames, QString* saveDir) { bool overWriteFiles = false; - (*saveDir) = QFileDialog::getExistingDirectory(NULL, "Select save directory", defaultDir); + (*saveDir) = QFileDialog::getExistingDirectory(nullptr, "Select save directory", defaultDir); std::vector filesToOverwrite; for (QString fileName : fileNames) diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp index 7a724cd464..5f8e01e014 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp @@ -191,7 +191,7 @@ ref StructGridGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; ref geo = new DrawableGeo; geo->setFromQuadVertexArray(m_vertices.p()); @@ -208,7 +208,7 @@ ref StructGridGeometryGenerator::generateSurface() ref StructGridGeometryGenerator::createMeshDrawable() { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(m_vertices.p()); @@ -228,7 +228,7 @@ ref StructGridGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- ref StructGridGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_vertices); @@ -238,7 +238,7 @@ ref StructGridGeometryGenerator::createOutlineMeshDrawable(double c ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } ref prim = new PrimitiveSetIndexedUInt(PT_LINES); @@ -279,7 +279,7 @@ ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(c cvf::ref cvfVertices = new cvf::Vec3fArray; cvfVertices->assign(vertices); - if (!(cvfVertices.notNull() && cvfVertices->size() != 0)) return NULL; + if (!(cvfVertices.notNull() && cvfVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(cvfVertices.p()); diff --git a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h index 208a0dac78..8f15eb0d15 100644 --- a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h +++ b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h @@ -58,8 +58,8 @@ class AnimationToolBar : public QToolBar Q_OBJECT public: - explicit AnimationToolBar(QWidget *parent = 0); - AnimationToolBar(const QString &title, QWidget *parent = 0); + explicit AnimationToolBar(QWidget *parent = nullptr); + AnimationToolBar(const QString &title, QWidget *parent = nullptr); void connectAnimationControl(caf::FrameAnimationControl* animationControl); diff --git a/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h b/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h index a180548f68..5f8422ccdd 100644 --- a/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h +++ b/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h @@ -53,7 +53,7 @@ class FrameAnimationControl : public QObject Q_OBJECT public: - explicit FrameAnimationControl(QObject* parent = 0); + explicit FrameAnimationControl(QObject* parent = nullptr); void setNumFrames(int numFrames); int numFrames() const; diff --git a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp index 1813c08e3e..099a301ccf 100644 --- a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp +++ b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp @@ -80,7 +80,7 @@ OpenGLWidget::OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLForma // the construction process above has already optimistically added the new context to the existing group. // In this case, the newly context is basically defunct so we just shut it down (which will also remove it from the group) myContext->shutdownContext(); - CVF_ASSERT(myContext->group() == NULL); + CVF_ASSERT(myContext->group() == nullptr); } } else @@ -129,7 +129,7 @@ OpenGLWidget::OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::Wind // the construction process above has already optimistically added the new context to the existing group. // In this case, the newly context is basically defunct so we just shut it down (which will also remove it from the group) myContext->shutdownContext(); - CVF_ASSERT(myContext->group() == NULL); + CVF_ASSERT(myContext->group() == nullptr); } } } diff --git a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h index b0cf0a5cd2..7bbf6176c9 100644 --- a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h +++ b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h @@ -56,8 +56,8 @@ namespace caf { class OpenGLWidget : public QGLWidget { public: - OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent, OpenGLWidget* shareWidget = NULL, Qt::WindowFlags f = 0); - OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::WindowFlags f = 0); + OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent, OpenGLWidget* shareWidget = nullptr, Qt::WindowFlags f = nullptr); + OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::WindowFlags f = nullptr); cvf::OpenGLContext* cvfOpenGLContext() const; void cvfShutdownOpenGLContext(); diff --git a/Fwk/AppFwk/cafViewer/cafViewer.cpp b/Fwk/AppFwk/cafViewer/cafViewer.cpp index 5ec746ebe9..9da9566eb8 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.cpp +++ b/Fwk/AppFwk/cafViewer/cafViewer.cpp @@ -113,7 +113,7 @@ cvf::ref caf::Viewer::sm_openGLContextGroup; //-------------------------------------------------------------------------------------------------- caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent) : caf::OpenGLWidget(contextGroup(), format, new QWidget(parent), sharedWidget()), - m_navigationPolicy(NULL), + m_navigationPolicy(nullptr), m_defaultPerspectiveNearPlaneDistance(0.05), m_maxClipPlaneDistance(cvf::UNDEFINED_DOUBLE), m_cameraFieldOfViewYDeg(40.0), @@ -247,7 +247,7 @@ caf::Viewer* caf::Viewer::sharedWidget() return *(sm_viewers.begin()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -735,7 +735,7 @@ void caf::Viewer::slotSetCurrentFrame(int frameIndex) int clampedFrameIndex = clampFrameIndex(frameIndex); - if (m_frameScenes.at(clampedFrameIndex) == NULL) return; + if (m_frameScenes.at(clampedFrameIndex) == nullptr) return; if (m_releaseOGLResourcesEachFrame) { @@ -885,7 +885,7 @@ cvf::Scene* caf::Viewer::frame(size_t frameIndex) if (frameIndex < m_frameScenes.size()) return m_frameScenes[frameIndex].p(); else - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1103,7 +1103,7 @@ void caf::Viewer::appendAllStaticModelsToFrame(cvf::Scene* scene) //-------------------------------------------------------------------------------------------------- cvf::OverlayItem* caf::Viewer::overlayItem(int winPosX, int winPosY) { - if (m_mainRendering.isNull()) return NULL; + if (m_mainRendering.isNull()) return nullptr; int translatedMousePosX = winPosX; int translatedMousePosY = height() - winPosY; diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp index 8a1254cc76..5dc1603592 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp @@ -55,7 +55,7 @@ cvf::ref BoxManipulatorGeometryGenerator::createBoundingBoxMes calculateArrays(); } - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setVertexArray(m_vertices.p()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp b/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp index fcb33dfd8d..374ef3f607 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp @@ -18055,7 +18055,7 @@ const size_t CVF_FIXED_ATLAS_FONT_LARGE_TEXTURE_IMAGE_BLOCK_COUNT = 588; FixedAtlasFont::FixedAtlasFont(FontSize size) : m_name(""), m_numGlyphs(0), - m_textureImage(NULL) + m_textureImage(nullptr) { bool fontLoaded = false; @@ -18160,7 +18160,7 @@ FixedAtlasFont::FixedAtlasFont(FontSize size) // Make sure isEmpty fails if unable to load if (!fontLoaded) { - m_textureImage = NULL; + m_textureImage = nullptr; } } @@ -18187,11 +18187,11 @@ const cvf::String& FixedAtlasFont::name() const //-------------------------------------------------------------------------------------------------- cvf::ref FixedAtlasFont::getGlyph(wchar_t character) { - if (isEmpty()) return NULL; + if (isEmpty()) return nullptr; cvf::uint characterPos = static_cast(character) > static_cast(m_numGlyphs) ? 0 : static_cast(character); - cvf::ref glyph = NULL; + cvf::ref glyph = nullptr; // Glyph already available? MapType::iterator it = m_atlasMap.find(characterPos); @@ -18368,7 +18368,7 @@ void FixedAtlasFont::unload() m_horizontalAdvances.clear(); m_characterWidths.clear(); m_characterHeights.clear(); - m_textureImage = NULL; + m_textureImage = nullptr; } } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp index dd99dd03df..f98be873c9 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp @@ -128,7 +128,7 @@ class RenderPassPreparator : public cvf::DynamicUniformSet CVF_ASSERT(renderConfiguration); m_renderConfiguration = renderConfiguration; } - virtual cvf::UniformSet* uniformSet() { return NULL; } + virtual cvf::UniformSet* uniformSet() { return nullptr; } virtual void update(cvf::Rendering* rendering) { m_renderConfiguration->updateEffectsForRendering(rendering); From 69875eec8f2508f16bc9c0c18851748a24527d02 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 18:22:23 +0100 Subject: [PATCH 0294/1027] (clang-tidy) : modernize-use-nullptr --- .../GeoMech/GeoMechDataModel/RigFemPart.cpp | 2 +- .../RigFemPartResultsCollection.cpp | 2 +- .../WellPathImportSsihub/RimOilFieldEntry.cpp | 2 +- .../RimWellPathImport.cpp | 4 ++-- .../RiuWellImportWizard.cpp | 24 +++++++++---------- .../RiuWellImportWizard.h | 10 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp index e4a5ba220a..2fb9b568f7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -365,7 +365,7 @@ void RigFemPart::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vec } m_elementSearchTree = new cvf::BoundingBoxTree; - m_elementSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, NULL); + m_elementSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, nullptr); } m_elementSearchTree->findIntersections(inputBB, elementIndices); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 0f6bdead28..93f03d22a8 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1919,7 +1919,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return resFrames; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp b/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp index 544e47d2c0..dae33da0c2 100644 --- a/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp +++ b/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp @@ -128,5 +128,5 @@ RimWellPathEntry* RimOilFieldEntry::find(const QString& name, RimWellPathEntry:: } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp b/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp index 47e39f865a..19b00c39ae 100644 --- a/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp +++ b/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp @@ -115,8 +115,8 @@ void RimWellPathImport::updateRegions(const QStringList& regionStrings, const QS for (int i = 0; i < regionStrings.size(); i++) { - RimOilRegionEntry* oilRegionEntry = NULL; - RimOilFieldEntry* oilFieldEntry = NULL; + RimOilRegionEntry* oilRegionEntry = nullptr; + RimOilFieldEntry* oilFieldEntry = nullptr; for (size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++) { diff --git a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp index e44f32c6f5..9e5e7c66f0 100644 --- a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp +++ b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp @@ -127,7 +127,7 @@ void RiuWellImportWizard::issueHttpRequestToFile(QString completeUrlText, QStrin tr("Unable to save the file %1: %2.") .arg(destinationFileName).arg(m_file->errorString())); delete m_file; - m_file = 0; + m_file = nullptr; return; } @@ -156,7 +156,7 @@ void RiuWellImportWizard::httpFinished() m_file->close(); m_file->remove(); delete m_file; - m_file = 0; + m_file = nullptr; } m_reply->deleteLater(); m_myProgressDialog->hide(); @@ -231,9 +231,9 @@ void RiuWellImportWizard::httpFinished() } m_reply->deleteLater(); - m_reply = 0; + m_reply = nullptr; delete m_file; - m_file = 0; + m_file = nullptr; if (m_currentDownloadState == DOWNLOAD_WELLS || m_currentDownloadState == DOWNLOAD_WELL_PATH) { @@ -446,7 +446,7 @@ void RiuWellImportWizard::downloadWellPaths() { WellSelectionPage* wellSelectionPage = dynamic_cast(page(m_wellSelectionPageId)); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { @@ -537,7 +537,7 @@ QStringList RiuWellImportWizard::absoluteFilePathsToWellPaths() const WellSelectionPage* wellSelectionPage = dynamic_cast(page(m_wellSelectionPageId)); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { @@ -787,7 +787,7 @@ void FieldSelectionPage::initializePage() //-------------------------------------------------------------------------------------------------- FieldSelectionPage::~FieldSelectionPage() { - m_propertyView->showProperties(NULL); + m_propertyView->showProperties(nullptr); } @@ -915,7 +915,7 @@ WellSelectionPage::~WellSelectionPage() { if (m_wellSelectionTreeView) { - m_wellSelectionTreeView->setPdmItem(NULL); + m_wellSelectionTreeView->setPdmItem(nullptr); } delete m_regionsWithVisibleWells; } @@ -926,7 +926,7 @@ WellSelectionPage::~WellSelectionPage() //-------------------------------------------------------------------------------------------------- void WellSelectionPage::selectedWellPathEntries(std::vector& downloadEntities, caf::PdmObjectHandle* objHandle) { - if (objHandle == NULL) + if (objHandle == nullptr) { objHandle = m_regionsWithVisibleWells; } @@ -968,8 +968,8 @@ void WellSelectionPage::selectedWellPathEntries(std::vector& dow //-------------------------------------------------------------------------------------------------- bool lessByDescription(const caf::PdmPointer& obj1, const caf::PdmPointer& obj2) { - caf::PdmUiFieldHandle* uiFieldHandle1 = NULL; - caf::PdmUiFieldHandle* uiFieldHandle2 = NULL; + caf::PdmUiFieldHandle* uiFieldHandle1 = nullptr; + caf::PdmUiFieldHandle* uiFieldHandle2 = nullptr; if (obj1.notNull() && obj1->uiCapability() && obj1->uiCapability()->userDescriptionField()) { @@ -1053,7 +1053,7 @@ void WellSummaryPage::updateSummaryPage() RiuWellImportWizard* wiz = dynamic_cast(wizard()); WellSelectionPage* wellSelectionPage = dynamic_cast(wiz->page(wiz->wellSelectionPageId())); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { diff --git a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h index 92043c5cf4..1fb9b20f6c 100644 --- a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h +++ b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h @@ -57,7 +57,7 @@ class AuthenticationPage : public QWizardPage Q_OBJECT public: - AuthenticationPage(const QString& webServiceAddress, QWidget *parent = 0); + AuthenticationPage(const QString& webServiceAddress, QWidget *parent = nullptr); virtual void initializePage(); }; @@ -71,7 +71,7 @@ class FieldSelectionPage : public QWizardPage Q_OBJECT public: - FieldSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + FieldSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); ~FieldSelectionPage(); virtual void initializePage(); @@ -127,7 +127,7 @@ class WellSelectionPage : public QWizardPage Q_OBJECT public: - WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); ~WellSelectionPage(); virtual void initializePage(); @@ -153,7 +153,7 @@ class WellSummaryPage : public QWizardPage Q_OBJECT public: - WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); virtual void initializePage(); @@ -182,7 +182,7 @@ class RiuWellImportWizard : public QWizard enum DownloadState{ DOWNLOAD_FIELDS, DOWNLOAD_WELLS, DOWNLOAD_WELL_PATH, DOWNLOAD_UNDEFINED}; public: - RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = 0); + RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = nullptr); ~RiuWellImportWizard(); void setCredentials(const QString& username, const QString& password); From 1ae30ef11a19fa09d4ac9a53041db5c0ee7bbef3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 18:56:43 +0100 Subject: [PATCH 0295/1027] (clang-tidy) : modernize-use-nullptr --- .../Application/RiaApplication.cpp | 54 +++++++++---------- .../Tools/RiaImportEclipseCaseTools.cpp | 10 ++-- .../Application/Tools/RiaLogging.cpp | 4 +- .../Application/Tools/RiaProjectModifier.cpp | 4 +- .../RicEditPreferencesFeature.cpp | 2 +- .../ApplicationCommands/RicHelpFeatures.cpp | 2 +- .../RicOpenProjectFeature.cpp | 2 +- .../RicAppendIntersectionFeature.cpp | 4 +- .../RicNewAzimuthDipIntersectionFeature.cpp | 2 +- .../RicNewPolylineIntersectionFeature.cpp | 2 +- .../RicNewSimWellIntersectionFeature.cpp | 4 +- .../RicNewWellPathIntersectionFeature.cpp | 2 +- .../RicAddEclipseInputPropertyFeature.cpp | 2 +- .../RicComputeStatisticsFeature.cpp | 4 +- ...RicCreateGridCaseGroupFromFilesFeature.cpp | 2 +- .../RicEclipseCaseNewGroupExec.cpp | 4 +- .../RicEclipsePropertyFilterFeatureImpl.cpp | 2 +- .../RicEclipsePropertyFilterInsertExec.cpp | 2 +- .../RicEclipsePropertyFilterNewExec.cpp | 2 +- .../RicImportEclipseCasesFeature.cpp | 2 +- .../RicNewStatisticsCaseFeature.cpp | 8 +-- .../ExportCommands/RicExportFaultsFeature.cpp | 2 +- .../RicExportToLasFileFeature.cpp | 2 +- .../RicSaveEclipseInputPropertyFeature.cpp | 4 +- ...icSaveEclipseResultAsInputPropertyExec.cpp | 2 +- .../RicSnapshotViewToFileFeature.cpp | 2 +- .../RicIntersectionBoxAtPosFeature.cpp | 2 +- .../RicIntersectionBoxXSliceFeature.cpp | 2 +- .../RicIntersectionBoxYSliceFeature.cpp | 2 +- .../RicIntersectionBoxZSliceFeature.cpp | 2 +- .../RicNewScriptFeature.cpp | 2 +- .../RicPasteEclipseCasesFeature.cpp | 6 +-- .../RicPasteFeatureImpl.cpp | 6 +-- .../Commands/RicCloseCaseFeature.cpp | 16 +++--- .../Commands/RicDeleteItemExec.cpp | 10 ++-- .../Commands/RicFileHierarchyDialog.cpp | 2 +- .../Commands/RicFileHierarchyDialog.h | 2 +- .../RicGeoMechPropertyFilterInsertExec.cpp | 2 +- .../RicGeoMechPropertyFilterNewExec.cpp | 2 +- .../Commands/RicImportGeoMechCaseFeature.cpp | 2 +- .../Commands/RicImportSummaryCaseFeature.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 2 +- .../Commands/RicNewViewFeature.cpp | 18 +++---- .../Commands/RicRangeFilterExecImpl.cpp | 2 +- .../Commands/RicRangeFilterExecImpl.h | 2 +- .../Commands/RicRangeFilterInsertExec.cpp | 2 +- .../Commands/RicRangeFilterInsertExec.h | 2 +- .../Commands/RicRangeFilterNewExec.cpp | 4 +- .../Commands/RicRangeFilterNewExec.h | 2 +- .../RicSelectOrCreateViewFeatureImpl.cpp | 2 +- .../RicNewGridTimeHistoryCurveFeature.cpp | 2 +- .../RicPasteAsciiDataToSummaryPlotFeature.cpp | 2 +- .../RicSummaryCurveCreator.cpp | 2 +- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 2 +- .../ViewLink/RicShowAllLinkedViewsFeature.cpp | 2 +- .../RicAddWellLogToPlotFeature.cpp | 4 +- .../RicDeleteWellLogPlotTrackFeature.cpp | 4 +- .../RicNewWellLogPlotTrackFeature.cpp | 2 +- .../RifEclipseInputFileTools.cpp | 22 ++++---- .../RifEclipseRestartFilesetAccess.cpp | 2 +- .../FileInterface/RifEclipseSummaryTools.cpp | 22 ++++---- .../RifEclipseUnifiedRestartFileAccess.cpp | 2 +- .../FileInterface/RifHdf5Reader.cpp | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 18 +++---- .../FileInterface/RifReaderEclipseRft.cpp | 2 +- .../FileInterface/RifReaderEclipseSummary.cpp | 4 +- .../FileInterface/RifReaderMockModel.cpp | 2 +- .../RivFemElmVisibilityCalculator.cpp | 10 ++-- .../RivFemPartGeometryGenerator.cpp | 10 ++-- .../RivFemPartPartMgr.cpp | 10 ++-- .../RivGeoMechVizLogic.cpp | 2 +- .../GridBox/RivGridBoxGenerator.cpp | 4 +- .../RivHexGridIntersectionTools.cpp | 4 +- .../RivCellEdgeEffectGenerator.cpp | 2 +- .../RivCellEdgeGeometryUtils.cpp | 8 +-- .../RivFaultGeometryGenerator.cpp | 8 +-- .../ModelVisualization/RivFaultPartMgr.cpp | 6 +-- .../ModelVisualization/RivGridPartMgr.cpp | 2 +- .../RivNNCGeometryGenerator.cpp | 4 +- .../RivPipeGeometryGenerator.cpp | 14 ++--- .../RivReservoirFaultsPartMgr.cpp | 4 +- .../RivReservoirViewPartMgr.cpp | 38 ++++++------- .../RivSimWellPipesPartMgr.cpp | 8 +-- .../RivSingleCellPartGenerator.cpp | 6 +-- .../RivTernaryScalarMapperEffectGenerator.cpp | 4 +- .../RivTernaryTextureCoordsCreator.cpp | 4 +- .../RimFishboneWellPathCollection.cpp | 2 +- .../Rim3dOverlayInfoConfig.cpp | 2 +- .../ProjectDataModel/Rim3dView.cpp | 2 +- .../ProjectDataModel/RimCaseCollection.cpp | 2 +- .../RimCellRangeFilterCollection.cpp | 6 +-- .../ProjectDataModel/RimCommandObject.cpp | 4 +- .../ProjectDataModel/RimEclipseCase.cpp | 6 +-- .../ProjectDataModel/RimEclipseCellColors.cpp | 4 +- .../RimEclipseFaultColors.cpp | 2 +- .../ProjectDataModel/RimEclipseInputCase.cpp | 4 +- .../RimEclipseInputPropertyCollection.cpp | 2 +- .../RimEclipsePropertyFilterCollection.cpp | 4 +- .../ProjectDataModel/RimEclipseResultCase.cpp | 4 +- .../RimEclipseStatisticsCase.cpp | 4 +- .../ProjectDataModel/RimEclipseView.cpp | 24 ++++----- .../ProjectDataModel/RimFaultInView.cpp | 4 +- .../RimFaultInViewCollection.cpp | 4 +- .../ProjectDataModel/RimFormationNames.cpp | 2 +- .../ProjectDataModel/RimGeoMechCellColors.cpp | 2 +- .../RimGeoMechPropertyFilter.cpp | 4 +- .../RimGeoMechPropertyFilterCollection.cpp | 4 +- .../ProjectDataModel/RimGeoMechView.cpp | 8 +-- .../ProjectDataModel/RimGridCollection.cpp | 2 +- .../ProjectDataModel/RimGridView.cpp | 12 ++--- .../RimIdenticalGridCaseGroup.cpp | 14 ++--- .../ProjectDataModel/RimIntersectionBox.cpp | 4 +- .../ProjectDataModel/RimPlotCurve.cpp | 6 +-- .../ProjectDataModel/RimPltPlotCollection.cpp | 4 +- .../RimPropertyFilterCollection.cpp | 4 +- .../RimReservoirCellResultsStorage.cpp | 8 +-- .../ProjectDataModel/RimRftPlotCollection.cpp | 4 +- .../ProjectDataModel/RimScriptCollection.cpp | 4 +- .../RimSimWellInViewCollection.cpp | 4 +- .../ProjectDataModel/RimViewController.cpp | 32 +++++------ .../ProjectDataModel/RimViewLinker.cpp | 8 +-- .../RimWellLogExtractionCurve.cpp | 4 +- .../ProjectDataModel/RimWellLogFile.cpp | 8 +-- .../ProjectDataModel/RimWellLogPlot.cpp | 2 +- .../RimWellLogPlotCollection.cpp | 4 +- .../RimWellPathCollection.cpp | 4 +- .../Summary/RimObservedDataCollection.cpp | 2 +- .../Summary/RimSummaryCase.cpp | 2 +- .../Summary/RimSummaryCurve.cpp | 2 +- .../Summary/RimSummaryCurveCollection.cpp | 2 +- .../Summary/RimSummaryPlot.cpp | 2 +- .../RigActiveCellsResultAccessor.cpp | 4 +- .../RigCaseCellResultsData.cpp | 38 ++++++------- .../RigCaseCellResultsData.h | 2 +- .../RigCaseToCaseCellMapper.cpp | 18 +++---- .../RigCaseToCaseCellMapperTools.cpp | 12 ++--- .../ReservoirDataModel/RigCell.cpp | 6 +-- .../RigCellEdgeResultAccessor.cpp | 4 +- .../RigCombTransResultAccessor.cpp | 2 +- .../ReservoirDataModel/RigGridBase.cpp | 4 +- .../ReservoirDataModel/RigGridManager.cpp | 4 +- .../RigHexIntersectionTools.cpp | 2 +- .../ReservoirDataModel/RigLasFileExporter.cpp | 2 +- .../ReservoirDataModel/RigLocalGrid.cpp | 2 +- .../ReservoirDataModel/RigMainGrid.cpp | 8 +-- .../ReservoirDataModel/RigNNCData.cpp | 2 +- ...igNumberOfFloodedPoreVolumesCalculator.cpp | 6 +-- .../RigReservoirBuilderMock.cpp | 2 +- .../RigResultAccessorFactory.cpp | 14 ++--- .../RigResultModifierFactory.cpp | 16 +++--- .../ReservoirDataModel/RigSimWellData.cpp | 2 +- .../RigSimulationWellCenterLineCalculator.cpp | 4 +- .../ReservoirDataModel/RigWellLogFile.cpp | 6 +-- .../ReservoirDataModel/cvfGeometryTools.cpp | 8 +-- .../ReservoirDataModel/cvfGeometryTools.inl | 2 +- .../SocketInterface/RiaCaseInfoCommands.cpp | 6 +-- .../SocketInterface/RiaNNCCommands.cpp | 2 +- .../RiaProjectInfoCommands.cpp | 6 +-- .../RiaPropertyDataCommands.cpp | 34 ++++++------ .../SocketInterface/RiaSocketServer.cpp | 18 +++---- .../SocketInterface/RiaSocketServer.h | 2 +- .../SocketInterface/RiaSocketTools.cpp | 6 +-- .../UnitTests/HDF5FileReader-Test.cpp | 2 +- .../UnitTests/RigStatisticsMath-Test.cpp | 2 +- ApplicationCode/UserInterface/RiuDragDrop.cpp | 6 +-- .../RiuFlowCharacteristicsPlot.h | 2 +- .../RiuGridStatisticsHistogramWidget.h | 2 +- .../UserInterface/RiuMainPlotWindow.cpp | 10 ++-- .../UserInterface/RiuMainWindow.cpp | 36 ++++++------- .../UserInterface/RiuMdiSubWindow.h | 2 +- .../RiuMultiCaseImportDialog.cpp | 2 +- .../UserInterface/RiuMultiCaseImportDialog.h | 2 +- .../UserInterface/RiuNightchartsWidget.h | 2 +- .../UserInterface/RiuProcessMonitor.cpp | 4 +- .../UserInterface/RiuProjectPropertyView.cpp | 2 +- .../UserInterface/RiuProjectPropertyView.h | 2 +- .../RiuPropertyViewTabWidget.cpp | 2 +- .../UserInterface/RiuPvtPlotPanel.cpp | 10 ++-- .../UserInterface/RiuPvtPlotUpdater.cpp | 10 ++-- .../RiuRecentFileActionProvider.cpp | 2 +- .../RiuRelativePermeabilityPlotUpdater.cpp | 12 ++--- .../UserInterface/RiuResultQwtPlot.h | 2 +- .../RiuSelectionChangedHandler.cpp | 8 +-- .../UserInterface/RiuSimpleHistogramWidget.h | 2 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 2 +- .../UserInterface/RiuSummaryQwtPlot.h | 2 +- ApplicationCode/UserInterface/RiuTextDialog.h | 4 +- .../RiuTofAccumulatedPhaseFractionsPlot.h | 2 +- .../UserInterface/RiuWellAllocationPlot.h | 2 +- .../UserInterface/RiuWellLogPlot.cpp | 4 +- .../UserInterface/RiuWellLogPlot.h | 2 +- .../UserInterface/RiuWellLogTrack.cpp | 2 +- .../UserInterface/RiuWellLogTrack.h | 2 +- .../UserInterface/RiuWellPltPlot.h | 2 +- .../UserInterface/RiuWellRftPlot.h | 2 +- 195 files changed, 552 insertions(+), 552 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index e24da9fa98..6d05e4b3b3 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -216,7 +216,7 @@ RiaApplication::RiaApplication(int& argc, char** argv) setWindowIcon(QIcon(":/AppLogo48x48.png")); m_socketServer = new RiaSocketServer( this); - m_workerProcess = NULL; + m_workerProcess = nullptr; #ifdef WIN32 m_startupDefaultDirectory = QDir::homePath(); @@ -393,10 +393,10 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi closeProject(); QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName); - QMessageBox::warning(NULL, "Error when opening project file", tmp); + QMessageBox::warning(nullptr, "Error when opening project file", tmp); RiuMainWindow* mainWnd = RiuMainWindow::instance(); - mainWnd->setPdmRoot(NULL); + mainWnd->setPdmRoot(nullptr); // Delete all object possibly generated by readFile() delete m_project; @@ -445,8 +445,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; - if (analysisModels == NULL) continue; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; + if (analysisModels == nullptr) continue; for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); ++cgIdx) { @@ -460,8 +460,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for(RimOilField* oilField: m_project->oilFields) { - if (oilField == NULL) continue; - if(oilField->formationNamesCollection() != NULL) + if (oilField == nullptr) continue; + if(oilField->formationNamesCollection() != nullptr) { oilField->formationNamesCollection()->readAllFormationNames(); } @@ -472,8 +472,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - if (oilField == NULL) continue; - if (oilField->wellPathCollection == NULL) + if (oilField == nullptr) continue; + if (oilField->wellPathCollection == nullptr) { //printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx); oilField->wellPathCollection = new RimWellPathCollection(); @@ -488,7 +488,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (RimOilField* oilField: m_project->oilFields) { - if (oilField == NULL) continue; + if (oilField == nullptr) continue; // Temporary if(!oilField->summaryCaseMainCollection()) { @@ -537,7 +537,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { analysisModels->recomputeStatisticsForAllCaseGroups(); @@ -641,7 +641,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi //-------------------------------------------------------------------------------------------------- bool RiaApplication::loadProject(const QString& projectFileName) { - return loadProject(projectFileName, PLA_NONE, NULL); + return loadProject(projectFileName, PLA_NONE, nullptr); } //-------------------------------------------------------------------------------------------------- @@ -789,12 +789,12 @@ void RiaApplication::storeTreeViewState() //-------------------------------------------------------------------------------------------------- void RiaApplication::addWellPathsToModel(QList wellPathFilePaths) { - if (m_project == NULL || m_project->oilFields.size() < 1) return; + if (m_project == nullptr || m_project->oilFields.size() < 1) return; RimOilField* oilField = m_project->activeOilField(); - if (oilField == NULL) return; + if (oilField == nullptr) return; - if (oilField->wellPathCollection == NULL) + if (oilField->wellPathCollection == nullptr) { //printf("Create well path collection.\n"); oilField->wellPathCollection = new RimWellPathCollection(); @@ -895,7 +895,7 @@ bool RiaApplication::saveProjectPromptForFileName() startPath += "/ResInsightProject.rsp"; } - QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"), startPath, tr("Project Files (*.rsp);;All files(*.*)")); + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save File"), startPath, tr("Project Files (*.rsp);;All files(*.*)")); if (fileName.isEmpty()) { return false; @@ -972,7 +972,7 @@ bool RiaApplication::saveProjectAs(const QString& fileName) if (!m_project->writeFile()) { - QMessageBox::warning(NULL, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName)); + QMessageBox::warning(nullptr, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName)); return false; } @@ -1098,10 +1098,10 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName) geoMechCase->setFileName(fileName); geoMechCase->caseUserDescription = caseName; - RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : NULL; + RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : nullptr; // Create the geoMech model container if it is not there already - if (geoMechModelCollection == NULL) + if (geoMechModelCollection == nullptr) { geoMechModelCollection = new RimGeoMechModels(); m_project->activeOilField()->geoMechModels = geoMechModelCollection; @@ -1343,7 +1343,7 @@ int RiaApplication::launchUnitTestsWithConsole() //-------------------------------------------------------------------------------------------------- void RiaApplication::createMainPlotWindow() { - CVF_ASSERT(m_mainPlotWindow == NULL); + CVF_ASSERT(m_mainPlotWindow == nullptr); m_mainPlotWindow = new RiuMainPlotWindow; @@ -1361,7 +1361,7 @@ void RiaApplication::deleteMainPlotWindow() if (m_mainPlotWindow) { m_mainPlotWindow->deleteLater(); - m_mainPlotWindow = NULL; + m_mainPlotWindow = nullptr; } } @@ -1415,7 +1415,7 @@ RiuMainWindowBase* RiaApplication::mainWindowByID(int mainWindowID) //-------------------------------------------------------------------------------------------------- RimViewWindow* RiaApplication::activeViewWindow() { - RimViewWindow* viewWindow = NULL; + RimViewWindow* viewWindow = nullptr; QWidget* mainWindowWidget = RiaApplication::activeWindow(); @@ -1609,7 +1609,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu { m_workerProcess->close(); } - m_workerProcess = NULL; + m_workerProcess = nullptr; // Either the work process crashed or was aborted by the user if (exitStatus == QProcess::CrashExit) @@ -1649,7 +1649,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu //-------------------------------------------------------------------------------------------------- bool RiaApplication::launchProcess(const QString& program, const QStringList& arguments) { - if (m_workerProcess == NULL) + if (m_workerProcess == nullptr) { // If multiple cases are present, pop the first case ID from the list and set as current case if (!m_currentCaseIds.empty()) @@ -1701,7 +1701,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar if (!m_workerProcess->waitForStarted(1000)) { m_workerProcess->close(); - m_workerProcess = NULL; + m_workerProcess = nullptr; m_runningWorkerProcess = false; RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); @@ -1715,7 +1715,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar } else { - QMessageBox::warning(NULL, "Script execution", "An Octave process is still running. Please stop this process before executing a new script."); + QMessageBox::warning(nullptr, "Script execution", "An Octave process is still running. Please stop this process before executing a new script."); return false; } } @@ -1825,7 +1825,7 @@ void RiaApplication::terminateProcess() } m_runningWorkerProcess = false; - m_workerProcess = NULL; + m_workerProcess = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 12336ec1cf..0ed45c19c1 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -92,8 +92,8 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); - RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : NULL; - if (analysisModels == NULL) return false; + RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : nullptr; + if (analysisModels == nullptr) return false; RiuMainWindow::instance()->show(); @@ -114,7 +114,7 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr // Add a corresponding summary case if it exists { - RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : NULL; + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if (sumCaseColl) { { @@ -193,9 +193,9 @@ bool RiaImportEclipseCaseTools::addEclipseCases(const QStringList& fileNames) // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RimEclipseResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = nullptr; std::vector< std::vector > mainCaseGridDimensions; - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); diff --git a/ApplicationCode/Application/Tools/RiaLogging.cpp b/ApplicationCode/Application/Tools/RiaLogging.cpp index ed0f5a6f06..a104ca1d66 100644 --- a/ApplicationCode/Application/Tools/RiaLogging.cpp +++ b/ApplicationCode/Application/Tools/RiaLogging.cpp @@ -157,7 +157,7 @@ void RiaDefaultConsoleLogger::writeToConsole(const std::string& str) DWORD stringLength = static_cast(str.length()); unsigned long iDum = 0; - WriteConsoleA(hStdOutputHandle, str.c_str(), stringLength, &iDum, NULL); + WriteConsoleA(hStdOutputHandle, str.c_str(), stringLength, &iDum, nullptr); } #else fputs(str.c_str(), stderr); @@ -203,7 +203,7 @@ void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance) void RiaLogging::deleteLoggerInstance() { delete sm_logger; - sm_logger = NULL; + sm_logger = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaProjectModifier.cpp b/ApplicationCode/Application/Tools/RiaProjectModifier.cpp index d922721315..82fae44ba2 100644 --- a/ApplicationCode/Application/Tools/RiaProjectModifier.cpp +++ b/ApplicationCode/Application/Tools/RiaProjectModifier.cpp @@ -125,7 +125,7 @@ void RiaProjectModifier::replaceSourceCases(RimProject* project) { for (RimOilField* oilField : project->oilFields()) { - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { for (RimIdenticalGridCaseGroup* caseGroup : analysisModels->caseGroups) @@ -280,7 +280,7 @@ int RiaProjectModifier::firstGroupId(RimProject* project) for (size_t oilFieldIdx = 0; oilFieldIdx < project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { if (analysisModels->caseGroups.size() > 0) diff --git a/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp index 28e668088b..08d5b8f875 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp @@ -47,7 +47,7 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QStringList tabNames = app->preferences()->tabNames(); - RiuPropertyViewTabWidget propertyDialog(NULL, app->preferences(), "Preferences", tabNames); + RiuPropertyViewTabWidget propertyDialog(nullptr, app->preferences(), "Preferences", tabNames); if (propertyDialog.exec() == QDialog::Accepted) { // Write preferences using QSettings and apply them to the application diff --git a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp index 996a76054c..250e551d6c 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp @@ -50,7 +50,7 @@ void RicHelpAboutFeature::onActionTriggered(bool isChecked) { this->disableModelChangeContribution(); - caf::AboutDialog dlg(NULL); + caf::AboutDialog dlg(nullptr); dlg.setApplicationName(RI_APPLICATION_NAME); dlg.setApplicationVersion(RiaApplication::getVersionStringApp(true)); diff --git a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp index 64f5da34df..6cd939a452 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp @@ -46,7 +46,7 @@ void RicOpenProjectFeature::onActionTriggered(bool isChecked) if (!app->askUserToSaveModifiedProject()) return; QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QString fileName = QFileDialog::getOpenFileName(NULL, "Open ResInsight Project", defaultDir, "ResInsight project (*.rsp *.rip);;All files(*.*)"); + QString fileName = QFileDialog::getOpenFileName(nullptr, "Open ResInsight Project", defaultDir, "ResInsight project (*.rsp *.rip);;All files(*.*)"); if (fileName.isEmpty()) return; diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index c8ea315507..fe8ef29fdd 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -49,7 +49,7 @@ void RicAppendIntersectionFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&collection); CVF_ASSERT(collection.size() == 1); - RimIntersectionCollection* intersectionCollection = NULL; + RimIntersectionCollection* intersectionCollection = nullptr; collection[0]->firstAncestorOrThisOfType(intersectionCollection); CVF_ASSERT(intersectionCollection); @@ -71,7 +71,7 @@ void RicAppendIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicAppendIntersectionFeatureCmd::RicAppendIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index c8979ff15f..1a1aedc2c7 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -81,7 +81,7 @@ void RicNewAzimuthDipIntersectionFeature::setupActionLook(QAction* actionToSetup /// //-------------------------------------------------------------------------------------------------- RicNewAzimuthDipIntersectionFeatureCmd::RicNewAzimuthDipIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index 70e67f3054..c2bcf150e1 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -80,7 +80,7 @@ void RicNewPolylineIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewPolylineIntersectionFeatureCmd::RicNewPolylineIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp index 4a9003ff38..f27011a7b6 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp @@ -52,7 +52,7 @@ void RicNewSimWellIntersectionFeature::onActionTriggered(bool isChecked) RimSimWellInView* simWell = collection[0]; - RimEclipseView* eclView = NULL; + RimEclipseView* eclView = nullptr; simWell->firstAncestorOrThisOfType(eclView); CVF_ASSERT(eclView); @@ -73,7 +73,7 @@ void RicNewSimWellIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewSimWellIntersectionCmd::RicNewSimWellIntersectionCmd(RimIntersectionCollection* intersectionCollection, RimSimWellInView* simWell) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection), m_simWell(simWell) { diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index 8952631522..b885afe50b 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -82,7 +82,7 @@ void RicNewWellPathIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewWellPathIntersectionFeatureCmd::RicNewWellPathIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection, RimWellPath* wellPath) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection), m_wellPath(wellPath) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp index de61fc1a35..249c3da997 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicAddEclipseInputPropertyFeature, "RicAddEclipseInputProper //-------------------------------------------------------------------------------------------------- bool RicAddEclipseInputPropertyFeature::isCommandEnabled() { - return selectedInputPropertyCollection() != NULL; + return selectedInputPropertyCollection() != nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp index 939b6aca65..242a471d54 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp @@ -43,10 +43,10 @@ bool RicComputeStatisticsFeature::isCommandEnabled() RimEclipseStatisticsCase* statisticsCase = selection[0]; if (statisticsCase) { - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; statisticsCase->firstAncestorOrThisOfType(gridCaseGroup); - RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : NULL; + RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : nullptr; return caseCollection ? caseCollection->reservoirs.size() > 0 : false; } } diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp index 0518025b8c..496cd7fedb 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp @@ -50,7 +50,7 @@ void RicCreateGridCaseGroupFromFilesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Create Grid Case Group from Files", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".EGRID")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Create Grid Case Group from Files", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".EGRID")); // Remember filters m_pathFilter = result.pathFilter; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp index 3f0fe88c35..6198cd8934 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp @@ -33,7 +33,7 @@ /// //-------------------------------------------------------------------------------------------------- RicEclipseCaseNewGroupExec::RicEclipseCaseNewGroupExec() - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { } @@ -60,7 +60,7 @@ void RicEclipseCaseNewGroupExec::redo() RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index 6d1fb95e72..bc2054c41f 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -91,7 +91,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert //-------------------------------------------------------------------------------------------------- bool RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable(caf::PdmObjectHandle* object) { - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; object->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp index d15e954280..206977f750 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp @@ -31,7 +31,7 @@ /// //-------------------------------------------------------------------------------------------------- RicEclipsePropertyFilterInsertExec::RicEclipsePropertyFilterInsertExec(RimEclipsePropertyFilter* propertyFilter) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(propertyFilter); m_propertyFilter = propertyFilter; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index 72db768450..7a10247a95 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -30,7 +30,7 @@ /// //-------------------------------------------------------------------------------------------------- RicEclipsePropertyFilterNewExec::RicEclipsePropertyFilterNewExec(RimEclipsePropertyFilterCollection* propertyFilterCollection) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { assert(propertyFilterCollection); m_propertyFilterCollection = propertyFilterCollection; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index 61d26dc959..988a3a75b5 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -52,7 +52,7 @@ void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Import Eclipse Cases", defaultDir, m_pathFilter, diff --git a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp index 6361893a40..ea5b876469 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewStatisticsCaseFeature, "RicNewStatisticsCaseFeature"); //-------------------------------------------------------------------------------------------------- bool RicNewStatisticsCaseFeature::isCommandEnabled() { - return selectedValidUIItem() != NULL; + return selectedValidUIItem() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -90,7 +90,7 @@ caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem() } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -98,7 +98,7 @@ caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem() //-------------------------------------------------------------------------------------------------- RimEclipseStatisticsCase* RicNewStatisticsCaseFeature::addStatisticalCalculation(caf::PdmUiItem* uiItem) { - RimIdenticalGridCaseGroup* caseGroup = NULL; + RimIdenticalGridCaseGroup* caseGroup = nullptr; if (dynamic_cast(uiItem)) { @@ -122,6 +122,6 @@ RimEclipseStatisticsCase* RicNewStatisticsCaseFeature::addStatisticalCalculation } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp index 2a36d63a46..fb86a2eb9c 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp @@ -69,7 +69,7 @@ void RicExportFaultsFeature::onActionTriggered(bool isChecked) QString projectFolder = app->currentProjectPath(); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("FAULTS", projectFolder); - QString selectedDir = QFileDialog::getExistingDirectory(NULL, tr("Select Directory"), defaultDir); + QString selectedDir = QFileDialog::getExistingDirectory(nullptr, tr("Select Directory"), defaultDir); if (selectedDir.isNull()) { // Stop if folder selection was cancelled. diff --git a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp index 6449f4054c..98e563fd44 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp @@ -79,7 +79,7 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked) featureUi.setRkbDiffs(wellNames, rkbDiffs); } - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); RicExportFeatureImpl::configureForExport(&propertyDialog); propertyDialog.resize(QSize(400, 200)); diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp index 02a866115a..738ad0b076 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp @@ -46,7 +46,7 @@ CAF_CMD_SOURCE_INIT(RicSaveEclipseInputPropertyFeature, "RicSaveEclipseInputProp //-------------------------------------------------------------------------------------------------- bool RicSaveEclipseInputPropertyFeature::isCommandEnabled() { - return selectedInputProperty() != NULL; + return selectedInputProperty() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -78,7 +78,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) exportSettings.eclipseKeyword = inputProperty->eclipseKeyword; // Find input reservoir for this property - RimEclipseInputCase* inputReservoir = NULL; + RimEclipseInputCase* inputReservoir = nullptr; { RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast(inputProperty->parentField()->ownerObject()); if (!inputPropertyCollection) return; diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp index 209c13a23d..df315d1e44 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp @@ -45,7 +45,7 @@ /// //-------------------------------------------------------------------------------------------------- RicSaveEclipseResultAsInputPropertyExec::RicSaveEclipseResultAsInputPropertyExec(RimEclipseCellColors* cellColors) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(cellColors); m_cellColors = cellColors; diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index dd4f5c114f..1af5521c5e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -90,7 +90,7 @@ void RicSnapshotViewToFileFeature::saveToFile(const QImage& image, const QString } QString defaultAbsFileName = caf::Utils::constructFullFileName(startPath, defaultFileBaseName, ".png"); - QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), defaultAbsFileName); + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Export to File"), defaultAbsFileName); if (fileName.isEmpty()) { return; diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp index 4684e56830..1f2b1838f4 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp @@ -67,7 +67,7 @@ void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimGridView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index 2f5499e6c8..980b68a69b 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -67,7 +67,7 @@ void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimGridView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index f5d187b2be..58908b5779 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -67,7 +67,7 @@ void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimGridView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index bd70ae6b60..e568036c34 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -66,7 +66,7 @@ void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimGridView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp index 31b7e60011..7c1c6efc0a 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp @@ -86,7 +86,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) } bool ok; - fullPathFilenameNewScript = QInputDialog::getText(NULL, + fullPathFilenameNewScript = QInputDialog::getText(nullptr, "Specify new script file", "File name", QLineEdit::Normal, diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp index 596c28adbc..971ccfae2b 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp @@ -126,7 +126,7 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(caf::PdmObjectGroup& o return; } - RimEclipseResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = nullptr; std::vector< std::vector > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group @@ -184,8 +184,8 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(caf::PdmObjectGroup& o } } - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : nullptr; if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir); caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir); diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp index f35506c329..07e9b605ea 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp @@ -95,13 +95,13 @@ RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(caf::PdmObject else if (dynamic_cast(objectHandle) || dynamic_cast(objectHandle)) { - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; objectHandle->firstAncestorOrThisOfType(gridCaseGroup); return gridCaseGroup; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(caf::PdmObjectHandle* objec return reservoirView->eclipseCase(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.cpp b/ApplicationCode/Commands/RicCloseCaseFeature.cpp index aca46ec016..6a3200a546 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseCaseFeature.cpp @@ -49,7 +49,7 @@ CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature"); //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::isCommandEnabled() { - return selectedEclipseCase() != NULL || selectedGeoMechCase() != NULL; + return selectedEclipseCase() != nullptr || selectedGeoMechCase() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -102,7 +102,7 @@ RimEclipseCase* RicCloseCaseFeature::selectedEclipseCase() const return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -118,7 +118,7 @@ RimGeoMechCase* RicCloseCaseFeature::selectedGeoMechCase() const return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -129,8 +129,8 @@ void RicCloseCaseFeature::removeCaseFromAllGroups(RimEclipseCase* eclipseCase) CVF_ASSERT(eclipseCase); RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : nullptr; if (analysisModels) { analysisModels->removeCaseFromAllGroups(eclipseCase); @@ -197,8 +197,8 @@ void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase) CVF_ASSERT(geoMechCase); RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : nullptr; if (models) { models->cases.removeChildObject(geoMechCase); @@ -240,7 +240,7 @@ bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vectorfirstAncestorOrThisOfType(gridCaseGroup); if (gridCaseGroup && hasAnyStatisticsResults(gridCaseGroup)) diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 8cb1531789..ab598aa4f7 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -97,7 +97,7 @@ void RicDeleteItemExec::redo() caf::PdmObjectHandle* parentObj = listField->ownerObject(); parentObj->uiCapability()->updateConnectedEditors(); - Rim3dView* view = NULL; + Rim3dView* view = nullptr; parentObj->firstAncestorOrThisOfType(view); // Range Filters @@ -107,7 +107,7 @@ void RicDeleteItemExec::redo() if (rangeFilterColl) { - rangeFilterColl->updateDisplayModeNotifyManagedViews(NULL); + rangeFilterColl->updateDisplayModeNotifyManagedViews(nullptr); } // Prop Filter @@ -219,7 +219,7 @@ void RicDeleteItemExec::redo() { if (wellLogPlotCollection->wellLogPlots.empty()) { - RimProject* project = NULL; + RimProject* project = nullptr; parentObj->firstAncestorOrThisOfType(project); if (project) { @@ -230,13 +230,13 @@ void RicDeleteItemExec::redo() // Linked views - RimViewLinkerCollection* viewLinkerCollection = NULL; + RimViewLinkerCollection* viewLinkerCollection = nullptr; parentObj->firstAncestorOrThisOfType(viewLinkerCollection); if (viewLinkerCollection) { viewLinkerCollection->uiCapability()->updateConnectedEditors(); - RimProject* project = NULL; + RimProject* project = nullptr; parentObj->firstAncestorOrThisOfType(project); if (project) { diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 09e5765c11..c9297bd97a 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -273,7 +273,7 @@ void RicFileHierarchyDialog::clearFileList() void RicFileHierarchyDialog::updateStatus(Status status, bool force) { static time_t lastStatusUpdate = 0; - time_t now = time(0); + time_t now = time(nullptr); // If less than one second since last update, then return if (!force && now == lastStatusUpdate) return; diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index c18a387550..4ec28889db 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -46,7 +46,7 @@ class RicFileHierarchyDialog : public QDialog RicFileHierarchyDialog(QWidget* parent); ~RicFileHierarchyDialog(); - static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = 0, + static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = nullptr, const QString& caption = QString(), const QString& dir = QString(), const QString& pathFilter = QString(), diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp index 3058d31aa0..8ce09ed4d2 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp @@ -31,7 +31,7 @@ /// //-------------------------------------------------------------------------------------------------- RicGeoMechPropertyFilterInsertExec::RicGeoMechPropertyFilterInsertExec(RimGeoMechPropertyFilter* propertyFilter) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(propertyFilter); m_propertyFilter = propertyFilter; diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp index e63ef16b06..fd5efd7035 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp @@ -29,7 +29,7 @@ /// //-------------------------------------------------------------------------------------------------- RicGeoMechPropertyFilterNewExec::RicGeoMechPropertyFilterNewExec(RimGeoMechPropertyFilterCollection* propertyFilterCollection) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { assert(propertyFilterCollection); m_propertyFilterCollection = propertyFilterCollection; diff --git a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp index ed28cec1f3..11ac6cd35a 100644 --- a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp @@ -41,7 +41,7 @@ void RicImportGeoMechCaseFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("GEOMECH_MODEL"); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)"); + QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)"); if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("GEOMECH_MODEL", defaultDir); diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index e0f81aa00b..112b007e0e 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -54,7 +54,7 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); + QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); if (fileNames.isEmpty()) return; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index da76ae1f3e..bcab65cbf7 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -57,7 +57,7 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(NULL, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); // Remember filters m_pathFilter = result.pathFilter; diff --git a/ApplicationCode/Commands/RicNewViewFeature.cpp b/ApplicationCode/Commands/RicNewViewFeature.cpp index 916f2f10a0..9d19d15555 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationCode/Commands/RicNewViewFeature.cpp @@ -52,10 +52,10 @@ void RicNewViewFeature::addReservoirView(RimEclipseCase* eclipseCase, RimGeoMech //-------------------------------------------------------------------------------------------------- bool RicNewViewFeature::isCommandEnabled() { - return selectedEclipseCase() != NULL - || selectedEclipseView() != NULL - || selectedGeoMechCase() != NULL - || selectedGeoMechView() != NULL; + return selectedEclipseCase() != nullptr + || selectedEclipseView() != nullptr + || selectedGeoMechCase() != nullptr + || selectedGeoMechView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -91,7 +91,7 @@ void RicNewViewFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- Rim3dView* RicNewViewFeature::createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) { - Rim3dView* insertedView = NULL; + Rim3dView* insertedView = nullptr; if (eclipseCase) { @@ -131,7 +131,7 @@ RimEclipseCase* RicNewViewFeature::selectedEclipseCase() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -147,7 +147,7 @@ RimGeoMechCase* RicNewViewFeature::selectedGeoMechCase() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -163,7 +163,7 @@ RimEclipseView* RicNewViewFeature::selectedEclipseView() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -179,5 +179,5 @@ RimGeoMechView* RicNewViewFeature::selectedGeoMechView() return selection[0]; } - return NULL; + return nullptr; } diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp index 2816ba408c..b25e7192ab 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp @@ -28,7 +28,7 @@ /// //-------------------------------------------------------------------------------------------------- RicRangeFilterExecImpl::RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(rangeFilterCollection); m_cellRangeFilterCollection = rangeFilterCollection; diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.h b/ApplicationCode/Commands/RicRangeFilterExecImpl.h index b7407922ab..c0f7f03296 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.h +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.h @@ -31,7 +31,7 @@ class RimCellRangeFilterCollection; class RicRangeFilterExecImpl : public caf::CmdExecuteCommand { public: - RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); virtual ~RicRangeFilterExecImpl(); virtual QString name() = 0; diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp index fd71c5720a..3d2245351b 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp @@ -65,7 +65,7 @@ void RicRangeFilterInsertExec::redo() rangeFilter->setDefaultValues(); applyCommandDataOnFilter(rangeFilter); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.h b/ApplicationCode/Commands/RicRangeFilterInsertExec.h index db47dd8890..392cddd5fe 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.h +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.h @@ -30,7 +30,7 @@ class RimCellRangeFilterCollection; class RicRangeFilterInsertExec : public RicRangeFilterExecImpl { public: - RicRangeFilterInsertExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterInsertExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); virtual ~RicRangeFilterInsertExec(); virtual QString name(); diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index 1e931dbfd6..773ad07d29 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -71,7 +71,7 @@ void RicRangeFilterNewExec::redo() rangeFilter->setDefaultValues(); applyCommandDataOnFilter(rangeFilter); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); @@ -94,7 +94,7 @@ void RicRangeFilterNewExec::undo() m_cellRangeFilterCollection->rangeFilters.erase(m_cellRangeFilterCollection->rangeFilters.size() - 1); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); } \ No newline at end of file diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.h b/ApplicationCode/Commands/RicRangeFilterNewExec.h index 111fa81881..ee9c41a058 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.h +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.h @@ -27,7 +27,7 @@ class RicRangeFilterNewExec : public RicRangeFilterExecImpl { public: - RicRangeFilterNewExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterNewExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); virtual ~RicRangeFilterNewExec(); virtual QString name(); diff --git a/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp b/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp index ee22079dc9..629c067807 100644 --- a/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp @@ -47,7 +47,7 @@ RimEclipseView* RicSelectOrCreateViewFeatureImpl::showViewSelection(RimEclipseRe featureUi.setCase(resultCase); } - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, dialogTitle, ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, dialogTitle, ""); propertyDialog.resize(QSize(400, 200)); if (propertyDialog.exec() != QDialog::Accepted) return nullptr; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index f938da37a4..6994f24945 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -112,7 +112,7 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() QString newPlotName = RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName(); featureUi.setSuggestedPlotName(newPlotName); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Select Destination Plot", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Select Destination Plot", ""); propertyDialog.resize(QSize(400, 200)); if (propertyDialog.exec() != QDialog::Accepted) return nullptr; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp index d02e9bee02..94bd772344 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp @@ -84,7 +84,7 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered(bool isChecked) if (!summaryPlot) pasteOptions.createNewPlot(); pasteOptions.setUiModePasteText(text); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &pasteOptions, "Set Paste Options", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &pasteOptions, "Set Paste Options", ""); if (propertyDialog.exec() != QDialog::Accepted) return; std::vector curves = parseCurves(text, pasteOptions); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 2c1bd90cea..9c3f3131b8 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -692,7 +692,7 @@ void RicSummaryCurveCreator::createNewPlot() { bool ok = false; - candidatePlotName = QInputDialog::getText(NULL, + candidatePlotName = QInputDialog::getText(nullptr, "New Summary Plot Name", "New Summary Plot Name", QLineEdit::Normal, candidatePlotName, diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index bbef140ede..a8121e0249 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -152,7 +152,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) RicLinkVisibleViewsFeatureUi featureUi; featureUi.setViews(views); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Select Master View", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Select Master View", ""); propertyDialog.setWindowIcon(QIcon(":/chain.png")); if (propertyDialog.exec() != QDialog::Accepted) return; diff --git a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index ea83e2387e..4d13a95255 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -49,7 +49,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&managedViews); for (size_t i = 0; i < managedViews.size(); i++) { - RimViewLinker* rimLinked = NULL; + RimViewLinker* rimLinked = nullptr; managedViews[i]->firstAncestorOrThisOfType(rimLinked); CVF_ASSERT(rimLinked); diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 77bfe87e31..c0ffe2aae4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -75,10 +75,10 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) { RimWellLogFileChannel* wellLog = selection[wlIdx]; - RimWellPath* wellPath = NULL; + RimWellPath* wellPath = nullptr; wellLog->firstAncestorOrThisOfType(wellPath); - RimWellLogFile* wellLogFile = NULL; + RimWellLogFile* wellLogFile = nullptr; wellLog->firstAncestorOrThisOfType(wellLogFile); if (wellLogFile) { diff --git a/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp index abb87fbefa..e83a591ea1 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp @@ -43,7 +43,7 @@ bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled() if (selection.size() > 0) { - RimWellLogPlot* wellLogPlot = NULL; + RimWellLogPlot* wellLogPlot = nullptr; selection[0]->firstAncestorOrThisOfType(wellLogPlot); if (wellLogPlot && wellLogPlot->trackCount() > 1) { @@ -68,7 +68,7 @@ void RicDeleteWellLogPlotTrackFeature::onActionTriggered(bool isChecked) { RimWellLogTrack* track = selection[i]; - RimWellLogPlot* wellLogPlot = NULL; + RimWellLogPlot* wellLogPlot = nullptr; track->firstAncestorOrThisOfType(wellLogPlot); if (wellLogPlot && wellLogPlot->trackCount() > 1) { diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp index eb2b9f4e87..f8f94e7002 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp @@ -44,7 +44,7 @@ bool RicNewWellLogPlotTrackFeature::isCommandEnabled() return false; } - return selectedWellLogPlot() != NULL; + return selectedWellLogPlot() != nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index cdabcf0f1a..0157e512ef 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -107,11 +107,11 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC - ecl_kw_type* specGridKw = NULL; - ecl_kw_type* zCornKw = NULL; - ecl_kw_type* coordKw = NULL; - ecl_kw_type* actNumKw = NULL; - ecl_kw_type* mapAxesKw = NULL; + ecl_kw_type* specGridKw = nullptr; + ecl_kw_type* zCornKw = nullptr; + ecl_kw_type* coordKw = nullptr; + ecl_kw_type* actNumKw = nullptr; + ecl_kw_type* mapAxesKw = nullptr; // Try to read all the needed keywords. Early exit if some are not found caf::ProgressInfo progress(8, "Read Grid from Eclipse Input file"); @@ -121,22 +121,22 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC bool allKwReadOk = true; fseek(gridFilePointer, specgridPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); progress.setProgress(1); fseek(gridFilePointer, zcornPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); progress.setProgress(2); fseek(gridFilePointer, coordPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); progress.setProgress(3); // If ACTNUM is not defined, this pointer will be NULL, which is a valid condition if (actnumPos >= 0) { fseek(gridFilePointer, actnumPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); progress.setProgress(4); } @@ -645,7 +645,7 @@ void RifEclipseInputFileTools::parseAndReadFaults(const QString& fileName, cvf:: while (filePos != -1) { - readFaults(data, filePos, faults, NULL); + readFaults(data, filePos, faults, nullptr); filePos = findKeyword(faultsKeyword, data, filePos); } } @@ -919,7 +919,7 @@ void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Coll // qDebug() << "Reading faults from\n " << data.fileName(); - RigFault* fault = NULL; + RigFault* fault = nullptr; do { diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index 6ea396a867..7dc6e8c0f2 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -307,7 +307,7 @@ int RifEclipseRestartFilesetAccess::reportNumber(const ecl_file_type* ecl_file) //-------------------------------------------------------------------------------------------------- int RifEclipseRestartFilesetAccess::readUnitsType() { - ecl_file_type* ecl_file = NULL; + ecl_file_type* ecl_file = nullptr; if (m_ecl_files.size() > 0) { diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp index c1d2bd76c1..3edb09a0fd 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp @@ -36,7 +36,7 @@ //-------------------------------------------------------------------------------------------------- void RifEclipseSummaryTools::findSummaryHeaderFile(const QString& inputFile, QString* headerFile, bool* isFormatted) { - findSummaryHeaderFileInfo(inputFile, headerFile, NULL, NULL, isFormatted); + findSummaryHeaderFileInfo(inputFile, headerFile, nullptr, nullptr, isFormatted); } //-------------------------------------------------------------------------------------------------- @@ -49,9 +49,9 @@ void RifEclipseSummaryTools::findSummaryFiles(const QString& inputFile, dataFiles->clear(); headerFile->clear(); - char* myPath = NULL; - char* myBase = NULL; - char* myExtention = NULL; + char* myPath = nullptr; + char* myBase = nullptr; + char* myExtention = nullptr; util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, &myExtention); @@ -61,7 +61,7 @@ void RifEclipseSummaryTools::findSummaryFiles(const QString& inputFile, if(path.isEmpty() || base.isEmpty()) return ; - char* myHeaderFile = NULL; + char* myHeaderFile = nullptr; stringlist_type* summary_file_list = stringlist_alloc_new(); ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), extention.data(), &myHeaderFile, summary_file_list); @@ -107,13 +107,13 @@ QStringList RifEclipseSummaryTools::findSummaryDataFiles(const QString& caseFile QString path; QString base; - findSummaryHeaderFileInfo(caseFile, NULL, &path, &base, NULL); + findSummaryHeaderFileInfo(caseFile, nullptr, &path, &base, nullptr); if (path.isEmpty() || base.isEmpty()) return fileNames; - char* header_file = NULL; + char* header_file = nullptr; stringlist_type* summary_file_list = stringlist_alloc_new(); - ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), NULL, &header_file, summary_file_list); + ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), nullptr, &header_file, summary_file_list); if (stringlist_get_size( summary_file_list ) > 0) { for (int i = 0; i < stringlist_get_size(summary_file_list); i++) @@ -169,11 +169,11 @@ void RifEclipseSummaryTools::dumpMetaData(RifSummaryReaderInterface* readerEclip //-------------------------------------------------------------------------------------------------- void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, QString* headerFile, QString* path, QString* base, bool* isFormatted) { - char* myPath = NULL; - char* myBase = NULL; + char* myPath = nullptr; + char* myBase = nullptr; bool formattedFile = true; - util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, NULL); + util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, nullptr); char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1); if (!myHeaderFile) diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index a363924309..2961776e32 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -44,7 +44,7 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess() : RifEclipseRestartDataAccess() { - m_ecl_file = NULL; + m_ecl_file = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifHdf5Reader.cpp b/ApplicationCode/FileInterface/RifHdf5Reader.cpp index 050bd7b4bc..6e52a3d23f 100644 --- a/ApplicationCode/FileInterface/RifHdf5Reader.cpp +++ b/ApplicationCode/FileInterface/RifHdf5Reader.cpp @@ -461,7 +461,7 @@ void RifHdf5Reader::getElementResultValues(H5::H5File file, std::string groupNam hsize_t dims[2]; H5::DataSpace dataspace = dataset.getSpace(); - dataspace.getSimpleExtentDims(dims, NULL); + dataspace.getSimpleExtentDims(dims, nullptr); (*resultValues).resize(dims[0]); dataset.read(resultValues->data(), H5::PredType::NATIVE_DOUBLE); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 5ea9100be5..f975fe7470 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -174,7 +174,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn // Sub grid in cell const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, gridLocalCellIndex); - if (subGrid != NULL) + if (subGrid != nullptr) { int subGridId = ecl_grid_get_lgr_nr(subGrid); CVF_ASSERT(subGridId > 0); @@ -208,10 +208,10 @@ RifReaderEclipseOutput::RifReaderEclipseOutput() m_fileName.clear(); m_filesWithSameBaseName.clear(); - m_eclipseCase = NULL; + m_eclipseCase = nullptr; - m_ecl_init_file = NULL; - m_dynamicResultsAccess = NULL; + m_ecl_init_file = nullptr; + m_dynamicResultsAccess = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -223,7 +223,7 @@ RifReaderEclipseOutput::~RifReaderEclipseOutput() { ecl_file_close(m_ecl_init_file); } - m_ecl_init_file = NULL; + m_ecl_init_file = nullptr; if (m_dynamicResultsAccess.notNull()) { @@ -1634,7 +1634,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo if (well_segment_get_outlet_id(segment) == -1) { - segment = NULL; + segment = nullptr; } else { @@ -1696,11 +1696,11 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo accLengthFromLastConnection += well_segment_get_length(outletSegment); segmentIdBelow = well_segment_get_id(outletSegment); - const well_segment_type* aboveOutletSegment = NULL; + const well_segment_type* aboveOutletSegment = nullptr; if (well_segment_get_outlet_id(outletSegment) == -1) { - aboveOutletSegment = NULL; + aboveOutletSegment = nullptr; } else { @@ -1740,7 +1740,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo if (well_segment_get_outlet_id(aboveOutletSegment) == -1) { - aboveOutletSegment = NULL; + aboveOutletSegment = nullptr; } else { diff --git a/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp b/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp index 71e056ce54..639ed1cb05 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp @@ -53,7 +53,7 @@ void RifReaderEclipseRft::open() m_ecl_rft_file = ecl_rft_file_alloc_case(RiaStringEncodingTools::toNativeEncoded(m_fileName).data()); - if (m_ecl_rft_file == NULL) + if (m_ecl_rft_file == nullptr) { RiaLogging::warning(QString("Libecl could not find/open file '%'").arg( m_fileName)); return; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 9d7b153f3d..414246fc07 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -33,7 +33,7 @@ /// //-------------------------------------------------------------------------------------------------- RifReaderEclipseSummary::RifReaderEclipseSummary() - : m_ecl_sum(NULL), + : m_ecl_sum(nullptr), m_ecl_SmSpec(nullptr) { @@ -47,7 +47,7 @@ RifReaderEclipseSummary::~RifReaderEclipseSummary() if (m_ecl_sum) { ecl_sum_free(m_ecl_sum); - m_ecl_sum = NULL; + m_ecl_sum = nullptr; } } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 38e1bf2c2e..c46c629a51 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -124,7 +124,7 @@ bool RifReaderMockModel::dynamicResult(const QString& result, RiaDefines::Porosi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderMockModel::RifReaderMockModel() : m_reservoir(NULL) +RifReaderMockModel::RifReaderMockModel() : m_reservoir(nullptr) { /* m_cellResults.push_back("Dummy results"); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index f53fd408b1..7b79840584 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -96,9 +96,9 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(rangeFilterVisibility != NULL); - CVF_ASSERT(propFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(rangeFilterVisibility != nullptr); + CVF_ASSERT(propFilterColl != nullptr); CVF_ASSERT(grid->elementCount() > 0); CVF_ASSERT(rangeFilterVisibility->size() == static_cast(grid->elementCount())); @@ -255,8 +255,8 @@ void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(cvf::UByteAr const RigFemPart* femPart, RimViewController* masterViewLink) { - CVF_ASSERT(elmVisibilities != NULL); - CVF_ASSERT(femPart != NULL); + CVF_ASSERT(elmVisibilities != nullptr); + CVF_ASSERT(femPart != nullptr); RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView(); cvf::ref totCellVisibility = masterView->currentTotalCellVisibility(); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index ef612df8ba..07f8789d71 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -69,7 +69,7 @@ ref RivFemPartGeometryGenerator::generateSurface() CVF_ASSERT(m_quadVertices.notNull()); - if (m_quadVertices->size() == 0) return NULL; + if (m_quadVertices->size() == 0) return nullptr; ref geo = new DrawableGeo; geo->setFromQuadVertexArray(m_quadVertices.p()); @@ -85,7 +85,7 @@ ref RivFemPartGeometryGenerator::generateSurface() //-------------------------------------------------------------------------------------------------- ref RivFemPartGeometryGenerator::createMeshDrawable() { - if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(m_quadVertices.p()); @@ -105,7 +105,7 @@ ref RivFemPartGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- ref RivFemPartGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_quadVertices); @@ -115,7 +115,7 @@ ref RivFemPartGeometryGenerator::createOutlineMeshDrawable(double c ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } ref prim = new PrimitiveSetIndexedUInt(PT_LINES); @@ -333,7 +333,7 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi quadVertices->assign(vertices); } - if (!(quadVertices.notNull() && quadVertices->size() != 0)) return NULL; + if (!(quadVertices.notNull() && quadVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(quadVertices.p()); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index 91849f76c8..b87d7d9c9e 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -104,7 +104,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui bool useBufferObjects = true; // Surface geometry { - m_surfaceFaces = NULL; // To possibly free memory before adding the new stuff + m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff cvf::ref geo = geoBuilder.generateSurface(); if (geo.notNull()) @@ -139,7 +139,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui // Mesh geometry { - m_surfaceGridLines = NULL; // To possibly free memory before adding the new stuff + m_surfaceGridLines = nullptr; // To possibly free memory before adding the new stuff cvf::ref geoMesh = geoBuilder.createMeshDrawable(); if (geoMesh.notNull()) @@ -176,7 +176,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui //-------------------------------------------------------------------------------------------------- void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); @@ -250,7 +250,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex); - const std::vector* vxToResultMapping = NULL; + const std::vector* vxToResultMapping = nullptr; int vxCount = 0; if (resVarAddress.resultPosType == RIG_NODAL) @@ -313,7 +313,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe } } - Rim3dView* view = NULL; + Rim3dView* view = nullptr; cellResultColors->firstAncestorOrThisOfType(view); CVF_ASSERT(view); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 89d0a9771f..560f12299b 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -205,7 +205,7 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: } else if (pMgrKey.geometryType() == PROPERTY_FILTERED) { - RivGeoMechPartMgr* rangefiltered = NULL; + RivGeoMechPartMgr* rangefiltered = nullptr; if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); diff --git a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp index 1f7f650fb1..20c14f5ccc 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp +++ b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp @@ -535,8 +535,8 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection break; } - std::vector* displayCoordsTickValues = NULL; - std::vector* domainCoordsTickValues = NULL; + std::vector* displayCoordsTickValues = nullptr; + std::vector* domainCoordsTickValues = nullptr; if (axis == X_AXIS) { diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp index 37bc797ef7..766b08442c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp @@ -67,9 +67,9 @@ bool RivEclipseIntersectionGrid::useCell(size_t cellIndex) const { const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex]; if (m_showInactiveCells) - return !(cell.isInvalid() || (cell.subGrid() != NULL)); + return !(cell.isInvalid() || (cell.subGrid() != nullptr)); else - return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == NULL); + return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == nullptr); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 9bd7e9074c..5af982f9ef 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -43,7 +43,7 @@ //-------------------------------------------------------------------------------------------------- CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper) { - CVF_ASSERT(edgeScalarMapper != NULL); + CVF_ASSERT(edgeScalarMapper != nullptr); m_edgeScalarMapper = edgeScalarMapper; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index 64a1605fb3..f881280dc7 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -56,7 +56,7 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( float opacityLevel) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); - CVF_ASSERT(eclipseCase != NULL); + CVF_ASSERT(eclipseCase != nullptr); // Create result access objects @@ -90,7 +90,7 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( double ignoredScalarValue = cellEdgeResultColors->ignoredScalarValue(); - const std::vector* isWellPipeVisible = NULL; + const std::vector* isWellPipeVisible = nullptr; cvf::cref gridCellToWellindexMap; if (opacityLevel < 1.0f) @@ -200,7 +200,7 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); - CVF_ASSERT(eclipseCase != NULL); + CVF_ASSERT(eclipseCase != nullptr); cvf::ref cellEdgeResultAccessor = createCellEdgeResultAccessor(cellResultColors, cellEdgeResultColors, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); @@ -339,7 +339,7 @@ cvf::ref RivCellEdgeGeometryUtils::createCellEdgeResultAccess //-------------------------------------------------------------------------------------------------- cvf::ref RivCellEdgeGeometryUtils::createCellCenterResultAccessor(RimEclipseCellColors* cellResultColors, size_t timeStepIndex, RigEclipseCaseData* eclipseCase, const RigGridBase* grid) { - cvf::ref resultAccessor = NULL; + cvf::ref resultAccessor = nullptr; if (cellResultColors->hasResult()) { diff --git a/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp index 4a7c73a8c0..b46d76b969 100644 --- a/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp @@ -60,7 +60,7 @@ cvf::ref RivFaultGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setFromQuadVertexArray(m_vertices.p()); @@ -75,7 +75,7 @@ cvf::ref RivFaultGeometryGenerator::generateSurface() cvf::ref RivFaultGeometryGenerator::createMeshDrawable() { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setVertexArray(m_vertices.p()); @@ -93,7 +93,7 @@ cvf::ref RivFaultGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- cvf::ref RivFaultGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_vertices); @@ -103,7 +103,7 @@ cvf::ref RivFaultGeometryGenerator::createOutlineMeshDrawable( cvf::ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } cvf::ref prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES); diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 3f14a0b11b..6d6f74118c 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -374,7 +374,7 @@ void RivFaultPartMgr::updatePartEffect() m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p()); } - updateNNCColors(0, NULL); + updateNNCColors(0, nullptr); // Update mesh colors as well, in case of change RiaPreferences* prefs = RiaApplication::instance()->preferences(); @@ -417,8 +417,8 @@ void RivFaultPartMgr::updatePartEffect() //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part) { - m_faultLabelPart = NULL; - m_faultLabelLinePart = NULL; + m_faultLabelPart = nullptr; + m_faultLabelLinePart = nullptr; if (!part) return; diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 9f2796dfbf..4c3249611d 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -189,7 +189,7 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB //-------------------------------------------------------------------------------------------------- void RivGridPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index 4a7d88c9d1..9a275428e5 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -56,7 +56,7 @@ cvf::ref RivNNCGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setFromTriangleVertexArray(m_vertices.p()); @@ -76,7 +76,7 @@ void RivNNCGeometryGenerator::computeArrays() long long numConnections = static_cast(m_nncIndexes.isNull()? m_nncData->connections().size(): m_nncIndexes->size()); bool isVisibilityCalcActive = m_cellVisibility.notNull() && m_grid.notNull(); - std::vector* allCells = NULL; + std::vector* allCells = nullptr; if (isVisibilityCalcActive) { allCells = &(m_grid->mainGrid()->globalCellArray()); diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index c5d3b5f5ee..a4cdfa198f 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -108,7 +108,7 @@ cvf::ref RivPipeGeometryGenerator::createPipeSurface() { if (m_radius == 0.0) { - return NULL; + return nullptr; } updateFilteredPipeCenterCoords(); @@ -212,9 +212,9 @@ void RivPipeGeometryGenerator::computeCircle(double radius, size_t tesselationCo //-------------------------------------------------------------------------------------------------- cvf::ref RivPipeGeometryGenerator::generateLine(const cvf::Vec3dArray* coords) { - CVF_ASSERT(coords != NULL); + CVF_ASSERT(coords != nullptr); - if (coords->size() < 2 ) return NULL; + if (coords->size() < 2 ) return nullptr; size_t duplicateVertexCount = 2 * (coords->size() - 1); @@ -259,9 +259,9 @@ cvf::ref RivPipeGeometryGenerator::generateLine(const cvf::Vec //-------------------------------------------------------------------------------------------------- cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(double radius, size_t crossSectionNodeCount, const cvf::Vec3dArray* cylinderCenterCoords) { - CVF_ASSERT(cylinderCenterCoords != NULL); + CVF_ASSERT(cylinderCenterCoords != nullptr); - if (cylinderCenterCoords->size() < 2) return NULL; + if (cylinderCenterCoords->size() < 2) return nullptr; std::vector crossSectionVertices; std::vector cylinderSegmentNormals; @@ -300,7 +300,7 @@ cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(do } } - if (i >= cylinderCenterCoords->size()-1) return NULL; // The pipe coordinates is all the same point + if (i >= cylinderCenterCoords->size()-1) return nullptr; // The pipe coordinates is all the same point // Loop along the cylinder center coords and calculate the cross section vertexes in each center vertex @@ -346,7 +346,7 @@ cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(do size_t crossSectionCount = crossSectionVertices.size() / crossSectionNodeCount; - if (crossSectionCount < 2) return NULL; + if (crossSectionCount < 2) return nullptr; CVF_ASSERT(crossSectionVertices.size() - crossSectionNodeCount == cylinderSegmentNormals.size()); diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index 5adf827c07..5f2d57c5d5 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -95,7 +95,7 @@ void RivReservoirFaultsPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilit //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); if (!faultCollection) return; @@ -243,7 +243,7 @@ void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if (!m_reservoirView) return; RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 5d7d2839ef..808d3a8532 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -150,8 +150,8 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(RivCellSetEnum geometryType) //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::clearGeometryCache(RivCellSetEnum geomType) { - RigEclipseCaseData* eclipseCase = NULL; - if (m_reservoirView != NULL && m_reservoirView->eclipseCase()) + RigEclipseCaseData* eclipseCase = nullptr; + if (m_reservoirView != nullptr && m_reservoirView->eclipseCase()) { eclipseCase = m_reservoirView->eclipseCase()->eclipseCaseData(); } @@ -564,10 +564,10 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib bool activeCellsIsVisible, bool mainGridIsVisible) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(grid != NULL); - CVF_ASSERT(activeCellInfo != NULL); - CVF_ASSERT(cellIsInWellStatuses != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(grid != nullptr); + CVF_ASSERT(activeCellInfo != nullptr); + CVF_ASSERT(cellIsInWellStatuses != nullptr); CVF_ASSERT(cellIsInWellStatuses->size() >= grid->cellCount()); cellVisibility->resize(grid->cellCount()); @@ -614,8 +614,8 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c std::vector > gridsWithCellSetVisibility = masterView->getAllGridsCurrentCellSetsCellVisibility(); #endif - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(grid != nullptr); size_t gridCellCount = grid->cellCount(); cellVisibility->resize(gridCellCount); @@ -660,8 +660,8 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::copyByteArray(cvf::UByteArray* destination, const cvf::UByteArray* source ) { - CVF_ASSERT(destination != NULL); - CVF_ASSERT(source != NULL); + CVF_ASSERT(destination != nullptr); + CVF_ASSERT(source != nullptr); if (destination->size() != source->size()) { @@ -685,11 +685,11 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(nativeVisibility != NULL); - CVF_ASSERT(rangeFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(nativeVisibility != nullptr); + CVF_ASSERT(rangeFilterColl != nullptr); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(grid != nullptr); CVF_ASSERT(nativeVisibility->size() == grid->cellCount()); // Initialize range filter with native visibility @@ -701,7 +701,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType cvf::CellRangeFilter gridCellRangeFilter; rangeFilterColl->compoundCellRangeFilter(&gridCellRangeFilter, grid->gridIndex()); - const RigLocalGrid* lgr = NULL; + const RigLocalGrid* lgr = nullptr; cvf::ref parentGridVisibilities; if (!grid->isMainGrid()) @@ -741,7 +741,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType size_t mainGridJ; size_t mainGridK; - bool isInSubGridArea = cell.subGrid() != NULL; + bool isInSubGridArea = cell.subGrid() != nullptr; grid->ijkFromCellIndex(cellIndex, &mainGridI, &mainGridJ, &mainGridK); bool nativeRangeVisibility = false; @@ -769,9 +769,9 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(rangeFilterVisibility != NULL); - CVF_ASSERT(propFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(rangeFilterVisibility != nullptr); + CVF_ASSERT(propFilterColl != nullptr); CVF_ASSERT(grid->cellCount() > 0); CVF_ASSERT(rangeFilterVisibility->size() == grid->cellCount()); diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index ac1df3fd54..ecb79200dd 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -224,10 +224,10 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { - if (m_rimWell == NULL) return; + if (m_rimWell == nullptr) return; RigSimWellData* simWellData = m_rimWell->simWellData(); - if (simWellData == NULL) return; + if (simWellData == nullptr) return; if (!simWellData->hasWellResult(frameIndex)) return; // Or reset colors or something @@ -282,14 +282,14 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx) { // we need a faster lookup, I guess - const RigWellResultPoint* wResCell = NULL; + const RigWellResultPoint* wResCell = nullptr; if (cellIds[wcIdx].isCell()) { wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex); } - if (wResCell == NULL) + if (wResCell == nullptr) { // We cant find any state. This well cell is closed. } diff --git a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp index 5819cbfa89..96039adb24 100644 --- a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp @@ -42,7 +42,7 @@ RivSingleCellPartGenerator::RivSingleCellPartGenerator(RigEclipseCaseData* rigCa : m_rigCaseData(rigCaseData), m_gridIndex(gridIndex), m_cellIndex(cellIndex), - m_geoMechCase(NULL) + m_geoMechCase(nullptr) { } @@ -53,7 +53,7 @@ RivSingleCellPartGenerator::RivSingleCellPartGenerator(RimGeoMechCase* rimGeoMec : m_geoMechCase(rimGeoMechCase), m_gridIndex(gridIndex), m_cellIndex(cellIndex), - m_rigCaseData(NULL) + m_rigCaseData(nullptr) { } @@ -101,5 +101,5 @@ cvf::ref RivSingleCellPartGenerator::createMeshDrawable() return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement(femPart, m_cellIndex); } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp index 279efc60c6..49206e74d4 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp @@ -241,9 +241,9 @@ caf::EffectGenerator* RivTernaryScalarMapperEffectGenerator::copy() const //-------------------------------------------------------------------------------------------------- bool RivTernaryScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1, const cvf::TextureImage* texImg2) { - if (texImg1 == NULL && texImg2 == NULL) return true; + if (texImg1 == nullptr && texImg2 == nullptr) return true; - if (texImg1 != NULL && texImg2 != NULL + if (texImg1 != nullptr && texImg2 != nullptr && texImg1->height() == texImg2->height() && texImg1->width() == texImg2->width() && texImg1->width() > 0 && texImg1->height() > 0 diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index 9e443bf675..43e54aa833 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -81,7 +81,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex) - : m_quadMapper(NULL) + : m_quadMapper(nullptr) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); @@ -100,7 +100,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p()); // Create a texture mapper without detecting transparency using RigPipeInCellEvaluator - m_texMapper = new RivTernaryResultToTextureMapper(ternaryColorMapper, NULL); + m_texMapper = new RivTernaryResultToTextureMapper(ternaryColorMapper, nullptr); CVF_ASSERT(m_texMapper.notNull()); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp index 0ad7710f13..093e007ee8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp @@ -137,7 +137,7 @@ void RimFishboneWellPathCollection::appendCompletion(RimFishboneWellPath* comple uiCapability()->setUiHidden(!m_wellPaths.empty()); - RimProject* project = NULL; + RimProject* project = nullptr; firstAncestorOrThisOfTypeAsserted(project); if (project) { diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 65fd77ac90..f437ed6f78 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -494,7 +494,7 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimGeoMechView* geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; - RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; + RigFemPartCollection* femParts = caseData ? caseData->femParts() : nullptr; if (femParts) { diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index ec65ec1299..8bbaf7f4fa 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -159,7 +159,7 @@ QWidget* Rim3dView::createViewWidget(QWidget* mainWindowParent) QGLFormat glFormat; glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - m_viewer = new RiuViewer(glFormat, NULL); + m_viewer = new RiuViewer(glFormat, nullptr); m_viewer->setOwnerReservoirView(this); cvf::String xLabel; diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index b63de1f8f8..75ef608631 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -66,5 +66,5 @@ RimEclipseCase* RimCaseCollection::findByDescription(const QString& caseDescript } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 60fc016f4b..d621a4bb9f 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -102,7 +102,7 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c updateIconState(); uiCapability()->updateConnectedEditors(); - updateDisplayModeNotifyManagedViews(NULL); + updateDisplayModeNotifyManagedViews(nullptr); } //-------------------------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter) { - Rim3dView* view = NULL; + Rim3dView* view = nullptr; firstAncestorOrThisOfType(view); if (!view) return; @@ -175,7 +175,7 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const //-------------------------------------------------------------------------------------------------- Rim3dView* RimCellRangeFilterCollection::baseView() const { - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); return rimView; diff --git a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp index f53be8ce52..bd13d041ab 100644 --- a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp @@ -308,7 +308,7 @@ caf::PdmObjectHandle* RimCommandIssueFieldChanged::findObjectByName(caf::PdmObje } } - return NULL; + return nullptr; } @@ -328,7 +328,7 @@ caf::PdmFieldHandle* RimCommandIssueFieldChanged::findFieldByKeyword(caf::PdmObj } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 12dc16c9f4..3fefea4066 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -109,7 +109,7 @@ RimEclipseCase::RimEclipseCase() m_fractureModelResults.uiCapability()->setUiHidden(true); m_fractureModelResults.uiCapability()->setUiTreeChildrenHidden(true); - this->setReservoirData( NULL ); + this->setReservoirData( nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -483,8 +483,8 @@ void RimEclipseCase::setReservoirData(RigEclipseCaseData* eclipseCase) } else { - m_fractureModelResults()->setCellResults(NULL); - m_matrixModelResults()->setCellResults(NULL); + m_fractureModelResults()->setCellResults(nullptr); + m_matrixModelResults()->setCellResults(nullptr); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index a5af468764..24ef2cfd10 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -70,7 +70,7 @@ RimEclipseCellColors::RimEclipseCellColors() //-------------------------------------------------------------------------------------------------- RimEclipseCellColors::~RimEclipseCellColors() { - CVF_ASSERT(obsoleteField_legendConfig() == NULL); + CVF_ASSERT(obsoleteField_legendConfig() == nullptr); m_legendConfigData.deleteAllChildObjects(); @@ -171,7 +171,7 @@ void RimEclipseCellColors::initAfterRead() RimLegendConfig* obsoleteLegend = obsoleteField_legendConfig(); // set to NULL before pushing into container - obsoleteField_legendConfig = NULL; + obsoleteField_legendConfig = nullptr; m_legendConfigData.push_back(obsoleteLegend); m_legendConfigPtrField = obsoleteLegend; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index f9d8e2f982..0148e97968 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -56,7 +56,7 @@ RimEclipseFaultColors::RimEclipseFaultColors() RimEclipseFaultColors::~RimEclipseFaultColors() { delete m_customFaultResultColors; - m_customFaultResultColors = NULL; + m_customFaultResultColors = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index 4bbefbf730..d3bcae58ba 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -103,7 +103,7 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) return true; } - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { this->setReservoirData(new RigEclipseCaseData(this)); } @@ -181,7 +181,7 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) bool RimEclipseInputCase::openEclipseGridFile() { // Early exit if reservoir data is created - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { cvf::ref readerInterface; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index 8a44efb595..caf2e71ff2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -76,6 +76,6 @@ RimEclipseInputProperty * RimEclipseInputPropertyCollection::findInputProperty(Q } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp index 9929da2fce..5c7709e76f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp @@ -56,7 +56,7 @@ RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimEclipseView* RimEclipsePropertyFilterCollection::reservoirView() { - RimEclipseView* eclipseView = NULL; + RimEclipseView* eclipseView = nullptr; firstAncestorOrThisOfType(eclipseView); return eclipseView; @@ -143,7 +143,7 @@ void RimEclipsePropertyFilterCollection::updateIconState() { bool activeIcon = true; - RimEclipseView* view = NULL; + RimEclipseView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index d347bf1128..28c0c2d5a0 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -152,7 +152,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData(bool showTimeStepFilter) m_timeStepFilter->setTimeStepsFromFile(timeSteps); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); propertyDialog.resize(QSize(400, 400)); if (propertyDialog.exec() != QDialog::Accepted) @@ -387,7 +387,7 @@ cvf::ref RimEclipseResultCase::createMockModel(QString model RimMockModelSettings rimMockModelSettings; caf::PdmSettings::readFieldsFromApplicationStore(&rimMockModelSettings); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &rimMockModelSettings, "Customize Mock Model", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &rimMockModelSettings, "Customize Mock Model", ""); if (propertyDialog.exec() == QDialog::Accepted) { QApplication::restoreOverrideCursor(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index ce556d43d9..d9f5f323d3 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -201,7 +201,7 @@ void RimEclipseStatisticsCase::populateResultSelectionAfterLoadingGrid() //-------------------------------------------------------------------------------------------------- void RimEclipseStatisticsCase::computeStatistics() { - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { openEclipseGridFile(); } @@ -336,7 +336,7 @@ RimIdenticalGridCaseGroup* RimEclipseStatisticsCase::caseGroup() return parentCollection->parentCaseGroup(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 7ce6996f3a..86128f1a11 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -156,7 +156,7 @@ RimEclipseView::RimEclipseView() m_reservoirGridPartManager = new RivReservoirViewPartMgr(this); m_simWellsPartManager = new RivReservoirSimWellsPartMgr(this); - m_eclipseCase = NULL; + m_eclipseCase = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -174,7 +174,7 @@ RimEclipseView::~RimEclipseView() m_reservoirGridPartManager->clearGeometryCache(); - m_eclipseCase = NULL; + m_eclipseCase = nullptr; } @@ -758,15 +758,15 @@ void RimEclipseView::onLoadDataAndUpdate() QMessageBox::warning(RiuMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file: \n"+ m_eclipseCase->gridFileName()); - this->setEclipseCase( NULL); + this->setEclipseCase( nullptr); return; } } - CVF_ASSERT(this->cellResult() != NULL); + CVF_ASSERT(this->cellResult() != nullptr); this->cellResult()->loadResult(); - CVF_ASSERT(this->cellEdgeResult() != NULL); + CVF_ASSERT(this->cellEdgeResult() != nullptr); this->cellEdgeResult()->loadResult(); this->faultResultSettings()->customFaultResult()->loadResult(); @@ -900,7 +900,7 @@ RigCaseCellResultsData* RimEclipseView::currentGridCellResults() return m_eclipseCase->results(cellResult->porosityModel()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -915,7 +915,7 @@ RigActiveCellInfo* RimEclipseView::currentActiveCellInfo() return m_eclipseCase->eclipseCaseData()->activeCellInfo(cellResult->porosityModel()); } - return NULL; + return nullptr; } @@ -935,7 +935,7 @@ void RimEclipseView::scheduleGeometryRegen(RivCellSetEnum geometryType) } } - m_currentReservoirCellVisibility = NULL; + m_currentReservoirCellVisibility = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -960,7 +960,7 @@ void RimEclipseView::scheduleSimWellGeometryRegen() //-------------------------------------------------------------------------------------------------- void RimEclipseView::indicesToVisibleGrids(std::vector* gridIndices) { - CVF_ASSERT(gridIndices != NULL); + CVF_ASSERT(gridIndices != nullptr); // Create vector of grid indices to render std::vector grids; @@ -1132,7 +1132,7 @@ void RimEclipseView::syncronizeWellsWithResults() for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimSimWellInView* well = this->wellCollection()->wells()[wIdx]; - well->setSimWellData(NULL, -1); + well->setSimWellData(nullptr, -1); } bool isAnyWellCreated = false; @@ -1161,7 +1161,7 @@ void RimEclipseView::syncronizeWellsWithResults() { RimSimWellInView* well = this->wellCollection()->wells()[wIdx]; RigSimWellData* simWellData = well->simWellData(); - if (simWellData == NULL) + if (simWellData == nullptr) { delete well; } @@ -1204,7 +1204,7 @@ RivReservoirViewPartMgr * RimEclipseView::reservoirGridPartManager() //-------------------------------------------------------------------------------------------------- void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid) { - CVF_ASSERT(visibleCells != NULL); + CVF_ASSERT(visibleCells != nullptr); // Initialize the return array if (visibleCells->size() != grid->cellCount()) diff --git a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp index 3844f92a0a..851c66b70a 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp @@ -41,7 +41,7 @@ RimFaultInView::RimFaultInView() CAF_PDM_InitField(&faultColor, "Color", cvf::Color3f(0.588f, 0.588f, 0.804f), "Fault Color", "", "", ""); - m_rigFault = NULL; + m_rigFault = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -68,7 +68,7 @@ void RimFaultInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c if (&faultColor == changedField || &showFault == changedField) { - RimEclipseView* reservoirView = NULL; + RimEclipseView* reservoirView = nullptr; this->firstAncestorOrThisOfType(reservoirView); diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 13e2d04f4e..55e918be68 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -84,7 +84,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() CAF_PDM_InitFieldNoDefault(&faults, "Faults", "Faults", "", "", ""); faults.uiCapability()->setUiHidden(true); - m_reservoirView = NULL; + m_reservoirView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -164,7 +164,7 @@ RimFaultInView* RimFaultInViewCollection::findFaultByName(QString name) return this->faults()[i]; } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index 803b63caac..fdb8a6db9d 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -215,6 +215,6 @@ void RimFormationNames::readFormationNamesFile(QString * errorMessage) //-------------------------------------------------------------------------------------------------- void RimFormationNames::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - m_formationNamesFileName = RimTools::relocateFile(m_formationNamesFileName(), newProjectPath, oldProjectPath, NULL, NULL); + m_formationNamesFileName = RimTools::relocateFile(m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index b0535bbe9e..b855c7283d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -51,7 +51,7 @@ RimGeoMechCellColors::~RimGeoMechCellColors(void) //-------------------------------------------------------------------------------------------------- void RimGeoMechCellColors::updateIconState() { - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp index f19decd54d..bbc305e647 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -41,7 +41,7 @@ CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilter, "GeoMechPropertyFilter"); /// //-------------------------------------------------------------------------------------------------- RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() - : m_parentContainer(NULL) + : m_parentContainer(nullptr) { CAF_PDM_InitObject("Property Filter", ":/CellFilter_Values.png", "", ""); @@ -193,7 +193,7 @@ bool RimGeoMechPropertyFilter::isPropertyFilterControlled() { bool isPropertyFilterControlled = false; - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); if (rimView) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp index acc74532fb..d356f79309 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp @@ -55,7 +55,7 @@ RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView() { - RimGeoMechView* geoMechView = NULL; + RimGeoMechView* geoMechView = nullptr; firstAncestorOrThisOfType(geoMechView); return geoMechView; @@ -142,7 +142,7 @@ void RimGeoMechPropertyFilterCollection::updateIconState() { bool activeIcon = true; - RimGeoMechView* view = NULL; + RimGeoMechView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 047e51f4a1..fd6c4eae65 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -102,7 +102,7 @@ RimGeoMechView::RimGeoMechView(void) //-------------------------------------------------------------------------------------------------- RimGeoMechView::~RimGeoMechView(void) { - m_geomechCase = NULL; + m_geomechCase = nullptr; delete m_tensorResults; delete cellResult; @@ -128,7 +128,7 @@ void RimGeoMechView::onLoadDataAndUpdate() QMessageBox::warning(RiuMainWindow::instance(), "File open error", displayMessage); - m_geomechCase = NULL; + m_geomechCase = nullptr; return; } } @@ -136,7 +136,7 @@ void RimGeoMechView::onLoadDataAndUpdate() progress.setProgressDescription("Reading Current Result"); - CVF_ASSERT(this->cellResult() != NULL); + CVF_ASSERT(this->cellResult() != nullptr); if (this->hasUserRequestedAnimation()) { m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress()); @@ -544,7 +544,7 @@ void RimGeoMechView::scheduleGeometryRegen(RivCellSetEnum geometryType) viewLinker->scheduleGeometryRegenForDepViews(geometryType); } } - m_currentReservoirCellVisibility = NULL; + m_currentReservoirCellVisibility = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 50a30d6bf4..d236211695 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -57,7 +57,7 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (changedField == &isActive) { - RimGridView* rimView = NULL; + RimGridView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 489e663ed5..815c564309 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -79,7 +79,7 @@ RimGridView::~RimGridView(void) if (proj && this->isMasterView()) { delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = NULL; + proj->viewLinkerCollection->viewLinker = nullptr; proj->uiCapability()->updateConnectedEditors(); } @@ -87,7 +87,7 @@ RimGridView::~RimGridView(void) RimViewController* vController = this->viewController(); if (proj && vController) { - vController->setManagedView(NULL); + vController->setManagedView(nullptr); vController->ownerViewLinker()->removeViewController(vController); delete vController; @@ -181,7 +181,7 @@ const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const //-------------------------------------------------------------------------------------------------- bool RimGridView::hasOverridenRangeFilterCollection() { - return m_overrideRangeFilterCollection() != NULL; + return m_overrideRangeFilterCollection() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -225,7 +225,7 @@ void RimGridView::replaceRangeFilterCollectionWithOverride() //-------------------------------------------------------------------------------------------------- RimViewController* RimGridView::viewController() const { - RimViewController* viewController = NULL; + RimViewController* viewController = nullptr; std::vector reffingObjs; this->objectsWithReferringPtrFields(reffingObjs); @@ -291,7 +291,7 @@ void RimGridView::onTimeStepChanged() { if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) { - m_currentReservoirCellVisibility = NULL; + m_currentReservoirCellVisibility = nullptr; } } @@ -339,7 +339,7 @@ void RimGridView::selectOverlayInfoConfig() //-------------------------------------------------------------------------------------------------- RimViewLinker* RimGridView::viewLinkerIfMasterView() const { - RimViewLinker* viewLinker = NULL; + RimViewLinker* viewLinker = nullptr; std::vector reffingObjs; this->objectsWithReferringPtrFields(reffingObjs); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 6ffd07ff42..5fb824b8c6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -71,7 +71,7 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() statisticsCaseCollection->uiCapability()->setUiIcon(QIcon(":/Histograms16x16.png")); - m_mainGrid = NULL; + m_mainGrid = nullptr; m_unionOfMatrixActiveCells = new RigActiveCellInfo; m_unionOfFractureActiveCells = new RigActiveCellInfo; @@ -82,13 +82,13 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() { - m_mainGrid = NULL; + m_mainGrid = nullptr; delete caseCollection; - caseCollection = NULL; + caseCollection = nullptr; delete statisticsCaseCollection; - statisticsCaseCollection = NULL; + statisticsCaseCollection = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -130,7 +130,7 @@ void RimIdenticalGridCaseGroup::removeCase(RimEclipseCase* reservoir) if (caseCollection()->reservoirs().size() == 0) { - m_mainGrid = NULL; + m_mainGrid = nullptr; } clearActiveCellUnions(); @@ -145,7 +145,7 @@ RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() { if (m_mainGrid) return m_mainGrid; - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -512,7 +512,7 @@ RimEclipseCase* RimIdenticalGridCaseGroup::mainCase() } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp index fe37b088c4..402a717a2d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp @@ -470,7 +470,7 @@ void RimIntersectionBox::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimIntersectionBox::slotScheduleRedraw() { - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -628,7 +628,7 @@ void RimIntersectionBox::switchSingelPlaneState() //-------------------------------------------------------------------------------------------------- cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; this->firstAncestorOrThisOfType(rimCase); CVF_ASSERT(rimCase); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index b856cc3633..f4f4247080 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -107,7 +107,7 @@ RimPlotCurve::RimPlotCurve() m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; - m_parentQwtPlot = NULL; + m_parentQwtPlot = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -119,7 +119,7 @@ RimPlotCurve::~RimPlotCurve() { m_qwtPlotCurve->detach(); delete m_qwtPlotCurve; - m_qwtPlotCurve = NULL; + m_qwtPlotCurve = nullptr; } if (m_parentQwtPlot) @@ -373,7 +373,7 @@ void RimPlotCurve::updateCurveAppearance() QColor curveColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()); - QwtSymbol* symbol = NULL; + QwtSymbol* symbol = nullptr; if (m_pointSymbol() != SYMBOL_NONE) { diff --git a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp index 2f6f6a691e..3fe7cd5db9 100644 --- a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -88,7 +88,7 @@ RigEclipseWellLogExtractor* RimPltPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -115,7 +115,7 @@ RigGeoMechWellLogExtractor* RimPltPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp index 3440d6614b..c46df10fc6 100644 --- a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp @@ -46,7 +46,7 @@ RimPropertyFilterCollection::~RimPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews() const { - Rim3dView* view = NULL; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); CVF_ASSERT(view); if (!view) return; @@ -83,7 +83,7 @@ void RimPropertyFilterCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& u { PdmObject::defineUiTreeOrdering(uiTreeOrdering, uiConfigName); - Rim3dView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); RimViewController* viewController = rimView->viewController(); if (viewController && (viewController->isPropertyFilterOveridden() diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 1ec7ebb26b..e366396acd 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -49,7 +49,7 @@ CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage" /// //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() - : m_cellResults(NULL) + : m_cellResults(nullptr) { CAF_PDM_InitObject("Cacher", "", "", ""); @@ -150,7 +150,7 @@ void RimReservoirCellResultsStorage::setupBeforeSave() // starting with the number of values for (size_t tsIdx = 0; tsIdx < resInfo[rIdx].dates().size() ; ++tsIdx) { - const std::vector* data = NULL; + const std::vector* data = nullptr; if (tsIdx < timestepCount) { data = &(m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx)); @@ -219,7 +219,7 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell { m_cellResults = cellResults; - if (m_cellResults == NULL) + if (m_cellResults == nullptr) return; // Now that we have got the results container, we can finally @@ -283,7 +283,7 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell for (size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx) { - std::vector* data = NULL; + std::vector* data = nullptr; data = &(m_cellResults->cellScalarResults(resultIndex, tsIdx)); diff --git a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp index 48ae95afb2..9f31899811 100644 --- a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -88,7 +88,7 @@ RigEclipseWellLogExtractor* RimRftPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -115,7 +115,7 @@ RigGeoMechWellLogExtractor* RimRftPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp index 2ed6cc2778..8cbe4d1321 100644 --- a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp @@ -160,12 +160,12 @@ RimScriptCollection * RimScriptCollection::findScriptCollection(const QString& p for (size_t i = 0; i < this->subDirectories.size(); ++i) { - RimScriptCollection* foundColl = NULL; + RimScriptCollection* foundColl = nullptr; if (this->subDirectories[i]) foundColl = this->subDirectories[i]->findScriptCollection(path); if (foundColl) return foundColl; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index d7b36b0d9c..e9512a9586 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -209,7 +209,7 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() obsoleteField_showWellLabel.xmlCapability()->setIOWritable(false); obsoleteField_showWellCellFence.xmlCapability()->setIOWritable(false); - m_reservoirView = NULL; + m_reservoirView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -266,7 +266,7 @@ RimSimWellInView* RimSimWellInViewCollection::findWell(QString name) return this->wells()[i]; } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index 63e3f98886..2cc1cbcbd6 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -266,8 +266,8 @@ void RimViewController::updateOverrides() if (isVisibleCellsOveridden()) { - if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL); - if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL); + if (manEclView) manEclView->setOverridePropertyFilterCollection(nullptr); + if (manGeoView) manGeoView->setOverridePropertyFilterCollection(nullptr); m_managedView->scheduleGeometryRegen(OVERRIDDEN_CELL_VISIBILITY); m_managedView->scheduleCreateDisplayModelAndRedraw(); } @@ -285,7 +285,7 @@ void RimViewController::updateOverrides() } else { - manEclView->setOverridePropertyFilterCollection(NULL); + manEclView->setOverridePropertyFilterCollection(nullptr); } } } @@ -301,13 +301,13 @@ void RimViewController::updateOverrides() } else { - manGeoView->setOverridePropertyFilterCollection(NULL); + manGeoView->setOverridePropertyFilterCollection(nullptr); } } } } - this->updateRangeFilterOverrides(NULL); + this->updateRangeFilterOverrides(nullptr); if (manGeoView) { @@ -351,10 +351,10 @@ void RimViewController::removeOverrides(RimGridView* view) RimEclipseView* manEclView = dynamic_cast(view); RimGeoMechView* manGeoView = dynamic_cast(view); - if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL); - if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL); + if (manEclView) manEclView->setOverridePropertyFilterCollection(nullptr); + if (manGeoView) manGeoView->setOverridePropertyFilterCollection(nullptr); - view->setOverrideRangeFilterCollection(NULL); + view->setOverrideRangeFilterCollection(nullptr); } } @@ -558,7 +558,7 @@ void RimViewController::updateLegendDefinitions() //-------------------------------------------------------------------------------------------------- RimViewLinker* RimViewController::ownerViewLinker() const { - RimViewLinker* viewLinker = NULL; + RimViewLinker* viewLinker = nullptr; this->firstAncestorOrThisOfType(viewLinker); return viewLinker; @@ -574,10 +574,10 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() RimGeoMechView* masterGeomechView = dynamic_cast(masterView()); RimGeoMechView* dependGeomechView = managedGeoView(); - RigMainGrid* masterEclGrid = NULL; - RigMainGrid* dependEclGrid = NULL; - RigFemPart* masterFemPart = NULL; - RigFemPart* dependFemPart = NULL; + RigMainGrid* masterEclGrid = nullptr; + RigMainGrid* dependEclGrid = nullptr; + RigFemPart* masterFemPart = nullptr; + RigFemPart* dependFemPart = nullptr; if (masterEclipseView) { @@ -613,7 +613,7 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() } else { - m_caseToCaseCellMapper = NULL; + m_caseToCaseCellMapper = nullptr; } } @@ -960,7 +960,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa if (!isRangeFiltersControlled()) { - m_managedView->setOverrideRangeFilterCollection(NULL); + m_managedView->setOverrideRangeFilterCollection(nullptr); return; } @@ -1034,7 +1034,7 @@ void RimViewController::applyRangeFilterCollectionByUserChoice() bool restoreOriginal = askUserToRestoreOriginalRangeFilterCollection(m_managedView->name); if (restoreOriginal) { - m_managedView->setOverrideRangeFilterCollection(NULL); + m_managedView->setOverrideRangeFilterCollection(nullptr); } else { diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 5a05568c83..5d967bd77a 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -291,7 +291,7 @@ QString RimViewLinker::displayNameForView(RimGridView* view) if (view) { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; view->firstAncestorOrThisOfType(rimCase); if (rimCase) { @@ -313,7 +313,7 @@ void RimViewLinker::setMasterView(RimGridView* view) if (previousViewController) { delete previousViewController; - this->m_viewControllers.removeChildObject(NULL); + this->m_viewControllers.removeChildObject(nullptr); } this->removeOverrides(); @@ -388,7 +388,7 @@ void RimViewLinker::updateScaleZ(RimGridView* sourceView, double scaleZ) //-------------------------------------------------------------------------------------------------- bool RimViewLinker::isActive() const { - RimViewLinkerCollection* viewLinkerCollection = NULL; + RimViewLinkerCollection* viewLinkerCollection = nullptr; this->firstAncestorOrThisOfType(viewLinkerCollection); if (!viewLinkerCollection) @@ -464,7 +464,7 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimGridV if (view) { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; view->firstAncestorOrThisOfType(rimCase); if (dynamic_cast(rimCase)) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index cfc27855a8..d53adb88dc 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -185,7 +185,7 @@ RimCase* RimWellLogExtractionCurve::rimCase() const //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) { - m_case = view ? view->ownerCase() : NULL; + m_case = view ? view->ownerCase() : nullptr; RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); @@ -657,7 +657,7 @@ void RimWellLogExtractionCurve::setLogScaleFromSelectedResult() if (resVar.toUpper().contains("PERM")) { - RimWellLogTrack* track = NULL; + RimWellLogTrack* track = nullptr; this->firstAncestorOrThisOfType(track); if (track) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index 5dcb6f5049..72d8f6490f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -89,7 +89,7 @@ RimWellLogFile::RimWellLogFile() m_invalidDateMessage.uiCapability()->setUiReadOnly(true); m_invalidDateMessage.xmlCapability()->disableIO(); - m_wellLogDataFile = NULL; + m_wellLogDataFile = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -107,7 +107,7 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath) { QFileInfo fi(logFilePath); - RimWellLogFile* wellLogFile = NULL; + RimWellLogFile* wellLogFile = nullptr; if (fi.suffix().toUpper().compare("LAS") == 0) { @@ -129,7 +129,7 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath) displayMessage); delete wellLogFile; - wellLogFile = NULL; + wellLogFile = nullptr; } } @@ -158,7 +158,7 @@ bool RimWellLogFile::readFile(QString* errorMessage) if (!m_wellLogDataFile->open(m_fileName, errorMessage)) { - m_wellLogDataFile = NULL; + m_wellLogDataFile = nullptr; return false; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 9be63af1f9..db01263cec 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -65,7 +65,7 @@ RimWellLogPlot::RimWellLogPlot() { CAF_PDM_InitObject("Well Log Plot", ":/WellLogPlot16x16.png", "", ""); - m_viewer = NULL; + m_viewer = nullptr; CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Well Log Plot"),"Name", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp index b1f0ac84d4..f89bf09c5a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp @@ -87,7 +87,7 @@ RigEclipseWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimW { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -114,7 +114,7 @@ RigGeoMechWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimW { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index d0199227d5..bb6eccbb38 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -252,7 +252,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++) { RimWellPath* wellPath = wellPathArray[wpIdx]; - wellPath->readWellPathFile(NULL, m_wellPathImporter); + wellPath->readWellPathFile(nullptr, m_wellPathImporter); progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name())); @@ -262,7 +262,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP { existingWellPath->filepath = wellPath->filepath; existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile; - existingWellPath->readWellPathFile(NULL, m_wellPathImporter); + existingWellPath->readWellPathFile(nullptr, m_wellPathImporter); // Let name from well path file override name from well log file existingWellPath->setName(wellPath->name()); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp index e302d3b260..46ea1b73e3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp @@ -161,7 +161,7 @@ RimObservedData* RimObservedDataCollection::createAndAddCvsObservedDataFromFile( } parseOptions->setUiModeImport(fileName); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, parseOptions, "CSV Import Options", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, parseOptions, "CSV Import Options", ""); if (propertyDialog.exec() != QDialog::Accepted) { return nullptr; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 1e5366d150..28d46eb279 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -147,7 +147,7 @@ void RimSummaryCase::updateAutoShortName() { if(m_useAutoShortName) { - RimOilField* oilField = NULL; + RimOilField* oilField = nullptr; this->firstAncestorOrThisOfType(oilField); CVF_ASSERT(oilField); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 0d0cfdefa0..5cdc0551eb 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -800,7 +800,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, .arg(last.toString(formatString)); } - QMessageBox::warning(NULL, "Detected no overlapping time steps", description); + QMessageBox::warning(nullptr, "Detected no overlapping time steps", description); } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index e8a7c4670e..38a005e209 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -151,7 +151,7 @@ RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromQwtCurve(const QwtPl } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index d4a0725535..d614a88911 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1505,7 +1505,7 @@ caf::PdmObject* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qwt } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp index f09a8d8fc8..77451bec2c 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp @@ -38,7 +38,7 @@ RigActiveCellsResultAccessor::RigActiveCellsResultAccessor(const RigGridBase* gr //-------------------------------------------------------------------------------------------------- double RigActiveCellsResultAccessor::cellScalar(size_t gridLocalCellIndex) const { - if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL; + if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0 ) return HUGE_VAL; size_t reservoirCellIndex = m_grid->reservoirCellIndex(gridLocalCellIndex); size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex); @@ -65,7 +65,7 @@ double RigActiveCellsResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, c //-------------------------------------------------------------------------------------------------- double RigActiveCellsResultAccessor::cellScalarGlobIdx(size_t reservoirCellIndex) const { - if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0) return HUGE_VAL; + if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0) return HUGE_VAL; size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 8b35439fb3..5b6a3e4fc3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -44,9 +44,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) : m_activeCellInfo(NULL) +RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) : m_activeCellInfo(nullptr) { - CVF_ASSERT(ownerCaseData != NULL); + CVF_ASSERT(ownerCaseData != nullptr); CVF_ASSERT(ownerCaseData->mainGrid() != nullptr); m_ownerCaseData = ownerCaseData; @@ -1316,15 +1316,15 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) this->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount); - std::vector* swatForTimeStep = NULL; - std::vector* sgasForTimeStep = NULL; + std::vector* swatForTimeStep = nullptr; + std::vector* sgasForTimeStep = nullptr; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex)); if (swatForTimeStep->size() == 0) { - swatForTimeStep = NULL; + swatForTimeStep = nullptr; } } @@ -1333,7 +1333,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) sgasForTimeStep = &(this->cellScalarResults(scalarIndexSGAS, timeStepIndex)); if (sgasForTimeStep->size() == 0) { - sgasForTimeStep = NULL; + sgasForTimeStep = nullptr; } } @@ -1405,13 +1405,13 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) this->cellScalarResults(scalarIndexSGAS, timeStepIndex).resize(swatResultValueCount); - std::vector* swatForTimeStep = NULL; + std::vector* swatForTimeStep = nullptr; { swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex)); if (swatForTimeStep->size() == 0) { - swatForTimeStep = NULL; + swatForTimeStep = nullptr; } } @@ -1554,7 +1554,7 @@ void calculateConnectionGeometry(const RigCell& c1, const RigCell& c2, const std bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &intersections, - (cvf::EdgeIntersectStorage*)NULL, + (cvf::EdgeIntersectStorage*)nullptr, cvf::wrapArrayConst(&nodes), face1.data(), face2.data(), @@ -1688,7 +1688,7 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo std::vector & permResults = this->cellScalarResults(permResultIdx)[0]; std::vector & riTransResults = this->cellScalarResults(riTransResultIdx)[0]; - std::vector * ntgResults = NULL; + std::vector * ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); @@ -1699,9 +1699,9 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo riTransResults.resize(resultValueCount); // Prepare how to index the result values: - ResultIndexFunction riTranIdxFunc = NULL; - ResultIndexFunction permIdxFunc = NULL; - ResultIndexFunction ntgIdxFunc = NULL; + ResultIndexFunction riTranIdxFunc = nullptr; + ResultIndexFunction permIdxFunc = nullptr; + ResultIndexFunction ntgIdxFunc = nullptr; { bool isPermUsingResIdx = this->isUsingGlobalActiveIndex(permResultIdx); bool isTransUsingResIdx = this->isUsingGlobalActiveIndex(riTransResultIdx); @@ -1841,17 +1841,17 @@ void RigCaseCellResultsData::computeNncCombRiTrans() std::vector & riCombTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTrans()); m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombTrans(), riCombTransScalarResultIndex); - std::vector * ntgResults = NULL; + std::vector * ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); } // Prepare how to index the result values: - ResultIndexFunction permXIdxFunc = NULL; - ResultIndexFunction permYIdxFunc = NULL; - ResultIndexFunction permZIdxFunc = NULL; - ResultIndexFunction ntgIdxFunc = NULL; + ResultIndexFunction permXIdxFunc = nullptr; + ResultIndexFunction permYIdxFunc = nullptr; + ResultIndexFunction permZIdxFunc = nullptr; + ResultIndexFunction ntgIdxFunc = nullptr; { bool isPermXUsingResIdx = this->isUsingGlobalActiveIndex(permXResultIdx); bool isPermYUsingResIdx = this->isUsingGlobalActiveIndex(permYResultIdx); @@ -1884,7 +1884,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx; cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face; - ResultIndexFunction permIdxFunc = NULL; + ResultIndexFunction permIdxFunc = nullptr; std::vector * permResults; switch (faceId) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 222459d0fb..5d0d420319 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -74,7 +74,7 @@ class RigCaseCellResultsData : public cvf::Object // Access meta-information about the results size_t resultCount() const; size_t timeStepCount(size_t scalarResultIndex) const; - size_t maxTimeStepCount(size_t* scalarResultIndex = NULL) const; + size_t maxTimeStepCount(size_t* scalarResultIndex = nullptr) const; QStringList resultNames(RiaDefines::ResultCatType type) const; bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; bool hasFlowDiagUsableFluxes() const; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp index ed3eff7898..29f11a515d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp @@ -31,8 +31,8 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid) : m_masterGrid(masterEclGrid), m_dependentGrid(dependentEclGrid), - m_masterFemPart(NULL), - m_dependentFemPart(NULL) + m_masterFemPart(nullptr), + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT); @@ -42,10 +42,10 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, Rig /// //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid) - : m_masterGrid(NULL), + : m_masterGrid(nullptr), m_dependentGrid(dependentEclGrid), m_masterFemPart(masterFemPart), - m_dependentFemPart(NULL) + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT); this->calculateEclToGeomCellMapping(dependentEclGrid, masterFemPart, false); @@ -55,8 +55,8 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigM /// //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigFemPart* dependentFemPart) - : m_masterGrid(NULL), - m_dependentGrid(NULL), + : m_masterGrid(nullptr), + m_dependentGrid(nullptr), m_masterFemPart(masterFemPart), m_dependentFemPart(dependentFemPart) { @@ -69,9 +69,9 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigF //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart) : m_masterGrid(masterEclGrid), - m_dependentGrid(NULL), + m_dependentGrid(nullptr), m_masterFemPart(dependentFemPart), - m_dependentFemPart(NULL) + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT); this->calculateEclToGeomCellMapping(masterEclGrid, dependentFemPart, true); @@ -87,7 +87,7 @@ const int * RigCaseToCaseCellMapper::masterCaseCellIndices(int dependentCaseRese if (seriesIndex == cvf::UNDEFINED_INT) { (*masterCaseCellIndexCount) = 0; - return NULL; + return nullptr; } if (seriesIndex < 0) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp index 48b1219292..2ea21dd336 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp @@ -41,12 +41,12 @@ class RigNeighborCornerFinder const caf::SizeTArray8* neighborIndices(int offsetI, int offsetJ, int offsetK) { - if (offsetI < 0 && m_baseI == 0) return NULL; - if (offsetJ < 0 && m_baseJ == 0) return NULL; - if (offsetK < 0 && m_baseK == 0) return NULL; - if (offsetI > 0 && m_baseI == m_mainGrid->cellCountI()-1) return NULL; - if (offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ()-1) return NULL; - if (offsetK > 0 && m_baseK == m_mainGrid->cellCountK()-1) return NULL; + if (offsetI < 0 && m_baseI == 0) return nullptr; + if (offsetJ < 0 && m_baseJ == 0) return nullptr; + if (offsetK < 0 && m_baseK == 0) return nullptr; + if (offsetI > 0 && m_baseI == m_mainGrid->cellCountI()-1) return nullptr; + if (offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ()-1) return nullptr; + if (offsetK > 0 && m_baseK == m_mainGrid->cellCountK()-1) return nullptr; size_t gridLocalCellIndex = m_mainGrid->cellIndexFromIJK(m_baseI + offsetI, m_baseJ + offsetJ, m_baseK + offsetK); const RigCell& cell = m_mainGrid->globalCellArray()[gridLocalCellIndex]; diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 2fc2a1a81d..ddd9662fd6 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -40,8 +40,8 @@ static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T, RigCell::RigCell() : m_parentCellIndex(cvf::UNDEFINED_SIZE_T), m_mainGridCellIndex(cvf::UNDEFINED_SIZE_T), - m_subGrid(NULL), - m_hostGrid(NULL), + m_subGrid(nullptr), + m_hostGrid(nullptr), m_isInvalid(false), m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T), m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T) @@ -309,7 +309,7 @@ cvf::Vec3d RigCell::faceNormalWithAreaLenght(cvf::StructGridInterface::FaceType //-------------------------------------------------------------------------------------------------- int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const { - CVF_ASSERT(intersectionPoint != NULL); + CVF_ASSERT(intersectionPoint != nullptr); cvf::ubyte faceVertexIndices[4]; int face; diff --git a/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp index ed3f5cc55d..1a337fbfd8 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp @@ -56,7 +56,7 @@ double RigCellEdgeResultAccessor::cellScalar(size_t gridLocalCellIndex) const double RigCellEdgeResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const { const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p(); - if (resultAccessObj != NULL) + if (resultAccessObj != nullptr) { return resultAccessObj->cellFaceScalar(gridLocalCellIndex, faceId); } @@ -82,7 +82,7 @@ double RigCellEdgeResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const double RigCellEdgeResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const { const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p(); - if (resultAccessObj != NULL) + if (resultAccessObj != nullptr) { return resultAccessObj->cellFaceScalarGlobIdx(globCellIndex, faceId); } diff --git a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp index 6fc358ae6f..f2f48882fa 100644 --- a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp @@ -63,7 +63,7 @@ double RigCombTransResultAccessor::cellScalar(size_t gridLocalCellIndex) const //-------------------------------------------------------------------------------------------------- double RigCombTransResultAccessor::neighborCellTran(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId, const RigResultAccessor* transAccessor) const { - if (transAccessor != NULL) + if (transAccessor != nullptr) { size_t i, j, k, neighborGridCellIdx; m_grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 2ae082b21f..5c1613099d 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -32,7 +32,7 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid): m_mainGrid(mainGrid), m_indexToStartOfCells(0) { - if (mainGrid == NULL) + if (mainGrid == nullptr) { m_gridIndex = 0; m_gridId = 0; @@ -493,7 +493,7 @@ bool RigGridCellFaceVisibilityFilter::isFaceVisible(size_t i, size_t j, size_t k } // If the neighbour cell is invisible, we need to draw the face - if ((cellVisibility != NULL) && !(*cellVisibility)[neighborCellIndex]) + if ((cellVisibility != nullptr) && !(*cellVisibility)[neighborCellIndex]) { return true; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp index e52d0525e6..bd153f09cb 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp @@ -58,7 +58,7 @@ RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid) return mainGrid; } } - return NULL; + return nullptr; } @@ -67,7 +67,7 @@ RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid) //-------------------------------------------------------------------------------------------------- bool RigGridManager::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) { - if (gridA == NULL || gridB == NULL) return false; + if (gridA == nullptr || gridB == nullptr) return false; if (gridA == gridB) return true; diff --git a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp index 54940ef0b8..3d51738c39 100644 --- a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp @@ -35,7 +35,7 @@ int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1, const size_t hexIndex, std::vector* intersections) { - CVF_ASSERT(intersections != NULL); + CVF_ASSERT(intersections != nullptr); std::set uniqueIntersections; diff --git a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp index b6090829e8..7a024257e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -394,7 +394,7 @@ bool RigLasFileExporter::writeToFolder(const QString& exportFolder) if (caf::Utils::fileExists(fileName)) { QString txt = QString("File %1 exists.\n\nDo you want to overwrite the file?").arg(fileName); - int ret = QMessageBox::question(NULL, "LAS File Export", + int ret = QMessageBox::question(nullptr, "LAS File Export", txt, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); diff --git a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp index 9b4ebbe248..652574913d 100644 --- a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp @@ -22,7 +22,7 @@ RigLocalGrid::RigLocalGrid(RigMainGrid* mainGrid): RigGridBase(mainGrid), - m_parentGrid(NULL), + m_parentGrid(nullptr), m_positionInParentGrid(cvf::UNDEFINED_SIZE_T) { diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 11b2615fe8..23a835aa7d 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -295,7 +295,7 @@ void RigMainGrid::calculateFaults(const RigActiveCellInfo* activeCellInfo) size_t neighborReservoirCellIdx; size_t neighborGridCellIdx; size_t i, j, k; - RigGridBase* hostGrid = NULL; + RigGridBase* hostGrid = nullptr; bool firstNO_FAULTFaceForCell = true; bool isCellActive = true; @@ -476,7 +476,7 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirC { CVF_ASSERT(m_faultsPrCellAcc.notNull()); - if (face == cvf::StructGridInterface::NO_FACE) return NULL; + if (face == cvf::StructGridInterface::NO_FACE) return nullptr; int faultIdx = m_faultsPrCellAcc->faultIdx(reservoirCellIndex, face); if (faultIdx != RigFaultsPrCellAccumulator::NO_FAULT ) @@ -510,7 +510,7 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirC } } #endif - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -555,7 +555,7 @@ void RigMainGrid::buildCellSearchTree() } m_cellSearchTree = new cvf::BoundingBoxTree; - m_cellSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, NULL); + m_cellSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, nullptr); } } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index ef0461f12c..37289499b0 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -169,7 +169,7 @@ cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap(const Ri bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &intersections, - (cvf::EdgeIntersectStorage*)NULL, + (cvf::EdgeIntersectStorage*)nullptr, cvf::wrapArrayConst(&mainGrid.nodes()), face1.data(), face2.data(), diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index 09f43e0821..a59ca86f3a 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -359,7 +359,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosINeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosINeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosINeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; @@ -385,7 +385,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosJNeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosJNeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosJNeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; @@ -412,7 +412,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosKNeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosKNeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosKNeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 40d287ff48..8cc31e00ec 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -298,7 +298,7 @@ bool RigReservoirBuilderMock::inputProperty(RigEclipseCaseData* eclipseCase, con size_t k; /* initialize random seed: */ - srand ( time(NULL) ); + srand ( time(nullptr) ); /* generate secret number: */ int iSecret = rand() % 20 + 1; diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp index 89172faf4c..5500061ec6 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp @@ -73,13 +73,13 @@ cvf::ref RigResultAccessorFactory::createFromNameAndType(cons if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultType, uiResultName); if (scalarSetIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } cvf::ref derivedCandidate = createDerivedResultAccessor(eclipseCase, @@ -155,13 +155,13 @@ cvf::ref RigResultAccessorFactory::createNativeFromUiResultNa if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName); if (scalarSetIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } return createFromResultIdx(eclipseCase, gridIndex, porosityModel, timeStepIndex, scalarSetIndex); @@ -323,10 +323,10 @@ cvf::ref RigResultAccessorFactory::createFromResultIdx(const return new RigHugeValResultAccessor; } - if (!eclipseCase) return NULL; + if (!eclipseCase) return nullptr; const RigGridBase* grid = eclipseCase->grid(gridIndex); - if (!grid) return NULL; + if (!grid) return nullptr; const std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(resultIndex); @@ -335,7 +335,7 @@ cvf::ref RigResultAccessorFactory::createFromResultIdx(const return new RigHugeValResultAccessor; } - const std::vector* resultValues = NULL; + const std::vector* resultValues = nullptr; if (timeStepIndex < scalarSetResults.size()) { resultValues = &(scalarSetResults[timeStepIndex]); diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp index ba772a5837..1db8e52737 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp @@ -35,11 +35,11 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc size_t timeStepIndex, QString& uiResultName) { - if (!eclipseCase) return NULL; + if (!eclipseCase) return nullptr; if (!eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName); @@ -56,32 +56,32 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc RiaDefines::PorosityModelType porosityModel, size_t timeStepIndex, size_t scalarResultIndex) { - if ( !eclipseCase ) return NULL; + if ( !eclipseCase ) return nullptr; if (!eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } RigGridBase* grid = eclipseCase->grid(gridIndex); if (!grid) { - return NULL; + return nullptr; } std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarResultIndex); if (timeStepIndex >= scalarSetResults.size()) { - return NULL; + return nullptr; } - std::vector* resultValues = NULL; + std::vector* resultValues = nullptr; if (timeStepIndex < scalarSetResults.size()) { resultValues = &(scalarSetResults[timeStepIndex]); diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp index d58b222127..db934ee3cf 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp @@ -371,7 +371,7 @@ const RigWellResultPoint* RigWellResultFrame::findResultCell(size_t gridIndex, s return &m_wellHead; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 8212160165..35eaede582 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -140,7 +140,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF cvf::Vec3d whIntermediate = whStartPos; whIntermediate.z() = (whStartPos.z() + whCell.center().z()) / 2.0; - const RigWellResultPoint* prevWellResPoint = NULL; + const RigWellResultPoint* prevWellResPoint = nullptr; // CVF_ASSERT(isMultiSegmentWell || resBranches.size() <= 1); // TODO : Consider to set isMultiSegmentWell = true; @@ -158,7 +158,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF const RigWellResultBranch& branch = resBranches[brIdx]; if ( !hasAnyValidDataCells(branch) ) continue; - prevWellResPoint = NULL; + prevWellResPoint = nullptr; // Find the start the MSW well-branch centerline. Normal wells are started "once" at wellhead in the code above diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp index 110be82073..9d9f9d843a 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp @@ -58,7 +58,7 @@ static double sg_createAbsentValue(double lowestDataValue) RigWellLogFile::RigWellLogFile() : cvf::Object() { - m_wellLogFile = NULL; + m_wellLogFile = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ bool RigWellLogFile::open(const QString& fileName, QString* errorMessage) { close(); - NRLib::Well* well = NULL; + NRLib::Well* well = nullptr; try { @@ -138,7 +138,7 @@ void RigWellLogFile::close() if (m_wellLogFile) { delete m_wellLogFile; - m_wellLogFile = NULL; + m_wellLogFile = nullptr; } m_wellLogChannelNames.clear(); diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp index 3e0a245178..f316e305ca 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp @@ -328,7 +328,7 @@ GeometryTools::inPlaneLineIntersect3D( const cvf::Vec3d& planeNormal, const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& p3, const cvf::Vec3d& p4, cvf::Vec3d* intersectionPoint, double* fractionAlongLine1, double* fractionAlongLine2, double tolerance) { - CVF_ASSERT (intersectionPoint != NULL); + CVF_ASSERT (intersectionPoint != nullptr); int Z = findClosestAxis(planeNormal); int X = (Z + 1) % 3; @@ -762,7 +762,7 @@ EarClipTesselator::EarClipTesselator(): m_X(-1), m_Y(-1), m_areaTolerance(1e-12), - m_nodeCoords(NULL) + m_nodeCoords(nullptr) { } @@ -775,7 +775,7 @@ EarClipTesselator::EarClipTesselator(): bool EarClipTesselator::calculateTriangles( std::vector* triangleIndices ) { - CVF_ASSERT(m_nodeCoords != NULL); + CVF_ASSERT(m_nodeCoords != nullptr); CVF_ASSERT(m_X > -1 && m_Y > -1); size_t numVertices = m_polygonIndices.size(); @@ -1010,7 +1010,7 @@ void FanEarClipTesselator::setCenterNode(size_t centerNodeIndex) bool FanEarClipTesselator::calculateTriangles(std::vector* triangles) { CVF_ASSERT(m_centerNodeIndex != std::numeric_limits::max()); - CVF_ASSERT(m_nodeCoords != NULL); + CVF_ASSERT(m_nodeCoords != nullptr); CVF_ASSERT(m_X > -1 && m_Y > -1); size_t nv = m_polygonIndices.size(); diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl index c11664e743..b1ecbebecd 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl @@ -142,7 +142,7 @@ bool GeometryTools::isPointTouchingIndexedPolygon( const cvf::Vec3d& polygonNor int yBelowVx1 = 0; const double* vtx0; - const double* vtx1 = NULL; + const double* vtx1 = nullptr; double dv0; diff --git a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp index 9597da7501..f72589d343 100644 --- a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -207,14 +207,14 @@ class RiaGetActiveCellInfo: public RiaSocketCommand if (actCellInfo->isActive(cIdx)) { RigGridBase* grid = reservoirCells[cIdx].hostGrid(); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(grid != nullptr); size_t cellIndex = reservoirCells[cIdx].gridLocalCellIndex(); size_t i, j, k; grid->ijkFromCellIndex(cellIndex, &i, &j, &k); size_t pi, pj, pk; - RigGridBase* parentGrid = NULL; + RigGridBase* parentGrid = nullptr; if (grid->isMainGrid()) { @@ -227,7 +227,7 @@ class RiaGetActiveCellInfo: public RiaSocketCommand { size_t parentCellIdx = reservoirCells[cIdx].parentCellIndex(); parentGrid = (static_cast(grid))->parentGrid(); - CVF_ASSERT(parentGrid != NULL); + CVF_ASSERT(parentGrid != nullptr); parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); } diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 529f5adebe..dba1cbbca1 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -298,7 +298,7 @@ class RiaSetNNCProperty: public RiaSocketCommand { public: RiaSetNNCProperty() : - m_currentReservoir(NULL), + m_currentReservoir(nullptr), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), m_bytesPerTimeStepToRead(0), diff --git a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp index 2eca0d817e..3db077693b 100644 --- a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp @@ -171,7 +171,7 @@ class RiaGetCaseGroups : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { RimProject* proj = RiaApplication::instance()->project(); - RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { std::vector groupNames; @@ -236,7 +236,7 @@ class RiaGetCases : public RiaSocketCommand } RimProject* proj = RiaApplication::instance()->project(); - RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { @@ -247,7 +247,7 @@ class RiaGetCases : public RiaSocketCommand } else { - RimIdenticalGridCaseGroup* caseGroup = NULL; + RimIdenticalGridCaseGroup* caseGroup = nullptr; for (size_t i = 0; i < analysisModels->caseGroups().size(); i++) { RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i]; diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 3dad4c480b..2bf5284892 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -74,7 +74,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand // Find the requested data size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(porosityModelEnum)) { @@ -87,7 +87,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); @@ -95,7 +95,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand // Write data back : timeStepCount, bytesPrTimestep, dataForTimestep0 ... dataForTimestepN - if ( scalarResultFrames == NULL) + if ( scalarResultFrames == nullptr) { // No data available socketStream << (quint64)0 << (quint64)0 ; @@ -230,7 +230,7 @@ class RiaGetGridProperty: public RiaSocketCommand QString porosityModelName = args[4]; RimEclipseCase*rimCase = server->findReservoir(caseId); - if (rimCase == NULL) + if (rimCase == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId)); @@ -382,8 +382,8 @@ class RiaSetActiveCellProperty: public RiaSocketCommand { public: RiaSetActiveCellProperty() : - m_currentReservoir(NULL), - m_scalarResultsToAdd(NULL), + m_currentReservoir(nullptr), + m_scalarResultsToAdd(nullptr), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), m_bytesPerTimeStepToRead(0), @@ -409,7 +409,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // Find the requested data, Or create a set if we are setting data and it is not found size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(m_porosityModelEnum)) { @@ -436,7 +436,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand } } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); return true; @@ -581,7 +581,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand } std::vector readBuffer; - double * internalMatrixData = NULL; + double * internalMatrixData = nullptr; if (isCoarseningActive) { @@ -635,7 +635,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand if (m_currentTimeStepNumberToRead == m_timeStepCountToRead) { - if (m_currentReservoir != NULL) + if (m_currentReservoir != nullptr) { // Create a new input property if we have an input reservoir RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); @@ -661,7 +661,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // Adjust the result data if only one time step is requested so the result behaves like a static result if (m_requestedTimesteps.size() == 1 && m_currentScalarIndex != cvf::UNDEFINED_SIZE_T) { - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; scalarResultFrames = &(m_currentReservoir->results(m_porosityModelEnum)->cellScalarResults(m_currentScalarIndex)); size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for (size_t i = 0; i < scalarResultFrames->size(); i++) @@ -728,8 +728,8 @@ class RiaSetGridProperty : public RiaSocketCommand { public: RiaSetGridProperty() : - m_currentReservoir(NULL), - m_scalarResultsToAdd(NULL), + m_currentReservoir(nullptr), + m_scalarResultsToAdd(nullptr), m_currentGridIndex(cvf::UNDEFINED_SIZE_T), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), @@ -803,7 +803,7 @@ class RiaSetGridProperty : public RiaSocketCommand size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(m_porosityModelEnum)) { @@ -825,7 +825,7 @@ class RiaSetGridProperty : public RiaSocketCommand } } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); return true; @@ -999,7 +999,7 @@ class RiaSetGridProperty : public RiaSocketCommand if (m_currentTimeStepNumberToRead == m_timeStepCountToRead) { - if (m_currentReservoir != NULL) + if (m_currentReservoir != nullptr) { // Create a new input property if we have an input reservoir RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); @@ -1025,7 +1025,7 @@ class RiaSetGridProperty : public RiaSocketCommand // Adjust the result data if only one time step is requested so the result behaves like a static result if (m_requestedTimesteps.size() == 1 && m_currentScalarIndex != cvf::UNDEFINED_SIZE_T) { - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; scalarResultFrames = &(m_currentReservoir->results(m_porosityModelEnum)->cellScalarResults(m_currentScalarIndex)); size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for (size_t i = 0; i < scalarResultFrames->size(); i++) diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 799acd25d0..84d84a8e0e 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -44,10 +44,10 @@ //-------------------------------------------------------------------------------------------------- RiaSocketServer::RiaSocketServer(QObject* parent) : QObject(parent), - m_tcpServer(NULL), - m_currentClient(NULL), + m_tcpServer(nullptr), + m_currentClient(nullptr), m_currentCommandSize(0), - m_currentCommand(NULL), + m_currentCommand(nullptr), m_currentCaseId(-1) { m_errorMessageDialog = new QErrorMessage(RiuMainWindow::instance()); @@ -161,7 +161,7 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId) else { RimProject* project = RiaApplication::instance()->project(); - if (!project) return NULL; + if (!project) return nullptr; std::vector cases; project->allCases(cases); @@ -175,7 +175,7 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -302,7 +302,7 @@ void RiaSocketServer::terminateCurrentConnection() m_currentClient->disconnect(SIGNAL(disconnected())); m_currentClient->disconnect(SIGNAL(readyRead())); m_currentClient->deleteLater(); - m_currentClient = NULL; + m_currentClient = nullptr; } // Clean up more state: @@ -310,7 +310,7 @@ void RiaSocketServer::terminateCurrentConnection() if (m_currentCommand) { delete m_currentCommand; - m_currentCommand = NULL; + m_currentCommand = nullptr; } m_currentCommandSize = 0; @@ -341,8 +341,8 @@ void RiaSocketServer::handleNextPendingConnection() QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection(); if (clientToHandle) { - CVF_ASSERT(m_currentClient == NULL); - CVF_ASSERT(m_currentCommand == NULL); + CVF_ASSERT(m_currentClient == nullptr); + CVF_ASSERT(m_currentCommand == nullptr); m_currentClient = clientToHandle; m_currentCommandSize = 0; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 0f4d0878d1..6aa3667f3e 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -47,7 +47,7 @@ class RiaSocketServer : public QObject enum ReadState {ReadingCommand, ReadingPropertyData}; public: - explicit RiaSocketServer(QObject *parent = 0); + explicit RiaSocketServer(QObject *parent = nullptr); ~RiaSocketServer(); unsigned short serverPort(); diff --git a/ApplicationCode/SocketInterface/RiaSocketTools.cpp b/ApplicationCode/SocketInterface/RiaSocketTools.cpp index 54d337a241..fb4e68d822 100644 --- a/ApplicationCode/SocketInterface/RiaSocketTools.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketTools.cpp @@ -49,7 +49,7 @@ //-------------------------------------------------------------------------------------------------- RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const QList& args) { - RimEclipseCase* rimCase = NULL; + RimEclipseCase* rimCase = nullptr; int caseId = -1; if (args.size() > 1) @@ -58,7 +58,7 @@ RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const } rimCase = server->findReservoir(caseId); - if (rimCase == NULL) + if (rimCase == nullptr) { // TODO: Display error message a different place to avoid socket comm to be halted. //server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the Case with CaseId : \"%1\"").arg(caseId)); @@ -79,7 +79,7 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri caseName = rimCase->caseUserDescription; RimEclipseCase* eclCase = dynamic_cast (rimCase); - RimCaseCollection* caseCollection = NULL; + RimCaseCollection* caseCollection = nullptr; if (eclCase) { caseCollection = eclCase->parentCaseCollection(); diff --git a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp index ea771d836f..e7af18e51a 100644 --- a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp +++ b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp @@ -88,7 +88,7 @@ TEST(DISABLED_HDFTests, BasicFileRead) hsize_t dims[2]; H5::DataSpace dataspace = dataset.getSpace(); - dataspace.getSimpleExtentDims(dims, NULL); + dataspace.getSimpleExtentDims(dims, nullptr); std::vector values; values.resize(dims[0]); diff --git a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp index 8c304e9946..d441785fa8 100644 --- a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp +++ b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp @@ -125,7 +125,7 @@ TEST(RigStatisticsMath, HistogramPercentiles) double min, max, range, mean, stdev; - RigStatisticsMath::calculateBasicStatistics(values, &min, &max, NULL, &range, &mean, &stdev); + RigStatisticsMath::calculateBasicStatistics(values, &min, &max, nullptr, &range, &mean, &stdev); std::vector histogram; RigHistogramCalculator histCalc(min, max, 100, &histogram); diff --git a/ApplicationCode/UserInterface/RiuDragDrop.cpp b/ApplicationCode/UserInterface/RiuDragDrop.cpp index b41d7b1561..768cee7c93 100644 --- a/ApplicationCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationCode/UserInterface/RiuDragDrop.cpp @@ -145,7 +145,7 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const //-------------------------------------------------------------------------------------------------- Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const { - Qt::ItemFlags itemflags = 0; + Qt::ItemFlags itemflags = nullptr; if (index.isValid()) { @@ -399,7 +399,7 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje { if (action == Qt::MoveAction) { - RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(trackTarget, wellLogPlotCurves, NULL); + RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(trackTarget, wellLogPlotCurves, nullptr); return true; } } @@ -429,7 +429,7 @@ bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGro { if (action == Qt::MoveAction) { - RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, NULL); + RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, nullptr); return true; } } diff --git a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h index b2f763df59..eeaf4f902b 100644 --- a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h +++ b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h @@ -47,7 +47,7 @@ class RiuFlowCharacteristicsPlot : public QFrame, public RiuInterfaceToViewWindo { Q_OBJECT; public: - RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = NULL); + RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuFlowCharacteristicsPlot(); void setLorenzCurve(const QStringList& dateTimeStrings, const std::vector& dateTimes, const std::vector& timeHistoryValues); diff --git a/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h b/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h index e3b24e3ab2..d6f08839fa 100644 --- a/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h @@ -30,7 +30,7 @@ class QStringList; class RiuGridStatisticsHistogramWidget : public QWidget { public: - RiuGridStatisticsHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0); + RiuGridStatisticsHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax); diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 4ac2d724e7..620d09a0a4 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -62,7 +62,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(NULL), m_blockSlotSubWindowActivated(false) +RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { m_mdiArea = new QMdiArea; m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); @@ -112,11 +112,11 @@ void RiuMainPlotWindow::initializeGuiNewProjectLoaded() //-------------------------------------------------------------------------------------------------- void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() { - setPdmRoot(NULL); + setPdmRoot(nullptr); if (m_pdmUiPropertyView) { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } cleanUpTemporaryWidgets(); @@ -400,7 +400,7 @@ QMdiSubWindow* RiuMainPlotWindow::findMdiSubWindow(QWidget* viewer) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -625,7 +625,7 @@ void RiuMainPlotWindow::selectedObjectsChanged() std::vector uiItems; m_projectTreeView->selectedUiItems(uiItems); - caf::PdmObjectHandle* firstSelectedObject = NULL; + caf::PdmObjectHandle* firstSelectedObject = nullptr; if (uiItems.size() == 1) { diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 82412c8a9f..8ccf1e94f5 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -97,20 +97,20 @@ //================================================================================================== -RiuMainWindow* RiuMainWindow::sm_mainWindowInstance = NULL; +RiuMainWindow* RiuMainWindow::sm_mainWindowInstance = nullptr; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuMainWindow::RiuMainWindow() - : m_pdmRoot(NULL), - m_mainViewer(NULL), - m_relPermPlotPanel(NULL), - m_pvtPlotPanel(NULL), - m_windowMenu(NULL), + : m_pdmRoot(nullptr), + m_mainViewer(nullptr), + m_relPermPlotPanel(nullptr), + m_pvtPlotPanel(nullptr), + m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { - CVF_ASSERT(sm_mainWindowInstance == NULL); + CVF_ASSERT(sm_mainWindowInstance == nullptr); m_mdiArea = new QMdiArea; m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); @@ -183,7 +183,7 @@ void RiuMainWindow::cleanupGuiCaseClose() if (m_pdmUiPropertyView) { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } for (size_t i = 0; i < additionalProjectViews.size(); i++) @@ -191,10 +191,10 @@ void RiuMainWindow::cleanupGuiCaseClose() RiuProjectAndPropertyView* projPropView = dynamic_cast(additionalProjectViews[i]->widget()); if (projPropView) { - projPropView->showProperties(NULL); + projPropView->showProperties(nullptr); } } - m_processMonitor->startMonitorWorkProcess(NULL); + m_processMonitor->startMonitorWorkProcess(nullptr); RicEditSummaryPlotFeature* editSumCurves = dynamic_cast(caf::CmdFeatureManager::instance()->getCommandFeature("RicEditSummaryPlotFeature")); if (editSumCurves) @@ -210,7 +210,7 @@ void RiuMainWindow::cleanupGuiCaseClose() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::cleanupGuiBeforeProjectClose() { - setPdmRoot(NULL); + setPdmRoot(nullptr); cleanupGuiCaseClose(); } @@ -745,7 +745,7 @@ void RiuMainWindow::slotRefreshViewActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshAnimationActions() { - caf::FrameAnimationControl* animationControl = NULL; + caf::FrameAnimationControl* animationControl = nullptr; Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && activeView->viewer()) @@ -858,7 +858,7 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1072,7 +1072,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) // Find the activated 3D view - Rim3dView* activatedView = NULL; + Rim3dView* activatedView = nullptr; std::vector allCases; proj->allCases(allCases); @@ -1080,7 +1080,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx) { RimCase* reservoirCase = allCases[caseIdx]; - if (reservoirCase == NULL) continue; + if (reservoirCase == nullptr) continue; std::vector views = reservoirCase->views(); @@ -1199,7 +1199,7 @@ void RiuMainWindow::setActiveViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotFramerateChanged(double frameRate) { - if (RiaApplication::instance()->activeReservoirView() != NULL) + if (RiaApplication::instance()->activeReservoirView() != nullptr) { RiaApplication::instance()->activeReservoirView()->maximumFrameRate.setValueWithFieldChanged(frameRate); } @@ -1255,7 +1255,7 @@ void RiuMainWindow::selectedObjectsChanged() std::vector uiItems; m_projectTreeView->selectedUiItems(uiItems); - caf::PdmObjectHandle* firstSelectedObject = NULL; + caf::PdmObjectHandle* firstSelectedObject = nullptr; if (uiItems.size() == 1) { @@ -1451,7 +1451,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) void RiuMainWindow::refreshDrawStyleActions() { Rim3dView* view = RiaApplication::instance()->activeReservoirView(); - bool enable = view != NULL; + bool enable = view != nullptr; bool isGridView = RiaApplication::instance()->activeGridView() != nullptr; m_drawStyleLinesAction->setEnabled(enable); diff --git a/ApplicationCode/UserInterface/RiuMdiSubWindow.h b/ApplicationCode/UserInterface/RiuMdiSubWindow.h index ed043f0e9f..2c21d535d8 100644 --- a/ApplicationCode/UserInterface/RiuMdiSubWindow.h +++ b/ApplicationCode/UserInterface/RiuMdiSubWindow.h @@ -25,7 +25,7 @@ class RiuMdiSubWindow : public QMdiSubWindow { public: - RiuMdiSubWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0); + RiuMdiSubWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr); ~RiuMdiSubWindow(); diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index e073c9df75..e60e6bede1 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -32,7 +32,7 @@ class FileListModel: public QStringListModel { public: - explicit FileListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent) + explicit FileListModel(QObject *parent = nullptr) : m_isItemsEditable(false), QStringListModel(parent) { } diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h index 4030c384eb..7ad1275cc2 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h @@ -37,7 +37,7 @@ class RiuMultiCaseImportDialog: public QDialog Q_OBJECT public: - explicit RiuMultiCaseImportDialog(QWidget *parent = 0); + explicit RiuMultiCaseImportDialog(QWidget *parent = nullptr); virtual ~RiuMultiCaseImportDialog(); QStringList eclipseCaseFileNames() const; diff --git a/ApplicationCode/UserInterface/RiuNightchartsWidget.h b/ApplicationCode/UserInterface/RiuNightchartsWidget.h index 378f0177d5..777b112d96 100644 --- a/ApplicationCode/UserInterface/RiuNightchartsWidget.h +++ b/ApplicationCode/UserInterface/RiuNightchartsWidget.h @@ -31,7 +31,7 @@ class RiuNightchartsWidget : public QWidget { Q_OBJECT public: - explicit RiuNightchartsWidget(QWidget* parent = 0); + explicit RiuNightchartsWidget(QWidget* parent = nullptr); void addItem(const QString& name, const QColor& color, float value); void setType(Nightcharts::type type); diff --git a/ApplicationCode/UserInterface/RiuProcessMonitor.cpp b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp index 96f49ca269..1254ba7ed4 100644 --- a/ApplicationCode/UserInterface/RiuProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp @@ -35,7 +35,7 @@ RiuProcessMonitor::RiuProcessMonitor(QDockWidget* pParent) : QWidget(pParent) { - m_monitoredProcess = NULL; + m_monitoredProcess = nullptr; QLabel* pLabel = new QLabel("Status:", this); pLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); @@ -112,7 +112,7 @@ void RiuProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess) //-------------------------------------------------------------------------------------------------- void RiuProcessMonitor::stopMonitorWorkProcess() { - m_monitoredProcess = NULL; + m_monitoredProcess = nullptr; m_terminatePushButton->setEnabled(false); diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp index 9efd302e85..6ef24b9549 100644 --- a/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp @@ -92,7 +92,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView(QWidget* parent, Qt::Window //-------------------------------------------------------------------------------------------------- void RiuProjectAndPropertyView::setPdmItem(caf::PdmUiItem* object) { - m_propertyView->showProperties(NULL); + m_propertyView->showProperties(nullptr); m_projectTreeView->setPdmItem(object); } diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.h b/ApplicationCode/UserInterface/RiuProjectPropertyView.h index eb2b2ea501..3b58ce40ea 100644 --- a/ApplicationCode/UserInterface/RiuProjectPropertyView.h +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.h @@ -33,7 +33,7 @@ namespace caf { class RiuProjectAndPropertyView : public QWidget { public: - RiuProjectAndPropertyView(QWidget* parent = 0, Qt::WindowFlags f = 0); + RiuProjectAndPropertyView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); void setPdmItem(caf::PdmUiItem* object); void showProperties(caf::PdmObjectHandle* object); diff --git a/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp b/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp index 4aa3cd5a86..7e7ee5632f 100644 --- a/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp +++ b/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp @@ -77,7 +77,7 @@ RiuPropertyViewTabWidget::~RiuPropertyViewTabWidget() { for (auto w : m_pageWidgets) { - w->showProperties(NULL); + w->showProperties(nullptr); } } diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp index cc787e7038..d9ca0f26f2 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp @@ -100,7 +100,7 @@ class RiuPvtQwtPicker : public QwtPicker //-------------------------------------------------------------------------------------------------- RiuPvtPlotWidget::RiuPvtPlotWidget(RiuPvtPlotPanel* parent) : QWidget(parent), - m_trackerPlotMarker(NULL) + m_trackerPlotMarker(nullptr) { m_qwtPlot = new PvtQwtPlot(this); setPlotDefaults(m_qwtPlot); @@ -190,7 +190,7 @@ void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, co m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotMarker); m_qwtCurveArr.clear(); m_pvtCurveArr.clear(); - m_trackerPlotMarker = NULL; + m_trackerPlotMarker = nullptr; // Construct an auxiliary curve that connects the first point in all the input curves as a visual aid @@ -383,7 +383,7 @@ void RiuPvtPlotWidget::updateTrackerPlotMarkerAndLabelFromPicker() { m_trackerPlotMarker->detach(); delete m_trackerPlotMarker; - m_trackerPlotMarker = NULL; + m_trackerPlotMarker = nullptr; needsReplot = true; } @@ -406,7 +406,7 @@ const QwtPlotCurve* RiuPvtPlotWidget::closestCurveSample(const QPoint& cursorPos if (closestSampleIndex) *closestSampleIndex = -1; - const QwtPlotCurve* closestCurve = NULL; + const QwtPlotCurve* closestCurve = nullptr; double distMin = HUGE_VAL; int closestPointSampleIndex = -1; @@ -437,7 +437,7 @@ const QwtPlotCurve* RiuPvtPlotWidget::closestCurveSample(const QPoint& cursorPos } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index 082a0f683c..d0126d8412 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -53,7 +53,7 @@ //-------------------------------------------------------------------------------------------------- RiuPvtPlotUpdater::RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel) : m_targetPlotPanel(targetPlotPanel), - m_sourceEclipseViewOfLastPlot(NULL) + m_sourceEclipseViewOfLastPlot(nullptr) { } @@ -67,11 +67,11 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selecti return; } - m_sourceEclipseViewOfLastPlot = NULL; + m_sourceEclipseViewOfLastPlot = nullptr; bool mustClearPlot = true; RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); - RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; if (!eclipseSelectionItem && !eclipseView) { @@ -138,7 +138,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView CVF_ASSERT(plotPanel); RimEclipseResultCase* eclipseResultCase = dynamic_cast(eclipseView.eclipseCase()); - RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL; + RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface()) { size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex); @@ -195,7 +195,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { size_t i = 0; diff --git a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp index 899463ebf9..8bdda78576 100644 --- a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp +++ b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp @@ -137,7 +137,7 @@ void RiuRecentFileActionProvider::slotOpenRecentFile() } else { - QMessageBox::warning(NULL, "File open", "Failed to import file located at\n" + fileName); + QMessageBox::warning(nullptr, "File open", "Failed to import file located at\n" + fileName); removeFileName(fileName); } diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 92c89b7c3b..2683be34d6 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -52,7 +52,7 @@ //-------------------------------------------------------------------------------------------------- RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel) : m_targetPlotPanel(targetPlotPanel), - m_sourceEclipseViewOfLastPlot(NULL) + m_sourceEclipseViewOfLastPlot(nullptr) { } @@ -67,11 +67,11 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelec return; } - m_sourceEclipseViewOfLastPlot = NULL; + m_sourceEclipseViewOfLastPlot = nullptr; bool mustClearPlot = true; RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); - RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; if (!eclipseSelectionItem && !eclipseView) { @@ -138,7 +138,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse CVF_ASSERT(plotPanel); RimEclipseResultCase* eclipseResultCase = dynamic_cast(eclipseView.eclipseCase()); - RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL; + RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface()) { size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex); @@ -182,7 +182,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double satnum) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { size_t i = 0; @@ -229,7 +229,7 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText(const Rig size_t CellLookupHelper::mapToActiveCellIndex(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { // Note!! diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.h b/ApplicationCode/UserInterface/RiuResultQwtPlot.h index c08250accc..945473ac2e 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.h @@ -37,7 +37,7 @@ namespace cvf class RiuResultQwtPlot : public QwtPlot { public: - explicit RiuResultQwtPlot(QWidget* parent = NULL); + explicit RiuResultQwtPlot(QWidget* parent = nullptr); virtual ~RiuResultQwtPlot(); void addCurve(const QString& curveName, diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 2652a71052..690af09cd0 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -84,12 +84,12 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater = RiuMainWindow::instance()->relativePermeabilityPlotPanel()->plotUpdater(); - relPermPlotUpdater->updateOnSelectionChanged(NULL); + relPermPlotUpdater->updateOnSelectionChanged(nullptr); RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); - pvtPlotUpdater->updateOnSelectionChanged(NULL); + pvtPlotUpdater->updateOnSelectionChanged(nullptr); - updateResultInfo(NULL); + updateResultInfo(nullptr); scheduleUpdateForAllVisibleViews(); } @@ -308,7 +308,7 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd QString pickInfo; RiuSelectionItem* selItem = const_cast(itemAdded); - if (selItem != NULL) + if (selItem != nullptr) { Rim2dIntersectionView* intersectionView = nullptr; diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h index d00508f152..be82643d9f 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h @@ -30,7 +30,7 @@ class QStringList; class RiuSimpleHistogramWidget : public QWidget { public: - RiuSimpleHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0); + RiuSimpleHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 7e13a3facd..bcbbcf0713 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -340,7 +340,7 @@ bool RiuSummaryQwtPlot::eventFilter(QObject* watched, QEvent* event) //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos) { - QwtPlotCurve* closestCurve = NULL; + QwtPlotCurve* closestCurve = nullptr; double distMin = DBL_MAX; const QwtPlotItemList& itmList = itemList(); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 1592aad790..c95350a1d5 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -44,7 +44,7 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = NULL); + RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuSummaryQwtPlot(); RimSummaryPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuTextDialog.h b/ApplicationCode/UserInterface/RiuTextDialog.h index ea2bc4116f..7dffaa74e4 100644 --- a/ApplicationCode/UserInterface/RiuTextDialog.h +++ b/ApplicationCode/UserInterface/RiuTextDialog.h @@ -26,7 +26,7 @@ class RiuQPlainTextEdit : public QPlainTextEdit { Q_OBJECT public: - explicit RiuQPlainTextEdit(QWidget *parent = 0) : QPlainTextEdit(parent) {} + explicit RiuQPlainTextEdit(QWidget *parent = nullptr) : QPlainTextEdit(parent) {} protected: virtual void keyPressEvent(QKeyEvent *e) override; @@ -46,7 +46,7 @@ class RiuTextDialog : public QDialog Q_OBJECT public: - explicit RiuTextDialog(QWidget* parent = 0); + explicit RiuTextDialog(QWidget* parent = nullptr); void setText(const QString& text); diff --git a/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h b/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h index 2fbe6d15cd..ac43f8167b 100644 --- a/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h +++ b/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h @@ -43,7 +43,7 @@ class RiuTofAccumulatedPhaseFractionsPlot : public QwtPlot, public RiuInterfaceT Q_OBJECT public: - RiuTofAccumulatedPhaseFractionsPlot(RimTofAccumulatedPhaseFractionsPlot* plotDefinition, QWidget* parent = NULL); + RiuTofAccumulatedPhaseFractionsPlot(RimTofAccumulatedPhaseFractionsPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuTofAccumulatedPhaseFractionsPlot(); RimTofAccumulatedPhaseFractionsPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h index 6fcee19707..52494bb749 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h @@ -45,7 +45,7 @@ class RiuWellAllocationPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = NULL); + RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellAllocationPlot(); RimWellAllocationPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 34a3f8484d..42c039695d 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -46,7 +46,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent) - : QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(NULL) + : QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(nullptr) { Q_ASSERT(plotDefinition); m_plotDefinition = plotDefinition; @@ -136,7 +136,7 @@ void RiuWellLogPlot::removeTrackPlot(RiuWellLogTrack* trackPlot) CVF_ASSERT(trackIdx >= 0); m_trackPlots.removeAt(trackIdx); - trackPlot->setParent(NULL); + trackPlot->setParent(nullptr); QwtLegend* legend = m_legends[trackIdx]; m_legends.removeAt(trackIdx); diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.h b/ApplicationCode/UserInterface/RiuWellLogPlot.h index 8ef62c57a8..768bba563f 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.h @@ -45,7 +45,7 @@ class RiuWellLogPlot : public QWidget, public RiuInterfaceToViewWindow Q_OBJECT public: - RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL); + RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellLogPlot(); RimWellLogPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp index e4f346fadf..e266087288 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp @@ -196,7 +196,7 @@ bool RiuWellLogTrack::eventFilter(QObject* watched, QEvent* event) //-------------------------------------------------------------------------------------------------- void RiuWellLogTrack::selectClosestCurve(const QPoint& pos) { - QwtPlotCurve* closestCurve = NULL; + QwtPlotCurve* closestCurve = nullptr; double distMin = DBL_MAX; const QwtPlotItemList& itmList = itemList(); diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.h b/ApplicationCode/UserInterface/RiuWellLogTrack.h index a97f8f3246..9be479e3d5 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.h +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.h @@ -42,7 +42,7 @@ class RiuWellLogTrack : public QwtPlot Q_OBJECT public: - RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget* parent = NULL); + RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr); virtual ~RiuWellLogTrack(); void setDepthZoom(double minDepth, double maxDepth); diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.h b/ApplicationCode/UserInterface/RiuWellPltPlot.h index f1281953d8..e571e1bf0b 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.h +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.h @@ -45,7 +45,7 @@ class RiuWellPltPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent = NULL); + RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellPltPlot(); RimWellPltPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.h b/ApplicationCode/UserInterface/RiuWellRftPlot.h index ba23496a35..cf60df95f5 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.h +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.h @@ -45,7 +45,7 @@ class RiuWellRftPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = NULL); + RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellRftPlot(); RimWellRftPlot* ownerPlotDefinition(); From 8d30b6e09f5c48e2b7ea6e75628f6a09ad2e251c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 18 Feb 2018 19:01:38 +0100 Subject: [PATCH 0296/1027] Use size_t instead of int --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 93f03d22a8..9586c66231 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1475,7 +1475,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues frameCountProgress.incrementProgress(); compactionFrame.resize(nodeCount); - for (int n = 0; n < nodeCount; n++) + for (size_t n = 0; n < nodeCount; n++) { RefElement refElement; findReferenceElementForNode(*part, n, resVarAddr.refKLayerIndex, &refElement); From de3aa9f9752d13121554a5efa81d5fba3b3eca1c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2018 13:54:29 +0100 Subject: [PATCH 0297/1027] #2509 Fracture : Add text to indicate unit of fracture template --- .../Completions/RimFracture.cpp | 2 +- .../Completions/RimFractureTemplate.cpp | 31 ++++++++++++++++++- .../Completions/RimFractureTemplate.h | 4 +++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 826cc094ac..77ac136618 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -394,7 +394,7 @@ QList RimFracture::calculateValueOptions(const caf::PdmF for (RimFractureTemplate* fracDef : fracDefColl->fractureDefinitions()) { - options.push_back(caf::PdmOptionItemInfo(fracDef->name(), fracDef)); + options.push_back(caf::PdmOptionItemInfo(fracDef->nameAndUnit(), fracDef)); } } else if (fieldNeedingOptions == &m_stimPlanTimeIndexToPlot) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 907b8f8ee1..1edfe8c27f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -98,6 +98,12 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); CAF_PDM_InitField(&m_name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_nameAndUnit, "NameAndUnit", "NameAndUnit", "", "", ""); + m_nameAndUnit.registerGetMethod(this, &RimFractureTemplate::nameAndUnit); + m_nameAndUnit.uiCapability()->setUiHidden(true); + m_nameAndUnit.xmlCapability()->disableIO(); + CAF_PDM_InitField(&m_fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); m_fractureTemplateUnit.uiCapability()->setUiReadOnly(true); @@ -138,12 +144,14 @@ RimFractureTemplate::RimFractureTemplate() m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::dFactor); m_dFactorDisplayField.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName()); m_dFactorDisplayField.uiCapability()->setUiReadOnly(true); + m_dFactorDisplayField.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault(&m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", ""); m_dFactorSummaryText.registerGetMethod(this, &RimFractureTemplate::dFactorSummary); m_dFactorSummaryText.uiCapability()->setUiReadOnly(true); m_dFactorSummaryText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); m_dFactorSummaryText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP); + m_dFactorSummaryText.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- @@ -198,7 +206,7 @@ RiaEclipseUnitTools::UnitSystemType RimFractureTemplate::fractureTemplateUnit() //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() { - return &m_name; + return &m_nameAndUnit; } //-------------------------------------------------------------------------------------------------- @@ -570,6 +578,27 @@ double RimFractureTemplate::fractureWidth() const return m_fractureWidth; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFractureTemplate::nameAndUnit() const +{ + QString decoratedName; + + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + decoratedName += "[M] - "; + } + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + decoratedName += "[F] - "; + } + + decoratedName += m_name; + + return decoratedName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 92aa6cd545..6c8ed18da2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -108,6 +108,8 @@ class RimFractureTemplate : public caf::PdmObject virtual ~RimFractureTemplate(); QString name() const; + QString nameAndUnit() const; + RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit() const; FracOrientationEnum orientationType() const; float azimuthAngle() const; @@ -157,6 +159,8 @@ class RimFractureTemplate : public caf::PdmObject protected: caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndUnit; + caf::PdmField m_fractureTemplateUnit; caf::PdmField> m_orientationType; caf::PdmField m_azimuthAngle; From 0ef0f3b5b16a6b872979e1e9437b322a72ed2d81 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2018 14:32:33 +0100 Subject: [PATCH 0298/1027] #2509 Fracture : Guard UI selection of fracture template of different unit --- .../ProjectDataModel/Completions/RimFracture.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 77ac136618..233fb8df6f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -64,6 +64,7 @@ #include "cvfMatrix4.h" #include "cvfPlane.h" +#include #include #include @@ -197,6 +198,19 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons { if (changedField == &m_fractureTemplate) { + if (fractureUnit() != m_fractureTemplate->fractureTemplateUnit()) + { + QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); + + QString warningText = QString("Using a fracture template of different unit is not supported.\n\nPlease select a " + "fracture template of unit '%1'") + .arg(fractureUnitText); + + QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); + + m_fractureTemplate = nullptr; + } + setFractureTemplate(m_fractureTemplate); setDefaultFractureColorResult(); } From 0cb14397ac005a91c99d963a8c85f1a08c6f52cc Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 19 Feb 2018 15:08:54 +0100 Subject: [PATCH 0299/1027] #2503 2D intersection View: Add Z-scale as info in the 3d info box --- ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 04b04f51c1..5c7384f2ce 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -190,6 +190,9 @@ void Rim2dIntersectionView::update3dInfo() } overlayInfoText += "

"; + + overlayInfoText += "Z-scale: " + QString::number(scaleZ()) + "
"; + overlayInfoText += "Intersection: " + m_intersection->name() + "
"; if (m_intersection->simulationWell()) From f0d32e6e450b2f1a990fe853c6009634930de3d7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 19 Feb 2018 15:11:35 +0100 Subject: [PATCH 0300/1027] #2511 2D Intersection view: Avoid selecting intersection in tree when selecting a cell --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 5af5b8f1c9..0c0e0d3d85 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -576,7 +576,10 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM intersectionHit = true; intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex); - RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection()); + if (!dynamic_cast(m_viewer->ownerViewWindow())) + { + RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection()); + } } else if (intersectionBoxSourceInfo) From a218addbe5b484ceb72764fa5f8ef840df7801db Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Feb 2018 21:09:44 +0100 Subject: [PATCH 0301/1027] clang : Fix to be compatible with Clang 3.8 --- .clang-tidy | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 9f1852b258..e5ffe435bf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,5 @@ --- Checks: '-*,modernize-use-nullptr' -WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false ... From fb95d896ef1610969a95bb11bcc7411d75debfa6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 07:20:25 +0100 Subject: [PATCH 0302/1027] #2509 Fracture : Add copy / paste of ellipse fracture template --- ApplicationCode/CMakeLists.txt | 1 + .../FractureCommands/CMakeLists_files.cmake | 23 ++++ .../RicPasteEllipseFractureFeature.cpp | 111 ++++++++++++++++++ .../RicPasteEllipseFractureFeature.h | 44 +++++++ .../RicCopyReferencesToClipboardFeature.cpp | 5 + .../RicNewEllipseFractureTemplateFeature.cpp | 62 ++++++---- .../RicNewEllipseFractureTemplateFeature.h | 8 +- .../RimContextCommandBuilder.cpp | 14 ++- 8 files changed, 240 insertions(+), 28 deletions(-) create mode 100644 ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake create mode 100644 ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp create mode 100644 ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 228bdf6d06..be308f89bb 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -124,6 +124,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake Commands/ExportCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake + Commands/FractureCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake Commands/IntersectionViewCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..f37d5560c7 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\Fracture" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp new file mode 100644 index 0000000000..d88cc41386 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteEllipseFractureFeature.h" + +#include "../OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "RimEllipseFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicPasteEllipseFractureFeature, "RicPasteEllipseFractureFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteEllipseFractureFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + if (typedObjects.size() == 0) + { + return false; + } + + if (fractureTemplateCollection()) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEllipseFractureFeature::onActionTriggered(bool isChecked) +{ + auto fractureTemplateColl = fractureTemplateCollection(); + if (!fractureTemplateColl) return; + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + for (const auto& source : typedObjects) + { + auto rimReservoirView = dynamic_cast( + source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateColl->fractureDefinitions.push_back(rimReservoirView); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, rimReservoirView); + } + + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEllipseFractureFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (Ellipse Fracture)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplateCollection* RicPasteEllipseFractureFeature::fractureTemplateCollection() +{ + RimFractureTemplateCollection* fractureTemplateColl = nullptr; + + auto destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (destinationObject) + { + destinationObject->firstAncestorOrThisOfType(fractureTemplateColl); + } + + return fractureTemplateColl; +} diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h new file mode 100644 index 0000000000..e3fe726421 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimFractureTemplateCollection; + +namespace caf +{ +class PdmObjectGroup; +} + +//================================================================================================== +/// +//================================================================================================== +class RicPasteEllipseFractureFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimFractureTemplateCollection* fractureTemplateCollection(); +}; diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index d99c3a8c34..c5c5d7eb6d 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -21,6 +21,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" +#include "RimFractureTemplate.h" #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" @@ -162,6 +163,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { if (!wellAllocPlot && !rftPlot) return true; } + else if (dynamic_cast(pdmObject)) + { + return true; + } return false; } diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index c4ceee429d..b9d0c921b7 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -20,10 +20,10 @@ #include "RiaApplication.h" -#include "RimOilField.h" #include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" +#include "RimOilField.h" #include "RimProject.h" #include "RiuMainWindow.h" @@ -34,11 +34,36 @@ #include - CAF_CMD_SOURCE_INIT(RicNewEllipseFractureTemplateFeature, "RicNewEllipseFractureTemplateFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, + RimEllipseFractureTemplate* ellipseFractureTemplate) +{ + ellipseFractureTemplate->loadDataAndUpdate(); + + templateCollection->updateConnectedEditors(); + + RimProject* project = RiaApplication::instance()->project(); + + std::vector views; + project->allVisibleViews(views); + + for (Rim3dView* view : views) + { + if (dynamic_cast(view)) + { + view->updateConnectedEditors(); + } + } + + RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate); +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) { @@ -49,35 +74,22 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) if (oilfield == nullptr) return; RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection(); - + if (fracDefColl) { RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate(); + fracDefColl->fractureDefinitions.push_back(ellipseFractureTemplate); ellipseFractureTemplate->setName("Ellipse Fracture Template"); ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitsForFracTemplates()); ellipseFractureTemplate->setDefaultValuesFromUnit(); - ellipseFractureTemplate->loadDataAndUpdate(); - - fracDefColl->updateConnectedEditors(); - - std::vector views; - project->allVisibleViews(views); - - for (Rim3dView* view : views) - { - if (dynamic_cast(view)) - { - view->updateConnectedEditors(); - } - } - RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate); + selectFractureTemplateAndUpdate(fracDefColl, ellipseFractureTemplate); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetup) { @@ -86,7 +98,7 @@ void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetu } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicNewEllipseFractureTemplateFeature::isCommandEnabled() { diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h index f8f6118c84..23d1a8d774 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h @@ -22,6 +22,8 @@ #include +class RimEllipseFractureTemplate; +class RimFractureTemplateCollection; //================================================================================================== /// @@ -29,8 +31,12 @@ class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -protected: +public: + static void selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, + RimEllipseFractureTemplate* ellipseFractureTemplate); + +protected: virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 00e1b39b19..373798a8a3 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -530,17 +530,27 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewSimWellFractureFeature"; } - else if (dynamic_cast(uiItem) || - dynamic_cast(uiItem)) + else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertAllFractureTemplatesToMetricFeature"; menuBuilder << "RicConvertAllFractureTemplatesToFieldFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewEllipseFractureTemplateFeature"; + menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; menuBuilder << "Separator"; From 82e706375a12c3a9915a80692caa670ab8c87330 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 08:03:37 +0100 Subject: [PATCH 0303/1027] Octave Plugin : Move definition of qtDataStreamVersion to riSettings After conversion from NULL -> nullptr the octave plugins failed to compile. By moving the define of qtDataStreamVersion this issue was resolved, and the dependency from oct-files to RiaSocketServer.h was not required anymore (and removed) --- .../SocketInterface/RiaSocketServer.h | 10 ++++---- .../SocketInterface/RiaSocketServerDefines.h | 25 +++++++++++++++++++ OctavePlugin/riSettings.h | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 ApplicationCode/SocketInterface/RiaSocketServerDefines.h diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 6aa3667f3e..c556cbebc8 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -20,6 +20,8 @@ #pragma once +#include "RiaSocketServerDefines.h" + #include #include #include @@ -34,11 +36,9 @@ class QTimer; class RimEclipseCase; class RiaSocketCommand; -namespace riOctavePlugin -{ - const int qtDataStreamVersion = QDataStream::Qt_4_0; -} - +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RiaSocketServer : public QObject { Q_OBJECT diff --git a/ApplicationCode/SocketInterface/RiaSocketServerDefines.h b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h new file mode 100644 index 0000000000..542bf47484 --- /dev/null +++ b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h @@ -0,0 +1,25 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include + +namespace riOctavePlugin +{ + const int qtDataStreamVersion = QDataStream::Qt_4_0; +} + diff --git a/OctavePlugin/riSettings.h b/OctavePlugin/riSettings.h index 3e80a781d9..ee31729355 100644 --- a/OctavePlugin/riSettings.h +++ b/OctavePlugin/riSettings.h @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "../ApplicationCode/SocketInterface/RiaSocketServer.h" +#include "../ApplicationCode/SocketInterface/RiaSocketServerDefines.h" namespace riOctavePlugin { From 79a32af209afaf551fd9a26da882aac216a05d0c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 08:03:37 +0100 Subject: [PATCH 0304/1027] Octave Plugin : Move definition of qtDataStreamVersion to RiaSocketServerDefines After conversion from NULL -> nullptr the octave plugins failed to compile. By moving the define of qtDataStreamVersion this issue was resolved, and the dependency from oct-files to RiaSocketServer.h was not required anymore (and removed) --- .../SocketInterface/RiaSocketServer.h | 10 ++++---- .../SocketInterface/RiaSocketServerDefines.h | 25 +++++++++++++++++++ OctavePlugin/riSettings.h | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 ApplicationCode/SocketInterface/RiaSocketServerDefines.h diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 6aa3667f3e..c556cbebc8 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -20,6 +20,8 @@ #pragma once +#include "RiaSocketServerDefines.h" + #include #include #include @@ -34,11 +36,9 @@ class QTimer; class RimEclipseCase; class RiaSocketCommand; -namespace riOctavePlugin -{ - const int qtDataStreamVersion = QDataStream::Qt_4_0; -} - +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RiaSocketServer : public QObject { Q_OBJECT diff --git a/ApplicationCode/SocketInterface/RiaSocketServerDefines.h b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h new file mode 100644 index 0000000000..542bf47484 --- /dev/null +++ b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h @@ -0,0 +1,25 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include + +namespace riOctavePlugin +{ + const int qtDataStreamVersion = QDataStream::Qt_4_0; +} + diff --git a/OctavePlugin/riSettings.h b/OctavePlugin/riSettings.h index 3e80a781d9..ee31729355 100644 --- a/OctavePlugin/riSettings.h +++ b/OctavePlugin/riSettings.h @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "../ApplicationCode/SocketInterface/RiaSocketServer.h" +#include "../ApplicationCode/SocketInterface/RiaSocketServerDefines.h" namespace riOctavePlugin { From 9b1b94a4ae823188fe7e54f1f58776a68e1bfeee Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 11:26:39 +0100 Subject: [PATCH 0305/1027] #2517 Export COMPDATL : Include diameter for LGR grids --- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 12 ++++++++++++ .../CompletionExportCommands/RigCompletionData.cpp | 8 ++++++++ .../CompletionExportCommands/RigCompletionData.h | 1 + 3 files changed, 21 insertions(+) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 087b7c962f..8ef7e9776c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -334,6 +334,7 @@ RigCompletionData RigCompletionData resultCompletion(wellName, cellIndexIJK, firstCompletion.firstOrderingValue()); resultCompletion.setSecondOrderingValue(firstCompletion.secondOrderingValue()); + resultCompletion.setDiameter(firstCompletion.diameter()); bool anyNonDarcyFlowPresent = false; for (const auto& c : completions) @@ -703,6 +704,17 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse else { formatter.add(data.transmissibility()); + + // Based on feedback from Shunping + // Include diameter when COMPDATL is exported + // See https://github.com/OPM/ResInsight/issues/2517 + if (!gridName.isEmpty()) + { + if (RigCompletionData::isDefaultValue(data.diameter())) + formatter.add("1*"); + else + formatter.add(data.diameter()); + } } formatter.rowCompleted(); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp index bce30c25e3..6ff440d92f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp @@ -121,6 +121,14 @@ void RigCompletionData::setSecondOrderingValue(double orderingValue) m_secondOrderingValue = orderingValue; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setDiameter(double diameter) +{ + m_diameter = diameter; +} + //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h index bf6a9c196e..05e05cb081 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h @@ -77,6 +77,7 @@ class RigCompletionData void setFromFracture(double transmissibility, double skinFactor, double diameter); void setSecondOrderingValue(double orderingValue); + void setDiameter(double diameter); void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, double skinFactor, From 4ca78ca833a477ca3e4f1c935598f13a1c715d4b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 20 Feb 2018 13:38:45 +0100 Subject: [PATCH 0306/1027] #2460 Tensor Vectors: Use result as colormapping on the vectors --- .../RigFemPartResultsCollection.cpp | 136 ++++++++++++++---- .../RigFemPartResultsCollection.h | 7 +- .../RivTensorResultPartMgr.cpp | 64 ++++++--- .../RivTensorResultPartMgr.h | 6 +- .../ProjectDataModel/RimGeoMechView.cpp | 55 ++++++- .../ProjectDataModel/RimGeoMechView.h | 3 + .../ProjectDataModel/RimTensorResults.cpp | 37 ++++- .../ProjectDataModel/RimTensorResults.h | 8 ++ 8 files changed, 263 insertions(+), 53 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 9586c66231..2ec6429d7b 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -34,6 +34,7 @@ #include "RigFemPartResults.h" #include "RigFemScalarResultFrames.h" #include "RigFormationNames.h" +#include "RigHexIntersectionTools.h" #include "RigStatisticsDataCache.h" #include "RimMainPlotCollection.h" @@ -53,7 +54,6 @@ #include #include -#include "RigHexIntersectionTools.h" //-------------------------------------------------------------------------------------------------- @@ -2293,45 +2293,46 @@ const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(co return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax) +std::vector RigFemPartResultsCollection::tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr) { - double currentMin = HUGE_VAL; - double currentMax = -HUGE_VAL; - - double min; - double max; - std::vector addresses; - for (size_t i = 0; i < 6; ++i) + for (size_t i = 0; i < 3; ++i) { addresses.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "")); } if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST") { - addresses[0].componentName = "S11"; - addresses[1].componentName = "S22"; - addresses[2].componentName = "S33"; - addresses[3].componentName = "S12"; - addresses[4].componentName = "S13"; - addresses[5].componentName = "S23"; + addresses[0].componentName = "S1"; + addresses[1].componentName = "S2"; + addresses[2].componentName = "S3"; } else if (resVarAddr.fieldName == "E") { - addresses[0].componentName = "E11"; - addresses[1].componentName = "E22"; - addresses[2].componentName = "E33"; - addresses[3].componentName = "E12"; - addresses[4].componentName = "E13"; - addresses[5].componentName = "E23"; + addresses[0].componentName = "E1"; + addresses[1].componentName = "E2"; + addresses[2].componentName = "E3"; } - else return; - - for (auto address : addresses) + else + { + addresses.clear(); + } + + return addresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax) +{ + double currentMin = HUGE_VAL; + double currentMax = -HUGE_VAL; + + double min, max; + + for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) { this->statistics(address)->minMaxCellScalarValues(frameIndex, min, max); if (min < currentMin) @@ -2348,6 +2349,87 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(cons *localMax = currentMax; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax) +{ + double currentMin = HUGE_VAL; + double currentMax = -HUGE_VAL; + + double min, max; + + for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->minMaxCellScalarValues(min, max); + if (min < currentMin) + { + currentMin = min; + } + if (max > currentMax) + { + currentMax = max; + } + } + + *globalMin = currentMin; + *globalMax = currentMax; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero) +{ + double currentPosClosestToZero = HUGE_VAL; + double currentNegClosestToZero = -HUGE_VAL; + + double pos, neg; + + for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->posNegClosestToZero(frameIndex, pos, neg); + if (pos < currentPosClosestToZero) + { + currentPosClosestToZero = pos; + } + if (neg > currentNegClosestToZero) + { + currentNegClosestToZero = neg; + } + } + + *localPosClosestToZero = currentPosClosestToZero; + *localNegClosestToZero = currentNegClosestToZero; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero) +{ + double currentPosClosestToZero = HUGE_VAL; + double currentNegClosestToZero = -HUGE_VAL; + + double pos, neg; + + for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->posNegClosestToZero(pos, neg); + if (pos < currentPosClosestToZero) + { + currentPosClosestToZero = pos; + } + if (neg > currentNegClosestToZero) + { + currentNegClosestToZero = neg; + } + } + + *globalPosClosestToZero = currentPosClosestToZero; + *globalNegClosestToZero = currentNegClosestToZero; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index b494d177be..729c75c196 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -88,7 +88,9 @@ class RigFemPartResultsCollection: public cvf::Object const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex); void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); - + void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); + void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); + void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero); private: RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, const RigFemResultAddress& resVarAddr); @@ -119,6 +121,9 @@ class RigFemPartResultsCollection: public cvf::Object RigFemScalarResultFrames* calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr); RigFemScalarResultFrames* calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr); + static std::vector tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr); + +private: cvf::Collection m_femPartResults; cvf::ref m_readerInterface; cvf::ref m_elementPropertyReader; diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 3742dc14c0..80023ea0a8 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -20,6 +20,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechView.h" +#include "RimLegendConfig.h" #include "RimTensorResults.h" #include "RigFemPartCollection.h" @@ -123,8 +124,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); - for (int quadVertex = 0; quadVertex < static_cast(quadVerticesToNodeIdxMapping.size()); - quadVertex = quadVertex + 4) + for (int quadVertex = 0; quadVertex < static_cast(quadVerticesToNodeIdxMapping.size()); quadVertex += 4) { cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); @@ -331,36 +331,34 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector scalarMapper = new cvf::ScalarMapperDiscreteLinear; + + cvf::ScalarMapper* activeScalerMapper = nullptr; auto vectorColors = m_rimReservoirView->tensorResults()->vectorColors(); if (vectorColors == RimTensorResults::MAGENTA_BROWN_BLACK || vectorColors == RimTensorResults::WHITE_GRAY_BLACK) { - createOneColorPerPrincipalScalarMapper(m_rimReservoirView->tensorResults()->vectorColors(), scalarMapper.p()); - createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); + cvf::ref discreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; + + activeScalerMapper = discreteScalarMapper.p(); + + createOneColorPerPrincipalScalarMapper(vectorColors, discreteScalarMapper.p()); + createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, discreteScalarMapper.p()); } else { - // THIS WILL BE REPLACED BY REAL RESULT COLOR MAPPER - cvf::Color3ubArray arrowColors; - arrowColors.resize(3); - arrowColors[0] = cvf::Color3::BLACK; - arrowColors[1] = cvf::Color3::BLACK; - arrowColors[2] = cvf::Color3::BLACK; - scalarMapper->setColors(arrowColors); - scalarMapper->setRange(0.5, 3.5); - scalarMapper->setLevelCount(3, true); - createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, scalarMapper.p()); + activeScalerMapper = m_rimReservoirView->tensorResults()->legendConfig()->scalarMapper(); + + createResultColorTextureCoords(lineTexCoords.p(), tensorVisualizations, activeScalerMapper); } - caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); + caf::ScalarMapperEffectGenerator surfEffGen(activeScalerMapper, caf::PO_1); if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) { surfEffGen.disableLighting(true); } - caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); + caf::ScalarMapperMeshEffectGenerator meshEffGen(activeScalerMapper); cvf::ref scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); drawable->setTextureCoordArray(lineTexCoords.p()); @@ -423,6 +421,31 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalTextureCoords(cvf::Vec2fA } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createResultColorTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper) +{ + CVF_ASSERT(textureCoords); + CVF_ASSERT(mapper); + + size_t vertexCount = tensorVisualizations.size() * 5; + if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); + + for (auto tensor : tensorVisualizations) + { + int sign = tensor.isPressure ? 1 : -1; + + for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) + { + cvf::Vec2f texCoord = mapper->mapToTextureCoord(sign * tensor.result.length()); + textureCoords->add(texCoord); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -472,11 +495,12 @@ bool RivTensorResultPartMgr::isValid(cvf::Vec3f resultVector) //-------------------------------------------------------------------------------------------------- bool RivTensorResultPartMgr::isPressure(float principalValue) { - if (principalValue < 0) + if (principalValue >= 0) { - return false; + return true; } - return true; + + return false; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index f1ab24d75e..c0a323f263 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -87,9 +87,13 @@ class RivTensorResultPartMgr : public cvf::Object static void createOneColorPerPrincipalScalarMapper(const RimTensorResults::TensorColors& colorSet, cvf::ScalarMapperDiscreteLinear* scalarMapper); static void createOneColorPerPrincipalTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector& tensorVisualization, + const std::vector& tensorVisualizations, const cvf::ScalarMapper* mapper); + static void createResultColorTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper); + static bool isTensorAddress(RigFemResultAddress address); static bool isValid(cvf::Vec3f resultVector); static bool isPressure(float principalValue); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index fd6c4eae65..8394c09a89 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -379,9 +379,51 @@ void RimGeoMechView::updateLegends() { m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } + + updateTensorLegendTextAndRanges(m_tensorResults->legendConfig(), m_currentTimeStep()); + + if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS) + { + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->legendConfig->legend()); + } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex) +{ + if (!m_geomechCase || !m_geomechCase->geoMechData()) return; + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + + RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData(); + CVF_ASSERT(gmCase); + + RigFemResultPosEnum resPos = tensorResults()->resultPositionType(); + QString resFieldName = tensorResults()->resultFieldName(); + + RigFemResultAddress resVarAddress(resPos, resFieldName.toStdString(), ""); + + gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, timeStepIndex, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero); + + gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, &globalMin, &globalMax); + gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); + + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + QString legendTitle = "Tensors:\n" + caf::AppEnum(tensorResults()->resultPositionType()).uiText() + "\n" + + tensorResults()->resultFieldName(); + + legendConfig->setTitle(legendTitle); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -424,9 +466,8 @@ void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, in legendConfig->setNamedCategoriesInverse(fnVector); } - QString legendTitle = - caf::AppEnum(cellResult->resultPositionType()).uiText() + "\n" - + cellResult->resultFieldUiName(); + QString legendTitle = "Cell Results:\n" + caf::AppEnum(cellResult->resultPositionType()).uiText() + + "\n" + cellResult->resultFieldUiName(); if (!cellResult->resultComponentUiName().isEmpty()) { @@ -463,6 +504,14 @@ const RimTensorResults* RimGeoMechView::tensorResults() const return m_tensorResults; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults* RimGeoMechView::tensorResults() +{ + return m_tensorResults; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 429672243b..dabe3913fb 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -91,6 +91,7 @@ class RimGeoMechView : public RimGridView const cvf::ref vizLogic() const; const RimTensorResults* tensorResults() const; + RimTensorResults* tensorResults(); protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; @@ -111,6 +112,8 @@ class RimGeoMechView : public RimGridView void updateLegends(); + void updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index fbe561aceb..a4927da90a 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -21,6 +21,7 @@ #include "RigFemResultAddress.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimLegendConfig.h" #include "cafAppEnum.h" #include "cafPdmUiListEditor.h" @@ -59,6 +60,10 @@ RimTensorResults::RimTensorResults() { CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", ""); + CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + this->legendConfig = new RimLegendConfig(); + legendConfig.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", ""); m_resultPositionType.uiCapability()->setUiHidden(true); @@ -97,7 +102,7 @@ RimTensorResults::RimTensorResults() //-------------------------------------------------------------------------------------------------- RimTensorResults::~RimTensorResults() { - + delete legendConfig; } //-------------------------------------------------------------------------------------------------- @@ -108,6 +113,16 @@ RigFemResultAddress RimTensorResults::selectedTensorResult() const return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), ""); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::setShowTensors(bool enableTensors) +{ + m_showTensors = enableTensors; + updateConnectedEditors(); + updateUiIconFromState(enableTensors); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,6 +187,22 @@ RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const return m_scaleMethod(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemResultPosEnum RimTensorResults::resultPositionType() const +{ + return m_resultPositionType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::resultFieldName() const +{ + return m_resultFieldName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -208,6 +239,10 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, m_resultPositionType = m_resultPositionTypeUiField; m_resultFieldName = m_resultFieldNameUiField; } + if (changedField == &m_showTensors) + { + setShowTensors(m_showTensors); + } RimGeoMechView* view; firstAncestorOrThisOfType(view); diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index fa3f59514f..19d6625750 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -18,6 +18,7 @@ #pragma once +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -28,6 +29,7 @@ #include class RigFemResultAddress; +class RimLegendConfig; //================================================================================================== /// @@ -56,6 +58,7 @@ class RimTensorResults : public caf::PdmObject virtual ~RimTensorResults(); RigFemResultAddress selectedTensorResult() const; + void setShowTensors(bool enableTensors); bool showTensors() const; bool showPrincipal1() const; bool showPrincipal2() const; @@ -65,6 +68,11 @@ class RimTensorResults : public caf::PdmObject TensorColors vectorColors() const; ScaleMethod scaleMethod() const; + RigFemResultPosEnum resultPositionType() const; + QString resultFieldName() const; + + caf::PdmChildField legendConfig; + private: std::vector getResultMetaDataForUIFieldSetting(); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From 2c26ca424318e2d0964ed43ff87d6cafe09cf395 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 20 Feb 2018 13:39:20 +0100 Subject: [PATCH 0307/1027] #2460 Tensor Vectors: Hide tensors on intersection creation --- .../RicAppendIntersectionFeature.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index fe8ef29fdd..9d6f30a044 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -19,9 +19,11 @@ #include "RicAppendIntersectionFeature.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimGridView.h" +#include "RimTensorResults.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -107,6 +109,13 @@ void RicAppendIntersectionFeatureCmd::redo() //Enable display of grid cells, to be able to show generated property filter view->showGridCells(false); + + RimGeoMechView* geoMechView = nullptr; + geoMechView = dynamic_cast(view); + if (geoMechView) + { + geoMechView->tensorResults()->setShowTensors(false); + } } //-------------------------------------------------------------------------------------------------- From 03663617670273e9b0f1b1c9dae5e0b51d966e67 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 20 Feb 2018 13:56:36 +0100 Subject: [PATCH 0308/1027] #2460 Tensor vectors: Move cvf::ref of scaler mapper out to avoid nullptr exception --- ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 80023ea0a8..c1864b57e8 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -334,10 +334,10 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector discreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; auto vectorColors = m_rimReservoirView->tensorResults()->vectorColors(); if (vectorColors == RimTensorResults::MAGENTA_BROWN_BLACK || vectorColors == RimTensorResults::WHITE_GRAY_BLACK) { - cvf::ref discreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; activeScalerMapper = discreteScalarMapper.p(); From b69b15145f2b58131ff3ecbf2e23fa8563c87deb Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 20 Feb 2018 14:27:03 +0100 Subject: [PATCH 0309/1027] #2496 Tensor vectors: Use dark magenta for principal 1 and move color code to RiaColorTables --- .../Application/Tools/RiaColorTables.cpp | 30 +++++++++++++++++++ .../Application/Tools/RiaColorTables.h | 2 ++ .../RivTensorResultPartMgr.cpp | 10 +++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index b69e279bc1..91d2beb880 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -190,6 +190,36 @@ const caf::ColorTable& RiaColorTables::categoryPaletteColors() return colorTable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorWhiteGrayBlackPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub::WHITE, + cvf::Color3ub::GRAY, + cvf::Color3ub::BLACK, + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorMagentaBrownBlackPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub::DARK_MAGENTA, + cvf::Color3ub::BROWN, + cvf::Color3ub::BLACK, + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 6b35226b57..20c561556f 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -37,6 +37,8 @@ class RiaColorTables static const caf::ColorTable& blueWhiteRedPaletteColors(); static const caf::ColorTable& redWhiteBluePaletteColors(); static const caf::ColorTable& categoryPaletteColors(); + static const caf::ColorTable& tensorWhiteGrayBlackPaletteColors(); + static const caf::ColorTable& tensorMagentaBrownBlackPaletteColors(); static const caf::ColorTable& angularPaletteColors(); static const caf::ColorTable& stimPlanPaletteColors(); static const caf::ColorTable& faultsPaletteColors(); diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index c1864b57e8..d2f8d96cb3 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -18,6 +18,8 @@ #include "RivTensorResultPartMgr.h" +#include "RiaColorTables.h" + #include "RimGeoMechCase.h" #include "RimGeoMechView.h" #include "RimLegendConfig.h" @@ -382,15 +384,11 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalScalarMapper(const RimTen arrowColors.resize(3); if (colorSet == RimTensorResults::MAGENTA_BROWN_BLACK) { - arrowColors[0] = cvf::Color3::MAGENTA; - arrowColors[1] = cvf::Color3::BROWN; - arrowColors[2] = cvf::Color3::BLACK; + arrowColors = RiaColorTables::tensorMagentaBrownBlackPaletteColors().color3ubArray(); } else if (colorSet == RimTensorResults::WHITE_GRAY_BLACK) { - arrowColors[0] = cvf::Color3::WHITE; - arrowColors[1] = cvf::Color3::GRAY; - arrowColors[2] = cvf::Color3::BLACK; + arrowColors = RiaColorTables::tensorWhiteGrayBlackPaletteColors().color3ubArray(); } scalarMapper->setColors(arrowColors); From 81287ee7cc4097c50ee8ddbe7b86afc70191ed66 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 20 Feb 2018 14:40:47 +0100 Subject: [PATCH 0310/1027] #2484 2D Intersection View: 3D Info text: Show only well name, well path name or intersection name --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 5c7384f2ce..65942e400e 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -193,15 +193,17 @@ void Rim2dIntersectionView::update3dInfo() overlayInfoText += "Z-scale: " + QString::number(scaleZ()) + "
"; - overlayInfoText += "Intersection: " + m_intersection->name() + "
"; - if (m_intersection->simulationWell()) { - overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
";; + overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
"; } else if (m_intersection->wellPath()) { - overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
";; + overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
"; + } + else + { + overlayInfoText += "Intersection: " + m_intersection->name() + "
"; } if (eclView) From 35febab8db67d1fb7453313dd158874946259da0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 15:15:06 +0100 Subject: [PATCH 0311/1027] #2509 Fracture : Add support for unit conversion of stimplan grid coords --- .../RicConvertFractureTemplateUnitFeature.cpp | 25 ++++--- .../FileInterface/RifStimPlanXmlReader.cpp | 66 +++++++++++++++---- .../FileInterface/RifStimPlanXmlReader.h | 7 +- .../RimEllipseFractureTemplate.cpp | 48 ++++++++++---- .../Completions/RimEllipseFractureTemplate.h | 3 + .../Completions/RimFractureTemplate.h | 3 + .../RimStimPlanFractureTemplate.cpp | 19 +++++- .../Completions/RimStimPlanFractureTemplate.h | 3 + .../RimContextCommandBuilder.cpp | 4 +- .../RigStimPlanFractureDefinition.h | 2 +- 10 files changed, 143 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp index 8dfb865e07..0b7eb50294 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp @@ -55,11 +55,20 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); if (!objHandle) return; - RimEllipseFractureTemplate* ellipseFractureTemplate = nullptr; - objHandle->firstAncestorOrThisOfType(ellipseFractureTemplate); + RimFractureTemplate* fractureTemplate = nullptr; + objHandle->firstAncestorOrThisOfType(fractureTemplate); - ellipseFractureTemplate->changeUnits(); + auto currentUnit = fractureTemplate->fractureTemplateUnit(); + if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + fractureTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); + } + else + { + fractureTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); + } + fractureTemplate->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -73,16 +82,16 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); if (!objHandle) return; - RimEllipseFractureTemplate* ellipseFractureTemplate = nullptr; - objHandle->firstAncestorOrThisOfType(ellipseFractureTemplate); - if (!ellipseFractureTemplate) return; + RimFractureTemplate* fractureTemplate = nullptr; + objHandle->firstAncestorOrThisOfType(fractureTemplate); + if (!fractureTemplate) return; QString text = "Convert Values to "; - if (ellipseFractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { text += "Field"; } - else if (ellipseFractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { text += "Metric"; } diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index ae166c706b..a3438226f4 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -40,6 +40,7 @@ bool hasNegativeValues(std::vector xs); cvf::ref RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit, QString * errorMessage) { RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName)); @@ -56,7 +57,7 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil QXmlStreamReader xmlStream; xmlStream.setDevice(&dataFile); xmlStream.readNext(); - readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode); + readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode, requiredUnit); RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet(); @@ -167,8 +168,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil /// //-------------------------------------------------------------------------------------------------- void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, - RigStimPlanFractureDefinition* stimPlanFileData, - MirrorMode mirrorMode) + RigStimPlanFractureDefinition* stimPlanFileData, + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit) { size_t startNegValuesYs = 0; QString gridunit = "unknown"; @@ -199,22 +201,33 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr if (xmlStream.name() == "xs") { - size_t dummy; - std::vector gridValues; - getGriddingValues(xmlStream, gridValues, dummy); - stimPlanFileData->m_fileXs = gridValues; + std::vector gridValuesXs; + { + size_t dummy; + std::vector gridValues; + getGriddingValues(xmlStream, gridValues, dummy); + + gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + } - stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValues) : (bool)mirrorMode); + stimPlanFileData->m_fileXs = gridValuesXs; + + stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValuesXs) : (bool)mirrorMode); } else if (xmlStream.name() == "ys") { - std::vector gridValues; - getGriddingValues(xmlStream, gridValues, startNegValuesYs); + std::vector gridValuesYs; + { + std::vector gridValues; + getGriddingValues(xmlStream, gridValues, startNegValuesYs); + + gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + } // Reorder and change sign std::vector ys; - for (double y : gridValues) + for (double y : gridValuesYs) { ys.insert(ys.begin(), -y); } @@ -273,6 +286,37 @@ std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeSte } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifStimPlanXmlReader::valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + const std::vector& values) +{ + if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + std::vector convertedValues; + for (const auto &valueInFeet : values) + { + convertedValues.push_back(RiaEclipseUnitTools::feetToMeter(valueInFeet)); + } + + return convertedValues; + } + else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + std::vector convertedValues; + for (const auto &valueInMeter : values) + { + convertedValues.push_back(RiaEclipseUnitTools::meterToFeet(valueInMeter)); + } + + return convertedValues; + } + + return values; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index 7521323f1a..eeb1f32c97 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -38,12 +38,14 @@ class RifStimPlanXmlReader static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit, QString * errorMessage); private: static void readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData, - MirrorMode mirrorMode); + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit); static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName); static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName); @@ -51,6 +53,9 @@ class RifStimPlanXmlReader static std::vector> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream); + static std::vector valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + const std::vector& values); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index fe4e6a0a3c..1a5d5eb2b6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -175,23 +175,11 @@ void RimEllipseFractureTemplate::changeUnits() { if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); - m_height = RiaEclipseUnitTools::meterToFeet(m_height); - m_width = RiaEclipseUnitTools::meterToInch(m_width); - m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); - m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); - - setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_FIELD); + convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); } else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); - m_height = RiaEclipseUnitTools::feetToMeter(m_height); - m_width = RiaEclipseUnitTools::inchToMeter(m_width); - m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); - m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); - - setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_METRIC); + convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); } this->updateConnectedEditors(); @@ -357,6 +345,38 @@ std::vector> RimEllipseFractureTemplate::uiResultNam return propertyNamesAndUnits; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + if (neededUnit == fractureTemplateUnit()) + { + return; + } + + if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); + m_height = RiaEclipseUnitTools::meterToFeet(m_height); + m_width = RiaEclipseUnitTools::meterToInch(m_width); + m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); + m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); + + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_FIELD); + } + else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); + m_height = RiaEclipseUnitTools::feetToMeter(m_height); + m_width = RiaEclipseUnitTools::inchToMeter(m_width); + m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); + m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); + + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_METRIC); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 5c7072b38c..f5563cbff1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -66,6 +66,9 @@ class RimEllipseFractureTemplate : public RimFractureTemplate virtual std::vector> uiResultNamesWithUnit() const override; + + virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 6c8ed18da2..abe7bdb08e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -141,6 +141,9 @@ class RimFractureTemplate : public caf::PdmObject double dFactor() const; double kh() const; + virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + + protected: virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index f33992e33d..81c940b3bf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -242,12 +242,17 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_conductivityScalingFactor(), RifStimPlanXmlReader::MIRROR_AUTO, + fractureTemplateUnit(), &errorMessage); if (errorMessage.size() > 0) RiaLogging::error(errorMessage); if (m_stimPlanFractureDefinitionData.notNull()) { - setFractureTemplateUnit(m_stimPlanFractureDefinitionData->unitSet()); + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_UNKNOWN) + { + setFractureTemplateUnit(m_stimPlanFractureDefinitionData->unitSet()); + } + m_readError = false; } else @@ -491,6 +496,18 @@ bool RimStimPlanFractureTemplate::showStimPlanMesh() const return m_showStimPlanMesh_OBSOLETE(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + setFractureTemplateUnit(neededUnit); + + m_readError = false; + loadDataAndUpdate(); + setDefaultsBasedOnXMLfile(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 302cca1009..c3687f4713 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -90,6 +90,9 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate bool showStimPlanMesh() const; + + virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 373798a8a3..ee5bfe04da 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -542,10 +542,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { - menuBuilder << "RicPasteEllipseFractureFeature"; + //menuBuilder << "RicPasteEllipseFractureFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicConvertFractureTemplateUnitFeature"; } else if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index c0e5788903..9414e272bb 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -125,7 +125,7 @@ class RigStimPlanFractureDefinition: public cvf::Object double maxY() const; private: - RiaEclipseUnitTools::UnitSystem m_unitSet; + RiaEclipseUnitTools::UnitSystem m_unitSet; // To be deleted std::vector m_fileXs; std::vector m_Ys; std::vector m_timeSteps; From 4e737885e4249c10347d8e4ba307652f251298c2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 15:35:08 +0100 Subject: [PATCH 0312/1027] #2509 Fracture : Move unit conversion of top/bot perforation depth --- .../FileInterface/RifStimPlanXmlReader.cpp | 40 +++++++++++++-- .../FileInterface/RifStimPlanXmlReader.h | 6 ++- .../RigStimPlanFractureDefinition.cpp | 50 ++----------------- .../RigStimPlanFractureDefinition.h | 4 +- 4 files changed, 45 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index a3438226f4..a57fdf986a 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -184,6 +184,8 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr if (xmlStream.isStartElement()) { + RiaEclipseUnitTools::UnitSystem destinationUnit = requiredUnit; + if (xmlStream.name() == "grid") { gridunit = getAttributeValueString(xmlStream, "uom"); @@ -192,11 +194,20 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr else if (gridunit == "ft") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_FIELD; else stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; + if (destinationUnit == RiaEclipseUnitTools::UNITS_UNKNOWN) + { + // Use file unit set if requested unit is unknown + destinationUnit = stimPlanFileData->m_unitSet; + } + double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); - double tvdToBottomPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + double tvdToBotPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + + double tvdToTopPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToTopPerfFt); + double tvdToBotPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToBotPerfFt); - stimPlanFileData->setTvdToTopPerf(tvdToTopPerfFt, RiaDefines::UNIT_FEET); - stimPlanFileData->setTvdToBottomPerf(tvdToBottomPerfFt, RiaDefines::UNIT_FEET); + stimPlanFileData->setTvdToTopPerf(tvdToTopPerfRequestedUnit); + stimPlanFileData->setTvdToBottomPerf(tvdToBotPerfRequestedUnit); } if (xmlStream.name() == "xs") @@ -207,7 +218,7 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr std::vector gridValues; getGriddingValues(xmlStream, gridValues, dummy); - gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); } stimPlanFileData->m_fileXs = gridValuesXs; @@ -222,7 +233,7 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr std::vector gridValues; getGriddingValues(xmlStream, gridValues, startNegValuesYs); - gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); } // Reorder and change sign @@ -317,6 +328,25 @@ std::vector RifStimPlanXmlReader::valuesInRequiredUnitSystem(RiaEclipseU return values; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value) +{ + if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + return RiaEclipseUnitTools::feetToMeter(value); + } + else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + return RiaEclipseUnitTools::meterToFeet(value); + } + + return value; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index eeb1f32c97..b698b1e62e 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -56,6 +56,8 @@ class RifStimPlanXmlReader static std::vector valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, RiaEclipseUnitTools::UnitSystem requiredUnit, const std::vector& values); -}; - + static double valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value); +}; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 758ccfb488..3d3c05cffe 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -133,59 +133,17 @@ double RigStimPlanFractureDefinition::maxY() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit) +void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd) { - if (unit == RiaDefines::UNIT_METER) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_topPerfTvd = RiaEclipseUnitTools::meterToFeet(topPerfTvd); - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_topPerfTvd = topPerfTvd; - } - } - else if (unit == RiaDefines::UNIT_FEET) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_topPerfTvd = topPerfTvd; - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_topPerfTvd = RiaEclipseUnitTools::feetToMeter(topPerfTvd); - } - } + m_topPerfTvd = topPerfTvd; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit) +void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd) { - if (unit == RiaDefines::UNIT_METER) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_bottomPerfTvd = RiaEclipseUnitTools::meterToFeet(bottomPerfTvd); - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_bottomPerfTvd = bottomPerfTvd; - } - } - else if (unit == RiaDefines::UNIT_FEET) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_bottomPerfTvd = bottomPerfTvd; - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_bottomPerfTvd = RiaEclipseUnitTools::feetToMeter(bottomPerfTvd); - } - } + m_bottomPerfTvd = bottomPerfTvd; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 9414e272bb..0d89a72532 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -68,8 +68,8 @@ class RigStimPlanFractureDefinition: public cvf::Object double maxDepth() const; double topPerfTvd() const; double bottomPerfTvd() const; - void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); - void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); + void setTvdToTopPerf(double topPerfTvd); + void setTvdToBottomPerf(double bottomPerfTvd); cvf::ref createFractureGrid(const QString& resultName, int activeTimeStepIndex, From b0be540977f969e262faa1b03f85445884e2c0b4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 08:18:55 +0100 Subject: [PATCH 0313/1027] #2509 Fracture : Remove obsolete unit conversion code --- .../RivWellFracturePartMgr.cpp | 2 +- .../RimEllipseFractureTemplate.cpp | 38 ++--------- .../Completions/RimEllipseFractureTemplate.h | 5 +- .../Completions/RimFracture.cpp | 2 +- .../Completions/RimFractureTemplate.h | 5 +- .../RimStimPlanFractureTemplate.cpp | 11 ++- .../Completions/RimStimPlanFractureTemplate.h | 5 +- .../RigStimPlanFractureDefinition.cpp | 68 +------------------ .../RigStimPlanFractureDefinition.h | 4 +- 9 files changed, 22 insertions(+), 118 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index d7ab81bd53..17c41b6145 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -664,7 +664,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar //-------------------------------------------------------------------------------------------------- cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimEclipseView& activeView) { - std::vector borderPolygonLocalCS = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit()); + std::vector borderPolygonLocalCS = m_rimFracture->fractureTemplate()->fractureBorderPolygon(); cvf::Mat4d frMx = m_rimFracture->transformMatrix(); cvf::BoundingBox frBBox; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 1a5d5eb2b6..56a27ac5cd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -112,38 +112,12 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha /// //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) + std::vector* triangleIndices) { RigEllipsisTesselator tesselator(20); - float a = cvf::UNDEFINED_FLOAT; - float b = cvf::UNDEFINED_FLOAT; - - if (neededUnit == fractureTemplateUnit()) - { - a = m_halfLength; - b = m_height / 2.0f; - - } - else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - RiaLogging::info(QString("Converting fracture template geometry from metric to field")); - a = RiaEclipseUnitTools::meterToFeet(m_halfLength); - b = RiaEclipseUnitTools::meterToFeet(m_height / 2.0f); - } - else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - RiaLogging::info(QString("Converting fracture template geometry from field to metric")); - a = RiaEclipseUnitTools::feetToMeter(m_halfLength); - b = RiaEclipseUnitTools::feetToMeter(m_height / 2.0f); - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture / fracture template")); - return; - } + float a = m_halfLength; + float b = m_height / 2.0f; tesselator.tesselateEllipsis(a, b, triangleIndices, nodeCoords); } @@ -151,14 +125,14 @@ void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector RimEllipseFractureTemplate::fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) +std::vector RimEllipseFractureTemplate::fractureBorderPolygon() { std::vector polygon; std::vector nodeCoords; std::vector triangleIndices; - fractureTriangleGeometry(&nodeCoords, &triangleIndices, neededUnit); + fractureTriangleGeometry(&nodeCoords, &triangleIndices); for (size_t i = 1; i < nodeCoords.size(); i++) { @@ -221,7 +195,7 @@ void RimEllipseFractureTemplate::setupFractureGridCells() double cond = conductivity(); - std::vector ellipseFracPolygon = fractureBorderPolygon(fractureTemplateUnit()); + std::vector ellipseFracPolygon = fractureBorderPolygon(); std::vector ellipseFracPolygonDouble; for (auto v : ellipseFracPolygon) ellipseFracPolygonDouble.push_back(static_cast(v)); std::vector >clippedFracturePolygons = RigCellGeometryTools::intersectPolygons(cellPolygon, ellipseFracPolygonDouble); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index f5563cbff1..dbac35ff64 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -49,9 +49,8 @@ class RimEllipseFractureTemplate : public RimFractureTemplate void loadDataAndUpdate(); void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* polygonIndices, - RiaEclipseUnitTools::UnitSystem neededUnit); - std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit); + std::vector* polygonIndices); + std::vector fractureBorderPolygon(); void changeUnits(); const RigFractureGrid* fractureGrid() const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 233fb8df6f..8de58d837d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -361,7 +361,7 @@ void RimFracture::triangleGeometry(std::vector* triangleIndices, std: RimFractureTemplate* fractureDef = fractureTemplate(); if (fractureDef) { - fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices, fractureUnit()); + fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices); } cvf::Mat4d m = transformMatrix(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index abe7bdb08e..b4cc9bac51 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -119,10 +119,9 @@ class RimFractureTemplate : public caf::PdmObject double perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); virtual void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + std::vector* triangleIndices) = 0; - virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + virtual std::vector fractureBorderPolygon() = 0; virtual const RigFractureGrid* fractureGrid() const = 0; const RimFractureContainment* fractureContainment(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 81c940b3bf..4eb076638d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -634,9 +634,11 @@ void RimStimPlanFractureTemplate::updateFractureGrid() if (m_stimPlanFractureDefinitionData.notNull()) { + QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit()); + m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_conductivityResultNameOnFile, m_activeTimeStepIndex, - fractureTemplateUnit(), + condUnit, m_wellPathDepthAtFracture); } } @@ -647,8 +649,7 @@ void RimStimPlanFractureTemplate::updateFractureGrid() /// //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) + std::vector* triangleIndices) { if (m_stimPlanFractureDefinitionData.isNull()) @@ -658,7 +659,6 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vectorcreateFractureTriangleGeometry(m_wellPathDepthAtFracture, - neededUnit, name(), nodeCoords, triangleIndices); @@ -668,7 +668,7 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) +std::vector RimStimPlanFractureTemplate::fractureBorderPolygon() { if (m_stimPlanFractureDefinitionData.isNull()) return std::vector(); @@ -681,7 +681,6 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEc parameterUnit, m_activeTimeStepIndex, m_wellPathDepthAtFracture, - neededUnit, name()); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index c3687f4713..817519984f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -69,9 +69,8 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate const RigFractureGrid* fractureGrid() const override; void updateFractureGrid(); void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) override; - std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) override; + std::vector* triangleIndices) override; + std::vector fractureBorderPolygon() override; // Result Access diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 3d3c05cffe..9accb428d6 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -256,7 +256,7 @@ std::vector > RigStimPlanFractureDefinition::getStim //-------------------------------------------------------------------------------------------------- cvf::ref RigStimPlanFractureDefinition::createFractureGrid(const QString& resultName, int activeTimeStepIndex, - RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, + const QString& conductivityUnitText, double wellPathIntersectionAtFractureDepth) { std::vector stimPlanCells; @@ -264,10 +264,8 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons bool wellCenterStimPlanCellFound = false; - QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit); - std::vector> conductivityValuesAtTimeStep = this->getDataAtTimeIndex(resultName, - condUnit, + conductivityUnitText, activeTimeStepIndex); std::vector yCoordsAtNodes = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); @@ -365,7 +363,6 @@ std::vector RigStimPlanFractureDefinition::fractureGridResults(const QSt /// //-------------------------------------------------------------------------------------------------- void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName, std::vector* vertices, std::vector* triangleIndices) @@ -375,30 +372,6 @@ void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double wellPa std::vector adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); - if ( neededUnit == m_unitSet ) - { - RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName)); - } - - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD ) - { - RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedYs ) value = RiaEclipseUnitTools::meterToFeet(value); - for ( double& value : xCoords ) value = RiaEclipseUnitTools::meterToFeet(value); - } - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC ) - { - RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedYs ) value = RiaEclipseUnitTools::feetToMeter(value); - for ( double& value : xCoords ) value = RiaEclipseUnitTools::feetToMeter(value); - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName)); - return; - } - for ( cvf::uint k = 0; k < adjustedYs.size(); k++ ) { for ( cvf::uint i = 0; i < lenXcoords; i++ ) @@ -431,7 +404,6 @@ void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double wellPa triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords); triangleIndices->push_back((i)+ (k + 1)*lenXcoords); } - } } } @@ -474,7 +446,6 @@ std::vector RigStimPlanFractureDefinition::createFractureBorderPolyg const QString& resultUnit, int activeTimeStepIndex, double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName) { std::vector polygon; @@ -526,41 +497,6 @@ std::vector RigStimPlanFractureDefinition::createFractureBorderPolyg //Adding first point last - to close the polygon if ( polygon.size()>0 ) polygon.push_back(polygon[0]); - - if ( neededUnit == m_unitSet ) - { - RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName)); - } - - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD ) - { - RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName)); - for ( cvf::Vec3f& node : polygon ) - { - float x = RiaEclipseUnitTools::meterToFeet(node.x()); - float y = RiaEclipseUnitTools::meterToFeet(node.y()); - float z = RiaEclipseUnitTools::meterToFeet(node.z()); - node = cvf::Vec3f(x, y, z); - } - } - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC ) - { - RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName)); - for ( cvf::Vec3f& node : polygon ) - { - float x = RiaEclipseUnitTools::feetToMeter(node.x()); - float y = RiaEclipseUnitTools::feetToMeter(node.y()); - float z = RiaEclipseUnitTools::feetToMeter(node.z()); - node = cvf::Vec3f(x, y, z); - } - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName)); - } - - return polygon; } diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 0d89a72532..b496548b45 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -73,11 +73,10 @@ class RigStimPlanFractureDefinition: public cvf::Object cvf::ref createFractureGrid(const QString& resultName, int activeTimeStepIndex, - RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, + const QString& conductivityUnitText, double wellPathIntersectionAtFractureDepth); void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName, std::vector* vertices, std::vector* triangleIndices); @@ -86,7 +85,6 @@ class RigStimPlanFractureDefinition: public cvf::Object const QString& resultUnit, int activeTimeStepIndex, double wellPathIntersectionAtFractureDepth, - RiaEclipseUnitTools::UnitSystem neededUnit, const QString& fractureUserName); const std::vector& timeSteps() const; From f67918eba380ab3531bb5dbdd271e99a00fa7bf2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 08:36:18 +0100 Subject: [PATCH 0314/1027] #2509 Fracture : Improve UI --- .../Completions/RimFracture.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 8de58d837d..d5f08dc75e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -208,7 +208,10 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); - m_fractureTemplate = nullptr; + PdmObjectHandle* prevValue = oldValue.value>().rawPtr(); + auto prevTemplate = dynamic_cast(prevValue); + + m_fractureTemplate = prevTemplate; } setFractureTemplate(m_fractureTemplate); @@ -398,17 +401,23 @@ QList RimFracture::calculateValueOptions(const caf::PdmF RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - RimOilField* oilField = proj->activeOilField(); - if (oilField == nullptr) return options; - if (fieldNeedingOptions == &m_fractureTemplate) { - RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); - if (fracDefColl == nullptr) return options; - - for (RimFractureTemplate* fracDef : fracDefColl->fractureDefinitions()) + RimOilField* oilField = proj->activeOilField(); + if (oilField && oilField->fractureDefinitionCollection) { - options.push_back(caf::PdmOptionItemInfo(fracDef->nameAndUnit(), fracDef)); + RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); + + for (RimFractureTemplate* fracDef : fracDefColl->fractureDefinitions()) + { + QString displayText = fracDef->nameAndUnit(); + if (fracDef->fractureTemplateUnit() != fractureUnit()) + { + displayText += " (non-matching unit)"; + } + + options.push_back(caf::PdmOptionItemInfo(displayText, fracDef)); + } } } else if (fieldNeedingOptions == &m_stimPlanTimeIndexToPlot) From 28ab07b1995d62dc78ba377e7e2ef17743c69292 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 09:10:08 +0100 Subject: [PATCH 0315/1027] #2509 Fracture : Remove obsolete unit conversion --- .../RicExportFractureCompletionsImpl.cpp | 4 +- .../RigWellPathStimplanIntersector.cpp | 2 +- .../Completions/RimFracture.cpp | 25 +++--------- .../Completions/RimFracture.h | 2 +- .../Completions/RimFractureTemplate.cpp | 38 ++----------------- .../Completions/RimFractureTemplate.h | 4 +- 6 files changed, 16 insertions(+), 59 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 8e3384a2a1..a785662e44 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -290,7 +290,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat double radialTrans = RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(wellCell.getConductivtyValue(), wellCell.cellSizeX(), wellCell.cellSizeZ(), - fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()), + fracture->wellRadius(), fracTemplate->skinFactor(), cDarcyInCorrectUnit); @@ -354,7 +354,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid()), fracture->fractureMD()); - double diameter = 2.0 * fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()); + double diameter = 2.0 * fracture->wellRadius(); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor(), diameter); compDat.addMetadata(fracture->name(), QString::number(trans)); allCompletionsForOneFracture.push_back(compDat); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp b/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp index f58a771c22..78c39ad3a2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp @@ -42,7 +42,7 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath { std::vector wellPathPoints = wellpathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(rimFracture->fractureMD()); cvf::Mat4d fractureXf = rimFracture->transformMatrix(); - double wellRadius = rimFracture->wellRadius(rimFracture->fractureUnit()); + double wellRadius = rimFracture->wellRadius(); std::vector > stpCellPolygons; { RimFractureTemplate* fractureTemplate = rimFracture->fractureTemplate(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index d5f08dc75e..bdc3ab8802 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -295,30 +295,17 @@ cvf::BoundingBox RimFracture::boundingBoxInDomainCoords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFracture::wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const +double RimFracture::wellRadius() const { if (m_fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { - if (unitSystem == RiaEclipseUnitTools::UNITS_FIELD) - { - return RiaEclipseUnitTools::meterToFeet(m_wellDiameter / 2); - } - else - { - return m_wellDiameter / 2; - } + return m_wellDiameter / 2; } else if (m_fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { - if (unitSystem == RiaEclipseUnitTools::UNITS_METRIC) - { - return RiaEclipseUnitTools::inchToMeter(m_wellDiameter / 2); - } - else - { - return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2); - } + return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2); } + return cvf::UNDEFINED_DOUBLE; } @@ -657,8 +644,8 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) { this->updateAzimuthBasedOnWellAzimuthAngle(); } - this->m_wellDiameter = fractureTemplate->wellDiameterInFractureUnit(m_fractureUnit()); - this->m_perforationLength = fractureTemplate->perforationLengthInFractureUnit(m_fractureUnit()); + this->m_wellDiameter = fractureTemplate->wellDiameterInFractureUnit(); + this->m_perforationLength = fractureTemplate->perforationLengthInFractureUnit(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index d1513ca7bc..b08a6137ed 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -60,7 +60,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf void setStimPlanTimeIndexToPlot(int timeIndex); - double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; + double wellRadius() const; cvf::Vec3d anchorPosition() const ; void setAnchorPosition(const cvf::Vec3d& pos); RiaEclipseUnitTools::UnitSystem fractureUnit() const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 1edfe8c27f..c4f771b686 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -602,47 +602,17 @@ QString RimFractureTemplate::nameAndUnit() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) +double RimFractureTemplate::wellDiameterInFractureUnit() { - if (fractureUnit == m_fractureTemplateUnit()) - { - return m_wellDiameter; - } - else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC - && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - return RiaEclipseUnitTools::meterToInch(m_wellDiameter); - } - else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD - && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - return RiaEclipseUnitTools::inchToMeter(m_wellDiameter); - } - - return cvf::UNDEFINED_DOUBLE; + return m_wellDiameter; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) +double RimFractureTemplate::perforationLengthInFractureUnit() { - if (fractureUnit == m_fractureTemplateUnit()) - { - return m_perforationLength; - } - else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC - && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - return RiaEclipseUnitTools::meterToFeet(m_perforationLength); - } - else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD - && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - return RiaEclipseUnitTools::feetToMeter(m_perforationLength); - } - - return cvf::UNDEFINED_DOUBLE; + return m_perforationLength; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index b4cc9bac51..971a8698ef 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -114,9 +114,9 @@ class RimFractureTemplate : public caf::PdmObject FracOrientationEnum orientationType() const; float azimuthAngle() const; float skinFactor() const; - double wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); + double wellDiameterInFractureUnit(); FracConductivityEnum conductivityType() const; - double perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); + double perforationLengthInFractureUnit(); virtual void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* triangleIndices) = 0; From 0d7e4f460ce945a989ffa3e909f2e2d127315d4b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 09:10:40 +0100 Subject: [PATCH 0316/1027] #2509 Fracture : Find matching template when adding new fracture --- .../RicNewSimWellFractureAtPosFeature.cpp | 15 +++++++++------ .../Commands/RicNewSimWellFractureFeature.cpp | 14 ++++++++------ .../Commands/RicNewWellPathFractureFeature.cpp | 10 +++++----- .../Completions/RimFracture.cpp | 17 +++++++++++++++-- .../RimFractureTemplateCollection.cpp | 16 ++++++++++++++++ .../Completions/RimFractureTemplateCollection.h | 2 ++ 6 files changed, 55 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp index a7dca470f9..a0ce60165e 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp @@ -93,17 +93,20 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) fracture->setName(QString("Fracture_") + fracNum); + auto unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; { RimEclipseResultCase* eclipseCase = nullptr; simWell->firstAncestorOrThisOfType(eclipseCase); - fracture->setFractureUnit(eclipseCase->eclipseCaseData()->unitsType()); - } + if (eclipseCase) + { + unitSet = eclipseCase->eclipseCaseData()->unitsType(); + } - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); + fracture->setFractureUnit(unitSet); } + + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); simWell->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(fracture); diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp index d9b0dd9362..052249ffcf 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp @@ -81,17 +81,19 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) fracture->setName(RicFractureNameGenerator::nameForNewFracture()); + auto unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; { RimEclipseResultCase* eclipseCase = nullptr; objHandle->firstAncestorOrThisOfType(eclipseCase); - fracture->setFractureUnit(eclipseCase->eclipseCaseData()->unitsType()); + if (eclipseCase) + { + unitSet = eclipseCase->eclipseCaseData()->unitsType(); + } + fracture->setFractureUnit(unitSet); } - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); - } + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); fracture->updateFracturePositionFromLocation(); diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp index 30a4c3c4ad..50d1767393 100644 --- a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp @@ -86,11 +86,11 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me fracture->setName(RicFractureNameGenerator::nameForNewFracture()); - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); - } + auto unitSet = wellPath->unitSystem(); + fracture->setFractureUnit(unitSet); + + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); wellPath->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(fracture); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index bdc3ab8802..3d0fdd5888 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -202,7 +202,7 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons { QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); - QString warningText = QString("Using a fracture template of different unit is not supported.\n\nPlease select a " + QString warningText = QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " "fracture template of unit '%1'") .arg(fractureUnitText); @@ -240,7 +240,6 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons proj->reloadCompletionTypeResultsInAllViews(); } } - } //-------------------------------------------------------------------------------------------------- @@ -623,6 +622,20 @@ size_t RimFracture::findAnchorEclipseCell(const RigMainGrid* mainGrid ) const //-------------------------------------------------------------------------------------------------- void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) { + if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit()) + { + QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); + + QString warningText = + QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " + "fracture template of unit '%1'") + .arg(fractureUnitText); + + QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); + + return; + } + m_fractureTemplate = fractureTemplate; if (!fractureTemplate) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index c3a87c0caf..05c4fe4aa0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -66,6 +66,22 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection() fractureDefinitions.deleteAllChildObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate* RimFractureTemplateCollection::firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const +{ + for (RimFractureTemplate* f : fractureDefinitions()) + { + if (f->fractureTemplateUnit() == unitSet) + { + return f; + } + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index b1116ccbbd..876817c762 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -37,6 +37,8 @@ class RimFractureTemplateCollection : public caf::PdmObject public: RimFractureTemplateCollection(void); virtual ~RimFractureTemplateCollection(void); + + RimFractureTemplate* firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const; caf::PdmChildArrayField fractureDefinitions; caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; From 0acab5cd65fb21c8eec4ae3d6ca2312ef7592905 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 09:50:50 +0100 Subject: [PATCH 0317/1027] #2509 Fracture : Add copy / paste of StimPlan --- .../FractureCommands/CMakeLists_files.cmake | 2 + .../RicPasteStimPlanFractureFeature.cpp | 111 ++++++++++++++++++ .../RicPasteStimPlanFractureFeature.h | 44 +++++++ .../RicNewEllipseFractureTemplateFeature.cpp | 6 +- .../RicNewEllipseFractureTemplateFeature.h | 16 ++- .../RimEllipseFractureTemplate.cpp | 16 +-- .../Completions/RimEllipseFractureTemplate.h | 2 +- .../Completions/RimFractureTemplate.cpp | 19 +++ .../Completions/RimFractureTemplate.h | 4 +- .../RimStimPlanFractureTemplate.cpp | 24 +++- .../Completions/RimStimPlanFractureTemplate.h | 2 +- .../RimContextCommandBuilder.cpp | 5 +- 12 files changed, 220 insertions(+), 31 deletions(-) create mode 100644 ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp create mode 100644 ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake index f37d5560c7..09f0370190 100644 --- a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -6,10 +6,12 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp new file mode 100644 index 0000000000..dbe86bc0ab --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteStimPlanFractureFeature.h" + +#include "../OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "RimFractureTemplateCollection.h" +#include "RimStimPlanFractureTemplate.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicPasteStimPlanFractureFeature, "RicPasteStimPlanFractureFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteStimPlanFractureFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + if (typedObjects.size() == 0) + { + return false; + } + + if (fractureTemplateCollection()) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteStimPlanFractureFeature::onActionTriggered(bool isChecked) +{ + auto fractureTemplateColl = fractureTemplateCollection(); + if (!fractureTemplateColl) return; + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + for (const auto& source : typedObjects) + { + auto copyOfStimPlanTemplate = dynamic_cast( + source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateColl->fractureDefinitions.push_back(copyOfStimPlanTemplate); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, copyOfStimPlanTemplate); + } + + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteStimPlanFractureFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (StimPlan Fracture)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplateCollection* RicPasteStimPlanFractureFeature::fractureTemplateCollection() +{ + RimFractureTemplateCollection* fractureTemplateColl = nullptr; + + auto destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (destinationObject) + { + destinationObject->firstAncestorOrThisOfType(fractureTemplateColl); + } + + return fractureTemplateColl; +} diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h new file mode 100644 index 0000000000..982b51ec21 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimFractureTemplateCollection; + +namespace caf +{ +class PdmObjectGroup; +} + +//================================================================================================== +/// +//================================================================================================== +class RicPasteStimPlanFractureFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimFractureTemplateCollection* fractureTemplateCollection(); +}; diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp index b9d0c921b7..282c5be805 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp @@ -40,9 +40,9 @@ CAF_CMD_SOURCE_INIT(RicNewEllipseFractureTemplateFeature, "RicNewEllipseFracture /// //-------------------------------------------------------------------------------------------------- void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, - RimEllipseFractureTemplate* ellipseFractureTemplate) + RimFractureTemplate* fractureTemplate) { - ellipseFractureTemplate->loadDataAndUpdate(); + fractureTemplate->loadDataAndUpdate(); templateCollection->updateConnectedEditors(); @@ -59,7 +59,7 @@ void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFr } } - RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate); + RiuMainWindow::instance()->selectAsCurrentItem(fractureTemplate); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h index 23d1a8d774..e6a45aa955 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h +++ b/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -22,11 +22,11 @@ #include -class RimEllipseFractureTemplate; +class RimFractureTemplate; class RimFractureTemplateCollection; //================================================================================================== -/// +/// //================================================================================================== class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature { @@ -34,12 +34,10 @@ class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature public: static void selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, - RimEllipseFractureTemplate* ellipseFractureTemplate); + RimFractureTemplate* ellipseFractureTemplate); protected: virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; virtual bool isCommandEnabled() override; - - }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 56a27ac5cd..588973d454 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -324,30 +324,20 @@ std::vector> RimEllipseFractureTemplate::uiResultNam //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) { - if (neededUnit == fractureTemplateUnit()) - { - return; - } + setFractureTemplateUnit(neededUnit); + RimFractureTemplate::convertToUnitSystem(neededUnit); if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); m_height = RiaEclipseUnitTools::meterToFeet(m_height); m_width = RiaEclipseUnitTools::meterToInch(m_width); - m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); - m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); - - setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_FIELD); } else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); m_height = RiaEclipseUnitTools::feetToMeter(m_height); m_width = RiaEclipseUnitTools::inchToMeter(m_width); - m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); - m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); - - setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_METRIC); } } @@ -362,14 +352,12 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm m_halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); m_height.uiCapability()->setUiName("Height [m]"); m_width.uiCapability()->setUiName("Width [m]"); - m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); } else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); m_height.uiCapability()->setUiName("Height [Ft]"); m_width.uiCapability()->setUiName("Width [inches]"); - m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); } if (conductivityType() == FINITE_CONDUCTIVITY) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index dbac35ff64..f5c0aac0bc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -46,7 +46,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate RimEllipseFractureTemplate(void); virtual ~RimEllipseFractureTemplate(void); - void loadDataAndUpdate(); + void loadDataAndUpdate() override; void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* polygonIndices); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index c4f771b686..e9a8df40b2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -563,6 +563,25 @@ double RimFractureTemplate::kh() const return effectivePermeability() * fractureWidth(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); + m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); + } + else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); + m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); + } + + // TODO : Convert NON-darcy values +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 971a8698ef..13c578ffff 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -140,7 +140,9 @@ class RimFractureTemplate : public caf::PdmObject double dFactor() const; double kh() const; - virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit); + + virtual void loadDataAndUpdate() = 0; protected: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 4eb076638d..1a707785dd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -502,10 +502,32 @@ bool RimStimPlanFractureTemplate::showStimPlanMesh() const void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) { setFractureTemplateUnit(neededUnit); + RimFractureTemplate::convertToUnitSystem(neededUnit); m_readError = false; loadDataAndUpdate(); - setDefaultsBasedOnXMLfile(); + + if (m_stimPlanFractureDefinitionData.isNull()) return; + + if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + m_wellPathDepthAtFracture = RiaEclipseUnitTools::meterToFeet(m_wellPathDepthAtFracture); + } + else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_wellPathDepthAtFracture = RiaEclipseUnitTools::feetToMeter(m_wellPathDepthAtFracture); + } + + m_activeTimeStepIndex = static_cast(m_stimPlanFractureDefinitionData->totalNumberTimeSteps() - 1); + bool polygonPropertySet = setBorderPolygonResultNameToDefault(); + + if (polygonPropertySet) RiaLogging::info(QString("Calculating polygon outline based on %1 at timestep %2").arg(m_borderPolygonResultName).arg(m_stimPlanFractureDefinitionData->timeSteps()[m_activeTimeStepIndex])); + else RiaLogging::info(QString("Property for polygon calculation not set.")); + + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 817519984f..79a290f43e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -54,7 +54,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate int activeTimeStepIndex(); - void loadDataAndUpdate(); + void loadDataAndUpdate() override; void setDefaultsBasedOnXMLfile(); void setFileName(const QString& fileName); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index ee5bfe04da..f13c7c2c4a 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -533,6 +533,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder << "RicPasteStimPlanFractureFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; @@ -542,7 +543,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { - //menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder << "RicPasteStimPlanFractureFeature"; + menuBuilder << "RicPasteEllipseFractureFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; @@ -552,6 +554,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder << "RicPasteStimPlanFractureFeature"; menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; From 81bb4481ed8a7186095cf2e7840e1b435c7ea1a6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 10:10:22 +0100 Subject: [PATCH 0318/1027] #2509 Fracture : Rename --- .../ProjectDataModel/Completions/RimFracture.cpp | 8 ++++---- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 4 ++-- .../ProjectDataModel/Completions/RimFractureTemplate.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 3d0fdd5888..ffa5bff6ed 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -298,11 +298,11 @@ double RimFracture::wellRadius() const { if (m_fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { - return m_wellDiameter / 2; + return m_wellDiameter / 2.0; } else if (m_fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2); + return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2.0); } return cvf::UNDEFINED_DOUBLE; @@ -657,8 +657,8 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) { this->updateAzimuthBasedOnWellAzimuthAngle(); } - this->m_wellDiameter = fractureTemplate->wellDiameterInFractureUnit(); - this->m_perforationLength = fractureTemplate->perforationLengthInFractureUnit(); + this->m_wellDiameter = fractureTemplate->wellDiameter(); + this->m_perforationLength = fractureTemplate->perforationLength(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index e9a8df40b2..b99f6908fe 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -621,7 +621,7 @@ QString RimFractureTemplate::nameAndUnit() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::wellDiameterInFractureUnit() +double RimFractureTemplate::wellDiameter() { return m_wellDiameter; } @@ -629,7 +629,7 @@ double RimFractureTemplate::wellDiameterInFractureUnit() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::perforationLengthInFractureUnit() +double RimFractureTemplate::perforationLength() { return m_perforationLength; } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 13c578ffff..8ab1a5ce8d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -114,12 +114,12 @@ class RimFractureTemplate : public caf::PdmObject FracOrientationEnum orientationType() const; float azimuthAngle() const; float skinFactor() const; - double wellDiameterInFractureUnit(); + double wellDiameter(); FracConductivityEnum conductivityType() const; - double perforationLengthInFractureUnit(); + double perforationLength(); - virtual void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices) = 0; + virtual void fractureTriangleGeometry(std::vector* nodeCoords, + std::vector* triangleIndices) = 0; virtual std::vector fractureBorderPolygon() = 0; virtual const RigFractureGrid* fractureGrid() const = 0; From ad97b19c3052c4e7f4088eb28b56fa928d33ce84 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 10:41:11 +0100 Subject: [PATCH 0319/1027] #2509 Fracture : Exclude files when fracture config is not active --- ApplicationCode/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index be308f89bb..ade87f19a1 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -124,7 +124,6 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake Commands/ExportCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake - Commands/FractureCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake Commands/IntersectionViewCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake @@ -139,6 +138,13 @@ list( APPEND REFERENCED_CMAKE_FILES CommandFileInterface/Core/CMakeLists_files.cmake ) +if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) + list (APPEND REFERENCED_CMAKE_FILES + Commands/FractureCommands/CMakeLists_files.cmake + ) +endif() + + option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF) if (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS) add_definitions(-DUSE_UNIT_TESTS) From 1b7dabdc515ba46ec630c70abf0a7bc2b59cd07b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 13:06:03 +0100 Subject: [PATCH 0320/1027] #2291 Fishbones : Use 6 decimals, as this is required when using MD above 1000 --- .../Completions/RimFishbonesMultipleSubs.cpp | 18 ------------------ .../Completions/RimFishbonesMultipleSubs.h | 2 -- 2 files changed, 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp index a0935ebd4f..fecd6ff775 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp @@ -462,24 +462,6 @@ caf::PdmFieldHandle* RimFishbonesMultipleSubs::objectToggleField() return &m_isActive; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFishbonesMultipleSubs::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) -{ - if (field == &m_rangeStart || - field == &m_rangeEnd || - field == &m_rangeSubSpacing) - { - caf::PdmUiDoubleValueEditorAttribute* attr = dynamic_cast(attribute); - - if (attr) - { - attr->m_decimals = 2; - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h index 75dc7d472c..0fc81fb520 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h @@ -110,8 +110,6 @@ class RimFishbonesMultipleSubs : public caf::PdmObject, public Rim3dPropertiesIn virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, - caf::PdmUiEditorAttribute* attribute) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; From 8ad30d9350bac21bb0f00000b04a519806981b09 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 19:07:03 +0100 Subject: [PATCH 0321/1027] #2509 Fracture : Disconnect fracture template when unit changes --- ...vertAllFractureTemplatesToFieldFeature.cpp | 2 ++ ...ertAllFractureTemplatesToMetricFeature.cpp | 2 ++ .../RicConvertFractureTemplateUnitFeature.cpp | 2 ++ .../RimEllipseFractureTemplate.cpp | 2 ++ .../Completions/RimFractureTemplate.cpp | 28 +++++++++++++++++++ .../Completions/RimFractureTemplate.h | 2 ++ .../RimStimPlanFractureTemplate.cpp | 2 ++ 7 files changed, 40 insertions(+) diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp index de93e781f1..3b282b9378 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp @@ -66,6 +66,8 @@ void RicConvertAllFractureTemplatesToFieldFeature::onActionTriggered(bool isChec if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { ellipseFracTemplate->changeUnits(); + + ellipseFracTemplate->disconnectAllFracturesAndRedrawViews(); } } } diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp index 78627f2e54..6390b1140c 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp +++ b/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp @@ -66,6 +66,8 @@ void RicConvertAllFractureTemplatesToMetricFeature::onActionTriggered(bool isChe if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { ellipseFracTemplate->changeUnits(); + + ellipseFracTemplate->disconnectAllFracturesAndRedrawViews(); } } diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp index 0b7eb50294..a86b82d747 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp @@ -68,6 +68,8 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) fractureTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); } + fractureTemplate->disconnectAllFracturesAndRedrawViews(); + fractureTemplate->updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 588973d454..0d007a77fa 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -324,6 +324,8 @@ std::vector> RimEllipseFractureTemplate::uiResultNam //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) { + if (m_fractureTemplateUnit() == neededUnit) return; + setFractureTemplateUnit(neededUnit); RimFractureTemplate::convertToUnitSystem(neededUnit); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index b99f6908fe..5f434ba49b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -582,6 +582,34 @@ void RimFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem ne // TODO : Convert NON-darcy values } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::disconnectAllFracturesAndRedrawViews() const +{ + // The unit has changed. Disconnect all fractures referencing this fracture template to avoid mix of units between fracture + // and template + + std::vector referringObjects; + this->objectsWithReferringPtrFields(referringObjects); + + for (auto objHandle : referringObjects) + { + RimFracture* fracture = dynamic_cast(objHandle); + if (fracture) + { + fracture->setFractureTemplate(nullptr); + } + } + + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 8ab1a5ce8d..820907d693 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -144,6 +144,8 @@ class RimFractureTemplate : public caf::PdmObject virtual void loadDataAndUpdate() = 0; + void disconnectAllFracturesAndRedrawViews() const; + protected: virtual caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 1a707785dd..82d8370028 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -501,6 +501,8 @@ bool RimStimPlanFractureTemplate::showStimPlanMesh() const //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) { + if (m_fractureTemplateUnit() == neededUnit) return; + setFractureTemplateUnit(neededUnit); RimFractureTemplate::convertToUnitSystem(neededUnit); From 69339ad141eb0de94385fa15178b6df894cef286 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 19:25:05 +0100 Subject: [PATCH 0322/1027] #2507 Non-Dracy Flow : Add display of unit and handle unit conversion --- .../Completions/RimEllipseFractureTemplate.cpp | 4 ++-- .../ProjectDataModel/Completions/RimFracture.cpp | 2 +- .../Completions/RimFractureTemplate.cpp | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 0d007a77fa..cd9137ae5c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -357,8 +357,8 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm } else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - m_halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); - m_height.uiCapability()->setUiName("Height [Ft]"); + m_halfLength.uiCapability()->setUiName("Halflenght Xf [ft]"); + m_height.uiCapability()->setUiName("Height [ft]"); m_width.uiCapability()->setUiName("Width [inches]"); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index ffa5bff6ed..75567588a8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -442,7 +442,7 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO else if (m_fractureUnit() == RiaEclipseUnitTools::UNITS_FIELD) { m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - m_perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [ft]"); } if (fractureTemplate()) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 5f434ba49b..bd669e735f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -138,7 +138,7 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability (Ke) [mD]", "", "", ""); CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density (γ)", "", "Relative density of gas at surface conditions with respect to air at STP", ""); - CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ)", "", "Gas viscosity at bottom hole pressure", ""); + CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ) [cP]", "", "Gas viscosity at bottom hole pressure", ""); CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::dFactor); @@ -399,11 +399,13 @@ void RimFractureTemplate::prepareFieldsForUiDisplay() { m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + m_fractureWidth.uiCapability()->setUiName("Fracture Width [m]"); } else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - m_perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [ft]"); + m_fractureWidth.uiCapability()->setUiName("Fracture Width [ft]"); } if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH @@ -572,14 +574,14 @@ void RimFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem ne { m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); + m_fractureWidth = RiaEclipseUnitTools::feetToMeter(m_fractureWidth); } else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); + m_fractureWidth = RiaEclipseUnitTools::meterToFeet(m_fractureWidth); } - - // TODO : Convert NON-darcy values } //-------------------------------------------------------------------------------------------------- From c22f38e30ce0d0f34572d43e54ad8e386c93dd2d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 19:38:20 +0100 Subject: [PATCH 0323/1027] #2509 Fracture : Move fracture commands to separate folder --- .../Commands/CMakeLists_files.cmake | 32 ------------------- .../FractureCommands/CMakeLists_files.cmake | 21 ++++++++++++ ...vertAllFractureTemplatesToFieldFeature.cpp | 0 ...onvertAllFractureTemplatesToFieldFeature.h | 0 ...ertAllFractureTemplatesToMetricFeature.cpp | 0 ...nvertAllFractureTemplatesToMetricFeature.h | 0 .../RicConvertFractureTemplateUnitFeature.cpp | 0 .../RicConvertFractureTemplateUnitFeature.h | 0 .../RicFractureNameGenerator.cpp | 0 .../RicFractureNameGenerator.h | 0 .../RicNewEllipseFractureTemplateFeature.cpp | 0 .../RicNewEllipseFractureTemplateFeature.h | 0 .../RicNewSimWellFractureAtPosFeature.cpp | 0 .../RicNewSimWellFractureAtPosFeature.h | 0 .../RicNewSimWellFractureFeature.cpp | 0 .../RicNewSimWellFractureFeature.h | 0 .../RicNewStimPlanFractureTemplateFeature.cpp | 0 .../RicNewStimPlanFractureTemplateFeature.h | 0 .../RicNewWellPathFractureAtPosFeature.cpp | 0 .../RicNewWellPathFractureAtPosFeature.h | 0 .../RicNewWellPathFractureFeature.cpp | 0 .../RicNewWellPathFractureFeature.h | 0 .../RicPasteEllipseFractureFeature.cpp | 2 +- .../RicPasteStimPlanFractureFeature.cpp | 2 +- 24 files changed, 23 insertions(+), 34 deletions(-) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertAllFractureTemplatesToFieldFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertAllFractureTemplatesToFieldFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertAllFractureTemplatesToMetricFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertAllFractureTemplatesToMetricFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertFractureTemplateUnitFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicConvertFractureTemplateUnitFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicFractureNameGenerator.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicFractureNameGenerator.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewEllipseFractureTemplateFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewEllipseFractureTemplateFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewSimWellFractureAtPosFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewSimWellFractureAtPosFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewSimWellFractureFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewSimWellFractureFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewStimPlanFractureTemplateFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewStimPlanFractureTemplateFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewWellPathFractureAtPosFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewWellPathFractureAtPosFeature.h (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewWellPathFractureFeature.cpp (100%) rename ApplicationCode/Commands/{ => FractureCommands}/RicNewWellPathFractureFeature.h (100%) diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index f5b964cd48..c04f095692 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -72,22 +72,6 @@ ${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.h ${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.h - ${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicWellLogTools.cpp @@ -152,22 +136,6 @@ ${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake index 09f0370190..c5bd8935db 100644 --- a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -7,13 +7,34 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.h +${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.h +${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.h +${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.h +${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.h +${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.h +${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h +${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h +${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.h +${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.h +${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.cpp +${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.cpp +${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.cpp +${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.cpp +${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.cpp +${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.cpp +${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.cpp ) + list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.cpp diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.h b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.h similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.h rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.h diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.cpp diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.h b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.h similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.h rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.h diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.h b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.h similarity index 100% rename from ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.h rename to ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.h diff --git a/ApplicationCode/Commands/RicFractureNameGenerator.cpp b/ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.cpp similarity index 100% rename from ApplicationCode/Commands/RicFractureNameGenerator.cpp rename to ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.cpp diff --git a/ApplicationCode/Commands/RicFractureNameGenerator.h b/ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.h similarity index 100% rename from ApplicationCode/Commands/RicFractureNameGenerator.h rename to ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.h diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.h diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.h diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.h diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h diff --git a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.cpp diff --git a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.h diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp index d88cc41386..37a40d703f 100644 --- a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp @@ -18,7 +18,7 @@ #include "RicPasteEllipseFractureFeature.h" -#include "../OperationsUsingObjReferences/RicPasteFeatureImpl.h" +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" #include "RicNewEllipseFractureTemplateFeature.h" diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp index dbe86bc0ab..a5e03ea2d1 100644 --- a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp @@ -18,7 +18,7 @@ #include "RicPasteStimPlanFractureFeature.h" -#include "../OperationsUsingObjReferences/RicPasteFeatureImpl.h" +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" #include "RicNewEllipseFractureTemplateFeature.h" From 594be9388340d74b5548a1f03e42cb8cf0c934c0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Feb 2018 19:53:22 +0100 Subject: [PATCH 0324/1027] Whitespace cleanup --- .../Completions/RimEllipseFractureTemplate.h | 45 +++++++++---------- .../Completions/RimFractureTemplate.cpp | 27 +++++------ .../Completions/RimFractureTemplate.h | 3 -- .../RimStimPlanFractureTemplate.cpp | 12 ++--- .../Completions/RimStimPlanFractureTemplate.h | 10 ++--- 5 files changed, 44 insertions(+), 53 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index f5c0aac0bc..1166429c43 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -43,40 +43,37 @@ class RimEllipseFractureTemplate : public RimFractureTemplate CAF_PDM_HEADER_INIT; public: - RimEllipseFractureTemplate(void); - virtual ~RimEllipseFractureTemplate(void); - - void loadDataAndUpdate() override; - - void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* polygonIndices); - std::vector fractureBorderPolygon(); - void changeUnits(); - - const RigFractureGrid* fractureGrid() const; + RimEllipseFractureTemplate(); + virtual ~RimEllipseFractureTemplate(); - void setDefaultValuesFromUnit(); - double conductivity() const; + void fractureTriangleGeometry(std::vector* nodeCoords, + std::vector* polygonIndices) override; - virtual void appendDataToResultStatistics(const QString& uiResultName, const QString& unit, - MinMaxAccumulator& minMaxAccumulator, - PosNegAccumulator& posNegAccumulator) const override; - - - virtual std::vector> uiResultNamesWithUnit() const override; + std::vector fractureBorderPolygon() override; + void changeUnits(); + const RigFractureGrid* fractureGrid() const override; + void setDefaultValuesFromUnit(); + double conductivity() const; + + void appendDataToResultStatistics(const QString& uiResultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; + void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; - virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + void loadDataAndUpdate() override; + std::vector> uiResultNamesWithUnit() const override; protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: - void setupFractureGridCells(); + void setupFractureGridCells(); - virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; + FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; private: cvf::ref m_fractureGrid; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index bd669e735f..2a767abdb9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -39,9 +39,9 @@ namespace caf template<> void caf::AppEnum< RimFractureTemplate::FracOrientationEnum>::setUp() { - addItem(RimFractureTemplate::AZIMUTH, "Az", "Azimuth"); - addItem(RimFractureTemplate::ALONG_WELL_PATH, "AlongWellPath", "Along Well Path"); - addItem(RimFractureTemplate::TRANSVERSE_WELL_PATH, "TransverseWellPath", "Transverse (normal) to Well Path"); + addItem(RimFractureTemplate::AZIMUTH, "Az", "Azimuth"); + addItem(RimFractureTemplate::ALONG_WELL_PATH, "AlongWellPath", "Along Well Path"); + addItem(RimFractureTemplate::TRANSVERSE_WELL_PATH, "TransverseWellPath", "Transverse (normal) to Well Path"); setDefault(RimFractureTemplate::TRANSVERSE_WELL_PATH); } @@ -50,7 +50,7 @@ namespace caf void caf::AppEnum< RimFractureTemplate::FracConductivityEnum>::setUp() { addItem(RimFractureTemplate::INFINITE_CONDUCTIVITY, "InfiniteConductivity", "Infinite Conductivity"); - addItem(RimFractureTemplate::FINITE_CONDUCTIVITY, "FiniteConductivity", "Finite Conductivity"); + addItem(RimFractureTemplate::FINITE_CONDUCTIVITY, "FiniteConductivity", "Finite Conductivity"); setDefault(RimFractureTemplate::INFINITE_CONDUCTIVITY); } @@ -58,8 +58,8 @@ namespace caf template<> void caf::AppEnum< RimFractureTemplate::PermeabilityEnum>::setUp() { - addItem(RimFractureTemplate::USER_DEFINED_PERMEABILITY, "UserDefinedPermeability", "User Defined"); - addItem(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE, "FractureConductivity", "Use Fracture Conductivity"); + addItem(RimFractureTemplate::USER_DEFINED_PERMEABILITY, "UserDefinedPermeability", "User Defined"); + addItem(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE, "FractureConductivity", "Use Fracture Conductivity"); setDefault(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE); } @@ -67,8 +67,8 @@ namespace caf template<> void caf::AppEnum::setUp() { - addItem(RimFractureTemplate::USER_DEFINED_WIDTH, "UserDefinedWidth", "User Defined"); - addItem(RimFractureTemplate::WIDTH_FROM_FRACTURE, "FractureWidth", "Use Fracture Width"); + addItem(RimFractureTemplate::USER_DEFINED_WIDTH, "UserDefinedWidth", "User Defined"); + addItem(RimFractureTemplate::WIDTH_FROM_FRACTURE, "FractureWidth", "Use Fracture Width"); setDefault(RimFractureTemplate::WIDTH_FROM_FRACTURE); } @@ -76,9 +76,9 @@ namespace caf template<> void caf::AppEnum::setUp() { - addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); - addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor from Parameters"); - addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED, "UserDefined", "By User Defined D-factor"); + addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); + addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor from Parameters"); + addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED,"UserDefined", "By User Defined D-factor"); setDefault(RimFractureTemplate::NON_DARCY_NONE); } @@ -104,7 +104,7 @@ RimFractureTemplate::RimFractureTemplate() m_nameAndUnit.uiCapability()->setUiHidden(true); m_nameAndUnit.xmlCapability()->disableIO(); - CAF_PDM_InitField(&m_fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); + CAF_PDM_InitField(&m_fractureTemplateUnit, "UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); m_fractureTemplateUnit.uiCapability()->setUiReadOnly(true); CAF_PDM_InitField(&m_orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); @@ -112,10 +112,11 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); CAF_PDM_InitField(&m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); + CAF_PDM_InitField(&m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); m_perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); CAF_PDM_InitField(&m_conductivityType, "ConductivityType", caf::AppEnum(FINITE_CONDUCTIVITY), "Conductivity in Fracture", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_fractureContainment, "FractureContainmentField", "Fracture Containment", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 820907d693..8f43d92cf2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -100,9 +100,6 @@ class RimFractureTemplate : public caf::PdmObject NON_DARCY_USER_DEFINED, }; - - - public: RimFractureTemplate(); virtual ~RimFractureTemplate(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 82d8370028..9080a881e0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -283,20 +283,18 @@ QList RimStimPlanFractureTemplate::calculateValueOptions { for (std::pair nameUnit : uiResultNamesWithUnit()) { - //options.push_back(caf::PdmOptionItemInfo(nameUnit.first + " [" + nameUnit.second + "]", nameUnit.first + " " + nameUnit.second)); options.push_back(caf::PdmOptionItemInfo(nameUnit.first, nameUnit.first)); } } else if (fieldNeedingOptions == &m_activeTimeStepIndex) { std::vector timeValues = timeSteps(); - int index = 0; + int index = 0; for (double value : timeValues) { options.push_back(caf::PdmOptionItemInfo(QString::number(value), index)); index++; } - } else if (fieldNeedingOptions == &m_conductivityResultNameOnFile) { @@ -311,7 +309,6 @@ QList RimStimPlanFractureTemplate::calculateValueOptions } return options; - } //-------------------------------------------------------------------------------------------------- @@ -703,9 +700,9 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon() { return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName, parameterUnit, - m_activeTimeStepIndex, - m_wellPathDepthAtFracture, - name()); + m_activeTimeStepIndex, + m_wellPathDepthAtFracture, + name()); } return std::vector(); @@ -772,4 +769,3 @@ void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandl } } } - diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 79a290f43e..e4b4a34d4a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -59,7 +59,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void setFileName(const QString& fileName); const QString& fileName(); - QString fileNameWithOutPath(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); @@ -80,9 +79,10 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; - virtual void appendDataToResultStatistics(const QString& uiResultName, const QString& unit, - MinMaxAccumulator& minMaxAccumulator, - PosNegAccumulator& posNegAccumulator) const override; + void appendDataToResultStatistics(const QString& uiResultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; QString mapUiResultNameToFileResultName(const QString& uiResultName) const; void setDefaultConductivityResultIfEmpty(); @@ -90,7 +90,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate bool showStimPlanMesh() const; - virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From 80af97c1a80fa9ea3ebf5ff18db76985a54bf9df Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 22 Feb 2018 14:48:24 +0100 Subject: [PATCH 0325/1027] #2521 Fishbones : Clamp MD ranges to max MD of well path --- .../Completions/RimFishbonesMultipleSubs.cpp | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp index fecd6ff775..22903f9c5a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp @@ -32,6 +32,7 @@ #include #include +#include "cvfMath.h" CAF_PDM_SOURCE_INIT(RimFishbonesMultipleSubs, "FishbonesMultipleSubs"); @@ -403,23 +404,38 @@ void RimFishbonesMultipleSubs::fieldChangedByUi(const caf::PdmFieldHandle* chang changedField == &m_rangeSubSpacing) { recomputeLocations = true; - } - if (changedField == &m_rangeStart && m_rangeStart > m_rangeEnd) - { - m_rangeEnd = m_rangeStart; - } + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + + RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry(); + if (rigWellPathGeo && !rigWellPathGeo->m_measuredDepths.empty()) + { + double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back(); - if (changedField == &m_rangeEnd && m_rangeEnd < m_rangeStart) - { - m_rangeStart = m_rangeEnd; + m_rangeStart = cvf::Math::clamp(m_rangeStart(), 0.0, lastWellPathMD); + m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), m_rangeStart(), lastWellPathMD); + } } - if (changedField == &m_rangeSubSpacing && - m_rangeSubSpacing() < 13.0) + if (changedField == &m_rangeSubSpacing) { - // Minimum distance between fishbones is 13m - m_rangeSubSpacing = 13.0; + // Minimum distance between fishbones is 13.0m + // Use 10.0m to allow for some flexibility + + double minimumDistanceMeter = 10.0; + + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD) + { + double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet(minimumDistanceMeter); + m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceFeet, std::max(m_rangeSubSpacing(), minimumDistanceFeet)); + } + else + { + m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceMeter, std::max(m_rangeSubSpacing(), minimumDistanceMeter)); + } } if (recomputeLocations) From d6974bfdba3ddb0605452a389c8603cf22d62904 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Feb 2018 11:08:35 +0100 Subject: [PATCH 0326/1027] #2519 Mohr Circle: Create plot widget --- .../UserInterface/CMakeLists_files.cmake | 3 + .../UserInterface/RiuMainWindow.cpp | 22 +++ ApplicationCode/UserInterface/RiuMainWindow.h | 2 + .../UserInterface/RiuMohrsCirclePlot.cpp | 160 ++++++++++++++++++ .../UserInterface/RiuMohrsCirclePlot.h | 72 ++++++++ 5 files changed, 259 insertions(+) create mode 100644 ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp create mode 100644 ApplicationCode/UserInterface/RiuMohrsCirclePlot.h diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 5f67777ec8..5e9bd6749a 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -69,6 +69,7 @@ ${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h ${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h ${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.h ${CEE_CURRENT_LIST_DIR}RiuTools.h +${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -133,6 +134,7 @@ ${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.cpp ${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.cpp ${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.cpp ${CEE_CURRENT_LIST_DIR}RiuTools.cpp +${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.cpp ) list(APPEND CODE_HEADER_FILES @@ -174,6 +176,7 @@ ${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h ${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h ${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h ${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h +${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.h ) list(APPEND QT_UI_FILES diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 8ccf1e94f5..6b07ab1aa4 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -42,6 +42,7 @@ #include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" #include "RiuMessagePanel.h" +#include "RiuMohrsCirclePlot.h" #include "RiuProcessMonitor.h" #include "RiuProjectPropertyView.h" #include "RiuPropertyViewTabWidget.h" @@ -107,6 +108,7 @@ RiuMainWindow::RiuMainWindow() m_mainViewer(nullptr), m_relPermPlotPanel(nullptr), m_pvtPlotPanel(nullptr), + m_mohrsCirclePlot(nullptr), m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { @@ -597,6 +599,7 @@ void RiuMainWindow::createDockPanels() QDockWidget* resultPlotDock = nullptr; QDockWidget* relPermPlotDock = nullptr; QDockWidget* pvtPlotDock = nullptr; + QDockWidget* mohrsCirclePlotDock = nullptr; { QDockWidget* dockWidget = new QDockWidget("Property Editor", this); @@ -640,6 +643,19 @@ void RiuMainWindow::createDockPanels() addDockWidget(Qt::BottomDockWidgetArea, dockPanel); resultPlotDock = dockPanel; } + +#ifdef USE_ODB_API + { + QDockWidget* dockPanel = new QDockWidget("Mohr's Circle Plot", this); + dockPanel->setObjectName("dockTimeHistoryPanel"); + dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_mohrsCirclePlot = new RiuMohrsCirclePlot(dockPanel); + dockPanel->setWidget(m_mohrsCirclePlot); + + addDockWidget(Qt::BottomDockWidgetArea, dockPanel); + mohrsCirclePlotDock = dockPanel; + } +#endif { QDockWidget* dockPanel = new QDockWidget("Relative Permeability Plot", this); @@ -677,7 +693,13 @@ void RiuMainWindow::createDockPanels() // Tabify docks tabifyDockWidget(pvtPlotDock, relPermPlotDock); +#ifdef USE_ODB_API + tabifyDockWidget(relPermPlotDock, mohrsCirclePlotDock); + tabifyDockWidget(mohrsCirclePlotDock, resultPlotDock); +#else tabifyDockWidget(relPermPlotDock, resultPlotDock); +#endif + } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 8a6c4ff3b9..86082cd0ff 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -46,6 +46,7 @@ class RiuResultQwtPlot; class RiuViewer; class RiuRelativePermeabilityPlotPanel; class RiuPvtPlotPanel; +class RiuMohrsCirclePlot; struct RimMdiWindowGeometry; @@ -175,6 +176,7 @@ class RiuMainWindow : public RiuMainWindowBase QPointer m_messagePanel; RiuResultQwtPlot* m_resultQwtPlot; + RiuMohrsCirclePlot* m_mohrsCirclePlot; RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel; RiuPvtPlotPanel* m_pvtPlotPanel; diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp new file mode 100644 index 0000000000..a28ea1f8e1 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -0,0 +1,160 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuMohrsCirclePlot.h" + +#include "qwt_round_scale_draw.h" +#include "qwt_symbol.h" + +#include "cvfAssert.h" + +//================================================================================================== +/// +/// \class RiuMohrsCirclePlot +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) +: QwtPlot(parent) +{ + setDefaults(); + setPrincipalsAndRedrawCircles(320, 200, 150); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot::~RiuMohrsCirclePlot() +{ + deleteCircles(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) +{ + CVF_ASSERT(p1 > p2); + CVF_ASSERT(p2 > p3); + + m_principal1 = p1; + m_principal2 = p2; + m_principal3 = p3; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, double p3) +{ + setPrincipals(p1, p2, p3); + + redrawCircles(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuMohrsCirclePlot::sizeHint() const +{ + return QSize(100, 100); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuMohrsCirclePlot::minimumSizeHint() const +{ + return QSize(0, 0); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::redrawCircles() +{ + deleteCircles(); + createMohrCircles(); + + for (MohrCircle circle : m_mohrCircles) + { + QwtSymbol* circleSymbol = new QwtSymbol(QwtSymbol::Ellipse); + circleSymbol->setSize(2 * circle.radius, 2 * circle.radius); + + QwtPlotMarker* circlePlotItem = new QwtPlotMarker("Circle"); + circlePlotItem->setSymbol(circleSymbol); + circlePlotItem->setXValue(circle.centerX); + circlePlotItem->setYValue(0); + + m_mohrCirclesMarkers.push_back(circlePlotItem); + circlePlotItem->attach(this); + } + + this->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deleteCircles() +{ + for (size_t i = 0; i < m_mohrCirclesMarkers.size(); i++) + { + m_mohrCirclesMarkers[i]->detach(); + delete m_mohrCirclesMarkers[i]; + } + + m_mohrCirclesMarkers.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setDefaults() +{ + enableAxis(QwtPlot::xBottom, true); + enableAxis(QwtPlot::yLeft, true); + enableAxis(QwtPlot::xTop, false); + enableAxis(QwtPlot::yRight, false); + + this->setAxisScale(QwtPlot::yLeft, -400, 400); + this->setAxisScale(QwtPlot::xBottom, 0, 400); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::createMohrCircles() +{ + m_mohrCircles[0].component = 2; + m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2; + m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2; + + m_mohrCircles[1].component = 1; + m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2; + m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2; + + m_mohrCircles[2].component = 3; + m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2; + m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2; +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h new file mode 100644 index 0000000000..c938c63d2e --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "qwt_plot.h" +#include "qwt_plot_marker.h" + +#include + +#include + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuMohrsCirclePlot : public QwtPlot +{ + Q_OBJECT + +public: + RiuMohrsCirclePlot(QWidget* parent); + ~RiuMohrsCirclePlot(); + + void setPrincipals(double p1, double p2, double p3); + void setPrincipalsAndRedrawCircles(double p1, double p2, double p3); + +protected: + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; + + void redrawCircles(); + void deleteCircles(); + +private: + struct MohrCircle + { + MohrCircle(size_t component, double radius, double centerX) + : component(component), radius(radius), centerX(centerX) {} + MohrCircle() {}; + size_t component; //1, 2 or 3 + double radius; + double centerX; + }; +private: + void setDefaults(); + void createMohrCircles(); + +private: + double m_principal1; + double m_principal2; + double m_principal3; + std::array m_mohrCircles; + std::vector m_mohrCirclesMarkers; + +}; From 28efe4661dab68ee82a0afbeda2071ebac4b412b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Feb 2018 17:52:10 +0100 Subject: [PATCH 0327/1027] #2522 Mohr circle: Update plot on 3D view selection --- .../UserInterface/RiuMainWindow.cpp | 9 +++ ApplicationCode/UserInterface/RiuMainWindow.h | 1 + .../UserInterface/RiuMohrsCirclePlot.cpp | 78 +++++++++++++++++++ .../UserInterface/RiuMohrsCirclePlot.h | 7 ++ .../RiuSelectionChangedHandler.cpp | 13 ++-- 5 files changed, 103 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 6b07ab1aa4..ead90ed792 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -182,6 +182,7 @@ void RiuMainWindow::cleanupGuiCaseClose() m_resultQwtPlot->deleteAllCurves(); if (m_relPermPlotPanel) m_relPermPlotPanel->clearPlot(); if (m_pvtPlotPanel) m_pvtPlotPanel->clearPlot(); + if (m_mohrsCirclePlot) m_mohrsCirclePlot->clearPlot(); if (m_pdmUiPropertyView) { @@ -915,6 +916,14 @@ RiuPvtPlotPanel* RiuMainWindow::pvtPlotPanel() return m_pvtPlotPanel; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot* RiuMainWindow::mohrsCirclePlot() +{ + return m_mohrsCirclePlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 86082cd0ff..916a2ab5c4 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -118,6 +118,7 @@ class RiuMainWindow : public RiuMainWindowBase RiuResultQwtPlot* resultPlot(); RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel(); RiuPvtPlotPanel* pvtPlotPanel(); + RiuMohrsCirclePlot* mohrsCirclePlot(); RiuMessagePanel* messagePanel(); void showProcessMonitorDockPanel(); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index a28ea1f8e1..ec0f91caca 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -20,6 +20,16 @@ #include "qwt_round_scale_draw.h" #include "qwt_symbol.h" +#include "RiuSelectionManager.h" + +#include "RigFemPartCollection.h" +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" #include "cvfAssert.h" @@ -72,6 +82,41 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, dou redrawCircles(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem) +{ + const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); + + RimGeoMechView* geoMechView = geoMechSelectionItem ? geoMechSelectionItem->m_view : nullptr; + + bool mustClearPlot = true; + + if (this->isVisible() && geoMechSelectionItem && geoMechView) + { + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t cellIndex = geoMechSelectionItem->m_cellIndex; + if (queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex)) + { + mustClearPlot = false; + } + } + + if (mustClearPlot) + { + this->clearPlot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::clearPlot() +{ + deleteCircles(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -127,6 +172,39 @@ void RiuMohrsCirclePlot::deleteCircles() m_mohrCirclesMarkers.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex) +{ + if (!geoMechView) return false; + + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + if (!resultCollection) return false; + + int frameIdx = geoMechView->currentTimeStep(); + + RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress(); + + //TODO: All tensors are calculated everytime this function is called. FIX + std::vector vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx); + RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + + caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; + for (int i = 1; i < 8; i++) + { + tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, i)]; + } + + caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0); + + cvf::Vec3f principalDirs[3]; + cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs); + + setPrincipalsAndRedrawCircles(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index c938c63d2e..9a47c8c0c4 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -25,6 +25,8 @@ #include +class RiuSelectionItem; +class RimGeoMechView; //================================================================================================== // // @@ -41,6 +43,9 @@ class RiuMohrsCirclePlot : public QwtPlot void setPrincipals(double p1, double p2, double p3); void setPrincipalsAndRedrawCircles(double p1, double p2, double p3); + void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); + void clearPlot(); + protected: virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; @@ -48,6 +53,8 @@ class RiuMohrsCirclePlot : public QwtPlot void redrawCircles(); void deleteCircles(); + bool queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); + private: struct MohrCircle { diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index fe5a465c76..724dd0255f 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -29,25 +29,26 @@ #include "RigTimeHistoryResultAccessor.h" #include "RiuFemTimeHistoryResultAccessor.h" +#include "Rim2dIntersectionView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" -#include "Rim2dIntersectionView.h" #include "RimIntersection.h" #include "RimProject.h" #include "RiuFemResultTextBuilder.h" #include "RiuMainWindow.h" +#include "RiuMohrsCirclePlot.h" +#include "RiuPvtPlotPanel.h" +#include "RiuPvtPlotUpdater.h" +#include "RiuRelativePermeabilityPlotPanel.h" +#include "RiuRelativePermeabilityPlotUpdater.h" #include "RiuResultQwtPlot.h" #include "RiuResultTextBuilder.h" #include "RiuSelectionManager.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuPvtPlotPanel.h" -#include "RiuRelativePermeabilityPlotUpdater.h" -#include "RiuPvtPlotUpdater.h" #include @@ -107,6 +108,8 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(item); + RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(item); + updateResultInfo(item); scheduleUpdateForAllVisibleViews(); From bf1a621332990aa1740712b90bf56ebf49f59ddc Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Feb 2018 18:10:24 +0100 Subject: [PATCH 0328/1027] #2523 Mohr Circle: Improve circle appearence --- .../Application/Tools/RiaColorTables.cpp | 16 ++++ .../Application/Tools/RiaColorTables.h | 1 + .../UserInterface/RiuMohrsCirclePlot.cpp | 82 ++++++++++++++----- .../UserInterface/RiuMohrsCirclePlot.h | 13 ++- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 91d2beb880..92f7c09a1b 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -482,6 +482,22 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors() return colorTable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::mohrsCirclePaletteColors() +{ + static std::vector colors{ + cvf::Color3ub::RED, + cvf::Color3ub::DARK_GREEN, + cvf::Color3ub::BLUE + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + + return colorTable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 20c561556f..5f7c44ffcc 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -52,6 +52,7 @@ class RiaColorTables static const caf::ColorTable& wellLogPlotPaletteColors(); static const caf::ColorTable& selectionPaletteColors(); static const caf::ColorTable& timestepsPaletteColors(); + static const caf::ColorTable& mohrsCirclePaletteColors(); static cvf::Color3f undefinedCellColor(); static cvf::Color3f perforationLengthColor(); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index ec0f91caca..09e000c091 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -18,10 +18,10 @@ #include "RiuMohrsCirclePlot.h" -#include "qwt_round_scale_draw.h" -#include "qwt_symbol.h" #include "RiuSelectionManager.h" +#include "RiaColorTables.h" + #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" @@ -33,6 +33,14 @@ #include "cvfAssert.h" +#include +#include + +#include "qwt_plot_layout.h" +#include "qwt_plot_marker.h" +#include "qwt_plot_rescaler.h" +#include "qwt_plot_shapeitem.h" + //================================================================================================== /// /// \class RiuMohrsCirclePlot @@ -47,8 +55,13 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) : QwtPlot(parent) { + + setDefaults(); - setPrincipalsAndRedrawCircles(320, 200, 150); + + //setPrincipalsAndRedrawCircles(40, 30, 20); + + } //-------------------------------------------------------------------------------------------------- @@ -57,6 +70,7 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { deleteCircles(); + delete m_rescaler; } //-------------------------------------------------------------------------------------------------- @@ -141,21 +155,44 @@ void RiuMohrsCirclePlot::redrawCircles() deleteCircles(); createMohrCircles(); - for (MohrCircle circle : m_mohrCircles) + QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX"); + lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine); + lineXPlotMarker->setYValue(0); + lineXPlotMarker->attach(this); + + QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY"); + lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine); + lineYPlotMarker->setXValue(0); + lineYPlotMarker->attach(this); + + caf::ColorTable colors = RiaColorTables::mohrsCirclePaletteColors(); + + for (size_t i = 0; i < m_mohrCircles.size(); i++) { - QwtSymbol* circleSymbol = new QwtSymbol(QwtSymbol::Ellipse); - circleSymbol->setSize(2 * circle.radius, 2 * circle.radius); - - QwtPlotMarker* circlePlotItem = new QwtPlotMarker("Circle"); - circlePlotItem->setSymbol(circleSymbol); - circlePlotItem->setXValue(circle.centerX); - circlePlotItem->setYValue(0); - - m_mohrCirclesMarkers.push_back(circlePlotItem); - circlePlotItem->attach(this); + MohrCircle* circle = &m_mohrCircles[i]; + QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle"); + + QPainterPath* circleDrawing = new QPainterPath(); + QPointF center(circle->centerX, 0); + circleDrawing->addEllipse(center, circle->radius, circle->radius); + plotItem->setPen(QPen(colors.cycledQColor(i))); + plotItem->setShape(*circleDrawing); + plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); + m_circlePlotItems.push_back(plotItem); + plotItem->attach(this); } + double yHeight = 0.6*(m_principal1 - m_principal3); + this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight); + + double xMin = m_principal3 < 0 ? 1.1*m_principal3 : -1; + double xMax = m_principal1 < 0 ? 1 : 1.1*m_principal1; + this->setAxisScale(QwtPlot::xBottom, xMin, xMax); + this->replot(); + m_rescaler->rescale(); + this->plotLayout()->setAlignCanvasToScales(true); + } //-------------------------------------------------------------------------------------------------- @@ -163,13 +200,13 @@ void RiuMohrsCirclePlot::redrawCircles() //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::deleteCircles() { - for (size_t i = 0; i < m_mohrCirclesMarkers.size(); i++) + for (size_t i = 0; i < m_circlePlotItems.size(); i++) { - m_mohrCirclesMarkers[i]->detach(); - delete m_mohrCirclesMarkers[i]; + m_circlePlotItems[i]->detach(); + delete m_circlePlotItems[i]; } - m_mohrCirclesMarkers.clear(); + m_circlePlotItems.clear(); } //-------------------------------------------------------------------------------------------------- @@ -210,13 +247,16 @@ bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setDefaults() { + m_rescaler = new QwtPlotRescaler(this->canvas()); + m_rescaler->setReferenceAxis(QwtPlot::yLeft); + m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0); + m_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed); + m_rescaler->setEnabled(true); + enableAxis(QwtPlot::xBottom, true); enableAxis(QwtPlot::yLeft, true); enableAxis(QwtPlot::xTop, false); enableAxis(QwtPlot::yRight, false); - - this->setAxisScale(QwtPlot::yLeft, -400, 400); - this->setAxisScale(QwtPlot::xBottom, 0, 400); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 9a47c8c0c4..67b6bb8b05 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -19,14 +19,16 @@ #pragma once #include "qwt_plot.h" -#include "qwt_plot_marker.h" - -#include +#include "qwt_plot_item.h" #include class RiuSelectionItem; class RimGeoMechView; +class QwtRoundScaleDraw; +class QwtPlotRescaler; +class QWidget; + //================================================================================================== // // @@ -73,7 +75,10 @@ class RiuMohrsCirclePlot : public QwtPlot double m_principal1; double m_principal2; double m_principal3; + std::array m_mohrCircles; - std::vector m_mohrCirclesMarkers; + std::vector m_circlePlotItems; + + QwtPlotRescaler* m_rescaler; }; From e8a65989c354f92133a2ea891b3e4f694021ffc1 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Feb 2018 18:15:56 +0100 Subject: [PATCH 0329/1027] Code cleanup --- .../UserInterface/RiuMohrsCirclePlot.cpp | 98 +++++++++---------- .../UserInterface/RiuResultQwtPlot.cpp | 1 - .../UserInterface/RiuResultQwtPlot.h | 4 +- 3 files changed, 48 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 09e000c091..ae09a45e23 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -45,36 +45,31 @@ /// /// \class RiuMohrsCirclePlot /// -/// +/// /// //================================================================================================== //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) -: QwtPlot(parent) + : QwtPlot(parent) { - - setDefaults(); - - //setPrincipalsAndRedrawCircles(40, 30, 20); - - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { deleteCircles(); + delete m_rescaler; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) { @@ -87,7 +82,7 @@ void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, double p3) { @@ -97,12 +92,12 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, dou } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem) { const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); - + RimGeoMechView* geoMechView = geoMechSelectionItem ? geoMechSelectionItem->m_view : nullptr; bool mustClearPlot = true; @@ -124,7 +119,7 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::clearPlot() { @@ -132,7 +127,7 @@ void RiuMohrsCirclePlot::clearPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QSize RiuMohrsCirclePlot::sizeHint() const { @@ -140,7 +135,7 @@ QSize RiuMohrsCirclePlot::sizeHint() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QSize RiuMohrsCirclePlot::minimumSizeHint() const { @@ -148,32 +143,22 @@ QSize RiuMohrsCirclePlot::minimumSizeHint() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::redrawCircles() { deleteCircles(); createMohrCircles(); - QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX"); - lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine); - lineXPlotMarker->setYValue(0); - lineXPlotMarker->attach(this); - - QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY"); - lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine); - lineYPlotMarker->setXValue(0); - lineYPlotMarker->attach(this); - caf::ColorTable colors = RiaColorTables::mohrsCirclePaletteColors(); for (size_t i = 0; i < m_mohrCircles.size(); i++) { - MohrCircle* circle = &m_mohrCircles[i]; + MohrCircle* circle = &m_mohrCircles[i]; QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle"); QPainterPath* circleDrawing = new QPainterPath(); - QPointF center(circle->centerX, 0); + QPointF center(circle->centerX, 0); circleDrawing->addEllipse(center, circle->radius, circle->radius); plotItem->setPen(QPen(colors.cycledQColor(i))); plotItem->setShape(*circleDrawing); @@ -182,21 +167,20 @@ void RiuMohrsCirclePlot::redrawCircles() plotItem->attach(this); } - double yHeight = 0.6*(m_principal1 - m_principal3); + double yHeight = 0.6 * (m_principal1 - m_principal3); this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight); - double xMin = m_principal3 < 0 ? 1.1*m_principal3 : -1; - double xMax = m_principal1 < 0 ? 1 : 1.1*m_principal1; + double xMin = m_principal3 < 0 ? 1.1 * m_principal3 : -1; + double xMax = m_principal1 < 0 ? 1 : 1.1 * m_principal1; this->setAxisScale(QwtPlot::xBottom, xMin, xMax); this->replot(); m_rescaler->rescale(); this->plotLayout()->setAlignCanvasToScales(true); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::deleteCircles() { @@ -210,22 +194,22 @@ void RiuMohrsCirclePlot::deleteCircles() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex) { if (!geoMechView) return false; - + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); if (!resultCollection) return false; int frameIdx = geoMechView->currentTimeStep(); - + RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress(); - //TODO: All tensors are calculated everytime this function is called. FIX + // TODO: All tensors are calculated everytime this function is called. FIX std::vector vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx); - RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; for (int i = 1; i < 8; i++) @@ -243,7 +227,7 @@ bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setDefaults() { @@ -257,22 +241,32 @@ void RiuMohrsCirclePlot::setDefaults() enableAxis(QwtPlot::yLeft, true); enableAxis(QwtPlot::xTop, false); enableAxis(QwtPlot::yRight, false); + + QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX"); + lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine); + lineXPlotMarker->setYValue(0); + lineXPlotMarker->attach(this); + + QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY"); + lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine); + lineYPlotMarker->setXValue(0); + lineYPlotMarker->attach(this); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::createMohrCircles() { m_mohrCircles[0].component = 2; - m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2; - m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2; + m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2; + m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2; m_mohrCircles[1].component = 1; - m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2; - m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2; + m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2; + m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2; m_mohrCircles[2].component = 3; - m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2; - m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2; + m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2; + m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2; } diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp index ae65202248..bcb625f6d1 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp @@ -31,7 +31,6 @@ #include "cafCmdFeatureMenuBuilder.h" #include "cvfBase.h" -#include "cvfAssert.h" #include "cvfColor3.h" #include "qwt_date_scale_draw.h" diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.h b/ApplicationCode/UserInterface/RiuResultQwtPlot.h index feb334944f..725a1c4a4d 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.h @@ -61,8 +61,8 @@ class RiuResultQwtPlot : public QwtPlot void deleteAllCurves(); protected: - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; virtual void contextMenuEvent(QContextMenuEvent *) override; private: From 69b1384d892c87526e3cdf1336d23500d178646f Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 23 Feb 2018 10:05:03 +0100 Subject: [PATCH 0330/1027] #2523 Mohrs circle: Add comments and improve readablity --- .../UserInterface/RiuMohrsCirclePlot.cpp | 82 ++++++++++++++----- .../UserInterface/RiuMohrsCirclePlot.h | 2 +- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index ae09a45e23..c6ade03a4e 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -98,21 +98,23 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select { const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); - RimGeoMechView* geoMechView = geoMechSelectionItem ? geoMechSelectionItem->m_view : nullptr; - - bool mustClearPlot = true; + if (!geoMechSelectionItem) + { + this->clearPlot(); + return; + } + + RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; + CVF_ASSERT(geoMechView); - if (this->isVisible() && geoMechSelectionItem && geoMechView) + if (this->isVisible()) { const size_t gridIndex = geoMechSelectionItem->m_gridIndex; const size_t cellIndex = geoMechSelectionItem->m_cellIndex; - if (queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex)) - { - mustClearPlot = false; - } + + queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex); } - - if (mustClearPlot) + else { this->clearPlot(); } @@ -160,6 +162,7 @@ void RiuMohrsCirclePlot::redrawCircles() QPainterPath* circleDrawing = new QPainterPath(); QPointF center(circle->centerX, 0); circleDrawing->addEllipse(center, circle->radius, circle->radius); + plotItem->setPen(QPen(colors.cycledQColor(i))); plotItem->setShape(*circleDrawing); plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); @@ -170,8 +173,45 @@ void RiuMohrsCirclePlot::redrawCircles() double yHeight = 0.6 * (m_principal1 - m_principal3); this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight); - double xMin = m_principal3 < 0 ? 1.1 * m_principal3 : -1; - double xMax = m_principal1 < 0 ? 1 : 1.1 * m_principal1; + // Scale the x-axis to show the y-axis if the largest circle's leftmost intersection of the + // x-axis (principal 3) is to the right of the y-axis + + //The following examples shows the largest of the three Mohr circles + + // Ex 1: xMin will be set to 1.1 * m_principal3 to be able to see the whole circle + // |y + // _|____ + // / | \ + // / | \ + //--|---|-------|------- x + // \ | / + // \_|_____/ + // | + // | + + // Ex 2: xMin will be set to -1 to be able to see the y-axis + // |y + // | _______ + // | / \ + // | / \ + // -|-------------|-----------|---------- x + // | \ / + // | \_______/ + // | + // | + + double xMin; + if (m_principal3 < 0) + { + xMin = 1.1 * m_principal3; + } + else + { + xMin = -1; + } + // When using the rescaler, xMax is ignored + double xMax = 0; + this->setAxisScale(QwtPlot::xBottom, xMin, xMax); this->replot(); @@ -196,12 +236,11 @@ void RiuMohrsCirclePlot::deleteCircles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex) +void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex) { - if (!geoMechView) return false; + CVF_ASSERT(geoMechView); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); - if (!resultCollection) return false; int frameIdx = geoMechView->currentTimeStep(); @@ -223,7 +262,6 @@ bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs); setPrincipalsAndRedrawCircles(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); - return true; } //-------------------------------------------------------------------------------------------------- @@ -259,14 +297,14 @@ void RiuMohrsCirclePlot::setDefaults() void RiuMohrsCirclePlot::createMohrCircles() { m_mohrCircles[0].component = 2; - m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2; - m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2; + m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2.0; + m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2.0; m_mohrCircles[1].component = 1; - m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2; - m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2; + m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2.0; + m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2.0; m_mohrCircles[2].component = 3; - m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2; - m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2; + m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2.0; + m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2.0; } diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 67b6bb8b05..6b3506decd 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -55,7 +55,7 @@ class RiuMohrsCirclePlot : public QwtPlot void redrawCircles(); void deleteCircles(); - bool queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); + void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); private: struct MohrCircle From f9de64c538384f729026d34c4f9b00439ed86e66 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 19:34:43 +0100 Subject: [PATCH 0331/1027] AppFwk : Use freopen_s instead of freopen --- Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index a288998d7a..8bbff80361 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -335,9 +335,14 @@ namespace caf { #pragma warning (push) #pragma warning (disable: 4996) AllocConsole(); - freopen("conin$", "r", stdin); - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); + + FILE* consoleFilePointer; + errno_t err; + + err = freopen_s(&consoleFilePointer, "conin$", "r", stdin); + err = freopen_s(&consoleFilePointer, "conout$", "w", stdout); + err = freopen_s(&consoleFilePointer, "conout$", "w", stderr); + #pragma warning (pop) #endif } From 309b1f074989ae4adca993deb4db056d5d6cae3a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 19:43:48 +0100 Subject: [PATCH 0332/1027] AppFwk Clang : Reorder initialization order to match declaration order --- Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h | 2 +- .../cafPdmUiCore/cafPdmUiItem.cpp | 4 +- .../cafPdmUiCore/cafPdmUiItem.h | 4 +- .../cafPdmUiCore/cafPdmUiTreeOrdering.cpp | 40 +++++++++---------- .../cafUserInterface/cafPdmUiListEditor.cpp | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h index 83cb0d2be9..4883a159c6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h @@ -139,7 +139,7 @@ namespace caf class PdmObject : public PdmObjectHandle, public PdmXmlObjectHandle, public PdmUiObjectHandle { public: - PdmObject() : PdmObjectHandle(), PdmUiObjectHandle(this, false), PdmXmlObjectHandle(this, false) {} + PdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false), PdmUiObjectHandle(this, false) {} virtual ~PdmObject() {} /// Adds field to the internal data structure and sets the file keyword and Ui information diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 2bf1678d20..dfe441507d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -47,8 +47,8 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool isReadOnly /* = false */, QIcon anIcon /* = QIcon()*/) - : m_value(aValue), - m_optionUiText(anOptionUiText), + : m_optionUiText(anOptionUiText), + m_value(aValue), m_isReadOnly(isReadOnly), m_icon(anIcon), m_level(0) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 91bd07da34..5df67078ac 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -69,10 +69,10 @@ class PdmUiItemInfo private: friend class PdmUiItem; QString m_uiName; + QIcon m_icon; QString m_toolTip; - QString m_extraDebugText; QString m_whatsThis; - QIcon m_icon; + QString m_extraDebugText; QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem int m_isHidden; ///< UiItem should be hidden. -1 means not set int m_isTreeChildrenHidden; ///< Children of UiItem should be hidden. -1 means not set diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp index 8afceb66c4..63c76662c9 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp @@ -140,13 +140,13 @@ bool PdmUiTreeOrdering::containsObject(const PdmObjectHandle* object) /// Creates an new root PdmUiTreeOrdering item, pointing at a PdmObject //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : - m_parentItem(nullptr), + m_object(pdmObject), m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(nullptr), - m_object(pdmObject), - m_treeItemEditor(nullptr) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { } @@ -154,13 +154,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : /// Creates an new root PdmUiTreeOrdering item, pointing at a field //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : - m_parentItem(nullptr), + m_object(nullptr), m_field(pdmField), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(nullptr), - m_object(nullptr), - m_treeItemEditor(nullptr) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { if (pdmField) m_object = pdmField->ownerObject(); } @@ -169,13 +169,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : /// Creates an new root PdmUiTreeOrdering item, as a display item only //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconResourceName) : - m_parentItem(nullptr), + m_object(nullptr), m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(nullptr), - m_object(nullptr), - m_treeItemEditor(nullptr) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { m_uiItem = new PdmUiItem(); m_uiItem->setUiName(title); @@ -187,13 +187,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconR /// at the end of parents existing child list. //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent, PdmObjectHandle* pdmObject) : - m_parentItem(parent), + m_object(pdmObject), m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(nullptr), - m_object(pdmObject), - m_treeItemEditor(nullptr) + m_treeItemEditor(nullptr), + m_parentItem(parent) { if (m_parentItem) { @@ -206,13 +206,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent, PdmObjectHandle* /// at the end of parents existing child list. //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent , PdmFieldHandle* pdmField ) : - m_parentItem(parent), + m_object(nullptr), m_field(pdmField), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(nullptr), - m_object(nullptr), - m_treeItemEditor(nullptr) + m_treeItemEditor(nullptr), + m_parentItem(parent) { if (m_parentItem) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 73e985ad0e..b5a344840a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -64,7 +64,7 @@ class MyStringListModel : public QStringListModel { public: - explicit MyStringListModel(QObject *parent = nullptr) : m_isItemsEditable(false), QStringListModel(parent) { } + explicit MyStringListModel(QObject *parent = nullptr) : QStringListModel(parent), m_isItemsEditable(false) { } virtual Qt::ItemFlags flags (const QModelIndex& index) const { From 8bc3f06acd959052b51f35c199d05d5efd506ec3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 19:56:38 +0100 Subject: [PATCH 0333/1027] AppFwk : Add missing default handling in switch statements --- Fwk/AppFwk/cafViewer/cafCadNavigation.cpp | 2 ++ Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp | 2 ++ Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index ae4542ea73..a8340535bc 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -167,6 +167,8 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index e66df439b2..88f70e3516 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -132,6 +132,8 @@ bool caf::CeetronNavigation::handleInputEvent(QInputEvent* inputEvent) case QEvent::Wheel: wheelEvent(static_cast ( inputEvent)); break; + default: + break; } return false; diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index ace62919f8..0a7f233ae6 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -202,6 +202,8 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) From 671818d72e70122ded37b3e47cf5f1ab49a88898 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 19:57:09 +0100 Subject: [PATCH 0334/1027] AppFwk : Reorder initialization to match declaration --- Fwk/AppFwk/cafViewer/cafViewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Fwk/AppFwk/cafViewer/cafViewer.cpp b/Fwk/AppFwk/cafViewer/cafViewer.cpp index 9da9566eb8..f38c310505 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.cpp +++ b/Fwk/AppFwk/cafViewer/cafViewer.cpp @@ -114,12 +114,12 @@ cvf::ref caf::Viewer::sm_openGLContextGroup; caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent) : caf::OpenGLWidget(contextGroup(), format, new QWidget(parent), sharedWidget()), m_navigationPolicy(nullptr), + m_navigationPolicyEnabled(true), m_defaultPerspectiveNearPlaneDistance(0.05), m_maxClipPlaneDistance(cvf::UNDEFINED_DOUBLE), m_cameraFieldOfViewYDeg(40.0), - m_releaseOGLResourcesEachFrame(false), m_paintCounter(0), - m_navigationPolicyEnabled(true), + m_releaseOGLResourcesEachFrame(false), m_isOverlayPaintingEnabled(true), m_offscreenViewportWidth(0), m_offscreenViewportHeight(0) From 70faea56df5c3c25bcbb9cffe74607fc8b9885a1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 20:03:19 +0100 Subject: [PATCH 0335/1027] AppFwk : Add missing initialization of variables and handling of switch statements --- Fwk/AppFwk/CommonCode/cafVecIjk.cpp | 2 +- Fwk/AppFwk/CommonCode/cvfStructGrid.cpp | 2 ++ .../cafHexGridIntersectionTools.cpp | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp index 16d60de3b4..38c39cfc61 100644 --- a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp +++ b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp @@ -43,7 +43,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- VecIjk::VecIjk(size_t i, size_t j, size_t k) { - m_values = { i, j, k }; + m_values = { {i, j, k} }; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp index 708e3ad558..7e82ed2c93 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp @@ -198,6 +198,8 @@ void StructGridInterface::neighborIJKAtCellFace(size_t i, size_t j, size_t k, Fa case NEG_J : if (j > 0) (*nj)--; else (*nj) = cvf::UNDEFINED_SIZE_T; break; case POS_K : (*nk)++; break; case NEG_K : if (k > 0) (*nk)--; else (*nk) = cvf::UNDEFINED_SIZE_T; break; + default: + break; } } diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp index f6ec78936c..8763812d2f 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp @@ -134,7 +134,9 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane CVF_ASSERT(false); } - bool ok1, ok2; + bool ok1 = false; + bool ok2 = false; + if (topVx == 1) { ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); From 34c6e3d90642cbc286235726ff8af8c3325a695b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 21:30:24 +0100 Subject: [PATCH 0336/1027] System : Add missing default sections of switch statements --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 2ec6429d7b..092f1d83d6 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -281,6 +281,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in case RIG_INTEGRATION_POINT: m_readerInterface->readIntegrationPointField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors); break; + default: + break; } } @@ -1998,6 +2000,8 @@ std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToCompo case RIG_INTEGRATION_POINT: fieldAndComponentNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); break; + default: + break; } std::vector< RigFemResultAddress> resAddressToComponents; From 0006c786cf158105923fc260603aba32f759aad6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 22:38:08 +0100 Subject: [PATCH 0337/1027] System : Reorder initialization order to match declaration --- .../RigActiveCellsResultAccessor.cpp | 6 +++--- ApplicationCode/ReservoirDataModel/RigCell.cpp | 10 +++++----- .../RigEclipseWellLogExtractor.cpp | 8 +++++--- .../ReservoirDataModel/RigFlowDiagResultAddress.h | 5 +++-- .../RigGeoMechWellLogExtractor.cpp | 10 +++++++--- ApplicationCode/ReservoirDataModel/RigGridBase.cpp | 4 ++-- .../ReservoirDataModel/RigLasFileExporter.cpp | 6 +++--- .../ReservoirDataModel/RigResultModifier.h | 12 +++++++----- .../RigResultModifierFactory.cpp | 2 +- .../ReservoirDataModel/RigSimWellData.h | 4 ++-- .../ReservoirDataModel/RigWellLogExtractionTools.h | 14 ++++++++++++-- 11 files changed, 50 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp index 77451bec2c..0c51ac5257 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp @@ -26,9 +26,9 @@ RigActiveCellsResultAccessor::RigActiveCellsResultAccessor(const RigGridBase* grid, const std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) - : m_grid(grid), - m_reservoirResultValues(reservoirResultValues), - m_activeCellInfo(activeCellInfo) + : m_activeCellInfo(activeCellInfo), + m_grid(grid), + m_reservoirResultValues(reservoirResultValues) { } diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index ddd9662fd6..de3c29aca6 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -38,13 +38,13 @@ static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T, /// //-------------------------------------------------------------------------------------------------- RigCell::RigCell() : + m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T), + m_hostGrid(nullptr), + m_subGrid(nullptr), m_parentCellIndex(cvf::UNDEFINED_SIZE_T), m_mainGridCellIndex(cvf::UNDEFINED_SIZE_T), - m_subGrid(nullptr), - m_hostGrid(nullptr), - m_isInvalid(false), - m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T), - m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T) + m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T), + m_isInvalid(false) { memcpy(m_cornerIndices.data(), undefinedCornersArray, 8*sizeof(size_t)); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index a9e2e57dca..f7ab544665 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -35,13 +35,15 @@ /// //================================================================================================== -RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) - : m_caseData(aCase), RigWellLogExtractor(wellpath, wellCaseErrorMsgName) +RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase, + const RigWellPath* wellpath, + const std::string& wellCaseErrorMsgName) + : RigWellLogExtractor(wellpath, wellCaseErrorMsgName) + , m_caseData(aCase) { calculateIntersection(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h index 1bb81d117b..28f2098b91 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h @@ -52,8 +52,9 @@ class RigFlowDiagResultAddress RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::set& someSelectedTracerNames) : variableName(aVariableName), - phaseSelection(phaseSelection), - selectedTracerNames(someSelectedTracerNames) {} + selectedTracerNames(someSelectedTracerNames), + phaseSelection(phaseSelection) + {} RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::string& tracerName) : variableName(aVariableName), diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index e070dd9a1e..db430a0537 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -30,11 +30,15 @@ #include "RigWellPath.h" #include "cvfGeometryTools.h" #include "RigWellPathIntersectionTools.h" + //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) - :m_caseData(aCase), RigWellLogExtractor(wellpath, wellCaseErrorMsgName) +RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase, + const RigWellPath* wellpath, + const std::string& wellCaseErrorMsgName) + : RigWellLogExtractor(wellpath, wellCaseErrorMsgName) + , m_caseData(aCase) { calculateIntersection(); } diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 5c1613099d..6e42c71bfd 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -29,8 +29,8 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid): m_gridPointDimensions(0,0,0), - m_mainGrid(mainGrid), - m_indexToStartOfCells(0) + m_indexToStartOfCells(0), + m_mainGrid(mainGrid) { if (mainGrid == nullptr) { diff --git a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp index 7a024257e6..706a5fac38 100644 --- a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -92,9 +92,9 @@ class SingleLasFileMetaData { public: SingleLasFileMetaData() - : m_minimumCurveValue(HUGE_VAL), - m_rkbDiff(HUGE_VAL), - m_exportTvdrkb(false) + : m_rkbDiff(HUGE_VAL) + , m_exportTvdrkb(false) + , m_minimumCurveValue(HUGE_VAL) { } diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifier.h b/ApplicationCode/ReservoirDataModel/RigResultModifier.h index 79bb36495d..93e54ce1b3 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifier.h +++ b/ApplicationCode/ReservoirDataModel/RigResultModifier.h @@ -66,10 +66,12 @@ class RigAllGridCellsResultModifier : public RigResultModifier class RigActiveCellsResultModifier : public RigResultModifier { public: - RigActiveCellsResultModifier(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) - : m_grid(grid), - m_reservoirResultValues(reservoirResultValues), - m_activeCellInfo(activeCellInfo) + RigActiveCellsResultModifier(const RigGridBase* grid, + const RigActiveCellInfo* activeCellInfo, + std::vector* reservoirResultValues) + : m_grid(grid) + , m_activeCellInfo(activeCellInfo) + , m_reservoirResultValues(reservoirResultValues) { } @@ -85,8 +87,8 @@ class RigActiveCellsResultModifier : public RigResultModifier private: - const RigActiveCellInfo* m_activeCellInfo; const RigGridBase* m_grid; + const RigActiveCellInfo* m_activeCellInfo; std::vector* m_reservoirResultValues; }; diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp index 1db8e52737..de4c947115 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp @@ -90,7 +90,7 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarResultIndex); if (useGlobalActiveIndex) { - cvf::ref object = new RigActiveCellsResultModifier(grid, resultValues, eclipseCase->activeCellInfo(porosityModel)); + cvf::ref object = new RigActiveCellsResultModifier(grid, eclipseCase->activeCellInfo(porosityModel), resultValues); return object; } else diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.h b/ApplicationCode/ReservoirDataModel/RigSimWellData.h index d945526d14..b13025ccdc 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.h +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.h @@ -160,8 +160,8 @@ class RigWellResultFrame public: RigWellResultFrame() : - m_isOpen(false), - m_productionType(UNDEFINED_PRODUCTION_TYPE) + m_productionType(UNDEFINED_PRODUCTION_TYPE), + m_isOpen(false) { } const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h index f20a8030da..dc01c9e340 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h @@ -45,7 +45,12 @@ struct RigWellLogExtractionTools struct RigMDCellIdxEnterLeaveKey { - RigMDCellIdxEnterLeaveKey(double md, size_t cellIdx, bool entering): measuredDepth(md), hexIndex(cellIdx), isEnteringCell(entering){} + RigMDCellIdxEnterLeaveKey(double md, size_t cellIdx, bool entering) + : measuredDepth(md) + , hexIndex(cellIdx) + , isEnteringCell(entering) + { + } double measuredDepth; size_t hexIndex; @@ -85,7 +90,12 @@ struct RigMDCellIdxEnterLeaveKey struct RigMDEnterLeaveCellIdxKey { - RigMDEnterLeaveCellIdxKey(double md, bool entering, size_t cellIdx ): measuredDepth(md), hexIndex(cellIdx), isEnteringCell(entering){} + RigMDEnterLeaveCellIdxKey(double md, bool entering, size_t cellIdx) + : measuredDepth(md) + , isEnteringCell(entering) + , hexIndex(cellIdx) + { + } double measuredDepth; bool isEnteringCell; // As opposed to leaving. From 245ea2dac2d733f850410e95f612ff9f94976f4b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 22:38:46 +0100 Subject: [PATCH 0338/1027] System : Use unsigned type as index --- ApplicationCode/ReservoirDataModel/RigNNCData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 37289499b0..9d9ce21efa 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -150,7 +150,7 @@ cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap(const Ri #endif - for ( char fIdx = 0; fIdx < 6; ++fIdx ) + for ( unsigned char fIdx = 0; fIdx < 6; ++fIdx ) { if ( !isPossibleNeighborInDirection[fIdx] ) { From ae064463a92730df2792663b70331d00793e0a30 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 22:39:14 +0100 Subject: [PATCH 0339/1027] System : Add missing default statements --- .../RigCaseCellResultsData.cpp | 19 ++++++++++--------- .../RigCombMultResultAccessor.cpp | 2 ++ .../RigCombTransResultAccessor.cpp | 2 ++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 5b6a3e4fc3..14ceec0997 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1891,19 +1891,20 @@ void RigCaseCellResultsData::computeNncCombRiTrans() { case cvf::StructGridInterface::POS_I: case cvf::StructGridInterface::NEG_I: - permIdxFunc = permXIdxFunc; - permResults = &permXResults; - break; + permIdxFunc = permXIdxFunc; + permResults = &permXResults; + break; case cvf::StructGridInterface::POS_J: case cvf::StructGridInterface::NEG_J: - permIdxFunc = permYIdxFunc; - permResults = &permYResults; - break; + permIdxFunc = permYIdxFunc; + permResults = &permYResults; + break; case cvf::StructGridInterface::POS_K: case cvf::StructGridInterface::NEG_K: - permIdxFunc = permZIdxFunc; - permResults = &permZResults; - break; + permIdxFunc = permZIdxFunc; + permResults = &permZResults; + break; + default: break; } if (!permIdxFunc) continue; diff --git a/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp index 4ef5d409a1..ca12be699c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp @@ -138,6 +138,8 @@ double RigCombMultResultAccessor::nativeMultScalar(size_t gridLocalCellIndex, cv } break; } + default: + break; } // FaceScalar with value HUGE_VAL means value outside valid IJK-range. Clamp to 1.0 as this means no change in MULT factor. diff --git a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp index f2f48882fa..fa7485a090 100644 --- a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp @@ -134,6 +134,8 @@ double RigCombTransResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf return this->neighborCellTran(gridLocalCellIndex, cvf::StructGridInterface::NEG_K, m_zTransAccessor.p()); } break; + default: + break; } return HUGE_VAL; From 7ce6177bc5967c08f0c89dbf078598280211aedf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2018 22:39:29 +0100 Subject: [PATCH 0340/1027] System : Add missing braces --- .../ReservoirDataModel/RigFlowDiagSolverInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 7ffa197027..5e12433eed 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -672,7 +672,7 @@ std::vector RigFlowDiagSolverInterface // Calculate and return curves both with and without endpoint scaling and tag them accordingly // Must use two calls to achieve this - const std::array epsModeArr = { RelPermCurve::EPS_ON , RelPermCurve::EPS_OFF }; + const std::array epsModeArr = { {RelPermCurve::EPS_ON , RelPermCurve::EPS_OFF} }; for (RelPermCurve::EpsMode epsMode : epsModeArr) { const bool useEps = epsMode == RelPermCurve::EPS_ON ? true : false; From bba69e7b98c9ddae531e01ac5d98866a3f356af6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Feb 2018 09:15:31 +0100 Subject: [PATCH 0341/1027] Clang : Add power shell scripts --- scripts/ceesol-sample-clang-build.ps1 | 231 +++ scripts/clang-build.ps1 | 2229 +++++++++++++++++++++++++ scripts/msbuild_translation_tests.ps1 | 334 ++++ scripts/sample-clang-build.ps1 | 225 +++ 4 files changed, 3019 insertions(+) create mode 100644 scripts/ceesol-sample-clang-build.ps1 create mode 100644 scripts/clang-build.ps1 create mode 100644 scripts/msbuild_translation_tests.ps1 create mode 100644 scripts/sample-clang-build.ps1 diff --git a/scripts/ceesol-sample-clang-build.ps1 b/scripts/ceesol-sample-clang-build.ps1 new file mode 100644 index 0000000000..d1ba3e1a79 --- /dev/null +++ b/scripts/ceesol-sample-clang-build.ps1 @@ -0,0 +1,231 @@ +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + It sets up the scene required for clang-build.ps1 to do its job, and makes + command-line usage for projects and files quicker. + + Before calling sample-clang-build.ps1 you need to set the current directory + to the root source directory. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + Doesn't actually apply the clang-tidy module changes to CPPs. + It will only print the tidy module output. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy-fix "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + It will apply all tidy module changes to CPPs. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo -proj-ignore foobar + + Runs clang++ on all CPPs in foo... projects, except foobar + +.OUTPUTS + Will output Clang warnings and errors to screen. The return code will be 0 for success, >0 for failure. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + ) + +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kClangCompileFlags -Option Constant ` + -value @( "-Wall" + , "-fms-compatibility-version=19.10" + , "-Wmicrosoft" + , "-Wno-invalid-token-paste" + , "-Wno-unknown-pragmas" + , "-Wno-unused-variable" + , "-Wno-unused-value" + , "-Wno-undefined-var-template" + , "-Wno-microsoft-enum-value" + , "-Wno-inconsistent-missing-override" + , "-Wno-extra-tokens" + , "-Wno-c99-extensions" + , "-Wno-logical-op-parentheses" + , "-Wno-invalid-source-encoding" + ) + +Set-Variable -name kVisualStudioVersion -value "2017" -Option Constant +Set-Variable -name kVisualStudioSku -value "Professional" -Option Constant +Set-Variable -name localVarUseParallelCompile -value $True -Option Constant +Set-Variable -name localVarCppToIgnore -Option Constant ` + -value @( "gtest" + , "moc_" + ) + + +# ------------------------------------------------------------------------------------------------ + +Function Merge-Array([string[]] $aArray) +{ + # we need to individually wrap items into quotes as values + # can contain PS control characters (e.g. - in -std=c++14) + $quotedArray = ($aArray | ForEach-Object { """$_"""}) + return ($quotedArray -join ",") +} + +[string] $scriptDirectory = (Split-Path -parent $PSCommandPath) + +[string] $clangScript = "$scriptDirectory\clang-build.ps1" +[string[]] $scriptParams = @("-aSolutionsPath", "'$(Get-Location)'") + +if (![string]::IsNullOrEmpty($aVcxprojToCompile)) +{ + $scriptParams += ("-aVcxprojToCompile", (Merge-Array $aVcxprojToCompile)) +} + +if (![string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + $scriptParams += ("-aVcxprojToIgnore", (Merge-Array $aVcxprojToIgnore)) +} + +if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) +{ + $scriptParams += ("-aVcxprojConfigPlatform", (Merge-Array $aVcxprojConfigPlatform)) +} + +if (![string]::IsNullOrEmpty($aCppToCompile)) +{ + $scriptParams += ("-aCppToCompile", (Merge-Array $aCppToCompile)) +} + +if (![string]::IsNullOrEmpty($localVarCppToIgnore)) +{ + $scriptParams += ("-aCppToIgnore", (Merge-Array $localVarCppToIgnore)) +} + +$scriptParams += ("-aClangCompileFlags", (Merge-Array $kClangCompileFlags)) + +if (![string]::IsNullOrEmpty($aTidyFlags)) +{ + $scriptParams += ("-aTidyFlags", (Merge-Array (@($aTidyFlags)))) +} + +if (![string]::IsNullOrEmpty($aTidyFixFlags)) +{ + $scriptParams += ("-aTidyFixFlags", (Merge-Array (@($aTidyFixFlags)))) +} + +if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) +{ + $scriptParams += ("-aAfterTidyFixFormatStyle", $aAfterTidyFixFormatStyle) +} + +if ($localVarUseParallelCompile) +{ + $scriptParams += ("-aUseParallelCompile") +} + +if ($aContinueOnError) +{ + $scriptParams += ("-aContinueOnError") +} + +if ($True) +{ + $scriptParams += ("-aTreatAdditionalIncludesAsSystemIncludes") +} + +if ($aDisableNameRegexMatching) +{ + $scriptParams += ("-aDisableNameRegexMatching") +} + +$scriptParams += ("-aVisualStudioVersion", $kVisualStudioVersion) +$scriptParams += ("-aVisualStudioSku", $kVisualStudioSku) +$scriptParams += ("-aTidyHeaderFilter", ".*") + +Invoke-Expression "&'$clangScript' $scriptParams" diff --git a/scripts/clang-build.ps1 b/scripts/clang-build.ps1 new file mode 100644 index 0000000000..8c8c37c8b8 --- /dev/null +++ b/scripts/clang-build.ps1 @@ -0,0 +1,2229 @@ +#Requires -Version 3 +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + +.DESCRIPTION + This PowerShell script scans for all .vcxproj Visual Studio projects inside a source directory. + One or more of these projects will be compiled or tidied up (modernized), using Clang. + +.PARAMETER aSolutionsPath + Alias 'dir'. Source directory to find sln files. + Projects will be extracted from each sln. + + Important: You can pass an absolute path to a sln. This way, no file searching will be done, and + only the projects from this solution file will be taken into acount. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects found in solutions are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all projects containing 'msicomp'. + + Absolute disk paths to vcxproj files are accepted. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" ignores projects containing 'msicomp'. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + +.PARAMETER aUseParallelCompile + Alias 'parallel'. Switch to run in parallel mode, on all logical CPU cores. + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aTreatAdditionalIncludesAsSystemIncludes + Alias 'treat-sai'. Switch to treat project additional include directories as system includes. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + + If '.clang-tidy' value is given, configuration will be read from .clang-tidy file + in the closest parent directory. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + + If '.clang-tidy' value is given, configuration will be read from .clang-tidy file + in the closest parent directory. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.PARAMETER aVisualStudioVersion + Alias 'vs-ver'. Version of Visual Studio (VC++) installed and that'll be used for + standard library include directories. E.g. 2017. + +.PARAMETER aVisualStudioSku + Alias 'vs-sku'. Sku of Visual Studio (VC++) installed and that'll be used for + standard library include directories. E.g. Professional. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("dir")] [Parameter(Mandatory=$true)] [string] $aSolutionsPath + , [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("parallel")] [Parameter(Mandatory=$false)][switch] $aUseParallelCompile + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("treat-sai")] [Parameter(Mandatory=$false)][switch] $aTreatAdditionalIncludesAsSystemIncludes + , [alias("clang-flags")] [Parameter(Mandatory=$true)] [string[]] $aClangCompileFlags + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("header-filter")][Parameter(Mandatory=$false)][string] $aTidyHeaderFilter + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + , [alias("vs-ver")] [Parameter(Mandatory=$true)] [string] $aVisualStudioVersion + , [alias("vs-sku")] [Parameter(Mandatory=$true)] [string] $aVisualStudioSku + ) + +# System Architecture Constants +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kLogicalCoreCount -value ` + (@(Get-WmiObject -class Win32_processor) | ` + ForEach-Object -Begin { $coreCount = 0 } ` + -Process { $coreCount += ($_ | Select-Object -property NumberOfLogicalProcessors ` + -ExpandProperty NumberOfLogicalProcessors) } ` + -End { $coreCount }) -option Constant +# ------------------------------------------------------------------------------------------------ +# Return Value Constants + +Set-Variable -name kScriptFailsExitCode -value 47 -option Constant + +# ------------------------------------------------------------------------------------------------ +# File System Constants + +Set-Variable -name kExtensionVcxproj -value ".vcxproj" -option Constant +Set-Variable -name kExtensionSolution -value ".sln" -option Constant +Set-Variable -name kExtensionClangPch -value ".clang.pch" -option Constant + +# ------------------------------------------------------------------------------------------------ +# Vcxproj Related Constants + +Set-Variable -name kVcxprojXpathPreprocessorDefs ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:PreprocessorDefinitions" ` + -option Constant + +Set-Variable -name kVcxprojXpathAdditionalIncludes ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:AdditionalIncludeDirectories" ` + -option Constant + +Set-Variable -name kVcxprojXpathHeaders ` + -value "ns:Project/ns:ItemGroup/ns:ClInclude" ` + -option Constant + +Set-Variable -name kVcxprojXpathCompileFiles ` + -value "ns:Project/ns:ItemGroup/ns:ClCompile" ` + -option Constant + +Set-Variable -name kVcxprojXpathWinPlatformVer ` + -value "ns:Project/ns:PropertyGroup/ns:WindowsTargetPlatformVersion" ` + -option Constant + +Set-Variable -name kVcxprojXpathForceIncludes ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:ForcedIncludeFiles" ` + -option Constant + +Set-Variable -name kVcxprojXpathPCH ` + -value "ns:Project/ns:ItemGroup/ns:ClCompile/ns:PrecompiledHeader[text()='Create']" ` + -option Constant + +Set-Variable -name kVcxprojXpathToolset ` + -value "ns:Project/ns:PropertyGroup[@Label='Configuration']/ns:PlatformToolset" ` + -option Constant + +Set-Variable -name kVcxprojXpathDefaultConfigPlatform ` + -value "ns:Project/ns:ItemGroup[@Label='ProjectConfigurations']/ns:ProjectConfiguration[1]" ` + -option Constant + +Set-Variable -name kVcxprojXpathConditionedElements ` + -value "//*[@Condition]" ` + -option Constant + +Set-Variable -name kVcxprojXpathChooseElements ` + -value "ns:Project//ns:Choose" ` + -option Constant + +Set-Variable -name kVcxprojXpathPropGroupElements ` + -value "ns:Project//ns:PropertyGroup/*" ` + -option Constant + +Set-Variable -name kVcxprojXpathCppStandard ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:LanguageStandard" ` + -option Constant + +Set-Variable -name kVSDefaultWinSDK -value '8.1' -option Constant +Set-Variable -name kVSDefaultWinSDK_XP -value '7.0' -option Constant + +# ------------------------------------------------------------------------------------------------ +# Clang-Related Constants + +Set-Variable -name kDefaultCppStd -value "stdcpp14" -option Constant +Set-Variable -name kClangFlagSupressLINK -value @("-fsyntax-only") -option Constant +Set-Variable -name kClangFlagWarningIsError -value @("-Werror") -option Constant +Set-Variable -name kClangFlagIncludePch -value "-include-pch" -option Constant +Set-Variable -name kClangFlagEmitPch -value "-emit-pch" -option Constant +Set-Variable -name kClangFlagMinusO -value "-o" -option Constant + +Set-Variable -name kClangDefinePrefix -value "-D" -option Constant +Set-Variable -name kClangFlagNoUnusedArg -value "-Wno-unused-command-line-argument" ` + -option Constant +Set-Variable -name kClangFlagNoMsInclude -value "-Wno-microsoft-include" ` + -Option Constant +Set-Variable -name kClangFlagFileIsCPP -value "-x c++" -option Constant +Set-Variable -name kClangFlagForceInclude -value "-include" -option Constant + +Set-Variable -name kClangCompiler -value "clang++.exe" -option Constant +Set-Variable -name kClangTidy -value "clang-tidy.exe" -option Constant +Set-Variable -name kClangTidyFlags -value @("-quiet" + ,"--") -option Constant +Set-Variable -name kClangTidyFixFlags -value @("-quiet" + ,"-fix-errors" + , "--") -option Constant +Set-Variable -name kClangTidyFlagHeaderFilter -value "-header-filter=" -option Constant +Set-Variable -name kClangTidyFlagChecks -value "-checks=" -option Constant +Set-Variable -name kClangTidyUseFile -value ".clang-tidy" -option Constant +Set-Variable -name kClangTidyFormatStyle -value "-format-style=" -option Constant + +# ------------------------------------------------------------------------------------------------ +# Default install locations of LLVM. If present there, we automatically use it + +Set-Variable -name kLLVMInstallLocations -value @("${Env:ProgramW6432}\LLVM\bin" + ,"${Env:ProgramFiles(x86)}\LLVM\bin" + ) -option Constant + +# ------------------------------------------------------------------------------------------------ +# Helpers for locating Visual Studio on the computer + +# VsWhere is available starting with Visual Studio 2017 version 15.2. +Set-Variable -name kVsWhereLocation ` + -value "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` + -option Constant + +# Default installation path of Visual Studio 2017. We'll use when VsWhere isn't available. +Set-Variable -name kVs15DefaultLocation ` + -value "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\$aVisualStudioVersion\$aVisualStudioSku" ` + -option Constant + +# Registry key containing information about Visual Studio 2015 installation path. +Set-Variable -name kVs2015RegistryKey ` + -value "HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0" ` + -option Constant + +#------------------------------------------------------------------------------------------------- +# PlatformToolset-Related Constants + +Set-Variable -name kDefinesUnicode -value @("-DUNICODE" + ,"-D_UNICODE" + ) ` + -option Constant + +Set-Variable -name kDefinesClangXpTargeting ` + -value @("-D_USING_V110_SDK71_") ` + -option Constant + + +Set-Variable -name kIncludePathsXPTargetingSDK ` + -value "${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v7.1A\Include" ` + -option Constant + +#------------------------------------------------------------------------------------------------- +# Custom Types + +Add-Type -TypeDefinition @" + public enum WorkloadType + { + Compile, + Tidy, + TidyFix + } +"@ + +Set-Variable -name kVStudioDefaultPlatformToolset -Value "v141" -option Constant + +Set-Variable -name "kMsbuildExpressionToPsRules" -option Constant ` + -value @(<# backticks are control characters in PS, replace them #> + ('`' , '''' )` + <# Temporarily replace $( #> ` + , ('\$\s*\(' , '!@#' )` + <# Escape $ #> ` + , ('\$' , '`$' )` + <# Put back $( #> ` + , ('!@#' , '$(' )` + <# Various operators #> ` + , ("([\s\)\'""])!=" , '$1 -ne ' )` + , ("([\s\)\'""])<=" , '$1 -le ' )` + , ("([\s\)\'""])>=" , '$1 -ge ' )` + , ("([\s\)\'""])==" , '$1 -eq ' )` + , ("([\s\)\'""])<" , '$1 -lt ' )` + , ("([\s\)\'""])>" , '$1 -gt ' )` + , ("([\s\)\'""])or" , '$1 -or ' )` + , ("([\s\)\'""])and" , '$1 -and ' )` + <# Use only double quotes #> ` + , ("\'" , '"' )` + , ("Exists\((.*?)\)(\s|$)" , '(Exists($1))$2' )` + , ("HasTrailingSlash\((.*?)\)(\s|$)" , '(HasTrailingSlash($1))$2' )` + , ("(\`$\()(Registry:)(.*?)(\))" , '$$(GetRegValue("$3"))' )` + ) + +Set-Variable -name "kMsbuildConditionToPsRules" -option Constant ` + -value @(<# Use only double quotes #> ` + ("\'" , '"' )` + <# We need to escape double quotes since we will eval() the condition #> ` + , ('"' , '""' )` + ) + +Set-Variable -name "kRedundantSeparatorsReplaceRules" -option Constant ` + -value @( <# handle multiple consecutive separators #> ` + (";+" , ";") ` + <# handle separator at end #> ` + , (";$" , "") ` + <# handle separator at beginning #> ` + , ("^;" , "") ` + ) + +#------------------------------------------------------------------------------------------------- +# Global variables + +# temporary files created during project processing (e.g. PCH files) +[System.Collections.ArrayList] $global:FilesToDeleteWhenScriptQuits = @() + +# vcxproj and property sheet files declare MsBuild properties (e.g. $(MYPROP)). +# they are used in project xml nodes expressions. we have a +# translation engine (MSBUILD-POWERSHELL) for these. it relies on +# PowerShell to evaluate these expressions. We have to inject project +# properties in the Powershell runtime context. We keep track of them in +# this list, to be cleaned before the next project begins processing +[System.Collections.ArrayList] $global:ProjectSpecificVariables = @() + +# flag to signal when errors are encounteres during project processing +[Boolean] $global:FoundErrors = $false + +# current vcxproj and property sheets +[xml[]] $global:projectFiles = @(); + +# path of current project +[string] $global:vcxprojPath = ""; + +# namespace of current project vcxproj XML +[System.Xml.XmlNamespaceManager] $global:xpathNS = $null; + +# filePath-fileData for SLN files located in source directory +[System.Collections.Generic.Dictionary[String,String]] $global:slnFiles = @{} + +#------------------------------------------------------------------------------------------------- +# Global functions + +Function Exit-Script([Parameter(Mandatory=$false)][int] $code = 0) +{ + Write-Verbose-Array -array $global:FilesToDeleteWhenScriptQuits ` + -name "Cleaning up PCH temporaries" + # Clean-up + foreach ($file in $global:FilesToDeleteWhenScriptQuits) + { + Remove-Item $file -ErrorAction SilentlyContinue | Out-Null + } + + # Restore working directory + Pop-Location + + exit $code +} + +Function Fail-Script([parameter(Mandatory=$false)][string] $msg = "Got errors.") +{ + if (![string]::IsNullOrEmpty($msg)) + { + Write-Err $msg + } + Exit-Script($kScriptFailsExitCode) +} + +Function Set-Var([parameter(Mandatory=$false)][string] $name, + [parameter(Mandatory=$false)][string] $value) +{ + Write-Verbose "SET_VAR $($name): $value" + Set-Variable -name $name -Value $value -Scope Global + + if (!$global:ProjectSpecificVariables.Contains($name)) + { + $global:ProjectSpecificVariables.Add($name) | Out-Null + } +} + +Function Clear-Vars() +{ + Write-Verbose-Array -array $global:ProjectSpecificVariables ` + -name "Deleting project specific variables" + + foreach ($var in $global:ProjectSpecificVariables) + { + Remove-Variable -name $var -scope Global -ErrorAction SilentlyContinue + } + + $global:ProjectSpecificVariables.Clear() +} + +Function Write-Message([parameter(Mandatory=$true)][string] $msg + ,[Parameter(Mandatory=$true)][System.ConsoleColor] $color) +{ + $foregroundColor = $host.ui.RawUI.ForegroundColor + $host.ui.RawUI.ForegroundColor = $color + Write-Output $msg + $host.ui.RawUI.ForegroundColor = $foregroundColor +} + +# Writes an error without the verbose powershell extra-info (script line location, etc.) +Function Write-Err([parameter(ValueFromPipeline, Mandatory=$true)][string] $msg) +{ + Write-Message -msg $msg -color Red +} + +Function Write-Success([parameter(ValueFromPipeline, Mandatory=$true)][string] $msg) +{ + Write-Message -msg $msg -color Green +} + +Function Write-Verbose-Array($array, $name) +{ + Write-Verbose "$($name):" + $array | ForEach-Object { Write-Verbose " $_" } +} + +Function Exists-Command([Parameter(Mandatory=$true)][string] $command) +{ + try + { + Get-Command -name $command -ErrorAction Stop + return $true + } + catch + { + return $false + } +} + +Function Get-FileDirectory([Parameter(Mandatory=$true)][string] $filePath) +{ + return ([System.IO.Path]::GetDirectoryName($filePath) + "\") +} + +Function Get-FileName( [Parameter(Mandatory=$true)][string] $path + , [Parameter(Mandatory=$false)][switch] $noext) +{ + if ($noext) + { + return ([System.IO.Path]::GetFileNameWithoutExtension($path)) + } + else + { + return ([System.IO.Path]::GetFileName($path)) + } +} + +Function IsFileMatchingName( [Parameter(Mandatory=$true)][string] $filePath + , [Parameter(Mandatory=$true)][string] $matchName) +{ + if ([System.IO.Path]::IsPathRooted($matchName)) + { + return $filePath -ieq $matchName + } + + [string] $fileName = (Get-FileName -path $filePath) + [string] $fileNameNoExt = (Get-FileName -path $filePath -noext) + if ($aDisableNameRegexMatching) + { + return (($fileName -eq $matchName) -or ($fileNameNoExt -eq $matchName)) + } + else + { + return (($fileName -match $matchName) -or ($fileNameNoExt -match $matchName)) + } +} + + <# + .DESCRIPTION + Merges an absolute and a relative file path. + .EXAMPLE + Havin base = C:\Windows\System32 and child = .. we get C:\Windows + .EXAMPLE + Havin base = C:\Windows\System32 and child = ..\..\..\.. we get C:\ (cannot go further up) + .PARAMETER base + The absolute path from which we start. + .PARAMETER child + The relative path to be merged into base. + .PARAMETER ignoreErrors + If this switch is not present, an error will be triggered if the resulting path + is not present on disk (e.g. c:\Windows\System33). + + If present and the resulting path does not exist, the function returns an empty string. + #> +Function Canonize-Path( [Parameter(Mandatory=$true)][string] $base + , [Parameter(Mandatory=$true)][string] $child + , [switch] $ignoreErrors) +{ + [string] $errorAction = If ($ignoreErrors) {"SilentlyContinue"} Else {"Stop"} + + if ([System.IO.Path]::IsPathRooted($child)) + { + if (!(Test-Path $child)) + { + return "" + } + return $child + } + else + { + [string[]] $paths = Join-Path -Path "$base" -ChildPath "$child" -Resolve -ErrorAction $errorAction + return $paths + } +} + +Function Get-SourceDirectory() +{ + [bool] $isDirectory = ($(Get-Item $aSolutionsPath) -is [System.IO.DirectoryInfo]) + if ($isDirectory) + { + return $aSolutionsPath + } + else + { + return (Get-FileDirectory -filePath $aSolutionsPath) + } +} + +function Load-Solutions() +{ + Write-Verbose "Scanning for solution files" + $slns = Get-ChildItem -recurse -LiteralPath "$aSolutionsPath" ` + | Where-Object { $_.Extension -eq $kExtensionSolution } + foreach ($sln in $slns) + { + $slnPath = $sln.FullName + $global:slnFiles[$slnPath] = (Get-Content $slnPath) + } + + Write-Verbose-Array -array $global:slnFiles.Keys -name "Solution file paths" +} + +function Get-SolutionProjects([Parameter(Mandatory=$true)][string] $slnPath) +{ + [string] $slnDirectory = Get-FileDirectory -file $slnPath + $matches = [regex]::Matches($global:slnFiles[$slnPath], 'Project\([{}\"A-Z0-9\-]+\) = \S+,\s(\S+),') + $projectAbsolutePaths = $matches ` + | ForEach-Object { Canonize-Path -base $slnDirectory ` + -child $_.Groups[1].Value.Replace('"','') -ignoreErrors } ` + | Where-Object { ! [string]::IsNullOrEmpty($_) -and $_.EndsWith($kExtensionVcxproj) } + return $projectAbsolutePaths +} + +function Get-ProjectSolution() +{ + foreach ($slnPath in $global:slnFiles.Keys) + { + [string[]] $solutionProjectPaths = Get-SolutionProjects $slnPath + if ($solutionProjectPaths -and $solutionProjectPaths -contains $global:vcxprojPath) + { + return $slnPath + } + } + return "" +} + +Function Get-MscVer() +{ + return ((Get-Item "$(Get-VisualStudio-Path)\VC\Tools\MSVC\" | Get-ChildItem) | select -last 1).Name +} + +Function InitializeMsBuildCurrentFileProperties([Parameter(Mandatory=$true)][string] $filePath) +{ + Set-Var -name "MSBuildThisFileFullPath" -value $filePath + Set-Var -name "MSBuildThisFileExtension" -value ([IO.Path]::GetExtension($filePath)) + Set-Var -name "MSBuildThisFile" -value (Get-FileName -path $filePath) + Set-Var -name "MSBuildThisFileName" -value (Get-FileName -path $filePath -noext) + Set-Var -name "MSBuildThisFileDirectory" -value (Get-FileDirectory -filePath $filePath) +} + +Function InitializeMsBuildProjectProperties() +{ + Write-Verbose "Importing environment variables into current scope" + foreach ($var in (Get-ChildItem Env:)) + { + Set-Var -name $var.Name -value $var.Value + } + + Set-Var -name "MSBuildProjectFullPath" -value $global:vcxprojPath + Set-Var -name "ProjectDir" -value (Get-FileDirectory -filePath $global:vcxprojPath) + Set-Var -name "MSBuildProjectExtension" -value ([IO.Path]::GetExtension($global:vcxprojPath)) + Set-Var -name "MSBuildProjectFile" -value (Get-FileName -path $global:vcxprojPath) + Set-Var -name "MSBuildProjectName" -value (Get-FileName -path $global:vcxprojPath -noext) + Set-Var -name "MSBuildProjectDirectory" -value (Get-FileDirectory -filePath $global:vcxprojPath) + Set-Var -name "MSBuildProgramFiles32" -value "${Env:ProgramFiles(x86)}" + # defaults for projectname and targetname, may be overriden by project settings + Set-Var -name "ProjectName" -value $MSBuildProjectName + Set-Var -name "TargetName" -value $MSBuildProjectName + + # These would enable full project platform references parsing, experimental right now + if ($env:CPT_LOAD_ALL -eq '1') + { + Set-Var -name "ConfigurationType" -value "Application" + Set-Var -name "VCTargetsPath" -value "$(Get-VisualStudio-Path)\Common7\IDE\VC\VCTargets\" + Set-Var -name "VsInstallRoot" -value (Get-VisualStudio-Path) + Set-Var -name "MSBuildExtensionsPath" -value "$(Get-VisualStudio-Path)\MSBuild" + Set-Var -name "LocalAppData" -value $env:LOCALAPPDATA + Set-Var -name "UserRootDir" -value "$LocalAppData\Microsoft\MSBuild\v4.0" + Set-Var -name "UniversalCRT_IncludePath" -value "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt" + } + + [string] $vsVer = "15.0" + if ($aVisualStudioVersion -eq "2015") + { + $vsVer = "14.0" + } + Set-Var -name "VisualStudioVersion" -value $vsVer + Set-Var -name "MSBuildToolsVersion" -value $vsVer + + [string] $projectSlnPath = Get-ProjectSolution + [string] $projectSlnDir = Get-FileDirectory -filePath $projectSlnPath + Set-Var -name "SolutionDir" -value $projectSlnDir +} + +Function Should-CompileProject([Parameter(Mandatory=$true)][string] $vcxprojPath) +{ + if ($aVcxprojToCompile -eq $null) + { + return $true + } + + foreach ($projMatch in $aVcxprojToCompile) + { + if (IsFileMatchingName -filePath $vcxprojPath -matchName $projMatch) + { + return $true + } + } + + return $false +} + +Function Should-IgnoreProject([Parameter(Mandatory=$true)][string] $vcxprojPath) +{ + if ($aVcxprojToIgnore -eq $null) + { + return $false + } + + foreach ($projIgnoreMatch in $aVcxprojToIgnore) + { + if (IsFileMatchingName -filePath $vcxprojPath -matchName $projIgnoreMatch) + { + return $true + } + } + + return $false +} + +Function Should-IgnoreFile([Parameter(Mandatory=$true)][string] $file) +{ + if ($aCppToIgnore -eq $null) + { + return $false + } + + foreach ($projIgnoreMatch in $aCppToIgnore) + { + if (IsFileMatchingName -filePath $file -matchName $projIgnoreMatch) + { + return $true + } + } + + return $false +} + +Function Get-ProjectFilesToCompile([Parameter(Mandatory=$false)][string] $pchCppName) +{ + [Boolean] $pchDisabled = [string]::IsNullOrEmpty($pchCppName) + + [string[]] $projectEntries = Select-ProjectNodes($kVcxprojXpathCompileFiles) | ` + Where-Object { ($_.Include -ne $null) -and + ($pchDisabled -or ($_.Include -ne $pchCppName)) + } | ` + Select-Object -Property "Include" -ExpandProperty "Include" + [string[]] $files = @() + foreach ($entry in $projectEntries) + { + [string[]] $matchedFiles = Canonize-Path -base $ProjectDir -child $entry + if ($matchedFiles.Count -gt 0) + { + $files += $matchedFiles + } + } + + if ($files.Count -gt 0) + { + $files = $files | Where-Object { ! (Should-IgnoreFile -file $_) } + } + + return $files +} + +Function Get-ProjectHeaders() +{ + [string[]] $headers = Select-ProjectNodes($kVcxprojXpathHeaders) | ForEach-Object {$_.Include } + + [string[]] $headerPaths = @() + + foreach ($headerEntry in $headers) + { + [string[]] $paths = Canonize-Path -base $ProjectDir -child $headerEntry -ignoreErrors + if ($paths.Count -gt 0) + { + $headerPaths += $paths + } + } + return $headerPaths +} + +Function Get-Project-SDKVer() +{ + [string] $sdkVer = (Select-ProjectNodes($kVcxprojXpathWinPlatformVer)).InnerText + + If ([string]::IsNullOrEmpty($sdkVer)) { "" } Else { $sdkVer.Trim() } +} + +Function Is-Project-Unicode() +{ + $propGroup = Select-ProjectNodes("ns:Project/ns:PropertyGroup[@Label='Configuration']") + + return ($propGroup.CharacterSet -eq "Unicode") +} + +Function Get-Project-CppStandard() +{ + [string] $cachedValueVarName = "ClangPowerTools:CppStd" + + [string] $cachedVar = (Get-Variable $cachedValueVarName -ErrorAction SilentlyContinue -ValueOnly) + if (![string]::IsNullOrEmpty($cachedVar)) + { + return $cachedVar + } + + [string] $cppStd = "" + + $cppStdNode = Select-ProjectNodes($kVcxprojXpathCppStandard) + if ($cppStdNode) + { + $cppStd = $cppStdNode.InnerText + } + else + { + $cppStd = $kDefaultCppStd + } + + $cppStdMap = @{ 'stdcpplatest' = 'c++1z' + ; 'stdcpp14' = 'c++14' + ; 'stdcpp17' = 'c++17' + } + + [string] $cppStdClangValue = $cppStdMap[$cppStd] + Set-Var -name $cachedValueVarName -value $cppStdClangValue + + return $cppStdClangValue +} + +Function Get-ClangCompileFlags() +{ + [string[]] $flags = $aClangCompileFlags + if (!($flags -match "-std=.*")) + { + [string] $cppStandard = Get-Project-CppStandard + + $flags = @("-std=$cppStandard") + $flags + } + + return $flags +} + +Function Get-ProjectPlatformToolset() +{ + $propGroup = Select-ProjectNodes($kVcxprojXpathToolset) + + $toolset = $propGroup.InnerText + + if ($toolset) + { + return $toolset + } + else + { + return $kVStudioDefaultPlatformToolset + } +} + +Function Get-VisualStudio-Includes([Parameter(Mandatory=$true)][string] $vsPath, + [Parameter(Mandatory=$false)][string] $mscVer) +{ + [string] $mscVerToken = "" + If (![string]::IsNullOrEmpty($mscVer)) + { + $mscVerToken = "Tools\MSVC\$mscVer\" + } + + return @( "$vsPath\VC\$($mscVerToken)include" + , "$vsPath\VC\$($mscVerToken)atlmfc\include" + ) +} + +Function Get-VisualStudio-Path() +{ + if ($aVisualStudioVersion -eq "2015") + { + $installLocation = (Get-Item $kVs2015RegistryKey).GetValue("InstallDir") + return Canonize-Path -base $installLocation -child "..\.." + } + else + { + if (Test-Path $kVsWhereLocation) + { + [string] $product = "Microsoft.VisualStudio.Product.$aVisualStudioSku" + return (& "$kVsWhereLocation" -nologo ` + -property installationPath ` + -products $product ` + -prerelease) + } + + if (Test-Path -Path $kVs15DefaultLocation) + { + return $kVs15DefaultLocation + } + + throw "Cannot locate Visual Studio location" + } +} + +Function Get-ProjectIncludeDirectories([Parameter(Mandatory=$false)][string] $stdafxDir) +{ + [string[]] $returnArray = ($IncludePath -split ";") | ` + Where-Object { ![string]::IsNullOrEmpty($_) } | ` + ForEach-Object { Canonize-Path -base $ProjectDir -child $_ -ignoreErrors } | ` + Where-Object { ![string]::IsNullOrEmpty($_) } | ` + ForEach-Object { $_ -replace '\\$', '' } + if ($env:CPT_LOAD_ALL -eq '1') + { + return $returnArray + } + + [string] $vsPath = Get-VisualStudio-Path + Write-Verbose "Visual Studio location: $vsPath" + + [string] $platformToolset = Get-ProjectPlatformToolset + + if ($aVisualStudioVersion -eq "2015") + { + $returnArray += Get-VisualStudio-Includes -vsPath $vsPath + } + else + { + $mscVer = Get-MscVer -visualStudioPath $vsPath + Write-Verbose "MSCVER: $mscVer" + + $returnArray += Get-VisualStudio-Includes -vsPath $vsPath -mscVer $mscVer + } + + $sdkVer = Get-Project-SDKVer + + # We did not find a WinSDK version in the vcxproj. We use Visual Studio's defaults + if ([string]::IsNullOrEmpty($sdkVer)) + { + if ($platformToolset.EndsWith("xp")) + { + $sdkVer = $kVSDefaultWinSDK_XP + } + else + { + $sdkVer = $kVSDefaultWinSDK + } + } + + Write-Verbose "WinSDK version: $sdkVer" + + # ---------------------------------------------------------------------------------------------- + # Windows 10 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("10"))) + { + $returnArray += @("${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\ucrt") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @($kIncludePathsXPTargetingSDK) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\um" + , "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\shared" + , "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\winrt" + ) + } + } + + # ---------------------------------------------------------------------------------------------- + # Windows 8 / 8.1 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("8."))) + { + $returnArray += @("${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @($kIncludePathsXPTargetingSDK) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\um" + , "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\shared" + , "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\winrt" + ) + } + } + + # ---------------------------------------------------------------------------------------------- + # Windows 7 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("7.0"))) + { + $returnArray += @("$vsPath\VC\Auxiliary\VS\include") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt" + , $kIncludePathsXPTargetingSDK + ) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\7.0\ucrt") + } + } + + if (![string]::IsNullOrEmpty($stdafxDir)) + { + $returnArray = @($stdafxDir) + $returnArray + } + + return ( $returnArray | ForEach-Object { $_ -replace '\\$', '' } ) +} + +Function Get-Projects() +{ + [string[]] $projects = @() + + foreach ($slnPath in $global:slnFiles.Keys) + { + [string[]] $solutionProjects = Get-SolutionProjects -slnPath $slnPath + if ($solutionProjects.Count -gt 0) + { + $projects += $solutionProjects + } + } + + return ($projects | Select -Unique); +} + +Function Get-PchCppIncludeHeader([Parameter(Mandatory=$true)][string] $pchCppFile) +{ + [string] $cppPath = Canonize-Path -base $ProjectDir -child $pchCppFile + [string] $fileContent = Get-Content -path $cppPath + + return [regex]::match($fileContent,'#include "(\S+)"').Groups[1].Value +} + +<# +.DESCRIPTION + Retrieve directory in which stdafx.h resides +#> +Function Get-ProjectStdafxDir([Parameter(Mandatory=$true)][string] $pchHeaderName) +{ + [string[]] $projectHeaders = Get-ProjectHeaders + [string] $stdafxPath = $projectHeaders | Where-Object { (Get-FileName -path $_) -cmatch $pchHeaderName } + if ([string]::IsNullOrEmpty($stdafxPath)) + { + $stdafxPath = Canonize-Path -base $ProjectDir ` + -child $pchHeaderName + } + + [string] $stdafxDir = Get-FileDirectory($stdafxPath) + + return $stdafxDir +} + +<# +.DESCRIPTION + Retrieve directory in which the PCH CPP resides (e.g. stdafx.cpp, stdafxA.cpp) +#> +Function Get-Project-PchCpp() +{ + $pchCppRelativePath = Select-ProjectNodes($kVcxprojXpathPCH) | + Select-Object -ExpandProperty ParentNode | + Select-Object -first 1 | + Select-Object -ExpandProperty Include + + return $pchCppRelativePath +} + +Function Get-ClangIncludeDirectories( [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + ) +{ + [string[]] $returnDirs = @() + + foreach ($includeDir in $includeDirectories) + { + $returnDirs += "-isystem""$includeDir""" + } + foreach ($includeDir in $additionalIncludeDirectories) + { + if ($aTreatAdditionalIncludesAsSystemIncludes) + { + $returnDirs += "-isystem""$includeDir""" + } + else + { + $returnDirs += "-I""$includeDir""" + } + } + + return $returnDirs +} + +Function Generate-Pch( [Parameter(Mandatory=$true)] [string] $stdafxDir + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$true)] [string] $stdafxHeaderName + , [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions) +{ + [string] $stdafx = (Canonize-Path -base $stdafxDir -child $stdafxHeaderName) + [string] $vcxprojShortName = [System.IO.Path]::GetFileNameWithoutExtension($global:vcxprojPath); + [string] $stdafxPch = (Join-Path -path (Get-SourceDirectory) ` + -ChildPath "$vcxprojShortName$kExtensionClangPch") + Remove-Item -Path "$stdafxPch" -ErrorAction SilentlyContinue | Out-Null + + $global:FilesToDeleteWhenScriptQuits.Add($stdafxPch) | Out-Null + + # Supress -Werror for PCH generation as it throws warnings quite often in code we cannot control + [string[]] $clangFlags = Get-ClangCompileFlags | Where-Object { $_ -ne $kClangFlagWarningIsError } + + [string[]] $compilationFlags = @("""$stdafx""" + ,$kClangFlagEmitPch + ,$kClangFlagMinusO + ,"""$stdafxPch""" + ,$clangFlags + ,$kClangFlagNoUnusedArg + ,$preprocessorDefinitions + ) + + $compilationFlags += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + Write-Verbose "INVOKE: ""$($global:llvmLocation)\$kClangCompiler"" $compilationFlags" + + [System.Diagnostics.Process] $processInfo = Start-Process -FilePath $kClangCompiler ` + -ArgumentList $compilationFlags ` + -WorkingDirectory "$(Get-SourceDirectory)" ` + -NoNewWindow ` + -Wait ` + -PassThru + if ($processInfo.ExitCode -ne 0) + { + Fail-Script "Errors encountered during PCH creation" + } + + return $stdafxPch +} + +function HasTrailingSlash([Parameter(Mandatory=$true)][string] $str) +{ + return $str.EndsWith('\') -or $str.EndsWith('/') +} + +function Exists([Parameter(Mandatory=$false)][string] $path) +{ + if ([string]::IsNullOrEmpty($path)) + { + return $false + } + + return Test-Path $path +} + +function GetRegValue([Parameter(Mandatory=$true)][string] $regPath) +{ + Write-Debug "REG_READ $regPath" + + [int] $separatorIndex = $regPath.IndexOf('@') + [string] $valueName = "" + if ($separatorIndex -gt 0) + { + [string] $valueName = $regPath.Substring($separatorIndex + 1) + $regPath = $regPath.Substring(0, $separatorIndex) + } + if ([string]::IsNullOrEmpty($valueName)) + { + throw "Cannot retrieve an empty registry value" + } + $regPath = $regPath -replace "HKEY_LOCAL_MACHINE\\", "HKLM:\" + + if (Test-Path $regPath) + { + return (Get-Item $regPath).GetValue($valueName) + } + else + { + return "" + } +} + +function Evaluate-MSBuildExpression([string] $expression, [switch] $isCondition) +{ + Write-Debug "Start evaluate MSBuild expression $expression" + + foreach ($rule in $kMsbuildExpressionToPsRules) + { + $expression = $expression -replace $rule[0], $rule[1] + } + + if ( !$isCondition -and ($expression.IndexOf('$') -lt 0)) + { + # we can stop here, further processing is not required + return $expression + } + + [int] $expressionStartIndex = -1 + [int] $openParantheses = 0 + for ([int] $i = 0; $i -lt $expression.Length; $i += 1) + { + if ($expression.Substring($i, 1) -eq '(') + { + if ($i -gt 0 -and $expressionStartIndex -lt 0 -and $expression.Substring($i - 1, 1) -eq '$') + { + $expressionStartIndex = $i - 1 + } + + if ($expressionStartIndex -ge 0) + { + $openParantheses += 1 + } + } + + if ($expression.Substring($i, 1) -eq ')' -and $expressionStartIndex -ge 0) + { + $openParantheses -= 1 + if ($openParantheses -lt 0) + { + throw "Parse error" + } + if ($openParantheses -eq 0) + { + [string] $content = $expression.Substring($expressionStartIndex + 2, + $i - $expressionStartIndex - 2) + [int] $initialLength = $content.Length + + if ([regex]::Match($content, "[a-zA-Z_][a-zA-Z0-9_\-]+").Value -eq $content) + { + # we have a plain property retrieval + $content = "`${$content}" + } + else + { + # dealing with a more complex expression + $content = $content -replace '(^|\s+|\$\()([a-zA-Z_][a-zA-Z0-9_]+)(\.|\)|$)', '$1$$$2$3' + } + + $newCond = $expression.Substring(0, $expressionStartIndex + 2) + + $content + $expression.Substring($i) + $expression = $newCond + + $i += ($content.Length - $initialLength) + $expressionStartIndex = -1 + } + } + } + + Write-Debug "Intermediate PS expression: $expression" + + try + { + [string] $toInvoke = "(`$s = ""$expression"")" + if ($isCondition) + { + $toInvoke = "(`$s = ""`$($expression)"")" + } + + $res = Invoke-Expression $toInvoke + } + catch + { + write-debug $_.Exception.Message + } + + Write-Debug "Evaluated expression to: $res" + + return $res +} +function Evaluate-MSBuildCondition([Parameter(Mandatory=$true)][string] $condition) +{ + Write-Debug "Evaluating condition $condition" + foreach ($rule in $kMsbuildConditionToPsRules) + { + $condition = $condition -replace $rule[0], $rule[1] + } + $expression = Evaluate-MSBuildExpression -expression $condition -isCondition + + if ($expression -ieq "true") + { + return $true + } + + if ($expression -ieq "false") + { + return $false + } + + [bool] $res = $false + try + { + $res = (Invoke-Expression $expression) -eq $true + } + catch + { + Write-Debug $_.Exception.Message + } + Write-Debug "Evaluated condition to $res" + + return $res +} + +<# +.DESCRIPTION +A wrapper over the XmlDOcument.SelectNodes function. For convenience. +Not to be used directly. Please use Select-ProjectNodes instead. +#> +function Help:Get-ProjectFileNodes([xml] $projectFile, [string] $xpath) +{ + [System.Xml.XmlElement[]] $nodes = $projectFile.SelectNodes($xpath, $global:xpathNS) + return $nodes +} + +function GetNodeInheritanceToken([System.Xml.XmlNode] $node) +{ + [string] $inheritanceToken = "%($($node.Name))"; + if ($node.InnerText.Contains($inheritanceToken)) + { + return $inheritanceToken + } + + return "" +} + +function ReplaceInheritedNodeValue([System.Xml.XmlNode] $currentNode + ,[System.Xml.XmlNode] $nodeToInheritFrom + ) +{ + [string] $inheritanceToken = GetNodeInheritanceToken($currentNode) + if ([string]::IsNullOrEmpty($inheritanceToken)) + { + # no need to inherit + return $false + } + + [string] $replaceWith = "" + if ($nodeToInheritFrom) + { + $replaceWith = $nodeToInheritFrom.InnerText + } + + [string] $whatToReplace = [regex]::Escape($inheritanceToken); + if ([string]::IsNullOrEmpty($replaceWith)) + { + # handle semicolon separators + [string] $escTok = [regex]::Escape($inheritanceToken) + $whatToReplace = "(;$escTok)|($escTok;)|($escTok)" + } + + # replace inherited token and redundant separators + $replacementRules = @(,($whatToReplace, $replaceWith)) + $kRedundantSeparatorsReplaceRules + foreach ($rule in $replacementRules) + { + $currentNode.InnerText = $currentNode.InnerText -replace $rule[0], $rule[1] + } + + return $currentNode.InnerText.Contains($inheritanceToken) +} + +<# +.SYNOPSIS +Selects one or more nodes from the project. +.DESCRIPTION +We often need to access data from the project, e.g. additional includes, Win SDK version. +A naive implementation would be to simply look inside the vcxproj, but that leaves out +property sheets. + +This function takes care to retrieve the nodes we're searching by looking in both the .vcxproj +and property sheets, taking care to inherit values accordingly. +.EXAMPLE +Give an example of how to use it +.EXAMPLE +Give another example of how to use it. +.PARAMETER xpath +XPath we want to use for searching nodes. +.PARAMETER fileIndex +Optional. Index of the project xml file we want to start our search in. +0 = .vcxproj and then, recursively, all property sheets +1 = first property sheet and then, recursively, all other property sheets +etc. +#> +function Select-ProjectNodes([Parameter(Mandatory=$true)] [string][string] $xpath + ,[Parameter(Mandatory=$false)] [int] $fileIndex = 0) +{ + [System.Xml.XmlElement[]] $nodes = @() + + if ($fileIndex -ge $global:projectFiles.Count) + { + return $nodes + } + + $nodes = Help:Get-ProjectFileNodes -projectFile $global:projectFiles[$fileIndex] ` + -xpath $xpath + + # nothing on this level or we're dealing with an ItemGroup, go above + if ($nodes.Count -eq 0 -or $xpath.Contains("ItemGroup")) + { + [System.Xml.XmlElement[]] $upperNodes = Select-ProjectNodes -xpath $xpath -fileIndex ($fileIndex + 1) + if ($upperNodes.Count -gt 0) + { + $nodes += $upperNodes + } + return $nodes + } + + if ($nodes[$nodes.Count -1]."#text") + { + # we found textual settings that can be inherited. see if we should inherit + + [System.Xml.XmlNode] $nodeToReturn = $nodes[$nodes.Count -1] + if ($nodeToReturn.Attributes.Count -gt 0) + { + throw "Did not expect node to have attributes" + } + + [bool] $shouldInheritMore = ![string]::IsNullOrEmpty((GetNodeInheritanceToken -node $nodeToReturn)) + for ([int] $i = $nodes.Count - 2; ($i -ge 0) -and $shouldInheritMore; $i -= 1) + { + $shouldInheritMore = ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $nodes[$i] + } + + if ($shouldInheritMore) + { + [System.Xml.XmlElement[]] $inheritedNodes = Select-ProjectNodes -xpath $xpath -fileIndex ($fileIndex + 1) + if ($inheritedNodes.Count -gt 1) + { + throw "Did not expect to inherit more than one node" + } + if ($inheritedNodes.Count -eq 1) + { + $shouldInheritMore = ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $inheritedNodes[0] + } + } + + # we still could have to inherit from parents but when not loading + # all MS prop sheets we have nothing to inherit from, delete inheritance token + ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $null | Out-Null + + return @($nodeToReturn) + } + else + { + # return what we found + return $nodes + } +} + +<# +.DESCRIPTION + Finds the first config-platform pair in the vcxproj. + We'll use it for all project data retrievals. + + Items for other config-platform pairs will be removed from the DOM. + This is needed so that our XPath selectors don't get confused when looking for data. +#> +function Detect-ProjectDefaultConfigPlatform([string] $projectValue) +{ + [string]$configPlatformName = "" + + if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) + { + $configPlatformName = $aVcxprojConfigPlatform + } + else + { + $configPlatformName = $projectValue + } + + if ([string]::IsNullOrEmpty($configPlatformName)) + { + throw "Could not automatically detect a configuration platform" + } + + [string[]] $configAndPlatform = $configPlatformName.Split('|') + Set-Var -Name "Configuration" -Value $configAndPlatform[0] + Set-Var -Name "Platform" -Value $configAndPlatform[1] +} + +function HandleChooseNode([System.Xml.XmlNode] $aChooseNode) +{ + SanitizeProjectNode $aChooseNode + if ($aChooseNode.ChildNodes.Count -eq 0) + { + return + } + + [System.Xml.XmlElement] $selectedChild = $aChooseNode.ChildNodes | ` + Where-Object { $_.GetType().Name -eq "XmlElement" } | ` + Select -first 1 + + foreach ($selectedGrandchild in $selectedChild.ChildNodes) + { + $aChooseNode.ParentNode.AppendChild($selectedGrandchild.Clone()) | Out-Null + } + + $aChooseNode.ParentNode.RemoveChild($aChooseNode) | Out-Null +} + +function SanitizeProjectNode([System.Xml.XmlNode] $node) +{ + if ($node.Name -ieq "#comment") + { + return + } + + [System.Collections.ArrayList] $nodesToRemove = @() + + if ($node.Name -ieq "#text" -and $node.InnerText.Length -gt 0) + { + # evaluate node content + $node.InnerText = Evaluate-MSBuildExpression $node.InnerText + } + + if ($node.Name -ieq "Import") + { + [string] $relPath = Evaluate-MSBuildExpression $node.GetAttribute("Project") + [string[]] $paths = Canonize-Path -base (Get-Location) -child $relPath -ignoreErrors + + foreach ($path in $paths) + { + if (![string]::IsNullOrEmpty($path) -and (Test-Path $path)) + { + Write-Verbose "Property sheet: $path" + SanitizeProjectFile($path) + } + else + { + Write-Verbose "Could not find property sheet $relPath" + } + } + } + + if ( ($node.Name -ieq "ClCompile" -or $node.Name -ieq "ClInclude") -and + ![string]::IsNullOrEmpty($node.GetAttribute("Include")) ) + { + [string] $expandedAttr = Evaluate-MSBuildExpression $node.GetAttribute("Include") + $node.Attributes["Include"].Value = $expandedAttr + } + + if ($node.Name -ieq "Choose") + { + HandleChooseNode $chooseChild + } + + if ($node.Name -ieq "Otherwise") + { + [System.Xml.XmlElement[]] $siblings = $node.ParentNode.ChildNodes | ` + Where-Object { $_.GetType().Name -ieq "XmlElement" -and $_ -ne $node } + if ($siblings.Count -gt 0) + { + # means there's a element that matched + # should not be evaluated, we could set unwated properties + return + } + } + + if ($node.Name -ieq "ItemGroup" -and $node.GetAttribute("Label") -ieq "ProjectConfigurations") + { + Detect-ProjectDefaultConfigPlatform $node.ChildNodes[0].GetAttribute("Include") + } + + if ($node.ParentNode.Name -ieq "PropertyGroup") + { + # set new property value + [string] $propertyName = $node.Name + [string] $propertyValue = Evaluate-MSBuildExpression $node.InnerText + + Set-Var -Name $propertyName -Value $propertyValue + + return + } + + foreach ($child in $node.ChildNodes) + { + [bool] $validChild = $true + if ($child.GetType().Name -ieq "XmlElement") + { + if ($child.HasAttribute("Condition")) + { + # process node condition + [string] $nodeCondition = $child.GetAttribute("Condition") + $validChild = ((Evaluate-MSBuildCondition($nodeCondition)) -eq $true) + if ($validChild) + { + $child.RemoveAttribute("Condition") + } + } + } + if (!$validChild) + { + $nodesToRemove.Add($child) | out-null + continue + } + else + { + SanitizeProjectNode($child) + } + } + + foreach ($nodeToRemove in $nodesToRemove) + { + $nodeToRemove.ParentNode.RemoveChild($nodeToRemove) | out-null + } +} + +<# +.DESCRIPTION + Sanitizes a project xml file, by removing config-platform pairs different from the + one we selected. + This is needed so that our XPath selectors don't get confused when looking for data. +#> +function SanitizeProjectFile([string] $projectFilePath) +{ + Write-Verbose "`nSanitizing $projectFilePath" + + [xml] $fileXml = Get-Content $projectFilePath + $global:projectFiles += @($fileXml) + $global:xpathNS = New-Object System.Xml.XmlNamespaceManager($fileXml.NameTable) + $global:xpathNS.AddNamespace("ns", $fileXml.DocumentElement.NamespaceURI) + + Push-Location (Get-FileDirectory -filePath $projectFilePath) + + InitializeMsBuildCurrentFileProperties -filePath $projectFilePath + SanitizeProjectNode($fileXml.Project) + + Pop-Location +} + +<# +.DESCRIPTION + Tries to find a Directory.Build.props property sheet, starting from the + project directories, going up. When one is found, the search stops. + + Multiple Directory.Build.props sheets are not supported. +#> +function Get-AutoPropertySheet() +{ + $startPath = $global:vcxprojPath + while ($true) + { + $propSheetPath = Canonize-Path -base $startPath ` + -child "Directory.Build.props" ` + -ignoreErrors + if (![string]::IsNullOrEmpty($propSheetPath)) + { + return $propSheetPath + } + + $newPath = Canonize-Path -base $startPath -child ".." + if ($newPath -eq $startPath) + { + return "" + } + $startPath = $newPath + } +} + +<# +.DESCRIPTION +Loads vcxproj and property sheets into memory. This needs to be called only once +when processing a project. Accessing project nodes can be done using Select-ProjectNodes. +#> +function LoadProject([string] $vcxprojPath) +{ + $global:vcxprojPath = $vcxprojPath + + InitializeMsBuildProjectProperties + + # see if we can find a Directory.Build.props automatic prop sheet + [string[]] $propSheetAbsolutePaths = @() + [xml[]] $autoPropSheetXmls = $null + $autoPropSheet = Get-AutoPropertySheet + if (![string]::IsNullOrEmpty($autoPropSheet)) + { + SanitizeProjectFile -projectFilePath $autoPropSheet + $autoPropSheetXmls = $global:projectFiles + } + + # the auto-prop sheet has to be last in the node retrieval sources + # but properties defined in it have to be accessible in all project files :( + $global:projectFiles = @() + + SanitizeProjectFile -projectFilePath $global:vcxprojPath + + if ($autoPropSheetXml) + { + $global:projectFiles += $autoPropSheetXmls + } +} + +<# +.DESCRIPTION + Retrieve array of preprocessor definitions for a given project, in Clang format (-DNAME ) +#> +Function Get-ProjectPreprocessorDefines() +{ + [string[]] $tokens = (Select-ProjectNodes $kVcxprojXpathPreprocessorDefs).InnerText -split ";" + + # make sure we add the required prefix and escape double quotes + [string[]]$defines = ( $tokens | ` + Where-Object { $_ } | ` + ForEach-Object { '"' + $(($kClangDefinePrefix + $_) -replace '"','\"') + '"' } ) + + if (Is-Project-Unicode) + { + $defines += $kDefinesUnicode + } + + [string] $platformToolset = Get-ProjectPlatformToolset + if ($platformToolset.EndsWith("xp")) + { + $defines += $kDefinesClangXpTargeting + } + + return $defines +} + +Function Get-ProjectAdditionalIncludes() +{ + [string[]] $tokens = @() + + $data = Select-ProjectNodes $kVcxprojXpathAdditionalIncludes + $tokens += ($data).InnerText -split ";" + + foreach ($token in $tokens) + { + if ([string]::IsNullOrEmpty($token)) + { + continue + } + + [string] $includePath = Canonize-Path -base $ProjectDir -child $token -ignoreErrors + if (![string]::IsNullOrEmpty($includePath)) + { + $includePath -replace '\\$', '' + } + } +} + +Function Get-ProjectForceIncludes() +{ + [System.Xml.XmlElement] $forceIncludes = Select-ProjectNodes $kVcxprojXpathForceIncludes + if ($forceIncludes) + { + return $forceIncludes.InnerText -split ";" + } + + return $null +} + +Function Get-ExeToCall([Parameter(Mandatory=$true)][WorkloadType] $workloadType) +{ + switch ($workloadType) + { + "Compile" { return $kClangCompiler } + "Tidy" { return $kClangTidy } + "TidyFix" { return $kClangTidy } + } +} + +Function Get-CompileCallArguments( [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$true)][string] $fileToCompile) +{ + [string[]] $projectCompileArgs = @() + if (! [string]::IsNullOrEmpty($pchFilePath)) + { + $projectCompileArgs += @($kClangFlagIncludePch , """$pchFilePath""") + } + + $projectCompileArgs += @( $kClangFlagFileIsCPP + , """$fileToCompile""" + , @(Get-ClangCompileFlags) + , $kClangFlagSupressLINK + , $preprocessorDefinitions + ) + + $projectCompileArgs += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + if ($forceIncludeFiles) + { + $projectCompileArgs += $kClangFlagNoMsInclude; + + foreach ($file in $forceIncludeFiles) + { + $projectCompileArgs += "$kClangFlagForceInclude $file" + } + } + + return $projectCompileArgs +} + +Function Get-TidyCallArguments( [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$true)][string] $fileToTidy + , [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$false)][switch] $fix) +{ + [string[]] $tidyArgs = @("""$fileToTidy""") + if ($fix -and $aTidyFixFlags -ne $kClangTidyUseFile) + { + $tidyArgs += "$kClangTidyFlagChecks$aTidyFixFlags" + } + elseif ($aTidyFlags -ne $kClangTidyUseFile) + { + $tidyArgs += "$kClangTidyFlagChecks$aTidyFlags" + } + + # The header-filter flag enables clang-tidy to run on headers too. + if (![string]::IsNullOrEmpty($aTidyHeaderFilter)) + { + if ($aTidyHeaderFilter -eq '_') + { + [string] $fileNameMatch = """$(Get-FileName -path $fileToTidy -noext).*""" + $tidyArgs += "$kClangTidyFlagHeaderFilter$fileNameMatch" + } + else + { + $tidyArgs += "$kClangTidyFlagHeaderFilter""$aTidyHeaderFilter""" + } + } + + if ($fix) + { + if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) + { + $tidyArgs += "$kClangTidyFormatStyle$aAfterTidyFixFormatStyle" + } + + $tidyArgs += $kClangTidyFixFlags + } + else + { + $tidyArgs += $kClangTidyFlags + } + + $tidyArgs += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + # We reuse flags used for compilation and preprocessor definitions. + $tidyArgs += @(Get-ClangCompileFlags) + $tidyArgs += $preprocessorDefinitions + $tidyArgs += $kClangFlagFileIsCPP + + if (! [string]::IsNullOrEmpty($pchFilePath)) + { + $tidyArgs += @($kClangFlagIncludePch , """$pchFilePath""") + } + + if ($forceIncludeFiles) + { + $tidyArgs += $kClangFlagNoMsInclude; + + foreach ($file in $forceIncludeFiles) + { + $tidyArgs += "$kClangFlagForceInclude $file" + } + } + + return $tidyArgs +} + +Function Get-ExeCallArguments( [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$true) ][string] $currentFile + , [Parameter(Mandatory=$true) ][WorkloadType] $workloadType) +{ + switch ($workloadType) + { + Compile { return Get-CompileCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToCompile $currentFile } + Tidy { return Get-TidyCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToTidy $currentFile } + TidyFix { return Get-TidyCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToTidy $currentFile ` + -fix} + } +} + +Function Process-ProjectResult($compileResult) +{ + if (!$compileResult.Success) + { + Write-Err ($compileResult.Output) + + if (!$aContinueOnError) + { + # Wait for other workers to finish. They have a lock on the PCH file + Get-Job -state Running | Wait-Job | Remove-Job | Out-Null + Fail-Script + } + + $global:FoundErrors = $true + } + else + { + if ( $compileResult.Output.Length -gt 0) + { + Write-Output $compileResult.Output + } + } +} + +Function Wait-AndProcessBuildJobs([switch]$any) +{ + $runningJobs = @(Get-Job -state Running) + + if ($any) + { + $runningJobs | Wait-Job -Any | Out-Null + } + else + { + $runningJobs | Wait-Job | Out-Null + } + + $jobData = Get-Job -State Completed + foreach ($job in $jobData) + { + $buildResult = Receive-Job $job + Process-ProjectResult -compileResult $buildResult + } + + Remove-Job -State Completed +} + +Function Wait-ForWorkerJobSlot() +{ + # We allow as many background workers as we have logical CPU cores + $runningJobs = @(Get-Job -State Running) + + if ($runningJobs.Count -ge $kLogicalCoreCount) + { + Wait-AndProcessBuildJobs -any + } +} + +Function Run-ClangJobs([Parameter(Mandatory=$true)] $clangJobs) +{ + # Script block (lambda) for logic to be used when running a clang job. + $jobWorkToBeDone = ` + { + param( $job ) + + Push-Location $job.WorkingDirectory + + $callOutput = & $job.FilePath $job.ArgumentList.Split(' ') 2>&1 |` + ForEach-Object { $_.ToString() } |` + Out-String + + $callSuccess = $LASTEXITCODE -eq 0 + + Pop-Location + + return New-Object PsObject -Prop @{ "File" = $job.File; + "Success" = $callSuccess; + "Output" = $callOutput } + } + + [int] $jobCount = $clangJobs.Count + [int] $crtJobCount = $jobCount + + foreach ($job in $clangJobs) + { + # Check if we must wait for background jobs to complete + Wait-ForWorkerJobSlot + + # Inform console what CPP we are processing next + Write-Output "$($crtJobCount): $($job.File)" + + if ($aUseParallelCompile) + { + Start-Job -ScriptBlock $jobWorkToBeDone ` + -ArgumentList $job ` + -ErrorAction Continue | Out-Null + } + else + { + $compileResult = Invoke-Command -ScriptBlock $jobWorkToBeDone ` + -ArgumentList $job + Process-ProjectResult -compileResult $compileResult + } + + $crtJobCount -= 1 + } + + Wait-AndProcessBuildJobs +} + +Function Process-Project( [Parameter(Mandatory=$true)][string] $vcxprojPath + , [Parameter(Mandatory=$true)][WorkloadType] $workloadType) +{ + # Load data + LoadProject($vcxprojPath) + + #----------------------------------------------------------------------------------------------- + # FIND FORCE INCLUDES + + [string[]] $forceIncludeFiles = Get-ProjectForceIncludes + Write-Verbose "Force includes: $forceIncludeFiles" + + #----------------------------------------------------------------------------------------------- + # LOCATE STDAFX.H DIRECTORY + + [string] $stdafxCpp = Get-Project-PchCpp + [string] $stdafxDir = "" + [string] $stdafxHeader = "" + + if (![string]::IsNullOrEmpty($stdafxCpp)) + { + Write-Verbose "PCH cpp name: $stdafxCpp" + + if ($forceIncludeFiles.Count -gt 0) + { + $stdafxHeader = $forceIncludeFiles[0] + } + else + { + $stdafxHeader = Get-PchCppIncludeHeader -pchCppFile $stdafxCpp + } + + Write-Verbose "PCH header name: $stdafxHeader" + $stdafxDir = Get-ProjectStdafxDir -pchHeaderName $stdafxHeader + } + + if ([string]::IsNullOrEmpty($stdafxDir)) + { + Write-Verbose ("PCH not enabled for this project!") + } + else + { + Write-Verbose ("PCH directory: $stdafxDir") + } + #----------------------------------------------------------------------------------------------- + # DETECT PROJECT PREPROCESSOR DEFINITIONS + + [string[]] $preprocessorDefinitions = Get-ProjectPreprocessorDefines + if ($aVisualStudioVersion -eq "2017") + { + # [HACK] pch generation crashes on VS 15.5 because of STL library, known bug. + # Triggered by addition of line directives to improve std::function debugging. + # There's a definition that supresses line directives. + + [string] $mscVer = Get-MscVer -visualStudioPath $vsPath + if ($mscVer -eq "14.12.25827") + { + $preprocessorDefinitions += "-D_DEBUG_FUNCTIONAL_MACHINERY" + } + } + + Write-Verbose-Array -array $preprocessorDefinitions -name "Preprocessor definitions" + + #----------------------------------------------------------------------------------------------- + # DETECT PLATFORM TOOLSET + + [string] $platformToolset = Get-ProjectPlatformToolset + Write-Verbose "Platform toolset: $platformToolset" + + #----------------------------------------------------------------------------------------------- + # DETECT PROJECT ADDITIONAL INCLUDE DIRECTORIES AND CONSTRUCT INCLUDE PATHS + + [string[]] $additionalIncludeDirectories = Get-ProjectAdditionalIncludes + Write-Verbose-Array -array $additionalIncludeDirectories -name "Additional include directories" + + [string[]] $includeDirectories = Get-ProjectIncludeDirectories -stdafxDir $stdafxDir + Write-Verbose-Array -array $includeDirectories -name "Include directories" + + #----------------------------------------------------------------------------------------------- + # FIND LIST OF CPPs TO PROCESS + + [string[]] $projCpps = Get-ProjectFilesToCompile -pchCppName $stdafxCpp + + if (![string]::IsNullOrEmpty($aCppToCompile)) + { + $projCpps = ( $projCpps | + Where-Object { IsFileMatchingName -filePath $_ ` + -matchName $aCppToCompile } ) + } + Write-Verbose ("Processing " + $projCpps.Count + " cpps") + + #----------------------------------------------------------------------------------------------- + # CREATE PCH IF NEED BE, ONLY FOR TWO CPPS OR MORE + + [string] $pchFilePath = "" + if ($projCpps.Count -ge 2 -and + ![string]::IsNullOrEmpty($stdafxDir)) + { + # COMPILE PCH + Write-Verbose "Generating PCH..." + $pchFilePath = Generate-Pch -stdafxDir $stdafxDir ` + -stdafxHeaderName $stdafxHeader ` + -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + Write-Verbose "PCH: $pchFilePath" + } + + #----------------------------------------------------------------------------------------------- + # PROCESS CPP FILES. CONSTRUCT COMMAND LINE JOBS TO BE INVOKED + + $clangJobs = @() + + foreach ($cpp in $projCpps) + { + [string] $exeToCall = Get-ExeToCall -workloadType $workloadType + + [string] $exeArgs = Get-ExeCallArguments -workloadType $workloadType ` + -pchFilePath $pchFilePath ` + -preprocessorDefinitions $preprocessorDefinitions ` + -forceIncludeFiles $forceIncludeFiles ` + -currentFile $cpp ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + $newJob = New-Object PsObject -Prop @{ 'FilePath' = $exeToCall; + 'WorkingDirectory'= Get-SourceDirectory; + 'ArgumentList' = $exeArgs; + 'File' = $cpp } + $clangJobs += $newJob + } + + #----------------------------------------------------------------------------------------------- + # PRINT DIAGNOSTICS + + if ($clangJobs.Count -ge 1) + { + Write-Verbose "INVOKE: ""$($global:llvmLocation)\$exeToCall"" $($clangJobs[0].ArgumentList)" + } + + #----------------------------------------------------------------------------------------------- + # RUN CLANG JOBS + + Run-ClangJobs -clangJobs $clangJobs + + #----------------------------------------------------------------------------------------------- + # CLEAN GLOBAL VARIABLES SPECIFIC TO CURRENT PROJECT + + Clear-Vars +} + +#------------------------------------------------------------------------------------------------- +# Script entry point + +Clear-Host # clears console + +#------------------------------------------------------------------------------------------------- +# Print script parameters + +$bParams = $PSCmdlet.MyInvocation.BoundParameters +if ($bParams) +{ + [string] $paramStr = "clang-build.ps1 invocation args: `n" + foreach ($key in $bParams.Keys) + { + $paramStr += " $($key) = $($bParams[$key]) `n" + } + Write-Verbose $paramStr +} + +#------------------------------------------------------------------------------------------------- +# Script entry point + +Write-Verbose "CPU logical core count: $kLogicalCoreCount" + +# If LLVM is not in PATH try to detect it automatically +if (! (Exists-Command($kClangCompiler)) ) +{ + foreach ($locationLLVM in $kLLVMInstallLocations) + { + if (Test-Path $locationLLVM) + { + Write-Verbose "LLVM location: $locationLLVM" + $env:Path += ";$locationLLVM" + $global:llvmLocation = $locationLLVM + break + } + } +} + +Push-Location (Get-SourceDirectory) + +# fetch .sln paths and data +Load-Solutions + +# This powershell process may already have completed jobs. Discard them. +Remove-Job -State Completed + +Write-Verbose "Source directory: $(Get-SourceDirectory)" +Write-Verbose "Scanning for project files" + +[System.IO.FileInfo[]] $projects = Get-Projects +Write-Verbose ("Found $($projects.Count) projects") + +[System.IO.FileInfo[]] $projectsToProcess = @() + +if ([string]::IsNullOrEmpty($aVcxprojToCompile) -and + [string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + Write-Verbose "PROCESSING ALL PROJECTS" + $projectsToProcess = $projects +} +else +{ + $projectsToProcess = $projects | + Where-Object { (Should-CompileProject -vcxprojPath $_.FullName) ` + -and !(Should-IgnoreProject -vcxprojPath $_.FullName ) } + + if ($projectsToProcess.Count -gt 1) + { + Write-Output ("PROJECTS: `n`t" + ($projectsToProcess -join "`n`t")) + $projectsToProcess = $projectsToProcess + } + + if ($projectsToProcess.Count -eq 0) + { + Write-Err "Cannot find given project" + } +} + +$projectCounter = $projectsToProcess.Length; +foreach ($project in $projectsToProcess) +{ + [string] $vcxprojPath = $project.FullName; + + [WorkloadType] $workloadType = [WorkloadType]::Compile + + if (![string]::IsNullOrEmpty($aTidyFlags)) + { + $workloadType = [WorkloadType]::Tidy + } + + if (![string]::IsNullOrEmpty($aTidyFixFlags)) + { + $workloadType = [WorkloadType]::TidyFix + } + + Write-Output ("`nPROJECT$(if ($projectCounter -gt 1) { " #$projectCounter" } else { } ): " + $vcxprojPath) + Process-Project -vcxprojPath $vcxprojPath -workloadType $workloadType + + $projectCounter -= 1 +} + +if ($global:FoundErrors) +{ + Fail-Script +} +else +{ + Exit-Script +} \ No newline at end of file diff --git a/scripts/msbuild_translation_tests.ps1 b/scripts/msbuild_translation_tests.ps1 new file mode 100644 index 0000000000..0340cf2eed --- /dev/null +++ b/scripts/msbuild_translation_tests.ps1 @@ -0,0 +1,334 @@ +# Tests for ClangPowerTools MSBUILD Expression/Condition translation + +$Configuration = "Release2" +$Platform = "Win32" +$UserRootDir = "c:\test" +$SolutionDir = "C:\AI Trunk\ClangPowerToolsProblem" +$ProjectDir = "C:\AI Trunk\win" +$TargetName = "YOLOTest" +$varB = 1 + +# ------------------------------------------------------------------------------------------------------------------- + +Set-Variable -name "kMsbuildExpressionToPsRules" -option Constant ` + -value @(<# backticks are control characters in PS, replace them #> + ('`' , '''' )` + <# Temporarily replace $( #> ` + , ('\$\s*\(' , '!@#' )` + <# Escape $ #> ` + , ('\$' , '`$' )` + <# Put back $( #> ` + , ('!@#' , '$(' )` + <# Various operators #> ` + , ("([\s\)\'""])!=" , '$1 -ne ' )` + , ("([\s\)\'""])<=" , '$1 -le ' )` + , ("([\s\)\'""])>=" , '$1 -ge ' )` + , ("([\s\)\'""])==" , '$1 -eq ' )` + , ("([\s\)\'""])<" , '$1 -lt ' )` + , ("([\s\)\'""])>" , '$1 -gt ' )` + , ("([\s\)\'""])or" , '$1 -or ' )` + , ("([\s\)\'""])and" , '$1 -and ' )` + <# Use only double quotes #> ` + , ("\'" , '"' )` + , ("Exists\((.*?)\)(\s|$)" , '(Exists($1))$2' )` + , ("HasTrailingSlash\((.*?)\)(\s|$)" , '(HasTrailingSlash($1))$2' )` + , ("(\`$\()(Registry:)(.*?)(\))" , '$$(GetRegValue("$3"))' )` + ) + +Set-Variable -name "kMsbuildConditionToPsRules" -option Constant ` + -value @(<# Use only double quotes #> ` + ("\'" , '"' )` + <# We need to escape double quotes since we will eval() the condition #> ` + , ('"' , '""' )` + ) + +function GetRegValue([Parameter(Mandatory=$true)][string] $regPath) +{ + [int] $separatorIndex = $regPath.IndexOf('@') + [string] $valueName = "" + if ($separatorIndex -gt 0) + { + [string] $valueName = $regPath.Substring($separatorIndex + 1) + $regPath = $regPath.Substring(0, $separatorIndex) + } + if ([string]::IsNullOrEmpty($valueName)) + { + throw "Cannot retrieve an empty registry value" + } + $regPath = $regPath -replace "HKEY_LOCAL_MACHINE\\", "HKLM:\" + + if (Test-Path $regPath) + { + return (Get-Item $regPath).GetValue($valueName) + } + else + { + return "" + } +} + +function HasTrailingSlash([Parameter(Mandatory=$true)][string] $str) +{ + return $str.EndsWith('\') -or $str.EndsWith('/') +} + +function Exists([Parameter(Mandatory=$false)][string] $path) +{ + if ([string]::IsNullOrEmpty($path)) + { + return $false + } + return Test-Path $path +} + +function Evaluate-MSBuildExpression([string] $expression, [switch] $isCondition) +{ + Write-Debug "Start evaluate MSBuild expression $expression" + + foreach ($rule in $kMsbuildExpressionToPsRules) + { + $expression = $expression -replace $rule[0], $rule[1] + } + + if ( !$isCondition -and ($expression.IndexOf('$') -lt 0)) + { + # we can stop here, further processing is not required + return $expression + } + + [int] $expressionStartIndex = -1 + [int] $openParantheses = 0 + for ([int] $i = 0; $i -lt $expression.Length; $i += 1) + { + if ($expression.Substring($i, 1) -eq '(') + { + if ($i -gt 0 -and $expressionStartIndex -lt 0 -and $expression.Substring($i - 1, 1) -eq '$') + { + $expressionStartIndex = $i - 1 + } + + if ($expressionStartIndex -ge 0) + { + $openParantheses += 1 + } + } + + if ($expression.Substring($i, 1) -eq ')' -and $expressionStartIndex -ge 0) + { + $openParantheses -= 1 + if ($openParantheses -lt 0) + { + throw "Parse error" + } + if ($openParantheses -eq 0) + { + [string] $content = $expression.Substring($expressionStartIndex + 2, + $i - $expressionStartIndex - 2) + [int] $initialLength = $content.Length + + if ([regex]::Match($content, "[a-zA-Z_][a-zA-Z0-9_\-]+").Value -eq $content) + { + # we have a plain property retrieval + $content = "`${$content}" + } + else + { + # dealing with a more complex expression + $content = $content -replace '(^|\s+|\$\()([a-zA-Z_][a-zA-Z0-9_]+)(\.|\)|$)', '$1$$$2$3' + } + + $newCond = $expression.Substring(0, $expressionStartIndex + 2) + + $content + $expression.Substring($i) + $expression = $newCond + + $i += ($content.Length - $initialLength) + $expressionStartIndex = -1 + } + } + } + + Write-Debug "Intermediate PS expression: $expression" + + try + { + [string] $toInvoke = "(`$s = ""$expression"")" + if ($isCondition) + { + $toInvoke = "(`$s = ""`$($expression)"")" + } + + $res = Invoke-Expression $toInvoke + } + catch + { + write-debug $_.Exception.Message + } + + Write-Debug "Evaluated expression to: $res" + + return $res +} + +function Evaluate-MSBuildCondition([Parameter(Mandatory=$true)][string] $condition) +{ + Write-Debug "Evaluating condition $condition" + foreach ($rule in $kMsbuildConditionToPsRules) + { + $condition = $condition -replace $rule[0], $rule[1] + } + $expression = Evaluate-MSBuildExpression -expression $condition -isCondition + + if ($expression -ieq "true") + { + return $true + } + + if ($expression -ieq "false") + { + return $false + } + + [bool] $res = $false + try + { + $res = (Invoke-Expression $expression) -eq $true + } + catch + { + Write-Debug $_.Exception.Message + } + Write-Debug "Evaluated condition to $res" + + return $res +} + +Clear-Host + +function Test-Condition([string] $condition, [bool]$expectation, [switch] $expectFailure) +{ + [boolean] $condValue + try + { + $condValue = Evaluate-MSBuildCondition $condition + } + catch + { + if ($expectFailure) + { + Write-Output "TEST OK" + return + } + else + { + Write-Output $_.Exception.Message + throw "Test failed" + } + } + + if ($condValue -ne $expectation) + { + Write-Output "Expected $expectation | Got $condValue" + throw "Test failed" + } + Write-Output "TEST OK" +} + +function Test-Expression($expresion) +{ + $res = Evaluate-MSBuildExpression $expresion + Write-output $res +} +# ---------------------------------------------------------------------------- + +Test-Condition "'`$(ImportDirectoryBuildProps)' == 'true' and exists('`$(DirectoryBuildPropsPath)')" -expectation $false + +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\15.0\AD7Metrics\ExpressionEvaluator\{3A12D0B7-C26C-11D0-B442-00A0244A1DD2}\{994B45C4-E6E9-11D2-903F-00C04FA302A1}@LoadInShimManagedEE)' +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)' +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)' + +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)' +Test-Expression '$(GetRegValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder"))' + + +Test-Condition "'`$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)' != ''" ` + -expectation $true + +Test-Condition "'`$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vs\Servicing\11.0\professional@Version)' == ''" ` + -expectation $true + + +Test-Condition -condition "'`$(Configuration)|`$(Platform)'=='Debug|Win32' or '`$(Configuration)' == 'Release2'" ` + -expectation $true + +Test-Condition -condition "'`$(Platform)'=='x64' or '`$(Platform)'=='Win32' or '`$(Platform)'=='Durango' or exists('`$(UserRootDir)\Microsoft.Cpp.`$(Platform).user.props2')"` + -expectation $true + +Test-Condition -condition "exists('c:\ai trunk')"` + -expectation $true + +Test-Condition -condition "'`$(Configuration)|`$(Platform)'=='Release|Win32'"` + -expectation $false + +Test-Condition -condition '$(Platform.Replace(" ", "")) and $(testB)'` + -expectation $false + +Test-Condition -condition '$(Platform) and $(varB)'` + -expectation $true + +Test-Condition -condition "exists('`$(UserRootDir)\Microsoft.Cpp.`$(Platform).user.props')"` + -expectation $true + +Test-Expression -expression "`$(SolutionDir)\Tools\PropertySheets\Evolution.Module.props" +Test-Expression -expresion "WIN32_LEAN_AND_MEAN and `$(Configuration)" + +Test-Condition -condition "exists('`$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformExtensionSDKLocation(``WindowsMobile, Version=10.0.10240.0``, `$(TargetPlatformIdentifier), `$(TargetPlatformVersion), `$(SDKReferenceDirectoryRoot), `$(SDKExtensionDirectoryRoot), `$(SDKReferenceRegistryRoot)))\DesignTime\CommonConfiguration\Neutral\WindowsMobile.props')"` + -expectFailure + +Test-Expression -expression "`$Foo;`$(ProjectDir);..\..;..\..\third-party" + +Test-Condition -condition "`$(TargetName.EndsWith('Test'))"` + -expectation $true + +Test-Condition -condition "`$(TargetName.EndsWith('Test2'))"` + -expectation $false + +$var = 4 +Test-Condition -condition '$(var) == 2 and 4 == 4'` + -expectation $false + +Test-Expression -expression "%(ASDASD);`$(TargetName)" + +$PkgMicrosoft_Gsl = "..\.." +Test-Condition -condition "Exists('`$(PkgMicrosoft_Gsl)\build\native\Microsoft.Gsl.targets') OR ! Exists('`$(PkgMicrosoft_Gsl)\build\native\Microsoft.Gsl.targets')"` + -expectation $true + +$myVar = 'TwoThree' +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains(`$(myVar.Substring(3, 3))))"` + -expectation $true + +$MySelector = "One;Two;Three" +$myVar = "Two" +Test-Condition -condition "`$(MySelector.Contains(`$(myVar)))"` + -expectation $true + +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains(Three))"` + -expectFailure + +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains('Three'))"` + -expectation $true + +Test-Condition -condition "`$([System.DateTime]::Now.Year) == 2018"` + -expectation $true + +Test-Condition -condition "HasTrailingSlash('c:\windows\')"` + -expectation $true + +Test-Condition -condition "HasTrailingSlash('c:\windows\') and hasTrailingSlash('c:\temp/')"` + -expectation $true + +$prop = "c:\windows\" +Test-Condition -condition "hasTrailingSlash(`$(prop))"` + -expectation $true \ No newline at end of file diff --git a/scripts/sample-clang-build.ps1 b/scripts/sample-clang-build.ps1 new file mode 100644 index 0000000000..577deff5c5 --- /dev/null +++ b/scripts/sample-clang-build.ps1 @@ -0,0 +1,225 @@ +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + It sets up the scene required for clang-build.ps1 to do its job, and makes + command-line usage for projects and files quicker. + + Before calling sample-clang-build.ps1 you need to set the current directory + to the root source directory. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + +.PARAMETER aUseParallelCompile + Alias 'parallel'. Switch to run in parallel mode, on all logical CPU cores. + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aTreatAdditionalIncludesAsSystemIncludes + Alias 'treat-sai'. Switch to treat project additional include directories as system includes. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + Doesn't actually apply the clang-tidy module changes to CPPs. + It will only print the tidy module output. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy-fix "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + It will apply all tidy module changes to CPPs. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo -proj-ignore foobar + + Runs clang++ on all CPPs in foo... projects, except foobar + +.OUTPUTS + Will output Clang warnings and errors to screen. The return code will be 0 for success, >0 for failure. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("parallel")] [Parameter(Mandatory=$false)][switch] $aUseParallelCompile + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("treat-sai")] [Parameter(Mandatory=$false)][switch] $aTreatAdditionalIncludesAsSystemIncludes + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + ) + +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kClangCompileFlags -Option Constant ` + -value @( "-Werror" + , "-Wall" + , "-fms-compatibility-version=19.10" + , "-Wmicrosoft" + , "-Wno-invalid-token-paste" + , "-Wno-unknown-pragmas" + , "-Wno-unused-value" + ) + +Set-Variable -name kVisualStudioVersion -value "2017" -Option Constant +Set-Variable -name kVisualStudioSku -value "Professional" -Option Constant + +# ------------------------------------------------------------------------------------------------ + +Function Merge-Array([string[]] $aArray) +{ + # we need to individually wrap items into quotes as values + # can contain PS control characters (e.g. - in -std=c++14) + $quotedArray = ($aArray | ForEach-Object { """$_"""}) + return ($quotedArray -join ",") +} + +[string] $scriptDirectory = (Split-Path -parent $PSCommandPath) + +[string] $clangScript = "$scriptDirectory\clang-build.ps1" +[string[]] $scriptParams = @("-aSolutionsPath", "'$(Get-Location)'") + +if (![string]::IsNullOrEmpty($aVcxprojToCompile)) +{ + $scriptParams += ("-aVcxprojToCompile", (Merge-Array $aVcxprojToCompile)) +} + +if (![string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + $scriptParams += ("-aVcxprojToIgnore", (Merge-Array $aVcxprojToIgnore)) +} + +if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) +{ + $scriptParams += ("-aVcxprojConfigPlatform", (Merge-Array $aVcxprojConfigPlatform)) +} + +if (![string]::IsNullOrEmpty($aCppToCompile)) +{ + $scriptParams += ("-aCppToCompile", (Merge-Array $aCppToCompile)) +} + +if (![string]::IsNullOrEmpty($aCppToIgnore)) +{ + $scriptParams += ("-aCppToIgnore", (Merge-Array $aCppToIgnore)) +} + +$scriptParams += ("-aClangCompileFlags", (Merge-Array $kClangCompileFlags)) + +if (![string]::IsNullOrEmpty($aTidyFlags)) +{ + $scriptParams += ("-aTidyFlags", (Merge-Array (@($aTidyFlags)))) +} + +if (![string]::IsNullOrEmpty($aTidyFixFlags)) +{ + $scriptParams += ("-aTidyFixFlags", (Merge-Array (@($aTidyFixFlags)))) +} + +if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) +{ + $scriptParams += ("-aAfterTidyFixFormatStyle", $aAfterTidyFixFormatStyle) +} + +if ($aUseParallelCompile) +{ + $scriptParams += ("-aUseParallelCompile") +} + +if ($aContinueOnError) +{ + $scriptParams += ("-aContinueOnError") +} + +if ($aTreatAdditionalIncludesAsSystemIncludes) +{ + $scriptParams += ("-aTreatAdditionalIncludesAsSystemIncludes") +} + +if ($aDisableNameRegexMatching) +{ + $scriptParams += ("-aDisableNameRegexMatching") +} + +$scriptParams += ("-aVisualStudioVersion", $kVisualStudioVersion) +$scriptParams += ("-aVisualStudioSku", $kVisualStudioSku) +$scriptParams += ("-aTidyHeaderFilter", ".*") + +Invoke-Expression "&'$clangScript' $scriptParams" From 905ebb49de3c660c9d718bd042335c3be6b301bd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Feb 2018 09:16:15 +0100 Subject: [PATCH 0342/1027] System : Add missing default statements in switch block --- ApplicationCode/UserInterface/RiuCadNavigation.cpp | 2 ++ ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp | 2 ++ ApplicationCode/UserInterface/RiuRmsNavigation.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.cpp b/ApplicationCode/UserInterface/RiuCadNavigation.cpp index d9f7cdf413..6d61969abe 100644 --- a/ApplicationCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuCadNavigation.cpp @@ -149,6 +149,8 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp index e9eafe6e34..25ead7cfba 100644 --- a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -160,6 +160,8 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp index 1b80a97535..f081ec8588 100644 --- a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp @@ -185,6 +185,8 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) From 1706a6c0c40c2909f39d510d46a6b580eca86c69 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Feb 2018 09:17:02 +0100 Subject: [PATCH 0343/1027] System : Reorder initialization order to match declaration order --- .../RiuFlowCharacteristicsPlot.cpp | 7 ++- .../RiuMultiCaseImportDialog.cpp | 4 +- .../UserInterface/RiuSelectionManager.cpp | 55 +++++++++---------- .../UserInterface/RiuViewerCommands.cpp | 13 +++-- .../UserInterface/RiuViewerCommands.h | 18 +++--- .../UserInterface/RiuWellAllocationPlot.cpp | 8 +-- .../UserInterface/RiuWellPltPlot.cpp | 7 ++- .../UserInterface/RiuWellRftPlot.cpp | 7 ++- 8 files changed, 60 insertions(+), 59 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp index 56000fe777..dfb3b62184 100644 --- a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp +++ b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp @@ -47,9 +47,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index e60e6bede1..6611ceb0b7 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -32,7 +32,9 @@ class FileListModel: public QStringListModel { public: - explicit FileListModel(QObject *parent = nullptr) : m_isItemsEditable(false), QStringListModel(parent) + explicit FileListModel(QObject* parent = nullptr) + : QStringListModel(parent) + , m_isItemsEditable(false) { } diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.cpp b/ApplicationCode/UserInterface/RiuSelectionManager.cpp index ca10deb431..87433a276e 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionManager.cpp @@ -177,42 +177,41 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, const cvf::Vec3d& localIntersectionPoint) - : m_view(view), - m_gridIndex(gridIndex), - m_cellIndex(cellIndex), - m_color(color), - m_elementFace(elementFace), - m_localIntersectionPoint(localIntersectionPoint), - m_hasIntersectionTriangle(false) + : m_view(view) + , m_gridIndex(gridIndex) + , m_cellIndex(cellIndex) + , m_color(color) + , m_elementFace(elementFace) + , m_hasIntersectionTriangle(false) + , m_localIntersectionPoint(localIntersectionPoint) { } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, - const cvf::Vec3d& localIntersectionPoint, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, + const cvf::Vec3d& localIntersectionPoint, const std::array& intersectionTriangle) - : m_view(view), - m_gridIndex(gridIndex), - m_cellIndex(cellIndex), - m_color(color), - m_elementFace(elementFace), - m_localIntersectionPoint(localIntersectionPoint), - m_hasIntersectionTriangle(true), - m_intersectionTriangle(intersectionTriangle) + : m_view(view) + , m_gridIndex(gridIndex) + , m_cellIndex(cellIndex) + , m_color(color) + , m_elementFace(elementFace) + , m_hasIntersectionTriangle(true) + , m_intersectionTriangle(intersectionTriangle) + , m_localIntersectionPoint(localIntersectionPoint) { - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 0c0e0d3d85..850f84d005 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -105,12 +105,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) - : QObject(ownerViewer), - m_viewer(ownerViewer), - m_currentGridIdx(-1), - m_currentCellIndex(-1), - m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED) +RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) + : QObject(ownerViewer) + , m_currentGridIdx(-1) + , m_currentCellIndex(-1) + , m_currentFaceIndex(cvf::StructGridInterface::NO_FACE) + , m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED) + , m_viewer(ownerViewer) { { m_viewerEventHandlers.push_back(dynamic_cast(RicIntersectionViewerEventHandler::instance())); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index a8e0a31fc3..ae867ac110 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -68,16 +68,12 @@ class RiuViewerCommands: public QObject bool handleOverlayItemPicking(int winPosX, int winPosY); - size_t m_currentGridIdx; - size_t m_currentCellIndex; - cvf::StructGridInterface::FaceType m_currentFaceIndex; - cvf::Vec3d m_currentPickPositionInDomainCoords; - - caf::PdmPointer m_reservoirView; - - QPointer m_viewer; - +private: + size_t m_currentGridIdx; + size_t m_currentCellIndex; + cvf::StructGridInterface::FaceType m_currentFaceIndex; + cvf::Vec3d m_currentPickPositionInDomainCoords; + caf::PdmPointer m_reservoirView; + QPointer m_viewer; std::vector m_viewerEventHandlers; }; - - diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 2a9615f1ec..ecd47ffad5 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -43,12 +43,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) { Q_ASSERT(m_plotDefinition); - + QVBoxLayout* mainLayout = new QVBoxLayout(); this->setLayout(mainLayout); this->layout()->setMargin(0); diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp index 222c9ea62c..defdd24b08 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp @@ -43,9 +43,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp index 37ad38f83b..c2a9d7c4e3 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp @@ -43,9 +43,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); From fe301bfc111e49a671450f1d28b6eeda4c0a8672 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 07:37:16 +0100 Subject: [PATCH 0344/1027] #2522 Mohr circle: Avoid calculating circle if result without tensor is selected --- .../UserInterface/RiuMohrsCirclePlot.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index c6ade03a4e..43c9817b3b 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -126,6 +126,7 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select void RiuMohrsCirclePlot::clearPlot() { deleteCircles(); + this->replot(); } //-------------------------------------------------------------------------------------------------- @@ -180,7 +181,7 @@ void RiuMohrsCirclePlot::redrawCircles() // Ex 1: xMin will be set to 1.1 * m_principal3 to be able to see the whole circle // |y - // _|____ + // _|_____ // / | \ // / | \ //--|---|-------|------- x @@ -245,10 +246,20 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz int frameIdx = geoMechView->currentTimeStep(); RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress(); - - // TODO: All tensors are calculated everytime this function is called. FIX + if (!(currentAddress.fieldName == "SE" || currentAddress.fieldName == "ST" || currentAddress.fieldName == "E")) + { + clearPlot(); + return; + } + // TODO: All tensors are calculated every time this function is called. FIX std::vector vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx); - RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + if (vertexTensors.empty()) + { + clearPlot(); + return; + } + + RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; for (int i = 1; i < 8; i++) From 75bcf7dcf4e503821ac60757b842825b003e851e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 08:36:21 +0100 Subject: [PATCH 0345/1027] #2527 Mohr Circle: Add friction-cohesion line --- .../UserInterface/RiuMohrsCirclePlot.cpp | 92 ++++++++++++++++++- .../UserInterface/RiuMohrsCirclePlot.h | 16 +++- 2 files changed, 105 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 43c9817b3b..a3f551d2d3 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -36,11 +36,14 @@ #include #include +#include "qwt_plot_curve.h" #include "qwt_plot_layout.h" #include "qwt_plot_marker.h" #include "qwt_plot_rescaler.h" #include "qwt_plot_shapeitem.h" +#include + //================================================================================================== /// /// \class RiuMohrsCirclePlot @@ -84,11 +87,12 @@ void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, double p3) +void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double p3) { setPrincipals(p1, p2, p3); redrawCircles(); + redrawEnvelope(); } //-------------------------------------------------------------------------------------------------- @@ -126,6 +130,8 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select void RiuMohrsCirclePlot::clearPlot() { deleteCircles(); + deleteEnvelope(); + this->replot(); } @@ -234,6 +240,68 @@ void RiuMohrsCirclePlot::deleteCircles() m_circlePlotItems.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::redrawEnvelope() +{ + deleteEnvelope(); + + if (m_cohesion == HUGE_VAL || m_frictionAngle == HUGE_VAL) + { + this->replot(); + return; + } + + QwtPlotCurve* qwtCurve = new QwtPlotCurve(); + + std::vector xVals; + std::vector yVals; + + double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(m_frictionAngle))); + + double x = m_cohesion/tanFrictionAngle; + if (m_principal1 < 0) + { + xVals.push_back(-x); + } + else + { + xVals.push_back(x); + } + + xVals.push_back(m_principal1*1.1); + + yVals.push_back(0); + yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.1) * tanFrictionAngle); + + qwtCurve->setSamples(xVals.data(), yVals.data(), 2); + + qwtCurve->setStyle(QwtPlotCurve::Lines); + qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + const QPen curvePen(Qt::red); + qwtCurve->setPen(curvePen); + + qwtCurve->attach(this); + + m_envolopePlotItem = qwtCurve; + this->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deleteEnvelope() +{ + if (m_envolopePlotItem) + { + m_envolopePlotItem->detach(); + delete m_envolopePlotItem; + m_envolopePlotItem = nullptr; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -272,7 +340,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz cvf::Vec3f principalDirs[3]; cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs); - setPrincipalsAndRedrawCircles(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); + setPrincipalsAndRedrawPlot(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); } //-------------------------------------------------------------------------------------------------- @@ -300,6 +368,10 @@ void RiuMohrsCirclePlot::setDefaults() lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine); lineYPlotMarker->setXValue(0); lineYPlotMarker->attach(this); + + m_envolopePlotItem = nullptr; + m_cohesion = HUGE_VAL; + m_frictionAngle = HUGE_VAL; } //-------------------------------------------------------------------------------------------------- @@ -319,3 +391,19 @@ void RiuMohrsCirclePlot::createMohrCircles() m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2.0; m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2.0; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setFrictionAngle(double frictionAngle) +{ + m_frictionAngle = frictionAngle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setCohesion(double cohesion) +{ + m_cohesion = cohesion; +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 6b3506decd..0a7f5cb236 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -28,6 +28,7 @@ class RimGeoMechView; class QwtRoundScaleDraw; class QwtPlotRescaler; class QWidget; +class QwtPlotCurve; //================================================================================================== // @@ -43,7 +44,7 @@ class RiuMohrsCirclePlot : public QwtPlot ~RiuMohrsCirclePlot(); void setPrincipals(double p1, double p2, double p3); - void setPrincipalsAndRedrawCircles(double p1, double p2, double p3); + void setPrincipalsAndRedrawPlot(double p1, double p2, double p3); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); void clearPlot(); @@ -55,6 +56,9 @@ class RiuMohrsCirclePlot : public QwtPlot void redrawCircles(); void deleteCircles(); + void redrawEnvelope(); + void deleteEnvelope(); + void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); private: @@ -67,10 +71,14 @@ class RiuMohrsCirclePlot : public QwtPlot double radius; double centerX; }; + private: void setDefaults(); void createMohrCircles(); + void setFrictionAngle(double frictionAngle); + void setCohesion(double cohesion); + private: double m_principal1; double m_principal2; @@ -79,6 +87,12 @@ class RiuMohrsCirclePlot : public QwtPlot std::array m_mohrCircles; std::vector m_circlePlotItems; + + QwtPlotCurve* m_envolopePlotItem; + + double m_frictionAngle; + double m_cohesion; + double m_factorOfSafety; QwtPlotRescaler* m_rescaler; }; From f3859a6bee72f1b00d475288aa77b9c276a37c37 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 10:59:47 +0100 Subject: [PATCH 0346/1027] #2528 Tensor Vectors: Make tensor vectors for result "E" --- .../RigFemPartResultsCollection.cpp | 4 +-- .../RivTensorResultPartMgr.cpp | 3 +- .../ProjectDataModel/RimTensorResults.cpp | 32 +++++++++++++++++-- .../ProjectDataModel/RimTensorResults.h | 3 ++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 092f1d83d6..5d95134a95 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -2146,7 +2146,7 @@ std::vector RigFemPartResultsCollection::tensors(const RigFemResultA address13.componentName = "S13"; address23.componentName = "S23"; } - else if (resVarAddr.fieldName == "E") + else if (resVarAddr.fieldName == "NE") { address11.componentName = "E11"; address22.componentName = "E22"; @@ -2312,7 +2312,7 @@ std::vector RigFemPartResultsCollection::tensorPrincipalCom addresses[1].componentName = "S2"; addresses[2].componentName = "S3"; } - else if (resVarAddr.fieldName == "E") + else if (resVarAddr.fieldName == "NE") { addresses[0].componentName = "E1"; addresses[1].componentName = "E2"; diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index d2f8d96cb3..b785f86e8d 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -340,7 +340,6 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vectortensorResults()->vectorColors(); if (vectorColors == RimTensorResults::MAGENTA_BROWN_BLACK || vectorColors == RimTensorResults::WHITE_GRAY_BLACK) { - activeScalerMapper = discreteScalarMapper.p(); createOneColorPerPrincipalScalarMapper(vectorColors, discreteScalarMapper.p()); @@ -453,7 +452,7 @@ bool RivTensorResultPartMgr::isTensorAddress(RigFemResultAddress address) { return false; } - if (!(address.fieldName == "SE" || address.fieldName == "ST" || address.fieldName == "E")) + if (!(address.fieldName == "SE" || address.fieldName == "ST" || address.fieldName == "NE")) { return false; } diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index a4927da90a..97edd23d5e 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -226,7 +226,7 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); if (m_resultPositionTypeUiField() == m_resultPositionType()) { - m_resultFieldNameUiField = m_resultFieldName(); + m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); } else { @@ -237,7 +237,7 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, if (changedField == &m_resultFieldNameUiField) { m_resultPositionType = m_resultPositionTypeUiField; - m_resultFieldName = m_resultFieldNameUiField; + m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField); } if (changedField == &m_showTensors) { @@ -319,7 +319,7 @@ void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering void RimTensorResults::initAfterRead() { m_resultPositionTypeUiField = m_resultPositionType; - m_resultFieldNameUiField = m_resultFieldName(); + m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); } //-------------------------------------------------------------------------------------------------- @@ -336,3 +336,29 @@ void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, Q } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::uiFieldName(const QString& fieldName) +{ + if (fieldName == "NE") + { + return QString("E"); + } + + return fieldName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::fieldNameFromUi(const QString& uiFieldName) +{ + if (uiFieldName == "E") + { + return QString("NE"); + } + + return uiFieldName; +} diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index 19d6625750..08fe0130b5 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -82,6 +82,9 @@ class RimTensorResults : public caf::PdmObject virtual void initAfterRead() override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + static QString uiFieldName(const QString& fieldName); + static QString fieldNameFromUi(const QString& uiFieldName); + private: caf::PdmField m_showTensors; From 23ab74c34d99fc2c2a67cccd7de5d96f8db79366 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 11:15:18 +0100 Subject: [PATCH 0347/1027] Mohr Circle: Make result "E" work --- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index a3f551d2d3..fb7f411629 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -314,7 +314,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz int frameIdx = geoMechView->currentTimeStep(); RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress(); - if (!(currentAddress.fieldName == "SE" || currentAddress.fieldName == "ST" || currentAddress.fieldName == "E")) + if (!(currentAddress.fieldName == "SE" || currentAddress.fieldName == "ST" || currentAddress.fieldName == "NE")) { clearPlot(); return; From f7ba9133fec7c3c589e8126e625c558d794c6a63 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 12:51:25 +0100 Subject: [PATCH 0348/1027] #2527 Mohr circle: Make friction-cohesion line for negative principals --- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index fb7f411629..b611a2fdef 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -263,14 +263,15 @@ void RiuMohrsCirclePlot::redrawEnvelope() double x = m_cohesion/tanFrictionAngle; if (m_principal1 < 0) { - xVals.push_back(-x); + xVals.push_back(x); + xVals.push_back(m_principal3*1.1); } else { - xVals.push_back(x); + xVals.push_back(-x); + xVals.push_back(m_principal1*1.1); } - xVals.push_back(m_principal1*1.1); yVals.push_back(0); yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.1) * tanFrictionAngle); From bed95a105eb39850ebeb4f59fc2a18be7db0bb50 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 13:39:13 +0100 Subject: [PATCH 0349/1027] #2527 Mohr Circle: Use cohersion and friction angle from case --- .../ProjectDataModel/RimGeoMechCase.cpp | 16 ++++++++++++++++ .../ProjectDataModel/RimGeoMechCase.h | 3 +++ .../UserInterface/RiuMohrsCirclePlot.cpp | 3 +++ 3 files changed, 22 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 68a3a45c75..0cc6c8c802 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -383,6 +383,22 @@ void RimGeoMechCase::addElementPropertyFiles(const std::vector& f } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechCase::cohesion() const +{ + return m_cohesion; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechCase::frictionAngleDeg() const +{ + return m_frictionAngleDeg; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 7d55de5861..13c6b897d4 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -71,6 +71,9 @@ class RimGeoMechCase : public RimCase void addElementPropertyFiles(const std::vector& filenames); + double cohesion() const; + double frictionAngleDeg() const; + // Fields: caf::PdmChildArrayField geoMechViews; diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index b611a2fdef..5e27a9ebef 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -311,6 +311,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz CVF_ASSERT(geoMechView); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + + setCohesion(geoMechView->geoMechCase()->cohesion()); + setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); int frameIdx = geoMechView->currentTimeStep(); From 0cee37ce86d699b1bceb251089fe3c1ef96b5c3c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2018 14:41:56 +0100 Subject: [PATCH 0350/1027] Add missing ifdef macro for use of fracture template --- .../RicCopyReferencesToClipboardFeature.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index c5c5d7eb6d..ab81dfe4a9 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -21,7 +21,9 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplate.h" +#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" @@ -163,10 +165,12 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { if (!wellAllocPlot && !rftPlot) return true; } +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES else if (dynamic_cast(pdmObject)) { return true; } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES return false; } From 2b368fb0b8e8fc0c4945c426cf41587078b9cfba Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 26 Feb 2018 15:55:29 +0100 Subject: [PATCH 0351/1027] #2523 Mohr Circle: Improve circle appearence --- .../Application/Tools/RiaColorTables.cpp | 6 +- .../UserInterface/RiuMohrsCirclePlot.cpp | 194 ++++++++++++------ .../UserInterface/RiuMohrsCirclePlot.h | 5 + 3 files changed, 137 insertions(+), 68 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 92f7c09a1b..d3644b1512 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -488,9 +488,9 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors() const caf::ColorTable& RiaColorTables::mohrsCirclePaletteColors() { static std::vector colors{ - cvf::Color3ub::RED, - cvf::Color3ub::DARK_GREEN, - cvf::Color3ub::BLUE + cvf::Color3ub(202, 0, 0), // Red + cvf::Color3ub(0, 112, 136), // Dark Green-Blue + cvf::Color3ub(56, 56, 255), // Vivid Blue }; static caf::ColorTable colorTable = caf::ColorTable(colors); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 5e27a9ebef..e1e6b1bfd9 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -19,10 +19,13 @@ #include "RiuMohrsCirclePlot.h" #include "RiuSelectionManager.h" +#include "RiuSummaryQwtPlot.h" #include "RiaColorTables.h" +#include "RigFemPart.h" #include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" @@ -91,8 +94,8 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double { setPrincipals(p1, p2, p3); - redrawCircles(); redrawEnvelope(); + redrawCircles(); } //-------------------------------------------------------------------------------------------------- @@ -173,57 +176,12 @@ void RiuMohrsCirclePlot::redrawCircles() plotItem->setPen(QPen(colors.cycledQColor(i))); plotItem->setShape(*circleDrawing); plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); - m_circlePlotItems.push_back(plotItem); plotItem->attach(this); - } - - double yHeight = 0.6 * (m_principal1 - m_principal3); - this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight); - - // Scale the x-axis to show the y-axis if the largest circle's leftmost intersection of the - // x-axis (principal 3) is to the right of the y-axis - - //The following examples shows the largest of the three Mohr circles - - // Ex 1: xMin will be set to 1.1 * m_principal3 to be able to see the whole circle - // |y - // _|_____ - // / | \ - // / | \ - //--|---|-------|------- x - // \ | / - // \_|_____/ - // | - // | - - // Ex 2: xMin will be set to -1 to be able to see the y-axis - // |y - // | _______ - // | / \ - // | / \ - // -|-------------|-----------|---------- x - // | \ / - // | \_______/ - // | - // | - double xMin; - if (m_principal3 < 0) - { - xMin = 1.1 * m_principal3; - } - else - { - xMin = -1; + m_circlePlotItems.push_back(plotItem); } - // When using the rescaler, xMax is ignored - double xMax = 0; - - this->setAxisScale(QwtPlot::xBottom, xMin, xMax); - this->replot(); - m_rescaler->rescale(); - this->plotLayout()->setAlignCanvasToScales(true); + replotAndScaleAxis(); } //-------------------------------------------------------------------------------------------------- @@ -238,6 +196,13 @@ void RiuMohrsCirclePlot::deleteCircles() } m_circlePlotItems.clear(); + + if (m_transparentCurve) + { + m_transparentCurve->detach(); + delete m_transparentCurve; + m_transparentCurve = nullptr; + } } //-------------------------------------------------------------------------------------------------- @@ -260,6 +225,13 @@ void RiuMohrsCirclePlot::redrawEnvelope() double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(m_frictionAngle))); + if (tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL) + { + this->replot(); + delete qwtCurve; + return; + } + double x = m_cohesion/tanFrictionAngle; if (m_principal1 < 0) { @@ -272,22 +244,22 @@ void RiuMohrsCirclePlot::redrawEnvelope() xVals.push_back(m_principal1*1.1); } - yVals.push_back(0); - yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.1) * tanFrictionAngle); + yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.05) * tanFrictionAngle); qwtCurve->setSamples(xVals.data(), yVals.data(), 2); qwtCurve->setStyle(QwtPlotCurve::Lines); qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); - const QPen curvePen(Qt::red); + const QPen curvePen(QColor(236, 118, 0)); qwtCurve->setPen(curvePen); qwtCurve->attach(this); m_envolopePlotItem = qwtCurve; - this->replot(); + + replotAndScaleAxis(); } //-------------------------------------------------------------------------------------------------- @@ -311,9 +283,6 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz CVF_ASSERT(geoMechView); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); - - setCohesion(geoMechView->geoMechCase()->cohesion()); - setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); int frameIdx = geoMechView->currentTimeStep(); @@ -330,9 +299,39 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz clearPlot(); return; } + + setCohesion(geoMechView->geoMechCase()->cohesion()); + setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + size_t i, j, k; + femPart->structGrid()->ijkFromCellIndex(cellIndex, &i, &j, &k); + + int elmId = femPart->elmId(cellIndex); + + QString title; + QString resultPos; + QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); + + switch (geoMechView->cellResultResultDefinition()->resultPositionType()) + { + case RIG_ELEMENT_NODAL: + resultPos = "Element Nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration Point"; + break; + default: + break; + } + + title += QString("%1, %2").arg(resultPos).arg(fieldName); + + title += QString(", Element Id[%1], ijk[%2,%3,%4]").arg(elmId).arg(i).arg(j).arg(k); + this->setTitle(title); + caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; for (int i = 1; i < 8; i++) { @@ -352,6 +351,8 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setDefaults() { + RiuSummaryQwtPlot::setCommonPlotBehaviour(this); + m_rescaler = new QwtPlotRescaler(this->canvas()); m_rescaler->setReferenceAxis(QwtPlot::yLeft); m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0); @@ -363,19 +364,13 @@ void RiuMohrsCirclePlot::setDefaults() enableAxis(QwtPlot::xTop, false); enableAxis(QwtPlot::yRight, false); - QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX"); - lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine); - lineXPlotMarker->setYValue(0); - lineXPlotMarker->attach(this); - - QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY"); - lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine); - lineYPlotMarker->setXValue(0); - lineYPlotMarker->attach(this); + setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress"); + setAxisTitle(QwtPlot::yLeft, "Shear Stress"); m_envolopePlotItem = nullptr; + m_transparentCurve = nullptr; m_cohesion = HUGE_VAL; - m_frictionAngle = HUGE_VAL; + m_frictionAngle = HUGE_VAL; } //-------------------------------------------------------------------------------------------------- @@ -411,3 +406,72 @@ void RiuMohrsCirclePlot::setCohesion(double cohesion) { m_cohesion = cohesion; } + +//-------------------------------------------------------------------------------------------------- +/// Add a transparent curve to make tooltip available on principals crossing the x-axis +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateTransparentCurveOnPrincipals() +{ + if (m_transparentCurve) + { + m_transparentCurve->detach(); + delete m_transparentCurve; + } + + m_transparentCurve = new QwtPlotCurve(); + + QVector qVectorPoints; + + qVectorPoints.push_back(QPointF(m_principal1, 0)); + qVectorPoints.push_back(QPointF(m_principal2, 0)); + qVectorPoints.push_back(QPointF(m_principal3, 0)); + + m_transparentCurve->setSamples(qVectorPoints); + m_transparentCurve->setYAxis(QwtPlot::yLeft); + m_transparentCurve->setStyle(QwtPlotCurve::NoCurve); + m_transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute); + + m_transparentCurve->attach(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::replotAndScaleAxis() +{ + double maxYEnvelope = -HUGE_VAL; + if (m_envolopePlotItem) + { + maxYEnvelope = m_envolopePlotItem->maxYValue(); + } + + double yHeight = std::max(maxYEnvelope, 0.6 * (m_principal1 - m_principal3)); + + this->setAxisScale(QwtPlot::yLeft, 0, yHeight); + + double minXEvelope = 0; + + if (m_envolopePlotItem) + { + minXEvelope = m_envolopePlotItem->minXValue(); + } + + double xMin; + if (minXEvelope < 0) + { + xMin = minXEvelope; + } + else + { + xMin = 1.1 * m_principal3; + } + + // When using the rescaler, xMax is ignored + this->setAxisScale(QwtPlot::xBottom, xMin, 0); + + updateTransparentCurveOnPrincipals(); + + this->replot(); + m_rescaler->rescale(); + this->plotLayout()->setAlignCanvasToScales(true); +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 0a7f5cb236..9adcfc4840 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -79,6 +79,10 @@ class RiuMohrsCirclePlot : public QwtPlot void setFrictionAngle(double frictionAngle); void setCohesion(double cohesion); + void updateTransparentCurveOnPrincipals(); + + void replotAndScaleAxis(); + private: double m_principal1; double m_principal2; @@ -89,6 +93,7 @@ class RiuMohrsCirclePlot : public QwtPlot std::vector m_circlePlotItems; QwtPlotCurve* m_envolopePlotItem; + QwtPlotCurve* m_transparentCurve; double m_frictionAngle; double m_cohesion; From 72b5f540e5f09b50c01e8cd612c24b1cda94c8c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2018 20:54:45 +0100 Subject: [PATCH 0352/1027] #2529 Fracture : Remove all #ifdef USE_PROTOTYPE_FEATURE_FRACTURES --- .../Application/RiaApplication.cpp | 7 ----- .../ApplicationCommands/RicHelpFeatures.cpp | 3 -- .../RicExportCompletionDataSettingsUi.cpp | 6 ---- .../RicExportCompletionDataSettingsUi.h | 2 -- ...ellPathExportCompletionDataFeatureImpl.cpp | 6 ---- .../RicCopyReferencesToClipboardFeature.cpp | 4 --- .../Commands/RicDeleteItemExec.cpp | 4 --- .../Commands/RicDeleteItemFeature.cpp | 5 ---- .../RivWellFracturePartMgr.cpp | 4 --- .../ModelVisualization/RivWellPathPartMgr.cpp | 2 -- .../ModelVisualization/RivWellPathPartMgr.h | 2 -- .../RivWellPathsPartMgr.cpp | 2 -- .../ModelVisualization/RivWellPathsPartMgr.h | 2 -- .../RimCompletionCellIntersectionCalc.cpp | 8 ----- .../RimCompletionCellIntersectionCalc.h | 16 ++++------ .../Completions/RimWellPathCompletions.cpp | 10 ------- .../Completions/RimWellPathCompletions.h | 6 ---- .../RimContextCommandBuilder.cpp | 10 ------- .../ProjectDataModel/RimEclipseCase.cpp | 3 -- .../ProjectDataModel/RimEclipseView.cpp | 19 ------------ .../ProjectDataModel/RimEclipseView.h | 4 --- .../ProjectDataModel/RimLegendConfig.cpp | 9 ------ .../ProjectDataModel/RimOilField.cpp | 12 -------- .../ProjectDataModel/RimProject.cpp | 15 ++-------- ApplicationCode/ProjectDataModel/RimProject.h | 2 -- .../ProjectDataModel/RimSimWellInView.cpp | 30 ++++++------------- .../ProjectDataModel/RimSimWellInView.h | 5 ---- .../RimSimWellInViewCollection.cpp | 4 --- .../ProjectDataModel/RimWellPath.cpp | 4 --- .../ProjectDataModel/RimWellPath.h | 4 --- .../RigCellGeometryTools.cpp | 10 ------- .../UnitTests/RigCellGeometryTools-Test.cpp | 2 -- .../UserInterface/RiuViewerCommands.cpp | 6 ---- 33 files changed, 16 insertions(+), 212 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 6d05e4b3b3..fa5b8c1d15 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -93,11 +93,9 @@ #include "RiuWellAllocationPlot.h" #include "RiuFlowCharacteristicsPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" #include "RimWellPathFracture.h" #include "RimStimPlanColors.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RicImportInputEclipseCaseFeature.h" @@ -511,8 +509,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi rimObservedData->updateMetaData(); } } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES oilField->fractureDefinitionCollection()->loadAndUpdateData(); oilField->fractureDefinitionCollection()->setDefaultConductivityResultIfEmpty(); @@ -526,7 +522,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi fracture->loadDataAndUpdate(); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } @@ -572,7 +567,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi viewProgress.setProgressDescription(riv->name()); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (m_project->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) { std::vector stimPlanColors; @@ -582,7 +576,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi stimPlanColors[0]->updateConductivityResultName(); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES riv->loadDataAndUpdate(); this->setActiveReservoirView(riv); diff --git a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp index 250e551d6c..4dfa6058f8 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp @@ -71,9 +71,6 @@ void RicHelpAboutFeature::onActionTriggered(bool isChecked) #ifdef USE_HDF5 activeFeatures += " Souring"; #endif -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - activeFeatures += " Fractures"; -#endif if (!activeFeatures.isEmpty()) { diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 9100f61aa1..fab2965197 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -76,9 +76,7 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWe CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Include Perforations", "", "", ""); CAF_PDM_InitField(&includeFishbones, "IncludeFishbones", true, "Include Fishbones", "", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Include Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, "Exclude Main Bore Transmissibility For Fishbones", "", "", ""); m_onlyWellPathCollectionSelected = onlyWellPathCollectionSelected; @@ -114,7 +112,6 @@ void RicExportCompletionDataSettingsUi::showForWellPath() //-------------------------------------------------------------------------------------------------- void RicExportCompletionDataSettingsUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (changedField == &compdatExport) { if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) @@ -128,7 +125,6 @@ void RicExportCompletionDataSettingsUi::fieldChangedByUi(const caf::PdmFieldHand includeFractures.uiCapability()->setUiReadOnly(false); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -210,7 +206,6 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c if (!includePerforations) timeStep.uiCapability()->setUiReadOnly(true); else timeStep.uiCapability()->setUiReadOnly(false); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmUiGroup* fractureGroup = uiOrdering.addNewGroup("Export of Fracture Completions"); fractureGroup->add(&includeFractures); @@ -222,7 +217,6 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c { includeFractures.uiCapability()->setUiReadOnly(false); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } uiOrdering.skipRemainingFields(); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 1224b44435..3ef0a43045 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -63,9 +63,7 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi caf::PdmField includePerforations; caf::PdmField includeFishbones; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmField includeFractures; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmField excludeMainBoreForFishbones; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 8ef7e9776c..89c46ff64b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -141,9 +141,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } size_t maxProgress = usedWellPaths.size() * 3 + -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES simWells.size() + -#endif // USE_PROTOTYPE_FEATURE_FRACTURES (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE @@ -175,7 +173,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } progress.incrementProgress(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (exportSettings.includeFractures()) { std::vector fractureCompletionData = @@ -183,11 +180,9 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES progress.incrementProgress(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES for (auto simWell : simWells) { std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell( @@ -195,7 +190,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); progress.incrementProgress(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index ab81dfe4a9..c5c5d7eb6d 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -21,9 +21,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplate.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" @@ -165,12 +163,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { if (!wellAllocPlot && !rftPlot) return true; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES else if (dynamic_cast(pdmObject)) { return true; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return false; } diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index ab598aa4f7..6ac93cf0a7 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -44,9 +44,7 @@ #include "RiuMainPlotWindow.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafNotificationCenter.h" @@ -150,7 +148,6 @@ void RicDeleteItemExec::redo() view->scheduleCreateDisplayModelAndRedraw(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimFractureTemplateCollection* fracTemplateColl; parentObj->firstAncestorOrThisOfType(fracTemplateColl); if (fracTemplateColl) @@ -172,7 +169,6 @@ void RicDeleteItemExec::redo() } } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES // Well paths diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index 79e1893a6e..221213a542 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -50,14 +50,12 @@ #include "RimWellLogRftCurve.h" #include "RimWellRftPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimEllipseFractureTemplate.h" #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimStimPlanFractureTemplate.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafCmdExecCommandManager.h" @@ -113,15 +111,12 @@ bool isDeletable(caf::PdmUiItem* uiItem) if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return false; } diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 17c41b6145..6cee288476 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -248,8 +248,6 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ } else if (stimPlanTemplate) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); RimStimPlanColors* stimPlanColors = activeView.fractureColors; @@ -267,8 +265,6 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ // Cell index text.append("Cell Index: "); text.append(iText + ", " + jText + "\n"); - -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } return text; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index a92dbd9b07..05a1cabc68 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -82,7 +82,6 @@ RivWellPathPartMgr::~RivWellPathPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) { if (m_rimView.isNull()) return; @@ -99,7 +98,6 @@ void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* m f->fracturePartManager()->appendGeometryPartsToModel(model, *eclView); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 79e83d7f0d..f7c90e5000 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -62,9 +62,7 @@ class RivWellPathPartMgr : public cvf::Object const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, const QDateTime& timeStamp, diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index ddccacc331..b8d0d753a7 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -57,7 +57,6 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) { if (!isWellPathVisible()) return; @@ -69,7 +68,6 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* partMgr->appendStaticFracturePartsToModel(model); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index f1bab94ee7..164f1ddf00 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -61,9 +61,7 @@ class RivWellPathsPartMgr : public cvf::Object const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, const QDateTime& timeStamp, diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 5795c0544a..9b1423bb12 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -38,7 +38,6 @@ #include "RigWellPathIntersectionTools.h" #include "RigCellGeometryTools.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFracture.h" #include "RimWellPathFracture.h" #include "RimFractureTemplate.h" @@ -47,7 +46,6 @@ #include "RimSimWellFracture.h" #include "RigFractureGrid.h" #include "RigFractureCell.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include @@ -70,7 +68,6 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP } } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES for (RimEclipseView* view : eclipseCase->reservoirViews()) { for (RimSimWellInView* simWell : view->wellCollection()->wells()) @@ -81,7 +78,6 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP } } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -115,7 +111,6 @@ void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const Rim } } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (wellPath->fractureCollection()->isChecked()) { for (const RimWellPathFracture* fracture : wellPath->fractureCollection()->fractures()) @@ -126,7 +121,6 @@ void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const Rim } } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES if (wellPath->perforationIntervalCollection()->isChecked()) { @@ -182,7 +176,6 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values) { if (!fracture->fractureTemplate()) return; @@ -251,4 +244,3 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index d7d997aff7..c35b68ba4b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -20,18 +20,14 @@ #include -class RimProject; -class RimWellPath; +class RigMainGrid; +class RimEclipseCase; class RimFishbonesMultipleSubs; -class RimPerforationInterval; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimFracture; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - -class RimEclipseCase; +class RimPerforationInterval; +class RimProject; +class RimWellPath; -class RigMainGrid; class QDateTime; //================================================================================================== @@ -51,7 +47,5 @@ class RimCompletionCellIntersectionCalc static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values); static void calculatePerforationIntersections(const RimWellPath* wellPath, const RimPerforationInterval* perforationInterval, const RigMainGrid* grid, std::vector& values); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES static void calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp index 103d1ba069..861462bfc1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp @@ -21,9 +21,7 @@ #include "RimFishbonesCollection.h" #include "RimFishboneWellPathCollection.h" #include "RimPerforationCollection.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cvfAssert.h" @@ -47,11 +45,9 @@ RimWellPathCompletions::RimWellPathCompletions() m_fishbonesCollection = new RimFishbonesCollection; m_fishbonesCollection.uiCapability()->setUiHidden(true); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&m_fractureCollection, "Fractures", "Fractures", "", "", ""); m_fractureCollection = new RimWellPathFractureCollection; m_fractureCollection.uiCapability()->setUiHidden(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitField(&m_wellNameForExport, "WellNameForExport", QString(), "Well Name for Completion Export", "", "", ""); } @@ -95,26 +91,22 @@ QString RimWellPathCompletions::wellNameForExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* RimWellPathCompletions::fractureCollection() const { CVF_ASSERT(m_fractureCollection); return m_fractureCollection; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimWellPathCompletions::hasCompletions() const { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (!fractureCollection()->fractures().empty()) { return true; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return !fishbonesCollection()->fishbonesSubs().empty() || !fishbonesCollection()->wellPathCollection()->wellPaths().empty() || @@ -147,10 +139,8 @@ void RimWellPathCompletions::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTree uiTreeOrdering.add(&m_fishbonesCollection); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (!fractureCollection()->fractures().empty()) { uiTreeOrdering.add(&m_fractureCollection); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h index 05183d1677..04ec0c37fd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h @@ -24,9 +24,7 @@ class RimFishbonesCollection; class RimPerforationCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimWellPathFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //================================================================================================== /// @@ -41,9 +39,7 @@ class RimWellPathCompletions : public caf::PdmObject RimFishbonesCollection* fishbonesCollection() const; RimPerforationCollection* perforationCollection() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* fractureCollection() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES void setWellNameForExport(const QString& name); QString wellNameForExport() const; @@ -57,9 +53,7 @@ class RimWellPathCompletions : public caf::PdmObject private: caf::PdmChildField m_fishbonesCollection; caf::PdmChildField m_perforationCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField m_fractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmField m_wellNameForExport; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index f13c7c2c4a..aea3b55d4e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -77,7 +77,6 @@ #include "RimWellPltPlot.h" #include "RimWellRftPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimEllipseFractureTemplate.h" #include "RimStimPlanFractureTemplate.h" #include "RimFractureTemplateCollection.h" @@ -85,7 +84,6 @@ #include "RimSimWellFracture.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RiuMainWindow.h" @@ -266,10 +264,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); - // Fracture commands -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewWellPathFractureFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewFishbonesSubsFeature"; menuBuilder << "RicNewPerforationIntervalFeature"; menuBuilder << "RicEditPerforationCollectionFeature"; @@ -525,7 +520,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicShowGridStatisticsFeature"; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES else if (dynamic_cast(uiItem)) { menuBuilder << "RicNewSimWellFractureFeature"; @@ -561,8 +555,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicConvertFractureTemplateUnitFeature"; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - if (dynamic_cast(uiItem)) { @@ -678,10 +670,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEclipseWellShowSpheresFeature"; menuBuilder << "RicEclipseWellShowWellCellsFeature"; menuBuilder << "RicEclipseWellShowWellCellFenceFeature"; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "Separator"; menuBuilder << "RicNewSimWellFractureFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } menuBuilder.addSeparator(); menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 3fefea4066..8946798f46 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -254,10 +254,7 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES rimEclipseView->fractureColors()->setDefaultResultName(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 86128f1a11..29e2079333 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -71,12 +71,10 @@ #include "RivTernarySaturationOverlayItem.h" #include "RivWellPathsPartMgr.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFracture.h" #include "RimFractureTemplateCollection.h" #include "RimSimWellFracture.h" #include "RivWellFracturePartMgr.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafCadNavigation.h" @@ -123,11 +121,9 @@ RimEclipseView::RimEclipseView() faultResultSettings = new RimEclipseFaultColors(); faultResultSettings.uiCapability()->setUiHidden(true); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&fractureColors, "StimPlanColors", "Fracture", "", "", ""); fractureColors = new RimStimPlanColors(); fractureColors.uiCapability()->setUiHidden(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", ""); wellCollection = new RimSimWellInViewCollection; @@ -462,15 +458,11 @@ void RimEclipseView::createDisplayModel() // NB! StimPlan legend colors must be updated before well path geometry is added to the model // as the fracture geometry depends on the StimPlan legend colors -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES fractureColors->updateLegendData(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p()); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES m_wellPathPipeVizModel->updateBoundingBoxesRecursive(); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); @@ -702,7 +694,6 @@ void RimEclipseView::updateCurrentTimeStep() } // Sim Well Fractures -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES { cvf::String name = "SimWellFracturesModel"; this->removeModelByName(frameScene, name); @@ -733,7 +724,6 @@ void RimEclipseView::updateCurrentTimeStep() simWellFracturesModelBasicList->updateBoundingBoxesRecursive(); frameScene->addModel(simWellFracturesModelBasicList.p()); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } } @@ -770,9 +760,7 @@ void RimEclipseView::onLoadDataAndUpdate() this->cellEdgeResult()->loadResult(); this->faultResultSettings()->customFaultResult()->loadResult(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES this->fractureColors->loadDataAndUpdate(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES updateMdiWindowVisibility(); @@ -786,7 +774,6 @@ void RimEclipseView::onLoadDataAndUpdate() syncronizeWellsWithResults(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES { // Update simulation well fractures after well cell results are imported @@ -797,7 +784,6 @@ void RimEclipseView::onLoadDataAndUpdate() fracture->loadDataAndUpdate(); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES this->scheduleCreateDisplayModelAndRedraw(); } @@ -1046,7 +1032,6 @@ void RimEclipseView::updateLegends() this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); if (stimPlanLegend) { @@ -1057,7 +1042,6 @@ void RimEclipseView::updateLegends() m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -1395,8 +1379,6 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(faultResultSettings()); uiTreeOrdering.add(wellCollection()); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); RimOilField* oilfield = project->activeOilField(); @@ -1408,7 +1390,6 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(fractureColors()); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES uiTreeOrdering.add(faultCollection()); uiTreeOrdering.add(m_crossSectionCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 260cee92a1..db6aea08e9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -53,9 +53,7 @@ class RimFaultInViewCollection; class RimReservoirCellResultsStorage; class RimReservoirCellResultsStorage; class RimSimWellInViewCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimStimPlanColors; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES class RiuViewer; class RivReservoirSimWellsPartMgr; class RivIntersectionPartMgr; @@ -85,9 +83,7 @@ class RimEclipseView : public RimGridView caf::PdmChildField cellResult; caf::PdmChildField cellEdgeResult; caf::PdmChildField faultResultSettings; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField fractureColors; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField wellCollection; caf::PdmChildField faultCollection; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 6baafb6d97..81b42b35a9 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -27,11 +27,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimGeoMechResultDefinition.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimStimPlanColors.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - #include "RimViewLinker.h" #include "cafCategoryLegend.h" @@ -208,8 +204,6 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - // Update stim plan templates if relevant RimStimPlanColors* stimPlanColors; firstAncestorOrThisOfType(stimPlanColors); @@ -217,7 +211,6 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { stimPlanColors->updateStimPlanTemplates(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -775,11 +768,9 @@ QList RimLegendConfig::calculateValueOptions(const caf:: { bool hasStimPlanParent = false; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimStimPlanColors* stimPlanColors = nullptr; this->firstAncestorOrThisOfType(stimPlanColors); if (stimPlanColors) hasStimPlanParent = true; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES bool isCategoryResult = false; { diff --git a/ApplicationCode/ProjectDataModel/RimOilField.cpp b/ApplicationCode/ProjectDataModel/RimOilField.cpp index b634f67fb8..47bdd2770d 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationCode/ProjectDataModel/RimOilField.cpp @@ -22,11 +22,7 @@ #include "RimEclipseCaseCollection.h" #include "RimFormationNamesCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - #include "RimGeoMechModels.h" #include "RimObservedData.h" #include "RimObservedDataCollection.h" @@ -47,18 +43,13 @@ RimOilField::RimOilField(void) CAF_PDM_InitFieldNoDefault(&geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png", "", ""); CAF_PDM_InitFieldNoDefault(&wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&fractureDefinitionCollection, "FractureDefinitionCollection", "Defenition of Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&summaryCaseMainCollection,"SummaryCaseCollection","Summary Cases",":/GridModels.png","",""); CAF_PDM_InitFieldNoDefault(&formationNamesCollection,"FormationNamesCollection","Formations","","",""); CAF_PDM_InitFieldNoDefault(&observedDataCollection, "ObservedDataCollection", "Observed Data", ":/Cases16x16.png", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES fractureDefinitionCollection = new RimFractureTemplateCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); summaryCaseMainCollection = new RimSummaryCaseMainCollection(); @@ -73,10 +64,7 @@ RimOilField::~RimOilField(void) { if (wellPathCollection()) delete wellPathCollection(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (fractureDefinitionCollection()) delete fractureDefinitionCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - if (geoMechModels()) delete geoMechModels(); if (analysisModels()) delete analysisModels(); if (summaryCaseMainCollection()) delete summaryCaseMainCollection(); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 56436e0227..b53d3ad220 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -37,13 +37,8 @@ #include "RimEclipseCaseCollection.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" -#include "RimSummaryCalculationCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimFractureTemplateCollection.h" #include "RimFractureTemplate.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - +#include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" #include "RimGridSummaryCase.h" @@ -56,6 +51,7 @@ #include "RimPltPlotCollection.h" #include "RimRftPlotCollection.h" #include "RimScriptCollection.h" +#include "RimSummaryCalculationCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" @@ -484,10 +480,8 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName oilField->summaryCaseMainCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CVF_ASSERT(oilField->fractureDefinitionCollection()); oilField->fractureDefinitionCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } { @@ -937,7 +931,6 @@ std::vector RimProject::geoMechCases() const return cases; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -973,7 +966,6 @@ std::vector RimProject::allFractureTemplates() const } return templates; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -1058,10 +1050,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS if (oilField->geoMechModels()) uiTreeOrdering.add(oilField->geoMechModels()); if (oilField->wellPathCollection()) uiTreeOrdering.add(oilField->wellPathCollection()); if (oilField->formationNamesCollection()) uiTreeOrdering.add(oilField->formationNamesCollection()); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (oilField->fractureDefinitionCollection()) uiTreeOrdering.add(oilField->fractureDefinitionCollection()); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } uiTreeOrdering.add(scriptCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 427324a4ec..a3064d937e 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -138,10 +138,8 @@ class RimProject : public caf::PdmDocument std::vector geoMechCases() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES std::vector allFractureTemplateCollections() const; std::vector allFractureTemplates() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES protected: // Overridden methods diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 15443e52c3..01f8401f66 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -20,32 +20,28 @@ #include "RimSimWellInView.h" -#include "RigSimulationWellCenterLineCalculator.h" +#include "RigActiveCellInfo.h" +#include "RigCell.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" #include "RigSimWellData.h" +#include "RigSimulationWellCenterLineCalculator.h" #include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimIntersectionCollection.h" -#include "RimSimWellInViewCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimSimWellFractureCollection.h" +#include "RimPropertyFilterCollection.h" #include "RimSimWellFracture.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES +#include "RimSimWellFractureCollection.h" +#include "RimSimWellInViewCollection.h" #include "RiuMainWindow.h" #include "RivReservoirViewPartMgr.h" #include "cafPdmUiTreeOrdering.h" - #include "cvfMath.h" -#include "RigCell.h" -#include "RimEclipseCase.h" -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" -#include "RigActiveCellInfo.h" -#include "RimPropertyFilterCollection.h" CAF_PDM_SOURCE_INIT(RimSimWellInView, "Well"); @@ -72,18 +68,14 @@ RimSimWellInView::RimSimWellInView() CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Well Cells", "", "", ""); CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&simwellFractureCollection, "FractureCollection", "Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES name.uiCapability()->setUiHidden(true); name.uiCapability()->setUiReadOnly(true); m_resultWellIndex = cvf::UNDEFINED_SIZE_T; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES simwellFractureCollection= new RimSimWellFractureCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -91,9 +83,7 @@ RimSimWellInView::RimSimWellInView() //-------------------------------------------------------------------------------------------------- RimSimWellInView::~RimSimWellInView() { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (simwellFractureCollection()) delete simwellFractureCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -389,13 +379,11 @@ void RimSimWellInView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- void RimSimWellInView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES for (RimSimWellFracture* fracture : simwellFractureCollection()->simwellFractures()) { uiTreeOrdering.add(fracture); } uiTreeOrdering.skipRemainingChildren(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES const RimEclipseView* reservoirView = nullptr; this->firstAncestorOrThisOfType(reservoirView); diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index 33f544c9f8..14850bbdaa 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -36,10 +36,7 @@ class RigSimWellData; class RigWellResultFrame; struct RigWellResultPoint; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimSimWellFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //================================================================================================== /// @@ -93,9 +90,7 @@ class RimSimWellInView : public caf::PdmObject caf::PdmField showWellCells; caf::PdmField showWellCellFence; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField simwellFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES protected: diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index e9512a9586..a89ea132d6 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -32,10 +32,8 @@ #include "RimProject.h" #include "RimSimWellInView.h" #include "RimWellAllocationPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RiuMainWindow.h" @@ -462,7 +460,6 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha if (m_reservoirView) m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (&wellPipeCoordType == changedField) { for (RimSimWellInView* w : wells) @@ -473,7 +470,6 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha } } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 13a3114346..1c49bb9531 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -261,26 +261,22 @@ const RimWellPathCompletions* RimWellPath::completions() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* RimWellPath::fractureCollection() { CVF_ASSERT(m_completions); return m_completions->fractureCollection(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES const RimWellPathFractureCollection * RimWellPath::fractureCollection() const { CVF_ASSERT(m_completions); return m_completions->fractureCollection(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index e8ae84c308..b7201b54a8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -48,9 +48,7 @@ class RimPerforationCollection; class RimWellPathCompletions; class RigWellPathFormations; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimWellPathFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //================================================================================================== /// @@ -110,10 +108,8 @@ class RimWellPath : public caf::PdmObject const RimPerforationCollection* perforationIntervalCollection() const; const RimWellPathCompletions* completions() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* fractureCollection(); const RimWellPathFractureCollection* fractureCollection() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES RigWellPath* wellPathGeometry(); const RigWellPath* wellPathGeometry() const; diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp index 11902ce077..e5b091dd60 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp @@ -24,9 +24,7 @@ #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" #include "cvfBoundingBox.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "clipper/clipper.hpp" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include @@ -222,7 +220,6 @@ double RigCellGeometryTools::polygonLengthInLocalXdirWeightedByArea(std::vector< return areaWeightedLength; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES double clipperConversionFactor = 10000; //For transform to clipper int @@ -249,7 +246,6 @@ cvf::Vec3d fromClipperPoint(const ClipperLib::IntPoint& clipPoint) return cvf::Vec3d (clipPoint.X, clipPoint.Y, zDValue ) /clipperConversionFactor; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -258,7 +254,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st { std::vector > clippedPolygons; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES // Convert to int for clipper library and store as clipper "path" ClipperLib::Path polygon1path; for (cvf::Vec3d& v : polygon1) @@ -289,7 +284,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st } clippedPolygons.push_back(clippedPolygon); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolygons; } @@ -297,7 +291,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void fillInterpolatedSubjectZ(ClipperLib::IntPoint& e1bot, ClipperLib::IntPoint& e1top, ClipperLib::IntPoint& e2bot, @@ -350,7 +343,6 @@ void fillUndefinedZ(ClipperLib::IntPoint& e1bot, { pt.Z = std::numeric_limits::max(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// Assumes x.y plane polygon. Polyline might have a Z, and the returned Z is the polyline Z, interpolated if it is clipped. @@ -361,7 +353,6 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo { std::vector > clippedPolyline; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //Adjusting polygon to avoid clipper issue with interpolating z-values when lines crosses though polygon vertecies std::vector adjustedPolygon = ajustPolygonToAvoidIntersectionsAtVertex(polyLine, polygon); @@ -410,7 +401,6 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo } clippedPolyline.push_back(clippedPolygon); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolyline; } diff --git a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp index 52d3241478..18009f2c1a 100644 --- a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp @@ -142,7 +142,6 @@ TEST(RigCellGeometryTools, findCellAverageZTest) } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -414,4 +413,3 @@ TEST(RigWellPathStimplanIntersector, intersection) } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 850f84d005..ecbe5af3ed 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -357,9 +357,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewWellPathFractureAtPosFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature"; menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature"; @@ -402,9 +400,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); menuBuilder << "RicShowContributingWellsFeature"; menuBuilder.addSeparator(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewSimWellFractureAtPosFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder.addSeparator(); menuBuilder << "RicNewSimWellIntersectionFeature"; } @@ -500,7 +496,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (rivObjectSourceInfo) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); { bool blockSelectionOfFracture = false; @@ -550,7 +545,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM // Display result info text RiuMainWindow::instance()->setResultInfo(resultInfoText); } -#endif //USE_PROTOTYPE_FEATURE_FRACTURES } if (rivSourceInfo) From f4bae6f7962738fe1e1968f220700647ec219aa5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2018 21:11:14 +0100 Subject: [PATCH 0353/1027] #2529 Fracture : Remove RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES from CMake files --- ApplicationCode/CMakeLists.txt | 17 +----- .../CMakeLists_files.cmake | 31 ++++------ .../FileInterface/CMakeLists_files.cmake | 14 +---- .../ModelVisualization/CMakeLists_files.cmake | 15 +---- .../ProjectDataModel/CMakeLists_files.cmake | 17 ++---- .../Completions/CMakeLists_files.cmake | 56 ++++++++----------- .../ReservoirDataModel/CMakeLists_files.cmake | 23 ++------ .../UnitTests/CMakeLists_files.cmake | 7 +-- CMakeLists.txt | 28 +++------- 9 files changed, 57 insertions(+), 151 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index ade87f19a1..8c27af7b02 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -136,14 +136,8 @@ list( APPEND REFERENCED_CMAKE_FILES CommandFileInterface/CMakeLists_files.cmake CommandFileInterface/Core/CMakeLists_files.cmake -) - -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND REFERENCED_CMAKE_FILES Commands/FractureCommands/CMakeLists_files.cmake - ) -endif() - +) option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF) if (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS) @@ -208,11 +202,6 @@ if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_SOURING) endif() -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - add_definitions(-DUSE_PROTOTYPE_FEATURE_FRACTURES) -endif() - - ############################################################################# # Qt specifics: Moc, ui, resources ############################################################################# @@ -577,10 +566,6 @@ if(RESINSIGHT_FOUND_HDF5) set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_souring") endif() -if(RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_fractures") -endif() - # Append el5 when compiled on RHEL5 and el6 if compiled on RHEL6 if (NOT "${RESINSIGHT_RHEL_SYSTEM_NAME}" STREQUAL "") set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_${RESINSIGHT_RHEL_SYSTEM_NAME}") diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 647b7d6ba0..4e22904d0b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -13,18 +13,13 @@ ${CEE_CURRENT_LIST_DIR}RigCompletionData.h ${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h ${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h ${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.h +${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h +${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h +${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h +${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h - ) -endif() - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp @@ -35,19 +30,13 @@ ${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp ${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp ${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp ${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp +${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp +${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp +${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp +${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 3f2483b921..41fd9ff108 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -42,17 +42,12 @@ ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.h ${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.h +${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.h - ) -endif() - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.cpp ${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp @@ -89,17 +84,12 @@ ${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp ${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.cpp ${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.cpp +${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index a575ad5258..fa10457974 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -41,15 +41,9 @@ ${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h ${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h ${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.h ${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.h +${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp ${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp @@ -82,14 +76,9 @@ ${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.cpp ${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.cpp ${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.cpp +${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 337ea62e44..33a2c5e460 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -100,14 +100,10 @@ ${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.h ${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.h ${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.h ${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.h +${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.h +${CEE_CURRENT_LIST_DIR}RimStimPlanColors.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.h - ) -endif() set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.cpp @@ -205,15 +201,10 @@ ${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.cpp +${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.cpp +${CEE_CURRENT_LIST_DIR}RimStimPlanColors.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake index 7ea1beaf38..1bb1525af6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake @@ -14,25 +14,19 @@ ${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.h ${CEE_CURRENT_LIST_DIR}RimPerforationCollection.h ${CEE_CURRENT_LIST_DIR}RimPerforationInterval.h ${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.h +${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h +${CEE_CURRENT_LIST_DIR}RimFracture.h +${CEE_CURRENT_LIST_DIR}RimFractureContainment.h +${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.h +${CEE_CURRENT_LIST_DIR}RimFractureTemplate.h +${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.h +${CEE_CURRENT_LIST_DIR}RimSimWellFracture.h +${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.h +${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.h +${CEE_CURRENT_LIST_DIR}RimWellPathFracture.h +${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFracture.h - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.h - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RimCompletionCellIntersectionCalc.cpp @@ -44,25 +38,19 @@ ${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.cpp ${CEE_CURRENT_LIST_DIR}RimPerforationCollection.cpp ${CEE_CURRENT_LIST_DIR}RimPerforationInterval.cpp ${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.cpp +${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp +${CEE_CURRENT_LIST_DIR}RimFracture.cpp +${CEE_CURRENT_LIST_DIR}RimFractureContainment.cpp +${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.cpp +${CEE_CURRENT_LIST_DIR}RimFractureTemplate.cpp +${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.cpp +${CEE_CURRENT_LIST_DIR}RimSimWellFracture.cpp +${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.cpp +${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.cpp +${CEE_CURRENT_LIST_DIR}RimWellPathFracture.cpp +${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 7e50d6080c..5cc7879c20 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -65,16 +65,11 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h +${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.h +${CEE_CURRENT_LIST_DIR}RigFractureGrid.h +${CEE_CURRENT_LIST_DIR}RigFractureCell.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.h - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.h - ${CEE_CURRENT_LIST_DIR}RigFractureCell.h - ) -endif() - set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp @@ -132,17 +127,11 @@ ${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp ${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp +${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.cpp +${CEE_CURRENT_LIST_DIR}RigFractureGrid.cpp +${CEE_CURRENT_LIST_DIR}RigFractureCell.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureCell.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index cceb7d1db9..234b6d798a 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -42,14 +42,9 @@ ${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp ${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp ${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader-Test.cpp ${CEE_CURRENT_LIST_DIR}RimRelocatePath-Test.cpp +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser-Test.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser-Test.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1df8eeada..eed49f6124 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,29 +278,19 @@ list(APPEND THIRD_PARTY_LIBRARIES ) ################################################################################ -# Prototype feature Fractures +# Eigen ################################################################################ -option (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES "Enable prototype feature Fractures" ON) -mark_as_advanced(FORCE RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) +include_directories(SYSTEM ThirdParty/Eigen-Subset) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - - ################################################################################ - # Eigen - ################################################################################ - include_directories(SYSTEM ThirdParty/Eigen-Subset) - - ################################################################################ - # clipper - ################################################################################ - - add_subdirectory(ThirdParty/clipper) +################################################################################ +# clipper +################################################################################ - list(APPEND THIRD_PARTY_LIBRARIES - clipper - ) +add_subdirectory(ThirdParty/clipper) -endif() # RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES +list(APPEND THIRD_PARTY_LIBRARIES + clipper +) ################################################################################ From cbbc9c0f26ba48a49f1a2e881063965924b3463b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 09:39:47 +0100 Subject: [PATCH 0354/1027] #2496 Tensor vectors: Two new paletts --- .../Application/Tools/RiaColorTables.cpp | 23 +++++++++++++--- .../Application/Tools/RiaColorTables.h | 3 ++- .../RivTensorResultPartMgr.cpp | 27 +++++++++++-------- .../ProjectDataModel/RimTensorResults.cpp | 3 ++- .../ProjectDataModel/RimTensorResults.h | 3 ++- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index d3644b1512..19c925a102 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -197,7 +197,7 @@ const caf::ColorTable& RiaColorTables::tensorWhiteGrayBlackPaletteColors() { static std::vector colors{ cvf::Color3ub::WHITE, - cvf::Color3ub::GRAY, + cvf::Color3ub::LIGHT_GRAY, cvf::Color3ub::BLACK, }; @@ -208,12 +208,27 @@ const caf::ColorTable& RiaColorTables::tensorWhiteGrayBlackPaletteColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const caf::ColorTable& RiaColorTables::tensorMagentaBrownBlackPaletteColors() +const caf::ColorTable& RiaColorTables::tensorOrangeBlueWhitePaletteColors() { static std::vector colors{ - cvf::Color3ub::DARK_MAGENTA, + cvf::Color3ub(236, 118, 0), // Orange + cvf::Color3ub(56, 56, 255), // Vivid Blue + cvf::Color3ub(210, 248, 250), // White Turquoiseish + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorsMagentaBrownGrayPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub(248, 0, 170), // Magenta cvf::Color3ub::BROWN, - cvf::Color3ub::BLACK, + cvf::Color3ub::LIGHT_GRAY, }; static caf::ColorTable colorTable = caf::ColorTable(colors); diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 5f7c44ffcc..2fc612cc3d 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -38,7 +38,8 @@ class RiaColorTables static const caf::ColorTable& redWhiteBluePaletteColors(); static const caf::ColorTable& categoryPaletteColors(); static const caf::ColorTable& tensorWhiteGrayBlackPaletteColors(); - static const caf::ColorTable& tensorMagentaBrownBlackPaletteColors(); + static const caf::ColorTable& tensorOrangeBlueWhitePaletteColors(); + static const caf::ColorTable& tensorsMagentaBrownGrayPaletteColors(); static const caf::ColorTable& angularPaletteColors(); static const caf::ColorTable& stimPlanPaletteColors(); static const caf::ColorTable& faultsPaletteColors(); diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index b785f86e8d..933fefcceb 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -338,18 +338,18 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector discreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; auto vectorColors = m_rimReservoirView->tensorResults()->vectorColors(); - if (vectorColors == RimTensorResults::MAGENTA_BROWN_BLACK || vectorColors == RimTensorResults::WHITE_GRAY_BLACK) + if (vectorColors == RimTensorResults::RESULT_COLORS) { - activeScalerMapper = discreteScalarMapper.p(); - - createOneColorPerPrincipalScalarMapper(vectorColors, discreteScalarMapper.p()); - createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, discreteScalarMapper.p()); + activeScalerMapper = m_rimReservoirView->tensorResults()->legendConfig()->scalarMapper(); + + createResultColorTextureCoords(lineTexCoords.p(), tensorVisualizations, activeScalerMapper); } else { - activeScalerMapper = m_rimReservoirView->tensorResults()->legendConfig()->scalarMapper(); + activeScalerMapper = discreteScalarMapper.p(); - createResultColorTextureCoords(lineTexCoords.p(), tensorVisualizations, activeScalerMapper); + createOneColorPerPrincipalScalarMapper(vectorColors, discreteScalarMapper.p()); + createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, discreteScalarMapper.p()); } caf::ScalarMapperEffectGenerator surfEffGen(activeScalerMapper, caf::PO_1); @@ -381,13 +381,18 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalScalarMapper(const RimTen cvf::Color3ubArray arrowColors; arrowColors.resize(3); - if (colorSet == RimTensorResults::MAGENTA_BROWN_BLACK) + + if (colorSet == RimTensorResults::WHITE_GRAY_BLACK) { - arrowColors = RiaColorTables::tensorMagentaBrownBlackPaletteColors().color3ubArray(); + arrowColors = RiaColorTables::tensorWhiteGrayBlackPaletteColors().color3ubArray(); } - else if (colorSet == RimTensorResults::WHITE_GRAY_BLACK) + else if (colorSet == RimTensorResults::ORANGE_BLUE_WHITE) { - arrowColors = RiaColorTables::tensorWhiteGrayBlackPaletteColors().color3ubArray(); + arrowColors = RiaColorTables::tensorOrangeBlueWhitePaletteColors().color3ubArray(); + } + else if (colorSet == RimTensorResults::MAGENTA_BROWN_GRAY) + { + arrowColors = RiaColorTables::tensorsMagentaBrownGrayPaletteColors().color3ubArray(); } scalarMapper->setColors(arrowColors); diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index 97edd23d5e..dd874254c1 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -36,7 +36,8 @@ namespace caf void AppEnum< RimTensorResults::TensorColors >::setUp() { addItem(RimTensorResults::WHITE_GRAY_BLACK , "WHITE_GRAY_BLACK", "White, Gray, Black"); - addItem(RimTensorResults::MAGENTA_BROWN_BLACK, "MAGENTA_BROWN_BLACK", "Magenta, Brown, Black"); + addItem(RimTensorResults::ORANGE_BLUE_WHITE, "ORANGE_BLUE_WHITE", "Orange, Blue, White"); + addItem(RimTensorResults::MAGENTA_BROWN_GRAY, "MAGENTA_BROWN_GRAY", "Magenta, Brown, Gray"); addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors"); setDefault(RimTensorResults::WHITE_GRAY_BLACK); diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index 08fe0130b5..30990a0ab0 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -43,7 +43,8 @@ class RimTensorResults : public caf::PdmObject enum TensorColors { WHITE_GRAY_BLACK, - MAGENTA_BROWN_BLACK, + ORANGE_BLUE_WHITE, + MAGENTA_BROWN_GRAY, RESULT_COLORS }; From cfa3443cddd1520450817236fa7d760f4fca8caf Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 10:32:59 +0100 Subject: [PATCH 0355/1027] #2530 Mohr circle: Fix crash when selected cell has no value --- .../UserInterface/RiuMohrsCirclePlot.cpp | 44 ++++++++++++++++--- .../UserInterface/RiuMohrsCirclePlot.h | 2 + 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index e1e6b1bfd9..86d254aaa5 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -79,12 +79,12 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) { - CVF_ASSERT(p1 > p2); - CVF_ASSERT(p2 > p3); - - m_principal1 = p1; - m_principal2 = p2; - m_principal3 = p3; + if (isValidPrincipals(p1, p2, p3)) + { + m_principal1 = p1; + m_principal2 = p2; + m_principal3 = p3; + } } //-------------------------------------------------------------------------------------------------- @@ -92,6 +92,12 @@ void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double p3) { + if (!isValidPrincipals(p1, p2, p3)) + { + clearPlot(); + return; + } + setPrincipals(p1, p2, p3); redrawEnvelope(); @@ -475,3 +481,29 @@ void RiuMohrsCirclePlot::replotAndScaleAxis() m_rescaler->rescale(); this->plotLayout()->setAlignCanvasToScales(true); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuMohrsCirclePlot::isValidPrincipals(double p1, double p2, double p3) +{ + //Inf + if (p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL) + { + return false; + } + + //Nan + if ((p1 != p1) || (p2 != p2) || p3 != p3) + { + return false; + } + + //Principal rules: + if ((p1 < p2) || (p2 < p3)) + { + return false; + } + + return true; +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 9adcfc4840..85bd3798de 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -83,6 +83,8 @@ class RiuMohrsCirclePlot : public QwtPlot void replotAndScaleAxis(); + static bool isValidPrincipals(double p1, double p2, double p3); + private: double m_principal1; double m_principal2; From 10bc5c92ab3dbf519dbe6f9fdfd46036008f008d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 12:05:37 +0100 Subject: [PATCH 0356/1027] #2532 Fracture : Create copy of fracture template if non-matching units is detected --- .../Application/RiaApplication.cpp | 1 + .../Completions/RimFracture.cpp | 38 ++++++----- .../Completions/RimFracture.h | 1 + .../RimFractureTemplateCollection.cpp | 65 +++++++++++++++++++ .../RimFractureTemplateCollection.h | 1 + 5 files changed, 91 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index fa5b8c1d15..d96637c2bc 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -511,6 +511,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi } oilField->fractureDefinitionCollection()->loadAndUpdateData(); + oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit(); oilField->fractureDefinitionCollection()->setDefaultConductivityResultIfEmpty(); { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 75567588a8..4c97455d26 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -342,6 +342,28 @@ cvf::Mat4d RimFracture::transformMatrix() const return m; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFracture::setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate) +{ + if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit()) + { + QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); + + QString warningText = + QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " + "fracture template of unit '%1'") + .arg(fractureUnitText); + + QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); + + return; + } + + m_fractureTemplate = fractureTemplate; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -622,21 +644,7 @@ size_t RimFracture::findAnchorEclipseCell(const RigMainGrid* mainGrid ) const //-------------------------------------------------------------------------------------------------- void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) { - if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit()) - { - QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); - - QString warningText = - QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " - "fracture template of unit '%1'") - .arg(fractureUnitText); - - QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); - - return; - } - - m_fractureTemplate = fractureTemplate; + setFractureTemplateNoUpdate(fractureTemplate); if (!fractureTemplate) { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index b08a6137ed..915822e312 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -72,6 +72,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf cvf::Mat4d transformMatrix() const; + void setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate); void setFractureTemplate(RimFractureTemplate* fractureTemplate); RimFractureTemplate* fractureTemplate() const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 05c4fe4aa0..074ad995c1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -18,6 +18,8 @@ #include "RimFractureTemplateCollection.h" +#include "RiaLogging.h" + #include "RigStatisticsMath.h" #include "RimCase.h" @@ -127,6 +129,69 @@ void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, c if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUnit() +{ + // If a fracture has different unit than the associated template, create a copy of template in correct unit + + std::vector templatesToBeAdded; + + for (RimFractureTemplate* fractureTemplate : fractureDefinitions()) + { + if (fractureTemplate) + { + RimFractureTemplate* templateWithMatchingUnit = nullptr; + + std::vector referringObjects; + fractureTemplate->objectsWithReferringPtrFields(referringObjects); + + for (auto refObj : referringObjects) + { + auto fracture = dynamic_cast(refObj); + if (fracture && fracture->fractureUnit() != fractureTemplate->fractureTemplateUnit()) + { + if (!templateWithMatchingUnit) + { + templateWithMatchingUnit = dynamic_cast(fractureTemplate->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + auto currentUnit = fractureTemplate->fractureTemplateUnit(); + auto neededUnit = RiaEclipseUnitTools::UNITS_UNKNOWN; + if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + neededUnit = RiaEclipseUnitTools::UNITS_FIELD; + } + else if (currentUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + neededUnit = RiaEclipseUnitTools::UNITS_METRIC; + } + + templateWithMatchingUnit->convertToUnitSystem(neededUnit); + + QString name = templateWithMatchingUnit->name(); + name += " (created to match fracture unit)"; + templateWithMatchingUnit->setName(name); + + templatesToBeAdded.push_back(templateWithMatchingUnit); + } + + RiaLogging::warning("Detected fracture with different unit than fracture template. Creating copy of template " + "with matching unit."); + + CVF_ASSERT(templateWithMatchingUnit->fractureTemplateUnit() == fracture->fractureUnit()); + fracture->setFractureTemplateNoUpdate(templateWithMatchingUnit); + } + } + } + } + + for (auto templateWithMatchingUnit : templatesToBeAdded) + { + fractureDefinitions.push_back(templateWithMatchingUnit); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 876817c762..2d650b79cf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -46,6 +46,7 @@ class RimFractureTemplateCollection : public caf::PdmObject std::vector > resultNamesAndUnits() const; void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; + void createAndAssignTemplateCopyForNonMatchingUnit(); void loadAndUpdateData(); void setDefaultConductivityResultIfEmpty(); From f4d4a8aa46d3811abe993abc1fcc6ea485bfab7e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 12:40:33 +0100 Subject: [PATCH 0357/1027] #2531 Mohr Circle: Add Info text --- .../UserInterface/RiuMohrsCirclePlot.cpp | 75 ++++++++++++++----- .../UserInterface/RiuMohrsCirclePlot.h | 38 ++++++---- 2 files changed, 80 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 86d254aaa5..07dcbd5595 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -44,6 +44,7 @@ #include "qwt_plot_marker.h" #include "qwt_plot_rescaler.h" #include "qwt_plot_shapeitem.h" +#include "qwt_plot_textlabel.h" #include @@ -102,6 +103,7 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double redrawEnvelope(); redrawCircles(); + addInfoLabel(); } //-------------------------------------------------------------------------------------------------- @@ -140,6 +142,7 @@ void RiuMohrsCirclePlot::clearPlot() { deleteCircles(); deleteEnvelope(); + deleteInfoLabel(); this->replot(); } @@ -281,6 +284,46 @@ void RiuMohrsCirclePlot::deleteEnvelope() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::addInfoLabel() +{ + deleteInfoLabel(); + + QString textBuilder; + + textBuilder.append(QString("Factor of Safety: %1
").arg("Coming soon")); + textBuilder.append(QString("Friction Angle: %1
").arg(m_frictionAngle)); + textBuilder.append(QString("Cohesion: %1
").arg(m_cohesion)); + textBuilder.append(QString("σ1: %1
").arg(m_principal1)); + textBuilder.append(QString("σ2: %1
").arg(m_principal2)); + textBuilder.append(QString("σ3: %1
").arg(m_principal3)); + + QwtText text = textBuilder; + + text.setRenderFlags(Qt::AlignLeft | Qt::AlignTop); + + m_infoTextItem = new QwtPlotTextLabel(); + m_infoTextItem->setText(text); + m_infoTextItem->attach(this); + + this->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deleteInfoLabel() +{ + if (m_infoTextItem) + { + m_infoTextItem->detach(); + delete m_infoTextItem; + m_infoTextItem = nullptr; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -305,10 +348,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz clearPlot(); return; } - + setCohesion(geoMechView->geoMechCase()->cohesion()); setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); - RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); size_t i, j, k; @@ -317,23 +359,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz int elmId = femPart->elmId(cellIndex); QString title; - QString resultPos; QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); - - switch (geoMechView->cellResultResultDefinition()->resultPositionType()) - { - case RIG_ELEMENT_NODAL: - resultPos = "Element Nodal"; - break; - - case RIG_INTEGRATION_POINT: - resultPos = "Integration Point"; - break; - default: - break; - } - title += QString("%1, %2").arg(resultPos).arg(fieldName); + title += QString("%1").arg(fieldName); title += QString(", Element Id[%1], ijk[%2,%3,%4]").arg(elmId).arg(i).arg(j).arg(k); this->setTitle(title); @@ -375,8 +403,13 @@ void RiuMohrsCirclePlot::setDefaults() m_envolopePlotItem = nullptr; m_transparentCurve = nullptr; + + m_infoTextItem = nullptr; + m_cohesion = HUGE_VAL; m_frictionAngle = HUGE_VAL; + + m_factorOfSafety = 0; } //-------------------------------------------------------------------------------------------------- @@ -413,6 +446,14 @@ void RiuMohrsCirclePlot::setCohesion(double cohesion) m_cohesion = cohesion; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setFactorOfSafety(double fos) +{ + m_factorOfSafety = fos; +} + //-------------------------------------------------------------------------------------------------- /// Add a transparent curve to make tooltip available on principals crossing the x-axis //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 85bd3798de..12cbd0165a 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -23,12 +23,13 @@ #include -class RiuSelectionItem; -class RimGeoMechView; -class QwtRoundScaleDraw; -class QwtPlotRescaler; class QWidget; class QwtPlotCurve; +class QwtPlotRescaler; +class QwtPlotTextLabel; +class QwtRoundScaleDraw; +class RimGeoMechView; +class RiuSelectionItem; //================================================================================================== // @@ -49,18 +50,6 @@ class RiuMohrsCirclePlot : public QwtPlot void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); void clearPlot(); -protected: - virtual QSize sizeHint() const override; - virtual QSize minimumSizeHint() const override; - - void redrawCircles(); - void deleteCircles(); - - void redrawEnvelope(); - void deleteEnvelope(); - - void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); - private: struct MohrCircle { @@ -73,11 +62,26 @@ class RiuMohrsCirclePlot : public QwtPlot }; private: + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; + + void redrawCircles(); + void deleteCircles(); + + void redrawEnvelope(); + void deleteEnvelope(); + + void addInfoLabel(); + void deleteInfoLabel(); + + void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); + void setDefaults(); void createMohrCircles(); void setFrictionAngle(double frictionAngle); void setCohesion(double cohesion); + void setFactorOfSafety(double fos); void updateTransparentCurveOnPrincipals(); @@ -101,5 +105,7 @@ class RiuMohrsCirclePlot : public QwtPlot double m_cohesion; double m_factorOfSafety; + QwtPlotTextLabel* m_infoTextItem; + QwtPlotRescaler* m_rescaler; }; From 4f8c585be7f8a657f4908342957b11c36ac65593 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 12:59:14 +0100 Subject: [PATCH 0358/1027] #2534 Mohr circle: Always use SE as result --- .../UserInterface/RiuMohrsCirclePlot.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 07dcbd5595..fcdc7dca3b 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -27,6 +27,7 @@ #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" +#include "RigFemResultPosEnum.h" #include "RigGeoMechCaseData.h" #include "RimGeoMechCase.h" @@ -334,15 +335,10 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); int frameIdx = geoMechView->currentTimeStep(); + RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", ""); - RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress(); - if (!(currentAddress.fieldName == "SE" || currentAddress.fieldName == "ST" || currentAddress.fieldName == "NE")) - { - clearPlot(); - return; - } // TODO: All tensors are calculated every time this function is called. FIX - std::vector vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx); + std::vector vertexTensors = resultCollection->tensors(address, 0, frameIdx); if (vertexTensors.empty()) { clearPlot(); @@ -356,14 +352,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(cellIndex, &i, &j, &k); - int elmId = femPart->elmId(cellIndex); - - QString title; - QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); - - title += QString("%1").arg(fieldName); - - title += QString(", Element Id[%1], ijk[%2,%3,%4]").arg(elmId).arg(i).arg(j).arg(k); + QString title = QString("SE, Element Id[%1], ijk[%2,%3,%4]").arg(femPart->elmId(cellIndex)).arg(i).arg(j).arg(k); this->setTitle(title); caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; From 2d931a81f55b3665a483e4a00881cb1b4d01cb5a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 14:09:31 +0100 Subject: [PATCH 0359/1027] #2523 Mohr circle: Remove colors from circles --- .../Application/Tools/RiaColorTables.cpp | 16 -------------- .../Application/Tools/RiaColorTables.h | 1 - .../UserInterface/RiuMohrsCirclePlot.cpp | 22 ++++++------------- .../UserInterface/RiuMohrsCirclePlot.h | 5 ++--- 4 files changed, 9 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 19c925a102..27b4d52408 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -497,22 +497,6 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors() return colorTable; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const caf::ColorTable& RiaColorTables::mohrsCirclePaletteColors() -{ - static std::vector colors{ - cvf::Color3ub(202, 0, 0), // Red - cvf::Color3ub(0, 112, 136), // Dark Green-Blue - cvf::Color3ub(56, 56, 255), // Vivid Blue - }; - - static caf::ColorTable colorTable = caf::ColorTable(colors); - - return colorTable; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 2fc612cc3d..ab1a3de8a1 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -53,7 +53,6 @@ class RiaColorTables static const caf::ColorTable& wellLogPlotPaletteColors(); static const caf::ColorTable& selectionPaletteColors(); static const caf::ColorTable& timestepsPaletteColors(); - static const caf::ColorTable& mohrsCirclePaletteColors(); static cvf::Color3f undefinedCellColor(); static cvf::Color3f perforationLengthColor(); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index fcdc7dca3b..f52917b6d1 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -21,8 +21,6 @@ #include "RiuSelectionManager.h" #include "RiuSummaryQwtPlot.h" -#include "RiaColorTables.h" - #include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" @@ -172,18 +170,14 @@ void RiuMohrsCirclePlot::redrawCircles() deleteCircles(); createMohrCircles(); - caf::ColorTable colors = RiaColorTables::mohrsCirclePaletteColors(); - - for (size_t i = 0; i < m_mohrCircles.size(); i++) + for (const MohrCircle& circle : m_mohrCircles) { - MohrCircle* circle = &m_mohrCircles[i]; QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle"); QPainterPath* circleDrawing = new QPainterPath(); - QPointF center(circle->centerX, 0); - circleDrawing->addEllipse(center, circle->radius, circle->radius); + QPointF center(circle.centerX, 0); + circleDrawing->addEllipse(center, circle.radius, circle.radius); - plotItem->setPen(QPen(colors.cycledQColor(i))); plotItem->setShape(*circleDrawing); plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); plotItem->attach(this); @@ -294,9 +288,10 @@ void RiuMohrsCirclePlot::addInfoLabel() QString textBuilder; - textBuilder.append(QString("Factor of Safety: %1
").arg("Coming soon")); textBuilder.append(QString("Friction Angle: %1
").arg(m_frictionAngle)); - textBuilder.append(QString("Cohesion: %1
").arg(m_cohesion)); + textBuilder.append(QString("Cohesion: %1

").arg(m_cohesion)); + + textBuilder.append(QString("Factor of Safety: %1
").arg("Coming soon")); textBuilder.append(QString("σ1: %1
").arg(m_principal1)); textBuilder.append(QString("σ2: %1
").arg(m_principal2)); textBuilder.append(QString("σ3: %1
").arg(m_principal3)); @@ -398,7 +393,7 @@ void RiuMohrsCirclePlot::setDefaults() m_cohesion = HUGE_VAL; m_frictionAngle = HUGE_VAL; - m_factorOfSafety = 0; + m_factorOfSafety = HUGE_VAL; } //-------------------------------------------------------------------------------------------------- @@ -406,15 +401,12 @@ void RiuMohrsCirclePlot::setDefaults() //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::createMohrCircles() { - m_mohrCircles[0].component = 2; m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2.0; m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2.0; - m_mohrCircles[1].component = 1; m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2.0; m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2.0; - m_mohrCircles[2].component = 3; m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2.0; m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2.0; } diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 12cbd0165a..181262d8be 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -53,10 +53,9 @@ class RiuMohrsCirclePlot : public QwtPlot private: struct MohrCircle { - MohrCircle(size_t component, double radius, double centerX) - : component(component), radius(radius), centerX(centerX) {} + MohrCircle(double radius, double centerX) + : radius(radius), centerX(centerX) {} MohrCircle() {}; - size_t component; //1, 2 or 3 double radius; double centerX; }; From 2734f52e53295c01e47b12063138f417906ce595 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 14:39:07 +0100 Subject: [PATCH 0360/1027] #2533 Mohr Circle: Calculate Element FOS --- .../UserInterface/RiuMohrsCirclePlot.cpp | 24 ++++++++++++++++++- .../UserInterface/RiuMohrsCirclePlot.h | 4 ++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index f52917b6d1..b74bf6d3e6 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -291,7 +291,7 @@ void RiuMohrsCirclePlot::addInfoLabel() textBuilder.append(QString("Friction Angle: %1
").arg(m_frictionAngle)); textBuilder.append(QString("Cohesion: %1

").arg(m_cohesion)); - textBuilder.append(QString("Factor of Safety: %1
").arg("Coming soon")); + textBuilder.append(QString("Factor of Safety: %1
").arg(m_factorOfSafety)); textBuilder.append(QString("σ1: %1
").arg(m_principal1)); textBuilder.append(QString("σ2: %1
").arg(m_principal2)); textBuilder.append(QString("σ3: %1
").arg(m_principal3)); @@ -361,6 +361,8 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz cvf::Vec3f principalDirs[3]; cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs); + setFactorOfSafety(calculateFOS(elmTensor)); + setPrincipalsAndRedrawPlot(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); } @@ -529,3 +531,23 @@ bool RiuMohrsCirclePlot::isValidPrincipals(double p1, double p2, double p3) return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RiuMohrsCirclePlot::calculateFOS(const caf::Ten3f& tensor) +{ + cvf::Vec3f dirs[3]; + cvf::Vec3f principals = tensor.calculatePrincipals(dirs); + + float se1 = principals[0]; + float se3 = principals[2]; + + float tanFricAng = tan(cvf::Math::toRadians(m_frictionAngle)); + float cohPrTanFricAngle = (float)(m_cohesion / tanFricAng); + + float pi_4 = 0.785398163397448309616f; + float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); + + return tanFricAng / tan(rho); +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 181262d8be..10c6c758a8 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -21,6 +21,8 @@ #include "qwt_plot.h" #include "qwt_plot_item.h" +#include "cafTensor3.h" + #include class QWidget; @@ -87,6 +89,8 @@ class RiuMohrsCirclePlot : public QwtPlot void replotAndScaleAxis(); static bool isValidPrincipals(double p1, double p2, double p3); + + float calculateFOS(const caf::Ten3f& tensor); private: double m_principal1; From 599909a9e851e7cfe0862f45c8f5d4c9c67d23c1 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 27 Feb 2018 15:06:59 +0100 Subject: [PATCH 0361/1027] #2533 Mohr circle: Round of FOS to 2 decimals --- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index b74bf6d3e6..28fa92dbd2 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -291,7 +291,7 @@ void RiuMohrsCirclePlot::addInfoLabel() textBuilder.append(QString("Friction Angle: %1
").arg(m_frictionAngle)); textBuilder.append(QString("Cohesion: %1

").arg(m_cohesion)); - textBuilder.append(QString("Factor of Safety: %1
").arg(m_factorOfSafety)); + textBuilder.append(QString("Factor of Safety: %1
").arg(QString::number(m_factorOfSafety, 'f', 2))); textBuilder.append(QString("σ1: %1
").arg(m_principal1)); textBuilder.append(QString("σ2: %1
").arg(m_principal2)); textBuilder.append(QString("σ3: %1
").arg(m_principal3)); From 6a3b43ec7c77cbf6fe3f045b19881c52b171ae68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 11:23:43 +0100 Subject: [PATCH 0362/1027] #2487 Avoid switching view when clicking objs in the intersectino view. Some minor refactoring of the MainWindows --- .../UserInterface/RiuMainPlotWindow.cpp | 33 +++---------------- .../UserInterface/RiuMainPlotWindow.h | 10 ++---- .../UserInterface/RiuMainWindow.cpp | 18 +++++----- ApplicationCode/UserInterface/RiuMainWindow.h | 7 ++-- .../UserInterface/RiuMainWindowBase.cpp | 22 +++++++++++++ .../UserInterface/RiuMainWindowBase.h | 17 ++++++++++ .../UserInterface/RiuViewerCommands.cpp | 8 ++--- 7 files changed, 60 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 620d09a0a4..7928a9afbc 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -576,14 +576,6 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) m_blockSlotSubWindowActivated = false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmUiTreeView* RiuMainPlotWindow::projectTreeView() -{ - return m_projectTreeView; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -631,22 +623,22 @@ void RiuMainPlotWindow::selectedObjectsChanged() { firstSelectedObject = dynamic_cast(uiItems[0]); } + m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within if (!firstSelectedObject) { caf::PdmFieldHandle* selectedField = dynamic_cast(uiItems[0]); - if (selectedField) - firstSelectedObject = selectedField->ownerObject(); + if (selectedField) firstSelectedObject = selectedField->ownerObject(); } - if (!firstSelectedObject) - return; + if (!firstSelectedObject) return; + RimViewWindow* selectedWindow = dynamic_cast(firstSelectedObject); if (!selectedWindow) { @@ -714,13 +706,6 @@ void RiuMainPlotWindow::restoreTreeViewState() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::selectAsCurrentItem(caf::PdmObject* object) -{ - m_projectTreeView->selectAsCurrentItem(object); -} //-------------------------------------------------------------------------------------------------- /// @@ -730,14 +715,6 @@ void RiuMainPlotWindow::setDefaultWindowSize() resize(1000, 810); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) -{ - m_projectTreeView->setExpanded(uiItem, expanded); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index 214df5ef2c..2872200ee0 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -55,7 +55,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase public: RiuMainPlotWindow(); - virtual QString mainWindowName(); + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiBeforeProjectClose(); @@ -65,15 +65,10 @@ class RiuMainPlotWindow : public RiuMainWindowBase void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override; void setActiveViewer(QWidget* subWindow) override; - caf::PdmUiTreeView* projectTreeView(); - void hideAllDockWindows(); - void selectAsCurrentItem(caf::PdmObject* object); - void setDefaultWindowSize(); - void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; @@ -87,7 +82,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase void updateSummaryPlotToolBar(); protected: - virtual void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; private: void setPdmRoot(caf::PdmObject* pdmRoot); @@ -121,7 +116,6 @@ private slots: QMenu* m_windowMenu; - caf::PdmUiTreeView* m_projectTreeView; caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index ead90ed792..7beb521680 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -149,6 +149,14 @@ RiuMainWindow* RiuMainWindow::instance() return sm_mainWindowInstance; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuMainWindow::mainWindowName() +{ + return "RiuMainWindow"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1297,7 +1305,7 @@ void RiuMainWindow::selectedObjectsChanged() m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within @@ -1619,14 +1627,6 @@ void RiuMainWindow::showProcessMonitorDockPanel() showDockPanel(DOCK_PANEL_NAME_PROCESS_MONITOR); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainWindow::selectAsCurrentItem(const caf::PdmObject* object) -{ - m_projectTreeView->selectAsCurrentItem(object); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 916a2ab5c4..8a16611012 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -78,7 +78,7 @@ class RiuMainWindow : public RiuMainWindowBase static RiuMainWindow* instance(); - virtual QString mainWindowName() { return "RiuMainWindow"; } + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiCaseClose(); @@ -93,12 +93,10 @@ class RiuMainWindow : public RiuMainWindowBase void refreshAnimationActions(); void updateScaleValue(); - caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} RiuProcessMonitor* processMonitor(); void hideAllDockWindows(); - void selectAsCurrentItem(const caf::PdmObject* object); void selectedCases(std::vector& cases); @@ -108,7 +106,7 @@ class RiuMainWindow : public RiuMainWindowBase void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); - RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer); + RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; void tileWindows(); bool isAnyMdiSubWindowVisible(); @@ -247,7 +245,6 @@ private slots: public: void setPdmRoot(caf::PdmObject* pdmRoot); private: - caf::PdmUiTreeView* m_projectTreeView; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp index 0c09d6e193..709e68234c 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp @@ -21,11 +21,15 @@ #include "RiaVersionInfo.h" #include +#include "cafPdmUiTreeView.h" +#include "cafPdmObject.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuMainWindowBase::RiuMainWindowBase() + : m_projectTreeView(nullptr) + , m_allowActiveViewChangeFromSelection(true) { setDockNestingEnabled(true); } @@ -96,3 +100,21 @@ QString RiuMainWindowBase::registryFolderName() QString regFolder = QString("%1/%2").arg(versionName).arg(mainWindowName()); return regFolder; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange) +{ + m_allowActiveViewChangeFromSelection = allowActiveViewChange; + m_projectTreeView->selectAsCurrentItem(object); + m_allowActiveViewChangeFromSelection = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) +{ + m_projectTreeView->setExpanded(uiItem, expanded); +} diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.h b/ApplicationCode/UserInterface/RiuMainWindowBase.h index 2bb580509e..5ac3f39663 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.h @@ -22,6 +22,13 @@ struct RimMdiWindowGeometry; +namespace caf +{ + class PdmObject; + class PdmUiTreeView; + class PdmUiItem; +} + //================================================================================================== /// //================================================================================================== @@ -44,6 +51,16 @@ class RiuMainWindowBase : public QMainWindow void saveWinGeoAndDockToolBarLayout(); void showWindow(); + caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} + void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + + void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + +protected: + caf::PdmUiTreeView* m_projectTreeView; + bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control + // whether to select the corresponding active view or not + private: QString registryFolderName(); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index ecbe5af3ed..d15c937dbb 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -571,11 +571,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM intersectionHit = true; intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex); - if (!dynamic_cast(m_viewer->ownerViewWindow())) - { - RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection()); - } - + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection(), allowActiveViewChange); } else if (intersectionBoxSourceInfo) { From 43dc25eca0336c2029246d91ce87f16832e2d897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 12:52:38 +0100 Subject: [PATCH 0363/1027] #2535 Add MainWindow tools class that can reduce number of mainWindow includes and hopefully reduce compile time --- .../UserInterface/CMakeLists_files.cmake | 4 ++ .../UserInterface/Riu3DMainWindowTools.cpp | 48 ++++++++++++++ .../UserInterface/Riu3DMainWindowTools.h | 35 +++++++++++ .../UserInterface/RiuPlotMainWindowTools.cpp | 62 +++++++++++++++++++ .../UserInterface/RiuPlotMainWindowTools.h | 37 +++++++++++ 5 files changed, 186 insertions(+) create mode 100644 ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp create mode 100644 ApplicationCode/UserInterface/Riu3DMainWindowTools.h create mode 100644 ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp create mode 100644 ApplicationCode/UserInterface/RiuPlotMainWindowTools.h diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 5e9bd6749a..39736ae65e 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -70,6 +70,8 @@ ${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h ${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.h ${CEE_CURRENT_LIST_DIR}RiuTools.h ${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.h +${CEE_CURRENT_LIST_DIR}RiuPlotMainWindowTools.h +${CEE_CURRENT_LIST_DIR}Riu3DMainWindowTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -135,6 +137,8 @@ ${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.cpp ${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.cpp ${CEE_CURRENT_LIST_DIR}RiuTools.cpp ${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.cpp +${CEE_CURRENT_LIST_DIR}RiuPlotMainWindowTools.cpp +${CEE_CURRENT_LIST_DIR}Riu3DMainWindowTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp new file mode 100644 index 0000000000..cf76b65dde --- /dev/null +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riu3DMainWindowTools.h" +#include "RiuMainWindow.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow) +{ + RiuMainWindow::instance()->setActiveViewer(subWindow); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/) +{ + RiuMainWindow::instance()->setExpanded(uiItem, expanded); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/) +{ + RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange); +} + + + diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.h b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h new file mode 100644 index 0000000000..11e9db0731 --- /dev/null +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QWidget; + +namespace caf +{ + class PdmUiItem; + class PdmObject; +} + +class Riu3DMainWindowTools +{ +public: + static void setActiveViewer(QWidget* subWindow) ; + static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); +}; diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp new file mode 100644 index 0000000000..2d70cf9b78 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuPlotMainWindowTools.h" +#include "RiaApplication.h" +#include "RiuMainPlotWindow.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::showPlotMainWindow() +{ + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow) +{ + RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->setActiveViewer(subWindow); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/) +{ + RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->setExpanded(uiItem, expanded); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/) +{ + RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange); +} + + + diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h new file mode 100644 index 0000000000..646aa89e91 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QWidget; + +namespace caf +{ + class PdmUiItem; + class PdmObject; +} + +class RiuPlotMainWindowTools +{ +public: + static void showPlotMainWindow(); + static void setActiveViewer(QWidget* subWindow) ; + static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); +}; + From d74807d669b782b49b3a29b88b29c1e36c694602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 15:21:14 +0100 Subject: [PATCH 0364/1027] #2535 Use the MainWindowTools class instead of MainWindow directly (part 1) --- ...NewFishbonesSubsAtMeasuredDepthFeature.cpp | 4 ++-- ...forationIntervalAtMeasuredDepthFeature.cpp | 4 ++-- .../RicNewPerforationIntervalFeature.cpp | 4 ++-- .../RicNewAzimuthDipIntersectionFeature.cpp | 4 ++-- .../RicNewPolylineIntersectionFeature.cpp | 4 ++-- .../RicEclipseCaseNewGroupExec.cpp | 7 ++++--- ...ddStoredFlowCharacteristicsPlotFeature.cpp | 12 +++++------ .../RicAddStoredWellAllocationPlotFeature.cpp | 10 +++------- .../RicPlotProductionRateFeature.cpp | 1 - .../RicShowFlowCharacteristicsPlotFeature.cpp | 6 +++--- .../RicShowWellAllocationPlotFeature.cpp | 6 +++--- .../RicNewEllipseFractureTemplateFeature.cpp | 4 ++-- .../RicAppendIntersectionBoxFeature.cpp | 4 ++-- .../RicCreateSummaryCaseCollectionFeature.cpp | 5 +++-- .../RicGeoMechPropertyFilterFeatureImpl.cpp | 6 +++--- .../Commands/RicRangeFilterInsertExec.cpp | 4 ++-- .../Commands/RicRangeFilterNewExec.cpp | 4 ++-- ApplicationCode/Commands/RicWellLogTools.cpp | 14 ++++++------- .../RicNewGridTimeHistoryCurveFeature.cpp | 5 +++-- .../RicSummaryCurveCreator.cpp | 9 +++++---- .../ViewLink/RicSetMasterViewFeature.cpp | 6 +++--- .../ViewLink/RicShowLinkOptionsFeature.cpp | 4 ++-- .../RicAddWellLogToPlotFeature.cpp | 8 +++++--- .../WellLogCommands/RicNewRftPlotFeature.cpp | 11 ++++------ .../RimFishboneWellPathCollection.cpp | 4 ++-- .../Completions/RimPerforationCollection.cpp | 4 ++-- .../ProjectDataModel/RimGridView.cpp | 4 ++-- .../Summary/RimObservedDataCollection.cpp | 20 +++++++------------ .../Summary/RimSummaryPlot.cpp | 12 +++++------ 29 files changed, 90 insertions(+), 100 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp index cd7fcc8dbe..b651e70431 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RimWellPath.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" @@ -58,7 +58,7 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered(bool isChecked RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(wellPath->fishbonesCollection()); wellPath->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(obj); + Riu3DMainWindowTools::selectAsCurrentItem(obj); RimProject* proj; wellPath->firstAncestorOrThisOfTypeAsserted(proj); diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp index 95a85c979f..bf1fc79aa9 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp @@ -27,7 +27,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" @@ -62,7 +62,7 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isC wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->scheduleRedrawAffectedViews(); - RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(perforationInterval); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp index cc55aaea97..6a66b7a196 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp @@ -21,7 +21,7 @@ #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RimPerforationInterval.h" #include "RimPerforationCollection.h" @@ -66,7 +66,7 @@ void RicNewPerforationIntervalFeature::onActionTriggered(bool isChecked) wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->scheduleRedrawAffectedViews(); - RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(perforationInterval); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 1a1aedc2c7..946c26fdae 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -25,7 +25,7 @@ #include "RimIntersectionCollection.h" #include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -125,7 +125,7 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo() m_intersectionCollection->appendIntersectionAndUpdate(intersection); RiuSelectionManager::instance()->deleteAllItems(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index c2bcf150e1..35c6ebfa72 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -26,7 +26,7 @@ #include "RimIntersectionCollection.h" #include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -116,7 +116,7 @@ void RicNewPolylineIntersectionFeatureCmd::redo() RiuSelectionManager::instance()->deleteAllItems(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp index 6198cd8934..134e5c4fbe 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp @@ -27,7 +27,7 @@ #include "RimOilField.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- /// @@ -73,8 +73,9 @@ void RicEclipseCaseNewGroupExec::redo() analysisModels->caseGroups().push_back(createdObject); analysisModels->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(createdObject); - RiuMainWindow::instance()->setExpanded(createdObject); + + Riu3DMainWindowTools::selectAsCurrentItem(createdObject); + Riu3DMainWindowTools::setExpanded(createdObject); } } diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp index 92ddc0ae33..69dcb88081 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp @@ -25,7 +25,7 @@ #include "RimProject.h" #include "RimFlowCharacteristicsPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -79,12 +79,10 @@ void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecke flowPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(flowCharacteristicsPlot); - mainPlotWindow->setExpanded(flowCharacteristicsPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + + RiuPlotMainWindowTools::selectAsCurrentItem(flowCharacteristicsPlot); + RiuPlotMainWindowTools::setExpanded(flowCharacteristicsPlot); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index a04eb49619..5c0beac5d0 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -25,7 +25,7 @@ #include "RimProject.h" #include "RimWellAllocationPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -79,12 +79,8 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered(bool isChecked) flowPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(wellAllocationPlot); - mainPlotWindow->setExpanded(wellAllocationPlot); - } + RiuPlotMainWindowTools::selectAsCurrentItem(wellAllocationPlot); + RiuPlotMainWindowTools::setExpanded(wellAllocationPlot); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index 542033b28a..6b885ba4b8 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -41,7 +41,6 @@ #include "RiaSummaryTools.h" #include "RiuMainPlotWindow.h" -#include "RiuMainWindow.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp index c335267fb9..5dd15fc659 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp @@ -32,7 +32,7 @@ #include "RimProject.h" #include "Rim3dView.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include @@ -91,13 +91,13 @@ void RicShowFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecked) RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection(); if (flowPlotColl) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); flowPlotColl->defaultFlowCharacteristicsPlot()->setFromFlowSolution(eclCase->defaultFlowDiagSolution()); flowPlotColl->defaultFlowCharacteristicsPlot()->updateConnectedEditors(); // Make sure the summary plot window is created and visible - plotwindow->selectAsCurrentItem(flowPlotColl->defaultFlowCharacteristicsPlot()); + RiuPlotMainWindowTools::selectAsCurrentItem(flowPlotColl->defaultFlowCharacteristicsPlot()); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index ab4f6d8e8b..d24c9c8616 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -28,7 +28,7 @@ #include "Rim3dView.h" #include "RimWellAllocationPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -110,8 +110,8 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) flowPlotColl->defaultWellAllocPlot()->updateConnectedEditors(); // Make sure the summary plot window is created and visible - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - plotwindow->selectAsCurrentItem(flowPlotColl->defaultWellAllocPlot()); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(flowPlotColl->defaultWellAllocPlot()); } } } diff --git a/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp index 282c5be805..f7370be3b0 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp @@ -26,7 +26,7 @@ #include "RimOilField.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -59,7 +59,7 @@ void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFr } } - RiuMainWindow::instance()->selectAsCurrentItem(fractureTemplate); + Riu3DMainWindowTools::selectAsCurrentItem(fractureTemplate); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index ff4034a52f..34898705e6 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -22,7 +22,7 @@ #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" #include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -61,7 +61,7 @@ void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked) intersectionBox->setToDefaultSizeBox(); coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); + Riu3DMainWindowTools::selectAsCurrentItem(intersectionBox); RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfTypeAsserted(rimView); diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 62789b362f..16bb885c7f 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -71,7 +71,8 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) summaryCaseMainCollection->addCaseCollection(selection); summaryCaseMainCollection->updateConnectedEditors(); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp index 4d99d5ed2b..5e01fee6c9 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp @@ -25,7 +25,7 @@ #include "RimGeoMechView.h" #include "RimGeoMechResultDefinition.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -66,7 +66,7 @@ void RicGeoMechPropertyFilterFeatureImpl::addPropertyFilter(RimGeoMechPropertyFi propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } @@ -83,7 +83,7 @@ void RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter(RimGeoMechPropert propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp index 3d2245351b..c811959d32 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp @@ -22,7 +22,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" #include "Rim3dView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- @@ -69,7 +69,7 @@ void RicRangeFilterInsertExec::redo() m_cellRangeFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); + Riu3DMainWindowTools::selectAsCurrentItem(rangeFilter); } } diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index 773ad07d29..c116de9ec4 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -25,7 +25,7 @@ #include "RimCellRangeFilterCollection.h" #include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- @@ -75,7 +75,7 @@ void RicRangeFilterNewExec::redo() m_cellRangeFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); + Riu3DMainWindowTools::selectAsCurrentItem(rangeFilter); RimGridView* view = nullptr; m_cellRangeFilterCollection->firstAncestorOrThisOfTypeAsserted(view); diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index 25e1675df3..ca9b7c91d0 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -35,7 +35,7 @@ #include "RifReaderEclipseRft.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -206,11 +206,11 @@ RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack->updateConnectedEditors(); // Make sure the summary plot window is created and visible - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); RiaApplication::instance()->project()->updateConnectedEditors(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } @@ -254,11 +254,11 @@ RimWellLogRftCurve* RicWellLogTools::addRftCurve(RimWellLogTrack* plotTrack, con plotTrack->setFormationTrajectoryType(RimWellLogTrack::SIMULATION_WELL); plotTrack->updateConnectedEditors(); - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); RiaApplication::instance()->project()->updateConnectedEditors(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } @@ -279,8 +279,8 @@ RimWellLogFileCurve* RicWellLogTools::addFileCurve(RimWellLogTrack* plotTrack) plotTrack->updateConnectedEditors(); - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index 6994f24945..32ea6a52a3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -36,7 +36,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafPdmReferenceHelper.h" @@ -71,7 +71,8 @@ void RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem(const RiuSe plot->updateConnectedEditors(); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(newCurve); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 9c3f3131b8..b1c9f20586 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -41,7 +41,7 @@ #include "RimSummaryPlotCollection.h" #include "RimSummaryCalculationCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSummaryCurveDefSelection.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" @@ -193,9 +193,10 @@ void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changed if (changedField == &m_okButtonField) { m_closeButtonField = true; - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - mainPlotWindow->selectAsCurrentItem(m_targetPlot); - mainPlotWindow->setExpanded(m_targetPlot); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(m_targetPlot); + RiuPlotMainWindowTools::setExpanded(m_targetPlot); } m_applyButtonField = false; diff --git a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index fd1c608383..1bed9c55c6 100644 --- a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -27,7 +27,7 @@ #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -81,8 +81,8 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked) proj->updateConnectedEditors(); // Set managed view collection to selected and expanded in project tree - RiuMainWindow::instance()->selectAsCurrentItem(viewLinker); - RiuMainWindow::instance()->setExpanded(viewLinker); + Riu3DMainWindowTools::selectAsCurrentItem(viewLinker); + Riu3DMainWindowTools::setExpanded(viewLinker); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp index 4982b889d0..eea54abb91 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp @@ -24,7 +24,7 @@ #include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -61,7 +61,7 @@ void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked) RimViewController* viewController = activeView->viewController(); - RiuMainWindow::instance()->selectAsCurrentItem(viewController); + Riu3DMainWindowTools::selectAsCurrentItem(viewController); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index c0ffe2aae4..6523e0ea54 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -32,7 +32,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RigWellLogFile.h" @@ -109,8 +109,10 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) plotTrack->viewer()->replot(); RiaApplication::instance()->project()->updateConnectedEditors(); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(plot); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->setExpanded(plotTrack); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(plot); + RiuPlotMainWindowTools::setExpanded(plotTrack); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index 11471315d5..3b964787eb 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -29,7 +29,7 @@ #include "RimWellPath.h" #include "RimWellRftPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -84,12 +84,9 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked) rftPlot->loadDataAndUpdate(); rftPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setExpanded(plotTrack); - mainPlotWindow->selectAsCurrentItem(rftPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::setExpanded(plotTrack); + RiuPlotMainWindowTools::selectAsCurrentItem(rftPlot); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp index 093e007ee8..59507d5ff0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp @@ -28,7 +28,7 @@ #include "RifWellPathImporter.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" CAF_PDM_SOURCE_INIT(RimFishboneWellPathCollection, "WellPathCompletionCollection"); @@ -133,7 +133,7 @@ void RimFishboneWellPathCollection::appendCompletion(RimFishboneWellPath* comple m_wellPaths.push_back(completion); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(completion); + Riu3DMainWindowTools::selectAsCurrentItem(completion); uiCapability()->setUiHidden(!m_wellPaths.empty()); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp index 59339ad035..f67766a70d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp @@ -27,7 +27,7 @@ #include "RifWellPathImporter.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" CAF_PDM_SOURCE_INIT(RimPerforationCollection, "PerforationCollection"); @@ -81,7 +81,7 @@ void RimPerforationCollection::appendPerforation(RimPerforationInterval* perfora perforation->setUnitSystemSpecificDefaults(); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(perforation); + Riu3DMainWindowTools::selectAsCurrentItem(perforation); RimProject* proj; this->firstAncestorOrThisOfTypeAsserted(proj); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 815c564309..1ffa00080c 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -30,7 +30,7 @@ #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cvfModel.h" #include "cvfScene.h" @@ -331,7 +331,7 @@ void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons //-------------------------------------------------------------------------------------------------- void RimGridView::selectOverlayInfoConfig() { - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); + Riu3DMainWindowTools::selectAsCurrentItem(m_overlayInfoConfig); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp index 46ea1b73e3..f6ac04f011 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp @@ -31,7 +31,7 @@ #include "RimObservedEclipseUserData.h" #include "RimSummaryObservedDataFile.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafUtils.h" #include "cafPdmSettings.h" @@ -130,12 +130,9 @@ RimObservedData* RimObservedDataCollection::createAndAddRsmObservedDataFromFile( errorText->append(observedData->errorMessagesFromReader()); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(observedData); - mainPlotWindow->setExpanded(observedData); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(observedData); + RiuPlotMainWindowTools::setExpanded(observedData); this->updateConnectedEditors(); caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); @@ -192,12 +189,9 @@ RimObservedData* RimObservedDataCollection::createAndAddCvsObservedDataFromFile( return nullptr; } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(userData); - mainPlotWindow->setExpanded(userData); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(userData); + RiuPlotMainWindowTools::setExpanded(userData); this->updateConnectedEditors(); caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index d614a88911..c7ac11d455 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -34,7 +34,7 @@ #include "RimSummaryPlotNameHelper.h" #include "RimSummaryTimeAxisProperties.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSummaryQwtPlot.h" #include "cvfBase.h" @@ -176,24 +176,24 @@ RimSummaryTimeAxisProperties* RimSummaryPlot::timeAxisProperties() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::selectAxisInPropertyEditor(int axis) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); if (axis == QwtPlot::yLeft) { - plotwindow->selectAsCurrentItem(m_leftYAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_leftYAxisProperties); } else if (axis == QwtPlot::yRight) { - plotwindow->selectAsCurrentItem(m_rightYAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_rightYAxisProperties); } else if (axis == QwtPlot::xBottom) { if (m_isCrossPlot) { - plotwindow->selectAsCurrentItem(m_bottomAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_bottomAxisProperties); } else { - plotwindow->selectAsCurrentItem(m_timeAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_timeAxisProperties); } } } From 72013f4ff8a3e91c48e21402763effe49a845de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 15:53:33 +0100 Subject: [PATCH 0365/1027] #2535 Use the MainWindowTools class instead of MainWindow directly (part 2) --- .../RicEclipsePropertyFilterFeatureImpl.cpp | 6 +++--- .../EclipseCommands/RicNewStatisticsCaseFeature.cpp | 4 ++-- .../RicNewSimWellFractureAtPosFeature.cpp | 4 ++-- .../FractureCommands/RicNewSimWellFractureFeature.cpp | 4 ++-- .../RicNewStimPlanFractureTemplateFeature.cpp | 4 ++-- .../RicNewWellPathFractureFeature.cpp | 4 ++-- .../RicPasteEclipseViewsFeature.cpp | 4 ++-- .../RicPasteGeoMechViewsFeature.cpp | 4 ++-- .../Commands/RicImportObservedDataFeature.cpp | 5 +++-- ApplicationCode/Commands/RicSelectColorResult.cpp | 6 +++--- .../RicDuplicateSummaryCurveFeature.cpp | 6 +++--- .../RicNewSummaryCrossPlotFeature.cpp | 11 ++++------- .../Commands/WellLogCommands/RicNewPltPlotFeature.cpp | 11 ++++------- .../ProjectDataModel/RimIntersectionCollection.cpp | 6 +++--- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 5 +++-- ApplicationCode/UserInterface/RiuWellLogTrack.cpp | 8 +++++--- 16 files changed, 45 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index bc2054c41f..743a986cfc 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -29,7 +29,7 @@ #include "cafSelectionManager.h" #include "cvfAssert.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- /// @@ -66,7 +66,7 @@ void RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(RimEclipsePropertyFi propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } @@ -83,7 +83,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp index ea5b876469..c758e8ed7a 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -53,7 +53,7 @@ void RicNewStatisticsCaseFeature::onActionTriggered(bool isChecked) RimEclipseStatisticsCase* newCase = addStatisticalCalculation(uiItem); if (newCase) { - RiuMainWindow::instance()->selectAsCurrentItem(newCase); + Riu3DMainWindowTools::selectAsCurrentItem(newCase); } } } diff --git a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp index a0ce60165e..c5908f4511 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp @@ -34,7 +34,7 @@ #include "RimSimWellInView.h" #include "RimStimPlanColors.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RivSimWellPipeSourceInfo.h" @@ -109,7 +109,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) fracture->setFractureTemplate(fracDef); simWell->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); activeView->scheduleCreateDisplayModelAndRedraw(); diff --git a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp index 052249ffcf..cf5949db89 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp @@ -36,7 +36,7 @@ #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -98,7 +98,7 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) fracture->updateFracturePositionFromLocation(); eclipseWell->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); RimEclipseCase* eclipseCase = nullptr; objHandle->firstAncestorOrThisOfType(eclipseCase); diff --git a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index 5d4913afcb..37c43d0726 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RimStimPlanFractureTemplate.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -90,7 +90,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) } } - RiuMainWindow::instance()->selectAsCurrentItem(fractureDef); + Riu3DMainWindowTools::selectAsCurrentItem(fractureDef); } } diff --git a/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index 50d1767393..f578cc625f 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -36,7 +36,7 @@ #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" @@ -93,7 +93,7 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me fracture->setFractureTemplate(fracDef); wellPath->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); RimProject* project = nullptr; fractureCollection->firstAncestorOrThisOfType(project); diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index d5e8892ee3..95036187b7 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RicPasteFeatureImpl.h" @@ -112,7 +112,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked) lastViewCopy = rimReservoirView; } - if (lastViewCopy) RiuMainWindow::instance()->selectAsCurrentItem(lastViewCopy); + if (lastViewCopy) Riu3DMainWindowTools::selectAsCurrentItem(lastViewCopy); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp index a95f02ca72..470373dffa 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp @@ -21,7 +21,7 @@ #include "RicPasteFeatureImpl.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RimGeoMechView.h" #include "RimGeoMechCase.h" @@ -105,7 +105,7 @@ void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked) lastViewCopy = rimReservoirView; } - if (lastViewCopy) RiuMainWindow::instance()->selectAsCurrentItem(lastViewCopy); + if (lastViewCopy) Riu3DMainWindowTools::selectAsCurrentItem(lastViewCopy); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp index 672a278f42..6dc98c157b 100644 --- a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RimSummaryObservedDataFile.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -100,7 +100,8 @@ void RicImportObservedDataFeature::selectObservedDataFileInDialog() } while (retryImport); } - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(observedData); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(observedData); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSelectColorResult.cpp b/ApplicationCode/Commands/RicSelectColorResult.cpp index f335afc067..885d22d926 100644 --- a/ApplicationCode/Commands/RicSelectColorResult.cpp +++ b/ApplicationCode/Commands/RicSelectColorResult.cpp @@ -25,7 +25,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include @@ -60,13 +60,13 @@ void RicSelectColorResult::onActionTriggered(bool isChecked) RimEclipseView* eclView = dynamic_cast(activeView); if (eclView) { - RiuMainWindow::instance()->selectAsCurrentItem(eclView->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(eclView->cellResult()); return; } RimGeoMechView* geoMechView = dynamic_cast(activeView); if (geoMechView) { - RiuMainWindow::instance()->selectAsCurrentItem(geoMechView->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(geoMechView->cellResult()); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp index ad1e0b2cb3..addcac632a 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp @@ -31,7 +31,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -65,8 +65,8 @@ void RicDuplicateSummaryCurveFeature::onActionTriggered(bool isChecked) if (curve) { RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(curve); - - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(newCurve); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index b4ed164d33..880c9afd1e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -31,7 +31,7 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cvfAssert.h" @@ -65,12 +65,9 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) summaryCrossPlotColl->updateConnectedEditors(); summaryPlot->loadDataAndUpdate(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(summaryPlot); - mainPlotWindow->setExpanded(summaryPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(summaryPlot); + RiuPlotMainWindowTools::setExpanded(summaryPlot); } } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index 3f70847cd7..8510149482 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -38,7 +38,7 @@ #include "RimMainPlotCollection.h" #include "RimEclipseResultCase.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManagerTools.h" @@ -123,12 +123,9 @@ void RicNewPltPlotFeature::onActionTriggered(bool isChecked) pltPlot->loadDataAndUpdate(); pltPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setExpanded(plotTrack); - mainPlotWindow->selectAsCurrentItem(pltPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::setExpanded(plotTrack); + RiuPlotMainWindowTools::selectAsCurrentItem(pltPlot); } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index cbb308b15c..15182e532f 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -27,7 +27,7 @@ #include "RimIntersectionBox.h" #include "RimSimWellInView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RivIntersectionBoxPartMgr.h" #include "RivIntersectionPartMgr.h" @@ -177,7 +177,7 @@ void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* int syncronize2dIntersectionViews(); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); @@ -224,7 +224,7 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBo m_intersectionBoxes.push_back(intersectionBox); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); + Riu3DMainWindowTools::selectAsCurrentItem(intersectionBox); Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index bcbbcf0713..e64d9fe672 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -26,7 +26,7 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuQwtCurvePointTracker.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotZoomer.h" @@ -368,7 +368,8 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos) if(proj && selectedCurve) { - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve); } } } diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp index e266087288..8bf7946637 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp @@ -25,7 +25,7 @@ #include "RimWellLogTrack.h" #include "RimWellLogCurve.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuQwtCurvePointTracker.h" #include "qwt_legend.h" @@ -220,13 +220,15 @@ void RiuWellLogTrack::selectClosestCurve(const QPoint& pos) RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve(closestCurve); if (selectedCurve) { - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve); return; } } - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(m_plotTrackDefinition); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(m_plotTrackDefinition); } //-------------------------------------------------------------------------------------------------- From 562dfbe9b85d884791044e87875958af5454ec13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 16:00:55 +0100 Subject: [PATCH 0366/1027] #2535 Use the MainWindowTools class instead of MainWindow directly (part 3) --- .../RicSnapshotAllPlotsToFileFeature.cpp | 8 ++------ .../RicSnapshotAllViewsToFileFeature.cpp | 13 +++---------- .../RicShowContributingWellsFeatureImpl.cpp | 4 ++-- ApplicationCode/Commands/RicNewViewFeature.cpp | 4 ++-- .../ViewLink/RicLinkVisibleViewsFeature.cpp | 4 ++-- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index b00dab064b..36cde19d7c 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -28,7 +28,7 @@ #include "RicSnapshotViewToFileFeature.h" #include "RicSnapshotFilenameGenerator.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafUtils.h" @@ -123,11 +123,7 @@ void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked) if (currentActiveWidget) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setActiveViewer(currentActiveWidget); - } + RiuPlotMainWindowTools::setActiveViewer(currentActiveWidget); } } diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 17a5f027db..46f51c874e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -32,7 +32,7 @@ #include "RicSnapshotViewToFileFeature.h" #include "RicSnapshotFilenameGenerator.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuViewer.h" #include "RigFemResultPosEnum.h" @@ -72,9 +72,6 @@ void RicSnapshotAllViewsToFileFeature::saveAllViews() //-------------------------------------------------------------------------------------------------- void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName) { - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (!mainWnd) return; - RimProject* project = RiaApplication::instance()->project(); if (project == nullptr) return; @@ -108,7 +105,7 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RiaApplication::instance()->setActiveReservoirView(riv); RiuViewer* viewer = riv->viewer(); - mainWnd->setActiveViewer(viewer->layoutWidget()); + Riu3DMainWindowTools::setActiveViewer(viewer->layoutWidget()); RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); @@ -159,11 +156,7 @@ void RicSnapshotAllViewsToFileFeature::onActionTriggered(bool isChecked) if (currentActiveWidget) { - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - if (mainWindow) - { - mainWindow->setActiveViewer(currentActiveWidget); - } + Riu3DMainWindowTools::setActiveViewer(currentActiveWidget); } } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp index b31672ee09..b5de57a139 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp @@ -37,7 +37,7 @@ #include "RimSimWellInView.h" #include "RimViewManipulator.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" @@ -156,7 +156,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->setExpanded(propertyFilterCollection); + Riu3DMainWindowTools::setExpanded(propertyFilterCollection); viewToModify->faultCollection()->showFaultCollection = false; viewToModify->faultCollection()->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/RicNewViewFeature.cpp b/ApplicationCode/Commands/RicNewViewFeature.cpp index 9d19d15555..ad7410c283 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationCode/Commands/RicNewViewFeature.cpp @@ -25,7 +25,7 @@ #include "RimGeoMechView.h" #include "Rim3dView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiaLogging.h" #include "cafSelectionManager.h" @@ -43,7 +43,7 @@ void RicNewViewFeature::addReservoirView(RimEclipseCase* eclipseCase, RimGeoMech if (newView) { - RiuMainWindow::instance()->setExpanded(newView); + Riu3DMainWindowTools::setExpanded(newView); } } diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index a8121e0249..8081f13df7 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -29,7 +29,7 @@ #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" @@ -177,7 +177,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) proj->viewLinkerCollection.uiCapability()->updateConnectedEditors(); proj->updateConnectedEditors(); - RiuMainWindow::instance()->setExpanded(proj->viewLinkerCollection()); + Riu3DMainWindowTools::setExpanded(proj->viewLinkerCollection()); } From 267e3ef59dcf98454b7e220bc420e5b2fdf54fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 27 Feb 2018 16:37:06 +0100 Subject: [PATCH 0367/1027] #2535 Use the MainWindowTools class instead of MainWindow directly (part 4) --- .../RicWellPathImportCompletionsFileFeature.cpp | 4 ++-- .../RicWellPathImportPerforationIntervalsFeature.cpp | 6 +++--- .../RicExportFishbonesWellSegmentsFeature.cpp | 4 ++-- .../RicWellPathExportCompletionDataFeature.cpp | 4 ++-- .../RicAddEclipseInputPropertyFeature.cpp | 4 ++-- .../EclipseCommands/RicImportEclipseCaseFeature.cpp | 4 ++-- .../RicImportEclipseCaseTimeStepFilterFeature.cpp | 4 ++-- .../RicImportInputEclipseCaseFeature.cpp | 6 +++--- .../RicSaveEclipseInputPropertyFeature.cpp | 6 +++--- .../RicSaveEclipseInputVisibleCellsFeature.cpp | 4 ++-- .../RicSaveEclipseResultAsInputPropertyExec.cpp | 4 ++-- .../RicNewIntersectionViewFeature.cpp | 4 ++-- .../OctaveScriptCommands/RicAddScriptPathFeature.cpp | 4 ++-- .../OctaveScriptCommands/RicEditScriptFeature.cpp | 4 ++-- .../OctaveScriptCommands/RicNewScriptFeature.cpp | 8 ++++---- .../Commands/RicImportFormationNamesFeature.cpp | 6 +++--- .../WellLogCommands/RicWellLogsImportFileFeature.cpp | 4 ++-- .../RicWellPathFormationsImportFileFeature.cpp | 6 +++--- .../RicWellPathsImportFileFeature.cpp | 6 +++--- .../RicWellPathsUnitSystemSettingsImpl.cpp | 4 ++-- .../FileInterface/RifWellPathFormationReader.cpp | 6 +++--- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 4 ++-- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimWellLogFile.cpp | 8 ++++---- .../ProjectDataModel/RimWellPathCollection.cpp | 12 ++++++------ .../UserInterface/Riu3DMainWindowTools.cpp | 8 ++++++++ ApplicationCode/UserInterface/Riu3DMainWindowTools.h | 1 + 27 files changed, 74 insertions(+), 65 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp index 4e4d06b8e0..0a006a5982 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -27,7 +27,7 @@ #include "RimWellPathCompletions.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -60,7 +60,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp index 79d225d22f..8b51f0c6df 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp @@ -29,7 +29,7 @@ #include "RifPerforationIntervalReader.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -62,7 +62,7 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered(bool isChec // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Perforation Intervals", defaultDir, "Well Path Perforation Intervals (*.ev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Path Perforation Intervals", defaultDir, "Well Path Perforation Intervals (*.ev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -109,7 +109,7 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered(bool isChec if (lastPerforationInterval) { - RiuMainWindow::instance()->selectAsCurrentItem(lastPerforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(lastPerforationInterval); } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp index 93ed5108ac..3b2de36453 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -34,7 +34,7 @@ #include "RigEclipseCaseData.h" #include "RigWellPath.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" #include "cafPdmUiPropertyViewDialog.h" @@ -78,7 +78,7 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked) exportSettings.folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Well Segments", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Well Segments", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index a3b38c5c4d..2349294140 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -30,7 +30,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" @@ -118,7 +118,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), exportSettings, "Export Completion Data", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp index 249c3da997..06e9b95963 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp @@ -23,7 +23,7 @@ #include "RimEclipseInputCase.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -49,7 +49,7 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); if (fileNames.isEmpty()) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index 8b700f4092..e9fcc281ea 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -25,7 +25,7 @@ #include "RimEclipseCaseCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -50,7 +50,7 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("BINARY_GRID", defaultDir); diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp index c174b6796e..26530278d4 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RiaImportEclipseCaseTools.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -38,7 +38,7 @@ void RicImportEclipseCaseTimeStepFilterFeature::onActionTriggered(bool isChecked RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QString fileName = QFileDialog::getOpenFileName(RiuMainWindow::instance(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); + QString fileName = QFileDialog::getOpenFileName(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); if (!fileName.isEmpty()) { defaultDir = QFileInfo(fileName).absolutePath(); diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp index db29b90609..f7e16bc27c 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp @@ -30,7 +30,7 @@ #include "RimOilField.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -76,7 +76,7 @@ bool RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(const Q analysisModels->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(riv->cellResult()); if (fileNames.size() == 1) { @@ -101,7 +101,7 @@ void RicImportInputEclipseCaseFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties Eclipse Input Files (*.GRDECL);;All Files (*.*)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties Eclipse Input Files (*.GRDECL);;All Files (*.*)"); if (fileNames.isEmpty()) return; diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp index 738ad0b076..a2db7490cd 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp @@ -30,7 +30,7 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimExportInputPropertySettings.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" @@ -68,7 +68,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) if (!isResolved) { - QMessageBox::warning(RiuMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); return; } @@ -101,7 +101,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) exportSettings.fileName = outputFileName; } - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Eclipse Property to Text File", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Eclipse Property to Text File", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp index fc48bcde4d..d78730c50b 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp @@ -35,7 +35,7 @@ #include "RigActiveCellInfo.h" #include "RigEclipseCaseData.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" @@ -54,7 +54,7 @@ void executeCommand(RimEclipseView* view) if (!view) return; RicSaveEclipseInputVisibleCellsUi exportSettings; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export FLUXNUM/MULTNUM", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export FLUXNUM/MULTNUM", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp index df315d1e44..cf3c628f66 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp @@ -34,7 +34,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafUtils.h" @@ -92,7 +92,7 @@ void RicSaveEclipseResultAsInputPropertyExec::redo() exportSettings.fileName = outputFileName; } - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Binary Eclipse Data to Text File", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Binary Eclipse Data to Text File", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index 2e947eb41d..42d8e45ab0 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -22,7 +22,7 @@ #include "RimCase.h" #include "RimIntersection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManagerTools.h" @@ -67,7 +67,7 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) QString text = QString("The intersection view only supports vertical intersections.\n" "The intersection '%1' is not vertical but a converted version will be shown in the view .").arg(intersection->name()); - QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "New Intersection View", text); } Rim2dIntersectionView* intersectionView = intersection->correspondingIntersectionView(); diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp index b68fba9303..dbba4c0f2e 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp @@ -26,7 +26,7 @@ #include "RicScriptFeatureImpl.h" #include "RimScriptCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cvfAssert.h" @@ -49,7 +49,7 @@ bool RicAddScriptPathFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAddScriptPathFeature::onActionTriggered(bool isChecked) { - QString selectedFolder = QFileDialog::getExistingDirectory(RiuMainWindow::instance(), "Select script folder"); + QString selectedFolder = QFileDialog::getExistingDirectory(Riu3DMainWindowTools::mainWindowWidget(), "Select script folder"); if (!selectedFolder.isEmpty()) { QString filePathString = RiaApplication::instance()->preferences()->scriptDirectories(); diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp index 7610e17792..fa21027efe 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp @@ -24,7 +24,7 @@ #include "RimCalcScript.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -65,7 +65,7 @@ void RicEditScriptFeature::onActionTriggered(bool isChecked) if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp index 7c1c6efc0a..c9a5e480e3 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp @@ -27,7 +27,7 @@ #include "RimCalcScript.h" #include "RimScriptCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuTools.h" #include "cafUtils.h" @@ -99,7 +99,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) QFile file(fullPathFilenameNewScript); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript); return; } @@ -108,7 +108,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) if (calcScript) { - RiuMainWindow::instance()->selectAsCurrentItem(calcScript); + Riu3DMainWindowTools::selectAsCurrentItem(calcScript); } RiaApplication* app = RiaApplication::instance(); @@ -123,7 +123,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 0ee5e2f794..88a5669e75 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -33,7 +33,7 @@ #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -56,7 +56,7 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Formation Names", defaultDir, "Formation Names description File (*.lyr);;All Files (*.*)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Formation Names", defaultDir, "Formation Names description File (*.lyr);;All Files (*.*)"); if (fileNames.isEmpty()) return; @@ -96,7 +96,7 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) if (formationName) { - RiuMainWindow::instance()->selectAsCurrentItem(formationName); + Riu3DMainWindowTools::selectAsCurrentItem(formationName); } } diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp index ff170dfbf2..ba56dc6fc6 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiObjectEditorHandle.h" @@ -46,7 +46,7 @@ void RicWellLogsImportFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELL_LOGS_DIR"); - QStringList wellLogFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Logs", defaultDir, "Well Logs (*.las);;All Files (*.*)"); + QStringList wellLogFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Logs", defaultDir, "Well Logs (*.las);;All Files (*.*)"); if (wellLogFilePaths.size() < 1) return; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp index 43bf2004ed..68225e2276 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp @@ -26,7 +26,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -50,7 +50,7 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATHFORMATIONS_DIR"); QStringList wellPathFormationsFilePaths = - QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Picks", defaultDir, + QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Picks", defaultDir, "Well Picks (*.csv);;All Files (*.*)"); if (wellPathFormationsFilePaths.size() < 1) @@ -80,7 +80,7 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { - RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + Riu3DMainWindowTools::selectAsCurrentItem(wellPath); } } } diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp index 3168992c9c..b3a19f0721 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp @@ -26,7 +26,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -50,7 +50,7 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -73,7 +73,7 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { - RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + Riu3DMainWindowTools::selectAsCurrentItem(wellPath); } } } diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp index 997001bea6..b187155157 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp @@ -20,7 +20,7 @@ #include "RicWellPathsUnitSystemSettingsUi.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" @@ -35,7 +35,7 @@ bool RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(RimWellPath * wellP } RicWellPathsUnitSystemSettingsUi settings; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &settings, "Select Unit System for Well Path", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &settings, "Select Unit System for Well Path", ""); if (propertyDialog.exec() == QDialog::Accepted) { wellPath->setUnitSystem(settings.unitSystem()); diff --git a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp index 4c6e31b760..f4c7a99f7c 100644 --- a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp +++ b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp @@ -19,7 +19,7 @@ #include "RifWellPathFormationReader.h" #include "RiaLogging.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -63,7 +63,7 @@ std::map> if (wellNames.empty() || formationNames.empty()) { - QMessageBox::warning(RiuMainWindow::instance(), "Import failure", + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure", QString("Failed to parse %1 as a well pick file").arg(filePath)); RiaLogging::error(QString("Failed to parse %1 as a well pick file").arg(filePath)); @@ -71,7 +71,7 @@ std::map> } else if (!(mdIsPresent || tvdIsPresent)) { - QMessageBox::warning(RiuMainWindow::instance(), "Import failure", + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure", QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath)); RiaLogging::error(QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath)); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 8394c09a89..d8100a30bb 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -40,7 +40,7 @@ #include "RimTensorResults.h" #include "RimViewLinker.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -125,7 +125,7 @@ void RimGeoMechView::onLoadDataAndUpdate() { QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage); - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage); m_geomechCase = nullptr; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 5fb824b8c6..d88876c537 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -36,7 +36,7 @@ #include "RimEclipseView.h" #include "RimReservoirCellResultsStorage.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafProgressInfo.h" @@ -173,7 +173,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() RimEclipseCase* mainCase = caseCollection()->reservoirs[0]; if (!mainCase->openReserviorCase()) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Error when opening project file", "Could not open the Eclipse Grid file: \n"+ mainCase->gridFileName() + "\n"+ "Current working directory is: \n" + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index 72d8f6490f..646f975e61 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -29,7 +29,7 @@ #include "RigWellLogFile.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiDateEditor.h" @@ -124,9 +124,9 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath) displayMessage += errorMessage; } - QMessageBox::warning(RiuMainWindow::instance(), - "File open error", - displayMessage); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), + "File open error", + displayMessage); delete wellLogFile; wellLogFile = nullptr; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index bb6eccbb38..ef72217b5e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -39,7 +39,7 @@ #include "RimWellPath.h" #include "RimPerforationCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RifWellPathFormationsImporter.h" #include "RifWellPathImporter.h" @@ -138,7 +138,7 @@ void RimWellPathCollection::readWellPathFiles() QString errorMessage; if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage, m_wellPathImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } @@ -159,7 +159,7 @@ void RimWellPathCollection::readWellPathFiles() displayMessage += errorMessage; } - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage); } @@ -367,7 +367,7 @@ void RimWellPathCollection::addWellPathFormations(const QStringList& filePaths) if (fileReadSuccess) { - QMessageBox::information(RiuMainWindow::instance(), "Well Picks Import", outputMessage); + QMessageBox::information(Riu3DMainWindowTools::mainWindowWidget(), "Well Picks Import", outputMessage); RiaLogging::info(outputMessage); } @@ -489,7 +489,7 @@ void RimWellPathCollection::readWellPathFormationFiles() QString errorMessage; if (!wellPaths[wpIdx]->readWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } @@ -511,7 +511,7 @@ void RimWellPathCollection::reloadAllWellPathFormations() QString errorMessage; if (!wellPaths[wpIdx]->reloadWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp index cf76b65dde..6db4df1274 100644 --- a/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp @@ -20,6 +20,14 @@ #include "RiuMainWindow.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Riu3DMainWindowTools::mainWindowWidget() +{ + return RiuMainWindow::instance(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.h b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h index 11e9db0731..5f4f4e4ca2 100644 --- a/ApplicationCode/UserInterface/Riu3DMainWindowTools.h +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h @@ -29,6 +29,7 @@ namespace caf class Riu3DMainWindowTools { public: + static QWidget* mainWindowWidget(); static void setActiveViewer(QWidget* subWindow) ; static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); From 65c3d6ff129e4f5eb89315ff4022b183c36e18d1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 25 Feb 2018 15:03:45 +0100 Subject: [PATCH 0368/1027] #2536 Build System AppFwk : Use target_include_directories --- Fwk/AppFwk/cafCommand/CMakeLists.txt | 20 +++++++++---------- Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt | 16 +++++++++------ .../cafPdmCore/CMakeLists.txt | 9 +++++---- .../cafPdmCore_UnitTests/CMakeLists.txt | 3 +-- .../cafPdmUiCore/CMakeLists.txt | 11 ++++++++-- .../cafPdmXml/CMakeLists.txt | 10 +++++++++- .../cafPdmXml_UnitTests/CMakeLists.txt | 6 +----- .../CMakeLists.txt | 14 +------------ .../cafTestApplication/CMakeLists.txt | 12 ----------- Fwk/AppFwk/cafUserInterface/CMakeLists.txt | 16 +++++---------- .../cafUserInterface_UnitTests/CMakeLists.txt | 15 +------------- 11 files changed, 52 insertions(+), 80 deletions(-) diff --git a/Fwk/AppFwk/cafCommand/CMakeLists.txt b/Fwk/AppFwk/cafCommand/CMakeLists.txt index c0dcef9c9b..7a40f0bbef 100644 --- a/Fwk/AppFwk/cafCommand/CMakeLists.txt +++ b/Fwk/AppFwk/cafCommand/CMakeLists.txt @@ -6,16 +6,6 @@ include (${QT_USE_FILE}) project (cafCommand) -include_directories( - ${cafProjectDataModel_SOURCE_DIR} -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - . -) # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS @@ -71,4 +61,14 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + cafProjectDataModel +) + + source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt index 7e451984f4..e880ee564d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt @@ -6,12 +6,6 @@ project (cafProjectDataModel) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) - set( PROJECT_FILES cafFactory.h cafFixedArray.h @@ -28,4 +22,14 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_link_libraries ( ${PROJECT_NAME} + cafPdmUiCore + cafPdmXml +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 725ff7201f..d703a7c6b6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -6,9 +6,6 @@ project (cafPdmCore) find_package ( Qt4 COMPONENTS QtCore ) include (${QT_USE_FILE}) -include_directories ( -) - set( PROJECT_FILES cafAssert.h @@ -50,9 +47,13 @@ set( PROJECT_FILES cafFilePath.h ) - add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt index e6a0882885..4868cb2407 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt @@ -6,8 +6,7 @@ include (${QT_USE_FILE}) project ( cafPdmCore_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt index 4328e3caa4..45aa9428f7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt @@ -7,8 +7,6 @@ find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) include_directories ( - - ${cafPdmCore_SOURCE_DIR} .. ) @@ -53,4 +51,13 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_link_libraries ( ${PROJECT_NAME} + cafPdmCore +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt index 1ba575d743..a1d93b0af9 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt @@ -8,7 +8,6 @@ include (${QT_USE_FILE}) include_directories ( .. - ${cafPdmCore_SOURCE_DIR} ) set( PROJECT_FILES @@ -45,4 +44,13 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_link_libraries ( ${PROJECT_NAME} + cafPdmCore +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt index 7a56128283..c00c5b9a44 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt @@ -6,12 +6,9 @@ include (${QT_USE_FILE}) project ( cafPdmXml_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${cafPdmCore_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) - # add the executable add_executable (${PROJECT_NAME} cafPdmXml_UnitTests.cpp @@ -24,7 +21,6 @@ add_executable (${PROJECT_NAME} message(STATUS ${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafPdmCore cafPdmXml ${QT_LIBRARIES} ${THREAD_LIBRARY} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt index 4ac2c8cec5..ae22c33511 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt @@ -6,16 +6,7 @@ include (${QT_USE_FILE}) project ( cafProjectDataModel_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - - ${cafProjectDataModel_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) set( PROJECT_FILES @@ -35,9 +26,6 @@ add_executable (${PROJECT_NAME} message(${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafPdmCore - cafPdmUiCore - cafPdmXml cafProjectDataModel ${QT_LIBRARIES} ${THREAD_LIBRARY} diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt index f03d2a90bd..69de97347c 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt @@ -32,11 +32,6 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) -include_directories ( - ${cafProjectDataModel_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} -) - if (USE_COMMAND_FRAMEWORK) include_directories ( ${cafCommand_SOURCE_DIR} @@ -45,12 +40,6 @@ if (USE_COMMAND_FRAMEWORK) endif(USE_COMMAND_FRAMEWORK) -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) - set( PROJECT_FILES Main.cpp MainWindow.cpp @@ -75,7 +64,6 @@ add_executable ( ${PROJECT_NAME} set (TAP_LINK_LIBRARIES cafUserInterface - cafPdmXml ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 29eeeb0a82..05ffb6cbfe 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -6,15 +6,6 @@ include (${QT_USE_FILE}) project (cafUserInterface) -include_directories( - ${cafProjectDataModel_SOURCE_DIR} -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS @@ -154,10 +145,13 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries ( ${PROJECT_NAME} cafProjectDataModel - cafPdmUiCore - cafPdmCore ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt index 1644fccae9..d948f19b1c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt @@ -6,16 +6,7 @@ include (${QT_USE_FILE}) project ( cafUserInterface_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - - ${cafProjectDataModel_SOURCE_DIR} - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - - ${cafUserInterface_SOURCE_DIR} - + ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -39,10 +30,6 @@ source_group("" FILES ${PROJECT_FILES}) message(STATUS ${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafProjectDataModel - cafPdmUiCore - cafPdmCore - cafPdmXml cafUserInterface ${QT_LIBRARIES} ${THREAD_LIBRARY} From 3fbce58fa5ed13fda710fd388399ae5884c4e02b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 17:20:46 +0100 Subject: [PATCH 0369/1027] #2536 Build System AppFwk : Several updates Simplified automoc Use target_include_directories and target_link_libraries Use CMake 2.8.12 --- Fwk/AppFwk/CommonCode/CMakeLists.txt | 23 ++++++++++++++++--- Fwk/AppFwk/cafAnimControl/CMakeLists.txt | 19 ++++++++++++--- Fwk/AppFwk/cafCommand/CMakeLists.txt | 7 +++--- Fwk/AppFwk/cafPdmCvf/CMakeLists.txt | 18 +++++++-------- Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt | 2 +- .../cafPdmCore/CMakeLists.txt | 2 +- .../cafPdmCore_UnitTests/CMakeLists.txt | 2 +- .../cafPdmXml/CMakeLists.txt | 2 +- .../cafPdmXml_UnitTests/CMakeLists.txt | 4 +++- .../CMakeLists.txt | 9 ++++---- Fwk/AppFwk/cafTensor/CMakeLists.txt | 9 ++++++-- .../cafTestApplication/CMakeLists.txt | 2 +- Fwk/AppFwk/cafUserInterface/CMakeLists.txt | 4 ++-- .../cafUserInterface_UnitTests/CMakeLists.txt | 2 +- Fwk/AppFwk/cafViewer/CMakeLists.txt | 22 ++++++++++++++---- Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 21 ++++++++++++++++- 16 files changed, 107 insertions(+), 41 deletions(-) diff --git a/Fwk/AppFwk/CommonCode/CMakeLists.txt b/Fwk/AppFwk/CommonCode/CMakeLists.txt index ec5a12cd61..4d4b63e8ce 100644 --- a/Fwk/AppFwk/CommonCode/CMakeLists.txt +++ b/Fwk/AppFwk/CommonCode/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (CommonCode) @@ -15,8 +15,6 @@ include_directories( ${LibGuiQt_SOURCE_DIR} ${LibRender_SOURCE_DIR} ${LibViewing_SOURCE_DIR} - - ${cafPdmCore_SOURCE_DIR} ) # These headers need to go through Qt's MOC compiler @@ -54,3 +52,22 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + + cafPdmCore + + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt index fa400a77e2..4a4b41bffe 100644 --- a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt +++ b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafAnimControl) @@ -11,7 +11,7 @@ set( QOBJECT_HEADERS cafAnimationToolBar.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -30,8 +30,21 @@ set( QRC_FILES PARENT_SCOPE ) -add_library( ${PROJECT_NAME} +set( PROJECT_FILES + cafFrameAnimationControl.h cafFrameAnimationControl.cpp + cafAnimationToolBar.h cafAnimationToolBar.cpp +) + +add_library( ${PROJECT_NAME} + ${PROJECT_FILES} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafCommand/CMakeLists.txt b/Fwk/AppFwk/cafCommand/CMakeLists.txt index 7a40f0bbef..4ebb3c9fed 100644 --- a/Fwk/AppFwk/cafCommand/CMakeLists.txt +++ b/Fwk/AppFwk/cafCommand/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) @@ -13,7 +13,7 @@ set( QOBJECT_HEADERS cafCmdFeatureManager.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -70,5 +70,4 @@ target_link_libraries ( ${PROJECT_NAME} cafProjectDataModel ) - -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt index 6be4d2ef14..59976d98bf 100644 --- a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt +++ b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafPdmCvf) @@ -8,14 +8,8 @@ include (${QT_USE_FILE}) include_directories( ${LibCore_SOURCE_DIR} - ${cafProjectDataModel_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} - - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} ) - add_library( ${PROJECT_NAME} cafPdmCoreColor3f.h cafPdmUiCoreColor3f.cpp @@ -39,11 +33,15 @@ add_library( ${PROJECT_NAME} cafPdmFieldCvfMat4d.h ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries ( ${PROJECT_NAME} - cafPdmCore - cafPdmUiCore cafUserInterface - cafProjectDataModel LibCore ${QT_LIBRARIES} ) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt index e880ee564d..aab257286e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt @@ -32,4 +32,4 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index d703a7c6b6..40e8db36b0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafPdmCore) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt index 4868cb2407..ca70e46c3e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt index a1d93b0af9..01fa1d3fa6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt @@ -53,4 +53,4 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt index c00c5b9a44..04b8e830cc 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore ) include (${QT_USE_FILE}) @@ -26,6 +26,8 @@ target_link_libraries ( ${PROJECT_NAME} ${THREAD_LIBRARY} ) +source_group("" FILES ${PROJECT_FILES}) + # Copy Qt Dlls if (MSVC) set (QTLIBLIST QtCore ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt index ae22c33511..e1e29599ee 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) @@ -12,10 +12,9 @@ include_directories ( set( PROJECT_FILES cafPdmBasicTest.cpp cafProjectDataModel_UnitTests.cpp - Child.cpp - Parent.cpp - TestObj.cpp - + Child.cpp + Parent.cpp + TestObj.cpp ) # add the executable diff --git a/Fwk/AppFwk/cafTensor/CMakeLists.txt b/Fwk/AppFwk/cafTensor/CMakeLists.txt index 073a78e53a..309078c889 100644 --- a/Fwk/AppFwk/cafTensor/CMakeLists.txt +++ b/Fwk/AppFwk/cafTensor/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafTensor) @@ -17,6 +17,11 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries( ${PROJECT_NAME} LibCore ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt index 69de97347c..b1fa180561 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl ) diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 05ffb6cbfe..25cddf2a32 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) @@ -42,7 +42,7 @@ set( QOBJECT_HEADERS cafPdmUiDoubleValueEditor.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt index d948f19b1c..7c717e4e31 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index b0402fd991..20f87a547f 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafViewer) @@ -12,8 +12,6 @@ include_directories( ${LibViewing_SOURCE_DIR} ${LibRender_SOURCE_DIR} ${LibGuiQt_SOURCE_DIR} - - ${cafAnimControl_SOURCE_DIR} ) # These headers need to go through Qt's MOC compiler @@ -21,7 +19,7 @@ set( QOBJECT_HEADERS cafViewer.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -44,3 +42,19 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index a743f3b293..be8d96a763 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafVizExtensions) @@ -36,3 +36,22 @@ add_library( ${PROJECT_NAME} cafHexGridIntersectionTools/cafHexGridIntersectionTools.h cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + + CommonCode + + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) From 72a3b731bc952bf0a91a4ee2e16831a8991632fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 18:49:24 +0100 Subject: [PATCH 0370/1027] #2536 Build System : Add target_include_directories to boost-Subset --- ThirdParty/NRLib/CMakeLists.txt | 12 +++++++++--- ThirdParty/NRLib/well_UnitTests/CMakeLists.txt | 3 --- ThirdParty/boost-Subset/CMakeLists.txt | 7 ++++++- ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt | 8 +++++--- ThirdParty/nightcharts/CMakeLists.txt | 8 +++++++- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ThirdParty/NRLib/CMakeLists.txt b/ThirdParty/NRLib/CMakeLists.txt index 215aba8f7c..0b865c0cf2 100644 --- a/ThirdParty/NRLib/CMakeLists.txt +++ b/ThirdParty/NRLib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (NRLib) @@ -6,8 +6,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/nrlib ${CMAKE_CURRENT_SOURCE_DIR}/nrlib/well - - ${boost-Subset_SOURCE_DIR} ) file ( GLOB NRLIB_IOTOOLS_SRC @@ -32,3 +30,11 @@ endif() add_subdirectory(well_UnitTests) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/nrlib/well +) + +target_link_libraries ( ${PROJECT_NAME} + boost-Subset +) diff --git a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt index f8ff33b636..7b63af94da 100644 --- a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt +++ b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt @@ -7,8 +7,6 @@ include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. - - ${NR_well_SOURCE_DIR} ) set( PROJECT_FILES @@ -28,6 +26,5 @@ source_group("" FILES ${PROJECT_FILES}) target_link_libraries ( ${PROJECT_NAME} NRLib - boost-Subset ) diff --git a/ThirdParty/boost-Subset/CMakeLists.txt b/ThirdParty/boost-Subset/CMakeLists.txt index 2fe351529e..5a94a45d8c 100644 --- a/ThirdParty/boost-Subset/CMakeLists.txt +++ b/ThirdParty/boost-Subset/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Procedure used to extract subset from complete Boost installation # @@ -36,3 +36,8 @@ add_library( ${PROJECT_NAME} if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4244") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index e0f850276e..d04bfd3989 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (custom-opm-flowdiag-app) @@ -6,7 +6,6 @@ include_directories( ../custom-opm-flowdiagnostics/opm-flowdiagnostics opm-flowdiagnostics-applications opmCore - ${boost-Subset_SOURCE_DIR} ) include (opm-flowdiagnostics-applications/CMakeLists_files.cmake) @@ -26,7 +25,10 @@ add_library(custom-opm-flowdiag-app ${project_source_files_complete_path1} ) -target_link_libraries(custom-opm-flowdiag-app ecl) +target_link_libraries(custom-opm-flowdiag-app + ecl + boost-Subset +) if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4190 /wd4267") diff --git a/ThirdParty/nightcharts/CMakeLists.txt b/ThirdParty/nightcharts/CMakeLists.txt index 287617a83d..3169a76e4c 100644 --- a/ThirdParty/nightcharts/CMakeLists.txt +++ b/ThirdParty/nightcharts/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (nightcharts) @@ -14,3 +14,9 @@ add_library( ${PROJECT_NAME} ${MAIN_SOURCE_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) From 4f20273e552c00ef47353dbbf16abc3c62b809ad Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 18:56:12 +0100 Subject: [PATCH 0371/1027] #2536 Build System : Add target_include_directories to clipper, exprparser, qwt --- ThirdParty/Qwt/src/CMakeLists.txt | 5 +++++ ThirdParty/clipper/CMakeLists.txt | 8 +++++++- ThirdParty/expressionparser/CMakeLists.txt | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ThirdParty/Qwt/src/CMakeLists.txt b/ThirdParty/Qwt/src/CMakeLists.txt index 8844512282..46b51e9d7c 100644 --- a/ThirdParty/Qwt/src/CMakeLists.txt +++ b/ThirdParty/Qwt/src/CMakeLists.txt @@ -280,3 +280,8 @@ qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${MOC_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + diff --git a/ThirdParty/clipper/CMakeLists.txt b/ThirdParty/clipper/CMakeLists.txt index 0a17507090..300964eeb3 100644 --- a/ThirdParty/clipper/CMakeLists.txt +++ b/ThirdParty/clipper/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (clipper) @@ -11,3 +11,9 @@ add_library(${PROJECT_NAME} ${project_source_files} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ThirdParty/expressionparser/CMakeLists.txt b/ThirdParty/expressionparser/CMakeLists.txt index e2e72d8383..4de3ad10bf 100644 --- a/ThirdParty/expressionparser/CMakeLists.txt +++ b/ThirdParty/expressionparser/CMakeLists.txt @@ -22,3 +22,10 @@ add_library( ${PROJECT_NAME} if(MSVC) set_target_properties(expressionparser PROPERTIES COMPILE_FLAGS "/wd4267") endif() + + target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) From 3b63c8d43347ecc79889b844e718ca7ba5b46bee Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 19:05:04 +0100 Subject: [PATCH 0372/1027] #2536 Build System : Add target_include_directories to app libraries --- .../GeoMech/GeoMechDataModel/CMakeLists.txt | 14 +++++++++----- ApplicationCode/GeoMech/OdbReader/CMakeLists.txt | 7 +++++++ .../ResultStatisticsCache/CMakeLists.txt | 9 ++++++++- .../WellPathImportSsihub/CMakeLists.txt | 12 ++++++++---- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt index 2201832c4c..84ac9d44ee 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -1,12 +1,9 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (RigGeoMechDataModel) include_directories( ${LibCore_SOURCE_DIR} - ${cafTensor_SOURCE_DIR} - ../../ResultStatisticsCache - ../OdbReader ) @@ -38,4 +35,11 @@ add_library( ${PROJECT_NAME} RimGeoMechGeometrySelectionItem.cpp ) -target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache RifOdbReader) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt index 75078fa037..8537fa1696 100644 --- a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt +++ b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt @@ -86,4 +86,11 @@ else() ) endif(MSVC) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries(${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/ResultStatisticsCache/CMakeLists.txt b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt index 4ac1d30def..d3385421c2 100644 --- a/ApplicationCode/ResultStatisticsCache/CMakeLists.txt +++ b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (ResultStatisticsCache) @@ -15,4 +15,11 @@ add_library( ${PROJECT_NAME} RigStatisticsMath.cpp ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries(${PROJECT_NAME} LibCore) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt index 56cabdd553..fd34856a6f 100644 --- a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt +++ b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (WellPathImportSsihub) @@ -11,7 +11,7 @@ set( QOBJECT_HEADERS set( QT_UI_FILES ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) endif() @@ -20,8 +20,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../FileInterface - ${CMAKE_CURRENT_SOURCE_DIR}/../../Fwk/AppFwk/cafProjectDataModel - ${CMAKE_CURRENT_SOURCE_DIR}/../../Fwk/AppFwk/cafUserInterface ) @@ -43,3 +41,9 @@ add_library( ${PROJECT_NAME} ${FORM_FILES_CPP} ${HEADER_FILES} ) + +target_link_libraries ( ${PROJECT_NAME} + cafUserInterface +) + +source_group("" FILES ${PROJECT_FILES}) From 233df05f68d24172d5858fcf996116e58db39c27 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 27 Feb 2018 20:00:56 +0100 Subject: [PATCH 0373/1027] #2536 Build System : Remove obsolete includes and update depending includes --- ApplicationCode/CMakeLists.txt | 27 +++---------------- .../GeoMech/GeoMechDataModel/CMakeLists.txt | 12 ++++++++- .../GeoMech/OdbReader/CMakeLists.txt | 1 - .../UserInterface/RiuNightchartsWidget.h | 2 +- .../WellPathImportSsihub/CMakeLists.txt | 2 +- CMakeLists.txt | 2 +- Fwk/AppFwk/cafViewer/CMakeLists.txt | 3 +++ Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 1 - .../NRLib/well_UnitTests/CMakeLists.txt | 2 -- .../custom-opm-flowdiag-app/CMakeLists.txt | 5 ++++ .../custom-opm-flowdiagnostics/CMakeLists.txt | 5 ++++ 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index ade87f19a1..1709c2705f 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (ApplicationCode) @@ -15,29 +15,10 @@ if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) endif() include_directories( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - ${cafProjectDataModel_SOURCE_DIR} - - ${cafCommand_SOURCE_DIR} - ${cafViewer_SOURCE_DIR} - ${cafAnimControl_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} - ${cafPdmCvf_SOURCE_DIR} - ${CommonCode_SOURCE_DIR} - ${cafVizExtensions_SOURCE_DIR} - ${cafTensor_SOURCE_DIR} - - ${ResInsight_SOURCE_DIR}/ThirdParty - ${ResInsight_SOURCE_DIR}/ThirdParty/NRLib/nrlib/well - ${ResInsight_SOURCE_DIR}/ThirdParty/Qwt/src - - ${boost-Subset_SOURCE_DIR} - ${custom-opm-flowdiagnostics_SOURCE_DIR}/opm-flowdiagnostics/ - ${custom-opm-flowdiag-app_SOURCE_DIR}/opm-flowdiagnostics-applications/ - ${custom-opm-flowdiag-app_SOURCE_DIR}/opmCore + # required for compilation of gtest, should be refactored + ${ResInsight_SOURCE_DIR}/ThirdParty + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Adm ${CMAKE_CURRENT_SOURCE_DIR}/Application diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt index 84ac9d44ee..c42c903c13 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -40,6 +40,16 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache RifOdbReader) +target_link_libraries( ${PROJECT_NAME} + LibCore + + cafPdmCvf + cafTensor + cafUserInterface + CommonCode + + ResultStatisticsCache + RifOdbReader +) source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt index 8537fa1696..b6c1af5f96 100644 --- a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt +++ b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt @@ -36,7 +36,6 @@ endif(MSVC) include_directories( ${RESINSIGHT_ODB_API_DIR}/include - ${RigGeoMechDataModel_SOURCE_DIR} ${LibCore_SOURCE_DIR} ) diff --git a/ApplicationCode/UserInterface/RiuNightchartsWidget.h b/ApplicationCode/UserInterface/RiuNightchartsWidget.h index 777b112d96..0a0ba6df5a 100644 --- a/ApplicationCode/UserInterface/RiuNightchartsWidget.h +++ b/ApplicationCode/UserInterface/RiuNightchartsWidget.h @@ -19,7 +19,7 @@ #pragma once -#include "nightcharts/nightcharts.h" +#include "nightcharts.h" #include "cafPdmPointer.h" diff --git a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt index fd34856a6f..acaa843178 100644 --- a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt +++ b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt @@ -43,7 +43,7 @@ add_library( ${PROJECT_NAME} ) target_link_libraries ( ${PROJECT_NAME} - cafUserInterface + cafUserInterface cafPdmCvf CommonCode ) source_group("" FILES ${PROJECT_FILES}) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1df8eeada..fe0a25768a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) include (CheckCSourceCompiles) project (ResInsight) diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index 20f87a547f..0a4e14227d 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -54,6 +54,9 @@ target_link_libraries ( ${PROJECT_NAME} LibViewing LibRender LibGuiQt + + cafAnimControl + ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index be8d96a763..11a4548332 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -11,7 +11,6 @@ include_directories( ${LibGuiQt_SOURCE_DIR} ${LibRender_SOURCE_DIR} ${LibViewing_SOURCE_DIR} - ${CommonCode_SOURCE_DIR} ) add_library( ${PROJECT_NAME} diff --git a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt index 7b63af94da..7938ccdb9a 100644 --- a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt +++ b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt @@ -4,8 +4,6 @@ project ( well_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. ) diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index d04bfd3989..c37bd33e02 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -33,3 +33,8 @@ target_link_libraries(custom-opm-flowdiag-app if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4190 /wd4267") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/opm-flowdiagnostics-applications +) diff --git a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt index 3e072c7c1e..447ed4e265 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt @@ -24,3 +24,8 @@ add_library(${PROJECT_NAME} if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4267") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/opm-flowdiagnostics +) From ca0087eb55746c52c08b354274920a401a0277bb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 28 Feb 2018 07:42:19 +0100 Subject: [PATCH 0374/1027] #2536 Build System VizFwk : Use target_* and remove includes --- .../GeoMech/GeoMechDataModel/CMakeLists.txt | 4 ---- .../GeoMech/OdbReader/CMakeLists.txt | 1 - CMakeLists.txt | 8 ------- Fwk/AppFwk/CommonCode/CMakeLists.txt | 8 ------- Fwk/AppFwk/cafPdmCvf/CMakeLists.txt | 4 ---- Fwk/AppFwk/cafTensor/CMakeLists.txt | 4 ---- Fwk/AppFwk/cafViewer/CMakeLists.txt | 8 ------- Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 8 ------- Fwk/VizFwk/LibCore/CMakeLists.txt | 7 ++++++ Fwk/VizFwk/LibGeometry/CMakeLists.txt | 14 +++++++++--- Fwk/VizFwk/LibGuiQt/CMakeLists.txt | 22 +++++++++++++------ Fwk/VizFwk/LibRender/CMakeLists.txt | 14 ++++++++++-- Fwk/VizFwk/LibViewing/CMakeLists.txt | 20 ++++++++++++----- 13 files changed, 59 insertions(+), 63 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt index c42c903c13..57217c686e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required (VERSION 2.8.12) project (RigGeoMechDataModel) -include_directories( - ${LibCore_SOURCE_DIR} -) - add_library( ${PROJECT_NAME} RigFemPart.h diff --git a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt index b6c1af5f96..57719f104f 100644 --- a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt +++ b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt @@ -36,7 +36,6 @@ endif(MSVC) include_directories( ${RESINSIGHT_ODB_API_DIR}/include - ${LibCore_SOURCE_DIR} ) add_library( ${PROJECT_NAME} diff --git a/CMakeLists.txt b/CMakeLists.txt index fe0a25768a..8a411e5bbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,14 +342,6 @@ add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibRender) add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibViewing) add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibGuiQt) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} -) - list(APPEND VIZ_FWK_LIBRARIES LibGuiQt LibViewing diff --git a/Fwk/AppFwk/CommonCode/CMakeLists.txt b/Fwk/AppFwk/CommonCode/CMakeLists.txt index 4d4b63e8ce..52e5193f4d 100644 --- a/Fwk/AppFwk/CommonCode/CMakeLists.txt +++ b/Fwk/AppFwk/CommonCode/CMakeLists.txt @@ -9,14 +9,6 @@ include (${QT_USE_FILE}) # Open GL find_package( OpenGL ) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} -) - # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS cafMessagePanel.h diff --git a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt index 59976d98bf..bafd45477d 100644 --- a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt +++ b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt @@ -6,10 +6,6 @@ project (cafPdmCvf) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) -include_directories( - ${LibCore_SOURCE_DIR} -) - add_library( ${PROJECT_NAME} cafPdmCoreColor3f.h cafPdmUiCoreColor3f.cpp diff --git a/Fwk/AppFwk/cafTensor/CMakeLists.txt b/Fwk/AppFwk/cafTensor/CMakeLists.txt index 309078c889..d15a356c04 100644 --- a/Fwk/AppFwk/cafTensor/CMakeLists.txt +++ b/Fwk/AppFwk/cafTensor/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required (VERSION 2.8.12) project (cafTensor) -include_directories ( - ${LibCore_SOURCE_DIR} -) - set( PROJECT_FILES cafTensor3.cpp cafTensor3.h diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index 0a4e14227d..2850fc3b0d 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -6,14 +6,6 @@ project (cafViewer) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} -) - # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS cafViewer.h diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index 11a4548332..783194cc35 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -5,14 +5,6 @@ project (cafVizExtensions) # Open GL find_package( OpenGL ) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} -) - add_library( ${PROJECT_NAME} cafDisplayCoordTransform.cpp cafDisplayCoordTransform.h diff --git a/Fwk/VizFwk/LibCore/CMakeLists.txt b/Fwk/VizFwk/LibCore/CMakeLists.txt index 3ce19f6ec0..0637746261 100644 --- a/Fwk/VizFwk/LibCore/CMakeLists.txt +++ b/Fwk/VizFwk/LibCore/CMakeLists.txt @@ -100,3 +100,10 @@ cvfVector4.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibGeometry/CMakeLists.txt b/Fwk/VizFwk/LibGeometry/CMakeLists.txt index 6034118a2c..c18b0bd727 100644 --- a/Fwk/VizFwk/LibGeometry/CMakeLists.txt +++ b/Fwk/VizFwk/LibGeometry/CMakeLists.txt @@ -7,9 +7,6 @@ project(LibGeometry) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") -include_directories(../LibCore) - - set(CEE_HEADER_FILES cvfArrowGenerator.h cvfBoundingBox.h @@ -57,3 +54,14 @@ cvfVertexWelder.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt index 5184988103..b699af4960 100644 --- a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt +++ b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt @@ -14,13 +14,6 @@ endif() find_package(Qt4 REQUIRED) include(${QT_USE_FILE}) - -include_directories(../LibCore) -include_directories(../LibGeometry) -include_directories(../LibRender) -include_directories(../LibViewing) - - set(CEE_HEADER_FILES cvfqtBasicAboutDialog.h cvfqtCvfBoundQGLContext.h @@ -43,3 +36,18 @@ cvfqtUtils.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibRender + LibViewing + + ${QT_LIBRARIES} +) +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibRender/CMakeLists.txt b/Fwk/VizFwk/LibRender/CMakeLists.txt index d2e28dee6c..73466d5e69 100644 --- a/Fwk/VizFwk/LibRender/CMakeLists.txt +++ b/Fwk/VizFwk/LibRender/CMakeLists.txt @@ -18,8 +18,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() -include_directories(../LibCore) -include_directories(../LibGeometry) include_directories(glew) @@ -178,3 +176,15 @@ cvfViewport.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibViewing/CMakeLists.txt b/Fwk/VizFwk/LibViewing/CMakeLists.txt index 7c40ee0661..28f5937fbd 100644 --- a/Fwk/VizFwk/LibViewing/CMakeLists.txt +++ b/Fwk/VizFwk/LibViewing/CMakeLists.txt @@ -6,12 +6,6 @@ project(LibViewing) # Use our strict compile flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") - -include_directories(../LibCore) -include_directories(../LibGeometry) -include_directories(../LibRender) - - set(CEE_HEADER_FILES cvfClipPlaneSet.h cvfConstantFrameRate.h @@ -76,3 +70,17 @@ cvfTransform.cpp ) add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibRender +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) From 89c090ba2476d4eca153de36424110de5a049f06 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 28 Feb 2018 08:05:00 +0100 Subject: [PATCH 0375/1027] #2536 Build System : Remove obsolete code for cmake older than "2.8.2" --- .../Application/CMakeLists_files.cmake | 51 +-- .../Application/Tools/CMakeLists_files.cmake | 84 ++-- .../CMakeLists_files.cmake | 59 ++- .../Commands/CMakeLists_files.cmake | 229 +++++----- .../CompletionCommands/CMakeLists_files.cmake | 39 +- .../CMakeLists_files.cmake | 59 ++- .../CMakeLists_files.cmake | 31 +- .../EclipseCommands/CMakeLists_files.cmake | 83 ++-- .../EclipseWell/CMakeLists_files.cmake | 14 +- .../ExportCommands/CMakeLists_files.cmake | 75 ++-- .../FlowCommands/CMakeLists_files.cmake | 47 +-- .../FractureCommands/CMakeLists_files.cmake | 55 ++- .../CMakeLists_files.cmake | 33 +- .../CMakeLists_files.cmake | 11 +- .../CMakeLists_files.cmake | 41 +- .../CMakeLists_files.cmake | 39 +- .../CMakeLists_files.cmake | 145 +++---- .../ToggleCommands/CMakeLists_files.cmake | 27 +- .../Commands/ViewLink/CMakeLists_files.cmake | 39 +- .../WellLogCommands/CMakeLists_files.cmake | 99 +++-- .../WellPathCommands/CMakeLists_files.cmake | 39 +- .../FileInterface/CMakeLists_files.cmake | 159 ++++--- .../CMakeLists_files.cmake | 35 +- .../ModelVisualization/CMakeLists_files.cmake | 145 ++++--- .../GridBox/CMakeLists_files.cmake | 15 +- .../Intersections/CMakeLists_files.cmake | 35 +- .../CMakeLists_files.cmake | 11 +- .../ProjectDataModel/CMakeLists_files.cmake | 395 +++++++++--------- .../Completions/CMakeLists_files.cmake | 87 ++-- .../Flow/CMakeLists_files.cmake | 55 ++- .../Summary/CMakeLists_files.cmake | 123 +++--- .../ReservoirDataModel/CMakeLists_files.cmake | 249 ++++++----- .../CMakeLists_filesNotToUnitTest.cmake | 35 +- .../UnitTests/CMakeLists_files.cmake | 71 ++-- .../UserInterface/CMakeLists_files.cmake | 325 +++++++------- 35 files changed, 1431 insertions(+), 1608 deletions(-) diff --git a/ApplicationCode/Application/CMakeLists_files.cmake b/ApplicationCode/Application/CMakeLists_files.cmake index e8bf0d2989..6e0a95b270 100644 --- a/ApplicationCode/Application/CMakeLists_files.cmake +++ b/ApplicationCode/Application/CMakeLists_files.cmake @@ -1,32 +1,27 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RiaApplication.h -${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h -${CEE_CURRENT_LIST_DIR}RiaDefines.h -${CEE_CURRENT_LIST_DIR}RiaFractureDefines.h -${CEE_CURRENT_LIST_DIR}RiaPreferences.h -${CEE_CURRENT_LIST_DIR}RiaPorosityModel.h -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.h -${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.h -${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.h +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaDefines.h +${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.h +${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.h +${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiaApplication.cpp -${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.cpp -${CEE_CURRENT_LIST_DIR}RiaDefines.cpp -${CEE_CURRENT_LIST_DIR}RiaFractureDefines.cpp -${CEE_CURRENT_LIST_DIR}RiaMain.cpp -${CEE_CURRENT_LIST_DIR}RiaPreferences.cpp -${CEE_CURRENT_LIST_DIR}RiaPorosityModel.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.cpp -${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.cpp -${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaDefines.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaMain.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.cpp ) list(APPEND CODE_HEADER_FILES @@ -39,10 +34,10 @@ ${SOURCE_GROUP_SOURCE_FILES} set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RiaApplication.h -${CEE_CURRENT_LIST_DIR}RiaCompletionTypeCalculationScheduler.h -${CEE_CURRENT_LIST_DIR}RiaViewRedrawScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.h +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h ) -source_group( "Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index 8a38c31b7a..56ab980717 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -1,52 +1,46 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RiaArgumentParser.h -${CEE_CURRENT_LIST_DIR}RiaDateStringParser.h -${CEE_CURRENT_LIST_DIR}RiaColorTables.h -${CEE_CURRENT_LIST_DIR}RiaColorTools.h -${CEE_CURRENT_LIST_DIR}RiaEclipseUnitTools.h -${CEE_CURRENT_LIST_DIR}RiaImageCompareReporter.h -${CEE_CURRENT_LIST_DIR}RiaImageFileCompare.h -${CEE_CURRENT_LIST_DIR}RiaLogging.h -${CEE_CURRENT_LIST_DIR}RiaProjectModifier.h -${CEE_CURRENT_LIST_DIR}RiaRegressionTest.h -${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.h -${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.h -${CEE_CURRENT_LIST_DIR}RiaSummaryTools.h -${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.h -${CEE_CURRENT_LIST_DIR}RiaStdStringTools.h -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.h -${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.h -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools.h -${CEE_CURRENT_LIST_DIR}RiaStringEncodingTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaArgumentParser.h +${CMAKE_CURRENT_LIST_DIR}/RiaDateStringParser.h +${CMAKE_CURRENT_LIST_DIR}/RiaColorTables.h +${CMAKE_CURRENT_LIST_DIR}/RiaColorTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaImageCompareReporter.h +${CMAKE_CURRENT_LIST_DIR}/RiaImageFileCompare.h +${CMAKE_CURRENT_LIST_DIR}/RiaLogging.h +${CMAKE_CURRENT_LIST_DIR}/RiaProjectModifier.h +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTest.h +${CMAKE_CURRENT_LIST_DIR}/RiaImportEclipseCaseTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaQDateTimeTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.h +${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.h +${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiaArgumentParser.cpp -${CEE_CURRENT_LIST_DIR}RiaDateStringParser.cpp -${CEE_CURRENT_LIST_DIR}RiaColorTables.cpp -${CEE_CURRENT_LIST_DIR}RiaColorTools.cpp -${CEE_CURRENT_LIST_DIR}RiaEclipseUnitTools.cpp -${CEE_CURRENT_LIST_DIR}RiaImageCompareReporter.cpp -${CEE_CURRENT_LIST_DIR}RiaImageFileCompare.cpp -${CEE_CURRENT_LIST_DIR}RiaLogging.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectModifier.cpp -${CEE_CURRENT_LIST_DIR}RiaRegressionTest.cpp -${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.cpp -${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryTools.cpp -${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.cpp -${CEE_CURRENT_LIST_DIR}RiaStdStringTools.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.cpp -${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools.cpp -${CEE_CURRENT_LIST_DIR}RiaStringEncodingTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaArgumentParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaDateStringParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaColorTables.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaColorTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImageCompareReporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImageFileCompare.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaLogging.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectModifier.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTest.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImportEclipseCaseTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaQDateTimeTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -62,4 +56,4 @@ ${QT_MOC_HEADERS} ) -source_group( "Application\\Tools" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "Application\\Tools" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 453af21c51..443493fdd6 100644 --- a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -1,39 +1,34 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h -${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h -${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.h -${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h -${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicOpenLastUsedFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.h -${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicHelpFeatures.h -${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.h -${CEE_CURRENT_LIST_DIR}RicShowPlotDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLaunchUnitTestsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotWindowFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowMainWindowFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicTileWindowsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicOpenProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicOpenLastUsedFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectAsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExitApplicationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.h +${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.cpp -${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicOpenLastUsedFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHelpFeatures.cpp -${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowPlotDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLaunchUnitTestsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotWindowFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowMainWindowFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicTileWindowsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicOpenProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicOpenLastUsedFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectAsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExitApplicationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -49,4 +44,4 @@ ${QT_MOC_HEADERS} ) -source_group( "CommandFeature\\Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index c04f095692..4ca7189620 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -1,138 +1,133 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicWellLogTools.h -${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.h -${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewInViewFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicNewViewFeature.h -${CEE_CURRENT_LIST_DIR}RicPropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterExecImpl.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h -${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h -${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h -${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicSelectColorResult.h - -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h - -${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h -${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportSummaryCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.h -${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.h -${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h - -${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogTools.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseInCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseObservedDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateSummaryCaseCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewInViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicNewViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterExecImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceIFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceJFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceKFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadWellPathFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSliceRangeFilterFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.h + +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h + +${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataInMenuFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.h + +${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.h # General delete of any object in a child array field -${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h -${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h -${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h -${CEE_CURRENT_LIST_DIR}RicCommandFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCommandFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadSummaryCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.h -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h -${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h -${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicWellLogTools.cpp -${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewInViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicNewViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterExecImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportElementPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSelectColorResult.cpp - -${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportSummaryCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp - -${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseInCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseObservedDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateSummaryCaseCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewInViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterExecImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceIFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceJFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceKFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadWellPathFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSliceRangeFilterFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataInMenuFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp # General delete of any object in a child array field -${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.cpp -${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp ) @@ -145,8 +140,8 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h -${CEE_CURRENT_LIST_DIR}RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ) -source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake index 43d1959445..85a8736fc5 100644 --- a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.cpp ) @@ -35,4 +30,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Completion" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Completion" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 647b7d6ba0..7a2e1ebfbc 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -1,49 +1,44 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h -${CEE_CURRENT_LIST_DIR}RigCompletionData.h -${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.h -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h -${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.h +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h + ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h + ${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.h + ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.h + ${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.h + ${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp -${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp -${CEE_CURRENT_LIST_DIR}RigCompletionDataGridCell.cpp -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.cpp ) endif() @@ -56,4 +51,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\CompletionExport" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\CompletionExport" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index 3ec39b00dc..e13a41b661 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -1,25 +1,20 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -30,4 +25,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\CrossSection" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\CrossSection" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake index c3c1cd1e66..1bfbc3825f 100644 --- a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -1,51 +1,46 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.h -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFromFilesFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddEclipseInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicComputeStatisticsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFromFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportInputEclipseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicApplyPropertyFilterAsCellResultFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseTimeStepFilterFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewInViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseHideFaultFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFromFilesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportEclipseCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddEclipseInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicComputeStatisticsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFromFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportInputEclipseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicApplyPropertyFilterAsCellResultFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseTimeStepFilterFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewInViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseHideFaultFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -56,4 +51,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Eclipse" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Eclipse" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake index 27f3295bad..333d21e9ac 100644 --- a/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake @@ -1,17 +1,13 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicEclipseWellFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicEclipseWellShowFeatures.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicEclipseWellFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseWellShowFeatures.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.cpp ) list(APPEND CODE_HEADER_FILES @@ -22,4 +18,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Eclipse\\Well" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Eclipse\\Well" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake index e667c58d71..5fdd3d1c04 100644 --- a/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake @@ -1,47 +1,42 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h -${CEE_CURRENT_LIST_DIR}RicExportCarfin.h -${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.h -${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h -${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.h -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCellRangeUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfin.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFaultsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportMultipleSnapshotsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileResampleUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyExec.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllPlotsToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp -${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp -${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.cpp -${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCellRangeUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfin.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFaultsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportMultipleSnapshotsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileResampleUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllPlotsToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -52,4 +47,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Export" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Export" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index b1f7eeb979..08a748ed6b 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -1,33 +1,28 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicAddStoredFlowCharacteristicsPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.h -${CEE_CURRENT_LIST_DIR}RicSelectViewUI.h -${CEE_CURRENT_LIST_DIR}RicShowTotalAllocationDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredFlowCharacteristicsPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowWellAllocationPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowFlowCharacteristicsPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredWellAllocationPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFromPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.h +${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddStoredFlowCharacteristicsPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSelectViewUI.cpp -${CEE_CURRENT_LIST_DIR}RicShowTotalAllocationDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredFlowCharacteristicsPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowWellAllocationPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowFlowCharacteristicsPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredWellAllocationPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFromPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -38,4 +33,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\FlowDiagnostics" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\FlowDiagnostics" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake index c5bd8935db..fc0972113c 100644 --- a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -1,37 +1,32 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.h -${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.h -${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.h -${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.h -${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.h -${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h -${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertFractureTemplateUnitFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteStimPlanFractureFeature.cpp -${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.cpp -${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.cpp -${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.cpp -${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertFractureTemplateUnitFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.cpp ) @@ -43,4 +38,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Fracture" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Fracture" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake index 8d4df6e2cb..d6a827a118 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake @@ -1,25 +1,20 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxZSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxYSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxZSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxAtPosFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxZSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxYSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxZSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxAtPosFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,8 +27,8 @@ ${SOURCE_GROUP_SOURCE_FILES} set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.h ) -source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake index 30d4a7728f..9dc9020940 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake @@ -1,15 +1,10 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewIntersectionViewFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicNewIntersectionViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewIntersectionViewFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -20,4 +15,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\IntersectionView" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\IntersectionView" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake index a2fe983e05..dc59b75adc 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake @@ -1,34 +1,29 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicAddScriptPathFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteScriptPathFeature.h -${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddScriptPathFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteScriptPathFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicScriptFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRefreshScriptsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddScriptPathFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteScriptPathFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddScriptPathFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteScriptPathFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicScriptFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRefreshScriptsFeature.cpp ) set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.h ) list(APPEND CODE_HEADER_FILES @@ -39,4 +34,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Script" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Script" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake index ce29835af3..9cd1e67568 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h - -${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteIntersectionsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCopyReferencesToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCutReferencesToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteFeatureImpl.h + +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp - -${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteIntersectionsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCopyReferencesToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCutReferencesToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteFeatureImpl.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 841ee8017a..20ed2af625 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -1,78 +1,72 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicSelectSummaryPlotUI.h -${CEE_CURRENT_LIST_DIR}RicPasteTimeHistoryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.h -${CEE_CURRENT_LIST_DIR}RicShowSummaryCurveCalculatorFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryCurveCalculationFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculator.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreator.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSelectSummaryPlotUI.cpp -${CEE_CURRENT_LIST_DIR}RicPasteTimeHistoryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.cpp -${CEE_CURRENT_LIST_DIR}RicShowSummaryCurveCalculatorFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryCurveCalculationFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculator.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -84,11 +78,10 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h ) - -source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake index 7827ec4f56..ce811d143d 100644 --- a/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake @@ -1,23 +1,18 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOffFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnOthersOffFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOffFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnOthersOffFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOffFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnOthersOffFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOffFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnOthersOffFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -28,4 +23,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ToggleItems" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ToggleItems" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake index 38cdeccec9..f709a38efc 100644 --- a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.h -${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h -${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicShowAllLinkedViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicUnLinkViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowLinkOptionsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllLinkedViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSetMasterViewFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowAllLinkedViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicUnLinkViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowLinkOptionsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllLinkedViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSetMasterViewFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ViewLink" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ViewLink" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 05eb69c4d6..7f31e9a079 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -1,59 +1,54 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogCurveExtractionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogRftCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicNewRftPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteRftPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPltPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDeletePltPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogFileCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.h -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.h -${CEE_CURRENT_LIST_DIR}RicMoveWellLogFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddWellLogToPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCurveExtractionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogRftCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewRftPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteRftPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPltPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeletePltPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogFileCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotCurveFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellLogPlotTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotTrackFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogCurveExtractionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogRftCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewRftPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteRftPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPltPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeletePltPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogFileCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicMoveWellLogFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddWellLogToPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCurveExtractionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogRftCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewRftPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteRftPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPltPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeletePltPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogFileCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotCurveFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellLogPlotTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotTrackFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -64,4 +59,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake index d5bbb20c97..67a87c1d8c 100644 --- a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.h -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.h -${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h -${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.h -${CEE_CURRENT_LIST_DIR}RicWellPathFormationsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathDeleteFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionViewerEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathFormationsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathDeleteFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionViewerEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 3f2483b921..93e3e5c91a 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -1,102 +1,97 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.h -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h -${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h -${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h -${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataParserTools.h -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.h -${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.h -${CEE_CURRENT_LIST_DIR}RifReaderObservedData.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.h -${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h -${CEE_CURRENT_LIST_DIR}RifReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h -${CEE_CURRENT_LIST_DIR}RifReaderSettings.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddressQMetaType.h -${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.h -${CEE_CURRENT_LIST_DIR}RifWellPathImporter.h -${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.h -${CEE_CURRENT_LIST_DIR}RifKeywordVectorUserData.h -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPlt.h -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPltQMetaType.h -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.h -${CEE_CURRENT_LIST_DIR}RifCsvUserData.h -${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h -${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h -${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h -${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.h -${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseOutputFileTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartDataAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartFilesetAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUnifiedRestartFileAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.h +${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.h +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.h +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorParser.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseRft.h +${CMAKE_CURRENT_LIST_DIR}/RifJsonEncodeDecode.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderMockModel.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderSettings.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddressQMetaType.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRftAddress.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathImporter.h +${CMAKE_CURRENT_LIST_DIR}/RifHdf5ReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPlt.h +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPltQMetaType.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataKeywordTools.h +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserDataParser.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationReader.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.h +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.h +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt -#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h +#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.h + ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp -${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp -${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataParserTools.cpp -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.cpp -${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.cpp -${CEE_CURRENT_LIST_DIR}RifReaderObservedData.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.cpp -${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp -${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp -${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathImporter.cpp -${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.cpp -${CEE_CURRENT_LIST_DIR}RifKeywordVectorUserData.cpp -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPlt.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.cpp -${CEE_CURRENT_LIST_DIR}RifCsvUserData.cpp -${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp -${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader.cpp -${CEE_CURRENT_LIST_DIR}RifElementPropertyReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseOutputFileTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartDataAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartFilesetAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUnifiedRestartFileAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.cpp +${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseRft.cpp +${CMAKE_CURRENT_LIST_DIR}/RifJsonEncodeDecode.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderMockModel.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRftAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathImporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifHdf5ReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPlt.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataKeywordTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserDataParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt -#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp +#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp ) endif() @@ -108,4 +103,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake index adb8e6856c..8db4eb3e1a 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake @@ -1,28 +1,23 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.h -${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.h -${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.cpp -${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.cpp ) @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index a575ad5258..14c8291b78 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -1,92 +1,87 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.h -${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.h -${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivGridPartMgr.h -${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.h -${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.h -${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.h -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h -${CEE_CURRENT_LIST_DIR}RivWellPathsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.h -${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h -${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivCompletionTypeResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivDefaultResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivTernaryResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.h -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.h -${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.h -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h -${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h -${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h -${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h -${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h -${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h -${CEE_CURRENT_LIST_DIR}RivPartPriority.h -${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeEffectGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivFaultPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivFaultGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivNNCGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivGridPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivTernarySaturationOverlayItem.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirViewPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirFaultsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirSimWellsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipesPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellHeadPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivCompletionTypeResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivDefaultResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTextureCoordsCreator.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryTextureCoordsCreator.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapperEffectGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivScalarMapperUtils.h +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeGeometryUtils.h +${CMAKE_CURRENT_LIST_DIR}/RivPipeQuadToSegmentMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivSingleCellPartGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipeSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellSpheresPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivPartPriority.h +${CMAKE_CURRENT_LIST_DIR}/RivObjectSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.h + ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivGridPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivWellPathsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp -${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp -${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp -${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivTensorResultPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeEffectGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFaultPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivNNCGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFaultGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGridPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernarySaturationOverlayItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirFaultsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirViewPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirSimWellsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipesPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellHeadPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTextureCoordsCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryTextureCoordsCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapperEffectGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivScalarMapperUtils.cpp +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeGeometryUtils.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeQuadToSegmentMapper.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSingleCellPartGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipeSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellSpheresPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivObjectSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp + ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp ) endif() @@ -98,4 +93,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake index 0049fdae70..3406423cc9 100644 --- a/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake @@ -1,17 +1,12 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RivPatchGenerator.h -${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivPatchGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivGridBoxGenerator.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivPatchGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPatchGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGridBoxGenerator.cpp ) @@ -23,4 +18,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization\\GridBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization\\GridBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake index c76e7125bd..5d2e68a6d6 100644 --- a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake @@ -1,27 +1,22 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RivIntersectionGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.h -${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivIntersectionGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,4 +27,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization\\Intersections" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization\\Intersections" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake index 8b861106db..37eb426653 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake @@ -1,15 +1,10 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RivWindowEdgeAxesOverlayItem.h +${CMAKE_CURRENT_LIST_DIR}/RivWindowEdgeAxesOverlayItem.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivWindowEdgeAxesOverlayItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWindowEdgeAxesOverlayItem.cpp ) @@ -21,4 +16,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization\\WindowEdgeAxesOverlayItem" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization\\WindowEdgeAxesOverlayItem" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 337ea62e44..ec45d9cf78 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -1,216 +1,211 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCellFilter.h -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.h -${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimLegendConfig.h -${CEE_CURRENT_LIST_DIR}RimOilField.h -${CEE_CURRENT_LIST_DIR}RimProject.h -${CEE_CURRENT_LIST_DIR}RimEclipseCase.h -${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseView.h -${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.h -${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.h -${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.h -${CEE_CURRENT_LIST_DIR}RimSimWellInView.h -${CEE_CURRENT_LIST_DIR}RimSimWellInViewCollection.h -${CEE_CURRENT_LIST_DIR}RimWellPath.h -${CEE_CURRENT_LIST_DIR}RimWellPathCollection.h -${CEE_CURRENT_LIST_DIR}RimScriptCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCalcScript.h -${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.h -${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.h -${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.h -${CEE_CURRENT_LIST_DIR}RimTensorResults.h -${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.h -${CEE_CURRENT_LIST_DIR}RimMimeData.h -${CEE_CURRENT_LIST_DIR}RimCommandObject.h -${CEE_CURRENT_LIST_DIR}RimTools.h -${CEE_CURRENT_LIST_DIR}RimFaultInView.h -${CEE_CURRENT_LIST_DIR}RimFaultInViewCollection.h -${CEE_CURRENT_LIST_DIR}RimFormationNames.h -${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.h -${CEE_CURRENT_LIST_DIR}RimMockModelSettings.h -${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.h -${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.h -${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.h -${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.h -${CEE_CURRENT_LIST_DIR}RimGeoMechModels.h -${CEE_CURRENT_LIST_DIR}RimGeoMechCase.h -${CEE_CURRENT_LIST_DIR}RimGeoMechView.h -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h -${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h -${CEE_CURRENT_LIST_DIR}RimViewWindow.h -${CEE_CURRENT_LIST_DIR}Rim3dView.h -${CEE_CURRENT_LIST_DIR}RimGridView.h -${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.h -${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.h -${CEE_CURRENT_LIST_DIR}RimViewManipulator.h -${CEE_CURRENT_LIST_DIR}RimCase.h -${CEE_CURRENT_LIST_DIR}RimViewController.h -${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimRftPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimPltPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RimWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RimWellLogCurve.h -${CEE_CURRENT_LIST_DIR}RimViewLinker.h -${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h -${CEE_CURRENT_LIST_DIR}RimWellLogFile.h -${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.h -${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.h -${CEE_CURRENT_LIST_DIR}RimWellLogRftCurve.h -${CEE_CURRENT_LIST_DIR}RimIntersection.h -${CEE_CURRENT_LIST_DIR}RimIntersectionCollection.h -${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.h -${CEE_CURRENT_LIST_DIR}RimGridCollection.h -${CEE_CURRENT_LIST_DIR}RimPlotCurve.h -${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h -${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h -${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h -${CEE_CURRENT_LIST_DIR}RimPropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimNamedObject.h -${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.h -${CEE_CURRENT_LIST_DIR}RimGridTimeHistoryCurve.h -${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.h -${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.h -${CEE_CURRENT_LIST_DIR}RimDialogData.h -${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimOilField.h +${CMAKE_CURRENT_LIST_DIR}/RimProject.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.h +${CMAKE_CURRENT_LIST_DIR}/RimIdenticalGridCaseGroup.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputProperty.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputPropertyCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseView.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCellColors.h +${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCalcScript.h +${CMAKE_CURRENT_LIST_DIR}/RimExportInputPropertySettings.h +${CMAKE_CURRENT_LIST_DIR}/RimBinaryExportSettings.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dOverlayInfoConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimTensorResults.h +${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.h +${CMAKE_CURRENT_LIST_DIR}/RimMimeData.h +${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.h +${CMAKE_CURRENT_LIST_DIR}/RimTools.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.h +${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimMockModelSettings.h +${CMAKE_CURRENT_LIST_DIR}/RimTernaryLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseFaultColors.h +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNNC.h +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNncCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechModels.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCase.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechView.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechResultDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCellColors.h +${CMAKE_CURRENT_LIST_DIR}/RimViewWindow.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dView.h +${CMAKE_CURRENT_LIST_DIR}/RimGridView.h +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionView.h +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimViewManipulator.h +${CMAKE_CURRENT_LIST_DIR}/RimCase.h +${CMAKE_CURRENT_LIST_DIR}/RimViewController.h +${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.h +${CMAKE_CURRENT_LIST_DIR}/RimViewLinkerCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersection.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionBox.h +${CMAKE_CURRENT_LIST_DIR}/RimMultiSnapshotDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.h +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.h +${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.h +${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.h +${CMAKE_CURRENT_LIST_DIR}/RimDialogData.h +${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.h + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCellFilter.cpp -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.cpp -${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp -${CEE_CURRENT_LIST_DIR}RimOilField.cpp -${CEE_CURRENT_LIST_DIR}RimProject.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseCase.cpp -${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseView.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.cpp -${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.cpp -${CEE_CURRENT_LIST_DIR}RimSimWellInView.cpp -${CEE_CURRENT_LIST_DIR}RimSimWellInViewCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellPath.cpp -${CEE_CURRENT_LIST_DIR}RimWellPathCollection.cpp -${CEE_CURRENT_LIST_DIR}RimScriptCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCalcScript.cpp -${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.cpp -${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.cpp -${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.cpp -${CEE_CURRENT_LIST_DIR}RimTensorResults.cpp -${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.cpp -${CEE_CURRENT_LIST_DIR}RimMimeData.cpp -${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp -${CEE_CURRENT_LIST_DIR}RimTools.cpp -${CEE_CURRENT_LIST_DIR}RimFaultInView.cpp -${CEE_CURRENT_LIST_DIR}RimFaultInViewCollection.cpp -${CEE_CURRENT_LIST_DIR}RimFormationNames.cpp -${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.cpp -${CEE_CURRENT_LIST_DIR}RimMockModelSettings.cpp -${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.cpp -${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.cpp -${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechModels.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechCase.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechView.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp -${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp -${CEE_CURRENT_LIST_DIR}Rim3dView.cpp -${CEE_CURRENT_LIST_DIR}RimGridView.cpp -${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.cpp -${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.cpp -${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp -${CEE_CURRENT_LIST_DIR}RimCase.cpp -${CEE_CURRENT_LIST_DIR}RimViewController.cpp -${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimRftPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPltPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogTrack.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogCurve.cpp -${CEE_CURRENT_LIST_DIR}RimViewLinker.cpp -${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFile.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogRftCurve.cpp -${CEE_CURRENT_LIST_DIR}RimIntersection.cpp -${CEE_CURRENT_LIST_DIR}RimIntersectionCollection.cpp -${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.cpp -${CEE_CURRENT_LIST_DIR}RimGridCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp -${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp -${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp -${CEE_CURRENT_LIST_DIR}RimPropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimNamedObject.cpp -${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.cpp -${CEE_CURRENT_LIST_DIR}RimGridTimeHistoryCurve.cpp -${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.cpp -${CEE_CURRENT_LIST_DIR}RimDialogData.cpp -${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimOilField.cpp +${CMAKE_CURRENT_LIST_DIR}/RimProject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIdenticalGridCaseGroup.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputProperty.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputPropertyCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCellColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalcScript.cpp +${CMAKE_CURRENT_LIST_DIR}/RimExportInputPropertySettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimBinaryExportSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dOverlayInfoConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTensorResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMimeData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMockModelSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTernaryLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseFaultColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNNC.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNncCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechModels.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechResultDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCellColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridView.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionView.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewManipulator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewController.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewLinkerCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionBox.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMultiSnapshotDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimDialogData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ) endif() @@ -223,4 +218,4 @@ ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake index 7ea1beaf38..65a8e691e2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake @@ -1,64 +1,59 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RimCompletionCellIntersectionCalc.h -${CEE_CURRENT_LIST_DIR}RimFishbonesCollection.h -${CEE_CURRENT_LIST_DIR}RimFishbonesMultipleSubs.h -${CEE_CURRENT_LIST_DIR}RimFishbonesPipeProperties.h -${CEE_CURRENT_LIST_DIR}RimFishboneWellPath.h -${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.h -${CEE_CURRENT_LIST_DIR}RimPerforationCollection.h -${CEE_CURRENT_LIST_DIR}RimPerforationInterval.h -${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RimCompletionCellIntersectionCalc.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesMultipleSubs.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesPipeProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPathCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPerforationCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPerforationInterval.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFracture.h - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.h - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimEllipseFractureTemplate.h + ${CMAKE_CURRENT_LIST_DIR}/RimFracture.h + ${CMAKE_CURRENT_LIST_DIR}/RimFractureContainment.h + ${CMAKE_CURRENT_LIST_DIR}/RimFractureExportSettings.h + ${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplate.h + ${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplateCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.h + ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.h + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimCompletionCellIntersectionCalc.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesCollection.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesMultipleSubs.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesPipeProperties.cpp -${CEE_CURRENT_LIST_DIR}RimFishboneWellPath.cpp -${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPerforationCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPerforationInterval.cpp -${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCompletionCellIntersectionCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesMultipleSubs.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesPipeProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPathCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPerforationCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPerforationInterval.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimEllipseFractureTemplate.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFracture.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFractureContainment.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFractureExportSettings.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplate.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplateCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.cpp ) endif() @@ -71,4 +66,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake index 028af8c003..fdbdaa46a8 100644 --- a/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake @@ -1,37 +1,32 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.h -${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RimTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.h -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.h -${CEE_CURRENT_LIST_DIR}RimFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RimWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RimWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RimDataSourceForRftPlt.h -${CEE_CURRENT_LIST_DIR}RimWellPlotTools.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowDiagSolution.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimTotalWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellFlowRateCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlotLegend.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp -${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RimTofAccumulatedPhaseFractionsPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.cpp -${CEE_CURRENT_LIST_DIR}RimFlowCharacteristicsPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellRftPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellPltPlot.cpp -${CEE_CURRENT_LIST_DIR}RimDataSourceForRftPlt.cpp -${CEE_CURRENT_LIST_DIR}RimWellPlotTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowDiagSolution.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTotalWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTofAccumulatedPhaseFractionsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellFlowRateCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlotLegend.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowCharacteristicsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPltPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -42,4 +37,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Flow" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Flow" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index 6e5f40478d..b4f64b79e0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -1,71 +1,66 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RimAsciiDataCurve.h -${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimSummaryCaseMainCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurve.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAutoName.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.h -${CEE_CURRENT_LIST_DIR}RimSummaryFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlot.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.h -${CEE_CURRENT_LIST_DIR}RimSummaryAxisProperties.h -${CEE_CURRENT_LIST_DIR}RimObservedData.h -${CEE_CURRENT_LIST_DIR}RimObservedDataCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryObservedDataFile.h -${CEE_CURRENT_LIST_DIR}RimObservedEclipseUserData.h -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCurveReader.h -${CEE_CURRENT_LIST_DIR}RimSummaryAddress.h -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.h -${CEE_CURRENT_LIST_DIR}RimCsvUserData.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.h +${CMAKE_CURRENT_LIST_DIR}/RimAsciiDataCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimFileSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedEclipseUserData.h +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCurveReader.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddress.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.h +${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimAsciiDataCurve.cpp -${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCaseMainCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurve.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAutoName.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlot.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryAxisProperties.cpp -${CEE_CURRENT_LIST_DIR}RimObservedData.cpp -${CEE_CURRENT_LIST_DIR}RimObservedDataCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryObservedDataFile.cpp -${CEE_CURRENT_LIST_DIR}RimObservedEclipseUserData.cpp -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCurveReader.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryAddress.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.cpp -${CEE_CURRENT_LIST_DIR}RimCsvUserData.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.cpp +${CMAKE_CURRENT_LIST_DIR}/RimAsciiDataCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFileSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedEclipseUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCurveReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp ) list(APPEND CODE_HEADER_FILES @@ -76,4 +71,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 7e50d6080c..8c8d52d758 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -1,144 +1,139 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.h -${CEE_CURRENT_LIST_DIR}RigCell.h -${CEE_CURRENT_LIST_DIR}RigEclipseCaseData.h -${CEE_CURRENT_LIST_DIR}RigGridBase.h -${CEE_CURRENT_LIST_DIR}RigGridManager.h -${CEE_CURRENT_LIST_DIR}RigResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.h -${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h -${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigResultModifier.h -${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.h -${CEE_CURRENT_LIST_DIR}RigFormationNames.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResults.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagInterfaceTools.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.h -${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.h -${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.h -${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.h -${CEE_CURRENT_LIST_DIR}RigLocalGrid.h -${CEE_CURRENT_LIST_DIR}RigMainGrid.h -${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h -${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h -${CEE_CURRENT_LIST_DIR}RigSimWellData.h -${CEE_CURRENT_LIST_DIR}RigWellPath.h -${CEE_CURRENT_LIST_DIR}RigFault.h -${CEE_CURRENT_LIST_DIR}RigNNCData.h -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl -${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h -${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h -${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h -${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h -${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h -${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h -${CEE_CURRENT_LIST_DIR}RigWellLogExtractionTools.h -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCurveDataTools.h -${CEE_CURRENT_LIST_DIR}RigObservedData.h -${CEE_CURRENT_LIST_DIR}RigLasFileExporter.h -${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.h -${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.h -${CEE_CURRENT_LIST_DIR}RigTesselatorTools.h -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.h -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.h -${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.h -${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h -${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h -${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h -${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo.h +${CMAKE_CURRENT_LIST_DIR}/RigCell.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseCaseData.h +${CMAKE_CURRENT_LIST_DIR}/RigGridBase.h +${CMAKE_CURRENT_LIST_DIR}/RigGridManager.h +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessorFactory.h +${CMAKE_CURRENT_LIST_DIR}/RigAllGridCellsResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellsResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCellEdgeResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCombTransResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigResultModifier.h +${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.h +${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagSolverInterface.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagInterfaceTools.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagVisibleCellsStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigAccWellFlowCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.h +${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.h +${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.h +${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.h +${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.h +${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RigFault.h +${CMAKE_CURRENT_LIST_DIR}/RigNNCData.h +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.inl +${CMAKE_CURRENT_LIST_DIR}/RigPipeInCellEvaluator.h +${CMAKE_CURRENT_LIST_DIR}/RigTernaryResultAccessor2d.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeVisibleCellsStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseMultiPropertyStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogCurveData.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCurveDataTools.h +${CMAKE_CURRENT_LIST_DIR}/RigObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RigLasFileExporter.h +${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCoordsAndMD.h +${CMAKE_CURRENT_LIST_DIR}/RigFishbonesGeometry.h +${CMAKE_CURRENT_LIST_DIR}/RigTesselatorTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultInfo.h +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityEquations.h +${CMAKE_CURRENT_LIST_DIR}/RigNumberOfFloodedPoreVolumesCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigWeightedMeanCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryCurveMerger.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.h ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.h - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.h - ${CEE_CURRENT_LIST_DIR}RigFractureCell.h + ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.h + ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h + ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h ) endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp -${CEE_CURRENT_LIST_DIR}RigCell.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseCaseData.cpp -${CEE_CURRENT_LIST_DIR}RigGridBase.cpp -${CEE_CURRENT_LIST_DIR}RigGridManager.cpp -${CEE_CURRENT_LIST_DIR}RigResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.cpp -${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.cpp -${CEE_CURRENT_LIST_DIR}RigFormationNames.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResults.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.cpp -${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp -${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp -${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp -${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp -${CEE_CURRENT_LIST_DIR}RigSimWellData.cpp -${CEE_CURRENT_LIST_DIR}RigWellPath.cpp -${CEE_CURRENT_LIST_DIR}RigFault.cpp -${CEE_CURRENT_LIST_DIR}RigNNCData.cpp -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCurveDataTools.cpp -${CEE_CURRENT_LIST_DIR}RigObservedData.cpp -${CEE_CURRENT_LIST_DIR}RigLasFileExporter.cpp -${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.cpp -${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.cpp -${CEE_CURRENT_LIST_DIR}RigTesselatorTools.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.cpp -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.cpp -${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp -${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseCaseData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigGridBase.cpp +${CMAKE_CURRENT_LIST_DIR}/RigGridManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessorFactory.cpp +${CMAKE_CURRENT_LIST_DIR}/RigAllGridCellsResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellsResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellEdgeResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCombTransResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagSolverInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagVisibleCellsStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigAccWellFlowCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.cpp +${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.cpp +${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFault.cpp +${CMAKE_CURRENT_LIST_DIR}/RigNNCData.cpp +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTernaryResultAccessor2d.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeVisibleCellsStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseMultiPropertyStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogCurveData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCurveDataTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigLasFileExporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCoordsAndMD.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFishbonesGeometry.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTesselatorTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityEquations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigNumberOfFloodedPoreVolumesCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWeightedMeanCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryCurveMerger.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureCell.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp ) endif() @@ -151,4 +146,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake index d54e923649..8de6209ac7 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake @@ -1,27 +1,22 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapperTools.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.h - ${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.h - ${CEE_CURRENT_LIST_DIR}RigWellLogFile.h - ${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.h + ${CMAKE_CURRENT_LIST_DIR}/RigGeoMechWellLogExtractor.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.h + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.h + ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.h ) set (SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapperTools.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.cpp - ${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp - ${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigGeoMechWellLogExtractor.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,4 +27,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ReservoirDataModel2" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_filesNotToUnitTest.cmake ) +source_group( "ReservoirDataModel2" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_filesNotToUnitTest.cmake ) diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index cceb7d1db9..6b03e099e4 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -1,10 +1,5 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - -CONFIGURE_FILE( ${CEE_CURRENT_LIST_DIR}RiaTestDataDirectory.h.cmake +CONFIGURE_FILE( ${CMAKE_CURRENT_LIST_DIR}/RiaTestDataDirectory.h.cmake ${CMAKE_BINARY_DIR}/Generated/RiaTestDataDirectory.h ) @@ -12,41 +7,41 @@ set (SOURCE_GROUP_HEADER_FILES ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}cvfGeometryTools-Test.cpp -${CEE_CURRENT_LIST_DIR}Ert-Test.cpp -${CEE_CURRENT_LIST_DIR}RifcCommandCore-Test.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput-Test.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary-Test.cpp -${CEE_CURRENT_LIST_DIR}RigActiveCellInfo-Test.cpp -${CEE_CURRENT_LIST_DIR}RigReservoir-Test.cpp -${CEE_CURRENT_LIST_DIR}RigStatisticsMath-Test.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurveImpl-Test.cpp -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator-Test.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper-Test.cpp -${CEE_CURRENT_LIST_DIR}ScalarMapper-Test.cpp -${CEE_CURRENT_LIST_DIR}WellPathAsciiFileReader-Test.cpp -${CEE_CURRENT_LIST_DIR}opm-flowdiagnostics-Test.cpp -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator-Test.cpp -${CEE_CURRENT_LIST_DIR}HDF5FileReader-Test.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}ObservedDataParser-Test.cpp -${CEE_CURRENT_LIST_DIR}EclipseRftReader-Test.cpp -${CEE_CURRENT_LIST_DIR}RicExpressionParser-Test.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap-Test.cpp -${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp -${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp -${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RifElementPropertyTableReader-Test.cpp -${CEE_CURRENT_LIST_DIR}RimRelocatePath-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/Ert-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifcCommandCore-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigReservoir-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigStatisticsMath-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurveImpl-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ScalarMapper-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/WellPathAsciiFileReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/opm-flowdiagnostics-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/HDF5FileReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ObservedDataParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/EclipseRftReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExpressionParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/FixedWidthDataParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeCurveHistoryMerger-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ListKeywordsForObjectsAndFields-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp ) endif() @@ -58,4 +53,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "UnitTests" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "UnitTests" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 5e9bd6749a..b2ac2b66b2 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -1,140 +1,135 @@ -# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly -if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") - set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) -endif() - set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RiuCadNavigation.h -${CEE_CURRENT_LIST_DIR}RiuCursors.h -${CEE_CURRENT_LIST_DIR}RiuDragDrop.h -${CEE_CURRENT_LIST_DIR}RiuFemResultTextBuilder.h -${CEE_CURRENT_LIST_DIR}RiuGeoQuestNavigation.h -${CEE_CURRENT_LIST_DIR}RiuInterfaceToViewWindow.h -${CEE_CURRENT_LIST_DIR}RiuLineSegmentQwtPlotCurve.h -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.h -${CEE_CURRENT_LIST_DIR}RiuMdiSubWindow.h -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.h -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h -${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.h -${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.h -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h -${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotZoomer.h -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.h -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.h -${CEE_CURRENT_LIST_DIR}RiuRmsNavigation.h -${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.h -${CEE_CURRENT_LIST_DIR}RiuSelectionManager.h -${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.h -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTextDialog.h -${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.h -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.h -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h -${CEE_CURRENT_LIST_DIR}RiuViewer.h -${CEE_CURRENT_LIST_DIR}RiuViewerToViewInterface.h -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RiuPlotAnnotationTool.h -${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.h -${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.h -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h -${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.h -${CEE_CURRENT_LIST_DIR}RiuContextMenuLauncher.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefinitionKeywords.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelection.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionDialog.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionEditor.h -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap.h -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.h -${CEE_CURRENT_LIST_DIR}RiuTools.h -${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuCadNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuCursors.h +${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.h +${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h +${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h +${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.h +${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultTextBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.h +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.h +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.h +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h +${CMAKE_CURRENT_LIST_DIR}/RiuGeoMechXfTensorResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RiuFemTimeHistoryResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotObjectPicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuContextMenuLauncher.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefinitionKeywords.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelection.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionEditor.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap.h +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuTools.h +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiuCadNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuCursors.cpp -${CEE_CURRENT_LIST_DIR}RiuDragDrop.cpp -${CEE_CURRENT_LIST_DIR}RiuFemResultTextBuilder.cpp -${CEE_CURRENT_LIST_DIR}RiuGeoQuestNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuInterfaceToViewWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuLineSegmentQwtPlotCurve.cpp -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMainWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.cpp -${CEE_CURRENT_LIST_DIR}RiuMdiSubWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.cpp -${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.cpp -${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.cpp -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.cpp -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.cpp -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.cpp -${CEE_CURRENT_LIST_DIR}RiuRmsNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.cpp -${CEE_CURRENT_LIST_DIR}RiuSelectionManager.cpp -${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuTextDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.cpp -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.cpp -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.cpp -${CEE_CURRENT_LIST_DIR}RiuViewer.cpp -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.cpp -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.cpp -${CEE_CURRENT_LIST_DIR}RiuPlotAnnotationTool.cpp -${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.cpp -${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.cpp -${CEE_CURRENT_LIST_DIR}RiuContextMenuLauncher.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelection.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionEditor.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap.cpp -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.cpp -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.cpp -${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuTools.cpp -${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCadNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCursors.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultTextBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGeoMechXfTensorResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFemTimeHistoryResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotObjectPicker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuContextMenuLauncher.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelection.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionEditor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.cpp ) list(APPEND CODE_HEADER_FILES @@ -146,41 +141,41 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.h -${CEE_CURRENT_LIST_DIR}RiuMainWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTextDialog.h -${CEE_CURRENT_LIST_DIR}RiuViewer.h -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.h -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.h -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.h -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.h -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuMohrsCirclePlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h ) list(APPEND QT_UI_FILES -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.ui +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.ui ) -source_group( "UserInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "UserInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) From 7b5963d75c13d77df9a06895362992dd6f404eaa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 28 Feb 2018 10:54:53 +0100 Subject: [PATCH 0376/1027] #2536 Build System : Add list of internal ResInsight libraries --- ApplicationCode/CMakeLists.txt | 26 ++++++++++++------- .../GeoMech/GeoMechDataModel/CMakeLists.txt | 8 +++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index dc43bfff7b..69d04055b8 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -151,6 +151,11 @@ list( APPEND CPP_SOURCES add_subdirectory(WellPathImportSsihub) add_subdirectory(ResultStatisticsCache) +set( RI_LIBRARIES + WellPathImportSsihub + ResultStatisticsCache +) + # # Odb api # @@ -164,6 +169,17 @@ endif() add_subdirectory(GeoMech/GeoMechDataModel) +if (RESINSIGHT_USE_ODB_API) + list( APPEND RI_LIBRARIES + RifOdbReader + ) +else() + list( APPEND RI_LIBRARIES + RigGeoMechDataModel + ) +endif() + + # # HDF5 # @@ -288,10 +304,7 @@ endif () set( LINK_LIBRARIES ${OPM_LIBRARIES} - WellPathImportSsihub - - ResultStatisticsCache - RigGeoMechDataModel + ${RI_LIBRARIES} ${APP_FWK_LIBRARIES} ${VIZ_FWK_LIBRARIES} @@ -309,11 +322,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") ) endif() -# Add the odb reader if we are compiling with odb support -IF (${RESINSIGHT_USE_ODB_API}) - set ( LINK_LIBRARIES ${LINK_LIBRARIES} RifOdbReader) -ENDIF() - target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES}) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt index 57217c686e..ed56edb9f3 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.8.12) project (RigGeoMechDataModel) - add_library( ${PROJECT_NAME} RigFemPart.h RigFemPart.cpp @@ -36,7 +35,7 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -target_link_libraries( ${PROJECT_NAME} +set( LINK_LIBRARIES LibCore cafPdmCvf @@ -45,7 +44,10 @@ target_link_libraries( ${PROJECT_NAME} CommonCode ResultStatisticsCache - RifOdbReader +) + +target_link_libraries( ${PROJECT_NAME} + ${LINK_LIBRARIES} ) source_group("" FILES ${PROJECT_FILES}) From 6a337354799463de33e387df36c7edf335f56ccf Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 28 Feb 2018 15:41:55 +0100 Subject: [PATCH 0377/1027] #2537 Mohr circle: Support multi selection of cells --- .../UserInterface/RiuMohrsCirclePlot.cpp | 481 +++++++++--------- .../UserInterface/RiuMohrsCirclePlot.h | 68 +-- .../RiuSelectionChangedHandler.cpp | 4 + 3 files changed, 284 insertions(+), 269 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 28fa92dbd2..8400cc13b4 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -18,6 +18,8 @@ #include "RiuMohrsCirclePlot.h" +#include "RiaColorTables.h" + #include "RiuSelectionManager.h" #include "RiuSummaryQwtPlot.h" @@ -38,6 +40,7 @@ #include #include +#include "qwt_legend.h" #include "qwt_plot_curve.h" #include "qwt_plot_layout.h" #include "qwt_plot_marker.h" @@ -61,48 +64,39 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) : QwtPlot(parent) { - setDefaults(); -} + RiuSummaryQwtPlot::setCommonPlotBehaviour(this); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuMohrsCirclePlot::~RiuMohrsCirclePlot() -{ - deleteCircles(); + m_rescaler = new QwtPlotRescaler(this->canvas()); + m_rescaler->setReferenceAxis(QwtPlot::yLeft); + m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0); + m_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed); + m_rescaler->setEnabled(true); - delete m_rescaler; -} + enableAxis(QwtPlot::xBottom, true); + enableAxis(QwtPlot::yLeft, true); + enableAxis(QwtPlot::xTop, false); + enableAxis(QwtPlot::yRight, false); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3) -{ - if (isValidPrincipals(p1, p2, p3)) - { - m_principal1 = p1; - m_principal2 = p2; - m_principal3 = p3; - } + setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress"); + setAxisTitle(QwtPlot::yLeft, "Shear Stress"); + + // The legend will be deleted in the destructor of the plot or when + // another legend is inserted. + QwtLegend* legend = new QwtLegend(this); + this->insertLegend(legend, BottomLegend); + + // this->setTitle(QString("SE")); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double p3) +RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { - if (!isValidPrincipals(p1, p2, p3)) - { - clearPlot(); - return; - } - - setPrincipals(p1, p2, p3); + deleteCircles(); + deleteEnvelopes(); - redrawEnvelope(); - redrawCircles(); - addInfoLabel(); + delete m_rescaler; } //-------------------------------------------------------------------------------------------------- @@ -117,16 +111,17 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select this->clearPlot(); return; } - + RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; CVF_ASSERT(geoMechView); if (this->isVisible()) { - const size_t gridIndex = geoMechSelectionItem->m_gridIndex; - const size_t cellIndex = geoMechSelectionItem->m_cellIndex; - - queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex); + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t cellIndex = geoMechSelectionItem->m_cellIndex; + const cvf::Color3f color = geoMechSelectionItem->m_color; + + queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); } else { @@ -139,9 +134,10 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::clearPlot() { + m_mohrsCiclesInfos.clear(); + deleteCircles(); - deleteEnvelope(); - deleteInfoLabel(); + deleteEnvelopes(); this->replot(); } @@ -165,27 +161,55 @@ QSize RiuMohrsCirclePlot::minimumSizeHint() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::redrawCircles() +void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo) { - deleteCircles(); - createMohrCircles(); + const cvf::Vec3f& principals = mohrsCirclesInfo.principals; + + std::array, 3> mohrsCircles; + + mohrsCircles[0].first = (principals[0] - principals[2]) / 2.0; + mohrsCircles[0].second = (principals[0] + principals[2]) / 2.0; + + mohrsCircles[1].first = (principals[1] - principals[2]) / 2.0; + mohrsCircles[1].second = (principals[1] + principals[2]) / 2.0; + + mohrsCircles[2].first = (principals[0] - principals[1]) / 2.0; + mohrsCircles[2].second = (principals[0] + principals[1]) / 2.0; - for (const MohrCircle& circle : m_mohrCircles) + for (size_t i = 0; i < 3; i++) { QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle"); QPainterPath* circleDrawing = new QPainterPath(); - QPointF center(circle.centerX, 0); - circleDrawing->addEllipse(center, circle.radius, circle.radius); + QPointF center(mohrsCircles[i].second, 0); + circleDrawing->addEllipse(center, mohrsCircles[i].first, mohrsCircles[i].first); + plotItem->setPen(QColor(mohrsCirclesInfo.color.r(), mohrsCirclesInfo.color.g(), mohrsCirclesInfo.color.b())); plotItem->setShape(*circleDrawing); plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + if (i == 0) + { + QString textBuilder; + textBuilder.append(QString("FOS: %1,").arg(QString::number(mohrsCirclesInfo.factorOfSafety, 'f', 2))); + + textBuilder.append(QString("Element Id: %1, ijk[%2, %3, %4],") + .arg(mohrsCirclesInfo.elmIndex) + .arg(mohrsCirclesInfo.i) + .arg(mohrsCirclesInfo.j) + .arg(mohrsCirclesInfo.k)); + + textBuilder.append(QString("σ1: %1,").arg(principals[0])); + textBuilder.append(QString("σ2: %1,").arg(principals[1])); + textBuilder.append(QString("σ3: %1").arg(principals[2])); + plotItem->setTitle(textBuilder); + plotItem->setItemAttribute(QwtPlotItem::Legend); + } + plotItem->attach(this); m_circlePlotItems.push_back(plotItem); } - - replotAndScaleAxis(); } //-------------------------------------------------------------------------------------------------- @@ -201,289 +225,272 @@ void RiuMohrsCirclePlot::deleteCircles() m_circlePlotItems.clear(); - if (m_transparentCurve) + for (size_t i = 0; i < m_transparentCurves.size(); i++) { - m_transparentCurve->detach(); - delete m_transparentCurve; - m_transparentCurve = nullptr; + m_transparentCurves[i]->detach(); + delete m_transparentCurves[i]; } + + m_transparentCurves.clear(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::redrawEnvelope() +void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechView* view) { - deleteEnvelope(); + if (!view) return; - if (m_cohesion == HUGE_VAL || m_frictionAngle == HUGE_VAL) + double cohesion = view->geoMechCase()->cohesion(); + double frictionAngle = view->geoMechCase()->frictionAngleDeg(); + + if (cohesion == HUGE_VAL || frictionAngle == HUGE_VAL) { - this->replot(); return; } - QwtPlotCurve* qwtCurve = new QwtPlotCurve(); - std::vector xVals; std::vector yVals; - - double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(m_frictionAngle))); + + double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle))); if (tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL) { - this->replot(); - delete qwtCurve; return; } - double x = m_cohesion/tanFrictionAngle; - if (m_principal1 < 0) + double x = cohesion / tanFrictionAngle; + if (principals[0] < 0) { xVals.push_back(x); - xVals.push_back(m_principal3*1.1); + xVals.push_back(principals[2] * 1.1); } else { xVals.push_back(-x); - xVals.push_back(m_principal1*1.1); + xVals.push_back(principals[0] * 1.1); } yVals.push_back(0); - yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.05) * tanFrictionAngle); + yVals.push_back((x + cvf::Math::abs(principals[0]) * 1.05) * tanFrictionAngle); + + // If envelope for the view already exists, check if a "larger" envelope should be created + if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end()) + { + if (yVals.back() <= m_envolopePlotItems[view]->maxYValue()) + { + return; + } + else + { + m_envolopePlotItems[view]->detach(); + delete m_envolopePlotItems[view]; + m_envolopePlotItems.erase(view); + } + } + + QwtPlotCurve* qwtCurve = new QwtPlotCurve(); qwtCurve->setSamples(xVals.data(), yVals.data(), 2); qwtCurve->setStyle(QwtPlotCurve::Lines); qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); - const QPen curvePen(QColor(236, 118, 0)); + const QPen curvePen(envelopeColor(view)); qwtCurve->setPen(curvePen); + qwtCurve->setTitle(QString("Envelope for %1, (S0: %2, Φ: %3)") + .arg(view->geoMechCase()->caseUserDescription) + .arg(cohesion) + .arg(frictionAngle)); + qwtCurve->attach(this); - m_envolopePlotItem = qwtCurve; - - replotAndScaleAxis(); + m_envolopePlotItems[view] = qwtCurve; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::deleteEnvelope() +void RiuMohrsCirclePlot::deleteEnvelopes() { - if (m_envolopePlotItem) + for (const std::pair& envelope : m_envolopePlotItems) { - m_envolopePlotItem->detach(); - delete m_envolopePlotItem; - m_envolopePlotItem = nullptr; + envelope.second->detach(); + delete envelope.second; } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addInfoLabel() -{ - deleteInfoLabel(); - - QString textBuilder; - textBuilder.append(QString("Friction Angle: %1
").arg(m_frictionAngle)); - textBuilder.append(QString("Cohesion: %1

").arg(m_cohesion)); - - textBuilder.append(QString("Factor of Safety: %1
").arg(QString::number(m_factorOfSafety, 'f', 2))); - textBuilder.append(QString("σ1: %1
").arg(m_principal1)); - textBuilder.append(QString("σ2: %1
").arg(m_principal2)); - textBuilder.append(QString("σ3: %1
").arg(m_principal3)); - - QwtText text = textBuilder; - - text.setRenderFlags(Qt::AlignLeft | Qt::AlignTop); - - m_infoTextItem = new QwtPlotTextLabel(); - m_infoTextItem->setText(text); - m_infoTextItem->attach(this); - - this->replot(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::deleteInfoLabel() -{ - if (m_infoTextItem) - { - m_infoTextItem->detach(); - delete m_infoTextItem; - m_infoTextItem = nullptr; - } + m_envolopePlotItems.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex) +void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, + size_t gridIndex, + size_t elmIndex, + const cvf::Color3ub& color) { CVF_ASSERT(geoMechView); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); - int frameIdx = geoMechView->currentTimeStep(); + int frameIdx = geoMechView->currentTimeStep(); RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", ""); // TODO: All tensors are calculated every time this function is called. FIX std::vector vertexTensors = resultCollection->tensors(address, 0, frameIdx); if (vertexTensors.empty()) { - clearPlot(); return; } - setCohesion(geoMechView->geoMechCase()->cohesion()); - setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); - size_t i, j, k; - femPart->structGrid()->ijkFromCellIndex(cellIndex, &i, &j, &k); - - QString title = QString("SE, Element Id[%1], ijk[%2,%3,%4]").arg(femPart->elmId(cellIndex)).arg(i).arg(j).arg(k); - this->setTitle(title); - - caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)]; + // Calculate average tensor in element + caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, 0)]; for (int i = 1; i < 8; i++) { - tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, i)]; + tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, i)]; } - caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0); - cvf::Vec3f principalDirs[3]; - cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs); + cvf::Vec3f dirs[3]; + cvf::Vec3f principals = elmTensor.calculatePrincipals(dirs); + + if (!isValidPrincipals(principals)) + { + return; + } - setFactorOfSafety(calculateFOS(elmTensor)); + double cohesion = geoMechView->geoMechCase()->cohesion(); + double frictionAngle = geoMechView->geoMechCase()->frictionAngleDeg(); - setPrincipalsAndRedrawPlot(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]); + size_t i, j, k; + femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); + + MohrsCirclesInfo mohrsCircle; + mohrsCircle.color = color; + mohrsCircle.elmIndex = elmIndex; + mohrsCircle.factorOfSafety = calculateFOS(principals, cohesion, frictionAngle); + mohrsCircle.principals = principals; + mohrsCircle.i = i; + mohrsCircle.j = j; + mohrsCircle.k = k; + + addMohrsCirclesInfo(mohrsCircle, geoMechView); + replotAndScaleAxis(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setDefaults() +void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo, RimGeoMechView* view) { - RiuSummaryQwtPlot::setCommonPlotBehaviour(this); + m_mohrsCiclesInfos.push_back(mohrsCircleInfo); - m_rescaler = new QwtPlotRescaler(this->canvas()); - m_rescaler->setReferenceAxis(QwtPlot::yLeft); - m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0); - m_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed); - m_rescaler->setEnabled(true); + addEnvelope(mohrsCircleInfo.principals, view); + addMohrCircles(mohrsCircleInfo); +} - enableAxis(QwtPlot::xBottom, true); - enableAxis(QwtPlot::yLeft, true); - enableAxis(QwtPlot::xTop, false); - enableAxis(QwtPlot::yRight, false); +//-------------------------------------------------------------------------------------------------- +/// Add a transparent curve to make tooltip available on principals crossing the x-axis +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateTransparentCurvesOnPrincipals() +{ + for (size_t i = 0; i < m_transparentCurves.size(); i++) + { + m_transparentCurves[i]->detach(); + delete m_transparentCurves[i]; + } - setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress"); - setAxisTitle(QwtPlot::yLeft, "Shear Stress"); + m_transparentCurves.clear(); + + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + QwtPlotCurve* transparentCurve = new QwtPlotCurve(); - m_envolopePlotItem = nullptr; - m_transparentCurve = nullptr; + QVector qVectorPoints; - m_infoTextItem = nullptr; + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[0], 0)); + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[1], 0)); + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[2], 0)); - m_cohesion = HUGE_VAL; - m_frictionAngle = HUGE_VAL; + transparentCurve->setSamples(qVectorPoints); + transparentCurve->setYAxis(QwtPlot::yLeft); + transparentCurve->setStyle(QwtPlotCurve::NoCurve); + transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute); - m_factorOfSafety = HUGE_VAL; + transparentCurve->attach(this); + m_transparentCurves.push_back(transparentCurve); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::createMohrCircles() +double RiuMohrsCirclePlot::largestCircleRadiusInPlot() const { - m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2.0; - m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2.0; - - m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2.0; - m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2.0; - - m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2.0; - m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2.0; -} + double currentLargestDiameter = -HUGE_VAL; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setFrictionAngle(double frictionAngle) -{ - m_frictionAngle = frictionAngle; -} + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + if (mohrCircleInfo.principals[0] > currentLargestDiameter) + { + currentLargestDiameter = mohrCircleInfo.principals[0] - mohrCircleInfo.principals[2]; + } + } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setCohesion(double cohesion) -{ - m_cohesion = cohesion; + return currentLargestDiameter / 2; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::setFactorOfSafety(double fos) +double RiuMohrsCirclePlot::smallestPrincipal() const { - m_factorOfSafety = fos; -} + double currentSmallestPrincipal = HUGE_VAL; -//-------------------------------------------------------------------------------------------------- -/// Add a transparent curve to make tooltip available on principals crossing the x-axis -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::updateTransparentCurveOnPrincipals() -{ - if (m_transparentCurve) + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) { - m_transparentCurve->detach(); - delete m_transparentCurve; + if (mohrCircleInfo.principals[2] < currentSmallestPrincipal) + { + currentSmallestPrincipal = mohrCircleInfo.principals[2]; + } } - m_transparentCurve = new QwtPlotCurve(); - - QVector qVectorPoints; - - qVectorPoints.push_back(QPointF(m_principal1, 0)); - qVectorPoints.push_back(QPointF(m_principal2, 0)); - qVectorPoints.push_back(QPointF(m_principal3, 0)); - - m_transparentCurve->setSamples(qVectorPoints); - m_transparentCurve->setYAxis(QwtPlot::yLeft); - m_transparentCurve->setStyle(QwtPlotCurve::NoCurve); - m_transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute); - - m_transparentCurve->attach(this); + return currentSmallestPrincipal; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::replotAndScaleAxis() { double maxYEnvelope = -HUGE_VAL; - if (m_envolopePlotItem) + + for (const std::pair& envelope : m_envolopePlotItems) { - maxYEnvelope = m_envolopePlotItem->maxYValue(); + double tempMax = envelope.second->maxYValue(); + if (tempMax > maxYEnvelope) + { + maxYEnvelope = tempMax; + } } - - double yHeight = std::max(maxYEnvelope, 0.6 * (m_principal1 - m_principal3)); - + + double yHeight = std::max(maxYEnvelope, 1.2 * largestCircleRadiusInPlot()); + this->setAxisScale(QwtPlot::yLeft, 0, yHeight); - double minXEvelope = 0; + double minXEvelope = HUGE_VAL; - if (m_envolopePlotItem) + for (const std::pair& envelope : m_envolopePlotItems) { - minXEvelope = m_envolopePlotItem->minXValue(); + double tempMin = envelope.second->minXValue(); + if (tempMin < minXEvelope) + { + minXEvelope = tempMin; + } } double xMin; @@ -493,13 +500,13 @@ void RiuMohrsCirclePlot::replotAndScaleAxis() } else { - xMin = 1.1 * m_principal3; + xMin = 1.1 * smallestPrincipal(); } // When using the rescaler, xMax is ignored this->setAxisScale(QwtPlot::xBottom, xMin, 0); - updateTransparentCurveOnPrincipals(); + updateTransparentCurvesOnPrincipals(); this->replot(); m_rescaler->rescale(); @@ -507,23 +514,27 @@ void RiuMohrsCirclePlot::replotAndScaleAxis() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -bool RiuMohrsCirclePlot::isValidPrincipals(double p1, double p2, double p3) +bool RiuMohrsCirclePlot::isValidPrincipals(const cvf::Vec3f& principals) { - //Inf + float p1 = principals[0]; + float p2 = principals[1]; + float p3 = principals[2]; + + // Inf if (p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL) { return false; } - - //Nan + + // Nan if ((p1 != p1) || (p2 != p2) || p3 != p3) { return false; } - //Principal rules: + // Principal rules: if ((p1 < p2) || (p2 < p3)) { return false; @@ -533,21 +544,35 @@ bool RiuMohrsCirclePlot::isValidPrincipals(double p1, double p2, double p3) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -float RiuMohrsCirclePlot::calculateFOS(const caf::Ten3f& tensor) +float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion) { - cvf::Vec3f dirs[3]; - cvf::Vec3f principals = tensor.calculatePrincipals(dirs); - float se1 = principals[0]; float se3 = principals[2]; - float tanFricAng = tan(cvf::Math::toRadians(m_frictionAngle)); - float cohPrTanFricAngle = (float)(m_cohesion / tanFricAng); + float tanFricAng = tan(cvf::Math::toRadians(frictionAngle)); + float cohPrTanFricAngle = (float)(cohesion / tanFricAng); float pi_4 = 0.785398163397448309616f; - float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); + float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); return tanFricAng / tan(rho); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view) +{ + if (m_envolopeColors.find(view) == m_envolopeColors.end()) + { + cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(m_envolopePlotItems.size()); + + QColor color(cvfColor.r(), cvfColor.g(), cvfColor.b()); + + m_envolopeColors[view] = color; + } + + return m_envolopeColors[view]; +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 10c6c758a8..fd72c8872d 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -20,13 +20,15 @@ #include "qwt_plot.h" #include "qwt_plot_item.h" +#include "qwt_plot_curve.h" #include "cafTensor3.h" +#include "cvfColor3.h" + #include class QWidget; -class QwtPlotCurve; class QwtPlotRescaler; class QwtPlotTextLabel; class QwtRoundScaleDraw; @@ -46,69 +48,53 @@ class RiuMohrsCirclePlot : public QwtPlot RiuMohrsCirclePlot(QWidget* parent); ~RiuMohrsCirclePlot(); - void setPrincipals(double p1, double p2, double p3); - void setPrincipalsAndRedrawPlot(double p1, double p2, double p3); - void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); void clearPlot(); -private: - struct MohrCircle +public: + struct MohrsCirclesInfo { - MohrCircle(double radius, double centerX) - : radius(radius), centerX(centerX) {} - MohrCircle() {}; - double radius; - double centerX; + cvf::Vec3f principals; + size_t elmIndex; + size_t i, j, k; + double factorOfSafety; + cvf::Color3ub color; }; private: virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; - void redrawCircles(); + void addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo); void deleteCircles(); - void redrawEnvelope(); - void deleteEnvelope(); - - void addInfoLabel(); - void deleteInfoLabel(); + void addEnvelope(const cvf::Vec3f& principals, RimGeoMechView* view); + void deleteEnvelopes(); - void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex); + void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); - void setDefaults(); - void createMohrCircles(); + void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo, RimGeoMechView* view); - void setFrictionAngle(double frictionAngle); - void setCohesion(double cohesion); - void setFactorOfSafety(double fos); - - void updateTransparentCurveOnPrincipals(); + void updateTransparentCurvesOnPrincipals(); + double largestCircleRadiusInPlot() const; + double smallestPrincipal() const; void replotAndScaleAxis(); - static bool isValidPrincipals(double p1, double p2, double p3); + static bool isValidPrincipals(const cvf::Vec3f& principals); - float calculateFOS(const caf::Ten3f& tensor); + static float calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion); + QColor envelopeColor(RimGeoMechView* view); + private: - double m_principal1; - double m_principal2; - double m_principal3; - - std::array m_mohrCircles; - - std::vector m_circlePlotItems; + std::vector m_circlePlotItems; + std::vector m_transparentCurves; - QwtPlotCurve* m_envolopePlotItem; - QwtPlotCurve* m_transparentCurve; - - double m_frictionAngle; - double m_cohesion; - double m_factorOfSafety; + std::map m_envolopePlotItems; + std::map m_envolopeColors; - QwtPlotTextLabel* m_infoTextItem; + std::vector m_mohrsCiclesInfos; QwtPlotRescaler* m_rescaler; }; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 724dd0255f..e17fff9a9f 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -90,6 +90,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(nullptr); + RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(nullptr); + updateResultInfo(nullptr); scheduleUpdateForAllVisibleViews(); @@ -122,6 +124,8 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i { RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); + RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(nullptr); + handleItemAppended(item); } From 50870856355d8c825f1aa0e8cddccbc8a79609e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 28 Feb 2018 17:18:48 +0100 Subject: [PATCH 0378/1027] #2482 Add wellhead pipe piece to simulation wells. --- .../Intersections/RivIntersectionPartMgr.cpp | 7 ++++-- .../RivWellConnectionsPartMgr.cpp | 4 ++-- .../ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- .../ProjectDataModel/RimIntersection.cpp | 13 ++++++++++ .../ProjectDataModel/RimSimWellInView.cpp | 24 +++++++++++++++---- .../ProjectDataModel/RimSimWellInView.h | 2 +- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index ca794d6b73..5404b62d0a 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -767,7 +767,7 @@ cvf::ref createStdLinePart(cvf::DrawableGeo* geometry, //-------------------------------------------------------------------------------------------------- void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) { - if (m_rimCrossSection.isNull()) return; + if (m_rimCrossSection.isNull() || m_crossSectionGenerator.isNull()) return; // Get information on how to draw the pipe @@ -775,6 +775,7 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod double pipeRadius = 1; int pipeCrossSectionVxCount = 6; cvf::Color3f wellPipeColor = cvf::Color3f::GRAY; + double characteristicCellSize = 0; if ( m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL ) { @@ -790,7 +791,7 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod wellPipeColor = simWellInView->wellPipeColor(); createSourceInfoFunc = [&](size_t brIdx) { return new RivSimWellPipeSourceInfo(simWellInView, brIdx); }; - + characteristicCellSize = eclView->eclipseCase()->characteristicCellSize(); } else if (m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH) { @@ -854,6 +855,8 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod (*cvfCoords)[cIdx].transformPoint(scaleTransform->worldTransform()); } + (*cvfCoords)[0].z() += characteristicCellSize; + pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); auto surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); auto centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp index 940fd1beb9..ee6c762a2b 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp @@ -96,7 +96,7 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasi characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); - m_rimWell->wellHeadTopBottomPosition(frameIndex, &wellHeadTop, &wellHeadBottom); + m_rimWell->wellHeadTopBottomPosition(static_cast(frameIndex), &wellHeadTop, &wellHeadBottom); wellHeadTop = displayCordXf->transformToDisplayCoord(wellHeadTop); wellHeadBottom = displayCordXf->transformToDisplayCoord(wellHeadBottom); wellHeadTop.z() += characteristicCellSize; @@ -183,7 +183,7 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasi cvf::Vec3d otherWellHeadTop; cvf::Vec3d otherWellHeadBottom; { - otherWell->wellHeadTopBottomPosition(frameIndex, &otherWellHeadTop, &otherWellHeadBottom); + otherWell->wellHeadTopBottomPosition(static_cast(frameIndex), &otherWellHeadTop, &otherWellHeadBottom); otherWellHeadTop = displayCordXf->transformToDisplayCoord(otherWellHeadTop); otherWellHeadBottom = displayCordXf->transformToDisplayCoord(otherWellHeadBottom); otherWellHeadTop.z() += characteristicCellSize; diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index e641f079d6..3a3e9e953e 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -88,7 +88,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) cvf::Vec3d whEndPos; cvf::Vec3d whStartPos; { - well->wellHeadTopBottomPosition(frameIndex, &whEndPos, &whStartPos); + well->wellHeadTopBottomPosition(static_cast(frameIndex), &whEndPos, &whStartPos); cvf::ref transForm = m_rimReservoirView->displayCoordTransform(); whEndPos = transForm->transformToDisplayCoord(whEndPos); diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 091ef10bdf..668ec506ce 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -435,6 +435,19 @@ std::vector< std::vector > RimIntersection::polyLines(double * hori if (type == CS_WELL_PATH || type == CS_SIMULATION_WELL) { + if (type == CS_SIMULATION_WELL && simulationWell()) + { + cvf::Vec3d top, bottom; + + simulationWell->wellHeadTopBottomPosition(-1, &top, &bottom); + + for ( size_t lIdx = 0; lIdx < lines.size(); ++lIdx ) + { + std::vector& polyLine = lines[lIdx]; + polyLine.insert(polyLine.begin(), top); + } + } + for (size_t lIdx = 0; lIdx < lines.size(); ++lIdx) { std::vector& polyLine = lines[lIdx]; diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 01f8401f66..7fe522cbb6 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -178,9 +178,9 @@ void RimSimWellInView::calculateWellPipeDynamicCenterLine(size_t } //-------------------------------------------------------------------------------------------------- -/// +/// frameIndex = -1 will use the static well frame //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom) +void RimSimWellInView::wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom) { RimEclipseView* m_rimReservoirView; @@ -188,10 +188,24 @@ void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData(); - if ( !this->simWellData()->hasAnyValidCells(frameIndex) ) return; + const RigWellResultFrame* wellResultFramePtr = nullptr; + const RigCell* whCellPtr = nullptr; + + if (frameIndex >= 0) + { + if ( !this->simWellData()->hasAnyValidCells(frameIndex) ) return; + + wellResultFramePtr = &(this->simWellData()->wellResultFrame(frameIndex)); + whCellPtr = &(rigReservoir->cellFromWellResultCell(wellResultFramePtr->wellHeadOrStartCell())); + } + else + { + wellResultFramePtr = &(this->simWellData()->staticWellCells()); + whCellPtr = &(rigReservoir->cellFromWellResultCell(wellResultFramePtr->wellHeadOrStartCell())); + } - const RigWellResultFrame& wellResultFrame = this->simWellData()->wellResultFrame(frameIndex); - const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.wellHeadOrStartCell()); + const RigWellResultFrame& wellResultFrame = *wellResultFramePtr; + const RigCell& whCell = *whCellPtr; // Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline() diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index 14850bbdaa..e066ca48cf 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -71,7 +71,7 @@ class RimSimWellInView : public caf::PdmObject std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) const; - void wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); + void wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); caf::PdmField showWell; From 25f38cb4068d362e080a249eb8fe2793ccc4e63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 28 Feb 2018 17:30:38 +0100 Subject: [PATCH 0379/1027] Upped to version 2018.01.01-dev.106 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 9d5aff0f48..7c600879cf 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".105") +set(RESINSIGHT_DEV_VERSION ".106") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 74e4775395e969025246dfa18dc46ce462f1c6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 1 Mar 2018 07:52:32 +0100 Subject: [PATCH 0380/1027] #2487 Avoid switching views when picking a simulation well in an intersection view --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index d15c937dbb..61da1cef03 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -497,6 +497,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (rivObjectSourceInfo) { RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); + { bool blockSelectionOfFracture = false; if (fracture) @@ -586,7 +587,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM } else if (eclipseWellSourceInfo) { - RiuMainWindow::instance()->selectAsCurrentItem(eclipseWellSourceInfo->well()); + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + RiuMainWindow::instance()->selectAsCurrentItem(eclipseWellSourceInfo->well(), allowActiveViewChange); } } From 4f20c7862ec221c5f2f2b97355c696ac1b279851 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 Mar 2018 12:52:38 +0100 Subject: [PATCH 0381/1027] #2541 Mohr Circle: Use correct arguments when calling calculateFOS --- .../UserInterface/RiuMohrsCirclePlot.cpp | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 8400cc13b4..2d5638cdb8 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -43,10 +43,8 @@ #include "qwt_legend.h" #include "qwt_plot_curve.h" #include "qwt_plot_layout.h" -#include "qwt_plot_marker.h" #include "qwt_plot_rescaler.h" #include "qwt_plot_shapeitem.h" -#include "qwt_plot_textlabel.h" #include @@ -95,8 +93,10 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { deleteCircles(); deleteEnvelopes(); - + if (m_rescaler) + { delete m_rescaler; + } } //-------------------------------------------------------------------------------------------------- @@ -191,7 +191,7 @@ void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo if (i == 0) { QString textBuilder; - textBuilder.append(QString("FOS: %1,").arg(QString::number(mohrsCirclesInfo.factorOfSafety, 'f', 2))); + textBuilder.append(QString("FOS: %1, ").arg(QString::number(mohrsCirclesInfo.factorOfSafety, 'f', 2))); textBuilder.append(QString("Element Id: %1, ijk[%2, %3, %4],") .arg(mohrsCirclesInfo.elmIndex) @@ -199,9 +199,10 @@ void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo .arg(mohrsCirclesInfo.j) .arg(mohrsCirclesInfo.k)); - textBuilder.append(QString("σ1: %1,").arg(principals[0])); - textBuilder.append(QString("σ2: %1,").arg(principals[1])); + textBuilder.append(QString("σ1: %1, ").arg(principals[0])); + textBuilder.append(QString("σ2: %1, ").arg(principals[1])); textBuilder.append(QString("σ3: %1").arg(principals[2])); + plotItem->setTitle(textBuilder); plotItem->setItemAttribute(QwtPlotItem::Legend); } @@ -249,8 +250,8 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie return; } - std::vector xVals; - std::vector yVals; + double xVals[2]; + double yVals[2]; double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle))); @@ -259,25 +260,29 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie return; } + yVals[0] = 0; + double x = cohesion / tanFrictionAngle; if (principals[0] < 0) { - xVals.push_back(x); - xVals.push_back(principals[2] * 1.1); + xVals[0] = x; + xVals[1] = principals[2]; + + yVals[1] = (cohesion / x) * (x + principals[2]); } else { - xVals.push_back(-x); - xVals.push_back(principals[0] * 1.1); + xVals[0] = -x; + xVals[1] = principals[0]; + + yVals[1] = (cohesion / x) * (x + principals[0]); } - yVals.push_back(0); - yVals.push_back((x + cvf::Math::abs(principals[0]) * 1.05) * tanFrictionAngle); // If envelope for the view already exists, check if a "larger" envelope should be created if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end()) { - if (yVals.back() <= m_envolopePlotItems[view]->maxYValue()) + if (yVals[1] <= m_envolopePlotItems[view]->maxYValue()) { return; } @@ -291,7 +296,7 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie QwtPlotCurve* qwtCurve = new QwtPlotCurve(); - qwtCurve->setSamples(xVals.data(), yVals.data(), 2); + qwtCurve->setSamples(xVals, yVals, 2); qwtCurve->setStyle(QwtPlotCurve::Lines); qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); @@ -364,7 +369,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView } double cohesion = geoMechView->geoMechCase()->cohesion(); - double frictionAngle = geoMechView->geoMechCase()->frictionAngleDeg(); + double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg(); size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); @@ -372,7 +377,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView MohrsCirclesInfo mohrsCircle; mohrsCircle.color = color; mohrsCircle.elmIndex = elmIndex; - mohrsCircle.factorOfSafety = calculateFOS(principals, cohesion, frictionAngle); + mohrsCircle.factorOfSafety = calculateFOS(principals, frictionAngleDeg, cohesion); mohrsCircle.principals = principals; mohrsCircle.i = i; mohrsCircle.j = j; @@ -508,7 +513,7 @@ void RiuMohrsCirclePlot::replotAndScaleAxis() updateTransparentCurvesOnPrincipals(); - this->replot(); + this->replot(); m_rescaler->rescale(); this->plotLayout()->setAlignCanvasToScales(true); } @@ -551,13 +556,18 @@ float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double fric float se1 = principals[0]; float se3 = principals[2]; - float tanFricAng = tan(cvf::Math::toRadians(frictionAngle)); - float cohPrTanFricAngle = (float)(cohesion / tanFricAng); + if (cvf::Math::cos(frictionAngle) == 0) + { + return 0; + } + + float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle)); + float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng; float pi_4 = 0.785398163397448309616f; - float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); + float rho = 2.0f * (cvf::Math::atan(cvf::Math::sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); - return tanFricAng / tan(rho); + return tanFricAng / cvf::Math::tan(rho); } //-------------------------------------------------------------------------------------------------- From 2ac9aba4854621272dc9f005037f68904beafb6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 1 Mar 2018 14:16:08 +0100 Subject: [PATCH 0382/1027] #2494 Add height/width fracture scaling --- .../FileInterface/RifStimPlanXmlReader.cpp | 8 +++++- .../FileInterface/RifStimPlanXmlReader.h | 3 +++ .../RimEllipseFractureTemplate.cpp | 23 +++++++++-------- .../Completions/RimFractureTemplate.cpp | 25 +++++++++++++++++++ .../Completions/RimFractureTemplate.h | 4 +++ .../RimStimPlanFractureTemplate.cpp | 19 ++++++++++++++ .../RigStimPlanFractureDefinition.cpp | 24 ++++++++++++++++++ .../RigStimPlanFractureDefinition.h | 2 ++ 8 files changed, 97 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index a57fdf986a..edff203d97 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -38,7 +38,10 @@ bool hasNegativeValues(std::vector xs); /// //-------------------------------------------------------------------------------------------------- cvf::ref RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName, - double conductivityScalingFactor, + double conductivityScalingFactor, + double xScaleFactor, + double yScaleFactor, + double wellPathInterationY, MirrorMode mirrorMode, RiaEclipseUnitTools::UnitSystem requiredUnit, QString * errorMessage) @@ -59,6 +62,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil xmlStream.readNext(); readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode, requiredUnit); + if(xScaleFactor != 1.0) stimPlanFileData->scaleXs(xScaleFactor); + if(yScaleFactor != 1.0) stimPlanFileData->scaleYs(yScaleFactor, wellPathInterationY); + RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet(); if (unitSystem != RiaEclipseUnitTools::UNITS_UNKNOWN) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index b698b1e62e..3489930d2e 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -37,6 +37,9 @@ class RifStimPlanXmlReader static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, + double xScaleFactor, + double yScaleFactor, + double wellPathIntersectionY, MirrorMode mirrorMode, RiaEclipseUnitTools::UnitSystem requiredUnit, QString * errorMessage); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index cd9137ae5c..38a0adeba5 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -90,7 +90,8 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha if ( changedField == &m_halfLength || changedField == &m_height || changedField == &m_width - || changedField == &m_userDefinedEffectivePermeability) + || changedField == &m_userDefinedEffectivePermeability + || changedField == &m_sizeScaleApplyButton) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -116,8 +117,8 @@ void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector fractureCells; std::pair wellCenterFractureCellIJ = std::make_pair(0, 0); int numberOfCellsX = 35; int numberOfCellsY = 35; - double cellSizeX = (m_halfLength * 2) / numberOfCellsX; - double cellSizeZ = m_height / numberOfCellsY; + double height = m_height * m_heightScaleFactor; + double halfLength = m_halfLength * m_widthScaleFactor; + + double cellSizeX = (halfLength * 2) / numberOfCellsX * m_widthScaleFactor; + double cellSizeZ = height / numberOfCellsY * m_heightScaleFactor; double cellArea = cellSizeX * cellSizeZ; double areaTresholdForIncludingCell = 0.5 * cellArea; @@ -182,10 +185,10 @@ void RimEllipseFractureTemplate::setupFractureGridCells() { for (int j = 0; j < numberOfCellsX; j++) { - double X1 = - m_halfLength + i * cellSizeX; - double X2 = - m_halfLength + (i+1) * cellSizeX; - double Y1 = - m_height / 2 + j * cellSizeZ; - double Y2 = - m_height / 2 + (j+1) * cellSizeZ; + double X1 = - halfLength + i * cellSizeX; + double X2 = - halfLength + (i+1) * cellSizeX; + double Y1 = - height / 2 + j * cellSizeZ; + double Y2 = - height / 2 + (j+1) * cellSizeZ; std::vector cellPolygon; cellPolygon.push_back(cvf::Vec3d(X1, Y1, 0.0)); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 2a767abdb9..822224a258 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -29,6 +29,7 @@ #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiDoubleValueEditor.h" #include "cafPdmUiTextEditor.h" +#include "cafPdmUiPushButtonEditor.h" #include "cvfVector3.h" @@ -153,6 +154,13 @@ RimFractureTemplate::RimFractureTemplate() m_dFactorSummaryText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); m_dFactorSummaryText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP); m_dFactorSummaryText.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height Scale Factor", "", "", ""); + CAF_PDM_InitField(&m_widthScaleFactor, "WidthScaleFactor", 1.0, "Width Scale Factor", "", "", ""); + CAF_PDM_InitField(&m_sizeScaleApplyButton, "SizeScaleApplyButton", false, "Apply", "", "", ""); + m_sizeScaleApplyButton.xmlCapability()->disableIO(); + m_sizeScaleApplyButton.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_sizeScaleApplyButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); } //-------------------------------------------------------------------------------------------------- @@ -296,6 +304,14 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { prepareFieldsForUiDisplay(); + { + auto group = uiOrdering.addNewGroup("Scale Factors"); + group->setCollapsedByDefault(false); + group->add(&m_heightScaleFactor); + group->add(&m_widthScaleFactor); + group->add(&m_sizeScaleApplyButton); + } + auto nonDarcyFlowGroup = uiOrdering.addNewGroup("Non-Darcy Flow"); nonDarcyFlowGroup->add(&m_nonDarcyFlowType); @@ -363,6 +379,15 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field myAttr->textMode = caf::PdmUiTextEditorAttribute::HTML; } } + + if (field == &m_sizeScaleApplyButton) + { + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + if (attrib) + { + attrib->m_buttonText = "Apply"; + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 8f43d92cf2..0a8b2db880 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -190,4 +190,8 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmProxyValueField m_dFactorDisplayField; caf::PdmProxyValueField m_dFactorSummaryText; + + caf::PdmField m_heightScaleFactor; + caf::PdmField m_widthScaleFactor; + caf::PdmField m_sizeScaleApplyButton; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 9080a881e0..7075042138 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -151,6 +151,22 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch proj->createDisplayModelAndRedrawAllViews(); } } + + if (changedField == &m_sizeScaleApplyButton) + { + m_sizeScaleApplyButton = false; + loadDataAndUpdate(); + //setDefaultsBasedOnXMLfile(); + + updateFractureGrid(); + + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -241,6 +257,9 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_conductivityScalingFactor(), + m_widthScaleFactor(), + m_heightScaleFactor(), + -m_wellPathDepthAtFracture(), RifStimPlanXmlReader::MIRROR_AUTO, fractureTemplateUnit(), &errorMessage); diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 9accb428d6..d69b6c575d 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -130,6 +130,30 @@ double RigStimPlanFractureDefinition::maxY() const return m_Ys.back(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::scaleXs(double scaleFactor) +{ + // Scale using 0 as scaling anchor + for (double& x : m_Xs) + { + x *= scaleFactor; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::scaleYs(double scaleFactor, double wellPathIntersectionY) +{ + // Scale using wellPathIntersectionY as scaling anchor + for (double& y : m_Ys) + { + y = (y - wellPathIntersectionY) * scaleFactor + wellPathIntersectionY; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index b496548b45..9aad1cf12c 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -121,6 +121,8 @@ class RigStimPlanFractureDefinition: public cvf::Object bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); double minY() const; double maxY() const; + void scaleXs(double scaleFactor); + void scaleYs(double scaleFactor, double wellPathIntersectionY); private: RiaEclipseUnitTools::UnitSystem m_unitSet; // To be deleted From 82a394d588ec302bf051ea1a3e8f0234d685c112 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 Mar 2018 16:01:14 +0100 Subject: [PATCH 0383/1027] #2543 Tensor vectors: Use tensor value, not length, for color mapping --- .../RivTensorResultPartMgr.cpp | 16 +++++++--------- .../ModelVisualization/RivTensorResultPartMgr.h | 6 ++++-- .../ProjectDataModel/RimGeoMechView.cpp | 5 ++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 933fefcceb..de32f58135 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -156,24 +156,24 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (isDrawable(result1, m_rimReservoirView->tensorResults()->showPrincipal1())) { tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1)); + cvf::Vec3f(displayCoord), result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1, elmPrincipals[0][elmIdx])); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1)); + cvf::Vec3f(displayCoord), -result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1, elmPrincipals[0][elmIdx])); } if (isDrawable(result2, m_rimReservoirView->tensorResults()->showPrincipal2())) { tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2)); + cvf::Vec3f(displayCoord), result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2, elmPrincipals[1][elmIdx])); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2)); + cvf::Vec3f(displayCoord), -result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2, elmPrincipals[1][elmIdx])); } if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) { tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3)); + cvf::Vec3f(displayCoord), result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3, elmPrincipals[2][elmIdx])); tensorVisualizations.push_back(TensorVisualization( - cvf::Vec3f(displayCoord), -result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3)); + cvf::Vec3f(displayCoord), -result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3, elmPrincipals[2][elmIdx])); } } } @@ -438,11 +438,9 @@ void RivTensorResultPartMgr::createResultColorTextureCoords(cvf::Vec2fArray* for (auto tensor : tensorVisualizations) { - int sign = tensor.isPressure ? 1 : -1; - for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) { - cvf::Vec2f texCoord = mapper->mapToTextureCoord(sign * tensor.result.length()); + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.principalValue); textureCoords->add(texCoord); } } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index c0a323f263..c32fd938a2 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -56,18 +56,20 @@ class RivTensorResultPartMgr : public cvf::Object private: struct TensorVisualization { - TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, size_t princial) + TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, size_t princial, float principalValue) : vertex(vertex) , result(result) , faceNormal(faceNormal) , isPressure(isPressure) - , princial(princial){}; + , princial(princial) + , principalValue(principalValue) {}; cvf::Vec3f vertex; cvf::Vec3f result; cvf::Vec3f faceNormal; bool isPressure; size_t princial; + float principalValue; }; private: diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index d8100a30bb..9ee21b3bb8 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -301,7 +301,10 @@ void RimGeoMechView::updateCurrentTimeStep() m_tensorPartMgr->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep); frameParts->updateBoundingBoxesRecursive(); - frameScene->addModel(frameParts.p()); + if (frameParts->partCount() != 0) + { + frameScene->addModel(frameParts.p()); + } } } } From 6bb06ce53c08eb1a949dcbc4abcf5dadcc75dbbd Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 2 Mar 2018 08:09:42 +0100 Subject: [PATCH 0384/1027] Tensor results: Add function to create arrow indices --- .../RivTensorResultPartMgr.cpp | 32 ++++++++++++++----- .../RivTensorResultPartMgr.h | 3 +- .../ProjectDataModel/RimTensorResults.cpp | 2 -- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index de32f58135..e427eea6af 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -168,6 +168,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi tensorVisualizations.push_back(TensorVisualization( cvf::Vec3f(displayCoord), -result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2, elmPrincipals[1][elmIdx])); } + if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) { tensorVisualizations.push_back(TensorVisualization( @@ -304,14 +305,10 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vector RivTensorResultPartMgr::createArrowVertices(const Tens return vertices; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivTensorResultPartMgr::createArrowIndices(uint startIndex) const +{ + std::array indices; + + indices[0] = startIndex; + indices[1] = startIndex + 1; + indices[2] = startIndex + 2; + indices[3] = startIndex + 3; + indices[4] = startIndex + 3; + indices[5] = startIndex + 4; + indices[6] = startIndex + 4; + indices[7] = startIndex + 2; + + return indices; +} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index c32fd938a2..783068dff0 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -101,7 +101,8 @@ class RivTensorResultPartMgr : public cvf::Object static bool isPressure(float principalValue); bool isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const; - std::array createArrowVertices(const TensorVisualization &tensorVisualization) const; + std::array createArrowVertices(const TensorVisualization &tensorVisualization) const; + std::array createArrowIndices(uint startIndex) const; private: caf::PdmPointer m_rimReservoirView; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index dd874254c1..c98a6f2057 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -224,7 +224,6 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { if (changedField == &m_resultPositionTypeUiField) { - std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); if (m_resultPositionTypeUiField() == m_resultPositionType()) { m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); @@ -284,7 +283,6 @@ QList RimTensorResults::calculateValueOptions(const caf: { options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), QString::fromStdString(fieldCompNames[oIdx]))); } - } return options; From bbabb60ece3d99a0398b978442e55c302104a14c Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 2 Mar 2018 09:31:17 +0100 Subject: [PATCH 0385/1027] #2538 Mohr Circle: Support time stepping --- .../UserInterface/RiuMohrsCirclePlot.cpp | 66 ++++++++++++++++--- .../UserInterface/RiuMohrsCirclePlot.h | 8 +++ .../RiuTimeStepChangedHandler.cpp | 9 ++- 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 2d5638cdb8..fd9ff36d14 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -60,7 +60,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) - : QwtPlot(parent) + : QwtPlot(parent), m_sourceGeoMechViewOfLastPlot(nullptr) { RiuSummaryQwtPlot::setCommonPlotBehaviour(this); @@ -91,11 +91,11 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { - deleteCircles(); - deleteEnvelopes(); + deletePlotItems(); + if (m_rescaler) { - delete m_rescaler; + delete m_rescaler; } } @@ -105,7 +105,9 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem) { const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); - + + m_sourceGeoMechViewOfLastPlot = nullptr; + if (!geoMechSelectionItem) { this->clearPlot(); @@ -122,6 +124,8 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select const cvf::Color3f color = geoMechSelectionItem->m_color; queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); + + m_sourceGeoMechViewOfLastPlot = geoMechView; } else { @@ -134,14 +138,42 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::clearPlot() { - m_mohrsCiclesInfos.clear(); - - deleteCircles(); - deleteEnvelopes(); + deletePlotItems(); this->replot(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView) +{ + if (!this->isVisible()) + { + return; + } + + // Don't update the plot if the view that changed time step is different from the view that was the source of the current plot + RimGeoMechView* geoMechView = dynamic_cast(changedView); + if (!geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot) + { + return; + } + + // Fetch the current global selection and only continue if the selection's view matches the view with time step change + const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(RiuSelectionManager::instance()->selectedItem()); + if (geoMechSelectionItem && geoMechSelectionItem->m_view == geoMechView) + { + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t gridCellIndex = geoMechSelectionItem->m_cellIndex; + const cvf::Color3f color = geoMechSelectionItem->m_color; + + deletePlotItems(); + + queryDataAndUpdatePlot(geoMechView, gridIndex, gridCellIndex, cvf::Color3ub(color)); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -337,6 +369,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView const cvf::Color3ub& color) { CVF_ASSERT(geoMechView); + m_sourceGeoMechViewOfLastPlot = geoMechView; RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); @@ -513,7 +546,8 @@ void RiuMohrsCirclePlot::replotAndScaleAxis() updateTransparentCurvesOnPrincipals(); - this->replot(); + //Replotting must be done before rescaling + this->replot(); m_rescaler->rescale(); this->plotLayout()->setAlignCanvasToScales(true); } @@ -586,3 +620,15 @@ QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view) return m_envolopeColors[view]; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deletePlotItems() +{ + m_mohrsCiclesInfos.clear(); + + deleteCircles(); + deleteEnvelopes(); +} + diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index fd72c8872d..318ec00b7d 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -34,6 +34,8 @@ class QwtPlotTextLabel; class QwtRoundScaleDraw; class RimGeoMechView; class RiuSelectionItem; +class Rim3dView; +class RimGeoMechView; //================================================================================================== // @@ -51,6 +53,8 @@ class RiuMohrsCirclePlot : public QwtPlot void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); void clearPlot(); + void updateOnTimeStepChanged(Rim3dView* changedView); + public: struct MohrsCirclesInfo { @@ -86,6 +90,8 @@ class RiuMohrsCirclePlot : public QwtPlot static float calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion); QColor envelopeColor(RimGeoMechView* view); + + void deletePlotItems(); private: std::vector m_circlePlotItems; @@ -96,5 +102,7 @@ class RiuMohrsCirclePlot : public QwtPlot std::vector m_mohrsCiclesInfos; + RimGeoMechView* m_sourceGeoMechViewOfLastPlot; + QwtPlotRescaler* m_rescaler; }; diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp index 72206926b7..8b82bd21b0 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp @@ -17,11 +17,13 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuTimeStepChangedHandler.h" + #include "RiuMainWindow.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuRelativePermeabilityPlotUpdater.h" +#include "RiuMohrsCirclePlot.h" #include "RiuPvtPlotPanel.h" #include "RiuPvtPlotUpdater.h" +#include "RiuRelativePermeabilityPlotPanel.h" +#include "RiuRelativePermeabilityPlotUpdater.h" #include "Rim3dView.h" @@ -71,5 +73,8 @@ void RiuTimeStepChangedHandler::handleTimeStepChanged(Rim3dView* changedView) co RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnTimeStepChanged(changedView); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + mohrsCirclePlot->updateOnTimeStepChanged(changedView); + //tim.reportTimeMS("done"); } From 3fc99a73bc6e7ebcf78fd83bb38d7baf74b04c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 2 Mar 2018 09:33:17 +0100 Subject: [PATCH 0386/1027] #2462 Add fracture template id --- .../RicNewEllipseFractureTemplateFeature.cpp | 4 +- .../RicNewStimPlanFractureTemplateFeature.cpp | 2 +- .../RicPasteEllipseFractureFeature.cpp | 6 +- .../RicPasteStimPlanFractureFeature.cpp | 2 +- .../RimEllipseFractureTemplate.cpp | 1 + .../Completions/RimFracture.cpp | 2 +- .../Completions/RimFractureTemplate.cpp | 19 +++++ .../Completions/RimFractureTemplate.h | 4 +- .../RimFractureTemplateCollection.cpp | 73 ++++++++++++++++--- .../RimFractureTemplateCollection.h | 16 +++- .../RimStimPlanFractureTemplate.cpp | 1 + .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 2 +- 13 files changed, 107 insertions(+), 27 deletions(-) diff --git a/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp index f7370be3b0..b23ecc84ab 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp @@ -79,9 +79,9 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) { RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate(); - fracDefColl->fractureDefinitions.push_back(ellipseFractureTemplate); + fracDefColl->addFractureTemplate(ellipseFractureTemplate); ellipseFractureTemplate->setName("Ellipse Fracture Template"); - ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitsForFracTemplates()); + ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitSystemType()); ellipseFractureTemplate->setDefaultValuesFromUnit(); selectFractureTemplateAndUpdate(fracDefColl, ellipseFractureTemplate); diff --git a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index 37c43d0726..b0905a59f8 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -60,7 +60,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) if (fracDefColl) { RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate(); - fracDefColl->fractureDefinitions.push_back(fractureDef); + fracDefColl->addFractureTemplate(fractureDef); QFileInfo stimplanfileFileInfo(fileName); QString name = stimplanfileFileInfo.baseName(); diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp index 37a40d703f..068b7bd101 100644 --- a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp @@ -73,12 +73,12 @@ void RicPasteEllipseFractureFeature::onActionTriggered(bool isChecked) for (const auto& source : typedObjects) { - auto rimReservoirView = dynamic_cast( + auto templ = dynamic_cast( source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - fractureTemplateColl->fractureDefinitions.push_back(rimReservoirView); + fractureTemplateColl->addFractureTemplate(templ); - RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, rimReservoirView); + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, templ); } return; diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp index a5e03ea2d1..ed429b4219 100644 --- a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp @@ -76,7 +76,7 @@ void RicPasteStimPlanFractureFeature::onActionTriggered(bool isChecked) auto copyOfStimPlanTemplate = dynamic_cast( source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - fractureTemplateColl->fractureDefinitions.push_back(copyOfStimPlanTemplate); + fractureTemplateColl->addFractureTemplate(copyOfStimPlanTemplate); RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, copyOfStimPlanTemplate); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 38a0adeba5..32cc5da026 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -377,6 +377,7 @@ void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pdm } uiOrdering.add(&m_name); + uiOrdering.add(&m_id); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); geometryGroup->add(&m_halfLength); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 4c97455d26..3ec570aea0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -416,7 +416,7 @@ QList RimFracture::calculateValueOptions(const caf::PdmF { RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); - for (RimFractureTemplate* fracDef : fracDefColl->fractureDefinitions()) + for (RimFractureTemplate* fracDef : fracDefColl->fractureTemplates()) { QString displayText = fracDef->nameAndUnit(); if (fracDef->fractureTemplateUnit() != fractureUnit()) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 822224a258..976ac886a7 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -98,6 +98,9 @@ RimFractureTemplate::RimFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); + CAF_PDM_InitField(&m_id, "Id", -1, "ID", "", "", ""); + m_id.uiCapability()->setUiReadOnly(true); + CAF_PDM_InitField(&m_name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_nameAndUnit, "NameAndUnit", "NameAndUnit", "", "", ""); @@ -170,6 +173,14 @@ RimFractureTemplate::~RimFractureTemplate() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFractureTemplate::id() const +{ + return m_id; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -638,6 +649,14 @@ void RimFractureTemplate::disconnectAllFracturesAndRedrawViews() const } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setId(int id) +{ + m_id = id; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 0a8b2db880..8aa1746957 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -104,6 +104,7 @@ class RimFractureTemplate : public caf::PdmObject RimFractureTemplate(); virtual ~RimFractureTemplate(); + int id() const; QString name() const; QString nameAndUnit() const; @@ -142,7 +143,7 @@ class RimFractureTemplate : public caf::PdmObject virtual void loadDataAndUpdate() = 0; void disconnectAllFracturesAndRedrawViews() const; - + void setId(int id); protected: virtual caf::PdmFieldHandle* userDescriptionField() override; @@ -161,6 +162,7 @@ class RimFractureTemplate : public caf::PdmObject double fractureWidth() const; protected: + caf::PdmField m_id; caf::PdmField m_name; caf::PdmProxyValueField m_nameAndUnit; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 074ad995c1..2a9c8995bb 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -52,12 +52,16 @@ RimFractureTemplateCollection::RimFractureTemplateCollection(void) { CAF_PDM_InitObject("Fracture Templates", ":/FractureTemplates16x16.png", "", ""); - CAF_PDM_InitField(&defaultUnitsForFracTemplates, "DefaultUnitForTemplates", + CAF_PDM_InitField(&m_defaultUnitsForFracTemplates, "DefaultUnitForTemplates", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Default unit system for fracture templates", "", "", ""); - CAF_PDM_InitFieldNoDefault(&fractureDefinitions, "FractureDefinitions", "", "", "", ""); - fractureDefinitions.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_fractureDefinitions, "FractureDefinitions", "", "", "", ""); + m_fractureDefinitions.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_nextValidFractureTemplateId, "NextValidFractureTemplateId", 0, "", "", "", ""); + m_fractureDefinitions.uiCapability()->setUiHidden(true); + } //-------------------------------------------------------------------------------------------------- @@ -65,7 +69,37 @@ RimFractureTemplateCollection::RimFractureTemplateCollection(void) //-------------------------------------------------------------------------------------------------- RimFractureTemplateCollection::~RimFractureTemplateCollection() { - fractureDefinitions.deleteAllChildObjects(); + m_fractureDefinitions.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimFractureTemplateCollection::fractureTemplates() const +{ + std::vector templates; + for (auto& templ : m_fractureDefinitions) + { + templates.push_back(templ); + } + return templates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::addFractureTemplate(RimFractureTemplate* templ) +{ + templ->setId(nextFractureTemplateId()); + m_fractureDefinitions.push_back(templ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaEclipseUnitTools::UnitSystemType RimFractureTemplateCollection::defaultUnitSystemType() const +{ + return m_defaultUnitsForFracTemplates; } //-------------------------------------------------------------------------------------------------- @@ -73,7 +107,7 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection() //-------------------------------------------------------------------------------------------------- RimFractureTemplate* RimFractureTemplateCollection::firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { if (f->fractureTemplateUnit() == unitSet) { @@ -91,7 +125,7 @@ std::vector > RimFractureTemplateCollection::resultN { std::set > nameSet; - for (const RimFractureTemplate* f : fractureDefinitions()) + for (const RimFractureTemplate* f : m_fractureDefinitions()) { std::vector > namesAndUnits = f->uiResultNamesWithUnit(); @@ -115,7 +149,7 @@ void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, c MinMaxAccumulator minMaxAccumulator; PosNegAccumulator posNegAccumulator; - for (const RimFractureTemplate* f : fractureDefinitions()) + for (const RimFractureTemplate* f : m_fractureDefinitions()) { if (f) { @@ -138,7 +172,7 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni std::vector templatesToBeAdded; - for (RimFractureTemplate* fractureTemplate : fractureDefinitions()) + for (RimFractureTemplate* fractureTemplate : m_fractureDefinitions()) { if (fractureTemplate) { @@ -188,7 +222,7 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni for (auto templateWithMatchingUnit : templatesToBeAdded) { - fractureDefinitions.push_back(templateWithMatchingUnit); + m_fractureDefinitions.push_back(templateWithMatchingUnit); } } @@ -197,7 +231,7 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::loadAndUpdateData() { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) @@ -212,7 +246,7 @@ void RimFractureTemplateCollection::loadAndUpdateData() //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::setDefaultConductivityResultIfEmpty() { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) @@ -227,7 +261,7 @@ void RimFractureTemplateCollection::setDefaultConductivityResultIfEmpty() //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) @@ -248,6 +282,12 @@ void RimFractureTemplateCollection::updateFilePathsFromProjectPath(const QString //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::initAfterRead() { + // Assign template id if not already assigned + for (auto& templ : m_fractureDefinitions) + { + if (templ->id() < 0) templ->setId(nextFractureTemplateId()); + } + RimProject* proj = nullptr; this->firstAncestorOrThisOfType(proj); if (proj && proj->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) @@ -347,3 +387,12 @@ void RimFractureTemplateCollection::initAfterRead() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFractureTemplateCollection::nextFractureTemplateId() +{ + int newId = m_nextValidFractureTemplateId; + m_nextValidFractureTemplateId = m_nextValidFractureTemplateId + 1; + return newId; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 2d650b79cf..2852a30afc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -38,10 +38,11 @@ class RimFractureTemplateCollection : public caf::PdmObject RimFractureTemplateCollection(void); virtual ~RimFractureTemplateCollection(void); + std::vector fractureTemplates() const; + void addFractureTemplate(RimFractureTemplate* templ); + RiaEclipseUnitTools::UnitSystemType defaultUnitSystemType() const; + RimFractureTemplate* firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const; - - caf::PdmChildArrayField fractureDefinitions; - caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; std::vector > resultNamesAndUnits() const; void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; @@ -52,6 +53,13 @@ class RimFractureTemplateCollection : public caf::PdmObject void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); protected: - virtual void initAfterRead() override; + virtual void initAfterRead() override; + +private: + int nextFractureTemplateId(); + + caf::PdmChildArrayField m_fractureDefinitions; + caf::PdmField< RiaEclipseUnitTools::UnitSystemType > m_defaultUnitsForFracTemplates; + caf::PdmField m_nextValidFractureTemplateId; // Unique fracture template ID within a project, used to identify a fracture template }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 7075042138..b26844710b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -734,6 +734,7 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon() void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&m_name); + uiOrdering.add(&m_id); caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("Input"); fileGroup->add(&m_stimPlanFileName); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 29e2079333..079e4b25fc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1385,7 +1385,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering if (oilfield && oilfield->fractureDefinitionCollection().notNull()) { - if (!oilfield->fractureDefinitionCollection()->fractureDefinitions.empty()) + if (!oilfield->fractureDefinitionCollection()->fractureTemplates().empty()) { uiTreeOrdering.add(fractureColors()); } diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index b53d3ad220..6395a3c7a0 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -959,7 +959,7 @@ std::vector RimProject::allFractureTemplates() const allOilFields(oilFields); for (RimFractureTemplateCollection* templColl : allFractureTemplateCollections()) { - for (RimFractureTemplate* templ : templColl->fractureDefinitions) + for (RimFractureTemplate* templ : templColl->fractureTemplates()) { templates.push_back(templ); } From db276fff0387a31c067f461cc180705ca9bf7f43 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 11:25:47 +0100 Subject: [PATCH 0387/1027] #2483 Intersections : Use branch detection switch in "Simulation Wells" --- .../ProjectDataModel/RimIntersection.cpp | 50 ++++++++++++------- .../ProjectDataModel/RimIntersection.h | 6 ++- .../RimIntersectionCollection.cpp | 13 ++++- .../RimIntersectionCollection.h | 1 + .../RimSimWellInViewCollection.cpp | 14 ++++-- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 668ec506ce..6d288fdcbe 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -155,9 +155,7 @@ void RimIntersection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, || changedField == &isActive || changedField == &type) { - m_wellBranchCenterlines.clear(); - updateWellCenterline(); - m_branchIndex = -1; + recomputeSimulationWellBranchData(); } if (changedField == &simulationWell @@ -231,8 +229,8 @@ void RimIntersection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& else if (type == CS_SIMULATION_WELL) { geometryGroup->add(&simulationWell); - updateWellCenterline(); - if (simulationWell() && m_wellBranchCenterlines.size() > 1) + updateSimulationWellCenterline(); + if (simulationWell() && m_simulationWellBranchCenterlines.size() > 1) { geometryGroup->add(&m_branchIndex); } @@ -322,9 +320,9 @@ QList RimIntersection::calculateValueOptions(const caf:: } else if (fieldNeedingOptions == &m_branchIndex) { - updateWellCenterline(); + updateSimulationWellCenterline(); - size_t branchCount = m_wellBranchCenterlines.size(); + size_t branchCount = m_simulationWellBranchCenterlines.size(); options.push_back(caf::PdmOptionItemInfo("All", -1)); @@ -411,16 +409,16 @@ std::vector< std::vector > RimIntersection::polyLines(double * hori { if (simulationWell()) { - updateWellCenterline(); + updateSimulationWellCenterline(); - if (0 <= m_branchIndex && m_branchIndex < static_cast(m_wellBranchCenterlines.size())) + if (0 <= m_branchIndex && m_branchIndex < static_cast(m_simulationWellBranchCenterlines.size())) { - lines.push_back(m_wellBranchCenterlines[m_branchIndex]); + lines.push_back(m_simulationWellBranchCenterlines[m_branchIndex]); } if (m_branchIndex == -1) { - lines = m_wellBranchCenterlines; + lines = m_simulationWellBranchCenterlines; } } } @@ -488,32 +486,35 @@ std::vector< std::vector > RimIntersection::polyLinesForExtrusionDi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersection::updateWellCenterline() const +void RimIntersection::updateSimulationWellCenterline() const { if (isActive() && type == CS_SIMULATION_WELL && simulationWell()) { - if (m_wellBranchCenterlines.size() == 0) + if (m_simulationWellBranchCenterlines.size() == 0) { RimEclipseCase* rimEclCase = nullptr; simulationWell->firstAncestorOrThisOfType(rimEclCase); if (rimEclCase) { - bool includeCellCenters = false; - bool detectBrances = true; + RimSimWellInViewCollection* simWellCollection = nullptr; + simulationWell->firstAncestorOrThisOfTypeAsserted(simWellCollection); + + bool includeCellCenters = simulationWell->isUsingCellCenterForPipe(); + bool detectBrances = simWellCollection->isAutoDetectingBranches; RigEclipseCaseData* caseData = rimEclCase->eclipseCaseData(); auto branches = caseData->simulationWellBranches(simulationWell->name, includeCellCenters, detectBrances); for (auto b : branches) { - m_wellBranchCenterlines.push_back(b->m_wellPathPoints); + m_simulationWellBranchCenterlines.push_back(b->m_wellPathPoints); } } } } else { - m_wellBranchCenterlines.clear(); + m_simulationWellBranchCenterlines.clear(); } } @@ -884,6 +885,21 @@ void RimIntersection::setLengthDown(double lengthDown) m_lengthDown = lengthDown; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersection::recomputeSimulationWellBranchData() +{ + if (type() == CS_SIMULATION_WELL) + { + m_simulationWellBranchCenterlines.clear(); + updateSimulationWellCenterline(); + m_branchIndex = -1; + + m_crossSectionPartMgr = nullptr; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 7942eaa659..3c23c61c49 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -101,6 +101,8 @@ class RimIntersection : public caf::PdmObject void setLengthUp(double heightUp); void setLengthDown(double heightDown); + void recomputeSimulationWellBranchData(); + protected: virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); @@ -130,7 +132,7 @@ class RimIntersection : public caf::PdmObject RimSimWellInViewCollection* simulationWellCollection(); void updateAzimuthLine(); - void updateWellCenterline() const; + void updateSimulationWellCenterline() const; void updateWellExtentDefaultValue(); void addExtents(std::vector &polyLine) const; void clipToReservoir(std::vector &polyLinee, double * horizontalLengthAlongWellToClipPoint) const; @@ -141,5 +143,5 @@ class RimIntersection : public caf::PdmObject cvf::ref m_crossSectionPartMgr; mutable - std::vector< std::vector > m_wellBranchCenterlines; + std::vector< std::vector > m_simulationWellBranchCenterlines; }; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index 15182e532f..10e015a828 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -19,8 +19,8 @@ #include "RimIntersectionCollection.h" -#include "Rim2dIntersectionViewCollection.h" #include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" #include "Rim3dView.h" #include "RimCase.h" #include "RimIntersection.h" @@ -167,6 +167,17 @@ std::vector RimIntersectionCollection::intersectionBoxes() return m_intersectionBoxes.childObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::recomputeSimWellBranchData() +{ + for (const auto& intersection : intersections()) + { + intersection->recomputeSimulationWellBranchData(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 5a0f362e1a..bb463c263a 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -62,6 +62,7 @@ class RimIntersectionCollection : public caf::PdmObject void syncronize2dIntersectionViews(); void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + void recomputeSimWellBranchData(); // Visualization interface diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index a89ea132d6..287e3301b7 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -28,12 +28,14 @@ #include "RigSimWellData.h" #include "RimEclipseCase.h" +#include "RimEclipseResultCase.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimProject.h" -#include "RimSimWellInView.h" -#include "RimWellAllocationPlot.h" #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" +#include "RimSimWellInView.h" +#include "RimWellAllocationPlot.h" #include "RiuMainWindow.h" @@ -41,7 +43,6 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiCheckBoxTristateEditor.h" -#include "RimEclipseResultCase.h" namespace caf @@ -460,8 +461,13 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha if (m_reservoirView) m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } - if (&wellPipeCoordType == changedField) + if (&wellPipeCoordType == changedField || &isAutoDetectingBranches == changedField) { + if (m_reservoirView) + { + m_reservoirView->crossSectionCollection()->recomputeSimWellBranchData(); + } + for (RimSimWellInView* w : wells) { for (RimSimWellFracture* frac : w->simwellFractureCollection()->simwellFractures()) From e39105503b36e54e7a4fc82ecdddd019289dfe1f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 12:43:12 +0100 Subject: [PATCH 0388/1027] #2483 Use update pattern of intersections when updating simwell fractures --- .../Completions/RimSimWellFracture.cpp | 22 +++++++------- .../Completions/RimSimWellFracture.h | 4 +-- .../RimSimWellFractureCollection.cpp | 29 ++++++++++++------- .../RimSimWellFractureCollection.h | 1 + .../RimSimWellInViewCollection.cpp | 7 ++--- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index a77806724d..c30da5922c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -66,7 +66,7 @@ RimSimWellFracture::~RimSimWellFracture() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::setClosestWellCoord(cvf::Vec3d& position, size_t branchIndex) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); double location = m_branchCenterLines[branchIndex].locationAlongWellCoords(position); @@ -81,7 +81,7 @@ void RimSimWellFracture::setClosestWellCoord(cvf::Vec3d& position, size_t branch //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::updateAzimuthBasedOnWellAzimuthAngle() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (!fractureTemplate()) return; if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH @@ -117,7 +117,7 @@ double RimSimWellFracture::wellAzimuthAtFracturePosition() const //-------------------------------------------------------------------------------------------------- double RimSimWellFracture::wellDipAtFracturePosition() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); double simWellDip = m_branchCenterLines[m_branchIndex].simWellDipAngle(fracturePosition()); return simWellDip; } @@ -127,7 +127,7 @@ double RimSimWellFracture::wellDipAtFracturePosition() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::loadDataAndUpdate() { - setBranchGeometry(); + computeSimWellBranchCenterLines(); updateFracturePositionFromLocation(); updateAzimuthBasedOnWellAzimuthAngle(); } @@ -190,7 +190,7 @@ void RimSimWellFracture::recomputeWellCenterlineCoordinates() { m_branchCenterLines.clear(); - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); } //-------------------------------------------------------------------------------------------------- @@ -198,7 +198,7 @@ void RimSimWellFracture::recomputeWellCenterlineCoordinates() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::updateFracturePositionFromLocation() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (m_branchCenterLines.size() > 0) { @@ -258,7 +258,7 @@ void RimSimWellFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, if (myAttr) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (m_branchCenterLines.size() > 0) { @@ -283,7 +283,7 @@ QList RimSimWellFracture::calculateValueOptions(const ca { if (m_branchCenterLines.size() == 0) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); } if (m_branchCenterLines.size() > 0) @@ -318,18 +318,18 @@ RigMainGrid* RimSimWellFracture::ownerCaseMainGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellFracture::updateBranchGeometry() +void RimSimWellFracture::computeSimWellBranchesIfRequired() { if (m_branchCenterLines.size() == 0) { - setBranchGeometry(); + computeSimWellBranchCenterLines(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellFracture::setBranchGeometry() +void RimSimWellFracture::computeSimWellBranchCenterLines() { m_branchCenterLines.clear(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h index 7b7f074d11..31d559c51c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h @@ -62,8 +62,8 @@ class RimSimWellFracture : public RimFracture RigMainGrid* ownerCaseMainGrid() const; private: - void updateBranchGeometry(); - void setBranchGeometry(); + void computeSimWellBranchesIfRequired(); + void computeSimWellBranchCenterLines(); private: caf::PdmField m_location; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp index 0b0974d089..438921e99d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -21,13 +21,10 @@ #include "RimSimWellFracture.h" #include "cafPdmObject.h" - - - CAF_PDM_SOURCE_INIT(RimSimWellFractureCollection, "SimWellFractureCollection"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::RimSimWellFractureCollection(void) { @@ -38,18 +35,28 @@ RimSimWellFractureCollection::RimSimWellFractureCollection(void) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::~RimSimWellFractureCollection() { simwellFractures.deleteAllChildObjects(); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSimWellFractureCollection::deleteFractures() { simwellFractures.deleteAllChildObjects(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSimWellFractureCollection::recomputeSimWellCenterlines() +{ + for (RimSimWellFracture* frac : simwellFractures()) + { + frac->recomputeWellCenterlineCoordinates(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h index d0d14b5848..9281fbb92a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h @@ -40,4 +40,5 @@ class RimSimWellFractureCollection : public caf::PdmObject void deleteFractures(); + void recomputeSimWellCenterlines(); }; diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 287e3301b7..1a93f228b0 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -32,7 +32,6 @@ #include "RimEclipseView.h" #include "RimIntersectionCollection.h" #include "RimProject.h" -#include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" #include "RimWellAllocationPlot.h" @@ -470,10 +469,8 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha for (RimSimWellInView* w : wells) { - for (RimSimWellFracture* frac : w->simwellFractureCollection()->simwellFractures()) - { - frac->recomputeWellCenterlineCoordinates(); - } + w->simwellFractureCollection()->recomputeSimWellCenterlines(); + } } } From 7bd0bdc612abb899c4eae3085553b53ac9d6384b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 13:54:42 +0100 Subject: [PATCH 0389/1027] #2483 Refactoring : Simplify generation of well branch geometry (1) --- .../RicExportFractureCompletionsImpl.cpp | 19 ++---------- .../ProjectDataModel/RimIntersection.cpp | 21 +++---------- .../ProjectDataModel/RimSimWellInView.cpp | 30 +++++++++++-------- .../ProjectDataModel/RimSimWellInView.h | 7 ++--- .../ReservoirDataModel/RigEclipseCaseData.cpp | 2 +- .../ReservoirDataModel/RigEclipseCaseData.h | 4 +-- 6 files changed, 31 insertions(+), 52 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index a785662e44..e11e605814 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -87,23 +87,10 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat { std::vector completionData; - std::vector< std::vector > pipeBranchesCLCoords; - std::vector< std::vector > pipeBranchesCellIds; - - RimEclipseView* view = nullptr; - well->firstAncestorOrThisOfTypeAsserted(view); - - size_t timeStep = view->currentTimeStep(); + auto branches = well->wellPipeBranches(); - well->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds); - - for (size_t branchIndex = 0; branchIndex < pipeBranchesCLCoords.size(); ++branchIndex) + for (size_t branchIndex = 0; branchIndex < branches.size(); ++branchIndex) { - RigSimulationWellCoordsAndMD coordsAndMD(pipeBranchesCLCoords[branchIndex]); - RigWellPath wellPathGeometry; - wellPathGeometry.m_wellPathPoints = coordsAndMD.wellPathPoints(); - wellPathGeometry.m_measuredDepths = coordsAndMD.measuredDepths(); - std::vector fractures; for (RimSimWellFracture* fracture : well->simwellFractureCollection->simwellFractures()) { @@ -113,7 +100,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat } } - std::vector branchCompletions = generateCompdatValues(eclipseCase, well->name(), &wellPathGeometry, fractures, outputStreamForIntermediateResultsText); + std::vector branchCompletions = generateCompdatValues(eclipseCase, well->name(), branches[branchIndex], fractures, outputStreamForIntermediateResultsText); completionData.insert(completionData.end(), branchCompletions.begin(), branchCompletions.end()); } diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 6d288fdcbe..41e679d7f4 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -490,25 +490,12 @@ void RimIntersection::updateSimulationWellCenterline() const { if (isActive() && type == CS_SIMULATION_WELL && simulationWell()) { - if (m_simulationWellBranchCenterlines.size() == 0) + if (m_simulationWellBranchCenterlines.empty()) { - RimEclipseCase* rimEclCase = nullptr; - simulationWell->firstAncestorOrThisOfType(rimEclCase); - if (rimEclCase) + auto branches = simulationWell->wellPipeBranches(); + for (const auto& branch : branches) { - RimSimWellInViewCollection* simWellCollection = nullptr; - simulationWell->firstAncestorOrThisOfTypeAsserted(simWellCollection); - - bool includeCellCenters = simulationWell->isUsingCellCenterForPipe(); - bool detectBrances = simWellCollection->isAutoDetectingBranches; - - RigEclipseCaseData* caseData = rimEclCase->eclipseCaseData(); - auto branches = caseData->simulationWellBranches(simulationWell->name, includeCellCenters, detectBrances); - - for (auto b : branches) - { - m_simulationWellBranchCenterlines.push_back(b->m_wellPathPoints); - } + m_simulationWellBranchCenterlines.push_back(branch->m_wellPathPoints); } } } diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 7fe522cbb6..997a26e42c 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -156,25 +156,31 @@ caf::PdmFieldHandle* RimSimWellInView::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::calculateWellPipeStaticCenterLine(std::vector>& pipeBranchesCLCoords, - std::vector>& pipeBranchesCellIds) +std::vector RimSimWellInView::wellPipeBranches() const { - RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(this, - pipeBranchesCLCoords, - pipeBranchesCellIds); + RimSimWellInViewCollection* simWellCollection = nullptr; + this->firstAncestorOrThisOfTypeAsserted(simWellCollection); + + RimEclipseCase* eclipseCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(eclipseCase); + RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); + CVF_ASSERT(caseData); + + bool includeCellCenters = this->isUsingCellCenterForPipe(); + bool detectBrances = simWellCollection->isAutoDetectingBranches; + + return caseData->simulationWellBranches(this->name(), includeCellCenters, detectBrances); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::calculateWellPipeDynamicCenterLine(size_t timeStepIdx, - std::vector>& pipeBranchesCLCoords, - std::vector>& pipeBranchesCellIds) const +void RimSimWellInView::calculateWellPipeStaticCenterLine(std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds) { - RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(this, - static_cast(timeStepIdx), - pipeBranchesCLCoords, - pipeBranchesCellIds); + RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(this, + pipeBranchesCLCoords, + pipeBranchesCellIds); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index e066ca48cf..b2a0dc94c8 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -37,6 +37,7 @@ class RigWellResultFrame; struct RigWellResultPoint; class RimSimWellFractureCollection; +class RigWellPath; //================================================================================================== /// @@ -64,13 +65,11 @@ class RimSimWellInView : public caf::PdmObject virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; + std::vector wellPipeBranches() const; + void calculateWellPipeStaticCenterLine( std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds); - void calculateWellPipeDynamicCenterLine(size_t timeStepIdx, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) const; - void wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); caf::PdmField showWell; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index 477edc830c..2bbe793d56 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -474,7 +474,7 @@ bool RigEclipseCaseData::hasSimulationWell(const QString& simWellName) const //-------------------------------------------------------------------------------------------------- std::vector RigEclipseCaseData::simulationWellBranches(const QString& simWellName, bool includeAllCellCenters, - bool useAutoDetectionOfBranches) + bool useAutoDetectionOfBranches) const { std::vector branches; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index 0a2f0e83d9..7c59f2fea1 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -108,7 +108,7 @@ class RigEclipseCaseData : public cvf::Object std::vector simulationWellBranches(const QString& simWellName, bool includeAllCellCenters, - bool useAutoDetectionOfBranches); + bool useAutoDetectionOfBranches) const; private: void computeActiveCellIJKBBox(); @@ -133,5 +133,5 @@ class RigEclipseCaseData : public cvf::Object RiaEclipseUnitTools::UnitSystem m_unitsType; - std::map, cvf::Collection> m_simWellBranchCache; + mutable std::map, cvf::Collection> m_simWellBranchCache; }; From 08995cf63eb1e9fa7723ef772092f8e8955b0d2d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 14:07:31 +0100 Subject: [PATCH 0390/1027] #2483 Refactoring : Simplify generation of well branch geometry (2) --- .../RigSimulationWellCenterLineCalculator.cpp | 13 +------------ .../RigSimulationWellCenterLineCalculator.h | 6 ------ 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 35eaede582..ed27f393d3 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -43,18 +43,6 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) -{ - calculateWellPipeDynamicCenterline(rimWell, -1, pipeBranchesCLCoords, pipeBranchesCellIds); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(const RimSimWellInView* rimWell, - int timeStepIndex, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) { CVF_ASSERT(rimWell); @@ -69,6 +57,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(c bool isAutoDetectBranches = eclipseView->wellCollection()->isAutoDetectingBranches(); bool useAllCellCenters = rimWell->isUsingCellCenterForPipe(); + int timeStepIndex = -1; calculateWellPipeCenterlineFromWellFrame(eclipseCaseData, simWellData, diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h index 9a2d85a2a8..1eaf5f2e61 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h @@ -32,12 +32,6 @@ class RigSimulationWellCenterLineCalculator std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) ; - static void calculateWellPipeDynamicCenterline(const RimSimWellInView* rimWell, - int timeStepIndex, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) ; - - static void calculateWellPipeCenterlineFromWellFrame(const RigEclipseCaseData* eclipseCaseData, const RigSimWellData* simWellData, int timeStepIndex, From bb0f0266446bb56701741b3c6ba087db70e14021 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 14:09:46 +0100 Subject: [PATCH 0391/1027] Whitespace --- .../RigSimulationWellCenterLineCalculator.cpp | 17 ++++++----- .../RigSimulationWellCenterLineCalculator.h | 29 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index ed27f393d3..2d47615e51 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -40,13 +40,14 @@ /// The returned CellIds is one less than the number of centerline points, /// and are describing the lines between the points, starting with the first line //-------------------------------------------------------------------------------------------------- -void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) +void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline( + RimSimWellInView* rimWell, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds) { CVF_ASSERT(rimWell); - const RigSimWellData* simWellData = rimWell->simWellData(); + const RigSimWellData* simWellData = rimWell->simWellData(); RimEclipseView* eclipseView; rimWell->firstAncestorOrThisOfType(eclipseView); @@ -54,17 +55,17 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(Ri CVF_ASSERT(eclipseView); RigEclipseCaseData* eclipseCaseData = eclipseView->eclipseCase()->eclipseCaseData(); - bool isAutoDetectBranches = eclipseView->wellCollection()->isAutoDetectingBranches(); + bool isAutoDetectBranches = eclipseView->wellCollection()->isAutoDetectingBranches(); - bool useAllCellCenters = rimWell->isUsingCellCenterForPipe(); - int timeStepIndex = -1; + bool useAllCellCenters = rimWell->isUsingCellCenterForPipe(); + int timeStepIndex = -1; calculateWellPipeCenterlineFromWellFrame(eclipseCaseData, simWellData, timeStepIndex, isAutoDetectBranches, useAllCellCenters, - pipeBranchesCLCoords, + pipeBranchesCLCoords, pipeBranchesCellIds); } diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h index 1eaf5f2e61..ec87e69112 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h @@ -19,28 +19,33 @@ #pragma once #include "RigSimWellData.h" + #include "cvfVector3.h" + #include class RigEclipseCaseData; class RimSimWellInView; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigSimulationWellCenterLineCalculator { public: - static void calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) ; - - static void calculateWellPipeCenterlineFromWellFrame(const RigEclipseCaseData* eclipseCaseData, - const RigSimWellData* simWellData, - int timeStepIndex, - bool isAutoDetectBranches, - bool useAllCellCenters, - std::vector> &pipeBranchesCLCoords, - std::vector> &pipeBranchesCellIds); -private: + static void calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds); + static void calculateWellPipeCenterlineFromWellFrame(const RigEclipseCaseData* eclipseCaseData, + const RigSimWellData* simWellData, + int timeStepIndex, + bool isAutoDetectBranches, + bool useAllCellCenters, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds); + +private: static bool hasAnyResultCells(const std::vector &resBranches); static bool hasAnyValidDataCells(const RigWellResultBranch& branch); static void finishPipeCenterLine( std::vector< std::vector > &pipeBranchesCLCoords, const cvf::Vec3d& lastCellCenter ) ; From ef2179f1ba1824e22ad22e210a97ae8fa6605638 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 1 Mar 2018 07:51:30 +0100 Subject: [PATCH 0392/1027] #2545 Move fields from public to private --- .../RicfExportProperty.cpp | 6 +- .../RicfExportSimWellCompletions.cpp | 6 +- .../RicEclipsePropertyFilterFeatureImpl.cpp | 2 +- ...cEclipsePropertyFilterNewInViewFeature.cpp | 2 +- .../RicShowWellAllocationPlotFeature.cpp | 4 +- .../RicNewSimWellFractureAtPosFeature.cpp | 2 +- .../RicNewSimWellFractureFeature.cpp | 2 +- .../RicNewWellPathFractureFeature.cpp | 2 +- .../RivWellFracturePartMgr.cpp | 26 +-- .../RimFractureTemplateCollection.cpp | 12 +- .../RimStimPlanFractureTemplate.cpp | 2 +- .../RimEclipseStatisticsCase.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 183 +++++++++++------- .../ProjectDataModel/RimEclipseView.h | 46 +++-- .../ProjectDataModel/RimIntersection.cpp | 2 +- .../SocketInterface/RiaNNCCommands.cpp | 2 +- .../RiaPropertyDataCommands.cpp | 4 +- .../RiuExportMultipleSnapshotsWidget.cpp | 4 +- .../UserInterface/RiuMainWindow.cpp | 2 +- 19 files changed, 182 insertions(+), 129 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp index 325b129b20..6b085884fa 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp @@ -104,9 +104,9 @@ void RicfExportProperty::execute() m_eclipseKeyword = m_propertyName; } - view->cellResult->setResultType(m_type()); - view->cellResult->setResultVariable(m_propertyName()); + view->cellResult()->setResultType(m_type()); + view->cellResult()->setResultVariable(m_propertyName()); view->loadDataAndUpdate(); - RifEclipseInputFileTools::writeBinaryResultToTextFile(filePath, eclipseCase->eclipseCaseData(), m_timeStepIndex, view->cellResult, m_eclipseKeyword, m_undefinedValue); + RifEclipseInputFileTools::writeBinaryResultToTextFile(filePath, eclipseCase->eclipseCaseData(), m_timeStepIndex, view->cellResult(), m_eclipseKeyword, m_undefinedValue); } diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 15f917e0e2..2bd3fd409a 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -105,15 +105,15 @@ void RicfExportSimWellCompletions::execute() std::vector simWells; if (m_wellPathNames().empty()) { - std::copy(view->wellCollection->wells.begin(), - view->wellCollection->wells.end(), + std::copy(view->wellCollection()->wells.begin(), + view->wellCollection()->wells.end(), std::back_inserter(simWells)); } else { for (const QString& wellPathName : m_wellPathNames()) { - RimSimWellInView* simWell = view->wellCollection->findWell(wellPathName); + RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName); if (simWell) { simWells.push_back(simWell); diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index 743a986cfc..1a63a39bc9 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -119,7 +119,7 @@ void RicEclipsePropertyFilterFeatureImpl::setDefaults(RimEclipsePropertyFilter* propertyFilter->firstAncestorOrThisOfTypeAsserted(reservoirView); propertyFilter->resultDefinition->setEclipseCase(reservoirView->eclipseCase()); - propertyFilter->resultDefinition->simpleCopy(reservoirView->cellResult); + propertyFilter->resultDefinition->simpleCopy(reservoirView->cellResult()); propertyFilter->resultDefinition->loadResult(); propertyFilter->setToDefaultValues(); diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp index ede703b84a..48f4f6c1f3 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp @@ -45,7 +45,7 @@ bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled() RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return false; - RimEclipseCellColors* cellColors = eclView->cellResult().p(); + RimEclipseCellColors* cellColors = eclView->cellResult(); if (!cellColors) return false; if (RiaDefines::isPerCellFaceResult(cellColors->resultVariable())) return false; diff --git a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index d24c9c8616..856042ff5c 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -62,7 +62,7 @@ bool RicShowWellAllocationPlotFeature::isCommandEnabled() RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return false; - RimSimWellInView* simWellFromWellPath = eclView->wellCollection->findWell(wellPathCollection[0]->associatedSimulationWellName()); + RimSimWellInView* simWellFromWellPath = eclView->wellCollection()->findWell(wellPathCollection[0]->associatedSimulationWellName()); if (simWellFromWellPath) { @@ -96,7 +96,7 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; - simWell = eclView->wellCollection->findWell(wellPathCollection[0]->associatedSimulationWellName()); + simWell = eclView->wellCollection()->findWell(wellPathCollection[0]->associatedSimulationWellName()); if (!simWell) return; } else return; diff --git a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp index c5908f4511..e4a31058d3 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp @@ -75,7 +75,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (activeView) { - activeView->fractureColors->setDefaultResultName(); + activeView->fractureColors()->setDefaultResultName(); } } diff --git a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp index cf5949db89..b6e83e4ef8 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp @@ -69,7 +69,7 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (activeView) { - activeView->fractureColors->setDefaultResultName(); + activeView->fractureColors()->setDefaultResultName(); } } diff --git a/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index f578cc625f..36a3a18b0d 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -66,7 +66,7 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (activeView) { - activeView->fractureColors->setDefaultResultName(); + activeView->fractureColors()->setDefaultResultName(); } } diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 6cee288476..f37a43a0fa 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -85,7 +85,7 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr() //-------------------------------------------------------------------------------------------------- void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) { - if (!m_rimFracture->isChecked() || !eclView.fractureColors->isChecked()) return; + if (!m_rimFracture->isChecked() || !eclView.fractureColors()->isChecked()) return; if (!m_rimFracture->fractureTemplate()) return; @@ -96,7 +96,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (stimPlanFracTemplate) { - if (eclView.fractureColors->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) + if (eclView.fractureColors()->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) { auto part = createStimPlanElementColorSurfacePart(eclView); if (part.notNull()) parts.push_back(part.p()); @@ -107,7 +107,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod if (part.notNull()) parts.push_back(part.p()); } - if (eclView.fractureColors->showStimPlanMesh()) + if (eclView.fractureColors()->showStimPlanMesh()) { auto part = createStimPlanMeshPart(eclView); if (part.notNull()) parts.push_back(part.p()); @@ -249,7 +249,7 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ else if (stimPlanTemplate) { const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); - RimStimPlanColors* stimPlanColors = activeView.fractureColors; + RimStimPlanColors* stimPlanColors = activeView.fractureColors(); QString condValueText = cell ? QString::number(cell->getConductivtyValue()) : "-"; QString iText = cell ? QString::number(cell->getI()) : "-"; @@ -356,7 +356,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc surfacePart->setDrawable(geo.p()); surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - cvf::Color4f fractureColor = cvf::Color4f(activeView.fractureColors->defaultColor()); + cvf::Color4f fractureColor = cvf::Color4f(activeView.fractureColors()->defaultColor()); RimLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) @@ -368,7 +368,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc { cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); - if (activeView.fractureColors->uiResultName() == RiaDefines::conductivityResultName()) + if (activeView.fractureColors()->uiResultName() == RiaDefines::conductivityResultName()) { RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); if (ellipseFractureTemplate) @@ -437,7 +437,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa std::vector perNodeResultValues(nodeCoords.size(), HUGE_VAL); { size_t idx = 0; - const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors->uiResultName(), activeView.fractureColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); + const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors()->uiResultName(), activeView.fractureColors()->unit(), stimPlanFracTemplate->activeTimeStepIndex()); for (const std::vector& dataAtY : dataToPlot) { for (double val : dataAtY) @@ -507,7 +507,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa { // No result is mapped, show the entire StimPlan surface with default color - return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.fractureColors->defaultColor()); + return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.fractureColors()->defaultColor()); } return nullptr; @@ -564,8 +564,8 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar scalarMapper = legendConfig->scalarMapper(); - QString resultNameFromColors = activeView.fractureColors->uiResultName(); - QString resultUnitFromColors = activeView.fractureColors->unit(); + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, resultUnitFromColors, @@ -651,7 +651,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar { // No result is mapped, show the entire StimPlan surface with default color - return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.fractureColors->defaultColor()); + return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.fractureColors()->defaultColor()); } } @@ -874,8 +874,8 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); std::vector stimPlanMeshVertices; - QString resultNameFromColors = activeView.fractureColors->uiResultName(); - QString resultUnitFromColors = activeView.fractureColors->unit(); + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, resultUnitFromColors, diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 2a9c8995bb..99d4292b45 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -332,7 +332,7 @@ void RimFractureTemplateCollection::initAfterRead() { if (setAllShowMeshToFalseOnAllEclipseViews) { - eclipseView->fractureColors->setShowStimPlanMesh(false); + eclipseView->fractureColors()->setShowStimPlanMesh(false); continue; } @@ -340,9 +340,9 @@ void RimFractureTemplateCollection::initAfterRead() std::map stimPlanFractureTemplatesInView; std::vector fractures; - if (eclipseView->wellCollection) + if (eclipseView->wellCollection()) { - eclipseView->wellCollection->descendantsIncludingThisOfType(fractures); + eclipseView->wellCollection()->descendantsIncludingThisOfType(fractures); } if (fractures.empty()) continue; @@ -361,7 +361,7 @@ void RimFractureTemplateCollection::initAfterRead() if (stimPlanFractureTemplatesInView.size() == 1) { - eclipseView->fractureColors->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); + eclipseView->fractureColors()->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); } else { @@ -376,11 +376,11 @@ void RimFractureTemplateCollection::initAfterRead() } if (anySetShowStimPlanMeshIsSetToFalse) { - eclipseView->fractureColors->setShowStimPlanMesh(false); + eclipseView->fractureColors()->setShowStimPlanMesh(false); } else { - eclipseView->fractureColors->setShowStimPlanMesh(true); + eclipseView->fractureColors()->setShowStimPlanMesh(true); } } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index b26844710b..e32df92367 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -284,7 +284,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() // Todo: Must update all views using this fracture template RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); - if (activeView) activeView->fractureColors->loadDataAndUpdate(); + if (activeView) activeView->fractureColors()->loadDataAndUpdate(); updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index d9f5f323d3..68c7cc305e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -686,7 +686,7 @@ void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() if (reservoirViews[i]) { // As new result might have been introduced, update all editors connected - reservoirViews[i]->cellResult->updateConnectedEditors(); + reservoirViews[i]->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 diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 079e4b25fc..4e7ebe25b4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -109,38 +109,38 @@ RimEclipseView::RimEclipseView() CAF_PDM_InitObject("Reservoir View", ":/3DView16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); - cellResult = new RimEclipseCellColors(); - cellResult.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); + m_cellResult = new RimEclipseCellColors(); + m_cellResult.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", ""); - cellEdgeResult = new RimCellEdgeColors(); - cellEdgeResult.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", ""); + m_cellEdgeResult = new RimCellEdgeColors(); + m_cellEdgeResult.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", ""); - faultResultSettings = new RimEclipseFaultColors(); - faultResultSettings.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", ""); + m_faultResultSettings = new RimEclipseFaultColors(); + m_faultResultSettings.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&fractureColors, "StimPlanColors", "Fracture", "", "", ""); - fractureColors = new RimStimPlanColors(); - fractureColors.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_fractureColors, "StimPlanColors", "Fracture", "", "", ""); + m_fractureColors = new RimStimPlanColors(); + m_fractureColors.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", ""); - wellCollection = new RimSimWellInViewCollection; - wellCollection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_wellCollection, "WellCollection", "Simulation Wells", "", "", ""); + m_wellCollection = new RimSimWellInViewCollection; + m_wellCollection.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&faultCollection, "FaultCollection", "Faults", "", "", ""); - faultCollection = new RimFaultInViewCollection; - faultCollection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_faultCollection, "FaultCollection", "Faults", "", "", ""); + m_faultCollection = new RimFaultInViewCollection; + m_faultCollection.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); m_propertyFilterCollection = new RimEclipsePropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiHidden(true); // Visualization fields - CAF_PDM_InitField(&showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", ""); - CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", ""); - CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", ""); + CAF_PDM_InitField(&m_showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", ""); + CAF_PDM_InitField(&m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", ""); + CAF_PDM_InitField(&m_showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", ""); this->cellResult()->setReservoirView(this); @@ -174,6 +174,54 @@ RimEclipseView::~RimEclipseView() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCellColors* RimEclipseView::cellResult() const +{ + return m_cellResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellEdgeColors* RimEclipseView::cellEdgeResult() const +{ + return m_cellEdgeResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseFaultColors* RimEclipseView::faultResultSettings() const +{ + return m_faultResultSettings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStimPlanColors* RimEclipseView::fractureColors() const +{ + return m_fractureColors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInViewCollection* RimEclipseView::wellCollection() const +{ + return m_wellCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultInViewCollection* RimEclipseView::faultCollection() const +{ + return m_faultCollection; +} + //-------------------------------------------------------------------------------------------------- /// Clamp the current timestep to actual possibilities //-------------------------------------------------------------------------------------------------- @@ -216,14 +264,14 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c { Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &showInvalidCells) + if (changedField == &m_showInvalidCells) { this->scheduleGeometryRegen(INACTIVE); this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); scheduleCreateDisplayModelAndRedraw(); } - else if (changedField == &showInactiveCells) + else if (changedField == &m_showInactiveCells) { this->updateGridBoxData(); @@ -232,7 +280,7 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c scheduleCreateDisplayModelAndRedraw(); } - else if (changedField == &showMainGrid) + else if (changedField == &m_showMainGrid) { scheduleCreateDisplayModelAndRedraw(); } @@ -324,7 +372,7 @@ void RimEclipseView::createDisplayModel() // The parts are still cached in the RivReservoir geometry and friends m_viewer->removeAllFrames(); - wellCollection->scheduleIsWellPipesVisibleRecalculation(); + wellCollection()->scheduleIsWellPipesVisibleRecalculation(); // Create vector of grid indices to render std::vector gridIndices; @@ -427,38 +475,13 @@ void RimEclipseView::createDisplayModel() m_crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); - - // Compute triangle count, Debug only -/* - if (false) - { - size_t totalTriangleCount = 0; - { - size_t mIdx; - for (mIdx = 0; mIdx < frameModels.size(); mIdx++) - { - cvf::Collection partCollection; - frameModels.at(mIdx)->allParts(&partCollection); - - size_t modelTriangleCount = 0; - size_t pIdx; - for (pIdx = 0; pIdx < partCollection.size(); pIdx++) - { - modelTriangleCount += partCollection.at(pIdx)->drawable()->triangleCount(); - } - - totalTriangleCount += modelTriangleCount; - } - } - } -*/ // Well path model m_wellPathPipeVizModel->removeAllParts(); // NB! StimPlan legend colors must be updated before well path geometry is added to the model // as the fracture geometry depends on the StimPlan legend colors - fractureColors->updateLegendData(); + fractureColors()->updateLegendData(); addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); @@ -731,7 +754,7 @@ void RimEclipseView::updateCurrentTimeStep() // Invisible Wells are marked as read only when "show wells intersecting visible cells" is enabled // Visibility of wells differ betweeen time steps, so trigger a rebuild of tree state items - wellCollection->updateConnectedEditors(); + wellCollection()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -760,7 +783,7 @@ void RimEclipseView::onLoadDataAndUpdate() this->cellEdgeResult()->loadResult(); this->faultResultSettings()->customFaultResult()->loadResult(); - this->fractureColors->loadDataAndUpdate(); + this->fractureColors()->loadDataAndUpdate(); updateMdiWindowVisibility(); @@ -866,14 +889,14 @@ void RimEclipseView::updateDisplayModelVisibility() { Rim3dView::updateDisplayModelVisibility(); - faultCollection->updateConnectedEditors(); + faultCollection()->updateConnectedEditors(); // This is required to update the read-only state of simulation wells // when a range filter is manipulated and visible simulation wells might change // // The visibility is controlled by RimEclipseWell::defineUiTreeOrdering // updateConnectedEditors will call recursively on child objects - wellCollection->updateConnectedEditors(); + wellCollection()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -883,7 +906,7 @@ RigCaseCellResultsData* RimEclipseView::currentGridCellResults() { if (m_eclipseCase) { - return m_eclipseCase->results(cellResult->porosityModel()); + return m_eclipseCase->results(cellResult()->porosityModel()); } return nullptr; @@ -898,7 +921,7 @@ RigActiveCellInfo* RimEclipseView::currentActiveCellInfo() m_eclipseCase->eclipseCaseData() ) { - return m_eclipseCase->eclipseCaseData()->activeCellInfo(cellResult->porosityModel()); + return m_eclipseCase->eclipseCaseData()->activeCellInfo(cellResult()->porosityModel()); } return nullptr; @@ -1035,7 +1058,7 @@ void RimEclipseView::updateLegends() RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); if (stimPlanLegend) { - fractureColors->updateLegendData(); + fractureColors()->updateLegendData(); if (fractureColors()->isChecked() && stimPlanLegend->legend()) { @@ -1308,7 +1331,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { bool isDependingOnCompletionType = false; - if (cellResult->isCompletionTypeSelected()) + if (cellResult()->isCompletionTypeSelected()) { isDependingOnCompletionType = true; } @@ -1361,9 +1384,9 @@ void RimEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup("Cell Visibility"); - cellGroup->add(&showMainGrid); - cellGroup->add(&showInactiveCells); - cellGroup->add(&showInvalidCells); + cellGroup->add(&m_showMainGrid); + cellGroup->add(&m_showInactiveCells); + cellGroup->add(&m_showInvalidCells); } //-------------------------------------------------------------------------------------------------- @@ -1392,7 +1415,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } uiTreeOrdering.add(faultCollection()); - uiTreeOrdering.add(m_crossSectionCollection()); + uiTreeOrdering.add(crossSectionCollection()); uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); @@ -1454,15 +1477,15 @@ bool RimEclipseView::isTimeStepDependentDataVisible() const if (this->eclipsePropertyFilterCollection()->hasActiveDynamicFilters()) return true; - if (this->wellCollection->hasVisibleWellPipes()) return true; + if (this->wellCollection()->hasVisibleWellPipes()) return true; if (this->cellResult()->isTernarySaturationSelected()) return true; - if (this->faultResultSettings->showCustomFaultResult()) + if (this->faultResultSettings()->showCustomFaultResult()) { - if (this->faultResultSettings->customFaultResult()->hasDynamicResult()) return true; + if (this->faultResultSettings()->customFaultResult()->hasDynamicResult()) return true; - if (this->faultResultSettings->customFaultResult()->isTernarySaturationSelected()) return true; + if (this->faultResultSettings()->customFaultResult()->isTernarySaturationSelected()) return true; } if (this->wellPathCollection()->anyWellsContainingPerforationIntervals()) return true; @@ -1607,7 +1630,7 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV //-------------------------------------------------------------------------------------------------- bool RimEclipseView::showActiveCellsOnly() { - return !showInactiveCells; + return !m_showInactiveCells; } //-------------------------------------------------------------------------------------------------- @@ -1675,6 +1698,30 @@ bool RimEclipseView::isUsingFormationNames() const return eclipsePropertyFilterCollection()->isUsingFormationNames(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showInvalidCells() const +{ + return m_showInvalidCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showInactiveCells() const +{ + return m_showInactiveCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showMainGrid() const +{ + return m_showMainGrid; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index db6aea08e9..f91fec8c20 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -75,24 +75,19 @@ class RimEclipseView : public RimGridView { CAF_PDM_HEADER_INIT; public: - RimEclipseView(void); - virtual ~RimEclipseView(void); - - // Fields containing child objects : - - caf::PdmChildField cellResult; - caf::PdmChildField cellEdgeResult; - caf::PdmChildField faultResultSettings; - caf::PdmChildField fractureColors; - - caf::PdmChildField wellCollection; - caf::PdmChildField faultCollection; - - // Fields - - caf::PdmField showInvalidCells; - caf::PdmField showInactiveCells; - caf::PdmField showMainGrid; + RimEclipseView(); + virtual ~RimEclipseView(); + + RimEclipseCellColors* cellResult() const; + RimCellEdgeColors* cellEdgeResult() const; + RimEclipseFaultColors* faultResultSettings() const; + RimStimPlanColors* fractureColors() const; + RimSimWellInViewCollection* wellCollection() const; + RimFaultInViewCollection* faultCollection() const; + + bool showInvalidCells() const; + bool showInactiveCells() const; + bool showMainGrid() const; // Access internal objects virtual const RimPropertyFilterCollection* propertyFilterCollection() const override; @@ -113,7 +108,7 @@ class RimEclipseView : public RimGridView // Display model generation - bool isTimeStepDependentDataVisible() const; + bool isTimeStepDependentDataVisible() const override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; void scheduleReservoirGridGeometryRegen(); @@ -173,6 +168,18 @@ class RimEclipseView : public RimGridView void setVisibleGridPartsWatertight(); private: + caf::PdmField m_showInvalidCells; + caf::PdmField m_showInactiveCells; + caf::PdmField m_showMainGrid; + + caf::PdmChildField m_cellResult; + caf::PdmChildField m_cellEdgeResult; + caf::PdmChildField m_faultResultSettings; + caf::PdmChildField m_fractureColors; + + caf::PdmChildField m_wellCollection; + caf::PdmChildField m_faultCollection; + caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; @@ -183,4 +190,3 @@ class RimEclipseView : public RimGridView std::vector m_visibleGridParts; }; - diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 41e679d7f4..bbb6d39b8f 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -360,7 +360,7 @@ RimSimWellInViewCollection* RimIntersection::simulationWellCollection() if (eclipseView) { - return eclipseView->wellCollection; + return eclipseView->wellCollection(); } return nullptr; diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index dba1cbbca1..c006605691 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -546,7 +546,7 @@ class RiaSetNNCProperty: public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->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 diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 2bf5284892..fe13dadc8c 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -686,7 +686,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->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 @@ -1050,7 +1050,7 @@ class RiaSetGridProperty : public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->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 diff --git a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp index 3f79dc26c0..273d6f655a 100644 --- a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp +++ b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp @@ -147,8 +147,8 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItemFromActiveView() RimEclipseView* eclipseView = dynamic_cast(activeView); if (eclipseView) { - multiSnapshot->eclipseResultType = eclipseView->cellResult->resultType(); - multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult->resultVariable()); + multiSnapshot->eclipseResultType = eclipseView->cellResult()->resultType(); + multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult()->resultVariable()); } multiSnapshot->timeStepStart = activeView->currentTimeStep(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 7beb521680..df2ac94df1 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1479,7 +1479,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) RimEclipseView* activeRiv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (!activeRiv) return; - activeRiv->faultCollection->showFaultLabel.setValueWithFieldChanged(showLabels); + activeRiv->faultCollection()->showFaultLabel.setValueWithFieldChanged(showLabels); refreshDrawStyleActions(); } From 48419480fa40a1ae5b195777095e110392025a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 2 Mar 2018 14:33:47 +0100 Subject: [PATCH 0393/1027] #2505 CommandFile. Add scaleFractureTemplate command. Currently accepting arguments width and height --- .../CMakeLists_files.cmake | 2 + .../RicfScaleFractureTemplate.cpp | 71 +++++++++++++++++++ .../RicfScaleFractureTemplate.h | 45 ++++++++++++ .../RimEllipseFractureTemplate.cpp | 27 ++++--- .../Completions/RimEllipseFractureTemplate.h | 1 + .../Completions/RimFractureTemplate.cpp | 9 +++ .../Completions/RimFractureTemplate.h | 2 + .../RimFractureTemplateCollection.cpp | 12 ++++ .../RimFractureTemplateCollection.h | 1 + .../RimStimPlanFractureTemplate.cpp | 28 +++++--- .../Completions/RimStimPlanFractureTemplate.h | 1 + 11 files changed, 180 insertions(+), 19 deletions(-) create mode 100644 ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp create mode 100644 ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h diff --git a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake index 17a4ec775b..7484d1c208 100644 --- a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake @@ -18,6 +18,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h +${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -39,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp new file mode 100644 index 0000000000..97a540a37f --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp @@ -0,0 +1,71 @@ +#include "RicfSetExportFolder.h" +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicfScaleFractureTemplate.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimProject.h" +#include "RimFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +CAF_PDM_SOURCE_INIT(RicfScaleFractureTemplate, "scaleFractureTemplate"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicfScaleFractureTemplate::RicfScaleFractureTemplate() +{ + RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); + RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", ""); + RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfScaleFractureTemplate::execute() +{ + if (m_id < 0) + { + RiaLogging::error("scaleFractureTemplate: Fracture template id not specified"); + return; + } + + RimProject* project = RiaApplication::instance()->project(); + + if (!project) + { + RiaLogging::error("scaleFractureTemplate: Project not found"); + return; + } + + RimFractureTemplateCollection* templColl = !project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr; + RimFractureTemplate* templ = templColl ? templColl->fractureTemplate(m_id) : nullptr; + + if (!templ) + { + RiaLogging::error(QString("scaleFractureTemplate: Fracture template not found. Id=%1").arg(m_id)); + return; + } + + templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor); + templ->reload(); +} diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h new file mode 100644 index 0000000000..148be060e7 --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "RicfCommandFileExecutor.h" + +#include "cafPdmField.h" + +//================================================================================================== +// +// +// +//================================================================================================== +class RicfScaleFractureTemplate : public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicfScaleFractureTemplate(); + + virtual void execute() override; + +private: + caf::PdmField m_id; + caf::PdmField m_widthScaleFactor; + caf::PdmField m_heightScaleFactor; +}; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 32cc5da026..a67828c07e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -93,16 +93,12 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha || changedField == &m_userDefinedEffectivePermeability || changedField == &m_sizeScaleApplyButton) { + m_sizeScaleApplyButton = false; + //Changes to one of these parameters should change all fractures with this fracture template attached. - RimProject* proj; - this->firstAncestorOrThisOfType(proj); - if (proj) - { - //Regenerate geometry - proj->createDisplayModelAndRedrawAllViews(); - setupFractureGridCells(); - } + reload(); } + if (changedField == &m_width || changedField == &m_userDefinedEffectivePermeability) { setupFractureGridCells(); @@ -322,6 +318,21 @@ std::vector> RimEllipseFractureTemplate::uiResultNam return propertyNamesAndUnits; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::reload() +{ + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + //Regenerate geometry + proj->createDisplayModelAndRedrawAllViews(); + setupFractureGridCells(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 1166429c43..85ec958522 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -64,6 +64,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate void loadDataAndUpdate() override; std::vector> uiResultNamesWithUnit() const override; + virtual void reload() override; protected: void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 976ac886a7..dcbd73a9fb 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -657,6 +657,15 @@ void RimFractureTemplate::setId(int id) m_id = id; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setScaleFactors(double width, double height) +{ + m_widthScaleFactor = width; + m_heightScaleFactor = height; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 8aa1746957..aca2ecd583 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -144,6 +144,8 @@ class RimFractureTemplate : public caf::PdmObject void disconnectAllFracturesAndRedrawViews() const; void setId(int id); + void setScaleFactors(double width, double height); + virtual void reload() {} protected: virtual caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 99d4292b45..b1e7b15796 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -72,6 +72,18 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection() m_fractureDefinitions.deleteAllChildObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate* RimFractureTemplateCollection::fractureTemplate(int id) const +{ + for (auto templ : m_fractureDefinitions) + { + if (templ->id() == id) return templ; + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 2852a30afc..11e919556d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -38,6 +38,7 @@ class RimFractureTemplateCollection : public caf::PdmObject RimFractureTemplateCollection(void); virtual ~RimFractureTemplateCollection(void); + RimFractureTemplate* fractureTemplate(int id) const; std::vector fractureTemplates() const; void addFractureTemplate(RimFractureTemplate* templ); RiaEclipseUnitTools::UnitSystemType defaultUnitSystemType() const; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index e32df92367..bb70c74135 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -155,17 +155,7 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch if (changedField == &m_sizeScaleApplyButton) { m_sizeScaleApplyButton = false; - loadDataAndUpdate(); - //setDefaultsBasedOnXMLfile(); - - updateFractureGrid(); - - RimProject* proj; - this->firstAncestorOrThisOfType(proj); - if (proj) - { - proj->createDisplayModelAndRedrawAllViews(); - } + reload(); } } @@ -548,6 +538,22 @@ void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitS } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::reload() +{ + loadDataAndUpdate(); + + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index e4b4a34d4a..439109b6a6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -91,6 +91,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + virtual void reload() override; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From fbe3e4fbda2b597a1f799109f45dd69a5af80819 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 15:16:43 +0100 Subject: [PATCH 0394/1027] #2483 Intersections : Keep branch index in intersection when switching branch detection mode --- .../ProjectDataModel/RimIntersection.cpp | 35 +++++++++++++++---- .../ProjectDataModel/RimIntersection.h | 7 ++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index bbb6d39b8f..43561a5f17 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -353,7 +353,7 @@ caf::PdmFieldHandle* RimIntersection::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSimWellInViewCollection* RimIntersection::simulationWellCollection() +RimSimWellInViewCollection* RimIntersection::simulationWellCollection() const { RimEclipseView* eclipseView = nullptr; firstAncestorOrThisOfType(eclipseView); @@ -411,12 +411,14 @@ std::vector< std::vector > RimIntersection::polyLines(double * hori { updateSimulationWellCenterline(); - if (0 <= m_branchIndex && m_branchIndex < static_cast(m_simulationWellBranchCenterlines.size())) + int branchIndexToUse = branchIndex(); + + if (0 <= branchIndexToUse && branchIndexToUse < static_cast(m_simulationWellBranchCenterlines.size())) { - lines.push_back(m_simulationWellBranchCenterlines[m_branchIndex]); + lines.push_back(m_simulationWellBranchCenterlines[branchIndexToUse]); } - if (m_branchIndex == -1) + if (branchIndexToUse == -1) { lines = m_simulationWellBranchCenterlines; } @@ -587,9 +589,9 @@ void RimIntersection::updateName() if (type == CS_SIMULATION_WELL && simulationWell()) { name = simulationWell()->name(); - if (m_branchIndex() != -1) + if (branchIndex() != -1) { - name = name() + " Branch " + QString::number(m_branchIndex() + 1); + name = name() + " Branch " + QString::number(branchIndex() + 1); } } else if (type() == CS_WELL_PATH && wellPath()) @@ -658,6 +660,26 @@ void RimIntersection::clipToReservoir(std::vector &polyLine, double polyLine.swap(clippedPolyLine); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimIntersection::branchIndex() const +{ + RimSimWellInViewCollection* coll = simulationWellCollection(); + + if (coll && !coll->isAutoDetectingBranches()) + { + return -1; + } + + if (m_branchIndex >= m_simulationWellBranchCenterlines.size()) + { + return -1; + } + + return m_branchIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -881,7 +903,6 @@ void RimIntersection::recomputeSimulationWellBranchData() { m_simulationWellBranchCenterlines.clear(); updateSimulationWellCenterline(); - m_branchIndex = -1; m_crossSectionPartMgr = nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 3c23c61c49..f8491c416d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -114,7 +114,10 @@ class RimIntersection : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - + +private: + int branchIndex() const; + private: caf::PdmField m_branchIndex; caf::PdmField m_extentLength; @@ -130,7 +133,7 @@ class RimIntersection : public caf::PdmObject static void setPushButtonText(bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute); static void setBaseColor(bool enable, caf::PdmUiListEditorAttribute* attribute); - RimSimWellInViewCollection* simulationWellCollection(); + RimSimWellInViewCollection* simulationWellCollection() const; void updateAzimuthLine(); void updateSimulationWellCenterline() const; void updateWellExtentDefaultValue(); From 2d01824ab3f97a6578eeaf74cd669f5a79b1e6dd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 2 Mar 2018 17:03:01 +0100 Subject: [PATCH 0395/1027] #2560 Unit conversion : Add conversion based on parsing unit text string --- .../Application/Tools/RiaEclipseUnitTools.cpp | 55 ++++++++++++++ .../Application/Tools/RiaEclipseUnitTools.h | 3 + .../UnitTests/CMakeLists_files.cmake | 2 + .../UnitTests/RiaEclipseUnitTools-Test.cpp | 76 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp index 315a739039..a0c4d36cf7 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp @@ -124,3 +124,58 @@ QString RiaEclipseUnitTools::unitStringPressure(UnitSystem unitSystem) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& unitText) +{ + QString timmed = unitText.trimmed(); + + if (timmed.compare("m", Qt::CaseInsensitive) == 0) + { + return sourceValue; + } + else if (timmed.compare("cm", Qt::CaseInsensitive) == 0) + { + return sourceValue / 100.0; + } + else if (timmed.compare("in", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::inchToMeter(sourceValue); + } + else if (timmed.compare("ft", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::feetToMeter(sourceValue); + } + + return HUGE_VAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaEclipseUnitTools::convertToFeet(double sourceValue, const QString& unitText) +{ + QString timmed = unitText.trimmed(); + + if (timmed.compare("ft", Qt::CaseInsensitive) == 0) + { + return sourceValue; + } + else if (timmed.compare("in", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::inchToFeet(sourceValue); + } + else if (timmed.compare("cm", Qt::CaseInsensitive) == 0) + { + double meter = sourceValue / 100.0; + return RiaEclipseUnitTools::meterToFeet(meter); + } + else if (timmed.compare("m", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::meterToFeet(sourceValue); + } + + return HUGE_VAL; +} + diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h index 0f43e97a7d..476970a941 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h @@ -51,5 +51,8 @@ class RiaEclipseUnitTools static double convertSurfaceGasFlowRateToOilEquivalents(UnitSystem, double eclGasFlowRate); static QString unitStringPressure(UnitSystem unitSystem); + + static double convertToMeter(double sourceValue, const QString& unitText); + static double convertToFeet(double sourceValue, const QString& unitText); }; diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index bfb8bc7804..d64f1f53ed 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -38,6 +38,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp b/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp new file mode 100644 index 0000000000..30cdad6a7d --- /dev/null +++ b/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp @@ -0,0 +1,76 @@ +#include "gtest/gtest.h" + +#include "RiaEclipseUnitTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaEclipseUnitTools, TestConversionToMeter) +{ + double deltaRange = 1e-7; + + { + double sourceValue = RiaEclipseUnitTools::feetPerMeter(); + QString unitText = "ft"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::feetPerMeter() * 12.0; + QString unitText = "in"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 1.0; + QString unitText = "m"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 100.0; + QString unitText = "cm"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaEclipseUnitTools, TestConversionToFeet) +{ + double deltaRange = 1e-7; + + { + double sourceValue = 1.0; + QString unitText = "ft"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 1.0 * 12.0; + QString unitText = "in"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::meterPerFeet(); + QString unitText = "m"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::meterPerFeet() * 100.0; + QString unitText = "cm"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } +} From e386b031c111eacc603d163420daa35717f22334 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 4 Mar 2018 10:36:39 +0100 Subject: [PATCH 0396/1027] #2567 Fracture : Fix display of result values for all result types --- .../RivWellFracturePartMgr.cpp | 11 ++++++++-- .../RimStimPlanFractureTemplate.cpp | 20 +++++++++++++++++++ .../Completions/RimStimPlanFractureTemplate.h | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index f37a43a0fa..370845320d 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -251,7 +251,14 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); RimStimPlanColors* stimPlanColors = activeView.fractureColors(); - QString condValueText = cell ? QString::number(cell->getConductivtyValue()) : "-"; + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); + + double resultValue = stimPlanTemplate->resultValueAtIJ( + resultNameFromColors, resultUnitFromColors, stimPlanTemplate->activeTimeStepIndex(), cell->getI(), cell->getJ()); + + QString resultValueText = QString("%1").arg(resultValue); + QString iText = cell ? QString::number(cell->getI()) : "-"; QString jText = cell ? QString::number(cell->getJ()) : "-"; @@ -260,7 +267,7 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ QString resultName = stimPlanTemplate->mapUiResultNameToFileResultName(stimPlanColors->uiResultName()); text.append(resultName + " "); - text.append(condValueText + "\n"); + text.append(resultValueText + "\n"); // Cell index text.append("Cell Index: "); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index bb70c74135..03d9a58282 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -648,6 +648,26 @@ bool RimStimPlanFractureTemplate::hasConductivity() const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimStimPlanFractureTemplate::resultValueAtIJ(const QString& uiResultName, const QString& unitName, size_t timeStepIndex, size_t i, size_t j) +{ + auto values = resultValues(uiResultName, unitName, timeStepIndex); + + if (values.empty()) return HUGE_VAL; + + size_t adjustedI = i + 1; + size_t adjustedJ = j + 1; + + if (adjustedI >= fractureGrid()->iCellCount() || adjustedJ >= fractureGrid()->jCellCount()) + { + return HUGE_VAL; + } + + return values[adjustedJ][adjustedI]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 439109b6a6..0c01918497 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -78,6 +78,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate std::vector> resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; + double resultValueAtIJ(const QString& uiResultName, const QString& unitName, size_t timeStepIndex, size_t i, size_t j); void appendDataToResultStatistics(const QString& uiResultName, const QString& unit, From 454e0b31be18f1f3bfd5572832469e26c91f1020 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Mar 2018 09:43:06 +0100 Subject: [PATCH 0397/1027] #2559 Fracture Template : Fix unit conversion for width and conductivity --- .../Completions/RimFractureTemplate.h | 3 + .../RimStimPlanFractureTemplate.cpp | 33 +++++-- .../RigStimPlanFractureDefinition.cpp | 86 ++++++++++++++++--- .../RigStimPlanFractureDefinition.h | 8 +- 4 files changed, 108 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index aca2ecd583..92c04009a6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -55,7 +55,10 @@ class FractureWidthAndConductivity return false; } + // Unit : meter or feet double m_width; + + // Unit : mD (milliDarcy) double m_permeability; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 03d9a58282..1cba8a6d18 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -444,14 +444,30 @@ FractureWidthAndConductivity RimStimPlanFractureTemplate::widthAndConductivityAt { if (nameUnit.first == propertyNameForFractureWidth) { - auto data = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + double widthInRequiredUnit = HUGE_VAL; + { + auto resultValues = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + + double widthInFileUnitSystem = resultValues[wellCellIndex]; - double width = data[wellCellIndex]; + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) + { + QString unitText = nameUnit.second; - if (fabs(width) > 1e-20) + widthInRequiredUnit = RiaEclipseUnitTools::convertToMeter(widthInFileUnitSystem, unitText); + } + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) + { + QString unitText = nameUnit.second; + + widthInRequiredUnit = RiaEclipseUnitTools::convertToFeet(widthInFileUnitSystem, unitText); + } + } + + if (widthInRequiredUnit != HUGE_VAL && fabs(widthInRequiredUnit) > 1e-20) { - values.m_width = width; - values.m_permeability = conductivity / width; + values.m_width = widthInRequiredUnit; + values.m_permeability = conductivity / widthInRequiredUnit; } } } @@ -662,6 +678,7 @@ double RimStimPlanFractureTemplate::resultValueAtIJ(const QString& uiResultName, if (adjustedI >= fractureGrid()->iCellCount() || adjustedJ >= fractureGrid()->jCellCount()) { + return HUGE_VAL; } @@ -700,12 +717,10 @@ void RimStimPlanFractureTemplate::updateFractureGrid() if (m_stimPlanFractureDefinitionData.notNull()) { - QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit()); - m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_conductivityResultNameOnFile, m_activeTimeStepIndex, - condUnit, - m_wellPathDepthAtFracture); + m_wellPathDepthAtFracture, + m_fractureTemplateUnit()); } } diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index d69b6c575d..7ce30ccdc2 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -155,7 +155,7 @@ void RigStimPlanFractureDefinition::scaleYs(double scaleFactor, double wellPathI } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd) { @@ -276,22 +276,86 @@ std::vector > RigStimPlanFractureDefinition::getStim } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +std::vector> + RigStimPlanFractureDefinition::conductivityValuesAtTimeStep(const QString& resultName, + int activeTimeStepIndex, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) const +{ + std::vector> conductivityValues; + + QString conductivityUnitTextOnFile; + + std::vector> propertyNamesUnitsOnFile = this->getStimPlanPropertyNamesUnits(); + for (auto properyNameUnit : propertyNamesUnitsOnFile) + { + if (resultName == properyNameUnit.first) + { + conductivityUnitTextOnFile = properyNameUnit.second; + } + } + + if (conductivityUnitTextOnFile.isEmpty()) + { + RiaLogging::error("Did not find unit for conductivity on file"); + + return conductivityValues; + } + + conductivityValues = this->getDataAtTimeIndex(resultName, conductivityUnitTextOnFile, activeTimeStepIndex); + + // Convert to the conductivity unit system used by the fracture template + // The conductivity value is used in the computations of transmissibility when exporting COMPDAT, and has unit md-m or md-ft + // This unit must match the unit used to represent coordinates of the grid used for export + + QString conversionUnitText; + if (conductivityUnitTextOnFile == "md-m") + { + conversionUnitText = "m"; + } + else if (conductivityUnitTextOnFile == "md-ft") + { + conversionUnitText = "ft"; + } + + for (auto& yValues : conductivityValues) + { + for (auto& xVal : yValues) + { + if (requiredUnitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + xVal = RiaEclipseUnitTools::convertToFeet(xVal, conversionUnitText); + } + else if (requiredUnitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + xVal = RiaEclipseUnitTools::convertToMeter(xVal, conversionUnitText); + } + } + } + + return conductivityValues; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- cvf::ref RigStimPlanFractureDefinition::createFractureGrid(const QString& resultName, - int activeTimeStepIndex, - const QString& conductivityUnitText, - double wellPathIntersectionAtFractureDepth) + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) { + std::vector> conductivityValues = conductivityValuesAtTimeStep(resultName, activeTimeStepIndex, requiredUnitSet); + if (conductivityValues.empty()) + { + return nullptr; + } + std::vector stimPlanCells; std::pair wellCenterStimPlanCellIJ = std::make_pair(0, 0); bool wellCenterStimPlanCellFound = false; - std::vector> conductivityValuesAtTimeStep = this->getDataAtTimeIndex(resultName, - conductivityUnitText, - activeTimeStepIndex); - std::vector yCoordsAtNodes = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); std::vector xCoordsAtNodes = this->m_Xs; @@ -311,9 +375,9 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons cellPolygon.push_back(cvf::Vec3d(xCoords[i], depthCoords[j + 1], 0.0)); RigFractureCell stimPlanCell(cellPolygon, i, j); - if ( conductivityValuesAtTimeStep.size() > 0 ) //Assuming vector to be of correct length, or no values + if ( conductivityValues.size() > 0 ) //Assuming vector to be of correct length, or no values { - stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]); + stimPlanCell.setConductivityValue(conductivityValues[j + 1][i + 1]); } else { diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 9aad1cf12c..4a00084d29 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -73,8 +73,8 @@ class RigStimPlanFractureDefinition: public cvf::Object cvf::ref createFractureGrid(const QString& resultName, int activeTimeStepIndex, - const QString& conductivityUnitText, - double wellPathIntersectionAtFractureDepth); + double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem requiredUnitSet); void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, const QString& fractureUserName, @@ -124,6 +124,10 @@ class RigStimPlanFractureDefinition: public cvf::Object void scaleXs(double scaleFactor); void scaleYs(double scaleFactor, double wellPathIntersectionY); + std::vector> conductivityValuesAtTimeStep(const QString& resultName, + int activeTimeStepIndex, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) const; + private: RiaEclipseUnitTools::UnitSystem m_unitSet; // To be deleted std::vector m_fileXs; From 204c0c77b127da448e635ee5f5d7228c628a8b83 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Mar 2018 09:56:06 +0100 Subject: [PATCH 0398/1027] #2560 Fracture : Reload XML data after unit system change --- .../FractureCommands/RicConvertFractureTemplateUnitFeature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp index a86b82d747..0d25d87a72 100644 --- a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp @@ -69,6 +69,7 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) } fractureTemplate->disconnectAllFracturesAndRedrawViews(); + fractureTemplate->loadDataAndUpdate(); fractureTemplate->updateConnectedEditors(); } From 2f023f40160fad8f899d1179ddcd184140b4ddb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 10:17:27 +0100 Subject: [PATCH 0399/1027] Argument parser. Add ignoreArgs argument for testing purposes --- ApplicationCode/Application/Tools/RiaArgumentParser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index 2f90a43c29..ff99059e24 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -70,6 +70,7 @@ bool RiaArgumentParser::parseArguments() progOpt.registerOption("regressiontest", "", "System command", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("updateregressiontestbase", "", "System command", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("unittest", "", "System command"); + progOpt.registerOption("ignoreArgs", "", "Ignore all arguments. Mostly for testing purposes"); progOpt.setOptionPrefix(cvf::ProgramOptions::DOUBLE_DASH); @@ -104,6 +105,12 @@ bool RiaArgumentParser::parseArguments() // Handling of the actual command line options // -------------------------------------------------------- + + if (cvf::Option o = progOpt.option("ignoreArgs")) + { + return true; + } + if (cvf::Option o = progOpt.option("regressiontest")) { CVF_ASSERT(o.valueCount() == 1); From b371a94e914b8da991008f92df249421ea4e6c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 10:20:47 +0100 Subject: [PATCH 0400/1027] #2495 Add batch command argument for D-factor scaling --- .../RicfScaleFractureTemplate.cpp | 3 +- .../RicfScaleFractureTemplate.h | 1 + .../RimEllipseFractureTemplate.cpp | 4 +- .../Completions/RimFractureTemplate.cpp | 55 +++++++++++-------- .../Completions/RimFractureTemplate.h | 5 +- .../RimStimPlanFractureTemplate.cpp | 4 +- 6 files changed, 42 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp index 97a540a37f..47f5dee3c1 100644 --- a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp @@ -36,6 +36,7 @@ RicfScaleFractureTemplate::RicfScaleFractureTemplate() RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", ""); RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", ""); + RICF_InitField(&m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -66,6 +67,6 @@ void RicfScaleFractureTemplate::execute() return; } - templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor); + templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor, m_dFactorScaleFactor); templ->reload(); } diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h index 148be060e7..73567d7916 100644 --- a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h @@ -42,4 +42,5 @@ class RicfScaleFractureTemplate : public RicfCommandObject caf::PdmField m_id; caf::PdmField m_widthScaleFactor; caf::PdmField m_heightScaleFactor; + caf::PdmField m_dFactorScaleFactor; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index a67828c07e..a14d91f133 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -91,9 +91,9 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha || changedField == &m_height || changedField == &m_width || changedField == &m_userDefinedEffectivePermeability - || changedField == &m_sizeScaleApplyButton) + || changedField == &m_scaleApplyButton) { - m_sizeScaleApplyButton = false; + m_scaleApplyButton = false; //Changes to one of these parameters should change all fractures with this fracture template attached. reload(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index dcbd73a9fb..599bc28569 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -158,12 +158,13 @@ RimFractureTemplate::RimFractureTemplate() m_dFactorSummaryText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP); m_dFactorSummaryText.xmlCapability()->disableIO(); - CAF_PDM_InitField(&m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height Scale Factor", "", "", ""); - CAF_PDM_InitField(&m_widthScaleFactor, "WidthScaleFactor", 1.0, "Width Scale Factor", "", "", ""); - CAF_PDM_InitField(&m_sizeScaleApplyButton, "SizeScaleApplyButton", false, "Apply", "", "", ""); - m_sizeScaleApplyButton.xmlCapability()->disableIO(); - m_sizeScaleApplyButton.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); - m_sizeScaleApplyButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height", "", "", ""); + CAF_PDM_InitField(&m_widthScaleFactor, "WidthScaleFactor", 1.0, "Width", "", "", ""); + CAF_PDM_InitField(&m_dFactorScaleFactor, "DFactorScaleFactor", 1.0, "D-factor", "", "", ""); + CAF_PDM_InitField(&m_scaleApplyButton, "ScaleApplyButton", false, "Apply", "", "", ""); + m_scaleApplyButton.xmlCapability()->disableIO(); + m_scaleApplyButton.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_scaleApplyButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); } //-------------------------------------------------------------------------------------------------- @@ -316,11 +317,12 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder prepareFieldsForUiDisplay(); { - auto group = uiOrdering.addNewGroup("Scale Factors"); + auto group = uiOrdering.addNewGroup("Sensitivity Scale Factors"); group->setCollapsedByDefault(false); group->add(&m_heightScaleFactor); group->add(&m_widthScaleFactor); - group->add(&m_sizeScaleApplyButton); + group->add(&m_dFactorScaleFactor); + group->add(&m_scaleApplyButton); } auto nonDarcyFlowGroup = uiOrdering.addNewGroup("Non-Darcy Flow"); @@ -391,7 +393,7 @@ void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field } } - if (field == &m_sizeScaleApplyButton) + if (field == &m_scaleApplyButton) { caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); if (attrib) @@ -572,26 +574,32 @@ double RimFractureTemplate::effectivePermeability() const //-------------------------------------------------------------------------------------------------- double RimFractureTemplate::dFactor() const { + double d; + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) { - return m_userDefinedDFactor; + d = m_userDefinedDFactor; } + else + { + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); + auto beta = m_inertialCoefficient; + auto effPerm = effectivePermeability(); + auto gamma = m_relativeGasDensity; - auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); - auto beta = m_inertialCoefficient; - auto effPerm = effectivePermeability(); - auto gamma = m_relativeGasDensity; - - auto radius = m_wellDiameter / 2.0; - auto mu = m_gasViscosity; - auto h = fractureWidth(); + auto radius = m_wellDiameter / 2.0; + auto mu = m_gasViscosity; + auto h = fractureWidth(); + + double numerator = alpha * beta * effPerm * gamma; + double denumerator = h * radius * mu; - double numerator = alpha * beta * effPerm * gamma; - double denumerator = h * radius * mu; + if (denumerator < 1e-10) return HUGE_VAL; - if (denumerator < 1e-10) return HUGE_VAL; + d = numerator / denumerator; + } - return numerator / denumerator; + return d * m_dFactorScaleFactor; } //-------------------------------------------------------------------------------------------------- @@ -660,10 +668,11 @@ void RimFractureTemplate::setId(int id) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplate::setScaleFactors(double width, double height) +void RimFractureTemplate::setScaleFactors(double width, double height, double dFactor) { m_widthScaleFactor = width; m_heightScaleFactor = height; + m_dFactorScaleFactor = dFactor; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 92c04009a6..9984082e21 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -147,7 +147,7 @@ class RimFractureTemplate : public caf::PdmObject void disconnectAllFracturesAndRedrawViews() const; void setId(int id); - void setScaleFactors(double width, double height); + void setScaleFactors(double width, double height, double dFactor); virtual void reload() {} protected: @@ -200,5 +200,6 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmField m_heightScaleFactor; caf::PdmField m_widthScaleFactor; - caf::PdmField m_sizeScaleApplyButton; + caf::PdmField m_dFactorScaleFactor; + caf::PdmField m_scaleApplyButton; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 1cba8a6d18..071e57ff8d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -152,9 +152,9 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch } } - if (changedField == &m_sizeScaleApplyButton) + if (changedField == &m_scaleApplyButton) { - m_sizeScaleApplyButton = false; + m_scaleApplyButton = false; reload(); } } From 3a6de3cc568bbd3b844b9f59258c458ac88efacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 11:55:34 +0100 Subject: [PATCH 0401/1027] #2505 Add conductivity scale factor batch command argument --- .../RicfScaleFractureTemplate.cpp | 11 ++++++----- .../CommandFileInterface/RicfScaleFractureTemplate.h | 1 + .../Completions/RimFractureTemplate.cpp | 10 +++++++++- .../Completions/RimFractureTemplate.h | 5 ++++- .../Completions/RimStimPlanFractureTemplate.cpp | 10 +--------- .../Completions/RimStimPlanFractureTemplate.h | 3 ++- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp index 47f5dee3c1..ac79a28717 100644 --- a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp @@ -33,10 +33,11 @@ CAF_PDM_SOURCE_INIT(RicfScaleFractureTemplate, "scaleFractureTemplate"); //-------------------------------------------------------------------------------------------------- RicfScaleFractureTemplate::RicfScaleFractureTemplate() { - RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); - RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", ""); - RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", ""); - RICF_InitField(&m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor", "", "", ""); + RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); + RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", ""); + RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", ""); + RICF_InitField(&m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor", "", "", ""); + RICF_InitField(&m_conductivityScaleFactor, "conductivity", 1.0, "ConductivityScaleFactor", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -67,6 +68,6 @@ void RicfScaleFractureTemplate::execute() return; } - templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor, m_dFactorScaleFactor); + templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor, m_dFactorScaleFactor, m_conductivityScaleFactor); templ->reload(); } diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h index 73567d7916..bb78233215 100644 --- a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h @@ -43,4 +43,5 @@ class RicfScaleFractureTemplate : public RicfCommandObject caf::PdmField m_widthScaleFactor; caf::PdmField m_heightScaleFactor; caf::PdmField m_dFactorScaleFactor; + caf::PdmField m_conductivityScaleFactor; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 599bc28569..df7febc924 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -161,7 +161,9 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height", "", "", ""); CAF_PDM_InitField(&m_widthScaleFactor, "WidthScaleFactor", 1.0, "Width", "", "", ""); CAF_PDM_InitField(&m_dFactorScaleFactor, "DFactorScaleFactor", 1.0, "D-factor", "", "", ""); + CAF_PDM_InitField(&m_conductivityScaleFactor, "ConductivityFactor", 1.0, "Conductivity", "", "The conductivity values read from file will be scaled with this parameters", ""); CAF_PDM_InitField(&m_scaleApplyButton, "ScaleApplyButton", false, "Apply", "", "", ""); + m_scaleApplyButton.xmlCapability()->disableIO(); m_scaleApplyButton.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); m_scaleApplyButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); @@ -322,6 +324,11 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder group->add(&m_heightScaleFactor); group->add(&m_widthScaleFactor); group->add(&m_dFactorScaleFactor); + + if (supportsConductivityScaling()) + { + group->add(&m_conductivityScaleFactor); + } group->add(&m_scaleApplyButton); } @@ -668,11 +675,12 @@ void RimFractureTemplate::setId(int id) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplate::setScaleFactors(double width, double height, double dFactor) +void RimFractureTemplate::setScaleFactors(double width, double height, double dFactor, double conductivity) { m_widthScaleFactor = width; m_heightScaleFactor = height; m_dFactorScaleFactor = dFactor; + m_conductivityScaleFactor = supportsConductivityScaling() ? conductivity : 1.0; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 9984082e21..928d6fa0be 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -147,7 +147,7 @@ class RimFractureTemplate : public caf::PdmObject void disconnectAllFracturesAndRedrawViews() const; void setId(int id); - void setScaleFactors(double width, double height, double dFactor); + void setScaleFactors(double width, double height, double dFactor, double conductivity); virtual void reload() {} protected: @@ -157,6 +157,8 @@ class RimFractureTemplate : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + virtual bool supportsConductivityScaling() const { return false; } + private: void prepareFieldsForUiDisplay(); virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const = 0; @@ -201,5 +203,6 @@ class RimFractureTemplate : public caf::PdmObject caf::PdmField m_heightScaleFactor; caf::PdmField m_widthScaleFactor; caf::PdmField m_dFactorScaleFactor; + caf::PdmField m_conductivityScaleFactor; caf::PdmField m_scaleApplyButton; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 071e57ff8d..8e5adec3d2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -71,7 +71,6 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() m_borderPolygonResultName.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); - CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); CAF_PDM_InitField(&m_conductivityResultNameOnFile, "ConductivityResultName", QString(""), "Active Conductivity Result Name", "", "", ""); CAF_PDM_InitField(&m_showStimPlanMesh_OBSOLETE, "ShowStimPlanMesh", true, "", "", "", ""); @@ -130,15 +129,9 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch } } - if (&m_conductivityScalingFactor == changedField) - { - loadDataAndUpdate(); - } - if (&m_wellPathDepthAtFracture == changedField || &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField - || &m_conductivityScalingFactor == changedField || &m_stimPlanFileName == changedField || &m_conductivityResultNameOnFile == changedField) { @@ -246,7 +239,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() if (m_readError) return; m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), - m_conductivityScalingFactor(), + m_conductivityScaleFactor(), m_widthScaleFactor(), m_heightScaleFactor(), -m_wellPathDepthAtFracture(), @@ -791,7 +784,6 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_conductivityResultNameOnFile); - propertyGroup->add(&m_conductivityScalingFactor); propertyGroup->add(&m_conductivityType); propertyGroup->add(&m_skinFactor); propertyGroup->add(&m_perforationLength); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 0c01918497..9d5001778e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -100,6 +100,8 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; + virtual bool supportsConductivityScaling() const override { return true; } + private: bool setBorderPolygonResultNameToDefault(); void setDepthOfWellPathAtFracture(); @@ -118,7 +120,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate caf::PdmField m_stimPlanFileName; cvf::ref m_stimPlanFractureDefinitionData; - caf::PdmField m_conductivityScalingFactor; cvf::ref m_fractureGrid; bool m_readError; From 658e9e9f4434ba1e6e77b2e424b60b2a9d8aa0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 14:17:18 +0100 Subject: [PATCH 0402/1027] #2505 Add setFractureContainment batch command --- .../CMakeLists_files.cmake | 2 + .../RicfSetFractureContainment.cpp | 72 +++++++++++++++++++ .../RicfSetFractureContainment.h | 45 ++++++++++++ .../Completions/RimFractureContainment.cpp | 16 +++++ .../Completions/RimFractureContainment.h | 3 + .../Completions/RimFractureTemplate.cpp | 16 +++++ .../Completions/RimFractureTemplate.h | 3 + 7 files changed, 157 insertions(+) create mode 100644 ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp create mode 100644 ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h diff --git a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake index 7484d1c208..581bd22329 100644 --- a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake @@ -19,6 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h ${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h +${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -41,6 +42,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp new file mode 100644 index 0000000000..dbe131d8a5 --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp @@ -0,0 +1,72 @@ +#include "RicfSetExportFolder.h" +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicfSetFractureContainment.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimProject.h" +#include "RimFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +CAF_PDM_SOURCE_INIT(RicfSetFractureContainment, "setFractureContainment"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicfSetFractureContainment::RicfSetFractureContainment() +{ + RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); + RICF_InitField(&m_topLayer, "topLayer", 1.0, "TopLayer", "", "", ""); + RICF_InitField(&m_baseLayer, "baseLayer", 1.0, "BaseLayer", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfSetFractureContainment::execute() +{ + if (m_id < 0) + { + RiaLogging::error("setFractureContainment: Fracture template id not specified"); + return; + } + + RimProject* project = RiaApplication::instance()->project(); + + if (!project) + { + RiaLogging::error("setFractureContainment: Project not found"); + return; + } + + RimFractureTemplateCollection* templColl = !project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr; + RimFractureTemplate* templ = templColl ? templColl->fractureTemplate(m_id) : nullptr; + + if (!templ) + { + RiaLogging::error(QString("setFractureContainment: Fracture template not found. Id=%1").arg(m_id)); + return; + } + + templ->setContainmentTopKLayer(m_topLayer); + templ->setContainmentBaseKLayer(m_baseLayer); + templ->reload(); +} diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h new file mode 100644 index 0000000000..b372cfdeb8 --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "RicfCommandFileExecutor.h" + +#include "cafPdmField.h" + +//================================================================================================== +// +// +// +//================================================================================================== +class RicfSetFractureContainment : public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicfSetFractureContainment(); + + virtual void execute() override; + +private: + caf::PdmField m_id; + caf::PdmField m_topLayer; + caf::PdmField m_baseLayer; +}; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp index bb6bc3816f..3d303b5e2c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -116,6 +116,22 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid* m return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureContainment::setTopKLayer(int topKLayer) +{ + m_topKLayer = topKLayer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureContainment::setBaseKLayer(int baseKLayer) +{ + m_baseKLayer = baseKLayer; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h index 52089c4a6d..c5c3257762 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h @@ -41,6 +41,9 @@ class RimFractureContainment : public caf::PdmObject bool isEnabled() const { return m_isUsingFractureContainment();} bool isEclipseCellWithinContainment(const RigMainGrid* mainGrid, size_t anchorEclipseCell, size_t globalCellIndex) const; + void setTopKLayer(int topKLayer); + void setBaseKLayer(int baseKLayer); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; protected: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index df7febc924..ce66a1ae5a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -683,6 +683,22 @@ void RimFractureTemplate::setScaleFactors(double width, double height, double dF m_conductivityScaleFactor = supportsConductivityScaling() ? conductivity : 1.0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setContainmentTopKLayer(int topKLayer) +{ + m_fractureContainment->setTopKLayer(topKLayer); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setContainmentBaseKLayer(int baseKLayer) +{ + m_fractureContainment->setBaseKLayer(baseKLayer); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 928d6fa0be..d1580b3262 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -150,6 +150,9 @@ class RimFractureTemplate : public caf::PdmObject void setScaleFactors(double width, double height, double dFactor, double conductivity); virtual void reload() {} + void setContainmentTopKLayer(int topKLayer); + void setContainmentBaseKLayer(int baseKLayer); + protected: virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From e5eb8f55b30bf4ed0b7ff207aa7f1db93340d528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 14:24:02 +0100 Subject: [PATCH 0403/1027] #2566 Set tooltip on compaction ref layer field --- ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 7e306b7341..8eefa9dcf5 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -108,7 +108,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_isCompactionUiField.xmlCapability()->setIOWritable(false); m_isCompactionUiField.xmlCapability()->setIOReadable(false); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "", ""); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); From 801b1aefb80a206bea5e76d2f37ebb2b1e37ef0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 5 Mar 2018 14:36:42 +0100 Subject: [PATCH 0404/1027] #2565 Campaction. Remove enable compaction checkbox --- .../GeoMechDataModel/RigFemResultAddress.h | 2 -- .../RimGeoMechResultDefinition.cpp | 21 +++---------------- .../RimGeoMechResultDefinition.h | 2 -- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index 2e9f4d92f9..c2717d5a9e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -62,8 +62,6 @@ class RigFemResultAddress bool isTimeLapse() const { return timeLapseBaseFrameIdx > NO_TIME_LAPSE;} bool representsAllTimeLapses() const { return timeLapseBaseFrameIdx == ALL_TIME_LAPSES;} - bool isCompaction() const { return refKLayerIndex > NO_COMPACTION; } - bool isValid() const { bool isTypeValid = resultPosType == RIG_NODAL diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 8eefa9dcf5..26653e834d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -79,9 +79,6 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", 0, "Base Time Step", "", "", ""); m_timeLapseBaseTimestep.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_isCompaction, "IsCompaction", false, "Compaction", "", "", ""); - m_isCompaction.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer", "", "", ""); m_compactionRefLayer.uiCapability()->setUiHidden(true); @@ -104,10 +101,6 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&m_isCompactionUiField, "IsCompactionUi", false, "Enable Compaction", "", "", ""); - m_isCompactionUiField.xmlCapability()->setIOWritable(false); - m_isCompactionUiField.xmlCapability()->setIOReadable(false); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); @@ -142,9 +135,7 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm if (m_resultPositionTypeUiField() == RIG_NODAL) { caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); - compactionGroup->add(&m_isCompactionUiField); - if (m_isCompactionUiField()) - compactionGroup->add(&m_compactionRefLayerUiField); + compactionGroup->add(&m_compactionRefLayerUiField); } if (!m_isChangedByField) @@ -180,8 +171,6 @@ QList RimGeoMechResultDefinition::calculateValueOptions( for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx) { - if (uiVarNames[oIdx].startsWith(RigFemPartResultsCollection::FIELD_NAME_COMPACTION.data()) && !m_isCompactionUiField()) continue; - options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); } } @@ -291,7 +280,6 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha m_isTimeLapseResult = m_isTimeLapseResultUiField(); m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField(); - m_isCompaction = m_isCompactionUiField(); m_compactionRefLayer = m_compactionRefLayerUiField(); } @@ -414,7 +402,6 @@ void RimGeoMechResultDefinition::initAfterRead() m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; - m_isCompactionUiField = m_isCompaction; m_compactionRefLayerUiField = m_compactionRefLayer; } @@ -439,7 +426,7 @@ RigFemResultAddress RimGeoMechResultDefinition::resultAddress() resultFieldName().toStdString(), resultComponentName().toStdString(), m_isTimeLapseResult() ? m_timeLapseBaseTimestep() : RigFemResultAddress::NO_TIME_LAPSE, - m_isCompaction() && resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION); + resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION); } //-------------------------------------------------------------------------------------------------- @@ -517,15 +504,13 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re m_resultFieldName = QString::fromStdString(resultAddress.fieldName); m_resultComponentName = QString::fromStdString(resultAddress.componentName); m_isTimeLapseResult = resultAddress.isTimeLapse(); - m_isCompaction = resultAddress.isCompaction(); m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: -1; - m_compactionRefLayer = m_isCompaction ? resultAddress.refKLayerIndex : -1; + m_compactionRefLayer = resultAddress.refKLayerIndex; m_resultPositionTypeUiField = m_resultPositionType; m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; - m_isCompactionUiField = m_isCompaction; m_compactionRefLayerUiField = m_compactionRefLayer; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index dd10008d92..0cc449b192 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -101,7 +101,6 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultComponentName; caf::PdmField m_isTimeLapseResult; caf::PdmField m_timeLapseBaseTimestep; - caf::PdmField m_isCompaction; caf::PdmField m_compactionRefLayer; // UI Fields only @@ -114,7 +113,6 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultVariableUiField; caf::PdmField m_isTimeLapseResultUiField; caf::PdmField m_timeLapseBaseTimestepUiField; - caf::PdmField m_isCompactionUiField; caf::PdmField m_compactionRefLayerUiField; caf::PdmPointer m_geomCase; From 3a1147dcdf67b075898c27f318a894ce1dfc6147 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Mar 2018 10:55:39 +0100 Subject: [PATCH 0405/1027] #2554 Non-Darcy : Add tool for text compare --- .../Application/Tools/CMakeLists_files.cmake | 2 + .../Application/Tools/RiaTextStringTools.cpp | 41 +++++++++++++++++++ .../Application/Tools/RiaTextStringTools.h | 29 +++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 ApplicationCode/Application/Tools/RiaTextStringTools.cpp create mode 100644 ApplicationCode/Application/Tools/RiaTextStringTools.h diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index 56ab980717..45069ba744 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -19,6 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.h ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -41,6 +42,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaTextStringTools.cpp b/ApplicationCode/Application/Tools/RiaTextStringTools.cpp new file mode 100644 index 0000000000..2f3992b35d --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextStringTools.cpp @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaTextStringTools.h" + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaTextStringTools::compare(const QString& expected, const QString& actual) +{ + // Suggestions for improvement + // 1. report line number for first change + // 2. report line numbers for all changes + // 3. add support for compare with content of a text file on disk + + if (expected.compare(actual) == 0) + { + return true; + } + + return false; +} + diff --git a/ApplicationCode/Application/Tools/RiaTextStringTools.h b/ApplicationCode/Application/Tools/RiaTextStringTools.h new file mode 100644 index 0000000000..ee915087f2 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextStringTools.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QString; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +namespace RiaTextStringTools +{ +bool compare(const QString& expected, const QString& actual); +} From bbcc59ee1d1f5c210b3438bff90518a0631fa2cb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 07:54:37 +0100 Subject: [PATCH 0406/1027] #2561 Fracture Templates: Create duplicate of template and convert --- .../RicConvertFractureTemplateUnitFeature.cpp | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp index 0d25d87a72..3b737fa0c0 100644 --- a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp @@ -22,12 +22,15 @@ #include "RiaApplication.h" #include "RiaEclipseUnitTools.h" +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFracture.h" #include "RimFractureExportSettings.h" -#include "Rim3dView.h" +#include "RimFractureTemplateCollection.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -58,20 +61,34 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) RimFractureTemplate* fractureTemplate = nullptr; objHandle->firstAncestorOrThisOfType(fractureTemplate); - auto currentUnit = fractureTemplate->fractureTemplateUnit(); + if (!fractureTemplate) return; + + RimFractureTemplateCollection* fractureTemplateCollection = nullptr; + fractureTemplate->firstAncestorOrThisOfType(fractureTemplateCollection); + + auto copyOfTemplate = dynamic_cast( + fractureTemplate->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateCollection->addFractureTemplate(copyOfTemplate); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); + + auto currentUnit = copyOfTemplate->fractureTemplateUnit(); if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) { - fractureTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); + copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); } else { - fractureTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); + copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); } - fractureTemplate->disconnectAllFracturesAndRedrawViews(); - fractureTemplate->loadDataAndUpdate(); + QString name = copyOfTemplate->name(); + name += " (copy)"; + copyOfTemplate->setName(name); - fractureTemplate->updateConnectedEditors(); + copyOfTemplate->loadDataAndUpdate(); + copyOfTemplate->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -89,18 +106,19 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet objHandle->firstAncestorOrThisOfType(fractureTemplate); if (!fractureTemplate) return; - QString text = "Convert Values to "; + QString destinationUnit; if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - text += "Field"; + destinationUnit += "Field"; } else if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - text += "Metric"; + destinationUnit += "Metric"; } + + QString text = QString("Create %1 Units Duplicate").arg(destinationUnit); actionToSetup->setIcon(QIcon(":/FractureTemplate16x16.png")); - //TODO: Add unit to text actionToSetup->setText(text); } From 0bf72d5f6876750fc6a99fd985e7bd45b3f0923b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 07:58:48 +0100 Subject: [PATCH 0407/1027] #2561 Fracture Templates: Rename command feature files --- .../Commands/FractureCommands/CMakeLists_files.cmake | 4 ++-- ...reateDuplicateTemplateInOtherUnitSystemFeature.cpp} | 10 +++++----- ...cCreateDuplicateTemplateInOtherUnitSystemFeature.h} | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) rename ApplicationCode/Commands/FractureCommands/{RicConvertFractureTemplateUnitFeature.cpp => RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp} (90%) rename ApplicationCode/Commands/FractureCommands/{RicConvertFractureTemplateUnitFeature.h => RicCreateDuplicateTemplateInOtherUnitSystemFeature.h} (93%) diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake index fc0972113c..9abc019ecd 100644 --- a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -4,7 +4,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.h -${CMAKE_CURRENT_LIST_DIR}/RicConvertFractureTemplateUnitFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.h @@ -19,7 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.cpp -${CMAKE_CURRENT_LIST_DIR}/RicConvertFractureTemplateUnitFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.cpp diff --git a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp similarity index 90% rename from ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp index 3b737fa0c0..10c049fd30 100644 --- a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicConvertFractureTemplateUnitFeature.h" +#include "RicCreateDuplicateTemplateInOtherUnitSystemFeature.h" #include "RiaApplication.h" @@ -45,12 +45,12 @@ #include #include -CAF_CMD_SOURCE_INIT(RicConvertFractureTemplateUnitFeature, "RicConvertFractureTemplateUnitFeature"); +CAF_CMD_SOURCE_INIT(RicCreateDuplicateTemplateInOtherUnitSystemFeature, "RicConvertFractureTemplateUnitFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) +void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool isChecked) { caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (!pdmUiItem) return; @@ -94,7 +94,7 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSetup) +void RicCreateDuplicateTemplateInOtherUnitSystemFeature::setupActionLook(QAction* actionToSetup) { caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (!pdmUiItem) return; @@ -126,7 +126,7 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicConvertFractureTemplateUnitFeature::isCommandEnabled() +bool RicCreateDuplicateTemplateInOtherUnitSystemFeature::isCommandEnabled() { return true; } diff --git a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.h b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h similarity index 93% rename from ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.h rename to ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h index 5b80c5d630..c7406382a1 100644 --- a/ApplicationCode/Commands/FractureCommands/RicConvertFractureTemplateUnitFeature.h +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h @@ -26,7 +26,7 @@ //================================================================================================== /// //================================================================================================== -class RicConvertFractureTemplateUnitFeature : public caf::CmdFeature +class RicCreateDuplicateTemplateInOtherUnitSystemFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; protected: From cbb25cb5144acfecfa5543ba30ba53c619fd9fea Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 08:16:39 +0100 Subject: [PATCH 0408/1027] #2561 Fracture Template : Set Default Conductivity Result in loadDataAndUpdate() --- ApplicationCode/Application/RiaApplication.cpp | 1 - .../Completions/RimFractureTemplateCollection.cpp | 15 --------------- .../Completions/RimFractureTemplateCollection.h | 1 - .../Completions/RimStimPlanFractureTemplate.cpp | 2 ++ .../Completions/RimStimPlanFractureTemplate.h | 2 +- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index d96637c2bc..8d3a613e2e 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -512,7 +512,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi oilField->fractureDefinitionCollection()->loadAndUpdateData(); oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit(); - oilField->fractureDefinitionCollection()->setDefaultConductivityResultIfEmpty(); { std::vector wellPathFractures; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index b1e7b15796..02ea9fc31d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -253,21 +253,6 @@ void RimFractureTemplateCollection::loadAndUpdateData() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::setDefaultConductivityResultIfEmpty() -{ - for (RimFractureTemplate* f : m_fractureDefinitions()) - { - RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); - if (stimPlanFracture) - { - stimPlanFracture->setDefaultConductivityResultIfEmpty(); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index 11e919556d..f00d598106 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -50,7 +50,6 @@ class RimFractureTemplateCollection : public caf::PdmObject void createAndAssignTemplateCopyForNonMatchingUnit(); void loadAndUpdateData(); - void setDefaultConductivityResultIfEmpty(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); protected: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 8e5adec3d2..e9599fa1e2 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -250,6 +250,8 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() if (m_stimPlanFractureDefinitionData.notNull()) { + setDefaultConductivityResultIfEmpty(); + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_UNKNOWN) { setFractureTemplateUnit(m_stimPlanFractureDefinitionData->unitSet()); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 9d5001778e..30cb44b477 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -86,7 +86,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate PosNegAccumulator& posNegAccumulator) const override; QString mapUiResultNameToFileResultName(const QString& uiResultName) const; - void setDefaultConductivityResultIfEmpty(); bool showStimPlanMesh() const; @@ -103,6 +102,7 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate virtual bool supportsConductivityScaling() const override { return true; } private: + void setDefaultConductivityResultIfEmpty(); bool setBorderPolygonResultNameToDefault(); void setDepthOfWellPathAtFracture(); void setPerforationLength(); From 44db864846cbf207d8523821cd2d685a56a94e02 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 08:53:26 +0100 Subject: [PATCH 0409/1027] System : Remove duplicate file reference --- ApplicationCode/UnitTests/CMakeLists_files.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index d64f1f53ed..7abc8e51ec 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -38,7 +38,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp -${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test ) From 5e54c58c6d6a596b3b487e03247648692b7599fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 09:33:03 +0100 Subject: [PATCH 0410/1027] #2564 Compaction. Set default reference layer to topmost layer having valid POR --- .../GeoMechDataModel/RigFemPartGrid.cpp | 30 +++++++++++++++++++ .../GeoMech/GeoMechDataModel/RigFemPartGrid.h | 4 ++- .../RimGeoMechResultDefinition.cpp | 7 ++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp index 372b7f2078..3fd1977ba6 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp @@ -182,6 +182,28 @@ void RigFemPartGrid::generateStructGridData() cvf::Vec3i ijk = m_ijkPrElement[elmIdx]; m_elmIdxPrIJK.at(ijk[0], ijk[1], ijk[2]) = elmIdx; } + + // IJK bounding box + m_reservoirIJKBoundingBox.first = cvf::Vec3st(INT_MAX, INT_MAX, INT_MAX); + m_reservoirIJKBoundingBox.second = cvf::Vec3st(0, 0, 0); + cvf::Vec3st& min = m_reservoirIJKBoundingBox.first; + cvf::Vec3st& max = m_reservoirIJKBoundingBox.second; + + for (int elmIdx = 0; elmIdx < m_femPart->elementCount(); ++elmIdx) + { + RigElementType elementType = m_femPart->elementType(elmIdx); + size_t i, j, k; + if (elementType == HEX8P && ijkFromCellIndex(elmIdx, &i, &j, &k)) + { + if (i < min.x()) min.x() = i; + if (j < min.y()) min.y() = j; + if (k < min.z()) min.z() = k; + if (i > max.x()) max.x() = i; + if (j > max.y()) max.y() = j; + if (k > max.z()) max.z() = k; + } + } + } //-------------------------------------------------------------------------------------------------- @@ -287,6 +309,14 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) const return ijkMainFaceIndices; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RigFemPartGrid::reservoirIJKBoundingBox() const +{ + return m_reservoirIJKBoundingBox; +} + //-------------------------------------------------------------------------------------------------- /// Find the face that is not perpFaceIdx or its opposite, and has normal closest to direction //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h index 20e511c569..810f66015d 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h @@ -38,6 +38,8 @@ class RigFemPartGrid : public cvf::StructGridInterface virtual size_t gridPointCountK() const; cvf::Vec3i findMainIJKFaces(int elementIndex) const; + + std::pair reservoirIJKBoundingBox() const; private: void generateStructGridData(); @@ -93,7 +95,7 @@ class RigFemPartGrid : public cvf::StructGridInterface }; IJKArray m_elmIdxPrIJK; - + std::pair m_reservoirIJKBoundingBox; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 26653e834d..ce0f48d30c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -101,7 +101,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); @@ -136,6 +136,11 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm { caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); compactionGroup->add(&m_compactionRefLayerUiField); + + if (m_compactionRefLayerUiField == RigFemResultAddress::NO_COMPACTION) + { + m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); + } } if (!m_isChangedByField) From fcf8bf6e683c48c114ac6a62704c5377b59bd1c5 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 5 Mar 2018 11:59:46 +0100 Subject: [PATCH 0411/1027] #2540 Mohr circle: Improve scaling of window --- .../UserInterface/RiuMohrsCirclePlot.cpp | 242 +++++++++++------- .../UserInterface/RiuMohrsCirclePlot.h | 54 ++-- 2 files changed, 190 insertions(+), 106 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index fd9ff36d14..f6427fbf50 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -38,7 +38,9 @@ #include "cvfAssert.h" #include +#include #include +#include #include "qwt_legend.h" #include "qwt_plot_curve.h" @@ -60,16 +62,12 @@ /// //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) - : QwtPlot(parent), m_sourceGeoMechViewOfLastPlot(nullptr) + : QwtPlot(parent) + , m_sourceGeoMechViewOfLastPlot(nullptr) + , m_scheduleUpdateAxisScaleTimer(nullptr) { RiuSummaryQwtPlot::setCommonPlotBehaviour(this); - m_rescaler = new QwtPlotRescaler(this->canvas()); - m_rescaler->setReferenceAxis(QwtPlot::yLeft); - m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0); - m_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed); - m_rescaler->setEnabled(true); - enableAxis(QwtPlot::xBottom, true); enableAxis(QwtPlot::yLeft, true); enableAxis(QwtPlot::xTop, false); @@ -92,11 +90,6 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) RiuMohrsCirclePlot::~RiuMohrsCirclePlot() { deletePlotItems(); - - if (m_rescaler) - { - delete m_rescaler; - } } //-------------------------------------------------------------------------------------------------- @@ -105,9 +98,9 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem) { const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); - + m_sourceGeoMechViewOfLastPlot = nullptr; - + if (!geoMechSelectionItem) { this->clearPlot(); @@ -124,7 +117,7 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select const cvf::Color3f color = geoMechSelectionItem->m_color; queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); - + m_sourceGeoMechViewOfLastPlot = geoMechView; } else @@ -144,7 +137,7 @@ void RiuMohrsCirclePlot::clearPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView) { @@ -161,12 +154,13 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView) } // Fetch the current global selection and only continue if the selection's view matches the view with time step change - const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(RiuSelectionManager::instance()->selectedItem()); + const RiuGeoMechSelectionItem* geoMechSelectionItem = + dynamic_cast(RiuSelectionManager::instance()->selectedItem()); if (geoMechSelectionItem && geoMechSelectionItem->m_view == geoMechView) { - const size_t gridIndex = geoMechSelectionItem->m_gridIndex; - const size_t gridCellIndex = geoMechSelectionItem->m_cellIndex; - const cvf::Color3f color = geoMechSelectionItem->m_color; + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t gridCellIndex = geoMechSelectionItem->m_cellIndex; + const cvf::Color3f color = geoMechSelectionItem->m_color; deletePlotItems(); @@ -277,7 +271,7 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie double cohesion = view->geoMechCase()->cohesion(); double frictionAngle = view->geoMechCase()->frictionAngleDeg(); - if (cohesion == HUGE_VAL || frictionAngle == HUGE_VAL) + if (cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90) { return; } @@ -292,24 +286,13 @@ void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechVie return; } - yVals[0] = 0; - double x = cohesion / tanFrictionAngle; - if (principals[0] < 0) - { - xVals[0] = x; - xVals[1] = principals[2]; - - yVals[1] = (cohesion / x) * (x + principals[2]); - } - else - { - xVals[0] = -x; - xVals[1] = principals[0]; - yVals[1] = (cohesion / x) * (x + principals[0]); - } + xVals[0] = -x; + xVals[1] = principals[0]; + yVals[0] = 0; + yVals[1] = (cohesion / x) * (x + principals[0]); // If envelope for the view already exists, check if a "larger" envelope should be created if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end()) @@ -401,23 +384,19 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView return; } - double cohesion = geoMechView->geoMechCase()->cohesion(); + double cohesion = geoMechView->geoMechCase()->cohesion(); double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg(); size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); - MohrsCirclesInfo mohrsCircle; - mohrsCircle.color = color; - mohrsCircle.elmIndex = elmIndex; - mohrsCircle.factorOfSafety = calculateFOS(principals, frictionAngleDeg, cohesion); - mohrsCircle.principals = principals; - mohrsCircle.i = i; - mohrsCircle.j = j; - mohrsCircle.k = k; + MohrsCirclesInfo mohrsCircle(principals, elmIndex, i, j, k, calculateFOS(principals, frictionAngleDeg, cohesion), color); addMohrsCirclesInfo(mohrsCircle, geoMechView); - replotAndScaleAxis(); + + setAxesScaleAndReplot(); + // Update axis scale is called one more time because the legend which is added on a later stage may disrupt the canvas + scheduleUpdateAxisScale(); } //-------------------------------------------------------------------------------------------------- @@ -429,6 +408,7 @@ void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircle addEnvelope(mohrsCircleInfo.principals, view); addMohrCircles(mohrsCircleInfo); + updateTransparentCurvesOnPrincipals(); } //-------------------------------------------------------------------------------------------------- @@ -503,53 +483,19 @@ double RiuMohrsCirclePlot::smallestPrincipal() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::replotAndScaleAxis() +double RiuMohrsCirclePlot::largestPrincipal() const { - double maxYEnvelope = -HUGE_VAL; - - for (const std::pair& envelope : m_envolopePlotItems) - { - double tempMax = envelope.second->maxYValue(); - if (tempMax > maxYEnvelope) - { - maxYEnvelope = tempMax; - } - } - - double yHeight = std::max(maxYEnvelope, 1.2 * largestCircleRadiusInPlot()); - - this->setAxisScale(QwtPlot::yLeft, 0, yHeight); + double currentLargestPrincipal = -HUGE_VAL; - double minXEvelope = HUGE_VAL; - - for (const std::pair& envelope : m_envolopePlotItems) + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) { - double tempMin = envelope.second->minXValue(); - if (tempMin < minXEvelope) + if (mohrCircleInfo.principals[0] > currentLargestPrincipal) { - minXEvelope = tempMin; + currentLargestPrincipal = mohrCircleInfo.principals[0]; } } - double xMin; - if (minXEvelope < 0) - { - xMin = minXEvelope; - } - else - { - xMin = 1.1 * smallestPrincipal(); - } - - // When using the rescaler, xMax is ignored - this->setAxisScale(QwtPlot::xBottom, xMin, 0); - - updateTransparentCurvesOnPrincipals(); - - //Replotting must be done before rescaling - this->replot(); - m_rescaler->rescale(); - this->plotLayout()->setAlignCanvasToScales(true); + return currentLargestPrincipal; } //-------------------------------------------------------------------------------------------------- @@ -592,10 +538,10 @@ float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double fric if (cvf::Math::cos(frictionAngle) == 0) { - return 0; + return 0.0f; } - float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle)); + float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle)); float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng; float pi_4 = 0.785398163397448309616f; @@ -622,7 +568,7 @@ QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::deletePlotItems() { @@ -632,3 +578,121 @@ void RiuMohrsCirclePlot::deletePlotItems() deleteEnvelopes(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::scheduleUpdateAxisScale() +{ + if (!m_scheduleUpdateAxisScaleTimer) + { + m_scheduleUpdateAxisScaleTimer = new QTimer(this); + connect(m_scheduleUpdateAxisScaleTimer, SIGNAL(timeout()), this, SLOT(setAxesScaleAndReplot())); + } + + if (!m_scheduleUpdateAxisScaleTimer->isActive()) + { + m_scheduleUpdateAxisScaleTimer->setSingleShot(true); + m_scheduleUpdateAxisScaleTimer->start(100); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::resizeEvent(QResizeEvent* e) +{ + setAxesScaleAndReplot(); + + // Update axis scale is called one more time because setAxesScaleAndReplot does not work the first + // time if the user does a very quick resizing of the window + scheduleUpdateAxisScale(); + QwtPlot::resizeEvent(e); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const +{ + *xMin = HUGE_VAL; + *xMax = -HUGE_VAL; + *yMax = -HUGE_VAL; + + double maxYEnvelope = -HUGE_VAL; + for (const std::pair& envelope : m_envolopePlotItems) + { + double tempMax = envelope.second->maxYValue(); + if (tempMax > maxYEnvelope) + { + maxYEnvelope = tempMax; + } + } + + *yMax = std::max(maxYEnvelope, 1.2 * largestCircleRadiusInPlot()); + + double minXEvelope = HUGE_VAL; + for (const std::pair& envelope : m_envolopePlotItems) + { + double tempMin = envelope.second->minXValue(); + if (tempMin < minXEvelope) + { + minXEvelope = tempMin; + } + } + + if (minXEvelope < 0) + { + *xMin = minXEvelope; + } + else + { + *xMin = 1.1 * smallestPrincipal(); + } + + *xMax = 1.1 * largestPrincipal(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setAxesScaleAndReplot() +{ + // yMin is always 0 + double xMin, xMax, yMax; + idealAxesEndPoints(&xMin, &xMax, &yMax); + + if (xMax == -HUGE_VAL || xMin == HUGE_VAL || yMax == -HUGE_VAL) + { + return; + } + + int canvasHeight = this->canvas()->height(); + int canvasWidth = this->canvas()->width(); + + const double minPlotWidth = xMax - xMin; + const double minPlotHeight = yMax; + + double xMaxDisplayed = xMax; + double yMaxDisplayed = yMax; + + double canvasWidthOverHeightRatio = (1.0 * canvasWidth) / (1.0 * canvasHeight); + + // widthToKeepAspectRatio increases when canvas height is increased + double widthToKeepAspectRatio = minPlotHeight * canvasWidthOverHeightRatio; + // heightToKeepAspectRatio increases when canvas width is increased + double heightToKeepAspectRatio = minPlotWidth / canvasWidthOverHeightRatio; + + if (widthToKeepAspectRatio > minPlotWidth) + { + xMaxDisplayed = widthToKeepAspectRatio + xMin; + } + else if (heightToKeepAspectRatio > minPlotHeight) + { + yMaxDisplayed = heightToKeepAspectRatio; + } + + this->setAxisScale(QwtPlot::yLeft, 0, yMaxDisplayed); + this->setAxisScale(QwtPlot::xBottom, xMin, xMaxDisplayed); + + this->replot(); +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 318ec00b7d..6a90555e0a 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -19,8 +19,8 @@ #pragma once #include "qwt_plot.h" -#include "qwt_plot_item.h" #include "qwt_plot_curve.h" +#include "qwt_plot_item.h" #include "cafTensor3.h" @@ -28,14 +28,11 @@ #include +class QTimer; class QWidget; -class QwtPlotRescaler; -class QwtPlotTextLabel; -class QwtRoundScaleDraw; -class RimGeoMechView; -class RiuSelectionItem; class Rim3dView; class RimGeoMechView; +class RiuSelectionItem; //================================================================================================== // @@ -58,16 +55,34 @@ class RiuMohrsCirclePlot : public QwtPlot public: struct MohrsCirclesInfo { - cvf::Vec3f principals; - size_t elmIndex; - size_t i, j, k; - double factorOfSafety; + MohrsCirclesInfo(cvf::Vec3f principals, + size_t elmIndex, + size_t i, + size_t j, + size_t k, + double factorOfSafety, + cvf::Color3ub color) + : principals(principals) + , elmIndex(elmIndex) + , i(i) + , j(j) + , k(k) + , factorOfSafety(factorOfSafety) + , color(color) {} + + cvf::Vec3f principals; + size_t elmIndex; + size_t i, j, k; + double factorOfSafety; cvf::Color3ub color; }; private: virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; + virtual void resizeEvent(QResizeEvent* e) override; + + void idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const; void addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo); void deleteCircles(); @@ -76,27 +91,32 @@ class RiuMohrsCirclePlot : public QwtPlot void deleteEnvelopes(); void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); - + void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo, RimGeoMechView* view); void updateTransparentCurvesOnPrincipals(); + double largestCircleRadiusInPlot() const; double smallestPrincipal() const; - - void replotAndScaleAxis(); + double largestPrincipal() const; static bool isValidPrincipals(const cvf::Vec3f& principals); - + static float calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion); QColor envelopeColor(RimGeoMechView* view); void deletePlotItems(); - + + void scheduleUpdateAxisScale(); + +private slots: + void setAxesScaleAndReplot(); + private: std::vector m_circlePlotItems; std::vector m_transparentCurves; - + std::map m_envolopePlotItems; std::map m_envolopeColors; @@ -104,5 +124,5 @@ class RiuMohrsCirclePlot : public QwtPlot RimGeoMechView* m_sourceGeoMechViewOfLastPlot; - QwtPlotRescaler* m_rescaler; + QTimer* m_scheduleUpdateAxisScaleTimer; }; From 3f7eae6bcc8855649ce7e8c629480e8b70748e36 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 6 Mar 2018 09:21:22 +0100 Subject: [PATCH 0412/1027] #2537 Mohr circle: avoid clearing plot on selection = nullptr --- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 10 ++++------ ApplicationCode/UserInterface/RiuMohrsCirclePlot.h | 6 +++--- .../UserInterface/RiuSelectionChangedHandler.cpp | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index f6427fbf50..7a7b84f2d5 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -95,7 +95,7 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem) +void RiuMohrsCirclePlot::appendSelection(const RiuSelectionItem* selectionItem) { const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); @@ -103,7 +103,6 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select if (!geoMechSelectionItem) { - this->clearPlot(); return; } @@ -264,7 +263,7 @@ void RiuMohrsCirclePlot::deleteCircles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addEnvelope(const cvf::Vec3f& principals, RimGeoMechView* view) +void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view) { if (!view) return; @@ -376,8 +375,7 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView } caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0); - cvf::Vec3f dirs[3]; - cvf::Vec3f principals = elmTensor.calculatePrincipals(dirs); + cvf::Vec3f principals = elmTensor.calculatePrincipals(nullptr); if (!isValidPrincipals(principals)) { @@ -406,7 +404,7 @@ void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircle { m_mohrsCiclesInfos.push_back(mohrsCircleInfo); - addEnvelope(mohrsCircleInfo.principals, view); + addEnvelopeCurve(mohrsCircleInfo.principals, view); addMohrCircles(mohrsCircleInfo); updateTransparentCurvesOnPrincipals(); } diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 6a90555e0a..7cf366ca0f 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -47,12 +47,12 @@ class RiuMohrsCirclePlot : public QwtPlot RiuMohrsCirclePlot(QWidget* parent); ~RiuMohrsCirclePlot(); - void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); + void appendSelection(const RiuSelectionItem* selectionItem); void clearPlot(); void updateOnTimeStepChanged(Rim3dView* changedView); -public: +private: struct MohrsCirclesInfo { MohrsCirclesInfo(cvf::Vec3f principals, @@ -87,7 +87,7 @@ class RiuMohrsCirclePlot : public QwtPlot void addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo); void deleteCircles(); - void addEnvelope(const cvf::Vec3f& principals, RimGeoMechView* view); + void addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view); void deleteEnvelopes(); void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index e17fff9a9f..ab27893372 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -90,7 +90,7 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(nullptr); - RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(nullptr); + RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); updateResultInfo(nullptr); @@ -110,7 +110,7 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(item); - RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(item); + RiuMainWindow::instance()->mohrsCirclePlot()->appendSelection(item); updateResultInfo(item); @@ -124,7 +124,7 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i { RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); - RiuMainWindow::instance()->mohrsCirclePlot()->updateOnSelectionChanged(nullptr); + RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); handleItemAppended(item); } From 381ae6bd81aa606200403079ddd8ce7cc2cf6264 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 6 Mar 2018 09:22:03 +0100 Subject: [PATCH 0413/1027] #2527 Mohr circle: Make coloring of envelope more robust --- ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 7a7b84f2d5..fdb3dd0153 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -555,7 +555,7 @@ QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view) { if (m_envolopeColors.find(view) == m_envolopeColors.end()) { - cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(m_envolopePlotItems.size()); + cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(m_envolopeColors.size()); QColor color(cvfColor.r(), cvfColor.g(), cvfColor.b()); From c685453fbb07f9aebb10ecfe23f1dd8146ca9b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 10:01:47 +0100 Subject: [PATCH 0414/1027] #2563 Compaction. Fixed compaction calculation due to wrong sign --- .../GeoMechDataModel/RigFemPartResultsCollection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 5d95134a95..30964e5ba4 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1485,7 +1485,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues if (refElement.elementIdx != cvf::UNDEFINED_SIZE_T) { float shortestDist = HUGE_VALF; - size_t closestNodeIdx = cvf::UNDEFINED_SIZE_T; + size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; for (size_t nodeIdx : refElement.elementFaceNodeIdxs) { @@ -1493,11 +1493,11 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues if (dist < shortestDist) { shortestDist = dist; - closestNodeIdx = nodeIdx; + closestRefNodeIdx = nodeIdx; } } - compactionFrame[n] = u3Frames->frameData(t)[n] - u3Frames->frameData(t)[closestNodeIdx]; + compactionFrame[n] = u3Frames->frameData(t)[closestRefNodeIdx] - u3Frames->frameData(t)[n]; } else { From d92918d11e2647e158d0778fff5546870dff2605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 10:20:23 +0100 Subject: [PATCH 0415/1027] Fix Linux build error --- ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp index 3fd1977ba6..49c10dcc59 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp @@ -22,6 +22,7 @@ #include "RigFemPart.h" #include +#include //-------------------------------------------------------------------------------------------------- /// From c77c08222d9ddaa33a955f75ad61058767acdbca Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 6 Mar 2018 10:29:04 +0100 Subject: [PATCH 0416/1027] Mohr circle: Use same function to calculate FOS (=1/dsm) in results collection and mohrs plot --- .../RigFemPartResultsCollection.cpp | 27 +++++++++++++------ .../RigFemPartResultsCollection.h | 1 + .../UserInterface/RiuMohrsCirclePlot.cpp | 13 +++++---- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 30964e5ba4..973a9f120c 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -776,14 +776,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDSM(int partInde for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) { - float se1 = se1Data[vIdx]; - float se3 = se3Data[vIdx]; - float pi_4 = 0.785398163397448309616f; - float rho = 2.0f * ( atan( sqrt(( se1 + cohPrTanFricAngle)/(se3 + cohPrTanFricAngle)) ) - pi_4); - - { - dstFrameData[vIdx] = tan(rho)/tanFricAng; - } + dstFrameData[vIdx] = dsm(se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle); } frameCountProgress.incrementProgress(); @@ -2049,6 +2042,24 @@ int RigFemPartResultsCollection::frameCount() return static_cast(stepNames().size()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RigFemPartResultsCollection::dsm(float p1, float p3, float tanFricAng, float cohPrTanFricAngle) +{ + if (p1 == HUGE_VAL || p3 == HUGE_VAL) + { + return std::nan(""); + } + + CVF_ASSERT(p1 > p3); + + float pi_4 = 0.785398163397448309616f; + float rho = 2.0f * (atan(sqrt((p1 + cohPrTanFricAngle) / (p3 + cohPrTanFricAngle))) - pi_4); + + return tan(rho) / tanFricAng; +} + //-------------------------------------------------------------------------------------------------- /// Returns whether any of the parts actually had any of the requested results //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 729c75c196..63a8abfb0b 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -73,6 +73,7 @@ class RigFemPartResultsCollection: public cvf::Object int partCount() const; int frameCount(); + static float dsm(float p1, float p3, float tanFricAng, float cohPrTanFricAngle); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index fdb3dd0153..c9644e43e5 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -531,21 +531,20 @@ bool RiuMohrsCirclePlot::isValidPrincipals(const cvf::Vec3f& principals) //-------------------------------------------------------------------------------------------------- float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion) { - float se1 = principals[0]; - float se3 = principals[2]; - if (cvf::Math::cos(frictionAngle) == 0) { - return 0.0f; + return std::nan(""); } + float se1 = principals[0]; + float se3 = principals[2]; + float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle)); float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng; - float pi_4 = 0.785398163397448309616f; - float rho = 2.0f * (cvf::Math::atan(cvf::Math::sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4); + float dsm = RigFemPartResultsCollection::dsm(se1, se3, tanFricAng, cohPrTanFricAngle); - return tanFricAng / cvf::Math::tan(rho); + return 1.0f / dsm; } //-------------------------------------------------------------------------------------------------- From 8ce6784517561f8393d4d515fe4c9b3b468fb696 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 10:23:10 +0100 Subject: [PATCH 0417/1027] #2573 Eclipse Text File Import : Improve error message if required keyword is missing --- .../RifEclipseInputFileTools.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 0157e512ef..01f8597e08 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -20,6 +20,8 @@ #include "RifEclipseInputFileTools.h" +#include "RiaLogging.h" + #include "RifReaderEclipseOutput.h" #include "RigActiveCellInfo.h" @@ -90,6 +92,25 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC if (coordPos < 0 || zcornPos < 0 || specgridPos < 0) { + QString errorText = QString("Failed to import grid file '%1'\n").arg(fileName); + + if (coordPos < 0) + { + errorText += " Missing required keyword COORD"; + } + + if (zcornPos < 0) + { + errorText += " Missing required keyword ZCORN"; + } + + if (specgridPos < 0) + { + errorText += " Missing required keyword SPECGRID"; + } + + RiaLogging::error(errorText); + return false; } From 7f06f51e59da22de11eddf28c0e6f839d9e3ad7c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 10:29:35 +0100 Subject: [PATCH 0418/1027] Fix signed/unsigned compare --- ApplicationCode/ProjectDataModel/RimIntersection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 43561a5f17..3ca92e3fe4 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -672,7 +672,7 @@ int RimIntersection::branchIndex() const return -1; } - if (m_branchIndex >= m_simulationWellBranchCenterlines.size()) + if (m_branchIndex >= static_cast(m_simulationWellBranchCenterlines.size())) { return -1; } From f4b6542f6089c7424975402f1150d7206baf580a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 6 Mar 2018 12:54:02 +0100 Subject: [PATCH 0419/1027] #2575 Use Integration Point to calculate elm avg tensor --- .../ProjectDataModel/RimGeoMechView.cpp | 3 +- .../ProjectDataModel/RimTensorResults.cpp | 45 +++---------------- .../ProjectDataModel/RimTensorResults.h | 8 ++-- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 9ee21b3bb8..258523ba2f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -421,8 +421,7 @@ void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConf legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - QString legendTitle = "Tensors:\n" + caf::AppEnum(tensorResults()->resultPositionType()).uiText() + "\n" - + tensorResults()->resultFieldName(); + QString legendTitle = "Tensors:\n" + RimTensorResults::uiFieldName(resFieldName); legendConfig->setTitle(legendTitle); } diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index c98a6f2057..405f11445a 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -59,22 +59,15 @@ namespace caf //-------------------------------------------------------------------------------------------------- RimTensorResults::RimTensorResults() { - CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", ""); + CAF_PDM_InitObject("Element Tensor Results", ":/CellResult.png", "", ""); CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); this->legendConfig = new RimLegendConfig(); legendConfig.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", ""); - m_resultPositionType.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", ""); m_resultFieldName.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); - m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false); - m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false); - CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); m_resultFieldNameUiField.xmlCapability()->setIOWritable(false); m_resultFieldNameUiField.xmlCapability()->setIOReadable(false); @@ -93,9 +86,6 @@ RimTensorResults::RimTensorResults() m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - - m_resultPositionType = RIG_ELEMENT_NODAL; - m_resultPositionTypeUiField = m_resultPositionType; } //-------------------------------------------------------------------------------------------------- @@ -111,7 +101,7 @@ RimTensorResults::~RimTensorResults() //-------------------------------------------------------------------------------------------------- RigFemResultAddress RimTensorResults::selectedTensorResult() const { - return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), ""); + return RigFemResultAddress(resultPositionType(), m_resultFieldName().toStdString(), ""); } //-------------------------------------------------------------------------------------------------- @@ -191,9 +181,9 @@ RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemResultPosEnum RimTensorResults::resultPositionType() const +RigFemResultPosEnum RimTensorResults::resultPositionType() { - return m_resultPositionType(); + return RIG_INTEGRATION_POINT; } //-------------------------------------------------------------------------------------------------- @@ -222,21 +212,8 @@ std::vector RimTensorResults::getResultMetaDataForUIFieldSetting() //-------------------------------------------------------------------------------------------------- void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &m_resultPositionTypeUiField) - { - if (m_resultPositionTypeUiField() == m_resultPositionType()) - { - m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); - } - else - { - m_resultFieldNameUiField = ""; - } - } - if (changedField == &m_resultFieldNameUiField) { - m_resultPositionType = m_resultPositionTypeUiField; m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField); } if (changedField == &m_showTensors) @@ -265,17 +242,7 @@ QList RimTensorResults::calculateValueOptions(const caf: QList options; *useOptionsOnly = true; - if ( fieldNeedingOptions == &m_resultPositionTypeUiField) - { - using ResultEnum = caf::AppEnum; - - options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_ELEMENT_NODAL), - RigFemResultPosEnum::RIG_ELEMENT_NODAL)); - - options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_INTEGRATION_POINT), - RigFemResultPosEnum::RIG_INTEGRATION_POINT)); - } - else if (fieldNeedingOptions == &m_resultFieldNameUiField) + if (fieldNeedingOptions == &m_resultFieldNameUiField) { std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); @@ -293,7 +260,6 @@ QList RimTensorResults::calculateValueOptions(const caf: //-------------------------------------------------------------------------------------------------- void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_resultPositionTypeUiField); uiOrdering.add(&m_resultFieldNameUiField); caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility"); @@ -317,7 +283,6 @@ void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- void RimTensorResults::initAfterRead() { - m_resultPositionTypeUiField = m_resultPositionType; m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); } diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index 30990a0ab0..8091d3ac0e 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -69,8 +69,9 @@ class RimTensorResults : public caf::PdmObject TensorColors vectorColors() const; ScaleMethod scaleMethod() const; - RigFemResultPosEnum resultPositionType() const; - QString resultFieldName() const; + static RigFemResultPosEnum resultPositionType(); + QString resultFieldName() const; + static QString uiFieldName(const QString& fieldName); caf::PdmChildField legendConfig; @@ -83,16 +84,13 @@ class RimTensorResults : public caf::PdmObject virtual void initAfterRead() override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; - static QString uiFieldName(const QString& fieldName); static QString fieldNameFromUi(const QString& uiFieldName); private: caf::PdmField m_showTensors; - caf::PdmField> m_resultPositionType; caf::PdmField m_resultFieldName; - caf::PdmField> m_resultPositionTypeUiField; caf::PdmField m_resultFieldNameUiField; caf::PdmField m_principal1; From b2c0ea73f1d3f7fc07daa8241cae091df826bc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 13:10:58 +0100 Subject: [PATCH 0420/1027] Fix Linux build problem --- .../ProjectDataModel/RimGeoMechResultDefinition.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index ce0f48d30c..d96100f54a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -101,7 +101,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", (int)RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); @@ -137,7 +137,7 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); compactionGroup->add(&m_compactionRefLayerUiField); - if (m_compactionRefLayerUiField == RigFemResultAddress::NO_COMPACTION) + if (m_compactionRefLayerUiField == (int)RigFemResultAddress::NO_COMPACTION) { m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); } From b2204fb22a848f3dbe65087cd8830b86036d706c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 11:27:08 +0100 Subject: [PATCH 0421/1027] #2554 System : Create absolute path of project file before update of file references --- ApplicationCode/Application/RiaApplication.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 8d3a613e2e..fab9fd4ea8 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -362,16 +362,15 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi RiaLogging::info(QString("Starting to open project file : '%1'").arg(projectFileName)); - // Open the project file and read the serialized data. - // Will initialize itself. - - if (!caf::Utils::fileExists(projectFileName)) + // Create a absolute path file name, as this is required for update of file references in the project modifier object + QString fullPathProjectFileName = caf::Utils::absoluteFileName(projectFileName); + if (!caf::Utils::fileExists(fullPathProjectFileName)) { - RiaLogging::info(QString("File does not exist : '%1'").arg(projectFileName)); + RiaLogging::info(QString("File does not exist : '%1'").arg(fullPathProjectFileName)); return false; } - m_project->fileName = projectFileName; + m_project->fileName = fullPathProjectFileName; m_project->readFile(); // Apply any modifications to the loaded project before we go ahead and load actual data @@ -382,7 +381,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi // Propagate possible new location of project - m_project->setProjectFileNameAndUpdateDependencies(projectFileName); + m_project->setProjectFileNameAndUpdateDependencies(fullPathProjectFileName); // On error, delete everything, and bail out. @@ -390,7 +389,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { closeProject(); - QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName); + QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(fullPathProjectFileName); QMessageBox::warning(nullptr, "Error when opening project file", tmp); RiuMainWindow* mainWnd = RiuMainWindow::instance(); @@ -437,7 +436,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi // VL check regarding specific order mentioned in comment above... - m_preferences->lastUsedProjectFileName = projectFileName; + m_preferences->lastUsedProjectFileName = fullPathProjectFileName; caf::PdmSettings::writeFieldsToApplicationStore(m_preferences); for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) From ce2b4febbb126c67b519f70030bfcf614f3ef2fe Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 11:56:32 +0100 Subject: [PATCH 0422/1027] #2554 Regression Test : Detect command files and execute content --- .../Application/RiaApplication.cpp | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index fab9fd4ea8..1370d9f2de 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -164,6 +164,7 @@ namespace RegTestNames const QString testFolderFilter = "TestCase*"; const QString imageCompareExeName = "compare"; const QString reportFileName = "ResInsightRegressionTestReport.html"; + const QString commandFileFilter = "commandfile-*"; }; @@ -1998,7 +1999,6 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* QString baseFolderName = RegTestNames::baseFolderName; QString regTestProjectName = RegTestNames::testProjectName; QString regTestFolderFilter = RegTestNames::testFolderFilter; - // Find all sub folders QDir testDir(testRootPath); // If string is empty it will end up as cwd @@ -2091,6 +2091,39 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* { QDir testCaseFolder(folderList[dirIdx].filePath()); + // Detect any command files + QStringList filterList; + filterList << RegTestNames::commandFileFilter; + + QFileInfoList commandFileEntries = testCaseFolder.entryInfoList(filterList); + if (!commandFileEntries.empty()) + { + QString currentApplicationPath = QDir::current().absolutePath(); + + // Set current path to the folder containing the command file, as this is required when using file references + // in the command file + QDir::setCurrent(folderList[dirIdx].filePath()); + + for (const auto& fileInfo : commandFileEntries) + { + QString commandFile = fileInfo.absoluteFilePath(); + + QFile file(commandFile); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error("Failed to open command file : " + commandFile); + } + else + { + QTextStream in(&file); + RicfCommandFileExecutor::instance()->executeCommands(in); + } + } + + QDir::setCurrent(currentApplicationPath); + } + + QString projectFileName; if (testCaseFolder.exists(regTestProjectName + ".rip")) From ec96edf266be2f647ef10f8aeae7108682a7bdbd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 12:35:02 +0100 Subject: [PATCH 0423/1027] #2576 Command File : Add support for comments --- .../Core/RicfMessages.cpp | 9 +++ .../CommandFileInterface/Core/RicfMessages.h | 2 + .../Core/RifcCommandFileReader.cpp | 18 ++++-- .../UnitTests/RifcCommandCore-Test.cpp | 60 +++++++++++++++++++ 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp b/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp index a3628113ba..c565e8d1e2 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp @@ -79,3 +79,12 @@ QChar RicfMessages::peekNextChar(QTextStream& inputStream) } return ch; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfMessages::skipLineWithLineNumberCount(QTextStream& inputStream) +{ + inputStream.readLine(); + m_currentLineNumber++; +} diff --git a/ApplicationCode/CommandFileInterface/Core/RicfMessages.h b/ApplicationCode/CommandFileInterface/Core/RicfMessages.h index 00bb4a3190..7085b0c348 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfMessages.h +++ b/ApplicationCode/CommandFileInterface/Core/RicfMessages.h @@ -37,6 +37,8 @@ class RicfMessages void addError(const QString& message); void skipWhiteSpaceWithLineNumberCount(QTextStream& inputStream); + void skipLineWithLineNumberCount(QTextStream& inputStream); + QChar readCharWithLineNumberCount(QTextStream& inputStream); QChar peekNextChar(QTextStream& inputStream); diff --git a/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp b/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp index 7a0cc81f14..d10f25dbd0 100644 --- a/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp @@ -45,9 +45,15 @@ std::vector RicfCommandFileReader::readCommands(QTextStream& errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); while ( !inputStream.atEnd() ) { - QChar currentChar; - currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream); - if ( currentChar.isSpace() ) + QChar currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream); + + if (currentChar == QChar('#')) + { + errorMessageContainer->skipLineWithLineNumberCount(inputStream); + errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); + currentChar = QChar(); + } + else if ( currentChar.isSpace() ) { errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); QChar isBracket('a'); @@ -65,7 +71,11 @@ std::vector RicfCommandFileReader::readCommands(QTextStream& { break; } - commandName += currentChar; + + if (!currentChar.isNull()) + { + commandName += currentChar; + } } } diff --git a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp index 7842a67e2d..4ce0cf87ae 100644 --- a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp +++ b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp @@ -205,3 +205,63 @@ TEST(RicfCommands, TransformFileCommandObjectsToExecutableCommandObjects) delete(obj); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicfCommands, IgnoreCommentLines) +{ + QString commandString = R"( + replaceCase(newGridFile="/1.EGRID", caseId=1) + # replaceCase(newGridFile="/2.EGRID", caseId=2) + + openProject(path="/home/user/ResInsightProject.rsp") + replaceCase(newGridFile="/3.EGRID", caseId=3) + # replaceCase(newGridFile="/4.EGRID", caseId=4) + + exportSnapshots() + replaceCase(newGridFile="/6.EGRID", caseId=6) + replaceCase(newGridFile="/7.EGRID", caseId=7) + + closeProject() + + )"; + + QTextStream inputStream(&commandString); + RicfMessages errors; + + auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance(), &errors); + EXPECT_TRUE(errors.m_messages.empty()); + + EXPECT_EQ((size_t)7, objects.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicfCommands, IgnoreCommentLinesShowErrorLine) +{ + QString commandString = R"( + replaceCase(newGridFile="/1.EGRID", caseId=1) + # replaceCase(newGridFile="/2.EGRID", caseId=2) + + openProject(path="/home/user/ResInsightProject.rsp") + replaceCase(newGridFile="/3.EGRID", caseId=3) + # replaceCase(newGridFile="/4.EGRID", caseId=4) + + + exportSnapshots() + sdareplaceCase(newGridFile="/6.EGRID", caseId=6) + replaceCase(newGridFile="/7.EGRID", caseId=7) + + closeProject() + + )"; + + QTextStream inputStream(&commandString); + RicfMessages errors; + + auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance(), &errors); + EXPECT_EQ((size_t)1, errors.m_messages.size()); + EXPECT_EQ((size_t)6, objects.size()); +} From 2435e92be13e3d607e9f87292c44b75a2ec2a465 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 13:18:39 +0100 Subject: [PATCH 0424/1027] #2577 Test : Add test toolbar to launch unit tests and regression tests --- .../Application/RiaPreferences.cpp | 4 ++ ApplicationCode/Application/RiaPreferences.h | 1 + .../CMakeLists_files.cmake | 2 + .../RicLaunchRegressionTestsFeature.cpp | 60 +++++++++++++++++++ .../RicLaunchRegressionTestsFeature.h | 34 +++++++++++ .../UserInterface/RiuMainWindow.cpp | 9 +++ 6 files changed, 110 insertions(+) create mode 100644 ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp create mode 100644 ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index bfbba55707..b7ed3af14c 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -72,6 +72,8 @@ RiaPreferences::RiaPreferences(void) appendClassNameToUiText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitField(&appendFieldKeywordToToolTipText, "appendFieldKeywordToToolTipText", false, "Show Field Keyword in ToolTip", "", "", ""); appendFieldKeywordToToolTipText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&showTestToolbar, "showTestToolbar", false, "Enable Test Toolbar", "", "", ""); + showTestToolbar.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitField(&includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, "Include Fracture Debug Info for Completion Export", "", "", ""); includeFractureDebugInfoFile.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); @@ -124,6 +126,7 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt field == &showHud || field == &appendClassNameToUiText || field == &appendFieldKeywordToToolTipText || + field == &showTestToolbar || field == &includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning) { @@ -184,6 +187,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& { uiOrdering.add(&appendClassNameToUiText); uiOrdering.add(&appendFieldKeywordToToolTipText); + uiOrdering.add(&showTestToolbar); uiOrdering.add(&includeFractureDebugInfoFile); } diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 4926c62a25..3fcd582ec6 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -68,6 +68,7 @@ class RiaPreferences : public caf::PdmObject caf::PdmField showHud; caf::PdmField appendClassNameToUiText; caf::PdmField appendFieldKeywordToToolTipText; + caf::PdmField showTestToolbar; caf::PdmField includeFractureDebugInfoFile; caf::PdmField lastUsedProjectFileName; diff --git a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 443493fdd6..901b6428a7 100644 --- a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -13,6 +13,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.h ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -29,6 +30,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.cpp ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp new file mode 100644 index 0000000000..fad2f14568 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicLaunchRegressionTestsFeature.h" + +#include "RiaApplication.h" +#include "RiaRegressionTest.h" + +#include "cafPdmSettings.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicLaunchRegressionTestsFeature, "RicLaunchRegressionTestsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicLaunchRegressionTestsFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked) +{ + RiaRegressionTest regTestConfig; + + caf::PdmSettings::readFieldsFromApplicationStore(®TestConfig); + + QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts); + + // Launch regression test using the current test folder and test filter + RiaApplication::instance()->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Launch Regression Tests"); +} diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h new file mode 100644 index 0000000000..9948adbb55 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicLaunchRegressionTestsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index df2ac94df1..aae719e4fa 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -536,6 +536,15 @@ void RiuMainWindow::createToolBars() dsToolBar->addAction(m_showWellCellsAction); } + RiaApplication* app = RiaApplication::instance(); + if (app->preferences()->showTestToolbar()) + { + QToolBar* toolbar = addToolBar(tr("Test")); + toolbar->setObjectName(toolbar->windowTitle()); + toolbar->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); + toolbar->addAction(cmdFeatureMgr->action("RicLaunchRegressionTestsFeature")); + } + // Create animation toolbar m_animationToolBar = new caf::AnimationToolBar("Animation", this); addToolBar(m_animationToolBar); From 1792163d55e85b8c42be05a4b9ce5f4d880ff29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 14:18:26 +0100 Subject: [PATCH 0425/1027] #2474 Fractures. Do not store object name to project file --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimCheckableObject.cpp | 61 +++++++++++++++++++ .../ProjectDataModel/RimCheckableObject.h | 44 +++++++++++++ .../ProjectDataModel/RimStimPlanColors.cpp | 5 +- .../ProjectDataModel/RimStimPlanColors.h | 4 +- 5 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimCheckableObject.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimCheckableObject.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index ee0a98820c..10c888ad6f 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -87,6 +87,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.h ${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.h ${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.h +${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.h ${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.h @@ -188,6 +189,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.cpp diff --git a/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp b/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp new file mode 100644 index 0000000000..33946e0508 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimCheckableObject.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCheckableObject, "RimCheckableObject"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableObject::RimCheckableObject(void) +{ + CAF_PDM_InitField(&m_isChecked, "IsChecked", true, "Active", "", "", ""); + m_isChecked.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableObject::~RimCheckableObject(void) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCheckableObject::isChecked() const +{ + return m_isChecked(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCheckableObject::setCheckState(bool checkState) +{ + m_isChecked = checkState; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCheckableObject::objectToggleField() +{ + return &m_isChecked; +} diff --git a/ApplicationCode/ProjectDataModel/RimCheckableObject.h b/ApplicationCode/ProjectDataModel/RimCheckableObject.h new file mode 100644 index 0000000000..d2ed97adfa --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableObject.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCheckableObject : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimCheckableObject(void); + virtual ~RimCheckableObject(void); + + bool isChecked() const; + void setCheckState(bool checkState); + +protected: + virtual caf::PdmFieldHandle* objectToggleField() override; + +protected: + caf::PdmField m_isChecked; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 5f064f4869..5d713b2b99 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -64,7 +64,7 @@ static QString toString(const std::pair& resultNameAndUnit); //-------------------------------------------------------------------------------------------------- RimStimPlanColors::RimStimPlanColors() { - CAF_PDM_InitObject("StimPlan Colors", ":/FractureSymbol16x16.png", "", ""); + CAF_PDM_InitObject("Fractures", ":/FractureSymbol16x16.png", "", ""); CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "Result Variable", "", "", ""); @@ -76,9 +76,6 @@ RimStimPlanColors::RimStimPlanColors() CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show Mesh", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation", "", "", ""); - - setName("Fractures"); - nameField()->uiCapability()->setUiReadOnly(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index 8da9052202..fb40eb701f 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -18,7 +18,7 @@ #pragma once -#include "RimCheckableNamedObject.h" +#include "RimCheckableObject.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -40,7 +40,7 @@ class RimFractureTemplateCollection; /// /// //================================================================================================== -class RimStimPlanColors : public RimCheckableNamedObject +class RimStimPlanColors : public RimCheckableObject { CAF_PDM_HEADER_INIT; From 8b9b0b8787dfbe785e87ab8909f0f892c362d45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 14:47:17 +0100 Subject: [PATCH 0426/1027] #2488 Formation names. Fix empty formation names dropdown --- ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 0cc6c8c802..90b3360c8c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -677,6 +677,8 @@ QList RimGeoMechCase::calculateValueOptions(const caf::P { QList options; + options = RimCase::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + if (fieldNeedingOptions == &m_elementPropertyFileNameIndexUiSelection) { for (size_t i = 0; i < m_elementPropertyFileNames.v().size(); i++) From fab8f2d6a09f38897c8731696351160a52836e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 15:38:03 +0100 Subject: [PATCH 0427/1027] #2505 Fix command argument types --- .../CommandFileInterface/RicfSetFractureContainment.cpp | 8 ++++---- .../CommandFileInterface/RicfSetFractureContainment.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp index dbe131d8a5..f5eaa7e81c 100644 --- a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp @@ -34,8 +34,8 @@ CAF_PDM_SOURCE_INIT(RicfSetFractureContainment, "setFractureContainment"); RicfSetFractureContainment::RicfSetFractureContainment() { RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); - RICF_InitField(&m_topLayer, "topLayer", 1.0, "TopLayer", "", "", ""); - RICF_InitField(&m_baseLayer, "baseLayer", 1.0, "BaseLayer", "", "", ""); + RICF_InitField(&m_topLayer, "topLayer", -1, "TopLayer", "", "", ""); + RICF_InitField(&m_baseLayer, "baseLayer", -1, "BaseLayer", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -43,9 +43,9 @@ RicfSetFractureContainment::RicfSetFractureContainment() //-------------------------------------------------------------------------------------------------- void RicfSetFractureContainment::execute() { - if (m_id < 0) + if (m_id < 0 || m_topLayer < 0 || m_baseLayer < 0) { - RiaLogging::error("setFractureContainment: Fracture template id not specified"); + RiaLogging::error("setFractureContainment: Required argument missing"); return; } diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h index b372cfdeb8..238fa6e37c 100644 --- a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h @@ -40,6 +40,6 @@ class RicfSetFractureContainment : public RicfCommandObject private: caf::PdmField m_id; - caf::PdmField m_topLayer; - caf::PdmField m_baseLayer; + caf::PdmField m_topLayer; + caf::PdmField m_baseLayer; }; From 3c26640f562d137baaaa2e5b88cf7cf50b915562 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 6 Mar 2018 16:05:01 +0100 Subject: [PATCH 0428/1027] #2579 2D Intersection View: apply Info Box on/off in main view to 2Dview --- .../Rim2dIntersectionView.cpp | 9 ++++ .../Rim3dOverlayInfoConfig.cpp | 41 +++++++++++++------ .../ProjectDataModel/Rim3dOverlayInfoConfig.h | 9 ++-- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 65942e400e..fc89cd18b1 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -177,6 +177,15 @@ void Rim2dIntersectionView::update3dInfo() RimEclipseView * eclView = nullptr; m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView && !eclView->overlayInfoConfig()->isActive()) + { + m_viewer->showInfoText(false); + m_viewer->showHistogram(false); + m_viewer->showAnimationProgress(false); + + m_viewer->update(); + return; + } if (eclView && eclView->overlayInfoConfig()->showCaseInfo()) { overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index f437ed6f78..d6b1aaff5c 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -232,7 +232,7 @@ QImage Rim3dOverlayInfoConfig::statisticsDialogScreenShotImage() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dOverlayInfoConfig::showAnimProgress() +bool Rim3dOverlayInfoConfig::showAnimProgress() const { return m_showAnimProgress; } @@ -240,7 +240,7 @@ bool Rim3dOverlayInfoConfig::showAnimProgress() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dOverlayInfoConfig::showCaseInfo() +bool Rim3dOverlayInfoConfig::showCaseInfo() const { return m_showCaseInfo; } @@ -248,11 +248,19 @@ bool Rim3dOverlayInfoConfig::showCaseInfo() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dOverlayInfoConfig::showResultInfo() +bool Rim3dOverlayInfoConfig::showResultInfo() const { return m_showResultInfo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::isActive() const +{ + return m_active; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -687,6 +695,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() m_viewDef->viewer()->showHistogram(false); m_viewDef->viewer()->showAnimationProgress(false); + update3DInfoIn2dViews(); return; } @@ -722,15 +731,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() m_gridStatisticsDialog->updateFromRimView(geoMechView); } - RimCase* rimCase; - firstAncestorOrThisOfType(rimCase); - if (rimCase) - { - for (Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views()) - { - view->update3dInfo(); - } - } + update3DInfoIn2dViews(); } //-------------------------------------------------------------------------------------------------- @@ -870,6 +871,22 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dOverlayInfoConfig::update3DInfoIn2dViews() const +{ + RimCase* rimCase; + firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + for (Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views()) + { + view->update3dInfo(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 9938a05558..9a55f603fd 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -79,9 +79,10 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void showStatisticsInfoDialog(bool raise = true); QImage statisticsDialogScreenShotImage(); - bool showAnimProgress(); - bool showCaseInfo(); - bool showResultInfo(); + bool showAnimProgress() const; + bool showCaseInfo() const; + bool showResultInfo() const; + bool isActive() const; enum StatisticsTimeRangeType { @@ -105,6 +106,8 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void updateEclipse3DInfo(RimEclipseView * reservoirView); void updateGeoMech3DInfo(RimGeoMechView * geoMechView); + void update3DInfoIn2dViews() const; + QString timeStepText(RimEclipseView* eclipseView); QString timeStepText(RimGeoMechView* geoMechView); HistogramData histogramData(RimEclipseView* eclipseView); From b13422d28b77b31e076fc0fa29aa6bce16726ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 6 Mar 2018 14:59:38 +0100 Subject: [PATCH 0429/1027] Guard against stepsize < 0 in tickMarkGenerator --- Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h index 88084ff9f0..4427334f98 100644 --- a/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h @@ -47,6 +47,8 @@ class TickMarkGenerator public: TickMarkGenerator(double min, double max, double minAllowedStepSize) { + if (minAllowedStepSize < 0.0) minAllowedStepSize = -minAllowedStepSize; + double step = roundUpToLog_1_2_5_10(minAllowedStepSize); double startStepCount = ceil(min / step); From 91daf49e8abae065cef65f747019050740a6b4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 6 Mar 2018 15:14:54 +0100 Subject: [PATCH 0430/1027] #2578 Fix avoid UTM coordinates in 2D intersection View (behind the scenes) --- .../Intersections/RivIntersectionGeometryGenerator.cpp | 7 ++++++- .../ProjectDataModel/Rim2dIntersectionView.cpp | 9 +++++++++ ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h | 3 +++ ApplicationCode/ProjectDataModel/RimIntersection.cpp | 5 +++-- ApplicationCode/UserInterface/RiuResultTextBuilder.cpp | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index bfe95eaab7..b7b8417922 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -144,14 +144,16 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() cvf::Vec3d p2 = polyLine[idxToNextP]; cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, m_extrusionDirection); + if ( pLineIdx == 0 && lIdx == 0 ) previousSectionOrigo = sectionLocalCS.translation(); + previousSectionFlattenedEndPosX += (sectionLocalCS.translation() - previousSectionOrigo).length(); previousSectionOrigo = sectionLocalCS.translation(); invSectionCS = sectionLocalCS.getInverted(); cvf::Vec3d flattenedTranslation(previousSectionFlattenedEndPosX, 0.0, 0.0); - invSectionCS.setTranslation(invSectionCS.translation() + flattenedTranslation - displayOffset); + invSectionCS.setTranslation(invSectionCS.translation() + flattenedTranslation ); } size_t inc = 0; @@ -210,6 +212,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() if (polyLine.size() < 2) continue; size_t lineCount = polyLine.size(); + //size_t lIdx = 0; + //while ( lIdx < lineCount - 1) for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx) { size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); @@ -402,6 +406,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() } } } +// lIdx = idxToNextP; } } m_triangleVxes->assign(triangleVertices); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index fc89cd18b1..810c0a08be 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -41,6 +41,7 @@ #include "RimWellPath.h" #include +#include "cafDisplayCoordTransform.h" CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); @@ -287,6 +288,14 @@ void Rim2dIntersectionView::update3dInfo() m_viewer->update(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim2dIntersectionView::displayCoordTransform() const +{ + return new caf::DisplayCoordTransform(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 4ed2befb49..8db542c59c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -60,6 +60,9 @@ class Rim2dIntersectionView : public Rim3dView cvf::ref flatIntersectionPartMgr() const { return m_flatIntersectionPartMgr; } + + virtual cvf::ref displayCoordTransform() const override; + protected: void updateLegends(); diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 3ca92e3fe4..0764e6ee48 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -392,11 +392,12 @@ void RimIntersection::updateAzimuthLine() //-------------------------------------------------------------------------------------------------- std::vector< std::vector > RimIntersection::polyLines(double * horizontalLengthAlongWellToPolylineStart) const { - CVF_ASSERT(horizontalLengthAlongWellToPolylineStart != nullptr); + if (horizontalLengthAlongWellToPolylineStart) *horizontalLengthAlongWellToPolylineStart = 0.0; std::vector< std::vector > lines; + double horizontalProjectedLengthAlongWellPathToClipPoint = 0.0; - if (horizontalLengthAlongWellToPolylineStart) *horizontalLengthAlongWellToPolylineStart = 0.0; + if (type == CS_WELL_PATH) { if (wellPath() && wellPath->wellPathGeometry() ) diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index bc7af30898..cffb7bc60a 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -191,7 +191,7 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) QString formattedText; if (m_2dIntersectionView) { - formattedText.sprintf("Horizontal length from well start: %.2f", domainCoord.x()); + formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); text += formattedText + itemSeparator; cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); From 0083ecdf6a1f68bbedc8d90e86f04e75fa83372a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 6 Mar 2018 16:30:15 +0100 Subject: [PATCH 0431/1027] #2506 Finally found the error with near vertical intersections --- .../RivIntersectionGeometryGenerator.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index b7b8417922..d134b593f1 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -36,6 +36,7 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapper.h" #include "cvfRay.h" +//#include "cvfTrace.h" //-------------------------------------------------------------------------------------------------- @@ -84,7 +85,9 @@ cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Ve sectionLineDir.normalize(); Vec3d Ey = Ez ^ sectionLineDir; + Ey.normalize(); Vec3d Ex = Ey ^ Ez; + Ex.normalize(); Ray extrusionRay; extrusionRay.setOrigin(p1); @@ -166,6 +169,27 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() lIdx = idxToNextP; } } + + // for (auto mx: m_segementTransformPrLinePoint[0]) + // { + // cvf::String text; + // + // for (int r = 0; r < 4; ++r) + // { + // for (int c = 0; c < 4; ++c) + // { + // text += cvf::String::number(mx(r, c)); + // + // if (r * c < 9) + // { + // text += " "; + // } + // } + // text += "\n"; + // } + // + // cvf::Trace::show( text ); + // } } //-------------------------------------------------------------------------------------------------- @@ -212,9 +236,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() if (polyLine.size() < 2) continue; size_t lineCount = polyLine.size(); - //size_t lIdx = 0; - //while ( lIdx < lineCount - 1) - for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx) + size_t lIdx = 0; + while ( lIdx < lineCount - 1) { size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); @@ -406,7 +429,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() } } } -// lIdx = idxToNextP; + lIdx = idxToNextP; } } m_triangleVxes->assign(triangleVertices); From 08ce58b2fa5b2355537e59bd0dbc5209387ec3bb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 13:42:57 +0100 Subject: [PATCH 0432/1027] #2554 Export Completions : Do not create two folders if export folder does not exist --- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 89c46ff64b..08249c07c0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -488,10 +488,9 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile( if (completionsPerGrid.empty()) return; QDir exportFolder(folderName); - if (!exportFolder.exists()) { - bool createdPath = exportFolder.mkpath(folderName); + bool createdPath = exportFolder.mkpath("."); if (createdPath) RiaLogging::info("Created export folder " + folderName); else From 2e122d2ab3257e8b8d9f94de09a24e4be05a5b14 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 17:42:00 +0100 Subject: [PATCH 0433/1027] #2554 Regression Test : Move serialization code into RiaRegressionTest --- .../Application/Tools/RiaRegressionTest.cpp | 17 +++++++++++++++++ .../Application/Tools/RiaRegressionTest.h | 3 +++ ApplicationCode/UserInterface/RiuMainWindow.cpp | 7 +++---- .../cafPdmXml/cafPdmSettings.cpp | 2 +- .../cafPdmXml/cafPdmSettings.h | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp index f08fab4d4c..95ea9d8f1f 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp @@ -18,6 +18,7 @@ #include "RiaRegressionTest.h" +#include "cafPdmSettings.h" #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiTextEditor.h" @@ -49,6 +50,22 @@ RiaRegressionTest::~RiaRegressionTest(void) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTest::writeSettingsToApplicationStore() const +{ + caf::PdmSettings::writeFieldsToApplicationStore(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTest::readSettingsFromApplicationStore() +{ + caf::PdmSettings::readFieldsFromApplicationStore(this); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.h b/ApplicationCode/Application/Tools/RiaRegressionTest.h index 04eab1f83e..b46d6f93a1 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.h @@ -32,6 +32,9 @@ class RiaRegressionTest : public caf::PdmObject RiaRegressionTest(void); virtual ~RiaRegressionTest(void); + void writeSettingsToApplicationStore() const; + void readSettingsFromApplicationStore(); + public: caf::PdmField applicationWorkingFolder; caf::PdmField regressionTestFolder; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index aae719e4fa..4c33cb1426 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1716,9 +1716,7 @@ void RiuMainWindow::slotCreateCommandObject() void RiuMainWindow::slotShowRegressionTestDialog() { RiaRegressionTest regTestConfig; - - RiaApplication* app = RiaApplication::instance(); - caf::PdmSettings::readFieldsFromApplicationStore(®TestConfig); + regTestConfig.readSettingsFromApplicationStore(); caf::PdmUiPropertyViewDialog regressionTestDialog(this, ®TestConfig, "Regression Test", ""); regressionTestDialog.resize(QSize(600, 300)); @@ -1726,7 +1724,7 @@ void RiuMainWindow::slotShowRegressionTestDialog() if (regressionTestDialog.exec() == QDialog::Accepted) { // Write preferences using QSettings and apply them to the application - caf::PdmSettings::writeFieldsToApplicationStore(®TestConfig); + regTestConfig.writeSettingsToApplicationStore(); QString currentApplicationPath = QDir::currentPath(); @@ -1734,6 +1732,7 @@ void RiuMainWindow::slotShowRegressionTestDialog() QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts); + RiaApplication* app = RiaApplication::instance(); app->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); QDir::setCurrent(currentApplicationPath); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp index 06620a0a6a..faa6888b35 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp @@ -94,7 +94,7 @@ void PdmSettings::readFieldsFromApplicationStore(caf::PdmObjectHandle* object, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmSettings::writeFieldsToApplicationStore(caf::PdmObjectHandle* object, const QString context) +void PdmSettings::writeFieldsToApplicationStore(const caf::PdmObjectHandle* object, const QString context) { CAF_ASSERT(object); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h index 22bf3eb47a..8de5adc6ea 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h @@ -48,7 +48,7 @@ class PdmSettings { public: static void readFieldsFromApplicationStore(caf::PdmObjectHandle* object, const QString context = ""); - static void writeFieldsToApplicationStore(caf::PdmObjectHandle* object, const QString context = ""); + static void writeFieldsToApplicationStore(const caf::PdmObjectHandle* object, const QString context = ""); }; From 91428a028da59138f101f4697fea727f7a5efb08 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 6 Mar 2018 17:59:40 +0100 Subject: [PATCH 0434/1027] #2554 Regression Test : Reorganize setting of current working folder --- .../Application/RiaApplication.cpp | 29 +++++++++++++++++++ ApplicationCode/Application/RiaApplication.h | 1 + .../Application/Tools/RiaRegressionTest.cpp | 6 ++-- .../Application/Tools/RiaRegressionTest.h | 2 +- .../RicLaunchRegressionTestsFeature.cpp | 9 +----- .../UserInterface/RiuMainWindow.cpp | 10 +------ 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 1370d9f2de..ffe32f65e9 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -28,6 +28,7 @@ #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaProjectModifier.h" +#include "RiaRegressionTest.h" #include "RiaSocketServer.h" #include "RiaVersionInfo.h" #include "RiaViewRedrawScheduler.h" @@ -1994,6 +1995,18 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* { m_runningRegressionTests = true; + RiaRegressionTest regressionTestConfig; + regressionTestConfig.readSettingsFromApplicationStore(); + + QString currentApplicationPath = QDir::currentPath(); + if (!regressionTestConfig.folderContainingCompareTool().isEmpty()) + { + // Windows Only : The image compare tool requires current working directory to be at the folder + // containing the image compare tool + + QDir::setCurrent(regressionTestConfig.folderContainingCompareTool()); + } + QString generatedFolderName = RegTestNames::generatedFolderName; QString diffFolderName = RegTestNames::diffFolderName; QString baseFolderName = RegTestNames::baseFolderName; @@ -2189,6 +2202,8 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* RiaLogging::info("\n"); logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); + QDir::setCurrent(currentApplicationPath); + m_runningRegressionTests = false; } @@ -2449,6 +2464,20 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath, Q } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::executeRegressionTests() +{ + RiaRegressionTest testConfig; + testConfig.readSettingsFromApplicationStore(); + + QString testPath = testConfig.regressionTestFolder(); + QStringList testFilter = testConfig.testFilter().split(";", QString::SkipEmptyParts); + + executeRegressionTests(testPath, &testFilter); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 04acc543f6..17d0bae7f9 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -99,6 +99,7 @@ class RiaApplication : public QApplication bool parseArguments(); void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr); + void executeRegressionTests(); void setActiveReservoirView(Rim3dView*); Rim3dView* activeReservoirView(); diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp index 95ea9d8f1f..15bfa02db9 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp @@ -30,8 +30,8 @@ CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest"); //-------------------------------------------------------------------------------------------------- RiaRegressionTest::RiaRegressionTest(void) { - CAF_PDM_InitFieldNoDefault(&applicationWorkingFolder, "workingFolder", "Folder containing compare", "", "Location of compare tool from Image Magic suite", ""); - applicationWorkingFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool, "workingFolder", "Folder containing compare", "", "Location of compare tool from Image Magic suite", ""); + folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", ""); regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); @@ -71,7 +71,7 @@ void RiaRegressionTest::readSettingsFromApplicationStore() //-------------------------------------------------------------------------------------------------- void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - if (field == &applicationWorkingFolder || field == ®ressionTestFolder) + if (field == &folderContainingCompareTool || field == ®ressionTestFolder) { caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.h b/ApplicationCode/Application/Tools/RiaRegressionTest.h index b46d6f93a1..2a35031084 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.h @@ -36,7 +36,7 @@ class RiaRegressionTest : public caf::PdmObject void readSettingsFromApplicationStore(); public: - caf::PdmField applicationWorkingFolder; + caf::PdmField folderContainingCompareTool; caf::PdmField regressionTestFolder; caf::PdmField testFilter; caf::PdmField showInteractiveDiffImages; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp index fad2f14568..6d62294ae9 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp @@ -41,14 +41,7 @@ bool RicLaunchRegressionTestsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked) { - RiaRegressionTest regTestConfig; - - caf::PdmSettings::readFieldsFromApplicationStore(®TestConfig); - - QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts); - - // Launch regression test using the current test folder and test filter - RiaApplication::instance()->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); + RiaApplication::instance()->executeRegressionTests(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 4c33cb1426..63e7e581bd 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1726,16 +1726,8 @@ void RiuMainWindow::slotShowRegressionTestDialog() // Write preferences using QSettings and apply them to the application regTestConfig.writeSettingsToApplicationStore(); - QString currentApplicationPath = QDir::currentPath(); - - QDir::setCurrent(regTestConfig.applicationWorkingFolder); - - QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts); - RiaApplication* app = RiaApplication::instance(); - app->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); - - QDir::setCurrent(currentApplicationPath); + app->executeRegressionTests(); } } From cec745d08af5469bbb063741db233c6ce43a4d98 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 7 Mar 2018 09:06:42 +0100 Subject: [PATCH 0435/1027] #2554 Regression Test : Add text file compare tool and display folder in test config --- .../Application/Tools/CMakeLists_files.cmake | 2 + .../Application/Tools/RiaRegressionTest.cpp | 7 +- .../Application/Tools/RiaRegressionTest.h | 1 + .../Application/Tools/RiaTextFileCompare.cpp | 139 ++++++++++++++++++ .../Application/Tools/RiaTextFileCompare.h | 57 +++++++ .../UnitTests/CMakeLists_files.cmake | 3 +- .../UnitTests/RiaTextFileCompare-Test.cpp | 68 +++++++++ .../base/folderA/getting_started.txt | 12 ++ .../base/folderB/folderC/getting_started.txt | 12 ++ .../reference/folderA/getting_started.txt | 12 ++ .../folderB/folderC/getting_started.txt | 12 ++ 11 files changed, 321 insertions(+), 4 deletions(-) create mode 100644 ApplicationCode/Application/Tools/RiaTextFileCompare.cpp create mode 100644 ApplicationCode/Application/Tools/RiaTextFileCompare.h create mode 100644 ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp create mode 100644 ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt create mode 100644 ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt create mode 100644 ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt create mode 100644 ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index 45069ba744..a8c4615eb3 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -20,6 +20,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -43,6 +44,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp index 15bfa02db9..2d696c5f59 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp @@ -33,6 +33,9 @@ RiaRegressionTest::RiaRegressionTest(void) CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool, "workingFolder", "Folder containing compare", "", "Location of compare tool from Image Magic suite", ""); folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(&folderContainingDiffTool, "folderContainingDiffTool", "Folder containing diff", "", "Location of diff tool used for text compare", ""); + folderContainingDiffTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", ""); regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); @@ -71,7 +74,7 @@ void RiaRegressionTest::readSettingsFromApplicationStore() //-------------------------------------------------------------------------------------------------- void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - if (field == &folderContainingCompareTool || field == ®ressionTestFolder) + if (field == &folderContainingDiffTool || field == &folderContainingCompareTool || field == ®ressionTestFolder) { caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -80,5 +83,3 @@ void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, } } } - - diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.h b/ApplicationCode/Application/Tools/RiaRegressionTest.h index 2a35031084..e4d815ed4f 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.h @@ -37,6 +37,7 @@ class RiaRegressionTest : public caf::PdmObject public: caf::PdmField folderContainingCompareTool; + caf::PdmField folderContainingDiffTool; caf::PdmField regressionTestFolder; caf::PdmField testFilter; caf::PdmField showInteractiveDiffImages; diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp new file mode 100644 index 0000000000..90bdc35cd9 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaTextFileCompare.h" + +#include "cafUtils.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::RiaTextFileCompare(const QString& pathToDiffTool) + : m_pathToDiffTool(pathToDiffTool) +{ + reset(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::~RiaTextFileCompare() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaTextFileCompare::reset() +{ + m_lastError = IC_NO_ERROR; + m_errorMsg.clear(); + m_errorDetails.clear(); + m_diffOutput.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaTextFileCompare::runComparison(const QString& baseFolder, const QString& generatedFolder) +{ + reset(); + + QString fullFilePath = "diff"; + if (!m_pathToDiffTool.isEmpty()) + { + fullFilePath = m_pathToDiffTool + "/" + fullFilePath; + } + + // Run compare recursively with '-r' + QString args = "-r"; + + QString completeCommand = QString("\"%1\" %2 %3 %4").arg(fullFilePath).arg(baseFolder).arg(generatedFolder).arg(args); + + // Launch process and wait + QProcess proc; + proc.start(completeCommand); + proc.waitForFinished(30000); + + QProcess::ProcessError procError = proc.error(); + if (procError != QProcess::UnknownError) + { + m_lastError = SEVERE_ERROR; + m_errorMsg = "Error running 'diff' tool process"; + m_errorDetails = completeCommand; + return false; + } + + QByteArray stdErr = proc.readAllStandardError(); + int procExitCode = proc.exitCode(); + + if (procExitCode == 0) + { + return true; + } + else if (procExitCode == 1) + { + QByteArray stdOut = proc.readAllStandardOutput(); + m_diffOutput = stdOut; + + return false; + } + else + { + stdErr = stdErr.simplified(); + + // Report non-severe error + m_lastError = IC_ERROR; + m_errorMsg = "Error running 'diff' tool process"; + m_errorDetails = stdErr; + + return false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::ErrorType RiaTextFileCompare::error() const +{ + return m_lastError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::errorMessage() const +{ + return m_errorMsg; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::errorDetails() const +{ + return m_errorDetails; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::diffOutput() const +{ + return m_diffOutput; +} diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.h b/ApplicationCode/Application/Tools/RiaTextFileCompare.h new file mode 100644 index 0000000000..ef05fe3f17 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +//================================================================================================== +// +// Execute text compare between to folders recursively using the external tool 'diff' +// +//================================================================================================== +class RiaTextFileCompare +{ +public: + enum ErrorType + { + IC_NO_ERROR, // No error occurred + IC_ERROR, // An error occurred + SEVERE_ERROR // Severe error occurred, it is likely that another call to compare() will also fail + }; + +public: + explicit RiaTextFileCompare(const QString& pathToDiffTool); + ~RiaTextFileCompare(); + + bool runComparison(const QString& baseFolder, const QString& generatedFolder); + ErrorType error() const; + QString errorMessage() const; + QString errorDetails() const; + QString diffOutput() const; + +private: + void reset(); + +private: + const QString m_pathToDiffTool; + ErrorType m_lastError; + QString m_errorMsg; + QString m_errorDetails; + QString m_diffOutput; +}; diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 7abc8e51ec..47d5eccb7e 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -38,7 +38,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp -${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp b/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp new file mode 100644 index 0000000000..a80e2f5a35 --- /dev/null +++ b/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp @@ -0,0 +1,68 @@ +#include "gtest/gtest.h" + +#include "RiaRegressionTest.h" +#include "RiaTestDataDirectory.h" +#include "RiaTextFileCompare.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareWithDiff) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/base").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_FALSE(noDifference); + + QString diffOutput = compare.diffOutput(); + EXPECT_FALSE(diffOutput.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareNoDiff) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/base/folderB").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference/folderB").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_TRUE(noDifference); + + QString diffOutput = compare.diffOutput(); + EXPECT_TRUE(diffOutput.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareError) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/baseDoesNotExist").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference/folderB").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_FALSE(noDifference); + + QString error = compare.errorMessage(); + EXPECT_FALSE(error.isEmpty()); +} diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt new file mode 100644 index 0000000000..8326e87343 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text somthing has changed +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + From 846dd710e40fd5cbaa70e2ca7fbeb75e839a7c69 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 11:32:24 +0100 Subject: [PATCH 0436/1027] #2581 3D well log curves: Create 3D curve object on a well path --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 138 ++++++++++++++++++ .../ProjectDataModel/Rim3dWellLogCurve.h | 80 ++++++++++ .../ProjectDataModel/RimWellPath.cpp | 21 +++ .../ProjectDataModel/RimWellPath.h | 5 + 5 files changed, 246 insertions(+) create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 10c888ad6f..1484e33117 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -98,6 +98,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h ) @@ -200,6 +201,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp new file mode 100644 index 0000000000..19a9a6483b --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -0,0 +1,138 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogCurve.h" + +#include "RimEclipseCase.h" +#include "RimEclipseResultDefinition.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechResultDefinition.h" + + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogCurve, "Rim3dWellLogCurve"); + +namespace caf +{ + template<> + void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() + { + addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Horizontal - Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Horizontal - Right"); + addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Vertical - Above"); + addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Vertical - Below"); + addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE1, "CAMERA_ALIGNED_SIDE_1", "Camera Aligned - Side 1"); + addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE2, "CAMERA_ALIGNED_SIDE_2", "Camera Aligned - Side 2"); + setDefault(Rim3dWellLogCurve::HORIZONTAL_LEFT); + } + + template<> + void AppEnum< Rim3dWellLogCurve::DrawStyle >::setUp() + { + addItem(Rim3dWellLogCurve::LINE, "LINE", "Line"); + addItem(Rim3dWellLogCurve::FILLED, "FILLED", "Filled"); + setDefault(Rim3dWellLogCurve::LINE); + } + + template<> + void AppEnum< Rim3dWellLogCurve::ColoringStyle >::setUp() + { + addItem(Rim3dWellLogCurve::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); + addItem(Rim3dWellLogCurve::CURVE_VALUE, "CURVE_VALUE", "Curve Value"); + addItem(Rim3dWellLogCurve::OTHER_RESULT, "OTHER_RESULT", "Other Result"); + setDefault(Rim3dWellLogCurve::SINGLE_COLOR); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::Rim3dWellLogCurve() +{ + CAF_PDM_InitObject("3d Well Log Curve", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_drawPlane, "DrawPlane", "Draw Plane", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_drawStyle, "DrawStyle", "Draw Style", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_coloringStyle, "ColoringStyle", "Coloring Style", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", ""); + m_case.uiCapability()->setUiTreeChildrenHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", ""); + m_eclipseResultDefinition.uiCapability()->setUiHidden(true); + m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_eclipseResultDefinition = new RimEclipseResultDefinition; + m_eclipseResultDefinition->findField("MResultType")->uiCapability()->setUiName("Result Type"); + + CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", ""); + m_geomResultDefinition.uiCapability()->setUiHidden(true); + m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_geomResultDefinition = new RimGeoMechResultDefinition; + + CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::~Rim3dWellLogCurve() +{ + delete m_geomResultDefinition; + delete m_eclipseResultDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + + curveDataGroup->add(&m_case); + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + if (eclipseCase) + { + m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + + } + else if (geomCase) + { + m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + + } + + if ((eclipseCase && m_eclipseResultDefinition->hasDynamicResult()) + || geomCase) + { + curveDataGroup->add(&m_timeStep); + } + + caf::PdmUiGroup* formatGroup = uiOrdering.addNewGroup("Appearance"); + formatGroup->add(&m_drawPlane); + formatGroup->add(&m_drawStyle); + formatGroup->add(&m_coloringStyle); + + uiOrdering.skipRemainingFields(); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h new file mode 100644 index 0000000000..8c35fa105b --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafAppEnum.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RimCase.h" + +class RimGeoMechResultDefinition; +class RimEclipseResultDefinition; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogCurve : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + enum DrawPlane + { + HORIZONTAL_LEFT, + HORIZONTAL_RIGHT, + VERTICAL_ABOVE, + VERTICAL_BELOW, + CAMERA_ALIGNED_SIDE1, + CAMERA_ALIGNED_SIDE2 + }; + + enum DrawStyle + { + LINE, + FILLED + }; + + enum ColoringStyle + { + SINGLE_COLOR, + CURVE_VALUE, + OTHER_RESULT + }; + + +public: + Rim3dWellLogCurve(); + virtual ~Rim3dWellLogCurve(); + +private: + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + caf::PdmPtrField m_case; + caf::PdmField m_timeStep; + caf::PdmChildField m_eclipseResultDefinition; + caf::PdmChildField m_geomResultDefinition; + + caf::PdmField> m_drawPlane; + caf::PdmField> m_drawStyle; + caf::PdmField> m_coloringStyle; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 1c49bb9531..3a39485916 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -29,6 +29,7 @@ #include "RigWellPath.h" +#include "Rim3dWellLogCurve.h" #include "RimFishbonesMultipleSubs.h" #include "RimMainPlotCollection.h" #include "RimProject.h" @@ -128,6 +129,8 @@ RimWellPath::RimWellPath() CAF_PDM_InitFieldNoDefault(&m_wellLogFiles, "WellLogFiles", "Well Log Files", "", "", ""); m_wellLogFiles.uiCapability()->setUiTreeHidden(true); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "3D Track", "", "", ""); + CAF_PDM_InitField(&m_formationKeyInFile, "WellPathFormationKeyInFile", QString(""), "Key in File", "", "", ""); m_formationKeyInFile.uiCapability()->setUiReadOnly(true); @@ -157,6 +160,11 @@ RimWellPath::~RimWellPath() delete file; } + for (const auto& rim3dWellLogCurve : m_3dWellLogCurves()) + { + delete rim3dWellLogCurve; + } + RimProject* project; firstAncestorOrThisOfType(project); if (project) @@ -511,6 +519,11 @@ void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, Q uiTreeOrdering.add(&m_completions); } + if (!m_3dWellLogCurves.empty()) + { + uiTreeOrdering.add(&m_3dWellLogCurves); + } + uiTreeOrdering.skipRemainingChildren(true); } @@ -790,6 +803,14 @@ const RigWellPathFormations* RimWellPath::formationsGeometry() const return m_wellPathFormations.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) +{ + m_3dWellLogCurves.push_back(rim3dWellLogCurve); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index b7201b54a8..fc4cbedfb5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -41,6 +41,7 @@ class RifWellPathFormationsImporter; class RigWellPath; class RimProject; class RimWellLogFile; +class Rim3dWellLogCurve; class RimFishboneWellPathCollection; class RimFishbonesCollection; @@ -75,6 +76,8 @@ class RimWellPath : public caf::PdmObject bool hasFormations() const; const RigWellPathFormations* formationsGeometry() const; + void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve); + virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; @@ -171,6 +174,8 @@ class RimWellPath : public caf::PdmObject caf::PdmField m_formationKeyInFile; caf::PdmChildArrayField m_wellLogFiles; + + caf::PdmChildArrayField m_3dWellLogCurves; caf::PdmChildField m_wellLogFile_OBSOLETE; }; From a37a9d3308420ceb2d8646671b050c2a65a98f05 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 12:02:13 +0100 Subject: [PATCH 0437/1027] #2582 3D well log curves: Create add 3D well log extraction curve cmd --- .../Commands/CMakeLists_files.cmake | 2 + .../Commands/RicAdd3dWellLogCurveFeature.cpp | 63 +++++++++++++++++++ .../Commands/RicAdd3dWellLogCurveFeature.h | 34 ++++++++++ .../RimContextCommandBuilder.cpp | 4 ++ .../ProjectDataModel/RimWellPath.cpp | 1 + .../UserInterface/RiuViewerCommands.cpp | 4 ++ 6 files changed, 108 insertions(+) create mode 100644 ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp create mode 100644 ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 4ca7189620..025ff74bce 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -31,6 +31,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h @@ -99,6 +100,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.cpp diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp new file mode 100644 index 0000000000..5adcb2190b --- /dev/null +++ b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogCurve.h" +#include "RimCase.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogCurveFeature, "RicAdd3dWellLogCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + return (RicWellLogTools::selectedWellPath() != nullptr); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) +{ + Rim3dWellLogCurve* rim3dWellLogCurve = new Rim3dWellLogCurve; + + RicWellLogTools::selectedWellPath()->add3dWellLogCurve(rim3dWellLogCurve); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log Curve"); +} diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h new file mode 100644 index 0000000000..ddc5cc4f4b --- /dev/null +++ b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index aea3b55d4e..8a167f71e3 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -263,6 +263,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); + menuBuilder << "RicAdd3dWellLogCurveFeature"; + + menuBuilder.addSeparator(); + menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); menuBuilder << "RicNewWellPathFractureFeature"; menuBuilder << "RicNewFishbonesSubsFeature"; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 3a39485916..de019a7298 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -809,6 +809,7 @@ const RigWellPathFormations* RimWellPath::formationsGeometry() const void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) { m_3dWellLogCurves.push_back(rim3dWellLogCurve); + updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 61da1cef03..4b3af5efdc 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -355,6 +355,10 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); + menuBuilder << "RicAdd3dWellLogCurveFeature"; + + menuBuilder.addSeparator(); + menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); menuBuilder << "RicNewWellPathFractureAtPosFeature"; From df0a356a0a6b1ce1a4c779652e66494a9f391a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 7 Mar 2018 12:47:48 +0100 Subject: [PATCH 0438/1027] #2478 Add top edge axis (intersection View) and repositioned info box and legends to follow. --- .../RivWindowEdgeAxesOverlayItem.cpp | 99 +++++++++++-------- .../RivWindowEdgeAxesOverlayItem.h | 3 + ApplicationCode/UserInterface/RiuViewer.cpp | 13 +-- 3 files changed, 66 insertions(+), 49 deletions(-) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp index 88e2717939..666ccd0cf8 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -65,6 +65,7 @@ RivWindowEdgeAxesOverlayItem::RivWindowEdgeAxesOverlayItem(Font* font) : m_windowSize(600, 600), m_textColor(Color3::BLACK), m_lineColor(Color3::BLACK), + m_frameColor(Color3::WHITE), m_lineWidth(1), m_font(font), m_isSwitchingYAxisValueSign(true) @@ -278,7 +279,9 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) // Bottom X - axis text { - const float textY = m_pixelSpacing + m_textSize.y()*0.5f; + const float textYTop = m_windowSize.y() - m_pixelSpacing - m_textSize.y()*0.5f; + const float textYBott = m_pixelSpacing + m_textSize.y()*0.5f; + size_t numTicks = m_domainCoordsXValues.size(); size_t i; for ( i = 0; i < numTicks; i++ ) @@ -291,14 +294,17 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) valueString = String::number(tickValue); auto labelSize = m_font->textExtent(valueString); - Vec2f pos(textX - labelSize.x()*0.5f, textY); + Vec2f pos(textX - labelSize.x()*0.5f, textYBott); + textDrawer->addText(valueString, pos); + pos[1] = textYTop; textDrawer->addText(valueString, pos); } } - + // Right Y - axis texts { - const float textX = m_windowSize.x() - m_pixelSpacing - m_textSize.x(); + const float textXRight = m_windowSize.x() - m_pixelSpacing - m_textSize.x(); + const float textXLeft = m_frameBorderWidth - m_tickLineLength - m_pixelSpacing; size_t numTicks = m_domainCoordsYValues.size(); size_t i; @@ -312,29 +318,10 @@ void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) valueString = String::number(tickValue); auto labelSize = m_font->textExtent(valueString); - Vec2f pos(textX, textY); - textDrawer->addText(valueString, pos); - } - } - - // Left Y - axis texts - { - const float textX = m_frameBorderWidth - m_tickLineLength - m_pixelSpacing; - - size_t numTicks = m_domainCoordsYValues.size(); - size_t i; - for ( i = 0; i < numTicks; i++ ) - { - float textY = static_cast(m_windowTickYValues[i]); - - double tickValue = m_isSwitchingYAxisValueSign ? -m_domainCoordsYValues[i]: m_domainCoordsYValues[i]; - String valueString; - - valueString = String::number(tickValue); - auto labelSize = m_font->textExtent(valueString); - - Vec2f pos(textX - labelSize.x(), textY); + Vec2f pos(textXRight, textY); textDrawer->addText(valueString, pos); + Vec2f posl(textXLeft - labelSize.x(), textY); + textDrawer->addText(valueString, posl); } } } @@ -347,15 +334,22 @@ std::array RivWindowEdgeAxesOverlayItem::frameVertexArray() float windowWidth = static_cast(m_windowSize.x()); float windowHeight = static_cast(m_windowSize.y()); + // 3 2 + // 7 6 + // + // 4 5 + // 0 1 + std::array vertexArray ={ - Vec3f(0.0f , 0.0f , 0.0f), - Vec3f(windowWidth , 0.0f , 0.0f), - Vec3f(windowWidth , windowHeight , 0.0f), - Vec3f(0.0f , windowHeight , 0.0f), - Vec3f(m_frameBorderWidth , m_frameBorderHeight, 0.0f), - Vec3f(windowWidth - m_frameBorderWidth, m_frameBorderHeight, 0.0f), - Vec3f(windowWidth - m_frameBorderWidth, windowHeight , 0.0f), - Vec3f(m_frameBorderWidth , windowHeight , 0.0f), + Vec3f(0.0f , 0.0f , 0.0f), + Vec3f(windowWidth , 0.0f , 0.0f), + Vec3f(windowWidth , windowHeight , 0.0f), + Vec3f(0.0f , windowHeight , 0.0f), + + Vec3f(m_frameBorderWidth , m_frameBorderHeight , 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, m_frameBorderHeight , 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, windowHeight - m_frameBorderHeight, 0.0f), + Vec3f(m_frameBorderWidth , windowHeight - m_frameBorderHeight, 0.0f), }; return vertexArray; @@ -380,7 +374,7 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext std::array vertexArray = frameVertexArray(); - glColor4fv(Vec4f(1.0f,1.0f,1.0f,0.5f).ptr()); + glColor4fv(m_frameColor.ptr()); glBegin(GL_TRIANGLE_FAN); glVertex3fv(vertexArray[0].ptr()); glVertex3fv(vertexArray[1].ptr()); @@ -399,6 +393,12 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext glVertex3fv(vertexArray[4].ptr()); glVertex3fv(vertexArray[7].ptr()); glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[7].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glEnd(); // Render Line around @@ -413,6 +413,8 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext glVertex3fv(vertexArray[5].ptr()); glVertex3fv(vertexArray[5].ptr()); glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[7].ptr()); // X - axis Tick lines for (double txpos : m_windowTickXValues) @@ -427,6 +429,14 @@ void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext glVertex3fv(p1.ptr()); glVertex3fv(p2.ptr()); + + p1[0] = (float)txpos; + p1[1] = m_windowSize.y() - m_frameBorderHeight; + p2[0] = (float)txpos; + p2[1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); } // Left Y - axis Tick lines @@ -503,16 +513,17 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* // Draw frame background - UniformFloat backgroundColorUniform("u_color", Color4f(1.0f, 1.0f, 1.0f, 0.5f)); + UniformFloat backgroundColorUniform("u_color", m_frameColor); shaderProgram->applyUniform(oglContext, backgroundColorUniform); // Triangle indices for the frame background static const ushort backgroundTriangleIndices[] = { 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5, - 3, 0, 4, 3, 4, 7 }; + 3, 0, 4, 3, 4, 7, + 2, 3, 6, 3, 7, 6 }; - glDrawRangeElements(GL_TRIANGLES, 0, 7, 18, GL_UNSIGNED_SHORT, backgroundTriangleIndices); + glDrawRangeElements(GL_TRIANGLES, 0, 7, 24, GL_UNSIGNED_SHORT, backgroundTriangleIndices); // Draw frame border lines @@ -522,9 +533,10 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* static const ushort frameLineIndices[] = { 7, 4, 4, 5, - 5, 6 }; + 5, 6, + 6, 7 }; - glDrawRangeElements(GL_LINES, 0, 7, 6, GL_UNSIGNED_SHORT, frameLineIndices); + glDrawRangeElements(GL_LINES, 0, 7, 8, GL_UNSIGNED_SHORT, frameLineIndices); // Render tickmarks @@ -540,6 +552,13 @@ void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* vertexArray[1][1] = m_frameBorderHeight - m_tickLineLength; glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + + vertexArray[0][0] = (float)txpos; + vertexArray[0][1] = m_windowSize.y() - m_frameBorderHeight; + vertexArray[1][0] = (float)txpos; + vertexArray[1][1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); } // Left Y - axis Tick lines diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h index 229906929f..8aefe6a6b4 100644 --- a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -72,6 +72,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem using OpenGLContext = cvf::OpenGLContext; using Vec2i = cvf::Vec2i; using Color3f = cvf::Color3f; + using Color4f = cvf::Color4f; using String = cvf::String; using Vec2f = cvf::Vec2f; using Vec3f = cvf::Vec3f; @@ -91,6 +92,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem const Color3f& textColor() const; void setLineColor(const Color3f& lineColor); const Color3f& lineColor() const; + void setFrameColor(const Color4f& frameColor); int frameBorderWidth() { return static_cast( m_frameBorderWidth); } int frameBorderHeight() { return static_cast( m_frameBorderHeight); } @@ -116,6 +118,7 @@ class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem Vec2ui m_textSize; Color3f m_textColor; Color3f m_lineColor; + Color4f m_frameColor; int m_lineWidth; cvf::ref m_font; diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 41877fc8fe..62cb0232b3 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -347,22 +347,17 @@ void RiuViewer::setEnableMask(unsigned int mask) //-------------------------------------------------------------------------------------------------- void RiuViewer::paintOverlayItems(QPainter* painter) { - // No support for overlay items using SW rendering yet. - //if (!isShadersSupported()) - //{ - // return; - //} - int columnWidth = 200; + int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; + int margin = 5; - int yPos = margin; + int yPos = margin + edgeAxisFrameBorderHeight; bool showAnimBar = false; if (isAnimationActive() && frameCount() > 1) showAnimBar = true; - //if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width()); if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_infoLabel->sizeHint().width()); int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth; @@ -598,7 +593,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) for (auto catLegend : categoryLegends) { catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight - edgeAxisBorderHeight)); + catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight - 2*edgeAxisBorderHeight)); xPos += categoryWidth + border; } From 9b8c06462c3a38df08e20d58fb7340cac33e61bc Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 13:03:27 +0100 Subject: [PATCH 0439/1027] #2582 3d well log curves: Select created curve in tree --- .../Commands/RicAdd3dWellLogCurveFeature.cpp | 14 ++++++++++++-- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 11 +++++++++++ .../ProjectDataModel/Rim3dWellLogCurve.h | 5 ++++- ApplicationCode/ProjectDataModel/RimWellPath.cpp | 1 - 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp index 5adcb2190b..3d16ac3463 100644 --- a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp @@ -27,6 +27,8 @@ #include "RimProject.h" #include "RimWellPath.h" +#include "Riu3DMainWindowTools.h" + #include CAF_CMD_SOURCE_INIT(RicAdd3dWellLogCurveFeature, "RicAdd3dWellLogCurveFeature"); @@ -48,9 +50,17 @@ bool RicAdd3dWellLogCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) { - Rim3dWellLogCurve* rim3dWellLogCurve = new Rim3dWellLogCurve; + RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); + + Rim3dWellLogCurve* rim3dWellLogCurve = new Rim3dWellLogCurve(); + selectedWellPath->add3dWellLogCurve(rim3dWellLogCurve); + + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); - RicWellLogTools::selectedWellPath()->add3dWellLogCurve(rim3dWellLogCurve); + selectedWellPath->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 19a9a6483b..8e9d39f82f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -89,6 +89,9 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() m_geomResultDefinition = new RimGeoMechResultDefinition; CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); + + CAF_PDM_InitField(&m_name, "Name", QString("3d Well Log Curve"), "3d Well Log Curve", "", "", ""); + m_name.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -100,6 +103,14 @@ Rim3dWellLogCurve::~Rim3dWellLogCurve() delete m_eclipseResultDefinition; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogCurve::userDescriptionField() +{ + return &m_name; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 8c35fa105b..72c30e0fe1 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -60,15 +60,18 @@ class Rim3dWellLogCurve : public caf::PdmObject OTHER_RESULT }; - public: Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); + virtual caf::PdmFieldHandle* userDescriptionField() override; + private: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: + caf::PdmField m_name; + caf::PdmPtrField m_case; caf::PdmField m_timeStep; caf::PdmChildField m_eclipseResultDefinition; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index de019a7298..3a39485916 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -809,7 +809,6 @@ const RigWellPathFormations* RimWellPath::formationsGeometry() const void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) { m_3dWellLogCurves.push_back(rim3dWellLogCurve); - updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- From 46127ee7248f2dc8eb112956fd197952c5f7c551 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 14:24:18 +0100 Subject: [PATCH 0440/1027] #2581 3D wellLog curves: Add function to set property detaults from view --- .../Commands/RicAdd3dWellLogCurveFeature.cpp | 7 ++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 90 ++++++++++++++++++- .../ProjectDataModel/Rim3dWellLogCurve.h | 9 +- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp index 3d16ac3463..0cbfddc9d4 100644 --- a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp @@ -53,6 +53,13 @@ void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); Rim3dWellLogCurve* rim3dWellLogCurve = new Rim3dWellLogCurve(); + + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + if (view) + { + rim3dWellLogCurve->setPropertiesFromView(view); + } + selectedWellPath->add3dWellLogCurve(rim3dWellLogCurve); RiaApplication::instance()->project()->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 8e9d39f82f..588b73fe90 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -22,7 +22,11 @@ #include "RimEclipseResultDefinition.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" - +#include "RimTools.h" +#include "Rim3dView.h" +#include "RimEclipseView.h" +#include "RimGeoMechView.h" +#include "RimEclipseCellColors.h" //================================================================================================== /// @@ -70,6 +74,9 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() { CAF_PDM_InitObject("3d Well Log Curve", "", "", ""); + CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); + m_showCurve.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_drawPlane, "DrawPlane", "Draw Plane", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_drawStyle, "DrawStyle", "Draw Style", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_coloringStyle, "ColoringStyle", "Coloring Style", "", "", ""); @@ -90,7 +97,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); - CAF_PDM_InitField(&m_name, "Name", QString("3d Well Log Curve"), "3d Well Log Curve", "", "", ""); + CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); m_name.uiCapability()->setUiHidden(true); } @@ -103,6 +110,84 @@ Rim3dWellLogCurve::~Rim3dWellLogCurve() delete m_eclipseResultDefinition; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) +{ + m_case = nullptr; + if (view) + { + m_case = view->ownerCase(); + } + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); + + RimEclipseView* eclipseView = dynamic_cast(view); + if (eclipseView) + { + m_eclipseResultDefinition->simpleCopy(eclipseView->cellResult()); + m_timeStep = eclipseView->currentTimeStep(); + } + + RimGeoMechView* geoMechView = dynamic_cast(view); + if (geoMechView) + { + m_geomResultDefinition->setResultAddress(geoMechView->cellResultResultDefinition()->resultAddress()); + m_timeStep = geoMechView->currentTimeStep(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogCurve::objectToggleField() +{ + return &m_showCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_case) + { + RimTools::caseOptionItems(&options); + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_timeStep) + { + QStringList timeStepNames; + + if (m_case) + { + timeStepNames = m_case->timeStepStrings(); + } + + for (int i = 0; i < timeStepNames.size(); i++) + { + options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); + } + } + + return options; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -147,3 +232,4 @@ void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin uiOrdering.skipRemainingFields(); } + diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 72c30e0fe1..7ee92cb13d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -64,12 +64,19 @@ class Rim3dWellLogCurve : public caf::PdmObject Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); - virtual caf::PdmFieldHandle* userDescriptionField() override; + void setPropertiesFromView(Rim3dView* view); + + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + virtual caf::PdmFieldHandle* userDescriptionField() override; private: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + private: + caf::PdmField m_showCurve; caf::PdmField m_name; caf::PdmPtrField m_case; From fbdfe90de0ef354fc3e0eac88fc8d65de3b2cde7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 14:25:12 +0100 Subject: [PATCH 0441/1027] Add override, sort includes --- .../RicNewWellLogCurveExtractionFeature.cpp | 6 +++--- .../ProjectDataModel/RimWellLogExtractionCurve.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index bd4915a7bb..1fdfae38b9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -27,9 +27,10 @@ #include "RigWellLogCurveData.h" +#include "Rim3dView.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "Rim3dView.h" +#include "RimSimWellInViewCollection.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -44,7 +45,6 @@ #include #include -#include "RimSimWellInViewCollection.h" CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtractionFeature"); @@ -125,5 +125,5 @@ bool RicNewWellLogCurveExtractionFeature::caseAvailable() std::vector cases; RiaApplication::instance()->project()->allCases(cases); - return cases.size() > 0; + return !cases.empty(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index f01dd1d056..62f0622d1f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -68,14 +68,14 @@ class RimWellLogExtractionCurve : public RimWellLogCurve void setEclipseResultVariable(const QString& resVarname); protected: - virtual QString createCurveAutoName(); - virtual void onLoadDataAndUpdate(bool updateParentPlot); - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - virtual void initAfterRead(); + virtual QString createCurveAutoName() override; + virtual void onLoadDataAndUpdate(bool updateParentPlot) override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual void initAfterRead() override; private: void setLogScaleFromSelectedResult(); From 00a0d2b1f6f451943925b99fccbefe524d5a5dbf Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 15:11:21 +0100 Subject: [PATCH 0442/1027] Avoid crash if selected item is not a PdmObjectHandle --- .../RicCopyIntersectionsToAllViewsInCaseFeature.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp index 05928db5e0..8d12763776 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -222,6 +222,11 @@ RimCase* commonGridCase(std::vector selectedItems) for (caf::PdmUiItem* item : selectedItems) { caf::PdmObjectHandle* obj = dynamic_cast(item); + if (!obj) + { + continue; + } + RimCase* itemCase = nullptr; obj->firstAncestorOrThisOfType(itemCase); From 831eac7fd5843525c52d1a24e26f147c781c2c6d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 15:12:27 +0100 Subject: [PATCH 0443/1027] #2584 3D well log curves: Create a collection object to hold curves --- .../Completions/CMakeLists_files.cmake | 2 + .../Rim3dWellLogCurveCollection.cpp | 62 +++++++++++++++++++ .../Completions/Rim3dWellLogCurveCollection.h | 42 +++++++++++++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 9 +-- .../ProjectDataModel/RimWellPath.cpp | 14 ++--- .../ProjectDataModel/RimWellPath.h | 6 +- 6 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h diff --git a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake index 555a1aced8..6255f8499f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake @@ -20,6 +20,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurveCollection.h ) @@ -44,6 +45,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurveCollection.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp new file mode 100644 index 0000000000..c34a5a5839 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogCurveCollection.h" + +#include "Rim3dWellLogCurve.h" + +CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() +{ + CAF_PDM_InitObject("3D Track", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); + m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::~Rim3dWellLogCurveCollection() +{ + m_3dWellLogCurves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::has3dWellLogCurves() const +{ + return !m_3dWellLogCurves.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) +{ + if (curve) + { + m_3dWellLogCurves.push_back(curve); + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h new file mode 100644 index 0000000000..885bafffbc --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmChildArrayField.h" + +class Rim3dWellLogCurve; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogCurveCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogCurveCollection(); + virtual ~Rim3dWellLogCurveCollection(); + + bool has3dWellLogCurves() const; + void add3dWellLogCurve(Rim3dWellLogCurve* curve); + + caf::PdmChildArrayField m_3dWellLogCurves; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 588b73fe90..53551dcd4e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -72,7 +72,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::Rim3dWellLogCurve() { - CAF_PDM_InitObject("3d Well Log Curve", "", "", ""); + CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); @@ -83,6 +83,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", ""); m_case.uiCapability()->setUiTreeChildrenHidden(true); + m_case = nullptr; CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", ""); m_eclipseResultDefinition.uiCapability()->setUiHidden(true); @@ -115,11 +116,7 @@ Rim3dWellLogCurve::~Rim3dWellLogCurve() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) { - m_case = nullptr; - if (view) - { - m_case = view->ownerCase(); - } + if (!view) return; RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 3a39485916..7970fd576a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -30,6 +30,7 @@ #include "RigWellPath.h" #include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimFishbonesMultipleSubs.h" #include "RimMainPlotCollection.h" #include "RimProject.h" @@ -129,7 +130,9 @@ RimWellPath::RimWellPath() CAF_PDM_InitFieldNoDefault(&m_wellLogFiles, "WellLogFiles", "Well Log Files", "", "", ""); m_wellLogFiles.uiCapability()->setUiTreeHidden(true); - CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "3D Track", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track", "", "", ""); + m_3dWellLogCurves = new Rim3dWellLogCurveCollection; + m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); CAF_PDM_InitField(&m_formationKeyInFile, "WellPathFormationKeyInFile", QString(""), "Key in File", "", "", ""); m_formationKeyInFile.uiCapability()->setUiReadOnly(true); @@ -160,11 +163,6 @@ RimWellPath::~RimWellPath() delete file; } - for (const auto& rim3dWellLogCurve : m_3dWellLogCurves()) - { - delete rim3dWellLogCurve; - } - RimProject* project; firstAncestorOrThisOfType(project); if (project) @@ -519,7 +517,7 @@ void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, Q uiTreeOrdering.add(&m_completions); } - if (!m_3dWellLogCurves.empty()) + if (m_3dWellLogCurves->has3dWellLogCurves()) { uiTreeOrdering.add(&m_3dWellLogCurves); } @@ -808,7 +806,7 @@ const RigWellPathFormations* RimWellPath::formationsGeometry() const //-------------------------------------------------------------------------------------------------- void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) { - m_3dWellLogCurves.push_back(rim3dWellLogCurve); + m_3dWellLogCurves->add3dWellLogCurve(rim3dWellLogCurve); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index fc4cbedfb5..47e29cf4f8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -41,7 +41,7 @@ class RifWellPathFormationsImporter; class RigWellPath; class RimProject; class RimWellLogFile; -class Rim3dWellLogCurve; +class RimFractureTemplateCollection; class RimFishboneWellPathCollection; class RimFishbonesCollection; @@ -50,6 +50,8 @@ class RimWellPathCompletions; class RigWellPathFormations; class RimWellPathFractureCollection; +class Rim3dWellLogCurveCollection; +class Rim3dWellLogCurve; //================================================================================================== /// @@ -175,7 +177,7 @@ class RimWellPath : public caf::PdmObject caf::PdmChildArrayField m_wellLogFiles; - caf::PdmChildArrayField m_3dWellLogCurves; + caf::PdmChildField m_3dWellLogCurves; caf::PdmChildField m_wellLogFile_OBSOLETE; }; From 0a55fa29b8d7b35bb278273dc6062a077ad28a61 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 7 Mar 2018 15:54:49 +0100 Subject: [PATCH 0444/1027] Move "New Intersection" command on wellpath in tree to top level --- ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 8a167f71e3..96c0993f8d 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -258,13 +258,14 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicShowWellAllocationPlotFeature"; menuBuilder << "RicNewWellLogFileCurveFeature"; menuBuilder << "RicNewWellLogCurveExtractionFeature"; - menuBuilder << "RicNewWellPathIntersectionFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicNewWellPathIntersectionFeature"; + menuBuilder.addSeparator(); menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); From 09246b722a843eed94b67cce8356477422bae507 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 8 Mar 2018 08:07:13 +0100 Subject: [PATCH 0445/1027] #2581 3D well log curve: Init after read --- .../Rim3dWellLogCurveCollection.cpp | 12 ++++++- .../Completions/Rim3dWellLogCurveCollection.h | 8 ++++- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 31 +++++++++++++------ .../ProjectDataModel/Rim3dWellLogCurve.h | 4 +-- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index c34a5a5839..c7a87d9a35 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -29,9 +29,11 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() { CAF_PDM_InitObject("3D Track", ":/WellLogCurve16x16.png", "", ""); + CAF_PDM_InitField(&m_showCurves, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); + m_showCurves.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); - } //-------------------------------------------------------------------------------------------------- @@ -60,3 +62,11 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) m_3dWellLogCurves.push_back(curve); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() +{ + return &m_showCurves; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 885bafffbc..1b4830395e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -18,8 +18,9 @@ #pragma once -#include "cafPdmObject.h" #include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" class Rim3dWellLogCurve; @@ -38,5 +39,10 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); +private: + virtual caf::PdmFieldHandle* objectToggleField() override; + +private: + caf::PdmField m_showCurves; caf::PdmChildArrayField m_3dWellLogCurves; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 53551dcd4e..1b964f0fbf 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,15 +18,15 @@ #include "Rim3dWellLogCurve.h" +#include "Rim3dView.h" #include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" #include "RimEclipseResultDefinition.h" +#include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" -#include "RimTools.h" -#include "Rim3dView.h" -#include "RimEclipseView.h" #include "RimGeoMechView.h" -#include "RimEclipseCellColors.h" +#include "RimTools.h" //================================================================================================== /// @@ -117,6 +117,8 @@ Rim3dWellLogCurve::~Rim3dWellLogCurve() void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) { if (!view) return; + + m_case = view->ownerCase(); RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); @@ -208,7 +210,6 @@ void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin if (eclipseCase) { m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); - } else if (geomCase) { @@ -222,11 +223,23 @@ void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin curveDataGroup->add(&m_timeStep); } - caf::PdmUiGroup* formatGroup = uiOrdering.addNewGroup("Appearance"); - formatGroup->add(&m_drawPlane); - formatGroup->add(&m_drawStyle); - formatGroup->add(&m_coloringStyle); + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + appearanceGroup->add(&m_drawPlane); + appearanceGroup->add(&m_drawStyle); + appearanceGroup->add(&m_coloringStyle); uiOrdering.skipRemainingFields(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::initAfterRead() +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); +} + diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 7ee92cb13d..8e6e66b005 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -66,14 +66,14 @@ class Rim3dWellLogCurve : public caf::PdmObject void setPropertiesFromView(Rim3dView* view); +private: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual caf::PdmFieldHandle* userDescriptionField() override; -private: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - + virtual void initAfterRead() override; private: caf::PdmField m_showCurve; From 4f7291c95d4a81357275a341d8f6ac731459be7d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 10:10:15 +0100 Subject: [PATCH 0446/1027] #2583 System : Move regression test framework to separate class --- .../Application/RiaApplication.cpp | 500 ++-------------- ApplicationCode/Application/RiaApplication.h | 42 +- .../Application/Tools/CMakeLists_files.cmake | 2 + .../Application/Tools/RiaArgumentParser.cpp | 11 +- .../Tools/RiaRegressionTestRunner.cpp | 546 ++++++++++++++++++ .../Tools/RiaRegressionTestRunner.h | 55 ++ .../Application/Tools/RiaTextFileCompare.cpp | 2 +- .../RicLaunchRegressionTestsFeature.cpp | 5 +- .../UserInterface/RiuMainWindow.cpp | 4 +- ApplicationCode/UserInterface/RiuViewer.cpp | 3 +- 10 files changed, 667 insertions(+), 503 deletions(-) create mode 100644 ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp create mode 100644 ApplicationCode/Application/Tools/RiaRegressionTestRunner.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index ffe32f65e9..9f99e469a1 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -22,99 +22,65 @@ #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" -#include "RiaImageCompareReporter.h" -#include "RiaImageFileCompare.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaProjectModifier.h" -#include "RiaRegressionTest.h" #include "RiaSocketServer.h" #include "RiaVersionInfo.h" #include "RiaViewRedrawScheduler.h" -#include "RigGridManager.h" -#include "RigEclipseCaseData.h" - +#include "RicImportInputEclipseCaseFeature.h" +#include "RicImportSummaryCaseFeature.h" +#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" #include "Rim2dIntersectionViewCollection.h" -#include "Rim3dOverlayInfoConfig.h" -#include "RimCaseCollection.h" -#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" #include "RimCommandObject.h" -#include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseView.h" -#include "RimFaultInViewCollection.h" -#include "RimFlowCharacteristicsPlot.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" -#include "RimRftPlotCollection.h" -#include "RimPltPlotCollection.h" - -#include "RimEclipseCase.h" +#include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechModels.h" #include "RimGeoMechView.h" +#include "RimGeoMechView.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimObservedData.h" #include "RimObservedDataCollection.h" #include "RimOilField.h" +#include "RimPltPlotCollection.h" #include "RimProject.h" -#include "RimReservoirCellResultsStorage.h" -#include "RimScriptCollection.h" +#include "RimRftPlotCollection.h" +#include "RimStimPlanColors.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimSummaryCurve.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RimWellAllocationPlot.h" #include "RimWellLogFile.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" -#include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RimWellRftPlot.h" +#include "RimWellPathFracture.h" #include "RimWellPltPlot.h" +#include "RimWellRftPlot.h" #include "RiuMainPlotWindow.h" #include "RiuMainWindow.h" #include "RiuProcessMonitor.h" #include "RiuRecentFileActionProvider.h" #include "RiuSelectionManager.h" -#include "RiuSummaryQwtPlot.h" #include "RiuViewer.h" -#include "RiuWellLogPlot.h" -#include "RiuWellAllocationPlot.h" -#include "RiuFlowCharacteristicsPlot.h" - -#include "RimFractureTemplateCollection.h" -#include "RimWellPathFracture.h" -#include "RimStimPlanColors.h" - - -#include "RicImportInputEclipseCaseFeature.h" -#include "RicImportSummaryCaseFeature.h" -#include "ExportCommands/RicSnapshotViewToFileFeature.h" -#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" -#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - -#include "RicfCommandFileExecutor.h" - -#include "cafFixedAtlasFont.h" #include "cafAppEnum.h" -#include "cafCeetronPlusNavigation.h" -#include "cafEffectCache.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" +#include "cafEffectGenerator.h" +#include "cafFixedAtlasFont.h" #include "cafPdmSettings.h" #include "cafPdmUiModelChangeDetector.h" #include "cafPdmUiTreeView.h" @@ -126,22 +92,15 @@ #include "cvfProgramOptions.h" #include "cvfqtUtils.h" -#include -#include #include #include #include #include -#include -#include #include +#ifdef USE_UNIT_TESTS #include "gtest/gtest.h" - -#ifdef WIN32 -#include -#endif - +#endif // USE_UNIT_TESTS namespace caf { @@ -158,14 +117,16 @@ void AppEnum< RiaApplication::RINavigationPolicy >::setUp() namespace RegTestNames { - const QString generatedFolderName = "RegTestGeneratedImages"; - const QString diffFolderName = "RegTestDiffImages"; - const QString baseFolderName = "RegTestBaseImages"; - const QString testProjectName = "RegressionTest"; - const QString testFolderFilter = "TestCase*"; - const QString imageCompareExeName = "compare"; - const QString reportFileName = "ResInsightRegressionTestReport.html"; - const QString commandFileFilter = "commandfile-*"; +const QString generatedFilesFolderName = "RegTestGeneratedFiles"; +const QString baseFilesFolderName = "RegTestBaseFiles"; +const QString generatedFolderName = "RegTestGeneratedImages"; +const QString diffFolderName = "RegTestDiffImages"; +const QString baseFolderName = "RegTestBaseImages"; +const QString testProjectName = "RegressionTest"; +const QString testFolderFilter = "TestCase*"; +const QString imageCompareExeName = "compare"; +const QString reportFileName = "ResInsightRegressionTestReport.html"; +const QString commandFileFilter = "commandfile-*"; }; @@ -230,8 +191,6 @@ RiaApplication::RiaApplication(int& argc, char** argv) // instead of using the application font m_standardFont = new caf::FixedAtlasFont(caf::FixedAtlasFont::POINT_SIZE_8); - m_runningRegressionTests = false; - m_runningWorkerProcess = false; m_mainPlotWindow = nullptr; @@ -1538,6 +1497,19 @@ std::vector RiaApplication::readFileListFromTextFile(QString listFileNa return fileList; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::waitUntilCommandObjectsHasBeenProcessed() +{ + // Wait until all command objects have completed + while (!m_commandQueueLock.tryLock()) + { + processEvents(); + } + m_commandQueueLock.unlock(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1963,317 +1935,6 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectFileNam mainWnd->loadWinGeoAndDockToolBarLayout(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void removeDirectoryWithContent(QDir dirToDelete ) -{ - QStringList files = dirToDelete.entryList(); - for (int fIdx = 0; fIdx < files.size(); ++fIdx) - { - dirToDelete.remove(files[fIdx]); - } - dirToDelete.rmdir("."); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg) -{ - double timeRunning = time.elapsed() / 1000.0; - - QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1); - - RiaLogging::info(timeText + msg); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* testFilter) -{ - m_runningRegressionTests = true; - - RiaRegressionTest regressionTestConfig; - regressionTestConfig.readSettingsFromApplicationStore(); - - QString currentApplicationPath = QDir::currentPath(); - if (!regressionTestConfig.folderContainingCompareTool().isEmpty()) - { - // Windows Only : The image compare tool requires current working directory to be at the folder - // containing the image compare tool - - QDir::setCurrent(regressionTestConfig.folderContainingCompareTool()); - } - - QString generatedFolderName = RegTestNames::generatedFolderName; - QString diffFolderName = RegTestNames::diffFolderName; - QString baseFolderName = RegTestNames::baseFolderName; - QString regTestProjectName = RegTestNames::testProjectName; - QString regTestFolderFilter = RegTestNames::testFolderFilter; - // Find all sub folders - - QDir testDir(testRootPath); // If string is empty it will end up as cwd - testDir.setFilter(QDir::Dirs); - QStringList dirNameFilter; - dirNameFilter.append(regTestFolderFilter); - testDir.setNameFilters(dirNameFilter); - - QFileInfoList folderList = testDir.entryInfoList(); - - if (testFilter && testFilter->size() > 0) - { - QFileInfoList subset; - - for (auto fi : folderList) - { - QString path = fi.path(); - QString baseName = fi.baseName(); - - for (auto s : *testFilter) - { - QString trimmed = s.trimmed(); - if (baseName.contains(trimmed)) - { - subset.push_back(fi); - } - } - } - - folderList = subset; - } - - // delete diff and generated images - - - for (int i = 0; i < folderList.size(); ++i) - { - QDir testCaseFolder(folderList[i].filePath()); - - QDir genDir(testCaseFolder.filePath(generatedFolderName)); - removeDirectoryWithContent(genDir); - - QDir diffDir(testCaseFolder.filePath(diffFolderName)); - removeDirectoryWithContent(diffDir); - - QDir baseDir(testCaseFolder.filePath(baseFolderName)); - } - - // Generate html report - - RiaImageCompareReporter imageCompareReporter; - - // Minor workaround - // Use registry to define if interactive diff images should be created - // Defined by user in RiaRegressionTest - { - QSettings settings; - - bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool(); - if (useInteractiveDiff) - { - imageCompareReporter.showInteractiveOnly(); - } - } - - QTime timeStamp; - timeStamp.start(); - - logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n"); - - for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) - { - QDir testCaseFolder(folderList[dirIdx].filePath()); - - QString testFolderName = testCaseFolder.dirName(); - QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName); - QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName); - QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName); - - imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), reportBaseFolderName.toStdString(), reportGeneratedFolderName.toStdString(), reportDiffFolderName.toStdString()); - } - - QString htmlReportFileName = testDir.filePath(RegTestNames::reportFileName); - imageCompareReporter.generateHTMLReport(htmlReportFileName.toStdString()); - - // Open HTML report - QDesktopServices::openUrl(htmlReportFileName); - - for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) - { - QDir testCaseFolder(folderList[dirIdx].filePath()); - - // Detect any command files - QStringList filterList; - filterList << RegTestNames::commandFileFilter; - - QFileInfoList commandFileEntries = testCaseFolder.entryInfoList(filterList); - if (!commandFileEntries.empty()) - { - QString currentApplicationPath = QDir::current().absolutePath(); - - // Set current path to the folder containing the command file, as this is required when using file references - // in the command file - QDir::setCurrent(folderList[dirIdx].filePath()); - - for (const auto& fileInfo : commandFileEntries) - { - QString commandFile = fileInfo.absoluteFilePath(); - - QFile file(commandFile); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - RiaLogging::error("Failed to open command file : " + commandFile); - } - else - { - QTextStream in(&file); - RicfCommandFileExecutor::instance()->executeCommands(in); - } - } - - QDir::setCurrent(currentApplicationPath); - } - - - QString projectFileName; - - if (testCaseFolder.exists(regTestProjectName + ".rip")) - { - projectFileName = regTestProjectName + ".rip"; - } - - if (testCaseFolder.exists(regTestProjectName + ".rsp")) - { - projectFileName = regTestProjectName + ".rsp"; - } - - if (!projectFileName.isEmpty()) - { - logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath()); - - loadProject(testCaseFolder.filePath(projectFileName)); - - // Wait until all command objects have completed - while (!m_commandQueueLock.tryLock()) - { - processEvents(); - } - m_commandQueueLock.unlock(); - - regressionTestConfigureProject(); - - resizeMaximizedPlotWindows(); - - QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); - RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder); - - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder); - - QDir baseDir(testCaseFolder.filePath(baseFolderName)); - QDir genDir(testCaseFolder.filePath(generatedFolderName)); - QDir diffDir(testCaseFolder.filePath(diffFolderName)); - if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName); - baseDir.setFilter(QDir::Files); - QStringList baseImageFileNames = baseDir.entryList(); - - for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx) - { - QString fileName = baseImageFileNames[fIdx]; - RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName); - bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName)); - if (!ok) - { - qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); - } - } - - closeProject(); - - logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath()); - } - else - { - RiaLogging::error("Could not find a regression test file named : " + testCaseFolder.absolutePath() + "/" + regTestProjectName + ".rsp"); - } - } - - RiaLogging::info("\n"); - logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); - - QDir::setCurrent(currentApplicationPath); - - m_runningRegressionTests = false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::resizeMaximizedPlotWindows() -{ - std::vector viewWindows; - m_project->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows); - - for (auto viewWindow : viewWindows) - { - if (viewWindow->isMdiWindow()) - { - RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry(); - if (wndGeo.isMaximized) - { - QWidget* viewWidget = viewWindow->viewWidget(); - - if (viewWidget) - { - QMdiSubWindow* mdiWindow = m_mainPlotWindow->findMdiSubWindow(viewWidget); - if (mdiWindow) - { - mdiWindow->showNormal(); - - viewWidget->resize(RiaApplication::regressionDefaultImageSize()); - } - } - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::updateRegressionTest(const QString& testRootPath) -{ - // Find all sub folders - - QDir testDir(testRootPath); // If string is empty it will end up as cwd - testDir.setFilter(QDir::Dirs); - QStringList dirNameFilter; - dirNameFilter.append(RegTestNames::testFolderFilter); - testDir.setNameFilters(dirNameFilter); - - QFileInfoList folderList = testDir.entryInfoList(); - - for (int i = 0; i < folderList.size(); ++i) - { - QDir testCaseFolder(folderList[i].filePath()); - - QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName)); - removeDirectoryWithContent(baseDir); - testCaseFolder.mkdir(RegTestNames::baseFolderName); - - QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName)); - - QStringList imageFileNames = genDir.entryList(); - - for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx) - { - QString fileName = imageFileNames[fIdx]; - QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName)); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2439,93 +2100,6 @@ void RiaApplication::executeCommandObjects() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiaApplication::isRunningRegressionTests() const -{ - return m_runningRegressionTests; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter) -{ - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (mainWnd) - { - mainWnd->hideAllDockWindows(); - - mainWnd->setDefaultWindowSize(); - runRegressionTest(regressionTestPath, testFilter); - - mainWnd->loadWinGeoAndDockToolBarLayout(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::executeRegressionTests() -{ - RiaRegressionTest testConfig; - testConfig.readSettingsFromApplicationStore(); - - QString testPath = testConfig.regressionTestFolder(); - QStringList testFilter = testConfig.testFilter().split(";", QString::SkipEmptyParts); - - executeRegressionTests(testPath, &testFilter); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::regressionTestConfigureProject() -{ - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (!mainWnd) return; - - if (m_project.isNull()) return; - - std::vector projectCases; - m_project->allCases(projectCases); - - for (size_t i = 0; i < projectCases.size(); i++) - { - RimCase* cas = projectCases[i]; - if (!cas) continue; - - std::vector views = cas->views(); - - for (size_t j = 0; j < views.size(); j++) - { - Rim3dView* riv = views[j]; - - if (riv && riv->viewer()) - { - // Make sure all views are maximized for snapshotting - QMdiSubWindow* subWnd = mainWnd->findMdiSubWindow(riv->viewer()->layoutWidget()); - if (subWnd) - { - subWnd->showMaximized(); - } - - // This size is set to match the regression test reference images - riv->viewer()->setFixedSize(RiaApplication::regressionDefaultImageSize()); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QSize RiaApplication::regressionDefaultImageSize() -{ - return QSize(1000, 745); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 17d0bae7f9..4dbe565d7d 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -93,22 +93,20 @@ class RiaApplication : public QApplication public: RiaApplication(int& argc, char** argv); ~RiaApplication(); - static RiaApplication* instance(); - - int parseArgumentsAndRunUnitTestsIfRequested(); - bool parseArguments(); + + static RiaApplication* instance(); - void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr); - void executeRegressionTests(); + int parseArgumentsAndRunUnitTestsIfRequested(); + bool parseArguments(); - void setActiveReservoirView(Rim3dView*); - Rim3dView* activeReservoirView(); - const Rim3dView* activeReservoirView() const; - RimGridView* activeGridView(); + void setActiveReservoirView(Rim3dView*); + Rim3dView* activeReservoirView(); + const Rim3dView* activeReservoirView() const; + RimGridView* activeGridView(); - RimViewWindow* activePlotWindow() const; + RimViewWindow* activePlotWindow() const; - RimProject* project(); + RimProject* project(); void createMockModel(); void createResultsMockModel(); @@ -141,7 +139,6 @@ class RiaApplication : public QApplication void addWellLogsToModel(const QList& wellLogFilePaths); void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector gridFileNames, const QString& snapshotFolderName); - void runRegressionTest(const QString& testRootPath, QStringList* testFilter = nullptr); void processNonGuiEvents(); @@ -180,8 +177,6 @@ class RiaApplication : public QApplication void addCommandObject(RimCommandObject* commandObject); void executeCommandObjects(); - bool isRunningRegressionTests() const; - int launchUnitTests(); int launchUnitTestsWithConsole(); @@ -204,9 +199,10 @@ class RiaApplication : public QApplication static std::vector readFileListFromTextFile(QString listFileName); + void waitUntilCommandObjectsHasBeenProcessed(); -private: +private: void onProjectOpenedOrClosed(); void setWindowCaptionFromAppState(); @@ -217,25 +213,16 @@ class RiaApplication : public QApplication void storeTreeViewState(); - void resizeMaximizedPlotWindows(); - void updateRegressionTest(const QString& testRootPath); - void regressionTestConfigureProject(); - static QSize regressionDefaultImageSize(); - friend RiaArgumentParser; void setHelpText(const QString& helpText); private slots: - void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - - + void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); private: - caf::PdmPointer m_activeReservoirView; - + caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; - RiaSocketServer* m_socketServer; caf::UiProcess* m_workerProcess; @@ -259,7 +246,6 @@ private slots: QMutex m_commandQueueLock; QString m_helpText; - bool m_runningRegressionTests; bool m_runningWorkerProcess; diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index a8c4615eb3..d8e76dd1af 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -21,6 +21,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -45,6 +46,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index ff99059e24..84f3c310d3 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -18,11 +18,12 @@ #include "RiaArgumentParser.h" -#include "RiaProjectModifier.h" #include "RiaApplication.h" -#include "RiaPreferences.h" -#include "RiaImportEclipseCaseTools.h" #include "RiaBaseDefs.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferences.h" +#include "RiaProjectModifier.h" +#include "RiaRegressionTestRunner.h" #include "RimProject.h" @@ -115,7 +116,7 @@ bool RiaArgumentParser::parseArguments() { CVF_ASSERT(o.valueCount() == 1); QString regressionTestPath = cvfqt::Utils::toQString(o.value(0)); - RiaApplication::instance()->executeRegressionTests(regressionTestPath); + RiaRegressionTestRunner::instance()->executeRegressionTests(regressionTestPath, QStringList()); return false; } @@ -123,7 +124,7 @@ bool RiaArgumentParser::parseArguments() { CVF_ASSERT(o.valueCount() == 1); QString regressionTestPath = cvfqt::Utils::toQString(o.value(0)); - RiaApplication::instance()->updateRegressionTest(regressionTestPath); + RiaRegressionTestRunner::instance()->updateRegressionTest(regressionTestPath); return false; } diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp new file mode 100644 index 0000000000..31f3d1b780 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -0,0 +1,546 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaRegressionTestRunner.h" + +#include "RiaApplication.h" +#include "RiaImageCompareReporter.h" +#include "RiaImageFileCompare.h" +#include "RiaLogging.h" +#include "RiaRegressionTest.h" +#include "RiaTextFileCompare.h" + +#include "RicfCommandFileExecutor.h" + +#include "Rim3dView.h" +#include "RimCase.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" + +#include "RiuMainPlotWindow.h" +#include "RiuMainWindow.h" +#include "RiuViewer.h" + +#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" +#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace RegTestNames +{ +const QString generatedFilesFolderName = "RegTestGeneratedFiles"; +const QString baseFilesFolderName = "RegTestBaseFiles"; +const QString generatedFolderName = "RegTestGeneratedImages"; +const QString diffFolderName = "RegTestDiffImages"; +const QString baseFolderName = "RegTestBaseImages"; +const QString testProjectName = "RegressionTest"; +const QString testFolderFilter = "TestCase*"; +const QString imageCompareExeName = "compare"; +const QString reportFileName = "ResInsightRegressionTestReport.html"; +const QString commandFileFilter = "commandfile-*"; +}; // namespace RegTestNames + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg) +{ + double timeRunning = time.elapsed() / 1000.0; + + QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1); + + RiaLogging::info(timeText + msg); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaRegressionTestRunner::RiaRegressionTestRunner() + : m_runningRegressionTests(false) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaRegressionTestRunner* RiaRegressionTestRunner::instance() +{ + static RiaRegressionTestRunner* singleton = new RiaRegressionTestRunner; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::runRegressionTest(const QString& testRootPath, const QStringList& testFilter) +{ + m_runningRegressionTests = true; + + RiaRegressionTest regressionTestConfig; + regressionTestConfig.readSettingsFromApplicationStore(); + + QString currentApplicationPath = QDir::currentPath(); + if (!regressionTestConfig.folderContainingCompareTool().isEmpty()) + { + // Windows Only : The image compare tool requires current working directory to be at the folder + // containing the image compare tool + + QDir::setCurrent(regressionTestConfig.folderContainingCompareTool()); + } + + QString generatedFolderName = RegTestNames::generatedFolderName; + QString diffFolderName = RegTestNames::diffFolderName; + QString baseFolderName = RegTestNames::baseFolderName; + QString regTestProjectName = RegTestNames::testProjectName; + QString regTestFolderFilter = RegTestNames::testFolderFilter; + + QDir testDir(testRootPath); // If string is empty it will end up as cwd + testDir.setFilter(QDir::Dirs); + QStringList dirNameFilter; + dirNameFilter.append(regTestFolderFilter); + testDir.setNameFilters(dirNameFilter); + + QFileInfoList folderList = testDir.entryInfoList(); + + if (!testFilter.isEmpty()) + { + QFileInfoList subset; + + for (auto fi : folderList) + { + QString path = fi.path(); + QString baseName = fi.baseName(); + + for (auto s : testFilter) + { + QString trimmed = s.trimmed(); + if (baseName.contains(trimmed)) + { + subset.push_back(fi); + } + } + } + + folderList = subset; + } + + // delete diff and generated images + + for (int i = 0; i < folderList.size(); ++i) + { + QDir testCaseFolder(folderList[i].filePath()); + + QDir genDir(testCaseFolder.filePath(generatedFolderName)); + removeDirectoryWithContent(genDir); + + QDir diffDir(testCaseFolder.filePath(diffFolderName)); + removeDirectoryWithContent(diffDir); + + QDir baseDir(testCaseFolder.filePath(baseFolderName)); + } + + // Generate html report + + RiaImageCompareReporter imageCompareReporter; + + // Minor workaround + // Use registry to define if interactive diff images should be created + // Defined by user in RiaRegressionTest + { + QSettings settings; + + bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool(); + if (useInteractiveDiff) + { + imageCompareReporter.showInteractiveOnly(); + } + } + + QTime timeStamp; + timeStamp.start(); + + logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n"); + + for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) + { + QDir testCaseFolder(folderList[dirIdx].filePath()); + + QString testFolderName = testCaseFolder.dirName(); + QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName); + QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName); + QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName); + + imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), + reportBaseFolderName.toStdString(), + reportGeneratedFolderName.toStdString(), + reportDiffFolderName.toStdString()); + } + + QString htmlReportFileName = testDir.filePath(RegTestNames::reportFileName); + imageCompareReporter.generateHTMLReport(htmlReportFileName.toStdString()); + + // Open HTML report + QDesktopServices::openUrl(htmlReportFileName); + + for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) + { + QDir testCaseFolder(folderList[dirIdx].filePath()); + + // Detect any command files + QStringList filterList; + filterList << RegTestNames::commandFileFilter; + + QFileInfoList commandFileEntries = testCaseFolder.entryInfoList(filterList); + if (!commandFileEntries.empty()) + { + QString currentApplicationPath = QDir::current().absolutePath(); + + // Set current path to the folder containing the command file, as this is required when using file references + // in the command file + QDir::setCurrent(folderList[dirIdx].filePath()); + + for (const auto& fileInfo : commandFileEntries) + { + QString commandFile = fileInfo.absoluteFilePath(); + + QFile file(commandFile); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error("Failed to open command file : " + commandFile); + } + else + { + QTextStream in(&file); + RicfCommandFileExecutor::instance()->executeCommands(in); + } + } + + QDir::setCurrent(currentApplicationPath); + + // Create diff based on generated folders + { + QString html; + + RiaRegressionTest regressionTestConfig; + regressionTestConfig.readSettingsFromApplicationStore(); + + RiaTextFileCompare textFileCompare(regressionTestConfig.folderContainingDiffTool()); + + QString baseFilesFolderName = testCaseFolder.filePath(RegTestNames::baseFilesFolderName); + QString generatedFilesFolderName = testCaseFolder.filePath(RegTestNames::generatedFilesFolderName); + + QFileInfo fib(baseFilesFolderName); + QFileInfo fig(generatedFilesFolderName); + + if (fib.exists() && fig.exists()) + { + { + QString headerText = testCaseFolder.dirName(); + + html += "

\n"; + html += " \n"; + html += " \n"; + html += " \n"; + + textFileCompare.runComparison(baseFilesFolderName, generatedFilesFolderName); + + QString diff = textFileCompare.diffOutput(); + if (diff.isEmpty()) + { + html += " \n"; + html += " \n"; + html += " \n"; + } + else + { + html += " \n"; + html += " \n"; + html += " \n"; + } + + // Table end + html += "
" + headerText + "
No text diff detected
Text diff detected - output from diff tool :
\n"; + + if (!diff.isEmpty()) + { + html += QString(" %1 ").arg(diff); + } + } + + QFile file(htmlReportFileName); + if (file.open(QIODevice::Append | QIODevice::Text)) + { + QTextStream stream(&file); + + stream << html; + } + } + } + } + + QString projectFileName; + + if (testCaseFolder.exists(regTestProjectName + ".rip")) + { + projectFileName = regTestProjectName + ".rip"; + } + + if (testCaseFolder.exists(regTestProjectName + ".rsp")) + { + projectFileName = regTestProjectName + ".rsp"; + } + + if (!projectFileName.isEmpty()) + { + logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath()); + + RiaApplication* app = RiaApplication::instance(); + + app->loadProject(testCaseFolder.filePath(projectFileName)); + + // Wait until all command objects have completed + app->waitUntilCommandObjectsHasBeenProcessed(); + + regressionTestConfigureProject(); + + resizeMaximizedPlotWindows(); + + QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder); + + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder); + + QDir baseDir(testCaseFolder.filePath(baseFolderName)); + QDir genDir(testCaseFolder.filePath(generatedFolderName)); + QDir diffDir(testCaseFolder.filePath(diffFolderName)); + if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName); + baseDir.setFilter(QDir::Files); + QStringList baseImageFileNames = baseDir.entryList(); + + for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx) + { + QString fileName = baseImageFileNames[fIdx]; + RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName); + bool ok = imgComparator.runComparison( + genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName)); + if (!ok) + { + qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); + } + } + + app->closeProject(); + + logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath()); + } + else + { + RiaLogging::error("Could not find a regression test file named : " + testCaseFolder.absolutePath() + "/" + + regTestProjectName + ".rsp"); + } + } + + RiaLogging::info("\n"); + logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); + + QDir::setCurrent(currentApplicationPath); + + m_runningRegressionTests = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::removeDirectoryWithContent(QDir& dirToDelete) +{ + QStringList files = dirToDelete.entryList(); + for (int fIdx = 0; fIdx < files.size(); ++fIdx) + { + dirToDelete.remove(files[fIdx]); + } + dirToDelete.rmdir("."); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::regressionTestConfigureProject() +{ + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + if (!mainWnd) return; + + RimProject* proj = RiaApplication::instance()->project(); + if (!proj) return; + + std::vector projectCases; + proj->allCases(projectCases); + + for (size_t i = 0; i < projectCases.size(); i++) + { + RimCase* cas = projectCases[i]; + if (!cas) continue; + + std::vector views = cas->views(); + + for (size_t j = 0; j < views.size(); j++) + { + Rim3dView* riv = views[j]; + + if (riv && riv->viewer()) + { + // Make sure all views are maximized for snapshotting + QMdiSubWindow* subWnd = mainWnd->findMdiSubWindow(riv->viewer()->layoutWidget()); + if (subWnd) + { + subWnd->showMaximized(); + } + + // This size is set to match the regression test reference images + riv->viewer()->setFixedSize(RiaRegressionTestRunner::regressionDefaultImageSize()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::resizeMaximizedPlotWindows() +{ + RimProject* proj = RiaApplication::instance()->project(); + if (!proj) return; + + RiuMainPlotWindow* plotMainWindow = RiaApplication::instance()->mainPlotWindow(); + if (!plotMainWindow) return; + + std::vector viewWindows; + + proj->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows); + + for (auto viewWindow : viewWindows) + { + if (viewWindow->isMdiWindow()) + { + RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry(); + if (wndGeo.isMaximized) + { + QWidget* viewWidget = viewWindow->viewWidget(); + + if (viewWidget) + { + QMdiSubWindow* mdiWindow = plotMainWindow->findMdiSubWindow(viewWidget); + if (mdiWindow) + { + mdiWindow->showNormal(); + + viewWidget->resize(RiaRegressionTestRunner::regressionDefaultImageSize()); + } + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiaRegressionTestRunner::regressionDefaultImageSize() +{ + return QSize(1000, 745); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::executeRegressionTests() +{ + RiaRegressionTest testConfig; + testConfig.readSettingsFromApplicationStore(); + + QString testPath = testConfig.regressionTestFolder(); + QStringList testFilter = testConfig.testFilter().split(";", QString::SkipEmptyParts); + + executeRegressionTests(testPath, testFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::executeRegressionTests(const QString& regressionTestPath, const QStringList& testFilter) +{ + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + if (mainWnd) + { + mainWnd->hideAllDockWindows(); + + mainWnd->setDefaultWindowSize(); + runRegressionTest(regressionTestPath, testFilter); + + mainWnd->loadWinGeoAndDockToolBarLayout(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaRegressionTestRunner::isRunningRegressionTests() const +{ + return m_runningRegressionTests; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::updateRegressionTest(const QString& testRootPath) +{ + // Find all sub folders + + QDir testDir(testRootPath); // If string is empty it will end up as cwd + testDir.setFilter(QDir::Dirs); + QStringList dirNameFilter; + dirNameFilter.append(RegTestNames::testFolderFilter); + testDir.setNameFilters(dirNameFilter); + + QFileInfoList folderList = testDir.entryInfoList(); + + for (int i = 0; i < folderList.size(); ++i) + { + QDir testCaseFolder(folderList[i].filePath()); + + QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName)); + removeDirectoryWithContent(baseDir); + testCaseFolder.mkdir(RegTestNames::baseFolderName); + + QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName)); + + QStringList imageFileNames = genDir.entryList(); + + for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx) + { + QString fileName = imageFileNames[fIdx]; + QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName)); + } + } +} diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h new file mode 100644 index 0000000000..7a622f9ff8 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +class QDir; + +//================================================================================================== +// +//================================================================================================== +class RiaRegressionTestRunner +{ +public: + RiaRegressionTestRunner(); + + static RiaRegressionTestRunner* instance(); + + void executeRegressionTests(const QString& regressionTestPath, const QStringList& testFilter); + void executeRegressionTests(); + + bool isRunningRegressionTests() const; + + static void updateRegressionTest(const QString& testRootPath); + +private: + void runRegressionTest(const QString& testRootPath, const QStringList& testFilter); + + static void removeDirectoryWithContent(QDir& dirToDelete); + static void regressionTestConfigureProject(); + static void resizeMaximizedPlotWindows(); + static QSize regressionDefaultImageSize(); + +private: + const QString m_rootPath; + const QStringList m_testFilter; + bool m_runningRegressionTests; +}; diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp index 90bdc35cd9..9120380a9d 100644 --- a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp @@ -61,7 +61,7 @@ bool RiaTextFileCompare::runComparison(const QString& baseFolder, const QString& } // Run compare recursively with '-r' - QString args = "-r"; + QString args = "-r -u"; QString completeCommand = QString("\"%1\" %2 %3 %4").arg(fullFilePath).arg(baseFolder).arg(generatedFolder).arg(args); diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp index 6d62294ae9..3d405b3405 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp @@ -18,8 +18,7 @@ #include "RicLaunchRegressionTestsFeature.h" -#include "RiaApplication.h" -#include "RiaRegressionTest.h" +#include "RiaRegressionTestRunner.h" #include "cafPdmSettings.h" @@ -41,7 +40,7 @@ bool RicLaunchRegressionTestsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked) { - RiaApplication::instance()->executeRegressionTests(); + RiaRegressionTestRunner::instance()->executeRegressionTests(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 63e7e581bd..ade02cc668 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -24,6 +24,7 @@ #include "RiaBaseDefs.h" #include "RiaPreferences.h" #include "RiaRegressionTest.h" +#include "RiaRegressionTestRunner.h" #include "Rim3dView.h" #include "RimCellEdgeColors.h" @@ -1726,8 +1727,7 @@ void RiuMainWindow::slotShowRegressionTestDialog() // Write preferences using QSettings and apply them to the application regTestConfig.writeSettingsToApplicationStore(); - RiaApplication* app = RiaApplication::instance(); - app->executeRegressionTests(); + RiaRegressionTestRunner::instance()->executeRegressionTests(); } } diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 41877fc8fe..f2f77556a4 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaBaseDefs.h" #include "RiaColorTools.h" +#include "RiaRegressionTestRunner.h" #include "RimCase.h" #include "RimProject.h" @@ -157,7 +158,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_viewerCommands = new RiuViewerCommands(this); - if (RiaApplication::instance()->isRunningRegressionTests()) + if (RiaRegressionTestRunner::instance()->isRunningRegressionTests()) { QFont regTestFont = m_infoLabel->font(); regTestFont.setPixelSize(11); From ca36e0a7ccaededfe29f350da4bdfd19effe4633 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 10:31:21 +0100 Subject: [PATCH 0447/1027] #2583 Add missing include --- ApplicationCode/Application/RiaApplication.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 9f99e469a1..eca3584b7d 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -98,6 +98,11 @@ #include #include + +#ifndef WIN32 +#include // for usleep +#endif //WIN32 + #ifdef USE_UNIT_TESTS #include "gtest/gtest.h" #endif // USE_UNIT_TESTS From 0629551fa88e16994e4a50ac43a3d6fdbca37bed Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 10:57:06 +0100 Subject: [PATCH 0448/1027] #2583 Remove obsolete code, moved to RiaRegressionTestRunner --- ApplicationCode/Application/RiaApplication.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index eca3584b7d..6dc271edda 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -120,21 +120,6 @@ void AppEnum< RiaApplication::RINavigationPolicy >::setUp() } } -namespace RegTestNames -{ -const QString generatedFilesFolderName = "RegTestGeneratedFiles"; -const QString baseFilesFolderName = "RegTestBaseFiles"; -const QString generatedFolderName = "RegTestGeneratedImages"; -const QString diffFolderName = "RegTestDiffImages"; -const QString baseFolderName = "RegTestBaseImages"; -const QString testProjectName = "RegressionTest"; -const QString testFolderFilter = "TestCase*"; -const QString imageCompareExeName = "compare"; -const QString reportFileName = "ResInsightRegressionTestReport.html"; -const QString commandFileFilter = "commandfile-*"; -}; - - From 00236c493e39e3a97f0733c842b709958ce619e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 11:00:55 +0100 Subject: [PATCH 0449/1027] Add new-line to 2D intersection view legend title --- ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 810c0a08be..6ef80b0521 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -486,12 +486,12 @@ void Rim2dIntersectionView::updateLegends() if ( eclView->cellResult()->isTernarySaturationSelected() ) { - m_ternaryLegendConfig()->setTitle("Cell Result:"); + m_ternaryLegendConfig()->setTitle("Cell Result:\n"); legend = m_ternaryLegendConfig()->legend(); } else { - m_legendConfig()->setTitle("Cell Result:" + eclView->cellResult()->resultVariableUiShortName()); + m_legendConfig()->setTitle("Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName()); legend = m_legendConfig()->legend(); } } From 6942a99406d96bfa04f1cde971f2d968f2b54130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 8 Mar 2018 11:01:04 +0100 Subject: [PATCH 0450/1027] #2569 Fracture containment. Fix fracture border polygon calculation --- .../RivWellFracturePartMgr.cpp | 16 +++- .../RivWellFracturePartMgr.h | 7 +- .../RimStimPlanFractureTemplate.cpp | 15 +--- .../RigCellGeometryTools.cpp | 37 +++++++++ .../ReservoirDataModel/RigCellGeometryTools.h | 2 + .../RigStimPlanFractureDefinition.cpp | 75 ++----------------- .../RigStimPlanFractureDefinition.h | 6 -- doc/fracture_clases.plantuml | 6 +- 8 files changed, 70 insertions(+), 94 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 370845320d..175d71c42b 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -667,7 +667,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar //-------------------------------------------------------------------------------------------------- cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimEclipseView& activeView) { - std::vector borderPolygonLocalCS = m_rimFracture->fractureTemplate()->fractureBorderPolygon(); + std::vector borderPolygonLocalCS = fractureBorderPolygon(); cvf::Mat4d frMx = m_rimFracture->transformMatrix(); cvf::BoundingBox frBBox; @@ -871,7 +871,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshPart(const RimEcli //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const +cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) { if (!stimPlanFracTemplate->fractureGrid()) return nullptr; @@ -888,6 +888,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri resultUnitFromColors, stimPlanFracTemplate->activeTimeStepIndex()); + m_visibleFracturePolygons.clear(); for ( size_t cIdx = 0; cIdx < stimPlanCells.size() ; ++cIdx) { if (prCellResults[cIdx] > 1e-7) @@ -898,6 +899,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri { stimPlanMeshVertices.push_back(static_cast(cellCorner)); } + m_visibleFracturePolygons.push_back(stimPlanCellPolygon); } } @@ -907,7 +909,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri } cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); - std::vector stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices, + std::vector stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform); @@ -926,6 +928,14 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri return stimPlanMeshGeo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RivWellFracturePartMgr::fractureBorderPolygon() +{ + return RigCellGeometryTools::unionOfPolygons(m_visibleFracturePolygons); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 614344f226..7fd9ab1a66 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -42,6 +42,7 @@ namespace caf } class RimFracture; +class RimFractureTemplate; class RimStimPlanFractureTemplate; class RimEclipseView; class RigFractureCell; @@ -74,7 +75,9 @@ class RivWellFracturePartMgr : public cvf::Object void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model); cvf::ref createStimPlanMeshPart(const RimEclipseView& activeView); - cvf::ref createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const; + cvf::ref createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView); + + std::vector fractureBorderPolygon(); static std::vector transformToFractureDisplayCoords(const std::vector& polygon, cvf::Mat4d m, @@ -84,4 +87,6 @@ class RivWellFracturePartMgr : public cvf::Object private: caf::PdmPointer m_rimFracture; + + std::vector> m_visibleFracturePolygons; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index e9599fa1e2..33aa35326d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -746,20 +746,7 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector RimStimPlanFractureTemplate::fractureBorderPolygon() { - if (m_stimPlanFractureDefinitionData.isNull()) return std::vector(); - - QString parameterName = m_borderPolygonResultName; - QString parameterUnit = getUnitForStimPlanParameter(parameterName); - - if (m_stimPlanFractureDefinitionData.notNull()) - { - return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName, - parameterUnit, - m_activeTimeStepIndex, - m_wellPathDepthAtFracture, - name()); - } - + // Not implemented return std::vector(); } diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp index e5b091dd60..5986063465 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp @@ -455,6 +455,43 @@ double RigCellGeometryTools::getLengthOfPolygonAlongLine(const std::pair RigCellGeometryTools::unionOfPolygons(std::vector> polygons) +{ + // Convert to int for clipper library and store as clipper "path" + std::vector polygonPaths; + for (const std::vector& polygon : polygons) + { + polygonPaths.emplace_back(); + auto& p = polygonPaths.back(); + for (const cvf::Vec3d& pp : polygon) + { + p.push_back(toClipperPoint(pp)); + } + } + + ClipperLib::Clipper clpr; + clpr.AddPaths(polygonPaths, ClipperLib::ptSubject, true); + + ClipperLib::Paths solution; + clpr.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); + + // Convert back to std::vector > + std::vector unionPolygon; + for (ClipperLib::Path pathInSol : solution) + { + std::vector clippedPolygon; + for (ClipperLib::IntPoint IntPosition : pathInSol) + { + unionPolygon.push_back(fromClipperPoint(IntPosition)); + } + } + + return unionPolygon; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h index 6a1b0c00da..24fc67fbf7 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h @@ -51,6 +51,8 @@ class RigCellGeometryTools static double getLengthOfPolygonAlongLine(const std::pair& line, const std::vector& polygon); + static std::vector unionOfPolygons(std::vector> polygons); + private: static std::vector ajustPolygonToAvoidIntersectionsAtVertex(const std::vector& polyLine, const std::vector& polygon); diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 7ce30ccdc2..8cd4e1a6fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -31,7 +31,6 @@ #include - //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- @@ -408,13 +407,13 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(cons RiaLogging::error("Did not find stim plan cell at well crossing!"); } - cvf::ref m_fractureGrid = new RigFractureGrid; - m_fractureGrid->setFractureCells(stimPlanCells); - m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ); - m_fractureGrid->setICellCount(this->m_Xs.size() - 2); - m_fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2); + cvf::ref fractureGrid = new RigFractureGrid; + fractureGrid->setFractureCells(stimPlanCells); + fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ); + fractureGrid->setICellCount(this->m_Xs.size() - 2); + fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2); - return m_fractureGrid; + return fractureGrid; } //-------------------------------------------------------------------------------------------------- @@ -526,68 +525,6 @@ void sortPolygon(std::vector &polygon) } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigStimPlanFractureDefinition::createFractureBorderPolygon(const QString& resultName, - const QString& resultUnit, - int activeTimeStepIndex, - double wellPathIntersectionAtFractureDepth, - const QString& fractureUserName) -{ - std::vector polygon; - - std::vector> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, activeTimeStepIndex); - - std::vector adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); - - for ( int k = 0; k < static_cast(dataAtTimeStep.size()); k++ ) - { - for ( int i = 0; i < static_cast(dataAtTimeStep[k].size()); i++ ) - { - if ( (dataAtTimeStep[k])[i] < 1e-7 ) //polygon should consist of nodes with value 0 - { - if ( (i > 0) && ((dataAtTimeStep[k])[(i - 1)] > 1e-7) ) //side neighbour cell different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), - static_cast(adjustedYs[k]), 0.0f)); - } - else if ( (k < static_cast(dataAtTimeStep.size()) - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7) )//cell below different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), - static_cast(adjustedYs[k]), 0.0f)); - } - else if ( (k > 0) && ((dataAtTimeStep[k - 1])[(i)] > 1e-7) )//cell above different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_Xs[i]), - static_cast(adjustedYs[k]), 0.0f)); - } - } - } - } - - sortPolygon(polygon); - - std::vector negPolygon; - for ( const cvf::Vec3f& node : polygon ) - { - cvf::Vec3f negNode = node; - negNode.x() = -negNode.x(); - negPolygon.insert(negPolygon.begin(), negNode); - } - - for ( const cvf::Vec3f& negNode : negPolygon ) - { - polygon.push_back(negNode); - } - - //Adding first point last - to close the polygon - if ( polygon.size()>0 ) polygon.push_back(polygon[0]); - - return polygon; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 4a00084d29..880fa6e60f 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -81,12 +81,6 @@ class RigStimPlanFractureDefinition: public cvf::Object std::vector* vertices, std::vector* triangleIndices); - std::vector createFractureBorderPolygon(const QString& resultName, - const QString& resultUnit, - int activeTimeStepIndex, - double wellPathIntersectionAtFractureDepth, - const QString& fractureUserName); - const std::vector& timeSteps() const; void addTimeStep(double time); size_t totalNumberTimeSteps(); diff --git a/doc/fracture_clases.plantuml b/doc/fracture_clases.plantuml index b4e0b2dd83..087952b33b 100644 --- a/doc/fracture_clases.plantuml +++ b/doc/fracture_clases.plantuml @@ -3,7 +3,7 @@ Title Classes related to fractures note as N1 - Updated 2018-02-07 + Updated 2018-03-07 end note class RimFracture { @@ -19,6 +19,10 @@ class RimWellPathFracture { RimFracture <|-- RimSimWellFracture RimFracture <|-- RimWellPathFracture +RimFracture -> RimStimPlanFractureTemplate + +RimFracture -> RivWellFracturePartMgr +RivWellFracturePartMgr ->RimFracture class RimFractureTemplate { RimDefines::UnitSystemType fractureTemplateUnit; From c258528dc58cda076bf21a20e8ecc6481f649d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 11:20:27 +0100 Subject: [PATCH 0451/1027] #51 Add background to standard legends. Needed a separate legend implementation, now in caf. Cleaned up CategoryLegend to make it ready for the new background. --- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 2 +- .../ProjectDataModel/RimLegendConfig.cpp | 8 +- .../ProjectDataModel/RimLegendConfig.h | 4 +- ApplicationCode/UserInterface/RiuViewer.cpp | 8 +- .../UserInterface/RiuViewerCommands.cpp | 2 +- Fwk/AppFwk/cafViewer/cafViewer.h | 1 - Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 4 + .../cafVizExtensions/cafCategoryLegend.cpp | 66 +- .../cafVizExtensions/cafCategoryLegend.h | 63 +- .../cafInternalLegendRenderTools.cpp | 203 +++++ .../cafInternalLegendRenderTools.h | 71 ++ .../cafOverlayScalarMapperLegend.cpp | 765 ++++++++++++++++++ .../cafOverlayScalarMapperLegend.h | 166 ++++ 14 files changed, 1258 insertions(+), 107 deletions(-) create mode 100644 Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp create mode 100644 Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h create mode 100644 Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp create mode 100644 Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 4e7ebe25b4..227e4b9117 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -82,10 +82,10 @@ #include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" #include "cafPdmUiTreeOrdering.h" +#include "cafOverlayScalarMapperLegend.h" #include "cvfDrawable.h" #include "cvfModelBasicList.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfScene.h" #include "cvfViewport.h" diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 258523ba2f..0adf95a227 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -55,9 +55,9 @@ #include "cafFrameAnimationControl.h" #include "cafPdmUiTreeOrdering.h" #include "cafProgressInfo.h" +#include "cafOverlayScalarMapperLegend.h" #include "cvfModelBasicList.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfScene.h" #include "cvfTransform.h" diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 81b42b35a9..971d48e037 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -32,6 +32,7 @@ #include "cafCategoryLegend.h" #include "cafCategoryMapper.h" +#include "cafOverlayScalarMapperLegend.h" #include "cafFactory.h" #include "cafPdmFieldCvfColor.h" @@ -39,7 +40,6 @@ #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiLineEditor.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfScalarMapperContinuousLinear.h" #include "cvfScalarMapperContinuousLog.h" #include "cvfScalarMapperDiscreteLinear.h" @@ -143,7 +143,7 @@ RimLegendConfig::RimLegendConfig() m_categoryMapper = new caf::CategoryMapper; cvf::Font* standardFont = RiaApplication::instance()->standardFont(); - m_scalarMapperLegend = new cvf::OverlayScalarMapperLegend(standardFont); + m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont); m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); updateFieldVisibility(); @@ -359,7 +359,7 @@ void RimLegendConfig::updateLegend() // Using Fixed format NumberFormatType nft = m_tickNumberFormat(); - m_scalarMapperLegend->setTickFormat((cvf::OverlayScalarMapperLegend::NumberFormat)nft); + m_scalarMapperLegend->setTickFormat((caf::OverlayScalarMapperLegend::NumberFormat)nft); // Set the fixed number of digits after the decimal point to the number needed to show all the significant digits. int numDecimalDigits = m_precision(); @@ -510,7 +510,7 @@ void RimLegendConfig::recreateLegend() // the legend disappeared because of this, so workaround: recreate the legend when needed: cvf::Font* standardFont = RiaApplication::instance()->standardFont(); - m_scalarMapperLegend = new cvf::OverlayScalarMapperLegend(standardFont); + m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont); m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); updateLegend(); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 41f0da15e8..d0772c3e6b 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -33,7 +33,6 @@ namespace cvf class ScalarMapperContinuousLog; class ScalarMapperContinuousLinear; class OverlayItem; - class OverlayScalarMapperLegend; class ScalarMapperDiscreteLinear; class ScalarMapperDiscreteLog; class ScalarMapper; @@ -44,6 +43,7 @@ namespace caf { class CategoryLegend; class CategoryMapper; + class OverlayScalarMapperLegend; } class Rim3dView; @@ -146,7 +146,7 @@ class RimLegendConfig: public caf::PdmObject cvf::ref m_linSmoothScalarMapper; cvf::ref m_currentScalarMapper; - cvf::ref m_scalarMapperLegend; + cvf::ref m_scalarMapperLegend; cvf::ref m_categoryMapper; cvf::ref m_categoryLegend; diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 62cb0232b3..37e8103221 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -40,6 +40,7 @@ #include "RiuViewerCommands.h" #include "cafCategoryLegend.h" +#include "cafOverlayScalarMapperLegend.h" #include "cafCeetronPlusNavigation.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -49,7 +50,6 @@ #include "cvfFont.h" #include "cvfOpenGLResourceManager.h" #include "cvfOverlayAxisCross.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfRenderQueueSorter.h" #include "cvfRenderSequence.h" #include "cvfRendering.h" @@ -908,17 +908,17 @@ void RiuViewer::updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend) cvf::Color3f contrastColor = computeContrastColor(); - cvf::OverlayScalarMapperLegend* scalarMapperLegend = dynamic_cast(legend); + caf::OverlayScalarMapperLegend* scalarMapperLegend = dynamic_cast(legend); if (scalarMapperLegend) { - scalarMapperLegend->setColor(contrastColor); + scalarMapperLegend->setTextColor(contrastColor); scalarMapperLegend->setLineColor(contrastColor); } caf::CategoryLegend* categoryLegend = dynamic_cast(legend); if (categoryLegend) { - categoryLegend->setColor(contrastColor); + categoryLegend->setTextColor(contrastColor); categoryLegend->setLineColor(contrastColor); } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 61da1cef03..db47dc9ab1 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -81,11 +81,11 @@ #include "cafDisplayCoordTransform.h" #include "cafPdmUiTreeView.h" #include "cafSelectionManager.h" +#include "cafOverlayScalarMapperLegend.h" #include "cvfDrawableGeo.h" #include "cvfHitItemCollection.h" #include "cvfOverlayAxisCross.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfTransform.h" diff --git a/Fwk/AppFwk/cafViewer/cafViewer.h b/Fwk/AppFwk/cafViewer/cafViewer.h index 23db03d2d6..9a58b4ee64 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.h +++ b/Fwk/AppFwk/cafViewer/cafViewer.h @@ -54,7 +54,6 @@ namespace cvf { class Model; class OverlayImage; class OverlayItem; - class OverlayScalarMapperLegend; class RenderSequence; class Rendering; class Scene; diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index 783194cc35..4acaab9e6a 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -14,6 +14,10 @@ add_library( ${PROJECT_NAME} cafBoxManipulatorGeometryGenerator.h cafCategoryLegend.cpp cafCategoryLegend.h + cafOverlayScalarMapperLegend.h + cafOverlayScalarMapperLegend.cpp + cafInternalLegendRenderTools.h + cafInternalLegendRenderTools.cpp cafCategoryMapper.cpp cafCategoryMapper.h cafFixedAtlasFont.h diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 80296c4ba1..cb1a522acf 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -39,7 +39,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) : m_sizeHint(200, 200), - m_color(Color3::BLACK), + m_textColor(Color3::BLACK), m_lineColor(Color3::BLACK), m_lineWidth(1), m_font(font), @@ -74,20 +74,11 @@ void CategoryLegend::setSizeHint(const Vec2ui& size) } //-------------------------------------------------------------------------------------------------- -/// Set color of the text and lines to be rendered +/// Set color of the text //-------------------------------------------------------------------------------------------------- -void CategoryLegend::setColor(const Color3f& color) +void CategoryLegend::setTextColor(const Color3f& color) { - m_color = color; -} - - -//-------------------------------------------------------------------------------------------------- -/// Returns the color of the text and lines -//-------------------------------------------------------------------------------------------------- -const Color3f& CategoryLegend::color() const -{ - return m_color; + m_textColor = color; } //-------------------------------------------------------------------------------------------------- @@ -108,25 +99,6 @@ void CategoryLegend::setTitle(const String& title) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -String CategoryLegend::title() const -{ - String title; - for (size_t i = 0; i < m_titleStrings.size(); ++i) - { - title += m_titleStrings[i]; - - if (i != m_titleStrings.size() - 1) - { - title += "\n"; - } - } - - return title; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -145,7 +117,7 @@ size_t CategoryLegend::categoryCount() const //-------------------------------------------------------------------------------------------------- void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, false); + renderGeneric(oglContext, position, size, false); } //-------------------------------------------------------------------------------------------------- @@ -153,7 +125,7 @@ void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, co //-------------------------------------------------------------------------------------------------- void CategoryLegend::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, true); + renderGeneric(oglContext, position, size, true); } //-------------------------------------------------------------------------------------------------- @@ -184,7 +156,7 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +void CategoryLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) { if (size.x() <= 0 || size.y() <= 0) { @@ -216,7 +188,7 @@ void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, co else { const MatrixState matrixState(camera); - renderLegend(oglContext, &layout, matrixState); + renderLegendUsingShaders(oglContext, &layout, matrixState); textDrawer.render(oglContext, camera); } @@ -236,7 +208,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL CVF_ASSERT(layout); textDrawer->setVerticalAlignment(TextDrawer::CENTER); - textDrawer->setTextColor(m_color); + textDrawer->setTextColor(m_textColor); m_visibleCategoryLabels.clear(); @@ -296,7 +268,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL //-------------------------------------------------------------------------------------------------- /// Draw the legend using shader programs //-------------------------------------------------------------------------------------------------- -void CategoryLegend::renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) +void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) { CVF_CALLSITE_OPENGL(oglContext); @@ -492,7 +464,7 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; - glColor3fv(m_color.ptr()); + glColor3fv(m_textColor.ptr()); glBegin(GL_LINES); glVertex3fv(v0); glVertex3fv(v1); @@ -550,14 +522,6 @@ void CategoryLegend::setLineColor(const Color3f& lineColor) m_lineColor = lineColor; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const Color3f& CategoryLegend::lineColor() const -{ - return m_lineColor; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -566,13 +530,7 @@ void CategoryLegend::setLineWidth(int lineWidth) m_lineWidth = lineWidth; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int CategoryLegend::lineWidth() const -{ - return m_lineWidth; -} + } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 74e9f1d03a..340a5ffe13 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -29,35 +29,21 @@ class CategoryLegend : public cvf::OverlayItem CategoryLegend(cvf::Font* font, const CategoryMapper* categoryMapper); virtual ~CategoryLegend(); - virtual cvf::Vec2ui sizeHint(); + void setSizeHint(const cvf::Vec2ui& size); - virtual void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual bool pick(int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size); + void setTextColor(const cvf::Color3f& color); + void setLineColor(const cvf::Color3f& lineColor); + void setLineWidth(int lineWidth); + void setTitle(const cvf::String& title); - - void setSizeHint(const cvf::Vec2ui& size); - - void setColor(const cvf::Color3f& color); - const cvf::Color3f& color() const; - - void setLineColor(const cvf::Color3f& lineColor); - const cvf::Color3f& lineColor() const; - void setLineWidth(int lineWidth); - int lineWidth() const; - - void setTitle(const cvf::String& title); - cvf::String title() const; - - size_t categoryCount() const; + size_t categoryCount() const; protected: + cvf::Vec2ui sizeHint() override; + void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; - //================================================================================================== - // - // Helper for storing layout info - // - //================================================================================================== struct OverlayColorLegendLayoutInfo { OverlayColorLegendLayoutInfo(const cvf::Vec2i& pos, const cvf::Vec2ui& setSize) @@ -85,24 +71,23 @@ class CategoryLegend : public cvf::OverlayItem cvf::Vec2ui size; }; + void layoutInfo(OverlayColorLegendLayoutInfo* layout); - void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - virtual void renderLegend(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const cvf::MatrixState& matrixState); - virtual void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout); - virtual void setupTextDrawer(cvf::TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout); - - void layoutInfo(OverlayColorLegendLayoutInfo* layout); + void renderGeneric(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); + void setupTextDrawer(cvf::TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout); + void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const cvf::MatrixState& matrixState); + void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout); protected: - std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label - - cvf::Vec2ui m_sizeHint; // Pixel size of the color legend area - - cvf::Color3f m_color; - cvf::Color3f m_lineColor; - int m_lineWidth; - std::vector m_titleStrings; - cvf::ref m_font; + std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label + + cvf::Vec2ui m_sizeHint; // Pixel size of the color legend area + + cvf::Color3f m_textColor; + cvf::Color3f m_lineColor; + int m_lineWidth; + std::vector m_titleStrings; + cvf::ref m_font; cvf::cref m_categoryMapper; }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp new file mode 100644 index 0000000000..9f97ea4e43 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp @@ -0,0 +1,203 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 "cafInternalLegendRenderTools.h" +#include "cvfOpenGL.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" +#include "cvfRenderStateBlending.h" +#include "cvfShaderProgram.h" +#include "cvfOpenGLContext.h" +#include "cvfOpenGLResourceManager.h" +#include +#include "cvfUniform.h" +#include "cvfRenderState_FF.h" + +using namespace cvf; + +namespace caf +{ +//-------------------------------------------------------------------------------------------------- +/// Render a semi transparent background frame +//-------------------------------------------------------------------------------------------------- +void InternalLegendRenderTools::renderBackgroundUsingShaders(OpenGLContext* oglContext, + const MatrixState& matrixState, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor) +{ + CVF_CALLSITE_OPENGL(oglContext); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLine line(1.0f); + line.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Shader program + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + std::array vertexArray ={ + Vec3f(1 , 1, 0.0f), + Vec3f(size.x(), 1, 0.0f), + Vec3f(size.x(), size.y(), 0.0f), + Vec3f(1 , size.y(), 0.0f), + }; + + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray.data()); + + // Draw frame background + + UniformFloat backgroundColorUniform("u_color", backgroundColor); + shaderProgram->applyUniform(oglContext, backgroundColorUniform); + + // Triangle indices for the frame background + + static const ushort backgroundTriangleIndices[] = { 0, 1, 2, 2, 3, 0}; + + glDrawRangeElements(GL_TRIANGLES, 0, 3, 6, GL_UNSIGNED_SHORT, backgroundTriangleIndices); + + + // Draw frame border lines + + UniformFloat uniformColor("u_color", backgroundFrameColor); + shaderProgram->applyUniform(oglContext, uniformColor); + + static const ushort frameLineIndices[] = { 0, 1, + 1, 2, + 2, 3, + 3, 0 }; + + glDrawRangeElements(GL_LINES, 0, 3, 8, GL_UNSIGNED_SHORT, frameLineIndices); + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + +//-------------------------------------------------------------------------------------------------- +/// Draw a background rectangle using OGL 1.1 compatibility +//-------------------------------------------------------------------------------------------------- +void InternalLegendRenderTools::renderBackgroundImmediateMode(OpenGLContext* oglContext, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor) +{ + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Frame vertices + + std::array vertexArray = { + Vec3f(1 , 1, 0.0f), + Vec3f(size.x(), 1, 0.0f), + Vec3f(size.x(), size.y(), 0.0f), + Vec3f(1 , size.y(), 0.0f), + }; + + + glColor4fv(backgroundColor.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glEnd(); + + // Render Line around + + { + glColor4fv(backgroundFrameColor.ptr()); + glBegin(GL_LINES); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[0].ptr()); + glEnd(); + } + + // Reset render states + + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + CVF_CHECK_OGL(oglContext); +} + + +} diff --git a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h new file mode 100644 index 0000000000..1a19614735 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h @@ -0,0 +1,71 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 "cvfOpenGLContext.h" +#include "cvfMatrixState.h" +#include "cvfColor4.h" + + +//================================================================================================== +// +// Tools to render legend stuff +// +//================================================================================================== +namespace caf { + + +class InternalLegendRenderTools +{ + using OpenGLContext = cvf::OpenGLContext; + using Color4f = cvf::Color4f; + using String = cvf::String; + using MatrixState = cvf::MatrixState; + using Vec2f = cvf::Vec2f; +public: + static void renderBackgroundUsingShaders(OpenGLContext* oglContext, + const MatrixState& matrixState, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor); + static void renderBackgroundImmediateMode(OpenGLContext* oglContext, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor); +}; + +} + diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp new file mode 100644 index 0000000000..b743248087 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -0,0 +1,765 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 "cvfBase.h" +#include "cafOverlayScalarMapperLegend.h" +#include "cvfOpenGL.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfGeometryBuilderDrawableGeo.h" +#include "cvfGeometryUtils.h" +#include "cvfViewport.h" +#include "cvfCamera.h" +#include "cvfTextDrawer.h" +#include "cvfFont.h" +#include "cvfShaderProgram.h" +#include "cvfShaderProgramGenerator.h" +#include "cvfShaderSourceProvider.h" +#include "cvfShaderSourceRepository.h" +#include "cvfUniform.h" +#include "cvfMatrixState.h" +#include "cvfBufferObjectManaged.h" +#include "cvfGlyph.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" + +#include "cafInternalLegendRenderTools.h" + +#ifndef CVF_OPENGL_ES +#include "cvfRenderState_FF.h" +#endif + +#include "cvfScalarMapper.h" +#include +#include "cvfRenderStateBlending.h" + +namespace caf { + +using namespace cvf; + +//================================================================================================== +/// +/// \class cvf::OverlayColorLegend +/// \ingroup Render +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +OverlayScalarMapperLegend::OverlayScalarMapperLegend(Font* font) +: m_sizeHint(200, 200), + m_textColor(Color3::BLACK), + m_lineColor(Color3::BLACK), + m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f), + m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f), + m_isBackgroundEnabled(true), + m_lineWidth(1), + m_font(font), + m_tickNumberPrecision(4), + m_numberFormat(AUTO) +{ + CVF_ASSERT(font); + CVF_ASSERT(!font->isEmpty()); + + m_tickValues.reserve(3); + m_tickValues.add(0.0); + m_tickValues.add(0.5); + m_tickValues.add(1.0); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +OverlayScalarMapperLegend::~OverlayScalarMapperLegend() +{ + // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui OverlayScalarMapperLegend::sizeHint() +{ + return m_sizeHint; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setScalarMapper(const ScalarMapper* scalarMapper) +{ + m_scalarMapper = scalarMapper; + + if (m_scalarMapper.notNull()) + { + std::vector levelValues; + m_scalarMapper->majorTickValues(&levelValues); + + m_tickValues.assign(levelValues); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setSizeHint(const Vec2ui& size) +{ + m_sizeHint = size; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set color of the text +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTextColor(const Color3f& color) +{ + m_textColor = color; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set the title (text that will be rendered above the legend) +/// +/// The legend supports multi-line titles. Separate each line with a '\n' character +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTitle(const String& title) +{ + // Title + if (title.isEmpty()) + { + m_titleStrings.clear(); + } + else + { + m_titleStrings = title.split("\n"); + } +} + +//-------------------------------------------------------------------------------------------------- +/// Hardware rendering using shader programs +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, false); +} + + +//-------------------------------------------------------------------------------------------------- +/// Software rendering using software +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, true); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) +{ + Recti oglRect(position, size.x(), size.y()); + + OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height())); + layoutInfo(&layoutInViewPortCoords); + + Vec2i legendBarOrigin = oglRect.min(); + legendBarOrigin.x() += static_cast(layoutInViewPortCoords.legendRect.min().x()); + legendBarOrigin.y() += static_cast(layoutInViewPortCoords.legendRect.min().y()); + + Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.legendRect.width()), static_cast(layoutInViewPortCoords.legendRect.height())); + + if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && + (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) + { + return true; + } + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set up camera/viewport and render +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +{ + if (size.x() <= 0 || size.y() <= 0) + { + return; + } + + Camera camera; + camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setProjectionAsPixelExact2D(); + camera.setViewMatrix(Mat4d::IDENTITY); + camera.applyOpenGL(); + camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); + + // Get layout information + // Todo: Cache this between renderings. Update only when needed. + OverlayColorLegendLayoutInfo layout(position, size); + layoutInfo(&layout); + + // Set up text drawer + float maxLegendRightPos = 0; + TextDrawer textDrawer(m_font.p()); + setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); + + Vec2f backgroundSize(maxLegendRightPos + 3.0f, (float)size.y()); + + // Do the actual rendering + if (software) + { + if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, m_backgroundColor, m_backgroundFrameColor); + renderLegendImmediateMode(oglContext, &layout); + textDrawer.renderSoftware(oglContext, camera); + } + else + { + const MatrixState matrixState(camera); + if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, m_backgroundColor, m_backgroundFrameColor); + renderLegendUsingShaders(oglContext, &layout, matrixState); + textDrawer.render(oglContext, camera); + } + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const OverlayColorLegendLayoutInfo* layout, float* maxLegendRightPos) +{ + CVF_ASSERT(layout); + + float legendRight = 0.0f; + + textDrawer->setVerticalAlignment(TextDrawer::CENTER); + textDrawer->setTextColor(m_textColor); + + m_visibleTickLabels.clear(); + + const float textX = layout->tickX + 5; + + const float overlapTolerance = 1.2f * layout->charHeight; + float lastVisibleTextY = 0.0; + + size_t numTicks = m_tickValues.size(); + size_t it; + for (it = 0; it < numTicks; it++) + { + float textY = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(it)); + + // Always draw first and last tick label. For all others, skip drawing if text ends up + // on top of the previous label. + if (it != 0 && it != (numTicks - 1)) + { + if (cvf::Math::abs(textY - lastVisibleTextY) < overlapTolerance) + { + m_visibleTickLabels.push_back(false); + continue; + } + // Make sure it does not overlap the last tick as well + + float lastTickY = static_cast(layout->legendRect.max().y() ); + + if (cvf::Math::abs(textY - lastTickY) < overlapTolerance) + { + m_visibleTickLabels.push_back(false); + continue; + } + } + + double tickValue = m_tickValues[it]; + String valueString; + switch (m_numberFormat) + { + case FIXED: + valueString = String::number(tickValue, 'f', m_tickNumberPrecision); + break; + case SCIENTIFIC: + valueString = String::number(tickValue, 'e', m_tickNumberPrecision); + break; + default: + valueString = String::number(tickValue); + break; + } + + Vec2f pos(textX, textY); + textDrawer->addText(valueString, pos); + + float neededRightPos = pos.x() + m_font->textExtent(valueString).x(); + legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; + + lastVisibleTextY = textY; + m_visibleTickLabels.push_back(true); + } + + float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight/2.0f; + for (it = 0; it < m_titleStrings.size(); it++) + { + Vec2f pos(layout->margins.x(), titleY); + textDrawer->addText(m_titleStrings[it], pos); + + float neededRightPos = pos.x() + m_font->textExtent(m_titleStrings[it]).x(); + legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; + + + titleY -= layout->lineSpacing; + } + + *maxLegendRightPos = legendRight; +} + + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using shader programs +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) +{ + CVF_CALLSITE_OPENGL(oglContext); + + CVF_TIGHT_ASSERT(layout); + CVF_TIGHT_ASSERT(layout->size.x() > 0); + CVF_TIGHT_ASSERT(layout->size.y() > 0); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + RenderStateLine line(static_cast(m_lineWidth)); + line.applyOpenGL(oglContext); + + // All vertices. Initialized here to set Z to zero once and for all. + static float vertexArray[] = + { + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f + }; + + // Per vector convenience pointers + float* v0 = &vertexArray[0]; + float* v1 = &vertexArray[3]; + float* v2 = &vertexArray[6]; + float* v3 = &vertexArray[9]; + float* v4 = &vertexArray[12]; + + // Constant coordinates + v0[0] = v3[0] = layout->x0; + v1[0] = v4[0] = layout->x1; + + // Connects + static const ushort trianglesConnects[] = { 0, 1, 4, 0, 4, 3 }; + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray); + + // Render color bar as one colored quad per pixel + + int legendHeightPixelCount = static_cast(layout->tickPixelPos->get(m_tickValues.size()-1) - layout->tickPixelPos->get(0) + 0.01); + if (m_scalarMapper.notNull()) + { + int iPx; + for (iPx = 0; iPx < legendHeightPixelCount; iPx++) + { + const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); + float y0 = static_cast(layout->legendRect.min().y() + iPx); + float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + + // Dynamic coordinates for rectangle + v0[1] = v1[1] = y0; + v3[1] = v4[1] = y1; + + // Draw filled rectangle elements + { + UniformFloat uniformColor("u_color", Color4f(Color3f(clr))); + shaderProgram->applyUniform(oglContext, uniformColor); + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, trianglesConnects); +#else + glDrawRangeElements(GL_TRIANGLES, 0, 4, 6, GL_UNSIGNED_SHORT, trianglesConnects); +#endif + } + } + } + + // Render frame + + // Dynamic coordinates for tickmarks-lines + bool isRenderingFrame = true; + if (isRenderingFrame) + { + v0[0] = v2[0] = layout->legendRect.min().x()-0.5f; + v1[0] = v3[0] = layout->legendRect.max().x()-0.5f; + v0[1] = v1[1] = layout->legendRect.min().y()-0.5f; + v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; + static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0}; + + UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + shaderProgram->applyUniform(oglContext, uniformColor); + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_LINES, 8, GL_UNSIGNED_SHORT, frameConnects); +#else + glDrawRangeElements(GL_LINES, 0, 3, 8, GL_UNSIGNED_SHORT, frameConnects); +#endif + } + + // Render tickmarks + bool isRenderingTicks = true; + + if (isRenderingTicks) + { + // Constant coordinates + v0[0] = layout->x0; + v1[0] = layout->x1 - 0.5f*(layout->tickX - layout->x1) - 0.5f; + v2[0] = layout->x1; + v3[0] = layout->tickX - 0.5f*(layout->tickX - layout->x1) - 0.5f; + v4[0] = layout->tickX; + + static const ushort tickLinesWithLabel[] = { 0, 4 }; + static const ushort tickLinesWoLabel[] = { 2, 3 }; + + size_t ic; + for (ic = 0; ic < m_tickValues.size(); ic++) + { + float y0 = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(ic) - 0.5f); + + // Dynamic coordinates for tickmarks-lines + v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; + + UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + shaderProgram->applyUniform(oglContext, uniformColor); + const ushort * linesConnects; + + if ( m_visibleTickLabels[ic]) + { + linesConnects = tickLinesWithLabel; + } + else + { + linesConnects = tickLinesWoLabel; + } + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, linesConnects); +#else + glDrawRangeElements(GL_LINES, 0, 4, 2, GL_UNSIGNED_SHORT, linesConnects); +#endif + } + } + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using immediate mode OpenGL +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout) +{ +#ifdef CVF_OPENGL_ES + CVF_UNUSED(layout); + CVF_FAIL_MSG("Not supported on OpenGL ES"); +#else + CVF_TIGHT_ASSERT(layout); + CVF_TIGHT_ASSERT(layout->size.x() > 0); + CVF_TIGHT_ASSERT(layout->size.y() > 0); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + // All vertices. Initialized here to set Z to zero once and for all. + static float vertexArray[] = + { + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + // Per vector convenience pointers + float* v0 = &vertexArray[0]; + float* v1 = &vertexArray[3]; + float* v2 = &vertexArray[6]; + float* v3 = &vertexArray[9]; + float* v4 = &vertexArray[12]; + + // Constant coordinates + v0[0] = v3[0] = layout->x0; + v1[0] = v4[0] = layout->x1; + + // Render color bar as one colored quad per pixel + + int legendHeightPixelCount = static_cast(layout->tickPixelPos->get(m_tickValues.size() - 1) - layout->tickPixelPos->get(0) + 0.01); + if (m_scalarMapper.notNull()) + { + int iPx; + for (iPx = 0; iPx < legendHeightPixelCount; iPx++) + { + const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); + float y0 = static_cast(layout->legendRect.min().y() + iPx); + float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + + // Dynamic coordinates for rectangle + v0[1] = v1[1] = y0; + v3[1] = v4[1] = y1; + + // Draw filled rectangle elements + glColor3ubv(clr.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(v0); + glVertex3fv(v1); + glVertex3fv(v4); + glVertex3fv(v3); + glEnd(); + } + } + + // Render frame + + // Dynamic coordinates for tickmarks-lines + bool isRenderingFrame = true; + if (isRenderingFrame) + { + v0[0] = v2[0] = layout->legendRect.min().x()-0.5f; + v1[0] = v3[0] = layout->legendRect.max().x()-0.5f; + v0[1] = v1[1] = layout->legendRect.min().y()-0.5f; + v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; + + glColor3fv(m_textColor.ptr()); + glBegin(GL_LINES); + glVertex3fv(v0); + glVertex3fv(v1); + glVertex3fv(v1); + glVertex3fv(v3); + glVertex3fv(v3); + glVertex3fv(v2); + glVertex3fv(v2); + glVertex3fv(v0); + glEnd(); + + } + + // Render tickmarks + bool isRenderingTicks = true; + + if (isRenderingTicks) + { + // Constant coordinates + v0[0] = layout->x0; + v1[0] = layout->x1 - 0.5f*(layout->tickX - layout->x1) - 0.5f; + v2[0] = layout->x1; + v3[0] = layout->tickX - 0.5f*(layout->tickX - layout->x1) - 0.5f; + v4[0] = layout->tickX; + + size_t ic; + for (ic = 0; ic < m_tickValues.size(); ic++) + { + float y0 = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(ic) - 0.5f); + + // Dynamic coordinates for tickmarks-lines + v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; + + glColor3fv(m_textColor.ptr()); + glBegin(GL_LINES); + if ( m_visibleTickLabels[ic]) + { + glVertex3fv(v0); + glVertex3fv(v4); + } + else + { + glVertex3fv(v2); + glVertex3fv(v3); + } + glEnd(); + } + } + + // Reset render states + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +#endif // CVF_OPENGL_ES +} + +//-------------------------------------------------------------------------------------------------- +/// Get layout information +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) +{ + CVF_TIGHT_ASSERT(layout); + + ref glyph = m_font->getGlyph(L'A'); + layout->charHeight = static_cast(glyph->height()); + layout->lineSpacing = layout->charHeight*1.5f; + layout->margins = Vec2f(4.0f, 4.0f); + + float legendWidth = 25.0f; + float legendHeight = static_cast(layout->size.y()) - 2*layout->margins.y() - static_cast(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing; + layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight/2.0f, legendWidth, legendHeight); + + if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) + { + return; + } + + layout->x0 = layout->margins.x(); + layout->x1 = layout->margins.x() + layout->legendRect.width(); + layout->tickX = layout->x1 + 5; + + // Build array containing the pixel positions of all the ticks + size_t numTicks = m_tickValues.size(); + layout->tickPixelPos = new DoubleArray(numTicks); + + size_t i; + for (i = 0; i < numTicks; i++) + { + double t; + if (m_scalarMapper.isNull()) t = 0; + else t = m_scalarMapper->normalizedValue(m_tickValues[i]); + t = Math::clamp(t, 0.0, 1.1); + if (i != numTicks -1) + { + layout->tickPixelPos->set(i, t*layout->legendRect.height()); + } + else + { + layout->tickPixelPos->set(i, layout->legendRect.height()); // Make sure we get a value at the top even if the scalarmapper range is zero + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setLineColor(const Color3f& lineColor) +{ + m_lineColor = lineColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setBackgroundColor(const Color4f& backgroundColor) +{ + m_backgroundColor = backgroundColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setBackgroundFrameColor(const Color4f& backgroundFrameColor) +{ + m_backgroundFrameColor = backgroundFrameColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::enableBackground(bool enable) +{ + m_isBackgroundEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setLineWidth(int lineWidth) +{ + m_lineWidth = lineWidth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTickPrecision(int precision) +{ + m_tickNumberPrecision = precision; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) +{ + m_numberFormat = format; +} + + +} // namespace cvf + diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h new file mode 100644 index 0000000000..1890f41244 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -0,0 +1,166 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 "cvfOverlayItem.h" +#include "cvfArray.h" +#include "cvfCamera.h" +#include "cvfString.h" +#include "cvfRect.h" + +namespace cvf { +class Font; +class ShaderProgram; +class MatrixState; +class TextDrawer; +class ScalarMapper; +} + +namespace caf { + + +//================================================================================================== +// +// Overlay color legend +// +//================================================================================================== +class OverlayScalarMapperLegend : public cvf::OverlayItem +{ + using Font = cvf::Font; + using ScalarMapper = cvf::ScalarMapper; + using OpenGLContext = cvf::OpenGLContext; + using Vec2i = cvf::Vec2i; + using Vec2ui = cvf::Vec2ui; + using Color3f = cvf::Color3f; + using Color4f = cvf::Color4f; + using String = cvf::String; + using DoubleArray = cvf::DoubleArray; + using MatrixState = cvf::MatrixState; + using Vec2f = cvf::Vec2f; + using Rectf = cvf::Rectf; + using TextDrawer = cvf::TextDrawer; + +public: + OverlayScalarMapperLegend(Font* font); + virtual ~OverlayScalarMapperLegend(); + + void setScalarMapper(const ScalarMapper* scalarMapper); + + void setSizeHint(const Vec2ui& size); + + void setTextColor(const Color3f& color); + void setLineColor(const Color3f& lineColor); + + void setLineWidth(int lineWidth); + + void setTickPrecision(int precision); + enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; + void setTickFormat(NumberFormat format); + + void enableBackground(bool enable); + void setBackgroundColor(const Color4f& backgroundColor); + void setBackgroundFrameColor(const Color4f& backgroundFrameColor); + + void setTitle(const String& title); + +protected: + Vec2ui sizeHint() override; + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) override; + + struct OverlayColorLegendLayoutInfo + { + OverlayColorLegendLayoutInfo(const Vec2i& pos, const Vec2ui& setSize) + { + position = pos; + size = setSize; + } + + float charHeight; + float lineSpacing; + Vec2f margins; + float tickX; + float x0, x1; + + Rectf legendRect; + + cvf::ref tickPixelPos; + + Vec2i position; + Vec2ui size; + }; + + void layoutInfo(OverlayColorLegendLayoutInfo* layout); + + void renderGeneric(OpenGLContext* oglContext, + const Vec2i& position, + const Vec2ui& size, + bool software); + void renderLegendUsingShaders(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const MatrixState& matrixState); + void renderLegendImmediateMode(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout); + void setupTextDrawer(TextDrawer* textDrawer, + const OverlayColorLegendLayoutInfo* layout, + float* maxLegendRightPos); + +protected: + DoubleArray m_tickValues; // Ticks between each level + top and bottom of legend (n+1 entries) + std::vector m_visibleTickLabels; // Skip tick labels ending up on top of previous visible label + int m_tickNumberPrecision; + NumberFormat m_numberFormat; + + Vec2ui m_sizeHint; // Pixel size of the color legend area + + Color3f m_textColor; + Color3f m_lineColor; + bool m_isBackgroundEnabled; + Color4f m_backgroundColor; + Color4f m_backgroundFrameColor; + + int m_lineWidth; + + std::vector m_titleStrings; + cvf::ref m_font; + + cvf::cref m_scalarMapper; +}; + +} From 7bd08067a98b4d1ff4c928a2da627461891527c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 11:38:51 +0100 Subject: [PATCH 0452/1027] #52 Add background to category legend --- .../cafVizExtensions/cafCategoryLegend.cpp | 65 +++++++++++++++++-- .../cafVizExtensions/cafCategoryLegend.h | 24 +++++-- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index cb1a522acf..bade5c7032 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -27,6 +27,7 @@ #endif #include "cvfScalarMapper.h" +#include "cafInternalLegendRenderTools.h" using namespace cvf; @@ -41,6 +42,9 @@ CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) : m_sizeHint(200, 200), m_textColor(Color3::BLACK), m_lineColor(Color3::BLACK), + m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f), + m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f), + m_isBackgroundEnabled(true), m_lineWidth(1), m_font(font), m_categoryMapper(categoryMapper) @@ -156,7 +160,10 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void CategoryLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +void CategoryLegend::renderGeneric(OpenGLContext* oglContext, + const Vec2i& position, + const Vec2ui& size, + bool software) { if (size.x() <= 0 || size.y() <= 0) { @@ -176,18 +183,30 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& posit layoutInfo(&layout); // Set up text drawer + float maxLegendRightPos = 0; TextDrawer textDrawer(m_font.p()); - setupTextDrawer(&textDrawer, &layout); + setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); + + Vec2f backgroundSize(maxLegendRightPos + 3.0f, (float)size.y()); // Do the actual rendering if (software) { + if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + backgroundSize, + m_backgroundColor, + m_backgroundFrameColor); renderLegendImmediateMode(oglContext, &layout); textDrawer.renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); + if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + backgroundSize, + m_backgroundColor, + m_backgroundFrameColor); renderLegendUsingShaders(oglContext, &layout, matrixState); textDrawer.render(oglContext, camera); } @@ -198,7 +217,9 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& posit //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout) +void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, + OverlayColorLegendLayoutInfo* layout, + float* maxLegendRightPos) { if (m_categoryMapper.isNull()) { @@ -207,6 +228,8 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL CVF_ASSERT(layout); + float legendRight = 0.0f; + textDrawer->setVerticalAlignment(TextDrawer::CENTER); textDrawer->setTextColor(m_textColor); @@ -251,6 +274,9 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL Vec2f pos(textX, textY); textDrawer->addText(displayText, pos); + float neededRightPos = pos.x() + m_font->textExtent(displayText).x(); + legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; + lastVisibleTextY = textY; m_visibleCategoryLabels.push_back(true); } @@ -261,14 +287,21 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL Vec2f pos(layout->margins.x(), titleY); textDrawer->addText(m_titleStrings[it], pos); + float neededRightPos = pos.x() + m_font->textExtent(m_titleStrings[it]).x(); + legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; + titleY -= layout->lineSpacing; } + + *maxLegendRightPos = legendRight; } //-------------------------------------------------------------------------------------------------- /// Draw the legend using shader programs //-------------------------------------------------------------------------------------------------- -void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) +void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const MatrixState& matrixState) { CVF_CALLSITE_OPENGL(oglContext); @@ -530,6 +563,30 @@ void CategoryLegend::setLineWidth(int lineWidth) m_lineWidth = lineWidth; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CategoryLegend::setBackgroundColor(const Color4f& backgroundColor) +{ + m_backgroundColor = backgroundColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CategoryLegend::setBackgroundFrameColor(const Color4f& backgroundFrameColor) +{ + m_backgroundFrameColor = backgroundFrameColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CategoryLegend::enableBackground(bool enable) +{ + m_isBackgroundEnabled = enable; +} + diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 340a5ffe13..450a6e3a8d 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -36,6 +36,10 @@ class CategoryLegend : public cvf::OverlayItem void setLineWidth(int lineWidth); void setTitle(const cvf::String& title); + void enableBackground(bool enable); + void setBackgroundColor(const cvf::Color4f& backgroundColor); + void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); + size_t categoryCount() const; protected: @@ -73,10 +77,18 @@ class CategoryLegend : public cvf::OverlayItem void layoutInfo(OverlayColorLegendLayoutInfo* layout); - void renderGeneric(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - void setupTextDrawer(cvf::TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout); - void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const cvf::MatrixState& matrixState); - void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout); + void renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software); + void setupTextDrawer(cvf::TextDrawer* textDrawer, + OverlayColorLegendLayoutInfo* layout, + float* maxLegendRightPos); + void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const cvf::MatrixState& matrixState); + void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout); protected: std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label @@ -89,6 +101,10 @@ class CategoryLegend : public cvf::OverlayItem std::vector m_titleStrings; cvf::ref m_font; + bool m_isBackgroundEnabled; + cvf::Color4f m_backgroundColor; + cvf::Color4f m_backgroundFrameColor; + cvf::cref m_categoryMapper; }; From c424063d864498e68fff1a8801aa6518c108632e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 11:40:53 +0100 Subject: [PATCH 0453/1027] #2586 StimPlan Viz : Mesh lines flickers when interpolating result values --- .../RivWellFracturePartMgr.cpp | 83 +++++++++---------- .../RivWellFracturePartMgr.h | 13 +-- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 175d71c42b..7ff96b3969 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -340,23 +340,18 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc { std::vector nodeCoords; std::vector triangleIndices; - m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords); - std::vector displayCoords; + m_rimFracture->fractureTemplate()->fractureTriangleGeometry(&nodeCoords, &triangleIndices); - for (const auto& nodeCoord : nodeCoords) - { - cvf::Vec3d nodeCoordsDouble = static_cast(nodeCoord); - cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble); - displayCoords.push_back(static_cast(displayCoordsDouble)); - } + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); - if (triangleIndices.empty() || displayCoords.empty()) + if (triangleIndices.empty() || nodeDisplayCoords.empty()) { return nullptr; } - cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, displayCoords); + cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeDisplayCoords); CVF_ASSERT(geo.notNull()); cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_ellipse"); @@ -415,21 +410,17 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa // If this ever changes, the entire code must be revisited std::vector nodeCoords; std::vector triangleIndices; - m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords); + + stimPlanFracTemplate->fractureTriangleGeometry(&nodeCoords, &triangleIndices); if (triangleIndices.empty() || nodeCoords.empty()) { return nullptr; } - // Transforms the node coordinates for display - for (auto& nodeCoord : nodeCoords) - { - cvf::Vec3d doubleCoord(nodeCoord); - doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord); - nodeCoord = cvf::Vec3f(doubleCoord); - } - + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); + RimLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { @@ -441,7 +432,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa { // Construct array with per node result values that correspond to the node coordinates of the triangle mesh // Since some time steps don't have result vales, we initialize the array to well known values before populating it - std::vector perNodeResultValues(nodeCoords.size(), HUGE_VAL); + std::vector perNodeResultValues(nodeDisplayCoords.size(), HUGE_VAL); { size_t idx = 0; const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors()->uiResultName(), activeView.fractureColors()->unit(), stimPlanFracTemplate->activeTimeStepIndex()); @@ -453,8 +444,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa } } } - CVF_ASSERT(perNodeResultValues.size() == nodeCoords.size()); - + CVF_ASSERT(perNodeResultValues.size() == nodeDisplayCoords.size()); std::vector triIndicesToInclude; for (size_t i = 0; i < triangleIndices.size(); i += 6) @@ -483,15 +473,11 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa return nullptr; } - cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeCoords); - cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); - surfacePart->setDrawable(geo.p()); - surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); - surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - + cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper(); CVF_ASSERT(scalarMapper); - cvf::ref textureCoords = new cvf::Vec2fArray(nodeCoords.size()); + + cvf::ref textureCoords = new cvf::Vec2fArray(nodeDisplayCoords.size()); textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); for (size_t i = 0; i < perNodeResultValues.size(); i++) { @@ -503,10 +489,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa } geo->setTextureCoordArray(textureCoords.p()); - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - effGen.disableLighting(activeView.isLightingDisabled()); - cvf::ref eff = effGen.generateCachedEffect(); - surfacePart->setEffect(eff.p()); + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); return surfacePart; } @@ -640,19 +623,11 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar } cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); - cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); - surfacePart->setDrawable(geo.p()); - surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); - surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - geo->setTextureCoordArray(textureCoords.p()); - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - effGen.disableLighting(activeView.isLightingDisabled()); - cvf::ref eff = effGen.generateCachedEffect(); - surfacePart->setEffect(eff.p()); + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); - return surfacePart; + return surfacePart; } else { @@ -928,6 +903,28 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri return stimPlanMeshGeo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createScalarMapperPart(cvf::DrawableGeo* drawableGeo, + const cvf::ScalarMapper* scalarMapper, + RimFracture* fracture, + bool disableLighting) +{ + cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); + surfacePart->setDrawable(drawableGeo); + surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); + surfacePart->setSourceInfo(new RivObjectSourceInfo(fracture)); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + effGen.disableLighting(disableLighting); + + cvf::ref eff = effGen.generateCachedEffect(); + surfacePart->setEffect(eff.p()); + + return surfacePart; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 7fd9ab1a66..3434ed48d7 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -30,10 +30,11 @@ namespace cvf { - class ModelBasicList; - class DrawableGeo; - class Part; - class Color3f; + class ModelBasicList; + class DrawableGeo; + class Part; + class Color3f; + class ScalarMapper; } namespace caf @@ -79,7 +80,9 @@ class RivWellFracturePartMgr : public cvf::Object std::vector fractureBorderPolygon(); - static std::vector transformToFractureDisplayCoords(const std::vector& polygon, + static cvf::ref createScalarMapperPart(cvf::DrawableGeo* drawableGeo, const cvf::ScalarMapper* scalarMapper, RimFracture* fracture, bool disableLighting); + + static std::vector transformToFractureDisplayCoords(const std::vector& polygon, cvf::Mat4d m, const caf::DisplayCoordTransform& displayCoordTransform); From 7a9e53bdb14ae6d4e90f240e1e74d96de9bfdb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 16:12:40 +0100 Subject: [PATCH 0454/1027] #51 Avoid that legend background misses frame line on the right --- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 2 +- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index bade5c7032..c69b5f936a 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -187,7 +187,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, TextDrawer textDrawer(m_font.p()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); - Vec2f backgroundSize(maxLegendRightPos + 3.0f, (float)size.y()); + Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); // Do the actual rendering if (software) diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index b743248087..4c2c4601ba 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -245,8 +245,8 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V float maxLegendRightPos = 0; TextDrawer textDrawer(m_font.p()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); - - Vec2f backgroundSize(maxLegendRightPos + 3.0f, (float)size.y()); + + Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); // Do the actual rendering if (software) From b4935a053435d5d266eebe364d695ff048ec42b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 16:14:13 +0100 Subject: [PATCH 0455/1027] #51 Add background to ternary legend --- .../RivTernarySaturationOverlayItem.cpp | 96 ++++++++++++++----- .../RivTernarySaturationOverlayItem.h | 28 ++++-- 2 files changed, 95 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index b01401826f..34fea69b1f 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -33,6 +33,7 @@ #include "cvfRenderState_FF.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStatePolygonOffset.h" +#include "cafInternalLegendRenderTools.h" @@ -40,13 +41,15 @@ /// //-------------------------------------------------------------------------------------------------- RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) - : m_textColor(cvf::Color3::BLACK), - m_font(font), - m_size(100, 140) + : m_textColor(cvf::Color3::BLACK) + , m_font(font) + , m_size(120, 150) + , m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f) + , m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f) + , m_isBackgroundEnabled(true) { } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -89,7 +92,7 @@ void RivTernarySaturationOverlayItem::setSize(const cvf::Vec2ui& size) //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) { - render(oglContext, position, size, false); + renderGeneric(oglContext, position, size, false); } @@ -98,20 +101,25 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) { - render(oglContext, position, size, true); + renderGeneric(oglContext, position, size, true); } //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software) +void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software) { if (size.x() <= 0 || size.y() <= 0) { return; } + float border = 0.0f; + cvf::Camera camera; camera.setViewport(position.x(), position.y(), size.x(), size.y()); camera.setProjectionAsPixelExact2D(); @@ -119,24 +127,46 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, cvf::Viewport::CLEAR_DEPTH); + if ( m_isBackgroundEnabled ) + { + if ( software ) + { + caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + cvf::Vec2f(size), + m_backgroundColor, + m_backgroundFrameColor); + } + else + { + const cvf::MatrixState matrixState(camera); + + caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + cvf::Vec2f(size), + m_backgroundColor, + m_backgroundFrameColor); + } + border = 3.0f; + } + cvf::TextDrawer textDrawer(m_font.p()); textDrawer.setTextColor(m_textColor); - float lineHeightInPixels = 10; + float lineHeightInPixels = (float)(m_font->textExtent("SWAT").y() + 2); - float textPosY = static_cast(size.y() - 10); + float textPosY = static_cast(size.y() - lineHeightInPixels); for (size_t it = 0; it < m_titleStrings.size(); it++) { - cvf::Vec2f pos(5, textPosY); + cvf::Vec2f pos(border, textPosY); textDrawer.addText(m_titleStrings[it], pos); textPosY -= lineHeightInPixels; } - cvf::Vec2f pos(5, textPosY); + cvf::Vec2f pos(border, textPosY); textDrawer.addText("TERNARY", pos); textPosY -= lineHeightInPixels; - textPosY -= 2; + textPosY -= border; { cvf::uint sgasTextWidth = m_font->textExtent("SGAS").x(); @@ -147,23 +177,23 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); } - textDrawer.addText("SWAT", cvf::Vec2f(0.0, 10.0)); - textDrawer.addText(m_swatRange, cvf::Vec2f(0.0, 0.0)); + textDrawer.addText("SWAT", cvf::Vec2f((float)border, (float)(lineHeightInPixels + border))); + textDrawer.addText(m_swatRange, cvf::Vec2f((float)border, (float)border)); { cvf::uint soilTextWidth = m_font->textExtent("SOIL").x(); - textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth), 10.0)); + textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth - border), lineHeightInPixels + border)); cvf::uint soilRangeTextWidth = m_font->textExtent(m_soilRange).x(); - float soilRangePos = static_cast(size.x()) - soilRangeTextWidth; + float soilRangePos = static_cast(size.x()) - soilRangeTextWidth - border; - textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, 0.0)); + textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border)); } textDrawer.renderSoftware(oglContext, camera); textPosY -= 3; - renderAxisImmediateMode(textPosY, oglContext); + renderAxisImmediateMode(textPosY, 2*lineHeightInPixels + border, border, oglContext); CVF_CHECK_OGL(oglContext); } @@ -173,7 +203,7 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con //-------------------------------------------------------------------------------------------------- /// Draw the axis using immediate mode OpenGL //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::OpenGLContext* oglContext) +void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, float lowerBoundY, float border, cvf::OpenGLContext* oglContext) { #ifdef CVF_OPENGL_ES CVF_UNUSED(layout); @@ -190,11 +220,10 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::Color3ub colB(cvf::Color3::GREEN); cvf::Color3ub colC(cvf::Color3::RED); - float lowerBoundY = 20; //float upperBoundY = static_cast(m_size.y() - 20); - cvf::Vec3f a(0, lowerBoundY, 0); - cvf::Vec3f b(static_cast(m_size.x()), lowerBoundY, 0); + cvf::Vec3f a(float(border), lowerBoundY, 0); + cvf::Vec3f b(static_cast(m_size.x() - border), lowerBoundY, 0); cvf::Vec3f c(static_cast(m_size.x() / 2), upperBoundY, 0); @@ -260,4 +289,27 @@ void RivTernarySaturationOverlayItem::setTitle(const cvf::String& title) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTernarySaturationOverlayItem::enableBackground(bool enable) +{ + m_isBackgroundEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTernarySaturationOverlayItem::setBackgroundColor(const cvf::Color4f& backgroundColor) +{ + m_backgroundColor = backgroundColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTernarySaturationOverlayItem::setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor) +{ + m_backgroundFrameColor = backgroundFrameColor; +} diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index 23a1c29133..138f328c82 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -22,6 +22,7 @@ #include "cvfOverlayItem.h" #include "cvfMatrix4.h" #include "cvfColor3.h" +#include "cvfColor4.h" #include "cvfString.h" namespace cvf { @@ -43,24 +44,37 @@ class RivTernarySaturationOverlayItem : public cvf::OverlayItem void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); - virtual cvf::Vec2ui sizeHint(); - - virtual void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - void setSize(const cvf::Vec2ui& size); void setAxisLabelsColor(const cvf::Color3f& color); void setTitle(const cvf::String& title); + void enableBackground(bool enable); + void setBackgroundColor(const cvf::Color4f& backgroundColor); + void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); private: - void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - void renderAxisImmediateMode(float upperY, cvf::OpenGLContext* oglContext); + cvf::Vec2ui sizeHint() override; + void render(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size) override; + void renderSoftware(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size) override; + + void renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software); + void renderAxisImmediateMode(float upperY, float lowerBoundY, float border, cvf::OpenGLContext* oglContext); private: cvf::Color3f m_textColor; // Text color cvf::ref m_font; + bool m_isBackgroundEnabled; + cvf::Color4f m_backgroundColor; + cvf::Color4f m_backgroundFrameColor; + cvf::String m_soilRange; cvf::String m_sgasRange; cvf::String m_swatRange; From 4d7f753d3c178c78d4b065dc144230dcfd520291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 16:15:45 +0100 Subject: [PATCH 0456/1027] #51 Add preference option to control legend background --- ApplicationCode/Application/RiaPreferences.cpp | 3 +++ ApplicationCode/Application/RiaPreferences.h | 1 + ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 5 +++++ ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index b7ed3af14c..623ef531b3 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -77,6 +77,8 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, "Include Fracture Debug Info for Completion Export", "", "", ""); includeFractureDebugInfoFile.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&showLegendBackground, "showLegendBackground", true, "Enable Legend Background", "", "", ""); + CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.uiCapability()->setUiHidden(true); @@ -153,6 +155,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& defaultSettingsGroup->add(&defaultWellLabelColor); defaultSettingsGroup->add(&fontSizeInScene); defaultSettingsGroup->add(&defaultScaleFactorZ); + defaultSettingsGroup->add(&showLegendBackground); caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D Views"); viewsGroup->add(&navigationPolicy); diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 3fcd582ec6..dbc02b5953 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -63,6 +63,7 @@ class RiaPreferences : public caf::PdmObject caf::PdmField defaultWellLabelColor; caf::PdmField showLasCurveWithoutTvdWarning; caf::PdmField fontSizeInScene; + caf::PdmField showLegendBackground; caf::PdmField useShaders; caf::PdmField showHud; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 971d48e037..fdd5364cb8 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -48,6 +48,7 @@ #include #include "RimIntersectionCollection.h" +#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -369,6 +370,10 @@ void RimLegendConfig::updateLegend() } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_scalarMapperLegend->enableBackground(preferences->showLegendBackground()); + m_categoryLegend->enableBackground(preferences->showLegendBackground()); if (m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) { diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index b507afc267..f79dab9d00 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -35,6 +35,7 @@ #include "cvfqtUtils.h" #include +#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig"); @@ -201,6 +202,10 @@ void RimTernaryLegendConfig::updateLegend() if (!m_legend.isNull()) { m_legend->setRangeText(soilRange, sgasRange, swatRange); + + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_legend->enableBackground(preferences->showLegendBackground()); } } From 3feaa55d02db39701b977e45bd021454b2461744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 8 Mar 2018 13:08:06 +0100 Subject: [PATCH 0457/1027] #2549 2dIntersectionView. Update when modifying SimWellInView --- .../ProjectDataModel/RimSimWellInView.cpp | 56 +++++++++++++++++-- .../ProjectDataModel/RimSimWellInView.h | 2 + 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 997a26e42c..bf2bda91c9 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -35,6 +35,8 @@ #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInViewCollection.h" +#include "RimIntersection.h" +#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" @@ -43,6 +45,13 @@ #include "cafPdmUiTreeOrdering.h" #include "cvfMath.h" + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* corresponding2dIntersectionView(RimSimWellInView *simWellInView); + + CAF_PDM_SOURCE_INIT(RimSimWellInView, "Well"); //-------------------------------------------------------------------------------------------------- @@ -110,6 +119,7 @@ void RimSimWellInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, &wellPipeColor == changedField) { reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } else if (&showWell == changedField || &showWellCells == changedField || @@ -118,15 +128,14 @@ void RimSimWellInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } else if ( &pipeScaleFactor == changedField || &wellHeadScaleFactor == changedField) { - if (reservoirView) - { - reservoirView->scheduleSimWellGeometryRegen(); - reservoirView->scheduleCreateDisplayModelAndRedraw(); - } + reservoirView->scheduleSimWellGeometryRegen(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } } @@ -352,6 +361,18 @@ bool RimSimWellInView::intersectsWellCellsFilteredCells(const RigWellResultFrame return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSimWellInView::schedule2dIntersectionViewUpdate() +{ + Rim2dIntersectionView* intersectionView = corresponding2dIntersectionView(this); + if (intersectionView) + { + intersectionView->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -607,3 +628,28 @@ size_t RimSimWellInView::resultWellIndex() const return m_resultWellIndex; } +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* corresponding2dIntersectionView(RimSimWellInView *simWellInView) +{ + Rim3dView* tdView; + simWellInView->firstAncestorOrThisOfType(tdView); + + std::vector intersectionColls; + if (tdView) + { + tdView->descendantsIncludingThisOfType(intersectionColls); + if (intersectionColls.size() == 1) + { + for (const auto intersection : intersectionColls[0]->intersections()) + { + if (intersection->simulationWell() == simWellInView) + { + return intersection->correspondingIntersectionView(); + } + } + } + } + return nullptr; +} diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index b2a0dc94c8..7026720870 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -103,6 +103,8 @@ class RimSimWellInView : public caf::PdmObject bool intersectsWellCellsFilteredCells(const RigWellResultFrame &wrsf, size_t frameIndex) const; + void schedule2dIntersectionViewUpdate(); + private: cvf::ref m_simWellData; size_t m_resultWellIndex; From 8bd37b341174fb2972056521bf51c1c55014c17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 8 Mar 2018 16:48:21 +0100 Subject: [PATCH 0458/1027] #2549 2dIntersectionView. Update view when modifying branch detection and interpol type --- ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 6 +----- ApplicationCode/ProjectDataModel/RimSimWellInView.h | 5 +++-- .../ProjectDataModel/RimSimWellInViewCollection.cpp | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 6ef80b0521..d5c9cf448a 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -388,11 +388,7 @@ void Rim2dIntersectionView::createDisplayModel() m_viewer->addFrame(new cvf::Scene()); } - - if ( m_flatIntersectionPartMgr.isNull() || m_intersection() != m_flatIntersectionPartMgr->intersection()) - { - m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true); - } + m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true); m_intersectionVizModel->removeAllParts(); diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index 7026720870..79728c2aeb 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -72,6 +72,9 @@ class RimSimWellInView : public caf::PdmObject void wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); + + void schedule2dIntersectionViewUpdate(); + caf::PdmField showWell; caf::PdmField name; @@ -103,8 +106,6 @@ class RimSimWellInView : public caf::PdmObject bool intersectsWellCellsFilteredCells(const RigWellResultFrame &wrsf, size_t frameIndex) const; - void schedule2dIntersectionViewUpdate(); - private: cvf::ref m_simWellData; size_t m_resultWellIndex; diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 1a93f228b0..269c8c59ac 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -415,6 +415,8 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha { m_reservoirView->scheduleSimWellGeometryRegen(); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + + for (RimSimWellInView* w : wells) w->schedule2dIntersectionViewUpdate(); } else if (&showWellsIntersectingVisibleCells == changedField) { From ab8a4f58abdbd100f5554a7bdcc74cf874df8d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 9 Mar 2018 08:37:53 +0100 Subject: [PATCH 0459/1027] Fix Linux build by adding missing include --- Fwk/VizFwk/LibCore/cvfSystem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Fwk/VizFwk/LibCore/cvfSystem.h b/Fwk/VizFwk/LibCore/cvfSystem.h index e705f28108..ca94957050 100644 --- a/Fwk/VizFwk/LibCore/cvfSystem.h +++ b/Fwk/VizFwk/LibCore/cvfSystem.h @@ -36,6 +36,7 @@ #pragma once +#include namespace cvf { From 954364985838411fabd02f0d1dcbfcad7f0261de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 9 Mar 2018 08:47:43 +0100 Subject: [PATCH 0460/1027] Revert "Fix Linux build by adding missing include" This reverts commit ab8a4f58abdbd100f5554a7bdcc74cf874df8d12. --- Fwk/VizFwk/LibCore/cvfSystem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Fwk/VizFwk/LibCore/cvfSystem.h b/Fwk/VizFwk/LibCore/cvfSystem.h index ca94957050..e705f28108 100644 --- a/Fwk/VizFwk/LibCore/cvfSystem.h +++ b/Fwk/VizFwk/LibCore/cvfSystem.h @@ -36,7 +36,6 @@ #pragma once -#include namespace cvf { From 6ae619cc105fe340ff00d2e11eaa15e0884029be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 9 Mar 2018 08:50:16 +0100 Subject: [PATCH 0461/1027] Fix Linux build by adding missing include (II) --- Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h index 1a19614735..586d017282 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h +++ b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h @@ -35,6 +35,7 @@ //################################################################################################## #pragma once +#include "cvfBase.h" #include "cvfOpenGLContext.h" #include "cvfMatrixState.h" #include "cvfColor4.h" From 7c554b8ff8d5f45734fe8395bf1ca40ed8f27740 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 20:28:05 +0100 Subject: [PATCH 0462/1027] Fracture : Fix typo when creating fracture cells for ellipse fracture --- .../ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index a14d91f133..294dd0c4cc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -179,7 +179,7 @@ void RimEllipseFractureTemplate::setupFractureGridCells() for (int i = 0; i < numberOfCellsX; i++) { - for (int j = 0; j < numberOfCellsX; j++) + for (int j = 0; j < numberOfCellsY; j++) { double X1 = - halfLength + i * cellSizeX; double X2 = - halfLength + (i+1) * cellSizeX; From 12b7ddf90ba7997739c103d6d4f5bba6c3df3249 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 20:35:04 +0100 Subject: [PATCH 0463/1027] Ellipse Fracture : Rename to assignConductivityToCellsInsideEllipse --- .../Completions/RimEllipseFractureTemplate.cpp | 10 +++++----- .../Completions/RimEllipseFractureTemplate.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 294dd0c4cc..192c9ee9ea 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -59,7 +59,7 @@ RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) CAF_PDM_InitField(&m_userDefinedEffectivePermeability,"Permeability", 0.0, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); } //-------------------------------------------------------------------------------------------------- @@ -74,7 +74,7 @@ RimEllipseFractureTemplate::~RimEllipseFractureTemplate() //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::loadDataAndUpdate() { - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (activeView) activeView->loadDataAndUpdate(); @@ -101,7 +101,7 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha if (changedField == &m_width || changedField == &m_userDefinedEffectivePermeability) { - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); } } @@ -159,7 +159,7 @@ void RimEllipseFractureTemplate::changeUnits() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEllipseFractureTemplate::setupFractureGridCells() +void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() { std::vector fractureCells; std::pair wellCenterFractureCellIJ = std::make_pair(0, 0); @@ -329,7 +329,7 @@ void RimEllipseFractureTemplate::reload() { //Regenerate geometry proj->createDisplayModelAndRedrawAllViews(); - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 85ec958522..e50683d101 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -71,7 +71,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: - void setupFractureGridCells(); + void assignConductivityToCellsInsideEllipse(); FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; From 64845d796cb576633878aca4af058281f6e52651 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 20:35:47 +0100 Subject: [PATCH 0464/1027] Fracture : Move code to cpp --- .../ReservoirDataModel/RigFractureCell.cpp | 79 ++++++++++++++---- .../ReservoirDataModel/RigFractureCell.h | 13 ++- .../ReservoirDataModel/RigFractureGrid.cpp | 83 ++++++++++++++++--- .../ReservoirDataModel/RigFractureGrid.h | 26 +++--- 4 files changed, 153 insertions(+), 48 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp b/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp index 666c581ac2..9da6e3faa5 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 - Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -22,35 +22,80 @@ #include - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigFractureCell::RigFractureCell(std::vector polygon, size_t i, size_t j) + : m_polygon(polygon) + , m_i(i) + , m_j(j) + , m_concutivityValue(0.0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFractureCell::getPolygon() const +{ + return m_polygon; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigFractureCell::getConductivtyValue() const +{ + return m_concutivityValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureCell::getI() const +{ + return m_i; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureCell::getJ() const +{ + return m_j; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFractureCell::hasNonZeroConductivity() const { - m_polygon = polygon; - m_i = i; - m_j = j; - m_concutivityValue = 0.0; + return m_concutivityValue > 1e-7; } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureCell::setConductivityValue(double cond) +{ + m_concutivityValue = cond; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- double RigFractureCell::cellSizeX() const { - //The polygon corners are always stored in the same order - if (m_polygon.size()>1) return (m_polygon[1] - m_polygon[0]).length(); + // The polygon corners are always stored in the same order + if (m_polygon.size() > 1) return (m_polygon[1] - m_polygon[0]).length(); return cvf::UNDEFINED_DOUBLE; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigFractureCell::cellSizeZ() const { - if (m_polygon.size()>2) return (m_polygon[2] - m_polygon[1]).length(); + if (m_polygon.size() > 2) return (m_polygon[2] - m_polygon[1]).length(); return cvf::UNDEFINED_DOUBLE; } - - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureCell.h b/ApplicationCode/ReservoirDataModel/RigFractureCell.h index 76ff63aa69..fc1a4d9907 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureCell.h +++ b/ApplicationCode/ReservoirDataModel/RigFractureCell.h @@ -33,13 +33,13 @@ class RigFractureCell public: RigFractureCell(std::vector polygon, size_t i, size_t j); - const std::vector& getPolygon() const { return m_polygon; } - double getConductivtyValue() const { return m_concutivityValue; } - size_t getI() const { return m_i; } - size_t getJ() const { return m_j; } + const std::vector& getPolygon() const; + double getConductivtyValue() const; + size_t getI() const; + size_t getJ() const; - bool hasNonZeroConductivity() const { return m_concutivityValue > 1e-7; } - void setConductivityValue(double cond) { m_concutivityValue = cond; } + bool hasNonZeroConductivity() const; + void setConductivityValue(double cond); double cellSizeX() const; double cellSizeZ() const; @@ -50,4 +50,3 @@ class RigFractureCell size_t m_i; size_t m_j; }; - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp b/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp index 07b5c86a5c..9ea5ba4d75 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp @@ -1,37 +1,78 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 - Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigFractureGrid.h" + #include "RiaLogging.h" + #include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigFractureGrid::RigFractureGrid() - : m_iCellCount(0), - m_jCellCount(0) + : m_iCellCount(0) + , m_jCellCount(0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setFractureCells(std::vector fractureCells) +{ + m_fractureCells = fractureCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ) +{ + m_wellCenterFractureCellIJ = wellCenterFractureCellIJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setICellCount(size_t iCellCount) +{ + m_iCellCount = iCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setJCellCount(size_t jCellCount) { + m_jCellCount = jCellCount; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFractureGrid::fractureCells() const +{ + return m_fractureCells; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const { @@ -39,7 +80,7 @@ size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const { @@ -50,7 +91,7 @@ const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const } else { - //TODO: Better error handling? + // TODO: Better error handling? RiaLogging::error(QString("Requesting non-existent StimPlanCell")); RiaLogging::error(QString("Returning cell 0, results will be invalid")); const RigFractureCell& cell = m_fractureCells[0]; @@ -58,4 +99,26 @@ const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureGrid::jCellCount() const +{ + return m_jCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureGrid::iCellCount() const +{ + return m_iCellCount; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RigFractureGrid::fractureCellAtWellCenter() const +{ + return m_wellCenterFractureCellIJ; +} diff --git a/ApplicationCode/ReservoirDataModel/RigFractureGrid.h b/ApplicationCode/ReservoirDataModel/RigFractureGrid.h index 430b48f5a2..c4e9a89784 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigFractureGrid.h @@ -31,28 +31,26 @@ class RigFractureCell; /// //================================================================================================== class RigFractureGrid : public cvf::Object - { public: RigFractureGrid(); - void setFractureCells(std::vector fractureCells) { m_fractureCells = fractureCells; } - void setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ) { m_wellCenterFractureCellIJ = wellCenterFractureCellIJ; } - void setICellCount(size_t iCellCount) { m_iCellCount = iCellCount; } - void setJCellCount(size_t jCellCount) { m_jCellCount = jCellCount; } + void setFractureCells(std::vector fractureCells); + void setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ); + void setICellCount(size_t iCellCount); + void setJCellCount(size_t jCellCount); - const std::vector& fractureCells() const { return m_fractureCells; } + const std::vector& fractureCells() const; size_t getGlobalIndexFromIJ(size_t i, size_t j) const; const RigFractureCell& cellFromIndex(size_t index) const; - size_t jCellCount() const { return m_jCellCount; } - size_t iCellCount() const { return m_iCellCount; } + size_t jCellCount() const; + size_t iCellCount() const; - std::pair fractureCellAtWellCenter() const { return m_wellCenterFractureCellIJ; } + std::pair fractureCellAtWellCenter() const; private: - std::vector m_fractureCells; - std::pair m_wellCenterFractureCellIJ; - size_t m_iCellCount; - size_t m_jCellCount; + std::vector m_fractureCells; + std::pair m_wellCenterFractureCellIJ; + size_t m_iCellCount; + size_t m_jCellCount; }; - From 9de2f1ae5238e63e522b4d41386fa27d42c73919 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 8 Mar 2018 21:08:41 +0100 Subject: [PATCH 0465/1027] Ellipse Fracture : Always set well intersection to center of ellipse --- .../RimEllipseFractureTemplate.cpp | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 192c9ee9ea..d8868d7acc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -162,24 +162,23 @@ void RimEllipseFractureTemplate::changeUnits() void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() { std::vector fractureCells; - std::pair wellCenterFractureCellIJ = std::make_pair(0, 0); - int numberOfCellsX = 35; - int numberOfCellsY = 35; + int numberOfCellsI = 35; + int numberOfCellsJ = 35; double height = m_height * m_heightScaleFactor; double halfLength = m_halfLength * m_widthScaleFactor; - double cellSizeX = (halfLength * 2) / numberOfCellsX * m_widthScaleFactor; - double cellSizeZ = height / numberOfCellsY * m_heightScaleFactor; + double cellSizeX = (halfLength * 2) / numberOfCellsI * m_widthScaleFactor; + double cellSizeZ = height / numberOfCellsJ * m_heightScaleFactor; double cellArea = cellSizeX * cellSizeZ; double areaTresholdForIncludingCell = 0.5 * cellArea; - for (int i = 0; i < numberOfCellsX; i++) + for (int i = 0; i < numberOfCellsI; i++) { - for (int j = 0; j < numberOfCellsY; j++) + for (int j = 0; j < numberOfCellsJ; j++) { double X1 = - halfLength + i * cellSizeX; double X2 = - halfLength + (i+1) * cellSizeX; @@ -211,24 +210,18 @@ void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() RigFractureCell fractureCell(cellPolygon, i, j); fractureCell.setConductivityValue(cond); - if (cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0) - { - if (cellPolygon[1].y() < 0.0 && cellPolygon[2].y() > 0.0) - { - wellCenterFractureCellIJ = std::make_pair(fractureCell.getI(), fractureCell.getJ()); - RiaLogging::debug(QString("Setting wellCenterFractureCell at cell %1, %2"). - arg(QString::number(fractureCell.getI()), QString::number(fractureCell.getJ()))); - } - } - fractureCells.push_back(fractureCell); } } m_fractureGrid->setFractureCells(fractureCells); + + // Set well intersection to center of ellipse + std::pair wellCenterFractureCellIJ = std::make_pair(numberOfCellsI / 2, numberOfCellsJ / 2); m_fractureGrid->setWellCenterFractureCellIJ(wellCenterFractureCellIJ); - m_fractureGrid->setICellCount(numberOfCellsX); - m_fractureGrid->setJCellCount(numberOfCellsY); + + m_fractureGrid->setICellCount(numberOfCellsI); + m_fractureGrid->setJCellCount(numberOfCellsJ); } //-------------------------------------------------------------------------------------------------- From 7221efa7b5410f63f9c6e77aa3ccd4845c7c208c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Mar 2018 08:14:09 +0100 Subject: [PATCH 0466/1027] #2554 Fracture : Do not exit if debug output file is not possible to open --- ...ellPathExportCompletionDataFeatureImpl.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 08249c07c0..895d7d1f67 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -121,27 +121,31 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve // FractureTransmissibilityExportInformation std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; - - QString fractureTransmisibillityExportInformationPath = - QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); - QFile fractureTransmissibilityExportInformationFile(fractureTransmisibillityExportInformationPath); + QFile fractureTransmissibilityExportInformationFile; RiaPreferences* prefs = RiaApplication::instance()->preferences(); if (prefs->includeFractureDebugInfoFile()) { + QDir outputDir = QDir(exportSettings.folder); + outputDir.mkpath("."); + + QString fractureTransmisibillityExportInformationPath = + QDir(exportSettings.folder).absoluteFilePath("FractureTransmissibilityExportInformation"); + + fractureTransmissibilityExportInformationFile.setFileName(fractureTransmisibillityExportInformationPath); if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) { RiaLogging::error(QString("Export Completions Data: Could not open the file: %1") .arg(fractureTransmisibillityExportInformationPath)); - return; } - - fractureTransmissibilityExportInformationStream = - std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); + else + { + fractureTransmissibilityExportInformationStream = + std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); + } } - size_t maxProgress = usedWellPaths.size() * 3 + - simWells.size() + + size_t maxProgress = usedWellPaths.size() * 3 + simWells.size() + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE From 4c19be91ac3456e27b9c3ba9a234292a96176c87 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Mar 2018 08:32:04 +0100 Subject: [PATCH 0467/1027] #2554 Regression Test : Ignore line endings when using diff tool --- ApplicationCode/Application/Tools/RiaTextFileCompare.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp index 9120380a9d..ebb77c5874 100644 --- a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp @@ -60,8 +60,9 @@ bool RiaTextFileCompare::runComparison(const QString& baseFolder, const QString& fullFilePath = m_pathToDiffTool + "/" + fullFilePath; } - // Run compare recursively with '-r' - QString args = "-r -u"; + // Command line arguments used when invoking 'diff' + // See https://docs.freebsd.org/info/diff/diff.info.diff_Options.html + QString args = "-r -u --strip-trailing-cr"; QString completeCommand = QString("\"%1\" %2 %3 %4").arg(fullFilePath).arg(baseFolder).arg(generatedFolder).arg(args); From 9a7ca2d2a98c08fa4a4dafc5ca36c4bafa6067fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Mar 2018 09:40:10 +0100 Subject: [PATCH 0468/1027] #2557 Non Darcy Flow : Fix inverted unit conversion --- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index ce66a1ae5a..c9e1b9329a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -622,13 +622,13 @@ double RimFractureTemplate::kh() const //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) { - if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) { m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); m_fractureWidth = RiaEclipseUnitTools::feetToMeter(m_fractureWidth); } - else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + else if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) { m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); From a38d3735c5b4343840b6f73bd589da6195a4419a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 9 Mar 2018 09:47:56 +0100 Subject: [PATCH 0469/1027] #2557 Non Darcy Flow : Select copy at the end to avoid update of editor too early --- .../RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp index 10c049fd30..b5ab0b6c05 100644 --- a/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp @@ -71,9 +71,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool fractureTemplateCollection->addFractureTemplate(copyOfTemplate); - RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); - - auto currentUnit = copyOfTemplate->fractureTemplateUnit(); + auto currentUnit = copyOfTemplate->fractureTemplateUnit(); if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) { copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); @@ -89,6 +87,8 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool copyOfTemplate->loadDataAndUpdate(); copyOfTemplate->updateConnectedEditors(); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); } //-------------------------------------------------------------------------------------------------- From ac5466f83d2f6d3c32ec287bd0d790437c96d483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Mar 2018 10:14:03 +0100 Subject: [PATCH 0470/1027] #2578 Fix missing scale in display coord transformation for 2D IntersectionView --- ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index d5c9cf448a..433e5f0313 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -293,7 +293,9 @@ void Rim2dIntersectionView::update3dInfo() //-------------------------------------------------------------------------------------------------- cvf::ref Rim2dIntersectionView::displayCoordTransform() const { - return new caf::DisplayCoordTransform(); + cvf::ref dispTx = new caf::DisplayCoordTransform(); + dispTx->setScale(cvf::Vec3d(1.0, 1.0, scaleZ())); + return dispTx; } //-------------------------------------------------------------------------------------------------- From 16551c05c464789f701470cf129b84a3b08221ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 9 Mar 2018 10:22:27 +0100 Subject: [PATCH 0471/1027] #2486 2d intersection view. Temporary fix to avoid crash --- .../Intersections/RivIntersectionPartMgr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 5404b62d0a..40cc3a2384 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -43,6 +43,7 @@ #include "RivHexGridIntersectionTools.h" #include "RivIntersectionGeometryGenerator.h" +#include "RivObjectSourceInfo.h" #include "RivIntersectionSourceInfo.h" #include "RivPartPriority.h" #include "RivPipeGeometryGenerator.h" @@ -812,7 +813,7 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod pipeCrossSectionVxCount = wellPathColl->wellPathCrossSectionVertexCount(); wellPipeColor = wellPath->wellPathColor(); - createSourceInfoFunc = [&](size_t brIdx) { return new RivWellPathSourceInfo(wellPath, m_rimCrossSection->correspondingIntersectionView()); }; + createSourceInfoFunc = [&](size_t brIdx) { return new RivObjectSourceInfo(wellPath); }; //Temporary fix to avoid crash } // Create pipe geometry From 06504b6fef5891cca359ea78f0a8d5f0280293b3 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Mar 2018 13:15:01 +0100 Subject: [PATCH 0472/1027] #2585 3D well log curves: Create visualization for a curve, random offsetted from a well path --- .../ModelVisualization/CMakeLists_files.cmake | 4 + .../Riv3dWellLogCurveGeomertyGenerator.cpp | 41 +++++++++ .../Riv3dWellLogCurveGeomertyGenerator.h | 39 ++++++++ .../Riv3dWellLogPlanePartMgr.cpp | 90 +++++++++++++++++++ .../Riv3dWellLogPlanePartMgr.h | 52 +++++++++++ .../ModelVisualization/RivWellPathPartMgr.cpp | 8 +- .../ModelVisualization/RivWellPathPartMgr.h | 3 + .../Rim3dWellLogCurveCollection.cpp | 14 +++ .../Completions/Rim3dWellLogCurveCollection.h | 2 + .../ProjectDataModel/RimWellPath.cpp | 8 ++ .../ProjectDataModel/RimWellPath.h | 4 +- 11 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index c2c1d16094..5a4a9719e4 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -37,6 +37,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -72,6 +74,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp new file mode 100644 index 0000000000..8e3430071d --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogCurveGeomertyGenerator.h" + +#include "cvfDrawableGeo.h" +#include "cvfPrimitiveSetIndexedUInt.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogCurveGeometryGenerator::createDrawable(const std::vector& vertices, const std::vector& indices) const +{ + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref drawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + drawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + drawable->setVertexArray(vertexArray.p()); + + return drawable; +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h new file mode 100644 index 0000000000..2e6f67d375 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfObject.h" +#include "cvfBase.h" +#include "cvfDrawableGeo.h" +#include "cvfVector3.h" + +#include + +namespace caf +{ + class DisplayCoordTransform; +} + +class Riv3dWellLogCurveGeometryGenerator : public cvf::Object +{ +public: + Riv3dWellLogCurveGeometryGenerator() = default; + + cvf::ref createDrawable(const std::vector& vertices, const std::vector& indices ) const; +}; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp new file mode 100644 index 0000000000..5b600f834d --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogPlanePartMgr.h" + +#include "RigWellPath.h" + +#include "Riv3dWellLogCurveGeomertyGenerator.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" + +#include "cvfModelBasicList.h" +#include "cvfPart.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry) + :m_wellPathGeometry(wellPathGeometry) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + std::vector* rim3dWellLogCurves) +{ + if (rim3dWellLogCurves->empty()) return; + + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator; + + std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + + std::vector vertices; + vertices.resize(wellPathPoints.size()); + + cvf::Mat4d transMat; + transMat.setTranslation(cvf::Vec3d(0, 0, 10)); + + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + wellPathPoints[i].transformPoint(transMat); + vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i])); + } + + std::vector indices; + indices.resize((vertices.size() - 1) * 2); + + cvf::uint counter = 0; + for (size_t i = 0; i < indices.size(); i++) + { + indices[i] = counter; + if (i % 2 == 0) counter++; + } + + for (Rim3dWellLogCurve* rim3dWellLogCurve : *rim3dWellLogCurves) + { + cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); + + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); + cvf::ref effect = surfaceGen.generateCachedEffect(); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + part->setEffect(effect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + } + } +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h new file mode 100644 index 0000000000..f398fe3c3b --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfObject.h" +#include "cafPdmPointer.h" + +#include "Rim3dWellLogCurve.h" + +namespace cvf +{ + class ModelBasicList; + class Part; +} + +namespace caf +{ + class DisplayCoordTransform; +} + +class Riv3dWellLogCurveGeometryGenerator; +class RigWellPath; + +class Riv3dWellLogPlanePartMgr : public cvf::Object +{ +public: + Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry); + + void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + std::vector* rim3dWellLogCurves); + +private: + cvf::ref m_3dWellLogCurveGeometryGenerator; + cvf::ref m_wellPathGeometry; +}; \ No newline at end of file diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 05a1cabc68..ba8576b5a3 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -40,15 +40,14 @@ #include "RimWellPathFractureCollection.h" #include "RimWellPathFracture.h" +#include "Riv3dWellLogPlanePartMgr.h" #include "RivFishbonesSubsPartMgr.h" #include "RivObjectSourceInfo.h" #include "RivPartPriority.h" #include "RivPipeGeometryGenerator.h" -#include "RivWellPathSourceInfo.h" - -#include "RivPartPriority.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathPartMgr.h" +#include "RivWellPathSourceInfo.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -418,6 +417,9 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* return; appendPerforationsToModel(timeStamp, model, displayCoordTransform, characteristicCellSize); + + m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); + m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, &m_rimWellPath->vectorOf3dWellLogCurves()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index f7c90e5000..b39d4c3a19 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -45,6 +45,7 @@ class RimWellPath; class RivFishbonesSubsPartMgr; class RimWellPathCollection; class Rim3dView; +class Riv3dWellLogPlanePartMgr; class QDateTime; @@ -105,4 +106,6 @@ class RivWellPathPartMgr : public cvf::Object cvf::ref m_centerLinePart; cvf::ref m_centerLineDrawable; cvf::ref m_wellLabelPart; + + cvf::ref m_3dWellLogCurvePartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index c7a87d9a35..c1fe487270 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -63,6 +63,20 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim3dWellLogCurveCollection::vectorOf3dWellLogCurves() const +{ + std::vector curves; + for (auto& wellLogCurve : m_3dWellLogCurves) + { + curves.push_back(wellLogCurve); + } + + return curves; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 1b4830395e..9e778436d5 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -39,6 +39,8 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); + std::vector vectorOf3dWellLogCurves() const; + private: virtual caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 7970fd576a..e594785262 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -809,6 +809,14 @@ void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) m_3dWellLogCurves->add3dWellLogCurve(rim3dWellLogCurve); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPath::vectorOf3dWellLogCurves() const +{ + return m_3dWellLogCurves->vectorOf3dWellLogCurves(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 47e29cf4f8..4964f99030 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -22,6 +22,8 @@ #include "RiaEclipseUnitTools.h" +#include "Rim3dWellLogCurve.h" + #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" @@ -51,7 +53,6 @@ class RigWellPathFormations; class RimWellPathFractureCollection; class Rim3dWellLogCurveCollection; -class Rim3dWellLogCurve; //================================================================================================== /// @@ -79,6 +80,7 @@ class RimWellPath : public caf::PdmObject const RigWellPathFormations* formationsGeometry() const; void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve); + std::vector vectorOf3dWellLogCurves() const; virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; From d72d5ba343ff02f0069e44d3921ec12511523d0e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Mar 2018 13:56:05 +0100 Subject: [PATCH 0473/1027] #2585 Fix linux build (move cvfBase to top) --- .../ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp | 1 - .../ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h | 4 +++- ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 8e3430071d..d4bd45633e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,7 +18,6 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" -#include "cvfDrawableGeo.h" #include "cvfPrimitiveSetIndexedUInt.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 2e6f67d375..aaf6c6b838 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -18,11 +18,13 @@ #pragma once -#include "cvfObject.h" #include "cvfBase.h" +#include "cvfObject.h" #include "cvfDrawableGeo.h" #include "cvfVector3.h" +#include "cafPdmPointer.h" + #include namespace caf diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index f398fe3c3b..c0d64f24e2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -18,8 +18,8 @@ #pragma once +#include "cvfBase.h" #include "cvfObject.h" -#include "cafPdmPointer.h" #include "Rim3dWellLogCurve.h" From 62a2ddfe824946702a19969fdb5359de02691214 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Mar 2018 14:00:41 +0100 Subject: [PATCH 0474/1027] #2585 Fix linux build --- .../ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 8 +++++--- .../ModelVisualization/Riv3dWellLogPlanePartMgr.h | 2 +- ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 5b600f834d..03da723504 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -41,9 +41,9 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry //-------------------------------------------------------------------------------------------------- void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, - std::vector* rim3dWellLogCurves) + std::vector rim3dWellLogCurves) { - if (rim3dWellLogCurves->empty()) return; + if (rim3dWellLogCurves.empty()) return; m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator; @@ -71,8 +71,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (i % 2 == 0) counter++; } - for (Rim3dWellLogCurve* rim3dWellLogCurve : *rim3dWellLogCurves) + + for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { + std::vector vertices = createCurveVertices(rim3dWellLogCurve); cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index c0d64f24e2..b3db1054bb 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -44,7 +44,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, - std::vector* rim3dWellLogCurves); + std::vector rim3dWellLogCurves); private: cvf::ref m_3dWellLogCurveGeometryGenerator; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index ba8576b5a3..dc358782e0 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -419,7 +419,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* appendPerforationsToModel(timeStamp, model, displayCoordTransform, characteristicCellSize); m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); - m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, &m_rimWellPath->vectorOf3dWellLogCurves()); + m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); } //-------------------------------------------------------------------------------------------------- From 540c4e57c91b04941dd4f69abc7e9a52176bcb6d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Mar 2018 14:09:54 +0100 Subject: [PATCH 0475/1027] #2585 Fix build??? --- ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 03da723504..8bd67f605e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -74,7 +74,6 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { - std::vector vertices = createCurveVertices(rim3dWellLogCurve); cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); From c63aee779df50c3ce3f14bf124da84818263bbd0 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 9 Mar 2018 15:42:23 +0100 Subject: [PATCH 0476/1027] #2585 3d Well Log Curves: Draw line along well path --- .../Riv3dWellLogPlanePartMgr.cpp | 95 ++++++++++++++----- .../Riv3dWellLogPlanePartMgr.h | 9 ++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 8 ++ .../ProjectDataModel/Rim3dWellLogCurve.h | 2 + 4 files changed, 91 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 8bd67f605e..ca31bd4d8e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -47,22 +47,87 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator; + std::vector indices = createPolylineIndices(m_wellPathGeometry->m_wellPathPoints.size()); + + for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) + { + std::vector vertices = createCurveVertices(rim3dWellLogCurve, displayCoordTransform); + cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); + + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); + cvf::ref effect = surfaceGen.generateCachedEffect(); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + part->setEffect(effect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogPlanePartMgr::createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform) +{ std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; std::vector vertices; vertices.resize(wellPathPoints.size()); - cvf::Mat4d transMat; - transMat.setTranslation(cvf::Vec3d(0, 0, 10)); + std::vector curveNormals; + curveNormals.reserve(wellPathPoints.size()); + + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + { + cvf::Vec3d wellPathSegment = wellPathPoints[i + 1] - wellPathPoints[i]; + + cvf::Vec3d normVec; + if (rim3dWellLogCurve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_LEFT) + { + normVec = -wellPathSegment.perpendicularVector(); + } + else + { + normVec = wellPathSegment.perpendicularVector(); + } + curveNormals.push_back((wellPathSegment ^ normVec).getNormalized()*30); + } + + cvf::Vec3d wellPathSegment = wellPathPoints[wellPathPoints.size()-1] - wellPathPoints[wellPathPoints.size() - 2]; + cvf::Vec3d normVec = wellPathSegment.perpendicularVector(); + curveNormals.push_back((wellPathSegment ^ normVec).getNormalized() * 30); - for (size_t i = 0; i < wellPathPoints.size(); i++) + for (size_t i = 0; i < curveNormals.size(); i++) { - wellPathPoints[i].transformPoint(transMat); - vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i])); + cvf::Mat4d transMat; + transMat.setTranslation(curveNormals[i]); + + vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); } +// cvf::Mat4d transMat; +// transMat.setTranslation(cvf::Vec3d(0, 0, 10)); +// +// for (size_t i = 0; i < wellPathPoints.size(); i++) +// { +// vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); +// } + + return vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogPlanePartMgr::createPolylineIndices(size_t vertexCount) +{ std::vector indices; - indices.resize((vertices.size() - 1) * 2); + indices.resize((vertexCount - 1) * 2); cvf::uint counter = 0; for (size_t i = 0; i < indices.size(); i++) @@ -71,21 +136,5 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (i % 2 == 0) counter++; } - - for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) - { - cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); - - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); - cvf::ref effect = surfaceGen.generateCachedEffect(); - - cvf::ref part = new cvf::Part; - part->setDrawable(drawable.p()); - part->setEffect(effect.p()); - - if (part.notNull()) - { - model->addPart(part.p()); - } - } + return indices; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index b3db1054bb..aff90e8f36 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -20,9 +20,14 @@ #include "cvfBase.h" #include "cvfObject.h" +#include "cvfVector3.h" #include "Rim3dWellLogCurve.h" +#include "cafPdmPointer.h" + +#include + namespace cvf { class ModelBasicList; @@ -45,6 +50,10 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, std::vector rim3dWellLogCurves); +private: + std::vector createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform); + std::vector createPolylineIndices(size_t vertexCount); private: cvf::ref m_3dWellLogCurveGeometryGenerator; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 1b964f0fbf..403416b007 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -140,6 +140,14 @@ void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const +{ + return m_drawPlane(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 8e6e66b005..60d1779533 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -66,6 +66,8 @@ class Rim3dWellLogCurve : public caf::PdmObject void setPropertiesFromView(Rim3dView* view); + DrawPlane drawPlane() const; + private: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From ec5a9e1682ed7efbd4aae469e537a2ef969e21ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Mar 2018 18:01:13 +0100 Subject: [PATCH 0477/1027] #2552 Generalized the flatting transforms to be able to reuse for simwells and wellpaths --- .../RivIntersectionGeometryGenerator.cpp | 176 ++++-------------- .../RivIntersectionGeometryGenerator.h | 2 +- .../Intersections/RivIntersectionPartMgr.cpp | 4 +- .../Intersections/RivIntersectionPartMgr.h | 2 +- .../Intersections/RivSectionFlattner.h | 148 +++++++++++++++ 5 files changed, 184 insertions(+), 148 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index d134b593f1..85bc42b96a 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -36,7 +36,8 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapper.h" #include "cvfRay.h" -//#include "cvfTrace.h" + +#include "RivSectionFlattner.h" //-------------------------------------------------------------------------------------------------- @@ -69,127 +70,42 @@ RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator() } -//-------------------------------------------------------------------------------------------------- -/// Origo in the intersection of the ray P1-ExtrDir with the XY plane -/// Ez in upwards extrusionDir -/// Ey normal tio the section pplane -/// Ex in plane along p1-p2 -//-------------------------------------------------------------------------------------------------- -cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir) -{ - using namespace cvf; - - Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; - - Vec3d sectionLineDir = p2 - p1; - sectionLineDir.normalize(); - - Vec3d Ey = Ez ^ sectionLineDir; - Ey.normalize(); - Vec3d Ex = Ey ^ Ez; - Ex.normalize(); - - Ray extrusionRay; - extrusionRay.setOrigin(p1); - - if (p1.z() > 0) extrusionRay.setDirection(-Ez); - else extrusionRay.setDirection(Ez); - - - Vec3d tr(Vec3d::ZERO); - extrusionRay.planeIntersect(Plane(0.0, 0.0 , 1.0, 0.0), &tr); - - return Mat4d(Ex[0], Ey[0], Ez[0], tr[0], - Ex[1], Ey[1], Ez[1], tr[1], - Ex[2], Ey[2], Ez[2], tr[2], - 0.0, 0.0, 0.0, 1.0); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() { - cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); - cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation(-displayOffset); - - m_segementTransformPrLinePoint.clear(); - - double previousSectionFlattenedEndPosX = m_horizontalLengthAlongWellToPolylineStart; - cvf::Vec3d previousSectionOrigo(cvf::Vec3d::ZERO); - - - for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) + if ( m_isFlattened ) { - m_segementTransformPrLinePoint.emplace_back(); - const std::vector& polyLine = m_polyLines[pLineIdx]; + if ( !(m_polyLines.size() && m_polyLines.back().size()) ) return; - size_t pointCount = polyLine.size(); + cvf::Vec3d startOffset ={ m_horizontalLengthAlongWellToPolylineStart, 0.0, m_polyLines[0][0].z() }; - size_t lIdx = 0; - while ( lIdx < pointCount ) + for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) { - size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); - if (idxToNextP == size_t(-1)) - { - size_t inc = 0; - while ((lIdx + inc) < pointCount) - { - m_segementTransformPrLinePoint.back().push_back(invSectionCS); - ++inc; - } - break; - } - - if (m_isFlattened) - { - cvf::Vec3d p1 = polyLine[lIdx]; - cvf::Vec3d p2 = polyLine[idxToNextP]; - - cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, m_extrusionDirection); - - if ( pLineIdx == 0 && lIdx == 0 ) previousSectionOrigo = sectionLocalCS.translation(); - - previousSectionFlattenedEndPosX += (sectionLocalCS.translation() - previousSectionOrigo).length(); - previousSectionOrigo = sectionLocalCS.translation(); - - invSectionCS = sectionLocalCS.getInverted(); - cvf::Vec3d flattenedTranslation(previousSectionFlattenedEndPosX, 0.0, 0.0); + const std::vector& polyLine = m_polyLines[pLineIdx]; + m_segementTransformPrLinePoint.emplace_back(RivSectionFlattner::calculateFlatteningCSsForPolyline(polyLine, + m_extrusionDirection, + startOffset, + &startOffset)); + } + } + else + { + m_segementTransformPrLinePoint.clear(); - invSectionCS.setTranslation(invSectionCS.translation() + flattenedTranslation ); - } + cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation(-m_hexGrid->displayOffset()); - size_t inc = 0; - while ((lIdx + inc) < idxToNextP) + for ( const auto & polyLine : m_polyLines ) + { + m_segementTransformPrLinePoint.emplace_back(); + std::vector& segmentTransforms = m_segementTransformPrLinePoint.back(); + for ( size_t lIdx = 0; lIdx < polyLine.size(); ++lIdx ) { - m_segementTransformPrLinePoint.back().push_back(invSectionCS); - inc++; + segmentTransforms.push_back(invSectionCS); } - - lIdx = idxToNextP; } } - - // for (auto mx: m_segementTransformPrLinePoint[0]) - // { - // cvf::String text; - // - // for (int r = 0; r < 4; ++r) - // { - // for (int c = 0; c < 4; ++c) - // { - // text += cvf::String::number(mx(r, c)); - // - // if (r * c < 9) - // { - // text += " "; - // } - // } - // text += "\n"; - // } - // - // cvf::Trace::show( text ); - // } } //-------------------------------------------------------------------------------------------------- @@ -239,7 +155,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() size_t lIdx = 0; while ( lIdx < lineCount - 1) { - size_t idxToNextP = indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); + size_t idxToNextP = RivSectionFlattner::indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); if (idxToNextP == size_t(-1)) break; @@ -569,34 +485,6 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol } -//-------------------------------------------------------------------------------------------------- -/// Find the next point in the polyline that avoids making the line nearly parallel to the extrusion direction -/// Returns size_t(-1) if no point is found -//-------------------------------------------------------------------------------------------------- -size_t RivIntersectionGeometryGenerator::indexToNextValidPoint(const std::vector& polyLine, - const cvf::Vec3d extrDir, - size_t idxToStartOfLineSegment) -{ - size_t lineCount = polyLine.size(); - if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; - - - cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; - - for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) - { - cvf::Vec3d p2 = polyLine[lIdx]; - cvf::Vec3d p1p2 = p2 - p1; - - if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) - { - return lIdx; - } - } - - return -1; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -635,23 +523,23 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) { cvf::Vec3d startPt = cvf::Vec3d::ZERO; int polyLineIdx = -1; int segIdx = -1; - for (size_t i = 0; i < m_flattenedOrOffsettedPolyLines.size(); i++) + for (size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++) { - std::vector pts = m_flattenedOrOffsettedPolyLines[i]; - for(size_t j = 0; j < pts.size(); j++) + std::vector polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx]; + for(size_t pIdx = 0; pIdx < polyLine.size(); pIdx++) { // Assumes ascending sorted list - if (j > 0 && intersectionPointUtm.x() < pts[j].x()) + if (pIdx > 0 && intersectionPointFlat.x() < polyLine[pIdx].x()) { - polyLineIdx = static_cast(i); - segIdx = static_cast(j) - 1; - startPt = pts[segIdx]; + polyLineIdx = static_cast(pLineIdx); + segIdx = static_cast(pIdx) - 1; + startPt = polyLine[segIdx]; break; } } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index e92cb0b41d..8338e073a8 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -75,7 +75,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object RimIntersection* crossSection() const; - cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); private: void calculateArrays(); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 40cc3a2384..33a7653e30 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -974,9 +974,9 @@ const RimIntersection* RivIntersectionPartMgr::intersection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm) +cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) { - return m_crossSectionGenerator->unflattenTransformMatrix(intersectionPointUtm); + return m_crossSectionGenerator->unflattenTransformMatrix(intersectionPointFlat); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 933532b5b3..5009e81451 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -76,7 +76,7 @@ class RivIntersectionPartMgr : public cvf::Object const RimIntersection* intersection() const; - cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointUtm); + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); public: static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h new file mode 100644 index 0000000000..c0973123b7 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h @@ -0,0 +1,148 @@ +#pragma once + + +class RivSectionFlattner +{ +public: + //-------------------------------------------------------------------------------------------------- + /// Returns the next index higher than idxToStartOfLineSegment that makes the line + // polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir + /// + /// Returns size_t(-1) if no point is found + //-------------------------------------------------------------------------------------------------- + static size_t indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment) + { + size_t lineCount = polyLine.size(); + if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; + + + cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; + + for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) + { + cvf::Vec3d p2 = polyLine[lIdx]; + cvf::Vec3d p1p2 = p2 - p1; + + if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) + { + return lIdx; + } + } + + return -1; + } + + //-------------------------------------------------------------------------------------------------- + /// Returns one CS pr point, valid for the next segment + //-------------------------------------------------------------------------------------------------- + static std::vector calculateFlatteningCSsForPolyline(const std::vector & polyLine, + const cvf::Vec3d& extrusionDir, + const cvf::Vec3d& startOffset, + cvf::Vec3d* endOffset) + { + CVF_ASSERT(endOffset); + size_t pointCount = polyLine.size(); + CVF_ASSERT(pointCount > 1); + + std::vector segmentTransforms; + segmentTransforms.reserve(pointCount); + + // Find initial transform, used if all is vertical + + cvf::Mat4d invSectionCS; + { + cvf::Vec3d p1 = polyLine[0]; + cvf::Vec3d p2 = polyLine[1]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); + invSectionCS.setTranslation(invSectionCS.translation() + startOffset); + } + + cvf::Vec3d previousFlattenedSectionEndPoint = startOffset; + + size_t lIdx = 0; + while ( lIdx < pointCount ) + { + size_t idxToNextP = indexToNextValidPoint(polyLine, extrusionDir, lIdx); + + // If the rest is nearly parallel to extrusionDir, use the current inverse matrix for the rest of the points + + if ( idxToNextP == size_t(-1) ) + { + size_t inc = 0; + while ( (lIdx + inc) < pointCount ) + { + segmentTransforms.push_back(invSectionCS); + ++inc; + } + break; + } + + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + invSectionCS = sectionLocalCS.getInverted(); + cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint(invSectionCS); + + invSectionCS.setTranslation(invSectionCS.translation() + previousFlattenedSectionEndPoint ); + + previousFlattenedSectionEndPoint += flattenedSectionEndPoint; + + // Assign the matrix to the points in between + + size_t inc = 0; + while ( (lIdx + inc) < idxToNextP ) + { + segmentTransforms.push_back(invSectionCS); + inc++; + } + + lIdx = idxToNextP; + } + + *endOffset = previousFlattenedSectionEndPoint; + return segmentTransforms; + } + +private: + + //-------------------------------------------------------------------------------------------------- + /// Origo in P1 + /// Ez in upwards extrusionDir + /// Ey normal to the section plane + /// Ex in plane along p1-p2 + //-------------------------------------------------------------------------------------------------- + static cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, + const cvf::Vec3d& p2, + const cvf::Vec3d& extrusionDir) + { + using namespace cvf; + + Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; + + Vec3d sectionLineDir = p2 - p1; + + if ( cvf::GeometryTools::getAngle(sectionLineDir, extrusionDir) < 0.01 ) + { + sectionLineDir = Ez.perpendicularVector(); + } + + Vec3d Ey = Ez ^ sectionLineDir; + Ey.normalize(); + Vec3d Ex = Ey ^ Ez; + Ex.normalize(); + + return Mat4d(Ex[0], Ey[0], Ez[0], p1[0], + Ex[1], Ey[1], Ez[1], p1[1], + Ex[2], Ey[2], Ez[2], p1[2], + 0.0, 0.0, 0.0, 1.0); + } + + +}; + + From 009ae7c7503d40530b76dc21dc66778f3f5a73dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Mar 2018 09:59:45 +0100 Subject: [PATCH 0478/1027] #2552 Separated the flattening code, to be able to use it to flatten simwells and wellpaths --- .../Intersections/CMakeLists_files.cmake | 2 + .../Intersections/RivSectionFlattner.cpp | 150 +++++++++++++++++ .../Intersections/RivSectionFlattner.h | 152 +++--------------- 3 files changed, 178 insertions(+), 126 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp diff --git a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake index 5d2e68a6d6..1b0684cc7c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.h ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -17,6 +18,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp new file mode 100644 index 0000000000..ab4aa91419 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp @@ -0,0 +1,150 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivSectionFlattner.h" +#include "cvfGeometryTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// Returns the next index higher than idxToStartOfLineSegment that makes the line +// polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir +/// +/// Returns size_t(-1) if no point is found +//-------------------------------------------------------------------------------------------------- +size_t RivSectionFlattner::indexToNextValidPoint(const std::vector& polyLine, const cvf::Vec3d extrDir, size_t idxToStartOfLineSegment) +{ + size_t lineCount = polyLine.size(); + if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; + + + cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; + + for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) + { + cvf::Vec3d p2 = polyLine[lIdx]; + cvf::Vec3d p1p2 = p2 - p1; + + if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) + { + return lIdx; + } + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// Returns one CS pr point, valid for the next segment +//-------------------------------------------------------------------------------------------------- +std::vector RivSectionFlattner::calculateFlatteningCSsForPolyline(const std::vector & polyLine, const cvf::Vec3d& extrusionDir, const cvf::Vec3d& startOffset, cvf::Vec3d* endOffset) +{ + CVF_ASSERT(endOffset); + size_t pointCount = polyLine.size(); + CVF_ASSERT(pointCount > 1); + + std::vector segmentTransforms; + segmentTransforms.reserve(pointCount); + + // Find initial transform, used if all is vertical + + cvf::Mat4d invSectionCS; + { + cvf::Vec3d p1 = polyLine[0]; + cvf::Vec3d p2 = polyLine[1]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); + invSectionCS.setTranslation(invSectionCS.translation() + startOffset); + } + + cvf::Vec3d previousFlattenedSectionEndPoint = startOffset; + + size_t lIdx = 0; + while ( lIdx < pointCount ) + { + size_t idxToNextP = indexToNextValidPoint(polyLine, extrusionDir, lIdx); + + // If the rest is nearly parallel to extrusionDir, use the current inverse matrix for the rest of the points + + if ( idxToNextP == size_t(-1) ) + { + size_t inc = 0; + while ( (lIdx + inc) < pointCount ) + { + segmentTransforms.push_back(invSectionCS); + ++inc; + } + break; + } + + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + invSectionCS = sectionLocalCS.getInverted(); + cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint(invSectionCS); + + invSectionCS.setTranslation(invSectionCS.translation() + previousFlattenedSectionEndPoint); + + previousFlattenedSectionEndPoint += flattenedSectionEndPoint; + + // Assign the matrix to the points in between + + size_t inc = 0; + while ( (lIdx + inc) < idxToNextP ) + { + segmentTransforms.push_back(invSectionCS); + inc++; + } + + lIdx = idxToNextP; + } + + *endOffset = previousFlattenedSectionEndPoint; + return segmentTransforms; +} + +//-------------------------------------------------------------------------------------------------- +/// Origo in P1 +/// Ez in upwards extrusionDir +/// Ey normal to the section plane +/// Ex in plane along p1-p2 +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir) +{ + using namespace cvf; + + Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; + + Vec3d sectionLineDir = p2 - p1; + + if ( cvf::GeometryTools::getAngle(sectionLineDir, extrusionDir) < 0.01 ) + { + sectionLineDir = Ez.perpendicularVector(); + } + + Vec3d Ey = Ez ^ sectionLineDir; + Ey.normalize(); + Vec3d Ex = Ey ^ Ez; + Ex.normalize(); + + return Mat4d(Ex[0], Ey[0], Ez[0], p1[0], + Ex[1], Ey[1], Ez[1], p1[1], + Ex[2], Ey[2], Ez[2], p1[2], + 0.0, 0.0, 0.0, 1.0); +} diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h index c0973123b7..6d3a9288ae 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h @@ -1,146 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + #pragma once +#include "cvfBase.h" +#include "cvfMatrix4.h" + +#include + class RivSectionFlattner { public: - //-------------------------------------------------------------------------------------------------- - /// Returns the next index higher than idxToStartOfLineSegment that makes the line - // polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir - /// - /// Returns size_t(-1) if no point is found - //-------------------------------------------------------------------------------------------------- static size_t indexToNextValidPoint(const std::vector& polyLine, const cvf::Vec3d extrDir, - size_t idxToStartOfLineSegment) - { - size_t lineCount = polyLine.size(); - if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; - - - cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; - - for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) - { - cvf::Vec3d p2 = polyLine[lIdx]; - cvf::Vec3d p1p2 = p2 - p1; - - if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) - { - return lIdx; - } - } - - return -1; - } + size_t idxToStartOfLineSegment); - //-------------------------------------------------------------------------------------------------- - /// Returns one CS pr point, valid for the next segment - //-------------------------------------------------------------------------------------------------- static std::vector calculateFlatteningCSsForPolyline(const std::vector & polyLine, const cvf::Vec3d& extrusionDir, const cvf::Vec3d& startOffset, - cvf::Vec3d* endOffset) - { - CVF_ASSERT(endOffset); - size_t pointCount = polyLine.size(); - CVF_ASSERT(pointCount > 1); - - std::vector segmentTransforms; - segmentTransforms.reserve(pointCount); - - // Find initial transform, used if all is vertical - - cvf::Mat4d invSectionCS; - { - cvf::Vec3d p1 = polyLine[0]; - cvf::Vec3d p2 = polyLine[1]; - - cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); - cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); - invSectionCS.setTranslation(invSectionCS.translation() + startOffset); - } - - cvf::Vec3d previousFlattenedSectionEndPoint = startOffset; - - size_t lIdx = 0; - while ( lIdx < pointCount ) - { - size_t idxToNextP = indexToNextValidPoint(polyLine, extrusionDir, lIdx); - - // If the rest is nearly parallel to extrusionDir, use the current inverse matrix for the rest of the points - - if ( idxToNextP == size_t(-1) ) - { - size_t inc = 0; - while ( (lIdx + inc) < pointCount ) - { - segmentTransforms.push_back(invSectionCS); - ++inc; - } - break; - } - - cvf::Vec3d p1 = polyLine[lIdx]; - cvf::Vec3d p2 = polyLine[idxToNextP]; - - cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); - invSectionCS = sectionLocalCS.getInverted(); - cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint(invSectionCS); - - invSectionCS.setTranslation(invSectionCS.translation() + previousFlattenedSectionEndPoint ); - - previousFlattenedSectionEndPoint += flattenedSectionEndPoint; - - // Assign the matrix to the points in between - - size_t inc = 0; - while ( (lIdx + inc) < idxToNextP ) - { - segmentTransforms.push_back(invSectionCS); - inc++; - } - - lIdx = idxToNextP; - } - - *endOffset = previousFlattenedSectionEndPoint; - return segmentTransforms; - } + cvf::Vec3d* endOffset); private: - //-------------------------------------------------------------------------------------------------- - /// Origo in P1 - /// Ez in upwards extrusionDir - /// Ey normal to the section plane - /// Ex in plane along p1-p2 - //-------------------------------------------------------------------------------------------------- static cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, - const cvf::Vec3d& extrusionDir) - { - using namespace cvf; - - Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; - - Vec3d sectionLineDir = p2 - p1; - - if ( cvf::GeometryTools::getAngle(sectionLineDir, extrusionDir) < 0.01 ) - { - sectionLineDir = Ez.perpendicularVector(); - } - - Vec3d Ey = Ez ^ sectionLineDir; - Ey.normalize(); - Vec3d Ex = Ey ^ Ez; - Ex.normalize(); - - return Mat4d(Ex[0], Ey[0], Ez[0], p1[0], - Ex[1], Ey[1], Ez[1], p1[1], - Ex[2], Ey[2], Ez[2], p1[2], - 0.0, 0.0, 0.0, 1.0); - } + const cvf::Vec3d& extrusionDir); }; From 8e8c168405bcb6d14cffa698ed3df25bd02fb2b0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 Mar 2018 11:07:46 +0100 Subject: [PATCH 0479/1027] #2546 Well Connection Factors : Several changes related to data access Moved rig classes from command feature into ReservoirDataModel\Completions\ --- ApplicationCode/CMakeLists.txt | 2 + .../CMakeLists_files.cmake | 12 -- ...ellPathExportCompletionDataFeatureImpl.cpp | 141 ++++++++++++++++++ ...cWellPathExportCompletionDataFeatureImpl.h | 4 + .../ModelVisualization/RivWellPathPartMgr.cpp | 24 +++ .../ModelVisualization/RivWellPathPartMgr.h | 4 + .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimEclipseView.cpp | 7 + .../ProjectDataModel/RimEclipseView.h | 2 + .../RimVirtualPerforationResults.cpp | 84 +++++++++++ .../RimVirtualPerforationResults.h | 53 +++++++ .../Completions/CMakeLists_files.cmake | 31 ++++ .../Completions}/RigCompletionData.cpp | 0 .../Completions}/RigCompletionData.h | 0 .../RigCompletionDataGridCell.cpp | 0 .../Completions}/RigCompletionDataGridCell.h | 0 ...StimPlanCellTransmissibilityCalculator.cpp | 0 ...ToStimPlanCellTransmissibilityCalculator.h | 0 .../RigFractureTransmissibilityEquations.cpp | 0 .../RigFractureTransmissibilityEquations.h | 0 .../RigTransmissibilityCondenser.cpp | 0 .../RigTransmissibilityCondenser.h | 0 ...igVirtualPerforationTransmissibilities.cpp | 107 +++++++++++++ .../RigVirtualPerforationTransmissibilities.h | 67 +++++++++ .../RigWellPathStimplanIntersector.cpp | 0 .../RigWellPathStimplanIntersector.h | 0 .../ReservoirDataModel/RigEclipseCaseData.cpp | 17 +++ .../ReservoirDataModel/RigEclipseCaseData.h | 6 + .../UnitTests/RigCellGeometryTools-Test.cpp | 2 +- .../RigTransmissibilityCondenser-Test.cpp | 2 +- 30 files changed, 553 insertions(+), 14 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h create mode 100644 ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigCompletionData.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigCompletionData.h (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigCompletionDataGridCell.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigCompletionDataGridCell.h (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigEclipseToStimPlanCellTransmissibilityCalculator.h (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigFractureTransmissibilityEquations.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigFractureTransmissibilityEquations.h (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigTransmissibilityCondenser.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigTransmissibilityCondenser.h (100%) create mode 100644 ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp create mode 100644 ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigWellPathStimplanIntersector.cpp (100%) rename ApplicationCode/{Commands/CompletionExportCommands => ReservoirDataModel/Completions}/RigWellPathStimplanIntersector.h (100%) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 4de30e6ff2..c0cf5a83f4 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -41,6 +41,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel + ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel/Completions ${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel @@ -80,6 +81,7 @@ list( APPEND REFERENCED_CMAKE_FILES ReservoirDataModel/CMakeLists_files.cmake ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake + ReservoirDataModel/Completions/CMakeLists_files.cmake FileInterface/CMakeLists_files.cmake ProjectDataModel/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index ae0798daf2..01b1fc3696 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -4,15 +4,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.h ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h -${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.h -${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h -${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.h -${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.h -${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.h -${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.h ) @@ -21,15 +15,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp -${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.cpp -${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp -${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp -${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.cpp -${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.cpp -${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 895d7d1f67..94491ce1ca 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -57,6 +57,7 @@ #include "cvfPlane.h" +#include "RigVirtualPerforationTransmissibilities.h" #include //-------------------------------------------------------------------------------------------------- @@ -315,6 +316,146 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +/* +void RicWellPathExportCompletionDataFeatureImpl::computeVirtualPerfTrans( + RigVirtualPerforationTransmissibilities* virtualPerfTrans, + RimEclipseCase* eclipseCase, + const std::vector& inputWellPaths) +{ + CVF_ASSERT(eclipseCase); + + std::vector usedWellPaths; + + { + for (RimWellPath* wellPath : inputWellPaths) + { + if (wellPath->unitSystem() == eclipseCase->eclipseCaseData()->unitsType()) + { + usedWellPaths.push_back(wellPath); + } + else + { + RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); + } + } + } + + RicExportCompletionDataSettingsUi exportSettings; + exportSettings.caseToApply = eclipseCase; + exportSettings.includeFishbones = true; + exportSettings.includePerforations = true; + exportSettings.includeFractures = true; + + bool anyPerforationsPresent = false; + for (const auto& w : usedWellPaths) + { + if (!w->perforationIntervalCollection()->perforations().empty()) + { + anyPerforationsPresent = true; + } + } + + for (auto wellPath : usedWellPaths) + { + std::vector completionsPerEclipseCell; + + // Compute completions that do not change between time steps + + if (exportSettings.includeFishbones) + { + std::vector completionData = + RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( + wellPath, exportSettings); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + if (exportSettings.includeFractures()) + { + std::vector completionData = + RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, nullptr); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + if (!anyPerforationsPresent) + { + virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); + } + else + { + for (size_t i = 0; i < eclipseCase->timeStepDates().size(); i++) + { + // Update time step in export settings + exportSettings.timeStep = static_cast(i); + + if (exportSettings.includePerforations) + { + std::vector completionData = generatePerforationsCompdatValues(wellPath, exportSettings); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + //virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); + } + } + } +} +*/ + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::computeCompletionsForWellPath( + RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& exportSettings) +{ + std::vector completionsPerEclipseCell; + { + // Compute completions that do not change between time steps + + if (exportSettings.includeFishbones) + { + std::vector completionData = + RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( + wellPath, exportSettings); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + if (exportSettings.includeFractures()) + { + std::vector completionData = + RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, nullptr); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + { +/* + for (size_t i = 0; i < exportSettings.caseToApply()->timeStepDates().size(); i++) + { + // Update time step in export settings + exportSettings.timeStep = static_cast(i); + + if (exportSettings.includePerforations) + { + std::vector completionData = generatePerforationsCompdatValues(wellPath, exportSettings); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + // virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); + } +*/ + } + } + return completionsPerEclipseCell; +} + //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index fa576949d9..81c102675a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -35,6 +35,7 @@ class RimFishbonesMultipleSubs; class RimSimWellInView; class RimWellPath; class RifEclipseDataTableFormatter; +class RigVirtualPerforationTransmissibilities; //================================================================================================== /// @@ -145,6 +146,9 @@ class RicWellPathExportCompletionDataFeatureImpl const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); + static std::vector computeCompletionsForWellPath(RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& exportSettings); + private: static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, double skinFactor, diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index dc358782e0..760c38bc02 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -23,7 +23,9 @@ #include "RiaApplication.h" +#include "RigEclipseCaseData.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RimEclipseCase.h" @@ -203,6 +205,28 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize) +{ + RimEclipseCase* eclipseCase = nullptr; + + m_rimView->firstAncestorOrThisOfType(eclipseCase); + if (!eclipseCase) return; + if (!eclipseCase->eclipseCaseData()) return; + + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + const RigVirtualPerforationTransmissibilities* trans = eclipseCaseData->virtualPerforationTransmissibilities(); + if (trans) + { + + } +} + //-------------------------------------------------------------------------------------------------- /// The pipe geometry needs to be rebuilt on scale change to keep the pipes round //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index b39d4c3a19..c5e3c1cc75 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -87,6 +87,10 @@ class RivWellPathPartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize); + void appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); + void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 1484e33117..72cedbe3d8 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -99,6 +99,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h ) @@ -202,6 +203,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 227e4b9117..b4293a6cdc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -59,6 +59,7 @@ #include "RimTernaryLegendConfig.h" #include "RimViewController.h" #include "RimViewLinker.h" +#include "RimVirtualPerforationResults.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -125,6 +126,10 @@ RimEclipseView::RimEclipseView() m_fractureColors = new RimStimPlanColors(); m_fractureColors.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_virtualPerforationResult, "VirtualPerforationResult", "Virtual Perforation Result", "", "", ""); + m_virtualPerforationResult = new RimVirtualPerforationResults(); + m_virtualPerforationResult.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_wellCollection, "WellCollection", "Simulation Wells", "", "", ""); m_wellCollection = new RimSimWellInViewCollection; m_wellCollection.uiCapability()->setUiHidden(true); @@ -1414,6 +1419,8 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } } + uiTreeOrdering.add(m_virtualPerforationResult); + uiTreeOrdering.add(faultCollection()); uiTreeOrdering.add(crossSectionCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index f91fec8c20..caa206d14e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -54,6 +54,7 @@ class RimReservoirCellResultsStorage; class RimReservoirCellResultsStorage; class RimSimWellInViewCollection; class RimStimPlanColors; +class RimVirtualPerforationResults; class RiuViewer; class RivReservoirSimWellsPartMgr; class RivIntersectionPartMgr; @@ -176,6 +177,7 @@ class RimEclipseView : public RimGridView caf::PdmChildField m_cellEdgeResult; caf::PdmChildField m_faultResultSettings; caf::PdmChildField m_fractureColors; + caf::PdmChildField m_virtualPerforationResult; caf::PdmChildField m_wellCollection; caf::PdmChildField m_faultCollection; diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp new file mode 100644 index 0000000000..695a4bfb08 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimVirtualPerforationResults.h" + +#include "RimLegendConfig.h" + + + +CAF_PDM_SOURCE_INIT(RimVirtualPerforationResults, "RimVirtualPerforationResults"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults::RimVirtualPerforationResults() +{ + CAF_PDM_InitObject("Virtual Perforation Results", ":/CellResult.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + this->legendConfig = new RimLegendConfig(); + legendConfig.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_showTensors, "ShowTensors", true, "", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults::~RimVirtualPerforationResults() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() +{ + return &m_showTensors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimVirtualPerforationResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + *useOptionsOnly = true; + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.skipRemainingFields(true); +} + diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h new file mode 100644 index 0000000000..f8c1e4b6b7 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + + +#include + +class RimLegendConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimVirtualPerforationResults : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + + +public: + RimVirtualPerforationResults(); + virtual ~RimVirtualPerforationResults(); + +private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + caf::PdmField m_showTensors; + + caf::PdmChildField legendConfig; +}; diff --git a/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake new file mode 100644 index 0000000000..02d025e364 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake @@ -0,0 +1,31 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.h +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.h +${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.h +${CMAKE_CURRENT_LIST_DIR}/RigVirtualPerforationTransmissibilities.h +) + + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.cpp +${CMAKE_CURRENT_LIST_DIR}/RigVirtualPerforationTransmissibilities.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ReservoirDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigCompletionData.h rename to ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigCompletionDataGridCell.h rename to ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h b/ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigEclipseToStimPlanCellTransmissibilityCalculator.h rename to ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigFractureTransmissibilityEquations.h rename to ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigTransmissibilityCondenser.h rename to ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.h diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp new file mode 100644 index 0000000000..5b017151c6 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigVirtualPerforationTransmissibilities.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CompletionDataFrame::CompletionDataFrame() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CompletionDataFrame::setCompletionData(const std::vector& completions) +{ + for (auto& completion : completions) + { + auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); + if (it != m_multipleCompletionsPerEclipseCell.end()) + { + it->second.push_back(completion); + } + else + { + m_multipleCompletionsPerEclipseCell.insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& CompletionDataFrame::multipleCompletionsPerEclipseCell() const +{ + return m_multipleCompletionsPerEclipseCell; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigVirtualPerforationTransmissibilities::RigVirtualPerforationTransmissibilities() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilities() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::appendCompletionDataForWellPath( + RimWellPath* wellPath, + const std::vector& completions) +{ +/* + auto item = m_mapFromWellToCompletionData.find(wellPath); + if (item != m_mapFromWellToCompletionData.end()) + { + item->second.setCompletionData + } + + auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); + if (it != m_multipleCompletionsPerEclipseCell.end()) + { + it->second.push_back(completion); + } + else + { + m_multipleCompletionsPerEclipseCell.insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); + } +*/ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& + RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const +{ + static std::map> dummy; + + auto item = m_mapFromWellToCompletionData.find(wellPath); + if (item != m_mapFromWellToCompletionData.end()) + { + return item->second[timeStepIndex].multipleCompletionsPerEclipseCell(); + } + + return dummy; +} diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h new file mode 100644 index 0000000000..ac8968b725 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RigCompletionData.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include +#include + +class RigCompletionData; +class RigCompletionDataGridCell; +class RimWellPath; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class CompletionDataFrame +{ +public: + CompletionDataFrame(); + + void setCompletionData(const std::vector& completions); + + const std::map>& + multipleCompletionsPerEclipseCell() const; + +private: + std::map> m_multipleCompletionsPerEclipseCell; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RigVirtualPerforationTransmissibilities : public cvf::Object +{ +public: + RigVirtualPerforationTransmissibilities(); + ~RigVirtualPerforationTransmissibilities(); + + void appendCompletionDataForWellPath(RimWellPath* wellPath, + const std::vector& completions); + + const std::map>& + multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const; + +private: + std::map> m_mapFromWellToCompletionData; +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.cpp diff --git a/ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.h b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.h similarity index 100% rename from ApplicationCode/Commands/CompletionExportCommands/RigWellPathStimplanIntersector.h rename to ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.h diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index 2bbe793d56..12aedfc108 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -30,6 +30,7 @@ #include "RigSimWellData.h" #include "RigSimulationWellCenterLineCalculator.h" #include "RigSimulationWellCoordsAndMD.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RimFlowPlotCollection.h" @@ -519,6 +520,22 @@ std::vector RigEclipseCaseData::simulationWellBranches(const return branches; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseCaseData::setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities) +{ + m_virtualPerforationTransmissibilities = virtualPerforationTransmissibilities; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVirtualPerforationTransmissibilities* RigEclipseCaseData::virtualPerforationTransmissibilities() const +{ + return m_virtualPerforationTransmissibilities; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index 7c59f2fea1..15820eda53 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -47,6 +47,7 @@ class RigSimWellData; class RigCell; class RigWellPath; class RimEclipseCase; +class RigVirtualPerforationTransmissibilities; struct RigWellResultPoint; @@ -110,6 +111,9 @@ class RigEclipseCaseData : public cvf::Object bool includeAllCellCenters, bool useAutoDetectionOfBranches) const; + void setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities); + const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const; + private: void computeActiveCellIJKBBox(); void computeWellCellsPrGrid(); @@ -127,6 +131,8 @@ class RigEclipseCaseData : public cvf::Object cvf::ref m_activeFormationNamesData; + RigVirtualPerforationTransmissibilities* m_virtualPerforationTransmissibilities; + cvf::Collection m_simWellData; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not cvf::Collection m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in diff --git a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp index 18009f2c1a..faa0fcf4ba 100644 --- a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp @@ -295,7 +295,7 @@ TEST(RigCellGeometryTools, polylinePolygonIntersectionTest2) } -#include "CompletionExportCommands/RigWellPathStimplanIntersector.h" +#include "Completions/RigWellPathStimplanIntersector.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp index 32e6283a51..db0c5949d5 100644 --- a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp +++ b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include "CompletionExportCommands/RigTransmissibilityCondenser.h" +#include "Completions/RigTransmissibilityCondenser.h" //-------------------------------------------------------------------------------------------------- /// From 716bb3184b5e5cd89c732f6a1edd02edee1e44ca Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 Mar 2018 11:12:39 +0100 Subject: [PATCH 0480/1027] System : Replace tab with four spaces --- .../Application/RiaApplication.cpp | 14 +- ApplicationCode/Application/RiaApplication.h | 16 +- .../Tools/RiaImageCompareReporter.cpp | 42 ++--- .../Tools/RiaRegressionTestRunner.cpp | 64 +++---- .../Application/Tools/RiaTextFileCompare.cpp | 2 +- ApplicationCode/CMakeLists.txt | 60 +++---- ...cWellPathExportCompletionDataFeatureImpl.h | 4 +- ...licateTemplateInOtherUnitSystemFeature.cpp | 4 +- .../Commands/RicCloseObservedDataFeature.cpp | 8 +- .../Commands/RicCloseSummaryCaseFeature.cpp | 8 +- ApplicationCode/FileInterface/RifHdf5Reader.h | 28 +-- .../RivWellFracturePartMgr.cpp | 10 +- .../RivWellFracturePartMgr.h | 8 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 6 +- .../RimEllipseFractureTemplate.cpp | 4 +- .../RimStimPlanFractureTemplate.cpp | 2 +- .../RimContextCommandBuilder.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 4 +- .../ProjectDataModel/RimEclipseView.h | 4 +- .../ProjectDataModel/RimPlotCurve.cpp | 22 +-- .../RimSimWellInViewCollection.h | 4 +- .../Summary/RimSummaryCaseCollection.h | 2 +- .../Summary/RimSummaryCurve.cpp | 2 +- .../Summary/RimSummaryCurvesCalculator.cpp | 10 +- .../Summary/RimSummaryPlot.cpp | 6 +- .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 +- ...igVirtualPerforationTransmissibilities.cpp | 44 ++--- .../RigVirtualPerforationTransmissibilities.h | 4 +- .../ReservoirDataModel/RigEclipseCaseData.cpp | 4 +- .../ReservoirDataModel/RigEclipseCaseData.h | 6 +- .../RigEclipseNativeStatCalc.h | 10 +- .../RigEclipseNativeVisibleCellsStatCalc.h | 10 +- ApplicationCode/Resources/ResInsight.qrc | 90 +++++----- .../SocketInterface/RiaSocketServer.cpp | 14 +- .../UnitTests/CMakeLists_files.cmake | 2 +- .../UnitTests/HDF5FileReader-Test.cpp | 170 +++++++++--------- .../UnitTests/ObservedDataParser-Test.cpp | 2 +- .../UserInterface/RiuCadNavigation.cpp | 2 +- .../RiuCalculationsContextMenuManager.h | 10 +- .../RiuExpressionContextMenuManager.h | 12 +- .../UserInterface/RiuMainPlotWindow.h | 2 +- .../UserInterface/RiuMainWindow.cpp | 4 +- ApplicationCode/UserInterface/RiuMainWindow.h | 2 +- .../UserInterface/RiuMessagePanel.h | 2 +- .../Resources/cafAnimControl.qrc | 26 +-- 45 files changed, 377 insertions(+), 377 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 6dc271edda..574804817c 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -100,7 +100,7 @@ #ifndef WIN32 -#include // for usleep +#include // for usleep #endif //WIN32 #ifdef USE_UNIT_TESTS @@ -1492,12 +1492,12 @@ std::vector RiaApplication::readFileListFromTextFile(QString listFileNa //-------------------------------------------------------------------------------------------------- void RiaApplication::waitUntilCommandObjectsHasBeenProcessed() { - // Wait until all command objects have completed - while (!m_commandQueueLock.tryLock()) - { - processEvents(); - } - m_commandQueueLock.unlock(); + // Wait until all command objects have completed + while (!m_commandQueueLock.tryLock()) + { + processEvents(); + } + m_commandQueueLock.unlock(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 4dbe565d7d..5584192dee 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -94,19 +94,19 @@ class RiaApplication : public QApplication RiaApplication(int& argc, char** argv); ~RiaApplication(); - static RiaApplication* instance(); + static RiaApplication* instance(); int parseArgumentsAndRunUnitTestsIfRequested(); bool parseArguments(); void setActiveReservoirView(Rim3dView*); - Rim3dView* activeReservoirView(); - const Rim3dView* activeReservoirView() const; - RimGridView* activeGridView(); + Rim3dView* activeReservoirView(); + const Rim3dView* activeReservoirView() const; + RimGridView* activeGridView(); RimViewWindow* activePlotWindow() const; - RimProject* project(); + RimProject* project(); void createMockModel(); void createResultsMockModel(); @@ -199,7 +199,7 @@ class RiaApplication : public QApplication static std::vector readFileListFromTextFile(QString listFileName); - void waitUntilCommandObjectsHasBeenProcessed(); + void waitUntilCommandObjectsHasBeenProcessed(); private: @@ -217,10 +217,10 @@ class RiaApplication : public QApplication void setHelpText(const QString& helpText); private slots: - void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); + void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); private: - caf::PdmPointer m_activeReservoirView; + caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; RiaSocketServer* m_socketServer; diff --git a/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp b/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp index cf140fe3ab..f3afde6fdf 100644 --- a/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp +++ b/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp @@ -177,36 +177,36 @@ std::string RiaImageCompareReporter::cssString() const html += ""; html += ".image-slider {"; - html += "position:relative;"; - html += "display: inline-block;"; - html += "line-height: 0;"; + html += "position:relative;"; + html += "display: inline-block;"; + html += "line-height: 0;"; html += "}"; html += ".image-slider > div {"; - html += "position: absolute;"; - html += "top: 0; bottom: 0; left: 0;"; - html += "width: 25px;"; - html += "max-width: 100%;"; - html += "overflow: hidden;"; - html += "resize: horizontal;"; + html += "position: absolute;"; + html += "top: 0; bottom: 0; left: 0;"; + html += "width: 25px;"; + html += "max-width: 100%;"; + html += "overflow: hidden;"; + html += "resize: horizontal;"; html += "}"; html += ".image-slider > div:before {"; - html += "content: '';"; - html += "position: absolute;"; - html += "right: 0; bottom: 0;"; - html += "width: 23px; height: 23px;"; - html += "padding: 5px;"; - html += "background: linear-gradient(-45deg, gray 50%, transparent 0);"; - html += "background-clip: content-box;"; - html += "cursor: ew-resize;"; - html += "-webkit-filter: drop-shadow(0 0 6px black);"; - html += "filter: drop-shadow(0 0 6px black);"; + html += "content: '';"; + html += "position: absolute;"; + html += "right: 0; bottom: 0;"; + html += "width: 23px; height: 23px;"; + html += "padding: 5px;"; + html += "background: linear-gradient(-45deg, gray 50%, transparent 0);"; + html += "background-clip: content-box;"; + html += "cursor: ew-resize;"; + html += "-webkit-filter: drop-shadow(0 0 6px black);"; + html += "filter: drop-shadow(0 0 6px black);"; html += "}"; html += ".image-slider img {"; - html += "user-select: none;"; - html += "max-width: 1000px;"; + html += "user-select: none;"; + html += "max-width: 1000px;"; html += "}"; html += ""; diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp index 31f3d1b780..66ea48252f 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -256,38 +256,38 @@ void RiaRegressionTestRunner::runRegressionTest(const QString& testRootPath, con if (fib.exists() && fig.exists()) { - { - QString headerText = testCaseFolder.dirName(); - - html += "\n"; - html += " \n"; - html += " \n"; - html += " \n"; - - textFileCompare.runComparison(baseFilesFolderName, generatedFilesFolderName); - - QString diff = textFileCompare.diffOutput(); - if (diff.isEmpty()) - { - html += " \n"; - html += " \n"; - html += " \n"; - } - else - { - html += " \n"; - html += " \n"; - html += " \n"; - } - - // Table end - html += "
" + headerText + "
No text diff detected
Text diff detected - output from diff tool :
\n"; - - if (!diff.isEmpty()) - { - html += QString(" %1 ").arg(diff); - } - } + { + QString headerText = testCaseFolder.dirName(); + + html += "\n"; + html += " \n"; + html += " \n"; + html += " \n"; + + textFileCompare.runComparison(baseFilesFolderName, generatedFilesFolderName); + + QString diff = textFileCompare.diffOutput(); + if (diff.isEmpty()) + { + html += " \n"; + html += " \n"; + html += " \n"; + } + else + { + html += " \n"; + html += " \n"; + html += " \n"; + } + + // Table end + html += "
" + headerText + "
No text diff detected
Text diff detected - output from diff tool :
\n"; + + if (!diff.isEmpty()) + { + html += QString(" %1 ").arg(diff); + } + } QFile file(htmlReportFileName); if (file.open(QIODevice::Append | QIODevice::Text)) diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp index ebb77c5874..a418d3187f 100644 --- a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp @@ -61,7 +61,7 @@ bool RiaTextFileCompare::runComparison(const QString& baseFolder, const QString& } // Command line arguments used when invoking 'diff' - // See https://docs.freebsd.org/info/diff/diff.info.diff_Options.html + // See https://docs.freebsd.org/info/diff/diff.info.diff_Options.html QString args = "-r -u --strip-trailing-cr"; QString completeCommand = QString("\"%1\" %2 %3 %4").arg(fullFilePath).arg(baseFolder).arg(generatedFolder).arg(args); diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index c0cf5a83f4..ad89a42c10 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -97,7 +97,7 @@ list( APPEND REFERENCED_CMAKE_FILES ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake UserInterface/CMakeLists_files.cmake - + Commands/CMakeLists_files.cmake Commands/ApplicationCommands/CMakeLists_files.cmake Commands/CompletionCommands/CMakeLists_files.cmake @@ -124,14 +124,14 @@ list( APPEND REFERENCED_CMAKE_FILES option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF) if (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS) - add_definitions(-DUSE_UNIT_TESTS) + add_definitions(-DUSE_UNIT_TESTS) list( APPEND REFERENCED_CMAKE_FILES UnitTests/CMakeLists_files.cmake ) list( APPEND CPP_SOURCES - ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc + ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc ) endif() @@ -155,7 +155,7 @@ add_subdirectory(ResultStatisticsCache) set( RI_LIBRARIES WellPathImportSsihub - ResultStatisticsCache + ResultStatisticsCache ) # @@ -163,10 +163,10 @@ set( RI_LIBRARIES # set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Optional path to the ABAQUS ODB API from Simulia. Needed for support of geomechanical models") if(NOT ${RESINSIGHT_ODB_API_DIR} EQUAL "") - add_definitions(-DUSE_ODB_API) - add_subdirectory(GeoMech/OdbReader) - SET(RESINSIGHT_USE_ODB_API 1) - MESSAGE( STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}" ) + add_definitions(-DUSE_ODB_API) + add_subdirectory(GeoMech/OdbReader) + SET(RESINSIGHT_USE_ODB_API 1) + MESSAGE( STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}" ) endif() add_subdirectory(GeoMech/GeoMechDataModel) @@ -192,7 +192,7 @@ if (RESINSIGHT_FOUND_HDF5) source_group( "FileInterface" FILES FileInterface/RifHdf5Reader.h FileInterface/RifHdf5Reader.cpp ) - add_definitions(-DUSE_HDF5) + add_definitions(-DUSE_HDF5) endif() if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_SOURING) @@ -271,7 +271,7 @@ set( EXE_FILES ${QRC_FILES_CPP} ${WIN_RESOURCE} ${HEADER_FILES} - ${REFERENCED_CMAKE_FILES} + ${REFERENCED_CMAKE_FILES} ../ResInsightVersion.cmake ../.clang-format ) @@ -349,9 +349,9 @@ if(RESINSIGHT_ENABLE_COTIRE) ReservoirDataModel/RigCellGeometryTools.cpp ) - foreach (fileToExclude ${COTIRE_EXCLUDE_FILES}) + foreach (fileToExclude ${COTIRE_EXCLUDE_FILES}) set_source_files_properties (${fileToExclude} PROPERTIES COTIRE_EXCLUDED TRUE) - endforeach(fileToExclude) + endforeach(fileToExclude) # disable precompiled headers set_target_properties(ResInsight PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) @@ -382,16 +382,16 @@ if (MSVC) # Odb Dlls if (RESINSIGHT_USE_ODB_API) - # Find all the dlls - file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll) - - # Strip off the path - foreach (aDLL ${RI_ALL_ODB_DLLS}) - get_filename_component(filenameWithExt ${aDLL} NAME) - list(APPEND RI_ODB_DLLS ${filenameWithExt} ) - endforeach(aDLL) - - foreach (aDLL ${RI_ODB_DLLS}) + # Find all the dlls + file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll) + + # Strip off the path + foreach (aDLL ${RI_ALL_ODB_DLLS}) + get_filename_component(filenameWithExt ${aDLL} NAME) + list(APPEND RI_ODB_DLLS ${filenameWithExt} ) + endforeach(aDLL) + + foreach (aDLL ${RI_ODB_DLLS}) list(APPEND RI_DLL_FILENAMES ${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}) endforeach() endif() @@ -410,13 +410,13 @@ endif(MSVC) foreach (FILE_TO_COPY ${RI_DLL_FILENAMES}) add_custom_command(TARGET ResInsight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${FILE_TO_COPY}" - "${CMAKE_CURRENT_BINARY_DIR}/$") + "${FILE_TO_COPY}" + "${CMAKE_CURRENT_BINARY_DIR}/$") if (_unityTargetName) add_custom_command(TARGET ${_unityTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${FILE_TO_COPY}" - "${CMAKE_CURRENT_BINARY_DIR}/$") + "${FILE_TO_COPY}" + "${CMAKE_CURRENT_BINARY_DIR}/$") endif() endforeach() @@ -437,10 +437,10 @@ if (RESINSIGHT_PRIVATE_INSTALL) # tell binary to first attempt to load libraries from its own directory set(RESINSIGHT_INSTALL_RPATH "\$ORIGIN") - if (${RESINSIGHT_USE_ODB_API}) - # This is a "hack" to make ResInsight runtime find the ODB so files used when compiling. - # statoil wanted it this way, but we should probbly make a different installoptions that does things this way, - # and really do copy them when doing PRIVATE_INSTALL + if (${RESINSIGHT_USE_ODB_API}) + # This is a "hack" to make ResInsight runtime find the ODB so files used when compiling. + # statoil wanted it this way, but we should probbly make a different installoptions that does things this way, + # and really do copy them when doing PRIVATE_INSTALL set(RESINSIGHT_INSTALL_RPATH ${RESINSIGHT_INSTALL_RPATH} ${RESINSIGHT_ODB_API_DIR}/lib) endif() diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 81c102675a..12dfbfb0bc 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -146,8 +146,8 @@ class RicWellPathExportCompletionDataFeatureImpl const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); - static std::vector computeCompletionsForWellPath(RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& exportSettings); + static std::vector computeCompletionsForWellPath(RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& exportSettings); private: static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, diff --git a/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp index b5ab0b6c05..4cacae58dd 100644 --- a/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp @@ -71,7 +71,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool fractureTemplateCollection->addFractureTemplate(copyOfTemplate); - auto currentUnit = copyOfTemplate->fractureTemplateUnit(); + auto currentUnit = copyOfTemplate->fractureTemplateUnit(); if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) { copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); @@ -88,7 +88,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool copyOfTemplate->loadDataAndUpdate(); copyOfTemplate->updateConnectedEditors(); - RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp b/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp index 14862db423..4ec8d50ba2 100644 --- a/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp @@ -40,8 +40,8 @@ CAF_CMD_SOURCE_INIT(RicCloseObservedDataFeature, "RicCloseObservedDataFeature"); //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Close"); - actionToSetup->setIcon(QIcon(":/Erase.png")); + actionToSetup->setText("Close"); + actionToSetup->setIcon(QIcon(":/Erase.png")); } //-------------------------------------------------------------------------------------------------- @@ -96,8 +96,8 @@ bool RicCloseObservedDataFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::onActionTriggered(bool isChecked) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); CVF_ASSERT(selection.size() > 0); RicCloseObservedDataFeature::deleteObservedData(selection); diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp index e25bc0861b..39c24fae14 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -43,8 +43,8 @@ CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature"); //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Close Summary Case"); - actionToSetup->setIcon(QIcon(":/Erase.png")); + actionToSetup->setText("Close Summary Case"); + actionToSetup->setIcon(QIcon(":/Erase.png")); } //-------------------------------------------------------------------------------------------------- @@ -103,8 +103,8 @@ bool RicCloseSummaryCaseFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::onActionTriggered(bool isChecked) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); CVF_ASSERT(selection.size() > 0); RicCloseSummaryCaseFeature::deleteSummaryCases(selection); diff --git a/ApplicationCode/FileInterface/RifHdf5Reader.h b/ApplicationCode/FileInterface/RifHdf5Reader.h index 5018a0a5bd..f3af15f3f2 100644 --- a/ApplicationCode/FileInterface/RifHdf5Reader.h +++ b/ApplicationCode/FileInterface/RifHdf5Reader.h @@ -40,23 +40,23 @@ class RifHdf5Reader : public RifHdf5ReaderInterface bool dynamicResult(const QString& result, size_t stepIndex, std::vector* values) const override; private: - std::vector getSourSimTimeStepFileNames(const QString& fileName) const; - QDateTime sourSimDateTimeToQDateTime(std::string dateString) const; + std::vector getSourSimTimeStepFileNames(const QString& fileName) const; + QDateTime sourSimDateTimeToQDateTime(std::string dateString) const; - std::string getTimeStepNumberAs5DigitString(std::string fileName) const; - std::string IntTo5DigitString(int i) const; + std::string getTimeStepNumberAs5DigitString(std::string fileName) const; + std::string IntTo5DigitString(int i) const; - int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - double getDoubleAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - std::string getStringAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + double getDoubleAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + std::string getStringAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - std::vector getSubGroupNames(H5::H5File file, std::string baseGroupName) const; - std::vector getStepTimeValues(H5::H5File file, std::string baseGroupName) const; - std::vector getResultNames(H5::H5File file, std::string baseGroupName) const; - void getElementResultValues(H5::H5File file, std::string groupName, std::vector* resultValues) const; + std::vector getSubGroupNames(H5::H5File file, std::string baseGroupName) const; + std::vector getStepTimeValues(H5::H5File file, std::string baseGroupName) const; + std::vector getResultNames(H5::H5File file, std::string baseGroupName) const; + void getElementResultValues(H5::H5File file, std::string groupName, std::vector* resultValues) const; private: - QString m_fileName; // name of SourSimRL main file given by user - int m_fileStrategy; // SourSimRL file strategy, fileStrategy == 1 means one time step per file - std::vector m_timeStepFileNames; // files containing transient SourSimRL results, one time step per file + QString m_fileName; // name of SourSimRL main file given by user + int m_fileStrategy; // SourSimRL file strategy, fileStrategy == 1 means one time step per file + std::vector m_timeStepFileNames; // files containing transient SourSimRL results, one time step per file }; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 7ff96b3969..68c134bde8 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -341,7 +341,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc std::vector nodeCoords; std::vector triangleIndices; - m_rimFracture->fractureTemplate()->fractureTriangleGeometry(&nodeCoords, &triangleIndices); + m_rimFracture->fractureTemplate()->fractureTriangleGeometry(&nodeCoords, &triangleIndices); cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); @@ -411,7 +411,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa std::vector nodeCoords; std::vector triangleIndices; - stimPlanFracTemplate->fractureTriangleGeometry(&nodeCoords, &triangleIndices); + stimPlanFracTemplate->fractureTriangleGeometry(&nodeCoords, &triangleIndices); if (triangleIndices.empty() || nodeCoords.empty()) { @@ -489,7 +489,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa } geo->setTextureCoordArray(textureCoords.p()); - cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); return surfacePart; } @@ -625,9 +625,9 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); geo->setTextureCoordArray(textureCoords.p()); - cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); - return surfacePart; + return surfacePart; } else { diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 3434ed48d7..ca1d41b1c2 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -34,7 +34,7 @@ namespace cvf class DrawableGeo; class Part; class Color3f; - class ScalarMapper; + class ScalarMapper; } namespace caf @@ -80,9 +80,9 @@ class RivWellFracturePartMgr : public cvf::Object std::vector fractureBorderPolygon(); - static cvf::ref createScalarMapperPart(cvf::DrawableGeo* drawableGeo, const cvf::ScalarMapper* scalarMapper, RimFracture* fracture, bool disableLighting); - - static std::vector transformToFractureDisplayCoords(const std::vector& polygon, + static cvf::ref createScalarMapperPart(cvf::DrawableGeo* drawableGeo, const cvf::ScalarMapper* scalarMapper, RimFracture* fracture, bool disableLighting); + + static std::vector transformToFractureDisplayCoords(const std::vector& polygon, cvf::Mat4d m, const caf::DisplayCoordTransform& displayCoordTransform); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 760c38bc02..928b49d035 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -221,10 +221,10 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); const RigVirtualPerforationTransmissibilities* trans = eclipseCaseData->virtualPerforationTransmissibilities(); - if (trans) - { + if (trans) + { - } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index d8868d7acc..df7144452e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -216,11 +216,11 @@ void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() m_fractureGrid->setFractureCells(fractureCells); - // Set well intersection to center of ellipse + // Set well intersection to center of ellipse std::pair wellCenterFractureCellIJ = std::make_pair(numberOfCellsI / 2, numberOfCellsJ / 2); m_fractureGrid->setWellCenterFractureCellIJ(wellCenterFractureCellIJ); - m_fractureGrid->setICellCount(numberOfCellsI); + m_fractureGrid->setICellCount(numberOfCellsI); m_fractureGrid->setJCellCount(numberOfCellsJ); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 33aa35326d..f6d27899be 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -732,7 +732,7 @@ void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vectorcreateFractureTriangleGeometry(m_wellPathDepthAtFracture, name(), diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 96c0993f8d..9919024bd5 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -616,7 +616,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicCutReferencesToClipboardFeature"; menuBuilder << "Separator"; - menuBuilder << "RicCloseSummaryCaseFeature"; + menuBuilder << "RicCloseSummaryCaseFeature"; menuBuilder << "RicCloseSummaryCaseInCollectionFeature"; menuBuilder << "RicDeleteSummaryCaseCollectionFeature"; menuBuilder << "RicCloseObservedDataFeature"; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index b4293a6cdc..4cd135d4a7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -156,8 +156,8 @@ RimEclipseView::RimEclipseView() m_reservoirGridPartManager = new RivReservoirViewPartMgr(this); m_simWellsPartManager = new RivReservoirSimWellsPartMgr(this); - - m_eclipseCase = nullptr; + + m_eclipseCase = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index caa206d14e..912bda226c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -177,7 +177,7 @@ class RimEclipseView : public RimGridView caf::PdmChildField m_cellEdgeResult; caf::PdmChildField m_faultResultSettings; caf::PdmChildField m_fractureColors; - caf::PdmChildField m_virtualPerforationResult; + caf::PdmChildField m_virtualPerforationResult; caf::PdmChildField m_wellCollection; caf::PdmChildField m_faultCollection; @@ -189,6 +189,6 @@ class RimEclipseView : public RimGridView cvf::ref m_reservoirGridPartManager; cvf::ref m_simWellsPartManager; - + std::vector m_visibleGridParts; }; diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index f4f4247080..59b0476fb8 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -115,17 +115,17 @@ RimPlotCurve::RimPlotCurve() //-------------------------------------------------------------------------------------------------- RimPlotCurve::~RimPlotCurve() { - if (m_qwtPlotCurve) - { - m_qwtPlotCurve->detach(); - delete m_qwtPlotCurve; - m_qwtPlotCurve = nullptr; - } - - if (m_parentQwtPlot) - { - m_parentQwtPlot->replot(); - } + if (m_qwtPlotCurve) + { + m_qwtPlotCurve->detach(); + delete m_qwtPlotCurve; + m_qwtPlotCurve = nullptr; + } + + if (m_parentQwtPlot) + { + m_parentQwtPlot->replot(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h index df15464505..dea4460889 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h @@ -109,8 +109,8 @@ class RimSimWellInViewCollection : public caf::PdmObject caf::PdmField wellHeadPosition; caf::PdmField isAutoDetectingBranches; - - caf::PdmChildArrayField wells; + + caf::PdmChildArrayField wells; RimSimWellInView* findWell(QString name); bool hasVisibleWellCells(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index efae6f033d..08d70733a5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -31,7 +31,7 @@ class RimSummaryCaseCollection : public caf::PdmObject public: RimSummaryCaseCollection(); virtual ~RimSummaryCaseCollection(); - + void removeCase(RimSummaryCase* summaryCase); void addCase(RimSummaryCase* summaryCase); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 5cdc0551eb..e210f4ecf0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -171,7 +171,7 @@ RimSummaryCurve::~RimSummaryCurve() //-------------------------------------------------------------------------------------------------- void RimSummaryCurve::setSummaryCaseY(RimSummaryCase* sumCase) { - m_yValuesSummaryCase = sumCase; + m_yValuesSummaryCase = sumCase; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 37cba228b0..19f1259b38 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -37,11 +37,11 @@ #include //-------------------------------------------------------------------------------------------------- -// e format as [-]9.9e[+|-]999 -// E format as[-]9.9E[+| -]999 -// f format as[-]9.9 -// g use e or f format, whichever is the most concise -// G use E or f format, whichever is the most concise +// e format as [-]9.9e[+|-]999 +// E format as[-]9.9E[+| -]999 +// f format as[-]9.9 +// g use e or f format, whichever is the most concise +// G use E or f format, whichever is the most concise //-------------------------------------------------------------------------------------------------- class DecimalScaleDraw : public QwtScaleDraw diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index c7ac11d455..b3dce95459 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -79,11 +79,11 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitFieldNoDefault(&m_curveFilters_OBSOLETE, "SummaryCurveFilters", "", "", "", ""); m_curveFilters_OBSOLETE.uiCapability()->setUiTreeHidden(true); - CAF_PDM_InitFieldNoDefault(&m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", ""); m_summaryCurveCollection.uiCapability()->setUiTreeHidden(true); m_summaryCurveCollection = new RimSummaryCurveCollection; - CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden(true); CAF_PDM_InitFieldNoDefault(&m_gridTimeHistoryCurves, "GridTimeHistoryCurves", "", "", "", ""); @@ -1302,7 +1302,7 @@ QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent) if ( m_summaryCurveCollection ) { - m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); + m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index b3393077f0..95e3a12522 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -164,7 +164,7 @@ class RimSummaryPlot : public RimViewWindow caf::PdmField m_userDefinedPlotTitle; caf::PdmChildArrayField m_gridTimeHistoryCurves; - caf::PdmChildField m_summaryCurveCollection; + caf::PdmChildField m_summaryCurveCollection; caf::PdmChildArrayField m_asciiDataCurves; caf::PdmField m_isAutoZoom; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index 5b017151c6..400c21721a 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -48,7 +48,7 @@ void CompletionDataFrame::setCompletionData(const std::vector //-------------------------------------------------------------------------------------------------- const std::map>& CompletionDataFrame::multipleCompletionsPerEclipseCell() const { - return m_multipleCompletionsPerEclipseCell; + return m_multipleCompletionsPerEclipseCell; } //-------------------------------------------------------------------------------------------------- @@ -69,22 +69,22 @@ void RigVirtualPerforationTransmissibilities::appendCompletionDataForWellPath( const std::vector& completions) { /* - auto item = m_mapFromWellToCompletionData.find(wellPath); - if (item != m_mapFromWellToCompletionData.end()) - { - item->second.setCompletionData - } + auto item = m_mapFromWellToCompletionData.find(wellPath); + if (item != m_mapFromWellToCompletionData.end()) + { + item->second.setCompletionData + } - auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); - if (it != m_multipleCompletionsPerEclipseCell.end()) - { - it->second.push_back(completion); - } - else - { - m_multipleCompletionsPerEclipseCell.insert(std::pair>( - completion.completionDataGridCell(), std::vector{completion})); - } + auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); + if (it != m_multipleCompletionsPerEclipseCell.end()) + { + it->second.push_back(completion); + } + else + { + m_multipleCompletionsPerEclipseCell.insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); + } */ } @@ -97,11 +97,11 @@ const std::map>& { static std::map> dummy; - auto item = m_mapFromWellToCompletionData.find(wellPath); - if (item != m_mapFromWellToCompletionData.end()) - { - return item->second[timeStepIndex].multipleCompletionsPerEclipseCell(); - } - + auto item = m_mapFromWellToCompletionData.find(wellPath); + if (item != m_mapFromWellToCompletionData.end()) + { + return item->second[timeStepIndex].multipleCompletionsPerEclipseCell(); + } + return dummy; } diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h index ac8968b725..b9dd803e22 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -40,8 +40,8 @@ class CompletionDataFrame void setCompletionData(const std::vector& completions); - const std::map>& - multipleCompletionsPerEclipseCell() const; + const std::map>& + multipleCompletionsPerEclipseCell() const; private: std::map> m_multipleCompletionsPerEclipseCell; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index 12aedfc108..cd3d095623 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -525,7 +525,7 @@ std::vector RigEclipseCaseData::simulationWellBranches(const //-------------------------------------------------------------------------------------------------- void RigEclipseCaseData::setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities) { - m_virtualPerforationTransmissibilities = virtualPerforationTransmissibilities; + m_virtualPerforationTransmissibilities = virtualPerforationTransmissibilities; } //-------------------------------------------------------------------------------------------------- @@ -533,7 +533,7 @@ void RigEclipseCaseData::setVirtualPerforationTransmissibilities(RigVirtualPerfo //-------------------------------------------------------------------------------------------------- const RigVirtualPerforationTransmissibilities* RigEclipseCaseData::virtualPerforationTransmissibilities() const { - return m_virtualPerforationTransmissibilities; + return m_virtualPerforationTransmissibilities; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index 15820eda53..ee95ae205a 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -111,8 +111,8 @@ class RigEclipseCaseData : public cvf::Object bool includeAllCellCenters, bool useAutoDetectionOfBranches) const; - void setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities); - const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const; + void setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities); + const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const; private: void computeActiveCellIJKBBox(); @@ -131,7 +131,7 @@ class RigEclipseCaseData : public cvf::Object cvf::ref m_activeFormationNamesData; - RigVirtualPerforationTransmissibilities* m_virtualPerforationTransmissibilities; + RigVirtualPerforationTransmissibilities* m_virtualPerforationTransmissibilities; cvf::Collection m_simWellData; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h index bab42e2063..04fd59e4d0 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h @@ -71,11 +71,11 @@ class RigEclipseNativeStatCalc : public RigStatisticsCalculator // Filter out inactive cells if (!actCellInfo->isActive(cIdx)) continue; - size_t cellResultIndex = cIdx; - if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex)) - { - cellResultIndex = actCellInfo->cellResultIndex(cIdx); - } + size_t cellResultIndex = cIdx; + if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex)) + { + cellResultIndex = actCellInfo->cellResultIndex(cIdx); + } if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size()) { diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h index afa65bded9..e67bf1daec 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h @@ -73,11 +73,11 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator { if (!(*m_cellVisibilities)[cIdx]) continue; - size_t cellResultIndex = cIdx; - if (m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex)) - { - cellResultIndex = actCellInfo->cellResultIndex(cIdx); - } + size_t cellResultIndex = cIdx; + if (m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex)) + { + cellResultIndex = actCellInfo->cellResultIndex(cIdx); + } if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size()) { diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 61faee12d5..1520a517ad 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -1,58 +1,58 @@ - AppLogo48x48.png - Default.png - NorthViewArrow.png - SouthViewArrow.png - EastViewArrow.png - WestViewArrow.png - UpViewArrow.png - DownViewArrow.png - CellFilter_Values.png - CellFilter_Range.png - CellResult.png - EdgeResult_1.png - EdgeResult_2.png - Legend.png - Plus.png - Minus.png - Save.png - Well.png - WellCollection.png + AppLogo48x48.png + Default.png + NorthViewArrow.png + SouthViewArrow.png + EastViewArrow.png + WestViewArrow.png + UpViewArrow.png + DownViewArrow.png + CellFilter_Values.png + CellFilter_Range.png + CellResult.png + EdgeResult_1.png + EdgeResult_2.png + Legend.png + Plus.png + Minus.png + Save.png + Well.png + WellCollection.png octave.png Folder.png EclipseInput48x48.png - Cases16x16.png - CreateGridCaseGroup16x16.png - GridCaseGroup16x16.png - Histogram16x16.png - Histograms16x16.png - ZoomAll16x16.png - draw_style_lines_24x24.png - draw_style_meshlines_24x24.png - draw_style_meshoutlines_24x24.png - draw_style_outlines_24x24.png - draw_style_surface_24x24.png - disable_lighting_24x24.png - SnapShot.png - SnapShotSave.png - SnapShotSaveViews.png - draw_style_faults_24x24.png + Cases16x16.png + CreateGridCaseGroup16x16.png + GridCaseGroup16x16.png + Histogram16x16.png + Histograms16x16.png + ZoomAll16x16.png + draw_style_lines_24x24.png + draw_style_meshlines_24x24.png + draw_style_meshoutlines_24x24.png + draw_style_outlines_24x24.png + draw_style_surface_24x24.png + disable_lighting_24x24.png + SnapShot.png + SnapShotSave.png + SnapShotSaveViews.png + draw_style_faults_24x24.png draw_style_faults_label_24x24.png Case48x48.png - GridModels.png - draw_style_WellCellsToRangeFilter_24x24.png - draw_style_surface_w_fault_mesh_24x24.png - InfoBox16x16.png - GeoMechCase48x48.png + GridModels.png + draw_style_WellCellsToRangeFilter_24x24.png + draw_style_surface_w_fault_mesh_24x24.png + InfoBox16x16.png + GeoMechCase48x48.png GeoMechCases48x48.png chain.png TileWindows24x24.png - LasFile16x16.png - WellLogTrack16x16.png - WellLogPlot16x16.png - WellLogPlots16x16.png - WellLogCurve16x16.png + LasFile16x16.png + WellLogTrack16x16.png + WellLogPlot16x16.png + WellLogPlots16x16.png + WellLogCurve16x16.png CrossSection16x16.png CrossSections16x16.png Refresh-32.png diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 84d84a8e0e..ff12893afe 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -145,18 +145,18 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId) // If the active mdi window is different from an Eclipse view, search through available mdi windows to find the last activated // Eclipse view. The sub windows are returned with the most recent activated window at the back. QList subWindows = RiuMainWindow::instance()->subWindowList(QMdiArea::ActivationHistoryOrder); - for (int i = subWindows.size() - 1; i > -1; i--) - { - RiuViewer* viewer = subWindows[i]->widget()->findChild(); - if (viewer) - { + for (int i = subWindows.size() - 1; i > -1; i--) + { + RiuViewer* viewer = subWindows[i]->widget()->findChild(); + if (viewer) + { RimEclipseView* riv = dynamic_cast(viewer->ownerReservoirView()); if (riv) { return riv->eclipseCase(); } - } - } + } + } } else { diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 47d5eccb7e..05251cf65e 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -1,6 +1,6 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_LIST_DIR}/RiaTestDataDirectory.h.cmake - ${CMAKE_BINARY_DIR}/Generated/RiaTestDataDirectory.h + ${CMAKE_BINARY_DIR}/Generated/RiaTestDataDirectory.h ) set (SOURCE_GROUP_HEADER_FILES diff --git a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp index e7af18e51a..28b849f60e 100644 --- a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp +++ b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp @@ -12,122 +12,122 @@ //-------------------------------------------------------------------------------------------------- TEST(DISABLED_HDFTests, BasicFileRead) { - std::string file_path = "D:/ResInsight/SourSim/PKMUNK_NOV_TEST_SS.sourpre.00001"; + std::string file_path = "D:/ResInsight/SourSim/PKMUNK_NOV_TEST_SS.sourpre.00001"; - try - { - H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately + try + { + H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately - H5::H5File file(file_path.c_str(), H5F_ACC_RDONLY); + H5::H5File file(file_path.c_str(), H5F_ACC_RDONLY); - { - H5::Group timestep = file.openGroup("Timestep_00001"); - H5::Attribute attr = timestep.openAttribute("timestep"); + { + H5::Group timestep = file.openGroup("Timestep_00001"); + H5::Attribute attr = timestep.openAttribute("timestep"); - double timestep_value = 0.0; + double timestep_value = 0.0; - H5::DataType type = attr.getDataType(); - attr.read(type, ×tep_value); + H5::DataType type = attr.getDataType(); + attr.read(type, ×tep_value); - //std::cout << "Timestep value " << timestep_value << std::endl; - EXPECT_NEAR(timestep_value, 1.0, 1e-1); - } + //std::cout << "Timestep value " << timestep_value << std::endl; + EXPECT_NEAR(timestep_value, 1.0, 1e-1); + } - { - // Group size is not an attribute! + { + // Group size is not an attribute! - H5::Group GridFunctions = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions"); + H5::Group GridFunctions = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions"); - hsize_t group_size = GridFunctions.getNumObjs(); + hsize_t group_size = GridFunctions.getNumObjs(); - //std::cout << "GridFunctions group_size " << group_size << std::endl; - EXPECT_EQ(size_t(20), group_size); + //std::cout << "GridFunctions group_size " << group_size << std::endl; + EXPECT_EQ(size_t(20), group_size); -/* for (hsize_t i = 0; i < group_size; i++) - { - // H5std_string node_name = GridFunctions.getObjnameByIdx(i); // crashes on VS2017 due to lib/heap/runtime differences to HDF5 VS2015 lib +/* for (hsize_t i = 0; i < group_size; i++) + { + // H5std_string node_name = GridFunctions.getObjnameByIdx(i); // crashes on VS2017 due to lib/heap/runtime differences to HDF5 VS2015 lib - std::string node_name; - node_name.resize(1024); + std::string node_name; + node_name.resize(1024); - ssize_t slen = GridFunctions.getObjnameByIdx(i, &node_name[0], 1023); + ssize_t slen = GridFunctions.getObjnameByIdx(i, &node_name[0], 1023); - node_name.resize(slen + 1); + node_name.resize(slen + 1); - std::cout << "GridFunctions sub-node name " << node_name << std::endl; - } + std::cout << "GridFunctions sub-node name " << node_name << std::endl; + } */ - std::string first_subnode(1024, '\0'); + std::string first_subnode(1024, '\0'); - ssize_t slen = GridFunctions.getObjnameByIdx(0, &first_subnode[0], 1023); - first_subnode.resize(slen + 1); + ssize_t slen = GridFunctions.getObjnameByIdx(0, &first_subnode[0], 1023); + first_subnode.resize(slen + 1); - EXPECT_TRUE(first_subnode.compare(0, slen, "GridFunction_00002") == 0); - } + EXPECT_TRUE(first_subnode.compare(0, slen, "GridFunction_00002") == 0); + } - { - H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); - H5::Attribute attr = GridFunction_00002.openAttribute("limits_max"); + { + H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); + H5::Attribute attr = GridFunction_00002.openAttribute("limits_max"); - double limits_max = 0.0; - - H5::DataType type = attr.getDataType(); - attr.read(type, &limits_max); + double limits_max = 0.0; + + H5::DataType type = attr.getDataType(); + attr.read(type, &limits_max); -// std::cout << "limits_max " << limits_max << std::endl; - EXPECT_NEAR(limits_max, 0.3970204292629652, 1e-10); - } +// std::cout << "limits_max " << limits_max << std::endl; + EXPECT_NEAR(limits_max, 0.3970204292629652, 1e-10); + } - { - H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); - H5::DataSet dataset = H5::DataSet(GridFunction_00002.openDataSet("values")); + { + H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); + H5::DataSet dataset = H5::DataSet(GridFunction_00002.openDataSet("values")); - hsize_t dims[2]; - H5::DataSpace dataspace = dataset.getSpace(); - dataspace.getSimpleExtentDims(dims, nullptr); + hsize_t dims[2]; + H5::DataSpace dataspace = dataset.getSpace(); + dataspace.getSimpleExtentDims(dims, nullptr); - std::vector values; - values.resize(dims[0]); - dataset.read(values.data(), H5::PredType::NATIVE_DOUBLE); + std::vector values; + values.resize(dims[0]); + dataset.read(values.data(), H5::PredType::NATIVE_DOUBLE); -/* for (hsize_t i = 0; i < dims[0]; i++) - { - std::cout << "value " << i << " " << values[i] << std::endl; +/* for (hsize_t i = 0; i < dims[0]; i++) + { + std::cout << "value " << i << " " << values[i] << std::endl; - } + } */ - EXPECT_NEAR(values[0], 0.32356910366452146, 1e-10); - EXPECT_NEAR(values[dims[0] - 1], 0.12200070891582514, 1e-10); - } - - - - } // end of try block - - - catch (H5::FileIException error) // catch failure caused by the H5File operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataSetIException error) // catch failure caused by the DataSet operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataSpaceIException error) // catch failure caused by the DataSpace operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataTypeIException error) // catch failure caused by the DataSpace operations - { - std::cout << error.getCDetailMsg(); - } + EXPECT_NEAR(values[0], 0.32356910366452146, 1e-10); + EXPECT_NEAR(values[dims[0] - 1], 0.12200070891582514, 1e-10); + } + + + + } // end of try block + + + catch (H5::FileIException error) // catch failure caused by the H5File operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataSetIException error) // catch failure caused by the DataSet operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataSpaceIException error) // catch failure caused by the DataSpace operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataTypeIException error) // catch failure caused by the DataSpace operations + { + std::cout << error.getCDetailMsg(); + } } diff --git a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp index a6faa68345..f75ad54b31 100644 --- a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp @@ -299,7 +299,7 @@ TEST(RifColumnBasedRsmspecParserTest, TestTwoPages) out << " OP-1 OP-1 OP-1 OP-1 OP-1 OP-1 \n"; out << "\n"; out << "\n"; - out << "1386 2003.170 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment \n"; + out << "1386 2003.170 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment \n"; out << "1436 2003.307 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment\n"; out << "1574 2003.685 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12\n"; out << "1636 2003.855 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12\n"; diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.cpp b/ApplicationCode/UserInterface/RiuCadNavigation.cpp index 6d61969abe..26a5869a62 100644 --- a/ApplicationCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuCadNavigation.cpp @@ -98,7 +98,7 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) m_trackball->endNavigation(); m_isNavigating = false; - if (m_hasMovedMouseDuringNavigation) isEventHandled = true; + if (m_hasMovedMouseDuringNavigation) isEventHandled = true; m_hasMovedMouseDuringNavigation = false; } diff --git a/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h b/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h index d8a130cf57..f12c64f7a4 100644 --- a/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h +++ b/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h @@ -43,17 +43,17 @@ class RiuCalculationsContextMenuManager : public QObject public: RiuCalculationsContextMenuManager() { } - void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc); + void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc); public slots: - void slotMenuItems(QPoint point); + void slotMenuItems(QPoint point); private slots: - void slotCreateCalculationCopy(); + void slotCreateCalculationCopy(); private: - QPointer m_widget; + QPointer m_widget; RicSummaryCurveCalculator* m_curveCalc; - int m_textPosition; + int m_textPosition; std::map> m_actionCache; }; diff --git a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h index 13721c5256..be54ed5a46 100644 --- a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h +++ b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h @@ -39,18 +39,18 @@ class RiuExpressionContextMenuManager : public QObject static const std::map> MENU_MAP; public: - RiuExpressionContextMenuManager() { } + RiuExpressionContextMenuManager() { } - void attachTextEdit(QTextEdit* textEdit); + void attachTextEdit(QTextEdit* textEdit); public slots: - void slotMenuItems(QPoint point); + void slotMenuItems(QPoint point); private slots: - void slotShowText(); + void slotShowText(); private: - QPointer m_textEdit; - int m_textPosition; + QPointer m_textEdit; + int m_textPosition; std::map> m_actionCache; }; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuMainPlotWindow.h index 2872200ee0..680e30498e 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.h @@ -75,7 +75,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase void tileWindows(); bool isAnyMdiSubWindowVisible(); QMdiSubWindow* findMdiSubWindow(QWidget* viewer); - QList subWindowList(QMdiArea::WindowOrder order); + QList subWindowList(QMdiArea::WindowOrder order); void addToTemporaryWidgets(QWidget* widget); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index ade02cc668..99d1107363 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -907,7 +907,7 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer) //-------------------------------------------------------------------------------------------------- QList RiuMainWindow::subWindowList(QMdiArea::WindowOrder order) { - return m_mdiArea->subWindowList(order); + return m_mdiArea->subWindowList(order); } //-------------------------------------------------------------------------------------------------- @@ -1727,7 +1727,7 @@ void RiuMainWindow::slotShowRegressionTestDialog() // Write preferences using QSettings and apply them to the application regTestConfig.writeSettingsToApplicationStore(); - RiaRegressionTestRunner::instance()->executeRegressionTests(); + RiaRegressionTestRunner::instance()->executeRegressionTests(); } } diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 8a16611012..f53ea53321 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -111,7 +111,7 @@ class RiuMainWindow : public RiuMainWindowBase void tileWindows(); bool isAnyMdiSubWindowVisible(); QMdiSubWindow* findMdiSubWindow(QWidget* viewer); - QList subWindowList(QMdiArea::WindowOrder order); + QList subWindowList(QMdiArea::WindowOrder order); RiuResultQwtPlot* resultPlot(); RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel(); diff --git a/ApplicationCode/UserInterface/RiuMessagePanel.h b/ApplicationCode/UserInterface/RiuMessagePanel.h index 133f1c295f..7cda43dff8 100644 --- a/ApplicationCode/UserInterface/RiuMessagePanel.h +++ b/ApplicationCode/UserInterface/RiuMessagePanel.h @@ -40,7 +40,7 @@ class RiuMessagePanel : public QWidget explicit RiuMessagePanel(QDockWidget* parent); void addMessage(RILogLevel messageLevel, const QString& msg); - virtual QSize sizeHint () const; + virtual QSize sizeHint () const; private slots: void slotShowContextMenu(const QPoint& pos); diff --git a/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc b/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc index e245321471..f599c5919c 100644 --- a/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc +++ b/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc @@ -1,16 +1,16 @@ - Play.png - Stop.png - Pause.png - StepFwd.png - StepBwd.png - SkipToEnd.png - SkipToStart.png - RepeatFromStart.png - RepeatFwdBwd.png - PlayBwd.png - Slow.png - Fast.png - + Play.png + Stop.png + Pause.png + StepFwd.png + StepBwd.png + SkipToEnd.png + SkipToStart.png + RepeatFromStart.png + RepeatFwdBwd.png + PlayBwd.png + Slow.png + Fast.png + From e13702a88ad7ab7c157884e8cf236830676c9260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 12 Mar 2018 09:21:27 +0100 Subject: [PATCH 0481/1027] #2485 Intersection. Field controlling polylines visibility --- .../Intersections/RivIntersectionPartMgr.cpp | 8 ++++--- .../Intersections/RivIntersectionPartMgr.h | 3 ++- .../Rim2dIntersectionView.cpp | 21 +++++++++++++++++-- .../ProjectDataModel/Rim2dIntersectionView.h | 4 +++- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 2 +- .../ProjectDataModel/RimIntersection.cpp | 8 +++++++ .../ProjectDataModel/RimIntersection.h | 1 + .../RimIntersectionCollection.cpp | 4 ++-- .../RimIntersectionCollection.h | 3 ++- 10 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 33a7653e30..c6c5c28f12 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -915,9 +915,11 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +void RivIntersectionPartMgr::appendPolylinePartsToModel(Rim3dView &view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform) { - if (m_rimCrossSection->inputPolyLineFromViewerEnabled) + Rim2dIntersectionView* curr2dView = dynamic_cast(&view); + + if (m_rimCrossSection->inputPolyLineFromViewerEnabled || (curr2dView && curr2dView->showDefiningPoints())) { if (m_highlightLineAlongPolyline.notNull()) { @@ -947,7 +949,7 @@ void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* mod } } - if (m_rimCrossSection->inputTwoAzimuthPointsFromViewerEnabled) + if (m_rimCrossSection->inputTwoAzimuthPointsFromViewerEnabled || (curr2dView && curr2dView->showDefiningPoints())) { if (m_highlightLineAlongPolyline.notNull()) { diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 5009e81451..1bdd72cd3d 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -44,6 +44,7 @@ class RigFemResultAddress; class RigGeoMechCaseData; class RigMainGrid; class RigResultAccessor; +class Rim3dView; class RimCellEdgeColors; class RimEclipseCellColors; class RimIntersection; @@ -71,7 +72,7 @@ class RivIntersectionPartMgr : public cvf::Object void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); const RimIntersection* intersection() const; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 433e5f0313..fe04c5186b 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -72,6 +72,8 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) m_ternaryLegendConfig.xmlCapability()->disableIO(); m_ternaryLegendConfig = new RimTernaryLegendConfig(); + CAF_PDM_InitField(&m_showDefiningPoints, "ShowDefiningPoints", true, "Show Points", "", "", ""); + m_showWindow = false; m_scaleTransform = new cvf::Transform(); m_intersectionVizModel = new cvf::ModelBasicList; @@ -298,6 +300,14 @@ cvf::ref Rim2dIntersectionView::displayCoordTransfor return dispTx; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::showDefiningPoints() const +{ + return m_showDefiningPoints; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -396,7 +406,7 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); - m_flatIntersectionPartMgr->appendPolylinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendPolylinePartsToModel(*this, m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendWellPipePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->applySingleColorEffect(); @@ -572,7 +582,8 @@ void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedF { Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == & m_intersection) + if (changedField == & m_intersection || + changedField == &m_showDefiningPoints) { this->loadDataAndUpdate(); } @@ -587,4 +598,10 @@ void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd uiOrdering.add(&m_intersection); Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); + + if (m_intersection->hasDefiningPoints()) + { + caf::PdmUiGroup* plGroup = uiOrdering.addNewGroup("Defining Points"); + plGroup->add(&m_showDefiningPoints); + } } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 8db542c59c..acdaf9e92c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -63,6 +63,8 @@ class Rim2dIntersectionView : public Rim3dView virtual cvf::ref displayCoordTransform() const override; + bool showDefiningPoints() const; + protected: void updateLegends(); @@ -96,5 +98,5 @@ class Rim2dIntersectionView : public Rim3dView cvf::ref m_intersectionVizModel; cvf::ref m_scaleTransform; - + caf::PdmField m_showDefiningPoints; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 4cd135d4a7..e0a2ae4632 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -477,7 +477,7 @@ void RimEclipseView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - m_crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); + m_crossSectionCollection->appendPartsToModel(*this, m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); // Well path model diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 0adf95a227..286274896d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -231,7 +231,7 @@ void RimGeoMechView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - m_crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), scaleTransform()); + m_crossSectionCollection->appendPartsToModel(*this, m_crossSectionVizModel.p(), scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); // If the animation was active before recreating everything, make viewer view current frame diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 0764e6ee48..1b72d4929d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -909,6 +909,14 @@ void RimIntersection::recomputeSimulationWellBranchData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIntersection::hasDefiningPoints() const +{ + return type == CS_POLYLINE || type == CS_AZIMUTHLINE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index f8491c416d..2ffcf3c1fe 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -102,6 +102,7 @@ class RimIntersection : public caf::PdmObject void setLengthDown(double heightDown); void recomputeSimulationWellBranchData(); + bool hasDefiningPoints() const; protected: virtual caf::PdmFieldHandle* userDescriptionField(); diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index 10e015a828..f18423d6b8 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -122,7 +122,7 @@ void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +void RimIntersectionCollection::appendPartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform) { if (!isActive) return; @@ -132,7 +132,7 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c { cs->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform); cs->intersectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform); - cs->intersectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform); + cs->intersectionPartMgr()->appendPolylinePartsToModel(view, model, scaleTransform); } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index bb463c263a..12b0fd9eac 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -23,6 +23,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" +class Rim3dView; class RimIntersection; class RimIntersectionBox; class RimEclipseCellColors; @@ -70,7 +71,7 @@ class RimIntersectionCollection : public caf::PdmObject void updateCellResultColor(size_t timeStepIndex, const cvf::ScalarMapper* scalarColorMapper, const RivTernaryScalarMapper* ternaryColorMapper); - void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + void appendPartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); std::vector intersections() const; std::vector intersectionBoxes() const; From 1e8f1bb95ed157d1f61caa14032ff53a974302a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 12 Mar 2018 15:14:22 +0100 Subject: [PATCH 0482/1027] #2589 intersections. Show extrusion line fix --- .../RivIntersectionGeometryGenerator.cpp | 47 +++++++++++++++++-- .../RivIntersectionGeometryGenerator.h | 14 +++--- .../Intersections/RivIntersectionPartMgr.cpp | 4 +- .../ProjectDataModel/RimIntersection.cpp | 8 +--- .../ProjectDataModel/RimIntersection.h | 2 +- .../cafDisplayCoordTransform.h | 5 +- 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 85bc42b96a..d5f166e4c7 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -23,11 +23,13 @@ #include "RigResultAccessor.h" #include "RimIntersection.h" +#include "Rim3dView.h" #include "RivHexGridIntersectionTools.h" #include "RivIntersectionPartMgr.h" #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" +#include "cafDisplayCoordTransform.h" #include "cvfDrawableGeo.h" #include "cvfGeometryTools.h" @@ -40,6 +42,16 @@ #include "RivSectionFlattner.h" +cvf::ref displayCoordTransform(const RimIntersection* intersection) +{ + Rim3dView* rimView = nullptr; + intersection->firstAncestorOrThisOfType(rimView); + CVF_ASSERT(rimView); + + cvf::ref transForm = rimView->displayCoordTransform(); + return transForm; +} + //-------------------------------------------------------------------------------------------------- /// isFlattened means to transform each flat section of the intersection onto the XZ plane /// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge @@ -399,6 +411,22 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly return createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine) +{ + cvf::ref transform = displayCoordTransform(crossSection()); + std::vector displayCoords; + + for (const auto& pt : extrusionLine) + { + displayCoords.push_back(transform->translateToDisplayCoord(pt)); + } + + return createLineAlongPolylineDrawable(std::vector>({ displayCoords })); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -407,8 +435,6 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly std::vector lineIndices; std::vector vertices; - cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); - for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) { const std::vector& polyLine = polyLines[pLineIdx]; @@ -450,6 +476,21 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol return createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createPointsFromExtrusionLineDrawable(const std::vector& extrusionLine) +{ + cvf::ref transform = displayCoordTransform(crossSection()); + std::vector displayCoords; + + for (const auto& pt : extrusionLine) + { + displayCoords.push_back(transform->translateToDisplayCoord(pt)); + } + + return createPointsFromPolylineDrawable(std::vector>({displayCoords})); +} //-------------------------------------------------------------------------------------------------- /// @@ -458,8 +499,6 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol { std::vector vertices; - cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); - for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) { const std::vector& polyLine = polyLines[pLineIdx]; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 8338e073a8..5886659644 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -61,10 +61,9 @@ class RivIntersectionGeometryGenerator : public cvf::Object cvf::ref generateSurface(); cvf::ref createMeshDrawable(); cvf::ref createLineAlongPolylineDrawable(); + cvf::ref createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine); cvf::ref createPointsFromPolylineDrawable(); - - cvf::ref createLineAlongPolylineDrawable(const std::vector >& polyLines); - cvf::ref createPointsFromPolylineDrawable(const std::vector >& polyLines); + cvf::ref createPointsFromExtrusionLineDrawable(const std::vector& extrusionLine); const std::vector >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; } @@ -78,13 +77,16 @@ class RivIntersectionGeometryGenerator : public cvf::Object cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); private: + cvf::ref createLineAlongPolylineDrawable(const std::vector >& polyLines); + cvf::ref createPointsFromPolylineDrawable(const std::vector >& polyLines); + void calculateArrays(); void calculateSegementTransformPrLinePoint(); void calculateFlattenedOrOffsetedPolyline(); - static size_t indexToNextValidPoint(const std::vector& polyLine, - const cvf::Vec3d extrDir, - size_t idxToStartOfLineSegment); + //static size_t indexToNextValidPoint(const std::vector& polyLine, + // const cvf::Vec3d extrDir, + // size_t idxToStartOfLineSegment); RimIntersection* m_crossSection; cvf::cref m_hexGrid; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index c6c5c28f12..9aeb67be8f 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -647,7 +647,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS) { { - cvf::ref polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); + cvf::ref polylineGeo = m_crossSectionGenerator->createLineAlongExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); if (polylineGeo.notNull()) { if (useBufferObjects) @@ -679,7 +679,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) } } - cvf::ref polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); + cvf::ref polylinePointsGeo = m_crossSectionGenerator->createPointsFromExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); if (polylinePointsGeo.notNull()) { if (useBufferObjects) diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 1b72d4929d..7a16add90a 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -477,13 +477,9 @@ RivIntersectionPartMgr* RimIntersection::intersectionPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > RimIntersection::polyLinesForExtrusionDirection() const +std::vector RimIntersection::polyLinesForExtrusionDirection() const { - std::vector< std::vector > lines; - - lines.push_back(m_customExtrusionPoints); - - return lines; + return m_customExtrusionPoints; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 2ffcf3c1fe..9459910f44 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -90,7 +90,7 @@ class RimIntersection : public caf::PdmObject Rim2dIntersectionView* correspondingIntersectionView(); RivIntersectionPartMgr* intersectionPartMgr(); - std::vector< std::vector > polyLinesForExtrusionDirection() const; + std::vector polyLinesForExtrusionDirection() const; void appendPointToExtrusionDirection(const cvf::Vec3d& point); void appendPointToAzimuthLine(const cvf::Vec3d& point); diff --git a/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h b/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h index f4e73ceda7..3e31256cd8 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h +++ b/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h @@ -20,15 +20,14 @@ class DisplayCoordTransform : public cvf::Object void setTranslation(const cvf::Vec3d& translation); cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const; + cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const; + cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const; cvf::Vec3d translateToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d transformToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d scaleToDomainSize(const cvf::Vec3d& displaySize) const; -private: - cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const; - private: cvf::Vec3d m_scale; cvf::Vec3d m_translation; From 3da3856c51588cfdce67eaf0fa187d2f63fbe7a4 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 12 Mar 2018 16:18:40 +0100 Subject: [PATCH 0483/1027] #2591 3D well log curves: Add grid along well path --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 147 +++++++++++++++++- .../Riv3dWellLogCurveGeomertyGenerator.h | 21 ++- .../Riv3dWellLogPlanePartMgr.cpp | 85 ++-------- .../Riv3dWellLogPlanePartMgr.h | 6 - 4 files changed, 179 insertions(+), 80 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index d4bd45633e..faf9f81ee7 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,13 +18,20 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "RigWellPath.h" + #include "cvfPrimitiveSetIndexedUInt.h" +#include "cafDisplayCoordTransform.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogCurveGeometryGenerator::createDrawable(const std::vector& vertices, const std::vector& indices) const +cvf::ref Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const { + std::vector vertices = createCurveVertices(rim3dWellLogCurve, displayCoordTransform); + std::vector indices = createPolylineIndices(vertices.size()); + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); @@ -38,3 +45,141 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createDrawable(co return drawable; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const +{ + std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + + std::vector vertices; + vertices.reserve(wellPathPoints.size() * 2); + + std::vector curveNormals; + curveNormals.reserve(wellPathPoints.size()); + + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + { + cvf::Vec3d z = zForDrawPlane(rim3dWellLogCurve->drawPlane()); + cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i + 1], z); + + curveNormals.push_back(y); + } + + std::vector indices; + vertices.reserve(wellPathPoints.size() * 2); + + cvf::uint counter = 0; + + for (size_t i = 0; i < curveNormals.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i]))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 100))); + + indices.push_back(counter++); + indices.push_back(counter++); + } + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref drawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + drawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + drawable->setVertexArray(vertexArray.p()); + + return drawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogCurveGeometryGenerator::createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform) const +{ + std::vector wellPathPoints; + wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + + std::vector vertices; + vertices.resize(wellPathPoints.size()); + + std::vector curveNormals; + curveNormals.reserve(wellPathPoints.size()); + + + for (size_t i = 0; i < wellPathPoints.size() - 1; i += 2) + { + cvf::Vec3d z = zForDrawPlane(rim3dWellLogCurve->drawPlane()); + + cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i+1], z); + + curveNormals.push_back(y); + curveNormals.push_back(y); + } + + for (size_t i = 0; i < curveNormals.size(); i++) + { + vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 30)); + } + + return vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogCurveGeometryGenerator::createPolylineIndices(size_t vertexCount) const +{ + std::vector indices; + indices.resize((vertexCount - 1) * 2); + + cvf::uint counter = 0; + for (size_t i = 0; i < indices.size(); i++) + { + indices[i] = counter; + if (i % 2 == 0) counter++; + } + + return indices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::normalBetweenPoints(const cvf::Vec3d& pt1, const cvf::Vec3d& pt2, const cvf::Vec3d& z) const +{ + cvf::Vec3d x = (pt2 - pt1).getNormalized(); + + return (z ^ x).getNormalized(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const +{ + if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_LEFT) + { + return cvf::Vec3d(0, 0, -1); + } + else if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_RIGHT) + { + return cvf::Vec3d(0, 0, 1); + } + else if (drawPlane == Rim3dWellLogCurve::VERTICAL_ABOVE) + { + return cvf::Vec3d(0, -1, 0); + } + else if (drawPlane == Rim3dWellLogCurve::VERTICAL_BELOW) + { + return cvf::Vec3d(0, 1, 0); + } + else + { + //Default: Horizontal left + return cvf::Vec3d(0, 0, -1); + } +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index aaf6c6b838..f21b31c6e9 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -25,6 +25,8 @@ #include "cafPdmPointer.h" +#include "Rim3dWellLogCurve.h" + #include namespace caf @@ -32,10 +34,25 @@ namespace caf class DisplayCoordTransform; } +class RigWellPath; + class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator() = default; + Riv3dWellLogCurveGeometryGenerator(RigWellPath* wellPathGeometry) : m_wellPathGeometry(wellPathGeometry) {}; + + cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; + cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; + +private: + std::vector createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform) const; + + std::vector createPolylineIndices(size_t vertexCount) const; + + cvf::Vec3d normalBetweenPoints(const cvf::Vec3d& pt1, const cvf::Vec3d& pt2, const cvf::Vec3d& z) const; + cvf::Vec3d zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const; - cvf::ref createDrawable(const std::vector& vertices, const std::vector& indices ) const; +private: + cvf::ref m_wellPathGeometry; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index ca31bd4d8e..eda868f180 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -25,6 +25,8 @@ #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" +#include "cvfColor3.h" +#include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" #include "cvfPart.h" @@ -45,20 +47,17 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* { if (rim3dWellLogCurves.empty()) return; - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator; - - std::vector indices = createPolylineIndices(m_wellPathGeometry->m_wellPathPoints.size()); + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPathGeometry.p()); for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { - std::vector vertices = createCurveVertices(rim3dWellLogCurve, displayCoordTransform); - cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); + cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); cvf::ref effect = surfaceGen.generateCachedEffect(); cvf::ref part = new cvf::Part; - part->setDrawable(drawable.p()); + part->setDrawable(curveDrawable.p()); part->setEffect(effect.p()); if (part.notNull()) @@ -66,75 +65,19 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model->addPart(part.p()); } } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogPlanePartMgr::createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, - const caf::DisplayCoordTransform* displayCoordTransform) -{ - std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + //TODO: Atm, only the grid for the first curve is drawn. + cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0]); - std::vector vertices; - vertices.resize(wellPathPoints.size()); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 255, 0, 1), caf::PO_1); + cvf::ref effect = surfaceGen.generateCachedEffect(); - std::vector curveNormals; - curveNormals.reserve(wellPathPoints.size()); + cvf::ref part = new cvf::Part; + part->setDrawable(gridDrawable.p()); + part->setEffect(effect.p()); - for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + if (part.notNull()) { - cvf::Vec3d wellPathSegment = wellPathPoints[i + 1] - wellPathPoints[i]; - - cvf::Vec3d normVec; - if (rim3dWellLogCurve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_LEFT) - { - normVec = -wellPathSegment.perpendicularVector(); - } - else - { - normVec = wellPathSegment.perpendicularVector(); - } - curveNormals.push_back((wellPathSegment ^ normVec).getNormalized()*30); + model->addPart(part.p()); } - - cvf::Vec3d wellPathSegment = wellPathPoints[wellPathPoints.size()-1] - wellPathPoints[wellPathPoints.size() - 2]; - cvf::Vec3d normVec = wellPathSegment.perpendicularVector(); - curveNormals.push_back((wellPathSegment ^ normVec).getNormalized() * 30); - - for (size_t i = 0; i < curveNormals.size(); i++) - { - cvf::Mat4d transMat; - transMat.setTranslation(curveNormals[i]); - - vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); - } - -// cvf::Mat4d transMat; -// transMat.setTranslation(cvf::Vec3d(0, 0, 10)); -// -// for (size_t i = 0; i < wellPathPoints.size(); i++) -// { -// vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); -// } - - return vertices; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogPlanePartMgr::createPolylineIndices(size_t vertexCount) -{ - std::vector indices; - indices.resize((vertexCount - 1) * 2); - - cvf::uint counter = 0; - for (size_t i = 0; i < indices.size(); i++) - { - indices[i] = counter; - if (i % 2 == 0) counter++; - } - - return indices; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index aff90e8f36..f2eff10511 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -20,7 +20,6 @@ #include "cvfBase.h" #include "cvfObject.h" -#include "cvfVector3.h" #include "Rim3dWellLogCurve.h" @@ -31,7 +30,6 @@ namespace cvf { class ModelBasicList; - class Part; } namespace caf @@ -50,10 +48,6 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, std::vector rim3dWellLogCurves); -private: - std::vector createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, - const caf::DisplayCoordTransform* displayCoordTransform); - std::vector createPolylineIndices(size_t vertexCount); private: cvf::ref m_3dWellLogCurveGeometryGenerator; From cf4830e0ad4e77c96ee5b3605516378b7607e1a0 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Mar 2018 09:25:29 +0100 Subject: [PATCH 0484/1027] #2592 3D well log curves: Visualize results --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 109 ++++++++++++------ .../Riv3dWellLogCurveGeomertyGenerator.h | 8 +- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 70 ++++++++++- .../ProjectDataModel/Rim3dWellLogCurve.h | 2 + .../ReservoirDataModel/RigCurveDataTools.h | 2 - 5 files changed, 146 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index faf9f81ee7..331dd07e21 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,22 +18,26 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "RigCurveDataTools.h" #include "RigWellPath.h" -#include "cvfPrimitiveSetIndexedUInt.h" #include "cafDisplayCoordTransform.h" - +#include "cvfPrimitiveSetIndexedUInt.h" //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const +cvf::ref + Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, + const Rim3dWellLogCurve* rim3dWellLogCurve) const { - std::vector vertices = createCurveVertices(rim3dWellLogCurve, displayCoordTransform); - std::vector indices = createPolylineIndices(vertices.size()); + std::vector vertices; + std::vector indices; + + createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, &vertices, &indices); cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); + cvf::ref indexArray = new cvf::UIntArray(indices); cvf::ref drawable = new cvf::DrawableGeo(); @@ -47,9 +51,10 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createCurveLine(c } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const +cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const Rim3dWellLogCurve* rim3dWellLogCurve) const { std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; @@ -82,7 +87,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); + cvf::ref indexArray = new cvf::UIntArray(indices); cvf::ref drawable = new cvf::DrawableGeo(); @@ -96,60 +101,88 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform) const +void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform, + std::vector* vertices, + std::vector* indices) const { + std::vector resultValues; + std::vector mds; + rim3dWellLogCurve->resultValuesAndMds(&resultValues, &mds); + + CVF_ASSERT(resultValues.size() == mds.size()); + std::vector wellPathPoints; - wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + wellPathPoints.reserve(mds.size()); - std::vector vertices; - vertices.resize(wellPathPoints.size()); + for (double md : mds) + { + wellPathPoints.push_back(m_wellPathGeometry->interpolatedPointAlongWellPath(md)); + } + + vertices->resize(wellPathPoints.size()); std::vector curveNormals; curveNormals.reserve(wellPathPoints.size()); - for (size_t i = 0; i < wellPathPoints.size() - 1; i += 2) { cvf::Vec3d z = zForDrawPlane(rim3dWellLogCurve->drawPlane()); - cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i+1], z); + cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i + 1], z); curveNormals.push_back(y); curveNormals.push_back(y); } - for (size_t i = 0; i < curveNormals.size(); i++) + double maxResult = -HUGE_VAL; + double minResult = HUGE_VAL; + + for (double result : resultValues) { - vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 30)); - } + if (!RigCurveDataTools::isValidValue(result, false)) continue; - return vertices; -} + maxResult = std::max(result, maxResult); + minResult = std::min(result, minResult); + } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::createPolylineIndices(size_t vertexCount) const -{ - std::vector indices; - indices.resize((vertexCount - 1) * 2); + double range = maxResult - minResult; + double factor = 60.0 / range; - cvf::uint counter = 0; - for (size_t i = 0; i < indices.size(); i++) + for (size_t i = 0; i < curveNormals.size(); i++) { - indices[i] = counter; - if (i % 2 == 0) counter++; + cvf::Vec3d result(0, 0, 0); + + if (RigCurveDataTools::isValidValue(resultValues[i], false)) + { + result = resultValues[i] * factor * curveNormals[i]; + } + + (*vertices)[i] = + cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 30 + result)); } - return indices; + std::vector> valuesIntervals = + RigCurveDataTools::calculateIntervalsOfValidValues(resultValues, false); + + for (const std::pair& interval : valuesIntervals) + { + for (size_t i = interval.first; i < interval.second; i++) + { + indices->push_back(cvf::uint(i)); + indices->push_back(cvf::uint(i + 1)); + } + } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::normalBetweenPoints(const cvf::Vec3d& pt1, const cvf::Vec3d& pt2, const cvf::Vec3d& z) const +cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::normalBetweenPoints(const cvf::Vec3d& pt1, + const cvf::Vec3d& pt2, + const cvf::Vec3d& z) const { cvf::Vec3d x = (pt2 - pt1).getNormalized(); @@ -157,7 +190,7 @@ cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::normalBetweenPoints(const cvf::Ve } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const { @@ -179,7 +212,7 @@ cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::zForDrawPlane(const Rim3dWellLogC } else { - //Default: Horizontal left + // Default: Horizontal left return cvf::Vec3d(0, 0, -1); } } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index f21b31c6e9..d2c72e91f1 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -45,10 +45,10 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; private: - std::vector createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, - const caf::DisplayCoordTransform* displayCoordTransform) const; - - std::vector createPolylineIndices(size_t vertexCount) const; + void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform, + std::vector* vertices, + std::vector* indices) const; cvf::Vec3d normalBetweenPoints(const cvf::Vec3d& pt1, const cvf::Vec3d& pt2, const cvf::Vec3d& z) const; cvf::Vec3d zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 403416b007..bb19b4f851 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,6 +18,10 @@ #include "Rim3dWellLogCurve.h" +#include "RiaApplication.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigGeoMechWellLogExtractor.h" +#include "RigResultAccessorFactory.h" #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -26,7 +30,10 @@ #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" #include "RimTools.h" +#include "RimWellLogPlotCollection.h" //================================================================================================== /// @@ -148,6 +155,68 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, std::vector* measuredDepthValues) const +{ + CAF_ASSERT(resultValues != nullptr); + CAF_ASSERT(measuredDepthValues != nullptr); + + RimProject* proj = RiaApplication::instance()->project(); + + RimMainPlotCollection* mainPlotCollection = proj->mainPlotCollection; + if (!mainPlotCollection) return; + + RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection(); + if (!wellLogCollection) return; + + cvf::ref eclExtractor; + cvf::ref geomExtractor; + + RimWellPath* wellPath; + firstAncestorOrThisOfType(wellPath); + + RimEclipseCase* eclipseCase = dynamic_cast(m_case()); + + if (eclipseCase) + { + eclExtractor = wellLogCollection->findOrCreateExtractor(wellPath, eclipseCase); + } + else + { + RimGeoMechCase* geomCase = dynamic_cast(m_case()); + if (geomCase) + { + geomExtractor = wellLogCollection->findOrCreateExtractor(wellPath, geomCase); + } + } + + if (eclExtractor.notNull() && eclipseCase) + { + *measuredDepthValues = eclExtractor->measuredDepth(); + + m_eclipseResultDefinition->loadResult(); + + cvf::ref resAcc = RigResultAccessorFactory::createFromResultDefinition(eclipseCase->eclipseCaseData(), + 0, + m_timeStep, + m_eclipseResultDefinition); + if (resAcc.notNull()) + { + eclExtractor->curveData(resAcc.p(), resultValues); + } + } + else if (geomExtractor.notNull()) + { + *measuredDepthValues = geomExtractor->measuredDepth(); + + m_geomResultDefinition->loadResult(); + + geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, resultValues); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -222,7 +291,6 @@ void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin else if (geomCase) { m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); - } if ((eclipseCase && m_eclipseResultDefinition->hasDynamicResult()) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 60d1779533..85c3957c22 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -68,6 +68,8 @@ class Rim3dWellLogCurve : public caf::PdmObject DrawPlane drawPlane() const; + void resultValuesAndMds(std::vector* resultValues, std::vector* measuredDepthValues) const; + private: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h index ab195f241f..0e812e5540 100644 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h @@ -60,8 +60,6 @@ class RigCurveDataTools static std::vector> computePolyLineStartStopIndices(const CurveIntervals& intervals); public: - // Helper methods, available as public to be able to access from unit tests - static bool isValidValue(double value, bool allowPositiveValuesOnly); }; From 60adcf299a409af9f44ef1abce0f73dc777d3f52 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Mar 2018 09:42:54 +0100 Subject: [PATCH 0485/1027] Fix build. include cmath --- .../ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 331dd07e21..451cf5fd25 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -24,6 +24,8 @@ #include "cafDisplayCoordTransform.h" #include "cvfPrimitiveSetIndexedUInt.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From ae077b86fdf396ce4b3eb9d25bf7282cb24b8d2e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Mar 2018 10:55:35 +0100 Subject: [PATCH 0486/1027] lenght -> length --- .../ModelVisualization/RivPipeGeometryGenerator.cpp | 4 ++-- ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index a4cdfa198f..6abefded1b 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -474,7 +474,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords() const size_t lastOriginalCoordIdx = m_originalPipeCenterCoords->size() - 1; - size_t firstSegmentWithLength = findFirstSegmentWithLenght(squareDistanceTolerance); + size_t firstSegmentWithLength = findFirstSegmentWithLength(squareDistanceTolerance); // Return if we have only zero-length segments @@ -562,7 +562,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RivPipeGeometryGenerator::findFirstSegmentWithLenght(double squareDistanceTolerance) +size_t RivPipeGeometryGenerator::findFirstSegmentWithLength(double squareDistanceTolerance) { size_t segIdx; for ( segIdx = 0; segIdx < m_originalPipeCenterCoords->size() - 1; segIdx++ ) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h index 368f9c8fe1..f4fe97922c 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h @@ -69,7 +69,7 @@ class RivPipeGeometryGenerator : public cvf::Object void clearComputedData(); void updateFilteredPipeCenterCoords(); - size_t findFirstSegmentWithLenght(double squareDistanceTolerance); + size_t findFirstSegmentWithLength(double squareDistanceTolerance); static void computeCircle(double radius, size_t tesselationCount, const cvf::Vec3d& center, const cvf::Vec3d& orient1, const cvf::Vec3d& orient2, std::vector* nodes); From 2fa820233214c7f1edc7511ee87222ab4b4f3a17 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 13 Mar 2018 11:18:25 +0100 Subject: [PATCH 0487/1027] #2592 3D well log curves: Update curves after editing properties --- .../Riv3dWellLogPlanePartMgr.cpp | 2 ++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 29 ++++++++++++++++++- .../ProjectDataModel/Rim3dWellLogCurve.h | 3 ++ .../RimEclipseResultDefinition.cpp | 19 ++++++++++-- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index eda868f180..9e47635edc 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -51,6 +51,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { + if (!rim3dWellLogCurve->toggleState()) continue; + cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index bb19b4f851..ab61bb41a5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -118,6 +118,16 @@ Rim3dWellLogCurve::~Rim3dWellLogCurve() delete m_eclipseResultDefinition; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::updateCurveIn3dView() +{ + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->createDisplayModelAndRedrawAllViews(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -155,6 +165,14 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurve::toggleState() const +{ + return m_showCurve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -230,7 +248,16 @@ caf::PdmFieldHandle* Rim3dWellLogCurve::objectToggleField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + if (changedField == &m_showCurve) + { + proj->reloadCompletionTypeResultsInAllViews(); + } + else + { + proj->createDisplayModelAndRedrawAllViews(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 85c3957c22..0276569ed6 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -64,9 +64,12 @@ class Rim3dWellLogCurve : public caf::PdmObject Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); + void updateCurveIn3dView(); + void setPropertiesFromView(Rim3dView* view); DrawPlane drawPlane() const; + bool toggleState() const; void resultValuesAndMds(std::vector* resultValues, std::vector* measuredDepthValues) const; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index cab12ec2de..30e3821ca9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -25,6 +25,8 @@ #include "RigEclipseCaseData.h" #include "RigFlowDiagResultAddress.h" +#include "Rim3dView.h" +#include "Rim3dWellLogCurve.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -33,12 +35,11 @@ #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" +#include "RimGridTimeHistoryCurve.h" #include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimReservoirCellResultsStorage.h" -#include "Rim3dView.h" #include "RimViewLinker.h" -#include "RimGridTimeHistoryCurve.h" #include "RimWellLogExtractionCurve.h" #include "cafPdmUiListEditor.h" @@ -336,6 +337,13 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() { curve->updateConnectedEditors(); } + + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -434,6 +442,13 @@ void RimEclipseResultDefinition::loadDataAndUpdate() { curve->loadDataAndUpdate(true); } + + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->updateCurveIn3dView(); + } } //-------------------------------------------------------------------------------------------------- From 28830d3a1bb13f9b4a8bd2b9d3ec8e222f8fcfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 13 Mar 2018 13:26:12 +0100 Subject: [PATCH 0488/1027] #2480 2d intersection view. Adjusted category legends position --- ApplicationCode/UserInterface/RiuViewer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 4377d47c93..ac9fe87deb 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -561,14 +561,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); if (catLegend) { - if (catLegend->categoryCount() > categoryThreshold) - { - categoryLegends.push_back(catLegend); - } - else - { - catLegend->setSizeHint(cvf::Vec2ui(200, 200)); - } + categoryLegends.push_back(catLegend); } else { @@ -594,8 +587,15 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) for (auto catLegend : categoryLegends) { catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight - 2*edgeAxisBorderHeight)); + if (catLegend->categoryCount() > categoryThreshold) + { + catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2 * border - axisCrossHeight - 2 * edgeAxisBorderHeight)); + } + else + { + catLegend->setSizeHint(cvf::Vec2ui(200, 200)); + } xPos += categoryWidth + border; } From 15e242d1e3411a3bcaea8dacbeec6d2077afa8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 13 Mar 2018 15:15:02 +0100 Subject: [PATCH 0489/1027] #2479 2dIntersectionView. Remove 2dIntersectionViewCollection toggle in project tree --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 11 +---------- .../Rim2dIntersectionViewCollection.cpp | 18 ------------------ .../Rim2dIntersectionViewCollection.h | 5 ----- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index fe04c5186b..16350082f0 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -361,16 +361,7 @@ int Rim2dIntersectionView::timeStepCount() //-------------------------------------------------------------------------------------------------- bool Rim2dIntersectionView::isWindowVisible() { - if (m_showWindow()) - { - Rim2dIntersectionViewCollection* viewColl = nullptr; - this->firstAncestorOrThisOfTypeAsserted(viewColl); - return viewColl->isActive(); - } - else - { - return false; - } + return m_showWindow(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index 909ee19164..3b85df0ccc 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -31,8 +31,6 @@ Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection() { CAF_PDM_InitObject("2D Intersection Views", ":/CrossSection16x16.png", "", ""); - CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show", "","",""); - CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png", "", ""); m_intersectionViews.uiCapability()->setUiTreeHidden(true); } @@ -116,19 +114,3 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda if (rimCase) rimCase->updateConnectedEditors(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue) -{ - if (changedField == &m_isActive) - { - for (auto view : m_intersectionViews) - { - view->updateMdiWindowVisibility(); - } - } -} diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h index 2bf1ca68f7..ce02db28c1 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h @@ -31,16 +31,11 @@ class Rim2dIntersectionViewCollection : public caf::PdmObject Rim2dIntersectionViewCollection(); virtual ~Rim2dIntersectionViewCollection(); - bool isActive() { return m_isActive();} void syncFromExistingIntersections( bool doUpdate ); std::vector views(); private: - virtual caf::PdmFieldHandle* objectToggleField() override { return &m_isActive; } - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - - caf::PdmField m_isActive; caf::PdmChildArrayField m_intersectionViews; }; From b7e8834b4c797a8b495f143be2999adfb698dd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 14 Mar 2018 08:05:38 +0100 Subject: [PATCH 0490/1027] #2476 2dIntersectionView. Clean up context menus --- .../Commands/RicSelectColorResult.cpp | 32 ++++- ApplicationCode/Commands/RicWellLogTools.cpp | 4 +- .../Rim2dIntersectionView.cpp | 2 +- .../ProjectDataModel/Rim2dIntersectionView.h | 2 +- .../UserInterface/RiuViewerCommands.cpp | 128 +++++++++++------- 5 files changed, 106 insertions(+), 62 deletions(-) diff --git a/ApplicationCode/Commands/RicSelectColorResult.cpp b/ApplicationCode/Commands/RicSelectColorResult.cpp index 885d22d926..891d4e0719 100644 --- a/ApplicationCode/Commands/RicSelectColorResult.cpp +++ b/ApplicationCode/Commands/RicSelectColorResult.cpp @@ -25,18 +25,31 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimGridView.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" + #include "Riu3DMainWindowTools.h" #include CAF_CMD_SOURCE_INIT(RicSelectColorResult, "RicSelectColorResult"); +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +RimGridView* gridViewFrom2dIntersectionView(const Rim2dIntersectionView* int2dView) +{ + RimGridView* gridView = nullptr; + int2dView->intersection()->firstAncestorOrThisOfType(gridView); + return gridView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicSelectColorResult::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Color Result"); + actionToSetup->setText("Select Color Result"); actionToSetup->setIcon(QIcon(":/CellResult.png")); } @@ -47,7 +60,7 @@ bool RicSelectColorResult::isCommandEnabled() { if (RicWellLogTools::isWellPathOrSimWellSelectedInView()) return false; - return RiaApplication::instance()->activeGridView() != nullptr; + return RiaApplication::instance()->activeReservoirView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -55,18 +68,23 @@ bool RicSelectColorResult::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicSelectColorResult::onActionTriggered(bool isChecked) { - RimGridView* activeView = RiaApplication::instance()->activeGridView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim2dIntersectionView* int2dView = dynamic_cast(activeView); + RimGridView* gridView = nullptr; + + if (int2dView) gridView = gridViewFrom2dIntersectionView(int2dView); + else gridView = dynamic_cast(activeView); - RimEclipseView* eclView = dynamic_cast(activeView); + RimEclipseView* eclView = dynamic_cast(gridView); if (eclView) { - Riu3DMainWindowTools::selectAsCurrentItem(eclView->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(eclView->cellResult(), int2dView == nullptr); return; } - RimGeoMechView* geoMechView = dynamic_cast(activeView); + RimGeoMechView* geoMechView = dynamic_cast(gridView); if (geoMechView) { - Riu3DMainWindowTools::selectAsCurrentItem(geoMechView->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(geoMechView->cellResult(), int2dView== nullptr); } } diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index ca9b7c91d0..7afa502394 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -116,10 +116,10 @@ bool RicWellLogTools::isWellPathOrSimWellSelectedInView() RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); - RiuSimWellSelectionItem* simWellSelectionItem = static_cast(selItem); + RiuSimWellSelectionItem* simWellSelectionItem = dynamic_cast(selItem); if (simWellSelectionItem) return true; - RiuWellPathSelectionItem* wellPathSelectionItem = static_cast(selItem); + RiuWellPathSelectionItem* wellPathSelectionItem = dynamic_cast(selItem); if (wellPathSelectionItem) return true; return false; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 16350082f0..90e15d6b7f 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -120,7 +120,7 @@ void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIntersection* Rim2dIntersectionView::intersection() +RimIntersection* Rim2dIntersectionView::intersection() const { return m_intersection(); } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index acdaf9e92c..1449317049 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -44,7 +44,7 @@ class Rim2dIntersectionView : public Rim3dView void setVisible(bool isVisible); void setIntersection(RimIntersection* intersection); - RimIntersection* intersection(); + RimIntersection* intersection() const; virtual bool isUsingFormationNames() const override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 8fb4cc50a7..f5ace6df12 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -160,6 +160,10 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED; + // Check type of view + RimGridView* gridView = dynamic_cast(m_reservoirView.p()); + Rim2dIntersectionView* int2dView = dynamic_cast(m_reservoirView.p()); + cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { @@ -187,10 +191,9 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - if (activeView) + if (m_reservoirView.p()) { - cvf::ref transForm = activeView->displayCoordTransform(); + cvf::ref transForm = m_reservoirView.p()->displayCoordTransform(); m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint); } @@ -228,10 +231,17 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RiuSelectionItem* selItem = new RiuGeneralSelectionItem(crossSectionSourceInfo->crossSection()); RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); - menuBuilder << "RicHideIntersectionFeature"; - menuBuilder.addSeparator(); - menuBuilder << "RicNewIntersectionViewFeature"; - menuBuilder.addSeparator(); + if (gridView) + { + menuBuilder << "RicHideIntersectionFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder.addSeparator(); + } + else if (int2dView) + { + menuBuilder << "RicSelectColorResult"; + } } else if (intersectionBoxSourceInfo) { @@ -245,50 +255,53 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); } - // IJK -slice commands - RimViewController* viewController = nullptr; - if (m_reservoirView) viewController = m_reservoirView->viewController(); - - if (!viewController || !viewController->isRangeFiltersControlled()) + if (gridView) { - size_t i, j, k; - ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); + // IJK -slice commands + RimViewController* viewController = nullptr; + if (m_reservoirView) viewController = m_reservoirView->viewController(); - QVariantList iSliceList; - iSliceList.push_back(0); - iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); - - QVariantList jSliceList; - jSliceList.push_back(1); - jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); + if (!viewController || !viewController->isRangeFiltersControlled()) + { + size_t i, j, k; + ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); - QVariantList kSliceList; - kSliceList.push_back(2); - kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); + QVariantList iSliceList; + iSliceList.push_back(0); + iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); - menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); + QVariantList jSliceList; + jSliceList.push_back(1); + jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "I-slice Range Filter", iSliceList); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "J-slice Range Filter", jSliceList); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "K-slice Range Filter", kSliceList); + QVariantList kSliceList; + kSliceList.push_back(2); + kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); - menuBuilder.subMenuEnd(); - } + menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); - menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; - menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "I-slice Range Filter", iSliceList); + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "J-slice Range Filter", jSliceList); + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "K-slice Range Filter", kSliceList); - menuBuilder.addSeparator(); + menuBuilder.subMenuEnd(); + } - menuBuilder.subMenuStart("Intersections", QIcon(":/IntersectionXPlane16x16.png")); + menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; + menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; - menuBuilder << "RicNewPolylineIntersectionFeature"; - menuBuilder << "RicNewAzimuthDipIntersectionFeature"; - menuBuilder << "RicIntersectionBoxAtPosFeature"; - - menuBuilder << "RicIntersectionBoxXSliceFeature"; - menuBuilder << "RicIntersectionBoxYSliceFeature"; - menuBuilder << "RicIntersectionBoxZSliceFeature"; + menuBuilder.addSeparator(); + + menuBuilder.subMenuStart("Intersections", QIcon(":/IntersectionXPlane16x16.png")); + + menuBuilder << "RicNewPolylineIntersectionFeature"; + menuBuilder << "RicNewAzimuthDipIntersectionFeature"; + menuBuilder << "RicIntersectionBoxAtPosFeature"; + + menuBuilder << "RicIntersectionBoxXSliceFeature"; + menuBuilder << "RicIntersectionBoxYSliceFeature"; + menuBuilder << "RicIntersectionBoxZSliceFeature"; + } menuBuilder.subMenuEnd(); @@ -414,18 +427,31 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) // View Link commands if (!firstHitPart) { - menuBuilder << "RicLinkViewFeature"; - menuBuilder << "RicShowLinkOptionsFeature"; - menuBuilder << "RicSetMasterViewFeature"; - menuBuilder << "RicUnLinkViewFeature"; + if (gridView) + { + menuBuilder << "RicLinkViewFeature"; + menuBuilder << "RicShowLinkOptionsFeature"; + menuBuilder << "RicSetMasterViewFeature"; + menuBuilder << "RicUnLinkViewFeature"; + } + else if (int2dView) + { + menuBuilder << "RicSelectColorResult"; + } } - menuBuilder.addSeparator(); - menuBuilder << "RicNewGridTimeHistoryCurveFeature"; - menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; - menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; - menuBuilder << "RicShowGridStatisticsFeature"; - menuBuilder << "RicSelectColorResult"; + if (gridView) + { + menuBuilder.addSeparator(); + menuBuilder << "RicNewGridTimeHistoryCurveFeature"; + menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; + menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; + menuBuilder << "RicShowGridStatisticsFeature"; + menuBuilder << "RicSelectColorResult"; + } + else if (int2dView) + { + } menuBuilder.appendToMenu(&menu); From 108ef5eecc05dfc07c3b6530f14fb1faf5e16433 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 09:35:48 +0100 Subject: [PATCH 0491/1027] #2544 Well CF Viz : Add basiz viz with spheres, add legend to view --- .../RicExportCompletionDataSettingsUi.cpp | 21 +- ...ellPathExportCompletionDataFeatureImpl.cpp | 136 +++---------- ...cWellPathExportCompletionDataFeatureImpl.h | 8 +- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivVirtualConnFactorPartMgr.cpp | 184 ++++++++++++++++++ .../RivVirtualConnFactorPartMgr.h | 67 +++++++ .../ModelVisualization/RivWellPathPartMgr.cpp | 19 +- .../ModelVisualization/RivWellPathPartMgr.h | 4 +- .../ProjectDataModel/RimEclipseCase.cpp | 121 ++++++++++++ .../ProjectDataModel/RimEclipseCase.h | 4 + .../ProjectDataModel/RimEclipseView.cpp | 29 +++ .../ProjectDataModel/RimEclipseView.h | 6 +- .../RimVirtualPerforationResults.cpp | 43 +++- .../RimVirtualPerforationResults.h | 10 +- ...igVirtualPerforationTransmissibilities.cpp | 87 ++++++--- .../RigVirtualPerforationTransmissibilities.h | 7 +- .../ReservoirDataModel/RigEclipseCaseData.cpp | 2 +- .../ReservoirDataModel/RigEclipseCaseData.h | 2 +- 18 files changed, 590 insertions(+), 162 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index fab2965197..31aa782b44 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -54,13 +54,6 @@ CAF_PDM_SOURCE_INIT(RicExportCompletionDataSettingsUi, "RicExportCompletionDataS /// //-------------------------------------------------------------------------------------------------- RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected) { CAF_PDM_InitObject("RimExportCompletionDataSettings", "", "", ""); @@ -71,7 +64,7 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWe CAF_PDM_InitFieldNoDefault(&compdatExport, "compdatExport", "Export", "", " ", ""); CAF_PDM_InitField(&timeStep, "TimeStepIndex", 0, "Time Step", "", "", ""); - + CAF_PDM_InitField(&useLateralNTG, "UseLateralNTG", false, "Use NTG Horizontally", "", "", ""); CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Include Perforations", "", "", ""); @@ -79,10 +72,20 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWe CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Include Fractures", "", "", ""); CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, "Exclude Main Bore Transmissibility For Fishbones", "", "", ""); - m_onlyWellPathCollectionSelected = onlyWellPathCollectionSelected; + m_onlyWellPathCollectionSelected = false; m_displayForSimWell = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected) +{ + RicExportCompletionDataSettingsUi(); + + setOnlyWellPathCollectionSelected(onlyWellPathCollectionSelected); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 94491ce1ca..669e55b133 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -319,52 +319,21 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -/* -void RicWellPathExportCompletionDataFeatureImpl::computeVirtualPerfTrans( - RigVirtualPerforationTransmissibilities* virtualPerfTrans, - RimEclipseCase* eclipseCase, - const std::vector& inputWellPaths) +std::vector + RicWellPathExportCompletionDataFeatureImpl::computeStaticCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase) { - CVF_ASSERT(eclipseCase); - - std::vector usedWellPaths; - - { - for (RimWellPath* wellPath : inputWellPaths) - { - if (wellPath->unitSystem() == eclipseCase->eclipseCaseData()->unitsType()) - { - usedWellPaths.push_back(wellPath); - } - else - { - RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); - } - } - } - - RicExportCompletionDataSettingsUi exportSettings; - exportSettings.caseToApply = eclipseCase; - exportSettings.includeFishbones = true; - exportSettings.includePerforations = true; - exportSettings.includeFractures = true; - - bool anyPerforationsPresent = false; - for (const auto& w : usedWellPaths) - { - if (!w->perforationIntervalCollection()->perforations().empty()) - { - anyPerforationsPresent = true; - } - } + std::vector completionsPerEclipseCell; - for (auto wellPath : usedWellPaths) + if (eclipseCase && eclipseCase->eclipseCaseData()) { - std::vector completionsPerEclipseCell; + RicExportCompletionDataSettingsUi exportSettings; + exportSettings.caseToApply = eclipseCase; + exportSettings.timeStep = 0; + exportSettings.includeFishbones = true; + exportSettings.includePerforations = true; + exportSettings.includeFractures = true; - // Compute completions that do not change between time steps - - if (exportSettings.includeFishbones) { std::vector completionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( @@ -373,86 +342,39 @@ void RicWellPathExportCompletionDataFeatureImpl::computeVirtualPerfTrans( std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); } - if (exportSettings.includeFractures()) { std::vector completionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, nullptr); std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); } - - if (!anyPerforationsPresent) - { - virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); - } - else - { - for (size_t i = 0; i < eclipseCase->timeStepDates().size(); i++) - { - // Update time step in export settings - exportSettings.timeStep = static_cast(i); - - if (exportSettings.includePerforations) - { - std::vector completionData = generatePerforationsCompdatValues(wellPath, exportSettings); - - std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); - } - - //virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); - } - } } + + return completionsPerEclipseCell; } -*/ //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::computeCompletionsForWellPath( - RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& exportSettings) +std::vector + RicWellPathExportCompletionDataFeatureImpl::computeDynamicCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStepIndex) { std::vector completionsPerEclipseCell; - { - // Compute completions that do not change between time steps - - if (exportSettings.includeFishbones) - { - std::vector completionData = - RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( - wellPath, exportSettings); - - std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); - } - - if (exportSettings.includeFractures()) - { - std::vector completionData = - RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, nullptr); - - std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); - } - - { -/* - for (size_t i = 0; i < exportSettings.caseToApply()->timeStepDates().size(); i++) - { - // Update time step in export settings - exportSettings.timeStep = static_cast(i); - if (exportSettings.includePerforations) - { - std::vector completionData = generatePerforationsCompdatValues(wellPath, exportSettings); - - std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); - } - - // virtualPerfTrans->appendCompletionDataForWellPath(wellPath, completionsPerEclipseCell); - } -*/ - } + if (eclipseCase && eclipseCase->eclipseCaseData()) + { + RicExportCompletionDataSettingsUi exportSettings; + exportSettings.caseToApply = eclipseCase; + exportSettings.timeStep = static_cast(timeStepIndex); + exportSettings.includeFishbones = true; + exportSettings.includePerforations = true; + exportSettings.includeFractures = true; + + completionsPerEclipseCell = generatePerforationsCompdatValues(wellPath, exportSettings); } + return completionsPerEclipseCell; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 12dfbfb0bc..2168792386 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -146,8 +146,12 @@ class RicWellPathExportCompletionDataFeatureImpl const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); - static std::vector computeCompletionsForWellPath(RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& exportSettings); + static std::vector computeStaticCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase); + + static std::vector computeDynamicCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStepIndex); private: static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 5a4a9719e4..4801558943 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -39,6 +39,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -76,6 +77,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp new file mode 100644 index 0000000000..91b45b77b0 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -0,0 +1,184 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivVirtualConnFactorPartMgr.h" + +#include "RiaApplication.h" + +#include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimLegendConfig.h" +#include "RimSimWellInViewCollection.h" +#include "RimVirtualPerforationResults.h" +#include "RimWellPath.h" + +#include "RiuViewer.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" +#include "cvfDrawableGeo.h" +#include "cvfGeometryBuilderFaceList.h" +#include "cvfGeometryBuilderTriangles.h" +#include "cvfGeometryUtils.h" +#include "cvfModelBasicList.h" +#include "cvfObject.h" +#include "cvfPart.h" +#include "cvfPrimitiveSetIndexedUInt.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivVirtualConnFactorPartMgr::RivVirtualConnFactorPartMgr(RimWellPath* well, + RimVirtualPerforationResults* virtualPerforationResult) + : m_rimWell(well) + , m_virtualPerforationResult(virtualPerforationResult) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivVirtualConnFactorPartMgr::~RivVirtualConnFactorPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +{ + RimEclipseView* eclView = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView); + + auto coordTransform = eclView->displayCoordTransform(); + + RimEclipseCase* eclipseCase = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + const RigMainGrid* mainGrid = eclipseCase->mainGrid(); + + const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (!trans) return; + + auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex); + + std::vector> centerColorPairs; + + for (const auto& cell : conn) + { + size_t gridIndex = cell.first.globalCellIndex(); + + const RigCell& rigCell = mainGrid->cell(gridIndex); + cvf::Vec3d center = rigCell.center(); + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(center); + + cvf::Color3f color = cvf::Color3f::BLUE; + + double transmissibility = HUGE_VAL; + if (!cell.second.empty()) + { + transmissibility = cell.second.front().transmissibility(); + } + + centerColorPairs.push_back(std::make_pair(cvf::Vec3f(displayCoord), transmissibility)); + } + + if (!centerColorPairs.empty()) + { + double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); + + auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); + + cvf::ref part = RivVirtualConnFactorPartMgr::createPart(centerColorPairs, radius, scalarMapper); + + model->addPart(part.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector>& centerColorPairs, + double radius, + cvf::ScalarMapper* scalarMapper) +{ + cvf::GeometryBuilderTriangles builder; + cvf::GeometryUtils::createSphere(radius, 5, 5, &builder); + + auto sphereVertices = builder.vertices(); + auto sphereIndices = builder.triangles(); + + cvf::ref vertices = new cvf::Vec3fArray; + cvf::ref indices = new cvf::UIntArray; + cvf::ref textureCoords = new cvf::Vec2fArray(); + + auto indexCount = centerColorPairs.size() * sphereIndices->size(); + auto vertexCount = centerColorPairs.size() * sphereVertices->size(); + indices->reserve(indexCount); + vertices->reserve(vertexCount); + textureCoords->reserve(vertexCount); + + textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); + + for (const auto& centerColorPair : centerColorPairs) + { + cvf::uint indexOffset = static_cast(vertices->size()); + + for (const auto& v : *sphereVertices) + { + vertices->add(centerColorPair.first + v); + + if (centerColorPair.second == HUGE_VAL) + { + textureCoords->add(cvf::Vec2f(0.5f, 1.0f)); + } + else + { + textureCoords->add(scalarMapper->mapToTextureCoord(centerColorPair.second)); + } + } + + for (const auto& i : *sphereIndices) + { + indices->add(i + indexOffset); + } + } + + cvf::ref drawable = new cvf::DrawableGeo(); + drawable->setVertexArray(vertices.p()); + + drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); + drawable->computeNormals(); + + drawable->setTextureCoordArray(textureCoords.p()); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + bool disableLighting = false; + effGen.disableLighting(disableLighting); + + cvf::ref eff = effGen.generateCachedEffect(); + part->setEffect(eff.p()); + + return part; +} diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h new file mode 100644 index 0000000000..113ba6a392 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cafPdmPointer.h" + +#include +#include +#include + +namespace cvf +{ +class Part; +class ModelBasicList; +class ScalarMapper; +} // namespace cvf + +class RimWellPath; +class RimVirtualPerforationResults; + +namespace caf +{ +class DisplayCoordTransform; +} + +//-------------------------------------------------------------------------------------------------- +/// +/// Based on RivWellSpheresPartMgr +/// +//-------------------------------------------------------------------------------------------------- +class RivVirtualConnFactorPartMgr : public cvf::Object +{ +public: + RivVirtualConnFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult); + ~RivVirtualConnFactorPartMgr(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + +private: + static cvf::ref createPart(std::vector>& centerColorPairs, + double radius, + cvf::ScalarMapper* scalarMapper); + +private: + caf::PdmPointer m_rimWell; + caf::PdmPointer m_virtualPerforationResult; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 928b49d035..0c20b0b1d1 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -51,6 +51,8 @@ #include "RivWellPathPartMgr.h" #include "RivWellPathSourceInfo.h" +#include "RiuViewer.h" + #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" #include "cvfDrawableGeo.h" @@ -61,6 +63,7 @@ #include "cvfScalarMapperDiscreteLinear.h" #include "cvfTransform.h" #include "cvfqtUtils.h" +#include "RivVirtualConnFactorPartMgr.h" //-------------------------------------------------------------------------------------------------- @@ -212,18 +215,21 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize) { - RimEclipseCase* eclipseCase = nullptr; + RimEclipseView* eclView = dynamic_cast(m_rimView.p()); + if (!eclView) return; - m_rimView->firstAncestorOrThisOfType(eclipseCase); - if (!eclipseCase) return; - if (!eclipseCase->eclipseCaseData()) return; + if (!eclView->isVirtualConnectionFactorGeometryVisible()) return; - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + RimEclipseCase* eclipseCase = nullptr; + eclView->firstAncestorOrThisOfType(eclipseCase); + if (!eclipseCase) return; - const RigVirtualPerforationTransmissibilities* trans = eclipseCaseData->virtualPerforationTransmissibilities(); + const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); if (trans) { + m_virtualConnectionFactorPartMgr = new RivVirtualConnFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); + m_virtualConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, 0); } } @@ -416,6 +422,7 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize); appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); + appendVirtualTransmissibilitiesToModel(model, displayCoordTransform, characteristicCellSize); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index c5e3c1cc75..a1871b9821 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -46,6 +46,7 @@ class RivFishbonesSubsPartMgr; class RimWellPathCollection; class Rim3dView; class Riv3dWellLogPlanePartMgr; +class RivVirtualConnFactorPartMgr; class QDateTime; @@ -111,5 +112,6 @@ class RivWellPathPartMgr : public cvf::Object cvf::ref m_centerLineDrawable; cvf::ref m_wellLabelPart; - cvf::ref m_3dWellLogCurvePartMgr; + cvf::ref m_3dWellLogCurvePartMgr; + cvf::ref m_virtualConnectionFactorPartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 8946798f46..e6d53b4439 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -24,11 +24,15 @@ #include "RiaColorTables.h" #include "RiaPreferences.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" + #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigSimWellData.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "Rim2dIntersectionViewCollection.h" #include "RimCaseCollection.h" @@ -43,8 +47,10 @@ #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" #include "RimIntersectionCollection.h" +#include "RimLegendConfig.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" +#include "RimPerforationCollection.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" #include "RimStimPlanColors.h" @@ -53,6 +59,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimTools.h" +#include "RimVirtualPerforationResults.h" #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -307,6 +314,120 @@ void RimEclipseCase::recalculateCompletionTypeAndRedrawAllViews() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::deleteVirtualConnectionFactorDataAndRedrawRequiredViews() +{ + RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); + + if (rigEclipseCase) + { + rigEclipseCase->setVirtualPerforationTransmissibilities(nullptr); + } + + for (Rim3dView* view : views()) + { + RimEclipseView* eclipseView = dynamic_cast(view); + if (eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible()) + { + eclipseView->scheduleCreateDisplayModelAndRedraw(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirtualPerforationTransmissibilities() +{ + RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); + + // TODO: Remove + rigEclipseCase->setVirtualPerforationTransmissibilities(nullptr); + + + if (rigEclipseCase->virtualPerforationTransmissibilities() == nullptr) + { + cvf::ref perfTrans = new RigVirtualPerforationTransmissibilities; + + std::vector visibleWellPaths; + bool anyPerforationsPresent = false; + { + RimProject* proj = RiaApplication::instance()->project(); + std::vector wellPaths = proj->allWellPaths(); + for (auto w : wellPaths) + { + if (w->showWellPath()) + { + visibleWellPaths.push_back(w); + + if (!w->perforationIntervalCollection()->perforations().empty()) + { + anyPerforationsPresent = true; + } + } + } + } + + for (auto w : visibleWellPaths) + { + std::vector staticCompletionData = RicWellPathExportCompletionDataFeatureImpl::computeStaticCompletionsForWellPath(w, this); + + if (anyPerforationsPresent) + { + std::vector> allCompletionData; + + for (size_t i = 0; i < timeStepDates().size(); i++) + { + std::vector dynamicCompletionDataOneTimeStep = RicWellPathExportCompletionDataFeatureImpl::computeDynamicCompletionsForWellPath(w, this, i); + + std::copy(staticCompletionData.begin(), staticCompletionData.end(), std::back_inserter(dynamicCompletionDataOneTimeStep)); + + allCompletionData.push_back(dynamicCompletionDataOneTimeStep); + } + + perfTrans->setCompletionDataForWellPath(w, allCompletionData); + } + else + { + std::vector> allCompletionData; + allCompletionData.push_back(staticCompletionData); + + perfTrans->setCompletionDataForWellPath(w, allCompletionData); + } + } + + rigEclipseCase->setVirtualPerforationTransmissibilities(perfTrans.p()); + + { + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + double posClosestToZero = HUGE_VAL; + double negClosestToZero = -HUGE_VAL; + + perfTrans->computeMinMax(&minValue, &maxValue, &posClosestToZero, &negClosestToZero); + + if (minValue != HUGE_VAL) + { + for (const auto& v : views()) + { + RimEclipseView* eclView = dynamic_cast(v); + if (eclView) + { + RimLegendConfig* legendConfig = eclView->virtualPerforationResult()->legendConfig(); + + legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); + } + } + } + } + } + + return rigEclipseCase->virtualPerforationTransmissibilities(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index bb0704f7c5..a658c2547b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -44,6 +44,7 @@ class RimCaseCollection; class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; class RimEclipseView; +class RigVirtualPerforationTransmissibilities; //================================================================================================== @@ -87,6 +88,9 @@ class RimEclipseCase : public RimCase RimEclipseView* createCopyAndAddView(const RimEclipseView* sourceView); void recalculateCompletionTypeAndRedrawAllViews(); + + void deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); + const RigVirtualPerforationTransmissibilities* computeAndGetVirtualPerforationTransmissibilities(); virtual QString locationOnDisc() const { return QString(); } virtual QString gridFileName() const { return QString(); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index e0a2ae4632..2f18f351fb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -227,6 +227,14 @@ RimFaultInViewCollection* RimEclipseView::faultCollection() const return m_faultCollection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults* RimEclipseView::virtualPerforationResult() const +{ + return m_virtualPerforationResult(); +} + //-------------------------------------------------------------------------------------------------- /// Clamp the current timestep to actual possibilities //-------------------------------------------------------------------------------------------------- @@ -1070,6 +1078,13 @@ void RimEclipseView::updateLegends() m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); } } + + if (m_virtualPerforationResult->isActive()) + { + RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); + + m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); + } } //-------------------------------------------------------------------------------------------------- @@ -1373,6 +1388,20 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::isVirtualConnectionFactorGeometryVisible() const +{ + if (!m_showWindow()) return false; + + if (!m_virtualPerforationResult->isActive()) return false; + + // TODO: Consider check if no well paths are visible + + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 912bda226c..23b037670b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -85,7 +85,8 @@ class RimEclipseView : public RimGridView RimStimPlanColors* fractureColors() const; RimSimWellInViewCollection* wellCollection() const; RimFaultInViewCollection* faultCollection() const; - + RimVirtualPerforationResults* virtualPerforationResult() const; + bool showInvalidCells() const; bool showInactiveCells() const; bool showMainGrid() const; @@ -118,6 +119,9 @@ class RimEclipseView : public RimGridView void calculateCompletionTypeAndRedrawIfRequired(); + bool isVirtualConnectionFactorGeometryVisible() const; + + const std::vector& visibleGridParts() const; const RivReservoirViewPartMgr* reservoirGridPartManager() const; RivReservoirViewPartMgr* reservoirGridPartManager(); diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index 695a4bfb08..d074896434 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -19,6 +19,7 @@ #include "RimVirtualPerforationResults.h" #include "RimLegendConfig.h" +#include "RimEclipseView.h" @@ -32,11 +33,14 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() { CAF_PDM_InitObject("Virtual Perforation Results", ":/CellResult.png", "", ""); - CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); - this->legendConfig = new RimLegendConfig(); - legendConfig.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", true, "", "", "", ""); + CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 0.2, "Geometry Scale Factor", "", "", ""); - CAF_PDM_InitField(&m_showTensors, "ShowTensors", true, "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + m_legendConfig.uiCapability()->setUiHidden(true); + + m_legendConfig = new RimLegendConfig(); + m_legendConfig->setTitle("Virtual Connection Factor"); } //-------------------------------------------------------------------------------------------------- @@ -47,12 +51,39 @@ RimVirtualPerforationResults::~RimVirtualPerforationResults() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimVirtualPerforationResults::isActive() const +{ + return m_isActive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimVirtualPerforationResults::geometryScaleFactor() const +{ + return m_geometryScaleFactor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimLegendConfig* RimVirtualPerforationResults::legendConfig() const +{ + return m_legendConfig(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { + RimEclipseView* eclView = nullptr; + this->firstAncestorOrThisOfTypeAsserted(eclView); + eclView->scheduleCreateDisplayModelAndRedraw(); } //-------------------------------------------------------------------------------------------------- @@ -60,7 +91,7 @@ void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() { - return &m_showTensors; + return &m_isActive; } //-------------------------------------------------------------------------------------------------- @@ -79,6 +110,8 @@ QList RimVirtualPerforationResults::calculateValueOption //-------------------------------------------------------------------------------------------------- void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + uiOrdering.add(&m_geometryScaleFactor); + uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h index f8c1e4b6b7..10b1b756d9 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -35,11 +35,14 @@ class RimVirtualPerforationResults : public caf::PdmObject { CAF_PDM_HEADER_INIT; - public: RimVirtualPerforationResults(); virtual ~RimVirtualPerforationResults(); + bool isActive() const; + double geometryScaleFactor() const; + RimLegendConfig* legendConfig() const; + private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; @@ -47,7 +50,8 @@ class RimVirtualPerforationResults : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - caf::PdmField m_showTensors; + caf::PdmField m_isActive; + caf::PdmField m_geometryScaleFactor; - caf::PdmChildField legendConfig; + caf::PdmChildField m_legendConfig; }; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index 400c21721a..e020d885f1 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigVirtualPerforationTransmissibilities.h" +#include "RigStatisticsMath.h" //-------------------------------------------------------------------------------------------------- /// @@ -44,9 +45,10 @@ void CompletionDataFrame::setCompletionData(const std::vector } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -const std::map>& CompletionDataFrame::multipleCompletionsPerEclipseCell() const +const std::map>& + CompletionDataFrame::multipleCompletionsPerEclipseCell() const { return m_multipleCompletionsPerEclipseCell; } @@ -64,29 +66,28 @@ RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilitie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigVirtualPerforationTransmissibilities::appendCompletionDataForWellPath( - RimWellPath* wellPath, - const std::vector& completions) +void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( + RimWellPath* wellPath, + std::vector>& completionsPerTimeStep) { -/* auto item = m_mapFromWellToCompletionData.find(wellPath); - if (item != m_mapFromWellToCompletionData.end()) - { - item->second.setCompletionData - } - auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); - if (it != m_multipleCompletionsPerEclipseCell.end()) - { - it->second.push_back(completion); - } - else + CVF_ASSERT(item == m_mapFromWellToCompletionData.end()); + { - m_multipleCompletionsPerEclipseCell.insert(std::pair>( - completion.completionDataGridCell(), std::vector{completion})); - } -*/ + std::vector values; + + for (const auto& c : completionsPerTimeStep) + { + CompletionDataFrame oneTimeStep; + oneTimeStep.setCompletionData(c); + values.push_back(oneTimeStep); + } + + auto pair = std::pair>(wellPath, values); + m_mapFromWellToCompletionData.insert(pair); + } } //-------------------------------------------------------------------------------------------------- @@ -100,8 +101,50 @@ const std::map>& auto item = m_mapFromWellToCompletionData.find(wellPath); if (item != m_mapFromWellToCompletionData.end()) { - return item->second[timeStepIndex].multipleCompletionsPerEclipseCell(); + size_t indexToUse = timeStepIndex; + if (item->second.size() == 1) + { + indexToUse = 0; + } + + return item->second[indexToUse].multipleCompletionsPerEclipseCell(); } - + return dummy; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const +{ + MinMaxAccumulator minMaxAccumulator; + PosNegAccumulator posNegAccumulator; + + for (const auto& item : m_mapFromWellToCompletionData) + { + auto completionDataFrame = item.second; + for (const auto& data : completionDataFrame) + { + for (const auto& data : completionDataFrame) + { + auto compl = data.multipleCompletionsPerEclipseCell(); + for (const auto& c : compl) + { + for (const auto& d : c.second) + { + double trans = d.transmissibility(); + + minMaxAccumulator.addValue(trans); + posNegAccumulator.addValue(trans); + } + } + } + } + } + + if (*minValue) *minValue = minMaxAccumulator.min; + if (*maxValue) *maxValue = minMaxAccumulator.max; + if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos; + if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; +} diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h index b9dd803e22..0d93720fa5 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -40,8 +40,7 @@ class CompletionDataFrame void setCompletionData(const std::vector& completions); - const std::map>& - multipleCompletionsPerEclipseCell() const; + const std::map>& multipleCompletionsPerEclipseCell() const; private: std::map> m_multipleCompletionsPerEclipseCell; @@ -56,12 +55,12 @@ class RigVirtualPerforationTransmissibilities : public cvf::Object RigVirtualPerforationTransmissibilities(); ~RigVirtualPerforationTransmissibilities(); - void appendCompletionDataForWellPath(RimWellPath* wellPath, - const std::vector& completions); + void setCompletionDataForWellPath(RimWellPath* wellPath, std::vector>& completionsPerTimeStep); const std::map>& multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const; + void computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; private: std::map> m_mapFromWellToCompletionData; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index cd3d095623..f826c41094 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -533,7 +533,7 @@ void RigEclipseCaseData::setVirtualPerforationTransmissibilities(RigVirtualPerfo //-------------------------------------------------------------------------------------------------- const RigVirtualPerforationTransmissibilities* RigEclipseCaseData::virtualPerforationTransmissibilities() const { - return m_virtualPerforationTransmissibilities; + return m_virtualPerforationTransmissibilities.p(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index ee95ae205a..1b760d8cd3 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -131,7 +131,7 @@ class RigEclipseCaseData : public cvf::Object cvf::ref m_activeFormationNamesData; - RigVirtualPerforationTransmissibilities* m_virtualPerforationTransmissibilities; + cvf::ref m_virtualPerforationTransmissibilities; cvf::Collection m_simWellData; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not From d3361d22dde8f64e9c2e251af80fd6861b3fdd5e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 09:47:17 +0100 Subject: [PATCH 0492/1027] #2546 Well CF Visualization : Fix computation of transmissibilty --- ...igVirtualPerforationTransmissibilities.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index e020d885f1..89a0da41dd 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -114,30 +114,30 @@ const std::map>& } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const +void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue, + double* maxValue, + double* posClosestToZero, + double* negClosestToZero) const { MinMaxAccumulator minMaxAccumulator; PosNegAccumulator posNegAccumulator; for (const auto& item : m_mapFromWellToCompletionData) { - auto completionDataFrame = item.second; - for (const auto& data : completionDataFrame) + auto dataForWellPath = item.second; + + for (const auto& timeStepFrame : dataForWellPath) { - for (const auto& data : completionDataFrame) + for (const auto& allCompletionsForWell : timeStepFrame.multipleCompletionsPerEclipseCell()) { - auto compl = data.multipleCompletionsPerEclipseCell(); - for (const auto& c : compl) + for (const auto& completionData : allCompletionsForWell.second) { - for (const auto& d : c.second) - { - double trans = d.transmissibility(); + double transmissibility = completionData.transmissibility(); - minMaxAccumulator.addValue(trans); - posNegAccumulator.addValue(trans); - } + minMaxAccumulator.addValue(transmissibility); + posNegAccumulator.addValue(transmissibility); } } } From 04520c8446c36fa33911365483f4150d84a7ac8e Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 14 Mar 2018 13:38:59 +0100 Subject: [PATCH 0493/1027] #2595 Fix crash when opening well log LAS curve without connection to well path --- ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index e77b2dcdb5..1864756ee3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -332,6 +332,8 @@ QList RimWellLogFileCurve::calculateValueOptions(const c //-------------------------------------------------------------------------------------------------- void RimWellLogFileCurve::initAfterRead() { + if (!m_wellPath) return; + if (m_wellPath->wellLogFiles().size() == 1) { m_wellLogFile = m_wellPath->wellLogFiles().front(); @@ -420,5 +422,10 @@ RimWellLogFile* RimWellLogFileCurve::wellLogFile() const //-------------------------------------------------------------------------------------------------- QString RimWellLogFileCurve::wellName() const { - return m_wellPath->name(); + if (m_wellPath) + { + return m_wellPath->name(); + } + + return QString(""); } From 46c4693ae676d89a25e47953c0bc889e52fdbeb5 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 14 Mar 2018 14:22:14 +0100 Subject: [PATCH 0494/1027] 3D well log curve: Establish a coordinate system for curve normals --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 155 +++++++++++------- .../Riv3dWellLogCurveGeomertyGenerator.h | 5 +- .../Riv3dWellLogPlanePartMgr.cpp | 4 + 3 files changed, 99 insertions(+), 65 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 451cf5fd25..cefcf451a9 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -60,29 +60,22 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; - std::vector vertices; - vertices.reserve(wellPathPoints.size() * 2); - - std::vector curveNormals; - curveNormals.reserve(wellPathPoints.size()); + cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); - for (size_t i = 0; i < wellPathPoints.size() - 1; i++) - { - cvf::Vec3d z = zForDrawPlane(rim3dWellLogCurve->drawPlane()); - cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i + 1], z); + std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), wellPathPoints); - curveNormals.push_back(y); - } + std::vector vertices; + vertices.reserve(wellPathPoints.size()); std::vector indices; - vertices.reserve(wellPathPoints.size() * 2); + indices.reserve(wellPathPoints.size()); cvf::uint counter = 0; - for (size_t i = 0; i < curveNormals.size(); i++) + for (size_t i = 0; i < pointNormals.size(); i += 2) { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i]))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 100))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + pointNormals[i] * 100))); indices.push_back(counter++); indices.push_back(counter++); @@ -116,28 +109,18 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim CVF_ASSERT(resultValues.size() == mds.size()); - std::vector wellPathPoints; - wellPathPoints.reserve(mds.size()); + cvf::Vec3d globalDirection = + (m_wellPathGeometry->m_wellPathPoints.back() - m_wellPathGeometry->m_wellPathPoints.front()).getNormalized(); + + std::vector interpolatedWellPathPoints; + interpolatedWellPathPoints.reserve(mds.size()); for (double md : mds) { - wellPathPoints.push_back(m_wellPathGeometry->interpolatedPointAlongWellPath(md)); + interpolatedWellPathPoints.push_back(m_wellPathGeometry->interpolatedPointAlongWellPath(md)); } - vertices->resize(wellPathPoints.size()); - - std::vector curveNormals; - curveNormals.reserve(wellPathPoints.size()); - - for (size_t i = 0; i < wellPathPoints.size() - 1; i += 2) - { - cvf::Vec3d z = zForDrawPlane(rim3dWellLogCurve->drawPlane()); - - cvf::Vec3d y = normalBetweenPoints(wellPathPoints[i], wellPathPoints[i + 1], z); - - curveNormals.push_back(y); - curveNormals.push_back(y); - } + std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); double maxResult = -HUGE_VAL; double minResult = HUGE_VAL; @@ -150,20 +133,28 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim minResult = std::min(result, minResult); } + vertices->resize(interpolatedWellPathPoints.size()); + double range = maxResult - minResult; double factor = 60.0 / range; + double offset = 30.0; + + if (minResult < 0) + { + offset += cvf::Math::abs(minResult * factor); + } - for (size_t i = 0; i < curveNormals.size(); i++) + for (size_t i = 0; i < pointNormals.size(); i++) { cvf::Vec3d result(0, 0, 0); if (RigCurveDataTools::isValidValue(resultValues[i], false)) { - result = resultValues[i] * factor * curveNormals[i]; + result = resultValues[i] * factor * pointNormals[i]; } - (*vertices)[i] = - cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + curveNormals[i] * 30 + result)); + (*vertices)[i] = cvf::Vec3f( + displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + pointNormals[i] * offset + result)); } std::vector> valuesIntervals = @@ -182,39 +173,79 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::normalBetweenPoints(const cvf::Vec3d& pt1, - const cvf::Vec3d& pt2, - const cvf::Vec3d& z) const +std::vector + Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& wellPathPoints) { - cvf::Vec3d x = (pt2 - pt1).getNormalized(); - - return (z ^ x).getNormalized(); -} + std::vector lineSegmentNormals; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const -{ - if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_LEFT) - { - return cvf::Vec3d(0, 0, -1); - } - else if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_RIGHT) + if (wellPathPoints.empty()) { - return cvf::Vec3d(0, 0, 1); + return lineSegmentNormals; } - else if (drawPlane == Rim3dWellLogCurve::VERTICAL_ABOVE) - { - return cvf::Vec3d(0, -1, 0); - } - else if (drawPlane == Rim3dWellLogCurve::VERTICAL_BELOW) + + lineSegmentNormals.reserve(wellPathPoints.size() - 1); + + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + const cvf::Vec3d up(0, 0, 1); + + for (size_t i = 0; i < wellPathPoints.size() - 1; i += 2) { - return cvf::Vec3d(0, 1, 0); + cvf::Vec3d vecAlongPath = (wellPathPoints[i + 1] - wellPathPoints[i]).getNormalized(); + + double dotProduct = up * vecAlongPath; + + cvf::Vec3d Ex; + + if (cvf::Math::abs(dotProduct) > 0.7071) + { + Ex = globalDirection; + } + else + { + Ex = vecAlongPath; + } + + cvf::Vec3d Ey = (up ^ Ex).getNormalized(); + cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); + + cvf::Vec3d normal; + + switch (drawPlane) + { + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: break; + } + + lineSegmentNormals.push_back(normal); } - else + + std::vector pointNormals; + pointNormals.resize(wellPathPoints.size()); + + pointNormals[0] = lineSegmentNormals[0]; + + for (size_t i = 1; i < pointNormals.size() - 1; i += 2) { - // Default: Horizontal left - return cvf::Vec3d(0, 0, -1); + size_t rightSegmentIdx = (i + 1) / 2; + size_t leftSegmentIdx = rightSegmentIdx - 1; + + pointNormals[i] = ((lineSegmentNormals[leftSegmentIdx] + lineSegmentNormals[rightSegmentIdx]) / 2).getNormalized(); + pointNormals[i + 1] = pointNormals[i]; } + + pointNormals[pointNormals.size() - 1] = lineSegmentNormals.back(); + + return pointNormals; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index d2c72e91f1..1e069704a8 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -50,9 +50,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector* vertices, std::vector* indices) const; - cvf::Vec3d normalBetweenPoints(const cvf::Vec3d& pt1, const cvf::Vec3d& pt2, const cvf::Vec3d& z) const; - cvf::Vec3d zForDrawPlane(const Rim3dWellLogCurve::DrawPlane& drawPlane) const; - + static std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& wellPathPoints); private: cvf::ref m_wellPathGeometry; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 9e47635edc..8f5720510c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -71,6 +71,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* //TODO: Atm, only the grid for the first curve is drawn. cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0]); + if (!gridDrawable->boundingBox().isValid()) + { + return; + } caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 255, 0, 1), caf::PO_1); cvf::ref effect = surfaceGen.generateCachedEffect(); From b1fc73bc95c1b2783f5696dbf9d01363bff52850 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 10:59:03 +0100 Subject: [PATCH 0495/1027] #2544 Well CF Visualization : Add basic star geometry --- .../RivVirtualConnFactorPartMgr.cpp | 122 ++++++++++++++++-- .../RivVirtualConnFactorPartMgr.h | 2 + 2 files changed, 115 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp index 91b45b77b0..62dd162314 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -120,18 +120,17 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector verticesForOneObject; + std::vector indicesForOneObject; - auto sphereVertices = builder.vertices(); - auto sphereIndices = builder.triangles(); + RivVirtualConnFactorPartMgr::createStarGeometry(&verticesForOneObject, &indicesForOneObject, radius, radius * 0.3); cvf::ref vertices = new cvf::Vec3fArray; cvf::ref indices = new cvf::UIntArray; cvf::ref textureCoords = new cvf::Vec2fArray(); - auto indexCount = centerColorPairs.size() * sphereIndices->size(); - auto vertexCount = centerColorPairs.size() * sphereVertices->size(); + auto indexCount = centerColorPairs.size() * indicesForOneObject.size(); + auto vertexCount = centerColorPairs.size() * verticesForOneObject.size(); indices->reserve(indexCount); vertices->reserve(vertexCount); textureCoords->reserve(vertexCount); @@ -142,7 +141,7 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector(vertices->size()); - for (const auto& v : *sphereVertices) + for (const auto& v : verticesForOneObject) { vertices->add(centerColorPair.first + v); @@ -156,7 +155,7 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vectoradd(i + indexOffset); } @@ -174,7 +173,8 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vectorsetDrawable(drawable.p()); caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - bool disableLighting = false; + + bool disableLighting = true; effGen.disableLighting(disableLighting); cvf::ref eff = effGen.generateCachedEffect(); @@ -182,3 +182,107 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector* vertices, + std::vector* indices, + double radius, + double thickness) +{ + auto p0 = cvf::Vec3f::Z_AXIS * radius; + auto p2 = cvf::Vec3f::X_AXIS * -radius; + auto p4 = -p0; + auto p6 = -p2; + + double innerFactor = 5.0; + + auto p1 = (p0 + p2) / innerFactor; + auto p3 = (p2 + p4) / innerFactor; + + auto p5 = -p1; + auto p7 = -p3; + + auto p8 = cvf::Vec3f::Y_AXIS * thickness; + auto p9 = -p8; + + vertices->push_back(p0); + vertices->push_back(p1); + vertices->push_back(p2); + vertices->push_back(p3); + vertices->push_back(p4); + vertices->push_back(p5); + vertices->push_back(p6); + vertices->push_back(p7); + vertices->push_back(p8); + vertices->push_back(p9); + + // Top + indices->push_back(0); + indices->push_back(1); + indices->push_back(8); + + indices->push_back(0); + indices->push_back(8); + indices->push_back(7); + + indices->push_back(0); + indices->push_back(9); + indices->push_back(1); + + indices->push_back(0); + indices->push_back(7); + indices->push_back(9); + + // Left + indices->push_back(2); + indices->push_back(3); + indices->push_back(8); + + indices->push_back(2); + indices->push_back(8); + indices->push_back(1); + + indices->push_back(2); + indices->push_back(9); + indices->push_back(3); + + indices->push_back(2); + indices->push_back(1); + indices->push_back(9); + + // Bottom + indices->push_back(4); + indices->push_back(5); + indices->push_back(8); + + indices->push_back(4); + indices->push_back(8); + indices->push_back(3); + + indices->push_back(4); + indices->push_back(9); + indices->push_back(5); + + indices->push_back(4); + indices->push_back(3); + indices->push_back(9); + + // Right + indices->push_back(6); + indices->push_back(7); + indices->push_back(8); + + indices->push_back(6); + indices->push_back(8); + indices->push_back(5); + + indices->push_back(6); + indices->push_back(9); + indices->push_back(7); + + indices->push_back(6); + indices->push_back(5); + indices->push_back(9); +} diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h index 113ba6a392..e7dc39a4be 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h @@ -61,6 +61,8 @@ class RivVirtualConnFactorPartMgr : public cvf::Object double radius, cvf::ScalarMapper* scalarMapper); + static void createStarGeometry(std::vector* vertices, std::vector* indices, double radius, double thickness); + private: caf::PdmPointer m_rimWell; caf::PdmPointer m_virtualPerforationResult; From d757c0c92a8bd4a4e4fd39f677421b7bf543cb4d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 11:36:15 +0100 Subject: [PATCH 0496/1027] #2545 Well CF Visualization: Use "Well Connection Factors" in UI --- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../RimVirtualPerforationResults.cpp | 65 ++++++++++++------- .../RimVirtualPerforationResults.h | 2 + 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 2f18f351fb..332576e67a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -126,7 +126,7 @@ RimEclipseView::RimEclipseView() m_fractureColors = new RimStimPlanColors(); m_fractureColors.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_virtualPerforationResult, "VirtualPerforationResult", "Virtual Perforation Result", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_virtualPerforationResult, "VirtualPerforationResult", "", "", "", ""); m_virtualPerforationResult = new RimVirtualPerforationResults(); m_virtualPerforationResult.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index d074896434..264e76b6cb 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -1,37 +1,38 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RimVirtualPerforationResults.h" -#include "RimLegendConfig.h" #include "RimEclipseView.h" - - +#include "RimLegendConfig.h" CAF_PDM_SOURCE_INIT(RimVirtualPerforationResults, "RimVirtualPerforationResults"); - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimVirtualPerforationResults::RimVirtualPerforationResults() { - CAF_PDM_InitObject("Virtual Perforation Results", ":/CellResult.png", "", ""); + // clang-format off + + QString connectionFactorUiName = "Well Connection Factors"; + + CAF_PDM_InitObject(connectionFactorUiName, ":/CellResult.png", "", ""); CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", true, "", "", "", ""); CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 0.2, "Geometry Scale Factor", "", "", ""); @@ -40,19 +41,18 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() m_legendConfig.uiCapability()->setUiHidden(true); m_legendConfig = new RimLegendConfig(); - m_legendConfig->setTitle("Virtual Connection Factor"); + m_legendConfig->setTitle(connectionFactorUiName); + + // clang-format on } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RimVirtualPerforationResults::~RimVirtualPerforationResults() -{ - -} +RimVirtualPerforationResults::~RimVirtualPerforationResults() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimVirtualPerforationResults::isActive() const { @@ -60,7 +60,7 @@ bool RimVirtualPerforationResults::isActive() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RimVirtualPerforationResults::geometryScaleFactor() const { @@ -68,7 +68,7 @@ double RimVirtualPerforationResults::geometryScaleFactor() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimLegendConfig* RimVirtualPerforationResults::legendConfig() const { @@ -76,10 +76,17 @@ RimLegendConfig* RimVirtualPerforationResults::legendConfig() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { + if (changedField == &m_isActive) + { + updateUiIconFromToggleField(); + } + RimEclipseView* eclView = nullptr; this->firstAncestorOrThisOfTypeAsserted(eclView); @@ -87,7 +94,7 @@ void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* c } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() { @@ -95,9 +102,10 @@ caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RimVirtualPerforationResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RimVirtualPerforationResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; *useOptionsOnly = true; @@ -106,7 +114,7 @@ QList RimVirtualPerforationResults::calculateValueOption } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -115,3 +123,10 @@ void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::P uiOrdering.skipRemainingFields(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::initAfterRead() +{ + updateUiIconFromToggleField(); +} diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h index 10b1b756d9..6e79b6f597 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -43,11 +43,13 @@ class RimVirtualPerforationResults : public caf::PdmObject double geometryScaleFactor() const; RimLegendConfig* legendConfig() const; + private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; private: caf::PdmField m_isActive; From 2bf0773815afd972cba7607535c20457fc1e3ebf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 11:36:55 +0100 Subject: [PATCH 0497/1027] #2546 Well CF Visualization: Recompute data when required --- .../Application/RiaCompletionTypeCalculationScheduler.cpp | 1 + ApplicationCode/ProjectDataModel/RimEclipseCase.cpp | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 2f9386c194..2f1c2e6a44 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -93,6 +93,7 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() for (RimEclipseCase* eclipseCase : uniqueCases) { eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); + eclipseCase->deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); } m_eclipseCasesToRecalculate.clear(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index e6d53b4439..574672386f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -343,10 +343,6 @@ const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirt { RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); - // TODO: Remove - rigEclipseCase->setVirtualPerforationTransmissibilities(nullptr); - - if (rigEclipseCase->virtualPerforationTransmissibilities() == nullptr) { cvf::ref perfTrans = new RigVirtualPerforationTransmissibilities; From 0aba950c12ca60e5c216dc956679a24f21665339 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 13:41:31 +0100 Subject: [PATCH 0498/1027] #2544 Well CF Visualization: Use coordinate on well path as center --- .../Application/Tools/CMakeLists_files.cmake | 2 + .../Application/Tools/RiaExtractionTools.cpp | 81 +++++++++++++++++++ .../Application/Tools/RiaExtractionTools.h | 48 +++++++++++ .../RivVirtualConnFactorPartMgr.cpp | 40 +++++++-- 4 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 ApplicationCode/Application/Tools/RiaExtractionTools.cpp create mode 100644 ApplicationCode/Application/Tools/RiaExtractionTools.h diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index d8e76dd1af..9e533fd960 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -22,6 +22,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.h +${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -47,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.cpp b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp new file mode 100644 index 0000000000..56a2f25b10 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaExtractionTools.h" + +#include "RiaApplication.h" + +#include "RigWellPath.h" +#include "RimEclipseCase.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" +#include "RimWellLogPlotCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseWellLogExtractor* RiaExtractionTools::wellLogExtractorEclipseCase(RimWellPath* wellPath, RimEclipseCase* eclipseCase) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + return wlPlotCollection->findOrCreateExtractor(wellPath, eclipseCase); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechWellLogExtractor* RiaExtractionTools::wellLogExtractorGeoMechCase(RimWellPath* wellPath, RimGeoMechCase* geomCase) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + return wlPlotCollection->findOrCreateExtractor(wellPath, geomCase); +} + +/* +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor(const QString& simWellName, + const QString& caseUserDescription, + const RigWellPath* wellPathGeom, + const RimEclipseCase* eclipseCase) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + return wlPlotCollection->findOrCreateSimWellExtractor( + simWellName, caseUserDescription, wellPathGeom, eclipseCase->eclipseCaseData()); +} +*/ + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCollection* RiaExtractionTools::wellLogPlotCollection() +{ + auto proj = RiaApplication::instance()->project(); + if (!proj) return nullptr; + + auto plotCollection = proj->mainPlotCollection(); + if (!plotCollection) return nullptr; + + auto wellLogPlotCollection = plotCollection->wellLogPlotCollection(); + return wellLogPlotCollection; +} diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.h b/ApplicationCode/Application/Tools/RiaExtractionTools.h new file mode 100644 index 0000000000..8690884c05 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RigEclipseWellLogExtractor; +class RigGeoMechWellLogExtractor; +class RimEclipseCase; +class RimGeoMechCase; +class RimWellLogPlotCollection; +class RimWellPath; +class RigWellPath; + +class QString; + +//================================================================================================== +// +//================================================================================================== +namespace RiaExtractionTools +{ +RigEclipseWellLogExtractor* wellLogExtractorEclipseCase(RimWellPath* wellPath, RimEclipseCase* eclipseCase); +RigGeoMechWellLogExtractor* wellLogExtractorGeoMechCase(RimWellPath* wellPath, RimGeoMechCase* geomCase); + +/* +RigEclipseWellLogExtractor* findOrCreateSimWellExtractor(const QString& simWellName, + const QString& caseUserDescription, + const RigWellPath* wellPathGeom, + const RimEclipseCase* eclipseCase); +*/ + +RimWellLogPlotCollection* wellLogPlotCollection(); + +}; // namespace RiaExtractionTools diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp index 62dd162314..3315377e37 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -20,8 +20,10 @@ #include "RiaApplication.h" +#include "RigEclipseWellLogExtractor.h" #include "RigMainGrid.h" #include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellPath.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" @@ -32,6 +34,8 @@ #include "RiuViewer.h" +#include "RiaExtractionTools.h" +#include "RigWellLogExtractor.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" #include "cafPdmFieldCvfColor.h" @@ -80,17 +84,43 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex); - std::vector> centerColorPairs; + std::vector wellPathCellIntersections; + { + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase); + if (extractor) + { + wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); + } + } + std::vector> centerColorPairs; for (const auto& cell : conn) { size_t gridIndex = cell.first.globalCellIndex(); - const RigCell& rigCell = mainGrid->cell(gridIndex); - cvf::Vec3d center = rigCell.center(); - cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(center); + const RigCell& rigCell = mainGrid->cell(gridIndex); + + cvf::Vec3d locationInDomainCoord = rigCell.center(); + + if (!wellPathCellIntersections.empty()) + { + for (const auto& intersectionInfo : wellPathCellIntersections) + { + if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) + { + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; + + double middleMD = (startMD + endMD) / 2.0; + + locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + + continue; + } + } + } - cvf::Color3f color = cvf::Color3f::BLUE; + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); double transmissibility = HUGE_VAL; if (!cell.second.empty()) From ca0c13be413b81128642440e214befc626ccd43c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 14:29:48 +0100 Subject: [PATCH 0499/1027] #2544 Use helper class to get extractors --- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 16 ++++------ .../ProjectDataModel/RimWellLogTrack.cpp | 29 ++++--------------- .../ProjectDataModel/RimWellLogTrack.h | 2 -- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index ab61bb41a5..5c66693d08 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,10 +18,12 @@ #include "Rim3dWellLogCurve.h" -#include "RiaApplication.h" +#include "RiaExtractionTools.h" + #include "RigEclipseWellLogExtractor.h" #include "RigGeoMechWellLogExtractor.h" #include "RigResultAccessorFactory.h" + #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -181,14 +183,6 @@ void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, st CAF_ASSERT(resultValues != nullptr); CAF_ASSERT(measuredDepthValues != nullptr); - RimProject* proj = RiaApplication::instance()->project(); - - RimMainPlotCollection* mainPlotCollection = proj->mainPlotCollection; - if (!mainPlotCollection) return; - - RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection(); - if (!wellLogCollection) return; - cvf::ref eclExtractor; cvf::ref geomExtractor; @@ -199,14 +193,14 @@ void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, st if (eclipseCase) { - eclExtractor = wellLogCollection->findOrCreateExtractor(wellPath, eclipseCase); + eclExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(wellPath, eclipseCase); } else { RimGeoMechCase* geomCase = dynamic_cast(m_case()); if (geomCase) { - geomExtractor = wellLogCollection->findOrCreateExtractor(wellPath, geomCase); + geomExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(wellPath, geomCase); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index aafbeffed8..d3c8bcbde5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -59,6 +59,7 @@ #include "qwt_scale_engine.h" #include "RiaSimWellBranchTools.h" +#include "RiaExtractionTools.h" #define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0 #define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0 @@ -1040,26 +1041,6 @@ RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor(RimWellLogPl eclipseCase->eclipseCaseData())); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigEclipseWellLogExtractor* RimWellLogTrack::createWellPathExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath) -{ - if (!wellLogCollection) return nullptr; - - RimEclipseCase* eclipseCase = dynamic_cast(rimCase); - return (wellLogCollection->findOrCreateExtractor(wellPath, eclipseCase)); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigGeoMechWellLogExtractor* RimWellLogTrack::createGeoMechExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath) -{ - RimGeoMechCase* geomCase = dynamic_cast(rimCase); - return (wellLogCollection->findOrCreateExtractor(wellPath, geomCase)); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1252,9 +1233,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot() } else { - eclWellLogExtractor = RimWellLogTrack::createWellPathExtractor(wellLogCollection, - m_formationCase, - m_formationWellPathForSourceCase); + eclWellLogExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_formationWellPathForSourceCase, + dynamic_cast(m_formationCase())); } if (eclWellLogExtractor) @@ -1271,7 +1251,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot() } else { - geoMechWellLogExtractor = RimWellLogTrack::createGeoMechExtractor(wellLogCollection, m_formationCase, m_formationWellPathForSourceCase); + geoMechWellLogExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(m_formationWellPathForSourceCase, + dynamic_cast(m_formationCase())); if (!geoMechWellLogExtractor) return; std::string activeFormationNamesResultName = RiaDefines::activeFormationNamesResultName().toStdString(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 500c746932..c6a7b70729 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -134,8 +134,6 @@ class RimWellLogTrack : public caf::PdmObject static void simWellOptionItems(QList* options, RimCase* eclCase); static RigEclipseWellLogExtractor* createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection); - static RigEclipseWellLogExtractor* createWellPathExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath); - static RigGeoMechWellLogExtractor* createGeoMechExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath); static CurveSamplingPointData curveSamplingPointData(RigEclipseWellLogExtractor* extractor, RigResultAccessor* resultAccessor); static CurveSamplingPointData curveSamplingPointData(RigGeoMechWellLogExtractor* extractor, const RigFemResultAddress& resultAddress); From 06b619cd177c0737f317e0845823ef614c273954 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 15:04:32 +0100 Subject: [PATCH 0500/1027] Clang : Set AllowShortCaseLabelsOnASingleLine to false --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index f3a6bf266c..04867544d7 100644 --- a/.clang-format +++ b/.clang-format @@ -10,7 +10,7 @@ AlignOperands: true AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortFunctionsOnASingleLine: Empty AllowShortLoopsOnASingleLine: false From 543c99371b3535552220623e3909681918cdb4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Mar 2018 11:33:22 +0100 Subject: [PATCH 0501/1027] #2552 Use displayCoordTransform and redability changes --- .../ModelVisualization/RivSimWellPipesPartMgr.cpp | 8 +++----- .../ModelVisualization/RivWellPathsPartMgr.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index ecb79200dd..27d1a465fe 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -50,6 +50,7 @@ #include "cvfRay.h" #include "cvfScalarMapperDiscreteLinear.h" #include "cvfTransform.h" +#include "cafDisplayCoordTransform.h" //-------------------------------------------------------------------------------------------------- @@ -122,14 +123,11 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - const RigMainGrid* mainGrid = m_rimReservoirView->mainGrid(); + cvf::ref displayCoordXf = m_rimReservoirView->displayCoordTransform(); for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) { - cvf::Vec4d transfCoord = m_scaleTransform->worldTransform()* cvf::Vec4d((*cvfCoords)[cIdx] - mainGrid->displayModelOffset(), 1); - (*cvfCoords)[cIdx][0] = transfCoord[0]; - (*cvfCoords)[cIdx][1] = transfCoord[1]; - (*cvfCoords)[cIdx][2] = transfCoord[2]; + (*cvfCoords)[cIdx] = displayCoordXf->transformToDisplayCoord((*cvfCoords)[cIdx]); } pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index b8d0d753a7..13de516a3c 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -40,7 +40,8 @@ RivWellPathsPartMgr::~RivWellPathsPartMgr() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, double characteristicCellSize, +void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) { @@ -72,7 +73,8 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, const QDateTime& timeStamp, +void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + const QDateTime& timeStamp, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) @@ -83,7 +85,10 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* for (auto& partMgr : m_wellPatshsPartMgrs) { - partMgr->appendDynamicGeometryPartsToModel(model, timeStamp, characteristicCellSize, wellPathClipBoundingBox, + partMgr->appendDynamicGeometryPartsToModel(model, + timeStamp, + characteristicCellSize, + wellPathClipBoundingBox, displayCoordTransform); } } From e314450e2e2a484e238d9b4e37db4d3556cec333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Mar 2018 12:36:39 +0100 Subject: [PATCH 0502/1027] #2552 Minor refactoring --- .../ModelVisualization/RivSimWellPipesPartMgr.cpp | 5 +++-- ApplicationCode/ProjectDataModel/RimSimWellInView.cpp | 10 ++++++++++ ApplicationCode/ProjectDataModel/RimSimWellInView.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 27d1a465fe..c3430da4e4 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -104,6 +104,8 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() m_rimWell->calculateWellPipeStaticCenterLine(m_pipeBranchesCLCoords, pipeBranchesCellIds); double pipeRadius = m_rimWell->pipeRadius(); + int crossSectionVertexCount = m_rimWell->pipeCrossSectionVertexCount(); + cvf::ref displayCoordXf = m_rimReservoirView->displayCoordTransform(); for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) { @@ -117,13 +119,12 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; pbd.m_pipeGeomGenerator->setRadius(pipeRadius); - pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); + pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(crossSectionVertexCount); cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - cvf::ref displayCoordXf = m_rimReservoirView->displayCoordTransform(); for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) { diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index bf2bda91c9..57ac920432 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -281,6 +281,16 @@ double RimSimWellInView::pipeRadius() return pipeRadius; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSimWellInView::pipeCrossSectionVertexCount() +{ + RimSimWellInViewCollection* simWellCollection = nullptr; + this->firstAncestorOrThisOfTypeAsserted(simWellCollection); + return simWellCollection->pipeCrossSectionVertexCount(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index 79728c2aeb..770c43f6b3 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -72,6 +72,7 @@ class RimSimWellInView : public caf::PdmObject void wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); + int pipeCrossSectionVertexCount(); void schedule2dIntersectionViewUpdate(); From 1fa898b79834c997d9cc16e0c2ac052c1546163f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Mar 2018 14:08:45 +0100 Subject: [PATCH 0503/1027] #2552 Small refactorings --- .../Intersections/RivSectionFlattner.cpp | 9 +++++++-- .../ModelVisualization/RivWellHeadPartMgr.cpp | 5 +++-- ApplicationCode/ProjectDataModel/Rim3dView.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp index ab4aa91419..de45bd2f07 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp @@ -26,7 +26,9 @@ /// /// Returns size_t(-1) if no point is found //-------------------------------------------------------------------------------------------------- -size_t RivSectionFlattner::indexToNextValidPoint(const std::vector& polyLine, const cvf::Vec3d extrDir, size_t idxToStartOfLineSegment) +size_t RivSectionFlattner::indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment) { size_t lineCount = polyLine.size(); if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; @@ -51,7 +53,10 @@ size_t RivSectionFlattner::indexToNextValidPoint(const std::vector& //-------------------------------------------------------------------------------------------------- /// Returns one CS pr point, valid for the next segment //-------------------------------------------------------------------------------------------------- -std::vector RivSectionFlattner::calculateFlatteningCSsForPolyline(const std::vector & polyLine, const cvf::Vec3d& extrusionDir, const cvf::Vec3d& startOffset, cvf::Vec3d* endOffset) +std::vector RivSectionFlattner::calculateFlatteningCSsForPolyline(const std::vector & polyLine, + const cvf::Vec3d& extrusionDir, + const cvf::Vec3d& startOffset, + cvf::Vec3d* endOffset) { CVF_ASSERT(endOffset); size_t pointCount = polyLine.size(); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 3a3e9e953e..5aaea1bdbe 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -103,6 +103,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex); double pipeRadius = m_rimWell->pipeRadius(); + int pipeCrossSectionVxCount = m_rimWell->pipeCrossSectionVertexCount(); if (wellResultFrame.m_isOpen) { @@ -125,7 +126,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) cvf::ref pipeGeomGenerator = new RivPipeGeometryGenerator; pipeGeomGenerator->setPipeCenterCoords(wellHeadPipeCoords.p()); - pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); + pipeGeomGenerator->setCrossSectionVertexCount(pipeCrossSectionVxCount); pipeGeomGenerator->setRadius(pipeRadius); @@ -207,7 +208,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) gen.setShaftRelativeRadius(0.5f); gen.setHeadRelativeRadius(1.0f); gen.setHeadRelativeLength(0.4f); - gen.setNumSlices(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); + gen.setNumSlices(pipeCrossSectionVxCount); gen.generate(&builder); cvf::ref vertices = builder.vertices(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 8bbaf7f4fa..8cd8b199cb 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -668,10 +668,10 @@ void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBas } m_wellPathsPartManager->appendDynamicGeometryPartsToModel(wellPathModelBasicList, - currentTimeStamp, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); + currentTimeStamp, + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox, + transForm.p()); wellPathModelBasicList->updateBoundingBoxesRecursive(); } From e52c88ff774464a5263120293a5e7659e1390418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 12 Mar 2018 14:09:59 +0100 Subject: [PATCH 0504/1027] #2552 WIP : Add flattening code to simwell part generator --- .../RivSimWellPipesPartMgr.cpp | 34 ++++++++++++++----- .../RivSimWellPipesPartMgr.h | 3 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index c3430da4e4..9e2086bfee 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -51,16 +51,17 @@ #include "cvfScalarMapperDiscreteLinear.h" #include "cvfTransform.h" #include "cafDisplayCoordTransform.h" +#include "RivSectionFlattner.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well) +RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well, bool isFlattened) + : m_rimReservoirView(reservoirView) + , m_needsTransformUpdate(true) + , m_isFlattened(isFlattened) { - m_rimReservoirView = reservoirView; - m_rimWell = well; - m_needsTransformUpdate = true; } //-------------------------------------------------------------------------------------------------- @@ -107,6 +108,8 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() int crossSectionVertexCount = m_rimWell->pipeCrossSectionVertexCount(); cvf::ref displayCoordXf = m_rimReservoirView->displayCoordTransform(); + cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO; + for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) { cvf::ref sourceInfo = new RivSimWellPipeSourceInfo(m_rimWell, brIdx); @@ -123,14 +126,27 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); - - // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) - { - (*cvfCoords)[cIdx] = displayCoordXf->transformToDisplayCoord((*cvfCoords)[cIdx]); + if (m_isFlattened) + { + std::vector flatningCSs = RivSectionFlattner::calculateFlatteningCSsForPolyline(m_pipeBranchesCLCoords[brIdx], + cvf::Vec3d(0, 0, 1), + flattenedStartOffset, + &flattenedStartOffset); + for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) + { + (*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]); + } } + else + { + // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) + { + (*cvfCoords)[cIdx] = displayCoordXf->transformToDisplayCoord((*cvfCoords)[cIdx]); + } + } pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); pbd.m_surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); pbd.m_centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 6fff0946dd..f42afaa28b 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -44,7 +44,7 @@ class RimSimWellInView; class RivSimWellPipesPartMgr : public cvf::Object { public: - RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); + RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well, bool isFlattened = false); ~RivSimWellPipesPartMgr(); void setScaleTransform(cvf::Transform * scaleTransform); @@ -60,6 +60,7 @@ class RivSimWellPipesPartMgr : public cvf::Object cvf::ref m_scaleTransform; bool m_needsTransformUpdate; + bool m_isFlattened; void buildWellPipeParts(); From b755ddc11d889782a4cb226795459313abb41b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 13 Mar 2018 16:16:41 +0100 Subject: [PATCH 0505/1027] #2552 Embed pipe visualization of Simulation Wells in intersection views --- .../RivIntersectionGeometryGenerator.cpp | 6 +- .../RivIntersectionGeometryGenerator.h | 4 +- .../Intersections/RivIntersectionPartMgr.cpp | 13 +-- .../RivReservoirSimWellsPartMgr.cpp | 7 +- .../RivSimWellPipesPartMgr.cpp | 85 +++++++++---------- .../RivSimWellPipesPartMgr.h | 43 +++++----- .../Rim2dIntersectionView.cpp | 36 ++++++++ .../ProjectDataModel/Rim2dIntersectionView.h | 2 + .../ProjectDataModel/Rim3dView.cpp | 21 +++++ ApplicationCode/ProjectDataModel/Rim3dView.h | 2 + .../ProjectDataModel/RimGridView.cpp | 20 ----- .../ProjectDataModel/RimGridView.h | 1 - .../ProjectDataModel/RimIntersection.cpp | 25 ++++-- .../ProjectDataModel/RimIntersection.h | 4 +- 14 files changed, 164 insertions(+), 105 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index d5f166e4c7..c2c09f6ebf 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -61,13 +61,13 @@ RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersect const cvf::Vec3d& extrusionDirection, const RivIntersectionHexGridInterface* grid, bool isFlattened, - double horizontalLengthAlongWellToPolylineStart) + const cvf::Vec3d& flattenedPolylineStartPoint) : m_crossSection(crossSection), m_polyLines(polylines), m_extrusionDirection(extrusionDirection), m_hexGrid(grid), m_isFlattened(isFlattened), - m_horizontalLengthAlongWellToPolylineStart(horizontalLengthAlongWellToPolylineStart) + m_flattenedPolylineStartPoint(flattenedPolylineStartPoint) { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; @@ -91,7 +91,7 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() { if ( !(m_polyLines.size() && m_polyLines.back().size()) ) return; - cvf::Vec3d startOffset ={ m_horizontalLengthAlongWellToPolylineStart, 0.0, m_polyLines[0][0].z() }; + cvf::Vec3d startOffset = m_flattenedPolylineStartPoint; for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) { diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 5886659644..75e2fbcaec 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -51,7 +51,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object const cvf::Vec3d& extrusionDirection, const RivIntersectionHexGridInterface* grid, bool isFlattened, - double horizontalLengthAlongWellToPolylineStart); + const cvf::Vec3d& flattenedPolylineStartPoint); ~RivIntersectionGeometryGenerator(); @@ -93,7 +93,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object const std::vector > m_polyLines; cvf::Vec3d m_extrusionDirection; bool m_isFlattened; - double m_horizontalLengthAlongWellToPolylineStart; + cvf::Vec3d m_flattenedPolylineStartPoint; // Output arrays cvf::ref m_triangleVxes; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 9aeb67be8f..dc5a2430b6 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -83,9 +83,9 @@ RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, m_crossSectionFacesTextureCoords = new cvf::Vec2fArray; - double horizontalLengthAlongWellToPolylineStart; + cvf::Vec3d flattenedPolylineStartPoint; - std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(&horizontalLengthAlongWellToPolylineStart); + std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(&flattenedPolylineStartPoint); if (polyLines.size() > 0) { cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); @@ -95,7 +95,7 @@ RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, direction, hexGrid.p(), m_isFlattened, - horizontalLengthAlongWellToPolylineStart); + flattenedPolylineStartPoint); } } @@ -778,7 +778,7 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod cvf::Color3f wellPipeColor = cvf::Color3f::GRAY; double characteristicCellSize = 0; - if ( m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL ) + if ( false)//m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL ) { RimSimWellInView * simWellInView = m_rimCrossSection->simulationWell(); @@ -818,8 +818,9 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod // Create pipe geometry - if ( m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL - || m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH ) + if ( //m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL + //|| + m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH ) { std::vector > polyLines = m_crossSectionGenerator->flattenedOrOffsettedPolyLines(); diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp index 71c694a1b3..846bdf2805 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp @@ -36,6 +36,7 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" +#include "cafDisplayCoordTransform.h" #include "cvfTransform.h" @@ -95,7 +96,7 @@ void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * scaleTransf for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) { - m_wellPipesPartMgrs[wIdx]->setScaleTransform(scaleTransform); + m_wellPipesPartMgrs[wIdx]->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p()); } for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) @@ -117,9 +118,9 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) { - RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); + RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i], false); m_wellPipesPartMgrs.push_back(wppmgr); - wppmgr->setScaleTransform(m_scaleTransform.p()); + wppmgr->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p()); RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); m_wellHeadPartMgrs.push_back(wellHeadMgr); diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 9e2086bfee..988e330edb 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -31,7 +31,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipsePropertyFilterCollection.h" -#include "RimEclipseView.h" +#include "Rim3dView.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" @@ -52,15 +52,16 @@ #include "cvfTransform.h" #include "cafDisplayCoordTransform.h" #include "RivSectionFlattner.h" - +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well, bool isFlattened) - : m_rimReservoirView(reservoirView) - , m_needsTransformUpdate(true) - , m_isFlattened(isFlattened) +RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView) + : m_rimWell(well) + , m_needsToRebuildGeometry(true) + , m_intersectionView(intersectionView) { } @@ -75,10 +76,10 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform) +void RivSimWellPipesPartMgr::setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf) { - m_scaleTransform = scaleTransform; - + m_displayCoordTransform = displayXf; + scheduleGeometryRegen(); } @@ -87,7 +88,18 @@ void RivSimWellPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform) //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::scheduleGeometryRegen() { - m_needsTransformUpdate = true; + m_needsToRebuildGeometry = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView* RivSimWellPipesPartMgr::viewWithSettings() +{ + Rim3dView* view = nullptr; + if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(view); + + return view; } //-------------------------------------------------------------------------------------------------- @@ -95,7 +107,7 @@ void RivSimWellPipesPartMgr::scheduleGeometryRegen() //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::buildWellPipeParts() { - if (m_rimReservoirView.isNull()) return; + if (!this->viewWithSettings()) return; m_wellBranches.clear(); @@ -106,9 +118,12 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() double pipeRadius = m_rimWell->pipeRadius(); int crossSectionVertexCount = m_rimWell->pipeCrossSectionVertexCount(); - cvf::ref displayCoordXf = m_rimReservoirView->displayCoordTransform(); - cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO; + cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO; + if ( m_pipeBranchesCLCoords.size() && m_pipeBranchesCLCoords[0].size() ) + { + flattenedStartOffset = { 0.0, 0.0, m_pipeBranchesCLCoords[0][0].z() }; + } for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) { @@ -127,15 +142,16 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); - if (m_isFlattened) + if (m_intersectionView) { std::vector flatningCSs = RivSectionFlattner::calculateFlatteningCSsForPolyline(m_pipeBranchesCLCoords[brIdx], - cvf::Vec3d(0, 0, 1), + cvf::Vec3d::Z_AXIS, flattenedStartOffset, &flattenedStartOffset); for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) { (*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]); + (*cvfCoords)[cIdx] = m_displayCoordTransform->scaleToDisplaySize((*cvfCoords)[cIdx]); } } else @@ -144,16 +160,17 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - (*cvfCoords)[cIdx] = displayCoordXf->transformToDisplayCoord((*cvfCoords)[cIdx]); + (*cvfCoords)[cIdx] = m_displayCoordTransform->transformToDisplayCoord((*cvfCoords)[cIdx]); } } + pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); pbd.m_surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); pbd.m_centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); if (pbd.m_surfaceDrawable.notNull()) { - pbd.m_surfacePart = new cvf::Part; + pbd.m_surfacePart = new cvf::Part(0,"SimWellPipeSurface"); pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWell->wellPipeColor()), caf::PO_1); @@ -166,7 +183,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() if (pbd.m_centerLineDrawable.notNull()) { - pbd.m_centerLinePart = new cvf::Part; + pbd.m_centerLinePart = new cvf::Part(0,"SimWellPipeCenterLine"); pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); caf::MeshEffectGenerator gen(m_rimWell->wellPipeColor()); @@ -181,31 +198,11 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() pbd.m_pipeGeomGenerator->setRadius(pipeRadius * 1.1); pbd.m_largeSurfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); } - } - - m_needsTransformUpdate = false; -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivPipeBranchData* RivSimWellPipesPartMgr::pipeBranchData(size_t branchIndex) -{ - if (branchIndex < m_wellBranches.size()) - { - size_t i = 0; - - auto brIt = m_wellBranches.begin(); - while (i < branchIndex) - { - brIt++; - i++; - } - - return &(*brIt); + if (m_intersectionView) flattenedStartOffset += { 2*m_intersectionView->intersection()->extentLength(), 0.0, 0.0}; } - return nullptr; + m_needsToRebuildGeometry = false; } //-------------------------------------------------------------------------------------------------- @@ -213,11 +210,11 @@ RivSimWellPipesPartMgr::RivPipeBranchData* RivSimWellPipesPartMgr::pipeBranchDat //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) { - if (m_rimReservoirView.isNull()) return; - if (m_rimWell.isNull()) return; + if (!viewWithSettings()) return; + if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - if (m_needsTransformUpdate) buildWellPipeParts(); + if (m_needsToRebuildGeometry) buildWellPipeParts(); std::list::iterator it; for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) @@ -269,7 +266,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfEffGen.disableLighting(true); } diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index f42afaa28b..1e6f74ea08 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -37,36 +37,43 @@ namespace cvf class DrawableGeo; } +namespace caf +{ + class DisplayCoordTransform; +} + class RivPipeGeometryGenerator; -class RimEclipseView; +class Rim3dView; class RimSimWellInView; +class Rim2dIntersectionView; class RivSimWellPipesPartMgr : public cvf::Object { public: - RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well, bool isFlattened = false); - ~RivSimWellPipesPartMgr(); + RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView = nullptr); - void setScaleTransform(cvf::Transform * scaleTransform); - - void scheduleGeometryRegen(); + ~RivSimWellPipesPartMgr(); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); - void updatePipeResultColor(size_t frameIndex); + void setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf); + void scheduleGeometryRegen(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + void updatePipeResultColor(size_t frameIndex); private: - caf::PdmPointer m_rimReservoirView; - caf::PdmPointer m_rimWell; - - cvf::ref m_scaleTransform; - bool m_needsTransformUpdate; - bool m_isFlattened; + Rim3dView* viewWithSettings(); + void buildWellPipeParts(); - void buildWellPipeParts(); + caf::PdmPointer m_rimWell; + caf::PdmPointer m_intersectionView; + bool m_isFlattened; + + cvf::ref m_displayCoordTransform; + bool m_needsToRebuildGeometry; struct RivPipeBranchData { - std::vector m_cellIds; + std::vector m_cellIds; cvf::ref m_pipeGeomGenerator; cvf::ref m_surfacePart; @@ -77,9 +84,7 @@ class RivSimWellPipesPartMgr : public cvf::Object }; - RivPipeBranchData* pipeBranchData(size_t branchIndex); - - std::list m_wellBranches; + std::list m_wellBranches; std::vector< std::vector > m_pipeBranchesCLCoords; }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 90e15d6b7f..311f363289 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -42,6 +42,7 @@ #include #include "cafDisplayCoordTransform.h" +#include "RivSimWellPipesPartMgr.h" CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); @@ -402,6 +403,20 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->applySingleColorEffect(); + m_flatSimWellPipePartMgr = nullptr; + + if ( m_intersection->type() == RimIntersection::CS_SIMULATION_WELL + && m_intersection->simulationWell() ) + { + RimEclipseView* eclipseView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclipseView); + + if ( eclipseView ) + { + m_flatSimWellPipePartMgr = new RivSimWellPipesPartMgr(m_intersection->simulationWell(), this); + } + } + m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); m_intersectionVizModel->updateBoundingBoxesRecursive(); @@ -446,6 +461,27 @@ void Rim2dIntersectionView::updateCurrentTimeStep() update3dInfo(); updateLegends(); + if ( m_flatSimWellPipePartMgr.notNull() ) + { + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + cvf::String name = "SimWellPipeMod"; + Rim3dView::removeModelByName(frameScene, name); + + cvf::ref simWellModelBasicList = new cvf::ModelBasicList; + simWellModelBasicList->setName(name); + + m_flatSimWellPipePartMgr->setDisplayCoordTransform(this->displayCoordTransform().p()); + m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), m_currentTimeStep); + + simWellModelBasicList->updateBoundingBoxesRecursive(); + frameScene->addModel(simWellModelBasicList.p()); + + m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); + } + } + if ((this->hasUserRequestedAnimation() && this->hasResults())) { m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep, diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 1449317049..2767179509 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -25,6 +25,7 @@ class RimIntersection; class RimLegendConfig; class RimTernaryLegendConfig; +class RivSimWellPipesPartMgr; namespace cvf { @@ -95,6 +96,7 @@ class Rim2dIntersectionView : public Rim3dView caf::PdmPtrField m_intersection; cvf::ref m_flatIntersectionPartMgr; + cvf::ref m_flatSimWellPipePartMgr; cvf::ref m_intersectionVizModel; cvf::ref m_scaleTransform; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 8cd8b199cb..926b2f635f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -49,6 +49,7 @@ #include #include +#include "cvfScene.h" namespace caf { @@ -362,6 +363,26 @@ void Rim3dView::createDisplayModelAndRedraw() RiuMainWindow::instance()->refreshAnimationActions(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +{ + std::vector modelsToBeRemoved; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == modelName) + { + modelsToBeRemoved.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + { + scene->removeModel(modelsToBeRemoved[i]); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 3b12a240e4..d632662cc8 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -151,6 +151,8 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual RimCase* ownerCase() const = 0; protected: + static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); + virtual void setDefaultView(); void disableGridBoxField(); void disablePerspectiveProjectionField(); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 1ffa00080c..50bffb09bc 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -264,26 +264,6 @@ Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const return m_overlayInfoConfig; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) -{ - std::vector modelsToBeRemoved; - for (cvf::uint i = 0; i < scene->modelCount(); i++) - { - if (scene->model(i)->name() == modelName) - { - modelsToBeRemoved.push_back(scene->model(i)); - } - } - - for (size_t i = 0; i < modelsToBeRemoved.size(); i++) - { - scene->removeModel(modelsToBeRemoved[i]); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h index f4fc95f086..75c084dcc5 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.h +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -47,7 +47,6 @@ class RimGridView : public Rim3dView RimViewLinker* assosiatedViewLinker() const override; protected: - static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); virtual void onTimeStepChanged() override; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 7a16add90a..32963d4369 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -390,9 +390,9 @@ void RimIntersection::updateAzimuthLine() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > RimIntersection::polyLines(double * horizontalLengthAlongWellToPolylineStart) const +std::vector< std::vector > RimIntersection::polyLines(cvf::Vec3d * flattenedPolylineStartPoint) const { - if (horizontalLengthAlongWellToPolylineStart) *horizontalLengthAlongWellToPolylineStart = 0.0; + if (flattenedPolylineStartPoint) *flattenedPolylineStartPoint = cvf::Vec3d::ZERO; std::vector< std::vector > lines; @@ -455,12 +455,19 @@ std::vector< std::vector > RimIntersection::polyLines(double * hori addExtents(polyLine); } - if (horizontalLengthAlongWellToPolylineStart) + if (flattenedPolylineStartPoint && lines.size() && lines[0].size() > 1) { - *horizontalLengthAlongWellToPolylineStart = horizontalProjectedLengthAlongWellPathToClipPoint - m_extentLength; + (*flattenedPolylineStartPoint)[0] = horizontalProjectedLengthAlongWellPathToClipPoint - m_extentLength; + (*flattenedPolylineStartPoint)[2] = lines[0][1].z(); // Depth of first point in first polyline + } + } + else + { + if ( flattenedPolylineStartPoint && lines.size() && lines[0].size() ) + { + (*flattenedPolylineStartPoint)[2] = lines[0][0].z(); // Depth of first point in first polyline } } - return lines; } @@ -891,6 +898,14 @@ void RimIntersection::setLengthDown(double lengthDown) m_lengthDown = lengthDown; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimIntersection::extentLength() +{ + return m_extentLength(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 9459910f44..4da76dfc17 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -84,7 +84,7 @@ class RimIntersection : public caf::PdmObject caf::PdmField< bool > inputExtrusionPointsFromViewerEnabled; caf::PdmField< bool > inputTwoAzimuthPointsFromViewerEnabled; - std::vector< std::vector > polyLines(double * horizontalLengthAlongWellToPolylineStart = nullptr) const; + std::vector< std::vector > polyLines(cvf::Vec3d * flattenedPolylineStartPoint = nullptr) const; void appendPointToPolyLine(const cvf::Vec3d& point); Rim2dIntersectionView* correspondingIntersectionView(); @@ -100,7 +100,7 @@ class RimIntersection : public caf::PdmObject double lengthDown() const; void setLengthUp(double heightUp); void setLengthDown(double heightDown); - + double extentLength(); void recomputeSimulationWellBranchData(); bool hasDefiningPoints() const; From 9cad0bff1e2b63b8cf7029fc27a7e0ea176cdc77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 13 Mar 2018 17:19:14 +0100 Subject: [PATCH 0506/1027] #2552 Refactor and align the partmanagers of sim well and sim well head. Prepare to get wellhead into 2d intersection views --- .../RivReservoirSimWellsPartMgr.cpp | 33 +++------- .../RivSimWellPipesPartMgr.cpp | 32 +++------- .../RivSimWellPipesPartMgr.h | 13 ++-- .../ModelVisualization/RivWellHeadPartMgr.cpp | 62 ++++++++++++------- .../ModelVisualization/RivWellHeadPartMgr.h | 27 ++++---- .../Rim2dIntersectionView.cpp | 5 +- 6 files changed, 75 insertions(+), 97 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp index 846bdf2805..54b32d8515 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp @@ -74,16 +74,6 @@ void RivReservoirSimWellsPartMgr::clearGeometryCache() //-------------------------------------------------------------------------------------------------- void RivReservoirSimWellsPartMgr::scheduleGeometryRegen() { - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->scheduleGeometryRegen(); - } - - for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) - { - //m_wellHeadPartMgrs[wIdx]->scheduleGeometryRegen(scaleTransform); - } - m_wellSpheresPartMgrs.clear(); } @@ -93,16 +83,6 @@ void RivReservoirSimWellsPartMgr::scheduleGeometryRegen() void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; - - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p()); - } - - for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) - { - m_wellHeadPartMgrs[wIdx]->setScaleTransform(scaleTransform); - } } //-------------------------------------------------------------------------------------------------- @@ -120,18 +100,21 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa { RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i], false); m_wellPipesPartMgrs.push_back(wppmgr); - wppmgr->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p()); - RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); + RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView->wellCollection()->wells[i]); m_wellHeadPartMgrs.push_back(wellHeadMgr); - wellHeadMgr->setScaleTransform(m_scaleTransform.p()); + } } for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) { - m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, + frameIndex, + m_reservoirView->displayCoordTransform().p()); + m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, + frameIndex, + m_reservoirView->displayCoordTransform().p()); } // Well spheres diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 988e330edb..3636649175 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -60,7 +60,6 @@ //-------------------------------------------------------------------------------------------------- RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView) : m_rimWell(well) - , m_needsToRebuildGeometry(true) , m_intersectionView(intersectionView) { } @@ -73,24 +72,6 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf) -{ - m_displayCoordTransform = displayXf; - - scheduleGeometryRegen(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::scheduleGeometryRegen() -{ - m_needsToRebuildGeometry = true; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -105,7 +86,7 @@ Rim3dView* RivSimWellPipesPartMgr::viewWithSettings() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::buildWellPipeParts() +void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf) { if (!this->viewWithSettings()) return; @@ -151,7 +132,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) { (*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]); - (*cvfCoords)[cIdx] = m_displayCoordTransform->scaleToDisplaySize((*cvfCoords)[cIdx]); + (*cvfCoords)[cIdx] = displayXf->scaleToDisplaySize((*cvfCoords)[cIdx]); } } else @@ -160,7 +141,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - (*cvfCoords)[cIdx] = m_displayCoordTransform->transformToDisplayCoord((*cvfCoords)[cIdx]); + (*cvfCoords)[cIdx] = displayXf->transformToDisplayCoord((*cvfCoords)[cIdx]); } } @@ -202,19 +183,20 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() if (m_intersectionView) flattenedStartOffset += { 2*m_intersectionView->intersection()->extentLength(), 0.0, 0.0}; } - m_needsToRebuildGeometry = false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf) { if (!viewWithSettings()) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - if (m_needsToRebuildGeometry) buildWellPipeParts(); + buildWellPipeParts(displayXf); std::list::iterator it; for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 1e6f74ea08..1f7c015786 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -54,22 +54,17 @@ class RivSimWellPipesPartMgr : public cvf::Object ~RivSimWellPipesPartMgr(); - void setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf); - void scheduleGeometryRegen(); - - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf); void updatePipeResultColor(size_t frameIndex); private: Rim3dView* viewWithSettings(); - void buildWellPipeParts(); + void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf); caf::PdmPointer m_rimWell; caf::PdmPointer m_intersectionView; - bool m_isFlattened; - - cvf::ref m_displayCoordTransform; - bool m_needsToRebuildGeometry; struct RivPipeBranchData { diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 5aaea1bdbe..c3272fdeb9 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -56,10 +56,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellHeadPartMgr::RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well) +RivWellHeadPartMgr::RivWellHeadPartMgr(RimSimWellInView* well) +: m_rimWell(well) { - m_rimReservoirView = reservoirView; - m_rimWell = well; } //-------------------------------------------------------------------------------------------------- @@ -73,31 +72,27 @@ RivWellHeadPartMgr::~RivWellHeadPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) +void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, + const caf::DisplayCoordTransform * displayXf) { clearAllGeometry(); - if (m_rimReservoirView.isNull()) return; + if (!viewWithSettings()) return; - RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData(); - RimSimWellInView* well = m_rimWell; - double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); + double characteristicCellSize = viewWithSettings()->ownerCase()->characteristicCellSize(); cvf::Vec3d whEndPos; cvf::Vec3d whStartPos; { well->wellHeadTopBottomPosition(static_cast(frameIndex), &whEndPos, &whStartPos); - cvf::ref transForm = m_rimReservoirView->displayCoordTransform(); - whEndPos = transForm->transformToDisplayCoord(whEndPos); - whStartPos = transForm->transformToDisplayCoord(whStartPos); + whEndPos = displayXf->transformToDisplayCoord(whEndPos); + whStartPos = displayXf->transformToDisplayCoord(whStartPos); whEndPos.z() += characteristicCellSize; } - - if (!well->simWellData()->hasWellResult(frameIndex)) return; const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex); @@ -141,7 +136,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) part->setDrawable(pipeSurface.p()); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfaceGen.enableLighting(false); } @@ -170,7 +165,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) } } - double arrowLength = characteristicCellSize * m_rimReservoirView->wellCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); + double arrowLength = characteristicCellSize * simWellInViewCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); if (wellResultFrame.m_isOpen) { @@ -269,7 +264,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) } caf::SurfaceEffectGenerator surfaceGen(headColor, caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfaceGen.enableLighting(false); } @@ -291,7 +286,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) drawableText->setDrawBorder(false); drawableText->setDrawBackground(false); drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER); - drawableText->setTextColor(m_rimReservoirView->wellCollection()->wellLabelColor()); + drawableText->setTextColor(simWellInViewCollection()->wellLabelColor()); cvf::String cvfString = cvfqt::Utils::toString(m_rimWell->name()); @@ -326,18 +321,16 @@ void RivWellHeadPartMgr::clearAllGeometry() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf) { - if (m_rimReservoirView.isNull()) return; if (m_rimWell.isNull()) return; - - RimSimWellInViewCollection* wellCollection = nullptr; - m_rimWell->firstAncestorOrThisOfType(wellCollection); - if (!wellCollection) return; + if (!viewWithSettings()) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellHeadParts(frameIndex); + buildWellHeadParts(frameIndex, displayXf); // Always add pipe part of well head if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); @@ -356,4 +349,25 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView* RivWellHeadPartMgr::viewWithSettings() +{ + Rim3dView* view = nullptr; + if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(view); + + return view; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInViewCollection* RivWellHeadPartMgr::simWellInViewCollection() +{ + RimSimWellInViewCollection* wellCollection = nullptr; + if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(wellCollection); + + return wellCollection; +} diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index 6ac6ec3f44..d4c38b33cf 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -30,32 +30,35 @@ namespace cvf class Transform; class Font; } +namespace caf +{ + class DisplayCoordTransform; +} -class RimEclipseView; +class Rim3dView; class RimSimWellInView; +class RimSimWellInViewCollection; class RivWellHeadPartMgr : public cvf::Object { public: - RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); + RivWellHeadPartMgr( RimSimWellInView* well); ~RivWellHeadPartMgr(); - void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;} - - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf); private: - void buildWellHeadParts(size_t frameIndex); - void clearAllGeometry(); - - + void buildWellHeadParts(size_t frameIndex, + const caf::DisplayCoordTransform * displayXf); + void clearAllGeometry(); + Rim3dView* viewWithSettings(); + RimSimWellInViewCollection* simWellInViewCollection(); private: - caf::PdmPointer m_rimReservoirView; caf::PdmPointer m_rimWell; - cvf::ref m_scaleTransform; - cvf::ref< cvf::Part > m_wellHeadArrowPart; cvf::ref< cvf::Part > m_wellHeadLabelPart; cvf::ref< cvf::Part > m_wellHeadPipeSurfacePart; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 311f363289..4506f3253a 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -472,8 +472,9 @@ void Rim2dIntersectionView::updateCurrentTimeStep() cvf::ref simWellModelBasicList = new cvf::ModelBasicList; simWellModelBasicList->setName(name); - m_flatSimWellPipePartMgr->setDisplayCoordTransform(this->displayCoordTransform().p()); - m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), m_currentTimeStep); + m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p()); simWellModelBasicList->updateBoundingBoxesRecursive(); frameScene->addModel(simWellModelBasicList.p()); From 186125528137646092145ba53149bab80742f118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Mar 2018 10:33:10 +0100 Subject: [PATCH 0507/1027] #2552 Fix visualization of branch-depth, both wells and intersection geoemetry. --- .../RivIntersectionGeometryGenerator.cpp | 1 + .../RivReservoirSimWellsPartMgr.cpp | 2 +- .../RivSimWellPipesPartMgr.cpp | 118 ++++++++++++------ .../RivSimWellPipesPartMgr.h | 14 ++- .../Rim2dIntersectionView.cpp | 38 ++++-- .../ProjectDataModel/Rim2dIntersectionView.h | 2 + .../ProjectDataModel/RimIntersection.h | 2 +- 7 files changed, 123 insertions(+), 54 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index c2c09f6ebf..3b0b946c7a 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -96,6 +96,7 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) { const std::vector& polyLine = m_polyLines[pLineIdx]; + startOffset.z() = polyLine[0].z(); m_segementTransformPrLinePoint.emplace_back(RivSectionFlattner::calculateFlatteningCSsForPolyline(polyLine, m_extrusionDirection, startOffset, diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp index 54b32d8515..e83e869107 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp @@ -98,7 +98,7 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) { - RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i], false); + RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i]); m_wellPipesPartMgrs.push_back(wppmgr); RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView->wellCollection()->wells[i]); diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 3636649175..7bfcea7c93 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -58,9 +58,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView) +RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well) : m_rimWell(well) - , m_intersectionView(intersectionView) { } @@ -86,7 +85,68 @@ Rim3dView* RivSimWellPipesPartMgr::viewWithSettings() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf) +void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf) +{ + if (!viewWithSettings()) return; + + if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + + buildWellPipeParts(displayXf, false, 0.0, -1); + + std::list::iterator it; + for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) + { + if (it->m_surfacePart.notNull()) + { + model->addPart(it->m_surfacePart.p()); + } + + if (it->m_centerLinePart.notNull()) + { + model->addPart(it->m_centerLinePart.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf, + double flattenedIntersectionExtentLength, + int branchIndex) +{ + if (!viewWithSettings()) return; + + if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + + buildWellPipeParts(displayXf, true, flattenedIntersectionExtentLength, branchIndex); + + std::list::iterator it; + for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) + { + if (it->m_surfacePart.notNull()) + { + model->addPart(it->m_surfacePart.p()); + } + + if (it->m_centerLinePart.notNull()) + { + model->addPart(it->m_centerLinePart.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, + bool doFlatten, + double flattenedIntersectionExtentLength, + int branchIndex) { if (!this->viewWithSettings()) return; @@ -100,13 +160,25 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform double pipeRadius = m_rimWell->pipeRadius(); int crossSectionVertexCount = m_rimWell->pipeCrossSectionVertexCount(); + // Take branch selection into account + size_t branchIdxStart = 0; + size_t branchIdxStop = pipeBranchesCellIds.size(); + if (m_pipeBranchesCLCoords.size() > 1) + { + if (branchIndex >= 0 && branchIndex < branchIdxStop) + { + branchIdxStart = branchIndex; + branchIdxStop = branchIdxStart + 1; + } + } + cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO; - if ( m_pipeBranchesCLCoords.size() && m_pipeBranchesCLCoords[0].size() ) + if ( m_pipeBranchesCLCoords.size() > branchIdxStart && m_pipeBranchesCLCoords[branchIdxStart].size() ) { - flattenedStartOffset = { 0.0, 0.0, m_pipeBranchesCLCoords[0][0].z() }; + flattenedStartOffset = { 0.0, 0.0, m_pipeBranchesCLCoords[branchIdxStart][0].z() }; } - for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) + for (size_t brIdx = branchIdxStart; brIdx sourceInfo = new RivSimWellPipeSourceInfo(m_rimWell, brIdx); @@ -122,8 +194,10 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); + + flattenedStartOffset.z() = m_pipeBranchesCLCoords[brIdx][0].z(); - if (m_intersectionView) + if (doFlatten) { std::vector flatningCSs = RivSectionFlattner::calculateFlatteningCSsForPolyline(m_pipeBranchesCLCoords[brIdx], cvf::Vec3d::Z_AXIS, @@ -180,39 +254,11 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform pbd.m_largeSurfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); } - if (m_intersectionView) flattenedStartOffset += { 2*m_intersectionView->intersection()->extentLength(), 0.0, 0.0}; + if (doFlatten) flattenedStartOffset += { 2*flattenedIntersectionExtentLength, 0.0, 0.0}; } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - size_t frameIndex, - const caf::DisplayCoordTransform* displayXf) -{ - if (!viewWithSettings()) return; - - if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - - buildWellPipeParts(displayXf); - - std::list::iterator it; - for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) - { - if (it->m_surfacePart.notNull()) - { - model->addPart(it->m_surfacePart.p()); - } - - if (it->m_centerLinePart.notNull()) - { - model->addPart(it->m_centerLinePart.p()); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 1f7c015786..1be06bbfc5 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -50,21 +50,29 @@ class Rim2dIntersectionView; class RivSimWellPipesPartMgr : public cvf::Object { public: - RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView = nullptr); + RivSimWellPipesPartMgr(RimSimWellInView* well); ~RivSimWellPipesPartMgr(); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, const caf::DisplayCoordTransform* displayXf); + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf, + double flattenedIntersectionExtentLength, + int branchIndex); + void updatePipeResultColor(size_t frameIndex); private: Rim3dView* viewWithSettings(); - void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf); + void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, + bool doFlatten, + double flattenedIntersectionExtentLength, + int branchIndex); caf::PdmPointer m_rimWell; - caf::PdmPointer m_intersectionView; struct RivPipeBranchData { diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 4506f3253a..2cf9138cab 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -43,6 +43,7 @@ #include #include "cafDisplayCoordTransform.h" #include "RivSimWellPipesPartMgr.h" +#include "RivWellHeadPartMgr.h" CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); @@ -404,6 +405,7 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->applySingleColorEffect(); m_flatSimWellPipePartMgr = nullptr; + m_flatWellHeadPartMgr = nullptr; if ( m_intersection->type() == RimIntersection::CS_SIMULATION_WELL && m_intersection->simulationWell() ) @@ -413,7 +415,8 @@ void Rim2dIntersectionView::createDisplayModel() if ( eclipseView ) { - m_flatSimWellPipePartMgr = new RivSimWellPipesPartMgr(m_intersection->simulationWell(), this); + m_flatSimWellPipePartMgr = new RivSimWellPipesPartMgr(m_intersection->simulationWell()); + m_flatWellHeadPartMgr = new RivWellHeadPartMgr(m_intersection->simulationWell()); } } @@ -466,20 +469,29 @@ void Rim2dIntersectionView::updateCurrentTimeStep() cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); if (frameScene) { - cvf::String name = "SimWellPipeMod"; - Rim3dView::removeModelByName(frameScene, name); - - cvf::ref simWellModelBasicList = new cvf::ModelBasicList; - simWellModelBasicList->setName(name); + { + cvf::String name = "SimWellPipeMod"; + Rim3dView::removeModelByName(frameScene, name); - m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), - m_currentTimeStep, - this->displayCoordTransform().p()); - - simWellModelBasicList->updateBoundingBoxesRecursive(); - frameScene->addModel(simWellModelBasicList.p()); + cvf::ref simWellModelBasicList = new cvf::ModelBasicList; + simWellModelBasicList->setName(name); + + m_flatSimWellPipePartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + m_intersection->extentLength(), + m_intersection->branchIndex()); - m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); + simWellModelBasicList->updateBoundingBoxesRecursive(); + frameScene->addModel(simWellModelBasicList.p()); + + m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); + + //m_flatWellHeadPartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), + // m_currentTimeStep, + // this->displayCoordTransform().p()); + // + } } } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 2767179509..5c6233f810 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -26,6 +26,7 @@ class RimIntersection; class RimLegendConfig; class RimTernaryLegendConfig; class RivSimWellPipesPartMgr; +class RivWellHeadPartMgr; namespace cvf { @@ -97,6 +98,7 @@ class Rim2dIntersectionView : public Rim3dView cvf::ref m_flatIntersectionPartMgr; cvf::ref m_flatSimWellPipePartMgr; + cvf::ref m_flatWellHeadPartMgr; cvf::ref m_intersectionVizModel; cvf::ref m_scaleTransform; diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 4da76dfc17..c767b5df3d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -104,6 +104,7 @@ class RimIntersection : public caf::PdmObject void recomputeSimulationWellBranchData(); bool hasDefiningPoints() const; + int branchIndex() const; protected: virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); @@ -117,7 +118,6 @@ class RimIntersection : public caf::PdmObject virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); private: - int branchIndex() const; private: caf::PdmField m_branchIndex; From bb28cf3f0976a8a7949bfa2d93ba084d267602db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Mar 2018 14:43:02 +0100 Subject: [PATCH 0508/1027] #2552 Add well head visualization. Not yet working for multiple branches --- .../ModelVisualization/RivWellHeadPartMgr.cpp | 58 +++++++++++++++++-- .../ModelVisualization/RivWellHeadPartMgr.h | 7 ++- .../Rim2dIntersectionView.cpp | 9 +-- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index c3272fdeb9..7b9913a83f 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -50,6 +50,7 @@ #include "cvfTransform.h" #include "cvfqtUtils.h" #include "cafDisplayCoordTransform.h" +#include "RivSectionFlattner.h" @@ -73,7 +74,8 @@ RivWellHeadPartMgr::~RivWellHeadPartMgr() /// //-------------------------------------------------------------------------------------------------- void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, - const caf::DisplayCoordTransform * displayXf) + const caf::DisplayCoordTransform * displayXf, + bool doFlatten) { clearAllGeometry(); @@ -88,9 +90,22 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, { well->wellHeadTopBottomPosition(static_cast(frameIndex), &whEndPos, &whStartPos); - whEndPos = displayXf->transformToDisplayCoord(whEndPos); - whStartPos = displayXf->transformToDisplayCoord(whStartPos); - whEndPos.z() += characteristicCellSize; + if (doFlatten) + { + whEndPos.x() = 0.0; + whEndPos.y() = 0.0; + whStartPos.x() = 0.0; + whStartPos.y() = 0.0; + whEndPos = displayXf->scaleToDisplaySize(whEndPos); + whStartPos = displayXf->scaleToDisplaySize(whStartPos); + whEndPos.z() += characteristicCellSize; + } + else + { + whEndPos = displayXf->transformToDisplayCoord(whEndPos); + whStartPos = displayXf->transformToDisplayCoord(whStartPos); + whEndPos.z() += characteristicCellSize; + } } if (!well->simWellData()->hasWellResult(frameIndex)) return; @@ -162,6 +177,8 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, part->setSourceInfo(sourceInfo.p()); m_wellHeadPipeCenterPart = part; + part->updateBoundingBox(); + CVF_ASSERT(part->boundingBox().isValid()); } } @@ -330,7 +347,7 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellHeadParts(frameIndex, displayXf); + buildWellHeadParts(frameIndex, displayXf, false); // Always add pipe part of well head if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); @@ -349,6 +366,37 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellHeadPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf) +{ + if (m_rimWell.isNull()) return; + if (!viewWithSettings()) return; + + if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + + buildWellHeadParts(frameIndex, displayXf, true); + + // Always add pipe part of well head + if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); + if (m_wellHeadPipeSurfacePart.notNull()) model->addPart(m_wellHeadPipeSurfacePart.p()); + + if (m_rimWell->showWellLabel() && + m_wellHeadLabelPart.notNull()) + { + model->addPart(m_wellHeadLabelPart.p()); + } + + if (m_rimWell->showWellHead() && + m_wellHeadArrowPart.notNull()) + { + model->addPart(m_wellHeadArrowPart.p()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index d4c38b33cf..cc4d0f5efc 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -48,11 +48,16 @@ class RivWellHeadPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, const caf::DisplayCoordTransform * displayXf); + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf); + private: void buildWellHeadParts(size_t frameIndex, - const caf::DisplayCoordTransform * displayXf); + const caf::DisplayCoordTransform * displayXf, + bool doFlatten); void clearAllGeometry(); Rim3dView* viewWithSettings(); RimSimWellInViewCollection* simWellInViewCollection(); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 2cf9138cab..99b3d3d001 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -482,15 +482,12 @@ void Rim2dIntersectionView::updateCurrentTimeStep() m_intersection->extentLength(), m_intersection->branchIndex()); + m_flatWellHeadPartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p()); simWellModelBasicList->updateBoundingBoxesRecursive(); frameScene->addModel(simWellModelBasicList.p()); - m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); - - //m_flatWellHeadPartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), - // m_currentTimeStep, - // this->displayCoordTransform().p()); - // } } } From 9f42c45dcc1a706ce90f6fe5b2c2fc333ceb7cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Mar 2018 15:13:11 +0100 Subject: [PATCH 0509/1027] Include cleanup SimWellPipespartMgr --- .../RivSimWellPipesPartMgr.cpp | 23 ++----------------- .../RivSimWellPipesPartMgr.h | 3 --- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 7bfcea7c93..e8d1392a37 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -20,40 +20,21 @@ #include "RivSimWellPipesPartMgr.h" -#include "RigEclipseCaseData.h" -#include "RigCell.h" -#include "RigMainGrid.h" -#include "RigSimulationWellCenterLineCalculator.h" - -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellEdgeColors.h" -#include "RimCellRangeFilterCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseCellColors.h" -#include "RimEclipsePropertyFilterCollection.h" #include "Rim3dView.h" -#include "RimReservoirCellResultsStorage.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RivPipeGeometryGenerator.h" -#include "RivWellPathSourceInfo.h" #include "RivSimWellPipeSourceInfo.h" +#include "RivSectionFlattner.h" #include "cafEffectGenerator.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" +#include "cafDisplayCoordTransform.h" #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfRay.h" #include "cvfScalarMapperDiscreteLinear.h" -#include "cvfTransform.h" -#include "cafDisplayCoordTransform.h" -#include "RivSectionFlattner.h" -#include "Rim2dIntersectionView.h" -#include "RimIntersection.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 1be06bbfc5..146f6ac47b 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -32,8 +32,6 @@ namespace cvf { class Part; class ModelBasicList; - class Transform; - class Effect; class DrawableGeo; } @@ -45,7 +43,6 @@ namespace caf class RivPipeGeometryGenerator; class Rim3dView; class RimSimWellInView; -class Rim2dIntersectionView; class RivSimWellPipesPartMgr : public cvf::Object { From cf1557fdf893bfcb65701dfc9b9c508beb1628a4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 14 Mar 2018 15:26:13 +0100 Subject: [PATCH 0510/1027] Include cleanup --- .../ModelVisualization/RivVirtualConnFactorPartMgr.cpp | 4 ++-- .../ModelVisualization/RivVirtualConnFactorPartMgr.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp index 3315377e37..e17b76b677 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -19,10 +19,12 @@ #include "RivVirtualConnFactorPartMgr.h" #include "RiaApplication.h" +#include "RiaExtractionTools.h" #include "RigEclipseWellLogExtractor.h" #include "RigMainGrid.h" #include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellLogExtractor.h" #include "RigWellPath.h" #include "RimEclipseCase.h" @@ -34,8 +36,6 @@ #include "RiuViewer.h" -#include "RiaExtractionTools.h" -#include "RigWellLogExtractor.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" #include "cafPdmFieldCvfColor.h" diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h index e7dc39a4be..b10bfeec47 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h @@ -24,8 +24,6 @@ #include "cafPdmPointer.h" -#include -#include #include namespace cvf From 87977824db1ab97c23213274ac83f382cc6fd42c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 14 Mar 2018 15:52:10 +0100 Subject: [PATCH 0511/1027] Guard for missing well path --- ...sTransmissibilityCalculationFeatureImp.cpp | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index d372d0bc0b..f1947ed92c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -65,6 +65,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) { + if (!wellPath) return; + // Generate data const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); std::vector locations = RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(settings.caseToApply, wellPath); @@ -101,8 +103,15 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell /// //-------------------------------------------------------------------------------------------------- std::vector RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings) + const RicExportCompletionDataSettingsUi& settings) { + std::vector completionData; + + if (!wellPath || !wellPath->completions()) + { + return completionData; + } + std::map > wellBorePartsInCells; //wellBore = main bore or fishbone lateral findFishboneLateralsWellBoreParts(wellBorePartsInCells, wellPath, settings); findFishboneImportedLateralsWellBoreParts(wellBorePartsInCells, wellPath, settings); @@ -111,8 +120,6 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp findMainWellBoreParts(wellBorePartsInCells, wellPath, settings); } - std::vector completionData; - const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); for (const auto& cellAndWellBoreParts : wellBorePartsInCells) @@ -200,6 +207,10 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); + + if (!wellPath) return; + if (!wellPath->wellPathGeometry()) return; + std::set wellPathCells = RicFishbonesTransmissibilityCalculationFeatureImp::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), wellPath->wellPathGeometry()->m_wellPathPoints); bool isMainBore = false; @@ -235,6 +246,9 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) { + if (!wellPath) return; + if (!wellPath->wellPathGeometry()) return; + RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); bool isMainBore = true; double holeDiameter = wellPath->fishbonesCollection()->mainBoreDiameter(unitSystem); @@ -250,6 +264,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st fishbonePerfWellPathCoords.first, fishbonePerfWellPathCoords.second); + if (!wellPath->fishbonesCollection()) return; + for (auto& cell : intersectedCellsIntersectionInfo) { double skinFactor = wellPath->fishbonesCollection()->mainBoreSkinFactor(); @@ -273,6 +289,11 @@ std::set RicFishbonesTransmissibilityCalculationFeatureImp::findIntersec { std::set cells; + if (!caseData) + { + return cells; + } + std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); for (auto intersection : intersections) { From bc3342639357b8502ff19ba00082852ac33a6215 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 14 Mar 2018 15:55:17 +0100 Subject: [PATCH 0512/1027] Upped to version 2018.01.01-dev.107 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 7c600879cf..1c88a04720 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".106") +set(RESINSIGHT_DEV_VERSION ".107") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From ab67dcfd1fffb026acc94eb940f37c85e65393b3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Mar 2018 07:27:48 +0100 Subject: [PATCH 0513/1027] #2463 Well CF Visualization: Set 'Well Connection Factors' default off --- .../ProjectDataModel/RimVirtualPerforationResults.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index 264e76b6cb..c15d87d138 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -34,7 +34,7 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() CAF_PDM_InitObject(connectionFactorUiName, ":/CellResult.png", "", ""); - CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", true, "", "", "", ""); + CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", false, "", "", "", ""); CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 0.2, "Geometry Scale Factor", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); From c8b92a0c89bd42fb964fb97270edf89030d7bd2b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Mar 2018 07:52:54 +0100 Subject: [PATCH 0514/1027] #2601 Well CF Visualization: Support regeneration of viz on time step changes --- .../ModelVisualization/RivWellPathPartMgr.cpp | 26 ++++++++++++++----- .../ModelVisualization/RivWellPathPartMgr.h | 4 +-- .../RivWellPathsPartMgr.cpp | 2 -- .../ModelVisualization/RivWellPathsPartMgr.h | 1 - .../ProjectDataModel/Rim3dView.cpp | 8 ------ 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 0c20b0b1d1..8bda6e44cf 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -159,8 +159,7 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewDate, - cvf::ModelBasicList* model, +void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize) { @@ -172,6 +171,18 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; + QDateTime currentTimeStamp; + RimEclipseCase* eclipseCase = nullptr; + m_rimView->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + size_t timeStepIndex = m_rimView->currentTimeStep(); + + std::vector timeStamps = eclipseCase->timeStepDates(); + if (timeStepIndex < static_cast(timeStamps.size())) + { + currentTimeStamp = timeStamps[timeStepIndex]; + } + // Since we're using the index of measured depths to find the index of a point, ensure they're equal CVF_ASSERT(wellPathGeometry->m_measuredDepths.size() == wellPathGeometry->m_wellPathPoints.size()); @@ -186,7 +197,7 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD if (!perforation->isChecked()) continue; if (perforation->startMD() > perforation->endMD()) continue; - if (currentViewDate.isValid() && !perforation->isActiveOnDate(currentViewDate)) continue; + if (currentTimeStamp.isValid() && !perforation->isActiveOnDate(currentTimeStamp)) continue; using namespace std; pair, vector > displayCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), @@ -229,7 +240,9 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL { m_virtualConnectionFactorPartMgr = new RivVirtualConnFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); - m_virtualConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, 0); + size_t timeStepIndex = m_rimView->currentTimeStep(); + + m_virtualConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); } } @@ -422,14 +435,12 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize); appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); - appendVirtualTransmissibilitiesToModel(model, displayCoordTransform, characteristicCellSize); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) @@ -447,7 +458,8 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false) return; - appendPerforationsToModel(timeStamp, model, displayCoordTransform, characteristicCellSize); + appendPerforationsToModel(model, displayCoordTransform, characteristicCellSize); + appendVirtualTransmissibilitiesToModel(model, displayCoordTransform, characteristicCellSize); m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index a1871b9821..afd6aea4ea 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -67,7 +67,6 @@ class RivWellPathPartMgr : public cvf::Object void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform); @@ -83,8 +82,7 @@ class RivWellPathPartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize); - void appendPerforationsToModel(const QDateTime& currentViewDate, - cvf::ModelBasicList* model, + void appendPerforationsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize); diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index 13de516a3c..a8807ed255 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -74,7 +74,6 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* /// //-------------------------------------------------------------------------------------------------- void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform) @@ -86,7 +85,6 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* for (auto& partMgr : m_wellPatshsPartMgrs) { partMgr->appendDynamicGeometryPartsToModel(model, - timeStamp, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index 164f1ddf00..4124ce1093 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -64,7 +64,6 @@ class RivWellPathsPartMgr : public cvf::Object void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox, const caf::DisplayCoordTransform* displayCoordTransform); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 926b2f635f..41fae6450b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -681,15 +681,7 @@ void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBas cvf::ref transForm = displayCoordTransform(); - QDateTime currentTimeStamp; - std::vector timeStamps = ownerCase()->timeStepDates(); - if (currentTimeStep() < static_cast(timeStamps.size())) - { - currentTimeStamp = timeStamps[currentTimeStep()]; - } - m_wellPathsPartManager->appendDynamicGeometryPartsToModel(wellPathModelBasicList, - currentTimeStamp, this->ownerCase()->characteristicCellSize(), wellPathClipBoundingBox, transForm.p()); From cc47016572f39397356baf52ee40705a6b7c5e78 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Mar 2018 12:55:50 +0100 Subject: [PATCH 0515/1027] #2597 3D Well Log Curve: Add option to create LAS curve --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 5 +- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 22 ++- .../ProjectDataModel/Rim3dWellLogCurve.h | 10 +- .../Rim3dWellLogFileCurve.cpp | 158 ++++++++++++++++++ .../ProjectDataModel/Rim3dWellLogFileCurve.h | 52 ++++++ 6 files changed, 238 insertions(+), 11 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index cefcf451a9..80c45e900a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -103,10 +103,13 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim std::vector* vertices, std::vector* indices) const { + if (m_wellPathGeometry.isNull()) return; + std::vector resultValues; std::vector mds; - rim3dWellLogCurve->resultValuesAndMds(&resultValues, &mds); + rim3dWellLogCurve->curveValuesAndMds(&resultValues, &mds); + if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == mds.size()); cvf::Vec3d globalDirection = diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 72cedbe3d8..09a3273bc0 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -99,6 +99,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h ) @@ -203,6 +204,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 5c66693d08..69fb630440 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -178,9 +178,9 @@ bool Rim3dWellLogCurve::toggleState() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, std::vector* measuredDepthValues) const +void Rim3dWellLogCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const { - CAF_ASSERT(resultValues != nullptr); + CAF_ASSERT(values != nullptr); CAF_ASSERT(measuredDepthValues != nullptr); cvf::ref eclExtractor; @@ -216,7 +216,7 @@ void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, st m_eclipseResultDefinition); if (resAcc.notNull()) { - eclExtractor->curveData(resAcc.p(), resultValues); + eclExtractor->curveData(resAcc.p(), values); } } else if (geomExtractor.notNull()) @@ -225,7 +225,7 @@ void Rim3dWellLogCurve::resultValuesAndMds(std::vector* resultValues, st m_geomResultDefinition->loadResult(); - geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, resultValues); + geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, values); } } @@ -321,9 +321,7 @@ void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin } caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); - appearanceGroup->add(&m_drawPlane); - appearanceGroup->add(&m_drawStyle); - appearanceGroup->add(&m_coloringStyle); + appearanceUiOrdering(*appearanceGroup); uiOrdering.skipRemainingFields(); } @@ -340,3 +338,13 @@ void Rim3dWellLogCurve::initAfterRead() m_geomResultDefinition->setGeoMechCase(geomCase); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_drawPlane); + uiOrdering.add(&m_drawStyle); + uiOrdering.add(&m_coloringStyle); +} + diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 0276569ed6..9affdfb4e8 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -71,9 +71,9 @@ class Rim3dWellLogCurve : public caf::PdmObject DrawPlane drawPlane() const; bool toggleState() const; - void resultValuesAndMds(std::vector* resultValues, std::vector* measuredDepthValues) const; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const; -private: +protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; @@ -82,9 +82,13 @@ class Rim3dWellLogCurve : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; + void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); + +protected: + caf::PdmField m_name; + private: caf::PdmField m_showCurve; - caf::PdmField m_name; caf::PdmPtrField m_case; caf::PdmField m_timeStep; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp new file mode 100644 index 0000000000..afc1c4c54d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -0,0 +1,158 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogFileCurve.h" + +#include "RigWellLogFile.h" + +#include "RimWellLogFile.h" +#include "RimWellLogFileChannel.h" +#include "RimWellPath.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogFileCurve, "Rim3dWellLogFileCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() +{ + CAF_PDM_InitObject("3d Well Log File Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogChannnelName, "CurveWellLogChannel", "Well Log Channel", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "Well Log File", "", "", ""); + + m_name = "3D Well Log LAS Curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogFileCurve::~Rim3dWellLogFileCurve() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() +{ + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + if (wellPath && !wellPath->wellLogFiles().empty()) + { + m_wellLogFile = wellPath->wellLogFiles()[0]; + } + + if (m_wellLogFile) + { + std::vector fileLogs = m_wellLogFile->wellLogChannels(); + + if (!fileLogs.empty()) + { + m_wellLogChannnelName = fileLogs[0]->name(); + m_name = "LAS: " + m_wellLogChannnelName; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + if (m_wellLogFile) + { + RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); + if (wellLogFile) + { + *values = wellLogFile->values(m_wellLogChannnelName); + *measuredDepthValues = wellLogFile->depthValues(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogFileCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + options = Rim3dWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + + if (!options.empty()) return options; + + if (fieldNeedingOptions == &m_wellLogChannnelName) + { + if (m_wellLogFile) + { + std::vector fileLogs = m_wellLogFile->wellLogChannels(); + + for (size_t i = 0; i < fileLogs.size(); i++) + { + QString wellLogChannelName = fileLogs[i]->name(); + options.push_back(caf::PdmOptionItemInfo(wellLogChannelName, wellLogChannelName)); + } + } + + if (options.size() == 0) + { + options.push_back(caf::PdmOptionItemInfo("None", "None")); + } + } + + if (fieldNeedingOptions == &m_wellLogFile) + { + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + if (wellPath && !wellPath->wellLogFiles().empty()) + { + for (RimWellLogFile* const wellLogFile : wellPath->wellLogFiles()) + { + QFileInfo fileInfo(wellLogFile->fileName()); + options.push_back(caf::PdmOptionItemInfo(fileInfo.baseName(), wellLogFile)); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + curveDataGroup->add(&m_wellLogFile); + curveDataGroup->add(&m_wellLogChannnelName); + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + + uiOrdering.skipRemainingFields(true); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h new file mode 100644 index 0000000000..5423406f46 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" + +class RimWellLogFile; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogFileCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogFileCurve(); + virtual ~Rim3dWellLogFileCurve(); + + void setDefaultFileCurveDataInfo(); + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + caf::PdmPtrField m_wellLogFile; + caf::PdmField m_wellLogChannnelName; +}; From ab800390ddb98bfa8cf2030f5b173a563c73d184 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Mar 2018 13:03:22 +0100 Subject: [PATCH 0516/1027] #2597 3D Well Log Curve: Context command to add new curve --- .../Commands/CMakeLists_files.cmake | 2 - .../WellLogCommands/CMakeLists_files.cmake | 4 + .../RicAdd3dWellLogCurveFeature.cpp | 0 .../RicAdd3dWellLogCurveFeature.h | 0 .../RicAdd3dWellLogFileCurveFeature.cpp | 75 +++++++++++++++++++ .../RicAdd3dWellLogFileCurveFeature.h | 34 +++++++++ .../RimContextCommandBuilder.cpp | 5 ++ .../UserInterface/RiuViewerCommands.cpp | 5 ++ 8 files changed, 123 insertions(+), 2 deletions(-) rename ApplicationCode/Commands/{ => WellLogCommands}/RicAdd3dWellLogCurveFeature.cpp (100%) rename ApplicationCode/Commands/{ => WellLogCommands}/RicAdd3dWellLogCurveFeature.h (100%) create mode 100644 ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp create mode 100644 ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 025ff74bce..4ca7189620 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -31,7 +31,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.h -${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h @@ -100,7 +99,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.cpp -${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.cpp diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 7f31e9a079..6e3d66d559 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -23,6 +23,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.h ${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -49,6 +51,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.cpp rename to ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp diff --git a/ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.h similarity index 100% rename from ApplicationCode/Commands/RicAdd3dWellLogCurveFeature.h rename to ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.h diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp new file mode 100644 index 0000000000..2befb1cac1 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogFileCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogFileCurve.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogFileCurveFeature, "RicAdd3dWellLogFileCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + return (RicWellLogTools::selectedWellPathWithLogFile() != nullptr); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogFileCurveFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPathWithLogFile(); + if (!selectedWellPath) return; + + Rim3dWellLogFileCurve* rim3dWellLogFileCurve = new Rim3dWellLogFileCurve(); + selectedWellPath->add3dWellLogCurve(rim3dWellLogFileCurve); + + rim3dWellLogFileCurve->setDefaultFileCurveDataInfo(); + + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogFileCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); + + selectedWellPath->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogFileCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log LAS Curve"); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h new file mode 100644 index 0000000000..7251912f61 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogFileCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 9919024bd5..443be275d9 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -262,7 +262,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); + menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png")); + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + + menuBuilder.subMenuEnd(); menuBuilder << "RicNewWellPathIntersectionFeature"; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index f5ace6df12..4a164d69a7 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -368,7 +368,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); + menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png")); + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + + menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); From 69caf4b3b2987da1f56cb682632748b568112209 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Mar 2018 13:04:39 +0100 Subject: [PATCH 0517/1027] #2591 3D Well Log Curve: Make geometry making more robust --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 10 +++++++++- .../ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 80c45e900a..0c40185c63 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -38,6 +38,11 @@ cvf::ref createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, &vertices, &indices); + if (vertices.empty() || indices.empty()) + { + return nullptr; + } + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); @@ -58,6 +63,10 @@ cvf::ref cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const { + cvf::ref drawable = new cvf::DrawableGeo(); + + if (m_wellPathGeometry.isNull()) return drawable; + std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); @@ -84,7 +93,6 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); - cvf::ref drawable = new cvf::DrawableGeo(); indexedUInt->setIndices(indexArray.p()); drawable->addPrimitiveSet(indexedUInt.p()); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 8f5720510c..0b21e275bf 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -46,6 +46,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* std::vector rim3dWellLogCurves) { if (rim3dWellLogCurves.empty()) return; + if (m_wellPathGeometry.isNull()) return; m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPathGeometry.p()); @@ -55,6 +56,11 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); + if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) + { + continue; + } + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); cvf::ref effect = surfaceGen.generateCachedEffect(); @@ -71,10 +77,11 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* //TODO: Atm, only the grid for the first curve is drawn. cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0]); - if (!gridDrawable->boundingBox().isValid()) + if (gridDrawable.isNull() || !gridDrawable->boundingBox().isValid()) { return; } + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 255, 0, 1), caf::PO_1); cvf::ref effect = surfaceGen.generateCachedEffect(); From 7fbf195b18e325e6e214c87fe1861c8df28e9394 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Mar 2018 13:04:57 +0100 Subject: [PATCH 0518/1027] Add Icon to well log LAS curve --- .../WellLogCommands/RicNewWellLogFileCurveFeature.cpp | 5 +++-- .../Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index 344fd5632e..8ddc6a65a7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -87,13 +87,14 @@ void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicNewWellLogFileCurveFeature::setupActionLook(QAction* actionToSetup) { + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); actionToSetup->setText("New Well Log LAS Curve"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() const +bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() { RimProject* project = RiaApplication::instance()->project(); if (project->activeOilField()->wellPathCollection()) @@ -102,7 +103,7 @@ bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() const for (size_t i = 0; i < wellPaths.size(); i++) { - if (wellPaths[i]->wellLogFiles().size() > 0) + if (!wellPaths[i]->wellLogFiles().empty()) { return true; } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h index d4ae4353a2..0a686babe4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h @@ -36,5 +36,5 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ) override; private: - bool wellLogFilesAvailable() const; + static bool wellLogFilesAvailable(); }; From a41ca4688ea84445d0bdc5a3beec937c25a3feaf Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 15 Mar 2018 14:17:56 +0100 Subject: [PATCH 0519/1027] #2597 3D Well Log Curve: Make 3d well log curve pure virtual. Add 3d well log extraction curve --- .../RicAdd3dWellLogCurveFeature.cpp | 10 +- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 197 +------------- .../ProjectDataModel/Rim3dWellLogCurve.h | 28 +- .../Rim3dWellLogExtractionCurve.cpp | 244 ++++++++++++++++++ .../Rim3dWellLogExtractionCurve.h | 60 +++++ .../Rim3dWellLogFileCurve.cpp | 3 + .../ProjectDataModel/Rim3dWellLogFileCurve.h | 1 + 8 files changed, 321 insertions(+), 224 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp index 0cbfddc9d4..d623a89d76 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp @@ -22,7 +22,7 @@ #include "RicWellLogTools.h" -#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogExtractionCurve.h" #include "RimCase.h" #include "RimProject.h" #include "RimWellPath.h" @@ -52,19 +52,19 @@ void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) { RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); - Rim3dWellLogCurve* rim3dWellLogCurve = new Rim3dWellLogCurve(); + Rim3dWellLogExtractionCurve* rim3dWellLogExtractionCurve = new Rim3dWellLogExtractionCurve(); Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (view) { - rim3dWellLogCurve->setPropertiesFromView(view); + rim3dWellLogExtractionCurve->setPropertiesFromView(view); } - selectedWellPath->add3dWellLogCurve(rim3dWellLogCurve); + selectedWellPath->add3dWellLogCurve(rim3dWellLogExtractionCurve); RiaApplication::instance()->project()->updateConnectedEditors(); - Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogCurve); + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogExtractionCurve); Riu3DMainWindowTools::setExpanded(selectedWellPath); selectedWellPath->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 09a3273bc0..2b5447879c 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -100,6 +100,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h ) @@ -205,6 +206,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 69fb630440..900bc94156 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,31 +18,14 @@ #include "Rim3dWellLogCurve.h" -#include "RiaExtractionTools.h" - -#include "RigEclipseWellLogExtractor.h" -#include "RigGeoMechWellLogExtractor.h" -#include "RigResultAccessorFactory.h" - -#include "Rim3dView.h" -#include "RimEclipseCase.h" -#include "RimEclipseCellColors.h" -#include "RimEclipseResultDefinition.h" -#include "RimEclipseView.h" -#include "RimGeoMechCase.h" -#include "RimGeoMechResultDefinition.h" -#include "RimGeoMechView.h" -#include "RimMainPlotCollection.h" #include "RimProject.h" -#include "RimTools.h" -#include "RimWellLogPlotCollection.h" //================================================================================================== /// /// //================================================================================================== -CAF_PDM_SOURCE_INIT(Rim3dWellLogCurve, "Rim3dWellLogCurve"); +CAF_PDM_ABSTRACT_SOURCE_INIT(Rim3dWellLogCurve, "Rim3dWellLogCurve"); namespace caf { @@ -90,23 +73,6 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitFieldNoDefault(&m_drawStyle, "DrawStyle", "Draw Style", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_coloringStyle, "ColoringStyle", "Coloring Style", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", ""); - m_case.uiCapability()->setUiTreeChildrenHidden(true); - m_case = nullptr; - - CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", ""); - m_eclipseResultDefinition.uiCapability()->setUiHidden(true); - m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); - m_eclipseResultDefinition = new RimEclipseResultDefinition; - m_eclipseResultDefinition->findField("MResultType")->uiCapability()->setUiName("Result Type"); - - CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", ""); - m_geomResultDefinition.uiCapability()->setUiHidden(true); - m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); - m_geomResultDefinition = new RimGeoMechResultDefinition; - - CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); - CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); m_name.uiCapability()->setUiHidden(true); } @@ -116,8 +82,6 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::~Rim3dWellLogCurve() { - delete m_geomResultDefinition; - delete m_eclipseResultDefinition; } //-------------------------------------------------------------------------------------------------- @@ -130,35 +94,6 @@ void Rim3dWellLogCurve::updateCurveIn3dView() proj->createDisplayModelAndRedrawAllViews(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) -{ - if (!view) return; - - m_case = view->ownerCase(); - - RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); - RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); - m_eclipseResultDefinition->setEclipseCase(eclipseCase); - m_geomResultDefinition->setGeoMechCase(geomCase); - - RimEclipseView* eclipseView = dynamic_cast(view); - if (eclipseView) - { - m_eclipseResultDefinition->simpleCopy(eclipseView->cellResult()); - m_timeStep = eclipseView->currentTimeStep(); - } - - RimGeoMechView* geoMechView = dynamic_cast(view); - if (geoMechView) - { - m_geomResultDefinition->setResultAddress(geoMechView->cellResultResultDefinition()->resultAddress()); - m_timeStep = geoMechView->currentTimeStep(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -175,60 +110,6 @@ bool Rim3dWellLogCurve::toggleState() const return m_showCurve; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const -{ - CAF_ASSERT(values != nullptr); - CAF_ASSERT(measuredDepthValues != nullptr); - - cvf::ref eclExtractor; - cvf::ref geomExtractor; - - RimWellPath* wellPath; - firstAncestorOrThisOfType(wellPath); - - RimEclipseCase* eclipseCase = dynamic_cast(m_case()); - - if (eclipseCase) - { - eclExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(wellPath, eclipseCase); - } - else - { - RimGeoMechCase* geomCase = dynamic_cast(m_case()); - if (geomCase) - { - geomExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(wellPath, geomCase); - } - } - - if (eclExtractor.notNull() && eclipseCase) - { - *measuredDepthValues = eclExtractor->measuredDepth(); - - m_eclipseResultDefinition->loadResult(); - - cvf::ref resAcc = RigResultAccessorFactory::createFromResultDefinition(eclipseCase->eclipseCaseData(), - 0, - m_timeStep, - m_eclipseResultDefinition); - if (resAcc.notNull()) - { - eclExtractor->curveData(resAcc.p(), values); - } - } - else if (geomExtractor.notNull()) - { - *measuredDepthValues = geomExtractor->measuredDepth(); - - m_geomResultDefinition->loadResult(); - - geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, values); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -254,37 +135,6 @@ void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList Rim3dWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) -{ - QList options; - - if (fieldNeedingOptions == &m_case) - { - RimTools::caseOptionItems(&options); - - options.push_front(caf::PdmOptionItemInfo("None", nullptr)); - } - else if (fieldNeedingOptions == &m_timeStep) - { - QStringList timeStepNames; - - if (m_case) - { - timeStepNames = m_case->timeStepStrings(); - } - - for (int i = 0; i < timeStepNames.size(); i++) - { - options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); - } - } - - return options; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -293,51 +143,6 @@ caf::PdmFieldHandle* Rim3dWellLogCurve::userDescriptionField() return &m_name; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); - - curveDataGroup->add(&m_case); - - RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); - RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); - - if (eclipseCase) - { - m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); - } - else if (geomCase) - { - m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); - } - - if ((eclipseCase && m_eclipseResultDefinition->hasDynamicResult()) - || geomCase) - { - curveDataGroup->add(&m_timeStep); - } - - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); - appearanceUiOrdering(*appearanceGroup); - - uiOrdering.skipRemainingFields(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::initAfterRead() -{ - RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); - RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); - - m_eclipseResultDefinition->setEclipseCase(eclipseCase); - m_geomResultDefinition->setGeoMechCase(geomCase); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 9affdfb4e8..6e5c83550b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -19,15 +19,9 @@ #pragma once #include "cafAppEnum.h" -#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimCase.h" - -class RimGeoMechResultDefinition; -class RimEclipseResultDefinition; - //================================================================================================== /// /// @@ -66,36 +60,24 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); - void setPropertiesFromView(Rim3dView* view); - DrawPlane drawPlane() const; bool toggleState() const; - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual caf::PdmFieldHandle* userDescriptionField() override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - virtual void initAfterRead() override; - - void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); + void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); protected: caf::PdmField m_name; + caf::PdmField> m_drawPlane; + caf::PdmField> m_drawStyle; + caf::PdmField> m_coloringStyle; private: caf::PdmField m_showCurve; - - caf::PdmPtrField m_case; - caf::PdmField m_timeStep; - caf::PdmChildField m_eclipseResultDefinition; - caf::PdmChildField m_geomResultDefinition; - - caf::PdmField> m_drawPlane; - caf::PdmField> m_drawStyle; - caf::PdmField> m_coloringStyle; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp new file mode 100644 index 0000000000..a5d642d92f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -0,0 +1,244 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogExtractionCurve.h" + +#include "RigWellLogFile.h" + +#include "RiaExtractionTools.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigGeoMechWellLogExtractor.h" +#include "RigResultAccessorFactory.h" +#include "Rim3dView.h" +#include "RimCase.h" +#include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseResultDefinition.h" +#include "RimEclipseView.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "RimTools.h" +#include "RimWellLogFile.h" +#include "RimWellLogFileChannel.h" +#include "RimWellPath.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogExtractionCurve, "Rim3dWellLogExtractionCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogExtractionCurve::Rim3dWellLogExtractionCurve() +{ + CAF_PDM_InitObject("3d Well Log Extraction Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", ""); + m_case.uiCapability()->setUiTreeChildrenHidden(true); + m_case = nullptr; + + CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", ""); + m_eclipseResultDefinition.uiCapability()->setUiHidden(true); + m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_eclipseResultDefinition = new RimEclipseResultDefinition; + m_eclipseResultDefinition->findField("MResultType")->uiCapability()->setUiName("Result Type"); + + CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", ""); + m_geomResultDefinition.uiCapability()->setUiHidden(true); + m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_geomResultDefinition = new RimGeoMechResultDefinition; + + m_name = "3D Well Log Curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogExtractionCurve::~Rim3dWellLogExtractionCurve() +{ + delete m_geomResultDefinition; + delete m_eclipseResultDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) +{ + if (!view) return; + + m_case = view->ownerCase(); + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); + + RimEclipseView* eclipseView = dynamic_cast(view); + if (eclipseView) + { + m_eclipseResultDefinition->simpleCopy(eclipseView->cellResult()); + m_timeStep = eclipseView->currentTimeStep(); + } + + RimGeoMechView* geoMechView = dynamic_cast(view); + if (geoMechView) + { + m_geomResultDefinition->setResultAddress(geoMechView->cellResultResultDefinition()->resultAddress()); + m_timeStep = geoMechView->currentTimeStep(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + CAF_ASSERT(values != nullptr); + CAF_ASSERT(measuredDepthValues != nullptr); + + cvf::ref eclExtractor; + cvf::ref geomExtractor; + + RimWellPath* wellPath; + firstAncestorOrThisOfType(wellPath); + + RimEclipseCase* eclipseCase = dynamic_cast(m_case()); + + if (eclipseCase) + { + eclExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(wellPath, eclipseCase); + } + else + { + RimGeoMechCase* geomCase = dynamic_cast(m_case()); + if (geomCase) + { + geomExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(wellPath, geomCase); + } + } + + if (eclExtractor.notNull() && eclipseCase) + { + *measuredDepthValues = eclExtractor->measuredDepth(); + + m_eclipseResultDefinition->loadResult(); + + cvf::ref resAcc = RigResultAccessorFactory::createFromResultDefinition(eclipseCase->eclipseCaseData(), + 0, + m_timeStep, + m_eclipseResultDefinition); + if (resAcc.notNull()) + { + eclExtractor->curveData(resAcc.p(), values); + } + } + else if (geomExtractor.notNull()) + { + *measuredDepthValues = geomExtractor->measuredDepth(); + + m_geomResultDefinition->loadResult(); + + geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, values); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_case) + { + RimTools::caseOptionItems(&options); + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_timeStep) + { + QStringList timeStepNames; + + if (m_case) + { + timeStepNames = m_case->timeStepStrings(); + } + + for (int i = 0; i < timeStepNames.size(); i++) + { + options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + + curveDataGroup->add(&m_case); + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + if (eclipseCase) + { + m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + } + else if (geomCase) + { + m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + } + + if ((eclipseCase && m_eclipseResultDefinition->hasDynamicResult()) + || geomCase) + { + curveDataGroup->add(&m_timeStep); + } + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::initAfterRead() +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h new file mode 100644 index 0000000000..de566a1160 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmPtrField.h" + +class Rim3dView; +class RimCase; +class RimGeoMechResultDefinition; +class RimEclipseResultDefinition; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogExtractionCurve(); + virtual ~Rim3dWellLogExtractionCurve(); + + void setPropertiesFromView(Rim3dView* view); + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + +private: + caf::PdmPtrField m_case; + caf::PdmField m_timeStep; + + caf::PdmChildField m_eclipseResultDefinition; + caf::PdmChildField m_geomResultDefinition; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index afc1c4c54d..fe4f41be08 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -82,6 +82,9 @@ void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogFileCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const { + CAF_ASSERT(values != nullptr); + CAF_ASSERT(measuredDepthValues != nullptr); + if (m_wellLogFile) { RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h index 5423406f46..b05f2fa4b1 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -22,6 +22,7 @@ #include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmPtrField.h" class RimWellLogFile; From 4ac0a6354c591ece880305f0fd6d554a6db9030d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 14 Mar 2018 17:21:09 +0100 Subject: [PATCH 0520/1027] #2552 Simulation well heads for branches in 2d intersection view --- .../ModelVisualization/RivSimWellPipesPartMgr.cpp | 12 +++++++++++- .../ModelVisualization/RivSimWellPipesPartMgr.h | 3 +++ .../ModelVisualization/RivWellHeadPartMgr.cpp | 14 ++++++++------ .../ModelVisualization/RivWellHeadPartMgr.h | 6 ++++-- .../ProjectDataModel/Rim2dIntersectionView.cpp | 11 ++++++++--- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index e8d1392a37..bc8e2abf7c 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -132,7 +132,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform if (!this->viewWithSettings()) return; m_wellBranches.clear(); - + m_flattenedBranchWellHeadOffsets.clear(); m_pipeBranchesCLCoords.clear(); std::vector< std::vector > pipeBranchesCellIds; @@ -177,6 +177,8 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); flattenedStartOffset.z() = m_pipeBranchesCLCoords[brIdx][0].z(); + + m_flattenedBranchWellHeadOffsets.push_back(flattenedStartOffset.x()); if (doFlatten) { @@ -398,3 +400,11 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RivSimWellPipesPartMgr::flattenedBranchWellHeadOffsets() +{ + return m_flattenedBranchWellHeadOffsets; +} + diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 146f6ac47b..98fef5c65f 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -62,6 +62,8 @@ class RivSimWellPipesPartMgr : public cvf::Object void updatePipeResultColor(size_t frameIndex); + std::vector flattenedBranchWellHeadOffsets(); + private: Rim3dView* viewWithSettings(); void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, @@ -87,4 +89,5 @@ class RivSimWellPipesPartMgr : public cvf::Object std::list m_wellBranches; std::vector< std::vector > m_pipeBranchesCLCoords; + std::vector m_flattenedBranchWellHeadOffsets; }; diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 7b9913a83f..21c5404f3c 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -75,7 +75,8 @@ RivWellHeadPartMgr::~RivWellHeadPartMgr() //-------------------------------------------------------------------------------------------------- void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, const caf::DisplayCoordTransform * displayXf, - bool doFlatten) + bool doFlatten, + double xOffset) { clearAllGeometry(); @@ -92,9 +93,9 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, if (doFlatten) { - whEndPos.x() = 0.0; + whEndPos.x() = xOffset; whEndPos.y() = 0.0; - whStartPos.x() = 0.0; + whStartPos.x() = xOffset; whStartPos.y() = 0.0; whEndPos = displayXf->scaleToDisplaySize(whEndPos); whStartPos = displayXf->scaleToDisplaySize(whStartPos); @@ -347,7 +348,7 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellHeadParts(frameIndex, displayXf, false); + buildWellHeadParts(frameIndex, displayXf, false, 0.0); // Always add pipe part of well head if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); @@ -371,14 +372,15 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- void RivWellHeadPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, - const caf::DisplayCoordTransform * displayXf) + const caf::DisplayCoordTransform * displayXf, + double xOffset) { if (m_rimWell.isNull()) return; if (!viewWithSettings()) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellHeadParts(frameIndex, displayXf, true); + buildWellHeadParts(frameIndex, displayXf, true, xOffset); // Always add pipe part of well head if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index cc4d0f5efc..c44ea15f6d 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -50,14 +50,16 @@ class RivWellHeadPartMgr : public cvf::Object const caf::DisplayCoordTransform * displayXf); void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, - const caf::DisplayCoordTransform * displayXf); + const caf::DisplayCoordTransform * displayXf, + double xOffset); private: void buildWellHeadParts(size_t frameIndex, const caf::DisplayCoordTransform * displayXf, - bool doFlatten); + bool doFlatten, + double xOffset); void clearAllGeometry(); Rim3dView* viewWithSettings(); RimSimWellInViewCollection* simWellInViewCollection(); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 99b3d3d001..38b4424512 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -482,9 +482,14 @@ void Rim2dIntersectionView::updateCurrentTimeStep() m_intersection->extentLength(), m_intersection->branchIndex()); - m_flatWellHeadPartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), - m_currentTimeStep, - this->displayCoordTransform().p()); + for ( double offset : m_flatSimWellPipePartMgr->flattenedBranchWellHeadOffsets() ) + { + m_flatWellHeadPartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + offset); + } + simWellModelBasicList->updateBoundingBoxesRecursive(); frameScene->addModel(simWellModelBasicList.p()); m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); From f55d0292562694761ed480f95d40cf09c9ef7352 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Mar 2018 19:09:23 +0100 Subject: [PATCH 0521/1027] #2544 Well CF Visualization: Make the orientation of the star geometry follow well path --- .../RivVirtualConnFactorPartMgr.cpp | 54 +++++++++++++++---- .../RivVirtualConnFactorPartMgr.h | 24 +++++++-- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp index e17b76b677..3e0ccb2578 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -93,7 +93,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa } } - std::vector> centerColorPairs; + std::vector centerColorPairs; for (const auto& cell : conn) { size_t gridIndex = cell.first.globalCellIndex(); @@ -101,6 +101,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa const RigCell& rigCell = mainGrid->cell(gridIndex); cvf::Vec3d locationInDomainCoord = rigCell.center(); + cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; if (!wellPathCellIntersections.empty()) { @@ -115,6 +116,12 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + cvf::Vec3d p1; + cvf::Vec3d p2; + m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); + + wellPathDirection = (p2 - p1).getNormalized(); + continue; } } @@ -128,7 +135,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa transmissibility = cell.second.front().transmissibility(); } - centerColorPairs.push_back(std::make_pair(cvf::Vec3f(displayCoord), transmissibility)); + centerColorPairs.push_back(CompletionVizData(displayCoord, wellPathDirection, transmissibility)); } if (!centerColorPairs.empty()) @@ -146,9 +153,9 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector>& centerColorPairs, - double radius, - cvf::ScalarMapper* scalarMapper) +cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector& vizDataItems, + double radius, + cvf::ScalarMapper* scalarMapper) { std::vector verticesForOneObject; std::vector indicesForOneObject; @@ -159,29 +166,33 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector indices = new cvf::UIntArray; cvf::ref textureCoords = new cvf::Vec2fArray(); - auto indexCount = centerColorPairs.size() * indicesForOneObject.size(); - auto vertexCount = centerColorPairs.size() * verticesForOneObject.size(); + auto indexCount = vizDataItems.size() * indicesForOneObject.size(); + auto vertexCount = vizDataItems.size() * verticesForOneObject.size(); indices->reserve(indexCount); vertices->reserve(vertexCount); textureCoords->reserve(vertexCount); textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); - for (const auto& centerColorPair : centerColorPairs) + for (const auto& item : vizDataItems) { + auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); + cvf::uint indexOffset = static_cast(vertices->size()); for (const auto& v : verticesForOneObject) { - vertices->add(centerColorPair.first + v); + auto rotatedPoint = v.getTransformedPoint(rotMatrix); + + vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); - if (centerColorPair.second == HUGE_VAL) + if (item.m_connectionFactor == HUGE_VAL) { textureCoords->add(cvf::Vec2f(0.5f, 1.0f)); } else { - textureCoords->add(scalarMapper->mapToTextureCoord(centerColorPair.second)); + textureCoords->add(scalarMapper->mapToTextureCoord(item.m_connectionFactor)); } } @@ -316,3 +327,24 @@ void RivVirtualConnFactorPartMgr::createStarGeometry(std::vector* ve indices->push_back(5); indices->push_back(9); } + +//-------------------------------------------------------------------------------------------------- +/// Taken from OverlayNavigationCube::computeNewUpVector +/// Consider move to geometry util class +//-------------------------------------------------------------------------------------------------- +cvf::Mat4f RivVirtualConnFactorPartMgr::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) +{ + using namespace cvf; + + Vec3d rotAxis = v1 ^ v2; + rotAxis.normalize(); + + // Guard acos against out-of-domain input + const double dotProduct = Math::clamp(v1*v2, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + + Mat4f myMat(rotMat); + + return myMat; +} diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h index b10bfeec47..8cfcb5c4f0 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h @@ -21,6 +21,7 @@ #include "cvfBase.h" #include "cvfObject.h" #include "cvfVector3.h" +#include "cvfMatrix4.h" #include "cafPdmPointer.h" @@ -41,6 +42,21 @@ namespace caf class DisplayCoordTransform; } +struct CompletionVizData +{ + CompletionVizData(cvf::Vec3d anchor, cvf::Vec3d direction, double connectionFactor) + : m_anchor(anchor) + , m_direction(direction) + , m_connectionFactor(connectionFactor) + { + } + + cvf::Vec3d m_anchor; + cvf::Vec3d m_direction; + double m_connectionFactor; +}; + + //-------------------------------------------------------------------------------------------------- /// /// Based on RivWellSpheresPartMgr @@ -55,12 +71,14 @@ class RivVirtualConnFactorPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); private: - static cvf::ref createPart(std::vector>& centerColorPairs, - double radius, - cvf::ScalarMapper* scalarMapper); + static cvf::ref createPart(std::vector& centerColorPairs, + double radius, + cvf::ScalarMapper* scalarMapper); static void createStarGeometry(std::vector* vertices, std::vector* indices, double radius, double thickness); + static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); + private: caf::PdmPointer m_rimWell; caf::PdmPointer m_virtualPerforationResult; From eb6b7450eb90914135af3b576c7933d049e4faf5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Mar 2018 19:20:40 +0100 Subject: [PATCH 0522/1027] #2544 Well CF Visualization: Add support for no lighting --- .../RivVirtualConnFactorPartMgr.cpp | 14 ++++++++------ .../RivVirtualConnFactorPartMgr.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp index 3e0ccb2578..024879164c 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp @@ -144,7 +144,9 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); - cvf::ref part = RivVirtualConnFactorPartMgr::createPart(centerColorPairs, radius, scalarMapper); + bool disableLighting = eclView->isLightingDisabled(); + cvf::ref part = + RivVirtualConnFactorPartMgr::createPart(centerColorPairs, radius, scalarMapper, disableLighting); model->addPart(part.p()); } @@ -155,7 +157,8 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa //-------------------------------------------------------------------------------------------------- cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector& vizDataItems, double radius, - cvf::ScalarMapper* scalarMapper) + cvf::ScalarMapper* scalarMapper, + bool disableLighting) { std::vector verticesForOneObject; std::vector indicesForOneObject; @@ -215,7 +218,6 @@ cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector eff = effGen.generateCachedEffect(); @@ -340,9 +342,9 @@ cvf::Mat4f RivVirtualConnFactorPartMgr::rotationMatrixBetweenVectors(const cvf:: rotAxis.normalize(); // Guard acos against out-of-domain input - const double dotProduct = Math::clamp(v1*v2, -1.0, 1.0); - const double angle = Math::acos(dotProduct); - Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); Mat4f myMat(rotMat); diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h index 8cfcb5c4f0..725db29aa0 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h @@ -73,7 +73,8 @@ class RivVirtualConnFactorPartMgr : public cvf::Object private: static cvf::ref createPart(std::vector& centerColorPairs, double radius, - cvf::ScalarMapper* scalarMapper); + cvf::ScalarMapper* scalarMapper, + bool disableLighting); static void createStarGeometry(std::vector* vertices, std::vector* indices, double radius, double thickness); From 4853957637dc6d5fd0d762a270e84c3448fb50e4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 15 Mar 2018 21:25:54 +0100 Subject: [PATCH 0523/1027] #2544 Well CF Visualization: Add geometry generator and source info object rename remove unused move to separate file rename --- .../ModelVisualization/CMakeLists_files.cmake | 8 +- .../RivVirtualConnFactorPartMgr.cpp | 352 ------------------ ...vWellConnectionFactorGeometryGenerator.cpp | 222 +++++++++++ ...ivWellConnectionFactorGeometryGenerator.h} | 50 +-- .../RivWellConnectionFactorPartMgr.cpp | 193 ++++++++++ .../RivWellConnectionFactorPartMgr.h | 53 +++ .../RivWellConnectionSourceInfo.cpp | 50 +++ .../RivWellConnectionSourceInfo.h | 46 +++ .../ModelVisualization/RivWellPathPartMgr.cpp | 8 +- .../ModelVisualization/RivWellPathPartMgr.h | 6 +- 10 files changed, 596 insertions(+), 392 deletions(-) delete mode 100644 ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp rename ApplicationCode/ModelVisualization/{RivVirtualConnFactorPartMgr.h => RivWellConnectionFactorGeometryGenerator.h} (56%) create mode 100644 ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h create mode 100644 ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp create mode 100644 ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 4801558943..d221f84380 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -39,7 +39,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h -${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -77,7 +79,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp -${CMAKE_CURRENT_LIST_DIR}/RivVirtualConnFactorPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp deleted file mode 100644 index 024879164c..0000000000 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.cpp +++ /dev/null @@ -1,352 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2018 Statoil ASA -// -// ResInsight is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RivVirtualConnFactorPartMgr.h" - -#include "RiaApplication.h" -#include "RiaExtractionTools.h" - -#include "RigEclipseWellLogExtractor.h" -#include "RigMainGrid.h" -#include "RigVirtualPerforationTransmissibilities.h" -#include "RigWellLogExtractor.h" -#include "RigWellPath.h" - -#include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimLegendConfig.h" -#include "RimSimWellInViewCollection.h" -#include "RimVirtualPerforationResults.h" -#include "RimWellPath.h" - -#include "RiuViewer.h" - -#include "cafDisplayCoordTransform.h" -#include "cafEffectGenerator.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" -#include "cvfDrawableGeo.h" -#include "cvfGeometryBuilderFaceList.h" -#include "cvfGeometryBuilderTriangles.h" -#include "cvfGeometryUtils.h" -#include "cvfModelBasicList.h" -#include "cvfObject.h" -#include "cvfPart.h" -#include "cvfPrimitiveSetIndexedUInt.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivVirtualConnFactorPartMgr::RivVirtualConnFactorPartMgr(RimWellPath* well, - RimVirtualPerforationResults* virtualPerforationResult) - : m_rimWell(well) - , m_virtualPerforationResult(virtualPerforationResult) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivVirtualConnFactorPartMgr::~RivVirtualConnFactorPartMgr() {} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) -{ - RimEclipseView* eclView = nullptr; - m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView); - - auto coordTransform = eclView->displayCoordTransform(); - - RimEclipseCase* eclipseCase = nullptr; - m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase); - - const RigMainGrid* mainGrid = eclipseCase->mainGrid(); - - const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); - if (!trans) return; - - auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex); - - std::vector wellPathCellIntersections; - { - RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase); - if (extractor) - { - wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); - } - } - - std::vector centerColorPairs; - for (const auto& cell : conn) - { - size_t gridIndex = cell.first.globalCellIndex(); - - const RigCell& rigCell = mainGrid->cell(gridIndex); - - cvf::Vec3d locationInDomainCoord = rigCell.center(); - cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; - - if (!wellPathCellIntersections.empty()) - { - for (const auto& intersectionInfo : wellPathCellIntersections) - { - if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) - { - double startMD = intersectionInfo.startMD; - double endMD = intersectionInfo.endMD; - - double middleMD = (startMD + endMD) / 2.0; - - locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); - - cvf::Vec3d p1; - cvf::Vec3d p2; - m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); - - wellPathDirection = (p2 - p1).getNormalized(); - - continue; - } - } - } - - cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); - - double transmissibility = HUGE_VAL; - if (!cell.second.empty()) - { - transmissibility = cell.second.front().transmissibility(); - } - - centerColorPairs.push_back(CompletionVizData(displayCoord, wellPathDirection, transmissibility)); - } - - if (!centerColorPairs.empty()) - { - double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); - - auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); - - bool disableLighting = eclView->isLightingDisabled(); - cvf::ref part = - RivVirtualConnFactorPartMgr::createPart(centerColorPairs, radius, scalarMapper, disableLighting); - - model->addPart(part.p()); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RivVirtualConnFactorPartMgr::createPart(std::vector& vizDataItems, - double radius, - cvf::ScalarMapper* scalarMapper, - bool disableLighting) -{ - std::vector verticesForOneObject; - std::vector indicesForOneObject; - - RivVirtualConnFactorPartMgr::createStarGeometry(&verticesForOneObject, &indicesForOneObject, radius, radius * 0.3); - - cvf::ref vertices = new cvf::Vec3fArray; - cvf::ref indices = new cvf::UIntArray; - cvf::ref textureCoords = new cvf::Vec2fArray(); - - auto indexCount = vizDataItems.size() * indicesForOneObject.size(); - auto vertexCount = vizDataItems.size() * verticesForOneObject.size(); - indices->reserve(indexCount); - vertices->reserve(vertexCount); - textureCoords->reserve(vertexCount); - - textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); - - for (const auto& item : vizDataItems) - { - auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); - - cvf::uint indexOffset = static_cast(vertices->size()); - - for (const auto& v : verticesForOneObject) - { - auto rotatedPoint = v.getTransformedPoint(rotMatrix); - - vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); - - if (item.m_connectionFactor == HUGE_VAL) - { - textureCoords->add(cvf::Vec2f(0.5f, 1.0f)); - } - else - { - textureCoords->add(scalarMapper->mapToTextureCoord(item.m_connectionFactor)); - } - } - - for (const auto& i : indicesForOneObject) - { - indices->add(i + indexOffset); - } - } - - cvf::ref drawable = new cvf::DrawableGeo(); - drawable->setVertexArray(vertices.p()); - - drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); - drawable->computeNormals(); - - drawable->setTextureCoordArray(textureCoords.p()); - - cvf::ref part = new cvf::Part; - part->setDrawable(drawable.p()); - - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - - effGen.disableLighting(disableLighting); - - cvf::ref eff = effGen.generateCachedEffect(); - part->setEffect(eff.p()); - - return part; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivVirtualConnFactorPartMgr::createStarGeometry(std::vector* vertices, - std::vector* indices, - double radius, - double thickness) -{ - auto p0 = cvf::Vec3f::Z_AXIS * radius; - auto p2 = cvf::Vec3f::X_AXIS * -radius; - auto p4 = -p0; - auto p6 = -p2; - - double innerFactor = 5.0; - - auto p1 = (p0 + p2) / innerFactor; - auto p3 = (p2 + p4) / innerFactor; - - auto p5 = -p1; - auto p7 = -p3; - - auto p8 = cvf::Vec3f::Y_AXIS * thickness; - auto p9 = -p8; - - vertices->push_back(p0); - vertices->push_back(p1); - vertices->push_back(p2); - vertices->push_back(p3); - vertices->push_back(p4); - vertices->push_back(p5); - vertices->push_back(p6); - vertices->push_back(p7); - vertices->push_back(p8); - vertices->push_back(p9); - - // Top - indices->push_back(0); - indices->push_back(1); - indices->push_back(8); - - indices->push_back(0); - indices->push_back(8); - indices->push_back(7); - - indices->push_back(0); - indices->push_back(9); - indices->push_back(1); - - indices->push_back(0); - indices->push_back(7); - indices->push_back(9); - - // Left - indices->push_back(2); - indices->push_back(3); - indices->push_back(8); - - indices->push_back(2); - indices->push_back(8); - indices->push_back(1); - - indices->push_back(2); - indices->push_back(9); - indices->push_back(3); - - indices->push_back(2); - indices->push_back(1); - indices->push_back(9); - - // Bottom - indices->push_back(4); - indices->push_back(5); - indices->push_back(8); - - indices->push_back(4); - indices->push_back(8); - indices->push_back(3); - - indices->push_back(4); - indices->push_back(9); - indices->push_back(5); - - indices->push_back(4); - indices->push_back(3); - indices->push_back(9); - - // Right - indices->push_back(6); - indices->push_back(7); - indices->push_back(8); - - indices->push_back(6); - indices->push_back(8); - indices->push_back(5); - - indices->push_back(6); - indices->push_back(9); - indices->push_back(7); - - indices->push_back(6); - indices->push_back(5); - indices->push_back(9); -} - -//-------------------------------------------------------------------------------------------------- -/// Taken from OverlayNavigationCube::computeNewUpVector -/// Consider move to geometry util class -//-------------------------------------------------------------------------------------------------- -cvf::Mat4f RivVirtualConnFactorPartMgr::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) -{ - using namespace cvf; - - Vec3d rotAxis = v1 ^ v2; - rotAxis.normalize(); - - // Guard acos against out-of-domain input - const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); - const double angle = Math::acos(dotProduct); - Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); - - Mat4f myMat(rotMat); - - return myMat; -} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp new file mode 100644 index 0000000000..cf65996a71 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -0,0 +1,222 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionFactorGeometryGenerator.h" + +#include "cvfArray.h" +#include "cvfDrawableGeo.h" +#include "cvfPrimitiveSetIndexedUInt.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorGeometryGenerator::createStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness) +{ + auto p0 = cvf::Vec3f::Z_AXIS * radius; + auto p2 = cvf::Vec3f::X_AXIS * -radius; + auto p4 = -p0; + auto p6 = -p2; + + float innerFactor = 5.0f; + + auto p1 = (p0 + p2) / innerFactor; + auto p3 = (p2 + p4) / innerFactor; + + auto p5 = -p1; + auto p7 = -p3; + + auto p8 = cvf::Vec3f::Y_AXIS * thickness; + auto p9 = -p8; + + vertices->push_back(p0); + vertices->push_back(p1); + vertices->push_back(p2); + vertices->push_back(p3); + vertices->push_back(p4); + vertices->push_back(p5); + vertices->push_back(p6); + vertices->push_back(p7); + vertices->push_back(p8); + vertices->push_back(p9); + + // Top + indices->push_back(0); + indices->push_back(1); + indices->push_back(8); + + indices->push_back(0); + indices->push_back(8); + indices->push_back(7); + + indices->push_back(0); + indices->push_back(9); + indices->push_back(1); + + indices->push_back(0); + indices->push_back(7); + indices->push_back(9); + + // Left + indices->push_back(2); + indices->push_back(3); + indices->push_back(8); + + indices->push_back(2); + indices->push_back(8); + indices->push_back(1); + + indices->push_back(2); + indices->push_back(9); + indices->push_back(3); + + indices->push_back(2); + indices->push_back(1); + indices->push_back(9); + + // Bottom + indices->push_back(4); + indices->push_back(5); + indices->push_back(8); + + indices->push_back(4); + indices->push_back(8); + indices->push_back(3); + + indices->push_back(4); + indices->push_back(9); + indices->push_back(5); + + indices->push_back(4); + indices->push_back(3); + indices->push_back(9); + + // Right + indices->push_back(6); + indices->push_back(7); + indices->push_back(8); + + indices->push_back(6); + indices->push_back(8); + indices->push_back(5); + + indices->push_back(6); + indices->push_back(9); + indices->push_back(7); + + indices->push_back(6); + indices->push_back(5); + indices->push_back(9); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( + std::vector& centerColorPairs, + float radius) + : m_centerColorPairs(centerColorPairs) + , m_radius(radius) + , m_trianglesPerConnection(0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellConnectionFactorGeometryGenerator::createPipeSurface() +{ + std::vector verticesForOneObject; + std::vector indicesForOneObject; + + RivWellConnectionFactorGeometryGenerator::createStarGeometry( + &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); + + cvf::ref vertices = new cvf::Vec3fArray; + cvf::ref indices = new cvf::UIntArray; + + auto indexCount = m_centerColorPairs.size() * indicesForOneObject.size(); + auto vertexCount = m_centerColorPairs.size() * verticesForOneObject.size(); + indices->reserve(indexCount); + vertices->reserve(vertexCount); + + for (const auto& item : m_centerColorPairs) + { + auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); + + cvf::uint indexOffset = static_cast(vertices->size()); + + for (const auto& v : verticesForOneObject) + { + auto rotatedPoint = v.getTransformedPoint(rotMatrix); + + vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); + } + + for (const auto& i : indicesForOneObject) + { + indices->add(i + indexOffset); + } + } + + cvf::ref drawable = new cvf::DrawableGeo(); + drawable->setVertexArray(vertices.p()); + + drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); + drawable->computeNormals(); + + return drawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + size_t connectionIndex = triangleIndex / m_trianglesPerConnection; + + return m_centerColorPairs[connectionIndex].m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// Taken from OverlayNavigationCube::computeNewUpVector +/// Consider move to geometry util class +//-------------------------------------------------------------------------------------------------- +cvf::Mat4f RivWellConnectionFactorGeometryGenerator::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) +{ + using namespace cvf; + + Vec3d rotAxis = v1 ^ v2; + rotAxis.normalize(); + + // Guard acos against out-of-domain input + const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + + Mat4f myMat(rotMat); + + return myMat; +} diff --git a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h similarity index 56% rename from ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h rename to ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h index 725db29aa0..504a9b81b4 100644 --- a/ApplicationCode/ModelVisualization/RivVirtualConnFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h @@ -19,68 +19,56 @@ #pragma once #include "cvfBase.h" +#include "cvfMatrix4.h" #include "cvfObject.h" #include "cvfVector3.h" -#include "cvfMatrix4.h" - -#include "cafPdmPointer.h" #include namespace cvf { -class Part; -class ModelBasicList; -class ScalarMapper; +class DrawableGeo; } // namespace cvf -class RimWellPath; -class RimVirtualPerforationResults; - -namespace caf -{ -class DisplayCoordTransform; -} - +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- struct CompletionVizData { - CompletionVizData(cvf::Vec3d anchor, cvf::Vec3d direction, double connectionFactor) + CompletionVizData(const cvf::Vec3d& anchor, const cvf::Vec3d& direction, double connectionFactor, size_t globalCellIndex) : m_anchor(anchor) , m_direction(direction) , m_connectionFactor(connectionFactor) + , m_globalCellIndex(globalCellIndex) { } cvf::Vec3d m_anchor; cvf::Vec3d m_direction; double m_connectionFactor; + size_t m_globalCellIndex; }; - //-------------------------------------------------------------------------------------------------- /// -/// Based on RivWellSpheresPartMgr -/// //-------------------------------------------------------------------------------------------------- -class RivVirtualConnFactorPartMgr : public cvf::Object +class RivWellConnectionFactorGeometryGenerator : public cvf::Object { public: - RivVirtualConnFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult); - ~RivVirtualConnFactorPartMgr(); + RivWellConnectionFactorGeometryGenerator(std::vector& centerColorPairs, float radius); + ~RivWellConnectionFactorGeometryGenerator(); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + cvf::ref createPipeSurface(); -private: - static cvf::ref createPart(std::vector& centerColorPairs, - double radius, - cvf::ScalarMapper* scalarMapper, - bool disableLighting); - - static void createStarGeometry(std::vector* vertices, std::vector* indices, double radius, double thickness); + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; +private: static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); + static void + createStarGeometry(std::vector* vertices, std::vector* indices, float radius, float thickness); private: - caf::PdmPointer m_rimWell; - caf::PdmPointer m_virtualPerforationResult; + std::vector m_centerColorPairs; + float m_radius; + size_t m_trianglesPerConnection; }; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp new file mode 100644 index 0000000000..cc633613d3 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -0,0 +1,193 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionFactorPartMgr.h" + +#include "RiaApplication.h" +#include "RiaExtractionTools.h" + +#include "RigEclipseWellLogExtractor.h" +#include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellLogExtractor.h" +#include "RigWellPath.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimLegendConfig.h" +#include "RimSimWellInViewCollection.h" +#include "RimVirtualPerforationResults.h" +#include "RimWellPath.h" + +#include "RiuViewer.h" + +#include "RivWellConnectionFactorGeometryGenerator.h" +#include "RivWellConnectionSourceInfo.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" +#include "cvfDrawableGeo.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorPartMgr::RivWellConnectionFactorPartMgr(RimWellPath* well, + RimVirtualPerforationResults* virtualPerforationResult) + : m_rimWell(well) + , m_virtualPerforationResult(virtualPerforationResult) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorPartMgr::~RivWellConnectionFactorPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +{ + m_geometryGenerator = nullptr; + + RimEclipseView* eclView = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView); + + auto coordTransform = eclView->displayCoordTransform(); + + RimEclipseCase* eclipseCase = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + const RigMainGrid* mainGrid = eclipseCase->mainGrid(); + + const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (!trans) return; + + auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex); + + std::vector wellPathCellIntersections; + { + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase); + if (extractor) + { + wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); + } + } + + std::vector mapFromConnectionIndexToGlobalCellIndex; + + std::vector centerColorPairs; + for (const auto& cell : conn) + { + size_t gridIndex = cell.first.globalCellIndex(); + + const RigCell& rigCell = mainGrid->cell(gridIndex); + + cvf::Vec3d locationInDomainCoord = rigCell.center(); + cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; + + if (!wellPathCellIntersections.empty()) + { + for (const auto& intersectionInfo : wellPathCellIntersections) + { + if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) + { + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; + + double middleMD = (startMD + endMD) / 2.0; + + locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + + cvf::Vec3d p1; + cvf::Vec3d p2; + m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); + + wellPathDirection = (p2 - p1).getNormalized(); + + continue; + } + } + } + + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); + + double transmissibility = HUGE_VAL; + if (!cell.second.empty()) + { + transmissibility = cell.second.front().transmissibility(); + } + + centerColorPairs.push_back( + CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex())); + mapFromConnectionIndexToGlobalCellIndex.push_back(cell.first.globalCellIndex()); + } + + if (!centerColorPairs.empty()) + { + double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); + + m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(centerColorPairs, radius); + auto drawable = m_geometryGenerator->createPipeSurface(); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + + auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); + + // Compute texture coords + cvf::ref textureCoords = new cvf::Vec2fArray(); + { + textureCoords->reserve(drawable->vertexArray()->size()); + size_t verticesPerItem = drawable->vertexArray()->size() / centerColorPairs.size(); + + textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); + + for (const auto& item : centerColorPairs) + { + cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f); + if (item.m_connectionFactor != HUGE_VAL) + { + textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor); + } + + for (size_t i = 0; i < verticesPerItem; i++) + { + textureCoords->add(textureCoord); + } + } + } + + drawable->setTextureCoordArray(textureCoords.p()); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + + bool disableLighting = eclView->isLightingDisabled(); + effGen.disableLighting(disableLighting); + + cvf::ref eff = effGen.generateCachedEffect(); + part->setEffect(eff.p()); + + cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p()); + part->setSourceInfo(sourceInfo.p()); + + model->addPart(part.p()); + } +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h new file mode 100644 index 0000000000..ac1b5e0f11 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" + +#include "cafPdmPointer.h" + +#include + +namespace cvf +{ +class ModelBasicList; +} // namespace cvf + +class RimWellPath; +class RimVirtualPerforationResults; +class RivWellConnectionFactorGeometryGenerator; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RivWellConnectionFactorPartMgr : public cvf::Object +{ +public: + RivWellConnectionFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult); + ~RivWellConnectionFactorPartMgr(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + +private: + caf::PdmPointer m_rimWell; + caf::PdmPointer m_virtualPerforationResult; + + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp new file mode 100644 index 0000000000..5dbc092435 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionSourceInfo.h" + +#include "RimWellPath.h" +#include "RivWellConnectionFactorGeometryGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionSourceInfo::RivWellConnectionSourceInfo(RimWellPath* wellPath, + RivWellConnectionFactorGeometryGenerator* geometryGenerator) + : m_wellPath(wellPath) + , m_geometryGenerator(geometryGenerator) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RivWellConnectionSourceInfo::wellPath() const +{ + return m_wellPath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0; + + return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h new file mode 100644 index 0000000000..c02205143d --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmPointer.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class RimWellPath; +class RivWellConnectionFactorGeometryGenerator; + +//================================================================================================== +/// +//================================================================================================== +class RivWellConnectionSourceInfo : public cvf::Object +{ +public: + explicit RivWellConnectionSourceInfo(RimWellPath* wellPath, RivWellConnectionFactorGeometryGenerator* geometryGenerator); + + RimWellPath* wellPath() const; + + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + +private: + caf::PdmPointer m_wellPath; + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 8bda6e44cf..c5679810cb 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -47,6 +47,7 @@ #include "RivObjectSourceInfo.h" #include "RivPartPriority.h" #include "RivPipeGeometryGenerator.h" +#include "RivWellConnectionFactorPartMgr.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathPartMgr.h" #include "RivWellPathSourceInfo.h" @@ -63,7 +64,6 @@ #include "cvfScalarMapperDiscreteLinear.h" #include "cvfTransform.h" #include "cvfqtUtils.h" -#include "RivVirtualConnFactorPartMgr.h" //-------------------------------------------------------------------------------------------------- @@ -178,7 +178,7 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, size_t timeStepIndex = m_rimView->currentTimeStep(); std::vector timeStamps = eclipseCase->timeStepDates(); - if (timeStepIndex < static_cast(timeStamps.size())) + if (timeStepIndex < timeStamps.size()) { currentTimeStamp = timeStamps[timeStepIndex]; } @@ -238,11 +238,11 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); if (trans) { - m_virtualConnectionFactorPartMgr = new RivVirtualConnFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); + m_wellConnectionFactorPartMgr = new RivWellConnectionFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); size_t timeStepIndex = m_rimView->currentTimeStep(); - m_virtualConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); + m_wellConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); } } diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index afd6aea4ea..cc8d9433ec 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -46,7 +46,7 @@ class RivFishbonesSubsPartMgr; class RimWellPathCollection; class Rim3dView; class Riv3dWellLogPlanePartMgr; -class RivVirtualConnFactorPartMgr; +class RivWellConnectionFactorPartMgr; class QDateTime; @@ -110,6 +110,6 @@ class RivWellPathPartMgr : public cvf::Object cvf::ref m_centerLineDrawable; cvf::ref m_wellLabelPart; - cvf::ref m_3dWellLogCurvePartMgr; - cvf::ref m_virtualConnectionFactorPartMgr; + cvf::ref m_3dWellLogCurvePartMgr; + cvf::ref m_wellConnectionFactorPartMgr; }; From b189346f326f934f34a407a599cc08db63e3844d Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 16 Mar 2018 11:20:17 +0100 Subject: [PATCH 0524/1027] #2598 3D Well log curve: Add RFT curve code. curveValuesAndMds does currently only give values for a simwell --- .../WellLogCommands/CMakeLists_files.cmake | 2 + .../RicAdd3dWellLogRftCurveFeature.cpp | 75 +++++++++ .../RicAdd3dWellLogRftCurveFeature.h | 34 ++++ .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 149 ++++++++++++++++++ .../ProjectDataModel/Rim3dWellLogRftCurve.h | 62 ++++++++ 6 files changed, 324 insertions(+) create mode 100644 ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp create mode 100644 ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp create mode 100644 ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 6e3d66d559..01adb66091 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -25,6 +25,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -53,6 +54,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp new file mode 100644 index 0000000000..1f9def91cc --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogRftCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogRftCurve.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogRftCurveFeature, "RicAdd3dWellLogRftCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogRftCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + RimWellPath* wellPath = RicWellLogTools::selectedWellPath(); + + return RicWellLogTools::wellHasRftData(wellPath->name()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogRftCurveFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); + if (!selectedWellPath) return; + + Rim3dWellLogRftCurve* rim3dWellLogRftCurve = new Rim3dWellLogRftCurve(); + selectedWellPath->add3dWellLogCurve(rim3dWellLogRftCurve); + + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogRftCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); + + selectedWellPath->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogRftCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log RFT Curve"); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h new file mode 100644 index 0000000000..a953f315fc --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogRftCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 2b5447879c..49c2a46248 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -101,6 +101,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h ) @@ -207,6 +208,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp new file mode 100644 index 0000000000..e245f99368 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -0,0 +1,149 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogRftCurve.h" + +#include "RimWellPath.h" +#include "RimWellLogCurve.h" +#include "RigWellLogCurveData.h" +#include "RimEclipseResultCase.h" +#include "RifReaderEclipseRft.h" +#include "RimTools.h" + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogRftCurve, "Rim3dWellLogRftCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() +{ + CAF_PDM_InitObject("3d Well Log RFT Curve", ":/WellLogCurve16x16.png", "", ""); + + m_name = "3D Well Log RFT Curve"; + + m_2dWellLogRftCurve.xmlCapability()->disableIO(); + m_2dWellLogRftCurve = new RimWellLogRftCurve(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogRftCurve::~Rim3dWellLogRftCurve() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + if (m_2dWellLogRftCurve->wellName() == QString()) + { + m_2dWellLogRftCurve->setDefaultAddress(wellName()); + } + + const RigWellLogCurveData* curveData = m_2dWellLogRftCurve->curveData(); + + //These values are for a simulation well + *values = curveData->xValues(); + *measuredDepthValues = curveData->measuredDepths(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogRftCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_eclipseResultCase) + { + RimTools::caseOptionItems(&options); + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_wellLogChannelName) + { + if (m_eclipseResultCase) + { + RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); + if (reader) + { + for (const RifEclipseRftAddress::RftWellLogChannelType& channelName : reader->availableWellLogChannels(wellName())) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(channelName), channelName)); + } + } + if (options.empty()) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(RifEclipseRftAddress::NONE), RifEclipseRftAddress::NONE)); + } + } + } + else if (fieldNeedingOptions == &m_timeStep) + { + if (m_eclipseResultCase) + { + RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); + if (reader) + { + QString dateFormat = "dd MMM yyyy"; + std::vector timeStamps = reader->availableTimeSteps(wellName(), m_wellLogChannelName()); + for (const QDateTime& dt : timeStamps) + { + options.push_back(caf::PdmOptionItemInfo(dt.toString(dateFormat), dt)); + } + } + + options.push_back(caf::PdmOptionItemInfo("None", QDateTime())); + } + } + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + curveDataGroup->add(&m_eclipseResultCase); + curveDataGroup->add(&m_wellLogChannelName); + curveDataGroup->add(&m_timeStep); + + caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); + Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::wellName() const +{ + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + return wellPath->name(); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h new file mode 100644 index 0000000000..72e1f04a3a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmPtrField.h" + +#include "RifEclipseRftAddress.h" +#include "RimWellLogRftCurve.h" + +class RimEclipseResultCase; +class QString; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogRftCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogRftCurve(); + virtual ~Rim3dWellLogRftCurve(); + + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + QString wellName() const; + +private: + caf::PdmPtrField m_eclipseResultCase; + caf::PdmField m_timeStep; + + caf::PdmField> m_wellLogChannelName; + + caf::PdmChildField m_2dWellLogRftCurve; +}; From 94932b9876e4099ddeabdc6cd11f77aaeeea25f7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 16 Mar 2018 11:40:24 +0100 Subject: [PATCH 0525/1027] #2613 Tensor Vectors: Set default off. Make ST selected on default --- ApplicationCode/ProjectDataModel/RimTensorResults.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index 405f11445a..053de15074 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -65,14 +65,14 @@ RimTensorResults::RimTensorResults() this->legendConfig = new RimLegendConfig(); legendConfig.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", ""); + CAF_PDM_InitField(&m_resultFieldName, "ResultVariable", QString("ST"), "Value", "", "", ""); m_resultFieldName.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); + CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString("ST"), "Value", "", "", ""); m_resultFieldNameUiField.xmlCapability()->setIOWritable(false); m_resultFieldNameUiField.xmlCapability()->setIOReadable(false); - CAF_PDM_InitField(&m_showTensors, "ShowTensors", true, "", "", "", ""); + CAF_PDM_InitField(&m_showTensors, "ShowTensors", false, "", "", "", ""); CAF_PDM_InitField(&m_principal1, "Principal1", true, "Principal 1", "", "", ""); CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", ""); From 08a978d0d7e4c9182844e34dc76e649484b0fb89 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 11:21:38 +0100 Subject: [PATCH 0526/1027] #2621 Check valid date in perforation interval --- .../ProjectDataModel/Completions/RimPerforationInterval.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp index e700d9f0b3..881665cc3a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp @@ -124,6 +124,9 @@ bool RimPerforationInterval::isActiveOnDate(const QDateTime& date) const { return true; } + + if (!date.isValid()) return false; + return m_date() < date; } From 471d625051f479a2dc6b736ba4580de49ca42c7e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 11:21:57 +0100 Subject: [PATCH 0527/1027] #2621 Improve interface of part managers to prepare for use in 2D intersection views --- .../RivSimWellPipesPartMgr.h | 1 + .../ModelVisualization/RivWellPathPartMgr.cpp | 47 ++++++++-------- .../ModelVisualization/RivWellPathPartMgr.h | 54 ++++++++++--------- .../RivWellPathsPartMgr.cpp | 30 ++++++----- .../ModelVisualization/RivWellPathsPartMgr.h | 49 ++++++++--------- .../ProjectDataModel/Rim3dView.cpp | 10 ++-- 6 files changed, 101 insertions(+), 90 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 98fef5c65f..5696c8e676 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -54,6 +54,7 @@ class RivSimWellPipesPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, const caf::DisplayCoordTransform* displayXf); + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex, const caf::DisplayCoordTransform* displayXf, diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index c5679810cb..cd793af020 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -160,6 +160,7 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod /// //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize) { @@ -172,15 +173,19 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, if (!wellPathGeometry) return; QDateTime currentTimeStamp; - RimEclipseCase* eclipseCase = nullptr; - m_rimView->firstAncestorOrThisOfTypeAsserted(eclipseCase); - - size_t timeStepIndex = m_rimView->currentTimeStep(); - - std::vector timeStamps = eclipseCase->timeStepDates(); - if (timeStepIndex < timeStamps.size()) + if (m_rimView) { - currentTimeStamp = timeStamps[timeStepIndex]; + RimCase* rimCase = nullptr; + m_rimView->firstAncestorOrThisOfType(rimCase); + + if (rimCase) + { + std::vector timeStamps = rimCase->timeStepDates(); + if (timeStepIndex < timeStamps.size()) + { + currentTimeStamp = timeStamps[timeStepIndex]; + } + } } // Since we're using the index of measured depths to find the index of a point, ensure they're equal @@ -197,7 +202,7 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, if (!perforation->isChecked()) continue; if (perforation->startMD() > perforation->endMD()) continue; - if (currentTimeStamp.isValid() && !perforation->isActiveOnDate(currentTimeStamp)) continue; + if (!perforation->isActiveOnDate(currentTimeStamp)) continue; using namespace std; pair, vector > displayCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), @@ -223,6 +228,7 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, /// //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize) { @@ -240,8 +246,6 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL { m_wellConnectionFactorPartMgr = new RivWellConnectionFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); - size_t timeStepIndex = m_rimView->currentTimeStep(); - m_wellConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); } } @@ -401,10 +405,10 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) +void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { RimWellPathCollection* wellPathCollection = this->wellPathCollection(); if (!wellPathCollection) return; @@ -440,10 +444,11 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) +void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { CVF_ASSERT(model); @@ -458,8 +463,8 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false) return; - appendPerforationsToModel(model, displayCoordTransform, characteristicCellSize); - appendVirtualTransmissibilitiesToModel(model, displayCoordTransform, characteristicCellSize); + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); + appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index cc8d9433ec..cfdcb60d14 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -59,41 +59,45 @@ class RivWellPathPartMgr : public cvf::Object explicit RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view); ~RivWellPathPartMgr(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); - size_t segmentIndexFromTriangleIndex(size_t triangleIndex); + size_t segmentIndexFromTriangleIndex(size_t triangleIndex); private: - void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); - void appendImportedFishbonesToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendImportedFishbonesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); - void appendPerforationsToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendPerforationsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); - void appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); + void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); - void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox); void clearAllBranchData(); inline RimWellPathCollection* wellPathCollection(); diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index a8807ed255..3237a1bde2 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -30,7 +30,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathsPartMgr::RivWellPathsPartMgr(Rim3dView* view) : m_rimView(view) {} +RivWellPathsPartMgr::RivWellPathsPartMgr(Rim3dView* view) + : m_rimView(view) +{ +} //-------------------------------------------------------------------------------------------------- /// @@ -40,10 +43,10 @@ RivWellPathsPartMgr::~RivWellPathsPartMgr() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) +void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { if (!isWellPathVisible()) return; @@ -51,7 +54,7 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* for (auto& partMgr : m_wellPatshsPartMgrs) { - partMgr->appendStaticGeometryPartsToModel(model, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); + partMgr->appendStaticGeometryPartsToModel(model, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); } } @@ -73,10 +76,11 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, +void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) + const cvf::BoundingBox& wellPathClipBoundingBox) { if (!isWellPathVisible()) return; @@ -84,10 +88,8 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* for (auto& partMgr : m_wellPatshsPartMgrs) { - partMgr->appendDynamicGeometryPartsToModel(model, - characteristicCellSize, - wellPathClipBoundingBox, - displayCoordTransform); + partMgr->appendDynamicGeometryPartsToModel( + model, timeStepIndex, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); } } @@ -148,7 +150,7 @@ RimWellPathCollection* RivWellPathsPartMgr::wellPathCollection() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RivWellPathsPartMgr::isWellPathVisible() const { diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index 4124ce1093..5f30339930 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -1,24 +1,23 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once - #include "cvfBase.h" #include "cvfCollection.h" #include "cvfObject.h" @@ -29,17 +28,16 @@ #include - namespace cvf { - class BoundingBox; - class Transform; - class ModelBasicList; -} +class BoundingBox; +class Transform; +class ModelBasicList; +} // namespace cvf namespace caf { - class DisplayCoordTransform; +class DisplayCoordTransform; } class Rim3dView; @@ -48,7 +46,7 @@ class RimWellPathCollection; class RimWellPath; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- class RivWellPathsPartMgr : public cvf::Object { @@ -56,29 +54,28 @@ class RivWellPathsPartMgr : public cvf::Object explicit RivWellPathsPartMgr(Rim3dView* view); ~RivWellPathsPartMgr(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); - - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); - - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); - - size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); + size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; private: void clearGeometryCache(); void scheduleGeometryRegen(); void createPartManagersIfRequired(); RimWellPathCollection* wellPathCollection() const; - bool isWellPathVisible() const; + bool isWellPathVisible() const; private: caf::PdmPointer m_rimView; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 41fae6450b..4fc5b6b008 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -665,9 +665,9 @@ void Rim3dView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, cvf::ref transForm = displayCoordTransform(); m_wellPathsPartManager->appendStaticGeometryPartsToModel(wellPathModelBasicList, + transForm.p(), this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); + wellPathClipBoundingBox); wellPathModelBasicList->updateBoundingBoxesRecursive(); } @@ -681,10 +681,12 @@ void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBas cvf::ref transForm = displayCoordTransform(); + size_t timeStepIndex = currentTimeStep(); m_wellPathsPartManager->appendDynamicGeometryPartsToModel(wellPathModelBasicList, + timeStepIndex, + transForm.p(), this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); + wellPathClipBoundingBox); wellPathModelBasicList->updateBoundingBoxesRecursive(); } From dc6bbba848d16f317ce461b7a4fea5d9ff9ec8f8 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Fri, 16 Mar 2018 11:54:45 +0100 Subject: [PATCH 0528/1027] #2612 Tensor Vectors: Hide legend when Tensor Vectors are turned off --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimTensorResults.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 286274896d..7ca1105495 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -385,7 +385,7 @@ void RimGeoMechView::updateLegends() updateTensorLegendTextAndRanges(m_tensorResults->legendConfig(), m_currentTimeStep()); - if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS) + if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->legendConfig->legend()); } diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index 053de15074..4b66427abb 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -93,7 +93,6 @@ RimTensorResults::RimTensorResults() //-------------------------------------------------------------------------------------------------- RimTensorResults::~RimTensorResults() { - delete legendConfig; } //-------------------------------------------------------------------------------------------------- @@ -110,6 +109,7 @@ RigFemResultAddress RimTensorResults::selectedTensorResult() const void RimTensorResults::setShowTensors(bool enableTensors) { m_showTensors = enableTensors; + updateConnectedEditors(); updateUiIconFromState(enableTensors); } From ecfb827b41d54c6c26fd837f829b8fe393776c19 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 13:40:49 +0100 Subject: [PATCH 0529/1027] Add missing init macros in constructor --- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index e245f99368..65a6bf71e6 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -39,10 +39,17 @@ Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() { CAF_PDM_InitObject("3d Well Log RFT Curve", ":/WellLogCurve16x16.png", "", ""); - m_name = "3D Well Log RFT Curve"; - - m_2dWellLogRftCurve.xmlCapability()->disableIO(); + CAF_PDM_InitFieldNoDefault(&m_eclipseResultCase, "eclipseResultCase", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_timeStep, "timeStep", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogChannelName, "wellLogChannelName", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_2dWellLogRftCurve, "my2dWellLogRftCurve", "", "", "", ""); + m_2dWellLogRftCurve = new RimWellLogRftCurve(); + m_2dWellLogRftCurve.xmlCapability()->disableIO(); + + m_name = "3D Well Log RFT Curve"; } //-------------------------------------------------------------------------------------------------- From 9656883c925e141c4197fc496748256a5e4d489b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 13:41:41 +0100 Subject: [PATCH 0530/1027] Fix wrong use of macros in constructor causing crash triggered by regression tests --- .../RicExportCompletionDataSettingsUi.cpp | 10 ---------- .../RicExportCompletionDataSettingsUi.h | 1 - ApplicationCode/ProjectDataModel/RimDialogData.cpp | 3 ++- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 31aa782b44..975436b61f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -76,16 +76,6 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() m_displayForSimWell = true; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected) -{ - RicExportCompletionDataSettingsUi(); - - setOnlyWellPathCollectionSelected(onlyWellPathCollectionSelected); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 3ef0a43045..b23cb6940f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -53,7 +53,6 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi RicExportCompletionDataSettingsUi(); - RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected); caf::PdmField fileSplit; caf::PdmField wellSelection; diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index d9ed687faf..e0c84020a8 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -34,7 +34,8 @@ RimDialogData::RimDialogData() m_exportCarfin = new RicExportCarfinUi; CAF_PDM_InitFieldNoDefault(&m_exportCompletionData, "ExportCompletionData", "Export Completion Data", "", "", ""); - m_exportCompletionData = new RicExportCompletionDataSettingsUi(false); + m_exportCompletionData = new RicExportCompletionDataSettingsUi(); + m_exportCompletionData->setOnlyWellPathCollectionSelected(false); } //-------------------------------------------------------------------------------------------------- From 7bb705b1b7e6b2339db199351299d82d1690b7e4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 15:33:57 +0100 Subject: [PATCH 0531/1027] #2600 Well CF Visualization: Add picking on connection factor objects --- ...vWellConnectionFactorGeometryGenerator.cpp | 4 ++ .../UserInterface/RiuViewerCommands.cpp | 59 ++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index cf65996a71..3eb91b5aed 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -154,6 +154,8 @@ cvf::ref RivWellConnectionFactorGeometryGenerator::createPipeS RivWellConnectionFactorGeometryGenerator::createStarGeometry( &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); + m_trianglesPerConnection = indicesForOneObject.size() / 3; + cvf::ref vertices = new cvf::Vec3fArray; cvf::ref indices = new cvf::UIntArray; @@ -195,6 +197,8 @@ cvf::ref RivWellConnectionFactorGeometryGenerator::createPipeS //-------------------------------------------------------------------------------------------------- size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const { + if (m_trianglesPerConnection == 0) return 0; + size_t connectionIndex = triangleIndex / m_trianglesPerConnection; return m_centerColorPairs[connectionIndex].m_globalCellIndex; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 4a164d69a7..e4d0812e2d 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -34,6 +34,7 @@ #include "RigFemPartGrid.h" #include "RigGeoMechCaseData.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RiaDefines.h" #include "RimCellEdgeColors.h" @@ -72,8 +73,9 @@ #include "RivSimWellPipeSourceInfo.h" #include "RivSourceInfo.h" #include "RivTernarySaturationOverlayItem.h" -#include "RivWellPathSourceInfo.h" +#include "RivWellConnectionSourceInfo.h" #include "RivWellFracturePartMgr.h" +#include "RivWellPathSourceInfo.h" #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" @@ -528,6 +530,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM const RivIntersectionSourceInfo* crossSectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); if (rivObjectSourceInfo) { @@ -626,6 +629,60 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM RiuMainWindow::instance()->selectAsCurrentItem(eclipseWellSourceInfo->well(), allowActiveViewChange); } + else if (wellConnectionSourceInfo) + { + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + size_t globalCellIndex = wellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCase* eclipseCase = nullptr; + eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + if (eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities()) + { + auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); + size_t timeStep = eclipseView->currentTimeStep(); + + const auto& completionData = connectionFactors->multipleCompletionsPerEclipseCell(wellConnectionSourceInfo->wellPath(), timeStep); + + for (const auto& compData : completionData) + { + if (compData.first.globalCellIndex() == globalCellIndex) + { + auto completionDataItems = compData.second; + + if (!completionDataItems.empty()) + { + QString resultInfoText; + + // For now, only report the fist completion and not the combined completion if more than one + // completion contributes into a cell + + resultInfoText += QString("Well Connection Factor : %1").arg(completionDataItems[0].transmissibility()); + resultInfoText += "

Details :
"; + + for (const auto& completionData : completionDataItems) + { + for (const auto& metaData : completionData.metadata()) + { + resultInfoText += QString("Name %1 Description %2
").arg(metaData.name).arg(metaData.comment); + } + } + + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } + + break; + } + } + } + } + + RiuMainWindow::instance()->selectAsCurrentItem(wellConnectionSourceInfo->wellPath(), allowActiveViewChange); + } } if (firstNncHitPart && firstNncHitPart->sourceInfo()) From 1aad577a4912a1332dd917d41e741f3ac549e596 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 15:58:04 +0100 Subject: [PATCH 0532/1027] #2544 Well CF Visualization: Use simplified star geometry --- ...vWellConnectionFactorGeometryGenerator.cpp | 60 ++++++++++++++++++- ...RivWellConnectionFactorGeometryGenerator.h | 7 ++- .../RivWellConnectionFactorPartMgr.cpp | 2 +- .../UserInterface/RiuViewerCommands.cpp | 1 - 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index 3eb91b5aed..ef1ca12837 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -126,6 +126,60 @@ void RivWellConnectionFactorGeometryGenerator::createStarGeometry(std::vectorpush_back(9); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness) +{ + auto p0 = cvf::Vec3f::Y_AXIS * thickness; + auto p1 = -p0; + auto p2 = cvf::Vec3f::Z_AXIS * radius; + + auto p3 = p0; + auto p4 = p1; + auto p5 = cvf::Vec3f::X_AXIS * radius; + + auto p6 = p0; + auto p7 = p1; + auto p8 = -p2; + + auto p9 = p0; + auto p10 = p1; + auto p11 = -p5; + + vertices->push_back(p0); + vertices->push_back(p1); + vertices->push_back(p2); + vertices->push_back(p3); + vertices->push_back(p4); + vertices->push_back(p5); + vertices->push_back(p6); + vertices->push_back(p7); + vertices->push_back(p8); + vertices->push_back(p9); + vertices->push_back(p10); + vertices->push_back(p11); + + indices->push_back(0); + indices->push_back(1); + indices->push_back(2); + + indices->push_back(3); + indices->push_back(4); + indices->push_back(5); + + indices->push_back(6); + indices->push_back(7); + indices->push_back(8); + + indices->push_back(9); + indices->push_back(10); + indices->push_back(11); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -146,13 +200,15 @@ RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenera //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellConnectionFactorGeometryGenerator::createPipeSurface() +cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfaceGeometry() { std::vector verticesForOneObject; std::vector indicesForOneObject; - RivWellConnectionFactorGeometryGenerator::createStarGeometry( + RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry( &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); + // RivWellConnectionFactorGeometryGenerator::createStarGeometry( + // &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); m_trianglesPerConnection = indicesForOneObject.size() / 3; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h index 504a9b81b4..d1168268d4 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h @@ -58,7 +58,7 @@ class RivWellConnectionFactorGeometryGenerator : public cvf::Object RivWellConnectionFactorGeometryGenerator(std::vector& centerColorPairs, float radius); ~RivWellConnectionFactorGeometryGenerator(); - cvf::ref createPipeSurface(); + cvf::ref createSurfaceGeometry(); size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; @@ -67,6 +67,11 @@ class RivWellConnectionFactorGeometryGenerator : public cvf::Object static void createStarGeometry(std::vector* vertices, std::vector* indices, float radius, float thickness); + static void createSimplifiedStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness); + private: std::vector m_centerColorPairs; float m_radius; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index cc633613d3..30872e1c9d 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -145,7 +145,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(centerColorPairs, radius); - auto drawable = m_geometryGenerator->createPipeSurface(); + auto drawable = m_geometryGenerator->createSurfaceGeometry(); cvf::ref part = new cvf::Part; part->setDrawable(drawable.p()); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index e4d0812e2d..1aa61384cc 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -76,7 +76,6 @@ #include "RivWellConnectionSourceInfo.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathSourceInfo.h" - #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" #include "cafCmdFeatureMenuBuilder.h" From 200873f2da3a8e1fb63105daa1d729452d437ca9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 16:12:25 +0100 Subject: [PATCH 0533/1027] Code cleanup --- ...vWellConnectionFactorGeometryGenerator.cpp | 203 +++++++++--------- 1 file changed, 102 insertions(+), 101 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index ef1ca12837..e1265fb32b 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -22,6 +22,105 @@ #include "cvfDrawableGeo.h" #include "cvfPrimitiveSetIndexedUInt.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( + std::vector& centerColorPairs, + float radius) + : m_centerColorPairs(centerColorPairs) + , m_radius(radius) + , m_trianglesPerConnection(0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfaceGeometry() +{ + std::vector verticesForOneObject; + std::vector indicesForOneObject; + + RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry( + &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); + + m_trianglesPerConnection = indicesForOneObject.size() / 3; + + cvf::ref vertices = new cvf::Vec3fArray; + cvf::ref indices = new cvf::UIntArray; + + auto indexCount = m_centerColorPairs.size() * indicesForOneObject.size(); + auto vertexCount = m_centerColorPairs.size() * verticesForOneObject.size(); + indices->reserve(indexCount); + vertices->reserve(vertexCount); + + for (const auto& item : m_centerColorPairs) + { + auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); + + cvf::uint indexOffset = static_cast(vertices->size()); + + for (const auto& v : verticesForOneObject) + { + auto rotatedPoint = v.getTransformedPoint(rotMatrix); + + vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); + } + + for (const auto& i : indicesForOneObject) + { + indices->add(i + indexOffset); + } + } + + cvf::ref drawable = new cvf::DrawableGeo(); + drawable->setVertexArray(vertices.p()); + + drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); + drawable->computeNormals(); + + return drawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_trianglesPerConnection == 0) return 0; + + size_t connectionIndex = triangleIndex / m_trianglesPerConnection; + + return m_centerColorPairs[connectionIndex].m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// Taken from OverlayNavigationCube::computeNewUpVector +/// Consider move to geometry util class +//-------------------------------------------------------------------------------------------------- +cvf::Mat4f RivWellConnectionFactorGeometryGenerator::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) +{ + using namespace cvf; + + Vec3d rotAxis = v1 ^ v2; + rotAxis.normalize(); + + // Guard acos against out-of-domain input + const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + + Mat4f myMat(rotMat); + + return myMat; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -134,6 +233,9 @@ void RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry(std: float radius, float thickness) { + // Suggested improvement + // As the nodes are duplicated, it will be possible create only vertices and then use DrawableGeo::setFromTriangleVertexArray + auto p0 = cvf::Vec3f::Y_AXIS * thickness; auto p1 = -p0; auto p2 = cvf::Vec3f::Z_AXIS * radius; @@ -179,104 +281,3 @@ void RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry(std: indices->push_back(10); indices->push_back(11); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( - std::vector& centerColorPairs, - float radius) - : m_centerColorPairs(centerColorPairs) - , m_radius(radius) - , m_trianglesPerConnection(0) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfaceGeometry() -{ - std::vector verticesForOneObject; - std::vector indicesForOneObject; - - RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry( - &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); - // RivWellConnectionFactorGeometryGenerator::createStarGeometry( - // &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); - - m_trianglesPerConnection = indicesForOneObject.size() / 3; - - cvf::ref vertices = new cvf::Vec3fArray; - cvf::ref indices = new cvf::UIntArray; - - auto indexCount = m_centerColorPairs.size() * indicesForOneObject.size(); - auto vertexCount = m_centerColorPairs.size() * verticesForOneObject.size(); - indices->reserve(indexCount); - vertices->reserve(vertexCount); - - for (const auto& item : m_centerColorPairs) - { - auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); - - cvf::uint indexOffset = static_cast(vertices->size()); - - for (const auto& v : verticesForOneObject) - { - auto rotatedPoint = v.getTransformedPoint(rotMatrix); - - vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); - } - - for (const auto& i : indicesForOneObject) - { - indices->add(i + indexOffset); - } - } - - cvf::ref drawable = new cvf::DrawableGeo(); - drawable->setVertexArray(vertices.p()); - - drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); - drawable->computeNormals(); - - return drawable; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const -{ - if (m_trianglesPerConnection == 0) return 0; - - size_t connectionIndex = triangleIndex / m_trianglesPerConnection; - - return m_centerColorPairs[connectionIndex].m_globalCellIndex; -} - -//-------------------------------------------------------------------------------------------------- -/// Taken from OverlayNavigationCube::computeNewUpVector -/// Consider move to geometry util class -//-------------------------------------------------------------------------------------------------- -cvf::Mat4f RivWellConnectionFactorGeometryGenerator::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) -{ - using namespace cvf; - - Vec3d rotAxis = v1 ^ v2; - rotAxis.normalize(); - - // Guard acos against out-of-domain input - const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); - const double angle = Math::acos(dotProduct); - Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); - - Mat4f myMat(rotMat); - - return myMat; -} From 0583c7a8159c40cccef5ae6a4966deba3867e456 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 16 Mar 2018 16:46:51 +0100 Subject: [PATCH 0534/1027] Rename --- .../RivWellConnectionFactorPartMgr.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 30872e1c9d..5394d0f185 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -93,7 +93,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode std::vector mapFromConnectionIndexToGlobalCellIndex; - std::vector centerColorPairs; + std::vector completionVizDataItems; for (const auto& cell : conn) { size_t gridIndex = cell.first.globalCellIndex(); @@ -135,16 +135,16 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode transmissibility = cell.second.front().transmissibility(); } - centerColorPairs.push_back( + completionVizDataItems.push_back( CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex())); mapFromConnectionIndexToGlobalCellIndex.push_back(cell.first.globalCellIndex()); } - if (!centerColorPairs.empty()) + if (!completionVizDataItems.empty()) { double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); - m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(centerColorPairs, radius); + m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); auto drawable = m_geometryGenerator->createSurfaceGeometry(); cvf::ref part = new cvf::Part; @@ -156,11 +156,11 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode cvf::ref textureCoords = new cvf::Vec2fArray(); { textureCoords->reserve(drawable->vertexArray()->size()); - size_t verticesPerItem = drawable->vertexArray()->size() / centerColorPairs.size(); + size_t verticesPerItem = drawable->vertexArray()->size() / completionVizDataItems.size(); textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); - for (const auto& item : centerColorPairs) + for (const auto& item : completionVizDataItems) { cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f); if (item.m_connectionFactor != HUGE_VAL) From af4b35b99050112efc5cbfc85cf1587bfced06ec Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 19 Mar 2018 11:16:50 +0100 Subject: [PATCH 0535/1027] #2618 Tensor Vectors: Add arrow length scaling range option for result --- .../RivTensorResultPartMgr.cpp | 16 +- .../ProjectDataModel/RimGeoMechView.cpp | 4 +- .../ProjectDataModel/RimLegendConfig.cpp | 8 +- .../ProjectDataModel/RimTensorResults.cpp | 184 ++++++++++++------ .../ProjectDataModel/RimTensorResults.h | 7 +- 5 files changed, 148 insertions(+), 71 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index e427eea6af..44dfeba37b 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -108,12 +108,18 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi RigFemPartNodes nodes = part->nodes(); + float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); + double min, max; - resultCollection->minMaxScalarValuesOverAllTensorComponents(address, (int)frameIndex, &min, &max); + m_rimReservoirView->tensorResults()->mappingRange(&min, &max); + + double maxAbsResult = 1.0; + if (min != cvf::UNDEFINED_DOUBLE && max != cvf::UNDEFINED_DOUBLE) + { + maxAbsResult = std::max(cvf::Math::abs(max), cvf::Math::abs(min)); + } - if (max == 0) max = 1; - float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); - float arrowResultScaling = arrowConstantScaling / cvf::Math::abs(max); + float arrowResultScaling = arrowConstantScaling / maxAbsResult; cvf::ref partMgrCache = m_rimReservoirView->vizLogic()->partMgrCache(); @@ -337,7 +343,7 @@ cvf::ref RivTensorResultPartMgr::createPart(const std::vectortensorResults()->vectorColors(); if (vectorColors == RimTensorResults::RESULT_COLORS) { - activeScalerMapper = m_rimReservoirView->tensorResults()->legendConfig()->scalarMapper(); + activeScalerMapper = m_rimReservoirView->tensorResults()->arrowColorLegendConfig()->scalarMapper(); createResultColorTextureCoords(lineTexCoords.p(), tensorVisualizations, activeScalerMapper); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 7ca1105495..cd2a17dcf1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -383,11 +383,11 @@ void RimGeoMechView::updateLegends() m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } - updateTensorLegendTextAndRanges(m_tensorResults->legendConfig(), m_currentTimeStep()); + updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { - m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); } } } diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index fdd5364cb8..ffaa8b9333 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -22,11 +22,13 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaPreferences.h" #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimGeoMechResultDefinition.h" +#include "RimIntersectionCollection.h" #include "RimStimPlanColors.h" #include "RimViewLinker.h" @@ -47,8 +49,6 @@ #include "cvfqtUtils.h" #include -#include "RimIntersectionCollection.h" -#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -57,8 +57,8 @@ namespace caf { template<> void AppEnum::setUp() { - addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "All Timesteps"); - addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Current Timestep"); + addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); + addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); setDefault(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS); } diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index 4b66427abb..0c5ef25578 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,51 +19,52 @@ #include "RimTensorResults.h" #include "RigFemResultAddress.h" +#include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" + +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" #include "cafAppEnum.h" #include "cafPdmUiListEditor.h" - +#include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults"); - namespace caf { - template<> - void AppEnum< RimTensorResults::TensorColors >::setUp() - { - addItem(RimTensorResults::WHITE_GRAY_BLACK , "WHITE_GRAY_BLACK", "White, Gray, Black"); - addItem(RimTensorResults::ORANGE_BLUE_WHITE, "ORANGE_BLUE_WHITE", "Orange, Blue, White"); - addItem(RimTensorResults::MAGENTA_BROWN_GRAY, "MAGENTA_BROWN_GRAY", "Magenta, Brown, Gray"); - addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors"); +template<> +void AppEnum::setUp() +{ + addItem(RimTensorResults::WHITE_GRAY_BLACK, "WHITE_GRAY_BLACK", "White, Gray, Black"); + addItem(RimTensorResults::ORANGE_BLUE_WHITE, "ORANGE_BLUE_WHITE", "Orange, Blue, White"); + addItem(RimTensorResults::MAGENTA_BROWN_GRAY, "MAGENTA_BROWN_GRAY", "Magenta, Brown, Gray"); + addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors"); - setDefault(RimTensorResults::WHITE_GRAY_BLACK); - } + setDefault(RimTensorResults::WHITE_GRAY_BLACK); +} - template<> - void AppEnum< RimTensorResults::ScaleMethod >::setUp() - { - addItem(RimTensorResults::RESULT, "RESULT", "Result"); - addItem(RimTensorResults::CONSTANT, "CONSTANT", "Constant"); +template<> +void AppEnum::setUp() +{ + addItem(RimTensorResults::RESULT, "RESULT", "Result"); + addItem(RimTensorResults::CONSTANT, "CONSTANT", "Constant"); - setDefault(RimTensorResults::RESULT); - } + setDefault(RimTensorResults::RESULT); } - +} // namespace caf //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimTensorResults::RimTensorResults() { CAF_PDM_InitObject("Element Tensor Results", ":/CellResult.png", "", ""); - CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); - this->legendConfig = new RimLegendConfig(); - legendConfig.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&arrowColorLegendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + this->arrowColorLegendConfig = new RimLegendConfig(); + arrowColorLegendConfig.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_resultFieldName, "ResultVariable", QString("ST"), "Value", "", "", ""); m_resultFieldName.uiCapability()->setUiHidden(true); @@ -83,20 +84,25 @@ RimTensorResults::RimTensorResults() CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", ""); CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", ""); + CAF_PDM_InitField(&m_rangeMode, + "RangeType", + RimLegendConfig::RangeModeEnum(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), + "Range Type", + "", + "Switches between automatic and user defined range", + ""); m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RimTensorResults::~RimTensorResults() -{ -} +RimTensorResults::~RimTensorResults() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigFemResultAddress RimTensorResults::selectedTensorResult() const { @@ -104,7 +110,7 @@ RigFemResultAddress RimTensorResults::selectedTensorResult() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimTensorResults::setShowTensors(bool enableTensors) { @@ -115,7 +121,7 @@ void RimTensorResults::setShowTensors(bool enableTensors) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimTensorResults::showTensors() const { @@ -123,7 +129,7 @@ bool RimTensorResults::showTensors() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimTensorResults::showPrincipal1() const { @@ -131,7 +137,7 @@ bool RimTensorResults::showPrincipal1() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimTensorResults::showPrincipal2() const { @@ -139,7 +145,7 @@ bool RimTensorResults::showPrincipal2() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimTensorResults::showPrincipal3() const { @@ -147,7 +153,7 @@ bool RimTensorResults::showPrincipal3() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- float RimTensorResults::threshold() const { @@ -155,7 +161,7 @@ float RimTensorResults::threshold() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- float RimTensorResults::sizeScale() const { @@ -163,7 +169,7 @@ float RimTensorResults::sizeScale() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimTensorResults::TensorColors RimTensorResults::vectorColors() const { @@ -171,7 +177,7 @@ RimTensorResults::TensorColors RimTensorResults::vectorColors() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const { @@ -179,7 +185,37 @@ RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::mappingRange(double* min, double* max) const +{ + *min = cvf::UNDEFINED_DOUBLE; + *max = cvf::UNDEFINED_DOUBLE; + + if (scaleMethod() == RESULT) + { + Rim3dView* view = nullptr; + firstAncestorOrThisOfType(view); + + int currentTimeStep = view->currentTimeStep(); + + RimGeoMechView* geoMechView = dynamic_cast(view); + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + if (!resultCollection) return; + + if (m_rangeMode == RimLegendConfig::AUTOMATIC_ALLTIMESTEPS) + { + resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), min, max); + } + else if (m_rangeMode == RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP) + { + resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), currentTimeStep, min, max); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- RigFemResultPosEnum RimTensorResults::resultPositionType() { @@ -187,7 +223,7 @@ RigFemResultPosEnum RimTensorResults::resultPositionType() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimTensorResults::resultFieldName() const { @@ -195,7 +231,7 @@ QString RimTensorResults::resultFieldName() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimTensorResults::getResultMetaDataForUIFieldSetting() { @@ -208,15 +244,17 @@ std::vector RimTensorResults::getResultMetaDataForUIFieldSetting() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { if (changedField == &m_resultFieldNameUiField) { m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField); } - if (changedField == &m_showTensors) + else if (changedField == &m_showTensors) { setShowTensors(m_showTensors); } @@ -227,7 +265,7 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimTensorResults::objectToggleField() { @@ -235,9 +273,10 @@ caf::PdmFieldHandle* RimTensorResults::objectToggleField() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RimTensorResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RimTensorResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; *useOptionsOnly = true; @@ -248,15 +287,24 @@ QList RimTensorResults::calculateValueOptions(const caf: for (size_t oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx) { - options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), QString::fromStdString(fieldCompNames[oIdx]))); + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), + QString::fromStdString(fieldCompNames[oIdx]))); } } + else if (fieldNeedingOptions == &m_rangeMode) + { + options.push_back(caf::PdmOptionItemInfo(RimLegendConfig::RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), + RimLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + options.push_back( + caf::PdmOptionItemInfo(RimLegendConfig::RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), + RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + } return options; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -272,14 +320,19 @@ void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering vectorColorsGroup->add(&m_vectorColor); caf::PdmUiGroup* vectorSizeGroup = uiOrdering.addNewGroup("Vector Size"); - vectorSizeGroup->add(&m_scaleMethod); vectorSizeGroup->add(&m_sizeScale); + vectorSizeGroup->add(&m_scaleMethod); + + if (m_scaleMethod == RESULT) + { + vectorSizeGroup->add(&m_rangeMode); + } uiOrdering.skipRemainingFields(true); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimTensorResults::initAfterRead() { @@ -287,9 +340,11 @@ void RimTensorResults::initAfterRead() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) { if (field == &m_resultFieldNameUiField) { @@ -302,7 +357,7 @@ void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, Q } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimTensorResults::uiFieldName(const QString& fieldName) { @@ -315,7 +370,7 @@ QString RimTensorResults::uiFieldName(const QString& fieldName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimTensorResults::fieldNameFromUi(const QString& uiFieldName) { @@ -326,3 +381,14 @@ QString RimTensorResults::fieldNameFromUi(const QString& uiFieldName) return uiFieldName; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) +{ + if (m_vectorColor() != RESULT_COLORS) + { + uiTreeOrdering.skipRemainingChildren(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index 8091d3ac0e..5785405210 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -23,6 +23,7 @@ #include "cafPdmObject.h" #include "RigFemResultPosEnum.h" +#include "RimLegendConfig.h" #include @@ -69,11 +70,13 @@ class RimTensorResults : public caf::PdmObject TensorColors vectorColors() const; ScaleMethod scaleMethod() const; + void mappingRange(double *min, double* max) const; + static RigFemResultPosEnum resultPositionType(); QString resultFieldName() const; static QString uiFieldName(const QString& fieldName); - caf::PdmChildField legendConfig; + caf::PdmChildField arrowColorLegendConfig; private: std::vector getResultMetaDataForUIFieldSetting(); @@ -83,6 +86,7 @@ class RimTensorResults : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; static QString fieldNameFromUi(const QString& uiFieldName); @@ -103,4 +107,5 @@ class RimTensorResults : public caf::PdmObject caf::PdmField> m_scaleMethod; caf::PdmField m_sizeScale; + caf::PdmField m_rangeMode; }; From 0e8dff00caf47faf2d40d1c8dd1bfc1558773210 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 19 Mar 2018 12:43:41 +0100 Subject: [PATCH 0536/1027] #2611 Mohr Circle: Fix time stepping with several cells --- .../UserInterface/RiuMohrsCirclePlot.cpp | 43 ++++++++++--------- .../UserInterface/RiuMohrsCirclePlot.h | 35 +++++++++------ 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index c9644e43e5..a414befbf5 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -115,7 +115,8 @@ void RiuMohrsCirclePlot::appendSelection(const RiuSelectionItem* selectionItem) const size_t cellIndex = geoMechSelectionItem->m_cellIndex; const cvf::Color3f color = geoMechSelectionItem->m_color; - queryDataAndUpdatePlot(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); + queryData(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); + updatePlot(); m_sourceGeoMechViewOfLastPlot = geoMechView; } @@ -152,19 +153,15 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView) return; } - // Fetch the current global selection and only continue if the selection's view matches the view with time step change - const RiuGeoMechSelectionItem* geoMechSelectionItem = - dynamic_cast(RiuSelectionManager::instance()->selectedItem()); - if (geoMechSelectionItem && geoMechSelectionItem->m_view == geoMechView) - { - const size_t gridIndex = geoMechSelectionItem->m_gridIndex; - const size_t gridCellIndex = geoMechSelectionItem->m_cellIndex; - const cvf::Color3f color = geoMechSelectionItem->m_color; - - deletePlotItems(); + std::vector mohrsCiclesInfosCopy = m_mohrsCiclesInfos; + deletePlotItems(); - queryDataAndUpdatePlot(geoMechView, gridIndex, gridCellIndex, cvf::Color3ub(color)); + for (const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy) + { + queryData(mohrInfo.view, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color); } + + updatePlot(); } //-------------------------------------------------------------------------------------------------- @@ -345,10 +342,10 @@ void RiuMohrsCirclePlot::deleteEnvelopes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, - size_t gridIndex, - size_t elmIndex, - const cvf::Color3ub& color) +void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, + size_t gridIndex, + size_t elmIndex, + const cvf::Color3ub& color) { CVF_ASSERT(geoMechView); m_sourceGeoMechViewOfLastPlot = geoMechView; @@ -388,10 +385,16 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); - MohrsCirclesInfo mohrsCircle(principals, elmIndex, i, j, k, calculateFOS(principals, frictionAngleDeg, cohesion), color); + MohrsCirclesInfo mohrsCircle(principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color); - addMohrsCirclesInfo(mohrsCircle, geoMechView); + addMohrsCirclesInfo(mohrsCircle); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updatePlot() +{ setAxesScaleAndReplot(); // Update axis scale is called one more time because the legend which is added on a later stage may disrupt the canvas scheduleUpdateAxisScale(); @@ -400,11 +403,11 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo, RimGeoMechView* view) +void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo) { m_mohrsCiclesInfos.push_back(mohrsCircleInfo); - addEnvelopeCurve(mohrsCircleInfo.principals, view); + addEnvelopeCurve(mohrsCircleInfo.principals, mohrsCircleInfo.view); addMohrCircles(mohrsCircleInfo); updateTransparentCurvesOnPrincipals(); } diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 7cf366ca0f..01f62c2b16 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -55,26 +55,32 @@ class RiuMohrsCirclePlot : public QwtPlot private: struct MohrsCirclesInfo { - MohrsCirclesInfo(cvf::Vec3f principals, - size_t elmIndex, - size_t i, - size_t j, - size_t k, - double factorOfSafety, - cvf::Color3ub color) + MohrsCirclesInfo(cvf::Vec3f principals, + size_t gridIndex, + size_t elmIndex, + size_t i, + size_t j, + size_t k, + RimGeoMechView* view, + double factorOfSafety, + cvf::Color3ub color) : principals(principals) + , gridIndex(gridIndex) , elmIndex(elmIndex) , i(i) , j(j) , k(k) + , view(view) , factorOfSafety(factorOfSafety) , color(color) {} - cvf::Vec3f principals; - size_t elmIndex; - size_t i, j, k; - double factorOfSafety; - cvf::Color3ub color; + cvf::Vec3f principals; + size_t gridIndex; + size_t elmIndex; + size_t i, j, k; + RimGeoMechView* view; + double factorOfSafety; + cvf::Color3ub color; }; private: @@ -90,9 +96,10 @@ class RiuMohrsCirclePlot : public QwtPlot void addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view); void deleteEnvelopes(); - void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); + void queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); + void updatePlot(); - void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo, RimGeoMechView* view); + void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo); void updateTransparentCurvesOnPrincipals(); From 241bf0364c40a23b798db984d82e3e5a99278939 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Mar 2018 14:41:46 +0100 Subject: [PATCH 0537/1027] #2600 Well CF Visualization: Make sure all connections are visualized --- ...vWellConnectionFactorGeometryGenerator.cpp | 30 +++++++-- ...RivWellConnectionFactorGeometryGenerator.h | 4 +- .../RivWellConnectionFactorPartMgr.cpp | 61 +++++++++++-------- .../RivWellConnectionSourceInfo.cpp | 10 +++ .../RivWellConnectionSourceInfo.h | 1 + .../UserInterface/RiuViewerCommands.cpp | 3 +- 6 files changed, 75 insertions(+), 34 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index e1265fb32b..2d7b557987 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -28,7 +28,7 @@ RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( std::vector& centerColorPairs, float radius) - : m_centerColorPairs(centerColorPairs) + : m_completionVizData(centerColorPairs) , m_radius(radius) , m_trianglesPerConnection(0) { @@ -55,12 +55,12 @@ cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfa cvf::ref vertices = new cvf::Vec3fArray; cvf::ref indices = new cvf::UIntArray; - auto indexCount = m_centerColorPairs.size() * indicesForOneObject.size(); - auto vertexCount = m_centerColorPairs.size() * verticesForOneObject.size(); + auto indexCount = m_completionVizData.size() * indicesForOneObject.size(); + auto vertexCount = m_completionVizData.size() * verticesForOneObject.size(); indices->reserve(indexCount); vertices->reserve(vertexCount); - for (const auto& item : m_centerColorPairs) + for (const auto& item : m_completionVizData) { auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); @@ -88,16 +88,36 @@ cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfa return drawable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellConnectionFactorGeometryGenerator::connectionFactor(cvf::uint triangleIndex) const +{ + size_t connectionIndex = mapFromTriangleToConnectionIndex(triangleIndex); + + return m_completionVizData[connectionIndex].m_connectionFactor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + size_t connectionIndex = mapFromTriangleToConnectionIndex(triangleIndex); + + return m_completionVizData[connectionIndex].m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionFactorGeometryGenerator::mapFromTriangleToConnectionIndex(cvf::uint triangleIndex) const { if (m_trianglesPerConnection == 0) return 0; size_t connectionIndex = triangleIndex / m_trianglesPerConnection; - return m_centerColorPairs[connectionIndex].m_globalCellIndex; + return connectionIndex; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h index d1168268d4..b3b9cf753e 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h @@ -60,9 +60,11 @@ class RivWellConnectionFactorGeometryGenerator : public cvf::Object cvf::ref createSurfaceGeometry(); + double connectionFactor(cvf::uint triangleIndex) const; size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; private: + size_t mapFromTriangleToConnectionIndex(cvf::uint triangleIndex) const; static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); static void createStarGeometry(std::vector* vertices, std::vector* indices, float radius, float thickness); @@ -73,7 +75,7 @@ class RivWellConnectionFactorGeometryGenerator : public cvf::Object float thickness); private: - std::vector m_centerColorPairs; + std::vector m_completionVizData; float m_radius; size_t m_trianglesPerConnection; }; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 5394d0f185..24fd04619c 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -91,8 +91,6 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode } } - std::vector mapFromConnectionIndexToGlobalCellIndex; - std::vector completionVizDataItems; for (const auto& cell : conn) { @@ -100,44 +98,53 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode const RigCell& rigCell = mainGrid->cell(gridIndex); - cvf::Vec3d locationInDomainCoord = rigCell.center(); - cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; + std::vector> locationAndDirection; - if (!wellPathCellIntersections.empty()) + for (const auto& intersectionInfo : wellPathCellIntersections) { - for (const auto& intersectionInfo : wellPathCellIntersections) + if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) { - if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) - { - double startMD = intersectionInfo.startMD; - double endMD = intersectionInfo.endMD; + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; - double middleMD = (startMD + endMD) / 2.0; + double middleMD = (startMD + endMD) / 2.0; - locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + cvf::Vec3d defaultLocationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); - cvf::Vec3d p1; - cvf::Vec3d p2; - m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); + cvf::Vec3d p1; + cvf::Vec3d p2; + m_rimWell->wellPathGeometry()->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); - wellPathDirection = (p2 - p1).getNormalized(); + cvf::Vec3d defaultWellPathDirection = (p2 - p1).getNormalized(); - continue; - } + locationAndDirection.push_back(std::make_pair(defaultLocationInDomainCoord, defaultWellPathDirection)); + } + else if (!locationAndDirection.empty()) + { + continue; } } - cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); - - double transmissibility = HUGE_VAL; - if (!cell.second.empty()) + for (size_t i = 0; i < cell.second.size(); i++) { - transmissibility = cell.second.front().transmissibility(); - } + const RigCompletionData& completionData = cell.second[i]; - completionVizDataItems.push_back( - CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex())); - mapFromConnectionIndexToGlobalCellIndex.push_back(cell.first.globalCellIndex()); + double transmissibility = completionData.transmissibility(); + + cvf::Vec3d locationInDomainCoord = rigCell.center(); + cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; + + if (i < locationAndDirection.size()) + { + locationInDomainCoord = locationAndDirection[i].first; + wellPathDirection = locationAndDirection[i].second; + } + + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); + + completionVizDataItems.push_back( + CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex())); + } } if (!completionVizDataItems.empty()) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp index 5dbc092435..6d534fb247 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp @@ -48,3 +48,13 @@ size_t RivWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint t return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellConnectionSourceInfo::connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0.0; + + return m_geometryGenerator->connectionFactor(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h index c02205143d..b37bf837c0 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h @@ -39,6 +39,7 @@ class RivWellConnectionSourceInfo : public cvf::Object RimWellPath* wellPath() const; size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + double connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const; private: caf::PdmPointer m_wellPath; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 1aa61384cc..2460d3728e 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -633,6 +633,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; size_t globalCellIndex = wellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); + double connectionFactor = wellConnectionSourceInfo->connectionFactorFromTriangleIndex(firstPartTriangleIndex); RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); if (eclipseView) @@ -660,7 +661,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM // For now, only report the fist completion and not the combined completion if more than one // completion contributes into a cell - resultInfoText += QString("Well Connection Factor : %1").arg(completionDataItems[0].transmissibility()); + resultInfoText += QString("Well Connection Factor : %1").arg(connectionFactor); resultInfoText += "

Details :
"; for (const auto& completionData : completionDataItems) From 0dc48db99333b4cf7056190baa9778807858e60f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 19 Mar 2018 21:09:54 +0100 Subject: [PATCH 0538/1027] #2600 Well CF Visualization: Improve result info text content --- .../UserInterface/RiuResultTextBuilder.cpp | 82 ++++++++++++++----- .../UserInterface/RiuResultTextBuilder.h | 2 + .../UserInterface/RiuViewerCommands.cpp | 10 ++- 3 files changed, 72 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index cffb7bc60a..6e228082e6 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -61,6 +61,44 @@ RiuResultTextBuilder::RiuResultTextBuilder(RimEclipseView* reservoirView, size_t m_face = cvf::StructGridInterface::NO_FACE; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuResultTextBuilder::RiuResultTextBuilder(RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex) +{ + CVF_ASSERT(reservoirView); + + m_reservoirView = reservoirView; + + m_gridIndex = 0; + m_cellIndex = 0; + + RimEclipseCase* eclipseCase = nullptr; + reservoirView->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase && eclipseCase->eclipseCaseData()) + { + RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); + RigMainGrid* mainGrid = caseData->mainGrid(); + + const RigCell& cell = caseData->mainGrid()->globalCellArray()[reservoirCellIndex]; + + for (size_t i = 0; i < mainGrid->gridCount(); i++) + { + if (mainGrid->gridByIndex(i) == cell.hostGrid()) + { + m_gridIndex = i; + m_cellIndex = cell.gridLocalCellIndex(); + } + } + } + + m_timeStepIndex = timeStepIndex; + + m_nncIndex = cvf::UNDEFINED_SIZE_T; + m_intersectionPoint = cvf::Vec3d::UNDEFINED; + m_face = cvf::StructGridInterface::NO_FACE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -169,11 +207,14 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) j++; k++; - cvf::StructGridInterface::FaceEnum faceEnum(m_face); + if (m_face != cvf::StructGridInterface::NO_FACE) + { + cvf::StructGridInterface::FaceEnum faceEnum(m_face); - QString faceText = faceEnum.text(); + QString faceText = faceEnum.text(); - text += QString("Face : %1").arg(faceText) + itemSeparator; + text += QString("Face : %1").arg(faceText) + itemSeparator; + } QString gridName = QString::fromStdString(grid->gridName()); text += QString("Grid : %1 [%2]").arg(gridName).arg(m_gridIndex) + itemSeparator; @@ -185,28 +226,31 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) } } - cvf::ref transForm = m_reservoirView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); - - QString formattedText; - if (m_2dIntersectionView) + if (m_intersectionPoint != cvf::Vec3d::UNDEFINED) { - formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); - text += formattedText + itemSeparator; + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); - cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); - if (!t.isZero()) + QString formattedText; + if (m_2dIntersectionView) { - cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); + text += formattedText + itemSeparator; + + cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); text += formattedText; } } - else - { - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); - text += formattedText; - } } } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index b3464529c6..b7a7ec2467 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -42,6 +42,8 @@ class RiuResultTextBuilder { public: RiuResultTextBuilder(RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex); + RiuResultTextBuilder(RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex); + void setFace(cvf::StructGridInterface::FaceType face); void setNncIndex(size_t nncIndex); void setIntersectionPoint(cvf::Vec3d intersectionPoint); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 2460d3728e..f4f5087dfc 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -62,6 +62,7 @@ #include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" +#include "RiuResultTextBuilder.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -657,11 +658,14 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (!completionDataItems.empty()) { QString resultInfoText; + resultInfoText += QString("Well Connection Factor : %1

").arg(connectionFactor); - // For now, only report the fist completion and not the combined completion if more than one - // completion contributes into a cell + { + RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); + + resultInfoText += textBuilder.geometrySelectionText("
"); + } - resultInfoText += QString("Well Connection Factor : %1").arg(connectionFactor); resultInfoText += "

Details :
"; for (const auto& completionData : completionDataItems) From 0b123044a1d452bf88ac927e5eb8d70002c9e9cf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 08:22:38 +0100 Subject: [PATCH 0539/1027] #2619 Fracture Sensitivity Support: Add conductivity scale for Ellipse fractures --- .../Completions/RimEllipseFractureTemplate.cpp | 3 ++- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 7 ++----- .../ProjectDataModel/Completions/RimFractureTemplate.h | 2 -- .../Completions/RimStimPlanFractureTemplate.h | 2 -- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index df7144452e..05b60c8136 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -283,7 +283,8 @@ double RimEllipseFractureTemplate::conductivity() const //Conductivity should be md-ft, but width is in inches cond = m_userDefinedEffectivePermeability * RiaEclipseUnitTools::inchToFeet(m_width); } - return cond; + + return m_conductivityScaleFactor * cond; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index c9e1b9329a..ad4b1a6190 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -324,11 +324,8 @@ void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder group->add(&m_heightScaleFactor); group->add(&m_widthScaleFactor); group->add(&m_dFactorScaleFactor); + group->add(&m_conductivityScaleFactor); - if (supportsConductivityScaling()) - { - group->add(&m_conductivityScaleFactor); - } group->add(&m_scaleApplyButton); } @@ -680,7 +677,7 @@ void RimFractureTemplate::setScaleFactors(double width, double height, double dF m_widthScaleFactor = width; m_heightScaleFactor = height; m_dFactorScaleFactor = dFactor; - m_conductivityScaleFactor = supportsConductivityScaling() ? conductivity : 1.0; + m_conductivityScaleFactor = conductivity; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index d1580b3262..9b43bec690 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -160,8 +160,6 @@ class RimFractureTemplate : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - virtual bool supportsConductivityScaling() const { return false; } - private: void prepareFieldsForUiDisplay(); virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const = 0; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 30cb44b477..1554eb6718 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -99,8 +99,6 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; - virtual bool supportsConductivityScaling() const override { return true; } - private: void setDefaultConductivityResultIfEmpty(); bool setBorderPolygonResultNameToDefault(); From af677451c6e0a5af3ef5021e920818ad9855bc89 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 08:32:23 +0100 Subject: [PATCH 0540/1027] Refactor : Use const reference --- .../Completions/RimEllipseFractureTemplate.cpp | 8 ++++---- .../Completions/RimEllipseFractureTemplate.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 05b60c8136..2a59ca046d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -48,7 +48,7 @@ CAF_PDM_SOURCE_INIT(RimEllipseFractureTemplate, "RimEllipseFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) +RimEllipseFractureTemplate::RimEllipseFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); @@ -195,11 +195,11 @@ void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() std::vector ellipseFracPolygon = fractureBorderPolygon(); std::vector ellipseFracPolygonDouble; - for (auto v : ellipseFracPolygon) ellipseFracPolygonDouble.push_back(static_cast(v)); + for (const auto& v : ellipseFracPolygon) ellipseFracPolygonDouble.push_back(static_cast(v)); std::vector >clippedFracturePolygons = RigCellGeometryTools::intersectPolygons(cellPolygon, ellipseFracPolygonDouble); - if (clippedFracturePolygons.size() > 0) + if (!clippedFracturePolygons.empty()) { - for (auto clippedFracturePolygon : clippedFracturePolygons) + for (const auto& clippedFracturePolygon : clippedFracturePolygons) { double areaCutPolygon = cvf::GeometryTools::polygonAreaNormal3D(clippedFracturePolygon).length(); if (areaCutPolygon < areaTresholdForIncludingCell) cond = 0.0; //Cell is excluded from calculation, cond is set to zero. Must be included for indexing to be correct diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index e50683d101..1c86cbef95 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -46,8 +46,7 @@ class RimEllipseFractureTemplate : public RimFractureTemplate RimEllipseFractureTemplate(); virtual ~RimEllipseFractureTemplate(); - void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* polygonIndices) override; + void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* polygonIndices) override; std::vector fractureBorderPolygon() override; void changeUnits(); @@ -73,7 +72,6 @@ class RimEllipseFractureTemplate : public RimFractureTemplate private: void assignConductivityToCellsInsideEllipse(); - FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; private: From cb6dbb1beef06cd28c55fa201cfbdab068ebb9ee Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 10:42:53 +0100 Subject: [PATCH 0541/1027] #2626 Fracture Adjustments --- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index ad4b1a6190..4e6816a660 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -134,7 +134,7 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitField(&m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_fractureWidthType, "FractureWidthType", "Type", "", "", ""); - CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.1, "Fracture Width (h)"); + CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.01, "Fracture Width (h)"); CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β)"); From 39c8834181fbbde17cd9aed4b0ff456f986ae5c2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 10:48:06 +0100 Subject: [PATCH 0542/1027] #2627 Export CF : kh is reported as zero --- .../Completions/RimFractureTemplate.cpp | 10 ++++++++++ .../ProjectDataModel/Completions/RimFractureTemplate.h | 3 +++ .../Completions/RimStimPlanFractureTemplate.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 4e6816a660..43d4ce936e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -611,6 +611,16 @@ double RimFractureTemplate::dFactor() const //-------------------------------------------------------------------------------------------------- double RimFractureTemplate::kh() const { + // kh = permeability * h + // conductivity = permeability * h + + auto values = widthAndConductivityAtWellPathIntersection(); + if (values.m_conductivity != HUGE_VAL) + { + // If conductivity is found in stim plan file, use this directly + return values.m_conductivity; + } + return effectivePermeability() * fractureWidth(); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 9b43bec690..9fc666b6a5 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -44,6 +44,7 @@ class FractureWidthAndConductivity FractureWidthAndConductivity() : m_width(0.0) , m_permeability(0.0) + , m_conductivity(HUGE_VAL) { } @@ -60,6 +61,8 @@ class FractureWidthAndConductivity // Unit : mD (milliDarcy) double m_permeability; + + double m_conductivity; }; //================================================================================================== diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index f6d27899be..921a088887 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -403,6 +403,7 @@ FractureWidthAndConductivity RimStimPlanFractureTemplate::widthAndConductivityAt const RigFractureCell& wellCell = m_fractureGrid->cellFromIndex(wellCellIndex); double conductivity = wellCell.getConductivtyValue(); + values.m_conductivity = conductivity; std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); From a108726f7ad7198577e76e53055c5dd5a7e916a7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 10:50:16 +0100 Subject: [PATCH 0543/1027] Fix missing include on Linux --- .../ProjectDataModel/Completions/RimFractureTemplate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index 9fc666b6a5..af87b73e14 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -32,6 +32,7 @@ #include "cvfVector3.h" #include +#include class RigFractureGrid; class RimFractureContainment; From 4bb468b07a540ffe6bd39f8db4f0c2b2945a1b7c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 10:58:06 +0100 Subject: [PATCH 0544/1027] #2626 Fracture Adjustments : Shorter UI text --- .../ProjectDataModel/Completions/RimFractureTemplate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index 43d4ce936e..b4e2270ed9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -78,8 +78,8 @@ namespace caf void caf::AppEnum::setUp() { addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); - addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor from Parameters"); - addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED,"UserDefined", "By User Defined D-factor"); + addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor"); + addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED,"UserDefined", "User Defined D-factor"); setDefault(RimFractureTemplate::NON_DARCY_NONE); } @@ -136,7 +136,7 @@ RimFractureTemplate::RimFractureTemplate() CAF_PDM_InitFieldNoDefault(&m_fractureWidthType, "FractureWidthType", "Type", "", "", ""); CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.01, "Fracture Width (h)"); - CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β)"); + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β) [Forch. unit]"); CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); CAF_PDM_InitField_Basic(&m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability"); From e1aa4bb164775d63535af6d45135d767a191f08d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 08:26:28 +0100 Subject: [PATCH 0545/1027] #2591 3D well log curves: Draw normals on fixed interval --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 111 ++++++++++++++---- .../Riv3dWellLogCurveGeomertyGenerator.h | 23 ++-- .../Riv3dWellLogPlanePartMgr.cpp | 2 +- .../ReservoirDataModel/RigWellPath.cpp | 2 +- 4 files changed, 103 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 0c40185c63..888afc2cc6 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -61,30 +61,92 @@ cvf::ref /// //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const Rim3dWellLogCurve* rim3dWellLogCurve) const + const Rim3dWellLogCurve* rim3dWellLogCurve, + double gridIntervalSize) const { - cvf::ref drawable = new cvf::DrawableGeo(); + CVF_ASSERT(gridIntervalSize > 0); + + if (m_wellPathGeometry.isNull()) return nullptr; - if (m_wellPathGeometry.isNull()) return drawable; - std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + if (wellPathPoints.empty()) return nullptr; + + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + const cvf::Vec3d up(0, 0, 1); + + std::vector pointNormals; + std::vector gridPoints; + + double firstMd = m_wellPathGeometry->m_measuredDepths.front(); + double lastMd = m_wellPathGeometry->m_measuredDepths.back(); + if (m_wellPathGeometry->m_measuredDepths.empty()) return nullptr; + + double md = firstMd; + while (md <= lastMd) + { + cvf::Vec3d point = m_wellPathGeometry->interpolatedPointAlongWellPath(md); + gridPoints.push_back(point); + + cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; + cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; + m_wellPathGeometry->twoClosestPoints(point, &p1, &p2); + if (p1.isUndefined() || p2.isUndefined()) continue; + + cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); + + double dotProduct = up * vecAlongPath; + + cvf::Vec3d Ex; + + if (cvf::Math::abs(dotProduct) > 0.7071) + { + Ex = globalDirection; + } + else + { + Ex = vecAlongPath; + } + + cvf::Vec3d Ey = (up ^ Ex).getNormalized(); + cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + cvf::Vec3d normal; + + switch (rim3dWellLogCurve->drawPlane()) + { + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; + } - std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), wellPathPoints); + pointNormals.push_back(normal); + + md += gridIntervalSize; + } std::vector vertices; - vertices.reserve(wellPathPoints.size()); + vertices.reserve(gridPoints.size() * 2); std::vector indices; - indices.reserve(wellPathPoints.size()); + indices.reserve(gridPoints.size() * 2); cvf::uint counter = 0; - for (size_t i = 0; i < pointNormals.size(); i += 2) + for (size_t i = 0; i < pointNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i]))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + pointNormals[i] * 100))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i]))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * 100))); indices.push_back(counter++); indices.push_back(counter++); @@ -93,6 +155,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); + cvf::ref drawable = new cvf::DrawableGeo(); indexedUInt->setIndices(indexArray.p()); drawable->addPrimitiveSet(indexedUInt.p()); @@ -184,9 +247,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector - Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, - const std::vector& wellPathPoints) +std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& wellPathPoints) { std::vector lineSegmentNormals; @@ -196,11 +258,11 @@ std::vector } lineSegmentNormals.reserve(wellPathPoints.size() - 1); - + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); const cvf::Vec3d up(0, 0, 1); - for (size_t i = 0; i < wellPathPoints.size() - 1; i += 2) + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) { cvf::Vec3d vecAlongPath = (wellPathPoints[i + 1] - wellPathPoints[i]).getNormalized(); @@ -224,19 +286,20 @@ std::vector switch (drawPlane) { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; break; case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; + normal = -Ez; + break; + default: break; - default: break; } lineSegmentNormals.push_back(normal); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 1e069704a8..7c1f75a0a6 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -19,8 +19,8 @@ #pragma once #include "cvfBase.h" -#include "cvfObject.h" #include "cvfDrawableGeo.h" +#include "cvfObject.h" #include "cvfVector3.h" #include "cafPdmPointer.h" @@ -31,7 +31,7 @@ namespace caf { - class DisplayCoordTransform; +class DisplayCoordTransform; } class RigWellPath; @@ -39,19 +39,24 @@ class RigWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator(RigWellPath* wellPathGeometry) : m_wellPathGeometry(wellPathGeometry) {}; + Riv3dWellLogCurveGeometryGenerator(RigWellPath* wellPathGeometry) + : m_wellPathGeometry(wellPathGeometry){}; - cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; - cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; + cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, + const Rim3dWellLogCurve* rim3dWellLogCurve) const; + cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double gridIntervalSize) const; private: - void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, + void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform, - std::vector* vertices, - std::vector* indices) const; + std::vector* vertices, + std::vector* indices) const; - static std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + static std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, const std::vector& wellPathPoints); + private: cvf::ref m_wellPathGeometry; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 0b21e275bf..272d7701e2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -75,7 +75,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* } //TODO: Atm, only the grid for the first curve is drawn. - cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0]); + cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0], 200); if (gridDrawable.isNull() || !gridDrawable->boundingBox().isValid()) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index 401160ebac..2eda11ddae 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -169,7 +169,7 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c } } - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if (closestIndex != cvf::UNDEFINED_SIZE_T) { if (closestIndex > 0) { From 60120c70d59a6a789e6998e24602c863be3edfbe Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 09:10:06 +0100 Subject: [PATCH 0546/1027] #2591 3D well log curves: Make point normal function use well path geom --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 121 +++++------------- .../Riv3dWellLogCurveGeomertyGenerator.h | 4 +- 2 files changed, 34 insertions(+), 91 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 888afc2cc6..8da7da46df 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -86,55 +86,12 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { cvf::Vec3d point = m_wellPathGeometry->interpolatedPointAlongWellPath(md); gridPoints.push_back(point); - - cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; - cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - m_wellPathGeometry->twoClosestPoints(point, &p1, &p2); - if (p1.isUndefined() || p2.isUndefined()) continue; - - cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); - - double dotProduct = up * vecAlongPath; - - cvf::Vec3d Ex; - - if (cvf::Math::abs(dotProduct) > 0.7071) - { - Ex = globalDirection; - } - else - { - Ex = vecAlongPath; - } - - cvf::Vec3d Ey = (up ^ Ex).getNormalized(); - cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - - cvf::Vec3d normal; - - switch (rim3dWellLogCurve->drawPlane()) - { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; - } - - pointNormals.push_back(normal); - md += gridIntervalSize; } + pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), gridPoints); + if (pointNormals.size() != gridPoints.size()) return nullptr; + std::vector vertices; vertices.reserve(gridPoints.size() * 2); @@ -195,6 +152,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim } std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); + if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; double minResult = HUGE_VAL; @@ -248,23 +206,24 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim /// //-------------------------------------------------------------------------------------------------- std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, - const std::vector& wellPathPoints) + const std::vector& points) const { - std::vector lineSegmentNormals; - - if (wellPathPoints.empty()) - { - return lineSegmentNormals; - } - - lineSegmentNormals.reserve(wellPathPoints.size() - 1); + std::vector pointNormals; + + if (m_wellPathGeometry.isNull()) return pointNormals; + pointNormals.reserve(points.size()); - const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + const cvf::Vec3d globalDirection = (points.back() - points.front()).getNormalized(); const cvf::Vec3d up(0, 0, 1); - for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + for (const cvf::Vec3d point : points) { - cvf::Vec3d vecAlongPath = (wellPathPoints[i + 1] - wellPathPoints[i]).getNormalized(); + cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; + cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; + m_wellPathGeometry->twoClosestPoints(point, &p1, &p2); + if (p1.isUndefined() || p2.isUndefined()) continue; + + cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); double dotProduct = up * vecAlongPath; @@ -286,40 +245,24 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal switch (drawPlane) { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; } - lineSegmentNormals.push_back(normal); - } - - std::vector pointNormals; - pointNormals.resize(wellPathPoints.size()); - - pointNormals[0] = lineSegmentNormals[0]; - - for (size_t i = 1; i < pointNormals.size() - 1; i += 2) - { - size_t rightSegmentIdx = (i + 1) / 2; - size_t leftSegmentIdx = rightSegmentIdx - 1; - - pointNormals[i] = ((lineSegmentNormals[leftSegmentIdx] + lineSegmentNormals[rightSegmentIdx]) / 2).getNormalized(); - pointNormals[i + 1] = pointNormals[i]; + pointNormals.push_back(normal); } - pointNormals[pointNormals.size() - 1] = lineSegmentNormals.back(); - return pointNormals; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 7c1f75a0a6..6cbca5903e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -54,8 +54,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector* vertices, std::vector* indices) const; - static std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, - const std::vector& wellPathPoints); + std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& points) const; private: cvf::ref m_wellPathGeometry; From 8766ea3057d57c0b6ea5ddf54d6d3c560a913220 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 11:29:46 +0100 Subject: [PATCH 0547/1027] #2591 3D well log curves: Option to turn grid on/off --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 4 +- .../Riv3dWellLogCurveGeomertyGenerator.h | 7 +-- .../Riv3dWellLogPlanePartMgr.cpp | 50 ++++++++++++++----- .../Riv3dWellLogPlanePartMgr.h | 8 +++ .../ModelVisualization/RivWellPathPartMgr.cpp | 14 +++++- .../Rim3dWellLogCurveCollection.cpp | 35 +++++++++++-- .../Completions/Rim3dWellLogCurveCollection.h | 8 ++- .../ProjectDataModel/RimWellPath.cpp | 8 +++ .../ProjectDataModel/RimWellPath.h | 1 + 9 files changed, 111 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 8da7da46df..fd1500a409 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -61,7 +61,7 @@ cvf::ref /// //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const Rim3dWellLogCurve* rim3dWellLogCurve, + const Rim3dWellLogCurve::DrawPlane drawPlane, double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); @@ -89,7 +89,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const md += gridIntervalSize; } - pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), gridPoints); + pointNormals = calculatePointNormals(drawPlane, gridPoints); if (pointNormals.size() != gridPoints.size()) return nullptr; std::vector vertices; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 6cbca5903e..2c1a2a9cd7 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -44,9 +44,10 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; - cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const Rim3dWellLogCurve* rim3dWellLogCurve, - double gridIntervalSize) const; + + cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const Rim3dWellLogCurve::DrawPlane drawPlane, + double gridIntervalSize) const; private: void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 272d7701e2..422609a141 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -61,8 +61,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* continue; } - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); - cvf::ref effect = surfaceGen.generateCachedEffect(); + caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.9f, 0.0f, 0.0f)); + cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = new cvf::Part; part->setDrawable(curveDrawable.p()); @@ -73,24 +73,48 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model->addPart(part.p()); } } +} - //TODO: Atm, only the grid for the first curve is drawn. - cvf::ref gridDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, rim3dWellLogCurves[0], 200); +cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable, cvf::Effect* effect) +{ + cvf::ref part = new cvf::Part; - if (gridDrawable.isNull() || !gridDrawable->boundingBox().isValid()) + if (drawable && drawable->boundingBox().isValid()) { - return; + part->setDrawable(drawable); + part->setEffect(effect); } - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 255, 0, 1), caf::PO_1); - cvf::ref effect = surfaceGen.generateCachedEffect(); + return part; +} - cvf::ref part = new cvf::Part; - part->setDrawable(gridDrawable.p()); - part->setEffect(effect.p()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) +{ + caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + + { + cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize); + + cvf::ref effect = meshEffectGen.generateCachedEffect(); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); - if (part.notNull()) + if (part.notNull()) + { + model->addPart(part.p()); + } + } { - model->addPart(part.p()); + cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize); + + cvf::ref effect = meshEffectGen.generateCachedEffect(); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + } } } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index f2eff10511..918f5c7c9c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -30,6 +30,9 @@ namespace cvf { class ModelBasicList; + class Drawable; + class Effect; + class Part; } namespace caf @@ -49,6 +52,11 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, std::vector rim3dWellLogCurves); + void appendGridToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double gridIntervalSize); +private: + cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); private: cvf::ref m_3dWellLogCurveGeometryGenerator; cvf::ref m_wellPathGeometry; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index cd793af020..935e03602f 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -28,6 +28,7 @@ #include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimFishboneWellPath.h" @@ -457,17 +458,26 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (m_rimWellPath.isNull()) return; - if (wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) - return; + if (wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false) + { return; + } appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); + if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; + if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; + m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); + + if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) + { + m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, 200); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index c1fe487270..63f606b471 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -19,6 +19,7 @@ #include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogCurve.h" +#include "RimProject.h" CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); @@ -29,8 +30,10 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() { CAF_PDM_InitObject("3D Track", ":/WellLogCurve16x16.png", "", ""); - CAF_PDM_InitField(&m_showCurves, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); - m_showCurves.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); + m_showPlot.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); @@ -63,6 +66,22 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::showGrid() const +{ + return m_showGrid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::showPlot() const +{ + return m_showPlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -77,10 +96,20 @@ std::vector Rim3dWellLogCurveCollection::vectorOf3dWellLogCu return curves; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->createDisplayModelAndRedrawAllViews(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() { - return &m_showCurves; + return &m_showPlot; } diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 9e778436d5..4fd57ec4dc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -39,12 +39,18 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); + bool showGrid() const; + bool showPlot() const; + std::vector vectorOf3dWellLogCurves() const; + private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; private: - caf::PdmField m_showCurves; + caf::PdmField m_showPlot; + caf::PdmField m_showGrid; caf::PdmChildArrayField m_3dWellLogCurves; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index e594785262..46fb52a932 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -817,6 +817,14 @@ std::vector RimWellPath::vectorOf3dWellLogCurves() const return m_3dWellLogCurves->vectorOf3dWellLogCurves(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection* RimWellPath::rim3dWellLogCurveCollection() const +{ + return m_3dWellLogCurves(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 4964f99030..09f75682af 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -81,6 +81,7 @@ class RimWellPath : public caf::PdmObject void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve); std::vector vectorOf3dWellLogCurves() const; + Rim3dWellLogCurveCollection* rim3dWellLogCurveCollection() const; virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; From 57a766fd09e26f19bd2a380f7fc776a393bd7b90 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 13:18:24 +0100 Subject: [PATCH 0548/1027] Return if geometry generator is null --- ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 422609a141..f3d1fe2a66 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -93,6 +93,8 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) { + if (m_3dWellLogCurveGeometryGenerator.isNull()) return; + caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); { From 3cf7deea3aa11790f8566d1ac5af05c08d39159e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 13:22:48 +0100 Subject: [PATCH 0549/1027] Hide next fracture ID from UI --- .../Completions/RimFractureTemplateCollection.cpp | 8 ++++---- .../Completions/RimFractureTemplateCollection.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 02ea9fc31d..b79b7cb6c0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -48,7 +48,7 @@ CAF_PDM_SOURCE_INIT(RimFractureTemplateCollection, "FractureDefinitionCollection //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFractureTemplateCollection::RimFractureTemplateCollection(void) +RimFractureTemplateCollection::RimFractureTemplateCollection() { CAF_PDM_InitObject("Fracture Templates", ":/FractureTemplates16x16.png", "", ""); @@ -60,8 +60,7 @@ RimFractureTemplateCollection::RimFractureTemplateCollection(void) m_fractureDefinitions.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_nextValidFractureTemplateId, "NextValidFractureTemplateId", 0, "", "", "", ""); - m_fractureDefinitions.uiCapability()->setUiHidden(true); - + m_nextValidFractureTemplateId.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -77,7 +76,7 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection() //-------------------------------------------------------------------------------------------------- RimFractureTemplate* RimFractureTemplateCollection::fractureTemplate(int id) const { - for (auto templ : m_fractureDefinitions) + for (const auto& templ : m_fractureDefinitions) { if (templ->id() == id) return templ; } @@ -391,5 +390,6 @@ int RimFractureTemplateCollection::nextFractureTemplateId() { int newId = m_nextValidFractureTemplateId; m_nextValidFractureTemplateId = m_nextValidFractureTemplateId + 1; + return newId; } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index f00d598106..2f677287d6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -35,8 +35,8 @@ class RimFractureTemplateCollection : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RimFractureTemplateCollection(void); - virtual ~RimFractureTemplateCollection(void); + RimFractureTemplateCollection(); + virtual ~RimFractureTemplateCollection(); RimFractureTemplate* fractureTemplate(int id) const; std::vector fractureTemplates() const; From 595bf2aa978b3a015912a5831b65fa1e4f443d4f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 13:30:18 +0100 Subject: [PATCH 0550/1027] #2440 Export Completions: Add MD-in and MD-out to comments --- ...ellPathExportCompletionDataFeatureImpl.cpp | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 669e55b133..f92130f7d3 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -354,7 +354,7 @@ std::vector } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicWellPathExportCompletionDataFeatureImpl::computeDynamicCompletionsForWellPath(RimWellPath* wellPath, @@ -719,9 +719,15 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); switch (data.connectionState()) { - case OPEN: formatter.add("OPEN"); break; - case SHUT: formatter.add("SHUT"); break; - case AUTO: formatter.add("AUTO"); break; + case OPEN: + formatter.add("OPEN"); + break; + case SHUT: + formatter.add("SHUT"); + break; + case AUTO: + formatter.add("AUTO"); + break; } if (RigCompletionData::isDefaultValue(data.saturation())) @@ -755,10 +761,18 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse switch (data.direction()) { - case DIR_I: formatter.add("'X'"); break; - case DIR_J: formatter.add("'Y'"); break; - case DIR_K: formatter.add("'Z'"); break; - default: formatter.add("'Z'"); break; + case DIR_I: + formatter.add("'X'"); + break; + case DIR_J: + formatter.add("'Y'"); + break; + case DIR_K: + formatter.add("'Z'"); + break; + default: + formatter.add("'Z'"); + break; } } else @@ -890,9 +904,9 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener completion.setTransAndWPImultBackgroundDataFromPerforation( transmissibility, interval->skinFactor(), interval->diameter(unitSystem), direction); - completion.addMetadata("Perforation", - QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + - QString(" : ") + QString::number(transmissibility)); + completion.addMetadata("Perforation Completion", + QString("MD In: %1 - MD Out: %2").arg(cell.startMD).arg(cell.endMD) + + QString(" Transmissibility: ") + QString::number(transmissibility)); completionData.push_back(completion); } } From cc5f4b2ec6856b02e582e27972d499dd83c92ddb Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 13:51:51 +0100 Subject: [PATCH 0551/1027] #2591 3D well log curves: Add grid line along path --- .../Intersections/RivIntersectionPartMgr.cpp | 2 - .../Riv3dWellLogCurveGeomertyGenerator.cpp | 146 ++++++++++++++++-- .../Riv3dWellLogCurveGeomertyGenerator.h | 15 +- .../Riv3dWellLogPlanePartMgr.cpp | 11 +- .../Riv3dWellLogPlanePartMgr.h | 11 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 5 +- 6 files changed, 160 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index dc5a2430b6..54450f2614 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -800,8 +800,6 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod if (!wellPath) return; - RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); - RimGridView* gridView = nullptr; m_rimCrossSection->firstAncestorOrThisOfTypeAsserted(gridView); double cellSize = gridView->ownerCase()->characteristicCellSize(); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index fd1500a409..961b8bb55f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,6 +18,10 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "RimCase.h" +#include "RimGridView.h" +#include "RimWellPath.h" + #include "RigCurveDataTools.h" #include "RigWellPath.h" @@ -66,9 +70,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { CVF_ASSERT(gridIntervalSize > 0); - if (m_wellPathGeometry.isNull()) return nullptr; + if (!wellPathGeometry()) return nullptr; - std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; if (wellPathPoints.empty()) return nullptr; const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); @@ -77,14 +81,14 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector pointNormals; std::vector gridPoints; - double firstMd = m_wellPathGeometry->m_measuredDepths.front(); - double lastMd = m_wellPathGeometry->m_measuredDepths.back(); - if (m_wellPathGeometry->m_measuredDepths.empty()) return nullptr; + double firstMd = wellPathGeometry()->m_measuredDepths.front(); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; double md = firstMd; while (md <= lastMd) { - cvf::Vec3d point = m_wellPathGeometry->interpolatedPointAlongWellPath(md); + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); gridPoints.push_back(point); md += gridIntervalSize; } @@ -100,15 +104,41 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint counter = 0; + double offsetFromWellPathCenter = wellPathRadius()*1.2; + double gridWidth = 100; + + // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i]))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * 100))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter+gridWidth)))); indices.push_back(counter++); indices.push_back(counter++); } + std::vector wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane); + + // Line along and close to well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); + indices.push_back(counter); + indices.push_back(++counter); + } + indices.pop_back(); + indices.pop_back(); + + // Line along and far away from well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth)))); + indices.push_back(counter); + indices.push_back(++counter); + } + indices.pop_back(); + indices.pop_back(); + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); @@ -131,7 +161,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim std::vector* vertices, std::vector* indices) const { - if (m_wellPathGeometry.isNull()) return; + if (!wellPathGeometry()) return; std::vector resultValues; std::vector mds; @@ -141,14 +171,14 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim CVF_ASSERT(resultValues.size() == mds.size()); cvf::Vec3d globalDirection = - (m_wellPathGeometry->m_wellPathPoints.back() - m_wellPathGeometry->m_wellPathPoints.front()).getNormalized(); + (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); std::vector interpolatedWellPathPoints; interpolatedWellPathPoints.reserve(mds.size()); for (double md : mds) { - interpolatedWellPathPoints.push_back(m_wellPathGeometry->interpolatedPointAlongWellPath(md)); + interpolatedWellPathPoints.push_back(wellPathGeometry()->interpolatedPointAlongWellPath(md)); } std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); @@ -168,8 +198,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim vertices->resize(interpolatedWellPathPoints.size()); double range = maxResult - minResult; - double factor = 60.0 / range; - double offset = 30.0; + double offset = wellPathRadius()*1.2; + double factor = 2 * offset / range; if (minResult < 0) { @@ -210,7 +240,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal { std::vector pointNormals; - if (m_wellPathGeometry.isNull()) return pointNormals; + if (!wellPathGeometry()) return pointNormals; pointNormals.reserve(points.size()); const cvf::Vec3d globalDirection = (points.back() - points.front()).getNormalized(); @@ -220,7 +250,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal { cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - m_wellPathGeometry->twoClosestPoints(point, &p1, &p2); + wellPathGeometry()->twoClosestPoints(point, &p1, &p2); if (p1.isUndefined() || p2.isUndefined()) continue; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -266,3 +296,89 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal return pointNormals; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const +{ + std::vector wellSegmentNormals; + + if (!wellPathGeometry()) return wellSegmentNormals; + + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + const cvf::Vec3d up(0, 0, 1); + + cvf::Vec3d normal; + + for (size_t i = 0; i < wellPathPoints.size()-1; i++) + { + cvf::Vec3d p1 = wellPathPoints[i]; + cvf::Vec3d p2 = wellPathPoints[i + 1]; + + if (p1.isUndefined() || p2.isUndefined()) continue; + + cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); + + double dotProduct = up * vecAlongPath; + + cvf::Vec3d Ex; + + if (cvf::Math::abs(dotProduct) > 0.7071) + { + Ex = globalDirection; + } + else + { + Ex = vecAlongPath; + } + + cvf::Vec3d Ey = (up ^ Ex).getNormalized(); + cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); + + + switch (drawPlane) + { + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; + } + + wellSegmentNormals.push_back(normal); + } + + wellSegmentNormals.push_back(normal); + + return wellSegmentNormals; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogCurveGeometryGenerator::wellPathRadius() const +{ + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + + return m_wellPath->wellPathRadius(cellSize); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const +{ + return m_wellPath->wellPathGeometry(); +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 2c1a2a9cd7..2376f78645 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -35,12 +35,14 @@ class DisplayCoordTransform; } class RigWellPath; +class RimGridView; +class RimWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator(RigWellPath* wellPathGeometry) - : m_wellPathGeometry(wellPathGeometry){}; + Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) + : m_wellPath(wellPath), m_gridView(gridView) {}; cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; @@ -58,6 +60,13 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, const std::vector& points) const; + std::vector calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const; + + double wellPathRadius() const; + + const RigWellPath* wellPathGeometry() const; + private: - cvf::ref m_wellPathGeometry; + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index f3d1fe2a66..a763f5fba4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,7 +18,8 @@ #include "Riv3dWellLogPlanePartMgr.h" -#include "RigWellPath.h" +#include "RimGridView.h" +#include "RimWellPath.h" #include "Riv3dWellLogCurveGeomertyGenerator.h" @@ -33,8 +34,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry) - :m_wellPathGeometry(wellPathGeometry) +Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView) + :m_wellPath(wellPath), m_gridView(gridView) { } @@ -46,9 +47,9 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* std::vector rim3dWellLogCurves) { if (rim3dWellLogCurves.empty()) return; - if (m_wellPathGeometry.isNull()) return; + if (m_wellPath.isNull()) return; - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPathGeometry.p()); + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 918f5c7c9c..350ae98733 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -40,13 +40,14 @@ namespace caf class DisplayCoordTransform; } +class RimGridView; +class RimWellPath; class Riv3dWellLogCurveGeometryGenerator; -class RigWellPath; class Riv3dWellLogPlanePartMgr : public cvf::Object { public: - Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry); + Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView); void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, @@ -59,5 +60,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); private: cvf::ref m_3dWellLogCurveGeometryGenerator; - cvf::ref m_wellPathGeometry; -}; \ No newline at end of file + + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 935e03602f..bcbd6fc382 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -471,7 +471,10 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; - m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); + RimGridView* gridView = dynamic_cast(m_rimView.p()); + if (!gridView) return; + + m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) From a833b5a2d7feac9cecfb0e375144cad5c1459c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Mar 2018 14:23:02 +0100 Subject: [PATCH 0552/1027] libecl. Local quick-fix to prevent summary restart file import under Windows --- ThirdParty/Ert/lib/util/util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 9452a37b79..37150e81cb 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -2896,6 +2896,11 @@ bool util_ftruncate(FILE * stream , long size) { */ bool util_same_file(const char * file1 , const char * file2) { + +#ifdef _WINDOWS + if (file1 == NULL || file2 == NULL) return false; + return stricmp(file1, file2) == 0; +#else stat_type buffer1 , buffer2; int stat1,stat2; @@ -2909,6 +2914,7 @@ bool util_same_file(const char * file1 , const char * file2) { return false; } else return false; // Files which do not exist are no equal! +#endif } From 208d738846705b504cacd00edca970629ddf1cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Mar 2018 14:23:48 +0100 Subject: [PATCH 0553/1027] #2555. Add summary restart file import dialog --- .../Commands/CMakeLists_files.cmake | 3 + .../Commands/RicImportSummaryCaseFeature.cpp | 26 ++- .../Commands/RicImportSummaryCasesFeature.cpp | 23 ++- .../Commands/RicSummaryCaseRestartDialog.cpp | 193 ++++++++++++++++++ .../Commands/RicSummaryCaseRestartDialog.h | 88 ++++++++ .../FileInterface/RifReaderEclipseSummary.cpp | 152 +++++++++++--- .../FileInterface/RifReaderEclipseSummary.h | 23 ++- .../Summary/RimFileSummaryCase.cpp | 23 ++- .../Summary/RimFileSummaryCase.h | 4 +- .../Summary/RimGridSummaryCase.cpp | 2 +- .../Summary/RimSummaryCaseMainCollection.cpp | 4 +- .../Summary/RimSummaryCaseMainCollection.h | 2 +- 12 files changed, 482 insertions(+), 61 deletions(-) create mode 100644 ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp create mode 100644 ApplicationCode/Commands/RicSummaryCaseRestartDialog.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 4ca7189620..3af4643a62 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ) @@ -128,6 +129,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp ) @@ -142,6 +144,7 @@ ${SOURCE_GROUP_SOURCE_FILES} list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ) source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 112b007e0e..fdff26c6af 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -21,6 +21,8 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RicSummaryCaseRestartDialog.h" + #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" @@ -32,8 +34,6 @@ #include "RiuMainPlotWindow.h" #include "RiuMainWindow.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - #include #include @@ -99,19 +99,23 @@ bool RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(const QString& RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName); - sumCaseColl->updateAllRequiredEditors(); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName); - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) + if (result.ok) { - mainPlotWindow->selectAsCurrentItem(sumCase); + RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, result.option == RicSummaryCaseRestartDialog::READ_ALL); + sumCaseColl->updateAllRequiredEditors(); - mainPlotWindow->updateSummaryPlotToolBar(); - } - - app->addToRecentFiles(fileName); + RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow) + { + mainPlotWindow->selectAsCurrentItem(sumCase); + mainPlotWindow->updateSummaryPlotToolBar(); + } + + app->addToRecentFiles(fileName); + } return true; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index bcab65cbf7..61ff285c14 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -22,6 +22,7 @@ #include "RiaPreferences.h" #include "RicFileHierarchyDialog.h" +#include "RicSummaryCaseRestartDialog.h" #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" @@ -108,19 +109,23 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName); - sumCaseColl->updateAllRequiredEditors(); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName); - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) + if (result.ok) { - mainPlotWindow->selectAsCurrentItem(sumCase); + RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, result.option == RicSummaryCaseRestartDialog::READ_ALL); + sumCaseColl->updateAllRequiredEditors(); - mainPlotWindow->updateSummaryPlotToolBar(); - } - - app->addToRecentFiles(fileName); + RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow) + { + mainPlotWindow->selectAsCurrentItem(sumCase); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + app->addToRecentFiles(fileName); + } return true; } diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp new file mode 100644 index 0000000000..ca1b1fe0d4 --- /dev/null +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -0,0 +1,193 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSummaryCaseRestartDialog.h" +#include "ExportCommands/RicSnapshotViewToClipboardFeature.h" +#include "ExportCommands/RicSnapshotViewToFileFeature.h" +#include "ExportCommands/RicSnapshotFilenameGenerator.h" + +#include "RiaApplication.h" + +#include "RifReaderEclipseSummary.h" + +#include "RimEclipseView.h" +#include "Rim3dOverlayInfoConfig.h" +#include "RimTools.h" + +#include "RiuMainPlotWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define DEFAULT_DIALOG_WIDTH 550 +#define DEFAULT_DIALOG_INIT_HEIGHT 150 + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) + : QDialog(parent, RiuTools::defaultDialogFlags()) +{ + // Create widgets + m_readAllRadioButton = new QRadioButton(this); + m_notReadRadionButton = new QRadioButton(this); + m_separateCasesRadionButton = new QRadioButton(this); + + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + // Connect to signals + connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); + connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); + + // Set widget properties + m_readAllRadioButton->setText("Import All Restart Files"); + m_notReadRadionButton->setText("Do Not Import Restart Files"); + m_separateCasesRadionButton->setText("Import Restart Files as Separate Cases"); + + // Define layout + QVBoxLayout* dialogLayout = new QVBoxLayout(); + + QGroupBox* filesGroup = new QGroupBox("Found Restart Files"); + m_filesGridLayout = new QGridLayout(); + filesGroup->setLayout(m_filesGridLayout); + + QGroupBox* optionsGroup = new QGroupBox("Read Options"); + QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsLayout->addWidget(m_readAllRadioButton); + optionsLayout->addWidget(m_notReadRadionButton); + optionsLayout->addWidget(m_separateCasesRadionButton); + optionsGroup->setLayout(optionsLayout); + + dialogLayout->addWidget(filesGroup); + dialogLayout->addWidget(optionsGroup); + dialogLayout->addWidget(m_buttons); + + setLayout(dialogLayout); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, QWidget *parent) +{ + RicSummaryCaseRestartDialog dialog(parent); + + dialog.setWindowTitle("Summary Case Restart Files"); + dialog.m_readAllRadioButton->setChecked(true); + + std::vector files = dialog.getRestartFiles(summaryHeaderFile); + for (const auto& file : files) + { + dialog.appendToFileList(file); + } + + // If no restart files are found, do not show dialog + if (files.empty()) + { + return RicSummaryCaseRestartDialogResult(true, READ_ALL); + } + + dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + dialog.exec(); + + return RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, dialog.selectedOption()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::ReadOptions RicSummaryCaseRestartDialog::selectedOption() const +{ + return + m_notReadRadionButton->isChecked() ? NOT_READ : + m_separateCasesRadionButton->isChecked() ? SEPARATE_CASES : + READ_ALL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::appendToFileList(const RifRestartFileInfo& fileInfo) +{ + QDateTime startDate = QDateTime::fromTime_t(fileInfo.startDate); + QString startDateString = startDate.toString(RimTools::dateFormatString()); + QDateTime endDate = QDateTime::fromTime_t(fileInfo.endDate); + QString endDateString = endDate.toString(RimTools::dateFormatString()); + int rowCount = m_filesGridLayout->rowCount(); + + QLabel* fileNameLabel = new QLabel(); + QLabel* dateLabel = new QLabel(); + fileNameLabel->setText(QFileInfo(fileInfo.fileName).fileName()); + dateLabel->setText(startDateString + " - " + endDateString); + + fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + m_filesGridLayout->addWidget(fileNameLabel, rowCount, 0); + m_filesGridLayout->addWidget(dateLabel, rowCount, 1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryCaseRestartDialog::getRestartFiles(const QString& summaryHeaderFile) +{ + RifReaderEclipseSummary reader; + return reader.getRestartFiles(summaryHeaderFile); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotDialogOkClicked() +{ + accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotDialogCancelClicked() +{ + reject(); +} diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h new file mode 100644 index 0000000000..4411a62f20 --- /dev/null +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dOverlayInfoConfig.h" + +#include "RifReaderEclipseSummary.h" + +#include "cafPdmPointer.h" + +#include + +class QLabel; +class QRadioButton; +class QLineEdit; +class QTextEdit; +class QDialogButtonBox; +class QPushButton; +class QMainWindow; +class QListWidget; +class QGridLayout; +class RicSummaryCaseRestartDialogResult; + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryCaseRestartDialog : public QDialog +{ + Q_OBJECT + +public: + enum ReadOptions { READ_ALL, NOT_READ, SEPARATE_CASES }; + + RicSummaryCaseRestartDialog(QWidget* parent); + ~RicSummaryCaseRestartDialog(); + + static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, QWidget *parent = nullptr); + + ReadOptions selectedOption() const; + +private: + void appendToFileList(const RifRestartFileInfo& fileInfo); + std::vector getRestartFiles(const QString& summaryHeaderFile); + +private slots: + void slotDialogOkClicked(); + void slotDialogCancelClicked(); + +private: + QGridLayout * m_filesGridLayout; + + QRadioButton* m_readAllRadioButton; + QRadioButton* m_notReadRadionButton; + QRadioButton* m_separateCasesRadionButton; + + QDialogButtonBox* m_buttons; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryCaseRestartDialogResult +{ +public: + RicSummaryCaseRestartDialogResult(bool ok, + RicSummaryCaseRestartDialog::ReadOptions option) : + ok(ok), option(option) {} + + bool ok; + RicSummaryCaseRestartDialog::ReadOptions option; +}; \ No newline at end of file diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 414246fc07..4de746e4d0 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -18,8 +18,8 @@ #include "RifReaderEclipseSummary.h" #include "RiaStringEncodingTools.h" - -#include "ert/ecl/ecl_sum.h" +#include "RifReaderEclipseOutput.h" +#include "RifEclipseSummaryTools.h" #include #include @@ -27,8 +27,62 @@ #include #include #include +#include + +#include "ert/ecl/ecl_sum.h" #include "ert/ecl/smspec_node.h" +#include "ert/ecl/ecl_file.h" +#include "ert/ecl/ecl_kw_magic.h" +#include "ert/ecl/ecl_kw.h" + + +std::vector getTimeSteps(ecl_sum_type* ecl_sum) +{ + std::vector timeSteps; + for (int time_index = 0; time_index < ecl_sum_get_data_length(ecl_sum); time_index++) + { + time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, time_index); + timeSteps.push_back(sim_time); + } + return timeSteps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ecl_sum_type* openEclSum(const QString& inHeaderFileName, bool includeRestartFiles) +{ + QString headerFileName; + QStringList dataFileNames; + QString nativeHeaderFileName = QDir::toNativeSeparators(inHeaderFileName); + RifEclipseSummaryTools::findSummaryFiles(nativeHeaderFileName, &headerFileName, &dataFileNames); + + if (headerFileName.isEmpty() || dataFileNames.size() == 0) return nullptr; + + assert(!headerFileName.isEmpty()); + assert(dataFileNames.size() > 0); + + stringlist_type* dataFiles = stringlist_alloc_new(); + for (int i = 0; i < dataFileNames.size(); i++) + { + stringlist_append_copy(dataFiles, RiaStringEncodingTools::toNativeEncoded(dataFileNames[i]).data()); + } + + std::string itemSeparatorInVariableNames = ":"; + ecl_sum_type* ecl_sum = ecl_sum_fread_alloc(RiaStringEncodingTools::toNativeEncoded(headerFileName).data(), dataFiles, itemSeparatorInVariableNames.data(), includeRestartFiles); + + stringlist_free(dataFiles); + + return ecl_sum; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void closeEclSum(ecl_sum_type* ecl_sum) +{ + if(ecl_sum) ecl_sum_free(ecl_sum); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -54,36 +108,17 @@ RifReaderEclipseSummary::~RifReaderEclipseSummary() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseSummary::open(const QString& headerFileName, const QStringList& dataFileNames) +bool RifReaderEclipseSummary::open(const QString& headerFileName, bool includeRestartFiles) { assert(m_ecl_sum == NULL); - if (headerFileName.isEmpty() || dataFileNames.size() == 0) return false; - - assert(!headerFileName.isEmpty()); - assert(dataFileNames.size() > 0); - - stringlist_type* dataFiles = stringlist_alloc_new(); - for (int i = 0; i < dataFileNames.size(); i++) - { - stringlist_append_copy(dataFiles, RiaStringEncodingTools::toNativeEncoded(dataFileNames[i]).data()); - } - - std::string itemSeparatorInVariableNames = ":"; - m_ecl_sum = ecl_sum_fread_alloc(RiaStringEncodingTools::toNativeEncoded(headerFileName).data(), dataFiles, itemSeparatorInVariableNames.data(), false); - - stringlist_free(dataFiles); + m_ecl_sum = openEclSum(headerFileName, includeRestartFiles); if (m_ecl_sum) { m_timeSteps.clear(); m_ecl_SmSpec = ecl_sum_get_smspec(m_ecl_sum); - - for ( int time_index = 0; time_index < timeStepCount(); time_index++ ) - { - time_t sim_time = ecl_sum_iget_sim_time(m_ecl_sum, time_index); - m_timeSteps.push_back(sim_time); - } + m_timeSteps = getTimeSteps(m_ecl_sum); buildMetaData(); @@ -93,6 +128,24 @@ bool RifReaderEclipseSummary::open(const QString& headerFileName, const QStringL return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName) +{ + std::vector restartFiles; + + RifRestartFileInfo currFile; + currFile.fileName = headerFileName; + while(!currFile.fileName.isEmpty()) + { + currFile = getRestartFile(currFile.fileName); + if (!currFile.fileName.isEmpty()) + restartFiles.push_back(currFile); + } + return restartFiles; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -326,6 +379,57 @@ void RifReaderEclipseSummary::buildMetaData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +time_t getStartDate(ecl_file_type * header) +{ + time_t startDate = 0; + ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW, 0); + if (startdat) + { + int * date = ecl_kw_get_int_ptr(startdat); + startDate = ecl_util_make_date(date[STARTDAT_DAY_INDEX], + date[STARTDAT_MONTH_INDEX], + date[STARTDAT_YEAR_INDEX]); + } + return startDate; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& headerFileName) +{ + RifRestartFileInfo restartFile; + + ecl_sum_type* ecl_sum = openEclSum(headerFileName, true); + + const ecl_smspec_type* smspec = ecl_sum ? ecl_sum_get_smspec(ecl_sum) : nullptr; + const char* rstCase = smspec ? ecl_smspec_get_restart_case(smspec) : nullptr; + QString restartCase = rstCase? RiaStringEncodingTools::fromNativeEncoded(rstCase) : ""; + closeEclSum(ecl_sum); + + if (!restartCase.isEmpty()) + { + QString path = QFileInfo(headerFileName).dir().path(); + QString restartBase = QDir(restartCase).dirName(); + + char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0); + restartFile.fileName = QDir::toNativeSeparators(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); + util_safe_free(smspec_header); + + ecl_sum = openEclSum(headerFileName, false); + std::vector timeSteps = getTimeSteps(ecl_sum); + if (timeSteps.size() > 0) + { + restartFile.startDate = timeSteps.front(); + restartFile.endDate = timeSteps.back(); + } + closeEclSum(ecl_sum); + } + return restartFile; +} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index 2162c38314..8ea783417b 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -21,13 +21,29 @@ #include "RifEclipseSummaryAddress.h" #include "RifSummaryReaderInterface.h" +#include + #include #include #include -class QString; class QStringList; + +//================================================================================================== +// +// +//================================================================================================== +class RifRestartFileInfo +{ +public: + RifRestartFileInfo() : startDate(0), endDate(0) {} + + QString fileName; + time_t startDate; + time_t endDate; +}; + //================================================================================================== // // @@ -38,7 +54,9 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface RifReaderEclipseSummary(); ~RifReaderEclipseSummary(); - bool open(const QString& headerFileName, const QStringList& dataFileNames); + bool open(const QString& headerFileName, bool includeRestartFiles); + + std::vector getRestartFiles(const QString& headerFileName); virtual const std::vector& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override; @@ -49,6 +67,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface int timeStepCount() const; int indexFromAddress(const RifEclipseSummaryAddress& resultAddress) const; void buildMetaData(); + RifRestartFileInfo getRestartFile(const QString& headerFileName); private: // Taken from ecl_sum.h diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index d8a34c1512..e948dfc77f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -39,9 +39,17 @@ CAF_PDM_SOURCE_INIT(RimFileSummaryCase,"FileSummaryCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFileSummaryCase::RimFileSummaryCase() +RimFileSummaryCase::RimFileSummaryCase() : m_includeRestartFiles(false) { - + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileSummaryCase::RimFileSummaryCase(bool includeRestartFiles) +{ + m_includeRestartFiles = includeRestartFiles; } //-------------------------------------------------------------------------------------------------- @@ -83,22 +91,17 @@ void RimFileSummaryCase::updateFilePathsFromProjectPath(const QString & newProje //-------------------------------------------------------------------------------------------------- void RimFileSummaryCase::createSummaryReaderInterface() { - m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename()); + m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderEclipseSummary* RimFileSummaryCase::findRelatedFilesAndCreateReader(const QString& headerFileName) +RifReaderEclipseSummary* RimFileSummaryCase::findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles) { - QString headerFileNameStd; - QStringList dataFileNames; - QString nativeSumHeadFileName = QDir::toNativeSeparators(headerFileName); - RifEclipseSummaryTools::findSummaryFiles(nativeSumHeadFileName, &headerFileNameStd, &dataFileNames); - RifReaderEclipseSummary* summaryFileReader = new RifReaderEclipseSummary; - if (!summaryFileReader->open(headerFileNameStd, dataFileNames)) + if (!summaryFileReader->open(headerFileName, includeRestartFiles)) { RiaLogging::warning(QString("Failed to open summary file %1").arg(headerFileName)); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h index 0b0be22fc7..e241ba3d20 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h @@ -34,6 +34,7 @@ class RimFileSummaryCase: public RimSummaryCase CAF_PDM_HEADER_INIT; public: RimFileSummaryCase(); + RimFileSummaryCase(bool includeRestartFiles); virtual ~RimFileSummaryCase(); virtual QString summaryHeaderFilename() const override; @@ -43,8 +44,9 @@ class RimFileSummaryCase: public RimSummaryCase virtual void createSummaryReaderInterface() override; virtual RifSummaryReaderInterface* summaryReader() override; - static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName); + static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles); private: cvf::ref m_summaryFileReader; + bool m_includeRestartFiles; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index c43478b41e..d108806032 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -175,7 +175,7 @@ void RimGridSummaryCase::updateFilePathsFromProjectPath(const QString & newProje //-------------------------------------------------------------------------------------------------- void RimGridSummaryCase::createSummaryReaderInterface() { - m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename()); + m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), true /* read restart files */); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index e75b1d9797..6f4b825e8c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -282,9 +282,9 @@ RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromFileName(const QString& fileName) +RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromFileName(const QString& fileName, bool includeRestartFiles) { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(includeRestartFiles); this->m_cases.push_back(newSumCase); newSumCase->setSummaryHeaderFileName(fileName); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index d72c0720d8..dce2794ba2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -45,7 +45,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void createSummaryCasesFromRelevantEclipseResultCases(); RimSummaryCase* createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase); - RimSummaryCase* createAndAddSummaryCaseFromFileName(const QString& fileName); + RimSummaryCase* createAndAddSummaryCaseFromFileName(const QString& fileName, bool includeRestartFiles); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; From f98dc2fe5e4cb5714265e30c31f23b7d32df20a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 15 Mar 2018 15:10:02 +0100 Subject: [PATCH 0554/1027] #2555 Add current summary file to dialog --- .../Commands/RicSummaryCaseRestartDialog.cpp | 10 +++++++++- ApplicationCode/Commands/RicSummaryCaseRestartDialog.h | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index ca1b1fe0d4..7770f8ff28 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -64,6 +64,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) : QDialog(parent, RiuTools::defaultDialogFlags()) { // Create widgets + m_currentFile = new QLabel(); m_readAllRadioButton = new QRadioButton(this); m_notReadRadionButton = new QRadioButton(this); m_separateCasesRadionButton = new QRadioButton(this); @@ -82,6 +83,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); + QGroupBox* currentFileGroup = new QGroupBox("Current Summary File"); + QVBoxLayout* currentFileLayout = new QVBoxLayout(); + currentFileLayout->addWidget(m_currentFile); + currentFileGroup->setLayout(currentFileLayout); + QGroupBox* filesGroup = new QGroupBox("Found Restart Files"); m_filesGridLayout = new QGridLayout(); filesGroup->setLayout(m_filesGridLayout); @@ -93,6 +99,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) optionsLayout->addWidget(m_separateCasesRadionButton); optionsGroup->setLayout(optionsLayout); + dialogLayout->addWidget(currentFileGroup); dialogLayout->addWidget(filesGroup); dialogLayout->addWidget(optionsGroup); dialogLayout->addWidget(m_buttons); @@ -116,7 +123,8 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.setWindowTitle("Summary Case Restart Files"); dialog.m_readAllRadioButton->setChecked(true); - + dialog.m_currentFile->setText(summaryHeaderFile); + std::vector files = dialog.getRestartFiles(summaryHeaderFile); for (const auto& file : files) { diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 4411a62f20..821129d1a3 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -63,7 +63,9 @@ private slots: void slotDialogCancelClicked(); private: - QGridLayout * m_filesGridLayout; + QLabel* m_currentFile; + + QGridLayout* m_filesGridLayout; QRadioButton* m_readAllRadioButton; QRadioButton* m_notReadRadionButton; From 8889bdf6d4ac6fbcafe33fc0416abdbe607064f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 16 Mar 2018 09:02:28 +0100 Subject: [PATCH 0555/1027] #2555 Add applyToAll checkbox --- .../Commands/RicImportSummaryCaseFeature.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 11 ++++++-- .../Commands/RicImportSummaryCasesFeature.h | 4 ++- .../Commands/RicSummaryCaseRestartDialog.cpp | 28 +++++++++++++++---- .../Commands/RicSummaryCaseRestartDialog.h | 19 ++++++++++--- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index fdff26c6af..8656bac68b 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -99,7 +99,7 @@ bool RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(const QString& RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName, false); if (result.ok) { diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 61ff285c14..557d669827 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -76,9 +76,10 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return; + RicSummaryCaseRestartDialogResult savedDialogResult; for (auto f : fileNames) { - RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(f); + RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(f, &savedDialogResult); } std::vector cases; @@ -102,14 +103,16 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName) +bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName, RicSummaryCaseRestartDialogResult *savedDialogResult) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName); + RicSummaryCaseRestartDialogResult result; + if (savedDialogResult->applyToAll) result = *savedDialogResult; + else result = RicSummaryCaseRestartDialog::openDialog(fileName, true); if (result.ok) { @@ -125,6 +128,8 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString } app->addToRecentFiles(fileName); + + *savedDialogResult = result; } return true; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 3f40088646..0f14501d59 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -22,6 +22,8 @@ #include +class RicSummaryCaseRestartDialogResult; + //================================================================================================== /// //================================================================================================== @@ -32,7 +34,7 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature public: RicImportSummaryCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") { } - static bool createAndAddSummaryCaseFromFile(const QString& fileName); + static bool createAndAddSummaryCaseFromFile(const QString& fileName, RicSummaryCaseRestartDialogResult *lastResult); protected: // Overrides diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 7770f8ff28..db8c5f2abe 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_readAllRadioButton = new QRadioButton(this); m_notReadRadionButton = new QRadioButton(this); m_separateCasesRadionButton = new QRadioButton(this); + m_applyToAllCheckBox = new QCheckBox(this); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -79,7 +81,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_readAllRadioButton->setText("Import All Restart Files"); m_notReadRadionButton->setText("Do Not Import Restart Files"); m_separateCasesRadionButton->setText("Import Restart Files as Separate Cases"); - + m_applyToAllCheckBox->setText("Apply to All Files"); + // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); @@ -99,10 +102,14 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) optionsLayout->addWidget(m_separateCasesRadionButton); optionsGroup->setLayout(optionsLayout); + QHBoxLayout* buttonsLayout = new QHBoxLayout(); + buttonsLayout->addWidget(m_applyToAllCheckBox); + buttonsLayout->addWidget(m_buttons); + dialogLayout->addWidget(currentFileGroup); dialogLayout->addWidget(filesGroup); dialogLayout->addWidget(optionsGroup); - dialogLayout->addWidget(m_buttons); + dialogLayout->addLayout(buttonsLayout); setLayout(dialogLayout); } @@ -117,13 +124,16 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, QWidget *parent) +RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, + bool showApplyToAllWidget, + QWidget *parent) { RicSummaryCaseRestartDialog dialog(parent); dialog.setWindowTitle("Summary Case Restart Files"); dialog.m_readAllRadioButton->setChecked(true); dialog.m_currentFile->setText(summaryHeaderFile); + dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); std::vector files = dialog.getRestartFiles(summaryHeaderFile); for (const auto& file : files) @@ -134,13 +144,13 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If no restart files are found, do not show dialog if (files.empty()) { - return RicSummaryCaseRestartDialogResult(true, READ_ALL); + return RicSummaryCaseRestartDialogResult(true, READ_ALL, false); } dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); - return RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, dialog.selectedOption()); + return RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, dialog.selectedOption(), dialog.applyToAllSelected()); } //-------------------------------------------------------------------------------------------------- @@ -154,6 +164,14 @@ RicSummaryCaseRestartDialog::ReadOptions RicSummaryCaseRestartDialog::selectedOp READ_ALL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSummaryCaseRestartDialog::applyToAllSelected() const +{ + return m_applyToAllCheckBox->isChecked(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 821129d1a3..25fef906a3 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -35,6 +35,7 @@ class QPushButton; class QMainWindow; class QListWidget; class QGridLayout; +class QCheckBox; class RicSummaryCaseRestartDialogResult; //================================================================================================== @@ -50,9 +51,12 @@ class RicSummaryCaseRestartDialog : public QDialog RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); - static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, QWidget *parent = nullptr); + static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, + bool showApplyToAllWidget, + QWidget *parent = nullptr); ReadOptions selectedOption() const; + bool applyToAllSelected() const; private: void appendToFileList(const RifRestartFileInfo& fileInfo); @@ -71,6 +75,7 @@ private slots: QRadioButton* m_notReadRadionButton; QRadioButton* m_separateCasesRadionButton; + QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; }; @@ -81,10 +86,16 @@ private slots: class RicSummaryCaseRestartDialogResult { public: - RicSummaryCaseRestartDialogResult(bool ok, - RicSummaryCaseRestartDialog::ReadOptions option) : - ok(ok), option(option) {} + RicSummaryCaseRestartDialogResult() : + ok(false), option(RicSummaryCaseRestartDialog::READ_ALL), applyToAll(false) {} + + RicSummaryCaseRestartDialogResult(bool _ok, + RicSummaryCaseRestartDialog::ReadOptions _option, + bool _applyToAll) : + ok(_ok), option(_option), applyToAll(_applyToAll) { + } bool ok; RicSummaryCaseRestartDialog::ReadOptions option; + bool applyToAll; }; \ No newline at end of file From 2a84cb6ddfc84e5b2b38c0d357da3d9aebaff83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 19 Mar 2018 11:02:22 +0100 Subject: [PATCH 0556/1027] #2555 Handle import to separate cases --- .../Application/RiaApplication.cpp | 4 +- .../Commands/RicImportSummaryCaseFeature.cpp | 43 +------- .../Commands/RicImportSummaryCaseFeature.h | 3 - .../Commands/RicImportSummaryCasesFeature.cpp | 97 ++++++++++++++----- .../Commands/RicImportSummaryCasesFeature.h | 26 ++++- .../Commands/RicSummaryCaseRestartDialog.cpp | 70 ++++++++++--- .../Commands/RicSummaryCaseRestartDialog.h | 12 ++- .../Summary/RimFileSummaryCase.cpp | 21 ++-- .../Summary/RimFileSummaryCase.h | 7 +- .../Summary/RimSummaryCaseMainCollection.cpp | 3 +- 10 files changed, 183 insertions(+), 103 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 574804817c..80cbf84a89 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -31,7 +31,7 @@ #include "RiaViewRedrawScheduler.h" #include "RicImportInputEclipseCaseFeature.h" -#include "RicImportSummaryCaseFeature.h" +#include "RicImportSummaryCasesFeature.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" #include "Rim2dIntersectionViewCollection.h" @@ -1872,7 +1872,7 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".smspec", Qt::CaseInsensitive)) { - loadingSucceded = RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(fileName); + loadingSucceded = RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileWithDialog(fileName); if (loadingSucceded) { getOrCreateAndShowMainPlotWindow(); diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 8656bac68b..d3648a5539 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" -#include "RicSummaryCaseRestartDialog.h" +#include "RicImportSummaryCasesFeature.h" #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" @@ -61,15 +61,11 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) // Remember the path to next time app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath()); - RimProject* proj = app->project(); + if (fileNames.isEmpty()) return; - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return; + std::vector fileInfos = RicImportSummaryCasesFeature::getFilesToImportWithDialog(fileNames, true); - for (auto f : fileNames) - { - RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(f); - } + RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(fileInfos); std::vector cases; app->project()->allCases(cases); @@ -88,34 +84,3 @@ void RicImportSummaryCaseFeature::setupActionLook(QAction* actionToSetup) actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); actionToSetup->setText("Import Summary Case"); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(const QString& fileName) -{ - RiaApplication* app = RiaApplication::instance(); - RimProject* proj = app->project(); - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return false; - - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(fileName, false); - - if (result.ok) - { - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, result.option == RicSummaryCaseRestartDialog::READ_ALL); - sumCaseColl->updateAllRequiredEditors(); - - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(sumCase); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - - app->addToRecentFiles(fileName); - } - return true; -} - diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.h b/ApplicationCode/Commands/RicImportSummaryCaseFeature.h index c07c393a3b..22171cb8b9 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.h @@ -29,9 +29,6 @@ class RicImportSummaryCaseFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -public: - static bool createAndAddSummaryCaseFromFile(const QString& fileName); - protected: // Overrides virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 557d669827..61cb441414 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -72,15 +72,9 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) QStringList fileNames = result.files; if (fileNames.isEmpty()) return; - RimProject* proj = app->project(); - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return; + std::vector fileInfos = getFilesToImportWithDialog(fileNames, true); - RicSummaryCaseRestartDialogResult savedDialogResult; - for (auto f : fileNames) - { - RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(f, &savedDialogResult); - } + createAndAddSummaryCaseFromFileInfo(fileInfos); std::vector cases; app->project()->allCases(cases); @@ -103,33 +97,84 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName, RicSummaryCaseRestartDialogResult *savedDialogResult) +std::vector RicImportSummaryCasesFeature::getFilesToImportWithDialog(const QStringList& initialFiles, + bool enableApplyToAllField) +{ + std::set filesToImport; + RicSummaryCaseRestartDialogResult lastResult; + + for (const QString& file : initialFiles) + { + RicSummaryCaseRestartDialogResult result; + if (lastResult.applyToAll) result = lastResult; + else result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField); + + if (result.ok) + { + if(result.files.size() > 0) RiaApplication::instance()->addToRecentFiles(result.files.front()); + + for (const QString& file : result.files) + { + RicSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); + if (filesToImport.count(fi) == 0) + { + filesToImport.insert(fi); + } + } + } + lastResult = result; + } + return std::vector(filesToImport.begin(), filesToImport.end()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(const std::vector& fileInfos) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + if (!sumCaseColl) return false; + + for (const auto& fi : fileInfos) + { + createAndAddSummaryCaseFromFile(fi.fileName, fi.includeRestartFiles); + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileWithDialog(const QString& fileName) +{ + QStringList fileNames({ fileName }); + std::vector fileInfos = getFilesToImportWithDialog(fileNames, false); + bool res = createAndAddSummaryCaseFromFileInfo(fileInfos); + RiaApplication::instance()->addToRecentFiles(fileName); + return res; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName, bool includeRestartFiles) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RicSummaryCaseRestartDialogResult result; - if (savedDialogResult->applyToAll) result = *savedDialogResult; - else result = RicSummaryCaseRestartDialog::openDialog(fileName, true); + RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, includeRestartFiles); + sumCaseColl->updateAllRequiredEditors(); - if (result.ok) + RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow) { - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, result.option == RicSummaryCaseRestartDialog::READ_ALL); - sumCaseColl->updateAllRequiredEditors(); - - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(sumCase); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - - app->addToRecentFiles(fileName); + mainPlotWindow->selectAsCurrentItem(sumCase); - *savedDialogResult = result; + mainPlotWindow->updateSummaryPlotToolBar(); } return true; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 0f14501d59..ec11bf6fb6 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -24,6 +24,23 @@ class RicSummaryCaseRestartDialogResult; + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryCaseFileInfo +{ +public: + RicSummaryCaseFileInfo(const QString _fileName, bool _includeRestartFiles) : + fileName(_fileName), includeRestartFiles(_includeRestartFiles) {} + + QString fileName; + bool includeRestartFiles; + + bool operator<(const RicSummaryCaseFileInfo& other) const { return fileName < other.fileName; } + bool operator==(const RicSummaryCaseFileInfo& other) const { return fileName == other.fileName; } +}; + //================================================================================================== /// //================================================================================================== @@ -34,7 +51,14 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature public: RicImportSummaryCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") { } - static bool createAndAddSummaryCaseFromFile(const QString& fileName, RicSummaryCaseRestartDialogResult *lastResult); + static std::vector getFilesToImportWithDialog(const QStringList& initialFiles, + bool enableApplyToAllField); + + static bool createAndAddSummaryCaseFromFileInfo(const std::vector& fileInfos); + static bool createAndAddSummaryCaseFromFileWithDialog(const QString& fileName); + +private: + static bool createAndAddSummaryCaseFromFile(const QString& fileName, bool includeRestartFiles); protected: // Overrides diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index db8c5f2abe..99e009b920 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -57,6 +57,15 @@ #define DEFAULT_DIALOG_WIDTH 550 #define DEFAULT_DIALOG_INIT_HEIGHT 150 +//-------------------------------------------------------------------------------------------------- +/// Internal variables +//-------------------------------------------------------------------------------------------------- +static QString SEPARATOR = "/"; + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +static QString toInternalSeparator(const QString& path); //-------------------------------------------------------------------------------------------------- /// @@ -130,27 +139,40 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const { RicSummaryCaseRestartDialog dialog(parent); - dialog.setWindowTitle("Summary Case Restart Files"); - dialog.m_readAllRadioButton->setChecked(true); - dialog.m_currentFile->setText(summaryHeaderFile); - dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); - - std::vector files = dialog.getRestartFiles(summaryHeaderFile); - for (const auto& file : files) + std::vector fileInfos = dialog.getRestartFiles(summaryHeaderFile); + for (const auto& fileInfo : fileInfos) { - dialog.appendToFileList(file); + dialog.appendToFileList(fileInfo); } // If no restart files are found, do not show dialog - if (files.empty()) + if (fileInfos.empty()) { - return RicSummaryCaseRestartDialogResult(true, READ_ALL, false); + return RicSummaryCaseRestartDialogResult(true, READ_SINGLE, QStringList({ summaryHeaderFile }), false); } + dialog.setWindowTitle("Summary Case Restart Files"); + dialog.m_readAllRadioButton->setChecked(true); + dialog.m_currentFile->setText(summaryHeaderFile); + dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); - return RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, dialog.selectedOption(), dialog.applyToAllSelected()); + + if (dialog.result() != QDialog::Accepted) + { + return RicSummaryCaseRestartDialogResult(false, READ_SINGLE, QStringList(), false); + } + + QStringList files({ toInternalSeparator(summaryHeaderFile) }); + if (dialog.selectedOption() == SEPARATE_CASES) + { + for (const auto& fileInfo : fileInfos) + { + files.push_back(toInternalSeparator(fileInfo.fileName)); + } + } + return RicSummaryCaseRestartDialogResult(true, dialog.selectedOption(), files, dialog.applyToAllSelected()); } //-------------------------------------------------------------------------------------------------- @@ -159,9 +181,9 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const RicSummaryCaseRestartDialog::ReadOptions RicSummaryCaseRestartDialog::selectedOption() const { return - m_notReadRadionButton->isChecked() ? NOT_READ : + m_readAllRadioButton->isChecked() ? READ_ALL : m_separateCasesRadionButton->isChecked() ? SEPARATE_CASES : - READ_ALL; + READ_SINGLE; } //-------------------------------------------------------------------------------------------------- @@ -217,3 +239,25 @@ void RicSummaryCaseRestartDialog::slotDialogCancelClicked() { reject(); } + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString toInternalSeparator(const QString& path) +{ + QString currNativeSep = QDir::separator(); + + if (currNativeSep == "/") + { + // On Linux like system -> Do not convert separators + return path; + } + + // On other systems (i.e. Windows) -> Convert to internal separator (/) + QString output = path; + return output.replace(QString("\\"), SEPARATOR); +} diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 25fef906a3..b0c5bddb94 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -46,7 +46,7 @@ class RicSummaryCaseRestartDialog : public QDialog Q_OBJECT public: - enum ReadOptions { READ_ALL, NOT_READ, SEPARATE_CASES }; + enum ReadOptions { READ_SINGLE, READ_ALL, SEPARATE_CASES }; RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); @@ -91,11 +91,13 @@ class RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialogResult(bool _ok, RicSummaryCaseRestartDialog::ReadOptions _option, + QStringList _files, bool _applyToAll) : - ok(_ok), option(_option), applyToAll(_applyToAll) { + ok(_ok), option(_option), files(_files), applyToAll(_applyToAll) { } - bool ok; - RicSummaryCaseRestartDialog::ReadOptions option; - bool applyToAll; + bool ok; + RicSummaryCaseRestartDialog::ReadOptions option; + QStringList files; + bool applyToAll; }; \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index e948dfc77f..6d37600879 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -39,17 +39,10 @@ CAF_PDM_SOURCE_INIT(RimFileSummaryCase,"FileSummaryCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFileSummaryCase::RimFileSummaryCase() : m_includeRestartFiles(false) +RimFileSummaryCase::RimFileSummaryCase() { - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimFileSummaryCase::RimFileSummaryCase(bool includeRestartFiles) -{ - m_includeRestartFiles = includeRestartFiles; + CAF_PDM_InitField(&m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", ""); + m_includeRestartFiles.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -119,3 +112,11 @@ RifSummaryReaderInterface* RimFileSummaryCase::summaryReader() { return m_summaryFileReader.p(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFileSummaryCase::setIncludeRestartFiles(bool includeRestartFiles) +{ + m_includeRestartFiles = includeRestartFiles; +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h index e241ba3d20..8ba0c4680e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h @@ -20,7 +20,7 @@ #include "RimSummaryCase.h" #include "cvfObject.h" - +#include "cafPdmField.h" class RifReaderEclipseSummary; @@ -34,7 +34,6 @@ class RimFileSummaryCase: public RimSummaryCase CAF_PDM_HEADER_INIT; public: RimFileSummaryCase(); - RimFileSummaryCase(bool includeRestartFiles); virtual ~RimFileSummaryCase(); virtual QString summaryHeaderFilename() const override; @@ -44,9 +43,11 @@ class RimFileSummaryCase: public RimSummaryCase virtual void createSummaryReaderInterface() override; virtual RifSummaryReaderInterface* summaryReader() override; + void setIncludeRestartFiles(bool includeRestartFiles); + static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles); private: cvf::ref m_summaryFileReader; - bool m_includeRestartFiles; + caf::PdmField m_includeRestartFiles; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 6f4b825e8c..f600e83f38 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -284,9 +284,10 @@ RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipse //-------------------------------------------------------------------------------------------------- RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromFileName(const QString& fileName, bool includeRestartFiles) { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(includeRestartFiles); + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); this->m_cases.push_back(newSumCase); + newSumCase->setIncludeRestartFiles(includeRestartFiles); newSumCase->setSummaryHeaderFileName(fileName); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); From 2f1139552590f926f4a166302abf09d4b175a152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 19 Mar 2018 13:35:56 +0100 Subject: [PATCH 0557/1027] #2555 Add preferences for summary restart file import --- .../Application/RiaPreferences.cpp | 18 ++++ ApplicationCode/Application/RiaPreferences.h | 5 ++ .../Application/Tools/CMakeLists_files.cmake | 2 + .../Application/Tools/RiaFilePathTools.cpp | 88 +++++++++++++++++++ .../Application/Tools/RiaFilePathTools.h | 39 ++++++++ .../Commands/RicFileHierarchyDialog.cpp | 76 ++-------------- .../Commands/RicImportSummaryCaseFeature.cpp | 11 ++- .../Commands/RicImportSummaryCasesFeature.cpp | 62 ++++++++++++- .../Commands/RicImportSummaryCasesFeature.h | 5 ++ .../Commands/RicSummaryCaseRestartDialog.cpp | 31 +------ .../FileInterface/RifReaderEclipseSummary.cpp | 3 +- 11 files changed, 236 insertions(+), 104 deletions(-) create mode 100644 ApplicationCode/Application/Tools/RiaFilePathTools.cpp create mode 100644 ApplicationCode/Application/Tools/RiaFilePathTools.h diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 623ef531b3..a77be746ed 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -27,6 +27,18 @@ #include "cafPdmUiFieldHandle.h" #include "cafPdmUiFilePathEditor.h" + +template<> +void RiaPreferences::SummaryRestartFilesImportModeType::setUp() +{ + addItem(RiaPreferences::ASK_USER, "ASK_USER", "Ask user"); + addItem(RiaPreferences::IMPORT, "IMPORT", "Always import"); + addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Never import"); + addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Import as separate summary cases"); + setDefault(RiaPreferences::ASK_USER); +} + + CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences"); //-------------------------------------------------------------------------------------------------- /// @@ -88,6 +100,9 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL", "", "", ""); loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&summaryRestartFilesImportMode, "summaryRestartFilesImportMode", "Import summary restart files", "", "", ""); + //loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; @@ -175,6 +190,9 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& newCaseBehaviourGroup->add(&loadAndShowSoil); m_readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup); + + caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Summary Restart Files"); + restartBehaviourGroup->add(&summaryRestartFilesImportMode); } else if (uiConfigName == m_tabNames[2]) { diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index dbc02b5953..03dca2b6d8 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -37,6 +37,9 @@ class RiaPreferences : public caf::PdmObject CAF_PDM_HEADER_INIT; public: + enum SummaryRestartFilesImportMode { ASK_USER, IMPORT, NOT_IMPORT, SEPARATE_CASES }; + typedef caf::AppEnum SummaryRestartFilesImportModeType; + RiaPreferences(void); virtual ~RiaPreferences(void); @@ -77,6 +80,8 @@ class RiaPreferences : public caf::PdmObject caf::PdmField autocomputeDepthRelatedProperties; caf::PdmField loadAndShowSoil; + caf::PdmField summaryRestartFilesImportMode; + protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index 9e533fd960..06095bc398 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -23,6 +23,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.h ${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaFilePathTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -49,6 +50,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaFilePathTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp new file mode 100644 index 0000000000..d9f3604ab0 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaFilePathTools.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// Internal variables +//-------------------------------------------------------------------------------------------------- +static QString SEPARATOR = "/"; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::toInternalSeparator(const QString& path) +{ + QString currNativeSep = QDir::separator(); + + if (currNativeSep == "/") + { + // On Linux like system -> Do not convert separators + return path; + } + + // On other systems (i.e. Windows) -> Convert to internal separator (/) + QString output = path; + return output.replace(QString("\\"), SEPARATOR); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString& RiaFilePathTools::appendSeparatorIfNo(QString& path) +{ + if (!path.endsWith(SEPARATOR)) + { + path.append(SEPARATOR); + } + return path; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::relativePath(const QString& rootDir, const QString& dir) +{ + if (dir.startsWith(rootDir)) + { + QString relPath = dir; + relPath.remove(0, rootDir.size()); + + if (relPath.startsWith(SEPARATOR)) relPath.remove(0, 1); + return appendSeparatorIfNo(relPath); + } + else + { + return dir; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaFilePathTools::equalPaths(const QString& path1, const QString& path2) +{ + QString p1 = path1; + QString p2 = path2; + appendSeparatorIfNo(p1); + appendSeparatorIfNo(p2); + return p1 == p2; +} diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.h b/ApplicationCode/Application/Tools/RiaFilePathTools.h new file mode 100644 index 0000000000..f5f10838cb --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +//================================================================================================== +// +// +// +//================================================================================================== +class RiaFilePathTools +{ +public: + static QString toInternalSeparator(const QString& path); + static QString& appendSeparatorIfNo(QString& path); + static QString relativePath(const QString& rootDir, const QString& dir); + static bool equalPaths(const QString& path1, const QString& path2); +}; diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index c9297bd97a..98977a879b 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -22,6 +22,7 @@ #include "ExportCommands/RicSnapshotFilenameGenerator.h" #include "RiaApplication.h" +#include "RiaFilePathTools.h" #include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" @@ -66,11 +67,7 @@ static QString SEPARATOR = "/"; //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -static QString toInternalSeparator(const QString& path); -static QString& appendSeparatorIfNo(QString& path); static QStringList prefixStrings(const QStringList& strings, const QString& prefix); -static QString relativePath(const QString& rootDir, const QString& dir); -static bool equalPaths(const QString& path1, const QString& path2); //-------------------------------------------------------------------------------------------------- /// @@ -203,8 +200,8 @@ QStringList RicFileHierarchyDialog::files() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::rootDir() const { - QString rootDir = toInternalSeparator(m_rootDir->text()); - return appendSeparatorIfNo(rootDir); + QString rootDir = RiaFilePathTools::toInternalSeparator(m_rootDir->text()); + return RiaFilePathTools::appendSeparatorIfNo(rootDir); } //-------------------------------------------------------------------------------------------------- @@ -212,7 +209,7 @@ QString RicFileHierarchyDialog::rootDir() const //-------------------------------------------------------------------------------------------------- QString RicFileHierarchyDialog::pathFilter() const { - return toInternalSeparator(m_pathFilter->text()); + return RiaFilePathTools::toInternalSeparator(m_pathFilter->text()); } //-------------------------------------------------------------------------------------------------- @@ -349,7 +346,7 @@ QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& c } } - QString currRelPath = relativePath(rootDir(), currentDir); + QString currRelPath = RiaFilePathTools::relativePath(rootDir(), currentDir); if (pathFilterMatch(currPathFilter, currRelPath)) { allDirs.push_back(currentDir); @@ -437,7 +434,7 @@ void RicFileHierarchyDialog::updateEffectiveFilter() .arg(m_fileFilter->text()) .arg(m_fileExtension->text()); - QString internalFilter(toInternalSeparator(effFilter)); + QString internalFilter(RiaFilePathTools::toInternalSeparator(effFilter)); // Remove duplicate separators int len; @@ -619,36 +616,6 @@ void RicFileHierarchyDialog::slotBrowseButtonClicked() /// Internal functions //-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString toInternalSeparator(const QString& path) -{ - QString currNativeSep = QDir::separator(); - - if (currNativeSep == "/") - { - // On Linux like system -> Do not convert separators - return path; - } - - // On other systems (i.e. Windows) -> Convert to internal separator (/) - QString output = path; - return output.replace(QString("\\"), SEPARATOR); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString& appendSeparatorIfNo(QString& path) -{ - if (!path.endsWith(SEPARATOR)) - { - path.append(SEPARATOR); - } - return path; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -668,34 +635,3 @@ QStringList prefixStrings(const QStringList& strings, const QString& prefix) } return prefixedStrings; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString relativePath(const QString& rootDir, const QString& dir) -{ - if (dir.startsWith(rootDir)) - { - QString relPath = dir; - relPath.remove(0, rootDir.size()); - - if (relPath.startsWith(SEPARATOR)) relPath.remove(0, 1); - return appendSeparatorIfNo(relPath); - } - else - { - return dir; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool equalPaths(const QString& path1, const QString& path2) -{ - QString p1 = path1; - QString p2 = path2; - appendSeparatorIfNo(p1); - appendSeparatorIfNo(p2); - return p1 == p2; -} diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index d3648a5539..c9a4f43779 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -53,6 +53,7 @@ bool RicImportSummaryCaseFeature::isCommandEnabled() void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); + RiaPreferences* prefs = app->preferences(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); @@ -63,7 +64,15 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) if (fileNames.isEmpty()) return; - std::vector fileInfos = RicImportSummaryCasesFeature::getFilesToImportWithDialog(fileNames, true); + std::vector fileInfos; + if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + { + fileInfos = RicImportSummaryCasesFeature::getFilesToImportWithDialog(fileNames, true); + } + else + { + fileInfos = RicImportSummaryCasesFeature::getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); + } RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(fileInfos); diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 61cb441414..b3a20a110e 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -56,6 +56,7 @@ bool RicImportSummaryCasesFeature::isCommandEnabled() void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); + RiaPreferences* prefs = app->preferences(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); @@ -72,10 +73,20 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) QStringList fileNames = result.files; if (fileNames.isEmpty()) return; - std::vector fileInfos = getFilesToImportWithDialog(fileNames, true); + std::vector fileInfos; + if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + { + fileInfos = getFilesToImportWithDialog(fileNames, true); + } + else + { + fileInfos = getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); + } createAndAddSummaryCaseFromFileInfo(fileInfos); + if (fileInfos.size() > 0) RiaApplication::instance()->addToRecentFiles(fileInfos.front().fileName); + std::vector cases; app->project()->allCases(cases); @@ -111,8 +122,6 @@ std::vector RicImportSummaryCasesFeature::getFilesToImpo if (result.ok) { - if(result.files.size() > 0) RiaApplication::instance()->addToRecentFiles(result.files.front()); - for (const QString& file : result.files) { RicSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); @@ -127,6 +136,38 @@ std::vector RicImportSummaryCasesFeature::getFilesToImpo return std::vector(filesToImport.begin(), filesToImport.end()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicImportSummaryCasesFeature::getFilesToImportFromPrefs(const QStringList& initialFiles, + RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode) +{ + std::set filesToImport; + RicSummaryCaseRestartDialogResult lastResult; + + for (const QString& file : initialFiles) + { + if (summaryRestartMode == RiaPreferences::IMPORT) + { + filesToImport.insert(RicSummaryCaseFileInfo(file, true)); + } + else if (summaryRestartMode == RiaPreferences::NOT_IMPORT) + { + filesToImport.insert(RicSummaryCaseFileInfo(file, false)); + } + else if (summaryRestartMode == RiaPreferences::SEPARATE_CASES) + { + filesToImport.insert(RicSummaryCaseFileInfo(file, false)); + + RifReaderEclipseSummary reader; + std::vector restartFileInfos = reader.getRestartFiles(file); + for (const auto& fi : restartFileInfos) + filesToImport.insert(RicSummaryCaseFileInfo(fi.fileName, false)); + } + } + return std::vector(filesToImport.begin(), filesToImport.end()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -149,8 +190,21 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(const std //-------------------------------------------------------------------------------------------------- bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileWithDialog(const QString& fileName) { + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* prefs = app->preferences(); + QStringList fileNames({ fileName }); - std::vector fileInfos = getFilesToImportWithDialog(fileNames, false); + std::vector fileInfos; + if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + { + fileInfos = getFilesToImportWithDialog(fileNames, false); + } + else + { + fileInfos = getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); + } + + bool res = createAndAddSummaryCaseFromFileInfo(fileInfos); RiaApplication::instance()->addToRecentFiles(fileName); return res; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index ec11bf6fb6..fcefac9df2 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -18,6 +18,8 @@ #pragma once +#include "RiaPreferences.h" + #include "cafCmdFeature.h" #include @@ -54,6 +56,9 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature static std::vector getFilesToImportWithDialog(const QStringList& initialFiles, bool enableApplyToAllField); + static std::vector getFilesToImportFromPrefs(const QStringList& initialFiles, + RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode); + static bool createAndAddSummaryCaseFromFileInfo(const std::vector& fileInfos); static bool createAndAddSummaryCaseFromFileWithDialog(const QString& fileName); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 99e009b920..ae52b0bb97 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -22,6 +22,7 @@ #include "ExportCommands/RicSnapshotFilenameGenerator.h" #include "RiaApplication.h" +#include "RiaFilePathTools.h" #include "RifReaderEclipseSummary.h" @@ -57,15 +58,6 @@ #define DEFAULT_DIALOG_WIDTH 550 #define DEFAULT_DIALOG_INIT_HEIGHT 150 -//-------------------------------------------------------------------------------------------------- -/// Internal variables -//-------------------------------------------------------------------------------------------------- -static QString SEPARATOR = "/"; - -//-------------------------------------------------------------------------------------------------- -/// Internal functions -//-------------------------------------------------------------------------------------------------- -static QString toInternalSeparator(const QString& path); //-------------------------------------------------------------------------------------------------- /// @@ -164,12 +156,12 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const return RicSummaryCaseRestartDialogResult(false, READ_SINGLE, QStringList(), false); } - QStringList files({ toInternalSeparator(summaryHeaderFile) }); + QStringList files({ RiaFilePathTools::toInternalSeparator(summaryHeaderFile) }); if (dialog.selectedOption() == SEPARATE_CASES) { for (const auto& fileInfo : fileInfos) { - files.push_back(toInternalSeparator(fileInfo.fileName)); + files.push_back(RiaFilePathTools::toInternalSeparator(fileInfo.fileName)); } } return RicSummaryCaseRestartDialogResult(true, dialog.selectedOption(), files, dialog.applyToAllSelected()); @@ -244,20 +236,3 @@ void RicSummaryCaseRestartDialog::slotDialogCancelClicked() /// Internal functions //-------------------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString toInternalSeparator(const QString& path) -{ - QString currNativeSep = QDir::separator(); - - if (currNativeSep == "/") - { - // On Linux like system -> Do not convert separators - return path; - } - - // On other systems (i.e. Windows) -> Convert to internal separator (/) - QString output = path; - return output.replace(QString("\\"), SEPARATOR); -} diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 4de746e4d0..28470afd5a 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -18,6 +18,7 @@ #include "RifReaderEclipseSummary.h" #include "RiaStringEncodingTools.h" +#include "RiaFilePathTools.h" #include "RifReaderEclipseOutput.h" #include "RifEclipseSummaryTools.h" @@ -416,7 +417,7 @@ RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& header QString restartBase = QDir(restartCase).dirName(); char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0); - restartFile.fileName = QDir::toNativeSeparators(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); + restartFile.fileName = RiaFilePathTools::toInternalSeparator(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); util_safe_free(smspec_header); ecl_sum = openEclSum(headerFileName, false); From d5bbeffdd0882acf1240637692d21a1a8c4e85e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 20 Mar 2018 11:25:54 +0100 Subject: [PATCH 0558/1027] #2555 Refactored summary restart file import --- .../Application/RiaApplication.cpp | 2 +- .../Commands/RicImportSummaryCaseFeature.cpp | 11 +- .../Commands/RicImportSummaryCasesFeature.cpp | 129 +---------------- .../Commands/RicImportSummaryCasesFeature.h | 28 +--- .../Commands/RicSummaryCaseRestartDialog.cpp | 38 +++-- .../Commands/RicSummaryCaseRestartDialog.h | 1 + .../FileInterface/CMakeLists_files.cmake | 2 + .../RifSummaryCaseRestartSelector.cpp | 131 ++++++++++++++++++ .../RifSummaryCaseRestartSelector.h | 67 +++++++++ .../Summary/RimSummaryCaseMainCollection.cpp | 38 +++-- .../Summary/RimSummaryCaseMainCollection.h | 2 +- 11 files changed, 267 insertions(+), 182 deletions(-) create mode 100644 ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp create mode 100644 ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 80cbf84a89..aac81a0e01 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1872,7 +1872,7 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".smspec", Qt::CaseInsensitive)) { - loadingSucceded = RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileWithDialog(fileName); + loadingSucceded = RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(QStringList({ fileName })); if (loadingSucceded) { getOrCreateAndShowMainPlotWindow(); diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index c9a4f43779..b4856b15b2 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -64,17 +64,10 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) if (fileNames.isEmpty()) return; - std::vector fileInfos; - if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + if (RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(fileNames)) { - fileInfos = RicImportSummaryCasesFeature::getFilesToImportWithDialog(fileNames, true); + for(const auto& fileName : fileNames) RiaApplication::instance()->addToRecentFiles(fileName); } - else - { - fileInfos = RicImportSummaryCasesFeature::getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); - } - - RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(fileInfos); std::vector cases; app->project()->allCases(cases); diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index b3a20a110e..f22da2cd47 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -22,7 +22,6 @@ #include "RiaPreferences.h" #include "RicFileHierarchyDialog.h" -#include "RicSummaryCaseRestartDialog.h" #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" @@ -56,7 +55,6 @@ bool RicImportSummaryCasesFeature::isCommandEnabled() void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); - RiaPreferences* prefs = app->preferences(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); @@ -73,19 +71,10 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) QStringList fileNames = result.files; if (fileNames.isEmpty()) return; - std::vector fileInfos; - if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + if (createAndAddSummaryCasesFromFiles(fileNames)) { - fileInfos = getFilesToImportWithDialog(fileNames, true); + for (const auto& fileName : fileNames) RiaApplication::instance()->addToRecentFiles(fileName); } - else - { - fileInfos = getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); - } - - createAndAddSummaryCaseFromFileInfo(fileInfos); - - if (fileInfos.size() > 0) RiaApplication::instance()->addToRecentFiles(fileInfos.front().fileName); std::vector cases; app->project()->allCases(cases); @@ -108,128 +97,22 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicImportSummaryCasesFeature::getFilesToImportWithDialog(const QStringList& initialFiles, - bool enableApplyToAllField) -{ - std::set filesToImport; - RicSummaryCaseRestartDialogResult lastResult; - - for (const QString& file : initialFiles) - { - RicSummaryCaseRestartDialogResult result; - if (lastResult.applyToAll) result = lastResult; - else result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField); - - if (result.ok) - { - for (const QString& file : result.files) - { - RicSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); - if (filesToImport.count(fi) == 0) - { - filesToImport.insert(fi); - } - } - } - lastResult = result; - } - return std::vector(filesToImport.begin(), filesToImport.end()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicImportSummaryCasesFeature::getFilesToImportFromPrefs(const QStringList& initialFiles, - RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode) -{ - std::set filesToImport; - RicSummaryCaseRestartDialogResult lastResult; - - for (const QString& file : initialFiles) - { - if (summaryRestartMode == RiaPreferences::IMPORT) - { - filesToImport.insert(RicSummaryCaseFileInfo(file, true)); - } - else if (summaryRestartMode == RiaPreferences::NOT_IMPORT) - { - filesToImport.insert(RicSummaryCaseFileInfo(file, false)); - } - else if (summaryRestartMode == RiaPreferences::SEPARATE_CASES) - { - filesToImport.insert(RicSummaryCaseFileInfo(file, false)); - - RifReaderEclipseSummary reader; - std::vector restartFileInfos = reader.getRestartFiles(file); - for (const auto& fi : restartFileInfos) - filesToImport.insert(RicSummaryCaseFileInfo(fi.fileName, false)); - } - } - return std::vector(filesToImport.begin(), filesToImport.end()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileInfo(const std::vector& fileInfos) -{ - RiaApplication* app = RiaApplication::instance(); - RimProject* proj = app->project(); - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return false; - - for (const auto& fi : fileInfos) - { - createAndAddSummaryCaseFromFile(fi.fileName, fi.includeRestartFiles); - } - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFileWithDialog(const QString& fileName) -{ - RiaApplication* app = RiaApplication::instance(); - RiaPreferences* prefs = app->preferences(); - - QStringList fileNames({ fileName }); - std::vector fileInfos; - if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) - { - fileInfos = getFilesToImportWithDialog(fileNames, false); - } - else - { - fileInfos = getFilesToImportFromPrefs(fileNames, prefs->summaryRestartFilesImportMode); - } - - - bool res = createAndAddSummaryCaseFromFileInfo(fileInfos); - RiaApplication::instance()->addToRecentFiles(fileName); - return res; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCaseFromFile(const QString& fileName, bool includeRestartFiles) +bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName, includeRestartFiles); + std::vector sumCases = sumCaseColl->createAndAddSummaryCasesFromFiles(fileNames); sumCaseColl->updateAllRequiredEditors(); RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) + if (mainPlotWindow && !sumCases.empty()) { - mainPlotWindow->selectAsCurrentItem(sumCase); + mainPlotWindow->selectAsCurrentItem(sumCases.back()); mainPlotWindow->updateSummaryPlotToolBar(); } return true; } - diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index fcefac9df2..093836f3d9 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -27,22 +27,6 @@ class RicSummaryCaseRestartDialogResult; -//================================================================================================== -/// -//================================================================================================== -class RicSummaryCaseFileInfo -{ -public: - RicSummaryCaseFileInfo(const QString _fileName, bool _includeRestartFiles) : - fileName(_fileName), includeRestartFiles(_includeRestartFiles) {} - - QString fileName; - bool includeRestartFiles; - - bool operator<(const RicSummaryCaseFileInfo& other) const { return fileName < other.fileName; } - bool operator==(const RicSummaryCaseFileInfo& other) const { return fileName == other.fileName; } -}; - //================================================================================================== /// //================================================================================================== @@ -53,17 +37,7 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature public: RicImportSummaryCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") { } - static std::vector getFilesToImportWithDialog(const QStringList& initialFiles, - bool enableApplyToAllField); - - static std::vector getFilesToImportFromPrefs(const QStringList& initialFiles, - RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode); - - static bool createAndAddSummaryCaseFromFileInfo(const std::vector& fileInfos); - static bool createAndAddSummaryCaseFromFileWithDialog(const QString& fileName); - -private: - static bool createAndAddSummaryCaseFromFile(const QString& fileName, bool includeRestartFiles); + static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName); protected: // Overrides diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index ae52b0bb97..b3825b046e 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -127,6 +127,7 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + RicSummaryCaseRestartDialogResult *lastResult, QWidget *parent) { RicSummaryCaseRestartDialog dialog(parent); @@ -143,28 +144,41 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const return RicSummaryCaseRestartDialogResult(true, READ_SINGLE, QStringList({ summaryHeaderFile }), false); } - dialog.setWindowTitle("Summary Case Restart Files"); - dialog.m_readAllRadioButton->setChecked(true); - dialog.m_currentFile->setText(summaryHeaderFile); - dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); - dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); - dialog.exec(); - + RicSummaryCaseRestartDialogResult dialogResult; + if (lastResult && lastResult->applyToAll) + { + dialogResult = *lastResult; + dialogResult.files.clear(); + } + else + { + dialog.setWindowTitle("Summary Case Restart Files"); + dialog.m_readAllRadioButton->setChecked(true); + dialog.m_currentFile->setText(summaryHeaderFile); + dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); + dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + dialog.exec(); + + dialogResult = RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, + dialog.selectedOption(), + {}, + dialog.applyToAllSelected()); + } - if (dialog.result() != QDialog::Accepted) + if (!dialogResult.ok) { return RicSummaryCaseRestartDialogResult(false, READ_SINGLE, QStringList(), false); } - QStringList files({ RiaFilePathTools::toInternalSeparator(summaryHeaderFile) }); - if (dialog.selectedOption() == SEPARATE_CASES) + dialogResult.files.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); + if (dialogResult.option == SEPARATE_CASES) { for (const auto& fileInfo : fileInfos) { - files.push_back(RiaFilePathTools::toInternalSeparator(fileInfo.fileName)); + dialogResult.files.push_back(RiaFilePathTools::toInternalSeparator(fileInfo.fileName)); } } - return RicSummaryCaseRestartDialogResult(true, dialog.selectedOption(), files, dialog.applyToAllSelected()); + return dialogResult; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index b0c5bddb94..b4c80386af 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -53,6 +53,7 @@ class RicSummaryCaseRestartDialog : public QDialog static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + RicSummaryCaseRestartDialogResult *lastResult = nullptr, QWidget *parent = nullptr); ReadOptions selectedOption() const; diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index a59d71b92e..88fdb8618a 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -38,6 +38,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.h ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.h ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h +${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h @@ -80,6 +81,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp new file mode 100644 index 0000000000..f538eee8a0 --- /dev/null +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifSummaryCaseRestartSelector.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicSummaryCaseRestartDialog.h" + +#include +#include + +#include +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseRestartSelector::RifSummaryCaseRestartSelector() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::getFilesToImport(const QStringList& selectedFiles) +{ + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* prefs = app->preferences(); + + std::vector fileInfos; + if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + { + bool enableApplyToAllField = selectedFiles.size() > 1; + fileInfos = getFilesToImportByAskingUser(selectedFiles, enableApplyToAllField); + } + else + { + fileInfos = getFilesToImportUsingPrefs(selectedFiles, prefs->summaryRestartFilesImportMode); + } + + return fileInfos; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialFiles, + bool enableApplyToAllField) +{ + std::set filesToImport; + RicSummaryCaseRestartDialogResult lastResult; + + for (const QString& file : initialFiles) + { + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField, &lastResult); + if (result.ok) + { + for (const QString& file : result.files) + { + RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); + if (filesToImport.count(fi) == 0) + { + filesToImport.insert(fi); + } + } + } + lastResult = result; + } + return std::vector(filesToImport.begin(), filesToImport.end()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const QStringList& initialFiles, + RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode) +{ + std::set filesToImport; + RicSummaryCaseRestartDialogResult lastResult; + + for (const QString& file : initialFiles) + { + if (summaryRestartMode == RiaPreferences::IMPORT) + { + filesToImport.insert(RifSummaryCaseFileInfo(file, true)); + } + else if (summaryRestartMode == RiaPreferences::NOT_IMPORT) + { + filesToImport.insert(RifSummaryCaseFileInfo(file, false)); + } + else if (summaryRestartMode == RiaPreferences::SEPARATE_CASES) + { + filesToImport.insert(RifSummaryCaseFileInfo(file, false)); + + RifReaderEclipseSummary reader; + std::vector restartFileInfos = reader.getRestartFiles(file); + for (const auto& fi : restartFileInfos) + filesToImport.insert(RifSummaryCaseFileInfo(fi.fileName, false)); + } + } + return std::vector(filesToImport.begin(), filesToImport.end()); +} diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h new file mode 100644 index 0000000000..e6dcb56d8f --- /dev/null +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" +#include + +#include +#include +#include + +class QStringList; +class RifSummaryCaseFileInfo; + + +//================================================================================================== +// +// +//================================================================================================== +class RifSummaryCaseRestartSelector +{ +public: + RifSummaryCaseRestartSelector(); + ~RifSummaryCaseRestartSelector(); + + std::vector getFilesToImport(const QStringList& selectedFiles); + +private: + std::vector getFilesToImportByAskingUser(const QStringList& initialFiles, + bool enableApplyToAllField); + std::vector getFilesToImportUsingPrefs(const QStringList& initialFiles, + RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode); + + +}; + +//================================================================================================== +/// +//================================================================================================== +class RifSummaryCaseFileInfo +{ +public: + RifSummaryCaseFileInfo(const QString _fileName, bool _includeRestartFiles) : + fileName(_fileName), includeRestartFiles(_includeRestartFiles) {} + + QString fileName; + bool includeRestartFiles; + + bool operator<(const RifSummaryCaseFileInfo& other) const { return fileName < other.fileName; } + bool operator==(const RifSummaryCaseFileInfo& other) const { return fileName == other.fileName; } +}; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index f600e83f38..0b7f68212d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -18,6 +18,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RifEclipseSummaryTools.h" +#include "RifSummaryCaseRestartSelector.h" #include "RimEclipseResultCase.h" #include "RimFileSummaryCase.h" @@ -267,8 +268,18 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) { QString gridFileName = eclResCase->gridFileName(); - if(RifEclipseSummaryTools::hasSummaryFiles(QDir::toNativeSeparators(gridFileName))) + QString summaryHeaderFile; + bool formatted; + + RifEclipseSummaryTools::findSummaryHeaderFile(QDir::toNativeSeparators(gridFileName), &summaryHeaderFile, &formatted); + + if(!summaryHeaderFile.isEmpty()) { + // Activate when after discussing how grid case and summary case(s) are going to be related + // + //RifSummaryCaseRestartSelector fileSelector; + //std::vector importFileInfos = fileSelector.getFilesToImport(QStringList({ summaryHeaderFile })); + RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); this->m_cases.push_back(newSumCase); newSumCase->setAssociatedEclipseCase(eclResCase); @@ -282,17 +293,26 @@ RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromFileName(const QString& fileName, bool includeRestartFiles) +std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFiles(const QStringList& inputFileNames) { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + std::vector sumCases; + RifSummaryCaseRestartSelector fileSelector; + std::vector importFileInfos = fileSelector.getFilesToImport(inputFileNames); + + for (const RifSummaryCaseFileInfo& fileInfo : importFileInfos) + { + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - this->m_cases.push_back(newSumCase); - newSumCase->setIncludeRestartFiles(includeRestartFiles); - newSumCase->setSummaryHeaderFileName(fileName); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); + this->m_cases.push_back(newSumCase); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); + newSumCase->setSummaryHeaderFileName(fileInfo.fileName); + newSumCase->createSummaryReaderInterface(); + newSumCase->updateOptionSensitivity(); + + sumCases.push_back(newSumCase); + } - return newSumCase; + return sumCases; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index dce2794ba2..22a4404f16 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -45,7 +45,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void createSummaryCasesFromRelevantEclipseResultCases(); RimSummaryCase* createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase); - RimSummaryCase* createAndAddSummaryCaseFromFileName(const QString& fileName, bool includeRestartFiles); + std::vector createAndAddSummaryCasesFromFiles(const QStringList& inputFileNames); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; From 95a97442415a74c834f37ee2e19915048641a35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 20 Mar 2018 13:28:06 +0100 Subject: [PATCH 0559/1027] #2555 Add time period for current file as well --- .../Commands/RicSummaryCaseRestartDialog.cpp | 33 +++++++++++------ .../Commands/RicSummaryCaseRestartDialog.h | 5 +-- .../FileInterface/RifReaderEclipseSummary.cpp | 35 ++++++++++++------- .../FileInterface/RifReaderEclipseSummary.h | 1 + 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index b3825b046e..b2289c17e9 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -66,7 +66,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) : QDialog(parent, RiuTools::defaultDialogFlags()) { // Create widgets - m_currentFile = new QLabel(); + m_currentFileGridLayout = new QGridLayout(); m_readAllRadioButton = new QRadioButton(this); m_notReadRadionButton = new QRadioButton(this); m_separateCasesRadionButton = new QRadioButton(this); @@ -88,9 +88,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) QVBoxLayout* dialogLayout = new QVBoxLayout(); QGroupBox* currentFileGroup = new QGroupBox("Current Summary File"); - QVBoxLayout* currentFileLayout = new QVBoxLayout(); - currentFileLayout->addWidget(m_currentFile); - currentFileGroup->setLayout(currentFileLayout); + m_currentFileGridLayout = new QGridLayout(); + currentFileGroup->setLayout(m_currentFileGridLayout); QGroupBox* filesGroup = new QGroupBox("Found Restart Files"); m_filesGridLayout = new QGridLayout(); @@ -132,10 +131,13 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const { RicSummaryCaseRestartDialog dialog(parent); + RifRestartFileInfo currentFileInfo = dialog.getFileInfo(summaryHeaderFile); + dialog.appendFileInfoToGridLayout(*dialog.m_currentFileGridLayout, currentFileInfo); + std::vector fileInfos = dialog.getRestartFiles(summaryHeaderFile); for (const auto& fileInfo : fileInfos) { - dialog.appendToFileList(fileInfo); + dialog.appendFileInfoToGridLayout(*dialog.m_filesGridLayout, fileInfo); } // If no restart files are found, do not show dialog @@ -154,7 +156,6 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const { dialog.setWindowTitle("Summary Case Restart Files"); dialog.m_readAllRadioButton->setChecked(true); - dialog.m_currentFile->setText(summaryHeaderFile); dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -203,13 +204,13 @@ bool RicSummaryCaseRestartDialog::applyToAllSelected() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::appendToFileList(const RifRestartFileInfo& fileInfo) +void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo) { QDateTime startDate = QDateTime::fromTime_t(fileInfo.startDate); QString startDateString = startDate.toString(RimTools::dateFormatString()); QDateTime endDate = QDateTime::fromTime_t(fileInfo.endDate); QString endDateString = endDate.toString(RimTools::dateFormatString()); - int rowCount = m_filesGridLayout->rowCount(); + int rowCount = gridLayout.rowCount(); QLabel* fileNameLabel = new QLabel(); QLabel* dateLabel = new QLabel(); @@ -217,8 +218,11 @@ void RicSummaryCaseRestartDialog::appendToFileList(const RifRestartFileInfo& fil dateLabel->setText(startDateString + " - " + endDateString); fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - m_filesGridLayout->addWidget(fileNameLabel, rowCount, 0); - m_filesGridLayout->addWidget(dateLabel, rowCount, 1); + gridLayout.addWidget(fileNameLabel, rowCount, 0); + gridLayout.addWidget(dateLabel, rowCount, 1); + + // Full path in tooltip + fileNameLabel->setToolTip(fileInfo.fileName); } //-------------------------------------------------------------------------------------------------- @@ -230,6 +234,15 @@ std::vector RicSummaryCaseRestartDialog::getRestartFiles(con return reader.getRestartFiles(summaryHeaderFile); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile) +{ + RifReaderEclipseSummary reader; + return reader.getFileInfo(summaryHeaderFile); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index b4c80386af..084214ce0b 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -60,15 +60,16 @@ class RicSummaryCaseRestartDialog : public QDialog bool applyToAllSelected() const; private: - void appendToFileList(const RifRestartFileInfo& fileInfo); + void appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo); std::vector getRestartFiles(const QString& summaryHeaderFile); + RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); private slots: void slotDialogOkClicked(); void slotDialogCancelClicked(); private: - QLabel* m_currentFile; + QGridLayout* m_currentFileGridLayout; QGridLayout* m_filesGridLayout; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 28470afd5a..be87be0e62 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -147,6 +147,24 @@ std::vector RifReaderEclipseSummary::getRestartFiles(const Q return restartFiles; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RifReaderEclipseSummary::getFileInfo(const QString& headerFileName) +{ + RifRestartFileInfo fileInfo; + ecl_sum_type* ecl_sum = openEclSum(headerFileName, false); + std::vector timeSteps = getTimeSteps(ecl_sum); + if (timeSteps.size() > 0) + { + fileInfo.fileName = headerFileName; + fileInfo.startDate = timeSteps.front(); + fileInfo.endDate = timeSteps.back(); + } + closeEclSum(ecl_sum); + return fileInfo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -402,8 +420,6 @@ time_t getStartDate(ecl_file_type * header) //-------------------------------------------------------------------------------------------------- RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& headerFileName) { - RifRestartFileInfo restartFile; - ecl_sum_type* ecl_sum = openEclSum(headerFileName, true); const ecl_smspec_type* smspec = ecl_sum ? ecl_sum_get_smspec(ecl_sum) : nullptr; @@ -415,21 +431,14 @@ RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& header { QString path = QFileInfo(headerFileName).dir().path(); QString restartBase = QDir(restartCase).dirName(); - + char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0); - restartFile.fileName = RiaFilePathTools::toInternalSeparator(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); + QString restartFileName = RiaFilePathTools::toInternalSeparator(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); util_safe_free(smspec_header); - ecl_sum = openEclSum(headerFileName, false); - std::vector timeSteps = getTimeSteps(ecl_sum); - if (timeSteps.size() > 0) - { - restartFile.startDate = timeSteps.front(); - restartFile.endDate = timeSteps.back(); - } - closeEclSum(ecl_sum); + return getFileInfo(restartFileName); } - return restartFile; + return RifRestartFileInfo(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index 8ea783417b..cb234924cf 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -57,6 +57,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface bool open(const QString& headerFileName, bool includeRestartFiles); std::vector getRestartFiles(const QString& headerFileName); + RifRestartFileInfo getFileInfo(const QString& headerFileName); virtual const std::vector& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override; From 148d058d889b3ff847834ee949f95b5be86fab50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 20 Mar 2018 14:32:24 +0100 Subject: [PATCH 0560/1027] #2555 Open summary restart dialog if necessary when opening egrid files --- .../Tools/RiaImportEclipseCaseTools.cpp | 3 +- .../RifSummaryCaseRestartSelector.cpp | 19 +++++-- .../Summary/RimGridSummaryCase.cpp | 12 ++++- .../Summary/RimGridSummaryCase.h | 3 ++ .../Summary/RimSummaryCaseMainCollection.cpp | 53 +++++++++++++------ .../Summary/RimSummaryCaseMainCollection.h | 2 +- 6 files changed, 70 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 0ed45c19c1..30718b4a64 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -127,7 +127,8 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr if (!sumCaseColl->findSummaryCaseFromEclipseResultCase(rimResultReservoir)) { - RimSummaryCase* newSumCase = sumCaseColl->createAndAddSummaryCaseFromEclipseResultCase(rimResultReservoir); + std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromEclipseResultCase(rimResultReservoir); + RimSummaryCase* newSumCase = !newSumCases.empty() ? newSumCases.front() : nullptr; if (newSumCase) { diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index f538eee8a0..793a73753f 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -32,6 +32,19 @@ #include +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +template +bool vectorContains(const std::vector& vector, T item) +{ + for (const auto& i : vector) + { + if (i == item) return true; + } + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -76,7 +89,7 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialFiles, bool enableApplyToAllField) { - std::set filesToImport; + std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; for (const QString& file : initialFiles) @@ -87,9 +100,9 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp for (const QString& file : result.files) { RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); - if (filesToImport.count(fi) == 0) + if (!vectorContains(filesToImport, fi)) { - filesToImport.insert(fi); + filesToImport.push_back(fi); } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index d108806032..e62b51e6b8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -51,6 +51,8 @@ RimGridSummaryCase::RimGridSummaryCase() m_eclipseGridFileName.uiCapability()->setUiReadOnly(true); m_eclipseGridFileName.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", ""); + m_includeRestartFiles.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -175,7 +177,7 @@ void RimGridSummaryCase::updateFilePathsFromProjectPath(const QString & newProje //-------------------------------------------------------------------------------------------------- void RimGridSummaryCase::createSummaryReaderInterface() { - m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), true /* read restart files */); + m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles); } //-------------------------------------------------------------------------------------------------- @@ -186,3 +188,11 @@ RifSummaryReaderInterface* RimGridSummaryCase::summaryReader() return m_summaryFileReader.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridSummaryCase::setIncludeRestartFiles(bool includeRestartFiles) +{ + m_includeRestartFiles = includeRestartFiles; +} + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h index cb9f594571..7adfcf4eb4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h @@ -50,6 +50,8 @@ class RimGridSummaryCase : public RimSummaryCase virtual void createSummaryReaderInterface() override; virtual RifSummaryReaderInterface* summaryReader() override; + void setIncludeRestartFiles(bool includeRestartFiles); + private: QString eclipseGridFileName() const; @@ -59,4 +61,5 @@ class RimGridSummaryCase : public RimSummaryCase caf::PdmProxyValueField m_eclipseGridFileName; cvf::ref m_summaryFileReader; + caf::PdmField m_includeRestartFiles; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 0b7f68212d..8ee010d917 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -91,7 +91,7 @@ void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCa if (!isFound) { // Create new GridSummaryCase - createAndAddSummaryCaseFromEclipseResultCase(eclResCase); + createAndAddSummaryCasesFromEclipseResultCase(eclResCase); } } } @@ -265,29 +265,50 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) +std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromEclipseResultCase(RimEclipseResultCase* eclResCase) { - QString gridFileName = eclResCase->gridFileName(); - QString summaryHeaderFile; - bool formatted; + std::vector sumCases; + QString gridFileName = eclResCase->gridFileName(); + QString summaryHeaderFile; + bool formatted; RifEclipseSummaryTools::findSummaryHeaderFile(QDir::toNativeSeparators(gridFileName), &summaryHeaderFile, &formatted); if(!summaryHeaderFile.isEmpty()) { - // Activate when after discussing how grid case and summary case(s) are going to be related - // - //RifSummaryCaseRestartSelector fileSelector; - //std::vector importFileInfos = fileSelector.getFilesToImport(QStringList({ summaryHeaderFile })); + RifSummaryCaseRestartSelector fileSelector; + std::vector importFileInfos = fileSelector.getFilesToImport(QStringList({ summaryHeaderFile })); - RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); - this->m_cases.push_back(newSumCase); - newSumCase->setAssociatedEclipseCase(eclResCase); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - return newSumCase; + if (!importFileInfos.empty()) + { + RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); + + this->m_cases.push_back(newSumCase); + newSumCase->setIncludeRestartFiles(importFileInfos.front().includeRestartFiles); + newSumCase->setAssociatedEclipseCase(eclResCase); + newSumCase->createSummaryReaderInterface(); + newSumCase->updateOptionSensitivity(); + sumCases.push_back(newSumCase); + + // Remove the processed element and add 'orphan' summary cases + importFileInfos.erase(importFileInfos.begin()); + + for (const RifSummaryCaseFileInfo& fileInfo : importFileInfos) + { + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + + this->m_cases.push_back(newSumCase); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); + newSumCase->setSummaryHeaderFileName(fileInfo.fileName); + newSumCase->createSummaryReaderInterface(); + newSumCase->updateOptionSensitivity(); + + sumCases.push_back(newSumCase); + } + } + } - return nullptr; + return sumCases; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 22a4404f16..3c36a44132 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -44,7 +44,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject std::vector summaryCaseCollections() const; void createSummaryCasesFromRelevantEclipseResultCases(); - RimSummaryCase* createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase); + std::vector createAndAddSummaryCasesFromEclipseResultCase(RimEclipseResultCase* eclResCase); std::vector createAndAddSummaryCasesFromFiles(const QStringList& inputFileNames); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; From a86fe5deb976680b30148ef631d993b279d47f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 20 Mar 2018 14:57:11 +0100 Subject: [PATCH 0561/1027] Fix Linux build error --- ApplicationCode/Application/RiaPreferences.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index a77be746ed..8af6ccbdf8 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -27,15 +27,17 @@ #include "cafPdmUiFieldHandle.h" #include "cafPdmUiFilePathEditor.h" - -template<> -void RiaPreferences::SummaryRestartFilesImportModeType::setUp() +namespace caf { - addItem(RiaPreferences::ASK_USER, "ASK_USER", "Ask user"); - addItem(RiaPreferences::IMPORT, "IMPORT", "Always import"); - addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Never import"); - addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Import as separate summary cases"); - setDefault(RiaPreferences::ASK_USER); + template<> + void RiaPreferences::SummaryRestartFilesImportModeType::setUp() + { + addItem(RiaPreferences::ASK_USER, "ASK_USER", "Ask user"); + addItem(RiaPreferences::IMPORT, "IMPORT", "Always import"); + addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Never import"); + addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Import as separate summary cases"); + setDefault(RiaPreferences::ASK_USER); + } } From 0de43ac9383190c0c1e84b4c8effcb96e99aa4b9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 15:36:57 +0100 Subject: [PATCH 0562/1027] #2628 3D well log curves: Scale curves by grid size --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 119 +++++++++--------- .../Riv3dWellLogCurveGeomertyGenerator.h | 3 +- .../Riv3dWellLogPlanePartMgr.cpp | 10 +- 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 961b8bb55f..055a9708c2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -74,7 +74,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; if (wellPathPoints.empty()) return nullptr; - + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); const cvf::Vec3d up(0, 0, 1); @@ -104,14 +104,15 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint counter = 0; - double offsetFromWellPathCenter = wellPathRadius()*1.2; - double gridWidth = 100; + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter+gridWidth)))); + vertices.push_back(cvf::Vec3f( + displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter + gridWidth())))); indices.push_back(counter++); indices.push_back(counter++); @@ -122,7 +123,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // Line along and close to well for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); indices.push_back(counter); indices.push_back(++counter); } @@ -132,7 +134,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // Line along and far away from well for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth)))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth())))); indices.push_back(counter); indices.push_back(++counter); } @@ -197,26 +200,20 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim vertices->resize(interpolatedWellPathPoints.size()); - double range = maxResult - minResult; - double offset = wellPathRadius()*1.2; - double factor = 2 * offset / range; - - if (minResult < 0) - { - offset += cvf::Math::abs(minResult * factor); - } + double plotRangeToResultRangeFactor = gridWidth() / (maxResult - minResult); + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); for (size_t i = 0; i < pointNormals.size(); i++) { - cvf::Vec3d result(0, 0, 0); + double scaledResult = 0; if (RigCurveDataTools::isValidValue(resultValues[i], false)) { - result = resultValues[i] * factor * pointNormals[i]; + scaledResult = offsetFromWellPathCenter + (resultValues[i] - minResult) * plotRangeToResultRangeFactor; } (*vertices)[i] = cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + pointNormals[i] * offset + result)); + displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * pointNormals[i])); } std::vector> valuesIntervals = @@ -239,7 +236,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal const std::vector& points) const { std::vector pointNormals; - + if (!wellPathGeometry()) return pointNormals; pointNormals.reserve(points.size()); @@ -275,20 +272,20 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal switch (drawPlane) { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; } pointNormals.push_back(normal); @@ -298,9 +295,10 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const +std::vector + Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const { std::vector wellSegmentNormals; @@ -312,12 +310,12 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg const cvf::Vec3d up(0, 0, 1); cvf::Vec3d normal; - - for (size_t i = 0; i < wellPathPoints.size()-1; i++) + + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) { cvf::Vec3d p1 = wellPathPoints[i]; cvf::Vec3d p2 = wellPathPoints[i + 1]; - + if (p1.isUndefined() || p2.isUndefined()) continue; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -338,23 +336,22 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg cvf::Vec3d Ey = (up ^ Ex).getNormalized(); cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - switch (drawPlane) { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; } wellSegmentNormals.push_back(normal); @@ -366,17 +363,25 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogCurveGeometryGenerator::wellPathRadius() const +double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const { double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - return m_wellPath->wellPathRadius(cellSize); + return m_wellPath->wellPathRadius(cellSize) * 1.2; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogCurveGeometryGenerator::gridWidth() const +{ + return 100; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 2376f78645..17ec52a37f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -62,7 +62,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const; - double wellPathRadius() const; + double wellPathCenterToPlotStartOffset() const; + double gridWidth() const; const RigWellPath* wellPathGeometry() const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index a763f5fba4..78516d3cd4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -49,7 +49,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (rim3dWellLogCurves.empty()) return; if (m_wellPath.isNull()) return; - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + if (m_3dWellLogCurveGeometryGenerator.isNull()) + { + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + } for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { @@ -94,7 +97,10 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) { - if (m_3dWellLogCurveGeometryGenerator.isNull()) return; + if (m_3dWellLogCurveGeometryGenerator.isNull()) + { + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + } caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); From a9daea0938eb61c24253d7063dd84b93e7ce6360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 20 Mar 2018 13:12:20 +0100 Subject: [PATCH 0563/1027] #2481, #2605, #2486 Use a flattened version of the normal wellpath visualization in 2D intersection view --- .../Intersections/RivIntersectionPartMgr.cpp | 7 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 224 ++++++++++++------ .../ModelVisualization/RivWellPathPartMgr.h | 7 +- .../Rim2dIntersectionView.cpp | 93 +++++--- .../ProjectDataModel/Rim2dIntersectionView.h | 6 +- .../ProjectDataModel/RimIntersection.cpp | 68 +----- .../ProjectDataModel/RimIntersection.h | 1 - .../ReservoirDataModel/RigWellPath.cpp | 136 +++++++++-- .../ReservoirDataModel/RigWellPath.h | 11 + .../UserInterface/RiuFemResultTextBuilder.cpp | 1 + 10 files changed, 357 insertions(+), 197 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 54450f2614..136fcfea10 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -794,7 +794,7 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod createSourceInfoFunc = [&](size_t brIdx) { return new RivSimWellPipeSourceInfo(simWellInView, brIdx); }; characteristicCellSize = eclView->eclipseCase()->characteristicCellSize(); } - else if (m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH) + else if (false)//m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH) { RimWellPath* wellPath = m_rimCrossSection->wellPath(); @@ -816,9 +816,10 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod // Create pipe geometry - if ( //m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL + if ( false //m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL //|| - m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH ) + //m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH + ) { std::vector > polyLines = m_crossSectionGenerator->flattenedOrOffsettedPolyLines(); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index bcbd6fc382..6af5fa373e 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -48,6 +48,7 @@ #include "RivObjectSourceInfo.h" #include "RivPartPriority.h" #include "RivPipeGeometryGenerator.h" +#include "RivSectionFlattner.h" #include "RivWellConnectionFactorPartMgr.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathPartMgr.h" @@ -256,7 +257,8 @@ void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox) + const cvf::BoundingBox& wellPathClipBoundingBox, + bool doFlatten) { RimWellPathCollection* wellPathCollection = this->wellPathCollection(); if (!wellPathCollection) return; @@ -264,111 +266,162 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; - if (wellPathGeometry->m_wellPathPoints.size() < 2) return; + const std::vector& wellpathCenterLine = wellPathGeometry->m_wellPathPoints; + + if (wellpathCenterLine.size() < 2) return; clearAllBranchData(); - double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); - cvf::Vec3d textPosition; + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); // Generate the well path geometry as a line and pipe structure + + m_pipeGeomGenerator = new RivPipeGeometryGenerator; + + m_pipeGeomGenerator->setRadius(wellPathRadius); + m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); + + double horizontalLengthAlongWellToClipPoint = 0.0; + + std::vector clippedWellPathCenterLine; + + // Skip visualization if outside the domain of this case { - m_pipeGeomGenerator = new RivPipeGeometryGenerator; + cvf::Vec3d casemax = wellPathClipBoundingBox.max(); + cvf::Vec3d casemin = wellPathClipBoundingBox.min(); + cvf::Vec3d caseext = wellPathClipBoundingBox.extent(); + + // Add up to the sealevel + cvf::BoundingBox relevantWellpathBBox = wellPathClipBoundingBox; + relevantWellpathBBox.add(cvf::Vec3d(casemax.x(), casemax.y(), 0.0)); - m_pipeGeomGenerator->setRadius(wellPathRadius); - m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); + // Add some sideways leeway - cvf::ref cvfCoords = new cvf::Vec3dArray; - if (wellPathCollection->wellPathClip) + cvf::Vec3d addSize = 3.0*cvf::Vec3d(caseext.x(), caseext.y(), 0.0); + relevantWellpathBBox.add(casemax + addSize); + relevantWellpathBBox.add(casemin - addSize); + + if ( !RigWellPath::isPolylineTouchingBBox(wellpathCenterLine, relevantWellpathBBox) ) + { + return; + } + } + + if ( wellPathCollection->wellPathClip ) + { + double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + clippedWellPathCenterLine = RigWellPath::clipPolylineStartAboveZ(wellpathCenterLine, + maxZClipHeight, + &horizontalLengthAlongWellToClipPoint); + + #if 0 + size_t firstVisibleSegmentIndex = cvf::UNDEFINED_SIZE_T; + for ( size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++ ) { - size_t firstVisibleSegmentIndex = cvf::UNDEFINED_SIZE_T; - for (size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) + cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; + if ( point.z() < (wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance) ) { - cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; - if (point.z() < (wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance)) - { - firstVisibleSegmentIndex = idx; - break; - } + firstVisibleSegmentIndex = idx; + break; } + } + - std::vector clippedPoints; - if (firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T) + if ( firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T ) + { + if ( firstVisibleSegmentIndex > 0 ) { - if (firstVisibleSegmentIndex > 0) - { - double wellPathStartPoint = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; - double stepsize = (wellPathStartPoint - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()) / - (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex].z() - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()); - - cvf::Vec3d newPoint = wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1] + - stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]); - - clippedPoints.push_back(newPoint); - m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); - } - else - { - m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); - } - - for (size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) - { - clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]); - } + double wellPathStartPoint = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + double stepsize = (wellPathStartPoint - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()) / + (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex].z() - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()); + + cvf::Vec3d newPoint = wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1] + + stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]); + clippedPoints.push_back(newPoint); + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); + } + else + { + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); } - if (clippedPoints.size() < 2) return; + for ( size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++ ) + { + clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]); + } - cvfCoords->assign(clippedPoints); } - else + #endif + + } + else + { + clippedWellPathCenterLine = wellpathCenterLine; + } + + if ( clippedWellPathCenterLine.size() < 2 ) return; + + cvf::ref cvfCoords = new cvf::Vec3dArray(clippedWellPathCenterLine.size()); + + // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. + + if ( doFlatten ) + { + cvf::Vec3d dummy; + std::vector flatningCSs = + RivSectionFlattner::calculateFlatteningCSsForPolyline(clippedWellPathCenterLine, + cvf::Vec3d::Z_AXIS, + { horizontalLengthAlongWellToClipPoint, 0.0, clippedWellPathCenterLine[0].z() }, + &dummy); + + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - cvfCoords->assign(wellPathGeometry->m_wellPathPoints); + auto clpoint = clippedWellPathCenterLine[cIdx].getTransformedPoint(flatningCSs[cIdx]); + (*cvfCoords)[cIdx] = displayCoordTransform->scaleToDisplaySize(clpoint); } - - // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) + } + else + { + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - (*cvfCoords)[cIdx] = displayCoordTransform->transformToDisplayCoord((*cvfCoords)[cIdx]); + (*cvfCoords)[cIdx] = displayCoordTransform->transformToDisplayCoord(clippedWellPathCenterLine[cIdx]); } + } - textPosition = cvfCoords->get(0); + m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); + m_surfaceDrawable = m_pipeGeomGenerator->createPipeSurface(); + m_centerLineDrawable = m_pipeGeomGenerator->createCenterLine(); - m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); - m_surfaceDrawable = m_pipeGeomGenerator->createPipeSurface(); - m_centerLineDrawable = m_pipeGeomGenerator->createCenterLine(); + if ( m_surfaceDrawable.notNull() ) + { + m_surfacePart = new cvf::Part; + m_surfacePart->setDrawable(m_surfaceDrawable.p()); - if (m_surfaceDrawable.notNull()) - { - m_surfacePart = new cvf::Part; - m_surfacePart->setDrawable(m_surfaceDrawable.p()); - - RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); - m_surfacePart->setSourceInfo(sourceInfo); + RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); + m_surfacePart->setSourceInfo(sourceInfo); - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); - cvf::ref eff = surfaceGen.generateCachedEffect(); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); - m_surfacePart->setEffect(eff.p()); - } + m_surfacePart->setEffect(eff.p()); + } - if (m_centerLineDrawable.notNull()) - { - m_centerLinePart = new cvf::Part; - m_centerLinePart->setDrawable(m_centerLineDrawable.p()); + if ( m_centerLineDrawable.notNull() ) + { + m_centerLinePart = new cvf::Part; + m_centerLinePart->setDrawable(m_centerLineDrawable.p()); - caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); - cvf::ref eff = gen.generateCachedEffect(); + caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); + cvf::ref eff = gen.generateCachedEffect(); - m_centerLinePart->setEffect(eff.p()); - } + m_centerLinePart->setEffect(eff.p()); } // Generate label with well-path name + cvf::Vec3d textPosition = cvfCoords->get(0); textPosition.z() += 2.2 * characteristicCellSize; if (wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty()) @@ -421,7 +474,7 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* return; // The pipe geometry needs to be rebuilt on scale change to keep the pipes round - buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); + buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, false); if (m_surfacePart.notNull()) { @@ -442,6 +495,33 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendFlattenedStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round + buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, true); + + if (m_surfacePart.notNull()) + { + model->addPart(m_surfacePart.p()); + } + + if (m_centerLinePart.notNull()) + { + model->addPart(m_centerLinePart.p()); + } + + if (m_wellLabelPart.notNull()) + { + model->addPart(m_wellLabelPart.p()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index cfdcb60d14..073e2e1280 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -64,6 +64,10 @@ class RivWellPathPartMgr : public cvf::Object double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox); + void appendFlattenedStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t timeStepIndex, @@ -96,7 +100,8 @@ class RivWellPathPartMgr : public cvf::Object void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox); + const cvf::BoundingBox& wellPathClipBoundingBox, + bool doFlatten); void clearAllBranchData(); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 38b4424512..d04f930ee9 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -17,19 +17,9 @@ ///////////////////////////////////////////////////////////////////////////////// #include "Rim2dIntersectionView.h" -#include "Rim2dIntersectionViewCollection.h" -#include "RimIntersection.h" #include "RimCase.h" -#include "RiuViewer.h" +#include "RimIntersection.h" #include "RimGridView.h" -#include "RivIntersectionPartMgr.h" -#include "RivTernarySaturationOverlayItem.h" - -#include "cvfPart.h" -#include "cvfModelBasicList.h" -#include "cvfTransform.h" -#include "cvfScene.h" - #include "Rim3dOverlayInfoConfig.h" #include "RimEclipseView.h" #include "RimEclipseCellColors.h" @@ -40,10 +30,22 @@ #include "RimSimWellInView.h" #include "RimWellPath.h" -#include -#include "cafDisplayCoordTransform.h" +#include "RiuViewer.h" + +#include "RivIntersectionPartMgr.h" +#include "RivTernarySaturationOverlayItem.h" #include "RivSimWellPipesPartMgr.h" #include "RivWellHeadPartMgr.h" +#include "RivWellPathPartMgr.h" + +#include "cafDisplayCoordTransform.h" + +#include "cvfModelBasicList.h" +#include "cvfTransform.h" +#include "cvfScene.h" +#include "cvfPart.h" + +#include CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); @@ -292,6 +294,14 @@ void Rim2dIntersectionView::update3dInfo() m_viewer->update(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim2dIntersectionView::flatIntersectionPartMgr() const +{ + return m_flatIntersectionPartMgr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -395,6 +405,7 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true); + m_intersectionVizModel->removeAllParts(); m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); @@ -420,6 +431,22 @@ void Rim2dIntersectionView::createDisplayModel() } } + m_flatWellpathPartMgr = nullptr; + if ( m_intersection->type() == RimIntersection::CS_WELL_PATH + && m_intersection->wellPath() ) + { + Rim3dView* settingsView = nullptr; + m_intersection->firstAncestorOrThisOfType(settingsView); + if ( settingsView ) + { + m_flatWellpathPartMgr = new RivWellPathPartMgr(m_intersection->wellPath(), settingsView); + m_flatWellpathPartMgr->appendFlattenedStaticGeometryPartsToModel(m_intersectionVizModel.p(), + this->displayCoordTransform().p(), + this->ownerCase()->characteristicCellSize(), + this->ownerCase()->activeCellsBoundingBox()); + } + } + m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); m_intersectionVizModel->updateBoundingBoxesRecursive(); @@ -436,26 +463,6 @@ void Rim2dIntersectionView::createDisplayModel() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) -{ -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::onTimeStepChanged() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Rim2dIntersectionView::clampCurrentTimestep() -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -579,6 +586,26 @@ void Rim2dIntersectionView::resetLegendsInViewer() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) +{ +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onTimeStepChanged() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::clampCurrentTimestep() +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 5c6233f810..c323c23010 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -19,7 +19,6 @@ #pragma once #include "Rim3dView.h" -#include "RivIntersectionPartMgr.h" #include "cafPdmPtrField.h" class RimIntersection; @@ -27,6 +26,8 @@ class RimLegendConfig; class RimTernaryLegendConfig; class RivSimWellPipesPartMgr; class RivWellHeadPartMgr; +class RivWellPathPartMgr; +class RivIntersectionPartMgr; namespace cvf { @@ -60,7 +61,7 @@ class Rim2dIntersectionView : public Rim3dView void update3dInfo(); - cvf::ref flatIntersectionPartMgr() const { return m_flatIntersectionPartMgr; } + cvf::ref flatIntersectionPartMgr() const; virtual cvf::ref displayCoordTransform() const override; @@ -99,6 +100,7 @@ class Rim2dIntersectionView : public Rim3dView cvf::ref m_flatIntersectionPartMgr; cvf::ref m_flatSimWellPipePartMgr; cvf::ref m_flatWellHeadPartMgr; + cvf::ref m_flatWellpathPartMgr; cvf::ref m_intersectionVizModel; cvf::ref m_scaleTransform; diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 32963d4369..57727baefb 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -403,7 +403,14 @@ std::vector< std::vector > RimIntersection::polyLines(cvf::Vec3d * if (wellPath() && wellPath->wellPathGeometry() ) { lines.push_back(wellPath->wellPathGeometry()->m_wellPathPoints); - clipToReservoir(lines[0], &horizontalProjectedLengthAlongWellPathToClipPoint); + RimCase* ownerCase = nullptr; + this->firstAncestorOrThisOfType(ownerCase); + if (ownerCase) + { + lines[0] = RigWellPath::clipPolylineStartAboveZ(lines[0], + ownerCase->activeCellsBoundingBox().max().z(), + &horizontalProjectedLengthAlongWellPathToClipPoint); + } } } else if (type == CS_SIMULATION_WELL) @@ -605,65 +612,6 @@ void RimIntersection::updateName() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimIntersection::clipToReservoir(std::vector &polyLine, double * horizontalLengthAlongWellToClipPoint) const -{ - CVF_ASSERT(horizontalLengthAlongWellToClipPoint != nullptr); - - *horizontalLengthAlongWellToClipPoint = 0.0; - RimCase* ownerCase = nullptr; - firstAncestorOrThisOfType(ownerCase); - - std::vector clippedPolyLine; - - if (ownerCase) - { - cvf::BoundingBox caseBB = ownerCase->activeCellsBoundingBox(); - bool hasEnteredReservoirBB = false; - for (size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx) - { - if (!caseBB.contains(polyLine[vxIdx])) - { - if (vxIdx > 0) - { - cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx-1]; - segment[2] = 0.0; - *horizontalLengthAlongWellToClipPoint += segment.length(); - } - continue; - } - - if (!hasEnteredReservoirBB) - { - if (vxIdx > 0) - { - // clip line, and add vx to start - cvf::Plane topPlane; - topPlane.setFromPointAndNormal(caseBB.max(), cvf::Vec3d::Z_AXIS); - cvf::Vec3d intersection; - - if (topPlane.intersect(polyLine[vxIdx-1], polyLine[vxIdx], &intersection)) - { - cvf::Vec3d segment = intersection - polyLine[vxIdx-1]; - segment[2] = 0.0; - *horizontalLengthAlongWellToClipPoint += segment.length(); - - clippedPolyLine.push_back(intersection); - } - } - - hasEnteredReservoirBB = true; - } - - clippedPolyLine.push_back(polyLine[vxIdx]); - } - } - - polyLine.swap(clippedPolyLine); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index c767b5df3d..3d30d1c1c3 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -139,7 +139,6 @@ class RimIntersection : public caf::PdmObject void updateSimulationWellCenterline() const; void updateWellExtentDefaultValue(); void addExtents(std::vector &polyLine) const; - void clipToReservoir(std::vector &polyLinee, double * horizontalLengthAlongWellToClipPoint) const; void updateName(); void rebuildGeometryAndScheduleCreateDisplayModel(); static double azimuthInRadians(cvf::Vec3d vec); diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index 2eda11ddae..15246758c7 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -17,9 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigWellPath.h" -#include "cvfGeometryTools.h" #include "cvfGeometryTools.h" +#include "cvfBoundingBox.h" +#include "cvfPlane.h" //-------------------------------------------------------------------------------------------------- /// @@ -63,14 +64,14 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) con cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO; size_t i = 0; - while (i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth ) + while ( i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth ) { i++; } - if (m_measuredDepths.size() > i) + if ( m_measuredDepths.size() > i ) { - if (i == 0) + if ( i == 0 ) { //For measuredDepth same or lower than first point, use this first point wellPathPoint = m_wellPathPoints.at(0); @@ -78,8 +79,8 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) con else { //Do interpolation - double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) / - (m_measuredDepths.at(i) - m_measuredDepths.at(i - 1)); + double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) / + (m_measuredDepths.at(i) - m_measuredDepths.at(i - 1)); wellPathPoint = m_wellPathPoints.at(i - 1) + stepsize * (m_wellPathPoints.at(i) - m_wellPathPoints.at(i-1)); } } @@ -101,13 +102,13 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const size_t closestIndex = cvf::UNDEFINED_SIZE_T; double closestDistance = cvf::UNDEFINED_DOUBLE; - for (size_t i = 1; i < m_wellPathPoints.size(); i++) + for ( size_t i = 1; i < m_wellPathPoints.size(); i++ ) { cvf::Vec3d p1 = m_wellPathPoints[i - 1]; cvf::Vec3d p2 = m_wellPathPoints[i - 0]; double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position); - if (candidateDistance < closestDistance) + if ( candidateDistance < closestDistance ) { closestDistance = candidateDistance; closestIndex = i; @@ -117,12 +118,12 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const //For vertical well (x-component of direction = 0) returned angle will be 90. double azimuthAngleDegrees = 90.0; - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if ( closestIndex != cvf::UNDEFINED_DOUBLE ) { cvf::Vec3d p1; cvf::Vec3d p2; - if (closestIndex > 0) + if ( closestIndex > 0 ) { p1 = m_wellPathPoints[closestIndex - 1]; p2 = m_wellPathPoints[closestIndex - 0]; @@ -135,7 +136,7 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const cvf::Vec3d direction = p2 - p1; - if (fabs(direction.y()) > 1e-5) + if ( fabs(direction.y()) > 1e-5 ) { double atanValue = direction.x() / direction.y(); double azimuthRadians = atan(atanValue); @@ -156,13 +157,13 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c size_t closestIndex = cvf::UNDEFINED_SIZE_T; double closestDistance = cvf::UNDEFINED_DOUBLE; - for (size_t i = 1; i < m_wellPathPoints.size(); i++) + for ( size_t i = 1; i < m_wellPathPoints.size(); i++ ) { cvf::Vec3d p1 = m_wellPathPoints[i - 1]; cvf::Vec3d p2 = m_wellPathPoints[i - 0]; double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position); - if (candidateDistance < closestDistance) + if ( candidateDistance < closestDistance ) { closestDistance = candidateDistance; closestIndex = i; @@ -171,7 +172,7 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c if (closestIndex != cvf::UNDEFINED_SIZE_T) { - if (closestIndex > 0) + if ( closestIndex > 0 ) { *p1 = m_wellPathPoints[closestIndex - 1]; *p2 = m_wellPathPoints[closestIndex - 0]; @@ -190,16 +191,16 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c std::pair, std::vector > RigWellPath::clippedPointSubset(double startMD, double endMD) const { std::pair, std::vector > pointsAndMDs; - if (m_measuredDepths.empty()) return pointsAndMDs; - if (startMD > endMD) return pointsAndMDs; + if ( m_measuredDepths.empty() ) return pointsAndMDs; + if ( startMD > endMD ) return pointsAndMDs; pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD)); pointsAndMDs.second.push_back(startMD); - for (size_t i = 0; i < m_measuredDepths.size(); ++i) + for ( size_t i = 0; i < m_measuredDepths.size(); ++i ) { double measuredDepth = m_measuredDepths[i]; - if (measuredDepth > startMD && measuredDepth < endMD) + if ( measuredDepth > startMD && measuredDepth < endMD ) { pointsAndMDs.first.push_back(m_wellPathPoints[i]); pointsAndMDs.second.push_back(measuredDepth); @@ -218,27 +219,27 @@ std::pair, std::vector > RigWellPath::clippedPoi std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const { std::vector points; - if (m_measuredDepths.empty()) return points; + if ( m_measuredDepths.empty() ) return points; cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath(intersectionMeasuredDepth); - for (size_t i = 0; i < m_measuredDepths.size() - 1; i++) + for ( size_t i = 0; i < m_measuredDepths.size() - 1; i++ ) { - if (m_measuredDepths[i] == intersectionMeasuredDepth) + if ( m_measuredDepths[i] == intersectionMeasuredDepth ) { points.push_back(m_wellPathPoints[i]); } - else if (m_measuredDepths[i] < intersectionMeasuredDepth) + else if ( m_measuredDepths[i] < intersectionMeasuredDepth ) { points.push_back(m_wellPathPoints[i]); - if (m_measuredDepths[i + 1] > intersectionMeasuredDepth) + if ( m_measuredDepths[i + 1] > intersectionMeasuredDepth ) { points.push_back(interpolatedWellPathPoint); } } - else if (m_measuredDepths[i] > intersectionMeasuredDepth) + else if ( m_measuredDepths[i] > intersectionMeasuredDepth ) { - if (i == 0) + if ( i == 0 ) { points.push_back(interpolatedWellPathPoint); } @@ -253,3 +254,88 @@ std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersec return points; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellPath::isPolylineTouchingBBox(const std::vector &polyLine, + const cvf::BoundingBox& caseBB) +{ + for ( const cvf::Vec3d& point : polyLine ) + { + if ( caseBB.contains(point) ) return true; + } + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellPath::clipPolylineStartAboveZ(const std::vector& polyLine, + double maxZ, + double * horizontalLengthAlongWellToClipPoint) +{ + CVF_ASSERT(horizontalLengthAlongWellToClipPoint != nullptr); + + // Find first visible point, and accumulate distance along wellpath + + *horizontalLengthAlongWellToClipPoint = 0.0; + size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T; + + for ( size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx ) + { + if ( polyLine[vxIdx].z() > maxZ ) + { + if ( vxIdx > 0 ) + { + cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + } + } + else + { + firstVisiblePointIndex = vxIdx; + break; + } + } + + // Clip line, and add vx to the start of the clipped result + + std::vector clippedPolyLine; + + if ( firstVisiblePointIndex == cvf::UNDEFINED_SIZE_T ) + { + return clippedPolyLine; + } + + if ( firstVisiblePointIndex > 0 ) + { + + cvf::Plane topPlane; + topPlane.setFromPointAndNormal({ 0.0, 0.0, maxZ }, cvf::Vec3d::Z_AXIS); + cvf::Vec3d intersection; + + if ( topPlane.intersect(polyLine[firstVisiblePointIndex-1], + polyLine[firstVisiblePointIndex], + &intersection) ) + { + cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + + clippedPolyLine.push_back(intersection); + } + } + + // Add the rest of the polyline + + for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx ) + { + clippedPolyLine.push_back(polyLine[vxIdx]); + } + + return clippedPolyLine; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index 94f39b026b..cbfbd808d0 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -23,6 +23,11 @@ #include "cvfMath.h" #include "cvfVector3.h" +namespace cvf +{ + class BoundingBox; +} + #include @@ -49,6 +54,12 @@ class RigWellPath : public cvf::Object std::vector wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const; + static bool isPolylineTouchingBBox(const std::vector &polyLine, + const cvf::BoundingBox& caseBB); + static std::vector clipPolylineStartAboveZ(const std::vector &polyLine, + double maxZ, + double * horizontalLengthAlongWellToClipPoint); + private: bool m_hasDatumElevation; double m_datumElevation; diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 343fd71bc8..1157757aff 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -31,6 +31,7 @@ #include "RimGeoMechView.h" #include "Rim2dIntersectionView.h" #include "RiuGeoMechXfTensorResultAccessor.h" +#include "RivIntersectionPartMgr.h" From 65b35cff92696549e6b7ea0b54b3b45e95f7b630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 20 Mar 2018 13:21:49 +0100 Subject: [PATCH 0564/1027] #2481, #2605, #2486, #2568 Remove obsolete code --- .../Intersections/RivIntersectionPartMgr.cpp | 113 ------------------ .../Intersections/RivIntersectionPartMgr.h | 1 - .../ModelVisualization/RivWellPathPartMgr.cpp | 42 ------- .../Rim2dIntersectionView.cpp | 1 - 4 files changed, 157 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 136fcfea10..5f4099e843 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -763,119 +763,6 @@ cvf::ref createStdLinePart(cvf::DrawableGeo* geometry, return part; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) -{ - if (m_rimCrossSection.isNull() || m_crossSectionGenerator.isNull()) return; - - // Get information on how to draw the pipe - - std::function< cvf::ref< cvf::Object > ( size_t ) > createSourceInfoFunc; - double pipeRadius = 1; - int pipeCrossSectionVxCount = 6; - cvf::Color3f wellPipeColor = cvf::Color3f::GRAY; - double characteristicCellSize = 0; - - if ( false)//m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL ) - { - RimSimWellInView * simWellInView = m_rimCrossSection->simulationWell(); - - if (!simWellInView) return; - - RimEclipseView* eclView = nullptr; - simWellInView->firstAncestorOrThisOfTypeAsserted(eclView); - - pipeRadius = simWellInView->pipeRadius(); - pipeCrossSectionVxCount = eclView->wellCollection()->pipeCrossSectionVertexCount(); - wellPipeColor = simWellInView->wellPipeColor(); - - createSourceInfoFunc = [&](size_t brIdx) { return new RivSimWellPipeSourceInfo(simWellInView, brIdx); }; - characteristicCellSize = eclView->eclipseCase()->characteristicCellSize(); - } - else if (false)//m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH) - { - RimWellPath* wellPath = m_rimCrossSection->wellPath(); - - if (!wellPath) return; - - RimGridView* gridView = nullptr; - m_rimCrossSection->firstAncestorOrThisOfTypeAsserted(gridView); - double cellSize = gridView->ownerCase()->characteristicCellSize(); - - RimWellPathCollection* wellPathColl = nullptr; - wellPath->firstAncestorOrThisOfTypeAsserted(wellPathColl); - - pipeRadius = wellPath->wellPathRadius(cellSize); - pipeCrossSectionVxCount = wellPathColl->wellPathCrossSectionVertexCount(); - wellPipeColor = wellPath->wellPathColor(); - - createSourceInfoFunc = [&](size_t brIdx) { return new RivObjectSourceInfo(wellPath); }; //Temporary fix to avoid crash - } - - // Create pipe geometry - - if ( false //m_rimCrossSection->type() == RimIntersection::CS_SIMULATION_WELL - //|| - //m_rimCrossSection->type() == RimIntersection::CS_WELL_PATH - ) - { - std::vector > polyLines = m_crossSectionGenerator->flattenedOrOffsettedPolyLines(); - - // Remove intersectino extents from the polyline - for (auto & polyLine: polyLines) - { - if ( polyLine.size() > 2 ) - { - polyLine.pop_back(); - polyLine.erase(polyLine.begin()); - } - } - - m_wellBranches.clear(); - - for ( size_t brIdx = 0; brIdx < polyLines.size(); ++brIdx ) - { - cvf::ref sourceInfo = createSourceInfoFunc(brIdx); - - m_wellBranches.emplace_back(); - RivPipeBranchData& pbd = m_wellBranches.back(); - - pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; - pbd.m_pipeGeomGenerator->setRadius(pipeRadius); - pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(pipeCrossSectionVxCount); - - cvf::ref cvfCoords = new cvf::Vec3dArray; - cvfCoords->assign(polyLines[brIdx]); - - // Scale the centerline coordinates using the Z-scale transform of the grid. - - for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) - { - (*cvfCoords)[cIdx].transformPoint(scaleTransform->worldTransform()); - } - - (*cvfCoords)[0].z() += characteristicCellSize; - - pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); - auto surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); - auto centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); - - pbd.m_surfacePart = createStdSurfacePart(surfaceDrawable.p(), - wellPipeColor, - "FlattenedSimWellPipe", - sourceInfo.p()); - - pbd.m_centerLinePart = createStdLinePart(centerLineDrawable.p(), - wellPipeColor, - "FlattenedSimWellPipeCenterLine"); - model->addPart(pbd.m_surfacePart.p()); - model->addPart(pbd.m_centerLinePart.p()); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 1bdd72cd3d..6537664c13 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -73,7 +73,6 @@ class RivIntersectionPartMgr : public cvf::Object void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - void appendWellPipePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); const RimIntersection* intersection() const; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 6af5fa373e..458f374d78 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -313,48 +313,6 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di clippedWellPathCenterLine = RigWellPath::clipPolylineStartAboveZ(wellpathCenterLine, maxZClipHeight, &horizontalLengthAlongWellToClipPoint); - - #if 0 - size_t firstVisibleSegmentIndex = cvf::UNDEFINED_SIZE_T; - for ( size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++ ) - { - cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; - if ( point.z() < (wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance) ) - { - firstVisibleSegmentIndex = idx; - break; - } - } - - - - if ( firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T ) - { - if ( firstVisibleSegmentIndex > 0 ) - { - double wellPathStartPoint = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; - double stepsize = (wellPathStartPoint - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()) / - (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex].z() - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()); - - cvf::Vec3d newPoint = wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1] + - stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]); - - clippedPoints.push_back(newPoint); - m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); - } - else - { - m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); - } - - for ( size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++ ) - { - clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]); - } - - } - #endif - } else { diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index d04f930ee9..5903219d02 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -411,7 +411,6 @@ void Rim2dIntersectionView::createDisplayModel() m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->appendPolylinePartsToModel(*this, m_intersectionVizModel.p(), scaleTransform()); - m_flatIntersectionPartMgr->appendWellPipePartsToModel(m_intersectionVizModel.p(), scaleTransform()); m_flatIntersectionPartMgr->applySingleColorEffect(); From 7aa07d6a789bf52b4c016c6c081fb7ae75816d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 20 Mar 2018 15:32:32 +0100 Subject: [PATCH 0565/1027] #2486 Wellpaths now reports correct MD in 2D intersection views --- .../RicWellPathViewerEventHandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index 10b96ff7b5..43b4de3447 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -24,6 +24,7 @@ #include "Rim3dView.h" #include "RimPerforationInterval.h" #include "RimWellPath.h" +#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" @@ -34,6 +35,7 @@ #include "cvfPart.h" #include "cvfVector3.h" +#include "RivIntersectionPartMgr.h" //-------------------------------------------------------------------------------------------------- @@ -106,6 +108,16 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even cvf::ref transForm = rimView->displayCoordTransform(); cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); + auto intersectionView = dynamic_cast(rimView); + if (intersectionView) + { + cvf::Mat4d unflatXf = intersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(domainCoord); + if (!unflatXf.isZero()) + { + domainCoord = domainCoord.getTransformedPoint(unflatXf); + } + } + double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, domainCoord); // NOTE: This computation was used to find the location for a fracture when clicking on a well path From c22bafbf299f21a2d4a925a571b01d705ce13327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 20 Mar 2018 17:28:27 +0100 Subject: [PATCH 0566/1027] #2605 Show perforations along well path in 2D intersections view --- .../ModelVisualization/RivWellPathPartMgr.cpp | 68 ++++++++++++++++--- .../ModelVisualization/RivWellPathPartMgr.h | 11 ++- .../Rim2dIntersectionView.cpp | 23 +++++++ .../ReservoirDataModel/RigWellPath.cpp | 44 ++++++++---- .../ReservoirDataModel/RigWellPath.h | 7 +- 5 files changed, 127 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 458f374d78..c803627b35 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -164,7 +164,8 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, size_t timeStepIndex, const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize) + double characteristicCellSize, + bool doFlatten) { if (!m_rimWellPath || !m_rimWellPath->perforationIntervalCollection()->isChecked()) return; @@ -201,23 +202,53 @@ void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, m_rimWellPath->descendantsIncludingThisOfType(perforations); for (RimPerforationInterval* perforation : perforations) { + using namespace std; + if (!perforation->isChecked()) continue; if (perforation->startMD() > perforation->endMD()) continue; if (!perforation->isActiveOnDate(currentTimeStamp)) continue; + + double horizontalLengthAlongWellPath = 0.0; + vector perfIntervalCL; + { + pair, vector > perfintervalCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), + perforation->endMD(), + &horizontalLengthAlongWellPath); + perfIntervalCL = perfintervalCoordsAndMD.first; + } + + if (perfIntervalCL.size() < 2) continue; - using namespace std; - pair, vector > displayCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), - perforation->endMD()); - - if (displayCoordsAndMD.first.size() < 2) continue; - for (cvf::Vec3d& point : displayCoordsAndMD.first) point = displayCoordTransform->transformToDisplayCoord(point); + vector perfIntervalCLDiplayCS; + if ( doFlatten ) + { + cvf::Vec3d dummy; + vector flatningCSs = + RivSectionFlattner::calculateFlatteningCSsForPolyline(perfIntervalCL, + cvf::Vec3d::Z_AXIS, + { horizontalLengthAlongWellPath, 0.0, perfIntervalCL[0].z() }, + &dummy); + + for ( size_t cIdx = 0; cIdx < perfIntervalCL.size(); ++cIdx ) + { + auto clpoint = perfIntervalCL[cIdx].getTransformedPoint(flatningCSs[cIdx]); + perfIntervalCLDiplayCS.push_back( displayCoordTransform->scaleToDisplaySize(clpoint)); + } + } + else + { + for ( cvf::Vec3d& point : perfIntervalCL ) + { + perfIntervalCLDiplayCS.push_back( displayCoordTransform->transformToDisplayCoord(point)); + } + } cvf::ref objectSourceInfo = new RivObjectSourceInfo(perforation); cvf::Collection parts; - geoGenerator.cylinderWithCenterLineParts(&parts, displayCoordsAndMD.first, cvf::Color3f::GREEN, perforationRadius); + geoGenerator.cylinderWithCenterLineParts(&parts, perfIntervalCLDiplayCS, cvf::Color3f::GREEN, perforationRadius); for (auto part : parts) { part->setSourceInfo(objectSourceInfo.p()); @@ -503,7 +534,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* return; } - appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false); appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; @@ -521,6 +552,25 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + CVF_ASSERT(model); + + RimWellPathCollection* wellPathCollection = this->wellPathCollection(); + if (!wellPathCollection) return; + + if (m_rimWellPath.isNull()) return; + + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 073e2e1280..48bac977a9 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -74,7 +74,13 @@ class RivWellPathPartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox); - + + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); size_t segmentIndexFromTriangleIndex(size_t triangleIndex); @@ -91,7 +97,8 @@ class RivWellPathPartMgr : public cvf::Object void appendPerforationsToModel(cvf::ModelBasicList* model, size_t timeStepIndex, const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + double characteristicCellSize, + bool doFlatten); void appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, size_t timeStepIndex, diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 5903219d02..b32e0fd04b 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -503,6 +503,29 @@ void Rim2dIntersectionView::updateCurrentTimeStep() } } + if ( m_flatWellpathPartMgr.notNull() ) + { + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + { + cvf::String name = "WellPipeDynMod"; + Rim3dView::removeModelByName(frameScene, name); + cvf::ref dynWellPathModel = new cvf::ModelBasicList; + dynWellPathModel->setName(name); + + m_flatWellpathPartMgr->appendFlattenedDynamicGeometryPartsToModel(dynWellPathModel.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + this->ownerCase()->characteristicCellSize(), + this->ownerCase()->activeCellsBoundingBox()); + dynWellPathModel->updateBoundingBoxesRecursive(); + frameScene->addModel(dynWellPathModel.p()); + } + } + } + + if ((this->hasUserRequestedAnimation() && this->hasResults())) { m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep, diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index 15246758c7..d64ef4467c 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -59,19 +59,27 @@ double RigWellPath::datumElevation() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) const +cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint) const { cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO; - size_t i = 0; - while ( i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth ) + if (horizontalLengthAlongWellToStartClipPoint) *horizontalLengthAlongWellToStartClipPoint = 0.0; + + size_t vxIdx = 0; + while ( vxIdx < m_measuredDepths.size() && m_measuredDepths.at(vxIdx) < measuredDepth ) { - i++; + if ( vxIdx > 0 && horizontalLengthAlongWellToStartClipPoint) + { + cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToStartClipPoint += segment.length(); + } + vxIdx++; } - if ( m_measuredDepths.size() > i ) + if ( m_measuredDepths.size() > vxIdx ) { - if ( i == 0 ) + if ( vxIdx == 0 ) { //For measuredDepth same or lower than first point, use this first point wellPathPoint = m_wellPathPoints.at(0); @@ -79,15 +87,23 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) con else { //Do interpolation - double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) / - (m_measuredDepths.at(i) - m_measuredDepths.at(i - 1)); - wellPathPoint = m_wellPathPoints.at(i - 1) + stepsize * (m_wellPathPoints.at(i) - m_wellPathPoints.at(i-1)); + double segmentFraction = (measuredDepth - m_measuredDepths.at(vxIdx-1)) / + (m_measuredDepths.at(vxIdx) - m_measuredDepths.at(vxIdx - 1)); + cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1]; + + wellPathPoint = m_wellPathPoints[vxIdx - 1] + segmentFraction * segment; + + if ( horizontalLengthAlongWellToStartClipPoint ) + { + segment[2] = 0.0; + *horizontalLengthAlongWellToStartClipPoint += segment.length(); + } } } else { - //Use endpoint if measuredDepth same or higher than last point - wellPathPoint = m_wellPathPoints.at(i-1); + // Use endpoint if measuredDepth same or higher than last point + wellPathPoint = m_wellPathPoints.at(vxIdx-1); } @@ -188,13 +204,15 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair, std::vector > RigWellPath::clippedPointSubset(double startMD, double endMD) const +std::pair, std::vector > RigWellPath::clippedPointSubset(double startMD, + double endMD, + double * horizontalLengthAlongWellToStartClipPoint) const { std::pair, std::vector > pointsAndMDs; if ( m_measuredDepths.empty() ) return pointsAndMDs; if ( startMD > endMD ) return pointsAndMDs; - pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD)); + pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD, horizontalLengthAlongWellToStartClipPoint)); pointsAndMDs.second.push_back(startMD); for ( size_t i = 0; i < m_measuredDepths.size(); ++i ) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index cbfbd808d0..25735bf40f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -45,12 +45,15 @@ class RigWellPath : public cvf::Object void setDatumElevation(double value); bool hasDatumElevation() const; double datumElevation() const; - cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth) const; + cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; double wellPathAzimuthAngle(const cvf::Vec3d& position) const; void twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2) const; std::pair, std::vector > - clippedPointSubset(double startMD, double endMD) const; + clippedPointSubset(double startMD, + double endMD, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; std::vector wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const; From 8db8575d1e61259f4a0b91b66006c9283aac8398 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Mar 2018 15:10:41 +0100 Subject: [PATCH 0567/1027] #2625 Completion Type Legend : Only show categories present in the model --- .../ProjectDataModel/RimEclipseCellColors.cpp | 25 ++++++++++++++++--- .../RigCaseCellResultsData.cpp | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 24ef2cfd10..8498d7a6c5 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -400,10 +400,27 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); caf::AppEnum fracture(RiaDefines::FRACTURE); - categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); - categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); - categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); - categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + const std::vector& visibleCatetories = cellResultsData->uniqueCellScalarValues(this->scalarResultIndex()); + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), wellPath.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), fishbone.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), perforationInterval.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), fracture.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + } legendConfig->setCategoryItems(categories); } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 14ceec0997..fdb025eb30 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -633,6 +633,7 @@ void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, c if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return; m_cellScalarResults[scalarResultIndex].clear(); + recalculateStatistics(scalarResultIndex); //m_resultInfos[scalarResultIndex].m_resultType = RiaDefines::REMOVED; } From 4060e7e5a5fb16b716bf47ca7c56901012fd85fa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Mar 2018 07:41:55 +0100 Subject: [PATCH 0568/1027] #2631 Text Export to Eclipse : Generated text file has too many characters in line --- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 1 + .../FileInterface/RifEclipseDataTableFormatter.cpp | 8 ++++++++ .../FileInterface/RifEclipseDataTableFormatter.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index f92130f7d3..d9af082dc1 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -574,6 +574,7 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile( QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); + formatter.setColumnSpacing(3); for (const auto& gridCompletions : completionsPerGrid) { diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp index 4ed1a6a699..1502c3a986 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp @@ -36,6 +36,14 @@ RifEclipseDataTableFormatter::~RifEclipseDataTableFormatter() CVF_ASSERT(m_columns.empty()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseDataTableFormatter::setColumnSpacing(int spacing) +{ + m_colSpacing = spacing; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h index dab0e8fd8a..b64543d8b8 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h @@ -106,6 +106,8 @@ class RifEclipseDataTableFormatter RifEclipseDataTableFormatter(QTextStream& out); virtual ~RifEclipseDataTableFormatter(); + void setColumnSpacing(int spacing); + RifEclipseDataTableFormatter& keyword(const QString keyword); RifEclipseDataTableFormatter& header(std::vector tableHeader); RifEclipseDataTableFormatter& add(const QString str); From 41d92832a78e0dfd9da65f46f6cfdf7248d01ac8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Mar 2018 07:43:54 +0100 Subject: [PATCH 0569/1027] #2631 Whitespace --- .../RifEclipseDataTableFormatter.cpp | 31 ++++---- .../RifEclipseDataTableFormatter.h | 77 +++++++++---------- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp index 1502c3a986..368eb2267d 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -23,7 +23,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out) : m_out(out) +RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out) + : m_out(out) + , m_colSpacing(5) { } @@ -49,7 +51,7 @@ void RifEclipseDataTableFormatter::setColumnSpacing(int spacing) //-------------------------------------------------------------------------------------------------- void RifEclipseDataTableFormatter::outputBuffer() { - if (m_columns.size() > 0) + if (!m_columns.empty()) { m_out << "-- "; for (RifEclipseOutputTableColumn& column : m_columns) @@ -72,7 +74,8 @@ void RifEclipseDataTableFormatter::outputBuffer() { m_out << formatColumn(line.data[i], m_columns[i]); } - m_out << " /" << "\n"; + m_out << " /" + << "\n"; } } m_columns.clear(); @@ -211,7 +214,7 @@ RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::addZeroBasedCellInde void RifEclipseDataTableFormatter::rowCompleted() { RifEclipseOutputTableLine line; - line.data = m_lineBuffer; + line.data = m_lineBuffer; line.lineType = CONTENTS; m_buffer.push_back(line); m_lineBuffer.clear(); @@ -256,12 +259,12 @@ QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDo { switch (doubleFormat.format) { - case RifEclipseOutputTableDoubleFormat::RIF_FLOAT: - return QString("%1").arg(num, 0, 'f', doubleFormat.width); - case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC: - return QString("%1").arg(num, 0, 'E'); - default: - return QString("%1"); + case RifEclipseOutputTableDoubleFormat::RIF_FLOAT: + return QString("%1").arg(num, 0, 'f', doubleFormat.width); + case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC: + return QString("%1").arg(num, 0, 'E'); + default: + return QString("%1"); } } diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h index b64543d8b8..2981149e8e 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -56,7 +56,7 @@ enum RifEclipseOutputTableDoubleFormat struct RifEclipseOutputTableLine { RifEclipseOutputTableLineType lineType; - std::vector< QString > data; + std::vector data; }; //================================================================================================== @@ -65,13 +65,13 @@ struct RifEclipseOutputTableLine struct RifEclipseOutputTableDoubleFormatting { RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat format = RIF_FLOAT, int width = 5) - : format(format), - width(width) - {} - + : format(format) + , width(width) + { + } RifEclipseOutputTableDoubleFormat format; - int width; + int width; }; //================================================================================================== @@ -79,14 +79,14 @@ struct RifEclipseOutputTableDoubleFormatting //================================================================================================== struct RifEclipseOutputTableColumn { - RifEclipseOutputTableColumn(const QString& title, + RifEclipseOutputTableColumn(const QString& title, RifEclipseOutputTableDoubleFormatting doubleFormat = RifEclipseOutputTableDoubleFormatting(), - RifEclipseOutputTableAlignment alignment = LEFT, - int width = -1) - : title(title), - doubleFormat(doubleFormat), - alignment(alignment), - width(width) + RifEclipseOutputTableAlignment alignment = LEFT, + int width = -1) + : title(title) + , doubleFormat(doubleFormat) + , alignment(alignment) + , width(width) { } @@ -96,7 +96,6 @@ struct RifEclipseOutputTableColumn int width; }; - //================================================================================================== // //================================================================================================== @@ -108,35 +107,35 @@ class RifEclipseDataTableFormatter void setColumnSpacing(int spacing); - RifEclipseDataTableFormatter& keyword(const QString keyword); - RifEclipseDataTableFormatter& header(std::vector tableHeader); - RifEclipseDataTableFormatter& add(const QString str); - RifEclipseDataTableFormatter& add(double num); - RifEclipseDataTableFormatter& add(int num); - RifEclipseDataTableFormatter& add(size_t num); - RifEclipseDataTableFormatter& addZeroBasedCellIndex(size_t index); - RifEclipseDataTableFormatter& comment(const QString str); - void rowCompleted(); - void tableCompleted(); + RifEclipseDataTableFormatter& keyword(const QString keyword); + RifEclipseDataTableFormatter& header(std::vector tableHeader); + RifEclipseDataTableFormatter& add(const QString str); + RifEclipseDataTableFormatter& add(double num); + RifEclipseDataTableFormatter& add(int num); + RifEclipseDataTableFormatter& add(size_t num); + RifEclipseDataTableFormatter& addZeroBasedCellIndex(size_t index); + RifEclipseDataTableFormatter& comment(const QString str); + void rowCompleted(); + void tableCompleted(); private: - int measure(const QString str); - int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); - int measure(int num); - int measure(size_t num); + int measure(const QString str); + int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); + int measure(int num); + int measure(size_t num); - QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); - QString format(int num); - QString format(size_t num); - QString formatColumn(const QString str, RifEclipseOutputTableColumn column); + QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); + QString format(int num); + QString format(size_t num); + QString formatColumn(const QString str, RifEclipseOutputTableColumn column); - void outputBuffer(); - void outputComment(RifEclipseOutputTableLine& comment); + void outputBuffer(); + void outputComment(RifEclipseOutputTableLine& comment); private: std::vector m_columns; std::vector m_buffer; std::vector m_lineBuffer; QTextStream& m_out; - int m_colSpacing = 5; + int m_colSpacing; }; From 0f696b81fe18b0be7b92d4e54fbee96594e1a1f6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Mar 2018 09:06:16 +0100 Subject: [PATCH 0570/1027] #2625 Completion Type Legend : Update property editor categories --- .../ProjectDataModel/RimEclipsePropertyFilter.cpp | 15 +++++++++++---- .../ProjectDataModel/RimEclipseView.cpp | 12 ++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index f771a2cebf..349fa4f4a9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -389,12 +389,19 @@ void RimEclipsePropertyFilter::computeResultValueRange() } else if (resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) { - std::vector ctNames; - for (QString ctName : caf::AppEnum::uiTexts()) + std::vector> categoryNameAndValues; { - ctNames.push_back(ctName); + const std::vector& visibleCatetories = results->uniqueCellScalarValues(resultDefinition->scalarResultIndex()); + for (auto categoryValue : visibleCatetories) + { + if (caf::AppEnum::isValid(categoryValue)) + { + auto text = caf::AppEnum::uiText(RiaDefines::CompletionType(categoryValue)); + categoryNameAndValues.push_back(std::make_pair(text, categoryValue)); + } + } } - setCategoryNames(ctNames); + setCategoryNamesAndValues(categoryNameAndValues); } else { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 332576e67a..3893ef477e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1360,7 +1360,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { std::vector metaData; cellEdgeResult()->cellEdgeMetaData(&metaData); - for (const auto cellEdgeMeta : metaData) + for (const auto& cellEdgeMeta : metaData) { if (cellEdgeMeta.m_resultVariable == RiaDefines::completionTypeResultName()) { @@ -1374,7 +1374,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() isDependingOnCompletionType = true; } - for (auto propFilter : m_propertyFilterCollection()->propertyFilters) + for (const auto& propFilter : m_propertyFilterCollection()->propertyFilters) { if (propFilter->isActive() && propFilter->resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) { @@ -1386,6 +1386,14 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { this->loadDataAndUpdate(); } + + for (const auto& propFilter : m_propertyFilterCollection()->propertyFilters) + { + if (propFilter->isActive() && propFilter->resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) + { + propFilter->updateConnectedEditors(); + } + } } //-------------------------------------------------------------------------------------------------- From ca8e56cff13a13089e6c7de012489c24d37c7ee0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Mar 2018 10:16:37 +0100 Subject: [PATCH 0571/1027] Perforation Interval : Do not cast to int when creating new perf interval --- .../RicNewPerforationIntervalAtMeasuredDepthFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp index bf1fc79aa9..eb61d16f4b 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp @@ -51,7 +51,7 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isC if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; RimPerforationInterval* perforationInterval = new RimPerforationInterval; - int measuredDepth = wellPathSelItem->m_measuredDepth; + double measuredDepth = wellPathSelItem->m_measuredDepth; perforationInterval->setStartAndEndMD(measuredDepth, measuredDepth + 50); wellPath->perforationIntervalCollection()->appendPerforation(perforationInterval); From 131eb647487379545bf9e5205bc29f236281181b Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 21 Mar 2018 09:48:51 +0100 Subject: [PATCH 0572/1027] #2633 3D well log curves: Clip grid on well path bounding box --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 36 ++++++++++++++----- .../Riv3dWellLogCurveGeomertyGenerator.h | 6 ++++ .../Riv3dWellLogPlanePartMgr.cpp | 28 +++++++++------ .../Riv3dWellLogPlanePartMgr.h | 22 +++++++----- .../ModelVisualization/RivWellPathPartMgr.cpp | 2 +- 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 055a9708c2..7eb415cd24 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -21,6 +21,7 @@ #include "RimCase.h" #include "RimGridView.h" #include "RimWellPath.h" +#include "RimWellPathCollection.h" #include "RigCurveDataTools.h" #include "RigWellPath.h" @@ -28,6 +29,8 @@ #include "cafDisplayCoordTransform.h" #include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfBoundingBox.h" + #include //-------------------------------------------------------------------------------------------------- @@ -65,32 +68,47 @@ cvf::ref /// //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve::DrawPlane drawPlane, - double gridIntervalSize) const + double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); if (!wellPathGeometry()) return nullptr; + if (!wellPathClipBoundingBox.isValid()) return nullptr; + + RimWellPathCollection* wellPathCollection = nullptr; + m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; if (wellPathPoints.empty()) return nullptr; - const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); - const cvf::Vec3d up(0, 0, 1); + size_t originalWellPathSize = wellPathPoints.size(); + + if (wellPathCollection->wellPathClip) + { + double horizontalLengthAlongWellToClipPoint; + double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + wellPathPoints = + RigWellPath::clipPolylineStartAboveZ(wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint); + } + if (wellPathPoints.empty()) return nullptr; std::vector pointNormals; std::vector gridPoints; - double firstMd = wellPathGeometry()->m_measuredDepths.front(); - double lastMd = wellPathGeometry()->m_measuredDepths.back(); if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; - double md = firstMd; - while (md <= lastMd) + size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); + double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + + double md = lastMd; + while (md >= firstMd) { cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); gridPoints.push_back(point); - md += gridIntervalSize; + md -= gridIntervalSize; } pointNormals = calculatePointNormals(drawPlane, gridPoints); @@ -201,7 +219,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim vertices->resize(interpolatedWellPathPoints.size()); double plotRangeToResultRangeFactor = gridWidth() / (maxResult - minResult); - double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); for (size_t i = 0; i < pointNormals.size(); i++) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 17ec52a37f..48e30330be 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -34,6 +34,11 @@ namespace caf class DisplayCoordTransform; } +namespace cvf +{ +class BoundingBox; +} + class RigWellPath; class RimGridView; class RimWellPath; @@ -48,6 +53,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const Rim3dWellLogCurve* rim3dWellLogCurve) const; cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve::DrawPlane drawPlane, double gridIntervalSize) const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 78516d3cd4..7bebfb219f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -26,6 +26,7 @@ #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" +#include "cvfBoundingBox.h" #include "cvfColor3.h" #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" @@ -35,7 +36,8 @@ /// //-------------------------------------------------------------------------------------------------- Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView) - :m_wellPath(wellPath), m_gridView(gridView) + : m_wellPath(wellPath) + , m_gridView(gridView) { } @@ -57,8 +59,9 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { if (!rim3dWellLogCurve->toggleState()) continue; - - cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); + + cvf::ref curveDrawable = + m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -66,7 +69,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* } caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.9f, 0.0f, 0.0f)); - cvf::ref effect = meshEffectGen.generateCachedEffect(); + cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = new cvf::Part; part->setDrawable(curveDrawable.p()); @@ -93,9 +96,12 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) +void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double gridIntervalSize) { if (m_3dWellLogCurveGeometryGenerator.isNull()) { @@ -105,10 +111,11 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); { - cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize); + cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( + displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); if (part.notNull()) { @@ -116,10 +123,11 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con } } { - cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize); + cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( + displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); if (part.notNull()) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 350ae98733..80e7e4fced 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -29,15 +29,16 @@ namespace cvf { - class ModelBasicList; - class Drawable; - class Effect; - class Part; -} +class ModelBasicList; +class Drawable; +class Effect; +class Part; +class BoundingBox; +} // namespace cvf namespace caf { - class DisplayCoordTransform; +class DisplayCoordTransform; } class RimGridView; @@ -49,15 +50,18 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object public: Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView); - void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, + void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, std::vector rim3dWellLogCurves); - void appendGridToModel(cvf::ModelBasicList* model, + void appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, - double gridIntervalSize); + const cvf::BoundingBox& wellPathClipBoundingBox, + double gridIntervalSize); + private: cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); + private: cvf::ref m_3dWellLogCurveGeometryGenerator; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index c803627b35..06f5806f5f 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -548,7 +548,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) { - m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, 200); + m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 200); } } From 687ddcb0a6ec7e3d57c4d1e440f72684adb209bf Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 21 Mar 2018 10:54:17 +0100 Subject: [PATCH 0573/1027] #2591 3D well log curves: Only add grid if curve is added --- ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 06f5806f5f..b92f96929d 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -539,6 +539,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; + if (m_rimWellPath->vectorOf3dWellLogCurves().empty()) return; RimGridView* gridView = dynamic_cast(m_rimView.p()); if (!gridView) return; From b20b633c40918e9d7bd0178ce2134febe14d57af Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Mar 2018 13:14:22 +0100 Subject: [PATCH 0574/1027] #2633 3D well log curves: Use currect normals when making grid --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 7eb415cd24..e7e5559ab3 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -70,7 +70,7 @@ cvf::ref cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve::DrawPlane drawPlane, - double gridIntervalSize) const + double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); @@ -94,7 +94,6 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } if (wellPathPoints.empty()) return nullptr; - std::vector pointNormals; std::vector gridPoints; if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; @@ -111,6 +110,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const md -= gridIntervalSize; } + std::vector pointNormals; + pointNormals = calculatePointNormals(drawPlane, gridPoints); if (pointNormals.size() != gridPoints.size()) return nullptr; @@ -121,7 +122,6 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const indices.reserve(gridPoints.size() * 2); cvf::uint counter = 0; - double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); // Normal lines @@ -136,7 +136,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const indices.push_back(counter++); } + // calculateWellPathSegmentNormals returns normals for the whole well path. Erase the part which is clipped off std::vector wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane); + wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); // Line along and close to well for (size_t i = 0; i < wellPathPoints.size(); i++) From a1d82fcffaaac58c157deaa0d3a18da4575346da Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Mar 2018 13:15:48 +0100 Subject: [PATCH 0575/1027] #2633 3D well log curves: Clip curve on well path bounding box --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 40 +++++++++++++++---- .../Riv3dWellLogCurveGeomertyGenerator.h | 2 + .../Riv3dWellLogPlanePartMgr.cpp | 5 ++- .../Riv3dWellLogPlanePartMgr.h | 2 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 4 +- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index e7e5559ab3..e3c967ec3c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -38,12 +38,13 @@ //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve) const { std::vector vertices; std::vector indices; - createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, &vertices, &indices); + createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); if (vertices.empty() || indices.empty()) { @@ -181,10 +182,13 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const //-------------------------------------------------------------------------------------------------- void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, std::vector* indices) const { if (!wellPathGeometry()) return; + if (wellPathGeometry()->m_wellPathPoints.empty()) return; + if (!wellPathClipBoundingBox.isValid()) return; std::vector resultValues; std::vector mds; @@ -193,17 +197,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == mds.size()); - cvf::Vec3d globalDirection = - (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); + RimWellPathCollection* wellPathCollection = nullptr; + m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); + + double maxZClipHeight = wellPathGeometry()->m_wellPathPoints.front().z(); + if (wellPathCollection->wellPathClip) + { + maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + } std::vector interpolatedWellPathPoints; - interpolatedWellPathPoints.reserve(mds.size()); - for (double md : mds) + for (auto rit = mds.rbegin(); rit != mds.rend(); rit++) { - interpolatedWellPathPoints.push_back(wellPathGeometry()->interpolatedPointAlongWellPath(md)); + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*rit); + if (point.z() > maxZClipHeight) break; + + interpolatedWellPathPoints.push_back(point); } + if (interpolatedWellPathPoints.size() % 2 != 0) + { + interpolatedWellPathPoints.pop_back(); + } + + std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); + + if (interpolatedWellPathPoints.empty()) return; + + resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size()); + std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; @@ -258,9 +281,12 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal std::vector pointNormals; if (!wellPathGeometry()) return pointNormals; + if (points.empty()) return pointNormals; + pointNormals.reserve(points.size()); - const cvf::Vec3d globalDirection = (points.back() - points.front()).getNormalized(); + const cvf::Vec3d globalDirection = + (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); const cvf::Vec3d up(0, 0, 1); for (const cvf::Vec3d point : points) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 48e30330be..349e19c620 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -50,6 +50,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object : m_wellPath(wellPath), m_gridView(gridView) {}; cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve) const; cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, @@ -60,6 +61,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object private: void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, std::vector* indices) const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 7bebfb219f..f9409541af 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -46,8 +46,9 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri //-------------------------------------------------------------------------------------------------- void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, - std::vector rim3dWellLogCurves) + const cvf::BoundingBox& wellPathClipBoundingBox) { + std::vector rim3dWellLogCurves = m_wellPath->vectorOf3dWellLogCurves(); if (rim3dWellLogCurves.empty()) return; if (m_wellPath.isNull()) return; @@ -61,7 +62,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (!rim3dWellLogCurve->toggleState()) continue; cvf::ref curveDrawable = - m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); + m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 80e7e4fced..139ed2b586 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -52,7 +52,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, - std::vector rim3dWellLogCurves); + const cvf::BoundingBox& wellPathClipBoundingBox); void appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index b92f96929d..27352f9aac 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -545,7 +545,9 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!gridView) return; m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); - m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); + m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, + displayCoordTransform, + wellPathClipBoundingBox); if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) { From e688b3de36274d1e5457bf46781c5b0d764fde2a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Mar 2018 13:46:03 +0100 Subject: [PATCH 0576/1027] #2591 3D well log curves: Increase size of offset between pipe and plot --- .../ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp | 4 ++-- ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index e3c967ec3c..b39ca500ae 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -415,7 +415,7 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con { double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - return m_wellPath->wellPathRadius(cellSize) * 1.2; + return m_wellPath->wellPathRadius(cellSize) * 2; } //-------------------------------------------------------------------------------------------------- @@ -423,7 +423,7 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con //-------------------------------------------------------------------------------------------------- double Riv3dWellLogCurveGeometryGenerator::gridWidth() const { - return 100; + return 400; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 27352f9aac..9304f41181 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -551,7 +551,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) { - m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 200); + m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 800); } } From 2b4e26aacad89d24ff188a9af5d290dd981443de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 13:47:22 +0100 Subject: [PATCH 0577/1027] #2630, #2605 unfalltenedTransformMatrix now returns mx[0] and mx[last] for points before and after end. --- .../RivIntersectionGeometryGenerator.cpp | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index 3b0b946c7a..f0abc155d5 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -565,34 +565,27 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const //-------------------------------------------------------------------------------------------------- cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) { - cvf::Vec3d startPt = cvf::Vec3d::ZERO; + cvf::Mat4d flattenMx = cvf::Mat4d::IDENTITY; - int polyLineIdx = -1; - int segIdx = -1; - for (size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++) + for ( size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++ ) { - std::vector polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx]; + const std::vector& polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx]; for(size_t pIdx = 0; pIdx < polyLine.size(); pIdx++) { - // Assumes ascending sorted list - if (pIdx > 0 && intersectionPointFlat.x() < polyLine[pIdx].x()) + if (polyLine[pIdx].x() >= intersectionPointFlat.x() ) { - polyLineIdx = static_cast(pLineIdx); - segIdx = static_cast(pIdx) - 1; - startPt = polyLine[segIdx]; + size_t csIdx = pIdx > 0 ? pIdx - 1: 0; + flattenMx = m_segementTransformPrLinePoint[pLineIdx][csIdx]; break; } + else if (pIdx == polyLine.size() - 1) + { + flattenMx = m_segementTransformPrLinePoint[pLineIdx][pIdx]; + } } - - if (!startPt.isZero()) break; } - if (polyLineIdx > -1 && segIdx > -1) - { - cvf::Mat4d t = m_segementTransformPrLinePoint[polyLineIdx][segIdx]; - return t.getInverted(); // Check for invertible? - } - return cvf::Mat4d::ZERO; + return flattenMx.getInverted(); } //-------------------------------------------------------------------------------------------------- From 24955d0dddebf65e53155bdc4df69946b95b9894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 13:49:58 +0100 Subject: [PATCH 0578/1027] #2630 convenince method to convert to utm coordiantes for intersectino points in 2d intersection view --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 10 ++++++++++ .../ProjectDataModel/Rim2dIntersectionView.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index b32e0fd04b..8624ba0bfd 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -302,6 +302,16 @@ cvf::ref Rim2dIntersectionView::flatIntersectionPartMgr( return m_flatIntersectionPartMgr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Rim2dIntersectionView::transformToUtm(const cvf::Vec3d& unscaledPointInFlatDomain) const +{ + cvf::Mat4d unflatXf = this->flatIntersectionPartMgr()->unflattenTransformMatrix(unscaledPointInFlatDomain); + + return unscaledPointInFlatDomain.getTransformedPoint(unflatXf); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index c323c23010..af53f03d4c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -62,7 +62,7 @@ class Rim2dIntersectionView : public Rim3dView void update3dInfo(); cvf::ref flatIntersectionPartMgr() const; - + cvf::Vec3d transformToUtm(const cvf::Vec3d& unscaledPointInFlatDomain) const; virtual cvf::ref displayCoordTransform() const override; From 375bda8b68e9cc4c0c85dff34387702b30a66a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 13:51:39 +0100 Subject: [PATCH 0579/1027] Rename --- ApplicationCode/UserInterface/RiuSelectionManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.h b/ApplicationCode/UserInterface/RiuSelectionManager.h index a736bc5a61..fa19b98b7c 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.h +++ b/ApplicationCode/UserInterface/RiuSelectionManager.h @@ -236,7 +236,7 @@ class RiuWellPathSelectionItem : public RiuSelectionItem { public: explicit RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo, - const cvf::Vec3d& currentPickPositionInDomainCoords, + const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords, double measuredDepth); virtual ~RiuWellPathSelectionItem() {}; From 25ff51c82b3e74a5d2f5b1ecadd745906b771e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 13:56:24 +0100 Subject: [PATCH 0580/1027] #2630 Fix wrong picked MD on clipped well paths --- .../ModelVisualization/RivWellPathPartMgr.cpp | 9 ++++++--- .../ProjectDataModel/RimIntersection.cpp | 8 +++++--- .../ReservoirDataModel/RigWellPath.cpp | 16 +++++++++++++--- ApplicationCode/ReservoirDataModel/RigWellPath.h | 3 ++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index c803627b35..dd8f82725f 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -312,7 +312,6 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di m_pipeGeomGenerator->setRadius(wellPathRadius); m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - double horizontalLengthAlongWellToClipPoint = 0.0; std::vector clippedWellPathCenterLine; @@ -338,12 +337,15 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di } } + double horizontalLengthAlongWellToClipPoint = 0.0; + size_t idxToFirstVisibleSegment = 0; if ( wellPathCollection->wellPathClip ) { double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; clippedWellPathCenterLine = RigWellPath::clipPolylineStartAboveZ(wellpathCenterLine, maxZClipHeight, - &horizontalLengthAlongWellToClipPoint); + &horizontalLengthAlongWellToClipPoint, + &idxToFirstVisibleSegment); } else { @@ -379,6 +381,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di } } + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(idxToFirstVisibleSegment); m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); m_surfaceDrawable = m_pipeGeomGenerator->createPipeSurface(); m_centerLineDrawable = m_pipeGeomGenerator->createCenterLine(); @@ -388,7 +391,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di m_surfacePart = new cvf::Part; m_surfacePart->setDrawable(m_surfaceDrawable.p()); - RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); + RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_pipeGeomGenerator.p()); m_surfacePart->setSourceInfo(sourceInfo); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 57727baefb..116d1dd608 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -407,9 +407,11 @@ std::vector< std::vector > RimIntersection::polyLines(cvf::Vec3d * this->firstAncestorOrThisOfType(ownerCase); if (ownerCase) { - lines[0] = RigWellPath::clipPolylineStartAboveZ(lines[0], - ownerCase->activeCellsBoundingBox().max().z(), - &horizontalProjectedLengthAlongWellPathToClipPoint); + size_t dummy; + lines[0] = RigWellPath::clipPolylineStartAboveZ(lines[0], + ownerCase->activeCellsBoundingBox().max().z(), + &horizontalProjectedLengthAlongWellPathToClipPoint, + &dummy); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index d64ef4467c..fa91079c86 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -292,13 +292,17 @@ bool RigWellPath::isPolylineTouchingBBox(const std::vector &polyLine //-------------------------------------------------------------------------------------------------- std::vector RigWellPath::clipPolylineStartAboveZ(const std::vector& polyLine, double maxZ, - double * horizontalLengthAlongWellToClipPoint) + double * horizontalLengthAlongWellToClipPoint, + size_t * indexToFirstVisibleSegment) { - CVF_ASSERT(horizontalLengthAlongWellToClipPoint != nullptr); + CVF_ASSERT(horizontalLengthAlongWellToClipPoint); + CVF_ASSERT(indexToFirstVisibleSegment); // Find first visible point, and accumulate distance along wellpath *horizontalLengthAlongWellToClipPoint = 0.0; + *indexToFirstVisibleSegment = cvf::UNDEFINED_SIZE_T; + size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T; for ( size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx ) @@ -345,8 +349,14 @@ std::vector RigWellPath::clipPolylineStartAboveZ(const std::vector clipPolylineStartAboveZ(const std::vector &polyLine, double maxZ, - double * horizontalLengthAlongWellToClipPoint); + double * horizontalLengthAlongWellToClipPoint, + size_t * indexToFirstVisibleSegment); private: bool m_hasDatumElevation; From dd29a3c727a358ad3882c7825f6e1eb8c82a2395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 13:57:21 +0100 Subject: [PATCH 0581/1027] #2634 Fix wrong MD when context menu creating completions in 2D intersectino View --- .../RicWellPathViewerEventHandler.cpp | 15 +++++-------- .../ModelVisualization/RivWellPathPartMgr.cpp | 8 ------- .../ModelVisualization/RivWellPathPartMgr.h | 2 -- .../RivWellPathSourceInfo.cpp | 21 ++++++++++++++----- .../RivWellPathSourceInfo.h | 15 +++++++------ .../RivWellPathsPartMgr.cpp | 11 ---------- .../ModelVisualization/RivWellPathsPartMgr.h | 2 -- .../ProjectDataModel/Rim3dView.cpp | 8 ------- ApplicationCode/ProjectDataModel/Rim3dView.h | 2 -- .../UserInterface/RiuViewerCommands.cpp | 9 +++++--- 10 files changed, 36 insertions(+), 57 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index 43b4de3447..a1646279af 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -106,24 +106,19 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even if (!rimView) return false; cvf::ref transForm = rimView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); + cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); - auto intersectionView = dynamic_cast(rimView); - if (intersectionView) + if (auto intersectionView = dynamic_cast(rimView)) { - cvf::Mat4d unflatXf = intersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(domainCoord); - if (!unflatXf.isZero()) - { - domainCoord = domainCoord.getTransformedPoint(unflatXf); - } + pickedPositionInUTM = intersectionView->transformToUtm(pickedPositionInUTM); } - double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, domainCoord); + double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, pickedPositionInUTM); // NOTE: This computation was used to find the location for a fracture when clicking on a well path // It turned out that the computation was a bit inaccurate // Consider to use code in RigSimulationWellCoordsAndMD instead - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(wellPathTriangleIndex, domainCoord); + cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->closestPointOnCenterLine(wellPathTriangleIndex, pickedPositionInUTM); QString wellPathText; wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name()); diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index dd8f82725f..9e6cf5f287 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -587,14 +587,6 @@ void RivWellPathPartMgr::clearAllBranchData() m_wellLabelPart = nullptr; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RivWellPathPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex) -{ - return m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 48bac977a9..f6190892cb 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -83,8 +83,6 @@ class RivWellPathPartMgr : public cvf::Object void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); - size_t segmentIndexFromTriangleIndex(size_t triangleIndex); - private: void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp index 82d459e092..1890ad3b90 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp @@ -24,6 +24,8 @@ #include "RimCase.h" #include "RimWellPath.h" #include "Rim3dView.h" +#include "RivPipeGeometryGenerator.h" + #include "RimWellPathCollection.h" #include "RivWellPathPartMgr.h" @@ -33,10 +35,19 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view) +RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath, RivPipeGeometryGenerator* pipeGeomGenerator) + : m_wellPath(wellPath) + , m_pipeGeomGenerator(pipeGeomGenerator) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathSourceInfo::~RivWellPathSourceInfo() { - m_wellPath = wellPath; - m_view = view; + } //-------------------------------------------------------------------------------------------------- @@ -66,7 +77,7 @@ double RivWellPathSourceInfo::measuredDepth(size_t triangleIndex, const cvf::Vec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RivWellPathSourceInfo::trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const +cvf::Vec3d RivWellPathSourceInfo::closestPointOnCenterLine(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const { size_t firstSegmentIndex = cvf::UNDEFINED_SIZE_T; double norm = 0.0; @@ -105,6 +116,6 @@ void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const c //-------------------------------------------------------------------------------------------------- size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const { - return m_view->wellPathSegmentIndexFromTriangleIndex(triangleIndex, m_wellPath); + return m_pipeGeomGenerator->segmentIndexFromTriangleIndex( triangleIndex); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h index 716bf92ee5..563a1613a8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h @@ -26,7 +26,7 @@ #include "cvfVector3.h" class RimWellPath; -class Rim3dView; +class RivPipeGeometryGenerator; //================================================================================================== /// @@ -34,19 +34,22 @@ class Rim3dView; class RivWellPathSourceInfo : public cvf::Object { public: - explicit RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view); + explicit RivWellPathSourceInfo(RimWellPath* wellPath, RivPipeGeometryGenerator* pipeGeomGenerator); + ~RivWellPathSourceInfo(); RimWellPath* wellPath() const; size_t segmentIndex(size_t triangleIndex) const; double measuredDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; - cvf::Vec3d trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; + cvf::Vec3d closestPointOnCenterLine(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; private: - void normalizedIntersection(size_t triangleIndex, const cvf::Vec3d& globalIntersection, - size_t* firstSegmentIndex, double* normalizedSegmentIntersection) const; + void normalizedIntersection(size_t triangleIndex, + const cvf::Vec3d& globalIntersection, + size_t* firstSegmentIndex, + double* normalizedSegmentIntersection) const; private: caf::PdmPointer m_wellPath; - caf::PdmPointer m_view; + cvf::ref m_pipeGeomGenerator; }; diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index 3237a1bde2..bd6c2a94d8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -93,17 +93,6 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RivWellPathsPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const -{ - auto it = m_mapFromViewToIndex.find(wellPath); - if (it == m_mapFromViewToIndex.end()) return -1; - - return it->second->segmentIndexFromTriangleIndex(triangleIndex); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index 5f30339930..0c01eba7c8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -68,8 +68,6 @@ class RivWellPathsPartMgr : public cvf::Object void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); - size_t segmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; - private: void clearGeometryCache(); void scheduleGeometryRegen(); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 4fc5b6b008..adc50adbac 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -862,14 +862,6 @@ cvf::ref Rim3dView::displayCoordTransform() const return coordTrans; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t Rim3dView::wellPathSegmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const -{ - return m_wellPathsPartManager->segmentIndexFromTriangleIndex(triangleIndex, wellPath); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index d632662cc8..95f3dedfd8 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -146,8 +146,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface cvf::ref displayCoordTransform() const override; - size_t wellPathSegmentIndexFromTriangleIndex(size_t triangleIndex, RimWellPath* wellPath) const; - virtual RimCase* ownerCase() const = 0; protected: diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index f4f5087dfc..fab2e2ba2a 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -343,9 +343,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) { if (firstPartTriangleIndex != cvf::UNDEFINED_UINT) { - double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, m_currentPickPositionInDomainCoords); - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, globalIntersectionPoint); - RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, trueVerticalDepth, measuredDepth); + cvf::Vec3d pickedPositionInUTM = m_currentPickPositionInDomainCoords; + if (int2dView) pickedPositionInUTM = int2dView->transformToUtm(pickedPositionInUTM); + + double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, pickedPositionInUTM); + cvf::Vec3d closestPointOnCenterLine = wellPathSourceInfo->closestPointOnCenterLine(firstPartTriangleIndex, pickedPositionInUTM); + RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, closestPointOnCenterLine, measuredDepth); RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); } From 39106fdf99ae5e3a3bf3f992d562c5a1b3378e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 21 Mar 2018 14:21:27 +0100 Subject: [PATCH 0582/1027] #2605 Place perforation intervals correct horizontally in 2D Intersection View --- ApplicationCode/ReservoirDataModel/RigWellPath.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index fa91079c86..c567673ce3 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -91,7 +91,8 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, dou (m_measuredDepths.at(vxIdx) - m_measuredDepths.at(vxIdx - 1)); cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1]; - wellPathPoint = m_wellPathPoints[vxIdx - 1] + segmentFraction * segment; + segment *= segmentFraction; + wellPathPoint = m_wellPathPoints[vxIdx - 1] + segment; if ( horizontalLengthAlongWellToStartClipPoint ) { From 1369b11e6edbaba679a4e9692055b91376445650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 21 Mar 2018 14:47:07 +0100 Subject: [PATCH 0583/1027] #2555 Guarding for nullptr and some minor fixes --- .../Commands/RicSummaryCaseRestartDialog.cpp | 5 +++++ .../FileInterface/RifReaderEclipseSummary.cpp | 10 +++++++--- .../FileInterface/RifReaderEclipseSummary.h | 1 + .../FileInterface/RifSummaryCaseRestartSelector.cpp | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index b2289c17e9..0e98159131 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -132,6 +132,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const RicSummaryCaseRestartDialog dialog(parent); RifRestartFileInfo currentFileInfo = dialog.getFileInfo(summaryHeaderFile); + if (!currentFileInfo.valid()) + { + return RicSummaryCaseRestartDialogResult(); + } + dialog.appendFileInfoToGridLayout(*dialog.m_currentFileGridLayout, currentFileInfo); std::vector fileInfos = dialog.getRestartFiles(summaryHeaderFile); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index be87be0e62..2e8582c81b 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -40,10 +40,14 @@ std::vector getTimeSteps(ecl_sum_type* ecl_sum) { std::vector timeSteps; - for (int time_index = 0; time_index < ecl_sum_get_data_length(ecl_sum); time_index++) + + if (ecl_sum) { - time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, time_index); - timeSteps.push_back(sim_time); + for (int time_index = 0; time_index < ecl_sum_get_data_length(ecl_sum); time_index++) + { + time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, time_index); + timeSteps.push_back(sim_time); + } } return timeSteps; } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index cb234924cf..656ead8d49 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -38,6 +38,7 @@ class RifRestartFileInfo { public: RifRestartFileInfo() : startDate(0), endDate(0) {} + bool valid() { return !fileName.isEmpty(); } QString fileName; time_t startDate; diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 793a73753f..ecc171d449 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -105,8 +105,8 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp filesToImport.push_back(fi); } } + lastResult = result; } - lastResult = result; } return std::vector(filesToImport.begin(), filesToImport.end()); } From 85cd8b0e1d76b0d90981c93ea426d37e07f55fb9 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Mar 2018 15:32:03 +0100 Subject: [PATCH 0584/1027] 3D Well Log Curve: Give Plane Part Mgr more responsibility --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 140 ++++++++---------- .../Riv3dWellLogCurveGeomertyGenerator.h | 22 ++- .../Riv3dWellLogPlanePartMgr.cpp | 65 +++++--- .../Riv3dWellLogPlanePartMgr.h | 15 +- .../ModelVisualization/RivWellPathPartMgr.cpp | 15 +- .../ModelVisualization/RivWellPathPartMgr.h | 2 +- .../ProjectDataModel/RimWellPath.cpp | 8 - .../ProjectDataModel/RimWellPath.h | 1 - 8 files changed, 133 insertions(+), 135 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index d78d87e406..2265a78580 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -116,8 +116,11 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } std::vector pointNormals; + + std::vector closestPoints; + calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints); - pointNormals = calculatePointNormals(drawPlane, gridPoints); + pointNormals = calculateLineSegmentNormals(drawPlane, closestPoints, LINE_SEGMENTS); if (pointNormals.size() != gridPoints.size()) return nullptr; std::vector vertices; @@ -142,7 +145,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } // calculateWellPathSegmentNormals returns normals for the whole well path. Erase the part which is clipped off - std::vector wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane); + std::vector wellPathSegmentNormals = calculateLineSegmentNormals(drawPlane, wellPathGeometry()->m_wellPathPoints, POLYLINE); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); // Line along and close to well @@ -161,6 +164,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth())))); + indices.push_back(counter); indices.push_back(++counter); } @@ -231,7 +235,10 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size()); - std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); + std::vector closestPoints; + calculatePairsOfClosestPointsAlongWellPath(&closestPoints, interpolatedWellPathPoints); + + std::vector pointNormals = calculateLineSegmentNormals(rim3dWellLogCurve->drawPlane(), closestPoints, LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; @@ -279,94 +286,38 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, - const std::vector& points) const +std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& vertices, + VertexOrganization organization) const { std::vector pointNormals; if (!wellPathGeometry()) return pointNormals; - if (points.empty()) return pointNormals; + if (vertices.empty()) return pointNormals; - pointNormals.reserve(points.size()); const cvf::Vec3d globalDirection = (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); const cvf::Vec3d up(0, 0, 1); - for (const cvf::Vec3d point : points) + size_t intervalSize; + if (organization == LINE_SEGMENTS) { - cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; - cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - wellPathGeometry()->twoClosestPoints(point, &p1, &p2); - if (p1.isUndefined() || p2.isUndefined()) continue; - - cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); - - double dotProduct = up * vecAlongPath; - - cvf::Vec3d Ex; - - if (cvf::Math::abs(dotProduct) > 0.7071) - { - Ex = globalDirection; - } - else - { - Ex = vecAlongPath; - } - - cvf::Vec3d Ey = (up ^ Ex).getNormalized(); - cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - - cvf::Vec3d normal; - - switch (drawPlane) - { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; - } - - pointNormals.push_back(normal); + pointNormals.reserve(vertices.size() / 2); + intervalSize = 2; + } + else //organization == POLYLINE + { + pointNormals.reserve(vertices.size()); + intervalSize = 1; } - - return pointNormals; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector - Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const -{ - std::vector wellSegmentNormals; - - if (!wellPathGeometry()) return wellSegmentNormals; - - std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; - - const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); - const cvf::Vec3d up(0, 0, 1); cvf::Vec3d normal; - - for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + + for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) { - cvf::Vec3d p1 = wellPathPoints[i]; - cvf::Vec3d p2 = wellPathPoints[i + 1]; - - if (p1.isUndefined() || p2.isUndefined()) continue; + cvf::Vec3d p1 = vertices[i]; + cvf::Vec3d p2 = vertices[i+1]; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -386,6 +337,7 @@ std::vector cvf::Vec3d Ey = (up ^ Ex).getNormalized(); cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); + switch (drawPlane) { case Rim3dWellLogCurve::HORIZONTAL_LEFT: @@ -404,12 +356,15 @@ std::vector break; } - wellSegmentNormals.push_back(normal); + pointNormals.push_back(normal); } - wellSegmentNormals.push_back(normal); + if (organization == POLYLINE) + { + pointNormals.push_back(normal); + } - return wellSegmentNormals; + return pointNormals; } //-------------------------------------------------------------------------------------------------- @@ -417,6 +372,8 @@ std::vector //-------------------------------------------------------------------------------------------------- double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const { + if (!m_gridView) return 0; + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); return m_wellPath->wellPathRadius(cellSize) * 2; @@ -427,7 +384,11 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con //-------------------------------------------------------------------------------------------------- double Riv3dWellLogCurveGeometryGenerator::gridWidth() const { - return 400; + if (!m_gridView) return 0; + + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + + return m_wellPath->wellPathRadius(cellSize) * 3; } //-------------------------------------------------------------------------------------------------- @@ -437,3 +398,22 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const { return m_wellPath->wellPathGeometry(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestPointsAlongWellPath(std::vector* closestWellPathPoints, std::vector& points) const +{ + CVF_ASSERT(closestWellPathPoints != nullptr); + + for (const cvf::Vec3d point : points) + { + cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; + cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; + wellPathGeometry()->twoClosestPoints(point, &p1, &p2); + if (p1.isUndefined() || p2.isUndefined()) continue; + + closestWellPathPoints->push_back(p1); + closestWellPathPoints->push_back(p2); + } +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 349e19c620..91d847254f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -47,10 +47,11 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) - : m_wellPath(wellPath), m_gridView(gridView) {}; + : m_wellPath(wellPath) + , m_gridView(gridView){}; cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, + const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve) const; cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, @@ -58,6 +59,13 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const Rim3dWellLogCurve::DrawPlane drawPlane, double gridIntervalSize) const; +private: + enum VertexOrganization + { + LINE_SEGMENTS, + POLYLINE + }; + private: void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, const caf::DisplayCoordTransform* displayCoordTransform, @@ -65,16 +73,18 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector* vertices, std::vector* indices) const; - std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, - const std::vector& points) const; - - std::vector calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const; + std::vector calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + const std::vector& vertices, + VertexOrganization organization) const; double wellPathCenterToPlotStartOffset() const; double gridWidth() const; const RigWellPath* wellPathGeometry() const; + void calculatePairsOfClosestPointsAlongWellPath(std::vector* closestWellPathPoints, + std::vector& points) const; + private: caf::PdmPointer m_wellPath; caf::PdmPointer m_gridView; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index f9409541af..ebb1aa1379 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,6 +18,7 @@ #include "Riv3dWellLogPlanePartMgr.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimGridView.h" #include "RimWellPath.h" @@ -41,6 +42,39 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (m_wellPath.isNull()) return; + + if (!m_wellPath->rim3dWellLogCurveCollection()) return; + + if (!m_wellPath->rim3dWellLogCurveCollection()->showPlot()) return; + + if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; + + append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox); + + if (m_wellPath->rim3dWellLogCurveCollection()->showGrid()) + { + std::map drawPlanes; + + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) + { + drawPlanes[rim3dWellLogCurve->drawPlane()]; + } + + for (const std::pair& drawPlane : drawPlanes) + { + appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane.first, 400); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -48,16 +82,16 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox) { - std::vector rim3dWellLogCurves = m_wellPath->vectorOf3dWellLogCurves(); - if (rim3dWellLogCurves.empty()) return; if (m_wellPath.isNull()) return; + if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; + if (m_3dWellLogCurveGeometryGenerator.isNull()) { m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); } - for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { if (!rim3dWellLogCurve->toggleState()) continue; @@ -99,11 +133,14 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double gridIntervalSize) +void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve::DrawPlane& drawPlane, + double gridIntervalSize) { + if (m_wellPath.isNull()) return; + if (m_3dWellLogCurveGeometryGenerator.isNull()) { m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); @@ -113,19 +150,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* { cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize); - - cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); - - if (part.notNull()) - { - model->addPart(part.p()); - } - } - { - cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize); + displayCoordTransform, wellPathClipBoundingBox, drawPlane, gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 139ed2b586..755e3bf2bb 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -50,16 +50,19 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object public: Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView); + void appendPlaneToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox); +private: void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox); - void appendGridToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double gridIntervalSize); - -private: + void appendGridToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve::DrawPlane& drawPlane, + double gridIntervalSize); cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); private: diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index a5bc562efe..243abeb15a 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -540,22 +540,11 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false); appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); - if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; - if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; - if (m_rimWellPath->vectorOf3dWellLogCurves().empty()) return; - RimGridView* gridView = dynamic_cast(m_rimView.p()); if (!gridView) return; - m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); - m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, - displayCoordTransform, - wellPathClipBoundingBox); - - if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) - { - m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 800); - } + m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); + m_3dWellLogPlanePartMgr->appendPlaneToModel(model, displayCoordTransform, wellPathClipBoundingBox); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index f6190892cb..ab1f660877 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -124,6 +124,6 @@ class RivWellPathPartMgr : public cvf::Object cvf::ref m_centerLineDrawable; cvf::ref m_wellLabelPart; - cvf::ref m_3dWellLogCurvePartMgr; + cvf::ref m_3dWellLogPlanePartMgr; cvf::ref m_wellConnectionFactorPartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 46fb52a932..87ca37e852 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -809,14 +809,6 @@ void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) m_3dWellLogCurves->add3dWellLogCurve(rim3dWellLogCurve); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimWellPath::vectorOf3dWellLogCurves() const -{ - return m_3dWellLogCurves->vectorOf3dWellLogCurves(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 09f75682af..3cc8721ed1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -80,7 +80,6 @@ class RimWellPath : public caf::PdmObject const RigWellPathFormations* formationsGeometry() const; void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve); - std::vector vectorOf3dWellLogCurves() const; Rim3dWellLogCurveCollection* rim3dWellLogCurveCollection() const; virtual caf::PdmFieldHandle* userDescriptionField() override; From 26d83983b142dc1434cae0dd9270d6dc50aafa0b Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Wed, 21 Mar 2018 16:22:35 +0100 Subject: [PATCH 0585/1027] 3D well log curve: add comments --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 86 +++++++++++-------- .../Riv3dWellLogCurveGeomertyGenerator.h | 4 +- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 2265a78580..0961cd8ec1 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -33,6 +33,15 @@ #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) + : m_wellPath(wellPath) + , m_gridView(gridView) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -90,12 +99,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { double horizontalLengthAlongWellToClipPoint; double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; - size_t indexToFirstVisibleSegment; - wellPathPoints = - RigWellPath::clipPolylineStartAboveZ(wellPathPoints, - maxZClipHeight, - &horizontalLengthAlongWellToClipPoint, - &indexToFirstVisibleSegment); + size_t indexToFirstVisibleSegment; + wellPathPoints = RigWellPath::clipPolylineStartAboveZ( + wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); } if (wellPathPoints.empty()) return nullptr; @@ -116,7 +122,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const } std::vector pointNormals; - + std::vector closestPoints; calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints); @@ -129,7 +135,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector indices; indices.reserve(gridPoints.size() * 2); - cvf::uint counter = 0; + cvf::uint indexCounter = 0; + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); // Normal lines @@ -137,15 +144,17 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { vertices.push_back(cvf::Vec3f( displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter + gridWidth())))); - indices.push_back(counter++); - indices.push_back(counter++); + indices.push_back(indexCounter++); + indices.push_back(indexCounter++); } - // calculateWellPathSegmentNormals returns normals for the whole well path. Erase the part which is clipped off - std::vector wellPathSegmentNormals = calculateLineSegmentNormals(drawPlane, wellPathGeometry()->m_wellPathPoints, POLYLINE); + // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off + std::vector wellPathSegmentNormals = + calculateLineSegmentNormals(drawPlane, wellPathGeometry()->m_wellPathPoints, POLYLINE); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); // Line along and close to well @@ -153,9 +162,12 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); - indices.push_back(counter); - indices.push_back(++counter); + + indices.push_back(indexCounter); + indices.push_back(++indexCounter); } + // Indices are added as line segments for the current point and the next point. The last point does not have a next point, + // therefore we remove the last line segment indices.pop_back(); indices.pop_back(); @@ -165,8 +177,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth())))); - indices.push_back(counter); - indices.push_back(++counter); + indices.push_back(indexCounter); + indices.push_back(++indexCounter); } indices.pop_back(); indices.pop_back(); @@ -199,11 +211,11 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim if (!wellPathClipBoundingBox.isValid()) return; std::vector resultValues; - std::vector mds; - rim3dWellLogCurve->curveValuesAndMds(&resultValues, &mds); + std::vector resultMds; + rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); if (resultValues.empty()) return; - CVF_ASSERT(resultValues.size() == mds.size()); + CVF_ASSERT(resultValues.size() == resultMds.size()); RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); @@ -216,29 +228,32 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim std::vector interpolatedWellPathPoints; - for (auto rit = mds.rbegin(); rit != mds.rend(); rit++) + // Iterate from bottom of well path and up to be able to stop at given Z max clipping height + for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) { - cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*rit); + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*md); if (point.z() > maxZClipHeight) break; interpolatedWellPathPoints.push_back(point); } + if (interpolatedWellPathPoints.empty()) return; if (interpolatedWellPathPoints.size() % 2 != 0) { interpolatedWellPathPoints.pop_back(); } - - std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); - if (interpolatedWellPathPoints.empty()) return; + // Reverse list, since it was filled in the wrong order + std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); + // Erase the result values for the part of the well which is clipped off, to match interpolatedWellPathPoints size resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size()); - std::vector closestPoints; - calculatePairsOfClosestPointsAlongWellPath(&closestPoints, interpolatedWellPathPoints); + std::vector pairsOfWellPathPoints; + calculatePairsOfClosestPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); - std::vector pointNormals = calculateLineSegmentNormals(rim3dWellLogCurve->drawPlane(), closestPoints, LINE_SEGMENTS); + std::vector pointNormals = + calculateLineSegmentNormals(rim3dWellLogCurve->drawPlane(), pairsOfWellPathPoints, LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; @@ -295,9 +310,9 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment if (!wellPathGeometry()) return pointNormals; if (vertices.empty()) return pointNormals; - const cvf::Vec3d globalDirection = (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); + const cvf::Vec3d up(0, 0, 1); size_t intervalSize; @@ -306,18 +321,18 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment pointNormals.reserve(vertices.size() / 2); intervalSize = 2; } - else //organization == POLYLINE + else // organization == POLYLINE { pointNormals.reserve(vertices.size()); intervalSize = 1; } cvf::Vec3d normal; - + for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) { cvf::Vec3d p1 = vertices[i]; - cvf::Vec3d p2 = vertices[i+1]; + cvf::Vec3d p2 = vertices[i + 1]; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -337,7 +352,6 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment cvf::Vec3d Ey = (up ^ Ex).getNormalized(); cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - switch (drawPlane) { case Rim3dWellLogCurve::HORIZONTAL_LEFT: @@ -373,7 +387,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const { if (!m_gridView) return 0; - + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); return m_wellPath->wellPathRadius(cellSize) * 2; @@ -400,9 +414,11 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestPointsAlongWellPath(std::vector* closestWellPathPoints, std::vector& points) const +void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestPointsAlongWellPath( + std::vector* closestWellPathPoints, + std::vector& points) const { CVF_ASSERT(closestWellPathPoints != nullptr); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 91d847254f..a30c792893 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -46,9 +46,7 @@ class RimWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) - : m_wellPath(wellPath) - , m_gridView(gridView){}; + Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView); cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, From 9e4d271d5b17eb6e1e02b28e2feb50823b061de1 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 08:54:48 +0100 Subject: [PATCH 0586/1027] #2591 3D well log curves: Use an angle to deretmine draw plane --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 63 ++++++++----------- .../Riv3dWellLogCurveGeomertyGenerator.h | 14 +++-- .../Riv3dWellLogPlanePartMgr.cpp | 44 ++++++++++--- .../Riv3dWellLogPlanePartMgr.h | 2 + 4 files changed, 69 insertions(+), 54 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 0961cd8ec1..fbf8d25c1a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -48,12 +48,15 @@ Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPa cvf::ref Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve* rim3dWellLogCurve) const + const std::vector& resultValues, + const std::vector& resultMds, + double rotationAngle) const { std::vector vertices; std::vector indices; - createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); + createCurveVerticesAndIndices( + resultValues, resultMds, rotationAngle, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); if (vertices.empty() || indices.empty()) { @@ -79,8 +82,8 @@ cvf::ref //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve::DrawPlane drawPlane, - double gridIntervalSize) const + double angle, + double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); @@ -126,7 +129,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector closestPoints; calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints); - pointNormals = calculateLineSegmentNormals(drawPlane, closestPoints, LINE_SEGMENTS); + pointNormals = calculateLineSegmentNormals(angle, closestPoints, LINE_SEGMENTS); if (pointNormals.size() != gridPoints.size()) return nullptr; std::vector vertices; @@ -154,7 +157,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off std::vector wellPathSegmentNormals = - calculateLineSegmentNormals(drawPlane, wellPathGeometry()->m_wellPathPoints, POLYLINE); + calculateLineSegmentNormals(angle, wellPathGeometry()->m_wellPathPoints, POLYLINE); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); // Line along and close to well @@ -200,7 +203,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, +void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector& resultValues, + const std::vector& resultMds, + double angle, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, @@ -210,10 +215,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim if (wellPathGeometry()->m_wellPathPoints.empty()) return; if (!wellPathClipBoundingBox.isValid()) return; - std::vector resultValues; - std::vector resultMds; - rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); - if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == resultMds.size()); @@ -243,23 +244,23 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim interpolatedWellPathPoints.pop_back(); } - // Reverse list, since it was filled in the wrong order + // Reverse list, since it was filled in the opposite order std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); - // Erase the result values for the part of the well which is clipped off, to match interpolatedWellPathPoints size - resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size()); + // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size + std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), + resultValues.end()); std::vector pairsOfWellPathPoints; calculatePairsOfClosestPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); - std::vector pointNormals = - calculateLineSegmentNormals(rim3dWellLogCurve->drawPlane(), pairsOfWellPathPoints, LINE_SEGMENTS); + std::vector pointNormals = calculateLineSegmentNormals(angle, pairsOfWellPathPoints, LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; double minResult = HUGE_VAL; - for (double result : resultValues) + for (double result : resultValuesForInterpolatedPoints) { if (!RigCurveDataTools::isValidValue(result, false)) continue; @@ -276,9 +277,10 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim { double scaledResult = 0; - if (RigCurveDataTools::isValidValue(resultValues[i], false)) + if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false)) { - scaledResult = offsetFromWellPathCenter + (resultValues[i] - minResult) * plotRangeToResultRangeFactor; + scaledResult = + offsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor; } (*vertices)[i] = cvf::Vec3f( @@ -286,7 +288,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim } std::vector> valuesIntervals = - RigCurveDataTools::calculateIntervalsOfValidValues(resultValues, false); + RigCurveDataTools::calculateIntervalsOfValidValues(resultValuesForInterpolatedPoints, false); for (const std::pair& interval : valuesIntervals) { @@ -301,7 +303,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane, +std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(double angle, const std::vector& vertices, VertexOrganization organization) const { @@ -352,23 +354,8 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment cvf::Vec3d Ey = (up ^ Ex).getNormalized(); cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); - switch (drawPlane) - { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - normal = -Ey; - break; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - normal = Ey; - break; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - normal = Ez; - break; - case Rim3dWellLogCurve::VERTICAL_BELOW: - normal = -Ez; - break; - default: - break; - } + cvf::Mat3d rotation; + normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle)); pointNormals.push_back(normal); } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index a30c792893..1f3fd6b7da 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -25,8 +25,6 @@ #include "cafPdmPointer.h" -#include "Rim3dWellLogCurve.h" - #include namespace caf @@ -50,11 +48,13 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve* rim3dWellLogCurve) const; + const std::vector& resultValues, + const std::vector& resultMds, + double rotationAngle) const; cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve::DrawPlane drawPlane, + double angle, double gridIntervalSize) const; private: @@ -65,13 +65,15 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object }; private: - void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, + void createCurveVerticesAndIndices(const std::vector& resultValues, + const std::vector& resultMds, + double angle, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, std::vector* indices) const; - std::vector calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane, + std::vector calculateLineSegmentNormals(double angle, const std::vector& vertices, VertexOrganization organization) const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index ebb1aa1379..4fdba7e766 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -50,9 +50,9 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* const cvf::BoundingBox& wellPathClipBoundingBox) { if (m_wellPath.isNull()) return; - + if (!m_wellPath->rim3dWellLogCurveCollection()) return; - + if (!m_wellPath->rim3dWellLogCurveCollection()->showPlot()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; @@ -95,8 +95,12 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* { if (!rim3dWellLogCurve->toggleState()) continue; - cvf::ref curveDrawable = - m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve); + std::vector resultValues; + std::vector resultMds; + rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); + + cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine( + displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, angle(rim3dWellLogCurve->drawPlane())); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -133,11 +137,31 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve::DrawPlane& drawPlane, - double gridIntervalSize) +double Riv3dWellLogPlanePartMgr::angle(const Rim3dWellLogCurve::DrawPlane& drawPlane) +{ + switch (drawPlane) + { + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + return cvf::PI_D; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + return 0.0; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + return cvf::PI_D / 2.0; + case Rim3dWellLogCurve::VERTICAL_BELOW: + return -cvf::PI_D / 2.0; + default: + return 0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve::DrawPlane& drawPlane, + double gridIntervalSize) { if (m_wellPath.isNull()) return; @@ -150,7 +174,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* { cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, drawPlane, gridIntervalSize); + displayCoordTransform, wellPathClipBoundingBox, angle(drawPlane), gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 755e3bf2bb..f33093620a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -65,6 +65,8 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object double gridIntervalSize); cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); + static double angle(const Rim3dWellLogCurve::DrawPlane& drawPlane); + private: cvf::ref m_3dWellLogCurveGeometryGenerator; From 3547240fe6da4f9aa264cf790298961132695bdb Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 09:54:58 +0100 Subject: [PATCH 0587/1027] #2591 3D well log curves: Remove view from geometry generator --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 64 ++++++---------- .../Riv3dWellLogCurveGeomertyGenerator.h | 21 +++--- .../Riv3dWellLogPlanePartMgr.cpp | 73 +++++++++++++------ .../Riv3dWellLogPlanePartMgr.h | 8 +- 4 files changed, 91 insertions(+), 75 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index fbf8d25c1a..ce4cedf369 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,8 +18,6 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" -#include "RimCase.h" -#include "RimGridView.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -36,9 +34,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) +Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath) : m_wellPath(wellPath) - , m_gridView(gridView) { } @@ -50,13 +47,15 @@ cvf::ref const cvf::BoundingBox& wellPathClipBoundingBox, const std::vector& resultValues, const std::vector& resultMds, - double rotationAngle) const + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth) const { std::vector vertices; std::vector indices; createCurveVerticesAndIndices( - resultValues, resultMds, rotationAngle, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); + resultValues, resultMds, planeAngle, planeOffsetFromWellPathCenter, planeWidth, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); if (vertices.empty() || indices.empty()) { @@ -82,7 +81,9 @@ cvf::ref //-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - double angle, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); @@ -129,7 +130,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector closestPoints; calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints); - pointNormals = calculateLineSegmentNormals(angle, closestPoints, LINE_SEGMENTS); + pointNormals = calculateLineSegmentNormals(planeAngle, closestPoints, LINE_SEGMENTS); if (pointNormals.size() != gridPoints.size()) return nullptr; std::vector vertices; @@ -140,16 +141,16 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint indexCounter = 0; - double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); + //double planeOffsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter + gridWidth())))); + gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); indices.push_back(indexCounter++); indices.push_back(indexCounter++); @@ -157,14 +158,14 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off std::vector wellPathSegmentNormals = - calculateLineSegmentNormals(angle, wellPathGeometry()->m_wellPathPoints, POLYLINE); + calculateLineSegmentNormals(planeAngle, wellPathGeometry()->m_wellPathPoints, POLYLINE); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); // Line along and close to well for (size_t i = 0; i < wellPathPoints.size(); i++) { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); + wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); indices.push_back(indexCounter); indices.push_back(++indexCounter); @@ -178,7 +179,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const for (size_t i = 0; i < wellPathPoints.size(); i++) { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth())))); + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); indices.push_back(indexCounter); indices.push_back(++indexCounter); @@ -205,7 +206,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const //-------------------------------------------------------------------------------------------------- void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector& resultValues, const std::vector& resultMds, - double angle, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, @@ -254,7 +257,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std std::vector pairsOfWellPathPoints; calculatePairsOfClosestPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); - std::vector pointNormals = calculateLineSegmentNormals(angle, pairsOfWellPathPoints, LINE_SEGMENTS); + std::vector pointNormals = calculateLineSegmentNormals(planeAngle, pairsOfWellPathPoints, LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; @@ -270,8 +273,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std vertices->resize(interpolatedWellPathPoints.size()); - double plotRangeToResultRangeFactor = gridWidth() / (maxResult - minResult); - double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); + double plotRangeToResultRangeFactor = planeWidth / (maxResult - minResult); for (size_t i = 0; i < pointNormals.size(); i++) { @@ -280,7 +282,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false)) { scaledResult = - offsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor; + planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor; } (*vertices)[i] = cvf::Vec3f( @@ -368,30 +370,6 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment return pointNormals; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const -{ - if (!m_gridView) return 0; - - double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - - return m_wellPath->wellPathRadius(cellSize) * 2; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double Riv3dWellLogCurveGeometryGenerator::gridWidth() const -{ - if (!m_gridView) return 0; - - double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - - return m_wellPath->wellPathRadius(cellSize) * 3; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 1f3fd6b7da..851f4738ca 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -38,23 +38,28 @@ class BoundingBox; } class RigWellPath; -class RimGridView; class RimWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView); + Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath); cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, const std::vector& resultValues, const std::vector& resultMds, - double rotationAngle) const; + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth) const; + + cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - double angle, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, double gridIntervalSize) const; private: @@ -67,7 +72,9 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object private: void createCurveVerticesAndIndices(const std::vector& resultValues, const std::vector& resultMds, - double angle, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, std::vector* vertices, @@ -77,9 +84,6 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const std::vector& vertices, VertexOrganization organization) const; - double wellPathCenterToPlotStartOffset() const; - double gridWidth() const; - const RigWellPath* wellPathGeometry() const; void calculatePairsOfClosestPointsAlongWellPath(std::vector* closestWellPathPoints, @@ -87,5 +91,4 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object private: caf::PdmPointer m_wellPath; - caf::PdmPointer m_gridView; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 4fdba7e766..a0de8b7d28 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -32,6 +32,8 @@ #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" #include "cvfPart.h" +#include "Rim3dView.h" +#include "RimCase.h" //-------------------------------------------------------------------------------------------------- /// @@ -83,13 +85,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* const cvf::BoundingBox& wellPathClipBoundingBox) { if (m_wellPath.isNull()) return; - + if (!m_wellPath->rim3dWellLogCurveCollection()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; - - if (m_3dWellLogCurveGeometryGenerator.isNull()) - { - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); - } + + create3dWellLogCurveGeometryGenerator(); for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { @@ -100,7 +99,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine( - displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, angle(rim3dWellLogCurve->drawPlane())); + displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, angle(rim3dWellLogCurve->drawPlane()), wellPathCenterToPlotStartOffset(), planeWidth()); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -154,6 +153,43 @@ double Riv3dWellLogPlanePartMgr::angle(const Rim3dWellLogCurve::DrawPlane& drawP } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset() const +{ + if (!m_gridView) return 0; + + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + + return -cellSize * 2; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogPlanePartMgr::planeWidth() const +{ + if (!m_gridView) return 0; + + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + + return cellSize * 4; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::create3dWellLogCurveGeometryGenerator() +{ + if (m_wellPath.isNull()) return; + + if (m_3dWellLogCurveGeometryGenerator.isNull()) + { + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -163,25 +199,18 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurve::DrawPlane& drawPlane, double gridIntervalSize) { - if (m_wellPath.isNull()) return; - - if (m_3dWellLogCurveGeometryGenerator.isNull()) - { - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); - } + create3dWellLogCurveGeometryGenerator(); caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - { - cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, angle(drawPlane), gridIntervalSize); + cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( + displayCoordTransform, wellPathClipBoundingBox, angle(drawPlane), wellPathCenterToPlotStartOffset(), planeWidth(), gridIntervalSize); - cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + cvf::ref effect = meshEffectGen.generateCachedEffect(); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); - if (part.notNull()) - { - model->addPart(part.p()); - } + if (part.notNull()) + { + model->addPart(part.p()); } } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index f33093620a..3d1e4ffd7e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -34,7 +34,7 @@ class Drawable; class Effect; class Part; class BoundingBox; -} // namespace cvf +} namespace caf { @@ -63,10 +63,16 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve::DrawPlane& drawPlane, double gridIntervalSize); + cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); static double angle(const Rim3dWellLogCurve::DrawPlane& drawPlane); + double wellPathCenterToPlotStartOffset() const; + double planeWidth() const; + + void create3dWellLogCurveGeometryGenerator(); + private: cvf::ref m_3dWellLogCurveGeometryGenerator; From ef1cb3468bb5eba38345c86b9ac2dd3fa7e6c848 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 11:45:11 +0100 Subject: [PATCH 0588/1027] 3D well log curves: Code cleanup --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 25 ++++++----- .../Riv3dWellLogCurveGeomertyGenerator.h | 7 +--- .../Riv3dWellLogPlanePartMgr.cpp | 42 +++++++------------ .../Riv3dWellLogPlanePartMgr.h | 4 +- .../Rim3dWellLogCurveCollection.cpp | 4 +- .../Completions/Rim3dWellLogCurveCollection.h | 5 +-- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 2 +- .../ProjectDataModel/Rim3dWellLogCurve.h | 2 +- .../ProjectDataModel/Rim3dWellLogRftCurve.h | 2 +- 9 files changed, 36 insertions(+), 57 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index ce4cedf369..8b37d4e28b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -54,8 +54,15 @@ cvf::ref std::vector vertices; std::vector indices; - createCurveVerticesAndIndices( - resultValues, resultMds, planeAngle, planeOffsetFromWellPathCenter, planeWidth, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices); + createCurveVerticesAndIndices(resultValues, + resultMds, + planeAngle, + planeOffsetFromWellPathCenter, + planeWidth, + displayCoordTransform, + wellPathClipBoundingBox, + &vertices, + &indices); if (vertices.empty() || indices.empty()) { @@ -128,7 +135,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector pointNormals; std::vector closestPoints; - calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints); + calculatePairsOfClosestSamplingPointsAlongWellPath(&closestPoints, gridPoints); pointNormals = calculateLineSegmentNormals(planeAngle, closestPoints, LINE_SEGMENTS); if (pointNormals.size() != gridPoints.size()) return nullptr; @@ -141,8 +148,6 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint indexCounter = 0; - //double planeOffsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); - // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { @@ -242,11 +247,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std } if (interpolatedWellPathPoints.empty()) return; - if (interpolatedWellPathPoints.size() % 2 != 0) - { - interpolatedWellPathPoints.pop_back(); - } - // Reverse list, since it was filled in the opposite order std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); @@ -255,7 +255,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std resultValues.end()); std::vector pairsOfWellPathPoints; - calculatePairsOfClosestPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); + calculatePairsOfClosestSamplingPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); std::vector pointNormals = calculateLineSegmentNormals(planeAngle, pairsOfWellPathPoints, LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; @@ -354,7 +354,6 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegment } cvf::Vec3d Ey = (up ^ Ex).getNormalized(); - cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); cvf::Mat3d rotation; normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle)); @@ -381,7 +380,7 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestPointsAlongWellPath( +void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestSamplingPointsAlongWellPath( std::vector* closestWellPathPoints, std::vector& points) const { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 851f4738ca..b6afb3d420 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -53,15 +53,12 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double planeOffsetFromWellPathCenter, double planeWidth) const; - - cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, double gridIntervalSize) const; - private: enum VertexOrganization { @@ -86,8 +83,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const RigWellPath* wellPathGeometry() const; - void calculatePairsOfClosestPointsAlongWellPath(std::vector* closestWellPathPoints, - std::vector& points) const; + void calculatePairsOfClosestSamplingPointsAlongWellPath(std::vector* closestWellPathPoints, + std::vector& points) const; private: caf::PdmPointer m_wellPath; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index a0de8b7d28..efa8fc3676 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,7 +18,9 @@ #include "Riv3dWellLogPlanePartMgr.h" +#include "Rim3dView.h" #include "Rim3dWellLogCurveCollection.h" +#include "RimCase.h" #include "RimGridView.h" #include "RimWellPath.h" @@ -32,8 +34,6 @@ #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "Rim3dView.h" -#include "RimCase.h" //-------------------------------------------------------------------------------------------------- /// @@ -42,6 +42,8 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri : m_wellPath(wellPath) , m_gridView(gridView) { + CVF_ASSERT(m_wellPath.notNull()); + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); } //-------------------------------------------------------------------------------------------------- @@ -55,24 +57,24 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* if (!m_wellPath->rim3dWellLogCurveCollection()) return; - if (!m_wellPath->rim3dWellLogCurveCollection()->showPlot()) return; + if (!m_wellPath->rim3dWellLogCurveCollection()->isShowingPlot()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox); - if (m_wellPath->rim3dWellLogCurveCollection()->showGrid()) + if (m_wellPath->rim3dWellLogCurveCollection()->isShowingGrid()) { - std::map drawPlanes; + std::set drawPlanes; for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { - drawPlanes[rim3dWellLogCurve->drawPlane()]; + drawPlanes.insert(rim3dWellLogCurve->drawPlane()); } - for (const std::pair& drawPlane : drawPlanes) + for (const Rim3dWellLogCurve::DrawPlane& drawPlane : drawPlanes) { - appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane.first, 400); + appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane, planeWidth()); } } } @@ -88,18 +90,16 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (!m_wellPath->rim3dWellLogCurveCollection()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; - create3dWellLogCurveGeometryGenerator(); - for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { - if (!rim3dWellLogCurve->toggleState()) continue; + if (!rim3dWellLogCurve->isShowingCurve()) continue; std::vector resultValues; std::vector resultMds; rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine( - displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, angle(rim3dWellLogCurve->drawPlane()), wellPathCenterToPlotStartOffset(), planeWidth()); + displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, planeAngle(rim3dWellLogCurve->drawPlane()), wellPathCenterToPlotStartOffset(), planeWidth()); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -136,7 +136,7 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::angle(const Rim3dWellLogCurve::DrawPlane& drawPlane) +double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane) { switch (drawPlane) { @@ -177,18 +177,6 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const return cellSize * 4; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::create3dWellLogCurveGeometryGenerator() -{ - if (m_wellPath.isNull()) return; - - if (m_3dWellLogCurveGeometryGenerator.isNull()) - { - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); - } -} //-------------------------------------------------------------------------------------------------- /// @@ -199,12 +187,10 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurve::DrawPlane& drawPlane, double gridIntervalSize) { - create3dWellLogCurveGeometryGenerator(); - caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, angle(drawPlane), wellPathCenterToPlotStartOffset(), planeWidth(), gridIntervalSize); + displayCoordTransform, wellPathClipBoundingBox, planeAngle(drawPlane), wellPathCenterToPlotStartOffset(), planeWidth(), gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 3d1e4ffd7e..9a5c51b4f7 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -66,13 +66,11 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); - static double angle(const Rim3dWellLogCurve::DrawPlane& drawPlane); + static double planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane); double wellPathCenterToPlotStartOffset() const; double planeWidth() const; - void create3dWellLogCurveGeometryGenerator(); - private: cvf::ref m_3dWellLogCurveGeometryGenerator; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 63f606b471..f85a1e8169 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -69,7 +69,7 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dWellLogCurveCollection::showGrid() const +bool Rim3dWellLogCurveCollection::isShowingGrid() const { return m_showGrid; } @@ -77,7 +77,7 @@ bool Rim3dWellLogCurveCollection::showGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dWellLogCurveCollection::showPlot() const +bool Rim3dWellLogCurveCollection::isShowingPlot() const { return m_showPlot; } diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 4fd57ec4dc..b8acdb99c8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -39,12 +39,11 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); - bool showGrid() const; - bool showPlot() const; + bool isShowingGrid() const; + bool isShowingPlot() const; std::vector vectorOf3dWellLogCurves() const; - private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 900bc94156..bf2b81b5e5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -105,7 +105,7 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dWellLogCurve::toggleState() const +bool Rim3dWellLogCurve::isShowingCurve() const { return m_showCurve; } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 6e5c83550b..9b5ad87ea7 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -61,7 +61,7 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); DrawPlane drawPlane() const; - bool toggleState() const; + bool isShowingCurve() const; virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h index 72e1f04a3a..638c573aa1 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -31,7 +31,7 @@ class RimEclipseResultCase; class QString; //================================================================================================== -/// +/// Not in use yet /// //================================================================================================== class Rim3dWellLogRftCurve : public Rim3dWellLogCurve From 7024ee045c70fc4ace243b801cb5abef4e306d23 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 12:54:31 +0100 Subject: [PATCH 0589/1027] #2591 3D well log curve: Add option to place at the side of the well --- .../Riv3dWellLogPlanePartMgr.cpp | 45 ++++++++++++++----- .../Riv3dWellLogPlanePartMgr.h | 3 +- .../Rim3dWellLogCurveCollection.cpp | 32 +++++++++++++ .../Completions/Rim3dWellLogCurveCollection.h | 16 ++++++- 4 files changed, 83 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index efa8fc3676..7b06fb0e9a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -89,7 +89,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (m_wellPath.isNull()) return; if (!m_wellPath->rim3dWellLogCurveCollection()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; - + + const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { if (!rim3dWellLogCurve->isShowingCurve()) continue; @@ -98,8 +101,14 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* std::vector resultMds; rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); - cvf::ref curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine( - displayCoordTransform, wellPathClipBoundingBox, resultValues, resultMds, planeAngle(rim3dWellLogCurve->drawPlane()), wellPathCenterToPlotStartOffset(), planeWidth()); + cvf::ref curveDrawable = + m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, + wellPathClipBoundingBox, + resultValues, + resultMds, + planeAngle(rim3dWellLogCurve->drawPlane()), + wellPathCenterToPlotStartOffset(planePosition), + planeWidth()); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -154,19 +163,26 @@ double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurve::DrawPlane& } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset() const +double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const { if (!m_gridView) return 0; double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - return -cellSize * 2; + if (planePosition == Rim3dWellLogCurveCollection::ALONG_WELLPATH) + { + return m_wellPath->wellPathRadius(cellSize) * 2; + } + else + { + return -cellSize * 2; + } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double Riv3dWellLogPlanePartMgr::planeWidth() const { @@ -177,7 +193,6 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const return cellSize * 4; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -187,13 +202,21 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurve::DrawPlane& drawPlane, double gridIntervalSize) { + const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); + caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - cvf::ref gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid( - displayCoordTransform, wellPathClipBoundingBox, planeAngle(drawPlane), wellPathCenterToPlotStartOffset(), planeWidth(), gridIntervalSize); + cvf::ref gridHorizontalDrawable = + m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, + wellPathClipBoundingBox, + planeAngle(drawPlane), + wellPathCenterToPlotStartOffset(planePosition), + planeWidth(), + gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); if (part.notNull()) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 9a5c51b4f7..fcbe95854a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -22,6 +22,7 @@ #include "cvfObject.h" #include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" #include "cafPdmPointer.h" @@ -68,7 +69,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object static double planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane); - double wellPathCenterToPlotStartOffset() const; + double wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const; double planeWidth() const; private: diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index f85a1e8169..4ad7277a5c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -23,6 +23,17 @@ CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); +namespace caf +{ + template<> + void AppEnum< Rim3dWellLogCurveCollection::PlanePosition >::setUp() + { + addItem(Rim3dWellLogCurveCollection::ALONG_WELLPATH, "ALONG_WELLPATH", "On One Side of Well Path"); + addItem(Rim3dWellLogCurveCollection::ON_WELLPATH, "ON_WELLPATH", "On Well Path"); + setDefault(Rim3dWellLogCurveCollection::ALONG_WELLPATH); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -35,6 +46,8 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_planePosition, "PlanePosition", "Plane Position", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); } @@ -82,6 +95,14 @@ bool Rim3dWellLogCurveCollection::isShowingPlot() const return m_showPlot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePosition() const +{ + return m_planePosition(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -113,3 +134,14 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() { return &m_showPlot; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Track Settings"); + + settingsGroup->add(&m_showGrid); + settingsGroup->add(&m_planePosition); +} diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index b8acdb99c8..cc518cbf1f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -18,6 +18,7 @@ #pragma once +#include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -32,6 +33,13 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; +public: + enum PlanePosition + { + ALONG_WELLPATH, + ON_WELLPATH + }; + public: Rim3dWellLogCurveCollection(); virtual ~Rim3dWellLogCurveCollection(); @@ -42,14 +50,20 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool isShowingGrid() const; bool isShowingPlot() const; + PlanePosition planePosition() const; + std::vector vectorOf3dWellLogCurves() const; private: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: caf::PdmField m_showPlot; + caf::PdmField m_showGrid; + caf::PdmField> m_planePosition; + caf::PdmChildArrayField m_3dWellLogCurves; }; From 73a08fffc4a3428cd982acce8510db41055c6e1c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 13:26:33 +0100 Subject: [PATCH 0590/1027] #2635 3D well log curves: Give new curves different colors --- .../Riv3dWellLogPlanePartMgr.cpp | 16 +++++++++++++++- .../Riv3dWellLogPlanePartMgr.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 7b06fb0e9a..0db54a841a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,6 +18,8 @@ #include "Riv3dWellLogPlanePartMgr.h" +#include "RiaColorTables.h" + #include "Rim3dView.h" #include "Rim3dWellLogCurveCollection.h" #include "RimCase.h" @@ -93,8 +95,11 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); + size_t colorIndex = 0; + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { + colorIndex++; if (!rim3dWellLogCurve->isShowingCurve()) continue; std::vector resultValues; @@ -115,7 +120,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* continue; } - caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.9f, 0.0f, 0.0f)); + caf::MeshEffectGenerator meshEffectGen(curveColor(colorIndex)); + meshEffectGen.setLineWidth(2.0f); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = new cvf::Part; @@ -193,6 +199,14 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const return cellSize * 4; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f Riv3dWellLogPlanePartMgr::curveColor(size_t index) +{ + return RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index fcbe95854a..45c280e1c6 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -35,6 +35,7 @@ class Drawable; class Effect; class Part; class BoundingBox; +class Color3f; } namespace caf @@ -72,6 +73,8 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object double wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const; double planeWidth() const; + cvf::Color3f curveColor(size_t index); + private: cvf::ref m_3dWellLogCurveGeometryGenerator; From 18bde3cd896a627d3b85e9f4bde8d4aed73d928a Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 14:35:54 +0100 Subject: [PATCH 0591/1027] #2636 3D Well log curve: Create well path geometry tools. --- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../Riv3dWellLogCurveGeomertyGenerator.cpp | 216 +----------------- .../Riv3dWellLogCurveGeomertyGenerator.h | 21 -- .../Riv3dWellLogGridGeomertyGenerator.cpp | 169 ++++++++++++++ .../Riv3dWellLogGridGeomertyGenerator.h | 58 +++++ .../Riv3dWellLogPlanePartMgr.cpp | 14 +- .../Riv3dWellLogPlanePartMgr.h | 2 + .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigWellPathGeometryTools.cpp | 111 +++++++++ .../RigWellPathGeometryTools.h | 49 ++++ 10 files changed, 404 insertions(+), 240 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp create mode 100644 ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h create mode 100644 ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index d221f84380..3872abd58a 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -42,6 +42,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -82,6 +83,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 8b37d4e28b..bdd3ed159b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -23,6 +23,7 @@ #include "RigCurveDataTools.h" #include "RigWellPath.h" +#include "RigWellPathGeometryTools.h" #include "cafDisplayCoordTransform.h" #include "cvfPrimitiveSetIndexedUInt.h" @@ -83,129 +84,6 @@ cvf::ref return drawable; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double gridIntervalSize) const -{ - CVF_ASSERT(gridIntervalSize > 0); - - if (!wellPathGeometry()) return nullptr; - if (!wellPathClipBoundingBox.isValid()) return nullptr; - - RimWellPathCollection* wellPathCollection = nullptr; - m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); - - std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; - if (wellPathPoints.empty()) return nullptr; - - size_t originalWellPathSize = wellPathPoints.size(); - - if (wellPathCollection->wellPathClip) - { - double horizontalLengthAlongWellToClipPoint; - double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; - size_t indexToFirstVisibleSegment; - wellPathPoints = RigWellPath::clipPolylineStartAboveZ( - wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); - } - if (wellPathPoints.empty()) return nullptr; - - std::vector gridPoints; - - if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; - - size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); - double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); - double lastMd = wellPathGeometry()->m_measuredDepths.back(); - - double md = lastMd; - while (md >= firstMd) - { - cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); - gridPoints.push_back(point); - md -= gridIntervalSize; - } - - std::vector pointNormals; - - std::vector closestPoints; - calculatePairsOfClosestSamplingPointsAlongWellPath(&closestPoints, gridPoints); - - pointNormals = calculateLineSegmentNormals(planeAngle, closestPoints, LINE_SEGMENTS); - if (pointNormals.size() != gridPoints.size()) return nullptr; - - std::vector vertices; - vertices.reserve(gridPoints.size() * 2); - - std::vector indices; - indices.reserve(gridPoints.size() * 2); - - cvf::uint indexCounter = 0; - - // Normal lines - for (size_t i = 0; i < pointNormals.size(); i++) - { - vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); - - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); - - indices.push_back(indexCounter++); - indices.push_back(indexCounter++); - } - - // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off - std::vector wellPathSegmentNormals = - calculateLineSegmentNormals(planeAngle, wellPathGeometry()->m_wellPathPoints, POLYLINE); - wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); - - // Line along and close to well - for (size_t i = 0; i < wellPathPoints.size(); i++) - { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); - - indices.push_back(indexCounter); - indices.push_back(++indexCounter); - } - // Indices are added as line segments for the current point and the next point. The last point does not have a next point, - // therefore we remove the last line segment - indices.pop_back(); - indices.pop_back(); - - // Line along and far away from well - for (size_t i = 0; i < wellPathPoints.size(); i++) - { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); - - indices.push_back(indexCounter); - indices.push_back(++indexCounter); - } - indices.pop_back(); - indices.pop_back(); - - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); - - cvf::ref drawable = new cvf::DrawableGeo(); - - indexedUInt->setIndices(indexArray.p()); - drawable->addPrimitiveSet(indexedUInt.p()); - - cvf::ref vertexArray = new cvf::Vec3fArray(vertices); - drawable->setVertexArray(vertexArray.p()); - - return drawable; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -255,9 +133,9 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std resultValues.end()); std::vector pairsOfWellPathPoints; - calculatePairsOfClosestSamplingPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints); + RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), &pairsOfWellPathPoints, interpolatedWellPathPoints); - std::vector pointNormals = calculateLineSegmentNormals(planeAngle, pairsOfWellPathPoints, LINE_SEGMENTS); + std::vector pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, pairsOfWellPathPoints, RigWellPathGeometryTools::LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; double maxResult = -HUGE_VAL; @@ -302,73 +180,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(double angle, - const std::vector& vertices, - VertexOrganization organization) const -{ - std::vector pointNormals; - - if (!wellPathGeometry()) return pointNormals; - if (vertices.empty()) return pointNormals; - - const cvf::Vec3d globalDirection = - (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); - - const cvf::Vec3d up(0, 0, 1); - - size_t intervalSize; - if (organization == LINE_SEGMENTS) - { - pointNormals.reserve(vertices.size() / 2); - intervalSize = 2; - } - else // organization == POLYLINE - { - pointNormals.reserve(vertices.size()); - intervalSize = 1; - } - - cvf::Vec3d normal; - - for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) - { - cvf::Vec3d p1 = vertices[i]; - cvf::Vec3d p2 = vertices[i + 1]; - - cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); - - double dotProduct = up * vecAlongPath; - - cvf::Vec3d Ex; - - if (cvf::Math::abs(dotProduct) > 0.7071) - { - Ex = globalDirection; - } - else - { - Ex = vecAlongPath; - } - - cvf::Vec3d Ey = (up ^ Ex).getNormalized(); - - cvf::Mat3d rotation; - normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle)); - - pointNormals.push_back(normal); - } - - if (organization == POLYLINE) - { - pointNormals.push_back(normal); - } - - return pointNormals; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -376,24 +187,3 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const { return m_wellPath->wellPathGeometry(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestSamplingPointsAlongWellPath( - std::vector* closestWellPathPoints, - std::vector& points) const -{ - CVF_ASSERT(closestWellPathPoints != nullptr); - - for (const cvf::Vec3d point : points) - { - cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; - cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - wellPathGeometry()->twoClosestPoints(point, &p1, &p2); - if (p1.isUndefined() || p2.isUndefined()) continue; - - closestWellPathPoints->push_back(p1); - closestWellPathPoints->push_back(p2); - } -} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index b6afb3d420..bc4c90a733 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -52,20 +52,6 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth) const; - - cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double gridIntervalSize) const; -private: - enum VertexOrganization - { - LINE_SEGMENTS, - POLYLINE - }; - private: void createCurveVerticesAndIndices(const std::vector& resultValues, const std::vector& resultMds, @@ -77,15 +63,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object std::vector* vertices, std::vector* indices) const; - std::vector calculateLineSegmentNormals(double angle, - const std::vector& vertices, - VertexOrganization organization) const; - const RigWellPath* wellPathGeometry() const; - void calculatePairsOfClosestSamplingPointsAlongWellPath(std::vector* closestWellPathPoints, - std::vector& points) const; - private: caf::PdmPointer m_wellPath; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp new file mode 100644 index 0000000000..2f7e23ae5b --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -0,0 +1,169 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogGridGeomertyGenerator.h" + +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "RigWellPath.h" +#include "RigWellPathGeometryTools.h" + +#include "cafDisplayCoordTransform.h" +#include "cvfPrimitiveSetIndexedUInt.h" + +#include "cvfBoundingBox.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath) + : m_wellPath(wellPath) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double gridIntervalSize) const +{ + CVF_ASSERT(gridIntervalSize > 0); + + if (!wellPathGeometry()) return nullptr; + if (!wellPathClipBoundingBox.isValid()) return nullptr; + + RimWellPathCollection* wellPathCollection = nullptr; + m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); + + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + if (wellPathPoints.empty()) return nullptr; + + size_t originalWellPathSize = wellPathPoints.size(); + + if (wellPathCollection->wellPathClip) + { + double horizontalLengthAlongWellToClipPoint; + double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + size_t indexToFirstVisibleSegment; + wellPathPoints = RigWellPath::clipPolylineStartAboveZ( + wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); + } + if (wellPathPoints.empty()) return nullptr; + + std::vector gridPoints; + + if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; + + size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); + double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + + double md = lastMd; + while (md >= firstMd) + { + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); + gridPoints.push_back(point); + md -= gridIntervalSize; + } + + std::vector pointNormals; + + std::vector closestPoints; + RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), &closestPoints, gridPoints); + + pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, closestPoints, RigWellPathGeometryTools::LINE_SEGMENTS); + if (pointNormals.size() != gridPoints.size()) return nullptr; + + std::vector vertices; + vertices.reserve(gridPoints.size() * 2); + + std::vector indices; + indices.reserve(gridPoints.size() * 2); + + cvf::uint indexCounter = 0; + + // Normal lines + for (size_t i = 0; i < pointNormals.size(); i++) + { + vertices.push_back(cvf::Vec3f( + displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); + + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + + indices.push_back(indexCounter++); + indices.push_back(indexCounter++); + } + + // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off + std::vector wellPathSegmentNormals = + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, wellPathGeometry()->m_wellPathPoints, RigWellPathGeometryTools::POLYLINE); + wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); + + // Line along and close to well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); + + indices.push_back(indexCounter); + indices.push_back(++indexCounter); + } + // Indices are added as line segments for the current point and the next point. The last point does not have a next point, + // therefore we remove the last line segment + indices.pop_back(); + indices.pop_back(); + + // Line along and far away from well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + + indices.push_back(indexCounter); + indices.push_back(++indexCounter); + } + indices.pop_back(); + indices.pop_back(); + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref drawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + drawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + drawable->setVertexArray(vertexArray.p()); + + return drawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellPath* Riv3dWellLogGridGeometryGenerator::wellPathGeometry() const +{ + return m_wellPath->wellPathGeometry(); +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h new file mode 100644 index 0000000000..f511c5bffd --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfDrawableGeo.h" +#include "cvfObject.h" + +#include "cafPdmPointer.h" + +#include + +namespace caf +{ +class DisplayCoordTransform; +} + +namespace cvf +{ +class BoundingBox; +} + +class RigWellPath; +class RimWellPath; + +class Riv3dWellLogGridGeometryGenerator : public cvf::Object +{ +public: + Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath); + + cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double gridIntervalSize) const; +private: + const RigWellPath* wellPathGeometry() const; + +private: + caf::PdmPointer m_wellPath; +}; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 0db54a841a..eb5b455741 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -27,6 +27,7 @@ #include "RimWellPath.h" #include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "Riv3dWellLogGridGeomertyGenerator.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -46,6 +47,7 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri { CVF_ASSERT(m_wellPath.notNull()); m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); + m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p()); } //-------------------------------------------------------------------------------------------------- @@ -222,12 +224,12 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); cvf::ref gridHorizontalDrawable = - m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, - wellPathClipBoundingBox, - planeAngle(drawPlane), - wellPathCenterToPlotStartOffset(planePosition), - planeWidth(), - gridIntervalSize); + m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, + wellPathClipBoundingBox, + planeAngle(drawPlane), + wellPathCenterToPlotStartOffset(planePosition), + planeWidth(), + gridIntervalSize); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 45c280e1c6..79af71486d 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -46,6 +46,7 @@ class DisplayCoordTransform; class RimGridView; class RimWellPath; class Riv3dWellLogCurveGeometryGenerator; +class Riv3dWellLogGridGeometryGenerator; class Riv3dWellLogPlanePartMgr : public cvf::Object { @@ -77,6 +78,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object private: cvf::ref m_3dWellLogCurveGeometryGenerator; + cvf::ref m_3dWellLogGridGeometryGenerator; caf::PdmPointer m_wellPath; caf::PdmPointer m_gridView; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 702bedc7dd..41f7511162 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -63,6 +63,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.h ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h ) @@ -125,6 +126,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.cpp ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp new file mode 100644 index 0000000000..a3d9ded99e --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigWellPathGeometryTools.h" + +#include "RigWellPath.h" + +#include "cvfMatrix3.h" +#include "cvfMath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, + double angle, + const std::vector& vertices, + VertexOrganization organization) +{ + std::vector pointNormals; + + if (!wellPathGeometry) return pointNormals; + if (vertices.empty()) return pointNormals; + + const cvf::Vec3d globalDirection = + (wellPathGeometry->m_wellPathPoints.back() - wellPathGeometry->m_wellPathPoints.front()).getNormalized(); + + const cvf::Vec3d up(0, 0, 1); + + size_t intervalSize; + if (organization == LINE_SEGMENTS) + { + pointNormals.reserve(vertices.size() / 2); + intervalSize = 2; + } + else // organization == POLYLINE + { + pointNormals.reserve(vertices.size()); + intervalSize = 1; + } + + cvf::Vec3d normal; + + for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) + { + cvf::Vec3d p1 = vertices[i]; + cvf::Vec3d p2 = vertices[i + 1]; + + cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); + + double dotProduct = up * vecAlongPath; + + cvf::Vec3d Ex; + + if (cvf::Math::abs(dotProduct) > 0.7071) + { + Ex = globalDirection; + } + else + { + Ex = vecAlongPath; + } + + cvf::Vec3d Ey = (up ^ Ex).getNormalized(); + + cvf::Mat3d rotation; + normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle)); + + pointNormals.push_back(normal); + } + + if (organization == POLYLINE) + { + pointNormals.push_back(normal); + } + + return pointNormals; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, std::vector* closestWellPathPoints, std::vector& points) +{ + CVF_ASSERT(closestWellPathPoints != nullptr); + + for (const cvf::Vec3d point : points) + { + cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; + cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; + wellPathGeometry->twoClosestPoints(point, &p1, &p2); + if (p1.isUndefined() || p2.isUndefined()) continue; + + closestWellPathPoints->push_back(p1); + closestWellPathPoints->push_back(p2); + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h new file mode 100644 index 0000000000..2591ad8bd6 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +#include "cvfBase.h" +#include "cvfVector3.h" + +class RigWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RigWellPathGeometryTools +{ +public: + enum VertexOrganization + { + LINE_SEGMENTS, + POLYLINE + }; + +public: + static std::vector calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, + double angle, + const std::vector& vertices, + VertexOrganization organization); + + static void calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, + std::vector* closestWellPathPoints, + std::vector& points); +}; From 4dcf98eda8003854dbc8b1f1abb8d329b44f8ba7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 22 Mar 2018 14:39:00 +0100 Subject: [PATCH 0592/1027] Tensors: Imporve variable name --- .../ModelVisualization/RivTensorResultPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 44dfeba37b..53647c90ec 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -420,7 +420,7 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalTextureCoords(cvf::Vec2fA { for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) { - cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princial); + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princialNumber); textureCoords->add(texCoord); } } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index 783068dff0..55df996634 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -56,19 +56,19 @@ class RivTensorResultPartMgr : public cvf::Object private: struct TensorVisualization { - TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, size_t princial, float principalValue) + TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, int princial, float principalValue) : vertex(vertex) , result(result) , faceNormal(faceNormal) , isPressure(isPressure) - , princial(princial) + , princialNumber(princial) , principalValue(principalValue) {}; cvf::Vec3f vertex; cvf::Vec3f result; cvf::Vec3f faceNormal; bool isPressure; - size_t princial; + int princialNumber; float principalValue; }; From 5b0fe2d772842d9efa48affff5f466136d350984 Mon Sep 17 00:00:00 2001 From: Baurzhan Muftakhidinov Date: Fri, 23 Mar 2018 16:09:20 +0500 Subject: [PATCH 0593/1027] Fix desktop file --- ApplicationCode/resinsight.desktop.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/resinsight.desktop.in b/ApplicationCode/resinsight.desktop.in index 585886c3f8..f3d00769f0 100644 --- a/ApplicationCode/resinsight.desktop.in +++ b/ApplicationCode/resinsight.desktop.in @@ -4,7 +4,7 @@ Type=Application Terminal=false StartupNotify=true Icon=@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/48x48/apps/ResInsight.png -ame=ResInsight +Name=ResInsight Comment=3D viewer and post processing tool for reservoir models Exec=@CMAKE_INSTALL_PREFIX@/bin/ResInsight Categories=Applications;Science; From bffc50b826e67935e261661966192d1d7888ceaf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Mar 2018 14:42:30 +0100 Subject: [PATCH 0594/1027] Fix typo when generating light NNC colors --- ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp | 3 ++- Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 6d6f74118c..a440b24930 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -705,8 +705,9 @@ void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors cvf::Color3f nncColor = m_defaultColor; nncColor.r() += (1.0 - nncColor.r()) * 0.2; nncColor.g() += (1.0 - nncColor.g()) * 0.2; - nncColor.g() += (1.0 - nncColor.b()) * 0.2; + nncColor.b() += (1.0 - nncColor.b()) * 0.2; + CVF_ASSERT(nncColor.isValid()); cvf::ref nncEffect; if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces) diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index c4c5c265e3..38d953b83f 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -259,6 +259,8 @@ void EffectGenerator::releaseUnreferencedEffects() //-------------------------------------------------------------------------------------------------- SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, PolygonOffset polygonOffset) { + CVF_ASSERT(color.isValid()); + m_color = color; m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; @@ -271,6 +273,8 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, Polygo //-------------------------------------------------------------------------------------------------- SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset) { + CVF_ASSERT(color.isValid()); + m_color = cvf::Color4f(color, 1.0f); m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; From 1a6c529488e1d9918dd386cd51b0b62aadc702da Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Mar 2018 14:59:07 +0100 Subject: [PATCH 0595/1027] Regression Test : Do not show warning/error dock window --- ApplicationCode/UserInterface/RiuMessagePanel.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMessagePanel.cpp b/ApplicationCode/UserInterface/RiuMessagePanel.cpp index 78971e9a64..c8f0ce3968 100644 --- a/ApplicationCode/UserInterface/RiuMessagePanel.cpp +++ b/ApplicationCode/UserInterface/RiuMessagePanel.cpp @@ -18,6 +18,8 @@ #include "RiuMessagePanel.h" +#include "RiaRegressionTestRunner.h" + #include #include #include @@ -71,12 +73,15 @@ void RiuMessagePanel::addMessage(RILogLevel messageLevel, const QString& msg) m_textEdit->moveCursor(QTextCursor::End); m_textEdit->ensureCursorVisible(); - if (messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING) + if (!RiaRegressionTestRunner::instance()->isRunningRegressionTests()) { - QDockWidget* parentDockWidget = dynamic_cast(this->parent()); - if (parentDockWidget && !parentDockWidget->isVisible()) + if (messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING) { - parentDockWidget->toggleViewAction()->trigger(); + QDockWidget* parentDockWidget = dynamic_cast(this->parent()); + if (parentDockWidget && !parentDockWidget->isVisible()) + { + parentDockWidget->toggleViewAction()->trigger(); + } } } } From 8b3f980079effecfd08f920266b995e35d04f626 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 2 Apr 2018 10:17:09 +0200 Subject: [PATCH 0596/1027] Fix crash on selection when there's no MohrsCirclePlot * Check if the pointer is valid before dereferencing --- .../UserInterface/RiuSelectionChangedHandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index ab27893372..513c716578 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -90,7 +90,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(nullptr); - RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); updateResultInfo(nullptr); @@ -110,7 +111,8 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(item); - RiuMainWindow::instance()->mohrsCirclePlot()->appendSelection(item); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->appendSelection(item); updateResultInfo(item); @@ -124,7 +126,8 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i { RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); - RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); handleItemAppended(item); } From 054263b94a2c6dd07df2bb89597a8e45c15e7011 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 4 Apr 2018 11:09:51 +0200 Subject: [PATCH 0597/1027] Apply guard to additional MohrsCirclePlot use --- ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp index 8b82bd21b0..e8da3853ba 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp @@ -74,7 +74,7 @@ void RiuTimeStepChangedHandler::handleTimeStepChanged(Rim3dView* changedView) co pvtPlotUpdater->updateOnTimeStepChanged(changedView); RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); - mohrsCirclePlot->updateOnTimeStepChanged(changedView); + if (mohrsCirclePlot) mohrsCirclePlot->updateOnTimeStepChanged(changedView); //tim.reportTimeMS("done"); } From 3b724e07bd1e1307fe5068b084a743f5d67fd1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 23 Mar 2018 10:17:06 +0100 Subject: [PATCH 0598/1027] #2436 Add cube face tracking through the clipping methods used for intersection calculations --- .../RivIntersectionBoxGeometryGenerator.cpp | 26 +-- .../RivIntersectionGeometryGenerator.cpp | 25 +-- .../cafHexGridIntersectionTools.cpp | 195 ++++++++++++------ .../cafHexGridIntersectionTools.h | 42 ++-- 4 files changed, 184 insertions(+), 104 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp index d805946b92..5a634fd745 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp @@ -283,8 +283,8 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() std::vector hexPlaneCutTriangleVxes; hexPlaneCutTriangleVxes.reserve(5*3); - std::vector isTriangleEdgeCellContour; - isTriangleEdgeCellContour.reserve(5*3); + std::vector cellFaceForEachTriangleEdge; + cellFaceForEachTriangleEdge.reserve(5*3); cvf::Vec3d cellCorners[8]; size_t cornerIndices[8]; @@ -302,20 +302,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() cellCorners, cornerIndices, &hexPlaneCutTriangleVxes, - &isTriangleEdgeCellContour); + &cellFaceForEachTriangleEdge); std::vector clippedTriangleVxes_once; - std::vector isClippedTriEdgeCellContour_once; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, - &clippedTriangleVxes_once, &isClippedTriEdgeCellContour_once); + std::vector cellFaceForEachClippedTriangleEdge_once; + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, cellFaceForEachTriangleEdge, p1Plane, p2Plane, + &clippedTriangleVxes_once, &cellFaceForEachClippedTriangleEdge_once); for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once) if (!clvx.isVxIdsNative) clvx.derivedVxLevel = 0; std::vector clippedTriangleVxes; - std::vector isClippedTriEdgeCellContour; + std::vector cellFaceForEachClippedTriangleEdge; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, isClippedTriEdgeCellContour_once, p3Plane, p4Plane, - &clippedTriangleVxes, &isClippedTriEdgeCellContour); + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, cellFaceForEachClippedTriangleEdge_once, p3Plane, p4Plane, + &clippedTriangleVxes, &cellFaceForEachClippedTriangleEdge); for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes) if (!clvx.isVxIdsNative && clvx.derivedVxLevel == -1) clvx.derivedVxLevel = 1; size_t clippedTriangleCount = clippedTriangleVxes.size()/3; @@ -336,18 +336,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() // Accumulate mesh lines + + #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) - if(isClippedTriEdgeCellContour[triVxIdx]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx])) { cellBorderLineVxes.push_back(p0); cellBorderLineVxes.push_back(p1); } - if(isClippedTriEdgeCellContour[triVxIdx+1]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1])) { cellBorderLineVxes.push_back(p1); cellBorderLineVxes.push_back(p2); } - if(isClippedTriEdgeCellContour[triVxIdx+2]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2])) { cellBorderLineVxes.push_back(p2); cellBorderLineVxes.push_back(p0); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index f0abc155d5..ff05996f45 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -229,8 +229,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() std::vector hexPlaneCutTriangleVxes; hexPlaneCutTriangleVxes.reserve(5*3); - std::vector isTriangleEdgeCellContour; - isTriangleEdgeCellContour.reserve(5*3); + std::vector cellFaceForEachTriangleEdge; + cellFaceForEachTriangleEdge.reserve(5*3); cvf::Vec3d cellCorners[8]; size_t cornerIndices[8]; @@ -247,10 +247,10 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices); caf::HexGridIntersectionTools::planeHexIntersectionMC(plane, - cellCorners, - cornerIndices, - &hexPlaneCutTriangleVxes, - &isTriangleEdgeCellContour); + cellCorners, + cornerIndices, + &hexPlaneCutTriangleVxes, + &cellFaceForEachTriangleEdge); if (m_crossSection->type == RimIntersection::CS_AZIMUTHLINE) { @@ -284,14 +284,14 @@ void RivIntersectionGeometryGenerator::calculateArrays() } std::vector clippedTriangleVxes; - std::vector isClippedTriEdgeCellContour; + std::vector cellFaceForEachClippedTriangleEdge; caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, - isTriangleEdgeCellContour, + cellFaceForEachTriangleEdge, p1Plane, p2Plane, &clippedTriangleVxes, - &isClippedTriEdgeCellContour); + &cellFaceForEachClippedTriangleEdge); size_t clippedTriangleCount = clippedTriangleVxes.size()/3; @@ -314,18 +314,19 @@ void RivIntersectionGeometryGenerator::calculateArrays() // Accumulate mesh lines + #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) - if (isClippedTriEdgeCellContour[triVxIdx]) + if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx]) ) { cellBorderLineVxes.emplace_back(p0); cellBorderLineVxes.emplace_back(p1); } - if (isClippedTriEdgeCellContour[triVxIdx+1]) + if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) { cellBorderLineVxes.emplace_back(p1); cellBorderLineVxes.emplace_back(p2); } - if (isClippedTriEdgeCellContour[triVxIdx+2]) + if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) { cellBorderLineVxes.emplace_back(p2); cellBorderLineVxes.emplace_back(p0); diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp index 8763812d2f..abd5a460c7 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp @@ -204,16 +204,19 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane // // Clips the supplied triangles into new triangles returned in clippedTriangleVxes. // New vertices have set isVxIdsNative = false and their vxIds is indices into triangleVxes -// The isTriangleEdgeCellContour bits refer to the edge after the corresponding triangle vertex. +// The cellFaceForEachTriangleEdge refer to the edge after the corresponding triangle vertex. +// This method will keep the faces provided, while added edges is marked with no face = 6 //-------------------------------------------------------------------------------------------------- void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std::vector& triangleVxes, - const std::vector& isTriangleEdgeCellContour, + const std::vector& cellFaceForEachTriangleEdge, const cvf::Plane& p1Plane, const cvf::Plane& p2Plane, std::vector* clippedTriangleVxes, - std::vector* isClippedTriEdgeCellContour) + std::vector* cellFaceForEachClippedTriangleEdge) { + #define HT_NO_FACE 6 + size_t triangleCount = triangleVxes.size() / 3; for (size_t tIdx = 0; tIdx < triangleCount; ++tIdx) @@ -272,9 +275,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[triVxIdx + 1]); clippedTriangleVxes->push_back(triangleVxes[triVxIdx + 2]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 0]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 1]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 2]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 0]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 1]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 2]); continue; } @@ -290,13 +293,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[newVx2OnP1.clippedEdgeVx2Id]); clippedTriangleVxes->push_back(newVx2OnP1); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -312,13 +315,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[newVx1OnP2.clippedEdgeVx2Id]); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -330,9 +333,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP1); clippedTriangleVxes->push_back(triangleVxes[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); continue; } @@ -344,9 +347,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP2); clippedTriangleVxes->push_back(triangleVxes[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); continue; } @@ -370,17 +373,17 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP2); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); } else { @@ -389,17 +392,17 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP1); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); } continue; @@ -416,13 +419,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP2); clippedTriangleVxes->push_back(newVx2OnP1); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -438,13 +441,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP2); clippedTriangleVxes->push_back(newVx1OnP1); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -502,17 +505,33 @@ cvf::Vec3d HexGridIntersectionTools::planeLineIntersectionForMC(const cvf::Plane } //-------------------------------------------------------------------------------------------------- +/// Based on description and implementation from Paul Bourke: /// +/// http://paulbourke.net/geometry/polygonise/ +/// +/// Note that the element is turned inside-out compared to what we use elsewhere in caf/ResInsight +/// So the winding of all the sides are opposite. +/// 4-----4------5 +/// /| /| k POS_I = 0 +/// 7 8 5 9 | NEG_I = 1 +/// / | / | | POS_J = 2 +/// 7------6-----6 | | NEG_J = 3 +/// | 0-----0--|---1 *------i POS_K = 4 +/// 11 / 10 / / NEG_K = 5 +/// | 3 | 1 / NO_FACE = 6 +/// |/ |/ j +/// 3------2-----2 +/// +// The cellFaceForEachTriangleEdge refer to the edge after the corresponding triangle vertex. //-------------------------------------------------------------------------------------------------- int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, - const cvf::Vec3d cell[8], - const size_t hexCornersIds[8], - std::vector* triangleVxes, - std::vector* isTriEdgeCellContour) + const cvf::Vec3d cell[8], + const size_t hexCornersIds[8], + std::vector* triangleVxes, + std::vector* cellFaceForEachTriangleEdge) { - // Based on description and implementation from Paul Bourke: - // http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/ + static const cvf::uint cubeIdxToCutEdgeBitfield[256] = { @@ -864,24 +883,67 @@ int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, const int* triangleIndicesToCubeEdges = cubeIdxToTriangleIndices[cubeIndex]; cvf::uint triangleVxIdx = 0; - int cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; - + int cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; while (cubeEdgeIdx != -1) { ClipVx cvx; - cvx.vx = edgeIntersections[cubeEdgeIdx]; + cvx.vx = edgeIntersections[cubeEdgeIdx]; cvx.normDistFromEdgeVx1 = normDistAlongEdge[cubeEdgeIdx]; - cvx.clippedEdgeVx1Id = hexCornersIds[edgeTable[cubeEdgeIdx][0]]; - cvx.clippedEdgeVx2Id = hexCornersIds[edgeTable[cubeEdgeIdx][1]]; + cvx.clippedEdgeVx1Id = hexCornersIds[edgeTable[cubeEdgeIdx][0]]; + cvx.clippedEdgeVx2Id = hexCornersIds[edgeTable[cubeEdgeIdx][1]]; (*triangleVxes).push_back(cvx); ++triangleVxIdx; + cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; } cvf::uint triangleCount = triangleVxIdx / 3; + static const int edgeEdgeCutsToCellFace[12][12] = { + // 0 1 2 3 4 5 6 7 8 9 10 11 + { 6, 5, 5, 5, 3, 6, 6, 6, 3, 3, 6, 6 }, // 0 + { 5, 6, 5, 5, 6, 0, 6, 6, 6, 0, 0, 6 }, // 1 POS_I = 0 + { 5, 5, 6, 5, 6, 6, 2, 6, 6, 6, 2, 2 }, // 2 NEG_I = 1 + { 5, 5, 5, 6, 6, 6, 6, 1, 1, 6, 6, 1 }, // 3 POS_J = 2 + { 3, 6, 6, 6, 6, 4, 4, 4, 3, 3, 6, 6 }, // 4 NEG_J = 3 + { 6, 0, 6, 6, 4, 6, 4, 4, 6, 0, 0, 6 }, // 5 POS_K = 4 + { 6, 6, 2, 6, 4, 4, 6, 4, 6, 6, 2, 2 }, // 6 NEG_K = 5 + { 6, 6, 6, 1, 4, 4, 4, 6, 1, 6, 6, 1 }, // 7 NO_FACE = 6 + { 3, 6, 6, 1, 3, 6, 6, 1, 6, 3, 6, 1 }, // 8 + { 3, 0, 6, 6, 3, 0, 6, 6, 3, 6, 0, 6 }, // 9 + { 6, 0, 2, 6, 6, 0, 2, 6, 6, 0, 6, 2 }, // 10 + { 6, 6, 2, 1, 6, 6, 2, 1, 1, 6, 2, 6 } // 11 + }; + + + (*cellFaceForEachTriangleEdge).clear(); + (*cellFaceForEachTriangleEdge).resize(triangleVxIdx, 6); + + for (cvf::uint tIdx = 0; tIdx < triangleCount; ++tIdx) + { + cvf::uint triVxIdx = 3 * tIdx; + + int cubeEdgeIdx1 = triangleIndicesToCubeEdges[triVxIdx]; + int cubeEdgeIdx2 = triangleIndicesToCubeEdges[triVxIdx + 1]; + int cubeEdgeIdx3 = triangleIndicesToCubeEdges[triVxIdx + 2]; + + (*cellFaceForEachTriangleEdge)[triVxIdx + 0] = edgeEdgeCutsToCellFace[cubeEdgeIdx1][cubeEdgeIdx2]; + (*cellFaceForEachTriangleEdge)[triVxIdx + 1] = edgeEdgeCutsToCellFace[cubeEdgeIdx2][cubeEdgeIdx3]; + (*cellFaceForEachTriangleEdge)[triVxIdx + 2] = edgeEdgeCutsToCellFace[cubeEdgeIdx3][cubeEdgeIdx1]; + } + + +#if 0 + // Calculate what triangle edges are representing the cut of a cell face + // Do this by counting the times two specific cube edges are used for a triangle edge. + // Internal edges will have a count of 2, while external edges only 1 + + (*isTriEdgeCellContour).clear(); + (*isTriEdgeCellContour).resize(triangleVxIdx); + + int triangleEdgeCount[12][12] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, @@ -920,11 +982,14 @@ int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, int cubeEdgeIdx2 = triangleIndicesToCubeEdges[triVxIdx + 1]; int cubeEdgeIdx3 = triangleIndicesToCubeEdges[triVxIdx + 2]; + // We have a contour if the count is exactly 1. + (*isTriEdgeCellContour)[triVxIdx + 0] = (1 == (cubeEdgeIdx1 < cubeEdgeIdx2 ? triangleEdgeCount[cubeEdgeIdx1][cubeEdgeIdx2] : triangleEdgeCount[cubeEdgeIdx2][cubeEdgeIdx1])); (*isTriEdgeCellContour)[triVxIdx + 1] = (1 == (cubeEdgeIdx2 < cubeEdgeIdx3 ? triangleEdgeCount[cubeEdgeIdx2][cubeEdgeIdx3] : triangleEdgeCount[cubeEdgeIdx3][cubeEdgeIdx2])); (*isTriEdgeCellContour)[triVxIdx + 2] = (1 == (cubeEdgeIdx3 < cubeEdgeIdx1 ? triangleEdgeCount[cubeEdgeIdx3][cubeEdgeIdx1] : triangleEdgeCount[cubeEdgeIdx1][cubeEdgeIdx3])); } +#endif return triangleCount; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h index 392cbf2002..36ea201dd0 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h @@ -40,28 +40,40 @@ class HexGridIntersectionTools int derivedVxLevel; //< Helper data to make it possible to track what set of ClipVx's the indices is reffering to in case of consecutive clips }; - static bool planeLineIntersect(const cvf::Plane& plane, const cvf::Vec3d& a, const cvf::Vec3d& b, cvf::Vec3d* intersection, double* normalizedDistFromA); + static bool planeLineIntersect(const cvf::Plane& plane, + const cvf::Vec3d& a, + const cvf::Vec3d& b, + cvf::Vec3d* intersection, + double* normalizedDistFromA); static bool planeTriangleIntersection(const cvf::Plane& plane, - const cvf::Vec3d& p1, size_t p1Id, - const cvf::Vec3d& p2, size_t p2Id, - const cvf::Vec3d& p3, size_t p3Id, - ClipVx* newVx1, ClipVx* newVx2, - bool* isMostVxesOnPositiveSide); + const cvf::Vec3d& p1, + size_t p1Id, + const cvf::Vec3d& p2, + size_t p2Id, + const cvf::Vec3d& p3, + size_t p3Id, + ClipVx* newVx1, + ClipVx* newVx2, + bool* isMostVxesOnPositiveSide); static void clipTrianglesBetweenTwoParallelPlanes(const std::vector& triangleVxes, - const std::vector& isTriangleEdgeCellContour, - const cvf::Plane& p1Plane, const cvf::Plane& p2Plane, - std::vector* clippedTriangleVxes, - std::vector* isClippedTriEdgeCellContour); + const std::vector& cellFaceForEachTriangleEdge, + const cvf::Plane& p1Plane, + const cvf::Plane& p2Plane, + std::vector* clippedTriangleVxes, + std::vector* cellFaceForEachClippedTriangleEdge); - static cvf::Vec3d planeLineIntersectionForMC(const cvf::Plane& plane, const cvf::Vec3d& p1, const cvf::Vec3d& p2, double* normalizedDistFromP1); + static cvf::Vec3d planeLineIntersectionForMC(const cvf::Plane& plane, + const cvf::Vec3d& p1, + const cvf::Vec3d& p2, + double* normalizedDistFromP1); static int planeHexIntersectionMC(const cvf::Plane& plane, - const cvf::Vec3d cell[8], - const size_t hexCornersIds[8], - std::vector* triangleVxes, - std::vector* isTriEdgeCellContour); + const cvf::Vec3d cell[8], + const size_t hexCornersIds[8], + std::vector* triangleVxes, + std::vector* cellFaceForEachTriangleEdge); }; From 97c2ebd955719bd230fd811e450d0bcf1ef64891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 23 Mar 2018 15:08:24 +0100 Subject: [PATCH 0599/1027] #2436 Intersection Fault lines are now separated and have a separate color --- .../RivHexGridIntersectionTools.cpp | 18 +++++ .../RivHexGridIntersectionTools.h | 9 ++- .../RivIntersectionGeometryGenerator.cpp | 70 +++++++++++++++---- .../RivIntersectionGeometryGenerator.h | 3 + .../Intersections/RivIntersectionPartMgr.cpp | 48 +++++++++++-- .../Intersections/RivIntersectionPartMgr.h | 2 + .../ReservoirDataModel/RigMainGrid.cpp | 2 +- 7 files changed, 133 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp index 766b08442c..98bca93107 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp @@ -89,6 +89,15 @@ void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t corn memcpy(cornerIndices, cornerIndicesSource.data(), 8); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return m_mainGrid->findFaultFromCellIndexAndCellFace(reservoirCellIndex, face); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,3 +181,12 @@ void RivFemIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIn cornerIndices[7] = m_femPart->elementNodeResultIdx(elmIdx, 7); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return nullptr; +} + diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h index 0cc00291d5..5d9b147e27 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h @@ -24,11 +24,12 @@ #include "cvfBoundingBox.h" #include +#include "cvfStructGrid.h" class RigActiveCellInfo; class RigFemPart; class RigMainGrid; - +class RigFault; //-------------------------------------------------------------------------------------------------- /// Interface definition used to compute the geometry for planes intersecting a grid @@ -42,6 +43,8 @@ class RivIntersectionHexGridInterface : public cvf::Object virtual bool useCell(size_t cellIndex) const = 0; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const = 0; }; //-------------------------------------------------------------------------------------------------- @@ -58,6 +61,8 @@ class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_mainGrid; @@ -79,6 +84,8 @@ class RivFemIntersectionGrid : public RivIntersectionHexGridInterface virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_femPart; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index ff05996f45..e73e491060 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -71,6 +71,8 @@ RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersect { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; + m_faultCellBorderLineVxes = new cvf::Vec3fArray; + if (m_isFlattened) m_extrusionDirection = -cvf::Vec3d::Z_AXIS; } @@ -152,6 +154,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_extrusionDirection.normalize(); std::vector triangleVertices; std::vector cellBorderLineVxes; + std::vector faultCellBorderLineVxes; cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); @@ -315,21 +318,46 @@ void RivIntersectionGeometryGenerator::calculateArrays() // Accumulate mesh lines #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) + using FaceType = cvf::StructGridInterface::FaceType; - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) ) { - cellBorderLineVxes.emplace_back(p0); - cellBorderLineVxes.emplace_back(p1); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + { + faultCellBorderLineVxes.emplace_back(p0); + faultCellBorderLineVxes.emplace_back(p1); + } + else + { + cellBorderLineVxes.emplace_back(p0); + cellBorderLineVxes.emplace_back(p1); + } } - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) { - cellBorderLineVxes.emplace_back(p1); - cellBorderLineVxes.emplace_back(p2); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) + { + faultCellBorderLineVxes.emplace_back(p1); + faultCellBorderLineVxes.emplace_back(p2); + } + else + { + cellBorderLineVxes.emplace_back(p1); + cellBorderLineVxes.emplace_back(p2); + } } - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) { - cellBorderLineVxes.emplace_back(p2); - cellBorderLineVxes.emplace_back(p0); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) + { + faultCellBorderLineVxes.emplace_back(p2); + faultCellBorderLineVxes.emplace_back(p0); + } + else + { + cellBorderLineVxes.emplace_back(p2); + cellBorderLineVxes.emplace_back(p0); + } } // Mapping to cell index @@ -352,9 +380,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1, - cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, - cvx.normDistFromEdgeVx1)); - + cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1)); } } } @@ -364,6 +391,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() } m_triangleVxes->assign(triangleVertices); m_cellBorderLineVxes->assign(cellBorderLineVxes); + m_faultCellBorderLineVxes->assign(faultCellBorderLineVxes); } @@ -405,6 +433,24 @@ cvf::ref RivIntersectionGeometryGenerator::createMeshDrawable( } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createFaultMeshDrawable() +{ + if (!(m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0)) return nullptr; + + cvf::ref geo = new cvf::DrawableGeo; + geo->setVertexArray(m_faultCellBorderLineVxes.p()); + + + cvf::ref prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES); + prim->setIndexCount(m_faultCellBorderLineVxes->size()); + + geo->addPrimitiveSet(prim.p()); + return geo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 75e2fbcaec..6bc7363ce8 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -60,6 +60,8 @@ class RivIntersectionGeometryGenerator : public cvf::Object // Generate geometry cvf::ref generateSurface(); cvf::ref createMeshDrawable(); + cvf::ref createFaultMeshDrawable(); + cvf::ref createLineAlongPolylineDrawable(); cvf::ref createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine); cvf::ref createPointsFromPolylineDrawable(); @@ -98,6 +100,7 @@ class RivIntersectionGeometryGenerator : public cvf::Object // Output arrays cvf::ref m_triangleVxes; cvf::ref m_cellBorderLineVxes; + cvf::ref m_faultCellBorderLineVxes; std::vector m_triangleToCellIdxMap; std::vector m_triVxToCellCornerWeights; std::vector > m_flattenedOrOffsettedPolyLines; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 5f4099e843..8968a0bf8c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -70,6 +70,8 @@ #include "cvfTransform.h" #include +#include "RiaApplication.h" +#include "RiaPreferences.h" //-------------------------------------------------------------------------------------------------- @@ -116,16 +118,25 @@ void RivIntersectionPartMgr::applySingleColorEffect() } // Update mesh colors as well, in case of change - //RiaPreferences* prefs = RiaApplication::instance()->preferences(); - - cvf::ref eff; - caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); - eff = CrossSectionEffGen.generateCachedEffect(); + RiaPreferences* prefs = RiaApplication::instance()->preferences(); if (m_crossSectionGridLines.notNull()) { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + m_crossSectionGridLines->setEffect(eff.p()); } + + if (m_crossSectionFaultGridLines.notNull()) + { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultFaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + + m_crossSectionFaultGridLines->setEffect(eff.p()); + } } //-------------------------------------------------------------------------------------------------- @@ -546,6 +557,27 @@ void RivIntersectionPartMgr::generatePartGeometry() } } + // Mesh geometry + { + cvf::ref geoMesh = m_crossSectionGenerator->createFaultMeshDrawable(); + if (geoMesh.notNull()) + { + if (useBufferObjects) + { + geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + } + + cvf::ref part = new cvf::Part; + part->setName("Cross Section faultmesh"); + part->setDrawable(geoMesh.p()); + + part->updateBoundingBox(); + part->setEnableMask(meshFaultBit); + part->setPriority(RivPartPriority::PartType::FaultMeshLines); + + m_crossSectionFaultGridLines = part; + } + } createPolyLineParts(useBufferObjects); createExtrusionDirParts(useBufferObjects); @@ -796,6 +828,12 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod m_crossSectionGridLines->setTransform(scaleTransform); model->addPart(m_crossSectionGridLines.p()); } + + if (m_crossSectionFaultGridLines.notNull()) + { + m_crossSectionFaultGridLines->setTransform(scaleTransform); + model->addPart(m_crossSectionFaultGridLines.p()); + } } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 6537664c13..4410ec3f6b 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -121,6 +121,8 @@ class RivIntersectionPartMgr : public cvf::Object cvf::ref m_crossSectionGenerator; cvf::ref m_crossSectionFaces; cvf::ref m_crossSectionGridLines; + cvf::ref m_crossSectionFaultGridLines; + cvf::ref m_crossSectionFacesTextureCoords; cvf::ref m_highlightLineAlongPolyline; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 23a835aa7d..5853a121a4 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -474,7 +474,7 @@ bool RigMainGrid::isFaceNormalsOutwards() const //-------------------------------------------------------------------------------------------------- const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const { - CVF_ASSERT(m_faultsPrCellAcc.notNull()); + CVF_TIGHT_ASSERT(m_faultsPrCellAcc.notNull()); if (face == cvf::StructGridInterface::NO_FACE) return nullptr; From f7bfe8d003fbf3d875bf3f0d7d1895176689e861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 4 Apr 2018 22:34:41 +0200 Subject: [PATCH 0600/1027] #2436 Separated Hide grid cells mode as a separate value. Make sure that all the possible drawstyles works as expected, both for 2D intersection view and 3D views. --- .../RivGeoMechVizLogic.cpp | 24 ++-- .../Intersections/RivIntersectionPartMgr.cpp | 10 +- .../RivReservoirFaultsPartMgr.cpp | 2 +- .../RivReservoirViewPartMgr.cpp | 115 +++++++++--------- .../RivReservoirViewPartMgr.h | 80 +++++++++--- .../Rim2dIntersectionView.cpp | 8 ++ .../ProjectDataModel/Rim2dIntersectionView.h | 1 + .../ProjectDataModel/Rim3dView.cpp | 83 ++++--------- ApplicationCode/ProjectDataModel/Rim3dView.h | 35 ++---- .../ProjectDataModel/RimEclipseView.cpp | 46 +++++-- .../RimFaultInViewCollection.cpp | 2 +- .../RimFaultInViewCollection.h | 2 +- .../ProjectDataModel/RimGridView.cpp | 26 ++-- .../ProjectDataModel/RimGridView.h | 14 ++- 14 files changed, 244 insertions(+), 204 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 560f12299b..c310c17460 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -147,19 +147,21 @@ std::vector RivGeoMechVizLogic::keysToVisiblePartMg { visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(OVERRIDDEN_CELL_VISIBILITY, -1)); } - else if (timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters()) + else if ( m_geomechView->isGridVisualizationMode() ) { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex)); - } - else if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) - { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); - } - else - { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + if ( timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters() ) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex)); + } + else if ( m_geomechView->rangeFilterCollection()->hasActiveFilters() ) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); + } + else + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + } } - return visiblePartMgrs; } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 8968a0bf8c..0b4e2307bd 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -528,14 +528,14 @@ void RivIntersectionPartMgr::generatePartGeometry() part->setSourceInfo(si.p()); part->updateBoundingBox(); - part->setEnableMask(faultBit); + part->setEnableMask(intersectionCellFaceBit); part->setPriority(RivPartPriority::PartType::Intersection); m_crossSectionFaces = part; } } - // Mesh geometry + // Cell Mesh geometry { cvf::ref geoMesh = m_crossSectionGenerator->createMeshDrawable(); if (geoMesh.notNull()) @@ -550,14 +550,14 @@ void RivIntersectionPartMgr::generatePartGeometry() part->setDrawable(geoMesh.p()); part->updateBoundingBox(); - part->setEnableMask(meshFaultBit); + part->setEnableMask(intersectionCellMeshBit); part->setPriority(RivPartPriority::PartType::MeshLines); m_crossSectionGridLines = part; } } - // Mesh geometry + // Fault Mesh geometry { cvf::ref geoMesh = m_crossSectionGenerator->createFaultMeshDrawable(); if (geoMesh.notNull()) @@ -572,7 +572,7 @@ void RivIntersectionPartMgr::generatePartGeometry() part->setDrawable(geoMesh.p()); part->updateBoundingBox(); - part->setEnableMask(meshFaultBit); + part->setEnableMask(intersectionFaultMeshBit); part->setPriority(RivPartPriority::PartType::FaultMeshLines); m_crossSectionFaultGridLines = part; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index 5f2d57c5d5..1b61952eab 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -109,7 +109,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) // Parts that is overridden by the grid settings bool forceDisplayOfFault = false; - if (!faultCollection->showFaultsOutsideFilters()) + if (!faultCollection->isShowingFaultsAndFaultsOutsideFilters()) { forceDisplayOfFault = isShowingGrid; } diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 808d3a8532..74317e8ca0 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -214,11 +214,20 @@ void RivReservoirViewPartMgr::clearGeometryCache() void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices) { - if (m_geometriesNeedsRegen[geometryType]) + ensureStaticGeometryPartsCreated(geometryType); + + m_geometries[geometryType].appendGridPartsToModel(model, gridIndices); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirViewPartMgr::ensureStaticGeometryPartsCreated(RivCellSetEnum geometryType) +{ + if (geometryType < PROPERTY_FILTERED && m_geometriesNeedsRegen[geometryType]) { createGeometry( geometryType); } - m_geometries[geometryType].appendGridPartsToModel(model, gridIndices); } //-------------------------------------------------------------------------------------------------- @@ -226,6 +235,23 @@ void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices) +{ + ensureDynamicGeometryPartsCreated(geometryType, frameIndex); + + if (geometryType == PROPERTY_FILTERED) + { + m_propFilteredGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); + } + else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) + { + m_propFilteredWellGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirViewPartMgr::ensureDynamicGeometryPartsCreated(RivCellSetEnum geometryType, size_t frameIndex) { if (geometryType == PROPERTY_FILTERED) { @@ -233,7 +259,6 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL { createPropertyFilteredNoneWellCellGeometry(frameIndex); } - m_propFilteredGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); } else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) { @@ -241,7 +266,6 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL { createPropertyFilteredWellGeometry(frameIndex); } - m_propFilteredWellGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); } } @@ -290,7 +314,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case VISIBLE_WELL_CELLS: { cvf::ref allWellCellsVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); allWellCellsVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); @@ -306,7 +330,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case VISIBLE_WELL_FENCE_CELLS: { cvf::ref allWellCellsVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); allWellCellsVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); @@ -325,7 +349,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[ACTIVE]) createGeometry(ACTIVE); + ensureStaticGeometryPartsCreated(ACTIVE); nativeVisibility = m_geometries[ACTIVE].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -334,7 +358,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED_INACTIVE: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[INACTIVE]) createGeometry(INACTIVE); + ensureStaticGeometryPartsCreated(INACTIVE); nativeVisibility = m_geometries[INACTIVE].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -343,7 +367,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED_WELL_CELLS: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); nativeVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -354,8 +378,8 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, cvf::ref visibleWellCells; cvf::ref rangeFilteredWellCells; - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS]) createGeometry(VISIBLE_WELL_CELLS); - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); visibleWellCells = m_geometries[VISIBLE_WELL_CELLS].cellVisibility(gridIdx); rangeFilteredWellCells = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gridIdx); @@ -374,8 +398,8 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, cvf::ref visibleWellCells; cvf::ref rangeFilteredWellCells; - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); visibleWellCells = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gridIdx); rangeFilteredWellCells = m_geometries[RANGE_FILTERED].cellVisibility(gridIdx); @@ -427,29 +451,29 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t if (hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); } else if (hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); fenceVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); } else if (!hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); rangeVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); } else if (!hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[ACTIVE]) createGeometry(ACTIVE); + ensureStaticGeometryPartsCreated(ACTIVE); rangeVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); fenceVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); @@ -504,36 +528,36 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd if (hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); } else if (hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); wellCellsOutsideRange = rangeVisibility; wellFenceCells = rangeVisibility; } else if (!hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS]) createGeometry(VISIBLE_WELL_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS); wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); rangeVisibility = wellCellsOutsideRange; } else if (!hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); wellFenceCells = m_geometries[ALL_WELL_CELLS].cellVisibility(gIdx); wellCellsOutsideRange = wellFenceCells; rangeVisibility = wellFenceCells; @@ -904,28 +928,11 @@ void RivReservoirViewPartMgr::updateFaultCellEdgeResultColor(RivCellSetEnum geom //-------------------------------------------------------------------------------------------------- const cvf::UByteArray* RivReservoirViewPartMgr::cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t timeStepIndex) { - if (geometryType == PROPERTY_FILTERED) - { - if (timeStepIndex >= m_propFilteredGeometryFramesNeedsRegen.size() || m_propFilteredGeometryFramesNeedsRegen[timeStepIndex]) - { - createPropertyFilteredNoneWellCellGeometry(timeStepIndex); - } - } - else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) - { - if (timeStepIndex >= m_propFilteredWellGeometryFramesNeedsRegen.size() || m_propFilteredWellGeometryFramesNeedsRegen[timeStepIndex]) - { - createPropertyFilteredWellGeometry(timeStepIndex); - } - } - else - { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } - } + ensureDynamicGeometryPartsCreated(geometryType, timeStepIndex); + ensureStaticGeometryPartsCreated(geometryType); + RivReservoirPartMgr * pmgr = (const_cast(this))->reservoirPartManager( geometryType, timeStepIndex ); + return pmgr->cellVisibility(gridIndex).p(); } @@ -972,13 +979,9 @@ void RivReservoirViewPartMgr::updateFaultColors(RivCellSetEnum geometryType, siz //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { - //CVF_ASSERT(geometryType < PROPERTY_FILTERED); if (geometryType >= PROPERTY_FILTERED) return; - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); /* QString text; @@ -1084,10 +1087,7 @@ RivCellSetEnum RivReservoirViewPartMgr::geometryTypeForFaultLabels(const std::se //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); m_geometries[geometryType].appendFaultLabelPartsToModel(model); } @@ -1120,10 +1120,7 @@ void RivReservoirViewPartMgr::forceWatertightGeometryOnForType(RivCellSetEnum ge } else { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); m_geometries[geometryType].forceWatertightGeometryOn(); } } diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h index ad27f02dfb..8a2b5acc36 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h @@ -54,36 +54,60 @@ class RivReservoirViewPartMgr: public cvf::Object void scheduleGeometryRegen(RivCellSetEnum geometryType); const cvf::UByteArray* cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t frameIndex); - void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices); - - void updateCellColor (RivCellSetEnum geometryType, size_t timeStepIndex, + void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + const std::vector& gridIndices); + void ensureStaticGeometryPartsCreated ( RivCellSetEnum geometryType ); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + size_t frameIndex, + const std::vector& gridIndices); + void ensureDynamicGeometryPartsCreated(RivCellSetEnum geometryType, + size_t frameIndex); + + void updateCellColor (RivCellSetEnum geometryType, + size_t timeStepIndex, cvf::Color4f color); - void updateCellResultColor (RivCellSetEnum geometryType, size_t timeStepIndex, + void updateCellResultColor (RivCellSetEnum geometryType, + size_t timeStepIndex, RimEclipseCellColors* cellResultColors); - void updateCellEdgeResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, + void updateCellEdgeResultColor(RivCellSetEnum geometryType, + size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors); // Faults - void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); - void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); - void updateFaultColors(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors); - void updateFaultCellEdgeResultColor( RivCellSetEnum geometryType, size_t timeStepIndex, - RimEclipseCellColors* cellResultColors, - RimCellEdgeColors* cellEdgeResultColors); + void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType); + void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + size_t frameIndex); + void updateFaultColors(RivCellSetEnum geometryType, + size_t timeStepIndex, + RimEclipseCellColors* cellResultColors); + void updateFaultCellEdgeResultColor(RivCellSetEnum geometryType, + size_t timeStepIndex, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); // Fault labels - RivCellSetEnum geometryTypeForFaultLabels(const std::set& geometryTypes, bool showFaultsOutsideFilters) const; - void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); - void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); + RivCellSetEnum geometryTypeForFaultLabels(const std::set& geometryTypes, + bool showFaultsOutsideFilters) const; + void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType); + void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, size_t frameIndex); void forceWatertightGeometryOnForType(RivCellSetEnum geometryType); void clearWatertightGeometryFlags(); private: void createGeometry(RivCellSetEnum geometryType); - void computeVisibility(cvf::UByteArray* cellVisibility, RivCellSetEnum geometryType, RigGridBase* grid, size_t gridIdx); + void computeVisibility(cvf::UByteArray* cellVisibility, + RivCellSetEnum geometryType, + RigGridBase* grid, + size_t gridIdx); void createPropertyFilteredNoneWellCellGeometry(size_t frameIndex); void createPropertyFilteredWellGeometry(size_t frameIndex); @@ -91,10 +115,26 @@ class RivReservoirViewPartMgr: public cvf::Object void clearGeometryCache(RivCellSetEnum geomType); - static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible); - void computeRangeVisibility (RivCellSetEnum geometryType, cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl); - static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl); - void computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid); + static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + const RigActiveCellInfo* activeCellInfo, + const cvf::UByteArray* cellIsInWellStatuses, + bool invalidCellsIsVisible, + bool inactiveCellsIsVisible, + bool activeCellsIsVisible, + bool mainGridIsVisible); + void computeRangeVisibility (RivCellSetEnum geometryType, + cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + const cvf::UByteArray* nativeVisibility, + const RimCellRangeFilterCollection* rangeFilterColl); + static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + size_t timeStepIndex, + const cvf::UByteArray* rangeFilterVisibility, + RimEclipsePropertyFilterCollection* propFilterColl); + void computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, + const RigGridBase* grid); static void copyByteArray(cvf::UByteArray* dest, const cvf::UByteArray* source ); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 8624ba0bfd..afffe6ead0 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -302,6 +302,14 @@ cvf::ref Rim2dIntersectionView::flatIntersectionPartMgr( return m_flatIntersectionPartMgr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isGridVisualizationMode() const +{ + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index af53f03d4c..9fa49ac01d 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -71,6 +71,7 @@ class Rim2dIntersectionView : public Rim3dView protected: void updateLegends(); + virtual bool isGridVisualizationMode() const override; virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; virtual void createDisplayModel() override; virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index adc50adbac..b1fe4c32ef 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -23,7 +23,7 @@ #include "RiaPreferences.h" #include "RiaViewRedrawScheduler.h" -#include "RimEclipseCase.h" +#include "RimCase.h" #include "RimGridView.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" @@ -47,7 +47,6 @@ #include "cvfTransform.h" #include "cvfViewport.h" -#include #include #include "cvfScene.h" @@ -428,35 +427,12 @@ void Rim3dView::setupBeforeSave() } } -//-------------------------------------------------------------------------------------------------- -/// -// Surf: No Fault Surf -// Mesh ------------- -// No F F G -// Fault F F G -// Mesh G G G -// -//-------------------------------------------------------------------------------------------------- -bool Rim3dView::isGridVisualizationMode() const -{ - return ( this->surfaceMode() == SURFACE - || this->meshMode() == FULL_MESH); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dView::setMeshOnlyDrawstyle() { - if (isGridVisualizationMode()) - { - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - + meshMode.setValueWithFieldChanged(FULL_MESH); surfaceMode.setValueWithFieldChanged(NO_SURFACE); } @@ -465,16 +441,8 @@ void Rim3dView::setMeshOnlyDrawstyle() //-------------------------------------------------------------------------------------------------- void Rim3dView::setMeshSurfDrawstyle() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } + surfaceMode.setValueWithFieldChanged(SURFACE); + meshMode.setValueWithFieldChanged(FULL_MESH); } //-------------------------------------------------------------------------------------------------- @@ -482,20 +450,7 @@ void Rim3dView::setMeshSurfDrawstyle() //-------------------------------------------------------------------------------------------------- void Rim3dView::setFaultMeshSurfDrawstyle() { - // Surf: No Fault Surf - // Mesh ------------- - // No FF FF SF - // Fault FF FF SF - // Mesh SF SF SF - if (this->isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - + surfaceMode.setValueWithFieldChanged(SURFACE); meshMode.setValueWithFieldChanged(FAULTS_MESH); } @@ -504,15 +459,7 @@ void Rim3dView::setFaultMeshSurfDrawstyle() //-------------------------------------------------------------------------------------------------- void Rim3dView::setSurfOnlyDrawstyle() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - + surfaceMode.setValueWithFieldChanged(SURFACE); meshMode.setValueWithFieldChanged(NO_MESH); } @@ -794,9 +741,20 @@ void Rim3dView::updateDisplayModelVisibility() const cvf::uint uintMeshSurfaceBit = meshSurfaceBit; const cvf::uint uintFaultBit = faultBit; const cvf::uint uintMeshFaultBit = meshFaultBit; + const cvf::uint uintIntersectionCellFaceBit = intersectionCellFaceBit; + const cvf::uint uintIntersectionCellMeshBit = intersectionCellMeshBit; + const cvf::uint uintIntersectionFaultMeshBit = intersectionFaultMeshBit; // Initialize the mask to show everything except the the bits controlled here - unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ; + unsigned int mask = + 0xffffffff + & ~uintSurfaceBit + & ~uintFaultBit + & ~uintMeshSurfaceBit + & ~uintMeshFaultBit + & ~intersectionCellFaceBit + & ~intersectionCellMeshBit + & ~intersectionFaultMeshBit; // Then turn the appropriate bits on according to the user settings @@ -804,20 +762,25 @@ void Rim3dView::updateDisplayModelVisibility() { mask |= uintSurfaceBit; mask |= uintFaultBit; + mask |= intersectionCellFaceBit; } else if (surfaceMode == FAULTS) { mask |= uintFaultBit; + mask |= intersectionCellFaceBit; } if (meshMode == FULL_MESH) { mask |= uintMeshSurfaceBit; mask |= uintMeshFaultBit; + mask |= intersectionCellMeshBit; + mask |= intersectionFaultMeshBit; } else if (meshMode == FAULTS_MESH) { mask |= uintMeshFaultBit; + mask |= intersectionFaultMeshBit; } m_viewer->setEnableMask(mask); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 95f3dedfd8..b98909b25a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -16,43 +16,31 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// - #pragma once + #include "RiuViewerToViewInterface.h" #include "RimViewWindow.h" +#include "RivCellSetEnum.h" + #include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmObject.h" + #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" #include "cafPdmFieldCvfVec3d.h" -#include "cafPdmObject.h" -#include "RivCellSetEnum.h" - -#include "cvfArray.h" #include "cvfBase.h" #include "cvfCollection.h" #include "cvfObject.h" #include - -class Rim3dOverlayInfoConfig; class RimCase; -class RimCellRangeFilter; -class RimCellRangeFilterCollection; -class RimIntersectionCollection; -class RimGridCollection; -class RimPropertyFilterCollection; -class RimViewController; -class RimViewLinker; class RiuViewer; class RimWellPathCollection; class RivWellPathsPartMgr; -class RimWellPath; namespace cvf { @@ -72,10 +60,13 @@ namespace caf enum PartRenderMaskEnum { - surfaceBit = 0x00000001, - meshSurfaceBit = 0x00000002, - faultBit = 0x00000004, - meshFaultBit = 0x00000008, + surfaceBit = 1, + meshSurfaceBit = 2, + faultBit = 4, + meshFaultBit = 8, + intersectionCellFaceBit = 16, + intersectionCellMeshBit = 32, + intersectionFaultMeshBit = 64 }; @@ -117,7 +108,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void disableLighting(bool disable); bool isLightingDisabled() const; - bool isGridVisualizationMode() const; + virtual bool isGridVisualizationMode() const = 0; void setScaleZAndUpdate(double scaleZ); virtual bool showActiveCellsOnly(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 3893ef477e..bf2b4b032b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -399,7 +399,8 @@ void RimEclipseView::createDisplayModel() if (!this->eclipsePropertyFilterCollection()->hasActiveFilters() - || this->viewController() && this->viewController()->isVisibleCellsOveridden()) + || ( this->viewController() + && this->viewController()->isVisibleCellsOveridden()) ) { std::vector geometryTypesToAdd; @@ -452,28 +453,41 @@ void RimEclipseView::createDisplayModel() { for (size_t gtIdx = 0; gtIdx < geometryTypesToAdd.size(); ++gtIdx) { - m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices); + if ( isGridVisualizationMode() ) + { + m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices); + } + else + { + m_reservoirGridPartManager->ensureStaticGeometryPartsCreated( geometryTypesToAdd[gtIdx]); + } } } - // Set static colors this->updateStaticCellColors(); } + else + { + std::vector empty; + setVisibleGridParts(empty); + } m_reservoirGridPartManager->clearWatertightGeometryFlags(); - if (faultCollection()->showFaultsOutsideFilters() || !this->eclipsePropertyFilterCollection()->hasActiveFilters() ) + if ( faultCollection()->showFaultCollection() + || !this->eclipsePropertyFilterCollection()->hasActiveFilters() ) { setVisibleGridPartsWatertight(); std::set faultGeometryTypesToAppend = allVisibleFaultGeometryTypes(); - RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->showFaultsOutsideFilters()); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->isShowingFaultsAndFaultsOutsideFilters()); for (size_t frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx) { for (RivCellSetEnum geometryType : faultGeometryTypesToAppend) { if (geometryType == PROPERTY_FILTERED || geometryType == PROPERTY_FILTERED_WELL_CELLS) continue; + m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryType); } @@ -569,10 +583,18 @@ void RimEclipseView::updateCurrentTimeStep() this->indicesToVisibleGrids(&gridIndices); geometriesToRecolor.push_back( PROPERTY_FILTERED); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep, gridIndices); - geometriesToRecolor.push_back( PROPERTY_FILTERED_WELL_CELLS); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); + + if ( isGridVisualizationMode() ) + { + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep, gridIndices); + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); + } + else + { + m_reservoirGridPartManager->ensureDynamicGeometryPartsCreated(PROPERTY_FILTERED, m_currentTimeStep); + m_reservoirGridPartManager->ensureDynamicGeometryPartsCreated(PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep); + } setVisibleGridParts(geometriesToRecolor); setVisibleGridPartsWatertight(); @@ -590,7 +612,7 @@ void RimEclipseView::updateCurrentTimeStep() } } - RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->showFaultsOutsideFilters()); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->isShowingFaultsAndFaultsOutsideFilters()); if (faultLabelType == PROPERTY_FILTERED) { m_reservoirGridPartManager->appendFaultLabelsDynamicGeometryPartsToModel(frameParts.p(), faultLabelType, m_currentTimeStep); @@ -614,7 +636,7 @@ void RimEclipseView::updateCurrentTimeStep() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE, gridIndices); - if (!faultCollection()->showFaultsOutsideFilters()) + if (!faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE); } @@ -623,7 +645,7 @@ void RimEclipseView::updateCurrentTimeStep() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), INACTIVE, gridIndices); - if (!faultCollection()->showFaultsOutsideFilters()) + if (!faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), INACTIVE); } @@ -1475,7 +1497,7 @@ std::set RimEclipseView::allVisibleFaultGeometryTypes() const std::set faultGeoTypes; faultGeoTypes.insert(m_visibleGridParts.begin(), m_visibleGridParts.end()); - if (faultCollection()->showFaultsOutsideFilters()) + if (faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { faultGeoTypes.insert(ACTIVE); faultGeoTypes.insert(ALL_WELL_CELLS); diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 55e918be68..8c144b3b1b 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -377,7 +377,7 @@ void RimFaultInViewCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimFaultInViewCollection::showFaultsOutsideFilters() const +bool RimFaultInViewCollection::isShowingFaultsAndFaultsOutsideFilters() const { if (!showFaultCollection) return false; diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h index 5dba0763f2..7e91ac2875 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h @@ -62,7 +62,7 @@ class RimFaultInViewCollection : public caf::PdmObject bool isGridVisualizationMode() const; - bool showFaultsOutsideFilters() const; + bool isShowingFaultsAndFaultsOutsideFilters() const; caf::PdmField showFaultFaces; caf::PdmField showOppositeFaultFaces; diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 50bffb09bc..bbd27691fa 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -34,6 +34,7 @@ #include "cvfModel.h" #include "cvfScene.h" +#include "RiuMainWindow.h" CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. Abstract class @@ -107,19 +108,14 @@ RimGridView::~RimGridView(void) //-------------------------------------------------------------------------------------------------- void RimGridView::showGridCells(bool enableGridCells) { - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } m_gridCollection->isActive = enableGridCells; + + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + m_gridCollection->updateConnectedEditors(); m_gridCollection->updateUiIconFromState(enableGridCells); } @@ -256,6 +252,14 @@ RimViewLinker* RimGridView::assosiatedViewLinker() const return viewLinker; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::isGridVisualizationMode() const +{ + return this->m_gridCollection->isActive(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h index 75c084dcc5..7d6baeebc1 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.h +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -20,6 +20,15 @@ #include "Rim3dView.h" +#include "cvfBase.h" +#include "cvfArray.h" + +class Rim3dOverlayInfoConfig; +class RimIntersectionCollection; +class RimPropertyFilterCollection; +class RimGridCollection; +class RimCellRangeFilterCollection; + class RimGridView : public Rim3dView { CAF_PDM_HEADER_INIT; @@ -46,7 +55,10 @@ class RimGridView : public Rim3dView RimViewController* viewController() const override; RimViewLinker* assosiatedViewLinker() const override; -protected: + + virtual bool isGridVisualizationMode() const override; + +protected: virtual void onTimeStepChanged() override; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; From d44ffbc1b5f37bb098d76e54474ebd0ce8bd275b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 5 Apr 2018 11:45:33 +0200 Subject: [PATCH 0601/1027] #2615 Compaction. Fixed compaction calculation expression --- .../GeoMechDataModel/RigFemPartResultsCollection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 973a9f120c..8b28a8cb01 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1490,7 +1490,11 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues } } - compactionFrame[n] = u3Frames->frameData(t)[closestRefNodeIdx] - u3Frames->frameData(t)[n]; + cvf::Vec3f currentNodeCoord = part->nodes().coordinates[n]; + if(currentNodeCoord.z() >= refElement.intersectionPoint.z()) + compactionFrame[n] = -(u3Frames->frameData(t)[n] - u3Frames->frameData(t)[closestRefNodeIdx]); + else + compactionFrame[n] = -(u3Frames->frameData(t)[closestRefNodeIdx] - u3Frames->frameData(t)[n]); } else { From 584c1084c0b8fe482e0f9fcdf92a630262ea725d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 5 Apr 2018 14:14:53 +0200 Subject: [PATCH 0602/1027] #2664 Fix missing update when creating curve --- .../Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp index d623a89d76..b1acef8728 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp @@ -62,6 +62,8 @@ void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) selectedWellPath->add3dWellLogCurve(rim3dWellLogExtractionCurve); + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); + RiaApplication::instance()->project()->updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogExtractionCurve); From 436420b648b7ea92b8c9739b6c13670c49ee059f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 5 Apr 2018 14:17:39 +0200 Subject: [PATCH 0603/1027] #2665 Fix draw plane position error with changed width --- .../ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index eb5b455741..78cbf6b989 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -185,7 +185,7 @@ double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCur } else { - return -cellSize * 2; + return -0.5*planeWidth(); } } @@ -198,7 +198,7 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - return cellSize * 4; + return cellSize * 1.0; } //-------------------------------------------------------------------------------------------------- From c7fbc99c9d99cc13b6aa57203bdeee3656813288 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 13:34:27 +0200 Subject: [PATCH 0604/1027] #2553 Move RigWellResultPoint into separate file --- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigSimWellData.cpp | 8 + .../ReservoirDataModel/RigSimWellData.h | 153 +----------------- .../ReservoirDataModel/RigWellResultPoint.cpp | 146 +++++++++++++++++ .../ReservoirDataModel/RigWellResultPoint.h | 114 +++++++++++++ 5 files changed, 273 insertions(+), 150 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigWellResultPoint.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 41f7511162..32e1a74614 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -63,6 +63,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.h ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h +${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h ${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h ) @@ -126,6 +127,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.cpp ${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp ) diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp index db934ee3cf..1b3072a523 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp @@ -22,6 +22,14 @@ #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigSimWellData::RigSimWellData() + : m_isMultiSegmentWell(false) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.h b/ApplicationCode/ReservoirDataModel/RigSimWellData.h index b13025ccdc..a8fa9c58e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.h +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.h @@ -18,6 +18,8 @@ #pragma once +#include "RigWellResultPoint.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cvfMath.h" @@ -27,162 +29,13 @@ #include -//================================================================================================== -/// Stores the info on a significant point in the well. Either a well-to-grid connection, or the -/// bottom position of a connection less well-segment -//================================================================================================== -struct RigWellResultPoint -{ - RigWellResultPoint() : - m_gridIndex(cvf::UNDEFINED_SIZE_T), - m_gridCellIndex(cvf::UNDEFINED_SIZE_T), - m_isOpen(false), - m_ertBranchId(-1), - m_ertSegmentId(-1), - m_bottomPosition(cvf::Vec3d::UNDEFINED), - m_flowRate(0.0), - m_oilRate(0.0), - m_gasRate(0.0), - m_waterRate(0.0) - { } - - bool isPointValid() const - { - return m_bottomPosition != cvf::Vec3d::UNDEFINED; - } - - bool isCell() const - { - return m_gridCellIndex != cvf::UNDEFINED_SIZE_T; - } - - bool isValid() const - { - return isCell() || isPointValid(); - } - - double flowRate() const - { - if ( isCell() && m_isOpen) - { - return m_flowRate; - } - else - { - return 0.0; - } - } - - double oilRate() const - { - if ( isCell() && m_isOpen) - { - return m_oilRate; - } - else - { - return 0.0; - } - } - - double gasRate() const - { - if ( isCell() && m_isOpen) - { - return m_gasRate; - } - else - { - return 0.0; - } - } - - double waterRate() const - { - if ( isCell() && m_isOpen) - { - return m_waterRate; - } - else - { - return 0.0; - } - } - - bool isEqual(const RigWellResultPoint& other ) const - { - return ( m_gridIndex == other.m_gridIndex - && m_gridCellIndex == other.m_gridCellIndex - && m_isOpen == other.m_isOpen - && m_ertBranchId == other.m_ertBranchId - && m_ertSegmentId == other.m_ertSegmentId - && m_flowRate == other.m_flowRate); - } - - size_t m_gridIndex; - size_t m_gridCellIndex; //< Index to cell which is included in the well - - bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation - - int m_ertBranchId; - int m_ertSegmentId; - - cvf::Vec3d m_bottomPosition; //< The estimated bottom position of the well segment, when we have no grid cell connections for the segment. - double m_flowRate; //< Total reservoir rate - double m_oilRate; //< Surface oil rate - double m_gasRate; //< Surface gas rate For Field-unit, converted to [stb/day] to allign with oil and water. - double m_waterRate; //< Surface water rate -}; - -//================================================================================================== -/// This class contains the connection information from and including a splitpoint to the end of -/// that particular branch. -//================================================================================================== -struct RigWellResultBranch -{ - RigWellResultBranch() : - m_ertBranchId(-1) - {} - - int m_ertBranchId; - std::vector m_branchResultPoints; -}; - -//================================================================================================== -/// This class contains the well information for one timestep. -/// The main content is the vector of RigWellResultBranch which contains all the simple pipe -/// sections that make up the well -//================================================================================================== -class RigWellResultFrame -{ -public: - enum WellProductionType { PRODUCER, OIL_INJECTOR, GAS_INJECTOR, WATER_INJECTOR, UNDEFINED_PRODUCTION_TYPE }; - -public: - RigWellResultFrame() : - m_productionType(UNDEFINED_PRODUCTION_TYPE), - m_isOpen(false) - { } - - const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; - - RigWellResultPoint wellHeadOrStartCell() const; - WellProductionType m_productionType; - bool m_isOpen; - RigWellResultPoint m_wellHead; - QDateTime m_timestamp; - - std::vector m_wellResultBranches; -}; - - //================================================================================================== /// //================================================================================================== class RigSimWellData : public cvf::Object { public: - RigSimWellData() { m_isMultiSegmentWell = false; } + RigSimWellData(); void setMultiSegmentWell(bool isMultiSegmentWell); bool isMultiSegmentWell() const; diff --git a/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp new file mode 100644 index 0000000000..dbafb10de6 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp @@ -0,0 +1,146 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigWellResultPoint.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellResultPoint::RigWellResultPoint() + : m_gridIndex(cvf::UNDEFINED_SIZE_T) + , m_gridCellIndex(cvf::UNDEFINED_SIZE_T) + , m_isOpen(false) + , m_ertBranchId(-1) + , m_ertSegmentId(-1) + , m_bottomPosition(cvf::Vec3d::UNDEFINED) + , m_flowRate(0.0) + , m_oilRate(0.0) + , m_gasRate(0.0) + , m_waterRate(0.0) + , m_connectionFactor(0.0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isPointValid() const +{ + return m_bottomPosition != cvf::Vec3d::UNDEFINED; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isCell() const +{ + return m_gridCellIndex != cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isValid() const +{ + return isCell() || isPointValid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isEqual(const RigWellResultPoint& other) const +{ + return ( m_gridIndex == other.m_gridIndex + && m_gridCellIndex == other.m_gridCellIndex + && m_isOpen == other.m_isOpen + && m_ertBranchId == other.m_ertBranchId + && m_ertSegmentId == other.m_ertSegmentId + && m_flowRate == other.m_flowRate + && m_oilRate == other.m_oilRate + && m_gasRate == other.m_gasRate + && m_waterRate == other.m_waterRate); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::flowRate() const +{ + if (isCell() && m_isOpen) + { + return m_flowRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::oilRate() const +{ + if (isCell() && m_isOpen) + { + return m_oilRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::gasRate() const +{ + if (isCell() && m_isOpen) + { + return m_gasRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::waterRate() const +{ + if (isCell() && m_isOpen) + { + return m_waterRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::connectionFactor() const +{ + return m_connectionFactor; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h new file mode 100644 index 0000000000..8cfe5255c1 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h @@ -0,0 +1,114 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfVector3.h" + +#include + +#include + + +//================================================================================================== +/// Stores the info on a significant point in the well. Either a well-to-grid connection, or the +/// bottom position of a connection less well-segment +//================================================================================================== +struct RigWellResultPoint +{ + RigWellResultPoint(); + + bool isPointValid() const; + bool isCell() const; + bool isValid() const; + bool isEqual(const RigWellResultPoint& other) const; + + double flowRate() const; + double oilRate() const; + double gasRate() const; + double waterRate() const; + double connectionFactor() const; + + size_t m_gridIndex; + size_t m_gridCellIndex; //< Index to cell which is included in the well + bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation + + int m_ertBranchId; + int m_ertSegmentId; + + cvf::Vec3d m_bottomPosition; //< The estimated bottom position of the well segment, when we have no grid cell connections for + //the segment. + double m_flowRate; //< Total reservoir rate + double m_oilRate; //< Surface oil rate + double m_gasRate; //< Surface gas rate For Field-unit, converted to [stb/day] to align with oil and water. + double m_waterRate; //< Surface water rate + + double m_connectionFactor; +}; + +//================================================================================================== +/// This class contains the connection information from and including a splitpoint to the end of +/// that particular branch. +//================================================================================================== +struct RigWellResultBranch +{ + RigWellResultBranch() + : m_ertBranchId(-1) + { + } + + int m_ertBranchId; + std::vector m_branchResultPoints; +}; + +//================================================================================================== +/// This class contains the well information for one timestep. +/// The main content is the vector of RigWellResultBranch which contains all the simple pipe +/// sections that make up the well +//================================================================================================== +class RigWellResultFrame +{ +public: + enum WellProductionType + { + PRODUCER, + OIL_INJECTOR, + GAS_INJECTOR, + WATER_INJECTOR, + UNDEFINED_PRODUCTION_TYPE + }; + +public: + RigWellResultFrame() + : m_productionType(UNDEFINED_PRODUCTION_TYPE) + , m_isOpen(false) + { + } + + const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; + + RigWellResultPoint wellHeadOrStartCell() const; + WellProductionType m_productionType; + bool m_isOpen; + RigWellResultPoint m_wellHead; + QDateTime m_timestamp; + + std::vector m_wellResultBranches; +}; + From 0512d3fbbc966163fe4ed50f19625b584f3e8cc0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 13:41:20 +0200 Subject: [PATCH 0605/1027] #2553 Well CF Visualization: Read well connection factor from ecllib --- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index adb4b82cc2..35543a58c8 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -1149,7 +1149,7 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa double oilRate = well_conn_get_oil_rate(ert_connection) ; double gasRate = well_conn_get_gas_rate(ert_connection); double waterRate = well_conn_get_water_rate(ert_connection); - + double connectionFactor = well_conn_get_connection_factor(ert_connection); RigWellResultPoint resultPoint; @@ -1167,6 +1167,8 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa resultPoint.m_waterRate = waterRate; resultPoint.m_gasRate = RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents(m_eclipseCase->unitsType(), gasRate); + + resultPoint.m_connectionFactor = connectionFactor; } return resultPoint; From 50212fff0db1253749b7d50a3bf648635d95ba54 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 13:46:50 +0200 Subject: [PATCH 0606/1027] #2553 Well CF Visualization: Add findOrCreateSimWellExtractor() --- .../Application/Tools/RiaExtractionTools.cpp | 25 +++++++++++++------ .../Application/Tools/RiaExtractionTools.h | 10 +++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.cpp b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp index 56a2f25b10..a401c6b254 100644 --- a/ApplicationCode/Application/Tools/RiaExtractionTools.cpp +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp @@ -24,6 +24,7 @@ #include "RimEclipseCase.h" #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimSimWellInView.h" #include "RimWellLogPlotCollection.h" //-------------------------------------------------------------------------------------------------- @@ -48,22 +49,32 @@ RigGeoMechWellLogExtractor* RiaExtractionTools::wellLogExtractorGeoMechCase(RimW return wlPlotCollection->findOrCreateExtractor(wellPath, geomCase); } -/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor(const QString& simWellName, - const QString& caseUserDescription, - const RigWellPath* wellPathGeom, - const RimEclipseCase* eclipseCase) +RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor(const RimSimWellInView* simWell, + const RigWellPath* wellPathGeom) { auto wlPlotCollection = wellLogPlotCollection(); if (!wlPlotCollection) return nullptr; + if (!(simWell && wellPathGeom)) + { + return nullptr; + } + + RimEclipseCase* eclipseCase = nullptr; + simWell->firstAncestorOrThisOfType(eclipseCase); + if (!(eclipseCase && eclipseCase->eclipseCaseData())) + { + return nullptr; + } + + QString caseUserDescription = eclipseCase->caseUserDescription(); + return wlPlotCollection->findOrCreateSimWellExtractor( - simWellName, caseUserDescription, wellPathGeom, eclipseCase->eclipseCaseData()); + simWell->name, caseUserDescription, wellPathGeom, eclipseCase->eclipseCaseData()); } -*/ //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.h b/ApplicationCode/Application/Tools/RiaExtractionTools.h index 8690884c05..6b1a3bee29 100644 --- a/ApplicationCode/Application/Tools/RiaExtractionTools.h +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.h @@ -20,11 +20,12 @@ class RigEclipseWellLogExtractor; class RigGeoMechWellLogExtractor; +class RigWellPath; class RimEclipseCase; class RimGeoMechCase; +class RimSimWellInView; class RimWellLogPlotCollection; class RimWellPath; -class RigWellPath; class QString; @@ -36,12 +37,7 @@ namespace RiaExtractionTools RigEclipseWellLogExtractor* wellLogExtractorEclipseCase(RimWellPath* wellPath, RimEclipseCase* eclipseCase); RigGeoMechWellLogExtractor* wellLogExtractorGeoMechCase(RimWellPath* wellPath, RimGeoMechCase* geomCase); -/* -RigEclipseWellLogExtractor* findOrCreateSimWellExtractor(const QString& simWellName, - const QString& caseUserDescription, - const RigWellPath* wellPathGeom, - const RimEclipseCase* eclipseCase); -*/ +RigEclipseWellLogExtractor* findOrCreateSimWellExtractor(const RimSimWellInView* simWell, const RigWellPath* wellPathGeom); RimWellLogPlotCollection* wellLogPlotCollection(); From c0054cff9187ad84d507d5fdaf297f9065abc937 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 13:50:14 +0200 Subject: [PATCH 0607/1027] #2553 Well CF Visualization: Add recompute of virtual conn factors --- .../ProjectDataModel/RimEclipseCase.cpp | 40 ++++++++++------- .../ProjectDataModel/RimEclipseView.cpp | 37 +++++++++++++++- .../ProjectDataModel/RimEclipseView.h | 1 + .../RimVirtualPerforationResults.cpp | 20 ++++++++- .../RimVirtualPerforationResults.h | 5 ++- .../Completions/RigCompletionData.cpp | 8 ++++ .../Completions/RigCompletionData.h | 2 + ...igVirtualPerforationTransmissibilities.cpp | 44 +++++++++++++++++++ .../RigVirtualPerforationTransmissibilities.h | 7 +++ 9 files changed, 142 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 574672386f..d5899d5dc9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -394,31 +394,39 @@ const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirt } } - rigEclipseCase->setVirtualPerforationTransmissibilities(perfTrans.p()); - + ; + for (const auto& wellRes : rigEclipseCase->wellResults()) { - double minValue = HUGE_VAL; - double maxValue = -HUGE_VAL; - double posClosestToZero = HUGE_VAL; - double negClosestToZero = -HUGE_VAL; - - perfTrans->computeMinMax(&minValue, &maxValue, &posClosestToZero, &negClosestToZero); - - if (minValue != HUGE_VAL) + std::vector> completionsPerTimeStep; + for (size_t i = 0; i < timeStepDates().size(); i++) { - for (const auto& v : views()) + std::vector completionData; + + if (wellRes->hasWellResult(i)) { - RimEclipseView* eclView = dynamic_cast(v); - if (eclView) + for (const auto& wellResultBranch : wellRes->wellResultFrame(i).m_wellResultBranches) { - RimLegendConfig* legendConfig = eclView->virtualPerforationResult()->legendConfig(); + for (const auto& r : wellResultBranch.m_branchResultPoints) + { + if (r.isValid() && r.m_isOpen) + { + RigCompletionData compData(wellRes->m_wellName, RigCompletionDataGridCell(r.m_gridCellIndex, rigEclipseCase->mainGrid()), 0); + compData.setTransmissibility(r.connectionFactor()); - legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); - legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); + completionData.push_back(compData); + } + } } + } + + completionsPerTimeStep.push_back(completionData); + + perfTrans->setCompletionDataForSimWell(wellRes.p(), completionsPerTimeStep); } } + + rigEclipseCase->setVirtualPerforationTransmissibilities(perfTrans.p()); } return rigEclipseCase->virtualPerforationTransmissibilities(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index bf2b4b032b..2ab8ea429b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -33,6 +33,7 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" #include "RigSimWellData.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellEdgeColors.h" @@ -310,8 +311,6 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c scheduleCreateDisplayModelAndRedraw(); } - - } //-------------------------------------------------------------------------------------------------- @@ -843,6 +842,11 @@ void RimEclipseView::onLoadDataAndUpdate() } } + if (this->isVirtualConnectionFactorGeometryVisible()) + { + m_virtualPerforationResult->loadData(); + } + this->scheduleCreateDisplayModelAndRedraw(); } @@ -1103,6 +1107,8 @@ void RimEclipseView::updateLegends() if (m_virtualPerforationResult->isActive()) { + updateVirtualConnectionLegendRanges(); + RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); @@ -1593,6 +1599,33 @@ void RimEclipseView::resetLegendsInViewer() m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::updateVirtualConnectionLegendRanges() +{ + if (!eclipseCase()) return; + + const RigVirtualPerforationTransmissibilities* virtualTransmissibilities = eclipseCase()->computeAndGetVirtualPerforationTransmissibilities(); + if (virtualTransmissibilities) + { + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + double posClosestToZero = HUGE_VAL; + double negClosestToZero = -HUGE_VAL; + + virtualTransmissibilities->computeMinMax(&minValue, &maxValue, &posClosestToZero, &negClosestToZero); + + if (minValue != HUGE_VAL) + { + RimLegendConfig* legendConfig = virtualPerforationResult()->legendConfig(); + + legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 23b037670b..492bf8b455 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -162,6 +162,7 @@ class RimEclipseView : public RimGridView void updateLegends(); void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData); virtual void resetLegendsInViewer() override; + void updateVirtualConnectionLegendRanges(); std::set allVisibleFaultGeometryTypes() const; void updateFaultColors(); diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index c15d87d138..6107b00417 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -18,6 +18,7 @@ #include "RimVirtualPerforationResults.h" +#include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimLegendConfig.h" @@ -35,7 +36,7 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() CAF_PDM_InitObject(connectionFactorUiName, ":/CellResult.png", "", ""); CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", false, "", "", "", ""); - CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 0.2, "Geometry Scale Factor", "", "", ""); + CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 1.0, "Geometry Scale Factor", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); m_legendConfig.uiCapability()->setUiHidden(true); @@ -75,6 +76,19 @@ RimLegendConfig* RimVirtualPerforationResults::legendConfig() const return m_legendConfig(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::loadData() +{ + RimEclipseCase* eclipseCase = nullptr; + this->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase) + { + eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -85,6 +99,8 @@ void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* c if (changedField == &m_isActive) { updateUiIconFromToggleField(); + + loadData(); } RimEclipseView* eclView = nullptr; @@ -124,7 +140,7 @@ void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::P } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimVirtualPerforationResults::initAfterRead() { diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h index 6e79b6f597..cc55c9c0fc 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -39,10 +39,11 @@ class RimVirtualPerforationResults : public caf::PdmObject RimVirtualPerforationResults(); virtual ~RimVirtualPerforationResults(); - bool isActive() const; - double geometryScaleFactor() const; + bool isActive() const; + double geometryScaleFactor() const; RimLegendConfig* legendConfig() const; + void loadData(); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp index 6ff440d92f..e66bf0b21d 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp @@ -129,6 +129,14 @@ void RigCompletionData::setDiameter(double diameter) m_diameter = diameter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setTransmissibility(double transmissibility) +{ + m_transmissibility = transmissibility; +} + //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h index 05e05cb081..0e6e337366 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h @@ -70,6 +70,7 @@ class RigCompletionData RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue); ~RigCompletionData(); + RigCompletionData(const RigCompletionData& other); bool operator<(const RigCompletionData& other) const; @@ -78,6 +79,7 @@ class RigCompletionData void setFromFracture(double transmissibility, double skinFactor, double diameter); void setSecondOrderingValue(double orderingValue); void setDiameter(double diameter); + void setTransmissibility(double transmissibility); void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, double skinFactor, diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index 89a0da41dd..b130555583 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigVirtualPerforationTransmissibilities.h" + #include "RigStatisticsMath.h" //-------------------------------------------------------------------------------------------------- @@ -113,6 +114,33 @@ const std::map>& return dummy; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::setCompletionDataForSimWell( + const RigSimWellData* simWellData, + std::vector>& completionsPerTimeStep) +{ + m_mapFromSimWellToCompletionData[simWellData] = completionsPerTimeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& + RigVirtualPerforationTransmissibilities::completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const +{ + static std::vector dummayVector; + + auto item = m_mapFromSimWellToCompletionData.find(simWellData); + if (item != m_mapFromSimWellToCompletionData.end()) + { + return item->second[timeStepIndex]; + } + + return dummayVector; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -143,6 +171,22 @@ void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue, } } + for (const auto& item : m_mapFromSimWellToCompletionData) + { + auto dataForSimWell = item.second; + + for (const auto& timeStepFrame : dataForSimWell) + { + for (const auto& completionData : timeStepFrame) + { + double transmissibility = completionData.transmissibility(); + + minMaxAccumulator.addValue(transmissibility); + posNegAccumulator.addValue(transmissibility); + } + } + } + if (*minValue) *minValue = minMaxAccumulator.min; if (*maxValue) *maxValue = minMaxAccumulator.max; if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h index 0d93720fa5..6e7134b06d 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -28,6 +28,7 @@ class RigCompletionData; class RigCompletionDataGridCell; +class RigSimWellData; class RimWellPath; //-------------------------------------------------------------------------------------------------- @@ -60,7 +61,13 @@ class RigVirtualPerforationTransmissibilities : public cvf::Object const std::map>& multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const; + void setCompletionDataForSimWell(const RigSimWellData* simWellData, std::vector>& completionsPerTimeStep); + + const std::vector& + completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const; + void computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; private: std::map> m_mapFromWellToCompletionData; + std::map>> m_mapFromSimWellToCompletionData; }; From 9b0427aba94583f887795af7cddc39e3e5f055eb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 13:54:15 +0200 Subject: [PATCH 0608/1027] #2553 Well CF Visualization: Add viz of connection factors on sim wells --- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivSimWellConnectionSourceInfo.cpp | 60 ++++++++++ .../RivSimWellConnectionSourceInfo.h | 47 ++++++++ .../RivSimWellPipesPartMgr.cpp | 113 +++++++++++++++++- .../RivSimWellPipesPartMgr.h | 6 +- ...vWellConnectionFactorGeometryGenerator.cpp | 57 ++++++++- ...RivWellConnectionFactorGeometryGenerator.h | 8 +- .../RivWellConnectionFactorPartMgr.cpp | 49 ++------ .../UserInterface/RiuViewerCommands.cpp | 50 ++++++++ 9 files changed, 341 insertions(+), 51 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp create mode 100644 ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 3872abd58a..29bef15533 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -42,6 +42,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.h ) @@ -83,6 +84,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.cpp ) diff --git a/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp new file mode 100644 index 0000000000..0018a16497 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivSimWellConnectionSourceInfo.h" + +#include "RimSimWellInView.h" +#include "RivWellConnectionFactorGeometryGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivSimWellConnectionSourceInfo::RivSimWellConnectionSourceInfo(RimSimWellInView* simWellInView, + RivWellConnectionFactorGeometryGenerator* geometryGenerator) + : m_simWellInView(simWellInView) + , m_geometryGenerator(geometryGenerator) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInView* RivSimWellConnectionSourceInfo::simWellInView() const +{ + return m_simWellInView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivSimWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0; + + return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivSimWellConnectionSourceInfo::connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0.0; + + return m_geometryGenerator->connectionFactor(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h new file mode 100644 index 0000000000..464e90a81b --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmPointer.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class RimSimWellInView; +class RivWellConnectionFactorGeometryGenerator; + +//================================================================================================== +/// +//================================================================================================== +class RivSimWellConnectionSourceInfo : public cvf::Object +{ +public: + explicit RivSimWellConnectionSourceInfo(RimSimWellInView* simWellInView, RivWellConnectionFactorGeometryGenerator* geometryGenerator); + + RimSimWellInView* simWellInView() const; + + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + double connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const; + +private: + caf::PdmPointer m_simWellInView; + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index bc8e2abf7c..4f8852c73b 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -20,16 +20,29 @@ #include "RivSimWellPipesPartMgr.h" +#include "RiaExtractionTools.h" + +#include "RigEclipseWellLogExtractor.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellLogExtractor.h" +#include "RigWellPath.h" + #include "Rim3dView.h" +#include "RimEclipseView.h" +#include "RimLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" +#include "RimVirtualPerforationResults.h" #include "RivPipeGeometryGenerator.h" -#include "RivSimWellPipeSourceInfo.h" #include "RivSectionFlattner.h" +#include "RivSimWellConnectionSourceInfo.h" +#include "RivSimWellPipeSourceInfo.h" +#include "RivWellConnectionFactorGeometryGenerator.h" +#include "RivWellConnectionSourceInfo.h" -#include "cafEffectGenerator.h" #include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" @@ -74,7 +87,7 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellPipeParts(displayXf, false, 0.0, -1); + buildWellPipeParts(displayXf, false, 0.0, -1, frameIndex); std::list::iterator it; for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) @@ -88,6 +101,11 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi { model->addPart(it->m_centerLinePart.p()); } + + if (it->m_connectionFactorsPart.notNull()) + { + model->addPart(it->m_connectionFactorsPart.p()); + } } } @@ -104,7 +122,7 @@ void RivSimWellPipesPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::Mod if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellPipeParts(displayXf, true, flattenedIntersectionExtentLength, branchIndex); + buildWellPipeParts(displayXf, true, flattenedIntersectionExtentLength, branchIndex, frameIndex); std::list::iterator it; for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) @@ -127,7 +145,8 @@ void RivSimWellPipesPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::Mod void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, bool doFlatten, double flattenedIntersectionExtentLength, - int branchIndex) + int branchIndex, + size_t frameIndex) { if (!this->viewWithSettings()) return; @@ -237,9 +256,91 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform pbd.m_largeSurfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); } + pbd.m_connectionFactorGeometryGenerator = nullptr; + pbd.m_connectionFactorsPart = nullptr; + + RimEclipseView* eclipseView = nullptr; + m_rimWell->firstAncestorOrThisOfType(eclipseView); + + if (eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible()) + { + RigSimWellData* simWellData = m_rimWell->simWellData(); + + if (simWellData && simWellData->hasWellResult(frameIndex)) + { + const RigWellResultFrame& wResFrame = simWellData->wellResultFrame(frameIndex); + + std::vector completionVizDataItems; + + RimVirtualPerforationResults* virtualPerforationResult = eclipseView->virtualPerforationResult(); + { + auto wellPaths = m_rimWell->wellPipeBranches(); + + const RigWellPath* wellPath = wellPaths[brIdx]; + + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor(m_rimWell, wellPath); + if (extractor) + { + std::vector wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); + + for (const auto& intersectionInfo : wellPathCellIntersections) + { + size_t globalCellIndex = intersectionInfo.globCellIndex; + + for (const auto& wellResultPoint : pbd.m_cellIds) + { + if (wellResultPoint.m_gridCellIndex == globalCellIndex) + { + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; + + double middleMD = (startMD + endMD) / 2.0; + + cvf::Vec3d defaultLocationInDomainCoord = wellPath->interpolatedPointAlongWellPath(middleMD); + + cvf::Vec3d p1; + cvf::Vec3d p2; + wellPath->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); + + cvf::Vec3d defaultWellPathDirection = (p2 - p1).getNormalized(); + + cvf::Vec3d anchor = displayXf->transformToDisplayCoord(defaultLocationInDomainCoord);; + + const RigWellResultPoint* wResCell = wResFrame.findResultCell(wellResultPoint.m_gridIndex, wellResultPoint.m_gridCellIndex); + if (wResCell && wResCell->m_isOpen) + { + CompletionVizData data(anchor, defaultWellPathDirection, wResCell->connectionFactor(), globalCellIndex); + + completionVizDataItems.push_back(data); + } + } + } + } + } + } + + if (!completionVizDataItems.empty()) + { + double radius = pipeRadius * virtualPerforationResult->geometryScaleFactor(); + radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry scale factor is set to 1.0 + + pbd.m_connectionFactorGeometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); + + cvf::ScalarMapper* scalarMapper = virtualPerforationResult->legendConfig()->scalarMapper(); + cvf::ref part = pbd.m_connectionFactorGeometryGenerator->createSurfacePart(scalarMapper, eclipseView->isLightingDisabled()); + if (part.notNull()) + { + cvf::ref sourceInfo = new RivSimWellConnectionSourceInfo(m_rimWell, pbd.m_connectionFactorGeometryGenerator.p()); + part->setSourceInfo(sourceInfo.p()); + } + + pbd.m_connectionFactorsPart = part; + } + } + } + if (doFlatten) flattenedStartOffset += { 2*flattenedIntersectionExtentLength, 0.0, 0.0}; } - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 5696c8e676..465f840131 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -43,6 +43,7 @@ namespace caf class RivPipeGeometryGenerator; class Rim3dView; class RimSimWellInView; +class RivWellConnectionFactorGeometryGenerator; class RivSimWellPipesPartMgr : public cvf::Object { @@ -70,7 +71,8 @@ class RivSimWellPipesPartMgr : public cvf::Object void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, bool doFlatten, double flattenedIntersectionExtentLength, - int branchIndex); + int branchIndex, + size_t frameIndex); caf::PdmPointer m_rimWell; @@ -85,6 +87,8 @@ class RivSimWellPipesPartMgr : public cvf::Object cvf::ref m_centerLinePart; cvf::ref m_centerLineDrawable; + cvf::ref m_connectionFactorGeometryGenerator; + cvf::ref m_connectionFactorsPart; }; std::list m_wellBranches; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index 2d7b557987..77f05c5950 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -18,17 +18,20 @@ #include "RivWellConnectionFactorGeometryGenerator.h" +#include "cafEffectGenerator.h" #include "cvfArray.h" #include "cvfDrawableGeo.h" +#include "cvfPart.h" #include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfScalarMapper.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( - std::vector& centerColorPairs, + std::vector& completionVizData, float radius) - : m_completionVizData(centerColorPairs) + : m_completionVizData(completionVizData) , m_radius(radius) , m_trianglesPerConnection(0) { @@ -39,6 +42,56 @@ RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerat //-------------------------------------------------------------------------------------------------- RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfacePart(const cvf::ScalarMapper* scalarMapper, bool disableLighting) +{ + if (!scalarMapper) return nullptr; + + cvf::ref drawable = createSurfaceGeometry(); + if (drawable.notNull()) + { + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + + // Compute texture coords + cvf::ref textureCoords = new cvf::Vec2fArray(); + { + textureCoords->reserve(drawable->vertexArray()->size()); + size_t verticesPerItem = drawable->vertexArray()->size() / m_completionVizData.size(); + + textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); + + for (const auto& item : m_completionVizData) + { + cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f); + if (item.m_connectionFactor != HUGE_VAL) + { + textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor); + } + + for (size_t i = 0; i < verticesPerItem; i++) + { + textureCoords->add(textureCoord); + } + } + } + + drawable->setTextureCoordArray(textureCoords.p()); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + effGen.disableLighting(disableLighting); + + cvf::ref eff = effGen.generateCachedEffect(); + part->setEffect(eff.p()); + + return part; + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h index b3b9cf753e..9e9535f2cd 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h @@ -28,6 +28,8 @@ namespace cvf { class DrawableGeo; +class Part; +class ScalarMapper; } // namespace cvf //-------------------------------------------------------------------------------------------------- @@ -55,16 +57,18 @@ struct CompletionVizData class RivWellConnectionFactorGeometryGenerator : public cvf::Object { public: - RivWellConnectionFactorGeometryGenerator(std::vector& centerColorPairs, float radius); + RivWellConnectionFactorGeometryGenerator(std::vector& completionVizData, float radius); ~RivWellConnectionFactorGeometryGenerator(); - cvf::ref createSurfaceGeometry(); + cvf::ref createSurfacePart(const cvf::ScalarMapper* scalarMapper, bool disableLighting); double connectionFactor(cvf::uint triangleIndex) const; size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; private: size_t mapFromTriangleToConnectionIndex(cvf::uint triangleIndex) const; + cvf::ref createSurfaceGeometry(); + static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); static void createStarGeometry(std::vector* vertices, std::vector* indices, float radius, float thickness); diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 24fd04619c..b481d12924 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -149,52 +149,21 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode if (!completionVizDataItems.empty()) { - double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor(); + double characteristicCellSize = eclView->ownerCase()->characteristicCellSize(); - m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); - auto drawable = m_geometryGenerator->createSurfaceGeometry(); + double radius = m_rimWell->wellPathRadius(characteristicCellSize) * m_virtualPerforationResult->geometryScaleFactor(); + radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry scale factor is set to 1.0 - cvf::ref part = new cvf::Part; - part->setDrawable(drawable.p()); + m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); - - // Compute texture coords - cvf::ref textureCoords = new cvf::Vec2fArray(); + cvf::ref part = m_geometryGenerator->createSurfacePart(scalarMapper, eclView->isLightingDisabled()); + if (part.notNull()) { - textureCoords->reserve(drawable->vertexArray()->size()); - size_t verticesPerItem = drawable->vertexArray()->size() / completionVizDataItems.size(); + cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p()); + part->setSourceInfo(sourceInfo.p()); - textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); - - for (const auto& item : completionVizDataItems) - { - cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f); - if (item.m_connectionFactor != HUGE_VAL) - { - textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor); - } - - for (size_t i = 0; i < verticesPerItem; i++) - { - textureCoords->add(textureCoord); - } - } + model->addPart(part.p()); } - - drawable->setTextureCoordArray(textureCoords.p()); - - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - - bool disableLighting = eclView->isLightingDisabled(); - effGen.disableLighting(disableLighting); - - cvf::ref eff = effGen.generateCachedEffect(); - part->setEffect(eff.p()); - - cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p()); - part->setSourceInfo(sourceInfo.p()); - - model->addPart(part.p()); } } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index fab2e2ba2a..ddadc56f74 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -71,12 +71,14 @@ #include "RivIntersectionBoxSourceInfo.h" #include "RivIntersectionSourceInfo.h" #include "RivObjectSourceInfo.h" +#include "RivSimWellConnectionSourceInfo.h" #include "RivSimWellPipeSourceInfo.h" #include "RivSourceInfo.h" #include "RivTernarySaturationOverlayItem.h" #include "RivWellConnectionSourceInfo.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathSourceInfo.h" + #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" #include "cafCmdFeatureMenuBuilder.h" @@ -690,6 +692,54 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM RiuMainWindow::instance()->selectAsCurrentItem(wellConnectionSourceInfo->wellPath(), allowActiveViewChange); } + else if (dynamic_cast(firstHitPart->sourceInfo())) + { + const RivSimWellConnectionSourceInfo* simWellConnectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + size_t globalCellIndex = simWellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); + double connectionFactor = simWellConnectionSourceInfo->connectionFactorFromTriangleIndex(firstPartTriangleIndex); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCase* eclipseCase = nullptr; + eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + if (eclipseCase->eclipseCaseData() && + eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities()) + { + auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); + size_t timeStep = eclipseView->currentTimeStep(); + + const auto& completionData = connectionFactors->completionsForSimWell(simWellConnectionSourceInfo->simWellInView()->simWellData(), timeStep); + + for (const auto& compData : completionData) + { + if (compData.completionDataGridCell().globalCellIndex() == globalCellIndex) + { + { + QString resultInfoText = QString("Simulation Well Connection Factor : %1

").arg(connectionFactor); + + { + RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); + + resultInfoText += textBuilder.geometrySelectionText("
"); + } + + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } + + break; + } + } + } + + } + + RiuMainWindow::instance()->selectAsCurrentItem(simWellConnectionSourceInfo->simWellInView(), allowActiveViewChange); + } } if (firstNncHitPart && firstNncHitPart->sourceInfo()) From 69b6ca6956b4b9e01ec4523c1825af590cad7114 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 14:25:06 +0200 Subject: [PATCH 0609/1027] Fix signed / unsigned compare --- ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 4f8852c73b..fa6d0e464e 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -165,7 +165,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform size_t branchIdxStop = pipeBranchesCellIds.size(); if (m_pipeBranchesCLCoords.size() > 1) { - if (branchIndex >= 0 && branchIndex < branchIdxStop) + if (branchIndex >= 0 && branchIndex < static_cast(branchIdxStop)) { branchIdxStart = branchIndex; branchIdxStop = branchIdxStart + 1; From 98c8f3305d8067810e70e3022758b013832b4d96 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Apr 2018 14:47:03 +0200 Subject: [PATCH 0610/1027] Add missing include --- .../RivWellConnectionFactorGeometryGenerator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp index 77f05c5950..c28f0b8a3b 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -25,6 +25,8 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapper.h" +#include // Needed for HUGE_VAL on Linux + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From 81354e0408bacb48507595614a02afc3004d9aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 22 Mar 2018 14:40:21 +0100 Subject: [PATCH 0611/1027] #2610 Add RifEnsambleParametersReader and RifFileParseTools --- .../FileInterface/CMakeLists_files.cmake | 4 + .../FileInterface/RifCsvUserDataParser.cpp | 28 +-- .../FileInterface/RifCsvUserDataParser.h | 1 - .../RifElementPropertyTableReader.cpp | 19 +- .../RifElementPropertyTableReader.h | 9 - .../RifEnsambleParametersReader.cpp | 212 ++++++++++++++++++ .../RifEnsambleParametersReader.h | 84 +++++++ .../FileInterface/RifFileParseTools.cpp | 33 +++ .../FileInterface/RifFileParseTools.h | 42 ++++ 9 files changed, 386 insertions(+), 46 deletions(-) create mode 100644 ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp create mode 100644 ApplicationCode/FileInterface/RifEnsambleParametersReader.h create mode 100644 ApplicationCode/FileInterface/RifFileParseTools.cpp create mode 100644 ApplicationCode/FileInterface/RifFileParseTools.h diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 88fdb8618a..92b5132317 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -39,6 +39,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.h ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h +${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.h +${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h @@ -82,6 +84,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt #${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp diff --git a/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp index 7b0adfa5e6..4b8f283620 100644 --- a/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp @@ -20,6 +20,7 @@ #include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" +#include "RifFileParseTools.h" #include "RiaDateStringParser.h" #include "RiaLogging.h" @@ -136,7 +137,7 @@ QString RifCsvUserDataParser::previewText(int lineCount, const AsciiDataParseOpt outStream << ""; int iCol = 0; - QStringList cols = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList cols = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); for (const QString& cellData : cols) { if (cellData == parseOptions.timeSeriesColumnName && header) @@ -187,7 +188,7 @@ bool RifCsvUserDataParser::parseColumnInfo(QTextStream* dataStream, const AsciiD QString line = dataStream->readLine(); if (line.trimmed().isEmpty()) continue; - QStringList lineColumns = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList lineColumns = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); int colCount = lineColumns.size(); @@ -230,7 +231,7 @@ bool RifCsvUserDataParser::parseData(const AsciiDataParseOptions& parseOptions) QString line = dataStream->readLine(); if(line.trimmed().isEmpty()) continue; - QStringList lineColumns = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList lineColumns = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); if(lineColumns.size() != colCount) { @@ -339,19 +340,6 @@ bool RifCsvUserDataParser::parseData(const AsciiDataParseOptions& parseOptions) return !errors; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QStringList RifCsvUserDataParser::splitLineAndTrim(const QString& line, const QString& separator) -{ - QStringList cols = line.split(separator); - for (QString& col : cols) - { - col = col.trimmed(); - } - return cols; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -386,9 +374,9 @@ QString RifCsvUserDataParser::tryDetermineCellSeparator() for (const QString& line : lines) { - totColumnCountTab += splitLineAndTrim(line, "\t").size(); - totColumnCountSemicolon += splitLineAndTrim(line, ";").size(); - totColumnCountComma += splitLineAndTrim(line, ",").size(); + totColumnCountTab += RifFileParseTools::splitLineAndTrim(line, "\t").size(); + totColumnCountSemicolon += RifFileParseTools::splitLineAndTrim(line, ";").size(); + totColumnCountComma += RifFileParseTools::splitLineAndTrim(line, ",").size(); } double avgColumnCountTab = (double)totColumnCountTab / lines.size(); @@ -421,7 +409,7 @@ QString RifCsvUserDataParser::tryDetermineDecimalSeparator(const QString& cellSe QString line = dataStream->readLine(); if (line.isEmpty()) continue; - for (const QString& cellData : splitLineAndTrim(line, cellSeparator)) + for (const QString& cellData : RifFileParseTools::splitLineAndTrim(line, cellSeparator)) { bool parseOk; QLocale locale; diff --git a/ApplicationCode/FileInterface/RifCsvUserDataParser.h b/ApplicationCode/FileInterface/RifCsvUserDataParser.h index 1969c7bddd..3f88890975 100644 --- a/ApplicationCode/FileInterface/RifCsvUserDataParser.h +++ b/ApplicationCode/FileInterface/RifCsvUserDataParser.h @@ -66,7 +66,6 @@ class RifCsvUserDataParser const AsciiDataParseOptions& parseOptions, std::vector* columnInfoList); bool parseData(const AsciiDataParseOptions& parseOptions); - static QStringList splitLineAndTrim(const QString& line, const QString& separator); static QDateTime tryParseDateTime(const std::string& colData, const QString& format); private: diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp index 9a1992b770..7918406e4a 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RifElementPropertyTableReader.h" +#include "RifFileParseTools.h" #include "RiaLogging.h" #include "RiuMainWindow.h" @@ -36,7 +37,6 @@ //-------------------------------------------------------------------------------------------------- static QFile* openFile(const QString &fileName); static void closeFile(QFile *file); -static QStringList splitLineAndTrim(const QString& line, const QString& separator); //-------------------------------------------------------------------------------------------------- /// @@ -70,7 +70,7 @@ RifElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QSt if (!metadataBlockFound) continue; - QStringList cols = splitLineAndTrim(line, ","); + QStringList cols = RifFileParseTools::splitLineAndTrim(line, ","); metadata.fileName = fileName; for (QString s : cols) @@ -119,7 +119,7 @@ void RifElementPropertyTableReader::readData(const RifElementPropertyMetadata *m while (!stream.atEnd()) { QString line = stream.readLine(); - QStringList cols = splitLineAndTrim(line, ","); + QStringList cols = RifFileParseTools::splitLineAndTrim(line, ","); lineNo++; if (!dataBlockFound) @@ -201,16 +201,3 @@ void closeFile(QFile *file) delete file; } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QStringList splitLineAndTrim(const QString& line, const QString& separator) -{ - QStringList cols = line.split(separator); - for (QString& col : cols) - { - col = col.trimmed(); - } - return cols; -} diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h index 2de6289d7e..619178f86b 100644 --- a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h @@ -40,15 +40,6 @@ class RifElementPropertyTableReader : cvf::Object static void readData(const RifElementPropertyMetadata *metadata, RifElementPropertyTable *table); }; -//================================================================================================== -/// -//================================================================================================== -class FileParseException -{ -public: - FileParseException(const QString &message) : message(message) {} - QString message; -}; //================================================================================================== /// diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp new file mode 100644 index 0000000000..d719b7bc27 --- /dev/null +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp @@ -0,0 +1,212 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifEnsambleParametersReader.h" +#include "RifFileParseTools.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Constants +//-------------------------------------------------------------------------------------------------- +#define PARAMETERS_FILE_NAME "parameters.txt" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& fileName) +{ + m_fileName = fileName; + m_file = nullptr; + m_textStream = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEnsambleParametersReader::~RifEnsambleParametersReader() +{ + if (m_textStream) + { + delete m_textStream; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEnsambleParametersReader::parse() +{ + bool errors = false; + QTextStream* dataStream = openDataStream(); + int lineNo = 0; + + try + { + while (!dataStream->atEnd() && !errors) + { + QString line = dataStream->readLine(); + + lineNo++; + QStringList cols = RifFileParseTools::splitLineAndTrim(line, " "); + + if (cols.size() != 2) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo)); + } + + QString& name = cols[0]; + QString& strValue = cols[1]; + + if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + bool parseOk = true; + double value = QLocale::c().toDouble(strValue, &parseOk); + if (!parseOk) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + m_parameters.addParameter(name, value); + } + + closeDataStream(); + } + catch (...) + { + closeDataStream(); + throw; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream* RifEnsambleParametersReader::openDataStream() +{ + if (!openFile()) return nullptr; + + m_textStream = new QTextStream(m_file); + return m_textStream; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEnsambleParametersReader::closeDataStream() +{ + if (m_textStream) + { + delete m_textStream; + m_textStream = nullptr; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifEnsambleParametersReader::openFile() +{ + if (!m_file) + { + m_file = new QFile(m_fileName); + if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error(QString("Failed to open %1").arg(m_fileName)); + + delete m_file; + return false; + } + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEnsambleParametersReader::closeFile() +{ + if (m_file) + { + m_file->close(); + delete m_file; + m_file = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RifEnsambleParameters& RifEnsambleParametersReader::parameters() const +{ + return m_parameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEnsambleParameters::addParameter(const QString& name, double value) +{ + m_parameters[name] = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RifEnsambleParameters::parameters() const +{ + return m_parameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifEnsambleParametersFileLocator::locate(const QString& modelPath) +{ + int MAX_LEVELS_UP = 2; + + int dirLevel = 0; + QDir qdir(modelPath); + + do + { + QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const QString& file : files) + { + if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0) + { + return file; + } + } + + } while (dirLevel++ == MAX_LEVELS_UP); + + return ""; +} diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h new file mode 100644 index 0000000000..114e56f518 --- /dev/null +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include +#include + +#include +#include +#include + +class QStringList; +class QTextStream; +class QFile; + +//================================================================================================== +// +// +//================================================================================================== +class RifEnsambleParameters +{ +public: + void addParameter(const QString& name, double value); + std::map parameters() const; + +private: + std::map m_parameters; +}; + +//================================================================================================== +// +// +//================================================================================================== +class RifEnsambleParametersReader +{ +public: + RifEnsambleParametersReader(const QString& fileName); + ~RifEnsambleParametersReader(); + + void parse(); + const RifEnsambleParameters& parameters() const; + +private: + QTextStream* openDataStream(); + void closeDataStream(); + bool openFile(); + void closeFile(); +private: + RifEnsambleParameters m_parameters; + + QString m_fileName; + QFile* m_file; + QTextStream* m_textStream; +}; + +//================================================================================================== +// +// +//================================================================================================== +class RifEnsambleParametersFileLocator +{ +public: + static QString locate(const QString& modelPath); +}; diff --git a/ApplicationCode/FileInterface/RifFileParseTools.cpp b/ApplicationCode/FileInterface/RifFileParseTools.cpp new file mode 100644 index 0000000000..9f7e88c966 --- /dev/null +++ b/ApplicationCode/FileInterface/RifFileParseTools.cpp @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifFileParseTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifFileParseTools::splitLineAndTrim(const QString& line, const QString& separator) +{ + QStringList cols = line.split(separator); + for (QString& col : cols) + { + col = col.trimmed(); + } + return cols; +} diff --git a/ApplicationCode/FileInterface/RifFileParseTools.h b/ApplicationCode/FileInterface/RifFileParseTools.h new file mode 100644 index 0000000000..1ad6b2724f --- /dev/null +++ b/ApplicationCode/FileInterface/RifFileParseTools.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + + +//================================================================================================== +/// +//================================================================================================== +class RifFileParseTools +{ +public: + static QStringList splitLineAndTrim(const QString& line, const QString& separator); +}; + +//================================================================================================== +/// +//================================================================================================== +class FileParseException +{ +public: + FileParseException(const QString &message) : message(message) {} + QString message; +}; From 70f99d8da46b57b12aa74772ec04789c3f115c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 22 Mar 2018 14:41:19 +0100 Subject: [PATCH 0612/1027] #2610 Add ensamble parameters reader unit tests --- .../UnitTests/CMakeLists_files.cmake | 1 + .../RifElementPropertyTableReader-Test.cpp | 1 + .../RifEnsambleParametersReader-Test.cpp | 86 +++++++++++++++++++ .../parameters.txt | 29 +++++++ .../parameters_invalid_format.txt | 29 +++++++ .../parameters_invalid_number_format.txt | 29 +++++++ 6 files changed, 175 insertions(+) create mode 100644 ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp create mode 100644 ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt create mode 100644 ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt create mode 100644 ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 05251cf65e..809f6b33b0 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -40,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader-Test.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp index fbfce67321..0683e25451 100644 --- a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp +++ b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp @@ -3,6 +3,7 @@ #include "RiaTestDataDirectory.h" #include "RifElementPropertyTableReader.h" +#include "RifFileParseTools.h" #include #include diff --git a/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp new file mode 100644 index 0000000000..398b609a6a --- /dev/null +++ b/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp @@ -0,0 +1,86 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifEnsambleParametersReader.h" +#include "RifFileParseTools.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifEnsambleParametersReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifEnsambleParametersReaderTest, SuccessfulParsing) +{ + RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt"); + + try + { + reader.parse(); + + const RifEnsambleParameters& parameters = reader.parameters(); + std::map params = parameters.parameters(); + + EXPECT_TRUE(params.count("LETSWOF:L_1OW")); + EXPECT_TRUE(params.count("LETSGOF:KRG1")); + EXPECT_TRUE(params.count("LOG10_MULTFLT:MULTFLT_F1")); + + EXPECT_EQ(params["LETSWOF:L_1OW"], 1.83555); + EXPECT_EQ(params["LETSGOF:KRG1"], 0.97); + EXPECT_EQ(params["LOG10_MULTFLT:MULTFLT_F1"], -0.168356); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidFormat) +{ + RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid file format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidNumberFormat) +{ + RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid number format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt new file mode 100644 index 0000000000..c7f910e6df --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt @@ -0,0 +1,29 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.168356 +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt new file mode 100644 index 0000000000..996f838a12 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt @@ -0,0 +1,29 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.168356 ERROR +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt new file mode 100644 index 0000000000..b171f7ece5 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt @@ -0,0 +1,29 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.16ERROR8356 +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +LETSGOF:KRG1 0.97 From f7f09c07197210f487008573aff915367fe86bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 26 Mar 2018 13:11:36 +0200 Subject: [PATCH 0613/1027] #2610 Import case realization parameters and store those in summary case --- .../FileInterface/CMakeLists_files.cmake | 2 + .../RifCaseRealizationParametersReader.cpp | 200 ++++++++++++++++++ .../RifCaseRealizationParametersReader.h | 73 +++++++ .../RifEnsambleParametersReader.cpp | 168 +-------------- .../RifEnsambleParametersReader.h | 48 +---- .../Summary/RimSummaryCase.cpp | 16 ++ .../ProjectDataModel/Summary/RimSummaryCase.h | 7 + .../Summary/RimSummaryCaseMainCollection.cpp | 27 ++- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigCaseRealizationParameters.cpp | 36 ++++ .../RigCaseRealizationParameters.h | 41 ++++ .../UnitTests/CMakeLists_files.cmake | 2 +- ...ifCaseRealizationParametersReader-Test.cpp | 106 ++++++++++ .../RifEnsambleParametersReader-Test.cpp | 86 -------- .../3/2/1/dummy.txt | 0 .../3/2/dummy.txt | 0 .../3/dummy.txt | 0 .../parameters.txt | 0 .../parameters_invalid_format.txt | 0 .../parameters_invalid_number_format.txt | 0 20 files changed, 520 insertions(+), 294 deletions(-) create mode 100644 ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp create mode 100644 ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h create mode 100644 ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h create mode 100644 ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp delete mode 100644 ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp create mode 100644 ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/1/dummy.txt create mode 100644 ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/dummy.txt create mode 100644 ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/dummy.txt rename ApplicationCode/UnitTests/TestData/{RifEnsambleParametersReader => RifCaseRealizationParametersReader}/parameters.txt (100%) rename ApplicationCode/UnitTests/TestData/{RifEnsambleParametersReader => RifCaseRealizationParametersReader}/parameters_invalid_format.txt (100%) rename ApplicationCode/UnitTests/TestData/{RifEnsambleParametersReader => RifCaseRealizationParametersReader}/parameters_invalid_number_format.txt (100%) diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 92b5132317..1879567717 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -40,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h ${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.h +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.h ${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.h # HDF5 file reader is directly included in ResInsight main CmakeList.txt @@ -85,6 +86,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp new file mode 100644 index 0000000000..f6ec9b11b8 --- /dev/null +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -0,0 +1,200 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifCaseRealizationParametersReader.h" +#include "RifFileParseTools.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Constants +//-------------------------------------------------------------------------------------------------- +#define PARAMETERS_FILE_NAME "parameters.txt" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QString& fileName) +{ + m_parameters = new RigCaseRealizationParameters(); + m_fileName = fileName; + m_file = nullptr; + m_textStream = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::~RifCaseRealizationParametersReader() +{ + if (m_textStream) + { + delete m_textStream; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::parse() +{ + int lineNo = 0; + QTextStream* dataStream = openDataStream(); + + try + { + while (!dataStream->atEnd()) + { + QString line = dataStream->readLine(); + + lineNo++; + QStringList cols = RifFileParseTools::splitLineAndTrim(line, " "); + + if (cols.size() != 2) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo)); + } + + QString& name = cols[0]; + QString& strValue = cols[1]; + + if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + bool parseOk = true; + double value = QLocale::c().toDouble(strValue, &parseOk); + if (!parseOk) + { + throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + m_parameters->addParameter(name, value); + } + + closeDataStream(); + } + catch (...) + { + closeDataStream(); + throw; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream* RifCaseRealizationParametersReader::openDataStream() +{ + openFile(); + + m_textStream = new QTextStream(m_file); + return m_textStream; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::closeDataStream() +{ + if (m_textStream) + { + delete m_textStream; + m_textStream = nullptr; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::openFile() +{ + if (!m_file) + { + m_file = new QFile(m_fileName); + if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) + { + closeFile(); + //delete m_file; + //m_file = nullptr; + throw FileParseException(QString("Failed to open %1").arg(m_fileName)); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::closeFile() +{ + if (m_file) + { + m_file->close(); + delete m_file; + m_file = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::ref RifCaseRealizationParametersReader::parameters() const +{ + return m_parameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifCaseRealizationParametersFileLocator::locate(const QString& modelPath) +{ + int MAX_LEVELS_UP = 2; + int dirLevel = 0; + + QDir qdir(modelPath); + + const QFileInfo dir(modelPath); + if (dir.isFile()) qdir.cdUp(); + else if (!dir.isDir()) return ""; + + do + { + QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const QString& file : files) + { + if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0) + { + return qdir.absoluteFilePath(file); + } + } + qdir.cdUp(); + + } while (dirLevel++ < MAX_LEVELS_UP); + + return ""; +} diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h new file mode 100644 index 0000000000..fd8b89f652 --- /dev/null +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RigCaseRealizationParameters.h" + +#include +#include + +#include +#include +#include + +class QStringList; +class QTextStream; +class QFile; + +//================================================================================================== +// +// +//================================================================================================== +class RifCaseRealizationParametersReader +{ +public: + RifCaseRealizationParametersReader(const QString& fileName); + ~RifCaseRealizationParametersReader(); + + void parse(); + const cvf::ref parameters() const; + +private: + QTextStream* openDataStream(); + void closeDataStream(); + void openFile(); + void closeFile(); +private: + cvf::ref m_parameters; + + QString m_fileName; + QFile* m_file; + QTextStream* m_textStream; +}; + + +//================================================================================================== +// +// +//================================================================================================== +class RifCaseRealizationParametersFileLocator +{ +public: + static QString locate(const QString& modelPath); +}; diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp index d719b7bc27..bf85c10aab 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RifEnsambleParametersReader.h" +#include "RifCaseRealizationParametersReader.h" #include "RifFileParseTools.h" #include "RiaLogging.h" @@ -27,20 +28,12 @@ #include -//-------------------------------------------------------------------------------------------------- -/// Constants -//-------------------------------------------------------------------------------------------------- -#define PARAMETERS_FILE_NAME "parameters.txt" - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& fileName) +RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& modelDirectory) { - m_fileName = fileName; - m_file = nullptr; - m_textStream = nullptr; + m_modelDirectory = modelDirectory; } //-------------------------------------------------------------------------------------------------- @@ -48,165 +41,16 @@ RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& fileName //-------------------------------------------------------------------------------------------------- RifEnsambleParametersReader::~RifEnsambleParametersReader() { - if (m_textStream) - { - delete m_textStream; - } - closeFile(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifEnsambleParametersReader::parse() -{ - bool errors = false; - QTextStream* dataStream = openDataStream(); - int lineNo = 0; - - try - { - while (!dataStream->atEnd() && !errors) - { - QString line = dataStream->readLine(); - - lineNo++; - QStringList cols = RifFileParseTools::splitLineAndTrim(line, " "); - - if (cols.size() != 2) - { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo)); - } - - QString& name = cols[0]; - QString& strValue = cols[1]; - - if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) - { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); - } - - bool parseOk = true; - double value = QLocale::c().toDouble(strValue, &parseOk); - if (!parseOk) - { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); - } - - m_parameters.addParameter(name, value); - } - - closeDataStream(); - } - catch (...) - { - closeDataStream(); - throw; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QTextStream* RifEnsambleParametersReader::openDataStream() -{ - if (!openFile()) return nullptr; - - m_textStream = new QTextStream(m_file); - return m_textStream; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifEnsambleParametersReader::closeDataStream() +RifEnsambleParametersPtr RifEnsambleParametersReader::import() { - if (m_textStream) - { - delete m_textStream; - m_textStream = nullptr; - } - closeFile(); -} + RifEnsambleParametersPtr parameters; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RifEnsambleParametersReader::openFile() -{ - if (!m_file) - { - m_file = new QFile(m_fileName); - if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) - { - RiaLogging::error(QString("Failed to open %1").arg(m_fileName)); - delete m_file; - return false; - } - } - return true; + return nullptr; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifEnsambleParametersReader::closeFile() -{ - if (m_file) - { - m_file->close(); - delete m_file; - m_file = nullptr; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RifEnsambleParameters& RifEnsambleParametersReader::parameters() const -{ - return m_parameters; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifEnsambleParameters::addParameter(const QString& name, double value) -{ - m_parameters[name] = value; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map RifEnsambleParameters::parameters() const -{ - return m_parameters; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RifEnsambleParametersFileLocator::locate(const QString& modelPath) -{ - int MAX_LEVELS_UP = 2; - - int dirLevel = 0; - QDir qdir(modelPath); - - do - { - QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot); - for (const QString& file : files) - { - if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0) - { - return file; - } - } - - } while (dirLevel++ == MAX_LEVELS_UP); - - return ""; -} diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h index 114e56f518..b2a622b2b1 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h @@ -18,67 +18,29 @@ #pragma once -#include "RiaPreferences.h" - #include "RifSummaryCaseRestartSelector.h" +#include "RifEnsambleParameters.h" #include -#include -#include -#include -#include class QStringList; class QTextStream; class QFile; -//================================================================================================== -// -// -//================================================================================================== -class RifEnsambleParameters -{ -public: - void addParameter(const QString& name, double value); - std::map parameters() const; - -private: - std::map m_parameters; -}; //================================================================================================== // -// +// UNDER CONSTRUCTION //================================================================================================== class RifEnsambleParametersReader { public: - RifEnsambleParametersReader(const QString& fileName); + RifEnsambleParametersReader(const QString& modelDirectory); ~RifEnsambleParametersReader(); - void parse(); - const RifEnsambleParameters& parameters() const; + RifEnsambleParametersPtr import(); private: - QTextStream* openDataStream(); - void closeDataStream(); - bool openFile(); - void closeFile(); -private: - RifEnsambleParameters m_parameters; - - QString m_fileName; - QFile* m_file; - QTextStream* m_textStream; -}; - -//================================================================================================== -// -// -//================================================================================================== -class RifEnsambleParametersFileLocator -{ -public: - static QString locate(const QString& modelPath); + QString m_modelDirectory; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 28d46eb279..6e5a8595c6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -83,6 +83,22 @@ bool RimSummaryCase::isObservedData() return m_isObservedData; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::setCaseRealizationParameters(cvf::ref crlParameters) +{ + m_crlParameters = crlParameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimSummaryCase::caseRealizationParameters() const +{ + return m_crlParameters; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index ff7d9979de..80d08e83cf 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -17,6 +17,8 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RigCaseRealizationParameters.h" + #include "cafPdmField.h" #include "cafPdmObject.h" @@ -52,6 +54,9 @@ class RimSummaryCase : public caf::PdmObject bool isObservedData(); + void setCaseRealizationParameters(cvf::ref crlParameters); + cvf::ref caseRealizationParameters() const; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); void updateTreeItemName(); @@ -60,6 +65,8 @@ class RimSummaryCase : public caf::PdmObject caf::PdmField m_useAutoShortName; caf::PdmField m_summaryHeaderFilename; bool m_isObservedData; + + cvf::ref m_crlParameters; private: virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 8ee010d917..6b7091eb01 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -19,6 +19,7 @@ #include "RifEclipseSummaryTools.h" #include "RifSummaryCaseRestartSelector.h" +#include "RifCaseRealizationParametersReader.h" #include "RimEclipseResultCase.h" #include "RimFileSummaryCase.h" @@ -33,6 +34,27 @@ CAF_PDM_SOURCE_INIT(RimSummaryCaseMainCollection,"SummaryCaseCollection"); +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +void addCaseRealizationParametersIfFound(RimSummaryCase& sumCase, const QString modelFolderOrFile) +{ + QString parametersFile = RifCaseRealizationParametersFileLocator::locate(modelFolderOrFile); + if (!parametersFile.isEmpty()) + { + RifCaseRealizationParametersReader reader(parametersFile); + + // Try parse case realization parameters + try + { + reader.parse(); + sumCase.setCaseRealizationParameters(reader.parameters()); + } + catch (...) {} + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -288,6 +310,7 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa newSumCase->setAssociatedEclipseCase(eclResCase); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); + addCaseRealizationParametersIfFound(*newSumCase, importFileInfos.front().fileName); sumCases.push_back(newSumCase); // Remove the processed element and add 'orphan' summary cases @@ -302,7 +325,7 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa newSumCase->setSummaryHeaderFileName(fileInfo.fileName); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); - + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); sumCases.push_back(newSumCase); } } @@ -329,7 +352,7 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa newSumCase->setSummaryHeaderFileName(fileInfo.fileName); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); - + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); sumCases.push_back(newSumCase); } diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 32e1a74614..6ba9315bff 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h ${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h ${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.h ) @@ -129,6 +130,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp new file mode 100644 index 0000000000..f9e19676ea --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCaseRealizationParameters.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::addParameter(const QString& name, double value) +{ + m_parameters[name] = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RigCaseRealizationParameters::parameters() const +{ + return m_parameters; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h new file mode 100644 index 0000000000..d647e83482 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfObject.h" + +#include + +#include +#include + + +//================================================================================================== +// +// +//================================================================================================== +class RigCaseRealizationParameters : public cvf::Object +{ +public: + void addParameter(const QString& name, double value); + std::map parameters() const; + +private: + std::map m_parameters; +}; diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 809f6b33b0..5fa645077a 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -40,7 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp -${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader-Test.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp new file mode 100644 index 0000000000..a91bf0e3d8 --- /dev/null +++ b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp @@ -0,0 +1,106 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifCaseRealizationParametersReader.h" +#include "RifFileParseTools.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifCaseRealizationParametersReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, LocatorTestSuccess) +{ + QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2"); + QString expected = TEST_DATA_DIRECTORY + "parameters.txt"; + EXPECT_EQ(expected.toStdString(), file.toStdString()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, LocatorTestFailure) +{ + QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2/1"); + QString expected = ""; + EXPECT_EQ(expected.toStdString(), file.toStdString()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, SuccessfulParsing) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt"); + + try + { + reader.parse(); + + const cvf::ref parameters = reader.parameters(); + std::map params = parameters->parameters(); + + EXPECT_EQ(1, params.count("LETSWOF:L_1OW")); + EXPECT_EQ(1, params.count("LETSGOF:KRG1")); + EXPECT_EQ(1, params.count("LOG10_MULTFLT:MULTFLT_F1")); + + EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"]); + EXPECT_EQ(0.97, params["LETSGOF:KRG1"]); + EXPECT_EQ(-0.168356, params["LOG10_MULTFLT:MULTFLT_F1"]); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidFormat) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid file format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidNumberFormat) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid number format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} diff --git a/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp deleted file mode 100644 index 398b609a6a..0000000000 --- a/ApplicationCode/UnitTests/RifEnsambleParametersReader-Test.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "gtest/gtest.h" - -#include "RiaTestDataDirectory.h" - -#include "RifEnsambleParametersReader.h" -#include "RifFileParseTools.h" - -#include -#include - - -static const QString TEST_DATA_DIRECTORY = QString("%1/RifEnsambleParametersReader/").arg(TEST_DATA_DIR); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(RifEnsambleParametersReaderTest, SuccessfulParsing) -{ - RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt"); - - try - { - reader.parse(); - - const RifEnsambleParameters& parameters = reader.parameters(); - std::map params = parameters.parameters(); - - EXPECT_TRUE(params.count("LETSWOF:L_1OW")); - EXPECT_TRUE(params.count("LETSGOF:KRG1")); - EXPECT_TRUE(params.count("LOG10_MULTFLT:MULTFLT_F1")); - - EXPECT_EQ(params["LETSWOF:L_1OW"], 1.83555); - EXPECT_EQ(params["LETSGOF:KRG1"], 0.97); - EXPECT_EQ(params["LOG10_MULTFLT:MULTFLT_F1"], -0.168356); - } - catch (...) - { - EXPECT_TRUE(false); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidFormat) -{ - RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt"); - - try - { - reader.parse(); - - EXPECT_TRUE(false); - } - catch (FileParseException e) - { - EXPECT_TRUE(e.message.contains("Invalid file format in line 10")); - } - catch (...) - { - EXPECT_TRUE(false); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidNumberFormat) -{ - RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt"); - - try - { - reader.parse(); - - EXPECT_TRUE(false); - } - catch (FileParseException e) - { - EXPECT_TRUE(e.message.contains("Invalid number format in line 10")); - } - catch (...) - { - EXPECT_TRUE(false); - } -} diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/1/dummy.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/1/dummy.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/dummy.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/dummy.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/dummy.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/dummy.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt similarity index 100% rename from ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters.txt rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_format.txt similarity index 100% rename from ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_format.txt rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_format.txt diff --git a/ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_number_format.txt similarity index 100% rename from ApplicationCode/UnitTests/TestData/RifEnsambleParametersReader/parameters_invalid_number_format.txt rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_number_format.txt From e25f8f100f185c931cd461480a8c75150f35c0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 27 Mar 2018 08:28:36 +0200 Subject: [PATCH 0614/1027] #2610 Fix build error --- .../FileInterface/RifEnsambleParametersReader.cpp | 14 +++++++------- .../FileInterface/RifEnsambleParametersReader.h | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp index bf85c10aab..34aaa131ec 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp @@ -46,11 +46,11 @@ RifEnsambleParametersReader::~RifEnsambleParametersReader() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEnsambleParametersPtr RifEnsambleParametersReader::import() -{ - RifEnsambleParametersPtr parameters; - - - return nullptr; -} +//RifEnsambleParameters RifEnsambleParametersReader::import() +//{ +// RifEnsambleParameters parameters; +// +// +// return ; +//} diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h index b2a622b2b1..066bb845fb 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h +++ b/ApplicationCode/FileInterface/RifEnsambleParametersReader.h @@ -19,7 +19,6 @@ #pragma once #include "RifSummaryCaseRestartSelector.h" -#include "RifEnsambleParameters.h" #include @@ -39,7 +38,7 @@ class RifEnsambleParametersReader RifEnsambleParametersReader(const QString& modelDirectory); ~RifEnsambleParametersReader(); - RifEnsambleParametersPtr import(); + //RifEnsambleParameters import(); private: QString m_modelDirectory; From 43f1101f1f5668f19505b69c38745293dad07999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 27 Mar 2018 08:51:14 +0200 Subject: [PATCH 0615/1027] #2610 Add curve set and curve set collection classes --- .../Summary/CMakeLists_files.cmake | 4 + .../Summary/RimEnsambleCurveSet.cpp | 412 ++++++++++++++++++ .../Summary/RimEnsambleCurveSet.h | 90 ++++ .../Summary/RimEnsambleCurveSetCollection.cpp | 412 ++++++++++++++++++ .../Summary/RimEnsambleCurveSetCollection.h | 90 ++++ 5 files changed, 1008 insertions(+) create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index b4f64b79e0..1bc0c3b6af 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -29,6 +29,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.h ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSetCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSet.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -61,6 +63,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSetCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSet.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp new file mode 100644 index 0000000000..38d000a35a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -0,0 +1,412 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsambleCurveSet.h" + +#include "RiaApplication.h" + +#include "RifReaderEclipseSummary.h" + +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotSourceStepping.h" + +#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuSummaryQwtPlot.h" + +#include "cafPdmUiTreeViewEditor.h" + +#include + +CAF_PDM_SOURCE_INIT(RimEnsambleCurveSet, "RimEnsambleCurveSet"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsambleCurveSet::RimEnsambleCurveSet() +{ + CAF_PDM_InitObject("Summary Curves", ":/SummaryCurveFilter16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_curves, "CollectionCurves", "Collection Curves", "", "", ""); + m_curves.uiCapability()->setUiHidden(true); + m_curves.uiCapability()->setUiTreeChildrenHidden(false); + + CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); + m_showCurves.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); + m_ySourceStepping = new RimSummaryPlotSourceStepping; + m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); + m_ySourceStepping.uiCapability()->setUiHidden(true); + m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_ySourceStepping.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); + m_xSourceStepping = new RimSummaryPlotSourceStepping; + m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); + m_xSourceStepping.uiCapability()->setUiHidden(true); + m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_xSourceStepping.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); + m_unionSourceStepping = new RimSummaryPlotSourceStepping; + m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); + m_unionSourceStepping.uiCapability()->setUiHidden(true); + m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_unionSourceStepping.xmlCapability()->disableIO(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsambleCurveSet::~RimEnsambleCurveSet() +{ + m_curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEnsambleCurveSet::isCurvesVisible() +{ + return m_showCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->loadDataAndUpdate(false); + curve->updateQwtPlotAxis(); + } + + if (updateParentPlot) + { + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) + { + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::setParentQwtPlotAndReplot(QwtPlot* plot) +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->setParentQwtPlotNoReplot(plot); + } + + if (plot) plot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::detachQwtCurves() +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->detachQwtCurve(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimEnsambleCurveSet::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const +{ + for (RimSummaryCurve* rimCurve : m_curves) + { + if (rimCurve->qwtPlotCurve() == qwtCurve) + { + return rimCurve; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::addCurve(RimSummaryCurve* curve) +{ + if (curve) + { + m_curves.push_back(curve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::deleteCurve(RimSummaryCurve* curve) +{ + if (curve) + { + m_curves.removeChildObject(curve); + delete curve; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSet::curves() const +{ + return m_curves.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSet::visibleCurves() const +{ + std::vector visible; + + for (auto c : m_curves) + { + if (c->isCurveVisible()) + { + visible.push_back(c); + } + } + + return visible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) +{ + std::vector summaryCurvesToDelete; + + for (RimSummaryCurve* summaryCurve : m_curves) + { + if (!summaryCurve) continue; + if (!summaryCurve->summaryCaseY()) continue; + + if (summaryCurve->summaryCaseY() == summaryCase) + { + summaryCurvesToDelete.push_back(summaryCurve); + } + } + for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) + { + m_curves.removeChildObject(summaryCurve); + delete summaryCurve; + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::deleteAllCurves() +{ + m_curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::updateCaseNameHasChanged() +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->updateCurveNameNoLegendUpdate(); + curve->updateConnectedEditors(); + } + + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::setCurrentSummaryCurve(RimSummaryCurve* curve) +{ + m_currentSummaryCurve = curve; + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSet::fieldsToShowInToolbar() +{ + RimSummaryCrossPlot* parentCrossPlot; + firstAncestorOrThisOfType(parentCrossPlot); + + if (parentCrossPlot) + { + return m_unionSourceStepping->fieldsToShowInToolbar(); + } + + return m_ySourceStepping()->fieldsToShowInToolbar(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::handleKeyPressEvent(QKeyEvent* keyEvent) +{ + if (!keyEvent) return; + + RimSummaryPlotSourceStepping* sourceStepping = nullptr; + { + RimSummaryCrossPlot* summaryCrossPlot = nullptr; + this->firstAncestorOrThisOfType(summaryCrossPlot); + + if (summaryCrossPlot) + { + sourceStepping = m_unionSourceStepping(); + } + else + { + sourceStepping = m_ySourceStepping(); + } + } + + if (keyEvent->key() == Qt::Key_PageUp) + { + if (keyEvent->modifiers() & Qt::ShiftModifier) + { + sourceStepping->applyPrevCase(); + + keyEvent->accept(); + } + else if (keyEvent->modifiers() & Qt::ControlModifier) + { + sourceStepping->applyPrevOtherIdentifier(); + + keyEvent->accept(); + } + else + { + sourceStepping->applyPrevQuantity(); + + keyEvent->accept(); + } + } + else if (keyEvent->key() == Qt::Key_PageDown) + { + if (keyEvent->modifiers() & Qt::ShiftModifier) + { + sourceStepping->applyNextCase(); + + keyEvent->accept(); + } + else if (keyEvent->modifiers() & Qt::ControlModifier) + { + sourceStepping->applyNextOtherIdentifier(); + + keyEvent->accept(); + } + else + { + sourceStepping->applyNextQuantity(); + + keyEvent->accept(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_showCurves) + { + loadDataAndUpdate(true); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + RimSummaryCrossPlot* parentCrossPlot; + firstAncestorOrThisOfType(parentCrossPlot); + + if (parentCrossPlot) + { + { + auto group = uiOrdering.addNewGroup("Y Source Stepping"); + + m_ySourceStepping()->uiOrdering(uiConfigName, *group); + } + + { + auto group = uiOrdering.addNewGroup("X Source Stepping"); + + m_xSourceStepping()->uiOrdering(uiConfigName, *group); + } + + { + auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); + + m_unionSourceStepping()->uiOrdering(uiConfigName, *group); + } + } + else + { + auto group = uiOrdering.addNewGroup("Plot Source Stepping"); + + m_ySourceStepping()->uiOrdering(uiConfigName, *group); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() +{ + return &m_showCurves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); + if (myAttr && m_currentSummaryCurve.notNull()) + { + myAttr->currentObject = m_currentSummaryCurve.p(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h new file mode 100644 index 0000000000..bbbd52ff3e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" + +class QwtPlot; +class QwtPlotCurve; +class RimSummaryCase; +class RimSummaryCurve; +class RimSummaryPlotSourceStepping; +class QKeyEvent; + +//================================================================================================== +/// +//================================================================================================== +class RimEnsambleCurveSet : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEnsambleCurveSet(); + virtual ~RimEnsambleCurveSet(); + + bool isCurvesVisible(); + + void loadDataAndUpdate(bool updateParentPlot); + void setParentQwtPlotAndReplot(QwtPlot* plot); + void detachQwtCurves(); + + RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; + + void addCurve(RimSummaryCurve* curve); + void deleteCurve(RimSummaryCurve* curve); + + std::vector curves() const; + std::vector visibleCurves() const; + + void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); + void deleteAllCurves(); + void updateCaseNameHasChanged(); + + void setCurrentSummaryCurve(RimSummaryCurve* curve); + + std::vector fieldsToShowInToolbar(); + + void handleKeyPressEvent(QKeyEvent* keyEvent); + +private: + caf::PdmFieldHandle* objectToggleField(); + virtual void defineObjectEditorAttribute(QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, const QVariant& newValue) override; + +private: + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curves; + + caf::PdmChildField m_ySourceStepping; + caf::PdmChildField m_xSourceStepping; + caf::PdmChildField m_unionSourceStepping; + + caf::PdmPointer m_currentSummaryCurve; +}; + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp new file mode 100644 index 0000000000..73a17b0ecc --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp @@ -0,0 +1,412 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsambleCurveSetCollection.h" + +#include "RiaApplication.h" + +#include "RifReaderEclipseSummary.h" + +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotSourceStepping.h" + +#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuSummaryQwtPlot.h" + +#include "cafPdmUiTreeViewEditor.h" + +#include + +CAF_PDM_SOURCE_INIT(RimEnsambleCurveSetCollection, "RimEnsambleCurveSetCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsambleCurveSetCollection::RimEnsambleCurveSetCollection() +{ + CAF_PDM_InitObject("Summary Curves", ":/SummaryCurveFilter16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_curves, "CollectionCurves", "Collection Curves", "", "", ""); + m_curves.uiCapability()->setUiHidden(true); + m_curves.uiCapability()->setUiTreeChildrenHidden(false); + + CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); + m_showCurves.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); + m_ySourceStepping = new RimSummaryPlotSourceStepping; + m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); + m_ySourceStepping.uiCapability()->setUiHidden(true); + m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_ySourceStepping.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); + m_xSourceStepping = new RimSummaryPlotSourceStepping; + m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); + m_xSourceStepping.uiCapability()->setUiHidden(true); + m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_xSourceStepping.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); + m_unionSourceStepping = new RimSummaryPlotSourceStepping; + m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); + m_unionSourceStepping.uiCapability()->setUiHidden(true); + m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + m_unionSourceStepping.xmlCapability()->disableIO(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsambleCurveSetCollection::~RimEnsambleCurveSetCollection() +{ + m_curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEnsambleCurveSetCollection::isCurvesVisible() +{ + return m_showCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->loadDataAndUpdate(false); + curve->updateQwtPlotAxis(); + } + + if ( updateParentPlot ) + { + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if ( parentPlot->qwtPlot() ) + { + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->setParentQwtPlotNoReplot(plot); + } + + if (plot) plot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::detachQwtCurves() +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->detachQwtCurve(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimEnsambleCurveSetCollection::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const +{ + for (RimSummaryCurve* rimCurve : m_curves) + { + if (rimCurve->qwtPlotCurve() == qwtCurve) + { + return rimCurve; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::addCurve(RimSummaryCurve* curve) +{ + if (curve) + { + m_curves.push_back(curve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::deleteCurve(RimSummaryCurve* curve) +{ + if (curve) + { + m_curves.removeChildObject(curve); + delete curve; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSetCollection::curves() const +{ + return m_curves.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSetCollection::visibleCurves() const +{ + std::vector visible; + + for (auto c : m_curves) + { + if (c->isCurveVisible()) + { + visible.push_back(c); + } + } + + return visible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) +{ + std::vector summaryCurvesToDelete; + + for (RimSummaryCurve* summaryCurve : m_curves) + { + if (!summaryCurve) continue; + if (!summaryCurve->summaryCaseY()) continue; + + if (summaryCurve->summaryCaseY() == summaryCase) + { + summaryCurvesToDelete.push_back(summaryCurve); + } + } + for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) + { + m_curves.removeChildObject(summaryCurve); + delete summaryCurve; + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::deleteAllCurves() +{ + m_curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::updateCaseNameHasChanged() +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->updateCurveNameNoLegendUpdate(); + curve->updateConnectedEditors(); + } + + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) +{ + m_currentSummaryCurve = curve; + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsambleCurveSetCollection::fieldsToShowInToolbar() +{ + RimSummaryCrossPlot* parentCrossPlot; + firstAncestorOrThisOfType(parentCrossPlot); + + if (parentCrossPlot) + { + return m_unionSourceStepping->fieldsToShowInToolbar(); + } + + return m_ySourceStepping()->fieldsToShowInToolbar(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) +{ + if (!keyEvent) return; + + RimSummaryPlotSourceStepping* sourceStepping = nullptr; + { + RimSummaryCrossPlot* summaryCrossPlot = nullptr; + this->firstAncestorOrThisOfType(summaryCrossPlot); + + if (summaryCrossPlot) + { + sourceStepping = m_unionSourceStepping(); + } + else + { + sourceStepping = m_ySourceStepping(); + } + } + + if (keyEvent->key() == Qt::Key_PageUp) + { + if (keyEvent->modifiers() & Qt::ShiftModifier) + { + sourceStepping->applyPrevCase(); + + keyEvent->accept(); + } + else if (keyEvent->modifiers() & Qt::ControlModifier) + { + sourceStepping->applyPrevOtherIdentifier(); + + keyEvent->accept(); + } + else + { + sourceStepping->applyPrevQuantity(); + + keyEvent->accept(); + } + } + else if (keyEvent->key() == Qt::Key_PageDown) + { + if (keyEvent->modifiers() & Qt::ShiftModifier) + { + sourceStepping->applyNextCase(); + + keyEvent->accept(); + } + else if (keyEvent->modifiers() & Qt::ControlModifier) + { + sourceStepping->applyNextOtherIdentifier(); + + keyEvent->accept(); + } + else + { + sourceStepping->applyNextQuantity(); + + keyEvent->accept(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_showCurves) + { + loadDataAndUpdate(true); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + RimSummaryCrossPlot* parentCrossPlot; + firstAncestorOrThisOfType(parentCrossPlot); + + if (parentCrossPlot) + { + { + auto group = uiOrdering.addNewGroup("Y Source Stepping"); + + m_ySourceStepping()->uiOrdering(uiConfigName, *group); + } + + { + auto group = uiOrdering.addNewGroup("X Source Stepping"); + + m_xSourceStepping()->uiOrdering(uiConfigName, *group); + } + + { + auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); + + m_unionSourceStepping()->uiOrdering(uiConfigName, *group); + } + } + else + { + auto group = uiOrdering.addNewGroup("Plot Source Stepping"); + + m_ySourceStepping()->uiOrdering(uiConfigName, *group); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsambleCurveSetCollection::objectToggleField() +{ + return &m_showCurves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); + if (myAttr && m_currentSummaryCurve.notNull()) + { + myAttr->currentObject = m_currentSummaryCurve.p(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h new file mode 100644 index 0000000000..151c7c23f2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" + +class QwtPlot; +class QwtPlotCurve; +class RimSummaryCase; +class RimSummaryCurve; +class RimSummaryPlotSourceStepping; +class QKeyEvent; + +//================================================================================================== +/// +//================================================================================================== +class RimEnsambleCurveSetCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEnsambleCurveSetCollection(); + virtual ~RimEnsambleCurveSetCollection(); + + bool isCurvesVisible(); + + void loadDataAndUpdate(bool updateParentPlot); + void setParentQwtPlotAndReplot(QwtPlot* plot); + void detachQwtCurves(); + + RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; + + void addCurve(RimSummaryCurve* curve); + void deleteCurve(RimSummaryCurve* curve); + + std::vector curves() const; + std::vector visibleCurves() const; + + void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); + void deleteAllCurves(); + void updateCaseNameHasChanged(); + + void setCurrentSummaryCurve(RimSummaryCurve* curve); + + std::vector fieldsToShowInToolbar(); + + void handleKeyPressEvent(QKeyEvent* keyEvent); + +private: + caf::PdmFieldHandle* objectToggleField(); + virtual void defineObjectEditorAttribute(QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, const QVariant& newValue) override; + +private: + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curves; + + caf::PdmChildField m_ySourceStepping; + caf::PdmChildField m_xSourceStepping; + caf::PdmChildField m_unionSourceStepping; + + caf::PdmPointer m_currentSummaryCurve; +}; + From 21a81744f1b2178f20c967085d3ffa34a161b335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 6 Apr 2018 08:16:14 +0200 Subject: [PATCH 0616/1027] #2610 New command, display ensamble curves with single color --- .../CMakeLists_files.cmake | 2 + .../RicNewSummaryEnsambleCurveSetFeature.cpp | 101 ++++ .../RicNewSummaryEnsambleCurveSetFeature.h | 41 ++ .../RicSummaryCurveCreator.cpp | 43 ++ .../RicSummaryCurveCreator.h | 2 + .../RimContextCommandBuilder.cpp | 5 + .../ProjectDataModel/RimPlotCurve.cpp | 5 + .../ProjectDataModel/RimPlotCurve.h | 3 +- .../ProjectDataModel/RimProject.cpp | 21 + ApplicationCode/ProjectDataModel/RimProject.h | 2 + .../Summary/RimEnsambleCurveSet.cpp | 453 +++++++++++++---- .../Summary/RimEnsambleCurveSet.h | 37 +- .../Summary/RimEnsambleCurveSetCollection.cpp | 465 +++++++++--------- .../Summary/RimEnsambleCurveSetCollection.h | 42 +- .../Summary/RimSummaryPlot.cpp | 35 ++ .../ProjectDataModel/Summary/RimSummaryPlot.h | 7 + .../Summary/RimSummaryPlotSourceStepping.cpp | 8 +- .../RiuSummaryCurveDefSelection.cpp | 10 +- 18 files changed, 897 insertions(+), 385 deletions(-) create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 20ed2af625..07a81c1a78 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -32,6 +32,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsambleCurveSetFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -67,6 +68,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsambleCurveSetFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp new file mode 100644 index 0000000000..09a04a3436 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp @@ -0,0 +1,101 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryEnsambleCurveSetFeature.h" + +#include "RiaApplication.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" +#include "RimEnsambleCurveSet.h" +#include "RimEnsambleCurveSetCollection.h" + +#include "RiuMainPlotWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicNewSummaryEnsambleCurveSetFeature, "RicNewSummaryEnsambleCurveSetFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryEnsambleCurveSetFeature::isCommandEnabled() +{ + return (selectedSummaryPlot()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryEnsambleCurveSetFeature::onActionTriggered(bool isChecked) +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimSummaryPlot* plot = selectedSummaryPlot(); + if (plot) + { + RimEnsambleCurveSet* curveSet = new RimEnsambleCurveSet(); + + plot->ensambleCurveSets()->addCurveSet(curveSet); + plot->updateConnectedEditors(); + + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(curveSet); + + RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateSummaryPlotToolBar(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryEnsambleCurveSetFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Summary Ensamble Curve Set"); + actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicNewSummaryEnsambleCurveSetFeature::selectedSummaryPlot() const +{ + RimSummaryPlot* sumPlot = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlot = RiaSummaryTools::parentSummaryPlot(selObj); + } + + return sumPlot; +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h new file mode 100644 index 0000000000..89b491e90c --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryEnsambleCurveSetFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + RimSummaryPlot* selectedSummaryPlot() const; +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index b1c9f20586..408236e184 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -40,6 +40,8 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryCalculationCollection.h" +#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsambleCurveSet.h" #include "RiuPlotMainWindowTools.h" #include "RiuSummaryCurveDefSelection.h" @@ -540,6 +542,23 @@ void RicSummaryCurveCreator::updateTargetPlot() copyCurveAndAddToPlot(editedCurve, m_targetPlot); } + // DEBUG + //{ + // m_targetPlot->ensambleCurveSets()->deleteAllCurveSets(); + + // RimEnsambleCurveSet* curveSet = new RimEnsambleCurveSet(); + // m_targetPlot->ensambleCurveSets()->addCurveSet(curveSet); + + // for (const auto& editedCurve : m_previewPlot->summaryCurves()) + // { + // if (!editedCurve->isCurveVisible()) + // { + // continue; + // } + // copyEnsambleCurveAndAddToPlot(editedCurve, curveSet); + // } + //} + m_targetPlot->enableAutoPlotTitle(m_useAutoPlotTitleProxy()); m_targetPlot->loadDataAndUpdate(); @@ -570,6 +589,30 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, curveCopy->loadDataAndUpdate(false); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::copyEnsambleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsambleCurveSet *curveSet, bool forceVisible) +{ + RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(curveCopy); + + if (forceVisible) + { + curveCopy->setCurveVisiblity(true); + } + + curveSet->addCurve(curveCopy); + + // Resolve references after object has been inserted into the project data model + curveCopy->resolveReferencesRecursively(); + + // The curve creator is not a descendant of the project, and need to be set manually + curveCopy->setSummaryCaseY(curve->summaryCaseY()); + curveCopy->initAfterReadRecursively(); + curveCopy->loadDataAndUpdate(false); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index 1ca75b9d64..fdbf8309f6 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -41,6 +41,7 @@ class RimSummaryCase; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; +class RimEnsambleCurveSet; //================================================================================================== /// @@ -85,6 +86,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot); void updateTargetPlot(); static void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false); + static void copyEnsambleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsambleCurveSet* curveSet, bool forceVisible = false); void setDefaultCurveSelection(); void resetAllFields(); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 443be275d9..6833e6c3f9 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -35,6 +35,7 @@ #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" +#include "RimEnsambleCurveSetCollection.h" #include "RimFaultInView.h" #include "RimFlowCharacteristicsPlot.h" #include "RimFlowDiagSolution.h" @@ -440,6 +441,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryCurveFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicNewSummaryEnsambleCurveSetFeature"; + } else if (dynamic_cast(uiItem)) { if (!dynamic_cast(uiItem)) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 59b0476fb8..48272a30bb 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -19,6 +19,7 @@ #include "RimPlotCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" +#include "RimEnsambleCurveSet.h" #include "RiuLineSegmentQwtPlotCurve.h" @@ -188,6 +189,10 @@ void RimPlotCurve::updateCurveVisibility(bool updateParentPlot) RimSummaryCurveCollection* summaryCurveCollection = nullptr; this->firstAncestorOrThisOfType(summaryCurveCollection); if (summaryCurveCollection) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); + + RimEnsambleCurveSet* ensambleCurveSet = nullptr; + firstAncestorOrThisOfType(ensambleCurveSet); + if (ensambleCurveSet) isVisibleInPossibleParent = ensambleCurveSet->isCurvesVisible(); } if (m_showCurve() && m_parentQwtPlot && isVisibleInPossibleParent) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 0cd9c4495a..9ece407b89 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -100,6 +100,8 @@ class RimPlotCurve : public caf::PdmObject void setZOrder(double z); + virtual void updateCurveAppearance(); + protected: virtual QString createCurveAutoName() = 0; @@ -107,7 +109,6 @@ class RimPlotCurve : public caf::PdmObject virtual void onLoadDataAndUpdate(bool updateParentPlot) = 0; void updateCurvePresentation(bool updatePlotLegend); - virtual void updateCurveAppearance(); void updateOptionSensitivity(); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 6395a3c7a0..3b7f83298e 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -602,6 +602,27 @@ std::vector RimProject::allSummaryCases() const return sumCases; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimProject::summaryGroups() const +{ + std::vector groups; + + for (RimOilField* oilField : oilFields) + { + if (!oilField) continue; + RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); + if (sumCaseMainColl) + { + std::vector g = sumCaseMainColl->summaryCaseCollections(); + groups.insert(groups.end(), g.begin(), g.end()); + } + } + + return groups; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index a3064d937e..87df663385 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -47,6 +47,7 @@ class RimObservedData; class RimOilField; class RimScriptCollection; class RimSummaryCase; +class RimSummaryCaseCollection; class Rim3dView; class RimGridView; class RimViewLinker; @@ -106,6 +107,7 @@ class RimProject : public caf::PdmDocument void allCases(std::vector& cases); std::vector allSummaryCases() const; + std::vector summaryGroups() const; void allVisibleViews(std::vector& views); void allVisibleGridViews(std::vector& views); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 38d000a35a..3ba762d51d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -24,18 +24,49 @@ #include "RimProject.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotSourceStepping.h" +#include "RimSummaryFilter.h" +#include "RimSummaryAddress.h" +#include "RimEnsambleCurveSetCollection.h" #include "RiuLineSegmentQwtPlotCurve.h" #include "RiuSummaryQwtPlot.h" #include "cafPdmUiTreeViewEditor.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmObject.h" +#include "cafPdmUiPushButtonEditor.h" +#include #include + +// See also corresponding fake implementations in RimSummaryCurveFilter +static QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + +static QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + +template<> +void caf::AppEnum< RimEnsambleCurveSet::ColorMode >::setUp() +{ + addItem(RimEnsambleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); + addItem(RimEnsambleCurveSet::BY_ENSAMBLE_PARAM, "BY_ENSAMBLE_PARAM", "By Ensamble Parameter"); + setDefault(RimEnsambleCurveSet::SINGLE_COLOR); +} + + CAF_PDM_SOURCE_INIT(RimEnsambleCurveSet, "RimEnsambleCurveSet"); //-------------------------------------------------------------------------------------------------- @@ -43,35 +74,73 @@ CAF_PDM_SOURCE_INIT(RimEnsambleCurveSet, "RimEnsambleCurveSet"); //-------------------------------------------------------------------------------------------------- RimEnsambleCurveSet::RimEnsambleCurveSet() { - CAF_PDM_InitObject("Summary Curves", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensamble Curve Set", ":/SummaryCurveFilter16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_curves, "CollectionCurves", "Collection Curves", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_curves, "EnsambleCurveSet", "Ensamble Curve Set", "", "", ""); m_curves.uiCapability()->setUiHidden(true); m_curves.uiCapability()->setUiTreeChildrenHidden(false); CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); m_showCurves.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); - m_ySourceStepping = new RimSummaryPlotSourceStepping; - m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); - m_ySourceStepping.uiCapability()->setUiHidden(true); - m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_ySourceStepping.xmlCapability()->disableIO(); - - CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); - m_xSourceStepping = new RimSummaryPlotSourceStepping; - m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); - m_xSourceStepping.uiCapability()->setUiHidden(true); - m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_xSourceStepping.xmlCapability()->disableIO(); - - CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); - m_unionSourceStepping = new RimSummaryPlotSourceStepping; - m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); - m_unionSourceStepping.uiCapability()->setUiHidden(true); - m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_unionSourceStepping.xmlCapability()->disableIO(); + //CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); + //m_ySourceStepping = new RimSummaryPlotSourceStepping; + //m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); + //m_ySourceStepping.uiCapability()->setUiHidden(true); + //m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_ySourceStepping.xmlCapability()->disableIO(); + + //CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); + //m_xSourceStepping = new RimSummaryPlotSourceStepping; + //m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); + //m_xSourceStepping.uiCapability()->setUiHidden(true); + //m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_xSourceStepping.xmlCapability()->disableIO(); + + //CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); + //m_unionSourceStepping = new RimSummaryPlotSourceStepping; + //m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); + //m_unionSourceStepping.uiCapability()->setUiHidden(true); + //m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_unionSourceStepping.xmlCapability()->disableIO(); + + // Y Values + + CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Group", "", "", ""); + m_yValuesSummaryGroup.uiCapability()->setUiTreeChildrenHidden(true); + m_yValuesSummaryGroup.uiCapability()->setAutoAddingOptionFromValue(false); + + CAF_PDM_InitFieldNoDefault(&m_yValuesSelectedVariableDisplayField, "SelectedVariableDisplayVar", "Vector", "", "", ""); + m_yValuesSelectedVariableDisplayField.xmlCapability()->disableIO(); + //m_yValuesSelectedVariableDisplayField.uiCapability()->setUiReadOnly(true); + + CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryFilter, "VarListFilter", "Filter", "", "", ""); + m_yValuesSummaryFilter.uiCapability()->setUiTreeChildrenHidden(true); + m_yValuesSummaryFilter.uiCapability()->setUiHidden(true); + + m_yValuesSummaryFilter = new RimSummaryFilter; + + CAF_PDM_InitFieldNoDefault(&m_yValuesUiFilterResultSelection, "FilterResultSelection", "Filter Result", "", "", ""); + m_yValuesUiFilterResultSelection.xmlCapability()->disableIO(); + m_yValuesUiFilterResultSelection.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_yValuesUiFilterResultSelection.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_yValuesUiFilterResultSelection.uiCapability()->setAutoAddingOptionFromValue(false); + + CAF_PDM_InitFieldNoDefault(&m_yValuesCurveVariable, "SummaryAddress", "Summary Address", "", "", ""); + m_yValuesCurveVariable.uiCapability()->setUiHidden(true); + m_yValuesCurveVariable.uiCapability()->setUiTreeChildrenHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_yPushButtonSelectSummaryAddress); + m_yPushButtonSelectSummaryAddress = false; + + m_yValuesCurveVariable = new RimSummaryAddress; + + CAF_PDM_InitField(&m_colorMode, "ColorMode", caf::AppEnum(SINGLE_COLOR), "Coloring Mode", "", "", ""); + + CAF_PDM_InitField(&m_color, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); + + CAF_PDM_InitField(&m_ensambleParameter, "EnsambleParameter", QString(""), "Ensamble Parameter", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -87,7 +156,9 @@ RimEnsambleCurveSet::~RimEnsambleCurveSet() //-------------------------------------------------------------------------------------------------- bool RimEnsambleCurveSet::isCurvesVisible() { - return m_showCurves(); + RimEnsambleCurveSetCollection* coll = nullptr; + firstAncestorOrThisOfType(coll); + return m_showCurves() && (coll ? coll->isCurveSetsVisible() : true); } //-------------------------------------------------------------------------------------------------- @@ -265,148 +336,316 @@ void RimEnsambleCurveSet::setCurrentSummaryCurve(RimSummaryCurve* curve) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSet::fieldsToShowInToolbar() -{ - RimSummaryCrossPlot* parentCrossPlot; - firstAncestorOrThisOfType(parentCrossPlot); - - if (parentCrossPlot) - { - return m_unionSourceStepping->fieldsToShowInToolbar(); - } - - return m_ySourceStepping()->fieldsToShowInToolbar(); -} +//std::vector RimEnsambleCurveSet::fieldsToShowInToolbar() +//{ +// RimSummaryCrossPlot* parentCrossPlot; +// firstAncestorOrThisOfType(parentCrossPlot); +// +// if (parentCrossPlot) +// { +// return m_unionSourceStepping->fieldsToShowInToolbar(); +// } +// +// return m_ySourceStepping()->fieldsToShowInToolbar(); +//} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSet::handleKeyPressEvent(QKeyEvent* keyEvent) { - if (!keyEvent) return; + //if (!keyEvent) return; + + //RimSummaryPlotSourceStepping* sourceStepping = nullptr; + //{ + // RimSummaryCrossPlot* summaryCrossPlot = nullptr; + // this->firstAncestorOrThisOfType(summaryCrossPlot); + + // if (summaryCrossPlot) + // { + // sourceStepping = m_unionSourceStepping(); + // } + // else + // { + // sourceStepping = m_ySourceStepping(); + // } + //} + + //if (keyEvent->key() == Qt::Key_PageUp) + //{ + // if (keyEvent->modifiers() & Qt::ShiftModifier) + // { + // sourceStepping->applyPrevCase(); + + // keyEvent->accept(); + // } + // else if (keyEvent->modifiers() & Qt::ControlModifier) + // { + // sourceStepping->applyPrevOtherIdentifier(); + + // keyEvent->accept(); + // } + // else + // { + // sourceStepping->applyPrevQuantity(); + + // keyEvent->accept(); + // } + //} + //else if (keyEvent->key() == Qt::Key_PageDown) + //{ + // if (keyEvent->modifiers() & Qt::ShiftModifier) + // { + // sourceStepping->applyNextCase(); + + // keyEvent->accept(); + // } + // else if (keyEvent->modifiers() & Qt::ControlModifier) + // { + // sourceStepping->applyNextOtherIdentifier(); + + // keyEvent->accept(); + // } + // else + // { + // sourceStepping->applyNextQuantity(); + + // keyEvent->accept(); + // } + //} +} - RimSummaryPlotSourceStepping* sourceStepping = nullptr; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_showCurves) { - RimSummaryCrossPlot* summaryCrossPlot = nullptr; - this->firstAncestorOrThisOfType(summaryCrossPlot); + loadDataAndUpdate(true); + } + else if (changedField == &m_yValuesSummaryGroup || changedField == &m_yValuesSelectedVariableDisplayField) + { + deleteAllCurves(); + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot) plot->loadDataAndUpdate(); - if (summaryCrossPlot) + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + RifEclipseSummaryAddress addr = m_yValuesSelectedVariableDisplayField(); + if (group && plot && addr.category() != RifEclipseSummaryAddress::SUMMARY_INVALID) { - sourceStepping = m_unionSourceStepping(); + for (auto& sumCase : group->allSummaryCases()) + { + RimSummaryCurve* curve = new RimSummaryCurve(); + curve->setSummaryCaseY(sumCase); + curve->setSummaryAddressY(addr); + + addCurve(curve); + curve->setParentQwtPlotNoReplot(plot->qwtPlot()); + + curve->updateCurveVisibility(true); + curve->loadDataAndUpdate(true); + } } - else + } + else if (changedField == &m_ensambleParameter) + { + + } + else if (changedField == &m_color) + { + for (auto& curve : m_curves) { - sourceStepping = m_ySourceStepping(); + curve->setColor(m_color); + curve->updateCurveAppearance(); } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); } +} - if (keyEvent->key() == Qt::Key_PageUp) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ { - if (keyEvent->modifiers() & Qt::ShiftModifier) - { - sourceStepping->applyPrevCase(); + QString curveDataGroupName = "Summary Vector"; + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y"); + curveDataGroup->add(&m_yValuesSummaryGroup); + curveDataGroup->add(&m_yValuesSelectedVariableDisplayField); + curveDataGroup->add(&m_yPushButtonSelectSummaryAddress); + + QString curveVarSelectionGroupName = "Vector Selection Filter Y"; + caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroupWithKeyword("Vector Selection Filter", curveVarSelectionGroupName); + curveVarSelectionGroup->setCollapsedByDefault(true); + m_yValuesSummaryFilter->uiOrdering(uiConfigName, *curveVarSelectionGroup); + curveVarSelectionGroup->add(&m_yValuesUiFilterResultSelection); - keyEvent->accept(); - } - else if (keyEvent->modifiers() & Qt::ControlModifier) - { - sourceStepping->applyPrevOtherIdentifier(); + } - keyEvent->accept(); - } - else - { - sourceStepping->applyPrevQuantity(); + caf::PdmUiGroup* colorsGroup = uiOrdering.addNewGroup("Colors"); + colorsGroup->add(&m_colorMode); - keyEvent->accept(); - } + if (m_colorMode == SINGLE_COLOR) + { + colorsGroup->add(&m_color); } - else if (keyEvent->key() == Qt::Key_PageDown) + else if (m_colorMode == BY_ENSAMBLE_PARAM) { - if (keyEvent->modifiers() & Qt::ShiftModifier) - { - sourceStepping->applyNextCase(); + colorsGroup->add(&m_ensambleParameter); + } + uiOrdering.skipRemainingFields(true); - keyEvent->accept(); - } - else if (keyEvent->modifiers() & Qt::ControlModifier) - { - sourceStepping->applyNextOtherIdentifier(); + //RimSummaryCrossPlot* parentCrossPlot; + //firstAncestorOrThisOfType(parentCrossPlot); - keyEvent->accept(); - } - else - { - sourceStepping->applyNextQuantity(); + //if (parentCrossPlot) + //{ + // { + // auto group = uiOrdering.addNewGroup("Y Source Stepping"); - keyEvent->accept(); - } - } + // m_ySourceStepping()->uiOrdering(uiConfigName, *group); + // } + + // { + // auto group = uiOrdering.addNewGroup("X Source Stepping"); + + // m_xSourceStepping()->uiOrdering(uiConfigName, *group); + // } + + // { + // auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); + + // m_unionSourceStepping()->uiOrdering(uiConfigName, *group); + // } + //} + //else + //{ + // auto group = uiOrdering.addNewGroup("Plot Source Stepping"); + + // m_ySourceStepping()->uiOrdering(uiConfigName, *group); + //} } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() { - if (changedField == &m_showCurves) + return &m_showCurves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); + if (myAttr && m_currentSummaryCurve.notNull()) { - loadDataAndUpdate(true); + myAttr->currentObject = m_currentSummaryCurve.p(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +QList RimEnsambleCurveSet::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { - RimSummaryCrossPlot* parentCrossPlot; - firstAncestorOrThisOfType(parentCrossPlot); + QList options; - if (parentCrossPlot) + if (fieldNeedingOptions == &m_yValuesSummaryGroup) { - { - auto group = uiOrdering.addNewGroup("Y Source Stepping"); + RimProject* proj = RiaApplication::instance()->project(); + std::vector groups = proj->summaryGroups(); - m_ySourceStepping()->uiOrdering(uiConfigName, *group); + for (RimSummaryCaseCollection* group : groups) + { + options.push_back(caf::PdmOptionItemInfo(group->name(), group)); } - { - auto group = uiOrdering.addNewGroup("X Source Stepping"); + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_ensambleParameter) + { + RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - m_xSourceStepping()->uiOrdering(uiConfigName, *group); - } + options.push_back(caf::PdmOptionItemInfo("None", "")); + if (group) { - auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); - - m_unionSourceStepping()->uiOrdering(uiConfigName, *group); + std::set paramSet; + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (!rimCase->caseRealizationParameters().isNull()) + { + auto ps = rimCase->caseRealizationParameters()->parameters(); + for (auto p : ps) paramSet.insert(p.first); + } + } + + for (auto param : paramSet) + { + options.push_back(caf::PdmOptionItemInfo(param, param)); + } } } - else + else if (fieldNeedingOptions == &m_yValuesSelectedVariableDisplayField) { - auto group = uiOrdering.addNewGroup("Plot Source Stepping"); + RimSummaryCaseCollection* group = m_yValuesSummaryGroup; + std::map allOpts; - m_ySourceStepping()->uiOrdering(uiConfigName, *group); + if (group) + { + for (auto& sumCase : group->allSummaryCases()) + { + std::map opts; + RimSummaryFilter filter; + getOptionsForSummaryAddresses(&opts, sumCase, &filter); + + for (auto& opt : opts) allOpts.insert(opt); + } + } + + for (const auto& opt : allOpts) options.push_back(caf::PdmOptionItemInfo(opt.first, QVariant::fromValue(opt.second))); + options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() -{ - return &m_showCurves; + //else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) + //{ + // appendOptionItemsForSummaryAddresses(&options, m_yValuesSummaryCase(), m_yValuesSummaryFilter()); + //} + + return options; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map* options, + RimSummaryCase* summaryCase, + RimSummaryFilter* summaryFilter) { - caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); - if (myAttr && m_currentSummaryCurve.notNull()) + if (summaryCase) { - myAttr->currentObject = m_currentSummaryCurve.p(); + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + if (reader) + { + const std::vector allAddresses = reader->allResultAddresses(); + + for (auto& address : allAddresses) + { + if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; + + std::string name = address.uiText(); + QString s = QString::fromStdString(name); + options->insert(std::make_pair(s, address)); + } + } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index bbbd52ff3e..0f546b42c0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -19,16 +19,24 @@ #pragma once +#include "RifEclipseSummaryAddress.h" + +#include "cafPdmFieldCvfColor.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPtrArrayField.h" +#include "cafPdmPtrField.h" +#include "cafAppEnum.h" class QwtPlot; class QwtPlotCurve; class RimSummaryCase; +class RimSummaryCaseCollection; class RimSummaryCurve; +class RimSummaryAddress; +class RimSummaryFilter; class RimSummaryPlotSourceStepping; class QKeyEvent; @@ -40,6 +48,8 @@ class RimEnsambleCurveSet : public caf::PdmObject CAF_PDM_HEADER_INIT; public: + enum ColorMode {SINGLE_COLOR, BY_ENSAMBLE_PARAM}; + RimEnsambleCurveSet(); virtual ~RimEnsambleCurveSet(); @@ -63,7 +73,7 @@ class RimEnsambleCurveSet : public caf::PdmObject void setCurrentSummaryCurve(RimSummaryCurve* curve); - std::vector fieldsToShowInToolbar(); + //std::vector fieldsToShowInToolbar(); void handleKeyPressEvent(QKeyEvent* keyEvent); @@ -72,19 +82,36 @@ class RimEnsambleCurveSet : public caf::PdmObject virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + static void getOptionsForSummaryAddresses(std::map* options, + RimSummaryCase* summaryCase, + RimSummaryFilter* summaryFilter); + private: caf::PdmField m_showCurves; - caf::PdmChildArrayField m_curves; + caf::PdmChildArrayField m_curves; // Convert to PtrField ? - caf::PdmChildField m_ySourceStepping; - caf::PdmChildField m_xSourceStepping; - caf::PdmChildField m_unionSourceStepping; + //caf::PdmChildField m_ySourceStepping; + //caf::PdmChildField m_xSourceStepping; + //caf::PdmChildField m_unionSourceStepping; caf::PdmPointer m_currentSummaryCurve; + + // Y values + caf::PdmPtrField m_yValuesSummaryGroup; + caf::PdmChildField m_yValuesCurveVariable; + caf::PdmField m_yValuesSelectedVariableDisplayField; + caf::PdmChildField m_yValuesSummaryFilter; + caf::PdmField m_yValuesUiFilterResultSelection; + caf::PdmField m_yPushButtonSelectSummaryAddress; + + caf::PdmField> m_colorMode; + caf::PdmField m_color; + caf::PdmField m_ensambleParameter; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp index 73a17b0ecc..8576c4346f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp @@ -23,6 +23,7 @@ #include "RifReaderEclipseSummary.h" #include "RimProject.h" +#include "RimEnsambleCurveSet.h" #include "RimSummaryCase.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" @@ -43,35 +44,35 @@ CAF_PDM_SOURCE_INIT(RimEnsambleCurveSetCollection, "RimEnsambleCurveSetCollectio //-------------------------------------------------------------------------------------------------- RimEnsambleCurveSetCollection::RimEnsambleCurveSetCollection() { - CAF_PDM_InitObject("Summary Curves", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensamble Curve Sets", ":/SummaryCurveFilter16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_curves, "CollectionCurves", "Collection Curves", "", "", ""); - m_curves.uiCapability()->setUiHidden(true); - m_curves.uiCapability()->setUiTreeChildrenHidden(false); + CAF_PDM_InitFieldNoDefault(&m_curveSets, "EnsambleCurveSets", "Ensamble Curve Sets", "", "", ""); + m_curveSets.uiCapability()->setUiHidden(true); + m_curveSets.uiCapability()->setUiTreeChildrenHidden(false); CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); m_showCurves.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); - m_ySourceStepping = new RimSummaryPlotSourceStepping; - m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); - m_ySourceStepping.uiCapability()->setUiHidden(true); - m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_ySourceStepping.xmlCapability()->disableIO(); - - CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); - m_xSourceStepping = new RimSummaryPlotSourceStepping; - m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); - m_xSourceStepping.uiCapability()->setUiHidden(true); - m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_xSourceStepping.xmlCapability()->disableIO(); - - CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); - m_unionSourceStepping = new RimSummaryPlotSourceStepping; - m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); - m_unionSourceStepping.uiCapability()->setUiHidden(true); - m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - m_unionSourceStepping.xmlCapability()->disableIO(); + //CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); + //m_ySourceStepping = new RimSummaryPlotSourceStepping; + //m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); + //m_ySourceStepping.uiCapability()->setUiHidden(true); + //m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_ySourceStepping.xmlCapability()->disableIO(); + + //CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); + //m_xSourceStepping = new RimSummaryPlotSourceStepping; + //m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); + //m_xSourceStepping.uiCapability()->setUiHidden(true); + //m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_xSourceStepping.xmlCapability()->disableIO(); + + //CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); + //m_unionSourceStepping = new RimSummaryPlotSourceStepping; + //m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); + //m_unionSourceStepping.uiCapability()->setUiHidden(true); + //m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); + //m_unionSourceStepping.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- @@ -79,13 +80,13 @@ RimEnsambleCurveSetCollection::RimEnsambleCurveSetCollection() //-------------------------------------------------------------------------------------------------- RimEnsambleCurveSetCollection::~RimEnsambleCurveSetCollection() { - m_curves.deleteAllChildObjects(); + m_curveSets.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEnsambleCurveSetCollection::isCurvesVisible() +bool RimEnsambleCurveSetCollection::isCurveSetsVisible() { return m_showCurves(); } @@ -95,36 +96,28 @@ bool RimEnsambleCurveSetCollection::isCurvesVisible() //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) { - for (RimSummaryCurve* curve : m_curves) + for (RimEnsambleCurveSet* curveSet : m_curveSets) { - curve->loadDataAndUpdate(false); - curve->updateQwtPlotAxis(); + curveSet->loadDataAndUpdate(updateParentPlot); } - if ( updateParentPlot ) - { - RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if ( parentPlot->qwtPlot() ) - { - parentPlot->qwtPlot()->updateLegend(); - parentPlot->updateAxes(); - parentPlot->updateZoomInQwt(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) -{ - for (RimSummaryCurve* curve : m_curves) - { - curve->setParentQwtPlotNoReplot(plot); - } - - if (plot) plot->replot(); + //for (RimSummaryCurve* curve : m_curves) + //{ + // curve->loadDataAndUpdate(false); + // curve->updateQwtPlotAxis(); + //} + + //if ( updateParentPlot ) + //{ + // RimSummaryPlot* parentPlot; + // firstAncestorOrThisOfTypeAsserted(parentPlot); + // if ( parentPlot->qwtPlot() ) + // { + // parentPlot->qwtPlot()->updateLegend(); + // parentPlot->updateAxes(); + // parentPlot->updateZoomInQwt(); + // } + //} } //-------------------------------------------------------------------------------------------------- @@ -132,69 +125,53 @@ void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSetCollection::detachQwtCurves() { - for (RimSummaryCurve* curve : m_curves) + for(const auto& curveSet : m_curveSets) { - curve->detachQwtCurve(); + curveSet->detachQwtCurves(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RimEnsambleCurveSetCollection::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const +void RimEnsambleCurveSetCollection::addCurveSet(RimEnsambleCurveSet* curveSet) { - for (RimSummaryCurve* rimCurve : m_curves) + if (curveSet) { - if (rimCurve->qwtPlotCurve() == qwtCurve) - { - return rimCurve; - } + m_curveSets.push_back(curveSet); } - - return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::addCurve(RimSummaryCurve* curve) +void RimEnsambleCurveSetCollection::deleteCurveSet(RimEnsambleCurveSet* curveSet) { - if (curve) + if (curveSet) { - m_curves.push_back(curve); + m_curveSets.removeChildObject(curveSet); + delete curveSet; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::deleteCurve(RimSummaryCurve* curve) +std::vector RimEnsambleCurveSetCollection::curveSets() const { - if (curve) - { - m_curves.removeChildObject(curve); - delete curve; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSetCollection::curves() const -{ - return m_curves.childObjects(); + return m_curveSets.childObjects(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSetCollection::visibleCurves() const +std::vector RimEnsambleCurveSetCollection::visibleCurveSets() const { - std::vector visible; + std::vector visible; - for (auto c : m_curves) + for (auto c : m_curveSets) { - if (c->isCurveVisible()) + if (c->isCurvesVisible()) { visible.push_back(c); } @@ -203,146 +180,146 @@ std::vector RimEnsambleCurveSetCollection::visibleCurves() con return visible; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) -{ - std::vector summaryCurvesToDelete; - - for (RimSummaryCurve* summaryCurve : m_curves) - { - if (!summaryCurve) continue; - if (!summaryCurve->summaryCaseY()) continue; - - if (summaryCurve->summaryCaseY() == summaryCase) - { - summaryCurvesToDelete.push_back(summaryCurve); - } - } - for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) - { - m_curves.removeChildObject(summaryCurve); - delete summaryCurve; - } - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::deleteAllCurves() -{ - m_curves.deleteAllChildObjects(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::updateCaseNameHasChanged() -{ - for (RimSummaryCurve* curve : m_curves) - { - curve->updateCurveNameNoLegendUpdate(); - curve->updateConnectedEditors(); - } - - RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); -} +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +//void RimEnsambleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) +//{ +// std::vector summaryCurvesToDelete; +// +// for (RimSummaryCurve* summaryCurve : m_curves) +// { +// if (!summaryCurve) continue; +// if (!summaryCurve->summaryCaseY()) continue; +// +// if (summaryCurve->summaryCaseY() == summaryCase) +// { +// summaryCurvesToDelete.push_back(summaryCurve); +// } +// } +// for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) +// { +// m_curves.removeChildObject(summaryCurve); +// delete summaryCurve; +// } +// +//} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) +void RimEnsambleCurveSetCollection::deleteAllCurveSets() { - m_currentSummaryCurve = curve; - - updateConnectedEditors(); + m_curveSets.deleteAllChildObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSetCollection::fieldsToShowInToolbar() -{ - RimSummaryCrossPlot* parentCrossPlot; - firstAncestorOrThisOfType(parentCrossPlot); - - if (parentCrossPlot) - { - return m_unionSourceStepping->fieldsToShowInToolbar(); - } - - return m_ySourceStepping()->fieldsToShowInToolbar(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) -{ - if (!keyEvent) return; - - RimSummaryPlotSourceStepping* sourceStepping = nullptr; - { - RimSummaryCrossPlot* summaryCrossPlot = nullptr; - this->firstAncestorOrThisOfType(summaryCrossPlot); - - if (summaryCrossPlot) - { - sourceStepping = m_unionSourceStepping(); - } - else - { - sourceStepping = m_ySourceStepping(); - } - } - - if (keyEvent->key() == Qt::Key_PageUp) - { - if (keyEvent->modifiers() & Qt::ShiftModifier) - { - sourceStepping->applyPrevCase(); - - keyEvent->accept(); - } - else if (keyEvent->modifiers() & Qt::ControlModifier) - { - sourceStepping->applyPrevOtherIdentifier(); - - keyEvent->accept(); - } - else - { - sourceStepping->applyPrevQuantity(); - - keyEvent->accept(); - } - } - else if (keyEvent->key() == Qt::Key_PageDown) - { - if (keyEvent->modifiers() & Qt::ShiftModifier) - { - sourceStepping->applyNextCase(); - - keyEvent->accept(); - } - else if (keyEvent->modifiers() & Qt::ControlModifier) - { - sourceStepping->applyNextOtherIdentifier(); - - keyEvent->accept(); - } - else - { - sourceStepping->applyNextQuantity(); - - keyEvent->accept(); - } - } -} +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +//void RimEnsambleCurveSetCollection::updateCaseNameHasChanged() +//{ +// for (RimSummaryCurve* curve : m_curves) +// { +// curve->updateCurveNameNoLegendUpdate(); +// curve->updateConnectedEditors(); +// } +// +// RimSummaryPlot* parentPlot; +// firstAncestorOrThisOfTypeAsserted(parentPlot); +// if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); +//} +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +//void RimEnsambleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) +//{ +// m_currentSummaryCurve = curve; +// +// updateConnectedEditors(); +//} +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +//std::vector RimEnsambleCurveSetCollection::fieldsToShowInToolbar() +//{ +// RimSummaryCrossPlot* parentCrossPlot; +// firstAncestorOrThisOfType(parentCrossPlot); +// +// if (parentCrossPlot) +// { +// return m_unionSourceStepping->fieldsToShowInToolbar(); +// } +// +// return m_ySourceStepping()->fieldsToShowInToolbar(); +//} +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +//void RimEnsambleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) +//{ +// if (!keyEvent) return; +// +// RimSummaryPlotSourceStepping* sourceStepping = nullptr; +// { +// RimSummaryCrossPlot* summaryCrossPlot = nullptr; +// this->firstAncestorOrThisOfType(summaryCrossPlot); +// +// if (summaryCrossPlot) +// { +// sourceStepping = m_unionSourceStepping(); +// } +// else +// { +// sourceStepping = m_ySourceStepping(); +// } +// } +// +// if (keyEvent->key() == Qt::Key_PageUp) +// { +// if (keyEvent->modifiers() & Qt::ShiftModifier) +// { +// sourceStepping->applyPrevCase(); +// +// keyEvent->accept(); +// } +// else if (keyEvent->modifiers() & Qt::ControlModifier) +// { +// sourceStepping->applyPrevOtherIdentifier(); +// +// keyEvent->accept(); +// } +// else +// { +// sourceStepping->applyPrevQuantity(); +// +// keyEvent->accept(); +// } +// } +// else if (keyEvent->key() == Qt::Key_PageDown) +// { +// if (keyEvent->modifiers() & Qt::ShiftModifier) +// { +// sourceStepping->applyNextCase(); +// +// keyEvent->accept(); +// } +// else if (keyEvent->modifiers() & Qt::ControlModifier) +// { +// sourceStepping->applyNextOtherIdentifier(); +// +// keyEvent->accept(); +// } +// else +// { +// sourceStepping->applyNextQuantity(); +// +// keyEvent->accept(); +// } +// } +//} //-------------------------------------------------------------------------------------------------- /// @@ -360,35 +337,35 @@ void RimEnsambleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimSummaryCrossPlot* parentCrossPlot; - firstAncestorOrThisOfType(parentCrossPlot); + //RimSummaryCrossPlot* parentCrossPlot; + //firstAncestorOrThisOfType(parentCrossPlot); - if (parentCrossPlot) - { - { - auto group = uiOrdering.addNewGroup("Y Source Stepping"); + //if (parentCrossPlot) + //{ + // { + // auto group = uiOrdering.addNewGroup("Y Source Stepping"); - m_ySourceStepping()->uiOrdering(uiConfigName, *group); - } + // m_ySourceStepping()->uiOrdering(uiConfigName, *group); + // } - { - auto group = uiOrdering.addNewGroup("X Source Stepping"); + // { + // auto group = uiOrdering.addNewGroup("X Source Stepping"); - m_xSourceStepping()->uiOrdering(uiConfigName, *group); - } + // m_xSourceStepping()->uiOrdering(uiConfigName, *group); + // } - { - auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); + // { + // auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); - m_unionSourceStepping()->uiOrdering(uiConfigName, *group); - } - } - else - { - auto group = uiOrdering.addNewGroup("Plot Source Stepping"); + // m_unionSourceStepping()->uiOrdering(uiConfigName, *group); + // } + //} + //else + //{ + // auto group = uiOrdering.addNewGroup("Plot Source Stepping"); - m_ySourceStepping()->uiOrdering(uiConfigName, *group); - } + // m_ySourceStepping()->uiOrdering(uiConfigName, *group); + //} } //-------------------------------------------------------------------------------------------------- @@ -404,9 +381,9 @@ caf::PdmFieldHandle* RimEnsambleCurveSetCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSetCollection::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); - if (myAttr && m_currentSummaryCurve.notNull()) - { - myAttr->currentObject = m_currentSummaryCurve.p(); - } + //caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); + //if (myAttr && m_currentSummaryCurve.notNull()) + //{ + // myAttr->currentObject = m_currentSummaryCurve.p(); + //} } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h index 151c7c23f2..fe35983fc6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h @@ -25,12 +25,8 @@ #include "cafPdmObject.h" #include "cafPdmPtrArrayField.h" -class QwtPlot; -class QwtPlotCurve; class RimSummaryCase; -class RimSummaryCurve; -class RimSummaryPlotSourceStepping; -class QKeyEvent; +class RimEnsambleCurveSet; //================================================================================================== /// @@ -43,29 +39,29 @@ class RimEnsambleCurveSetCollection : public caf::PdmObject RimEnsambleCurveSetCollection(); virtual ~RimEnsambleCurveSetCollection(); - bool isCurvesVisible(); + bool isCurveSetsVisible(); void loadDataAndUpdate(bool updateParentPlot); - void setParentQwtPlotAndReplot(QwtPlot* plot); + //void setParentQwtPlotAndReplot(QwtPlot* plot); void detachQwtCurves(); - RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; + //RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; - void addCurve(RimSummaryCurve* curve); - void deleteCurve(RimSummaryCurve* curve); + void addCurveSet(RimEnsambleCurveSet* curveSet); + void deleteCurveSet(RimEnsambleCurveSet* curveSet); - std::vector curves() const; - std::vector visibleCurves() const; + std::vector curveSets() const; + std::vector visibleCurveSets() const; - void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); - void deleteAllCurves(); - void updateCaseNameHasChanged(); + //void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); + void deleteAllCurveSets(); + //void updateCaseNameHasChanged(); - void setCurrentSummaryCurve(RimSummaryCurve* curve); + //void setCurrentSummaryCurve(RimSummaryCurve* curve); - std::vector fieldsToShowInToolbar(); + //std::vector fieldsToShowInToolbar(); - void handleKeyPressEvent(QKeyEvent* keyEvent); + //void handleKeyPressEvent(QKeyEvent* keyEvent); private: caf::PdmFieldHandle* objectToggleField(); @@ -78,13 +74,9 @@ class RimEnsambleCurveSetCollection : public caf::PdmObject const QVariant& oldValue, const QVariant& newValue) override; private: - caf::PdmField m_showCurves; - caf::PdmChildArrayField m_curves; + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curveSets; - caf::PdmChildField m_ySourceStepping; - caf::PdmChildField m_xSourceStepping; - caf::PdmChildField m_unionSourceStepping; - - caf::PdmPointer m_currentSummaryCurve; + //caf::PdmPointer m_currentSummaryCurve; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index b3dce95459..5d3f635ad2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -22,12 +22,14 @@ #include "RiaSummaryCurveAnalyzer.h" #include "RimAsciiDataCurve.h" +#include "RimEnsambleCurveSet.h" #include "RimGridTimeHistoryCurve.h" #include "RimProject.h" #include "RimSummaryAxisProperties.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimEnsambleCurveSetCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryCurvesCalculator.h" #include "RimSummaryPlotCollection.h" @@ -83,6 +85,10 @@ RimSummaryPlot::RimSummaryPlot() m_summaryCurveCollection.uiCapability()->setUiTreeHidden(true); m_summaryCurveCollection = new RimSummaryCurveCollection; + CAF_PDM_InitFieldNoDefault(&m_ensambleCurveSetCollection, "EnsambleCurveSetCollection", "", "", "", ""); + m_ensambleCurveSetCollection.uiCapability()->setUiTreeHidden(true); + m_ensambleCurveSetCollection = new RimEnsambleCurveSetCollection(); + CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden(true); @@ -133,6 +139,7 @@ RimSummaryPlot::~RimSummaryPlot() m_summaryCurves_OBSOLETE.deleteAllChildObjects(); m_curveFilters_OBSOLETE.deleteAllChildObjects(); delete m_summaryCurveCollection; + delete m_ensambleCurveSetCollection; } //-------------------------------------------------------------------------------------------------- @@ -937,6 +944,18 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//void RimSummaryPlot::addEnsambleCurve(const RimEnsambleCurveSet* curveSet, RimSummaryCurve* curve) +//{ +// if (curveSet && curve) +// { +// const_cast(curveSet)->addCurve(curve); +// curve->setParentQwtPlotAndReplot(m_qwtPlot); +// } +//} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -962,6 +981,14 @@ void RimSummaryPlot::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsambleCurveSetCollection* RimSummaryPlot::ensambleCurveSets() const +{ + return m_ensambleCurveSetCollection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -969,6 +996,9 @@ void RimSummaryPlot::setCurveCollection(RimSummaryCurveCollection* curveCollecti { if (curveCollection) { + // Delete current curve coll ? + + m_summaryCurveCollection = curveCollection; if (m_qwtPlot) { @@ -1114,6 +1144,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering axisFolder->add(&m_rightYAxisProperties); uiTreeOrdering.add(&m_summaryCurveCollection); + uiTreeOrdering.add(&m_ensambleCurveSetCollection); uiTreeOrdering.add(&m_gridTimeHistoryCurves); uiTreeOrdering.add(&m_asciiDataCurves); @@ -1134,6 +1165,8 @@ void RimSummaryPlot::onLoadDataAndUpdate() m_summaryCurveCollection->loadDataAndUpdate(false); } + m_ensambleCurveSetCollection->loadDataAndUpdate(false); + for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { curve->loadDataAndUpdate(true); @@ -1461,6 +1494,8 @@ void RimSummaryPlot::detachAllCurves() m_summaryCurveCollection->detachQwtCurves(); } + m_ensambleCurveSetCollection->detachQwtCurves(); + for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { curve->detachQwtCurve(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 95e3a12522..39129e7c45 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -38,6 +38,7 @@ class RimGridTimeHistoryCurve; class RimSummaryCase; class RimSummaryCurve; class RimSummaryCurveCollection; +class RimEnsambleCurveSetCollection; class RimSummaryCurveFilter_OBSOLETE; class RimSummaryTimeAxisProperties; class RimSummaryAxisProperties; @@ -69,10 +70,14 @@ class RimSummaryPlot : public RimViewWindow void addCurveAndUpdate(RimSummaryCurve* curve); void addCurveNoUpdate(RimSummaryCurve* curve); + //void addEnsambleCurve(const RimEnsambleCurveSet* curveSet, RimSummaryCurve* curve); + void deleteCurve(RimSummaryCurve* curve); void setCurveCollection(RimSummaryCurveCollection* curveCollection); void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); + RimEnsambleCurveSetCollection* ensambleCurveSets() const; + void addGridTimeHistoryCurve(RimGridTimeHistoryCurve* curve); void addAsciiDataCruve(RimAsciiDataCurve* curve); @@ -165,6 +170,8 @@ class RimSummaryPlot : public RimViewWindow caf::PdmChildArrayField m_gridTimeHistoryCurves; caf::PdmChildField m_summaryCurveCollection; + caf::PdmChildField m_ensambleCurveSetCollection; + caf::PdmChildArrayField m_asciiDataCurves; caf::PdmField m_isAutoZoom; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 4f7a0169bf..94ec272b8c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -526,7 +526,9 @@ std::set RimSummaryPlotSourceStepping::visibleAddresse std::set addresses; RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfTypeAsserted(curveCollection); + this->firstAncestorOrThisOfType(curveCollection); + + if (!curveCollection) return addresses; auto curves = curveCollection->visibleCurves(); for (auto c : curves) @@ -553,7 +555,9 @@ std::set RimSummaryPlotSourceStepping::visibleSummaryCasesCurve std::set sumCases; RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfTypeAsserted(curveCollection); + this->firstAncestorOrThisOfType(curveCollection); + + if (!curveCollection) return sumCases; auto curves = curveCollection->visibleCurves(); for (auto c : curves) diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 5431cc627c..363864bd72 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -307,7 +307,15 @@ void RiuSummaryCurveDefSelection::setDefaultSelection() RiaSummaryCurveDefinition curveDef(allSumCases[0], defaultAddress); std::vector curveDefs; curveDefs.push_back(curveDef); - + + // DEBUG + //{ + // RifEclipseSummaryAddress defaultAddress = RifEclipseSummaryAddress::fieldVarAddress("FOPTH"); + + // RiaSummaryCurveDefinition curveDef(allSumCases[0], defaultAddress); + // curveDefs.push_back(curveDef); + //} + setSelectedCurveDefinitions(curveDefs); } } From ba5480fa81792fa4c55ff39edc6a5b8e96114876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 6 Apr 2018 11:30:48 +0200 Subject: [PATCH 0617/1027] #2655, #2610 Add legend config to curve set. No connected to curves yet... --- .../Summary/RimEnsambleCurveSet.cpp | 51 ++++++++++++++++++- .../Summary/RimEnsambleCurveSet.h | 5 ++ .../Summary/RimSummaryCaseMainCollection.cpp | 6 ++- .../Summary/RimSummaryPlot.cpp | 5 +- .../RigCaseRealizationParameters.cpp | 9 ++++ .../RigCaseRealizationParameters.h | 2 + 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 3ba762d51d..9928e071ab 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -37,10 +37,13 @@ #include "RiuSummaryQwtPlot.h" #include "cafPdmUiTreeViewEditor.h" +#include "cafPdmUiTreeOrdering.h" #include "cafPdmUiListEditor.h" #include "cafPdmObject.h" #include "cafPdmUiPushButtonEditor.h" +#include "cvfScalarMapperContinuousLinear.h" + #include #include @@ -141,6 +144,9 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitField(&m_color, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); CAF_PDM_InitField(&m_ensambleParameter, "EnsambleParameter", QString(""), "Ensamble Parameter", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); + m_legendConfig = new RimLegendConfig(); } //-------------------------------------------------------------------------------------------------- @@ -452,7 +458,41 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } else if (changedField == &m_ensambleParameter) { + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + QString parameterName = m_ensambleParameter(); + if (group && !parameterName.isEmpty()) + { + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (!rimCase->caseRealizationParameters().isNull()) + { + double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value != HUGE_VAL) + { + if (value < minValue) minValue = value; + if (value > maxValue) maxValue = value; + } + } + } + cvf::ScalarMapperContinuousLinear colorMapper; + colorMapper.setRange(minValue, maxValue); + + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + curve->setColor(cvf::Color3f(colorMapper.mapToColor(value))); + curve->updateCurveAppearance(); + } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); + } } else if (changedField == &m_color) { @@ -532,6 +572,15 @@ void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder //} } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + uiTreeOrdering.add(m_legendConfig()); + uiTreeOrdering.skipRemainingChildren(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -575,7 +624,7 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c { RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - options.push_back(caf::PdmOptionItemInfo("None", "")); + //options.push_back(caf::PdmOptionItemInfo("None", "")); if (group) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index 0f546b42c0..a5cebba9a2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -21,6 +21,8 @@ #include "RifEclipseSummaryAddress.h" +#include "RimLegendConfig.h" + #include "cafPdmFieldCvfColor.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" @@ -84,6 +86,7 @@ class RimEnsambleCurveSet : public caf::PdmObject virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -113,5 +116,7 @@ class RimEnsambleCurveSet : public caf::PdmObject caf::PdmField> m_colorMode; caf::PdmField m_color; caf::PdmField m_ensambleParameter; + + caf::PdmChildField m_legendConfig; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 6b7091eb01..7e452858ab 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -280,7 +280,11 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() { for (RimSummaryCase* sumCase : allSummaryCases()) { - if (sumCase) sumCase->createSummaryReaderInterface(); + if (sumCase) + { + sumCase->createSummaryReaderInterface(); + addCaseRealizationParametersIfFound(*sumCase, sumCase->summaryHeaderFilename()); + } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 5d3f635ad2..7c21246194 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1144,7 +1144,10 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering axisFolder->add(&m_rightYAxisProperties); uiTreeOrdering.add(&m_summaryCurveCollection); - uiTreeOrdering.add(&m_ensambleCurveSetCollection); + if (!m_isCrossPlot) + { + uiTreeOrdering.add(&m_ensambleCurveSetCollection); + } uiTreeOrdering.add(&m_gridTimeHistoryCurves); uiTreeOrdering.add(&m_asciiDataCurves); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp index f9e19676ea..0869cc8dd2 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp @@ -27,6 +27,15 @@ void RigCaseRealizationParameters::addParameter(const QString& name, double valu m_parameters[name] = value; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCaseRealizationParameters::parameterValue(const QString& name) +{ + if (m_parameters.count(name) == 0) return HUGE_VAL; + return m_parameters[name]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h index d647e83482..6e5075fdb0 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h @@ -34,6 +34,8 @@ class RigCaseRealizationParameters : public cvf::Object { public: void addParameter(const QString& name, double value); + double parameterValue(const QString& name); + std::map parameters() const; private: From 7dc41bd981d5fbb50bac0ddfa739cb5fc21cabff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 6 Apr 2018 11:53:44 +0200 Subject: [PATCH 0618/1027] #2610 Enable delete command for ensamble curve sets --- ApplicationCode/Commands/RicDeleteItemFeature.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index 221213a542..df4ac23e09 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -25,6 +25,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipseView.h" +#include "RimEnsambleCurveSet.h" #include "RimFishbonesMultipleSubs.h" #include "RimFormationNames.h" #include "RimFormationNamesCollection.h" @@ -117,6 +118,7 @@ bool isDeletable(caf::PdmUiItem* uiItem) if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; + if (dynamic_cast(uiItem)) return true; return false; } From 8491fd7f6c68c08cb3e7d760454d5de6ddcd800d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 6 Apr 2018 13:35:47 +0200 Subject: [PATCH 0619/1027] #2610 Fix a few Linux build errors --- .../Summary/RimEnsambleCurveSet.cpp | 13 ++++++++----- .../RigCaseRealizationParameters.cpp | 2 +- .../RigCaseRealizationParameters.h | 1 + .../RifCaseRealizationParametersReader-Test.cpp | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 9928e071ab..41cea53298 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -61,12 +61,15 @@ static QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sob return str; } -template<> -void caf::AppEnum< RimEnsambleCurveSet::ColorMode >::setUp() +namespace caf { - addItem(RimEnsambleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); - addItem(RimEnsambleCurveSet::BY_ENSAMBLE_PARAM, "BY_ENSAMBLE_PARAM", "By Ensamble Parameter"); - setDefault(RimEnsambleCurveSet::SINGLE_COLOR); + template<> + void AppEnum< RimEnsambleCurveSet::ColorMode >::setUp() + { + addItem(RimEnsambleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); + addItem(RimEnsambleCurveSet::BY_ENSAMBLE_PARAM, "BY_ENSAMBLE_PARAM", "By Ensamble Parameter"); + setDefault(RimEnsambleCurveSet::SINGLE_COLOR); + } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp index 0869cc8dd2..558a1e50ba 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigCaseRealizationParameters.h" - +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h index 6e5075fdb0..801458e04b 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h @@ -18,6 +18,7 @@ #pragma once +#include "cvfBase.h" #include "cvfObject.h" #include diff --git a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp index a91bf0e3d8..4d447ff60c 100644 --- a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp +++ b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp @@ -45,9 +45,9 @@ TEST(RifCaseRealizationParametersReaderTest, SuccessfulParsing) const cvf::ref parameters = reader.parameters(); std::map params = parameters->parameters(); - EXPECT_EQ(1, params.count("LETSWOF:L_1OW")); - EXPECT_EQ(1, params.count("LETSGOF:KRG1")); - EXPECT_EQ(1, params.count("LOG10_MULTFLT:MULTFLT_F1")); + EXPECT_EQ(1U, params.count("LETSWOF:L_1OW")); + EXPECT_EQ(1U, params.count("LETSGOF:KRG1")); + EXPECT_EQ(1U, params.count("LOG10_MULTFLT:MULTFLT_F1")); EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"]); EXPECT_EQ(0.97, params["LETSGOF:KRG1"]); From e8d765a2a9393691e798aa8a380fd589ecb8a706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 6 Apr 2018 15:52:16 +0200 Subject: [PATCH 0620/1027] #2610 Add default constructor and setter --- .../RifCaseRealizationParametersReader.cpp | 19 +++++++++++++++++++ .../RifCaseRealizationParametersReader.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp index f6ec9b11b8..c4d77d7b1d 100644 --- a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -44,6 +44,17 @@ RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QSt m_textStream = nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::RifCaseRealizationParametersReader() +{ + m_parameters = new RigCaseRealizationParameters(); + m_fileName = ""; + m_file = nullptr; + m_textStream = nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -56,6 +67,14 @@ RifCaseRealizationParametersReader::~RifCaseRealizationParametersReader() closeFile(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::setFileName(const QString& fileName) +{ + m_fileName = fileName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h index fd8b89f652..56e8a793db 100644 --- a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h @@ -42,9 +42,11 @@ class QFile; class RifCaseRealizationParametersReader { public: + RifCaseRealizationParametersReader(); RifCaseRealizationParametersReader(const QString& fileName); ~RifCaseRealizationParametersReader(); + void setFileName(const QString& fileName); void parse(); const cvf::ref parameters() const; From b72091bb944a91d70a26658a05e87654e9ed28ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 08:48:36 +0200 Subject: [PATCH 0621/1027] #2661 Update ecllib from statoil master repo --- ResInsightVersion.cmake | 2 +- ThirdParty/Ert/.travis.yml | 5 +- ThirdParty/Ert/CMakeLists.txt | 49 +- ThirdParty/Ert/applications/CMakeLists.txt | 1 + ThirdParty/Ert/applications/ecl/ecl_pack.c | 50 +- ThirdParty/Ert/applications/ecl/ecl_unpack.c | 58 +- ThirdParty/Ert/applications/ecl/kw_extract.c | 41 +- ThirdParty/Ert/appveyor.yml | 2 +- ThirdParty/Ert/bin/CMakeLists.txt | 3 + ThirdParty/Ert/bin/summary_resample | 27 + .../Ert/cmake/libecl-config-version.cmake.in | 4 +- ThirdParty/Ert/cmake/libecl-config.cmake.in | 4 +- ThirdParty/Ert/debian/control | 4 +- ThirdParty/Ert/debian/python-cwrap.install | 1 + ThirdParty/Ert/debian/rules | 2 +- ThirdParty/Ert/docs/CMakeLists.txt | 2 +- .../code/python/packages/eclipse/index.rst | 4 +- ThirdParty/Ert/docs/nexus.plt | 4 +- ThirdParty/Ert/docs/tips.txt | 8 +- ThirdParty/Ert/lib/CMakeLists.txt | 74 +- ThirdParty/Ert/lib/build_config.h.in | 3 +- ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c | 2 + ThirdParty/Ert/lib/ecl/ecl_grid.c | 19 +- ThirdParty/Ert/lib/ecl/ecl_kw.c | 128 +- ThirdParty/Ert/lib/ecl/ecl_kw_functions.c | 24 + ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c | 4 +- ThirdParty/Ert/lib/ecl/ecl_rft_file.c | 2 +- ThirdParty/Ert/lib/ecl/ecl_rft_node.c | 2 +- ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 +- ThirdParty/Ert/lib/ecl/ecl_smspec.c | 295 ++-- ThirdParty/Ert/lib/ecl/ecl_sum.c | 158 +- ThirdParty/Ert/lib/ecl/ecl_sum_data.c | 57 +- ThirdParty/Ert/lib/ecl/ecl_sum_vector.c | 81 +- ThirdParty/Ert/lib/ecl/ecl_util.c | 319 ++-- ThirdParty/Ert/lib/ecl/fault_block_layer.c | 2 +- ThirdParty/Ert/lib/ecl/smspec_node.c | 2 +- .../Ert/lib/ecl/tests/ecl_grid_corner.c | 45 +- ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c | 41 +- ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c | 14 +- .../ecl/tests/ecl_sum_alloc_resampled_test.c | 98 ++ ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c | 2 +- ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c | 46 +- .../Ert/lib/ecl/tests/ecl_util_filenames.c | 120 ++ .../Ert/lib/ecl/tests/ecl_util_path_access.c | 53 + .../lib/ecl/tests/well_branch_collection.c | 4 + ThirdParty/Ert/lib/ecl/tests/well_conn.c | 3 + ThirdParty/Ert/lib/ecl/tests/well_segment.c | 4 + .../Ert/lib/ecl/tests/well_segment_conn.c | 4 + ThirdParty/Ert/lib/ert_api_config.h.in | 1 - ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp | 2 +- ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h | 1 + ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h | 1 + .../Ert/lib/include/ert/ecl/ecl_kw_magic.h | 21 +- .../Ert/lib/include/ert/ecl/ecl_smspec.h | 9 +- ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h | 16 +- .../Ert/lib/include/ert/ecl/ecl_sum_vector.h | 5 +- ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h | 5 +- ThirdParty/Ert/lib/include/ert/util/hash.h | 43 +- .../Ert/lib/include/ert/util/msvc_stdbool.h | 6 +- .../Ert/lib/include/ert/util/stringlist.h | 6 +- ThirdParty/Ert/lib/include/ert/util/util.h | 42 +- ThirdParty/Ert/lib/util/hash.c | 217 +-- ThirdParty/Ert/lib/util/path_stack.c | 45 +- ThirdParty/Ert/lib/util/set.c | 2 +- ThirdParty/Ert/lib/util/string_util.c | 2 + ThirdParty/Ert/lib/util/stringlist.c | 90 +- ThirdParty/Ert/lib/util/test_work_area.c | 11 +- .../Ert/lib/util/tests/ert_util_filename.c | 49 +- .../Ert/lib/util/tests/ert_util_normal_path.c | 73 + .../lib/util/tests/ert_util_relpath_test.c | 2 +- .../Ert/lib/util/tests/ert_util_spawn.c | 18 +- .../lib/util/tests/ert_util_stringlist_test.c | 52 + .../util/tests/ert_util_type_vector_test.c | 33 + ThirdParty/Ert/lib/util/util.c | 551 ++----- ThirdParty/Ert/lib/util/util_endian.c | 2 +- ThirdParty/Ert/lib/util/util_lockf.c | 2 +- ThirdParty/Ert/lib/util/util_spawn.c | 57 +- ThirdParty/Ert/lib/util/util_zlib.c | 2 +- ThirdParty/Ert/lib/util/vector.c | 2 +- ThirdParty/Ert/lib/util/vector_template.c | 93 +- ThirdParty/Ert/lib/vector_template.h.in | 51 +- ThirdParty/Ert/python/CMakeLists.txt | 19 +- .../python/cmake/Modules/init_python.cmake | 2 +- ThirdParty/Ert/python/doc/devel.txt | 8 +- ThirdParty/Ert/python/ecl/CMakeLists.txt | 18 + ThirdParty/Ert/python/ecl/__init__.py | 140 ++ .../Ert/python/ecl/ecl_lib_info_build.py.in | 9 + .../Ert/python/ecl/ecl_lib_info_install.py.in | 9 + ThirdParty/Ert/python/ecl/ecl_type.py | 184 +++ ThirdParty/Ert/python/ecl/ecl_util.py | 166 ++ .../Ert/python/ecl/eclfile/CMakeLists.txt | 14 + ThirdParty/Ert/python/ecl/eclfile/__init__.py | 45 + .../Ert/python/ecl/eclfile/ecl_3d_file.py | 41 + ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py | 239 +++ ThirdParty/Ert/python/ecl/eclfile/ecl_file.py | 721 +++++++++ .../Ert/python/ecl/eclfile/ecl_file_view.py | 200 +++ .../Ert/python/ecl/eclfile/ecl_init_file.py | 30 + ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py | 1245 +++++++++++++++ .../python/ecl/eclfile/ecl_restart_file.py | 159 ++ ThirdParty/Ert/python/ecl/eclfile/fortio.py | 211 +++ .../Ert/python/ecl/gravimetry/CMakeLists.txt | 9 + .../Ert/python/ecl/gravimetry/__init__.py | 28 + .../Ert/python/ecl/gravimetry/ecl_grav.py | 220 +++ .../python/ecl/gravimetry/ecl_grav_calc.py | 84 + .../python/ecl/gravimetry/ecl_subsidence.py | 144 ++ ThirdParty/Ert/python/ecl/grid/CMakeLists.txt | 11 + ThirdParty/Ert/python/ecl/grid/__init__.py | 35 + ThirdParty/Ert/python/ecl/grid/cell.py | 127 ++ ThirdParty/Ert/python/ecl/grid/ecl_grid.py | 1299 +++++++++++++++ .../Ert/python/ecl/grid/ecl_grid_generator.py | 710 +++++++++ ThirdParty/Ert/python/ecl/grid/ecl_region.py | 1062 +++++++++++++ .../Ert/python/ecl/grid/faults/CMakeLists.txt | 12 + .../Ert/python/ecl/grid/faults/__init__.py | 9 + .../Ert/python/ecl/grid/faults/fault.py | 656 ++++++++ .../Ert/python/ecl/grid/faults/fault_block.py | 190 +++ .../ecl/grid/faults/fault_block_collection.py | 84 + .../ecl/grid/faults/fault_block_layer.py | 236 +++ .../ecl/grid/faults/fault_collection.py | 135 ++ .../Ert/python/ecl/grid/faults/fault_line.py | 248 +++ .../python/ecl/grid/faults/fault_segments.py | 174 ++ .../Ert/python/ecl/grid/faults/layer.py | 275 ++++ ThirdParty/Ert/python/ecl/rft/CMakeLists.txt | 8 + ThirdParty/Ert/python/ecl/rft/__init__.py | 25 + ThirdParty/Ert/python/ecl/rft/ecl_rft.py | 356 +++++ ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py | 171 ++ .../Ert/python/ecl/rft/well_trajectory.py | 84 + .../Ert/python/ecl/summary/CMakeLists.txt | 14 + ThirdParty/Ert/python/ecl/summary/__init__.py | 35 + ThirdParty/Ert/python/ecl/summary/ecl_cmp.py | 184 +++ ThirdParty/Ert/python/ecl/summary/ecl_npv.py | 220 +++ .../Ert/python/ecl/summary/ecl_smspec_node.py | 196 +++ ThirdParty/Ert/python/ecl/summary/ecl_sum.py | 1393 +++++++++++++++++ .../ecl/summary/ecl_sum_keyword_vector.py | 77 + .../Ert/python/ecl/summary/ecl_sum_node.py | 28 + .../Ert/python/ecl/summary/ecl_sum_tstep.py | 92 ++ .../python/ecl/summary/ecl_sum_var_type.py | 56 + .../Ert/python/ecl/summary/ecl_sum_vector.py | 304 ++++ ThirdParty/Ert/python/ecl/util/CMakeLists.txt | 10 + ThirdParty/Ert/python/ecl/util/__init__.py | 0 .../Ert/python/ecl/util/enums/CMakeLists.txt | 8 + .../Ert/python/ecl/util/enums/__init__.py | 2 + .../ecl/util/enums/rng_alg_type_enum.py | 8 + .../ecl/util/enums/rng_init_mode_enum.py | 14 + .../python/ecl/util/geometry/CMakeLists.txt | 13 + .../Ert/python/ecl/util/geometry/__init__.py | 30 + .../Ert/python/ecl/util/geometry/cpolyline.py | 210 +++ .../ecl/util/geometry/cpolyline_collection.py | 121 ++ .../python/ecl/util/geometry/geo_pointset.py | 79 + .../python/ecl/util/geometry/geo_region.py | 121 ++ .../ecl/util/geometry/geometry_tools.py | 449 ++++++ .../Ert/python/ecl/util/geometry/polyline.py | 171 ++ .../Ert/python/ecl/util/geometry/surface.py | 293 ++++ .../Ert/python/ecl/util/geometry/xyz_io.py | 62 + .../Ert/python/ecl/util/test/CMakeLists.txt | 18 + .../Ert/python/ecl/util/test/__init__.py | 11 + .../Ert/python/ecl/util/test/debug_msg.py | 7 + .../ecl/util/test/ecl_mock/CMakeLists.txt | 6 + .../python/ecl/util/test/ecl_mock/__init__.py | 1 + .../ecl/util/test/ecl_mock/ecl_sum_mock.py | 50 + .../python/ecl/util/test/ert_test_context.py | 117 ++ .../python/ecl/util/test/ert_test_runner.py | 63 + .../python/ecl/util/test/extended_testcase.py | 191 +++ .../python/ecl/util/test/import_test_case.py | 55 + .../python/ecl/util/test/lint_test_case.py | 61 + .../Ert/python/ecl/util/test/path_context.py | 46 + .../python/ecl/util/test/source_enumerator.py | 39 + .../Ert/python/ecl/util/test/temp_area.py | 81 + .../Ert/python/ecl/util/test/test_area.py | 151 ++ .../Ert/python/ecl/util/test/test_run.py | 158 ++ .../Ert/python/ecl/util/util/CMakeLists.txt | 24 + .../Ert/python/ecl/util/util/__init__.py | 120 ++ .../Ert/python/ecl/util/util/arg_pack.py | 57 + .../Ert/python/ecl/util/util/bool_vector.py | 154 ++ .../Ert/python/ecl/util/util/cthread_pool.py | 88 ++ ThirdParty/Ert/python/ecl/util/util/ctime.py | 148 ++ .../Ert/python/ecl/util/util/cwd_context.py | 16 + .../Ert/python/ecl/util/util/double_vector.py | 77 + ThirdParty/Ert/python/ecl/util/util/hash.py | 134 ++ .../ecl/util/util/install_abort_signals.py | 16 + .../Ert/python/ecl/util/util/int_vector.py | 113 ++ .../Ert/python/ecl/util/util/lookup_table.py | 122 ++ ThirdParty/Ert/python/ecl/util/util/matrix.py | 230 +++ .../ecl/util/util/permutation_vector.py | 38 + ThirdParty/Ert/python/ecl/util/util/rng.py | 81 + .../Ert/python/ecl/util/util/stringlist.py | 308 ++++ .../Ert/python/ecl/util/util/thread_pool.py | 151 ++ .../Ert/python/ecl/util/util/time_vector.py | 177 +++ .../Ert/python/ecl/util/util/util_func.py | 54 + .../python/ecl/util/util/vector_template.py | 687 ++++++++ .../Ert/python/ecl/util/util/version.py | 118 ++ ThirdParty/Ert/python/ecl/well/CMakeLists.txt | 13 + ThirdParty/Ert/python/ecl/well/__init__.py | 13 + .../Ert/python/ecl/well/well_connection.py | 112 ++ .../well/well_connection_direction_enum.py | 15 + ThirdParty/Ert/python/ecl/well/well_info.py | 123 ++ .../Ert/python/ecl/well/well_segment.py | 76 + ThirdParty/Ert/python/ecl/well/well_state.py | 166 ++ .../Ert/python/ecl/well/well_time_line.py | 43 + .../Ert/python/ecl/well/well_type_enum.py | 16 + ThirdParty/Ert/python/ert/CMakeLists.txt | 11 + ThirdParty/Ert/python/ert/__init__.py | 4 + ThirdParty/Ert/python/ert/ecl/__init__.py | 26 + .../Ert/python/ert/ecl/faults/__init__.py | 7 + ThirdParty/Ert/python/ert/geo/__init__.py | 8 + ThirdParty/Ert/python/ert/test/__init__.py | 10 + ThirdParty/Ert/python/ert/util/__init__.py | 21 + ThirdParty/Ert/python/ert/well/__init__.py | 7 + ThirdParty/Ert/python/test_env.py.in | 6 + ThirdParty/Ert/python/tests/CMakeLists.txt | 22 +- ThirdParty/Ert/python/tests/__init__.py | 82 + .../Ert/python/tests/bin_tests/CMakeLists.txt | 8 + .../Ert/python/tests/bin_tests/__init__.py | 0 .../tests/bin_tests/test_summary_resample.py | 93 ++ .../Ert/python/tests/ecl_tests/CMakeLists.txt | 92 ++ .../Ert/python/tests/ecl_tests/__init__.py | 0 .../Ert/python/tests/ecl_tests/test_cell.py | 100 ++ .../Ert/python/tests/ecl_tests/test_debug.py | 25 + .../tests/ecl_tests/test_deprecation.py | 53 + .../python/tests/ecl_tests/test_ecl_3dkw.py | 204 +++ .../python/tests/ecl_tests/test_ecl_cmp.py | 70 + .../python/tests/ecl_tests/test_ecl_file.py | 256 +++ .../tests/ecl_tests/test_ecl_file_statoil.py | 275 ++++ .../tests/ecl_tests/test_ecl_init_file.py | 49 + .../Ert/python/tests/ecl_tests/test_ecl_kw.py | 614 ++++++++ .../tests/ecl_tests/test_ecl_kw_statoil.py | 114 ++ .../tests/ecl_tests/test_ecl_restart_file.py | 70 + .../python/tests/ecl_tests/test_ecl_sum.py | 147 ++ .../tests/ecl_tests/test_ecl_sum_tstep.py | 41 + .../tests/ecl_tests/test_ecl_sum_vector.py | 55 + .../python/tests/ecl_tests/test_ecl_type.py | 140 ++ .../python/tests/ecl_tests/test_ecl_util.py | 42 + .../tests/ecl_tests/test_fault_blocks.py | 482 ++++++ .../ecl_tests/test_fault_blocks_statoil.py | 46 + .../Ert/python/tests/ecl_tests/test_faults.py | 798 ++++++++++ .../tests/ecl_tests/test_fk_user_data.py | 49 + .../Ert/python/tests/ecl_tests/test_fortio.py | 142 ++ .../python/tests/ecl_tests/test_geertsma.py | 148 ++ .../Ert/python/tests/ecl_tests/test_grav.py | 29 + .../Ert/python/tests/ecl_tests/test_grdecl.py | 125 ++ .../Ert/python/tests/ecl_tests/test_grid.py | 592 +++++++ .../tests/ecl_tests/test_grid_generator.py | 280 ++++ .../tests/ecl_tests/test_grid_statoil.py | 417 +++++ .../tests/ecl_tests/test_indexed_read.py | 118 ++ .../tests/ecl_tests/test_kw_function.py | 79 + .../Ert/python/tests/ecl_tests/test_layer.py | 307 ++++ .../Ert/python/tests/ecl_tests/test_npv.py | 195 +++ .../Ert/python/tests/ecl_tests/test_region.py | 91 ++ .../tests/ecl_tests/test_region_statoil.py | 207 +++ .../python/tests/ecl_tests/test_removed.py | 36 + .../python/tests/ecl_tests/test_restart.py | 129 ++ .../tests/ecl_tests/test_restart_head.py | 44 + .../Ert/python/tests/ecl_tests/test_rft.py | 36 + .../python/tests/ecl_tests/test_rft_cell.py | 95 ++ .../tests/ecl_tests/test_rft_statoil.py | 142 ++ .../tests/ecl_tests/test_statoil_faults.py | 132 ++ .../Ert/python/tests/ecl_tests/test_sum.py | 488 ++++++ .../tests/ecl_tests/test_sum_statoil.py | 532 +++++++ .../tests/geometry_tests/CMakeLists.txt | 28 + .../python/tests/geometry_tests/__init__.py | 0 .../tests/geometry_tests/test_convex_hull.py | 27 + .../tests/geometry_tests/test_cpolyline.py | 172 ++ .../test_cpolyline_collection.py | 134 ++ .../tests/geometry_tests/test_geo_pointset.py | 28 + .../tests/geometry_tests/test_geo_region.py | 89 ++ .../geometry_tests/test_geometry_tools.py | 81 + .../tests/geometry_tests/test_intersection.py | 47 + .../geometry_tests/test_point_in_polygon.py | 60 + .../geometry_tests/test_polygon_slicing.py | 139 ++ .../tests/geometry_tests/test_polyline.py | 194 +++ .../tests/geometry_tests/test_surface.py | 211 +++ .../python/tests/global_tests/CMakeLists.txt | 12 + .../Ert/python/tests/global_tests/__init__.py | 0 .../python/tests/global_tests/test_import.py | 26 + .../python/tests/global_tests/test_pylint.py | 45 + .../tests/install_tests/test_install.py | 14 + .../python/tests/legacy_tests/CMakeLists.txt | 16 + .../Ert/python/tests/legacy_tests/__init__.py | 0 .../Ert/python/tests/legacy_tests/test_ecl.py | 42 + .../Ert/python/tests/legacy_tests/test_geo.py | 14 + .../python/tests/legacy_tests/test_test.py | 15 + .../python/tests/legacy_tests/test_util.py | 31 + .../python/tests/legacy_tests/test_well.py | 13 + ThirdParty/Ert/python/tests/test_install.in | 2 +- .../python/tests/util_tests/CMakeLists.txt | 32 + .../Ert/python/tests/util_tests/__init__.py | 0 .../python/tests/util_tests/test_arg_pack.py | 36 + .../Ert/python/tests/util_tests/test_ctime.py | 131 ++ .../Ert/python/tests/util_tests/test_hash.py | 68 + .../tests/util_tests/test_lookup_table.py | 88 ++ .../tests/util_tests/test_path_context.py | 50 + .../Ert/python/tests/util_tests/test_rng.py | 46 + .../Ert/python/tests/util_tests/test_spawn.py | 64 + .../tests/util_tests/test_string_list.py | 159 ++ .../tests/util_tests/test_thread_pool.py | 101 ++ .../python/tests/util_tests/test_vectors.py | 576 +++++++ .../python/tests/util_tests/test_version.py | 110 ++ .../python/tests/util_tests/test_work_area.py | 125 ++ .../python/tests/well_tests/CMakeLists.txt | 12 + .../Ert/python/tests/well_tests/__init__.py | 0 .../python/tests/well_tests/test_ecl_well.py | 448 ++++++ .../python/tests/well_tests/test_ecl_well2.py | 45 + .../python/tests/well_tests/test_ecl_well3.py | 50 + ThirdParty/Ert/redhat/ecl.spec | 101 ++ ThirdParty/Ert/requirements.txt | 2 + ThirdParty/Ert/test-data/local/nexus/SPE1.plt | Bin 43012 -> 43012 bytes .../local/nexus/SPE1_delayedWell.plt | Bin 0 -> 50836 bytes 306 files changed, 32636 insertions(+), 1425 deletions(-) create mode 100644 ThirdParty/Ert/bin/CMakeLists.txt create mode 100644 ThirdParty/Ert/bin/summary_resample create mode 100644 ThirdParty/Ert/debian/python-cwrap.install create mode 100644 ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c create mode 100644 ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c create mode 100644 ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c create mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c create mode 100644 ThirdParty/Ert/python/ecl/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in create mode 100644 ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in create mode 100644 ThirdParty/Ert/python/ecl/ecl_type.py create mode 100644 ThirdParty/Ert/python/ecl/ecl_util.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/eclfile/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_file.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py create mode 100644 ThirdParty/Ert/python/ecl/eclfile/fortio.py create mode 100644 ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/gravimetry/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py create mode 100644 ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py create mode 100644 ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py create mode 100644 ThirdParty/Ert/python/ecl/grid/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/grid/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/grid/cell.py create mode 100644 ThirdParty/Ert/python/ecl/grid/ecl_grid.py create mode 100644 ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py create mode 100644 ThirdParty/Ert/python/ecl/grid/ecl_region.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_block.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_line.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py create mode 100644 ThirdParty/Ert/python/ecl/grid/faults/layer.py create mode 100644 ThirdParty/Ert/python/ecl/rft/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/rft/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/rft/ecl_rft.py create mode 100644 ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py create mode 100644 ThirdParty/Ert/python/ecl/rft/well_trajectory.py create mode 100644 ThirdParty/Ert/python/ecl/summary/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/summary/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_cmp.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_npv.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py create mode 100644 ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/enums/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py create mode 100644 ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/geo_region.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/polyline.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/surface.py create mode 100644 ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/test/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/debug_msg.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/ert_test_context.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/extended_testcase.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/import_test_case.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/lint_test_case.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/path_context.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/source_enumerator.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/temp_area.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/test_area.py create mode 100644 ThirdParty/Ert/python/ecl/util/test/test_run.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/util/util/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/arg_pack.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/bool_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/cthread_pool.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/ctime.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/cwd_context.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/double_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/hash.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/int_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/lookup_table.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/matrix.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/permutation_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/rng.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/stringlist.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/thread_pool.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/time_vector.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/util_func.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/vector_template.py create mode 100644 ThirdParty/Ert/python/ecl/util/util/version.py create mode 100644 ThirdParty/Ert/python/ecl/well/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ecl/well/__init__.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_connection.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_info.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_segment.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_state.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_time_line.py create mode 100644 ThirdParty/Ert/python/ecl/well/well_type_enum.py create mode 100644 ThirdParty/Ert/python/ert/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/ert/__init__.py create mode 100644 ThirdParty/Ert/python/ert/ecl/__init__.py create mode 100644 ThirdParty/Ert/python/ert/ecl/faults/__init__.py create mode 100644 ThirdParty/Ert/python/ert/geo/__init__.py create mode 100644 ThirdParty/Ert/python/ert/test/__init__.py create mode 100644 ThirdParty/Ert/python/ert/util/__init__.py create mode 100644 ThirdParty/Ert/python/ert/well/__init__.py create mode 100644 ThirdParty/Ert/python/test_env.py.in create mode 100644 ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/bin_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_cell.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_debug.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_faults.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grav.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grid.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_layer.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_npv.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_region.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_removed.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_restart.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_rft.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_sum.py create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py create mode 100644 ThirdParty/Ert/python/tests/geometry_tests/test_surface.py create mode 100644 ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/global_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/global_tests/test_import.py create mode 100644 ThirdParty/Ert/python/tests/global_tests/test_pylint.py create mode 100644 ThirdParty/Ert/python/tests/install_tests/test_install.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/test_geo.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/test_test.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/test_util.py create mode 100644 ThirdParty/Ert/python/tests/legacy_tests/test_well.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/util_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_ctime.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_hash.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_path_context.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_rng.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_spawn.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_string_list.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_vectors.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_version.py create mode 100644 ThirdParty/Ert/python/tests/util_tests/test_work_area.py create mode 100644 ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/python/tests/well_tests/__init__.py create mode 100644 ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py create mode 100644 ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py create mode 100644 ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py create mode 100644 ThirdParty/Ert/redhat/ecl.spec create mode 100644 ThirdParty/Ert/requirements.txt create mode 100644 ThirdParty/Ert/test-data/local/nexus/SPE1_delayedWell.plt diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 1c88a04720..433acc85d3 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -16,7 +16,7 @@ set(RESINSIGHT_DEV_VERSION ".107") set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") # https://github.com/Statoil/libecl -set(ERT_GITHUB_SHA "2e36798b43daf18c112b91aa3febbf2fccd4a95f") +set(ECL_GITHUB_SHA "f3e2954101d06fd21c952fb4f039201f20a623de") # https://github.com/OPM/opm-flowdiagnostics set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f") diff --git a/ThirdParty/Ert/.travis.yml b/ThirdParty/Ert/.travis.yml index 06dc0a0217..78fa0c189b 100644 --- a/ThirdParty/Ert/.travis.yml +++ b/ThirdParty/Ert/.travis.yml @@ -15,6 +15,7 @@ dist: trusty env: global: - ERT_SHOW_BACKTRACE=1 + - LD_LIBRARY_PATH="$(pwd)/install/lib64" matrix: - PYTHON_VERSION=2.7 TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow - PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1 @@ -65,10 +66,12 @@ install: - export CONDA_HOME="$HOME/miniconda" - export PATH="$CONDA_HOME/bin:$PATH" - hash -r + - pip install -r requirements.txt - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a # Useful for debugging any issues with conda - - conda install pylint numpy pandas + - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/install_python_packages.py + - python install_python_packages.py before_script: - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/build_total.py diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 73fb3b30db..4fc4cc86d7 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -45,8 +45,8 @@ endif() option( BUILD_TESTS "Should the tests be built" OFF) option( BUILD_APPLICATIONS "Should we build small utility applications" OFF) option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF) -option( BUILD_NEXUS "Build support for the Nexus simulator" ON) option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF) +option( ENABLE_PYTHON "Build and install the Python wrappers" OFF) option( BUILD_SHARED_LIBS "Build shared libraries" ON ) option( ERT_USE_OPENMP "Use OpenMP" OFF ) option( RST_DOC "Build RST documentation" OFF) @@ -54,7 +54,6 @@ option( ERT_BUILD_CXX "Build some CXX wrappers" option( USE_RPATH "Don't strip RPATH from libraries and binaries" OFF) option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF) - set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata") if (EXISTS ${STATOIL_TESTDATA_ROOT}) set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" ) @@ -71,6 +70,11 @@ if (EXISTS ${STATOIL_TESTDATA_ROOT}) endif() +if (BUILD_PYTHON) + set(ENABLE_PYTHON ON) + message(WARNING "The option 'BUILD_PYTHON' is deprecated - use ENABLE_PYTHON.") +endif() + # output libs to some lib/ path for testing set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) @@ -176,18 +180,6 @@ if(M_LIBRARY) set(m m) endif () -find_package(BLAS) -if (BLAS_FOUND) - set(blas "${BLAS_LIBRARIES}") -endif () - -set(ERT_HAVE_LAPACK OFF) -find_package(LAPACK) -if (LAPACK_FOUND) - set(ERT_HAVE_LAPACK ON) - list(APPEND lapack ${LAPACK_LIBRARIES} ${LAPACK_LINKER_FLAGS}) -endif() - find_package(ZLIB) if (ZLIB_FOUND) set(ERT_HAVE_ZLIB ON) @@ -199,6 +191,11 @@ if (SHLWAPI_LIBRARY) set(shlwapi ${SHLWAPI_LIBRARY}) endif () +find_library(WS2_32_LIBRARY NAMES Ws2_32) +if (WS2_32_LIBRARY) + set(ws2_32 ${WS2_32_LIBRARY}) +endif () + #----------------------------------------------------------------- # feature tests @@ -207,6 +204,8 @@ include(CheckIncludeFile) include(CheckSymbolExists) include(CheckTypeSize) +check_function_exists( access HAVE_POSIX_ACCESS) +check_function_exists( _access HAVE_WINDOWS__ACCESS) check_function_exists( chdir HAVE_POSIX_CHDIR ) check_function_exists( _chdir HAVE_WINDOWS_CHDIR ) check_function_exists( chmod HAVE_CHMOD ) @@ -235,7 +234,6 @@ check_function_exists( readlinkat ERT_HAVE_READLINKAT ) check_function_exists( realpath HAVE_REALPATH ) check_function_exists( regexec ERT_HAVE_REGEXP ) check_function_exists( round HAVE_ROUND ) -check_function_exists( setenv HAVE_POSIX_SETENV ) check_function_exists( symlink ERT_HAVE_SYMLINK ) check_function_exists( timegm HAVE_TIMEGM ) check_function_exists( usleep HAVE__USLEEP ) @@ -287,10 +285,6 @@ if (ERT_WINDOWS) endif() endif() -find_program(PING_PATH NAMES ping) -if (PING_PATH) - set(ERT_HAVE_PING ON) -endif() find_package(Git) if(GIT_FOUND) @@ -330,7 +324,7 @@ endif() if (ERT_WINDOWS) message(WARNING "Python is not supported on Windows") - set( BUILD_PYTHON OFF ) + set( ENABLE_PYTHON OFF ) endif () if (ERT_LINUX) @@ -339,15 +333,15 @@ endif() add_subdirectory( lib ) add_subdirectory( applications ) +add_subdirectory( bin ) - -if (BUILD_PYTHON) +if (ENABLE_PYTHON) if (ERT_WINDOWS) message(WARNING "Python is not supported on Windows") - set( BUILD_PYTHON OFF ) + set( ENABLE_PYTHON OFF ) else() # If finding the Python interpreter and required packages - # fails in the python/CMakeLists.txt file the BUILD_PYTHON + # fails in the python/CMakeLists.txt file the ENABLE_PYTHON # will be set to OFF. add_subdirectory( python ) @@ -357,15 +351,12 @@ if (BUILD_PYTHON) endif() endif() -if (BUILD_PYTHON) +if (ENABLE_PYTHON) if (NOT ${BUILD_SHARED_LIBS}) message(FATAL_ERROR "The Python wrappers require shared libraries") endif() endif() -if (INSTALL_ERT) - install(EXPORT ecl-config DESTINATION share/cmake/ecl) -endif() - +install(EXPORT ecl-config DESTINATION share/cmake/ecl) export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/applications/CMakeLists.txt b/ThirdParty/Ert/applications/CMakeLists.txt index 318197a204..1000455f91 100644 --- a/ThirdParty/Ert/applications/CMakeLists.txt +++ b/ThirdParty/Ert/applications/CMakeLists.txt @@ -10,6 +10,7 @@ if (BUILD_APPLICATIONS) target_link_libraries(grdecl_grid ecl) target_link_libraries(summary ecl) + list(APPEND apps make_grid grdecl_grid summary) foreach (app ecl_pack diff --git a/ThirdParty/Ert/applications/ecl/ecl_pack.c b/ThirdParty/Ert/applications/ecl/ecl_pack.c index 34ae853cda..ad6822c0ad 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_pack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_pack.c @@ -1,30 +1,29 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 #include #include -#include #include #include -#include +#include #include @@ -50,7 +49,7 @@ int main(int argc, char ** argv) { } util_alloc_file_components( argv[1] , &path , &ecl_base , NULL); - + /** Will pack to cwd, even though the source files might be somewhere else. To unpack to the same directory as the source @@ -59,7 +58,6 @@ int main(int argc, char ** argv) { */ { - msg_type * msg; int i , report_step , prev_report_step; char * target_file_name = ecl_util_alloc_filename( NULL , ecl_base , target_type , fmt_file , -1); stringlist_type * filelist = stringlist_alloc_argv_copy( (const char **) &argv[1] , num_files ); @@ -69,16 +67,8 @@ int main(int argc, char ** argv) { if (target_type == ECL_UNIFIED_RESTART_FILE) { int dummy; seqnum_kw = ecl_kw_alloc_new("SEQNUM" , 1 , ECL_INT , &dummy); - } - - { - char * msg_format = util_alloc_sprintf("Packing %s <= " , target_file_name); - msg = msg_alloc( msg_format , false); - free( msg_format ); } - - msg_show( msg ); stringlist_sort( filelist , ecl_util_fname_report_cmp); prev_report_step = -1; for (i=0; i < num_files; i++) { @@ -87,11 +77,10 @@ int main(int argc, char ** argv) { if (this_file_type == file_type) { if (report_step == prev_report_step) util_exit("Tried to write same report step twice: %s / %s \n", - stringlist_iget(filelist , i-1) , + stringlist_iget(filelist , i-1) , stringlist_iget(filelist , i)); prev_report_step = report_step; - msg_update(msg , stringlist_iget( filelist , i)); { ecl_file_type * src_file = ecl_file_open( stringlist_iget( filelist , i) , 0 ); if (target_type == ECL_UNIFIED_RESTART_FILE) { @@ -104,7 +93,6 @@ int main(int argc, char ** argv) { } } /* Else skipping file of incorrect type. */ } - msg_free(msg , false); fortio_fclose( target ); free(target_file_name); stringlist_free( filelist ); @@ -114,4 +102,4 @@ int main(int argc, char ** argv) { util_safe_free(path); } } - + diff --git a/ThirdParty/Ert/applications/ecl/ecl_unpack.c b/ThirdParty/Ert/applications/ecl/ecl_unpack.c index 71c6f3492d..58f9cde244 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_unpack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_unpack.c @@ -1,25 +1,24 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 #include -#include #include #include @@ -36,9 +35,9 @@ void unpack_file(const char * filename) { target_type = ECL_SUMMARY_FILE; else if (file_type == ECL_UNIFIED_RESTART_FILE) target_type = ECL_RESTART_FILE; - else + else util_exit("Can only unpack unified ECLIPSE summary and restart files\n"); - + if (target_type == ECL_SUMMARY_FILE) { printf("** Warning: when unpacking unified summary files it as ambigous - starting with 0001 -> \n"); } @@ -48,23 +47,16 @@ void unpack_file(const char * filename) { int offset; int report_step = 0; int block_index = 0; - char * path; + char * path; char * base; - msg_type * msg; util_alloc_file_components( filename , &path , &base , NULL); - { - char * label = util_alloc_sprintf("Unpacking %s => ", filename); - msg = msg_alloc( label , false); - free( label ); - } - msg_show(msg); - if (target_type == ECL_SUMMARY_FILE) + if (target_type == ECL_SUMMARY_FILE) size = ecl_file_get_num_named_kw( src_file , "SEQHDR" ); else size = ecl_file_get_num_named_kw( src_file , "SEQNUM" ); - - + + while (true) { ecl_file_view_type * active_view; @@ -89,22 +81,20 @@ void unpack_file(const char * filename) { files, just send in @path as first argument when creating the target_file. */ - + { char * target_file = ecl_util_alloc_filename( NULL , base , target_type , fmt_file , report_step); fortio_type * fortio_target = fortio_open_writer( target_file , fmt_file , ECL_ENDIAN_FLIP ); - msg_update(msg , target_file); ecl_file_view_fwrite( active_view , fortio_target , offset); - + fortio_fclose(fortio_target); free(target_file); } block_index++; - } + } ecl_file_close( src_file ); util_safe_free(path); free(base); - msg_free(msg , true); } } diff --git a/ThirdParty/Ert/applications/ecl/kw_extract.c b/ThirdParty/Ert/applications/ecl/kw_extract.c index a578b5abfa..165ad67f7d 100644 --- a/ThirdParty/Ert/applications/ecl/kw_extract.c +++ b/ThirdParty/Ert/applications/ecl/kw_extract.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -54,10 +53,10 @@ int main(int argc, char ** argv) { fortio_type * fortio_target; bool fmt_src , fmt_target; set_type * kw_set = set_alloc( num_kw , kw_list ); - + if (!ecl_util_fmt_file(src_file, &fmt_src)) util_exit("Hmm - could not determine formatted/unformatted status for:%s \n",src_file); - + fmt_target = fmt_src; /* Can in principle be different */ fortio_src = fortio_open_reader(src_file , fmt_src , ECL_ENDIAN_FLIP); fortio_target = fortio_open_writer(target_file , fmt_target , ECL_ENDIAN_FLIP); @@ -66,18 +65,18 @@ int main(int argc, char ** argv) { ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); while (true) { if (ecl_kw_fread_header( ecl_kw , fortio_src ) == ECL_KW_READ_OK) { - const char * header = ecl_kw_get_header( ecl_kw ); + const char * header = ecl_kw_get_header( ecl_kw ); if (set_has_key( kw_set , header )) { ecl_kw_fread_realloc_data(ecl_kw , fortio_src ); ecl_kw_fwrite( ecl_kw , fortio_target ); } else ecl_kw_fskip_data( ecl_kw , fortio_src ); - } else + } else break; /* We have reached EOF */ } ecl_kw_free( ecl_kw ); } - + fortio_fclose(fortio_src); fortio_fclose(fortio_target); set_free( kw_set ); diff --git a/ThirdParty/Ert/appveyor.yml b/ThirdParty/Ert/appveyor.yml index 574be1fff7..78604583b0 100644 --- a/ThirdParty/Ert/appveyor.yml +++ b/ThirdParty/Ert/appveyor.yml @@ -6,7 +6,7 @@ build_script: cd build - cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DERT_BUILD_CXX=OFF -DBUILD_PYTHON=OFF -DBUILD_APPLICATIONS=ON + cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DERT_BUILD_CXX=OFF -DENABLE_PYTHON=OFF -DBUILD_APPLICATIONS=ON msbuild /m /p:Configuration=Release /p:Platform="x64" ERT.sln diff --git a/ThirdParty/Ert/bin/CMakeLists.txt b/ThirdParty/Ert/bin/CMakeLists.txt new file mode 100644 index 0000000000..528b7fd216 --- /dev/null +++ b/ThirdParty/Ert/bin/CMakeLists.txt @@ -0,0 +1,3 @@ +if (ENABLE_PYTHON) + install(PROGRAMS summary_resample DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +endif() diff --git a/ThirdParty/Ert/bin/summary_resample b/ThirdParty/Ert/bin/summary_resample new file mode 100644 index 0000000000..eb6cf5521f --- /dev/null +++ b/ThirdParty/Ert/bin/summary_resample @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import sys +import argparse +from ecl.summary import EclSum +from ecl.util.util import TimeVector, CTime + + + +parser = argparse.ArgumentParser() +parser.add_argument("input_case", metavar="input_case", type=str) +parser.add_argument("output_case", metavar="output_case", type=str) +parser.add_argument("--num-timestep", type=int, default=50) +parser.add_argument("--refcase", metavar="refcase", type=str) +args = parser.parse_args() + +input_case = EclSum(args.input_case) +if args.refcase: + refcase = EclSum(args.refcase) + report_only = False + time_points = refcase.alloc_time_vector( report_only ) +else: + start_time = input_case.get_data_start_time() + end_time = input_case.get_end_time() + time_points = TimeVector.create_linear(CTime(start_time), CTime(end_time), args.num_timestep) + +output_case = input_case.resample(args.output_case, time_points) +output_case.fwrite( ) diff --git a/ThirdParty/Ert/cmake/libecl-config-version.cmake.in b/ThirdParty/Ert/cmake/libecl-config-version.cmake.in index 3a8e633c45..2f8df5a4e8 100644 --- a/ThirdParty/Ert/cmake/libecl-config-version.cmake.in +++ b/ThirdParty/Ert/cmake/libecl-config-version.cmake.in @@ -9,6 +9,6 @@ link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) include_directories( @CMAKE_INSTALL_PREFIX@/include ) set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE_PATH}) -if (@BUILD_PYTHON@) +if (@ENABLE_PYTHON@) set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ ) -endif() \ No newline at end of file +endif() diff --git a/ThirdParty/Ert/cmake/libecl-config.cmake.in b/ThirdParty/Ert/cmake/libecl-config.cmake.in index 318a35c20b..bf718e2e23 100644 --- a/ThirdParty/Ert/cmake/libecl-config.cmake.in +++ b/ThirdParty/Ert/cmake/libecl-config.cmake.in @@ -5,6 +5,6 @@ set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) include_directories( @CMAKE_INSTALL_PREFIX@/include ) -if (@BUILD_PYTHON@) +if (@ENABLE_PYTHON@) set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ ) -endif() \ No newline at end of file +endif() diff --git a/ThirdParty/Ert/debian/control b/ThirdParty/Ert/debian/control index e91d5b83d0..f1cee7a739 100644 --- a/ThirdParty/Ert/debian/control +++ b/ThirdParty/Ert/debian/control @@ -2,7 +2,7 @@ Source: ecl Priority: extra Maintainer: Arne Morten Kvarving Build-Depends: debhelper (>= 8.0.0), cmake, liblapack-dev, libquadmath0, - iputils-ping, zlib1g-dev, git, python-dev, python-numpy + iputils-ping, zlib1g-dev, git, python-dev, python-numpy, python-cwrap Standards-Version: 3.9.2 Section: libs Homepage: http://ert.nr.no @@ -26,6 +26,6 @@ Description: libecl Eclipse IO library Package: python-ecl Section: python Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libert.ecl1, python-cwrap +Depends: ${shlibs:Depends}, ${misc:Depends}, libecl1, python-cwrap Description: libecl Eclipse IO library - Python bindings libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. diff --git a/ThirdParty/Ert/debian/python-cwrap.install b/ThirdParty/Ert/debian/python-cwrap.install new file mode 100644 index 0000000000..4712e62110 --- /dev/null +++ b/ThirdParty/Ert/debian/python-cwrap.install @@ -0,0 +1 @@ +usr/lib/python2.7/*/cwrap/* diff --git a/ThirdParty/Ert/debian/rules b/ThirdParty/Ert/debian/rules index 7e2e104ef3..a2fd90c353 100644 --- a/ThirdParty/Ert/debian/rules +++ b/ThirdParty/Ert/debian/rules @@ -13,4 +13,4 @@ dh $@ override_dh_auto_configure: - DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DBUILD_PYTHON=1 -DCMAKE_BUILD_TYPE=Release + DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DENABLE_PYTHON=1 -DCMAKE_BUILD_TYPE=Release diff --git a/ThirdParty/Ert/docs/CMakeLists.txt b/ThirdParty/Ert/docs/CMakeLists.txt index 117c4af359..833ce3a56e 100644 --- a/ThirdParty/Ert/docs/CMakeLists.txt +++ b/ThirdParty/Ert/docs/CMakeLists.txt @@ -17,7 +17,7 @@ if (SPHINX_FOUND) configure_file(index.rst.in ${PROJECT_BINARY_DIR}/doc-src/index.rst) configure_file(conf.py.in ${PROJECT_BINARY_DIR}/doc-src/conf.py) - if (BUILD_PYTHON) + if (ENABLE_PYTHON) add_custom_target(api-doc ALL COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/doc-src/code" COMMAND sphinx-apidoc -e -o doc-src/API/python/ecl ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} diff --git a/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst b/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst index 2d6b93d97b..90946c557e 100644 --- a/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst +++ b/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst @@ -851,9 +851,9 @@ ministep sequence, but there will never be holes in this range. It is closely coupled to the simulator timestep and what the user of ECLIPSE has chosen to store, so no further meaning should be attached to these indices. Ultimately all lookups will be based on :code:`time_index`; in the C -code it is therefor often denoted :code:`internal_index`. +code it is therefore often denoted :code:`internal_index`. -ministep +ministep ,,,,,,,,, Each simulator timestep corresponds to one ministep, but an arbitrary diff --git a/ThirdParty/Ert/docs/nexus.plt b/ThirdParty/Ert/docs/nexus.plt index ec183b8dd8..88b482631b 100644 --- a/ThirdParty/Ert/docs/nexus.plt +++ b/ThirdParty/Ert/docs/nexus.plt @@ -20,14 +20,13 @@ for c in classes: for v in vars[c]: 4*b : The variable names 8*b : Skipped -4*b : Skipped ----> : This is the position of first timestep while classname != STOP: 8*b : classname 8*b : skipped - f : timestep (will cast to int) + f : timestep (cast to int) f : time f : num_items (cast to int) f : max_items (cast to int) @@ -49,3 +48,4 @@ while classname != STOP: 8*b : skipped 72*b : skipped var_in_class*f : The real data + 8*b : skipped diff --git a/ThirdParty/Ert/docs/tips.txt b/ThirdParty/Ert/docs/tips.txt index 6ed9b68ab7..d6bf3c18dc 100644 --- a/ThirdParty/Ert/docs/tips.txt +++ b/ThirdParty/Ert/docs/tips.txt @@ -94,7 +94,7 @@ it. In the configuration file both GEN_DATA and GEN_PARAM can be used: GEN_PARAM: For parameters which are not changed by the forward model, i.e. like porosity and permeability. - GEN_DATA: Data which is changed by the forward model, and therefor + GEN_DATA: Data which is changed by the forward model, and therefore must be loaded at the end of each timestep. The arch-typical example of a GEN_DATA instance would be seismic data. @@ -436,14 +436,14 @@ The block_fs driver is based on creating block_fs instances (block_fs_type is implemented in libutil/src/block_fs.c). The block_fs instances are binary files which are open through the duration of the program, the block_fs system then has an api for reading and writing -(key,value) pairs to this file. +(key,value) pairs to this file. The block_fs_driver/block_fs combination is quite complex, but it has not had any hickups for about 1.5 years of extensive use in Statoil. Observe that if you pull the plug on ERT you might loose some of the data which has been stored with the block_fs driver, but partly written and malformed data will be detected and discarded at the next -boot. You are therefor guaranteed (add as many quotes you like to the +boot. You are therefore guaranteed (add as many quotes you like to the guarantee - but this has at least worked 100% up until now) that no bogus data will be loaded after an unclean shutdown. When shut down cleanly the block_fs will create an index file which can be used for @@ -551,7 +551,7 @@ SConstruct files: Unfortunately it has been a major pain in the ass to get SCons to behave according to the requirements listed above; for the more -extensive installation procedures there are therefor simple Python +extensive installation procedures there are therefore simple Python scripts "install.py" which should be invoked after the SCons build is complete. diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index 2b91ee17fc..eb7388ca06 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -1,20 +1,6 @@ project(libecl-ecl C CXX) -if (HAVE_PTHREAD) - # The block_fs filesystem is so heavily dependant on pthreads that it is - # not built if de not have pthreads. - list(APPEND opt_srcs util/thread_pool.c) -endif () -if (LAPACK_FOUND) - list(APPEND opt_srcs util/matrix_lapack.c - util/matrix_blas.c - util/matrix_stat.c - util/regression.c - util/lars.c - util/stepwise.c -) -endif () if (HAVE_BACKTRACE) list(APPEND opt_srcs util/util_abort_gnu.c) @@ -71,13 +57,9 @@ if (ERT_BUILD_CXX) ecl/FortIO.cpp ecl/Smspec.cpp ecl/EclFilename.cpp - nexus/nexus_plot.cpp ) endif () -if (BUILD_NEXUS) - list(APPEND opt_srcs nexus/nexus_plot.cpp) -endif () configure_file(build_config.h.in include/ert/util/build_config.h) configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h) @@ -93,26 +75,18 @@ add_library(ecl util/rng.c util/node_data.c util/node_ctype.c util/util.c - util/util_env.c util/util_symlink.c util/util_lfs.c util/util_unlink.c - util/msg.c util/arg_pack.c - util/path_fmt.c - util/menu.c - util/subst_func.c util/vector.c util/parser.c util/stringlist.c - util/matrix.c util/buffer.c - util/log.c util/timer.c util/time_interval.c util/string_util.c util/type_vector_functions.c - util/ui_return.c util/ecl_version.c util/struct_vector.c util/perm_vector.c @@ -182,9 +156,9 @@ target_link_libraries(ecl PUBLIC ${m} ${dl} ${pthread} ${blas} - ${lapack} ${zlib} ${shlwapi} + ${ws2_32} ) target_include_directories(ecl @@ -207,9 +181,6 @@ target_compile_definitions(ecl PRIVATE target_compile_options(ecl PUBLIC ${pthreadarg}) -if (PING_PATH) - target_compile_definitions(ecl PRIVATE -DPING_CMD=${PING_PATH}) -endif() if (ERT_USE_OPENMP) target_compile_options(ecl PUBLIC ${OpenMP_C_FLAGS}) @@ -220,7 +191,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) -if (INSTALL_ERT) + install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -245,7 +216,6 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () -endif() if (NOT BUILD_TESTS) return () @@ -261,10 +231,7 @@ foreach (name ert_util_alloc_file_components ert_util_chdir ert_util_filename ert_util_hash_test - ert_util_logh - ert_util_matrix ert_util_parent_path - ert_util_PATH_test ert_util_realpath ert_util_relpath_test ert_util_rng @@ -277,9 +244,9 @@ foreach (name ert_util_alloc_file_components ert_util_strstr_int_format ert_util_time_interval ert_util_type_vector_functions - ert_util_ui_return ert_util_vector_test ert_util_datetime + ert_util_normal_path ) add_executable(${name} util/tests/${name}.c) @@ -301,15 +268,6 @@ add_test(NAME ert_util_work_area WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/util/tests ) -find_library( VALGRIND NAMES valgr ) -if (VALGRIND) - set(valgrind_cmd valgrind --error-exitcode=1 --tool=memcheck) -endif () - -add_executable(test_thread_pool util/tests/test_thread_pool.c) -target_link_libraries(test_thread_pool ecl) -add_test(NAME test_thread_pool COMMAND ${valgrind_cmd} test_thread_pool) - add_executable(ert_util_cwd_test util/tests/ert_util_cwd_test.c) target_link_libraries(ert_util_cwd_test ecl) add_test(NAME ert_util_cwd_test COMMAND ert_util_cwd_test ${CMAKE_CURRENT_BINARY_DIR}) @@ -329,15 +287,6 @@ target_link_libraries(ert_util_path_stack_test ecl) add_test(NAME ert_util_path_stack_test COMMAND ert_util_path_stack_test ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -if (LAPACK_FOUND) - add_executable(ert_util_matrix_lapack util/tests/ert_util_matrix_lapack.c) - target_link_libraries(ert_util_matrix_lapack ecl) - add_test(NAME ert_util_matrix_lapack COMMAND ert_util_matrix_lapack) - - add_executable(ert_util_matrix_stat util/tests/ert_util_matrix_stat.c) - target_link_libraries(ert_util_matrix_stat ecl) - add_test(NAME ert_util_matrix_stat COMMAND ert_util_matrix_stat) -endif() if (HAVE_BACKTRACE) add_executable(ert_util_abort_gnu_tests util/tests/ert_util_abort_gnu_tests.c) @@ -372,6 +321,7 @@ endif() foreach (name ecl_alloc_cpgrid ecl_alloc_grid_dxv_dyv_dzv ecl_fault_block_layer + ecl_util_path_access ecl_grid_add_nnc ecl_grid_copy ecl_grid_create @@ -389,11 +339,13 @@ foreach (name ecl_alloc_cpgrid ecl_nnc_info_test ecl_nnc_vector ecl_rft_cell + ecl_sum_alloc_resampled_test ecl_file_view test_ecl_file_index test_transactions ecl_rst_file ecl_sum_writer + ecl_util_filenames ecl_util_make_date_no_shift ecl_util_month_range ecl_valid_basename @@ -467,14 +419,6 @@ if (ERT_BUILD_CXX) endforeach () endif () -if (BUILD_NEXUS) - foreach (name nexus_plot_load nexus2ecl) - add_executable(${name} nexus/tests/${name}.cpp) - target_link_libraries(${name} ecl) - add_test(NAME ${name} COMMAND ${name} ${CMAKE_SOURCE_DIR}) - endforeach () -endif() - if (NOT STATOIL_TESTDATA_ROOT) return () @@ -484,12 +428,6 @@ endif() # ecl # -if (PING_PATH) - add_executable(ert_util_ping util/tests/ert_util_ping.c) - target_link_libraries(ert_util_ping ecl) - add_test(NAME ert_util_ping COMMAND ert_util_ping) -endif () - add_executable(ecl_coarse_test ecl/tests/ecl_coarse_test.c) target_link_libraries(ecl_coarse_test ecl) diff --git a/ThirdParty/Ert/lib/build_config.h.in b/ThirdParty/Ert/lib/build_config.h.in index d468d27d13..2c4c6aa5fb 100644 --- a/ThirdParty/Ert/lib/build_config.h.in +++ b/ThirdParty/Ert/lib/build_config.h.in @@ -24,7 +24,6 @@ #cmakedefine HAVE_WINDOWS_MKDIR #cmakedefine HAVE_GETPWUID #cmakedefine HAVE_FSYNC -#cmakedefine HAVE_POSIX_SETENV #cmakedefine HAVE_CHMOD #cmakedefine HAVE_MODE_T #cmakedefine HAVE_CXX_SHARED_PTR @@ -35,6 +34,8 @@ #cmakedefine HAVE_WINSOCK2_H +#cmakedefine HAVE_POSIX_ACCESS +#cmakedefine HAVE_WINDOWS__ACCESS #cmakedefine HAVE_WINDOWS_GET_TEMP_PATH #cmakedefine HAVE_WINDOWS_TZNAME diff --git a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c index e279f0c73b..3716b9fa0a 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c +++ b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.c b/ThirdParty/Ert/lib/ecl/ecl_grid.c index 0d484aecba..d04f6715d5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.c @@ -411,7 +411,7 @@ properties and the fracture properties in a cell is implemented as a nnc where the fracture cell has global index in the range [nx*ny*nz, 2*nz*ny*nz). In ert we we have not implemented this double covering - in the case of dual porosity models, and therefor NNC involving + in the case of dual porosity models so NNC involving fracture cells are not considered. */ @@ -1011,7 +1011,7 @@ static double ecl_cell_max_y( const ecl_cell_type * cell ) { have all four corner at the same arbitrary depth; these cells are inactive and do not affect flow simulations - however the arbitrary location of the cells warps visualisation of normal inactive cells - completely. We therefor try to invalidate such cells here. The + completely. We therefore try to invalidate such cells here. The algorithm used is the same as used for RMS; however RMS will mark the cells as inactive - whereas we mark already inactive cells as invalid. @@ -1326,7 +1326,7 @@ static double ecl_cell_get_signed_volume( ecl_cell_type * cell) { * Note added: these volume calculations are used to calculate pore * volumes in OPM, it turns out that opm is very sensitive to these * volumes. Extracting the divison by 6.0 was actually enough to - * induce a regression test failure in flow, this has therefor been + * induce a regression test failure in flow, this has therefore been * reverted. */ @@ -2793,7 +2793,7 @@ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid The physical connection between the matrix and the fractures in cell nr c is modelled as an nnc: cell[c] -> cell[c + nx*ny*nz]. In the ert ecl library we only have cells in the range [0,nx*ny*nz), - and fracture is a property of a cell, we therefor do not include + and fracture is a property of a cell. We therefore do not include nnc connections involving fracture cells (i.e. cell_index >= nx*ny*nz). */ @@ -4751,6 +4751,17 @@ void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type * grid , int global_index } +void ecl_grid_export_cell_corners1(const ecl_grid_type * grid, int global_index, double *x, double *y, double *z) { + const ecl_cell_type * cell = ecl_grid_get_cell(grid, global_index); + for (int i=0; i<8; i++) { + const point_type point = cell->corner_list[i]; + x[i] = point.x; + y[i] = point.y; + z[i] = point.z; + } +} + + void ecl_grid_get_cell_corner_xyz3(const ecl_grid_type * grid , int i , int j , int k, int corner_nr , double * xpos , double * ypos , double * zpos ) { const int global_index = ecl_grid_get_global_index__(grid , i , j , k ); ecl_grid_get_cell_corner_xyz1( grid , global_index , corner_nr , xpos , ypos , zpos); diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw.c b/ThirdParty/Ert/lib/ecl/ecl_kw.c index 86cc2e75aa..82dd68a1d2 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -107,7 +108,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) 3. The logical type involves converting back and forth between 'T' and 'F' and internal logical representation. The format strings - are therefor for reading/writing a character. + are therefore for reading/writing a character. */ @@ -1289,7 +1290,7 @@ bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { /** This function will skip the header part of an ecl_kw instance. The function will read the file content at the current position, it is - therefor essential that the file pointer is positioned at the + therefore essential that the file pointer is positioned at the beginning of a keyword when this function is called; otherwise it will be complete crash and burn. */ @@ -1917,6 +1918,38 @@ ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target return new_kw; } +ecl_kw_type * ecl_kw_alloc_global_copy(const ecl_kw_type * src, const ecl_kw_type * actnum) { + if (ecl_kw_get_type(actnum) != ECL_INT_TYPE) + return NULL; + + const int global_size = ecl_kw_get_size(actnum); + ecl_kw_type * global_copy = ecl_kw_alloc( ecl_kw_get_header(src), global_size, src->data_type); + const int * mapping = ecl_kw_get_int_ptr(actnum); + const int src_size = ecl_kw_get_size(src); + int src_index = 0; + for (int global_index=0; global_index < global_size; global_index++) { + if (mapping[global_index]) { + /* We ran through and beyond the size of the src keyword. */ + if (src_index >= src_size) { + ecl_kw_free(global_copy); + global_copy = NULL; + break; + } + const void * value_ptr = ecl_kw_iget_ptr(src, src_index); + ecl_kw_iset_static(global_copy, global_index, value_ptr); + src_index++; + } + } + + /* Not all the src data was distributed. */ + if (src_index < src_size) { + ecl_kw_free(global_copy); + global_copy = NULL; + } + + return global_copy; +} + void ecl_kw_fread_double_param(const char * filename , bool fmt_file , double * double_data) { @@ -2194,6 +2227,41 @@ void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { } } +#define ECL_KW_TYPED_INPLACE_ADD_SQUARED( ctype ) \ +static void ecl_kw_inplace_add_squared_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { \ + if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ + util_abort("%s: type/size mismatch\n",__func__); \ + { \ + ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + int i; \ + for (i=0; i < target_kw->size; i++) \ + target_data[i] += add_data[i] * add_data[i]; \ + } \ +} +ECL_KW_TYPED_INPLACE_ADD_SQUARED( int ) +ECL_KW_TYPED_INPLACE_ADD_SQUARED( double ) +ECL_KW_TYPED_INPLACE_ADD_SQUARED( float ) + +#undef ECL_KW_TYPED_INPLACE_ADD + +void ecl_kw_inplace_add_squared( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { + ecl_type_enum type = ecl_kw_get_type(target_kw); + switch (type) { + case(ECL_FLOAT_TYPE): + ecl_kw_inplace_add_squared_float( target_kw , add_kw ); + break; + case(ECL_DOUBLE_TYPE): + ecl_kw_inplace_add_squared_double( target_kw , add_kw ); + break; + case(ECL_INT_TYPE): + ecl_kw_inplace_add_squared_int( target_kw , add_kw ); + break; + default: + util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) )); + } +} + @@ -2309,8 +2377,47 @@ void ecl_kw_inplace_abs( ecl_kw_type * kw ) { } +/*****************************************************************/ +static int sqrti(int x) { + return round( sqrt(x) ); +} + +#define ECL_KW_TYPED_INPLACE_SQRT( ctype, sqrt_func ) \ +void ecl_kw_inplace_sqrt_ ## ctype( ecl_kw_type * kw ) { \ + ctype * data = ecl_kw_get_data_ref( kw ); \ + int i; \ + for (i=0; i < kw->size; i++) \ + data[i] = sqrt_func(data[i]); \ +} + +ECL_KW_TYPED_INPLACE_SQRT( double , sqrt ) +ECL_KW_TYPED_INPLACE_SQRT( float , sqrtf ) +ECL_KW_TYPED_INPLACE_SQRT( int, sqrti) +#undef ECL_KW_TYPED_INPLACE_SQRT + + + +void ecl_kw_inplace_sqrt( ecl_kw_type * kw ) { + ecl_type_enum type = ecl_kw_get_type(kw); + switch (type) { + case(ECL_FLOAT_TYPE): + ecl_kw_inplace_sqrt_float( kw ); + break; + case(ECL_DOUBLE_TYPE): + ecl_kw_inplace_sqrt_double( kw ); + break; + case(ECL_INT_TYPE): + ecl_kw_inplace_sqrt_int( kw ); + break; + default: + util_abort("%s: inplace sqrt not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(kw) )); + } +} + + /*****************************************************************/ + #define ECL_KW_TYPED_INPLACE_MUL( ctype ) \ void ecl_kw_inplace_mul_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * mul_kw) { \ if (!ecl_kw_assert_binary_ ## ctype( target_kw , mul_kw )) \ @@ -2468,6 +2575,23 @@ void ecl_kw_inplace_div_indexed( ecl_kw_type * target_kw , const int_vector_type } +bool ecl_kw_inplace_safe_div(ecl_kw_type * target_kw, const ecl_kw_type * divisor) { + if (ecl_kw_get_type(target_kw) != ECL_FLOAT_TYPE) + return false; + + if (ecl_kw_get_type(divisor) != ECL_INT_TYPE) + return false; + + float * target_data = ecl_kw_get_data_ref( target_kw ); + const int* div_data = ecl_kw_get_data_ref( divisor ); + for (int i=0; i < target_kw->size; i++) { + if (div_data[i] != 0) + target_data[i] /= div_data[i]; + } + + return true; +} + diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c index 1737b808ff..edc577d0cc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c @@ -128,3 +128,27 @@ void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, c int_vector_free( undetermined1 ); int_vector_free( undetermined2 ); } + + + +ecl_kw_type * ecl_kw_alloc_actnum(const ecl_kw_type * porv_kw, float porv_limit) { + if (!ecl_type_is_float( porv_kw->data_type)) + return NULL; + + if (!util_string_equal(PORV_KW, ecl_kw_get_header(porv_kw))) + return NULL; + + const int size = ecl_kw_get_size(porv_kw); + ecl_kw_type * actnum_kw = ecl_kw_alloc(ACTNUM_KW, size, ECL_INT); + const float * porv_values = ecl_kw_get_float_ptr(porv_kw); + int * actnum_values = ecl_kw_get_int_ptr( actnum_kw); + + for (int i=0; i < size; i++) { + if (porv_values[i] > porv_limit) + actnum_values[i] = 1; + else + actnum_values[i] = 0; + } + + return actnum_kw; +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c index 8149fca1dd..f71b75ad6c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c @@ -42,7 +42,7 @@ b) There is not type information; presented with a bunch of formatted numbers it is in general impossible to determine whether the underlying datatype should be integer, float or - double. Therefor all the file-reading routines here expect an + double. Therefore all the file-reading routines here expect an ecl_data_type as input. 2. The files can have comment sections; even in the data block. @@ -159,7 +159,7 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) { This function will search through a GRDECL file to look for the 'kw'; input variables and return vales are similar to ecl_kw_fseek_kw(). Observe that the GRDECL files are extremely - weakly structured, it is therefor veeeery easy to fool this function + weakly structured, it is therefore veeeery easy to fool this function with a malformed GRDECL file. In particular the comparison is case sensitive; that is probably not diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c b/ThirdParty/Ert/lib/ecl/ecl_rft_file.c index 9fb1df3153..17c381087a 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_file.c @@ -415,7 +415,7 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, /** The sorting here works directly on the internal node storage rft_file->data; that might in principle ruin the indexing of - the ecl_file object - it is therefor absolutely essential + the ecl_file object - it is therefore absolutely essential that this ecl_rft_file object does not live beyond this function, and also that the ecl_rft_file api functions are avoided for the rest of this function. diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c b/ThirdParty/Ert/lib/ecl/ecl_rft_node.c index 73bc54ec2d..dc19a5ea30 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_node.c @@ -75,7 +75,7 @@ struct ecl_rft_node_struct { The implementation of cell types based on _either_ RFT data or PLT data is based on a misunderstanding and is currently WRONG. One section in an RFT file can contain RFT data, PLT data and SEGMENT - data. The @data_type string should therefor not be interpreted as a + data. The @data_type string should therefore not be interpreted as a type string, but rather as a "bit mask": diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c index 52d40a9aab..e8d9cef33a 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c @@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - - if (doubhead_kw) - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = NULL; + const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); - if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) - doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); - if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/ecl_smspec.c index a8b02a7a06..c725d5d2f2 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.c @@ -141,6 +141,8 @@ struct ecl_smspec_struct { float_vector_type * params_default; char * restart_case; + ert_ecl_unit_enum unit_system; + int restart_step; }; @@ -246,7 +248,7 @@ static const char* smspec_required_keywords[] = { /*****************************************************************/ -static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string) { +ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string) { ecl_smspec_type *ecl_smspec; ecl_smspec = util_malloc(sizeof *ecl_smspec ); UTIL_TYPE_ID_INIT(ecl_smspec , ECL_SMSPEC_ID); @@ -272,8 +274,16 @@ static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * k ecl_smspec->locked = false; ecl_smspec->time_seconds = -1; + /* + The unit system is given as an integer in the INTEHEAD keyword. The INTEHEAD + keyword is optional, and we have for a long time been completely oblivious + to the possibility of extracting unit system information from the SMSPEC file. + */ + ecl_smspec->unit_system = ECL_METRIC_UNITS; + ecl_smspec->index_map = int_vector_alloc(0,0); ecl_smspec->restart_case = NULL; + ecl_smspec->restart_step = -1; ecl_smspec->params_default = float_vector_alloc(0 , PARAMS_GLOBAL_DEFAULT); ecl_smspec->write_mode = write_mode; ecl_smspec->need_nums = false; @@ -357,137 +367,140 @@ static ecl_data_type get_wgnames_type(const ecl_smspec_type * smspec) { return max_len <= ECL_STRING8_LENGTH ? ECL_CHAR : ECL_STRING(max_len); } -// DIMENS -// KEYWORDS -// WGNAMES -// NUMS - optional -// UNITS -// STARTDAT +static void ecl_smspec_fwrite_INTEHEAD(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * intehead = ecl_kw_alloc( INTEHEAD_KW, INTEHEAD_SMSPEC_SIZE, ECL_INT); + ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX, smspec->unit_system); + /* + The simulator type is just hardcoded to ECLIPSE100. + */ + ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_IPROG_INDEX, INTEHEAD_ECLIPSE100_VALUE); + ecl_kw_fwrite(intehead, fortio); + ecl_kw_free(intehead); +} -static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_type * fortio) { - int num_nodes = ecl_smspec_num_nodes( smspec ); - { - ecl_kw_type * restart_kw = ecl_kw_alloc( RESTART_KW , SUMMARY_RESTART_SIZE , ECL_CHAR ); - for (int i=0; i < SUMMARY_RESTART_SIZE; i++) - ecl_kw_iset_string8( restart_kw , i , ""); - - if (smspec->restart_case != NULL) { - int restart_case_len = strlen(smspec->restart_case); - - int offset = 0; - for (int i = 0; i < SUMMARY_RESTART_SIZE ; i++) { - if (offset < restart_case_len) - ecl_kw_iset_string8( restart_kw , i , &smspec->restart_case[ offset ]); - offset += ECL_STRING8_LENGTH; - } - } +static void ecl_smspec_fwrite_RESTART(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * restart_kw = ecl_kw_alloc( RESTART_KW , SUMMARY_RESTART_SIZE , ECL_CHAR ); + for (int i=0; i < SUMMARY_RESTART_SIZE; i++) + ecl_kw_iset_string8( restart_kw , i , ""); - ecl_kw_fwrite( restart_kw , fortio ); - ecl_kw_free( restart_kw ); - } - { - ecl_kw_type * dimens_kw = ecl_kw_alloc( DIMENS_KW , DIMENS_SIZE , ECL_INT ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_SIZE_INDEX , num_nodes ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NX_INDEX , smspec->grid_dims[0] ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NY_INDEX , smspec->grid_dims[1] ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NZ_INDEX , smspec->grid_dims[2] ); - - /* Do not know what these two last items are for. */ - ecl_kw_iset_int( dimens_kw , 4 , 0 ); - ecl_kw_iset_int( dimens_kw , 5 , -1 ); - - ecl_kw_fwrite( dimens_kw , fortio ); - ecl_kw_free( dimens_kw ); + if (smspec->restart_case != NULL) { + int restart_case_len = strlen(smspec->restart_case); + + int offset = 0; + for (int i = 0; i < SUMMARY_RESTART_SIZE ; i++) { + if (offset < restart_case_len) + ecl_kw_iset_string8( restart_kw , i , &smspec->restart_case[ offset ]); + offset += ECL_STRING8_LENGTH; + } } + ecl_kw_fwrite( restart_kw , fortio ); + ecl_kw_free( restart_kw ); +} - { - ecl_kw_type * keywords_kw = ecl_kw_alloc( KEYWORDS_KW , num_nodes , ECL_CHAR ); - ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR ); - ecl_kw_type * nums_kw = NULL; - - // If the names_type is an ECL_STRING we expect this to be an INTERSECT - // summary, otherwise an ECLIPSE summary. - ecl_data_type names_type = get_wgnames_type(smspec); - ecl_kw_type * wgnames_kw = ecl_kw_alloc( - ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, - num_nodes, - names_type - ); - if (smspec->need_nums) - nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT); - { - int i; - for (i=0; i < ecl_smspec_num_nodes( smspec ); i++) { - const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , i ); - /* - It is possible to add variables with deferred initialisation - with the ecl_sum_add_blank_var() function. Before these - variables can be actually used for anything interesting they - must be initialized with the ecl_sum_init_var() function. +static void ecl_smspec_fwrite_DIMENS(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * dimens_kw = ecl_kw_alloc( DIMENS_KW , DIMENS_SIZE , ECL_INT ); + int num_nodes = ecl_smspec_num_nodes( smspec ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_SIZE_INDEX , num_nodes ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NX_INDEX , smspec->grid_dims[0] ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NY_INDEX , smspec->grid_dims[1] ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NZ_INDEX , smspec->grid_dims[2] ); + ecl_kw_iset_int( dimens_kw , 4 , 0 ); // Do not know what this is for. + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_RESTART_STEP_INDEX , smspec->restart_step ); - If a call to save the smspec file comes before all the - variable have been initialized things will potentially go - belly up. This is solved with the following uber-hack: + ecl_kw_fwrite( dimens_kw , fortio ); + ecl_kw_free( dimens_kw ); +} - o One of the well related keywords is chosen; in - particular 'WWCT' in this case. - o The wgname value is set to DUMMY_WELL +static void ecl_smspec_fwrite_STARTDAT(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * startdat_kw = ecl_kw_alloc( STARTDAT_KW , STARTDAT_SIZE , ECL_INT ); + int day,month,year; + ecl_util_set_date_values( smspec->sim_start_time , &day, &month , &year); - The use of DUMMY_WELL ensures that this field will be - ignored when/if this smspec file is read in at a later - stage. - */ - if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) { - ecl_kw_iset_string8( keywords_kw , i , "WWCT" ); - ecl_kw_iset_string8( units_kw , i , "????????"); - ecl_kw_iset_string_ptr( wgnames_kw , i , DUMMY_WELL); - } else { - ecl_kw_iset_string8( keywords_kw , i , smspec_node_get_keyword( smspec_node )); - ecl_kw_iset_string8( units_kw , i , smspec_node_get_unit( smspec_node )); - { - const char * wgname = DUMMY_WELL; - if (smspec_node_get_wgname( smspec_node )) - wgname = smspec_node_get_wgname( smspec_node ); - ecl_kw_iset_string_ptr( wgnames_kw , i , wgname); - } - } + ecl_kw_iset_int( startdat_kw , STARTDAT_DAY_INDEX , day ); + ecl_kw_iset_int( startdat_kw , STARTDAT_MONTH_INDEX , month ); + ecl_kw_iset_int( startdat_kw , STARTDAT_YEAR_INDEX , year ); - if (nums_kw != NULL) - ecl_kw_iset_int( nums_kw , i , smspec_node_get_num( smspec_node )); - } - } + ecl_kw_fwrite( startdat_kw , fortio ); + ecl_kw_free( startdat_kw ); +} - ecl_kw_fwrite( keywords_kw , fortio ); - ecl_kw_fwrite( wgnames_kw , fortio ); - if (nums_kw != NULL) - ecl_kw_fwrite( nums_kw , fortio ); - ecl_kw_fwrite( units_kw , fortio ); +static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_type * fortio) { + ecl_smspec_fwrite_INTEHEAD(smspec, fortio); + ecl_smspec_fwrite_RESTART(smspec, fortio); + ecl_smspec_fwrite_DIMENS(smspec, fortio); + + int num_nodes = ecl_smspec_num_nodes( smspec ); + ecl_kw_type * keywords_kw = ecl_kw_alloc( KEYWORDS_KW , num_nodes , ECL_CHAR ); + ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR ); + ecl_kw_type * nums_kw = NULL; + + // If the names_type is an ECL_STRING we expect this to be an INTERSECT + // summary, otherwise an ECLIPSE summary. + ecl_data_type names_type = get_wgnames_type(smspec); + ecl_kw_type * wgnames_kw = ecl_kw_alloc( ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, + num_nodes, + names_type ); + + if (smspec->need_nums) + nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT); + + for (int i=0; i < ecl_smspec_num_nodes( smspec ); i++) { + const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , i ); + /* + It is possible to add variables with deferred initialisation + with the ecl_sum_add_blank_var() function. Before these + variables can be actually used for anything interesting they + must be initialized with the ecl_sum_init_var() function. + If a call to save the smspec file comes before all the + variable have been initialized things will potentially go + belly up. This is solved with the following uber-hack: - ecl_kw_free( keywords_kw ); - ecl_kw_free( wgnames_kw ); - ecl_kw_free( units_kw ); - if (nums_kw != NULL) - ecl_kw_free( nums_kw ); - } + o One of the well related keywords is chosen; in + particular 'WWCT' in this case. - { - ecl_kw_type * startdat_kw = ecl_kw_alloc( STARTDAT_KW , STARTDAT_SIZE , ECL_INT ); - int day,month,year; - ecl_util_set_date_values( smspec->sim_start_time , &day, &month , &year); + o The wgname value is set to DUMMY_WELL - ecl_kw_iset_int( startdat_kw , STARTDAT_DAY_INDEX , day ); - ecl_kw_iset_int( startdat_kw , STARTDAT_MONTH_INDEX , month ); - ecl_kw_iset_int( startdat_kw , STARTDAT_YEAR_INDEX , year ); + The use of DUMMY_WELL ensures that this field will be + ignored when/if this smspec file is read in at a later + stage. + */ + if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) { + ecl_kw_iset_string8( keywords_kw , i , "WWCT" ); + ecl_kw_iset_string8( units_kw , i , "????????"); + ecl_kw_iset_string_ptr( wgnames_kw , i , DUMMY_WELL); + } else { + ecl_kw_iset_string8( keywords_kw , i , smspec_node_get_keyword( smspec_node )); + ecl_kw_iset_string8( units_kw , i , smspec_node_get_unit( smspec_node )); + { + const char * wgname = DUMMY_WELL; + if (smspec_node_get_wgname( smspec_node )) + wgname = smspec_node_get_wgname( smspec_node ); + ecl_kw_iset_string_ptr( wgnames_kw , i , wgname); + } + } - ecl_kw_fwrite( startdat_kw , fortio ); - ecl_kw_free( startdat_kw ); + if (nums_kw != NULL) + ecl_kw_iset_int( nums_kw , i , smspec_node_get_num( smspec_node )); } + ecl_kw_fwrite( keywords_kw , fortio ); + ecl_kw_fwrite( wgnames_kw , fortio ); + if (nums_kw != NULL) + ecl_kw_fwrite( nums_kw , fortio ); + ecl_kw_fwrite( units_kw , fortio ); + + ecl_kw_free( keywords_kw ); + ecl_kw_free( wgnames_kw ); + ecl_kw_free( units_kw ); + if (nums_kw != NULL) + ecl_kw_free( nums_kw ); + + ecl_smspec_fwrite_STARTDAT(smspec, fortio); } @@ -501,14 +514,19 @@ void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , free( filename ); } -ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const char * restart_case, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - ecl_smspec_type * ecl_smspec = ecl_smspec_alloc_empty( true , key_join_string ); - - if (restart_case != NULL) { - if (strlen(restart_case) <= (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) - ecl_smspec->restart_case = util_alloc_string_copy( restart_case ); - else - return NULL; + + +static ecl_smspec_type * ecl_smspec_alloc_writer__( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + ecl_smspec_type * ecl_smspec = ecl_smspec_alloc_empty( true , key_join_string ); + /* + Only a total of 9 * 8 characters is set aside for the restart keyword, if + the supplied restart case is longer than that we silently ignore it. + */ + if (restart_case) { + if (strlen(restart_case) <= (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) { + ecl_smspec->restart_case = util_alloc_string_copy( restart_case ); + ecl_smspec->restart_step = restart_step; + } } ecl_smspec->grid_dims[0] = nx; ecl_smspec->grid_dims[1] = ny; @@ -547,6 +565,14 @@ ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const return ecl_smspec; } +ecl_smspec_type * ecl_smspec_alloc_restart_writer( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + return ecl_smspec_alloc_writer__(key_join_string, restart_case, restart_step, sim_start, time_in_days, nx, ny, nz); +} + +ecl_smspec_type * ecl_smspec_alloc_writer(const char * key_join_string, time_t sim_start, bool time_in_days, int nx, int ny , int nz) { + return ecl_smspec_alloc_writer__(key_join_string, NULL, 0, sim_start, time_in_days, nx, ny, nz); +} + UTIL_SAFE_CAST_FUNCTION( ecl_smspec , ECL_SMSPEC_ID ) @@ -1017,9 +1043,13 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL ); smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0); if (!util_same_file(smspec_header , ecl_smspec->header_file)) /* Restart from the current case is ignored. */ { - char * tmp_path = util_alloc_filename( path , restart_base , NULL ); - ecl_smspec->restart_case = util_alloc_abs_path(tmp_path); - free( tmp_path ); + if (util_is_abs_path(restart_base)) + ecl_smspec->restart_case = util_alloc_string_copy( restart_base ); + else { + char * tmp_path = util_alloc_filename( path , restart_base , NULL ); + ecl_smspec->restart_case = util_alloc_abs_path(tmp_path); + free( tmp_path ); + } } util_safe_free( path ); @@ -1147,6 +1177,16 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h if (ecl_file_has_kw(header , NUMS_KW)) nums = ecl_file_iget_named_kw(header , NUMS_KW , 0); + if (ecl_file_has_kw(header, INTEHEAD_KW)) { + const ecl_kw_type * intehead = ecl_file_iget_named_kw(header, INTEHEAD_KW, 0); + ecl_smspec->unit_system = ecl_kw_iget_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX); + /* + The second item in the INTEHEAD vector is an integer designating which + simulator has been used for the current simulation, that is currently + ignored. + */ + } + if (ecl_file_has_kw( header , LGRS_KW )) {/* The file has LGR information. */ lgrs = ecl_file_iget_named_kw( header , LGRS_KW , 0 ); numlx = ecl_file_iget_named_kw( header , NUMLX_KW , 0 ); @@ -1166,6 +1206,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h ecl_smspec->grid_dims[0] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NX_INDEX ); ecl_smspec->grid_dims[1] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NY_INDEX ); ecl_smspec->grid_dims[2] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NZ_INDEX ); + ecl_smspec->restart_step = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_RESTART_STEP_INDEX); ecl_smspec_set_params_size( ecl_smspec , ecl_kw_get_size(keywords)); ecl_util_get_file_type( header_file , &ecl_smspec->formatted , NULL ); @@ -1640,6 +1681,10 @@ const char * ecl_smspec_get_header_file( const ecl_smspec_type * ecl_smspec ) { } +int ecl_smspec_get_restart_step(const ecl_smspec_type * ecl_smspec) { + return ecl_smspec->restart_step; +} + const char * ecl_smspec_get_restart_case( const ecl_smspec_type * ecl_smspec) { return ecl_smspec->restart_case; @@ -1884,3 +1929,7 @@ void ecl_smspec_sort( ecl_smspec_type * smspec ) { } } + +ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type * smspec) { + return smspec->unit_system; +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.c b/ThirdParty/Ert/lib/ecl/ecl_sum.c index f9e68cd797..57692fe185 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.c @@ -35,6 +35,8 @@ #include #include + +#include #include #include #include @@ -95,6 +97,7 @@ struct ecl_sum_struct { UTIL_TYPE_ID_DECLARATION; ecl_smspec_type * smspec; /* Internalized version of the SMSPEC file. */ ecl_sum_data_type * data; /* The data - can be NULL. */ + ecl_sum_type * restart_case; bool fmt_case; @@ -149,6 +152,9 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key_join_string) { + if (!ecl_util_path_access(input_arg)) + return NULL; + ecl_sum_type * ecl_sum = util_malloc( sizeof * ecl_sum ); UTIL_TYPE_ID_INIT( ecl_sum , ECL_SUM_ID ); @@ -162,6 +168,7 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key ecl_sum->smspec = NULL; ecl_sum->data = NULL; + ecl_sum->restart_case = NULL; return ecl_sum; } @@ -177,10 +184,10 @@ static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * static void ecl_sum_fread_history( ecl_sum_type * ecl_sum ) { - ecl_sum_type * history = ecl_sum_fread_alloc_case__( ecl_smspec_get_restart_case( ecl_sum->smspec ) , ":" , true); - if (history) { - ecl_sum_data_add_case(ecl_sum->data , history->data ); - ecl_sum_free( history ); + ecl_sum_type * restart_case = ecl_sum_fread_alloc_case__( ecl_smspec_get_restart_case( ecl_sum->smspec ) , ":" , true); + if (restart_case) { + ecl_sum->restart_case = restart_case; + ecl_sum_data_add_case(ecl_sum->data , restart_case->data ); } } @@ -244,9 +251,11 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart) { ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string, bool include_restart) { ecl_sum_type * ecl_sum = ecl_sum_alloc__( header_file , key_join_string ); - if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart)) { - ecl_sum_free( ecl_sum ); - ecl_sum = NULL; + if (ecl_sum) { + if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart)) { + ecl_sum_free( ecl_sum ); + ecl_sum = NULL; + } } return ecl_sum; } @@ -274,6 +283,15 @@ smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keywor return smspec_node; } +smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node) { + return ecl_sum_add_var(ecl_sum, + smspec_node_get_keyword(node), + smspec_node_get_wgname(node), + smspec_node_get_num(node), + smspec_node_get_unit(node), + smspec_node_get_default(node)); +} + smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value) { smspec_node_type * smspec_node = smspec_node_alloc_new( -1 , default_value ); @@ -299,23 +317,49 @@ ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds ); } +static ecl_sum_type * ecl_sum_alloc_writer__( const char * ecl_case , const char * restart_case , int restart_step, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { -ecl_sum_type * ecl_sum_alloc_restart_writer( const char * ecl_case , const char * restart_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - ecl_sum_type * ecl_sum = ecl_sum_alloc__( ecl_case , key_join_string ); - ecl_sum_set_unified( ecl_sum , unified ); - ecl_sum_set_fmt_case( ecl_sum , fmt_output ); + if (ecl_sum) { + ecl_sum_set_unified( ecl_sum , unified ); + ecl_sum_set_fmt_case( ecl_sum , fmt_output ); - ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string , restart_case, sim_start , time_in_days , nx , ny , nz ); - ecl_sum->data = ecl_sum_data_alloc_writer( ecl_sum->smspec ); + if (restart_case) + ecl_sum->smspec = ecl_smspec_alloc_restart_writer( key_join_string , restart_case, restart_step, sim_start , time_in_days , nx , ny , nz ); + else + ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string, sim_start, time_in_days, nx, ny, nz); + ecl_sum->data = ecl_sum_data_alloc_writer( ecl_sum->smspec ); + } return ecl_sum; } + +ecl_sum_type * ecl_sum_alloc_restart_writer2( const char * ecl_case , const char * restart_case , int restart_step, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); +} + + +/* + This does not take in the restart_step argument is depcrecated. You should use the + ecl_sum_alloc_restart_writer2() function. +*/ + +ecl_sum_type * ecl_sum_alloc_restart_writer( const char * ecl_case , const char * restart_case, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + int restart_step = 0; + return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); +} + + + + + + ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - return ecl_sum_alloc_restart_writer(ecl_case, NULL, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); + return ecl_sum_alloc_writer__(ecl_case, NULL, 0, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); } + void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ) { ecl_sum_fwrite_smspec( ecl_sum ); ecl_sum_data_fwrite( ecl_sum->data , ecl_sum->ecl_case , ecl_sum->fmt_case , ecl_sum->unified ); @@ -342,10 +386,13 @@ void ecl_sum_free_data( ecl_sum_type * ecl_sum ) { void ecl_sum_free( ecl_sum_type * ecl_sum ) { - if (ecl_sum->data != NULL) + if (ecl_sum->restart_case) + ecl_sum_free(ecl_sum->restart_case); + + if (ecl_sum->data) ecl_sum_free_data( ecl_sum ); - if (ecl_sum->smspec != NULL) + if (ecl_sum->smspec) ecl_smspec_free( ecl_sum->smspec ); util_safe_free( ecl_sum->path ); @@ -390,7 +437,10 @@ void ecl_sum_free__(void * __ecl_sum) { ecl_sum_type * ecl_sum_fread_alloc_case__(const char * input_file , const char * key_join_string , bool include_restart){ - ecl_sum_type * ecl_sum = ecl_sum_alloc__(input_file , key_join_string); + ecl_sum_type * ecl_sum = ecl_sum_alloc__(input_file , key_join_string); + if (!ecl_sum) + return NULL; + if (ecl_sum_fread_case( ecl_sum , include_restart)) return ecl_sum; else { @@ -690,6 +740,67 @@ const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const /*****************************************************************/ + +ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times) { + time_t start_time = ecl_sum_get_data_start(ecl_sum); + + if ( time_t_vector_get_first(times) < start_time ) + return NULL; + if ( time_t_vector_get_last(times) > ecl_sum_get_end_time(ecl_sum) ) + return NULL; + if ( !time_t_vector_is_sorted(times, false) ) + return NULL; + + const int * grid_dims = ecl_smspec_get_grid_dims(ecl_sum->smspec); + + bool time_in_days = false; + const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, 0); + if ( util_string_equal(smspec_node_get_unit(node), "DAYS" ) ) + time_in_days = true; + + ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_writer( ecl_case , ecl_sum->fmt_case , ecl_sum->unified , ecl_sum->key_join_string , start_time , time_in_days , grid_dims[0] , grid_dims[1] , grid_dims[2] ); + + + + for (int i = 0; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) { + const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, i); + if (util_string_equal(smspec_node_get_gen_key1(node), "TIME")) + continue; + + if (!smspec_node_is_valid(node)) + continue; + + ecl_sum_add_smspec_node( ecl_sum_resampled, node ); + } + + /* + The SMSPEC header structure has been completely initialized, it is time to + start filling it up with data. + */ + ecl_sum_vector_type * ecl_sum_vector = ecl_sum_vector_alloc(ecl_sum, true); + double_vector_type * data = double_vector_alloc( ecl_sum_vector_get_size(ecl_sum_vector) , 0); + + + for (int report_step = 0; report_step < time_t_vector_size(times); report_step++) { + time_t t = time_t_vector_iget(times, report_step); + + /* Look up interpolated data in the original case. */ + ecl_sum_get_interp_vector( ecl_sum, t, ecl_sum_vector, data); + + /* Add timestep corresponding to the interpolated data in the resampled case. */ + ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum_resampled , report_step , t - start_time); + for (int data_index = 0; data_index < ecl_sum_vector_get_size(ecl_sum_vector); data_index++) { + double value = double_vector_iget(data,data_index); + int params_index = data_index + 1; // The +1 shift is because the first element in the tstep is time value. + ecl_sum_tstep_iset(tstep, params_index, value); + } + } + double_vector_free( data ); + ecl_sum_vector_free( ecl_sum_vector ); + return ecl_sum_resampled; +} + + double ecl_sum_iget( const ecl_sum_type * ecl_sum , int time_index , int param_index) { return ecl_sum_data_iget(ecl_sum->data , time_index , param_index); } @@ -1053,6 +1164,14 @@ void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename , } +const ecl_sum_type * ecl_sum_get_restart_case(const ecl_sum_type * ecl_sum) { + return ecl_sum->restart_case; +} + +int ecl_sum_get_restart_step(const ecl_sum_type * ecl_sum) { + return ecl_smspec_get_restart_step(ecl_sum->smspec); +} + const char * ecl_sum_get_case(const ecl_sum_type * ecl_sum) { return ecl_sum->ecl_case; @@ -1300,3 +1419,8 @@ time_t_vector_type * ecl_sum_alloc_time_solution( const ecl_sum_type * ecl_sum , } return solution; } + + +ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type * ecl_sum) { + return ecl_smspec_get_unit_system(ecl_sum->smspec); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c b/ThirdParty/Ert/lib/ecl/ecl_sum_data.c index c0b28cdc43..73d29f763f 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.c @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -927,9 +928,15 @@ void ecl_sum_data_add_case(ecl_sum_data_type * self, const ecl_sum_data_type * o ecl_sum_tstep_type * other_tstep = ecl_sum_data_iget_ministep( other , tstep_nr ); /* - The dataset 'self' is the authorative in the timeinterval where - it has data, so if 'other' also has data in the same time interval - that is discarded. + The dataset 'self' is the authorative in the timeinterval where it has + data, so if 'other' also has data in the same time interval that is + discarded. In most cases 'other' will represent a history case, and 'self' + is a prediction which has been restarted. + + After implementing the time_interval_contains() based check it turned out + that the smspec structure also contains a restart_step integer value in + the DIMENS vector which could probably be used to achieve the same thing. + That field is currently not used. */ if (!time_interval_contains( self->sim_time , ecl_sum_tstep_get_sim_time( other_tstep ))) { @@ -1180,12 +1187,10 @@ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1 } -static double ecl_sum_data_vector_iget(const ecl_sum_data_type * data, time_t sim_time, const ecl_sum_vector_type * keylist, int key_index, +static double ecl_sum_data_vector_iget(const ecl_sum_data_type * data, time_t sim_time, int params_index, bool is_rate, int time_index1 , int time_index2 , double weight1 , double weight2 ) { - int params_index = ecl_sum_vector_iget_param_index(keylist, key_index); double value = 0.0; - bool is_rate = ecl_sum_vector_iget_is_rate(keylist, key_index); if (is_rate) { int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time); // uses step function since it is a rate @@ -1205,15 +1210,35 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data, time_t ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); for (int i = 0; i < num_keywords; i++) { - double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2); + if (ecl_sum_vector_iget_valid(keylist, i)) { + int params_index = ecl_sum_vector_iget_param_index(keylist, i); + bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); + double value = ecl_sum_data_vector_iget( data, sim_time, params_index , is_rate, time_index1, time_index2, weight1, weight2); - if (i == 0) - fprintf(fp, "%f", value); - else - fprintf(fp, ",%f", value); + if (i == 0) + fprintf(fp, "%f", value); + else + fprintf(fp, ",%f", value); + } else { + if (i == 0) + fputs("", fp); + else + fputs(",", fp); + } } } + +/* + If the keylist contains invalid indices the corresponding element in the + results vector will *not* be updated; i.e. it is smart to initialize the + results vector with an invalid-value marker before calling this function: + + double_vector_type * results = double_vector_alloc( ecl_sum_vector_get_size(keys), NAN); + ecl_sum_data_get_interp_vector( data, sim_time, keys, results); + +*/ + void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, double_vector_type * results){ int num_keywords = ecl_sum_vector_get_size(keylist); double weight1, weight2; @@ -1222,8 +1247,12 @@ void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); double_vector_reset( results ); for (int i = 0; i < num_keywords; i++) { - double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2); - double_vector_iset( results, i , value ); + if (ecl_sum_vector_iget_valid(keylist, i)) { + int params_index = ecl_sum_vector_iget_param_index(keylist, i); + bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); + double value = ecl_sum_data_vector_iget( data, sim_time, params_index, is_rate, time_index1, time_index2, weight1, weight2); + double_vector_iset( results, i , value ); + } } } @@ -1414,7 +1443,7 @@ void ecl_sum_data_init_time_vector( const ecl_sum_data_type * data , time_t_vect } } else { int i; - for (i = 0; i < vector_get_size(data->data); i++) { + for (i = 1; i < vector_get_size(data->data); i++) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); time_t_vector_append( time_vector , ecl_sum_tstep_get_sim_time( ministep )); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c index 5e22358d18..bc735e7b99 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c @@ -42,39 +42,91 @@ void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){ int_vector_free(ecl_sum_vector->node_index_list); bool_vector_free(ecl_sum_vector->is_rate_list); stringlist_free(ecl_sum_vector->key_list); + free(ecl_sum_vector); } UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID ) +static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const smspec_node_type * node, const char * key ) { + int params_index = smspec_node_get_params_index( node ); + bool is_rate_key = smspec_node_is_rate( node); -ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum){ + int_vector_append(vector->node_index_list, params_index); + bool_vector_append(vector->is_rate_list, is_rate_key); + stringlist_append_copy( vector->key_list, key ); +} + + +ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords) { ecl_sum_vector_type * ecl_sum_vector = util_malloc( sizeof * ecl_sum_vector ); UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID); ecl_sum_vector->ecl_sum = ecl_sum; ecl_sum_vector->node_index_list = int_vector_alloc(0,0); ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false); ecl_sum_vector->key_list = stringlist_alloc_new( ); + if (add_keywords) { + const ecl_smspec_type * smspec = ecl_sum_get_smspec(ecl_sum); + for (int i=0; i < ecl_smspec_num_nodes(smspec); i++) { + const smspec_node_type * node = ecl_smspec_iget_node( smspec , i ); + if (!smspec_node_is_valid(node)) + continue; + + const char * key = smspec_node_get_gen_key1(node); + /* + The TIME keyword is special case handled to not be included; that is + to match the same special casing in the key matching function. + */ + if (!util_string_equal(key, "TIME")) + ecl_sum_vector_add_node( ecl_sum_vector, node, key); + } + } return ecl_sum_vector; } +static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const char * key) { + int_vector_append(vector->node_index_list, -1); + bool_vector_append(vector->is_rate_list, false); + stringlist_append_copy(vector->key_list, key); +} + + +/* + This function will allocate a keyword vector for the keys in the @ecl_sum + argument passed in, it will contain all the same keys as in the input argument + @src_vector. If the @src_vector contains keys which are not present in + @ecl_sum an entry marked as *invalid* will be added. The whole point about + this function is to ensure that calls to: + + ecl_sum_fwrite_interp_csv_line( ) + + will result in nicely aligned output even if the different summary cases do + not have the exact same keys. +*/ + +ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type * src_vector, const ecl_sum_type * ecl_sum) { + ecl_sum_vector_type * new_vector = ecl_sum_vector_alloc(ecl_sum, false); + for (int i=0; i < stringlist_get_size(src_vector->key_list); i++) { + const char * key = stringlist_iget(src_vector->key_list, i); + if (ecl_sum_has_general_var(ecl_sum, key)) + ecl_sum_vector_add_key(new_vector, key); + else + ecl_sum_vector_add_invalid_key(new_vector, key); + } + return new_vector; +} + + bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char * key){ if (ecl_sum_has_general_var( ecl_sum_vector->ecl_sum , key)) { const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); - int params_index = smspec_node_get_params_index( node ); - bool is_rate_key = smspec_node_is_rate( node); - - int_vector_append(ecl_sum_vector->node_index_list, params_index); - bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); - stringlist_append_copy( ecl_sum_vector->key_list, key ); + ecl_sum_vector_add_node(ecl_sum_vector, node, key); return true; } else return false; } - - void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * pattern){ stringlist_type * keylist = ecl_sum_alloc_matching_general_var_list(ecl_sum_vector->ecl_sum , pattern); @@ -83,12 +135,7 @@ void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * for(i = 0; i < num_keywords ;i++){ const char * key = stringlist_iget(keylist, i); const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); - int params_index = smspec_node_get_params_index( node ); - bool is_rate_key = smspec_node_is_rate( node); - - int_vector_append(ecl_sum_vector->node_index_list, params_index); - bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); - stringlist_append_copy( ecl_sum_vector->key_list, key ); + ecl_sum_vector_add_node(ecl_sum_vector, node, key); } stringlist_free(keylist); } @@ -101,6 +148,10 @@ bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int return bool_vector_iget(ecl_sum_vector->is_rate_list, index); } +bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index) { + return (int_vector_iget(ecl_sum_vector->node_index_list, index) >= 0); +} + int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){ return int_vector_iget(ecl_sum_vector->node_index_list, index); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_util.c b/ThirdParty/Ert/lib/ecl/ecl_util.c index 6b1dae13f9..3aac4927b5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_util.c +++ b/ThirdParty/Ert/lib/ecl/ecl_util.c @@ -55,22 +55,6 @@ #define ECL_INIT_UFMT_PATTERN "INIT" #define ECL_RFT_UFMT_PATTERN "RFT" -#ifdef ERT_WINDOWS -/* - The filename matching function on windows onyl recognizes the '*' - and '?' wildcard characters. -*/ - #define ECL_RESTART_FMT_PATTERN "F????" - #define ECL_SUMMARY_FMT_PATTERN "A????" - #define ECL_RESTART_UFMT_PATTERN "X????" - #define ECL_SUMMARY_UFMT_PATTERN "S????" -#else - #define ECL_RESTART_FMT_PATTERN "F[0-9][0-9][0-9][0-9]" - #define ECL_SUMMARY_FMT_PATTERN "A[0-9][0-9][0-9][0-9]" - #define ECL_RESTART_UFMT_PATTERN "X[0-9][0-9][0-9][0-9]" - #define ECL_SUMMARY_UFMT_PATTERN "S[0-9][0-9][0-9][0-9]" -#endif - @@ -122,37 +106,15 @@ char * ecl_util_alloc_base_guess(const char * path) { -int ecl_util_filename_report_nr(const char *filename) { - char *ext = strrchr(filename , '.'); - if (ext == NULL) - return -1; - if (ext[1] == 'X' || ext[1] == 'F' || ext[1] == 'S' || ext[1] == 'A') - return atoi(&ext[2]); - - return -1; +int ecl_util_filename_report_nr(const char *filename) { + int report_nr = -1; + ecl_util_get_file_type(filename, NULL, &report_nr); + return report_nr; } -/* -bool ecl_util_numeric_extension(const char * extension) { - - const char digit_ascii_min = 48; - const char digit_ascii_max = 57; - bool valid = true; - int pos = 1; - while (valid && pos <= 5) { - char c = extension[pos]; - valid = (valid & (c >= digit_ascii_min && c <= digit_ascii_max)); - if (!valid) - break; - } - - return valid; -} -*/ - /* We accept mixed lowercase/uppercase Eclipse file extensions even if Eclipse itself does not accept them. @@ -252,39 +214,26 @@ ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int to the fundamental type, it is also determined whether the file is formatted or not, and in the case of summary/restart files, which report number this corresponds to. - - */ -ecl_file_enum ecl_util_get_file_type(const char * filename, bool *_fmt_file, int * _report_nr) { - +ecl_file_enum ecl_util_get_file_type(const char * filename, bool *fmt_file, int * report_nr) { char *ext = strrchr(filename , '.'); - if (ext != NULL) { - ext++; - return ecl_util_inspect_extension( ext , _fmt_file , _report_nr); - } else + if (ext == NULL) return ECL_OTHER_FILE; + return ecl_util_inspect_extension( &ext[1] , fmt_file , report_nr); } - - static const char * ecl_util_get_file_pattern( ecl_file_enum file_type , bool fmt_file ) { if (fmt_file) { switch( file_type ) { case( ECL_OTHER_FILE ): return ECL_OTHER_FILE_FMT_PATTERN; /* '*' */ break; - case( ECL_RESTART_FILE ): - return ECL_RESTART_FMT_PATTERN; - break; case( ECL_UNIFIED_RESTART_FILE ): return ECL_UNIFIED_RESTART_FMT_PATTERN; break; - case( ECL_SUMMARY_FILE ): - return ECL_SUMMARY_FMT_PATTERN; - break; case( ECL_UNIFIED_SUMMARY_FILE ): return ECL_UNIFIED_SUMMARY_FMT_PATTERN; break; @@ -312,15 +261,9 @@ static const char * ecl_util_get_file_pattern( ecl_file_enum file_type , bool fm case( ECL_OTHER_FILE ): return ECL_OTHER_FILE_UFMT_PATTERN; /* '*' */ break; - case( ECL_RESTART_FILE ): - return ECL_RESTART_UFMT_PATTERN; - break; case( ECL_UNIFIED_RESTART_FILE ): return ECL_UNIFIED_RESTART_UFMT_PATTERN; break; - case( ECL_SUMMARY_FILE ): - return ECL_SUMMARY_UFMT_PATTERN; - break; case( ECL_UNIFIED_SUMMARY_FILE ): return ECL_UNIFIED_SUMMARY_UFMT_PATTERN; break; @@ -392,6 +335,28 @@ const char * ecl_util_file_type_name( ecl_file_enum file_type ) { return NULL; } +static bool valid_base(const char * input_base, bool * upper_case) { + bool upper = false; + bool lower = false; + const char * base = strrchr(input_base, UTIL_PATH_SEP_CHAR); + if (base == NULL) + base = input_base; + + for (int i=0; i < strlen(base); i++) { + char c = base[i]; + + if (isupper(c)) + upper = true; + + if (islower(c)) + lower = true; + + } + + if (upper_case) + *upper_case = upper; + return !(lower && upper); +} @@ -408,6 +373,11 @@ const char * ecl_util_file_type_name( ecl_file_enum file_type ) { */ static char * ecl_util_alloc_filename_static(const char * path, const char * base , ecl_file_enum file_type , bool fmt_file, int report_nr, bool must_exist) { + bool upper_case; + if (!valid_base(base, &upper_case)) + return NULL; + + char * filename; char * ext; switch (file_type) { @@ -484,6 +454,11 @@ static char * ecl_util_alloc_filename_static(const char * path, const char * bas ext = NULL; } + if (!upper_case) { + for (int i=0; i < strlen(ext); i++) + ext[i] = tolower(ext[i]); + } + filename = util_alloc_filename(path , base , ext); free(ext); @@ -570,24 +545,134 @@ int ecl_util_fname_report_cmp(const void *f1, const void *f2) { starts. */ +static bool numeric_extension_predicate(const char * filename, const char * base, const char leading_char) { + if (strncmp(filename, base, strlen(base)) != 0) + return false; + + const char * ext_start = strrchr(filename, '.'); + if (!ext_start) + return false; + + if (strlen(ext_start) != 6) + return false; + + if (ext_start[1] != leading_char) + return false; + + for (int i=0; i < 4; i++) + if (!isdigit(ext_start[i+2])) + return false; + + return true; +} + + +static bool summary_UPPERCASE_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'A'); +} + +static bool summary_UPPERCASE_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'S'); +} + +static bool summary_lowercase_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'a'); +} + +static bool summary_lowercase_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 's'); +} + +static bool restart_UPPERCASE_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'F'); +} + +static bool restart_UPPERCASE_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'X'); +} + +static bool restart_lowercase_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'f'); +} + +static bool restart_lowercase_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, base, 'x'); +} + +static int ecl_util_select_predicate_filelist(const char * path, const char * base, ecl_file_enum file_type, bool fmt_file, bool upper_case, stringlist_type * filelist) { + file_pred_ftype * predicate = NULL; + char * full_path = NULL; + char * pure_base = NULL; + { + char * tmp = util_alloc_filename(path, base, NULL); + util_alloc_file_components(tmp, &full_path, &pure_base, NULL); + free(tmp); + } + + if (file_type == ECL_SUMMARY_FILE) { + if (fmt_file) { + if (upper_case) + predicate = summary_UPPERCASE_ASCII; + else + predicate = summary_lowercase_ASCII; + } else { + if (upper_case) + predicate = summary_UPPERCASE_BINARY; + else + predicate = summary_lowercase_BINARY; + } + } else if (file_type == ECL_RESTART_FILE) { + if (fmt_file) { + if (upper_case) + predicate = restart_UPPERCASE_ASCII; + else + predicate = restart_lowercase_ASCII; + } else { + if (upper_case) + predicate = restart_UPPERCASE_BINARY; + else + predicate = restart_lowercase_BINARY; + } + } else + util_abort("%s: internal error - method called with wrong file type: %d\n", __func__, file_type); + + stringlist_select_files(filelist, full_path, predicate, pure_base); + stringlist_sort( filelist , ecl_util_fname_report_cmp ); + free(pure_base); + free(full_path); + return stringlist_get_size(filelist); +} int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist) { - char * file_pattern; - char * base_pattern; - const char * extension = ecl_util_get_file_pattern( file_type , fmt_file ); - if (base == NULL) - base_pattern = util_alloc_string_copy( "*" ); - else - base_pattern = util_alloc_string_copy( base ); + bool valid_case = true; + bool upper_case = true; + stringlist_clear(filelist); + + if (base) + valid_case = valid_base(base, &upper_case); + + if (valid_case) { + if (file_type == ECL_SUMMARY_FILE || file_type == ECL_RESTART_FILE) + return ecl_util_select_predicate_filelist(path, base, file_type, fmt_file, upper_case, filelist); + + char * ext_pattern = util_alloc_string_copy(ecl_util_get_file_pattern( file_type , fmt_file )); + char * file_pattern; - file_pattern = util_alloc_filename( NULL , base_pattern , extension ); - stringlist_select_matching_files( filelist , path , file_pattern ); - if ((file_type == ECL_SUMMARY_FILE) || (file_type == ECL_RESTART_FILE)) - stringlist_sort( filelist , ecl_util_fname_report_cmp ); + if (!upper_case) { + for (int i=0; i < strlen(ext_pattern); i++) + ext_pattern[i] = tolower(ext_pattern[i]); + } + + if (base) + file_pattern = util_alloc_filename(NULL , base, ext_pattern); + else + file_pattern = util_alloc_filename(NULL, "*", ext_pattern); - free( base_pattern ); - free( file_pattern ); + stringlist_select_matching_files( filelist , path , file_pattern ); + free( file_pattern ); + free( ext_pattern ); + } return stringlist_get_size( filelist ); } @@ -1274,29 +1359,7 @@ ert_ecl_unit_enum ecl_util_get_unit_set(const char * data_file) { bool ecl_util_valid_basename( const char * basename ) { - - char * eclbasename = util_split_alloc_filename(basename); - - int upper_count = 0; - int lower_count = 0; - int index; - - for (index = 0; index < strlen( eclbasename ); index++) { - int c = eclbasename[index]; - if (isalpha(c)) { - if (isupper(c)) - upper_count++; - else - lower_count++; - } - } - - free(eclbasename); - - if ((lower_count * upper_count) != 0) - return false; - else - return true; + return valid_base(basename, NULL); } @@ -1437,3 +1500,59 @@ void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year) } +#ifdef ERT_HAVE_UNISTD +#include +#endif + +/* + This is a small function which tries to give a sensible answer to the + question: Do I have read access to this eclipse simulation? The ecl_case + argument can either be a directory or the full path to a file, the filename + need not exists. The approach is as follows: + + 1. If @ecl_case corresponds to an existing filesystem entry - just return + access(ecl_case, R_OK). + + 2. If @ecl_case corresponds to a non-existing entry: + + a) If there is a directory part - return access(dir, R_OK). + b) No directory part - return access(cwd, R_OK); + + For the case 2b) the situation is that we test for read access to CWD, + that could in principle be denied - but that is a highly contrived + situation and we just return true. + + ecl_util_access_path("PATH") -> access("PATH", R_OK); + ecl_util_access_path("PATH/FILE_EXISTS") -> access("PATH/FILE_EXISTS", R_OK); + ecl_util_access_path("PATH/FILE_DOES_NOT_EXIST") -> access("PATH", R_OK); + ecl_util_access_path("PATH_DOES_NOT_EXIST") -> true +*/ + +bool ecl_util_path_access(const char * ecl_case) { + if (util_access(ecl_case, R_OK)) + return true; + + if (util_access(ecl_case, F_OK)) + return false; + + /* Check if the input argument corresponds to an existing directory and one + additional element, in that case we do an access check on the directory part. */ + + { + bool path_access; + char * dir_name; + const char * path_sep = strrchr(ecl_case, UTIL_PATH_SEP_CHAR); + + if (!path_sep) + /* We are trying to access CWD - we return true without actually checking + access. */ + return true; + + + dir_name = util_alloc_substring_copy(ecl_case, 0, path_sep - ecl_case); + path_access = util_access(dir_name, R_OK); + free(dir_name); + return path_access; + } + return false; +} diff --git a/ThirdParty/Ert/lib/ecl/fault_block_layer.c b/ThirdParty/Ert/lib/ecl/fault_block_layer.c index 9466515b42..a73e4e91ea 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block_layer.c +++ b/ThirdParty/Ert/lib/ecl/fault_block_layer.c @@ -34,7 +34,7 @@ The fault_block object is implemented as a separate object type in the fault_block.c file; however the fault blocks should be closely linked to the layer object in the fault_block_layer structure - it - is therefor not possible/legal to create a fault block instance by + is therefore not possible/legal to create a fault block instance by itself. To support that encapsulation the fault_block.c file is included here, and the functions: diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.c b/ThirdParty/Ert/lib/ecl/smspec_node.c index 412b027731..b96e0b69e8 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.c +++ b/ThirdParty/Ert/lib/ecl/smspec_node.c @@ -197,7 +197,7 @@ char * smspec_alloc_completion_num_key( const char * join_string , const char * To support ECLIPSE behaviour where new wells/groups can be created during the simulation it must be possible to create a smspec node with an initially unknown well/group name; all gen_key formats which - use the wgname value must therefor accept a NULL value for wgname. + use the wgname value must therefore accept a NULL value for wgname. */ static char * smspec_alloc_wgname_key( const char * join_string , const char * keyword , const char * wgname) { diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c index b4adf52270..efc1727ef0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 #include @@ -40,7 +40,10 @@ void test_invalid( ecl_grid_type * grid) { void test_OK( const ecl_grid_type * grid) { double x,y,z; - + double x8[8]; + double y8[8]; + double z8[8]; + ecl_grid_get_corner_xyz( grid , 0,0,0,&x,&y,&z); test_assert_double_equal( x,0 ); test_assert_double_equal( y,0 ); @@ -55,6 +58,14 @@ void test_OK( const ecl_grid_type * grid) { test_assert_double_equal( x,10 ); test_assert_double_equal( y,10 ); test_assert_double_equal( z,10 ); + + ecl_grid_export_cell_corners1(grid, 456, x8, y8, z8); + for (int i=0; i < 8; i++) { + ecl_grid_get_cell_corner_xyz1(grid, 456, i, &x,&y,&z); + test_assert_double_equal(x,x8[i]); + test_assert_double_equal(y,y8[i]); + test_assert_double_equal(z,z8[i]); + } } @@ -65,7 +76,7 @@ int main( int argc , char ** argv) { test_invalid( grid ); test_OK(grid); - + ecl_grid_free( grid ); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c index d89181e6fe..649541b669 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c @@ -1,25 +1,23 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 #include -#include - #include #include #include @@ -32,11 +30,10 @@ int main( int argc , char ** argv) { int num_kw = 1000; // Total file size should roughly exceed 2GB int kw_size = 600000; ecl_kw_type * kw = ecl_kw_alloc("KW" , kw_size , ECL_INT ); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); int i; offset_type file_size; - for (i=0; i < kw_size; i++) - ecl_kw_iset_int( kw , i , rng_get_int( rng , 912732 )); + for (i=0; i < kw_size; i++) + ecl_kw_iset_int( kw , i , i); { fortio_type * fortio = fortio_open_writer( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); @@ -73,7 +70,7 @@ int main( int argc , char ** argv) { fortio_fclose( fortio ); printf("Seek OK \n"); } - + printf("Doing ecl_file_open(..)\n"); { @@ -87,6 +84,6 @@ int main( int argc , char ** argv) { } remove( "LARGE_FILE.UNRST" ); - + exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c index 98d832f818..961601dd2b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c @@ -20,7 +20,7 @@ #include #include - +#include #include void test_sort( ecl_smspec_type * smspec ) @@ -39,6 +39,18 @@ void test_sort( ecl_smspec_type * smspec ) } +void test_copy(const ecl_smspec_type * smspec1) { + ecl_sum_type * ecl_sum2 = ecl_sum_alloc_writer("CASE", false, true, ":", 0, true, 100, 100, 100); + ecl_smspec_type * smspec2 = ecl_sum_get_smspec(ecl_sum2); + for (int i=0; i < ecl_smspec_num_nodes(smspec1); i++) { + const smspec_node_type * node = ecl_smspec_iget_node(smspec1, i); + ecl_sum_add_smspec_node(ecl_sum2, node); + } + test_assert_true( ecl_smspec_equal(smspec1, smspec2)); + ecl_sum_free(ecl_sum2); +} + + int main(int argc, char ** argv) { const char * case1 = argv[1]; const char * case2 = argv[2]; diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c new file mode 100644 index 0000000000..142e8073ae --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c @@ -0,0 +1,98 @@ + +#include + +#include +#include + +ecl_sum_type * test_alloc_ecl_sum() { + time_t start_time = util_make_date_utc( 1,1,2010 ); + ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( "/tmp/CASE" , false , true , ":" , start_time , true , 10 , 10 , 10 ); + double sim_seconds = 0; + + int num_dates = 4; + double ministep_length = 86400; // seconds in a day + + smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); + smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); + smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + + for (int report_step = 0; report_step < num_dates; report_step++) { + { + ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum , report_step + 1 , sim_seconds ); + ecl_sum_tstep_set_from_node( tstep , node1 , report_step*2.0 ); + ecl_sum_tstep_set_from_node( tstep , node2 , report_step*4.0 + 2.0 ); + ecl_sum_tstep_set_from_node( tstep , node3 , report_step*6.0 + 4.0 ); + } + sim_seconds += ministep_length * 3; + + } + return ecl_sum; +} + +void test_correct_time_vector() { + + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 2,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 4,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 6,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 8,1,2010 )); + ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_resample(ecl_sum, "kk", t); + test_assert_int_equal( ecl_sum_get_report_time(ecl_sum_resampled, 2) , util_make_date_utc( 6,1,2010 )); + + const ecl_smspec_type * smspec_resampled = ecl_sum_get_smspec(ecl_sum_resampled); + const smspec_node_type * node1 = ecl_smspec_iget_node(smspec_resampled, 1); + const smspec_node_type * node2 = ecl_smspec_iget_node(smspec_resampled, 2); + const smspec_node_type * node3 = ecl_smspec_iget_node(smspec_resampled, 3); + test_assert_string_equal( "BPR" , smspec_node_get_keyword(node2) ); + test_assert_string_equal( "BARS" , smspec_node_get_unit(node2) ); + + test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 6,1,2010 ), node1) ); + test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 2,1,2010 ), node2) ); + test_assert_double_equal(10.0000, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 4,1,2010 ), node3) ); + + + ecl_sum_free(ecl_sum_resampled); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_time_before() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2009 )); + test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_time_after() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 11,1,2010 )); + test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_not_sorted() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 3,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 2,1,2010 )); + test_assert_NULL( ecl_sum_alloc_resample( ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + + +int main() { + test_correct_time_vector(); + test_time_before(); + test_time_after(); + test_not_sorted(); + return 0; +} + diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c index 11523e1ae9..d10a2142b3 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c @@ -63,7 +63,7 @@ void test_is_oil_producer( const ecl_sum_type * ecl_sum) { int main( int argc , char ** argv) { const char * case1 = argv[1]; - + ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":"); test_assert_true( ecl_sum_is_instance( ecl_sum1 )); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c index a66c9f9f02..f1691a943d 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c @@ -61,7 +61,7 @@ double write_summary( const char * name , time_t start_time , int nx , int ny , int write_restart_summary(const char * name, const char * restart_name , int start_report_step, double sim_seconds, time_t start_time , int nx , int ny , int nz , int num_dates, int num_ministep, double ministep_length) { ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( name , restart_name, false , true , ":" , start_time , true , nx , ny , nz ); - + smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); @@ -70,8 +70,6 @@ int write_restart_summary(const char * name, const char * restart_name , int sta int num_report_steps = start_report_step + num_dates; for (int report_step = start_report_step; report_step < num_report_steps; report_step++) { for (int step = 0; step < num_ministep; step++) { - - { ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum , report_step + 1 , sim_seconds ); ecl_sum_tstep_set_from_node( tstep , node1 , sim_seconds); @@ -147,7 +145,7 @@ void test_ecl_sum_alloc_restart_writer() { int num_ministep = 10; double ministep_length = 36000; // Seconds - int sim_seconds = write_summary( name1 , start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); + int sim_seconds = write_summary( name1 , start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); sim_seconds = write_restart_summary( name2 , name1 , num_dates, sim_seconds, start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); ecl_sum_type * case1 = ecl_sum_fread_alloc_case( name1 , ":" ); @@ -157,20 +155,20 @@ void test_ecl_sum_alloc_restart_writer() { test_assert_true( ecl_sum_has_key( case2 , "FOPT" )); ecl_file_type * restart_file = ecl_file_open( "CASE2.SMSPEC" , 0 ); - ecl_file_view_type * view_file = ecl_file_get_global_view( restart_file ); + ecl_file_view_type * view_file = ecl_file_get_global_view( restart_file ); test_assert_true( ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type * kw = ecl_file_view_iget_kw(view_file, 0); - test_assert_int_equal(8, ecl_kw_get_size(kw)); - test_assert_string_equal( "CASE1 ", ecl_kw_iget_ptr( kw , 0 ) ); - test_assert_string_equal( " ", ecl_kw_iget_ptr( kw , 1 ) ); + ecl_kw_type * restart_kw = ecl_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); + test_assert_string_equal( "CASE1 ", ecl_kw_iget_ptr( restart_kw , 0 ) ); + test_assert_string_equal( " ", ecl_kw_iget_ptr( restart_kw , 1 ) ); - for (int time_index=0; time_index < ecl_sum_get_data_length( case1 ); time_index++) + for (int time_index=0; time_index < ecl_sum_get_data_length( case1 ); time_index++) test_assert_double_equal( ecl_sum_get_general_var( case1 , time_index , "FOPT"), ecl_sum_get_general_var( case2 , time_index , "FOPT")); ecl_sum_free(case2); ecl_sum_free(case1); ecl_file_close(restart_file); - + } test_work_area_free( work_area ); } @@ -186,27 +184,35 @@ void test_long_restart_names() { const char * name = "THE_CASE"; test_work_area_type * work_area = test_work_area_alloc("sum_write_restart_long_name"); { + int restart_step = 77; time_t start_time = util_make_date_utc( 1,1,2010 ); - ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( name , restart_case , false , true , ":" , start_time , true , 3, 3, 3); + ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer2( name , restart_case , restart_step, false , true , ":" , start_time , true , 3, 3, 3); ecl_sum_fwrite( ecl_sum ); ecl_sum_free(ecl_sum); - + ecl_file_type * smspec_file = ecl_file_open( "THE_CASE.SMSPEC" , 0 ); - ecl_file_view_type * view_file = ecl_file_get_global_view( smspec_file ); + ecl_file_view_type * view_file = ecl_file_get_global_view( smspec_file ); test_assert_true( ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type * kw = ecl_file_view_iget_kw(view_file, 0); - test_assert_int_equal(8, ecl_kw_get_size(kw)); + ecl_kw_type * restart_kw = ecl_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); for (int n = 0; n < 8; n++) { char s[9]; sprintf(s, "WWWWGGG%d", n); - test_assert_string_equal(s, ecl_kw_iget_char_ptr(kw, n) ); + test_assert_string_equal(s, ecl_kw_iget_char_ptr(restart_kw, n) ); + } + ecl_file_close( smspec_file); + { + ecl_smspec_type * smspec = ecl_smspec_alloc_restart_writer( ":" , "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", 10, start_time, true, 3, 3 ,3); + /* + Restart case is too long - it is ignored. + */ + test_assert_NULL( ecl_smspec_get_restart_case( smspec)); + ecl_smspec_free( smspec); } - - test_assert_NULL( ecl_smspec_alloc_writer( ":" , "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", start_time, true, 3, 3 ,3) ); } test_work_area_free( work_area ); - + } int main( int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c new file mode 100644 index 0000000000..45b2256f85 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c @@ -0,0 +1,120 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + The file 'ecl_util_filenames.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include +#include + +#include + + +void test_filename_report_nr() { + test_assert_int_equal(78, ecl_util_filename_report_nr("Path/with/mixedCASE/case.x0078")); + test_assert_int_equal(78, ecl_util_filename_report_nr("Case.X0078")); + test_assert_int_equal(ECL_EGRID_FILE, ecl_util_get_file_type("path/WITH/xase/MyGrid.EGrid", NULL, NULL)); +} + +void test_filename_case() { + test_assert_NULL( ecl_util_alloc_filename(NULL, "mixedBase", ECL_EGRID_FILE, false, -1)); + test_assert_string_equal( ecl_util_alloc_filename(NULL, "UPPER", ECL_EGRID_FILE, false, -1), "UPPER.EGRID"); + test_assert_string_equal( ecl_util_alloc_filename(NULL , "lower", ECL_EGRID_FILE, false, -1), "lower.egrid"); +} + + +void test_file_list() { + test_work_area_type * work_area = test_work_area_alloc("RESTART_FILES"); + stringlist_type * s = stringlist_alloc_new(); + + for (int i = 0; i < 10; i += 2) { + char * fname = ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, true, i); + FILE * stream = util_fopen(fname, "w"); + fclose(stream); + free( fname); + } + + for (int i = 0; i < 10; i += 2) { + char * fname = util_alloc_sprintf("Case.F%04d", i); + FILE * stream = util_fopen(fname, "w"); + fclose(stream); + free( fname); + } + + + ecl_util_select_filelist(NULL , "case" , ECL_RESTART_FILE, true, s); + test_assert_int_equal( stringlist_get_size(s), 5); + for (int i = 0; i < 5; i++) { + char * fname = ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, true, 2*i); + test_assert_string_equal( fname, stringlist_iget(s,i)); + free( fname); + } + + ecl_util_select_filelist(NULL , "Case" , ECL_RESTART_FILE, true, s); + test_assert_int_equal( stringlist_get_size(s), 0); + + + util_make_path("path"); + for (int i=0; i < 10; i++) { + char * summary_file1 = ecl_util_alloc_filename("path", "CASE1", ECL_SUMMARY_FILE, false, i ); + char * summary_file2 = ecl_util_alloc_filename("path", "CASE2", ECL_SUMMARY_FILE, true, i); + char * restart_file1 = ecl_util_alloc_filename("path", "CASE1", ECL_RESTART_FILE, false, i); + + FILE * f1 = fopen(summary_file1, "w"); + fclose(f1); + + FILE * f2 = fopen(summary_file2, "w"); + fclose(f2); + + FILE * f3 = fopen(restart_file1, "w"); + fclose(f3); + + free(summary_file1); + free(summary_file2); + free(restart_file1); + } + printf("-----------------------------------------------------------------\n"); + ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, false, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 0); + + ecl_util_select_filelist(NULL, "path/CASE2", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, false, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 0); + + ecl_util_select_filelist("path", "CASE2", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + stringlist_free(s); + test_work_area_free(work_area); +} + + +int main(int argc , char ** argv) { + test_filename_report_nr(); + test_filename_case(); + test_file_list(); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c new file mode 100644 index 0000000000..1273184503 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c @@ -0,0 +1,53 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + The file 'ecl_util_path_access.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + +#include + + +void test_relative_access() { + test_work_area_type * work_area = test_work_area_alloc("access"); + test_assert_false( ecl_util_path_access("No/directory/does/not/exist")); + + util_make_path("path"); + test_assert_true( ecl_util_path_access("path")); + test_assert_true( ecl_util_path_access("path/FILE_DOES_NOT_EXIST")); + + { + FILE * f = util_fopen("path/file", "w"); + fprintf(f,"Hello\n"); + fclose(f); + } + test_assert_true( ecl_util_path_access("path/file")); + chmod("path/file", 0); + test_assert_false( ecl_util_path_access("path/file")); + + test_assert_true( ecl_util_path_access("ECLIPSE_CASE")); + test_work_area_free( work_area ); +} + + +int main(int argc, char ** argv) { + test_relative_access(); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c index bd6d410d3a..39daebd45e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c @@ -62,8 +62,12 @@ int main(int argc , char ** argv) { test_assert_true( well_segment_is_instance( well_branch_collection_iget_start_segment( branches , 0 ))); test_assert_true( well_segment_is_instance( well_branch_collection_get_start_segment( branches , 78 ))); test_assert_true( well_branch_collection_has_branch( branches , 78 )); + + well_segment_free( segment2 ); + well_segment_free( segment1 ); } + free( rseg_data ); well_branch_collection_free( branches ); exit(0); diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn.c b/ThirdParty/Ert/lib/ecl/tests/well_conn.c index b788d95f7c..a1c8583eb3 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn.c @@ -77,6 +77,8 @@ int main(int argc , char ** argv) { test_assert_true( well_conn_equal( conn , conn2 )); test_assert_false( well_conn_equal( conn , conn3 )); test_assert_double_equal( CF , well_conn_get_connection_factor( conn )); + well_conn_free( conn3 ); + well_conn_free( conn2 ); well_conn_free( conn ); } @@ -107,6 +109,7 @@ int main(int argc , char ** argv) { well_conn_dir_enum dir = well_conn_dirX; well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open); test_assert_not_NULL( conn ); + well_conn_free( conn ); } { diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment.c b/ThirdParty/Ert/lib/ecl/tests/well_segment.c index a3f1cce752..79426e62fd 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment.c @@ -72,6 +72,7 @@ int main(int argc , char ** argv) { test_assert_true( well_segment_nearest_wellhead( ws )); test_assert_false( well_segment_main_stem( ws )); + well_segment_free( ws ); } @@ -81,6 +82,7 @@ int main(int argc , char ** argv) { well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data); test_assert_false( well_segment_active( ws )); + well_segment_free( ws ); } { @@ -96,6 +98,7 @@ int main(int argc , char ** argv) { well_segment_link_strict( ws , outlet ); // This relinks - not very logical; refcount gets wrong. well_segment_free( ws ); + well_segment_free( outlet ); } { @@ -109,6 +112,7 @@ int main(int argc , char ** argv) { test_assert_int_equal( well_segment_get_link_count( outlet ) , 0 ); well_segment_free( ws ); + well_segment_free( outlet ); } free( rseg_data ); exit(0); diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c index c1dbdf2591..b3886e604c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c @@ -55,6 +55,10 @@ int main(int argc , char ** argv) { test_assert_true( well_conn_collection_is_instance( well_segment_get_connections( ws , ECL_GRID_GLOBAL_GRID))); test_assert_true( well_conn_collection_is_instance( well_segment_get_global_connections( ws))); test_assert_NULL( well_segment_get_connections( ws , "doesNotExist")); + + well_conn_free( conn1 ); + well_conn_free( conn2 ); + well_segment_free( ws ); } free( rseg_data ); exit(0); diff --git a/ThirdParty/Ert/lib/ert_api_config.h.in b/ThirdParty/Ert/lib/ert_api_config.h.in index 11b43d6b19..08c3e5da96 100644 --- a/ThirdParty/Ert/lib/ert_api_config.h.in +++ b/ThirdParty/Ert/lib/ert_api_config.h.in @@ -1,4 +1,3 @@ -#cmakedefine ERT_HAVE_LAPACK #cmakedefine ERT_HAVE_ZLIB #cmakedefine ERT_HAVE_ISFINITE #cmakedefine ERT_HAVE_GETOPT diff --git a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp index d703a71751..34ad650fcd 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp @@ -107,7 +107,7 @@ inline const char* EclKW_ref< const char* >::at( size_t i ) const { /* The current implementation of "string" storage in the underlying C ecl_kw structure does not lend itself to easily implement - operator[]. We have therefor explicitly deleted it here. + operator[]. We have therefore explicitly deleted it here. */ template<> diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h index 3c9cd71060..0e8689fa6f 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h @@ -254,6 +254,7 @@ extern "C" { void ecl_grid_reset_actnum( ecl_grid_type * grid , const int * actnum ); void ecl_grid_compressed_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); void ecl_grid_global_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); + void ecl_grid_export_cell_corners1(const ecl_grid_type * grid, int global_index, double *x, double *y, double *z); UTIL_IS_INSTANCE_HEADER( ecl_grid ); UTIL_SAFE_CAST_HEADER( ecl_grid ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h index 60d3561b3e..9eacaf31ef 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h @@ -174,6 +174,7 @@ extern "C" { ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target_size , const int * mapping, void * def_value); + void ecl_kw_inplace_add_squared(ecl_kw_type * target_kw, const ecl_kw_type * add_kw); void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw); void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw); void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h index 71d31dc402..8c0f50db65 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h @@ -303,7 +303,9 @@ values (2e20) are denoted with '*'. #define INTEHEAD_TIMESTEP_INDEX 67 #define INTEHEAD_REPORT_STEP 68 #define INTEHEAD_IPROG_INDEX 94 -#define INTEHEAD_REPORT_INDEX 219 (report_steps-1) + +// The value seems to be: report_step - 1; might be previous? +#define INTEHEAD_REPORT_INDEX 219 #define INTEHEAD_METRIC_VALUE 1 @@ -339,6 +341,7 @@ values (2e20) are denoted with '*'. #define LOGIHEAD_REV_ENDPOINT_SCALING_INDEX 18 #define LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX 19 #define LOGIHEAD_MISC_DISPLACEMENT_INDEX 35 +#define LOGIHEAD_CONSTANT_OILCOMPR_INDEX (39-1) /* Constant oil compressibility (PVCDO)? */ #define LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX 55 #define LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX 56 @@ -450,12 +453,16 @@ values (2e20) are denoted with '*'. keyword in the SMSPEC files. Observe that these magic indices differ from the magic indices used to look up grid dimensions from the DIMENS keyword in GRID files. */ -#define DIMENS_SMSPEC_SIZE_INDEX 0 -#define DIMENS_SMSPEC_NX_INDEX 1 -#define DIMENS_SMSPEC_NY_INDEX 2 -#define DIMENS_SMSPEC_NZ_INDEX 3 - -#define DIMENS_SIZE 6 // Do not know what the two last items are? +#define DIMENS_SMSPEC_SIZE_INDEX 0 +#define DIMENS_SMSPEC_NX_INDEX 1 +#define DIMENS_SMSPEC_NY_INDEX 2 +#define DIMENS_SMSPEC_NZ_INDEX 3 +#define DIMENS_SMSPEC_RESTART_STEP_INDEX 5 +#define DIMENS_SIZE 6 + +#define INTEHEAD_SMSPEC_SIZE 2 +#define INTEHEAD_SMSPEC_UNIT_INDEX 0 +#define INTEHEAD_SMSPEC_IPROG_INDEX 1 /* Summary data files: */ diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h index 1afed73c7d..f42e5c338b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h @@ -29,6 +29,7 @@ extern "C" { #include #include +#include #include typedef struct ecl_smspec_struct ecl_smspec_type; @@ -54,7 +55,11 @@ typedef struct ecl_smspec_struct ecl_smspec_type; bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); const char * ecl_smspec_get_var_type_name( ecl_smspec_var_type var_type ); ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var); - ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const char * restart_case, time_t sim_start , bool time_in_days , int nx , int ny , int nz); + ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string); + + ecl_smspec_type * ecl_smspec_alloc_restart_writer( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz); + + ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz); void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , bool fmt_file ); ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * key_join_string , bool include_restart); @@ -128,6 +133,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , const char * pattern); stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec ); const char * ecl_smspec_get_simulation_path(const ecl_smspec_type * ecl_smspec); + int ecl_smspec_get_restart_step(const ecl_smspec_type * ecl_smspec); const char * ecl_smspec_get_restart_case( const ecl_smspec_type * ecl_smspec); const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec); const float_vector_type * ecl_smspec_get_params_default( const ecl_smspec_type * ecl_smspec ); @@ -144,6 +150,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; bool ecl_smspec_equal( const ecl_smspec_type * self , const ecl_smspec_type * other); void ecl_smspec_sort( ecl_smspec_type * smspec ); + ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type * smspec); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h index 60080768bc..5c2f8fdc96 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h @@ -94,6 +94,7 @@ typedef struct ecl_sum_struct ecl_sum_type; ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string, bool include_restart); ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string); ecl_sum_type * ecl_sum_fread_alloc_case__(const char * , const char * key_join_string , bool include_restart); + ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times); bool ecl_sum_case_exists( const char * input_file ); /* Accessor functions : */ @@ -170,6 +171,7 @@ typedef struct ecl_sum_struct ecl_sum_type; const char * ecl_sum_get_base(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_path(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_abs_path(const ecl_sum_type * ecl_sum ); + const ecl_sum_type * ecl_sum_get_restart_case(const ecl_sum_type * ecl_sum); const char * ecl_sum_get_case(const ecl_sum_type * ); bool ecl_sum_same_case( const ecl_sum_type * ecl_sum , const char * input_file ); @@ -200,7 +202,18 @@ typedef struct ecl_sum_struct ecl_sum_type; int ecl_sum_iget_report_end( const ecl_sum_type * ecl_sum , int report_step ); int ecl_sum_iget_report_start( const ecl_sum_type * ecl_sum , int report_step ); - + ecl_sum_type * ecl_sum_alloc_restart_writer2( const char * ecl_case, + const char * restart_case, + int restart_step, + bool fmt_output, + bool unified, + const char * key_join_string, + time_t sim_start, + bool time_in_days, + int nx, + int ny, + int nz); + ecl_sum_type * ecl_sum_alloc_restart_writer(const char * ecl_case , const char * restart_case , bool fmt_output , @@ -221,6 +234,7 @@ typedef struct ecl_sum_struct ecl_sum_type; void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); + smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node); smspec_node_type * ecl_sum_add_var(ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h index d460a23129..1ab5dc1e8f 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h @@ -30,14 +30,17 @@ extern "C" { typedef struct ecl_sum_vector_struct ecl_sum_vector_type; void ecl_sum_vector_free( ecl_sum_vector_type * keylist ); - ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum); + ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords); bool ecl_sum_vector_add_key( ecl_sum_vector_type * keylist, const char * key); void ecl_sum_vector_add_keys( ecl_sum_vector_type * keylist, const char * pattern); + const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index); bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index); int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index); int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector); + bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index); + UTIL_IS_INSTANCE_HEADER( ecl_sum_vector); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h index 67cca9cde2..7dea54f480 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h @@ -96,7 +96,6 @@ typedef enum { #define ECL_PHASE_ENUM_DEFS {.value = 1 , .name = "ECL_OIL_PHASE"}, {.value = 2 , .name = "ECL_GAS_PHASE"} , {.value = 4 , .name = "ECL_WATER_PHASE"} #define ECL_PHASE_ENUM_SIZE 3 - typedef enum { ECL_METRIC_UNITS = 1, ECL_FIELD_UNITS = 2, @@ -118,8 +117,8 @@ bool ecl_util_unified_file(const char *filename); const char * ecl_util_file_type_name( ecl_file_enum file_type ); char * ecl_util_alloc_base_guess(const char *); int ecl_util_filename_report_nr(const char *); -ecl_file_enum ecl_util_get_file_type(const char * , bool * , int * ); ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int * _report_nr); +ecl_file_enum ecl_util_get_file_type(const char * filename, bool * fmt_file, int * report_nr); char * ecl_util_alloc_filename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/); char * ecl_util_alloc_exfilename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/); void ecl_util_memcpy_typed_data(void *, const void * , ecl_data_type , ecl_data_type , int ); @@ -145,7 +144,7 @@ int ecl_util_select_filelist( const char * path , const char * base void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end); void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date); void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year); - +bool ecl_util_path_access(const char * ecl_case); #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash.h b/ThirdParty/Ert/lib/include/ert/util/hash.h index dcc862f0cc..cc7dfbb200 100644 --- a/ThirdParty/Ert/lib/include/ert/util/hash.h +++ b/ThirdParty/Ert/lib/include/ert/util/hash.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'hash.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'hash.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. */ #ifndef ERT_HASH_H @@ -35,10 +35,7 @@ typedef void (hash_apply_ftype) (void * ); UTIL_SAFE_CAST_HEADER(hash); UTIL_SAFE_CAST_HEADER_CONST(hash); -void hash_lock (hash_type * ); -void hash_unlock(hash_type * ); hash_type * hash_alloc(void); -hash_type * hash_alloc_unlocked(void); void hash_iter_complete(hash_type * ); void hash_free(hash_type *); void hash_free__(void *); @@ -55,12 +52,12 @@ void hash_safe_del(hash_type * , const char * ); void hash_clear(hash_type *); int hash_get_size(const hash_type *); void hash_set_keylist(const hash_type * , char **); -char ** hash_alloc_keylist(hash_type *); -stringlist_type * hash_alloc_stringlist(hash_type * ); +char ** hash_alloc_keylist(const hash_type *); +stringlist_type * hash_alloc_stringlist(const hash_type * ); -char ** hash_alloc_sorted_keylist (hash_type *hash , int ( hash_get_cmp_value ) (const void *)); -char ** hash_alloc_key_sorted_list(hash_type *hash, int (*cmp)(const void *, const void *)); -bool hash_key_list_compare( hash_type * hash1, hash_type * hash2); +char ** hash_alloc_sorted_keylist (const hash_type *hash , int ( hash_get_cmp_value ) (const void *)); +char ** hash_alloc_key_sorted_list(const hash_type *hash, int (*cmp)(const void *, const void *)); +bool hash_key_list_compare(const hash_type * hash1, const hash_type * hash2); void hash_insert_hash_owned_ref(hash_type *, const char * , const void *, free_ftype *); void hash_resize(hash_type *hash, int new_size); diff --git a/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h b/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h index 396185b107..ebe515e384 100644 --- a/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h +++ b/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h @@ -4,12 +4,12 @@ - The ERT code makes use of stdbool in many places. The msvc C compiler does not have a stdbool header, i.e. the #include - statements fail when compiling. + statements fail when compiling. - When included in a C++ project the compiler already has a bool - defined; it is therefor important not to redefine this symbol if + defined; it is therefore important not to redefine this symbol if we are compiling C++. - + */ #ifndef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/util/stringlist.h b/ThirdParty/Ert/lib/include/ert/util/stringlist.h index 597bba63c9..85f6e130cf 100644 --- a/ThirdParty/Ert/lib/include/ert/util/stringlist.h +++ b/ThirdParty/Ert/lib/include/ert/util/stringlist.h @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef __cplusplus extern "C" { @@ -34,6 +33,9 @@ extern "C" { typedef struct stringlist_struct stringlist_type; typedef int ( string_cmp_ftype) (const void * , const void *); +typedef bool ( file_pred_ftype) (const char *, const void *); + + int stringlist_select_files(stringlist_type * names, const char * path, file_pred_ftype * predicate, const void * pred_arg); const char * stringlist_get_last( const stringlist_type * stringlist ); char * stringlist_pop( stringlist_type * stringlist); @@ -103,8 +105,6 @@ typedef int ( string_cmp_ftype) (const void * , const void *); char ** stringlist_alloc_char_ref(const stringlist_type * stringlist); void stringlist_fread(stringlist_type * , FILE * ); void stringlist_fwrite(const stringlist_type * , FILE * ); - void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer ); - void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer ); void stringlist_sort(stringlist_type * , string_cmp_ftype * string_cmp); void stringlist_reverse( stringlist_type * s ); void stringlist_python_sort( stringlist_type * s , int cmp_flag); diff --git a/ThirdParty/Ert/lib/include/ert/util/util.h b/ThirdParty/Ert/lib/include/ert/util/util.h index 56c7408f5e..8549300f9a 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.h +++ b/ThirdParty/Ert/lib/include/ert/util/util.h @@ -134,8 +134,6 @@ typedef enum {left_pad = 0, bool util_sscanf_date_utc(const char * , time_t *); bool util_sscanf_isodate(const char * , time_t *); bool util_sscanf_percent(const char * string, double * value); - char * util_alloc_stdin_line(void); - char * util_realloc_stdin_line(char * ); bool util_is_executable(const char * ); bool util_entry_exists( const char * entry ); bool util_file_exists(const char *); @@ -164,6 +162,7 @@ typedef enum {left_pad = 0, bool util_copy_file(const char * , const char * ); char * util_alloc_cwd(void); bool util_is_cwd( const char * path ); + char * util_alloc_normal_path( const char * input_path ); char * util_alloc_realpath(const char * ); char * util_alloc_realpath__(const char * input_path); bool util_string_match(const char * string , const char * pattern); @@ -175,7 +174,6 @@ typedef enum {left_pad = 0, void util_usleep( unsigned long micro_seconds ); void util_yield(void); - char * util_blocking_alloc_stdin_line(unsigned long ); int util_roundf( float x ); int util_round( double x ); @@ -213,7 +211,7 @@ typedef enum {left_pad = 0, int util_count_file_lines(FILE * ); FILE * util_mkdir_fopen( const char * filename , const char * mode ); int util_fmove( FILE * stream , long offset , long shift); - FILE * util_fopen(const char * , const char *); + FILE * util_fopen(const char * , const char *); FILE * util_fopen__(const char * filename , const char * mode); void util_fclose( FILE * stream ); bool util_fopen_test(const char *, const char *); @@ -238,14 +236,7 @@ typedef enum {left_pad = 0, bool util_sscanf_int(const char * , int * ); const char * util_parse_int(const char * , int * , bool *); const char * util_skip_sep(const char * , const char * , bool *); - int util_scanf_int_with_limits(const char * , int , int , int ); - char * util_scanf_int_with_limits_return_char(const char * , int , int , int ); - void util_printf_prompt(const char * , int , char , const char *); - int util_scanf_int(const char * , int); - char * util_scanf_int_return_char(const char * , int); - double util_scanf_double(const char * prompt , int prompt_len); - char * util_scanf_alloc_string(const char * ); - bool util_sscanf_double(const char * , double * ); + bool util_sscanf_double(const char * , double * ); //char * util_alloc_full_path(const char *, const char *); char * util_alloc_filename(const char * , const char * , const char * ); char * util_realloc_filename(char * , const char * , const char * , const char * ); @@ -340,9 +331,6 @@ typedef enum {left_pad = 0, double util_double_min(double , double ); void util_fskip_lines(FILE * , int); bool util_same_file(const char * , const char * ); - void util_read_path(const char * , int , bool , char * ); - char * util_fscanf_alloc_filename(const char * , int , int); - void util_read_string(const char * , int , char * ); void util_fread (void *, size_t , size_t , FILE * , const char * ); void util_fwrite(const void *, size_t , size_t , FILE * , const char * ); time_t util_fread_time_t(FILE * stream); @@ -382,17 +370,21 @@ typedef enum {left_pad = 0, int util_fnmatch( const char * pattern , const char * string ); void util_time_utc( time_t * t , struct tm * ts ); - char ** util_alloc_PATH_list(void); - char * util_alloc_PATH_executable(const char * executable ); - char * util_isscanf_alloc_envvar( const char * string , int env_index ); - void util_setenv( const char * variable , const char * value); - const char * util_interp_setenv( const char * variable , const char * value); - void util_unsetenv( const char * variable); - char * util_alloc_envvar( const char * value ); bool util_is_link(const char * ); // Will always return false on windows int util_chdir(const char * path); bool util_chdir_file( const char * filename ); +#ifdef ERT_HAVE_UNISTD +#include + bool util_access(const char * entry, mode_t mode); +#else + bool util_access(const char * entry, int mode); +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#endif + #define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); } #define UTIL_FREAD_SCALAR(s,stream) { \ @@ -495,9 +487,6 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type void util_abort__(const char * file , const char * function , int line , const char * fmt , ...); void util_abort_signal(int ); -void util_abort_append_version_info(const char * ); -void util_abort_free_version_info(void); -void util_abort_set_executable( const char * argv0 ); @@ -521,9 +510,6 @@ void util_abort_set_executable( const char * argv0 ); #ifdef ERT_HAVE_SPAWN pid_t util_spawn(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file); int util_spawn_blocking(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file); -#ifdef ERT_HAVE_PING - bool util_ping( const char * hostname); -#endif #endif diff --git a/ThirdParty/Ert/lib/util/hash.c b/ThirdParty/Ert/lib/util/hash.c index 2062537f76..68e636b8ba 100644 --- a/ThirdParty/Ert/lib/util/hash.c +++ b/ThirdParty/Ert/lib/util/hash.c @@ -30,12 +30,6 @@ #include #include -#ifdef HAVE_PTHREAD -#include -typedef pthread_rwlock_t lock_type; -#else -typedef int lock_type; -#endif #ifdef __cplusplus extern "C" { @@ -71,8 +65,6 @@ struct hash_struct { double resize_fill; hash_sll_type **table; hashf_type *hashf; - - lock_type rwlock; }; @@ -83,54 +75,12 @@ typedef struct hash_sort_node { } hash_sort_type; -/*****************************************************************/ -/* locking */ -/*****************************************************************/ -#ifdef HAVE_PTHREAD - -static void __hash_rdlock(hash_type * hash) { - int lock_error = pthread_rwlock_tryrdlock( &hash->rwlock ); - if (lock_error != 0) - util_abort("%s: did not get hash->read_lock - fix locking in calling scope\n",__func__); -} - - -static void __hash_wrlock(hash_type * hash) { - int lock_error = pthread_rwlock_trywrlock( &hash->rwlock ); - if (lock_error != 0) - util_abort("%s: did not get hash->write_lock - fix locking in calling scope\n",__func__); -} - - -static void __hash_unlock( hash_type * hash) { - pthread_rwlock_unlock( &hash->rwlock ); -} - - -static void LOCK_DESTROY( lock_type * rwlock ) { - pthread_rwlock_destroy( rwlock ); -} - -static void LOCK_INIT( lock_type * rwlock ) { - pthread_rwlock_init( rwlock , NULL); -} - -#else - -static void __hash_rdlock(hash_type * hash) {} -static void __hash_wrlock(hash_type * hash) {} -static void __hash_unlock(hash_type * hash) {} -static void LOCK_DESTROY(lock_type * rwlock) {} -static void LOCK_INIT(lock_type * rwlock) {} - -#endif - /*****************************************************************/ /* Low level access functions */ /*****************************************************************/ -static void * __hash_get_node_unlocked(const hash_type *__hash , const char *key, bool abort_on_error) { +static void * __hash_get_node(const hash_type *__hash , const char *key, bool abort_on_error) { hash_type * hash = (hash_type *) __hash; /* The net effect is no change - but .... ?? */ hash_node_type * node = NULL; { @@ -146,23 +96,6 @@ static void * __hash_get_node_unlocked(const hash_type *__hash , const char *key } -/* - This function looks up a hash_node from the hash. This is the common - low-level function to get content from the hash. The function takes - read-lock which is held during execution. - - Would strongly preferred that the hash_type * was const - but that is - difficult due to locking requirements. -*/ - -static void * __hash_get_node(const hash_type *hash_in , const char *key, bool abort_on_error) { - hash_node_type * node; - hash_type * hash = (hash_type *)hash_in; - __hash_rdlock( hash ); - node = (hash_node_type*)__hash_get_node_unlocked(hash , key , abort_on_error); - __hash_unlock( hash ); - return node; -} static node_data_type * hash_get_node_data(const hash_type *hash , const char *key) { @@ -215,46 +148,37 @@ void hash_resize(hash_type *hash, int new_size) { /** - This is the low-level function for inserting a hash node. This - function takes a write-lock which is held during the execution of - the function. + This is the low-level function for inserting a hash node. */ static void __hash_insert_node(hash_type *hash , hash_node_type *node) { - __hash_wrlock( hash ); + uint32_t table_index = hash_node_get_table_index(node); { - uint32_t table_index = hash_node_get_table_index(node); - { - /* - If a node with the same key already exists in the table - it is removed. - */ - hash_node_type *existing_node = (hash_node_type*)__hash_get_node_unlocked(hash , hash_node_get_key(node) , false); - if (existing_node != NULL) { - hash_sll_del_node(hash->table[table_index] , existing_node); - hash->elements--; - } + /* + If a node with the same key already exists in the table + it is removed. + */ + hash_node_type *existing_node = (hash_node_type*)__hash_get_node(hash , hash_node_get_key(node) , false); + if (existing_node != NULL) { + hash_sll_del_node(hash->table[table_index] , existing_node); + hash->elements--; } - - hash_sll_add_node(hash->table[table_index] , node); - hash->elements++; - if ((1.0 * hash->elements / hash->size) > hash->resize_fill) - hash_resize(hash , hash->size * 2); } - __hash_unlock( hash ); + + hash_sll_add_node(hash->table[table_index] , node); + hash->elements++; + if ((1.0 * hash->elements / hash->size) > hash->resize_fill) + hash_resize(hash , hash->size * 2); } /** - This function deletes a node from the hash_table. Observe that this - function does *NOT* do any locking - it is the repsonsibility of - the calling functions: hash_del() and hash_clear() to take the - necessary write lock. + This function deletes a node from the hash_table. */ -static void hash_del_unlocked__(hash_type *hash , const char *key) { +static void hash_del__(hash_type *hash , const char *key) { const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size); hash_node_type *node = hash_sll_get(hash->table[table_index] , global_index , key); @@ -297,40 +221,32 @@ static hash_node_type * hash_internal_iter_next(const hash_type *hash , const ha This is the low level function which traverses a hash table and allocates a char ** list of keys. - It takes a read-lock which is held during the execution of the - function. The locking guarantees that the list of keys is valid - when this function is exited, but the the hash table can be - subsequently updated. - If the hash table is empty NULL is returned. */ -static char ** hash_alloc_keylist__(hash_type *hash , bool lock) { +static char ** hash_alloc_keylist__(const hash_type *hash) { char **keylist; - if (lock) __hash_rdlock( hash ); - { - if (hash->elements > 0) { - int i = 0; - hash_node_type *node = NULL; - keylist = (char**)calloc(hash->elements , sizeof *keylist); - { - uint32_t i = 0; - while (i < hash->size && hash_sll_empty(hash->table[i])) - i++; - - if (i < hash->size) - node = hash_sll_get_head(hash->table[i]); - } - - while (node != NULL) { - const char *key = hash_node_get_key(node); - keylist[i] = util_alloc_string_copy(key); - node = hash_internal_iter_next(hash , node); + if (hash->elements > 0) { + int i = 0; + hash_node_type *node = NULL; + keylist = (char**)calloc(hash->elements , sizeof *keylist); + { + uint32_t i = 0; + while (i < hash->size && hash_sll_empty(hash->table[i])) i++; - } - } else keylist = NULL; - } - if (lock) __hash_unlock( hash ); + + if (i < hash->size) + node = hash_sll_get_head(hash->table[i]); + } + + while (node != NULL) { + const char *key = hash_node_get_key(node); + keylist[i] = util_alloc_string_copy(key); + node = hash_internal_iter_next(hash , node); + i++; + } + } else + keylist = NULL; return keylist; } @@ -420,9 +336,7 @@ double hash_get_double(const hash_type * hash , const char * key) { /*****************************************************************/ void hash_del(hash_type *hash , const char *key) { - __hash_wrlock( hash ); - hash_del_unlocked__(hash , key); - __hash_unlock( hash ); + hash_del__(hash , key); } /** @@ -431,28 +345,21 @@ void hash_del(hash_type *hash , const char *key) { */ void hash_safe_del(hash_type * hash , const char * key) { - __hash_wrlock( hash ); - if (__hash_get_node_unlocked(hash , key , false)) - hash_del_unlocked__(hash , key); - __hash_unlock( hash ); + if (__hash_get_node(hash , key , false)) + hash_del__(hash , key); } void hash_clear(hash_type *hash) { - __hash_wrlock( hash ); - { - int old_size = hash_get_size(hash); - if (old_size > 0) { - char **keyList = hash_alloc_keylist__( hash , false); - int i; - for (i=0; i < old_size; i++) { - hash_del_unlocked__(hash , keyList[i]); - free(keyList[i]); - } - free(keyList); + int old_size = hash_get_size(hash); + if (old_size > 0) { + char **keyList = hash_alloc_keylist__( hash ); + for (int i=0; i < old_size; i++) { + hash_del__(hash , keyList[i]); + free(keyList[i]); } + free(keyList); } - __hash_unlock( hash ); } @@ -512,8 +419,6 @@ static hash_type * __hash_alloc(int size, double resize_fill , hashf_type *hashf hash->table = hash_sll_alloc_table(hash->size); hash->elements = 0; hash->resize_fill = resize_fill; - LOCK_INIT( &hash->rwlock ); - return hash; } @@ -522,11 +427,6 @@ hash_type * hash_alloc() { return __hash_alloc(HASH_DEFAULT_SIZE , 0.50 , hash_index); } -// Purely a helper in the process of removing the internal locking -// in the hash implementation. -hash_type * hash_alloc_unlocked() { - return __hash_alloc(HASH_DEFAULT_SIZE , 0.50 , hash_index); -} UTIL_SAFE_CAST_FUNCTION( hash , HASH_TYPE_ID) @@ -538,7 +438,6 @@ void hash_free(hash_type *hash) { for (i=0; i < hash->size; i++) hash_sll_free(hash->table[i]); free(hash->table); - LOCK_DESTROY( &hash->rwlock ); free(hash); } @@ -548,13 +447,13 @@ void hash_free__(void * void_hash) { } -char ** hash_alloc_keylist(hash_type *hash) { - return hash_alloc_keylist__(hash , true); +char ** hash_alloc_keylist(const hash_type *hash) { + return hash_alloc_keylist__(hash); } -stringlist_type * hash_alloc_stringlist(hash_type * hash) { +stringlist_type * hash_alloc_stringlist(const hash_type * hash) { stringlist_type * stringlist = stringlist_alloc_new(); - char ** keylist = hash_alloc_keylist__(hash , true); + char ** keylist = hash_alloc_keylist__(hash); int i; for (i = 0; i < hash_get_size( hash ); i++) stringlist_append_owned_ref( stringlist , keylist[i] ); @@ -684,7 +583,7 @@ static int hash_sortlist_cmp(const void *_p1 , const void *_p2) { } -static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void * )) { +static char ** __hash_alloc_ordered_keylist(const hash_type *hash , int ( hash_get_cmp_value) (const void * )) { int i; char **sorted_keylist; char **tmp_keylist = hash_alloc_keylist(hash); @@ -705,7 +604,7 @@ static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp } -char ** hash_alloc_sorted_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void *)) { +char ** hash_alloc_sorted_keylist(const hash_type *hash , int ( hash_get_cmp_value) (const void *)) { char ** key_list; key_list = __hash_alloc_ordered_keylist(hash , hash_get_cmp_value); @@ -722,7 +621,7 @@ static int key_cmp(const void *_s1 , const void *_s2) { } -static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const void * , const void *)) { +static char ** __hash_alloc_key_sorted_list(const hash_type *hash, int (*cmp) (const void * , const void *)) { char **keylist = hash_alloc_keylist(hash); qsort(keylist , hash_get_size(hash) , sizeof *keylist , cmp); @@ -731,7 +630,7 @@ static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const v -char ** hash_alloc_key_sorted_list(hash_type * hash, int (*cmp) (const void *, const void *)) +char ** hash_alloc_key_sorted_list(const hash_type * hash, int (*cmp) (const void *, const void *)) { char ** key_list; @@ -742,7 +641,7 @@ char ** hash_alloc_key_sorted_list(hash_type * hash, int (*cmp) (const void *, c -bool hash_key_list_compare(hash_type * hash1, hash_type * hash2) +bool hash_key_list_compare(const hash_type * hash1, const hash_type * hash2) { bool has_equal_keylist; int i,size1, size2; diff --git a/ThirdParty/Ert/lib/util/path_stack.c b/ThirdParty/Ert/lib/util/path_stack.c index 824be798f4..3d248849e1 100644 --- a/ThirdParty/Ert/lib/util/path_stack.c +++ b/ThirdParty/Ert/lib/util/path_stack.c @@ -1,23 +1,24 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include #include #include #include @@ -47,22 +48,22 @@ struct path_stack_struct { /** This will create a new path_stack instance; it will push anything - on the current stack of paths. + on the current stack of paths. */ path_stack_type * path_stack_alloc() { path_stack_type * path_stack = (path_stack_type*)util_malloc( sizeof * path_stack ); - path_stack->stack = stringlist_alloc_new(); - path_stack->storage = stringlist_alloc_new(); - return path_stack; + path_stack->stack = stringlist_alloc_new(); + path_stack->storage = stringlist_alloc_new(); + return path_stack; } -/* +/* This will destroy the storage taken by the current path_stack instance. This function will NOT pop any elements off the stack; so if you have not manully clerad the stack with the right number of path_stack_pop() calls, you will (probably) destroy the path stack - instance with an incorrect value of cwd. + instance with an incorrect value of cwd. */ void path_stack_free( path_stack_type * path_stack ) { @@ -85,7 +86,7 @@ bool path_stack_push( path_stack_type * path_stack , const char * path ) { if (path != NULL) if (util_chdir( path ) != 0) return false; - + path_stack_push_cwd( path_stack ); return true; } diff --git a/ThirdParty/Ert/lib/util/set.c b/ThirdParty/Ert/lib/util/set.c index 68fbd7a9fc..68ea5ba2ee 100644 --- a/ThirdParty/Ert/lib/util/set.c +++ b/ThirdParty/Ert/lib/util/set.c @@ -40,7 +40,7 @@ static UTIL_SAFE_CAST_FUNCTION( set , SET_TYPE_ID ) set_type * set_alloc(int size, const char ** keyList) { set_type * set = (set_type*) malloc(sizeof * set); UTIL_TYPE_ID_INIT( set , SET_TYPE_ID ); - set->key_hash = hash_alloc_unlocked(); + set->key_hash = hash_alloc(); { int ikey; for (ikey = 0; ikey < size; ikey++) diff --git a/ThirdParty/Ert/lib/util/string_util.c b/ThirdParty/Ert/lib/util/string_util.c index ec7c85b654..12db74bdab 100644 --- a/ThirdParty/Ert/lib/util/string_util.c +++ b/ThirdParty/Ert/lib/util/string_util.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/stringlist.c b/ThirdParty/Ert/lib/util/stringlist.c index b074aabe56..6bd06f9bfe 100644 --- a/ThirdParty/Ert/lib/util/stringlist.c +++ b/ThirdParty/Ert/lib/util/stringlist.c @@ -21,6 +21,11 @@ #include #include +#ifdef ERT_HAVE_OPENDIR +#include +#include +#endif + #ifdef ERT_HAVE_GLOB #include #else @@ -30,8 +35,6 @@ #include #include #include -#include - #define STRINGLIST_TYPE_ID 671855 @@ -621,13 +624,6 @@ stringlist_type * stringlist_alloc_from_split( const char * input_string , const /*****************************************************************/ -void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer ) { - int i; - int size = stringlist_get_size( s ); - buffer_fwrite_int( buffer , size ); - for (i=0; i < size; i++) - buffer_fwrite_string(buffer , stringlist_iget(s , i) ); -} void stringlist_fwrite(const stringlist_type * s, FILE * stream) { @@ -652,13 +648,6 @@ void stringlist_fread(stringlist_type * s, FILE * stream) { } -void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer ) { - int size = buffer_fread_int( buffer ); - int i; - stringlist_clear(s); - for (i=0; i < size; i++) - stringlist_append_owned_ref( s , buffer_fread_alloc_string( buffer )); -} @@ -772,6 +761,68 @@ int stringlist_select_matching_files(stringlist_type * names , const char * path #endif } + +int stringlist_select_files(stringlist_type * names, const char * path, file_pred_ftype * predicate, const void * pred_arg) { + stringlist_clear(names); + char * path_arg = path ? util_alloc_string_copy(path) : util_alloc_cwd(); + +#ifdef ERT_HAVE_OPENDIR + DIR * dir = opendir(path_arg); + if (!dir) { + free(path_arg); + return 0; + } + + while (true) { + struct dirent * entry = readdir(dir); + if (!entry) + break; + + if (util_string_equal(entry->d_name, ".")) + continue; + + if (util_string_equal(entry->d_name, "..")) + continue; + + if (predicate && !predicate(entry->d_name, pred_arg)) + continue; + + stringlist_append_owned_ref(names, util_alloc_filename(path, entry->d_name, NULL)); + } + + closedir(dir); + +#else + + WIN32_FIND_DATA file_data; + HANDLE file_handle; + char * pattern = util_alloc_filename( path_arg , "*", NULL ); + + file_handle = FindFirstFile( pattern , &file_data ); + if (file_handle != INVALID_HANDLE_VALUE) { + do { + if (util_string_equal(file_data.cFileName, ".")) + continue; + + if (util_string_equal(file_data.cFileName, "..")) + continue; + + if (predicate && !predicate(file_data.cFileName, pred_arg)) + continue; + + stringlist_append_owned_ref(names, util_alloc_filename(path, file_data.cFileName, NULL)); + } while (FindNextFile( file_handle , &file_data) != 0); + FindClose( file_handle ); + } + free( pattern ); + +#endif + + free(path_arg); + return stringlist_get_size(names); +} + + int stringlist_append_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern) { int ielm; int match_count = 0; @@ -790,12 +841,17 @@ int stringlist_append_matching_elements(stringlist_type * target , const stringl return stringlist_append_matching_elements( target , src , pattern ); } + +static int void_strcmp(const void* s1, const void *s2) { + return strcmp(s1,s2); +} + bool stringlist_unique(const stringlist_type * stringlist ) { bool unique = true; stringlist_type * cpy = stringlist_alloc_shallow_copy(stringlist); - stringlist_sort(cpy, strcmp); + stringlist_sort(cpy, void_strcmp); for (int i = 0; i < stringlist_get_size(cpy) - 1; i++) { const char* s1 = stringlist_iget(cpy, i); const char* s2 = stringlist_iget(cpy, i+1); diff --git a/ThirdParty/Ert/lib/util/test_work_area.c b/ThirdParty/Ert/lib/util/test_work_area.c index dbb9823b5d..88116c7e1c 100644 --- a/ThirdParty/Ert/lib/util/test_work_area.c +++ b/ThirdParty/Ert/lib/util/test_work_area.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #ifdef ERT_HAVE_OPENDIR @@ -173,18 +172,20 @@ UTIL_IS_INSTANCE_FUNCTION( test_work_area , TEST_WORK_AREA_TYPE_ID) static test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , const char * test_name, bool change_dir) { if (test_name) { - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + unsigned int random_int; + util_fread_dev_urandom( sizeof random_int, (char *) &random_int); + random_int = random_int % 100000000; + #ifdef ERT_HAVE_GETUID uid_t uid = getuid(); struct passwd * pw = getpwuid( uid ); char * user_name = util_alloc_string_copy( pw->pw_name ); #else - char * user_name = util_alloc_sprintf("ert-test-%08d" , rng_get_int(rng , 100000000)); + char * user_name = util_alloc_sprintf("ert-test-%08u" , random_int); #endif - char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , rng_get_int( rng , 100000000 )); + char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , random_int); test_work_area_type * work_area = test_work_area_alloc__( prefix , test_path, change_dir); free( test_path ); - rng_free( rng ); free( user_name ); return work_area; } else diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_filename.c b/ThirdParty/Ert/lib/util/tests/ert_util_filename.c index 4bd358ecd9..0612a98071 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_filename.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_filename.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 @@ -29,7 +29,7 @@ void test_dirname() { const char * src_file1 = "/some/very/long/path/file.txt"; const char * src_file2 = "relative/path/file.txt"; const char * src_file3 = "file.txt"; - + char * path1 = util_split_alloc_dirname( src_file1 ); char * path2 = util_split_alloc_dirname( src_file2 ); char * path3 = util_split_alloc_dirname( src_file3 ); @@ -48,7 +48,7 @@ void test_filename() { const char * src_file1 = "/some/very/long/path/file1.txt"; const char * src_file2 = "relative/path/file2"; const char * src_file3 = "/tmp"; - + char * file1 = util_split_alloc_filename( src_file1 ); char * file2 = util_split_alloc_filename( src_file2 ); char * file3 = util_split_alloc_filename( src_file3 ); @@ -61,13 +61,24 @@ void test_filename() { } +void test_alloc_filename_empty_strings() { + const char * path = ""; + const char * filename = "file"; + const char * extension = ""; + + char * alloc_filename = util_alloc_filename( path, filename , extension); + test_assert_string_equal( alloc_filename , filename ); + free( alloc_filename ); + +} int main(int argc , char ** argv) { - + test_dirname(); test_filename(); + test_alloc_filename_empty_strings(); exit(0); - + } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c new file mode 100644 index 0000000000..4fbb95ca12 --- /dev/null +++ b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c @@ -0,0 +1,73 @@ +/* + Copyright (C) 2017 Statoil ASA, Norway. + + The file 'ert_util_normal_path.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + + +void test_path(const char * input_path, const char * expected_path) { + char * normal_path = util_alloc_normal_path( input_path ); + test_assert_string_equal( normal_path , expected_path ); + free( normal_path ); +} + + +void test_relative() { + test_work_area_type * work_area = test_work_area_alloc("Work"); + util_make_path("level0/level1/level2"); + + test_path( "level0/level1/../", "level0"); + test_path( "level0", "level0"); + test_path( "level0/././level1/../", "level0"); + test_path( "level0/level1/../level1/level2/../", "level0/level1"); + test_path( "level0/level1/../level1/level2/..", "level0/level1"); + test_path( "level0/level1/../level1/level2/../file.txt", "level0/level1/file.txt"); + test_path( "level0/level1/../level1a" , "level0/level1a"); + + test_path( "a/b/c/../c/../.." , "a"); + test_path( "a/b/c/d/e/f" , "a/b/c/d/e/f"); + util_chdir("level0/level1"); + test_path("../../level0/level1/level2/../file.txt" , "file.txt"); + test_path("../../level0/level1/level2/../" , ""); + test_work_area_free( work_area ); +} + +void test_beyond_root() { + test_work_area_type * work_area = test_work_area_alloc("Work"); + char * cwd = util_alloc_cwd( ); + char * backref_cwd1 = util_alloc_sprintf("../../../../../../../../../../../%s" , cwd ); + char * backref_cwd2 = util_alloc_sprintf("/../../../../../../../../../../../%s" , cwd ); + test_path( backref_cwd1 , "" ); + test_path( backref_cwd2 , cwd ); // The input is a semi-absolute path, and we compare with the absolute path cwd(). + free( backref_cwd1 ); + free( backref_cwd2 ); + free( cwd ); + test_work_area_free( work_area ); +} + + + +int main( int argc , char ** argv) { + test_relative( ); + test_beyond_root( ); + exit(0); +} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c index 6b2ce539aa..900b04894d 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c @@ -64,7 +64,7 @@ int main(int argc , char ** argv) { const char * root7 = "/tmp/root/path"; const char * path7 = "/tmp/root/path"; - const char * true7 = NULL; + const char * true7 = ""; const char * root8 = "/tmp"; const char * path8 = "root/path"; diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c index 19c268266e..0a81e4194f 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include static const char * stdout_msg = "stdout_xxx"; @@ -150,7 +148,6 @@ void test_spawn_redirect() { } void test_spawn_redirect_threaded() { - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); const int num = 128; // Generate the scripts on disk first @@ -158,7 +155,7 @@ void test_spawn_redirect_threaded() { int * path_codes = (int *)util_calloc(num, sizeof *path_codes); stringlist_type * script_fullpaths = stringlist_alloc_new(); for (int i=0; i < num; i++) { - path_codes[i] = rng_get_int( rng , 1000000); + path_codes[i] = rand() % 1000000; char * path = util_alloc_sprintf("%06d" , path_codes[i]); util_make_path( path ); @@ -180,22 +177,9 @@ void test_spawn_redirect_threaded() { test_assert_true(check_script(script)); } - // Run the scripts in parallel - stringlist_type * script_paths = stringlist_alloc_new(); // free the paths after threads have completed - thread_pool_type * tp = thread_pool_alloc( 8 , true ); - for(int i = 0; i < num; i++) { - char * path = util_alloc_sprintf("%06d" , path_codes[i]); - stringlist_append_owned_ref(script_paths, path); - thread_pool_add_job( tp , test_spawn_redirect__ , path ); - } - thread_pool_join( tp ); - thread_pool_free( tp ); - stringlist_free(script_paths); - stringlist_free(script_fullpaths); util_free(path_codes); test_work_area_free( test_area ); - rng_free( rng ); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c index eeb591f17b..db0817293d 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c @@ -17,9 +17,12 @@ */ #include #include +#include +#include #include #include +#include void test_char() { const char * S1 = "S1"; @@ -338,6 +341,54 @@ void test_matching() { } +bool FILE_predicate(const char * name, const void * arg) { + return util_string_equal("FILE.txt", name); +} + +bool not_FILE_predicate(const char * name, const void * arg) { + return !util_string_equal("FILE.txt", name); +} + + +void test_predicate_matching() { + test_work_area_type * work_area = test_work_area_alloc("predicate_test"); + stringlist_type * s = stringlist_alloc_new(); + stringlist_append_ref(s, "s"); + stringlist_select_files(s, "does/not/exist", NULL, NULL); + test_assert_int_equal(stringlist_get_size(s), 0); + + + { + FILE * f = util_fopen("FILE.txt", "w"); + fclose(f); + } + stringlist_select_files(s , test_work_area_get_cwd(work_area), NULL, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + { + char * exp = util_alloc_abs_path("FILE.txt"); + test_assert_string_equal( exp, stringlist_iget(s, 0)); + free(exp); + } + + stringlist_select_files(s , NULL, NULL, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + test_assert_string_equal( "FILE.txt", stringlist_iget(s, 0)); + + stringlist_select_files(s , test_work_area_get_cwd(work_area), FILE_predicate, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + { + char * exp = util_alloc_abs_path("FILE.txt"); + test_assert_string_equal( exp, stringlist_iget(s, 0)); + free(exp); + } + + stringlist_select_files(s , test_work_area_get_cwd(work_area), not_FILE_predicate, NULL); + test_assert_int_equal(0, stringlist_get_size(s)); + + stringlist_free(s); + test_work_area_free(work_area); +} + void test_unique() { stringlist_type * s = stringlist_alloc_new(); @@ -365,5 +416,6 @@ int main( int argc , char ** argv) { test_split(); test_matching(); test_unique(); + test_predicate_matching(); exit(0); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c index e5bc248634..05245bc53e 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c @@ -343,6 +343,38 @@ void test_empty() { int_vector_free( vec ); } + +void test_equal_index() { + int_vector_type * v1 = int_vector_alloc(0,0); + int_vector_type * v2 = int_vector_alloc(0,0); + int_vector_type * v3 = int_vector_alloc(0,0); + + for (int i=0; i < 5; i++) { + int_vector_iset(v1,i,i); + int_vector_iset(v2,i,i); + int_vector_iset(v3,i,i+1); + } + + test_assert_int_equal( int_vector_first_equal(v1,v2,10), -2); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,10), -2); + + test_assert_int_equal( int_vector_first_equal(v1,v2,0), 0); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,0), -1); + + + int_vector_iset(v1,0,77); + test_assert_int_equal( int_vector_first_equal(v1,v2,0), 1); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,0),0); + test_assert_int_equal( int_vector_first_equal(v1,v3,0), -1); + test_assert_int_equal( int_vector_first_not_equal(v1,v1,0), -1); + + int_vector_free(v1); + int_vector_free(v2); + int_vector_free(v3); +} + + + int main(int argc , char ** argv) { int_vector_type * int_vector = int_vector_alloc( 0 , 99); @@ -433,5 +465,6 @@ int main(int argc , char ** argv) { test_resize(); test_empty(); test_insert_double(); + test_equal_index(); exit(0); } diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 37150e81cb..8b301cb4e1 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -183,7 +183,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { variables will be by swapping two elements in one operation; this is provided by the util_endian_convert32_64() function. In the case of binary ECLIPSE files this case is quite common, and - therefor worth supporting as a special case. + therefore worth supporting as a special case. */ uint64_t *tmp64 = (uint64_t *) data; @@ -680,56 +680,6 @@ char * util_fscanf_realloc_line(FILE *stream , bool *at_eof , char *line) { -/** - Reads characters from stdin until EOL/EOF is detected. A '\0' is - appended to the resulting string before it is returned. If the - function reads an immediate EOF/EOL, i.e. the user enters an empty - input string, NULL (and not "") is returned. - - Observe that is this function does *not* cooperate very nicely with - fscanf() based input, because fscanf will leave a EOL character in - the input buffer, which will lead to immediate return from this - function. Hence if this function is called after a fscanf() based - function it is essential to preceede this function with one call to - getchar() to clear the EOL character. -*/ - -char * util_alloc_stdin_line(void) { - int input_size = 256; - char * input = (char*)util_calloc(input_size , sizeof * input ); - int index = 0; - bool end = false; - int c; - do { - c = getchar(); - if ((!EOL_CHAR(c)) && (c != EOF)) { - input[index] = c; - index++; - if (index == (input_size - 1)) { /* Reserve space for terminating \0 */ - input_size *= 2; - input = (char*)util_realloc(input , input_size ); - } - } else end = true; - } while (!end); - if (index == 0) { - free(input); - input = NULL; - } else { - input[index] = '\0'; - input = (char*)util_realloc(input , strlen(input) + 1 ); - } - - return input; -} - - - -char * util_realloc_stdin_line(char * p) { - util_safe_free(p); - return util_alloc_stdin_line(); -} - - /** WIndows does not have the usleep() function, on the other hand @@ -764,23 +714,6 @@ void util_yield() { #endif } -/** - This function will allocate and read a line from stdin. If there is - no input waiting on stdin (this typically only applies if stdin is - redirected from a file/PIPE), the function will sleep for 'usec' - microseconds and try again. -*/ - -char * util_blocking_alloc_stdin_line(unsigned long usec) { - char * line; - do { - line = util_alloc_stdin_line(); - if (line == NULL) - util_usleep(usec); - } while (line == NULL); - return line; -} - static char * util_getcwd(char * buffer , int size) { #ifdef HAVE_POSIX_GETCWD return getcwd( buffer , size ); @@ -875,78 +808,67 @@ char * util_alloc_realpath__(const char * input_path) { char * real_path = (char*)util_malloc( strlen(abs_path) + 2 ); real_path[0] = '\0'; + { - bool * mask; char ** path_list; + char ** path_stack; int path_len; util_path_split( abs_path , &path_len , &path_list ); - mask = (bool*)util_malloc( path_len * sizeof * mask ); - { - int i; - for (i=0; i < path_len; i++) - mask[i] = true; - } + path_stack = util_malloc( path_len * sizeof * path_stack ); + for (int i=0; i < path_len; i++) + path_stack[i] = NULL; { - int path_index = 1; // Path can not start with .. - int prev_index = 0; - while (true) { - if (path_index == path_len) - break; + int stack_size = 0; - if (strcmp(path_list[path_index] , BACKREF ) == 0) { - mask[path_index] = false; - mask[prev_index] = false; - prev_index--; - path_index++; - } else if (strcmp( path_list[path_index] , CURRENT) == 0) { - mask[path_index] = false; - path_index++; - } else { - path_index++; - prev_index++; - while (!mask[prev_index]) - prev_index++; + for (int path_index=0; path_index < path_len; path_index++) { + const char * path_elm = path_list[path_index]; + + if (strcmp( path_elm , CURRENT) == 0) + continue; + + /* Backref - pop from stack. */ + if (strcmp(path_elm , BACKREF ) == 0) { + if (stack_size > 0) { + memmove(path_stack, &path_stack[1] , (stack_size - 1) * sizeof * path_stack); + stack_size--; + } + continue; } + + /* Normal path element - push onto stack. */ + memmove(&path_stack[1], path_stack, stack_size * sizeof * path_stack); + path_stack[0] = path_elm; + stack_size++; } /* Build up the new string. */ - { - int i; - bool first = true; - - for (i=0; i < path_len; i++) { - if (mask[i]) { - const char * path_elm = path_list[i]; - if (first) { - + if (stack_size > 0) { + for (int pos = stack_size - 1; pos >= 0; pos--) { + const char * path_elm = path_stack[pos]; + if (pos == (stack_size- 1)) { #ifdef ERT_WINDOWS - // Windows: - // 1) If the path starts with X: - just do nothing - // 2) Else add \\ - for a UNC path. - if (path_elm[1] != ':') { - strcat(real_path, UTIL_PATH_SEP_STRING); - strcat(real_path, UTIL_PATH_SEP_STRING); - } -#else - // Posix: just start with a leading '/' + // Windows: + // 1) If the path starts with X: - just do nothing + // 2) Else add \\ - for a UNC path. + if (path_elm[1] != ':') { strcat(real_path, UTIL_PATH_SEP_STRING); -#endif - strcat( real_path , path_elm); - } else { - strcat(real_path, UTIL_PATH_SEP_STRING); - strcat( real_path , path_elm); - } - - first = false; +#else + // Posix: just start with a leading '/' + strcat(real_path, UTIL_PATH_SEP_STRING); +#endif + strcat( real_path , path_elm); + } else { + strcat(real_path, UTIL_PATH_SEP_STRING); + strcat(real_path , path_elm); } } } } - free(mask); + free( path_stack ); util_free_stringlist( path_list , path_len ); } @@ -1085,10 +1007,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { util_free_stringlist( path_list , path_length ); free( root_path ); - if (strlen(rel_path) == 0) { - free(rel_path); - rel_path = NULL; - } return rel_path; + return rel_path; } else { /* One or both the input arguments do not correspond to an @@ -1099,73 +1018,22 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { } } - - - -/** - This function will allocate a string copy of the env_index'th - occurence of an embedded environment variable from the input - string. - - An environment variable is defined as follows: - - 1. It starts with '$'. - 2. It ends with a characeter NOT in the set [a-Z,0-9,_]. - - The function will return environment variable number 'env_index'. If - no such environment variable can be found in the string the - function will return NULL. - - Observe that the returned string will start with '$'. This is to - simplify subsequent calls to util_string_replace_XXX() functions, - however &ret_value[1] must be used in the subsequent getenv() call: - - { - char * env_var = util_isscanf_alloc_envvar( s , 0 ); - if (env_var != NULL) { - const char * env_value = getenv( &env_var[1] ); // Skip the leading '$'. - if (env_value != NULL) - util_string_replace_inplace( s , env_value ); - else - fprintf(stderr,"** Warning: environment variable: \'%s\' is not defined \n", env_var); - free( env_var ); - } - } - - +/* + This function will return a new string where all "../" and "./" + occurences have been normalized away. The function is based on pure + string scanning, and will not consider the filesystem at + all. */ -char * util_isscanf_alloc_envvar( const char * string , int env_index ) { - int env_count = 0; - const char * offset = string; - const char * env_ptr; - do { - env_ptr = strchr( offset , '$' ); - offset = &env_ptr[1]; - env_count++; - } while ((env_count <= env_index) && (env_ptr != NULL)); +char * util_alloc_normal_path( const char * input_path ) { + if (util_is_abs_path(input_path)) + return util_alloc_realpath__( input_path ); - if (env_ptr != NULL) { - /* - We found an environment variable we are interested in. Find the - end of this variable and return a copy. - */ - int length = 1; - bool cont = true; - do { + char * realpath = util_alloc_realpath__(input_path); + return util_alloc_rel_path( NULL , realpath ); +} - if ( !( isalnum(env_ptr[length]) || env_ptr[length] == '_' )) - cont = false; - else - length++; - if (length == strlen( env_ptr )) - cont = false; - } while (cont); - return util_alloc_substring_copy( env_ptr , 0 , length ); - } else - return NULL; /* Could not find any env variable occurences. */ -} @@ -1994,8 +1862,10 @@ bool util_sscanf_bool(const char * buffer , bool * _value) { bool util_fscanf_bool(FILE * stream , bool * value) { char buffer[256]; - fscanf(stream , "%s" , buffer); - return util_sscanf_bool( buffer , value ); + if (fscanf(stream , "%s" , buffer) == 1) + return util_sscanf_bool( buffer , value ); + + return false; } @@ -2026,147 +1896,12 @@ bool util_fscanf_int(FILE * stream , int * value) { } -/** - Prompt .........====> - <-------1------><-2-> - The section marked with 1 above is the prompt length, i.e. the - input prompt is padded wth one blank, and then padded with - 'fill_char' (in the case above that is '.') characters up to a - total length of prompt_len. Then the the termination string ("===>" - above) is added. Observe the following: - * A space is _always_ added after the prompt, before the fill char - comes, even if the prompt is too long in the first place. - * No space is added at the end of the termination string. If - you want a space, that should be included in the termination - string. -*/ -void util_printf_prompt(const char * prompt , int prompt_len, char fill_char , const char * termination) { - int current_len = strlen(prompt) + 1; - printf("%s ",prompt); /* Observe that one ' ' is forced in here. */ - - while (current_len < prompt_len) { - fputc(fill_char , stdout); - current_len++; - } - printf("%s" , termination); - -} - - -/** - This functions presents the user with a prompt, and reads an - integer - the integer value is returned. The functions returns - NULL on empty input. -*/ - -int util_scanf_int(const char * prompt , int prompt_len) { - char input[256]; - int int_value; - bool OK; - do { - util_printf_prompt(prompt , prompt_len, '=', "=> "); - scanf("%s" , input); - OK = util_sscanf_int(input , &int_value); - } while (!OK); - getchar(); /* eating a \r left in the stdin input buffer. */ - return int_value; -} - -/** - This functions presents the user with a prompt, and reads an - integer - the integer value is returned. The functions will loop - indefinitely until a valid integer is entered. -*/ - -char * util_scanf_int_return_char(const char * prompt , int prompt_len) { - char input[256]; - int int_value; - bool OK = false; - while(!OK){ - util_printf_prompt(prompt , prompt_len, '=', "=> "); - fgets(input, prompt_len, stdin); - { - char *newline = strchr(input,'\n'); - if(newline) - *newline = 0; - } - - if(strlen(input) !=0){ - OK = util_sscanf_int(input , &int_value); - } - else { - OK = true; - } - } - return util_alloc_string_copy(input); -} - - -double util_scanf_double(const char * prompt , int prompt_len) { - char input[256]; - double double_value; - bool OK; - do { - util_printf_prompt(prompt , prompt_len, '=', "=> "); - scanf("%s" , input); - OK = util_sscanf_double(input , &double_value); - } while (!OK); - getchar(); /* eating a \r left in the stdin input buffer. */ - return double_value; -} - - - - - - - -/** - The limits are inclusive. -*/ -int util_scanf_int_with_limits(const char * prompt , int prompt_len , int min_value , int max_value) { - int value; - char * new_prompt = util_alloc_sprintf("%s [%d:%d]" , prompt , min_value , max_value); - do { - value = util_scanf_int(new_prompt , prompt_len); - } while (value < min_value || value > max_value); - free(new_prompt); - return value; -} - -/** - The limits are inclusive, yet the function returns the input char and stops on empty string. -*/ -char * util_scanf_int_with_limits_return_char(const char * prompt , int prompt_len , int min_value , int max_value) { - int value = min_value - 1; - char * value_char = NULL; - char * new_prompt = util_alloc_sprintf("%s [%d:%d]" , prompt , min_value , max_value); - while( value < min_value || value > max_value ){ - value_char = util_scanf_int_return_char(new_prompt , prompt_len); - if (strlen(value_char) == 0) - value = min_value; - else - util_sscanf_int(value_char , &value); - } - free(new_prompt); - return value_char; -} - - - -char * util_scanf_alloc_string(const char * prompt) { - char input[256]; - printf("%s" , prompt); - scanf("%256s" , input); - return util_alloc_string_copy(input); -} - /** @@ -2505,9 +2240,27 @@ int util_fmove( FILE * stream , long offset , long shift) { } +/* + Windows *might* have both the symbols _access() and access(), but we prefer + the _access() symbol as that seems to be preferred by Windows. We therefor do + the #HAVE_WINDOWS__ACCESS check first. +*/ + +#ifdef HAVE_WINDOWS__ACCESS + +bool util_access(const char * entry, int mode) { + return (_access(entry, mode) == 0); +} +#else +#ifdef HAVE_POSIX_ACCESS +bool util_access(const char * entry, mode_t mode) { + return (access(entry, mode) == 0); +} +#endif +#endif /** @@ -2527,20 +2280,8 @@ bool util_file_exists(const char *filename) { */ bool util_entry_exists( const char * entry ) { - stat_type stat_buffer; - int stat_return = util_stat(entry, &stat_buffer); - if (stat_return == 0) - return true; - else { - if (errno == ENOENT) - return false; - else { - util_abort("%s: error checking for entry:%s %d/%s \n",__func__ , entry , errno , strerror(errno)); - return false; - } - } + return util_access(entry, F_OK); } - /*****************************************************************/ @@ -2896,11 +2637,7 @@ bool util_ftruncate(FILE * stream , long size) { */ bool util_same_file(const char * file1 , const char * file2) { - -#ifdef _WINDOWS - if (file1 == NULL || file2 == NULL) return false; - return stricmp(file1, file2) == 0; -#else +#ifdef ERT_HAVE_UNISTD stat_type buffer1 , buffer2; int stat1,stat2; @@ -2914,6 +2651,17 @@ bool util_same_file(const char * file1 , const char * file2) { return false; } else return false; // Files which do not exist are no equal! +#else + if (util_file_exists(file1) && util_file_exists(file2)) { + char * abs_path1 = util_alloc_abs_path(file1); + char * abs_path2 = util_alloc_abs_path(file2); + bool same_file = util_string_equal(abs_path1, abs_path2); + free(abs_path1); + free(abs_path2); + return same_file; + } + else + return false; #endif } @@ -4718,67 +4466,6 @@ void util_free(void * ptr) { -static void util_display_prompt(const char * prompt , int prompt_len2) { - int i; - printf("%s" , prompt); - for (i=0; i < util_int_max(strlen(prompt) , prompt_len2) - strlen(prompt); i++) - fputc(' ' , stdout); - printf(": "); -} - - - -void util_read_string(const char * prompt , int prompt_len , char * s) { - util_display_prompt(prompt , prompt_len); - fscanf(stdin , "%s" , s); -} - - -void util_read_path(const char * prompt , int prompt_len , bool must_exist , char * path) { - bool ok = false; - while (!ok) { - util_read_string(prompt , prompt_len , path); - if (must_exist) - ok = util_is_directory(path); - else - ok = true; - if (!ok) - fprintf(stderr,"Path: %s does not exist - try again.\n",path); - } -} - -/* - exist_status == 0: Just read a string; do not check if it exist or not. - exist_status == 1: Must be existing file. - exist_status == 2: Must NOT exist as entry. -*/ - -char * util_fscanf_alloc_filename(const char * prompt , int prompt_len , int exist_status) { - char * filename = NULL; - while (filename == NULL) { - util_printf_prompt(prompt , prompt_len , '=' , "=> "); - filename = util_alloc_stdin_line(); - if (filename != NULL) { - if (exist_status != 0) { - if (exist_status == 1) { - if (!util_file_exists(filename)) { - fprintf(stderr,"Sorry: %s does not exist. \n",filename); - free( filename ); - filename = NULL; - } - } else if (exist_status == 2) { - if (util_entry_exists( filename )) { - fprintf(stderr,"Sorry: entry %s already exists. \n",filename); - free( filename ); - filename = NULL; - } - } - } - } - } - return filename; -} - /*****************************************************************/ @@ -5088,39 +4775,6 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type } -static char * __abort_program_message = NULL; /* Can use util_abort_append_version_info() to fill this with - version info+++ wich will be printed when util_abort() is called. */ -static char * __current_executable = NULL; - - -void util_abort_append_version_info(const char * msg) { - __abort_program_message = util_strcat_realloc( __abort_program_message , msg ); -} - - -void util_abort_free_version_info() { - util_safe_free( __abort_program_message ); - util_safe_free( __current_executable ); - - __current_executable = NULL; - __abort_program_message = NULL; -} - - -void util_abort_set_executable( const char * argv0 ) { - if (util_is_abs_path(argv0)) - __current_executable = util_realloc_string_copy( __current_executable , argv0 ); - else { - char * executable; - if (util_is_executable( argv0 )) - executable = util_alloc_realpath(argv0); - else - executable = util_alloc_PATH_executable( argv0 ); - - util_abort_set_executable( executable ); - free( executable ); - } -} @@ -5352,24 +5006,23 @@ char * util_alloc_filename(const char * path , const char * basename , const cha char * file; int length = strlen(basename) + 1; - if (path != NULL) + if (path && strlen(path)) length += strlen(path) + 1; - if (extension != NULL) + if (extension && strlen(extension)) length += strlen(extension) + 1; - file = (char*)util_calloc(length , sizeof * file ); - - if (path == NULL) { - if (extension == NULL) - memcpy(file , basename , strlen(basename) + 1); - else - sprintf(file , "%s.%s" , basename , extension); - } else { - if (extension == NULL) - sprintf(file , "%s%c%s" , path , UTIL_PATH_SEP_CHAR , basename); - else - sprintf(file , "%s%c%s.%s" , path , UTIL_PATH_SEP_CHAR , basename , extension); + file = (char*) util_calloc(length , sizeof * file ); + file[0] = '\0'; + + if (path && strlen(path)) { + strcat(file, path); + strcat(file, UTIL_PATH_SEP_STRING ); + } + strcat(file, basename); + if (extension && strlen(extension)) { + strcat(file, "."); + strcat(file, extension); } return file; diff --git a/ThirdParty/Ert/lib/util/util_endian.c b/ThirdParty/Ert/lib/util/util_endian.c index b2a5d1e2c6..3c88e55545 100644 --- a/ThirdParty/Ert/lib/util/util_endian.c +++ b/ThirdParty/Ert/lib/util/util_endian.c @@ -119,7 +119,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { variables will be by swapping two elements in one operation; this is provided by the util_endian_convert32_64() function. In the case of binary ECLIPSE files this case is quite common, and - therefor worth supporting as a special case. + therefore worth supporting as a special case. */ uint64_t *tmp64 = (uint64_t *) data; diff --git a/ThirdParty/Ert/lib/util/util_lockf.c b/ThirdParty/Ert/lib/util/util_lockf.c index fe3636b85c..6b7b120de2 100644 --- a/ThirdParty/Ert/lib/util/util_lockf.c +++ b/ThirdParty/Ert/lib/util/util_lockf.c @@ -20,7 +20,7 @@ If the lock is aquired the function will return true, otherwise it will return false. The lock is only active as long as the lockfile - is open, we therefor have to keep track of the relevant file + is open, we therefore have to keep track of the relevant file descriptor; it is passed back to the calling scope through a reference. Observe that if the locking fails we close the file immediately, and return -1 in the file descriptor argument. diff --git a/ThirdParty/Ert/lib/util/util_spawn.c b/ThirdParty/Ert/lib/util/util_spawn.c index 35a2d32112..76a08ea9f5 100644 --- a/ThirdParty/Ert/lib/util/util_spawn.c +++ b/ThirdParty/Ert/lib/util/util_spawn.c @@ -19,7 +19,18 @@ extern char **environ; #define STDOUT_FILENO 1 #define STDERR_FILENO 2 -static void __init_redirection(posix_spawn_file_actions_t * file_actions, const char *stdout_file, const char *stderr_file) { +static void spawn_init_attributes__(posix_spawnattr_t * attributes) { + posix_spawnattr_init(attributes); + short flags; + + posix_spawnattr_getflags(attributes, &flags); + flags |= POSIX_SPAWN_SETPGROUP; + posix_spawnattr_setflags(attributes, flags); + + posix_spawnattr_setpgroup( attributes, 0); +} + +static void spawn_init_redirection__(posix_spawn_file_actions_t * file_actions, const char *stdout_file, const char *stderr_file) { int status; status = posix_spawn_file_actions_init(file_actions); @@ -62,27 +73,28 @@ static pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER; */ pid_t util_spawn(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file) { pid_t pid; - char **__argv = (char**)util_malloc((argc + 2) * sizeof *__argv); + char **argv__ = (char**)util_malloc((argc + 2) * sizeof *argv__); { int iarg; - __argv[0] = (char *) executable; + argv__[0] = (char *) executable; for (iarg = 0; iarg < argc; iarg++) - __argv[iarg + 1] = (char *) argv[iarg]; - __argv[argc + 1] = NULL; + argv__[iarg + 1] = (char *) argv[iarg]; + argv__[argc + 1] = NULL; } { + posix_spawnattr_t spawn_attr; posix_spawn_file_actions_t file_actions; - __init_redirection(&file_actions , stdout_file , stderr_file); - + spawn_init_redirection__(&file_actions , stdout_file , stderr_file); + spawn_init_attributes__(&spawn_attr); pthread_mutex_lock( &spawn_mutex ); { int spawn_status; if (util_is_executable(executable)) { // the executable is in current directory or an absolute path - spawn_status = posix_spawn(&pid, executable, &file_actions, NULL, __argv, environ); + spawn_status = posix_spawn(&pid, executable, &file_actions, &spawn_attr, argv__, environ); } else { // Try to find executable in path - spawn_status = posix_spawnp(&pid, executable, &file_actions, NULL, __argv, environ); + spawn_status = posix_spawnp(&pid, executable, &file_actions, &spawn_attr, argv__, environ); } if (spawn_status != 0) @@ -90,9 +102,10 @@ pid_t util_spawn(const char *executable, int argc, const char **argv, const char } pthread_mutex_unlock( &spawn_mutex ); posix_spawn_file_actions_destroy(&file_actions); + posix_spawnattr_destroy(&spawn_attr); } - free(__argv); + free(argv__); return pid; } @@ -111,30 +124,6 @@ int util_spawn_blocking(const char *executable, int argc, const char **argv, con -/** - The ping program must(?) be setuid root, so implementing a simple - version based on sockets() proved to be nontrivial. - - The PING_CMD is passed as -D from the build system. -*/ - -#ifdef ERT_HAVE_PING -#define xstr(s) #s -#define str(s) xstr(s) -bool util_ping(const char *hostname) { - int wait_status; - const char* args[ 4 ] = { "-c", "3", "-q", hostname }; - wait_status = util_spawn_blocking(str(PING_CMD), 4, args, "/dev/null" , "/dev/null"); - - if (WIFEXITED( wait_status )) { - int ping_status = WEXITSTATUS( wait_status ); - return ping_status == 0; - } else { - return false; - } -} -#endif - diff --git a/ThirdParty/Ert/lib/util/util_zlib.c b/ThirdParty/Ert/lib/util/util_zlib.c index 195de19319..17d59e586f 100644 --- a/ThirdParty/Ert/lib/util/util_zlib.c +++ b/ThirdParty/Ert/lib/util/util_zlib.c @@ -93,7 +93,7 @@ Layout on disk when using util_fwrite_compressed: Observe that the functions util_fwrite_compressed() and util_fread_compressed must be used as a pair, the files can **N O T** be interchanged with normal calls to gzip/gunzip. To avoid confusion -it is therefor strongly advised NOT to give the files a .gz extension. +it is therefore strongly advised NOT to give the files a .gz extension. */ diff --git a/ThirdParty/Ert/lib/util/vector.c b/ThirdParty/Ert/lib/util/vector.c index 30ce655bb7..09ae564438 100644 --- a/ThirdParty/Ert/lib/util/vector.c +++ b/ThirdParty/Ert/lib/util/vector.c @@ -542,7 +542,7 @@ static int vector_cmp(const void * s1 , const void * s2) { int (* user_cmp) (const void *, const void *) i.e. the same as for qsort. The vector implementation considers - (fully) untyped data, it is therefor the users responsability to + (fully) untyped data, it is therefore the users responsability to ensure that the comparison makes sense. For example: diff --git a/ThirdParty/Ert/lib/util/vector_template.c b/ThirdParty/Ert/lib/util/vector_template.c index 302bd2193e..ccd85fd551 100644 --- a/ThirdParty/Ert/lib/util/vector_template.c +++ b/ThirdParty/Ert/lib/util/vector_template.c @@ -95,10 +95,11 @@ #include #include +#include +#include #include #include -#include #include #ifdef __cplusplus @@ -895,6 +896,26 @@ void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYP } + +bool @TYPE@_vector_init_linear(@TYPE@_vector_type * vector , @TYPE@ start_value, @TYPE@ end_value, int num_values) { + if (num_values < 2) + return false; + + @TYPE@_vector_reset( vector ); + @TYPE@_vector_iset( vector, 0 , start_value); + { + double slope = (end_value - start_value) / (num_values - 1); + + for (int i=1; i < num_values - 1; i++) { + @TYPE@ value = (@TYPE@) start_value + slope*i; + @TYPE@_vector_iset(vector, i, value); + } + } + @TYPE@_vector_iset( vector, num_values - 1, end_value); + return true; +} + + void @TYPE@_vector_append_many(@TYPE@_vector_type * vector , const @TYPE@ * data , int length) { @TYPE@_vector_set_many( vector , @TYPE@_vector_size( vector ) , data , length); } @@ -1450,31 +1471,6 @@ void @TYPE@_vector_fread( @TYPE@_vector_type * vector , FILE * stream ) { -void @TYPE@_vector_buffer_fwrite(const @TYPE@_vector_type * vector , buffer_type * buffer) { - buffer_fwrite_int( buffer , vector->size ); - buffer_fwrite( buffer , &vector->default_value , sizeof vector->default_value , 1 ); - buffer_fwrite( buffer , vector->data , sizeof * vector->data , vector->size ); -} - - -void @TYPE@_vector_buffer_fread(@TYPE@_vector_type * vector , buffer_type * buffer) { - @TYPE@ default_value; - int size = buffer_fread_int( buffer ); - buffer_fread( buffer , &default_value , sizeof default_value , 1 ); - - @TYPE@_vector_set_default( vector , default_value ); - @TYPE@_vector_realloc_data__( vector , size ); - buffer_fread( buffer , vector->data , sizeof * vector->data , size ); - vector->size = size; -} - - -@TYPE@_vector_type * @TYPE@_vector_buffer_fread_alloc( buffer_type * buffer ) { - @TYPE@_vector_type * vector = @TYPE@_vector_alloc( 0 , 0); - @TYPE@_vector_buffer_fread( vector , buffer ); - return vector; -} - /*****************************************************************/ @@ -1489,6 +1485,51 @@ bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vecto } +int @TYPE@_vector_first_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset) { + if (offset >= vector1->size) + return -2; + + if (offset >= vector2->size) + return -2; + + int index = offset; + while (vector1->data[index] != vector2->data[index]) { + index++; + + if (index == vector1->size) + return -1; + + if (index == vector2->size) + return -1; + } + + return index; +} + + + +int @TYPE@_vector_first_not_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset) { + if (offset >= vector1->size) + return -2; + + if (offset >= vector2->size) + return -2; + + int index = offset; + while (vector1->data[index] == vector2->data[index]) { + index++; + + if (index == vector1->size) + return -1; + + if (index == vector2->size) + return -1; + } + + return index; +} + + void @TYPE@_vector_apply(@TYPE@_vector_type * vector , @TYPE@_ftype * func) { @TYPE@_vector_assert_writable( vector ); diff --git a/ThirdParty/Ert/lib/vector_template.h.in b/ThirdParty/Ert/lib/vector_template.h.in index e8aee46f8c..c11dc38d34 100644 --- a/ThirdParty/Ert/lib/vector_template.h.in +++ b/ThirdParty/Ert/lib/vector_template.h.in @@ -1,37 +1,36 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'vector_template.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'vector_template.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. */ #ifndef ERT_@TYPE@_VECTOR_H #define ERT_@TYPE@_VECTOR_H -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include #include -#include #include #include typedef struct @TYPE@_vector_struct @TYPE@_vector_type; typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); - + int @TYPE@_vector_lookup_bin( const @TYPE@_vector_type * limits , @TYPE@ value , int guess); int @TYPE@_vector_lookup_bin__( const @TYPE@_vector_type * limits , @TYPE@ value , int guess); void @TYPE@_vector_inplace_div( @TYPE@_vector_type * vector , const @TYPE@_vector_type * inv_factor); @@ -71,10 +70,10 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); void @TYPE@_vector_insert( @TYPE@_vector_type * vector , int index , @TYPE@ value); void @TYPE@_vector_append(@TYPE@_vector_type * , @TYPE@); void @TYPE@_vector_free_container(@TYPE@_vector_type * vector); - void @TYPE@_vector_free(@TYPE@_vector_type *); - void @TYPE@_vector_free__(void *); - void @TYPE@_vector_free_data(@TYPE@_vector_type *); - void @TYPE@_vector_reset(@TYPE@_vector_type *); + void @TYPE@_vector_free(@TYPE@_vector_type *); + void @TYPE@_vector_free__(void *); + void @TYPE@_vector_free_data(@TYPE@_vector_type *); + void @TYPE@_vector_reset(@TYPE@_vector_type *); void @TYPE@_vector_reset__(void * __vector); int @TYPE@_vector_size(const @TYPE@_vector_type * ); void @TYPE@_vector_lshift(@TYPE@_vector_type * vector , int shift); @@ -85,6 +84,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); @TYPE@ * @TYPE@_vector_get_ptr(const @TYPE@_vector_type * ); @TYPE@ * @TYPE@_vector_alloc_data_copy( const @TYPE@_vector_type * vector ); const @TYPE@ * @TYPE@_vector_get_const_ptr(const @TYPE@_vector_type * ); + bool @TYPE@_vector_init_linear(@TYPE@_vector_type * vector , @TYPE@ start_value, @TYPE@ end_value, int num_values); void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYPE@ value2 , @TYPE@ delta); void @TYPE@_vector_set_many(@TYPE@_vector_type * , int , const @TYPE@ * , int ); void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value); @@ -108,14 +108,13 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); perm_vector_type * @TYPE@_vector_alloc_rsort_perm(const @TYPE@_vector_type * vector); void @TYPE@_vector_fprintf(const @TYPE@_vector_type * vector , FILE * stream , const char * name , const char * fmt); void @TYPE@_vector_fwrite(const @TYPE@_vector_type * vector , FILE * stream); - void @TYPE@_vector_buffer_fread(@TYPE@_vector_type * vector , buffer_type * buffer); @TYPE@_vector_type * @TYPE@_vector_fread_alloc( FILE * stream ); - @TYPE@_vector_type * @TYPE@_vector_buffer_fread_alloc( buffer_type * buffer ); - void @TYPE@_vector_buffer_fwrite(const @TYPE@_vector_type * vector , buffer_type * buffer); void @TYPE@_vector_fread( @TYPE@_vector_type * vector , FILE * stream ); void @TYPE@_vector_fwrite_data( const @TYPE@_vector_type * vector , FILE * stream ); void @TYPE@_vector_fread_data( @TYPE@_vector_type * vector , int size, FILE * stream); bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vector_type * vector2); + int @TYPE@_vector_first_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset); + int @TYPE@_vector_first_not_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset); void @TYPE@_vector_apply(@TYPE@_vector_type * vector , @TYPE@_ftype *func); int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_value); int @TYPE@_vector_element_size( const @TYPE@_vector_type * vector ); @@ -125,7 +124,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); UTIL_SAFE_CAST_HEADER( @TYPE@_vector ); UTIL_IS_INSTANCE_HEADER( @TYPE@_vector ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/python/CMakeLists.txt b/ThirdParty/Ert/python/CMakeLists.txt index 031fbc96f5..f3d5cd1a9a 100644 --- a/ThirdParty/Ert/python/CMakeLists.txt +++ b/ThirdParty/Ert/python/CMakeLists.txt @@ -7,14 +7,27 @@ init_python( 2.7 ) find_python_package(numpy 1.7.1 ${PYTHON_INSTALL_PREFIX}) if (NOT DEFINED PY_numpy) - message(WARNING "numpy module not found - Python wrappers not enabled") - set( BUILD_PYTHON OFF PARENT_SCOPE ) + message(WARNING "numpy module not found - Python wrappers not enabled. Install with: \"pip install numpy\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) return() endif() +find_python_package(cwrap 1 ${PYTHON_INSTALL_PREFIX}) +if (NOT DEFINED PY_cwrap) + message(WARNING "cwrap module not found Python wrappers not enabled. Install with: \"pip install cwrap\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) + return() +endif() + +configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/test_env.py ) + +add_subdirectory( ecl ) + +if (INSTALL_ERT_LEGACY) + add_subdirectory( ert ) +endif() if (BUILD_TESTS) add_subdirectory( tests ) endif() -add_subdirectory( python ) diff --git a/ThirdParty/Ert/python/cmake/Modules/init_python.cmake b/ThirdParty/Ert/python/cmake/Modules/init_python.cmake index 74cef5cf30..ae1f201e31 100644 --- a/ThirdParty/Ert/python/cmake/Modules/init_python.cmake +++ b/ThirdParty/Ert/python/cmake/Modules/init_python.cmake @@ -134,7 +134,7 @@ def update_path(): if __name__ == '__main__': update_path( ) - from ecl.test import ErtTestRunner + from ecl.util.test import ErtTestRunner for test_class in sys.argv[1:]: tests = ErtTestRunner.getTestsFromTestClass(test_class) diff --git a/ThirdParty/Ert/python/doc/devel.txt b/ThirdParty/Ert/python/doc/devel.txt index 299ded6513..7bae061d39 100644 --- a/ThirdParty/Ert/python/doc/devel.txt +++ b/ThirdParty/Ert/python/doc/devel.txt @@ -165,16 +165,16 @@ like: typedef struct { ..... ..... - } abs_type; + } abs_type; and "methods" like: abs_type * abs_type_alloc( ) { } - void abs_type_free( abs_type * at ) {} - int abs_type_get_an_int( const abs_type * at) {} + void abs_type_free( abs_type * at ) {} + int abs_type_get_an_int( const abs_type * at) {} void abs_type_set_an_int( abs_type * at , int value) {} -it has therefor been relatively easy to map this onto Python classes +it has therefore been relatively easy to map this onto Python classes and give a pythonic feel to the whole thing. As a ground rule each C file implements one struct; this struct is wrapped in a Python module with the same name and a Python class with CamelCaps naming: diff --git a/ThirdParty/Ert/python/ecl/CMakeLists.txt b/ThirdParty/Ert/python/ecl/CMakeLists.txt new file mode 100644 index 0000000000..3a9139aaf2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/CMakeLists.txt @@ -0,0 +1,18 @@ +set(PYTHON_SOURCES + __init__.py + ecl_type.py + ecl_util.py +) +add_python_package("python.ecl" ${PYTHON_INSTALL_PREFIX}/ecl "${PYTHON_SOURCES}" True) + +add_subdirectory(eclfile) +add_subdirectory(grid) +add_subdirectory(rft) +add_subdirectory(gravimetry) +add_subdirectory(summary) +add_subdirectory(util) +add_subdirectory(well) + +configure_file(ecl_lib_info_build.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl/__ecl_lib_info.py ) +configure_file(ecl_lib_info_install.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py ) +install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py DESTINATION ${PYTHON_INSTALL_PREFIX}/ecl RENAME __ecl_lib_info.py) diff --git a/ThirdParty/Ert/python/ecl/__init__.py b/ThirdParty/Ert/python/ecl/__init__.py new file mode 100644 index 0000000000..9988076250 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/__init__.py @@ -0,0 +1,140 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +ert - Ensemble Reservoir Tool - a package for reservoir modeling. + +The ert package itself has no code, but contains several subpackages: + +ecl.ecl: Package for working with ECLIPSE files. The far most mature + package in ert. + +ecl.util: + +The ert package is based on wrapping the libriaries from the ERT C +code with ctypes; an essential part of ctypes approach is to load the +shared libraries with the ctypes.CDLL() function. The ctypes.CDLL() +function uses the standard methods of the operating system, +i.e. standard locations configured with ld.so.conf and the environment +variable LD_LIBRARY_PATH. + +To avoid conflict with other application using the ert libraries the +Python code should be able to locate the shared libraries without +(necessarily) using the LD_LIBRARY_PATH variable. The default +behaviour is to try to load from the library ../../lib64, but by using +the enviornment variable ERT_LIBRARY_PATH you can alter how ert looks +for shared libraries. + + 1. By default the code will try to load the shared libraries from + '../../lib64' relative to the location of this file. + + 2. Depending on the value of ERT_LIBRARY_PATH two different + behaviours can be imposed: + + Existing path: the package will look in the path pointed to + by ERT_LIBRARY_PATH for shared libraries. + + Arbitrary value: the package will use standard load order for + the operating system. + +If the fixed path, given by the default ../../lib64 or ERT_LIBRARY_PATH +alternative fails, the loader will try the default load behaviour +before giving up completely. +""" +import os.path +import sys + +import warnings +warnings.simplefilter('always', DeprecationWarning) # see #1437 + +from cwrap import load as cwrapload +from cwrap import Prototype + +try: + import ert_site_init +except ImportError: + pass + + +required_version_hex = 0x02070000 + +ecl_lib_path = None +ert_so_version = "" +__version__ = "0.0.0" + + +# 1. Try to load the __ecl_lib_info module; this module has been +# configured by cmake during the build configuration process. The +# module should contain the variable lib_path pointing to the +# directory with shared object files. +try: + from .__ecl_lib_info import EclLibInfo + ecl_lib_path = EclLibInfo.lib_path + ert_so_version = EclLibInfo.so_version + __version__ = EclLibInfo.__version__ +except ImportError: + pass +except AttributeError: + pass + + +# 2. Using the environment variable ERT_LIBRARY_PATH it is possible to +# override the default algorithms. If the ERT_LIBRARY_PATH is set +# to a non existing directory a warning will go to stderr and the +# setting will be ignored. +env_lib_path = os.getenv("ERT_LIBRARY_PATH") +if env_lib_path: + if os.path.isdir( env_lib_path ): + ert_lib_path = os.getenv("ERT_LIBRARY_PATH") + else: + sys.stderr.write("Warning: Environment variable ERT_LIBRARY_PATH points to nonexisting directory:%s - ignored" % env_lib_path) + + +# Check that the final ert_lib_path setting corresponds to an existing +# directory. +if ecl_lib_path: + if not os.path.isabs(ecl_lib_path): + ecl_lib_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ecl_lib_path)) + + if not os.path.isdir( ecl_lib_path ): + ecl_lib_path = None + + +if sys.hexversion < required_version_hex: + raise Exception("ERT Python requires Python 2.7.") + +def load(name): + return cwrapload(name, path=ecl_lib_path, so_version=ert_so_version) + +class EclPrototype(Prototype): + lib = load("libecl") + + def __init__(self, prototype, bind=True): + super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) + +from .ecl_type import EclTypeEnum, EclDataType +from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil + +from .util.util import EclVersion +from .util.util import updateAbortSignals + +updateAbortSignals( ) + +def root(): + """ + Will print the filesystem root of the current ert package. + """ + return os.path.abspath( os.path.join( os.path.dirname( __file__ ) , "../")) + diff --git a/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in b/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in new file mode 100644 index 0000000000..7f80c68807 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in @@ -0,0 +1,9 @@ + + +class EclLibInfo(object): + lib_path = "${LIBRARY_OUTPUT_PATH}" + so_version = "${ECL_BINARY_POSTFIX}" + __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + + def __init__(self): + pass diff --git a/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in b/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in new file mode 100644 index 0000000000..12c6c69375 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in @@ -0,0 +1,9 @@ + + +class EclLibInfo(object): + lib_path = "../../../../${CMAKE_INSTALL_LIBDIR}" + so_version = "${ECL_BINARY_POSTFIX}" + __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + + def __init__(self): + pass diff --git a/ThirdParty/Ert/python/ecl/ecl_type.py b/ThirdParty/Ert/python/ecl/ecl_type.py new file mode 100644 index 0000000000..ca4d9c6831 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_type.py @@ -0,0 +1,184 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'ecl_type.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass, BaseCEnum +from ecl import EclPrototype + +class EclTypeEnum(BaseCEnum): + TYPE_NAME="ecl_type_enum" + ECL_CHAR_TYPE = None + ECL_FLOAT_TYPE = None + ECL_DOUBLE_TYPE = None + ECL_INT_TYPE = None + ECL_BOOL_TYPE = None + ECL_MESS_TYPE = None + ECL_STRING_TYPE = None + +EclTypeEnum.addEnum("ECL_CHAR_TYPE", 0) +EclTypeEnum.addEnum("ECL_FLOAT_TYPE", 1) +EclTypeEnum.addEnum("ECL_DOUBLE_TYPE", 2) +EclTypeEnum.addEnum("ECL_INT_TYPE", 3) +EclTypeEnum.addEnum("ECL_BOOL_TYPE", 4) +EclTypeEnum.addEnum("ECL_MESS_TYPE", 5) +EclTypeEnum.addEnum("ECL_STRING_TYPE", 7) + +#----------------------------------------------------------------- + +class EclDataType(BaseCClass): + + TYPE_NAME = "ecl_data_type" + + _alloc = EclPrototype("void* ecl_type_alloc_python(ecl_type_enum, size_t)", bind=False) + _alloc_from_type = EclPrototype("void* ecl_type_alloc_from_type_python(ecl_type_enum)", bind=False) + _alloc_from_name = EclPrototype("void* ecl_type_alloc_from_name_python(char*)", bind=False) + _free = EclPrototype("void ecl_type_free_python(ecl_data_type)") + _get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)") + _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_fortio_python(ecl_data_type)") + _is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)") + _is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)") + _is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)") + _is_double = EclPrototype("bool ecl_type_is_double_python(ecl_data_type)") + _is_mess = EclPrototype("bool ecl_type_is_mess_python(ecl_data_type)") + _is_bool = EclPrototype("bool ecl_type_is_bool_python(ecl_data_type)") + _is_string = EclPrototype("bool ecl_type_is_string_python(ecl_data_type)") + _get_name = EclPrototype("char* ecl_type_alloc_name_python(ecl_data_type)") + _is_numeric = EclPrototype("bool ecl_type_is_numeric_python(ecl_data_type)") + _is_equal = EclPrototype("bool ecl_type_is_equal_python(ecl_data_type, ecl_data_type)") + + def __init__(self, type_enum=None, element_size=None, type_name=None): + self._assert_valid_arguments(type_enum, element_size, type_name) + + if type_name: + c_ptr = self._alloc_from_name(type_name) + elif element_size is None: + c_ptr = self._alloc_from_type(type_enum) + else: + c_ptr = self._alloc(type_enum, element_size) + + super(EclDataType, self).__init__(c_ptr) + + def _assert_valid_arguments(self, type_enum, element_size, type_name): + if type_name is not None: + if type_enum is not None or element_size is not None: + err_msg = ("Type name given (%s). Expected both " + + "type_enum and element_size to be None") + raise ValueError(err_msg % type_name) + + elif type_enum is None: + raise ValueError("Both type_enum and type_name is None!") + + elif type_enum == EclTypeEnum.ECL_STRING_TYPE: + if element_size is None: + raise ValueError("When creating an ECL_STRING one must " + + "provide an element size!") + + if not (0 <= element_size <= 999): + raise ValueError("Expected element_size to be in the range " + + "[0, 999], was: %d" % element_size) + + @property + def type(self): + return self._get_type() + + @property + def element_size(self): + return self._get_element_size() + + @property + def type_name(self): + return self._get_name() + + def free(self): + self._free() + + def is_int(self): + return self._is_int() + + def is_char(self): + return self._is_char() + + def is_float(self): + return self._is_float() + + def is_double(self): + return self._is_double() + + def is_mess(self): + return self._is_mess() + + def is_bool(self): + return self._is_bool() + + def is_string(self): + return self._is_string() + + def is_numeric(self): + return self._is_numeric() + + def is_equal(self, other): + return self._is_equal(other) + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self.is_equal(other) + return False + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + return hash((self.type, self. element_size)) + + @classmethod + def create_from_type_name(cls, name): + return EclDataType(type_name=name) + + # Enables one to fetch a type as EclDataType.ECL_XXXX + class classproperty(object): + + def __init__(self, fget): + self.fget = fget + + def __get__(self, owner_self, owner_cls): + return self.fget(owner_cls) + + @classproperty + def ECL_INT(cls): + return EclDataType(EclTypeEnum.ECL_INT_TYPE) + + @classproperty + def ECL_FLOAT(cls): + return EclDataType(EclTypeEnum.ECL_FLOAT_TYPE) + + @classproperty + def ECL_DOUBLE(cls): + return EclDataType(EclTypeEnum.ECL_DOUBLE_TYPE) + + @classproperty + def ECL_BOOL(cls): + return EclDataType(EclTypeEnum.ECL_BOOL_TYPE) + + @classproperty + def ECL_MESS(cls): + return EclDataType(EclTypeEnum.ECL_MESS_TYPE) + + @classproperty + def ECL_CHAR(cls): + return EclDataType(EclTypeEnum.ECL_CHAR_TYPE) + + @classmethod + def ECL_STRING(cls, elem_size): + return EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) diff --git a/ThirdParty/Ert/python/ecl/ecl_util.py b/ThirdParty/Ert/python/ecl/ecl_util.py new file mode 100644 index 0000000000..2742c498fa --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_util.py @@ -0,0 +1,166 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_util.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Constants from the header ecl_util.h - some stateless functions. + +This module does not contain any class definitions; it mostly consists +of enum definitions/values from ecl_util.h; the enum values are +extracted from the shared library in a semi-automagic manner using the +BaseCEnum class from cwrap. + +In addition to the enum definitions there are a few stateless +functions from ecl_util.c which are not bound to any class type. +""" + +import ctypes + +from cwrap import BaseCEnum +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype + +class EclFileEnum(BaseCEnum): + TYPE_NAME = "ecl_file_enum" + ECL_OTHER_FILE = None + ECL_RESTART_FILE = None + ECL_UNIFIED_RESTART_FILE = None + ECL_SUMMARY_FILE = None + ECL_UNIFIED_SUMMARY_FILE = None + ECL_GRID_FILE = None + ECL_EGRID_FILE = None + ECL_INIT_FILE = None + ECL_RFT_FILE = None + ECL_DATA_FILE = None + + +EclFileEnum.addEnum("ECL_OTHER_FILE", 0) +EclFileEnum.addEnum("ECL_RESTART_FILE", 1) +EclFileEnum.addEnum("ECL_UNIFIED_RESTART_FILE", 2) +EclFileEnum.addEnum("ECL_SUMMARY_FILE", 4) +EclFileEnum.addEnum("ECL_UNIFIED_SUMMARY_FILE", 8) +EclFileEnum.addEnum("ECL_SUMMARY_HEADER_FILE", 16) +EclFileEnum.addEnum("ECL_GRID_FILE", 32) +EclFileEnum.addEnum("ECL_EGRID_FILE", 64) +EclFileEnum.addEnum("ECL_INIT_FILE", 128) +EclFileEnum.addEnum("ECL_RFT_FILE", 256) +EclFileEnum.addEnum("ECL_DATA_FILE", 512) + + +#----------------------------------------------------------------- + +class EclPhaseEnum(BaseCEnum): + TYPE_NAME="ecl_phase_enum" + ECL_OIL_PHASE = None + ECL_GAS_PHASE = None + ECL_WATER_PHASE = None + +EclPhaseEnum.addEnum("ECL_OIL_PHASE", 1) +EclPhaseEnum.addEnum("ECL_GAS_PHASE", 2) +EclPhaseEnum.addEnum("ECL_WATER_PHASE", 4) + + +#----------------------------------------------------------------- + +class EclUnitTypeEnum(BaseCEnum): + TYPE_NAME = "ecl_unit_enum" + + ECL_METRIC_UNITS = None + ECL_FIELD_UNITS = None + ECL_LAB_UNITS = None + ECL_PVT_M_UNITS = None + +EclUnitTypeEnum.addEnum("ECL_METRIC_UNITS", 1) +EclUnitTypeEnum.addEnum("ECL_FIELD_UNITS", 2) +EclUnitTypeEnum.addEnum("ECL_LAB_UNITS", 3) +EclUnitTypeEnum.addEnum("ECL_PVT_M_UNITS", 4) + + + +#----------------------------------------------------------------- + +class EclFileFlagEnum(BaseCEnum): + TYPE_NAME="ecl_file_flag_enum" + ECL_FILE_CLOSE_STREAM = None + ECL_FILE_WRITABLE = None + +EclFileFlagEnum.addEnum("ECL_FILE_CLOSE_STREAM", 1) +EclFileFlagEnum.addEnum("ECL_FILE_WRITABLE", 2) + + +#----------------------------------------------------------------- + +class EclUtil(object): + _get_num_cpu = EclPrototype("int ecl_util_get_num_cpu(char*)", bind = False) + _get_file_type = EclPrototype("ecl_file_enum ecl_util_get_file_type(char*, bool*, int*)", bind = False) + _get_start_date = EclPrototype("time_t ecl_util_get_start_date(char*)", bind = False) + _get_report_step = EclPrototype("int ecl_util_filename_report_nr(char*)", bind = False) + + + @staticmethod + def get_num_cpu(datafile): + """ + Parse ECLIPSE datafile and determine how many CPUs are needed. + + Will look for the "PARALLELL" keyword, and then read off the + number of CPUs required. Will return one if no PARALLELL keyword + is found. + """ + return EclUtil._get_num_cpu(datafile) + + @staticmethod + def get_file_type(filename): + """ + Will inspect an ECLIPSE filename and return an integer type flag. + """ + file_type, fmt, step = EclUtil.inspectExtension(filename) + return file_type + + @staticmethod + def get_start_date(datafile): + return EclUtil._get_start_date(datafile).datetime() + + @staticmethod + def inspect_extension(filename): + """Will inspect an ECLIPSE filename and return a tuple consisting of + file type (EclFileEnum), a bool for formatted or not, and an + integer for the step number. + + """ + fmt_file = ctypes.c_bool() + report_step = ctypes.c_int(-1) + file_type = EclUtil._get_file_type(filename, ctypes.byref(fmt_file), ctypes.byref(report_step)) + if report_step.value == -1: + step = None + else: + step = report_step.value + + return (file_type, fmt_file.value, step) + + @staticmethod + def report_step(filename): + report_step = EclUtil._get_report_step(filename) + if report_step < 0: + raise ValueError("Could not infer report step from: %s" % filename) + + return report_step + + + +get_num_cpu = EclUtil.get_num_cpu +get_file_type = EclUtil.get_file_type +get_start_date = EclUtil.get_start_date + +monkey_the_camel(EclUtil, 'inspectExtension', EclUtil.inspect_extension, staticmethod) +monkey_the_camel(EclUtil, 'reportStep', EclUtil.report_step, staticmethod) diff --git a/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt b/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt new file mode 100644 index 0000000000..d438f38314 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt @@ -0,0 +1,14 @@ +set(PYTHON_SOURCES + __init__.py + ecl_3d_file.py + ecl_file.py + ecl_file_view.py + ecl_init_file.py + ecl_restart_file.py + ecl_kw.py + fortio.py + ecl_3dkw.py + +) + +add_python_package("python.ecl.eclfile" ${PYTHON_INSTALL_PREFIX}/ecl/eclfile "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/eclfile/__init__.py b/ThirdParty/Ert/python/ecl/eclfile/__init__.py new file mode 100644 index 0000000000..c98633910f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/__init__.py @@ -0,0 +1,45 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" +The eclfile package contains several classes for working directly with ECLIPSE +files. + + fortio/FortIO: This is functionality to read and write binary + fortran files. + + ecl_kw/EclKW: This class holds one ECLIPSE keyword, like SWAT, in + restart format. + + ecl_type/EclDataType: This class is used to represent the data type + of the elements in EclKW. + + ecl_file/EclFile: This class is used to load an ECLIPSE file in + restart format, alternatively only parts of the file can be + loaded. Internally it consists of a collection of EclKW + instances. +""" + +import ecl.util.util + +from .fortio import FortIO, openFortIO +from .ecl_kw import EclKW +from .ecl_file_view import EclFileView +from .ecl_file import EclFile , openEclFile +from .ecl_3dkw import Ecl3DKW +from .ecl_3d_file import Ecl3DFile +from .ecl_init_file import EclInitFile +from .ecl_restart_file import EclRestartFile diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py new file mode 100644 index 0000000000..0d462a7636 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py @@ -0,0 +1,41 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.eclfile import EclFile, Ecl3DKW + + +class Ecl3DFile(EclFile): + + def __init__(self, grid, filename, flags=0): + self.grid = grid + super(Ecl3DFile, self).__init__(filename, flags) + + + def __getitem__(self, index): + return_arg = super(Ecl3DFile, self).__getitem__(index) + if isinstance(return_arg,list): + kw_list = return_arg + else: + kw_list = [return_arg] + + # Go through all the keywords and try inplace promotion to Ecl3DKW + for kw in kw_list: + try: + Ecl3DKW.castFromKW(kw, self.grid) + except ValueError: + pass + + return return_arg diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py new file mode 100644 index 0000000000..f19d01f171 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py @@ -0,0 +1,239 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_3dkw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import (absolute_import, division, + print_function, unicode_literals) + +from ecl.util.util import monkey_the_camel +from .ecl_kw import EclKW + +class Ecl3DKW(EclKW): + """ + Class for working with Eclipse keywords defined over a grid + + The Ecl3DKW class is derived from the EclKW class, and most of the + methods are implemented in the EclKW base class. The purpose of + the Ecl3DKW class is to simplify working with 3D properties like + PORO or SATNUM. + + The Ecl3DKW class has an attached EclGrid which is used to support + [i,j,k] indexing, and a defined default value which is used when + reading an inactive value. The Ecl3DKW keyword instances are + returned from the EclInitFile and EclRestartFile classes, in + addition you can excplicitly \"cast\" a EclKW keyword to Ecl3DKW + with the Ecl3DKW.castFromKW() classmethod. + + Usage example: + + from ecl.ecl import EclInitFile,EclGrid + + grid = EclGrid("ECLIPSE.EGRID") + file = EclInitFile(grid , "ECLIPSE.INIT") + + permx_kw = file["PORO"][0] + porv_kw = file["PORV"][0] + + permx_kw.setDefault( -1 ) + for k in range(grid.getNZ()): + for j in range(grid.getNY()): + for i in range(grid.getNX()): + print('"(%d,%d,%d) Permx:%g Porv:%g"' % (i,j,k,permx_kw[i,j,k] , porv_kw[i,j,k])) + + In the example we open an ECLIPSE INIT file and extract the PERMX + and PORV properties, and then iterate over all the cells in the + grid. + + In the INIT file the PORV keyword is stored with all cells, + whereas the PERMX keyword typically only has the active cells + stored, this active/inactive gymnastics is handled + transparently. With the call: + + permx_kw.setDefault( -1 ) + + we say that we want the value -1 for all inactive cells in the + PERMX property. + + """ + def __init__(self, kw , grid , value_type , default_value = 0 , global_active = False): + if global_active: + size = grid.getGlobalSize() + else: + size = grid.getNumActive( ) + super(Ecl3DKW , self).__init__( kw , size , value_type) + self.grid = grid + self.global_active = global_active + self.setDefault( default_value ) + + + @classmethod + def create(cls , kw , grid , value_type , default_value = 0 , global_active = False): + new_kw = Ecl3DKW(kw , grid , value_type , default_value , global_active) + return new_kw + + @classmethod + def read_grdecl( cls , grid , fileH , kw , strict = True , ecl_type = None): + """ + Will load an Ecl3DKW instance from a grdecl formatted filehandle. + + See the base class EclKW.read_grdecl() for more documentation. + """ + kw = super(Ecl3DKW , cls).read_grdecl( fileH , kw , strict , ecl_type) + Ecl3DKW.castFromKW(kw , grid) + return kw + + + + def __getitem__(self , index): + """Will return item [g] or [i,j,k]. + + The __getitem__() methods supports both scalar indexing like + [g] and tuples [i,j,k]. If the input argument is given as a + [i,j,k] tuple it is converted to an active index before the + final lookup. + + If the [i,j,k] input corresponds to an inactive cell in a + keyword with only nactive elements the default value will be + returned. By default the default value will be 0, but another + value can be assigned with the setDefault() method. + """ + if isinstance(index , tuple): + global_index = self.grid.get_global_index( ijk = index ) + if self.global_active: + index = global_index + else: + if not self.grid.active( global_index = global_index): + return self.getDefault() + else: + index = self.grid.get_active_index( ijk = index ) + + + return super(Ecl3DKW , self).__getitem__( index ) + + + + + def __setitem__(self , index , value): + """Set the value of at index [g] or [i,j,k]. + + The __setitem__() methods supports both scalar indexing like + [g] and tuples [i,j,k]. If the input argument is given as a + [i,j,k] tuple it is converted to an active index before the + final assignment. + + If you try to assign an inactive cell in a keyword with only + nactive elements a ValueError() exception will be raised. + """ + if isinstance(index , tuple): + global_index = self.grid.get_global_index( ijk = index ) + if self.global_active: + index = global_index + else: + if not self.grid.active( global_index = global_index): + raise ValueError("Tried to assign value to inactive cell: (%d,%d,%d)" % index) + else: + index = self.grid.get_active_index( ijk = index ) + + + return super(Ecl3DKW , self).__setitem__( index , value ) + + + @classmethod + def cast_from_kw(cls, kw, grid, default_value=0): + """Will convert a normal EclKW to a Ecl3DKW. + + The method will convert a normal EclKW instance to Ecl3DKw + instance with an attached grid and a default value. + + The method will check that size of the keyword is compatible + with the grid dimensions, i.e. the keyword must have either + nactive or nx*ny*nz elements. If the size of the keyword is + not compatible with the grid dimensions a ValueError exception + is raised. + + Example: + + 1. Load the poro keyword from a grdecl formatted file. + 2. Convert the keyword to a 3D keyword. + + + from ecl.ecl import EclGrid,EclKW,Ecl3DKW + + grid = EclGrid("ECLIPSE.EGRID") + poro = EclKW.read_grdecl(open("poro.grdecl") , "PORO") + Ecl3DKW.castFromKW( poro , grid ) + + print('Porosity in cell (10,11,12):%g' % poro[10,11,12]) + """ + if len(kw) == grid.getGlobalSize(): + kw.global_active = True + elif len(kw) == grid.getNumActive(): + kw.global_active = False + else: + raise ValueError("Size mismatch - must have size matching global/active size of grid") + + + kw.__class__ = cls + kw.default_value = default_value + kw.grid = grid + if len(kw) == grid.getGlobalSize(): + kw.global_active = True + else: + kw.global_active = False + + kw.setDefault( default_value ) + return kw + + + def compressed_copy(self): + """Will return a EclKW copy with nactive elements. + + The returned copy will be of type EclKW; i.e. no default + interpolation and only linear access in the [] operator. The + main purpose of this is to facilitate iteration over the + active index, and for writing binary files. + """ + return self.grid.compressedKWCopy( self ) + + + def global_copy(self): + """Will return a EclKW copy with nx*ny*nz elements. + + The returned copy will be of type EclKW; i.e. no default + interpolation and only linear access in the [] operator. The + main purpose of this is to facilitate iteration over the + global index, and for writing binary files. + """ + return self.grid.globalKWCopy( self , self.getDefault() ) + + + + def dims(self): + return (self.grid.getNX() , self.grid.getNY() , self.grid.getNZ()) + + + def set_default(self, default_value): + self.default_value = default_value + + + def get_default(self): + return self.default_value + + +monkey_the_camel(Ecl3DKW, 'castFromKW', Ecl3DKW.cast_from_kw, classmethod) +monkey_the_camel(Ecl3DKW, 'compressedCopy', Ecl3DKW.compressed_copy) +monkey_the_camel(Ecl3DKW, 'globalCopy', Ecl3DKW.global_copy) +monkey_the_camel(Ecl3DKW, 'setDefault', Ecl3DKW.set_default) +monkey_the_camel(Ecl3DKW, 'getDefault', Ecl3DKW.get_default) diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py new file mode 100644 index 0000000000..75ac344456 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py @@ -0,0 +1,721 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +The ecl_file module contains functionality to load a an ECLIPSE file +in 'restart format'. Files of 'restart format' include restart files, +init files, grid files, summary files and RFT files. + +The ecl_file implementation is agnostic[1] to the content and +structure of the file; more specialized classes like EclSum and +EclGrid use the EclFile functionality for low level file loading. + +The typical usage involves loading a complete file, and then +subsequently querying for various keywords. In the example below we +load a restart file, and ask for the SWAT keyword: + + file = EclFile( "ECLIPSE.X0067" ) + swat_kw = file.iget_named_kw( "SWAT" , 0 ) + +The ecl_file module is a thin wrapper around the ecl_file.c +implementation from the libecl library. + +[1]: In particular for restart files, which do not have a special + RestartFile class, there is some specialized functionality. +""" +import re +import types +import datetime +import ctypes + +from cwrap import BaseCClass + +from ecl import EclPrototype +from ecl.util.util import CTime +from ecl.util.util import monkey_the_camel +from ecl import EclFileEnum +from ecl.eclfile import EclKW, EclFileView + + +class EclFile(BaseCClass): + TYPE_NAME = "ecl_file" + _open = EclPrototype("void* ecl_file_open( char* , int )" , bind = False) + _get_file_type = EclPrototype("ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)" , bind = False) + _writable = EclPrototype("bool ecl_file_writable( ecl_file )") + _save_kw = EclPrototype("void ecl_file_save_kw( ecl_file , ecl_kw )") + _close = EclPrototype("void ecl_file_close( ecl_file )") + _iget_restart_time = EclPrototype("time_t ecl_file_iget_restart_sim_date( ecl_file , int )") + _iget_restart_days = EclPrototype("double ecl_file_iget_restart_sim_days( ecl_file , int )") + _get_restart_index = EclPrototype("int ecl_file_get_restart_index( ecl_file , time_t)") + _get_src_file = EclPrototype("char* ecl_file_get_src_file( ecl_file )") + _replace_kw = EclPrototype("void ecl_file_replace_kw( ecl_file , ecl_kw , ecl_kw , bool)") + _fwrite = EclPrototype("void ecl_file_fwrite_fortio( ecl_file , fortio , int)") + _has_report_step = EclPrototype("bool ecl_file_has_report_step( ecl_file , int)") + _has_sim_time = EclPrototype("bool ecl_file_has_sim_time( ecl_file , time_t )") + _get_global_view = EclPrototype("ecl_file_view_ref ecl_file_get_global_view( ecl_file )") + _write_index = EclPrototype("bool ecl_file_write_index( ecl_file , char*)") + _fast_open = EclPrototype("void* ecl_file_fast_open( char* , char* , int )" , bind=False) + + + @staticmethod + def get_filetype(filename): + fmt_file = ctypes.c_bool() + report_step = ctypes.c_int() + + file_type = EclFile._get_file_type( filename , ctypes.byref( fmt_file ) , ctypes.byref(report_step)) + if file_type in [EclFileEnum.ECL_RESTART_FILE , EclFileEnum.ECL_SUMMARY_FILE]: + report_step = report_step.value + else: + report_step = None + + if file_type in [EclFileEnum.ECL_OTHER_FILE , EclFileEnum.ECL_DATA_FILE]: + fmt_file = None + else: + fmt_file = fmt_file.value + + + return (file_type , report_step , fmt_file ) + + + + @classmethod + def restart_block( cls , filename , dtime = None , report_step = None): + raise NotImplementedError("The restart_block implementation has been removed - open file normally and use EclFileView.") + + + + @classmethod + def contains_report_step( cls , filename , report_step ): + """ + Will check if the @filename contains @report_step. + + This classmethod works by opening the file @filename and + searching through linearly to see if an ecl_kw with value + corresponding to @report_step can be found. Since this is a + classmethod it is invoked like this: + + import ecl.ecl.ecl as ecl + .... + if ecl.EclFile.contains_report_step("ECLIPSE.UNRST" , 20): + print "OK - file contains report step 20" + else: + print "File does not contain report step 20" + + If you have already loaded the file into an EclFile instance + you should use the has_report_step() method instead. + """ + obj = EclFile( filename ) + return obj.has_report_step( report_step ) + + + @classmethod + def contains_sim_time( cls , filename , dtime ): + """ + Will check if the @filename contains simulation at @dtime. + + This classmethod works by opening the file @filename and + searching through linearly to see if a result block at the + time corresponding to @dtime can be found. Since this is a + classmethod it is invoked like this: + + import ecl.ecl.ecl as ecl + .... + if ecl.EclFile.contains_sim_time("ECLIPSE.UNRST" , datetime.datetime( 2007 , 10 , 10) ): + print "OK - file contains 10th of October 2007" + else: + print "File does not contain 10th of October 2007" + + If you have already loaded the file into an EclFile instance + you should use the has_sim_time() method instead. + """ + obj = EclFile( filename ) + return obj.has_sim_time( dtime ) + + @property + def report_list(self): + report_steps = [] + try: + seqnum_list = self["SEQNUM"] + for s in seqnum_list: + report_steps.append( s[0] ) + except KeyError: + # OK - we did not have seqnum; that might be because this + # a non-unified restart file; or because this is not a + # restart file at all. + fname = self.getFilename( ) + matchObj = re.search("\.[XF](\d{4})$" , fname) + if matchObj: + report_steps.append( int(matchObj.group(1)) ) + else: + raise TypeError('Tried get list of report steps from file "%s" - which is not a restart file' % fname) + + + return report_steps + + + + @classmethod + def file_report_list( cls , filename ): + """ + Will identify the available report_steps from @filename. + """ + + file = EclFile( filename ) + return file.report_list + + + + def __repr__(self): + fn = self.getFilename() + wr = ', read/write' if self._writable() else '' + return self._create_repr('"%s"%s' % (fn,wr)) + + + def __init__( self , filename , flags = 0 , index_filename = None): + """ + Loads the complete file @filename. + + Will create a new EclFile instance with the content of file + @filename. The file @filename must be in 'restart format' - + otherwise it will be crash and burn. + + The optional argument flags can be an or'ed combination of the + flags: + + ecl.ECL_FILE_WRITABLE : It is possible to update the + content of the keywords in the file. + + ecl.ECL_FILE_CLOSE_STREAM : The underlying FILE * is closed + when not used; to save number of open file descriptors + in cases where a high number of EclFile instances are + open concurrently. + + When the file has been loaded the EclFile instance can be used + to query for and get reference to the EclKW instances + constituting the file, like e.g. SWAT from a restart file or + FIPNUM from an INIT file. + """ + if index_filename is None: + c_ptr = self._open( filename , flags ) + else: + c_ptr = self._fast_open(filename, index_filename, flags) + + if c_ptr is None: + raise IOError('Failed to open file "%s"' % filename) + else: + super(EclFile , self).__init__(c_ptr) + self.global_view = self._get_global_view( ) + self.global_view.setParent( self ) + + + def save_kw( self , kw ): + """ + Will write the @kw back to file. + + This function should typically be used in situations like this: + + 1. Create an EclFile instance around an ECLIPSE output file. + 2. Extract a keyword of interest and modify it. + 3. Call this method to save the modifications to disk. + + There are several restrictions to the use of this function: + + 1. The EclFile instance must have been created with the + optional read_only flag set to False. + + 2. You can only modify the content of the keyword; if you + try to modify the header in any way (i.e. size, datatype + or name) the function will fail. + + 3. The keyword you are trying to save must be exactly the + keyword you got from this EclFile instance, otherwise the + function will fail. + """ + if self._writable( ): + self._save_kw( kw ) + else: + raise IOError('save_kw: the file "%s" has been opened read only.' % self.getFilename( )) + + + def __len__(self): + return len(self.global_view) + + + def close(self): + if self: + self._close( ) + self._invalidateCPointer( ) + + + def free(self): + self.close() + + + def block_view(self, kw, kw_index): + if not kw in self: + raise KeyError('No such keyword "%s".' % kw) + ls = self.global_view.numKeywords(kw) + idx = kw_index + if idx < 0: + idx += ls + if 0 <= idx < ls: + return self.global_view.blockView(kw, idx) + raise IndexError('Index out of range, must be in [0, %d), was %d.' % (ls, kw_index)) + + + def block_view2(self, start_kw, stop_kw, start_index): + return self.global_view.blockView2( start_kw , stop_kw, start_index ) + + + def restart_view(self, seqnum_index=None, report_step=None, sim_time=None, sim_days=None): + return self.global_view.restartView( seqnum_index, report_step , sim_time, sim_days ) + + + def select_block(self, kw, kw_index): + raise NotImplementedError("The select_block implementation has been removed - use EclFileView") + + + def select_global( self ): + raise NotImplementedError("The select_global implementation has been removed - use EclFileView") + + + def select_restart_section( self, index = None , report_step = None , sim_time = None): + raise NotImplementedError("The select_restart_section implementation has been removed - use EclFileView") + """ + Will select a restart section as the active section. + + You must specify a report step with the @report_step argument, + a true time with the @sim_time argument or a plain index to + select restart block. If none of arguments are given exception + TypeError will be raised. If present the @sim_time argument + should be a datetime instance. + + If the restart section you ask for can not be found the method + will raise a ValueError exeception. To protect against this + you can query first with the has_report_step(), + has_sim_time() or num_report_steps() methods. + + This method should be used when you have already loaded the + complete file; if you only want to load a section from the + file you can use the classmethod restart_block(). + + The method will return 'self' which can be used to aid + readability. + """ + + + + def select_last_restart( self ): + raise NotImplementedError("The select_restart_section implementation has been removed - use EclFileView") + """ + Will select the last SEQNUM block in restart file. + + Works by searching for the last SEQNUM keyword; the SEQNUM + Keywords are only present in unified restart files. If this + is a non-unified restart file (or not a restart file at all), + the method will do nothing and return False. + """ + + + + + + def __getitem__(self , index): + """ + Implements [] operator; index can be integer or key. + + Will look up EclKW instances from the current EclFile + instance. The @index argument can either be an integer, in + which case the method will return EclKW number @index, or + alternatively a keyword string, in which case the method will + return a list of EclKW instances with that keyword: + + restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + kw9 = restart_file[9] + swat_list = restart_file["SWAT"] + + The keyword based lookup can be combined with an extra [] to + get EclKW instance nr: + + swat9 = restart_file["SWAT"][9] + + Will return the 10'th SWAT keyword from the restart file. The + following example will iterate over all the SWAT keywords in a + restart file: + + restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + for swat in restart_file["SWAT"]: + .... + """ + if isinstance(index, int): + ls = len(self) + idx = index + if idx < 0: + idx += ls + if 0 <= idx < ls: + return self.global_view[idx] + else: + raise IndexError('Index must be in [0, %d), was: %d.' % (ls, index)) + return self.global_view[index] + + + def iget_kw( self , index , copy = False): + """ + Will return EclKW instance nr @index. + + In the files loaded with the EclFile implementation the + ECLIPSE keywords come sequentially in a long series, an INIT + file might have the following keywords: + + INTEHEAD + LOGIHEAD + DOUBHEAD + PORV + DX + DY + DZ + PERMX + PERMY + PERMZ + MULTX + MULTY + ..... + + The iget_kw() method will give you a EclKW reference to + keyword nr @index. This functionality is also available + through the index operator []: + + file = EclFile( "ECLIPSE.INIT" ) + permx = file.iget_kw( 7 ) + permz = file[ 9 ] + + Observe that the returned EclKW instance is only a reference + to the data owned by the EclFile instance. + + The method iget_named_kw() which lets you specify the name of + the keyword you are interested in is in general more useful + than this method. + """ + kw = self[index] + if copy: + return EclKW.copy( kw ) + else: + return kw + + + def iget_named_kw( self , kw_name , index , copy = False): + return self.global_view.iget_named_kw( kw_name , index ) + + + + def restart_get_kw( self , kw_name , dtime , copy = False): + """Will return EclKW @kw_name from restart file at time @dtime. + + This function assumes that the current EclFile instance + represents a restart file. It will then look for keyword + @kw_name exactly at the time @dtime; @dtime is a datetime + instance: + + file = EclFile( "ECLIPSE.UNRST" ) + swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 )) + + By default the returned kw instance is a reference to the + ecl_kw still contained in the EclFile instance; i.e. the kw + will become a dangling reference if the EclFile instance goes + out of scope. If the optional argument @copy is True the + returned kw will be a true copy. + + If the file does not have the keyword at the specified time + the function will raise IndexError(); if the file does not + have the keyword at all - KeyError will be raised. + """ + index = self._get_restart_index( CTime( dtime ) ) + if index >= 0: + if self.num_named_kw(kw_name) > index: + kw = self.iget_named_kw( kw_name , index ) + if copy: + return EclKW.copy( kw ) + else: + return kw + else: + if self.has_kw(kw_name): + raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime)) + else: + raise KeyError('Keyword "%s" not recognized.' % kw_name) + else: + raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime)) + + + def replace_kw( self , old_kw , new_kw): + """ + Will replace @old_kw with @new_kw in current EclFile instance. + + This method can be used to replace one of the EclKW instances + in the current EclFile. The @old_kw reference must be to the + actual EclKW instance in the current EclFile instance (the + final comparison is based on C pointer equality!), i.e. it + must be a reference (not a copy) from one of the ??get_kw?? + methods of the EclFile class. In the example below we replace + the SWAT keyword from a restart file: + + swat = file.iget_named_kw( "SWAT" , 0 ) + new_swat = swat * 0.25 + file.replace_kw( swat , new_swat ) + + + The C-level ecl_file_type structure takes full ownership of + all installed ecl_kw instances; mixing the garbage collector + into it means that this is quite low level - and potentially + dangerous! + """ + + # We ensure that this scope owns the new_kw instance; the + # new_kw will be handed over to the ecl_file instance, and we + # can not give away something we do not alreeady own. + if not new_kw.data_owner: + new_kw = EclKW.copy( new_kw ) + + # The ecl_file instance will take responsability for freeing + # this ecl_kw instance. + new_kw.data_owner = False + self._replace_kw( old_kw , new_kw , False ) + + + + @property + def size(self): + """ + The number of keywords in the current EclFile object. + """ + return len(self) + + @property + def unique_size( self ): + """ + The number of unique keyword (names) in the current EclFile object. + """ + return self.global_view.uniqueSize( ) + + + + def keys(self): + """ + Will return a list of unique kw names - like keys() on a dict. + """ + header_dict = {} + for index in range(len(self)): + kw = self[index] + header_dict[ kw.getName() ] = True + return header_dict.keys() + + + @property + def headers(self): + """ + Will return a list of the headers of all the keywords. + """ + header_list = [] + for index in range(self.size): + kw = self[index] + header_list.append( kw.header ) + return header_list + + @property + def report_steps( self ): + """ + Will return a list of all report steps. + + The method works by iterating through the whole restart file + looking for 'SEQNUM' keywords; if the current EclFile instance + is not a restart file it will not contain any 'SEQNUM' + keywords and the method will simply return an empty list. + """ + steps = [] + seqnum_list = self["SEQNUM"] + for kw in self["SEQNUM"]: + steps.append( kw[0] ) + return steps + + @property + def report_dates( self ): + """ + Will return a list of the dates for all report steps. + + The method works by iterating through the whole restart file + looking for 'SEQNUM/INTEHEAD' keywords; the method can + probably be tricked by other file types also containing an + INTEHEAD keyword. + """ + if self.has_kw('SEQNUM'): + dates = [] + for index in range( self.num_named_kw( 'SEQNUM' )): + dates.append( self.iget_restart_sim_time( index )) + return dates + elif 'INTEHEAD' in self: + # This is a uber-hack; should export the ecl_rsthead + # object as ctypes structure. + intehead = self["INTEHEAD"][0] + year = intehead[66] + month = intehead[65] + day = intehead[64] + date = datetime.datetime( year , month , day ) + return [ date ] + return None + + + @property + def dates( self ): + """ + Will return a list of the dates for all report steps. + """ + return self.report_dates + + + def num_named_kw( self , kw): + """ + The number of keywords with name == @kw in the current EclFile object. + """ + return self.global_view.numKeywords( kw ) + + + def has_kw( self , kw , num = 0): + """ + Check if current EclFile instance has a keyword @kw. + + If the optional argument @num is given it will check if the + EclFile has at least @num occurences of @kw. + """ + + return self.num_named_kw( kw ) > num + + def __contains__(self , kw): + """ + Check if the current file contains keyword @kw. + """ + return self.has_kw( kw ) + + def has_report_step( self , report_step ): + """ + Checks if the current EclFile has report step @report_step. + + If the EclFile in question is not a restart file, you will + just get False. If you want to check if the file contains the + actual report_step before loading the file, you should use the + classmethod contains_report_step() instead. + """ + return self._has_report_step( report_step ) + + def num_report_steps( self ): + """ + Returns the total number of report steps in the restart file. + + Works by counting the number of 'SEQNUM' instances, and will + happily return 0 for a non-restart file. Observe that the + report_steps present in a unified restart file are in general + not consecutive, i.e. the last report step will typically be + much higher than the return value from this function. + """ + return len( self["SEQNUM"] ) + + + + def has_sim_time( self , dtime ): + """ + Checks if the current EclFile has data for time @dtime. + + The implementation goes through all the INTEHEAD headers in + the EclFile, i.e. it can be fooled (and probably crash and + burn) if the EclFile instance in question is has INTEHEAD + keyword(s), but is still not a restart file. The @dtime + argument should be a normal python datetime instance. + """ + return self._has_sim_time( CTime(dtime) ) + + + def iget_restart_sim_time( self , index ): + """ + Will locate restart block nr @index and return the true time + as a datetime instance. + """ + ct = CTime(self._iget_restart_time( index )) + return ct.datetime() + + + def iget_restart_sim_days( self , index ): + """ + Will locate restart block nr @index and return the number of days + (in METRIC at least ...) since the simulation started. + + """ + return self._iget_restart_days( index ) + + + def get_filename(self): + """ + Name of the file currently loaded. + """ + fn = self._get_src_file() + return str(fn) if fn else '' + + def fwrite( self , fortio ): + """ + Will write current EclFile instance to fortio stream. + + ECLIPSE is written in Fortran; and a "special" handle for + Fortran IO must be used when reading and writing these files. + This method will write the current EclFile instance to a + FortIO stream already opened for writing: + + import ecl.ecl.ecl as ecl + ... + fortio = ecl.FortIO( "FILE.XX" ) + file.fwrite( fortio ) + fortio.close() + + """ + self._fwrite( fortio , 0 ) + + def write_index(self, index_file_name): + if not self._write_index(index_file_name): + raise IOError("Failed to write index file:%s" % index_file_name) + + +class EclFileContextManager(object): + + def __init__(self , ecl_file): + self.__ecl_file = ecl_file + + def __enter__(self): + return self.__ecl_file + + def __exit__(self, exc_type, exc_val, exc_tb): + self.__ecl_file.close() + return False + + +def openEclFile( file_name , flags = 0): + print('The function openEclFile is deprecated, use open_ecl_file.') + return open_ecl_file(file_name, flags) + +def open_ecl_file(file_name, flags=0): + return EclFileContextManager(EclFile(file_name, flags)) + + + +monkey_the_camel(EclFile, 'getFileType', EclFile.get_filetype, staticmethod) +monkey_the_camel(EclFile, 'blockView', EclFile.block_view) +monkey_the_camel(EclFile, 'blockView2', EclFile.block_view2) +monkey_the_camel(EclFile, 'restartView', EclFile.restart_view) +monkey_the_camel(EclFile, 'getFilename', EclFile.get_filename) diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py new file mode 100644 index 0000000000..16b09643c6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py @@ -0,0 +1,200 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import absolute_import, division, print_function, unicode_literals +from six import string_types +from cwrap import BaseCClass +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclPrototype + +class EclFileView(BaseCClass): + TYPE_NAME = "ecl_file_view" + _iget_kw = EclPrototype("ecl_kw_ref ecl_file_view_iget_kw( ecl_file_view , int)") + _iget_named_kw = EclPrototype("ecl_kw_ref ecl_file_view_iget_named_kw( ecl_file_view , char* , int)") + _get_size = EclPrototype("int ecl_file_view_get_size( ecl_file_view )") + _get_num_named_kw = EclPrototype("int ecl_file_view_get_num_named_kw( ecl_file_view , char* )") + _get_unique_size = EclPrototype("int ecl_file_view_get_num_distinct_kw( ecl_file_view )") + _create_block_view = EclPrototype("ecl_file_view_ref ecl_file_view_add_blockview( ecl_file_view , char*, int )") + _create_block_view2 = EclPrototype("ecl_file_view_ref ecl_file_view_add_blockview2( ecl_file_view , char*, char*, int )") + _restart_view = EclPrototype("ecl_file_view_ref ecl_file_view_add_restart_view( ecl_file_view , int, int, time_t, double )") + + + def __init__(self): + raise NotImplementedError("Can not instantiate directly") + + + def __iget(self, index): + return self._iget_kw(index).setParent(parent=self) + + + def __repr__(self): + return 'EclFileView(size=%d) %s' % (len(self), self._ad_str()) + + def iget_named_kw(self, kw_name, index): + if not kw_name in self: + raise KeyError("No such keyword: %s" % kw_name) + + if index >= self.numKeywords(kw_name): + raise IndexError("Too large index: %d" % index) + + return self._iget_named_kw(kw_name, index).setParent(parent=self) + + + + def __getitem__(self, index): + """ + Implements [] operator; index can be integer or key. + + Will look up EclKW instances from the current EclFile + instance. The @index argument can either be an integer, in + which case the method will return EclKW number @index, or + alternatively a keyword string, in which case the method will + return a list of EclKW instances with that keyword: + + restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + kw9 = restart_file[9] + swat_list = restart_file["SWAT"] + + The keyword based lookup can be combined with an extra [] to + get EclKW instance nr: + + swat9 = restart_file["SWAT"][9] + + Will return the 10'th SWAT keyword from the restart file. The + following example will iterate over all the SWAT keywords in a + restart file: + + restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + for swat in restart_file["SWAT"]: + .... + """ + + if isinstance(index, int): + ls = len(self) + idx = index + if idx < 0: + idx += ls + if 0 <= idx < ls: + return self.__iget(idx) + else: + raise IndexError('Index must be in [0, %d), was: %d.' % (ls, index)) + + if isinstance(index, slice): + indices = index.indices(len(self)) + kw_list = [] + for i in range(*indices): + kw_list.append(self[i]) + return kw_list + else: + if isinstance(index, bytes): + index = index.decode('ascii') + if isinstance(index, string_types): + if index in self: + kw_index = index + kw_list = [] + for index in range(self.numKeywords(kw_index)): + kw_list.append( self.iget_named_kw(kw_index, index)) + return kw_list + else: + raise KeyError("Unrecognized keyword:\'%s\'" % index) + else: + raise TypeError("Index must be integer or string (keyword)") + + + def __len__(self): + return self._get_size() + + + def __contains__(self, kw): + if self.numKeywords(kw) > 0: + return True + else: + return False + + + def num_keywords(self, kw): + return self._get_num_named_kw(kw) + + + def unique_size(self): + return self._get_unique_size() + + def block_view2(self, start_kw, stop_kw, start_index): + idx = start_index + if start_kw: + if not start_kw in self: + raise KeyError("The keyword:%s is not in file" % start_kw) + + ls = self.numKeywords(start_kw) + if idx < 0: + idx += ls + if not (0 <= idx < ls): + raise IndexError('Index must be in [0, %d), was: %d.' % (ls, start_index)) + + if stop_kw: + if not stop_kw in self: + raise KeyError("The keyword:%s is not in file" % stop_kw) + + view = self._create_block_view2(start_kw, stop_kw, idx) + view.setParent(parent=self) + return view + + + def block_view(self, kw, kw_index): + num = self.numKeywords(kw) + + if num == 0: + raise KeyError("Unknown keyword: %s" % kw) + + idx = kw_index + if idx < 0: + idx += num + + if not (0 <= idx < num): + raise IndexError('Index must be in [0, %d), was: %d.' % (num, kw_index)) + + view = self._create_block_view(kw, kw_index) + view.setParent(parent=self) + return view + + + def restart_view(self, seqnum_index=None, report_step=None, sim_time=None, sim_days=None): + if report_step is None: + report_step = -1 + + if sim_time is None: + sim_time = -1 + + if sim_days is None: + sim_days = -1 + + if seqnum_index is None: + seqnum_index = -1 + + view = self._restart_view(seqnum_index, report_step, CTime(sim_time), sim_days) + if view is None: + raise ValueError("No such restart block could be identiefied") + + view.setParent(parent=self) + return view + + +monkey_the_camel(EclFileView, 'numKeywords', EclFileView.num_keywords) +monkey_the_camel(EclFileView, 'uniqueSize', EclFileView.unique_size) +monkey_the_camel(EclFileView, 'blockView2', EclFileView.block_view2) +monkey_the_camel(EclFileView, 'blockView', EclFileView.block_view) +monkey_the_camel(EclFileView, 'restartView', EclFileView.restart_view) diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py new file mode 100644 index 0000000000..51ae032143 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py @@ -0,0 +1,30 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclFileEnum +from ecl.eclfile import EclFile, Ecl3DFile + + +class EclInitFile(Ecl3DFile): + + def __init__(self, grid, filename, flags=0): + file_type, report_step, fmt_file = EclFile.getFileType(filename) + if file_type == EclFileEnum.ECL_INIT_FILE: + super(EclInitFile, self).__init__(grid, filename, flags) + else: + err = 'The input filename "%s" does not correspond to a restart file.' + err += ' Please follow the Eclipse naming conventions.' + raise ValueError(err % filename) diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py new file mode 100644 index 0000000000..9f43dda574 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py @@ -0,0 +1,1245 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Support for working with one keyword from ECLIPSE file. + +ECLIPSE files in "restart format" are organized in keywords consisting +of a simple header and blocks of data. A keyword typically looks like: + + 'SWAT ' 10000 'REAL' + 0.05 0.08 0.08 0.10 + 0.11 0.11 0.10 0.09 + .... + +I.e. it starts with of header consisting of a 8 characters name, a +length and a datatype, immediately followed by the actual +data. + +Altough the term "restart format" is used to describe the format, this +particular format is not limited to restart files; it is (at least) +used in INIT, EGRID, GRID, Snnn, UNSMRY, SMSPEC, UNRST, Xnnnn and RFT +files. This module also has (some) support for working with GRDECL +'formatted' files. + +The ecl_kw.py implementation wraps the ecl_kw.c implementation from +the libecl library. +""" + +from __future__ import absolute_import, division, print_function, unicode_literals + +import ctypes +import warnings +import numpy + +from cwrap import CFILE, BaseCClass + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclDataType +from ecl import EclTypeEnum, EclUtil + +from .fortio import FortIO + +def dump_type_deprecation_warning(): + warnings.warn("EclTypeEnum is deprecated. " + + "You should instead provide an EclDataType", + DeprecationWarning) + +def constant_size_data_type(ecl_type): + return (ecl_type in [ + EclTypeEnum.ECL_CHAR_TYPE, + EclTypeEnum.ECL_FLOAT_TYPE, + EclTypeEnum.ECL_DOUBLE_TYPE, + EclTypeEnum.ECL_INT_TYPE, + EclTypeEnum.ECL_BOOL_TYPE, + EclTypeEnum.ECL_MESS_TYPE + ]) + +def warn_and_cast_data_type(data_type): + if isinstance(data_type, EclDataType): + return data_type + if isinstance(data_type, EclTypeEnum): + if not constant_size_data_type(data_type): + raise ValueError("Cannot cast EclTypeEnum (%d) to EclDataType due " + "to non-constant size. Please provide an EclDataType instead.") + + dump_type_deprecation_warning() + return EclDataType(data_type) + +class EclKW(BaseCClass): + """ + The EclKW class contains the information from one ECLIPSE keyword. + + The ecl_kw type is the lowest level type in the libecl C library, + and all the other datatypes like e.g. ecl_grid and ecl_sum are + based on collections of ecl_kw instances, and interpreting the + content of the ecl_kw keywords. + + Many of the special __xxx___() functions have been implemented, so + that the EclKW class supports both numerical operations and also + [] based lookup. Many of the methods accept an optional @mask + argument; this should be a EclRegion instance which can be used to + limit the operation to a part of the EclKW. + """ + + int_kw_set = set(["PVTNUM", "FIPNUM", "EQLNUM", "FLUXNUM", "MULTNUM", "ACTNUM", "SPECGRID", "REGIONS"]) + + TYPE_NAME = "ecl_kw" + _alloc_new = EclPrototype("void* ecl_kw_alloc_python(char*, int, ecl_data_type)", bind = False) + _fread_alloc = EclPrototype("ecl_kw_obj ecl_kw_fread_alloc(fortio)", bind = False) + _load_grdecl = EclPrototype("ecl_kw_obj ecl_kw_fscanf_alloc_grdecl_dynamic_python(FILE, char*, bool, ecl_data_type)", bind = False) + _fseek_grdecl = EclPrototype("bool ecl_kw_grdecl_fseek_kw(char*, bool, FILE)", bind = False) + + _sub_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_sub_copy(ecl_kw, char*, int, int)") + _copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_copy(ecl_kw)") + _slice_copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_slice_copy(ecl_kw, int, int, int)") + _global_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_global_copy(ecl_kw, ecl_kw)") + _fprintf_grdecl = EclPrototype("void ecl_kw_fprintf_grdecl(ecl_kw, FILE)") + _fprintf_data = EclPrototype("void ecl_kw_fprintf_data(ecl_kw, char*, FILE)") + + _get_size = EclPrototype("int ecl_kw_get_size(ecl_kw)") + _get_fortio_size = EclPrototype("size_t ecl_kw_fortio_size(ecl_kw)") + _get_type = EclPrototype("ecl_type_enum ecl_kw_get_type(ecl_kw)") + _iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr(ecl_kw, int)") + _iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr(ecl_kw, int, char*)") + _iget_string_ptr = EclPrototype("char* ecl_kw_iget_string_ptr(ecl_kw, int)") + _iset_string_ptr = EclPrototype("void ecl_kw_iset_string_ptr(ecl_kw, int, char*)") + _iget_bool = EclPrototype("bool ecl_kw_iget_bool(ecl_kw, int)") + _iset_bool = EclPrototype("bool ecl_kw_iset_bool(ecl_kw, int, bool)") + _iget_int = EclPrototype("int ecl_kw_iget_int(ecl_kw, int)") + _iget_double = EclPrototype("double ecl_kw_iget_double(ecl_kw, int)") + _iget_float = EclPrototype("float ecl_kw_iget_float(ecl_kw, int)") + _float_ptr = EclPrototype("float* ecl_kw_get_float_ptr(ecl_kw)") + _int_ptr = EclPrototype("int* ecl_kw_get_int_ptr(ecl_kw)") + _double_ptr = EclPrototype("double* ecl_kw_get_double_ptr(ecl_kw)") + _free = EclPrototype("void ecl_kw_free(ecl_kw)") + _fwrite = EclPrototype("void ecl_kw_fwrite(ecl_kw, fortio)") + _get_header = EclPrototype("char* ecl_kw_get_header (ecl_kw)") + _set_header = EclPrototype("void ecl_kw_set_header_name (ecl_kw, char*)") + _get_data_type = EclPrototype("ecl_data_type_obj ecl_kw_get_data_type_python(ecl_kw)"); + + _int_sum = EclPrototype("int ecl_kw_element_sum_int(ecl_kw)") + _float_sum = EclPrototype("double ecl_kw_element_sum_float(ecl_kw)") + _iadd_squared = EclPrototype("void ecl_kw_inplace_add_squared(ecl_kw, ecl_kw)") + _isqrt = EclPrototype("void ecl_kw_inplace_sqrt(ecl_kw)") + _iadd = EclPrototype("void ecl_kw_inplace_add(ecl_kw, ecl_kw)") + _imul = EclPrototype("void ecl_kw_inplace_mul(ecl_kw, ecl_kw)") + _idiv = EclPrototype("void ecl_kw_inplace_div(ecl_kw, ecl_kw)") + _isub = EclPrototype("void ecl_kw_inplace_sub(ecl_kw, ecl_kw)") + _iabs = EclPrototype("void ecl_kw_inplace_abs(ecl_kw)") + _equal = EclPrototype("bool ecl_kw_equal(ecl_kw, ecl_kw)") + _equal_numeric = EclPrototype("bool ecl_kw_numeric_equal(ecl_kw, ecl_kw, double, double)") + + _assert_binary = EclPrototype("bool ecl_kw_size_and_numeric_type_equal(ecl_kw, ecl_kw)") + _scale_int = EclPrototype("void ecl_kw_scale_int(ecl_kw, int)") + _scale_float = EclPrototype("void ecl_kw_scale_float_or_double(ecl_kw, double)") + _shift_int = EclPrototype("void ecl_kw_shift_int(ecl_kw, int)") + _shift_float = EclPrototype("void ecl_kw_shift_float_or_double(ecl_kw, double)") + _copy_data = EclPrototype("void ecl_kw_memcpy_data(ecl_kw, ecl_kw)") + _set_int = EclPrototype("void ecl_kw_scalar_set_int(ecl_kw, int)") + _set_float = EclPrototype("void ecl_kw_scalar_set_float_or_double(ecl_kw, double)") + + _max_min_int = EclPrototype("void ecl_kw_max_min_int(ecl_kw, int*, int*)") + _max_min_float = EclPrototype("void ecl_kw_max_min_float(ecl_kw, float*, float*)") + _max_min_double = EclPrototype("void ecl_kw_max_min_double(ecl_kw, double*, double*)") + _fix_uninitialized = EclPrototype("void ecl_kw_fix_uninitialized(ecl_kw,int, int, int, int*)") + _create_actnum = EclPrototype("ecl_kw_obj ecl_kw_alloc_actnum(ecl_kw, float)") + _first_different = EclPrototype("int ecl_kw_first_different(ecl_kw, ecl_kw, int, double, double)") + _resize = EclPrototype("void ecl_kw_resize(ecl_kw, int)") + _safe_div = EclPrototype("bool ecl_kw_inplace_safe_div(ecl_kw,ecl_kw)") + + + @classmethod + def createCReference(cls, c_ptr, parent=None): + ecl_kw = super(EclKW, cls).createCReference(c_ptr, parent=parent) + if ecl_kw is None: + raise ValueError("Failed to create EclKW instance") + + ecl_kw.__private_init() + return ecl_kw + + + @classmethod + def createPythonObject(cls, c_ptr): + ecl_kw = super(EclKW, cls).createPythonObject(c_ptr) + if ecl_kw is None: + raise ValueError("Failed to create EclKW instance") + + ecl_kw.__private_init() + return ecl_kw + + + + @classmethod + def add_int_kw(cls, kw): + """Will add keyword @kw to the standard set of integer keywords.""" + cls.int_kw_set.add(kw) + + @classmethod + def del_int_kw(cls, kw): + """Will remove keyword @kw from the standard set of integer keywords.""" + cls.int_kw_set.discard(kw) + + @classmethod + def int_keywords(cls): + """Will return the current set of integer keywords.""" + return cls.int_kw_set + + + def slice_copy(self, slice_range): + (start, stop, step) = slice_range.indices(len(self)) + if stop > start: + return self._slice_copyc(start, stop, step) + else: + return None + + + def copy(self): + """ + Will create a deep copy of the current kw instance. + """ + return self._copyc() + + + + + @classmethod + def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): + """ + Function to load an EclKW instance from a grdecl formatted filehandle. + + This constructor can be used to load an EclKW instance from a + grdecl formatted file; the input files for petrophysical + properties are typically given as grdecl files. + + The @file argument should be a Python filehandle to an open + file. The @kw argument should be the keyword header you are + searching for, e.g. "PORO" or "PVTNUM"[1], the method will + then search forward through the file to look for this @kw. If + the keyword can not be found the method will return None. The + searching will start from the current position in the file; so + if you want to reposition the file pointer you should use the + seek() method of the file object first. + + Observe that there is a strict 8 character limit on @kw - + altough you could in principle use an arbitrary external + program to create grdecl files with more than 8 character + length headers, this implementation will refuse to even try + loading them. In that case you will have to rename the + keywords in your file - sorry. A TypeError exception + will be raised if @kw has more than 8 characters. + + The implementation in ert can read integer and float type + keywords from grdecl files; however the grdecl files have no + datatype header, and it is impossible to determine the type + reliably by inspection. Hence the type must be known when + reading the file. The algorithm for specifying type, in order + of presedence, is as follows: + + 1. The optional argument @ecl_type can be used to specify + the type: + + special_int_kw = EclKW.read_grdecl(fileH, 'INTKW', ecl_type=ECL_INT) + + If ecl_type is different from ECL_INT or + ECL_FLOAT a TypeError exception will be raised. + + If ecl_type == None (the default), the method will continue + to point 2. or 3. to determine the correct type. + + + 2. If the keyword is included in the set built in set + 'int_kw_set' the type will be ECL_INT_TYPE. + + pvtnum_kw = EclKW.read_grdecl(fileH, 'PVTNUM') + + Observe that (currently) no case conversions take place + when checking the 'int_kw_set'. The current built in set is + accesible through the int_kw property. + + + 3. Otherwise the default is float, i.e. ECL_FLOAT. + + EclKw reads grdecl with EclDataType + poro_kw = EclKW.read_grdecl(fileH, 'PORO') + + + Observe that since the grdecl files are quite weakly + structured it is difficult to verify the integrity of the + files, malformed input might therefore pass unnoticed before + things blow up at a later stage. + + [1]: It is possible, but not recommended, to pass in None for + @kw, in which case the method will load the first keyword + it finds in the file. + """ + + cfile = CFILE(fileH) + if kw: + if len(kw) > 8: + raise TypeError("Sorry keyword:%s is too long, must be eight characters or less." % kw) + + if ecl_type is None: + if cls.int_kw_set.__contains__(kw): + ecl_type = EclDataType.ECL_INT + else: + ecl_type = EclDataType.ECL_FLOAT + + ecl_type = warn_and_cast_data_type(ecl_type) + + if not isinstance(ecl_type, EclDataType): + raise TypeError("Expected EclDataType, was: %s" % type(ecl_type)) + + if not ecl_type in [EclDataType.ECL_FLOAT, EclDataType.ECL_INT]: + raise ValueError("The type:%s is invalid when loading keyword:%s" % (ecl_type.type_name, kw)) + + return cls._load_grdecl(cfile, kw, strict, ecl_type) + + + @classmethod + def fseek_grdecl(cls, fileH, kw, rewind=False): + """ + Will search through the open file and look for string @kw. + + If the search succeeds the function will return and the file + pointer will be positioned at the start of the kw, if the + search fails the function will return false and the file + pointer will be repositioned at the position it had prior to + the call. + + Only @kw instances which are found at the beginning of a line + (with optional leading space characters) are considered, + i.e. searching for the string PERMX in the cases below will + fail: + + -- PERMX + EQUIL PERMX / + + + The function will start searching from the current position in + the file and forwards, if the optional argument @rewind is + true the function rewind to the beginning of the file and + search from there after the initial search. + """ + cfile = CFILE(fileH) + return cls._fseek_grdecl(kw, rewind, cfile) + + + @classmethod + def fread(cls, fortio): + """ + Will read a new EclKW instance from the open FortIO file. + """ + return cls._fread_alloc(fortio) + + + def free(self): + self._free() + + def __repr__(self): + si = len(self) + nm = self.getName() + mm = 'type=%s' % str(self.getEclType()) + if self.isNumeric(): + mi, ma = self.getMinMax() + mm = 'min=%.2f, max=%.2f' % (mi,ma) + ad = self._ad_str() + fmt = 'EclKW(size=%d, name="%s", %s) %s' + return fmt % (si,nm,mm,ad) + + def __init__(self, name, size, data_type): + """Creates a brand new EclKW instance. + + This method will create a grand spanking new EclKW + instance. The instance will get name @name @size elements and + datatype @data_type. Using this method you could create a SOIL + keyword with: + + soil_kw = EclKW("SOIL", 10000, ECL_FLOAT_TYPE) + + """ + if len(name) > 8: + raise ValueError("Sorry - maximum eight characters in keyword name") + + data_type = warn_and_cast_data_type(data_type) + + if not isinstance(data_type, EclDataType): + raise TypeError("Expected an EclDataType, received: %s" % + type(data_type)) + + c_ptr = self._alloc_new(name, size, data_type) + super(EclKW, self).__init__(c_ptr) + self.__private_init() + + + + def __private_init(self): + self.data_ptr = None + + if self.data_type.is_int(): + self.data_ptr = self._int_ptr() + self.dtype = numpy.int32 + self.str_fmt = "%8d" + elif self.data_type.is_float(): + self.data_ptr = self._float_ptr() + self.dtype = numpy.float32 + self.str_fmt = "%13.4f" + elif self.data_type.is_double(): + self.data_ptr = self._double_ptr() + self.dtype = numpy.float64 + self.str_fmt = "%13.4f" + else: + # Iteration not supported for CHAR / BOOL + self.data_ptr = None + self.dtype = None + if self.data_type.is_char(): + self.str_fmt = "%8s" + elif self.data_type.is_bool(): + self.str_fmt = "%d" + elif self.data_type.is_mess(): + self.str_fmt = "%s" #"Message type" + elif self.data_type.is_string(): + self.str_fmt = "%" + str(self.data_type.element_size) + "s" + else: + raise ValueError("Unknown EclDataType (%s)!" % self.data_type.type_name) + + def sub_copy(self, offset, count, new_header=None): + """ + Will create a new block copy of the src keyword. + + If @new_header == None the copy will get the same 'name' as + the src, otherwise the keyword will get the @new_header as + header. + + The copy will start at @block of the src keyword and copy + @count elements; a negative value of @count is interpreted as + 'the rest of the elements' + + new1 = src.sub_copy(0, 10, new_header="NEW1") + new2 = src.sub_copy(10, -1, new_header="NEW2") + + If the count or index arguments are in some way invalid the + method will raise IndexError. + """ + if offset < 0 or offset >= len(self): + raise IndexError("Offset:%d invalid - valid range:[0,%d)" % (offset, len(self))) + + if offset + count > len(self): + raise IndexError("Invalid value of (offset + count):%d" % (offset + count)) + + return self._sub_copy(new_header, offset, count) + + + def is_numeric(self): + """ + Will check if the keyword contains numeric data, i.e int, float or double. + """ + return self.data_type.is_numeric() + + def ecl_kw_instance(self): + return True + + + + def __len__(self): + """ + Returns the number of elements. Implements len() + """ + return self._get_size() + + + def __deep_copy__(self, memo): + """ + Python special routine used to perform deep copy. + """ + ecl_kw = self.copy() + return ecl_kw + + + def __getitem__(self, index): + """ + Function to support index based lookup: y = kw[index] + """ + if isinstance(index,int): + length = len(self) + if index < 0: + # We allow one level of negative indexing + index += len(self) + + if index < 0 or index >= length: + raise IndexError + else: + if self.data_ptr: + return self.data_ptr[ index ] + else: + if self.data_type.is_bool(): + return self._iget_bool(index) + elif self.data_type.is_char(): + return self._iget_char_ptr(index) + elif self.data_type.is_string(): + return self._iget_string_ptr(index) + else: + raise TypeError("Internal implementation error ...") + elif isinstance(index, slice): + return self.slice_copy(index) + else: + raise TypeError("Index should be integer type") + + + def __setitem__(self, index,value): + """ + Function to support index based assignment: kw[index] = value + """ + if isinstance(index, int): + length = len(self) + if index < 0: + # Will only wrap backwards once + index = len(self) + index + + if index < 0 or index >= length: + raise IndexError + else: + if self.data_ptr: + self.data_ptr[ index ] = value + else: + if self.data_type.is_bool(): + self._iset_bool(index, value) + elif self.data_type.is_char(): + return self._iset_char_ptr(index, value) + elif self.data_type.is_string(): + return self._iset_string_ptr(index, value) + else: + raise SystemError("Internal implementation error ...") + elif isinstance(index, slice): + (start, stop, step) = index.indices(len(self)) + index = start + while index < stop: + self[index] = value + index += step + else: + raise TypeError("Index should be integer type") + + + ################################################################# + + + def __IMUL__(self, factor, mul=True): + if self.isNumeric(): + if hasattr(factor, "ecl_kw_instance"): + if self.assert_binary(factor): + if mul: + self._imul(factor) + else: + self._idiv(factor) + else: + raise TypeError("Type mismatch") + else: + if not mul: + factor = 1.0 / factor + + if self.data_type.is_int(): + if isinstance(factor, int): + self._scale_int(factor) + else: + raise TypeError("Type mismatch") + else: + if isinstance(factor, int) or isinstance(factor, float): + self._scale_float(factor) + else: + raise TypeError("Only muliplication with scalar supported") + else: + raise TypeError("Not numeric type") + + return self + + + def __IADD__(self, delta, add=True): + if self.isNumeric(): + if type(self) == type(delta): + if self.assert_binary(delta): + if add: + self._iadd(delta) + else: + self._isub(delta) + else: + raise TypeError("Type / size mismatch") + else: + if add: + sign = 1 + else: + sign = -1 + + if self.data_type.is_int(): + if isinstance(delta, int): + self._shift_int(delta * sign) + else: + raise TypeError("Type mismatch") + else: + if isinstance(delta, int) or isinstance(delta, float): + self._shift_float(delta * sign) # Will call the _float() or _double() function in the C layer. + else: + raise TypeError("Type mismatch") + else: + raise TypeError("Type / size mismatch") + + return self + + def __iadd__(self, delta): + return self.__IADD__(delta, True) + + def __isub__(self, delta): + return self.__IADD__(delta, False) + + def __imul__(self, delta): + return self.__IMUL__(delta, True) + + def __idiv__(self, delta): + return self.__IMUL__(delta, False) + + + ################################################################# + + def __abs__(self): + if self.isNumeric(): + copy = self.copy() + copy._iabs() + return copy + else: + raise TypeError("The __abs__() function is only implemented for numeric types") + + + + def __add__(self, delta): + copy = self.copy() + copy += delta + return copy + + def __radd__(self, delta): + return self.__add__(delta) + + def __sub__(self, delta): + copy = self.copy() + copy -= delta + return copy + + def __rsub__(self, delta): + return self.__sub__(delta) * -1 + + def __mul__(self, factor): + copy = self.copy() + copy *= factor + return copy + + def __rmul__(self, factor): + return self.__mul__(factor) + + def __div__(self, factor): + copy = self.copy() + copy /= factor + return copy + + # No __rdiv__() + + def add_squared(self, other): + if not self.is_numeric(): + raise TypeError("Can only be called on numeric types") + + if not self.assert_binary(other): + raise ValueError("Invalid argument to method add_squared") + + self._iadd_squared(other) + + def isqrt(self): + if not self.is_numeric(): + raise TypeError("Can only be called on numeric types") + + self._isqrt() + + + def sum(self, mask = None, force_active = False): + """ + Will calculate the sum of all the elements in the keyword. + + String: Raise ValueError exception. + Bool: The number of true values + """ + if mask is None: + if self.data_type.is_int(): + return self._int_sum() + elif self.data_type.is_float(): + return self._float_sum() + elif self.data_type.is_double(): + return self._float_sum() + elif self.data_type.is_bool(): + sum = 0 + for elm in self: + if elm: + sum += 1 + return sum + else: + raise ValueError('The keyword "%s" is of string type - sum is not implemented' % self.getName()) + + return mask.sum_kw(self, force_active) + + + + def assert_binary(self, other): + """ + Utility function to assert that keywords @self and @other can + be combined. + """ + return self._assert_binary(other) + + ################################################################# + + def assign(self, value, mask=None, force_active=False): + """ + Assign a value to current kw instance. + + This method is used to assign value(s) to the current EclKW + instance. The @value parameter can either be a scalar, or + another EclKW instance. To set all elements of a keyword to + 1.0: + + kw.assign(1.0) + + The numerical type of @value must be compatible with the + current keyword. The optional @mask argument should be an + EclRegion instance which can be used to limit the assignment + to only parts of the EclKW. In the example below we select all + the elements with PORO below 0.10, and then assign EQLNUM + value 88 to those cells: + + grid = ecl.EclGrid("ECLIPSE.EGRID") + reg = ecl.EclRegion(grid, false) + init = ecl.EclFile("ECLIPSE.INIT") + + poro = init["PORO"][0] + eqlnum = init["EQLNUM"][0] + reg.select_below(poro, 0.10) + + eqlnum.assign(88, mask = reg) + + The EclRegion instance has two equivalent sets of selected + indices; one consisting of active indices and one consisting + of global indices. By default the assign() method will select + the global indices if the keyword has nx*ny*nz elements and + the active indices if the kw has nactive elements. By setting + the optional argument @force_active to true, you can force the + method to only modify the active indices, even though the + keyword has nx*ny*nz elements; if the keyword has nactive + elements the @force_active flag is not considered. + """ + if self.isNumeric(): + if type(value) == type(self): + if mask is not None: + mask.copy_kw(self, value, force_active) + else: + if self.assert_binary(value): + self._copy_data(value) + else: + raise TypeError("Type / size mismatch") + else: + if mask is not None: + mask.set_kw(self, value, force_active) + else: + if self.data_type.is_int(): + if isinstance(value, int): + self._set_int(value) + else: + raise TypeError("Type mismatch") + else: + if isinstance(value, int) or isinstance(value, float): + self._set_float(value) + else: + raise TypeError("Only muliplication with scalar supported") + + + def add(self, other, mask=None, force_active=False): + """ + See method assign() for documentation of optional arguments + @mask and @force_active. + """ + if mask is not None: + mask.iadd_kw(self, other, force_active) + else: + return self.__iadd__(other) + + def sub(self, other, mask=None, force_active=False): + """ + See method assign() for documentation of optional arguments + @mask and @force_active. + """ + if mask is not None: + mask.isub_kw(self, other, force_active) + else: + return self.__isub__(other) + + def mul(self, other, mask=None, force_active=False): + """ + See method assign() for documentation of optional arguments + @mask and @force_active. + """ + if mask is not None: + mask.imul_kw(self, other, force_active) + else: + return self.__imul__(other) + + def div(self, other, mask=None, force_active=False): + """ + See method assign() for documentation of optional arguments + @mask and @force_active. + """ + if mask is not None: + mask.idiv_kw(self, other, force_active) + else: + return self.__idiv__(other) + + def apply(self, func, arg=None, mask=None, force_active=False): + """ + Will apply the function @func on the keyword - inplace. + + The function @func should take a scalar value from the ecl_kw + vector as input, and return a scalar value of the same type; + optionally you can supply a second argument with the @arg + attribute: + + def cutoff(x, limit): + if x > limit: + return x + else: + return 0 + + + kw.apply(math.sin) + kw.apply(cutoff, arg=0.10) + + + See method assign() for documentation of optional arguments + @mask and @force_active. + """ + if mask is not None: + active_list = mask.kw_index_list(self, force_active) + if arg: + for index in active_list: + self.data_ptr[index] = func(self.data_ptr[index], arg) + else: + for index in active_list: + self.data_ptr[index] = func(self.data_ptr[index]) + else: + if arg: + for i in range(len(self)): + self.data_ptr[i] = func(self.data_ptr[i], arg) + else: + for i in range(len(self)): + self.data_ptr[i] = func(self.data_ptr[i]) + + + def equal(self, other): + """ + Will check if the two keywords are (exactly) equal. + + The check is based on the content of the keywords, and not + pointer comparison. + """ + if isinstance(other, EclKW): + return self._equal(other) + else: + raise TypeError("Can only compare with another EclKW") + + + def __eq__(self, other): + return self.equal(other) + + def __hash__(self): + return hash(self._get_header()) + + + def equal_numeric(self, other, epsilon=1e-6, abs_epsilon=None, rel_epsilon=None): + """Will check if two numerical keywords are ~nearly equal. + + + If the keywords are of type integer, the comparison is + absolute. + + If you pass in xxx_epsilon <= 0 the xxx_epsilon will be + ignored in the test. + + """ + if isinstance(other, EclKW): + if abs_epsilon is None: + abs_epsilon = epsilon + + if rel_epsilon is None: + rel_epsilon = epsilon + + return self._equal_numeric(other, abs_epsilon, rel_epsilon) + else: + raise TypeError("Can only compare with another EclKW") + + + ################################################################# + + def deep_copy(self): + ecl_kw = self.__deep_copy__({}) + return ecl_kw + + def fort_io_size(self): + """ + The number of bytes this keyword would occupy in a BINARY file. + """ + return self._get_fortio_size() + + def set_name(self, name): + if len(name) > 8: + raise ValueError("Sorry: the name property must be max 8 characters long :-(") + self._set_header(name) + + @property + def name(self): + n = self._get_header() + return str(n) if n else '' + + @name.setter + def name(self, value): + self.set_name(value) + + def get_name(self): + return self.name + + def resize(self, new_size): + """ + Will set the new size of the kw to @new_size. + """ + if new_size >= 0: + self._resize(int(new_size)) + + # Iteration is based on a pointer to the underlying storage, + # that will generally by reset by the resize() call; i.e. we + # need to call the __private_init() method again. + self.__private_init() + + + def get_min_max(self): + """ + Will return a touple (min,max) for numerical types. + + Will raise TypeError exception if the keyword is not of + numerical type. + """ + if self.data_type.is_float(): + min_ = ctypes.c_float() + max_ = ctypes.c_float() + self._max_min_float(ctypes.byref(max_), ctypes.byref(min_)) + elif self.data_type.is_double(): + min_ = ctypes.c_double() + max_ = ctypes.c_double() + self._max_min_double(ctypes.byref(max_), ctypes.byref(min_)) + elif self.data_type.is_int(): + min_ = ctypes.c_int() + max_ = ctypes.c_int() + self._max_min_int(ctypes.byref(max_), ctypes.byref(min_)) + else: + raise TypeError("min_max property not defined for keywords of type: %s" % self.type) + return (min_.value, max_.value) + + + def get_max(self): + mm = self.getMinMax() + return mm[1] + + + def get_min(self): + mm = self.getMinMax() + return mm[0] + + @property + def type(self): + return self.getEclType() + + @property + def data_type(self): + return self._get_data_type() + + @property + def type_name(self): + return self.data_type.type_name + + def type_name(self): + return self.data_type.type_name + + def get_ecl_type(self): + warnings.warn("EclTypeEnum is deprecated. " + + "You should instead provide an EclDataType", + DeprecationWarning) + + return self._get_type() + + + + + @property + def header(self): + return (self.getName(), len(self), self.typeName()) + + @property + def array(self): + a = self.data_ptr + if not a == None: + a.size = len(self) + a.__parent__ = self # Inhibit GC + return a + + + def str_data(self, width, index1, index2, fmt): + """ + Helper function for str() method. + """ + data = [] + s = "" + for index in range(index1, index2): + data.append(self[index]) + for index in range(len(data)): + s += fmt % data[ index ] + if index % width == (width - 1): + s+= "\n" + return s + + + def str(self, width=5, max_lines=10, fmt=None): + """ + Return string representation of kw for pretty printing. + + The function will return a string consisting of a header, and + then a chunk of data. The data will be formatted in @width + columns, and a maximum of @max_lines lines. If @max_lines is + not sufficient the first elements in the kewyord are + represented, a .... continuation line and then the last part + of the keyword. If @max_lines is None all of the vector will + be printed, irrespective of how long it is. + + If a value is given for @fmt that is used as format string for + each element, otherwise a type-specific default format is + used. If given the @fmt string should contain spacing between + the elements. The implementation of the builtin method + __str__() is based on this method. + """ + s = "%-8s %8d %-4s\n" % (self.getName(), len(self), self.typeName()) + lines = len(self) // width + if not fmt: + fmt = self.str_fmt + " " + + if max_lines is None or lines <= max_lines: + s += self.str_data(width, 0, len(self), fmt) + else: + s1 = width * max_lines // 2 + s += self.str_data(width , 0, s1, fmt) + s += " .... \n" + s += self.str_data(width , len(self) - s1, len(self), fmt) + + return s + + def __str__(self): + """ + Return string representation - see method str(). + """ + return self.str(width=5, max_lines=10) + + + def numpy_view(self): + """Will return a numpy view to the underlying data. + + The data in this numpy array is *shared* with the EclKW + instance, meaning that updates in one will be reflected in the + other. + """ + + if self.dtype is numpy.float64: + ct = ctypes.c_double + elif self.dtype is numpy.float32: + ct = ctypes.c_float + elif self.dtype is numpy.int32: + ct = ctypes.c_int + else: + raise ValueError("Invalid type - numpy array only valid for int/float/double") + + ap = ctypes.cast(self.data_ptr, ctypes.POINTER(ct * len(self))) + return numpy.frombuffer(ap.contents, dtype=self.dtype) + + + def numpy_copy(self): + """Will return a numpy array which contains a copy of the EclKW data. + + The numpy array has a separate copy of the data, so that + changes to either the numpy array or the EclKW will *not* be + reflected in the other datastructure. This is in contrast to + the EclKW.numpyView() method where the underlying data is + shared. + """ + view = self.numpyView() + return numpy.copy(view) + + def fwrite(self, fortio): + self._fwrite(fortio) + + def write_grdecl(self, file): + """ + Will write keyword in GRDECL format. + + This method will write the current keyword in GRDECL format, + the @file argument must be a Python file handle to an already + opened file. In the example below we load the porosity from an + existing GRDECL file, set all poro values below 0.05 to 0.00 + and write back an updated GRDECL file. + + poro = ecl.EclKW.read_grdecl(open("poro1.grdecl", "r"), "PORO") + grid = ecl.EclGrid("ECLIPSE.EGRID") + reg = ecl.EclRegion(grid, False) + + reg.select_below(poro, 0.05) + poro.assign(0.0, mask=reg) + + fileH = open("poro2.grdecl", "w") + poro.write_grdecl(fileH) + fileH.close() + + """ + cfile = CFILE(file) + self._fprintf_grdecl(cfile) + + + + def fprintf_data(self, file, fmt=None): + """ + Will print the keyword data formatted to file. + + The @file argument should be a python file handle to a file + opened for writing. The @fmt argument is used as fprintf() + format specifier, observe that the format specifier should + include a separation character between the elements. If no + @fmt argument is supplied the default str_fmt specifier is + used for every element, separated by a newline. + + In the case of boolean data the function will print o and 1 + for False and True respectively. For string data the function + will print the data as 8 characters long string with blank + padding on the right. + """ + if fmt is None: + fmt = self.str_fmt + "\n" + cfile = CFILE(file) + self._fprintf_data(fmt, cfile) + + def create_actnum(self, porv_limit = 0): + """Will create ACTNUM keyword from PORV keyword. + + This quite specialized method will create an ACTNUM keyword based on + interpreting the current keyword as a PORV keyword. The method will + raise an exception if the current keyword is not ("PORV", FLOAT). The + code implemented in C for speed is essentially: + + actnum = [ 1 if x > porv_limit else 0 for x in self ] + + """ + if not self.data_type.is_float(): + raise TypeError("The PORV keyword must be of type FLOAT") + + if not self.get_name() == "PORV": + raise ValueError("Input argument must be PORV keyword") + + return self._create_actnum(porv_limit) + + + def fix_uninitialized(self, grid): + """ + Special case function for region code. + """ + dims = grid.getDims() + actnum = grid.exportACTNUM() + self._fix_uninitialized(dims[0], dims[1], dims[2], actnum.getDataPtr()) + + + def get_data_ptr(self): + if self.data_type.is_int(): + return self._int_ptr() + elif self.data_type.is_float(): + return self._float_ptr() + elif self.data_type.is_double(): + return self._double_ptr() + else: + raise ValueError("Only numeric types can export data pointer") + + + def first_different(self, other, offset=0, epsilon=0, abs_epsilon=None, rel_epsilon=None): + if len(self) != len(other): + raise ValueError("Keywords must have equal size") + + if offset >= len(self): + raise IndexError("Offset:%d invalid - size:%d" % (offset, len(self))) + + if self.getEclType() != other.getEclType(): + raise TypeError("The two keywords have different type") + + if abs_epsilon is None: + abs_epsilon = epsilon + + if rel_epsilon is None: + rel_epsilon = epsilon + + return self._first_different(other, offset, abs_epsilon, rel_epsilon) + + + + + def scatter_copy(self, actnum): + if not isinstance(actnum, EclKW): + raise TypeError("The actnum argument must be of type EclKW") + + return self._global_copy(actnum) + + + def safe_div(self, divisor): + if not len(self) == len(divisor): + raise ValueError("Length mismatch between %s and %s" % (self.name, divisor.name)) + + if not self.is_numeric(): + raise TypeError("The self keyword must be of numeric type") + + if not divisor.is_numeric(): + raise TypeError("Must divide by numeric keyword") + + ok = self._safe_div( divisor ) + if not ok: + raise NotImplementedError("safe_div not implemented for this type combination") + + + + +monkey_the_camel(EclKW, 'intKeywords', EclKW.int_keywords, classmethod) +monkey_the_camel(EclKW, 'isNumeric', EclKW.is_numeric) +monkey_the_camel(EclKW, 'fortIOSize', EclKW.fort_io_size) +monkey_the_camel(EclKW, 'setName', EclKW.set_name) +monkey_the_camel(EclKW, 'getName', EclKW.get_name) +monkey_the_camel(EclKW, 'getMinMax', EclKW.get_min_max) +monkey_the_camel(EclKW, 'getMax', EclKW.get_max) +monkey_the_camel(EclKW, 'getMin', EclKW.get_min) +monkey_the_camel(EclKW, 'typeName', EclKW.type_name) +monkey_the_camel(EclKW, 'getEclType', EclKW.get_ecl_type) +monkey_the_camel(EclKW, 'numpyView', EclKW.numpy_view) +monkey_the_camel(EclKW, 'numpyCopy', EclKW.numpy_copy) +monkey_the_camel(EclKW, 'fixUninitialized', EclKW.fix_uninitialized) +monkey_the_camel(EclKW, 'getDataPtr', EclKW.get_data_ptr) +monkey_the_camel(EclKW, 'firstDifferent', EclKW.first_different) diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py new file mode 100644 index 0000000000..bdd2e33e8f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py @@ -0,0 +1,159 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_restart_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclFileEnum +from ecl.eclfile import EclFile, Ecl3DFile, Ecl3DKW + +class EclRestartHead(BaseCClass): + TYPE_NAME = "ecl_rsthead" + _alloc = EclPrototype("void* ecl_rsthead_alloc(ecl_file_view , int )", bind = False) + _alloc_from_kw = EclPrototype("void* ecl_rsthead_alloc_from_kw(int , ecl_kw , ecl_kw , ecl_kw )", bind = False) + _free = EclPrototype("void ecl_rsthead_free(ecl_rsthead)") + _get_report_step = EclPrototype("int ecl_rsthead_get_report_step(ecl_rsthead)") + _get_sim_time = EclPrototype("time_t ecl_rsthead_get_sim_time(ecl_rsthead)") + _get_sim_days = EclPrototype("double ecl_rsthead_get_sim_days(ecl_rsthead)") + _get_nxconz = EclPrototype("int ecl_rsthead_get_nxconz(ecl_rsthead)") + _get_ncwmax = EclPrototype("int ecl_rsthead_get_ncwmax(ecl_rsthead)") + + def __init__(self , kw_arg = None , rst_view = None): + if kw_arg is None and rst_view is None: + raise ValueError('Cannot construct EclRestartHead without one of kw_arg and rst_view, both were None!') + + if not kw_arg is None: + report_step , intehead_kw , doubhead_kw , logihead_kw = kw_arg + c_ptr = self._alloc_from_kw( report_step , intehead_kw , doubhead_kw , logihead_kw ) + else: + c_ptr = self._alloc( rst_view , -1 ) + + super(EclRestartHead, self).__init__(c_ptr) + + + def free(self): + self._free( ) + + def get_report_step(self): + return self._get_report_step( ) + + def get_sim_date(self): + ct = CTime( self._get_sim_time( ) ) + return ct.datetime( ) + + def get_sim_days(self): + return self._get_sim_days( ) + + def well_details(self): + return {"NXCONZ" : self._get_nxconz(), + "NCWMAX" : self._get_ncwmax()} + + + + +class EclRestartFile(Ecl3DFile): + + def __init__(self , grid , filename , flags = 0): + """Will open an Eclipse restart file. + + The EclRestartFile class will open an eclipse restart file, in + unified or non unified format. The constructor will infer the + file type based on the filename, and will raise a ValueError + exception if the file type is not ECL_RESTART_FILE or + ECL_UNIFIED_RESTART_FILE. + + The EclRestartFile will use a grid reference to create Ecl3DKw + instances for all the keyword elements which have either + 'nactive' or 'nx*ny*nz' elements. + """ + + file_type , report_step , fmt_file = EclFile.getFileType( filename ) + if not file_type in [EclFileEnum.ECL_RESTART_FILE, EclFileEnum.ECL_UNIFIED_RESTART_FILE]: + raise ValueError('The input filename "%s" does not correspond to a restart file. Please follow the Eclipse naming conventions' + % filename) + + super(EclRestartFile , self).__init__( grid, filename , flags) + self.rst_headers = None + if file_type == EclFileEnum.ECL_RESTART_FILE: + self.is_unified = False + self.report_step = report_step + else: + self.is_unified = True + + + + def unified(self): + """ + Will return True if the file we have opened is unified. + """ + return self.is_unified + + + def assert_headers(self): + if self.rst_headers is None: + self.rst_headers = [] + if self.unified(): + for index in range(self.num_named_kw("SEQNUM")): + self.rst_headers.append( EclRestartHead( rst_view = self.restartView( seqnum_index = index ))) + else: + intehead_kw = self["INTEHEAD"][0] + doubhead_kw = self["DOUBHEAD"][0] + if "LOGIHEAD" in self: + logihead_kw = self["LOGIHEAD"][0] + else: + logihead_kw = None + + self.rst_headers.append( EclRestartHead( kw_arg = (self.report_step , intehead_kw , doubhead_kw , logihead_kw) )) + + + def time_list(self): + """Will return a list of report_step, simulation time and days. + + The return value will be a list tuples. For a unified restart + file with the three report steps {10,15,20} it can look like: + + [ (10, datetime.datetime( 2010 , 1 , 1 , 0 , 0 , 0 ) , 100.0), + (15, datetime.datetime( 2010 , 3 , 1 , 0 , 0 , 0 ) , 160.0), + (20, datetime.datetime( 2010 , 5 , 1 , 0 , 0 , 0 ) , 220.0) ] + + For a non-unified restart file the list will have only one element. + """ + + self.assertHeaders() + time_list = [] + for header in self.rst_headers: + time_list.append( (header.getReportStep() , header.getSimDate( ) , header.getSimDays( )) ) + + return time_list + + + def headers(self): + self.assertHeaders() + return self.rst_headers + + + def get_header(self, index): + self.assertHeaders() + return self.rst_headers[index] + +monkey_the_camel(EclRestartHead, 'getReportStep', EclRestartHead.get_report_step) +monkey_the_camel(EclRestartHead, 'getSimDate', EclRestartHead.get_sim_date) +monkey_the_camel(EclRestartHead, 'getSimDays', EclRestartHead.get_sim_days) + +monkey_the_camel(EclRestartFile, 'assertHeaders', EclRestartFile.assert_headers) +monkey_the_camel(EclRestartFile, 'timeList', EclRestartFile.time_list) diff --git a/ThirdParty/Ert/python/ecl/eclfile/fortio.py b/ThirdParty/Ert/python/ecl/eclfile/fortio.py new file mode 100644 index 0000000000..e454a9b8b0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/fortio.py @@ -0,0 +1,211 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'fortio.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Module to support transparent binary IO of Fortran created files. + +Fortran is a a funny language; when writing binary blobs of data to +file the Fortran runtime will silently add a header and footer around +the date. The Fortran code: + + integer array(100) + write(unit) array + +it actually writes a head and tail in addition to the actual +data. The header and tail is a 4 byte integer, which value is the +number of bytes in the immediately following record. I.e. what is +actually found on disk after the Fortran code above is: + + | 400 | array ...... | 400 | + +The fortio.c file implements the fortio_type C structure which can be +used to read and write these structures transparently. The current +python module is a minimal wrapping of this datastructure; mainly to +support passing of FortIO handles to the underlying C functions. A +more extensive wrapping of the fortio implementation would be easy. +""" +import ctypes +import os + +from cwrap import BaseCClass +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype + + +class FortIO(BaseCClass): + TYPE_NAME = "fortio" + + READ_MODE = 1 + WRITE_MODE = 2 + READ_AND_WRITE_MODE = 3 + APPEND_MODE = 4 + + _open_reader = EclPrototype("void* fortio_open_reader(char*, bool, bool)", bind=False) + _open_writer = EclPrototype("void* fortio_open_writer(char*, bool, bool)", bind=False) + _open_readwrite = EclPrototype("void* fortio_open_readwrite(char*, bool, bool)", bind=False) + _open_append = EclPrototype("void* fortio_open_append(char*, bool, bool)", bind=False) + _guess_fortran = EclPrototype("bool fortio_looks_like_fortran_file(char*, bool)", bind=False) + + _write_record = EclPrototype("void fortio_fwrite_record(fortio, char*, int)") + _get_position = EclPrototype("long fortio_ftell(fortio)") + _seek = EclPrototype("void fortio_fseek(fortio, long, int)") + _close = EclPrototype("bool fortio_fclose(fortio)") + _truncate = EclPrototype("bool fortio_ftruncate(fortio, long)") + _filename = EclPrototype("char* fortio_filename_ref(fortio)") + + + def __init__(self, file_name, mode=READ_MODE, fmt_file=False, endian_flip_header=True): + """Will open a new FortIO handle to @file_name - default for reading. + + The newly created FortIO handle will open the underlying FILE* + for reading, but if you pass the flag mode=FortIO.WRITE_MODE + the file will be opened for writing. + + Observe that the flag @endian_flip_header will only affect the + interpretation of the block size markers in the file, endian + flipping of the actual data blocks must be handled at a higher + level. + + When you are finished working with the FortIO instance you can + manually close it with the close() method, alternatively that + will happen automagically when it goes out of scope. + + Small example script opening a restart file, and then writing + all the pressure keywords to another file: + + import sys + from ecl.ecl import FortIO, EclFile + + rst_file = EclFile(sys.argv[1]) + fortio = FortIO("PRESSURE", mode=FortIO.WRITE_MODE) + + for kw in rst_file: + if kw.name() == "PRESSURE": + kw.write(fortio) + + fortio.close() + + See the documentation of openFortIO() for an alternative + method based on a context manager and the with statement. + + """ + read_modes = (FortIO.READ_MODE, FortIO.APPEND_MODE, FortIO.READ_AND_WRITE_MODE) + if mode in read_modes and not os.path.exists(file_name): + raise IOError('No such file "%s".' % file_name) + if mode == FortIO.READ_MODE: + c_pointer = self._open_reader(file_name, fmt_file, endian_flip_header) + elif mode == FortIO.WRITE_MODE: + c_pointer = self._open_writer(file_name, fmt_file, endian_flip_header) + elif mode == FortIO.READ_AND_WRITE_MODE: + c_pointer = self._open_readwrite(file_name, fmt_file, endian_flip_header) + elif mode == FortIO.APPEND_MODE: + c_pointer = self._open_append(file_name, fmt_file, endian_flip_header) + else: + raise UserWarning("Unknown mode: %d" % mode) + + self.__mode = mode + if not c_pointer: + raise IOError('Failed to open FortIO file "%s".' % file_name) + super(FortIO, self).__init__(c_pointer) + + + + def close(self): + if self: + self._close() + self._invalidateCPointer() + + + def get_position(self): + """ @rtype: long """ + return self._get_position() + + + def truncate(self, size=None): + """Will truncate the file to new size. + + If the method is called without a size argument the stream + will be truncated to the current position. + """ + if size is None: + size = self.getPosition() + + if not self._truncate(size): + raise IOError("Truncate of fortran filehandle:%s failed" % self.filename()) + + + def filename(self): + return self._filename() + + + def seek(self, position, whence=0): + # SEEK_SET = 0 + # SEEK_CUR = 1 + # SEEK_END = 2 + self._seek(position, whence) + + + @classmethod + def is_fortran_file(cls, filename, endian_flip=True): + + """@rtype: bool + @type filename: str + + + Will use heuristics to try to guess if @filename is a binary + file written in fortran style. ASCII files will return false, + even if they are structured as ECLIPSE keywords. + """ + return cls._guess_fortran(filename, endian_flip) + + + def free(self): + self.close() + + +class FortIOContextManager(object): + + def __init__(self, fortio): + self.__fortio = fortio + + def __enter__(self): + return self.__fortio + + def __exit__(self, exc_type, exc_val, exc_tb): + self.__fortio.close() + return exc_type is not None + + +def openFortIO(file_name, mode=FortIO.READ_MODE, fmt_file=False, endian_flip_header=True): + """Will create FortIO based context manager for use with with. + + The with: statement and context managers is a good alternative in + the situation where you need to ensure resource cleanup. + + import sys + from ecl.ecl import FortIO, EclFile + + rst_file = EclFile(sys.argv[1]) + with openFortIO("PRESSURE", mode=FortIO.WRITE_MODE) as fortio: + for kw in rst_file: + if kw.name() == "PRESSURE": + kw.write(fortio) + + """ + return FortIOContextManager(FortIO(file_name, mode=mode, fmt_file=fmt_file, + endian_flip_header=endian_flip_header)) + +monkey_the_camel(FortIO, 'getPosition', FortIO.get_position) +monkey_the_camel(FortIO, 'isFortranFile', FortIO.is_fortran_file, classmethod) diff --git a/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt b/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt new file mode 100644 index 0000000000..f4b96370f9 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt @@ -0,0 +1,9 @@ +set(PYTHON_SOURCES + __init__.py + ecl_grav.py + ecl_grav_calc.py + ecl_subsidence.py + +) + +add_python_package("python.ecl.gravimetry" ${PYTHON_INSTALL_PREFIX}/ecl/gravimetry "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/gravimetry/__init__.py b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py new file mode 100644 index 0000000000..f218261dda --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py @@ -0,0 +1,28 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" + ecl_grav/EclGrav: Class used to simplify evaluation of ECLIPSE + modelling time-lapse gravitational surveys. + + ecl_subsidence/EclSubsidence: Small class used to evaluate simulated + subsidence from ECLIPSE simulations; analogous to the EcLGrav + functionality. +""" + +from .ecl_subsidence import EclSubsidence +from .ecl_grav_calc import phase_deltag, deltag +from .ecl_grav import EclGrav diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py new file mode 100644 index 0000000000..f8d75a3822 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py @@ -0,0 +1,220 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_grav.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Calculate dynamic change in gravitational strength. + +The ecl_grav module contains functionality to load time-lapse ECLIPSE +results and calculate the change in gravitational strength between the +different surveys. The implementation is a thin wrapper around the +ecl_grav.c implementation in the libecl library. +""" +from cwrap import BaseCClass + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPhaseEnum +import ecl.eclfile + +class EclGrav(BaseCClass): + """ + Holding ECLIPSE results for calculating gravity changes. + + The EclGrav class is a collection class holding the results from + ECLIPSE forward modelling of gravity surveys. Observe that the + class is focused on the ECLIPSE side of things, and does not have + any notion of observed values or measurement locations; that + should be handled by the scope using the EclGrav class. + + Typical use of the EclGrav class involves the following steps: + + 1. Create the EclGrav instance. + 2. Add surveys with the add_survey_XXXX() methods. + 3. Evalute the gravitational response with the eval() method. + """ + TYPE_NAME = "ecl_grav" + _grav_alloc = EclPrototype("void* ecl_grav_alloc(ecl_grid, ecl_file)", bind=False) + _free = EclPrototype("void ecl_grav_free(ecl_grav)") + _add_survey_RPORV = EclPrototype("void* ecl_grav_add_survey_RPORV(ecl_grav, char*, ecl_file_view)") + _add_survey_PORMOD = EclPrototype("void* ecl_grav_add_survey_PORMOD(ecl_grav, char*, ecl_file_view)") + _add_survey_FIP = EclPrototype("void* ecl_grav_add_survey_FIP(ecl_grav, char*, ecl_file_view)") + _add_survey_RFIP = EclPrototype("void* ecl_grav_add_survey_RFIP(ecl_grav, char*, ecl_file_view)") + _new_std_density = EclPrototype("void ecl_grav_new_std_density(ecl_grav, int, double)") + _add_std_density = EclPrototype("void ecl_grav_add_std_density(ecl_grav, int, int, double)") + _eval = EclPrototype("double ecl_grav_eval(ecl_grav, char*, char*, ecl_region, double, double, double, int)") + + + + def __init__(self, grid, init_file): + """ + Creates a new EclGrav instance. + + The input arguments @grid and @init_file should be instances + of EclGrid and EclFile respectively. + """ + self.init_file = init_file # Inhibit premature garbage collection of init_file + + c_ptr = self._grav_alloc(grid, init_file) + super(EclGrav, self).__init__(c_ptr) + + self.dispatch = {"FIP" : self.add_survey_FIP, + "RFIP" : self.add_survey_RFIP, + "PORMOD" : self.add_survey_PORMOD, + "RPORV" : self.add_survey_RPORV} + + + def add_survey_RPORV(self, survey_name, restart_view): + """ + Add new survey based on RPORV keyword. + + Add a new survey; in this context a survey is the state of + reservoir, i.e. an ECLIPSE restart file. The @survey_name + input argument will be used when refering to this survey at a + later stage. The @restart_view input argument should be an + EclFile instance with data from one report step. A typical way + to load the @restart_view argument is: + + import datetime + from ecl.ecl import EclRestartFile + ... + ... + date = datetime.datetime(year, month, day) + rst_file = EclRestartFile("ECLIPSE.UNRST") + restart_view1 = rst_file.restartView(sim_time=date) + restart_view2 = rst_file.restartView(report_step=67) + + The pore volume of each cell will be calculated based on the + RPORV keyword from the restart files. The methods + add_survey_PORMOD() and add_survey_FIP() are alternatives + which are based on other keywords. + """ + self._add_survey_RPORV(survey_name, restart_view) + + def add_survey_PORMOD(self, survey_name, restart_view): + """ + Add new survey based on PORMOD keyword. + + The pore volum is calculated from the initial pore volume and + the PORV_MOD keyword from the restart file; see + add_survey_RPORV() for further details. + """ + self._add_survey_PORMOD(survey_name, restart_view) + + def add_survey_FIP(self, survey_name, restart_view): + """ + Add new survey based on FIP keywords. + + This method adds a survey as add_survey_RPORV() and + add_survey_PORMOD; but the mass content in each cell is + calculated based on the FIPxxx keyword along with the mass + density at standard conditions of the respective phases. + + The mass density at standard conditions must be specified with + the new_std_density() (and possibly also add_std_density()) + method before calling the add_survey_FIP() method. + """ + self._add_survey_FIP(survey_name, restart_view) + + def add_survey_RFIP(self, survey_name, restart_view): + """ + Add new survey based on RFIP keywords. + + This method adds a survey as add_survey_RPORV() and + add_survey_PORMOD; but the mass content in each cell is + calculated based on the RFIPxxx keyword along with the + per-cell mass density of the respective phases. + """ + self._add_survey_RFIP(survey_name, restart_view) + + def add_survey(self, name, restart_view, method): + method = self.dispatch[ method ] + return method(name, restart_view) + + def eval(self, base_survey, monitor_survey, pos, region=None, + phase_mask=EclPhaseEnum.ECL_OIL_PHASE + EclPhaseEnum.ECL_GAS_PHASE + EclPhaseEnum.ECL_WATER_PHASE): + """ + Calculates the gravity change between two surveys. + + This is the method everything is leading up to; will calculate + the change in gravitational strength, in units of micro Gal, + between the two surveys named @base_survey and + @monitor_survey. + + The monitor survey can be 'None' - the resulting answer has + nothing whatsovever to do with gravitation, but can be + interesting to determine the numerical size of the quantities + which are subtracted in a 4D study. + + The @pos argument should be a tuple of three elements with the + (utm_x, utm_y, depth) position where we want to evaluate the + change in gravitational strength. + + If supplied the optional argument @region should be an + EclRegion() instance; this region will be used to limit the + part of the reserviour included in the gravity calculations. + + The optional argument @phase_mask is an integer flag to + indicate which phases you are interested in. It should be a + sum of the relevant integer constants 'ECL_OIL_PHASE', + 'ECL_GAS_PHASE' and 'ECL_WATER_PHASE'. + """ + return self._eval(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], phase_mask) + + + def new_std_density(self, phase_enum, default_density): + """ + Adds a new phase with a corresponding density. + + @phase_enum is one of the integer constants ECL_OIL_PHASE, + ECL_GAS_PHASE or ECL_WATER_PHASE, all available in the + ecl_util and also ecl modules. + + @default_density is the density, at standard conditions, for + this particular phase. By default @default_density will be + used for all the cells in the model; by using the + add_std_density() method you can specify different densities + for different PVT regions. + + The new_std_density() and add_std_density() methods must be + used before you use the add_survey_FIP() method to add a + survey based on the FIP keyword. + """ + self._new_std_density(phase_enum, default_density) + + def add_std_density(self, phase_enum, pvtnum, density): + """ + Add standard conditions density for PVT region @pvtnum. + + The new_std_density() method will add a standard conditions + density which applies to all cells in the model. Using the + add_std_density() method it is possible to add standard + conditions densities on a per PVT region basis. You can add + densities for as many PVT regions as you like, and then fall + back to the default density for the others. + + The new_std_density() method must be called before calling the + add_std_density() method. + + The new_std_density() and add_std_density() methods must be + used before you use the add_survey_FIP() method to add a + survey based on the FIP keyword. + """ + self._add_std_density(phase_enum, pvtnum, density) + + + def free(self): + self._free() + +monkey_the_camel(EclGrav, 'addSurvey', EclGrav.add_survey) diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py new file mode 100644 index 0000000000..c00a1e714b --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py @@ -0,0 +1,84 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclPrototype + +__arglist = 'double, double, double, ' +__arglist += 'ecl_grid, ecl_file, ' +__arglist += 'ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw' +_phase_deltag = EclPrototype("double ecl_grav_phase_deltag(%s)" % __arglist) + +def phase_deltag(xyz, grid, init, sat1, rho1, porv1, sat2, rho2, porv2): + return _phase_deltag(xyz[0], xyz[1], xyz[2], + grid.c_ptr, init.c_ptr, + sat1.c_ptr, rho1.c_ptr, porv1.c_ptr, + sat2.c_ptr, rho2.c_ptr, porv2.c_ptr) + + +def deltag(xyz, grid, init_file, restart_file1, restart_file2): + """ + 1. All restart files should have water, i.e. the SWAT keyword. + 2. All phases present in the restart file should also be present as densities, + in addition the model must contain one additional phase - which should have a density. + 3. The restart files can never contain oil saturation. + """ + + swat1 = restart_file1.iget_named_kw("SWAT", 0) + swat2 = restart_file2.iget_named_kw("SWAT", 0) + + phase_list = [(swat1, swat2)] + + if restart_file1.has_kw("SGAS"): + # This is a three phase Water / Gas / Oil system + sgas1 = restart_file1.iget_named_kw("SGAS", 0) + sgas2 = restart_file2.iget_named_kw("SGAS", 0) + + soil1 = 1 - (sgas1 + swat1) + soil2 = 1 - (sgas2 + swat2) + soil1.name = "SOIL" + soil2.name = "SOIL" + phase_list += [(sgas1, sgas2), + (soil1, soil2)] + else: + # This is a two phase Water / xxx System. Will look for + # OIL_DEN and GAS_DEN keywords to determine whether it is a + # Water / Oil or Water / Gas system. + + if restart_file1.has_kw("OIL_DEN"): + # Oil / Water system + soil1 = 1 - swat1 + soil2 = 1 - swat2 + soil1.name = "SOIL" + soil2.name = "SOIL" + phase_list += [(soil1, soil2)] + else: + # Gas / Water system + sgas1 = 1 - swat1 + sgas2 = 1 - swat2 + sgas1.name = "SGAS" + sgas2.name = "SGAS" + phase_list += [(sgas1, sgas2)] + + porv1 = restart_file1.iget_named_kw("RPORV", 0) + porv2 = restart_file2.iget_named_kw("RPORV", 0) + + deltag = 0 + for (sat1, sat2) in phase_list: + rho_name = "%s_DEN" % sat1.name[1:] + rho1 = restart_file1.iget_named_kw(rho_name, 0) + rho2 = restart_file2.iget_named_kw(rho_name, 0) + deltag += phase_deltag(xyz, grid, init_file, sat1, rho1, porv1, sat2, rho2, porv2) + return deltag diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py new file mode 100644 index 0000000000..890e4e5ccc --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py @@ -0,0 +1,144 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_subsidence.py' is part of ERT - Ensemble based +# Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Calculate dynamic change in gravitational strength. + +The ecl_subsidence module contains functionality to load time-lapse ECLIPSE +results and calculate the change in seafloor subsidence between the +different surveys. The implementation is a thin wrapper around the +ecl_subsidence.c implementation in the libecl library. +""" +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +import ecl.grid + +class EclSubsidence(BaseCClass): + """ + Holding ECLIPSE results for calculating subsidence changes. + + The EclSubsidence class is a collection class holding the results from + ECLIPSE forward modelling of subsidence surveys. Observe that the + class is focused on the ECLIPSE side of things, and does not have + any notion of observed values or measurement locations; that + should be handled by the scope using the EclSubsidence class. + + Typical use of the EclSubsidence class involves the following steps: + + 1. Create the EclSubsidence instance. + 2. Add surveys with the add_survey_XXXX() methods. + 3. Evalute the subsidence response with the eval() method. + """ + TYPE_NAME = "ecl_subsidence" + _alloc = EclPrototype("void* ecl_subsidence_alloc( ecl_grid , ecl_file )" , bind = False) + _free = EclPrototype("void ecl_subsidence_free( ecl_subsidence )") + _add_survey_PRESSURE = EclPrototype("void* ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file_view )") + _eval = EclPrototype("double ecl_subsidence_eval( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double)") + _eval_geertsma = EclPrototype("double ecl_subsidence_eval_geertsma( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double, double)") + _has_survey = EclPrototype("bool ecl_subsidence_has_survey( ecl_subsidence , char*)") + + def __init__( self, grid, init_file ): + """ + Creates a new EclSubsidence instance. + + The input arguments @grid and @init_file should be instances + of EclGrid and EclFile respectively. + """ + self.init_file = init_file # Inhibit premature garbage collection of init_file + c_ptr = self._alloc( grid , init_file ) + super( EclSubsidence , self ).__init__( c_ptr ) + + + def __contains__(self , survey_name): + return self._has_survey( survey_name ) + + + + def add_survey_PRESSURE( self, survey_name, restart_file ): + """ + Add new survey based on PRESSURE keyword. + + Add a new survey; in this context a survey is the state of + reservoir, i.e. an ECLIPSE restart file. The @survey_name + input argument will be used when refering to this survey at a + later stage. The @restart_file input argument should be an + EclFile instance with data from one report step. A typical way + to load the @restart_file argument is: + + import datetime + import ecl.ecl.ecl as ecl + ... + ... + date = datetime.datetime( year , month , day ) + restart_file1 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , dtime = date) + restart_file2 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 ) + + The pore volume is calculated from the initial pore volume and + the PRESSURE keyword from the restart file. + """ + self._add_survey_PRESSURE( survey_name, restart_file) + + + def eval_geertsma(self, base_survey, monitor_survey, pos, youngs_modulus, poisson_ratio, seabed, region=None): + if not base_survey in self: + raise KeyError("No such survey: %s" % base_survey) + + if monitor_survey is not None: + if not monitor_survey in self: + raise KeyError("No such survey: %s" % monitor_survey) + + return self._eval_geertsma(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], youngs_modulus, poisson_ratio, seabed) + + def eval(self, base_survey, monitor_survey, pos, compressibility, poisson_ratio, region=None): + """ + Calculates the subsidence change between two surveys. + + This is the method everything is leading up to; will calculate + the change in subsidence, in centimeters, + between the two surveys named @base_survey and + @monitor_survey. + + The monitor survey can be 'None' - the resulting answer has + nothing whatsovever to do with subsidence, but can be + interesting to determine the numerical size of the quantities + which are subtracted in a 4D study. + + The @pos argument should be a tuple of three elements with the + (utm_x , utm_y , depth) position where we want to evaluate the + change in subsidence. + + If supplied the optional argument @region should be an + EclRegion() instance; this region will be used to limit the + part of the reserviour included in the subsidence calculations. + + The argument @compressibility is the total reservoir compressibility. + """ + if not base_survey in self: + raise KeyError("No such survey: %s" % base_survey) + + if not monitor_survey in self: + raise KeyError("No such survey: %s" % monitor_survey) + + return self._eval(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], compressibility,poisson_ratio) + + + + def free(self): + self._free( ) + + +monkey_the_camel(EclSubsidence, 'evalGeertsma', EclSubsidence.eval_geertsma) diff --git a/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt b/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt new file mode 100644 index 0000000000..46ed7c3347 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt @@ -0,0 +1,11 @@ +set(PYTHON_SOURCES + __init__.py + cell.py + ecl_grid.py + ecl_region.py + ecl_grid_generator.py +) + +add_python_package("python.ecl.grid" ${PYTHON_INSTALL_PREFIX}/ecl/grid "${PYTHON_SOURCES}" True) + +add_subdirectory(faults) diff --git a/ThirdParty/Ert/python/ecl/grid/__init__.py b/ThirdParty/Ert/python/ecl/grid/__init__.py new file mode 100644 index 0000000000..69d110e0bf --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/__init__.py @@ -0,0 +1,35 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" + ecl_grid/EclGrid: This will load an ECLIPSE GRID or EGRID file, and + can then subsequently be used for queries about the grid. + + ecl_region/EclRegion: Convenience class to support selecting cells + in a grid based on a wide range of criteria. Can be used as a + mask in operations on EclKW instances. + + ecl_grid_generator/EclGridGenerator: This can be used to generate various + grids. +""" + +import ecl.util.util +import ecl.util.geometry + +from .cell import Cell +from .ecl_grid import EclGrid +from .ecl_region import EclRegion +from .ecl_grid_generator import EclGridGenerator diff --git a/ThirdParty/Ert/python/ecl/grid/cell.py b/ThirdParty/Ert/python/ecl/grid/cell.py new file mode 100644 index 0000000000..5824d6fc47 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/cell.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +class Cell(object): + + def __init__(self, grid, global_index): + self._grid = grid + self._idx = global_index + self._ijk = grid.get_ijk(global_index=self._idx) + self._aidx = grid.get_active_index(global_index=self._idx) + + @property + def volume(self): + return self._grid.cell_volume(global_index=self._idx) + + @property + def global_index(self): + return self._idx + + @property + def active_index(self): + return self._aidx + + @property + def ijk(self): + return self._ijk + @property + def i(self): + return self._ijk[0] + @property + def j(self): + return self._ijk[1] + @property + def k(self): + return self._ijk[2] + + @property + def active(self): + return self._aidx >= 0 + + def eval(self, kw): + return self._grid.grid_value(kw, self.i, self.j, self.k) + + @property + def fracture(self): + return self._grid.active_fracture_index(global_index=self._idx) + + @property + def dz(self): + return self._grid.cell_dz(global_index=self._idx) + + @property + def dimension(self): + return self._grid.get_cell_dims(global_index=self._idx) + + @property + def valid_geometry(self): + return self._grid.valid_cell_geometry(global_index=self._idx) + + @property + def valid(self): + return not self._grid.cell_invalid(global_index=self._idx) + + def __contains__(self, coord): + """ + Will check if this cell contains point given by world + coordinates (x,y,z)=coord. + """ + if len(coord) != 3: + raise ValueError('Cell contains takes a triple (x,y,z), was given %s.' % coord) + x,y,z = coord + return self._grid._cell_contains(self._idx, x,y,z) + + def __eq__(self, other): + if isinstance(other, Cell): + idx_eq = self.global_index == other.global_index + return idx_eq and self._grid == other._grid + return NotImplemented + + def __neq__(self, other): + if isinstance(other, Cell): + return not self == other + return NotImplemented + + def hash(self): + return hash((self._idx, self._aidx, self.ijk)) + + @property + def coordinate(self): + return self._grid.get_xyz(global_index=self._idx) + + @property + def corners(self): + """ + Return xyz for each of the eight vertices, indexed by: + + lower layer: upper layer + + 2---3 6---7 + | | | | + 0---1 4---5 + """ + cs = lambda c : self._grid.get_cell_corner(c, global_index=self._idx) + return [cs(i) for i in range(8)] + + def __repr__(self): + act = 'active' if self.active else 'inactive' + pos = '(%.3f, %.3f, %.3f)' % self.coordinate + cnt = '%d, %d, %d, %s, %s, grid=%s' % (self.i, self.j, self.k, + act, pos, + self._grid.get_name()) + + return 'Cell(%s)' % cnt diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_grid.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py new file mode 100644 index 0000000000..1a923140ac --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py @@ -0,0 +1,1299 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_grid.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" +Module to load and query ECLIPSE GRID/EGRID files. + +The ecl_grid module contains functionality to load and query an +ECLIPSE grid file; it is currently not possible to manipulate or let +alone create a grid with ecl_grid module. The functionality is +implemented in the EclGrid class. The ecl_grid module is a thin +wrapper around the ecl_grid.c implementation from the libecl library. +""" +import ctypes + +import warnings +import numpy +import sys +import os.path +import math +import itertools +from cwrap import CFILE, BaseCClass, load, open as copen + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclDataType, EclUnitTypeEnum +from ecl.eclfile import EclKW, FortIO +from ecl.grid import Cell + + +class EclGrid(BaseCClass): + """ + Class for loading and internalizing ECLIPSE GRID/EGRID files. + """ + + TYPE_NAME = "ecl_grid" + _fread_alloc = EclPrototype("void* ecl_grid_load_case__(char*, bool)", bind = False) + _grdecl_create = EclPrototype("ecl_grid_obj ecl_grid_alloc_GRDECL_kw(int, int, int, ecl_kw, ecl_kw, ecl_kw, ecl_kw)", bind = False) + _alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind = False) + _exists = EclPrototype("bool ecl_grid_exists(char*)", bind = False) + + _get_numbered_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr_from_lgr_nr(ecl_grid, int)") + _get_named_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr(ecl_grid, char*)") + _get_cell_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_cell_lgr1(ecl_grid, int)") + _num_coarse_groups = EclPrototype("int ecl_grid_get_num_coarse_groups(ecl_grid)") + _in_coarse_group1 = EclPrototype("bool ecl_grid_cell_in_coarse_group1(ecl_grid, int)") + _free = EclPrototype("void ecl_grid_free(ecl_grid)") + _get_nx = EclPrototype("int ecl_grid_get_nx(ecl_grid)") + _get_ny = EclPrototype("int ecl_grid_get_ny(ecl_grid)") + _get_nz = EclPrototype("int ecl_grid_get_nz(ecl_grid)") + _get_global_size = EclPrototype("int ecl_grid_get_global_size(ecl_grid)") + _get_active = EclPrototype("int ecl_grid_get_active_size(ecl_grid)") + _get_active_fracture = EclPrototype("int ecl_grid_get_nactive_fracture(ecl_grid)") + _get_name = EclPrototype("char* ecl_grid_get_name(ecl_grid)") + _ijk_valid = EclPrototype("bool ecl_grid_ijk_valid(ecl_grid, int, int, int)") + _get_active_index3 = EclPrototype("int ecl_grid_get_active_index3(ecl_grid, int, int, int)") + _get_global_index3 = EclPrototype("int ecl_grid_get_global_index3(ecl_grid, int, int, int)") + _get_active_index1 = EclPrototype("int ecl_grid_get_active_index1(ecl_grid, int)") + _get_active_fracture_index1 = EclPrototype("int ecl_grid_get_active_fracture_index1(ecl_grid, int)") + _get_global_index1A = EclPrototype("int ecl_grid_get_global_index1A(ecl_grid, int)") + _get_global_index1F = EclPrototype("int ecl_grid_get_global_index1F(ecl_grid, int)") + _get_ijk1 = EclPrototype("void ecl_grid_get_ijk1(ecl_grid, int, int*, int*, int*)") + _get_ijk1A = EclPrototype("void ecl_grid_get_ijk1A(ecl_grid, int, int*, int*, int*)") + _get_xyz3 = EclPrototype("void ecl_grid_get_xyz3(ecl_grid, int, int, int, double*, double*, double*)") + _get_xyz1 = EclPrototype("void ecl_grid_get_xyz1(ecl_grid, int, double*, double*, double*)") + _get_cell_corner_xyz1 = EclPrototype("void ecl_grid_get_cell_corner_xyz1(ecl_grid, int, int, double*, double*, double*)") + _get_corner_xyz = EclPrototype("void ecl_grid_get_corner_xyz(ecl_grid, int, int, int, double*, double*, double*)") + _get_xyz1A = EclPrototype("void ecl_grid_get_xyz1A(ecl_grid, int, double*, double*, double*)") + _get_ij_xy = EclPrototype("bool ecl_grid_get_ij_from_xy(ecl_grid, double, double, int, int*, int*)") + _get_ijk_xyz = EclPrototype("int ecl_grid_get_global_index_from_xyz(ecl_grid, double, double, double, int)") + _cell_contains = EclPrototype("bool ecl_grid_cell_contains_xyz1(ecl_grid, int, double, double, double)") + _cell_regular = EclPrototype("bool ecl_grid_cell_regular1(ecl_grid, int)") + _num_lgr = EclPrototype("int ecl_grid_get_num_lgr(ecl_grid)") + _has_numbered_lgr = EclPrototype("bool ecl_grid_has_lgr_nr(ecl_grid, int)") + _has_named_lgr = EclPrototype("bool ecl_grid_has_lgr(ecl_grid, char*)") + _grid_value = EclPrototype("double ecl_grid_get_property(ecl_grid, ecl_kw, int, int, int)") + _get_cell_volume = EclPrototype("double ecl_grid_get_cell_volume1(ecl_grid, int)") + _get_cell_thickness = EclPrototype("double ecl_grid_get_cell_thickness1(ecl_grid, int)") + _get_cell_dx = EclPrototype("double ecl_grid_get_cell_dx1(ecl_grid, int)") + _get_cell_dy = EclPrototype("double ecl_grid_get_cell_dy1(ecl_grid, int)") + _get_depth = EclPrototype("double ecl_grid_get_cdepth1(ecl_grid, int)") + _fwrite_grdecl = EclPrototype("void ecl_grid_grdecl_fprintf_kw(ecl_grid, ecl_kw, char*, FILE, double)") + _load_column = EclPrototype("void ecl_grid_get_column_property(ecl_grid, ecl_kw, int, int, double_vector)") + _get_top = EclPrototype("double ecl_grid_get_top2(ecl_grid, int, int)") + _get_top1A = EclPrototype("double ecl_grid_get_top1A(ecl_grid, int)") + _get_bottom = EclPrototype("double ecl_grid_get_bottom2(ecl_grid, int, int)") + _locate_depth = EclPrototype("int ecl_grid_locate_depth(ecl_grid, double, int, int)") + _invalid_cell = EclPrototype("bool ecl_grid_cell_invalid1(ecl_grid, int)") + _valid_cell = EclPrototype("bool ecl_grid_cell_valid1(ecl_grid, int)") + _get_distance = EclPrototype("void ecl_grid_get_distance(ecl_grid, int, int, double*, double*, double*)") + _fprintf_grdecl2 = EclPrototype("void ecl_grid_fprintf_grdecl2(ecl_grid, FILE, ecl_unit_enum) ") + _fwrite_GRID2 = EclPrototype("void ecl_grid_fwrite_GRID2(ecl_grid, char*, ecl_unit_enum)") + _fwrite_EGRID2 = EclPrototype("void ecl_grid_fwrite_EGRID2(ecl_grid, char*, ecl_unit_enum)") + _equal = EclPrototype("bool ecl_grid_compare(ecl_grid, ecl_grid, bool, bool)") + _dual_grid = EclPrototype("bool ecl_grid_dual_grid(ecl_grid)") + _init_actnum = EclPrototype("void ecl_grid_init_actnum_data(ecl_grid, int*)") + _compressed_kw_copy = EclPrototype("void ecl_grid_compressed_kw_copy(ecl_grid, ecl_kw, ecl_kw)") + _global_kw_copy = EclPrototype("void ecl_grid_global_kw_copy(ecl_grid, ecl_kw, ecl_kw)") + _create_volume_keyword = EclPrototype("ecl_kw_obj ecl_grid_alloc_volume_kw(ecl_grid, bool)") + _use_mapaxes = EclPrototype("bool ecl_grid_use_mapaxes(ecl_grid)") + _export_coord = EclPrototype("ecl_kw_obj ecl_grid_alloc_coord_kw(ecl_grid)") + _export_zcorn = EclPrototype("ecl_kw_obj ecl_grid_alloc_zcorn_kw(ecl_grid)") + _export_actnum = EclPrototype("ecl_kw_obj ecl_grid_alloc_actnum_kw(ecl_grid)") + _export_mapaxes = EclPrototype("ecl_kw_obj ecl_grid_alloc_mapaxes_kw(ecl_grid)") + + + + @classmethod + def load_from_grdecl(cls, filename): + """Will create a new EclGrid instance from grdecl file. + + This function will scan the input file @filename and look for + the keywords required to build a grid. The following keywords + are required: + + SPECGRID ZCORN COORD + + In addition the function will look for and use the ACTNUM and + MAPAXES keywords if they are found; if ACTNUM is not found all + cells are assumed to be active. + + Slightly more exotic grid concepts like dual porosity, NNC + mapping, LGR and coarsened cells will be completely ignored; + if you need such concepts you must have an EGRID file and use + the default EclGrid() constructor - that is also considerably + faster. + """ + + if os.path.isfile(filename): + with copen(filename) as f: + specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) + zcorn = EclKW.read_grdecl(f, "ZCORN") + coord = EclKW.read_grdecl(f, "COORD") + try: + actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclDataType.ECL_INT) + except ValueError: + actnum = None + + try: + mapaxes = EclKW.read_grdecl(f, "MAPAXES") + except ValueError: + mapaxes = None + + return EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes) + else: + raise IOError("No such file:%s" % filename) + + @classmethod + def load_from_file(cls, filename): + """ + Will inspect the @filename argument and create a new EclGrid instance. + """ + if FortIO.isFortranFile(filename): + return EclGrid(filename) + else: + return EclGrid.loadFromGrdecl(filename) + + + @classmethod + def create(cls, specgrid, zcorn, coord, actnum, mapaxes=None): + + """ + Create a new grid instance from existing keywords. + + This is a class method which can be used to create an EclGrid + instance based on the EclKW instances @specgrid, @zcorn, + @coord and @actnum. An ECLIPSE EGRID file contains the + SPECGRID, ZCORN, COORD and ACTNUM keywords, so a somewhat + involved way to create a EclGrid instance could be: + + file = ecl.EclFile("ECLIPSE.EGRID") + specgrid_kw = file.iget_named_kw("SPECGRID", 0) + zcorn_kw = file.iget_named_kw("ZCORN", 0) + coord_kw = file.iget_named_kw("COORD", 0) + actnum_kw = file.iget_named_kw("ACTNUM", 0) + + grid = EclGrid.create(specgrid_kw, zcorn_kw, coord_kw, actnum_kw) + + If you are so inclined ... + """ + return cls._grdecl_create(specgrid[0], specgrid[1], specgrid[2], zcorn, coord, actnum, mapaxes) + + @classmethod + def create_rectangular(cls, dims, dV, actnum=None): + """ + Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz) + + With the default value @actnum == None all cells will be active, + """ + + warnings.warn("EclGrid.createRectangular is deprecated. " + + "Please used the similar method in EclGridGenerator!", + DeprecationWarning) + + if actnum is None: + ecl_grid = cls._alloc_rectangular(dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], None) + else: + if not isinstance(actnum, IntVector): + tmp = IntVector(initial_size=len(actnum)) + for (index, value) in enumerate(actnum): + tmp[index] = value + actnum = tmp + + if not len(actnum) == dims[0] * dims[1] * dims[2]: + raise ValueError("ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" % (len(actnum), dims[0] * dims[1] * dims[2])) + ecl_grid = cls._alloc_rectangular(dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], actnum.getDataPtr()) + + # If we have not succeeded in creatin the grid we *assume* the + # error is due to a failed malloc. + if ecl_grid is None: + raise MemoryError("Failed to allocated regualar grid") + + return ecl_grid + + def __init__(self, filename, apply_mapaxes=True): + """ + Will create a grid structure from an EGRID or GRID file. + """ + c_ptr = self._fread_alloc(filename, apply_mapaxes) + if c_ptr: + super(EclGrid, self).__init__(c_ptr) + else: + raise IOError("Loading grid from:%s failed" % filename) + + + def free(self): + self._free() + + def _nicename(self): + """name is often full path to grid, if so, output basename, else name""" + name = self.getName() + if os.path.isfile(name): + name = os.path.basename(name) + return name + + def __repr__(self): + """Returns, e.g.: + EclGrid("NORNE_ATW2013.EGRID", 46x112x22, global_size=113344, active_size=44431) at 0x28c4a70 + """ + name = self._nicename() + if name: + name = '"%s", ' % name + g_size = self.getGlobalSize() + a_size = self.getNumActive() + xyz_s = '%dx%dx%d' % (self.getNX(),self.getNY(),self.getNZ()) + return self._create_repr('%s%s, global_size=%d, active_size=%d' % (name, xyz_s, g_size, a_size)) + + def __len__(self): + """ + len(grid) wil return the total number of cells. + """ + return self._get_global_size() + + def equal(self, other, include_lgr=True, include_nnc=False, verbose=False): + """ + Compare the current grid with the other grid. + """ + if not isinstance(other, EclGrid): + raise TypeError("The other argument must be an EclGrid instance") + return self._equal(other, include_lgr, include_nnc, verbose) + + + def dual_grid(self): + """Is this grid dual porosity model?""" + return self._dual_grid() + + def get_dims(self): + """A tuple of four elements: (nx, ny, nz, nactive).""" + return (self.getNX(), + self.getNY(), + self.getNZ(), + self.getNumActive()) + + + @property + def nx(self): + return self._get_nx() + + def get_nx(self): + """ The number of elements in the x direction""" + return self._get_nx() + + @property + def ny(self): + return self._get_ny() + + def get_ny(self): + """ The number of elements in the y direction""" + return self._get_ny() + + @property + def nz(self): + return self._get_nz() + + def get_nz(self): + """ The number of elements in the z direction""" + return self._get_nz() + + def get_global_size(self): + """Returns the total number of cells in this grid""" + return self._get_global_size() + + def get_num_active(self): + """The number of active cells in the grid.""" + return self._get_active() + + + def get_num_active_fracture(self): + """The number of active cells in the grid.""" + return self._get_active_fracture() + + + def get_bounding_box_2d(self, layer=0, lower_left=None, upper_right=None): + if 0 <= layer <= self.getNZ(): + x = ctypes.c_double() + y = ctypes.c_double() + z = ctypes.c_double() + + if lower_left is None: + i1 = 0 + j1 = 0 + else: + i1,j1 = lower_left + if not 0 < i1 < self.getNX(): + raise ValueError("lower_left i coordinate invalid") + + if not 0 < j1 < self.getNY(): + raise ValueError("lower_left j coordinate invalid") + + + if upper_right is None: + i2 = self.getNX() + j2 = self.getNY() + else: + i2,j2 = upper_right + + if not 1 < i2 <= self.getNX(): + raise ValueError("upper_right i coordinate invalid") + + if not 1 < j2 <= self.getNY(): + raise ValueError("upper_right j coordinate invalid") + + if not i1 < i2: + raise ValueError("Must have lower_left < upper_right") + + if not j1 < j2: + raise ValueError("Must have lower_left < upper_right") + + + + self._get_corner_xyz(i1, j1, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + p0 = (x.value, y.value) + + self._get_corner_xyz(i2, j1, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + p1 = (x.value, y.value ) + + self._get_corner_xyz( i2, j2, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + p2 = (x.value, y.value ) + + self._get_corner_xyz(i1, j2, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + p3 = (x.value, y.value ) + + return (p0,p1,p2,p3) + else: + raise ValueError("Invalid layer value:%d Valid range: [0,%d]" % (layer, self.getNZ())) + + + def get_name(self): + """ + Name of the current grid, returns a string. + + For the main grid this is the filename given to the + constructor when loading the grid; for an LGR this is the name + of the LGR. If the grid instance has been created with the + create() classmethod this can be None. + """ + n = self._get_name() + return str(n) if n else '' + + def cell(self, global_index=None, active_index=None, i=None, j=None, k=None): + if global_index is not None: + return Cell(self, global_index) + if active_index is not None: + return Cell(self, self.global_index(active_index=active_index)) + if i is not None: + return Cell(self, self.global_index(ijk=(i,j,k))) + + def __getitem__(self, global_index): + if isinstance(global_index, tuple): + i,j,k = global_index + return self.cell(i=i, j=j, k=k) + return self.cell(global_index=global_index) + + def __iter__(self): + for i in range(len(self)): + yield self[i] + + def cells(self, active=False): + """Iterator over all the (active) cells""" + if not active: + for c in self: + yield c + else: + for i in range(self.get_num_active()): + yield self.cell(active_index=i) + + def global_index(self, active_index=None, ijk=None): + """ + Will convert either active_index or (i,j,k) to global index. + """ + return self.__global_index(active_index=active_index, ijk=ijk) + + def __global_index(self, active_index=None, global_index=None, ijk=None): + """ + Will convert @active_index or @ijk to global_index. + + This method will convert @active_index or @ijk to a global + index. Exactly one of the arguments @active_index, + @global_index or @ijk must be supplied. + + The method is used extensively internally in the EclGrid + class; most methods which take coordinate input pass through + this method to normalize the coordinate representation. + """ + + set_count = 0 + if not active_index is None: + set_count += 1 + + if not global_index is None: + set_count += 1 + + if ijk: + set_count += 1 + + if not set_count == 1: + raise ValueError("Exactly one of the kewyord arguments active_index, global_index or ijk must be set") + + if not active_index is None: + global_index = self._get_global_index1A( active_index) + elif ijk: + nx = self.getNX() + ny = self.getNY() + nz = self.getNZ() + + i,j,k = ijk + + if not 0 <= i < nx: + raise IndexError("Invalid value i:%d Range: [%d,%d)" % (i, 0, nx)) + + if not 0 <= j < ny: + raise IndexError("Invalid value j:%d Range: [%d,%d)" % (j, 0, ny)) + + if not 0 <= k < nz: + raise IndexError("Invalid value k:%d Range: [%d,%d)" % (k, 0, nz)) + + global_index = self._get_global_index3(i,j,k) + else: + if not 0 <= global_index < self.getGlobalSize(): + raise IndexError("Invalid value global_index:%d Range: [%d,%d)" % (global_index, 0, self.getGlobalSize())) + return global_index + + + def get_active_index(self, ijk=None, global_index=None): + """ + Lookup active index based on ijk or global index. + + Will determine the active_index of a cell, based on either + @ijk = (i,j,k) or @global_index. If the cell specified by the + input arguments is not active the function will return -1. + """ + gi = self.__global_index(global_index=global_index, ijk=ijk) + return self._get_active_index1(gi) + + + def get_active_fracture_index(self, ijk=None, global_index=None): + """ + For dual porosity - get the active fracture index. + """ + gi = self.__global_index(global_index=global_index, ijk=ijk) + return self._get_active_fracture_index1(gi) + + + def get_global_index1F(self, active_fracture_index): + """ + Will return the global index corresponding to active fracture index. + """ + return self._get_global_index1F(active_fracture_index) + + + def cell_invalid(self, ijk=None, global_index=None, active_index=None): + """ + Tries to check if a cell is invalid. + + Cells which are used to represent numerical aquifers are + typically located in UTM position (0,0); these cells have + completely whacked up shape and size, and should **NOT** be + used in calculations involving real world coordinates. To + protect against this a heuristic is used identify such cells + and mark them as invalid. There might be other sources than + numerical aquifers to this problem. + """ + gi = self.__global_index(global_index=global_index, ijk=ijk, active_index=active_index) + return self._invalid_cell(gi) + + + def valid_cell_geometry(self, ijk=None, global_index=None, active_index=None): + """Checks if the cell has valid geometry. + + There are at least two reasons why a cell might have invalid + gemetry: + + 1. In the case of GRID files it is not necessary to supply + the geometry for all the cells; in that case this + function will return false for cells which do not have + valid coordinates. + + 2. Cells which are used to represent numerical aquifers are + typically located in UTM position (0,0); these cells have + completely whacked up shape and size; these cells are + identified by a heuristic - which might fail + + If the validCellGeometry() returns false for a particular + cell functions which calculate cell volumes, real world + coordinates and so on - should not be used. + """ + gi = self.__global_index(global_index=global_index, ijk=ijk, active_index=active_index) + return self._valid_cell(gi) + + + + def active(self, ijk=None, global_index=None): + """ + Is the cell active? + + See documentation og get_xyz() for explanation of parameters + @ijk and @global_index. + """ + gi = self.__global_index(global_index=global_index, ijk=ijk) + active_index = self._get_active_index1(gi) + if active_index >= 0: + return True + else: + return False + + + def get_global_index(self, ijk=None, active_index=None): + """ + Lookup global index based on ijk or active index. + """ + gi = self.__global_index(active_index=active_index, ijk=ijk) + return gi + + + def get_ijk(self, active_index=None, global_index=None): + """ + Lookup (i,j,k) for a cell, based on either active index or global index. + + The return value is a tuple with three elements (i,j,k). + """ + i = ctypes.c_int() + j = ctypes.c_int() + k = ctypes.c_int() + + gi = self.__global_index(active_index=active_index, global_index=global_index) + self._get_ijk1(gi, ctypes.byref(i), ctypes.byref(j), ctypes.byref(k)) + + return (i.value, j.value, k.value) + + + def get_xyz(self, active_index=None, global_index=None, ijk=None): + """ + Find true position of cell center. + + Will return world position of the center of a cell in the + grid. The return value is a tuple of three elements: + (utm_x, utm_y, depth). + + The cells of a grid can be specified in three different ways: + + (i,j,k) : As a tuple of i,j,k values. + + global_index : A number in the range [0,nx*ny*nz). The + global index is related to (i,j,k) as: + + global_index = i + j*nx + k*nx*ny + + active_index : A number in the range [0,nactive). + + For many of the EclGrid methods a cell can be specified using + any of these three methods. Observe that one and only method is + allowed: + + OK: + pos1 = grid.get_xyz(active_index=100) + pos2 = grid.get_xyz(ijk=(10,20,7)) + + Crash and burn: + pos3 = grid.get_xyz(ijk=(10,20,7), global_index=10) + pos4 = grid.get_xyz() + + All the indices in the EclGrid() class are zero offset, this + is in contrast to ECLIPSE which has an offset 1 interface. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + + x = ctypes.c_double() + y = ctypes.c_double() + z = ctypes.c_double() + self._get_xyz1(gi, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + return (x.value, y.value, z.value) + + + def get_node_pos(self, i, j, k): + """Will return the (x,y,z) for the node given by (i,j,k). + + Observe that this method does not consider cells, but the + nodes in the grid. This means that the valid input range for + i,j and k are are upper end inclusive. To get the four + bounding points of the lower layer of the grid: + + p0 = grid.getNodePos(0, 0, 0) + p1 = grid.getNodePos(grid.getNX(), 0, 0) + p2 = grid.getNodePos(0, grid.getNY(), 0) + p3 = grid.getNodePos(grid.getNX(), grid.getNY(), 0) + + """ + if not 0 <= i <= self.getNX(): + raise IndexError("Invalid I value:%d - valid range: [0,%d]" % (i, self.getNX())) + + if not 0 <= j <= self.getNY(): + raise IndexError("Invalid J value:%d - valid range: [0,%d]" % (j, self.getNY())) + + if not 0 <= k <= self.getNZ(): + raise IndexError("Invalid K value:%d - valid range: [0,%d]" % (k, self.getNZ())) + + x = ctypes.c_double() + y = ctypes.c_double() + z = ctypes.c_double() + self._get_corner_xyz(i,j,k, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + return (x.value, y.value, z.value) + + + def get_cell_corner(self, corner_nr, active_index=None, global_index=None, ijk=None): + """ + Will look up xyz of corner nr @corner_nr + + + lower layer: upper layer + + 2---3 6---7 + | | | | + 0---1 4---5 + + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + x = ctypes.c_double() + y = ctypes.c_double() + z = ctypes.c_double() + self._get_cell_corner_xyz1(gi, corner_nr, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + return (x.value, y.value, z.value) + + def get_node_xyz(self, i,j,k): + """ + This function returns the position of Vertex (i,j,k). + + The coordinates are in the inclusive interval [0,nx] x [0,ny] x [0,nz]. + """ + nx = self.getNX() + ny = self.getNY() + nz = self.getNZ() + + corner = 0 + + if i == nx: + i -= 1 + corner += 1 + + if j == ny: + j -= 1 + corner += 2 + + if k == nz: + k -= 1 + corner += 4 + + if self._ijk_valid(i, j, k): + return self.getCellCorner(corner, global_index=i + j*nx + k*nx*ny) + else: + raise IndexError("Invalid coordinates: (%d,%d,%d) " % (i,j,k)) + + + + def get_layer_xyz(self, xy_corner, layer): + nx = self.getNX() + + (j, i) = divmod(xy_corner, nx + 1) + k = layer + return self.getNodeXYZ(i,j,k) + + + + def distance(self, global_index1, global_index2): + dx = ctypes.c_double() + dy = ctypes.c_double() + dz = ctypes.c_double() + self._get_distance(global_index1, global_index2, ctypes.byref(dx), ctypes.byref(dy), ctypes.byref(dz)) + return (dx.value, dy.value, dz.value) + + + def depth(self, active_index=None, global_index=None, ijk=None): + """ + Depth of the center of a cell. + + Returns the depth of the center of the cell given by + @active_index, @global_index or @ijk. See method get_xyz() for + documentation of @active_index, @global_index and @ijk. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + return self._get_depth( gi) + + def top(self, i, j): + """ + Top of the reservoir; in the column (@i, @j). + Returns average depth of the four top corners. + """ + return self._get_top(i, j) + + def top_active(self, i, j): + """ + Top of the active part of the reservoir; in the column (@i, @j). + Raises ValueError if (i,j) column is inactive. + """ + for k in range(self.getNZ()): + a_idx = self.get_active_index(ijk=(i,j,k)) + if a_idx >= 0: + return self._get_top1A(a_idx) + raise ValueError('No active cell in column (%d,%d)' % (i,j)) + + def bottom(self, i, j): + """ + Bottom of the reservoir; in the column (@i, @j). + """ + return self._get_bottom( i, j) + + def locate_depth(self, depth, i, j): + """ + Will locate the k value of cell containing specified depth. + + Will scan through the grid column specified by the input + arguments @i and @j and search for a cell containing the depth + given by input argument @depth. The return value is the k + value of cell containing @depth. + + If @depth is above the top of the reservoir the function will + return -1, and if @depth is below the bottom of the reservoir + the function will return -nz. + """ + return self._locate_depth( depth, i, j) + + + def find_cell(self, x, y, z, start_ijk=None): + """ + Lookup cell containg true position (x,y,z). + + Will locate the cell in the grid which contains the true + position (@x,@y,@z), the return value is as a triplet + (i,j,k). The underlying C implementation is not veeery + efficient, and can potentially take quite long time. If you + provide a good intial guess with the parameter @start_ijk (a + tuple (i,j,k)) things can speed up quite substantially. + + If the location (@x,@y,@z) can not be found in the grid, the + method will return None. + """ + start_index = 0 + if start_ijk: + start_index = self.__global_index(ijk=start_ijk) + + global_index = self._get_ijk_xyz(x, y, z, start_index) + if global_index >= 0: + i = ctypes.c_int() + j = ctypes.c_int() + k = ctypes.c_int() + self._get_ijk1(global_index, + ctypes.byref(i), ctypes.byref(j), ctypes.byref(k)) + return (i.value, j.value, k.value) + return None + + def cell_contains(self, x, y, z, active_index=None, global_index=None, ijk=None): + """ + Will check if the cell contains point given by world + coordinates (x,y,z). + + See method get_xyz() for documentation of @active_index, + @global_index and @ijk. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + return self._cell_contains(gi, x,y,z) + + + def find_cell_xy(self, x, y, k): + """Will find the i,j of cell with utm coordinates x,y. + + The @k input is the layer you are interested in, the allowed + values for k are [0,nz]. If the coordinates (x,y) are found to + be outside the grid a ValueError exception is raised. + """ + if 0 <= k <= self.getNZ(): + i = ctypes.c_int() + j = ctypes.c_int() + ok = self._get_ij_xy(x,y,k, ctypes.byref(i), ctypes.byref(j)) + if ok: + return (i.value, j.value) + else: + raise ValueError("Could not find the point:(%g,%g) in layer:%d" % (x,y,k)) + else: + raise IndexError("Invalid layer value:%d" % k) + + def find_cell_corner_xy(self, x, y, k): + """Will find the corner nr of corner closest to utm coordinates x,y. + + The @k input is the layer you are interested in, the allowed + values for k are [0,nz]. If the coordinates (x,y) are found to + be outside the grid a ValueError exception is raised. + """ + i,j = self.findCellXY(x,y,k) + if k == self.getNZ(): + k -= 1 + corner_shift = 4 + else: + corner_shift = 0 + + nx = self.getNX() + x0,y0,z0 = self.getCellCorner(corner_shift, ijk=(i,j,k)) + d0 = math.sqrt((x0 - x)*(x0 - x) + (y0 - y)*(y0 - y)) + c0 = i + j*(nx + 1) + + x1,y1,z1 = self.getCellCorner(1 + corner_shift, ijk=(i,j,k)) + d1 = math.sqrt((x1 - x)*(x1 - x) + (y1 - y)*(y1 - y)) + c1 = i + 1 + j*(nx + 1) + + x2,y2,z2 = self.getCellCorner(2 + corner_shift, ijk=(i,j,k)) + d2 = math.sqrt((x2 - x)*(x2 - x) + (y2 - y)*(y2 - y)) + c2 = i + (j + 1)*(nx + 1) + + x3,y3,z3 = self.getCellCorner(3 + corner_shift, ijk=(i,j,k)) + d3 = math.sqrt((x3 - x)*(x3 - x) + (y3 - y)*(y3 - y)) + c3 = i + 1 + (j + 1)*(nx + 1) + + l = [(d0, c0), (d1,c1), (d2, c2), (d3,c3)] + l.sort(key=lambda k: k[0]) + return l[0][1] + + + + def cell_regular(self, active_index=None, global_index=None, ijk=None): + """ + The ECLIPSE grid models often contain various degenerate cells, + which are twisted, have overlapping corners or what not. This + function gives a moderate sanity check on a cell, essentially + what the function does is to check if the cell contains it's + own centerpoint - which is actually not as trivial as it + sounds. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + return self._cell_regular( gi) + + + def cell_volume(self, active_index=None, global_index=None, ijk=None): + """ + Calculate the volume of a cell. + + Will calculate the total volume of the cell. See method + get_xyz() for documentation of @active_index, @global_index + and @ijk. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + return self._get_cell_volume(gi) + + + def cell_dz(self, active_index=None, global_index=None, ijk=None): + """ + The thickness of a cell. + + Will calculate the (average) thickness of the cell. See method + get_xyz() for documentation of @active_index, @global_index + and @ijk. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + return self._get_cell_thickness( gi) + + + def get_cell_dims(self, active_index=None, global_index=None, ijk=None): + """Will return a tuple (dx,dy,dz) for cell dimension. + + The dx and dy values are best effor estimates of the cell size + along the i and j directions respectively. The three values + are guaranteed to satisfy: + + dx * dy * dz = dV + + See method get_xyz() for documentation of @active_index, + @global_index and @ijk. + + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + dx = self._get_cell_dx(gi) + dy = self._get_cell_dy(gi) + dz = self._get_cell_thickness( gi) + return (dx,dy,dz) + + + + def get_num_lgr(self): + + """ + How many LGRs are attached to this main grid? + + How many LGRs are attached to this main grid; the grid + instance doing the query must itself be a main grid. + """ + return self._num_lgr() + + + + def has_lgr(self, lgr_name): + """ + Query if the grid has an LGR with name @lgr_name. + """ + if self._has_named_lgr(lgr_name): + return True + else: + return False + + + def get_lgr(self, lgr_key): + """Get EclGrid instance with LGR content. + + Return an EclGrid instance based on the LGR @lgr, the input + argument can either be the name of an LGR or the grid number + of the LGR. The LGR grid instance is mostly like an ordinary + grid instance; the only difference is that it can not be used + for further queries about LGRs. + + If the grid does not contain an LGR with this name/nr + exception KeyError will be raised. + + """ + lgr = None + if isinstance(lgr_key, int): + if self._has_numbered_lgr(lgr_key): + lgr = self._get_numbered_lgr(lgr_key) + else: + if self._has_named_lgr(lgr_key): + lgr = self._get_named_lgr(lgr_key) + + if lgr is None: + raise KeyError("No such LGR: %s" % lgr_key) + + lgr.setParent(self) + return lgr + + + + def get_cell_lgr(self, active_index=None, global_index=None, ijk=None): + """ + Get EclGrid instance located in cell. + + Will query the current grid instance if the cell given by + @active_index, @global_index or @ijk has been refined with an + LGR. Will return None if the cell in question has not been + refined, the return value can be used for further queries. + + See get_xyz() for documentation of the input parameters. + """ + gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) + lgr = self._get_cell_lgr(gi) + if lgr: + lgr.setParent(self) + return lgr + else: + raise IndexError("No LGR defined for this cell") + + + def grid_value(self, kw, i, j, k): + """ + Will evalute @kw in location (@i,@j,@k). + + The ECLIPSE properties and solution vectors are stored in + restart and init files as 1D vectors of length nx*nx*nz or + nactive. The grid_value() method is a minor convenience + function to convert the (@i,@j,@k) input values to an + appropriate 1D index. + + Depending on the length of kw the input arguments are + converted either to an active index or to a global index. If + the length of kw does not fit with either the global size of + the grid or the active size of the grid things will fail hard. + """ + return self._grid_value(kw, i, j, k) + + + def load_column(self, kw, i, j, column): + """ + Load the values of @kw from the column specified by (@i,@j). + + The method will scan through all k values of the input field + @kw for fixed values of i and j. The size of @kw must be + either nactive or nx*ny*nz. + + The input argument @column should be a DoubleVector instance, + observe that if size of @kw == nactive k values corresponding + to inactive cells will not be modified in the @column + instance; in that case it is important that @column is + initialized with a suitable default value. + """ + self._load_column( kw, i, j, column) + + + def create_kw(self, array, kw_name, pack): + """ + Creates an EclKW instance based on existing 3D numpy object. + + The method create3D() does the inverse operation; creating a + 3D numpy object from an EclKW instance. If the argument @pack + is true the resulting keyword will have length 'nactive', + otherwise the element will have length nx*ny*nz. + """ + if array.ndim == 3: + dims = array.shape + if dims[0] == self.getNX() and dims[1] == self.getNY() and dims[2] == self.getNZ(): + dtype = array.dtype + if dtype == numpy.int32: + type = EclDataType.ECL_INT + elif dtype == numpy.float32: + type = EclDataType.ECL_FLOAT + elif dtype == numpy.float64: + type = EclDataType.ECL_DOUBLE + else: + sys.exit("Do not know how to create ecl_kw from type:%s" % dtype) + + if pack: + size = self.getNumActive() + else: + size = self.getGlobalSize() + + if len(kw_name) > 8: + # Silently truncate to length 8 - ECLIPSE has it's challenges. + kw_name = kw_name[0:8] + + kw = EclKW(kw_name, size, type) + active_index = 0 + global_index = 0 + for k in range(self.getNZ()): + for j in range(self.getNY()): + for i in range(self.getNX()): + if pack: + if self.active(global_index=global_index): + kw[active_index] = array[i,j,k] + active_index += 1 + else: + if dtype == numpy.int32: + kw[global_index] = int(array[i,j,k]) + else: + kw[global_index] = array[i,j,k] + + global_index += 1 + return kw + raise ValueError("Wrong size / dimension on array") + + + def coarse_groups(self): + """ + Will return the number of coarse groups in this grid. + """ + return self._num_coarse_groups() + + + def in_coarse_group(self, global_index=None, ijk=None, active_index=None): + """ + Will return True or False if the cell is part of coarse group. + """ + global_index = self.__global_index(active_index=active_index, ijk=ijk, global_index=global_index) + return self._in_coarse_group1(global_index) + + + def create_3d(self, ecl_kw, default = 0): + """ + Creates a 3D numpy array object with the data from @ecl_kw. + + Observe that 3D numpy object is a copy of the data in the + EclKW instance, i.e. modification to the numpy object will not + be reflected in the ECLIPSE keyword. + + The methods createKW() does the inverse operation; creating an + EclKW instance from a 3D numpy object. + + Alternative: Creating the numpy array object is not very + efficient; if you only need a limited number of elements from + the ecl_kw instance it might be wiser to use the grid_value() + method: + + value = grid.grid_value(ecl_kw, i, j, k) + + """ + if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): + array = numpy.ones([ self.getGlobalSize() ], dtype=ecl_kw.dtype) * default + kwa = ecl_kw.array + if len(ecl_kw) == self.getGlobalSize(): + for i in range(kwa.size): + array[i] = kwa[i] + else: + data_index = 0 + for global_index in range(self.getGlobalSize()): + if self.active(global_index=global_index): + array[global_index] = kwa[data_index] + data_index += 1 + + array = array.reshape([self.getNX(), self.getNY(), self.getNZ()], order='F') + return array + else: + err_msg_fmt = 'Keyword "%s" has invalid size %d; must be either nactive=%d or nx*ny*nz=%d' + err_msg = err_msg_fmt % (ecl_kw, len(ecl_kw), self.getNumActive(), + self.getGlobalSize()) + raise ValueError(err_msg) + + def save_grdecl(self, pyfile, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): + """ + Will write the the grid content as grdecl formatted keywords. + + Will only write the main grid. + """ + cfile = CFILE(pyfile) + self._fprintf_grdecl2(cfile, output_unit) + + def save_EGRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): + """ + Will save the current grid as a EGRID file. + """ + self._fwrite_EGRID2(filename, output_unit) + + def save_GRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): + """ + Will save the current grid as a EGRID file. + """ + self._fwrite_GRID2( filename, output_unit) + + + def write_grdecl(self, ecl_kw, pyfile, special_header=None, default_value=0): + """ + Writes an EclKW instance as an ECLIPSE grdecl formatted file. + + The input argument @ecl_kw must be an EclKW instance of size + nactive or nx*ny*nz. If the size is nactive the inactive cells + will be filled with @default_value; hence the function will + always write nx*ny*nz elements. + + The data in the @ecl_kw argument can be of type integer, + float, double or bool. In the case of bool the default value + must be specified as 1 (True) or 0 (False). + + The input argument @pyfile should be a valid python filehandle + opened for writing; i.e. + + pyfile = open("PORO.GRDECL", "w") + grid.write_grdecl(poro_kw , pyfile, default_value=0.0) + grid.write_grdecl(permx_kw, pyfile, default_value=0.0) + pyfile.close() + + """ + + if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): + cfile = CFILE(pyfile) + self._fwrite_grdecl(ecl_kw, special_header, cfile, default_value) + else: + raise ValueError("Keyword: %s has invalid size(%d), must be either nactive:%d or nx*ny*nz:%d" % (ecl_kw.getName(), len(ecl_kw), self.getNumActive(), self.getGlobalSize())) + + + def exportACTNUM(self): + actnum = IntVector(initial_size=self.getGlobalSize()) + self._init_actnum(actnum.getDataPtr()) + return actnum + + + def compressed_kw_copy(self, kw): + if len(kw) == self.getNumActive(): + return kw.copy() + elif len(kw) == self.getGlobalSize(): + kw_copy = EclKW(kw.getName(), self.getNumActive(), kw.data_type) + self._compressed_kw_copy(kw_copy, kw) + return kw_copy + else: + raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) + + def global_kw_copy(self, kw, default_value): + if len(kw) == self.getGlobalSize(): + return kw.copy() + elif len(kw) == self.getNumActive(): + kw_copy = EclKW(kw.getName(), self.getGlobalSize(), kw.data_type) + kw_copy.assign(default_value) + self._global_kw_copy(kw_copy, kw) + return kw_copy + else: + raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) + + + def export_ACTNUM_kw(self): + actnum = EclKW("ACTNUM", self.getGlobalSize(), EclDataType.ECL_INT) + self._init_actnum(actnum.getDataPtr()) + return actnum + + + def create_volume_keyword(self, active_size=True): + """Will create a EclKW initialized with cell volumes. + + The purpose of this method is to create a EclKW instance which + is initialized with all the cell volumes, this can then be + used to perform volume summation; i.e. to calculate the total + oil volume: + + soil = 1 - sgas - swat + cell_volume = grid.createVolumeKeyword() + tmp = cell_volume * soil + oip = tmp.sum() + + The oil in place calculation shown above could easily be + implemented by iterating over the soil kw, however using the + volume keyword has two advantages: + + 1. The calculation of cell volumes is quite time consuming, + by storing the results in a kw they can be reused. + + 2. By using the compact form 'oip = cell_volume * soil' the + inner loop iteration will go in C - which is faster. + + By default the kw will only have values for the active cells, + but by setting the optional variable @active_size to False you + will get volume values for all cells in the grid. + """ + + return self._create_volume_keyword(active_size) + + def export_coord(self): + return self._export_coord() + + def export_zcorn(self): + return self._export_zcorn() + + def export_actnum(self): + return self._export_actnum() + + def export_mapaxes(self): + if not self._use_mapaxes(): + return None + + return self._export_mapaxes() + +monkey_the_camel(EclGrid, 'loadFromGrdecl', EclGrid.load_from_grdecl, classmethod) +monkey_the_camel(EclGrid, 'loadFromFile', EclGrid.load_from_file, classmethod) +monkey_the_camel(EclGrid, 'createRectangular', EclGrid.create_rectangular, classmethod) +monkey_the_camel(EclGrid, 'dualGrid', EclGrid.dual_grid) +monkey_the_camel(EclGrid, 'getDims', EclGrid.get_dims) +monkey_the_camel(EclGrid, 'getNX', EclGrid.get_nx) +monkey_the_camel(EclGrid, 'getNY', EclGrid.get_ny) +monkey_the_camel(EclGrid, 'getNZ', EclGrid.get_nz) +monkey_the_camel(EclGrid, 'getGlobalSize', EclGrid.get_global_size) +monkey_the_camel(EclGrid, 'getNumActive', EclGrid.get_num_active) +monkey_the_camel(EclGrid, 'getNumActiveFracture', EclGrid.get_num_active_fracture) +monkey_the_camel(EclGrid, 'getBoundingBox2D', EclGrid.get_bounding_box_2d) +monkey_the_camel(EclGrid, 'getName', EclGrid.get_name) +monkey_the_camel(EclGrid, 'validCellGeometry', EclGrid.valid_cell_geometry) +monkey_the_camel(EclGrid, 'getNodePos', EclGrid.get_node_pos) +monkey_the_camel(EclGrid, 'getCellCorner', EclGrid.get_cell_corner) +monkey_the_camel(EclGrid, 'getNodeXYZ', EclGrid.get_node_xyz) +monkey_the_camel(EclGrid, 'getLayerXYZ', EclGrid.get_layer_xyz) +monkey_the_camel(EclGrid, 'findCellXY', EclGrid.find_cell_xy) +monkey_the_camel(EclGrid, 'findCellCornerXY', EclGrid.find_cell_corner_xy) +monkey_the_camel(EclGrid, 'getCellDims', EclGrid.get_cell_dims) +monkey_the_camel(EclGrid, 'getNumLGR', EclGrid.get_num_lgr) +monkey_the_camel(EclGrid, 'createKW', EclGrid.create_kw) +monkey_the_camel(EclGrid, 'create3D', EclGrid.create_3d) +monkey_the_camel(EclGrid, 'compressedKWCopy', EclGrid.compressed_kw_copy) +monkey_the_camel(EclGrid, 'globalKWCopy', EclGrid.global_kw_copy) +monkey_the_camel(EclGrid, 'exportACTNUMKw', EclGrid.export_ACTNUM_kw) +monkey_the_camel(EclGrid, 'createVolumeKeyword', EclGrid.create_volume_keyword) diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py new file mode 100644 index 0000000000..7bdf798bd3 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py @@ -0,0 +1,710 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'ecl_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import itertools, numpy +from math import sqrt + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid + +def flatten(l): + return [elem for sublist in l for elem in sublist] + +def divide(l, size): + return [l[i:i+size:] for i in range(0, len(l), size)] + +def duplicate_inner(l): + return [elem for elem in l for i in range(2)][1:-1:] + +def construct_floatKW(name, values): + kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) + for i, value in enumerate(values): + kw[i] = value + return kw + +def pre_mapaxes_translation(translation, mapaxes): + if mapaxes is None: + return translation + + x, y, z = translation + + unit_y = numpy.array((mapaxes[0]-mapaxes[2], mapaxes[1]-mapaxes[3])); + unit_y /= sqrt(numpy.sum(unit_y*unit_y)) + + unit_x = numpy.array((mapaxes[4]-mapaxes[2], mapaxes[5]-mapaxes[3])); + unit_x /= sqrt(numpy.sum(unit_x*unit_x)) + + det = 1.0 / (unit_x[0]*unit_y[1] - unit_x[1] * unit_y[0]); + + return ( + ( x*unit_y[1] - y*unit_y[0]) * det, + (-x*unit_x[1] + y*unit_x[0]) * det, + z + ) + +class EclGridGenerator: + + _alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind=False) + + @classmethod + def create_rectangular(cls, dims, dV, actnum=None): + """ + Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz) + + With the default value @actnum == None all cells will be active, + """ + if actnum is None: + ecl_grid = cls._alloc_rectangular( + dims[0], dims[1], dims[2], + dV[0], dV[1], dV[2], + None + ) + else: + if not isinstance(actnum, IntVector): + tmp = IntVector(initial_size=len(actnum)) + for (index, value) in enumerate(actnum): + tmp[index] = value + actnum = tmp + + if not len(actnum) == dims[0]*dims[1]*dims[2]: + raise ValueError( + "ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" + % (len(actnum), dims[0]*dims[1]*dims[2]) + ) + + ecl_grid = cls._alloc_rectangular( + dims[0], dims[1], dims[2], + dV[0], dV[1], dV[2], + actnum.getDataPtr() + ) + + # If we have not succeeded in creatin the grid we *assume* the + # error is due to a failed malloc. + if ecl_grid is None: + raise MemoryError("Failed to allocated regualar grid") + + return ecl_grid + + @classmethod + def create_single_cell_grid(cls, corners): + """ + Provided with the corners of the grid in a similar manner as the eight + corners are output for a single cell, this method will create a grid + consisting of a single cell with the specified corners as its corners. + """ + + zcorn = [corners[i][2] for i in range(8)] + + coord = [(corners[i], corners[i+4]) for i in range(4)] + coord = flatten(flatten(coord)) + + def construct_floatKW(name, values): + kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) + for i in range(len(values)): + kw[i] = values[i] + return kw + + grid = EclGrid.create( + (1, 1, 1), + construct_floatKW("ZCORN", zcorn), + construct_floatKW("COORD", coord), + None + ) + + if not corners == [grid.getCellCorner(i, 0) for i in range(8)]: + raise AssertionError("Failed to generate single cell grid. " + + "Did not end up the expected corners.") + + return grid + + @classmethod + def create_zcorn(cls, dims, dV, offset=1, escape_origo_shift=(1,1,0), + irregular_offset=False, irregular=False, concave=False, + faults=False): + + cls.__assert_zcorn_parameters(dims, dV, offset, escape_origo_shift, + irregular_offset, irregular, concave, faults) + + nx, ny, nz = dims + dx, dy, dz = dV + + # Compute zcorn + z = escape_origo_shift[2] + zcorn = [z]*(4*nx*ny) + for k in range(nz-1): + z = z+dz + local_offset = offset + (dz/2. if irregular_offset and k%2 == 0 else 0) + + layer = [] + for i in range(ny+1): + shift = ((i if concave else 0) + (k/2 if irregular else 0)) % 2 + path = [z if i%2 == shift else z+local_offset for i in range(nx+1)] + layer.append(duplicate_inner(path)) + + zcorn = zcorn + (2*flatten(duplicate_inner(layer))) + + z = z+dz + zcorn = zcorn + ([z]*(4*nx*ny)) + + if faults: + # Ensure that drop does not align with grid structure + drop = (offset+dz)/2. if abs(offset-dz/2.) > 0.2 else offset + 0.4 + zcorn = cls.__create_faults(nx, ny, nz, zcorn, drop) + + + if z != escape_origo_shift[2] + nz*dz: + raise ValueError("%f != %f" % (z, escape_origo_shift[2] + nz*dz)) + + cls.assert_zcorn(nx, ny, nz, zcorn) + return construct_floatKW("ZCORN", zcorn) + + @classmethod + def create_coord(cls, dims, dV, escape_origo_shift=(1,1,0), + scale=1, translation=(0,0,0), rotate=False, misalign=False): + + nx, ny, nz = dims + dx, dy, dz = dV + + # Compute coord + z = escape_origo_shift[2] + nz*dz + coord = [] + for j, i in itertools.product(range(ny+1), range(nx+1)): + x, y = i*dx+escape_origo_shift[0], j*dy+escape_origo_shift[1] + coord = coord + [x, y, escape_origo_shift[2], x, y, z] + + # Apply transformations + lower_center = ( + nx*dx/2. + escape_origo_shift[0], + ny*dy/2. + escape_origo_shift[1] + ) + + if misalign: + coord = cls.__misalign_coord(coord, dims, dV) + + coord = cls.__scale_coord(coord, scale, lower_center) + + if rotate: + coord = cls.__rotate_coord(coord, lower_center) + + coord = cls.__translate_lower_coord(coord, translation) + + cls.assert_coord(nx, ny, nz, coord) + return construct_floatKW("COORD", coord) + + @classmethod + def __assert_zcorn_parameters(cls, dims, dV, offset, escape_origo_shift, + irregular_offset, irregular, concave, faults): + + nx, ny, nz = dims + dx, dy, dz = dV + + # Validate arguments + if min(dims + dV) <= 0: + raise ValueError("Expected positive grid and cell dimentions") + + if offset < 0: + raise ValueError("Expected non-negative offset") + + if irregular and offset + (dz/2. if irregular_offset else 0) > dz: + raise AssertionError("Arguments can result in self-" + + "intersecting cells. Increase dz, deactivate eiter " + + "irregular or irregular_offset, or decrease offset to avoid " + + "any problems") + + @classmethod + def create_grid(cls, dims, dV, offset=1, + escape_origo_shift=(1,1,0), + irregular_offset=False, irregular=False, concave=False, + faults=False, scale=1, translation=(0,0,0), rotate=False, + misalign=False): + """ + Will create a new grid where each cell is a parallelogram (skewed by z-value). + The number of cells are given by @dims = (nx, ny, nz) and the dimention + of each cell by @dV = (dx, dy, dz). + + All cells are guaranteed to not be self-intersecting. Hence, no twisted + cells and somewhat meaningfull cells. + + @offset gives how much the layers should fluctuate or "wave" as you + move along the X-axis. + + @irregular_offset decides whether the offset should be constant or + increase by dz/2 every now and then. + + @irregular if true some of the layers will be inclining and others + declining at the start. + + @concave decides whether the cells are to be convex or not. In + particular, if set to False, all cells of the grid will be concave. + + @escape_origo_shift is used to prevent any cell of having corners in (0,0,z) + as there is a heuristic in ecl_grid.c that marks such cells as tainted. + + @faults decides if there are to be faults in the grid. + + @scale A positive number that scales the "lower" endpoint of all + coord's. In particular, @scale != 1 creates trapeziod cells in both the XZ + and YZ-plane. + + @translation the lower part of the grid is translated ("slided") by the specified + additive factor. + + @rotate the lower part of the grid is rotated 90 degrees around its + center. + + @misalign will toggle COORD's slightly in various directions to break + alignment + + Note that cells in the lowermost layer can have multiple corners + at the same point. + + For testing it should give good coverage of the various scenarios this + method can produce, by leting @dims be (10,10,10), @dV=(2,2,2), @offset=1, + and try all 4 different configurations of @concave and + @irregular_offset. + """ + + zcorn = cls.create_zcorn(dims, dV, offset, escape_origo_shift, + irregular_offset, irregular, concave, faults) + + coord = cls.create_coord(dims, dV, escape_origo_shift, scale, + translation, rotate, misalign) + + return EclGrid.create(dims, zcorn, coord, None) + + @classmethod + def __create_faults(cls, nx, ny, nz, zcorn, drop): + """ + Will create several faults consisting of all cells such that either its + i or j index is 1 modulo 3. + """ + + plane_size = 4*nx*ny + for x, y, z in itertools.product(range(nx), range(ny), range(nz)): + if x%3 != 1 and y%3 != 1: + continue + + corner = [0]*8 + corner[0] = 2*z*plane_size + 4*y*nx + 2*x + corner[1] = corner[0] + 1 + corner[2] = corner[0] + 2*nx + corner[3] = corner[2] + 1 + + for i in range(4, 8): + corner[i] = corner[i-4] + plane_size + + for c in corner: + zcorn[c] = zcorn[c] + drop + + return zcorn + + @classmethod + def assert_zcorn(cls, nx, ny, nz, zcorn, twisted_check=True): + """ + + Raises an AssertionError if the zcorn is not as expected. In + patricular, it is verified that: + + - zcorn has the approperiate length (8*nx*ny*nz) and + - that no cell is twisted. + + """ + + if len(zcorn) != 8*nx*ny*nz: + raise AssertionError( + "Expected len(zcorn) to be %d, was %d" % + (8*nx*ny*nz, len(zcorn)) + ) + + plane_size = 4*nx*ny + for p in range(8*nx*ny*nz - plane_size): + if zcorn[p] > zcorn[p + plane_size] and twisted_check: + raise AssertionError( + "Twisted cell was created. " + + "Decrease offset or increase dz to avoid this!" + ) + + @classmethod + def __scale_coord(cls, coord, scale, lower_center): + coord = numpy.array([ + list(map(float, coord[i:i+6:])) + for i in range(0, len(coord), 6) + ]) + origo = numpy.array(3*[0.] + list(lower_center) + [0]) + scale = numpy.array(3*[1.] + 2*[scale] + [1]) + coord = scale * (coord-origo) + origo + return coord.flatten().tolist() + + @classmethod + def __misalign_coord(cls, coord, dims, dV): + nx, ny, nz = dims + + coord = numpy.array([ + list(map(float, coord[i:i+6:])) + for i in range(0, len(coord), 6) + ]) + + tf = lambda i, j: 1./2 if abs(i)+abs(j) <= 1 else 0.25 + adjustment = numpy.array([ + (0, 0, 0, i*tf(i,j)*dV[0], j*tf(i,j)*dV[1], 0) for i, j in itertools.product([-1, 0, 1], repeat=2) + ]) + + for i, c in enumerate(coord): + # Leave the outermost coords alone + if i < nx+1 or i >= len(coord)-(nx+1): + continue + if i%(nx+1) in [0, nx]: + continue + + c += adjustment[i%len(adjustment)] + + return coord.flatten().tolist() + + @classmethod + def __rotate_coord(cls, coord, lower_center): + coord = numpy.array([ + list(map(float, coord[i:i+6:])) + for i in range(0, len(coord), 6) + ]) + + origo = numpy.array(3*[0.] + list(lower_center) + [0]) + coord -= origo + + for c in coord: + c[3], c[4] = -c[4], c[3] + + coord += origo + return coord.flatten().tolist() + + @classmethod + def __translate_lower_coord(cls, coord, translation): + coord = numpy.array([ + list(map(float, coord[i:i+6:])) + for i in range(0, len(coord), 6) + ]) + translation = numpy.array(3*[0.] + list(translation)) + + coord = coord + translation + return coord.flatten().tolist() + + @classmethod + def assert_coord(cls, nx, ny, nz, coord, negative_values=False): + """ + + Raises an AssertionError if the coord is not as expected. In + particular, it is verified that: + + - coord has the approperiate length (6*(nx+1)*(ny+1)) and + - that all values are positive unless negative_values are + explicitly allowed. + + """ + + if len(coord) != 6*(nx+1)*(ny+1): + raise AssertionError( + "Expected len(coord) to be %d, was %d" % + (6*(nx+1)*(ny+1), len(coord)) + ) + + if not negative_values and min(coord) < 0: + raise AssertionError("Negative COORD values was generated. " + + "This is likely due to a tranformation. " + + "Increasing the escape_origio_shift will most likely " + + "fix the problem") + + @classmethod + def assert_actnum(cls, nx, ny, nz, actnum): + """ + + Raises an AssertionError if the actnum is not as expected. In + particular, it is verified that: + + - actnum has the approperiate length nx*ny*nz and + - that all values are either 0 or 1. + + """ + + if actnum is None: + return + + if len(actnum) != nx*ny*nz: + raise AssertionError( + "Expected the length of ACTNUM to be %d, was %s." + %(nx*ny*nz, len(actnum)) + ) + + if set(actnum)-set([0,1]): + raise AssertionError( + "Expected ACTNUM to consist of 0's and 1's, was %s." + % ", ".join(map(str, set(actnum))) + ) + + @classmethod + def extract_coord(cls, dims, coord, ijk_bounds): + nx, ny, nz = dims + (lx, ux), (ly, uy), (lz, uz) = ijk_bounds + new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 + + cls.assert_coord(nx, ny, nz, coord, negative_values=True) + + # Format COORD + coord = divide(divide(coord, 6), nx+1) + + # Extract new COORD + new_coord = [coord_slice[lx:ux+2:] + for coord_slice in coord[ly:uy+2]] + + # Flatten and verify + new_coord = flatten(flatten(new_coord)) + cls.assert_coord(new_nx, new_ny, new_nz, new_coord, + negative_values=True) + + return construct_floatKW("COORD", new_coord) + + @classmethod + def extract_zcorn(cls, dims, zcorn, ijk_bounds): + nx, ny, nz = dims + (lx, ux), (ly, uy), (lz, uz) = ijk_bounds + new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 + + cls.assert_zcorn(nx, ny, nz, zcorn, twisted_check=False) + + # Format ZCORN + zcorn = divide(divide(zcorn, 2*nx), 2*ny) + + # Extract new ZCORN + new_zcorn = [ + y_slice[2*lx:2*ux+2:] + for z_slice in zcorn[2*lz:2*uz+2:] + for y_slice in z_slice[2*ly:2*uy+2:] + ] + + # Flatten and verify + new_zcorn = flatten(new_zcorn) + cls.assert_zcorn(new_nx, new_ny, new_nz, new_zcorn) + + return construct_floatKW("ZCORN", new_zcorn) + + @classmethod + def extract_actnum(cls, dims, actnum, ijk_bounds): + if actnum is None: + return None + + nx, ny, nz = dims + (lx, ux), (ly, uy), (lz, uz) = ijk_bounds + new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 + + cls.assert_actnum(nx, ny, nz, actnum) + + actnum = divide(divide(actnum, nx), ny) + + new_actnum = [ + y_slice[lx:ux+1:] + for z_slice in actnum[lz:uz+1:] + for y_slice in z_slice[ly:uy+1:] + ] + + new_actnum = flatten(new_actnum) + cls.assert_actnum(new_nx, new_ny, new_nz, new_actnum) + + actnumkw = EclKW("ACTNUM", len(new_actnum), EclDataType.ECL_INT) + for i, value in enumerate(new_actnum): + actnumkw[i] = value + + return actnumkw + + @classmethod + def __translate_coord(cls, coord, translation): + coord = numpy.array([ + list(map(float, coord[i:i+6:])) + for i in range(0, len(coord), 6) + ]) + translation = numpy.array(list(translation) + list(translation)) + + coord = coord + translation + return construct_floatKW("COORD", coord.flatten().tolist()) + + + @classmethod + def extract_subgrid(cls, grid, ijk_bounds, + decomposition_change=False, translation=None): + + """ + Extracts a subgrid from the given grid according to the specified + bounds. + + @ijk_bounds: The bounds describing the subgrid. Should be a tuple of + length 3, where each element gives the bound for the i, j, k + coordinates of the subgrid to be described, respectively. Each bound + should either be an interval of the form (a, b) where 0 <= a <= b < nx + or a single integer a which is equivialent to the bound (a, a). + + NOTE: The given bounds are including endpoints. + + @decomposition_change: Depending on the given ijk_bounds, libecl might + decompose the cells of the subgrid differently when extracted from + grid. This is somewhat unexpected behaviour and if this event occur we + give an exception together with an description for how to avoid this, + unless decompostion_change is set to True. + + @translation: Gives the possibility of translating the subgrid. Should + be given as a tuple (dx, dy, dz), where each coordinate of the grid + will be moved by di in direction i. + + """ + + gdims = grid.getDims()[:-1:] + nx, ny, nz = gdims + ijk_bounds = cls.assert_ijk_bounds(gdims, ijk_bounds) + + coord = grid.export_coord() + cls.assert_coord(nx, ny, nz, coord, negative_values=True) + + zcorn = grid.export_zcorn() + cls.assert_zcorn(nx, ny, nz, zcorn) + + actnum = grid.export_actnum() + cls.assert_actnum(nx, ny, nz, actnum) + + mapaxes = grid.export_mapaxes() + + sub_data = cls.extract_subgrid_data( + gdims, + coord, zcorn, + ijk_bounds=ijk_bounds, + actnum=actnum, + mapaxes=mapaxes, + decomposition_change=decomposition_change, + translation=translation + ) + + sdim = tuple([b-a+1 for a,b in ijk_bounds]) + sub_coord, sub_zcorn, sub_actnum = sub_data + + return EclGrid.create(sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes) + + @classmethod + def extract_subgrid_data(cls, dims, coord, zcorn, ijk_bounds, actnum=None, + mapaxes=None, decomposition_change=False, translation=None): + """ + + Extracts subgrid data from COORD, ZCORN and potentially ACTNUM. It + returns similar formatted data for the subgrid described by the bounds. + + @dims: The dimentions (nx, ny, nz) of the grid + + @coord: The COORD data of the grid. + + @zcorn: The ZCORN data of the grid. + + @ijk_bounds: The bounds describing the subgrid. Should be a tuple of + length 3, where each element gives the bound for the i, j, k + coordinates of the subgrid to be described, respectively. Each bound + should either be an interval of the form (a, b) where 0 <= a <= b < nx + or a single integer a which is equivialent to the bound (a, a). + + NOTE: The given bounds are including endpoints. + + @actnum: The ACTNUM data of the grid. + + @mapaxes The MAPAXES data of the grid. + + @decomposition_change: Depending on the given ijk_bounds, libecl might + decompose the cells of the subgrid differently when extracted from + grid. This is somewhat unexpected behaviour and if this event occur we + give an exception together with an description for how to avoid this, + unless decompostion_change is set to True. + + @translation: Gives the possibility of translating the subgrid. Should + be given as a tuple (dx, dy, dz), where each coordinate of the grid + will be moved by di in direction i. + + """ + coord, zcorn = list(coord), list(zcorn) + actnum = None if actnum is None else list(actnum) + + ijk_bounds = cls.assert_ijk_bounds(dims, ijk_bounds) + cls.assert_decomposition_change(ijk_bounds, decomposition_change) + + nx, ny, nz = dims + (lx, ux), (ly, uy), (lz, uz) = ijk_bounds + new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 + + new_coord = cls.extract_coord(dims, coord, ijk_bounds) + new_zcorn = cls.extract_zcorn(dims, zcorn, ijk_bounds) + new_actnum = cls.extract_actnum(dims, actnum, ijk_bounds) + + if translation is not None: + mtranslation = pre_mapaxes_translation(translation, mapaxes) + new_coord = cls.__translate_coord(new_coord, mtranslation) + + for i in range(len(new_zcorn)): + new_zcorn[i] += translation[2] + + return new_coord, new_zcorn, new_actnum + + @classmethod + def assert_ijk_bounds(cls, dims, ijk_bounds): + ijk_bounds = list(ijk_bounds) + + for i in range(len(ijk_bounds)): + if isinstance(ijk_bounds[i], int): + ijk_bounds[i] = [ijk_bounds[i]] + if len(ijk_bounds[i]) == 1: + ijk_bounds[i] += ijk_bounds[i] + + if len(ijk_bounds) != 3: + raise ValueError( + "Expected ijk_bounds to contain three intervals, " + + "contained only %d" % len(ijk_bounds)) + + for n, bound in zip(dims, ijk_bounds): + if len(bound) != 2: + raise ValueError( + "Expected bound to consist of two elements, was %s", + str(bound)) + + if not (isinstance(bound[0], int) and isinstance(bound[1], int)): + raise TypeError( + "Expected bound to consist of two integers, ", + "was %s (%s)" + %(str(bound), str((map(type,bound)))) + ) + + if not (0 <= bound[0] <= bound[1] < n): + raise ValueError( + "Expected bounds to have the following format: " + + "0 <= lower bound <= upper_bound < ni, "+ + "was %d <=? %d <=? %d +# for more details. +""" +Module used to select cells based on many different criteria. + +This module implements the class EclRegion which can be used to select +cells in a grid matching a criteria. A wide range of different +criteria are supported. Many of the special functions for implementing +mathematical operations are implemented, so that regions can be +combined e.g. with logical &. + +When the selection process is complete the region instance can be +queried for the corresponding list of indices. +""" +import ctypes + +from cwrap import BaseCClass + +import ecl +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector + +from ecl import EclPrototype +from ecl.grid.faults import Layer +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.util.geometry import CPolyline + + +def select_method(select): + """ + The select_method method decorator is applied to all the + select_xxx() methods. The purpose of this decorator is to + allow the select_xxx() methods to have an optional argument + @intersect. If the @intersect argument is True the results of + the current select method will be and'ed with the current + selection, instead of or'ed which is the default. + + Consider this example: + + region = EclRegion( grid , False ) + region.select_islice(0 , 5) # Selects all cells with i:[0:5] + region.select_jslice(0 , 5) # Selects all cells with j:[0:5] + + When these two calls have completed selection will contain all + the cells which are either in i-interval [0:5] or in + j-interval [0:5]. If we supply the @intersect argument in the + second call the j selection will only be applied to the cells + in i:[0:5] interval: + + region = EclRegion( grid , False ) + region.select_islice(0 , 5) # Selects all cells with i:[0:5] + region.select_jslice(0 , 5) # Selects all cells with j:[0:5] AND i:[0:5] + """ + + def select_wrapper(self , *args , **kwargs): + intersect = 'intersect' in kwargs and kwargs['intersect'] + if intersect: + new_region = EclRegion( self.grid , False ) + select(new_region , *args ) + + self &= new_region + else: + select(self , *args ) + + return select_wrapper + +class EclRegion(BaseCClass): + TYPE_NAME = "ecl_region" + _alloc = EclPrototype("void* ecl_region_alloc( ecl_grid , bool )", bind = False) + _alloc_copy = EclPrototype("ecl_region_obj ecl_region_alloc_copy( ecl_region )") + + _set_kw_int = EclPrototype("void ecl_region_set_kw_int( ecl_region , ecl_kw , int, bool) ") + _set_kw_float = EclPrototype("void ecl_region_set_kw_float( ecl_region , ecl_kw , float, bool ) ") + _set_kw_double = EclPrototype("void ecl_region_set_kw_double( ecl_region , ecl_kw , double , bool) ") + _shift_kw_int = EclPrototype("void ecl_region_shift_kw_int( ecl_region , ecl_kw , int, bool) ") + _shift_kw_float = EclPrototype("void ecl_region_shift_kw_float( ecl_region , ecl_kw , float, bool ) ") + _shift_kw_double = EclPrototype("void ecl_region_shift_kw_double( ecl_region , ecl_kw , double , bool) ") + _scale_kw_int = EclPrototype("void ecl_region_scale_kw_int( ecl_region , ecl_kw , int, bool) ") + _scale_kw_float = EclPrototype("void ecl_region_scale_kw_float( ecl_region , ecl_kw , float, bool ) ") + _scale_kw_double = EclPrototype("void ecl_region_scale_kw_double( ecl_region , ecl_kw , double , bool) ") + _sum_kw_int = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ") + _sum_kw_float = EclPrototype("float ecl_region_sum_kw_float( ecl_region , ecl_kw , bool ) ") + _sum_kw_double = EclPrototype("double ecl_region_sum_kw_double( ecl_region , ecl_kw , bool) ") + _sum_kw_bool = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ") + + _free = EclPrototype("void ecl_region_free( ecl_region )") + _reset = EclPrototype("void ecl_region_reset( ecl_region )") + _select_all = EclPrototype("void ecl_region_select_all( ecl_region )") + _deselect_all = EclPrototype("void ecl_region_deselect_all( ecl_region )") + _select_equal = EclPrototype("void ecl_region_select_equal( ecl_region , ecl_kw , int )") + _deselect_equal = EclPrototype("void ecl_region_deselect_equal( ecl_region , ecl_kw , int)") + _select_less = EclPrototype("void ecl_region_select_smaller( ecl_region , ecl_kw , float )") + _deselect_less = EclPrototype("void ecl_region_deselect_smaller( ecl_region , ecl_kw , float )") + _select_more = EclPrototype("void ecl_region_select_larger( ecl_region , ecl_kw , float )") + _deselect_more = EclPrototype("void ecl_region_deselect_larger( ecl_region , ecl_kw , float )") + _select_in_interval = EclPrototype("void ecl_region_select_in_interval( ecl_region, ecl_kw , float , float )") + _deselect_in_interval = EclPrototype("void ecl_region_deselect_in_interval( ecl_region, ecl_kw, float , float )") + _invert_selection = EclPrototype("void ecl_region_invert_selection( ecl_region )") + + _select_box = EclPrototype("void ecl_region_select_from_ijkbox(ecl_region , int , int , int , int , int , int)") + _deselect_box = EclPrototype("void ecl_region_deselect_from_ijkbox(ecl_region , int , int , int , int , int , int)") + _imul_kw = EclPrototype("void ecl_region_kw_imul( ecl_region , ecl_kw , ecl_kw , bool)") + _idiv_kw = EclPrototype("void ecl_region_kw_idiv( ecl_region , ecl_kw , ecl_kw , bool)") + _iadd_kw = EclPrototype("void ecl_region_kw_iadd( ecl_region , ecl_kw , ecl_kw , bool)") + _isub_kw = EclPrototype("void ecl_region_kw_isub( ecl_region , ecl_kw , ecl_kw , bool)") + _copy_kw = EclPrototype("void ecl_region_kw_copy( ecl_region , ecl_kw , ecl_kw , bool)") + _intersect = EclPrototype("void ecl_region_intersection( ecl_region , ecl_region )") + _combine = EclPrototype("void ecl_region_union( ecl_region , ecl_region )") + _subtract = EclPrototype("void ecl_region_subtract( ecl_region , ecl_region )") + _xor = EclPrototype("void ecl_region_xor( ecl_region , ecl_region )") + _get_kw_index_list = EclPrototype("int_vector_ref ecl_region_get_kw_index_list( ecl_region , ecl_kw , bool )") + _get_active_list = EclPrototype("int_vector_ref ecl_region_get_active_list( ecl_region )") + _get_global_list = EclPrototype("int_vector_ref ecl_region_get_global_list( ecl_region )") + _get_active_global = EclPrototype("int_vector_ref ecl_region_get_global_active_list( ecl_region )") + _select_cmp_less = EclPrototype("void ecl_region_cmp_select_less( ecl_region , ecl_kw , ecl_kw)") + _select_cmp_more = EclPrototype("void ecl_region_cmp_select_more( ecl_region , ecl_kw , ecl_kw)") + _deselect_cmp_less = EclPrototype("void ecl_region_cmp_deselect_less( ecl_region , ecl_kw , ecl_kw)") + _deselect_cmp_more = EclPrototype("void ecl_region_cmp_deselect_more( ecl_region , ecl_kw , ecl_kw)") + _select_islice = EclPrototype("void ecl_region_select_i1i2( ecl_region , int , int )") + _deselect_islice = EclPrototype("void ecl_region_deselect_i1i2( ecl_region , int , int )") + _select_jslice = EclPrototype("void ecl_region_select_j1j2( ecl_region , int , int )") + _deselect_jslice = EclPrototype("void ecl_region_deselect_j1j2( ecl_region , int , int )") + _select_kslice = EclPrototype("void ecl_region_select_k1k2( ecl_region , int , int )") + _deselect_kslice = EclPrototype("void ecl_region_deselect_k1k2( ecl_region , int , int )") + _select_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )") + _deselect_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )") + _select_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )") + _deselect_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )") + _select_small = EclPrototype("void ecl_region_select_small_cells( ecl_region , double )") + _deselect_small = EclPrototype("void ecl_region_deselect_small_cells( ecl_region , double )") + _select_large = EclPrototype("void ecl_region_select_large_cells( ecl_region , double )") + _deselect_large = EclPrototype("void ecl_region_deselect_large_cells( ecl_region , double )") + _select_thin = EclPrototype("void ecl_region_select_thin_cells( ecl_region , double )") + _deselect_thin = EclPrototype("void ecl_region_deselect_thin_cells( ecl_region , double )") + _select_thick = EclPrototype("void ecl_region_select_thick_cells( ecl_region , double )") + _deselect_thick = EclPrototype("void ecl_region_deselect_thick_cells( ecl_region , double )") + _select_active = EclPrototype("void ecl_region_select_active_cells( ecl_region )") + _select_inactive = EclPrototype("void ecl_region_select_inactive_cells( ecl_region )") + _deselect_active = EclPrototype("void ecl_region_deselect_active_cells( ecl_region )") + _deselect_inactive = EclPrototype("void ecl_region_deselect_inactive_cells( ecl_region )") + _select_above_plane = EclPrototype("void ecl_region_select_above_plane( ecl_region , double* , double* )") + _select_below_plane = EclPrototype("void ecl_region_select_below_plane( ecl_region , double* , double* )") + _deselect_above_plane = EclPrototype("void ecl_region_deselect_above_plane( ecl_region, double* , double* )") + _deselect_below_plane = EclPrototype("void ecl_region_deselect_below_plane( ecl_region, double* , double* )") + _select_inside_polygon = EclPrototype("void ecl_region_select_inside_polygon( ecl_region , geo_polygon)") + _select_outside_polygon = EclPrototype("void ecl_region_select_outside_polygon( ecl_region , geo_polygon)") + _deselect_inside_polygon = EclPrototype("void ecl_region_deselect_inside_polygon( ecl_region , geo_polygon)") + _deselect_outside_polygon = EclPrototype("void ecl_region_deselect_outside_polygon( ecl_region , geo_polygon)") + _set_name = EclPrototype("void ecl_region_set_name( ecl_region , char*)") + _get_name = EclPrototype("char* ecl_region_get_name( ecl_region )") + _contains_ijk = EclPrototype("void ecl_region_contains_ijk( ecl_region , int , int , int)") + _contains_global = EclPrototype("void ecl_region_contains_global( ecl_region, int )") + _contains_active = EclPrototype("void ecl_region_contains_active( ecl_region , int )") + _equal = EclPrototype("bool ecl_region_equal( ecl_region , ecl_region )") + _select_true = EclPrototype("void ecl_region_select_true( ecl_region , ecl_kw)") + _select_false = EclPrototype("void ecl_region_select_false( ecl_region , ecl_kw)") + _deselect_true = EclPrototype("void ecl_region_deselect_true( ecl_region , ecl_kw)") + _deselect_false = EclPrototype("void ecl_region_deselect_false( ecl_region , ecl_kw)") + _select_from_layer = EclPrototype("void ecl_region_select_from_layer( ecl_region , layer , int , int)") + _deselect_from_layer = EclPrototype("void ecl_region_deselect_from_layer( ecl_region , layer , int , int)") + + + def __init__(self , grid , preselect): + """ + Create a new region selector for cells in @grid. + + Will create a new region selector to select and deselect the + cells in the grid given by @grid. The input argument @grid + should be a EclGrid instance. You can start with either all + cells, or no cells, selected, depending on the value of + @preselect. + """ + + self.grid = grid + self.active_index = False + c_ptr = self._alloc( grid , preselect ) + super(EclRegion , self).__init__( c_ptr ) + + + def free(self): + self._free( ) + + + def __eq__(self , other): + return self._equal(other) + + def __hash__(self): + return hash(hash(self.grid) + hash(self.active_index)) + + + def __deep_copy__(self , memo): + """ + Creates a deep copy of the current region. + """ + return self._alloc_copy( ) + + def __nonzero__(self): + global_list = self.get_global_list() + return len(global_list) > 0 + + def __bool__(self): + return self.__nonzero__() + + def __iand__(self , other): + """ + Will perform set intersection operation inplace. + + Will update the current region selection so that the elements + selected in self are also selected in @other. Bound to the + inplace & operator, i.e. + + reg1 &= reg2 + + will eventually call this method. + """ + if isinstance(other , EclRegion): + self._intersect( other) + else: + raise TypeError("Ecl region can only intersect with other EclRegion instances") + + return self + + + def __isub__(self , other): + """ + Inplace "subtract" one selection from another. + + Bound to reg -= reg2 + """ + if isinstance( other , EclRegion ): + self._subtract( other) + else: + raise TypeError("Ecl region can only subtract with other EclRegion instances") + + return self + + + def __ior__(self , other): + """ + Will perform set operation union in place. + + The current region selection will be updated to contain all + the elements which are selected either in the current region, + or in @other; bound to to inplace | operator, so you can write e.g. + + reg1 |= reg2 + + to update reg1 with the selections from reg2. + """ + if isinstance( other , EclRegion): + self._combine( other) + else: + raise TypeError("Ecl region can only be combined with other EclRegion instances") + + return self + + def __iadd__(self , other): + """ + Combines to regions - see __ior__(). + """ + return self.__ior__( other ) + + def __or__(self , other): + """ + Creates a new region which is the union of @self and other. + + The method will create a new region which selection status is + given by the logical or of regions @self and @other; the two + initial regions will not be modified. Bound to the unary | + operator: + + new_reg = reg1 | reg2 + + """ + new_region = self.copy() + new_region.__ior__( other ) + return new_region + + def __and__(self , other): + """ + Creates a new region which is the intersection of @self and other. + + The method will create a new region which selection status is + given by the logical and of regions @self and @other; the two + initial regions will not be modified. Bound to the unary & + operator: + + new_reg = reg1 & reg2 + """ + new_region = self.copy() + new_region.__iand__( other ) + return new_region + + def __add__(self , other): + """ + Unary add operator for two regions - implemented by __or__(). + """ + return self.__or__( other ) + + + def __sub__( self, other): + """ + Unary del operator for two regions. + """ + new_region = self.copy() + new_region.__isub__( other ) + return new_region + + + def union_with( self, other): + """ + Will update self with the union of @self and @other. + + See doscumentation of __ior__(). + """ + return self.__ior__( other ) + + def intersect_with( self, other): + """ + Will update self with the intersection of @self and @other. + + See doscumentation of __iand__(). + """ + return self.__iand__( other ) + + + def copy( self ): + return self.__deep_copy__( {} ) + + def reset(self): + """ + Clear selections according to constructor argument @preselect. + + Will clear all selections, depending on the value of the + constructor argument @preselect. If @preselect is true + everything will be selected after calling reset(), otherwise + no cells will be selected after calling reset(). + """ + self._reset( ) + + ################################################################## + + + @select_method + def select_more( self , ecl_kw , limit , intersect = False): + """ + Select all cells where keyword @ecl_kw is above @limit. + + This method is used to select all the cells where an arbitrary + field, contained in @ecl_kw, is above a limiting value + @limit. The EclKW instance must have either nactive or + nx*ny*nz elements; if this is not satisfied method will fail + hard. The datatype of @ecl_kw must be numeric, + i.e. ECL_INT_TYPE, ECL_DOUBLE_TYPE or ECL_FLOAT_TYPE. In the + example below we select all the cells with water saturation + above 0.85: + + restart_file = ecl.EclFile( "ECLIPSE.X0067" ) + swat_kw = restart_file["SWAT"][0] + grid = ecl.EclGrid( "ECLIPSE.EGRID" ) + region = ecl.EclRegion( grid , False ) + + region.select_more( swat_kw , 0.85 ) + + """ + self._select_more( ecl_kw , limit ) + + + + def deselect_more( self , ecl_kw , limit): + """ + Deselects cells with value above limit. + + See select_more() for further documentation. + """ + self._deselect_more( ecl_kw , limit ) + + @select_method + def select_less( self , ecl_kw , limit , intersect = False): + """ + Select all cells where keyword @ecl_kw is below @limit. + + See select_more() for further documentation. + """ + self._select_less( ecl_kw , limit ) + + def deselect_less( self , ecl_kw , limit): + """ + Deselect all cells where keyword @ecl_kw is below @limit. + + See select_more() for further documentation. + """ + self._deselect_less( ecl_kw , limit ) + + @select_method + def select_equal( self , ecl_kw , value , intersect = False): + """ + Select all cells where @ecl_kw is equal to @value. + + The EclKW instance @ecl_kw must be of size nactive or + nx*ny*nz, and it must be of integer type; testing for equality + is not supported for floating point numbers. In the example + below we select all the cells in PVT regions 2 and 4: + + init_file = ecl.EclFile( "ECLIPSE.INIT" ) + pvtnum_kw = init_file.iget_named_kw( "PVTNUM" , 0 ) + grid = ecl.EclGrid( "ECLIPSE.GRID" ) + region = ecl.EclRegion( grid , False ) + + region.select_equal( pvtnum_kw , 2 ) + region.select_equal( pvtnum_kw , 4 ) + + """ + if not ecl_kw.data_type.is_int(): + raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( )) + self._select_equal( ecl_kw , value ) + + + def deselect_equal( self , ecl_kw , value ): + """ + Select all cells where @ecl_kw is equal to @value. + + See select_equal() for further documentation. + """ + if not ecl_kw.data_type.is_int(): + raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( )) + self._deselect_equal( ecl_kw , value ) + + @select_method + def select_in_range( self , ecl_kw , lower_limit , upper_limit , select = False): + """ + Select all cells where @ecl_kw is in the half-open interval [ , ). + + Will select all the cells where EclKW instance @ecl_kw has + value in the half-open interval [@lower_limit , + @upper_limit). The input argument @ecl_kw must have size + nactive or nx*ny*nz, and it must be of type ECL_FLOAT_TYPE. + + The following example will select all cells with porosity in + the range [0.15,0.20): + + init_file = ecl.EclFile( "ECLIPSE.INIT" ) + poro_kw = init_file.iget_named_kw( "PORO" , 0 ) + grid = ecl.EclGrid( "ECLIPSE.GRID" ) + region = ecl.EclRegion( grid , False ) + + region.select_in_range( poro_kw , 0.15, 0.20 ) + + """ + self._select_in_interval( ecl_kw , lower_limit , upper_limit) + + def deselect_in_range( self , ecl_kw , lower_limit , upper_limit): + """ + Deselect all cells where @ecl_kw is in the half-open interval [ , ). + + See select_in_range() for further documentation. + """ + self._deselect_in_interval( ecl_kw , lower_limit , upper_limit) + + + @select_method + def select_cmp_less( self , kw1 , kw2 , intersect = False): + """ + Will select all cells where kw2 < kw1. + + Will compare the ECLIPSE keywords @kw1 and @kw2, and select + all the cells where the numerical value of @kw1 is less than + the numerical value of @kw2. The ECLIPSE keywords @kw1 and + @kw2 must both be of the same size, nactive or nx*ny*nz. In + addition they must both be of type type ECL_FLOAT_TYPE. In the + example below we select all the cells where the pressure has + dropped: + + restart_file = ecl.EclFile("ECLIPSE.UNRST") + pressure1 = restart_file.iget_named_kw( "PRESSURE" , 0) + pressure2 = restart_file.iget_named_kw( "PRESSURE" , 100) + + region.select_cmp_less( pressure2 , pressure1) + + """ + self._select_cmp_less( kw1 , kw2 ) + + def deselect_cmp_less( self , kw1 , kw2): + """ + Will deselect all cells where kw2 < kw1. + + See select_cmp_less() for further documentation. + """ + self._deselect_cmp_less( kw1 , kw2 ) + + @select_method + def select_cmp_more( self , kw1 , kw2 , intersect = False): + """ + Will select all cells where kw2 > kw1. + + See select_cmp_less() for further documentation. + """ + self._select_cmp_more( kw1 , kw2 ) + + def deselect_cmp_more( self , kw1 , kw2): + """ + Will deselect all cells where kw2 > kw1. + + See select_cmp_less() for further documentation. + """ + self._deselect_cmp_more( kw1 , kw2 ) + + @select_method + def select_active( self , intersect = False): + """ + Will select all the active grid cells. + """ + self._select_active( ) + + def deselect_active( self ): + """ + Will deselect all the active grid cells. + """ + self._deselect_active( ) + + @select_method + def select_inactive( self , intersect = False): + """ + Will select all the inactive grid cells. + """ + self._select_inactive( ) + + + def deselect_inactive( self ): + """ + Will deselect all the inactive grid cells. + """ + self._deselect_inactive( ) + + + def select_all( self ): + """ + Will select all the cells. + """ + self._select_all( ) + + def deselect_all( self ): + """ + Will deselect all the cells. + """ + self._deselect_all( ) + + def clear( self ): + """ + Will deselect all cells. + """ + self.deselect_all() + + @select_method + def select_deep( self , depth , intersect = False): + """ + Will select all cells below @depth. + """ + self._select_deep_cells(depth) + + def deselect_deep( self, depth): + """ + Will deselect all cells below @depth. + """ + self._deselect_deep_cells(depth) + + @select_method + def select_shallow( self, depth , intersect = False): + """ + Will select all cells above @depth. + """ + self._select_shallow_cells(depth) + + def deselect_shallow( self, depth): + """ + Will deselect all cells above @depth. + """ + self._deselect_shallow_cells(depth) + + @select_method + def select_small( self , size_limit , intersect = False): + """ + Will select all cells smaller than @size_limit. + """ + self._select_small( size_limit ) + + def deselect_small( self , size_limit ): + """ + Will deselect all cells smaller than @size_limit. + """ + self._deselect_small( size_limit ) + + @select_method + def select_large( self , size_limit , intersect = False): + """ + Will select all cells larger than @size_limit. + """ + self._select_large( size_limit ) + + def deselect_large( self , size_limit ): + """ + Will deselect all cells larger than @size_limit. + """ + self._deselect_large( size_limit ) + + @select_method + def select_thin( self , size_limit , intersect = False): + """ + Will select all cells thinner than @size_limit. + """ + self._select_thin( size_limit ) + + def deselect_thin( self , size_limit ): + """ + Will deselect all cells thinner than @size_limit. + """ + self._deselect_thin( size_limit ) + + @select_method + def select_thick( self , size_limit , intersect = False): + """ + Will select all cells thicker than @size_limit. + """ + self._select_thick( size_limit ) + + def deselect_thick( self , size_limit ): + """ + Will deselect all cells thicker than @size_limit. + """ + self._deselect_thick( size_limit ) + + @select_method + def select_box( self , ijk1 , ijk2 , intersect = False): + """ + Will select all cells in box. + + Will select all the the cells in the box given by @ijk1 and + @ijk2. The two arguments @ijk1 and @ijk2 are tuples (1,j,k) + representing two arbitrary - diagonally opposed corners - of a + box. All the elements in @ijk1 and @ijk2 are inclusive, i.e. + + select_box( (10,12,8) , (8 , 16,4) ) + + will select the box defined by [8,10] x [12,16] x [4,8]. + """ + self._select_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2]) + + def deselect_box( self , ijk1 , ijk2 ): + """ + Will deselect all elements in box. + + See select_box() for further documentation. + """ + self._deselect_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2]) + + @select_method + def select_islice( self , i1 , i2, intersect = False): + """ + Will select all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset. + """ + self._select_islice( i1,i2) + + def deselect_islice( self , i1 , i2): + """ + Will deselect all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset. + """ + self._deselect_islice( i1,i2) + + @select_method + def select_jslice( self , j1 , j2 , intersect = False): + """ + Will select all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset. + """ + self._select_jslice( j1,j2) + + def deselect_jslice( self , j1 , j2): + """ + Will deselect all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset. + """ + self._deselect_jslice( j1,j2) + + @select_method + def select_kslice( self , k1 , k2 , intersect = False): + """ + Will select all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset. + """ + self._select_kslice( k1,k2) + + def deselect_kslice( self , k1 , k2): + """ + Will deselect all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset. + """ + self._deselect_kslice( k1,k2) + + def invert( self ): + """ + Will invert the current selection. + """ + self._invert_selection( ) + + def __init_plane_select( self , n , p ): + n_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double )) + p_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double )) + for i in range(3): + n_vec[i] = n[i] + p_vec[i] = p[i] + return ( n_vec , p_vec ) + + @select_method + def select_above_plane( self , n , p , intersect = False): + """ + Will select all the cells 'above' the plane defined by n & p. + + @n is the surface normal vector of the plane in question and + @p is a point on the plane surface. The point @p should be + given in (utm_x , utm_y , tvd) coordinates. The term 'above' + means that the cell center has a positive distance to the + plain; correspondingly 'below' means that the cell center has + a negative disatnce to the plane. + """ + (n_vec , p_vec) = self.__init_plane_select( n , p ) + self._select_above_plane( n_vec , p_vec ) + + @select_method + def select_below_plane( self , n , p , interscet = False): + """ + Will select all the cells 'below' the plane defined by n & p. + + See method 'select_above_plane' for further documentation. + """ + (n_vec , p_vec) = self.__init_plane_select( n , p ) + self._select_below_plane( n_vec , p_vec ) + + def deselect_above_plane( self , n , p): + """ + Will deselect all the cells 'above' the plane defined by n & p. + + See method 'select_above_plane' for further documentation. + """ + (n_vec , p_vec) = self.__init_plane_select( n , p ) + self._deselect_above_plane( n_vec , p_vec ) + + def deselect_below_plane( self , n , p): + """ + Will deselect all the cells 'below' the plane defined by n & p. + + See method 'select_above_plane' for further documentation. + """ + (n_vec , p_vec) = self.__init_plane_select( n , p ) + self._deselect_below_plane( n_vec , p_vec ) + + @select_method + def select_inside_polygon( self , points , intersect = False): + """ + Will select all points inside polygon. + + Will select all points inside polygon specified by input + variable @points. Points should be a list of two-element + tuples (x,y). So to select all the points within the rectangle + bounded by the lower left rectangle (0,0) and upper right + (100,100) the @points list should be: + + points = [(0,0) , (0,100) , (100,100) , (100,0)] + + The elements in the points list should be (utm_x, utm_y) + values. These values will be compared with the centerpoints of + the cells in the grid. The selection is based the top k=0 + layer, and then extending this selection to all k values; this + implies that the selection polygon will effectively be + translated if the pillars are not vertical. + """ + self._select_inside_polygon( CPolyline( init_points = points )) + + @select_method + def select_outside_polygon( self , points , intersect = False): + """ + Will select all points outside polygon. + + See select_inside_polygon for more docuemntation. + """ + self._select_outside_polygon( CPolyline( init_points = points )) + + def deselect_inside_polygon( self , points ): + """ + Will select all points outside polygon. + + See select_inside_polygon for more docuemntation. + """ + self._deselect_inside_polygon( CPolyline( init_points = points )) + + def deselect_outside_polygon( self , points ): + """ + Will select all points outside polygon. + + See select_inside_polygon for more docuemntation. + """ + self._deselect_outside_polygon( CPolyline( init_points = points )) + + + @select_method + def select_true( self , ecl_kw , intersect = False): + """ + Assume that input ecl_kw is a boolean mask. + """ + self._select_true( ecl_kw ) + + + @select_method + def select_false( self , ecl_kw , intersect = False): + """ + Assume that input ecl_kw is a boolean mask. + """ + self._select_false( ecl_kw ) + + + @select_method + def select_from_layer(self , layer , k , value, intersect = False): + """Will select all the cells in in @layer with value @value - at + vertical coordinate @k. + + The input @layer should be of type Layer - from the + ecl.ecl.faults.layer module. The k value must in the range + [0,grid.nz) and the dimensions of the layer must correspond + exactly to nx,ny of the grid. + """ + grid = self.grid + if k < 0 or k >= grid.getNZ(): + raise ValueError("Invalid k value:%d - must be in range [0,%d)" % (k , grid.getNZ())) + + if grid.getNX() != layer.getNX(): + raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX() , layer.getNX())) + + if grid.getNY() != layer.getNY(): + raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY() , layer.getNY())) + + self._select_from_layer( layer , k , value ) + + + + ################################################################# + + def scalar_apply_kw( self , target_kw , scalar , func_dict , force_active = False): + + """ + Helper function to apply a function with one scalar arg on target_kw. + """ + data_type = target_kw.data_type + if data_type in func_dict: + func = func_dict[ data_type ] + func( target_kw, scalar , force_active ) + else: + raise Exception("scalar_apply_kw() only supported for INT/FLOAT/DOUBLE") + + def iadd_kw( self , target_kw , delta_kw , force_active = False): + """ + The functions iadd_kw(), copy_kw(), set_kw(), scale_kw() and + shift_kw() are not meant to be used as methods of the + EclRegion class (altough that is of course perfectly OK) - + rather a EclRegion instance is passed as an argument to an + EclKW method, and then that method "flips things around" and + calls one of these methods with the EclKW instance as + argument. This applies to all the EclKW methods which take an + optional "mask" argument. + """ + if isinstance(delta_kw , EclKW): + if target_kw.assert_binary( delta_kw ): + self._iadd_kw( target_kw , delta_kw , force_active ) + else: + raise TypeError("Type mismatch") + else: + self.shift_kw( target_kw , delta_kw , force_active = force_active) + + + def shift_kw( self , ecl_kw , shift , force_active = False): + """ + See usage documentation on iadd_kw(). + """ + self.scalar_apply_kw( ecl_kw , shift , {EclDataType.ECL_INT : self._shift_kw_int, + EclDataType.ECL_FLOAT : self._shift_kw_float , + EclDataType.ECL_DOUBLE : self._shift_kw_double} , force_active) + + def isub_kw( self , target_kw , delta_kw , force_active = False): + if isinstance(delta_kw , EclKW): + if target_kw.assert_binary( delta_kw ): + self._isub_kw( target_kw , delta_kw , force_active ) + else: + raise TypeError("Type mismatch") + else: + self.shift_kw( target_kw , -delta_kw , force_active = force_active) + + + def scale_kw( self , ecl_kw , scale , force_active = False): + """ + See usage documentation on iadd_kw(). + """ + self.scalar_apply_kw( ecl_kw , scale , {EclDataType.ECL_INT : self._scale_kw_int, + EclDataType.ECL_FLOAT : self._scale_kw_float , + EclDataType.ECL_DOUBLE : self._scale_kw_double} , force_active) + + def imul_kw(self, target_kw , other , force_active = False): + if isinstance(other , EclKW): + if target_kw.assert_binary( other): + self._imul_kw( target_kw , other ) + else: + raise TypeError("Type mismatch") + else: + self.scale_kw( target_kw , other , force_active ) + + + def idiv_kw( self , target_kw , other , force_active = False): + if isinstance(other , EclKW): + if target_kw.assert_binary( other): + self._idiv_kw( target_kw , other ) + else: + raise TypeError("Type mismatch") + else: + if target_kw.data_type.is_int(): + scale = 1 // other + else: + scale = 1.0 / other + self.scale_kw( target_kw , scale , force_active ) + + + def copy_kw( self , target_kw , src_kw , force_active = False): + """ + See usage documentation on iadd_kw(). + """ + if target_kw.assert_binary( src_kw ): + self._copy_kw( target_kw , src_kw , force_active ) + else: + raise TypeError("Type mismatch") + + def set_kw( self , ecl_kw , value , force_active = False): + """ + See usage documentation on iadd_kw(). + """ + self.scalar_apply_kw( ecl_kw , value , {EclDataType.ECL_INT : self._set_kw_int, + EclDataType.ECL_FLOAT : self._set_kw_float , + EclDataType.ECL_DOUBLE : self._set_kw_double} , force_active) + + + def sum_kw(self, kw, force_active = False): + data_type = kw.data_type + if data_type == EclDataType.ECL_FLOAT: + return self._sum_kw_float( kw, force_active ) + + if data_type == EclDataType.ECL_INT: + return self._sum_kw_int( kw, force_active ) + + if data_type == EclDataType.ECL_DOUBLE: + return self._sum_kw_double( kw, force_active ) + + if data_type == EclDataType.ECL_BOOL: + return self._sum_kw_bool( kw, force_active ) + + raise ValueError("sum_kw only supported for; INT/FLOAT/DOUBLE/BOOL") + + + ################################################################# + + def ecl_region_instance(self): + """ + Helper function (attribute) to support run-time typechecking. + """ + return True + + + def active_size(self): + return len(self._get_active_list()) + + + def global_size(self): + return len(self._get_global_list()) + + + def get_active_list(self): + """ + IntVector instance with active indices in the region. + """ + active_list = self._get_active_list() + active_list.setParent(self) + return active_list + + + def get_global_list(self): + """ + IntVector instance with global indices in the region. + """ + global_list = self._get_global_list() + global_list.setParent(self) + return global_list + + + def get_ijk_list(self): + """ + WIll return a Python list of (ij,k) tuples for the region. + """ + global_list = self.getGlobalList() + ijk_list = [] + for g in global_list: + ijk_list.append( self.grid.get_ijk( global_index = g ) ) + + return ijk_list + + def contains_ijk( self , i,j,k): + """ + Will check if the cell given by i,j,k is part of the region. + """ + return self._contains_ijk( i , j , k ) + + + def contains_global( self , global_index): + """ + Will check if the cell given by @global_index is part of the region. + """ + return self._contains_global( global_index ) + + + def contains_active( self , active_index): + """ + Will check if the cell given by @active_index is part of the region. + """ + return self._contains_active( active_index ) + + + def kw_index_list(self , ecl_kw , force_active): + c_ptr = self._get_kw_index_list( ecl_kw , force_active) + index_list = IntVector.createCReference( c_ptr, self ) + return index_list + + @property + def name(self): + return self._get_name() + + def get_name(self): + return self._get_name( ) + + def set_name(self , name): + self._set_name( name ) + +monkey_the_camel(EclRegion, 'selectTrue', EclRegion.select_true) +monkey_the_camel(EclRegion, 'selectFalse', EclRegion.select_false) +monkey_the_camel(EclRegion, 'selectFromLayer', EclRegion.select_from_layer) +monkey_the_camel(EclRegion, 'getActiveList', EclRegion.get_active_list) +monkey_the_camel(EclRegion, 'getGlobalList', EclRegion.get_global_list) +monkey_the_camel(EclRegion, 'getIJKList', EclRegion.get_ijk_list) +monkey_the_camel(EclRegion, 'getName', EclRegion.get_name) +monkey_the_camel(EclRegion, 'setName', EclRegion.set_name) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt b/ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt new file mode 100644 index 0000000000..2e23b67b90 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt @@ -0,0 +1,12 @@ +set(PYTHON_SOURCES + __init__.py + fault_block.py + fault_block_layer.py + fault_collection.py + fault.py + fault_line.py + fault_segments.py + layer.py +) + +add_python_package("python.ecl.grid.faults" ${PYTHON_INSTALL_PREFIX}/ecl/grid/faults "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/__init__.py b/ThirdParty/Ert/python/ecl/grid/faults/__init__.py new file mode 100644 index 0000000000..996cbd86c5 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/__init__.py @@ -0,0 +1,9 @@ + + +from .layer import Layer +from .fault_collection import FaultCollection +from .fault import Fault +from .fault_line import FaultLine +from .fault_segments import FaultSegment , SegmentMap +from .fault_block import FaultBlock , FaultBlockCell +from .fault_block_layer import FaultBlockLayer diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault.py b/ThirdParty/Ert/python/ecl/grid/faults/fault.py new file mode 100644 index 0000000000..ac5ef42acb --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault.py @@ -0,0 +1,656 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import numpy as np + +from ecl.util.util import monkey_the_camel +from ecl.util.geometry import Polyline, CPolyline, GeometryTools + +from .fault_line import FaultLine +from .fault_segments import FaultSegment, SegmentMap + + +class FaultLayer(object): + def __init__(self, grid, K): + assert(isinstance(K, int)) + self.__grid = grid + self.__K = K + self.__fault_lines = [] + self.__segment_map = SegmentMap() + self.__processed = False + + + def add_segment(self, segment): + self.__segment_map.addSegment(segment) + self.__processed = False + + def __len__(self): + self.processSegments() + return len(self.__fault_lines) + + def __iter__(self): + self.processSegments() + return iter(self.__fault_lines) + + def __getitem__(self, index): + self.processSegments() + return self.__fault_lines[index] + + def get_k(self): + return self.__K + + @property + def k(self): + return self.__K + + + def get_neighbor_cells(self): + neighbor_cells = [] + for fl in self: + neighbor_cells += fl.getNeighborCells() + return neighbor_cells + + def get_polyline(self, name=None): + polyline = CPolyline(name=name) + for fl in self: + polyline += fl.getPolyline() + return polyline + + + def get_ij_polyline(self): + """ + Will return a python list of (int,int) tuple. + """ + polyline = [] + for fl in self: + polyline += fl.getIJPolyline() + return polyline + + + def num_lines(self): + return len(self) + + def __sort_fault_lines(self): + """A fault can typically consist of several non connected fault + segments; right after reading the fault input these can be in + a complete mess: + + 1. The different part of the fault can be in random order. + + 2. Within each fault line the micro segments can be ordered in + reverse. + + This method goes through some desparate heuristics trying to sort + things out. + + """ + + N = len(self.__fault_lines) + x = np.zeros(N) + y = np.zeros(N) + for index,line in enumerate(self.__fault_lines): + xc,yc = line.center() + x[index] = xc + y[index] = yc + + + + + + # y = beta[1] + beta[0] * x + # = a + b * x + beta = np.polyfit(x, y, 1) + a = beta[1] + b = beta[0] + + perm_list = [] + for index,line in enumerate(self.__fault_lines): + x0, y0 = line.center() + d = x0 + b*(y0 - a) + perm_list.append((index, d)) + perm_list.sort(key=lambda x: x[1]) + + fault_lines = [] + for (index,d) in perm_list: + fault_lines.append(self.__fault_lines[ index ]) + self.__fault_lines = fault_lines + + + for line in self.__fault_lines: + x1,y1 = line.startPoint() + x2,y2 = line.endPoint() + d1 = x1 + b*(y1 - a) + d2 = x2 + b*(y2 - a) + + if d1 > d2: + line.reverse() + + + + + def process_segments(self): + if self.__processed: + return + + while self.__segment_map: + fault_line = FaultLine(self.__grid, self.__K) + self.__fault_lines.append(fault_line) + + current_segment = self.__segment_map.popStart() + while current_segment: + append = fault_line.tryAppend(current_segment) + if not append: + fault_line = FaultLine(self.__grid, self.__K) + self.__fault_lines.append(fault_line) + fault_line.tryAppend(current_segment) + + current_segment.next_segment = self.__segment_map.popNext(current_segment) + current_segment = current_segment.next_segment + + if len(self.__fault_lines) > 1: + self.__sort_fault_lines() + + self.__processed = True + + +################################################################# + + +class Fault(object): + allowed_faces = ["X","Y","Z","I","J","K","X-","Y-","Z-","I-","J-","K-"] + + def __init__(self, grid, name): + self.__grid = grid + self.__name = name + self.__layer_map = {} + self.__layer_list = [] + (self.nx, self.ny, self.nz, nactive) = grid.getDims() + + + def __str__(self): + return "Fault:%s" % self.__name + + def __getitem__(self, K): + if not self.hasLayer(K): + self.addLayer(K) + layer = self.__layer_map[K] + return layer + + def __len__(self): + return len(self.__layer_map) + + + def __iter__(self): + for layer in self.__layer_list: + yield layer + + + def has_layer(self, K): + return K in self.__layer_map + + + def add_layer(self, K): + layer = FaultLayer(self.__grid, K) + self.__layer_map[K] = layer + self.__layer_list.append(layer) + + + def create_segment(self, I1, I2, J1, J2, face): + if face in ["X", "I"]: + C1 = I1 + 1 + J1*(self.nx + 1) + C2 = C1 + (1 + J2 - J1) * (self.nx + 1) + elif face in ["X-", "I-"]: + C1 = I1 + J1*(self.nx + 1) + C2 = C1 + (1 + J2 - J1) * (self.nx + 1) + elif face in ["Y", "J"]: + C1 = I1 + (J1 + 1) * (self.nx + 1) + C2 = C1 + (1 + I2 - I1) + elif face in ["Y-", "J-"]: + C1 = I1 + J1 * (self.nx + 1) + C2 = C1 + (1 + I2 - I1) + else: + return None + + return FaultSegment(C1,C2) + + + + def add_record(self, I1, I2, J1, J2, K1, K2, face): + if not face in Fault.allowed_faces: + raise ValueError("Invalid face:%s" % face) + + if I1 > I2: + raise ValueError("Invalid I1 I2 indices") + + if J1 > J2: + raise ValueError("Invalid J1 J2 indices") + + if K1 > K2: + raise ValueError("Invalid K1 K2 indices") + + if I1 < 0 or I1 >= self.nx: + raise ValueError("Invalid I1:%d" % I1) + if I2 < 0 or I2 >= self.nx: + raise ValueError("Invalid I2:%d" % I2) + + if J1 < 0 or J1 >= self.ny: + raise ValueError("Invalid J1:%d" % J1) + if J2 < 0 or J2 >= self.ny: + raise ValueError("Invalid J2:%d" % J2) + + if K1 < 0 or K1 >= self.nz: + raise ValueError("Invalid K1:%d" % K1) + if K2 < 0 or K2 >= self.nz: + raise ValueError("Invalid K2:%d" % K2) + + if face in ["X","I"]: + if I1 != I2: + raise ValueError("For face:%s we must have I1 == I2" % face) + + if face in ["Y","J"]: + if J1 != J2: + raise ValueError("For face:%s we must have J1 == J2" % face) + + if face in ["Z","K"]: + if K1 != K2: + raise ValueError("For face:%s we must have K1 == K2" % face) + + #----------------------------------------------------------------- + + for K in range(K1,K2+1): + if not self.hasLayer(K): + self.addLayer(K) + layer = self.__layer_map[K] + segment = self.createSegment(I1,I2,J1,J2,face) + if segment: + layer.addSegment(segment) + + + + @property + def name(self): + return self.__name + + def get_name(self): + return self.__name + + + def get_neighbor_cells(self): + neighbor_cells = [] + for layer in self: + neighbor_cells += layer.getNeighborCells() + return neighbor_cells + + + def get_polyline(self, k): + layer = self[k] + return layer.getPolyline(name="Polyline[%s]" % self.getName()) + + + def get_ij_polyline(self, k): + layer = self[k] + return layer.getIJPolyline() + + + def num_lines(self, k): + layer = self[k] + return layer.numLines() + + + @staticmethod + def __ray_intersect(p0, p1, polyline): + ray_dir = GeometryTools.lineToRay(p0, p1) + intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, polyline) + if intersections: + if len(intersections) > 1: + d_list = [ GeometryTools.distance(p1, p[1]) for p in intersections ] + index = d_list.index(min(d_list)) + else: + index = 0 + p2 = intersections[index][1] + return [p1, p2] + else: + return None + + + def connect_with_polyline(self, polyline, k): + """ + """ + if self.intersectsPolyline(polyline, k): + return None + else: + self_polyline = self.getPolyline(k) + if len(self_polyline) > 0: + return self_polyline.connect(polyline) + else: + return None + + + def connect(self, target, k): + if isinstance(target, Fault): + polyline = target.getPolyline(k) + else: + polyline = target + return self.connectWithPolyline(polyline, k) + + + + def extend_to_polyline(self, polyline, k): + """Extends the fault until it intersects @polyline in layer @k. + + The return value is a list [(x1,y1), (x2,y2)] where (x1,y1) + is on the tip of the fault, and (x2,y2) is on the polyline. If + the fault already intersects polyline None is returned, if no + intersection is found a ValueError exception is raised. + + The method will try four different strategies for finding an + intersection between the extension of the fault and the + polyline. Assume the fault and the polyline looks like: + + + Polyline: ---------------------------------------------- + + +------------+ D + | | | + | +-------C + B-----+ + | + A + + The algorithm will then try to intersect the following rays + with the polyline, the first match will return: + + 1. (Pc, Pd) + 2. (Pb, Pa) + 3. (Pa, Pd) + 4. (Pd, Pa) + + The fault object is not directed in any way; i.e. in the case + both (Pc,Pd) and (Pb,Pa) intersects the polyline it is + impossible to know which intersection is returned, without + actually consulting the construction of the fault object. + """ + if self.intersectsPolyline(polyline, k): + return None + + fault_polyline = self.getPolyline(k) + p0 = fault_polyline[-2] + p1 = fault_polyline[-1] + extension = self.__ray_intersect(p0, p1, polyline) + if extension: + return extension + + p0 = fault_polyline[1] + p1 = fault_polyline[0] + extension = self.__ray_intersect(p0, p1, polyline) + if extension: + return extension + + p0 = fault_polyline[0] + p1 = fault_polyline[-1] + extension = self.__ray_intersect(p0, p1, polyline) + if extension: + return extension + + p0 = fault_polyline[-1] + p1 = fault_polyline[0] + extension = self.__ray_intersect(p0, p1, polyline) + if extension: + return extension + + raise ValueError("The fault %s can not be extended to intersect with polyline:%s in layer:%d" % (self.getName(), polyline.getName(), k+1)) + + + + def intersects_polyline(self, polyline, k): + fault_line = self.getPolyline(k) + return fault_line.intersects(polyline) + + + def intersects_fault(self, other_fault, k): + fault_line = other_fault.getPolyline(k) + return self.intersectsPolyline(fault_line, k) + + def extend_to_fault(self, fault, k): + fault_line = fault.getPolyline(k) + return self.extendToPolyline(fault_line, k) + + def extend_to_edge(self, edge, k): + if isinstance(edge, Fault): + return self.extendToFault(edge, k) + else: + return self.extendToPolyline(edge, k) + + + def extend_to_b_box(self, bbox, k, start=True): + fault_polyline = self.getPolyline(k) + if start: + p0 = fault_polyline[1] + p1 = fault_polyline[0] + else: + p0 = fault_polyline[-2] + p1 = fault_polyline[-1] + + ray_dir = GeometryTools.lineToRay(p0,p1) + intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, bbox) + if intersections: + p2 = intersections[0][1] + if self.getName(): + name = "Extend:%s" % self.getName() + else: + name = None + + return CPolyline(name=name, init_points=[(p1[0], p1[1]), p2]) + else: + raise Exception("Logical error - must intersect with bounding box") + + + def end_join(self, other, k): + fault_polyline = self.getPolyline(k) + + if isinstance(other, Fault): + other_polyline = other.getPolyline(k) + else: + other_polyline = other + + return GeometryTools.joinPolylines(fault_polyline, other_polyline) + + + + def connect_polyline_onto(self, polyline, k): + if self.intersectsPolyline(polyline, k): + return None + + self_polyline = self.getPolyline(k) + return polyline.connect(self_polyline) + + + + def extend_polyline_onto(self, polyline, k): + if self.intersectsPolyline(polyline, k): + return None + + if len(polyline) > 1: + fault_polyline = self.getPolyline(k) + ext1 = self.__ray_intersect(polyline[-2], polyline[-1], fault_polyline) + ext2 = self.__ray_intersect(polyline[0] , polyline[1] , fault_polyline) + + if ext1 and ext2: + d1 = GeometryTools.distance(ext1[0], ext1[1]) + d2 = GeometryTools.distance(ext2[0], ext2[1]) + + if d1 < d2: + return ext1 + else: + return ext2 + + if ext1: + return ext1 + else: + return ext2 + else: + raise ValueError("Polyline must have length >= 2") + + + + @staticmethod + def intersect_fault_rays(ray1, ray2): + p1,dir1 = ray1 + p2,dir2 = ray2 + if p1 == p2: + return [] + + dx = p2[0] - p1[0] + dy = p2[1] - p1[1] + if dx != 0: + if dir1[0] * dx <= 0 and dir2[0] * dx >= 0: + raise ValueError("Rays will never intersect") + + if dy != 0: + if dir1[1] * dy <= 0 and dir2[1] * dy >= 0: + raise ValueError("Rays will never intersect") + + if dx*dy != 0: + if dir1[0] != 0: + xc = p2[0] + yc = p1[1] + else: + xc = p1[0] + yc = p2[1] + + coord_list = [p1, (xc,yc), p2] + else: + coord_list = [p1,p2] + + return coord_list + + + @staticmethod + def int_ray(p1,p2): + if p1 == p2: + raise Exception("Can not form ray from coincident points") + + if p1[0] == p2[0]: + # Vertical line + dx = 0 + if p2[1] > p1[1]: + dy = 1 + elif p2[1] < p1[1]: + dy = -1 + else: + # Horizontal line + if p2[1] != p1[1]: + raise Exception("Invalid direction") + + dy = 0 + if p2[0] > p1[0]: + dx = 1 + else: + dx = -1 + + return [p2, (dx,dy)] + + + + def get_end_rays(self, k): + polyline = self.getIJPolyline(k) + + p0 = polyline[0] + p1 = polyline[1] + p2 = polyline[-2] + p3 = polyline[-1] + + return (Fault.intRay(p1,p0), Fault.intRay(p2,p3)) + + + + + @staticmethod + def join_faults(fault1, fault2, k): + fault1_rays = fault1.getEndRays(k) + fault2_rays = fault2.getEndRays(k) + + if fault1.intersectsFault(fault2, k): + return None + + count = 0 + join = None + try: + join = Fault.intersectFaultRays(fault1_rays[0], fault2_rays[0]) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays(fault1_rays[0], fault2_rays[1]) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays(fault1_rays[1], fault2_rays[0]) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays(fault1_rays[1], fault2_rays[1]) + count += 1 + except ValueError: + pass + + if count == 1: + xy_list = [] + for ij in join: + xyz = fault1.__grid.getNodeXYZ(ij[0], ij[1], k) + xy_list.append((xyz[0], xyz[1])) + + return xy_list + else: + return fault1.endJoin(fault2, k) + + +monkey_the_camel(FaultLayer, 'addSegment', FaultLayer.add_segment) +monkey_the_camel(FaultLayer, 'getK', FaultLayer.get_k) +monkey_the_camel(FaultLayer, 'getNeighborCells', FaultLayer.get_neighbor_cells) +monkey_the_camel(FaultLayer, 'getPolyline', FaultLayer.get_polyline) +monkey_the_camel(FaultLayer, 'getIJPolyline', FaultLayer.get_ij_polyline) +monkey_the_camel(FaultLayer, 'numLines', FaultLayer.num_lines) +monkey_the_camel(FaultLayer, 'processSegments', FaultLayer.process_segments) + +monkey_the_camel(Fault, 'hasLayer', Fault.has_layer) +monkey_the_camel(Fault, 'addLayer', Fault.add_layer) +monkey_the_camel(Fault, 'createSegment', Fault.create_segment) +monkey_the_camel(Fault, 'addRecord', Fault.add_record) +monkey_the_camel(Fault, 'getName', Fault.get_name) +monkey_the_camel(Fault, 'getNeighborCells', Fault.get_neighbor_cells) +monkey_the_camel(Fault, 'getPolyline', Fault.get_polyline) +monkey_the_camel(Fault, 'getIJPolyline', Fault.get_ij_polyline) +monkey_the_camel(Fault, 'numLines', Fault.num_lines) +monkey_the_camel(Fault, 'connectWithPolyline', Fault.connect_with_polyline) +monkey_the_camel(Fault, 'extendToPolyline', Fault.extend_to_polyline) +monkey_the_camel(Fault, 'intersectsPolyline', Fault.intersects_polyline) +monkey_the_camel(Fault, 'intersectsFault', Fault.intersects_fault) +monkey_the_camel(Fault, 'extendToFault', Fault.extend_to_fault) +monkey_the_camel(Fault, 'extendToEdge', Fault.extend_to_edge) +monkey_the_camel(Fault, 'extendToBBox', Fault.extend_to_b_box) +monkey_the_camel(Fault, 'endJoin', Fault.end_join) +monkey_the_camel(Fault, 'connectPolylineOnto', Fault.connect_polyline_onto) +monkey_the_camel(Fault, 'extendPolylineOnto', Fault.extend_polyline_onto) +monkey_the_camel(Fault, 'intersectFaultRays', Fault.intersect_fault_rays, staticmethod) +monkey_the_camel(Fault, 'intRay', Fault.int_ray, staticmethod) +monkey_the_camel(Fault, 'getEndRays', Fault.get_end_rays) +monkey_the_camel(Fault, 'joinFaults', Fault.join_faults, staticmethod) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py new file mode 100644 index 0000000000..e5313170a7 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py @@ -0,0 +1,190 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault_block.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from cwrap import BaseCClass + +from ecl.util.util import monkey_the_camel +from ecl.util.util import DoubleVector, IntVector +from ecl import EclPrototype +from ecl.util.geometry import Polyline, GeometryTools, CPolylineCollection + +class FaultBlockCell(object): + + def __init__(self, i, j, k, x, y, z): + self.i = i + self.j = j + self.k = k + + self.x = x + self.y = y + self.z = z + + + def __str__(self): + return "(%d,%d)" % (self.i, self.j) + + + +class FaultBlock(BaseCClass): + TYPE_NAME = "fault_block" + + _get_xc = EclPrototype("double fault_block_get_xc(fault_block)") + _get_yc = EclPrototype("double fault_block_get_yc(fault_block)") + _get_block_id = EclPrototype("int fault_block_get_id(fault_block)") + _get_size = EclPrototype("int fault_block_get_size(fault_block)") + _export_cell = EclPrototype("void fault_block_export_cell(fault_block, int, int*, int*, int*, double*, double*, double*)") + _assign_to_region = EclPrototype("void fault_block_assign_to_region(fault_block, int)") + _get_region_list = EclPrototype("int_vector_ref fault_block_get_region_list(fault_block)") + _add_cell = EclPrototype("void fault_block_add_cell(fault_block, int, int)") + _get_global_index_list = EclPrototype("int_vector_ref fault_block_get_global_index_list(fault_block)") + _trace_edge = EclPrototype("void fault_block_trace_edge(fault_block, double_vector, double_vector, int_vector)") + _get_neighbours = EclPrototype("void fault_block_list_neighbours(fault_block, bool, geo_polygon_collection, int_vector)") + _free = EclPrototype("void fault_block_free__(fault_block)") + + + def __init__(self, *args, **kwargs): + raise NotImplementedError("Class can not be instantiated directly!") + + + def __getitem__(self, index): + if isinstance(index, int): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + x = ctypes.c_double() + y = ctypes.c_double() + z = ctypes.c_double() + + i = ctypes.c_int() + j = ctypes.c_int() + k = ctypes.c_int() + + self._export_cell(index, + ctypes.byref(i), ctypes.byref(j), ctypes.byref(k), + ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) + return FaultBlockCell(i.value, j.value, k.value, x.value, y.value, z.value) + else: + raise IndexError("Index:%d out of range: [0,%d)" % (index, len(self))) + else: + raise TypeError("Index:%s wrong type - integer expected") + + def __str__(self): + return "Block ID: %d" % self.getBlockID() + + + def __len__(self): + return self._get_size() + + def free(self): + self._free() + + def get_centroid(self): + xc = self._get_xc() + yc = self._get_yc() + return (xc,yc) + + + def count_inside(self, polygon): + """ + Will count the number of points in block which are inside polygon. + """ + inside = 0 + for p in self: + if GeometryTools.pointInPolygon((p.x, p.y), polygon): + inside += 1 + + return inside + + + def get_block_id(self): + return self._get_block_id() + + + def assign_to_region(self, region_id): + self._assign_to_region(region_id) + + + def get_region_list(self): + regionList = self._get_region_list() + return regionList.copy() + + def add_cell(self, i, j): + self._add_cell(i, j) + + def get_global_index_list(self): + return self._get_global_index_list() + + + def get_edge_polygon(self): + x_list = DoubleVector() + y_list = DoubleVector() + cell_list = IntVector() + + self._trace_edge(x_list, y_list, cell_list) + p = Polyline() + for (x,y) in zip(x_list, y_list): + p.addPoint(x,y) + return p + + + def contains_polyline(self, polyline): + """ + Will return true if at least one point from the polyline is inside the block. + """ + edge_polyline = self.getEdgePolygon() + for p in polyline: + if GeometryTools.pointInPolygon(p, edge_polyline): + return True + else: + edge_polyline.assertClosed() + return GeometryTools.polylinesIntersect(edge_polyline, polyline) + + + def get_neighbours(self, polylines=None, connected_only=True): + """ + Will return a list of FaultBlock instances which are in direct + contact with this block. + """ + neighbour_id_list = IntVector() + if polylines is None: + polylines = CPolylineCollection() + + self._get_neighbours(connected_only, polylines, neighbour_id_list) + + parent_layer = self.getParentLayer() + neighbour_list = [] + for id in neighbour_id_list: + neighbour_list.append(parent_layer.getBlock(id)) + return neighbour_list + + + def get_parent_layer(self): + return self.parent() + + +monkey_the_camel(FaultBlock, 'getCentroid', FaultBlock.get_centroid) +monkey_the_camel(FaultBlock, 'countInside', FaultBlock.count_inside) +monkey_the_camel(FaultBlock, 'getBlockID', FaultBlock.get_block_id) +monkey_the_camel(FaultBlock, 'assignToRegion', FaultBlock.assign_to_region) +monkey_the_camel(FaultBlock, 'getRegionList', FaultBlock.get_region_list) +monkey_the_camel(FaultBlock, 'addCell', FaultBlock.add_cell) +monkey_the_camel(FaultBlock, 'getGlobalIndexList', FaultBlock.get_global_index_list) +monkey_the_camel(FaultBlock, 'getEdgePolygon', FaultBlock.get_edge_polygon) +monkey_the_camel(FaultBlock, 'containsPolyline', FaultBlock.contains_polyline) +monkey_the_camel(FaultBlock, 'getNeighbours', FaultBlock.get_neighbours) +monkey_the_camel(FaultBlock, 'getParentLayer', FaultBlock.get_parent_layer) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py new file mode 100644 index 0000000000..16166c3ea6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py @@ -0,0 +1,84 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault_block_collection.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +from cwrap import BaseCClass + +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype + + +class FaultBlockCollection(BaseCClass): + TYPE_NAME = "fault_block_collection" + _alloc = EclPrototype("void* fault_block_collection_alloc(ecl_grid)", bind=False) + _free = EclPrototype("void fault_block_collection_free(fault_block_collection)") + _num_layers = EclPrototype("int fault_block_collection_num_layers(fault_block_collection)") + _scan_keyword = EclPrototype("bool fault_block_collection_scan_kw(fault_block_collection, ecl_kw)") + _get_layer = EclPrototype("fault_block_layer_ref fault_block_collection_get_layer(fault_block_collection, int)") + + def __init__(self, grid): + c_ptr = self._alloc(grid) + if c_ptr: + super(FaultBlockCollection, self).__init__(c_ptr) + else: + raise ValueError("Invalid input - failed to create FaultBlockCollection") + + # The underlying C implementation uses lazy evaluation and + # needs to hold on to the grid reference. We therefore take + # references to it here, to protect against premature garbage + # collection. + self.grid_ref = grid + + + def __len__(self): + return self._num_layers() + + + def __repr__(self): + return self._create_repr('len=%s' % len(self)) + + + def __getitem__(self, index): + """ + @rtype: FaultBlockLayer + """ + if isinstance(index, int): + if 0 <= index < len(self): + return self._get_layer(index).setParent(self) + else: + raise IndexError("Index:%d out of range [0,%d)" % (index, len(self))) + else: + raise TypeError("Index should be integer type") + + + def get_layer(self, k): + """ + @rtype: FaultBlockLayer + """ + return self[k] + + def free(self): + self._free() + + + def scan_keyword(self, fault_block_kw): + ok = self._scan_keyword(fault_block_kw) + if not ok: + raise ValueError("The fault block keyword had wrong type/size") + + +monkey_the_camel(FaultBlockCollection, 'getLayer', FaultBlockCollection.get_layer) +monkey_the_camel(FaultBlockCollection, 'scanKeyword', FaultBlockCollection.scan_keyword) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py new file mode 100644 index 0000000000..cc84d65981 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py @@ -0,0 +1,236 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault_block_layer.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import print_function +from cwrap import BaseCClass + +from ecl.util.util import monkey_the_camel +from ecl import EclDataType +from ecl import EclPrototype +from ecl.grid.faults import Fault + +class FaultBlockLayer(BaseCClass): + TYPE_NAME = "fault_block_layer" + _alloc = EclPrototype("void* fault_block_layer_alloc(ecl_grid, int)", bind = False) + _free = EclPrototype("void fault_block_layer_free(fault_block_layer)") + _size = EclPrototype("int fault_block_layer_get_size(fault_block_layer)") + _iget_block = EclPrototype("fault_block_ref fault_block_layer_iget_block(fault_block_layer, int)") + _add_block = EclPrototype("fault_block_ref fault_block_layer_add_block(fault_block_layer, int)") + _get_block = EclPrototype("fault_block_ref fault_block_layer_get_block(fault_block_layer, int)") + _del_block = EclPrototype("void fault_block_layer_del_block(fault_block_layer, int)") + _has_block = EclPrototype("bool fault_block_layer_has_block(fault_block_layer, int)") + _scan_keyword = EclPrototype("bool fault_block_layer_scan_kw(fault_block_layer, ecl_kw)") + _load_keyword = EclPrototype("bool fault_block_layer_load_kw(fault_block_layer, ecl_kw)") + _getK = EclPrototype("int fault_block_layer_get_k(fault_block_layer)") + _get_next_id = EclPrototype("int fault_block_layer_get_next_id(fault_block_layer)") + _scan_layer = EclPrototype("void fault_block_layer_scan_layer(fault_block_layer, layer)") + _insert_block_content = EclPrototype("void fault_block_layer_insert_block_content(fault_block_layer, fault_block)") + _export_kw = EclPrototype("bool fault_block_layer_export(fault_block_layer, ecl_kw)") + _get_layer = EclPrototype("layer_ref fault_block_layer_get_layer(fault_block_layer)") + + + def __init__(self, grid, k): + c_ptr = self._alloc(grid, k) + if c_ptr: + super(FaultBlockLayer, self).__init__(c_ptr) + else: + raise ValueError("Invalid input - failed to create FaultBlockLayer") + + # The underlying C implementation uses lazy evaluation and + # needs to hold on to the grid reference. We therefore take + # references to it here, to protect against premature garbage + # collection. + self.grid_ref = grid + + + def __len__(self): + return self._size() + + + def __repr__(self): + return self._create_repr('size=%d, k=%d' % (len(self), self.get_k())) + + def __getitem__(self, index): + """ + @rtype: FaultBlock + """ + if isinstance(index, int): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + return self._iget_block(index).setParent(self) + else: + raise IndexError("Index:%d out of range: [0,%d)" % (index, len(self))) + elif isinstance(index,tuple): + i,j = index + if 0 <= i < self.grid_ref.getNX() and 0 <= j < self.grid_ref.getNY(): + geo_layer = self.getGeoLayer() + block_id = geo_layer[i,j] + if block_id == 0: + raise ValueError("No fault block defined for location (%d,%d)" % (i,j)) + else: + return self.getBlock(block_id) + else: + raise IndexError("Invalid i,j : (%d,%d)" % (i,j)) + else: + raise TypeError("Index should be integer type") + + def __contains__(self, block_id): + return self._has_block(block_id) + + + def scan_keyword(self, fault_block_kw): + """ + Will reorder the block ids, and ensure single connectedness. Assign block_id to zero blocks. + """ + ok = self._scan_keyword(fault_block_kw) + if not ok: + raise ValueError("The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d" % (fault_block_kw.type_name, len(fault_block_kw), self.grid_ref.getGlobalSize())) + + + def load_keyword(self, fault_block_kw): + """ + Will load directly from keyword - without reorder; ignoring zero. + """ + ok = self._load_keyword(fault_block_kw) + if not ok: + raise ValueError("The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d" % (fault_block_kw.typeName(), len(fault_block_kw), self.grid_ref.getGlobalSize())) + + + def get_block(self, block_id): + """ + @rtype: FaultBlock + """ + if block_id in self: + return self._get_block(block_id).setParent(self) + else: + raise KeyError("No blocks with ID:%d in this layer" % block_id) + + + def delete_block(self, block_id): + if block_id in self: + self._del_block(block_id) + else: + raise KeyError("No blocks with ID:%d in this layer" % block_id) + + def add_block(self, block_id=None): + if block_id is None: + block_id = self.getNextID() + + if block_id in self: + raise KeyError("Layer already contains block with ID:%s" % block_id) + else: + return self._add_block(block_id).setParent(self) + + def get_next_id(self): + return self._get_next_id() + + + def get_k(self): + return self._getK() + + @property + def k(self): + return self._getK() + + def free(self): + self._free() + + + def scan_layer(self, layer): + self._scan_layer(layer) + + + def insert_block_content(self, block): + self._insert_block_content(block) + + def export_keyword(self, kw): + if len(kw) != self.grid_ref.getGlobalSize(): + msg = 'The size of the target keyword must be equal to the size of the grid.' + msg += ' Got:%d Expected:%d.' + raise ValueError(msg % (len(kw), self.grid_ref.getGlobalSize())) + + if not kw.data_type.is_int(): + raise TypeError("The target kewyord must be of integer type") + + self._export_kw(kw) + + + def add_fault_barrier(self, fault, link_segments=False): + layer = self.getGeoLayer() + layer.addFaultBarrier(fault, self.getK(), link_segments) + + + def add_fault_link(self, fault1, fault2): + if not fault1.intersectsFault(fault2, self.getK()): + layer = self.getGeoLayer() + layer.addIJBarrier(fault1.extendToFault(fault2, self.getK())) + + + def join_faults(self, fault1, fault2): + if not fault1.intersectsFault(fault2, self.getK()): + layer = self.getGeoLayer() + try: + layer.addIJBarrier(Fault.joinFaults(fault1, fault2, self.getK())) + except ValueError: + err = 'Failed to join faults %s and %s' + names = (fault1.getName(), fault2.getName()) + print(err % names) + raise ValueError(err % names) + + + def add_polyline_barrier(self, polyline): + layer = self.getGeoLayer() + p0 = polyline[0] + c0 = self.grid_ref.findCellCornerXY(p0[0], p0[1], self.getK()) + i,j = self.grid_ref.findCellXY(p0[0], p0[1], self.getK()) + print('%g,%g -> %d,%d %d' % (p0[0], p0[1], i,j,c0)) + for index in range(1,len(polyline)): + p1 = polyline[index] + c1 = self.grid_ref.findCellCornerXY(p1[0], p1[1], self.getK()) + i,j = self.grid_ref.findCellXY(p1[0], p1[1], self.getK()) + layer.addInterpBarrier(c0, c1) + print('%g,%g -> %d,%d %d' % (p1[0], p1[1], i,j,c1)) + print('Adding barrier %d -> %d' % (c0, c1)) + c0 = c1 + + + def get_geo_layer(self): + """Returns the underlying geometric layer.""" + return self._get_layer() + + + def cell_contact(self, p1, p2): + layer = self.getGeoLayer() + return layer.cellContact(p1,p2) + +monkey_the_camel(FaultBlockLayer, 'scanKeyword', FaultBlockLayer.scan_keyword) +monkey_the_camel(FaultBlockLayer, 'loadKeyword', FaultBlockLayer.load_keyword) +monkey_the_camel(FaultBlockLayer, 'getBlock', FaultBlockLayer.get_block) +monkey_the_camel(FaultBlockLayer, 'deleteBlock', FaultBlockLayer.delete_block) +monkey_the_camel(FaultBlockLayer, 'addBlock', FaultBlockLayer.add_block) +monkey_the_camel(FaultBlockLayer, 'getNextID', FaultBlockLayer.get_next_id) +monkey_the_camel(FaultBlockLayer, 'getK', FaultBlockLayer.get_k) +monkey_the_camel(FaultBlockLayer, 'scanLayer', FaultBlockLayer.scan_layer) +monkey_the_camel(FaultBlockLayer, 'insertBlockContent', FaultBlockLayer.insert_block_content) +monkey_the_camel(FaultBlockLayer, 'exportKeyword', FaultBlockLayer.export_keyword) +monkey_the_camel(FaultBlockLayer, 'addFaultBarrier', FaultBlockLayer.add_fault_barrier) +monkey_the_camel(FaultBlockLayer, 'addFaultLink', FaultBlockLayer.add_fault_link) +monkey_the_camel(FaultBlockLayer, 'joinFaults', FaultBlockLayer.join_faults) +monkey_the_camel(FaultBlockLayer, 'addPolylineBarrier', FaultBlockLayer.add_polyline_barrier) +monkey_the_camel(FaultBlockLayer, 'getGeoLayer', FaultBlockLayer.get_geo_layer) +monkey_the_camel(FaultBlockLayer, 'cellContact', FaultBlockLayer.cell_contact) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py new file mode 100644 index 0000000000..704c5fad87 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py @@ -0,0 +1,135 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault_collection.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import re + +from ecl.util.util import monkey_the_camel +from ecl.grid import EclGrid +from .fault import Fault + +comment_regexp = re.compile("--.*") + +def dequote(s): + if s[0] in ["'", '"']: + if s[0] == s[-1]: + return s[1:-1] + else: + raise ValueError("Quote fuckup") + else: + return s + + +class FaultCollection(object): + def __init__(self, grid=None, *file_list): + self.__fault_list = [] + self.__fault_map = {} + self.__grid = grid + + if self.__grid is not None: + if not isinstance(self.__grid, EclGrid): + raise ValueError("When supplying a list of files to load - you must have a grid") + for file in file_list: + self.load(self.__grid, file) + + + def __contains__(self, fault_name): + return fault_name in self.__fault_map + + + def __len__(self): + return len(self.__fault_list) + + + def __getitem__(self, index): + if isinstance(index, str): + return self.__fault_map[index] + elif isinstance(index, int): + return self.__fault_list[index] + else: + raise TypeError("Argument must be fault name or number") + + def __iter__(self): + return iter(self.__fault_list) + + + def get_grid(self): + return self.__grid + + + def get_fault(self, name): + return self[name] + + + def has_fault(self, fault_name): + return fault_name in self + + + def add_fault(self, fault): + self.__fault_map[fault.getName()] = fault + self.__fault_list.append(fault) + + + def split_line(self, line): + tmp = line.split() + if not tmp[-1] == "/": + raise ValueError("Line:%s does not end with /" % line) + + if len(tmp) != 9: + raise ValueError("Line:%s not correct number of items" % line) + + fault_name = dequote(tmp[0]) + I1 = int(tmp[1]) - 1 + I2 = int(tmp[2]) - 1 + J1 = int(tmp[3]) - 1 + J2 = int(tmp[4]) - 1 + K1 = int(tmp[5]) - 1 + K2 = int(tmp[6]) - 1 + face = dequote(tmp[7]) + + return (fault_name, I1,I2,J1,J2,K1,K2, face) + + + + def load_faults(self, grid, fileH): + for line in fileH: + line = comment_regexp.sub("", line) + line = line.strip() + if line == "/": + break + + if line: + (name, I1, I2, J1, J2, K1, K2, face) = self.splitLine(line) + if not self.hasFault(name): + fault = Fault(grid, name) + self.addFault(fault) + else: + fault = self.getFault(name) + + fault.addRecord(I1, I2, J1, J2, K1, K2, face) + + + def load(self, grid, file_name): + with open(file_name) as fileH: + for line in fileH: + if line.startswith("FAULTS"): + self.loadFaults(grid, fileH) + + +monkey_the_camel(FaultCollection, 'getGrid', FaultCollection.get_grid) +monkey_the_camel(FaultCollection, 'getFault', FaultCollection.get_fault) +monkey_the_camel(FaultCollection, 'hasFault', FaultCollection.has_fault) +monkey_the_camel(FaultCollection, 'addFault', FaultCollection.add_fault) +monkey_the_camel(FaultCollection, 'splitLine', FaultCollection.split_line) +monkey_the_camel(FaultCollection, 'loadFaults', FaultCollection.load_faults) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py new file mode 100644 index 0000000000..10ef3da0e8 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py @@ -0,0 +1,248 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'fault_line.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import print_function +import sys + +from ecl.util.util import monkey_the_camel +from ecl.util.util import DoubleVector +from ecl.util.geometry import CPolyline + +from .fault_segments import FaultSegment + + +class FaultLine(object): + def __init__(self, grid, k): + self.__grid = grid + self.__k = k + self.__segment_list = [] + self.__polyline = None + self.__ijpolyline = None + self.__neighborCells = None + + def __len__(self): + return len(self.__segment_list) + + + def __getitem__(self, index): + return self.__segment_list[index] + + def __iter__(self): + return iter(self.__segment_list) + + + def verify(self): + if len(self.__segment_list) > 1: + current = self.__segment_list[0] + for next_segment in self.__segment_list[1:]: + if not current.getC2() == next_segment.getC1(): + sys.stdout.write("Current: %d ---- %d \n" % (current.getC1() , current.getC2())) + sys.stdout.write("Next : %d ---- %d \n" % (next_segment.getC1(), next_segment.getC2())) + assert current.getC2() == next_segment.getC1() + current = next_segment + + + def try_append(self, segment): + if len(self.__segment_list) > 0: + tail = self.__segment_list[-1] + if tail.getC2() != segment.getC1(): + if len(self.__segment_list) == 1: + if tail.getC2() == segment.getC2(): + segment.swap() + else: + tail.swap() + if tail.getC2() == segment.getC2(): + segment.swap() + else: + segment.swap() + + if not tail.getC2() == segment.getC1(): + return False + + self.__segment_list.append(segment) + self.__polyline = None + self.__ijpolyline = None + return True + + + def get_k(self): + return self.__k + + @property + def k(self): + return self.__k + + + def __init_ij_polyline(self): + pl = [] + nx = self.__grid.getNX() + ny = self.__grid.getNY() + for segment in self: + corner = segment.getC1() + i = corner % (nx + 1) + j = corner // (nx + 1) + pl.append((i,j)) + + segment = self[-1] + corner = segment.getC2() + i = corner % (nx + 1) + j = corner // (nx + 1) + pl.append((i,j)) + + self.__ijpolyline = pl + + + + def __init_polyline(self): + pl = CPolyline() + for (i,j) in self.getIJPolyline(): + x,y,z = self.__grid.getNodeXYZ(i, j, self.__k) + pl.addPoint(x, y) + self.__polyline = pl + + + + def get_polyline(self): + if self.__polyline is None: + self.__init_polyline() + return self.__polyline + + + def get_ij_polyline(self): + if self.__ijpolyline is None: + self.__init_ij_polyline() + return self.__ijpolyline + + + + def __init_neighbor_cells(self): + self.__neighborCells = [] + nx = self.__grid.getNX() + ny = self.__grid.getNY() + k = self.__k + + for segment in self: + (j1,i1) = divmod(segment.getC1(), (nx + 1)) + (j2,i2) = divmod(segment.getC2(), (nx + 1)) + + if j1 > j2: + j1,j2 = j2,j1 + + if i1 > i2: + i1,i2 = i2,i1 + + + if i1 == i2: + i = i1 + for j in range(j1, j2): + g2 = i + j * nx + k * nx*ny + if i == 0: + g1 = -1 + else: + g1 = g2 - 1 + + if i == nx: + g2 = -1 + + self.__neighborCells.append((g1,g2)) + elif j1 == j2: + j = j1 + for i in range(i1,i2): + g2 = i + j * nx + k * nx*ny + if j == 0: + g1 = -1 + else: + g1 = g2 - nx + + if j == ny: + g2 = -1 + + self.__neighborCells.append((g1,g2)) + else: + raise Exception("Internal error: found fault segment with " + "variation in two directions") + + self.__neighborCells.sort(key=lambda k: (k[0], k[1])) + + + def get_neighbor_cells(self): + if self.__neighborCells is None: + self.__init_neighbor_cells() + + return self.__neighborCells + + + def center(self): + xlist = DoubleVector() + ylist = DoubleVector() + for segment in self: + C1 = segment.getC1() + C2 = segment.getC2() + (J1, I1) = divmod(C1, self.__grid.getNX() + 1) + (J2, I2) = divmod(C2, self.__grid.getNX() + 1) + + (x1,y1,z) = self.__grid.getNodePos(I1, J1, self.__k) + (x2,y2,z) = self.__grid.getNodePos(I2, J2, self.__k) + + xlist.append(x1) + xlist.append(x2) + + ylist.append(y1) + ylist.append(y2) + + + N = len(xlist) + return (xlist.elementSum()/N, ylist.elementSum()/N) + + + + def reverse(self): + reverse_list = reversed(self.__segment_list) + self.__segment_list = [] + for segment in reverse_list: + C1 = segment.getC1() + C2 = segment.getC2() + + rseg = FaultSegment(C2, C1) + self.tryAppend(rseg) + + + def start_point(self): + pl = self.getPolyline() + return pl[0] + + def end_point(self): + pl = self.getPolyline() + return pl[-1] + + def dump(self): + print('-----------------------------------------------------------------') + for segment in self: + C1 = segment.getC1() + C2 = segment.getC2() + (J1, I1) = divmod(C1, self.__grid.getNX() + 1) + (J2, I2) = divmod(C2, self.__grid.getNX() + 1) + print('[Corner:%5d IJ:(%3d,%d)] -> [Corner:%5d IJ:(%3d,%d)]' + % (C1, I1, J1, C2, I2, J2)) + + +monkey_the_camel(FaultLine, 'tryAppend', FaultLine.try_append) +monkey_the_camel(FaultLine, 'getK', FaultLine.get_k) +monkey_the_camel(FaultLine, 'getPolyline', FaultLine.get_polyline) +monkey_the_camel(FaultLine, 'getIJPolyline', FaultLine.get_ij_polyline) +monkey_the_camel(FaultLine, 'getNeighborCells', FaultLine.get_neighbor_cells) +monkey_the_camel(FaultLine, 'startPoint', FaultLine.start_point) +monkey_the_camel(FaultLine, 'endPoint', FaultLine.end_point) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py new file mode 100644 index 0000000000..7949a44d0e --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py @@ -0,0 +1,174 @@ +# Copyright (C) 2014. Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import print_function + +from ecl.util.util import monkey_the_camel + + +class FaultSegment(object): + + def __init__(self, C1, C2): + self.__C1 = C1 + self.__C2 = C2 + self.__next_segment = None + + + def __eq__(self, other): + s = self.c1, self.c2 + o = other.c1, other.c2 + o_flipped = other.c2, other.c1 + return s == o or s == o_flipped + + def __hash__(self): + return hash(hash(self.__C1) + hash(self.__C2) + hash(self.__next_segment)) + + def get_corners(self): + return (self.__C1, self.__C2) + + def joins(self, other): + if self.__C1 == other.__C1: + return True + if self.__C1 == other.__C2: + return True + if self.__C2 == other.__C1: + return True + if self.__C2 == other.__C2: + return True + + return False + + def get_c1(self): + return self.__C1 + + @property + def c1(self): + return self.__C1 + + def get_c2(self): + return self.__C2 + + @property + def c2(self): + return self.__C2 + + def swap(self): + C1 = self.__C1 + self.__C1 = self.__C2 + self.__C2 = C1 + + + def __repr__(self): + return "%d -> %d" % (self.__C1, self.__C2) + + + +class SegmentMap(object): + + def __init__(self): + self.__segment_map = {} + self.__count_map = {} + + def __len__(self): + return len(self.__segment_map) + + def __str__(self): + return self.__segment_map.__str__() + + def verify(self): + for (C, count) in self.__count_map.iteritems(): + if count > 0: + d = self.__segment_map[C] + if len(d) != count: + print('CornerPoint:%d count:%d len(d):%d map:%s' % (C, count, len(d), d)) + assert len(d) == count + else: + assert self.__segment_map.get(C) is None + + + def add_segment(self, segment): + (C1,C2) = segment.getCorners() + if C1 not in self.__segment_map: + self.__segment_map[C1] = {} + self.__count_map[C1] = 0 + if C2 not in self.__segment_map: + self.__segment_map[C2] = {} + self.__count_map[C2] = 0 + + if C2 not in self.__segment_map[C1]: + self.__segment_map[C1][C2] = segment + self.__count_map[C1] += 1 + + if C1 not in self.__segment_map[C2]: + self.__segment_map[C2][C1] = segment + self.__count_map[C2] += 1 + + + + def del_segment(self, segment): + (C1,C2) = segment.getCorners() + self.__count_map[C1] -= 1 + self.__count_map[C2] -= 1 + del self.__segment_map[C1][C2] + del self.__segment_map[C2][C1] + + if len(self.__segment_map[C1]) == 0: + del self.__segment_map[C1] + + if len(self.__segment_map[C2]) == 0: + del self.__segment_map[C2] + + + def pop_start(self): + end_segments = [] + for (C, count) in self.__count_map.items(): + if count == 1: + end_segments.append(list(self.__segment_map[C].values())[0]) + + start_segment = end_segments[0] + self.delSegment(start_segment) + return start_segment + + def pop_next(self, segment): + (C1,C2) = segment.getCorners() + if self.__count_map[C1] >= 1: + next_segment = list(self.__segment_map[C1].values())[0] + elif self.__count_map[C2] >= 1: + next_segment = list(self.__segment_map[C2].values())[0] + else: + next_segment = None + + if next_segment: + self.delSegment(next_segment) + return next_segment + + + def print_content(self): + for d in self.__segment_map.values(): + for (C,S) in d.iteritems(): + print(S) + + + +monkey_the_camel(FaultSegment, 'getCorners', FaultSegment.get_corners) +monkey_the_camel(FaultSegment, 'getC1', FaultSegment.get_c1) +monkey_the_camel(FaultSegment, 'getC2', FaultSegment.get_c2) + +monkey_the_camel(SegmentMap, 'addSegment', SegmentMap.add_segment) +monkey_the_camel(SegmentMap, 'delSegment', SegmentMap.del_segment) +monkey_the_camel(SegmentMap, 'popStart', SegmentMap.pop_start) +monkey_the_camel(SegmentMap, 'popNext', SegmentMap.pop_next) +monkey_the_camel(SegmentMap, 'printContent', SegmentMap.print_content) diff --git a/ThirdParty/Ert/python/ecl/grid/faults/layer.py b/ThirdParty/Ert/python/ecl/grid/faults/layer.py new file mode 100644 index 0000000000..855f8f6be0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/faults/layer.py @@ -0,0 +1,275 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'layer.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes + +from ecl.grid import EclGrid +from cwrap import BaseCClass +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclPrototype + + +class Layer(BaseCClass): + TYPE_NAME = "layer" + _alloc = EclPrototype("void* layer_alloc(int, int)", bind=False) + _copy = EclPrototype("void layer_memcpy(layer, layer)") + _free = EclPrototype("void layer_free(layer)") + _get_nx = EclPrototype("int layer_get_nx(layer)") + _get_ny = EclPrototype("int layer_get_ny(layer)") + _set_cell = EclPrototype("void layer_iset_cell_value(layer, int, int, int)") + _get_cell = EclPrototype("int layer_iget_cell_value(layer, int, int)") + _get_bottom_barrier = EclPrototype("bool layer_iget_bottom_barrier(layer, int, int)") + _get_left_barrier = EclPrototype("bool layer_iget_left_barrier(layer, int, int)") + _cell_contact = EclPrototype("bool layer_cell_contact(layer, int, int, int, int)") + _add_barrier = EclPrototype("void layer_add_barrier(layer, int, int)") + _add_ijbarrier = EclPrototype("void layer_add_ijbarrier(layer, int, int, int, int)") + _add_interp_barrier = EclPrototype("void layer_add_interp_barrier(layer, int, int)") + _clear_cells = EclPrototype("void layer_clear_cells(layer)") + _assign = EclPrototype("void layer_assign(layer, int)") + _cell_sum = EclPrototype("int layer_get_cell_sum(layer)") + _update_connected = EclPrototype("void layer_update_connected_cells(layer,int,int,int,int)") + _cells_equal = EclPrototype("void layer_cells_equal(layer, int,int_vector,int_vector)") + _count_equal = EclPrototype("int layer_count_equal(layer, int)") + _active_cell = EclPrototype("bool layer_iget_active(layer, int,int)") + _update_active = EclPrototype("bool layer_update_active(layer, ecl_grid, int)") + + def __init__(self, nx, ny): + c_ptr = self._alloc(nx, ny) + if c_ptr: + super(Layer, self).__init__(c_ptr) + else: + raise ValueError("Invalid input - no Layer object created") + + @classmethod + def copy(cls, src): + layer = Layer(src.getNX(), src.getNY()) + layer._copy(layer, src) + return layer + + + def _assert_ij(self, i,j): + if i < 0 or i >= self.getNX(): + raise ValueError("Invalid layer i:%d" % i) + + if j < 0 or j >= self.getNY(): + raise ValueError("Invalid layer j:%d" % j) + + + def __unpack_index(self, index): + try: + (i,j) = index + except TypeError: + raise ValueError("Index:%s is invalid - must have two integers" % str(index)) + + self._assert_ij(i,j) + + return (i,j) + + + def __setitem__(self, index, value): + (i,j) = self.__unpack_index(index) + self._set_cell(i, j, value) + + def active_cell(self, i,j): + self._assert_ij(i,j) + return self._active_cell(i, j) + + + def update_active(self, grid, k): + if grid.getNX() != self.getNX(): + raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX(), self.getNX())) + + if grid.getNY() != self.getNY(): + raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY(), self.getNY())) + + if k >= grid.getNZ(): + raise ValueError("K value invalid: Grid range [0,%d)" % grid.getNZ()) + + self._update_active(grid, k) + + + def __getitem__(self, index): + (i,j) = self.__unpack_index(index) + return self._get_cell(i, j) + + def bottom_barrier(self, i,j): + self._assert_ij(i,j) + return self._get_bottom_barrier(i, j) + + def left_barrier(self, i,j): + self._assert_ij(i,j) + return self._get_left_barrier(i, j) + + def get_nx(self): + return self._get_nx() + + @property + def nx(self): + return self._get_nx() + + def get_ny(self): + return self._get_ny() + + @property + def ny(self): + return self._get_ny() + + def free(self): + self._free() + + def cell_contact(self, p1, p2): + i1,j1 = p1 + i2,j2 = p2 + + if not 0 <= i1 < self.getNX(): + raise IndexError("Invalid i1:%d" % i1) + + if not 0 <= i2 < self.getNX(): + raise IndexError("Invalid i2:%d" % i2) + + if not 0 <= j1 < self.getNY(): + raise IndexError("Invalid i1:%d" % j1) + + if not 0 <= j2 < self.getNY(): + raise IndexError("Invalid i2:%d" % j2) + + return self._cell_contact(i1, j1, i2, j2) + + + def add_interp_barrier(self, c1, c2): + self._add_interp_barrier(c1, c2) + + + def add_polyline_barrier(self, polyline, grid, k): + if len(polyline) > 1: + for i in range(len(polyline) - 1): + x1,y1 = polyline[i] + x2,y2 = polyline[i + 1] + + c1 = grid.findCellCornerXY(x1, y1, k) + c2 = grid.findCellCornerXY(x2, y2, k) + + self.addInterpBarrier(c1, c2) + + + def add_fault_barrier(self, fault, K, link_segments=True): + fault_layer = fault[K] + num_lines = len(fault_layer) + for index, fault_line in enumerate(fault_layer): + for segment in fault_line: + c1, c2 = segment.getCorners() + self._add_barrier(c1, c2) + + if index < num_lines - 1: + next_line = fault_layer[index + 1] + next_segment = next_line[0] + next_c1, next_c2 = next_segment.getCorners() + + if link_segments: + self.addInterpBarrier(c2, next_c1) + + + def add_ij_barrier(self, ij_list): + if len(ij_list) < 2: + raise ValueError("Must have at least two (i,j) points") + + nx = self.getNX() + ny = self.getNY() + p1 = ij_list[0] + i1,j1 = p1 + for p2 in ij_list[1:]: + i2,j2 = p2 + if i1 == i2 or j1 == j2: + if not 0 <= i2 <= nx: + raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (i1, i2)) + + if not 0 <= j2 <= ny: + raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (j1, j2)) + + self._add_ijbarrier(i1, j1, i2, j2) + p1 = p2 + i1,j1 = p1 + else: + raise ValueError("Must have i1 == i2 or j1 == j2") + + + def cell_sum(self): + return self._cell_sum() + + def clear_cells(self): + """ + Will reset all cell and edge values to zero. Barriers will be left + unchanged. + """ + self._clear_cells() + + + def assign(self, value): + """ + Will set the cell value to @value in all cells. Barriers will not be changed + """ + self._assign(value) + + def update_connected(self, ij, new_value, org_value=None): + """ + Will update cell value of all cells in contact with cell ij to the + value @new_value. If org_value is not supplied, the current + value in cell ij is used. + """ + if org_value is None: + org_value = self[ij] + + if self[ij] == org_value: + self._update_connected(ij[0], ij[1], org_value, new_value) + else: + raise ValueError("Cell %s is not equal to %d \n" % (ij, org_value)) + + + def cells_equal(self, value): + """ + Will return a list [(i1,j1),(i2,j2), ...(in,jn)] of all cells with value @value. + """ + i_list = IntVector() + j_list = IntVector() + self._cells_equal(value, i_list, j_list) + ij_list= [] + for (i,j) in zip(i_list, j_list): + ij_list.append((i,j)) + return ij_list + + + def count_equal(self, value): + return self._count_equal(value) + + + +monkey_the_camel(Layer, 'activeCell', Layer.active_cell) +monkey_the_camel(Layer, 'updateActive', Layer.update_active) +monkey_the_camel(Layer, 'bottomBarrier', Layer.bottom_barrier) +monkey_the_camel(Layer, 'leftBarrier', Layer.left_barrier) +monkey_the_camel(Layer, 'getNX', Layer.get_nx) +monkey_the_camel(Layer, 'getNY', Layer.get_ny) +monkey_the_camel(Layer, 'cellContact', Layer.cell_contact) +monkey_the_camel(Layer, 'addInterpBarrier', Layer.add_interp_barrier) +monkey_the_camel(Layer, 'addPolylineBarrier', Layer.add_polyline_barrier) +monkey_the_camel(Layer, 'addFaultBarrier', Layer.add_fault_barrier) +monkey_the_camel(Layer, 'addIJBarrier', Layer.add_ij_barrier) +monkey_the_camel(Layer, 'cellSum', Layer.cell_sum) +monkey_the_camel(Layer, 'clearCells', Layer.clear_cells) +monkey_the_camel(Layer, 'updateConnected', Layer.update_connected) +monkey_the_camel(Layer, 'cellsEqual', Layer.cells_equal) +monkey_the_camel(Layer, 'countEqual', Layer.count_equal) diff --git a/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt b/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt new file mode 100644 index 0000000000..2427bbca2a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt @@ -0,0 +1,8 @@ +set(PYTHON_SOURCES + __init__.py + well_trajectory.py + ecl_rft.py + ecl_rft_cell.py +) + +add_python_package("python.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/rft "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/rft/__init__.py b/ThirdParty/Ert/python/ecl/rft/__init__.py new file mode 100644 index 0000000000..d4efcd32c0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/__init__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" + ecl_rft/[EclRFTFile , EclRFT , EclRFTCell]: Loads an ECLIPSE RFT/PLT + file, and can afterwords be used to support various queries. +""" + +from .well_trajectory import WellTrajectory +from .ecl_rft_cell import EclPLTCell, EclRFTCell +from .ecl_rft import EclRFT, EclRFTFile + diff --git a/ThirdParty/Ert/python/ecl/rft/ecl_rft.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py new file mode 100644 index 0000000000..38411dfd4b --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py @@ -0,0 +1,356 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_rft.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Module for loading ECLIPSE RFT files. +""" + +from __future__ import absolute_import, division, print_function, unicode_literals + +from cwrap import BaseCClass + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl.rft import EclRFTCell, EclPLTCell + +class EclRFT(BaseCClass): + """The EclRFT class contains the information for *one* RFT. + + The ECLIPSE RFT file can contain three different types of RFT like + objects which are lumped together; the EclRFTClass is a container + for such objects. The three different object types which can be + found in an RFT file are: + + RFT: This is old-fashioned RFT which contains measurements of + saturations for each of the completed cells. + + PLT: This contains production and flow rates for each phase in + each cell. + + SEGMENT: Not implemented. + + In addition to the measurements specific for RFT and PLT each cell + has coordinates, pressure and depth. + """ + TYPE_NAME = "ecl_rft" + _alloc = EclPrototype("void* ecl_rft_node_alloc_new( char* , char* , time_t , double)" , bind = False) + _free = EclPrototype("void ecl_rft_node_free( ecl_rft )") + _get_type = EclPrototype("int ecl_rft_node_get_type( ecl_rft )") + _get_well = EclPrototype("char* ecl_rft_node_get_well_name( ecl_rft )") + _get_date = EclPrototype("time_t ecl_rft_node_get_date( ecl_rft )") + _get_size = EclPrototype("int ecl_rft_node_get_size( ecl_rft )") + _iget_cell = EclPrototype("void* ecl_rft_node_iget_cell( ecl_rft )") + _iget_cell_sorted = EclPrototype("void* ecl_rft_node_iget_cell_sorted( ecl_rft )") + _sort_cells = EclPrototype("void* ecl_rft_node_inplace_sort_cells( ecl_rft )") + _iget_depth = EclPrototype("double ecl_rft_node_iget_depth( ecl_rft )") + _iget_pressure = EclPrototype("double ecl_rft_node_iget_pressure(ecl_rft)") + _iget_ijk = EclPrototype("void ecl_rft_node_iget_ijk( ecl_rft , int , int*, int*, int*)") + _iget_swat = EclPrototype("double ecl_rft_node_iget_swat(ecl_rft)") + _iget_sgas = EclPrototype("double ecl_rft_node_iget_sgas(ecl_rft)") + _iget_orat = EclPrototype("double ecl_rft_node_iget_orat(ecl_rft)") + _iget_wrat = EclPrototype("double ecl_rft_node_iget_wrat(ecl_rft)") + _iget_grat = EclPrototype("double ecl_rft_node_iget_grat(ecl_rft)") + _lookup_ijk = EclPrototype("void* ecl_rft_node_lookup_ijk( ecl_rft , int , int , int)") + _is_RFT = EclPrototype("bool ecl_rft_node_is_RFT( ecl_rft )") + _is_PLT = EclPrototype("bool ecl_rft_node_is_PLT( ecl_rft )") + _is_SEGMENT = EclPrototype("bool ecl_rft_node_is_SEGMENT( ecl_rft )") + _is_MSW = EclPrototype("bool ecl_rft_node_is_MSW( ecl_rft )") + + + def __init__(self , name , type_string , date , days): + c_ptr = self._alloc( name , type_string , CTime( date ) , days ) + super(EclRFT , self).__init__( c_ptr ) + + + def free(self): + self._free( ) + + def __repr__(self): + rs = [] + rs.append('completed_cells = %d' % len(self)) + rs.append('date = %s' % self.getDate()) + if self.is_RFT(): + rs.append('RFT') + if self.is_PLT(): + rs.append('PLT') + if self.is_SEGMENT(): + rs.append('SEGMENT') + if self.is_MSW(): + rs.append('MSW') + rstr = ', '.join(rs) + return self._create_repr(rstr) + + def __len__(self): + """ + The number of completed cells in this RFT. + """ + return self._get_size( ) + + def is_RFT(self): + """ + Is instance an RFT; in that case all the cells will be EclRFTCell instances. + """ + return self._is_RFT( ) + + def is_PLT(self): + """ + Is instance a PLT; in that case all the cells will be EclPLTCell instances. + """ + return self._is_PLT( ) + + def is_SEGMENT(self): + """ + Is this a SEGMENT - not implemented. + """ + return self._is_SEGMENT( ) + + def is_MSW(self): + """ + Is this well a MSW well. Observe that the test ONLY applies to PLTs. + """ + return self._is_MSW( ) + + + def get_well_name(self): + """ + The name of the well we are considering. + """ + return self._get_well( ) + + def get_date(self): + """ + The date when this RFT/PLT/... was recorded. + """ + ct = CTime(self._get_date( )) + return ct.date() + + def __cell_ref( self , cell_ptr ): + if self.is_RFT(): + return EclRFTCell.createCReference( cell_ptr , self ) + elif self.is_PLT(): + return EclPLTCell.createCReference( cell_ptr , self ) + else: + raise NotImplementedError("Only RFT and PLT cells are implemented") + + + def assert_cell_index( self , index ): + if isinstance( index , int): + length = self.__len__() + if index < 0 or index >= length: + raise IndexError + else: + raise TypeError("Index should be integer type") + + + def __getitem__(self , index): + """Implements the [] operator to return the cells. + + To get the object related to cell nr 5: + + cell = rft[4] + + The return value from the __getitem__() method is either an + EclRFTCell instance or a EclPLTCell instance, depending on the + type of this particular RFT object. + """ + self.assert_cell_index( index ) + cell_ptr = self._iget_cell( index ) + return self.__cell_ref( cell_ptr ) + + + def iget( self , index ): + return self[index] + + + def iget_sorted( self , index ): + """ + Will return the cell nr @index in the list of sorted cells. + + See method sort() for further documentation. + """ + self.assert_cell_index( index ) + cell_ptr = self._iget_cell_sorted( index ) + return self.__cell_ref( cell_ptr ) + + + def sort(self): + """ + Will sort cells in RFT; currently only applies to MSW wells. + + By default the cells in the RFT come in the order they are + specified in the ECLIPSE input file; that is not necessarily + in a suitable order. In the case of MSW wells it is possible + to sort the connections after distance along the wellpath. To + access the cells in sort order you have two options: + + 1. Sort the cells using the sort() method, and then + subsequently access them sequentially: + + rft.sort() + for cell in rft: + print cell + + 2. Let the rft object stay unsorted, but access the cells + using the iget_sorted() method: + + for i in range(len(rft)): + cell = rft.iget_sorted( i ) + + Currently only MSW/PLTs are sorted, based on the CONLENST + keyword; for other wells the sort() method does nothing. + """ + self._sort_cells( ) + + + # ijk are zero offset + def ijkget( self , ijk ): + """ + Will look up the cell based on (i,j,k). + + If the cell (i,j,k) is not part of this RFT/PLT None will be + returned. The (i,j,k) input values should be zero offset, + i.e. you must subtract 1 from the (i,j,k) values given in the ECLIPSE input. + """ + cell_ptr = self._lookup_ijk( ijk[0] , ijk[1] , ijk[2]) + if cell_ptr: + return self.__cell_ref( cell_ptr ) + else: + return None + + + + +class EclRFTFile(BaseCClass): + TYPE_NAME = "ecl_rft_file" + _load = EclPrototype("void* ecl_rft_file_alloc_case( char* )", bind = False) + _iget = EclPrototype("ecl_rft_ref ecl_rft_file_iget_node( ecl_rft_file , int )") + _get_rft = EclPrototype("ecl_rft_ref ecl_rft_file_get_well_time_rft( ecl_rft_file , char* , time_t)") + _has_rft = EclPrototype("bool ecl_rft_file_case_has_rft( char* )", bind = False) + _free = EclPrototype("void ecl_rft_file_free( ecl_rft_file )") + _get_size = EclPrototype("int ecl_rft_file_get_size__( ecl_rft_file , char* , time_t)") + _get_num_wells = EclPrototype("int ecl_rft_file_get_num_wells( ecl_rft_file )") + + + """ + The EclRFTFile class is used to load an ECLIPSE RFT file. + + The EclRFTFile serves as a container which can load and hold the + content of an ECLIPSE RFT file. The RFT files will in general + contain data for several wells and several times in one large + container. The EclRFTClass class contains methods get the the RFT + results for a specific time and/or well. + + The EclRFTFile class can in general contain a mix of RFT and PLT + measurements. The class does not really differentiate between + these. + """ + + def __init__(self , case): + c_ptr = self._load( case ) + super(EclRFTFile , self).__init__(c_ptr) + + + def __len__(self): + return self._get_size( None , CTime(-1)) + + + def __getitem__(self, index): + if isinstance(index, int): + if 0 <= index < len(self): + rft = self._iget(index) + rft.setParent( self ) + return rft + else: + raise IndexError("Index '%d' must be in range: [0, %d]" % (index, len(self) - 1)) + else: + raise TypeError("Index must be integer type") + + + def size(self, well=None, date=None): + """ + The number of elements in EclRFTFile container. + + By default the size() method will return the total number of + RFTs/PLTs in the container, but by specifying the optional + arguments date and/or well the function will only count the + number of well measurements matching that time or well + name. The well argument can contain wildcards. + + rftFile = ecl.EclRFTFile( "ECLIPSE.RFT" ) + print "Total number of RFTs : %d" % rftFile.size( ) + print "RFTs matching OP* : %d" % rftFile.size( well = "OP*" ) + print "RFTs at 01/01/2010 : %d" % rftFile.size( date = datetime.date( 2010 , 1 , 1 )) + + """ + if date: + cdate = CTime( date ) + else: + cdate = CTime( -1 ) + + return self._get_size( well , cdate) + + + def get_num_wells(self): + """ + Returns the total number of distinct wells in the RFT file. + """ + return self._get_num_wells( ) + + + def get_headers(self): + """ + Returns a list of two tuples (well_name , date) for the whole file. + """ + header_list = [] + for i in (range(self._get_size( None , CTime(-1)))): + rft = self.iget( i ) + header_list.append( (rft.getWellName() , rft.getDate()) ) + return header_list + + + def iget(self , index): + """ + Will lookup RFT @index - equivalent to [@index]. + """ + return self[index] + + + def get(self , well_name , date ): + """ + Will look up the RFT object corresponding to @well and @date. + + Raise Exception if not found. + """ + if self.size( well = well_name , date = date) == 0: + raise KeyError("No RFT for well:%s at %s" % (well_name , date)) + + rft = self._get_rft( well_name , CTime( date )) + rft.setParent( self ) + return rft + + def free(self): + self._free( ) + + def __repr__(self): + w = len(self) + return self._create_repr('wells = %d' % w) + + +monkey_the_camel(EclRFT, 'getWellName', EclRFT.get_well_name) +monkey_the_camel(EclRFT, 'getDate', EclRFT.get_date) + +monkey_the_camel(EclRFTFile, 'getNumWells', EclRFTFile.get_num_wells) +monkey_the_camel(EclRFTFile, 'getHeaders', EclRFTFile.get_headers) diff --git a/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py new file mode 100644 index 0000000000..13a80cc4b6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py @@ -0,0 +1,171 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass +from ecl import EclPrototype + + +class RFTCell(BaseCClass): + """The RFTCell is a base class for the cells which are part of an RFT/PLT. + + The RFTCell class contains the elements which are common to both + RFT and PLT. The list of common elements include the corrdinates + (i,j,k) the pressure and the depth of the cell. Actual user access + should be based on the derived classes EclRFTCell and EclPLTCell. + + Observe that from june 2013 the properties i,j and k which return + offset 1 coordinate values are deprecated, and you should rather + use the methods get_i(), get_j() and get_k() which return offset 0 + coordinate values. + """ + TYPE_NAME = "rft_cell" + _free = EclPrototype("void ecl_rft_cell_free(rft_cell)") + _get_pressure = EclPrototype("double ecl_rft_cell_get_pressure(rft_cell)") + _get_depth = EclPrototype("double ecl_rft_cell_get_depth(rft_cell)") + _get_i = EclPrototype("int ecl_rft_cell_get_i(rft_cell)") + _get_j = EclPrototype("int ecl_rft_cell_get_j(rft_cell)") + _get_k = EclPrototype("int ecl_rft_cell_get_k(rft_cell)") + + + def free(self): + self._free() + + def get_i(self): + return self._get_i() + + def get_j(self): + return self._get_j() + + def get_k(self): + return self._get_k() + + def get_ijk(self): + return (self.get_i(), self.get_j(), self.get_k()) + + @property + def pressure(self): + return self._get_pressure() + + @property + def depth(self): + return self._get_depth() + + +################################################################# + + +class EclRFTCell(RFTCell): + TYPE_NAME = "ecl_rft_cell" + _alloc_RFT = EclPrototype("void* ecl_rft_cell_alloc_RFT(int, int, int, double, double, double, double)", bind = False) + _get_swat = EclPrototype("double ecl_rft_cell_get_swat(ecl_rft_cell)") + _get_soil = EclPrototype("double ecl_rft_cell_get_soil(ecl_rft_cell)") + _get_sgas = EclPrototype("double ecl_rft_cell_get_sgas(ecl_rft_cell)") + + def __init__(self, i, j, k, depth, pressure, swat, sgas): + c_ptr = self._alloc_RFT(i, j, k, depth, pressure, swat, sgas) + super(EclRFTCell, self).__init__(c_ptr) + + @property + def swat(self): + return self._get_swat() + + @property + def sgas(self): + return self._get_sgas() + + @property + def soil(self): + return 1 - (self._get_sgas() + self._get_swat()) + + +################################################################# + + +class EclPLTCell(RFTCell): + TYPE_NAME = "ecl_plt_cell" + _alloc_PLT = EclPrototype("void* ecl_rft_cell_alloc_PLT(int, int, int, double, double, double, double, double, double, double, double, double, double, double)", bind=False) + _get_orat = EclPrototype("double ecl_rft_cell_get_orat(ecl_plt_cell)") + _get_grat = EclPrototype("double ecl_rft_cell_get_grat(ecl_plt_cell)") + _get_wrat = EclPrototype("double ecl_rft_cell_get_wrat(ecl_plt_cell)") + + _get_flowrate = EclPrototype("double ecl_rft_cell_get_flowrate(ecl_plt_cell)") + _get_oil_flowrate = EclPrototype("double ecl_rft_cell_get_oil_flowrate(ecl_plt_cell)") + _get_gas_flowrate = EclPrototype("double ecl_rft_cell_get_gas_flowrate(ecl_plt_cell)") + _get_water_flowrate = EclPrototype("double ecl_rft_cell_get_water_flowrate(ecl_plt_cell)") + + _get_conn_start = EclPrototype("double ecl_rft_cell_get_connection_start(ecl_plt_cell)") + _get_conn_end = EclPrototype("double ecl_rft_cell_get_connection_end(ecl_plt_cell)") + + + def __init__(self, i, j, k, depth, pressure, orat, grat, wrat, conn_start, + conn_end, flowrate, oil_flowrate, gas_flowrate, water_flowrate): + c_ptr = self._alloc_PLT(i, j, k, depth, pressure, orat, grat, wrat, + conn_start, conn_end, flowrate, oil_flowrate, + gas_flowrate, water_flowrate) + super(EclPLTCell, self).__init__(c_ptr) + + + @property + def orat(self): + return self._get_orat() + + @property + def grat(self): + return self._get_grat() + + @property + def wrat(self): + return self._get_wrat() + + @property + def conn_start(self): + """Will return the length from wellhead(?) to connection. + + For MSW wells this property will return the distance from a + fixed point (wellhead) to the current connection. This value + will be used to sort the completed cells along the well + path. In the case of non MSW wells this will just return a + fixed default value. + """ + return self._get_conn_start() + + @property + def conn_end(self): + """Will return the length from wellhead(?) to connection end. + + For MSW wells this property will return the distance from a + fixed point (wellhead) to the current connection end. This value + will be used to sort the completed cells along the well + path. In the case of non MSW wells this will just return a + fixed default value. + """ + return self._get_conn_end() + + @property + def flowrate(self): + return self._get_flowrate() + + @property + def oil_flowrate(self): + return self._get_oil_flowrate() + + @property + def gas_flowrate(self): + return self._get_gas_flowrate() + + @property + def water_flowrate(self): + return self._get_water_flowrate() diff --git a/ThirdParty/Ert/python/ecl/rft/well_trajectory.py b/ThirdParty/Ert/python/ecl/rft/well_trajectory.py new file mode 100644 index 0000000000..abe0cadcd5 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/well_trajectory.py @@ -0,0 +1,84 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'well_trajectory.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import sys +from os.path import isfile +from collections import namedtuple + +TrajectoryPoint = namedtuple('TrajectoryPoint', + ['utm_x', 'utm_y', + 'measured_depth', 'true_vertical_depth', + 'zone']) + +def _read_point(line): + line = line.partition("--")[0] + line = line.strip() + if not line: + return None + + point = line.split() + if len(point) not in (4, 5): + fmt = 'utm_x utm_y md tvd [zone]' + err = 'Trajectory data file not on correct format: "%s".' + err += ' zone is optional.' + raise UserWarning(err % fmt) + return point + +def _parse_point(point): + try: + utm_x = float(point[0]) + utm_y = float(point[1]) + md = float(point[2]) + tvd = float(point[3]) + except ValueError: + raise UserWarning("Error: Failed to extract data from line %s\n" % str(point)) + zone = None + if len(point) > 4: + zone = point[4] + return TrajectoryPoint(utm_x, utm_y, md, tvd, zone) + + +class WellTrajectory: + + def __init__(self, filename): + self._points = [] + if not isfile(filename): + raise IOError('No such file "%s"' % filename) + + with open(filename) as fileH: + for line in fileH.readlines(): + point = _read_point(line) + if not point: + continue + traj = _parse_point(point) + self._points.append(traj) + + def __len__(self): + return len(self._points) + + + def __getitem__(self, index): + if index < 0: + index += len(self) + + return self._points[index] + + + def __repr__(self): + return 'WellTrajectory(len=%d)' % len(self) + + def __str__(self): + return 'WellTrajectory(%s)' % str(self._points) diff --git a/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt b/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt new file mode 100644 index 0000000000..23799c778d --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt @@ -0,0 +1,14 @@ +set(PYTHON_SOURCES + __init__.py + ecl_npv.py + ecl_smspec_node.py + ecl_sum.py + ecl_sum_keyword_vector.py + ecl_sum_node.py + ecl_sum_tstep.py + ecl_sum_vector.py + ecl_cmp.py + ecl_sum_var_type.py +) + +add_python_package("python.ecl.summary" ${PYTHON_INSTALL_PREFIX}/ecl/summary "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/summary/__init__.py b/ThirdParty/Ert/python/ecl/summary/__init__.py new file mode 100644 index 0000000000..946fcf6e8d --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/__init__.py @@ -0,0 +1,35 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +""" + ecl_sum/EclSum: This will load summary results from an ECLIPSE run; + both data file(s) and the SMSPEC file. The EclSum object can be + used as basis for queries on summary vectors. +""" + + +import ecl.util.util +import ecl.util.geometry + +from .ecl_sum_var_type import EclSumVarType +from .ecl_sum_tstep import EclSumTStep +from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from .ecl_sum_keyword_vector import EclSumKeyWordVector +from .ecl_sum_node import EclSumNode +from .ecl_sum_vector import EclSumVector +from .ecl_npv import EclNPV , NPVPriceVector +from .ecl_cmp import EclCmp + diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py new file mode 100644 index 0000000000..ce705d20e7 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py @@ -0,0 +1,184 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.util.util import monkey_the_camel +from ecl.summary import EclSum + +class EclCase(object): + + def __init__(self, case): + self.case = case + + self.grid = None + self.restart = None + self.init = None + self.summary = None + + self.loadSummary() + + + def __contains__(self, key): + return key in self.summary + + + def keys(self): + return self.summary.keys() + + + def wells(self): + return self.summary.wells() + + def load_summary(self): + self.summary = EclSum(self.case) + + + def start_time_equal(self, other): + if self.summary.getDataStartTime() == other.summary.getDataStartTime(): + return True + else: + return False + + def end_time_equal(self, other): + if self.summary.getEndTime() == other.summary.getEndTime(): + return True + else: + return False + + + def cmp_summary_vector(self, other, key, sample=100): + if key in self and key in other: + days_total = min(self.summary.getSimulationLength(), other.summary.getSimulationLength()) + dt = days_total / (sample - 1) + days = [ x * dt for x in range(sample) ] + + ref_data = self.summary.get_interp_vector(key, days_list=days) + test_data = other.summary.get_interp_vector(key, days_list=days) + diff_data = ref_data - test_data + + ref_sum = sum(ref_data) + diff_sum = sum(abs(diff_data)) + return (diff_sum, ref_sum) + else: + raise KeyError("Key:%s was not present in both cases" % key) + + + + + +class EclCmp(object): + + def __init__(self, test_case, ref_case): + """Class to compare to simulation cases with Eclipse formatted result files. + + The first argument is supposed to be the test_case and the + second argument is the reference case. The arguemnts should be + the basenames of the simulation, with an optional path + prefix - an extension is accepted, but will be ignored. + + The constructor will start be calling the method initCheck() + to check that the two cases are 'in the same ballpark'. + """ + self.test_case = EclCase(test_case) + self.ref_case = EclCase(ref_case) + + self.initCheck() + + + def init_check(self): + """A crude initial check to verify that the cases can be meaningfully + compared. + """ + if not self.test_case.startTimeEqual(self.ref_case): + raise ValueError("The two cases do not start at the same time - can not be compared") + + + def has_summary_vector(self, key): + """ + Will check if both test and refernce have @key. + """ + return (key in self.test_case, key in self.ref_case) + + + def end_time_equal(self): + """ + Will check that ref_case and test_case are equally long. + """ + return self.test_case.endTimeEqual(self.ref_case) + + + + def cmp_summary_vector(self, key, sample=100): + """Will compare the summary vectors according to @key. + + The comparison is based on evaluating the integrals: + + I0 = \int R(t) dt + + delta = \int | R(t) - T(t)| dt + + numericall. R(t) is the reference solution and T(t) is + testcase solution. The return value is a tuple: + + (delta, I0) + + So that a natural way to evaluate the check for numerical + equality, based on the relative error could be: + + delta, scale = ecl_cmp.cmpSummaryVector("WWCT:OP_1") + + if delta/scale < 0.0001: + print("Equal enough") + else: + print("Different ..") + + The upper limit for the integrals is: + + max(length(ref_case), length(test_case)) + + meaning that two simulations which don't have the same + end-time will compare as equal if they compare equal in the + common part. If that is not OK you should call the + endTimeEqual() method independently. + """ + return self.test_case.cmpSummaryVector(self.ref_case, key, sample=sample) + + + def test_keys(self): + """ + Will return a list of summary keys in the test case. + """ + return self.test_case.keys() + + + def test_wells(self): + """ + Will return a list of wells keys in the test case. + """ + return self.test_case.wells() + + + +monkey_the_camel(EclCase, 'loadSummary', EclCase.load_summary) +monkey_the_camel(EclCase, 'startTimeEqual', EclCase.start_time_equal) +monkey_the_camel(EclCase, 'endTimeEqual', EclCase.end_time_equal) +monkey_the_camel(EclCase, 'cmpSummaryVector', EclCase.cmp_summary_vector) + +monkey_the_camel(EclCmp, 'initCheck', EclCmp.init_check) +monkey_the_camel(EclCmp, 'hasSummaryVector', EclCmp.has_summary_vector) +monkey_the_camel(EclCmp, 'endTimeEqual', EclCmp.end_time_equal) +monkey_the_camel(EclCmp, 'cmpSummaryVector', EclCmp.cmp_summary_vector) +monkey_the_camel(EclCmp, 'testKeys', EclCmp.test_keys) +monkey_the_camel(EclCmp, 'testWells', EclCmp.test_wells) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_npv.py b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py new file mode 100644 index 0000000000..67363f2669 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py @@ -0,0 +1,220 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'ecl_npv.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import re +import datetime +import numbers + +from ecl.util.util import monkey_the_camel +from ecl.summary import EclSum + + +class NPVParseKey(object): + def __init__(self, eclNPV): + self.baseCase = eclNPV.baseCase + self.NPV = eclNPV + + + def __call__(self, matchObject): + key = matchObject.group(1) + smspecNode = self.baseCase.smspec_node(key) + if smspecNode.isTotal(): + var = key.replace(":", "_") + self.NPV.addKey(key, var) + return var + "[i]" + else: + raise ValueError("Sorry - the key: %s is not a total key - aborting" % key) + + +class NPVPriceVector(object): + def __init__(self, argList): + self.dateList = [] + if isinstance(argList, list): + for item in argList: + if isinstance(item, tuple) and len(item) == 2: + self.addItem(item) + else: + raise ValueError("Each element in list must be tuple with two elements") + else: + raise ValueError("Constructor argument must be list") + + + + def add_item(self, item): + dateItem = item[0] + try: + year = dateItem.year + month = dateItem.month + day = dateItem.day + date = datetime.date(year, month, day) + except AttributeError: + try: + tmp = re.split("[ .-/]", dateItem) + day = int(tmp[0]) + month = int(tmp[1]) + year = int(tmp[2]) + + date = datetime.date(year, month, day) + except Exception: + raise ValueError("First element was invalid date item") + + + if len(self.dateList): + prevItem = self.dateList[-1] + if prevItem[0] >= date: + raise ValueError("The dates must be in a strictly increasing order") + + value = item[1] + if isinstance(value, numbers.Real) or callable(value): + self.dateList.append((date, value)) + else: + raise ValueError("The value argument must be a scalar number or callable") + + @staticmethod + def assert_date(date): + try: + year = date.year + month = date.month + day = date.day + date = datetime.date(year, month, day) + + return date + except AttributeError: + return date.date() + + + + def eval_date(self, dateItem, date): + value = dateItem[1] + if callable(value): + td = date - dateItem[0] + return value(td.days) + else: + return value + + + def eval(self, date): + date = self.assertDate(date) + startDate = self.dateList[0][0] + if date >= startDate: + endDate = self.dateList[-1][0] + if date >= endDate: + return self.evalDate(self.dateList[-1], date) + else: + index1 = 0 + index2 = len(self.dateList) - 1 + while True: + if (index2 - index1) == 1: + index = index1 + break + + index = (index1 + index2) >> 1 + item = self.dateList[index] + if date >= item[0]: + index1 = index + else: + index2 = index + return self.evalDate(self.dateList[index], date) + else: + raise ValueError("Input date:%s before start of vector" % date) + + + + + +class EclNPV(object): + sumKeyRE = re.compile("[[]([\w:,]+)[]]") + + + def __init__(self, baseCase): + sum = EclSum(baseCase) + if sum: + self.baseCase = sum + else: + raise Error("Failed to open ECLIPSE sumamry case:%s" % baseCase) + self.expression = None + self.keyList = {} + self.start = None + self.end = None + self.interval = "1Y" + + + def eval(self): + if self.expression is None: + raise ValueError("Can not eval with an expression to evaluate") + pass + + + def get_expression(self): + return self.expression + + + def set_expression(self, expression): + self.compiled_expr = self.compile(expression) + self.expression = expression + + + def get_key_list(self): + return self.keyList.keys() + + + def add_key(self, key, var): + self.keyList[key] = var + + + def parse_expression(self, expression): + self.keyList = {} + if expression.count("[") != expression.count("]"): + raise ValueError("Expression:%s invalid - not matching [ and ]" % expression) + + replaceKey = NPVParseKey(self) + parsedExpression = self.sumKeyRE.sub(replaceKey, expression) + return parsedExpression + + + def compile(self, expression): + parsedExpression = self.parseExpression(expression) + self.code = "trange = self.baseCase.timeRange(self.start, self.end, self.interval)\n" + for (key,var) in self.keyList.items(): + self.code += "%s = self.baseCase.blockedProduction(\"%s\", trange)\n" % (var, key) + + self.code += "npv = 0\n" + self.code += """ +for i in range(len(trange) - 1): + npv += %s +varDict[\"npv\"] = npv +""" % parsedExpression + + + + def eval_npv(self): + byteCode = compile(self.code, "", 'exec') + varDict = {} + eval(byteCode) + return varDict["npv"] + + + +monkey_the_camel(NPVPriceVector, 'addItem', NPVPriceVector.add_item) +monkey_the_camel(NPVPriceVector, 'assertDate', NPVPriceVector.assert_date, staticmethod) +monkey_the_camel(NPVPriceVector, 'evalDate', NPVPriceVector.eval_date) + +monkey_the_camel(EclNPV, 'getExpression', EclNPV.get_expression) +monkey_the_camel(EclNPV, 'setExpression', EclNPV.set_expression) +monkey_the_camel(EclNPV, 'getKeyList', EclNPV.get_key_list) +monkey_the_camel(EclNPV, 'addKey', EclNPV.add_key) +monkey_the_camel(EclNPV, 'parseExpression', EclNPV.parse_expression) +monkey_the_camel(EclNPV, 'evalNPV', EclNPV.eval_npv) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py new file mode 100644 index 0000000000..291b5ec949 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py @@ -0,0 +1,196 @@ +# Copyright (C) 2016 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype + + +class EclSMSPECNode(BaseCClass): + """ + Small class with some meta information about a summary variable. + + The summary variables have different attributes, like if they + represent a total quantity, a rate or a historical quantity. These + quantities, in addition to the underlying values like WGNAMES, + KEYWORD and NUMS taken from the the SMSPEC file are stored in this + structure. + """ + TYPE_NAME = "smspec_node" + _node_is_total = EclPrototype("bool smspec_node_is_total( smspec_node )") + _node_is_historical = EclPrototype("bool smspec_node_is_historical( smspec_node )") + _node_is_rate = EclPrototype("bool smspec_node_is_rate( smspec_node )") + _node_unit = EclPrototype("char* smspec_node_get_unit( smspec_node )") + _node_wgname = EclPrototype("char* smspec_node_get_wgname( smspec_node )") + _node_keyword = EclPrototype("char* smspec_node_get_keyword( smspec_node )") + _node_num = EclPrototype("int smspec_node_get_num( smspec_node )") + _node_need_num = EclPrototype("bool smspec_node_need_nums( smspec_node )") + _gen_key1 = EclPrototype("char* smspec_node_get_gen_key1( smspec_node )") + _gen_key2 = EclPrototype("char* smspec_node_get_gen_key2( smspec_node )") + _var_type = EclPrototype("ecl_sum_var_type smspec_node_get_var_type( smspec_node )") + _cmp = EclPrototype("int smspec_node_cmp( smspec_node , smspec_node)") + + def __init__(self): + super(EclSMSPECNode, self).__init__(0) # null pointer + raise NotImplementedError("Class can not be instantiated directly!") + + def cmp(self, other): + if isinstance(other, EclSMSPECNode): + return self._cmp( other ) + else: + raise TypeError("Other argument must be of type EclSMSPECNode") + + + def __lt__(self , other): + return self.cmp( other ) < 0 + + + def __gt__(self , other): + return self.cmp( other ) > 0 + + + def __eq__(self , other): + return self.cmp( other ) == 0 + + + def __hash__(self , other): + return hash(self._gen_key1( )) + + + @property + def unit(self): + """ + Returns the unit of this node as a string. + """ + return self._node_unit( ) + + @property + def wgname(self): + """ + Returns the WGNAME property for this node. + + Many variables do not have the WGNAME property, i.e. the field + related variables like FOPT and the block properties like + BPR:10,10,10. For these variables the function will return + None, and not the ECLIPSE dummy value: ":+:+:+:+". + """ + return self._node_wgname( ) + + + @property + def keyword(self): + """ + Returns the KEYWORD property for this node. + + The KEYWORD property is the main classification property in + the ECLIPSE SMSPEC file. The properties of a variable can be + read from the KEWYORD value; see table 3.4 in the ECLIPSE file + format reference manual. + """ + return self._node_keyword( ) + + @property + def num(self): + return self.getNum( ) + + def get_key1(self): + """ + Returns the primary composite key, i.e. like 'WOPR:OPX' for this + node. + """ + return self._gen_key1( ) + + + def get_key2(self): + """Returns the secondary composite key for this node. + + Most variables have only one composite key, but in particular + nodes which involve (i,j,k) coordinates will contain two + forms: + + getKey1() => "BPR:10,11,6" + getKey2() => "BPR:52423" + + Where the '52423' in getKey2() corresponds to i + j*nx + + k*nx*ny. + """ + return self._gen_key2( ) + + + def var_type(self): + return self._var_type( ) + + + def get_num(self): + """ + Returns the NUMS value for this keyword; or None. + + Many of the summary keywords have an integer stored in the + vector NUMS as an attribute, i.e. the block properties have + the global index of the cell in the nums vector. If the + variable in question makes use of the NUMS value this property + will return the value, otherwise it will return None: + + sum.smspec_node("FOPT").num => None + sum.smspec_node("BPR:1000").num => 1000 + + """ + if self._node_need_num( ): + return self._node_num( ) + else: + return None + + def is_rate(self): + """ + Will check if the variable in question is a rate variable. + + The conecpt of rate variabel is important (internally) when + interpolation values to arbitrary times. + """ + return self._node_is_rate() + + + def is_total(self): + """ + Will check if the node corresponds to a total quantity. + + The question of whether a variable corresponds to a 'total' + quantity or not can be interesting for e.g. interpolation + purposes. The actual question whether a quantity is total or + not is based on a hardcoded list in smspec_node_set_flags() in + smspec_node.c; this list again is based on the tables 2.7 - + 2.11 in the ECLIPSE fileformat documentation. + """ + return self._node_is_total( ) + + + def is_historical(self): + """ + Checks if the key corresponds to a historical variable. + + The check is only based on the last character; all variables + ending with 'H' are considered historical. + """ + return self._node_is_historical( ) + + +monkey_the_camel(EclSMSPECNode, 'getKey1', EclSMSPECNode.get_key1) +monkey_the_camel(EclSMSPECNode, 'getKey2', EclSMSPECNode.get_key2) +monkey_the_camel(EclSMSPECNode, 'varType', EclSMSPECNode.var_type) +monkey_the_camel(EclSMSPECNode, 'getNum', EclSMSPECNode.get_num) +monkey_the_camel(EclSMSPECNode, 'isRate', EclSMSPECNode.is_rate) +monkey_the_camel(EclSMSPECNode, 'isTotal', EclSMSPECNode.is_total) +monkey_the_camel(EclSMSPECNode, 'isHistorical', EclSMSPECNode.is_historical) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py new file mode 100644 index 0000000000..1b7c79568a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py @@ -0,0 +1,1393 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Module for loading and querying summary data. + +The low-level organisation of summary data is extensively documented +in the C source files ecl_sum.c, ecl_smspec.c and ecl_sum_data in the +libecl/src directory. +""" + + +import numpy +import datetime +import os.path + +# Observe that there is some convention conflict with the C code +# regarding order of arguments: The C code generally takes the time +# index as the first argument and the key/key_index as second +# argument. In the python code this order has been reversed. +from cwrap import BaseCClass, CFILE + +from ecl.util.util import monkey_the_camel +from ecl.util.util import StringList, CTime, DoubleVector, TimeVector, IntVector + +from ecl.summary import EclSumTStep +from ecl.summary import EclSumVarType +from ecl.summary.ecl_sum_vector import EclSumVector +from ecl.summary.ecl_smspec_node import EclSMSPECNode +from ecl import EclPrototype, EclUnitTypeEnum +#, EclSumKeyWordVector + + + + +#import ecl.ecl_plot.sum_plot as sum_plot + +# The date2num function is a verbatim copy of the _to_ordinalf() +# function from the matplotlib.dates module. Inserted here only to +# avoid importing the full matplotlib library. The date2num +# implementation could be replaced with: +# +# from matplotlib.dates import date2num + + +HOURS_PER_DAY = 24.0 +MINUTES_PER_DAY = 60 * HOURS_PER_DAY +SECONDS_PER_DAY = 60 * MINUTES_PER_DAY +MUSECONDS_PER_DAY = 1e6 * SECONDS_PER_DAY + +def date2num(dt): + """ + Convert a python datetime instance to UTC float days. + + Convert datetime to the Gregorian date as UTC float days, + preserving hours, minutes, seconds and microseconds, return value + is a float. The function is a verbatim copy of the _to_ordinalf() + function from the matplotlib.dates module. + """ + + if hasattr(dt, 'tzinfo') and dt.tzinfo is not None: + delta = dt.tzinfo.utcoffset(dt) + if delta is not None: + dt -= delta + + base = float(dt.toordinal()) + if hasattr(dt, 'hour'): + base += (dt.hour/HOURS_PER_DAY + + dt.minute/MINUTES_PER_DAY + + dt.second/SECONDS_PER_DAY + + dt.microsecond/MUSECONDS_PER_DAY) + return base + + +class EclSum(BaseCClass): + TYPE_NAME = "ecl_sum" + _fread_alloc_case = EclPrototype("void* ecl_sum_fread_alloc_case__(char*, char*, bool)", bind=False) + _fread_alloc = EclPrototype("void* ecl_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False) + _create_restart_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_restart_writer2(char*, char*, int, bool, bool, char*, time_t, bool, int, int, int)", bind = False) + _create_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_writer(char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False) + _resample = EclPrototype("ecl_sum_obj ecl_sum_alloc_resample( ecl_sum, char*, time_t_vector)") + _iiget = EclPrototype("double ecl_sum_iget(ecl_sum, int, int)") + _free = EclPrototype("void ecl_sum_free(ecl_sum)") + _data_length = EclPrototype("int ecl_sum_get_data_length(ecl_sum)") + _scale_vector = EclPrototype("void ecl_sum_scale_vector(ecl_sum, int, double)") + _shift_vector = EclPrototype("void ecl_sum_shift_vector(ecl_sum, int, double)") + _iget_sim_days = EclPrototype("double ecl_sum_iget_sim_days(ecl_sum, int) ") + _iget_report_step = EclPrototype("int ecl_sum_iget_report_step(ecl_sum, int) ") + _iget_mini_step = EclPrototype("int ecl_sum_iget_mini_step(ecl_sum, int) ") + _iget_sim_time = EclPrototype("time_t ecl_sum_iget_sim_time(ecl_sum, int) ") + _get_report_end = EclPrototype("int ecl_sum_iget_report_end(ecl_sum, int)") + _get_general_var = EclPrototype("double ecl_sum_get_general_var(ecl_sum, int, char*)") + _get_general_var_index = EclPrototype("int ecl_sum_get_general_var_params_index(ecl_sum, char*)") + _get_general_var_from_sim_days = EclPrototype("double ecl_sum_get_general_var_from_sim_days(ecl_sum, double, char*)") + _get_general_var_from_sim_time = EclPrototype("double ecl_sum_get_general_var_from_sim_time(ecl_sum, time_t, char*)") + _solve_days = EclPrototype("double_vector_obj ecl_sum_alloc_days_solution(ecl_sum, char*, double, bool)") + _solve_dates = EclPrototype("time_t_vector_obj ecl_sum_alloc_time_solution(ecl_sum, char*, double, bool)") + _get_first_gt = EclPrototype("int ecl_sum_get_first_gt(ecl_sum, int, double)") + _get_first_lt = EclPrototype("int ecl_sum_get_first_lt(ecl_sum, int, double)") + _get_start_date = EclPrototype("time_t ecl_sum_get_start_time(ecl_sum)") + _get_end_date = EclPrototype("time_t ecl_sum_get_end_time(ecl_sum)") + _get_last_report_step = EclPrototype("int ecl_sum_get_last_report_step(ecl_sum)") + _get_first_report_step = EclPrototype("int ecl_sum_get_first_report_step(ecl_sum)") + _select_matching_keys = EclPrototype("void ecl_sum_select_matching_general_var_list(ecl_sum, char*, stringlist)") + _has_key = EclPrototype("bool ecl_sum_has_general_var(ecl_sum, char*)") + _check_sim_time = EclPrototype("bool ecl_sum_check_sim_time(ecl_sum, time_t)") + _check_sim_days = EclPrototype("bool ecl_sum_check_sim_days(ecl_sum, double)") + _sim_length = EclPrototype("double ecl_sum_get_sim_length(ecl_sum)") + _get_first_day = EclPrototype("double ecl_sum_get_first_day(ecl_sum)") + _get_data_start = EclPrototype("time_t ecl_sum_get_data_start(ecl_sum)") + _get_unit = EclPrototype("char* ecl_sum_get_unit(ecl_sum, char*)") + _get_restart_case = EclPrototype("ecl_sum_ref ecl_sum_get_restart_case(ecl_sum)") + _get_restart_step = EclPrototype("int ecl_sum_get_restart_step(ecl_sum)") + _get_simcase = EclPrototype("char* ecl_sum_get_case(ecl_sum)") + _get_unit_system = EclPrototype("ecl_unit_enum ecl_sum_get_unit_system(ecl_sum)") + _get_base = EclPrototype("char* ecl_sum_get_base(ecl_sum)") + _get_path = EclPrototype("char* ecl_sum_get_path(ecl_sum)") + _get_abs_path = EclPrototype("char* ecl_sum_get_abs_path(ecl_sum)") + _get_report_step_from_time = EclPrototype("int ecl_sum_get_report_step_from_time(ecl_sum, time_t)") + _get_report_step_from_days = EclPrototype("int ecl_sum_get_report_step_from_days(ecl_sum, double)") + _get_report_time = EclPrototype("time_t ecl_sum_get_report_time(ecl_sum, int)") + _fwrite_sum = EclPrototype("void ecl_sum_fwrite(ecl_sum)") + _set_case = EclPrototype("void ecl_sum_set_case(ecl_sum, char*)") + _alloc_time_vector = EclPrototype("time_t_vector_obj ecl_sum_alloc_time_vector(ecl_sum, bool)") + _alloc_data_vector = EclPrototype("double_vector_obj ecl_sum_alloc_data_vector(ecl_sum, int, bool)") + _get_var_node = EclPrototype("smspec_node_ref ecl_sum_get_general_var_node(ecl_sum, char*)") + _create_well_list = EclPrototype("stringlist_obj ecl_sum_alloc_well_list(ecl_sum, char*)") + _create_group_list = EclPrototype("stringlist_obj ecl_sum_alloc_group_list(ecl_sum, char*)") + _add_variable = EclPrototype("smspec_node_ref ecl_sum_add_var(ecl_sum, char*, char*, int, char*, double)") + _add_tstep = EclPrototype("ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)") + _export_csv = EclPrototype("void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)") + _identify_var_type = EclPrototype("ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind = False) + + + + def __init__(self, load_case, join_string=":", include_restart=True): + """ + Loads a new EclSum instance with summary data. + + Loads a new summary results from the ECLIPSE case given by + argument @load_case; @load_case should be the basename of the ECLIPSE + simulation you want to load. @load_case can contain a leading path + component, and also an extension - the latter will be ignored. + + The @join_string is the string used when combining elements + from the WGNAMES, KEYWORDS and NUMS vectors into a composit + key; with @join_string == ":" the water cut in well OP_1 will + be available as "WWCT:OP_1". + + If the @include_restart parameter is set to true the summary + loader will, in the case of a restarted ECLIPSE simulation, + try to load summary results also from the restarted case. + """ + if not load_case: + raise ValueError('load_case must be the basename of the simulation') + c_pointer = self._fread_alloc_case(load_case, join_string, include_restart) + if c_pointer is None: + raise IOError("Failed to create summary instance from argument:%s" % load_case) + + super(EclSum, self).__init__(c_pointer) + self.__private_init() + self._load_case = load_case + + + @classmethod + def load(cls, smspec_file, unsmry_file, key_join_string = ":", include_restart = True): + if not os.path.isfile( smspec_file ): + raise IOError("No such file: %s" % smspec_file) + + if not os.path.isfile( unsmry_file ): + raise IOError("No such file: %s" % unsmry_file ) + + data_files = StringList( ) + data_files.append( unsmry_file ) + c_ptr = cls._fread_alloc(smspec_file, data_files, key_join_string, include_restart) + if c_ptr is None: + raise IOError("Failed to create summary instance") + + ecl_sum = cls.createPythonObject( c_ptr ) + ecl_sum._load_case = smspec_file + return ecl_sum + + + @classmethod + def createCReference(cls, c_pointer, parent=None): + result = super(EclSum, cls).createCReference(c_pointer, parent) + if not result is None: + result.__private_init() + return result + + + @classmethod + def createPythonObject(cls, c_pointer): + result = super(EclSum, cls).createPythonObject(c_pointer) + result.__private_init() + return result + + + @classmethod + def var_type(cls, keyword): + return cls._identify_var_type(keyword) + + + @staticmethod + def writer(case, + start_time, + nx,ny,nz, + fmt_output=False, + unified=True, + time_in_days=True, + key_join_string=":"): + """ + The writer is not generally usable. + @rtype: EclSum + """ + + start = CTime(start_time) + + smry = EclSum._create_writer(case, + fmt_output, + unified, + key_join_string, + start, + time_in_days, + nx, + ny, + nz) + smry._load_case = 'writer' + return smry + + + @staticmethod + def restart_writer(case, + restart_case, + restart_step, + start_time, + nx,ny,nz, + fmt_output=False, + unified=True, + time_in_days=True, + key_join_string=":"): + """ + The writer is not generally usable. + @rtype: EclSum + """ + + start = CTime(start_time) + + smry = EclSum._create_restart_writer(case, + restart_case, + restart_step, + fmt_output, + unified, + key_join_string, + start, + time_in_days, + nx, + ny, + nz) + smry._load_case = 'restart_writer' + return smry + + def add_variable(self, variable, wgname=None, num=0, unit="None", default_value=0): + return self._add_variable(variable, wgname, num, unit, default_value).setParent(parent=self) + + + def add_t_step(self, report_step, sim_days): + """ @rtype: EclSumTStep """ + # report_step int + if not isinstance(report_step, int): + raise TypeError('Parameter report_step should be int, was %r' % report_step) + try: + float(sim_days) + except TypeError: + raise TypeError('Parameter sim_days should be float, was %r' % sim_days) + + sim_seconds = sim_days * 24 * 60 * 60 + + return self._add_tstep(report_step, sim_seconds).setParent(parent=self) + + + + def __private_init(self): + # Initializing the time vectors + length = self.length + self.__dates = [0] * length + self.__report_step = numpy.zeros(length, dtype=numpy.int32) + self.__mini_step = numpy.zeros(length, dtype=numpy.int32) + self.__days = numpy.zeros(length) + self.__mpl_dates = numpy.zeros(length) + + for i in range(length): + self.__days[i] = self._iget_sim_days(i) + self.__dates[i] = self.iget_date(i) + self.__report_step[i] = self._iget_report_step(i) + self.__mini_step[i] = self._iget_mini_step(i) + self.__mpl_dates[i] = date2num(self.__dates[i]) + + index_list = self.report_index_list() + + length = len(index_list) - index_list.count(-1) + self.__datesR = [0] * length + self.__report_stepR = numpy.zeros(length, dtype=numpy.int32) + self.__mini_stepR = numpy.zeros(length, dtype=numpy.int32) + self.__daysR = numpy.zeros(length) + self.__mpl_datesR = numpy.zeros(length) + + # Slightly hysterical heuristics to accomoate for the + # situation where there are holes in the report steps series; + # when a report step is completely missing there will be -1 + # entries in the index_list. + i1 = 0 + for i0 in range(length): + while True: + time_index = index_list[i1] + i1 += 1 + if time_index >= 0: + break + + self.__daysR[i0] = self._iget_sim_days(time_index) + self.__datesR[i0] = self.iget_date(time_index) + self.__report_stepR[i0] = self._iget_report_step(time_index) + self.__mini_stepR[i0] = self._iget_mini_step(time_index) + self.__mpl_datesR[i0] = date2num(self.__datesR[i0]) + + + def get_vector(self, key, report_only=False): + """ + Will return EclSumVector according to @key. + + Will raise exception KeyError if the summary object does not + have @key. + """ + self.assertKeyValid(key) + if report_only: + return EclSumVector(self, key, report_only=True) + else: + return EclSumVector(self, key) + + + def report_index_list(self): + """ + Internal function for working with report_steps. + """ + first_report = self.first_report + last_report = self.last_report + index_list = IntVector() + for report_step in range(first_report, last_report + 1): + time_index = self._get_report_end(report_step) + index_list.append(time_index) + return index_list + + + + def wells(self, pattern=None): + """ + Will return a list of all the well names in case. + + If the pattern variable is different from None only wells + matching the pattern will be returned; the matching is based + on fnmatch(), i.e. shell style wildcards. + """ + return self._create_well_list(pattern) + + + def groups(self, pattern=None): + """ + Will return a list of all the group names in case. + + If the pattern variable is different from None only groups + matching the pattern will be returned; the matching is based + on fnmatch(), i.e. shell style wildcards. + """ + return self._create_group_list(pattern) + + + def get_values(self, key, report_only=False): + """ + Will return numpy vector of all values according to @key. + + If the optional argument report_only is true only the values + corresponding to report steps are included. The method is + also available as the 'values' property of an EclSumVector + instance. + """ + if self.has_key(key): + key_index = self._get_general_var_index(key) + if report_only: + index_list = self.report_index_list() + values = numpy.zeros(len(index_list)) + for i in range(len(index_list)): + time_index = index_list[i] + values[i] = self._iiget(time_index, key_index) + else: + length = self._data_length() + values = numpy.zeros(length) + for i in range(length): + values[i] = self._iiget(i, key_index) + + return values + else: + raise KeyError("Summary object does not have key:%s" % key) + + + def get_key_index(self, key): + """ + Lookup parameter index of @key. + + All the summary keys identified in the SMSPEC file have a + corresponding index which is used internally. This function + will return that index for input key @key, this can then be + used in subsequent calls to e.g. the iiget() method. This is a + minor optimization in the case of many lookups of the same + key: + + sum = ecl.EclSum(case) + key_index = sum.get_key_index(key) + for time_index in range(sum.length): + value = sum.iiget(time_index, key_index) + + Quite low-level function, should probably rather use a + EclSumVector based function? + """ + index = self._get_general_var_index(key) + if index >= 0: + return index + else: + return None + + + def get_last_value(self, key): + """ + Will return the last value corresponding to @key. + + Typically useful to get the total production at end of + simulation: + + total_production = sum.last_value("FOPT") + + The alternative method 'last' will return a EclSumNode + instance with some extra time related information. + """ + return self[key].last_value + + def get_last(self, key): + """ + Will return the last EclSumNode corresponding to @key. + + If you are only interested in the final value, you can use the + get_last_value() method. + """ + return self[key].last + + + def iiget(self, time_index, key_index): + """ + Lookup a summary value based on naive @time_index and + @key_index. + + The iiget() method will lookup a summary value based on the + 'time' value give by @time_index (i.e. naive counting of + time steps starting at zero), and a key index given by + @key_index. The @key_index value will typically be obtained + with the get_key_index() method first. + + This is a quite low level function, in most cases it will be + natural to go via e.g. an EclSumVector instance. + """ + return self._iiget(time_index, key_index) + + + def iget(self, key, time_index): + """ + Lookup summary value based on @time_index and key. + + The @time_index value should be an integer [0,num_steps) and + @key should be string key. To get all the water cut values + from a well: + + for time_index in range(sum.length): + wwct = sum.iget(time_index, "WWCT:W5") + + This is a quite low level function, in most cases it will be + natural to go via e.g. an EclSumVector instance. + """ + return self._get_general_var(time_index, key) + + + def __len__(self): + """ + The number of timesteps in the dataset; the return when evaluating + len(case). + + """ + return self._data_length() + + + def __contains__(self, key): + if self._has_key(key): + return True + else: + return False + + def assert_key_valid(self, key): + if not key in self: + raise KeyError("The summary key:%s was not recognized" % key) + + def __iter__(self): + return iter(self.keys()) + + def __getitem__(self, key): + """ + Implements [] operator - @key should be a summary key. + + The returned value will be a EclSumVector instance. + """ + return self.get_vector(key) + + def scale_vector(self, key, scalar): + """ecl_sum.scaleVector("WOPR:OPX", 0.78) + will scale all the elements in the 'WOPR:OPX' vector with 0.78. + """ + if not key in self: + raise KeyError("Summary object does not have key:%s" % key) + + key_index = self._get_general_var_index(key) + self._scale_vector(key_index, float(scalar)) + + def shift_vector(self, key, addend): + """ecl_sum.shiftVector("WOPR:OPX", 0.78) + will shift (add) all the elements in the 'WOPR:OPX' vector with 0.78. + """ + if not key in self: + raise KeyError("Summary object does not have key:%s" % key) + key_index = self._get_general_var_index(key) + self._shift_vector(key_index, float(addend)) + + def check_sim_time(self, date): + """ + Will check if the input date is in the time span [sim_start, sim_end]. + """ + if not isinstance(date, CTime): + date = CTime(date) + return self._check_sim_time(date) + + def get_interp_direct(self,key, date): + + if not isinstance(date, CTime): + date = CTime(date) + return self._get_general_var_from_sim_time(date, key) + + def get_interp(self, key, days=None, date=None): + """ + Will lookup vector @key at time given by @days or @date. + + Requiers exactly one input argument @days or @date; will raise + exception ValueError if this is not satisfied. + + The method will check that the time argument is within the + time limits of the simulation; if else the method will raise + exception ValueError. + + Also available as method get_interp() on the EclSumVector + class. + """ + self.assertKeyValid(key) + if days is None and date is None: + raise ValueError("Must supply either days or date") + + if days is None: + t = CTime(date) + if self.check_sim_time(t): + return self._get_general_var_from_sim_time(t, key) + else: + + raise ValueError("date:%s is outside range of simulation data" % date) + elif date is None: + if self._check_sim_days(days): + return self._get_general_var_from_sim_days(days, key) + else: + raise ValueError("days:%s is outside range of simulation: [%g,%g]" % (days, self.first_day, self.sim_length)) + else: + raise ValueError("Must supply either days or date") + + + def get_interp_row(self, key_list, sim_time, invalid_value = -1): + ctime = CTime(sim_time) + data = DoubleVector( initial_size = len(key_list) , default_value = invalid_value) + EclSum._get_interp_vector(self, ctime, key_list, data) + return data + + + def time_range(self, start=None, end=None, interval="1Y", num_timestep = None, extend_end=True): + """Will create a vector of timepoints based on the current case. + + By default the timepoints will be regularly sampled based on the + interval given by the @interval string. Alternatively the total number + of timesteps can be specified, if the @num_timestep option is specified + that will take presedence. + """ + (num, timeUnit) = TimeVector.parseTimeUnit(interval) + + if start is None: + start = self.getDataStartTime() + else: + if isinstance(start, datetime.date): + start = datetime.datetime(start.year, start.month, start.day, 0, 0, 0) + + if start < self.getDataStartTime(): + start = self.getDataStartTime() + + + if end is None: + end = self.getEndTime() + else: + if isinstance(end, datetime.date): + end = datetime.datetime(end.year, end.month, end.day, 0, 0, 0) + + if end > self.getEndTime(): + end = self.getEndTime() + + if end < start: + raise ValueError("Invalid time interval start after end") + + + if not num_timestep is None: + return TimeVector.create_linear(CTime(start), CTime(end), num_timestep) + + range_start = start + range_end = end + if not timeUnit == "d": + year1 = start.year + year2 = end.year + month1 = start.month + month2 = end.month + day1 = start.day + day2 = end.day + if extend_end: + if timeUnit == 'm': + if day2 > 1: + month2 += 1 + if month2 == 13: + year2 += 1 + month2 = 1 + elif timeUnit == "y": + month1 = 1 + if year2 > 1 or day2 > 1: + year2 += 1 + month2 = 1 + day1 = 1 + day2 = 1 + + range_start = datetime.date(year1, month1, day1) + range_end = datetime.date(year2, month2, day2) + + trange = TimeVector.createRegular(range_start, range_end, interval) + + # If the simulation does not start at the first of the month + # the start value will be before the simulation start; we + # manually shift the first element in the trange to the start + # value; the same for the end of list. + + if trange[-1] < end: + if extend_end: + trange.appendTime(num, timeUnit) + else: + trange.append(end) + + data_start = self.getDataStartTime() + if trange[0] < data_start: + trange[0] = CTime(data_start) + + return trange + + + + def blocked_production(self, totalKey, timeRange): + node = self.smspec_node(totalKey) + if node.isTotal(): + total = DoubleVector() + for t in timeRange: + if t < CTime(self.start_time): + total.append(0) + elif t >= CTime(self.end_time): + total.append(self.get_last_value(totalKey)) + else: + total.append(self.get_interp(totalKey, date=t)) + tmp = total << 1 + total.pop() + return tmp - total + else: + raise TypeError("The blockedProduction method must be called with one of the TOTAL keys like e.g. FOPT or GWIT") + + + def get_report(self, date=None, days=None): + """ + Will return the report step corresponding to input @date or @days. + + If the input argument does not correspond to any report steps + the function will return -1. Observe that the function + requires strict equality. + """ + if date: + if days: + raise ValueError("Must supply either days or date") + step = self._get_report_step_from_time(CTime(date)) + elif days: + step = self._get_report_step_from_days(days) + + return step + + + def get_report_time(self, report): + """ + Will return the datetime corresponding to the report_step @report. + """ + return CTime(self._get_report_time(report)).date() + + + def get_interp_vector(self, key, days_list=None, date_list=None): + """ + Will return numpy vector with interpolated values. + + Requiers exactly one input argument @days or @date; will raise + exception ValueError if this is not satisfied. + + The method will check that the time arguments are within the + time limits of the simulation; if else the method will raise + exception ValueError. + + Also available as method get_interp_vector() on the + EclSumVector class. + """ + self.assertKeyValid(key) + if days_list: + if date_list: + raise ValueError("Must supply either days_list or date_list") + else: + vector = numpy.zeros(len(days_list)) + sim_length = self.sim_length + sim_start = self.first_day + index = 0 + for days in days_list: + if (days >= sim_start) and (days <= sim_length): + vector[index] = self._get_general_var_from_sim_days(days, key) + else: + raise ValueError("Invalid days value") + index += 1 + elif date_list: + start_time = self.data_start + end_time = self.end_date + vector = numpy.zeros(len(date_list)) + index = 0 + + for date in date_list: + ct = CTime(date) + if start_time <= ct <= end_time: + vector[index] = self._get_general_var_from_sim_time(ct, key) + else: + raise ValueError("Invalid date value") + index += 1 + else: + raise ValueError("Must supply either days_list or date_list") + return vector + + + def get_from_report(self, key, report_step): + """ + Return summary value of @key at time @report_step. + """ + time_index = self._get_report_end(report_step) + return self._get_general_var(time_index, key) + + + def has_key(self, key): + """ + Check if summary object has key @key. + """ + return key in self + + + def smspec_node(self, key): + """ + Will return a EclSMSPECNode instance corresponding to @key. + + The returned EclSMPECNode instance can then be used to ask for + various properties of the variable; i.e. if it is a rate + variable, what is the unit, if it is a total variable and so + on. + """ + if self.has_key(key): + node = self._get_var_node(key).setParent(self) + return node + else: + raise KeyError("Summary case does not have key:%s" % key) + + + def unit(self, key): + """ + Will return the unit of @key. + """ + node = self.smspec_node(key) + return node.unit + + + @property + def unit_system(self): + """ + Will return the unit system in use for this case. + """ + return self._get_unit_system() + + @property + def case(self): + """ + Will return the case name of the current instance - optionally including path. + """ + return self._get_simcase() + + + @property + def restart_step(self): + """ + Will return the report step this case has been restarted from, or -1. + """ + return self._get_restart_step() + + + @property + def restart_case(self): + restart_case = self._get_restart_case() + if restart_case: + restart_case.setParent(parent=self) + return restart_case + + + @property + def path(self): + """ + Will return the path to the current case. Will be None for + case in CWD. See also abs_path. + """ + return self._get_path() + + @property + def base(self): + """ + Will return the basename of the current case - no path. + """ + return self._get_base() + + @property + def abs_path(self): + """ + Will return the absolute path to the current case. + """ + return self._get_abs_path() + + #----------------------------------------------------------------- + # Here comes functions for getting vectors of the time + # dimension. All the get_xxx() functions have an optional boolean + # argument @report_only. If this argument is set to True the + # functions will return time vectors only corresponding to the + # report times. + # + # In addition to the get_xxx() methods there are properties with + # the same name (excluding the 'get'); these properties correspond + # to an get_xxx() invocation with optional argument report_only + # set to False (i.e. the defualt). + + @property + def days(self): + """ + Will return a numpy vector of simulations days. + """ + return self.get_days(False) + + def get_days(self, report_only=False): + """ + Will return a numpy vector of simulations days. + + If the optional argument @report_only is set to True, only + 'days' values corresponding to report steps will be included. + """ + if report_only: + return self.__daysR + else: + return self.__days + + @property + def dates(self): + """ + Will return a list of simulation dates. + + The list will be an ordinary Python list, and the dates will + be in terms ordinary Python datetime values. + """ + return self.get_dates(False) + + def get_dates(self, report_only=False): + """ + Will return a list of simulation dates. + + The list will be an ordinary Python list, and the dates will + be in terms ordinary Python datetime values. If the optional + argument @report_only is set to True, only dates corresponding + to report steps will be included. + """ + if report_only: + return self.__datesR + else: + return self.__dates + + @property + def mpl_dates(self): + """ + Will return a numpy vector of dates ready for matplotlib + + The content of the vector are dates in matplotlib format, + i.e. floats - generated by the date2num() function at the top + of this file. + """ + return self.get_mpl_dates(False) + + def get_mpl_dates(self, report_only=False): + """ + Will return a numpy vector of dates ready for matplotlib + + If the optional argument @report_only is set to True, only + dates values corresponding to report steps will be + included. The content of the vector are dates in matplotlib + format, i.e. floats - generated by the date2num() function at + the top of this file. + """ + if report_only: + return self.__mpl_datesR + else: + return self.__mpl_dates + + @property + def mini_step(self): + """ + Will return a a python list of ministep values. + + Will return a Python list of ministep values from this summary + case; the ministep values are the internal indexing of + timesteps provided by the reservoir simulator. In normal cases + this will be: [0,1,2,3,4,5,....], but in the case of restarted + simulations it can start at a higher value, and there can also + be 'holes' in the series if 'RPTONLY' has been used in THE + ECLIPSE datafile. + """ + return self.get_mini_step(False) + + def get_mini_step(self, report_only=False): + """ + Will return a a python list of ministep values. + + If the optional argument @report_only is set to True, only + dates values corresponding to report steps will be + included. See documentation of property: 'mini_step' for + further documentation. + """ + if report_only: + return self.__mini_stepR + else: + return self.__mini_step + + + @property + def report_step(self): + """ + Will return a list of report steps. + + The simulator will typically use several simulation timesteps + for each report step, and the number will change between + different report steps. So - assuming that the first report + step one has five simulations timesteps and the next two have + three the report_step vector can look like: + + [...,1,1,1,1,1,2,2,2,3,3,3,....] + + """ + return self.get_report_step(False) + + def get_report_step(self, report_only=False): + if report_only: + return self.__report_stepR + else: + return self.__report_step + + #----------------------------------------------------------------- + + def iget_days(self, time_index): + """ + Returns the number of simulation days for element nr @time_index. + """ + return self._iget_sim_days(time_index) + + def iget_date(self, time_index): + """ + Returns the simulation date for element nr @time_index. + """ + long_time = self._iget_sim_time(time_index) + ct = CTime(long_time) + return ct.datetime() + + + def iget_report(self, time_index): + """ + Returns the report step corresponding to @time_index. + + One report step will in general contain many ministeps. + """ + return self._iget_report_step(time_index) + + + @property + def length(self): + """ + The number of timesteps in the dataset. + """ + return self._data_length() + + @property + def first_day(self): + """ + The first day we have simulation data for; normally 0. + """ + return self._get_first_day() + + @property + def sim_length(self): + return self.getSimulationLength() + + @property + def start_date(self): + """ + A Python date instance with the start date. + + The start time is taken from the SMSPEC file, and in case not + all timesteps have been loaded, e.g. for a restarted case, the + returned start_date might be different from the datetime of + the first (loaded) timestep. + """ + ct = self._get_start_date() + return CTime(ct).date() + + + @property + def end_date(self): + """ + The date of the last (loaded) time step. + """ + return CTime(self._get_end_date()).date() + + + + @property + def data_start(self): + return self.getDataStartTime() + + + + @property + def end_time(self): + """ + The time of the last (loaded) time step. + """ + return self.getEndTime() + + + @property + def start_time(self): + return self.getStartTime() + + + def get_data_start_time(self): + """The first date we have data for. + + Thiw will mostly be equal to getStartTime(), but in the case + of restarts, where the case we have restarted from is not + found, this time will be later than the true start of the + field. + """ + return CTime(self._get_data_start()).datetime() + + + + def get_start_time(self): + """ + A Python datetime instance with the start time. + + See start_date() for further details. + """ + return CTime(self._get_start_date()).datetime() + + + def get_end_time(self): + """ + A Python datetime instance with the last loaded time. + """ + return CTime(self._get_end_date()).datetime() + + def getSimulationLength(self): + """ + The length of the current dataset in simulation days. + + Will include the length of a leading restart section, + irrespective of whether we have data for this or not. + """ + return self._sim_length() + + + + @property + def last_report(self): + """ + The number of the last report step in the dataset. + """ + return self._get_last_report_step() + + @property + def first_report(self): + """ + The number of the first report step in the dataset. + """ + return self._get_first_report_step() + + def first_gt_index(self, key, limit): + """ + Returns the first index where @key is above @limit. + """ + key_index = self._get_general_var_index(key) + time_index = self._get_first_gt(key_index, limit) + return time_index + + def first_lt_index(self, key, limit): + """ + Returns the first index where @key is below @limit. + """ + key_index = self._get_general_var_index(key) + time_index = self._get_first_lt(key_index, limit) + return time_index + + def first_gt(self, key, limit): + """ + First EclSumNode of @key which is above @limit. + """ + vector = self[key] + return vector.first_gt(limit) + + def first_lt(self, key, limit): + """ + First EclSumNode of @key which is below @limit. + """ + vector = self[key] + return vector.first_lt(limit) + + def solve_dates(self, key, value, rates_clamp_lower=True): + """Will solve the equation vector[@key] == value for dates. + + See solveDays() for further details. + """ + if not key in self: + raise KeyError("Unrecognized key:%s" % key) + + if len(self) < 2: + raise ValueError("Must have at least two elements to start solving") + + return [ x.datetime() for x in self._solve_dates(key, value, rates_clamp_lower)] + + + def solve_days(self, key, value, rates_clamp_lower=True): + """Will solve the equation vector[@key] == value. + + This method will solve find tha approximate simulation days + where the vector @key is equal @value. The method will return + a list of values, which can have zero, one or multiple values: + + case = EclSum("CASE") + days = case.solveDays("RPR:2", 200) + + if len(days) == 0: + print("Pressure was never equal to 200 BARSA") + elif len(days) == 1: + print("Pressure equal to 200 BARSA after %s simulation days" % days[0]) + else: + print("Pressure equal to 200 BARSA multiple times") + for index,day in enumerate(days): + print("Solution[%d] : %s days" % (index, day)) + + For variables like pressure and total volumes the solution is + based on straightforward linear interpolation between the + simulated values; that is quite intuitive. However - rates is + less intuitive, and how a rate like FOPR is handled can be + surprising: + + Fundamentally the simulator works with *volumes*. Assume that + the simulator calculates that between the times t1 and t2 the + total volume of oil produced is V, then the oil production + rate is given as: + + FOPR = V / (t2 - t1) + + This is the average production rate in the timespan (t1,t2]; + the simulator does not have any information on a finer time + scale than this - so the natural assumption is that the + production is constant at this value for the whole time + period. The logical consequence of this is that production + rates should be visualized as a piecewise constant function: + + + + A B + | | + /|\ OPR | | + | \|/ \|/ + | + | +============X + | | | + |-------------------------------------------------- X + | | | + | +=============X + | | + | | +===========X + |=========X | + | + +---------+-------------+------------+-----------+--> + t0 t1 t2 t3 t4 time + + + This figure shows a plot of the OPR as a piecewise constant + function. In a strict mathematical sense the equation: + + OPR = X + + Does not have a solution at all, but since this inequality: + + OPR(t2) < X < OPR(t3) + + it is natural to say that the equation has a solution. The + default behaviour is to say that the (first) solution in this + case is: + + tx = t2 + epsilon + + corresponding to the arrow 'A' on the figure. Alternatively if + you set the optional argument 'rates_clamp_lower' to false the + method will find the solution: + + tx = t3 + + corresponding to the arrow 'B* in the figure. + + """ + if not key in self: + raise KeyError("Unrecognized key:%s" % key) + + if len(self) < 2: + raise ValueError("Must have at least two elements to start solving") + + return self._solve_days(key, value, rates_clamp_lower) + + + def keys(self, pattern=None): + """ + Return a StringList of summary keys matching @pattern. + + The matching algorithm is ultimately based on the fnmatch() + function, i.e. normal shell-character syntax is used. With + @pattern == "WWCT:*" you will get a list of watercut keys for + all wells. + + If pattern is None you will get all the keys of summary + object. + """ + s = StringList() + self._select_matching_keys(pattern, s) + return s + + + + + def fwrite(self, ecl_case=None): + if ecl_case: + self._set_case(ecl_case) + + self._fwrite_sum() + + + def alloc_time_vector(self, report_only): + return self._alloc_time_vector(report_only) + + def alloc_data_vector(self, data_index, report_only): + return self._alloc_data_vector(data_index, report_only) + + def get_general_var_index(self, key): + return self._get_general_var_index(key) + + def free(self): + self._free() + + def _nicename(self): + """load_case is often full path to summary file, + if so, output basename, else name + """ + name = self._load_case + if name and os.path.isfile(name): + name = os.path.basename(name) + return name + + def __repr__(self): + """Returns, e.g. + EclSum("NORNE_ATW2013.UNSMRY", [1997-11-06 00:00:00, 2006-12-01 00:00:00], keys=3781) at 0x1609e20 + """ + name = self._nicename() + s_time = self.getStartTime() + e_time = self.getEndTime() + num_keys = len(self.keys()) + content = 'name="%s", time=[%s, %s], keys=%d' % (name, s_time, e_time, num_keys) + return self._create_repr(content) + + def dump_csv_line(self, time, keywords, pfile): + """ + Will dump a csv formatted line of the keywords in @keywords, + evaluated at the intertpolated time @time. @pfile should point to an open Python file handle. + """ + cfile = CFILE(pfile) + ctime = CTime(time) + EclSum._dump_csv_line(self, ctime, keywords, cfile) + + + + def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"): + """Will create a CSV file with summary data. + + By default all the vectors in the summary case will be + exported, but by using the optional keys parameter you can + limit the keys which are exported: + + ecl_sum = EclSum("CASE") + ecl_sum.exportCSV("case.csv", keys=["W*:OP1", "W*:OP2", "F*T"]) + + Will export all well related variables for wells 'OP1' and + 'OP2' and all total field vectors. + """ + + if keys is None: + var_list = self.keys() + else: + var_list = StringList() + for key in keys: + var_list |= self.keys(pattern=key) + self._export_csv(filename, var_list, date_format, sep) + + + + def resample(self, new_case_name, time_points): + return self._resample(new_case_name, time_points) + + +import ecl.summary.ecl_sum_keyword_vector +EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) +EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) + +monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod) +monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable) +monkey_the_camel(EclSum, 'addTStep', EclSum.add_t_step) +monkey_the_camel(EclSum, 'assertKeyValid', EclSum.assert_key_valid) +monkey_the_camel(EclSum, 'scaleVector', EclSum.scale_vector) +monkey_the_camel(EclSum, 'shiftVector', EclSum.shift_vector) +monkey_the_camel(EclSum, 'timeRange', EclSum.time_range) +monkey_the_camel(EclSum, 'blockedProduction', EclSum.blocked_production) +monkey_the_camel(EclSum, 'getDataStartTime', EclSum.get_data_start_time) +monkey_the_camel(EclSum, 'getStartTime', EclSum.get_start_time) +monkey_the_camel(EclSum, 'getEndTime', EclSum.get_end_time) +monkey_the_camel(EclSum, 'solveDates', EclSum.solve_dates) +monkey_the_camel(EclSum, 'solveDays', EclSum.solve_days) +monkey_the_camel(EclSum, 'dumpCSVLine', EclSum.dump_csv_line) +monkey_the_camel(EclSum, 'exportCSV', EclSum.export_csv) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py new file mode 100644 index 0000000000..a3fc4c12a6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py @@ -0,0 +1,77 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_sum_keyword_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +import numpy +import datetime + +# Observe that there is some convention conflict with the C code +# regarding order of arguments: The C code generally takes the time +# index as the first argument and the key/key_index as second +# argument. In the python code this order has been reversed. + +from cwrap import BaseCClass +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype + + + +class EclSumKeyWordVector(BaseCClass): + TYPE_NAME = "ecl_sum_vector" + _alloc = EclPrototype("void* ecl_sum_vector_alloc(ecl_sum, bool)", bind=False) + _alloc_copy = EclPrototype("ecl_sum_vector_obj ecl_sum_vector_alloc_layout_copy(ecl_sum_vector, ecl_sum)") + _free = EclPrototype("void ecl_sum_vector_free(ecl_sum_vector)") + _add = EclPrototype("bool ecl_sum_vector_add_key(ecl_sum_vector, char*)") + _add_multiple = EclPrototype("void ecl_sum_vector_add_keys(ecl_sum_vector, char*)") + _get_size = EclPrototype("int ecl_sum_vector_get_size(ecl_sum_vector)") + _iget_key = EclPrototype("char* ecl_sum_vector_iget_key(ecl_sum_vector, int)") + + def __init__(self, ecl_sum, add_keywords = False): + c_pointer = self._alloc(ecl_sum, add_keywords) + super(EclSumKeyWordVector, self).__init__(c_pointer) + + def __getitem__(self, index): + if index < 0: + index += len(self) + + if index >= len(self): + raise IndexError("Out of range") + + return self._iget_key( index ) + + def __len__(self): + return self._get_size() + + def free(self): + self._free() + + def add_keyword(self, keyword): + success = self._add(keyword) + if not success: + raise KeyError("Failed to add keyword to vector") + + def add_keywords(self, keyword_pattern): + self._add_multiple(keyword_pattern) + + def __repr__(self): + return self._create_repr('len=%d' % len(self)) + + def copy(self, ecl_sum): + return self._alloc_copy(ecl_sum) + + +monkey_the_camel(EclSumKeyWordVector, 'addKeyword', EclSumKeyWordVector.add_keyword) +monkey_the_camel(EclSumKeyWordVector, 'addKeywords', EclSumKeyWordVector.add_keywords) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py new file mode 100644 index 0000000000..ed4ccfc680 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py @@ -0,0 +1,28 @@ +class EclSumNode(object): + + def __init__(self, mini_step, report_step, days, date, mpl_date, value): + """ + EclSumNode is a 'struct' with a summary value and time. + + EclSumNode - a small 'struct' with a summary value and time in + several formats. When iterating over a EclSumVector instance + you will get EclSumNode instances. The content of the + EclSumNode type is stored as plain attributes: + + value : The actual value + report_step : The report step + mini_step : The ministep + days : Days since simulation start + date : The simulation date + mpl_date : A date format suitable for matplotlib + + """ + self.value = value + self.report_step = report_step + self.mini_step = mini_step + self.days = days + self.date = date + self.mpl_date = mpl_date + + def __repr__(self): + return "EclSumNode(days=%d, value=%g)" % (self.days, self.value) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py new file mode 100644 index 0000000000..0b165e6e0a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py @@ -0,0 +1,92 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass + +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclPrototype + + + +class EclSumTStep(BaseCClass): + TYPE_NAME = "ecl_sum_tstep" + _alloc = EclPrototype("void* ecl_sum_tstep_alloc_new(int, int, float, void*)", bind=False) + _free = EclPrototype("void ecl_sum_tstep_free(ecl_sum_tstep)") + _get_sim_days = EclPrototype("double ecl_sum_tstep_get_sim_days(ecl_sum_tstep)") + _get_sim_time = EclPrototype("time_t ecl_sum_tstep_get_sim_time(ecl_sum_tstep)") + _get_report = EclPrototype("int ecl_sum_tstep_get_report(ecl_sum_tstep)") + _get_ministep = EclPrototype("int ecl_sum_tstep_get_ministep(ecl_sum_tstep)") + _set_from_key = EclPrototype("void ecl_sum_tstep_set_from_key(ecl_sum_tstep, char*, float)") + _get_from_key = EclPrototype("double ecl_sum_tstep_get_from_key(ecl_sum_tstep, char*)") + _has_key = EclPrototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep, char*)") + + + + def __init__(self, report_step, mini_step, sim_days, smspec): + sim_seconds = sim_days * 24 * 60 * 60 + c_pointer = self._alloc(report_step, mini_step, sim_seconds, smspec) + super(EclSumTStep, self).__init__(c_pointer) + + + def get_sim_days(self): + """ @rtype: double """ + return self._get_sim_days() + + def get_report(self): + """ @rtype: int """ + return self._get_report() + + def get_mini_step(self): + """ @rtype: int """ + return self._get_ministep() + + def get_sim_time(self): + """ @rtype: CTime """ + return self._get_sim_time() + + def __getitem__(self, key): + """ @rtype: double """ + if not key in self: + raise KeyError("Key '%s' is not available." % key) + + return self._get_from_key(key) + + def __setitem__(self, key, value): + if not key in self: + raise KeyError("Key '%s' is not available." % key) + + self._set_from_key(key, value) + + def __contains__(self, key): + return self._has_key(key) + + def free(self): + self._free(self) + + def __repr__(self): + d = self._get_sim_days() + t = self._get_sim_time() + r = self._get_report() + m = self._get_ministep() + cnt = 'sim_days={}, sim_time={}, report={}, ministep={}' + return self._create_repr(cnt.format(d, t, r, m)) + + +monkey_the_camel(EclSumTStep, 'getSimDays', EclSumTStep.get_sim_days) +monkey_the_camel(EclSumTStep, 'getReport', EclSumTStep.get_report) +monkey_the_camel(EclSumTStep, 'getMiniStep', EclSumTStep.get_mini_step) +monkey_the_camel(EclSumTStep, 'getSimTime', EclSumTStep.get_sim_time) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py new file mode 100644 index 0000000000..039105f497 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py @@ -0,0 +1,56 @@ +# Copyright (C) 2016 Statoil ASA, Norway. +# +# The file 'ecl_sum_var_type.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCEnum + + + +class EclSumVarType(BaseCEnum): + TYPE_NAME = "ecl_sum_var_type" + ECL_SMSPEC_INVALID_VAR = None + ECL_SMSPEC_FIELD_VAR = None + ECL_SMSPEC_REGION_VAR = None + ECL_SMSPEC_GROUP_VAR = None + ECL_SMSPEC_WELL_VAR = None + ECL_SMSPEC_SEGMENT_VAR = None + ECL_SMSPEC_BLOCK_VAR = None + ECL_SMSPEC_AQUIFER_VAR = None + ECL_SMSPEC_COMPLETION_VAR = None + ECL_SMSPEC_NETWORK_VAR = None + ECL_SMSPEC_REGION_2_REGION_VAR = None + ECL_SMSPEC_LOCAL_BLOCK_VAR = None + ECL_SMSPEC_LOCAL_COMPLETION_VAR = None + ECL_SMSPEC_LOCAL_WELL_VAR = None + ECL_SMSPEC_MISC_VAR = None + + +EclSumVarType.addEnum("ECL_SMSPEC_INVALID_VAR", 0) +EclSumVarType.addEnum("ECL_SMSPEC_FIELD_VAR", 1) +EclSumVarType.addEnum("ECL_SMSPEC_REGION_VAR", 2) +EclSumVarType.addEnum("ECL_SMSPEC_GROUP_VAR", 3) +EclSumVarType.addEnum("ECL_SMSPEC_WELL_VAR", 4) +EclSumVarType.addEnum("ECL_SMSPEC_SEGMENT_VAR", 5) +EclSumVarType.addEnum("ECL_SMSPEC_BLOCK_VAR", 6) +EclSumVarType.addEnum("ECL_SMSPEC_AQUIFER_VAR", 7) +EclSumVarType.addEnum("ECL_SMSPEC_COMPLETION_VAR", 8) +EclSumVarType.addEnum("ECL_SMSPEC_NETWORK_VAR", 9) +EclSumVarType.addEnum("ECL_SMSPEC_REGION_2_REGION_VAR", 10) +EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_BLOCK_VAR", 11) +EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_COMPLETION_VAR", 12) +EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_WELL_VAR", 13) +EclSumVarType.addEnum("ECL_SMSPEC_MISC_VAR", 14) + + diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py new file mode 100644 index 0000000000..4ec15faedd --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py @@ -0,0 +1,304 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import print_function +import warnings +from ecl.summary.ecl_sum_node import EclSumNode + + +class EclSumVector(object): + def __init__(self, parent, key, report_only = False): + """ + A summary vector with a vector of values and time. + + A summary vector contains the the full time history of one + key, along with the corresponding time vectors in several + different time formats. Depending on the report_only argument + the data vectors in the EclSumVector can either contain all + the time values, or only those corresponding to report_steps. + + The EclSumVector contains a reference to the parent EclSum + structure and this is used to implement several of the + properties and methods of the object; the EclSum vector + instances should therefore only be instantiated through the + EclSum.get_vector() method, and not manually with the + EclSumVector() constructor. + """ + self.parent = parent + self.key = key + self.report_only = report_only + + if report_only: + warnings.warn("The report_only flag to the EclSumVector will be removed", DeprecationWarning) + + self.__dates = parent.get_dates(report_only) + self.__days = parent.get_days(report_only) + self.__mpl_dates = parent.get_mpl_dates(report_only) + self.__mini_step = parent.get_mini_step(report_only) + self.__report_step = parent.get_report_step(report_only) + self.__values = None + + + def __str__(self): + return "" % self.key + + def __repr__(self): + return 'EclSumVector(key = %s, size = %d, unit = %s)' % (self.key, len(self), self.unit) + + @property + def unit(self): + """ + The unit of this vector. + """ + return self.parent.unit(self.key) + + def assert_values(self): + """ + This function will load and internalize all the values. + """ + if self.__values is None: + self.__values = self.parent.get_values(self.key, self.report_only) + + @property + def values(self): + """ + All the summary values of the vector, as a numpy vector. + """ + self.assert_values() + return self.__values + + @property + def dates(self): + """ + All the dates of the vector, list of datetime() instances. + """ + return self.__dates + + @property + def days(self): + """ + The time in days as a numpy vector. + + In the case of lab unit this will be hours. + """ + return self.__days + + @property + def mpl_dates(self): + """ + All the dates as numpy vector of dates in matplotlib format. + """ + return self.__mpl_dates + + @property + def mini_step(self): + """ + All the ministeps of the vector. + + Ministeps is the ECLIPSE notion of timesteps. The ministeps + are numbered sequentially starting at zero; if you have loaded + the entire simulation the ministep number will correspond to + the natural indexing. The length of each ministep is + determined by the convergence properties of the ECLIPSE + simulation. + """ + return self.__mini_step + + @property + def report_step(self): + """ + All the report_step of the vector. + """ + return self.__report_step + + + def __iget(self, index): + """ + Will return an EclSumNode for element @index; should be called + through the [] operator, otherwise you can come across + unitialized data. + """ + return EclSumNode(self.__mini_step[index], + self.__report_step[index], + self.__days[index], + self.__dates[index], + self.__mpl_dates[index], + self.__values[index]) + + + def __len__(self): + """ + The length of the vector - used for the len() builtin. + """ + return len(self.__days) + + + def __getitem__(self, index): + """ + Implements the [] operator. + + Will return EclSumNode instance according to @index. The index + value will be interpreted as in a normal python [] lookup, + i.e. negative values will be interpreted as starting from the + right and also slice notation is allowed[*]. + + [*] Observe that in the case of slices the return value will + not be a proper EclSumVector instance, but rather a normal + Python list of EclSumNode instances. + """ + self.assert_values() + length = len(self.values) + if isinstance(index, int): + if index < 0: + index += len(self.__values) + if index < 0 or index > length: + raise KeyError("Invalid index:%d out of range [0:%d)" % (index, length)) + else: + return self.__iget(index) + elif isinstance(index, slice): + # Observe that the slice based lookup does __not__ return + # a proper EclSumVector instance; it will merely return + # a simple Python list with EclSumNode instances. + (start, stop, step) = index.indices(length) + index = start + sub_vector = [] + while index < stop: + sub_vector.append(self.__iget(index)) + index += step + return sub_vector + + raise KeyError("Invalid index:%s - must have integer or slice." % index) + + @property + def first(self): + """ + Will return the first EclSumNode in this vector. + """ + self.assert_values() + return self.__iget(0) + + @property + def last(self): + """ + Will return the last EclSumNode in this vector. + """ + self.assert_values() + + index = len(self.__values) - 1 + return self.__iget(index) + + @property + def last_value(self): + """ + Will return the last value in this vector. + """ + self.assert_values() + + index = len(self.__values) - 1 + return self.__iget(index).value + + + def get_interp(self, days=None, date=None): + """ + Will lookup value interpolated to @days or @date. + + The function requires one, and only one, time indicator in + terms of @days or @date. If the @date variable is given that + should be Python datetime instance. + + vec = sum["WWCT:A-3"] + vec.get_interp(days = 100) + vec.get_interp(date = datetime.date(year, month, day)) + + This function will crash and burn if the time arguments are + invalid; if in doubt you should check first. + """ + return self.parent.get_interp(self.key, days, date) + + + def get_interp_vector(self, days_list=None, date_list=None): + """ + Will return Python list of interpolated values. + + See get_interp() for further details. + """ + return self.parent.get_interp_vector(self.key, days_list, date_list) + + + def get_from_report(self, report_step): + """ + Will lookup the value based on @report_step. + """ + return self.parent.get_from_report(self.key, report_step) + + ################################################################# + + def first_gt_index(self, limit): + """ + Locates first index where the value is above @limit. + + Observe that this method will raise an exception if it is + called from a vector instance with report_only = True. + """ + if not self.report_only: + key_index = self.parent._get_general_var_index(self.key) + time_index = self.parent._get_first_gt(key_index, limit) + return time_index + else: + raise Exception("Sorry - first_gt_index() can not be called for vectors with report_only=True") + + def first_gt(self, limit): + """ + Locate the first EclSumNode where value is above @limit. + + vec = sum["WWCT:A-3"] + w = vec.first_gt(0.50) + print('Water cut above 0.50 in well A-3 at: %s' % w.date) + + Uses first_gt_index() internally and can not be called for + vectors with report_only = True. + """ + time_index = self.first_gt_index(limit) + print(time_index) + if time_index >= 0: + return self.__iget(time_index) + else: + return None + + def first_lt_index(self, limit): + """ + Locates first index where the value is below @limit. + + See first_gt_index() for further details. + """ + if not self.report_only: + key_index = self.parent._get_general_var_index(self.key) + time_index = self.parent._get_first_lt(key_index, limit) + return time_index + else: + raise Exception("Sorry - first_lt_index() can not be called for vectors with report_only=True") + + def first_lt(self, limit): + """ + Locates first element where the value is below @limit. + + See first_gt() for further details. + """ + time_index = self.first_lt_index(limit) + if time_index >= 0: + return self.__iget(time_index) + else: + return None diff --git a/ThirdParty/Ert/python/ecl/util/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/CMakeLists.txt new file mode 100644 index 0000000000..a4b6f67f33 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/CMakeLists.txt @@ -0,0 +1,10 @@ +set(PYTHON_SOURCES + __init__.py +) + +add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/ecl/util "${PYTHON_SOURCES}" True) + +add_subdirectory(enums) +add_subdirectory(util) +add_subdirectory(test) +add_subdirectory(geometry) diff --git a/ThirdParty/Ert/python/ecl/util/__init__.py b/ThirdParty/Ert/python/ecl/util/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt new file mode 100644 index 0000000000..64559cd9b7 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt @@ -0,0 +1,8 @@ +set(PYTHON_SOURCES + __init__.py + rng_alg_type_enum.py + rng_init_mode_enum.py +) + +add_python_package("python.ecl.util.enums" ${PYTHON_INSTALL_PREFIX}/ecl/util/enums "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/python/ecl/util/enums/__init__.py b/ThirdParty/Ert/python/ecl/util/enums/__init__.py new file mode 100644 index 0000000000..ced8c20089 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/enums/__init__.py @@ -0,0 +1,2 @@ +from .rng_init_mode_enum import RngInitModeEnum +from .rng_alg_type_enum import RngAlgTypeEnum diff --git a/ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py b/ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py new file mode 100644 index 0000000000..a93b47194e --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py @@ -0,0 +1,8 @@ +from cwrap import BaseCEnum + +class RngAlgTypeEnum(BaseCEnum): + TYPE_NAME = "rng_alg_type_enum" + MZRAN = None + + +RngAlgTypeEnum.addEnum("MZRAN", 1) diff --git a/ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py b/ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py new file mode 100644 index 0000000000..049ec0dd6a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py @@ -0,0 +1,14 @@ +from cwrap import BaseCEnum + +class RngInitModeEnum(BaseCEnum): + TYPE_NAME = "rng_init_mode_enum" + INIT_DEFAULT = None + INIT_CLOCK = None + INIT_DEV_RANDOM = None + INIT_DEV_URANDOM = None + + +RngInitModeEnum.addEnum("INIT_DEFAULT", 0) +RngInitModeEnum.addEnum("INIT_CLOCK", 1) +RngInitModeEnum.addEnum("INIT_DEV_RANDOM", 2) +RngInitModeEnum.addEnum("INIT_DEV_URANDOM", 3) diff --git a/ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt new file mode 100644 index 0000000000..177b135916 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt @@ -0,0 +1,13 @@ +set(PYTHON_SOURCES + __init__.py + cpolyline.py + cpolyline_collection.py + geometry_tools.py + geo_pointset.py + geo_region.py + polyline.py + xyz_io.py + surface.py +) + +add_python_package("python.ecl.util.geometry" ${PYTHON_INSTALL_PREFIX}/ecl/util/geometry "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/util/geometry/__init__.py b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py new file mode 100644 index 0000000000..e4bc012dc9 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py @@ -0,0 +1,30 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Simple package for working with 2D geometry. + +""" +import ecl +from cwrap import Prototype + +from .geo_pointset import GeoPointset +from .geo_region import GeoRegion +from .cpolyline import CPolyline +from .cpolyline_collection import CPolylineCollection +from .polyline import Polyline +from .xyz_io import XYZIo +from .geometry_tools import GeometryTools +from .surface import Surface diff --git a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py new file mode 100644 index 0000000000..227413182b --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py @@ -0,0 +1,210 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Create a polygon +""" +import ctypes +import os.path + +from cwrap import BaseCClass +from ecl import EclPrototype +from .geometry_tools import GeometryTools + + +class CPolyline(BaseCClass): + TYPE_NAME = "geo_polygon" + + _alloc_new = EclPrototype("void* geo_polygon_alloc( char* )" , bind = False) + _fread_alloc_irap = EclPrototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )" , bind = False) + _add_point = EclPrototype("void geo_polygon_add_point( geo_polygon , double , double )") + _add_point_front = EclPrototype("void geo_polygon_add_point_front( geo_polygon , double , double )") + _free = EclPrototype("void geo_polygon_free( geo_polygon )") + _size = EclPrototype("int geo_polygon_get_size( geo_polygon )") + _iget_xy = EclPrototype("void geo_polygon_iget_xy( geo_polygon , int , double* , double* )") + _segment_intersects = EclPrototype("bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)") + _get_name = EclPrototype("char* geo_polygon_get_name( geo_polygon )") + _set_name = EclPrototype("void geo_polygon_set_name( geo_polygon , char* )") + _segment_length = EclPrototype("double geo_polygon_get_length( geo_polygon)") + _equal = EclPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") + + + def __init__(self, name = None , init_points = ()): + c_ptr = self._alloc_new( name ) + super(CPolyline , self).__init__( c_ptr ) + for (xc, yc) in init_points: + self.addPoint(xc, yc) + + + @classmethod + def createFromXYZFile(cls , filename , name = None): + if not os.path.isfile(filename): + raise IOError("No such file:%s" % filename) + + polyline = cls._fread_alloc_irap( filename ) + if not name is None: + polyline._set_name( name ) + return polyline + + def __str__(self): + name = self.getName() + if name: + str = "%s [" % name + else: + str = "[" + + for index,p in enumerate(self): + str += "(%g,%g)" % p + if index < len(self) - 1: + str += "," + str += "]" + return str + + def __repr__(self): + return str(self) + + + def __len__(self): + return self._size() + + + def __getitem__(self , index): + if not isinstance(index,int): + raise TypeError("Index argument must be integer. Index:%s invalid" % index) + + if index < 0: + index += len(self) + + if 0 <= index < len(self): + x = ctypes.c_double() + y = ctypes.c_double() + self._iget_xy( index , ctypes.byref(x) , ctypes.byref(y) ) + + return (x.value , y.value) + else: + raise IndexError("Invalid index:%d valid range: [0,%d)" % (index , len(self))) + + + def segmentIntersects(self, p1 , p2): + return self._segment_intersects(p1[0] , p1[1] , p2[0] , p2[1]) + + + def intersects(self , polyline): + if len(self) > 1: + for index,p2 in enumerate(polyline): + if index == 0: + continue + + p1 = polyline[index - 1] + if self.segmentIntersects(p1 , p2): + return True + return False + + + def __iadd__(self , other ): + for p in other: + self.addPoint( p[0] , p[1] ) + return self + + + def __add__(self , other ): + copy = CPolyline( init_points = self) + copy.__iadd__(other) + return copy + + + def __radd__(self , other ): + copy = CPolyline( init_points = other ) + copy.__iadd__(self) + return copy + + def __eq__(self , other): + if super(CPolyline , self).__eq__( other ): + return True + else: + return self._equal( other ) + + + def segmentLength(self): + if len(self) == 0: + raise ValueError("Can not measure length of zero point polyline") + + return self._segment_length( ) + + def extendToBBox(self , bbox , start = True): + if start: + p0 = self[1] + p1 = self[0] + else: + p0 = self[-2] + p1 = self[-1] + + ray_dir = GeometryTools.lineToRay(p0,p1) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , bbox) + if intersections: + p2 = intersections[0][1] + if self.getName(): + name = "Extend:%s" % self.getName() + else: + name = None + + return CPolyline( name = name , init_points = [(p1[0] , p1[1]) , p2]) + else: + raise ValueError("Logical error - must intersect with bounding box") + + + def addPoint( self, xc, yc , front = False): + if front: + self._add_point_front(xc, yc) + else: + self._add_point(xc, yc) + + + def getName(self): + return self._get_name( ) + + + def free(self): + self._free( ) + + + def unzip(self): + x_list = [ ] + y_list = [ ] + for x,y in self: + x_list.append(x) + y_list.append(y) + + return (x_list , y_list) + + + def unzip2(self): + return self.unzip() + + + def connect(self , target): + end1 = self[0] + end2 = self[-1] + + p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) + p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) + + d1 = GeometryTools.distance( p1 , end1 ) + d2 = GeometryTools.distance( p2 , end2 ) + + if d1 < d2: + return [end1 , p1] + else: + return [end2 , p2] diff --git a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py new file mode 100644 index 0000000000..335f3092b6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py @@ -0,0 +1,121 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'cpolyline_collection.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Create a polygon +""" +import ctypes + +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.util.geometry import CPolyline + + +class CPolylineCollection(BaseCClass): + TYPE_NAME = "geo_polygon_collection" + + _alloc_new = EclPrototype("void* geo_polygon_collection_alloc( )" , bind = False) + _free = EclPrototype("void geo_polygon_collection_free( geo_polygon_collection )" ) + _size = EclPrototype("int geo_polygon_collection_size( geo_polygon_collection)" ) + _create_polyline = EclPrototype("geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) + _has_polyline = EclPrototype("bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) + _iget = EclPrototype("geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) + _get = EclPrototype("geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) + _add_polyline = EclPrototype("void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)") + + + + def __init__(self): + c_ptr = self._alloc_new( ) + super(CPolylineCollection , self).__init__( c_ptr ) + self.parent_ref = None + + + def __contains__(self , name): + return self._has_polyline(name) + + + def __len__(self): + return self._size( ) + + + def __iter__(self): + index = 0 + + while index < len(self): + yield self[index] + index += 1 + + + def __getitem__(self , index): + if isinstance(index , int): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + return self._iget( index).setParent( self ) + else: + raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , len(self))) + elif isinstance(index , str): + if index in self: + return self._get(index) + else: + raise KeyError("No polyline named:%s" % index) + else: + raise TypeError("The index argument must be string or integer") + + + def shallowCopy(self): + copy = CPolylineCollection() + for pl in self: + copy._add_polyline(pl , False) + + # If we make a shallow copy we must ensure that source, owning + # all the polyline objects does not go out of scope. + copy.parent_ref = self + return copy + + + + def addPolyline(self , polyline , name = None): + if not isinstance(polyline , CPolyline): + polyline = CPolyline( init_points = polyline , name = name) + else: + if not name is None: + raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object") + + name = polyline.getName() + if name and name in self: + raise KeyError("The polyline collection already has an object:%s" % name) + + if polyline.isReference(): + self._add_polyline( polyline , False) + else: + polyline.convertToCReference( self ) + self._add_polyline( polyline , True) + + + + def createPolyline(self , name = None): + if name and name in self: + raise KeyError("The polyline collection already has an object:%s" % name) + + polyline = self._create_polyline(name) + polyline.setParent( parent = self ) + return polyline + + + def free(self): + self._free( ) diff --git a/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py new file mode 100644 index 0000000000..6286de3eef --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py @@ -0,0 +1,79 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from cwrap import BaseCClass +from ecl import EclPrototype + +class GeoPointset(BaseCClass): + TYPE_NAME = "geo_pointset" + + _alloc = EclPrototype("void* geo_pointset_alloc(bool)", bind=False) + _free = EclPrototype("void geo_pointset_free(geo_pointset)") + #_add_xyz = EclPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") + _get_size = EclPrototype("int geo_pointset_get_size(geo_pointset)") + #_iget_xy = EclPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") + #_get_zcoord = EclPrototype("double* geo_pointset_get_zcoord(geo_pointset)") + _equal = EclPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") + _iget_z = EclPrototype("double geo_pointset_iget_z(geo_pointset, int)") + #_iset_z = EclPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") + #_memcpy = EclPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") + #_shift_z = EclPrototype("void geo_pointset_shift_z(geo_pointset, double)") + #_assign_z = EclPrototype("void geo_pointset_assign_z(geo_pointset, double)") + #_scale_z = EclPrototype("void geo_pointset_scale_z(geo_pointset, double)") + #_imul = EclPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") + #_iadd = EclPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") + #_isub = EclPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") + #_isqrt = EclPrototype("void geo_pointset_isqrt(geo_pointset)") + + + def __init__(self, external_z=False): + c_ptr = self._alloc(external_z) + if c_ptr: + super(GeoPointset, self).__init__(c_ptr) + else: + ext = 'external' if external_z else 'internal' + raise ValueError('Failed to construct GeoPointset with %s_z.' % ext) + + @staticmethod + def fromSurface(surface): + return surface.getPointset() + + def __eq__(self, other): + if isinstance(other, GeoPointset): + return self._equal(other) + return NotImplemented + + def __getitem__(self, key): + size = len(self) + if isinstance(key, int): + idx = key + if idx < 0: + idx += size + if 0 <= idx < size: + return self._iget_z(idx) + else: + raise IndexError('Invalid index, must be in [0, %d), was: %d.' % (size, key)) + else: + # TODO implement slicing? + raise ValueError('Index must be int, not %s.' % type(key)) + + def __len__(self): + return self._get_size() + + def __repr__(self): + return self._create_repr('len=%d' % len(self)) + + def free(self): + self._free() diff --git a/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py new file mode 100644 index 0000000000..9d4e290147 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py @@ -0,0 +1,121 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from cwrap import BaseCClass +from ecl.util.util import IntVector +from ecl import EclPrototype +from .cpolyline import CPolyline +from ctypes import c_double + +cpair = c_double * 2 # this is a function that maps two doubles to a double* + +class GeoRegion(BaseCClass): + TYPE_NAME = "geo_region" + + _alloc = EclPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) + _free = EclPrototype("void geo_region_free(geo_region)") + _reset = EclPrototype("void geo_region_reset(geo_region)") + _get_index_list = EclPrototype("int_vector_ref geo_region_get_index_list(geo_region)") + _select_inside_polygon = EclPrototype("void geo_region_select_inside_polygon(geo_region, geo_polygon)") + _select_outside_polygon = EclPrototype("void geo_region_select_outside_polygon(geo_region, geo_polygon)") + _deselect_inside_polygon = EclPrototype("void geo_region_deselect_inside_polygon(geo_region, geo_polygon)") + _deselect_outside_polygon = EclPrototype("void geo_region_deselect_outside_polygon(geo_region, geo_polygon)") + _select_above_line = EclPrototype("void geo_region_select_above_line(geo_region, double*, double*)") + _select_below_line = EclPrototype("void geo_region_select_below_line(geo_region, double*, double*)") + _deselect_above_line = EclPrototype("void geo_region_deselect_above_line(geo_region, double*, double*)") + _deselect_below_line = EclPrototype("void geo_region_deselect_below_line(geo_region, double*, double*)") + + + def __init__(self, pointset, preselect=False): + self._preselect = True if preselect else False + c_ptr = self._alloc(pointset, self._preselect) + if c_ptr: + super(GeoRegion, self).__init__(c_ptr) + else: + raise ValueError('Could not construct GeoRegion from pointset %s.' % pointset) + + + def getActiveList(self): + return self._get_index_list() + + def _assert_polygon(self, polygon): + if not isinstance(polygon, CPolyline): + raise ValueError('Need to select with a CPolyline, not %s.' + % type(polygon)) + + + def _construct_cline(self, line): + """Takes a line ((x1,y1), (x2,y2)) and returns two double[2]* but + reordered to (x1x2, y1y2). + """ + try: + p1, p2 = line + x1, y1 = map(float, p1) + x2, y2 = map(float, p2) + except Exception as err: + err_msg = 'Select with pair ((x1,y1), (x2,y2)), not %s (%s).' + raise ValueError(err_msg % (line, err)) + x1x2_ptr = cpair(x1, x2) + y1y2_ptr = cpair(y1, y2) + return x1x2_ptr, y1y2_ptr + + + def select_inside(self, polygon): + self._assert_polygon(polygon) + self._select_inside_polygon(polygon) + + def select_outside(self, polygon): + self._assert_polygon(polygon) + self._select_outside_polygon(polygon) + + def deselect_inside(self, polygon): + self._assert_polygon(polygon) + self._deselect_inside_polygon(polygon) + + def deselect_outside(self, polygon): + self._assert_polygon(polygon) + self._deselect_outside_polygon(polygon) + + + def select_above(self, line): + x_ptr, y_ptr = self._construct_cline(line) + self._select_above_line(x_ptr, y_ptr) + + def select_below(self, line): + x_ptr, y_ptr = self._construct_cline(line) + self._select_below_line(x_ptr, y_ptr) + + def deselect_above(self, line): + x_ptr, y_ptr = self._construct_cline(line) + self._deselect_above_line(x_ptr, y_ptr) + + def deselect_below(self, line): + x_ptr, y_ptr = self._construct_cline(line) + self._deselect_below_line(x_ptr, y_ptr) + + + def __len__(self): + """Returns the size of the active list, not the size of the + underlying pointset""" + return len(self._get_index_list()) + + def __repr__(self): + ls = len(self) + il = repr(self.getActiveList()) + pres = 'preselected' if self._preselect else 'not preselected' + return self._create_repr('size=%d, active_list=<%s>, %s' % (ls, il, pres)) + + def free(self): + self._free() diff --git a/ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py b/ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py new file mode 100644 index 0000000000..c3efe43a73 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py @@ -0,0 +1,449 @@ +from math import sqrt +import sys +import six + +class GeometryTools(object): + EPSILON = 0.000001 + + @staticmethod + def lineIntersection(p1, p2, p3, p4): + """ + Finds intersection between line segments. Returns None if no intersection found. + Algorithm provided by Paul Bourke + + @type p1: tuple of (float, float) + @type p2: tuple of (float, float) + @type p3: tuple of (float, float) + @type p4: tuple of (float, float) + @rtype: tuple of (float, float) + """ + + denominator = (p4[1] - p3[1]) * (p2[0] - p1[0]) - (p4[0] - p3[0]) * (p2[1] - p1[1]) + numerator_a = (p4[0] - p3[0]) * (p1[1] - p3[1]) - (p4[1] - p3[1]) * (p1[0] - p3[0]) + numerator_b = (p2[0] - p1[0]) * (p1[1] - p3[1]) - (p2[1] - p1[1]) * (p1[0] - p3[0]) + + # coincident? + if abs(numerator_a) < GeometryTools.EPSILON and abs(numerator_b) < GeometryTools.EPSILON and abs(denominator) < GeometryTools.EPSILON: + return None + + # parallel? + if abs(denominator) < GeometryTools.EPSILON: + return None + + + # intersection along the segments? + mua = numerator_a / denominator + mub = numerator_b / denominator + + if mua < 0.0 or mua > 1.0 or mub < 0.0 or mub > 1.0: + return None + + x = p1[0] + mua * (p2[0] - p1[0]) + y = p1[1] + mua * (p2[1] - p1[1]) + return x, y + + @staticmethod + def polylinesIntersect(polyline1 , polyline2): + """Test if the polylines polyline1 and polyline2 intersect. + + The input arguments must be either Polyline instances[1], or a + list of (float,float) tuples. The method performs a super + naive n^2 check and should not be used for large polyline objects. + + @type polyline1: Polyline or list of tuple of (float, float) + @type polyline2: Polyline or list of tuple of (float, float) + + [1]: The z - coordinate will be ignored. + + """ + + for index1 in range(len(polyline1) - 1): + p1 = polyline1[index1] + p2 = polyline1[index1 + 1] + for index2 in range(len(polyline2) - 1): + p3 = polyline2[index2] + p4 = polyline2[index2 + 1] + + if GeometryTools.lineIntersection(p1,p2,p3,p4): + return True + + return False + + + + + @staticmethod + def ccw(p1, p2, p3): + """ + Three points are a counter-clockwise turn if ccw > 0, clockwise if + ccw < 0, and collinear if ccw = 0 because ccw is a determinant that + gives the signed area of the triangle formed by p1, p2 and p3. + + @type p1: tuple of (float, float) + @type p2: tuple of (float, float) + @type p3: tuple of (float, float) + @rtype: float + """ + return (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0]) + + + @staticmethod + def convexHull(points): + """ + Given a list of points finds the convex hull + @type points: list of tuple of (float, float) + @rtype: list of tuple of (float, float) + """ + points = sorted(points) + + def keepLeft(hull, r): + while len(hull) > 1 and GeometryTools.ccw(hull[-2], hull[-1], r) > 0: + hull.pop() + + if len(hull) == 0 or hull[-1] != r: + hull.append(r) + + return hull + + l = six.functools.reduce(keepLeft, points, []) + u = six.functools.reduce(keepLeft, reversed(points), []) + l.extend([u[i] for i in six.moves.xrange(1, len(u) - 1)]) + + return l + + + @staticmethod + def pointInPolygon(p, polygon): + """ + Finds out if a point is inside a polygon or not + @type p: tuple of (float, float) + @type polygon: Polyline or list of tuple of (float, float) + @rtype: bool + """ + x = p[0] + y = p[1] + n = len(polygon) + + inside = False + + p1x, p1y = polygon[0][0:2] + for index in range(n + 1): + p2x, p2y = polygon[index % n][0:2] + + if min(p1y, p2y) < y <= max(p1y, p2y): + if x <= max(p1x, p2x): + if p1y != p2y: + xints = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x + + if p1x == p2x or x <= xints: + inside = not inside + + p1x, p1y = p2x, p2y + + return inside + + + @staticmethod + def extendToEdge(bounding_polygon, poly_line): + """ + """ + assert(bounding_polygon.isClosed()) + for p in poly_line: + if not GeometryTools.pointInPolygon( p , bounding_polygon): + raise ValueError("The point:%s was not inside bounding polygon") + + p1 = poly_line[0] + ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) + intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex + + + p2 = poly_line[-1] + assert(GeometryTools.pointInPolygon(p2 , bounding_polygon)) + + ray2 = GeometryTools.lineToRay(poly_line[-2], poly_line[-1]) + intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon) + intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex + + return [intersection1[1]] + poly_line + [intersection2[1]] + + + @staticmethod + def slicePolygon(bounding_polygon, poly_line): + """ + This algorithm extends the end-points of the line and find intersections between the line + and the enclosing polygon. The result is a polygon sliced by the extended line. + + The enclosing polygon must be convex, closed and completely enclose the line. + + @type bounding_polygon: Polyline or list of tuple of (float, float) + @type poly_line: Polyline or list of tuple of (float, float) + @rtype: list of tuple of (float, float) + """ + + p1 = poly_line[0] + ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) + tmp = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon) + intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex + + p2 = poly_line[-1] + ray2 = GeometryTools.lineToRay(poly_line[-2], poly_line[-1]) + intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex + + + # Check for intersection between the polyline extensions on the inside of the bounadary + internal_intersection = GeometryTools.lineIntersection( p1 , intersection1[1] , p2 , intersection2[1]) + if internal_intersection: + start_point = poly_line[0] + return poly_line + [ internal_intersection , start_point] + + + + if intersection2[0] < intersection1[0]: + intersection1, intersection2 = intersection2, intersection1 + poly_line = list(reversed(poly_line)) + + result = [intersection1[1]] + + for index in range(intersection1[0] + 1, intersection2[0] + 1): + result.append(bounding_polygon[index]) + + result.append(intersection2[1]) + + for point in reversed(poly_line): + result.append(point) + + result.append(intersection1[1]) + + return result + + + + + @staticmethod + def lineToRay(p0, p1): + """ + Converts a line segment to a unit vector starting at p0 pointing towards p1. + @type p0: tuple of (float, float) + @type p1: tuple of (float, float) + @rtype: tuple of (float, float) + """ + + x = p1[0] - p0[0] + y = p1[1] - p0[1] + + length = sqrt(x * x + y * y) + + return x / length, y / length + + + @staticmethod + def rayLineIntersection(point, ray, p1, p2 , flip_ray = False): + """ + Finds the intersection between the ray starting at point and the line [p1, p2]. + @type point: tuple of (float, float) + @type ray: tuple of (float, float) + @type p1: tuple of (float, float) + @type p2: tuple of (float, float) + @rtype: tuple of (float, float) or None + + stackoverflow: 563198 + """ + s = (p2[0] - p1[0] , p2[1] - p1[1]) + q = p1 + r = ray + p = point + + p_m_q = (p[0] - q[0] , p[1] - q[1]) + q_m_p = (q[0] - p[0] , q[1] - p[1]) + r_x_s = r[0] * s[1] - r[1]*s[0] + + q_m_p_x_r = q_m_p[0] * r[1] - q_m_p[1] * r[0] + q_m_p_x_s = q_m_p[0] * s[1] - q_m_p[1] * s[0] + + if abs(r_x_s) < GeometryTools.EPSILON and abs(q_m_p_x_r) < GeometryTools.EPSILON: + q_m_p_dot_r = q_m_p[0] * r[0] + q_m_p[1] * r[1] + r_dot_r = r[0] * r[0] + r[1] * r[1] + + p_m_q_dot_s = p_m_q[0] * s[0] + p_m_q[1] * s[1] + s_dot_s = s[0] * s[0] + s[1] * s[1] + + # Coincident + if 0 <= q_m_p_dot_r <= r_dot_r: + return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) + + # Coincident + if 0 <= p_m_q_dot_s <= s_dot_s: + return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) + + return None + + + if abs(r_x_s) < GeometryTools.EPSILON: + # Parallell + return None + + + t = 1.0 * q_m_p_x_s / r_x_s + u = 1.0 * q_m_p_x_r / r_x_s + + if t >= 0 and 0 <= u <= 1: + x = p[0] + t*r[0] + y = p[1] + t*r[1] + + return x,y + + if flip_ray: + return GeometryTools.rayLineIntersection( point , (-ray[0] , -ray[1]) , p1 , p2 , False) + else: + return None + + + + + @staticmethod + def rayPolygonIntersections(point, ray, polygon): + """ + Finds all intersections along the ray with the polygon. + The returned value is a tuple containing the line segment in the polygon and the intersection coordinate. + + @type point: tuple of (float, float) + @type ray: tuple of (float, float) + @type polygon: Polyline or [tuple of (float, float)] + @rtype: list of tuple of (int, tuple of (float, float)) + """ + results = [] + for index in range(len(polygon) - 1): + lp1 = polygon[index] + lp2 = polygon[index + 1] + + intersection = GeometryTools.rayLineIntersection(point, ray, lp1, lp2) + if intersection is not None: + results.append((index, intersection)) + + return results + + + @staticmethod + def distance(p1,p2): + if len(p1) != len(p2): + raise ValueError("Different lenght of objects") + + sqr_distance = 0 + for x1,x2 in zip(p1,p2): + sqr_distance += (x1 - x2) * (x1 - x2) + + return sqrt( sqr_distance ) + + + @staticmethod + def joinPolylines(polyline1 , polyline2): + """The shortest straight line connecting polyline1 and polyline2. + + The joinPolylines function does not extend the polylines with + a ray from the end, only the length of the straight line + connecting the various endpoints is considered. If the two + polylines already intersect the function returns None. + """ + + + if len(polyline1) < 1: + raise ValueError("Length of polyline must be >= 1") + + if len(polyline2) < 1: + raise ValueError("Length of polyline must be >= 1") + + if GeometryTools.polylinesIntersect( polyline1 , polyline2): + return None + + p0 = polyline1[0] + p1 = polyline1[-1] + pa = polyline2[0] + pb = polyline2[-1] + + d_list = [ (GeometryTools.distance( p0 , pa ), [p0 , pa]), + (GeometryTools.distance( p0 , pb ), [p0 , pb]), + (GeometryTools.distance( p1 , pa ), [p1 , pa]), + (GeometryTools.distance( p1 , pb ), [p1 , pb]) ] + + d_list.sort( key = lambda x: x[0]) + return d_list[0][1] + + + @staticmethod + def connectPolylines( polyline , target_polyline): + if GeometryTools.polylinesIntersect( polyline , target_polyline ): + return None + + if len(polyline) < 2: + raise ValueError("Polyline must have at least two points") + + d_list = [] + + p0 = polyline[-1] + p1 = polyline[-2] + ray = GeometryTools.lineToRay( p1 , p0 ) + for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): + d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) + + p0 = polyline[0] + p1 = polyline[1] + ray = GeometryTools.lineToRay( p1 , p0 ) + for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): + d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) + + if len(d_list) == 0: + raise ValueError("Polyline %s can not be extended to %s" % (polyline.getName() , target_polyline.getName())) + + d_list.sort( key = lambda x: x[0]) + return d_list[0][1] + + + + @staticmethod + def nearestPointOnPolyline( p , polyline ): + if len(polyline) > 1: + d_list = [ GeometryTools.distance( p , pi ) for pi in polyline ] + index0 = d_list.index( min(d_list) ) + p0 = polyline[index0] + dist0 = d_list[index0] + + dist1 = sys.float_info.max + dist2 = sys.float_info.max + intercept1 = None + intercept2 = None + + index1 = None + index2 = None + if index0 > 0: + index1 = index0 - 1 + + if index0 < len(polyline) - 1: + index2 = index0 + 1 + + if not index1 is None: + p1 = polyline[index1] + dy1 = p1[1] - p0[1] + dx1 = p1[0] - p0[0] + intercept1 = GeometryTools.rayLineIntersection( p , (dy1 , -dx1) , p0 , p1 , True) + if intercept1: + dist1 = GeometryTools.distance( intercept1 , p ) + + + if not index2 is None: + p2 = polyline[index2] + dy2 = p2[1] - p0[1] + dx2 = p2[0] - p0[0] + intercept2 = GeometryTools.rayLineIntersection( p , (dy2 , -dx2) , p0 , p2 , True) + if intercept2: + dist2 = GeometryTools.distance( intercept2 , p ) + + + point_list = [ p0 , intercept1 , intercept2 ] + d_list = [ dist0 , dist1 , dist2 ] + index = d_list.index( min(d_list) ) + + + return point_list[index] + else: + raise ValueError("Polyline must have len() >= 2") + diff --git a/ThirdParty/Ert/python/ecl/util/geometry/polyline.py b/ThirdParty/Ert/python/ecl/util/geometry/polyline.py new file mode 100644 index 0000000000..8a11571a31 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/polyline.py @@ -0,0 +1,171 @@ +import collections +from .geometry_tools import GeometryTools + +class Polyline(object): + def __init__(self, name=None , init_points = None): + super(Polyline, self).__init__() + self.__name = name + self.__points = [] + if init_points: + self.loadPoints( init_points ) + + def __str__(self): + s = "Polyline:[ " + for p in self: + s += "(%s,%s) " % (p[0],p[1]) + s += "]" + return s + + def getName(self): + """ @rtype: str """ + return self.__name + + + def __iadd__(self , other ): + for p in other: + self.__points.append( p ) + return self + + + def __add__(self , other ): + copy = Polyline( init_points = self) + copy.__iadd__(other) + return copy + + + def __radd__(self , other ): + copy = Polyline( init_points = other ) + copy.__iadd__(self) + return copy + + + def __eq__(self, other): + if len(self) != len(other): + return False + + for (p1,p2) in zip(self , other): + if p1 != p2: + return False + + return True + + + + def __len__(self): + return len(self.__points) + + def addPoint(self, x, y, z=None): + if z is None: + p = (x, y) + else: + p = (x, y, z) + self.__points.append(p) + + def __getitem__(self, index): + """ @rtype: tuple of (float, float, float) """ + if index < 0: + index += len(self) + + if not 0 <= index < len(self): + raise IndexError("Index:%d invalid must be in range: [0, %d]" % (index, (len(self) - 1))) + return self.__points[index] + + def isClosed(self): + first = self[0] + last = self[-1] + + return first == last + + + def assertClosed(self): + if not self.isClosed(): + first_point = self[0] + + x = first_point[0] + y = first_point[1] + try: + z = first_point[2] + self.addPoint(x,y,z) + except IndexError: + self.addPoint(x,y) + + + + + + def loadPoints(self , points): + for point in points: + x = point[0] + y = point[1] + try: + z = point[2] + except IndexError: + z = None + + self.addPoint(x,y,z) + + def intersects(self, other_polyline): + """ + Test if instances intersects with other polyline. + + @type other_polyline: Polyline or list of tuple of (float, float) + @rtype: bool + """ + return GeometryTools.polylinesIntersect( self , other_polyline ) + + + def __iter__(self): + index = 0 + + while index < len(self): + yield self[index] + index += 1 + + + def unzip2(self): + x = [] + y = [] + for p in self: + x.append(p[0]) + y.append(p[1]) + + return (x,y) + + + def unzip(self): + first_point = self[0] + x = [] + y = [] + + try: + z = first_point[2] + z = [] + for p in self: + x.append(p[0]) + y.append(p[1]) + z.append(p[2]) + + return (x,y,z) + except IndexError: + for p in self: + x.append(p[0]) + y.append(p[1]) + + return (x,y) + + + def connect(self , target): + end1 = self[0] + end2 = self[-1] + + p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) + p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) + + d1 = GeometryTools.distance( p1 , end1 ) + d2 = GeometryTools.distance( p2 , end2 ) + + if d1 < d2: + return [end1 , p1] + else: + return [end2 , p2] + diff --git a/ThirdParty/Ert/python/ecl/util/geometry/surface.py b/ThirdParty/Ert/python/ecl/util/geometry/surface.py new file mode 100644 index 0000000000..ba610cb9bc --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/surface.py @@ -0,0 +1,293 @@ +# Copyright (C) 2016 Statoil ASA, Norway. +# +# The file 'surface' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from __future__ import division + +""" +Create a polygon +""" +import os.path +import ctypes + +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.util.geometry import GeoPointset + + +class Surface(BaseCClass): + TYPE_NAME = "surface" + + _alloc = EclPrototype("void* geo_surface_fload_alloc_irap( char* , bool )" , bind = False) + _free = EclPrototype("void geo_surface_free( surface )") + _new = EclPrototype("void* geo_surface_alloc_new( int, int, double, double, double, double, double )", bind = False) + _get_nx = EclPrototype("int geo_surface_get_nx( surface )") + _get_ny = EclPrototype("int geo_surface_get_ny( surface )") + _iget_zvalue = EclPrototype("double geo_surface_iget_zvalue( surface , int)") + _iset_zvalue = EclPrototype("void geo_surface_iset_zvalue( surface , int , double)") + _write = EclPrototype("void geo_surface_fprintf_irap( surface , char* )") + _equal = EclPrototype("bool geo_surface_equal( surface , surface )") + _header_equal = EclPrototype("bool geo_surface_equal_header( surface , surface )") + _copy = EclPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") + _assign = EclPrototype("void geo_surface_assign_value( surface , double )") + _scale = EclPrototype("void geo_surface_scale( surface , double )") + _shift = EclPrototype("void geo_surface_shift( surface , double )") + _iadd = EclPrototype("void geo_surface_iadd( surface , surface )") + _imul = EclPrototype("void geo_surface_imul( surface , surface )") + _isub = EclPrototype("void geo_surface_isub( surface , surface )") + _isqrt = EclPrototype("void geo_surface_isqrt( surface )") + _iget_xy = EclPrototype("void geo_surface_iget_xy(surface, int, double*, double*)") + _get_pointset = EclPrototype("geo_pointset_ref geo_surface_get_pointset(surface)") + + + def __init__(self, filename=None, nx=None, ny=None, xinc=None, yinc=None, + xstart=None, ystart=None, angle=None): + """ + This will load a irap surface from file. The surface should + consist of a header and a set z values. + """ + if filename is not None: + filename = str(filename) + if os.path.isfile( filename ): + c_ptr = self._alloc(filename , True) + super(Surface , self).__init__(c_ptr) + else: + raise IOError('No such file "%s".' % filename) + else: + s_args = [nx, ny, xinc, yinc, xstart, ystart, angle] + if None in s_args: + raise ValueError('Missing argument for creating surface, all values must be set, was: %s' % str(s_args)) + c_ptr = self._new(*s_args) + super(Surface , self).__init__(c_ptr) + + def __eq__(self , other): + """ + Compares two Surface instances, both header and data must be equal + to compare as equal. + """ + if isinstance( other , Surface): + return self._equal(other) + else: + return False + + + def headerEqual(self , other): + return self._header_equal( other) + + + def __iadd__(self , other): + if isinstance(other , Surface): + if self.headerEqual(other): + self._iadd(other) + else: + raise ValueError("Tried to add incompatible surfaces") + else: + self._shift(other) + return self + + + def __isub__(self , other): + if isinstance(other , Surface): + if self.headerEqual(other): + self._isub(other) + else: + raise ValueError("Tried to subtract incompatible surfaces") + else: + self._shift( -other) + return self + + + def __imul__(self , other): + if isinstance(other , Surface): + if self.headerEqual(other): + self._imul( other) + else: + raise ValueError("Tried to add multiply ncompatible surfaces") + else: + self._scale( other) + return self + + def __itruediv__(self , other): + self._scale(1.0 / other) + return self + + def __idiv__(self, other): + return self.__itruediv__(other) + + + def __add__(self , other): + copy = self.copy() + copy += other + return copy + + + def __mul__(self , other): + copy = self.copy() + copy *= other + return copy + + + def __sub__(self , other): + copy = self.copy() + copy -= other + return copy + + + def __truediv__(self , other): + copy = self.copy() + copy /= other + return copy + + + def __div__(self, other): + return self.__truediv__(other) + + + def __len__(self): + """ + The number of values in the surface. + """ + return self.getNX() * self.getNY() + + + def inplaceSqrt(self): + """ + Will do an inplace sqrt operation. + """ + self._isqrt( ) + return self + + + def sqrt(self): + """ + Will return a new surface where all elements have been sqrt{ .. }. + """ + copy = self.copy( ) + copy.inplaceSqrt( ) + return copy + + + def copy(self , copy_data = True): + """Will create a deep copy of self, if copy_data is set to False the + copy will have all z-values set to zero. + """ + return self._copy( copy_data) + + + def write(self , filename): + + """ + Will write the surface as an ascii formatted file to @filename. + """ + self._write( filename ) + + + + def assign(self , value): + """ + Will set all the values in the surface to @value" + """ + self._assign(value) + + + def __setitem__(self , index , value): + if isinstance(index , int): + if index >= len(self): + raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self))) + if index < 0: + index += len(self) + + self._iset_zvalue(index , value) + else: + raise TypeError("Invalid index type:%s - must be integer" % index) + + + def __getitem__(self , index): + if isinstance(index , int): + idx = index + ls = len(self) + if idx < 0: + idx += ls + if 0 <= idx < ls: + return self._iget_zvalue(idx) + else: + raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self))) + else: + raise TypeError("Invalid index type:%s - must be integer" % index) + + + def getXY(self, index): + """Gets the index'th (x,y) coordinate""" + if isinstance(index, int): + idx = index + if idx < 0: + idx += len(self) + if not 0 <= idx < len(self): + raise IndexError("Invalid index:%d - valid range [0,%d)" % (index, len(self))) + index = idx + else: + raise TypeError("Invalid index type:%s - must be integer" % index) + + x = ctypes.c_double() + y = ctypes.c_double() + self._iget_xy(index, ctypes.byref(x), ctypes.byref(y)) + + return x.value, y.value + + + def getNX(self): + return self._get_nx() + + + def getNY(self): + return self._get_ny() + + def getPointset(self): + return self._get_pointset() + + def _assert_idx_or_i_and_j(self, idx, i, j): + if idx is None: + if i is None or j is None: + raise ValueError('idx is None, i and j must be ints, was %s and %s.' % (i, j)) + else: + if i is not None or j is not None: + raise ValueError('idx is set, i and j must be None, was %s and %s.' % (i, j)) + + + def getXYZ(self, idx=None, i=None, j=None): + """Returns a tuple of 3 floats, (x,y,z) for given global index, or i and j.""" + self._assert_idx_or_i_and_j(idx, i, j) + if idx is None: + nx, ny = self.getNX(), self.getNY() + i_idx, j_idx = i,j + if i_idx < 0: + i_idx += self.getNX() + if j_idx < 0: + j_idx += self.getNY() + if 0 <= i_idx < self.getNX() and 0 <= j_idx < self.getNY(): + idx = j_idx * self.getNX() + i_idx + else: + fmt = 'Index error: i=%d not in [0,nx=%d) or j=%d not in [0,ny=%d).' + raise IndexError(fmt % (i, nx, j, ny)) + x,y = self.getXY(idx) + z = self[idx] + return (x,y,z) + + + def free(self): + self._free() + + def __repr__(self): + cnt = 'nx=%d, ny=%d' % (self.getNX(), self.getNY()) + return self._create_repr(cnt) diff --git a/ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py b/ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py new file mode 100644 index 0000000000..9f349b339f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py @@ -0,0 +1,62 @@ +import os +from .polyline import Polyline + +class XYZIo(object): + + @staticmethod + def readXYZFile(path): + """ @rtype: Polyline """ + + if not os.path.exists(path): + raise IOError("Path does not exist '%s'!" % path) + + name = os.path.basename(path) + + polyline = Polyline(name=name) + + with open(path, "r") as f: + for line in f: + line = line.strip() + if line: + x, y, z = map(float, line.split()) + + if x != 999.000000 and y != 999.000000 and z != 999.000000: + polyline.addPoint(x, y, z) + else: + break + else: + break + + return polyline + + + @staticmethod + def readXYFile(path): + """ @rtype: Polyline """ + + if not os.path.exists(path): + raise IOError("Path does not exist '%s'!" % path) + + name = os.path.basename(path) + + polyline = Polyline(name=name) + + with open(path, "r") as f: + for line in f: + x, y= map(float, line.split()) + polyline.addPoint(x, y) + + return polyline + + + @staticmethod + def saveXYFile(polyline , filename): + """ + @type polyline: Polyline or list of tuple of (float, float) + """ + with open(filename , "w") as fileH: + for p in polyline: + fileH.write("%g %g\n" % (p[0] , p[1])) + + + diff --git a/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt new file mode 100644 index 0000000000..4d87b9efca --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt @@ -0,0 +1,18 @@ +set(PYTHON_SOURCES + __init__.py + ert_test_context.py + ert_test_runner.py + extended_testcase.py + test_run.py + source_enumerator.py + test_area.py + temp_area.py + path_context.py + lint_test_case.py + import_test_case.py + debug_msg.py +) + +add_python_package("python.ecl.util.test" ${PYTHON_INSTALL_PREFIX}/ecl/util/test "${PYTHON_SOURCES}" True) + +add_subdirectory(ecl_mock) diff --git a/ThirdParty/Ert/python/ecl/util/test/__init__.py b/ThirdParty/Ert/python/ecl/util/test/__init__.py new file mode 100644 index 0000000000..1cc89f8d32 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/__init__.py @@ -0,0 +1,11 @@ +from .test_run import TestRun +from .test_run import path_exists +from .extended_testcase import ExtendedTestCase +from .source_enumerator import SourceEnumerator +from .test_area import TestArea , TestAreaContext +from .temp_area import TempArea , TempAreaContext +from .ert_test_runner import ErtTestRunner +from .path_context import PathContext +from .lint_test_case import LintTestCase +from .import_test_case import ImportTestCase +from .debug_msg import debug_msg diff --git a/ThirdParty/Ert/python/ecl/util/test/debug_msg.py b/ThirdParty/Ert/python/ecl/util/test/debug_msg.py new file mode 100644 index 0000000000..4f479b9b74 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/debug_msg.py @@ -0,0 +1,7 @@ +import inspect + +def debug_msg(msg): + record = inspect.stack()[1] + frame = record[0] + info = inspect.getframeinfo( frame ) + return "FILE: %s LINE: %s Msg: %s" % (info.filename, info.lineno, msg) diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt new file mode 100644 index 0000000000..c9fcd038c2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt @@ -0,0 +1,6 @@ +set(PYTHON_SOURCES + __init__.py + ecl_sum_mock.py +) + +add_python_package("python.ecl.util.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/util/test/ecl_mock "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py new file mode 100644 index 0000000000..eb49177fc0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py @@ -0,0 +1 @@ +from .ecl_sum_mock import createEclSum diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py new file mode 100644 index 0000000000..a2f1e210f2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py @@ -0,0 +1,50 @@ +import datetime +from ecl.summary import EclSum + + +def mock_func(ecl_sum , key , days): + return days * 10 + + +def createEclSum( case, + keys, + sim_start = datetime.date(2010 , 1, 1), + data_start = None, + sim_length_days = 5 * 365, + num_report_step = 5, + num_mini_step = 10, + dims = (20,10,5) , + func_table = {}, + restart_case = None, + restart_step = -1): + + ecl_sum = EclSum.restart_writer(case , restart_case, restart_step, sim_start , dims[0] , dims[1] , dims[2]) + var_list = [] + for (kw,wgname,num) in keys: + var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num) ) + + # This is a bug! This should not be integer division, but tests are written + # around that assumption. + report_step_length = float(sim_length_days // num_report_step) + mini_step_length = float(report_step_length // num_mini_step) + + if data_start is None: + time_offset = 0 + else: + dt = data_start - sim_start + time_offset = dt.total_seconds() / 86400.0 + + for report_step in range(num_report_step): + for mini_step in range(num_mini_step): + days = time_offset + report_step * report_step_length + mini_step * mini_step_length + t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days ) + + for var in var_list: + key = var.getKey1( ) + if key in func_table: + func = func_table[key] + t_step[key] = func( days ) + else: + t_step[key] = mock_func( ecl_sum , key , days) + + return ecl_sum diff --git a/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py b/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py new file mode 100644 index 0000000000..dd89c5a720 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py @@ -0,0 +1,117 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os.path + +from cwrap import BaseCClass +from ert.enkf import EnKFMain, EnkfPrototype + +class ErtTest(BaseCClass): + TYPE_NAME = "ert_test" + + _alloc = EnkfPrototype("void* ert_test_context_alloc_python( char* , char*)", bind = False) + _set_store = EnkfPrototype("void* ert_test_context_set_store( ert_test , bool)") + _free = EnkfPrototype("void ert_test_context_free( ert_test )") + _get_cwd = EnkfPrototype("char* ert_test_context_get_cwd( ert_test )") + _get_enkf_main = EnkfPrototype("enkf_main_ref ert_test_context_get_main( ert_test )") + + + + def __init__(self, test_name, model_config, store_area=False): + if not os.path.exists(model_config): + raise IOError("The configuration file: %s does not exist" % model_config) + else: + c_ptr = self._alloc(test_name, model_config) + super(ErtTest, self).__init__(c_ptr) + self.setStore(store_area) + + self.__ert = None + + def setStore(self, store): + self._set_store(store) + + def getErt(self): + """ @rtype: EnKFMain """ + if self.__ert is None: + self.__ert = self._get_enkf_main() + + return self.__ert + + def free(self): + ert = self.getErt() + ert.umount() + self._free() + + def installWorkflowJob(self, job_name, job_path): + """ @rtype: bool """ + if os.path.exists(job_path) and os.path.isfile(job_path): + ert = self.getErt() + workflow_list = ert.getWorkflowList() + + workflow_list.addJob(job_name, job_path) + return workflow_list.hasJob(job_name) + else: + return False + + def runWorkflowJob(self, job_name, *arguments): + """ @rtype: bool """ + ert = self.getErt() + workflow_list = ert.getWorkflowList() + + if workflow_list.hasJob(job_name): + job = workflow_list.getJob(job_name) + job.run(ert, [arg for arg in arguments]) + return True + else: + return False + + + def getCwd(self): + """ + Returns the current working directory of this context. + @rtype: string + """ + return self._get_cwd() + + + +class ErtTestContext(object): + def __init__(self, test_name, model_config, store_area=False): + self.__test_name = test_name + self.__model_config = model_config + self.__store_area = store_area + self.__test_context = ErtTest(self.__test_name, self.__model_config, store_area=self.__store_area) + + + def __enter__(self): + """ @rtype: ErtTest """ + return self.__test_context + + + def __exit__(self, exc_type, exc_val, exc_tb): + del self.__test_context + return False + + + def getErt(self): + return self.__test_context.getErt() + + + def getCwd(self): + """ + Returns the current working directory of this context. + @rtype: string + """ + return self.__test_context.getCwd() diff --git a/ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py b/ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py new file mode 100644 index 0000000000..0ca274508f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py @@ -0,0 +1,63 @@ +import os + +try: + from unittest2 import TestLoader, TextTestRunner +except ImportError: + from unittest import TestLoader, TextTestRunner + + +class ErtTestRunner(object): + + @staticmethod + def runTestSuite(tests , test_verbosity = 3): + test_runner = TextTestRunner(verbosity=test_verbosity) + result = test_runner.run(tests) + + return result.wasSuccessful() + + + @staticmethod + def findTestsInDirectory(path, recursive=True , pattern = "test*.py"): + loader = TestLoader() + test_suite = loader.discover(path , pattern = pattern) + + for (root, dirnames, filenames) in os.walk( path ): + for directory in dirnames: + test_suite.addTests(ErtTestRunner.findTestsInDirectory(os.path.join(root, directory), recursive , pattern)) + + return test_suite + + + @staticmethod + def runTestsInDirectory(path=".", recursive=True, test_verbosity=3): + test_suite = ErtTestRunner.findTestsInDirectory(path, recursive) + return ErtTestRunner.runTestSuite(test_suite) + + + @staticmethod + def runTestsInClass(classpath, test_verbosity=3): + klass = ErtTestRunner.importClass(classpath) + loader = TestLoader() + tests = loader.loadTestsFromTestCase(klass) + testRunner = TextTestRunner(verbosity=test_verbosity) + testRunner.run(tests) + + + @staticmethod + def importClass(classpath): + dot = classpath.rfind(".") + class_name = classpath[dot + 1:] + try: + m = __import__(classpath[0:dot], globals(), locals(), [class_name]) + return getattr(m, class_name) + except ImportError: + print("Failed to import: %s" % classpath) + raise + + + @staticmethod + def getTestsFromTestClass(test_class_path, argv=None): + klass = ErtTestRunner.importClass(test_class_path) + klass.argv = argv + loader = TestLoader() + return loader.loadTestsFromTestCase(klass) diff --git a/ThirdParty/Ert/python/ecl/util/test/extended_testcase.py b/ThirdParty/Ert/python/ecl/util/test/extended_testcase.py new file mode 100644 index 0000000000..7f71f31969 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/extended_testcase.py @@ -0,0 +1,191 @@ +import numbers +import os +import os.path +import traceback +import sys + +try: + from unittest2 import TestCase +except ImportError: + from unittest import TestCase + +from .source_enumerator import SourceEnumerator +from ecl.util.util import installAbortSignals +from ecl.util.util import Version + + +# Function wrapper which can be used to add decorator @log_test to test +# methods. When a test has been decorated with @log_test it will print +# "starting: " when a method is complete and "complete: " +# when the method is complete. Convenient when debugging tests which fail hard +# or lock up. + +def log_test(test): + def wrapper(*args): + sys.stderr.write("starting: %s \n" % test.__name__) + test(*args) + sys.stderr.write("complete: %s \n" % test.__name__) + return wrapper + + + +class _AssertNotRaisesContext(object): + + def __init__(self, test_class): + super(_AssertNotRaisesContext, self).__init__() + self._test_class = test_class + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, tb): + if exc_type is not None: + try: + exc_name = exc_type.__name__ + except AttributeError: + exc_name = str(exc_type) + self._test_class.fail("Exception: %s raised\n%s" % (exc_name, traceback.print_exception(exc_type, exc_value, tb))) + return True + + +""" +This class provides some extra functionality for testing values that are almost equal. +""" +class ExtendedTestCase(TestCase): + TESTDATA_ROOT = None + SHARE_ROOT = None + SOURCE_ROOT = None + + + def __init__(self , *args , **kwargs): + installAbortSignals() + super(ExtendedTestCase , self).__init__(*args , **kwargs) + + + def __str__(self): + return 'ExtendedTestCase( TESTADATA_ROOT=%s, SOURCE_ROOT=%s, SHARE_ROOT=%s)' % (self.TESTDATA_ROOT, + self.SOURCE_ROOT, + self.SHARE_ROOT) + + def assertFloatEqual(self, first, second, msg=None, tolerance=1e-6): + try: + f_first, f_second = float(first), float(second) + diff = abs(f_first - f_second) + scale = max(1, abs(first) + abs(second)) + if msg is None: + msg = "Floats not equal: |%f - %f| > %g" % (f_first, f_second, tolerance) + self.assertTrue(diff < tolerance * scale, msg=msg) + except TypeError: + self.fail("Cannot compare as floats: %s (%s) and %s (%s)" % + (first, type(first), second, type(second))) + + + def assertAlmostEqualList(self, first, second, msg=None, tolerance=1e-6): + if len(first) != len(second): + self.fail("Lists are not of same length!") + + for index in range(len(first)): + self.assertFloatEqual( + first[index], second[index], + msg=msg, tolerance=tolerance + ) + + + def assertImportable(self, module_name): + try: + __import__(module_name) + except ImportError: + tb = traceback.format_exc() + self.fail("Module %s not found!\n\nTrace:\n%s" % (module_name, str(tb))) + except Exception: + tb = traceback.format_exc() + self.fail("Import of module %s caused errors!\n\nTrace:\n%s" % (module_name, str(tb))) + + + def assertFilesAreEqual(self, first, second): + if not self.__filesAreEqual(first, second): + self.fail("Buffer contents of files are not identical!") + + + def assertFilesAreNotEqual(self, first, second): + if self.__filesAreEqual(first, second): + self.fail("Buffer contents of files are identical!") + + def assertFileExists(self, path): + if not os.path.exists(path) or not os.path.isfile(path): + self.fail("The file: %s does not exist!" % path) + + def assertDirectoryExists(self, path): + if not os.path.exists(path) or not os.path.isdir(path): + self.fail("The directory: %s does not exist!" % path) + + def assertFileDoesNotExist(self, path): + if os.path.exists(path) and os.path.isfile(path): + self.fail("The file: %s exists!" % path) + + def assertDirectoryDoesNotExist(self, path): + if os.path.exists(path) and os.path.isdir(path): + self.fail("The directory: %s exists!" % path) + + def __filesAreEqual(self, first, second): + buffer1 = open(first, "rb").read() + buffer2 = open(second, "rb").read() + + return buffer1 == buffer2 + + def assertEnumIsFullyDefined(self, enum_class, enum_name, source_path, verbose=False): + if self.SOURCE_ROOT is None: + raise Exception("SOURCE_ROOT is not set.") + + enum_values = SourceEnumerator.findEnumerators(enum_name, os.path.join( self.SOURCE_ROOT , source_path)) + + for identifier, value in enum_values: + if verbose: + print("%s = %d" % (identifier, value)) + + self.assertTrue(identifier in enum_class.__dict__, "Enum does not have identifier: %s" % identifier) + class_value = enum_class.__dict__[identifier] + self.assertEqual(class_value, value, "Enum value for identifier: %s does not match: %s != %s" % (identifier, class_value, value)) + + + @classmethod + def createSharePath(cls, path): + if cls.SHARE_ROOT is None: + raise Exception("Trying to create directory rooted in 'SHARE_ROOT' - variable 'SHARE_ROOT' is not set.") + return os.path.realpath(os.path.join(cls.SHARE_ROOT , path)) + + + @classmethod + def createTestPath(cls, path): + if cls.TESTDATA_ROOT is None: + raise Exception("Trying to create directory rooted in 'TESTDATA_ROOT' - variable 'TESTDATA_ROOT' has not been set.") + return os.path.realpath(os.path.join(cls.TESTDATA_ROOT , path)) + + + def assertNotRaises(self, func=None): + + context = _AssertNotRaisesContext(self) + if func is None: + return context + + with context: + func() + + @staticmethod + def slowTestShouldNotRun(): + """ + @param: The slow test flag can be set by environment variable SKIP_SLOW_TESTS = [True|False] + """ + + return os.environ.get("SKIP_SLOW_TESTS", "False") == "True" + + + @staticmethod + def requireVersion(major , minor , micro = "git"): + required_version = Version(major, minor , micro) + current_version = Version.currentVersion() + + if required_version < current_version: + return True + else: + return False diff --git a/ThirdParty/Ert/python/ecl/util/test/import_test_case.py b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py new file mode 100644 index 0000000000..13b940d49b --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py @@ -0,0 +1,55 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import importlib +import os +import sys +import traceback +import unittest +import inspect +import imp + +class ImportTestCase(unittest.TestCase): + + def import_file(self, path): + return imp.load_source( "module", path) + + def import_module(self , module): + mod = importlib.import_module( module ) + return mod + + def import_package(self, package): + if "__" in package: + return True + module = self.import_module( package ) + + path = os.path.dirname( inspect.getfile( module ) ) + + for entry in sorted(os.listdir(path)): + entry_path = os.path.join(path, entry) + if os.path.isdir( entry_path ): + module = os.path.basename( entry ) + sub_module = "%s.%s" % (package , module) + self.import_package( sub_module ) + else: + module, ext = os.path.splitext( entry ) + if module == "__init__": + continue + + if ext == "py": + self.import_module("%s.%s" % (package , module)) + + return True diff --git a/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py b/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py new file mode 100644 index 0000000000..ff3bd729d6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import sys +import fnmatch +import os +import unittest +try: + from pylint import epylint as lint +except ImportError: + sys.stderr.write("Could not import pylint module - lint based testing will be skipped\n") + lint = None + + +class LintTestCase(unittest.TestCase): + """This class is a test case for linting.""" + + LINT_ARGS = ['-d', 'R,C,W'] + \ + ['--extension-pkg-whitelist=numpy'] + + + @staticmethod + def _get_lintable_files(paths, whitelist=()): + """Recursively traverses all folders in paths for *.py files""" + matches = [] + for folder in paths: + for root, _, filenames in os.walk(folder): + for filename in fnmatch.filter(filenames, '*.py'): + if filename not in whitelist: + matches.append(os.path.join(root, filename)) + return matches + + + def assertLinted(self, paths, whitelist=()): # noqa + """Takes a path to a folder or a list of paths to folders and recursively finds + all *.py files within that folder except the ones with filenames in whitelist. + + Will assert lint.lint(fname) == 0 for every *.py file found. + """ + if lint is None: + self.skipTest("pylint not installed") + + if isinstance(paths, str): + paths = [paths] + files = self._get_lintable_files(paths, whitelist=whitelist) + for f in files: + self.assertEqual(0, lint.lint(f, self.LINT_ARGS), 'Linting required for %s' % f) diff --git a/ThirdParty/Ert/python/ecl/util/test/path_context.py b/ThirdParty/Ert/python/ecl/util/test/path_context.py new file mode 100644 index 0000000000..98dda72040 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/path_context.py @@ -0,0 +1,46 @@ +import os +import shutil + +class PathContext(object): + def __init__(self , path , store = False): + self.path = path + self.cwd = os.getcwd() + self.store = store + self.path_list = [ ] + + if not os.path.exists(path): + work_path = path + + while True: + work_path , base = os.path.split(work_path) + if work_path: + if os.path.isdir(work_path): + break + else: + self.path_list.append( work_path ) + else: + break + + os.makedirs( path ) + else: + if not self.store: + raise OSError("Entry %s already exists" % path) + os.chdir( path ) + + + + def __exit__(self , exc_type , exc_val , exc_tb): + os.chdir( self.cwd ) + if self.store == False: + shutil.rmtree( self.path ) + for path in self.path_list: + try: + os.rmdir( path ) + except OSError: + break + + return False + + + def __enter__(self): + return self diff --git a/ThirdParty/Ert/python/ecl/util/test/source_enumerator.py b/ThirdParty/Ert/python/ecl/util/test/source_enumerator.py new file mode 100644 index 0000000000..e0c76300f1 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/source_enumerator.py @@ -0,0 +1,39 @@ +import os +import re + +class SourceEnumerator(object): + + @classmethod + def removeComments(cls, code_string): + code_string = re.sub(re.compile("/\*.*?\*/",re.DOTALL ) ,"" ,code_string) # remove all occurance streamed comments (/*COMMENT */) from string + code_string = re.sub(re.compile("//.*?\n" ) ,"" ,code_string) # remove all occurance singleline comments (//COMMENT\n ) from string + return code_string + + + @classmethod + def findEnum(cls, enum_name, full_source_file_path): + with open(full_source_file_path, "r") as f: + text = f.read() + + text = SourceEnumerator.removeComments(text) + + enum_pattern = re.compile("typedef\s+enum\s+\{(.*?)\}\s*(\w+?);", re.DOTALL) + + for enum in enum_pattern.findall(text): + if enum[1] == enum_name: + return enum[0] + + raise ValueError("Enum with name: '%s' not found!" % enum_name) + + + @classmethod + def findEnumerators(cls, enum_name, source_file): + enum_text = SourceEnumerator.findEnum(enum_name, source_file) + + enumerator_pattern = re.compile("(\w+?)\s*?=\s*?(\d+)") + + enumerators = [] + for enumerator in enumerator_pattern.findall(enum_text): + enumerators.append((enumerator[0], int(enumerator[1]))) + + return enumerators diff --git a/ThirdParty/Ert/python/ecl/util/test/temp_area.py b/ThirdParty/Ert/python/ecl/util/test/temp_area.py new file mode 100644 index 0000000000..4b7d2aa697 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/temp_area.py @@ -0,0 +1,81 @@ +# Copyright (C) 2016 Statoil ASA, Norway. +# +# The file 'temp_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +import os.path +from ecl import EclPrototype +from . import TestArea + +class TempArea(TestArea): + """TempArea class is essentially similar to the TestArea class, with + the only difference that the cwd is *not* changed into the newly + created area. + """ + + _temp_area_alloc = EclPrototype("void* temp_area_alloc( char* )" , bind = False) + _temp_area_alloc_relative = EclPrototype("void* temp_area_alloc_relative( char* , char* )" , bind = False) + + def __init__(self, name, prefix = None , store_area=False): + if prefix: + if os.path.exists( prefix ): + c_ptr = self._temp_area_alloc_relative(prefix , name) + else: + raise IOError("The prefix path:%s must exist" % prefix) + else: + c_ptr = self._temp_area_alloc(name) + super(TempArea, self).__init__(name , c_ptr = c_ptr , store_area = store_area) + + + def __str__(self): + return self.getPath() + + + def get_cwd(self): + """ + Since the TempArea class does *not* change the cwd this method + just returns the ordinary os.getcwd(). + """ + return os.getcwd() + + + def getPath(self): + """ + Will return the full path to the temporary working area. + """ + return self._get_cwd( ) + + + +class TempAreaContext(object): + def __init__(self, name, prefix = None , store_area=False): + self.name = name + self.store_area = store_area + self.prefix = prefix + + def __enter__(self): + """ + @rtype: TempArea + """ + self.temp_area = TempArea(self.name, prefix = self.prefix , store_area = self.store_area ) + return self.temp_area + + + def __exit__(self, exc_type, exc_val, exc_tb): + del self.temp_area + return False + + + diff --git a/ThirdParty/Ert/python/ecl/util/test/test_area.py b/ThirdParty/Ert/python/ecl/util/test/test_area.py new file mode 100644 index 0000000000..5f90b320f5 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/test_area.py @@ -0,0 +1,151 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os.path + +from cwrap import BaseCClass +from ecl import EclPrototype + + +class TestArea(BaseCClass): + _test_area_alloc = EclPrototype("void* test_work_area_alloc( char* )" , bind = False) + _test_area_alloc_relative = EclPrototype("void* test_work_area_alloc_relative( char* , char* )" , bind = False) + _free = EclPrototype("void test_work_area_free( test_area )") + _install_file = EclPrototype("void test_work_area_install_file( test_area , char* )") + _copy_directory = EclPrototype("void test_work_area_copy_directory( test_area , char* )") + _copy_file = EclPrototype("void test_work_area_copy_file( test_area , char* )") + _copy_directory_content = EclPrototype("void test_work_area_copy_directory_content( test_area , char* )") + _copy_parent_directory = EclPrototype("void test_work_area_copy_parent_directory( test_area , char* )") + _copy_parent_content = EclPrototype("void test_work_area_copy_parent_content( test_area , char* )") + _get_cwd = EclPrototype("char* test_work_area_get_cwd( test_area )") + _get_original_cwd = EclPrototype("char* test_work_area_get_original_cwd( test_area )") + _set_store = EclPrototype("void test_work_area_set_store( test_area , bool)") + _sync = EclPrototype("void test_work_area_sync( test_area )") + + def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): + + if c_ptr is None: + if prefix: + if os.path.exists( prefix ): + c_ptr = self._test_area_alloc_relative(prefix , test_name) + else: + raise IOError("The prefix path:%s must exist" % prefix) + else: + c_ptr = self._test_area_alloc(test_name) + + super(TestArea, self).__init__(c_ptr) + self.set_store( store_area ) + + + def get_original_cwd(self): + return self._get_original_cwd() + + def get_cwd(self): + return self._get_cwd() + + def orgPath(self , path): + if os.path.isabs( path ): + return path + else: + return os.path.abspath( os.path.join( self.get_original_cwd( ) , path ) ) + + + # All the methods install_file() , copy_directory(), + # copy_parent_directory(), copy_parent_content(), + # copy_directory_content() and copy_file() expect an input + # argument which is relative to the original CWD - or absolute. + + def install_file( self, filename): + if os.path.isfile(self.orgPath(filename)): + self._install_file(filename) + else: + raise IOError("No such file:%s" % filename) + + + def copy_directory( self, directory): + if os.path.isdir( self.orgPath(directory) ): + self._copy_directory(directory) + else: + raise IOError("No such directory: %s" % directory) + + def copy_parent_directory( self , path): + if os.path.exists( self.orgPath(path) ): + self._copy_parent_directory( path) + else: + raise IOError("No such file or directory: %s" % path) + + + def copy_parent_content( self , path): + if os.path.exists( self.orgPath(path) ): + self._copy_parent_content(path) + else: + raise IOError("No such file or directory: %s" % path) + + def copy_directory_content( self, directory): + if os.path.isdir( self.orgPath(directory) ): + self._copy_directory_content(directory) + else: + raise IOError("No such directory: %s" % directory ) + + + def copy_file( self, filename): + if os.path.isfile( self.orgPath(filename) ): + self._copy_file(filename) + else: + raise IOError("No such file:%s" % filename) + + + def free(self): + self._free() + + + def set_store(self, store): + self._set_store(store) + + + def getFullPath(self , path): + if not os.path.exists( path ): + raise IOError("Path not found:%s" % path) + + if os.path.isabs( path ): + raise IOError("Path:%s is already absolute" % path) + + return os.path.join( self.get_cwd() , path ) + + + def sync(self): + return self._sync( ) + + + +class TestAreaContext(object): + def __init__(self, test_name, prefix = None , store_area=False): + self.test_name = test_name + self.store_area = store_area + self.prefix = prefix + + def __enter__(self): + """ + @rtype: TestArea + """ + self.test_area = TestArea(self.test_name, prefix = self.prefix , store_area = self.store_area ) + return self.test_area + + + def __exit__(self, exc_type, exc_val, exc_tb): + self.test_area.free() # free the TestData object (and cd back to the original dir) + self.test_area.free = None # avoid double free + del self.test_area + return False diff --git a/ThirdParty/Ert/python/ecl/util/test/test_run.py b/ThirdParty/Ert/python/ecl/util/test/test_run.py new file mode 100644 index 0000000000..496353ba4d --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/test_run.py @@ -0,0 +1,158 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_run.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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, teither version 3 of the License, or +# (at your option) any later version. +# +# ERT 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. +import random +import os.path +import subprocess +import argparse +from .test_area import TestAreaContext + + +def path_exists( path ): + if os.path.exists( path ): + return (True , "Path:%s exists" % path) + else: + return (False , "ERROR: Path:%s does not exist" % path) + + +class TestRun(object): + default_ert_cmd = "ert" + default_ert_version = "stable" + default_path_prefix = None + + def __init__(self , config_file , args = [] , name = None): + if os.path.exists( config_file ) and os.path.isfile( config_file ): + self.parseArgs(args) + self.__ert_cmd = TestRun.default_ert_cmd + self.path_prefix = TestRun.default_path_prefix + self.config_file = config_file + + self.check_list = [] + self.workflows = [] + if name: + self.name = name + else: + self.name = config_file.replace("/" , ".") + while True: + if self.name[0] == ".": + self.name = self.name[1:] + else: + break + self.name += "/%08d" % random.randint(0,100000000) + else: + raise IOError("No such config file: %s" % config_file) + + + def parseArgs(self , args): + parser = argparse.ArgumentParser() + parser.add_argument("-v" , "--version" , default = self.default_ert_version) + parser.add_argument("args" , nargs="*") + result = parser.parse_args(args) + self.ert_version = result.version + self.args = result.args + + + def get_config_file(self): + return self.__config_file + + def set_config_file(self , input_config_file): + self.__config_file = os.path.basename( input_config_file ) + self.abs_config_file = os.path.abspath( input_config_file ) + + config_file = property( get_config_file , set_config_file ) + + #----------------------------------------------------------------- + + def set_path_prefix(self , path_prefix): + self.__path_prefix = path_prefix + + def get_path_prefix(self): + return self.__path_prefix + + path_prefix = property( get_path_prefix , set_path_prefix ) + + #----------------------------------------------------------------- + + def get_ert_cmd(self): + return self.__ert_cmd + + def set_ert_cmd(self , cmd): + self.__ert_cmd = cmd + + ert_cmd = property( get_ert_cmd , set_ert_cmd) + + #----------------------------------------------------------------- + + def get_workflows(self): + return self.workflows + + + def add_workflow(self , workflow): + self.workflows.append( workflow ) + + #----------------------------------------------------------------- + + def get_args(self): + return self.args + + #----------------------------------------------------------------- + + def add_check( self , check_func , arg): + if callable(check_func): + self.check_list.append( (check_func , arg) ) + else: + raise Exception("The checker:%s is not callable" % check_func ) + + #----------------------------------------------------------------- + + def __run(self , work_area ): + argList = [ self.ert_cmd , "-v" , self.ert_version ] + for arg in self.args: + argList.append( arg ) + + argList.append( self.config_file ) + for wf in self.workflows: + argList.append( wf ) + + status = subprocess.call( argList ) + if status == 0: + return (True , "ert has run successfully") + else: + return (False , "ERROR:: ert exited with status code:%s" % status) + + + def run(self): + if len(self.workflows): + with TestAreaContext(self.name , prefix = self.path_prefix , store_area = False) as work_area: + test_cwd = work_area.get_cwd() + work_area.copy_parent_content( self.abs_config_file ) + status = self.__run( work_area ) + global_status = status[0] + + status_list = [ status ] + if status[0]: + for (check_func , arg) in self.check_list: + status = check_func( arg ) + status_list.append( status ) + if not status[0]: + global_status = False + + if not global_status: + work_area.set_store( True ) + + return (global_status , test_cwd , status_list) + else: + raise Exception("Must have added workflows before invoking start()") + diff --git a/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt new file mode 100644 index 0000000000..8374950ce2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt @@ -0,0 +1,24 @@ +set(PYTHON_SOURCES + __init__.py + bool_vector.py + ctime.py + double_vector.py + hash.py + int_vector.py + install_abort_signals.py + lookup_table.py + rng.py + stringlist.py + #substitution_list.py + thread_pool.py + time_vector.py + util_func.py + vector_template.py + permutation_vector.py + version.py + arg_pack.py + cwd_context.py +) + +add_python_package("python.ecl.util.util" ${PYTHON_INSTALL_PREFIX}/ecl/util/util "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/python/ecl/util/util/__init__.py b/ThirdParty/Ert/python/ecl/util/util/__init__.py new file mode 100644 index 0000000000..feccb678d1 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/__init__.py @@ -0,0 +1,120 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Package with utility classes, used by other ERT classes. + +The libutil library implements many utility functions and classes of +things like hash table and vector; these classes are extensively used +by the other ert libraries. The present wrapping here is to facilitate +use and interaction with various ert classes, in a pure python context +you are probably better served by using a plain python solution; +either based on built in python objects or well established third +party packages. + +The modules included in the util package are: + + tvector.py: This module implements the classes IntVector, + DoubleVector and BoolVector. This is a quite normal + implementation of a typed growable vector; but with a special + twist regarding default values. + + util_func.py: This module wraps a couple of stateless (i.e. there is + no class involved) functions from the util.c file. + +""" + +from __future__ import (absolute_import, division, + print_function, unicode_literals) + +import ecl +from cwrap import Prototype + + + +from .version import Version, EclVersion + +from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum + +from .ctime import CTime + +from .permutation_vector import PermutationVector +from .vector_template import VectorTemplate +from .double_vector import DoubleVector +from .int_vector import IntVector +from .bool_vector import BoolVector +from .time_vector import TimeVector +from .stringlist import StringList +from .rng import RandomNumberGenerator +from .lookup_table import LookupTable +from .hash import Hash, StringHash, DoubleHash, IntegerHash +from .thread_pool import ThreadPool +from .install_abort_signals import installAbortSignals, updateAbortSignals +from .arg_pack import ArgPack +from .cwd_context import CWDContext + + + +### +### monkey_the_camel is a function temporarily added to libecl while we are in +### the process of changing camelCase function names to snake_case function +### names. +### +### See https://github.com/Statoil/libecl/issues/142 for a discussion and for +### usage. +### + +import os +import warnings + +__cc = os.environ.get('ECLWARNING', None) # __cc in (None, 'user', 'dev', 'hard') + +def __silencio(msg): + pass + +def __user_warning(msg): + print('User warning: ' + msg) + +def __dev_warning(msg): + warnings.warn(msg, DeprecationWarning) + +def __hard_warning(msg): + raise UserWarning('CamelCase exception: ' + msg) + + +__ecl_camel_case_warning = __silencio +if __cc == 'user': + __ecl_camel_case_warning = __user_warning +elif __cc == 'dev': + __ecl_camel_case_warning = __dev_warning +elif __cc == 'hard': + __ecl_camel_case_warning = __hard_warning + + +def monkey_the_camel(class_, camel, method_, method_type=None): + """Creates a method "class_.camel" in class_ which prints a warning and forwards + to method_. method_type should be one of (None, classmethod, staticmethod), + and generates new methods accordingly. + """ + def shift(*args): + return args if (method_type != classmethod) else args[1:] + def warned_method(*args, **kwargs): + __ecl_camel_case_warning('Warning, %s is deprecated, use %s' % (camel, str(method_))) + return method_(*shift(*args), **kwargs) + if method_type == staticmethod: + warned_method = staticmethod(warned_method) + elif method_type == classmethod: + warned_method = classmethod(warned_method) + setattr(class_, camel, warned_method) diff --git a/ThirdParty/Ert/python/ecl/util/util/arg_pack.py b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py new file mode 100644 index 0000000000..4b53e03b18 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py @@ -0,0 +1,57 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'arg_pack.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from cwrap import BaseCClass +from ecl import EclPrototype + + +class ArgPack(BaseCClass): + TYPE_NAME = "arg_pack" + + _alloc = EclPrototype("void* arg_pack_alloc()" , bind = False) + _append_int = EclPrototype("void arg_pack_append_int(arg_pack, int)") + _append_double = EclPrototype("void arg_pack_append_double(arg_pack, double)") + _append_ptr = EclPrototype("void arg_pack_append_ptr(arg_pack, void*)") + + _size = EclPrototype("int arg_pack_size(arg_pack)") + _free = EclPrototype("void arg_pack_free(arg_pack)") + + def __init__(self, *args): + c_ptr = self._alloc() + super(ArgPack, self).__init__(c_ptr) + self.child_list = [] + for arg in args: + self.append(arg) + + + def append(self, data): + if isinstance(data, int): + self._append_int(data) + elif isinstance(data, float): + self._append_double(data) + elif isinstance(data, BaseCClass): + self._append_ptr(BaseCClass.from_param(data)) + self.child_list.append(data) + else: + raise TypeError("Can only add int/double/basecclass") + + + def __len__(self): + return self._size() + + + def free(self): + self._free( ) diff --git a/ThirdParty/Ert/python/ecl/util/util/bool_vector.py b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py new file mode 100644 index 0000000000..d688562682 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py @@ -0,0 +1,154 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class BoolVector(VectorTemplate): + default_format = "%8d" + + _alloc = EclPrototype("void* bool_vector_alloc( int , bool )" , bind = False) + _create_active_mask = EclPrototype("bool_vector_obj string_util_alloc_active_mask( char* )" , bind = False) + _active_list = EclPrototype("int_vector_obj bool_vector_alloc_active_list(bool_vector)", bind = False) + _alloc_copy = EclPrototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )") + _update_active_mask = EclPrototype("bool string_util_update_active_mask(char*, bool_vector)" , bind = False) + + _strided_copy = EclPrototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)") + _free = EclPrototype("void bool_vector_free( bool_vector )") + _iget = EclPrototype("bool bool_vector_iget( bool_vector , int )") + _safe_iget = EclPrototype("bool bool_vector_safe_iget( bool_vector , int )") + _iset = EclPrototype("void bool_vector_iset( bool_vector , int , bool)") + _size = EclPrototype("int bool_vector_size( bool_vector )") + _append = EclPrototype("void bool_vector_append( bool_vector , bool )") + _idel_block = EclPrototype("void bool_vector_idel_block( bool_vector , bool , bool )") + _idel = EclPrototype("void bool_vector_idel( bool_vector , int )") + _pop = EclPrototype("bool bool_vector_pop( bool_vector )") + _lshift = EclPrototype("void bool_vector_lshift( bool_vector , int )") + _rshift = EclPrototype("void bool_vector_rshift( bool_vector , int )") + _insert = EclPrototype("void bool_vector_insert( bool_vector , int , bool)") + _fprintf = EclPrototype("void bool_vector_fprintf( bool_vector , FILE , char* , char*)") + _sort = EclPrototype("void bool_vector_sort( bool_vector )") + _rsort = EclPrototype("void bool_vector_rsort( bool_vector )") + _reset = EclPrototype("void bool_vector_reset( bool_vector )") + _set_read_only = EclPrototype("void bool_vector_set_read_only( bool_vector , bool )") + _get_read_only = EclPrototype("bool bool_vector_get_read_only( bool_vector )") + _get_max = EclPrototype("bool bool_vector_get_max( bool_vector )") + _get_min = EclPrototype("bool bool_vector_get_min( bool_vector )") + _get_max_index = EclPrototype("int bool_vector_get_max_index( bool_vector , bool)") + _get_min_index = EclPrototype("int bool_vector_get_min_index( bool_vector , bool)") + _shift = EclPrototype("void bool_vector_shift( bool_vector , bool )") + _scale = EclPrototype("void bool_vector_scale( bool_vector , bool )") + _div = EclPrototype("void bool_vector_div( bool_vector , bool )") + _inplace_add = EclPrototype("void bool_vector_inplace_add( bool_vector , bool_vector )") + _inplace_mul = EclPrototype("void bool_vector_inplace_mul( bool_vector , bool_vector )") + _assign = EclPrototype("void bool_vector_set_all( bool_vector , bool)") + _memcpy = EclPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") + _set_default = EclPrototype("void bool_vector_set_default( bool_vector , bool)") + _get_default = EclPrototype("bool bool_vector_get_default( bool_vector )") + _element_size = EclPrototype("int bool_vector_element_size( bool_vector )") + + _permute = EclPrototype("void bool_vector_permute(bool_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj bool_vector_alloc_rsort_perm(bool_vector)") + + _contains = EclPrototype("bool bool_vector_contains(bool_vector, bool)") + _select_unique = EclPrototype("void bool_vector_select_unique(bool_vector)") + _element_sum = EclPrototype("bool bool_vector_sum(bool_vector)") + _get_data_ptr = EclPrototype("bool* bool_vector_get_ptr(bool_vector)") + _count_equal = EclPrototype("int bool_vector_count_equal(bool_vector, bool)") + _init_linear = None + _equal = EclPrototype("bool bool_vector_equal(bool_vector, bool_vector)") + _first_eq = EclPrototype("int bool_vector_first_equal(bool_vector, bool_vector, int)") + _first_neq = EclPrototype("int bool_vector_first_not_equal(bool_vector, bool_vector, int)") + + + def __init__(self, default_value=False, initial_size=0): + super(BoolVector, self).__init__(default_value, initial_size) + + def count(self, value=True): + """ @rtype: int """ + return self._count_equal(self, value) + + @classmethod + def createActiveMask(cls, range_string): + """ + Will create a BoolVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} + "1,4-7,10X" => {} + + The empty list will evaluate to false + @rtype: BoolVector + """ + return cls._create_active_mask(range_string) + + def updateActiveMask(self, range_string): + """ + Updates a bool vector based on a range string. + @type range_string: str + @type bool_vector: BoolVector + @rtype: bool + """ + return self._update_active_mask(range_string , self) + + @classmethod + def createFromList(cls, size, source_list): + """ + Allocates a bool vector from a Python list of indexes + @rtype: BoolVector + """ + bool_vector = BoolVector(False, size) + + for index in source_list: + index = int(index) + bool_vector[index] = True + + return bool_vector + + def createActiveList(self): + """ @rtype: ecl.util.IntVector """ + return self._active_list(self) + + def _tostr(self, arr = None): + if arr is None: + arr = self + return "".join(['1' if x else '0' for x in arr]) + + def __repr__(self): + """Will return BoolVector(size = 4, content = "0010") at 0x1729 and + if size > 10, will return content = "0001...100", i.e., |content|<=10. + """ + cnt = '' + ls = len(self) + if ls <= 20: + cnt = self._tostr() + else: + a,b = self[:9], self[-8:] + cnt = self._tostr(a) + cnt += "..." + cnt += self._tostr(b) + return 'BoolVector(size = %d, content = "%s") %s' % (ls, cnt, self._ad_str()) + + + @classmethod + def create_linear(cls, start_value, end_value, num_values): + raise NotImplementedError("The init_linear method does not make sense for bool vectors") diff --git a/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py new file mode 100644 index 0000000000..39d8c3be91 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py @@ -0,0 +1,88 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'cthread_pool.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes + +from cwrap import BaseCClass +from ecl import EclPrototype + +import weakref + + +class CThreadPool(BaseCClass): + TYPE_NAME = "thread_pool" + + _alloc = EclPrototype("void* thread_pool_alloc(int, bool)", bind = False) + _free = EclPrototype("void thread_pool_free(thread_pool)") + _add_job = EclPrototype("void thread_pool_add_job(thread_pool, void*, void*)") + _join = EclPrototype("void thread_pool_join(thread_pool)") + + def __init__(self, pool_size, start=True): + c_ptr = self._alloc(pool_size, start) + super(CThreadPool, self).__init__(c_ptr) + self.arg_list = [] + + def addTaskFunction(self, name, lib, c_function_name): + function = CThreadPool.lookupCFunction(lib, c_function_name) + self_ref = weakref.ref(self) # avoid circular dependencies + + def wrappedFunction(arg): + return self_ref().addTask(function, arg) + + setattr(self, name, wrappedFunction) + + def addTask(self, cfunc, arg): + """ + The function should come from CThreadPool.lookupCFunction(). + """ + if isinstance(arg, BaseCClass): + arg_ptr = BaseCClass.from_param(arg) + else: + arg_ptr = arg + + self.arg_list.append(arg) + self._add_job(cfunc, arg_ptr) + + def join(self): + self._join() + + def free(self): + self.join() + self._free() + + @staticmethod + def lookupCFunction(lib, name): + if isinstance(lib, ctypes.CDLL): + func = getattr(lib, name) + return func + else: + raise TypeError("The lib argument must be of type ctypes.CDLL") + + +class CThreadPoolContextManager(object): + def __init__(self, tp): + self.__tp = tp + + def __enter__(self): + return self.__tp + + def __exit__(self, exc_type, exc_val, exc_tb): + self.__tp.join() + return False + + +def startCThreadPool(size): + return CThreadPoolContextManager(CThreadPool(size, start=True)) diff --git a/ThirdParty/Ert/python/ecl/util/util/ctime.py b/ThirdParty/Ert/python/ecl/util/util/ctime.py new file mode 100644 index 0000000000..0c92ecd893 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/ctime.py @@ -0,0 +1,148 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ctime.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +import ctypes +import datetime +import time + +from cwrap import BaseCValue +from ecl import EclPrototype + + +class CTime(BaseCValue): + TYPE_NAME = "time_t" + DATA_TYPE = ctypes.c_long + _timezone = EclPrototype("char* util_get_timezone()" , bind = False) + _timegm = EclPrototype("long util_make_datetime_utc(int, int, int, int, int, int)" , bind = False) + + def __init__(self, value): + if isinstance(value, int): + value = value + elif isinstance(value, CTime): + value = value.value() + elif isinstance(value, datetime.datetime): + value = CTime._timegm(value.second, value.minute, value.hour, value.day, value.month, value.year) + elif isinstance(value, datetime.date): + value = CTime._timegm(0, 0, 0, value.day, value.month, value.year) + else: + raise NotImplementedError("Can not convert class %s to CTime" % value.__class__) + + super(CTime, self).__init__(value) + + def ctime(self): + """ @rtype: int """ + return self.value() + + def time(self): + """Return this time_t as a time.gmtime() object""" + return time.gmtime(self.value()) + + def date(self): + """Return this time_t as a datetime.date([year, month, day])""" + return datetime.date(*self.time()[0:3]) + + def datetime(self): + return datetime.datetime(*self.time()[0:6]) + + def __str__(self): + return self.datetime().strftime("%Y-%m-%d %H:%M:%S%z") + + def __ge__(self, other): + return self > other or self == other + + def __le__(self, other): + return self < other or self == other + + def __gt__(self, other): + if isinstance(other, CTime): + return self.value() > other.value() + elif isinstance(other, (int, datetime.datetime, datetime.date)): + return self > CTime(other) + else: + raise TypeError("CTime does not support type: %s" % other.__class__) + + def __lt__(self, other): + if isinstance(other, CTime): + return self.value() < other.value() + elif isinstance(other, (int, datetime.datetime, datetime.date)): + return self < CTime(other) + else: + raise TypeError("CTime does not support type: %s" % other.__class__) + + def __ne__(self, other): + return not self == other + + def __eq__(self, other): + if isinstance(other, CTime): + return self.value() == other.value() + elif isinstance(other, (int, datetime.datetime, datetime.date)): + return self == CTime(other) + elif isinstance(other, type(None)): + return False + else: + raise TypeError("CTime does not support type: %s" % other.__class__) + + def __imul__(self, other): + value = int(self.value() * other) + self.setValue(value) + return self + + def __hash__(self): + return hash(self.value()) + + def __iadd__(self, other): + if isinstance(other, CTime): + self.setValue(self.value() + other.value()) + return self + else: + self.setValue(self.value() + CTime(other).value()) + return self + + def __add__(self, other): + copy = CTime(self) + copy += other + return copy + + def __radd__(self, other): + return self + other + + def __mul__(self, other): + copy = CTime(self) + copy *= other + return copy + + def __rmul__(self, other): + return self * other + + def timetuple(self): + # this function is a requirement for comparing against datetime objects where the CTime is on the right side + pass + + def __repr__(self): + return "time_t value: %d [%s]" % (self.value(), str(self)) + + @property + def stripped(self): + return time.strptime(self, "%Y-%m-%d %H:%M:S%") + + @classmethod + def timezone(cls): + """ + Returns the current timezone "in" C + @rtype: str + """ + return CTime._timezone() diff --git a/ThirdParty/Ert/python/ecl/util/util/cwd_context.py b/ThirdParty/Ert/python/ecl/util/util/cwd_context.py new file mode 100644 index 0000000000..c51eb81399 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/cwd_context.py @@ -0,0 +1,16 @@ +import os + +class CWDContext(object): + def __init__(self , path): + self.cwd = os.getcwd() + if os.path.isdir( path ): + os.chdir( path ) + else: + raise IOError("Path:%s does not exist" % path) + + def __exit__(self , exc_type , exc_val , exc_tb): + os.chdir( self.cwd ) + return False + + def __enter__(self): + return self diff --git a/ThirdParty/Ert/python/ecl/util/util/double_vector.py b/ThirdParty/Ert/python/ecl/util/util/double_vector.py new file mode 100644 index 0000000000..9ba7100958 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/double_vector.py @@ -0,0 +1,77 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'double_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class DoubleVector(VectorTemplate): + default_format = "%8.4f" + + _alloc = EclPrototype("void* double_vector_alloc( int , double )" , bind = False) + _alloc_copy = EclPrototype("double_vector_obj double_vector_alloc_copy( double_vector )") + _strided_copy = EclPrototype("double_vector_obj double_vector_alloc_strided_copy( double_vector , int , int , int)") + _free = EclPrototype("void double_vector_free( double_vector )") + _iget = EclPrototype("double double_vector_iget( double_vector , int )") + _safe_iget = EclPrototype("double double_vector_safe_iget(double_vector , int )") + _iset = EclPrototype("double double_vector_iset( double_vector , int , double)") + _size = EclPrototype("int double_vector_size( double_vector )") + _append = EclPrototype("void double_vector_append( double_vector , double )") + _idel_block = EclPrototype("void double_vector_idel_block( double_vector , int , int )") + _pop = EclPrototype("double double_vector_pop( double_vector )") + _idel = EclPrototype("void double_vector_idel( double_vector , int )") + _lshift = EclPrototype("void double_vector_lshift( double_vector , int )") + _rshift = EclPrototype("void double_vector_rshift( double_vector , int )") + _insert = EclPrototype("void double_vector_insert( double_vector , int , double)") + _fprintf = EclPrototype("void double_vector_fprintf( double_vector , FILE , char* , char*)") + _sort = EclPrototype("void double_vector_sort( double_vector )") + _rsort = EclPrototype("void double_vector_rsort( double_vector )") + _reset = EclPrototype("void double_vector_reset( double_vector )") + _get_read_only = EclPrototype("bool double_vector_get_read_only( double_vector )") + _set_read_only = EclPrototype("void double_vector_set_read_only( double_vector , bool )") + _get_max = EclPrototype("double double_vector_get_max( double_vector )") + _get_min = EclPrototype("double double_vector_get_min( double_vector )") + _get_max_index = EclPrototype("int double_vector_get_max_index( double_vector , bool)") + _get_min_index = EclPrototype("int double_vector_get_min_index( double_vector , bool)") + _shift = EclPrototype("void double_vector_shift( double_vector , double )") + _scale = EclPrototype("void double_vector_scale( double_vector , double )") + _div = EclPrototype("void double_vector_div( double_vector , double )") + _inplace_add = EclPrototype("void double_vector_inplace_add( double_vector , double_vector )") + _inplace_mul = EclPrototype("void double_vector_inplace_mul( double_vector , double_vector )") + _assign = EclPrototype("void double_vector_set_all( double_vector , double)") + _memcpy = EclPrototype("void double_vector_memcpy(double_vector , double_vector )") + _set_default = EclPrototype("void double_vector_set_default( double_vector , double)") + _get_default = EclPrototype("double double_vector_get_default( double_vector )") + _element_size = EclPrototype("int double_vector_element_size( double_vector )") + + _permute = EclPrototype("void double_vector_permute(double_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj double_vector_alloc_sort_perm(double_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)") + _contains = EclPrototype("bool double_vector_contains(double_vector, double)") + _select_unique = EclPrototype("void double_vector_select_unique(double_vector)") + _element_sum = EclPrototype("double double_vector_sum(double_vector)") + _get_data_ptr = EclPrototype("double* double_vector_get_ptr(double_vector)") + _count_equal = EclPrototype("int double_vector_count_equal(double_vector, double)") + _init_range = EclPrototype("void double_vector_init_range(double_vector, double , double , double)") + _init_linear = EclPrototype("bool double_vector_init_linear(double_vector, double, double, int)") + _equal = EclPrototype("bool double_vector_equal(double_vector, double_vector)") + _first_eq = EclPrototype("int double_vector_first_equal(double_vector, double_vector, int)") + _first_neq = EclPrototype("int double_vector_first_not_equal(double_vector, double_vector, int)") + + + + def __init__(self, default_value=0, initial_size=0): + super(DoubleVector, self).__init__(default_value, initial_size) diff --git a/ThirdParty/Ert/python/ecl/util/util/hash.py b/ThirdParty/Ert/python/ecl/util/util/hash.py new file mode 100644 index 0000000000..3edc600763 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/hash.py @@ -0,0 +1,134 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'hash.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from ctypes import c_void_p + +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.util.util import StringList + + +class Hash(BaseCClass): + _alloc = EclPrototype("void* hash_alloc()" , bind = False) + _free = EclPrototype("void hash_free(hash)") + _size = EclPrototype("int hash_get_size(hash)") + _keys = EclPrototype("stringlist_obj hash_alloc_stringlist(hash)") + _has_key = EclPrototype("bool hash_has_key(hash, char*)") + _get = EclPrototype("void* hash_get(hash, char*)") + _insert_ref = EclPrototype("void hash_insert_ref(hash, char*, void*)") + + """ + Base hash class that supports string:void* values + """ + + def __init__(self): + c_ptr = self._alloc() + super(Hash, self).__init__(c_ptr) + + def __len__(self): + return self._size() + + def __getitem__(self, key): + if self._has_key(key): + return self._get(key) + else: + raise KeyError("Hash does not have key: %s" % key) + + def __setitem__(self, key, value): + if isinstance(value, c_void_p): + self._insert_ref(key, value) + else: + raise ValueError("Hash does not support type: %s" % value.__class__) + + def __contains__(self, key): + """ @rtype: bool """ + return self._has_key(key) + + def __iter__(self): + for key in self.keys(): + yield key + + def keys(self): + """ @rtype: StringList """ + return self._keys() + + def free(self): + self._free() + + def __str__(self): + return str(["%s: %s" % (key, self[key]) for key in self.keys()]) + + +class StringHash(Hash): + _get_string = EclPrototype("char* hash_get_string(hash, char*)") + _insert_string = EclPrototype("void hash_insert_string(hash, char*, char*)") + + def __init__(self): + super(StringHash, self).__init__() + + def __setitem__(self, key, value): + if isinstance(value, str): + self._insert_string(key, value) + else: + raise ValueError("StringHash does not support type: %s" % value.__class__) + + def __getitem__(self, key): + if key in self: + return self._get_string(key) + else: + raise KeyError("Hash does not have key: %s" % key) + + +class IntegerHash(Hash): + _get_int = EclPrototype("int hash_get_int(hash, char*)") + _insert_int = EclPrototype("void hash_insert_int(hash, char*, int)") + + def __init__(self): + super(IntegerHash, self).__init__() + + def __setitem__(self, key, value): + if isinstance(value, int): + self._insert_int(key, value) + else: + raise ValueError("IntegerHash does not support type: %s" % value.__class__) + + def __getitem__(self, key): + if key in self: + return self._get_int(key) + else: + raise KeyError("Hash does not have key: %s" % key) + + +class DoubleHash(Hash): + _get_double = EclPrototype("double hash_get_double(hash, char*)") + _insert_double = EclPrototype("void hash_insert_double(hash, char*, double)") + + def __init__(self): + super(DoubleHash, self).__init__() + + def __setitem__(self, key, value): + if isinstance(value, int): + value = float(value) + + if isinstance(value, float): + self._insert_double(key, value) + else: + raise ValueError("DoubleHash does not support type: %s" % value.__class__) + + def __getitem__(self, key): + if key in self: + return self._get_double( key) + else: + raise KeyError("Hash does not have key: %s" % key) diff --git a/ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py b/ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py new file mode 100644 index 0000000000..70b9a22be0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py @@ -0,0 +1,16 @@ +from ecl import EclPrototype + + +def installAbortSignals(): + install_signals() + + +def updateAbortSignals(): + """ + Will install the util_abort_signal for all UNMODIFIED signals. + """ + update_signals() + + +install_signals = EclPrototype("void util_install_signals()") +update_signals = EclPrototype("void util_update_signals()") diff --git a/ThirdParty/Ert/python/ecl/util/util/int_vector.py b/ThirdParty/Ert/python/ecl/util/util/int_vector.py new file mode 100644 index 0000000000..f280603df8 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/int_vector.py @@ -0,0 +1,113 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'int_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class IntVector(VectorTemplate): + default_format = "%d" + + _alloc = EclPrototype("void* int_vector_alloc( int , int )" , bind = False) + _create_active_list = EclPrototype("int_vector_obj string_util_alloc_active_list( char*)" , bind = False) + _create_value_list = EclPrototype("int_vector_obj string_util_alloc_value_list( char*)" , bind = False) + _alloc_copy = EclPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") + _strided_copy = EclPrototype("int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)") + _free = EclPrototype("void int_vector_free( int_vector )") + _iget = EclPrototype("int int_vector_iget( int_vector , int )") + _safe_iget = EclPrototype("int int_vector_safe_iget( int_vector , int )") + _iset = EclPrototype("int int_vector_iset( int_vector , int , int)") + _size = EclPrototype("int int_vector_size( int_vector )") + _append = EclPrototype("void int_vector_append( int_vector , int )") + _idel_block = EclPrototype("void int_vector_idel_block( int_vector , int , int )") + _pop = EclPrototype("int int_vector_pop( int_vector )") + _idel = EclPrototype("void int_vector_idel( int_vector , int )") + _insert = EclPrototype("void int_vector_insert( int_vector , int , int)") + _lshift = EclPrototype("void int_vector_lshift( int_vector , int )") + _rshift = EclPrototype("void int_vector_rshift( int_vector , int )") + _fprintf = EclPrototype("void int_vector_fprintf( int_vector , FILE , char* , char*)") + _sort = EclPrototype("void int_vector_sort( int_vector )") + _rsort = EclPrototype("void int_vector_rsort( int_vector )") + _reset = EclPrototype("void int_vector_reset( int_vector )") + _set_read_only = EclPrototype("void int_vector_set_read_only( int_vector , bool )") + _get_read_only = EclPrototype("bool int_vector_get_read_only( int_vector )") + _get_max = EclPrototype("int int_vector_get_max( int_vector )") + _get_min = EclPrototype("int int_vector_get_min( int_vector )") + _get_max_index = EclPrototype("int int_vector_get_max_index( int_vector , bool)") + _get_min_index = EclPrototype("int int_vector_get_min_index( int_vector , bool)") + _shift = EclPrototype("void int_vector_shift( int_vector , int )") + _scale = EclPrototype("void int_vector_scale( int_vector , int )") + _div = EclPrototype("void int_vector_div( int_vector , int )") + _inplace_add = EclPrototype("void int_vector_inplace_add( int_vector , int_vector )") + _inplace_mul = EclPrototype("void int_vector_inplace_mul( int_vector , int_vector )") + _assign = EclPrototype("void int_vector_set_all( int_vector , int)") + _memcpy = EclPrototype("void int_vector_memcpy(int_vector , int_vector )") + _set_default = EclPrototype("void int_vector_set_default( int_vector , int)") + _get_default = EclPrototype("int int_vector_get_default( int_vector )") + _element_size = EclPrototype("int int_vector_element_size( int_vector )") + + _permute = EclPrototype("void int_vector_permute(int_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj int_vector_alloc_sort_perm(int_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)") + _contains = EclPrototype("bool int_vector_contains(int_vector, int)") + _select_unique = EclPrototype("void int_vector_select_unique(int_vector)") + _element_sum = EclPrototype("int int_vector_sum(int_vector)") + _get_data_ptr = EclPrototype("int* int_vector_get_ptr(int_vector)") + _count_equal = EclPrototype("int int_vector_count_equal(int_vector, int)") + _init_range = EclPrototype("void int_vector_init_range(int_vector, int , int , int)") + _init_linear = EclPrototype("bool int_vector_init_linear(int_vector, int, int, int)") + _equal = EclPrototype("bool int_vector_equal(int_vector, int_vector)") + _first_eq = EclPrototype("int int_vector_first_equal(int_vector, int_vector, int)") + _first_neq = EclPrototype("int int_vector_first_not_equal(int_vector, int_vector, int)") + + def __init__(self, default_value=0, initial_size=0): + super(IntVector, self).__init__(default_value, initial_size) + + @classmethod + def active_list(cls, range_string): + """Will create a IntVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {1,4,5,6,7,10} + "1,4-7,10X" => {} + + The empty list will evaluate to false. The values in the input + string are meant to indicate "active values", i.e. the output + values are sorted and repeated values are only counted once: + + "1,1,7,2" => {1,2,7} + + """ + return cls._create_active_list(range_string) + + @classmethod + def valueList(cls , range_string): + """Will create a IntVecter of all the values in the @range_string. + + Will not sort the values, and not uniquiefy - in contrast to + the active_list() method. + + """ + return cls._create_value_list(range_string) + + + def count(self, value): + """ @rtype: int """ + return self._count_equal(value) diff --git a/ThirdParty/Ert/python/ecl/util/util/lookup_table.py b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py new file mode 100644 index 0000000000..4d01ba8732 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py @@ -0,0 +1,122 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'lookup_table.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +from cwrap import BaseCClass +from ecl import EclPrototype + + +class LookupTable(BaseCClass): + _alloc = EclPrototype("void* lookup_table_alloc_empty()" , bind = False) + _max = EclPrototype("double lookup_table_get_max_value( lookup_table )") + _min = EclPrototype("double lookup_table_get_min_value( lookup_table )") + _arg_max = EclPrototype("double lookup_table_get_max_arg( lookup_table )") + _arg_min = EclPrototype("double lookup_table_get_min_arg( lookup_table )") + _append = EclPrototype("void lookup_table_append( lookup_table , double , double )") + _size = EclPrototype("int lookup_table_get_size( lookup_table )") + _interp = EclPrototype("double lookup_table_interp( lookup_table , double)") + _free = EclPrototype("void lookup_table_free( lookup_table )") + _set_low_limit = EclPrototype("void lookup_table_set_low_limit( lookup_table , double)") + _set_high_limit = EclPrototype("void lookup_table_set_high_limit( lookup_table , double)") + _has_low_limit = EclPrototype("bool lookup_table_has_low_limit( lookup_table)") + _has_high_limit = EclPrototype("bool lookup_table_has_high_limit( lookup_table)") + + def __init__(self, lower_limit=None, upper_limit=None): + super(LookupTable, self).__init__(self._alloc()) + + if not lower_limit is None: + self.setLowerLimit(lower_limit) + + if not upper_limit is None: + self.setUpperLimit(upper_limit) + + def getMaxValue(self): + self.assertSize(1) + return self._max() + + def getMinValue(self): + self.assertSize(1) + return self._min() + + def getMinArg(self): + self.assertSize(1) + return self._arg_min() + + def getMaxArg(self): + self.assertSize(1) + return self._arg_max() + + def assertSize(self, N): + if len(self) < N: + raise ValueError("Lookup table is too small") + + def __len__(self): + return self._size() + + @property + def size(self): + return len(self) + + # Deprecated properties + @property + def max(self): + return self.getMaxValue() + + @property + def min(self): + return self.getMinValue() + + @property + def arg_max(self): + return self.getMaxArg() + + @property + def arg_min(self): + return self.getMinArg() + + def setLowerLimit(self, value): + self._set_low_limit(value) + + def hasLowerLimit(self): + return self._has_low_limit() + + def setUpperLimit(self, value): + self._set_high_limit(value) + + def hasUpperLimit(self): + return self._has_high_limit() + + def interp(self, x): + self.assertSize(2) + if x < self.getMinArg(): + if not self.hasLowerLimit(): + raise ValueError("Interpolate argument:%g is outside valid interval: [%g,%g]" % (x, self.getMinArg(), self.getMaxArg())) + elif x > self.getMaxArg(): + if not self.hasUpperLimit(): + raise ValueError("Interpolate argument:%g is outside valid interval: [%g,%g]" % (x, self.getMinArg(), self.getMaxArg())) + + return self._interp(x) + + def append(self, x, y): + self._append( x, y) + + #todo: necessary??? + def __del__(self): + self._free() + + def free(self): + self._free( ) + diff --git a/ThirdParty/Ert/python/ecl/util/util/matrix.py b/ThirdParty/Ert/python/ecl/util/util/matrix.py new file mode 100644 index 0000000000..160763987c --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/matrix.py @@ -0,0 +1,230 @@ + +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'matrix.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +# The Matrix class implemented here wraps the C matrix implementation +# in matrix.c from the libutil library. The C matrix implementation +# has the very limited ambition of just barely satisfying the matrix +# needs of the EnKF algorithm, i.e. for general linear algebra +# applications you will probably be better served by a more complete +# matrix library. This applies even more so to this Python +# implementation; it is only here facilitate use of C libraries which +# expect a matrix instance as input (i.e. the LARS estimator). For +# general linear algebra in Python the numpy library is a natural +# choice. + + +from cwrap import BaseCClass,CFILE +from ecl import EclPrototype + + +class Matrix(BaseCClass): + _matrix_alloc = EclPrototype("void* matrix_alloc(int, int )" , bind = False) + _matrix_alloc_identity = EclPrototype("matrix_obj matrix_alloc_identity( int )" , bind = False) + _alloc_transpose = EclPrototype("matrix_obj matrix_alloc_transpose(matrix)") + _inplace_transpose = EclPrototype("void matrix_inplace_transpose(matrix)") + _copy = EclPrototype("matrix_obj matrix_alloc_copy(matrix)" ) + _sub_copy = EclPrototype("matrix_obj matrix_alloc_sub_copy(matrix, int , int , int , int)" ) + _free = EclPrototype("void matrix_free(matrix)") + _iget = EclPrototype("double matrix_iget( matrix , int , int )") + _iset = EclPrototype("void matrix_iset( matrix , int , int , double)") + _set_all = EclPrototype("void matrix_scalar_set( matrix , double)") + _scale_column = EclPrototype("void matrix_scale_column(matrix , int , double)") + _scale_row = EclPrototype("void matrix_scale_row(matrix , int , double)") + _copy_column = EclPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False) + _rows = EclPrototype("int matrix_get_rows(matrix)") + _columns = EclPrototype("int matrix_get_columns(matrix)") + _equal = EclPrototype("bool matrix_equal(matrix, matrix)") + _pretty_print = EclPrototype("void matrix_pretty_print(matrix, char*, char*)") + _fprint = EclPrototype("void matrix_fprintf(matrix, char*, FILE)") + _random_init = EclPrototype("void matrix_random_init(matrix, rng)") + _dump_csv = EclPrototype("void matrix_dump_csv(matrix, char*)") + + # Requires BLAS. If the library does not have the + # matrix_alloc_matmul() function the prototype will have _func = + # None, and NotImplementedError( ) will be raised int the + # __call__() method if we try to use this function. + try: + _alloc_matmul = EclPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False) + except AttributeError: + _alloc_matmul = None + + # Requires BLAS! + @classmethod + def matmul(cls, m1,m2): + """ + Will return a new matrix which is matrix product of m1 and m2. + """ + if m1.columns( ) == m2.rows( ): + return cls._alloc_matmul( m1, m2) + else: + raise ValueError("Matrix size mismatch") + + + def __init__(self, rows, columns, value=0): + c_ptr = self._matrix_alloc(rows, columns) + super(Matrix, self).__init__(c_ptr) + self.setAll(value) + + def copy(self): + return self._copy( ) + + @classmethod + def identity(cls, dim): + """Returns a dim x dim identity matrix.""" + if dim < 1: + raise ValueError('Identity matrix must have positive size, %d not allowed.' % dim) + return cls._matrix_alloc_identity(dim) + + def subCopy(self, row_offset, column_offset, rows, columns): + if row_offset < 0 or row_offset >= self.rows(): + raise ValueError("Invalid row offset") + + if column_offset < 0 or column_offset >= self.columns(): + raise ValueError("Invalid column offset") + + if row_offset + rows > self.rows(): + raise ValueError("Invalid rows") + + if column_offset + columns > self.columns(): + raise ValueError("Invalid columns") + + return self._sub_copy( row_offset , column_offset , rows , columns) + + + def __str__(self): + s = "" + for i in range(self.rows()): + s += "[" + for j in range(self.columns()): + d = self._iget(i, j) + s += "%6.3g " % d + s += "]\n" + return s + + def __getitem__(self, index_tuple): + if not 0 <= index_tuple[0] < self.rows(): + raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) + + if not 0 <= index_tuple[1] < self.columns(): + raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) + + return self._iget(index_tuple[0], index_tuple[1]) + + def __setitem__(self, index_tuple, value): + if not 0 <= index_tuple[0] < self.rows(): + raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) + + if not 0 <= index_tuple[1] < self.columns(): + raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) + + return self._iset(index_tuple[0], index_tuple[1], value) + + def dims(self): + return self._rows(), self._columns() + + def rows(self): + """ @rtype: int """ + return self._rows() + + def transpose(self , inplace = False): + """ + Will transpose the matrix. By default a transposed copy is returned. + """ + if inplace: + self._inplace_transpose( ) + return self + else: + return self._alloc_transpose( ) + + + def columns(self): + """ @rtype: int """ + return self._columns() + + def __eq__(self, other): + assert isinstance(other, Matrix) + return self._equal(other) + + def scaleColumn(self, column, factor): + if not 0 <= column < self.columns(): + raise IndexError("Expected column: [0,%d) got:%d" % (self.columns(), column)) + self._scale_column(column, factor) + + def scaleRow(self, row, factor): + if not 0 <= row < self.rows(): + raise IndexError("Expected row: [0,%d) got:%d" % (self.rows(), row)) + self._scale_row(row, factor) + + def setAll(self, value): + self._set_all(value) + + def copyColumn(self, target_column, src_column): + columns = self.columns() + if not 0 <= src_column < columns: + raise ValueError("src column:%d invalid" % src_column) + + if not 0 <= target_column < columns: + raise ValueError("target column:%d invalid" % target_column) + + if src_column != target_column: + # The underlying C function accepts column copy between matrices. + Matrix._copy_column(self, self, target_column, src_column) + + + def dumpCSV(self , filename): + self._dump_csv( filename ) + + + def prettyPrint(self, name, fmt="%6.3g"): + self._pretty_print(name, fmt) + + def fprint(self , fileH , fmt = "%g "): + """Will print ASCII representation of matrix. + + The fileH argument should point to an open Python + filehandle. If you supply a fmt string it is important that it + contains a separator, otherwise you might risk that elements + overlap in the output. For the matrix: + + [0 1 2] + m = [3 4 5] + [6 7 8] + + The code: + + with open("matrix.txt" , "w") as f: + m.fprintf( f ) + + The file 'matrix.txt' will look like: + + 0 1 2 + 3 4 5 + 6 7 8 + + """ + self._fprint( fmt , CFILE( fileH)) + + + def randomInit(self, rng): + self._random_init(rng) + + def free(self): + self._free() + + + diff --git a/ThirdParty/Ert/python/ecl/util/util/permutation_vector.py b/ThirdParty/Ert/python/ecl/util/util/permutation_vector.py new file mode 100644 index 0000000000..92291ceb4c --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/permutation_vector.py @@ -0,0 +1,38 @@ +from cwrap import BaseCClass +from ecl import EclPrototype + + +class PermutationVector(BaseCClass): + TYPE_NAME = "permutation_vector" + _free = EclPrototype("void perm_vector_free( permutation_vector )") + _size = EclPrototype("int perm_vector_get_size( permutation_vector )") + _iget = EclPrototype("int perm_vector_iget( permutation_vector , int)") + + + def __init__(self): + raise NotImplementedError("Can not instantiate PermutationVector directly") + + + def __len__(self): + return self._size( ) + + + def __str__(self): + s = "(" + for index in self: + s += " %d" % index + return s + ")" + + + def __getitem__(self, index): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + return self._iget( index ) + else: + raise IndexError("Invalid index:%d" % index) + + + def free(self): + self._free( ) diff --git a/ThirdParty/Ert/python/ecl/util/util/rng.py b/ThirdParty/Ert/python/ecl/util/util/rng.py new file mode 100644 index 0000000000..e03af1c3f2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/rng.py @@ -0,0 +1,81 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'rng.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os.path + +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.util.enums import RngInitModeEnum, RngAlgTypeEnum + + +class RandomNumberGenerator(BaseCClass): + TYPE_NAME = "rng" + + _rng_alloc = EclPrototype("void* rng_alloc(rng_alg_type_enum, rng_init_mode_enum)" , bind = False) + _free = EclPrototype("void rng_free(rng)") + _get_double = EclPrototype("double rng_get_double(rng)") + _get_int = EclPrototype("int rng_get_int(rng, int)") + _get_max_int = EclPrototype("uint rng_get_max_int(rng)") + _state_size = EclPrototype("int rng_state_size(rng)") + _set_state = EclPrototype("void rng_set_state(rng , char*)") + _load_state = EclPrototype("void rng_load_state(rng , char*)") + _save_state = EclPrototype("void rng_save_state(rng , char*)") + + def __init__(self, alg_type=RngAlgTypeEnum.MZRAN, init_mode=RngInitModeEnum.INIT_CLOCK): + assert isinstance(alg_type, RngAlgTypeEnum) + assert isinstance(init_mode, RngInitModeEnum) + + c_ptr = self._rng_alloc(alg_type, init_mode) + super(RandomNumberGenerator, self).__init__(c_ptr) + + def stateSize(self): + return self._state_size() + + def setState(self, seed_string): + state_size = self.stateSize() + if len(seed_string) < state_size: + raise ValueError("The seed string must be at least %d characters long" % self.stateSize()) + self._set_state( seed_string) + + def getDouble(self): + """ @rtype: float """ + return self._get_double() + + def getInt(self, max=None): + """ @rtype: float """ + if max is None: + max = self._get_max_int() + + return self._get_int(max) + + def free(self): + self._free() + + def loadState(self , seed_file): + """ + Will seed the RNG from the file @seed_file. + """ + if os.path.isfile( seed_file ): + self._load_state( seed_file ) + else: + raise IOError("No such file: %s" % seed_file) + + + def saveState(self , seed_file): + """ + Will save the state of the rng to @seed_file + """ + self._save_state( seed_file ) + diff --git a/ThirdParty/Ert/python/ecl/util/util/stringlist.py b/ThirdParty/Ert/python/ecl/util/util/stringlist.py new file mode 100644 index 0000000000..fcdc185d88 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/stringlist.py @@ -0,0 +1,308 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'stringlist.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Simple wrapping of stringlist 'class' from C library. + +The stringlist type from the libutil C library is a simple structure +consisting of a vector of \0 terminated char pointers - slightly +higher level than the (char ** string , int size) convention. + +For a pure Python application you should just stick with a normal +Python list of string objects; but when interfacing with the C +libraries there are situations where you might need to instantiate a +StringList object. + +The StringList constructor can take an optional argument which should +be an iterable consisting of strings, and the strings property will +return a normal python list of string objects, used in this way you +hardly need to notice that the StringList class is at play. +""" +from __future__ import absolute_import, division, print_function, unicode_literals +from six import string_types +from ecl import EclPrototype +from cwrap import BaseCClass + + +class StringList(BaseCClass): + TYPE_NAME = "stringlist" + + _alloc = EclPrototype("void* stringlist_alloc_new( )", bind = False) + _free = EclPrototype("void stringlist_free(stringlist )") + _append = EclPrototype("void stringlist_append_copy(stringlist , char* )") + _iget = EclPrototype("char* stringlist_iget(stringlist , int )") + _front = EclPrototype("char* stringlist_front( stringlist )") + _back = EclPrototype("char* stringlist_back( stringlist )") + _iget_copy = EclPrototype("char* stringlist_iget_copy(stringlist, int)") + _iset = EclPrototype("void stringlist_iset_copy( stringlist , int , char* )") + _get_size = EclPrototype("int stringlist_get_size( stringlist )") + _contains = EclPrototype("bool stringlist_contains(stringlist , char*)") + _equal = EclPrototype("bool stringlist_equal(stringlist , stringlist)") + _sort = EclPrototype("void stringlist_python_sort( stringlist , int)") + _pop = EclPrototype("char* stringlist_pop(stringlist)") + _last = EclPrototype("char* stringlist_get_last(stringlist)") + _find_first = EclPrototype("int stringlist_find_first(stringlist, char*)") + + def __init__(self, initial=None): + """ + Creates a new stringlist instance. + + Creates a new stringlist instance. The optional argument + @initial should be an iterable of strings which will be the + initial content of the StringList; the content will be copied + from the initial list: + + S = StringList( initial = ["My" , "name" , "is", "John" , "Doe"] ) + + If an element in the @initial argument is not a string the + TypeError exception will be raised. + + If c_ptr argument is different from None, that should refer to + an already created stringlist instance; this Python will take + ownership of the underlying object. + """ + + c_ptr = self._alloc() + super(StringList, self).__init__(c_ptr) + if initial: + self._append_all(initial) + + def _append_all(self, lst): + for s in lst: + if isinstance(s, bytes): + s.decode('ascii') + if isinstance(s, string_types): + self.append(s) + else: + raise TypeError('Item is not a string: "%s".' % s) + + + def __eq__(self , other): + if len(self) == len(other): + if isinstance( other , StringList): + return self._equal(other) + else: + equal = True + for index,s2 in enumerate(other): + if self[index] != s2: + equal = False + break + return equal + else: + return False + + + def __setitem__(self, index, value): + if isinstance(index, int): + length = len(self) + if index < 0: + # Will only wrap backwards once + index = len(self) + index + + if index < 0 or index >= length: + raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) + if isinstance(value, bytes): + value = value.decode('ascii') + if isinstance(value, string_types): + self._iset(index, value) + else: + raise TypeError("Item: %s not string type" % value) + + + def __getitem__(self, index): + """ + Implements [] read operator on the stringlist. + + The __getitem__ method supports negative, i.e. from the right, + indexing; but not slices. + """ + if isinstance(index, int): + length = len(self) + if index < 0: + index += length + if index < 0 or index >= length: + raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) + else: + return self._iget(index) + else: + raise TypeError("Index should be integer type") + + def __contains__(self, s): + """ + Implements the 'in' operator. + + The 'in' check is based on string equality. + """ + return self._contains(s) + + + def __iadd__(self , other): + if isinstance(other, bytes): + other.decode('ascii') + if isinstance(other , string_types): + raise TypeError("Can not add strings with + - use append()") + for s in other: + self.append( s ) + return self + + + def __add__(self , other): + copy = StringList( initial = self ) + copy += other + return copy + + + def __ior__(self , other): + if isinstance(other, bytes): + other.decode('ascii') + if isinstance(other , string_types): + raise TypeError("Can not | with string.") + for s in other: + if not s in self: + self.append( s ) + return self + + + def __or__(self , other): + copy = StringList( initial = self ) + copy |= other + return copy + + + + def contains(self, s): + """ + Checks if the list contains @s. + + Functionality also available through the 'in' builtin in + Python. + """ + return s in self + + + def __len__(self): + """ + The length of the list - used to support builtin len(). + """ + return self._get_size( ) + + + def __str__(self): + """ + String representation of list; used when calling print." + """ + buffer = "[" + length = len(self) + for i in range(length): + if i == length - 1: + buffer += "\'%s\'" % self[i] + else: + buffer += "\'%s\'," % self[i] + buffer += "]" + return buffer + + def __repr__(self): + return 'StringList(size = %d) %s' % (len(self), self._ad_str()) + + def empty(self): + """Returns true if and only if list is empty.""" + return len(self) == 0 + + def pop(self): + """ + Will remove the last element from the list and return it. + + Will raise IndexError if list is empty. + """ + if not self.empty(): + return self._pop() + else: + raise IndexError("List empty. Cannot call pop().") + + + def append(self, s): + """ + Appends a new string @s to list. If the input argument is not a + string the string representation will be appended. + """ + if isinstance(s, bytes): + s.decode('ascii') + if isinstance(s, string_types): + self._append(s) + else: + self._append(str(s)) + + + @property + def strings(self): + """ + The strings in as a normal Python list of strings. + + The content is copied, so the StringList() instance can safely go + out of scope after the call has completed. Hmmmm - is that true? + """ + slist = [] + for s in self: + slist.append(s) + return slist + + @property + def last(self): + """ + Will return the last element in list. Raise IndexError if empty. + """ + if not self.empty(): + return self._last() + else: + raise IndexError("List empty. No such element last().") + + + def sort(self, cmp_flag=0): + """ + Will sort the list inplace. + + The string comparison can be altered with the value of the + optional cmp_flag parameter: + + 0 : Normal strcmp() string comparison + 1 : util_strcmp_int() string comparison + 2 : util_strcmp_float() string comparison + + """ + self._sort(cmp_flag) + + def index(self, value): + """ @rtype: int """ + if isinstance(value, bytes): + value.decode('ascii') + if isinstance(value, string_types): + return self._find_first(value) + raise KeyError('Cannot index by "%s", lst.index() needs a string.' % str(type(value))) + + def free(self): + self._free() + + + def front(self): + if not self.empty(): + return self._front() + else: + raise IndexError('List empty. No such element front().') + + def back(self): + if not self.empty(): + return self._back() + else: + raise IndexError('List empty. No such element back().') diff --git a/ThirdParty/Ert/python/ecl/util/util/thread_pool.py b/ThirdParty/Ert/python/ecl/util/util/thread_pool.py new file mode 100644 index 0000000000..fa5597398a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/thread_pool.py @@ -0,0 +1,151 @@ +import multiprocessing +from threading import Thread +import time +import traceback + + +class Task(Thread): + def __init__(self, func, *args, **kwargs): + super(Task, self).__init__() + self.__func = func + self.__args = args + self.__kwargs = kwargs + + self.__started = False + self.__done = False + self.__failed = False + self.__start_time = None + + self.__verbose = False + + def setVerbose(self, verbose): + self.__verbose = verbose + + def run(self): + self.__start_time = time.time() + self.__started = True + try: + self.__func(*self.__args, **self.__kwargs) + except Exception: + self.__failed = True + traceback.print_exc() + finally: + self.__done = True + + if self.__verbose: + running_time = time.time() - self.__start_time + print("Running time of task: %f" % running_time) + + def isDone(self): + return self.__done + + def hasStarted(self): + return self.__started or self.isAlive() + + def isRunning(self): + return self.hasStarted() and not self.__done + + def hasFailed(self): + return self.__failed + + def join(self, timeout=None): + while not self.hasStarted() or self.isRunning(): + time.sleep(0.01) + + + +class ThreadPool(object): + + def __init__(self, size=None, verbose=False): + super(ThreadPool, self).__init__() + + if size is None: + size = multiprocessing.cpu_count() + + self.__size = size + self.__task_list = [] + self.__pool_finished = False + self.__runner_thread = None + self.__verbose = verbose + self.__start_time = None + + + def addTask(self, func, *args, **kwargs): + if self.__start_time is None: + task = Task(func, *args, **kwargs) + # task.setVerbose(self.__verbose) + self.__task_list.append(task) + else: + raise UserWarning("Can not add task after the pool has started!") + + def poolSize(self): + return self.__size + + def taskCount(self): + return len(self.__task_list) + + def __allTasksFinished(self): + for task in self.__task_list: + if not task.isDone(): + return False + + return True + + def runningCount(self): + count = 0 + + for task in self.__task_list: + if task.isRunning(): + count += 1 + + return count + + def doneCount(self): + count = 0 + + for task in self.__task_list: + if task.isDone(): + count += 1 + + return count + + def __findNextTask(self): + for task in self.__task_list: + if not task.hasStarted(): + return task + + return None + + def __start(self): + while not self.__allTasksFinished(): + if self.runningCount() < self.poolSize(): + task = self.__findNextTask() + + if task is not None: + task.start() + + time.sleep(0.001) + + self.__pool_finished = True + + + def nonBlockingStart(self): + self.__runner_thread = Thread() + self.__runner_thread.run = self.__start + self.__runner_thread.start() + self.__start_time = time.time() + + def join(self): + while not self.__pool_finished: + time.sleep(0.001) + + if self.__verbose: + running_time = time.time() - self.__start_time + print("Running time: %f using a pool size of: %d" % (running_time, self.poolSize())) + + def hasFailedTasks(self): + for task in self.__task_list: + if task.hasFailed(): + return True + + return False diff --git a/ThirdParty/Ert/python/ecl/util/util/time_vector.py b/ThirdParty/Ert/python/ecl/util/util/time_vector.py new file mode 100644 index 0000000000..cffcb411f8 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/time_vector.py @@ -0,0 +1,177 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import datetime +import re + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate, CTime + + +class TimeVector(VectorTemplate): + TYPE_NAME = "time_t_vector" + default_format = "%d" + + _alloc = EclPrototype("void* time_t_vector_alloc(int, time_t )" , bind = False) + _alloc_copy = EclPrototype("time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )") + _strided_copy = EclPrototype("time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , int , int , int)") + _free = EclPrototype("void time_t_vector_free( time_t_vector )") + _iget = EclPrototype("time_t time_t_vector_iget( time_t_vector , int )") + _safe_iget = EclPrototype("time_t time_t_vector_safe_iget( time_t_vector , int )") + _iset = EclPrototype("time_t time_t_vector_iset( time_t_vector , int , time_t)") + _size = EclPrototype("int time_t_vector_size( time_t_vector )") + _append = EclPrototype("void time_t_vector_append( time_t_vector , time_t )") + _idel_block = EclPrototype("void time_t_vector_idel_block( time_t_vector , int , int )") + _idel = EclPrototype("void time_t_vector_idel( time_t_vector , int )") + _pop = EclPrototype("time_t time_t_vector_pop( time_t_vector )") + _lshift = EclPrototype("void time_t_vector_lshift( time_t_vector , int )") + _rshift = EclPrototype("void time_t_vector_rshift( time_t_vector , int )") + _insert = EclPrototype("void time_t_vector_insert( time_t_vector , int , time_t)") + _fprintf = EclPrototype("void time_t_vector_fprintf( time_t_vector , FILE , char* , char*)") + _sort = EclPrototype("void time_t_vector_sort( time_t_vector )") + _rsort = EclPrototype("void time_t_vector_rsort( time_t_vector )") + _reset = EclPrototype("void time_t_vector_reset( time_t_vector )") + _set_read_only = EclPrototype("void time_t_vector_set_read_only( time_t_vector , bool )") + _get_read_only = EclPrototype("bool time_t_vector_get_read_only( time_t_vector )") + _get_max = EclPrototype("time_t time_t_vector_get_max( time_t_vector )") + _get_min = EclPrototype("time_t time_t_vector_get_min( time_t_vector )") + _get_max_index = EclPrototype("int time_t_vector_get_max_index( time_t_vector , bool)") + _get_min_index = EclPrototype("int time_t_vector_get_min_index( time_t_vector , bool)") + _shift = EclPrototype("void time_t_vector_shift( time_t_vector , time_t )") + _scale = EclPrototype("void time_t_vector_scale( time_t_vector , time_t )") + _div = EclPrototype("void time_t_vector_div( time_t_vector , time_t )") + _inplace_add = EclPrototype("void time_t_vector_inplace_add( time_t_vector , time_t_vector )") + _inplace_mul = EclPrototype("void time_t_vector_inplace_mul( time_t_vector , time_t_vector )") + _assign = EclPrototype("void time_t_vector_set_all( time_t_vector , time_t)") + _memcpy = EclPrototype("void time_t_vector_memcpy(time_t_vector , time_t_vector )") + _set_default = EclPrototype("void time_t_vector_set_default( time_t_vector , time_t)") + _get_default = EclPrototype("time_t time_t_vector_get_default( time_t_vector )") + _element_size = EclPrototype("int time_t_vector_element_size( time_t_vector )") + + _permute = EclPrototype("void time_t_vector_permute(time_t_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj time_t_vector_alloc_sort_perm(time_t_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)") + _contains = EclPrototype("bool time_t_vector_contains(time_t_vector, time_t)") + _select_unique = EclPrototype("void time_t_vector_select_unique(time_t_vector)") + _element_sum = EclPrototype("time_t time_t_vector_sum(time_t_vector)") + _count_equal = EclPrototype("int time_t_vector_count_equal(time_t_vector, time_t)") + _init_range = EclPrototype("void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)") + _init_linear = EclPrototype("bool time_t_vector_init_linear(time_t_vector, time_t, time_t, int)") + _equal = EclPrototype("bool time_t_vector_equal(time_t_vector, time_t_vector)") + _first_eq = EclPrototype("int time_t_vector_first_equal(time_t_vector, time_t_vector, int)") + _first_neq = EclPrototype("int time_t_vector_first_not_equal(time_t_vector, time_t_vector, int)") + + + + def __init__(self, default_value=None, initial_size=0): + if default_value is None: + super(TimeVector, self).__init__(CTime(0), initial_size) + else: + try: + default = CTime(default_value) + except: + raise ValueError("default value invalid - must be type ctime() or date/datetime") + + super(TimeVector, self).__init__(default, initial_size) + + @classmethod + def parseTimeUnit(cls, deltaString): + deltaRegexp = re.compile("(?P\d*)(?P[dmy])", re.IGNORECASE) + matchObj = deltaRegexp.match(deltaString) + if matchObj: + try: + num = int(matchObj.group("num")) + except: + num = 1 + + timeUnit = matchObj.group("unit").lower() + return num, timeUnit + else: + raise TypeError("The delta string must be on form \'1d\', \'2m\', \'Y\' for one day, two months or one year respectively") + + def __str__(self): + """ + Returns string representantion of vector. + """ + string_list = [] + for d in self: + string_list.append("%s" % d) + + return str(string_list) + + def append(self, value): + self._append(CTime(value)) + + def __contains__(self, value): + return self._contains(CTime(value)) + + def nextTime(self, num, timeUnit): + currentTime = self[-1].datetime() + hour = currentTime.hour + minute = currentTime.minute + second = currentTime.second + + if timeUnit == "d": + td = datetime.timedelta(days=num) + currentTime += td + else: + day = currentTime.day + month = currentTime.month + year = currentTime.year + + if timeUnit == "y": + year += num + else: + month += num - 1 + (deltaYear, newMonth) = divmod(month, 12) + month = newMonth + 1 + year += deltaYear + currentTime = datetime.datetime(year, month, day, hour, minute, second) + + return currentTime + + def appendTime(self, num, timeUnit): + next = self.nextTime(num, timeUnit) + self.append(CTime(next)) + + @classmethod + def createRegular(cls, start, end, deltaString): + """ + The last element in the vector will be <= end; i.e. if the + question of whether the range is closed in the upper end + depends on the commensurability of the [start,end] interval + and the delta: + + createRegular(0 , 10 , delta=3) => [0,3,6,9] + createRegular(0 , 10 , delta=2) => [0,2,4,6,8,10] + """ + start = CTime(start) + end = CTime(end) + if start > end: + raise ValueError("The time interval is invalid start is after end") + + (num, timeUnit) = cls.parseTimeUnit(deltaString) + + timeVector = TimeVector() + currentTime = start + while currentTime <= end: + ct = CTime(currentTime) + timeVector.append(ct) + currentTime = timeVector.nextTime(num, timeUnit) + + return timeVector + + def getDataPtr(self): + raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors") diff --git a/ThirdParty/Ert/python/ecl/util/util/util_func.py b/ThirdParty/Ert/python/ecl/util/util/util_func.py new file mode 100644 index 0000000000..cb7cf236d6 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/util_func.py @@ -0,0 +1,54 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'util_func.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Module with utility functions from util.c +""" + +from ecl import EclPrototype + +strcmp_int = EclPrototype("int util_strcmp_int( char* , char* )") +""" +Function to compare strings with embedded integers. + +Will use proper numeric comparison when comparing strings with +embedded numbers, i.e. "CASE-9" will follow after "CASE-10" when +sorting: + + >> l = ["CASE-9" , "CASE-10"] + >> l.sort() + >> print(l) + ["CASE-10" , "CASE-9"] + >> l.sort( strcmp_int ) + >> print(l) + ["CASE-9" , "CASE-10"] + +When the standard strcmp() function is used for comparing strings +the '1' will compare as less than the '9' and the order will be +the reverse. Observe that the '-' is not interpreted as a sign +prefix. The strcmp_int function will interpret '.' as separating +character, wheras the strcmp_float() function will interpret '.' +as a descimal point. + +@type: (str, str) -> int +""" + +strcmp_float = EclPrototype("int util_strcmp_float( char* , char* )") +""" +Function to compare strings with embedded numbers. + +See documentation of strcmp_int() for further details. +@type: (str, str) -> int +""" diff --git a/ThirdParty/Ert/python/ecl/util/util/vector_template.py b/ThirdParty/Ert/python/ecl/util/util/vector_template.py new file mode 100644 index 0000000000..ca4d1a506a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/vector_template.py @@ -0,0 +1,687 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +""" +Typed vectors IntVector, DoubleVector and BoolVector. + +This module implements a quite simple typed vector which will grow +transparently as needed. The vector is created with a default value, +which will be used for not explicitly set indices. + + vec = IntVector( default_value = 66 ) + vec[0] = 10 + vec[2] = 10 + +After the 'vec[2] = 10' statement the vector has grown to contain +three elements. The element vec[1] has not been explicitly assigned by +the user, in that case the implementation has 'filled the hole' with +the default value (i.e. 66 in this case). So the statement + + print(vec[1]) + +will give '66'. The main part of the implementation is in terms of an +"abstract base class" TVector. The TVector class should be not +instantiated directly, instead the child classes IntVector, +DoubleVector or BoolVector should be used. + +The C-level has implementations for several fundamental types like +float and size_t not currently implemented in the Python version. +""" + +from __future__ import absolute_import, division, print_function, unicode_literals + +import sys + +from cwrap import CFILE, BaseCClass + + + +class VectorTemplate(BaseCClass): + + def strided_copy(self, slice_range): + """ + Will create a new copy according to @slice. + + Mainly a support function to support slice based lookup like + + v = IntVector() + v[0] = 1 + v[1] = 1 + v[100] = 100 + ... + c = v[0:100:10] + + Now 'c' will be a Intvector() instance containing every tenth + element from 'v'. + """ + (start, stop, step) = slice_range.indices(len(self)) + if stop > start: + return self._strided_copy(start, stop, step) + else: + return None + + def __bool__(self): + """ + Will evaluate to False for empty vector. + """ + if len(self) == 0: + return False + else: + return True + + def __nonzero__(self): + return self.__bool__( ) + + + def __eq__(self, other): + return self._equal(other) + + + def __ne__(self,other): + return not self.__eq__(other) + + def first_eq(self, other, offset = 0): + index = self._first_eq(other, offset) + if index <= -2: + raise ValueError("Invalid offset") + + return index + + + def first_neq(self, other, offset = 0): + index = self._first_neq(other, offset) + if index <= -2: + raise ValueError("Invalid offset") + + return index + + + def copy(self): + """ + Create a new copy of the current vector. + """ + new = self._alloc_copy( ) + return new + + def __irshift__(self,shift): + if shift < 0: + raise ValueError("The shift must be positive") + self._rshift(shift) + return self + + def __ilshift__(self,shift): + if shift < 0: + raise ValueError("The shift must be positive") + if shift > len(self): + raise ValueError("The shift is too large %d > %d" % (shift, len(self))) + self._lshift( shift) + return self + + + def __rshift__(self,shift): + copy = self.copy() + copy >>= shift + return copy + + + def __lshift__(self,shift): + copy = self.copy() + copy <<= shift + return copy + + def __deepcopy__(self, memo): + new = self.copy() + return new + + def __init__(self, default_value=0, initial_size=0): + """ + Creates a new TVector instance. + """ + c_pointer = self._alloc(initial_size, default_value) + super(VectorTemplate, self).__init__(c_pointer) + self.element_size = self._element_size() + + def __contains__(self , value): + return self._contains( value) + + + def pop(self): + if len(self) > 0: + return self._pop() + else: + raise ValueError("Trying to pop from empty vector") + + + def str_data(self, width, index1, index2, fmt): + """ + Helper function for str() method. + """ + data = [] + s = "" + for index in range(index1, index2): + data.append(self[index]) + for index in range(len(data)): + s += fmt % data[index] + if index % width == (width - 1): + s += "\n" + return s + + + # The str() method is a verbatim copy of the implementation in + # ecl_kw.py. + def str(self, width=5, max_lines=10, fmt=None): + """ + Return string representation of vector for pretty printing. + + The function will return a string consisting of a header, and + then a chunk of data. The data will be formatted in @width + columns, and a maximum of @max_lines lines. If @max_lines is + not sufficient the first elements in the kewyord are + represented, a .... continuation line and then the last part + of the vector. If @max_lines is None all of the vector will be + printed, irrespectiv of how long it is. + + If a value is given for @fmt that is used as format string for + each element, otherwise a type-specific default format is + used. If given the @fmt string should contain spacing between + the elements. The implementation of the builtin method + __str__() is based on this method. + """ + + s = "" + lines = len(self) // width + if not fmt: + fmt = self.default_format + " " + + if max_lines is None or lines <= max_lines: + s += self.str_data(width, 0, len(self), fmt) + else: + s1 = width * max_lines // 2 + s += self.str_data(width, 0, s1, fmt) + s += " .... \n" + s += self.str_data(width, len(self) - s1, len(self), fmt) + + return s + + def __str__(self): + """ + Returns string representantion of vector. + """ + return self.str(max_lines=10, width=5) + + + def __getitem__(self, index): + """ + Implements read [] operator - @index can be slice instance. + """ + if isinstance(index, int): + length = len(self) + idx = index + if idx < 0: + idx += length + + if 0 <= idx < length: + return self._iget(idx) + else: + raise IndexError('Index must be in range %d <= %d < %d.' % (0, index, length)) + elif isinstance(index, slice): + return self.strided_copy(index) + else: + raise TypeError("Index should be integer or slice type.") + + def __setitem__(self, index, value): + """ + Implements write [] operator - @index must be integer or slice. + """ + ls = len(self) + if isinstance(index, int): + idx = index + if idx < 0: + idx += ls + self._iset(idx, value) + elif isinstance( index, slice ): + for i in range(*index.indices(ls)): + self[i] = value + else: + raise TypeError("Index should be integer type") + + ################################################################## + # Mathematical operations: + + def __IADD(self, delta, add): + """ + Low-level function implementing inplace add. + + The __IADD__ function implements the operation: + + v += a + + The variable which is added, i.e. @delta, can either be of the + same type as the current instance, or a numerical scalar. The + __IADD__ method implements both add and subtract, based on the + boolean flag @add. + + The __IADD__ method should not be called directly; but rather + via the __iadd__, __add__ and __radd__ methods which implement + the various addition operation, and the corresponding + subtraction operations: __isub__, __sub__ and __rsub__. + """ + if type(self) == type(delta): + if len(self) == len(delta): + # This is vector + vector operation. + if not add: + delta *= -1 + self._inplace_add(delta) + else: + raise ValueError("Incompatible sizes for add self:%d other:%d" % (len(self), len(delta))) + else: + if isinstance(delta, int) or isinstance(delta, float): + if not add: + delta *= -1 + self._shift(delta) + else: + raise TypeError("delta has wrong type:%s " % type(delta)) + + return self + + + def __iadd__(self, delta): + """ + Implements inplace add. @delta can be vector or scalar. + """ + return self.__IADD(delta, True) + + + def __isub__(self, delta): + """ + Implements inplace subtract. @delta can be vector or scalar. + """ + return self.__IADD(delta, False) + + + def __radd__(self, delta): + return self.__add__(delta) + + + def __add__(self, delta): + """ + Implements add operation - creating a new copy. + + b = DoubleVector() + c = DoubleVector() // Or alternatively scalar + .... + a = b + c + """ + copy = self._alloc_copy( ) + copy += delta + return copy + + def __sub__(self, delta): + """ + Implements subtraction - creating new copy. + """ + copy = self._alloc_copy( ) + copy -= delta + return copy + + + def __rsub__(self, delta): + return self.__sub__(delta) * -1 + + + def __imul__(self, factor): + """ + Low-level function implementing inplace multiplication. + + The __IMUL__ function implements the operation: + + v *= a + + The variable which is multiplied in, i.e. @factor, can either + be of the same type as the current instance, or a numerical + scalar. The __IMUL__ method should not be called directly, but + rather via the __mul__, __imul__ and __rmul__ functions. + """ + + if type(self) == type(factor): + # This is vector * vector operation. + if len(self) == len(factor): + self._inplace_mul(factor) + else: + raise ValueError("Incompatible sizes for mul self:%d other:%d" % (len(self), len(factor))) + else: + if isinstance(factor, int) or isinstance(factor, float): + self._scale(factor) + else: + raise TypeError("factor has wrong type:%s " % type(factor)) + + return self + + + def __mul__(self, factor): + copy = self._alloc_copy( ) + copy *= factor + return copy + + def __rmul__(self, factor): + return self.__mul__(factor) + + def __div__(self, divisor): + if isinstance(divisor, int) or isinstance(divisor, float): + copy = self._alloc_copy() + copy._div(divisor) + return copy + else: + raise TypeError("Divisor has wrong type:%s" % type(divisor)) + + def __truediv__(self, divisor): + return self.__div__(divisor) + + def __idiv__(self, divisor): + return self.__div__(divisor) + + def __itruediv__(self, divisor): + return self.__div__(divisor) + + # End mathematical operations + ################################################################# + + # Essentally implements a = b + def assign(self, value): + """ + Implements assignment of type a = b. + + The @value parameter can either be a vector instance, in which + case the content of @value is copied into the current + instance, or a scalar in which case all the elements of the + vector are set to this value: + + v1 = IntVector() + v2 = IntVector() + + v1[10] = 77 + v2.assign( v1 ) # Now v2 contains identicall content to v1 + .... + v1.assign( 66 ) # Now v1 is a vector of 11 elements - all equal to 66 + + """ + if type(self) == type(value): + # This is a copy operation + self._memcpy(value) + else: + if isinstance(value, int) or isinstance(value, float): + self._assign(value) + else: + raise TypeError("Value has wrong type") + + def __len__(self): + """ + The number of elements in the vector. + """ + return self._size( ) + + + def printf(self, fmt=None, name=None, stream=sys.stdout): + """ + See also the str() method which returns string representantion + of the vector. + """ + cfile = CFILE(stream) + if not fmt: + fmt = self.default_format + self._fprintf(cfile, name, fmt) + + + def max(self): + if len(self) > 0: + return self._get_max() + else: + raise IndexError("The vector is empty!") + + def min(self): + if len(self) > 0: + return self._get_min() + else: + raise IndexError("The vector is empty!") + + + def minIndex(self, reverse=False): + """ + @type reverse: bool + @rtype: int + """ + if len(self) > 0: + return self._get_min_index(reverse) + else: + raise IndexError("The vector is empty!") + + def maxIndex(self, reverse=False): + """ + @type reverse: bool + @rtype: int + """ + if len(self) > 0: + return self._get_max_index(reverse) + else: + raise IndexError("The vector is empty!") + + def append(self, value): + self._append(value) + + def deleteBlock(self, index, block_size): + """ + Remove a block of size @block_size starting at @index. + + After the removal data will be left shifted. + """ + self._idel_block(index, block_size) + + def sort(self, reverse=False): + """ + Sort the vector inplace in increasing numerical order or decreasing order if reverse is True. + @type reverse: bool + """ + if not reverse: + self._sort() + else: + self._rsort() + + def clear(self): + self._reset() + + def safeGetByIndex(self, index): + return self._safe_iget(index) + + def setReadOnly(self, read_only): + self._set_read_only(read_only) + + def getReadOnly(self): + return self._get_read_only() + + def setDefault(self, value): + self._set_default(value) + + def getDefault(self): + return self._get_default() + + + def free(self): + self._free() + + def __repr__(self): + return self._create_repr('size = %d' % len(self)) + + def permute(self, permutation_vector): + """ + Reorders this vector based on the indexes in permutation_vector. + @type permutation_vector: PermutationVector + """ + + self._permute( permutation_vector) + + def permutationSort(self, reverse=False): + """ + Returns the permutation vector for sorting of this vector. Vector is not sorted. + @type reverse: bool + @@rtype: PermutationVector + """ + if len(self) > 0: + if not reverse: + return self._sort_perm() + else: + return self._rsort_perm() + + return None + + + def asList(self): + l = [0] * len(self) + for (index,value) in enumerate(self): + l[index] = value + + return l + + def selectUnique(self): + self._select_unique() + + + def elementSum(self): + return self._element_sum( ) + + + def getDataPtr(self): + "Low level function which returns a pointer to underlying storage" + # Observe that the get_data_ptr() function is not implemented + # for the TimeVector class. + return self._get_data_ptr() + + def countEqual(self , value): + return self._count_equal( value ) + + + def initRange(self , min_value , max_value , delta): + """ + Will fill the vector with the values from min_value to + max_value in steps of delta. The upper limit is guaranteed to + be inclusive, even if it is not commensurable with the delta. + """ + if delta == 0: + raise ValueError("Invalid range") + else: + self._init_range( min_value , max_value , delta ) + + + @classmethod + def create_linear(cls, start_value, end_value, num_values): + vector = cls() + if not vector._init_linear(start_value, end_value, num_values): + raise ValueError("init_linear arguments invalid") + + return vector + + + @classmethod + def createRange(cls , min_value , max_value , delta): + """ + Will create new vector and initialize a range. + """ + vector = cls( ) + vector.initRange( min_value , max_value , delta ) + return vector + + def _strided_copy(self, *_): + raise NotImplementedError() + def _rshift(self, *_): + raise NotImplementedError() + def _lshift(self, *_): + raise NotImplementedError() + def _alloc(self, *_): + raise NotImplementedError() + def _element_size(self, *_): + raise NotImplementedError() + def _contains(self, *_): + raise NotImplementedError() + def _pop(self, *_): + raise NotImplementedError() + def default_format(self, *_): + raise NotImplementedError() + def _iget(self, *_): + raise NotImplementedError() + def _iset(self, *_): + raise NotImplementedError() + def _inplace_add(self, *_): + raise NotImplementedError() + def _shift(self, *_): + raise NotImplementedError() + def _alloc_copy(self, *_): + raise NotImplementedError() + def _inplace_mul(self, *_): + raise NotImplementedError() + def _scale(self, *_): + raise NotImplementedError() + def _memcpy(self, *_): + raise NotImplementedError() + def _assign(self, *_): + raise NotImplementedError() + def _size(self, *_): + raise NotImplementedError() + def _fprintf(self, *_): + raise NotImplementedError() + def _get_max(self, *_): + raise NotImplementedError() + def _get_min(self, *_): + raise NotImplementedError() + def _get_min_index(self, *_): + raise NotImplementedError() + def _get_max_index(self, *_): + raise NotImplementedError() + def _append(self, *_): + raise NotImplementedError() + def _idel_block(self, *_): + raise NotImplementedError() + def _sort(self, *_): + raise NotImplementedError() + def _rsort(self, *_): + raise NotImplementedError() + def _reset(self, *_): + raise NotImplementedError() + def _safe_iget(self, *_): + raise NotImplementedError() + def _set_read_only(self, *_): + raise NotImplementedError() + def _get_read_only(self, *_): + raise NotImplementedError() + def _set_default(self, *_): + raise NotImplementedError() + def _get_default(self, *_): + raise NotImplementedError() + def _free(self, *_): + raise NotImplementedError() + def _permute(self, *_): + raise NotImplementedError() + def _sort_perm(self, *_): + raise NotImplementedError() + def _rsort_perm(self, *_): + raise NotImplementedError() + def _select_unique(self, *_): + raise NotImplementedError() + def _element_sum(self, *_): + raise NotImplementedError() + def _get_data_ptr(self, *_): + raise NotImplementedError() + def _count_equal(self, *_): + raise NotImplementedError() + def _init_range(self, *_): + raise NotImplementedError() diff --git a/ThirdParty/Ert/python/ecl/util/util/version.py b/ThirdParty/Ert/python/ecl/util/util/version.py new file mode 100644 index 0000000000..95df9f0fd5 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/version.py @@ -0,0 +1,118 @@ +from ecl import EclPrototype + + +def cmp_method(method): + def cmp_wrapper(self, other): + if not isinstance(other, Version): + other = Version(other[0], other[1], other[2]) + + return method(self, other) + + return cmp_wrapper + + + +class Version(object): + + + def __init__(self, major, minor, micro, git_commit = None, build_time = None): + self.major = major + self.minor = minor + self.micro = micro + try: + self.micro_int = int(micro) + self.is_devel = False + except ValueError: + self.micro_int = -1 + self.is_devel = True + self.build_time = build_time + self.git_commit = git_commit + + def isDevelVersion(self): + return self.is_devel + + def versionString(self): + return "%d.%d.%s" % (self.major, self.minor, self.micro) + + def versionTuple(self): + return self.major, self.minor, self.micro + + def __cmpTuple(self): + return self.major, self.minor, self.micro_int + + def __str__(self): + return self.versionString() + + def __repr__(self): + status = 'production' + git_commit = self.getGitCommit( short = True ) + if self.is_devel: + status = 'development' + fmt = 'Version(major=%d, minor=%d, micro="%s", commit="%s", status="%s")' + return fmt % (self.major, self.minor, self.micro, git_commit, status) + + @cmp_method + def __eq__(self, other): + return self.versionTuple() == other.versionTuple() + + def __ne__(self, other): + return not (self == other) + + def __hash__(self): + return hash(self.versionTuple()) + + # All development versions are compared with micro version == -1; + # i.e. the two versions version(1,2,"Alpha") and + # ecl_version(1,2,"Beta") compare as equal in the >= and <= tests - + # but not in the == test. + + @cmp_method + def __ge__(self, other): + return self.__cmpTuple() >= other.__cmpTuple() + + @cmp_method + def __lt__(self, other): + return not (self >= other) + + @cmp_method + def __le__(self, other): + return self.__cmpTuple() <= other.__cmpTuple() + + @cmp_method + def __gt__(self, other): + return not (self <= other) + + def getBuildTime(self): + if self.build_time is None: + return "?????" + else: + return self.build_time + + def getGitCommit(self, short=False): + if self.git_commit is None: + return "???????" + else: + if short: + return self.git_commit[0:8] + else: + return self.git_commit + + +class EclVersion(Version): + _build_time = EclPrototype("char* ecl_version_get_build_time()", bind = False) + _git_commit = EclPrototype("char* ecl_version_get_git_commit()", bind = False) + _major_version = EclPrototype("int ecl_version_get_major_version()", bind = False) + _minor_version = EclPrototype("int ecl_version_get_minor_version()", bind = False) + _micro_version = EclPrototype("char* ecl_version_get_micro_version()", bind = False) + _is_devel = EclPrototype("bool ecl_version_is_devel_version()", bind = False) + + def __init__(self): + major = self._major_version( ) + minor = self._minor_version( ) + micro = self._micro_version( ) + git_commit = self._git_commit( ) + build_time = self._build_time( ) + super( EclVersion, self).__init__( major, minor , micro , git_commit, build_time) + + + diff --git a/ThirdParty/Ert/python/ecl/well/CMakeLists.txt b/ThirdParty/Ert/python/ecl/well/CMakeLists.txt new file mode 100644 index 0000000000..b37c7f17c4 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/CMakeLists.txt @@ -0,0 +1,13 @@ +set(PYTHON_SOURCES + __init__.py + well_connection.py + well_connection_direction_enum.py + well_info.py + well_segment.py + well_state.py + well_time_line.py + well_type_enum.py +) + +add_python_package("python.ecl.well" ${PYTHON_INSTALL_PREFIX}/ecl/well "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/python/ecl/well/__init__.py b/ThirdParty/Ert/python/ecl/well/__init__.py new file mode 100644 index 0000000000..979df95428 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/__init__.py @@ -0,0 +1,13 @@ +import ecl +import ecl.util.util +import ecl.util.geometry + +from cwrap import Prototype + +from .well_type_enum import WellTypeEnum +from .well_connection_direction_enum import WellConnectionDirectionEnum +from .well_connection import WellConnection +from .well_segment import WellSegment +from .well_state import WellState +from .well_time_line import WellTimeLine +from .well_info import WellInfo diff --git a/ThirdParty/Ert/python/ecl/well/well_connection.py b/ThirdParty/Ert/python/ecl/well/well_connection.py new file mode 100644 index 0000000000..522d19ee0c --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_connection.py @@ -0,0 +1,112 @@ +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.well import WellConnectionDirectionEnum + +class WellConnection(BaseCClass): + TYPE_NAME = "well_connection" + + _i = EclPrototype("int well_conn_get_i(well_connection)") + _j = EclPrototype("int well_conn_get_j(well_connection)") + _k = EclPrototype("int well_conn_get_k(well_connection)") + _segment_id = EclPrototype("int well_conn_get_segment_id(well_connection)") + _is_open = EclPrototype("bool well_conn_open(well_connection)") + _is_msw = EclPrototype("bool well_conn_MSW(well_connection)") + _fracture_connection = EclPrototype("bool well_conn_fracture_connection(well_connection)") + _matrix_connection = EclPrototype("bool well_conn_matrix_connection(well_connection)") + _connection_factor = EclPrototype("double well_conn_get_connection_factor(well_connection)") + _equal = EclPrototype("bool well_conn_equal(well_connection, well_connection)") + _get_dir = EclPrototype("void* well_conn_get_dir(well_connection)") + _oil_rate = EclPrototype("double well_conn_get_oil_rate(well_connection)") + _gas_rate = EclPrototype("double well_conn_get_gas_rate(well_connection)") + _water_rate = EclPrototype("double well_conn_get_water_rate(well_connection)") + _volume_rate = EclPrototype("double well_conn_get_volume_rate(well_connection)") + + _oil_rate_si = EclPrototype("double well_conn_get_oil_rate_si(well_connection)") + _gas_rate_si = EclPrototype("double well_conn_get_gas_rate_si(well_connection)") + _water_rate_si = EclPrototype("double well_conn_get_water_rate_si(well_connection)") + _volume_rate_si = EclPrototype("double well_conn_get_volume_rate_si(well_connection)") + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly") + + + def isOpen(self): + """ @rtype: bool """ + return self._is_open() + + + def ijk(self): + """ @rtype: tuple of (int, int, int) """ + i = self._i() + j = self._j() + k = self._k() + return i, j, k + + def direction(self): + """ @rtype: WellConnectionDirectionEnum """ + return self._get_dir() + + def segmentId(self): + """ @rtype: int """ + return self._segment_id() + + def isFractureConnection(self): + """ @rtype: bool """ + return self._fracture_connection() + + def isMatrixConnection(self): + """ @rtype: bool """ + return self._matrix_connection() + + def connectionFactor(self): + """ @rtype: float """ + return self._connection_factor() + + def __eq__(self, other): + return self._equal(other) + + def __hash__(self): + return id(self) + + def __ne__(self, other): + return not self == other + + def free(self): + pass + + def isMultiSegmentWell(self): + """ @rtype: bool """ + return self._is_msw() + + def __repr__(self): + ijk = str(self.ijk()) + frac = 'fracture ' if self.isFractureConnection() else '' + open_ = 'open ' if self.isOpen() else 'shut ' + msw = ' (multi segment)' if self.isMultiSegmentWell() else '' + dir = WellConnectionDirectionEnum(self.direction()) + addr = self._address() + return 'WellConnection(%s %s%s%s, rates = (O:%s,G:%s,W:%s), direction = %s) at 0x%x' % (ijk, frac, open_, msw, self.oilRate(), self.gasRate(), self.waterRate(), dir, addr) + + def gasRate(self): + return self._gas_rate() + + def waterRate(self): + return self._water_rate() + + def oilRate(self): + return self._oil_rate() + + def volumeRate(self): + return self._volume_rate() + + def gasRateSI(self): + return self._gas_rate_si() + + def waterRateSI(self): + return self._water_rate_si() + + def oilRateSI(self): + return self._oil_rate_si() + + def volumeRateSI(self): + return self._volume_rate_si() diff --git a/ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py b/ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py new file mode 100644 index 0000000000..084d796f94 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py @@ -0,0 +1,15 @@ +from cwrap import BaseCEnum + +class WellConnectionDirectionEnum(BaseCEnum): + TYPE_NAME = "well_connection_dir_enum" + well_conn_dirX = None + well_conn_dirY = None + well_conn_dirZ = None + well_conn_fracX = None + well_conn_fracY = None + +WellConnectionDirectionEnum.addEnum("well_conn_dirX", 1) +WellConnectionDirectionEnum.addEnum("well_conn_dirY", 2) +WellConnectionDirectionEnum.addEnum("well_conn_dirZ", 3) +WellConnectionDirectionEnum.addEnum("well_conn_fracX", 4) +WellConnectionDirectionEnum.addEnum("well_conn_fracY", 5) diff --git a/ThirdParty/Ert/python/ecl/well/well_info.py b/ThirdParty/Ert/python/ecl/well/well_info.py new file mode 100644 index 0000000000..938341ace0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_info.py @@ -0,0 +1,123 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from os.path import isfile +from cwrap import BaseCClass +from ecl.grid import EclGrid +from ecl.eclfile.ecl_file import EclFile +from ecl.well import WellTimeLine +from ecl import EclPrototype + + +class WellInfo(BaseCClass): + TYPE_NAME = "well_info" + + _alloc = EclPrototype("void* well_info_alloc(ecl_grid)", bind = False) + _free = EclPrototype("void well_info_free(well_info)") + _load_rstfile = EclPrototype("void well_info_load_rstfile(well_info, char*, bool)") + _load_rst_eclfile = EclPrototype("void well_info_load_rst_eclfile(well_info, ecl_file, bool)") + _get_well_count = EclPrototype("int well_info_get_num_wells(well_info)") + _iget_well_name = EclPrototype("char* well_info_iget_well_name(well_info, int)") + _has_well = EclPrototype("bool well_info_has_well(well_info, char*)") + _get_ts = EclPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") + + + def __init__(self, grid, rst_file=None, load_segment_information=True): + """ + @type grid: EclGrid + @type rst_file: str or EclFile or list of str or list of EclFile + """ + c_ptr = self._alloc(grid) + super(WellInfo, self).__init__(c_ptr) + if not c_ptr: + raise ValueError('Unable to construct WellInfo from grid %s.' % str(grid)) + + if rst_file is not None: + if isinstance(rst_file, list): + for item in rst_file: + self.addWellFile(item, load_segment_information) + else: + self.addWellFile(rst_file, load_segment_information) + + + def __repr__(self): + return 'WellInfo(well_count = %d) at 0x%x' % (len(self), self._address()) + + def __len__(self): + """ @rtype: int """ + return self._get_well_count( ) + + + def __getitem__(self, item): + """ + @type item: int or str + @rtype: WellTimeLine + """ + + if isinstance(item, str): + if not item in self: + raise KeyError("The well '%s' is not in this set." % item) + well_name = item + + elif isinstance(item, int): + if not 0 <= item < len(self): + raise IndexError("Index must be in range 0 <= %d < %d" % (item, len(self))) + well_name = self._iget_well_name( item ) + + return self._get_ts(well_name).setParent(self) + + def __iter__(self): + """ @rtype: iterator of WellTimeLine """ + index = 0 + + while index < len(self): + yield self[index] + index += 1 + + + def allWellNames(self): + """ @rtype: list of str """ + return [self._iget_well_name(index) for index in range(0, len(self))] + + + def __contains__(self, item): + """ + @type item: str + @rtype: bool + """ + return self._has_well( item ) + + def _assert_file_exists(self, rst_file): + if not isfile(rst_file): + raise IOError('No such file %s' % rst_file) + + def addWellFile(self, rst_file, load_segment_information): + """ @type rstfile: str or EclFile """ + if isinstance(rst_file, str): + self._assert_file_exists(rst_file) + self._load_rstfile(rst_file, load_segment_information) + elif isinstance(rst_file, EclFile): + self._load_rst_eclfile(rst_file, load_segment_information) + else: + raise TypeError("Expected the RST file to be a filename or an EclFile instance.") + + + def hasWell(self , well_name): + return well_name in self + + + def free(self): + self._free( ) diff --git a/ThirdParty/Ert/python/ecl/well/well_segment.py b/ThirdParty/Ert/python/ecl/well/well_segment.py new file mode 100644 index 0000000000..9fefeefe8f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_segment.py @@ -0,0 +1,76 @@ +from cwrap import BaseCClass +from ecl import EclPrototype + +class WellSegment(BaseCClass): + TYPE_NAME = "well_segment" + + _active = EclPrototype("bool well_segment_active(well_segment)") + _main_stem = EclPrototype("bool well_segment_main_stem(well_segment)") + _nearest_wellhead = EclPrototype("bool well_segment_nearest_wellhead(well_segment)") + _id = EclPrototype("int well_segment_get_id(well_segment)") + _link_count = EclPrototype("int well_segment_get_link_count(well_segment)") + _branch_id = EclPrototype("int well_segment_get_branch_id(well_segment)") + _outlet_id = EclPrototype("int well_segment_get_outlet_id(well_segment)") + _depth = EclPrototype("double well_segment_get_depth(well_segment)") + _length = EclPrototype("double well_segment_get_length(well_segment)") + _total_length = EclPrototype("double well_segment_get_total_length(well_segment)") + _diameter = EclPrototype("double well_segment_get_diameter(well_segment)") + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly") + + def free(self): + pass + + def __repr__(self): + return 'WellSegment(%s) at 0x%x' % (str(self), self._address()) + + def __str__(self): + return "{Segment ID:%d BranchID:%d Length:%g}" % (self.id() , self.branchId() , self.length()) + + def id(self): + """ @rtype: int """ + return self._id() + + def linkCount(self): + """ @rtype: int """ + return self._link_count() + + def branchId(self): + """ @rtype: int """ + return self._branch_id() + + def outletId(self): + """ @rtype: int """ + return self._outlet_id() + + def isActive(self): + """ @rtype: bool """ + return self._active() + + def isMainStem(self): + """ @rtype: bool """ + return self._main_stem() + + def isNearestWellHead(self): + """ @rtype: bool """ + return self._nearest_wellhead() + + def depth(self): + """ @rtype: float """ + return self._depth() + + def __len__(self): + return self.length() + + def length(self): + """ @rtype: float """ + return self._length() + + def totalLength(self): + """ @rtype: float """ + return self._total_length() + + def diameter(self): + """ @rtype: float """ + return self._diameter() diff --git a/ThirdParty/Ert/python/ecl/well/well_state.py b/ThirdParty/Ert/python/ecl/well/well_state.py new file mode 100644 index 0000000000..7771fef53a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_state.py @@ -0,0 +1,166 @@ +from cwrap import BaseCClass + +from ecl import EclPrototype +from ecl.well import WellTypeEnum, WellConnection +from ecl.util.util import CTime + +class WellState(BaseCClass): + TYPE_NAME = "well_state" + + _global_connections_size = EclPrototype("int well_conn_collection_get_size(void*)", bind = False) + _global_connections_iget = EclPrototype("well_connection_ref well_conn_collection_iget(void*, int)", bind = False) + _segment_collection_size = EclPrototype("int well_segment_collection_get_size(void*)", bind = False) + _segment_collection_iget = EclPrototype("well_segment_ref well_segment_collection_iget(void*, int)", bind = False) + _has_global_connections = EclPrototype("bool well_state_has_global_connections(well_state)") + _get_global_connections = EclPrototype("void* well_state_get_global_connections(well_state)") + _get_segment_collection = EclPrototype("void* well_state_get_segments(well_state)") + _branches = EclPrototype("void* well_state_get_branches(well_state)") + _segments = EclPrototype("void* well_state_get_segments(well_state)") + _get_name = EclPrototype("char* well_state_get_name(well_state)") + _is_open = EclPrototype("bool well_state_is_open(well_state)") + _is_msw = EclPrototype("bool well_state_is_MSW(well_state)") + _well_number = EclPrototype("int well_state_get_well_nr(well_state)") + _report_number = EclPrototype("int well_state_get_report_nr(well_state)") + _has_segment_data = EclPrototype("bool well_state_has_segment_data(well_state)") + _sim_time = EclPrototype("time_t well_state_get_sim_time(well_state)") + _well_type = EclPrototype("well_type_enum well_state_get_type(well_state)") + _oil_rate = EclPrototype("double well_state_get_oil_rate(well_state)") + _gas_rate = EclPrototype("double well_state_get_gas_rate(well_state)") + _water_rate = EclPrototype("double well_state_get_water_rate(well_state)") + _volume_rate = EclPrototype("double well_state_get_volume_rate(well_state)") + _oil_rate_si = EclPrototype("double well_state_get_oil_rate_si(well_state)") + _gas_rate_si = EclPrototype("double well_state_get_gas_rate_si(well_state)") + _water_rate_si = EclPrototype("double well_state_get_water_rate_si(well_state)") + _volume_rate_si = EclPrototype("double well_state_get_volume_rate_si(well_state)") + _get_global_well_head = EclPrototype("well_connection_ref well_state_get_global_wellhead(well_state)") + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly") + + def name(self): + """ @rtype: str """ + return self._get_name( ) + + def isOpen(self): + """ @rtype: bool """ + return self._is_open( ) + + def free(self): + pass + + def wellHead(self): + well_head = self._get_global_well_head() + well_head.setParent( self ) + return well_head + + def wellNumber(self): + """ @rtype: int """ + return self._well_number( ) + + def reportNumber(self): + """ @rtype: int """ + return self._report_number( ) + + def simulationTime(self): + """ @rtype: CTime """ + return self._sim_time( ) + + def wellType(self): + """ @rtype: WellTypeEnum """ + return self._well_type( ) + + def hasGlobalConnections(self): + """ @rtype: bool """ + return self._has_global_connections( ) + + def globalConnections(self): + """ @rtype: list of WellConnection """ + global_connections = self._get_global_connections( ) + count = self._global_connections_size( global_connections ) + + values = [] + for index in range(count): + value = self._global_connections_iget(global_connections, index).setParent( self ) + values.append(value) + return values + + def __len__(self): + return self.numSegments() + + def __getitem__(self, idx): + return self.igetSegment(idx) + + def numSegments(self): + """ @rtype: int """ + segment_collection = self._get_segment_collection( ) + count = self._segment_collection_size(segment_collection) + return count + + + def segments(self): + """ @rtype: list of WellSegment """ + segment_collection = self._get_segment_collection( ) + + values = [] + for index in range(self.numSegments()): + value = self._segment_collection_iget(segment_collection, index).setParent(self) + values.append(value) + + return values + + + def igetSegment(self , seg_idx): + """ @rtype: WellSegment """ + if seg_idx < 0: + seg_idx += len(self) + + if not 0 <= seg_idx < self.numSegments(): + raise IndexError("Invalid index:%d - valid range [0,%d)" % (seg_idx , len(self))) + + segment_collection = self._get_segment_collection( ) + return self._segment_collection_iget(segment_collection, seg_idx).setParent(self) + + def isMultiSegmentWell(self): + """ @rtype: bool """ + return self._is_msw( ) + + def hasSegmentData(self): + """ @rtype: bool """ + return self._has_segment_data( ) + + def __repr__(self): + name = self.name() + if name: + name = '%s' % name + else: + name = '[no name]' + msw = ' (multi segment)' if self.isMultiSegmentWell() else '' + wn = str(self.wellNumber()) + type_ = self.wellType() + open_ = 'open' if self.isOpen() else 'shut' + cnt = '%s%s, number = %s, type = "%s", state = %s' % (name, msw, wn, type_, open_) + return self._create_repr(cnt) + + def gasRate(self): + return self._gas_rate( ) + + def waterRate(self): + return self._water_rate( ) + + def oilRate(self): + return self._oil_rate( ) + + def volumeRate(self): + return self._volume_rate( ) + + def gasRateSI(self): + return self._gas_rate_si( ) + + def waterRateSI(self): + return self._water_rate_si( ) + + def oilRateSI(self): + return self._oil_rate_si( ) + + def volumeRateSI(self): + return self._volume_rate_si( ) diff --git a/ThirdParty/Ert/python/ecl/well/well_time_line.py b/ThirdParty/Ert/python/ecl/well/well_time_line.py new file mode 100644 index 0000000000..2f9f4b835c --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_time_line.py @@ -0,0 +1,43 @@ +from cwrap import BaseCClass +from ecl import EclPrototype +from ecl.well import WellState + +class WellTimeLine(BaseCClass): + TYPE_NAME = "well_time_line" + _size = EclPrototype("int well_ts_get_size(well_time_line)") + _name = EclPrototype("char* well_ts_get_name(well_time_line)") + _iget = EclPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly") + + def getName(self): + return self._name() + + def __len__(self): + """ @rtype: int """ + return self._size() + + + def __getitem__(self, index): + """ + @type index: int + @rtype: WellState + """ + + if index < 0: + index += len(self) + + if not 0 <= index < len(self): + raise IndexError("Index must be in range 0 <= %d < %d" % (index, len(self))) + + return self._iget(index).setParent(self) + + def free(self): + pass + + def __repr__(self): + n = self.getName() + l = len(self) + cnt = 'name = %s, size = %d' % (n,l) + return self._create_repr(cnt) diff --git a/ThirdParty/Ert/python/ecl/well/well_type_enum.py b/ThirdParty/Ert/python/ecl/well/well_type_enum.py new file mode 100644 index 0000000000..f44e01fd22 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/well/well_type_enum.py @@ -0,0 +1,16 @@ +from cwrap import BaseCEnum + +class WellTypeEnum(BaseCEnum): + TYPE_NAME = "well_type_enum" + ECL_WELL_ZERO = None + ECL_WELL_PRODUCER = None + ECL_WELL_WATER_INJECTOR = None + ECL_WELL_GAS_INJECTOR = None + ECL_WELL_OIL_INJECTOR = None + +WellTypeEnum.addEnum("ECL_WELL_ZERO", 0) +WellTypeEnum.addEnum("ECL_WELL_PRODUCER", 1) +WellTypeEnum.addEnum("ECL_WELL_OIL_INJECTOR", 2) +WellTypeEnum.addEnum("ECL_WELL_WATER_INJECTOR", 3) +WellTypeEnum.addEnum("ECL_WELL_GAS_INJECTOR", 4) + diff --git a/ThirdParty/Ert/python/ert/CMakeLists.txt b/ThirdParty/Ert/python/ert/CMakeLists.txt new file mode 100644 index 0000000000..dc308b5229 --- /dev/null +++ b/ThirdParty/Ert/python/ert/CMakeLists.txt @@ -0,0 +1,11 @@ +set(PYTHON_SOURCES + __init__.py + ecl/__init__.py + ecl/faults/__init__.py + geo/__init__.py + well/__init__.py + util/__init__.py + test/__init__.py +) +add_python_package("python.ert" ${PYTHON_INSTALL_PREFIX}/ert "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/python/ert/__init__.py b/ThirdParty/Ert/python/ert/__init__.py new file mode 100644 index 0000000000..7eaa381b15 --- /dev/null +++ b/ThirdParty/Ert/python/ert/__init__.py @@ -0,0 +1,4 @@ +try: + from .local import * +except ImportError: + pass diff --git a/ThirdParty/Ert/python/ert/ecl/__init__.py b/ThirdParty/Ert/python/ert/ecl/__init__.py new file mode 100644 index 0000000000..bd632f46cc --- /dev/null +++ b/ThirdParty/Ert/python/ert/ecl/__init__.py @@ -0,0 +1,26 @@ +from ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil +from ecl import EclTypeEnum, EclDataType +from ecl.summary import EclSumVarType +from ecl.summary import EclSumTStep +from ecl.summary import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from ecl.summary import EclSumKeyWordVector +from ecl.rft import EclPLTCell, EclRFTCell +from ecl.rft import EclRFT, EclRFTFile +from ecl.eclfile import FortIO, openFortIO +from ecl.eclfile import EclKW +from ecl.eclfile import Ecl3DKW +from ecl.eclfile import EclFileView +from ecl.eclfile import EclFile , openEclFile +from ecl.eclfile import Ecl3DFile +from ecl.eclfile import EclInitFile +from ecl.eclfile import EclRestartFile +from ecl.grid import EclGrid +from ecl.grid import EclRegion +from ecl.gravimetry import EclSubsidence +from ecl.gravimetry import phase_deltag, deltag +from ecl.gravimetry import EclGrav +from ecl.summary import EclSumNode +from ecl.summary import EclSumVector +from ecl.summary import EclNPV , NPVPriceVector +from ecl.summary import EclCmp +from ecl.grid import EclGridGenerator diff --git a/ThirdParty/Ert/python/ert/ecl/faults/__init__.py b/ThirdParty/Ert/python/ert/ecl/faults/__init__.py new file mode 100644 index 0000000000..fa0ef626a9 --- /dev/null +++ b/ThirdParty/Ert/python/ert/ecl/faults/__init__.py @@ -0,0 +1,7 @@ +from ecl.grid.faults import Layer +from ecl.grid.faults import FaultCollection +from ecl.grid.faults import Fault +from ecl.grid.faults import FaultLine +from ecl.grid.faults import FaultSegment , SegmentMap +from ecl.grid.faults import FaultBlock , FaultBlockCell +from ecl.grid.faults import FaultBlockLayer diff --git a/ThirdParty/Ert/python/ert/geo/__init__.py b/ThirdParty/Ert/python/ert/geo/__init__.py new file mode 100644 index 0000000000..ececa79587 --- /dev/null +++ b/ThirdParty/Ert/python/ert/geo/__init__.py @@ -0,0 +1,8 @@ +from ecl.util.geometry import GeoPointset +from ecl.util.geometry import GeoRegion +from ecl.util.geometry import CPolyline +from ecl.util.geometry import CPolylineCollection +from ecl.util.geometry import Polyline +from ecl.util.geometry import XYZIo +from ecl.util.geometry import GeometryTools +from ecl.util.geometry import Surface diff --git a/ThirdParty/Ert/python/ert/test/__init__.py b/ThirdParty/Ert/python/ert/test/__init__.py new file mode 100644 index 0000000000..bacdd1adf8 --- /dev/null +++ b/ThirdParty/Ert/python/ert/test/__init__.py @@ -0,0 +1,10 @@ +from ecl.util.test import TestRun +from ecl.util.test import path_exists +from ecl.util.test import ExtendedTestCase +from ecl.util.test import SourceEnumerator +from ecl.util.test import TestArea , TestAreaContext +from ecl.util.test import TempArea , TempAreaContext +from ecl.util.test import ErtTestRunner +from ecl.util.test import PathContext +from ecl.util.test import LintTestCase +from ecl.util.test import ImportTestCase diff --git a/ThirdParty/Ert/python/ert/util/__init__.py b/ThirdParty/Ert/python/ert/util/__init__.py new file mode 100644 index 0000000000..48e2d7bff7 --- /dev/null +++ b/ThirdParty/Ert/python/ert/util/__init__.py @@ -0,0 +1,21 @@ +from ecl.util.util import Version +from ecl.util.util import RngAlgTypeEnum, RngInitModeEnum +from ecl.util.util import CTime +from ecl.util.util import PermutationVector +from ecl.util.util import VectorTemplate +from ecl.util.util import DoubleVector +from ecl.util.util import IntVector +from ecl.util.util import BoolVector +from ecl.util.util import TimeVector +from ecl.util.util import StringList +from ecl.util.util import RandomNumberGenerator +from ecl.util.util import LookupTable +from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash +from ecl.util.util import ThreadPool +from ecl.util.util import installAbortSignals, updateAbortSignals +from ecl.util.util import ArgPack + +try: + from res.util import SubstitutionList +except ImportError: + pass diff --git a/ThirdParty/Ert/python/ert/well/__init__.py b/ThirdParty/Ert/python/ert/well/__init__.py new file mode 100644 index 0000000000..5a699e5689 --- /dev/null +++ b/ThirdParty/Ert/python/ert/well/__init__.py @@ -0,0 +1,7 @@ +from ecl.well import WellTypeEnum +from ecl.well import WellConnectionDirectionEnum +from ecl.well import WellConnection +from ecl.well import WellSegment +from ecl.well import WellState +from ecl.well import WellTimeLine +from ecl.well import WellInfo diff --git a/ThirdParty/Ert/python/test_env.py.in b/ThirdParty/Ert/python/test_env.py.in new file mode 100644 index 0000000000..9fd11ea156 --- /dev/null +++ b/ThirdParty/Ert/python/test_env.py.in @@ -0,0 +1,6 @@ +import os + +TESTDATA_ROOT = os.getenv("ERT_TEST_ROOT_PATH") or "${PROJECT_SOURCE_DIR}/test-data" +SOURCE_ROOT = "${PROJECT_SOURCE_DIR}" +BUILD_ROOT = "${PROJECT_BINARY_DIR}" + diff --git a/ThirdParty/Ert/python/tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/CMakeLists.txt index a343151dff..7f02af2e52 100644 --- a/ThirdParty/Ert/python/tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/CMakeLists.txt @@ -1,20 +1,20 @@ -set(TEST_SOURCES - __init__.py +configure_file( + __init__.py + "${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/tests/__init__.py" + @ONLY ) -add_python_package("python.tests" "${PYTHON_INSTALL_PREFIX}/tests" "${TEST_SOURCES}" False) set(CTEST_PYTHONPATH ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}) -add_subdirectory(geometry) -add_subdirectory(util) -add_subdirectory(ecl) -add_subdirectory(well) -add_subdirectory(cwrap) -add_subdirectory(global) +add_subdirectory(geometry_tests) +add_subdirectory(util_tests) +add_subdirectory(ecl_tests) +add_subdirectory(well_tests) +add_subdirectory(global_tests) +add_subdirectory(bin_tests) if (INSTALL_ERT_LEGACY) - add_subdirectory(legacy) + add_subdirectory(legacy_tests) endif() - configure_file( test_install.in ${EXECUTABLE_OUTPUT_PATH}/test_install @ONLY ) diff --git a/ThirdParty/Ert/python/tests/__init__.py b/ThirdParty/Ert/python/tests/__init__.py index e69de29bb2..918cbb6acc 100644 --- a/ThirdParty/Ert/python/tests/__init__.py +++ b/ThirdParty/Ert/python/tests/__init__.py @@ -0,0 +1,82 @@ +import os.path +import types +from ecl.util.test import ExtendedTestCase +from functools import wraps +from functools import partial +import unittest +from unittest import SkipTest + +def source_root(): + src = '@CMAKE_CURRENT_SOURCE_DIR@/../..' + if os.path.isdir(src): + return os.path.realpath(src) + + # If the file was not correctly configured by cmake, look for the source + # folder, assuming the build folder is inside the source folder. + path_list = os.path.dirname(os.path.abspath(__file__)).split("/") + while len(path_list) > 0: + git_path = os.path.join(os.sep, "/".join(path_list), ".git") + if os.path.isdir(git_path): + return os.path.join(os.sep, *path_list) + path_list.pop() + raise RuntimeError('Cannot find the source folder') + + +# Decorator which is used to mark either an entire test class or individual +# test methods as requiring Statoil testdata. If Statoil testdata has not been +# configured as part of the build process these tests will be skipped. +# +# Ideally the statoil_test() implementation should just be a suitable wrapper of: +# +# skipUnless(EclTest.STATOIL_DATA, "Missing Statoil testdata") +# +# but that has been surprisingly difficult to achieve. The current +# implemenation is based on the skip() function from the unittest/case.py +# module in the Python standard distribution. There are unfortunately several +# problems with this: +# +# 1. It is based on accessing the __unittest_skip attribute of the TestCase +# class, that is certainly a private detail which we should not access. +# +# 2. The decorator must be invoked with an empty parenthesis when decorating a +# class, that is not required when decorating method: +# +# +# @statoil_test() +# class StatoilTest(EclTest): +# # This test class will be skipped entirely if we do not have access to +# # Statoil testdata. +# +# +# class XTest(EclTest): +# +# @statoil_test +# def test_method(self): + +def statoil_test(): + """ + Will mark a test method or an entire test class as dependent on Statoil testdata. + """ + def decorator(test_item): + if not isinstance(test_item, type): + if not EclTest.STATOIL_DATA: + @functools.wraps(test_item) + def skip_wrapper(*args, **kwargs): + raise SkipTest("Missing Statoil testdata") + test_item = skip_wrapper + + if not EclTest.STATOIL_DATA: + test_item.__unittest_skip__ = True + test_item.__unittest_skip_why__ = "Missing Statoil testdata" + return test_item + return decorator + + + + +class EclTest(ExtendedTestCase): + SOURCE_ROOT = source_root() + TESTDATA_ROOT = os.path.join(SOURCE_ROOT, "test-data") + STATOIL_DATA = os.path.islink(os.path.join(TESTDATA_ROOT, "Statoil")) + + diff --git a/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt new file mode 100644 index 0000000000..420cbe1d98 --- /dev/null +++ b/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_summary_resample.py +) + +add_python_package("python.tests.bin_tests" ${PYTHON_INSTALL_PREFIX}/tests/bin_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.bin_tests.test_summary_resample.SummaryResampleTest) diff --git a/ThirdParty/Ert/python/tests/bin_tests/__init__.py b/ThirdParty/Ert/python/tests/bin_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py new file mode 100644 index 0000000000..fbd1e6c178 --- /dev/null +++ b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py @@ -0,0 +1,93 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os.path +import subprocess +from subprocess import CalledProcessError as CallError + +from ecl.grid import Cell, EclGrid +from ecl.summary import EclSum +from tests import EclTest +from ecl.util.test.ecl_mock import createEclSum +from ecl.util.test import TestAreaContext + + +def fopr(days): + return days + +def fopt(days): + return days + +def fgpt(days): + if days < 50: + return days + else: + return 100 - days + +def create_case(num_mini_step = 10, case = "CSV"): + length = 100 + return createEclSum(case, [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], + sim_length_days = length, + num_report_step = 10, + num_mini_step = num_mini_step, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FGPT" : fgpt }) + + + +class SummaryResampleTest(EclTest): + + @classmethod + def setUpClass(cls): + cls.script = os.path.join(cls.SOURCE_ROOT, "bin/summary_resample") + cls.case = create_case() + + def test_run_default(self): + with TestAreaContext(""): + self.case.fwrite() + + # Too few arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script]) + + # Too few arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script, "CSV"]) + + # Invalid first arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script, "DOES_NOT_EXIST", "OUTPUT"]) + + # Should run OK: + subprocess.check_call([self.script, "CSV", "OUTPUT"]) + output_case = EclSum("OUTPUT") + self.assertEqual( output_case.get_data_start_time(), self.case.get_data_start_time()) + self.assertEqual( output_case.get_end_time(), self.case.get_end_time()) + + with self.assertRaises(CallError): + subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=does/not/exist"]) + + refcase = create_case( num_mini_step = 7, case = "REFCASE") + refcase.fwrite() + subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=REFCASE"]) + output_case = EclSum("OUTPUT") + self.assertEqual( output_case.get_data_start_time(), refcase.get_data_start_time()) + self.assertEqual( output_case.get_end_time(), refcase.get_end_time()) + time_points = output_case.alloc_time_vector(False) + t1 = output_case.alloc_time_vector(False) + t2 = refcase.alloc_time_vector(False) + self.assertEqual(t1,t2) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt new file mode 100644 index 0000000000..6444b8bfe3 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt @@ -0,0 +1,92 @@ +set(TEST_SOURCES + __init__.py + test_deprecation.py + test_removed.py + test_ecl_3dkw.py + test_ecl_file_statoil.py + test_ecl_file.py + test_ecl_init_file.py + test_ecl_restart_file.py + test_debug.py + test_ecl_sum.py + test_ecl_sum_vector.py + test_fault_blocks.py + test_fault_blocks_statoil.py + test_faults.py + test_fortio.py + test_grdecl.py + test_grid.py + test_cell.py + test_grid_statoil.py + test_grid_generator.py + test_indexed_read.py + test_ecl_kw_statoil.py + test_ecl_kw.py + test_kw_function.py + test_layer.py + test_npv.py + test_region.py + test_region_statoil.py + test_restart.py + test_rft.py + test_rft_statoil.py + test_rft_cell.py + test_statoil_faults.py + test_sum_statoil.py + test_ecl_util.py + test_ecl_cmp.py + test_sum.py + test_grav.py + test_geertsma.py + test_ecl_type.py + test_restart_head.py + test_fk_user_data.py +) + +add_python_package("python.tests.ecl_tests" ${PYTHON_INSTALL_PREFIX}/tests/ecl_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.ecl_tests.test_fk_user_data.FKTest) +addPythonTest(tests.ecl_tests.test_cell.CellTest) +addPythonTest(tests.ecl_tests.test_grid.GridTest LABELS SLOW_1) +addPythonTest(tests.ecl_tests.test_grid_generator.GridGeneratorTest LABELS SLOW_2) +addPythonTest(tests.ecl_tests.test_ecl_kw.KWTest LABELS SLOW_2) +addPythonTest(tests.ecl_tests.test_kw_function.KWFunctionTest) +addPythonTest(tests.ecl_tests.test_ecl_3dkw.Ecl3DKWTest ) +addPythonTest(tests.ecl_tests.test_rft.RFTTest) +addPythonTest(tests.ecl_tests.test_rft_cell.RFTCellTest) +addPythonTest(tests.ecl_tests.test_sum.SumTest) +addPythonTest(tests.ecl_tests.test_layer.LayerTest ) +addPythonTest(tests.ecl_tests.test_faults.FaultTest ) +addPythonTest(tests.ecl_tests.test_fault_blocks.FaultBlockTest ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_1_9_Test ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_2_0_Test ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_2_1_Test ) +addPythonTest(tests.ecl_tests.test_removed.Removed_2_1_Test ) +addPythonTest(tests.ecl_tests.test_ecl_util.EclUtilTest ) +addPythonTest(tests.ecl_tests.test_fortio.FortIOTest) +addPythonTest(tests.ecl_tests.test_ecl_file.EclFileTest) +addPythonTest(tests.ecl_tests.test_grav.EclGravTest) +addPythonTest(tests.ecl_tests.test_geertsma.GeertsmaTest) +addPythonTest(tests.ecl_tests.test_ecl_type.EclDataTypeTest) +addPythonTest(tests.ecl_tests.test_region.RegionTest) +addPythonTest(tests.ecl_tests.test_debug.DebugTest) + + +addPythonTest(tests.ecl_tests.test_ecl_file_statoil.EclFileStatoilTest) +addPythonTest(tests.ecl_tests.test_grdecl.GRDECLTest) +addPythonTest(tests.ecl_tests.test_grid_statoil.GridTest) +addPythonTest(tests.ecl_tests.test_ecl_kw_statoil.KWTest) +addPythonTest(tests.ecl_tests.test_ecl_init_file.InitFileTest) +addPythonTest(tests.ecl_tests.test_ecl_restart_file.RestartFileTest) +addPythonTest(tests.ecl_tests.test_restart.RestartTest ) +addPythonTest(tests.ecl_tests.test_region_statoil.RegionTest) +addPythonTest(tests.ecl_tests.test_rft_statoil.RFTTest) +addPythonTest(tests.ecl_tests.test_sum_statoil.SumTest) +addPythonTest(tests.ecl_tests.test_ecl_sum_vector.EclSumVectorTest) +addPythonTest(tests.ecl_tests.test_ecl_sum.EclSumTest) +addPythonTest(tests.ecl_tests.test_statoil_faults.StatoilFaultTest) +addPythonTest(tests.ecl_tests.test_fault_blocks_statoil.FaultBlockTest) +addPythonTest(tests.ecl_tests.test_npv.NPVTest) +addPythonTest(tests.ecl_tests.test_indexed_read.EclIndexedReadTest) +addPythonTest(tests.ecl_tests.test_ecl_cmp.EclCmpTest) +addPythonTest(tests.ecl_tests.test_restart_head.RestartHeadTest) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/__init__.py b/ThirdParty/Ert/python/tests/ecl_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py new file mode 100644 index 0000000000..5b8f41e52b --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.grid import Cell, EclGrid +from tests import EclTest +from unittest import skipUnless + +class CellTest(EclTest): + + def setUp(self): + fk = self.createTestPath('local/ECLIPSE/faarikaal/faarikaal1.EGRID') + self.grid = EclGrid(fk) + self.cell = self.grid[3455] + self.actives = [c for c in self.grid if c.active] + + def test_init(self): + cell = self.grid[0] + self.assertEqual(0, cell.global_index) + + def test_actives(self): + self.assertEqual(4160, len(self.actives)) + + def test_volumes(self): + actives = self.actives + vols = [c.volume for c in actives] + vmin, vmax = min(vols), max(vols) + self.assertFloatEqual(vmin, 1332.328921) + self.assertFloatEqual(vmax, 10104.83204) + self.assertFloatEqual(actives[2000].dz, 1.68506) + + act_dim = (48.5676, 54.1515, 1.685) # cell dimension in meter + cel_dim = self.cell.dimension + self.assertEqual(3, len(cel_dim)) + for d in range(2): + self.assertFloatEqual(act_dim[d], cel_dim[d]) + + def test_indices(self): + c = self.cell + self.assertEqual(3455, c.global_index) + self.assertEqual(2000, c.active_index) + self.assertEqual((4,1,82), c.ijk) + self.assertEqual(c.ijk, (c.i, c.j, c.k)) + + def test_coordinates(self): + c = self.cell + corners = c.corners + self.assertEqual(8, len(corners)) + se0 = corners[5] # upper south east + se0_act = (606900.002, 5202050.07, 5149.26) + for i in range(3): + self.assertFloatEqual(se0[i], se0_act[i]) + + coordinate = c.coordinate + coor_act = (606866.883, 5202064.939, 5154.52) + + for i in range(3): + self.assertFloatEqual(coordinate[i], coor_act[i]) + + xyz = c.coordinate + self.assertIn(xyz, c) + + def test_eq(self): + c1 = self.cell + c2 = self.grid[4,1,82] + c3 = self.grid[1,1,82] + self.assertEqual(c1,c2) + self.assertEqual(c2,c1) + self.assertNotEqual(c1, 'notacell') + self.assertNotEqual(c1,c3) + self.assertNotEqual(c3,c1) + + def test_getitem_3(self): + c = self.cell + d = self.grid[4,1,82] + self.assertEqual(c, d) + + def test_validity(self): + self.assertTrue(self.cell.valid_geometry) + self.assertTrue(self.cell.valid) + + def test_repr(self): + c = self.cell + r = repr(c) + self.assertTrue(r.startswith('Cell(4, 1, 82, active, ')) + self.assertIn('faarikaal1.EGRID', r) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py new file mode 100644 index 0000000000..49e4f997f1 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py @@ -0,0 +1,25 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'test_debug.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.util.test import debug_msg +from tests import EclTest + +class DebugTest(EclTest): + + def test_create(self): + msg = debug_msg( "DEBUG" ) + self.assertIn( __file__[:-1] , msg ) + self.assertIn( "DEBUG" , msg ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py new file mode 100644 index 0000000000..869b6a4168 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_deprecation.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import warnings +import time +import datetime + +from ecl.util.test import TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclFile, EclKW, FortIO, openFortIO +from ecl.grid import EclGrid, EclGrid, EclRegion, EclGridGenerator +from ecl.rft import EclRFT +from ecl.util.test.ecl_mock import createEclSum +from ecl.util.util import BoolVector +from tests import EclTest + +# The class Deprecation_1_9_Test contains methods which will be marked +# as deprecated in the 1.9.x versions. + +warnings.simplefilter("error" , DeprecationWarning) + +class Deprecation_2_1_Test(EclTest): + pass + +class Deprecation_2_0_Test(EclTest): + + def test_EclFile_name_property(self): + with TestAreaContext("name") as t: + kw = EclKW("TEST", 3, EclDataType.ECL_INT) + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + kw.fwrite( f ) + + t.sync() + f = EclFile( "TEST" ) + +class Deprecation_1_9_Test(EclTest): + + def test_EclRegion_properties(self): + grid = EclGridGenerator.createRectangular( (10,10,10) , (1,1,1)) + region = EclRegion( grid , False ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py new file mode 100644 index 0000000000..e6a8fed20a --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os +import random + +from ecl.util.util import IntVector +from ecl import EclDataType, EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclFile, FortIO +from ecl.grid import EclGrid +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class Ecl3DKWTest(EclTest): + + def test_create( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT ) + self.assertEqual( len(kw) , grid.getNumActive()) + + self.assertEqual( (10,10,10) , kw.dims() ) + + + def test_create_global_size( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , global_active = True) + self.assertEqual( len(kw) , grid.getGlobalSize()) + + kw.assign(50) + self.assertEqual( kw[0,0,0] , 50 ) + + kw[0,0,0] = 45 + self.assertEqual( kw[0,0,0] , 45 ) + + + def test_fix_uninitialized(self): + nx = 10 + ny = 11 + nz = 12 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + kw = Ecl3DKW("REGIONS" , grid , EclDataType.ECL_INT , global_active = True) + kw.assign(3) + self.assertEqual( 3 * nx*ny*nz , sum(kw)) + + kw[1,1,1] = 0 + kw[3,3,3] = 0 + kw[6,6,6] = 0 + + self.assertEqual( 3 * nx*ny*nz - 9 , sum(kw)) + kw.fixUninitialized( grid ) + self.assertEqual( 3 * nx*ny*nz , sum(kw)) + + + + def test_getitem( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77) + + with self.assertRaises(IndexError): + kw[1000] + + with self.assertRaises(IndexError): + kw[0,10,100] + + with self.assertRaises(ValueError): + kw[1,1] + + with self.assertRaises(ValueError): + kw[1,1,1,1] + + kw.assign(99) + + self.assertEqual( kw[0,0,0] , 77 ) + self.assertEqual( kw[0,0,1] , 99 ) + + + + def test_setitem( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77) + + with self.assertRaises(IndexError): + kw[1000] + + with self.assertRaises(IndexError): + kw[0,10,100] + + with self.assertRaises(ValueError): + kw[1,1] + + with self.assertRaises(ValueError): + kw[1,1,1,1] + + kw.assign(99) + self.assertEqual( kw[0,0,0] , 77 ) + self.assertEqual( kw[0,0,1] , 99 ) + + + with self.assertRaises(ValueError): + kw[0,0,0] = 88 + + kw[0,0,1] = 100 + self.assertEqual( kw[0,0,1] , 100 ) + + + + def test_cast(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw_wrong_size = EclKW( "KW" , 27 , EclDataType.ECL_FLOAT ) + kw_global_size = EclKW( "KW" , grid.getGlobalSize() , EclDataType.ECL_FLOAT ) + kw_active_size = EclKW( "KW" , grid.getNumActive() , EclDataType.ECL_FLOAT ) + + with self.assertRaises(ValueError): + Ecl3DKW.castFromKW(kw_wrong_size , grid) + + Ecl3DKW.castFromKW(kw_global_size , grid) + self.assertTrue( isinstance( kw_global_size , Ecl3DKW)) + + Ecl3DKW.castFromKW(kw_active_size , grid , default_value = 66) + self.assertTrue( isinstance( kw_active_size , Ecl3DKW)) + + self.assertEqual( kw_active_size[0,0,0] , 66) + with self.assertRaises(ValueError): + kw_active_size[0,0,0] = 88 + + + def test_default(self): + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1)) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT ) + kw.setDefault(55) + self.assertTrue( 55 , kw.getDefault()) + + + def test_compressed_copy(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(500): + actnum[2*i + 1] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_INT , global_active = True) + for i in range(len(kw)): + kw[i] = i + + kw_copy = kw.compressedCopy() + self.assertTrue( isinstance( kw_copy , EclKW ) ) + + self.assertEqual(len(kw_copy) , 500) + for i in range(len(kw_copy)): + self.assertEqual(kw_copy[i] , 2*i) + + + + def test_global_copy(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(500): + actnum[2*i + 1] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_INT , global_active = False) + for i in range(len(kw)): + kw[i] = i + + kw.setDefault( 177 ) + kw_copy = kw.globalCopy() + self.assertTrue( isinstance( kw_copy , EclKW ) ) + + self.assertEqual(len(kw_copy) , 1000) + for i in range(len(kw)): + self.assertEqual(kw_copy[2*i] , i) + self.assertEqual(kw_copy[2*i + 1] , kw.getDefault()) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py new file mode 100644 index 0000000000..39adb1fcb9 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py @@ -0,0 +1,70 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.util.test import TestAreaContext +from ecl.util.test.ecl_mock import createEclSum +from ecl.summary import EclCmp +from tests import EclTest, statoil_test + +@statoil_test() +class EclCmpTest(EclTest): + def setUp(self): + self.root1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") + self.root2 = self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") + + + def test_not_existing(self): + with self.assertRaises(IOError): + ecl_cmp = EclCmp( "missing/case1" , "missing/case2") + + with self.assertRaises(IOError): + ecl_cmp = EclCmp( "missing/case1" , self.root1 ) + + with self.assertRaises(IOError): + ecl_cmp = EclCmp( self.root1 , "missing/case1") + + ecl_cmp = EclCmp( self.root1 , self.root1) + ecl_cmp = EclCmp( self.root2 , self.root2) + + + def test_different_start(self): + with self.assertRaises(ValueError): + ecl_cmp = EclCmp(self.root1 , self.root2) + + + def test_summary_cmp(self): + ecl_cmp = EclCmp( self.root1 , self.root1) + self.assertEqual( (False , False) , ecl_cmp.hasSummaryVector("MISSING")) + self.assertEqual( (True , True) , ecl_cmp.hasSummaryVector("FOPT")) + + with self.assertRaises(KeyError): + diff = ecl_cmp.cmpSummaryVector("MISSING") + + diff_sum , ref_sum = ecl_cmp.cmpSummaryVector("FOPT") + self.assertEqual( diff_sum , 0.0 ) + self.assertTrue( ecl_cmp.endTimeEqual( ) ) + + + def test_wells(self): + ecl_cmp = EclCmp( self.root1 , self.root1) + wells = ecl_cmp.testWells() + + well_set = set( ["OP_1" , "OP_2" , "OP_3" , "OP_4" , "OP_5" , "WI_1" , "WI_2" , "WI_3"] ) + self.assertEqual( len(wells) , len(well_set)) + for well in wells: + self.assertTrue( well in well_set ) + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py new file mode 100644 index 0000000000..717012aed3 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py @@ -0,0 +1,256 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import shutil +import datetime +import os.path +import gc +from unittest import skipIf + +from ecl import EclFileFlagEnum, EclDataType, EclFileEnum +from ecl.eclfile import EclFile, FortIO, EclKW , openFortIO , openEclFile +from ecl.util.util import CWDContext +from ecl.util.test import TestAreaContext, PathContext +from tests import EclTest + +def createFile( name , kw_list ): + with openFortIO(name , mode = FortIO.WRITE_MODE) as f: + for kw in kw_list: + kw.fwrite( f ) + + +def loadKeywords( name ): + kw_list = [] + f = EclFile( name ) + for kw in f: + kw_list.append( kw ) + + return kw_list + + + + +class EclFileTest(EclTest): + + def assertFileType(self , filename , expected): + file_type , step , fmt_file = EclFile.getFileType(filename) + self.assertEqual( file_type , expected[0] ) + self.assertEqual( fmt_file , expected[1] ) + self.assertEqual( step , expected[2] ) + + + def test_file_type(self): + self.assertFileType( "ECLIPSE.UNRST" , (EclFileEnum.ECL_UNIFIED_RESTART_FILE , False , None)) + self.assertFileType( "ECLIPSE.X0030" , (EclFileEnum.ECL_RESTART_FILE , False , 30 )) + self.assertFileType( "ECLIPSE.DATA" , (EclFileEnum.ECL_DATA_FILE , None , None )) + self.assertFileType( "ECLIPSE.FINIT" , (EclFileEnum.ECL_INIT_FILE , True , None )) + self.assertFileType( "ECLIPSE.A0010" , (EclFileEnum.ECL_SUMMARY_FILE , True , 10 )) + self.assertFileType( "ECLIPSE.EGRID" , (EclFileEnum.ECL_EGRID_FILE , False , None )) + + + def test_IOError(self): + with self.assertRaises(IOError): + EclFile("No/Does/not/exist") + + + def test_context( self ): + with TestAreaContext("python/ecl_file/context"): + kw1 = EclKW( "KW1" , 100 , EclDataType.ECL_INT) + kw2 = EclKW( "KW2" , 100 , EclDataType.ECL_INT) + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + kw2.fwrite( f ) + + with openEclFile("TEST") as ecl_file: + self.assertEqual( len(ecl_file) , 2 ) + self.assertTrue( ecl_file.has_kw("KW1")) + self.assertTrue( ecl_file.has_kw("KW2")) + self.assertEqual(ecl_file[1], ecl_file[-1]) + + def test_ecl_index(self): + with TestAreaContext("python/ecl_file/context"): + kw1 = EclKW( "KW1" , 100 , EclDataType.ECL_INT) + kw2 = EclKW( "KW2" , 100 , EclDataType.ECL_FLOAT) + kw3 = EclKW( "KW3" , 100 , EclDataType.ECL_CHAR) + kw4 = EclKW( "KW4" , 100 , EclDataType.ECL_STRING(23)) + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + kw2.fwrite( f ) + kw3.fwrite( f ) + kw4.fwrite( f ) + + ecl_file = EclFile("TEST") + ecl_file.write_index("INDEX_FILE") + ecl_file.close() + + ecl_file_index = EclFile("TEST", 0, "INDEX_FILE") + for kw in ["KW1","KW2","KW3","KW4"]: + self.assertIn( kw , ecl_file_index ) + + with self.assertRaises(IOError): + ecl_file.write_index("does-not-exist/INDEX") + + os.mkdir("read-only") + os.chmod("read-only", 0o444) + + with self.assertRaises(IOError): + ecl_file.write_index("read-only/INDEX") + + with self.assertRaises(IOError): + ecl_file_index = EclFile("TEST", 0, "index_does_not_exist") + + shutil.copyfile( "INDEX_FILE" , "INDEX_perm_denied") + os.chmod("INDEX_perm_denied", 0o000) + with self.assertRaises(IOError): + ecl_file_index = EclFile("TEST", 0, "INDEX_perm_denied") + + + os.mkdir("path") + shutil.copyfile("TEST" , "path/TEST") + ecl_file = EclFile("path/TEST") + ecl_file.write_index("path/index") + + with CWDContext("path"): + ecl_file = EclFile("TEST" , 0 , "index") + + + def test_save_kw(self): + with TestAreaContext("python/ecl_file/save_kw"): + data = range(1000) + kw = EclKW("MY_KEY", len(data), EclDataType.ECL_INT) + for index, val in enumerate(data): + kw[index] = val + + clean_dump = "my_clean_file" + fortio = FortIO(clean_dump, FortIO.WRITE_MODE) + kw.fwrite(fortio) + fortio.close() + + test_file = "my_dump_file" + fortio = FortIO(test_file, FortIO.WRITE_MODE) + kw.fwrite(fortio) + fortio.close() + + self.assertFilesAreEqual(clean_dump, test_file) + + ecl_file = EclFile(test_file, flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + loaded_kw = ecl_file["MY_KEY"][0] + self.assertTrue(kw.equal(loaded_kw)) + + ecl_file.save_kw(loaded_kw) + ecl_file.close() + + self.assertFilesAreEqual(clean_dump, test_file) + + ecl_file = EclFile(test_file) + loaded_kw = ecl_file["MY_KEY"][0] + self.assertTrue(kw.equal(loaded_kw)) + + def test_gc(self): + kw1 = EclKW("KW1" , 100 , EclDataType.ECL_INT) + kw2 = EclKW("KW2" , 100 , EclDataType.ECL_INT) + kw3 = EclKW("KW3" , 100 , EclDataType.ECL_INT) + + for i in range(len(kw1)): + kw1[i] = i + kw2[i] = 2*i + kw3[i] = 3*i + + kw_list = [kw1 , kw2 , kw2] + + with TestAreaContext("context") as ta: + createFile("TEST" , kw_list ) + gc.collect() + kw_list2 = loadKeywords( "TEST" ) + + for kw1,kw2 in zip(kw_list,kw_list2): + self.assertEqual( kw1, kw2 ) + + + def test_broken_file(self): + with TestAreaContext("test_broken_file"): + with open("CASE.FINIT", "w") as f: + f.write("This - is not a ECLISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc") + + + with self.assertRaises(IOError): + f = EclFile("CASE.FINIT") + + + def test_block_view(self): + with TestAreaContext("python/ecl_file/view"): + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + for i in range(5): + header = EclKW("HEADER" , 1 , EclDataType.ECL_INT ) + header[0] = i + + data1 = EclKW("DATA1" , 100 , EclDataType.ECL_INT ) + data1.assign( i ) + + + data2 = EclKW("DATA2" , 100 , EclDataType.ECL_INT ) + data2.assign( i*10 ) + + header.fwrite( f ) + data1.fwrite( f ) + data2.fwrite( f ) + + + ecl_file = EclFile("TEST") + pfx = 'EclFile(' + self.assertEqual(pfx, repr(ecl_file)[:len(pfx)]) + with self.assertRaises(KeyError): + ecl_file.blockView("NO" , 1) + + with self.assertRaises(IndexError): + ecl_file.blockView("HEADER" , 100) + + with self.assertRaises(IndexError): + ecl_file.blockView("HEADER" , 1000) + + bv = ecl_file.blockView("HEADER" , -1) + + + for i in range(5): + view = ecl_file.blockView("HEADER" , i) + self.assertEqual( len(view) , 3) + header = view["HEADER"][0] + data1 = view["DATA1"][0] + data2 = view["DATA2"][0] + + self.assertEqual( header[0] , i ) + self.assertEqual( data1[99] , i ) + self.assertEqual( data2[99] , i*10 ) + + + for i in range(5): + view = ecl_file.blockView2("HEADER" , "DATA2", i ) + self.assertEqual( len(view) , 2) + header = view["HEADER"][0] + data1 = view["DATA1"][0] + + self.assertEqual( header[0] , i ) + self.assertEqual( data1[99] , i ) + + self.assertFalse( "DATA2" in view ) + + view = ecl_file.blockView2("HEADER" , None, 0 ) + self.assertEqual( len(view) , len(ecl_file)) + + view = ecl_file.blockView2(None , "DATA2", 0 ) + #self.assertEqual( len(view) , 2) + #self.assertTrue( "HEADER" in view ) + #self.assertTrue( "DATA1" in view ) + #self.assertFalse( "DATA2" in view ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py new file mode 100644 index 0000000000..8377b639f0 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py @@ -0,0 +1,275 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import datetime +import os.path +from unittest import skipIf + +from ecl import EclFileFlagEnum, EclFileEnum +from ecl.eclfile import EclFile, FortIO, EclKW , openFortIO , openEclFile + +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test + + +@statoil_test() +class EclFileStatoilTest(EclTest): + def setUp(self): + self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.test_fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") + + def assertFileType(self , filename , expected): + file_type , step , fmt_file = EclFile.getFileType(filename) + self.assertEqual( file_type , expected[0] ) + self.assertEqual( fmt_file , expected[1] ) + self.assertEqual( step , expected[2] ) + + + def test_fast_open(self): + with TestAreaContext("index"): + f0 = EclFile( self.test_file ) + f0.write_index("index") + f1 = EclFile( self.test_file , 0 , "index") + for kw0,kw1 in zip(f0,f1): + self.assertEqual( kw0,kw1 ) + + def test_restart_days(self): + rst_file = EclFile( self.test_file ) + self.assertAlmostEqual( 0.0 , rst_file.iget_restart_sim_days(0) ) + self.assertAlmostEqual( 31.0 , rst_file.iget_restart_sim_days(1) ) + self.assertAlmostEqual( 274.0 , rst_file.iget_restart_sim_days(10) ) + + with self.assertRaises(KeyError): + rst_file.restart_get_kw("Missing" , dtime = datetime.date( 2004,1,1)) + + with self.assertRaises(IndexError): + rst_file.restart_get_kw("SWAT" , dtime = datetime.date( 1985 , 1 , 1)) + + + def test_iget_named(self): + f = EclFile(self.test_file) + N = f.num_named_kw( "SWAT" ) + with self.assertRaises(IndexError): + s = f.iget_named_kw( "SWAT" , N + 1) + + + + def test_fwrite( self ): + #work_area = TestArea("python/ecl_file/fwrite") + with TestAreaContext("python/ecl_file/fwrite"): + rst_file = EclFile(self.test_file) + fortio = FortIO("ECLIPSE.UNRST", FortIO.WRITE_MODE) + rst_file.fwrite(fortio) + fortio.close() + rst_file.close() + self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) + + + + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") + def test_save(self): + #work_area = TestArea("python/ecl_file/save") + with TestAreaContext("python/ecl_file/save", store_area=False) as work_area: + work_area.copy_file(self.test_file) + rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + swat0 = rst_file["SWAT"][0] + swat0.assign(0.75) + rst_file.save_kw(swat0) + rst_file.close() + self.assertFilesAreNotEqual("ECLIPSE.UNRST",self.test_file) + + rst_file1 = EclFile(self.test_file) + rst_file2 = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + + swat1 = rst_file1["SWAT"][0] + swat2 = rst_file2["SWAT"][0] + swat2.assign(swat1) + + rst_file2.save_kw(swat2) + self.assertTrue(swat1.equal(swat2)) + rst_file1.close() + rst_file2.close() + + # Random failure .... + self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) + + + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") + def test_save_fmt(self): + #work_area = TestArea("python/ecl_file/save_fmt") + with TestAreaContext("python/ecl_file/save_fmt") as work_area: + work_area.copy_file(self.test_fmt_file) + rst_file = EclFile("ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + swat0 = rst_file["SWAT"][0] + swat0.assign(0.75) + rst_file.save_kw(swat0) + rst_file.close() + self.assertFilesAreNotEqual("ECLIPSE.FUNRST", self.test_fmt_file) + + rst_file1 = EclFile(self.test_fmt_file) + rst_file2 = EclFile("ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + + swat1 = rst_file1["SWAT"][0] + swat2 = rst_file2["SWAT"][0] + + swat2.assign(swat1) + rst_file2.save_kw(swat2) + self.assertTrue(swat1.equal(swat2)) + rst_file1.close() + rst_file2.close() + + # Random failure .... + self.assertFilesAreEqual("ECLIPSE.FUNRST", self.test_fmt_file) + + + def test_truncated(self): + with TestAreaContext("python/ecl_file/truncated") as work_area: + work_area.copy_file(self.test_file) + size = os.path.getsize("ECLIPSE.UNRST") + with open("ECLIPSE.UNRST" , "r+") as f: + f.truncate( size / 2 ) + + with self.assertRaises(IOError): + rst_file = EclFile("ECLIPSE.UNRST") + + with self.assertRaises(IOError): + rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + + def test_restart_view(self): + f = EclFile( self.test_file ) + with self.assertRaises(ValueError): + v = f.restartView( ) + + v = f.restartView( sim_days = 274 ) + v = f.restartView( sim_time = datetime.date( 2004,1,1) ) + v = f.restartView( report_step = 30 ) + v = f.restartView( seqnum_index = 30 ) + + + def test_index(self): + with TestAreaContext("python/ecl_file/truncated"): + f0 = EclFile( self.test_file ) + f0.write_index( "index" ) + + f1 = EclFile( self.test_file , index_filename = "index") + for kw0,kw1 in zip(f0,f1): + self.assertEqual(kw0,kw1) + + + def test_ix_case(self): + f = EclFile( self.createTestPath( "Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well.SMSPEC")) + + # Keywords + self.assertTrue( "KEYWORDS" in f ) + keywords_loaded = list(f["KEYWORDS"][0]) + keywords_from_file = [ + 'TIME', 'YEARS', 'AAQR', 'AAQT', 'AAQP', 'AAQR', 'AAQT', + 'AAQP', 'AAQR', 'AAQT', 'AAQP', 'FPPW', 'FPPO', 'FPPG', 'FNQT', + 'FNQR', 'FEIP', 'FWPT', 'FWIT', 'FWIP', 'FWGR', 'FVPT', 'FVPR', + 'FVIT', 'FVIR', 'FPR', 'FOPT', 'FOIT', 'FOIR', 'FOIPL', + 'FOIPG', 'FOIP', 'FGPT', 'FGIT', 'FGIPL', 'FGIPG', 'FGIP', + 'FAQT', 'FAQR', 'FGOR', 'FWCT', 'FGSR', 'FGIR', 'FGPR', 'FWIR', + 'FWPR', 'FOPR', 'MEMORYTS', 'NAIMFRAC', 'TCPUDAY', 'TCPUTS', + 'NBAKFL', 'NNUMST', 'NNUMFL', 'NEWTFL', 'MSUMNEWT', 'MSUMLINS', + 'MLINEARS', 'NLINEARS', 'NEWTON', 'ELAPSED', 'TCPU', + 'TIMESTEP', 'GOPR', 'GOPR', 'GOPR', 'GWPR', 'GWPR', 'GWPR', + 'GWIR', 'GWIR', 'GWIR', 'GGPR', 'GGPR', 'GGPR', 'GWCT', 'GWCT', + 'GWCT', 'GGOR', 'GGOR', 'GGOR', 'GGIR', 'GGIR', 'GGIR', 'GGIT', + 'GGIT', 'GGIT', 'GGPT', 'GGPT', 'GGPT', 'GOIR', 'GOIR', 'GOIR', + 'GOIT', 'GOIT', 'GOIT', 'GOPT', 'GOPT', 'GOPT', 'GVIR', 'GVIR', + 'GVIR', 'GVIT', 'GVIT', 'GVIT', 'GVPR', 'GVPR', 'GVPR', 'GVPT', + 'GVPT', 'GVPT', 'GWGR', 'GWGR', 'GWGR', 'GWIT', 'GWIT', 'GWIT', + 'GWPT', 'GWPT', 'GWPT', 'WOPR', 'WOPR', 'WOPR', 'WOPR', 'WOPR', + 'WOPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWIR', + 'WWIR', 'WWIR', 'WWIR', 'WWIR', 'WWIR', 'WGPR', 'WGPR', 'WGPR', + 'WGPR', 'WGPR', 'WGPR', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', + 'WWCT', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', + 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WAPI', 'WAPI', + 'WAPI', 'WAPI', 'WAPI', 'WAPI', 'WBHP', 'WBHP', 'WBHP', 'WBHP', + 'WBHP', 'WBHP', 'WGIR', 'WGIR', 'WGIR', 'WGIR', 'WGIR', 'WGIR', + 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGPT', 'WGPT', + 'WGPT', 'WGPT', 'WGPT', 'WGPT', 'WOIR', 'WOIR', 'WOIR', 'WOIR', + 'WOIR', 'WOIR', 'WOIT', 'WOIT', 'WOIT', 'WOIT', 'WOIT', 'WOIT', + 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WPIG', 'WPIG', + 'WPIG', 'WPIG', 'WPIG', 'WPIG', 'WPIO', 'WPIO', 'WPIO', 'WPIO', + 'WPIO', 'WPIO', 'WPIW', 'WPIW', 'WPIW', 'WPIW', 'WPIW', 'WPIW', + 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WVIR', 'WVIR', + 'WVIR', 'WVIR', 'WVIR', 'WVIR', 'WVIT', 'WVIT', 'WVIT', 'WVIT', + 'WVIT', 'WVIT', 'WVPR', 'WVPR', 'WVPR', 'WVPR', 'WVPR', 'WVPR', + 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WWGR', 'WWGR', + 'WWGR', 'WWGR', 'WWGR', 'WWGR', 'WWIT', 'WWIT', 'WWIT', 'WWIT', + 'WWIT', 'WWIT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', + 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBP', 'WBP', + 'WBP', 'WBP', 'WBP', 'WBP', 'WWCT', 'WWCT', 'WWCT', 'WWCT', + 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', + 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', + 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT' + ] + + padd = lambda str_len : (lambda s : s + (" " * (max(0, str_len-len(s))))) + self.assertEqual( list(map(padd(8), keywords_from_file)), keywords_loaded) + + # Names + self.assertTrue( "NAMES" in f ) + names_loaded = list(f["NAMES"][0]) + names_from_file = [ + '', '', 'AQFR_1', 'AQFR_1', 'AQFR_1', 'AQFR_2', 'AQFR_2', + 'AQFR_2', 'AQFR_3', 'AQFR_3', 'AQFR_3', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', + 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', + 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', + 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', + 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', + 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', + 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', + 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', + 'TWO', 'FIELD', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', + 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', + 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', + 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', + 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', + 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', + 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', + 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', + 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', + 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', + 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', + 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', + 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', + 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', + 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', + 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', + 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', + 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', + 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', + 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', + 'I6', 'I8', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', + ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', + ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', + ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', + ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', + ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+' + ] + + self.assertEqual( list(map(padd(10), names_from_file)), names_loaded) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py new file mode 100644 index 0000000000..9be2c65c72 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py @@ -0,0 +1,49 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO +from ecl.grid import EclGrid + +@statoil_test() +class InitFileTest(EclTest): + + + def setUp(self): + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.init_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT") + + + def test_wrong_type(self): + g = EclGrid(self.grid_file) + with self.assertRaises(ValueError): + f = EclInitFile(g, self.grid_file) + + + def test_load(self): + g = EclGrid(self.grid_file) + f = EclInitFile(g, self.init_file) + + head = f["INTEHEAD"][0] + self.assertTrue(isinstance(head, EclKW)) + + porv = f["PORV"][0] + self.assertTrue(isinstance(porv, Ecl3DKW)) + + poro = f["PORO"][0] + self.assertTrue(isinstance(poro, Ecl3DKW)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py new file mode 100644 index 0000000000..19617aad8d --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py @@ -0,0 +1,614 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import random +import warnings +import cwrap +import random + +from ecl import EclDataType, EclTypeEnum, EclFileFlagEnum +from ecl.eclfile import EclKW, EclFile, FortIO, openFortIO + + +from ecl.util.test import TestAreaContext +from tests import EclTest + + +def copy_long(): + src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + copy = src.sub_copy(0, 2000) + + +def copy_offset(): + src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + copy = src.sub_copy(200, 100) + + +class KWTest(EclTest): + + def test_name(self): + kw = EclKW('TEST', 3, EclDataType.ECL_INT) + self.assertEqual(kw.name, 'TEST') + self.assertIn('TEST', repr(kw)) + kw.name = 'SCHMEST' + self.assertEqual(kw.name, 'SCHMEST') + self.assertIn('SCHMEST', repr(kw)) + + def test_min_max(self): + kw = EclKW("TEST", 3, EclDataType.ECL_INT) + kw[0] = 10 + kw[1] = 5 + kw[2] = 0 + + self.assertEqual(10, kw.getMax()) + self.assertEqual(0 , kw.getMin()) + self.assertEqual((0,10) , kw.getMinMax()) + + + def test_deprecated_datatypes(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + kw = EclKW("Test", 10, EclTypeEnum.ECL_INT_TYPE) + self.assertTrue(len(w) > 0) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + kw = EclKW("Test", 10, EclDataType.ECL_INT) + self.assertTrue(len(w) == 0) + + self.assertEqual(EclTypeEnum.ECL_INT_TYPE, kw.type) + + self.assertTrue(len(w) > 0) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + + def kw_test(self, data_type, data, fmt): + name1 = "file1.txt" + name2 = "file2.txt" + kw = EclKW("TEST", len(data), data_type) + i = 0 + for d in data: + kw[i] = d + i += 1 + + file1 = cwrap.open(name1, "w") + kw.fprintf_data(file1, fmt) + file1.close() + + file2 = open(name2, "w") + for d in data: + file2.write(fmt % d) + file2.close() + self.assertFilesAreEqual(name1, name2) + self.assertEqual(kw.data_type, data_type) + + def test_create(self): + with self.assertRaises(ValueError): + EclKW("ToGodDamnLong", 100, EclDataType.ECL_CHAR) + + def test_sum(self): + for ecl_type in [EclDataType.ECL_CHAR, EclDataType.ECL_STRING(42)]: + kw_string = EclKW("STRING", 100, ecl_type) + with self.assertRaises(ValueError): + kw_string.sum() + + kw_int = EclKW("INT", 4, EclDataType.ECL_INT) + kw_int[0] = 1 + kw_int[1] = 2 + kw_int[2] = 3 + kw_int[3] = 4 + self.assertEqual(kw_int.sum(), 10) + + kw_d = EclKW("D", 4, EclDataType.ECL_DOUBLE) + kw_d[0] = 1 + kw_d[1] = 2 + kw_d[2] = 3 + kw_d[3] = 4 + self.assertEqual(kw_d.sum(), 10) + + kw_f = EclKW("F", 4, EclDataType.ECL_FLOAT) + kw_f[0] = 1 + kw_f[1] = 2 + kw_f[2] = 3 + kw_f[3] = 4 + self.assertEqual(kw_f.sum(), 10) + + kw_b = EclKW("F", 4, EclDataType.ECL_BOOL) + kw_b[0] = False + kw_b[1] = True + kw_b[2] = False + kw_b[3] = True + self.assertEqual(kw_b.sum(), 2) + + + + def test_fprintf(self): + with TestAreaContext("python.ecl_kw"): + self.kw_test(EclDataType.ECL_INT, [0, 1, 2, 3, 4, 5], "%4d\n") + self.kw_test(EclDataType.ECL_FLOAT, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n") + self.kw_test(EclDataType.ECL_DOUBLE, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n") + self.kw_test(EclDataType.ECL_BOOL, [True, True, True, False, True], "%4d\n") + self.kw_test(EclDataType.ECL_CHAR, ["1", "22", "4444", "666666", "88888888"], "%-8s\n") + + for str_len in range(1000): + self.kw_test(EclDataType.ECL_STRING(str_len), [str(i)*str_len for i in range(10)], "%s\n") + + def test_kw_write(self): + with TestAreaContext("python/ecl_kw/writing"): + + data = [random.random() for i in range(10000)] + + kw = EclKW("TEST", len(data), EclDataType.ECL_DOUBLE) + i = 0 + for d in data: + kw[i] = d + i += 1 + + pfx = 'EclKW(' + self.assertEqual(pfx, repr(kw)[:len(pfx)]) + + fortio = FortIO("ECL_KW_TEST", FortIO.WRITE_MODE) + kw.fwrite(fortio) + fortio.close() + + fortio = FortIO("ECL_KW_TEST") + + kw2 = EclKW.fread(fortio) + + self.assertTrue(kw.equal(kw2)) + + ecl_file = EclFile("ECL_KW_TEST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + kw3 = ecl_file["TEST"][0] + self.assertTrue(kw.equal(kw3)) + ecl_file.save_kw(kw3) + ecl_file.close() + + fortio = FortIO("ECL_KW_TEST", FortIO.READ_AND_WRITE_MODE) + kw4 = EclKW.fread(fortio) + self.assertTrue(kw.equal(kw4)) + fortio.seek(0) + kw4.fwrite(fortio) + fortio.close() + + ecl_file = EclFile("ECL_KW_TEST") + kw5 = ecl_file["TEST"][0] + self.assertTrue(kw.equal(kw5)) + + + + def test_fprintf_data(self): + with TestAreaContext("kw_no_header"): + kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + for i in range(len(kw)): + kw[i] = i + + fileH = cwrap.open("test", "w") + kw.fprintf_data(fileH) + fileH.close() + + fileH = open("test", "r") + data = [] + for line in fileH.readlines(): + tmp = line.split() + for elm in tmp: + data.append(int(elm)) + + for (v1,v2) in zip(data,kw): + self.assertEqual(v1,v2) + + + def test_sliced_set(self): + kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + kw.assign(99) + kw[0:5] = 66 + self.assertEqual(kw[0], 66) + self.assertEqual(kw[4], 66) + self.assertEqual(kw[5], 99) + + + def test_long_name(self): + with self.assertRaises(ValueError): + EclKW("LONGLONGNAME", 10, EclDataType.ECL_INT) + + kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + with self.assertRaises(ValueError): + kw.name = "LONGLONGNAME" + + + def test_abs(self): + for ecl_type in [ + EclDataType.ECL_CHAR, + EclDataType.ECL_BOOL, + EclDataType.ECL_STRING(32) + ]: + kw = EclKW("NAME", 10, ecl_type) + with self.assertRaises(TypeError): + abs_kw = abs(kw) + + kw = EclKW("NAME", 10, EclDataType.ECL_INT) + for i in range(len(kw)): + kw[i] = -i + + abs_kw = abs(kw) + for i in range(len(kw)): + self.assertEqual(kw[i], -i) + self.assertEqual(abs_kw[i], i) + + + def test_fmt(self): + kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) + kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) + + for i in range(len(kw1)): + kw1[i] = i + 1 + kw2[i] = len(kw1) - kw1[i] + + with TestAreaContext("ecl_kw/fmt") as ta: + with openFortIO("TEST.FINIT", FortIO.WRITE_MODE, fmt_file=True) as f: + kw1.fwrite(f) + kw2.fwrite(f) + + with openFortIO("TEST.FINIT", fmt_file=True) as f: + kw1b = EclKW.fread(f) + kw2b = EclKW.fread(f) + + self.assertTrue(kw1 == kw1b) + self.assertTrue(kw2 == kw2b) + + f = EclFile("TEST.FINIT") + self.assertTrue(kw1 == f[0]) + self.assertTrue(kw2 == f[1]) + + + def test_first_different(self): + kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) + kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) + kw3 = EclKW("NAME2", 200, EclDataType.ECL_INT) + kw4 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) + kw5 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) + + + with self.assertRaises(IndexError): + EclKW.firstDifferent(kw1, kw2, offset=100) + + with self.assertRaises(ValueError): + EclKW.firstDifferent(kw1, kw3) + + with self.assertRaises(TypeError): + EclKW.firstDifferent(kw1, kw4) + + + with self.assertRaises(IndexError): + kw1.firstDifferent(kw2, offset=100) + + with self.assertRaises(ValueError): + kw1.firstDifferent(kw3) + + with self.assertRaises(TypeError): + kw1.firstDifferent(kw4) + + + kw1.assign(1) + kw2.assign(1) + + self.assertEqual(kw1.firstDifferent(kw2), len(kw1)) + + kw1[0] = 100 + self.assertEqual(kw1.firstDifferent(kw2), 0) + self.assertEqual(kw1.firstDifferent(kw2, offset=1), len(kw1)) + kw1[10] = 100 + self.assertEqual(kw1.firstDifferent(kw2, offset=1), 10) + + + kw4.assign(1.0) + kw5.assign(1.0) + self.assertEqual(kw4.firstDifferent(kw5), len(kw4)) + + kw4[10] *= 1.0001 + self.assertEqual(kw4.firstDifferent(kw5), 10) + + self.assertEqual(kw4.firstDifferent(kw5, epsilon=1.0), len(kw4)) + self.assertEqual(kw4.firstDifferent(kw5, epsilon=0.0000001), 10) + + + def test_numeric_equal(self): + kw1 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) + kw2 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) + + + shift = 0.0001 + value = 1000 + + abs_diff = shift + rel_diff = shift / (shift + 2* value) + kw1.assign(value) + kw2.assign(value + shift) + + + self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=rel_diff * 1.1)) + self.assertFalse(kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=rel_diff * 0.9)) + self.assertFalse(kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 0.9, rel_epsilon=rel_diff * 1.1)) + self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=0, rel_epsilon=rel_diff * 1.1)) + self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=0)) + + def test_mul(self): + kw1 = EclKW("Name1", 10, EclDataType.ECL_INT) + kw1.assign(10) + + kw2 = EclKW("Name1", 10, EclDataType.ECL_INT) + kw2.assign(2) + + kw3 = kw1 * kw2 + kw4 = kw1 + kw2 + self.assertEqual(len(kw3), len(kw1)) + self.assertEqual(len(kw4), len(kw1)) + for v in kw3: + self.assertEqual(v, 20) + + for v in kw4: + self.assertEqual(v, 12) + + + def test_numpy(self): + kw1 = EclKW("DOUBLE", 10, EclDataType.ECL_DOUBLE) + + view = kw1.numpyView() + copy = kw1.numpyCopy() + + self.assertTrue(copy[ 0 ] == kw1[ 0 ]) + self.assertTrue(view[ 0 ] == kw1[ 0 ]) + + kw1[ 0 ] += 1 + self.assertTrue(view[ 0 ] == kw1[ 0 ]) + self.assertTrue(copy[ 0 ] == kw1[ 0 ] - 1) + + for ecl_type in [ + EclDataType.ECL_CHAR, + EclDataType.ECL_BOOL, + EclDataType.ECL_STRING(19)]: + kw2 = EclKW("TEST_KW", 10, ecl_type) + with self.assertRaises(ValueError): + kw2.numpyView() + + def test_slice(self): + N = 100 + kw = EclKW("KW", N, EclDataType.ECL_INT) + for i in range(len(kw)): + kw[i] = i + + even = kw[0:len(kw):2] + odd = kw[1:len(kw):2] + + self.assertEqual(len(even), N/2) + self.assertEqual(len(odd) , N/2) + + for i in range(len(even)): + self.assertEqual(even[i], 2*i) + self.assertEqual(odd[i], 2*i + 1) + + + def test_resize(self): + N = 4 + kw = EclKW("KW", N, EclDataType.ECL_INT) + for i in range(N): + kw[i] = i + + kw.resize(2*N) + self.assertEqual(len(kw), 2*N) + for i in range(N): + self.assertEqual(kw[i], i) + + kw.resize(N/2) + self.assertEqual(len(kw), N/2) + for i in range(int(N / 2)): + self.assertEqual(kw[i], i) + + + def test_typename(self): + kw = EclKW("KW", 100, EclDataType.ECL_INT) + + self.assertEqual(kw.typeName(), "INTE") + + def test_string_alloc(self): + kw = EclKW("KW", 10, EclDataType.ECL_STRING(30)) + + for i in range(10): + kw[i] = str(i)*30 + + for i in range(10): + self.assertEqual(str(i)*30, kw[i]) + + def test_string_write_read_unformatted(self): + for str_len in range(1000): + with TestAreaContext("my_space"): + + kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) + for i in range(10): + kw[i] = str(i)*str_len + + file_name = "ecl_kw_test" + + with openFortIO(file_name, mode=FortIO.WRITE_MODE) as fortio: + kw.fwrite(fortio) + + with openFortIO(file_name) as fortio: + loaded_kw = EclKW.fread(fortio) + + self.assertEqual(kw, loaded_kw) + + def test_string_write_read_formatted(self): + for str_len in range(1000): + with TestAreaContext("my_space"): + + kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) + for i in range(10): + kw[i] = str(i)*str_len + + file_name = "ecl_kw_test" + with openFortIO(file_name, mode=FortIO.WRITE_MODE, fmt_file=True) as fortio: + kw.fwrite(fortio) + + with openFortIO(file_name, fmt_file=True) as fortio: + loaded_kw = EclKW.fread(fortio) + + self.assertEqual(kw, loaded_kw) + + + def test_string_padding(self): + kw = EclKW("TEST_KW", 1, EclDataType.ECL_STRING(4)) + kw[0] = "AB" + self.assertEqual(kw[0], "AB ") + + kw = EclKW("TEST_KW", 1, EclDataType.ECL_CHAR) + kw[0] = "ABCD" + self.assertEqual(kw[0], "ABCD ") + + + + def test_add_squared(self): + kw1 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) + kw2 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) + + with self.assertRaises(TypeError): + kw1.add_squared(kw2) + + + kw1 = EclKW("T1", 10, EclDataType.ECL_INT) + kw2 = EclKW("T2", 11, EclDataType.ECL_INT) + with self.assertRaises(ValueError): + kw1.add_squared(kw2) + + kw2 = EclKW("T", 10, EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + kw1.add_squared(kw2) + + kw2 = EclKW("T2", 10, EclDataType.ECL_INT) + kw2.assign(2) + kw1.add_squared(kw2) + + for elm in kw1: + self.assertEqual(elm, 4) + + + def test_scatter_copy(self): + source = EclKW("SOURCE", 4 , EclDataType.ECL_INT) + with self.assertRaises(TypeError): + copy = source.scatter_copy([1,1,1,1]) + + actnum = EclKW("ACTNUM", 6 , EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + + actnum = EclKW("ACTNUM", 8, EclDataType.ECL_INT) + actnum[0] = 1 + actnum[1] = 1 + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + actnum.assign(1) + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + + for i in range(4): + source[i] = i+1 + actnum[2*i] = 0 + + # src = [1,2,3,4] + # actnum = [0,1,0,1,0,1,0,1] + # copy = [0,1,0,2,0,3,0,4] + copy = source.scatter_copy(actnum) + for i in range(4): + self.assertEqual(copy[2*i + 1], i+1) + + def test_safe_div(self): + kw1 = EclKW("SOURCE", 10, EclDataType.ECL_INT) + kw2 = EclKW("XXX", 11, EclDataType.ECL_INT) + + with self.assertRaises(ValueError): + kw1.safe_div(kw2) + + kw1 = EclKW("SOURCE", 2, EclDataType.ECL_FLOAT) + kw1.assign(10) + + kw2 = EclKW("DIV", 2, EclDataType.ECL_INT) + kw2[0] = 0 + kw2[1] = 2 + + kw1.safe_div( kw2 ) + self.assertEqual(kw1[0], 10) + self.assertEqual(kw1[1], 5) + + + + def test_fmu_stat_workflow(self): + N = 100 + global_size = 100 + active_size = 50 + with TestAreaContext("FMU_FILES"): + for i in range(N): + permx = EclKW("PERMX", active_size, EclDataType.ECL_FLOAT) + poro = EclKW("PORO", active_size, EclDataType.ECL_FLOAT) + porv = EclKW("PORV", global_size, EclDataType.ECL_FLOAT) + + porv.assign(0) + for g in random.sample( range(global_size), active_size): + porv[g] = 1 + + permx.assign(random.random()) + poro.assign(random.random()) + + with openFortIO("TEST%d.INIT" % i, FortIO.WRITE_MODE) as f: + permx.fwrite(f) + poro.fwrite(f) + porv.fwrite(f) + + mean_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) + std_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) + mean_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) + std_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) + + count = EclKW("COUNT", global_size, EclDataType.ECL_INT) + for i in range(N): + f = EclFile("TEST%d.INIT" % i) + + porv = f["PORV"][0] + permx = f["PERMX"][0] + poro = f["PORO"][0] + + actnum = porv.create_actnum() + + global_permx = permx.scatter_copy( actnum ) + mean_permx += global_permx + std_permx.add_squared( global_permx) + + global_poro = poro.scatter_copy( actnum ) + mean_poro += global_poro + std_poro.add_squared( global_poro) + + count += actnum + + + mean_permx.safe_div(count) + std_permx.safe_div(count) + std_permx -= mean_permx * mean_permx + std_permx.isqrt() + + mean_poro.safe_div(count) + std_poro.safe_div(count) + std_poro -= mean_poro * mean_poro + std_poro.isqrt() diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py new file mode 100644 index 0000000000..13b2d5d292 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os +import random +from ecl import EclDataType, EclFileFlagEnum +from ecl.eclfile import EclKW, EclFile, FortIO + +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test + +def copy_long(): + src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + copy = src.sub_copy(0, 2000) + + +def copy_offset(): + src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + copy = src.sub_copy(200, 100) + + +@statoil_test() +class KWTest(EclTest): + def test_fortio_size( self ): + unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file = EclFile(unrst_file_path) + size = 0 + for kw in unrst_file: + size += kw.fortIOSize() + + stat = os.stat(unrst_file_path) + self.assertTrue(size == stat.st_size) + + + + + def test_sub_copy(self): + unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file = EclFile(unrst_file_path) + swat = unrst_file["SWAT"][0] + + swat1 = swat.sub_copy(0, -1) + swat2 = swat.sub_copy(0, len(swat)) + + self.assertTrue(swat.equal(swat1)) + self.assertTrue(swat.equal(swat2)) + + swat3 = swat.sub_copy(20000, 100, new_header="swat") + self.assertTrue(swat3.getName() == "swat") + self.assertTrue(len(swat3) == 100) + equal = True + for i in range(len(swat3)): + if swat3[i] != swat[i + 20000]: + equal = False + self.assertTrue(equal) + + self.assertRaises(IndexError, copy_long) + self.assertRaises(IndexError, copy_offset) + + + def test_equal(self): + kw1 = EclKW("TEST", 3, EclDataType.ECL_CHAR) + kw1[0] = "Test1" + kw1[1] = "Test13" + kw1[2] = "Test15" + + kw2 = EclKW("TEST", 3, EclDataType.ECL_CHAR) + kw2[0] = "Test1" + kw2[1] = "Test13" + kw2[2] = "Test15" + + self.assertTrue(kw1.equal(kw2)) + self.assertTrue(kw1.equal_numeric(kw2)) + + kw2[2] = "Test15X" + self.assertFalse(kw1.equal(kw2)) + self.assertFalse(kw1.equal_numeric(kw2)) + + unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file = EclFile(unrst_file_path) + kw1 = unrst_file["PRESSURE"][0] + kw2 = kw1.deep_copy() + + self.assertTrue(kw1.equal(kw2)) + self.assertTrue(kw1.equal_numeric(kw2)) + + kw2 *= 1.00001 + self.assertFalse(kw1.equal(kw2)) + self.assertFalse(kw1.equal_numeric(kw2, epsilon=1e-8)) + self.assertTrue(kw1.equal_numeric(kw2, epsilon=1e-2)) + + kw1 = unrst_file["ICON"][10] + kw2 = kw1.deep_copy() + self.assertTrue(kw1.equal(kw2)) + self.assertTrue(kw1.equal_numeric(kw2)) + + kw1[-1] += 1 + self.assertFalse(kw1.equal(kw2)) + self.assertFalse(kw1.equal_numeric(kw2)) + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py new file mode 100644 index 0000000000..690ac7ba52 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py @@ -0,0 +1,70 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import datetime + +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO +from ecl.grid import EclGrid + +@statoil_test() +class RestartFileTest(EclTest): + def setUp(self): + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") + self.xrst_file10 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0010") + self.xrst_file20 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0020") + + + def test_load(self): + g = EclGrid( self.grid_file ) + f = EclRestartFile( g , self.unrst_file ) + + head = f["INTEHEAD"][0] + self.assertTrue( isinstance( head , EclKW )) + + swat = f["SWAT"][0] + self.assertTrue( isinstance( swat , Ecl3DKW )) + + pressure = f["PRESSURE"][0] + self.assertTrue( isinstance( pressure , Ecl3DKW )) + + + def test_type(self): + g = EclGrid( self.grid_file ) + with self.assertRaises(ValueError): + f = EclRestartFile( g , "NOT_A_RESTART_FILE") + + + def test_unified(self): + g = EclGrid( self.grid_file ) + f_unrst = EclRestartFile( g , self.unrst_file ) + f_x0 = EclRestartFile( g , self.xrst_file0 ) + f_x10 = EclRestartFile( g , self.xrst_file10 ) + f_x20 = EclRestartFile( g , self.xrst_file20 ) + + self.assertTrue( f_unrst.unified() ) + self.assertFalse( f_x0.unified() ) + self.assertFalse( f_x10.unified() ) + self.assertFalse( f_x20.unified() ) + + self.assertEqual( [(10 , datetime.datetime( 2000 , 10 , 1 , 0 , 0 , 0 ) , 274.0)] , f_x10.timeList()) + + unrst_timeList = f_unrst.timeList() + self.assertEqual( len(unrst_timeList) , 63 ) + self.assertEqual( (62 , datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0 ) , 1826.0) , unrst_timeList[62]); + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py new file mode 100644 index 0000000000..2177dbce95 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import datetime +import os.path + +from cwrap import CFILE +from cwrap import Prototype, load, open as copen + +from ecl.eclfile import EclFile, FortIO, openFortIO, openEclFile, EclKW +from ecl.summary import EclSum, EclSumKeyWordVector +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test + +@statoil_test() +class EclSumTest(EclTest): + + + def setUp(self): + self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.ecl_sum = EclSum(self.test_file) + + + def test_time_range_year(self): + real_range = self.ecl_sum.timeRange(interval="1y", extend_end=False) + extended_range = self.ecl_sum.timeRange(interval="1y", extend_end=True) + assert real_range[-1] < extended_range[-1] + + + def test_time_range_day(self): + real_range = self.ecl_sum.timeRange(interval="1d", extend_end=False) + extended_range = self.ecl_sum.timeRange(interval="1d", extend_end=True) + assert real_range[-1] == extended_range[-1] + + + def test_time_range_month(self): + real_range = self.ecl_sum.timeRange(interval="1m", extend_end=False) + extended_range = self.ecl_sum.timeRange(interval="1m", extend_end=True) + assert real_range[-1] < extended_range[-1] + + + def test_dump_csv_line(self): + ecl_sum_vector = EclSumKeyWordVector(self.ecl_sum) + ecl_sum_vector.addKeywords("F*") + + with self.assertRaises(KeyError): + ecl_sum_vector.addKeyword("MISSING") + + dtime = datetime.datetime(2002, 1, 1, 0, 0, 0) + with TestAreaContext("EclSum/csv_dump"): + test_file_name = self.createTestPath("dump.csv") + outputH = copen(test_file_name, "w") + self.ecl_sum.dumpCSVLine(dtime, ecl_sum_vector, outputH) + assert os.path.isfile(test_file_name) + + + def test_truncated_smspec(self): + with TestAreaContext("EclSum/truncated_smspec") as ta: + ta.copy_file(self.test_file) + ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + + file_size = os.path.getsize("ECLIPSE.SMSPEC") + with open("ECLIPSE.SMSPEC","r+") as f: + f.truncate(file_size / 2) + + with self.assertRaises(IOError): + EclSum("ECLIPSE") + + + def test_truncated_data(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file(self.test_file) + ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + + + file_size = os.path.getsize("ECLIPSE.UNSMRY") + with open("ECLIPSE.UNSMRY","r+") as f: + f.truncate(file_size / 2) + + with self.assertRaises(IOError): + EclSum("ECLIPSE") + + + def test_missing_smspec_keyword(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file(self.test_file) + ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + + with openEclFile("ECLIPSE.SMSPEC") as f: + kw_list = [] + for kw in f: + kw_list.append(EclKW.copy(kw)) + + with openFortIO("ECLIPSE.SMSPEC", mode=FortIO.WRITE_MODE) as f: + for kw in kw_list: + if kw.getName() == "KEYWORDS": + continue + kw.fwrite(f) + + with self.assertRaises(IOError): + EclSum("ECLIPSE") + + + def test_missing_unsmry_keyword(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file(self.test_file) + ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + + with openEclFile("ECLIPSE.UNSMRY") as f: + kw_list = [] + for kw in f: + kw_list.append(EclKW.copy(kw)) + + + with openFortIO("ECLIPSE.UNSMRY", mode=FortIO.WRITE_MODE) as f: + c = 0 + for kw in kw_list: + if kw.getName() == "PARAMS": + if c % 5 == 0: + continue + c += 1 + kw.fwrite(f) + + with self.assertRaises(IOError): + EclSum("ECLIPSE") + + + def test_labscale(self): + case = self.createTestPath("Statoil/ECLIPSE/LabScale/HDMODEL") + sum = EclSum(case) + self.assertEqual(sum.getStartTime(), datetime.datetime(2013,1,1,0,0,0)) + self.assertEqual(sum.getEndTime() , datetime.datetime(2013,1,1,19,30,0)) + self.assertFloatEqual(sum.getSimulationLength(), 0.8125) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py new file mode 100644 index 0000000000..add1916a34 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py @@ -0,0 +1,41 @@ +from datetime import datetime +import random +from ecl.ecl import EclSumTStep, EclSum +from tests import EclTest + + +class EclSumTStepTest(EclTest): + + def test_creation(self): + ecl_sum = EclSum.writer("TEST", datetime(2010, 1, 1), 10, 10, 10) + ecl_sum.addVariable("FOPT") + ecl_sum.addVariable("FOPR") + + smspec = ecl_sum.cNamespace().get_smspec(ecl_sum) + + test_data = [(1, 0, 10), (1, 1, 20), (1, 2, 30), (2, 0, 40)] + + for report_step, mini_step, sim_days in test_data: + ecl_sum_tstep = EclSumTStep(report_step, mini_step, sim_days, smspec) + + self.assertEqual(ecl_sum_tstep.getSimDays(), sim_days) + self.assertEqual(ecl_sum_tstep.getReport(), report_step) + self.assertEqual(ecl_sum_tstep.getMiniStep(), mini_step) + + self.assertTrue("FOPT" in ecl_sum_tstep) + self.assertTrue("FOPR" in ecl_sum_tstep) + self.assertFalse("WWCT" in ecl_sum_tstep) + + random_float = random.random() + ecl_sum_tstep["FOPT"] = random_float + ecl_sum_tstep["FOPR"] = random_float + 1 + + self.assertAlmostEqual(random_float, ecl_sum_tstep["FOPT"], places=5) + self.assertAlmostEqual(random_float + 1, ecl_sum_tstep["FOPR"], places=5) + + with self.assertRaises(KeyError): + ecl_sum_tstep["FROPR"] = 2 + + with self.assertRaises(KeyError): + value = ecl_sum_tstep["FROPR"] + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py new file mode 100644 index 0000000000..454fa9143a --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_ecl_sum_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +import warnings + +from ecl.summary import EclSumVector, EclSum +from tests import EclTest, statoil_test + +@statoil_test() +class EclSumVectorTest(EclTest): + + + def setUp(self): + self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.ecl_sum = EclSum(self.test_file) + + def test_reportOnly_warns(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + + vector = EclSumVector(self.ecl_sum, "FOPT", True) + assert len(w) == 1 + assert issubclass(w[-1].category, DeprecationWarning) + + + def test_basic(self): + self.assertEqual(512, len(self.ecl_sum.keys())) + pfx = 'EclSum(name' + self.assertEqual(pfx, repr(self.ecl_sum)[:len(pfx)]) + it = iter(self.ecl_sum) + #t = self.ecl_sum[it.next()] # EclSumVector + t = self.ecl_sum[next(it)] # EclSumVector + self.assertEqual(63, len(t)) + self.assertEqual('BARSA', t.unit) + pfx = 'EclSumVector(key = ' + self.assertEqual(pfx, repr(t)[:len(pfx)]) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py new file mode 100644 index 0000000000..537e7a61de --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py @@ -0,0 +1,140 @@ +from ecl.util.test import TestAreaContext +from tests import EclTest + +from ecl import EclDataType, EclTypeEnum + +def get_const_size_types(): + return EclTypeEnum.enums()[:-1:] + +class EclDataTypeTest(EclTest): + + # All of the below should list their elements in the same order as + # EclTypeEnum! + # [char, float, double, int, bool, mess] + + CONST_SIZES = [8, 4, 8, 4, 4, 0] + + CONST_VERIFIERS = [ + EclDataType.is_char, + EclDataType.is_float, + EclDataType.is_double, + EclDataType.is_int, + EclDataType.is_bool, + EclDataType.is_mess + ] + + CONST_NAMES = ["CHAR", "REAL", "DOUB", "INTE", "LOGI", "MESS"] + + STRING_NAMES = ["C000", "C010", "C020", "C042", "C999"] + + STRING_SIZES = [0, 10, 20, 42, 999] + + TYPES = (get_const_size_types() + + len(STRING_SIZES) * [EclTypeEnum.ECL_STRING_TYPE]) + + SIZES = CONST_SIZES + STRING_SIZES + + NAMES = CONST_NAMES + STRING_NAMES + + + def test_alloc_from_type(self): + types, sizes = get_const_size_types(), self.CONST_SIZES + for (ecl_type, element_size) in zip(types, sizes): + data_type = EclDataType(ecl_type) + self.assertEqual(ecl_type, data_type.type) + self.assertEqual(element_size, data_type.element_size) + + def test_invalid_string_alloc(self): + with self.assertRaises(ValueError): + data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE) + + with self.assertRaises(ValueError): + data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, -1) + + with self.assertRaises(ValueError): + data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, 1000) + + def test_alloc(self): + for (ecl_type, element_size) in zip(self.TYPES, self.SIZES): + data_type = EclDataType(ecl_type, element_size) + self.assertEqual(ecl_type, data_type.type) + self.assertEqual(element_size, data_type.element_size) + + def test_type_verifiers(self): + test_base = zip(self.TYPES, self.SIZES, self.CONST_VERIFIERS) + for (ecl_type, elem_size, verifier) in test_base: + data_type = EclDataType(ecl_type, elem_size) + self.assertTrue(verifier(data_type)) + + def test_get_type_name(self): + test_base = zip(self.TYPES, self.SIZES, self.NAMES) + for (ecl_type, elem_size, type_name) in test_base: + data_type = EclDataType(ecl_type, elem_size) + self.assertEqual(type_name, data_type.type_name) + + def test_initialization_validation(self): + invalid_args = [ + (None, 0, self.CONST_NAMES[0]), + (1, None, self.CONST_NAMES[0]), + (1, 0, self.CONST_NAMES[0]), + (None, None, None), + (None, 12, None) + ] + + for inv_arg in invalid_args: + with self.assertRaises(ValueError): + EclDataType(inv_arg[0], inv_arg[1], inv_arg[2]) + + def test_create_from_type_name(self): + test_base = zip(self.TYPES, self.SIZES, self.NAMES) + for (ecl_type, elem_size, type_name) in test_base: + data_type = EclDataType.create_from_type_name(type_name) + self.assertEqual(ecl_type, data_type.type) + self.assertEqual(elem_size, data_type.element_size) + self.assertEqual(type_name, data_type.type_name) + + def test_is_numeric(self): + numeric_types = [ + EclTypeEnum.ECL_INT_TYPE, + EclTypeEnum.ECL_FLOAT_TYPE, + EclTypeEnum.ECL_DOUBLE_TYPE + ] + + for ecl_type in numeric_types: + self.assertTrue(EclDataType(ecl_type).is_numeric()) + + for ecl_type in set(get_const_size_types())-set(numeric_types): + self.assertFalse(EclDataType(ecl_type).is_numeric()) + + for elem_size in self.STRING_SIZES: + data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) + self.assertFalse(data_type.is_numeric()) + + def test_equals(self): + test_base = zip(self.TYPES, self.SIZES) + for ecl_type, elem_size in test_base: + a = EclDataType(ecl_type, elem_size) + b = EclDataType(ecl_type, elem_size) + + self.assertTrue(a.is_equal(b)) + self.assertEqual(a, b) + + for otype, osize in set(test_base)-set([(ecl_type, elem_size)]): + self.assertFalse(a.is_equal(EclDataType(otype, osize))) + self.assertNotEqual(a, EclDataType(otype, osize)) + + def test_hash(self): + all_types = set() + test_base = list(zip(self.TYPES, self.SIZES)) + + for index, (ecl_type, elem_size) in enumerate(test_base): + all_types.add(EclDataType(ecl_type, elem_size)) + self.assertEqual(index+1, len(all_types)) + + for index, (ecl_type, elem_size) in enumerate(test_base): + all_types.add(EclDataType(ecl_type, elem_size)) + + for index, ecl_type in enumerate(get_const_size_types()): + all_types.add(EclDataType(ecl_type)) + + self.assertEqual(len(test_base), len(all_types)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py new file mode 100644 index 0000000000..89003401c1 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py @@ -0,0 +1,42 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl import EclTypeEnum , EclFileEnum, EclPhaseEnum, EclUnitTypeEnum, EclUtil +from ecl.grid import EclGrid +from tests import EclTest + +class EclUtilTest(EclTest): + + def test_enums(self): + source_file_path = "lib/include/ert/ecl/ecl_util.h" + self.assertEnumIsFullyDefined(EclFileEnum, "ecl_file_enum", source_file_path) + self.assertEnumIsFullyDefined(EclPhaseEnum, "ecl_phase_enum", source_file_path) + self.assertEnumIsFullyDefined(EclUnitTypeEnum, "ert_ecl_unit_enum", source_file_path) + + source_file_path = "lib/include/ert/ecl/ecl_type.h" + self.assertEnumIsFullyDefined(EclTypeEnum, "ecl_type_enum", source_file_path) + + def test_file_type(self): + file_type , fmt , report = EclUtil.inspectExtension("CASE.X0078") + self.assertEqual( file_type , EclFileEnum.ECL_RESTART_FILE ) + + def test_file_report_nr(self): + report_nr = EclUtil.reportStep("CASE.X0080") + self.assertEqual( report_nr , 80 ) + + with self.assertRaises(ValueError): + EclUtil.reportStep("CASE.EGRID") + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py new file mode 100644 index 0000000000..8e6ca732c4 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py @@ -0,0 +1,482 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from __future__ import print_function +from unittest import skipIf +import warnings +import cwrap + +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import FaultBlock, FaultBlockLayer, FaultBlockCell,FaultCollection +from ecl.util.geometry import Polyline , CPolylineCollection +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class FaultBlockTest(EclTest): + def setUp(self): + self.grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) ) + self.kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_INT ) + self.kw.assign( 1 ) + + reg = EclRegion( self.grid , False ) + + for k in range(self.grid.getNZ()): + reg.clear( ) + reg.select_kslice( k , k ) + self.kw.assign( k , mask = reg ) + self.kw[ k * self.grid.getNX() * self.grid.getNY() + 7] = 177 + + + + def test_fault_block(self): + grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) + kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT ) + kw.assign( 0 ) + for j in range(1,4): + for i in range(1,4): + g = i + j*grid.getNX() + kw[g] = 1 + + layer = FaultBlockLayer( grid , 0 ) + layer.scanKeyword( kw ) + block = layer[1] + + self.assertEqual( (2.50 , 2.50) , block.getCentroid() ) + self.assertEqual( len(block) , 9) + self.assertEqual( layer , block.getParentLayer() ) + + def test_get_ijk(self): + with TestAreaContext("python/fault_block_layer/neighbour") as work_area: + with open("kw.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 0 0\n") + fileH.write("1 2 2 0 3\n") + fileH.write("4 2 2 3 3\n") + fileH.write("4 4 4 0 0\n") + fileH.write("4 4 4 0 5\n") + fileH.write("/\n") + with cwrap.open("kw.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + + grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + layer.loadKeyword( kw ) + + block = layer[0,0] + self.assertEqual( block.getBlockID() , 1 ) + + block = layer[2,2] + self.assertEqual( block.getBlockID() , 2 ) + + with self.assertRaises(ValueError): + layer[3,3] + + with self.assertRaises(IndexError): + layer[5,5] + + + + def test_neighbours(self): + + with TestAreaContext("python/fault_block_layer/neighbour") as work_area: + with open("kw.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 0 0\n") + fileH.write("1 2 2 0 3\n") + fileH.write("4 2 2 3 3\n") + fileH.write("4 4 4 0 0\n") + fileH.write("4 4 4 0 5\n") + fileH.write("/\n") + + with cwrap.open("kw.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + + grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + + layer.loadKeyword( kw ) + block1 = layer.getBlock( 1 ) + block2 = layer.getBlock( 2 ) + block3 = layer.getBlock( 3 ) + block4 = layer.getBlock( 4 ) + block5 = layer.getBlock( 5 ) + self.assertEqual( block1.getParentLayer() , layer ) + + #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {} + + neighbours = block1.getNeighbours() + self.assertEqual( len(neighbours) , 2) + self.assertTrue( block2 in neighbours ) + self.assertTrue( block4 in neighbours ) + + neighbours = block2.getNeighbours() + self.assertEqual( len(neighbours) , 3) + self.assertTrue( block1 in neighbours ) + self.assertTrue( block3 in neighbours ) + self.assertTrue( block4 in neighbours ) + + neighbours = block3.getNeighbours() + self.assertEqual( len(neighbours) , 1) + self.assertTrue( block2 in neighbours ) + + neighbours = block4.getNeighbours() + self.assertEqual( len(neighbours) , 2) + self.assertTrue( block1 in neighbours ) + self.assertTrue( block2 in neighbours ) + + neighbours = block5.getNeighbours() + self.assertEqual( len(neighbours) , 0) + + + + + def test_neighbours2(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/neighbours"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("/\n") + + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + + with open("faults.grdecl", "w") as f: + f.write("FAULTS\n") + f.write("\'FY\' 1 4 4 4 1 1 'Y' /\n") + f.write("\'FX\' 4 4 1 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + layer.loadKeyword( kw ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + b3 = layer.getBlock( 3 ) + + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + self.assertTrue( b3 in nb ) + + polylines1 = CPolylineCollection() + p1 = polylines1.createPolyline(name="P1") + p1.addPoint(4,0) + p1.addPoint(4,4) + p1.addPoint(4,8) + nb = b1.getNeighbours( polylines = polylines1 ) + self.assertFalse( b2 in nb ) + self.assertTrue( b3 in nb ) + + + polylines2 = CPolylineCollection() + p1 = polylines2.createPolyline(name="P2") + p1.addPoint(0,4) + p1.addPoint(4,4) + nb = b1.getNeighbours( polylines = polylines2 ) + self.assertTrue( b2 in nb ) + self.assertFalse( b3 in nb ) + + + + layer.addFaultBarrier( faults["FY"] ) + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + self.assertFalse( b3 in nb ) + + layer.addFaultBarrier( faults["FX"] ) + nb = b1.getNeighbours() + self.assertEqual( len(nb) , 0 ) + + + def test_neighbours3(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/neighbours"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("/\n") + + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") + f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + layer.loadKeyword( kw ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + + layer.addFaultBarrier( faults["FX"] , link_segments = False) + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + + + + + + + + def test_fault_block_edge(self): + grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) + kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT ) + kw.assign( 0 ) + for j in range(1,4): + for i in range(1,4): + g = i + j*grid.getNX() + kw[g] = 1 + + layer = FaultBlockLayer( grid , 0 ) + #with self.assertRaises: + # layer.getEdgePolygon( ) + + + + def test_fault_block_layer(self): + with self.assertRaises(ValueError): + layer = FaultBlockLayer( self.grid , -1 ) + + with self.assertRaises(ValueError): + layer = FaultBlockLayer( self.grid , self.grid.getGlobalSize() ) + + layer = FaultBlockLayer( self.grid , 1 ) + self.assertEqual( 1 , layer.getK() ) + + kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) + with self.assertRaises(ValueError): + layer.scanKeyword( kw ) + + layer.scanKeyword( self.kw ) + self.assertEqual( 2 , len(layer) ) + + with self.assertRaises(TypeError): + ls = layer["JJ"] + + l = [] + for blk in layer: + l.append( blk ) + self.assertEqual( len(l) , 2 ) + + l0 = layer[0] + l1 = layer[1] + self.assertTrue( isinstance(l1 , FaultBlock )) + l0.getCentroid() + l1.getBlockID() + + with self.assertRaises(IndexError): + l2 = layer[2] + + + self.assertEqual( True , 1 in layer) + self.assertEqual( True , 2 in layer) + self.assertEqual( False , 77 in layer) + self.assertEqual( False , 177 in layer) + + l1 = layer.getBlock( 1 ) + self.assertTrue( isinstance(l1 , FaultBlock )) + + with self.assertRaises(KeyError): + l =layer.getBlock(66) + + with self.assertRaises(KeyError): + layer.deleteBlock(66) + + layer.deleteBlock(2) + self.assertEqual( 1 , len(layer)) + blk = layer[0] + self.assertEqual( blk.getBlockID() , 1 ) + + with self.assertRaises(KeyError): + layer.addBlock(1) + + blk2 = layer.addBlock(2) + self.assertEqual( len(layer) , 2 ) + + blk3 = layer.addBlock() + self.assertEqual( len(layer) , 3 ) + + + layer.addBlock(100) + layer.addBlock(101) + layer.addBlock(102) + layer.addBlock(103) + + layer.deleteBlock(2) + blk1 = layer.getBlock( 103 ) + blk2 = layer[-1] + self.assertEqual( blk1.getBlockID() , blk2.getBlockID() ) + + fault_block = layer[0] + fault_block.assignToRegion( 2 ) + self.assertEqual( [2] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 2 ) + self.assertEqual( [2] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 3 ) + self.assertEqual( [2,3] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 1 ) + self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 2 ) + self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) + + + def test_add_polyline_barrier1(self): + grid = EclGrid.createRectangular( (4,1,1) , (1,1,1) ) + layer = FaultBlockLayer( self.grid , 0 ) + polyline = Polyline( init_points = [ (1.99 , 0.001) , (2.01 , 0.99)]) + + points = [((1,0) , (2,0))] + + geo_layer = layer.getGeoLayer() + for p1,p2 in points: + self.assertTrue(geo_layer.cellContact( p1 , p2 )) + + layer.addPolylineBarrier( polyline ) + for p1,p2 in points: + print(p1,p2) + self.assertFalse(geo_layer.cellContact( p1 , p2 )) + + + + def test_add_polyline_barrier2(self): + grid = EclGrid.createRectangular( (10,10,1) , (1,1,1) ) + layer = FaultBlockLayer( self.grid , 0 ) + polyline = Polyline( init_points = [ (0.1 , 0.9) , (8.9,0.9) , (8.9,8.9) ]) + + points = [((0,0) , (0,1)), + ((2,0) , (2,1)), + ((4,0) , (4,1)), + ((6,0) , (6,1)), + ((8,0) , (8,1)), + # + ((8,1) , (9,1)), + ((8,3) , (9,3)), + ((8,5) , (9,5)), + ((8,7) , (9,7))] + + geo_layer = layer.getGeoLayer() + for p1,p2 in points: + self.assertTrue(geo_layer.cellContact( p1 , p2 )) + + layer.addPolylineBarrier( polyline ) + for p1,p2 in points: + print(p1,p2) + self.assertFalse(geo_layer.cellContact( p1 , p2 )) + + + + + + + def test_fault_block_layer_export(self): + layer = FaultBlockLayer( self.grid , 1 ) + kw1 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() + 1 , EclDataType.ECL_INT ) + with self.assertRaises(ValueError): + layer.exportKeyword( kw1 ) + + kw2 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) + with self.assertRaises(TypeError): + layer.exportKeyword(kw2) + + + def test_internal_blocks(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/internal_blocks"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 4 4 1 2 5 5 2 \n") + fileH.write("1 4 4 1 2 5 5 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 3 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("/\n") + + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + + with open("faults.grdecl", "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") + f.write("\'FX\' 5 5 4 4 1 1 'Y' /\n") + f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + + layer.loadKeyword( kw ) + layer.addFaultBarrier( faults["FX"] ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + b3 = layer.getBlock( 3 ) + b4 = layer.getBlock( 4 ) + b5 = layer.getBlock( 5 ) + + + nb = b1.getNeighbours() + for b in nb: + print('Block:%d' % b.getBlockID()) + + self.assertTrue( len(nb) == 2 ) + self.assertTrue( b3 in nb ) + self.assertTrue( b4 in nb ) + + nb = b2.getNeighbours() + self.assertTrue( len(nb) == 1 ) + self.assertTrue( b5 in nb ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py new file mode 100644 index 0000000000..4b72f27be6 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.grid.faults import FaultBlock, FaultBlockLayer + +from cwrap import open as copen + + +@statoil_test() +class FaultBlockTest(EclTest): + def setUp(self): + self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID")) + fileH = copen( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) + self.kw = EclKW.read_grdecl( fileH , "FAULTBLK" , ecl_type = EclDataType.ECL_INT ) + + + + def test_load(self): + for k in range(self.grid.getNZ()): + faultBlocks = FaultBlockLayer(self.grid , k) + faultBlocks.scanKeyword( self.kw ) + for block in faultBlocks: + centroid = block.getCentroid() + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py new file mode 100644 index 0000000000..5a65e9a0b1 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py @@ -0,0 +1,798 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from unittest import skipIf +import time +from ecl import util + +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment,FaultBlockLayer +from ecl.util.test import TestAreaContext +from ecl.util.geometry import Polyline , CPolyline +from tests import EclTest + +class FaultTest(EclTest): + @classmethod + def setUpClass(cls): + cls.grid = EclGrid.createRectangular( (151,100,50) , (1,1,1)) + + def setUp(self): + self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") + self.faults2 = self.createTestPath("local/ECLIPSE/FAULTS/fault2.grdecl") + + + def test_PolylineIJ(self): + nx = 10 + ny = 10 + nz = 10 + grid = EclGrid.createRectangular( (nx,ny,nz) , (0.1,0.1,0.1)) + f = Fault(grid , "F") + f.addRecord(0 , 1 , 0 , 0 , 0,0 , "Y-") + f.addRecord(2 , 2 , 0 , 1 , 0,0 , "X-") + f.addRecord(2 , 2 , 1 , 1 , 0,0 , "Y") + + pl = f.getIJPolyline( 0 ) + self.assertEqual(pl , [(0,0) , (2,0) , (2,2) , (3,2)]) + + + def test_empty_collection(self): + faults = FaultCollection() + self.assertEqual(0 , len(faults)) + + self.assertFalse( faults.hasFault("FX") ) + + with self.assertRaises(TypeError): + f = faults[ [] ] + + with self.assertRaises(KeyError): + f = faults["FX"] + + with self.assertRaises(IndexError): + f = faults[0] + + self.assertFalse( "NAME" in faults ) + + def test_collection_invalid_arg(self): + with self.assertRaises(ValueError): + faults = FaultCollection(self.faults1) + + with self.assertRaises(ValueError): + faults = FaultCollection(self.faults1 , self.faults2) + + + + def test_splitLine(self): + faults = FaultCollection(self.grid) + with self.assertRaises(ValueError): + # Not slash terminated + t = faults.splitLine("'F1' 149 149 29 29 1 43 'Y'") + + with self.assertRaises(ValueError): + # Not integer + t = faults.splitLine("'F1' 149 149 29 29 1 43X 'Y' /") + + with self.assertRaises(ValueError): + # Missing item + t = faults.splitLine("'F1' 149 29 29 1 43 'Y' /") + + with self.assertRaises(ValueError): + # Quote fuckup + t = faults.splitLine("'F1 149 149 29 29 1 43 'X' /") + + + def test_empty_fault( self ): + f = Fault(self.grid , "NAME") + self.assertEqual("NAME" , f.getName()) + + with self.assertRaises(Exception): + g = f["Key"] + + + def test_empty_faultLine(self): + fl = FaultLine(self.grid , 10) + self.assertEqual( 10 , fl.getK()) + self.assertEqual( 0 , len(fl) ) + + with self.assertRaises(TypeError): + f = fl[ "Test" ] + + with self.assertRaises(IndexError): + f = fl[0] + + + + def test_faultLine_center(self): + nx = 10 + ny = 10 + nz = 2 + grid = EclGrid.createRectangular( (nx,ny,nz) , (0.1,0.1,0.1)) + fl = FaultLine(grid , 0) + C1 = (nx + 1) * 5 + 3 + C2 = C1 + 2 + C3 = C2 + 2 + + s1 = FaultSegment( C1 , C2 ) + s2 = FaultSegment( C2 , C3 ) + + fl.tryAppend( s1 ) + fl.tryAppend( s2 ) + + self.assertEqual( len(fl) , 2 ) + self.assertEqual( fl.center() , (0.50 , 0.50) ) + + + + def test_faultLine(self): + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(0 , 10) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + S3 = FaultSegment(20 , 30) + fl.tryAppend( S3 ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(0 , 10) + S2 = FaultSegment(20 , 10) + fl.tryAppend( S1 ) + self.assertTrue( fl.tryAppend( S2 ) ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(20 , 10) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + S3 = FaultSegment(40 , 30) + self.assertTrue( fl.tryAppend(S3) == False ) + self.assertEqual( len(fl) , 2 ) + + pl = fl.getPolyline( ) + self.assertIsInstance( pl , CPolyline ) + self.assertEqual( len(pl) , len(fl) + 1 ) + + S3 = FaultSegment(20 , 30) + fl.tryAppend( S3 ) + pl = fl.getPolyline( ) + self.assertIsInstance( pl , CPolyline ) + self.assertEqual( len(pl) , len(fl) + 1 ) + + + + + def test_load(self): + faults = FaultCollection(self.grid , self.faults1) + self.assertEqual( 3 , len(faults)) + faults.load( self.grid , self.faults2 ) + self.assertEqual( 7 , len(faults)) + fault1 = faults["F1"] + layer8 = fault1[8] + self.assertEqual( len(layer8) , 1 ) + + with self.assertRaises(IOError): + faults.load(self.grid , "No/this/does/not/exist") + + + def test_connect_faults(self): + grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + + for other_fault in [fault2 , fault3,fault4]: + with self.assertRaises(ValueError): + fault1.extendToFault( other_fault ,0) + + with self.assertRaises(ValueError): + fault2.extendToFault( fault3 , 0) + + for other_fault in [fault1 , fault2,fault4]: + with self.assertRaises(ValueError): + fault3.extendToFault( other_fault ,0 ) + + for other_fault in [fault1 , fault2,fault3]: + with self.assertRaises(ValueError): + fault4.extendToFault( other_fault , 0) + + ext21 = fault2.extendToFault( fault1 , 0) + self.assertEqual(len(ext21) , 2) + p0 = ext21[0] + p1 = ext21[1] + self.assertEqual(p0 , (5 , 16)) + self.assertEqual(p1 , (2 , 16)) + + + ext24 = fault2.extendToFault( fault4,0 ) + self.assertEqual(len(ext24) , 2) + p0 = ext24[0] + p1 = ext24[1] + self.assertEqual(p0 , (11 , 16)) + self.assertEqual(p1 , (21 , 16)) + + + def test_intersect_intRays(self): + p1 = (0,0) + dir1 = (1,0) + p2 = (0,0) + dir2 = (0,1) + + line = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual( line , [] ) + + # Opposite direction + p3 = (-1,0) + dir3 = (-1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p3,dir3)) + + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p3,dir3),(p1,dir1)) + + # Parallell with offset + p4 = (0,1) + dir4 = (1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p4,dir4)) + + p5 = (0,1) + dir5 = (-1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p5,dir5)) + + p6 = (1,1) + dir6 = (1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p6,dir6)) + + p2 = (-1,0) + dir2 = (-1,0) + join = Fault.intersectFaultRays(( p2,dir1),(p1,dir2)) + self.assertEqual( join , [p2 , p1]) + + join = Fault.intersectFaultRays(( p1,dir3),(p3,dir1)) + self.assertEqual( join , [p1 , p3]) + + p2 = (1,0) + dir2 = (1,0) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2)) + self.assertEqual( join , [p1 , p2]) + + # Orthogonal + p2 = (1,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (0,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,0) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,1) + dir2 = (0,-1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (3,-1) + dir2 = (0,-1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (1,-1) + dir2 = (0,1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , (1,0) , p2]) + + p2 = (1,1) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , (1,0) , p2]) + + p2 = (0,3) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , p2]) + + p2 = (3,0) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , p2]) + + + def test_join_faults(self): + grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + rays = fault1.getEndRays(0) + self.assertEqual( rays[0] , [(2,10) , (0,-1)]) + self.assertEqual( rays[1] , [(2,100) , (0,1)]) + + extra = Fault.joinFaults( fault1 , fault3 , 0) + self.assertEqual( extra , [(2,10) , (2,6) , (5,6)] ) + + + def test_contact(self): + grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ----------------------+-- Fault2 + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 30 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(2 , 10 , 9 , 9 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + #self.assertFalse( fault1.intersectsFault(fault2 , 0) ) + #self.assertFalse( fault2.intersectsFault(fault1 , 0) ) + + #self.assertTrue( fault2.intersectsFault(fault4 , 0) ) + #self.assertTrue( fault4.intersectsFault(fault2 , 0) ) + + self.assertTrue( fault1.intersectsFault(fault1 , 0) ) + #self.assertTrue( fault3.intersectsFault(fault3 , 0) ) + + + + def test_iter(self): + faults = FaultCollection(self.grid , self.faults1 , self.faults2) + self.assertEqual( 7 , len(faults)) + c = 0 + for f in faults: + c += 1 + self.assertEqual( c , len(faults)) + + for f in ["F1","F2","F3" ,"F4"]: + self.assertTrue( f in faults ) + + self.assertFalse("FX" in faults ) + + + + def test_fault(self): + f = Fault(self.grid , "NAME") + + with self.assertRaises(ValueError): + # Invalid face + f.addRecord( 10 , 10 , 11 , 11 , 1 , 43 , "F") + + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( -1 , 10 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10000 , 10 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") + + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates/face combination + f.addRecord( 10 , 11 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates/face combination + f.addRecord( 10 , 11 , 11 , 12 , 1 , 43 , "Y") + + f.addRecord(10 , 10 , 0 , 10 , 1 , 10 , "X") + + + def test_segment(self ): + s0 = FaultSegment(0 , 10) + self.assertEqual(s0.getC1() , 0 ) + self.assertEqual(s0.getC2() , 10 ) + + s0.swap() + self.assertEqual(s0.getC1() , 10 ) + self.assertEqual(s0.getC2() , 0 ) + + + + + def test_fault_line(self ): + faults = FaultCollection(self.grid , self.faults1 , self.faults2) + for fault in faults: + for layer in fault: + for fl in layer: + fl.verify() + + + def test_fault_line_order(self): + nx = 120 + ny = 60 + nz = 43 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F\' 105 107 50 50 1 43 \'Y\' / +\'F\' 108 108 50 50 1 43 \'X\' / +\'F\' 108 108 50 50 22 43 \'Y\' / +\'F\' 109 109 49 49 1 43 \'Y\' / +\'F\' 110 110 49 49 1 43 \'X\' / +\'F\' 111 111 48 48 1 43 \'Y\' / +/ +""") + faults = FaultCollection( grid , "faults.grdecl" ) + + fault = faults["F"] + layer = fault[29] + self.assertEqual(len(layer) , 2) + + line1 = layer[0] + line2 = layer[1] + self.assertEqual(len(line1) , 4) + self.assertEqual(len(line2) , 2) + + seg0 = line1[0] + seg1 = line1[1] + seg2 = line1[2] + seg3 = line1[3] + self.assertEqual( seg0.getCorners() , (50 * (nx + 1) + 104 , 50 * (nx + 1) + 107)) + self.assertEqual( seg1.getCorners() , (50 * (nx + 1) + 107 , 50 * (nx + 1) + 108)) + self.assertEqual( seg2.getCorners() , (50 * (nx + 1) + 108 , 49 * (nx + 1) + 108)) + self.assertEqual( seg3.getCorners() , (49 * (nx + 1) + 108 , 49 * (nx + 1) + 109)) + + + + + + def test_neighbour_cells(self): + nx = 10 + ny = 8 + nz = 7 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") + faults = FaultCollection( grid , faults_file ) + + fault = faults["FY"] + self.assertEqual(len(fault),1) + fault_layer = fault[0] + + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(0, nx) , (1,nx + 1), (2,nx+2) , (3,nx + 3) , (4,nx+4)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fl2 = fault_layer[1] + nb_cells2 = fl2.getNeighborCells() + true_nb_cells2 = [(6, nx+6) , (7,nx + 7), (8 , nx+8) , (9,nx + 9)] + self.assertListEqual( nb_cells2 , true_nb_cells2 ) + + nb_cells = fault_layer.getNeighborCells() + self.assertListEqual( nb_cells , true_nb_cells1 + true_nb_cells2) + + + fault = faults["FY0"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(-1,0) , (-1,1), (-1,2)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + fault = faults["FYNY"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(nx * (ny - 1) , -1), (nx * (ny - 1) + 1 , -1), (nx * (ny - 1) + 2, -1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fault = faults["FX"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(0,1) , (nx , nx+1) , (2*nx , 2*nx + 1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + fault = faults["FX0"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(-1 , 0) , (-1 , nx) , (-1 , 2*nx)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fault = faults["FXNX"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(nx -1 , -1) , (2*nx -1 , -1) , (3*nx - 1 , -1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + def test_polyline_intersection(self): + grid = EclGrid.createRectangular( (100,100,10) , (0.25 , 0.25 , 1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # (5 , 2.50) + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + + polyline = Polyline( init_points = [(4 , 4) , (8,4)]) + self.assertTrue( fault4.intersectsPolyline( polyline , 0)) + + cpolyline = CPolyline( init_points = [(4 , 4) , (8,4)]) + self.assertTrue( fault4.intersectsPolyline( cpolyline , 0)) + + polyline = Polyline( init_points = [(8 , 4) , (16,4)]) + self.assertFalse( fault4.intersectsPolyline( polyline , 0)) + + cpolyline = CPolyline( init_points = [(8 , 4) , (16,4)]) + self.assertFalse( fault4.intersectsPolyline( cpolyline , 0)) + + + def test_num_linesegment(self): + nx = 10 + ny = 10 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F1\' 1 4 2 2 1 1 \'Y\' / +\'F1\' 6 8 2 2 1 1 \'Y\' / +\'F2\' 1 8 2 2 1 1 \'Y\' / +/ +""") + faults = FaultCollection( grid , "faults.grdecl" ) + + f1 = faults["F1"] + f2 = faults["F2"] + self.assertEqual( 2 , f1.numLines(0)) + self.assertEqual( 1 , f2.numLines(0)) + + + def test_extend_to_polyline(self): + grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1)) + + # o o o o + # + # o---o---o---o + # + # o===+ o o + # | + # o o o o + + fault1 = Fault(grid , "Fault") + + fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "X-") + fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "Y") + + polyline = CPolyline( init_points = [(0,2) , (3,2)]) + points = fault1.extendToPolyline( polyline , 0 ) + self.assertEqual( points , [(1,1) , (2,2)]) + + end_join = fault1.endJoin( polyline , 0 ) + self.assertEqual( end_join, [(1,1) , (0,2)] ) + + polyline2 = CPolyline( init_points = [(0.8,2) , (0.8,0.8)]) + end_join = fault1.endJoin( polyline2 , 0 ) + self.assertIsNone( end_join ) + + + def test_extend_polyline_on(self): + grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1)) + + # o o o o + # + # o---o---o---o + # + # o===o===o===o + # + # o o o o + + fault1 = Fault(grid , "Fault") + fault1.addRecord(0 , 2 , 0 , 0 , 0 , 0 , "Y") + + polyline0 = CPolyline( init_points = [(0,2)]) + polyline1 = CPolyline( init_points = [(0,2) , (3,2)]) + polyline2 = CPolyline( init_points = [(1,3) , (1,2)]) + polyline3 = CPolyline( init_points = [(1,3) , (1,0)]) + + with self.assertRaises(ValueError): + fault1.extendPolylineOnto( polyline0 , 0 ) + + points = fault1.extendPolylineOnto( polyline1 , 0 ) + self.assertIsNone( points ) + + points = fault1.extendPolylineOnto( polyline2 , 0) + self.assertEqual( points , [(1,2) , (1,1)]) + + points = fault1.extendPolylineOnto( polyline3 , 0) + self.assertIsNone( points ) + + + def test_stepped(self): + grid = EclGrid.createRectangular( (6,1,4) , (1,1,1)) + f = Fault(grid , "F") + f.addRecord(4,4,0,0,0,1,"X") + f.addRecord(2,2,0,0,1,1,"Z") + f.addRecord(1,1,0,0,2,3,"X") + + block_kw = EclKW("FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT) + block_kw.assign(1) + block_kw[5] = 2 + block_kw[11] = 2 + block_kw[14:18] = 2 + block_kw[14:18] = 2 + block_kw[20:23] = 2 + + layer0 = FaultBlockLayer( grid , 0 ) + layer0.scanKeyword( block_kw ) + layer0.addFaultBarrier( f ) + self.assertTrue( layer0.cellContact((0,0) , (1,0))) + self.assertFalse( layer0.cellContact((4,0) , (5,0))) + + layer1 = FaultBlockLayer( grid , 1 ) + layer1.scanKeyword( block_kw ) + layer1.addFaultBarrier( f ) + self.assertTrue( layer1.cellContact((0,0) , (1,0))) + self.assertFalse( layer1.cellContact((4,0) , (5,0))) + + layer2 = FaultBlockLayer( grid , 2 ) + layer2.scanKeyword( block_kw ) + layer2.addFaultBarrier( f ) + self.assertTrue( layer2.cellContact((0,0) , (1,0))) + self.assertFalse( layer2.cellContact((1,0) , (2,0))) + + layer3 = FaultBlockLayer( grid , 3 ) + layer3.scanKeyword( block_kw ) + layer3.addFaultBarrier( f ) + self.assertTrue( layer3.cellContact((0,0) , (1,0))) + self.assertFalse( layer3.cellContact((1,0) , (2,0))) + + + + def test_connectWithPolyline(self): + grid = EclGrid.createRectangular( (4,4,1) , (1 , 1 , 1)) + + + # o o o o o + # + # o o o o o + # + # o---o---o---o---o + # + # o o o o o + # | + # o o o o o + + fault1 = Fault(grid , "Fault1") + fault1.addRecord(0 , 3 , 1 , 1 , 0 , 0 , "Y") + + fault2 = Fault(grid , "Fault2") + fault2.addRecord(1 , 1 , 0 , 0 , 0 , 0 , "X") + + fault3 = Fault(grid , "Fault3") + fault3.addRecord(1 , 1 , 0 , 2 , 0 , 0 , "X") + + self.assertIsNone( fault3.connect( fault1 , 0 )) + + + intersect = fault2.connect( fault1 , 0 ) + self.assertEqual( len(intersect) , 2 ) + p1 = intersect[0] + p2 = intersect[1] + + self.assertEqual( p1 , (2,1)) + self.assertEqual( p2 , (2,2)) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py new file mode 100644 index 0000000000..d01c981463 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'test_ecl_cell_containment.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.grid import EclGrid +from ecl.util.test import TestAreaContext +from tests import EclTest + +class FKTest(EclTest): + + def test_cell_containment(self): + + grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID" + well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt" + + for i in range(1, 8): + grid_file = self.createTestPath(grid_location % i) + well_file = self.createTestPath(well_location % i) + + grid = EclGrid(grid_file) + + # Load well data + with open(well_file, "r") as f: + lines = [line.split() for line in f.readlines()] + + points = [map(float, line[:3:]) for line in lines] + exp_cells = [tuple(map(int, line[3::])) for line in lines] + + msg = "Expected point %s to be in cell %s, was in %s." + for point, exp_cell in zip(points, exp_cells): + reported_cell = grid.find_cell(*point) + self.assertEqual( + exp_cell, + reported_cell, + msg % (str(point), str(exp_cell), str(reported_cell)) + ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py new file mode 100644 index 0000000000..54a4b9fabe --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os +import cwrap +from random import randint +from ecl import EclDataType +from ecl.eclfile import FortIO, EclKW , openFortIO, EclFile +from ecl.util.test import TestAreaContext +from tests import EclTest + + + + +class FortIOTest(EclTest): + + + + + def test_open_write(self): + with TestAreaContext("python/fortio/write"): + f = FortIO("newfile", FortIO.WRITE_MODE) + self.assertTrue(os.path.exists("newfile")) + + def test_noex(self): + with self.assertRaises(IOError): + f = FortIO("odes_not_exist", FortIO.READ_MODE) + + def test_kw(self): + kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) + kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) + + kw1[0] = 99 + kw1[1] = 77 + kw2[0] = 113 + kw2[1] = 335 + + with TestAreaContext("python/fortio/write-kw"): + f = FortIO("test", FortIO.WRITE_MODE, fmt_file=False) + kw1.fwrite(f) + + f = FortIO("test", FortIO.APPEND_MODE) + kw2.fwrite(f) + + f = FortIO("test", fmt_file=False) + k1 = EclKW.fread(f) + k2 = EclKW.fread(f) + + self.assertTrue(k1.equal(kw1)) + self.assertTrue(k2.equal(kw2)) + + + def test_truncate(self): + kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) + kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) + + kw1[0] = 99 + kw1[1] = 77 + kw2[0] = 113 + kw2[1] = 335 + + with TestAreaContext("python/fortio/ftruncate") as t: + with openFortIO("file" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite(f) + pos1 = f.getPosition( ) + kw2.fwrite(f) + + t.sync( ) + # Truncate file in read mode; should fail hard. + with openFortIO("file") as f: + with self.assertRaises(IOError): + f.truncate( ) + + + with openFortIO("file" , mode = FortIO.READ_AND_WRITE_MODE) as f: + f.seek( pos1 ) + f.truncate( ) + + + f = EclFile("file") + self.assertEqual( len(f) , 1) + kw1_ = f[0] + self.assertEqual( kw1 , kw1_) + + + + def test_fortio_creation(self): + with TestAreaContext("python/fortio/create"): + w = FortIO("test", FortIO.WRITE_MODE) + rw = FortIO("test", FortIO.READ_AND_WRITE_MODE) + r = FortIO("test", FortIO.READ_MODE) + a = FortIO("test", FortIO.APPEND_MODE) + + w.close() + w.close() # should not fail + + + + + + def test_context(self): + with TestAreaContext("python/fortio/context") as t: + kw1 = EclKW("KW" , 2456 , EclDataType.ECL_FLOAT) + for i in range(len(kw1)): + kw1[i] = randint(0,1000) + + with openFortIO("file" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + self.assertEqual( f.filename() , "file") + + t.sync( ) + + with openFortIO("file") as f: + kw2 = EclKW.fread( f ) + + self.assertTrue( kw1 == kw2 ) + + + def test_is_fortran_file(self): + with TestAreaContext("python/fortio/guess"): + kw1 = EclKW("KW" , 12345 , EclDataType.ECL_FLOAT) + with openFortIO("fortran_file" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + + with cwrap.open("text_file" , "w") as f: + kw1.write_grdecl( f ) + + self.assertTrue( FortIO.isFortranFile( "fortran_file" )) + self.assertFalse( FortIO.isFortranFile( "text_file" )) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py new file mode 100644 index 0000000000..f991e88704 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py @@ -0,0 +1,148 @@ +import datetime +from ecl import EclDataType +from ecl.eclfile import EclKW, openFortIO, FortIO, EclFile +from ecl.grid import EclGrid +from ecl.gravimetry import EclSubsidence + +from ecl.util.test import TestAreaContext +from tests import EclTest + +import numpy as np + + +def create_init(grid, case): + poro = EclKW("PORO", grid.getNumActive(), EclDataType.ECL_FLOAT) + porv = poro.copy() + porv.setName("PORV") + for g in range(grid.getGlobalSize()): + porv[g] *= grid.cell_volume(global_index=g) + + with openFortIO("%s.INIT" % case, mode=FortIO.WRITE_MODE) as f: + poro.fwrite(f) + porv.fwrite(f) + + +def create_restart(grid, case, p1, p2=None): + with openFortIO("%s.UNRST" % case, mode=FortIO.WRITE_MODE) as f: + seq_hdr = EclKW("SEQNUM", 1, EclDataType.ECL_FLOAT) + seq_hdr[0] = 10 + p = EclKW("PRESSURE", grid.getNumActive(), EclDataType.ECL_FLOAT) + for i in range(len(p1)): + p[i] = p1[i] + + header = EclKW("INTEHEAD", 67, EclDataType.ECL_INT) + header[64] = 1 + header[65] = 1 + header[66] = 2000 + + seq_hdr.fwrite(f) + header.fwrite(f) + p.fwrite(f) + + if p2: + seq_hdr[0] = 20 + header[66] = 2010 + for i in range(len(p2)): + p[i] = p2[i] + + seq_hdr.fwrite(f) + header.fwrite(f) + p.fwrite(f) + + +class GeertsmaTest(EclTest): + + @staticmethod + def test_geertsma_kernel(): + grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + with TestAreaContext("Subsidence"): + p1 = [1] + create_restart(grid, "TEST", p1) + create_init(grid, "TEST") + + init = EclFile("TEST.INIT") + restart_file = EclFile("TEST.UNRST") + + restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) + + subsidence = EclSubsidence(grid, init) + subsidence.add_survey_PRESSURE("S1", restart_view1) + + youngs_modulus = 5E8 + poisson_ratio = 0.3 + seabed = 0 + above = 100 + topres = 2000 + receiver = (1000, 1000, 0) + + dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz, 3.944214576168326e-09) + + receiver = (1000, 1000, topres - seabed - above) + + dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz, 5.8160298201497136e-08) + + @staticmethod + def test_geertsma_kernel_2_source_points_2_vintages(): + grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) + + with TestAreaContext("Subsidence"): + p1 = [1, 10] + p2 = [10, 20] + create_restart(grid, "TEST", p1, p2) + create_init(grid, "TEST") + + init = EclFile("TEST.INIT") + restart_file = EclFile("TEST.UNRST") + + restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) + restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1)) + + subsidence = EclSubsidence(grid, init) + subsidence.add_survey_PRESSURE("S1", restart_view1) + subsidence.add_survey_PRESSURE("S2", restart_view2) + + youngs_modulus = 5E8 + poisson_ratio = 0.3 + seabed = 0 + receiver = (1000, 1000, 0) + + dz1 = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz1, 8.65322541521704e-07) + + dz2 = subsidence.evalGeertsma("S2", None, receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz2, 2.275556615015282e-06) + + np.testing.assert_almost_equal(dz1-dz2, -1.4102340734935779e-06) + + dz = subsidence.evalGeertsma("S1", "S2", receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz, dz1-dz2) + + @staticmethod + def test_geertsma_kernel_seabed(): + grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + with TestAreaContext("Subsidence"): + p1 = [1] + create_restart(grid, "TEST", p1) + create_init(grid, "TEST") + + init = EclFile("TEST.INIT") + restart_file = EclFile("TEST.UNRST") + + restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) + + subsidence = EclSubsidence(grid, init) + subsidence.add_survey_PRESSURE("S1", restart_view1) + + youngs_modulus = 5E8 + poisson_ratio = 0.3 + seabed = 300 + above = 100 + topres = 2000 + receiver = (1000, 1000, topres - seabed - above) + + dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) + np.testing.assert_almost_equal(dz, 5.819790154474284e-08) + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grav.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grav.py new file mode 100644 index 0000000000..cec520ecee --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grav.py @@ -0,0 +1,29 @@ +import time +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, openFortIO, FortIO +from ecl.grid import EclGrid +from ecl.gravimetry import EclGrav +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class EclGravTest(EclTest): + + + def setUp(self): + self.grid = EclGrid.createRectangular( (10,10,10) , (1,1,1)) + + + def test_create(self): + # The init file created here only contains a PORO field. More + # properties must be added to this before it can be used for + # any usefull gravity calculations. + poro = EclKW( "PORO" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) + with TestAreaContext("grav_init"): + with openFortIO( "TEST.INIT" , mode = FortIO.WRITE_MODE ) as f: + poro.fwrite( f ) + self.init = EclFile( "TEST.INIT") + + grav = EclGrav( self.grid , self.init ) + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py new file mode 100644 index 0000000000..6063c109e0 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +from ecl.eclfile import EclKW, Ecl3DKW +from ecl.grid import EclGrid +from tests import EclTest, statoil_test + +from cwrap import open as copen + + +@statoil_test() +class GRDECLTest(EclTest): + def setUp(self): + self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") + self.file_list = [] + + def addFile(self, filename): + self.file_list.append(filename) + + def tearDown(self): + for f in self.file_list: + if os.path.exists(f): + os.unlink(f) + + + def test_Load( self ): + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + self.assertTrue(kw) + + grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) + kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX") + self.assertTrue( isinstance( kw , Ecl3DKW )) + + + + def test_reload( self ): + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + tmp_file1 = "/tmp/permx1.grdecl" + tmp_file2 = "/tmp/permx2.grdecl" + self.addFile(tmp_file1) + self.addFile(tmp_file2) + + fileH = copen(tmp_file1, "w") + kw.write_grdecl(fileH) + fileH.close() + + kw1 = EclKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") + + fileH = copen(tmp_file2, "w") + kw1.write_grdecl(fileH) + fileH.close() + + self.assertFilesAreEqual(tmp_file1, tmp_file2) + + + def test_fseek( self ): + file = copen(self.src_file, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + file.close() + + file = copen(self.src_file, "r") + kw1 = EclKW.read_grdecl(file, "PERMX") + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + file.close() + + + def test_fseek2(self): + test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") + # Test kw at the the very start + file = copen(test_src, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + + # Test commented out kw: + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + + # Test ignore not start of line: + self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + + # Test rewind + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + + # Test multiline comments + blanks + self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) + + + def test_fseek_dos(self): + test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl_dos") # File formatted with \r\n line endings. + # Test kw at the the very start + file = copen(test_src, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + + # Test commented out kw: + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + + # Test ignore not start of line: + self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + + # Test rewind + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + + # Test multiline comments + blanks + self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py new file mode 100644 index 0000000000..6c4be05924 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py @@ -0,0 +1,592 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os.path +import six +from unittest import skipIf +import time +import itertools +from numpy import linspace + +from ecl.util.util import IntVector +from ecl import EclDataType, EclUnitTypeEnum +from ecl.eclfile import EclKW, EclFile +from ecl.grid import EclGrid +from ecl.grid import EclGridGenerator as GridGen +from ecl.grid.faults import Layer , FaultCollection +from ecl.util.test import TestAreaContext +from tests import EclTest + +# This dict is used to verify that corners are mapped to the correct +# cell with respect to containment. +CORNER_HOME = { + (0, 0, 0) : 0, (0, 0, 1) : 9, (0, 0, 2) : 18, (0, 0, 3) : 18, + (0, 1, 0) : 3, (0, 1, 1) : 12, (0, 1, 2) : 21, (0, 1, 3) : 21, + (0, 2, 0) : 6, (0, 2, 1) : 15, (0, 2, 2) : 24, (0, 2, 3) : 24, + (0, 3, 0) : 6, (0, 3, 1) : 15, (0, 3, 2) : 24, (0, 3, 3) : 24, + (1, 0, 0) : 1, (1, 0, 1) : 10, (1, 0, 2) : 19, (1, 0, 3) : 19, + (1, 1, 0) : 4, (1, 1, 1) : 13, (1, 1, 2) : 22, (1, 1, 3) : 22, + (1, 2, 0) : 7, (1, 2, 1) : 16, (1, 2, 2) : 25, (1, 2, 3) : 25, + (1, 3, 0) : 7, (1, 3, 1) : 16, (1, 3, 2) : 25, (1, 3, 3) : 25, + (2, 0, 0) : 2, (2, 0, 1) : 11, (2, 0, 2) : 20, (2, 0, 3) : 20, + (2, 1, 0) : 5, (2, 1, 1) : 14, (2, 1, 2) : 23, (2, 1, 3) : 23, + (2, 2, 0) : 8, (2, 2, 1) : 17, (2, 2, 2) : 26, (2, 2, 3) : 26, + (2, 3, 0) : 8, (2, 3, 1) : 17, (2, 3, 2) : 26, (2, 3, 3) : 26, + (3, 0, 0) : 2, (3, 0, 1) : 11, (3, 0, 2) : 20, (3, 0, 3) : 20, + (3, 1, 0) : 5, (3, 1, 1) : 14, (3, 1, 2) : 23, (3, 1, 3) : 23, + (3, 2, 0) : 8, (3, 2, 1) : 17, (3, 2, 2) : 26, (3, 2, 3) : 26, + (3, 3, 0) : 8, (3, 3, 1) : 17, (3, 3, 2) : 26, (3, 3, 3) : 26 +} + +def createVolumeTestGridBase(dim, dV, offset=1): + return [ + GridGen.create_grid(dim, dV, offset=0), + GridGen.create_grid(dim, dV, offset=offset), + GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True), + GridGen.create_grid(dim, dV, offset=offset, concave=True), + GridGen.create_grid(dim, dV, offset=offset, irregular=True), + GridGen.create_grid(dim, dV, offset=offset, concave=True, irregular=True), + GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True, concave=True), + GridGen.create_grid(dim, dV, offset=0, faults=True), + GridGen.create_grid(dim, dV, offset=offset, faults=True), + GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=2), + GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=0.5), + GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), translation=(50,50,0)), + GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), rotate=True), + GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), misalign=True), + GridGen.create_grid(dim, dV, offset=offset, escape_origo_shift=(100, 100, 0), + irregular_offset=True, concave=True, irregular=True, + scale=1.5, translation=(5,5,0), rotate=True, + misalign=True) + ] + +def createContainmentTestBase(): + return [ + (3, GridGen.create_grid((6,6,6), (1,1,1), offset=1)), + (10, GridGen.create_grid((3,3,3), (1,1,1), offset=1, concave=True)), + (4, GridGen.create_grid((10,10,1), (1,1,1), offset=0., misalign=True)), + (3, + GridGen.create_grid((6,6,6), (1,1,1), offset=0., + escape_origo_shift=(100, 100, 0), + irregular_offset=True, concave=True, irregular=True, + scale=1.5, translation=(5,5,0), + misalign=True + ) + ) + ] + +def getMinMaxValue(grid): + corners = [ + grid.getCellCorner(i, cell) + for i in range(8) + for cell in range(grid.getGlobalSize()) + ] + + return [(min(values), max(values)) for values in zip(*corners)] + +def createWrapperGrid(grid): + """ + Creates a grid that occupies the same space as the given grid, + but that consists of a single cell. + """ + + x, y, z = grid.getNX()-1, grid.getNY()-1, grid.getNZ()-1 + corner_pos = [ + (0, 0, 0), (x, 0, 0), (0, y, 0), (x, y, 0), + (0, 0, z), (x, 0, z), (0, y, z), (x, y, z) + ] + + corners = [ + grid.getCellCorner(i, ijk=pos) + for i, pos in enumerate(corner_pos) + ] + + return GridGen.create_single_cell_grid(corners) + +def average(points): + p = six.functools.reduce( + lambda a, b: (a[0] + b[0], a[1] + b[1], a[2] + b[2]), points) + return [elem/float(len(points)) for elem in p] + +# This test class should only have test cases which do not require +# external test data. Tests involving Statoil test data are in the +# test_grid_statoil module. +class GridTest(EclTest): + + def test_oom_grid(self): + nx = 2000 + ny = 2000 + nz = 2000 + + with self.assertRaises(MemoryError): + grid = GridGen.createRectangular( (nx,ny,nz), (1,1,1)) + + + + def test_posXYEdge(self): + nx = 10 + ny = 11 + grid = GridGen.createRectangular( (nx,ny,1) , (1,1,1) ) + self.assertEqual( grid.findCellCornerXY(0,0,0) , 0 ) + self.assertEqual( grid.findCellCornerXY(nx,0,0) , nx) + self.assertEqual( grid.findCellCornerXY(0 , ny , 0) , (nx + 1 ) * ny ) + self.assertEqual( grid.findCellCornerXY(nx,ny,0) , (nx + 1 ) * (ny + 1) - 1) + + self.assertEqual( grid.findCellCornerXY(0.25,0,0) , 0 ) + self.assertEqual( grid.findCellCornerXY(0,0.25,0) , 0 ) + + self.assertEqual( grid.findCellCornerXY(nx - 0.25,0,0) , nx ) + self.assertEqual( grid.findCellCornerXY(nx , 0.25,0) , nx ) + + self.assertEqual( grid.findCellCornerXY(0 , ny - 0.25, 0) , (nx + 1 ) * ny ) + self.assertEqual( grid.findCellCornerXY(0.25 , ny , 0) , (nx + 1 ) * ny ) + + self.assertEqual( grid.findCellCornerXY(nx -0.25 ,ny,0) , (nx + 1 ) * (ny + 1) - 1) + self.assertEqual( grid.findCellCornerXY(nx , ny - 0.25,0) , (nx + 1 ) * (ny + 1) - 1) + + + def test_dims(self): + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) + self.assertEqual( grid.getNX() , 10 ) + self.assertEqual( grid.getNY() , 20 ) + self.assertEqual( grid.getNZ() , 30 ) + self.assertEqual( grid.getGlobalSize() , 30*10*20 ) + + self.assertEqual( grid.getDims() , (10,20,30,6000) ) + + def test_create(self): + with self.assertRaises(ValueError): + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = [0,1,1,2]) + + with self.assertRaises(ValueError): + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = IntVector(initial_size = 10)) + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) # actnum=None -> all active + self.assertEqual( grid.getNumActive( ) , 30*20*10) + actnum = IntVector(default_value = 1 , initial_size = 6000) + actnum[0] = 0 + actnum[1] = 0 + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = actnum) + self.assertEqual( grid.getNumActive( ) , 30*20*10 - 2) + + def test_all_iters(self): + fk = self.createTestPath('local/ECLIPSE/faarikaal/faarikaal1.EGRID') + grid = EclGrid(fk) + cell = grid[3455] + self.assertEqual(3455, cell.global_index) + cell = grid[(4,1,82)] + self.assertEqual(3455, cell.global_index) + self.assertEqual(grid.cell(global_index=3455), + grid.cell(active_index=2000)) + self.assertEqual(grid.cell(global_index=3455), + grid.cell(i=4, j=1, k=82)) + + na = grid.get_num_active() + self.assertEqual(na, 4160) + cnt = 0 + for c in grid.cells(active=True): + cnt += 1 + self.assertTrue(c.active) + self.assertEqual(cnt, 4160) + + cnt = len([c for c in grid.cells()]) + self.assertEqual(cnt, len(grid)) + + + def test_repr_and_name(self): + grid = GridGen.createRectangular((2,2,2), (10,10,10), actnum=[0,0,0,0,1,1,1,1]) + pfx = 'EclGrid(' + rep = repr(grid) + self.assertEqual(pfx, rep[:len(pfx)]) + self.assertEqual(type(rep), type('')) + self.assertEqual(type(grid.getName()), type('')) + with TestAreaContext("python/ecl_grid/repr"): + grid.save_EGRID("CASE.EGRID") + g2 = EclGrid("CASE.EGRID") + r2 = repr(g2) + self.assertEqual(pfx, r2[:len(pfx)]) + self.assertEqual(type(r2), type('')) + self.assertEqual(type(g2.getName()), type('')) + + def test_node_pos(self): + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) + with self.assertRaises(IndexError): + grid.getNodePos(-1,0,0) + + with self.assertRaises(IndexError): + grid.getNodePos(11,0,0) + + p0 = grid.getNodePos(0,0,0) + self.assertEqual( p0 , (0,0,0)) + + p7 = grid.getNodePos(10,20,30) + self.assertEqual( p7 , (10,20,30)) + + + def test_truncated_file(self): + grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) + with TestAreaContext("python/ecl_grid/truncated"): + grid.save_EGRID( "TEST.EGRID") + + size = os.path.getsize( "TEST.EGRID") + with open("TEST.EGRID" , "r+") as f: + f.truncate( size / 2 ) + + with self.assertRaises(IOError): + EclGrid("TEST.EGRID") + + def test_posXY1(self): + nx = 4 + ny = 1 + nz = 1 + grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) + (i,j) = grid.findCellXY( 0.5 , 0.5, 0 ) + self.assertEqual(i , 0) + self.assertEqual(j , 0) + + (i,j) = grid.findCellXY( 3.5 , 0.5, 0 ) + self.assertEqual(i , 3) + self.assertEqual(j , 0) + + + def test_init_ACTNUM(self): + nx = 10 + ny = 23 + nz = 7 + grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) + actnum = grid.exportACTNUM() + + self.assertEqual( len(actnum) , nx*ny*nz ) + self.assertEqual( actnum[0] , 1 ) + self.assertEqual( actnum[nx*ny*nz - 1] , 1 ) + + actnum_kw = grid.exportACTNUMKw( ) + self.assertEqual(len(actnum_kw) , len(actnum)) + for a1,a2 in zip(actnum, actnum_kw): + self.assertEqual(a1, a2) + + + def test_posXY(self): + nx = 10 + ny = 23 + nz = 7 + grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) + with self.assertRaises(IndexError): + grid.findCellXY( 1 , 1, -1 ) + + with self.assertRaises(IndexError): + grid.findCellXY( 1 , 1, nz + 1 ) + + with self.assertRaises(ValueError): + grid.findCellXY(15 , 78 , 2) + + + i,j = grid.findCellXY( 1.5 , 1.5 , 2 ) + self.assertEqual(i , 1) + self.assertEqual(j , 1) + + + for i in range(nx): + for j in range(ny): + p = grid.findCellXY(i + 0.5 , j+ 0.5 , 0) + self.assertEqual( p[0] , i ) + self.assertEqual( p[1] , j ) + + c = grid.findCellCornerXY( 0.10 , 0.10 , 0 ) + self.assertEqual(c , 0) + + c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) + 1 ) + + c = grid.findCellCornerXY( 0.10 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) ) + + c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) + 1 ) + + c = grid.findCellCornerXY( 0.90 , 0.10 , 0 ) + self.assertEqual( c , 1 ) + + def test_compressed_copy(self): + nx = 10 + ny = 10 + nz = 10 + grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) + kw1 = EclKW("KW" , 1001 , EclDataType.ECL_INT ) + with self.assertRaises(ValueError): + cp = grid.compressedKWCopy( kw1 ) + + + def test_dxdydz(self): + nx = 10 + ny = 10 + nz = 10 + grid = GridGen.createRectangular( (nx,ny,nz) , (2,3,4) ) + + (dx,dy,dz) = grid.getCellDims( active_index = 0 ) + self.assertEqual( dx , 2 ) + self.assertEqual( dy , 3 ) + self.assertEqual( dz , 4 ) + + def test_numpy3D(self): + nx = 10 + ny = 7 + nz = 5 + grid = GridGen.createRectangular((nx,ny,nz) , (1,1,1)) + kw = EclKW( "SWAT" , nx*ny*nz , EclDataType.ECL_FLOAT ) + numpy_3d = grid.create3D( kw ) + + def test_len(self): + nx = 10 + ny = 11 + nz = 12 + actnum = EclKW( "ACTNUM" , nx*ny*nz , EclDataType.ECL_INT ) + actnum[0] = 1 + actnum[1] = 1 + actnum[2] = 1 + actnum[3] = 1 + + grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1), actnum = actnum) + self.assertEqual( len(grid) , nx*ny*nz ) + self.assertEqual( grid.getNumActive( ) , 4 ) + + def test_export(self): + dims = (3, 3, 3) + coord = GridGen.create_coord(dims, (1,1,1)) + zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) + + grid = EclGrid.create(dims, zcorn, coord, None) + + self.assertEqual(zcorn, grid.export_zcorn()) + self.assertEqual(coord, grid.export_coord()) + + def test_output_units(self): + n = 10 + a = 1 + grid = GridGen.createRectangular( (n,n,n), (a,a,a)) + + with TestAreaContext("python/ecl_grid/units"): + grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_FIELD_UNITS ) + f = EclFile("CASE.EGRID") + g = f["GRIDUNIT"][0] + self.assertEqual( g[0].strip( ) , "FEET" ) + g2 = EclGrid("CASE.EGRID") + self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 3.28084*3.28084*3.28084) + + + grid.save_EGRID( "CASE.EGRID" ) + f = EclFile("CASE.EGRID") + g = f["GRIDUNIT"][0] + self.assertEqual( g[0].strip( ) , "METRES" ) + + grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_LAB_UNITS) + f = EclFile("CASE.EGRID") + g = f["GRIDUNIT"][0] + self.assertEqual( g[0].strip() , "CM" ) + g2 = EclGrid("CASE.EGRID") + self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 100*100*100 ) + + def test_volume(self): + dim = (10,10,10) + dV = (2,2,2) + + grids = createVolumeTestGridBase(dim, dV) + for grid in grids: + tot_vol = createWrapperGrid(grid).cell_volume(0) + cell_volumes = [grid.cell_volume(i) for i in range(grid.getGlobalSize())] + self.assertTrue(min(cell_volumes) >= 0) + self.assertFloatEqual(sum(cell_volumes), tot_vol) + + def test_unique_containment(self): + test_base = createContainmentTestBase() + + for steps_per_unit, grid in test_base: + wgrid = createWrapperGrid(grid) + + (xmin, xmax), (ymin, ymax), (zmin, zmax) = getMinMaxValue(wgrid) + x_space = linspace(xmin-1, xmax+1, (xmax-xmin+2)*steps_per_unit+1) + y_space = linspace(ymin-1, ymax+1, (ymax-ymin+2)*steps_per_unit+1) + z_space = linspace(zmin-1, zmax+1, (zmax-zmin+2)*steps_per_unit+1) + + for x, y, z in itertools.product(x_space, y_space, z_space): + hits = [ + grid.cell_contains(x, y, z, i) + for i in range(grid.getGlobalSize()) + ].count(True) + + self.assertIn(hits, [0, 1]) + + expected = 1 if wgrid.cell_contains(x, y, z, 0) else 0 + self.assertEqual( + expected, + hits, + 'Expected %d for (%g,%g,%g), got %d' % (expected, x, y, z, hits) + ) + + def test_cell_corner_containment(self): + n = 4 + d = 10 + grid = GridGen.createRectangular( (n, n, n), (d, d, d)) + + for x, y, z in itertools.product(range(0, n*d+1, d), repeat=3): + self.assertEqual( + 1, + [grid.cell_contains(x, y, z, i) for i in range(n**3)].count(True) + ) + + def test_cell_corner_containment_compatability(self): + grid = GridGen.createRectangular( (3,3,3), (1,1,1) ) + + for x, y, z in itertools.product(range(4), repeat=3): + for i in range(27): + if grid.cell_contains(x, y, z, i): + self.assertEqual( + CORNER_HOME[(x,y,z)], + i + ) + + def test_cell_face_containment(self): + n = 4 + d = 10 + grid = GridGen.createRectangular( (n, n, n), (d, d, d)) + + for x, y, z in itertools.product(range(d//2, n*d, d), repeat=3): + for axis, direction in itertools.product(range(3), [-1, 1]): + p = [x, y, z] + p[axis] = p[axis] + direction*d/2 + self.assertEqual( + 1, + [grid.cell_contains(p[0], p[1], p[2], i) for i in range(n**3)].count(True) + ) + + # This test generates a cell that is concave on ALL 6 sides + def test_concave_cell_containment(self): + points = [ + (5, 5, 5), + (20, 10, 10), + (10, 20, 10), + (25, 25, 5), + (10, 10, 20), + (25, 5, 25), + (5, 25, 25), + (20, 20, 20) + ] + + grid = GridGen.create_single_cell_grid(points) + + assertPoint = lambda p : self.assertTrue( + grid.cell_contains(p[0], p[1], p[2], 0) + ) + + assertNotPoint = lambda p : self.assertFalse( + grid.cell_contains(p[0], p[1], p[2], 0) + ) + + # Cell center + assertPoint(average(points)); + + # "Side" center + assertNotPoint(average(points[0:4:])) + assertNotPoint(average(points[4:8:])) + assertNotPoint(average(points[1:8:2])) + assertNotPoint(average(points[0:8:2])) + assertNotPoint(average(points[0:8:4] + points[1:8:4])) + assertNotPoint(average(points[2:8:4] + points[3:8:4])) + + # Corners + for p in points: + assertPoint(p) + + # Edges + edges = ([(i, i+1) for i in range(0, 8, 2)] + + [(i, i+2) for i in [0, 1, 4, 5]] + + [(i, i+4) for i in range(4)] + + [(1,2), (2,7), (1,7), (4,7), (2,4), (4,1)]) + for a,b in edges: + assertPoint(average([points[a], points[b]])) + + # Epsilon inside from corners + middle_point = average(points) + for p in points: + assertPoint(average(20*[p] + [middle_point])) + + # Espilon outside + middle_point[2] = 0 + for p in points[0:4:]: + assertNotPoint(average(20*[p] + [middle_point])) + + middle_point[2] = 30 + for p in points[4:8:]: + assertNotPoint(average(20*[p] + [middle_point])) + + # This test generates a cell that is strictly convex on ALL 6 sides + def test_concvex_cell_containment(self): + points = [ + (10, 10, 10), + (25, 5, 5), + (5, 25, 5), + (20, 20, 10), + (5, 5, 25), + (20, 10, 20), + (10, 20, 20), + (25, 25, 25) + ] + + grid = GridGen.create_single_cell_grid(points) + + assertPoint = lambda p : self.assertTrue( + grid.cell_contains(p[0], p[1], p[2], 0) + ) + + assertNotPoint = lambda p : self.assertFalse( + grid.cell_contains(p[0], p[1], p[2], 0) + ) + + # Cell center + assertPoint(average(points)); + + # "Side" center + assertPoint(average(points[0:4:])) + assertPoint(average(points[4:8:])) + assertPoint(average(points[1:8:2])) + assertPoint(average(points[0:8:2])) + assertPoint(average(points[0:8:4] + points[1:8:4])) + assertPoint(average(points[2:8:4] + points[3:8:4])) + + # Corners + for p in points: + assertPoint(p) + + # Edges + edges = ([(i, i+1) for i in range(0, 8, 2)] + + [(i, i+2) for i in [0, 1, 4, 5]] + + [(i, i+4) for i in range(4)] + + [(1,2), (2,7), (1,7), (4,7), (2,4), (4,1)]) + for a,b in edges: + assertPoint(average([points[a], points[b]])) + + # Epsilon inside from corners + middle_point = average(points) + for p in points: + assertPoint(average(20*[p] + [middle_point])) + + # Espilon outside + middle_point[2] = 0 + for p in points[0:4:]: + assertNotPoint(average(20*[p] + [middle_point])) + + middle_point[2] = 30 + for p in points[4:8:]: + assertNotPoint(average(20*[p] + [middle_point])) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py new file mode 100644 index 0000000000..9289003bc5 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py @@ -0,0 +1,280 @@ +#!/usr/bin/env python +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'test_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from itertools import product as prod +import operator +import random +import numpy +import six + +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid import EclGridGenerator as GridGen +from ecl.util.test import TestAreaContext +from tests import EclTest + + +def generate_ijk_bounds(dims): + ibounds = [(l, u) for l in range(dims[0]) for u in range(l, dims[0])] + jbounds = [(l, u) for l in range(dims[1]) for u in range(l, dims[1])] + kbounds = [(l, u) for l in range(dims[2]) for u in range(l, dims[2])] + return prod(ibounds, jbounds, kbounds) + +def decomposition_preserving(ijk_bound): + return sum(list(zip(*ijk_bound))[0]) % 2 is 0 + +class GridGeneratorTest(EclTest): + + def setUp(self): + self.test_base = [ + ( + list(GridGen.create_coord((4,4,4), (1,1,1))), + list(GridGen.create_zcorn((4,4,4), (1,1,1), offset=0)), + GridGen.create_grid((4,4,4), (1,1,1), offset=0) + ), + ( + list( + GridGen.create_coord((5,5,5), (1,1,1), + translation=(10,10,0)) + ), + list( + GridGen.create_zcorn((5,5,5), (1,1,1), offset=0.5, + irregular_offset=True, concave=True, irregular=True) + ), + GridGen.create_grid( + (5,5,5), (1,1,1), offset=0.5, + irregular=True, irregular_offset=True, concave=True, + translation=(10,10,0) + ) + ) + ] + + def test_extract_grid_decomposition_change(self): + dims = (4,4,4) + zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) + coord = list(GridGen.create_coord(dims, (1,1,1))) + + ijk_bounds = generate_ijk_bounds(dims) + for ijk_bounds in ijk_bounds: + if decomposition_preserving(ijk_bounds): + GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds) + else: + with self.assertRaises(ValueError): + GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds) + + GridGen.extract_subgrid_data(dims, + coord, zcorn, + ijk_bounds, + decomposition_change=True) + + def test_extract_grid_invalid_bounds(self): + dims = (3,3,3) + zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) + coord = list(GridGen.create_coord(dims, (1,1,1))) + + with self.assertRaises(ValueError): + GridGen.extract_subgrid_data(dims, coord, zcorn, ((-1,0), (2,2), (2,2))) + + with self.assertRaises(ValueError): + GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,6), (2,2), (2,2))) + + with self.assertRaises(ValueError): + GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,2), (2,0), (2,2))) + + def test_extract_grid_slice_spec(self): + dims = (4,4,4) + zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) + coord = list(GridGen.create_coord(dims, (1,1,1))) + + ijk_bounds = generate_ijk_bounds(dims) + for ijk in ijk_bounds: + ijk = list(ijk) + for i in range(3): + if len(set(ijk[i])) == 1: + ijk[i] = ijk[i][0] + + GridGen.extract_subgrid_data(dims, + coord, zcorn, + ijk, + decomposition_change=True) + + def assertSubgrid(self, grid, subgrid, ijk_bound): + sijk_space = prod(*[range(d) for d in subgrid.getDims()[:-1:]]) + for sijk in sijk_space: + gijk = tuple([a + b for a, b in + zip(sijk, list(zip(*ijk_bound))[0])]) + + self.assertEqual( + [subgrid.getCellCorner(i, ijk=sijk) for i in range(8)], + [grid.getCellCorner(i, ijk=gijk) for i in range(8)] + ) + + self.assertEqual(grid.active(ijk=gijk), subgrid.active(ijk=sijk)) + + def test_validate_cells(self): + for coord, zcorn, grid in self.test_base: + grid_dims = grid.getDims()[:-1:] + ijk_bounds = generate_ijk_bounds(grid_dims) + for ijk_bound in ijk_bounds: + if not decomposition_preserving(ijk_bound): + continue + + sub_dims = tuple([u-l+1 for l, u in ijk_bound]) + sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data( + grid_dims, + coord, + zcorn, + ijk_bound + ) + + subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, None) + self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) + self.assertSubgrid(grid, subgrid, ijk_bound) + + def test_actnum_extraction(self): + dims = (4,4,4) + + coord = GridGen.create_coord(dims, (1,1,1)) + zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) + + actnum = EclKW("ACTNUM", six.functools.reduce(operator.mul, dims), + EclDataType.ECL_INT) + random.seed(1337) + for i in range(len(actnum)): + actnum[i] = random.randint(0, 1) + + grid = EclGrid.create(dims, zcorn, coord, actnum) + + ijk_bounds = generate_ijk_bounds(dims) + for ijk_bound in ijk_bounds: + if not decomposition_preserving(ijk_bound): + continue + + sub = GridGen.extract_subgrid_data( + dims, + coord, + zcorn, + ijk_bound, + actnum=actnum + ) + + sub_coord, sub_zcorn, sub_actnum = sub + sub_dims = tuple([u-l+1 for l, u in ijk_bound]) + subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum) + self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) + self.assertSubgrid(grid, subgrid, ijk_bound) + + def test_translation(self): + dims = (3,3,3) + + coord = GridGen.create_coord(dims, (1,1,1)) + zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) + grid = EclGrid.create(dims, zcorn, coord, None) + + ijk_bound = [(0, d-1) for d in dims] + translation = (1, 2, 3) + sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data( + dims, + coord, + zcorn, + ijk_bound, + translation=translation + ) + + tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None) + self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize()) + + for gi in range(grid.getGlobalSize()): + translation = numpy.array(translation) + corners = [grid.getCellCorner(i, gi) for i in range(8)] + corners = [tuple(numpy.array(c)+translation) for c in corners] + + tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)] + + self.assertEqual(corners, tcorners) + + def test_subgrid_extration(self): + for _, _, grid in self.test_base[:-1:]: + grid_dims = grid.getDims()[:-1:] + ijk_bounds = generate_ijk_bounds(grid_dims) + for ijk_bound in ijk_bounds: + if not decomposition_preserving(ijk_bound): + continue + + sub_dims = tuple([u-l+1 for l, u in ijk_bound]) + subgrid = GridGen.extract_subgrid(grid, ijk_bound) + + self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) + self.assertSubgrid(grid, subgrid, ijk_bound) + + def test_subgrid_translation(self): + grid = GridGen.create_grid((4,4,4), (1,1,1), offset=0.5, + irregular=True, irregular_offset=True, concave=True, + translation=(10,10,0)) + + # Create grid with MAPAXES + mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT) + for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]): + mapaxes[i] = val + + grid = EclGrid.create( + grid.getDims(), + grid.export_zcorn(), + grid.export_coord(), + None, + mapaxes=mapaxes + ) + + for translation in [ + (0,0,0), + (10, 10, 100), + (-1, -1, -1) + ]: + subgrid = GridGen.extract_subgrid( + grid, + ((0,3), (0,3), (0,3)), + translation=translation + ) + + self.assertEqual(grid.getDims(), subgrid.getDims()) + + translation = numpy.array(translation) + for gindex in range(grid.getGlobalSize()): + grid_corners = [ + grid.getCellCorner(i, global_index=gindex) + for i in range(8) + ] + + subgrid_corners = [ + subgrid.getCellCorner(i, global_index=gindex) + for i in range(8) + ] + + subgrid_corners = [ + list(numpy.array(corner) - translation) + for corner in subgrid_corners + ] + + for gc, sc in zip(grid_corners, subgrid_corners): + self.assertAlmostEqualList( + gc, + sc, + msg="Failed to translate corners correctly." + + "Expected %s, was %s." % (gc, sc), + tolerance=10e-10 + ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py new file mode 100644 index 0000000000..19f6be7295 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py @@ -0,0 +1,417 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import math + +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +from cwrap import Prototype +from cwrap import open as copen + +import time +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, openEclFile +from ecl.grid import EclGrid +from ecl.util.util import DoubleVector, IntVector +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test + + +@statoil_test() +class GridTest(EclTest): + def egrid_file(self): + return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + + + def grid_file(self): + return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID") + + + def grdecl_file(self): + return self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_grid_sim.GRDECL") + + def test_loadFromFile(self): + g1 = EclGrid.loadFromFile( self.egrid_file() ) + g2 = EclGrid.loadFromFile( self.grdecl_file() ) + + self.assertTrue( isinstance( g1 , EclGrid ) ) + self.assertTrue( isinstance( g2 , EclGrid ) ) + + + def test_corner(self): + grid = EclGrid(self.egrid_file()) + nx = grid.getNX() + ny = grid.getNY() + nz = grid.getNZ() + + (x1,y1,z1) = grid.getCellCorner( 0 , ijk = (0,0,0)) + (x2,y2,z2) = grid.getLayerXYZ( 0 , 0 ) + self.assertEqual(x1,x2) + self.assertEqual(y1,y2) + self.assertEqual(z1,z2) + + (x1,y1,z1) = grid.getCellCorner( 0 , ijk = (0,1,0)) + (x2,y2,z2) = grid.getLayerXYZ( (nx + 1) , 0 ) + self.assertEqual(x1,x2) + self.assertEqual(y1,y2) + self.assertEqual(z1,z2) + + (x1,y1,z1) = grid.getCellCorner( 1 , ijk = (nx - 1,0,0)) + (x2,y2,z2) = grid.getLayerXYZ( nx , 0 ) + self.assertEqual(x1,x2) + self.assertEqual(y1,y2) + self.assertEqual(z1,z2) + + (x1,y1,z1) = grid.getCellCorner( 4 , ijk = (0,0,nz-1)) + (x2,y2,z2) = grid.getLayerXYZ( 0 , nz ) + self.assertEqual(x1,x2) + self.assertEqual(y1,y2) + self.assertEqual(z1,z2) + + (x1,y1,z1) = grid.getCellCorner( 7 , ijk = (nx-1,ny-1,nz-1)) + (x2,y2,z2) = grid.getLayerXYZ( (nx + 1)*(ny + 1) - 1 , nz ) + self.assertEqual(x1,x2) + self.assertEqual(y1,y2) + self.assertEqual(z1,z2) + + + + with self.assertRaises(IndexError): + grid.getLayerXYZ( -1 , 0 ) + + with self.assertRaises(IndexError): + grid.getLayerXYZ( (nx + 1)*(ny + 1) , 0 ) + + with self.assertRaises(IndexError): + grid.getLayerXYZ( 0 , -1 ) + + with self.assertRaises(IndexError): + grid.getLayerXYZ( 0 , nz + 1 ) + + + def test_GRID( self ): + grid = EclGrid(self.grid_file()) + self.assertTrue(grid) + + + + def test_EGRID( self ): + grid = EclGrid(self.egrid_file()) + self.assertTrue(grid) + dims = grid.getDims() + self.assertEqual(dims[0] , grid.getNX()) + self.assertEqual(dims[1] , grid.getNY()) + self.assertEqual(dims[2] , grid.getNZ()) + + + + def create(self, filename, load_actnum=True): + fileH = copen(filename, "r") + specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) + zcorn = EclKW.read_grdecl(fileH, "ZCORN") + coord = EclKW.read_grdecl(fileH, "COORD") + if load_actnum: + actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) + else: + actnum = None + + mapaxes = EclKW.read_grdecl(fileH, "MAPAXES") + grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes) + return grid + + + def test_rect(self): + with TestAreaContext("python/grid-test/testRect"): + a1 = 1.0 + a2 = 2.0 + a3 = 3.0 + grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3)) + grid.save_EGRID("rect.EGRID") + grid2 = EclGrid("rect.EGRID") + self.assertTrue(grid) + self.assertTrue(grid2) + + (x, y, z) = grid.get_xyz(ijk=(4, 4, 4)) + self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3]) + + v = grid.cell_volume(ijk=(4, 4, 4)) + self.assertFloatEqual(v, a1 * a2 * a3) + + z = grid.depth(ijk=(4, 4, 4 )) + self.assertFloatEqual(z, 4.5 * a3) + + g1 = grid.global_index(ijk=(2, 2, 2)) + g2 = grid.global_index(ijk=(4, 4, 4)) + (dx, dy, dz) = grid.distance(g2, g1) + self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3]) + + self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2))) + + #ijk = grid.find_cell(1.5 * a1 , 2.5 * a2 , 3.5 * a3) + #self.assertAlmostEqualList(ijk, [1, 2, 3]) + + + def test_create(self): + grid = self.create(self.grdecl_file()) + self.assertTrue(grid) + + + def test_grdecl_load(self): + with self.assertRaises(IOError): + grid = EclGrid.loadFromGrdecl("/file/does/not/exists") + + with TestAreaContext("python/grid-test/grdeclLoad"): + with open("grid.grdecl","w") as f: + f.write("Hei ...") + + with self.assertRaises(ValueError): + grid = EclGrid.loadFromGrdecl("grid.grdecl") + + actnum = IntVector(default_value = 1 , initial_size = 1000) + actnum[0] = 0 + g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum ) + self.assertEqual( g1.getNumActive() , actnum.elementSum() ) + g1.save_EGRID("G.EGRID") + + with open("grid.grdecl" , "w") as f2: + f2.write("SPECGRID\n") + f2.write(" 10 10 10 \'F\' /\n") + + with openEclFile("G.EGRID") as f: + with copen("grid.grdecl" , "a") as f2: + + coord_kw = f["COORD"][0] + coord_kw.write_grdecl( f2 ) + + zcorn_kw = f["ZCORN"][0] + zcorn_kw.write_grdecl( f2 ) + + actnum_kw = f["ACTNUM"][0] + actnum_kw.write_grdecl( f2 ) + + g2 = EclGrid.loadFromGrdecl("grid.grdecl") + self.assertTrue( g1.equal( g2 )) + + + + def test_ACTNUM(self): + g1 = self.create(self.grdecl_file()) + g2 = self.create(self.grdecl_file(), load_actnum=False) + self.assertTrue(g1.equal(g2)) + + + def test_time(self): + t0 = time.clock() + g1 = EclGrid(self.egrid_file()) + t1 = time.clock() + t = t1 - t0 + self.assertTrue(t < 1.0) + + + def test_save(self): + with TestAreaContext("python/grid-test/testSave"): + g1 = EclGrid(self.egrid_file()) + + g1.save_EGRID("test.EGRID") + g2 = EclGrid("test.EGRID") + self.assertTrue(g1.equal(g2)) + + g1.save_GRID("test.GRID") + g2 = EclGrid("test.GRID") + self.assertTrue(g1.equal(g2)) + + fileH = copen("test.grdecl", "w") + g1.save_grdecl(fileH) + fileH.close() + g2 = self.create("test.grdecl") + self.assertTrue(g1.equal(g2)) + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of coarse grid skipped!") + def test_coarse(self): + #work_area = TestArea("python/grid-test/testCoarse") + with TestAreaContext("python/grid-test/testCoarse"): + testGRID = True + g1 = EclGrid(self.createTestPath("Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID")) + + g1.save_EGRID("LGC.EGRID") + g2 = EclGrid("LGC.EGRID") + self.assertTrue(g1.equal(g2, verbose=True)) + + if testGRID: + g1.save_GRID("LGC.GRID") + g3 = EclGrid("LGC.GRID") + self.assertTrue(g1.equal(g3, verbose=True)) + + self.assertTrue(g1.coarse_groups() == 3384) + + + def test_raise_IO_error(self): + with self.assertRaises(IOError): + g = EclGrid("/does/not/exist.EGRID") + + def test_boundingBox(self): + grid = EclGrid.createRectangular((10,10,10) , (1,1,1)) + with self.assertRaises(ValueError): + bbox = grid.getBoundingBox2D(layer = -1 ) + + with self.assertRaises(ValueError): + bbox = grid.getBoundingBox2D( layer = 11 ) + + bbox = grid.getBoundingBox2D( layer = 10 ) + self.assertEqual( bbox , ((0,0) , (10, 0) , (10 , 10) , (0,10))) + + + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (-1,0) ) + + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (6,10) ) + + bbox = grid.getBoundingBox2D( lower_left = (3,3) ) + self.assertEqual( bbox , ((3,3) , (10,3) , (10,10) , (3,10))) + + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (2,2)) + + bbox = grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (7,7)) + self.assertEqual( bbox , ((3,3) , (7,3) , (7,7) , (3,7))) + + + + + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of dual grid skipped!") + def test_dual(self): + with TestAreaContext("python/grid-test/testDual"): + grid = EclGrid(self.egrid_file()) + self.assertFalse(grid.dualGrid()) + self.assertTrue(grid.getNumActiveFracture() == 0) + + grid2 = EclGrid(self.grid_file()) + self.assertFalse(grid.dualGrid()) + self.assertTrue(grid.getNumActiveFracture() == 0) + + dgrid = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.EGRID")) + self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) + self.assertTrue(dgrid.getNumActive() == 46118) + + dgrid2 = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.GRID")) + self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) + self.assertTrue(dgrid.getNumActive() == 46118) + self.assertTrue(dgrid.equal(dgrid2)) + + + # The DUAL_DIFF grid has been manipulated to create a + # situation where some cells are only matrix active, and some + # cells are only fracture active. + dgrid = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID")) + self.assertTrue(dgrid.getNumActive() == 106) + self.assertTrue(dgrid.getNumActiveFracture() == 105) + + self.assertTrue(dgrid.get_active_fracture_index(global_index=0) == -1) + self.assertTrue(dgrid.get_active_fracture_index(global_index=2) == -1) + self.assertTrue(dgrid.get_active_fracture_index(global_index=3) == 0) + self.assertTrue(dgrid.get_active_fracture_index(global_index=107) == 104) + + self.assertTrue(dgrid.get_active_index(global_index=1) == 1) + self.assertTrue(dgrid.get_active_index(global_index=105) == 105) + self.assertTrue(dgrid.get_active_index(global_index=106) == -1) + self.assertTrue(dgrid.get_global_index1F(2) == 5) + + dgrid.save_EGRID("DUAL_DIFF.EGRID") + dgrid2 = EclGrid("DUAL_DIFF.EGRID") + self.assertTrue(dgrid.equal(dgrid2 , verbose = True)) + + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!") + def test_num_active_large_memory(self): + case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") + vecList = [] + for i in range(12500): + vec = DoubleVector() + vec[81920] = 0 + vecList.append(vec) + + grid1 = EclGrid(case) + grid2 = EclGrid(case) + self.assertEqual(grid1.getNumActive(), grid2.getNumActive()) + self.assertEqual(grid1.getNumActive(), 34770) + + + def test_no_mapaxes_check_for_nan(self): + grid_paths = ["Statoil/ECLIPSE/NoMapaxes/ECLIPSE.EGRID", "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.GRID"] + + for grid_path in grid_paths: + test_grid_path = self.createTestPath(grid_path) + grid = EclGrid(test_grid_path) + + xyz = grid.get_xyz(ijk=(0, 0, 0)) + self.assertFalse(math.isnan(xyz[0])) + self.assertFalse(math.isnan(xyz[1])) + self.assertFalse(math.isnan(xyz[2])) + + xyz = grid.get_xyz(ijk=(1, 1, 1)) + self.assertFalse(math.isnan(xyz[0])) + self.assertFalse(math.isnan(xyz[1])) + self.assertFalse(math.isnan(xyz[2])) + + + def test_valid_geometry(self): + grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/GRID_INVALID_CELL/PRED_RESEST_0_R_13_0.GRID")) + self.assertTrue( grid.validCellGeometry( ijk = (27,0,0)) ) + self.assertFalse( grid.validCellGeometry( ijk = (0,0,0)) ) + + + def test_volume_kw(self): + grid = EclGrid(self.egrid_file()) + vol = grid.createVolumeKeyword( ) + self.assertEqual( len(vol) , grid.getNumActive()) + for active_index , volume in enumerate(vol): + self.assertEqual( volume , grid.cell_volume( active_index = active_index )) + + vol = grid.createVolumeKeyword( active_size = False ) + self.assertEqual( len(vol) , grid.getGlobalSize()) + for global_index , volume in enumerate(vol): + self.assertEqual( volume , grid.cell_volume( global_index = global_index )) + + + + def test_large_case(self): + grdecl_file = self.createTestPath("Statoil/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl") + grid = EclGrid.loadFromGrdecl( grdecl_file ) + + + def test_lgr_get(self): + grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID")) + for (nr,name) in [ ( 104 , "LG003017"), + (2 , "LG006024"), + ( 4 , "LG005025"), + ( 82 , "LG011029"), + (100 , "LG007021"), + (110 , "LG003014")]: + lgr_name = grid.get_lgr( name ) + lgr_nr = grid.get_lgr( nr ) + + self.assertEqual( lgr_name , lgr_nr ) + + with self.assertRaises(KeyError): + grid.get_lgr("NO/SUCHLGR") + + with self.assertRaises(KeyError): + grid.get_lgr(1024) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py b/ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py new file mode 100644 index 0000000000..a3cfee4ca7 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py @@ -0,0 +1,118 @@ +import ctypes +import ecl + +from ecl import EclPrototype +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, FortIO +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.util import IntVector + +class EclIndexedReadTest(EclTest): + _freadIndexedData = EclPrototype("void ecl_kw_fread_indexed_data_python(fortio, int, ecl_data_type, int, int_vector, char*)", bind = False) # fortio, offset, type, count, index_map, buffer + _eclFileIndexedRead = EclPrototype("void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)", bind = False) # ecl_file, kw, index, index_map, buffer + + def test_ecl_kw_indexed_read(self): + with TestAreaContext("ecl_kw_indexed_read") as area: + fortio = FortIO("index_test", mode=FortIO.WRITE_MODE) + + element_count = 100000 + ecl_kw = EclKW("TEST", element_count, EclDataType.ECL_INT) + + for index in range(element_count): + ecl_kw[index] = index + + ecl_kw.fwrite(fortio) + + fortio.close() + + + fortio = FortIO("index_test", mode=FortIO.READ_MODE) + + new_ecl_kw = EclKW.fread(fortio) + + for index in range(element_count): + self.assertEqual(new_ecl_kw[index], index) + + index_map = IntVector() + index_map.append(2) + index_map.append(3) + index_map.append(5) + index_map.append(7) + index_map.append(11) + index_map.append(13) + index_map.append(313) + index_map.append(1867) + index_map.append(5227) + index_map.append(7159) + index_map.append(12689) + index_map.append(18719) + index_map.append(32321) + index_map.append(37879) + index_map.append(54167) + index_map.append(77213) + index_map.append(88843) + index_map.append(99991) + + char_buffer = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) + + self._freadIndexedData(fortio, 24, EclDataType.ECL_INT, element_count, index_map, char_buffer) + + int_buffer = ctypes.cast(char_buffer, ctypes.POINTER(ctypes.c_int)) + + for index, index_map_value in enumerate(index_map): + self.assertEqual(index_map_value, int_buffer[index]) + + + + def test_ecl_file_indexed_read(self): + with TestAreaContext("ecl_file_indexed_read") as area: + fortio = FortIO("ecl_file_index_test", mode=FortIO.WRITE_MODE) + + element_count = 100000 + ecl_kw_1 = EclKW("TEST1", element_count, EclDataType.ECL_INT) + ecl_kw_2 = EclKW("TEST2", element_count, EclDataType.ECL_INT) + + for index in range(element_count): + ecl_kw_1[index] = index + ecl_kw_2[index] = index + 3 + + ecl_kw_1.fwrite(fortio) + ecl_kw_2.fwrite(fortio) + + fortio.close() + + ecl_file = EclFile("ecl_file_index_test") + + index_map = IntVector() + index_map.append(2) + index_map.append(3) + index_map.append(5) + index_map.append(7) + index_map.append(11) + index_map.append(13) + index_map.append(313) + index_map.append(1867) + index_map.append(5227) + index_map.append(7159) + index_map.append(12689) + index_map.append(18719) + index_map.append(32321) + index_map.append(37879) + index_map.append(54167) + index_map.append(77213) + index_map.append(88843) + index_map.append(99991) + + char_buffer_1 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) + char_buffer_2 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) + + self._eclFileIndexedRead(ecl_file, "TEST2", 0, index_map, char_buffer_2) + self._eclFileIndexedRead(ecl_file, "TEST1", 0, index_map, char_buffer_1) + + int_buffer_1 = ctypes.cast(char_buffer_1, ctypes.POINTER(ctypes.c_int)) + int_buffer_2 = ctypes.cast(char_buffer_2, ctypes.POINTER(ctypes.c_int)) + + for index, index_map_value in enumerate(index_map): + self.assertEqual(index_map_value, int_buffer_1[index]) + self.assertEqual(index_map_value, int_buffer_2[index] - 3) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py new file mode 100644 index 0000000000..21f8452be8 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_kw_function.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os +import random +from ecl import EclDataType +from ecl.eclfile import EclKW, Ecl3DKW +from ecl.grid import EclGrid +from ecl.util.util import IntVector +from tests import EclTest + +class KWFunctionTest(EclTest): + + def test_region_filter(self): + nx = 10 + ny = 10 + nz = 1 + actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 ) + actnum[nx*ny - 1] = 0 + + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum) + self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 ) + + kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True ) + kw.assign( 0 ) + kw[0:int(nx*ny/2)] = 1 + kw[5,2,0] = 0 + kw[0,9,0] = 2 + + kw.fixUninitialized( grid ) + + # Not assigned because they are in contact with a '2'; these + # two are problem cells. + self.assertEqual( kw[0,ny - 2,0] , 0) + self.assertEqual( kw[1,ny - 1,0] , 0) + + # Not assigned because it is inactive + self.assertEqual( kw[nx - 1,ny - 1,0] , 0) + + self.assertEqual( kw[5,2,0] , 1 ) + for j in range(5,10): + self.assertEqual( kw[5,j,0] , 1 ) + + for i in range(10): + self.assertEqual( kw[i,7,0] , 1 ) + + + + def test_porv_kw(self): + porv_int = EclKW( "PORV", 100, EclDataType.ECL_INT) + with self.assertRaises(TypeError): + actnum = porv_int.create_actnum() + + + prv = EclKW("PRV", 100, EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + actnum = prv.create_actnum() + + + porv = EclKW("PORV", 4, EclDataType.ECL_FLOAT) + porv[0] = 0 + porv[1] = 0.50 + porv[2] = 0.50 + porv[3] = 0 + actnum = porv.create_actnum() + self.assertEqual(tuple(actnum), (0,1,1,0)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py new file mode 100644 index 0000000000..0c8aabf6f7 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py @@ -0,0 +1,307 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_layer.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from unittest import skipIf +import time + +from ecl.util.util import IntVector +from ecl.grid import EclGrid +from ecl.util.geometry import CPolyline +from ecl.grid.faults import Layer , FaultCollection +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class LayerTest(EclTest): + def setUp(self): + pass + + + def test_create_layer(self): + layer = Layer(10,10) + self.assertTrue( isinstance( layer , Layer )) + + + def test_add_cell(self): + layer = Layer(10,10) + with self.assertRaises(ValueError): + layer[100,100] = 199 + + with self.assertRaises(ValueError): + layer[100,"X"] = 199 + + with self.assertRaises(ValueError): + layer[100] = 199 + + layer[5,5] = 88 + self.assertEqual(layer[5,5] , 88) + + + + def test_contact(self): + nx = 20 + ny = 10 + layer = Layer(nx,ny) + grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) + + with self.assertRaises(IndexError): + layer.cellContact( (-1,0),(1,1) ) + + with self.assertRaises(IndexError): + layer.cellContact( (20,0),(1,1) ) + + + self.assertFalse( layer.cellContact((0,0) , (2,0)) ) + self.assertFalse( layer.cellContact((1,0) , (1,0)) ) + + self.assertTrue( layer.cellContact((0,0) , (1,0)) ) + self.assertTrue( layer.cellContact((1,0) , (0,0)) ) + + self.assertTrue( layer.cellContact((0,0) , (0,1)) ) + self.assertTrue( layer.cellContact((0,1) , (0,0)) ) + + self.assertFalse( layer.cellContact((0,0) , (1,1)) ) + self.assertFalse( layer.cellContact((1,1) , (0,0)) ) + + self.assertTrue( layer.cellContact((4,0) , (5,0)) ) + self.assertTrue( layer.cellContact((0,4) , (0,5)) ) + + with TestAreaContext("Layer/barrier"): + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 5 5 1 10 1 1 'X' /\n") + f.write("\'FY\' 1 10 5 5 1 1 'Y' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + + layer.addFaultBarrier( faults["FX"] , 0 ) + self.assertFalse( layer.cellContact((4,0) , (5,0)) ) + + layer.addFaultBarrier( faults["FY"] , 0 ) + self.assertFalse( layer.cellContact((0,4) , (0,5)) ) + + self.assertFalse( layer.cellContact((9,4) , (9,5)) ) + self.assertTrue( layer.cellContact((10,4) , (10,5)) ) + + def test_get_barrier(self): + layer = Layer(10,10) + self.assertFalse( layer.leftBarrier(5,5) ) + self.assertFalse( layer.bottomBarrier(5,5) ) + + layer.addIJBarrier([(1,1),(2,1),(2,2)]) + self.assertTrue( layer.bottomBarrier(1,1) ) + self.assertTrue( layer.leftBarrier(2,1) ) + + + + def test_fault_barrier(self): + nx = 120 + ny = 60 + nz = 43 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F\' 105 107 50 50 1 43 \'Y\' / +\'F\' 108 108 50 50 1 43 \'X\' / +\'F\' 108 108 50 50 22 43 \'Y\' / +\'F\' 109 109 49 49 1 43 \'Y\' / +\'F\' 110 110 49 49 1 43 \'X\' / +\'F\' 111 111 48 48 1 43 \'Y\' / +/ +""") + with open("faults.grdecl") as f: + faults = FaultCollection( grid , "faults.grdecl" ) + + + # Fault layout: + # + # +---+---+---+---+ + # | + # +---+ + + # | + # +---+ + + + fault = faults["F"] + layer = Layer(nx,ny) + fault_pairs = [((104,49),(104,50)), + ((105,49),(105,50)), + ((106,49),(106,50)), + ((107,49),(108,49)), + ((107,49),(107,50)), + ((108,48),(108,49)), + ((109,48),(110,48)), + ((110,47),(110,48))] + gap_pair = ((109,48),(109,49)) + + + for p1,p2 in fault_pairs: + self.assertTrue(layer.cellContact( p1 , p2 )) + + p1,p2 = gap_pair + self.assertTrue(layer.cellContact( p1 , p2 )) + + + layer.addFaultBarrier(fault , 30 , link_segments = False) + for p1,p2 in fault_pairs: + self.assertFalse(layer.cellContact( p1 , p2 )) + p1,p2 = gap_pair + self.assertTrue(layer.cellContact( p1 , p2 )) + + layer.addFaultBarrier(fault , 30) + p1,p2 = gap_pair + self.assertFalse(layer.cellContact( p1 , p2 )) + + + def test_contact2(self): + nx = 10 + ny = 10 + layer = Layer(nx,ny) + grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) + + # Too short + with self.assertRaises(ValueError): + layer.addIJBarrier( [(1,5)] ) + + # Out of range + with self.assertRaises(ValueError): + layer.addIJBarrier( [(10,15),(5,5)] ) + + # Out of range + with self.assertRaises(ValueError): + layer.addIJBarrier( [(7,7),(-5,5)] ) + + # Must have either i1 == i2 or j1 == j2 + with self.assertRaises(ValueError): + layer.addIJBarrier( [(7,8),(6,5)] ) + + p1 = (0 , 4) + p2 = (0 , 5) + self.assertTrue(layer.cellContact( p1 , p2 )) + layer.addIJBarrier( [(0,5) , (nx , 5)] ) + self.assertFalse(layer.cellContact( p1 , p2 )) + + + + def test_update_connected(self): + nx = 10 + ny = 10 + layer = Layer(nx,ny) + + layer[0,0] = 100 + self.assertEqual( layer[0,0], 100 ) + layer.clearCells() + self.assertEqual( layer[0,0], 0 ) + self.assertEqual( layer.cellSum( ) , 0 ) + + with self.assertRaises(ValueError): + layer.updateConnected( (10,10) , 10 ) + + layer[0,0] = 77 + with self.assertRaises(ValueError): + layer.updateConnected( (0,0) , 10 , org_value = 0) + + layer.updateConnected( (0,0) , 10 ) + self.assertEqual( 10 , layer.cellSum() ) + + layer[0,0] = 0 + layer.updateConnected( (0,0) , 3 ) + self.assertEqual( nx*ny*3 , layer.cellSum() ) + + layer.addIJBarrier( [(5,0), (5,10)] ) + layer.clearCells( ) + self.assertEqual( 0 , layer.cellSum( ) ) + layer.updateConnected( (0,0) , 1 ) + + self.assertEqual( 50 , layer.cellSum( ) ) + self.assertEqual( layer[4,0] , 1 ) + self.assertEqual( layer[5,0] , 0 ) + + layer = Layer(nx,ny) + layer.addIJBarrier( [(5,0), (5,5)] ) + layer.updateConnected( (0,0) , 1 ) + self.assertEqual( 100 , layer.cellSum( ) ) + + + def test_matching(self): + d = 10 + layer = Layer(d,d) + + for i in range(d): + layer[i,i] = 10 + + cell_list = layer.cellsEqual( 1 ) + self.assertEqual( cell_list , [] ) + + cell_list = layer.cellsEqual( 10 ) + self.assertEqual( cell_list , [ (i,i) for i in range(d)] ) + + + def test_add_polyline_barrier(self): + d = 10 + layer = Layer(d,d) + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) + pl = CPolyline( init_points = [(0 , 0) , (d/2 , d/2) , (d,d)]) + layer.addPolylineBarrier( pl , grid , 0) + for i in range(d): + self.assertTrue( layer.bottomBarrier(i,i) ) + if i < (d - 1): + self.assertTrue( layer.leftBarrier(i+1,i) ) + + + def test_active(self): + d = 10 + layer = Layer(d,d) + with self.assertRaises( ValueError ): + layer.activeCell(d+1,d+2) + + self.assertTrue( layer.activeCell(1,2) ) + + grid = EclGrid.createRectangular( (d,d+1,1) , (1,1,1) ) + with self.assertRaises( ValueError ): + layer.updateActive( grid , 0 ) + + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) + with self.assertRaises( ValueError ): + layer.updateActive( grid , 10 ) + + actnum = IntVector( initial_size = d*d*1 , default_value = 1) + actnum[0] = 0 + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) , actnum = actnum) + layer.updateActive( grid , 0 ) + self.assertTrue( layer.activeCell(1,2) ) + self.assertFalse( layer.activeCell(0,0) ) + + + def test_assign(self): + layer = Layer(10,5) + self.assertEqual( layer.cellSum() , 0 ) + + layer.assign(10) + self.assertEqual( layer.cellSum() , 500 ) + + + + def test_count_equal(self): + layer = Layer(10,10) + self.assertEqual( 100 , layer.countEqual( 0 )) + self.assertEqual( 0 , layer.countEqual( 1 )) + + layer[3,3] = 3 + self.assertEqual( 1 , layer.countEqual( 3 )) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py new file mode 100644 index 0000000000..43bd77493f --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py @@ -0,0 +1,195 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +import datetime +import math + +try: + from unittest2 import skipIf, skipUnless, skipIf +except ImportError: + from unittest import skipIf, skipUnless, skipIf + +from ecl.summary import EclSum +from ecl.summary import EclNPV , NPVPriceVector + +from ecl.util.util import StringList, TimeVector, DoubleVector , CTime +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test + + +base = "ECLIPSE" +path = "Statoil/ECLIPSE/Gurbat" +case = "%s/%s" % (path, base) + +def callable(x): + return 1 + +def linear1(x): + return x + +def linear2(x): + return 2*x + +@statoil_test() +class NPVTest(EclTest): + def setUp(self): + self.case = self.createTestPath(case) + + + def test_create(self): + with self.assertRaises(Exception): + npv = EclNPV("/does/not/exist") + + npv = EclNPV( self.case ) + + + def test_eval_npv(self): + npv = EclNPV( self.case ) + with self.assertRaises(ValueError): + npv.eval() + + + def test_expression(self): + npv = EclNPV( self.case ) + self.assertIsNone( npv.getExpression() ) + npv.setExpression( "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") + self.assertEqual( npv.getExpression() , "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") + self.assertIn( "FOPT" , npv.getKeyList() ) + self.assertIn( "FGIT" , npv.getKeyList() ) + + with self.assertRaises(ValueError): + npv.parseExpression("[FOPT") + + with self.assertRaises(ValueError): + npv.parseExpression("FOPT]") + + with self.assertRaises(KeyError): + npv.parseExpression("[FoPT]") + + with self.assertRaises(ValueError): + npv.parseExpression("[FOPR]") + + parsedExpression = npv.parseExpression("[FOPT]") + self.assertEqual( parsedExpression , "FOPT[i]") + self.assertEqual( 1 , len(npv.getKeyList() )) + + + parsedExpression = npv.parseExpression("[FOPT]*2 + [FGPT] - [WOPT:OP_1]") + self.assertEqual( parsedExpression , "FOPT[i]*2 + FGPT[i] - WOPT_OP_1[i]") + keyList = npv.getKeyList() + self.assertEqual( 3 , len(keyList)) + self.assertIn( "FOPT" , keyList ) + self.assertIn( "FGPT" , keyList ) + self.assertIn( "WOPT:OP_1" , keyList ) + + + def test_period(self): + npv = EclNPV( self.case ) + self.assertIsNone(npv.start) + self.assertIsNone(npv.end) + self.assertEqual("1Y" , npv.interval) + + + def test_eval(self): + npv = EclNPV(self.case) + npv.compile("[FOPT]") + npv1 = npv.evalNPV() + + npv2 = 0 + sum = EclSum(self.case) + trange = sum.timeRange() + fopr = sum.blockedProduction("FOPT" , trange) + for v in fopr: + npv2 += v + self.assertAlmostEqual( npv1 , npv2 ) + + npv.compile("[FOPT] - 0.5*[FOPT] - 0.5*[FOPT]") + npv1 = npv.evalNPV() + self.assertTrue( abs(npv1) < 1e-2 ) + + npv.compile("[WOPT:OP_1] - 0.5*[WOPT:OP_1] - 0.5*[WOPT:OP_1]") + npv1 = npv.evalNPV() + self.assertTrue( abs(npv1) < 1e-2 ) + + + + def test_price_vector(self): + with self.assertRaises(ValueError): + NPVPriceVector("NotList") + + with self.assertRaises(ValueError): + NPVPriceVector(1.25) + + with self.assertRaises(ValueError): + NPVPriceVector((1,25)) + + with self.assertRaises(ValueError): + NPVPriceVector([1,2,3]) + + with self.assertRaises(ValueError): + NPVPriceVector([(1,25) , ("String",100,100)]) + + with self.assertRaises(ValueError): + NPVPriceVector([(1,25) , ("String",100)]) + + NPVPriceVector([(datetime.datetime(2010 , 1 , 1 , 0 , 0 , 0) , 100)]) + NPVPriceVector([(datetime.date(2010 , 1 , 1 ) , 100)]) + NPVPriceVector([("19/06/2010" , 100)]) + + with self.assertRaises(ValueError): + NPVPriceVector([("01/01/2000" , 100), + ("01/01/1999" , 100)]) + + with self.assertRaises(ValueError): + NPVPriceVector([("01/01/2000" , "String")]) + + NPVPriceVector([("01/01/2000" , 100)]) + NPVPriceVector([("01/01/2000" , 77.99)]) + NPVPriceVector([("01/01/2000" , callable)]) + + + vec = NPVPriceVector([("01/01/2000" , 100), + ("01/02/2000" , 200), + ("01/03/2000" , 300)]) + + with self.assertRaises(ValueError): + vec.eval( datetime.date( 1999 , 1 , 1)) + + self.assertEqual( datetime.date( 2000 , 1 , 1 ) , NPVPriceVector.assertDate( datetime.date(2000,1,1) )) + self.assertEqual( datetime.date( 2000 , 1 , 1 ) , NPVPriceVector.assertDate( CTime(datetime.date(2000,1,1)) )) + + + self.assertEqual( 100 , vec.eval( datetime.date( 2000 , 1 , 10))) + self.assertEqual( 100 , vec.eval( datetime.datetime( 2000 , 1 , 10 , 0,0,0))) + self.assertEqual( 100 , vec.eval( CTime(datetime.datetime( 2000 , 1 , 10 , 0,0,0)))) + + self.assertEqual( 300 , vec.eval( datetime.date( 2000 , 4, 1))) + + + vec = NPVPriceVector([("01/01/2000" , linear1), + ("01/02/2000" , linear2), + ("01/03/2000" , 300)]) + + self.assertEqual( 300 , vec.eval( datetime.date( 2000 , 3 , 10))) + self.assertEqual( 0 , vec.eval( datetime.date( 2000 , 1 , 1) )) + self.assertEqual( 10 , vec.eval( datetime.date( 2000 , 1 , 11) )) + self.assertEqual( 20 , vec.eval( datetime.date( 2000 , 1 , 21) )) + + self.assertEqual( 0 , vec.eval( datetime.date( 2000 , 2 , 1) )) + self.assertEqual( 20 , vec.eval( datetime.date( 2000 , 2 , 11) )) + self.assertEqual( 40 , vec.eval( datetime.date( 2000 , 2 , 21) )) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_region.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py new file mode 100644 index 0000000000..6c38697115 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py @@ -0,0 +1,91 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import Layer +from ecl.util.util import IntVector +from tests import EclTest + +class RegionTest(EclTest): + + def test_equal(self): + grid = EclGrid.createRectangular( (10,10,1) , (1,1,1)) + kw_int = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) + kw_float = EclKW( "FLOAT" , grid.getGlobalSize( ) , EclDataType.ECL_FLOAT ) + + kw_int[0:49] = 1 + region = EclRegion(grid, False) + region.select_equal( kw_int , 1 ) + glist = region.getGlobalList() + for g in glist: + self.assertEqual( kw_int[g] , 1 ) + + with self.assertRaises(ValueError): + region.select_equal( kw_float , 1 ) + + def test_sum(self): + grid = EclGrid.createRectangular( (10,10,1) , (1,1,1)) + kw_mask = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) + int_value = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) + float_value = EclKW( "FLOAT" , grid.getGlobalSize( ) , EclDataType.ECL_FLOAT) + double_value = EclKW( "DOUBLE" , grid.getGlobalSize( ) , EclDataType.ECL_DOUBLE ) + bool_value = EclKW( "BOOL" , grid.getGlobalSize( ) , EclDataType.ECL_BOOL ) + + kw_mask[0:50] = 1 + + for i in range(len(int_value)): + float_value[i] = i + double_value[i] = i + int_value[i] = i + bool_value[i] = True + + region = EclRegion(grid, False) + region.select_equal( kw_mask , 1 ) + + self.assertEqual( int_value.sum( ) , 99*100/2 ) + self.assertEqual( int_value.sum( mask = region ) , 49*50/2 ) + self.assertEqual( double_value.sum( mask = region ) , 1.0*49*50/2 ) + self.assertEqual( float_value.sum( mask = region ) , 1.0*49*50/2 ) + self.assertEqual( bool_value.sum( mask = region ) , 50 ) + + + def test_truth_and_size(self): + actnum = IntVector( initial_size = 100, default_value = 0) + actnum[0:50] = 1 + grid = EclGrid.createRectangular( (10,10,1) , (1,1,1), actnum = actnum) + region = EclRegion(grid, False) + + self.assertFalse( region ) + self.assertEqual( 0, region.active_size( )) + self.assertEqual( 0, region.global_size( )) + + region.select_all( ) + self.assertTrue( region ) + self.assertEqual( 50, region.active_size( )) + self.assertEqual( 100, region.global_size( )) + + region.deselect_all() + self.assertFalse( region ) + self.assertEqual( 0, region.active_size( )) + self.assertEqual( 0, region.global_size( )) + + region = EclRegion(grid, False) + region.select_inactive() + self.assertTrue( region ) + self.assertEqual( 0 , region.active_size( )) + self.assertEqual( 50, region.global_size( )) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py new file mode 100644 index 0000000000..16fc04090a --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py @@ -0,0 +1,207 @@ +#!/usr/bin/env python +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from ecl.eclfile import EclFile +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import Layer +from tests import EclTest, statoil_test + + +@statoil_test() +class RegionTest(EclTest): + def setUp(self): + case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") + self.grid = EclGrid(case) + self.rst_file = EclFile("%s.UNRST" % case) + self.init_file = EclFile("%s.INIT" % case) + + + def test_kw_imul(self): + P = self.rst_file["PRESSURE"][5] + fipnum = self.init_file["FIPNUM"][0] + fipnum_copy = fipnum.deep_copy() + + reg = EclRegion(self.grid, False) + reg.select_more(P, 260) + fipnum.mul(-1, mask=reg) + self.assertFalse(fipnum.equal(fipnum_copy)) + + fipnum.mul(-1, mask=reg) + self.assertTrue(fipnum.equal(fipnum_copy)) + + def test_equal(self): + reg1 = EclRegion(self.grid , False) + reg2 = EclRegion(self.grid , False) + + self.assertTrue( reg1 == reg2 ) + + reg1.select_islice(4 , 6) + self.assertFalse( reg1 == reg2 ) + reg2.select_islice(4,7) + self.assertFalse( reg1 == reg2 ) + reg1.select_islice(7,7) + self.assertTrue( reg1 == reg2 ) + + + def test_kw_idiv(self): + P = self.rst_file["PRESSURE"][5] + fipnum = self.init_file["FIPNUM"][0] + fipnum_copy = fipnum.deep_copy() + + reg = EclRegion(self.grid, False) + reg.select_more(P, 260) + fipnum.div(-1, mask=reg) + self.assertFalse(fipnum.equal(fipnum_copy)) + + fipnum.div(-1, mask=reg) + self.assertTrue(fipnum.equal(fipnum_copy)) + + + def test_kw_iadd(self): + P = self.rst_file["PRESSURE"][5] + fipnum = self.init_file["FIPNUM"][0] + fipnum_copy = fipnum.deep_copy() + + reg = EclRegion(self.grid, False) + reg.select_more(P, 260) + fipnum.add(1, mask=reg) + self.assertFalse(fipnum.equal(fipnum_copy)) + + reg.invert() + fipnum.add(1, mask=reg) + + fipnum.sub(1) + self.assertTrue(fipnum.equal(fipnum_copy)) + + + def test_kw_isub(self): + P = self.rst_file["PRESSURE"][5] + fipnum = self.init_file["FIPNUM"][0] + fipnum_copy = fipnum.deep_copy() + + reg = EclRegion(self.grid, False) + reg.select_more(P, 260) + fipnum.sub(1, mask=reg) + self.assertFalse(fipnum.equal(fipnum_copy)) + fipnum.add(1, mask=reg) + self.assertTrue(fipnum.equal(fipnum_copy)) + + + def test_slice(self): + reg = EclRegion(self.grid, False) + reg.select_islice(0, 5) + OK = True + + global_list = reg.getGlobalList() + self.assertEqual(global_list.parent(), reg) + + for gi in global_list: + (i, j, k) = self.grid.get_ijk(global_index=gi) + if i > 5: + OK = False + self.assertTrue(OK) + self.assertTrue(self.grid.getNY() * self.grid.getNZ() * 6 == len(reg.getGlobalList())) + + reg.select_jslice(7, 8, intersect=True) + OK = True + for gi in reg.getGlobalList(): + (i, j, k) = self.grid.get_ijk(global_index=gi) + if i > 5: + OK = False + + if j < 7 or j > 8: + OK = False + + self.assertTrue(OK) + self.assertTrue(2 * self.grid.getNZ() * 6 == len(reg.getGlobalList())) + + reg2 = EclRegion(self.grid, False) + reg2.select_kslice(3, 5) + reg &= reg2 + OK = True + for gi in reg.getGlobalList(): + (i, j, k) = self.grid.get_ijk(global_index=gi) + if i > 5: + OK = False + + if j < 7 or j > 8: + OK = False + + if k < 3 or k > 5: + OK = False + + self.assertTrue(OK) + self.assertTrue(2 * 3 * 6 == len(reg.getGlobalList())) + + + + def test_index_list(self): + reg = EclRegion(self.grid, False) + reg.select_islice(0, 5) + active_list = reg.getActiveList() + global_list = reg.getGlobalList() + + + + def test_polygon(self): + reg = EclRegion(self.grid, False) + (x,y,z) = self.grid.get_xyz( ijk=(10,10,0) ) + dx = 0.1 + dy = 0.1 + reg.select_inside_polygon( [(x-dx,y-dy) , (x-dx,y+dy) , (x+dx,y+dy) , (x+dx,y-dy)] ) + self.assertTrue( self.grid.getNZ() == len(reg.getGlobalList())) + + + def test_heidrun(self): + root = self.createTestPath("Statoil/ECLIPSE/Heidrun") + grid = EclGrid( "%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root) + + polygon = [] + with open("%s/polygon.ply" % root) as fileH: + for line in fileH.readlines(): + tmp = line.split() + polygon.append( (float(tmp[0]) , float(tmp[1]))) + self.assertEqual( len(polygon) , 11 ) + + reg = EclRegion( grid , False ) + reg.select_inside_polygon( polygon ) + self.assertEqual( 0 , len(reg.getGlobalList()) % grid.getNZ()) + + + def test_layer(self): + region = EclRegion(self.grid, False) + layer = Layer( self.grid.getNX() , self.grid.getNY() + 1) + with self.assertRaises(ValueError): + region.selectFromLayer( layer , 0 , 1 ) + + layer = Layer( self.grid.getNX() , self.grid.getNY() ) + layer[0,0] = 1 + layer[1,1] = 1 + layer[2,2] = 1 + + with self.assertRaises(ValueError): + region.selectFromLayer( layer , -1 , 1 ) + + with self.assertRaises(ValueError): + region.selectFromLayer( layer , self.grid.getNZ() , 1 ) + + region.selectFromLayer( layer , 0 , 2 ) + glist = region.getGlobalList() + self.assertEqual(0 , len(glist)) + + region.selectFromLayer( layer , 0 , 1 ) + glist = region.getGlobalList() + self.assertEqual(3 , len(glist)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py new file mode 100644 index 0000000000..db480ffe82 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py @@ -0,0 +1,36 @@ +import time +import datetime + +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl import EclDataType +from ecl.eclfile import EclFile, EclKW, openFortIO, FortIO + + + +class Removed_2_1_Test(EclTest): + def test_ecl_file_block(self): + + with TestAreaContext("name") as t: + kw = EclKW("TEST", 3, EclDataType.ECL_INT) + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + kw.fwrite( f ) + + t.sync() + + f = EclFile( "TEST" ) + with self.assertRaises(NotImplementedError): + f.select_block( "KW" , 100 ) + + with self.assertRaises(NotImplementedError): + f.select_global( ) + + with self.assertRaises(NotImplementedError): + f.select_restart_section( index = None , report_step = None , sim_time = None) + + with self.assertRaises(NotImplementedError): + f.select_restart_section( ) + + with self.assertRaises(NotImplementedError): + EclFile.restart_block( "TEST" ) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py new file mode 100644 index 0000000000..32fa276aec --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from _ctypes import ArgumentError +import os +import datetime +from ecl.eclfile import EclFile +from tests import EclTest, statoil_test + + + + +@statoil_test() +class RestartTest(EclTest): + def setUp(self): + self.xfile0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") + self.u_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.file_list = [] + + def addFile( self, filename ): + self.file_list.append(filename) + + + def tearDown(self): + for f in self.file_list: + if os.path.exists(f): + os.unlink(f) + + + def report_file_test(self, fname): + self.assertTrue(EclFile.contains_report_step(fname, 4)) + self.assertTrue(EclFile.contains_report_step(fname, 0)) + self.assertTrue(EclFile.contains_report_step(fname, 62)) + self.assertFalse(EclFile.contains_report_step(fname, -1)) + self.assertFalse(EclFile.contains_report_step(fname, 100)) + + f = EclFile(fname) + self.assertTrue(f.has_report_step(4)) + self.assertTrue(f.has_report_step(0)) + self.assertTrue(f.has_report_step(62)) + + self.assertFalse(f.has_report_step(-1)) + self.assertFalse(f.has_report_step(100)) + + + def test_report(self): + self.report_file_test(self.u_file) + + + def test_date(self): + f = EclFile(self.u_file) + self.assertTrue(f.has_sim_time(datetime.datetime(2001, 6, 1))) + self.assertFalse(f.has_sim_time(datetime.datetime(2005, 6, 1))) + self.assertFalse(f.has_sim_time(datetime.datetime(1999, 6, 1))) + self.assertFalse(f.has_sim_time(datetime.datetime(2001, 6, 11))) + + self.assertTrue(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 1))) + self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2005, 6, 1))) + self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(1999, 6, 1))) + self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 11))) + + + def report_list_file_test(self, fname, rlist0): + rlist = EclFile.file_report_list(fname) + self.assertListEqual(rlist, rlist0) + + f = EclFile(fname) + rlist = f.report_list + self.assertListEqual(rlist, rlist0) + + + def test_report_list(self): + rlist0 = list(range(63)) + self.report_list_file_test(self.u_file, rlist0) + + rlist0 = [0] + self.report_list_file_test(self.xfile0, rlist0) + + f = EclFile(self.grid_file) + with self.assertRaises(ArgumentError): #argumentError wraps the expected TypeError + EclFile.file_report_list(f) + + + def test_dates(self): + f = EclFile(self.u_file) + dates = f.dates + self.assertTrue(len(dates) == 63) + + f = EclFile(self.xfile0) + dates = f.dates + self.assertTrue(len(dates) == 1) + self.assertTrue(dates[0] == datetime.datetime(2000, 1, 1)) + + + def test_name(self): + f = EclFile(self.u_file) + self.assertTrue(f.getFilename() == self.u_file) + + f = EclFile(self.xfile0) + self.assertTrue(f.getFilename() == self.xfile0) + + + def test_kw( self ): + f = EclFile(self.u_file) + kw1 = f["SWAT"][40] + kw2 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1)) + kw3 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1), copy=True) + + self.assertTrue(kw1.equal(kw2)) + self.assertTrue(kw1.equal(kw3)) + + with self.assertRaises(IndexError): + kw4 = f.restart_get_kw("SWAT", datetime.datetime(2009, 3, 17)) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py new file mode 100644 index 0000000000..c1683f6d41 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py @@ -0,0 +1,44 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import datetime + +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO +from ecl.grid import EclGrid + +@statoil_test() +class RestartHeadTest(EclTest): + def setUp(self): + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") + + def test_headers(self): + g = EclGrid( self.grid_file ) + f = EclRestartFile( g , self.unrst_file ) + + headers = f.headers( ) + self.assertEqual( len(headers) , 63 ) + + with self.assertRaises(IndexError): + f.get_header(1000) + + header = f.get_header( 10 ) + details = header.well_details( ) + self.assertTrue( "NXCONZ" in details ) + self.assertTrue( "NCWMAX" in details ) + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py new file mode 100644 index 0000000000..b903f3d78f --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# Copyright (C) 2016 Statoil ASA, Norway. +# +# The file 'test_rft.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +import datetime +from ecl.util.util import CTime +from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, EclRFT, WellTrajectory +from tests import EclTest + +class RFTTest(EclTest): + + def test_create(self): + rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) + self.assertEqual( len(rft) , 0 ) + + with self.assertRaises(IndexError): + cell = rft[5] + + def test_repr(self): + rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) + pfx = 'EclRFT(completed_cells = 0, date = 2015-10-01, RFT, MSW)' + self.assertEqual(pfx, repr(rft)[:len(pfx)]) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py new file mode 100644 index 0000000000..67fb0c0062 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +from ecl.rft import EclRFTCell, EclPLTCell +from tests import EclTest + + +# def out_of_range(): +# rftFile = ecl.EclRFTFile(RFT_file) +# rft = rftFile[100] + + +class RFTCellTest(EclTest): + def setUp(self): + self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") + self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") + + def test_RFT_cell(self): + i = 10 + j = 8 + k = 100 + depth = 100 + pressure = 65 + swat = 0.56 + sgas = 0.10 + cell = EclRFTCell(i, j, k, depth, pressure, swat, sgas) + + self.assertEqual(i, cell.get_i()) + self.assertEqual(j, cell.get_j()) + self.assertEqual(k, cell.get_k()) + + self.assertFloatEqual(pressure, cell.pressure) + self.assertFloatEqual(depth, cell.depth) + self.assertFloatEqual(swat, cell.swat) + self.assertFloatEqual(sgas, cell.sgas) + self.assertFloatEqual(1 - (sgas + swat), cell.soil) + + + def test_PLT_cell(self): + i = 2 + j = 16 + k = 100 + depth = 100 + pressure = 65 + orat = 0.78 + grat = 88 + wrat = 97213 + conn_start = 214 + conn_end = 400 + flowrate = 111 + oil_flowrate = 12 + gas_flowrate = 132 + water_flowrate = 13344 + + cell = EclPLTCell(i, j, k, depth, pressure, orat, grat, wrat, conn_start, conn_end, flowrate, + oil_flowrate, gas_flowrate, water_flowrate) + + + self.assertEqual(i, cell.get_i()) + self.assertEqual(j, cell.get_j()) + self.assertEqual(k, cell.get_k()) + + self.assertFloatEqual(pressure, cell.pressure) + self.assertFloatEqual(depth, cell.depth) + self.assertFloatEqual(orat, cell.orat) + self.assertFloatEqual(grat, cell.grat) + self.assertFloatEqual(wrat, cell.wrat) + + self.assertFloatEqual(conn_start, cell.conn_start) + self.assertFloatEqual(conn_end, cell.conn_end) + self.assertFloatEqual(flowrate, cell.flowrate) + self.assertFloatEqual(oil_flowrate, cell.oil_flowrate) + self.assertFloatEqual(gas_flowrate, cell.gas_flowrate) + self.assertFloatEqual(water_flowrate, cell.water_flowrate) + + + + + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py new file mode 100644 index 0000000000..e097551a44 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_rft_statoil.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from __future__ import print_function +import datetime +from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, WellTrajectory +from tests import EclTest, statoil_test + + +@statoil_test() +class RFTTest(EclTest): + def setUp(self): + self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") + self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") + + + def test_RFT_load(self): + rftFile = EclRFTFile(self.RFT_file) + + rft = rftFile[0] + cell = rft.ijkget((32, 53, 0)) + self.assertIsInstance(cell, EclRFTCell) + + self.assertEqual(2, rftFile.size()) + self.assertEqual(0, rftFile.size(well="OP*")) + self.assertEqual(0, rftFile.size(well="XXX")) + self.assertEqual(1, rftFile.size(date=datetime.date(2000, 6, 1))) + self.assertEqual(0, rftFile.size(date=datetime.date(2000, 6, 17))) + + cell = rft.ijkget((30, 20, 1880)) + self.assertIsNone(cell) + + for rft in rftFile: + self.assertTrue(rft.is_RFT()) + self.assertFalse(rft.is_SEGMENT()) + self.assertFalse(rft.is_PLT()) + self.assertFalse(rft.is_MSW()) + + for cell in rft: + self.assertIsInstance(cell, EclRFTCell) + + cell0 = rft.iget_sorted(0) + self.assertIsInstance(cell, EclRFTCell) + rft.sort() + + for h in rftFile.getHeaders(): + print(h) + self.assertIsInstance(h[1], datetime.date) + + + def test_PLT_load(self): + pltFile = EclRFTFile(self.PLT_file) + plt = pltFile[11] + self.assertTrue(plt.is_PLT()) + self.assertFalse(plt.is_SEGMENT()) + self.assertFalse(plt.is_RFT()) + self.assertFalse(plt.is_MSW()) + + for cell in plt: + self.assertIsInstance(cell, EclPLTCell) + + + def test_exceptions(self): + with self.assertRaises(IndexError): + rftFile = EclRFTFile(self.RFT_file) + rft = rftFile[100] + + + def test_basics(self): + wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) + self.assertEqual(len(wt), 38) + self.assertTrue(isinstance(str(wt), str)) + self.assertTrue(isinstance(repr(wt), str)) + self.assertEqual('WellTrajectory(len=38)', repr(wt)) + + def test_trajectory(self): + with self.assertRaises(IOError): + WellTrajectory("/does/no/exist") + + with self.assertRaises(UserWarning): + WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/invalid_float.txt")) + + with self.assertRaises(UserWarning): + WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/missing_item.txt")) + + wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) + self.assertEqual(len(wt), 38) + + with self.assertRaises(IndexError): + p = wt[38] + + p0 = wt[0] + self.assertEqual(p0.utm_x, 458920.671 ) + self.assertEqual(p0.utm_y, 7324939.077 ) + self.assertEqual(p0.measured_depth, 2707.5000) + + pm1 = wt[-1] + p37 = wt[37] + self.assertEqual(p37, pm1) + + + + def test_PLT(self): + rft_file = EclRFTFile(self.createTestPath("Statoil/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT")) + + rft0 = rft_file[0] + rft1 = rft_file[1] + rft2 = rft_file[2] + rft3 = rft_file[3] + + self.assertTrue(rft0.is_RFT()) + self.assertTrue(rft1.is_RFT()) + self.assertTrue(rft2.is_PLT()) + self.assertTrue(rft3.is_PLT()) + + self.assertEqual(len(rft0), 42) + self.assertEqual(len(rft1), 37) + self.assertEqual(len(rft2), 42) + self.assertEqual(len(rft3), 37) + + self.assertFloatEqual(rft0[0].pressure, 0.22919502E+03) + self.assertFloatEqual(rft0[0].depth , 0.21383721E+04) + + self.assertFloatEqual(rft1[0].pressure, 0.22977950E+03) + self.assertFloatEqual(rft1[0].depth , 0.21384775E+04) + + self.assertFloatEqual(rft2[0].pressure, 0.19142435E+03) + self.assertFloatEqual(rft2[0].depth , 0.21383721E+04) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py new file mode 100644 index 0000000000..03c5b3210a --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +from cwrap import open as copen + +import time +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment +from tests import EclTest, statoil_test + + +@statoil_test() +class StatoilFaultTest(EclTest): + def loadGrid(self): + grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") + fileH = copen(grid_file, "r") + specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) + zcorn = EclKW.read_grdecl(fileH, "ZCORN") + coord = EclKW.read_grdecl(fileH, "COORD") + actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) + + return EclGrid.create(specgrid, zcorn, coord, actnum) + + + + + def test_load(self): + grid = self.loadGrid() + faults_file = self.createTestPath("Statoil/ECLIPSE/Faults/faults.grdecl") + faults = FaultCollection( grid , faults_file ) + for fault in faults: + for layer in fault: + for fl in layer: + fl.verify() + + + + def test_splitLine2(self): + grid = self.loadGrid( ) + f = Fault(grid , "DF41_C") + +# 179 180 181 +# o o o o o o o o o o o o o o +# | +# 78 | +# o o o o o o o o o o o o o o +# | +# 77 | +# o o o o o o o o o o o o o o +# | +# 76 | +# o o o o o o o o o o o o o o +# | +# 75 | +# o o o o o o o o o o o o o o +# +# 74 +# o o o o o o o o o o o o o o +# +# 73 +# o o o o-----o o o o o o o o o o +# | +# 72 | +# o o o o-----o o o o o o o o o o +# +# 71 +# o o o o-----o o o o o o o o o o +# | +# 70 | +# o o o o o o o o o o o o o o +# | +# 69 | +# o o o o o o o o o o o o o o +# +# 68 +# o o o o o o o o o o o o o o +# +# 67 +# o o o o o o o o o o o o o o +# +# 66 +# o o o o o o o o o o o o o o +# | +# 65 | +# o o o o-----o o o o o o o o o o + + + f.addRecord( 179, 179 , 77 , 78 , 0 , 42 , 'X' ) + f.addRecord( 179, 179 , 75 , 76 , 0 , 41 , 'X' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'X' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y-' ) + + f.addRecord( 180, 180 , 70 , 70 , 0 , 42 , 'Y' ) + f.addRecord( 180, 180 , 69 , 70 , 0 , 42 , 'X' ) + f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'X' ) + f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'Y-' ) + + + ij_polyline = f.getIJPolyline( 19 ) + ij_list = [(180, 79), (180, 77), (180, 75), + (180, 73), (181, 73), (181, 72), (180, 72), + (180, 71), (181, 71), (181, 69), + (181, 66), (181, 65), (180, 65)] + + self.assertEqual(ij_polyline , ij_list) + + + + + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py new file mode 100644 index 0000000000..811e7ec6db --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py @@ -0,0 +1,488 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os.path +import os +import inspect +import datetime +import csv +import shutil +import cwrap +import stat +from contextlib import contextmanager +from unittest import skipIf, skipUnless, skipIf + +from ecl import EclUnitTypeEnum +from ecl import EclDataType +from ecl.eclfile import FortIO, openFortIO, EclKW, EclFile +from ecl.summary import EclSum, EclSumVarType, EclSumKeyWordVector +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.test.ecl_mock import createEclSum + + +@contextmanager +def pushd(path): + if not os.path.isdir(path): + os.makedirs(path) + cwd = os.getcwd() + os.chdir(path) + + yield + + os.chdir(cwd) + +def create_prediction(history, pred_path): + restart_case = os.path.join( os.getcwd(), history.base) + restart_step = history.last_report + with pushd(pred_path): + prediction = create_case( case = "PREDICTION", restart_case = restart_case, restart_step = restart_step, data_start = history.end_date) + prediction.fwrite() + + +def fopr(days): + return days + +def fopt(days): + return days + +def fgpt(days): + if days < 50: + return days + else: + return 100 - days + +def create_case(case = "CSV", restart_case = None, restart_step = -1, data_start = None): + length = 100 + return createEclSum(case , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], + sim_length_days = length, + num_report_step = 10, + num_mini_step = 10, + data_start = data_start, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FGPT" : fgpt }, + restart_case = restart_case, + restart_step = restart_step) + +class SumTest(EclTest): + + + def test_mock(self): + case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + self.assertTrue("FOPT" in case) + self.assertFalse("WWCT:OPX" in case) + + def test_TIME_special_case(self): + case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + keys = case.keys() + self.assertEqual( len(keys) , 2 ) + self.assertIn( "FOPT" , keys ) + self.assertIn( "FOPR" , keys ) + + + keys = case.keys(pattern = "*") + self.assertEqual( len(keys) , 2 ) + self.assertIn( "FOPT" , keys ) + self.assertIn( "FOPR" , keys ) + + + def test_identify_var_type(self): + self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h") + self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR ) + self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR ) + self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR ) + self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) + + case = createEclSum("CSV" , [("FOPT", None , 0) , + ("FOPR" , None , 0), + ("AARQ" , None , 10), + ("RGPT" , None ,1)]) + + node1 = case.smspec_node( "FOPT" ) + self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) + + node2 = case.smspec_node( "AARQ:10" ) + self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) + self.assertEqual( node2.getNum( ) , 10 ) + + node3 = case.smspec_node("RGPT:1") + self.assertEqual( node3.varType( ) , EclSumVarType.ECL_SMSPEC_REGION_VAR ) + self.assertEqual( node3.getNum( ) , 1 ) + self.assertTrue( node3.isTotal( )) + + self.assertLess( node1, node3 ) + self.assertGreater( node2, node3 ) + self.assertEqual( node1, node1 ) + self.assertNotEqual( node1, node2 ) + + with self.assertRaises(TypeError): + a = node1 < 1 + + def test_csv_export(self): + case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + sep = ";" + with TestAreaContext("ecl/csv"): + case.exportCSV( "file.csv" , sep = sep) + self.assertTrue( os.path.isfile( "file.csv" ) ) + input_file = csv.DictReader( open("file.csv") , delimiter = sep ) + for row in input_file: + self.assertIn("DAYS", row) + self.assertIn("DATE", row) + self.assertIn("FOPT", row) + self.assertIn("FOPR", row) + self.assertEqual( len(row) , 4 ) + break + + + + with TestAreaContext("ecl/csv"): + case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep) + self.assertTrue( os.path.isfile( "file.csv" ) ) + input_file = csv.DictReader( open("file.csv") , delimiter=sep) + for row in input_file: + self.assertIn("DAYS", row) + self.assertIn("DATE", row) + self.assertIn("FOPT", row) + self.assertEqual( len(row) , 3 ) + break + + + + with TestAreaContext("ecl/csv"): + date_format = "%y-%m-%d" + sep = "," + case.exportCSV( "file.csv" , keys = ["F*"] , sep=sep , date_format = date_format) + self.assertTrue( os.path.isfile( "file.csv" ) ) + with open("file.csv") as f: + time_index = -1 + for line in f.readlines(): + tmp = line.split( sep ) + self.assertEqual( len(tmp) , 4) + + if time_index >= 0: + d = datetime.datetime.strptime( tmp[1] , date_format ) + self.assertEqual( case.iget_date( time_index ) , d ) + + time_index += 1 + + + def test_solve(self): + length = 100 + case = create_case() + self.assert_solve( case ) + + def assert_solve(self, case): + with self.assertRaises( KeyError ): + case.solveDays( "MISSING:KEY" , 0.56) + + sol = case.solveDays( "FOPT" , 150 ) + self.assertEqual( len(sol) , 0 ) + + sol = case.solveDays( "FOPT" , -10 ) + self.assertEqual( len(sol) , 0 ) + + sol = case.solveDays( "FOPT" , 50 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50 ) + + sol = case.solveDays( "FOPT" , 50.50 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50.50 ) + + sol = case.solveDays( "FOPR" , 50.90 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50.00 + 1.0/86400 ) + + sol = case.solveDates("FOPR" , 50.90) + t = case.getDataStartTime( ) + datetime.timedelta( days = 50 ) + datetime.timedelta( seconds = 1 ) + self.assertEqual( sol[0] , t ) + + sol = case.solveDays( "FOPR" , 50.90 , rates_clamp_lower = False) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 51.00 ) + + sol = case.solveDays( "FGPT" ,25.0) + self.assertEqual( len(sol) , 2 ) + self.assertFloatEqual( sol[0] , 25.00 ) + self.assertFloatEqual( sol[1] , 75.00 ) + + sol = case.solveDates( "FGPT" , 25 ) + self.assertEqual( len(sol) , 2 ) + t0 = case.getDataStartTime( ) + t1 = t0 + datetime.timedelta( days = 25 ) + t2 = t0 + datetime.timedelta( days = 75 ) + self.assertEqual( sol[0] , t1 ) + self.assertEqual( sol[1] , t2 ) + + + def test_ecl_sum_vector_algebra(self): + scalar = 0.78 + addend = 2.718281828459045 + + case = create_case() + with self.assertRaises( KeyError ): + case.scaleVector( "MISSING:KEY" , scalar) + case.shiftVector( "MISSING:KEY" , addend) + + # scale all vectors with scalar + for key in case.keys(): + x = case.get_values(key) # get vector key + case.scaleVector(key , scalar) + y = case.get_values(key) + x = x * scalar # numpy vector scaling + for i in range(len(x)): + self.assertFloatEqual(x[i], y[i]) + + # shift all vectors with addend + for key in case.keys(): + x = case.get_values(key) # get vector key + case.shiftVector(key , addend) + y = case.get_values(key) + x = x + addend # numpy vector shifting + for i in range(len(x)): + self.assertFloatEqual(x[i], y[i]) + + + def test_different_names(self): + case = create_case() + with TestAreaContext("sum_different"): + case.fwrite( ) + shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC") + with self.assertRaises(IOError): + case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY") + + with self.assertRaises(IOError): + case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY") + + case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" ) + self.assert_solve( case2 ) + + def test_invalid(self): + case = create_case() + with TestAreaContext("sum_invalid"): + case.fwrite( ) + with open("CASE.txt", "w") as f: + f.write("No - this is not EclKW file ....") + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" ) + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" ) + + kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT) + kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT) + + with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + kw2.fwrite( f ) + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW") + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" ) + + + def test_kw_vector(self): + case1 = create_case() + case2 = createEclSum("CSV" , [("FOPR", None , 0) , ("FOPT" , None , 0), ("FWPT" , None , 0)], + sim_length_days = 100, + num_report_step = 10, + num_mini_step = 10, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FWPT" : fgpt }) + + kw_list = EclSumKeyWordVector( case1 ) + kw_list.add_keyword("FOPT") + kw_list.add_keyword("FGPT") + kw_list.add_keyword("FOPR") + + t = case1.getDataStartTime( ) + datetime.timedelta( days = 43 ); + data = case1.get_interp_row( kw_list , t ) + for d1,d2 in zip(data, [ case1.get_interp("FOPT", date = t), + case1.get_interp("FOPT", date = t), + case1.get_interp("FOPT", date = t) ]): + + self.assertFloatEqual(d1,d2) + + tmp = [] + for key in kw_list: + tmp.append(key) + + for (k1,k2) in zip(kw_list,tmp): + self.assertEqual(k1,k2) + + kw_list2 = kw_list.copy(case2) + self.assertIn("FOPT", kw_list2) + self.assertIn("FOPR", kw_list2) + self.assertIn("FGPT", kw_list2) + data2 = case2.get_interp_row( kw_list2 , t ) + + self.assertEqual(len(data2), 3) + self.assertEqual(data[0], data2[0]) + self.assertEqual(data[2], data2[2]) + + with TestAreaContext("sum_vector"): + with cwrap.open("f1.txt","w") as f: + case1.dumpCSVLine(t, kw_list, f) + + with cwrap.open("f2.txt", "w") as f: + case2.dumpCSVLine(t,kw_list2,f) + + with open("f1.txt") as f: + d1 = f.readline().split(",") + + with open("f2.txt") as f: + d2 = f.readline().split(",") + + self.assertEqual(d1[0],d2[0]) + self.assertEqual(d1[2],d2[2]) + self.assertEqual(d2[1],"") + + + + def test_vector_select_all(self): + case = create_case() + ecl_sum_vector = EclSumKeyWordVector(case, True) + keys = case.keys() + self.assertEqual( len(keys), len(ecl_sum_vector)) + for key in keys: + self.assertIn(key, ecl_sum_vector) + + + def test_time_range(self): + case = create_case() + with self.assertRaises(ValueError): + case.time_range(num_timestep = 1) + + time_range = case.time_range( num_timestep = 10) + self.assertEqual( len(time_range), 10) + self.assertEqual( time_range[0], case.get_data_start_time()) + self.assertEqual( time_range[-1], case.get_end_time()) + + + def test_resample(self): + case = create_case() + time_vector = case.alloc_time_vector( False ) + case2 = case.resample( "RS", time_vector) + time_vector_resample = case2.alloc_time_vector(False) + first_diff = time_vector_resample.first_neq( time_vector) + self.assertEqual( time_vector_resample, time_vector) + + + + # The purpose of this test is to reproduce a slightly contrived error situation. + # + # 1. A history simulation is created and stored somewhere in the + # filesystem. + # + # 2. We create a prediction, which has 'RESTART' reference to + # the history case. + # + # 3. The prediction case is loaded from disk, with a cwd different from the + # location of the predition case. + # + # This configuration would previously lead to a bug in the path used to + # resolve the history case, and the history would silently be ignored. + + def test_restart_abs_path(self): + with TestAreaContext("restart_test"): + history = create_case(case = "HISTORY") + history.fwrite() + + pred_path = "prediction" + create_prediction(history, pred_path) + + pred = EclSum(os.path.join(pred_path, "PREDICTION")) + # The restart case has a maximum length of 72 characters, depending + # on the path used for $TMP and so on we do not really know here if + # the restart_case has been set or not. + if pred.restart_case: + self.assertTrue(isinstance(pred.restart_case, EclSum)) + self.assertEqual(pred.restart_case.case, os.path.join(os.getcwd(), history.case)) + self.assertEqual(pred.restart_step, history.last_report) + + length = pred.sim_length + pred_times = pred.alloc_time_vector(False) + hist_times = history.alloc_time_vector(False) + + for index in range(len(hist_times)): + self.assertEqual(hist_times[index], pred_times[index]) + + + + + def test_restart_too_long_history_path(self): + with TestAreaContext("restart_test_too_fucking_long_path_for_the_eclipse_restart_keyword_1234567890123456789012345678901234567890"): + history = create_case(case = "HISTORY") + history.fwrite() + + pred_path = "prediction" + create_prediction(history, pred_path) + + pred = EclSum(os.path.join(pred_path, "PREDICTION")) + self.assertIsNone(pred.restart_case) + + + def test_restart_perm_denied(self): + with TestAreaContext("restart_test"): + with pushd("history/case1"): + history = create_case(case = "HISTORY") + history.fwrite() + + prediction = create_case( case = "PREDICTION", restart_case = "history/case1/HISTORY", data_start = history.end_date) + prediction.fwrite() + + os.chmod("history", 0) + + # This just tests that we can create a summary instance even if we do not + # have access to load the history case. + pred = EclSum("PREDICTION") + + os.chmod("history", stat.S_IRWXU) + + + def test_units(self): + case = create_case() + self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) + + + # We do not really have support for writing anything else than the + # default MERIC unit system. To be able to test the read functionality + # we therefor monkey-patch the summary files in place. + with TestAreaContext("unit_test"): + case = create_case("UNITS") + case.fwrite() + case2 = EclSum("UNITS") + + kw_list = [] + f = EclFile("UNITS.SMSPEC") + for kw in f: + if kw.name == "INTEHEAD": + kw[0] = 3 + kw_list.append(kw.copy()) + + f.close() + with openFortIO("UNITS.SMSPEC", mode = FortIO.WRITE_MODE) as f: + for kw in kw_list: + kw.fwrite(f) + + + case = EclSum("UNITS") + self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_LAB_UNITS) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py new file mode 100644 index 0000000000..2ab3a5fa31 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py @@ -0,0 +1,532 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +import datetime + +from unittest import skipIf, skipUnless, skipIf + +from ecl.eclfile import EclFile +from ecl.summary import EclSum +from ecl import EclUnitTypeEnum + +from ecl.util.util import StringList, TimeVector, DoubleVector, CTime + +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test +import csv + +base = "ECLIPSE" +path = "Statoil/ECLIPSE/Gurbat" +case = "%s/%s" % (path, base) + + + + +def sum_get(*args): + sum = args[0] + key = args[1] + vec = sum[key] + + +@statoil_test() +class SumTest(EclTest): + def setUp(self): + self.case = self.createTestPath(case) + self.ecl_sum = EclSum(self.case) + + self.assertIsInstance(self.ecl_sum, EclSum) + + + def test_load(self): + self.assertIsNotNone(self.ecl_sum, "Load failed") + + + def test_invalid(self): + with self.assertRaises(IOError): + sum = EclSum("Does/not/exist") + + + def test_KeyError(self): + sum = self.ecl_sum + with self.assertRaises(KeyError): + v = sum["KeyMissing"] + + with self.assertRaises(KeyError): + v = sum.get_interp("Missing" , days = 750) + + with self.assertRaises(KeyError): + v = sum.get_interp_vector("Missing" , days_list = [750]) + + + + def test_contains(self): + self.assertTrue( "FOPT" in self.ecl_sum) + self.assertFalse( "MISSING" in self.ecl_sum ) + + + def test_interp(self): + sum = self.ecl_sum + + self.assertAlmostEqual(sum.get_interp("WWCT:OP_3", days=750), 0.11719122) + self.assertAlmostEqual(sum.get_interp("WWCT:OP_3", date=datetime.date(2004, 1, 1)), 0.603358387947) + + v = sum.get_interp_vector("WOPT:OP_1", days_list=[100, 200, 400]) + self.assertAlmostEqualList([805817.11875, 1614955.34677419, 3289267.67857143 ], v) + + v = sum.get_interp_vector("WGPT:OP_2", date_list=[datetime.date(2002, 1, 1), datetime.date(2003, 1, 1), datetime.date(2004, 1, 1)]) + self.assertAlmostEqualList(v, [8.20773632e+08, 9.68444032e+08, 1.02515213e+09]) + + self.assertEqual(sum.get_interp("FOPT" , days = 0) , 0) + + self.assertEqual(sum.get_interp("WOPR:OP_1" , days = 0) , 0) + self.assertEqual(sum.get_interp("WOPR:OP_1" , date=datetime.date(2000,1,1)) , 0) + + self.assertEqual(sum.get_interp("WOPR:OP_1" , days = 31) , 7996) + self.assertEqual(sum.get_interp("WOPR:OP_1" , date=datetime.date(2000,2,1)) , 7996) + + FPR = sum["FPR"] + self.assertFloatEqual(sum.get_interp("FPR" , days = 0) , FPR[0].value) + self.assertFloatEqual(sum.get_interp("FPR" , days = 31) , FPR[1].value) + + with self.assertRaises(ValueError): + sum.get_interp("WOPR:OP_1") + + with self.assertRaises(ValueError): + sum.get_interp("WOPR:OP_1" , days=10 , date = datetime.date(2000,1,1)) + + + def test_LLINEAR(self): + sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/LGRISSUE/EM-LTAA-ISEG_CARFIN_NWPROPS")) + self.assertTrue( sum.has_key("LLINEARS") ) + + + + def test_wells(self): + wells = self.ecl_sum.wells() + wells.sort() + self.assertListEqual([well for well in wells], ["OP_1", "OP_2", "OP_3", "OP_4", "OP_5", "WI_1", "WI_2", "WI_3"]) + + wells = self.ecl_sum.wells(pattern="*_3") + wells.sort() + self.assertListEqual([well for well in wells], ["OP_3", "WI_3"]) + + groups = self.ecl_sum.groups() + groups.sort() + self.assertListEqual([group for group in groups], ['GMWIN', 'OP', 'WI']) + + + def test_last( self ): + last = self.ecl_sum.get_last("FOPT") + self.assertFloatEqual(last.value, 38006336.0) + self.assertFloatEqual(last.days, 1826.0) + self.assertEqual(last.date, datetime.datetime(2004, 12, 31, 0, 0, 0)) + + self.assertFloatEqual(self.ecl_sum.get_last_value("FGPT"), 6605249024.0) + self.assertEqual( len(self.ecl_sum) , 63 ) + + + def test_dates( self ): + sum = self.ecl_sum + d = sum.dates + + self.assertEqual(d[0], datetime.datetime(2000, 1, 1, 0, 0, 0)) + self.assertEqual(d[62], datetime.datetime(2004, 12, 31, 0, 0, 0)) + self.assertEqual(len(d), 63) + self.assertEqual(d[25], datetime.datetime(2001, 12, 1, 0, 0, 0)) + self.assertEqual(sum.iget_date(25), datetime.datetime(2001, 12, 1, 0, 0, 0)) + + mpl_dates = sum.mpl_dates + self.assertAlmostEqual(mpl_dates[25], 730820) + + days = sum.days + self.assertAlmostEqual(days[50], 1461) + + self.assertEqual(sum.start_time, datetime.datetime(2000, 1, 1, 0, 0, 0)) + self.assertEqual(sum.end_time, datetime.datetime(2004, 12, 31, 0, 0, 0)) + self.assertTrue(sum.check_sim_time(datetime.datetime(2004, 12, 31, 0, 0, 0))) + self.assertEqual(sum.end_date , datetime.date(2004, 12, 31)) + + + + def test_dates2( self ): + sum = EclSum(self.createTestPath("Statoil/ECLIPSE/FF12/FF12_2013B3_AMAP2")) + self.assertEqual(sum.end_date , datetime.date(2045, 1, 1)) + + + + + + def test_keys(self): + sum = self.ecl_sum + self.assertRaises(KeyError, sum.__getitem__, "BJARNE") + + v = sum["FOPT"] + self.assertEqual(len(v), 63) + + + def test_index(self): + sum = self.ecl_sum + index = sum.get_key_index("TCPUDAY") + self.assertEqual(index, 10239) + + + def test_report(self): + sum = self.ecl_sum + self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 1)), 10) + self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 3)), -1) + self.assertEqual(sum.get_report(date=datetime.date(1980, 10, 3)), -1) + self.assertEqual(sum.get_report(date=datetime.date(2012, 10, 3)), -1) + + self.assertEqual(sum.get_report(days=91), 3) + self.assertEqual(sum.get_report(days=92), -1) + self.assertAlmostEqual(sum.get_interp("FOPT", days=91), sum.get_from_report("FOPT", 3)) + + self.assertEqual(sum.first_report, 1) + self.assertEqual(sum.last_report, 62) + + self.assertEqual(sum.get_report_time(10), datetime.date(2000, 10, 1)) + self.assertFloatEqual(sum.get_from_report("FOPT", 10), 6.67447e+06) + + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test skipped") + def test_fwrite(self): + # todo: What is tested here? + # work_area = TestArea("python/sum-test/fwrite", True) + with TestAreaContext("python/sum-test/fwrite") as work_area: + self.ecl_sum.fwrite(ecl_case="CASE") + self.assertTrue(True) + + + def test_block(self): + sum = self.ecl_sum + index_ijk = sum.get_key_index("BPR:15,28,1") + index_num = sum.get_key_index("BPR:1095") + self.assertEqual(index_ijk, index_num) + + + def test_restart(self): + hist = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/history/T07-4A-W2011-18-P1")) + base = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE")) + pred = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE"), include_restart=False) + + self.assertIsNotNone(hist) + self.assertIsNotNone(base) + self.assertIsNotNone(pred) + + + def test_case1(self ): + self.assertTrue(self.ecl_sum.path == self.createTestPath(path)) + self.assertTrue(self.ecl_sum.base == base) + self.assertTrue(self.ecl_sum.case == self.createTestPath(case)) + self.assertTrue(self.ecl_sum.abs_path == self.createTestPath(path)) + + + def test_case2( self ): + cwd = os.getcwd() + os.chdir(self.createTestPath(path)) + sum = EclSum(base) + self.assertIsNone(sum.path) + self.assertTrue(sum.base == base) + self.assertTrue(sum.case == base) + self.assertTrue(sum.abs_path == self.createTestPath(path)) + os.chdir(cwd) + + + def test_var_properties( self ): + sum = self.ecl_sum + self.assertRaises(KeyError, sum.smspec_node, "BJARNE") + + node = sum.smspec_node("FOPT") + self.assertTrue(node.isTotal()) + self.assertFalse(node.isHistorical()) + + node = sum.smspec_node("FOPR") + self.assertFalse(node.isTotal()) + self.assertFalse(node.isHistorical()) + self.assertTrue(node.keyword == "FOPR") + + node = sum.smspec_node("FOPRH") + self.assertFalse(node.isTotal()) + self.assertTrue(node.isHistorical()) + self.assertTrue(node.isRate()) + self.assertTrue(node.keyword == "FOPRH") + + node = sum.smspec_node("WOPR:OP_1") + self.assertFalse(node.isTotal()) + self.assertTrue(node.isRate()) + self.assertTrue(node.keyword == "WOPR") + + node = sum.smspec_node("WOPT:OP_1") + self.assertTrue(node.isTotal()) + self.assertFalse(node.isRate()) + self.assertTrue(node.unit == "SM3") + self.assertTrue(node.wgname == "OP_1") + self.assertTrue(node.keyword == "WOPT") + + self.assertTrue(sum.unit("FOPR") == "SM3/DAY") + + node = sum.smspec_node("FOPTH") + self.assertTrue(node.isTotal()) + self.assertFalse(node.isRate()) + self.assertIsNone(node.wgname) + node = sum.smspec_node("BPR:1095") + self.assertEqual(node.num, 1095) + + def test_stringlist_gc(self): + sum = EclSum(self.case) + wells = sum.wells() + well1 = wells[0] + del wells + self.assertTrue(well1 == "OP_1") + + + def test_stringlist_reference(self): + sum = EclSum(self.case) + wells = sum.wells() + self.assertListEqual([well for well in wells], ['OP_1', 'OP_2', 'OP_3', 'OP_4', 'OP_5', 'WI_1', 'WI_2', 'WI_3']) + self.assertIsInstance(wells, StringList) + + + def test_stringlist_setitem(self): + sum = EclSum(self.case) + wells = sum.wells() + wells[0] = "Bjarne" + well0 = wells[0] + self.assertTrue(well0 == "Bjarne") + self.assertTrue(wells[0] == "Bjarne") + wells[0] = "XXX" + self.assertTrue(well0 == "Bjarne") + self.assertTrue(wells[0] == "XXX") + + + def test_segment(self): + sum = EclSum(self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4")) + segment_vars = sum.keys("SOFR:F-8:*") + self.assertIn("SOFR:F-8:1", segment_vars) + for var in segment_vars: + tmp = var.split(":") + nr = int(tmp[2]) + self.assertTrue(nr >= 0) + + def test_return_types(self): + self.assertIsInstance(self.ecl_sum.alloc_time_vector(True), TimeVector) + key_index = self.ecl_sum.get_general_var_index("FOPT") + self.assertIsInstance(self.ecl_sum.alloc_data_vector(key_index, True), DoubleVector) + + def test_timeRange(self): + sum = EclSum(self.case) + with self.assertRaises(TypeError): + trange = sum.timeRange(interval = "1") + trange = sum.timeRange(interval = "1X") + trange = sum.timeRange(interval = "YY") + trange = sum.timeRange(interval = "MY") + + with self.assertRaises(ValueError): + trange = sum.timeRange( start = datetime.datetime(2000,1,1) , end = datetime.datetime(1999,1,1) ) + + sim_start = datetime.datetime(2000, 1, 1, 0, 0, 0) + sim_end = datetime.datetime(2004, 12, 31, 0, 0, 0) + trange = sum.timeRange( interval = "1Y") + self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) + self.assertTrue( trange[1] == datetime.date( 2001 , 1 , 1 )) + self.assertTrue( trange[2] == datetime.date( 2002 , 1 , 1 )) + self.assertTrue( trange[3] == datetime.date( 2003 , 1 , 1 )) + self.assertTrue( trange[4] == datetime.date( 2004 , 1 , 1 )) + self.assertTrue( trange[5] == datetime.date( 2005 , 1 , 1 )) + + trange = sum.timeRange( interval = "1M") + self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) + + trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15), interval = "1M") + self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) + + trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15) , end = datetime.date( 2003 , 1 , 15), interval = "1M") + self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2003 , 2 , 1 )) + + trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15) , end = datetime.datetime( 2003 , 1 , 15,0,0,0), interval = "1M") + self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2003 , 2 , 1 )) + + + + # Loading this dataset is a test of loading a case where one report step is missing. + def test_Heidrun(self): + sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS")) + self.assertEqual( 452 , len(sum)) + self.assertFloatEqual( 1.8533144e+8 , sum.get_last_value("FOPT")) + + trange = sum.timeRange( start = datetime.date( 2015 , 1 , 1), interval = "1M") + self.assertTrue( trange[0] == datetime.date( 2016 , 2 , 1 )) + for t in trange: + sum.get_interp( "FOPT" , date = t ) + + + + def test_regularProduction(self): + sum = EclSum(self.case) + with self.assertRaises(TypeError): + trange = TimeVector.createRegular( sum.start_time , sum.end_time , "1M" ) + prod = sum.blockedProduction("FOPR" , trange) + + with self.assertRaises(KeyError): + trange = TimeVector.createRegular( sum.start_time , sum.end_time , "1M" ) + prod = sum.blockedProduction("NoNotThis" , trange) + + trange = sum.timeRange(interval = "2Y") + self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2006 , 1 , 1 )) + + trange = sum.timeRange(interval = "5Y") + self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) + self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) + + trange = sum.timeRange(interval = "6M") + wprod1 = sum.blockedProduction("WOPT:OP_1" , trange) + wprod2 = sum.blockedProduction("WOPT:OP_2" , trange) + wprod3 = sum.blockedProduction("WOPT:OP_3" , trange) + wprod4 = sum.blockedProduction("WOPT:OP_4" , trange) + wprod5 = sum.blockedProduction("WOPT:OP_5" , trange) + + fprod = sum.blockedProduction("FOPT" , trange) + gprod = sum.blockedProduction("GOPT:OP" , trange) + wprod = wprod1 + wprod2 + wprod3 + wprod4 + wprod5 + for (w,f,g) in zip(wprod, fprod,gprod): + self.assertFloatEqual( w , f ) + self.assertFloatEqual( w , g ) + + + + def test_writer(self): + writer = EclSum.writer("CASE" , datetime.date( 2000 , 1 , 1) , 10 , 10 , 5) + self.assertIsInstance(self.ecl_sum, EclSum) + + + writer.addVariable( "FOPT" ) + self.assertTrue( writer.has_key( "FOPT" )) + + writer.addTStep( 1 , 100 ) + + + def test_aquifer(self): + case = EclSum( self.createTestPath( "Statoil/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) + self.assertTrue( "AAQR:2" in case ) + + + def test_restart_mapping(self): + history = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) + total = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0") , include_restart = True) + + history_dates = history.get_dates( ) + total_dates = total.get_dates( ) + for i in range(len(history_dates)): + self.assertEqual( history_dates[i] , total_dates[i] ) + + + keys = history.keys( pattern = "W*") + for key in keys: + if key in total: + self.assertEqual( history.iget( key , 5 ) , total.iget( key , 5 )) + + self.assertFalse( "WGPR:NOT_21_D" in history ) + self.assertTrue( "WGPR:NOT_21_D" in total ) + + self.assertEqual( total.iget( "WGPR:NOT_21_D", 5) , 0) # Default value + + def test_write(self): + with TestAreaContext("my_space") as area: + intersect_summary = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) + self.assertIsNotNone(intersect_summary) + + write_location = os.path.join(os.getcwd(), "CASE") + intersect_summary.fwrite(ecl_case=write_location) + + reloaded_summary = EclSum(write_location) + self.assertEqual(intersect_summary.keys(), reloaded_summary.keys()) + + def test_ix_case(self): + intersect_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL")) + self.assertIsNotNone(intersect_summary) + + self.assertTrue( + "HWELL_PROD" in + [intersect_summary.smspec_node(key).wgname for key in intersect_summary.keys()] + ) + + eclipse_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/ECL100/E100_CREATE_REGION_AROUND_WELL")) + self.assertIsNotNone(eclipse_summary) + + hwell_padder = lambda key : key if key.split(":")[-1] != "HWELL_PR" else key + "OD" + self.assertEqual( + intersect_summary.keys("WWCT*"), + list(map(hwell_padder, eclipse_summary.keys("WWCT*"))) + ) + + def test_ix_write(self): + for data_set in [ + "Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL", + "Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC" + ]: + + with TestAreaContext("my_space" + data_set.split("/")[-1]) as area: + intersect_summary = EclSum(self.createTestPath(data_set)) + self.assertIsNotNone(intersect_summary) + + write_location = os.path.join(os.getcwd(), "CASE") + intersect_summary.fwrite(ecl_case=write_location) + + reloaded_summary = EclSum(write_location) + self.assertEqual( + list(intersect_summary.keys()), + list(reloaded_summary.keys()) + ) + + def test_ix_caseII(self): + troll_summary = EclSum( self.createTestPath("Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC")) + self.assertIsNotNone(troll_summary) + self.assertTrue("WMCTL:Q21BH1" in list(troll_summary.keys())) + + + def test_resample(self): + time_points = TimeVector() + start_time = self.ecl_sum.get_data_start_time() + end_time = self.ecl_sum.get_end_time() + delta = end_time - start_time + N = 25 + time_points.initRange( CTime(start_time), + CTime(end_time), + CTime(int(delta.total_seconds()/(N - 1)))) + time_points.append(CTime(end_time)) + resampled = self.ecl_sum.resample( "OUTPUT_CASE", time_points ) + + for key in self.ecl_sum.keys(): + self.assertIn( key, resampled ) + + self.assertEqual(self.ecl_sum.get_data_start_time(), resampled.get_data_start_time()) + delta = self.ecl_sum.get_end_time() - resampled.get_end_time() + self.assertTrue( delta.total_seconds() <= 1 ) + + keys = ["FOPT", "FOPR", "BPR:15,28,1", "WGOR:OP_1"] + for key in keys: + for time_index,t in enumerate(time_points): + self.assertFloatEqual(resampled.iget( key, time_index), self.ecl_sum.get_interp_direct( key, t)) + + + def test_summary_units(self): + self.assertEqual(self.ecl_sum.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt new file mode 100644 index 0000000000..42aa148046 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt @@ -0,0 +1,28 @@ +set(TEST_SOURCES + __init__.py + test_convex_hull.py + test_cpolyline.py + test_cpolyline_collection.py + test_geometry_tools.py + test_intersection.py + test_point_in_polygon.py + test_polygon_slicing.py + test_polyline.py + test_surface.py + test_geo_pointset.py + test_geo_region.py +) + +add_python_package("python.tests.geometry_tests" ${PYTHON_INSTALL_PREFIX}/tests/geometry_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.geometry_tests.test_geo_pointset.GeoPointsetTest) +addPythonTest(tests.geometry_tests.test_geo_region.GeoRegionTest) +addPythonTest(tests.geometry_tests.test_surface.SurfaceTest) +addPythonTest(tests.geometry_tests.test_polyline.PolylineTest) +addPythonTest(tests.geometry_tests.test_intersection.IntersectionTest) +addPythonTest(tests.geometry_tests.test_convex_hull.ConvexHullTest) +addPythonTest(tests.geometry_tests.test_point_in_polygon.PointInPolygonTest) +addPythonTest(tests.geometry_tests.test_polygon_slicing.PolygonSlicingTest) +addPythonTest(tests.geometry_tests.test_cpolyline.CPolylineTest) +addPythonTest(tests.geometry_tests.test_cpolyline_collection.CPolylineCollectionTest) +addPythonTest(tests.geometry_tests.test_geometry_tools.GeometryToolsTest ) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/__init__.py b/ThirdParty/Ert/python/tests/geometry_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py b/ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py new file mode 100644 index 0000000000..352d830f40 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py @@ -0,0 +1,27 @@ +from ecl.util.geometry.geometry_tools import GeometryTools +from tests import EclTest + + +class ConvexHullTest(EclTest): + + def test_ccw(self): + p1 = (0, 0) + p2 = (1, 0) + p3 = (0, 1) + p4 = (0, 2) + + + self.assertTrue(GeometryTools.ccw(p1, p2, p3) > 0) # Counter-clockwise + self.assertTrue(GeometryTools.ccw(p1, p3, p2) < 0) # Clockwise + self.assertTrue(GeometryTools.ccw(p1, p3, p4) == 0) # Colinear + + + def test_convex_hull(self): + points = [(0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0.5, 0.5), (0.25, 0.25), (0.5, 1.25), (0.5, 0.75)] + result = GeometryTools.convexHull(points) + self.assertEqual(result, [(0, 0), (0, 1), (0.5, 1.25), (1, 1), (1, 0)]) + + + points = [(0, -0.5), (0, 0.5), (-0.5, 0), (0.5, 0), (0, 0), (0.5, 0.5)] + result = GeometryTools.convexHull(points) + self.assertEqual(result, [(-0.5, 0), (0, 0.5), (0.5, 0.5), (0.5, 0), (0, -0.5)]) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py new file mode 100644 index 0000000000..39708f2cc1 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py @@ -0,0 +1,172 @@ +import math + +from ecl.util.geometry import CPolyline , Polyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class CPolylineTest(EclTest): + def setUp(self): + self.polyline1 = self.createTestPath("local/geometry/pol11.xyz") + self.polyline2 = self.createTestPath("local/geometry/pol8.xyz") + self.polyline3 = self.createTestPath("local/geometry/pol8_noend.xyz") + + + + def test_construction(self): + polyline = CPolyline() + self.assertEqual( len(polyline) , 0 ) + + with self.assertRaises(IOError): + CPolyline.createFromXYZFile( "Does/not/exist" ) + + p1 = CPolyline.createFromXYZFile( self.polyline1 ) + self.assertEqual( len(p1) , 13 ) + x,y = p1[-1] + self.assertEqual(x , 389789.263184) + self.assertEqual(y , 6605784.945099) + + p2 = CPolyline.createFromXYZFile( self.polyline2 ) + self.assertEqual( len(p2) , 20 ) + x,y = p2[-1] + self.assertEqual(x , 396056.314697) + self.assertEqual(y , 6605835.119461) + + p3 = CPolyline.createFromXYZFile( self.polyline3 ) + self.assertEqual( len(p3) , 20 ) + x,y = p3[-1] + self.assertEqual(x , 396056.314697) + self.assertEqual(y , 6605835.119461) + + + + def test_front(self): + polyline = CPolyline() + polyline.addPoint( 1 , 1 ) + polyline.addPoint( 0 , 0 , front = True ) + self.assertEqual( len(polyline) , 2 ) + + x,y = polyline[0] + self.assertEqual(x,0) + self.assertEqual(y,0) + + x,y = polyline[1] + self.assertEqual(x,1) + self.assertEqual(y,1) + + + def test_equal(self): + pl1 = CPolyline(name = "Poly1" , init_points = [(0,0) , (1,1) , (2,2)]) + pl2 = CPolyline(name = "Poly2" , init_points = [(0,0) , (1,1) , (2,2)]) + pl3 = CPolyline(init_points = [(0,0) , (1,1) , (2,3)]) + + self.assertEqual( pl1 , pl1 ) + self.assertEqual( pl1 , pl2 ) + self.assertFalse( pl1 == pl3 ) + + + def test_length(self): + polyline = CPolyline( init_points = [(0,1)]) + self.assertEqual( polyline.segmentLength() , 0 ) + + polyline = CPolyline( init_points = [(0,0) , (1,0) , (1,1) , (2,2)]) + self.assertEqual( polyline.segmentLength() , 2 + math.sqrt(2)) + + + def test_extend_to_bbox(self): + bbox = [(0,0) , (10,0) , (10,10) , (0,10)] + + polyline = CPolyline( init_points = [(11,11) , (13,13)]) + with self.assertRaises(ValueError): + polyline.extendToBBox( bbox , start = False ) + + + polyline = CPolyline( init_points = [(1,1) , (3,3)]) + + line1 = polyline.extendToBBox( bbox , start = True ) + self.assertEqual( line1 , CPolyline( init_points = [(1,1) , (0,0)])) + + line1 = polyline.extendToBBox( bbox , start = False ) + self.assertEqual( line1 , CPolyline( init_points = [(3,3) , (10,10)])) + + + + + def test_item(self): + polyline = CPolyline() + polyline.addPoint( 10 , 20 ) + self.assertEqual( len(polyline) , 1 ) + + with self.assertRaises(TypeError): + (x,y) = polyline["KEY"] + + with self.assertRaises(IndexError): + (x,y) = polyline[10] + + (x,y) = polyline[0] + self.assertEqual( x , 10 ) + self.assertEqual( y , 20 ) + + polyline.addPoint(20,20) + (x,y) = polyline[-1] + self.assertEqual( x , 20 ) + self.assertEqual( y , 20 ) + + + def test_cross_segment(self): + polyline = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) + # + # x + # | + # | + # | + # x-------x + # + + self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (0.5 , -0.5))) + self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (1.5 , 0.5))) + + self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , ( 0.5 , 1.5))) + self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , (-0.5 , 0.5))) + self.assertFalse(polyline.segmentIntersects( (0.5 , 1.5) , ( 1.5 , 1.5))) + + self.assertTrue( polyline.segmentIntersects( (1.0 , 1.0) , ( 1.5 , 1.5))) + self.assertTrue( polyline.segmentIntersects( ( 1.5 , 1.5) , (1.0 , 1.0))) + self.assertTrue( polyline.segmentIntersects( ( 1 , 0) , (1.0 , 1.0))) + + + + def test_intersects(self): + polyline1 = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) + polyline2 = CPolyline( init_points = [(0.50,0.50) , (1.50,0.50)]) + polyline3 = Polyline( init_points = [(0.50,0.50) , (1.50,0.50)]) + polyline4 = CPolyline( init_points = [(0.50,1.50) , (1.50,1.50)]) + + self.assertTrue( polyline1.intersects( polyline2 )) + self.assertTrue( polyline1.intersects( polyline3 )) + self.assertFalse( polyline1.intersects( polyline4 )) + + + def test_intersects2(self): + polyline = CPolyline( init_points = [(2,10),(2,100)]) + self.assertTrue( polyline.intersects( polyline )) + + + + def test_name(self): + p1 = CPolyline() + self.assertTrue( p1.getName() is None ) + + p2 = CPolyline( name = "Poly2" ) + self.assertEqual( p2.getName() , "Poly2") + + + def test_unzip(self): + pl = CPolyline( init_points = [(0,3) , (1,4) , (2,5)] ) + x,y = pl.unzip() + self.assertEqual(x , [0,1,2]) + self.assertEqual(y , [3,4,5]) + + + diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py new file mode 100644 index 0000000000..52819ce6a0 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py @@ -0,0 +1,134 @@ +import gc + +from ecl.util.geometry import CPolylineCollection , CPolyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.util import DoubleVector + +class CPolylineCollectionTest(EclTest): + + def test_construction(self): + pc = CPolylineCollection() + self.assertEqual(len(pc) , 0) + + + def test_add_polyline(self): + pc = CPolylineCollection() + pl = pc.createPolyline( name = "TestP" ) + self.assertTrue( isinstance(pl , CPolyline)) + self.assertEqual(len(pc) , 1) + self.assertTrue( "TestP" in pc ) + + with self.assertRaises(IndexError): + pl = pc[2] + + p0 = pc[0] + self.assertTrue( p0 == pl ) + + with self.assertRaises(KeyError): + pn = pc["missing"] + + pn = pc["TestP"] + self.assertTrue( pn == pl ) + + px = CPolyline( name = "TestP") + with self.assertRaises(KeyError): + pc.addPolyline( px ) + self.assertEqual(len(pc) , 1) + + + p2 = CPolyline( name = "Poly2") + pc.addPolyline( p2 ) + + self.assertEqual( len(pc) , 2 ) + self.assertTrue( "Poly2" in pc ) + + l = [] + for p in pc: + l.append(p) + self.assertEqual( len(pc) , 2 ) + + + points = [(0,1) , (1,1)] + pc.addPolyline( points , name = "XYZ") + self.assertTrue( "XYZ" in pc ) + + + + + def create_collection(self): + collection = CPolylineCollection() + p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)]) + p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)]) + collection.addPolyline( p1 ) + collection.addPolyline( p2 ) + + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + + return collection + + + def test_gc_polyline(self): + # This should test that the elements in the collection can be + # safely accessed, even after the polyline objects p1 and p2 + # from create_collection() have gone out of scope. + c = self.create_collection() + v = DoubleVector(initial_size = 10000) + + p1 = c[0] + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + p2 = c[1] + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + + + def get_polyline(self): + collection = self.create_collection() + return collection[0] + + + def test_gc_collection(self): + p1 = self.get_polyline() + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual( p1.getName() , "POLY1") + + def create_coll2(self): + coll1 = self.create_collection() + coll2 = coll1.shallowCopy() + coll1.addPolyline( CPolyline( name = "POLY3" , init_points = [(1,1) , (2,2) , (1,3) , (1,1)])) + + self.assertEqual(len(coll1) , 3) + self.assertTrue( "POLY3" in coll1 ) + + self.assertEqual(len(coll2) , 2) + self.assertFalse( "POLY3" in coll2 ) + + return coll2 + + + def test_shallow_copy(self): + coll2 = self.create_coll2() + self.assertEqual(len(coll2) , 2) + + p1 = coll2["POLY1"] + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + p2 = coll2["POLY2"] + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py new file mode 100644 index 0000000000..4f43df59da --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py @@ -0,0 +1,28 @@ +from ecl.util.geometry import GeoPointset, Surface +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class GeoPointsetTest(EclTest): + + def test_init(self): + gp = GeoPointset() + self.assertEqual(0, len(gp)) + + def test_repr(self): + gp = GeoPointset() + self.assertTrue(repr(gp).startswith('GeoPointset')) + + def test_from_surface(self): + srf_path = self.createTestPath("local/geometry/surface/valid_ascii.irap") + srf = Surface(srf_path) + gp = GeoPointset.fromSurface(srf) + self.assertEqual(3871, len(srf)) + self.assertEqual(len(srf), len(gp)) + + def test_getitem(self): + srf_path = self.createTestPath("local/geometry/surface/valid_ascii.irap") + srf = Surface(srf_path) + gp = GeoPointset.fromSurface(srf) + for i in (561, 1105, 1729, 2465, 2821): + self.assertEqual(gp[i], srf[i]) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py new file mode 100644 index 0000000000..c1d6533489 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py @@ -0,0 +1,89 @@ +from ecl.util.geometry import GeoRegion, GeoPointset, CPolyline, Surface +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class GeoRegionTest(EclTest): + + def test_init(self): + pointset = GeoPointset() + georegion = GeoRegion(pointset) + self.assertEqual(0, len(georegion)) + + def test_repr(self): + pointset = GeoPointset() + georegion = GeoRegion(pointset) + self.assertTrue(repr(georegion).startswith('GeoRegion')) + + @staticmethod + def small_surface(): + ny,nx = 12,12 + xinc,yinc = 1, 1 + xstart,ystart = -1, -1 + angle = 0.0 + s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) + return Surface(*s_args) + + def test_select_polygon(self): + surface = self.small_surface() + pointset = GeoPointset.fromSurface(surface) + georegion = GeoRegion(pointset) + self.assertEqual(0, len(georegion)) + points = [(-0.1,2.0), (1.9,8.1), (6.1,8.1), (9.1,5), (7.1,0.9)] + polygon = CPolyline(name='test_polygon', init_points=points) + picked = 52 # https://www.futilitycloset.com/2013/04/24/picks-theorem/ + georegion.select_inside(polygon) + self.assertEqual(picked, len(georegion)) + georegion.deselect_inside(polygon) + self.assertEqual(0, len(georegion)) + georegion.select_outside(polygon) + self.assertEqual(len(surface) - picked, len(georegion)) + georegion.deselect_outside(polygon) + self.assertEqual(0, len(georegion)) + + georegion.select_inside(polygon) + georegion.select_outside(polygon) + self.assertEqual(len(surface), len(georegion)) + georegion.deselect_inside(polygon) + georegion.deselect_outside(polygon) + self.assertEqual(0, len(georegion)) + + georegion.select_inside(polygon) + self.assertEqual(picked, len(georegion)) + internal_square = [(2.5,2.5), (2.5,6.5), (6.5,6.5), (6.5,2.5)] + georegion.deselect_inside(CPolyline(init_points=internal_square)) + self.assertEqual(picked - 4*4, len(georegion)) # internal square is 4x4 + + + def test_select_halfspace(self): + surface = self.small_surface() + pointset = GeoPointset.fromSurface(surface) + georegion = GeoRegion(pointset) + self.assertEqual(0, len(georegion)) + line = [(-0.1,2.0), (1.9,8.1)] + picked = 118 + georegion.select_above(line) + self.assertEqual(picked, len(georegion)) + georegion.deselect_above(line) + self.assertEqual(0, len(georegion)) + georegion.select_below(line) + self.assertEqual(len(surface) - picked, len(georegion)) + georegion.deselect_below(line) + self.assertEqual(0, len(georegion)) + + georegion.select_above(line) + georegion.select_below(line) + self.assertEqual(len(surface), len(georegion)) + georegion.deselect_above(line) + georegion.deselect_below(line) + self.assertEqual(0, len(georegion)) + + + def test_raises(self): + surface = self.small_surface() + pointset = GeoPointset.fromSurface(surface) + georegion = GeoRegion(pointset) + with self.assertRaises(ValueError): + georegion.select_above(((2,), (1, 3))) + with self.assertRaises(ValueError): + georegion.select_above((('not-a-number', 2), (1, 3))) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py new file mode 100644 index 0000000000..8e2d7587ff --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py @@ -0,0 +1,81 @@ +import math + +from ecl.util.geometry import Polyline, GeometryTools , CPolyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class GeometryToolsTest(EclTest): + + def test_distance(self): + p1 = (1,1) + p2 = (1,2,3) + with self.assertRaises(ValueError): + GeometryTools.distance( p1 , p2) + + with self.assertRaises(TypeError): + GeometryTools.distance( 1 , p2 ) + + p2 = (2,2) + self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(2)) + + p1 = (1,1,1) + p2 = (2,2,2) + self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(3)) + + + def test_join__polylines(self): + l1 = Polyline( init_points = [(0,1) , (1,1)]) + l2 = CPolyline( init_points = [(2,-1) , (2,0)]) + l3 = CPolyline( init_points = [(2,2) , (2,3)]) + l4 = Polyline( ) + l5 = CPolyline( init_points = [(0.5,0),(0.5,2)] ) + + with self.assertRaises( ValueError ): + GeometryTools.joinPolylines( l1 , l4 ) + + with self.assertRaises( ValueError ): + GeometryTools.joinPolylines( l4 , l1 ) + + self.assertIsNone( GeometryTools.joinPolylines( l1 , l5 )) + + self.assertEqual( GeometryTools.joinPolylines( l1 , l2 ) , [(1,1) , (2,0)] ) + + + def test_join_extend_polylines_onto(self): + l1 = Polyline( init_points = [(0,1) , (1,1)]) + l2 = CPolyline( init_points = [(2,0) , (2,2)]) + l3 = CPolyline( init_points = [(0.5 , 0) , (0.5 , 2)]) + l4 = Polyline( init_points = [(0,5) , (1,5)]) + l5 = Polyline( init_points = [(0,5)]) + + self.assertIsNone( GeometryTools.connectPolylines( l1 , l3 )) + + with self.assertRaises( ValueError ): + GeometryTools.connectPolylines( l1 , l5 ) + + with self.assertRaises( ValueError ): + GeometryTools.connectPolylines( l1 , l4 ) + + self.assertEqual( GeometryTools.connectPolylines( l1 , l2 ) , [(1,1) , (2,1)]) + + def test_ray_line_intersection(self): + p = GeometryTools.rayLineIntersection((0,0) , (1,0) , (5,-1),(5,1)) + self.assertEqual( p , (5,0)) + + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (-1,0) , (5,-1),(5,1)) ) + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,1) , (5,-1),(5,1)) ) + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,-1) , (5,-1),(5,1)) ) + + p = GeometryTools.rayLineIntersection((0,0) , (1,1) , (5,-6),(5,6)) + self.assertEqual( p , (5,5)) + + + def test_nearest_point(self): + l1 = Polyline( init_points = [(0,0) , (10,0)]) + + p = GeometryTools.nearestPointOnPolyline( (5 , 5) , l1 ) + self.assertEqual( p , (5 , 0) ) + + diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py b/ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py new file mode 100644 index 0000000000..189ad14614 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py @@ -0,0 +1,47 @@ +from ecl.util.geometry import GeometryTools +from tests import EclTest + + +class IntersectionTest(EclTest): + + def test_intersection(self): + + p1 = (0.0, 0.0) + p2 = (10.0, 0.0) + p3 = (5.0, -5.0) + p4 = (5.0, 5.0) + + self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p4), (5.0, 0.0)) + + p5 = (0.0, 5.0) + self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p5), (2.5, 0)) + + + self.assertEqual(GeometryTools.lineIntersection((0.0, 0.0), (1.0, 1.0), (0.0, 1.0), (1.0, 0.0)), (0.5, 0.5)) + + + def test_coincident(self): + p1 = (0.0, 0.0) + p2 = (10.0, 10.0) + + self.assertIsNone( GeometryTools.lineIntersection(p1, p2, p1, p2) ) + + + def test_parallel(self): + p1 = (0.0, 0.0) + p2 = (10.0, 0.0) + + p3 = (0.0, 1.0) + p4 = (10.0, 1.0) + + self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) + + + def test_intersection_outside_segments(self): + p1 = (0.0, 0.0) + p2 = (10.0, 0.0) + + p3 = (-1.0, -1.0) + p4 = (-1.0, 1.0) + + self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py b/ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py new file mode 100644 index 0000000000..469a58127d --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py @@ -0,0 +1,60 @@ +from ecl.util.geometry.geometry_tools import GeometryTools +from ecl.util.geometry.polyline import Polyline +from tests import EclTest + + +class PointInPolygonTest(EclTest): + + def test_point_in_polygon(self): + p1 = (0.5, 0.5) + p2 = (2, 2) + p3 = (1, 0.5) # on the edge + + poly1 = [(0, 0), (1, 0), (1, 1), (0, 1)] # Not explicitly closed + poly2 = [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] # explicitly closed + + self.assertTrue(GeometryTools.pointInPolygon(p1, poly1)) + self.assertTrue(GeometryTools.pointInPolygon(p1, poly2)) + + self.assertFalse(GeometryTools.pointInPolygon(p2, poly1)) + self.assertFalse(GeometryTools.pointInPolygon(p2, poly2)) + + self.assertTrue(GeometryTools.pointInPolygon(p3, poly1)) + + + def test_point_in_polyline(self): + p1 = (0.5, 0.5) + p2 = (2, 2) + + poly = Polyline() + poly.addPoint(0, 0) + poly.addPoint(1, 0) + poly.addPoint(1, 1) + poly.addPoint(0, 1) + poly.addPoint(0, 0) + + self.assertTrue(GeometryTools.pointInPolygon(p1, poly)) + self.assertTrue(GeometryTools.pointInPolygon(p1, poly)) + + self.assertFalse(GeometryTools.pointInPolygon(p2, poly)) + self.assertFalse(GeometryTools.pointInPolygon(p2, poly)) + + + def test_point_in_strange_polygon(self): + p1 = (0.5, 0.51) + p2 = (0.5, 0.49) + + poly = [(0,0), (0, 1), (0.6, 0.5), (0.4, 0.5), (1, 1), (1, 0)] + + self.assertFalse(GeometryTools.pointInPolygon(p1, poly)) + self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) + + + def test_point_in_polygon_with_3_element_points(self): + p1 = (0.5, 0.51, 0.2) + p2 = (0.5, 0.49, 0.1) + + poly = [(0,0,9), (0,1,9), (0.6,0.5), (0.4,0.5,9), (1,1), (1,0,9)] + + self.assertFalse(GeometryTools.pointInPolygon(p1, poly)) + self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py b/ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py new file mode 100644 index 0000000000..5d6e0f06ec --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py @@ -0,0 +1,139 @@ +from math import sqrt +from ecl.util.geometry.geometry_tools import GeometryTools +from tests import EclTest + + +class PolygonSlicingTest(EclTest): + + def test_slicing_internal_hull(self): + polygon = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4)] + edge = [(0,0) , (10,0) , (10,10), (0,10) , (0,0)] + + sliced = GeometryTools.slicePolygon(edge , polygon) + expected = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4),(2.0,4.0),(2,2)] + self.assertEqual(sliced, expected) + + + + def test_line_to_ray(self): + p0 = (0.0, 0.0) + p1 = (1.0, 1.0) + p2 = (1.0, 0.0) + + ray = GeometryTools.lineToRay(p0, p1) + self.assertEqual(ray, (1.0 / sqrt(2.0), 1.0 / sqrt(2.0))) + + ray = GeometryTools.lineToRay(p1, p0) + self.assertEqual(ray, (-1.0 / sqrt(2.0), -1.0 / sqrt(2.0))) + + ray = GeometryTools.lineToRay(p0, p2) + self.assertEqual(ray, (1.0, 0.0)) + + + def test_ray_line_intersection(self): + p0 = (0.0, 0.0) + p1 = (0.0, 1.0) + p2 = (1.0, 1.0) + p3 = (1.0, 0.0) + p5 = (2.0, 1.0) + + ray1 = GeometryTools.lineToRay(p0, p2) + ray2 = GeometryTools.lineToRay(p2, p0) + ray3 = GeometryTools.lineToRay(p0, p5) + + self.assertEqual((0.5, 0.5), GeometryTools.rayLineIntersection(p0, ray1, p1, p3)) + self.assertIsNone(GeometryTools.rayLineIntersection(p0, ray2, p1, p3)) #ray2 is ray1 reversed (no backwards intersections) + + self.assertEqual((1.0, 0.5), GeometryTools.rayLineIntersection(p0, ray3, p2, p3)) + self.assertIsNone(GeometryTools.rayLineIntersection(p0, ray3, p1, p2)) + + + + + def test_slicing_short_line_segment(self): + p0 = (0.0, 0.0) + p1 = (0.0, 1.0) + p2 = (1.0, 1.0) + p3 = (1.0, 0.0) + polygon = [p0, p1, p2, p3, p0] + lp0 = (0.2, 0.5) + lp1 = (0.4, 0.5) + line = [lp0, lp1] + + result = GeometryTools.slicePolygon(polygon, line) + + expected = [(0.0, 0.5), p1, p2, (1.0, 0.5), lp1, lp0, (0.0, 0.5)] + + self.assertEqual(result, expected) + + + def test_slicing_bendy_line_segments(self): + p0 = (0.0, 0.0) + p1 = (0.0, 1.0) + p2 = (1.0, 1.0) + p3 = (1.0, 0.0) + polygon = [p0, p1, p2, p3, p0] + + lp0 = (0.2, 0.5) + lp1 = (0.4, 0.5) + lp2 = (0.4, 0.3) + line = [lp0, lp1, lp2] + + expected = [(0.0, 0.5), p1, p2, p3, (0.4, 0.0), lp2, lp1, lp0, (0.0, 0.5)] + + result = GeometryTools.slicePolygon(polygon, line) + self.assertEqual(result, expected) + + line = [lp2, lp1, lp0] + result = GeometryTools.slicePolygon(polygon, line) + self.assertEqual(result, expected) + + + def test_slicing_same_segment(self): + p0 = (0.0, 0.0) + p1 = (0.0, 1.0) + p2 = (1.0, 1.0) + p3 = (1.0, 0.0) + polygon = [p0, p1, p2, p3, p0] + + lp0 = (0.2, 0.5) + lp1 = (0.4, 0.5) + lp2 = (0.4, 0.3) + lp3 = (0.2, 0.3) + + line = [lp0, lp1, lp2, lp3] + result = GeometryTools.slicePolygon(polygon, line) + expected = [(0.0, 0.5), (0.0, 0.3), lp3, lp2, lp1, lp0, (0.0, 0.5)] + self.assertEqual(result, expected) + + line = [lp3, lp2, lp1, lp0] + result = GeometryTools.slicePolygon(polygon, line) + expected = [(0.0, 0.3), (0.0, 0.5), lp0, lp1, lp2, lp3, (0.0, 0.3)] + self.assertEqual(result, expected) + + + def test_ray_polyline_intersections(self): + # /.\ + # . + # . + # (4)---------+----(3) + # /________:_____:_________ + # \ . | + # (1)--+----(2) + # | . + # | . + # (0) . + + + polygon = [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 2.0), (-1.0, 2.0)] + + p0 = (0.5, 0.0) + ray0 = (0.0, 1.0) + intersections0 = GeometryTools.rayPolygonIntersections(p0, ray0, polygon) + self.assertEqual(intersections0, [(1, (0.5, 1.0)), (3, (0.5, 2.0))]) + + + p1 = (1.5, 1.5) + ray1 = (-1.0, 0.0) + intersections1 = GeometryTools.rayPolygonIntersections(p1, ray1, polygon) + self.assertEqual(intersections1, [(2, (1, 1.5))]) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py b/ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py new file mode 100644 index 0000000000..04c538c84f --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py @@ -0,0 +1,194 @@ + +from ecl.util.geometry import Polyline, GeometryTools +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class PolylineTest(EclTest): + def setUp(self): + self.polyline = self.createTestPath("local/geometry/pol11.xyz") + self.closed_polyline = self.createTestPath("local/geometry/pol8.xyz") + + def test_construction(self): + polyline = Polyline(name="test line") + + with self.assertRaises(IndexError): + polyline.isClosed() + + self.assertEqual(polyline.getName(), "test line") + + self.assertEqual(len(polyline), 0) + + polyline.addPoint(0, 0, 0) + self.assertEqual(len(polyline), 1) + + polyline.addPoint(1, 1, 0) + self.assertEqual(len(polyline), 2) + + polyline.addPoint(1, 1.5) + self.assertEqual(len(polyline), 3) + + self.assertEqual(polyline[0], (0, 0, 0)) + self.assertEqual(polyline[1], (1, 1, 0)) + self.assertEqual(polyline[2], (1, 1.5)) + + polyline.addPoint(0, 1, 0) + self.assertFalse(polyline.isClosed()) + + polyline.addPoint(0, 0, 0) + self.assertTrue(polyline.isClosed()) + + + + def test_construction_default(self): + with self.assertRaises(TypeError): + pl = Polyline( init_points = 1 ) + + with self.assertRaises(TypeError): + pl = Polyline( init_points = [1.23] ) + + pl = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) + self.assertEqual( len(pl) , 3 ) + + + + + def test_iteration(self): + values = [(0, 0, 0), + (1, 0, 0), + (1, 1, 0), + (1, 1, 1)] + + polyline = Polyline(name="iteration line") + + for p in values: + polyline.addPoint(*p) + + for index, point in enumerate(polyline): + self.assertEqual(point, values[index]) + + + + def test_read_xyz_from_file(self): + with self.assertRaises(IOError): + XYZIo.readXYZFile("does/not/exist.xyz") + + polyline = XYZIo.readXYZFile(self.polyline) + + self.assertEqual(polyline.getName(), "pol11.xyz") + self.assertEqual(len(polyline), 13) + self.assertFalse(polyline.isClosed()) + self.assertEqual(polyline[0], (390271.843750, 6606121.334396, 1441.942627)) # first point + self.assertEqual(polyline[12], (389789.263184, 6605784.945099, 1446.627808)) # last point + + polyline = XYZIo.readXYZFile(self.closed_polyline) + + self.assertEqual(polyline.getName(), "pol8.xyz") + self.assertEqual(len(polyline), 21) + self.assertTrue(polyline.isClosed()) + self.assertEqual(polyline[0], (396202.413086, 6606091.935028, 1542.620972)) # first point + self.assertEqual(polyline[20], (396202.413086, 6606091.935028, 1542.620972)) # last point + + + def test_closed(self): + pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)]) + self.assertFalse( pl.isClosed() ) + pl.addPoint( 1,0 ) + self.assertEqual( 4 , len(pl) ) + self.assertTrue( pl.isClosed() ) + + pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)]) + self.assertFalse( pl.isClosed() ) + pl.assertClosed( ) + self.assertEqual( 4 , len(pl) ) + self.assertTrue( pl.isClosed() ) + + + def test_save(self): + with TestAreaContext("polyline/fwrite") as work_area: + p1 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) + p2 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) + self.assertTrue( p1 == p2 ) + + XYZIo.saveXYFile(p1 , "poly.xy") + + p2 = XYZIo.readXYFile("poly.xy") + self.assertTrue( p1 == p2 ) + + + def test_unzip(self): + p2 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) + p3 = Polyline( init_points = [(1,0,1) , (1,1,2) , (1,2,3)]) + (x,y) = p2.unzip() + self.assertEqual( x , [1,1,1]) + self.assertEqual( y , [0,1,2]) + + (x,y,z) = p3.unzip() + self.assertEqual( x , [1,1,1]) + self.assertEqual( y , [0,1,2]) + self.assertEqual( z , [1,2,3]) + + + with self.assertRaises(ValueError): + (x,y,z) = p2.unzip() + + with self.assertRaises(ValueError): + (x,y) = p3.unzip() + + + def test_intersection(self): + p1 = Polyline( init_points = [(0,0) , (1,0)]) + p2 = Polyline( init_points = [(0.5 , 0.5) , (0.5,-0.5)]) + p3 = Polyline( init_points = [(0,1) , (1,1)]) + + self.assertTrue(GeometryTools.polylinesIntersect( p1 , p2 )) + self.assertFalse( GeometryTools.polylinesIntersect( p2 , p3 )) + self.assertFalse( GeometryTools.polylinesIntersect( p1 , p3 )) + + self.assertTrue( p1.intersects(p2) ) + self.assertTrue( p2.intersects(p1) ) + + self.assertTrue( not p1.intersects(p3) ) + self.assertTrue( not p3.intersects(p1) ) + + + def test_add(self): + l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + l2 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + + l3 = l1 + l2 + self.assertEqual( len(l3) , 4 ) + self.assertEqual( l1[0] , l3[0] ) + self.assertEqual( l1[1] , l3[1] ) + self.assertEqual( l1[0] , l3[2] ) + self.assertEqual( l1[1] , l3[3] ) + + l4 = l1 + l4 += l2 + self.assertEqual(l3 , l4) + + + + def test_extend_to_edge(self): + bound = Polyline( init_points = [(0,0) , (1,0) , (1,1) , (0,1)] ) + l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + l2 = Polyline( init_points = [(0.25,0.25) , (0.75, 0.75)]) + + # Bound is not closed + with self.assertRaises(AssertionError): + GeometryTools.extendToEdge( bound , l1 ) + + bound.assertClosed() + # l1 is not fully contained in bound + with self.assertRaises(ValueError): + GeometryTools.extendToEdge( bound , l1 ) + + l3 = GeometryTools.extendToEdge( bound , l2 ) + self.assertEqual( l3[0] , (0.00,0.00)) + self.assertEqual( l3[1] , (0.25,0.25)) + self.assertEqual( l3[2] , (0.75,0.75)) + self.assertEqual( l3[3] , (1.00,1.00)) + self.assertEqual( len(l3) , 4) + + diff --git a/ThirdParty/Ert/python/tests/geometry_tests/test_surface.py b/ThirdParty/Ert/python/tests/geometry_tests/test_surface.py new file mode 100644 index 0000000000..631305b30d --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_surface.py @@ -0,0 +1,211 @@ +import random +from ecl.util.geometry import Surface +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class SurfaceTest(EclTest): + def setUp(self): + self.surface_valid = self.createTestPath("local/geometry/surface/valid_ascii.irap") + self.surface_short = self.createTestPath("local/geometry/surface/short_ascii.irap") + self.surface_long = self.createTestPath("local/geometry/surface/long_ascii.irap") + self.surface_valid2 = self.createTestPath("local/geometry/surface/valid2_ascii.irap") + self.surface_small = self.createTestPath("local/geometry/surface/valid_small_ascii.irap") + + def test_xyz(self): + s = Surface(self.surface_valid2) + self.assertEqual(s.getXYZ(i=5,j=13), s.getXYZ(idx=642)) + x,y,z = s.getXYZ(i=5,j=13) + self.assertFloatEqual(464041.44804, x) + self.assertFloatEqual(7336966.309535, y) + self.assertFloatEqual(0.0051, z) + self.assertAlmostEqualList(s.getXYZ(i=6,j=13), s.getXYZ(idx=643)) + self.assertFloatEqual(-0.0006, s.getXYZ(i=6,j=13)[2]) # z value + + def test_create_new(self): + with self.assertRaises(ValueError): + s = Surface(None, 1, 1, 1) + with self.assertRaises(IOError): + s = Surface(50, 1, 1, 1) + + # values copied from irap surface_small + ny,nx = 20,30 + xinc,yinc = 50.0, 50.0 + xstart,ystart = 463325.5625, 7336963.5 + angle = -65.0 + s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) + s = Surface(*s_args) + self.assertEqual(ny*nx, len(s)) + self.assertEqual(nx, s.getNX()) + self.assertEqual(ny, s.getNY()) + small = Surface (self.surface_small) + self.assertTrue(small.headerEqual(s)) + valid = Surface (self.surface_valid) + self.assertFalse(valid.headerEqual(s)) + + self.assertNotEqual(s, small) + idx = 0 + for i in range(nx): + for j in range(ny): + s[idx] = small[idx] + idx += 1 + self.assertEqual(s, small) + + def test_create(self): + with self.assertRaises(IOError): + s = Surface("File/does/not/exist") + + with self.assertRaises(ValueError): + s = Surface(self.surface_short) + + with self.assertRaises(ValueError): + s = Surface(self.surface_long) + + s = Surface( self.surface_valid ) + + self.assertEqual( s.getNX( ) , 49 ) + self.assertEqual( s.getNY( ) , 79 ) + self.assertEqual( len(s) , 49*79 ) + + with self.assertRaises(IndexError): + v = s[49 * 79] + + with self.assertRaises(TypeError): + v = s["KEY"] + + self.assertEqual( s[0] , 0.0051 ) + self.assertEqual( s[-1] , -0.0014 ) + + with self.assertRaises(IndexError): + s[49*79] = 787 + + s[0] = 10 + self.assertEqual( s[0] , 10 ) + + s[-1] = 77 + self.assertEqual( s[len(s) - 1] , 77 ) + + + def test_write(self): + with TestAreaContext("surface/write"): + + s0 = Surface( self.surface_valid ) + s0.write( "new_surface.irap") + + s1 = Surface( "new_surface.irap") + self.assertTrue( s1 == s0 ) + + s0[0] = 99 + self.assertFalse( s1 == s0 ) + + + + def test_copy(self): + with TestAreaContext("surface/copy"): + s0 = Surface( self.surface_valid ) + s1 = s0.copy( ) + + self.assertTrue( s1 == s0 ) + s1[0] = 99 + self.assertFalse( s1 == s0 ) + del s0 + self.assertEqual( s1[0] , 99) + + s2 = s1.copy( copy_data = False ) + self.assertEqual( s2[0] , 0.0 ) + self.assertEqual( s2[10] , 0.0 ) + self.assertEqual( s2[100] , 0.0 ) + + + def test_header_equal(self): + s0 = Surface( self.surface_valid ) + s1 = Surface( self.surface_valid2 ) + s2 = s0.copy( ) + + self.assertTrue( s0.headerEqual( s0 )) + self.assertFalse( s0.headerEqual( s1 )) + self.assertTrue( s0.headerEqual( s2 )) + + + def test_ops(self): + s0 = Surface( self.surface_valid ) + s0.assign(1.0) + for v in s0: + self.assertEqual(v , 1.0) + + s0 += 1 + for v in s0: + self.assertEqual(v , 2.0) + + s0 *= 2 + for v in s0: + self.assertEqual(v , 4.0) + + s1 = s0 + 4 + for v in s1: + self.assertEqual(v , 8.0) + + s2 = Surface( self.surface_valid2 ) + with self.assertRaises(ValueError): + s3 = s1 + s2 + + s4 = s1 + s0 + for v in s4: + self.assertEqual(v , 12.0) + + s5 = s4 / 12 + for v in s5: + self.assertEqual(v , 1.0) + + + def test_ops2(self): + s0 = Surface( self.surface_small ) + surface_list = [] + for i in range(10): + s = s0.copy() + for j in range(len(s)): + s[j] = random.random() + surface_list.append(s) + + mean = s0.copy( copy_data = False ) + for s in surface_list: + mean += s + mean /= len(surface_list) + + std = s0.copy( copy_data = False ) + for s in surface_list: + std += (s - mean) * (s - mean) + std /= (len(surface_list) - 1) + + + def test_sqrt(self): + s0 = Surface( self.surface_small ) + s0.assign(4) + self.assertEqual(20*30, len(s0)) + s_sqrt = s0.sqrt( ) + for i in range(len(s0)): + self.assertEqual(s0[i] , 4) + self.assertEqual(s_sqrt[i] , 2) + s0.inplaceSqrt( ) + self.assertTrue( s0 == s_sqrt ) + + + def test_xy(self): + ny,nx = 20,30 + xinc,yinc = 50.0, 50.0 + xstart,ystart = 463325.5625, 7336963.5 + angle = 0 + s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) + s = Surface(*s_args) + + xy = s.getXY(0) + self.assertEqual((xstart, ystart), xy) + + xy = s.getXY(1) + self.assertEqual((xstart+xinc, ystart), xy) + + xy = s.getXY(nx) + self.assertEqual((xstart, ystart+yinc), xy) + + xy = s.getXY(-1) + self.assertEqual((xstart+xinc*(nx-1), ystart+yinc*(ny-1)), xy) diff --git a/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt new file mode 100644 index 0000000000..25fb9e4263 --- /dev/null +++ b/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt @@ -0,0 +1,12 @@ +set(TEST_SOURCES + __init__.py + test_import.py + test_pylint.py +) + +add_python_package("python.tests.global_tests" "${PYTHON_INSTALL_PREFIX}/tests/global_tests" "${TEST_SOURCES}" False) + +addPythonTest(tests.global_tests.test_import.ImportEcl) +addPythonTest(tests.global_tests.test_pylint.LintErt) + + diff --git a/ThirdParty/Ert/python/tests/global_tests/__init__.py b/ThirdParty/Ert/python/tests/global_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/global_tests/test_import.py b/ThirdParty/Ert/python/tests/global_tests/test_import.py new file mode 100644 index 0000000000..6681589a8d --- /dev/null +++ b/ThirdParty/Ert/python/tests/global_tests/test_import.py @@ -0,0 +1,26 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +import sys + + +from ecl.util.test import ImportTestCase + +class ImportEcl(ImportTestCase): + + def test_import_ecl(self): + self.assertTrue( self.import_package( "ecl" )) diff --git a/ThirdParty/Ert/python/tests/global_tests/test_pylint.py b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py new file mode 100644 index 0000000000..1dac7dafaf --- /dev/null +++ b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py @@ -0,0 +1,45 @@ +# Copyright (C) 2017 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +from ecl.util.test import LintTestCase + +class LintErt(LintTestCase): + """Tests that no file in ert needs linting""" + + def test_lint_ecl(self): + #white = ['ecl_kw.py', 'ecl_type.py', 'ecl_sum.py', 'ecl_grid.py', 'ecl_npv.py'] # TODO fix issues and remove + #self.assertLinted('ecl/ecl', whitelist=white) + pass # temporarily disable linting due to monkey patching + + def test_lint_geo(self): + self.assertLinted('ecl/geo') + + def test_lint_util(self): + self.assertLinted('ecl/util', whitelist = ["vector_template.py", + "test_area.py", + "extended_testcase.py", + "ert_test_context.py", + "ert_test_runnet.py", + "import_test_case.py", + "lint_test_case.py", + "path_context.py" + "source_enumerator.py", + "temp_area.py", + "test_run.py" + ]) + + def test_lint_well(self): + self.assertLinted('ecl/well') diff --git a/ThirdParty/Ert/python/tests/install_tests/test_install.py b/ThirdParty/Ert/python/tests/install_tests/test_install.py new file mode 100644 index 0000000000..a0696599c8 --- /dev/null +++ b/ThirdParty/Ert/python/tests/install_tests/test_install.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import sys + +# This is a small executable which is used to verify the install, +# Prior to calling this the environment must have been prepared to +# ensure that the newly installed versions are picked up - this can +# typically be achieved with the bash script bin/test_install which is +# generated during the configure process. + +from ecl.grid import EclGrid +from ecl.summary import EclSum + + + diff --git a/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt new file mode 100644 index 0000000000..74fd4fcd47 --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt @@ -0,0 +1,16 @@ +set(TEST_SOURCES + __init__.py + test_ecl.py + test_geo.py + test_well.py + test_util.py + test_test.py +) + +add_python_package("python.tests.legacy_tests.ert" ${PYTHON_INSTALL_PREFIX}/tests/legacy_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.legacy_tests.test_ecl.ErtLegacyEclTest) +addPythonTest(tests.legacy_tests.test_geo.ErtLegacyGeoTest) +addPythonTest(tests.legacy_tests.test_well.ErtLegacyWellTest) +addPythonTest(tests.legacy_tests.test_util.ErtLegacyUtilTest) +addPythonTest(tests.legacy_tests.test_test.ErtLegacyTestTest) diff --git a/ThirdParty/Ert/python/tests/legacy_tests/__init__.py b/ThirdParty/Ert/python/tests/legacy_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py b/ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py new file mode 100644 index 0000000000..c51a55eabc --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py @@ -0,0 +1,42 @@ +from ert.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil +from ert.ecl import EclTypeEnum, EclDataType +from ert.ecl import EclSumVarType +from ert.ecl import EclSumTStep +from ert.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from ert.ecl import EclSumKeyWordVector +from ert.ecl import EclPLTCell, EclRFTCell +from ert.ecl import EclRFT, EclRFTFile +from ert.ecl import FortIO, openFortIO +from ert.ecl import EclKW +from ert.ecl import Ecl3DKW +from ert.ecl import EclFileView +from ert.ecl import EclFile , openEclFile +from ert.ecl import Ecl3DFile +from ert.ecl import EclInitFile +from ert.ecl import EclRestartFile +from ert.ecl import EclGrid +from ert.ecl import EclRegion +from ert.ecl import EclSubsidence +from ert.ecl import phase_deltag, deltag +from ert.ecl import EclGrav +from ert.ecl import EclSumNode +from ert.ecl import EclSumVector +from ert.ecl import EclNPV , NPVPriceVector +from ert.ecl import EclCmp +from ert.ecl import EclGridGenerator + +from ert.ecl.faults import Layer +from ert.ecl.faults import FaultCollection +from ert.ecl.faults import Fault +from ert.ecl.faults import FaultLine +from ert.ecl.faults import FaultSegment , SegmentMap +from ert.ecl.faults import FaultBlock , FaultBlockCell +from ert.ecl.faults import FaultBlockLayer + + + +from tests import EclTest + + +class ErtLegacyEclTest(EclTest): + pass diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_geo.py b/ThirdParty/Ert/python/tests/legacy_tests/test_geo.py new file mode 100644 index 0000000000..b0e5cb0126 --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_geo.py @@ -0,0 +1,14 @@ +from ert.geo import GeoPointset +from ert.geo import GeoRegion +from ert.geo import CPolyline +from ert.geo import CPolylineCollection +from ert.geo import Polyline +from ert.geo import XYZIo +from ert.geo import GeometryTools +from ert.geo import Surface + +from tests import EclTest + + +class ErtLegacyGeoTest(EclTest): + pass diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_test.py b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py new file mode 100644 index 0000000000..1b75b2941f --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py @@ -0,0 +1,15 @@ +from ert.test import TestRun +from ert.test import path_exists +from ert.test import SourceEnumerator +from ert.test import TestArea , TestAreaContext +from ert.test import TempArea , TempAreaContext +from ert.test import ErtTestRunner +from ert.test import PathContext +from ert.test import LintTestCase +from ert.test import ImportTestCase + +from tests import EclTest + + +class ErtLegacyTestTest(EclTest): + pass diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_util.py b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py new file mode 100644 index 0000000000..a52dd8f442 --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py @@ -0,0 +1,31 @@ +from ert.util import Version +from ert.util import RngAlgTypeEnum, RngInitModeEnum +from ert.util import CTime +from ert.util import PermutationVector +from ert.util import VectorTemplate +from ert.util import DoubleVector +from ert.util import IntVector +from ert.util import BoolVector +from ert.util import TimeVector +from ert.util import StringList +from ert.util import RandomNumberGenerator +from ert.util import LookupTable +from ert.util import Hash, StringHash, DoubleHash, IntegerHash +from ert.util import ThreadPool +from ert.util import installAbortSignals, updateAbortSignals +from ert.util import ArgPack + +from tests import EclTest + +try: + from res.util import SubstitutionList +except ImportError: + pass + +try: + from res.util import CThreadPool, startCThreadPool +except ImportError: + pass + +class ErtLegacyUtilTest(EclTest): + pass diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_well.py b/ThirdParty/Ert/python/tests/legacy_tests/test_well.py new file mode 100644 index 0000000000..b622ec965a --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_well.py @@ -0,0 +1,13 @@ +from ert.well import WellTypeEnum +from ert.well import WellConnectionDirectionEnum +from ert.well import WellConnection +from ert.well import WellSegment +from ert.well import WellState +from ert.well import WellTimeLine +from ert.well import WellInfo + +from tests import EclTest + + +class ErtLegacyWellTest(EclTest): + pass diff --git a/ThirdParty/Ert/python/tests/test_install.in b/ThirdParty/Ert/python/tests/test_install.in index 0831127069..e7e154739a 100644 --- a/ThirdParty/Ert/python/tests/test_install.in +++ b/ThirdParty/Ert/python/tests/test_install.in @@ -2,5 +2,5 @@ export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@:@CTEST_PYTHONPATH@:$PYTHONPATH -@PROJECT_SOURCE_DIR@/python/tests/install/test_install.py $@ +@PROJECT_SOURCE_DIR@/python/tests/install_tests/test_install.py $@ diff --git a/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt new file mode 100644 index 0000000000..a14e586e39 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt @@ -0,0 +1,32 @@ +set(TEST_SOURCES + __init__.py + test_ctime.py + test_hash.py + test_lookup_table.py + test_rng.py + test_string_list.py + #test_substitution_list.py + test_thread_pool.py + test_vectors.py + test_version.py + test_work_area.py + test_path_context.py + test_arg_pack.py + test_spawn.py +) + +add_python_package("python.tests.util_tests" ${PYTHON_INSTALL_PREFIX}/tests/util_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.util_tests.test_ctime.CTimeTest) +addPythonTest(tests.util_tests.test_hash.HashTest) +addPythonTest(tests.util_tests.test_lookup_table.LookupTableTest ) +addPythonTest(tests.util_tests.test_rng.RngTest ) +addPythonTest(tests.util_tests.test_string_list.StringListTest) +addPythonTest(tests.util_tests.test_vectors.UtilTest) +addPythonTest(tests.util_tests.test_work_area.WorkAreaTest) +addPythonTest(tests.util_tests.test_version.VersionTest) +addPythonTest(tests.util_tests.test_path_context.PathContextTest) +addPythonTest(tests.util_tests.test_thread_pool.ThreadPoolTest) +addPythonTest(tests.util_tests.test_arg_pack.ArgPackTest) +addPythonTest(tests.util_tests.test_spawn.SpawnTest) +#addPythonTest(tests.util.test_substitution_list.SubstitutionListTest) diff --git a/ThirdParty/Ert/python/tests/util_tests/__init__.py b/ThirdParty/Ert/python/tests/util_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py b/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py new file mode 100644 index 0000000000..69f77c68b5 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py @@ -0,0 +1,36 @@ +import ecl +from ecl import EclPrototype +from tests import EclTest +from ecl.util.util import ArgPack, StringList + +TEST_LIB = EclPrototype.lib + + +class ArgPackTest(EclTest): + def test_create(self): + arg = ArgPack() + self.assertEqual(len(arg), 0) + + arg.append(StringList()) + self.assertEqual(len(arg), 1) + + arg.append(3.14) + self.assertEqual(len(arg), 2) + + o = object() + with self.assertRaises(TypeError): + arg.append(o) + + def test_args(self): + arg = ArgPack(1, 2, 3) + self.assertEqual(len(arg), 3) + + def test_append_ptr(self): + arg = ArgPack(StringList()) + self.assertEqual(len(arg), 1) + + func = getattr(TEST_LIB, "test_argpack_is_stringlist") + func.restype = None + func.argtypes = [ArgPack] + + func(arg) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_ctime.py b/ThirdParty/Ert/python/tests/util_tests/test_ctime.py new file mode 100644 index 0000000000..18ca924804 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_ctime.py @@ -0,0 +1,131 @@ +import time +from datetime import datetime, date + +from ecl.util.util import CTime + + +try: + from unittest2 import TestCase +except ImportError: + from unittest import TestCase + + +class CTimeTest(TestCase): + def test_creation(self): + t0 = CTime(0) + + t2 = CTime(datetime(1970, 1, 1)) + self.assertEqual(t0, t2) + + t3 = CTime(date(1970, 1, 1)) + self.assertEqual(t0, t3) + + with self.assertRaises(NotImplementedError): + CTime("string") + + def test_c_time(self): + delta = 0 + c_time = CTime(0) + py_time = datetime(1970, 1, 1) + + self.assertEqual(str(c_time), py_time.strftime("%Y-%m-%d %H:%M:%S%z")) + + date_time = CTime(py_time) + self.assertEqual(c_time, date_time) + + date_time_after = CTime(datetime(1970, 1, 1, 1, 0, 5)) + + self.assertTrue(date_time_after > date_time) + + def test_math(self): + c1 = CTime(date(2000, 1, 1)) + c2 = CTime(date(2000, 1, 1)) + c3 = CTime(date(2000, 1, 1)) + + c3 += c1 + self.assertTrue(isinstance(c3, CTime)) + + c4 = c1 * 1.0 + self.assertTrue(isinstance(c4, CTime)) + self.assertTrue(isinstance(c1 + c2, CTime)) + + self.assertEqual((c1 + c2) * 0.5, date(2000, 1, 1)) + + def test_comparison(self): + t0 = CTime(0) + t1 = CTime(0) + t2 = CTime(1) + + self.assertTrue(t0 == t1) + self.assertFalse(t0 != t1) + with self.assertRaises(TypeError): + t0 != 0.5 + + self.assertFalse(t0 < t1) + self.assertTrue(t0 < t2) + with self.assertRaises(TypeError): + t0 < 0.5 + + self.assertTrue(t0 <= t1) + self.assertTrue(t0 <= t2) + with self.assertRaises(TypeError): + t0 <= 0.5 + + self.assertFalse(t0 > t1) + self.assertFalse(t0 > t2) + with self.assertRaises(TypeError): + t0 > 0.5 + + self.assertTrue(t0 >= t1) + self.assertFalse(t0 >= t2) + with self.assertRaises(TypeError): + t0 >= 0.5 + + t3 = CTime(date(2050, 1, 1)) + t4 = CTime(date(2060, 1, 1)) + self.assertTrue(t1 < t3) + self.assertTrue(t3 < t4) + + t5 = CTime(t4) + self.assertTrue(t4 == t5) + + def test_range(self): + d1 = date(2000, 1, 1) + dt1 = datetime(2000, 1, 1, 0, 0, 0) + c1 = CTime(d1) + + d0 = date(1999, 1, 1) + dt0 = datetime(1999, 1, 1, 0, 0, 0) + c0 = CTime(d0) + + d2 = date(2001, 1, 1) + dt2 = datetime(2001, 1, 1, 0, 0, 0) + c2 = CTime(d2) + + self.assertTrue(d0 <= c1 < dt2) + self.assertTrue(c0 <= c1 < d2) + self.assertTrue(dt0 <= c1 < c2) + + self.assertFalse(d1 <= c0 < dt2) + self.assertFalse(c1 <= c0 < d2) + self.assertFalse(dt1 <= c0 < c2) + + self.assertTrue(d0 <= c0 < dt2) + self.assertTrue(c0 <= c0 < d2) + self.assertTrue(dt0 <= c0 < c2) + + self.assertFalse(d0 <= c2 < dt2) + self.assertFalse(c0 <= c2 < d2) + self.assertFalse(dt0 <= c2 < c2) + + self.assertTrue(d0 <= c2 <= dt2) + self.assertTrue(c0 <= c2 <= d2) + self.assertTrue(dt0 <= c2 <= c2) + + def test_conversion(self): + t = CTime(0) + + self.assertEqual(t.value(), 0) + self.assertEqual(t.ctime(), 0) + self.assertEqual(t.time(), time.gmtime(0)) + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_hash.py b/ThirdParty/Ert/python/tests/util_tests/test_hash.py new file mode 100644 index 0000000000..a8111a164f --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_hash.py @@ -0,0 +1,68 @@ +from ctypes import c_void_p + +from tests import EclTest +from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash + + +class HashTest(EclTest): + def test_string_hash(self): + hash = StringHash() + + self.assertEqual(len(hash), 0) + + hash["hipp"] = "" + + self.assertEqual(len(hash), 1) + + with self.assertRaises(ValueError): + hash["hopp"] = 55 + + with self.assertRaises(KeyError): + hopp = hash["hopp"] + + self.assertTrue("hipp" in hash) + + self.assertEqual(list(hash.keys()), ["hipp"]) + + def test_int_hash(self): + hash = IntegerHash() + + with self.assertRaises(ValueError): + hash["one"] = "ein" + + with self.assertRaises(ValueError): + hash["one"] = 1.0 + + hash["two"] = 2 + + self.assertEqual(hash["two"], 2) + + def test_double_hash(self): + hash = DoubleHash() + + with self.assertRaises(ValueError): + hash["one"] = "ein" + + hash["two"] = 2 + hash["three"] = 3.0 + + self.assertEqual(hash["two"], 2) + self.assertEqual(hash["three"], 3.0) + + def test_c_void_p_hash(self): + hash = Hash() + + cp = c_void_p(512) + hash["1"] = cp + + self.assertEqual(hash["1"], cp.value) + + def test_for_in_hash(self): + hash = StringHash() + + hash["one"] = "one" + hash["two"] = "two" + hash["three"] = "three" + + for key in hash: + self.assertTrue(key in hash) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py b/ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py new file mode 100644 index 0000000000..48d7c827f7 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py @@ -0,0 +1,88 @@ +try: + from unittest2 import TestCase +except ImportError: + from unittest import TestCase + +from ecl.util.util import LookupTable + + +class LookupTableTest(TestCase): + def test_lookup_table_no_values(self): + lookup = LookupTable() + + self.assertEqual(len(lookup), 0) + + with self.assertRaises(ValueError): + lookup.getMaxValue() + + with self.assertRaises(ValueError): + lookup.getMinValue() + + with self.assertRaises(ValueError): + lookup.getMaxArg() + + with self.assertRaises(ValueError): + lookup.getMinArg() + + with self.assertRaises(ValueError): + lookup.interp(0.25) + + def test_lookup_table_one_value(self): + lookup = LookupTable() + lookup.append(0, 0) + with self.assertRaises(ValueError): + lookup.interp(0.25) + + def test_lookup_table_min_and_max(self): + lookup = LookupTable() + + lookup.append(0.0, 0.0) + lookup.append(1.0, 10.0) + + self.assertEqual(lookup.getMaxValue(), 10.0) + self.assertEqual(lookup.getMinValue(), 0.0) + self.assertEqual(lookup.getMaxArg(), 1.0) + self.assertEqual(lookup.getMinArg(), 0.0) + self.assertEqual(len(lookup), 2) + + def test_lookup_out_of_bounds(self): + lookup = LookupTable() + + lookup.append(0.0, 0.0) + lookup.append(1.0, 10.0) + + self.assertEqual(lookup.interp(0), 0) + self.assertEqual(lookup.interp(1), 10) + + with self.assertRaises(ValueError): + lookup.interp(-1) + + with self.assertRaises(ValueError): + lookup.interp(2) + + lookup.setLowerLimit(-1) + self.assertEqual(lookup.interp(-0.25), -1) + + with self.assertRaises(ValueError): + lookup.interp(2) + + lookup.setUpperLimit(88) + self.assertEqual(lookup.interp(1.25), 88) + + def test_lookup_table_interpolation(self): + lookup = LookupTable() + + lookup.append(0.0, 0.0) + lookup.append(1.0, 10.0) + + self.assertEqual(lookup.interp(0.5), 5.0) + + def test_optional_arg(self): + lookup = LookupTable(lower_limit=-1, upper_limit=100) + + lookup.append(0.0, 0.0) + lookup.append(1.0, 10.0) + + self.assertEqual(lookup.interp(-1), -1.0) + self.assertEqual(lookup.interp(0.5), 5.0) + self.assertEqual(lookup.interp(2), 100.0) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_path_context.py b/ThirdParty/Ert/python/tests/util_tests/test_path_context.py new file mode 100644 index 0000000000..1690d04ae9 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_path_context.py @@ -0,0 +1,50 @@ +import os +from ecl.util.test import PathContext,TestAreaContext +from tests import EclTest + + +class PathContextTest(EclTest): + + def test_error(self): + with TestAreaContext("pathcontext"): + # Test failure on creating PathContext with an existing path + os.makedirs("path/1") + with self.assertRaises(OSError): + with PathContext("path/1"): + pass + + # Test failure on non-writable path + os.chmod("path/1", 0o0444) + with self.assertRaises(OSError): + with PathContext("path/1/subfolder"): + pass + os.chmod("path/1", 0o0744) + + # Test failure on creating PathContext with an existing file + with open("path/1/file", "w") as f: + f.write("xx") + with self.assertRaises(OSError): + with PathContext("path/1/file"): + pass + + + def test_chdir(self): + with PathContext("/tmp/pc"): + self.assertEqual( + os.path.realpath(os.getcwd()), + os.path.realpath("/tmp/pc") + ) + + def test_cleanup(self): + with TestAreaContext("pathcontext"): + os.makedirs("path/1") + + with PathContext("path/1/next/2/level"): + with open("../../file" , "w") as f: + f.write("Crap") + + self.assertTrue(os.path.isdir("path/1")) + self.assertTrue(os.path.isdir("path/1/next")) + self.assertFalse(os.path.isdir("path/1/next/2")) + + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_rng.py b/ThirdParty/Ert/python/tests/util_tests/test_rng.py new file mode 100644 index 0000000000..aba91bfed4 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_rng.py @@ -0,0 +1,46 @@ +from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum +from ecl.util.util import RandomNumberGenerator +from ecl.util.test import TestAreaContext +from tests import EclTest + + +class RngTest(EclTest): + + def test_enums(self): + self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "lib/include/ert/util/rng.h") + self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "lib/include/ert/util/rng.h") + + def test_rng_default(self): + rng = RandomNumberGenerator() + self.assertIsInstance(rng.getDouble(), float) + + def test_rng_state(self): + rng = RandomNumberGenerator() + with self.assertRaises(ValueError): + rng.setState("12") + + rng.setState("0123456789ABCDEF") + val1 = rng.getInt() + val2 = rng.getInt() + + self.assertFalse( val1 == val2 ) + rng.setState("0123456789ABCDEF") + self.assertEqual( rng.getInt() , val1) + self.assertEqual( rng.getInt() , val2) + + + + def test_load_save(self): + rng = RandomNumberGenerator() + with self.assertRaises(IOError): + rng.loadState("does/not/exist") + + with TestAreaContext("rng_state") as t: + rng.saveState( "rng.txt" ) + t.sync() + val1 = rng.getInt() + val2 = rng.getInt() + rng.loadState( "rng.txt" ) + self.assertEqual( rng.getInt() , val1 ) + self.assertEqual( rng.getInt() , val2 ) + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_spawn.py b/ThirdParty/Ert/python/tests/util_tests/test_spawn.py new file mode 100644 index 0000000000..80809fcfff --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_spawn.py @@ -0,0 +1,64 @@ +import os +import stat +import sys + +import ecl +from ecl import EclPrototype +from tests import EclTest +from ecl.util.test.test_area import TestAreaContext + +from cwrap import Prototype + +class _TestSpawnPrototype(Prototype): + lib = EclPrototype.lib + + def __init__(self, prototype, bind=True): + super(_TestSpawnPrototype, self).__init__(_TestSpawnPrototype.lib, prototype, bind=bind) + + +class SpawnTest(EclTest): + _spawn = _TestSpawnPrototype("int util_spawn_blocking(char*, int, void*, char*, char*)", bind = False) + def createScript(self, name, stdout_string , stderr_string): + with open(name, "w") as f: + f.write("#!/usr/bin/env python\n") + f.write("import sys\n") + f.write("sys.stdout.write('%s')\n" % stdout_string) + f.write("sys.stdout.flush()\n") + f.write("sys.stderr.write('%s')\n" % stderr_string) + f.write("sys.stderr.flush()\n") + + mode = os.stat(name).st_mode + mode |= stat.S_IXUSR | stat.S_IXGRP + os.chmod(name, stat.S_IMODE(mode)) + + + + def test_spawn_redirect(self): + with TestAreaContext("spawn_test1", store_area=True) as test_area: + stdout_string = "stdout_redirect" + stderr_string = "stderr_redirect" + self.createScript("print.py",stdout_string, stderr_string) + status = self._spawn("print.py",0, None, "print.out", "print.err") + self.assertEqual(status , 0) + + sys.stderr.write("init stderr\n") + sys.stdout.write("init stdout\n") + sys.stderr.write("complete stderr\n") + sys.stdout.write("complete stdout\n") + + with open("print.out", "r") as f: + s = f.read() + self.assertEqual(s , stdout_string) + + with open("print.err", "r") as f: + s = f.read() + self.assertEqual(s , stderr_string) + + + + def test_spawn_noredirect(self): + with TestAreaContext("spawn_test2", store_area=True) as test_area: + self.createScript("print.py","stdout_no_redirect", "stderr_no_redirect") + status = self._spawn("print.py", 0, None, None , None) + self.assertEqual(status , 0) + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_string_list.py b/ThirdParty/Ert/python/tests/util_tests/test_string_list.py new file mode 100644 index 0000000000..6d0a809836 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_string_list.py @@ -0,0 +1,159 @@ +from __future__ import absolute_import, division, print_function, unicode_literals + +try: + from unittest2 import TestCase +except ImportError: + from unittest import TestCase + +from ecl.util.util import StringList + + +class StringListTest(TestCase): + def test_del(self): + s = StringList( initial = ["A", "list"] ) + internal_list_of_strings = s.strings + python_list_of_strings = list(s) + + self.assertEqual(internal_list_of_strings, python_list_of_strings) + + del s + + self.assertEqual(python_list_of_strings, ["A", "list"]) + + def test_iterate(self): + s = ["A", "list", "of", "strings"] + s1 = StringList(initial=s) + s2 = s1.strings + s3 = list(s1) + + for index in range(len(s1)): + self.assertEqual(s[index], s1[index]) + + for index in range(len(s2)): + self.assertEqual(s[index], s2[index]) + + for index in range(len(s3)): + self.assertEqual(s[index], s3[index]) + + + def test_pop( self ): + s = StringList(initial=["A", "list", "of", "strings"]) + s1 = s.pop() + self.assertTrue(len(s) == 3) + self.assertTrue(s1 == "strings") + + s1 = s.pop() + self.assertTrue(len(s) == 2) + self.assertTrue(s1 == "of") + + s1 = s.pop() + self.assertTrue(len(s) == 1) + self.assertTrue(s1 == "list") + + s1 = s.pop() + self.assertTrue(len(s) == 0) + self.assertTrue(s1 == "A") + + with self.assertRaises(IndexError): + s.pop() + + def test_last(self): + s = StringList(initial=["A", "list", "of", "strings"]) + self.assertEqual(s.last, "strings") + + with self.assertRaises(IndexError): + s.pop() + s.pop() + s.pop() + s.pop() + s.last + + + def test_in_and_not_in(self): + s = StringList(["A", "list", "of", "strings"]) + + self.assertTrue("A" in s) + self.assertTrue("Bjarne" not in s) + + def test_append(self): + s1 = StringList(["A", "B"]) + s1.append("C") + + s2 = StringList(["A","B","C"]) + self.assertEqual(s1, ["A", "B", "C"]) + self.assertEqual(s1, s2) + self.assertFalse(s1 == ["A","B","D"]) + self.assertFalse(s1 == ["A","B","C" , "D"]) + + pfx = 'StringList(size' # __repr__ + self.assertEqual(pfx, repr(s2)[:len(pfx)]) + + def test_append_not_string(self): + s = StringList() + s.append(10) + self.assertEqual( len(s) , 1) + self.assertEqual(s[0] , "10") + + + def test_negative_index(self): + s = StringList(["A", "B", "C"]) + + self.assertEqual(s[-1], "C") + self.assertEqual(s[-3], "A") + + with self.assertRaises(LookupError): + s = s[-4] + + def test_find_first(self): + s = StringList(["A", "B", "C"]) + + self.assertEqual(s.index("A"), 0) + self.assertEqual(s.index("B"), 1) + self.assertEqual(s.index("C"), 2) + self.assertEqual(s.index("D"), -1) + + + + def test_front_back(self): + s = StringList() + with self.assertRaises(LookupError): + s.front() + + with self.assertRaises(LookupError): + s.back() + + s.append("S1") + s.append("S2") + s.append("S3") + + self.assertEqual( "S1" , s.front() ) + self.assertEqual( "S3" , s.back() ) + + + def test_iadd(self): + s1 = StringList( initial = ["A","B","C"]) + with self.assertRaises(TypeError): + s3 = s1 + 10 + + + s2 = StringList( initial = ["A","B","C"]) + s3 = s1 + s2 + self.assertEqual( s3 , ["A","B","C","A","B","C"]) + + s1 += s2 + self.assertEqual( s1 , ["A","B","C","A","B","C"]) + with self.assertRaises(TypeError): + s3 += "b" + + + def test_ior(self): + s1 = StringList( initial = ["A","B","C"]) + s2 = StringList( initial = ["A","B","C"]) + + s3 = s1 | s2 + self.assertEqual( s3 , ["A","B","C"]) + s1 |= s2 + self.assertEqual( s1 , ["A","B","C"]) + + with self.assertRaises(TypeError): + s1 |= 26 diff --git a/ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py b/ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py new file mode 100644 index 0000000000..a7cb895924 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py @@ -0,0 +1,101 @@ +import time +from ecl.util.util import ThreadPool +from ecl.util.util.thread_pool import Task +from tests import EclTest + + +class ThreadPoolTest(EclTest): + + + def sleepTask(self, *args, **kwargs): + time.sleep(args[0]) + + def numberer(self, index, result): + result[index] = True + + def test_pool_creation(self): + pool = ThreadPool(4) + + self.assertEqual(4, pool.poolSize()) + + def noop(*args, **kwargs): + pass + + pool.addTask(noop) + self.assertEqual(1, pool.taskCount()) + + pool.addTask(noop, 1, 2, 3) + self.assertEqual(2, pool.taskCount()) + + pool.addTask(noop, 1, 2, 3, name="name", group="group", purpose="porpoise") + self.assertEqual(3, pool.taskCount()) + + self.assertEqual(pool.runningCount(), 0) + self.assertEqual(pool.doneCount(), 0) + + + def test_pool_execution(self): + pool = ThreadPool(4) + + result = {} + for index in range(10): + pool.addTask(self.numberer, index, result=result) + + pool.nonBlockingStart() + pool.join() + + for index in range(10): + self.assertTrue(index in result) + self.assertTrue(result[index]) + + self.assertFalse(pool.hasFailedTasks()) + + + + def test_pool_unbound_fail(self): + pool = ThreadPool(4) + + self.assertEqual(4, pool.poolSize()) + pool.addTask(ThreadPoolTest.numberer, 0, {}) + + pool.nonBlockingStart() + pool.join() + + self.assertTrue(pool.hasFailedTasks()) + + + def test_fill_pool(self): + pool = ThreadPool(4) + + for index in range(10): + pool.addTask(self.sleepTask, 2) + + pool.nonBlockingStart() + time.sleep(0.5) + self.assertEqual(pool.doneCount(), 0) + self.assertEqual(pool.runningCount(), 4) + + pool.join() + + + + def test_task(self): + def sleeping(): + time.sleep(1) + + task = Task(sleeping) + + self.assertFalse(task.hasStarted()) + self.assertFalse(task.isRunning()) + self.assertFalse(task.isDone()) + + task.start() + + self.assertTrue(task.hasStarted()) + self.assertTrue(task.isRunning()) + + task.join() + + self.assertFalse(task.isRunning()) + self.assertTrue(task.isDone()) + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_vectors.py b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py new file mode 100644 index 0000000000..47d306aacd --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py @@ -0,0 +1,576 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_vectors.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +import copy +import datetime +import six + +try: + from unittest2 import TestCase +except ImportError: + from unittest import TestCase + +from ecl.util.util import DoubleVector, IntVector, BoolVector, TimeVector, CTime, PermutationVector + +class UtilTest(TestCase): + def setUp(self): + pass + + def dotest_slicing(self, vec): + self.assertEqual(10, len(vec)) + self.assertEqual(vec[-1], vec[9]) + self.assertEqual(8, len(vec[:8])) + self.assertEqual(9, len(vec[1:])) + self.assertEqual(3, len(vec[1:8:3])) + odds = vec[1::2] + self.assertEqual(4, len(vec[1:8:2])) + for i in range(4): + self.assertEqual(vec[2*i + 1], odds[i]) + + def test_slicing(self): + dv = DoubleVector(initial_size=10) + for i in range(10): + dv[i] = 1.0 / (1+i) + self.dotest_slicing(dv) + iv = IntVector(initial_size=10) + for i in range(10): + iv[i] = i**3 + self.dotest_slicing(iv) + bv = BoolVector(initial_size=10) + for i in range(0,10,3): + bv[i] = True + self.dotest_slicing(bv) + tv = TimeVector(initial_size=10) + for i in range(10): + tv[i] = CTime(datetime.datetime(2016, 12, i+3, 0, 0, 0)) + self.dotest_slicing(tv) + + + + def test_double_vector(self): + v = DoubleVector() + + v[0] = 77.25 + v[1] = 123.25 + v[2] = 66.25 + v[3] = 56.25 + v[4] = 111.25 + v[5] = 99.25 + v[12] = 12 + + self.assertEqual(len(v), 13) + self.assertEqual(list(v), [v[0], v[1], v[2], v[3], v[4], v[5], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v[12]]) + + v.clear() + self.assertEqual(len(v), 0) + + v.clear() + + v[0] = 0.1 + v[1] = 0.2 + v[2] = 0.4 + v[3] = 0.8 + + v2 = v * 2 + + self.assertEqual(list(v2), [v[0] * 2, v[1] * 2, v[2] * 2, v[3] * 2]) + + v2 += v + self.assertEqual(list(v2), [v[0] * 3, v[1] * 3, v[2] * 3, v[3] * 3]) + + v2.assign(0.66) + self.assertEqual(list(v2), [0.66, 0.66, 0.66, 0.66]) + + v.assign(v2) + self.assertEqual(list(v), [0.66, 0.66, 0.66, 0.66]) + + v.clear() + v.setDefault(0.75) + self.assertEqual(v.getDefault(), 0.75) + v[2] = 0.0 + self.assertEqual(v[1], 0.75) + + def test_vector_operations_with_exceptions(self): + iv1 = IntVector() + iv1.append(1) + iv1.append(2) + iv1.append(3) + + iv2 = IntVector() + iv2.append(4) + iv2.append(5) + + dv1 = DoubleVector() + dv1.append(0.5) + dv1.append(0.75) + dv1.append(0.25) + + # Size mismatch + with self.assertRaises(ValueError): + iv3 = iv1 + iv2 + + # Size mismatch + with self.assertRaises(ValueError): + iv3 = iv1 * iv2 + + # Type mismatch + with self.assertRaises(TypeError): + iv1 += dv1 + + # Type mismatch + with self.assertRaises(TypeError): + iv1 *= dv1 + + def test_setitem_getitem(self): + primes = [2,3,5,7,11,13,17,19] + primep = [i in primes for i in range(20)] + b = BoolVector(initial_size = 20) + b[2] = True + b[3:8:2] = True + b[11::2] = True + self.assertTrue(b[15]) + self.assertTrue(b[-5]) + self.assertTrue(b[17]) + self.assertTrue(b[19]) + b[-5] = False + self.assertEqual(list(b), primep) + + def test_repr(self): + primes = [2,3,5,7,11,13,17,19] + b = BoolVector() + for i in primes: + b[i] = True + pfx = 'BoolVector(size = 20, content = "00110101000101000101")' + self.assertEqual(pfx, repr(b)[:len(pfx)]) + b[30] = True + pfx = 'BoolVector(size = 31, content = "001101010...00000001")' + self.assertEqual(pfx, repr(b)[:len(pfx)]) + + + def test_bool_vector(self): + b = BoolVector() + b.setDefault(True) + + b[4] = False + + self.assertEqual(list(b), [True, True, True, True, False]) + + def test_activeList(self): + active_list = IntVector.active_list("1,10,100-105") + self.assertTrue(len(active_list) == 8) + self.assertTrue(active_list[0] == 1) + self.assertTrue(active_list[2] == 100) + self.assertTrue(active_list[7] == 105) + self.assertEqual(active_list.count(100), 1) + active_list.append(100) + active_list.append(100) + self.assertEqual(active_list.count(100), 3) + + active_list = IntVector.active_list("1,10,100-105X") + self.assertFalse(active_list) + + def test_value_list(self): + list2 = IntVector.valueList("3,10-12,0,1") + self.assertTrue(len(list2) == 6) + expected = [3, 10, 11, 12, 0, 1] + for v1, v2 in zip(list2, expected): + self.assertEqual(v1, v2) + + def test_contains_int(self): + iv = IntVector() + iv[0] = 1 + iv[1] = 10 + iv[2] = 100 + iv[3] = 1000 + + self.assertTrue(1 in iv) + self.assertTrue(10 in iv) + self.assertTrue(88 not in iv) + self.assertTrue(99 not in iv) + + def test_activeMask(self): + active_list = BoolVector.createActiveMask("1 , 4 - 7 , 10") + self.assertTrue(len(active_list) == 11) + self.assertTrue(active_list[1]) + self.assertTrue(active_list[4]) + self.assertTrue(active_list[10]) + self.assertFalse(active_list[9]) + self.assertFalse(active_list[8]) + + self.assertEqual(6, active_list.count(True)) + + active_list = BoolVector.createActiveMask("1,4-7,10X") + self.assertFalse(active_list) + + def test_update_active_mask(self): + vec = BoolVector(False, 10) + + self.assertTrue(vec.updateActiveMask("1-2,5")) + self.assertTrue(vec[1]) + self.assertTrue(vec[2]) + self.assertTrue(vec[5]) + self.assertFalse(vec[4]) + + vec = BoolVector(False, 10) + + self.assertTrue(vec.updateActiveMask("1-5,2,3")) + self.assertTrue(vec[1]) + self.assertTrue(vec[2]) + self.assertTrue(vec[3]) + self.assertTrue(vec[4]) + self.assertTrue(vec[5]) + self.assertFalse(vec[0]) + self.assertFalse(vec[6]) + + vec = BoolVector(False, 10) + + self.assertTrue(vec.updateActiveMask("5,6,7,15")) + self.assertTrue(vec[5]) + self.assertTrue(vec[6]) + self.assertTrue(vec[7]) + self.assertFalse(vec[4]) + self.assertFalse(vec[8]) + self.assertEqual(len(vec), 16) + + def test_pop(self): + a = IntVector() + a.append(1) + a.append(2) + + self.assertEqual(a.pop(), 2) + self.assertEqual(len(a), 1) + self.assertEqual(a.pop(), 1) + self.assertEqual(len(a), 0) + with self.assertRaises(ValueError): + a.pop() + +#---- + + def test_shift(self): + a = IntVector() + a.append(1) + a.append(2) + a.append(3) + a.append(4) + a.append(5) + + with self.assertRaises(ValueError): + a >> -1 + + with self.assertRaises(ValueError): + a << -1 + + with self.assertRaises(ValueError): + a << -6 + + b = a << 2 + self.assertEqual(list(b), [3, 4, 5]) + + a <<= 2 + self.assertEqual(list(a), [3, 4, 5]) + + b = a >> 2 + self.assertEqual(list(b), [0, 0, 3, 4, 5]) + + a >>= 2 + self.assertEqual(list(a), [0, 0, 3, 4, 5]) + + def test_int_vector(self): + a = IntVector() + a.append(1) + a.append(2) + a.append(3) + a.append(4) + a.append(5) + + self.assertEqual(list(a), [1, 2, 3, 4, 5]) + + a.sort(reverse=True) + self.assertEqual(list(a), [5, 4, 3, 2, 1]) + + self.assertTrue(a.max(), 5) + self.assertTrue(a.min(), 1) + self.assertTrue(a.minIndex(), 4) + + self.assertEqual(a.maxIndex(reverse=True), 0) + self.assertEqual(a.maxIndex(reverse=False), 0) + + a[4] = 5 + self.assertTrue(a[4] == 5) + + a_plus_one = a + 1 + self.assertEqual(list(a_plus_one), [6, 5, 4, 3, 6]) + + sliced = a[0:3] + self.assertEqual(list(sliced), [5, 4, 3]) + + with self.assertRaises(IndexError): + item = a[6] + + copy_of_a = a.copy() + self.assertEqual(list(a), list(copy_of_a)) + + another_copy_of_a = copy_of_a.copy( ) + self.assertEqual(list(a), list(another_copy_of_a)) + +#--- + + def test_div(self): + v = IntVector() + v[0] = 100 + v[1] = 10 + v[2] = 1 + v /= 10 + + self.assertEqual(list(v), [10, 1, 0]) + + def test_true(self): + iv = IntVector() + self.assertFalse(iv) # Will invoke the __len__ function; could override with __nonzero__ + iv[0] = 1 + self.assertTrue(iv) + + def test_time_vector(self): + time_vector = TimeVector() + + time1 = CTime(datetime.datetime(2013, 8, 13, 0, 0, 0)) + time2 = CTime(datetime.datetime(2013, 8, 13, 1, 0, 0)) + + time_vector.setDefault(time2) + + time_vector.append(time1) + time_vector[2] = time2 + + self.assertEqual(time_vector[0], time1) + self.assertEqual(time_vector[1], time2) + self.assertEqual(time_vector[2], time2) + + tv1 = TimeVector(default_value=datetime.date(2000, 1, 1), initial_size=2) + self.assertEqual(tv1[0], datetime.date(2000, 1, 1)) + + tv2 = TimeVector() + tv2.append(time2) + + def test_permutation_vector(self): + vector = DoubleVector() + + for i in range(5, 0, -1): + vector.append(i) + + permutation_vector = vector.permutationSort() + + for index, value in enumerate(range(5, 0, -1)): + self.assertEqual(vector[index], value) + + vector.permute(permutation_vector) + + for index, value in enumerate(range(1, 6)): + self.assertEqual(vector[index], value) + + def test_contains_time(self): + start = datetime.datetime(2010, 1, 1, 0, 0, 0) + end = datetime.datetime(2010, 2, 1, 0, 0, 0) + other = datetime.datetime(2010, 1, 15, 0, 0, 0) + + tv = TimeVector() + tv.append(start) + tv.append(end) + + self.assertTrue(start in tv) + self.assertTrue(end in tv) + self.assertTrue(other not in tv) + + def test_unique(self): + iv = IntVector() + iv.append(1) + iv.append(1) + iv.append(1) + iv.append(0) + iv.append(1) + iv.append(2) + iv.append(2) + iv.append(0) + iv.append(3) + iv.selectUnique() + self.assertEqual(len(iv), 4) + self.assertEqual(iv[0], 0) + self.assertEqual(iv[1], 1) + self.assertEqual(iv[2], 2) + self.assertEqual(iv[3], 3) + + def test_element_sum(self): + dv = DoubleVector() + iv = IntVector() + for i in range(10): + dv.append(i + 1) + iv.append(i + 1) + + self.assertEqual(dv.elementSum(), 55) + self.assertEqual(iv.elementSum(), 55) + + def test_time_vector_regular(self): + start = datetime.datetime(2010, 1, 1, 0, 0, 0) + end = datetime.datetime(2010, 2, 1, 0, 0, 0) + + with self.assertRaises(ValueError): + trange = TimeVector.createRegular(end, start, "1X") + + with self.assertRaises(TypeError): + trange = TimeVector.createRegular(start, end, "1X") + + with self.assertRaises(TypeError): + trange = TimeVector.createRegular(start, end, "1") + + with self.assertRaises(TypeError): + trange = TimeVector.createRegular(start, end, "X") + + with self.assertRaises(TypeError): + trange = TimeVector.createRegular(start, end, "1.5Y") + + trange = TimeVector.createRegular(start, end, "d") + trange = TimeVector.createRegular(start, end, "D") + trange = TimeVector.createRegular(start, end, "1d") + self.assertEqual(trange[0].datetime(), start) + self.assertEqual(trange[-1].datetime(), end) + date = start + delta = datetime.timedelta(days=1) + for t in trange: + self.assertEqual(t, date) + date += delta + + end = datetime.datetime(2010, 1, 10, 0, 0, 0) + trange = TimeVector.createRegular(start, end, "2d") + self.assertEqual(trange[-1].datetime(), datetime.datetime(2010, 1, 9, 0, 0, 0)) + self.assertEqual(5, len(trange)) + + end = datetime.datetime(2012, 1, 10, 0, 0, 0) + trange = TimeVector.createRegular(start, end, "3M") + self.assertTrue(trange[-1] == datetime.datetime(2012, 1, 1, 0, 0, 0)) + self.assertTrue(trange[1] == datetime.datetime(2010, 4, 1, 0, 0, 0)) + self.assertTrue(trange[2] == datetime.datetime(2010, 7, 1, 0, 0, 0)) + self.assertTrue(trange[3] == datetime.datetime(2010, 10, 1, 0, 0, 0)) + self.assertTrue(trange[4] == datetime.datetime(2011, 1, 1, 0, 0, 0)) + + start = datetime.datetime(1980, 1, 1, 0, 0, 0) + end = datetime.datetime(2020, 1, 1, 0, 0, 0) + trange = TimeVector.createRegular(start, end, "2Y") + for (y, t) in zip(six.moves.xrange(1980, 2022, 2), trange): + self.assertTrue(t == datetime.datetime(y, 1, 1, 0, 0, 0)) + + trange = TimeVector.createRegular(start, datetime.date(2050, 1, 1), "1Y") + + def test_asList(self): + v = IntVector() + v[0] = 100 + v[1] = 10 + v[2] = 1 + + l = v.asList() + self.assertListEqual(l, [100, 10, 1]) + + def test_true_false(self): + v = IntVector(default_value=77) + self.assertFalse(v) + v[10] = 77 + self.assertTrue(v) + + v = DoubleVector(default_value=77) + self.assertFalse(v) + v[10] = 77 + self.assertTrue(v) + + def test_count_equal(self): + v = IntVector(default_value=77) + v[0] = 1 + v[10] = 1 + v[20] = 1 + self.assertEqual(v.countEqual(1), 3) + + v = DoubleVector(default_value=77) + v[0] = 1 + v[10] = 1 + v[20] = 1 + self.assertEqual(v.countEqual(1), 3) + + def range_test(self, v, a, b, d): + v.initRange(a, b, d) + r = range(a, b, d) + + self.assertEqual(len(v), len(r)) + for a, b in zip(v, r): + self.assertEqual(a, b) + + def create_range_test(self, v, a, b, d): + v = IntVector.createRange(a, b, d) + r = range(a, b, d) + + self.assertEqual(len(v), len(r)) + for a, b in zip(v, r): + self.assertEqual(a, b) + + def test_range(self): + v = IntVector() + v[10] = 99 + + with self.assertRaises(ValueError): + v.initRange(1, 2, 0) + + self.range_test(v, 0, 5, 1) + self.range_test(v, 0, 100, 3) + self.range_test(v, 0, 100, -3) + + self.create_range_test(v, 0, 5, 1) + self.create_range_test(v, 0, 100, 3) + self.create_range_test(v, 0, 100, -3) + + + + def test_perm_vector(self): + v = IntVector.createRange( 11 , 0 , -1 ) + perm = v.permutationSort( ) + self.assertEqual( perm[0] , 10 ) + self.assertEqual( perm[5] , 5 ) + self.assertEqual( perm[10] , 0 ) + + + def test_init_linear(self): + with self.assertRaises(ValueError): + v = IntVector.create_linear(0, 10, 1) + + v = IntVector.create_linear(0,10,11) + for i in range(len(v)): + self.assertEqual(v[i], i) + + + v = IntVector.create_linear(10,0,11) + for i in range(len(v)): + self.assertEqual(v[i], 10 - i) + + + d = DoubleVector.create_linear(0,1,11) + for i in range(len(d)): + self.assertEqual( d[i] , i*0.10) + + def test_equal(self): + v1 = IntVector() + v1[3] = 99 + + v2 = IntVector() + self.assertNotEqual( v1,v2 ) + v2[3] = 99 + self.assertEqual(v1,v2) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_version.py b/ThirdParty/Ert/python/tests/util_tests/test_version.py new file mode 100644 index 0000000000..c0864b4a20 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_version.py @@ -0,0 +1,110 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_version.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +import os.path + +import ecl +from tests import EclTest +from ecl.util.util import Version,EclVersion + + +class VersionTest(EclTest): + def setUp(self): + pass + + def test_create(self): + v1 = Version(1, 8, 6) + self.assertFalse(v1.isDevelVersion()) + + self.assertEqual(v1.versionString(), "1.8.6") + self.assertEqual(v1.versionTuple(), (1, 8, 6)) + + v2 = Version(2, 0, "X") + self.assertTrue(v2.isDevelVersion()) + + def test_eq(self): + v1 = Version(1, 2, 3) + v2 = Version(1, 2, 3) + + self.assertTrue(v1 == v2) + self.assertEqual(v1, v2) + self.assertEqual(str(v1), str(v2)) + self.assertEqual(repr(v1), repr(v2)) + self.assertFalse(v1 != v2) + + v1 = Version(1, 2, "X") + v2 = Version(1, 2, "Y") + self.assertTrue(v1 != v2) + self.assertFalse(v1 == v2) + + v1 = Version(1, 2, "X") + v2 = Version(1, 2, 0) + self.assertTrue(v1 != v2) + self.assertFalse(v1 == v2) + + v1 = Version(1, 2, "X") + v2 = Version(1, 3, "X") + self.assertTrue(v1 != v2) + self.assertFalse(v1 == v2) + + v1 = Version(1, 2, "X") + v2 = (1, 3, "X") + self.assertTrue(v1 != v2) + self.assertFalse(v1 == v2) + + def test_ge(self): + v1 = Version(1, 2, 3) + v2 = Version(1, 2, 3) + v3 = (1, 2, 2) + + self.assertEqual(str(v1), str(v2)) + self.assertEqual(repr(v1), repr(v2)) + + self.assertTrue(v1 >= v2) + self.assertFalse(v1 < v2) + + self.assertTrue(v1 >= v3) + self.assertFalse(v1 < v3) + + v1 = Version(1, 2, "X") + v2 = Version(1, 1, 9) + self.assertTrue(v1 > v2) + + v2 = Version(1, 2, "X") + self.assertTrue(v1 >= v2) + + v2 = Version(1, 2, 0) + self.assertFalse(v1 >= v2) + + self.assertNotEqual(str(v1), str(v2)) + self.assertNotEqual(repr(v1), repr(v2)) + + + def test_current(self): + current = EclVersion( ) + self.assertTrue(current > (0, 0, 0)) + pfx = 'Version(major=' + self.assertEqual(pfx, repr(current)[:len(pfx)]) + + + def test_root_version(self): + cv = EclVersion( ) + self.assertEqual( ecl.__version__ , cv.versionString() ) + + + def test_root_path(self): + self.assertTrue( os.path.isdir( os.path.join( ecl.root() , "ecl"))) + self.assertTrue( os.path.isfile( os.path.join( ecl.root() , "ecl", "__init__.py"))) + diff --git a/ThirdParty/Ert/python/tests/util_tests/test_work_area.py b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py new file mode 100644 index 0000000000..0d7a69bae5 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os.path +import os + +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +from ecl.util.test import TestAreaContext, TempAreaContext +from tests import EclTest + + +class WorkAreaTest(EclTest): + + def test_full_path(self): + with TestAreaContext("TestArea") as test_area: + with open("test_file" , "w") as fileH: + fileH.write("Something") + + self.assertTrue( os.path.isfile( "test_file") ) + + with self.assertRaises(IOError): + full_path = test_area.getFullPath( "does/not/exists" ) + + with self.assertRaises(IOError): + full_path = test_area.getFullPath( "/already/absolute" ) + + full_path = test_area.getFullPath( "test_file" ) + self.assertTrue( os.path.isfile( full_path )) + self.assertTrue( os.path.isabs( full_path )) + + + def test_temp_area(self): + with TestAreaContext("TestArea") as test_area: + cwd = os.getcwd() + with open("file.txt" , "w") as f: + f.write("File") + + with TempAreaContext("TempArea") as temp_area: + self.assertEqual( cwd, os.getcwd()) + self.assertEqual( cwd, temp_area.get_cwd()) + temp_area.copy_file( "file.txt" ) + + self.assertTrue( os.path.isfile( os.path.join( temp_area.getPath( ) , "file.txt"))) + + os.mkdir("tmp") + os.chdir("tmp") + + self.assertEqual( os.getcwd() , os.path.join( cwd , "tmp")) + + + def test_IOError(self): + with TestAreaContext("TestArea") as test_area: + with self.assertRaises(IOError): + test_area.copy_file( "Does/not/exist" ) + + with self.assertRaises(IOError): + test_area.install_file( "Does/not/exist" ) + + with self.assertRaises(IOError): + test_area.copy_directory( "Does/not/exist" ) + + with self.assertRaises(IOError): + test_area.copy_parent_directory( "Does/not/exist" ) + + os.makedirs("path1/path2") + with open("path1/file.txt" , "w") as f: + f.write("File ...") + + with self.assertRaises(IOError): + test_area.copy_directory( "path1/file.txt" ) + + def test_sync(self): + with TestAreaContext("test_sync") as t: + with open("file.txt" , "w") as f: + f.write("content") + + t.sync() + self.assertTrue( os.path.isfile( "file.txt")) + + def test_multiple_areas(self): + original_dir = os.getcwd() + context_dirs = [] + for i in range(3): + loop_dir = os.getcwd() + self.assertEqual(loop_dir, original_dir, + 'Wrong folder before creating TestAreaContext. Loop: {} -- CWD: {} ' + .format(i, loop_dir)) + + with TestAreaContext("test_multiple_areas") as t: + t_dir = t.get_cwd() + + self.assertNotIn(t_dir, context_dirs, + 'Multiple TestAreaContext objects in the same folder. Loop {} -- CWD: {}' + .format(i, loop_dir)) + context_dirs.append(t_dir) + + # It is possible to make the following assert fail, but whoever run the tests should + # try really really hard to make that happen + self.assertNotEqual(t_dir, original_dir, + 'TestAreaContext in the current working directory. Loop: {} -- CWD: {}' + .format(i, loop_dir)) + + loop_dir = os.getcwd() + self.assertEqual(loop_dir, original_dir, + 'Wrong folder after creating TestAreaContext. Loop: {} -- CWD: {} ' + .format(i, loop_dir)) + diff --git a/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt new file mode 100644 index 0000000000..00d362918c --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt @@ -0,0 +1,12 @@ +set(TEST_SOURCES + __init__.py + test_ecl_well.py + test_ecl_well2.py + test_ecl_well3.py +) + +add_python_package("python.tests.well_tests" ${PYTHON_INSTALL_PREFIX}/tests/well_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.well_tests.test_ecl_well.EclWellTest) +addPythonTest(tests.well_tests.test_ecl_well2.EclWellTest2) +addPythonTest(tests.well_tests.test_ecl_well3.EclWellTest3) diff --git a/ThirdParty/Ert/python/tests/well_tests/__init__.py b/ThirdParty/Ert/python/tests/well_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py new file mode 100644 index 0000000000..8f12c67354 --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py @@ -0,0 +1,448 @@ +import datetime +from ecl import EclFileFlagEnum +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime +from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment + +@statoil_test() +class EclWellTest(EclTest): + ALL_WELLS = ['E5H', 'G1H', 'M41', 'J41', 'D10H', 'P41', 'L41', 'M42', 'S41', 'S13H', 'Q12HT2', 'O41', 'L11H', 'Q21H', + 'E6CH', 'D4Y1H', 'D4Y2H', 'I13Y1H', 'Q21AY1H', 'F5AH', 'O14Y4HT2', 'K24Y1H', 'K24Y3H', 'S21H', 'N11H', + 'L23Y1H', 'D7AY1H', 'S21AHT2', 'H2AH', 'S21AHT3', 'L23Y6H', 'N11AH', 'N11BY1H', 'X23Y2H', 'N22Y3HT3', + 'G1BY1HT2', 'Q21BY1H', 'Q21BY2T2', 'A08', 'A37', 'P24Y4H', 'A11', 'A33', 'P21BY1H', 'H6BY2H', 'M24AH', + 'TOGIB2H', 'TOGIB3H', 'TOGIB4H', 'TOGIB5H', 'TOGIB6H', 'TAP21', 'D1AH', 'D1BYH', 'D2H', 'D2AYH', 'D4YH', + 'D5AH', 'D6H', 'D7H', 'D7AYH', 'D8AH', 'D8BYH', 'E1AH', 'E1BYH', 'E3YH', 'E4H', 'E5AH', 'E6BH', 'E6DYH', + '31/2-T1', 'F1AH', 'F1BYH', 'F4AHT2', 'F5H', 'F5BYH', 'F6AH', 'F6BYH', '2B3H', 'G1AHT2', 'G1BYH', 'G3H', + 'G3AYH', 'G4AH', 'G4BYH', 'G6HT2', 'G6AYH', '31/5-T1', 'H1AH', 'H2BYH', 'H2HT2', 'H3ABH', 'H3CYH', 'H4HT2', + 'H5AHT2', 'H6AH', 'H6BYH', 'Z1H', 'Z2H', 'I11AH', 'I12AYH', 'I13YH', 'I14AHT2', 'I14BYH', 'I21AHT2', + 'I21BYH', 'I22AH', 'I23AH', 'I32YH', 'J11AH', 'J12H', 'J13H', 'J13AYH', 'J14H', 'J14AYH', 'J21YH', 'J22YH', + 'J22AYH', 'J23AH', 'J24HT2', 'J24AYH', 'K11YH', 'K12AH', 'K12BYH', 'K13AH', 'K14AYH', 'K21AYH', 'K22AH', + 'K23AH', 'K24YH', 'L11AH', 'L11BYH', 'L12Y', 'L13H', 'L13AYH', 'L14YH', 'L21AYH', 'L22AYH', 'L23YH', + 'L24AYH', 'M11H', 'M12H', 'M13YH', 'M14AHT2', 'M14BYH', 'M21H', 'M22H', 'M23AH', 'M24YH', 'N11BYH', + 'N12HT2', 'N13H', 'N14AH', 'N21YH', 'N22YH', 'N23AYH', 'N24YH', 'O11H', 'O11AYH', 'O12AH', 'O13AH', + 'O13BYH', 'O14YH', 'O21YH', 'O23YH', 'O26YH', 'P11YH', 'P11AYH', 'P12H', 'P13AHT2', 'P13BYH', 'P14AHT2', + 'P14BYH', 'P21AYH', 'P21BYH', 'P22AYH', 'P23YH', 'P24YH', 'P24Y1H', 'Q11AHT2', 'Q11BYH', 'Q12AH', 'Q12BH', + 'Q13AH', 'Q14H', 'Q14AYH', 'Q21AYH', 'Q21BH1', 'Q21BH2', 'S11HT3', 'S12H', 'S13AH', 'S14AH', 'S14BYH', + 'S21BYH', 'S22AH', 'S23HT2', 'S23AYH', 'S24YH', 'S31H', 'X11AH', 'X11BYH', 'X12H', 'X12AH', 'X13YH', + 'X14AYH', 'X21H', 'X22H', 'X22AYH', 'X23YH', 'X24AH', 'Y11AH', 'Y11BYH', 'Y12YH', 'Y13AH', 'Y13BYH', + 'Y14AYH', 'Y21YH', 'Y22YH', 'Y23AHT2', 'Y23CYH', 'Y24AH'] + + + @classmethod + def setUpClass(cls): + EclWellTest.__well_info = None + EclWellTest.__well_info_with_no_well_segments = None + + + def getWellInfoWithNoWellSegments(self): + """ @rtype: WellInfo """ + if EclWellTest.__well_info_with_no_well_segments is None: + grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") + rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") + + grid = EclGrid(grid_path) + + rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) + + EclWellTest.__well_info_with_no_well_segments = WellInfo(grid, rst_file, False) + + + return EclWellTest.__well_info_with_no_well_segments + + def getWellInfo(self): + """ @rtype: WellInfo """ + if EclWellTest.__well_info is None: + grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") + rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") + + grid = EclGrid(grid_path) + + rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) + + EclWellTest.__well_info = WellInfo(grid, rst_file) + + + return EclWellTest.__well_info + + + def test_no_such_well(self): + grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + rst_path1 = self.createTestPath("nosuch/path/ECLIPSE.X001") + rst_path2 = self.createTestPath("nosuch/path/ECLIPSE.X002") + grid = EclGrid(grid_path) + with self.assertRaises(IOError): + _ = WellInfo(grid, rst_path1) + with self.assertRaises(IOError): + _ = WellInfo(grid, [rst_path1, rst_path2]) + + def test_construction(self): + grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0011") + rst_path_2 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0022") + rst_path_3 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0035") + rst_path_4 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0061") + + grid = EclGrid(grid_path) + + def checkWellInfo(well_info, well_count, report_step_count): + self.assertEqual(len(well_info), well_count) + + for index, well_time_line in enumerate(well_info): + self.assertEqual(len(well_time_line), report_step_count[index]) + + well_info = WellInfo(grid, rst_path_1) + checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) + + well_info = WellInfo(grid, EclFile(rst_path_1)) + checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) + + well_info = WellInfo(grid, [rst_path_1, rst_path_2, rst_path_3]) + checkWellInfo(well_info, well_count=8, report_step_count=[3, 3, 3, 3, 3, 2, 2, 2]) + + well_info = WellInfo(grid, [EclFile(rst_path_1), EclFile(rst_path_2), rst_path_3, EclFile(rst_path_4)]) + checkWellInfo(well_info, well_count=8, report_step_count=[4, 4, 4, 4, 4, 3, 3, 3]) + + + well_info = WellInfo(grid) + well_info.addWellFile(rst_path_1, True) + + checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) + + well_info.addWellFile(EclFile(rst_path_2), True) + checkWellInfo(well_info, well_count=8, report_step_count=[2, 2, 2, 2, 2, 1, 1, 1]) + + well_info.addWellFile(EclFile(rst_path_3), True) + checkWellInfo(well_info, well_count=8, report_step_count=[3, 3, 3, 3, 3, 2, 2, 2]) + + well_info.addWellFile(rst_path_4, True) + checkWellInfo(well_info, well_count=8, report_step_count=[4, 4, 4, 4, 4, 3, 3, 3]) + + + + def test_well_type_enum(self): + source_file_path = "lib/include/ert/ecl_well/well_conn.h" + # The header file has duplicated symbols, so the simple test fails. + # self.assertEnumIsFullyDefined(WellTypeEnum, "well_type_enum", source_file_path) + + + def test_well_connection_direction_enum(self): + source_file_path = "lib/include/ert/ecl_well/well_conn.h" + self.assertEnumIsFullyDefined(WellConnectionDirectionEnum, "well_conn_dir_enum", source_file_path) + + + def test_well_info(self): + well_info = self.getWellInfo() + self.assertEqual(len(well_info), 222) + + all_well_names = well_info.allWellNames() + + self.assertEqual(len(well_info), len(all_well_names)) + self.assertEqual(EclWellTest.ALL_WELLS, all_well_names) + + for well_name in all_well_names: + self.assertTrue(well_name in well_info) + + self.assertEqual(well_info[0], well_info[all_well_names[0]]) + self.assertEqual(well_info[1], well_info[all_well_names[1]]) + self.assertEqual(well_info[221], well_info[all_well_names[221]]) + + self.assertNotEqual(well_info[0], well_info[1]) + + well_time_lines = [wtl for wtl in well_info] + self.assertEqual(len(well_time_lines), len(well_info)) + + with self.assertRaises(IndexError): + err = well_info[222] + + with self.assertRaises(KeyError): + err = well_info["Well"] + + + + + def test_well_time_line(self): + well_info = self.getWellInfo() + + for well_time_line in well_info: + self.assertEqual(len(well_time_line), 1) + + well_states = set() + for well_name in EclWellTest.ALL_WELLS: + well_time_line = well_info[well_name] + well_states.add(well_time_line[0]) + + with self.assertRaises(IndexError): + err = well_time_line[1] + + self.assertEqual(len(well_states), len(EclWellTest.ALL_WELLS)) + + # testing name and repr + info = self.getWellInfo() + wtl = info['G6HT2'] + self.assertEqual('G6HT2', wtl.getName()) + rep = repr(wtl) + print(rep) + pfx = 'WellTimeLine(' + self.assertEqual(pfx, rep[:len(pfx)]) + + # testing __getitem__ and its well state + ws = wtl[0] + self.assertTrue(ws.isOpen()) + self.assertEqual(ws.wellType(), WellTypeEnum.ECL_WELL_PRODUCER) + self.assertTrue(ws.isMultiSegmentWell()) + pfx = 'WellState(' + self.assertEqual(pfx, repr(ws)[:len(pfx)]) + + + def test_well_state(self): + well_info = self.getWellInfo() + + sim_time = CTime(datetime.date(2000, 1, 1)) + open_states = {True: 0, False: 0} + msw_states = {True: 0, False: 0} + well_types = {WellTypeEnum.ECL_WELL_ZERO: 0, + WellTypeEnum.ECL_WELL_PRODUCER: 0, + WellTypeEnum.ECL_WELL_GAS_INJECTOR: 0, + WellTypeEnum.ECL_WELL_OIL_INJECTOR: 0, + WellTypeEnum.ECL_WELL_WATER_INJECTOR: 0} + + segments = set() + branches = set() + connections = set() + connections_count = 0 + + for index, well_name in enumerate(EclWellTest.ALL_WELLS): + well_time_line = well_info[well_name] + well_state = well_time_line[0] + + self.assertEqual(well_state.name(), well_name) + well_number = well_state.wellNumber() + self.assertEqual(well_number, index) + + self.assertEqual(well_state.reportNumber(), 135) + self.assertEqual(well_state.simulationTime(), sim_time) + + open_states[well_state.isOpen()] += 1 + msw_states[well_state.isMultiSegmentWell()] += 1 + + well_types[well_state.wellType()] += 1 + + self.assertTrue(well_state.hasGlobalConnections()) + global_connections = well_state.globalConnections() + connections_count += len(global_connections) + connections.update(global_connections) + + # branches.add(well_state.branches()) + # segments.add(well_state.segments()) + + self.assertEqual(open_states[True], 53) + self.assertEqual(open_states[False], 169) + + self.assertEqual(msw_states[True], 169) + self.assertEqual(msw_states[False], 53) + + self.assertEqual(well_types[WellTypeEnum.ECL_WELL_ZERO], 0) + self.assertEqual(well_types[WellTypeEnum.ECL_WELL_WATER_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.ECL_WELL_OIL_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.ECL_WELL_GAS_INJECTOR], 1) + self.assertEqual(well_types[WellTypeEnum.ECL_WELL_PRODUCER], 221) + + self.assertEqual(len(connections), connections_count) + + + + def test_well_segments(self): + well_info = self.getWellInfo() + + well_name = "X22AYH" + well_time_line = well_info[well_name] + well_state = well_time_line[0] + + segments = well_state.segments() + + branch_ids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55] + + outlet_ids = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 45, 47, 48, 49, 50, 51, + 52, 53, 54, 55] + + depths = [1554.0, 1557.505, 1557.506, 1557.50540469, 1557.75140469, 1558.24240469, 1558.24240469, 1557.75340469, + 1557.50740469, 1557.50658613, 1557.50628848, 1557.50584678, 1557.50384678, 1557.50484678, 1557.50402823, + 1557.50380498, 1557.50454913, 1557.50425147, 1557.50325147, 1557.50273057, 1557.50473057, 1557.50373057, + 1557.5038794, 1557.5048794, 1557.50398643, 1557.50406085, 1557.50606085, 1557.50670767, 1557.635, 1557.509, + 1557.504, 1557.503, 1557.502, 1557.50242878, 1557.50542878, 1557.50505671, 1557.50602409, 1557.50602409, + 1557.50402409, 1557.50485764, 1557.50563489, 1557.50543796, 1557.50643796, 1557.50843796, 1557.50799148, + 1557.50709851, 1557.50665427, 1557.50865427, 1557.50943383, 1557.50543383, 1557.50443383, 1557.50495473, + 1557.504285, 1557.50473149, 1557.50442009, 1557.505, 1557.506, 1557.50540469, 1557.75140469, 1558.24240469, + 1558.24240469, 1557.75340469, 1557.50740469, 1557.50658613, 1557.50628848, 1557.50584678, 1557.50384678, + 1557.50484678, 1557.50402823, 1557.50380498, 1557.50454913, 1557.50425147, 1557.50325147, 1557.50273057, + 1557.50473057, 1557.50373057, 1557.5038794, 1557.5048794, 1557.50398643, 1557.50406085, 1557.50606085, + 1557.50670767, 1557.635, 1557.509, 1557.504, 1557.503, 1557.502, 1557.50242878, 1557.50542878, 1557.50505671, + 1557.50602409, 1557.50602409, 1557.50402409, 1557.50485764, 1557.50563489, 1557.50543796, 1557.50643796, + 1557.50799148, 1557.50799148, 1557.50665427, 1557.50865427, 1557.50943383, 1557.50543383, 1557.50443383, + 1557.50495473, 1557.504285, 1557.50473149, 1557.50442009] + + lengths = [1853.483, 525.634, 89.101, 148.227, 105.066, 70.981, 50.194, 71.215, 129.929, 141.712, 141.239, 108.247, + 200.032, 116.122, 141.525, 141.983, 112.622, 72.694, 105.195, 149.555, 128.22, 83.537, 112.533, 155.336, + 86.552, 71.427, 129.949, 92.347, 210.312, 58.0, 218.375, 111.0, 250.925, 76.233, 72.565, 127.481, 97.987, + 75.648, 121.119, 129.137, 188.157, 109.433, 142.914, 84.9, 47.458, 57.507, 55.704, 211.767, 121.219, + 143.23, 145.666, 146.044, 88.195, 72.891, 58.92, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + + total_lengths = [1853.483, 2379.117, 2468.218, 2616.445, 2721.511, 2792.492, 2842.686, 2913.901, 3043.83, 3185.542, + 3326.781, 3435.028, 3635.06, 3751.182, 3892.707, 4034.69, 4147.312, 4220.006, 4325.201, 4474.756, + 4602.976, 4686.513, 4799.046, 4954.382, 5040.934, 5112.361, 5242.31, 5334.657, 2063.795, 2121.795, + 2340.17, 2451.17, 2702.095, 2778.328, 2850.893, 2978.374, 3076.361, 3152.009, 3273.128, 3402.265, + 3590.422, 3699.855, 3842.769, 3927.669, 3975.127, 4032.634, 4088.338, 4300.105, 4421.324, 4564.554, + 4710.22, 4856.264, 4944.459, 5017.35, 5076.27, 2379.217, 2468.318, 2616.545, 2721.611, 2792.592, + 2842.786, 2914.001, 3043.93, 3185.642, 3326.881, 3435.128, 3635.16, 3751.282, 3892.807, 4034.79, + 4147.412, 4220.106, 4325.301, 4474.856, 4603.076, 4686.613, 4799.146, 4954.482, 5041.034, 5112.461, + 5242.41, 5334.757, 2063.895, 2121.895, 2340.27, 2451.27, 2702.195, 2778.428, 2850.993, 2978.474, + 3076.461, 3152.109, 3273.228, 3402.365, 3590.522, 3699.955, 3842.869, 3975.227, 3975.227, 4088.438, + 4300.205, 4421.424, 4564.654, 4710.32, 4856.364, 4944.559, 5017.45, 5076.37] + + link_count = 0 + main_stem = {True: 0, False: 0} + nearest_wellhead = {True: 0, False: 0} + for index, segment in enumerate(segments): + assert isinstance(segment, WellSegment) + self.assertEqual(segment.id(), index + 1) + link_count += segment.linkCount() + self.assertEqual(segment.branchId(), branch_ids[index]) + self.assertEqual(segment.outletId(), outlet_ids[index]) + + self.assertTrue(segment.isActive()) + main_stem[segment.isMainStem()] += 1 + nearest_wellhead[segment.isNearestWellHead()] += 1 + + self.assertFloatEqual(segment.depth(), depths[index]) + self.assertFloatEqual(segment.length(), lengths[index]) + self.assertFloatEqual(segment.totalLength(), total_lengths[index]) + + if index == 0: + self.assertEqual(segment.diameter(), 0.0) + else: + self.assertEqual(segment.diameter(), 0.159) + + + self.assertEqual(main_stem[True], 28) + self.assertEqual(main_stem[False], 80) + + self.assertEqual(nearest_wellhead[True], 1) + self.assertEqual(nearest_wellhead[False], 107) + + self.assertEqual(link_count, 53) + + + + def test_well_connections(self): + well_info = self.getWellInfo() + + well_name = "H6BY2H" + well_connections_ijk = [(33, 157, 9), (32, 157, 9), (32, 157, 51), (32, 157, 52), + (32, 157, 53), (32, 157, 54), (32, 157, 55), (32, 157, 56), + (32, 157, 57), (31, 157, 57), (31, 158, 57), (31, 158, 56), + (30, 158, 56), (29, 158, 56), (29, 157, 56), (28, 157, 56), + (28, 158, 56), (28, 158, 55), (27, 158, 55), (27, 158, 54), + (26, 158, 54), (26, 158, 53), (25, 158, 53), (24, 158, 53), + (23, 158, 53), (23, 158, 54), (22, 158, 54), (21, 158, 54), + (20, 158, 54), (20, 158, 55), (19, 158, 55), (19, 158, 54), + (18, 158, 54), (17, 158, 54), (16, 158, 54), (16, 158, 55), + (15, 158, 55), (15, 158, 54), (15, 158, 53), (14, 158, 54), + (13, 158, 54), (13, 158, 55), (12, 158, 55), (12, 157, 55)] + + well_connection_factors = [3022.45092773, 171.561004639, 237.263000488, 135.57800293, 177.925994873, 289.058990479, + 1081.09997559, 1575.79101562, 3679.54907227, 2865.51489258, 3999.2199707, 14205.3300781, + 1864.43005371, 1296.47302246, 3.40599989891, 2012.7199707, 2656.25390625, 4144.21923828, + 6.22700023651, 96.4029998779, 0.144999995828, 80.81199646, 114.416999817, 97.5159988403, + 26.8530006409, 0.12800000608, 34238.15625, 34493.7070312, 2618.16894531, 31999.1992188, + 27874.6191406, 7343.23681641, 35418.1679688, 34612.6523438, 3486.13500977, 15446.3691406, + 65.4499969482, 8687.91113281, 13238.8037109, 5644.90380859, 7499.49707031, 12863.5292969, + 12277.4716797, 19404.5488281] + + well_time_line = well_info[well_name] + well_state = well_time_line[0] + + self.assertFalse(well_state.isMultiSegmentWell()) + + self.assertTrue(well_state.hasGlobalConnections()) + global_connections = well_state.globalConnections() + + for index, connection in enumerate(global_connections): + assert isinstance(connection, WellConnection) + self.assertTrue(connection.isOpen()) + self.assertEqual(connection.ijk(), well_connections_ijk[index]) + self.assertFalse(connection.isMultiSegmentWell()) + self.assertEqual(connection.segmentId(), -999) + self.assertFalse(connection.isFractureConnection()) + self.assertTrue(connection.isMatrixConnection()) + self.assertFloatEqual(connection.connectionFactor(), well_connection_factors[index]) + self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirX) + + self.assertNotEqual(global_connections[0], global_connections[1]) + self.assertEqual(global_connections[0], global_connections[0]) + + + def test_well_connections_msw(self): + well_info = self.getWellInfo() + + well_name = "X22AYH" + well_time_line = well_info[well_name] + well_state = well_time_line[0] + + segment_ids = [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108] + + self.assertTrue(well_state.isMultiSegmentWell()) + + self.assertTrue(well_state.hasGlobalConnections()) + global_connections = well_state.globalConnections() + + self.assertEqual(len(global_connections), len(segment_ids)) + + for index, connection in enumerate(global_connections): + assert isinstance(connection, WellConnection) + self.assertTrue(connection.isOpen()) + self.assertTrue(connection.isMultiSegmentWell()) + self.assertEqual(connection.segmentId(), segment_ids[index]) + self.assertFalse(connection.isFractureConnection()) + self.assertTrue(connection.isMatrixConnection()) + self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) + + + def test_well_connections_msw_do_not_load_segments(self): + well_info = self.getWellInfoWithNoWellSegments() + + well_name = "X22AYH" + well_time_line = well_info[well_name] + well_state = well_time_line[0] + + segment_ids = [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108] + + self.assertTrue(well_state.isMultiSegmentWell()) + self.assertFalse(well_state.hasSegmentData()) + + self.assertTrue(well_state.hasGlobalConnections()) + global_connections = well_state.globalConnections() + + self.assertEqual(len(global_connections), len(segment_ids)) + + for index, connection in enumerate(global_connections): + assert isinstance(connection, WellConnection) + self.assertTrue(connection.isOpen()) + self.assertTrue(connection.isMultiSegmentWell()) + self.assertEqual(connection.segmentId(), segment_ids[index]) + self.assertFalse(connection.isFractureConnection()) + self.assertTrue(connection.isMatrixConnection()) + self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py new file mode 100644 index 0000000000..554e18bda2 --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py @@ -0,0 +1,45 @@ +import datetime +import os.path + +from ecl import EclFileFlagEnum +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime +from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment + + +@statoil_test() +class EclWellTest2(EclTest): + grid = None + + + def getGrid(self): + if EclWellTest2.grid is None: + EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) + + return EclWellTest2.grid + + + def checkWell(self , rst_file): + segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, + 128.534 , 165.33 , 59.97 , 936.719 ] + + well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file ))) + well_time_line = well_info["F4BYH"] + for well_state in well_time_line: + self.assertTrue( well_state.isMultiSegmentWell() ) + self.assertTrue( well_state.hasSegmentData() ) + + for index,length in enumerate(segment_length): + segment = well_state.igetSegment(index) + self.assertFloatEqual( segment.length() , length ) + + + + + def testWell(self): + self.checkWell("T07-4A-W2014-06.X0695") + self.checkWell("T07-4A-W2014-06.X0709") + self.checkWell("T07-4A-W2014-06.UNRST") + diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py new file mode 100644 index 0000000000..9252f111d6 --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py @@ -0,0 +1,50 @@ +import datetime +import os.path + +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from ecl.summary import EclSum +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime +from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment + +@statoil_test() +class EclWellTest3(EclTest): + grid = None + + def test_rates(self): + grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + rst_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + sum_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + + grid = EclGrid(grid_path) + well_info = WellInfo(grid, rst_path) + sum = EclSum(sum_path) + + for wtl in well_info: + for well_state in wtl: + # print "%03d %g %g " % (R , well_state.oilRate(), sum.get_from_report( "WOPR:%s" % well , R)) + if wtl.getName() == "OP_4": + pass + # print well_state.oilRate(), well_state.waterRate(), well_state.gasRate(), well_state.volumeRate() + # print well_state.oilRateSI(), well_state.waterRateSI(), well_state.gasRateSI(), well_state.volumeRateSI() + self.assertEqual(well_state.oilRate(), well_state.oilRateSI()) + self.assertEqual(well_state.waterRate(), well_state.waterRateSI()) + self.assertEqual(well_state.gasRate(), well_state.gasRateSI()) + self.assertEqual(well_state.volumeRate(), well_state.volumeRateSI()) + # print sum.get_from_report("WOPR:%s" % wtl.getName(), 1) + # print sum.get_from_report( "WWPR:%s" % wtl.getName(), 30 ) + + for conn in well_state.globalConnections(): + # print conn.gasRate(), conn.waterRate(), conn.oilRate() + # print conn.gasRateSI(), conn.waterRateSI(), conn.oilRateSI() + self.assertEqual(conn.gasRate(), conn.gasRateSI()) + self.assertEqual(conn.waterRate(), conn.waterRateSI()) + self.assertEqual(conn.oilRate(), conn.oilRateSI()) + self.assertEqual(conn.volumeRate(), conn.volumeRateSI()) + # + # print sum.get_from_report("WGPR:%s" % wtl.getName(), 30) + # + # self.assertFloatEqual(well_state.oilRate(), sum.get_from_report("WOPR:%s" % wtl.getName(), 30)) + # self.assertFloatEqual(well_state.waterRate(), sum.get_from_report("WWPR:%s" % wtl.getName(), 30)) + # self.assertFloatEqual(well_state.gasRate(), sum.get_from_report("WGPR:%s" % wtl.getName(), 30)) diff --git a/ThirdParty/Ert/redhat/ecl.spec b/ThirdParty/Ert/redhat/ecl.spec new file mode 100644 index 0000000000..47b7a85513 --- /dev/null +++ b/ThirdParty/Ert/redhat/ecl.spec @@ -0,0 +1,101 @@ +# +# spec file for package ecl +# + +%define tag rc1 + +Name: ecl +Version: 2017.10 +Release: 0 +Summary: ECL library +License: GPL-3+ +Group: Development/Libraries/C and C++ +Url: http://ert.nr.no +Source0: https://github.com/Statoil/libecl/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz +BuildRequires: lapack-devel zlib-devel iputils +BuildRequires: devtoolset-6-toolchain +%{?!el6:BuildRequires: python-devel numpy} +%{?el6:BuildRequires: cmake3} +%{?!el6:BuildRequires: cmake} +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Requires: libecl1 = %{version} + +%description +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. + +%package -n libecl1 +Summary: ECL library +Group: System/Libraries + +%{?!el6: +%package -n python-ecl +Summary: ECL - Python bindings +Group: Python/Libraries +Requires: libecl1 + +%description -n python-ecl +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. This package contains the Python bindings. + +%package -n python-cwrap +Summary: Simplify ctypes based wrapping of C code. +Group: Python/Libraries + +%description -n python-cwrap +Package to simplify ctypes based wrapping of C code. +} + +%description -n libecl1 +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. + +%package devel +Summary: Development and header files for libecl +Group: Development/Libraries/C and C++ +Requires: %{name} = %{version} +Requires: lapack-devel +Requires: libecl1 = %{version} + +%description devel +This package contains the development and header files for ecl + +%prep +%setup -q -n libecl-release-%{version}-%{tag} + +%build +scl enable devtoolset-6 bash +DESTDIR=${RPM_BUILD_ROOT} %{?el6:cmake3} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 %{?el6:-DENABLE_PYTHON=0} %{?!el6:-DENABLE_PYTHON=1}-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gfortran +make + +%install +make install DESTDIR=${RPM_BUILD_ROOT} + +%clean +rm -rf %{buildroot} + +%post -n libecl1 -p /sbin/ldconfig + +%postun -n libecl1 -p /sbin/ldconfig + +%files +%doc README.md + +%files -n libecl1 +%defattr(-,root,root,-) +%{_libdir}/*.so.* +%{_bindir}/* + +%files devel +%defattr(-,root,root,-) +%{_libdir}/*.so +%{_includedir}/* +%{_datadir}/cmake/* +%{_datadir}/man/* + +%{?!el6: +%files -n python-ecl +%defattr(-,root,root,-) +/usr/lib/python2.7/site-packages/ecl/* + +%files -n python-cwrap +%defattr(-,root,root,-) +/usr/lib/python2.7/site-packages/cwrap/* +} diff --git a/ThirdParty/Ert/requirements.txt b/ThirdParty/Ert/requirements.txt new file mode 100644 index 0000000000..4622ca5be8 --- /dev/null +++ b/ThirdParty/Ert/requirements.txt @@ -0,0 +1,2 @@ +cwrap +numpy diff --git a/ThirdParty/Ert/test-data/local/nexus/SPE1.plt b/ThirdParty/Ert/test-data/local/nexus/SPE1.plt index cf144f845bd66472e2fede9d2f2b504012c892cf..e8226ce9b0a737bcd7c1a10c670f018d640da9c7 100644 GIT binary patch literal 43012 zcmeHQ33yY*_AdxnR1{eh5F}+2WDy8RfF`-gy~$0|G+P4&WK$7Q;i)XoCyJD{KtYgI zMFEke&;qh4pdyRU4P_A!1)hc{B1QgyJ{G~J{?D1*bD3so8@PR+7U%m;&fIh7&dfP; z=FItJX_JzYTKL@FpiXCXdUQHn`&O-6wbprT-MVDxTDNJ{x;4nKq}zg4OF*Yfg7!&C z<&!dewl?8Af4yFd7C;|>;sZa>iQaUdCE(2PdUU>k*Xp*V>l$9Eb6}rHTHCag`_)1J zm4V8I>H2pr*O?5Br2}$g+T3o`Ez|Ap4%KyW5))w6J~Xfc_c*8GzaWRRC%ZWCQ91R0F8CLfGzT(3x%%y*`~N17#w2 z0(a{CAoGLF4>CW<{2;SBe7a1ZLzkHbsGrABIhwzN`=XIr_AycY=M&)dCxxjIvJ=dzbfF)LRB38`6HowLv`-)vM4N zaQhYFS%xnlWy)@QCfMEuYv2Mu%4GXG@jZMJbPh6K=3^7L&V}|f=PNi~VZRH<4~iGq zFVFz&8#aJ0!!HA60=a=KKn`61ktCHNb@w=vC?*NjM@3lr5#viJ}%T;^bUL%lN z^`N=a-nLcsdwMNm_7Y&sdGEHw_MQqCcOf^AeCvSGerld$(KO6ElG4l1$wS_0nt!c% z$P2eYH3XDQIS$r=3j1P~YFj+Nit|PC$+#T*0IDjrXav-Iu=V!3gB881;yqd{WdZ3j zZhuNU^*;5FYr?2-|H+icLA%1bX2IZFN=4Uv+E*}UQmlQ4a&g?;M#!n4eXvgU!TqoW z1yINj!dKC+w4bm~YD=7NO?!y$DLfzA2yGf$9o#0m(sd}Q?saKiVZUfp2lXc1X@1y- zuhTO;=X9@2ZHe>kiqf5wRrJ?K`dD$-FpdC}k8uLy1;z@DBN!7>SG+ZapNDPEgcH(* zSC<;HcML**#e1kXa-6pyBqhBE97`-c!gs>2R)`B&v+aK(Xl}nH3+wm{#vdgPeU32# z;{nD7i~|@Slvu#ly=~!jZ&#eIk@sOp0jPw!PizIc&kgH-^cUK%SG4Yzb)N;gzYKFo zRCg8|5X-@%(Xk<<+MmTicSf)^6!Hz?Y8;BROXM|-AprSeohKk?=STSLDeNz}#*yoZ z?J34X)dwUf^P}}6p78vzZ@%!cjF-oYYkV7J&++qXuh@ln!t*O-`*l#}M?B&A@%m$3 zBl{)O`w!4%VP6G-0HnkU=Bw0J(S`DzM0GjN=R>sKy!}ZxKKC(idi%V2r@k`S#*0HDboh4@<{a)(2#$m1d?0xvWoIBDX&&+5~ zeI@GSykDdL@)*MGTGhwY#X8o1Q_r5h>Z_{zYEF3v^L_MT%d$$#aZL2(@Yv@ozT7EjGz ze^f7&iuh%v$FUm5^9>867Dx|_i)!!)HA=HXMhxQtTB1Q8Ab>0X+Zwg4@zZugEvHU-A|7%Zju(?V@Ah&EpK?Z@Y_R zn1_n~^p->@cfzyK_L4aKmxuMRLr$l9n&J6vPsrwuUq6iF zpuHgW{6KLCV}t|ZL8;^UlIeaY=>CnOJJbJ)*B#De)YrD{iLRjgAgm{-do-TsV?#*w zJr)Nw!}FKVlO{N4D(EZWv!}4XFgzczp7;!|sq!q3mkGxcFE&0aKHnPp5`eI;LWSSY z{Ec{Vjc=pG8-9L-S@ik^Q3aJoze&Apj|HlKHA;cwY6% zC125cbN0WBbmMa$q45LX2+bEC6jy#*OcR5O$Q+1rMt9Q+ z8+`Sqe9iDY?U-gmUMHtDO`uYd{_8*{g)LyJOu|AUP&hB41s|7s9sV!>KJ>=5KPuEKw zr{@}SYPos2YA?uLQ+sUwG_`G$Df%;2-(dC{wk?}@o^%C0g)OC`Yd-BOur=WM=zWKB+7npEq6MDEKFMc@ zhkFmd(jKCF3eShTnteW>sP0 zZn^^9qwzc+8$yL+gJyU>#(9EsM_&n_J%#;+;rWR5#P+zR$f59fnQ%PutHz`Jehv>8 zevKE`_%=$s;paySuSa6IvZ=f~@hb&c#7jpxZ%VGIGs$$}T<`<SSl~JNfQAo=vO&Vl#&4BVsQ3E&2@=bC*HgjiwrITtQ5JwG|-mf{ndKkmn{F5bNlX*XSV*7 z`byNtF}EkbW>}NM5N6lfWK$RY*Z#`xCw)~Pd7I&R$oJ8Qt=YG*&q>jj!((fV=gXjt z4JV#(YhdGOJUVLMU{?v(Q#2PRx8#KkS$r zNc~(+OwtQTF8kzfoZXlHY~1oet8h=@SLw^84k=@6Q$tR}!Mt3x7vlN8zs^Y=wQ+?0 zYv<1>7X%n{K=%#U-m~k;y~tHOpEF=TUZ;Q4_IBjlxfO!TXgtsRVwP&#vWe$OSJ1Px z@I37+ur=cOsC|cW*b_^TQ_%v?W1r+R#HoMew1?=P!t>#lW_UhP-L=B=SEIXTcpl;e z#tV!U7)LNB7&jd}!mojC{Q1$+y8SB*IVYEChUeEcKV>#=XYZxrnqvG>;*bYpgahJ1 zspI*Q={^~B&sTI$(FD)0YkmQAhhMIR<5mK?N8@=uHiQbtLCx@djPnHNj=mB;dkXst z!}AgAiS2PskwftTmD>01`TfjBQ(of5HNK4!Z}|BUjwhZlUXFDh6 zsKx9*(8Bms>tn`qD_aUPlQuhN1shlg1!s%7nMcLk>__E^m$ujzPAYFt$=N91Kf+-f zc)!&;_|!7&K+X*wkY_gRi*+oC`Z(tHXJFM~EVd{rY=0~<%I3 z=-rZimnTs?ztWkNgcMog;dyFD@%KvbdArNVX=Up{No%2+0@Gs+u zQ#$CE6=~Fg1CE&!;q&=H?DzX9WO!a!yF*k6W%w+#{ZgDhXsCYd*w=v;p&X0#!sww$ zuE%En=$uver17UAUxe?3U!@NR4Uh))wi_mW{su2s?S**0|1C>W^B&x*-!;4s$^`*( zm`v;Q*xqx&?Le;L`H9(iOrGpz?;mpKRtV(Lc%JvgEY-GU6VH>bpl4~}dD>TC>$rHn zZD@k>naG=@zZ%^&!}Aa)FkWD+z&L_2 z!Fb~QA$|>P*}1n%OM4zSYl`tli9?GpMmQiIlscX-neO#L z_wNSSl~JGsg6wrO>n{K)WpM9d|>MZck9_RQ&Pob^;S&$JuZfG7zbj|&s%CqC^m=>BY`xs8*cN7{ct@eb^Ly=LLVI^+$YF+*=u*hkPG>*m`u{3>>et@O)Xc zvEh?fM`>W=Xgt3Le*0HB9E$~56FwgQukbwj0+vMae4db$gcMmy6VKCFmwlH>Lhz~` zo^L+?tfytSr%hFQ?xyjiCl6;iravSZ#)VkEjB!;M~zy!e>umf5F%vxt`b_*AzJv9xv1P?1>i}pNsqbe0YfH*OKgQWzX^RBOFgW z;rYcnk8ySy*^h8M@r36WZK>Fj1nn1%=gC*0djUv^dCXU}`h5PfO?&R9`Npz8v{Q2* z;lt~m6~0|vTU_|s&*H*;50Uoh!&r~ZfmA#nCkJw;ytmPJ+h<>e@%+3xmfeF3CC+4D$v^{@!IppTFMHP+t=btg2E9fhHJn@Wkv-MN!F3Ydt!b5e%*Q+d%$9=KX z_HB=5_LO;Bm!_3_>K(Rjr3=-0RwV&$n{;CPoYk+z@D^ZTETqkPx&&unAEyRYojz{b&d{!PI1 z^>?#aEP%22c>G7l^UZN_W0aEO`N&66cl`TbB`KGEm$eSTt9E!^XpriW?>%E`+~9ti zi}XP2gN_%HM;peqXXg>h8J_Q$R!LL{WiFwC5!xOS7d4)vpZ)&bK&qLn$5$sKxn_5N z+xb)PA*Q>BvERDlb6BMO7GFs@t$c=wvvb3e@GG5H=zppG^=ndpfACBFo1g4s_7dRp z`Og2s^E=5~zao2|PW^m-eCnqt_ZY^`M_w$R=Y26NAzv&u-+|!;pg#_tCtX3$YYorC zI% zo_NCZi*+93I2zfHa6IvZ=cnjgEF=6;Y{T&SM&o(%Rp>wfQsSAmcwY6%2KUo^W7(h2 zeT1)fyk;rC|CqSo-rvLpk8Xjfv4TE~mB<`O#q)7;Ah+(RS-zV0{1nFX`Zbn|509c8 zh+=togs>fOzmy~|ih)Zt`}_91FP0U%ts7rg!hAA@-JWBd&-hIa+lYq+V;AZSZ8&*5ucTF@BK}lSzgWe6ZLV-?a8kh*5ojRIjz#i zri`Np{S`)@@ZI2igyDI}_i-&m-Rf#M{$)(0F`h4jHa4soU0nkkN8@?;<+JVH1%FCB zk3JNu{OR$0M#JwseY0LSrM}yr^pm={syU{7n`an1q&~?Qo^QYRDN!MmyD}OcgSOSh z<>?RU=ly&d=#1L_$hPaPK(0mGC%dX${JY7zxA5oluWjBdOc7<0=NZ?dTo3@yw~^Ry&%CYnjA!lX^Z7Bpd+^%h{oxbj#o~G17qirHS#D6w zdrQUUJ21Qe^vA*Tq$}w87oLZef&VoIq}lK1S&zyKow2+uvVOIn&qwx$*R*enx~H^Z zx@(5#Ax>btz*vEC1Y*K>rqr$5`FYsJzw%#c;;_bsiP;r3!}Gb9Z058xET2HVF#afU z=nTdP2gHL?$MYr9{Z$v}UN@}!(eE|E^SPH^0Nw3q;{1 zb4OnZpFM^B1!I5YdSZKAQ{+&tEj(Yk_9Glmyx8;YfAoGxG@d741qTp-lz65so>zVH z-ToBIW9379?jxMt|DmP&lR4t6XYUZ_H9ZGYV+DN}E0H;nis$3xK<@hTa9{PgT^XK- z9LQRAOh?Lr6rIBZz^ed+`=um#Q4CzF9iCV1wsm`1vD@16?~TEHGKSrv@q7`!sTrPE zZ5+7~b|IOQDefhn2@L4&x)nIwXMG5Oz67_M+ z?a8kh*5ojRIj!kRQ${b@f8ChozU0r(GdvIZKCXq>As7GdL+Ro9GH7GN(oUiVHjc*g z;0d<$EEa@u-rlDBTC%_2ME9kc$NwuWm@vzbeR3knkkfgE{+HVCx7x;LKisKbIIJVe1p)AU zqqbAAo!2{hDG=nv#q3cn`s zd{MeeM4uH}CW6Bg9g49_n=zS8U)umbzX zHO2U&#Gx@5BODM9N*&LaNcV=-K=+f1?l)&{zOcV!5_>UiC@uAewJ1`}4VvrNWYymPV_3iF0>dFTPUIPr9HF zV?8nlQt^D89LRlVOP%l53vPzzAqTQHK0TLmAUelr3;`;*UrLe}#lWT7;d#|=8K0CD zyP+>)J{iMq(RjWH-_#7xt2Pej>SSl~J2_>)Bdz8*f#LZ$F&F(tU*)S?k(;FkeT~OA zo;9A=SGH6vc-Z;<7n{YVrVqe}=ZmkTR+h8&p0d|E{BL{8n>}Uk=jH6zwL5BEddJe+bV+9mUB~6n9d;Q4 zQVaRJD&Q)A;rXz=Ttg4v<;i)iz3H)qZZeP5;hDP~Gk%$D7~OR)$rzr$XUB7*LMVr4 zn?l>>;?94(tY3fdL7;wW`~9o`Z3S{|He|Yj^;VmP*x5d$`_jZ8E=lVK-fkGbvIWVI z(|Lvdm-=Y(4x@ELBmJDlvrsMwfah!1IgjnUu5%1CsNc7raO7Vo_l$C!L0&AL-^Tf3 zmO5_P#Pg&p=y|Q-dGrM=9C#ZWgp66pjNc9zM@qCQ)1lR5I*;CkGF!o2TC$`5mMGl3>%k({a;*>KK z%b_1Z=?hr#rKo%&;%R<Li? z08(PPws@Y)hiJaB?9b;umMRx^S~@(uM|^2^SMjBtmB|3;!&r~ZfmA#nCkJxZYkuBW z^`4Fl&qEGmHQlura-i9$uc9*z!R&zhr6hS#3|y)mo>%R*WO-S!+Z*fO-irBT47)|+ z`67H%Gd!=_IGn4KoyqTH-Df|gRbP|J@O+$@i;knOdb5DsZ257%@lqp~@w{h?<(AHs zoj>jzFLpXTO?>H7S$w%d9r?LUBkYZAx7t&-JS)4q-eA9Z;ArbgeLZ|u&aHPwp7C7> z>sS)?am?)%zn;agCWj%+X*24X{A(xs%WXO4tC$PFJ%QiPL%xq|AwJ|>h~t$So-czo WHq3Z=odz~e&Io#acs7Cglm8!TD|QV4 literal 43012 zcmeHQ33wF65)K+5fC?(0DCmkHD93{Y4NJ0_+04%DY&Lr)5Ks{n6%-XO!0B5ucVuK{TK#qzcBzu? z$;h;_eW=2CjX>Ihv;m0)X$B&Lv;(OPQcn}?w?EV2k|mGVB-uf-P&+_7Og?DyL7NZS ze9-2Dwp7(?%JQnFEGLN9+94CJB~O;u2V(d5O<7X=%q-A8d%9f$vH5Loo8Q$@@_W3J z-wu)m;&DJ7B+CKKCTKQ6vk97^4g&A-xHDbWbf3xUh4)G}uLRNw#42TW07ElcZ{!nSx6Xa_BU?g+XQ2-*qq723+%70GU|U(QfvtIeNfGG#a&ZkUcKD^)Ui zvr=_GgxZYriq^&=c7dHP2&77eES-aGUx974(Kast$7{1@W`f2!VLQltX1Cp%;qy4s zeOZ})3F;EmC9J0^b`TFp7OXS&$$+)a@OE*yy`J`&nV>U4lkcUBOur-3Z>KfNkTYE% zR<9?^1!B$c+FT%3Tsxbb?)7DQGVL7{ldLEvuP4Ke7-3jJoIpVE#hYOLKtOi_-3c_# z8Me)}Vb}zW5IzxpAgagVHQ7P3K=`!00p7;V}P{uy=XPqTO~7@*(Y4TpP4ATDyv@0k>Zvo@IFb zwk&(Pk_Em`gEdG49A&Y69sM3Y3^r#nEc3C6TjwJCnZpXcuPE+<@q^+8jtkNq$A%4H z%JA7ivOv;7tRSk%5AA+v_d~lM+WpY(hxSZ(0K^WG1(FV81yM8M0T4R~>@sMF2S6ZV zGJJQZ_Z5fP;%q6-r={43?~9{z2J0ZTQ{i-wmd3=0aDgJ^!jE9g5CM*Sp-W2r=(<=9 zyLcNq<+)Uq5VRy*Y0lq0ZM4Qw{n;NgtpWF;vSC{M0V7u4LXUj7mV?Xz+V`iWhURe6IMfr8A z90%(lMX{KxzZcK1(y&OFELP(fAhneGHEJWyQa{nhuZ8z$v9txG%VNjV`sw#+d|VTh zkn!UvkAr?iZOw(3uhr*bq^)_hui%|Ak@g+7+qO1%5j7R`57ue^xF6PH0~EqR@GAT# z?I-2x-ixR&X}&k@A-bpOJm@2~Zk(!eo9JBEp{%wKqB1j&_35)>{E3z?;U`$Af8#9%khw`iaxRN?|ym|Xe zYY?wk&~7X^Z&8eiSpynNBs+q4f9zy$`PxLCR>mS{ZB~$866oI8OWZoYuY2_Upm+elUk|5JjsS@y%e53Me%}b9J-$P5XE?? zVyqXn`O*53j(UDLHedKy#*5 zKJP1vRd|O8qQwe^RqCtRLitX#w&WLLGCP6RoAZBPvW?GugcU1)5td&$N1i^?DolK0GSAW&8-mskzNW$HIB|ZOqgNe#?&1Z|h-hF&D7k;^;Fnm}aTi zguWO@36rFw^l_!yJT}okar)UxA)0$@|eZGR{ibWp8??Z*1v(bNA<%?<0m& z+xaHqI}yvlcUNNj-*3-A9}|8_|LbG$u_*7IW`K{w`8<5;YrA7Di$NkR1|N?J;c&ET=Ap7>#ds2IPYcKcu&=PVONRu{+lNr}{%3pr#|Gj|*qM}e z$?->0MtkPbJ=BVG{+05;PQRIVjk%X^*Zl>1-13g8fu-K5d5QCD-@yDO!aM8E8;kut zl@2;k>wLa(&H%i2SAK2v9}3NZoYnT4utR7L zL^-2tV7)c2g_qS~d>(S3)VgPxr!)%Wh*&G>vs%q83cT=XJzdZuaepTD-Yoah=a z-q!Oy<%?Y}NY%H+%2U@Yl&AjKM-7}_sr2_9vp>JLKwU1`l&ZJgE=@>aXS*Zz(LL&+ z2H((N(PBLLsc!Ehu9JFI%4b}Y;}AkxUhkCl?k2to$JTpa|6?ukdCd0_!>J$s$UaX% zEC=6hFrTl0J{EgQdkpY#IG=wM^6Qs_F-U~P;Nx*A9Exrit6?}CG613%=iB|h)-SY* zMf#F)iyZNuy2m*2e_HN{`b!Lbbsi^aLDTI>(8 zbxR-KbWgmm8TQx43P6)#eBN2VcOR$!FK^23#JMmoEAo+HcPK6X{>{8?-+!r%@%hA| zepwT2$7i8$qOkmEhlKkd{|)4Kz5nmmzGVY(K3nij+Cz0ZrF?(WOuC0!Y1d+^JnG;X z^X_F`_;$@kc1Bs|9I;r2R_T~H^A8`kiz4JO)sL{xZaufV8{%_1pKowSkk6+q#Phv$ zKF?z@SNAQ;4G3fvhR>6&U}t&pdD>U#`$+o^+hI>!g_?>HeBSbb@G4=3G>wm%_7L6E zbRN4^^m|&OxY6dbdC}T#6rVpI+sWAT=JOCIFkWD+z&L_2A!WDx0KW#x_Uhf0>$=V~ ze_QE{VSL`XV6>2Q$c*p7HO2U&#i8FZMmQiIlslgqtM$GQlb@%a++BE+N{@*>P5%Ztw!`b~b|BJf){pDzKMM)CPV9|v=F-On2C z)IqCTtBddSBA@3m3lNF8Cx!Npb+V+?mMkZR)E0Yejv$Cjx}s(+C2BE259Z`}e

sd0-Cv{e7L!*UL-9=iR-lotP#?ueD(*;5oRjL(OxC-%oR zMGeIZQf|L*&+ljUHtk1oagFbz#T$Np#N$av&6gvc$M{Zz{6{>Vbky_X?Z>)7{tM^x zgjINl2%^PuWBI&}$$iafy?OtWZG7${j_NCmQ|}lqPk2C;CybC_YOG*P!b)fk1bn^) zwuk0Glry^eJu$;Ix5*O5=OG75-O$*KIgkj?&^dYaBFrPXyvWe+ z=Xoq%1bz$W^Ce)@Fh0*=6P8`ivj}(Uz@B^5g%6Bmd_E-R5^nK1DuVCp7M4D(zO|f~ z+d>=@v%=nVZBJ=Mc2jx6#4YlK^#|3Rr|we<#;&vHRQ_FE;J8g$zUw+^b-^)w-Vxhz zwVHqQeHtrTj3@v1^h(5aQr1l^7}w-Dgpjs+S4#WX*L-95O!ZFb^&I2#knbagCH3J; z@tug};JXdx^A*s?qQCA#2KYFf&%XmaZ~wh428pm3d^{$iUd(r*bh}s$!{Lwt5WP@b z(Ho%B=FHkh@j6;QKOZs)l+aQfpQnBlf6s-_C+^$7563B2KHuY-v(A~yZ9>~6>~{h1 zee&ncuT`3SbBlS~ebwc&+}N!jS7pU<~#5{5#+-8eS5MM z>?|)nPx}h&*3TKN^QBEIH|Ab?F@n$E-sjnNgc;KM3!p-Ki0*0HP(B~6?MCtW^ReA9 zJ`ZsM;|0bFj3W>e&I)Z;X=iP4C6w*nH09EALMk@p)-qt#hjPEkYf5hWS zM?F8B3ttTKUpSv9tisDg5G|G)%jb1WF7eTN^ZqB>_}oW)xAQ^q1L-Gu?8b5O*weZz zFec$eXbz}F$+=tmA+D3u&qgt>$#DoFZS(Gw%vBS7V{)2#Cx0-T z@p;Ji5yR4Rmpp~TET@$KiZ_A#g?bjdc;$1BH*rMAXZh&%i7FlYouG+ub{arV2hbYHo${m=5o zdezOl9$7V?i3y`h+j5qv(r|K?+a z8Pfdg+8p`*dc3B4nl_Zr^Y1H*?MCtW^ReA9J`ZsM;|0WuRTxJwCJ6U<<9MGa+n@MU zK5^YN^X{>q8ph|vP4@}P!8)|I7=I`ZVT^DiKc!ae4TUcs%K-=NICpVlSigUpSv9til^a z5G|G)%jb1WI$F|vIsfbV5TE;q8!qi5{;=RGdGw=`<R ztoK~+^l&jg4>^!@^A44AAUelzTr468?w7LUMdixpb-#JzBKS?m?f;YCa4%y%8NqMi ze7*#18ph{!9|v=F-On2C)cy?`t8+)SVSK(Y=IWS5yzoVEzFFClce0n|#G!k|PhbAo zo^{FPwuay3$)jKICXfCiQQi8?WA^y9SKD)L4yf;ZewDrE!Q;}N2~BYfN37ag&Hub7 zjTbG(ll$E?2yva1bnp|#H8~C;q#df3l6lv+zR~Swcqi3a%=kRy`?wa;_~{?xI}16H z!QanUKp%^VFLW`$$KibbJ>c^%ZWpUzI2| zRqyE{@7}%Dyt7j~YC}!u72?mb_^>-gU9m4Q#~RQ4B|;qevQ7^6^UO<|gj(nGSD&7R z*Y1rEK8?CmKF?z@SATEC2Dl(roW(c-F`>WEZ|7uw9?Fh>Ciy_yH_W?o-ZzZTr>turq*XQHd(d`_ zKUy5h!x-U!cu?+qzHGKP1KX!D+p`N!8p7vO)-?j#Z$1ax!}&ZP8v^=1F_zC4o+oE< z&QuU9!Lz3*UNH8Dt|vZ&YpOlV^JU`kr2kPqs_i*`e#GNRM?F8>U)p(G9{wX9Pde)P z(R!AqOUlRSS27y`qrMmmx2Tz)KDL z`}X`^rge^l+y5uOAr>*8jNrF$K3@Vh4de41HW{w8f7eL3Q~T9Espc)TFg_mvvpQ(B zil83($nxO}Z7e4*nI(SjuW5g{QBRvv`K&zZ@j>#aDMQsSr>wNACp+77TD4YZojPg1 z<;Ee>Pc!eu#~ra&Ma^HuzN^RUXfd9gd*C+2byBPSOBvVXIE3J=@<~d@{_lOSUg7di z==mVy^N{c3T1X3SV*kfjAty4J&sRVni_O>EWq^;v`TR2A^LM=dFP{heV_d!<`25UD zG0wjiUn-30`WNm?Eb^=ccPgfiwauHY&4Vr4@7p)pI$qWU+nqBjRf4{E3CBOVEMe-2 zKS0jt{Xc)}4jV{%rB~i|cB|h^nAoB#-9s&(ZU2k>!;q%tuVZfK+v&Vwe17iIZYkZT zOiz5gWis=Z2ytXxw^y*gXYFDeYMsy5TGIiq-3M9^LtQGL=dqZppOY1n&y%fS=f%e7 zTe<74Ks*qxG<{L<`I2lmjL$=yz<7bN0^8UEiO<_IUJfl(vWS zc|JA-^nGG1pO0{!;M@@_!Lz3*UKpPbSx@YbYl<2Q&zFhElm18fsJ7?$`4NvN9rgSo zoyX_|gZxK4o^;gn!?~2D5YH>AFXz8-K2KPM0YnfjmK)3Gbxd~si{=~2|9tKv9^byq zdi9gJ@`#p;_F>lN3`FWNIc4>^$3_12@116j~s&1QN< zA)hZpUKD|s8pr2#zjb@0qWBH5i1}m$zlHPp60m6)pVxgH%++;2Yq(Q$O*g6U?5)Q5 zd@(Us2M$yO<*~Jv9XS&$C$D~3Jau;q`?LEmv32j-RUUEgF?qzulj`Sx9|H(|FNhJo(w*??zlFHD0obaZQdx2+pSOret(> z`9_{v=pDCp2IKRP@8eoXpFI`)-mbj<{d@)Vv3S$AAqMz3oX^8=-N>%ofB8J_rQ8dI z&o2smlYaTU?!wHUM$q1rC)b#zH0;~o{Kdv}YQsEKZut0S5^Q%a3VaKFXNy%D{+jU4 zvX4PF=>0eBnPCG-zbx)==POg+5c0f7=^kqNr(1@~e?57FdHb|ld^??2jL$DR-7jU( z&_0Rxop_S@ON5+m@mZJ&@cGU8X{dERf7Ogwyml9yV&C7F%IA43=IZBU#pLs3E7*Cl z@p;4q7Q&ULFA6>%v^=uyhVglb6BsWbR=6;ZKuq{XnE8wT*&xnA+5OoJdBcvQ<{is+ z7{=$5r_2<*57)!-aZNGyXmRKhj1dlq2j$M^%Vzr=u>AsL{W;hk z&gc2q5YVw=ET1ntPh2=>Du|Wf*;5oRjL(OxCq9E~sy)l|W#aLq|4}{~VSdEpNk=_D z?mR9J{}GQT9rgS)n@d&1KT7Qw{JbWd&l6T*01-rs<;L=P9g{zep!stC*YhDh_p!## zyvf>VUVC|1@?Y|>#}mjt%!#lbngi*4zL*@y_3ZKyt~Za(VtgKQAgOQhh2)xudKCk=jm%`6MBJBGz`ipYo2q#m4wNI^kHva}J}|(? z;e7r>;BgOl|K;-lM2yQ9#P{=S2W&`h@YzSga_ftd`5W)t zB5Q(uoofet0(~X1_Cxg(mi)X5WHpUp`(Viol=M2olbtg^zD`&p?WcRF<(+$aDVOgZ zVcxcLE8kA%731?ukM>NNSpB6$f8yiJUn0bj+3QT$-}Bw_UZ{0GU-v*`)_%nR%=JqD zexAo-u6|BdOg>Mxf}Ix|pO0UfrT-gi#D#{hi-OOWWV>N}9^wSX3y2kiF^)h?*dQ#o z9Y(6(EAu891su6ozIue_8WEE zvkU$*gwI<)ZG4Wlhx2(pHU#wjVJx37JWmD_CQu_*f@e=ryf8i=vYyx<*Az9B3zpAo zdybzU@p#fv^JVTlE)V|^k0%}V{DMnT`cL8?CH3U|7tZGit1y5FqQ!D!`Mi!v>x(pB z&i{Ho#OFTN%TLX4!ULwcMf`!FZMdT0)$^Z8gw)q zW|x?ln8v}BK&Hv$@cKIK3ogLd}n3}g}+Ppc*kW!tQj-+&xDTeCD#FU81 z2s&GYuKfLZEm{CRKq*LmV3Gr=!K8F=M!;_hrUx7;&Qw#qqB;lK1Q~79Vs6(&?Uy5p z4N;j*7xO{}W0{CNSGqNxO)jr9MN#D`-i*x5 zq;$8FW~nPBkdc`r=Ann$t50MhYDH9%=yoC}QCp%oq8cip-oZ?7s#6XGO|qLP3*1ZG zYf2+o8p+Z~mPWEPk~us832XeP$N%G;YiA^Lnk=R6H$`jFZ0{+a@q?9yMQjnf2D?yp46H$_! z*?|(Ct&wEe^T`$#H^8Qf4M`^a*mJ zRYGrfQbt<9o0685nJ!aaro4>2!{sIl5M|LgqfQ2mbw;qO*B=bD&&(vANt|sjXJn>( zGt=EXMj6h`RHCF{AS;z9DI=()5+z~m6lY2>Ei;hm?%*;xT`p5Fkl}}q2w#DpP(Vm) zX`=BXBHoF3C*tTcO`GZwzDYj9{t5RZ@&vp=lba}uNI$luhc;dTTE*N%SwtBD8do7u)5`EZ5 zP$m>JByvZ6;v#STxSTJib|j))A}#sj?mn&+)QqQOt5L`*jk^p~8ka5=BITvE!^ZsBUwSKG=ZkwjBh zpSY;nt3?<$Mc55(5aoIk%2iCg?uS8%D`qXEvPeo!jb5JBa}HTXz5f%-920-IRqpc8 z6eh@VFV*cW_gi+z+|;w1Xb;zyYdlc}-;(KF}2)dcnZCI8q7Zhzv9eOA}8`JR`iW8V>z zT4L^U@V3*_*4PI8*(dYmXoIMV(zrfRmw}F( zY7JENs)B1gSn2?BG2iyodfIhvA7dgYtbMcIGfXBfYWIh?7hdM}HL)BhU87e9M7=68l-G6#2>X z6>V}|=K9(^NBNq{v#E~MqJhJs8;YWib76I_#r+ETUHzKSn|0^@p^iS!_vpD!_gY++ zxxU`zbZ2E%{fp{@*@#1kM~Fp;Q;0cA1HF zpI-%)>5&pqA$6bFlyrYCr2D}?IUW>g+%M`rn{q34TzNoY@VX`H~^4xh)U&wB^T28krKe>`uQN8LZPtxx(jOfS!GJ=51w zW39e_Jhzxf-M?bC-yN#IGmpA|di{|%$bMxR*P~%4y2#tC6EMm7B%X3Lo0M-x%PBeAl zjj5wnWLsM=-cRj{q`aK`hi6fxv6gW+-oi4RKjgI3CQOif>0YXPR(|Bqd(DAmM~O5X zO}?)40+9FM<|jOhr){vdyJrx$1@4TUa7MYcLodsuF3;=bs*YlfO6)k`<96>H+-*MB zFc)(8jCaDC7O3y(;GYDn{Z&?28h$o1@vbFuqt|jG*UH zs{$t~aZTVvY)i6Zap6QfZ^^DP{ygS2#xkthy52c|ld-+4S(zvp+x5~Gc$!%*Jh7)Za;I`lS^}Tow>_xHd2*)|ZAP>cxV#kRJr+XdJ{To$x zp?{Iboz{Hl>)bk^1L^(%^3m$f1FepGQO~gdi&%;DH%_F(iFi#IL5pFo7IVbEpQmLVoL+ zzK*)i==;ZWi+R-j)9v$$!+wkpF^{@`di{|%$bOMH5&J4VLn2bwN8zi6;Y6BGF5b`M zt+W3vtebvMEj8%=jdc6VU&yb1e}lZT(mv{%NZ4y56TY|huIwz%G2we_K8vK>T5^4` z_LQ#$PDFca>Fv~qvA33}E&ZMVdB_A#bea7&d=mR@oKJN7ZDVmF&2H=cdDyLCly*Bp zYW+9cEfOcXjBgr-6KOUModMa-?04?l4|PmV=ut}GL>FVOI2*G4VOLJ}P7mLj_~$W) z^;D0RQlkgo^4?K?Nz$sV@5w7o3G&L6SogFW$~qftDd$QU_?x@$qD9K`!{Z%EvnS(z z_tO3kx@SpMxUFb?9A`%MYk^_t&Zc%>_Apy}e?nUMEn|Z>l-(zAB05LHhaJs#;eAGN z)($<}V4UbLXk*KnJ5C#5<4BySAK^0-LorB_wAfUbvw6Pw5aUWTw$x%wE|He})h;Mn zLCx4#Om!g}!inm~(s_!g`@Haa;pNxot$qa*F843DuML->+^$(K@%|9UUp{+rT@i~% za4BzYUwGjjT=7?^|2FEYZRL{4IGpJH*gI0+TrAhjpu1Lz$S?fH{oVn97?(M-W z6F8CY(Ur1FkbB>cwNTyH<&pQqo4fZvNpyGoj31DY}s&%`FNF8!d?$tL_h(bNV1 zKsh!0LTPZ_x|K`CNSug$Q6gjJXtphkFBZ7pq32Pn*APy`wj?_i7f!_Umh4J6QRKXa zoaY?!NJij9Xp?=Cd8qZ!C(lv7rt)mMYS{Zk(dup#PIM)@8-^2696~%oEJB>3m~)49 z(#}@;F>sE5bg{CnO9jj1Lx&8*iPq1&&ED?Nop=t$6!A@sbEgo4JQQz=9VaTB?yE`n za;oko=zqmH(fXNY(%n`R-T%gk)E$Y*bZx&+#A^c0onpg@^4O=qXAvVpdzwq*guscy z<}vDHE`w9j<1ma5F)wi4F9;{n$MMkPLZA7qXZkwoI-~C&<3r4&?q6Q}JUr7N`!PPm zJnH`G^+(gupq+U7w3{oqK7w-R@bkCCJmLx4U z73OSSRGbLkf4(HOoBTmv2vnR%{N24UIMHj5my7|0C&G!=h09RBqoTY5oa1j%aH4i2 zmy7R`kniT89ks1oYSuWM=ey?oC!9|xUDzSvqTa&k+Z>W zStSU)bT8F4$rH04G7tVSg-H85zZ_$hKt9)#-*`JM`Q4iHUei!Zp-<)WB_1VX%dM8l z^#K=C8fKLk^$u-q&e8>ic&-^a;3z6HUHvFUqOkw7dyiw{GQ9 zF%l7fzucNLr`u;IK#Js?LNjQ#`*FF!=G{}C84>6Cre|r6qH^_dGI1&3QJwqZ= z*Kn~HGz=%wd~#1i9&f$RA1;d^Vsi4H&> zzPIMHNJ{-heS$S>H5ND#?X8oBcky6vEzv!^f5H98OT-0Ebea7&d=mR@oKJN7ZDVmF z&2C?Odkxqv5+}NhZyJUZX*Ld>0ol&%ckWvUO3AekG!i&bSj=U=C3n%1J#AlO>(J&u zT2H;&M4A<|**iP4uH%8sIr7r1gYwexecThz<~SEkD&b0)yutm?;T~tde>xlkk1az3 z?xmUg+_UO+LmnwwAIF)I{aRocy0fX>xA{w3`;xQM%KWxASn2b+0wi2pk3tmsEe2h+i0qac^IimnUkG&iJ~>>5vh#zZ+rT;g=7|%b!ex@r zltEE~e0P1bKhcibRxXJQ!-;&=My2_yHt26Xe5@I@E0Qwuix!?)qi(c}dq4xm1WqKq zHeOZ<6>%@sZ7I*_@veEys5(UPp%!S3IrGFZkgxCT*S)jrPO|tO(5$_waT(cK&qF!fiOI+TkzIo@6+aQO}c(Yvi-NP9FnUtTwHJoVTNP!Re%ceaH zxo+LcrJ@vee&HhTU3jmRub-g}qFm26_m}k#t-g@*T2fkWn#g{|LiuounM&zf4u_~u zZOCyi>NedCA|Ef(+NfFb6K?+aB+SnWGJ~CCME>o)g#xQ+OY*p0Z37;Qa#`jXh|9KYa3 zWl7f)mdUdMhT&?fhgP-AFN*aFV~X`aT^HgJvpp1_iyc=hobK_Y`*BrwV{o#ueYx_+1HDj2tOAG6gQMRP z@j}mc^*f5L(hEx1GkfE=G_)AO>l@Y{tTXwIyHVfME2QpgNO!T;k?yZR|02)#i@KL4 z-OCq2_sHLK;x%CejYFHh_C38XEkk_vUhVb!I`rMw;=zIbcjL>1#|eR})jB&* z`DWw}bFH)Uz1y}A74@6H4u%vYDmGkAAIHVh)Q|kuGkqO(ozeG?=N9v5=U7lFUi&eg z#ysl&>Gen6Ap1q)YV51@42eix!-cOJg{xik$z#oUy!G~H-B6F@L*b*+M>%&TjU0Sj zekQrR{7mmg)HRXFcjqDFo89-kPs&)#XAxi5+7}>qI{Qs`ezU44pGElWmXgqYOR)Mw zKHzG$QunuV_(uO^PW#{?NebzWdyz!!ln_hl_ng!@5~$X`zPQHwZJIOiN&o9@j^aG0 z+ix3+t6j9)=_A*G-6Cu9dh_;A&wpgZ&o1!O5Po zzk+qqk<-@G$*ZJKAKdBPDmTG3`I*rNGEuws{qz}4W_@L|Wn z`Jwl($d^M;HWpX=E85tS^3`SoY#fQJZKD`gj$)D&B7Hn&KttVMa*@{-F6YZ>Y^l|l zTp}$6OyB;Z71Rv-wNlZH>|8jk7sW#`Wz-?;aF_invqw(a^O4R8-9 z<&6)|DPt-uwoLN1W*N9wK@wA+E>V@z6Veg1oD~>*E{i7|e3!O21LVoco8p&t>L%d)eylOt3DVvDiGK%Q;~$ zs^mG7F5av2SD*R}?qM9#7eA^5%Kq=)Z4Mr0uSi@?KX-GqaWWQHD_^-4<|X4g)U7H+ z1^Bv&V?@3jZJ@1U$JGuDN|0&X!}=eItFbL}t`4r2R~#gJ&~IBWHGy+d$o|N4|0T*N zb)yeT>}R1;NnX$fx%%AB01%fu>O z=hsA8rdS0Ip9e?3CE|si@2c*uvgf+ndwu%}-Kxb1Uf;0xV4cZt+>ON53ZZ*R(p~&! z2kBl1`WJb=U(~%P=`L)p#<7?}>K=)!@tQD##vxa;rC47L!_`(*d(~%84eIxG7&l)= z#@m60+opxb34yCQmeg}rsQii9v82BDh37kp`puvH2Aq-}x8mYYb!taa z+ah)`h3~2ON`5h&uY(s0u2#JEV?2$yW}k3-g_lWPi3nqHNixWOk+>TBDm_giQhi_e zs$saA=968=@OUda`?GH3yE!CZ2_KbCRaBC`te7Ov@K%y%bXm^EAm6QryzjLOGkoiI zbmp^&@6BW(civRGmhz)T}xW=Q-Ve+gMypvs;hvt^vD6;%b-iO~Y_C&BmcK zGuxT{&Ruu-Z^<=ZcuwGII-i9Y02L1ng6Gq7o+uYonQX| z|5amsJ;Zyv@8)N1Sx?PP`$v_yE;U;K)({1*CMiAr?p+Vq8r`Hgb!tvAood1FRHstUfTJ2^V1z_5Q#lIt~m}h9s=^s z`Ip0ca!xl}qbJ1we}`*G$}10TSEijjXqmW3{4FUY)pQhVRN@2Yoz|EIgUxR|{XBGs z&v@HjC$PRid_61f;dRS1!DT|(f9DO|z;)|ZE)|W#)$F%^9wn1nRQq3qy{MAsE$3^f>$hzZ@5QsdeDP15hCI;dEhl)Gy&`cn{oKvb z#!2j@3YfbE?honl5>XW;_D%)!l5ri#a4igT;9`O8^8OQTpsixZ)%I4f$~5j_{g1@e z*p@k030KP_4w5}$oZo#g5S$b2k39EZqI^;}`k=&q7Ai%4YPcG;$#t3QYhQI-tq{70 z{O-;xe_!nibZ4hleU{;tXni~zaU1a)u^VxnVsuYigJxUwW8j>ezE7E+e8w^<>ubYs zwUxa-wI_EH?+9Sru^y=FLQTYM#OM6*72|NVLh1fJ>3&+(y^bNc+R9$vlI~4m<7jo~ zfmX-8sPEE<_tmhrpbuD|u+}t9xMLy8oLsTPPANB9#C}+&SOq!eIym|*5ij(7XKbnb zf#LT4tHj?gdA{@dhP4OlOn&2TD6Uqp?x%ISw}bxBonsyMolH=0th=cD<3-dx5?A9j zVFZmsuGR-*akV)mUh>%!f7I{mps#O0rDp?uj^7p@Cj_q6qibJhy(X`kdvtxk`()Mv zQNQ_wH^C`kUvt&pR}175(?yTek7B{qir0ROr!kK<_D7sy!uO4oSgql+;(fK`Dfi0F@3NX_&h|=DNN?PW zBx0we;%e#~3HbMjziDXuZJILzSL+n}Re;WOy8X7XxSD3SW?QZSyG7z^m+?)*a5c@w zp))hvnf=af>bEetM%fbrSJU|{e1-iMc}{lc{FkiO^T<8vouNFo-8viW}U88k3@TQ=&eZROGp1z-(P;A$D^WBlEl46r5cdyzY$ z_$yBJ%sRQ#GG<&F%LK00=K1roN|5_9(#KNWY4V0jKbv1#T$-qiR{#6V0}dkJOTYf? zi#zwJ&GFj`z6P#5pFC4p7&F&0;mEyuxn?igyCx3l`i%9)RiBzyeAQ6cOCntD_6a*t zKhX3)bHRDt@=V;_0cC&MP@#uz-O44gakyIhL#+Zs=EmY#oaE*k-edH6l? ze|aL01p9+?|0T*7`kc-0Y*Cx+lg!a3Cyr@+P36V+zFHx45Bc5FTF{$y=l-GJ`aJ8Q z=N#K%Pp->cU+;3d8-}Y<+(!IH>_%Lt7(K?8c;J$F<(&3IHD%0)Z(Alld(tpmZS_s> z+JhygL0{;O^*~)0${=PVKIez87>27APWO1yeY2{&F~7sV`lgRb_Zdae-B4VO))w>u z>l4lT%@4{6noZq?=quWwj; zu+HQ+?uO!O1?%3Abnk(FlI}M{|02)#i@H}XqVAEnTCTdjj-YX%yc$2m`fAwwYL6tw z`0RtG==XJGju_vV-uDIOKGiHdP6%9W{HzjA`M@4Caqj?AS5d$DdLK9?U^!PGSIZ}+ ziyo;TYOK}wk1=cJQR7xh@!F5^H0DwFPp?1n`aOXDT7LTheI1?sB5}1`)mP~TiAe9O zhP|(*`Q*MAxxae*vu^NRlE=bFlWL3~4#pnqRQ*k))8`xED#p zPD#bp)HxF9-TI)orhN}|y$?1GOg{TE&U3o`wz0UHX14>e*MQw3akbq1ebX>pO|x<6 z%*=LXzjN1lenIk0{ht=NT3F0rzlCpbvOC7Fvi`PZmi0``zmw`!Z{sUje<`lX6ZU)} zPx$^B_Y-xiyG$eYxf0ICyHl=T>MFOck7NE@V%>Hx$?fZ&`GQ!>aZj{9ZoBB$y9MT> z#(K;dyZ853Y#nQNN{hMfhhVvqeFd&YehnX%@7Ov3&x0?68;+~}1#N7ZH!R%%8%N@5 z^cIdYb;Q-f)v}MB4~_Z7Pxfp1gmP9s_T3OczqHwVu}0pxoY50&gTk){Gmhkj%TRWn z_)TCV>Y8(9@2f5B`yAR)+sdWp3&0wpz}0%5XyG58{EIEK{}0rzNQylz&hyOv>Xy-S z#k))p3S7;6|AVqhkokI^Xi0Ue$sc|75A&+H_lU&4UerJE^A-n@?={btKJ(_8w!1Pl z+z!{3=}-PgS-XF`W&H2=pv+0L7jU%^8ywaqUsp4~*m5r9SkJuiiz=dSz?wY=oN*%0 z)Id3u{e7kiY(Tee<&xMqT&;JdA%SO`&c?Gi$>ye+>{puXgB}&-+!~ESH1|Hpy>u_? zx`zBL-WB7z;121Z=^*df-#$%Fx@V;R8uIem5j&iJCVd<(*W1h1Gv|KW+@71w*)PTl zdr@W2q-OWx9{=Dq0wZO6(Rt@K$OBVThJ%OMD-u`J&)po&7mdZ$jvs#x^OCU*>Q)t^ z0(||y2v_^yx^ps(dszP?aW%Fj+3~92YI(##vMa@?M{fk@B$NG-=l)BSPwGY=l-SQg zrN~bWTcS3(E^~eD%VA3`8aO=adplqZHAQ>A5by5rGXsUt9eRU`e9mS}@d|WjWmWwd zZi!lV#BIcH#BRiOiqS1>nS*4u2e@V%)Y{cjM@D;;wwZiGXgLL1l>RucA7kS)Oe8u_t)G?&{F4#6&-FcwZaWCqbKlHvD ztu5#S)+ekr%}O3Tgfb^r1!b6=-HraDPwNTADsboyj($tT3q9W%TdK0;3Hy+tVh!Q> z&g&c29;`F@jk}?^TEV&x)#-i#`d{g|yQ(aCyokC-;%dAmU>tI_cxx=K*00twpH!ud zeqTpJ9^;$V_P)S|&#Q*V34yCk&ED<|TGyMWX7BL!+^|K|Z{aBqPAN!q^>MX)V!G&& z`k}*xxPLsim`591gG%w*kMT6-QTI=;Kl0&wQof$wn#kA1y`kTB#`s3!YV50YQ6f_3 zz3^4Ta5c>*`~SfG)!UzSgYT0375HdU!)kjR58u379<#HnJm%|fscRyU?`}uNccS$5 z$^BCs@L43eQ|wX5mA6(jb;Tu`_$! z<6a~YJ0-+Y`h7KZjsza9(MMckT#e?8z}1$|mjZO2)9ts7#nm*s4U(?`yG7z^m+?)* za5c@wp))hvnf=aP>q6P&YVRKrxLR1uV84ZLaI)LqZEY*np_27Xqqa#cHeTneu&yeu z$zx0WA&P2L!a!|^5I1nU?LT`RPB}3wud~O~q|~ z1oZ>Sof?2MPUM;Cp>Ng`el)6$&_lOw<&xMqTy1d2Kwy2?_dpwM+{k`~J|M|kT|s&O zE3E~6af?{jy>zckbzLK8Xz!?pYSWr*-FP14D|Oq_cDyRMS{`u_KH)s`B=&S#lF9xk zaQ`LB7y6vd*b=qLKFJ(ya^jfA*Hm77@2eF;cjyf&@;Tc8-3`OlC~hNuBX%RMQ;eQ% z>${^L+aKJyFt(i1tI!mtu3%W)+ekr&072+)=J2bT$R&G$cxhNM_#5_ z1rDDFN53WFg`V$>tHt%0Z69hEZJ`Y$Uf;0xV4cZt+zrLmqSJjH^e^&!zjECpaW!5O zM$kCqUb?;-_P*NP!$o8uvXVNnR2kK7>j}rn{n>%fuv+D;X%yXyB_jau9 z7xi2GR2Q7m{~uf}pO_x%Qs}c-aJAyKALD7viw{?e&VG@&8v81lS|U>Cz1RyHhO22l z`9Y?KiKhbU-4d>7SNF>?DD} z)zmo>7~iW4Droy{nll1d+wR(j^PFzKjXjv;cV=b<(v#IcuN3)jivQNnz+AEd{+ziMC;?W zi+=s3z Date: Mon, 9 Apr 2018 10:08:50 +0200 Subject: [PATCH 0622/1027] Fix cotire build errors --- ApplicationCode/CMakeLists.txt | 3 +++ .../RifEclipseSummaryAddress.cpp | 21 +++++++++++++++++++ .../FileInterface/RifEclipseSummaryAddress.h | 6 ++++++ .../Summary/RimEnsambleCurveSet.cpp | 13 ------------ .../Summary/RimSummaryCurve.cpp | 16 -------------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index ad89a42c10..641863bcd1 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -347,6 +347,9 @@ if(RESINSIGHT_ENABLE_COTIRE) ReservoirDataModel/RigTransmissibilityCondenser.cpp ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp ReservoirDataModel/RigCellGeometryTools.cpp + + # exclude test files due to cotire redefinition error report + UnitTests/RifCaseRealizationParametersReader-Test.cpp ) foreach (fileToExclude ${COTIRE_EXCLUDE_FILES}) diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index 685e7e94b5..3029884d03 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -20,6 +20,8 @@ #include "RiaStdStringTools.h" +#include + #include "cvfAssert.h" //-------------------------------------------------------------------------------------------------- @@ -515,3 +517,22 @@ bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAdd } return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h index 6846cdedbf..6f0231eaf7 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h @@ -20,6 +20,8 @@ #include #include +class QTextStream; + //================================================================================================== // // @@ -166,3 +168,7 @@ class RifEclipseSummaryAddress bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second); bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second); + +QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj); + +QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 41cea53298..2cea892254 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -48,19 +48,6 @@ #include -// See also corresponding fake implementations in RimSummaryCurveFilter -static QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - -static QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - namespace caf { template<> diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index e210f4ecf0..70d0f77225 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -54,22 +54,6 @@ #include -// See also corresponding fake implementations in RimSummaryCurveFilter -QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - -QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - - - - CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve"); //-------------------------------------------------------------------------------------------------- From c69b558ff8dd46eea257618bb5b841f2ce8b3ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 10:53:51 +0200 Subject: [PATCH 0623/1027] Restart files. Fix bug during import of grid summary cases --- .../RifSummaryCaseRestartSelector.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index ecc171d449..e3eb6d352c 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaFilePathTools.h" #include "RicSummaryCaseRestartDialog.h" @@ -117,28 +118,36 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp std::vector RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const QStringList& initialFiles, RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode) { - std::set filesToImport; + std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; - for (const QString& file : initialFiles) + for (const QString& initialFile : initialFiles) { + QString file = RiaFilePathTools::toInternalSeparator(initialFile); + if (summaryRestartMode == RiaPreferences::IMPORT) { - filesToImport.insert(RifSummaryCaseFileInfo(file, true)); + filesToImport.push_back(RifSummaryCaseFileInfo(file, true)); } else if (summaryRestartMode == RiaPreferences::NOT_IMPORT) { - filesToImport.insert(RifSummaryCaseFileInfo(file, false)); + filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); } else if (summaryRestartMode == RiaPreferences::SEPARATE_CASES) { - filesToImport.insert(RifSummaryCaseFileInfo(file, false)); + filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); RifReaderEclipseSummary reader; std::vector restartFileInfos = reader.getRestartFiles(file); - for (const auto& fi : restartFileInfos) - filesToImport.insert(RifSummaryCaseFileInfo(fi.fileName, false)); + for (const auto& rfi : restartFileInfos) + { + RifSummaryCaseFileInfo fi(rfi.fileName, false); + if (!vectorContains(filesToImport, fi)) + { + filesToImport.push_back(fi); + } + } } } - return std::vector(filesToImport.begin(), filesToImport.end()); + return filesToImport; } From 7eda26665bb98c3787f542e13ade912c5b840a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 11:21:45 +0200 Subject: [PATCH 0624/1027] Add libecl patch file and updated readme --- patches/install-ert.patch | 49 +++++++++++++++++++++++++++++++++++++++ patches/readme.txt | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 patches/install-ert.patch diff --git a/patches/install-ert.patch b/patches/install-ert.patch new file mode 100644 index 0000000000..c874f27eab --- /dev/null +++ b/patches/install-ert.patch @@ -0,0 +1,49 @@ +From 57a5f7fc667d42a5405021c975dabc2db53079a4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jacob=20St=C3=B8ren?= +Date: Thu, 26 Oct 2017 17:16:42 +0200 +Subject: [PATCH] #2011 libecl: Add INSTALL_ERT to control install targets + +--- + ThirdParty/Ert/CMakeLists.txt | 5 ++++- + ThirdParty/Ert/lib/CMakeLists.txt | 3 ++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt +index ffb2de0f9..73fb3b30d 100644 +--- a/ThirdParty/Ert/CMakeLists.txt ++++ b/ThirdParty/Ert/CMakeLists.txt +@@ -363,6 +363,9 @@ if (BUILD_PYTHON) + endif() + endif() + +-install(EXPORT ecl-config DESTINATION share/cmake/ecl) ++if (INSTALL_ERT) ++ install(EXPORT ecl-config DESTINATION share/cmake/ecl) ++endif() ++ + export(TARGETS ecl FILE eclConfig.cmake) + export(PACKAGE ecl) +diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt +index 477f95530..2b91ee17f 100644 +--- a/ThirdParty/Ert/lib/CMakeLists.txt ++++ b/ThirdParty/Ert/lib/CMakeLists.txt +@@ -220,7 +220,7 @@ endif () + set_target_properties(ecl PROPERTIES + VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} + SOVERSION ${ECL_VERSION_MAJOR}) +- ++if (INSTALL_ERT) + install(TARGETS ecl + EXPORT ecl-config + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +@@ -245,6 +245,7 @@ if (ERT_BUILD_CXX) + PATTERN *.hpp + ) + endif () ++endif() + + if (NOT BUILD_TESTS) + return () +-- +2.16.2.windows.1 + diff --git a/patches/readme.txt b/patches/readme.txt index 34f195f307..0a0d7ecc9a 100644 --- a/patches/readme.txt +++ b/patches/readme.txt @@ -6,4 +6,4 @@ Description: Will fix reading of special Eclipse cases related to synthetic ODB test cases. Required for regression testing. Patch is created by : -git format-patch -1 +git format-patch -1 --stdout > patch-file From 75d505c9f66e4efb0ab5fe9da5d6a03fee3971b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 11:22:39 +0200 Subject: [PATCH 0625/1027] #2011 libecl: Add INSTALL_ERT to control install targets --- ThirdParty/Ert/CMakeLists.txt | 5 ++++- ThirdParty/Ert/lib/CMakeLists.txt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 4fc4cc86d7..070dc78d7e 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -357,6 +357,9 @@ if (ENABLE_PYTHON) endif() endif() -install(EXPORT ecl-config DESTINATION share/cmake/ecl) +if (INSTALL_ERT) + install(EXPORT ecl-config DESTINATION share/cmake/ecl) +endif() + export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index eb7388ca06..389b5448f4 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -191,7 +191,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) - +if (INSTALL_ERT) install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -216,6 +216,7 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () +endif() if (NOT BUILD_TESTS) return () From c71ab4e88d4e875d3f005279fe7e083a9b754d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 11:24:31 +0200 Subject: [PATCH 0626/1027] #2317 Apply fix for synthetic ODB files --- ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c index e8d9cef33a..52d40a9aab 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + + if (doubhead_kw) + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -109,12 +112,15 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); + const ecl_kw_type * doubhead_kw = NULL; const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); + if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) + doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); + if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); From a40c4df6b30ac0daac728fb3ee440c3de598e4e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Apr 2018 12:56:48 +0200 Subject: [PATCH 0627/1027] #2632 Export Completions : Set all completions in same group --- .../RicExportCompletionDataSettingsUi.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 975436b61f..c0ac9d00c8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -63,15 +63,15 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitFieldNoDefault(&compdatExport, "compdatExport", "Export", "", " ", ""); - CAF_PDM_InitField(&timeStep, "TimeStepIndex", 0, "Time Step", "", "", ""); + CAF_PDM_InitField(&timeStep, "TimeStepIndex", 0, " Time Step", "", "", ""); CAF_PDM_InitField(&useLateralNTG, "UseLateralNTG", false, "Use NTG Horizontally", "", "", ""); - CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Include Perforations", "", "", ""); - CAF_PDM_InitField(&includeFishbones, "IncludeFishbones", true, "Include Fishbones", "", "", ""); - CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Include Fractures", "", "", ""); + CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Perforations", "", "", ""); + CAF_PDM_InitField(&includeFishbones, "IncludeFishbones", true, "Fishbones", "", "", ""); + CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Fractures", "", "", ""); - CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, "Exclude Main Bore Transmissibility For Fishbones", "", "", ""); + CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, " Exclude Main Bore Transmissibility", "", "", ""); m_onlyWellPathCollectionSelected = false; m_displayForSimWell = true; } @@ -187,20 +187,19 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c if (!m_displayForSimWell) { - caf::PdmUiGroup* fishboneGroup = uiOrdering.addNewGroup("Export of Fishbone Completions"); - fishboneGroup->add(&includeFishbones); - fishboneGroup->add(&excludeMainBoreForFishbones); + caf::PdmUiGroup* group = uiOrdering.addNewGroup("Visible Completions"); + + group->add(&includeFishbones); + group->add(&excludeMainBoreForFishbones); if (!includeFishbones) excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); else excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); - caf::PdmUiGroup* perfIntervalGroup = uiOrdering.addNewGroup("Export of Perforation Completions"); - perfIntervalGroup->add(&includePerforations); - perfIntervalGroup->add(&timeStep); + group->add(&includePerforations); + group->add(&timeStep); if (!includePerforations) timeStep.uiCapability()->setUiReadOnly(true); else timeStep.uiCapability()->setUiReadOnly(false); - caf::PdmUiGroup* fractureGroup = uiOrdering.addNewGroup("Export of Fracture Completions"); - fractureGroup->add(&includeFractures); + group->add(&includeFractures); if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { From e50e34feb4237cefae87492da4417d3bd4516773 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Apr 2018 13:20:21 +0200 Subject: [PATCH 0628/1027] #2632 Export Completions : Remove support for export of all well path completions --- .../RicfExportSimWellCompletions.cpp | 1 - .../RicfExportWellPathCompletions.cpp | 1 - .../RicExportCompletionDataSettingsUi.cpp | 36 ------------------- .../RicExportCompletionDataSettingsUi.h | 4 --- ...RicWellPathExportCompletionDataFeature.cpp | 5 ++- ...ellPathExportCompletionDataFeatureImpl.cpp | 14 ++------ .../ProjectDataModel/RimDialogData.cpp | 2 -- 7 files changed, 7 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index 2bd3fd409a..e8c894f4d4 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -60,7 +60,6 @@ void RicfExportSimWellCompletions::execute() RimProject* project = RiaApplication::instance()->project(); RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); exportSettings->timeStep = m_timeStep; - exportSettings->wellSelection = m_wellSelection; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index 3e89a57d98..07a21c5a12 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -59,7 +59,6 @@ void RicfExportWellPathCompletions::execute() RimProject* project = RiaApplication::instance()->project(); RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); exportSettings->timeStep = m_timeStep; - exportSettings->wellSelection = m_wellSelection; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; exportSettings->includePerforations = m_includePerforations; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index c0ac9d00c8..83df0f771c 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -58,8 +58,6 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitObject("RimExportCompletionDataSettings", "", "", ""); CAF_PDM_InitFieldNoDefault(&fileSplit, "FileSplit", "File Split", "", "", ""); - CAF_PDM_InitFieldNoDefault(&wellSelection, "WellSelection", "Well Selection", "", "", ""); - wellSelection.uiCapability()->setAutoAddingOptionFromValue(false); CAF_PDM_InitFieldNoDefault(&compdatExport, "compdatExport", "Export", "", " ", ""); @@ -72,18 +70,9 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Fractures", "", "", ""); CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, " Exclude Main Bore Transmissibility", "", "", ""); - m_onlyWellPathCollectionSelected = false; m_displayForSimWell = true; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::setOnlyWellPathCollectionSelected(bool onlyWellPathCollectionSelected) -{ - m_onlyWellPathCollectionSelected = onlyWellPathCollectionSelected; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -140,18 +129,6 @@ QList RicExportCompletionDataSettingsUi::calculateValueO options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); } } - else if (fieldNeedingOptions == &wellSelection) - { - if (m_onlyWellPathCollectionSelected) - { - options.push_back(caf::PdmOptionItemInfo("All Wells", ALL_WELLS)); - options.push_back(caf::PdmOptionItemInfo("Checked Wells", CHECKED_WELLS)); - } - else - { - options.push_back(caf::PdmOptionItemInfo("Selected Wells", SELECTED_WELLS)); - } - } else { options = RicCaseAndFileExportSettingsUi::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); @@ -170,19 +147,6 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c generalExportSettings->add(&compdatExport); generalExportSettings->add(&useLateralNTG); - generalExportSettings->add(&wellSelection); - if (!m_onlyWellPathCollectionSelected) - { - wellSelection.setValue(SELECTED_WELLS); - } - else - { - if (wellSelection() != ALL_WELLS && wellSelection() != CHECKED_WELLS) - { - wellSelection.setValue(CHECKED_WELLS); - } - } - generalExportSettings->add(&fileSplit); if (!m_displayForSimWell) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index b23cb6940f..c21f5fb2ad 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -55,7 +55,6 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi RicExportCompletionDataSettingsUi(); caf::PdmField fileSplit; - caf::PdmField wellSelection; caf::PdmField compdatExport; caf::PdmField useLateralNTG; @@ -68,8 +67,6 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi caf::PdmField timeStep; - void setOnlyWellPathCollectionSelected(bool onlyWellPathCollectionSelected); - void showForSimWells(); void showForWellPath(); @@ -80,6 +77,5 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - bool m_onlyWellPathCollectionSelected; bool m_displayForSimWell; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index 2349294140..e8f8225ef0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -154,7 +154,10 @@ std::vector RicWellPathExportCompletionDataFeature::selectedWellPa { for (auto wellPath : wellPathCollection->wellPaths()) { - wellPaths.push_back(wellPath); + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } } } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index d9af082dc1..ad6690d1d0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -74,19 +74,11 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } std::vector usedWellPaths; - if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS || - exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) + for (auto wellPath : wellPaths) { - usedWellPaths = wellPaths; - } - else if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::CHECKED_WELLS) - { - for (auto wellPath : wellPaths) + if (wellPath->showWellPath) { - if (wellPath->showWellPath) - { - usedWellPaths.push_back(wellPath); - } + usedWellPaths.push_back(wellPath); } } diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index e0c84020a8..2f2b350930 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -35,7 +35,6 @@ RimDialogData::RimDialogData() CAF_PDM_InitFieldNoDefault(&m_exportCompletionData, "ExportCompletionData", "Export Completion Data", "", "", ""); m_exportCompletionData = new RicExportCompletionDataSettingsUi(); - m_exportCompletionData->setOnlyWellPathCollectionSelected(false); } //-------------------------------------------------------------------------------------------------- @@ -68,7 +67,6 @@ void RimDialogData::setExportCarfinDataFromString(const QString& data) //-------------------------------------------------------------------------------------------------- RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData(bool onlyWellPathCollectionSelected) const { - m_exportCompletionData->setOnlyWellPathCollectionSelected(onlyWellPathCollectionSelected); return m_exportCompletionData; } From 4fb1a0385cb50d94f3e36e619d11c0ff25ab9711 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Apr 2018 14:09:40 +0200 Subject: [PATCH 0629/1027] #2632 Export Completions : Add exportCompletionsForVisibleWellPaths --- .../RicfExportSimWellCompletions.cpp | 2 +- .../RicfExportWellPathCompletions.cpp | 2 +- .../CMakeLists_files.cmake | 2 + ...tCompletionsForVisibleWellPathsFeature.cpp | 157 ++++++++++++++++++ ...ortCompletionsForVisibleWellPathsFeature.h | 40 +++++ ...RicWellPathExportCompletionDataFeature.cpp | 4 +- .../RimContextCommandBuilder.cpp | 6 +- .../ProjectDataModel/RimDialogData.cpp | 2 +- .../ProjectDataModel/RimDialogData.h | 2 +- 9 files changed, 209 insertions(+), 8 deletions(-) create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index e8c894f4d4..66dcfef3ce 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -58,7 +58,7 @@ RicfExportSimWellCompletions::RicfExportSimWellCompletions() void RicfExportSimWellCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); exportSettings->timeStep = m_timeStep; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index 07a21c5a12..a87959f6aa 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -57,7 +57,7 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions() void RicfExportWellPathCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); exportSettings->timeStep = m_timeStep; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 01b1fc3696..23eae5d246 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.h ) @@ -18,6 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp new file mode 100644 index 0000000000..5f452b6f08 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportCompletionsForVisibleWellPathsFeature.h" + +#include "RiaApplication.h" + +#include "RicExportFeatureImpl.h" +#include "RicExportCompletionDataSettingsUi.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RimDialogData.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCompletionsForVisibleWellPathsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() +{ + std::vector wellPaths = visibleWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = visibleWellPaths(); + CVF_ASSERT(wellPaths.size() > 0); + + std::vector simWells; + + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + QString projectFolder = app->currentProjectPath(); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + exportSettings->showForWellPath(); + + if (!exportSettings->caseToApply()) + { + std::vector cases; + app->project()->allCases(cases); + for (auto c : cases) + { + RimEclipseCase* eclipseCase = dynamic_cast(c); + if (eclipseCase != nullptr) + { + exportSettings->caseToApply = eclipseCase; + break; + } + } + } + + if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + RicExportFeatureImpl::configureForExport(&propertyDialog); + + if (propertyDialog.exec() == QDialog::Accepted) + { + RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Visible Well Paths"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() +{ + std::vector wellPaths; + + { + std::vector wellPathCollections; + caf::SelectionManager::instance()->objectsByType(&wellPathCollections); + + if (wellPathCollections.empty()) + { + std::vector selectedWellPaths; + caf::SelectionManager::instance()->objectsByType(&selectedWellPaths); + + if (!selectedWellPaths.empty()) + { + RimWellPathCollection* parent = nullptr; + selectedWellPaths[0]->firstAncestorOrThisOfType(parent); + if (parent) + { + wellPathCollections.push_back(parent); + } + } + } + + for (auto wellPathCollection : wellPathCollections) + { + for (auto wellPath : wellPathCollection->wellPaths()) + { + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } + } + } + } + + std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); + wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return wellPaths; +} + diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h new file mode 100644 index 0000000000..c80ba540ca --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSimWellInView; +class RimWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RicExportCompletionsForVisibleWellPathsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector visibleWellPaths(); +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index e8f8225ef0..71b5c33253 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -88,9 +88,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) QString projectFolder = app->currentProjectPath(); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - bool onlyWellPathCollectionSelected = noWellPathsSelectedDirectly(); - RicExportCompletionDataSettingsUi* exportSettings = - project->dialogData()->exportCompletionData(onlyWellPathCollectionSelected); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); if (wellPaths.empty()) { diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6833e6c3f9..cbbe790455 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -241,6 +241,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicReloadWellPathFormationNamesFeature"; menuBuilder << "RicWellPathImportPerforationIntervalsFeature"; menuBuilder.subMenuEnd(); + + menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; } else if (dynamic_cast(uiItem)) { @@ -282,6 +284,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.subMenuEnd(); menuBuilder << "Separator"; + + menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; + menuBuilder << "RicWellPathExportCompletionDataFeature"; } else if (dynamic_cast(uiItem)) { @@ -615,7 +620,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder << "RicExportFishbonesLateralsFeature"; menuBuilder << "RicExportFishbonesWellSegmentsFeature"; - menuBuilder << "RicWellPathExportCompletionDataFeature"; menuBuilder << "RicWellPathImportCompletionsFileFeature"; menuBuilder << "RicFlyToObjectFeature"; menuBuilder << "RicExportCarfin"; diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index 2f2b350930..79138b2a90 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -65,7 +65,7 @@ void RimDialogData::setExportCarfinDataFromString(const QString& data) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData(bool onlyWellPathCollectionSelected) const +RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData() const { return m_exportCompletionData; } diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.h b/ApplicationCode/ProjectDataModel/RimDialogData.h index 257a78621a..a03131c48d 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.h +++ b/ApplicationCode/ProjectDataModel/RimDialogData.h @@ -39,7 +39,7 @@ class RimDialogData : public caf::PdmObject QString exportCarfinDataAsString() const; void setExportCarfinDataFromString(const QString& data); - RicExportCompletionDataSettingsUi* exportCompletionData(bool onlyWellPathCollectionSelected) const; + RicExportCompletionDataSettingsUi* exportCompletionData() const; private: caf::PdmChildField m_exportCarfin; From 7f137a3e7cce38528b06ceb1896d96580d0fffe4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Apr 2018 14:23:17 +0200 Subject: [PATCH 0630/1027] #2632 Export Completions : Add exportCompletionsForVisibleSimWells --- .../CMakeLists_files.cmake | 2 + ...rtCompletionsForVisibleSimWellsFeature.cpp | 156 ++++++++++++++++++ ...portCompletionsForVisibleSimWellsFeature.h | 39 +++++ .../RimContextCommandBuilder.cpp | 6 + 4 files changed, 203 insertions(+) create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp create mode 100644 ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 23eae5d246..e94144b290 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -8,6 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h ${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleSimWellsFeature.h ) @@ -20,6 +21,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleSimWellsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp new file mode 100644 index 0000000000..a3a8f32081 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp @@ -0,0 +1,156 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportCompletionsForVisibleSimWellsFeature.h" + +#include "RiaApplication.h" + +#include "RicExportFeatureImpl.h" +#include "RicExportCompletionDataSettingsUi.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RimDialogData.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleSimWellsFeature, "RicExportCompletionsForVisibleSimWellsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionsForVisibleSimWellsFeature::isCommandEnabled() +{ + std::vector simWells = visibleSimWells(); + + if (simWells.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChecked) +{ + std::vector simWells = visibleSimWells(); + CVF_ASSERT(!simWells.empty()); + + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + QString projectFolder = app->currentProjectPath(); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + exportSettings->showForSimWells(); + + if (!exportSettings->caseToApply()) + { + std::vector cases; + app->project()->allCases(cases); + for (auto c : cases) + { + RimEclipseCase* eclipseCase = dynamic_cast(c); + if (eclipseCase != nullptr) + { + exportSettings->caseToApply = eclipseCase; + break; + } + } + } + + if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + RicExportFeatureImpl::configureForExport(&propertyDialog); + + if (propertyDialog.exec() == QDialog::Accepted) + { + RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + + std::vector wellPaths; + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Visible Simulation Wells"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() +{ + std::vector simWells; + + { + std::vector simWellCollection; + caf::SelectionManager::instance()->objectsByType(&simWellCollection); + + if (simWellCollection.empty()) + { + std::vector selectedSimWells; + caf::SelectionManager::instance()->objectsByType(&selectedSimWells); + + if (!selectedSimWells.empty()) + { + RimSimWellInViewCollection* parent = nullptr; + selectedSimWells[0]->firstAncestorOrThisOfType(parent); + if (parent) + { + simWellCollection.push_back(parent); + } + } + } + + for (auto coll : simWellCollection) + { + for (const auto& wellPath : coll->wells()) + { + if (wellPath->showWell()) + { + simWells.push_back(wellPath); + } + } + } + } + + std::set uniqueWellPaths(simWells.begin(), simWells.end()); + simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return simWells; +} + diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h new file mode 100644 index 0000000000..9e6a49ef0b --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSimWellInView; + +//================================================================================================== +/// +//================================================================================================== +class RicExportCompletionsForVisibleSimWellsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector visibleSimWells(); +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index cbbe790455..8fff068f28 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -504,6 +504,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPlotProductionRateFeature"; menuBuilder << "RicShowWellAllocationPlotFeature"; menuBuilder.subMenuEnd(); + + menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature"; } else if(dynamic_cast(uiItem)) { From 4377ac2a6b953416e8c3e5278e093989256ca680 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Apr 2018 09:18:34 +0200 Subject: [PATCH 0631/1027] AppFwk : Remove sub menu action if sub menu is empty --- Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp index d3e2483db8..e911837c96 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp @@ -164,7 +164,21 @@ void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu) { if (menus.size() > 1) { + QMenu* completeSubMenu = menus.back(); menus.pop_back(); + + if (!menus.empty()) + { + // Remove the sub menu action if no (sub) actions are present in the sub menu + if (completeSubMenu->actions().isEmpty()) + { + QMenu* menuWithEmptySubMenu = menus.back(); + + QAction* subMenuAction = completeSubMenu->menuAction(); + + menuWithEmptySubMenu->removeAction(subMenuAction); + } + } } } else From f71563cb1e2a9effb0bea82364da3b7ca2f36253 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Apr 2018 09:29:41 +0200 Subject: [PATCH 0632/1027] #2632 Export Completions : Add sub menus for export of completions --- ...RicWellPathExportCompletionDataFeature.cpp | 92 ++----------------- .../RicWellPathExportCompletionDataFeature.h | 3 - .../RimContextCommandBuilder.cpp | 35 ++++++- 3 files changed, 41 insertions(+), 89 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index 71b5c33253..d97b83377a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -44,27 +44,9 @@ CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCo //-------------------------------------------------------------------------------------------------- bool RicWellPathExportCompletionDataFeature::isCommandEnabled() { - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); + std::vector wellPaths = selectedWellPaths(); - if (wellPaths.empty() && simWells.empty()) - { - return false; - } - - if (!wellPaths.empty() && !simWells.empty()) - { - return false; - } - - std::set eclipseCases; - for (auto simWell : simWells) - { - RimEclipseCase* eclipseCase; - simWell->firstAncestorOrThisOfType(eclipseCase); - eclipseCases.insert(eclipseCase); - } - if (eclipseCases.size() > 1) + if (wellPaths.empty()) { return false; } @@ -77,10 +59,8 @@ bool RicWellPathExportCompletionDataFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) { - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); - - CVF_ASSERT(wellPaths.size() > 0 || simWells.size() > 0); + std::vector wellPaths = selectedWellPaths(); + CVF_ASSERT(!wellPaths.empty()); RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); @@ -116,13 +96,16 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + caf::PdmUiPropertyViewDialog propertyDialog( + Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) { RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + std::vector simWells; + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } } @@ -132,7 +115,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Export Completion Data"); + actionToSetup->setText("Export Completion Data for Selected Well Paths"); } //-------------------------------------------------------------------------------------------------- @@ -143,63 +126,8 @@ std::vector RicWellPathExportCompletionDataFeature::selectedWellPa std::vector wellPaths; caf::SelectionManager::instance()->objectsByType(&wellPaths); - if (wellPaths.empty()) - { - std::vector wellPathCollections; - caf::SelectionManager::instance()->objectsByType(&wellPathCollections); - - for (auto wellPathCollection : wellPathCollections) - { - for (auto wellPath : wellPathCollection->wellPaths()) - { - if (wellPath->showWellPath()) - { - wellPaths.push_back(wellPath); - } - } - } - } - std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - return wellPaths; -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::noWellPathsSelectedDirectly() -{ - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType(&wellPaths); - - if (wellPaths.empty()) - return true; - else - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::selectedSimWells() -{ - std::vector simWells; - caf::SelectionManager::instance()->objectsByType(&simWells); - - std::vector simWellCollections; - caf::SelectionManager::instance()->objectsByType(&simWellCollections); - - for (auto simWellCollection : simWellCollections) - { - for (auto simWell : simWellCollection->wells()) - { - simWells.push_back(simWell); - } - } - - std::set uniqueSimWells(simWells.begin(), simWells.end()); - simWells.assign(uniqueSimWells.begin(), uniqueSimWells.end()); - - return simWells; + return wellPaths; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index 574365894e..c589a3af0a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -37,7 +37,4 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature private: std::vector selectedWellPaths(); - std::vector selectedSimWells(); - - bool noWellPathsSelectedDirectly(); }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 8fff068f28..5ca56e055d 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -241,8 +241,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicReloadWellPathFormationNamesFeature"; menuBuilder << "RicWellPathImportPerforationIntervalsFeature"; menuBuilder.subMenuEnd(); - - menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; } else if (dynamic_cast(uiItem)) { @@ -283,10 +281,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder.subMenuEnd(); - menuBuilder << "Separator"; - + menuBuilder.subMenuStart("Export Completions", QIcon(":/FishBoneGroup16x16.png")); menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; menuBuilder << "RicWellPathExportCompletionDataFeature"; + menuBuilder.subMenuEnd(); + + menuBuilder << "Separator"; + } else if (dynamic_cast(uiItem)) { @@ -626,6 +627,32 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder << "RicExportFishbonesLateralsFeature"; menuBuilder << "RicExportFishbonesWellSegmentsFeature"; + + { + QStringList candidates; + + if (!menuBuilder.isCmdFeatureAdded("RicExportCompletionsForVisibleWellPathsFeature")) + { + candidates << "RicExportCompletionsForVisibleWellPathsFeature"; + } + if (!menuBuilder.isCmdFeatureAdded("RicWellPathExportCompletionDataFeature")) + { + candidates << "RicWellPathExportCompletionDataFeature"; + } + + if (!candidates.isEmpty()) + { + menuBuilder.subMenuStart("Export Completions", QIcon(":/FishBoneGroup16x16.png")); + + for (const auto& text : candidates) + { + menuBuilder << text; + } + + menuBuilder.subMenuEnd(); + } + } + menuBuilder << "RicWellPathImportCompletionsFileFeature"; menuBuilder << "RicFlyToObjectFeature"; menuBuilder << "RicExportCarfin"; From c759ef71b92ed1b0bf5a4c55e5b2f8aef04ea409 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Apr 2018 10:08:10 +0200 Subject: [PATCH 0633/1027] #2632 Export Completions : Use common entry point for completion export --- ...rtCompletionsForVisibleSimWellsFeature.cpp | 56 ++--------------- ...tCompletionsForVisibleWellPathsFeature.cpp | 61 +++---------------- ...RicWellPathExportCompletionDataFeature.cpp | 57 ++++++++++------- .../RicWellPathExportCompletionDataFeature.h | 7 ++- 4 files changed, 54 insertions(+), 127 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp index a3a8f32081..fe82fa65b4 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp @@ -18,22 +18,11 @@ #include "RicExportCompletionsForVisibleSimWellsFeature.h" -#include "RiaApplication.h" +#include "RicWellPathExportCompletionDataFeature.h" -#include "RicExportFeatureImpl.h" -#include "RicExportCompletionDataSettingsUi.h" -#include "RicWellPathExportCompletionDataFeatureImpl.h" - -#include "RimDialogData.h" -#include "RimProject.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" -#include "RimWellPath.h" -#include "RimWellPathCollection.h" - -#include "Riu3DMainWindowTools.h" -#include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" #include @@ -63,42 +52,10 @@ void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChe std::vector simWells = visibleSimWells(); CVF_ASSERT(!simWells.empty()); - RiaApplication* app = RiaApplication::instance(); - RimProject* project = app->project(); - - QString projectFolder = app->currentProjectPath(); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + std::vector wellPaths; + QString dialogTitle = "Export Completion Data for Visible Simulation Wells"; - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); - exportSettings->showForSimWells(); - - if (!exportSettings->caseToApply()) - { - std::vector cases; - app->project()->allCases(cases); - for (auto c : cases) - { - RimEclipseCase* eclipseCase = dynamic_cast(c); - if (eclipseCase != nullptr) - { - exportSettings->caseToApply = eclipseCase; - break; - } - } - } - - if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - - caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); - RicExportFeatureImpl::configureForExport(&propertyDialog); - - if (propertyDialog.exec() == QDialog::Accepted) - { - RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); - - std::vector wellPaths; - RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); - } + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); } //-------------------------------------------------------------------------------------------------- @@ -115,7 +72,7 @@ void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook(QAction* act std::vector RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() { std::vector simWells; - + { std::vector simWellCollection; caf::SelectionManager::instance()->objectsByType(&simWellCollection); @@ -150,7 +107,6 @@ std::vector RicExportCompletionsForVisibleSimWellsFeature::vi std::set uniqueWellPaths(simWells.begin(), simWells.end()); simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - + return simWells; } - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp index 5f452b6f08..5d2787da80 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -18,22 +18,11 @@ #include "RicExportCompletionsForVisibleWellPathsFeature.h" -#include "RiaApplication.h" +#include "RicWellPathExportCompletionDataFeature.h" -#include "RicExportFeatureImpl.h" -#include "RicExportCompletionDataSettingsUi.h" -#include "RicWellPathExportCompletionDataFeatureImpl.h" - -#include "RimDialogData.h" -#include "RimProject.h" -#include "RimSimWellInView.h" -#include "RimSimWellInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "Riu3DMainWindowTools.h" - -#include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" #include @@ -45,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCo //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() { - std::vector wellPaths = visibleWellPaths(); + std::vector wellPaths = visibleWellPaths(); if (wellPaths.empty()) { @@ -60,46 +49,13 @@ bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) { - std::vector wellPaths = visibleWellPaths(); + std::vector wellPaths = visibleWellPaths(); CVF_ASSERT(wellPaths.size() > 0); - - std::vector simWells; - - RiaApplication* app = RiaApplication::instance(); - RimProject* project = app->project(); - - QString projectFolder = app->currentProjectPath(); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); - exportSettings->showForWellPath(); - if (!exportSettings->caseToApply()) - { - std::vector cases; - app->project()->allCases(cases); - for (auto c : cases) - { - RimEclipseCase* eclipseCase = dynamic_cast(c); - if (eclipseCase != nullptr) - { - exportSettings->caseToApply = eclipseCase; - break; - } - } - } - - if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - - caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); - RicExportFeatureImpl::configureForExport(&propertyDialog); - - if (propertyDialog.exec() == QDialog::Accepted) - { - RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + std::vector simWells; + QString dialogTitle = "Export Completion Data for Visible Well Paths"; - RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); - } + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); } //-------------------------------------------------------------------------------------------------- @@ -116,7 +72,7 @@ void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* ac std::vector RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() { std::vector wellPaths; - + { std::vector wellPathCollections; caf::SelectionManager::instance()->objectsByType(&wellPathCollections); @@ -151,7 +107,6 @@ std::vector RicExportCompletionsForVisibleWellPathsFeature::visibl std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - + return wellPaths; } - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index d97b83377a..986cf1110a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -42,26 +42,11 @@ CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::isCommandEnabled() +void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( + const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells) { - std::vector wellPaths = selectedWellPaths(); - - if (wellPaths.empty()) - { - return false; - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) -{ - std::vector wellPaths = selectedWellPaths(); - CVF_ASSERT(!wellPaths.empty()); - RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); @@ -96,20 +81,46 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog( - Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) { RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); - std::vector simWells; - RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathExportCompletionDataFeature::isCommandEnabled() +{ + std::vector wellPaths = selectedWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = selectedWellPaths(); + CVF_ASSERT(!wellPaths.empty()); + + std::vector simWells; + QString dialogTitle = "Export Completion Data for Selected Well Paths"; + + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index c589a3af0a..d5595e5b00 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -30,11 +30,16 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void prepareExportSettingsAndExportCompletions(const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells); + protected: virtual bool isCommandEnabled() override; virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; private: - std::vector selectedWellPaths(); + std::vector selectedWellPaths(); }; From 7a09b9a146da6562019c1fc6d5c6a263a139e0d9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Apr 2018 11:23:14 +0200 Subject: [PATCH 0634/1027] #2632 Export Completions : Show settings for avalable completions types --- .../RicExportCompletionDataSettingsUi.cpp | 97 ++++++++++++++----- .../RicExportCompletionDataSettingsUi.h | 10 +- ...RicWellPathExportCompletionDataFeature.cpp | 48 +++++++++ 3 files changed, 130 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 83df0f771c..6e82f8ec2e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -71,6 +71,10 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, " Exclude Main Bore Transmissibility", "", "", ""); m_displayForSimWell = true; + + m_fracturesEnabled = true; + m_perforationsEnabled = true; + m_fishbonesEnabled = true; } //-------------------------------------------------------------------------------------------------- @@ -89,6 +93,30 @@ void RicExportCompletionDataSettingsUi::showForWellPath() m_displayForSimWell = false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::enableFractures(bool enable) +{ + m_fracturesEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::enablePerforations(bool enable) +{ + m_perforationsEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::enableFishbone(bool enable) +{ + m_fishbonesEnabled = enable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -141,37 +169,58 @@ QList RicExportCompletionDataSettingsUi::calculateValueO //-------------------------------------------------------------------------------------------------- void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* generalExportSettings = uiOrdering.addNewGroup("General Export Settings"); - generalExportSettings->add(&folder); - generalExportSettings->add(&caseToApply); - generalExportSettings->add(&compdatExport); - generalExportSettings->add(&useLateralNTG); + { + caf::PdmUiGroup* group = uiOrdering.addNewGroup("File Settings"); + + group->add(&folder); + group->add(&fileSplit); + } + + { + caf::PdmUiGroup* group = uiOrdering.addNewGroup("Settings"); - generalExportSettings->add(&fileSplit); + group->add(&caseToApply); + group->add(&compdatExport); + group->add(&useLateralNTG); + } - if (!m_displayForSimWell) { caf::PdmUiGroup* group = uiOrdering.addNewGroup("Visible Completions"); - - group->add(&includeFishbones); - group->add(&excludeMainBoreForFishbones); - if (!includeFishbones) excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); - else excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); - - group->add(&includePerforations); - group->add(&timeStep); - if (!includePerforations) timeStep.uiCapability()->setUiReadOnly(true); - else timeStep.uiCapability()->setUiReadOnly(false); - - group->add(&includeFractures); - - if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + if (!m_displayForSimWell) { - includeFractures.uiCapability()->setUiReadOnly(true); + if (m_fishbonesEnabled) + { + group->add(&includeFishbones); + group->add(&excludeMainBoreForFishbones); + if (!includeFishbones) + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); + else + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); + } + + if (m_perforationsEnabled) + { + group->add(&includePerforations); + group->add(&timeStep); + if (!includePerforations) + timeStep.uiCapability()->setUiReadOnly(true); + else + timeStep.uiCapability()->setUiReadOnly(false); + } } - else if (compdatExport == TRANSMISSIBILITIES) + + if (m_fracturesEnabled) { - includeFractures.uiCapability()->setUiReadOnly(false); + group->add(&includeFractures); + + if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + includeFractures.uiCapability()->setUiReadOnly(true); + } + else if (compdatExport == TRANSMISSIBILITIES) + { + includeFractures.uiCapability()->setUiReadOnly(false); + } } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index c21f5fb2ad..54f2f70edd 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -70,6 +70,10 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi void showForSimWells(); void showForWellPath(); + void enableFractures(bool enable); + void enablePerforations(bool enable); + void enableFishbone(bool enable); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; protected: @@ -77,5 +81,9 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - bool m_displayForSimWell; + bool m_displayForSimWell; + + bool m_fracturesEnabled; + bool m_perforationsEnabled; + bool m_fishbonesEnabled; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index 986cf1110a..1f6139754a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -24,11 +24,15 @@ #include "RicExportFeatureImpl.h" #include "RimDialogData.h" +#include "RimFishbonesMultipleSubs.h" +#include "RimPerforationInterval.h" #include "RimProject.h" +#include "RimSimWellFracture.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPathFracture.h" #include "Riu3DMainWindowTools.h" @@ -81,6 +85,50 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + std::vector simWellFractures; + std::vector wellPathFractures; + std::vector wellPathFishbones; + std::vector wellPathPerforations; + + for (auto s : simWells) + { + s->descendantsIncludingThisOfType(simWellFractures); + } + + for (auto w : wellPaths) + { + w->descendantsIncludingThisOfType(wellPathFractures); + w->descendantsIncludingThisOfType(wellPathFishbones); + w->descendantsIncludingThisOfType(wellPathPerforations); + } + + if ((!simWellFractures.empty()) || (!wellPathFractures.empty())) + { + exportSettings->enableFractures(true); + } + else + { + exportSettings->enableFractures(false); + } + + if (!wellPathFishbones.empty()) + { + exportSettings->enableFishbone(true); + } + else + { + exportSettings->enableFishbone(false); + } + + if (!wellPathPerforations.empty()) + { + exportSettings->enablePerforations(true); + } + else + { + exportSettings->enablePerforations(false); + } + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, ""); RicExportFeatureImpl::configureForExport(&propertyDialog); From 507229f84b321b7e58d26fd15c8fa344ed59dac0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 5 Apr 2018 15:25:33 +0200 Subject: [PATCH 0635/1027] Fixed background color setting for legends and refactored Legend class hierarchy * Added a new cafTitledOverlayFrame as a base-class for all ResInsight legend classes * Inherits cvf::OverlayItem --- .../RivTernarySaturationOverlayItem.cpp | 107 ++--------- .../RivTernarySaturationOverlayItem.h | 22 +-- .../Rim2dIntersectionView.cpp | 2 +- .../ProjectDataModel/RimLegendConfig.cpp | 3 +- .../ProjectDataModel/RimLegendConfig.h | 3 +- ApplicationCode/UserInterface/RiuViewer.cpp | 12 +- ApplicationCode/UserInterface/RiuViewer.h | 9 +- Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 2 + .../cafVizExtensions/cafCategoryLegend.cpp | 127 ++----------- .../cafVizExtensions/cafCategoryLegend.h | 29 +-- .../cafOverlayScalarMapperLegend.cpp | 130 ++------------ .../cafOverlayScalarMapperLegend.h | 30 +--- .../cafTitledOverlayFrame.cpp | 167 ++++++++++++++++++ .../cafVizExtensions/cafTitledOverlayFrame.h | 62 +++++++ 14 files changed, 315 insertions(+), 390 deletions(-) create mode 100644 Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp create mode 100644 Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 34fea69b1f..1168eaa619 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -41,12 +41,7 @@ /// //-------------------------------------------------------------------------------------------------- RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) - : m_textColor(cvf::Color3::BLACK) - , m_font(font) - , m_size(120, 150) - , m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f) - , m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f) - , m_isBackgroundEnabled(true) + : TitledOverlayFrame(font, 120, 150) { } @@ -58,35 +53,14 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::setAxisLabelsColor(const cvf::Color3f& color) { - m_textColor = color; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec2ui RivTernarySaturationOverlayItem::sizeHint() -{ - return m_size; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setSize(const cvf::Vec2ui& size) -{ - m_size = size; + this->setTextColor(color); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -95,7 +69,6 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con renderGeneric(oglContext, position, size, false); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -104,7 +77,6 @@ void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglCont renderGeneric(oglContext, position, size, true); } - //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- @@ -127,14 +99,14 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, cvf::Viewport::CLEAR_DEPTH); - if ( m_isBackgroundEnabled ) + if ( this->backgroundEnabled() ) { if ( software ) { caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, cvf::Vec2f(size), - m_backgroundColor, - m_backgroundFrameColor); + this->backgroundColor(), + this->backgroundFrameColor()); } else { @@ -143,22 +115,22 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, cvf::Vec2f(size), - m_backgroundColor, - m_backgroundFrameColor); + this->backgroundColor(), + this->backgroundFrameColor()); } border = 3.0f; } - cvf::TextDrawer textDrawer(m_font.p()); - textDrawer.setTextColor(m_textColor); + cvf::TextDrawer textDrawer(this->font()); + textDrawer.setTextColor(this->textColor()); - float lineHeightInPixels = (float)(m_font->textExtent("SWAT").y() + 2); + float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2); float textPosY = static_cast(size.y() - lineHeightInPixels); - for (size_t it = 0; it < m_titleStrings.size(); it++) + for (size_t it = 0; it < this->titleStrings().size(); it++) { cvf::Vec2f pos(border, textPosY); - textDrawer.addText(m_titleStrings[it], pos); + textDrawer.addText(this->titleStrings()[it], pos); textPosY -= lineHeightInPixels; } @@ -169,10 +141,10 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte textPosY -= border; { - cvf::uint sgasTextWidth = m_font->textExtent("SGAS").x(); + cvf::uint sgasTextWidth = this->font()->textExtent("SGAS").x(); textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (size.x() / 2) - sgasTextWidth / 2 ), textPosY)); - cvf::uint sgasRangeTextWidth = m_font->textExtent(m_sgasRange).x(); + cvf::uint sgasRangeTextWidth = this->font()->textExtent(m_sgasRange).x(); textPosY -= lineHeightInPixels; textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); } @@ -181,10 +153,10 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte textDrawer.addText(m_swatRange, cvf::Vec2f((float)border, (float)border)); { - cvf::uint soilTextWidth = m_font->textExtent("SOIL").x(); + cvf::uint soilTextWidth = this->font()->textExtent("SOIL").x(); textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth - border), lineHeightInPixels + border)); - cvf::uint soilRangeTextWidth = m_font->textExtent(m_soilRange).x(); + cvf::uint soilRangeTextWidth = this->font()->textExtent(m_soilRange).x(); float soilRangePos = static_cast(size.x()) - soilRangeTextWidth - border; textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border)); @@ -220,11 +192,11 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::Color3ub colB(cvf::Color3::GREEN); cvf::Color3ub colC(cvf::Color3::RED); - //float upperBoundY = static_cast(m_size.y() - 20); + //float upperBoundY = static_cast(this->sizeHint().y() - 20); cvf::Vec3f a(float(border), lowerBoundY, 0); - cvf::Vec3f b(static_cast(m_size.x() - border), lowerBoundY, 0); - cvf::Vec3f c(static_cast(m_size.x() / 2), upperBoundY, 0); + cvf::Vec3f b(static_cast(this->sizeHint().x() - border), lowerBoundY, 0); + cvf::Vec3f c(static_cast(this->sizeHint().x() / 2), upperBoundY, 0); // Draw filled rectangle elements @@ -272,44 +244,3 @@ void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange, m_sgasRange = sgasRange; m_swatRange = swatRange; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setTitle(const cvf::String& title) -{ - // Title - if (title.isEmpty()) - { - m_titleStrings.clear(); - } - else - { - m_titleStrings = title.split("\n"); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::enableBackground(bool enable) -{ - m_isBackgroundEnabled = enable; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setBackgroundColor(const cvf::Color4f& backgroundColor) -{ - m_backgroundColor = backgroundColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor) -{ - m_backgroundFrameColor = backgroundFrameColor; -} - diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index 138f328c82..ff3fffd0b3 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -19,7 +19,7 @@ #pragma once -#include "cvfOverlayItem.h" +#include "cafTitledOverlayFrame.h" #include "cvfMatrix4.h" #include "cvfColor3.h" #include "cvfColor4.h" @@ -36,7 +36,7 @@ class Font; // // //================================================================================================== -class RivTernarySaturationOverlayItem : public cvf::OverlayItem +class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame { public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); @@ -44,16 +44,9 @@ class RivTernarySaturationOverlayItem : public cvf::OverlayItem void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); - void setSize(const cvf::Vec2ui& size); void setAxisLabelsColor(const cvf::Color3f& color); - void setTitle(const cvf::String& title); - - void enableBackground(bool enable); - void setBackgroundColor(const cvf::Color4f& backgroundColor); - void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); private: - cvf::Vec2ui sizeHint() override; void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; @@ -68,19 +61,8 @@ class RivTernarySaturationOverlayItem : public cvf::OverlayItem void renderAxisImmediateMode(float upperY, float lowerBoundY, float border, cvf::OpenGLContext* oglContext); private: - cvf::Color3f m_textColor; // Text color - cvf::ref m_font; - - bool m_isBackgroundEnabled; - cvf::Color4f m_backgroundColor; - cvf::Color4f m_backgroundFrameColor; - cvf::String m_soilRange; cvf::String m_sgasRange; cvf::String m_swatRange; - - cvf::Vec2ui m_size; // Pixel size of draw area - - std::vector m_titleStrings; }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index afffe6ead0..cea81d063c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -573,7 +573,7 @@ void Rim2dIntersectionView::updateLegends() RimGeoMechView * geoView = nullptr; m_intersection->firstAncestorOrThisOfType(geoView); - cvf::OverlayItem* legend = nullptr; + caf::TitledOverlayFrame* legend = nullptr; if (eclView) { diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index ffaa8b9333..3b8fc83bce 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -32,6 +32,7 @@ #include "RimStimPlanColors.h" #include "RimViewLinker.h" +#include "cafTitledOverlayFrame.h" #include "cafCategoryLegend.h" #include "cafCategoryMapper.h" #include "cafOverlayScalarMapperLegend.h" @@ -675,7 +676,7 @@ void RimLegendConfig::setTitle(const QString& title) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::OverlayItem* RimLegendConfig::legend() +caf::TitledOverlayFrame* RimLegendConfig::legend() { if (m_currentScalarMapper == m_categoryMapper) { diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index d0772c3e6b..fb591bbc5c 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -41,6 +41,7 @@ namespace cvf namespace caf { + class TitledOverlayFrame; class CategoryLegend; class CategoryMapper; class OverlayScalarMapperLegend; @@ -119,7 +120,7 @@ class RimLegendConfig: public caf::PdmObject void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } - cvf::OverlayItem* legend(); + caf::TitledOverlayFrame* legend(); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index ac9fe87deb..cd79a7e394 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaBaseDefs.h" #include "RiaColorTools.h" +#include "RiaPreferences.h" #include "RiaRegressionTestRunner.h" #include "RimCase.h" @@ -40,6 +41,7 @@ #include "RiuSimpleHistogramWidget.h" #include "RiuViewerCommands.h" +#include "cafTitledOverlayFrame.h" #include "cafCategoryLegend.h" #include "cafOverlayScalarMapperLegend.h" #include "cafCeetronPlusNavigation.h" @@ -534,9 +536,13 @@ void RiuViewer::removeAllColorLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) +void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend) { + RiaApplication* app = RiaApplication::instance(); + CVF_ASSERT(app); + RiaPreferences* preferences = app->preferences(); cvf::Rendering* firstRendering = m_mainRendering.p(); + CVF_ASSERT(preferences); CVF_ASSERT(firstRendering); if (legend) @@ -544,7 +550,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) updateLegendTextAndTickMarkColor(legend); firstRendering->addOverlayItem(legend); - + legend->enableBackground(preferences->showLegendBackground()); m_visibleLegends.push_back(legend); } @@ -552,7 +558,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) const size_t categoryThreshold = 13; std::vector categoryLegends; - std::vector overlayItems; + std::vector overlayItems; for (auto legend : m_visibleLegends) { legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index ebee202195..8c3266d80e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -42,6 +42,11 @@ class QCDEStyle; class QLabel; class QProgressBar; +namespace caf +{ + class TitledOverlayFrame; +} + namespace cvf { class Color3f; @@ -91,7 +96,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void showAnimationProgress(bool enable); void removeAllColorLegends(); - void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend); + void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend); void enableNavigationRotation(bool disable); void updateNavigationPolicy(); @@ -150,7 +155,7 @@ public slots: cvf::ref m_axisCross; bool m_showAxisCross; - cvf::Collection m_visibleLegends; + cvf::Collection m_visibleLegends; cvf::Collection allOverlayItems(); diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index 4acaab9e6a..136ab8146f 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -12,6 +12,8 @@ add_library( ${PROJECT_NAME} cafBoxManipulatorPartManager.h cafBoxManipulatorGeometryGenerator.cpp cafBoxManipulatorGeometryGenerator.h + cafTitledOverlayFrame.cpp + cafTitledOverlayFrame.h cafCategoryLegend.cpp cafCategoryLegend.h cafOverlayScalarMapperLegend.h diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index c69b5f936a..640fc7b528 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -39,15 +39,8 @@ namespace caf { /// //-------------------------------------------------------------------------------------------------- CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) - : m_sizeHint(200, 200), - m_textColor(Color3::BLACK), - m_lineColor(Color3::BLACK), - m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f), - m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f), - m_isBackgroundEnabled(true), - m_lineWidth(1), - m_font(font), - m_categoryMapper(categoryMapper) + : TitledOverlayFrame(font, 200, 200) + , m_categoryMapper(categoryMapper) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -61,48 +54,6 @@ CategoryLegend::~CategoryLegend() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec2ui CategoryLegend::sizeHint() -{ - return m_sizeHint; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setSizeHint(const Vec2ui& size) -{ - m_sizeHint = size; -} - -//-------------------------------------------------------------------------------------------------- -/// Set color of the text -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setTextColor(const Color3f& color) -{ - m_textColor = color; -} - -//-------------------------------------------------------------------------------------------------- -/// Set the title (text that will be rendered above the legend) -/// -/// The legend supports multi-line titles. Separate each line with a '\n' character -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setTitle(const String& title) -{ - // Title - if (title.isEmpty()) - { - m_titleStrings.clear(); - } - else - { - m_titleStrings = title.split("\n"); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -184,7 +135,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, // Set up text drawer float maxLegendRightPos = 0; - TextDrawer textDrawer(m_font.p()); + TextDrawer textDrawer(this->font()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); @@ -192,21 +143,21 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, // Do the actual rendering if (software) { - if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, - m_backgroundColor, - m_backgroundFrameColor); + this->backgroundColor(), + this->backgroundFrameColor()); renderLegendImmediateMode(oglContext, &layout); textDrawer.renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); - if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, - m_backgroundColor, - m_backgroundFrameColor); + this->backgroundColor(), + this->backgroundFrameColor()); renderLegendUsingShaders(oglContext, &layout, matrixState); textDrawer.render(oglContext, camera); } @@ -231,7 +182,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, float legendRight = 0.0f; textDrawer->setVerticalAlignment(TextDrawer::CENTER); - textDrawer->setTextColor(m_textColor); + textDrawer->setTextColor(this->textColor()); m_visibleCategoryLabels.clear(); @@ -274,7 +225,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, Vec2f pos(textX, textY); textDrawer->addText(displayText, pos); - float neededRightPos = pos.x() + m_font->textExtent(displayText).x(); + float neededRightPos = pos.x() + this->font()->textExtent(displayText).x(); legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; lastVisibleTextY = textY; @@ -282,12 +233,12 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, } float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight / 2.0f; - for (size_t it = 0; it < m_titleStrings.size(); it++) + for (size_t it = 0; it < this->titleStrings().size(); it++) { Vec2f pos(layout->margins.x(), titleY); - textDrawer->addText(m_titleStrings[it], pos); + textDrawer->addText(this->titleStrings()[it], pos); - float neededRightPos = pos.x() + m_font->textExtent(m_titleStrings[it]).x(); + float neededRightPos = pos.x() + this->font()->textExtent(this->titleStrings()[it]).x(); legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; titleY -= layout->lineSpacing; @@ -311,7 +262,7 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, RenderStateDepth depth(false); depth.applyOpenGL(oglContext); - RenderStateLine line(static_cast(m_lineWidth)); + RenderStateLine line(static_cast(this->lineWidth())); line.applyOpenGL(oglContext); // All vertices. Initialized here to set Z to zero once and for all. @@ -393,7 +344,7 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0 }; - UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); shaderProgram->applyUniform(oglContext, uniformColor); #ifdef CVF_OPENGL_ES @@ -497,7 +448,7 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; - glColor3fv(m_textColor.ptr()); + glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); glVertex3fv(v0); glVertex3fv(v1); @@ -528,13 +479,13 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) { CVF_TIGHT_ASSERT(layout); - ref glyph = m_font->getGlyph(L'A'); + ref glyph = this->font()->getGlyph(L'A'); layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; layout->margins = Vec2f(4.0f, 4.0f); float legendWidth = 25.0f; - float legendHeight = static_cast(layout->size.y()) - 2 * layout->margins.y() - static_cast(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing; + float legendHeight = static_cast(layout->size.y()) - 2 * layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight / 2.0f, legendWidth, legendHeight); if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) @@ -547,46 +498,6 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->tickX = layout->x1 + 5; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setLineColor(const Color3f& lineColor) -{ - m_lineColor = lineColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setLineWidth(int lineWidth) -{ - m_lineWidth = lineWidth; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setBackgroundColor(const Color4f& backgroundColor) -{ - m_backgroundColor = backgroundColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setBackgroundFrameColor(const Color4f& backgroundFrameColor) -{ - m_backgroundFrameColor = backgroundFrameColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::enableBackground(bool enable) -{ - m_isBackgroundEnabled = enable; -} - diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 450a6e3a8d..0e5e6cdf29 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -1,6 +1,7 @@ #pragma once +#include "cafTitledOverlayFrame.h" #include "cvfBase.h" #include "cvfArray.h" #include "cvfCamera.h" @@ -23,27 +24,15 @@ class CategoryMapper; // // //================================================================================================== -class CategoryLegend : public cvf::OverlayItem +class CategoryLegend : public caf::TitledOverlayFrame { public: CategoryLegend(cvf::Font* font, const CategoryMapper* categoryMapper); virtual ~CategoryLegend(); - void setSizeHint(const cvf::Vec2ui& size); - - void setTextColor(const cvf::Color3f& color); - void setLineColor(const cvf::Color3f& lineColor); - void setLineWidth(int lineWidth); - void setTitle(const cvf::String& title); - - void enableBackground(bool enable); - void setBackgroundColor(const cvf::Color4f& backgroundColor); - void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); - size_t categoryCount() const; protected: - cvf::Vec2ui sizeHint() override; void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; bool pick(int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; @@ -92,19 +81,7 @@ class CategoryLegend : public cvf::OverlayItem protected: std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label - - cvf::Vec2ui m_sizeHint; // Pixel size of the color legend area - - cvf::Color3f m_textColor; - cvf::Color3f m_lineColor; - int m_lineWidth; - std::vector m_titleStrings; - cvf::ref m_font; - - bool m_isBackgroundEnabled; - cvf::Color4f m_backgroundColor; - cvf::Color4f m_backgroundFrameColor; - + cvf::cref m_categoryMapper; }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 4c2c4601ba..0cdccdd3ca 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -83,16 +83,9 @@ using namespace cvf; /// Constructor //-------------------------------------------------------------------------------------------------- OverlayScalarMapperLegend::OverlayScalarMapperLegend(Font* font) -: m_sizeHint(200, 200), - m_textColor(Color3::BLACK), - m_lineColor(Color3::BLACK), - m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f), - m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f), - m_isBackgroundEnabled(true), - m_lineWidth(1), - m_font(font), - m_tickNumberPrecision(4), - m_numberFormat(AUTO) +: TitledOverlayFrame(font, 200, 200) + , m_tickNumberPrecision(4) + , m_numberFormat(AUTO) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -112,16 +105,6 @@ OverlayScalarMapperLegend::~OverlayScalarMapperLegend() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec2ui OverlayScalarMapperLegend::sizeHint() -{ - return m_sizeHint; -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -138,43 +121,6 @@ void OverlayScalarMapperLegend::setScalarMapper(const ScalarMapper* scalarMapper } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setSizeHint(const Vec2ui& size) -{ - m_sizeHint = size; -} - - -//-------------------------------------------------------------------------------------------------- -/// Set color of the text -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setTextColor(const Color3f& color) -{ - m_textColor = color; -} - - -//-------------------------------------------------------------------------------------------------- -/// Set the title (text that will be rendered above the legend) -/// -/// The legend supports multi-line titles. Separate each line with a '\n' character -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setTitle(const String& title) -{ - // Title - if (title.isEmpty()) - { - m_titleStrings.clear(); - } - else - { - m_titleStrings = title.split("\n"); - } -} - //-------------------------------------------------------------------------------------------------- /// Hardware rendering using shader programs //-------------------------------------------------------------------------------------------------- @@ -243,7 +189,7 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V // Set up text drawer float maxLegendRightPos = 0; - TextDrawer textDrawer(m_font.p()); + TextDrawer textDrawer(this->font()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); @@ -251,14 +197,14 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V // Do the actual rendering if (software) { - if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, m_backgroundColor, m_backgroundFrameColor); + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); renderLegendImmediateMode(oglContext, &layout); textDrawer.renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); - if (m_isBackgroundEnabled) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, m_backgroundColor, m_backgroundFrameColor); + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); renderLegendUsingShaders(oglContext, &layout, matrixState); textDrawer.render(oglContext, camera); } @@ -277,7 +223,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov float legendRight = 0.0f; textDrawer->setVerticalAlignment(TextDrawer::CENTER); - textDrawer->setTextColor(m_textColor); + textDrawer->setTextColor(this->textColor()); m_visibleTickLabels.clear(); @@ -330,7 +276,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov Vec2f pos(textX, textY); textDrawer->addText(valueString, pos); - float neededRightPos = pos.x() + m_font->textExtent(valueString).x(); + float neededRightPos = pos.x() + this->font()->textExtent(valueString).x(); legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; lastVisibleTextY = textY; @@ -338,12 +284,12 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov } float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight/2.0f; - for (it = 0; it < m_titleStrings.size(); it++) + for (it = 0; it < this->titleStrings().size(); it++) { Vec2f pos(layout->margins.x(), titleY); - textDrawer->addText(m_titleStrings[it], pos); + textDrawer->addText(this->titleStrings()[it], pos); - float neededRightPos = pos.x() + m_font->textExtent(m_titleStrings[it]).x(); + float neededRightPos = pos.x() + this->font()->textExtent(this->titleStrings()[it]).x(); legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; @@ -367,7 +313,7 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte RenderStateDepth depth(false); depth.applyOpenGL(oglContext); - RenderStateLine line(static_cast(m_lineWidth)); + RenderStateLine line(static_cast(this->lineWidth())); line.applyOpenGL(oglContext); // All vertices. Initialized here to set Z to zero once and for all. @@ -449,7 +395,7 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0}; - UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); shaderProgram->applyUniform(oglContext, uniformColor); #ifdef CVF_OPENGL_ES @@ -482,7 +428,7 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte // Dynamic coordinates for tickmarks-lines v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; - UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); shaderProgram->applyUniform(oglContext, uniformColor); const ushort * linesConnects; @@ -597,7 +543,7 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont v0[1] = v1[1] = layout->legendRect.min().y()-0.5f; v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; - glColor3fv(m_textColor.ptr()); + glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); glVertex3fv(v0); glVertex3fv(v1); @@ -631,7 +577,7 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont // Dynamic coordinates for tickmarks-lines v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; - glColor3fv(m_textColor.ptr()); + glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); if ( m_visibleTickLabels[ic]) { @@ -664,13 +610,13 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) { CVF_TIGHT_ASSERT(layout); - ref glyph = m_font->getGlyph(L'A'); + ref glyph = this->font()->getGlyph(L'A'); layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; layout->margins = Vec2f(4.0f, 4.0f); float legendWidth = 25.0f; - float legendHeight = static_cast(layout->size.y()) - 2*layout->margins.y() - static_cast(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing; + float legendHeight = static_cast(layout->size.y()) - 2*layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight/2.0f, legendWidth, legendHeight); if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) @@ -704,46 +650,6 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setLineColor(const Color3f& lineColor) -{ - m_lineColor = lineColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setBackgroundColor(const Color4f& backgroundColor) -{ - m_backgroundColor = backgroundColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setBackgroundFrameColor(const Color4f& backgroundFrameColor) -{ - m_backgroundFrameColor = backgroundFrameColor; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::enableBackground(bool enable) -{ - m_isBackgroundEnabled = enable; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setLineWidth(int lineWidth) -{ - m_lineWidth = lineWidth; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index 1890f41244..11a2f2c7cc 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -37,6 +37,7 @@ #pragma once +#include "cafTitledOverlayFrame.h" #include "cvfOverlayItem.h" #include "cvfArray.h" #include "cvfCamera.h" @@ -59,7 +60,7 @@ namespace caf { // Overlay color legend // //================================================================================================== -class OverlayScalarMapperLegend : public cvf::OverlayItem +class OverlayScalarMapperLegend : public caf::TitledOverlayFrame { using Font = cvf::Font; using ScalarMapper = cvf::ScalarMapper; @@ -81,25 +82,11 @@ class OverlayScalarMapperLegend : public cvf::OverlayItem void setScalarMapper(const ScalarMapper* scalarMapper); - void setSizeHint(const Vec2ui& size); - - void setTextColor(const Color3f& color); - void setLineColor(const Color3f& lineColor); - - void setLineWidth(int lineWidth); - void setTickPrecision(int precision); enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); - void enableBackground(bool enable); - void setBackgroundColor(const Color4f& backgroundColor); - void setBackgroundFrameColor(const Color4f& backgroundFrameColor); - - void setTitle(const String& title); - protected: - Vec2ui sizeHint() override; void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) override; @@ -147,19 +134,6 @@ class OverlayScalarMapperLegend : public cvf::OverlayItem int m_tickNumberPrecision; NumberFormat m_numberFormat; - Vec2ui m_sizeHint; // Pixel size of the color legend area - - Color3f m_textColor; - Color3f m_lineColor; - bool m_isBackgroundEnabled; - Color4f m_backgroundColor; - Color4f m_backgroundFrameColor; - - int m_lineWidth; - - std::vector m_titleStrings; - cvf::ref m_font; - cvf::cref m_scalarMapper; }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp new file mode 100644 index 0000000000..4660733875 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -0,0 +1,167 @@ +#include "cafTitledOverlayFrame.h" +#include "cafCategoryMapper.h" +#include "cvfFont.h" + +using namespace cvf; + +namespace caf { + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + TitledOverlayFrame::TitledOverlayFrame(Font* font, unsigned int width, unsigned int height) + : m_font(font) + , m_sizeHint(width, height) + , m_textColor(Color3::BLACK) + , m_lineColor(Color3::BLACK) + , m_lineWidth(1) + , m_isBackgroundEnabled(true) + , m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f) + , m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f) + { + } + + TitledOverlayFrame::~TitledOverlayFrame() + { + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setSizeHint(const Vec2ui& size) + { + m_sizeHint = size; + } + + //-------------------------------------------------------------------------------------------------- + /// Set color of the text + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setTextColor(const Color3f& color) + { + m_textColor = color; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setLineColor(const Color3f& lineColor) + { + m_lineColor = lineColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setLineWidth(int lineWidth) + { + m_lineWidth = lineWidth; + } + + //-------------------------------------------------------------------------------------------------- + /// Set the title (text that will be rendered above the legend) + /// + /// The legend supports multi-line titles. Separate each line with a '\n' character + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setTitle(const String& title) + { + // Title + if (title.isEmpty()) + { + m_titleStrings.clear(); + } + else + { + m_titleStrings = title.split("\n"); + } + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::enableBackground(bool enable) + { + m_isBackgroundEnabled = enable; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setBackgroundColor(const Color4f& backgroundColor) + { + m_backgroundColor = backgroundColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setBackgroundFrameColor(const Color4f& backgroundFrameColor) + { + m_backgroundFrameColor = backgroundFrameColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Vec2ui TitledOverlayFrame::sizeHint() + { + return m_sizeHint; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color3f TitledOverlayFrame::textColor() const + { + return m_textColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color3f TitledOverlayFrame::lineColor() const + { + return m_lineColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + int TitledOverlayFrame::lineWidth() const + { + return m_lineWidth; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + bool TitledOverlayFrame::backgroundEnabled() const + { + return m_isBackgroundEnabled; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color4f TitledOverlayFrame::backgroundColor() const + { + return m_backgroundColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color4f TitledOverlayFrame::backgroundFrameColor() const + { + return m_backgroundFrameColor; + } + + std::vector& TitledOverlayFrame::titleStrings() + { + return m_titleStrings; + } + + cvf::Font* TitledOverlayFrame::font() + { + return m_font.p(); + } +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h new file mode 100644 index 0000000000..384aff7c8e --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -0,0 +1,62 @@ +#pragma once +#include "cvfBase.h" +#include "cvfColor3.h" +#include "cvfColor4.h" +#include "cvfOverlayItem.h" +#include "cvfString.h" + +namespace cvf +{ + class Font; +} + +namespace caf { + //================================================================================================== + // Base class for ApplicationFwk Legends. + // Abstract because the pure virtual render methods from cvf::OverlayItem are not implemented. + //================================================================================================== + class TitledOverlayFrame : public cvf::OverlayItem + { + public: + TitledOverlayFrame(cvf::Font* font, unsigned int width = 100, unsigned int height = 200); + virtual ~TitledOverlayFrame(); + + virtual void setSizeHint(const cvf::Vec2ui& size); + + void setTextColor(const cvf::Color3f& color); + void setLineColor(const cvf::Color3f& lineColor); + void setLineWidth(int lineWidth); + + void setTitle(const cvf::String& title); + + void enableBackground(bool enable); + void setBackgroundColor(const cvf::Color4f& backgroundColor); + void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); + + virtual cvf::Vec2ui sizeHint() override; + + protected: + cvf::Color3f textColor() const; + cvf::Color3f lineColor() const; + int lineWidth() const; + + bool backgroundEnabled() const; + cvf::Color4f backgroundColor() const; + cvf::Color4f backgroundFrameColor() const; + std::vector& titleStrings(); + cvf::Font* font(); + + private: + cvf::Vec2ui m_sizeHint; // The desired pixel size of the color legend area + cvf::Color3f m_textColor; + cvf::Color3f m_lineColor; + int m_lineWidth; + + bool m_isBackgroundEnabled; + cvf::Color4f m_backgroundColor; + cvf::Color4f m_backgroundFrameColor; + + std::vector m_titleStrings; + cvf::ref m_font; + }; +} From 63ffade45292c0b3f7c1f5dd1d2d886201493392 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 6 Apr 2018 11:52:29 +0200 Subject: [PATCH 0636/1027] Set background and frame color from the view plus update frame margins. --- .../Application/Tools/RiaColorTools.cpp | 29 +++++++++++++++++++ .../Application/Tools/RiaColorTools.h | 3 +- .../GridBox/RivGridBoxGenerator.cpp | 26 ++--------------- .../RivTernarySaturationOverlayItem.cpp | 4 +-- .../Rim2dIntersectionView.cpp | 2 +- .../ProjectDataModel/Rim3dView.cpp | 20 +++++++++---- ApplicationCode/ProjectDataModel/Rim3dView.h | 5 +++- .../ProjectDataModel/RimEclipseView.cpp | 28 +++++++++++++----- .../ProjectDataModel/RimEclipseView.h | 1 + .../ProjectDataModel/RimGeoMechView.cpp | 9 ++++-- ApplicationCode/UserInterface/RiuViewer.cpp | 4 ++- ApplicationCode/UserInterface/RiuViewer.h | 2 +- .../cafVizExtensions/cafCategoryLegend.cpp | 4 +-- .../cafOverlayScalarMapperLegend.cpp | 4 +-- 14 files changed, 90 insertions(+), 51 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTools.cpp b/ApplicationCode/Application/Tools/RiaColorTools.cpp index c17f61e6c3..0d74ee9489 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTools.cpp @@ -17,6 +17,8 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaColorTools.h" +#include "cvfMath.h" +#include //-------------------------------------------------------------------------------------------------- /// @@ -31,6 +33,33 @@ bool RiaColorTools::isBrightnessAboveThreshold(cvf::Color3f backgroundColor) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::computeOffsetColor(cvf::Color3f color, float offsetFactor) +{ + float gridR = 0.0; + float gridG = 0.0; + float gridB = 0.0; + + if (isBrightnessAboveThreshold(color)) + { + gridR = color.r() - (color.r() * offsetFactor); + gridG = color.g() - (color.g() * offsetFactor); + gridB = color.b() - (color.b() * offsetFactor); + } + else + { + gridR = color.r() + (1.0f - color.r()) * offsetFactor; + gridG = color.g() + (1.0f - color.g()) * offsetFactor; + gridB = color.b() + (1.0f - color.b()) * offsetFactor; + } + + return cvf::Color3f(cvf::Math::clamp(gridR, 0.0f, 1.0f), + cvf::Math::clamp(gridG, 0.0f, 1.0f), + cvf::Math::clamp(gridB, 0.0f, 1.0f)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTools.h b/ApplicationCode/Application/Tools/RiaColorTools.h index ff2141b566..8feb7a1d7c 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.h +++ b/ApplicationCode/Application/Tools/RiaColorTools.h @@ -30,7 +30,8 @@ class RiaColorTools { public: static bool isBrightnessAboveThreshold(cvf::Color3f backgroundColor); - + + static cvf::Color3f computeOffsetColor(cvf::Color3f color, float offsetFactor); static cvf::Color3f darkContrastColor(); static cvf::Color3f brightContrastColor(); static cvf::Color3f constrastColor(cvf::Color3f backgroundColor); diff --git a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp index 20c14f5ccc..b818027b04 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp +++ b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp @@ -734,30 +734,8 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2) //-------------------------------------------------------------------------------------------------- void RivGridBoxGenerator::updateFromBackgroundColor(const cvf::Color3f& backgroundColor) { - double adjustmentFactor = 0.3; - - float gridR = 0.0; - float gridG = 0.0; - float gridB = 0.0; - - if (RiaColorTools::isBrightnessAboveThreshold(backgroundColor)) - { - gridR = backgroundColor.r() - (backgroundColor.r() * adjustmentFactor); - gridG = backgroundColor.g() - (backgroundColor.g() * adjustmentFactor); - gridB = backgroundColor.b() - (backgroundColor.b() * adjustmentFactor); - - m_gridLegendColor = RiaColorTools::darkContrastColor(); - } - else - { - gridR = backgroundColor.r() + (1.0 - backgroundColor.r()) * adjustmentFactor; - gridG = backgroundColor.g() + (1.0 - backgroundColor.g()) * adjustmentFactor; - gridB = backgroundColor.b() + (1.0 - backgroundColor.b()) * adjustmentFactor; - - m_gridLegendColor = RiaColorTools::brightContrastColor(); - } - - m_gridColor.set(gridR, gridG, gridB); + m_gridColor = RiaColorTools::computeOffsetColor(backgroundColor, 0.3f); + m_gridLegendColor = RiaColorTools::constrastColor(backgroundColor); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 1168eaa619..70a96c9a80 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -118,7 +118,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte this->backgroundColor(), this->backgroundFrameColor()); } - border = 3.0f; + border = 8.0f; } cvf::TextDrawer textDrawer(this->font()); @@ -126,7 +126,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2); - float textPosY = static_cast(size.y() - lineHeightInPixels); + float textPosY = static_cast(size.y() - lineHeightInPixels - border); for (size_t it = 0; it < this->titleStrings().size(); it++) { cvf::Vec2f pos(border, textPosY); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index cea81d063c..0aac11a9d6 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -603,7 +603,7 @@ void Rim2dIntersectionView::updateLegends() if ( legend ) { - m_viewer->addColorLegendToBottomLeftCorner(legend); + m_viewer->addColorLegendToBottomLeftCorner(legend, this->backgroundColor()); } } diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index b1fe4c32ef..eba20674cc 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -583,12 +583,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const } else if (changedField == &m_backgroundColor) { - if (m_viewer != nullptr) - { - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - } - updateGridBoxData(); - updateAnnotationItems(); + this->applyBackgroundColor(); } else if (changedField == &maximumFrameRate) { @@ -730,6 +725,19 @@ void Rim3dView::createHighlightAndGridBoxDisplayModel() m_viewer->showGridBox(m_showGridBox()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::applyBackgroundColor() +{ + if (m_viewer != nullptr) + { + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + } + updateGridBoxData(); + updateAnnotationItems(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index b98909b25a..6656072d03 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -155,6 +155,10 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void createHighlightAndGridBoxDisplayModel(); + // Implementation of RiuViewerToViewInterface + virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor(); } + virtual void applyBackgroundColor(); + // Abstract methods to implement in subclasses virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; @@ -206,7 +210,6 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface // Implementation of RiuViewerToViewInterface - virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor();} virtual void setCameraPosition(const cvf::Mat4d& cameraPosition) override { m_cameraPosition = cameraPosition; } virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) override { m_cameraPointOfInterest = cameraPointOfInterest;} virtual QString timeStepName(int frameIdx) const override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 2ab8ea429b..49ec05442c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1085,7 +1085,7 @@ void RimEclipseView::updateLegends() } } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor()); this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); } else @@ -1101,7 +1101,7 @@ void RimEclipseView::updateLegends() if (fractureColors()->isChecked() && stimPlanLegend->legend()) { - m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); + m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend(), this->backgroundColor()); } } @@ -1111,7 +1111,7 @@ void RimEclipseView::updateLegends() RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); - m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); + m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor()); } } @@ -1126,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->hasResult()) { - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); } @@ -1136,7 +1136,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->ternaryLegendConfig->legend()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor()); } } } @@ -1594,9 +1594,14 @@ void RimEclipseView::resetLegendsInViewer() m_viewer->removeAllColorLegends(); - if (cellResultNormalLegendConfig) m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend()); + if (cellResultNormalLegendConfig) + { + m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend(), + this->backgroundColor()); + } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), + this->backgroundColor()); } //-------------------------------------------------------------------------------------------------- @@ -1732,6 +1737,15 @@ bool RimEclipseView::showActiveCellsOnly() return !m_showInactiveCells; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::applyBackgroundColor() +{ + Rim3dView::applyBackgroundColor(); + this->updateLegends(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 492bf8b455..6b8b971a2b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -147,6 +147,7 @@ class RimEclipseView : public RimGridView virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; virtual bool showActiveCellsOnly() override; + virtual void applyBackgroundColor() override; private: void createDisplayModel() override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index cd2a17dcf1..45bc143e8d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -364,7 +364,8 @@ void RimGeoMechView::resetLegendsInViewer() this->cellResult()->legendConfig->recreateLegend(); m_viewer->removeAllColorLegends(); - m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend(), + this->backgroundColor()); } //-------------------------------------------------------------------------------------------------- @@ -380,14 +381,16 @@ void RimGeoMechView::updateLegends() if (cellResult()->hasResult()) { - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend(), + this->backgroundColor()); } updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { - m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend(), + this->backgroundColor()); } } } diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index cd79a7e394..eb2408ba62 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -536,7 +536,7 @@ void RiuViewer::removeAllColorLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend) +void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend, const cvf::Color3f& backgroundColor) { RiaApplication* app = RiaApplication::instance(); CVF_ASSERT(app); @@ -551,6 +551,8 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend firstRendering->addOverlayItem(legend); legend->enableBackground(preferences->showLegendBackground()); + legend->setBackgroundColor(cvf::Color4f(backgroundColor, 0.8f)); + legend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(backgroundColor, 0.3f), 0.9f)); m_visibleLegends.push_back(legend); } diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 8c3266d80e..1f33413ed4 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -96,7 +96,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void showAnimationProgress(bool enable); void removeAllColorLegends(); - void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend); + void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend, const cvf::Color3f& backgroundColor); void enableNavigationRotation(bool disable); void updateNavigationPolicy(); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 640fc7b528..1da1fd6221 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -138,7 +138,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, TextDrawer textDrawer(this->font()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); - Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + layout.margins.x(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) @@ -482,7 +482,7 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) ref glyph = this->font()->getGlyph(L'A'); layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; - layout->margins = Vec2f(4.0f, 4.0f); + layout->margins = Vec2f(8.0f, 8.0f); float legendWidth = 25.0f; float legendHeight = static_cast(layout->size.y()) - 2 * layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 0cdccdd3ca..ad1fee92aa 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -192,7 +192,7 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V TextDrawer textDrawer(this->font()); setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); - Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + 3.0f, (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + layout.margins.x(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) @@ -613,7 +613,7 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) ref glyph = this->font()->getGlyph(L'A'); layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; - layout->margins = Vec2f(4.0f, 4.0f); + layout->margins = Vec2f(8.0f, 8.0f); float legendWidth = 25.0f; float legendHeight = static_cast(layout->size.y()) - 2*layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; From 38aa447dcd1ce8395776462eddb4d217f07ad7e5 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 6 Apr 2018 14:07:00 +0200 Subject: [PATCH 0637/1027] Unify the width of all visible legends. * Calculate the minimum width to fit the content before the render pass. * Set the actual width of all the legends to the largest of the minimum widths. * This resizes the legends to always be the same size and reduces the size of you remove the widest legend. --- .../RivTernarySaturationOverlayItem.cpp | 9 ++++ .../RivTernarySaturationOverlayItem.h | 1 + .../ProjectDataModel/RimLegendConfig.cpp | 1 + ApplicationCode/UserInterface/RiuViewer.cpp | 11 +++++ .../cafVizExtensions/cafCategoryLegend.cpp | 37 +++++++++------- .../cafVizExtensions/cafCategoryLegend.h | 8 ++-- .../cafOverlayScalarMapperLegend.cpp | 42 ++++++++++++------- .../cafOverlayScalarMapperLegend.h | 6 ++- .../cafTitledOverlayFrame.cpp | 36 ++++++++++++++++ .../cafVizExtensions/cafTitledOverlayFrame.h | 11 ++++- 10 files changed, 127 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 70a96c9a80..78695e899e 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -43,6 +43,7 @@ RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) : TitledOverlayFrame(font, 120, 150) { + this->computeLayoutAndExtents(); } //-------------------------------------------------------------------------------------------------- @@ -53,6 +54,14 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTernarySaturationOverlayItem::computeLayoutAndExtents() +{ + this->setMinimumWidth(this->sizeHint().x()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index ff3fffd0b3..34ee1d58ac 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -41,6 +41,7 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); ~RivTernarySaturationOverlayItem(); + virtual void computeLayoutAndExtents() override; void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 3b8fc83bce..819cc1c8eb 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -370,6 +370,7 @@ void RimLegendConfig::updateLegend() numDecimalDigits -= static_cast(decadesInRange); } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); + m_scalarMapperLegend->computeLayoutAndExtents(); RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index eb2408ba62..4bc5008681 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -614,6 +614,17 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend yPos += item->sizeHint().y() + border + edgeAxisBorderHeight; } } + + unsigned int requiredLegendWidth = 0u; + for (auto legend : m_visibleLegends) + { + requiredLegendWidth = std::max(requiredLegendWidth, legend->minimumWidth()); + } + + for (auto legend : m_visibleLegends) + { + legend->setWidth(requiredLegendWidth); + } } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 1da1fd6221..58e9797481 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -41,6 +41,7 @@ namespace caf { CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) : TitledOverlayFrame(font, 200, 200) , m_categoryMapper(categoryMapper) + , m_Layout(Vec2i(0, 0), Vec2ui(200u, 200u)) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -128,17 +129,9 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - // Get layout information - // Todo: Cache this between renderings. Update only when needed. - OverlayColorLegendLayoutInfo layout(position, size); - layoutInfo(&layout); - - // Set up text drawer - float maxLegendRightPos = 0; - TextDrawer textDrawer(this->font()); - setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); + this->computeLayoutAndExtents(); - Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + layout.margins.x(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN((float) this->width(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) @@ -147,8 +140,8 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); - renderLegendImmediateMode(oglContext, &layout); - textDrawer.renderSoftware(oglContext, camera); + renderLegendImmediateMode(oglContext, &m_Layout); + m_textDrawer->renderSoftware(oglContext, camera); } else { @@ -158,8 +151,8 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); - renderLegendUsingShaders(oglContext, &layout, matrixState); - textDrawer.render(oglContext, camera); + renderLegendUsingShaders(oglContext, &m_Layout, matrixState); + m_textDrawer->render(oglContext, camera); } CVF_CHECK_OGL(oglContext); @@ -498,6 +491,22 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->tickX = layout->x1 + 5; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CategoryLegend::computeLayoutAndExtents() +{ + // Todo: Cache this between renderings. Update only when needed. + layoutInfo(&m_Layout); + m_textDrawer = new TextDrawer(this->font()); + + // Set up text drawer + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); + + unsigned int contentWidth = static_cast(std::ceil(maxLegendRightPos + m_Layout.margins.x())); + this->setMinimumWidth(contentWidth); +} diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 0e5e6cdf29..a78eb9d726 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -31,6 +31,7 @@ class CategoryLegend : public caf::TitledOverlayFrame virtual ~CategoryLegend(); size_t categoryCount() const; + void computeLayoutAndExtents() override; protected: void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; @@ -80,9 +81,10 @@ class CategoryLegend : public caf::TitledOverlayFrame OverlayColorLegendLayoutInfo* layout); protected: - std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label - - cvf::cref m_categoryMapper; + std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label + OverlayColorLegendLayoutInfo m_Layout; + cvf::ref m_textDrawer; + cvf::cref m_categoryMapper; }; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index ad1fee92aa..0abf0c9b79 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -86,6 +86,7 @@ OverlayScalarMapperLegend::OverlayScalarMapperLegend(Font* font) : TitledOverlayFrame(font, 200, 200) , m_tickNumberPrecision(4) , m_numberFormat(AUTO) + , m_Layout(Vec2i(0, 0), Vec2ui(200u, 200u)) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -182,31 +183,26 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - // Get layout information - // Todo: Cache this between renderings. Update only when needed. - OverlayColorLegendLayoutInfo layout(position, size); - layoutInfo(&layout); + m_Layout.position = position; + m_Layout.size = size; + + this->computeLayoutAndExtents(); - // Set up text drawer - float maxLegendRightPos = 0; - TextDrawer textDrawer(this->font()); - setupTextDrawer(&textDrawer, &layout, &maxLegendRightPos); - - Vec2f backgroundSize(CVF_MIN(maxLegendRightPos + layout.margins.x(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN((float)this->width(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) { if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); - renderLegendImmediateMode(oglContext, &layout); - textDrawer.renderSoftware(oglContext, camera); + renderLegendImmediateMode(oglContext, &m_Layout); + m_textDrawer->renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); - renderLegendUsingShaders(oglContext, &layout, matrixState); - textDrawer.render(oglContext, camera); + renderLegendUsingShaders(oglContext, &m_Layout, matrixState); + m_textDrawer->render(oglContext, camera); } CVF_CHECK_OGL(oglContext); @@ -221,7 +217,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov CVF_ASSERT(layout); float legendRight = 0.0f; - + textDrawer->setVerticalAlignment(TextDrawer::CENTER); textDrawer->setTextColor(this->textColor()); @@ -666,6 +662,22 @@ void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) m_numberFormat = format; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::computeLayoutAndExtents() +{ + layoutInfo(&m_Layout); + + m_textDrawer = new TextDrawer(this->font()); + + // Set up text drawer + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); + + unsigned int contentWidth = static_cast(std::ceil(maxLegendRightPos + m_Layout.margins.x())); + this->setMinimumWidth(contentWidth); +} } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index 11a2f2c7cc..6a2c2fffd0 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -85,7 +85,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame void setTickPrecision(int precision); enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); - + void computeLayoutAndExtents() override; protected: void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; @@ -134,7 +134,9 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame int m_tickNumberPrecision; NumberFormat m_numberFormat; - cvf::cref m_scalarMapper; + OverlayColorLegendLayoutInfo m_Layout; + cvf::ref m_textDrawer; + cvf::cref m_scalarMapper; }; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp index 4660733875..10f35d6832 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -2,6 +2,8 @@ #include "cafCategoryMapper.h" #include "cvfFont.h" +#include + using namespace cvf; namespace caf { @@ -12,6 +14,7 @@ namespace caf { TitledOverlayFrame::TitledOverlayFrame(Font* font, unsigned int width, unsigned int height) : m_font(font) , m_sizeHint(width, height) + , m_minimumWidth(0u) , m_textColor(Color3::BLACK) , m_lineColor(Color3::BLACK) , m_lineWidth(1) @@ -33,6 +36,23 @@ namespace caf { m_sizeHint = size; } + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setMinimumWidth(unsigned int width) + { + m_minimumWidth = width; + m_actualWidth = std::max(m_minimumWidth, m_actualWidth); + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setWidth(unsigned int width) + { + m_actualWidth = width; + } + //-------------------------------------------------------------------------------------------------- /// Set color of the text //-------------------------------------------------------------------------------------------------- @@ -107,6 +127,22 @@ namespace caf { return m_sizeHint; } + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + unsigned int TitledOverlayFrame::minimumWidth() + { + return m_minimumWidth; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + unsigned int TitledOverlayFrame::width() + { + return m_actualWidth; + } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 384aff7c8e..8c211253f8 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -22,6 +22,8 @@ namespace caf { virtual ~TitledOverlayFrame(); virtual void setSizeHint(const cvf::Vec2ui& size); + void setMinimumWidth(unsigned int width); + void setWidth(unsigned int width); void setTextColor(const cvf::Color3f& color); void setLineColor(const cvf::Color3f& lineColor); @@ -33,8 +35,12 @@ namespace caf { void setBackgroundColor(const cvf::Color4f& backgroundColor); void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); - virtual cvf::Vec2ui sizeHint() override; + virtual void computeLayoutAndExtents() = 0; + virtual cvf::Vec2ui sizeHint() override; + unsigned int minimumWidth(); + unsigned int width(); + protected: cvf::Color3f textColor() const; cvf::Color3f lineColor() const; @@ -48,6 +54,9 @@ namespace caf { private: cvf::Vec2ui m_sizeHint; // The desired pixel size of the color legend area + unsigned int m_minimumWidth; + unsigned int m_actualWidth; + cvf::Color3f m_textColor; cvf::Color3f m_lineColor; int m_lineWidth; From e93f79790e7a0880e5db0f10c5bf05b810442886 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 6 Apr 2018 14:35:00 +0200 Subject: [PATCH 0638/1027] Make sure Ternary legends also expand and renamed width method. --- .../RivTernarySaturationOverlayItem.cpp | 23 +++++++++++-------- ApplicationCode/UserInterface/RiuViewer.cpp | 2 +- .../cafVizExtensions/cafCategoryLegend.cpp | 2 +- .../cafOverlayScalarMapperLegend.cpp | 2 +- .../cafTitledOverlayFrame.cpp | 12 +++++----- .../cafVizExtensions/cafTitledOverlayFrame.h | 8 +++---- 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 78695e899e..6cf2ecec42 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -91,18 +91,21 @@ void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglCont //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, - const cvf::Vec2ui& size, + const cvf::Vec2ui& sizeHint, bool software) { - if (size.x() <= 0 || size.y() <= 0) + if (sizeHint.x() <= 0 || sizeHint.y() <= 0) { return; } float border = 0.0f; + cvf::Vec2ui sizeMatched = sizeHint; + sizeMatched.x() = this->matchedWidth(); // Match to other legends + cvf::Camera camera; - camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setViewport(position.x(), position.y(), sizeMatched.x(), sizeMatched.y()); camera.setProjectionAsPixelExact2D(); camera.setViewMatrix(cvf::Mat4d::IDENTITY); camera.applyOpenGL(); @@ -113,7 +116,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte if ( software ) { caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, - cvf::Vec2f(size), + cvf::Vec2f(sizeMatched), this->backgroundColor(), this->backgroundFrameColor()); } @@ -123,7 +126,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, - cvf::Vec2f(size), + cvf::Vec2f(sizeMatched), this->backgroundColor(), this->backgroundFrameColor()); } @@ -135,7 +138,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2); - float textPosY = static_cast(size.y() - lineHeightInPixels - border); + float textPosY = static_cast(sizeMatched.y() - lineHeightInPixels - border); for (size_t it = 0; it < this->titleStrings().size(); it++) { cvf::Vec2f pos(border, textPosY); @@ -151,11 +154,11 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte { cvf::uint sgasTextWidth = this->font()->textExtent("SGAS").x(); - textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (size.x() / 2) - sgasTextWidth / 2 ), textPosY)); + textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (sizeMatched.x() / 2) - sgasTextWidth / 2 ), textPosY)); cvf::uint sgasRangeTextWidth = this->font()->textExtent(m_sgasRange).x(); textPosY -= lineHeightInPixels; - textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); + textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (sizeMatched.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); } textDrawer.addText("SWAT", cvf::Vec2f((float)border, (float)(lineHeightInPixels + border))); @@ -163,10 +166,10 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte { cvf::uint soilTextWidth = this->font()->textExtent("SOIL").x(); - textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth - border), lineHeightInPixels + border)); + textDrawer.addText("SOIL", cvf::Vec2f(static_cast(sizeMatched.x() - soilTextWidth - border), lineHeightInPixels + border)); cvf::uint soilRangeTextWidth = this->font()->textExtent(m_soilRange).x(); - float soilRangePos = static_cast(size.x()) - soilRangeTextWidth - border; + float soilRangePos = static_cast(sizeMatched.x()) - soilRangeTextWidth - border; textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border)); } diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 4bc5008681..bbb8b9a85e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -623,7 +623,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend for (auto legend : m_visibleLegends) { - legend->setWidth(requiredLegendWidth); + legend->setMatchedWidth(requiredLegendWidth); } } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 58e9797481..9297c6061e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -131,7 +131,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, this->computeLayoutAndExtents(); - Vec2f backgroundSize(CVF_MIN((float) this->width(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN((float) this->matchedWidth(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 0abf0c9b79..0753dfcf55 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -188,7 +188,7 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V this->computeLayoutAndExtents(); - Vec2f backgroundSize(CVF_MIN((float)this->width(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN((float)this->matchedWidth(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp index 10f35d6832..14ce1943bd 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -37,20 +37,20 @@ namespace caf { } //-------------------------------------------------------------------------------------------------- - /// + /// Will also update the matched width since this should always be >= minimum width //-------------------------------------------------------------------------------------------------- void TitledOverlayFrame::setMinimumWidth(unsigned int width) { m_minimumWidth = width; - m_actualWidth = std::max(m_minimumWidth, m_actualWidth); + m_matchedWidth = std::max(m_minimumWidth, m_matchedWidth); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - void TitledOverlayFrame::setWidth(unsigned int width) + void TitledOverlayFrame::setMatchedWidth(unsigned int width) { - m_actualWidth = width; + m_matchedWidth = width; } //-------------------------------------------------------------------------------------------------- @@ -138,9 +138,9 @@ namespace caf { //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - unsigned int TitledOverlayFrame::width() + unsigned int TitledOverlayFrame::matchedWidth() { - return m_actualWidth; + return m_matchedWidth; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 8c211253f8..6ca71a7722 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -23,7 +23,7 @@ namespace caf { virtual void setSizeHint(const cvf::Vec2ui& size); void setMinimumWidth(unsigned int width); - void setWidth(unsigned int width); + void setMatchedWidth(unsigned int width); void setTextColor(const cvf::Color3f& color); void setLineColor(const cvf::Color3f& lineColor); @@ -39,7 +39,7 @@ namespace caf { virtual cvf::Vec2ui sizeHint() override; unsigned int minimumWidth(); - unsigned int width(); + unsigned int matchedWidth(); protected: cvf::Color3f textColor() const; @@ -54,8 +54,8 @@ namespace caf { private: cvf::Vec2ui m_sizeHint; // The desired pixel size of the color legend area - unsigned int m_minimumWidth; - unsigned int m_actualWidth; + unsigned int m_minimumWidth; // Minimum width required to fit content + unsigned int m_matchedWidth; // Width matched to other legends (>= minimumWidth) cvf::Color3f m_textColor; cvf::Color3f m_lineColor; From fe56375be6a6bbea0dd01a55cbfa622d14aeaa04 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 6 Apr 2018 15:30:51 +0200 Subject: [PATCH 0639/1027] Added toggle option for legends. --- .../ProjectDataModel/RimEclipseView.cpp | 70 ++++++++++--------- .../ProjectDataModel/RimLegendConfig.cpp | 6 ++ .../ProjectDataModel/RimLegendConfig.h | 5 +- .../RimTernaryLegendConfig.cpp | 6 +- .../ProjectDataModel/RimTernaryLegendConfig.h | 4 ++ 5 files changed, 55 insertions(+), 36 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 49ec05442c..8e7049e5c2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1055,47 +1055,50 @@ void RimEclipseView::updateLegends() updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); } - if (this->cellEdgeResult()->hasResult()) + if (this->cellEdgeResult()->legendConfig()->enableLegend()) { - if (this->cellEdgeResult()->isUsingSingleVariable()) + if (this->cellEdgeResult()->hasResult()) { - this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep); - } - else - { - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax); - this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero); + if (this->cellEdgeResult()->isUsingSingleVariable()) + { + this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep); + } + else + { + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax); + this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero); - this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero); - this->cellEdgeResult()->legendConfig()->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax); + this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero); + this->cellEdgeResult()->legendConfig()->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax); - if (this->cellEdgeResult()->hasCategoryResult()) - { - if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES) - { - cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex())); - } - else + if (this->cellEdgeResult()->hasCategoryResult()) { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector); + if (cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES) + { + cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex())); + } + else + { + const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); + cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector); + } } } - } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor()); - this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); - } - else - { - this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0); - this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor()); + this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); + } + else + { + this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0); + this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); + } } RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); - if (stimPlanLegend) + if (stimPlanLegend && stimPlanLegend->enableLegend()) { fractureColors()->updateLegendData(); @@ -1105,12 +1108,11 @@ void RimEclipseView::updateLegends() } } - if (m_virtualPerforationResult->isActive()) + if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend()) { updateVirtualConnectionLegendRanges(); RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); - m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor()); } } @@ -1124,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, { resultColors->updateLegendData(m_currentTimeStep); - if (resultColors->hasResult()) + if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend()) { m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); @@ -1133,7 +1135,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - if (resultColors->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor()); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 819cc1c8eb..30a0a39e3a 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -123,6 +123,7 @@ RimLegendConfig::RimLegendConfig() m_isAllTimeStepsRangeDisabled(false) { CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); + CAF_PDM_InitField(&enableLegend, "EnableLegend", true, "Enable Legend", "", "", ""); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); @@ -465,6 +466,11 @@ void RimLegendConfig::initAfterRead() updateFieldVisibility(); } +caf::PdmFieldHandle* RimLegendConfig::objectToggleField() +{ + return &enableLegend; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index fb591bbc5c..2b9471e07e 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -120,11 +120,14 @@ class RimLegendConfig: public caf::PdmObject void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } - caf::TitledOverlayFrame* legend(); + caf::TitledOverlayFrame* legend(); + + caf::PdmField enableLegend; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void initAfterRead(); + virtual caf::PdmFieldHandle* objectToggleField(); friend class RimStimPlanLegendConfig; virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index f79dab9d00..b6311b960a 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -57,7 +57,7 @@ namespace caf { RimTernaryLegendConfig::RimTernaryLegendConfig() { CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", ""); - + CAF_PDM_InitField(&enableLegend, "EnableTernaryLegend", true, "Enable Ternary Legend", "", "", ""); CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", ""); @@ -491,3 +491,7 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const return m_scalarMapper.p(); } +caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() +{ + return &enableLegend; +} diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index de4bf7bb06..804c61328e 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -73,6 +73,9 @@ class RimTernaryLegendConfig : public caf::PdmObject const RivTernarySaturationOverlayItem* legend() const; RivTernarySaturationOverlayItem* legend(); + + caf::PdmField enableLegend; + void setTitle(const QString& title); const RivTernaryScalarMapper* scalarMapper() const; @@ -81,6 +84,7 @@ class RimTernaryLegendConfig : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + virtual caf::PdmFieldHandle* objectToggleField(); private: void updateLegend(); From b6fb60115ab8edf025ed6bc165a19982d7c084da Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 9 Apr 2018 11:51:30 +0200 Subject: [PATCH 0640/1027] Refactored after review --- .../RivTernarySaturationOverlayItem.cpp | 30 +++++++++---------- .../RivTernarySaturationOverlayItem.h | 2 +- .../Rim2dIntersectionView.cpp | 2 +- .../ProjectDataModel/Rim2dIntersectionView.h | 2 +- .../ProjectDataModel/Rim3dView.cpp | 1 + ApplicationCode/ProjectDataModel/Rim3dView.h | 3 +- .../ProjectDataModel/RimEclipseView.cpp | 25 +++++----------- .../ProjectDataModel/RimEclipseView.h | 3 +- .../ProjectDataModel/RimGeoMechView.cpp | 14 ++++----- .../ProjectDataModel/RimGeoMechView.h | 2 +- .../ProjectDataModel/RimLegendConfig.cpp | 2 +- ApplicationCode/UserInterface/RiuViewer.cpp | 19 +++++++----- ApplicationCode/UserInterface/RiuViewer.h | 2 +- .../cafVizExtensions/cafCategoryLegend.cpp | 5 ++-- .../cafVizExtensions/cafCategoryLegend.h | 2 +- .../cafOverlayScalarMapperLegend.cpp | 11 ++++--- .../cafOverlayScalarMapperLegend.h | 2 +- .../cafVizExtensions/cafTitledOverlayFrame.h | 2 +- 18 files changed, 62 insertions(+), 67 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 6cf2ecec42..2150a35556 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -43,7 +43,7 @@ RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) : TitledOverlayFrame(font, 120, 150) { - this->computeLayoutAndExtents(); + this->computeLayoutAndExtents(cvf::Vec2i(0, 0), this->sizeHint()); } //-------------------------------------------------------------------------------------------------- @@ -57,9 +57,9 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::computeLayoutAndExtents() +void RivTernarySaturationOverlayItem::computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) { - this->setMinimumWidth(this->sizeHint().x()); + this->setMinimumWidth(size.x()); } //-------------------------------------------------------------------------------------------------- @@ -91,21 +91,21 @@ void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglCont //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, - const cvf::Vec2ui& sizeHint, + const cvf::Vec2ui& size, bool software) { - if (sizeHint.x() <= 0 || sizeHint.y() <= 0) + if (size.x() <= 0 || size.y() <= 0) { return; } float border = 0.0f; - cvf::Vec2ui sizeMatched = sizeHint; - sizeMatched.x() = this->matchedWidth(); // Match to other legends + cvf::Vec2ui sizeFrameBox = size; + sizeFrameBox.x() = this->matchedWidth(); // Match to other legends cvf::Camera camera; - camera.setViewport(position.x(), position.y(), sizeMatched.x(), sizeMatched.y()); + camera.setViewport(position.x(), position.y(), sizeFrameBox.x(), sizeFrameBox.y()); camera.setProjectionAsPixelExact2D(); camera.setViewMatrix(cvf::Mat4d::IDENTITY); camera.applyOpenGL(); @@ -116,7 +116,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte if ( software ) { caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, - cvf::Vec2f(sizeMatched), + cvf::Vec2f(sizeFrameBox), this->backgroundColor(), this->backgroundFrameColor()); } @@ -126,7 +126,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, - cvf::Vec2f(sizeMatched), + cvf::Vec2f(sizeFrameBox), this->backgroundColor(), this->backgroundFrameColor()); } @@ -138,7 +138,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2); - float textPosY = static_cast(sizeMatched.y() - lineHeightInPixels - border); + float textPosY = static_cast(size.y() - lineHeightInPixels - border); for (size_t it = 0; it < this->titleStrings().size(); it++) { cvf::Vec2f pos(border, textPosY); @@ -154,11 +154,11 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte { cvf::uint sgasTextWidth = this->font()->textExtent("SGAS").x(); - textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (sizeMatched.x() / 2) - sgasTextWidth / 2 ), textPosY)); + textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (size.x() / 2) - sgasTextWidth / 2 ), textPosY)); cvf::uint sgasRangeTextWidth = this->font()->textExtent(m_sgasRange).x(); textPosY -= lineHeightInPixels; - textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (sizeMatched.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); + textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); } textDrawer.addText("SWAT", cvf::Vec2f((float)border, (float)(lineHeightInPixels + border))); @@ -166,10 +166,10 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte { cvf::uint soilTextWidth = this->font()->textExtent("SOIL").x(); - textDrawer.addText("SOIL", cvf::Vec2f(static_cast(sizeMatched.x() - soilTextWidth - border), lineHeightInPixels + border)); + textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth - border), lineHeightInPixels + border)); cvf::uint soilRangeTextWidth = this->font()->textExtent(m_soilRange).x(); - float soilRangePos = static_cast(sizeMatched.x()) - soilRangeTextWidth - border; + float soilRangePos = static_cast(size.x()) - soilRangeTextWidth - border; textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border)); } diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index 34ee1d58ac..ee7f77603d 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -41,7 +41,7 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); ~RivTernarySaturationOverlayItem(); - virtual void computeLayoutAndExtents() override; + virtual void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 0aac11a9d6..cea81d063c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -603,7 +603,7 @@ void Rim2dIntersectionView::updateLegends() if ( legend ) { - m_viewer->addColorLegendToBottomLeftCorner(legend, this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(legend); } } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 9fa49ac01d..7828702e36 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -69,7 +69,7 @@ class Rim2dIntersectionView : public Rim3dView bool showDefiningPoints() const; protected: - void updateLegends(); + void updateLegends() override; virtual bool isGridVisualizationMode() const override; virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index eba20674cc..95020e7c7d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -736,6 +736,7 @@ void Rim3dView::applyBackgroundColor() } updateGridBoxData(); updateAnnotationItems(); + updateLegends(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 6656072d03..8eca749991 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -132,6 +132,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void createHighlightAndGridBoxDisplayModelWithRedraw(); void updateGridBoxData(); void updateAnnotationItems(); + virtual void updateLegends() = 0; bool isMasterView() const; @@ -157,7 +158,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface // Implementation of RiuViewerToViewInterface virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor(); } - virtual void applyBackgroundColor(); + void applyBackgroundColor(); // Abstract methods to implement in subclasses diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 8e7049e5c2..9e5ff47280 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1087,7 +1087,7 @@ void RimEclipseView::updateLegends() } } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); } else @@ -1104,7 +1104,7 @@ void RimEclipseView::updateLegends() if (fractureColors()->isChecked() && stimPlanLegend->legend()) { - m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend(), this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); } } @@ -1113,7 +1113,7 @@ void RimEclipseView::updateLegends() updateVirtualConnectionLegendRanges(); RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); - m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend(), this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); } } @@ -1128,7 +1128,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend(), this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); } @@ -1138,7 +1138,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend(), this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); } } } @@ -1598,12 +1598,10 @@ void RimEclipseView::resetLegendsInViewer() if (cellResultNormalLegendConfig) { - m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend(), - this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend()); } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend(), - this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); } //-------------------------------------------------------------------------------------------------- @@ -1739,15 +1737,6 @@ bool RimEclipseView::showActiveCellsOnly() return !m_showInactiveCells; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseView::applyBackgroundColor() -{ - Rim3dView::applyBackgroundColor(); - this->updateLegends(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 6b8b971a2b..deb25aefdb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -147,7 +147,6 @@ class RimEclipseView : public RimGridView virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; virtual bool showActiveCellsOnly() override; - virtual void applyBackgroundColor() override; private: void createDisplayModel() override; @@ -160,7 +159,7 @@ class RimEclipseView : public RimGridView virtual void updateStaticCellColors() override; void updateStaticCellColors(RivCellSetEnum geometryType); - void updateLegends(); + void updateLegends() override; void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData); virtual void resetLegendsInViewer() override; void updateVirtualConnectionLegendRanges(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 45bc143e8d..bfedd4a30d 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -364,8 +364,7 @@ void RimGeoMechView::resetLegendsInViewer() this->cellResult()->legendConfig->recreateLegend(); m_viewer->removeAllColorLegends(); - m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend(), - this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); } //-------------------------------------------------------------------------------------------------- @@ -379,18 +378,19 @@ void RimGeoMechView::updateLegends() this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); - if (cellResult()->hasResult()) + if (cellResult()->hasResult() && cellResult()->legendConfig()->enableLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend(), - this->backgroundColor()); + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { - m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend(), - this->backgroundColor()); + if (tensorResults()->arrowColorLegendConfig()->enableLegend()) + { + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index dabe3913fb..cfcc3bae4a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -110,7 +110,7 @@ class RimGeoMechView : public RimGridView virtual void resetLegendsInViewer() override; - void updateLegends(); + void updateLegends() override; void updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 30a0a39e3a..30f8b01046 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -371,7 +371,7 @@ void RimLegendConfig::updateLegend() numDecimalDigits -= static_cast(decadesInRange); } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); - m_scalarMapperLegend->computeLayoutAndExtents(); + m_scalarMapperLegend->computeLayoutAndExtents(cvf::Vec2i(0, 0), m_scalarMapperLegend->sizeHint()); RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index bbb8b9a85e..10ca6fb5d3 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -432,7 +432,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) painter->drawLine(centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y()); } } - } + } } //-------------------------------------------------------------------------------------------------- @@ -536,7 +536,7 @@ void RiuViewer::removeAllColorLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend, const cvf::Color3f& backgroundColor) +void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend) { RiaApplication* app = RiaApplication::instance(); CVF_ASSERT(app); @@ -547,12 +547,16 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend if (legend) { + cvf::Color4f backgroundColor = mainCamera()->viewport()->clearColor(); + backgroundColor.a() = 0.8f; + cvf::Color3f frameColor(backgroundColor.r(), backgroundColor.g(), backgroundColor.b()); updateLegendTextAndTickMarkColor(legend); - + firstRendering->addOverlayItem(legend); legend->enableBackground(preferences->showLegendBackground()); - legend->setBackgroundColor(cvf::Color4f(backgroundColor, 0.8f)); - legend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(backgroundColor, 0.3f), 0.9f)); + legend->setBackgroundColor(backgroundColor); + legend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(frameColor, 0.3f), 0.9f)); + m_visibleLegends.push_back(legend); } @@ -616,12 +620,13 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend } unsigned int requiredLegendWidth = 0u; - for (auto legend : m_visibleLegends) + for (auto legend : overlayItems) { + legend->computeLayoutAndExtents(cvf::Vec2i(0, 0), legend->sizeHint()); requiredLegendWidth = std::max(requiredLegendWidth, legend->minimumWidth()); } - for (auto legend : m_visibleLegends) + for (auto legend : overlayItems) { legend->setMatchedWidth(requiredLegendWidth); } diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 1f33413ed4..8c3266d80e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -96,7 +96,7 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void showAnimationProgress(bool enable); void removeAllColorLegends(); - void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend, const cvf::Color3f& backgroundColor); + void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend); void enableNavigationRotation(bool disable); void updateNavigationPolicy(); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 9297c6061e..e18dd5e5ff 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -129,7 +129,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - this->computeLayoutAndExtents(); + this->computeLayoutAndExtents(position, size); Vec2f backgroundSize(CVF_MIN((float) this->matchedWidth(), (float)size.x()), (float)size.y()); @@ -494,9 +494,10 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CategoryLegend::computeLayoutAndExtents() +void CategoryLegend::computeLayoutAndExtents(const Vec2i& position, const Vec2ui& size) { // Todo: Cache this between renderings. Update only when needed. + m_Layout = OverlayColorLegendLayoutInfo(position, size); layoutInfo(&m_Layout); m_textDrawer = new TextDrawer(this->font()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index a78eb9d726..bb9ddcc393 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -31,7 +31,7 @@ class CategoryLegend : public caf::TitledOverlayFrame virtual ~CategoryLegend(); size_t categoryCount() const; - void computeLayoutAndExtents() override; + void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; protected: void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 0753dfcf55..3a25a58c8f 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -183,12 +183,9 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - m_Layout.position = position; - m_Layout.size = size; - - this->computeLayoutAndExtents(); + this->computeLayoutAndExtents(position, size); - Vec2f backgroundSize(CVF_MIN((float)this->matchedWidth(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(this->matchedWidth(), (float)size.y()); // Do the actual rendering if (software) @@ -665,8 +662,10 @@ void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::computeLayoutAndExtents() +void OverlayScalarMapperLegend::computeLayoutAndExtents(const Vec2i& position, const Vec2ui& size) { + // Todo: Cache this between renderings. Update only when needed. + //m_Layout = OverlayColorLegendLayoutInfo(position, size); layoutInfo(&m_Layout); m_textDrawer = new TextDrawer(this->font()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index 6a2c2fffd0..db22015825 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -85,7 +85,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame void setTickPrecision(int precision); enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); - void computeLayoutAndExtents() override; + void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; protected: void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 6ca71a7722..76fb30370f 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -35,7 +35,7 @@ namespace caf { void setBackgroundColor(const cvf::Color4f& backgroundColor); void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); - virtual void computeLayoutAndExtents() = 0; + virtual void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) = 0; virtual cvf::Vec2ui sizeHint() override; unsigned int minimumWidth(); From 3116a4a2235044ee18cfabb4798785ed7a2d6bbd Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 9 Apr 2018 13:13:20 +0200 Subject: [PATCH 0641/1027] Shifted pure virtual updateLegends to RiuViewerToViewInterface --- ApplicationCode/ProjectDataModel/Rim3dView.h | 3 +-- ApplicationCode/UserInterface/RiuViewerToViewInterface.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 8eca749991..e42532d508 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -131,8 +131,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface void createDisplayModelAndRedraw(); void createHighlightAndGridBoxDisplayModelWithRedraw(); void updateGridBoxData(); - void updateAnnotationItems(); - virtual void updateLegends() = 0; + void updateAnnotationItems(); bool isMasterView() const; diff --git a/ApplicationCode/UserInterface/RiuViewerToViewInterface.h b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h index fd71685bb2..a8980bc76b 100644 --- a/ApplicationCode/UserInterface/RiuViewerToViewInterface.h +++ b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h @@ -60,5 +60,7 @@ class RiuViewerToViewInterface virtual void setCurrentTimeStepAndUpdate(int frameIndex) = 0; virtual void updateCurrentTimeStepAndRedraw() = 0; + virtual void updateLegends() = 0; + virtual void endAnimation() = 0; }; From ee9e9b2989c9095bb4e1e78d9dd8f4540adc2a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 9 Apr 2018 13:21:48 +0200 Subject: [PATCH 0642/1027] #2685 Origin summary. Split preferences settings into two fields --- .../Application/RiaPreferences.cpp | 8 +++---- ApplicationCode/Application/RiaPreferences.h | 5 +++-- .../Commands/RicSummaryCaseRestartDialog.cpp | 16 +++++++++----- .../Commands/RicSummaryCaseRestartDialog.h | 5 +++-- .../RifSummaryCaseRestartSelector.cpp | 22 ++++++++++++++----- .../RifSummaryCaseRestartSelector.h | 3 ++- 6 files changed, 40 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 8af6ccbdf8..3ef407d7d0 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -32,11 +32,10 @@ namespace caf template<> void RiaPreferences::SummaryRestartFilesImportModeType::setUp() { - addItem(RiaPreferences::ASK_USER, "ASK_USER", "Ask user"); addItem(RiaPreferences::IMPORT, "IMPORT", "Always import"); addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Never import"); addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Import as separate summary cases"); - setDefault(RiaPreferences::ASK_USER); + setDefault(RiaPreferences::IMPORT); } } @@ -102,8 +101,8 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL", "", "", ""); loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - CAF_PDM_InitFieldNoDefault(&summaryRestartFilesImportMode, "summaryRestartFilesImportMode", "Import summary restart files", "", "", ""); - //loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&summaryRestartFilesShowImportDialog, "summaryRestartFilesShowImportDialog", "Show Import Dialog", "", "", ""); + CAF_PDM_InitFieldNoDefault(&summaryRestartFilesImportMode, "summaryRestartFilesImportMode", "Default Import Mode", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; @@ -194,6 +193,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& m_readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup); caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Summary Restart Files"); + restartBehaviourGroup->add(&summaryRestartFilesShowImportDialog); restartBehaviourGroup->add(&summaryRestartFilesImportMode); } else if (uiConfigName == m_tabNames[2]) diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 03dca2b6d8..0de4885fe8 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -37,7 +37,7 @@ class RiaPreferences : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - enum SummaryRestartFilesImportMode { ASK_USER, IMPORT, NOT_IMPORT, SEPARATE_CASES }; + enum SummaryRestartFilesImportMode { IMPORT, NOT_IMPORT, SEPARATE_CASES }; typedef caf::AppEnum SummaryRestartFilesImportModeType; RiaPreferences(void); @@ -80,7 +80,8 @@ class RiaPreferences : public caf::PdmObject caf::PdmField autocomputeDepthRelatedProperties; caf::PdmField loadAndShowSoil; - caf::PdmField summaryRestartFilesImportMode; + caf::PdmField summaryRestartFilesShowImportDialog; + caf::PdmField summaryRestartFilesImportMode; protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 0e98159131..326728a6a6 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -126,6 +126,7 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + ReadOptions defaultReadOption, RicSummaryCaseRestartDialogResult *lastResult, QWidget *parent) { @@ -148,7 +149,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If no restart files are found, do not show dialog if (fileInfos.empty()) { - return RicSummaryCaseRestartDialogResult(true, READ_SINGLE, QStringList({ summaryHeaderFile }), false); + return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, QStringList({ summaryHeaderFile }), false); } RicSummaryCaseRestartDialogResult dialogResult; @@ -160,7 +161,12 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const else { dialog.setWindowTitle("Summary Case Restart Files"); - dialog.m_readAllRadioButton->setChecked(true); + switch (defaultReadOption) + { + case ReadOptions::IMPORT_ALL: dialog.m_readAllRadioButton->setChecked(true); break; + case ReadOptions::NOT_IMPORT: dialog.m_notReadRadionButton->setChecked(true); break; + case ReadOptions::SEPARATE_CASES: dialog.m_separateCasesRadionButton->setChecked(true); break; + } dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -173,7 +179,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const if (!dialogResult.ok) { - return RicSummaryCaseRestartDialogResult(false, READ_SINGLE, QStringList(), false); + return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, QStringList(), false); } dialogResult.files.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); @@ -193,9 +199,9 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const RicSummaryCaseRestartDialog::ReadOptions RicSummaryCaseRestartDialog::selectedOption() const { return - m_readAllRadioButton->isChecked() ? READ_ALL : + m_readAllRadioButton->isChecked() ? IMPORT_ALL : m_separateCasesRadionButton->isChecked() ? SEPARATE_CASES : - READ_SINGLE; + NOT_IMPORT; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 084214ce0b..d480da0539 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -46,13 +46,14 @@ class RicSummaryCaseRestartDialog : public QDialog Q_OBJECT public: - enum ReadOptions { READ_SINGLE, READ_ALL, SEPARATE_CASES }; + enum ReadOptions { NOT_IMPORT, IMPORT_ALL, SEPARATE_CASES }; RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + ReadOptions defaultReadOption, RicSummaryCaseRestartDialogResult *lastResult = nullptr, QWidget *parent = nullptr); @@ -89,7 +90,7 @@ class RicSummaryCaseRestartDialogResult { public: RicSummaryCaseRestartDialogResult() : - ok(false), option(RicSummaryCaseRestartDialog::READ_ALL), applyToAll(false) {} + ok(false), option(RicSummaryCaseRestartDialog::IMPORT_ALL), applyToAll(false) {} RicSummaryCaseRestartDialogResult(bool _ok, RicSummaryCaseRestartDialog::ReadOptions _option, diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index e3eb6d352c..ef471b6706 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -46,6 +46,17 @@ bool vectorContains(const std::vector& vector, T item) return false; } +//-------------------------------------------------------------------------------------------------- +/// INternal function +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::ReadOptions mapReadOption(RiaPreferences::SummaryRestartFilesImportMode mode) +{ + return + mode == RiaPreferences::SummaryRestartFilesImportMode::NOT_IMPORT ? RicSummaryCaseRestartDialog::ReadOptions::NOT_IMPORT : + mode == RiaPreferences::SummaryRestartFilesImportMode::SEPARATE_CASES ? RicSummaryCaseRestartDialog::ReadOptions::SEPARATE_CASES : + RicSummaryCaseRestartDialog::ReadOptions::IMPORT_ALL; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -71,10 +82,10 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp RiaPreferences* prefs = app->preferences(); std::vector fileInfos; - if (prefs->summaryRestartFilesImportMode == RiaPreferences::ASK_USER) + if (prefs->summaryRestartFilesShowImportDialog) { bool enableApplyToAllField = selectedFiles.size() > 1; - fileInfos = getFilesToImportByAskingUser(selectedFiles, enableApplyToAllField); + fileInfos = getFilesToImportByAskingUser(selectedFiles, enableApplyToAllField, prefs->summaryRestartFilesImportMode); } else { @@ -88,19 +99,20 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp /// //-------------------------------------------------------------------------------------------------- std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialFiles, - bool enableApplyToAllField) + bool enableApplyToAllField, + RiaPreferences::SummaryRestartFilesImportModeType defaultSummaryRestartMode) { std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; for (const QString& file : initialFiles) { - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField, &lastResult); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField, mapReadOption(defaultSummaryRestartMode), &lastResult); if (result.ok) { for (const QString& file : result.files) { - RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::READ_ALL); + RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::IMPORT_ALL); if (!vectorContains(filesToImport, fi)) { filesToImport.push_back(fi); diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index e6dcb56d8f..3c9c4d65e0 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -43,7 +43,8 @@ class RifSummaryCaseRestartSelector private: std::vector getFilesToImportByAskingUser(const QStringList& initialFiles, - bool enableApplyToAllField); + bool enableApplyToAllField, + RiaPreferences::SummaryRestartFilesImportModeType defaultSummaryRestartMode); std::vector getFilesToImportUsingPrefs(const QStringList& initialFiles, RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode); From fee549de35a6da8f4e56af88c97596ac795b2b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 9 Apr 2018 12:51:44 +0200 Subject: [PATCH 0643/1027] Adjust an argument order in RigWellPathGeometryTools --- .../ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp | 2 +- .../ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp | 2 +- .../ReservoirDataModel/RigWellPathGeometryTools.cpp | 4 +++- ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index bdd3ed159b..31e59abfe0 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -133,7 +133,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std resultValues.end()); std::vector pairsOfWellPathPoints; - RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), &pairsOfWellPathPoints, interpolatedWellPathPoints); + RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), interpolatedWellPathPoints, &pairsOfWellPathPoints); std::vector pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, pairsOfWellPathPoints, RigWellPathGeometryTools::LINE_SEGMENTS); if (interpolatedWellPathPoints.size() != pointNormals.size()) return; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 2f7e23ae5b..4e8b030962 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -89,7 +89,7 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const c std::vector pointNormals; std::vector closestPoints; - RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), &closestPoints, gridPoints); + RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), gridPoints, &closestPoints); pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, closestPoints, RigWellPathGeometryTools::LINE_SEGMENTS); if (pointNormals.size() != gridPoints.size()) return nullptr; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index a3d9ded99e..c64e9ce57a 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -94,7 +94,9 @@ std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, std::vector* closestWellPathPoints, std::vector& points) +void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, + const std::vector& points, + std::vector* closestWellPathPoints) { CVF_ASSERT(closestWellPathPoints != nullptr); diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h index 2591ad8bd6..3c3f0b8f7d 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -44,6 +44,6 @@ class RigWellPathGeometryTools VertexOrganization organization); static void calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, - std::vector* closestWellPathPoints, - std::vector& points); + const std::vector& points, + std::vector* closestWellPathPoints); }; From b488d99f8175eb6f7bf3a389c6a06c76bffcc45c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 9 Apr 2018 14:19:43 +0200 Subject: [PATCH 0644/1027] #2696 Fix ubuntu build after Legend updates. * Was missing to get std::ceil, but cvf::Math also has ceil, so switch to that. --- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index e18dd5e5ff..fb3b311c07 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -505,7 +505,7 @@ void CategoryLegend::computeLayoutAndExtents(const Vec2i& position, const Vec2ui float maxLegendRightPos = 0; setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); - unsigned int contentWidth = static_cast(std::ceil(maxLegendRightPos + m_Layout.margins.x())); + unsigned int contentWidth = static_cast(cvf::Math::ceil(maxLegendRightPos + m_Layout.margins.x())); this->setMinimumWidth(contentWidth); } From ab736ab46bf9d5c4d1a6c6547c1bd05c8757e419 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 9 Apr 2018 14:30:21 +0200 Subject: [PATCH 0645/1027] #2693. Fix overlap of category legend with other legends. * CategoryLegend should not use the matchedWidth. They have their own columns. * Change shifts to using minimumWidth instead. --- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index fb3b311c07..6b28e94875 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -131,7 +131,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, this->computeLayoutAndExtents(position, size); - Vec2f backgroundSize(CVF_MIN((float) this->matchedWidth(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(CVF_MIN((float)this->minimumWidth(), (float)size.x()), (float)size.y()); // Do the actual rendering if (software) From dd38543dd2e76f2a93b287b82b119675caef9309 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 10 Apr 2018 08:31:03 +0200 Subject: [PATCH 0646/1027] Fix Ubuntu build (#2696) * std::ceil -> cvf::Math::ceil to avoid header issues. --- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 3a25a58c8f..c2a305c9ec 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -674,7 +674,7 @@ void OverlayScalarMapperLegend::computeLayoutAndExtents(const Vec2i& position, c float maxLegendRightPos = 0; setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); - unsigned int contentWidth = static_cast(std::ceil(maxLegendRightPos + m_Layout.margins.x())); + unsigned int contentWidth = static_cast(cvf::Math::ceil(maxLegendRightPos + m_Layout.margins.x())); this->setMinimumWidth(contentWidth); } From a73526f85b28b6458ae352c9ac3ecd5140f019c3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 10 Apr 2018 08:36:20 +0200 Subject: [PATCH 0647/1027] Remove compile warning for OverlayScalarMapperLegend * apply explicit unsigned int -> float cast. --- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index c2a305c9ec..d0967f0602 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -185,7 +185,7 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V this->computeLayoutAndExtents(position, size); - Vec2f backgroundSize(this->matchedWidth(), (float)size.y()); + Vec2f backgroundSize((float)this->matchedWidth(), (float)size.y()); // Do the actual rendering if (software) From 2cc93fb09d8c3f23d161d41e78fc5a54322b5a83 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 10 Apr 2018 10:57:04 +0200 Subject: [PATCH 0648/1027] 3D Well Log Curves: Command to Delete curve #2667 * Add delete command with explicit delete feature class. --- .../WellLogCommands/CMakeLists_files.cmake | 2 + .../Ric3dWellLogCurveDeleteFeature.cpp | 81 +++++++++++++++++++ .../Ric3dWellLogCurveDeleteFeature.h | 36 +++++++++ .../Rim3dWellLogCurveCollection.cpp | 28 +++++++ .../Completions/Rim3dWellLogCurveCollection.h | 3 +- .../RimContextCommandBuilder.cpp | 12 ++- 6 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp create mode 100644 ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 01adb66091..dd55b9252d 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -26,6 +26,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -55,6 +56,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp new file mode 100644 index 0000000000..866aceb212 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Ric3dWellLogCurveDeleteFeature.h" + +#include "RiaApplication.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RimProject.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(Ric3dWellLogCurveDeleteFeature, "Ric3dWellLogCurveDeleteFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Ric3dWellLogCurveDeleteFeature::isCommandEnabled() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() > 0) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::onActionTriggered(bool isChecked) +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 0) return; + + Rim3dWellLogCurve* firstCurve = objects[0]; + + Rim3dWellLogCurveCollection* curveCollection = nullptr; + firstCurve->firstAncestorOrThisOfType(curveCollection); + if (!curveCollection) return; + + for (Rim3dWellLogCurve* curve : objects) + { + curveCollection->remove3dWellLogCurve(curve); + delete curve; + } + curveCollection->redrawAffectedViewsAndEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Delete 3D Well Log Curve(s)"); + actionToSetup->setIcon(QIcon(":/Erase.png")); +} diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h new file mode 100644 index 0000000000..6dc5bb9cec --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class Ric3dWellLogCurveDeleteFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 4ad7277a5c..7f1379968e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -19,6 +19,7 @@ #include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogCurve.h" +#include "RimWellPath.h" #include "RimProject.h" CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); @@ -79,6 +80,14 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::remove3dWellLogCurve(Rim3dWellLogCurve* curve) +{ + m_3dWellLogCurves.removeChildObject(curve); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -117,6 +126,25 @@ std::vector Rim3dWellLogCurveCollection::vectorOf3dWellLogCu return curves; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + RimWellPath* path = nullptr; + this->firstAncestorOrThisOfType(path); + if (path) + { + path->updateConnectedEditors(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index cc518cbf1f..809ecec4ce 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -46,6 +46,7 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool has3dWellLogCurves() const; void add3dWellLogCurve(Rim3dWellLogCurve* curve); + void remove3dWellLogCurve(Rim3dWellLogCurve* curve); bool isShowingGrid() const; bool isShowingPlot() const; @@ -53,7 +54,7 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject PlanePosition planePosition() const; std::vector vectorOf3dWellLogCurves() const; - + void redrawAffectedViewsAndEditors(); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5ca56e055d..4fb9d19c7c 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -760,18 +760,22 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicDeleteSubItemsFeature"; } + // Special delete commands for specific features + // Placed here to fit context menu location of general delete feature if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellPathDeleteFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellPathDeleteFeature"; } + if (caf::CmdFeatureManager::instance()->getCommandFeature("Ric3dWellLogCurveDeleteFeature")->canFeatureBeExecuted()) + { + menuBuilder << "Separator"; + menuBuilder << "Ric3dWellLogCurveDeleteFeature"; + } + if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellLogFileCloseFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellLogFileCloseFeature"; } From 951e0f7aa0fb3bcdeee0b188b85fa5296b63edf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 10 Apr 2018 09:01:04 +0200 Subject: [PATCH 0649/1027] #2555 Detect restart file reference looping. Break out if loop is detected --- .../FileInterface/RifReaderEclipseSummary.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 2e8582c81b..0cb185ad14 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -22,6 +22,8 @@ #include "RifReaderEclipseOutput.h" #include "RifEclipseSummaryTools.h" +#include "RiaLogging.h" + #include #include @@ -144,7 +146,17 @@ std::vector RifReaderEclipseSummary::getRestartFiles(const Q currFile.fileName = headerFileName; while(!currFile.fileName.isEmpty()) { + QString prevFile = currFile.fileName; + currFile = getRestartFile(currFile.fileName); + + // Fix to stop potential infinite loop + if (currFile.fileName == prevFile) + { + RiaLogging::error("RifReaderEclipseSummary: Restart file reference loop detected"); + break; + } + if (!currFile.fileName.isEmpty()) restartFiles.push_back(currFile); } From d0905c518b7d4324ff059b3e7b2cd2553008640c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 10 Apr 2018 13:07:25 +0200 Subject: [PATCH 0650/1027] libecl. Local quick-fix to prevent crash under Windows when restart file is located in different directory --- ThirdParty/Ert/lib/util/util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 8b301cb4e1..0e1add9a91 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -2249,6 +2249,7 @@ int util_fmove( FILE * stream , long offset , long shift) { #ifdef HAVE_WINDOWS__ACCESS bool util_access(const char * entry, int mode) { + if (!entry) return -1; return (_access(entry, mode) == 0); } From 5cc3af4586aa4c87a012bda68003b0181233331d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 10 Apr 2018 13:10:55 +0200 Subject: [PATCH 0651/1027] #2555 Summary cases. Convert paths to have internal separators ('/') --- .../Commands/RicImportSummaryCaseFeature.cpp | 13 +++++++++++-- .../UserInterface/RiuRecentFileActionProvider.cpp | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index b4856b15b2..c71283f016 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaFilePathTools.h" #include "RicImportSummaryCasesFeature.h" @@ -55,9 +56,17 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); RiaPreferences* prefs = app->preferences(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); + QStringList fileNames_ = QFileDialog::getOpenFileNames(nullptr, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); - if (fileNames.isEmpty()) return; + if (fileNames_.isEmpty()) return; + + QStringList fileNames; + + // Convert to internal path separator + for (QString s : fileNames_) + { + fileNames.push_back(RiaFilePathTools::toInternalSeparator(s)); + } // Remember the path to next time app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath()); diff --git a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp index 8bdda78576..aa7b62cb1e 100644 --- a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp +++ b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp @@ -19,6 +19,7 @@ #include "RiuRecentFileActionProvider.h" #include "RiaApplication.h" +#include "RiaFilePathTools.h" #include #include @@ -122,7 +123,7 @@ void RiuRecentFileActionProvider::slotOpenRecentFile() QAction* action = qobject_cast(sender()); if (action) { - QString fileName = action->data().toString(); + QString fileName = RiaFilePathTools::toInternalSeparator(action->data().toString()); RiaApplication* app = RiaApplication::instance(); if (RiaApplication::hasValidProjectFileExtension(fileName)) From 3f429ccfd74fd34314782dbe03e8c1476153106d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 10 Apr 2018 13:11:41 +0200 Subject: [PATCH 0652/1027] #2555 Add canonicalPath method to improve path handling --- ApplicationCode/Application/Tools/RiaFilePathTools.cpp | 8 ++++++++ ApplicationCode/Application/Tools/RiaFilePathTools.h | 1 + ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp | 5 ++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp index d9f3604ab0..812097bc0c 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -86,3 +86,11 @@ bool RiaFilePathTools::equalPaths(const QString& path1, const QString& path2) appendSeparatorIfNo(p2); return p1 == p2; } + +//-------------------------------------------------------------------------------------------------- +/// Own canonicalPath method since the QDir::canonicalPath seems to not work +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::canonicalPath(const QString& path) +{ + return QDir(path).absolutePath(); +} diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.h b/ApplicationCode/Application/Tools/RiaFilePathTools.h index f5f10838cb..8a25b055b9 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.h +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.h @@ -36,4 +36,5 @@ class RiaFilePathTools static QString& appendSeparatorIfNo(QString& path); static QString relativePath(const QString& rootDir, const QString& dir); static bool equalPaths(const QString& path1, const QString& path2); + static QString canonicalPath(const QString& path); }; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 0cb185ad14..fa81fb5ab3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -38,7 +38,6 @@ #include "ert/ecl/ecl_kw_magic.h" #include "ert/ecl/ecl_kw.h" - std::vector getTimeSteps(ecl_sum_type* ecl_sum) { std::vector timeSteps; @@ -440,12 +439,12 @@ RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& header const ecl_smspec_type* smspec = ecl_sum ? ecl_sum_get_smspec(ecl_sum) : nullptr; const char* rstCase = smspec ? ecl_smspec_get_restart_case(smspec) : nullptr; - QString restartCase = rstCase? RiaStringEncodingTools::fromNativeEncoded(rstCase) : ""; + QString restartCase = rstCase? RiaFilePathTools::canonicalPath(RiaStringEncodingTools::fromNativeEncoded(rstCase)) : ""; closeEclSum(ecl_sum); if (!restartCase.isEmpty()) { - QString path = QFileInfo(headerFileName).dir().path(); + QString path = QFileInfo(restartCase).dir().path(); QString restartBase = QDir(restartCase).dirName(); char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0); From c784deae25d32485b52ee78290d75710563c66f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Apr 2018 15:35:10 +0200 Subject: [PATCH 0653/1027] #2437 Add fault-labels to 2d Intersection view --- .../RivIntersectionGeometryGenerator.cpp | 117 +++++++++++------- .../RivIntersectionGeometryGenerator.h | 5 + .../Intersections/RivIntersectionPartMgr.cpp | 93 ++++++++++++++ .../Intersections/RivIntersectionPartMgr.h | 9 +- 4 files changed, 177 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index e73e491060..b1ed7216d2 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -144,6 +144,60 @@ void RivIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline() } } + +class MeshLinesAccumulator +{ +public: + MeshLinesAccumulator(const RivIntersectionHexGridInterface* hexGrid) + : m_hexGrid(hexGrid) + {} + + std::vector cellBorderLineVxes; + std::vector faultCellBorderLineVxes; + std::map faultToHighestFaultMeshVxMap; + + void accumulateMeshLines(const std::vector& cellFaceForEachClippedTriangleEdge, + uint triVxIdx, + size_t globalCellIdx, + const cvf::Vec3d& p0, + const cvf::Vec3d& p1) + { + #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) + using FaceType = cvf::StructGridInterface::FaceType; + + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + { + const RigFault * fault = m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, + (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]); + if ( fault ) + { + cvf::Vec3d highestVx = p0.z() > p1.z() ? p0 : p1; + + auto itIsInsertedPair = faultToHighestFaultMeshVxMap.insert({fault, highestVx}); + if (!itIsInsertedPair.second) + { + if (itIsInsertedPair.first->second.z() < highestVx.z()) + { + itIsInsertedPair.first->second = highestVx; + } + } + + faultCellBorderLineVxes.emplace_back(p0); + faultCellBorderLineVxes.emplace_back(p1); + } + else + { + cellBorderLineVxes.emplace_back(p0); + cellBorderLineVxes.emplace_back(p1); + } + } + } + +private: + cvf::cref m_hexGrid; +}; + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -153,8 +207,9 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_extrusionDirection.normalize(); std::vector triangleVertices; - std::vector cellBorderLineVxes; - std::vector faultCellBorderLineVxes; + + MeshLinesAccumulator meshAcc(m_hexGrid.p()); + cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); @@ -303,6 +358,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() uint triVxIdx = tIdx*3; // Accumulate triangle vertices + cvf::Vec3d p0(clippedTriangleVxes[triVxIdx+0].vx); cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx); cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx); @@ -317,49 +373,12 @@ void RivIntersectionGeometryGenerator::calculateArrays() // Accumulate mesh lines - #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) - using FaceType = cvf::StructGridInterface::FaceType; - - if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) ) - { - if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]) ) - { - faultCellBorderLineVxes.emplace_back(p0); - faultCellBorderLineVxes.emplace_back(p1); - } - else - { - cellBorderLineVxes.emplace_back(p0); - cellBorderLineVxes.emplace_back(p1); - } - } - if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) - { - if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) - { - faultCellBorderLineVxes.emplace_back(p1); - faultCellBorderLineVxes.emplace_back(p2); - } - else - { - cellBorderLineVxes.emplace_back(p1); - cellBorderLineVxes.emplace_back(p2); - } - } - if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) - { - if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) - { - faultCellBorderLineVxes.emplace_back(p2); - faultCellBorderLineVxes.emplace_back(p0); - } - else - { - cellBorderLineVxes.emplace_back(p2); - cellBorderLineVxes.emplace_back(p0); - } - } + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 0, globalCellIdx, p0, p1); + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 1, globalCellIdx, p1, p2); + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 2, globalCellIdx, p2, p0); + + // Mapping to cell index m_triangleToCellIdxMap.push_back(globalCellIdx); @@ -389,9 +408,15 @@ void RivIntersectionGeometryGenerator::calculateArrays() lIdx = idxToNextP; } } + m_triangleVxes->assign(triangleVertices); - m_cellBorderLineVxes->assign(cellBorderLineVxes); - m_faultCellBorderLineVxes->assign(faultCellBorderLineVxes); + m_cellBorderLineVxes->assign(meshAcc.cellBorderLineVxes); + m_faultCellBorderLineVxes->assign(meshAcc.faultCellBorderLineVxes); + + for (const auto& it : meshAcc.faultToHighestFaultMeshVxMap) + { + m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } ); + } } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 6bc7363ce8..5c8a08fcea 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -29,6 +29,8 @@ #include +#include + class RigMainGrid; class RigActiveCellInfo; class RigResultAccessor; @@ -68,6 +70,8 @@ class RivIntersectionGeometryGenerator : public cvf::Object cvf::ref createPointsFromExtrusionLineDrawable(const std::vector& extrusionLine); const std::vector >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; } + const std::vector > & faultMeshLabelAndAnchorPositions() { return m_faultMeshLabelAndAnchorPositions; } + // Mapping between cells and geometry const std::vector& triangleToCellIndex() const; @@ -106,5 +110,6 @@ class RivIntersectionGeometryGenerator : public cvf::Object std::vector > m_flattenedOrOffsettedPolyLines; std::vector > m_segementTransformPrLinePoint; + std::vector > m_faultMeshLabelAndAnchorPositions; }; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 0b4e2307bd..d49e7fe5d6 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -59,9 +59,11 @@ #include "cafTensor3.h" #include "cvfDrawableGeo.h" +#include "cvfDrawableText.h" #include "cvfGeometryTools.h" #include "cvfModelBasicList.h" #include "cvfPart.h" +#include "cvfqtUtils.h" #include "cvfPrimitiveSetDirect.h" #include "cvfRenderState_FF.h" #include "cvfRenderStateDepth.h" @@ -582,9 +584,87 @@ void RivIntersectionPartMgr::generatePartGeometry() createExtrusionDirParts(useBufferObjects); + if (m_isFlattened) createFaultLabelParts(m_crossSectionGenerator->faultMeshLabelAndAnchorPositions()); + applySingleColorEffect(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionPartMgr::createFaultLabelParts(const std::vector >& labelAndAnchors) +{ + cvf::Font* font = RiaApplication::instance()->customFont(); + + std::vector lineVertices; + + cvf::ref drawableText = new cvf::DrawableText; + { + drawableText->setFont(font); + drawableText->setCheckPosVisible(false); + drawableText->setDrawBorder(false); + drawableText->setDrawBackground(false); + drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE); + cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor(); + drawableText->setTextColor(defWellLabelColor); + } + + cvf::BoundingBox bb = m_crossSectionFaces->boundingBox(); + double labelZOffset = bb.extent().z() / 10; + + for (const auto& labelAndAnchorPair : labelAndAnchors) + { + cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first); + cvf::Vec3f textCoord(labelAndAnchorPair.second); + + textCoord.z() += labelZOffset; + drawableText->addText(cvfString, textCoord); + + lineVertices.push_back(cvf::Vec3f(labelAndAnchorPair.second)); + lineVertices.push_back(textCoord); + } + + // Labels part + { + cvf::ref part = new cvf::Part; + part->setName("Fault mesh label : text "); + part->setDrawable(drawableText.p()); + + cvf::ref eff = new cvf::Effect; + + part->setEffect(eff.p()); + part->setPriority(RivPartPriority::PartType::Text); + part->updateBoundingBox(); + + m_faultMeshLabels = part; + } + + // Lines to labels part + { + cvf::ref vertices = new cvf::Vec3fArray; + vertices->assign(lineVertices); + cvf::ref geo = new cvf::DrawableGeo; + geo->setVertexArray(vertices.p()); + + cvf::ref primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES); + primSet->setStartIndex(0); + primSet->setIndexCount(vertices->size()); + geo->addPrimitiveSet(primSet.p()); + + cvf::ref part = new cvf::Part; + part->setName("Anchor lines for fault mesh labels"); + part->setDrawable(geo.p()); + + part->updateBoundingBox(); + + caf::MeshEffectGenerator gen(RiaApplication::instance()->preferences()->defaultFaultGridLineColors()); + cvf::ref eff = gen.generateCachedEffect(); + + part->setEffect(eff.p()); + m_faultMeshLabelLines = part; + } + +} //-------------------------------------------------------------------------------------------------- /// @@ -834,6 +914,19 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod m_crossSectionFaultGridLines->setTransform(scaleTransform); model->addPart(m_crossSectionFaultGridLines.p()); } + + if (m_faultMeshLabelLines.notNull()) + { + m_faultMeshLabelLines->setTransform(scaleTransform); + model->addPart(m_faultMeshLabelLines.p()); + } + + if (m_faultMeshLabels.notNull()) + { + m_faultMeshLabels->setTransform(scaleTransform); + model->addPart(m_faultMeshLabels.p()); + } + } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 4410ec3f6b..1e422ec737 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -28,7 +28,10 @@ #include "cafPdmPointer.h" +#include + #include +#include namespace cvf { @@ -110,6 +113,7 @@ class RivIntersectionPartMgr : public cvf::Object const cvf::ScalarMapper* mapper); private: void generatePartGeometry(); + void createFaultLabelParts(const std::vector >& labelAndAnchors); void createPolyLineParts(bool useBufferObjects); void createExtrusionDirParts(bool useBufferObjects); @@ -122,7 +126,10 @@ class RivIntersectionPartMgr : public cvf::Object cvf::ref m_crossSectionFaces; cvf::ref m_crossSectionGridLines; cvf::ref m_crossSectionFaultGridLines; - + cvf::ref m_faultMeshLabels; + cvf::ref m_faultMeshLabelLines; + + cvf::ref m_crossSectionFacesTextureCoords; cvf::ref m_highlightLineAlongPolyline; From 29a8158a18e5dc48f1850ff9b431203d7ec75e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Apr 2018 17:57:40 +0200 Subject: [PATCH 0654/1027] Upped to version 2018.01.01-dev.108 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 433acc85d3..bcdc08f54f 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".107") +set(RESINSIGHT_DEV_VERSION ".108") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 0bf6db50f977423211b2ea8ddcd41d0f5c34d802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 13 Apr 2018 11:30:01 +0200 Subject: [PATCH 0655/1027] Fix crash due to empty fault label parts --- .../Intersections/RivIntersectionPartMgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index d49e7fe5d6..40fc47bd23 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -594,6 +594,11 @@ void RivIntersectionPartMgr::generatePartGeometry() //-------------------------------------------------------------------------------------------------- void RivIntersectionPartMgr::createFaultLabelParts(const std::vector >& labelAndAnchors) { + m_faultMeshLabels = nullptr; + m_faultMeshLabelLines = nullptr; + + if (!labelAndAnchors.size()) return; + cvf::Font* font = RiaApplication::instance()->customFont(); std::vector lineVertices; From 1d3bc6887e68760b5c6d065925e3c3e9335fc013 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 11 Apr 2018 14:27:32 +0200 Subject: [PATCH 0656/1027] #2709 Export of COMPDAT : Always export diameter --- ...icWellPathExportCompletionDataFeatureImpl.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index ad6690d1d0..78c8f8e12a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -772,16 +772,14 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse { formatter.add(data.transmissibility()); - // Based on feedback from Shunping - // Include diameter when COMPDATL is exported + // Based on feedback from Shunping for COMPDATL, hhgs required COMPDAT + // Always include diameter // See https://github.com/OPM/ResInsight/issues/2517 - if (!gridName.isEmpty()) - { - if (RigCompletionData::isDefaultValue(data.diameter())) - formatter.add("1*"); - else - formatter.add(data.diameter()); - } + // See https://github.com/OPM/ResInsight/issues/2709 + if (RigCompletionData::isDefaultValue(data.diameter())) + formatter.add("1*"); + else + formatter.add(data.diameter()); } formatter.rowCompleted(); From dfa87b218f73707807fd404b3530cafb242b896e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 13 Apr 2018 09:44:34 +0200 Subject: [PATCH 0657/1027] #2737 Command File Launcher : Add command for launching command file from UI --- .../CMakeLists_files.cmake | 2 + .../RicRunCommandFileFeature.cpp | 75 +++++++++++++++++++ .../RicRunCommandFileFeature.h | 34 +++++++++ .../UserInterface/RiuMainWindow.cpp | 2 + 4 files changed, 113 insertions(+) create mode 100644 ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp create mode 100644 ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h diff --git a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 901b6428a7..a104e060e6 100644 --- a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -14,6 +14,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.h ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -31,6 +32,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.cpp ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp new file mode 100644 index 0000000000..a31c104c69 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicRunCommandFileFeature.h" + +#include "RiaApplication.h" +#include "RicfCommandFileExecutor.h" + +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicRunCommandFileFeature, "RicRunCommandFileFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunCommandFileFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunCommandFileFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("COMMAND_FILE"); + + QString fileName = QFileDialog::getOpenFileName(nullptr, "Open ResInsight Command File", defaultDir, "ResInsight Command File (*.txt);;All files(*.*)"); + + if (!fileName.isEmpty()) + { + QFile file(fileName); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + + QString applicationPath = QDir::currentPath(); + + QFileInfo fi(fileName); + QDir::setCurrent(fi.absolutePath()); + + RicfCommandFileExecutor::instance()->executeCommands(in); + + QDir::setCurrent(applicationPath); + + app->setLastUsedDialogDirectory("COMMAND_FILE", QFileInfo(fileName).absolutePath()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunCommandFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Run Command File"); +} diff --git a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h new file mode 100644 index 0000000000..be4ca628b1 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicRunCommandFileFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 99d1107363..e54b5c1d91 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -452,6 +452,7 @@ void RiuMainWindow::createMenus() testMenu->addAction(m_showRegressionTestDialog); testMenu->addAction(m_executePaintEventPerformanceTest); testMenu->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); + testMenu->addAction(cmdFeatureMgr->action("RicRunCommandFileFeature")); // Windows menu m_windowMenu = menuBar()->addMenu("&Windows"); @@ -544,6 +545,7 @@ void RiuMainWindow::createToolBars() toolbar->setObjectName(toolbar->windowTitle()); toolbar->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); toolbar->addAction(cmdFeatureMgr->action("RicLaunchRegressionTestsFeature")); + toolbar->addAction(cmdFeatureMgr->action("RicRunCommandFileFeature")); } // Create animation toolbar From 12fcb124c7ff47b9386df9946b596d642ccd7c17 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 13 Apr 2018 12:13:27 +0200 Subject: [PATCH 0658/1027] #2697 #2700 #2697 Export Completions Rename to RicfExportSimWellFractureCompletions Add missing parameters to RicfExportWellPathCompletions Add support for individual export multiple completion types into separate sections of same file --- .../CMakeLists_files.cmake | 4 +- ... RicfExportSimWellFractureCompletions.cpp} | 24 +-- ...=> RicfExportSimWellFractureCompletions.h} | 10 +- .../RicfExportWellPathCompletions.cpp | 29 ++- .../RicfExportWellPathCompletions.h | 6 +- .../RicExportCompletionDataSettingsUi.cpp | 66 ++++--- .../RicExportCompletionDataSettingsUi.h | 43 ++-- ...RicWellPathExportCompletionDataFeature.cpp | 12 +- ...ellPathExportCompletionDataFeatureImpl.cpp | 186 +++++++++++------- ...cWellPathExportCompletionDataFeatureImpl.h | 8 +- 10 files changed, 237 insertions(+), 151 deletions(-) rename ApplicationCode/CommandFileInterface/{RicfExportSimWellCompletions.cpp => RicfExportSimWellFractureCompletions.cpp} (75%) rename ApplicationCode/CommandFileInterface/{RicfExportSimWellCompletions.h => RicfExportSimWellFractureCompletions.h} (88%) diff --git a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake index 581bd22329..e7230c0ae7 100644 --- a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake @@ -6,7 +6,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.h -${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellFractureCompletions.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.h ${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.h @@ -29,7 +29,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.cpp -${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellFractureCompletions.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.cpp diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp similarity index 75% rename from ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp rename to ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp index 66dcfef3ce..e841fb196f 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicfExportSimWellCompletions.h" +#include "RicfExportSimWellFractureCompletions.h" #include "RicfCommandFileExecutor.h" @@ -37,28 +37,28 @@ #include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" -CAF_PDM_SOURCE_INIT(RicfExportSimWellCompletions, "exportSimWellCompletions"); +CAF_PDM_SOURCE_INIT(RicfExportSimWellFractureCompletions, "exportSimWellFractureCompletions"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicfExportSimWellCompletions::RicfExportSimWellCompletions() +RicfExportSimWellFractureCompletions::RicfExportSimWellFractureCompletions() { - RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", ""); - RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); - RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", ""); - RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", ""); - RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); - RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); + RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", ""); + RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); + RICF_InitField(&m_simWellNames, "simulationWellNames", std::vector(), "Simulation Well Names", "", "", ""); + RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); + RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicfExportSimWellCompletions::execute() +void RicfExportSimWellFractureCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + exportSettings->timeStep = m_timeStep; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; @@ -102,7 +102,7 @@ void RicfExportSimWellCompletions::execute() } std::vector simWells; - if (m_wellPathNames().empty()) + if (m_simWellNames().empty()) { std::copy(view->wellCollection()->wells.begin(), view->wellCollection()->wells.end(), @@ -110,7 +110,7 @@ void RicfExportSimWellCompletions::execute() } else { - for (const QString& wellPathName : m_wellPathNames()) + for (const QString& wellPathName : m_simWellNames()) { RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName); if (simWell) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h similarity index 88% rename from ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h rename to ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h index e639d939c2..fff7f75bae 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h @@ -30,21 +30,21 @@ // // //================================================================================================== -class RicfExportSimWellCompletions : public RicfCommandObject +class RicfExportSimWellFractureCompletions : public RicfCommandObject { CAF_PDM_HEADER_INIT; public: - RicfExportSimWellCompletions(); + RicfExportSimWellFractureCompletions(); virtual void execute() override; private: - caf::PdmField m_caseId; caf::PdmField m_timeStep; - caf::PdmField< std::vector > m_wellPathNames; - caf::PdmField m_wellSelection; + + caf::PdmField< std::vector > m_simWellNames; + caf::PdmField m_fileSplit; caf::PdmField m_compdatExport; }; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index a87959f6aa..36fc6f242b 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -43,12 +43,17 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions() RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", ""); - RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", ""); + RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); - RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", ""); - RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", ""); - RICF_InitField(&m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones", "", "", ""); + RICF_InitField(&m_combinationMode, "combinationMode", RicExportCompletionDataSettingsUi::CombinationModeType(), "Combination Mode", "", "", ""); + + RICF_InitField(&m_useLateralNTG, "useNtgHorizontally", false, "Use NTG Horizontally", "", "", ""); + RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", ""); + RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", ""); + RICF_InitField(&m_includeFractures, "includeFractures", true, "Include Fractures", "", "", ""); + + RICF_InitField(&m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -58,12 +63,26 @@ void RicfExportWellPathCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); - exportSettings->timeStep = m_timeStep; + + if (m_timeStep < 0) + { + exportSettings->timeStep = 0; + } + else + { + exportSettings->timeStep = m_timeStep; + } + exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; + + exportSettings->useLateralNTG = m_useLateralNTG; exportSettings->includePerforations = m_includePerforations; exportSettings->includeFishbones = m_includeFishbones; exportSettings->excludeMainBoreForFishbones = m_excludeMainBoreForFishbones; + exportSettings->includeFractures = m_includeFractures; + + exportSettings->setCombinationMode(m_combinationMode()); { bool foundCase = false; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h index fc5454ed41..f7d5d57d3c 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h @@ -44,10 +44,14 @@ class RicfExportWellPathCompletions : public RicfCommandObject caf::PdmField m_caseId; caf::PdmField m_timeStep; caf::PdmField< std::vector > m_wellPathNames; - caf::PdmField m_wellSelection; + caf::PdmField m_fileSplit; caf::PdmField m_compdatExport; + caf::PdmField m_combinationMode; + + caf::PdmField m_useLateralNTG; caf::PdmField m_includePerforations; caf::PdmField m_includeFishbones; + caf::PdmField m_includeFractures; caf::PdmField m_excludeMainBoreForFishbones; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 6e82f8ec2e..5d680609e4 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -29,15 +29,6 @@ namespace caf setDefault(RicExportCompletionDataSettingsUi::UNIFIED_FILE); } - template<> - void RicExportCompletionDataSettingsUi::WellSelectionType::setUp() - { - addItem(RicExportCompletionDataSettingsUi::ALL_WELLS, "ALL_WELLS", "All Wells"); - addItem(RicExportCompletionDataSettingsUi::CHECKED_WELLS, "CHECKED_WELLS", "Checked Wells"); - addItem(RicExportCompletionDataSettingsUi::SELECTED_WELLS, "SELECTED_WELLS", "Selected Wells"); - setDefault(RicExportCompletionDataSettingsUi::ALL_WELLS); - } - template<> void RicExportCompletionDataSettingsUi::CompdatExportType::setUp() { @@ -45,6 +36,14 @@ namespace caf addItem(RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS", "Default Connection Factors and WPIMULT (Fractures Not Supported)"); setDefault(RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES); } + + template<> + void RicExportCompletionDataSettingsUi::CombinationModeType::setUp() + { + addItem(RicExportCompletionDataSettingsUi::INDIVIDUALLY, "INDIVIDUALLY", "Individually"); + addItem(RicExportCompletionDataSettingsUi::COMBINED, "COMBINED", "Combined"); + setDefault(RicExportCompletionDataSettingsUi::INDIVIDUALLY); + } } @@ -70,6 +69,9 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Fractures", "", "", ""); CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, " Exclude Main Bore Transmissibility", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_reportCompletionTypesSeparately, "ReportCompletionTypesSeparately", "Export Completion Types", "", "", ""); + m_displayForSimWell = true; m_fracturesEnabled = true; @@ -96,7 +98,15 @@ void RicExportCompletionDataSettingsUi::showForWellPath() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::enableFractures(bool enable) +void RicExportCompletionDataSettingsUi::setCombinationMode(CombinationMode combinationMode) +{ + m_reportCompletionTypesSeparately = combinationMode; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showFractureInUi(bool enable) { m_fracturesEnabled = enable; } @@ -104,7 +114,7 @@ void RicExportCompletionDataSettingsUi::enableFractures(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::enablePerforations(bool enable) +void RicExportCompletionDataSettingsUi::showPerforationsInUi(bool enable) { m_perforationsEnabled = enable; } @@ -112,11 +122,19 @@ void RicExportCompletionDataSettingsUi::enablePerforations(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::enableFishbone(bool enable) +void RicExportCompletionDataSettingsUi::showFishbonesInUi(bool enable) { m_fishbonesEnabled = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionDataSettingsUi::reportCompletionsTypesIndividually() const +{ + return m_reportCompletionTypesSeparately() == INDIVIDUALLY; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -174,6 +192,7 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c group->add(&folder); group->add(&fileSplit); + group->add(&m_reportCompletionTypesSeparately); } { @@ -188,16 +207,6 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c caf::PdmUiGroup* group = uiOrdering.addNewGroup("Visible Completions"); if (!m_displayForSimWell) { - if (m_fishbonesEnabled) - { - group->add(&includeFishbones); - group->add(&excludeMainBoreForFishbones); - if (!includeFishbones) - excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); - else - excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); - } - if (m_perforationsEnabled) { group->add(&includePerforations); @@ -222,6 +231,19 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, c includeFractures.uiCapability()->setUiReadOnly(false); } } + + if (!m_displayForSimWell) + { + if (m_fishbonesEnabled) + { + group->add(&includeFishbones); + group->add(&excludeMainBoreForFishbones); + if (!includeFishbones) + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); + else + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); + } + } } uiOrdering.skipRemainingFields(); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 54f2f70edd..2b35840844 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -38,41 +38,43 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi }; typedef caf::AppEnum ExportSplitType; - enum WellSelection { - ALL_WELLS, - CHECKED_WELLS, - SELECTED_WELLS, - }; - typedef caf::AppEnum WellSelectionType; - enum CompdatExport { TRANSMISSIBILITIES, WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, }; typedef caf::AppEnum CompdatExportType; + enum CombinationMode + { + INDIVIDUALLY, + COMBINED, + }; + typedef caf::AppEnum CombinationModeType; + RicExportCompletionDataSettingsUi(); + caf::PdmField timeStep; + caf::PdmField fileSplit; caf::PdmField compdatExport; caf::PdmField useLateralNTG; caf::PdmField includePerforations; caf::PdmField includeFishbones; - - caf::PdmField includeFractures; - caf::PdmField excludeMainBoreForFishbones; - - caf::PdmField timeStep; - + caf::PdmField includeFractures; + void showForSimWells(); void showForWellPath(); - void enableFractures(bool enable); - void enablePerforations(bool enable); - void enableFishbone(bool enable); + void setCombinationMode(CombinationMode combinationMode); + + void showFractureInUi(bool enable); + void showPerforationsInUi(bool enable); + void showFishbonesInUi(bool enable); + + bool reportCompletionsTypesIndividually() const; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -81,9 +83,10 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - bool m_displayForSimWell; + caf::PdmField m_reportCompletionTypesSeparately; - bool m_fracturesEnabled; - bool m_perforationsEnabled; - bool m_fishbonesEnabled; + bool m_displayForSimWell; + bool m_fracturesEnabled; + bool m_perforationsEnabled; + bool m_fishbonesEnabled; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index 1f6139754a..ea34f91857 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -104,29 +104,29 @@ void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompl if ((!simWellFractures.empty()) || (!wellPathFractures.empty())) { - exportSettings->enableFractures(true); + exportSettings->showFractureInUi(true); } else { - exportSettings->enableFractures(false); + exportSettings->showFractureInUi(false); } if (!wellPathFishbones.empty()) { - exportSettings->enableFishbone(true); + exportSettings->showFishbonesInUi(true); } else { - exportSettings->enableFishbone(false); + exportSettings->showFishbonesInUi(false); } if (!wellPathPerforations.empty()) { - exportSettings->enablePerforations(true); + exportSettings->showPerforationsInUi(true); } else { - exportSettings->enablePerforations(false); + exportSettings->showPerforationsInUi(false); } caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, ""); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 78c8f8e12a..120e80d2b2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -110,7 +110,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } - std::map> completionsPerEclipseCell; // FractureTransmissibilityExportInformation std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; @@ -149,15 +148,25 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve caf::ProgressInfo progress(maxProgress, "Export Completions"); progress.setProgressDescription("Read Completion Data"); + + std::vector completions; + for (auto wellPath : usedWellPaths) { + std::map> completionsPerEclipseCellAllCompletionTypes; + std::map> completionsPerEclipseCellFishbones; + std::map> completionsPerEclipseCellFracture; + std::map> completionsPerEclipseCellPerforations; + // Generate completion data if (exportSettings.includePerforations) { std::vector perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, perforationCompletionData); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, perforationCompletionData); + appendCompletionData(&completionsPerEclipseCellPerforations, perforationCompletionData); } progress.incrementProgress(); @@ -166,7 +175,9 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve std::vector fishbonesCompletionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, fishbonesCompletionData); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, fishbonesCompletionData); + appendCompletionData(&completionsPerEclipseCellFishbones, fishbonesCompletionData); } progress.incrementProgress(); @@ -175,16 +186,52 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath( wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); - appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, fractureCompletionData); + appendCompletionData(&completionsPerEclipseCellFracture, fractureCompletionData); + } + + if (exportSettings.reportCompletionsTypesIndividually()) + { + for (auto& data : completionsPerEclipseCellFracture) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + for (auto& data : completionsPerEclipseCellFishbones) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + for (auto& data : completionsPerEclipseCellPerforations) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } } + else + { + for (auto& data : completionsPerEclipseCellAllCompletionTypes) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + } + progress.incrementProgress(); } for (auto simWell : simWells) { + std::map> completionsPerEclipseCell; + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell( exportSettings.caseToApply(), simWell, fractureTransmissibilityExportInformationStream.get()); appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); + + for (auto& data : completionsPerEclipseCell) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + progress.incrementProgress(); } @@ -193,27 +240,14 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve progress.setProgressDescription("Write Export Files"); if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE) { - std::vector completions; - for (auto& data : completionsPerEclipseCell) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, completions, exportSettings.compdatExport); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.compdatExport); progress.incrementProgress(); } else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) { for (auto wellPath : usedWellPaths) { - std::map> filteredWellCompletions = - getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } std::vector wellCompletions; for (const auto& completion : completions) { @@ -226,50 +260,44 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (wellCompletions.empty()) continue; QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); progress.incrementProgress(); } } else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) { - for (auto wellPath : usedWellPaths) + std::vector completionTypes; + completionTypes.push_back(RigCompletionData::FISHBONES); + completionTypes.push_back(RigCompletionData::FRACTURE); + completionTypes.push_back(RigCompletionData::PERFORATION); + + for (const auto& completionType : completionTypes) { - std::map> filteredWellCompletions = - getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) + for (auto wellPath : usedWellPaths) { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - { - std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType( - completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); - if (!fishbonesCompletions.empty()) - { - QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - { - std::vector perforationCompletions = getCompletionsForWellAndCompletionType( - completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); - if (!perforationCompletions.empty()) + std::vector wellCompletions; + for (const auto& completion : completions) { - QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles( - exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); + if (completion.wellName() == wellPath->completions()->wellNameForExport() && + completionType == completion.completionType()) + { + wellCompletions.push_back(completion); + } } - progress.incrementProgress(); - } - { - std::vector fractureCompletions = getCompletionsForWellAndCompletionType( - completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); - if (!fractureCompletions.empty()) + + if (wellCompletions.empty()) continue; + { - QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); + QString completionTypeText; + if (completionType == RigCompletionData::FISHBONES) completionTypeText = "Fishbones"; + if (completionType == RigCompletionData::FRACTURE) completionTypeText = "Fracture"; + if (completionType == RigCompletionData::PERFORATION) completionTypeText = "Perforation"; + + QString fileName = QString("%1_%2_%3").arg(wellPath->name()).arg(completionTypeText).arg(eclipseCaseName); + sortAndExportCompletionsToFile( + exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); } + progress.incrementProgress(); } } @@ -281,13 +309,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve { for (auto simWell : simWells) { - std::map> filteredWellCompletions = - getCompletionsForWell(completionsPerEclipseCell, simWell->name()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } std::vector wellCompletions; for (const auto& completion : completions) { @@ -299,10 +320,9 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (wellCompletions.empty()) continue; - QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL - ? QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) - : QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); - printCompletionsToFiles(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + QString fileName = QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + progress.incrementProgress(); } } @@ -487,7 +507,7 @@ RigCompletionData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles( +void RicWellPathExportCompletionDataFeatureImpl::sortAndExportCompletionsToFile( const QString& folderName, const QString& fileName, std::vector& completions, @@ -525,20 +545,20 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFiles( std::map> completionsForGrid; completionsForGrid.insert(std::pair>("", completionsForMainGrid)); - printCompletionsToFile(folderName, fileName, completionsForGrid, exportType); + exportCompdatAndWpimultTables(folderName, fileName, completionsForGrid, exportType); } if (!completionsForSubGrids.empty()) { QString lgrFileName = fileName + "_LGR"; - printCompletionsToFile(folderName, lgrFileName, completionsForSubGrids, exportType); + exportCompdatAndWpimultTables(folderName, lgrFileName, completionsForSubGrids, exportType); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile( +void RicWellPathExportCompletionDataFeatureImpl::exportCompdatAndWpimultTables( const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, @@ -577,11 +597,11 @@ void RicWellPathExportCompletionDataFeatureImpl::printCompletionsToFile( // Print completion data QString gridName = gridCompletions.first; - generateCompdatTable(formatter, gridName, completions); + exportCompdatTableUsingFormatter(formatter, gridName, completions); if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { - generateWpimultTable(formatter, gridName, completions); + exportWpimultTableUsingFormatter(formatter, gridName, completions); } } @@ -634,9 +654,10 @@ std::map> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipseDataTableFormatter& formatter, - const QString& gridName, - const std::vector& completionData) +void RicWellPathExportCompletionDataFeatureImpl::exportCompdatTableUsingFormatter( + RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) { std::vector header; @@ -687,6 +708,8 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse } formatter.header(header); + RigCompletionData::CompletionType currentCompletionType = RigCompletionData::CT_UNDEFINED; + for (const RigCompletionData& data : completionData) { if (data.transmissibility() == 0.0 || data.wpimult() == 0.0) @@ -695,6 +718,20 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse continue; } + if (currentCompletionType != data.completionType()) + { + // The completions are sorted by completion type, write out a heading when completion type changes + + QString txt; + if (data.completionType() == RigCompletionData::FISHBONES) txt = "Fishbones"; + if (data.completionType() == RigCompletionData::FRACTURE) txt = "Fracture"; + if (data.completionType() == RigCompletionData::PERFORATION) txt = "Perforation"; + + formatter.comment("---- Completions for completion type " + txt + " ----"); + + currentCompletionType = data.completionType(); + } + for (const RigCompletionMetaData& metadata : data.metadata()) { formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); @@ -790,9 +827,10 @@ void RicWellPathExportCompletionDataFeatureImpl::generateCompdatTable(RifEclipse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::generateWpimultTable(RifEclipseDataTableFormatter& formatter, - const QString& gridName, - const std::vector& completionData) +void RicWellPathExportCompletionDataFeatureImpl::exportWpimultTableUsingFormatter( + RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) { std::vector header; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 2168792386..3991caceac 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -163,12 +163,12 @@ class RicWellPathExportCompletionDataFeatureImpl static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); - static void printCompletionsToFiles(const QString& exportFolder, + static void sortAndExportCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static void printCompletionsToFile(const QString& folderName, + static void exportCompdatAndWpimultTables(const QString& folderName, const QString& fileName, const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); @@ -181,11 +181,11 @@ class RicWellPathExportCompletionDataFeatureImpl getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, + static void exportCompdatTableUsingFormatter(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); - static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, + static void exportWpimultTableUsingFormatter(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); From 6e0b7e23051ff517877cc4e573e7dac1f1f3980c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 13:34:41 +0200 Subject: [PATCH 0659/1027] Improve 3D Well path plots * Always generate in up-direction and rotate to left/right/down * Generate a "dominant direction" by interrogating the whole curve, not just the first and last item. * Improve maths: - Generate a projection plane spanned by UP and the dominant direction. - Project the tangent onto this projection plane. - Generate normal as the cross product between the projected tangent and the normal to the projection plane. - Rotate the normal into left/right/down if required. --- .../Riv3dWellLogPlanePartMgr.cpp | 8 +- .../RigWellPathGeometryTools.cpp | 127 ++++++++++++++---- .../RigWellPathGeometryTools.h | 5 + 3 files changed, 107 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 78cbf6b989..47bc840199 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -158,13 +158,13 @@ double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurve::DrawPlane& switch (drawPlane) { case Rim3dWellLogCurve::HORIZONTAL_LEFT: - return cvf::PI_D; + return cvf::PI_D / 2.0; case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - return 0.0; + return -cvf::PI_D / 2.0; case Rim3dWellLogCurve::VERTICAL_ABOVE: - return cvf::PI_D / 2.0; + return 0.0; case Rim3dWellLogCurve::VERTICAL_BELOW: - return -cvf::PI_D / 2.0; + return cvf::PI_D; default: return 0; } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index c64e9ce57a..95e0ca09fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -20,14 +20,17 @@ #include "RigWellPath.h" -#include "cvfMatrix3.h" #include "cvfMath.h" +#include "cvfMatrix3.h" + +#include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, - double angle, + double planeAngle, const std::vector& vertices, VertexOrganization organization) { @@ -36,10 +39,13 @@ std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(co if (!wellPathGeometry) return pointNormals; if (vertices.empty()) return pointNormals; - const cvf::Vec3d globalDirection = - (wellPathGeometry->m_wellPathPoints.back() - wellPathGeometry->m_wellPathPoints.front()).getNormalized(); + cvf::Vec3d up(0, 0, 1); - const cvf::Vec3d up(0, 0, 1); + // Project onto normal plane + cvf::Vec3d dominantDirection = estimateDominantDirectionInXYPlane(wellPathGeometry); + + const cvf::Vec3d projectionPlaneNormal = (up ^ dominantDirection).getNormalized(); + CVF_ASSERT(projectionPlaneNormal * dominantDirection <= std::numeric_limits::epsilon()); size_t intervalSize; if (organization == LINE_SEGMENTS) @@ -53,48 +59,36 @@ std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(co intervalSize = 1; } - cvf::Vec3d normal; - + cvf::Vec3d lastNormal; for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) { cvf::Vec3d p1 = vertices[i]; cvf::Vec3d p2 = vertices[i + 1]; - cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); - - double dotProduct = up * vecAlongPath; - - cvf::Vec3d Ex; - - if (cvf::Math::abs(dotProduct) > 0.7071) - { - Ex = globalDirection; - } - else + cvf::Vec3d tangent = (p2 - p1).getNormalized(); + cvf::Vec3d normal(0, 0, 0); + if (cvf::Math::abs(tangent * projectionPlaneNormal) < 0.7071) { - Ex = vecAlongPath; + cvf::Vec3d projectedTangent = (tangent - (tangent * projectionPlaneNormal) * projectionPlaneNormal).getNormalized(); + normal = (projectedTangent ^ projectionPlaneNormal).getNormalized(); + normal = normal.getTransformedVector(cvf::Mat3d::fromRotation(tangent, planeAngle)); } - - cvf::Vec3d Ey = (up ^ Ex).getNormalized(); - - cvf::Mat3d rotation; - normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle)); - pointNormals.push_back(normal); + lastNormal = normal; } if (organization == POLYLINE) { - pointNormals.push_back(normal); + pointNormals.push_back(lastNormal); } - return pointNormals; + return interpolateUndefinedNormals(up, pointNormals, vertices); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, +void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, const std::vector& points, std::vector* closestWellPathPoints) { @@ -111,3 +105,78 @@ void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPat closestWellPathPoints->push_back(p2); } } + +std::vector RigWellPathGeometryTools::interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, + const std::vector& normals, + const std::vector& vertices) +{ + std::vector interpolated(normals); + cvf::Vec3d lastNormal(0, 0, 0); + double distanceFromLast = 0.0; + + for (size_t i = 0; i < normals.size(); ++i) + { + cvf::Vec3d currentNormal = normals[i]; + bool currentInterpolated = false; + if (i > 0) + { + distanceFromLast += (vertices[i] - vertices[i - 1]).length(); + } + + if (currentNormal.length() == 0.0) // Undefined. Need to estimate from neighbors. + { + currentInterpolated = true; + currentNormal = planeNormal; // By default use the plane normal + + cvf::Vec3d nextNormal(0, 0, 0); + double distanceToNext = 0.0; + for (size_t j = i + 1; j < normals.size() && nextNormal.length() == 0.0; ++j) + { + nextNormal = normals[j]; + distanceToNext += (vertices[j] - vertices[j - 1]).length(); + } + + if (lastNormal.length() > 0.0 && nextNormal.length() > 0.0) + { + // Both last and next are acceptable, interpolate! + currentNormal = (distanceToNext * lastNormal + distanceFromLast * nextNormal).getNormalized(); + } + else if (lastNormal.length() > 0.0) + { + currentNormal = lastNormal; + } + else if (nextNormal.length() > 0.0) + { + currentNormal = nextNormal; + } + } + if (i > 0 && currentNormal * lastNormal < -std::numeric_limits::epsilon()) + { + currentNormal *= -1.0; + } + if (!currentInterpolated) + { + lastNormal = currentNormal; + distanceFromLast = 0.0; // Reset distance + } + interpolated[i] = currentNormal; + } + return interpolated; +} + +cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const RigWellPath* wellPathGeometry) +{ + cvf::Vec3d directionSum(0, 0, 0); + const std::vector& points = wellPathGeometry->m_wellPathPoints; + for (size_t i = 1; i < points.size(); ++i) + { + cvf::Vec3d vec = points[i] - points[i - 1]; + vec.z() = 0.0; + if (directionSum.length() > 0.0 && (directionSum * vec) < std::numeric_limits::epsilon()) + { + vec *= -1; + } + directionSum += vec; + } + return directionSum.getNormalized(); +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h index 3c3f0b8f7d..d1b26dd6ef 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -46,4 +46,9 @@ class RigWellPathGeometryTools static void calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, const std::vector& points, std::vector* closestWellPathPoints); +private: + static std::vector interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, + const std::vector& normals, + const std::vector& vertices); + static cvf::Vec3d estimateDominantDirectionInXYPlane(const RigWellPath* wellPathGeometry); }; From e8b006d068daebe469edc166d3cdcc0288c7a241 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 12 Apr 2018 17:44:50 +0200 Subject: [PATCH 0660/1027] 3D Well Log Curves (#2671): Split normals, border and surface into several drawables. * Also create a closed LINES_LOOP out of the mesh border. * This will facilitate using different effects on the different parts. i.e. solid border and white surface background. --- .../Riv3dWellLogGridGeomertyGenerator.cpp | 157 +++++++++++------- .../Riv3dWellLogGridGeomertyGenerator.h | 19 ++- .../Riv3dWellLogPlanePartMgr.cpp | 27 ++- 3 files changed, 131 insertions(+), 72 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 4e8b030962..dea144f13c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -25,10 +25,14 @@ #include "RigWellPathGeometryTools.h" #include "cafDisplayCoordTransform.h" +#include "cvfObject.h" +#include "cvfDrawableGeo.h" #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfBoundingBox.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -40,23 +44,35 @@ Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, +std::map< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > +Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double gridIntervalSize) const + double planeOffsetFromWellPathCenter, + double planeWidth, + double gridIntervalSize) const { CVF_ASSERT(gridIntervalSize > 0); - if (!wellPathGeometry()) return nullptr; - if (!wellPathClipBoundingBox.isValid()) return nullptr; + if (!wellPathGeometry() || wellPathGeometry()->m_measuredDepths.empty()) + { + return std::map< DrawableId, cvf::ref >(); + } + + if (!wellPathClipBoundingBox.isValid()) + { + return std::map< DrawableId, cvf::ref >(); + } + RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; - if (wellPathPoints.empty()) return nullptr; + if (wellPathPoints.empty()) + { + return std::map< DrawableId, cvf::ref >(); + } size_t originalWellPathSize = wellPathPoints.size(); @@ -68,11 +84,15 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const c wellPathPoints = RigWellPath::clipPolylineStartAboveZ( wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); } - if (wellPathPoints.empty()) return nullptr; - std::vector gridPoints; + if (wellPathPoints.empty()) + { + return std::map< DrawableId, cvf::ref >(); + } + + std::map< DrawableId, cvf::ref > drawables; - if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; + std::vector gridPoints; size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); @@ -92,27 +112,9 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const c RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), gridPoints, &closestPoints); pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, closestPoints, RigWellPathGeometryTools::LINE_SEGMENTS); - if (pointNormals.size() != gridPoints.size()) return nullptr; - - std::vector vertices; - vertices.reserve(gridPoints.size() * 2); - - std::vector indices; - indices.reserve(gridPoints.size() * 2); - - cvf::uint indexCounter = 0; - - // Normal lines - for (size_t i = 0; i < pointNormals.size(); i++) + if (pointNormals.size() != gridPoints.size()) { - vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); - - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); - - indices.push_back(indexCounter++); - indices.push_back(indexCounter++); + return std::map< DrawableId, cvf::ref >(); } // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off @@ -120,44 +122,79 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::createGrid(const c RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, wellPathGeometry()->m_wellPathPoints, RigWellPathGeometryTools::POLYLINE); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); - // Line along and close to well - for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); - - indices.push_back(indexCounter); - indices.push_back(++indexCounter); + std::vector vertices; + vertices.reserve(gridPoints.size()); + + std::vector indices; + indices.reserve(gridPoints.size()); + cvf::uint indexCounter = 0; + // Line along and close to well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); + + indices.push_back(indexCounter); + indices.push_back(++indexCounter); + } + // Line along and far away from well in reverse order to create a closed surface. + for (int64_t i = (int64_t) wellPathPoints.size()-1; i >= 0; i--) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + + indices.push_back(indexCounter); + indices.push_back(++indexCounter); + } + indices.pop_back(); + indices.push_back(0u); // Close surface + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINE_LOOP); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref gridBorderDrawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + gridBorderDrawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + gridBorderDrawable->setVertexArray(vertexArray.p()); + drawables[GridBorder] = gridBorderDrawable; } - // Indices are added as line segments for the current point and the next point. The last point does not have a next point, - // therefore we remove the last line segment - indices.pop_back(); - indices.pop_back(); - - // Line along and far away from well - for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + std::vector vertices; + vertices.reserve(gridPoints.size()); - indices.push_back(indexCounter); - indices.push_back(++indexCounter); - } - indices.pop_back(); - indices.pop_back(); + std::vector indices; + indices.reserve(gridPoints.size()); + cvf::uint indexCounter = 0; + // Normal lines. Start from one to avoid drawing at surface edge. + for (size_t i = 1; i < pointNormals.size(); i++) + { + vertices.push_back(cvf::Vec3f( + displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); - cvf::ref drawable = new cvf::DrawableGeo(); + indices.push_back(indexCounter++); + indices.push_back(indexCounter++); + } - indexedUInt->setIndices(indexArray.p()); - drawable->addPrimitiveSet(indexedUInt.p()); + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); - cvf::ref vertexArray = new cvf::Vec3fArray(vertices); - drawable->setVertexArray(vertexArray.p()); + cvf::ref normalLinesDrawable = new cvf::DrawableGeo(); - return drawable; + indexedUInt->setIndices(indexArray.p()); + normalLinesDrawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + normalLinesDrawable->setVertexArray(vertexArray.p()); + + drawables[NormalLines] = normalLinesDrawable; + } + return drawables; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index f511c5bffd..c78c3ea615 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -24,7 +24,7 @@ #include "cafPdmPointer.h" -#include +#include namespace caf { @@ -42,14 +42,21 @@ class RimWellPath; class Riv3dWellLogGridGeometryGenerator : public cvf::Object { public: + enum DrawableId + { + NormalLines = 0, + GridBorder = 1, + GridBackground = 2 + }; Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath); - cvf::ref createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, + std::map > + createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double gridIntervalSize) const; + double planeOffsetFromWellPathCenter, + double planeWidth, + double gridIntervalSize) const; private: const RigWellPath* wellPathGeometry() const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 47bc840199..e54194e9cc 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -38,6 +38,8 @@ #include "cvfModelBasicList.h" #include "cvfPart.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -221,9 +223,12 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); - caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + caf::SurfaceEffectGenerator surfaceEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 0.5), caf::PO_1); + caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + caf::MeshEffectGenerator normalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + normalsEffectGen.setLineStipple(true); - cvf::ref gridHorizontalDrawable = + std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > gridDrawables = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, wellPathClipBoundingBox, planeAngle(drawPlane), @@ -231,11 +236,21 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* planeWidth(), gridIntervalSize); - cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = createPart(gridHorizontalDrawable.p(), effect.p()); + std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > effects; + effects[Riv3dWellLogGridGeometryGenerator::GridBackground] = surfaceEffectGen.generateCachedEffect(); + effects[Riv3dWellLogGridGeometryGenerator::GridBorder] = gridBorderEffectGen.generateCachedEffect(); + effects[Riv3dWellLogGridGeometryGenerator::NormalLines] = normalsEffectGen.generateCachedEffect(); + cvf::ref normalsEffect = normalsEffectGen.generateCachedEffect(); - if (part.notNull()) + for(std::pair< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > item : gridDrawables) { - model->addPart(part.p()); + Riv3dWellLogGridGeometryGenerator::DrawableId drawableId = item.first; + cvf::ref drawable = item.second; + CVF_ASSERT(drawable.notNull()); + cvf::ref part = createPart(drawable.p(), effects[drawableId].p()); + if (part.notNull()) + { + model->addPart(part.p()); + } } } From 1bb1b3004ec30217b5022993824acb48db6131f0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 14:35:14 +0200 Subject: [PATCH 0661/1027] Generalize the interpolation in RigWellPath * Make it possible to interpolate any vector along the well path, not just the well path points. This way it can be used for normals. * The interpolation line needs to be a weighted sum of vectors from the two closest points rather than the previous point + a segment, which only works for points. * If used for normals, the end result *has to be normalized* --- .../ReservoirDataModel/RigWellPath.cpp | 34 ++++++++++++++----- .../ReservoirDataModel/RigWellPath.h | 11 ++++-- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index c567673ce3..f76af2b5fe 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -59,9 +59,12 @@ double RigWellPath::datumElevation() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint) const +cvf::Vec3d RigWellPath::interpolatedVectorAlongWellPath(const std::vector& vectors, + double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const { - cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO; + CVF_ASSERT(vectors.size() == m_wellPathPoints.size()); + cvf::Vec3d interpolatedVector = cvf::Vec3d::ZERO; if (horizontalLengthAlongWellToStartClipPoint) *horizontalLengthAlongWellToStartClipPoint = 0.0; @@ -82,17 +85,15 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, dou if ( vxIdx == 0 ) { //For measuredDepth same or lower than first point, use this first point - wellPathPoint = m_wellPathPoints.at(0); + interpolatedVector = vectors.at(0); } else { //Do interpolation double segmentFraction = (measuredDepth - m_measuredDepths.at(vxIdx-1)) / (m_measuredDepths.at(vxIdx) - m_measuredDepths.at(vxIdx - 1)); - cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1]; - - segment *= segmentFraction; - wellPathPoint = m_wellPathPoints[vxIdx - 1] + segment; + cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1]; + interpolatedVector = (1.0 - segmentFraction) * vectors[vxIdx - 1] + segmentFraction * vectors[vxIdx]; if ( horizontalLengthAlongWellToStartClipPoint ) { @@ -104,11 +105,16 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, dou else { // Use endpoint if measuredDepth same or higher than last point - wellPathPoint = m_wellPathPoints.at(vxIdx-1); + interpolatedVector = vectors.at(vxIdx-1); } - return wellPathPoint; + return interpolatedVector; +} + +cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const +{ + return interpolatedVectorAlongWellPath(m_wellPathPoints, measuredDepth, horizontalLengthAlongWellToStartClipPoint); } //-------------------------------------------------------------------------------------------------- @@ -368,3 +374,13 @@ std::vector RigWellPath::clipPolylineStartAboveZ(const std::vector& RigWellPath::wellPathPoints() const +{ + return m_wellPathPoints; +} + +const std::vector& RigWellPath::measureDepths() const +{ + return m_measuredDepths; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index f7903be5e4..b61cbd35a2 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -37,16 +37,19 @@ namespace cvf class RigWellPath : public cvf::Object { public: - RigWellPath(); - std::vector m_wellPathPoints; std::vector m_measuredDepths; + RigWellPath(); void setDatumElevation(double value); bool hasDatumElevation() const; double datumElevation() const; - cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth, + cvf::Vec3d interpolatedVectorAlongWellPath(const std::vector& vectors, + double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; + cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; + double wellPathAzimuthAngle(const cvf::Vec3d& position) const; void twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2) const; @@ -63,6 +66,8 @@ class RigWellPath : public cvf::Object double maxZ, double * horizontalLengthAlongWellToClipPoint, size_t * indexToFirstVisibleSegment); + const std::vector& wellPathPoints() const; + const std::vector& measureDepths() const; private: bool m_hasDatumElevation; From b48adbbaa947b0040e58f61a7ca642618d996634 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 14:36:37 +0200 Subject: [PATCH 0662/1027] 3D Well log curves: Use the new generalized interpolation for normals * Don't have to perform the normal generation again for grid points. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 16 +++-- .../Riv3dWellLogGridGeomertyGenerator.cpp | 58 ++++++++----------- .../RigWellPathGeometryTools.cpp | 50 +++------------- .../RigWellPathGeometryTools.h | 8 +-- 4 files changed, 41 insertions(+), 91 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 31e59abfe0..b26f00f647 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -113,15 +113,19 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; } - std::vector interpolatedWellPathPoints; + std::vector wellPathNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); + std::vector interpolatedWellPathPoints; + std::vector interpolatedNormals; // Iterate from bottom of well path and up to be able to stop at given Z max clipping height for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) { cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*md); + cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathNormals, *md); if (point.z() > maxZClipHeight) break; interpolatedWellPathPoints.push_back(point); + interpolatedNormals.push_back(normal.getNormalized()); } if (interpolatedWellPathPoints.empty()) return; @@ -132,12 +136,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); - std::vector pairsOfWellPathPoints; - RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), interpolatedWellPathPoints, &pairsOfWellPathPoints); - - std::vector pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, pairsOfWellPathPoints, RigWellPathGeometryTools::LINE_SEGMENTS); - if (interpolatedWellPathPoints.size() != pointNormals.size()) return; - double maxResult = -HUGE_VAL; double minResult = HUGE_VAL; @@ -153,7 +151,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std double plotRangeToResultRangeFactor = planeWidth / (maxResult - minResult); - for (size_t i = 0; i < pointNormals.size(); i++) + for (size_t i = 0; i < interpolatedNormals.size(); i++) { double scaledResult = 0; @@ -164,7 +162,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std } (*vertices)[i] = cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * pointNormals[i])); + displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * interpolatedNormals[i])); } std::vector> valuesIntervals = diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index dea144f13c..96bfee9e79 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -92,42 +92,17 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* std::map< DrawableId, cvf::ref > drawables; - std::vector gridPoints; - - size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); - double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); - double lastMd = wellPathGeometry()->m_measuredDepths.back(); - - double md = lastMd; - while (md >= firstMd) - { - cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); - gridPoints.push_back(point); - md -= gridIntervalSize; - } - - std::vector pointNormals; - - std::vector closestPoints; - RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(wellPathGeometry(), gridPoints, &closestPoints); - - pointNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, closestPoints, RigWellPathGeometryTools::LINE_SEGMENTS); - if (pointNormals.size() != gridPoints.size()) - { - return std::map< DrawableId, cvf::ref >(); - } - // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off std::vector wellPathSegmentNormals = - RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle, wellPathGeometry()->m_wellPathPoints, RigWellPathGeometryTools::POLYLINE); + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); { std::vector vertices; - vertices.reserve(gridPoints.size()); + vertices.reserve(wellPathPoints.size()); std::vector indices; - indices.reserve(gridPoints.size()); + indices.reserve(wellPathPoints.size()); cvf::uint indexCounter = 0; // Line along and close to well for (size_t i = 0; i < wellPathPoints.size(); i++) @@ -162,20 +137,37 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* drawables[GridBorder] = gridBorderDrawable; } { + std::vector interpolatedGridPoints; + std::vector interpolatedGridNormals; + + size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); + double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + + double md = lastMd; + while (md >= firstMd) + { + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); + cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathSegmentNormals, md); + interpolatedGridPoints.push_back(point); + interpolatedGridNormals.push_back(normal.getNormalized()); + md -= gridIntervalSize; + } + std::vector vertices; - vertices.reserve(gridPoints.size()); + vertices.reserve(interpolatedGridPoints.size()); std::vector indices; - indices.reserve(gridPoints.size()); + indices.reserve(interpolatedGridPoints.size()); cvf::uint indexCounter = 0; // Normal lines. Start from one to avoid drawing at surface edge. - for (size_t i = 1; i < pointNormals.size(); i++) + for (size_t i = 1; i < interpolatedGridNormals.size(); i++) { vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter))); + displayCoordTransform->transformToDisplayCoord(interpolatedGridPoints[i] + interpolatedGridNormals[i] * planeOffsetFromWellPathCenter))); vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + interpolatedGridPoints[i] + interpolatedGridNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); indices.push_back(indexCounter++); indices.push_back(indexCounter++); diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index 95e0ca09fb..f375dc2bcb 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -30,37 +30,27 @@ /// //-------------------------------------------------------------------------------------------------- std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, - double planeAngle, - const std::vector& vertices, - VertexOrganization organization) + double planeAngle) { std::vector pointNormals; if (!wellPathGeometry) return pointNormals; + + const std::vector& vertices = wellPathGeometry->wellPathPoints(); + if (vertices.empty()) return pointNormals; + pointNormals.reserve(vertices.size()); + cvf::Vec3d up(0, 0, 1); - // Project onto normal plane cvf::Vec3d dominantDirection = estimateDominantDirectionInXYPlane(wellPathGeometry); const cvf::Vec3d projectionPlaneNormal = (up ^ dominantDirection).getNormalized(); CVF_ASSERT(projectionPlaneNormal * dominantDirection <= std::numeric_limits::epsilon()); - size_t intervalSize; - if (organization == LINE_SEGMENTS) - { - pointNormals.reserve(vertices.size() / 2); - intervalSize = 2; - } - else // organization == POLYLINE - { - pointNormals.reserve(vertices.size()); - intervalSize = 1; - } - cvf::Vec3d lastNormal; - for (size_t i = 0; i < vertices.size() - 1; i += intervalSize) + for (size_t i = 0; i < vertices.size() - 1; ++i) { cvf::Vec3d p1 = vertices[i]; cvf::Vec3d p2 = vertices[i + 1]; @@ -77,35 +67,11 @@ std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(co lastNormal = normal; } - if (organization == POLYLINE) - { - pointNormals.push_back(lastNormal); - } + pointNormals.push_back(lastNormal); return interpolateUndefinedNormals(up, pointNormals, vertices); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigWellPathGeometryTools::calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, - const std::vector& points, - std::vector* closestWellPathPoints) -{ - CVF_ASSERT(closestWellPathPoints != nullptr); - - for (const cvf::Vec3d point : points) - { - cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; - cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - wellPathGeometry->twoClosestPoints(point, &p1, &p2); - if (p1.isUndefined() || p2.isUndefined()) continue; - - closestWellPathPoints->push_back(p1); - closestWellPathPoints->push_back(p2); - } -} - std::vector RigWellPathGeometryTools::interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, const std::vector& normals, const std::vector& vertices) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h index d1b26dd6ef..17cd410a79 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -39,13 +39,7 @@ class RigWellPathGeometryTools public: static std::vector calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, - double angle, - const std::vector& vertices, - VertexOrganization organization); - - static void calculatePairsOfClosestSamplingPointsAlongWellPath(const RigWellPath* wellPathGeometry, - const std::vector& points, - std::vector* closestWellPathPoints); + double angle); private: static std::vector interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, const std::vector& normals, From fd63ae753140cbdba5b7a2e1b18cf12b7d0c8225 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 15:29:13 +0200 Subject: [PATCH 0663/1027] 3D Well path plots: clean up some indentation and remove an unnecessary epsilon --- .../ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp | 2 +- .../ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h | 2 +- ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 96bfee9e79..2f6eba25c4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -47,7 +47,7 @@ Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath std::map< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, + double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, double gridIntervalSize) const diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index c78c3ea615..1f91e06625 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -53,7 +53,7 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object std::map > createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, + double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, double gridIntervalSize) const; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index f375dc2bcb..bc092b58a1 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -138,7 +138,7 @@ cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const Ri { cvf::Vec3d vec = points[i] - points[i - 1]; vec.z() = 0.0; - if (directionSum.length() > 0.0 && (directionSum * vec) < std::numeric_limits::epsilon()) + if (directionSum.length() > 0.0 && (directionSum * vec) < 0.0) { vec *= -1; } From 4c5b90f363db81de59cb2c3f0de42de5a1bd3927 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 13:45:12 +0200 Subject: [PATCH 0664/1027] Add get methods for drawStyle and coloringStyle for Rim3dWellLogCurve --- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 18 +++++++++++++++++- .../ProjectDataModel/Rim3dWellLogCurve.h | 6 ++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index bf2b81b5e5..2e6ae4e627 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -95,13 +95,29 @@ void Rim3dWellLogCurve::updateCurveIn3dView() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const { return m_drawPlane(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::DrawStyle Rim3dWellLogCurve::drawStyle() const +{ + return m_drawStyle(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::ColoringStyle Rim3dWellLogCurve::coloringStyle() const +{ + return m_coloringStyle(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 9b5ad87ea7..24b5827e08 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -60,8 +60,10 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); - DrawPlane drawPlane() const; - bool isShowingCurve() const; + DrawPlane drawPlane() const; + DrawStyle drawStyle() const; + ColoringStyle coloringStyle() const; + bool isShowingCurve() const; virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; From edf23b526585f529a01caaf3f607130f5cef5c9c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 13 Apr 2018 13:44:18 +0200 Subject: [PATCH 0665/1027] Remove epsilon guard in setAutomaticRanges for RimLegendConfig. --- .../ProjectDataModel/RimLegendConfig.cpp | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 30f8b01046..3aa7ebf901 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -423,39 +423,13 @@ void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, dou double candidateLocalAutoMin = roundToNumSignificantDigits(localMin, m_precision); double candidateLocalAutoMax = roundToNumSignificantDigits(localMax, m_precision); - bool needsUpdate = false; - const double epsilon = std::numeric_limits::epsilon(); - - if (cvf::Math::abs(candidateGlobalAutoMax - m_globalAutoMax) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateGlobalAutoMin - m_globalAutoMin) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateLocalAutoMax - m_localAutoMax) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateLocalAutoMin - m_localAutoMin) > epsilon) - { - needsUpdate = true; - } + m_globalAutoMin = candidateGlobalAutoMin; + m_globalAutoMax = candidateGlobalAutoMax; - if (needsUpdate) - { - m_globalAutoMin = candidateGlobalAutoMin; - m_globalAutoMax = candidateGlobalAutoMax; - - m_localAutoMin = candidateLocalAutoMin; - m_localAutoMax = candidateLocalAutoMax; + m_localAutoMin = candidateLocalAutoMin; + m_localAutoMax = candidateLocalAutoMax; - updateLegend(); - } + updateLegend(); } //-------------------------------------------------------------------------------------------------- From d7e7c4a463a841a7becf65a01391b4f4a268c168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 13 Apr 2018 11:11:05 +0200 Subject: [PATCH 0666/1027] #2720, #2686, #2701 Origin summary and grid cases import enhancements --- .../Application/RiaApplication.cpp | 2 +- .../Application/RiaPreferences.cpp | 1 + ApplicationCode/Application/RiaPreferences.h | 1 + .../Application/Tools/RiaArgumentParser.cpp | 6 +- .../Tools/RiaImportEclipseCaseTools.cpp | 143 ++++++++++-------- .../Tools/RiaImportEclipseCaseTools.h | 3 +- .../CommandFileInterface/RicfLoadCase.cpp | 6 +- .../RicImportEclipseCaseFeature.cpp | 15 +- .../RicImportEclipseCasesFeature.cpp | 15 +- .../Commands/RicImportSummaryCasesFeature.cpp | 7 +- .../Commands/RicSummaryCaseRestartDialog.cpp | 62 ++++++-- .../Commands/RicSummaryCaseRestartDialog.h | 22 ++- .../FileInterface/RifEclipseSummaryTools.cpp | 35 ++++- .../FileInterface/RifEclipseSummaryTools.h | 1 + .../RifSummaryCaseRestartSelector.cpp | 119 ++++++++++++--- .../RifSummaryCaseRestartSelector.h | 28 +++- .../ProjectDataModel/RimProject.cpp | 16 ++ ApplicationCode/ProjectDataModel/RimProject.h | 2 + .../Summary/RimSummaryCaseMainCollection.cpp | 86 ++++------- .../Summary/RimSummaryCaseMainCollection.h | 8 +- 20 files changed, 379 insertions(+), 199 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index aac81a0e01..7b5b870760 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1860,7 +1860,7 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".egrid", Qt::CaseInsensitive) || fileName.contains(".grid", Qt::CaseInsensitive)) { - loadingSucceded = RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName); + loadingSucceded = !RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ fileName })).isEmpty(); } else if (fileName.contains(".grdecl", Qt::CaseInsensitive)) { diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 3ef407d7d0..f3e890336c 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -103,6 +103,7 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitFieldNoDefault(&summaryRestartFilesShowImportDialog, "summaryRestartFilesShowImportDialog", "Show Import Dialog", "", "", ""); CAF_PDM_InitFieldNoDefault(&summaryRestartFilesImportMode, "summaryRestartFilesImportMode", "Default Import Mode", "", "", ""); + CAF_PDM_InitFieldNoDefault(&importRestartGridCaseFiles, "importRestartGridCaseFiles", "Import Restart Grid Cases", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 0de4885fe8..09fa39efcd 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -82,6 +82,7 @@ class RiaPreferences : public caf::PdmObject caf::PdmField summaryRestartFilesShowImportDialog; caf::PdmField summaryRestartFilesImportMode; + caf::PdmField importRestartGridCaseFiles; protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index 84f3c310d3..5f9a835886 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -272,21 +272,21 @@ bool RiaArgumentParser::parseArguments() if (caf::Utils::fileExists(caseName) && (fileExtension == "EGRID" || fileExtension == "GRID")) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseName); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), true); } else { QString caseFileNameWithExt = caseName + ".EGRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseFileNameWithExt); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), true); } else { caseFileNameWithExt = caseName + ".GRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseFileNameWithExt); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), true); } } } diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 30718b4a64..ab1fa1d7aa 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -23,6 +23,9 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RifEclipseSummaryTools.h" +#include "RifSummaryCaseRestartSelector.h" + #include "RigGridManager.h" #include "RimCaseCollection.h" @@ -50,6 +53,80 @@ #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& fileNames, bool noDialog) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + QStringList openedCaseFiles; + + // Get list of files to import + RifSummaryCaseRestartSelector selector; + if(noDialog) selector.showDialog(false); + selector.buildGridCaseFileList(true); + std::vector summaryFileInfos = selector.getFilesToImportFromGridFiles(fileNames); + + // Import eclipse case files + for (const QString& gridCaseFile : selector.gridCaseFiles()) + { + if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(gridCaseFile)) + { + openedCaseFiles.push_back(gridCaseFile); + } + } + + // Import summary cases + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(summaryFileInfos); + + for (RimSummaryCase* newSumCase : newSumCases) + { + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); + if (!gridCaseFile.isEmpty()) + { + RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); + if (existingFileSummaryCase) + { + // Replace all occurrences of file sum with ecl sum + + std::vector referringObjects; + existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); + + // UI settings of a curve filter is updated based + // on the new case association for the curves in the curve filter + // UI is updated by loadDataAndUpdate() + + for (caf::PdmObjectHandle* objHandle : referringObjects) + { + RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); + if (summaryCurve) + { + RimSummaryCurveCollection* parentCollection = nullptr; + summaryCurve->firstAncestorOrThisOfType(parentCollection); + if (parentCollection) + { + parentCollection->loadDataAndUpdate(true); + parentCollection->updateConnectedEditors(); + break; + } + } + } + + sumCaseColl->removeCase(existingFileSummaryCase); + + delete existingFileSummaryCase; + + } + + sumCaseColl->updateAllRequiredEditors(); + } + } + return openedCaseFiles; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -93,7 +170,11 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr RimProject* project = app->project(); RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : nullptr; - if (analysisModels == nullptr) return false; + if (analysisModels == nullptr) + { + delete rimResultReservoir; + return false; + } RiuMainWindow::instance()->show(); @@ -112,66 +193,6 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr riv->loadDataAndUpdate(); - // Add a corresponding summary case if it exists - { - RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; - if (sumCaseColl) - { - { - RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow(); - if (sumCaseColl->summaryCaseCount() == 0 && mainPlotWindow) - { - mainPlotWindow->hide(); - } - } - - if (!sumCaseColl->findSummaryCaseFromEclipseResultCase(rimResultReservoir)) - { - std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromEclipseResultCase(rimResultReservoir); - RimSummaryCase* newSumCase = !newSumCases.empty() ? newSumCases.front() : nullptr; - - if (newSumCase) - { - RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); - if (existingFileSummaryCase) - { - // Replace all occurrences of file sum with ecl sum - - std::vector referringObjects; - existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); - - // UI settings of a curve filter is updated based - // on the new case association for the curves in the curve filter - // UI is updated by loadDataAndUpdate() - - for (caf::PdmObjectHandle* objHandle : referringObjects) - { - RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); - if (summaryCurve) - { - RimSummaryCurveCollection* parentCollection = nullptr; - summaryCurve->firstAncestorOrThisOfType(parentCollection); - if (parentCollection) - { - parentCollection->loadDataAndUpdate(true); - parentCollection->updateConnectedEditors(); - break; - } - } - } - - sumCaseColl->removeCase(existingFileSummaryCase); - - delete existingFileSummaryCase; - - } - - sumCaseColl->updateAllRequiredEditors(); - } - } - } - } - if (!riv->cellResult()->hasResult()) { riv->cellResult()->setResultVariable(RiaDefines::undefinedResultName()); diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h index 34d9e3689a..99b15a969a 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -27,7 +27,7 @@ class QStringList; class RiaImportEclipseCaseTools { public: - static bool openEclipseCaseFromFile(const QString& fileName); + static QStringList openEclipseCasesFromFile(const QStringList& fileNames, bool noDialog = false); static bool openEclipseCaseShowTimeStepFilter(const QString& fileName); static bool openMockModel(const QString& name); @@ -35,6 +35,7 @@ class RiaImportEclipseCaseTools static bool addEclipseCases(const QStringList& fileNames); private: + static bool openEclipseCaseFromFile(const QString& fileName); static bool openEclipseCaseShowTimeStepFilterImpl(const QString& fileName, bool showTimeStepFilter); }; diff --git a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp index 09bb6ea5c4..854433eab0 100644 --- a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp +++ b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp @@ -22,6 +22,8 @@ #include "RiaLogging.h" +#include + CAF_PDM_SOURCE_INIT(RicfLoadCase, "loadCase"); //-------------------------------------------------------------------------------------------------- @@ -37,8 +39,8 @@ RicfLoadCase::RicfLoadCase() //-------------------------------------------------------------------------------------------------- void RicfLoadCase::execute() { - bool ok = RiaImportEclipseCaseTools::openEclipseCaseFromFile(m_path); - if (!ok) + QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({m_path()}), true); + if (newCaseFiles.isEmpty()) { RiaLogging::error(QString("loadCase: Unable to load case from %1").arg(m_path())); } diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index e9fcc281ea..eda6d503fa 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -54,18 +54,11 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked) if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("BINARY_GRID", defaultDir); - int i; - for (i = 0; i < fileNames.size(); i++) - { - QString fileName = fileNames[i]; + QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(fileNames); - if (!fileName.isEmpty()) - { - if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName)) - { - app->addToRecentFiles(fileName); - } - } + for (const auto newCaseFile : newCaseFiles) + { + RiaApplication::instance()->addToRecentFiles(newCaseFile); } } diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index 988a3a75b5..68b0ad053b 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -68,18 +68,11 @@ void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) // Remember the path to next time app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(result.rootDir).absoluteFilePath()); - int i; - for (i = 0; i < result.files.size(); i++) + QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(result.files); + + for (const auto newCaseFile : newCaseFiles) { - QString fileName = result.files[i]; - - if (!fileName.isEmpty()) - { - if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName)) - { - app->addToRecentFiles(fileName); - } - } + RiaApplication::instance()->addToRecentFiles(newCaseFile); } } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index f22da2cd47..bf131a7598 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -23,6 +23,8 @@ #include "RicFileHierarchyDialog.h" +#include "RifSummaryCaseRestartSelector.h" + #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" @@ -104,7 +106,10 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStri RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; if (!sumCaseColl) return false; - std::vector sumCases = sumCaseColl->createAndAddSummaryCasesFromFiles(fileNames); + RifSummaryCaseRestartSelector fileSelector; + std::vector importFileInfos = fileSelector.getFilesToImportFromSummaryFiles(fileNames); + + std::vector sumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(importFileInfos); sumCaseColl->updateAllRequiredEditors(); RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 326728a6a6..e829dfcf21 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -25,6 +25,7 @@ #include "RiaFilePathTools.h" #include "RifReaderEclipseSummary.h" +#include "RifEclipseSummaryTools.h" #include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" @@ -70,6 +71,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_readAllRadioButton = new QRadioButton(this); m_notReadRadionButton = new QRadioButton(this); m_separateCasesRadionButton = new QRadioButton(this); + m_includeGridHistoryFiles = new QCheckBox(this); m_applyToAllCheckBox = new QCheckBox(this); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -82,6 +84,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_readAllRadioButton->setText("Import All Restart Files"); m_notReadRadionButton->setText("Do Not Import Restart Files"); m_separateCasesRadionButton->setText("Import Restart Files as Separate Cases"); + m_includeGridHistoryFiles->setText("Import Historic Grid Case Files"); m_applyToAllCheckBox->setText("Apply to All Files"); // Define layout @@ -100,6 +103,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) optionsLayout->addWidget(m_readAllRadioButton); optionsLayout->addWidget(m_notReadRadionButton); optionsLayout->addWidget(m_separateCasesRadionButton); + optionsLayout->addWidget(m_includeGridHistoryFiles); optionsGroup->setLayout(optionsLayout); QHBoxLayout* buttonsLayout = new QHBoxLayout(); @@ -126,6 +130,7 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + bool buildGridCaseFileList, ReadOptions defaultReadOption, RicSummaryCaseRestartDialogResult *lastResult, QWidget *parent) @@ -138,35 +143,41 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const return RicSummaryCaseRestartDialogResult(); } - dialog.appendFileInfoToGridLayout(*dialog.m_currentFileGridLayout, currentFileInfo); - - std::vector fileInfos = dialog.getRestartFiles(summaryHeaderFile); - for (const auto& fileInfo : fileInfos) - { - dialog.appendFileInfoToGridLayout(*dialog.m_filesGridLayout, fileInfo); - } + RifReaderEclipseSummary reader; + std::vector restartFileInfos = reader.getRestartFiles(summaryHeaderFile); // If no restart files are found, do not show dialog - if (fileInfos.empty()) + if (restartFileInfos.empty()) { - return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, QStringList({ summaryHeaderFile }), false); + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); + return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, QStringList({ summaryHeaderFile }), false, false, QStringList({ gridCaseFile })); } RicSummaryCaseRestartDialogResult dialogResult; if (lastResult && lastResult->applyToAll) { dialogResult = *lastResult; - dialogResult.files.clear(); + dialogResult.summaryFiles.clear(); + dialogResult.restartGridFilesToImport.clear(); } else { dialog.setWindowTitle("Summary Case Restart Files"); + + dialog.appendFileInfoToGridLayout(*dialog.m_currentFileGridLayout, currentFileInfo); + for (const auto& restartFileInfo : restartFileInfos) + { + dialog.appendFileInfoToGridLayout(*dialog.m_filesGridLayout, restartFileInfo); + } + switch (defaultReadOption) { case ReadOptions::IMPORT_ALL: dialog.m_readAllRadioButton->setChecked(true); break; case ReadOptions::NOT_IMPORT: dialog.m_notReadRadionButton->setChecked(true); break; case ReadOptions::SEPARATE_CASES: dialog.m_separateCasesRadionButton->setChecked(true); break; } + dialog.m_includeGridHistoryFiles->setVisible(buildGridCaseFileList); + dialog.m_includeGridHistoryFiles->setChecked(lastResult->includeGridHistoryFiles); dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -174,20 +185,33 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialogResult = RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, dialog.selectedOption(), {}, - dialog.applyToAllSelected()); + dialog.applyToAllSelected(), + dialog.includeGridHistoryFiles()); } if (!dialogResult.ok) { - return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, QStringList(), false); + return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, QStringList(), false, false); } - dialogResult.files.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); if (dialogResult.option == SEPARATE_CASES) { - for (const auto& fileInfo : fileInfos) + for (const auto& restartFileInfo : restartFileInfos) + { + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(restartFileInfo.fileName)); + } + } + + if (dialogResult.includeGridHistoryFiles) + { + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); + dialogResult.restartGridFilesToImport.push_back(gridCaseFile); + + for (const auto& restartFileInfo : restartFileInfos) { - dialogResult.files.push_back(RiaFilePathTools::toInternalSeparator(fileInfo.fileName)); + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(restartFileInfo.fileName); + if (buildGridCaseFileList && !gridCaseFile.isEmpty()) dialogResult.restartGridFilesToImport.push_back(gridCaseFile); } } return dialogResult; @@ -212,6 +236,14 @@ bool RicSummaryCaseRestartDialog::applyToAllSelected() const return m_applyToAllCheckBox->isChecked(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSummaryCaseRestartDialog::includeGridHistoryFiles() const +{ + return m_includeGridHistoryFiles->isChecked(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index d480da0539..20e7e4501a 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -53,12 +53,14 @@ class RicSummaryCaseRestartDialog : public QDialog static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, + bool buildGridCaseFileList, ReadOptions defaultReadOption, RicSummaryCaseRestartDialogResult *lastResult = nullptr, QWidget *parent = nullptr); ReadOptions selectedOption() const; bool applyToAllSelected() const; + bool includeGridHistoryFiles() const; private: void appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo); @@ -78,6 +80,8 @@ private slots: QRadioButton* m_notReadRadionButton; QRadioButton* m_separateCasesRadionButton; + QCheckBox* m_includeGridHistoryFiles; + QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; }; @@ -94,13 +98,23 @@ class RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialogResult(bool _ok, RicSummaryCaseRestartDialog::ReadOptions _option, - QStringList _files, - bool _applyToAll) : - ok(_ok), option(_option), files(_files), applyToAll(_applyToAll) { + QStringList _summaryFiles, + bool _applyToAll, + bool _includeGridHistoryFiles, + QStringList _restartGridFilesToImport = {}) : + ok(_ok), + option(_option), + summaryFiles(_summaryFiles), + applyToAll(_applyToAll), + includeGridHistoryFiles(_includeGridHistoryFiles), + restartGridFilesToImport(_restartGridFilesToImport) { } bool ok; RicSummaryCaseRestartDialog::ReadOptions option; - QStringList files; + QStringList summaryFiles; bool applyToAll; + + bool includeGridHistoryFiles; + QStringList restartGridFilesToImport; }; \ No newline at end of file diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp index 3edb09a0fd..97c66f20f9 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp @@ -26,6 +26,7 @@ #include "ert/ecl/ecl_util.h" +#include #include #include @@ -128,6 +129,38 @@ QStringList RifEclipseSummaryTools::findSummaryDataFiles(const QString& caseFile return fileNames; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(const QString& summaryHeaderFile) +{ + char* myPath = nullptr; + char* myBase = nullptr; + bool formattedFile = true; + + util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(summaryHeaderFile)).data(), &myPath, &myBase, nullptr); + + char* caseFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, true, -1); + if (!caseFile) + { + caseFile= ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, false, -1); + if (caseFile) + { + formattedFile = false; + } + } + + QString gridCaseFile; + + if (caseFile) gridCaseFile = caseFile; + + util_safe_free(caseFile); + util_safe_free(myBase); + util_safe_free(myPath); + + return gridCaseFile; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -173,7 +206,7 @@ void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, char* myBase = nullptr; bool formattedFile = true; - util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, nullptr); + util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(inputFile)).data(), &myPath, &myBase, nullptr); char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1); if (!myHeaderFile) diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h index d2e99047e7..85957737b3 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h @@ -37,6 +37,7 @@ class RifEclipseSummaryTools public: static void findSummaryHeaderFile(const QString& inputFile, QString* headerFile, bool* isFormatted); static QStringList findSummaryDataFiles(const QString& caseFile); + static QString findGridCaseFileFromSummaryHeaderFile(const QString& summaryHeaderFile); static void findSummaryFiles(const QString& inputFile, QString* headerFile, QStringList* dataFiles); static bool hasSummaryFiles(const QString& gridFileName); diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index ef471b6706..5554abdeff 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -24,6 +24,8 @@ #include "RicSummaryCaseRestartDialog.h" +#include "RifEclipseSummaryTools.h" + #include #include @@ -62,7 +64,13 @@ RicSummaryCaseRestartDialog::ReadOptions mapReadOption(RiaPreferences::SummaryRe //-------------------------------------------------------------------------------------------------- RifSummaryCaseRestartSelector::RifSummaryCaseRestartSelector() { - + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + m_showDialog = prefs->summaryRestartFilesShowImportDialog(); + m_defaultRestartImportMode = mapReadOption(prefs->summaryRestartFilesImportMode()); + m_importRestartGridCaseFiles = prefs->importRestartGridCaseFiles(); + + m_buildGridCaseFileList = false; + m_gridCaseFiles.clear(); } //-------------------------------------------------------------------------------------------------- @@ -76,41 +84,53 @@ RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImport(const QStringList& selectedFiles) +std::vector RifSummaryCaseRestartSelector::getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) { - RiaApplication* app = RiaApplication::instance(); - RiaPreferences* prefs = app->preferences(); + return getFilesToImport(initialSummaryFiles); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::getFilesToImportFromGridFiles(const QStringList& initialGridFiles) +{ + QStringList summaryFiles = getSummaryFilesFromGridFiles(initialGridFiles); + return getFilesToImport(summaryFiles); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::getFilesToImport(const QStringList& initialSummaryFiles) +{ std::vector fileInfos; - if (prefs->summaryRestartFilesShowImportDialog) + if (m_showDialog) { - bool enableApplyToAllField = selectedFiles.size() > 1; - fileInfos = getFilesToImportByAskingUser(selectedFiles, enableApplyToAllField, prefs->summaryRestartFilesImportMode); + bool enableApplyToAllField = initialSummaryFiles.size() > 1; + fileInfos = getFilesToImportByAskingUser(initialSummaryFiles, enableApplyToAllField); } else { - fileInfos = getFilesToImportUsingPrefs(selectedFiles, prefs->summaryRestartFilesImportMode); + fileInfos = getFilesToImportUsingPrefs(initialSummaryFiles); } - return fileInfos; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialFiles, - bool enableApplyToAllField, - RiaPreferences::SummaryRestartFilesImportModeType defaultSummaryRestartMode) +std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialSummaryFiles, + bool enableApplyToAllField) { std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; - for (const QString& file : initialFiles) + for (const QString& summaryFile : initialSummaryFiles) { - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(file, enableApplyToAllField, mapReadOption(defaultSummaryRestartMode), &lastResult); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(summaryFile, enableApplyToAllField, m_buildGridCaseFileList, m_defaultRestartImportMode, &lastResult); if (result.ok) { - for (const QString& file : result.files) + for (const QString& file : result.summaryFiles) { RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::IMPORT_ALL); if (!vectorContains(filesToImport, fi)) @@ -119,6 +139,17 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp } } lastResult = result; + + for (const QString& gridCaseFile : result.restartGridFilesToImport) + { + m_gridCaseFiles.push_back(gridCaseFile); + } + } + else + { + // Cancel pressed, cancel everything + m_gridCaseFiles.clear(); + return std::vector(); } } return std::vector(filesToImport.begin(), filesToImport.end()); @@ -127,27 +158,40 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const QStringList& initialFiles, - RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode) +std::vector RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const QStringList& initialSummaryFiles) { std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; - for (const QString& initialFile : initialFiles) + m_gridCaseFiles.clear(); + + for (const QString& summaryFile : initialSummaryFiles) { - QString file = RiaFilePathTools::toInternalSeparator(initialFile); + QString file = RiaFilePathTools::toInternalSeparator(summaryFile); - if (summaryRestartMode == RiaPreferences::IMPORT) + if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { filesToImport.push_back(RifSummaryCaseFileInfo(file, true)); + if (m_buildGridCaseFileList) + { + m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); + } } - else if (summaryRestartMode == RiaPreferences::NOT_IMPORT) + else if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) { filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); + if (m_buildGridCaseFileList) + { + m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); + } } - else if (summaryRestartMode == RiaPreferences::SEPARATE_CASES) + else if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); + if (m_buildGridCaseFileList) + { + m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); + } RifReaderEclipseSummary reader; std::vector restartFileInfos = reader.getRestartFiles(file); @@ -157,9 +201,40 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp if (!vectorContains(filesToImport, fi)) { filesToImport.push_back(fi); + + if (m_buildGridCaseFileList) + { + m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fi.fileName)); + } } } } } return filesToImport; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(const QStringList& gridFiles) +{ + QStringList summaryFiles; + + // Find summary header file names from eclipse case file names + for (const auto& gridFile : gridFiles) + { + if (!gridFile.isEmpty()) + { + QString summaryHeaderFile; + bool formatted; + + RifEclipseSummaryTools::findSummaryHeaderFile(gridFile, &summaryHeaderFile, &formatted); + + if (!summaryHeaderFile.isEmpty()) + { + summaryFiles.push_back(summaryHeaderFile); + } + } + } + return summaryFiles; +} diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index 3c9c4d65e0..4834efb26d 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -19,13 +19,15 @@ #pragma once #include "RiaPreferences.h" +#include "RicSummaryCaseRestartDialog.h" + #include +#include #include #include #include -class QStringList; class RifSummaryCaseFileInfo; @@ -39,16 +41,28 @@ class RifSummaryCaseRestartSelector RifSummaryCaseRestartSelector(); ~RifSummaryCaseRestartSelector(); - std::vector getFilesToImport(const QStringList& selectedFiles); + std::vector getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); + std::vector getFilesToImportFromGridFiles(const QStringList& initialGridFiles); + + void showDialog(bool show) { m_showDialog = show; } + void buildGridCaseFileList(bool build) { m_buildGridCaseFileList = build; } + QStringList gridCaseFiles() const { return m_gridCaseFiles; } + + static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); private: - std::vector getFilesToImportByAskingUser(const QStringList& initialFiles, - bool enableApplyToAllField, - RiaPreferences::SummaryRestartFilesImportModeType defaultSummaryRestartMode); - std::vector getFilesToImportUsingPrefs(const QStringList& initialFiles, - RiaPreferences::SummaryRestartFilesImportModeType summaryRestartMode); + std::vector getFilesToImport(const QStringList& initialSummaryFiles); + + std::vector getFilesToImportByAskingUser(const QStringList& initialSummaryFiles, + bool enableApplyToAllField); + std::vector getFilesToImportUsingPrefs(const QStringList& initialSummaryFiles); + bool m_showDialog; + RicSummaryCaseRestartDialog::ReadOptions m_defaultRestartImportMode; + bool m_importRestartGridCaseFiles; + bool m_buildGridCaseFileList; + QStringList m_gridCaseFiles; }; //================================================================================================== diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 3b7f83298e..2626e4332a 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaProjectFileVersionTools.h" #include "RiaVersionInfo.h" +#include "RiaFilePathTools.h" #include "RigEclipseCaseData.h" #include "RigGridBase.h" @@ -860,6 +861,21 @@ std::vector RimProject::eclipseCases() const return allCases; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimProject::eclipseCaseFromGridFileName(const QString& gridFileName) const +{ + for (RimEclipseCase* eclCase : eclipseCases()) + { + if (RiaFilePathTools::toInternalSeparator(eclCase->gridFileName()) == RiaFilePathTools::toInternalSeparator(gridFileName)) + { + return eclCase; + } + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 87df663385..22e1091435 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -132,6 +132,8 @@ class RimProject : public caf::PdmDocument RimDialogData* dialogData() const; std::vector eclipseCases() const; + RimEclipseCase* eclipseCaseFromGridFileName(const QString& gridFileName) const; + std::vector simulationWellNames() const; RimWellPath* wellPathFromSimWellName(const QString& simWellName, int branchIndex = -1); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 7e452858ab..d904d80478 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -113,7 +113,12 @@ void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCa if (!isFound) { // Create new GridSummaryCase - createAndAddSummaryCasesFromEclipseResultCase(eclResCase); + QStringList summaryFileNames = RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(QStringList({ eclResCase->gridFileName() })); + if (!summaryFileNames.isEmpty()) + { + RifSummaryCaseFileInfo fileInfo(summaryFileNames.front(), false); + createAndAddSummaryCasesFromFileInfos({ fileInfo }); + } } } } @@ -291,75 +296,46 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromEclipseResultCase(RimEclipseResultCase* eclResCase) +std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) { - std::vector sumCases; - QString gridFileName = eclResCase->gridFileName(); - QString summaryHeaderFile; - bool formatted; + RimProject* project = RiaApplication::instance()->project(); - RifEclipseSummaryTools::findSummaryHeaderFile(QDir::toNativeSeparators(gridFileName), &summaryHeaderFile, &formatted); + std::vector sumCases; - if(!summaryHeaderFile.isEmpty()) + for (RifSummaryCaseFileInfo fileInfo : summaryHeaderFileInfos) { - RifSummaryCaseRestartSelector fileSelector; - std::vector importFileInfos = fileSelector.getFilesToImport(QStringList({ summaryHeaderFile })); + RimEclipseCase* eclCase = nullptr; + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.fileName); + if (!gridCaseFile.isEmpty()) + { + eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); + } - if (!importFileInfos.empty()) + if (eclCase) { RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); this->m_cases.push_back(newSumCase); - newSumCase->setIncludeRestartFiles(importFileInfos.front().includeRestartFiles); - newSumCase->setAssociatedEclipseCase(eclResCase); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); + newSumCase->setAssociatedEclipseCase(eclCase); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, importFileInfos.front().fileName); + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); sumCases.push_back(newSumCase); - - // Remove the processed element and add 'orphan' summary cases - importFileInfos.erase(importFileInfos.begin()); - - for (const RifSummaryCaseFileInfo& fileInfo : importFileInfos) - { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - - this->m_cases.push_back(newSumCase); - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); - newSumCase->setSummaryHeaderFileName(fileInfo.fileName); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); - sumCases.push_back(newSumCase); - } } - - } - return sumCases; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFiles(const QStringList& inputFileNames) -{ - std::vector sumCases; - RifSummaryCaseRestartSelector fileSelector; - std::vector importFileInfos = fileSelector.getFilesToImport(inputFileNames); + else + { + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - for (const RifSummaryCaseFileInfo& fileInfo : importFileInfos) - { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - - this->m_cases.push_back(newSumCase); - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); - newSumCase->setSummaryHeaderFileName(fileInfo.fileName); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); - sumCases.push_back(newSumCase); + this->m_cases.push_back(newSumCase); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); + newSumCase->setSummaryHeaderFileName(fileInfo.fileName); + newSumCase->createSummaryReaderInterface(); + newSumCase->updateOptionSensitivity(); + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); + sumCases.push_back(newSumCase); + } } - return sumCases; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 3c36a44132..eadb99bc8e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -25,6 +25,7 @@ class RimSummaryCase; class RimEclipseResultCase; class RimSummaryCaseCollection; +class RifSummaryCaseFileInfo; //================================================================================================== /// @@ -44,12 +45,11 @@ class RimSummaryCaseMainCollection : public caf::PdmObject std::vector summaryCaseCollections() const; void createSummaryCasesFromRelevantEclipseResultCases(); - std::vector createAndAddSummaryCasesFromEclipseResultCase(RimEclipseResultCase* eclResCase); - std::vector createAndAddSummaryCasesFromFiles(const QStringList& inputFileNames); - + std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; - + void addCase(RimSummaryCase* summaryCase); void removeCase(RimSummaryCase* summaryCase); From 9f40679f22ec62a288a7b56231d5f301d0563639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 13 Apr 2018 13:17:44 +0200 Subject: [PATCH 0667/1027] #2555 Bugfix --- ApplicationCode/Application/RiaApplication.cpp | 2 +- ApplicationCode/Application/Tools/RiaArgumentParser.cpp | 6 +++--- .../Application/Tools/RiaImportEclipseCaseTools.cpp | 8 +++----- .../Application/Tools/RiaImportEclipseCaseTools.h | 2 +- ApplicationCode/CommandFileInterface/RicfLoadCase.cpp | 4 ++-- .../EclipseCommands/RicImportEclipseCaseFeature.cpp | 3 ++- .../EclipseCommands/RicImportEclipseCasesFeature.cpp | 3 ++- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 7b5b870760..c55671f0cd 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1860,7 +1860,7 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".egrid", Qt::CaseInsensitive) || fileName.contains(".grid", Qt::CaseInsensitive)) { - loadingSucceded = !RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ fileName })).isEmpty(); + loadingSucceded = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ fileName })); } else if (fileName.contains(".grdecl", Qt::CaseInsensitive)) { diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index 5f9a835886..432dc7029c 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -272,21 +272,21 @@ bool RiaArgumentParser::parseArguments() if (caf::Utils::fileExists(caseName) && (fileExtension == "EGRID" || fileExtension == "GRID")) { - RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), true); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), nullptr, true); } else { QString caseFileNameWithExt = caseName + ".EGRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), true); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); } else { caseFileNameWithExt = caseName + ".GRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), true); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); } } } diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index ab1fa1d7aa..7d5caacd86 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -56,13 +56,11 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& fileNames, bool noDialog) +bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& fileNames, QStringList* openedFiles, bool noDialog) { RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); - QStringList openedCaseFiles; - // Get list of files to import RifSummaryCaseRestartSelector selector; if(noDialog) selector.showDialog(false); @@ -74,7 +72,7 @@ QStringList RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringLis { if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(gridCaseFile)) { - openedCaseFiles.push_back(gridCaseFile); + if(openedFiles) openedFiles->push_back(gridCaseFile); } } @@ -124,7 +122,7 @@ QStringList RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringLis sumCaseColl->updateAllRequiredEditors(); } } - return openedCaseFiles; + return true; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h index 99b15a969a..90941a0ff2 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -27,7 +27,7 @@ class QStringList; class RiaImportEclipseCaseTools { public: - static QStringList openEclipseCasesFromFile(const QStringList& fileNames, bool noDialog = false); + static bool openEclipseCasesFromFile(const QStringList& fileNames, QStringList* openedFiles = nullptr, bool noDialog = false); static bool openEclipseCaseShowTimeStepFilter(const QString& fileName); static bool openMockModel(const QString& name); diff --git a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp index 854433eab0..fc80ad6a49 100644 --- a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp +++ b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp @@ -39,8 +39,8 @@ RicfLoadCase::RicfLoadCase() //-------------------------------------------------------------------------------------------------- void RicfLoadCase::execute() { - QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({m_path()}), true); - if (newCaseFiles.isEmpty()) + bool ok = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({m_path()}), nullptr, true); + if (!ok) { RiaLogging::error(QString("loadCase: Unable to load case from %1").arg(m_path())); } diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index eda6d503fa..5a21716256 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -54,7 +54,8 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked) if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("BINARY_GRID", defaultDir); - QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(fileNames); + QStringList newCaseFiles; + RiaImportEclipseCaseTools::openEclipseCasesFromFile(fileNames, &newCaseFiles); for (const auto newCaseFile : newCaseFiles) { diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index 68b0ad053b..aa67053010 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -68,7 +68,8 @@ void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) // Remember the path to next time app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(result.rootDir).absoluteFilePath()); - QStringList newCaseFiles = RiaImportEclipseCaseTools::openEclipseCasesFromFile(result.files); + QStringList newCaseFiles; + RiaImportEclipseCaseTools::openEclipseCasesFromFile(result.files, &newCaseFiles); for (const auto newCaseFile : newCaseFiles) { From e5e9692eb5460beb93875a3dfa1221c2b477ddfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 13 Apr 2018 15:44:28 +0200 Subject: [PATCH 0668/1027] #2710, #2719 Restart preference and dialog adjustments. And some bugfixes --- .../Application/RiaPreferences.cpp | 26 ++- ApplicationCode/Application/RiaPreferences.h | 4 +- .../Tools/RiaImportEclipseCaseTools.cpp | 3 +- .../Commands/RicSummaryCaseRestartDialog.cpp | 168 ++++++++++++------ .../Commands/RicSummaryCaseRestartDialog.h | 61 ++++--- .../FileInterface/RifReaderEclipseSummary.h | 2 + .../RifSummaryCaseRestartSelector.cpp | 69 +++---- .../RifSummaryCaseRestartSelector.h | 12 +- 8 files changed, 215 insertions(+), 130 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index f3e890336c..d23e0540ab 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -32,9 +32,9 @@ namespace caf template<> void RiaPreferences::SummaryRestartFilesImportModeType::setUp() { - addItem(RiaPreferences::IMPORT, "IMPORT", "Always import"); - addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Never import"); - addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Import as separate summary cases"); + addItem(RiaPreferences::IMPORT, "IMPORT", "Unified"); + addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Skip"); + addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Separate Cases"); setDefault(RiaPreferences::IMPORT); } } @@ -102,8 +102,8 @@ RiaPreferences::RiaPreferences(void) loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitFieldNoDefault(&summaryRestartFilesShowImportDialog, "summaryRestartFilesShowImportDialog", "Show Import Dialog", "", "", ""); - CAF_PDM_InitFieldNoDefault(&summaryRestartFilesImportMode, "summaryRestartFilesImportMode", "Default Import Mode", "", "", ""); - CAF_PDM_InitFieldNoDefault(&importRestartGridCaseFiles, "importRestartGridCaseFiles", "Import Restart Grid Cases", "", "", ""); + CAF_PDM_InitField(&summaryImportMode, "summaryImportMode", SummaryRestartFilesImportModeType(RiaPreferences::IMPORT), "Default Summary Import Option", "", "", ""); + CAF_PDM_InitField(&gridImportMode, "gridImportMode", SummaryRestartFilesImportModeType(RiaPreferences::NOT_IMPORT), "Default Grid Import Option", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; @@ -193,9 +193,12 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& m_readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup); - caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Summary Restart Files"); + caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Restart Files"); restartBehaviourGroup->add(&summaryRestartFilesShowImportDialog); - restartBehaviourGroup->add(&summaryRestartFilesImportMode); + caf::PdmUiGroup* summaryImportOptionGroup = restartBehaviourGroup->addNewGroup("Origin Summary Files"); + summaryImportOptionGroup->add(&summaryImportMode); + caf::PdmUiGroup* gridImportOptionGroup = restartBehaviourGroup->addNewGroup("Origin Grid Files"); + gridImportOptionGroup->add(&gridImportMode); } else if (uiConfigName == m_tabNames[2]) { @@ -240,6 +243,15 @@ QList RiaPreferences::calculateValueOptions(const caf::P options.push_back(caf::PdmOptionItemInfo(fontSizes[oIdx], fontSizes[oIdx])); } } + else if (fieldNeedingOptions == &gridImportMode) + { + // Manual option handling in order to one only a subset of the enum values + SummaryRestartFilesImportModeType skip(RiaPreferences::NOT_IMPORT); + SummaryRestartFilesImportModeType separate(RiaPreferences::SEPARATE_CASES); + + options.push_back(caf::PdmOptionItemInfo(skip.uiText(), RiaPreferences::NOT_IMPORT)); + options.push_back(caf::PdmOptionItemInfo(separate.uiText(), RiaPreferences::SEPARATE_CASES)); + } return options; } diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 09fa39efcd..4b2f9c532b 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -81,8 +81,8 @@ class RiaPreferences : public caf::PdmObject caf::PdmField loadAndShowSoil; caf::PdmField summaryRestartFilesShowImportDialog; - caf::PdmField summaryRestartFilesImportMode; - caf::PdmField importRestartGridCaseFiles; + caf::PdmField summaryImportMode; + caf::PdmField gridImportMode; protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 7d5caacd86..8ec09c909e 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -83,7 +83,8 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file for (RimSummaryCase* newSumCase : newSumCases) { QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); - if (!gridCaseFile.isEmpty()) + RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); + if (gridCase) { RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); if (existingFileSummaryCase) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index e829dfcf21..144c4aafa6 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -67,11 +67,12 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) : QDialog(parent, RiuTools::defaultDialogFlags()) { // Create widgets - m_currentFileGridLayout = new QGridLayout(); - m_readAllRadioButton = new QRadioButton(this); - m_notReadRadionButton = new QRadioButton(this); - m_separateCasesRadionButton = new QRadioButton(this); - m_includeGridHistoryFiles = new QCheckBox(this); + m_currentSummaryFileLayout = new QGridLayout(); + m_summaryReadAllBtn = new QRadioButton(this); + m_summarySeparateCasesBtn = new QRadioButton(this); + m_summaryNotReadBtn = new QRadioButton(this); + m_gridSeparateCasesBtn = new QRadioButton(this); + m_gridNotReadBtn = new QRadioButton(this); m_applyToAllCheckBox = new QCheckBox(this); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); @@ -81,38 +82,65 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); // Set widget properties - m_readAllRadioButton->setText("Import All Restart Files"); - m_notReadRadionButton->setText("Do Not Import Restart Files"); - m_separateCasesRadionButton->setText("Import Restart Files as Separate Cases"); - m_includeGridHistoryFiles->setText("Import Historic Grid Case Files"); + m_summaryReadAllBtn->setText("Unified"); + m_summarySeparateCasesBtn->setText("Separate Cases"); + m_summaryNotReadBtn->setText("Skip"); + m_gridSeparateCasesBtn->setText("Separate Cases"); + m_gridNotReadBtn->setText("Skip"); m_applyToAllCheckBox->setText("Apply to All Files"); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); QGroupBox* currentFileGroup = new QGroupBox("Current Summary File"); - m_currentFileGridLayout = new QGridLayout(); - currentFileGroup->setLayout(m_currentFileGridLayout); + m_currentSummaryFileLayout = new QGridLayout(); + currentFileGroup->setLayout(m_currentSummaryFileLayout); - QGroupBox* filesGroup = new QGroupBox("Found Restart Files"); - m_filesGridLayout = new QGridLayout(); - filesGroup->setLayout(m_filesGridLayout); + // Summary files + QGroupBox* summaryFilesGroup = new QGroupBox("Found Origin Summary Files"); + { + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); + summaryFilesGroup->setLayout(filesGroupLayout); + + m_summaryFilesLayout = new QGridLayout(); + filesGroupLayout->addLayout(m_summaryFilesLayout); + m_summaryFilesLayout->setContentsMargins(0, 0, 0, 20); + + QGroupBox* optionsGroup = new QGroupBox("Import Options"); + QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsGroup->setLayout(optionsLayout); + optionsLayout->addWidget(m_summaryReadAllBtn); + optionsLayout->addWidget(m_summarySeparateCasesBtn); + optionsLayout->addWidget(m_summaryNotReadBtn); + filesGroupLayout->addWidget(optionsGroup); + } - QGroupBox* optionsGroup = new QGroupBox("Read Options"); - QVBoxLayout* optionsLayout = new QVBoxLayout(); - optionsLayout->addWidget(m_readAllRadioButton); - optionsLayout->addWidget(m_notReadRadionButton); - optionsLayout->addWidget(m_separateCasesRadionButton); - optionsLayout->addWidget(m_includeGridHistoryFiles); - optionsGroup->setLayout(optionsLayout); + // Grid files + m_gridFilesGroup = new QGroupBox("Found Origin Grid Files"); + { + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); + m_gridFilesGroup->setLayout(filesGroupLayout); + + m_gridFilesLayout = new QGridLayout(); + filesGroupLayout->addLayout(m_gridFilesLayout); + m_gridFilesLayout->setContentsMargins(0, 0, 0, 20); + + QGroupBox* optionsGroup = new QGroupBox("Import Options"); + QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsGroup->setLayout(optionsLayout); + optionsLayout->addWidget(m_gridSeparateCasesBtn); + optionsLayout->addWidget(m_gridNotReadBtn); + filesGroupLayout->addWidget(optionsGroup); + } + // Apply to all checkbox and buttons QHBoxLayout* buttonsLayout = new QHBoxLayout(); buttonsLayout->addWidget(m_applyToAllCheckBox); buttonsLayout->addWidget(m_buttons); dialogLayout->addWidget(currentFileGroup); - dialogLayout->addWidget(filesGroup); - dialogLayout->addWidget(optionsGroup); + dialogLayout->addWidget(summaryFilesGroup); + dialogLayout->addWidget(m_gridFilesGroup); dialogLayout->addLayout(buttonsLayout); setLayout(dialogLayout); @@ -131,7 +159,8 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, bool buildGridCaseFileList, - ReadOptions defaultReadOption, + ImportOptions defaultSummaryImportOption, + ImportOptions defaultGridImportOption, RicSummaryCaseRestartDialogResult *lastResult, QWidget *parent) { @@ -144,13 +173,13 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } RifReaderEclipseSummary reader; - std::vector restartFileInfos = reader.getRestartFiles(summaryHeaderFile); + std::vector originFileInfos = reader.getRestartFiles(summaryHeaderFile); // If no restart files are found, do not show dialog - if (restartFileInfos.empty()) + if (originFileInfos.empty()) { QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); - return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, QStringList({ summaryHeaderFile }), false, false, QStringList({ gridCaseFile })); + return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ summaryHeaderFile }), QStringList({ gridCaseFile }), false); } RicSummaryCaseRestartDialogResult dialogResult; @@ -158,60 +187,84 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const { dialogResult = *lastResult; dialogResult.summaryFiles.clear(); - dialogResult.restartGridFilesToImport.clear(); + dialogResult.gridFiles.clear(); } else { - dialog.setWindowTitle("Summary Case Restart Files"); + dialog.setWindowTitle("Restart Files"); + + dialog.appendFileInfoToGridLayout(*dialog.m_currentSummaryFileLayout, currentFileInfo); + for (const auto& ofi : originFileInfos) + { + dialog.appendFileInfoToGridLayout(*dialog.m_summaryFilesLayout, ofi); + } - dialog.appendFileInfoToGridLayout(*dialog.m_currentFileGridLayout, currentFileInfo); - for (const auto& restartFileInfo : restartFileInfos) + switch (defaultSummaryImportOption) { - dialog.appendFileInfoToGridLayout(*dialog.m_filesGridLayout, restartFileInfo); + case ImportOptions::IMPORT_ALL: dialog.m_summaryReadAllBtn->setChecked(true); break; + case ImportOptions::SEPARATE_CASES: dialog.m_summarySeparateCasesBtn->setChecked(true); break; + case ImportOptions::NOT_IMPORT: dialog.m_summaryNotReadBtn->setChecked(true); break; } - switch (defaultReadOption) + dialog.m_gridFilesGroup->setVisible(buildGridCaseFileList); + if (buildGridCaseFileList) { - case ReadOptions::IMPORT_ALL: dialog.m_readAllRadioButton->setChecked(true); break; - case ReadOptions::NOT_IMPORT: dialog.m_notReadRadionButton->setChecked(true); break; - case ReadOptions::SEPARATE_CASES: dialog.m_separateCasesRadionButton->setChecked(true); break; + bool gridFilesAdded = false; + for (const auto& ofi : originFileInfos) + { + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); + if (QFileInfo(gridFile).exists()) + { + dialog.appendFileInfoToGridLayout(*dialog.m_gridFilesLayout, RifRestartFileInfo(gridFile, ofi.startDate, ofi.endDate)); + gridFilesAdded = true; + } + } + if (!gridFilesAdded) dialog.m_gridFilesGroup->setVisible(false); + + switch (defaultGridImportOption) + { + case ImportOptions::SEPARATE_CASES: dialog.m_gridSeparateCasesBtn->setChecked(true); break; + case ImportOptions::NOT_IMPORT: dialog.m_gridNotReadBtn->setChecked(true); break; + } } - dialog.m_includeGridHistoryFiles->setVisible(buildGridCaseFileList); - dialog.m_includeGridHistoryFiles->setChecked(lastResult->includeGridHistoryFiles); dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); dialogResult = RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, - dialog.selectedOption(), + dialog.selectedSummaryImportOption(), + dialog.selectedGridImportOption(), {}, - dialog.applyToAllSelected(), - dialog.includeGridHistoryFiles()); + {}, + dialog.applyToAllSelected()); } if (!dialogResult.ok) { - return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, QStringList(), false, false); + return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); } dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); - if (dialogResult.option == SEPARATE_CASES) + if (dialogResult.summaryImportOption == SEPARATE_CASES) { - for (const auto& restartFileInfo : restartFileInfos) + for (const auto& ofi : originFileInfos) { - dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(restartFileInfo.fileName)); + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(ofi.fileName)); } } - if (dialogResult.includeGridHistoryFiles) + if (buildGridCaseFileList) { QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); - dialogResult.restartGridFilesToImport.push_back(gridCaseFile); + dialogResult.gridFiles.push_back(gridCaseFile); - for (const auto& restartFileInfo : restartFileInfos) + if (dialogResult.gridImportOption == SEPARATE_CASES) { - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(restartFileInfo.fileName); - if (buildGridCaseFileList && !gridCaseFile.isEmpty()) dialogResult.restartGridFilesToImport.push_back(gridCaseFile); + for (const auto& ofi : originFileInfos) + { + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); + if (buildGridCaseFileList && !gridCaseFile.isEmpty()) dialogResult.gridFiles.push_back(gridFile); + } } } return dialogResult; @@ -220,28 +273,29 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCaseRestartDialog::ReadOptions RicSummaryCaseRestartDialog::selectedOption() const +RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedSummaryImportOption() const { return - m_readAllRadioButton->isChecked() ? IMPORT_ALL : - m_separateCasesRadionButton->isChecked() ? SEPARATE_CASES : + m_summaryReadAllBtn->isChecked() ? IMPORT_ALL : + m_summarySeparateCasesBtn->isChecked() ? SEPARATE_CASES : NOT_IMPORT; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCaseRestartDialog::applyToAllSelected() const +RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedGridImportOption() const { - return m_applyToAllCheckBox->isChecked(); + return + m_gridSeparateCasesBtn->isChecked() ? SEPARATE_CASES : NOT_IMPORT; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCaseRestartDialog::includeGridHistoryFiles() const +bool RicSummaryCaseRestartDialog::applyToAllSelected() const { - return m_includeGridHistoryFiles->isChecked(); + return m_applyToAllCheckBox->isChecked(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 20e7e4501a..58b408d61e 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -36,6 +36,7 @@ class QMainWindow; class QListWidget; class QGridLayout; class QCheckBox; +class QGroupBox; class RicSummaryCaseRestartDialogResult; //================================================================================================== @@ -46,7 +47,7 @@ class RicSummaryCaseRestartDialog : public QDialog Q_OBJECT public: - enum ReadOptions { NOT_IMPORT, IMPORT_ALL, SEPARATE_CASES }; + enum ImportOptions { IMPORT_ALL, SEPARATE_CASES, NOT_IMPORT }; RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); @@ -54,13 +55,14 @@ class RicSummaryCaseRestartDialog : public QDialog static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, bool showApplyToAllWidget, bool buildGridCaseFileList, - ReadOptions defaultReadOption, + ImportOptions defaultSummaryImportOption, + ImportOptions defaultGridImportOption, RicSummaryCaseRestartDialogResult *lastResult = nullptr, QWidget *parent = nullptr); - ReadOptions selectedOption() const; + ImportOptions selectedSummaryImportOption() const; + ImportOptions selectedGridImportOption() const; bool applyToAllSelected() const; - bool includeGridHistoryFiles() const; private: void appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo); @@ -72,15 +74,19 @@ private slots: void slotDialogCancelClicked(); private: - QGridLayout* m_currentFileGridLayout; + QGridLayout* m_currentSummaryFileLayout; - QGridLayout* m_filesGridLayout; + QGridLayout* m_summaryFilesLayout; - QRadioButton* m_readAllRadioButton; - QRadioButton* m_notReadRadionButton; - QRadioButton* m_separateCasesRadionButton; + QRadioButton* m_summaryReadAllBtn; + QRadioButton* m_summarySeparateCasesBtn; + QRadioButton* m_summaryNotReadBtn; - QCheckBox* m_includeGridHistoryFiles; + QGroupBox* m_gridFilesGroup; + QGridLayout* m_gridFilesLayout; + + QRadioButton* m_gridNotReadBtn; + QRadioButton* m_gridSeparateCasesBtn; QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; @@ -94,27 +100,30 @@ class RicSummaryCaseRestartDialogResult { public: RicSummaryCaseRestartDialogResult() : - ok(false), option(RicSummaryCaseRestartDialog::IMPORT_ALL), applyToAll(false) {} + ok(false), + summaryImportOption(RicSummaryCaseRestartDialog::IMPORT_ALL), + gridImportOption(RicSummaryCaseRestartDialog::NOT_IMPORT), + applyToAll(false) {} RicSummaryCaseRestartDialogResult(bool _ok, - RicSummaryCaseRestartDialog::ReadOptions _option, + RicSummaryCaseRestartDialog::ImportOptions _summaryImportOption, + RicSummaryCaseRestartDialog::ImportOptions _gridImportOption, QStringList _summaryFiles, - bool _applyToAll, - bool _includeGridHistoryFiles, - QStringList _restartGridFilesToImport = {}) : + QStringList _gridFiles, + bool _applyToAll) : ok(_ok), - option(_option), + summaryImportOption(_summaryImportOption), + gridImportOption(_gridImportOption), summaryFiles(_summaryFiles), - applyToAll(_applyToAll), - includeGridHistoryFiles(_includeGridHistoryFiles), - restartGridFilesToImport(_restartGridFilesToImport) { + gridFiles(_gridFiles), + applyToAll(_applyToAll) + { } - bool ok; - RicSummaryCaseRestartDialog::ReadOptions option; - QStringList summaryFiles; - bool applyToAll; - - bool includeGridHistoryFiles; - QStringList restartGridFilesToImport; + bool ok; + RicSummaryCaseRestartDialog::ImportOptions summaryImportOption; + RicSummaryCaseRestartDialog::ImportOptions gridImportOption; + QStringList summaryFiles; + QStringList gridFiles; + bool applyToAll; }; \ No newline at end of file diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index 656ead8d49..1d352e4fec 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -38,6 +38,8 @@ class RifRestartFileInfo { public: RifRestartFileInfo() : startDate(0), endDate(0) {} + RifRestartFileInfo(const QString& _fileName, time_t _startDate, time_t _endDate) : + fileName(_fileName), startDate(_startDate), endDate(_endDate) {} bool valid() { return !fileName.isEmpty(); } QString fileName; diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 5554abdeff..709ee37f0f 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -51,12 +51,12 @@ bool vectorContains(const std::vector& vector, T item) //-------------------------------------------------------------------------------------------------- /// INternal function //-------------------------------------------------------------------------------------------------- -RicSummaryCaseRestartDialog::ReadOptions mapReadOption(RiaPreferences::SummaryRestartFilesImportMode mode) +RicSummaryCaseRestartDialog::ImportOptions mapReadOption(RiaPreferences::SummaryRestartFilesImportMode mode) { return - mode == RiaPreferences::SummaryRestartFilesImportMode::NOT_IMPORT ? RicSummaryCaseRestartDialog::ReadOptions::NOT_IMPORT : - mode == RiaPreferences::SummaryRestartFilesImportMode::SEPARATE_CASES ? RicSummaryCaseRestartDialog::ReadOptions::SEPARATE_CASES : - RicSummaryCaseRestartDialog::ReadOptions::IMPORT_ALL; + mode == RiaPreferences::SummaryRestartFilesImportMode::NOT_IMPORT ? RicSummaryCaseRestartDialog::ImportOptions::NOT_IMPORT : + mode == RiaPreferences::SummaryRestartFilesImportMode::SEPARATE_CASES ? RicSummaryCaseRestartDialog::ImportOptions::SEPARATE_CASES : + RicSummaryCaseRestartDialog::ImportOptions::IMPORT_ALL; } //-------------------------------------------------------------------------------------------------- @@ -66,11 +66,11 @@ RifSummaryCaseRestartSelector::RifSummaryCaseRestartSelector() { RiaPreferences* prefs = RiaApplication::instance()->preferences(); m_showDialog = prefs->summaryRestartFilesShowImportDialog(); - m_defaultRestartImportMode = mapReadOption(prefs->summaryRestartFilesImportMode()); - m_importRestartGridCaseFiles = prefs->importRestartGridCaseFiles(); + m_defaultSummaryImportMode = mapReadOption(prefs->summaryImportMode()); + m_defaultGridImportMode = mapReadOption(prefs->gridImportMode()); - m_buildGridCaseFileList = false; - m_gridCaseFiles.clear(); + m_buildGridFileList = false; + m_gridFiles.clear(); } //-------------------------------------------------------------------------------------------------- @@ -127,12 +127,17 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp for (const QString& summaryFile : initialSummaryFiles) { - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(summaryFile, enableApplyToAllField, m_buildGridCaseFileList, m_defaultRestartImportMode, &lastResult); + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(summaryFile, + enableApplyToAllField, + m_buildGridFileList, + m_defaultSummaryImportMode, + m_defaultGridImportMode, + &lastResult); if (result.ok) { for (const QString& file : result.summaryFiles) { - RifSummaryCaseFileInfo fi(file, result.option == RicSummaryCaseRestartDialog::IMPORT_ALL); + RifSummaryCaseFileInfo fi(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); if (!vectorContains(filesToImport, fi)) { filesToImport.push_back(fi); @@ -140,15 +145,15 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp } lastResult = result; - for (const QString& gridCaseFile : result.restartGridFilesToImport) + for (const QString& gridFile : result.gridFiles) { - m_gridCaseFiles.push_back(gridCaseFile); + m_gridFiles.push_back(gridFile); } } else { // Cancel pressed, cancel everything - m_gridCaseFiles.clear(); + m_gridFiles.clear(); return std::vector(); } } @@ -163,35 +168,23 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; - m_gridCaseFiles.clear(); + m_gridFiles.clear(); for (const QString& summaryFile : initialSummaryFiles) { QString file = RiaFilePathTools::toInternalSeparator(summaryFile); - if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) + if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { filesToImport.push_back(RifSummaryCaseFileInfo(file, true)); - if (m_buildGridCaseFileList) - { - m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); - } } - else if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) { filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); - if (m_buildGridCaseFileList) - { - m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); - } } - else if (m_defaultRestartImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); - if (m_buildGridCaseFileList) - { - m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); - } RifReaderEclipseSummary reader; std::vector restartFileInfos = reader.getRestartFiles(file); @@ -201,10 +194,24 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp if (!vectorContains(filesToImport, fi)) { filesToImport.push_back(fi); + } + } + } + + if (m_buildGridFileList) + { + m_gridFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); - if (m_buildGridCaseFileList) + if (m_defaultGridImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + { + RifReaderEclipseSummary reader; + std::vector restartFileInfos = reader.getRestartFiles(file); + for (const auto& rfi : restartFileInfos) + { + RifSummaryCaseFileInfo fi(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName), false); + if (!m_gridFiles.contains(fi.fileName) && QFileInfo(fi.fileName).exists()) { - m_gridCaseFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fi.fileName)); + m_gridFiles.push_back(fi.fileName); } } } diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index 4834efb26d..f3f73a1274 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -45,8 +45,8 @@ class RifSummaryCaseRestartSelector std::vector getFilesToImportFromGridFiles(const QStringList& initialGridFiles); void showDialog(bool show) { m_showDialog = show; } - void buildGridCaseFileList(bool build) { m_buildGridCaseFileList = build; } - QStringList gridCaseFiles() const { return m_gridCaseFiles; } + void buildGridCaseFileList(bool build) { m_buildGridFileList = build; } + QStringList gridCaseFiles() const { return m_gridFiles; } static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); @@ -58,11 +58,11 @@ class RifSummaryCaseRestartSelector std::vector getFilesToImportUsingPrefs(const QStringList& initialSummaryFiles); bool m_showDialog; - RicSummaryCaseRestartDialog::ReadOptions m_defaultRestartImportMode; - bool m_importRestartGridCaseFiles; + RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; + RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; - bool m_buildGridCaseFileList; - QStringList m_gridCaseFiles; + bool m_buildGridFileList; + QStringList m_gridFiles; }; //================================================================================================== From cdc613f33488906f07a00445e7c9e166b7f83fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 16 Apr 2018 08:43:56 +0200 Subject: [PATCH 0669/1027] #2699 Update ecllib from statoil master repo commit b31b055af2d6b887f47aec84c65ec497a5d12973 --- ResInsightVersion.cmake | 2 +- ThirdParty/Ert/CMakeLists.txt | 5 +- ThirdParty/Ert/applications/CMakeLists.txt | 2 +- ThirdParty/Ert/lib/CMakeLists.txt | 5 +- ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 +- ThirdParty/Ert/lib/ecl/ecl_smspec.c | 27 ++- ThirdParty/Ert/lib/ecl/ecl_sum.c | 4 - ThirdParty/Ert/lib/ecl/ecl_sum_data.c | 186 ++++++------------ ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h | 2 - .../Ert/lib/include/ert/ecl/ecl_sum_data.h | 5 - ThirdParty/Ert/lib/include/ert/util/util.h | 3 + ThirdParty/Ert/lib/util/util.c | 1 - .../Ert/python/ecl/util/test/test_area.py | 48 ++--- 13 files changed, 116 insertions(+), 184 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index bcdc08f54f..07e0aaefc2 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -16,7 +16,7 @@ set(RESINSIGHT_DEV_VERSION ".108") set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") # https://github.com/Statoil/libecl -set(ECL_GITHUB_SHA "f3e2954101d06fd21c952fb4f039201f20a623de") +set(ECL_GITHUB_SHA "b31b055af2d6b887f47aec84c65ec497a5d12973") # https://github.com/OPM/opm-flowdiagnostics set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f") diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 070dc78d7e..4fc4cc86d7 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -357,9 +357,6 @@ if (ENABLE_PYTHON) endif() endif() -if (INSTALL_ERT) - install(EXPORT ecl-config DESTINATION share/cmake/ecl) -endif() - +install(EXPORT ecl-config DESTINATION share/cmake/ecl) export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/applications/CMakeLists.txt b/ThirdParty/Ert/applications/CMakeLists.txt index 1000455f91..d2a2ed6e8c 100644 --- a/ThirdParty/Ert/applications/CMakeLists.txt +++ b/ThirdParty/Ert/applications/CMakeLists.txt @@ -33,7 +33,7 @@ if (BUILD_APPLICATIONS) if (ERT_LINUX) - foreach (app convert esummary grdecl_test kw_list) + foreach (app convert grdecl_test kw_list) add_executable(${app} ecl/${app}.c) target_link_libraries(${app} ecl) # The stupid .x extension creates problems on windows diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index 389b5448f4..cd13891963 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -84,7 +84,6 @@ add_library(ecl util/rng.c util/stringlist.c util/buffer.c util/timer.c - util/time_interval.c util/string_util.c util/type_vector_functions.c util/ecl_version.c @@ -191,7 +190,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) -if (INSTALL_ERT) + install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -216,7 +215,6 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () -endif() if (NOT BUILD_TESTS) return () @@ -243,7 +241,6 @@ foreach (name ert_util_alloc_file_components ert_util_stringlist_test ert_util_string_util ert_util_strstr_int_format - ert_util_time_interval ert_util_type_vector_functions ert_util_vector_test ert_util_datetime diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c index 52d40a9aab..e8d9cef33a 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c @@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - - if (doubhead_kw) - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = NULL; + const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); - if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) - doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); - if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/ecl_smspec.c index c725d5d2f2..ebdd880dee 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -508,6 +509,11 @@ void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_SUMMARY_HEADER_FILE , fmt_file , 0 ); fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP); + if (!fortio) { + char * error_fmt_msg = "%s: Unable to open fortio file %s, error: %s .\n"; + util_abort( error_fmt_msg , __func__ , filename , strerror( errno ) ); + } + ecl_smspec_fortio_fwrite( smspec , fortio ); fortio_fclose( fortio ); @@ -1032,7 +1038,7 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi char * restart_base; int i; tmp_base[0] = '\0'; - for (i=0; i < ecl_kw_get_size( restart_kw ); i++) + for (i=0; i < ecl_kw_get_size( restart_kw ); i++) strcat( tmp_base , ecl_kw_iget_ptr( restart_kw , i )); restart_base = util_alloc_strip_copy( tmp_base ); @@ -1040,6 +1046,25 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi char * path; char * smspec_header; + /* + The conditional block here is to support the following situation: + + 1. A simulation with a restart has been performed on Posix with path + separator '/'. + + 2. The simulation is loaded on windows, where the native path + separator is '\'. + + This code block will translate '/' -> '\' in the restart keyword which + is read from the summary file. + */ +#ifdef ERT_WINDOWS + for (int i=0; i < strlen(restart_base); i++) { + if (restart_base[i] == UTIL_POSIX_PATH_SEP_CHAR) + restart_base[i] = UTIL_PATH_SEP_CHAR; + } +#endif + util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL ); smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0); if (!util_same_file(smspec_header , ecl_smspec->header_file)) /* Restart from the current case is ignored. */ { diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.c b/ThirdParty/Ert/lib/ecl/ecl_sum.c index 57692fe185..3d5d0ed627 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -972,9 +971,6 @@ time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index ) { return ecl_sum_data_iget_sim_time( ecl_sum->data , index ); } -const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) { - return ecl_sum_data_get_sim_time( ecl_sum->data ); -} time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ) { return ecl_sum_data_get_data_start( ecl_sum->data ); diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c b/ThirdParty/Ert/lib/ecl/ecl_sum_data.c index 73d29f763f..6f38d91f21 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -207,25 +206,21 @@ #define INVALID_MINISTEP_NR -1 - +#define INVALID_TIME_T 0 struct ecl_sum_data_struct { ecl_smspec_type * smspec; /* A shared reference - only used for providing good error messages. */ vector_type * data; /* Vector of ecl_sum_tstep_type instances. */ - int first_ministep; - int last_ministep; double days_start; double sim_length; int_vector_type * report_first_index ; /* Indexed by report_step - giving first internal_index in report_step. */ int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */ int first_report_step; int last_report_step; - time_t __min_time; /* An internal member used during the load of - restarted cases; see doc in ecl_sum_data_append_tstep. */ bool index_valid; - time_interval_type * sim_time; /* The time interval sim_time goes from the first time value where we have - data to the end of the simulation. In the case of restarts the start - value might disagree with the simulation start reported by the smspec file. */ + time_t start_time; /* In the case of restarts the start might disagree with the value reported + in the smspec file. */ + time_t end_time; }; @@ -238,7 +233,6 @@ struct ecl_sum_data_struct { vector_free( data->data ); int_vector_free( data->report_first_index ); int_vector_free( data->report_last_index ); - time_interval_free( data->sim_time ); free(data); } @@ -257,10 +251,9 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { data->last_report_step = -1024 * 1024; data->days_start = 0; data->sim_length = -1; - data->first_ministep = INVALID_MINISTEP_NR; - data->last_ministep = INVALID_MINISTEP_NR; data->index_valid = false; - time_interval_reopen( data->sim_time ); + data->start_time = INVALID_TIME_T; + data->end_time = INVALID_TIME_T; } @@ -268,11 +261,9 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { ecl_sum_data_type * data = util_malloc( sizeof * data ); data->data = vector_alloc_new(); data->smspec = smspec; - data->__min_time = 0; data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); data->report_last_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); - data->sim_time = time_interval_alloc_open(); ecl_sum_data_clear_index( data ); return data; @@ -439,11 +430,10 @@ void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case -const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data) { return data->sim_time; } -time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return time_interval_get_end( data->sim_time ); } +time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return data->end_time; } -time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return time_interval_get_start( data->sim_time ); } +time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return data->start_time; } double ecl_sum_data_get_first_day( const ecl_sum_data_type * data) { return data->days_start; } @@ -472,8 +462,13 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { */ bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - return (time_interval_contains(data->sim_time, sim_time) - || (sim_time == time_interval_get_end(data->sim_time))); + if (sim_time < data->start_time) + return false; + + if (sim_time > data->end_time) + return false; + + return true; } @@ -522,15 +517,12 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - time_t data_start_time = time_interval_get_start(data->sim_time); - time_t sim_end = time_interval_get_end(data->sim_time); - if (!ecl_sum_data_check_sim_time(data, sim_time)) { fprintf(stderr , "Simulation start: "); util_fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr ); - fprintf(stderr , "Data start......: "); util_fprintf_date_utc( data_start_time , stderr ); - fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( sim_end , stderr ); + fprintf(stderr , "Data start......: "); util_fprintf_date_utc( data->start_time , stderr ); + fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( data->end_time , stderr ); fprintf(stderr , "Requested date .: "); util_fprintf_date_utc( sim_time , stderr ); - util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , sim_end); + util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data->start_time , data->end_time); } /* @@ -683,48 +675,11 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , ecl_sum_tste sorted by ministep_nr before the data instance is returned. */ - /* - We keep track of the earliest (in true time sence) tstep we - have added so far; this is done somewhat manuyally because we need - this information before the index is ready. - - The __min_time field is used to limit loading of restarted data in - time periods where both the main case and the source case we have - restarted from have data. This situation typically arises when we - have restarted a simulation from a report step before the end of - the initial simulation: - - Simulation 1: T1-------------TR------------T2 - | - Simulation 2: \-----------------------T3 - - - In the time interval [TR,T2] we have data from two simulations, we - want to use only the data from simulation 2 in this period. The - decision whether to to actually append the ministep or not must - have been performed by the scope calling this function; when a - ministep has arrived here it will be added. - */ - - if (data->__min_time == 0) - data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); - else { - if (ecl_sum_tstep_get_sim_time( tstep ) < data->__min_time) - data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); - } - vector_append_owned_ref( data->data , tstep , ecl_sum_tstep_free__); data->index_valid = false; } -static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) { - const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); - - sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep ); - sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); - time_interval_update_end( sum_data->sim_time , ecl_sum_tstep_get_sim_time( last_ministep )); -} static int cmp_ministep( const void * arg1 , const void * arg2) { const ecl_sum_tstep_type * ministep1 = ecl_sum_tstep_safe_cast_const( arg1 ); @@ -754,9 +709,8 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { /* Identify various global first and last values. */ { - const ecl_sum_tstep_type * first_ministep = ecl_sum_data_iget_ministep( sum_data , 0 ); - sum_data->first_ministep = ecl_sum_tstep_get_ministep( first_ministep ); - + const ecl_sum_tstep_type * first_ministep = vector_iget_const( sum_data->data, 0 ); + const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); /* In most cases the days_start and data_start_time will agree with the global simulation start; however in the case where we @@ -765,9 +719,10 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { will be a difference. */ sum_data->days_start = ecl_sum_tstep_get_sim_days( first_ministep ); - time_interval_update_start( sum_data->sim_time , ecl_sum_tstep_get_sim_time( first_ministep )); + sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); + sum_data->start_time = ecl_sum_tstep_get_sim_time( first_ministep); + sum_data->end_time = ecl_sum_tstep_get_sim_time( last_ministep ); } - ecl_sum_data_update_end_info( sum_data ); /* Build up the report -> ministep mapping. */ { @@ -776,27 +731,27 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( sum_data , internal_index ); int report_step = ecl_sum_tstep_get_report(ministep); - /* Indexing internal_index - report_step */ - { - int current_first_index = int_vector_safe_iget( sum_data->report_first_index , report_step ); - if (current_first_index < 0) /* i.e. currently not set. */ + /* Indexing internal_index - report_step */ + { + int current_first_index = int_vector_safe_iget( sum_data->report_first_index , report_step ); + if (current_first_index < 0) /* i.e. currently not set. */ int_vector_iset( sum_data->report_first_index , report_step , internal_index); - else - if (internal_index < current_first_index) - int_vector_iset( sum_data->report_first_index , report_step , internal_index); - } + else + if (internal_index < current_first_index) + int_vector_iset( sum_data->report_first_index , report_step , internal_index); + } - { - int current_last_index = int_vector_safe_iget( sum_data->report_last_index , report_step ); - if (current_last_index < 0) - int_vector_iset( sum_data->report_last_index , report_step , internal_index); - else - if (internal_index > current_last_index) - int_vector_iset( sum_data->report_last_index , report_step , internal_index); - } + { + int current_last_index = int_vector_safe_iget( sum_data->report_last_index , report_step ); + if (current_last_index < 0) + int_vector_iset( sum_data->report_last_index , report_step , internal_index); + else + if (internal_index > current_last_index) + int_vector_iset( sum_data->report_last_index , report_step , internal_index); + } - sum_data->first_report_step = util_int_min( sum_data->first_report_step , report_step ); - sum_data->last_report_step = util_int_max( sum_data->last_report_step , report_step ); + sum_data->first_report_step = util_int_min( sum_data->first_report_step , report_step ); + sum_data->last_report_step = util_int_max( sum_data->last_report_step , report_step ); } } sum_data->index_valid = true; @@ -834,9 +789,11 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int if (ecl_sum_tstep_get_report( prev_tstep ) == ecl_sum_tstep_get_report( tstep )) { // Same report step if (ecl_sum_tstep_get_sim_days( prev_tstep ) < ecl_sum_tstep_get_sim_days( tstep )) { // This tstep will become the new latest tstep int internal_index = vector_get_size( data->data ) - 1; - - ecl_sum_data_update_end_info( data ); int_vector_iset( data->report_last_index , report_step , internal_index ); + + data->sim_length = ecl_sum_tstep_get_sim_days( tstep ); + data->end_time = ecl_sum_tstep_get_sim_time(tstep); + rebuild_index = false; } } @@ -878,7 +835,6 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int */ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , - time_t load_end , int report_step , const ecl_file_view_type * summary_view, const ecl_smspec_type * smspec) { @@ -893,22 +849,15 @@ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , ecl_kw_type * params_kw = ecl_file_view_iget_named_kw( summary_view , PARAMS_KW , ikw); { - ecl_sum_tstep_type * tstep; int ministep_nr = ecl_kw_iget_int( ministep_kw , 0 ); - tstep = ecl_sum_tstep_alloc_from_file( report_step , - ministep_nr , - params_kw , - ecl_file_view_get_src_file( summary_view ), - smspec ); - - if (tstep != NULL) { - if (load_end == 0 || (ecl_sum_tstep_get_sim_time( tstep ) < load_end)) + ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc_from_file( report_step , + ministep_nr , + params_kw , + ecl_file_view_get_src_file( summary_view ), + smspec ); + + if (tstep) ecl_sum_data_append_tstep__( data , tstep ); - else - /* This tstep is in a time-period overlapping with data we - already have; discard this. */ - ecl_sum_tstep_free( tstep ); - } } } } @@ -939,7 +888,7 @@ void ecl_sum_data_add_case(ecl_sum_data_type * self, const ecl_sum_data_type * o That field is currently not used. */ - if (!time_interval_contains( self->sim_time , ecl_sum_tstep_get_sim_time( other_tstep ))) { + if (!ecl_sum_data_check_sim_time(self, ecl_sum_tstep_get_sim_time(other_tstep))) { ecl_sum_tstep_type * new_tstep; if (header_equal) @@ -975,7 +924,7 @@ static bool ecl_sum_data_check_file( ecl_file_type * ecl_file ) { call to ecl_sum_data_build_index(). */ -static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , const stringlist_type * filelist) { +bool ecl_sum_data_fread(ecl_sum_data_type * data , const stringlist_type * filelist) { if (stringlist_get_size( filelist ) == 0) return false; @@ -999,7 +948,7 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c { ecl_file_type * ecl_file = ecl_file_open( data_file , 0); if (ecl_file && ecl_sum_data_check_file( ecl_file )) { - ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file_get_global_view( ecl_file ) , data->smspec); + ecl_sum_data_add_ecl_file( data , report_step , ecl_file_get_global_view( ecl_file ) , data->smspec); ecl_file_close( ecl_file ); } } @@ -1018,7 +967,7 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c */ ecl_file_view_type * summary_view = ecl_file_get_summary_view(ecl_file , report_step - 1 ); if (summary_view) { - ecl_sum_data_add_ecl_file( data , load_end , report_step , summary_view , data->smspec); + ecl_sum_data_add_ecl_file( data , report_step , summary_view , data->smspec); report_step++; } else break; } @@ -1037,23 +986,10 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c } } -bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist) { - return ecl_sum_data_fread__( data , 0 , filelist ); -} - - -static time_t ecl_sum_data_get_load_end( const ecl_sum_data_type * data ) { - return data->__min_time; -} -void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist) { - time_t load_end = ecl_sum_data_get_load_end( data ); - ecl_sum_data_fread__( data , load_end , filelist ); -} - @@ -1068,7 +1004,7 @@ void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_typ ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * smspec , const stringlist_type * filelist , bool include_restart) { ecl_sum_data_type * data = ecl_sum_data_alloc( smspec ); - ecl_sum_data_fread__( data , 0 , filelist ); + ecl_sum_data_fread( data , filelist ); /*****************************************************************/ /* OK - now we have loaded all the data. Must sort the internal @@ -1418,14 +1354,6 @@ int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data ) { } -int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data ) { - return data->first_ministep; -} - -int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data ) { - return data->last_ministep; -} - /*****************************************************************/ /* High level vector routines */ diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h index 5c2f8fdc96..4585fec8c4 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h @@ -30,7 +30,6 @@ extern "C" { #include #include #include -#include #include #include @@ -166,7 +165,6 @@ typedef struct ecl_sum_struct ecl_sum_type; time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ); time_t ecl_sum_get_end_time( const ecl_sum_type * ecl_sum); time_t ecl_sum_get_start_time(const ecl_sum_type * ); - const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum); const char * ecl_sum_get_base(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_path(const ecl_sum_type * ecl_sum ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h index df2caa42a7..a04d5363f5 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h @@ -29,7 +29,6 @@ extern "C" { #include #include #include -#include #include #include @@ -41,7 +40,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_fwrite_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified, int report_step); void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified); bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist); - void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist); ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec ); ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec); double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time); @@ -57,7 +55,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step); double ecl_sum_data_get_first_day( const ecl_sum_data_type * data); - const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data); time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data ); double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ); @@ -74,8 +71,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_free( ecl_sum_data_type * ); int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data ); int ecl_sum_data_get_first_report_step( const ecl_sum_data_type * data ); - int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data ); - int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data ); double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node); double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node); diff --git a/ThirdParty/Ert/lib/include/ert/util/util.h b/ThirdParty/Ert/lib/include/ert/util/util.h index 8549300f9a..fe0fe48e06 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.h +++ b/ThirdParty/Ert/lib/include/ert/util/util.h @@ -43,6 +43,9 @@ #define UTIL_PATH_SEP_CHAR '/' /* A simple character used when we want an actual char instance (i.e. not a pointer). */ #endif +#define UTIL_WINDOWS_PATH_SEP_CHAR '\\' +#define UTIL_POSIX_PATH_SEP_CHAR '/' + #define UTIL_NEWLINE_STRING " \n" #define UTIL_DEFAULT_MKDIR_MODE 0777 /* Directories are by default created with mode a+rwx - and then comes the umask ... */ diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 0e1add9a91..8b301cb4e1 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -2249,7 +2249,6 @@ int util_fmove( FILE * stream , long offset , long shift) { #ifdef HAVE_WINDOWS__ACCESS bool util_access(const char * entry, int mode) { - if (!entry) return -1; return (_access(entry, mode) == 0); } diff --git a/ThirdParty/Ert/python/ecl/util/test/test_area.py b/ThirdParty/Ert/python/ecl/util/test/test_area.py index 5f90b320f5..22089bd86c 100644 --- a/ThirdParty/Ert/python/ecl/util/test/test_area.py +++ b/ThirdParty/Ert/python/ecl/util/test/test_area.py @@ -1,17 +1,17 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. import os.path @@ -33,7 +33,7 @@ class TestArea(BaseCClass): _get_original_cwd = EclPrototype("char* test_work_area_get_original_cwd( test_area )") _set_store = EclPrototype("void test_work_area_set_store( test_area , bool)") _sync = EclPrototype("void test_work_area_sync( test_area )") - + def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): if c_ptr is None: @@ -48,7 +48,7 @@ def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): super(TestArea, self).__init__(c_ptr) self.set_store( store_area ) - + def get_original_cwd(self): return self._get_original_cwd() @@ -60,7 +60,7 @@ def orgPath(self , path): return path else: return os.path.abspath( os.path.join( self.get_original_cwd( ) , path ) ) - + # All the methods install_file() , copy_directory(), # copy_parent_directory(), copy_parent_content(), @@ -86,7 +86,7 @@ def copy_parent_directory( self , path): else: raise IOError("No such file or directory: %s" % path) - + def copy_parent_content( self , path): if os.path.exists( self.orgPath(path) ): self._copy_parent_content(path) @@ -99,22 +99,22 @@ def copy_directory_content( self, directory): else: raise IOError("No such directory: %s" % directory ) - + def copy_file( self, filename): if os.path.isfile( self.orgPath(filename) ): self._copy_file(filename) else: raise IOError("No such file:%s" % filename) - + def free(self): self._free() - + def set_store(self, store): self._set_store(store) - + def getFullPath(self , path): if not os.path.exists( path ): raise IOError("Path not found:%s" % path) @@ -127,8 +127,8 @@ def getFullPath(self , path): def sync(self): return self._sync( ) - - + + class TestAreaContext(object): def __init__(self, test_name, prefix = None , store_area=False): From c9a1eeef030fe1df13f82335c21bb651d615e728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 16 Apr 2018 08:45:53 +0200 Subject: [PATCH 0670/1027] Apply two ecllib patches after upgrade --- ThirdParty/Ert/CMakeLists.txt | 5 ++++- ThirdParty/Ert/lib/CMakeLists.txt | 3 ++- ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 4fc4cc86d7..070dc78d7e 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -357,6 +357,9 @@ if (ENABLE_PYTHON) endif() endif() -install(EXPORT ecl-config DESTINATION share/cmake/ecl) +if (INSTALL_ERT) + install(EXPORT ecl-config DESTINATION share/cmake/ecl) +endif() + export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index cd13891963..f1bcff4fdb 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -190,7 +190,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) - +if (INSTALL_ERT) install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -215,6 +215,7 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () +endif() if (NOT BUILD_TESTS) return () diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c index e8d9cef33a..52d40a9aab 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + + if (doubhead_kw) + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -109,12 +112,15 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); + const ecl_kw_type * doubhead_kw = NULL; const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); + if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) + doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); + if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); From 0fcc0bea4cb1845e36f42706e35f74d99253b085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 16 Apr 2018 14:11:31 +0200 Subject: [PATCH 0671/1027] 2743 Origin summary import dialog adjustments --- .../Application/Tools/RiaFilePathTools.cpp | 25 ++++ .../Application/Tools/RiaFilePathTools.h | 1 + .../Commands/RicSummaryCaseRestartDialog.cpp | 130 ++++++++++++++---- .../Commands/RicSummaryCaseRestartDialog.h | 6 +- .../FileInterface/RifEclipseSummaryTools.cpp | 9 +- 5 files changed, 138 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp index 812097bc0c..3fc9269c51 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -94,3 +94,28 @@ QString RiaFilePathTools::canonicalPath(const QString& path) { return QDir(path).absolutePath(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::commonRootPath(const QStringList& paths) +{ + QString root = paths.front(); + for (const auto& item : paths) + { + if (root.length() > item.length()) root.truncate(item.length()); + + int iDir = 0; + for (int i = 0; i < root.length(); ++i) + { + if (i > 0 && (root[i-1] == '/' || root[i-1] == '\\')) iDir = i; + + if (root[i] != item[i]) + { + root.truncate(std::min(i, iDir)); + break; + } + } + } + return root; +} diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.h b/ApplicationCode/Application/Tools/RiaFilePathTools.h index 8a25b055b9..9dbb0735fd 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.h +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.h @@ -37,4 +37,5 @@ class RiaFilePathTools static QString relativePath(const QString& rootDir, const QString& dir); static bool equalPaths(const QString& path1, const QString& path2); static QString canonicalPath(const QString& path); + static QString commonRootPath(const QStringList& paths); }; diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 144c4aafa6..7d0a7a38cd 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -52,6 +52,8 @@ #include #include +#include + #include #include #include @@ -60,6 +62,37 @@ #define DEFAULT_DIALOG_INIT_HEIGHT 150 +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +std::vector> removeRootPath(const std::vector>& fileInfoLists) +{ + // Find common root path among all paths + QStringList allPaths; + for (const auto& fileInfoList : fileInfoLists) + { + for (const auto fi : fileInfoList) allPaths.push_back(fi.fileName); + } + QString commonRoot = RiaFilePathTools::commonRootPath(allPaths); + int commonRootSize = commonRoot.size(); + + // Build output lists + std::vector> output; + for (const auto& fileInfoList : fileInfoLists) + { + std::vector currList; + + for (auto& fi : fileInfoList) + { + RifRestartFileInfo newFi = fi; + newFi.fileName.remove(0, commonRootSize); + currList.push_back(newFi); + } + output.push_back(currList); + } + return output; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -67,7 +100,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) : QDialog(parent, RiuTools::defaultDialogFlags()) { // Create widgets - m_currentSummaryFileLayout = new QGridLayout(); + m_currentFilesLayout = new QGridLayout(); m_summaryReadAllBtn = new QRadioButton(this); m_summarySeparateCasesBtn = new QRadioButton(this); m_summaryNotReadBtn = new QRadioButton(this); @@ -87,14 +120,15 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn->setText("Skip"); m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridNotReadBtn->setText("Skip"); - m_applyToAllCheckBox->setText("Apply to All Files"); + m_applyToAllCheckBox->setText("Apply Settings to Remaining Files"); + m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); - QGroupBox* currentFileGroup = new QGroupBox("Current Summary File"); - m_currentSummaryFileLayout = new QGridLayout(); - currentFileGroup->setLayout(m_currentSummaryFileLayout); + m_currentFilesGroup = new QGroupBox("Current Summary File"); + m_currentFilesLayout = new QGridLayout(); + m_currentFilesGroup->setLayout(m_currentFilesLayout); // Summary files QGroupBox* summaryFilesGroup = new QGroupBox("Found Origin Summary Files"); @@ -135,10 +169,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Apply to all checkbox and buttons QHBoxLayout* buttonsLayout = new QHBoxLayout(); + buttonsLayout->addStretch(1); buttonsLayout->addWidget(m_applyToAllCheckBox); buttonsLayout->addWidget(m_buttons); - dialogLayout->addWidget(currentFileGroup); + dialogLayout->addWidget(m_currentFilesGroup); dialogLayout->addWidget(summaryFilesGroup); dialogLayout->addWidget(m_gridFilesGroup); dialogLayout->addLayout(buttonsLayout); @@ -191,14 +226,34 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } else { - dialog.setWindowTitle("Restart Files"); + std::vector currentFileInfos; + std::vector originSummaryFileInfos; + std::vector originGridFileInfos; + + // Build lists of files + if (buildGridCaseFileList) + { + dialog.m_currentFilesGroup->setTitle("Current Grid and Summary Files"); + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(currentFileInfo.fileName); + currentFileInfos.push_back(RifRestartFileInfo(gridFile, currentFileInfo.startDate, currentFileInfo.endDate)); + + for (const auto& ofi : originFileInfos) + { + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); + if (QFileInfo(gridFile).exists()) + { + originGridFileInfos.push_back(RifRestartFileInfo(gridFile, ofi.startDate, ofi.endDate)); + } + } + } - dialog.appendFileInfoToGridLayout(*dialog.m_currentSummaryFileLayout, currentFileInfo); + currentFileInfos.push_back(currentFileInfo); for (const auto& ofi : originFileInfos) { - dialog.appendFileInfoToGridLayout(*dialog.m_summaryFilesLayout, ofi); + originSummaryFileInfos.push_back(ofi); } + // Set default import options switch (defaultSummaryImportOption) { case ImportOptions::IMPORT_ALL: dialog.m_summaryReadAllBtn->setChecked(true); break; @@ -206,27 +261,29 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const case ImportOptions::NOT_IMPORT: dialog.m_summaryNotReadBtn->setChecked(true); break; } - dialog.m_gridFilesGroup->setVisible(buildGridCaseFileList); if (buildGridCaseFileList) { - bool gridFilesAdded = false; - for (const auto& ofi : originFileInfos) - { - QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); - if (QFileInfo(gridFile).exists()) - { - dialog.appendFileInfoToGridLayout(*dialog.m_gridFilesLayout, RifRestartFileInfo(gridFile, ofi.startDate, ofi.endDate)); - gridFilesAdded = true; - } - } - if (!gridFilesAdded) dialog.m_gridFilesGroup->setVisible(false); - switch (defaultGridImportOption) { case ImportOptions::SEPARATE_CASES: dialog.m_gridSeparateCasesBtn->setChecked(true); break; case ImportOptions::NOT_IMPORT: dialog.m_gridNotReadBtn->setChecked(true); break; } } + + // Remove common root path + std::vector> fileInfosNoRoot = removeRootPath( + { + currentFileInfos, originSummaryFileInfos, originGridFileInfos + } + ); + + // Populate file list widgets + dialog.populateFileList(dialog.m_currentFilesLayout, fileInfosNoRoot[0]); + dialog.populateFileList(dialog.m_summaryFilesLayout, fileInfosNoRoot[1]); + dialog.populateFileList(dialog.m_gridFilesLayout, fileInfosNoRoot[2]); + + // Set properties and show dialog + dialog.setWindowTitle("Restart Files"); dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -301,22 +358,41 @@ bool RicSummaryCaseRestartDialog::applyToAllSelected() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo) +void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos) { + if (fileInfos.empty()) + { + QWidget* parent = gridLayout->parentWidget(); + if (parent) parent->setVisible(false); + } + + for (const auto& fileInfo : fileInfos) + { + appendFileInfoToGridLayout(gridLayout, fileInfo); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo) +{ + CVF_ASSERT(gridLayout); + QDateTime startDate = QDateTime::fromTime_t(fileInfo.startDate); QString startDateString = startDate.toString(RimTools::dateFormatString()); QDateTime endDate = QDateTime::fromTime_t(fileInfo.endDate); QString endDateString = endDate.toString(RimTools::dateFormatString()); - int rowCount = gridLayout.rowCount(); + int rowCount = gridLayout->rowCount(); QLabel* fileNameLabel = new QLabel(); QLabel* dateLabel = new QLabel(); - fileNameLabel->setText(QFileInfo(fileInfo.fileName).fileName()); + fileNameLabel->setText(fileInfo.fileName); dateLabel->setText(startDateString + " - " + endDateString); fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - gridLayout.addWidget(fileNameLabel, rowCount, 0); - gridLayout.addWidget(dateLabel, rowCount, 1); + gridLayout->addWidget(fileNameLabel, rowCount, 0); + gridLayout->addWidget(dateLabel, rowCount, 1); // Full path in tooltip fileNameLabel->setToolTip(fileInfo.fileName); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 58b408d61e..30ffce90b5 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -65,7 +65,8 @@ class RicSummaryCaseRestartDialog : public QDialog bool applyToAllSelected() const; private: - void appendFileInfoToGridLayout(QGridLayout& gridLayout, const RifRestartFileInfo& fileInfo); + void populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos); + void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo); std::vector getRestartFiles(const QString& summaryHeaderFile); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); @@ -74,7 +75,8 @@ private slots: void slotDialogCancelClicked(); private: - QGridLayout* m_currentSummaryFileLayout; + QGroupBox* m_currentFilesGroup; + QGridLayout* m_currentFilesLayout; QGridLayout* m_summaryFilesLayout; diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp index 97c66f20f9..bf4201a478 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp @@ -21,6 +21,7 @@ #include "RiaSummaryCurveAnalyzer.h" #include "RifReaderEclipseSummary.h" #include "RiaStringEncodingTools.h" +#include "RiaFilePathTools.h" #include "cafAppEnum.h" @@ -158,7 +159,7 @@ QString RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(const QStr util_safe_free(myBase); util_safe_free(myPath); - return gridCaseFile; + return RiaFilePathTools::toInternalSeparator(gridCaseFile); } //-------------------------------------------------------------------------------------------------- @@ -218,9 +219,9 @@ void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, } } - if (myHeaderFile && headerFile) *headerFile = myHeaderFile; - if (myPath && path) *path = myPath; - if (myBase && base) *base = myBase; + if (myHeaderFile && headerFile) *headerFile = RiaFilePathTools::toInternalSeparator(myHeaderFile); + if (myPath && path) *path = RiaFilePathTools::toInternalSeparator(myPath); + if (myBase && base) *base = RiaFilePathTools::toInternalSeparator(myBase); if (isFormatted) *isFormatted = formattedFile; util_safe_free(myHeaderFile); From 1da9501bccfcc6285d65ba6c10a63d17b1e16475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 16 Apr 2018 15:14:07 +0200 Subject: [PATCH 0672/1027] #2742 Hide the Show Points toggle when not needed --- ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index cea81d063c..37ba2a54c9 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -704,9 +704,8 @@ void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedF //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_intersection); - Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); if (m_intersection->hasDefiningPoints()) { From 5769ba45f163a353e8af5b0eda3dd74ef7381beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 17 Apr 2018 07:42:41 +0200 Subject: [PATCH 0673/1027] #2739 Normal intersection box mesh lines now not labled as fault mesh lines --- .../Intersections/RivIntersectionBoxPartMgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index a64fbc2cb3..2a9d25cc2d 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -255,7 +255,7 @@ void RivIntersectionBoxPartMgr::generatePartGeometry() part->setSourceInfo(si.p()); part->updateBoundingBox(); - part->setEnableMask(faultBit); + part->setEnableMask(intersectionCellFaceBit); part->setPriority(RivPartPriority::PartType::Intersection); m_intersectionBoxFaces = part; @@ -277,7 +277,7 @@ void RivIntersectionBoxPartMgr::generatePartGeometry() part->setDrawable(geoMesh.p()); part->updateBoundingBox(); - part->setEnableMask(meshFaultBit); + part->setEnableMask(intersectionCellMeshBit); part->setPriority(RivPartPriority::PartType::MeshLines); m_intersectionBoxGridLines = part; From 43e5fb00f44efd0da0231f75cd14d9bc81006a7c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 07:55:52 +0200 Subject: [PATCH 0674/1027] Testing : Fix invalid index in small mock model --- ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 8cc31e00ec..07505ad984 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -536,7 +536,7 @@ void RigReservoirBuilderMock::addFaults(RigEclipseCaseData* eclipseCase) size_t k1 = 3; size_t i2 = 2; - size_t j2 = 5; + size_t j2 = 1; size_t k2 = 4; addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections); From 4fc6da2c76dc59fbd604c7f2b0d90967f318679d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 09:35:04 +0200 Subject: [PATCH 0675/1027] #2744 Well Log Extractor : Add failing test for well path inside one cell --- .../UnitTests/CMakeLists_files.cmake | 1 + .../UnitTests/RigWellLogExtractor-Test.cpp | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 5fa645077a..dacb8749a3 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -41,6 +41,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor-Test.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp b/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp new file mode 100644 index 0000000000..86abb48003 --- /dev/null +++ b/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "gtest/gtest.h" + +#include "RifReaderMockModel.h" + +#include "RigEclipseCaseData.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigGridManager.h" +#include "RigMainGrid.h" +#include "RigWellPath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigEclipseWellLogExtractor, ShortWellPathInsideOneCell) +{ + cvf::ref reservoir = new RigEclipseCaseData(nullptr); + + { + cvf::ref mockFileInterface = new RifReaderMockModel; + + mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20)); + mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6)); + mockFileInterface->enableWellData(false); + + mockFileInterface->open("", reservoir.p()); + + reservoir->mainGrid()->computeCachedData(); + } + + auto cells = reservoir->mainGrid()->globalCellArray(); + EXPECT_FALSE(cells.empty()); + + auto firstCell = reservoir->mainGrid()->globalCellArray()[0]; + auto center = firstCell.center(); + + cvf::ref wellPathGeometry = new RigWellPath; + { + std::vector wellPathPoints; + std::vector mdValues; + + { + double offset = 0.0; + wellPathPoints.push_back(center); + mdValues.push_back(offset); + } + + { + double offset = 0.1; + wellPathPoints.push_back(center + cvf::Vec3d(0, 0, offset)); + mdValues.push_back(offset); + } + + wellPathGeometry->m_wellPathPoints = wellPathPoints; + wellPathGeometry->m_measuredDepths = mdValues; + } + + cvf::ref e = new RigEclipseWellLogExtractor(reservoir.p(), wellPathGeometry.p(), ""); + + auto intersections = e->cellIntersectionInfosAlongWellPath(); + EXPECT_FALSE(intersections.empty()); +} From 34cbd794106d6c54c7b834f5713c0f88a61c1d3b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 09:41:08 +0200 Subject: [PATCH 0676/1027] #2744 Well Log Extractor : Support detection of small well path inside one cell --- .../RigEclipseWellLogExtractor.cpp | 63 +++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index f7ab544665..af4e16dc6e 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -19,6 +19,8 @@ #include "RigEclipseWellLogExtractor.h" +#include "RiaLogging.h" + #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigResultAccessor.h" @@ -62,7 +64,6 @@ void RigEclipseWellLogExtractor::calculateIntersection() cvf::Vec3d p1 = m_wellPath->m_wellPathPoints[wpp]; cvf::Vec3d p2 = m_wellPath->m_wellPathPoints[wpp+1]; - cvf::BoundingBox bb; bb.add(p1); @@ -70,7 +71,6 @@ void RigEclipseWellLogExtractor::calculateIntersection() std::vector closeCells = findCloseCells(bb); - cvf::Vec3d hexCorners[8]; for (size_t cIdx = 0; cIdx < closeCells.size(); ++cIdx) { @@ -116,6 +116,63 @@ void RigEclipseWellLogExtractor::calculateIntersection() } + if (uniqueIntersections.empty() && m_wellPath->m_wellPathPoints.size() > 1) + { + // When entering this function, all well path points are either completely outside the grid + // or all well path points are inside one cell + + cvf::Vec3d firstPoint = m_wellPath->m_wellPathPoints.front(); + cvf::Vec3d lastPoint = m_wellPath->m_wellPathPoints.back(); + + { + cvf::BoundingBox bb; + bb.add(firstPoint); + + std::vector closeCellIndices = findCloseCells(bb); + + cvf::Vec3d hexCorners[8]; + for (const auto& globalCellIndex : closeCellIndices) + { + const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; + + if (cell.isInvalid()) continue; + + m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners); + + if (RigHexIntersectionTools::isPointInCell(firstPoint, hexCorners)) + { + if (RigHexIntersectionTools::isPointInCell(lastPoint, hexCorners)) + { + { + // Mark the first well path point as entering the cell + + bool isEntering = true; + HexIntersectionInfo info(firstPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex); + RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.front(), globalCellIndex, isEntering); + + uniqueIntersections.insert(std::make_pair(enterLeaveKey, info)); + } + + { + // Mark the last well path point as leaving cell + + bool isEntering = false; + HexIntersectionInfo info(lastPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex); + RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.back(), globalCellIndex, isEntering); + + uniqueIntersections.insert(std::make_pair(enterLeaveKey, info)); + } + } + else + { + QString txt = "Detected two points assumed to be in the same cell, but they are in two different cells"; + RiaLogging::debug(txt); + } + } + } + } + } + this->populateReturnArrays(uniqueIntersections); } @@ -136,7 +193,6 @@ void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccess } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -157,4 +213,3 @@ cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell(size_t cellIndex, c return RigWellPathIntersectionTools::calculateLengthInCell(hexCorners, startPoint, endPoint); } - From c0704a65f31ff7fa69266f02ec6d23fffd146ce2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 10:14:57 +0200 Subject: [PATCH 0677/1027] #2744 Well Log Extractor : Replace use of cornerIndices with cellCornerVertices --- .../RigEclipseWellLogExtractor.cpp | 30 +++++++------------ .../RigEclipseWellLogExtractor.h | 4 +-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index af4e16dc6e..aed14a0f77 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -56,7 +56,7 @@ void RigEclipseWellLogExtractor::calculateIntersection() const std::vector& nodeCoords = m_caseData->mainGrid()->nodes(); bool isCellFaceNormalsOut = m_caseData->mainGrid()->isFaceNormalsOutwards(); - if (!m_wellPath->m_wellPathPoints.size()) return ; + if (m_wellPath->m_wellPathPoints.empty()) return; for (size_t wpp = 0; wpp < m_wellPath->m_wellPathPoints.size() - 1; ++wpp) { @@ -69,35 +69,25 @@ void RigEclipseWellLogExtractor::calculateIntersection() bb.add(p1); bb.add(p2); - std::vector closeCells = findCloseCells(bb); + std::vector closeCellIndices = findCloseCellIndices(bb); cvf::Vec3d hexCorners[8]; - for (size_t cIdx = 0; cIdx < closeCells.size(); ++cIdx) + for (const auto& globalCellIndex : closeCellIndices) { - const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[closeCells[cIdx]]; + const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; if (cell.isInvalid()) continue; - const caf::SizeTArray8& cornerIndices = cell.cornerIndices(); + m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners); - hexCorners[0] = nodeCoords[cornerIndices[0]]; - hexCorners[1] = nodeCoords[cornerIndices[1]]; - hexCorners[2] = nodeCoords[cornerIndices[2]]; - hexCorners[3] = nodeCoords[cornerIndices[3]]; - hexCorners[4] = nodeCoords[cornerIndices[4]]; - hexCorners[5] = nodeCoords[cornerIndices[5]]; - hexCorners[6] = nodeCoords[cornerIndices[6]]; - hexCorners[7] = nodeCoords[cornerIndices[7]]; - - //int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[cIdx], &intersections); - RigHexIntersectionTools::lineHexCellIntersection(p1, p2, hexCorners, closeCells[cIdx], &intersections); + RigHexIntersectionTools::lineHexCellIntersection(p1, p2, hexCorners, globalCellIndex, &intersections); } if (!isCellFaceNormalsOut) { - for (size_t intIdx = 0; intIdx < intersections.size(); ++intIdx) + for (auto& intersection : intersections) { - intersections[intIdx].m_isIntersectionEntering = !intersections[intIdx].m_isIntersectionEntering ; + intersection.m_isIntersectionEntering = !intersection.m_isIntersectionEntering; } } @@ -128,7 +118,7 @@ void RigEclipseWellLogExtractor::calculateIntersection() cvf::BoundingBox bb; bb.add(firstPoint); - std::vector closeCellIndices = findCloseCells(bb); + std::vector closeCellIndices = findCloseCellIndices(bb); cvf::Vec3d hexCorners[8]; for (const auto& globalCellIndex : closeCellIndices) @@ -196,7 +186,7 @@ void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccess //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigEclipseWellLogExtractor::findCloseCells(const cvf::BoundingBox& bb) +std::vector RigEclipseWellLogExtractor::findCloseCellIndices(const cvf::BoundingBox& bb) { std::vector closeCells; m_caseData->mainGrid()->findIntersectingCells(bb, &closeCells); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h index b30286c870..e6067d0616 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h @@ -41,9 +41,9 @@ class RigEclipseWellLogExtractor : public RigWellLogExtractor const RigEclipseCaseData* caseData() { return m_caseData.p();} -protected: +private: void calculateIntersection(); - std::vector findCloseCells(const cvf::BoundingBox& bb); + std::vector findCloseCellIndices(const cvf::BoundingBox& bb); virtual cvf::Vec3d calculateLengthInCell(size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint) const override; From a8fb4469b4becd66f40bedd5a8487e1c29df7a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 17 Apr 2018 10:59:47 +0200 Subject: [PATCH 0678/1027] Fix a bug in commonRootPath logic --- ApplicationCode/Application/Tools/RiaFilePathTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp index 3fc9269c51..025837684b 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -110,7 +110,7 @@ QString RiaFilePathTools::commonRootPath(const QStringList& paths) { if (i > 0 && (root[i-1] == '/' || root[i-1] == '\\')) iDir = i; - if (root[i] != item[i]) + if (root[i] != item[i] || i == root.length() - 1) { root.truncate(std::min(i, iDir)); break; From 7afa753d1108fca993a2663dd289fd10b82362ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 17 Apr 2018 11:01:24 +0200 Subject: [PATCH 0679/1027] #2714 Display a warning in origin summary import dialog when ecllib may fail to read origin files --- .../Commands/RicSummaryCaseRestartDialog.cpp | 33 ++++++++++---- .../Commands/RicSummaryCaseRestartDialog.h | 4 +- .../FileInterface/RifReaderEclipseSummary.cpp | 43 ++++++++++++++++--- .../FileInterface/RifReaderEclipseSummary.h | 9 ++-- .../RifSummaryCaseRestartSelector.cpp | 12 +++++- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 7d0a7a38cd..1b6a0e3b90 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaFilePathTools.h" +#include "RiaLogging.h" #include "RifReaderEclipseSummary.h" #include "RifEclipseSummaryTools.h" @@ -107,7 +108,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_gridSeparateCasesBtn = new QRadioButton(this); m_gridNotReadBtn = new QRadioButton(this); m_applyToAllCheckBox = new QCheckBox(this); - + m_warnings = new QListWidget(this); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); // Connect to signals @@ -176,6 +177,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) dialogLayout->addWidget(m_currentFilesGroup); dialogLayout->addWidget(summaryFilesGroup); dialogLayout->addWidget(m_gridFilesGroup); + dialogLayout->addWidget(m_warnings); dialogLayout->addLayout(buttonsLayout); setLayout(dialogLayout); @@ -208,10 +210,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } RifReaderEclipseSummary reader; - std::vector originFileInfos = reader.getRestartFiles(summaryHeaderFile); + bool hasWarnings = false; + std::vector originFileInfos = reader.getRestartFiles(summaryHeaderFile, &hasWarnings); - // If no restart files are found, do not show dialog - if (originFileInfos.empty()) + // If no restart files are found and no warnings, do not show dialog + if (originFileInfos.empty() &&!hasWarnings) { QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ summaryHeaderFile }), QStringList({ gridCaseFile }), false); @@ -223,6 +226,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialogResult = *lastResult; dialogResult.summaryFiles.clear(); dialogResult.gridFiles.clear(); + + if (hasWarnings) + { + for (const QString& warning : reader.warnings()) RiaLogging::error(warning); + } } else { @@ -282,6 +290,9 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.populateFileList(dialog.m_summaryFilesLayout, fileInfosNoRoot[1]); dialog.populateFileList(dialog.m_gridFilesLayout, fileInfosNoRoot[2]); + // Display warnings if any + dialog.displayWarningsIfAny(reader.warnings()); + // Set properties and show dialog dialog.setWindowTitle("Restart Files"); dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); @@ -401,19 +412,23 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicSummaryCaseRestartDialog::getRestartFiles(const QString& summaryHeaderFile) +RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile) { RifReaderEclipseSummary reader; - return reader.getRestartFiles(summaryHeaderFile); + return reader.getFileInfo(summaryHeaderFile); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile) +void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnings) { - RifReaderEclipseSummary reader; - return reader.getFileInfo(summaryHeaderFile); + m_warnings->setVisible(!warnings.isEmpty()); + for (const auto& warning : warnings) + { + QListWidgetItem* item = new QListWidgetItem(warning, m_warnings); + item->setForeground(Qt::red); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 30ffce90b5..356aeca999 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -67,8 +67,8 @@ class RicSummaryCaseRestartDialog : public QDialog private: void populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos); void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo); - std::vector getRestartFiles(const QString& summaryHeaderFile); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); + void displayWarningsIfAny(const QStringList& warnings); private slots: void slotDialogOkClicked(); @@ -92,6 +92,8 @@ private slots: QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; + + QListWidget* m_warnings; }; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index fa81fb5ab3..720a602278 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -22,8 +22,6 @@ #include "RifReaderEclipseOutput.h" #include "RifEclipseSummaryTools.h" -#include "RiaLogging.h" - #include #include @@ -137,10 +135,14 @@ bool RifReaderEclipseSummary::open(const QString& headerFileName, bool includeRe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName) +std::vector RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName, bool* hasWarnings) { + CVF_ASSERT(hasWarnings); + std::vector restartFiles; - + m_warnings.clear(); + *hasWarnings = false; + RifRestartFileInfo currFile; currFile.fileName = headerFileName; while(!currFile.fileName.isEmpty()) @@ -152,10 +154,41 @@ std::vector RifReaderEclipseSummary::getRestartFiles(const Q // Fix to stop potential infinite loop if (currFile.fileName == prevFile) { - RiaLogging::error("RifReaderEclipseSummary: Restart file reference loop detected"); + m_warnings.push_back("RifReaderEclipseSummary: Restart file reference loop detected"); + *hasWarnings = true; break; } + // Due to a weakness in libecl regarding restart summary header file selection, + // do some extra checking + { + QString formattedHeaderExtension = ".FSMSPEC"; + QString nonformattedHeaderExtension = ".SMSPEC"; + QString formattedDataFileExtension = ".FUNSMRY"; + + if (currFile.fileName.endsWith(nonformattedHeaderExtension, Qt::CaseInsensitive)) + { + QString formattedHeaderFile = currFile.fileName; + formattedHeaderFile.replace(nonformattedHeaderExtension, formattedHeaderExtension, Qt::CaseInsensitive); + QString formattedDateFile = currFile.fileName; + formattedDateFile.replace(nonformattedHeaderExtension, formattedDataFileExtension, Qt::CaseInsensitive); + + QFileInfo nonformattedHeaderFileInfo = QFileInfo(currFile.fileName); + QFileInfo formattedHeaderFileInfo = QFileInfo(formattedHeaderFile); + QFileInfo formattedDateFileInfo = QFileInfo(formattedDateFile); + if (formattedHeaderFileInfo.lastModified() < nonformattedHeaderFileInfo.lastModified() && + formattedHeaderFileInfo.exists() && !formattedDateFileInfo.exists()) + { + m_warnings.push_back(QString("RifReaderEclipseSummary: Formatted summary header file without an\n") + + QString("associated data file detected.\n") + + QString("This may cause a failure reading summary origin data.\n") + + QString("To avoid this problem, please delete or rename the.FSMSPEC file.")); + *hasWarnings = true; + break; + } + } + } + if (!currFile.fileName.isEmpty()) restartFiles.push_back(currFile); } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index 1d352e4fec..88f0cf228f 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -22,13 +22,12 @@ #include "RifSummaryReaderInterface.h" #include +#include #include #include #include -class QStringList; - //================================================================================================== // @@ -59,7 +58,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface bool open(const QString& headerFileName, bool includeRestartFiles); - std::vector getRestartFiles(const QString& headerFileName); + std::vector getRestartFiles(const QString& headerFileName, bool* hasWarnings); RifRestartFileInfo getFileInfo(const QString& headerFileName); virtual const std::vector& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override; @@ -67,6 +66,8 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector* values) const override; virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) const override; + QStringList warnings() const { return m_warnings; } + private: int timeStepCount() const; int indexFromAddress(const RifEclipseSummaryAddress& resultAddress) const; @@ -83,5 +84,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface std::vector m_timeSteps; std::map m_resultAddressToErtNodeIdx; + + QStringList m_warnings; }; diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 709ee37f0f..94909f16ec 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" #include "RiaFilePathTools.h" +#include "RiaLogging.h" #include "RicSummaryCaseRestartDialog.h" @@ -187,7 +188,8 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); RifReaderEclipseSummary reader; - std::vector restartFileInfos = reader.getRestartFiles(file); + bool hasWarnings = false; + std::vector restartFileInfos = reader.getRestartFiles(file, &hasWarnings); for (const auto& rfi : restartFileInfos) { RifSummaryCaseFileInfo fi(rfi.fileName, false); @@ -205,7 +207,8 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp if (m_defaultGridImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { RifReaderEclipseSummary reader; - std::vector restartFileInfos = reader.getRestartFiles(file); + bool hasWarnings = false; + std::vector restartFileInfos = reader.getRestartFiles(file, &hasWarnings); for (const auto& rfi : restartFileInfos) { RifSummaryCaseFileInfo fi(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName), false); @@ -214,6 +217,11 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp m_gridFiles.push_back(fi.fileName); } } + + if (hasWarnings) + { + for (const QString& warning : reader.warnings()) RiaLogging::error(warning); + } } } } From ea3bbd1cf96def5f6023b0a386fdc93ce5e021dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 11 Apr 2018 08:20:22 +0200 Subject: [PATCH 0680/1027] #2610 UML diagrams --- doc/case_collections.plantuml | 57 +++++++++++++++++++++++++++++++++++ doc/curve_creator.plantuml | 54 +++++++++++++++++++++++++++++++++ doc/legends.plantuml | 21 +++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 doc/case_collections.plantuml create mode 100644 doc/curve_creator.plantuml create mode 100644 doc/legends.plantuml diff --git a/doc/case_collections.plantuml b/doc/case_collections.plantuml new file mode 100644 index 0000000000..bfebd6b19f --- /dev/null +++ b/doc/case_collections.plantuml @@ -0,0 +1,57 @@ +@startuml + +package "Summary case ensamble" { + + skinparam class { + BackgroundColor<> LightGray + } + + package Cases { + RimSummaryCaseMainCollection --> "*" RimSummaryCaseCollection + RimSummaryCaseMainCollection --> "*" RimSummaryCase + RimSummaryCaseCollection --> "*" RimSummaryCase + + RimSummaryCase -> RigCaseRealizationParameters + + 'RimSummaryCaseMainCollection ..> RifEnsambleParametersReader + RimSummaryCaseMainCollection ..> RifCaseRealizationParametersReader : create + RifCaseRealizationParametersReader ..> RimSummaryCase : set parameters + + class RifSummaryReaderInterface { + allResultAddresses() + } + class RimEnsambleSummaryCase << New >> + class RifReaderEnsambleSummary << New >> + RimSummaryCase <|-- RimGridSummaryCase + RimSummaryCase <|-- RimEnsambleSummaryCase + RimSummaryCase --> RifSummaryReaderInterface + RifSummaryReaderInterface <|-- RifReaderEclipseSummary + RifSummaryReaderInterface <|-- RifReaderEnsambleSummary + RimEnsambleSummaryCase ..> RifReaderEnsambleSummary + RimEnsambleSummaryCase --> RimSummaryCaseCollection + RimGridSummaryCase ..> RifReaderEclipseSummary + } + + package Curves { + RimMainPlotCollection --> RimSummaryPlotCollection + RimSummaryPlotCollection --> "*" RimSummaryPlot + + RimSummaryPlot --> RimSummaryCurveCollection + RimSummaryPlot -> RimEnsambleCurveSetCollection + RimSummaryCurveCollection --> "*" RimSummaryCurve + RimSummaryCurveCollection -> "3" RimSummaryPlotSourceStepping + RimEnsambleCurveSetCollection --> RimEnsambleCurveSet + RimEnsambleCurveSet --> "*" RimSummaryCurve + } + + RimProject -> RimMainPlotCollection + RimProject --> "*" RimOilField + RimOilField --> RimSummaryCaseMainCollection + + RimSummaryCurve -> RimSummaryCase + RimSummaryCurve --> RifEclipseSummaryAddress + + RifSummaryReaderInterface --> "*" RifEclipseSummaryAddress +} + +@enduml diff --git a/doc/curve_creator.plantuml b/doc/curve_creator.plantuml new file mode 100644 index 0000000000..1727120710 --- /dev/null +++ b/doc/curve_creator.plantuml @@ -0,0 +1,54 @@ +@startuml + +package "Curve creator (Plot editor)" { + +' +' Class definitions +' +class RicSummaryCurveCreatorSplitterUi { + Qt layouts +} + +class RicSummaryCurveCreator { + Appearance types + OK/Apply/Cancel buttons +} + +class RiuSummaryCurveDefSelectionEditor { + m_firstRowLeftLayout + m_firstRowRightLayout +} + +class RiuSummaryCurveDefSelection { + Cases + Summary categories + Identifier fields +} + +' +' Class Hierarchy +' +PdmUiWidgetBasedObjectEditor <|- RicSummaryCurveCreatorSplitterUi +PdmUiWidgetBasedObjectEditor <|- RicSummaryCurveCreatorTabsUi +PdmUiWidgetBasedObjectEditor <|-- RiuSummaryCurveDefSelectionEditor + +' +' Class references +' +RicSummaryCurveCreatorDialog --> RicSummaryCurveCreatorTabsUi + +RicSummaryCurveCreatorSplitterUi ->RicSummaryCurveCreator + +RicSummaryCurveCreatorTabsUi -> RicSummaryCurveCreatorSplitterUi : curves +RicSummaryCurveCreatorTabsUi -> RicSummaryCurveCreatorSplitterUi : ensambles + +RicSummaryCurveCreator --> RiuSummaryCurveDefSelectionEditor + +RicSummaryCurveCreator --> RimSummaryPlot : Target plot +RicSummaryCurveCreator --> RimSummaryPlot : Preview plot + +RiuSummaryCurveDefSelectionEditor --> RiuSummaryCurveDefSelection + +} + +@enduml diff --git a/doc/legends.plantuml b/doc/legends.plantuml new file mode 100644 index 0000000000..8ca560617b --- /dev/null +++ b/doc/legends.plantuml @@ -0,0 +1,21 @@ +@startuml + +package Legends { + + OverlayItem <|-- OverlayScalarMapperLegend + + ScalarMapper <|-- ScalarMapperRangeBased + ScalarMapperRangeBased <|-- ScalarMapperContinuousLinear + ScalarMapperRangeBased <|-- ScalarMapperDiscreteLinear + + RimStimPlanColors --> RimLegendConfig + Rim2dIntersectionView --> RimLegendConfig + RimEclipseCellColors --> RimLegendConfig + + RimLegendConfig --> ScalarMapper + RimLegendConfig --> OverlayScalarMapperLegend + + OverlayScalarMapperLegend --> ScalarMapper +} + +@enduml From 54097b7cc0f05b0771b86e7498d900af5179644e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 17 Apr 2018 11:56:39 +0200 Subject: [PATCH 0681/1027] #2722 Show axis for ensamble curves as well --- .../Summary/RimEnsambleCurveSet.cpp | 8 ++++++++ .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 2cea892254..a35a19c488 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -444,6 +444,14 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie curve->updateCurveVisibility(true); curve->loadDataAndUpdate(true); } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot && plot->qwtPlot()) + { + plot->qwtPlot()->replot(); + plot->updateAxes(); + } } } else if (changedField == &m_ensambleParameter) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 7c21246194..9b8e227e28 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -671,6 +671,20 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis(RiaDef } } } + + if (m_ensambleCurveSetCollection && m_ensambleCurveSetCollection->isCurveSetsVisible()) + { + for (RimEnsambleCurveSet* curveSet : m_ensambleCurveSetCollection->curveSets()) + { + for (RimSummaryCurve* curve : curveSet->curves()) + { + if (curve->isCurveVisible() && curve->axisY() == plotAxis) + { + curves.push_back(curve); + } + } + } + } } return curves; From 5e6613d4286bd7ace961cd5840c3ab53829d493e Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 16 Apr 2018 10:35:56 +0200 Subject: [PATCH 0682/1027] 3D Well Log Curves (#2671): Apply white background to curve draw plane. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 1 + .../Riv3dWellLogGridGeomertyGenerator.cpp | 121 ++++++++++++------ .../Riv3dWellLogGridGeomertyGenerator.h | 26 ++-- .../Riv3dWellLogPlanePartMgr.cpp | 60 +++++---- 4 files changed, 135 insertions(+), 73 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index b26f00f647..cfd93e3bb1 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -131,6 +131,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std // Reverse list, since it was filled in the opposite order std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); + std::reverse(interpolatedNormals.begin(), interpolatedNormals.end()); // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 2f6eba25c4..e3141ff4fb 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -44,24 +44,24 @@ Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > +bool Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, - double gridIntervalSize) const + double gridIntervalSize) { CVF_ASSERT(gridIntervalSize > 0); if (!wellPathGeometry() || wellPathGeometry()->m_measuredDepths.empty()) { - return std::map< DrawableId, cvf::ref >(); + return false; } if (!wellPathClipBoundingBox.isValid()) { - return std::map< DrawableId, cvf::ref >(); + return false; } @@ -71,7 +71,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; if (wellPathPoints.empty()) { - return std::map< DrawableId, cvf::ref >(); + return false; } size_t originalWellPathSize = wellPathPoints.size(); @@ -85,13 +85,12 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); } - if (wellPathPoints.empty()) + if (wellPathPoints.size() < (size_t) 2) { - return std::map< DrawableId, cvf::ref >(); + // Need at least two well path points to create a valid path. + return false; } - std::map< DrawableId, cvf::ref > drawables; - // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off std::vector wellPathSegmentNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); @@ -99,42 +98,73 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* { std::vector vertices; - vertices.reserve(wellPathPoints.size()); + vertices.reserve(wellPathPoints.size() * 2); - std::vector indices; - indices.reserve(wellPathPoints.size()); - cvf::uint indexCounter = 0; - // Line along and close to well + std::vector backgroundIndices; + backgroundIndices.reserve(wellPathPoints.size() * 2); + + // Vertices are used for both surface and border for (size_t i = 0; i < wellPathPoints.size(); i++) { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); - - indices.push_back(indexCounter); - indices.push_back(++indexCounter); - } - // Line along and far away from well in reverse order to create a closed surface. - for (int64_t i = (int64_t) wellPathPoints.size()-1; i >= 0; i--) - { vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); - - indices.push_back(indexCounter); - indices.push_back(++indexCounter); + backgroundIndices.push_back((cvf::uint) (2 * i)); + backgroundIndices.push_back((cvf::uint) (2 * i + 1)); } - indices.pop_back(); - indices.push_back(0u); // Close surface - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINE_LOOP); - cvf::ref indexArray = new cvf::UIntArray(indices); - - cvf::ref gridBorderDrawable = new cvf::DrawableGeo(); - - indexedUInt->setIndices(indexArray.p()); - gridBorderDrawable->addPrimitiveSet(indexedUInt.p()); - + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); - gridBorderDrawable->setVertexArray(vertexArray.p()); - drawables[GridBorder] = gridBorderDrawable; + + { + // Background specific + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); + cvf::ref indexArray = new cvf::UIntArray(backgroundIndices); + indexedUInt->setIndices(indexArray.p()); + + m_background = new cvf::DrawableGeo(); + m_background->addPrimitiveSet(indexedUInt.p()); + m_background->setVertexArray(vertexArray.p()); + } + + { + std::vector borderIndices; + borderIndices.reserve(vertices.size()); + + int secondLastEvenVertex = (int) vertices.size() - 4; + + // Border close to the well. All even indices. + for (size_t i = 0; i <= secondLastEvenVertex; i += 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i+2); + } + + // Connect to border away from well + borderIndices.push_back((cvf::uint) (vertices.size() - 2)); + borderIndices.push_back((cvf::uint) (vertices.size() - 1)); + + int secondOddVertex = 3; + int lastOddVertex = (int) vertices.size() - 1; + + // Border away from from well are odd indices in reverse order to create a closed surface. + for (int i = lastOddVertex; i >= secondOddVertex; i -= 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i - 2); + } + // Close border + borderIndices.push_back(1u); + borderIndices.push_back(0u); + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(borderIndices); + indexedUInt->setIndices(indexArray.p()); + + m_border = new cvf::DrawableGeo(); + m_border->addPrimitiveSet(indexedUInt.p()); + m_border->setVertexArray(vertexArray.p()); + } } { std::vector interpolatedGridPoints; @@ -184,9 +214,24 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* cvf::ref vertexArray = new cvf::Vec3fArray(vertices); normalLinesDrawable->setVertexArray(vertexArray.p()); - drawables[NormalLines] = normalLinesDrawable; + m_normalLines = normalLinesDrawable; } - return drawables; + return true; +} + +cvf::ref Riv3dWellLogGridGeometryGenerator::background() +{ + return m_background; +} + +cvf::ref Riv3dWellLogGridGeometryGenerator::border() +{ + return m_border; +} + +cvf::ref Riv3dWellLogGridGeometryGenerator::normalLines() +{ + return m_normalLines; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index 1f91e06625..0c6ddce54e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -42,24 +42,24 @@ class RimWellPath; class Riv3dWellLogGridGeometryGenerator : public cvf::Object { public: - enum DrawableId - { - NormalLines = 0, - GridBorder = 1, - GridBackground = 2 - }; Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath); - std::map > - createGrid(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double gridIntervalSize) const; + bool createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double gridIntervalSize); + + cvf::ref background(); + cvf::ref border(); + cvf::ref normalLines(); private: const RigWellPath* wellPathGeometry() const; private: caf::PdmPointer m_wellPath; + cvf::ref m_background; + cvf::ref m_border; + cvf::ref m_normalLines; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index e54194e9cc..f559356a58 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -223,31 +223,47 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); - caf::SurfaceEffectGenerator surfaceEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 0.5), caf::PO_1); - caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - caf::MeshEffectGenerator normalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - normalsEffectGen.setLineStipple(true); - - std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > gridDrawables = - m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, - wellPathClipBoundingBox, - planeAngle(drawPlane), - wellPathCenterToPlotStartOffset(planePosition), - planeWidth(), - gridIntervalSize); - - std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > effects; - effects[Riv3dWellLogGridGeometryGenerator::GridBackground] = surfaceEffectGen.generateCachedEffect(); - effects[Riv3dWellLogGridGeometryGenerator::GridBorder] = gridBorderEffectGen.generateCachedEffect(); - effects[Riv3dWellLogGridGeometryGenerator::NormalLines] = normalsEffectGen.generateCachedEffect(); + caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); + caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + caf::MeshEffectGenerator normalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + backgroundEffectGen.enableLighting(false); + + bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, + wellPathClipBoundingBox, + planeAngle(drawPlane), + wellPathCenterToPlotStartOffset(planePosition), + planeWidth(), + gridIntervalSize); + if (!gridCreated) return; + + cvf::ref backgroundEffect = backgroundEffectGen.generateCachedEffect(); + cvf::ref borderEffect = gridBorderEffectGen.generateCachedEffect(); cvf::ref normalsEffect = normalsEffectGen.generateCachedEffect(); - for(std::pair< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref > item : gridDrawables) + cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); + if (background.notNull()) { - Riv3dWellLogGridGeometryGenerator::DrawableId drawableId = item.first; - cvf::ref drawable = item.second; - CVF_ASSERT(drawable.notNull()); - cvf::ref part = createPart(drawable.p(), effects[drawableId].p()); + cvf::ref part = createPart(background.p(), backgroundEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + } + } + + cvf::ref border = m_3dWellLogGridGeometryGenerator->border(); + if (border.notNull()) + { + cvf::ref part = createPart(border.p(), borderEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + } + } + + cvf::ref normals = m_3dWellLogGridGeometryGenerator->normalLines(); + if (normals.notNull()) + { + cvf::ref part = createPart(normals.p(), normalsEffect.p()); if (part.notNull()) { model->addPart(part.p()); From 092624799e650f3d5e3824bb4ab10897350674e0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 16 Apr 2018 10:42:01 +0200 Subject: [PATCH 0683/1027] 3D Well Log Curves: Renaming of the term normals in curve/grid-generation * Make it more obvious we are talking about the normals to the 3D well log curve. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 14 +++++++------- .../Riv3dWellLogGridGeomertyGenerator.cpp | 18 +++++++++--------- .../Riv3dWellLogGridGeomertyGenerator.h | 4 ++-- .../Riv3dWellLogPlanePartMgr.cpp | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index cfd93e3bb1..434a2132d5 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -113,25 +113,25 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; } - std::vector wellPathNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); + std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); std::vector interpolatedWellPathPoints; - std::vector interpolatedNormals; + std::vector interpolatedCurveNormals; // Iterate from bottom of well path and up to be able to stop at given Z max clipping height for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) { cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*md); - cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathNormals, *md); + cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, *md); if (point.z() > maxZClipHeight) break; interpolatedWellPathPoints.push_back(point); - interpolatedNormals.push_back(normal.getNormalized()); + interpolatedCurveNormals.push_back(normal.getNormalized()); } if (interpolatedWellPathPoints.empty()) return; // Reverse list, since it was filled in the opposite order std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); - std::reverse(interpolatedNormals.begin(), interpolatedNormals.end()); + std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end()); // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), @@ -152,7 +152,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std double plotRangeToResultRangeFactor = planeWidth / (maxResult - minResult); - for (size_t i = 0; i < interpolatedNormals.size(); i++) + for (size_t i = 0; i < interpolatedCurveNormals.size(); i++) { double scaledResult = 0; @@ -163,7 +163,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std } (*vertices)[i] = cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * interpolatedNormals[i])); + displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i])); } std::vector> valuesIntervals = diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index e3141ff4fb..350250ea1e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -168,7 +168,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* } { std::vector interpolatedGridPoints; - std::vector interpolatedGridNormals; + std::vector interpolatedGridCurveNormals; size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); @@ -178,9 +178,9 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* while (md >= firstMd) { cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); - cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathSegmentNormals, md); + cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathSegmentNormals, md); interpolatedGridPoints.push_back(point); - interpolatedGridNormals.push_back(normal.getNormalized()); + interpolatedGridCurveNormals.push_back(curveNormal.getNormalized()); md -= gridIntervalSize; } @@ -191,13 +191,13 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* indices.reserve(interpolatedGridPoints.size()); cvf::uint indexCounter = 0; // Normal lines. Start from one to avoid drawing at surface edge. - for (size_t i = 1; i < interpolatedGridNormals.size(); i++) + for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++) { vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedGridPoints[i] + interpolatedGridNormals[i] * planeOffsetFromWellPathCenter))); + displayCoordTransform->transformToDisplayCoord(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter))); vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - interpolatedGridPoints[i] + interpolatedGridNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); indices.push_back(indexCounter++); indices.push_back(indexCounter++); @@ -214,7 +214,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* cvf::ref vertexArray = new cvf::Vec3fArray(vertices); normalLinesDrawable->setVertexArray(vertexArray.p()); - m_normalLines = normalLinesDrawable; + m_curveNormalLines = normalLinesDrawable; } return true; } @@ -229,9 +229,9 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::border() return m_border; } -cvf::ref Riv3dWellLogGridGeometryGenerator::normalLines() +cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalLines() { - return m_normalLines; + return m_curveNormalLines; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index 0c6ddce54e..a0363811e0 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -53,7 +53,7 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object cvf::ref background(); cvf::ref border(); - cvf::ref normalLines(); + cvf::ref curveNormalLines(); private: const RigWellPath* wellPathGeometry() const; @@ -61,5 +61,5 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object caf::PdmPointer m_wellPath; cvf::ref m_background; cvf::ref m_border; - cvf::ref m_normalLines; + cvf::ref m_curveNormalLines; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index f559356a58..c6cf18e25d 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -225,7 +225,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - caf::MeshEffectGenerator normalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + caf::MeshEffectGenerator curveNormalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); backgroundEffectGen.enableLighting(false); bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, @@ -238,7 +238,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* cvf::ref backgroundEffect = backgroundEffectGen.generateCachedEffect(); cvf::ref borderEffect = gridBorderEffectGen.generateCachedEffect(); - cvf::ref normalsEffect = normalsEffectGen.generateCachedEffect(); + cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); if (background.notNull()) @@ -260,10 +260,10 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - cvf::ref normals = m_3dWellLogGridGeometryGenerator->normalLines(); + cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalLines(); if (normals.notNull()) { - cvf::ref part = createPart(normals.p(), normalsEffect.p()); + cvf::ref part = createPart(normals.p(), curveNormalsEffect.p()); if (part.notNull()) { model->addPart(part.p()); From 501e80b1ad8f1f93eb9d6638b167a43e1af631a1 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 08:30:06 +0200 Subject: [PATCH 0684/1027] 3D Well Log Curves(#2671): Make curve draw plane background optional --- .../Riv3dWellLogPlanePartMgr.cpp | 50 ++++++++----------- .../Riv3dWellLogPlanePartMgr.h | 2 +- .../Rim3dWellLogCurveCollection.cpp | 28 ++++++++--- .../Completions/Rim3dWellLogCurveCollection.h | 9 +++- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 8 +-- .../ProjectDataModel/Rim3dWellLogCurve.h | 1 - 6 files changed, 56 insertions(+), 42 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index c6cf18e25d..7ff2415dda 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -69,19 +69,9 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox); - if (m_wellPath->rim3dWellLogCurveCollection()->isShowingGrid()) + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { - std::set drawPlanes; - - for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) - { - drawPlanes.insert(rim3dWellLogCurve->drawPlane()); - } - - for (const Rim3dWellLogCurve::DrawPlane& drawPlane : drawPlanes) - { - appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane, planeWidth()); - } + appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); } } @@ -217,11 +207,13 @@ cvf::Color3f Riv3dWellLogPlanePartMgr::curveColor(size_t index) void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve::DrawPlane& drawPlane, + const Rim3dWellLogCurve* rim3dWellLogCurve, double gridIntervalSize) { const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); + bool showGrid = curveCollection->isShowingGrid(); + bool showBackground = curveCollection->isShowingBackground(); caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); @@ -230,7 +222,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, wellPathClipBoundingBox, - planeAngle(drawPlane), + planeAngle(rim3dWellLogCurve->drawPlane()), wellPathCenterToPlotStartOffset(planePosition), planeWidth(), gridIntervalSize); @@ -241,7 +233,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); - if (background.notNull()) + if (showBackground && background.notNull()) { cvf::ref part = createPart(background.p(), backgroundEffect.p()); if (part.notNull()) @@ -250,23 +242,25 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - cvf::ref border = m_3dWellLogGridGeometryGenerator->border(); - if (border.notNull()) - { - cvf::ref part = createPart(border.p(), borderEffect.p()); - if (part.notNull()) + if (showGrid) { + cvf::ref border = m_3dWellLogGridGeometryGenerator->border(); + if (border.notNull()) { - model->addPart(part.p()); + cvf::ref part = createPart(border.p(), borderEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + } } - } - cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalLines(); - if (normals.notNull()) - { - cvf::ref part = createPart(normals.p(), curveNormalsEffect.p()); - if (part.notNull()) + cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalLines(); + if (normals.notNull()) { - model->addPart(part.p()); + cvf::ref part = createPart(normals.p(), curveNormalsEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + } } } } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 79af71486d..d59806e36c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -64,7 +64,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve::DrawPlane& drawPlane, + const Rim3dWellLogCurve* rim3dWellLogCurve, double gridIntervalSize); cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 7f1379968e..61f492128f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -18,6 +18,7 @@ #include "Rim3dWellLogCurveCollection.h" +#include "RiaColorTables.h" #include "Rim3dWellLogCurve.h" #include "RimWellPath.h" #include "RimProject.h" @@ -45,10 +46,10 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() CAF_PDM_InitField(&m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); m_showPlot.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_planePosition, "PlanePosition", "Plane Position", "", "", ""); + CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); + CAF_PDM_InitField(&m_showBackground, "Show3dWellLogBackground", false, "Show Background", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); } @@ -88,6 +89,14 @@ void Rim3dWellLogCurveCollection::remove3dWellLogCurve(Rim3dWellLogCurve* curve) m_3dWellLogCurves.removeChildObject(curve); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::isShowingPlot() const +{ + return m_showPlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -99,13 +108,14 @@ bool Rim3dWellLogCurveCollection::isShowingGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Rim3dWellLogCurveCollection::isShowingPlot() const +bool Rim3dWellLogCurveCollection::isShowingBackground() const { - return m_showPlot; + return m_showBackground; } + //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePosition() const { @@ -168,8 +178,12 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Track Settings"); + caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Settings"); - settingsGroup->add(&m_showGrid); settingsGroup->add(&m_planePosition); + + caf::PdmUiGroup* appearanceSettingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); + appearanceSettingsGroup->add(&m_showGrid); + appearanceSettingsGroup->add(&m_showBackground); + } diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 809ecec4ce..82a5f58743 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -48,13 +48,15 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject void add3dWellLogCurve(Rim3dWellLogCurve* curve); void remove3dWellLogCurve(Rim3dWellLogCurve* curve); - bool isShowingGrid() const; bool isShowingPlot() const; + bool isShowingGrid() const; + bool isShowingBackground() const; PlanePosition planePosition() const; std::vector vectorOf3dWellLogCurves() const; void redrawAffectedViewsAndEditors(); + private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; @@ -63,8 +65,11 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject private: caf::PdmField m_showPlot; - caf::PdmField m_showGrid; caf::PdmField> m_planePosition; + caf::PdmField m_showGrid; + caf::PdmField m_showBackground; + + caf::PdmChildArrayField m_3dWellLogCurves; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 2e6ae4e627..f68bb6e059 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -164,8 +164,10 @@ caf::PdmFieldHandle* Rim3dWellLogCurve::userDescriptionField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_drawPlane); - uiOrdering.add(&m_drawStyle); - uiOrdering.add(&m_coloringStyle); + caf::PdmUiGroup* curveAppearanceGroup = uiOrdering.addNewGroup("Curve Appearance"); + curveAppearanceGroup->add(&m_drawPlane); + curveAppearanceGroup->add(&m_drawStyle); + curveAppearanceGroup->add(&m_coloringStyle); + } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 24b5827e08..0c68618ef5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -71,7 +71,6 @@ class Rim3dWellLogCurve : public caf::PdmObject virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* userDescriptionField() override; - void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); protected: From 1180c199b451c813ab8095fd0f3830145da3db14 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 08:38:13 +0200 Subject: [PATCH 0685/1027] 3D Well Log Curves (#2669): Implement control of single color. * Set a cycled default whenever a curve is added to a collection. --- .../Riv3dWellLogPlanePartMgr.cpp | 10 +--------- .../Riv3dWellLogPlanePartMgr.h | 2 -- .../Rim3dWellLogCurveCollection.cpp | 2 ++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 20 +++++++++++++++++-- .../ProjectDataModel/Rim3dWellLogCurve.h | 8 +++++++- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 7ff2415dda..6bb01d9ede 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -114,7 +114,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* continue; } - caf::MeshEffectGenerator meshEffectGen(curveColor(colorIndex)); + caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); meshEffectGen.setLineWidth(2.0f); cvf::ref effect = meshEffectGen.generateCachedEffect(); @@ -193,14 +193,6 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const return cellSize * 1.0; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Color3f Riv3dWellLogPlanePartMgr::curveColor(size_t index) -{ - return RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index d59806e36c..98833dc860 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -74,8 +74,6 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object double wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const; double planeWidth() const; - cvf::Color3f curveColor(size_t index); - private: cvf::ref m_3dWellLogCurveGeometryGenerator; cvf::ref m_3dWellLogGridGeometryGenerator; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 61f492128f..b04ecfaddd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -77,6 +77,8 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) { if (curve) { + size_t index = m_3dWellLogCurves.size(); + curve->setColor(RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index)); m_3dWellLogCurves.push_back(curve); } } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index f68bb6e059..2fde3c90fa 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -72,7 +72,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitFieldNoDefault(&m_drawPlane, "DrawPlane", "Draw Plane", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_drawStyle, "DrawStyle", "Draw Style", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_coloringStyle, "ColoringStyle", "Coloring Style", "", "", ""); - + CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); m_name.uiCapability()->setUiHidden(true); } @@ -118,6 +118,14 @@ Rim3dWellLogCurve::ColoringStyle Rim3dWellLogCurve::coloringStyle() const return m_coloringStyle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f Rim3dWellLogCurve::color() const +{ + return m_color; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -126,6 +134,14 @@ bool Rim3dWellLogCurve::isShowingCurve() const return m_showCurve; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::setColor(const cvf::Color3f& color) +{ + m_color = color; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -168,6 +184,6 @@ void Rim3dWellLogCurve::appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering) curveAppearanceGroup->add(&m_drawPlane); curveAppearanceGroup->add(&m_drawStyle); curveAppearanceGroup->add(&m_coloringStyle); - + curveAppearanceGroup->add(&m_color); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 0c68618ef5..e060f9ef45 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -22,6 +22,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cafPdmFieldCvfColor.h" + //================================================================================================== /// /// @@ -63,10 +65,12 @@ class Rim3dWellLogCurve : public caf::PdmObject DrawPlane drawPlane() const; DrawStyle drawStyle() const; ColoringStyle coloringStyle() const; + cvf::Color3f color() const; bool isShowingCurve() const; - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; + void setColor(const cvf::Color3f& color); protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -78,6 +82,8 @@ class Rim3dWellLogCurve : public caf::PdmObject caf::PdmField> m_drawPlane; caf::PdmField> m_drawStyle; caf::PdmField> m_coloringStyle; + caf::PdmField m_color; + private: caf::PdmField m_showCurve; From 290d58e7fdbc60b2c44b2d32f32570e152e7a4f7 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 08:43:08 +0200 Subject: [PATCH 0686/1027] 3D Well Log Curves(#2678): Remove curve drawing options that aren't yet implemented. * drawing style (i.e. filled) * coloring style (i.e. color by curve value) --- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 39 +------------------ .../ProjectDataModel/Rim3dWellLogCurve.h | 17 -------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 2fde3c90fa..244a667477 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -39,24 +39,7 @@ namespace caf addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE1, "CAMERA_ALIGNED_SIDE_1", "Camera Aligned - Side 1"); addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE2, "CAMERA_ALIGNED_SIDE_2", "Camera Aligned - Side 2"); setDefault(Rim3dWellLogCurve::HORIZONTAL_LEFT); - } - - template<> - void AppEnum< Rim3dWellLogCurve::DrawStyle >::setUp() - { - addItem(Rim3dWellLogCurve::LINE, "LINE", "Line"); - addItem(Rim3dWellLogCurve::FILLED, "FILLED", "Filled"); - setDefault(Rim3dWellLogCurve::LINE); - } - - template<> - void AppEnum< Rim3dWellLogCurve::ColoringStyle >::setUp() - { - addItem(Rim3dWellLogCurve::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); - addItem(Rim3dWellLogCurve::CURVE_VALUE, "CURVE_VALUE", "Curve Value"); - addItem(Rim3dWellLogCurve::OTHER_RESULT, "OTHER_RESULT", "Other Result"); - setDefault(Rim3dWellLogCurve::SINGLE_COLOR); - } + } } //-------------------------------------------------------------------------------------------------- @@ -70,8 +53,6 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() m_showCurve.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_drawPlane, "DrawPlane", "Draw Plane", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_drawStyle, "DrawStyle", "Draw Style", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_coloringStyle, "ColoringStyle", "Coloring Style", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); m_name.uiCapability()->setUiHidden(true); @@ -102,22 +83,6 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurve::DrawStyle Rim3dWellLogCurve::drawStyle() const -{ - return m_drawStyle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurve::ColoringStyle Rim3dWellLogCurve::coloringStyle() const -{ - return m_coloringStyle(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -182,8 +147,6 @@ void Rim3dWellLogCurve::appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* curveAppearanceGroup = uiOrdering.addNewGroup("Curve Appearance"); curveAppearanceGroup->add(&m_drawPlane); - curveAppearanceGroup->add(&m_drawStyle); - curveAppearanceGroup->add(&m_coloringStyle); curveAppearanceGroup->add(&m_color); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index e060f9ef45..e923857487 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -43,19 +43,6 @@ class Rim3dWellLogCurve : public caf::PdmObject CAMERA_ALIGNED_SIDE2 }; - enum DrawStyle - { - LINE, - FILLED - }; - - enum ColoringStyle - { - SINGLE_COLOR, - CURVE_VALUE, - OTHER_RESULT - }; - public: Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); @@ -63,8 +50,6 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); DrawPlane drawPlane() const; - DrawStyle drawStyle() const; - ColoringStyle coloringStyle() const; cvf::Color3f color() const; bool isShowingCurve() const; @@ -80,8 +65,6 @@ class Rim3dWellLogCurve : public caf::PdmObject protected: caf::PdmField m_name; caf::PdmField> m_drawPlane; - caf::PdmField> m_drawStyle; - caf::PdmField> m_coloringStyle; caf::PdmField m_color; From 36b1dcf85fd080c5a5b1dac407b64df41f586c96 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 08:46:53 +0200 Subject: [PATCH 0687/1027] 3D Well Log Curves(#2678): Remove camera aligned draw plane --- ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp | 8 +++----- ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 244a667477..79c5767f10 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -32,13 +32,11 @@ namespace caf template<> void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() { - addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Horizontal - Left"); - addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Horizontal - Right"); addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Vertical - Above"); addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Vertical - Below"); - addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE1, "CAMERA_ALIGNED_SIDE_1", "Camera Aligned - Side 1"); - addItem(Rim3dWellLogCurve::CAMERA_ALIGNED_SIDE2, "CAMERA_ALIGNED_SIDE_2", "Camera Aligned - Side 2"); - setDefault(Rim3dWellLogCurve::HORIZONTAL_LEFT); + addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Horizontal - Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Horizontal - Right"); + setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); } } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index e923857487..0d34c289a7 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -35,12 +35,10 @@ class Rim3dWellLogCurve : public caf::PdmObject public: enum DrawPlane { - HORIZONTAL_LEFT, - HORIZONTAL_RIGHT, VERTICAL_ABOVE, VERTICAL_BELOW, - CAMERA_ALIGNED_SIDE1, - CAMERA_ALIGNED_SIDE2 + HORIZONTAL_LEFT, + HORIZONTAL_RIGHT }; public: From 9da3f09782fb8aa57d316d8c1b8bb3d64e307748 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 09:40:30 +0200 Subject: [PATCH 0688/1027] 3D Well Log Curves (#2668): Implement Draw-plane width control * Apply a factor between 0.25 and 2.5 times the characteristic cell size * Make the offset from the pipe scale with the plane width up to a maximum offset. * Organise the CurveCollection settings into two groups. --- .../Riv3dWellLogPlanePartMgr.cpp | 7 +++-- .../Rim3dWellLogCurveCollection.cpp | 31 ++++++++++++++++--- .../Completions/Rim3dWellLogCurveCollection.h | 5 +-- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 6bb01d9ede..25e3640b25 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -173,7 +173,8 @@ double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCur if (planePosition == Rim3dWellLogCurveCollection::ALONG_WELLPATH) { - return m_wellPath->wellPathRadius(cellSize) * 2; + double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth()); + return m_wellPath->wellPathRadius(cellSize) + wellPathOffset; } else { @@ -189,8 +190,8 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const if (!m_gridView) return 0; double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - - return cellSize * 1.0; + const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + return cellSize * curveCollection->planeWidthScaling(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index b04ecfaddd..89ca5351e9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -23,6 +23,8 @@ #include "RimWellPath.h" #include "RimProject.h" +#include "cafPdmUiDoubleSliderEditor.h" + CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); namespace caf @@ -47,7 +49,8 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() m_showPlot.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_planePosition, "PlanePosition", "Plane Position", "", "", ""); - + CAF_PDM_InitField(&m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Plane Width Scaling Factor", "", "", ""); + m_planeWidthScaling.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); CAF_PDM_InitField(&m_showBackground, "Show3dWellLogBackground", false, "Show Background", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); @@ -100,7 +103,7 @@ bool Rim3dWellLogCurveCollection::isShowingPlot() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool Rim3dWellLogCurveCollection::isShowingGrid() const { @@ -124,6 +127,14 @@ Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePos return m_planePosition(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float Rim3dWellLogCurveCollection::planeWidthScaling() const +{ + return m_planeWidthScaling; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -181,11 +192,23 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Settings"); - settingsGroup->add(&m_planePosition); - + settingsGroup->add(&m_planeWidthScaling); + caf::PdmUiGroup* appearanceSettingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); appearanceSettingsGroup->add(&m_showGrid); appearanceSettingsGroup->add(&m_showBackground); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiDoubleSliderEditorAttribute* widthAttribute = dynamic_cast(attribute); + if (widthAttribute) + { + widthAttribute->m_minimum = 0.25; + widthAttribute->m_maximum = 2.5; + } } diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 82a5f58743..da3f2cfedf 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -53,6 +53,7 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool isShowingBackground() const; PlanePosition planePosition() const; + float planeWidthScaling() const; std::vector vectorOf3dWellLogCurves() const; void redrawAffectedViewsAndEditors(); @@ -61,11 +62,11 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); private: caf::PdmField m_showPlot; - caf::PdmField> m_planePosition; + caf::PdmField m_planeWidthScaling; caf::PdmField m_showGrid; caf::PdmField m_showBackground; From 7a2979ca5608ef441c1a95cb0e39a9043adec393 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 13:53:26 +0200 Subject: [PATCH 0689/1027] Always show all completion type categories in Property Filter Revert change introduced in 0f696b81 --- .../ProjectDataModel/RimEclipsePropertyFilter.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index 349fa4f4a9..ec2d91f925 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -389,19 +389,12 @@ void RimEclipsePropertyFilter::computeResultValueRange() } else if (resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) { - std::vector> categoryNameAndValues; + std::vector ctNames; + for (const QString& ctName : caf::AppEnum::uiTexts()) { - const std::vector& visibleCatetories = results->uniqueCellScalarValues(resultDefinition->scalarResultIndex()); - for (auto categoryValue : visibleCatetories) - { - if (caf::AppEnum::isValid(categoryValue)) - { - auto text = caf::AppEnum::uiText(RiaDefines::CompletionType(categoryValue)); - categoryNameAndValues.push_back(std::make_pair(text, categoryValue)); - } - } + ctNames.push_back(ctName); } - setCategoryNamesAndValues(categoryNameAndValues); + setCategoryNames(ctNames); } else { From ba3074ff08e93434bbca671b048477d4a6e9968d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 14:14:31 +0200 Subject: [PATCH 0690/1027] #2748 Completion Type Calculations : Use findIntersectedGlobalCellIndices --- .../RimCompletionCellIntersectionCalc.cpp | 149 ++++++++++-------- .../RimCompletionCellIntersectionCalc.h | 43 +++-- .../RigCaseCellResultsData.cpp | 2 +- .../RigWellPathIntersectionTools.cpp | 54 ++++++- .../RigWellPathIntersectionTools.h | 4 + 5 files changed, 162 insertions(+), 90 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 9b1423bb12..a717a42f96 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,85 +19,90 @@ #include "RimCompletionCellIntersectionCalc.h" #include "RiaDefines.h" + +#include "RigCellGeometryTools.h" +#include "RigEclipseCaseData.h" +#include "RigFractureCell.h" +#include "RigFractureGrid.h" +#include "RigHexIntersectionTools.h" +#include "RigMainGrid.h" +#include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" + #include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimSimWellInViewCollection.h" #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" +#include "RimFracture.h" +#include "RimFractureTemplate.h" #include "RimOilField.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" #include "RimProject.h" +#include "RimSimWellFracture.h" +#include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathCompletions.h" - -#include "RigMainGrid.h" -#include "RigWellPath.h" -#include "RigWellPathIntersectionTools.h" -#include "RigCellGeometryTools.h" - -#include "RimFracture.h" #include "RimWellPathFracture.h" -#include "RimFractureTemplate.h" #include "RimWellPathFractureCollection.h" -#include "RimSimWellFractureCollection.h" -#include "RimSimWellFracture.h" -#include "RigFractureGrid.h" -#include "RigFractureCell.h" - #include -#include "RigHexIntersectionTools.h" //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - const RigMainGrid* grid, - std::vector& completionTypeCellResults, - const QDateTime& fromDate) +void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimProject* project, + const RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResults, + const QDateTime& fromDate) { + CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); + + const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) { if (wellPath->showWellPath()) { - calculateWellPathIntersections(wellPath, grid, completionTypeCellResults, fromDate); + calculateWellPathIntersections(wellPath, eclipseCaseData, completionTypeCellResults, fromDate); } } - for (RimEclipseView* view : eclipseCase->reservoirViews()) + const RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); + if (mainGrid) { - for (RimSimWellInView* simWell : view->wellCollection()->wells()) + for (RimEclipseView* view : eclipseCase->reservoirViews()) { - for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) + for (RimSimWellInView* simWell : view->wellCollection()->wells()) { - calculateFractureIntersections(grid, fracture, completionTypeCellResults); + for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) + { + calculateFractureIntersections(mainGrid, fracture, completionTypeCellResults); + } } } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, - const RigMainGrid* grid, - std::vector& values, - const QDateTime& fromDate) +void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values, + const QDateTime& fromDate) { - std::vector intersections; if (wellPath->wellPathGeometry()) { - intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - wellPath->wellPathGeometry()->m_wellPathPoints); - } - - for (auto& intersection : intersections) - { - values[intersection.m_hexIndex] = RiaDefines::WELL_PATH; + auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); + for (auto& intersection : intersectedCells) + { + values[intersection] = RiaDefines::WELL_PATH; + } } if (wellPath->fishbonesCollection()->isChecked()) @@ -106,13 +111,15 @@ void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const Rim { if (fishbones->isActive()) { - calculateFishbonesIntersections(fishbones, grid, values); + calculateFishbonesIntersections(fishbones, eclipseCaseData, values); } } } if (wellPath->fractureCollection()->isChecked()) { + const RigMainGrid* grid = eclipseCaseData->mainGrid(); + for (const RimWellPathFracture* fracture : wellPath->fractureCollection()->fractures()) { if (fracture->isChecked()) @@ -128,55 +135,59 @@ void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const Rim { if (perforationInterval->isChecked() && perforationInterval->isActiveOnDate(fromDate)) { - calculatePerforationIntersections(wellPath, perforationInterval, grid, values); + calculatePerforationIntersections(wellPath, perforationInterval, eclipseCaseData, values); } } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values) +void RimCompletionCellIntersectionCalc::calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values) { for (auto& sub : fishbonesSubs->installedLateralIndices()) { for (size_t lateralIndex : sub.lateralIndices) { - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - fishbonesSubs->coordsForLateral(sub.subIndex, lateralIndex)); - for (auto& intersection : intersections) + auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, fishbonesSubs->coordsForLateral(sub.subIndex, lateralIndex)); + for (auto& intersection : intersectedCells) { - values[intersection.m_hexIndex] = RiaDefines::FISHBONES; + values[intersection] = RiaDefines::FISHBONES; } } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const RimWellPath* wellPath, - const RimPerforationInterval* perforationInterval, - const RigMainGrid* grid, - std::vector& values) +void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const RimWellPath* wellPath, + const RimPerforationInterval* perforationInterval, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values) { using namespace std; - pair, vector > clippedWellPathData = wellPath->wellPathGeometry()->clippedPointSubset(perforationInterval->startMD(), - perforationInterval->endMD()); + pair, vector> clippedWellPathData = + wellPath->wellPathGeometry()->clippedPointSubset(perforationInterval->startMD(), perforationInterval->endMD()); - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - clippedWellPathData.first); + auto intersections = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, clippedWellPathData.first, clippedWellPathData.second); for (auto& intersection : intersections) { - values[intersection.m_hexIndex] = RiaDefines::PERFORATION_INTERVAL; + values[intersection] = RiaDefines::PERFORATION_INTERVAL; } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values) +void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, + const RimFracture* fracture, + std::vector& values) { if (!fracture->fractureTemplate()) return; if (!fracture->fractureTemplate()->fractureGrid()) return; @@ -198,7 +209,7 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig { cvf::BoundingBox boundingBox; - for (cvf::Vec3d nodeCoord : fractureCellTransformed) + for (const cvf::Vec3d& nodeCoord : fractureCellTransformed) { boundingBox.add(nodeCoord); } @@ -213,8 +224,10 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig std::array hexCorners; mainGrid->cellCornerVertices(cellIndex, hexCorners.data()); - std::vector< std::vector > planeCellPolygons; - bool isPlaneIntersected = RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, fracture->transformMatrix(), planeCellPolygons); + std::vector> planeCellPolygons; + + bool isPlaneIntersected = + RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, fracture->transformMatrix(), planeCellPolygons); if (!isPlaneIntersected || planeCellPolygons.empty()) continue; { @@ -230,7 +243,8 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig for (const std::vector& planeCellPolygon : planeCellPolygons) { - std::vector< std::vector > clippedPolygons = RigCellGeometryTools::intersectPolygons(planeCellPolygon, fractureCell.getPolygon()); + std::vector> clippedPolygons = + RigCellGeometryTools::intersectPolygons(planeCellPolygon, fractureCell.getPolygon()); for (const auto& clippedPolygon : clippedPolygons) { if (!clippedPolygon.empty()) @@ -241,6 +255,5 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig } } } - } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index c35b68ba4b..da399c70d4 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -27,25 +27,38 @@ class RimFracture; class RimPerforationInterval; class RimProject; class RimWellPath; +class RigEclipseCaseData; class QDateTime; //================================================================================================== -/// -/// +/// +/// //================================================================================================== class RimCompletionCellIntersectionCalc { public: - static void calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - const RigMainGrid* grid, - std::vector& completionTypeCellResult, - const QDateTime& fromDate); + static void calculateCompletionTypeResult(const RimProject* project, + const RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + const QDateTime& fromDate); private: - static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); - static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values); - static void calculatePerforationIntersections(const RimWellPath* wellPath, const RimPerforationInterval* perforationInterval, const RigMainGrid* grid, std::vector& values); - static void calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values); + static void calculateWellPathIntersections(const RimWellPath* wellPath, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values, + const QDateTime& fromDate); + + static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values); + + static void calculatePerforationIntersections(const RimWellPath* wellPath, + const RimPerforationInterval* perforationInterval, + const RigEclipseCaseData* eclipseCaseData, + std::vector& values); + + static void calculateFractureIntersections(const RigMainGrid* mainGrid, + const RimFracture* fracture, + std::vector& values); }; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index fdb025eb30..3561ca9f00 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2259,7 +2259,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) QDateTime timeStepDate = this->timeStepDates()[timeStep]; - RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, m_ownerMainGrid, completionTypeResult, timeStepDate); + RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, completionTypeResult, timeStepDate); } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index a19e1f1a55..dccfb5f0e3 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -20,17 +20,19 @@ #include "RiaLogging.h" -#include "RigWellPath.h" -#include "RigMainGrid.h" +#include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigMainGrid.h" +#include "RigSimulationWellCoordsAndMD.h" #include "RigWellLogExtractionTools.h" -#include "RigCellGeometryTools.h" +#include "RigWellPath.h" -#include "cvfGeometryTools.h" -#include "cvfMatrix3.h" -#include "RigEclipseWellLogExtractor.h" #include "RimEclipseCase.h" +//#include "cvfGeometryTools.h" +//#include "cvfMatrix3.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -54,6 +56,46 @@ std::vector RigWellPathIntersectionTools::findCell return extractor->cellIntersectionInfosAlongWellPath(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, + const std::vector& coords, + const std::vector& measuredDepths) +{ + std::set globalCellIndices; + + if (caseData) + { + cvf::ref dummyWellPath = new RigWellPath; + + if (measuredDepths.size() == coords.size()) + { + dummyWellPath->m_wellPathPoints = coords; + dummyWellPath->m_measuredDepths = measuredDepths; + } + else + { + RigSimulationWellCoordsAndMD helper(coords); + + dummyWellPath->m_wellPathPoints = helper.wellPathPoints(); + dummyWellPath->m_measuredDepths = helper.measuredDepths(); + } + + cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, + dummyWellPath.p(), + caseData->ownerCase()->caseUserDescription().toStdString()); + + std::vector intersections = extractor->cellIntersectionInfosAlongWellPath(); + for (const auto& intersection : intersections) + { + globalCellIndices.insert(intersection.globCellIndex); + } + } + + return globalCellIndices; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index 0fcc67a5b8..2beba3dc7e 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -40,6 +40,10 @@ class RigWellPathIntersectionTools const std::vector& pathCoords, const std::vector& pathMds); + static std::set findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, + const std::vector& coords, + const std::vector& measuredDepths = {}); + static std::vector findRawHexCellIntersections(const RigMainGrid* grid, const std::vector& coords); static cvf::Vec3d calculateLengthInCell(const std::array& hexCorners, From f3a235b9df7a2eb708d8597d8537d8b8cc863ea9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 14:41:50 +0200 Subject: [PATCH 0691/1027] #2748 Completion Type Calculations : Remove unused code --- ...sTransmissibilityCalculationFeatureImp.cpp | 28 +----- ...nesTransmissibilityCalculationFeatureImp.h | 2 - .../RigWellPathIntersectionTools.cpp | 90 +++++-------------- .../RigWellPathIntersectionTools.h | 39 ++++---- 4 files changed, 47 insertions(+), 112 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index f1947ed92c..e4775e46c6 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -210,11 +210,11 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate if (!wellPath) return; if (!wellPath->wellPathGeometry()) return; - - std::set wellPathCells = RicFishbonesTransmissibilityCalculationFeatureImp::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), - wellPath->wellPathGeometry()->m_wellPathPoints); - bool isMainBore = false; + std::set wellPathCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndicesForWellPath( + settings.caseToApply()->eclipseCaseData(), wellPath->wellPathGeometry()); + + bool isMainBore = false; double diameter = wellPath->fishbonesCollection()->wellPathCollection()->holeDiameter(unitSystem); for (const RimFishboneWellPath* fishbonesPath : wellPath->fishbonesCollection()->wellPathCollection()->wellPaths()) { @@ -282,23 +282,3 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RicFishbonesTransmissibilityCalculationFeatureImp::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) -{ - std::set cells; - - if (!caseData) - { - return cells; - } - - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); - for (auto intersection : intersections) - { - cells.insert(intersection.m_hexIndex); - } - - return cells; -} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h index cb2c9b6752..651a23f3e8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h @@ -56,6 +56,4 @@ class RicFishbonesTransmissibilityCalculationFeatureImp static void findMainWellBoreParts(std::map>& wellBorePartsInCells, const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); - - static std::set findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords); }; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index dccfb5f0e3..fb23d14f8b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -30,8 +30,6 @@ #include "RimEclipseCase.h" -//#include "cvfGeometryTools.h" -//#include "cvfMatrix3.h" //-------------------------------------------------------------------------------------------------- /// @@ -59,31 +57,14 @@ std::vector RigWellPathIntersectionTools::findCell //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, - const std::vector& coords, - const std::vector& measuredDepths) +std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndicesForWellPath(const RigEclipseCaseData* caseData, const RigWellPath* wellPath) { std::set globalCellIndices; if (caseData) { - cvf::ref dummyWellPath = new RigWellPath; - - if (measuredDepths.size() == coords.size()) - { - dummyWellPath->m_wellPathPoints = coords; - dummyWellPath->m_measuredDepths = measuredDepths; - } - else - { - RigSimulationWellCoordsAndMD helper(coords); - - dummyWellPath->m_wellPathPoints = helper.wellPathPoints(); - dummyWellPath->m_measuredDepths = helper.measuredDepths(); - } - - cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, - dummyWellPath.p(), + cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, + wellPath, caseData->ownerCase()->caseUserDescription().toStdString()); std::vector intersections = extractor->cellIntersectionInfosAlongWellPath(); @@ -94,37 +75,39 @@ std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( } return globalCellIndices; + } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellPathIntersectionTools::findRawHexCellIntersections(const RigMainGrid* grid, - const std::vector& coords) +std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, + const std::vector& coords, + const std::vector& measuredDepths) { - std::vector intersections; - for (size_t i = 0; i < coords.size() - 1; ++i) - { - cvf::BoundingBox bb; - bb.add(coords[i]); - bb.add(coords[i + 1]); - - std::vector closeCells = findCloseCells(grid, bb); + std::set globalCellIndices; - std::array hexCorners; + if (caseData) + { + cvf::ref dummyWellPath = new RigWellPath; - for (size_t closeCell : closeCells) + if (measuredDepths.size() == coords.size()) { - const RigCell& cell = grid->globalCellArray()[closeCell]; - if (cell.isInvalid()) continue; - - grid->cellCornerVertices(closeCell, hexCorners.data()); + dummyWellPath->m_wellPathPoints = coords; + dummyWellPath->m_measuredDepths = measuredDepths; + } + else + { + RigSimulationWellCoordsAndMD helper(coords); - RigHexIntersectionTools::lineHexCellIntersection(coords[i], coords[i + 1], hexCorners.data(), closeCell, &intersections); + dummyWellPath->m_wellPathPoints = helper.wellPathPoints(); + dummyWellPath->m_measuredDepths = helper.measuredDepths(); } + + globalCellIndices = findIntersectedGlobalCellIndicesForWellPath(caseData, dummyWellPath.p()); } - return intersections; + return globalCellIndices; } //-------------------------------------------------------------------------------------------------- @@ -172,30 +155,3 @@ std::vector RigWellPathIntersectionTools::findCloseCells(const RigMainGr return closeCells; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigWellPathIntersectionTools::findCellFromCoords(const RigMainGrid* grid, const cvf::Vec3d& coords, bool* foundCell) -{ - cvf::BoundingBox bb; - bb.add(coords); - std::vector closeCells = findCloseCells(grid, bb); - std::array hexCorners; - - for (size_t closeCell : closeCells) - { - const RigCell& cell = grid->globalCellArray()[closeCell]; - if (cell.isInvalid()) continue; - - grid->cellCornerVertices(closeCell, hexCorners.data()); - - if (RigHexIntersectionTools::isPointInCell(coords, hexCorners.data())) - { - *foundCell = true; - return closeCell; - } - } - - *foundCell = false; - return 0; -} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index 2beba3dc7e..413d72e1e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,8 +19,8 @@ #pragma once #include "cvfBase.h" -#include "cvfVector3.h" #include "cvfBoundingBox.h" +#include "cvfVector3.h" #include @@ -31,30 +31,31 @@ struct HexIntersectionInfo; struct WellPathCellIntersectionInfo; //================================================================================================== -/// +/// //================================================================================================== class RigWellPathIntersectionTools { public: - static std::vector findCellIntersectionInfosAlongPath(const RigEclipseCaseData* caseData, + static std::vector findCellIntersectionInfosAlongPath(const RigEclipseCaseData* caseData, const std::vector& pathCoords, - const std::vector& pathMds); + const std::vector& pathMds); + + static std::set findIntersectedGlobalCellIndicesForWellPath(const RigEclipseCaseData* caseData, + const RigWellPath* wellPath); static std::set findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, const std::vector& coords, const std::vector& measuredDepths = {}); - static std::vector findRawHexCellIntersections(const RigMainGrid* grid, const std::vector& coords); - - static cvf::Vec3d calculateLengthInCell(const std::array& hexCorners, - const cvf::Vec3d& startPoint, - const cvf::Vec3d& endPoint); - static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, - size_t cellIndex, - const cvf::Vec3d& startPoint, - const cvf::Vec3d& endPoint); + static cvf::Vec3d calculateLengthInCell(const std::array& hexCorners, + const cvf::Vec3d& startPoint, + const cvf::Vec3d& endPoint); - static std::vector findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); - static size_t findCellFromCoords(const RigMainGrid* caseData, const cvf::Vec3d& coords, bool* foundCell); + static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, + size_t cellIndex, + const cvf::Vec3d& startPoint, + const cvf::Vec3d& endPoint); +private: + static std::vector findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); }; From 2452c965ab10fa69b3327c74bba9943098f2ed3e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Apr 2018 16:01:29 +0200 Subject: [PATCH 0692/1027] #2728 Well CF Visualization: Contributions in same cell are not added --- .../UserInterface/RiuViewerCommands.cpp | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index ddadc56f74..303728c10f 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -649,43 +649,50 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM if (eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities()) { - auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); - size_t timeStep = eclipseView->currentTimeStep(); - - const auto& completionData = connectionFactors->multipleCompletionsPerEclipseCell(wellConnectionSourceInfo->wellPath(), timeStep); + std::vector completionsForOneCell; - for (const auto& compData : completionData) { - if (compData.first.globalCellIndex() == globalCellIndex) + auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); + size_t timeStep = eclipseView->currentTimeStep(); + + const auto& multipleCompletions = connectionFactors->multipleCompletionsPerEclipseCell(wellConnectionSourceInfo->wellPath(), timeStep); + + RigCompletionDataGridCell completionGridCell(globalCellIndex, eclipseCase->eclipseCaseData()->mainGrid()); + auto completionDataIt = multipleCompletions.find(completionGridCell); + if (completionDataIt != multipleCompletions.end()) { - auto completionDataItems = compData.second; + completionsForOneCell = completionDataIt->second; + } + } - if (!completionDataItems.empty()) - { - QString resultInfoText; - resultInfoText += QString("Well Connection Factor : %1

").arg(connectionFactor); + if (!completionsForOneCell.empty()) + { + double aggregatedConnectionFactor = 0.0; + for (const auto& completionData : completionsForOneCell) + { + aggregatedConnectionFactor += completionData.transmissibility(); + } - { - RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); + QString resultInfoText; + resultInfoText += QString("Well Connection Factor : %1

").arg(aggregatedConnectionFactor); - resultInfoText += textBuilder.geometrySelectionText("
"); - } + { + RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); - resultInfoText += "

Details :
"; + resultInfoText += textBuilder.geometrySelectionText("
"); + } - for (const auto& completionData : completionDataItems) - { - for (const auto& metaData : completionData.metadata()) - { - resultInfoText += QString("Name %1 Description %2
").arg(metaData.name).arg(metaData.comment); - } - } + resultInfoText += "

Details :
"; - RiuMainWindow::instance()->setResultInfo(resultInfoText); + for (const auto& completionData : completionsForOneCell) + { + for (const auto& metaData : completionData.metadata()) + { + resultInfoText += QString("Name %1 Description %2
").arg(metaData.name).arg(metaData.comment); } - - break; } + + RiuMainWindow::instance()->setResultInfo(resultInfoText); } } } From c3e9a395328e2dcded8dae6f559c95037b419316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 18 Apr 2018 08:32:16 +0200 Subject: [PATCH 0693/1027] #2688 Set different curves color for each curve set --- .../Summary/RimEnsambleCurveSet.cpp | 132 +++++++++++------- .../Summary/RimEnsambleCurveSet.h | 6 +- .../Summary/RimEnsambleCurveSetCollection.cpp | 21 +++ .../Summary/RimEnsambleCurveSetCollection.h | 3 +- .../Summary/RimSummaryPlot.cpp | 12 +- .../ProjectDataModel/Summary/RimSummaryPlot.h | 1 + 6 files changed, 120 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index a35a19c488..7dbf587ea6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -157,6 +157,14 @@ bool RimEnsambleCurveSet::isCurvesVisible() return m_showCurves() && (coll ? coll->isCurveSetsVisible() : true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::setColor(cvf::Color3f color) +{ + m_color = color; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -184,14 +192,12 @@ void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::setParentQwtPlotAndReplot(QwtPlot* plot) +void RimEnsambleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) { for (RimSummaryCurve* curve : m_curves) { curve->setParentQwtPlotNoReplot(plot); } - - if (plot) plot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -228,6 +234,11 @@ void RimEnsambleCurveSet::addCurve(RimSummaryCurve* curve) { if (curve) { + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot) curve->setParentQwtPlotNoReplot(plot->qwtPlot()); + + curve->setColor(m_color); m_curves.push_back(curve); } } @@ -422,6 +433,9 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } else if (changedField == &m_yValuesSummaryGroup || changedField == &m_yValuesSelectedVariableDisplayField) { + // Update backing field + m_yValuesCurveVariable->setAddress(m_yValuesSelectedVariableDisplayField); + deleteAllCurves(); RimSummaryPlot* plot; @@ -439,7 +453,6 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie curve->setSummaryAddressY(addr); addCurve(curve); - curve->setParentQwtPlotNoReplot(plot->qwtPlot()); curve->updateCurveVisibility(true); curve->loadDataAndUpdate(true); @@ -454,56 +467,20 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } } } - else if (changedField == &m_ensambleParameter) + else if (changedField == &m_ensambleParameter || + changedField == &m_color || + changedField == &m_colorMode) { - RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); - QString parameterName = m_ensambleParameter(); - if (group && !parameterName.isEmpty()) - { - double minValue = HUGE_VAL; - double maxValue = -HUGE_VAL; - - for (RimSummaryCase* rimCase : group->allSummaryCases()) - { - if (!rimCase->caseRealizationParameters().isNull()) - { - double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - if (value != HUGE_VAL) - { - if (value < minValue) minValue = value; - if (value > maxValue) maxValue = value; - } - } - } - - cvf::ScalarMapperContinuousLinear colorMapper; - colorMapper.setRange(minValue, maxValue); - - for (auto& curve : m_curves) - { - RimSummaryCase* rimCase = curve->summaryCaseY(); - double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - curve->setColor(cvf::Color3f(colorMapper.mapToColor(value))); - curve->updateCurveAppearance(); - } - - RimSummaryPlot* plot; - firstAncestorOrThisOfType(plot); - if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); - } + updateCurveColors(); } - else if (changedField == &m_color) - { - for (auto& curve : m_curves) - { - curve->setColor(m_color); - curve->updateCurveAppearance(); - } +} - RimSummaryPlot* plot; - firstAncestorOrThisOfType(plot); - if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::initAfterRead() +{ + m_yValuesSelectedVariableDisplayField = m_yValuesCurveVariable->address(); } //-------------------------------------------------------------------------------------------------- @@ -696,3 +673,56 @@ void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::mapallSummaryCases()) + { + if (!rimCase->caseRealizationParameters().isNull()) + { + double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value != HUGE_VAL) + { + if (value < minValue) minValue = value; + if (value > maxValue) maxValue = value; + } + } + } + + cvf::ScalarMapperContinuousLinear colorMapper; + colorMapper.setRange(minValue, maxValue); + + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + curve->setColor(cvf::Color3f(colorMapper.mapToColor(value))); + curve->updateCurveAppearance(); + } + } + } + else if (m_colorMode == SINGLE_COLOR) + { + for (auto& curve : m_curves) + { + curve->setColor(m_color); + curve->updateCurveAppearance(); + } + } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index a5cebba9a2..d9dab31632 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -56,9 +56,10 @@ class RimEnsambleCurveSet : public caf::PdmObject virtual ~RimEnsambleCurveSet(); bool isCurvesVisible(); + void setColor(cvf::Color3f color); void loadDataAndUpdate(bool updateParentPlot); - void setParentQwtPlotAndReplot(QwtPlot* plot); + void setParentQwtPlotNoReplot(QwtPlot* plot); void detachQwtCurves(); RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; @@ -90,11 +91,14 @@ class RimEnsambleCurveSet : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void initAfterRead() override; static void getOptionsForSummaryAddresses(std::map* options, RimSummaryCase* summaryCase, RimSummaryFilter* summaryFilter); + void updateCurveColors(); + private: caf::PdmField m_showCurves; caf::PdmChildArrayField m_curves; // Convert to PtrField ? diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp index 8576c4346f..d05b104da9 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp @@ -19,6 +19,7 @@ #include "RimEnsambleCurveSetCollection.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RifReaderEclipseSummary.h" @@ -29,6 +30,7 @@ #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotSourceStepping.h" +#include "RimSummaryCurveAppearanceCalculator.h" #include "RiuLineSegmentQwtPlotCurve.h" #include "RiuSummaryQwtPlot.h" @@ -120,6 +122,19 @@ void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) //} } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) +{ + for (RimEnsambleCurveSet* curveSet : m_curveSets) + { + curveSet->setParentQwtPlotNoReplot(plot); + } + + if (plot) plot->replot(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -136,9 +151,15 @@ void RimEnsambleCurveSetCollection::detachQwtCurves() //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSetCollection::addCurveSet(RimEnsambleCurveSet* curveSet) { + static int nextAutoColorIndex = 1; + static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size(); + if (curveSet) { + curveSet->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor(nextAutoColorIndex)); m_curveSets.push_back(curveSet); + + nextAutoColorIndex = (++nextAutoColorIndex) % numberOfColors; } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h index fe35983fc6..6eb4e22955 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h @@ -27,6 +27,7 @@ class RimSummaryCase; class RimEnsambleCurveSet; +class QwtPlot; //================================================================================================== /// @@ -42,7 +43,7 @@ class RimEnsambleCurveSetCollection : public caf::PdmObject bool isCurveSetsVisible(); void loadDataAndUpdate(bool updateParentPlot); - //void setParentQwtPlotAndReplot(QwtPlot* plot); + void setParentQwtPlotAndReplot(QwtPlot* plot); void detachQwtCurves(); //RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 9b8e227e28..812e789d18 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -965,6 +965,8 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve) //{ // if (curveSet && curve) // { +// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensambleCurveSetCollection->curveSets().size())); +// // const_cast(curveSet)->addCurve(curve); // curve->setParentQwtPlotAndReplot(m_qwtPlot); // } @@ -1186,17 +1188,18 @@ void RimSummaryPlot::onLoadDataAndUpdate() for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { - curve->loadDataAndUpdate(true); + curve->loadDataAndUpdate(false); } for (RimAsciiDataCurve* curve : m_asciiDataCurves) { - curve->loadDataAndUpdate(true); + curve->loadDataAndUpdate(false); } if (m_qwtPlot) m_qwtPlot->updateLegend(); this->updateAxes(); updateZoomInQwt(); + if(m_qwtPlot) m_qwtPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -1354,6 +1357,11 @@ QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent) { m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); } + + if (m_ensambleCurveSetCollection) + { + m_ensambleCurveSetCollection->setParentQwtPlotAndReplot(m_qwtPlot); + } } return m_qwtPlot; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 39129e7c45..25790ce491 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -38,6 +38,7 @@ class RimGridTimeHistoryCurve; class RimSummaryCase; class RimSummaryCurve; class RimSummaryCurveCollection; +class RimEnsambleCurveSet; class RimEnsambleCurveSetCollection; class RimSummaryCurveFilter_OBSOLETE; class RimSummaryTimeAxisProperties; From 56dd1b3eb994f9fcd00d06a29569cbf02f5d4a27 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 15:59:50 +0200 Subject: [PATCH 0694/1027] Legends (#2749): Clean up enable/showLegend option * Make public field private ... * Make the option invisible from within the property panel. --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 10 +++++----- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 10 ++++++++-- ApplicationCode/ProjectDataModel/RimLegendConfig.h | 4 ++-- .../ProjectDataModel/RimTernaryLegendConfig.cpp | 10 ++++++++-- .../ProjectDataModel/RimTernaryLegendConfig.h | 4 +++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 9e5ff47280..b1b0e6b6ad 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1055,7 +1055,7 @@ void RimEclipseView::updateLegends() updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); } - if (this->cellEdgeResult()->legendConfig()->enableLegend()) + if (this->cellEdgeResult()->legendConfig()->showLegend()) { if (this->cellEdgeResult()->hasResult()) { @@ -1098,7 +1098,7 @@ void RimEclipseView::updateLegends() } RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); - if (stimPlanLegend && stimPlanLegend->enableLegend()) + if (stimPlanLegend && stimPlanLegend->showLegend()) { fractureColors()->updateLegendData(); @@ -1108,7 +1108,7 @@ void RimEclipseView::updateLegends() } } - if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend()) + if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->showLegend()) { updateVirtualConnectionLegendRanges(); @@ -1126,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, { resultColors->updateLegendData(m_currentTimeStep); - if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend()) + if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); @@ -1135,7 +1135,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->legend()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index bfedd4a30d..771207fdc3 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -378,7 +378,7 @@ void RimGeoMechView::updateLegends() this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); - if (cellResult()->hasResult() && cellResult()->legendConfig()->enableLegend()) + if (cellResult()->hasResult() && cellResult()->legendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } @@ -387,7 +387,7 @@ void RimGeoMechView::updateLegends() if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { - if (tensorResults()->arrowColorLegendConfig()->enableLegend()) + if (tensorResults()->arrowColorLegendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); } diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 3aa7ebf901..d3693906c3 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -123,7 +123,8 @@ RimLegendConfig::RimLegendConfig() m_isAllTimeStepsRangeDisabled(false) { CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&enableLegend, "EnableLegend", true, "Enable Legend", "", "", ""); + CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Show Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); @@ -442,7 +443,7 @@ void RimLegendConfig::initAfterRead() caf::PdmFieldHandle* RimLegendConfig::objectToggleField() { - return &enableLegend; + return &m_showLegend; } //-------------------------------------------------------------------------------------------------- @@ -669,6 +670,11 @@ caf::TitledOverlayFrame* RimLegendConfig::legend() } } +bool RimLegendConfig::showLegend() const +{ + return m_showLegend; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 2b9471e07e..5ae482d36d 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -121,8 +121,7 @@ class RimLegendConfig: public caf::PdmObject cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } caf::TitledOverlayFrame* legend(); - - caf::PdmField enableLegend; + bool showLegend() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -172,6 +171,7 @@ class RimLegendConfig: public caf::PdmObject cvf::Color3ubArray m_categoryColors; // Fields + caf::PdmField m_showLegend; caf::PdmField m_numLevels; caf::PdmField m_precision; caf::PdmField > m_tickNumberFormat; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index b6311b960a..e9f71cdd87 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -57,7 +57,8 @@ namespace caf { RimTernaryLegendConfig::RimTernaryLegendConfig() { CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&enableLegend, "EnableTernaryLegend", true, "Enable Ternary Legend", "", "", ""); + CAF_PDM_InitField(&m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", ""); @@ -340,6 +341,11 @@ RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() return m_legend.p(); } +bool RimTernaryLegendConfig::showLegend() const +{ + return m_showLegend; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -493,5 +499,5 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() { - return &enableLegend; + return &m_showLegend; } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 804c61328e..7993753666 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -74,7 +74,7 @@ class RimTernaryLegendConfig : public caf::PdmObject const RivTernarySaturationOverlayItem* legend() const; RivTernarySaturationOverlayItem* legend(); - caf::PdmField enableLegend; + bool showLegend() const; void setTitle(const QString& title); @@ -107,6 +107,8 @@ class RimTernaryLegendConfig : public caf::PdmObject caf::PdmField applyFullRangeMinMax; caf::PdmField ternaryRangeSummary; + caf::PdmField m_showLegend; + std::vector m_globalAutoMax; std::vector m_globalAutoMin; std::vector m_localAutoMax; From d7204363a0a028e80d0710a634ce20d0a026066b Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 18 Apr 2018 08:38:15 +0200 Subject: [PATCH 0695/1027] 3D Well Log Curves (#2673): Consolidate the draw plane position control. --- .../Riv3dWellLogPlanePartMgr.cpp | 69 ++++++++++++------- .../Riv3dWellLogPlanePartMgr.h | 5 +- .../Rim3dWellLogCurveCollection.cpp | 25 ++++--- .../Completions/Rim3dWellLogCurveCollection.h | 6 +- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 47 ++++++++++--- .../ProjectDataModel/Rim3dWellLogCurve.h | 5 +- .../Rim3dWellLogExtractionCurve.cpp | 5 +- .../Rim3dWellLogFileCurve.cpp | 3 +- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 3 +- 9 files changed, 112 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 25e3640b25..c7ab52fda0 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -87,7 +87,6 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); size_t colorIndex = 0; @@ -105,8 +104,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* wellPathClipBoundingBox, resultValues, resultMds, - planeAngle(rim3dWellLogCurve->drawPlane()), - wellPathCenterToPlotStartOffset(planePosition), + planeAngle(curveCollection, rim3dWellLogCurve), + wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), planeWidth()); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) @@ -129,6 +128,9 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable, cvf::Effect* effect) { cvf::ref part = new cvf::Part; @@ -145,41 +147,57 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane) +double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurveCollection* collection, + const Rim3dWellLogCurve* curve) { - switch (drawPlane) + switch (curve->drawPlane()) { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - return cvf::PI_D / 2.0; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - return -cvf::PI_D / 2.0; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - return 0.0; - case Rim3dWellLogCurve::VERTICAL_BELOW: - return cvf::PI_D; - default: - return 0; + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + return cvf::PI_D / 2.0; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + if (collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ON_WELLPATH) + { + return cvf::PI_D / 2.0; // Always left when on well path + } + return -cvf::PI_D / 2.0; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + return 0.0; + case Rim3dWellLogCurve::VERTICAL_BELOW: + if (collection->planePositionVertical() == Rim3dWellLogCurveCollection::ON_WELLPATH) + { + return 0.0; // Always above when on well path. + } + return cvf::PI_D; + default: + return 0; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const +double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve) const { - if (!m_gridView) return 0; - - double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - - if (planePosition == Rim3dWellLogCurveCollection::ALONG_WELLPATH) + bool centered = false; + if (curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_LEFT || + curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_RIGHT) { - double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth()); - return m_wellPath->wellPathRadius(cellSize) + wellPathOffset; + centered = collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ON_WELLPATH; } else + { + centered = collection->planePositionVertical() == Rim3dWellLogCurveCollection::ON_WELLPATH; + } + if (centered) { return -0.5*planeWidth(); } + else + { + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth()); + return m_wellPath->wellPathRadius(cellSize) + wellPathOffset; + } } //-------------------------------------------------------------------------------------------------- @@ -204,7 +222,6 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* double gridIntervalSize) { const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition(); bool showGrid = curveCollection->isShowingGrid(); bool showBackground = curveCollection->isShowingBackground(); @@ -215,8 +232,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, wellPathClipBoundingBox, - planeAngle(rim3dWellLogCurve->drawPlane()), - wellPathCenterToPlotStartOffset(planePosition), + planeAngle(curveCollection, rim3dWellLogCurve), + wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), planeWidth(), gridIntervalSize); if (!gridCreated) return; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 98833dc860..860ddb9c9e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -69,9 +69,8 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); - static double planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane); - - double wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const; + static double planeAngle(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve); + double wellPathCenterToPlotStartOffset(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve) const; double planeWidth() const; private: diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 89ca5351e9..bbe0e64ba3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -32,8 +32,8 @@ namespace caf template<> void AppEnum< Rim3dWellLogCurveCollection::PlanePosition >::setUp() { - addItem(Rim3dWellLogCurveCollection::ALONG_WELLPATH, "ALONG_WELLPATH", "On One Side of Well Path"); - addItem(Rim3dWellLogCurveCollection::ON_WELLPATH, "ON_WELLPATH", "On Well Path"); + addItem(Rim3dWellLogCurveCollection::ALONG_WELLPATH, "ALONG_WELLPATH", "Beside Well Path"); + addItem(Rim3dWellLogCurveCollection::ON_WELLPATH, "ON_WELLPATH", "Centered On Well Path"); setDefault(Rim3dWellLogCurveCollection::ALONG_WELLPATH); } } @@ -48,8 +48,9 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() CAF_PDM_InitField(&m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); m_showPlot.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_planePosition, "PlanePosition", "Plane Position", "", "", ""); - CAF_PDM_InitField(&m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Plane Width Scaling Factor", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_planePositionVertical, "PlanePositionVertical", "Vertical Position", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_planePositionHorizontal, "PlanePositionHorizontal", "Horizontal Position", "", "", ""); + CAF_PDM_InitField(&m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Width Scaling", "", "", ""); m_planeWidthScaling.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); CAF_PDM_InitField(&m_showBackground, "Show3dWellLogBackground", false, "Show Background", "", "", ""); @@ -118,13 +119,20 @@ bool Rim3dWellLogCurveCollection::isShowingBackground() const return m_showBackground; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePositionVertical() const +{ + return m_planePositionVertical(); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePosition() const +Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePositionHorizontal() const { - return m_planePosition(); + return m_planePositionHorizontal(); } //-------------------------------------------------------------------------------------------------- @@ -191,8 +199,9 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Settings"); - settingsGroup->add(&m_planePosition); + caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Configuration"); + settingsGroup->add(&m_planePositionVertical); + settingsGroup->add(&m_planePositionHorizontal); settingsGroup->add(&m_planeWidthScaling); caf::PdmUiGroup* appearanceSettingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index da3f2cfedf..1a633d0478 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -52,7 +52,8 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool isShowingGrid() const; bool isShowingBackground() const; - PlanePosition planePosition() const; + PlanePosition planePositionVertical() const; + PlanePosition planePositionHorizontal() const; float planeWidthScaling() const; std::vector vectorOf3dWellLogCurves() const; @@ -65,7 +66,8 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); private: caf::PdmField m_showPlot; - caf::PdmField> m_planePosition; + caf::PdmField> m_planePositionVertical; + caf::PdmField> m_planePositionHorizontal; caf::PdmField m_planeWidthScaling; caf::PdmField m_showGrid; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 79c5767f10..eb0bac7a33 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,6 +18,7 @@ #include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimProject.h" //================================================================================================== @@ -32,10 +33,10 @@ namespace caf template<> void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() { - addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Vertical - Above"); - addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Vertical - Below"); - addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Horizontal - Left"); - addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Horizontal - Right"); + addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Beside Well Path - Above"); + addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Beside Well Path - Below"); + addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Beside Well Path - Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Beside Well Path - Right"); setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); } } @@ -50,7 +51,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_drawPlane, "DrawPlane", "Draw Plane", "", "", ""); + CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); m_name.uiCapability()->setUiHidden(true); @@ -141,10 +142,38 @@ caf::PdmFieldHandle* Rim3dWellLogCurve::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering) +void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* curveAppearanceGroup = uiOrdering.addNewGroup("Curve Appearance"); - curveAppearanceGroup->add(&m_drawPlane); - curveAppearanceGroup->add(&m_color); + caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Configuration"); + configurationGroup->add(&m_drawPlane); + configurationGroup->add(&m_color); } +QList Rim3dWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + if (fieldNeedingOptions == &m_drawPlane) + { + Rim3dWellLogCurveCollection* collection; + this->firstAncestorOrThisOfTypeAsserted(collection); + if (collection->planePositionVertical() == Rim3dWellLogCurveCollection::ALONG_WELLPATH) + { + options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::VERTICAL_ABOVE), Rim3dWellLogCurve::VERTICAL_ABOVE)); + options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::VERTICAL_BELOW), Rim3dWellLogCurve::VERTICAL_BELOW)); + } + else + { + options.push_back(caf::PdmOptionItemInfo(QString("Vertical - Centered"), Rim3dWellLogCurve::VERTICAL_ABOVE)); + } + if (collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ALONG_WELLPATH) + { + options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::HORIZONTAL_LEFT), Rim3dWellLogCurve::HORIZONTAL_LEFT)); + options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::HORIZONTAL_RIGHT), Rim3dWellLogCurve::HORIZONTAL_RIGHT)); + } + else + { + options.push_back(caf::PdmOptionItemInfo(QString("Horizontal - Centered"), Rim3dWellLogCurve::HORIZONTAL_LEFT)); + } + } + return options; +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 0d34c289a7..e12ebe3e2c 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -40,7 +40,7 @@ class Rim3dWellLogCurve : public caf::PdmObject HORIZONTAL_LEFT, HORIZONTAL_RIGHT }; - + typedef caf::AppEnum DrawPlaneEnum; public: Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); @@ -58,7 +58,8 @@ class Rim3dWellLogCurve : public caf::PdmObject virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* userDescriptionField() override; - void appearanceUiOrdering(caf::PdmUiOrdering& uiOrdering); + void configurationUiOrdering(caf::PdmUiOrdering& uiOrdering); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; protected: caf::PdmField m_name; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index a5d642d92f..9470119b7e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -174,6 +174,8 @@ QList Rim3dWellLogExtractionCurve::calculateValueOptions { QList options; + options = Rim3dWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + if (fieldNeedingOptions == &m_case) { RimTools::caseOptionItems(&options); @@ -225,8 +227,7 @@ void Rim3dWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::Pd curveDataGroup->add(&m_timeStep); } - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); - Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index fe4f41be08..7458ca7872 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -154,8 +154,7 @@ void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd curveDataGroup->add(&m_wellLogFile); curveDataGroup->add(&m_wellLogChannnelName); - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); - Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index 65a6bf71e6..33c50ce9a3 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -138,8 +138,7 @@ void Rim3dWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrde curveDataGroup->add(&m_wellLogChannelName); curveDataGroup->add(&m_timeStep); - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance"); - Rim3dWellLogCurve::appearanceUiOrdering(*appearanceGroup); + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); uiOrdering.skipRemainingFields(true); } From f85c1de33086bd9397e995d42a790e3557351f4a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Apr 2018 09:21:15 +0200 Subject: [PATCH 0696/1027] Doc : Updated view classes --- doc/view_classes.plantuml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/view_classes.plantuml b/doc/view_classes.plantuml index 7494fc2ac9..f553c317b9 100644 --- a/doc/view_classes.plantuml +++ b/doc/view_classes.plantuml @@ -4,12 +4,12 @@ class RimViewWindow { RimMdiWindowController mdiWindowGeometry() } -note top of RimViewWindow : Updated 2017-02-24 +note top of RimViewWindow : Updated 2018-04-18 (NOTE : sub classes of RimViewWindow is not complete, consider Doxygen for this info class RimView { } -RimViewWindow <|-- RimView +RimViewWindow <|-- Rim3dView package plots { RimViewWindow <|-- RimSummaryPlot @@ -20,8 +20,12 @@ RimViewWindow <|-- RimWellLogPlot RimViewWindow *-- RimMdiWindowController -RimView <|-- RimEclipseView -RimView <|-- RimGeoMechView +Rim3dView <|-- Rim2dIntersectionView + +Rim3dView <|-- RimGridView + +RimGridView <|-- RimEclipseView +RimGridView <|-- RimGeoMechView From 3bc85ce794b9db884a5d67431e3b98eae19b1344 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Apr 2018 10:10:39 +0200 Subject: [PATCH 0697/1027] #2727 Legends : Rename to RimRegularLegendConfig --- .../RivFemPartPartMgr.cpp | 2 +- .../RivIntersectionBoxPartMgr.cpp | 2 +- .../Intersections/RivIntersectionPartMgr.cpp | 2 +- .../RivCellEdgeGeometryUtils.cpp | 2 +- .../ModelVisualization/RivFaultPartMgr.cpp | 2 +- .../ModelVisualization/RivGridPartMgr.cpp | 2 +- .../RivScalarMapperUtils.cpp | 2 +- .../RivSimWellPipesPartMgr.cpp | 2 +- .../RivTensorResultPartMgr.cpp | 2 +- .../RivTextureCoordsCreator.cpp | 2 +- .../RivWellConnectionFactorPartMgr.cpp | 2 +- .../RivWellFracturePartMgr.cpp | 8 +- .../ProjectDataModel/CMakeLists_files.cmake | 4 +- .../Rim2dIntersectionView.cpp | 4 +- .../ProjectDataModel/Rim2dIntersectionView.h | 4 +- .../ProjectDataModel/RimCellEdgeColors.cpp | 6 +- .../ProjectDataModel/RimCellEdgeColors.h | 6 +- .../ProjectDataModel/RimEclipseCase.cpp | 2 +- .../ProjectDataModel/RimEclipseCellColors.cpp | 22 +-- .../ProjectDataModel/RimEclipseCellColors.h | 12 +- .../RimEclipseFaultColors.cpp | 2 +- .../ProjectDataModel/RimEclipseView.cpp | 12 +- .../ProjectDataModel/RimGeoMechCellColors.cpp | 16 +- .../ProjectDataModel/RimGeoMechCellColors.h | 4 +- .../ProjectDataModel/RimGeoMechView.cpp | 6 +- .../ProjectDataModel/RimGeoMechView.h | 6 +- ...dConfig.cpp => RimRegularLegendConfig.cpp} | 144 +++++++++--------- ...egendConfig.h => RimRegularLegendConfig.h} | 8 +- .../ProjectDataModel/RimStimPlanColors.cpp | 20 +-- .../ProjectDataModel/RimStimPlanColors.h | 6 +- .../RimStimPlanLegendConfig.cpp | 4 +- .../RimStimPlanLegendConfig.h | 4 +- .../ProjectDataModel/RimTensorResults.cpp | 16 +- .../ProjectDataModel/RimTensorResults.h | 8 +- .../ProjectDataModel/RimViewLinker.cpp | 2 +- .../RimVirtualPerforationResults.cpp | 6 +- .../RimVirtualPerforationResults.h | 6 +- .../Summary/RimEnsambleCurveSet.cpp | 2 +- .../Summary/RimEnsambleCurveSet.h | 4 +- .../UserInterface/RiuResultTextBuilder.cpp | 4 +- .../UserInterface/RiuViewerCommands.cpp | 2 +- 41 files changed, 186 insertions(+), 186 deletions(-) rename ApplicationCode/ProjectDataModel/{RimLegendConfig.cpp => RimRegularLegendConfig.cpp} (82%) rename ApplicationCode/ProjectDataModel/{RimLegendConfig.h => RimRegularLegendConfig.h} (98%) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index b87d7d9c9e..2db16ba7a8 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -33,7 +33,7 @@ #include "RimEclipseView.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RivFemPickSourceInfo.h" #include "RivPartPriority.h" diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index 2a9d25cc2d..7506558e71 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -32,7 +32,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimIntersectionBox.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivIntersectionBoxSourceInfo.h" diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 40fc47bd23..4464ec8e0d 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -34,7 +34,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTernaryLegendConfig.h" diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index f881280dc7..0b6cf69ba0 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -32,7 +32,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivTernaryTextureCoordsCreator.h" diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index a440b24930..f2a06238fa 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -31,7 +31,7 @@ #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivFaultGeometryGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 4c3249611d..b4a178c60c 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -32,7 +32,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RimTernaryLegendConfig.h" diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index fdbf6a1f4b..36f83ac76e 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -24,7 +24,7 @@ #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivCellEdgeEffectGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index fa6d0e464e..0d9ab92959 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -29,7 +29,7 @@ #include "Rim3dView.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimVirtualPerforationResults.h" diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 53647c90ec..18a4ced74e 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -22,7 +22,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTensorResults.h" #include "RigFemPartCollection.h" diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp index 1db9149f92..185f9b7bc3 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp @@ -27,7 +27,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RivResultToTextureMapper.h" diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index b481d12924..5e200e2f86 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -29,7 +29,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RimVirtualPerforationResults.h" #include "RimWellPath.h" diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 68c134bde8..187306ff3e 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -33,7 +33,7 @@ #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" @@ -360,7 +360,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc cvf::Color4f fractureColor = cvf::Color4f(activeView.fractureColors()->defaultColor()); - RimLegendConfig* legendConfig = nullptr; + RimRegularLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { legendConfig = activeView.fractureColors()->activeLegend(); @@ -421,7 +421,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); - RimLegendConfig* legendConfig = nullptr; + RimRegularLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { legendConfig = activeView.fractureColors()->activeLegend(); @@ -545,7 +545,7 @@ cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePar { std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); - RimLegendConfig* legendConfig = nullptr; + RimRegularLegendConfig* legendConfig = nullptr; if (activeView.fractureColors() && activeView.fractureColors()->isChecked() && activeView.fractureColors()->activeLegend()) diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 49c2a46248..64f7f7d33d 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -8,7 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.h ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.h -${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimRegularLegendConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimOilField.h ${CMAKE_CURRENT_LIST_DIR}/RimProject.h ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.h @@ -115,7 +115,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.cpp -${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRegularLegendConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimOilField.cpp ${CMAKE_CURRENT_LIST_DIR}/RimProject.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.cpp diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 37ba2a54c9..834f8d518e 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -25,7 +25,7 @@ #include "RimEclipseCellColors.h" #include "RimGeoMechView.h" #include "RimGeoMechCellColors.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RimSimWellInView.h" #include "RimWellPath.h" @@ -68,7 +68,7 @@ Rim2dIntersectionView::Rim2dIntersectionView(void) m_legendConfig.uiCapability()->setUiHidden(true); m_legendConfig.uiCapability()->setUiTreeChildrenHidden(true); m_legendConfig.xmlCapability()->disableIO(); - m_legendConfig = new RimLegendConfig(); + m_legendConfig = new RimRegularLegendConfig(); CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", ""); m_ternaryLegendConfig.uiCapability()->setUiTreeHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 7828702e36..85c5b2177c 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -22,7 +22,7 @@ #include "cafPdmPtrField.h" class RimIntersection; -class RimLegendConfig; +class RimRegularLegendConfig; class RimTernaryLegendConfig; class RivSimWellPipesPartMgr; class RivWellHeadPartMgr; @@ -93,7 +93,7 @@ class Rim2dIntersectionView : public Rim3dView int timeStepCount(); - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; caf::PdmChildField m_ternaryLegendConfig; caf::PdmPtrField m_intersection; diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp index b42817b761..6f3e73f500 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -25,7 +25,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "cafPdmUiListEditor.h" @@ -70,7 +70,7 @@ RimCellEdgeColors::RimCellEdgeColors() m_resultVariable.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); - m_legendConfig = new RimLegendConfig(); + m_legendConfig = new RimRegularLegendConfig(); m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE; resetResultIndices(); @@ -593,7 +593,7 @@ RimEclipseCellColors* RimCellEdgeColors::singleVarEdgeResultColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimCellEdgeColors::legendConfig() +RimRegularLegendConfig* RimCellEdgeColors::legendConfig() { if (isUsingSingleVariable()) { diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h index b427a94ea7..c5e99c7608 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h @@ -30,7 +30,7 @@ class RigCaseCellResultsData; class RimEclipseCase; class RimEclipseCellColors; class RimEclipseView; -class RimLegendConfig; +class RimRegularLegendConfig; class RimCellEdgeMetaData { @@ -86,7 +86,7 @@ class RimCellEdgeColors : public caf::PdmObject bool isUsingSingleVariable() const; RimEclipseCellColors* singleVarEdgeResultColors(); - RimLegendConfig* legendConfig(); + RimRegularLegendConfig* legendConfig(); PropertyType propertyType() const; void minMaxCellEdgeValues(double& min, double& max); @@ -123,7 +123,7 @@ class RimCellEdgeColors : public caf::PdmObject caf::PdmField > m_propertyType; - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; caf::PdmChildField m_singleVarEdgeResultColors; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index d5899d5dc9..3109a37139 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -47,7 +47,7 @@ #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" #include "RimIntersectionCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimPerforationCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 8498d7a6c5..7c15f9065c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -29,7 +29,7 @@ #include "RimEclipseCase.h" #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTernaryLegendConfig.h" @@ -143,7 +143,7 @@ void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend) // Not found ? if (!found) { - RimLegendConfig* newLegend = new RimLegendConfig; + RimRegularLegendConfig* newLegend = new RimRegularLegendConfig; newLegend->resultVariableName = resultVarNameOfNewLegend; m_legendConfigData.push_back(newLegend); @@ -168,7 +168,7 @@ void RimEclipseCellColors::initAfterRead() if (obsoleteField_legendConfig) { // The current legend config is NOT stored in in ResInsight up to v 1.3.7-dev - RimLegendConfig* obsoleteLegend = obsoleteField_legendConfig(); + RimRegularLegendConfig* obsoleteLegend = obsoleteField_legendConfig(); // set to NULL before pushing into container obsoleteField_legendConfig = nullptr; @@ -208,19 +208,19 @@ void RimEclipseCellColors::updateLegendCategorySettings() if (this->hasCategoryResult()) { - legendConfig()->setMappingMode(RimLegendConfig::CATEGORY_INTEGER); - legendConfig()->setColorRangeMode(RimLegendConfig::CATEGORY); + legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); + legendConfig()->setColorRangeMode(RimRegularLegendConfig::CATEGORY); } else { - if (legendConfig()->mappingMode() == RimLegendConfig::CATEGORY_INTEGER) + if (legendConfig()->mappingMode() == RimRegularLegendConfig::CATEGORY_INTEGER) { - legendConfig()->setMappingMode(RimLegendConfig::LINEAR_CONTINUOUS); + legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if (legendConfig()->colorRangeMode() == RimLegendConfig::CATEGORY) + if (legendConfig()->colorRangeMode() == RimRegularLegendConfig::CATEGORY) { - legendConfig()->setColorRangeMode(RimLegendConfig::NORMAL); + legendConfig()->setColorRangeMode(RimRegularLegendConfig::NORMAL); } } } @@ -274,7 +274,7 @@ public : /// //-------------------------------------------------------------------------------------------------- void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, - RimLegendConfig* legendConfig, + RimRegularLegendConfig* legendConfig, RimTernaryLegendConfig* ternaryLegendConfig) { if (!legendConfig) legendConfig = this->legendConfig(); @@ -514,7 +514,7 @@ void RimEclipseCellColors::setResultVariable(const QString& val) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimEclipseCellColors::legendConfig() +RimRegularLegendConfig* RimEclipseCellColors::legendConfig() { return m_legendConfigPtrField; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 9812e8cbdb..3962a7ecaa 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -27,7 +27,7 @@ #include "cafPdmPtrField.h" class RimTernaryLegendConfig; -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -44,9 +44,9 @@ class RimEclipseCellColors : public RimEclipseResultDefinition RimEclipseView* reservoirView(); void updateLegendData(size_t timestep, - RimLegendConfig* legendConfig = nullptr, + RimRegularLegendConfig* legendConfig = nullptr, RimTernaryLegendConfig* ternaryLegendConfig = nullptr); - RimLegendConfig* legendConfig(); + RimRegularLegendConfig* legendConfig(); caf::PdmChildField ternaryLegendConfig; virtual void setResultVariable(const QString& resultName); @@ -67,12 +67,12 @@ class RimEclipseCellColors : public RimEclipseResultDefinition private: void changeLegendConfig(QString resultVarNameOfNewLegend); - caf::PdmChildArrayField m_legendConfigData; - caf::PdmPtrField m_legendConfigPtrField; + caf::PdmChildArrayField m_legendConfigData; + caf::PdmPtrField m_legendConfigPtrField; caf::PdmPointer m_reservoirView; // Obsolete - caf::PdmChildField obsoleteField_legendConfig; + caf::PdmChildField obsoleteField_legendConfig; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index 0148e97968..52afeb264e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -22,7 +22,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index b1b0e6b6ad..7d9338719e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -50,7 +50,7 @@ #include "RimGridCollection.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimOilField.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" @@ -151,7 +151,7 @@ RimEclipseView::RimEclipseView() this->cellResult()->setReservoirView(this); this->cellEdgeResult()->setReservoirView(this); - this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimLegendConfig::PINK_WHITE); + this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimRegularLegendConfig::PINK_WHITE); this->faultResultSettings()->setReservoirView(this); @@ -1097,7 +1097,7 @@ void RimEclipseView::updateLegends() } } - RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); + RimRegularLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); if (stimPlanLegend && stimPlanLegend->showLegend()) { fractureColors()->updateLegendData(); @@ -1112,7 +1112,7 @@ void RimEclipseView::updateLegends() { updateVirtualConnectionLegendRanges(); - RimLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); + RimRegularLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); } } @@ -1588,7 +1588,7 @@ RimEclipseCellColors* RimEclipseView::currentFaultResultColors() //-------------------------------------------------------------------------------------------------- void RimEclipseView::resetLegendsInViewer() { - RimLegendConfig* cellResultNormalLegendConfig = this->cellResult()->legendConfig(); + RimRegularLegendConfig* cellResultNormalLegendConfig = this->cellResult()->legendConfig(); if (cellResultNormalLegendConfig) cellResultNormalLegendConfig->recreateLegend(); this->cellResult()->ternaryLegendConfig->recreateLegend(); @@ -1623,7 +1623,7 @@ void RimEclipseView::updateVirtualConnectionLegendRanges() if (minValue != HUGE_VAL) { - RimLegendConfig* legendConfig = virtualPerforationResult()->legendConfig(); + RimRegularLegendConfig* legendConfig = virtualPerforationResult()->legendConfig(); legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index b855c7283d..835d1fbdb4 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -19,7 +19,7 @@ #include "RimGeoMechCellColors.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT(RimGeoMechCellColors, "GeoMechResultSlot"); RimGeoMechCellColors::RimGeoMechCellColors(void) { CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); - this->legendConfig = new RimLegendConfig(); + this->legendConfig = new RimRegularLegendConfig(); legendConfig.uiCapability()->setUiHidden(true); } @@ -87,19 +87,19 @@ void RimGeoMechCellColors::updateLegendCategorySettings() { if(this->hasCategoryResult()) { - legendConfig->setMappingMode(RimLegendConfig::CATEGORY_INTEGER); - legendConfig->setColorRangeMode(RimLegendConfig::CATEGORY); + legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); + legendConfig->setColorRangeMode(RimRegularLegendConfig::CATEGORY); } else { - if(legendConfig->mappingMode() == RimLegendConfig::CATEGORY_INTEGER) + if(legendConfig->mappingMode() == RimRegularLegendConfig::CATEGORY_INTEGER) { - legendConfig->setMappingMode(RimLegendConfig::LINEAR_CONTINUOUS); + legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if(legendConfig->colorRangeMode() == RimLegendConfig::CATEGORY) + if(legendConfig->colorRangeMode() == RimRegularLegendConfig::CATEGORY) { - legendConfig->setColorRangeMode(RimLegendConfig::NORMAL); + legendConfig->setColorRangeMode(RimRegularLegendConfig::NORMAL); } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h index c3da0cb14c..0e14fdd270 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h @@ -24,7 +24,7 @@ #include "cafPdmChildField.h" #include "cafPdmField.h" -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== @@ -39,7 +39,7 @@ class RimGeoMechCellColors : public RimGeoMechResultDefinition RimGeoMechCellColors(void); virtual ~RimGeoMechCellColors(void); - caf::PdmChildField legendConfig; + caf::PdmChildField legendConfig; void updateIconState(); virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 771207fdc3..358791ded3 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -36,7 +36,7 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" #include "RimIntersectionCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTensorResults.h" #include "RimViewLinker.h" @@ -398,7 +398,7 @@ void RimGeoMechView::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex) +void RimGeoMechView::updateTensorLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex) { if (!m_geomechCase || !m_geomechCase->geoMechData()) return; @@ -432,7 +432,7 @@ void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex) +void RimGeoMechView::updateLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex) { if (!m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index cfcc3bae4a..28efa2ff6f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -42,7 +42,7 @@ class RimTensorResults; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; -class RimLegendConfig; +class RimRegularLegendConfig; class RivTensorResultPartMgr; namespace cvf { @@ -87,7 +87,7 @@ class RimGeoMechView : public RimGridView virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; - void updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + void updateLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex); const cvf::ref vizLogic() const; const RimTensorResults* tensorResults() const; @@ -112,7 +112,7 @@ class RimGeoMechView : public RimGridView void updateLegends() override; - void updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex); + void updateTensorLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp similarity index 82% rename from ApplicationCode/ProjectDataModel/RimLegendConfig.cpp rename to ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index d3693906c3..c70263f3c9 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RiaApplication.h" #include "RiaColorTables.h" @@ -52,66 +52,66 @@ #include -CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); +CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend"); namespace caf { template<> - void AppEnum::setUp() + void AppEnum::setUp() { - addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); - addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); - addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); - setDefault(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS); + addItem(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); + addItem(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); + addItem(RimRegularLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); + setDefault(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS); } } namespace caf { template<> - void RimLegendConfig::ColorRangeEnum::setUp() + void RimRegularLegendConfig::ColorRangeEnum::setUp() { - addItem(RimLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); - addItem(RimLegendConfig::OPPOSITE_NORMAL,"OPPOSITE_NORMAL", "Full color, Blue on top"); - addItem(RimLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); - addItem(RimLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); - addItem(RimLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); - addItem(RimLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); - addItem(RimLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); - addItem(RimLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); - addItem(RimLegendConfig::CATEGORY, "CATEGORY", "Category colors"); - addItem(RimLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); - addItem(RimLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); - setDefault(RimLegendConfig::NORMAL); + addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); + addItem(RimRegularLegendConfig::OPPOSITE_NORMAL,"OPPOSITE_NORMAL", "Full color, Blue on top"); + addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); + addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); + addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); + addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); + addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); + addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); + addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors"); + addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); + addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); + setDefault(RimRegularLegendConfig::NORMAL); } } namespace caf { template<> - void RimLegendConfig::MappingEnum::setUp() + void RimRegularLegendConfig::MappingEnum::setUp() { - addItem(RimLegendConfig::LINEAR_DISCRETE, "LinearDiscrete", "Discrete Linear"); - addItem(RimLegendConfig::LINEAR_CONTINUOUS, "LinearContinuous", "Continuous Linear"); - addItem(RimLegendConfig::LOG10_CONTINUOUS, "Log10Continuous", "Continuous Logarithmic"); - addItem(RimLegendConfig::LOG10_DISCRETE, "Log10Discrete", "Discrete Logarithmic"); - addItem(RimLegendConfig::CATEGORY_INTEGER, "Category", "Category"); - setDefault(RimLegendConfig::LINEAR_CONTINUOUS); + addItem(RimRegularLegendConfig::LINEAR_DISCRETE, "LinearDiscrete", "Discrete Linear"); + addItem(RimRegularLegendConfig::LINEAR_CONTINUOUS, "LinearContinuous", "Continuous Linear"); + addItem(RimRegularLegendConfig::LOG10_CONTINUOUS, "Log10Continuous", "Continuous Logarithmic"); + addItem(RimRegularLegendConfig::LOG10_DISCRETE, "Log10Discrete", "Discrete Logarithmic"); + addItem(RimRegularLegendConfig::CATEGORY_INTEGER, "Category", "Category"); + setDefault(RimRegularLegendConfig::LINEAR_CONTINUOUS); } } namespace caf { template<> - void AppEnum::setUp() + void AppEnum::setUp() { - addItem( RimLegendConfig::AUTO, "AUTO", "Automatic"); - addItem( RimLegendConfig::FIXED, "FIXED", "Fixed, decimal"); - addItem( RimLegendConfig::SCIENTIFIC, "SCIENTIFIC", "Scientific notation"); - setDefault(RimLegendConfig::FIXED); + addItem( RimRegularLegendConfig::AUTO, "AUTO", "Automatic"); + addItem( RimRegularLegendConfig::FIXED, "FIXED", "Fixed, decimal"); + addItem( RimRegularLegendConfig::SCIENTIFIC, "SCIENTIFIC", "Scientific notation"); + setDefault(RimRegularLegendConfig::FIXED); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig::RimLegendConfig() +RimRegularLegendConfig::RimRegularLegendConfig() : m_globalAutoMax(cvf::UNDEFINED_DOUBLE), m_globalAutoMin(cvf::UNDEFINED_DOUBLE), m_localAutoMax(cvf::UNDEFINED_DOUBLE), @@ -127,7 +127,7 @@ RimLegendConfig::RimLegendConfig() m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); - CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); + CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", ""); CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", ""); @@ -157,7 +157,7 @@ RimLegendConfig::RimLegendConfig() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig::~RimLegendConfig() +RimRegularLegendConfig::~RimRegularLegendConfig() { } @@ -165,7 +165,7 @@ RimLegendConfig::~RimLegendConfig() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimRegularLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &m_numLevels) { @@ -220,7 +220,7 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::updateLegend() +void RimRegularLegendConfig::updateLegend() { double adjustedMin = cvf::UNDEFINED_DOUBLE; double adjustedMax = cvf::UNDEFINED_DOUBLE; @@ -402,7 +402,7 @@ void RimLegendConfig::updateLegend() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::disableAllTimeStepsRange(bool doDisable) +void RimRegularLegendConfig::disableAllTimeStepsRange(bool doDisable) { // If we enable AllTimesteps, and we have used current timestep, then "restore" the default if (m_isAllTimeStepsRangeDisabled && !doDisable && m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) m_rangeMode = AUTOMATIC_ALLTIMESTEPS; @@ -416,7 +416,7 @@ void RimLegendConfig::disableAllTimeStepsRange(bool doDisable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax) +void RimRegularLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax) { double candidateGlobalAutoMin = roundToNumSignificantDigits(globalMin, m_precision); double candidateGlobalAutoMax = roundToNumSignificantDigits(globalMax, m_precision); @@ -436,12 +436,12 @@ void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, dou //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::initAfterRead() +void RimRegularLegendConfig::initAfterRead() { updateFieldVisibility(); } -caf::PdmFieldHandle* RimLegendConfig::objectToggleField() +caf::PdmFieldHandle* RimRegularLegendConfig::objectToggleField() { return &m_showLegend; } @@ -449,7 +449,7 @@ caf::PdmFieldHandle* RimLegendConfig::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::updateFieldVisibility() +void RimRegularLegendConfig::updateFieldVisibility() { bool showRangeItems = m_mappingMode == CATEGORY_INTEGER ? false : true; @@ -473,7 +473,7 @@ void RimLegendConfig::updateFieldVisibility() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode) +void RimRegularLegendConfig::setColorRangeMode(ColorRangesType colorMode) { m_colorRangeMode = colorMode; updateLegend(); @@ -482,7 +482,7 @@ void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setMappingMode(MappingType mappingType) +void RimRegularLegendConfig::setMappingMode(MappingType mappingType) { m_mappingMode = mappingType; updateLegend(); @@ -491,7 +491,7 @@ void RimLegendConfig::setMappingMode(MappingType mappingType) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::recreateLegend() +void RimRegularLegendConfig::recreateLegend() { // Due to possible visualization bug, we need to recreate the legend if the last viewer // has been removed, (and thus the opengl resources has been deleted) The text in @@ -507,7 +507,7 @@ void RimLegendConfig::recreateLegend() //-------------------------------------------------------------------------------------------------- /// Rounding the double value to given number of significant digits //-------------------------------------------------------------------------------------------------- -double RimLegendConfig::roundToNumSignificantDigits(double domainValue, double numSignificantDigits) +double RimRegularLegendConfig::roundToNumSignificantDigits(double domainValue, double numSignificantDigits) { double absDomainValue = cvf::Math::abs(domainValue); if (absDomainValue == 0.0) @@ -534,7 +534,7 @@ double RimLegendConfig::roundToNumSignificantDigits(double domainValue, double n //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero) +void RimRegularLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero) { bool needsUpdate = false; const double epsilon = std::numeric_limits::epsilon(); @@ -575,7 +575,7 @@ void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, doub //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setIntegerCategories(const std::vector& categories) +void RimRegularLegendConfig::setIntegerCategories(const std::vector& categories) { m_categories = categories; m_categoryNames.clear(); @@ -587,7 +587,7 @@ void RimLegendConfig::setIntegerCategories(const std::vector& categories) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) +void RimRegularLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) { std::vector nameIndices; std::vector names; @@ -607,7 +607,7 @@ void RimLegendConfig::setNamedCategoriesInverse(const std::vector& cate //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setCategoryItems(const std::vector< std::tuple >& categories) +void RimRegularLegendConfig::setCategoryItems(const std::vector< std::tuple >& categories) { m_categories.clear(); m_categoryNames.clear(); @@ -627,7 +627,7 @@ void RimLegendConfig::setCategoryItems(const std::vector< std::tuplesetTitle(cvfTitle); @@ -658,7 +658,7 @@ void RimLegendConfig::setTitle(const QString& title) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::TitledOverlayFrame* RimLegendConfig::legend() +caf::TitledOverlayFrame* RimRegularLegendConfig::legend() { if (m_currentScalarMapper == m_categoryMapper) { @@ -670,7 +670,7 @@ caf::TitledOverlayFrame* RimLegendConfig::legend() } } -bool RimLegendConfig::showLegend() const +bool RimRegularLegendConfig::showLegend() const { return m_showLegend; } @@ -678,7 +678,7 @@ bool RimLegendConfig::showLegend() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig) +void RimRegularLegendConfig::setUiValuesFromLegendConfig(const RimRegularLegendConfig* otherLegendConfig) { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); @@ -688,41 +688,41 @@ void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Color3ubArray RimLegendConfig::colorArrayFromColorType(ColorRangesType colorType) +cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesType colorType) { switch (colorType) { - case RimLegendConfig::NORMAL: + case RimRegularLegendConfig::NORMAL: return RiaColorTables::normalPaletteColors().color3ubArray(); break; - case RimLegendConfig::OPPOSITE_NORMAL: + case RimRegularLegendConfig::OPPOSITE_NORMAL: return RiaColorTables::normalPaletteOppositeOrderingColors().color3ubArray(); break; - case RimLegendConfig::WHITE_PINK: + case RimRegularLegendConfig::WHITE_PINK: return RiaColorTables::whitePinkPaletteColors().color3ubArray(); break; - case RimLegendConfig::PINK_WHITE: + case RimRegularLegendConfig::PINK_WHITE: return RiaColorTables::pinkWhitePaletteColors().color3ubArray(); break; - case RimLegendConfig::WHITE_BLACK: + case RimRegularLegendConfig::WHITE_BLACK: return RiaColorTables::whiteBlackPaletteColors().color3ubArray(); break; - case RimLegendConfig::BLACK_WHITE: + case RimRegularLegendConfig::BLACK_WHITE: return RiaColorTables::blackWhitePaletteColors().color3ubArray(); break; - case RimLegendConfig::BLUE_WHITE_RED: + case RimRegularLegendConfig::BLUE_WHITE_RED: return RiaColorTables::blueWhiteRedPaletteColors().color3ubArray(); break; - case RimLegendConfig::RED_WHITE_BLUE: + case RimRegularLegendConfig::RED_WHITE_BLUE: return RiaColorTables::redWhiteBluePaletteColors().color3ubArray(); break; - case RimLegendConfig::CATEGORY: + case RimRegularLegendConfig::CATEGORY: return RiaColorTables::categoryPaletteColors().color3ubArray(); break; - case RimLegendConfig::ANGULAR: + case RimRegularLegendConfig::ANGULAR: return RiaColorTables::angularPaletteColors().color3ubArray(); break; - case RimLegendConfig::STIMPLAN: + case RimRegularLegendConfig::STIMPLAN: return RiaColorTables::stimPlanPaletteColors().color3ubArray(); break; default: @@ -735,7 +735,7 @@ cvf::Color3ubArray RimLegendConfig::colorArrayFromColorType(ColorRangesType colo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimRegularLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { { caf::PdmUiOrdering * formatGr = uiOrdering.addNewGroup("Format"); @@ -757,7 +757,7 @@ void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimLegendConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RimRegularLegendConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { bool hasStimPlanParent = false; @@ -832,13 +832,13 @@ QList RimLegendConfig::calculateValueOptions(const caf:: { if (!m_isAllTimeStepsRangeDisabled) { - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), RimLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); } if (!hasStimPlanParent) { - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); } - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::USER_DEFINED), RimLegendConfig::USER_DEFINED)); + options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::USER_DEFINED), RimRegularLegendConfig::USER_DEFINED)); } return options; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h similarity index 98% rename from ApplicationCode/ProjectDataModel/RimLegendConfig.h rename to ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 5ae482d36d..107fe8381a 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -53,12 +53,12 @@ class Rim3dView; /// /// //================================================================================================== -class RimLegendConfig: public caf::PdmObject +class RimRegularLegendConfig: public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimLegendConfig(); - virtual ~RimLegendConfig(); + RimRegularLegendConfig(); + virtual ~RimRegularLegendConfig(); caf::PdmField resultVariableName; // Used internally to describe the variable this legend setup is used for @@ -117,7 +117,7 @@ class RimLegendConfig: public caf::PdmObject void setTitle(const QString& title); - void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); + void setUiValuesFromLegendConfig(const RimRegularLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } caf::TitledOverlayFrame* legend(); diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 5d713b2b99..2b7afe1325 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -23,7 +23,7 @@ #include "RimEclipseView.h" #include "RimFractureTemplateCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimOilField.h" #include "RimProject.h" #include "RimStimPlanFractureTemplate.h" @@ -105,8 +105,8 @@ void RimStimPlanColors::loadDataAndUpdate() // Delete legends referencing results not present on file { - std::vector toBeDeleted; - for (RimLegendConfig* legend : m_legendConfigurations) + std::vector toBeDeleted; + for (RimRegularLegendConfig* legend : m_legendConfigurations) { QString legendVariableName = legend->resultVariableName(); @@ -139,7 +139,7 @@ void RimStimPlanColors::loadDataAndUpdate() QString resultNameUnitString = toString(resultNameAndUnit); bool foundResult = false; - for (RimLegendConfig* legend : m_legendConfigurations) + for (RimRegularLegendConfig* legend : m_legendConfigurations) { if (legend->resultVariableName() == resultNameUnitString) { @@ -149,10 +149,10 @@ void RimStimPlanColors::loadDataAndUpdate() if (!foundResult) { - RimLegendConfig* legendConfig = new RimLegendConfig(); + RimRegularLegendConfig* legendConfig = new RimRegularLegendConfig(); legendConfig->resultVariableName = resultNameUnitString; - legendConfig->setMappingMode(RimLegendConfig::LINEAR_DISCRETE); - legendConfig->setColorRangeMode(RimLegendConfig::STIMPLAN); + legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE); + legendConfig->setColorRangeMode(RimRegularLegendConfig::STIMPLAN); m_legendConfigurations.push_back(legendConfig); @@ -226,9 +226,9 @@ void RimStimPlanColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimStimPlanColors::activeLegend() const +RimRegularLegendConfig* RimStimPlanColors::activeLegend() const { - for (RimLegendConfig* legendConfig : m_legendConfigurations) + for (RimRegularLegendConfig* legendConfig : m_legendConfigurations) { if (m_resultNameAndUnit == legendConfig->resultVariableName()) { @@ -276,7 +276,7 @@ cvf::Color3f RimStimPlanColors::defaultColor() const //-------------------------------------------------------------------------------------------------- void RimStimPlanColors::updateLegendData() { - RimLegendConfig* legendConfig = activeLegend(); + RimRegularLegendConfig* legendConfig = activeLegend(); if (legendConfig) { double minValue = HUGE_VAL; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index fb40eb701f..1ff3a5735e 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -33,7 +33,7 @@ namespace caf { } -class RimLegendConfig; +class RimRegularLegendConfig; class RimFractureTemplateCollection; //================================================================================================== @@ -54,7 +54,7 @@ class RimStimPlanColors : public RimCheckableObject RimStimPlanColors(); virtual ~RimStimPlanColors(); - RimLegendConfig* activeLegend() const; + RimRegularLegendConfig* activeLegend() const; QString uiResultName() const; void setDefaultResultName(); QString unit() const; @@ -85,7 +85,7 @@ class RimStimPlanColors : public RimCheckableObject private: caf::PdmField m_defaultColor; caf::PdmField m_resultNameAndUnit; - caf::PdmChildArrayField m_legendConfigurations; + caf::PdmChildArrayField m_legendConfigurations; caf::PdmField m_showStimPlanMesh; caf::PdmField> m_stimPlanCellVizMode; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp index 9f58c46326..b5d54fe9b6 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp @@ -18,7 +18,7 @@ #include "RimStimPlanLegendConfig.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" @@ -38,7 +38,7 @@ RimStimPlanLegendConfig::RimStimPlanLegendConfig() m_name.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_legend, "Legend", "Legend", "", "", ""); - m_legend = new RimLegendConfig; + m_legend = new RimRegularLegendConfig; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h index 7f8afa26a8..3a60a9719c 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h @@ -24,7 +24,7 @@ #include "cafPdmChildField.h" -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -50,6 +50,6 @@ class RimStimPlanLegendConfig : public caf::PdmObject private: caf::PdmField m_name; - caf::PdmChildField m_legend; + caf::PdmChildField m_legend; }; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp index 0c5ef25578..d2f05925a2 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -63,7 +63,7 @@ RimTensorResults::RimTensorResults() CAF_PDM_InitObject("Element Tensor Results", ":/CellResult.png", "", ""); CAF_PDM_InitFieldNoDefault(&arrowColorLegendConfig, "LegendDefinition", "Legend Definition", "", "", ""); - this->arrowColorLegendConfig = new RimLegendConfig(); + this->arrowColorLegendConfig = new RimRegularLegendConfig(); arrowColorLegendConfig.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_resultFieldName, "ResultVariable", QString("ST"), "Value", "", "", ""); @@ -86,7 +86,7 @@ RimTensorResults::RimTensorResults() CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", ""); CAF_PDM_InitField(&m_rangeMode, "RangeType", - RimLegendConfig::RangeModeEnum(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), + RimRegularLegendConfig::RangeModeEnum(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), "Range Type", "", "Switches between automatic and user defined range", @@ -203,11 +203,11 @@ void RimTensorResults::mappingRange(double* min, double* max) const RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); if (!resultCollection) return; - if (m_rangeMode == RimLegendConfig::AUTOMATIC_ALLTIMESTEPS) + if (m_rangeMode == RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS) { resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), min, max); } - else if (m_rangeMode == RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP) + else if (m_rangeMode == RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP) { resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), currentTimeStep, min, max); } @@ -293,11 +293,11 @@ QList RimTensorResults::calculateValueOptions(const caf: } else if (fieldNeedingOptions == &m_rangeMode) { - options.push_back(caf::PdmOptionItemInfo(RimLegendConfig::RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), - RimLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + options.push_back(caf::PdmOptionItemInfo(RimRegularLegendConfig::RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), + RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); options.push_back( - caf::PdmOptionItemInfo(RimLegendConfig::RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), - RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + caf::PdmOptionItemInfo(RimRegularLegendConfig::RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), + RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); } return options; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h index 5785405210..18701d39f1 100644 --- a/ApplicationCode/ProjectDataModel/RimTensorResults.h +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -23,14 +23,14 @@ #include "cafPdmObject.h" #include "RigFemResultPosEnum.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include #include class RigFemResultAddress; -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -76,7 +76,7 @@ class RimTensorResults : public caf::PdmObject QString resultFieldName() const; static QString uiFieldName(const QString& fieldName); - caf::PdmChildField arrowColorLegendConfig; + caf::PdmChildField arrowColorLegendConfig; private: std::vector getResultMetaDataForUIFieldSetting(); @@ -107,5 +107,5 @@ class RimTensorResults : public caf::PdmObject caf::PdmField> m_scaleMethod; caf::PdmField m_sizeScale; - caf::PdmField m_rangeMode; + caf::PdmField m_rangeMode; }; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 5d967bd77a..25dc2d4126 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -34,7 +34,7 @@ #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "RimIntersectionCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimProject.h" #include "RimTernaryLegendConfig.h" #include "Rim3dView.h" diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index 6107b00417..e457b7fd86 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -20,7 +20,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" CAF_PDM_SOURCE_INIT(RimVirtualPerforationResults, "RimVirtualPerforationResults"); @@ -41,7 +41,7 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); m_legendConfig.uiCapability()->setUiHidden(true); - m_legendConfig = new RimLegendConfig(); + m_legendConfig = new RimRegularLegendConfig(); m_legendConfig->setTitle(connectionFactorUiName); // clang-format on @@ -71,7 +71,7 @@ double RimVirtualPerforationResults::geometryScaleFactor() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimVirtualPerforationResults::legendConfig() const +RimRegularLegendConfig* RimVirtualPerforationResults::legendConfig() const { return m_legendConfig(); } diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h index cc55c9c0fc..9b0ce42896 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -25,7 +25,7 @@ #include -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -41,7 +41,7 @@ class RimVirtualPerforationResults : public caf::PdmObject bool isActive() const; double geometryScaleFactor() const; - RimLegendConfig* legendConfig() const; + RimRegularLegendConfig* legendConfig() const; void loadData(); @@ -56,5 +56,5 @@ class RimVirtualPerforationResults : public caf::PdmObject caf::PdmField m_isActive; caf::PdmField m_geometryScaleFactor; - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 7dbf587ea6..94d0acca49 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -136,7 +136,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitField(&m_ensambleParameter, "EnsambleParameter", QString(""), "Ensamble Parameter", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); - m_legendConfig = new RimLegendConfig(); + m_legendConfig = new RimRegularLegendConfig(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index d9dab31632..f73ab30bf0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -21,7 +21,7 @@ #include "RifEclipseSummaryAddress.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmChildArrayField.h" @@ -121,6 +121,6 @@ class RimEnsambleCurveSet : public caf::PdmObject caf::PdmField m_color; caf::PdmField m_ensambleParameter; - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; }; diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index 6e228082e6..d957952604 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -35,7 +35,7 @@ #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" #include "RimFormationNames.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RivIntersectionPartMgr.h" @@ -793,7 +793,7 @@ QString RiuResultTextBuilder::cellResultText(RimEclipseCellColors* resultColors) QString resultValueText; if (resultColors->hasCategoryResult()) { - RimLegendConfig* legendConfig = resultColors->legendConfig(); + RimRegularLegendConfig* legendConfig = resultColors->legendConfig(); resultValueText += legendConfig->categoryNameFromCategoryValue(scalarValue); } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 303728c10f..d36a249b02 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -51,7 +51,7 @@ #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimTernaryLegendConfig.h" #include "RimViewController.h" From 71b7bd21f9fcfd4ad7ccbcdb5999f0336b4929d6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Apr 2018 10:32:51 +0200 Subject: [PATCH 0698/1027] #2727 Legends : Add RimLegendConfig as base for Regular and Ternary --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../Rim2dIntersectionView.cpp | 18 ++++++ .../ProjectDataModel/Rim2dIntersectionView.h | 2 + ApplicationCode/ProjectDataModel/Rim3dView.h | 4 +- .../ProjectDataModel/RimEclipseView.cpp | 18 ++++++ .../ProjectDataModel/RimEclipseView.h | 2 + .../ProjectDataModel/RimGeoMechView.cpp | 13 +++++ .../ProjectDataModel/RimGeoMechView.h | 2 + .../ProjectDataModel/RimLegendConfig.cpp | 38 +++++++++++++ .../ProjectDataModel/RimLegendConfig.h | 43 +++++++++++++++ .../RimRegularLegendConfig.cpp | 30 ++++++++++ .../ProjectDataModel/RimRegularLegendConfig.h | 11 ++-- .../RimTernaryLegendConfig.cpp | 19 +++++++ .../ProjectDataModel/RimTernaryLegendConfig.h | 9 ++- .../UserInterface/RiuViewerCommands.cpp | 55 ++++--------------- 15 files changed, 215 insertions(+), 51 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimLegendConfig.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimLegendConfig.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 64f7f7d33d..f1781a8b9e 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -103,6 +103,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h ) @@ -210,6 +211,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 834f8d518e..7fd42a6e77 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -338,6 +338,24 @@ bool Rim2dIntersectionView::showDefiningPoints() const return m_showDefiningPoints; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim2dIntersectionView::legendConfigs() const +{ + std::vector legendsIn3dView; + + Rim3dView* associated3dView = nullptr; + this->firstAncestorOrThisOfType(associated3dView); + + if (associated3dView) + { + legendsIn3dView = associated3dView->legendConfigs(); + } + + return legendsIn3dView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 85c5b2177c..958670e8a3 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -68,6 +68,8 @@ class Rim2dIntersectionView : public Rim3dView bool showDefiningPoints() const; + std::vector legendConfigs() const override; + protected: void updateLegends() override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index e42532d508..b96923292d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -38,8 +38,9 @@ #include class RimCase; -class RiuViewer; +class RimLegendConfig; class RimWellPathCollection; +class RiuViewer; class RivWellPathsPartMgr; namespace cvf @@ -138,6 +139,7 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface cvf::ref displayCoordTransform() const override; virtual RimCase* ownerCase() const = 0; + virtual std::vector legendConfigs() const = 0; protected: static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 7d9338719e..2fc1ddfac6 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1729,6 +1729,24 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseView::legendConfigs() const +{ + std::vector absLegends; + + absLegends.push_back(cellResult()->legendConfig()); + absLegends.push_back(cellResult()->ternaryLegendConfig()); + absLegends.push_back(faultResultSettings()->customFaultResult()->legendConfig()); + absLegends.push_back(faultResultSettings()->customFaultResult()->ternaryLegendConfig()); + absLegends.push_back(cellEdgeResult()->legendConfig()); + absLegends.push_back(fractureColors()->activeLegend()); + absLegends.push_back(virtualPerforationResult()->legendConfig()); + + return absLegends; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index deb25aefdb..fe973c9ce1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -138,6 +138,8 @@ class RimEclipseView : public RimGridView virtual bool isUsingFormationNames() const override; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; + + std::vector legendConfigs() const override; protected: virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 358791ded3..51636b00db 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -517,6 +517,19 @@ RimTensorResults* RimGeoMechView::tensorResults() return m_tensorResults; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimGeoMechView::legendConfigs() const +{ + std::vector absLegendConfigs; + + absLegendConfigs.push_back(cellResult()->legendConfig()); + + return absLegendConfigs; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 28efa2ff6f..18954b1a41 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -93,6 +93,8 @@ class RimGeoMechView : public RimGridView const RimTensorResults* tensorResults() const; RimTensorResults* tensorResults(); + std::vector legendConfigs() const override; + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp new file mode 100644 index 0000000000..644c2e8127 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimLegendConfig.h" + +// NB! Special macro for pure virtual class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimLegendConfig, "LegendConfig"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimLegendConfig::RimLegendConfig() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimLegendConfig::~RimLegendConfig() +{ + +} diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h new file mode 100644 index 0000000000..705dabe2e1 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" + +namespace caf +{ +class TitledOverlayFrame; +} + +//================================================================================================== +/// +/// +//================================================================================================== +class RimLegendConfig : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimLegendConfig(); + virtual ~RimLegendConfig(); + + virtual const caf::TitledOverlayFrame* titledOverlayFrame() const = 0; + virtual caf::TitledOverlayFrame* titledOverlayFrame() = 0; +}; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index c70263f3c9..4579a91741 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -675,6 +675,36 @@ bool RimRegularLegendConfig::showLegend() const return m_showLegend; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() +{ + if (m_currentScalarMapper == m_categoryMapper) + { + return m_categoryLegend.p(); + } + else + { + return m_scalarMapperLegend.p(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() const +{ + if (m_currentScalarMapper == m_categoryMapper) + { + return m_categoryLegend.p(); + } + else + { + return m_scalarMapperLegend.p(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 107fe8381a..94deec64fe 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -19,13 +19,13 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once + +#include "RimLegendConfig.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cvfArray.h" -#include "cafPdmObject.h" -#include "cafPdmField.h" - #include namespace cvf @@ -53,7 +53,7 @@ class Rim3dView; /// /// //================================================================================================== -class RimRegularLegendConfig: public caf::PdmObject +class RimRegularLegendConfig : public RimLegendConfig { CAF_PDM_HEADER_INIT; public: @@ -123,6 +123,9 @@ class RimRegularLegendConfig: public caf::PdmObject caf::TitledOverlayFrame* legend(); bool showLegend() const; + const caf::TitledOverlayFrame* titledOverlayFrame() const override; + caf::TitledOverlayFrame* titledOverlayFrame() override; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void initAfterRead(); diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index e9f71cdd87..43d6e4fdce 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -497,6 +497,25 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const return m_scalarMapper.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::TitledOverlayFrame* RimTernaryLegendConfig::titledOverlayFrame() const +{ + return m_legend.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::TitledOverlayFrame* RimTernaryLegendConfig::titledOverlayFrame() +{ + return m_legend.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() { return &m_showLegend; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 7993753666..03891e3383 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -19,12 +19,12 @@ #pragma once +#include "RimLegendConfig.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cafAppEnum.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" class RimEclipseView; class RivTernarySaturationOverlayItem; @@ -41,7 +41,7 @@ namespace cvf /// /// //================================================================================================== -class RimTernaryLegendConfig : public caf::PdmObject +class RimTernaryLegendConfig : public RimLegendConfig { CAF_PDM_HEADER_INIT; @@ -79,6 +79,9 @@ class RimTernaryLegendConfig : public caf::PdmObject void setTitle(const QString& title); const RivTernaryScalarMapper* scalarMapper() const; + + const caf::TitledOverlayFrame* titledOverlayFrame() const override; + caf::TitledOverlayFrame* titledOverlayFrame() override; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index d36a249b02..df5e9e2b90 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaDefines.h" #include "RicEclipsePropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h" @@ -36,13 +37,14 @@ #include "RigMainGrid.h" #include "RigVirtualPerforationTransmissibilities.h" -#include "RiaDefines.h" +#include "Rim2dIntersectionView.h" #include "RimCellEdgeColors.h" #include "RimContextCommandBuilder.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" +#include "RimEllipseFractureTemplate.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" #include "RimFracture.h" @@ -51,15 +53,12 @@ #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" -#include "RimRegularLegendConfig.h" +#include "RimLegendConfig.h" +#include "RimPerforationInterval.h" #include "RimSimWellInView.h" -#include "RimTernaryLegendConfig.h" +#include "RimStimPlanFractureTemplate.h" #include "RimViewController.h" #include "RimWellPath.h" -#include "RimPerforationInterval.h" -#include "RimStimPlanFractureTemplate.h" -#include "RimEllipseFractureTemplate.h" -#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" #include "RiuResultTextBuilder.h" @@ -96,6 +95,7 @@ #include #include #include + #include @@ -1058,48 +1058,17 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY) if (pickedOverlayItem) { - caf::PdmObject* objToSelect = nullptr; + std::vector legendConfigs = m_reservoirView->legendConfigs(); - RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - if (eclipseView) + for (const auto& legendConfig : legendConfigs) { - if (eclipseView->cellResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->cellResult()->legendConfig(); - } - else if (eclipseView->cellResult()->ternaryLegendConfig()->legend() == pickedOverlayItem) + if (legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem) { - objToSelect = eclipseView->cellResult()->ternaryLegendConfig(); - } - else if (eclipseView->faultResultSettings()->customFaultResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->faultResultSettings()->customFaultResult()->legendConfig(); - } - else if (eclipseView->faultResultSettings()->customFaultResult()->ternaryLegendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->faultResultSettings()->customFaultResult()->ternaryLegendConfig(); - } - else if (eclipseView->cellEdgeResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->cellEdgeResult()->legendConfig(); - } - } + RiuMainWindow::instance()->selectAsCurrentItem(legendConfig); - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (geomView) - { - if (geomView->cellResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = geomView->cellResult()->legendConfig(); + return true; } } - - if (objToSelect) - { - RiuMainWindow::instance()->selectAsCurrentItem(objToSelect); - - return true; - } } return false; From 978a74a1fe2ff40e18b3c6b6f8103e8744714a58 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 18 Apr 2018 10:43:01 +0200 Subject: [PATCH 0699/1027] #2727 Legends : Remove obsolete functions --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 6 +++--- .../ProjectDataModel/RimEclipseView.cpp | 18 +++++++++--------- .../ProjectDataModel/RimGeoMechView.cpp | 6 +++--- .../RimRegularLegendConfig.cpp | 12 ------------ .../ProjectDataModel/RimRegularLegendConfig.h | 1 - .../RimTernaryLegendConfig.cpp | 13 ------------- .../ProjectDataModel/RimTernaryLegendConfig.h | 3 --- 7 files changed, 15 insertions(+), 44 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 7fd42a6e77..9e67fbae24 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -602,12 +602,12 @@ void Rim2dIntersectionView::updateLegends() if ( eclView->cellResult()->isTernarySaturationSelected() ) { m_ternaryLegendConfig()->setTitle("Cell Result:\n"); - legend = m_ternaryLegendConfig()->legend(); + legend = m_ternaryLegendConfig()->titledOverlayFrame(); } else { m_legendConfig()->setTitle("Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName()); - legend = m_legendConfig()->legend(); + legend = m_legendConfig()->titledOverlayFrame(); } } @@ -616,7 +616,7 @@ void Rim2dIntersectionView::updateLegends() m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); - legend = m_legendConfig()->legend(); + legend = m_legendConfig()->titledOverlayFrame(); } if ( legend ) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 2fc1ddfac6..065882265c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1087,7 +1087,7 @@ void RimEclipseView::updateLegends() } } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); } else @@ -1102,9 +1102,9 @@ void RimEclipseView::updateLegends() { fractureColors()->updateLegendData(); - if (fractureColors()->isChecked() && stimPlanLegend->legend()) + if (fractureColors()->isChecked() && stimPlanLegend->titledOverlayFrame()) { - m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); + m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->titledOverlayFrame()); } } @@ -1113,7 +1113,7 @@ void RimEclipseView::updateLegends() updateVirtualConnectionLegendRanges(); RimRegularLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); - m_viewer->addColorLegendToBottomLeftCorner(virtLegend->legend()); + m_viewer->addColorLegendToBottomLeftCorner(virtLegend->titledOverlayFrame()); } } @@ -1128,17 +1128,17 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->titledOverlayFrame()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->titledOverlayFrame()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->titledOverlayFrame()); } } } @@ -1598,10 +1598,10 @@ void RimEclipseView::resetLegendsInViewer() if (cellResultNormalLegendConfig) { - m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->titledOverlayFrame()); } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 51636b00db..842a3eb30b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -364,7 +364,7 @@ void RimGeoMechView::resetLegendsInViewer() this->cellResult()->legendConfig->recreateLegend(); m_viewer->removeAllColorLegends(); - m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->titledOverlayFrame()); } //-------------------------------------------------------------------------------------------------- @@ -380,7 +380,7 @@ void RimGeoMechView::updateLegends() if (cellResult()->hasResult() && cellResult()->legendConfig()->showLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->titledOverlayFrame()); } updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); @@ -389,7 +389,7 @@ void RimGeoMechView::updateLegends() { if (tensorResults()->arrowColorLegendConfig()->showLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->titledOverlayFrame()); } } } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 4579a91741..43b47f04d0 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -658,18 +658,6 @@ void RimRegularLegendConfig::setTitle(const QString& title) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::TitledOverlayFrame* RimRegularLegendConfig::legend() -{ - if (m_currentScalarMapper == m_categoryMapper) - { - return m_categoryLegend.p(); - } - else - { - return m_scalarMapperLegend.p(); - } -} - bool RimRegularLegendConfig::showLegend() const { return m_showLegend; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 94deec64fe..ef659695f2 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -120,7 +120,6 @@ class RimRegularLegendConfig : public RimLegendConfig void setUiValuesFromLegendConfig(const RimRegularLegendConfig* otherLegendConfig); cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } - caf::TitledOverlayFrame* legend(); bool showLegend() const; const caf::TitledOverlayFrame* titledOverlayFrame() const override; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 43d6e4fdce..6b5a73c1b2 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -328,19 +328,6 @@ void RimTernaryLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() const -{ - return m_legend.p(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() -{ - return m_legend.p(); -} - bool RimTernaryLegendConfig::showLegend() const { return m_showLegend; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 03891e3383..b1eea5d12d 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -71,9 +71,6 @@ class RimTernaryLegendConfig : public RimLegendConfig void recreateLegend(); - const RivTernarySaturationOverlayItem* legend() const; - RivTernarySaturationOverlayItem* legend(); - bool showLegend() const; void setTitle(const QString& title); From 53cf8a80cdb4e6729301a3969e8e84dd3437af70 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 18 Apr 2018 09:27:24 +0200 Subject: [PATCH 0700/1027] Stop building docs as part of "ALL". --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdd7846467..85d449a798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,7 +442,7 @@ if(RESINSIGHT_BUILD_DOCUMENTATION) configure_file(Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) #-- Add a custom target to run Doxygen when ever the project is built - add_custom_target (Docs ALL + add_custom_target (Docs COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile SOURCES ${PROJECT_BINARY_DIR}/Doxyfile) # IF you do NOT want the documentation to be generated EVERY time you build the project From 33033501939651d487dfbe14bc175ff442c1efcb Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 18 Apr 2018 09:49:47 +0200 Subject: [PATCH 0701/1027] Rename member variable in RivWellPathsPartManager to get rid of spelling error. --- .../ModelVisualization/RivWellPathsPartMgr.cpp | 12 ++++++------ .../ModelVisualization/RivWellPathsPartMgr.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index bd6c2a94d8..8d4228836f 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -52,7 +52,7 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* createPartManagersIfRequired(); - for (auto& partMgr : m_wellPatshsPartMgrs) + for (auto& partMgr : m_wellPathsPartMgrs) { partMgr->appendStaticGeometryPartsToModel(model, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); } @@ -67,7 +67,7 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* createPartManagersIfRequired(); - for (auto& partMgr : m_wellPatshsPartMgrs) + for (auto& partMgr : m_wellPathsPartMgrs) { partMgr->appendStaticFracturePartsToModel(model); } @@ -86,7 +86,7 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* createPartManagersIfRequired(); - for (auto& partMgr : m_wellPatshsPartMgrs) + for (auto& partMgr : m_wellPathsPartMgrs) { partMgr->appendDynamicGeometryPartsToModel( model, timeStepIndex, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); @@ -98,7 +98,7 @@ void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- void RivWellPathsPartMgr::clearGeometryCache() { - m_wellPatshsPartMgrs.clear(); + m_wellPathsPartMgrs.clear(); m_mapFromViewToIndex.clear(); } @@ -115,14 +115,14 @@ void RivWellPathsPartMgr::createPartManagersIfRequired() RimProject* proj = RiaApplication::instance()->project(); auto wellPaths = proj->allWellPaths(); - if (m_wellPatshsPartMgrs.size() != wellPaths.size()) + if (m_wellPathsPartMgrs.size() != wellPaths.size()) { clearGeometryCache(); for (auto wellPath : wellPaths) { RivWellPathPartMgr* wppm = new RivWellPathPartMgr(wellPath, m_rimView); - m_wellPatshsPartMgrs.push_back(wppm); + m_wellPathsPartMgrs.push_back(wppm); m_mapFromViewToIndex[wellPath] = wppm; } } diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index 0c01eba7c8..62330ea03d 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -77,6 +77,6 @@ class RivWellPathsPartMgr : public cvf::Object private: caf::PdmPointer m_rimView; - cvf::Collection m_wellPatshsPartMgrs; + cvf::Collection m_wellPathsPartMgrs; std::map m_mapFromViewToIndex; }; From 01a1f660e76056d46ba7bc9bbddcd09e95786605 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 18 Apr 2018 11:09:50 +0200 Subject: [PATCH 0702/1027] 3D Well Log Curves (#2746): Handle set scale. * Transform to display coordinates *before* calculating normals and generating curves. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 21 +++++++---- .../Riv3dWellLogGridGeomertyGenerator.cpp | 36 +++++++++++-------- .../RigWellPathGeometryTools.cpp | 17 ++++----- .../RigWellPathGeometryTools.h | 4 +-- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 434a2132d5..4157ee7df9 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -107,22 +107,30 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); - double maxZClipHeight = wellPathGeometry()->m_wellPathPoints.front().z(); + cvf::Vec3d clipLocation = wellPathGeometry()->m_wellPathPoints.front(); if (wellPathCollection->wellPathClip) { - maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + double clipZDistance = wellPathCollection->wellPathClipZDistance; + clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); } + clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); - std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + for (cvf::Vec3d& wellPathPoint : wellPathPoints) + { + wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); + } + + std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); std::vector interpolatedWellPathPoints; std::vector interpolatedCurveNormals; // Iterate from bottom of well path and up to be able to stop at given Z max clipping height for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) { - cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*md); + cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, *md); cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, *md); - if (point.z() > maxZClipHeight) break; + if (point.z() > clipLocation.z()) break; interpolatedWellPathPoints.push_back(point); interpolatedCurveNormals.push_back(normal.getNormalized()); @@ -162,8 +170,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor; } - (*vertices)[i] = cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i])); + (*vertices)[i] = cvf::Vec3f(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); } std::vector> valuesIntervals = diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 350250ea1e..72a8c77af8 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -74,15 +74,26 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* return false; } + for (cvf::Vec3d& wellPathPoint : wellPathPoints) + { + wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); + } + + std::vector wellPathSegmentNormals = + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); + + size_t originalWellPathSize = wellPathPoints.size(); if (wellPathCollection->wellPathClip) { + double clipZDistance = wellPathCollection->wellPathClipZDistance; double horizontalLengthAlongWellToClipPoint; - double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + cvf::Vec3d clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); + clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); size_t indexToFirstVisibleSegment; wellPathPoints = RigWellPath::clipPolylineStartAboveZ( - wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); + wellPathPoints, clipLocation.z(), &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); } if (wellPathPoints.size() < (size_t) 2) @@ -91,9 +102,8 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* return false; } - // calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off - std::vector wellPathSegmentNormals = - RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathGeometry(), planeAngle); + // Note that normals are calculated on the full non-clipped well path to increase the likelihood of creating good normals + // for the end points of the curve. So we need to clip the remainder here. wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); { @@ -106,10 +116,10 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* // Vertices are used for both surface and border for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter)); + vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); backgroundIndices.push_back((cvf::uint) (2 * i)); backgroundIndices.push_back((cvf::uint) (2 * i + 1)); } @@ -177,7 +187,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* double md = lastMd; while (md >= firstMd) { - cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); + cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathSegmentNormals, md); interpolatedGridPoints.push_back(point); interpolatedGridCurveNormals.push_back(curveNormal.getNormalized()); @@ -193,11 +203,9 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* // Normal lines. Start from one to avoid drawing at surface edge. for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++) { - vertices.push_back(cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter)); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( - interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)))); + vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); indices.push_back(indexCounter++); indices.push_back(indexCounter++); diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index bc092b58a1..f7e1fcff60 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -29,22 +29,18 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, +std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const std::vector& vertices, double planeAngle) { std::vector pointNormals; - if (!wellPathGeometry) return pointNormals; - - const std::vector& vertices = wellPathGeometry->wellPathPoints(); - if (vertices.empty()) return pointNormals; pointNormals.reserve(vertices.size()); cvf::Vec3d up(0, 0, 1); - cvf::Vec3d dominantDirection = estimateDominantDirectionInXYPlane(wellPathGeometry); + cvf::Vec3d dominantDirection = estimateDominantDirectionInXYPlane(vertices); const cvf::Vec3d projectionPlaneNormal = (up ^ dominantDirection).getNormalized(); CVF_ASSERT(projectionPlaneNormal * dominantDirection <= std::numeric_limits::epsilon()); @@ -130,13 +126,12 @@ std::vector RigWellPathGeometryTools::interpolateUndefinedNormals(co return interpolated; } -cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const RigWellPath* wellPathGeometry) +cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const std::vector& vertices) { - cvf::Vec3d directionSum(0, 0, 0); - const std::vector& points = wellPathGeometry->m_wellPathPoints; - for (size_t i = 1; i < points.size(); ++i) + cvf::Vec3d directionSum(0, 0, 0); + for (size_t i = 1; i < vertices.size(); ++i) { - cvf::Vec3d vec = points[i] - points[i - 1]; + cvf::Vec3d vec = vertices[i] - vertices[i - 1]; vec.z() = 0.0; if (directionSum.length() > 0.0 && (directionSum * vec) < 0.0) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h index 17cd410a79..658605280b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -38,11 +38,11 @@ class RigWellPathGeometryTools }; public: - static std::vector calculateLineSegmentNormals(const RigWellPath* wellPathGeometry, + static std::vector calculateLineSegmentNormals(const std::vector& vertices, double angle); private: static std::vector interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, const std::vector& normals, const std::vector& vertices); - static cvf::Vec3d estimateDominantDirectionInXYPlane(const RigWellPath* wellPathGeometry); + static cvf::Vec3d estimateDominantDirectionInXYPlane(const std::vector& vertices); }; From 916fb59bee9b2f248cffa4d3fa5a0f2c9d4642f3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 18 Apr 2018 11:31:40 +0200 Subject: [PATCH 0703/1027] 3D Well Log Curves (#2673): Simplify draw plane text * Above, Below, Left, Right, Vertical, Horizontal --- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index eb0bac7a33..a668a297ac 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -33,10 +33,10 @@ namespace caf template<> void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() { - addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Beside Well Path - Above"); - addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Beside Well Path - Below"); - addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Beside Well Path - Left"); - addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Beside Well Path - Right"); + addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Above"); + addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Below"); + addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Right"); setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); } } @@ -163,7 +163,7 @@ QList Rim3dWellLogCurve::calculateValueOptions(const caf } else { - options.push_back(caf::PdmOptionItemInfo(QString("Vertical - Centered"), Rim3dWellLogCurve::VERTICAL_ABOVE)); + options.push_back(caf::PdmOptionItemInfo(QString("Vertical"), Rim3dWellLogCurve::VERTICAL_ABOVE)); } if (collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ALONG_WELLPATH) { @@ -172,7 +172,7 @@ QList Rim3dWellLogCurve::calculateValueOptions(const caf } else { - options.push_back(caf::PdmOptionItemInfo(QString("Horizontal - Centered"), Rim3dWellLogCurve::HORIZONTAL_LEFT)); + options.push_back(caf::PdmOptionItemInfo(QString("Horizontal"), Rim3dWellLogCurve::HORIZONTAL_LEFT)); } } return options; From 3ce2bfd67cc5f38becbba4e78c78306070ca7566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 18 Apr 2018 13:56:01 +0200 Subject: [PATCH 0704/1027] #2687 #2750 Add import ensamble command. Add import summary cases commands to plot tree nodes --- .../Commands/CMakeLists_files.cmake | 2 + .../RicCreateSummaryCaseCollectionFeature.cpp | 27 ++- .../RicCreateSummaryCaseCollectionFeature.h | 4 + .../Commands/RicImportEnsambleFeature.cpp | 157 ++++++++++++++++++ .../Commands/RicImportEnsambleFeature.h | 48 ++++++ .../Commands/RicImportSummaryCasesFeature.cpp | 71 +++++--- .../Commands/RicImportSummaryCasesFeature.h | 13 +- .../RimContextCommandBuilder.cpp | 18 ++ .../Summary/RimEnsambleCurveSet.cpp | 1 + .../Summary/RimSummaryCaseCollection.h | 1 + .../Summary/RimSummaryCaseMainCollection.cpp | 3 +- .../Summary/RimSummaryCaseMainCollection.h | 2 +- .../UserInterface/RiuMainPlotWindow.cpp | 1 + .../UserInterface/RiuMainWindow.cpp | 1 + 14 files changed, 309 insertions(+), 40 deletions(-) create mode 100644 ApplicationCode/Commands/RicImportEnsambleFeature.cpp create mode 100644 ApplicationCode/Commands/RicImportEnsambleFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 3af4643a62..0498e2eb5f 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -66,6 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsambleFeature.h ) @@ -130,6 +131,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsambleFeature.cpp ) diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 16bb885c7f..11a13e0130 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -33,6 +33,24 @@ CAF_CMD_SOURCE_INIT(RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCaseCollectionFeature"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector cases, const QString& groupName) +{ + RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; + if (!cases.empty()) + { + cases[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); + + summaryCaseMainCollection->addCaseCollection(cases, groupName); + summaryCaseMainCollection->updateConnectedEditors(); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -65,14 +83,7 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&selection); if (selection.size() == 0) return; - RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; - selection[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); - - summaryCaseMainCollection->addCaseCollection(selection); - summaryCaseMainCollection->updateConnectedEditors(); - - RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); + groupSummaryCases(selection, ""); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h index e39857e9a7..411ed16028 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h @@ -22,6 +22,8 @@ #include +class RimSummaryCase; + //================================================================================================== /// //================================================================================================== @@ -29,6 +31,8 @@ class RicCreateSummaryCaseCollectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; + static void groupSummaryCases(std::vector cases, const QString& groupName); + private: virtual bool isCommandEnabled() override; virtual void onActionTriggered(bool isChecked) override; diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp new file mode 100644 index 0000000000..0bd4969308 --- /dev/null +++ b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportEnsambleFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportSummaryCasesFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuMainPlotWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicImportEnsambleFeature, "RicImportEnsambleFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEnsambleFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEnsambleFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + + std::vector cases = RicImportSummaryCasesFeature::importSummaryCases("Import Ensamble"); + + if (cases.empty()) return; + validateEnsambleCases(cases); + + QString ensambleName = askForEnsambleName(); + if (ensambleName.isEmpty()) return; + + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensambleName); + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEnsambleFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); + actionToSetup->setText("Import Ensamble"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEnsambleFeature::validateEnsambleCases(std::vector cases) +{ + // Validate ensamble parameters + try + { + std::hash paramsHasher; + size_t paramsHash = 0; + + for (RimSummaryCase* rimCase : cases) + { + if (rimCase->caseRealizationParameters().isNull() || rimCase->caseRealizationParameters()->parameters().empty()) + { + throw QString("The case %1 has no ensamble parameters").arg(rimCase->summaryHeaderFilename()); + } + else + { + QString paramNames; + for (std::pair paramPair : rimCase->caseRealizationParameters()->parameters()) + { + paramNames.append(paramPair.first); + } + + size_t currHash = paramsHasher(paramNames.toStdString()); + if (paramsHash == 0) + { + paramsHash = currHash; + } + else if (paramsHash != currHash) + { + throw QString("Ensamble parameters differ between cases"); + } + } + } + return true; + } + catch (QString errorMessage) + { + QMessageBox mbox; + mbox.setIcon(QMessageBox::Icon::Warning); + mbox.setInformativeText(errorMessage); + mbox.exec(); + return false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicImportEnsambleFeature::askForEnsambleName() +{ + RimProject* project = RiaApplication::instance()->project(); + int groupCount = (int)project->summaryGroups().size(); + + QInputDialog dialog; + dialog.setInputMode(QInputDialog::TextInput); + dialog.setWindowTitle("Ensamble Name"); + dialog.setLabelText("Ensamble Name"); + dialog.setTextValue(QString("Ensamble %1").arg(groupCount)); + dialog.resize(300, 50); + dialog.exec(); + return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString(""); +} diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.h b/ApplicationCode/Commands/RicImportEnsambleFeature.h new file mode 100644 index 0000000000..c112927f49 --- /dev/null +++ b/ApplicationCode/Commands/RicImportEnsambleFeature.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicImportEnsambleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; + + bool validateEnsambleCases(std::vector cases); + QString askForEnsambleName(); +}; + + diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index bf131a7598..83b7618672 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -43,6 +43,13 @@ CAF_CMD_SOURCE_INIT(RicImportSummaryCasesFeature, "RicImportSummaryCasesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicImportSummaryCasesFeature::m_pathFilter = "*"; +QString RicImportSummaryCasesFeature::m_fileNameFilter = "*"; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -56,32 +63,15 @@ bool RicImportSummaryCasesFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) { - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Import Summary Cases", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); - - // Remember filters - m_pathFilter = result.pathFilter; - m_fileNameFilter = result.fileNameFilter; - - if (!result.ok) return; - - // Remember the path to next time - app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + RiaApplication* app = RiaApplication::instance(); + std::vector cases = importSummaryCases("Import Summary Cases"); + + for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); - QStringList fileNames = result.files; - if (fileNames.isEmpty()) return; + std::vector allCases; + app->project()->allCases(allCases); - if (createAndAddSummaryCasesFromFiles(fileNames)) - { - for (const auto& fileName : fileNames) RiaApplication::instance()->addToRecentFiles(fileName); - } - - std::vector cases; - app->project()->allCases(cases); - - if (cases.size() == 0) + if (allCases.size() == 0) { RiuMainWindow::instance()->close(); } @@ -99,11 +89,13 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames) +bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + + if (newCases) newCases->clear(); if (!sumCaseColl) return false; RifSummaryCaseRestartSelector fileSelector; @@ -119,5 +111,34 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStri mainPlotWindow->updateSummaryPlotToolBar(); } + + if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicImportSummaryCasesFeature::importSummaryCases(const QString& dialogTitle) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, dialogTitle, defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (!result.ok) return std::vector(); + + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + + QStringList fileNames = result.files; + if (fileNames.isEmpty()) return std::vector(); + + std::vector newCases; + createAndAddSummaryCasesFromFiles(fileNames, &newCases); + return newCases; +} diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 093836f3d9..53e07b3f9d 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -23,9 +23,10 @@ #include "cafCmdFeature.h" #include +#include class RicSummaryCaseRestartDialogResult; - +class RimSummaryCase; //================================================================================================== /// @@ -35,9 +36,11 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - RicImportSummaryCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") { } + RicImportSummaryCasesFeature() { } + + static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases = nullptr); - static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName); + static std::vector importSummaryCases(const QString& dialogTitle); protected: // Overrides @@ -46,8 +49,8 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ) override; private: - QString m_pathFilter; - QString m_fileNameFilter; + static QString m_pathFilter; + static QString m_fileNameFilter; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 4fb9d19c7c..87b3a44eac 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -58,6 +58,8 @@ #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" @@ -451,8 +453,24 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewSummaryEnsambleCurveSetFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportEnsambleFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportEnsambleFeature"; + } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportEnsambleFeature"; + if (!dynamic_cast(uiItem)) { menuBuilder << "RicShowSummaryCurveCalculatorFeature"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 94d0acca49..f7c65c5745 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -466,6 +466,7 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie plot->updateAxes(); } } + updateCurveColors(); } else if (changedField == &m_ensambleParameter || changedField == &m_color || diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 08d70733a5..84985633f3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -36,6 +36,7 @@ class RimSummaryCaseCollection : public caf::PdmObject void addCase(RimSummaryCase* summaryCase); std::vector allSummaryCases(); + void setName(const QString& name) { m_name = name; } QString name() const { return m_name; } private: diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index d904d80478..9e7be37866 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -193,9 +193,10 @@ void RimSummaryCaseMainCollection::removeCase(RimSummaryCase* summaryCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases) +void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases, const QString& collectionName) { RimSummaryCaseCollection* summaryCaseCollection = new RimSummaryCaseCollection(); + if(!collectionName.isEmpty()) summaryCaseCollection->setName(collectionName); for (RimSummaryCase* summaryCase : summaryCases) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index eadb99bc8e..736a71e5cd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -53,7 +53,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void addCase(RimSummaryCase* summaryCase); void removeCase(RimSummaryCase* summaryCase); - void addCaseCollection(std::vector summaryCases); + void addCaseCollection(std::vector summaryCases, const QString& coolectionName); void removeCaseCollection(RimSummaryCaseCollection* caseCollection); void loadAllSummaryCaseData(); diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 7928a9afbc..fa26dd910a 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -189,6 +189,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEnsambleFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e54b5c1d91..e1b48b3e39 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -381,6 +381,7 @@ void RiuMainWindow::createMenus() #endif importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEnsambleFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); From e468227dfec5dcdd5f9d1f612f784f6cd00b2659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 18 Apr 2018 14:13:37 +0200 Subject: [PATCH 0705/1027] Fix Linux warning --- .../ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 72a8c77af8..72083bf04a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -144,7 +144,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* int secondLastEvenVertex = (int) vertices.size() - 4; // Border close to the well. All even indices. - for (size_t i = 0; i <= secondLastEvenVertex; i += 2) + for (int i = 0; i <= secondLastEvenVertex; i += 2) { borderIndices.push_back((cvf::uint) i); borderIndices.push_back((cvf::uint) i+2); From 53a6e0e502835e9fc6680bb8978ad0ffd48c2621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 18 Apr 2018 15:58:49 +0200 Subject: [PATCH 0706/1027] #2657 WIP: Add movable widget with color legend for ensemble curve sets to summary plot --- .../Summary/RimEnsambleCurveSet.cpp | 24 ++ .../Summary/RimEnsambleCurveSet.h | 1 + .../UserInterface/CMakeLists_files.cmake | 6 + .../UserInterface/RiuCvfOverlayItemWidget.cpp | 210 ++++++++++++++++++ .../UserInterface/RiuCvfOverlayItemWidget.h | 48 ++++ .../UserInterface/RiuSummaryQwtPlot.cpp | 48 ++++ .../UserInterface/RiuSummaryQwtPlot.h | 10 + .../UserInterface/RiuWidgetDragger.cpp | 56 +++++ .../UserInterface/RiuWidgetDragger.h | 40 ++++ 9 files changed, 443 insertions(+) create mode 100644 ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp create mode 100644 ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h create mode 100644 ApplicationCode/UserInterface/RiuWidgetDragger.cpp create mode 100644 ApplicationCode/UserInterface/RiuWidgetDragger.h diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index f7c65c5745..05313a9988 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -145,6 +145,13 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() RimEnsambleCurveSet::~RimEnsambleCurveSet() { m_curves.deleteAllChildObjects(); + + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) + { + parentPlot->qwtPlot()->removeEnsambleCurveSetLegend(this); + } } //-------------------------------------------------------------------------------------------------- @@ -185,6 +192,15 @@ void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); + + if (m_showCurves() && m_colorMode() == BY_ENSAMBLE_PARAM) + { + parentPlot->qwtPlot()->addOrUpdateEnsambleCurveSetLegend(this); + } + else + { + parentPlot->qwtPlot()->removeEnsambleCurveSetLegend(this); + } } } } @@ -422,6 +438,14 @@ void RimEnsambleCurveSet::handleKeyPressEvent(QKeyEvent* keyEvent) //} } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig* RimEnsambleCurveSet::legendConfig() +{ + return m_legendConfig; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index f73ab30bf0..44d296c780 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -79,6 +79,7 @@ class RimEnsambleCurveSet : public caf::PdmObject //std::vector fieldsToShowInToolbar(); void handleKeyPressEvent(QKeyEvent* keyEvent); + RimRegularLegendConfig* legendConfig(); private: caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 76c6a6cc73..5c12f75e59 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -21,6 +21,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.h +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.h @@ -90,6 +92,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.cpp @@ -165,6 +169,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.h +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.h diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp new file mode 100644 index 0000000000..88d46b6d8a --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -0,0 +1,210 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#include "RiuCvfOverlayItemWidget.h" + +#include +#include +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuCvfOverlayItemWidget::RiuCvfOverlayItemWidget(QWidget* parent/*=0*/) +: QWidget(parent) +{ + this->setLayout(new QHBoxLayout(this)); + m_overlayItemLabel = new QLabel(this); + this->layout()->addWidget(m_overlayItemLabel); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() +{ + +} + +#include "cafViewer.h" +#include "cvfRendering.h" +#include "cvfRenderSequence.h" +#include "cvfFramebufferObject.h" +#include "cvfRenderbufferObject.h" +#include "cvfqtUtils.h" +#include "glew/GL/glew.h" +#include "RiaApplication.h" +#include "cvfCamera.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) +{ + //m_scalarMapperLegend->setTitle("Hei og hopp"); + //m_scalarMapperLegend->computeLayoutAndExtents({0,0}, {100, 400}); + //unsigned int width = m_scalarMapperLegend->minimumWidth() + 100; + unsigned int width = item->sizeHint().x(); + unsigned int height = item->sizeHint().y(); + + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); + cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); + viewer->resize(width, height); + + // Create a rendering + + cvf::ref rendering = new cvf::Rendering; + item->setLayoutFixedPosition({0,0}); + rendering->addOverlayItem(item); + + + rendering->camera()->setViewport(0,0,width, height); + rendering->camera()->viewport()->setClearColor({1,1,1,0}); + + cvf::ref renderingSequence = new cvf::RenderSequence; + renderingSequence->addRendering(rendering.p()); + + if (RiaApplication::instance()->useShaders()) + { + // Set up frame and render buffers + + cvf::ref fbo = new cvf::FramebufferObject; + + cvf::ref rboColor = new cvf::RenderbufferObject(cvf::RenderbufferObject::RGBA, width, height); + cvf::ref rboDepth = new cvf::RenderbufferObject(cvf::RenderbufferObject::DEPTH_COMPONENT24, width, height); + + fbo->attachDepthRenderbuffer(rboDepth.p()); + fbo->attachColorRenderbuffer(0, rboColor.p()); + + fbo->applyOpenGL(cvfOglContext); + rendering->setTargetFramebuffer(fbo.p()); + fbo->bind(cvfOglContext); + } + + renderingSequence->render(cvfOglContext); + + // Read data from framebuffer + + cvf::UByteArray arr(4*width*height); + glReadPixels(0, 0, static_cast(width), static_cast(height), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr()); + + // Create a cvf texture image + + cvf::ref img = new cvf::TextureImage; + img->setData(arr.ptr(), width, height); + + QImage image = cvfqt::Utils::toQImage(*img.p()); + //image.save("jjsLegendImageTest.png"); + + QPixmap pixmap = QPixmap::fromImage(image); + + delete viewer; + + m_overlayItemLabel->setPixmap(pixmap); + this->setMinimumSize(QSize(width, height)); + +} + +#if 0 + +#include "cafViewer.h" +#include "cvfRendering.h" +#include "cvfRenderSequence.h" +#include "cvfFramebufferObject.h" +#include "cvfRenderbufferObject.h" +#include "cvfqtUtils.h" +#include "glew/GL/glew.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QPixmap RimLegendConfig::drawLegend() +{ + m_scalarMapperLegend->setTitle("Hei og hopp"); + m_scalarMapperLegend->computeLayoutAndExtents({0,0}, {100, 400}); + unsigned int width = m_scalarMapperLegend->minimumWidth() + 100; + unsigned int height = m_scalarMapperLegend->sizeHint().y(); + + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); + cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); + viewer->resize(width, height); + + + // Create a rendering + + cvf::ref rendering = new cvf::Rendering; + m_scalarMapperLegend->setLayoutFixedPosition({0,0}); + rendering->addOverlayItem(m_scalarMapperLegend.p()); + + + rendering->camera()->setViewport(0,0,width, height); + rendering->camera()->viewport()->setClearColor({1,1,1,0}); + + cvf::ref renderingSequence = new cvf::RenderSequence; + renderingSequence->addRendering(rendering.p()); + + if (RiaApplication::instance()->useShaders()) + { + // Set up frame and render buffers + + cvf::ref fbo = new cvf::FramebufferObject; + + cvf::ref rboColor = new cvf::RenderbufferObject(cvf::RenderbufferObject::RGBA, width, height); + cvf::ref rboDepth = new cvf::RenderbufferObject(cvf::RenderbufferObject::DEPTH_COMPONENT24, width, height); + + fbo->attachDepthRenderbuffer(rboDepth.p()); + fbo->attachColorRenderbuffer(0, rboColor.p()); + + fbo->applyOpenGL(cvfOglContext); + rendering->setTargetFramebuffer(fbo.p()); + fbo->bind(cvfOglContext); + } + + renderingSequence->render(cvfOglContext); + + // Read data from framebuffer + + cvf::UByteArray arr(4*width*height); + glReadPixels(0, 0, static_cast(width), static_cast(height), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr()); + + // Create a cvf texture image + + cvf::ref img = new cvf::TextureImage; + img->setData(arr.ptr(), width, height); + + QImage image = cvfqt::Utils::toQImage(*img.p()); + //image.save("jjsLegendImageTest.png"); + + QPixmap pixmap = QPixmap::fromImage(image); + + delete viewer; + + return pixmap; +} +#endif \ No newline at end of file diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h new file mode 100644 index 0000000000..46f670b479 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class QLabel; +namespace cvf +{ + class OverlayItem; +} + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuCvfOverlayItemWidget : public QWidget +{ + Q_OBJECT +public: + explicit RiuCvfOverlayItemWidget(QWidget* parent = nullptr); + ~RiuCvfOverlayItemWidget(); + + void updateFromOverlyItem( cvf::OverlayItem * item); + + // virtual QSize sizeHint() const override; + // virtual QSize minimumSizeHint() const override; + +protected: + QLabel* m_overlayItemLabel; +}; diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index e64d9fe672..732a0d0832 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -52,6 +52,12 @@ #include +#include "RiuWidgetDragger.h" +#include "RiuCvfOverlayItemWidget.h" +#include "RimEnsambleCurveSet.h" +#include "RimRegularLegendConfig.h" +#include "cafTitledOverlayFrame.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -158,6 +164,48 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::addOrUpdateEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor) +{ + RiuCvfOverlayItemWidget* overlayWidget = nullptr; + + auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor); + if (it == m_ensembleLegendWidgets.end() || it->second == nullptr) + { + overlayWidget = new RiuCvfOverlayItemWidget(this); + new RiuWidgetDragger(overlayWidget); + + m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget; + overlayWidget->move(30, 30); + } + else + { + overlayWidget = it->second; + } + + if ( overlayWidget ) + { + overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame()); + overlayWidget->show(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::removeEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor) +{ + auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor); + if ( it != m_ensembleLegendWidgets.end() ) + { + if ( it->second != nullptr ) it->second->deleteLater(); + + m_ensembleLegendWidgets.erase(it); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index c95350a1d5..763e1ae044 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -32,8 +32,12 @@ class QwtPlotZoomer; class QwtInterval; class QwtPicker; class QwtPlotMarker; +class QwtScaleWidget; + +class RiuCvfOverlayItemWidget; class RimSummaryPlot; +class RimEnsambleCurveSet; //================================================================================================== // @@ -61,6 +65,9 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow const QwtInterval& rightAxis, const QwtInterval& timeAxis); + void addOrUpdateEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor); + void removeEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor); + static void setCommonPlotBehaviour(QwtPlot* plot); static void enableDateBasedBottomXAxis(QwtPlot* plot); @@ -85,5 +92,8 @@ private slots: QPointer m_zoomerLeft; QPointer m_zoomerRight; + + std::map< caf::PdmPointer, QPointer > m_ensembleLegendWidgets; + }; diff --git a/ApplicationCode/UserInterface/RiuWidgetDragger.cpp b/ApplicationCode/UserInterface/RiuWidgetDragger.cpp new file mode 100644 index 0000000000..6b2d327178 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuWidgetDragger.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuWidgetDragger.h" +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWidgetDragger::RiuWidgetDragger(QWidget* widgetToMove) + : QObject(widgetToMove) + , m_widgetToMove(widgetToMove) + , m_startPos(0,0) +{ + m_widgetToMove->installEventFilter(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuWidgetDragger::eventFilter(QObject * watched, QEvent * event) +{ + if (event->type() == QEvent::MouseMove) + { + QMouseEvent* mMoveEv = static_cast(event); + if (mMoveEv->buttons() & Qt::LeftButton) + { + m_widgetToMove->move( m_widgetToMove->mapToParent(mMoveEv->pos() - m_startPos)); + } + } + else if (event->type() == QEvent::MouseButtonPress) + { + QMouseEvent* mEv = static_cast(event); + m_startPos = mEv->pos(); + } + + return false; +} + diff --git a/ApplicationCode/UserInterface/RiuWidgetDragger.h b/ApplicationCode/UserInterface/RiuWidgetDragger.h new file mode 100644 index 0000000000..ea68299cd9 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuWidgetDragger.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include +#include +#include + +class QWidget; +class QEvent; + +class RiuWidgetDragger : public QObject +{ + Q_OBJECT +public: + RiuWidgetDragger(QWidget* widgetToMove); + + virtual bool eventFilter(QObject * watched, QEvent * event) override; + +private: + QPointer m_widgetToMove; + QPoint m_startPos; +}; + + From 305fdfcfc80ee589f484d907855d2d3a6b82c0c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 07:04:46 +0200 Subject: [PATCH 0707/1027] Remove unused variables and functions --- ...ellPathExportCompletionDataFeatureImpl.cpp | 43 ------------------- ...cWellPathExportCompletionDataFeatureImpl.h | 8 ---- .../RigEclipseWellLogExtractor.cpp | 1 - .../RigWellPathIntersectionTools.cpp | 11 ----- .../RigWellPathIntersectionTools.h | 3 -- .../UserInterface/RiuViewerCommands.cpp | 1 - 6 files changed, 67 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 120e80d2b2..6f98e92a52 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -608,49 +608,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompdatAndWpimultTables( RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWellAndCompletionType( - const std::vector& completions, - const QString& wellName, - RigCompletionData::CompletionType completionType) -{ - std::vector filteredCompletions; - for (const auto& completion : completions) - { - if (completion.wellName() == wellName && completion.completionType() == completionType) - { - filteredCompletions.push_back(completion); - } - } - return filteredCompletions; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map> - RicWellPathExportCompletionDataFeatureImpl::getCompletionsForWell( - const std::map>& cellToCompletionMap, - const QString& wellName) -{ - std::map> wellCompletions; - - for (const auto& it : cellToCompletionMap) - { - for (auto& completion : it.second) - { - if (completion.wellName() == wellName) - { - wellCompletions[it.first].push_back(completion); - } - } - } - - return wellCompletions; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 3991caceac..0836e4c073 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -173,14 +173,6 @@ class RicWellPathExportCompletionDataFeatureImpl const std::map>& completionsPerGrid, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, - const QString& wellName, - RigCompletionData::CompletionType completionType); - - static std::map > - getCompletionsForWell(const std::map>& cellToCompletionMap, - const QString& wellName); - static void exportCompdatTableUsingFormatter(RifEclipseDataTableFormatter& formatter, const QString& gridName, const std::vector& completionData); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index aed14a0f77..5b5079c5bb 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -53,7 +53,6 @@ void RigEclipseWellLogExtractor::calculateIntersection() { std::map uniqueIntersections; - const std::vector& nodeCoords = m_caseData->mainGrid()->nodes(); bool isCellFaceNormalsOut = m_caseData->mainGrid()->isFaceNormalsOutwards(); if (m_wellPath->m_wellPathPoints.empty()) return; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index fb23d14f8b..ed05ffae6c 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -144,14 +144,3 @@ cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const RigMainGrid return calculateLengthInCell(hexCorners, startPoint, endPoint); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigWellPathIntersectionTools::findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb) -{ - std::vector closeCells; - grid->findIntersectingCells(bb, &closeCells); - return closeCells; -} - diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index 413d72e1e6..c5f8cf3b81 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -55,7 +55,4 @@ class RigWellPathIntersectionTools size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint); - -private: - static std::vector findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index df5e9e2b90..714ebf12f5 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -639,7 +639,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; size_t globalCellIndex = wellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); - double connectionFactor = wellConnectionSourceInfo->connectionFactorFromTriangleIndex(firstPartTriangleIndex); RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); if (eclipseView) From fff5ee4ea15f25aa48a57ee48cd799cd022c76ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 18 Apr 2018 21:38:50 +0200 Subject: [PATCH 0708/1027] #2691 Complete curve set vector selection from the property panel --- .../Summary/RimEnsambleCurveSet.cpp | 236 +++++++++++++----- .../Summary/RimEnsambleCurveSet.h | 16 +- 2 files changed, 189 insertions(+), 63 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 05313a9988..921442c676 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -20,6 +20,8 @@ #include "RiaApplication.h" +#include "RiuSummaryCurveDefSelectionDialog.h" + #include "RifReaderEclipseSummary.h" #include "RimProject.h" @@ -105,7 +107,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitFieldNoDefault(&m_yValuesSelectedVariableDisplayField, "SelectedVariableDisplayVar", "Vector", "", "", ""); m_yValuesSelectedVariableDisplayField.xmlCapability()->disableIO(); - //m_yValuesSelectedVariableDisplayField.uiCapability()->setUiReadOnly(true); + m_yValuesSelectedVariableDisplayField.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryFilter, "VarListFilter", "Filter", "", "", ""); m_yValuesSummaryFilter.uiCapability()->setUiTreeChildrenHidden(true); @@ -126,6 +128,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitFieldNoDefault(&m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", ""); caf::PdmUiPushButtonEditor::configureEditorForField(&m_yPushButtonSelectSummaryAddress); m_yPushButtonSelectSummaryAddress = false; + m_yPushButtonSelectSummaryAddress.uiCapability()->setUiReadOnly(true); m_yValuesCurveVariable = new RimSummaryAddress; @@ -135,6 +138,8 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitField(&m_ensambleParameter, "EnsambleParameter", QString(""), "Ensamble Parameter", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_plotAxis, "PlotAxis", "Axis", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); m_legendConfig = new RimRegularLegendConfig(); } @@ -177,6 +182,10 @@ void RimEnsambleCurveSet::setColor(cvf::Color3f color) //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) { + m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText()); + + m_yValuesSummaryFilter->updateFromAddress(m_yValuesCurveVariable->address()); + for (RimSummaryCurve* curve : m_curves) { curve->loadDataAndUpdate(false); @@ -451,46 +460,26 @@ RimRegularLegendConfig* RimEnsambleCurveSet::legendConfig() //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType(plot); + CVF_ASSERT(plot); + if (changedField == &m_showCurves) { loadDataAndUpdate(true); } - else if (changedField == &m_yValuesSummaryGroup || changedField == &m_yValuesSelectedVariableDisplayField) + else if (changedField == &m_yValuesUiFilterResultSelection) { - // Update backing field - m_yValuesCurveVariable->setAddress(m_yValuesSelectedVariableDisplayField); - - deleteAllCurves(); + m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection()); - RimSummaryPlot* plot; - firstAncestorOrThisOfType(plot); - if (plot) plot->loadDataAndUpdate(); - - RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); - RifEclipseSummaryAddress addr = m_yValuesSelectedVariableDisplayField(); - if (group && plot && addr.category() != RifEclipseSummaryAddress::SUMMARY_INVALID) - { - for (auto& sumCase : group->allSummaryCases()) - { - RimSummaryCurve* curve = new RimSummaryCurve(); - curve->setSummaryCaseY(sumCase); - curve->setSummaryAddressY(addr); + createNewCurves(); - addCurve(curve); - - curve->updateCurveVisibility(true); - curve->loadDataAndUpdate(true); - } - - RimSummaryPlot* plot; - firstAncestorOrThisOfType(plot); - if (plot && plot->qwtPlot()) - { - plot->qwtPlot()->replot(); - plot->updateAxes(); - } - } - updateCurveColors(); + //RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + //mainPlotWindow->updateSummaryPlotToolBar(); + } + else if (changedField == &m_yValuesSummaryGroup) + { + createNewCurves(); } else if (changedField == &m_ensambleParameter || changedField == &m_color || @@ -498,14 +487,49 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { updateCurveColors(); } -} + else if (changedField == &m_plotAxis) + { + for (RimSummaryCurve* curve : curves()) + { + curve->setLeftOrRightAxisY(m_plotAxis()); + } + updateQwtPlotAxis(); + plot->updateAxes(); + } + else if (changedField == &m_yPushButtonSelectSummaryAddress) + { + //RiuSummaryCurveDefSelectionDialog dlg(nullptr); + //RimSummaryCase* candidateCase = m_yValuesSummaryCase(); + //RifEclipseSummaryAddress candicateAddress = m_yValuesCurveVariable->address(); + + //if (candidateCase == nullptr) + //{ + // candidateCase = m_xValuesSummaryCase(); + //} + + //if (!candicateAddress.isValid()) + //{ + // candicateAddress = m_xValuesCurveVariable->address(); + //} + + //dlg.setCaseAndAddress(candidateCase, candicateAddress); + + //if (dlg.exec() == QDialog::Accepted) + //{ + // auto curveSelection = dlg.curveSelection(); + // if (curveSelection.size() > 0) + // { + // m_yValuesSummaryCase = curveSelection[0].summaryCase(); + // m_yValuesCurveVariable->setAddress(curveSelection[0].summaryAddress()); + + // crossPlotTestForMatchingTimeSteps = true; + // loadAndUpdate = true; + // } + //} + + //m_yPushButtonSelectSummaryAddress = false; + } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::initAfterRead() -{ - m_yValuesSelectedVariableDisplayField = m_yValuesCurveVariable->address(); } //-------------------------------------------------------------------------------------------------- @@ -518,6 +542,7 @@ void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y"); curveDataGroup->add(&m_yValuesSummaryGroup); curveDataGroup->add(&m_yValuesSelectedVariableDisplayField); + curveDataGroup->add(&m_plotAxis); curveDataGroup->add(&m_yPushButtonSelectSummaryAddress); QString curveVarSelectionGroupName = "Vector Selection Filter Y"; @@ -592,12 +617,18 @@ caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimEnsambleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); - if (myAttr && m_currentSummaryCurve.notNull()) + //caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); + //if (myAttr && m_currentSummaryCurve.notNull()) + //{ + // myAttr->currentObject = m_currentSummaryCurve.p(); + //} + + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + if (attrib) { - myAttr->currentObject = m_currentSummaryCurve.p(); + attrib->m_buttonText = "Vector Selection Dialog"; } } @@ -644,25 +675,30 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c } } } + else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) + { + appendOptionItemsForSummaryAddresses(&options, m_yValuesSummaryGroup(), m_yValuesSummaryFilter()); + } else if (fieldNeedingOptions == &m_yValuesSelectedVariableDisplayField) { - RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - std::map allOpts; - if (group) - { - for (auto& sumCase : group->allSummaryCases()) - { - std::map opts; - RimSummaryFilter filter; - getOptionsForSummaryAddresses(&opts, sumCase, &filter); + //RimSummaryCaseCollection* group = m_yValuesSummaryGroup; + //std::map allOpts; - for (auto& opt : opts) allOpts.insert(opt); - } - } + //if (group) + //{ + // for (auto& sumCase : group->allSummaryCases()) + // { + // std::map opts; + // RimSummaryFilter filter; + // getOptionsForSummaryAddresses(&opts, sumCase, &filter); - for (const auto& opt : allOpts) options.push_back(caf::PdmOptionItemInfo(opt.first, QVariant::fromValue(opt.second))); - options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); + // for (auto& opt : opts) allOpts.insert(opt); + // } + //} + + //for (const auto& opt : allOpts) options.push_back(caf::PdmOptionItemInfo(opt.first, QVariant::fromValue(opt.second))); + //options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); } //else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) @@ -699,6 +735,37 @@ void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map* options, + RimSummaryCaseCollection* summaryCaseGroup, + RimSummaryFilter* summaryFilter) +{ + // BEJ + RimSummaryCase* summaryCase = summaryCaseGroup->allSummaryCases().front(); + + if (summaryCase) + { + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + if (reader) + { + const std::vector allAddresses = reader->allResultAddresses(); + + for (auto& address : allAddresses) + { + if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; + + std::string name = address.uiText(); + QString s = QString::fromStdString(name); + options->push_back(caf::PdmOptionItemInfo(s, QVariant::fromValue(address))); + } + } + + options->push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -751,3 +818,54 @@ void RimEnsambleCurveSet::updateCurveColors() firstAncestorOrThisOfType(plot); if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::updateQwtPlotAxis() +{ + for (RimSummaryCurve* curve : curves()) + { + curve->updateQwtPlotAxis(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsambleCurveSet::createNewCurves() +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType(plot); + CVF_ASSERT(plot); + + deleteAllCurves(); + + plot->loadDataAndUpdate(); + + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + RimSummaryAddress* addr = m_yValuesCurveVariable(); + if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) + { + for (auto& sumCase : group->allSummaryCases()) + { + RimSummaryCurve* curve = new RimSummaryCurve(); + curve->setSummaryCaseY(sumCase); + curve->setSummaryAddressY(addr->address()); + + addCurve(curve); + + curve->updateCurveVisibility(true); + curve->loadDataAndUpdate(true); + } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot->qwtPlot()) + { + plot->qwtPlot()->replot(); + plot->updateAxes(); + } + } + updateCurveColors(); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index 44d296c780..74800d2488 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -21,6 +21,8 @@ #include "RifEclipseSummaryAddress.h" +#include "RiaDefines.h" + #include "RimRegularLegendConfig.h" #include "cafPdmFieldCvfColor.h" @@ -83,8 +85,7 @@ class RimEnsambleCurveSet : public caf::PdmObject private: caf::PdmFieldHandle* objectToggleField(); - virtual void defineObjectEditorAttribute(QString uiConfigName, - caf::PdmUiEditorAttribute* attribute) override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; @@ -92,13 +93,18 @@ class RimEnsambleCurveSet : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void initAfterRead() override; static void getOptionsForSummaryAddresses(std::map* options, RimSummaryCase* summaryCase, RimSummaryFilter* summaryFilter); + static void appendOptionItemsForSummaryAddresses(QList* options, + RimSummaryCaseCollection* summaryCaseGroup, + RimSummaryFilter* summaryFilter); + void updateCurveColors(); + void updateQwtPlotAxis(); + void createNewCurves(); private: caf::PdmField m_showCurves; @@ -113,7 +119,7 @@ class RimEnsambleCurveSet : public caf::PdmObject // Y values caf::PdmPtrField m_yValuesSummaryGroup; caf::PdmChildField m_yValuesCurveVariable; - caf::PdmField m_yValuesSelectedVariableDisplayField; + caf::PdmField m_yValuesSelectedVariableDisplayField; caf::PdmChildField m_yValuesSummaryFilter; caf::PdmField m_yValuesUiFilterResultSelection; caf::PdmField m_yPushButtonSelectSummaryAddress; @@ -122,6 +128,8 @@ class RimEnsambleCurveSet : public caf::PdmObject caf::PdmField m_color; caf::PdmField m_ensambleParameter; + caf::PdmField> m_plotAxis; + caf::PdmChildField m_legendConfig; }; From 22d3e59570a232b759a6998dfeb789ffa04247e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 19 Apr 2018 08:29:58 +0200 Subject: [PATCH 0709/1027] #2610 Cleanup RimEnsambleCurveSet class --- .../Summary/RimEnsambleCurveSet.cpp | 317 +----------------- .../Summary/RimEnsambleCurveSet.h | 41 +-- 2 files changed, 32 insertions(+), 326 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 921442c676..36cd5d42a2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -20,25 +20,19 @@ #include "RiaApplication.h" -#include "RiuSummaryCurveDefSelectionDialog.h" - #include "RifReaderEclipseSummary.h" #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" -#include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" -#include "RimSummaryPlotSourceStepping.h" #include "RimSummaryFilter.h" #include "RimSummaryAddress.h" #include "RimEnsambleCurveSetCollection.h" -#include "RiuLineSegmentQwtPlotCurve.h" #include "RiuSummaryQwtPlot.h" -#include "cafPdmUiTreeViewEditor.h" #include "cafPdmUiTreeOrdering.h" #include "cafPdmUiListEditor.h" #include "cafPdmObject.h" @@ -46,9 +40,6 @@ #include "cvfScalarMapperContinuousLinear.h" -#include -#include - namespace caf { @@ -78,29 +69,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); m_showCurves.uiCapability()->setUiHidden(true); - //CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); - //m_ySourceStepping = new RimSummaryPlotSourceStepping; - //m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); - //m_ySourceStepping.uiCapability()->setUiHidden(true); - //m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_ySourceStepping.xmlCapability()->disableIO(); - - //CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); - //m_xSourceStepping = new RimSummaryPlotSourceStepping; - //m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); - //m_xSourceStepping.uiCapability()->setUiHidden(true); - //m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_xSourceStepping.xmlCapability()->disableIO(); - - //CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); - //m_unionSourceStepping = new RimSummaryPlotSourceStepping; - //m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); - //m_unionSourceStepping.uiCapability()->setUiHidden(true); - //m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_unionSourceStepping.xmlCapability()->disableIO(); - // Y Values - CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Group", "", "", ""); m_yValuesSummaryGroup.uiCapability()->setUiTreeChildrenHidden(true); m_yValuesSummaryGroup.uiCapability()->setAutoAddingOptionFromValue(false); @@ -236,22 +205,6 @@ void RimEnsambleCurveSet::detachQwtCurves() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RimEnsambleCurveSet::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const -{ - for (RimSummaryCurve* rimCurve : m_curves) - { - if (rimCurve->qwtPlotCurve() == qwtCurve) - { - return rimCurve; - } - } - - return nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -306,31 +259,6 @@ std::vector RimEnsambleCurveSet::visibleCurves() const return visible; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) -{ - std::vector summaryCurvesToDelete; - - for (RimSummaryCurve* summaryCurve : m_curves) - { - if (!summaryCurve) continue; - if (!summaryCurve->summaryCaseY()) continue; - - if (summaryCurve->summaryCaseY() == summaryCase) - { - summaryCurvesToDelete.push_back(summaryCurve); - } - } - for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) - { - m_curves.removeChildObject(summaryCurve); - delete summaryCurve; - } - -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -339,114 +267,6 @@ void RimEnsambleCurveSet::deleteAllCurves() m_curves.deleteAllChildObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::updateCaseNameHasChanged() -{ - for (RimSummaryCurve* curve : m_curves) - { - curve->updateCurveNameNoLegendUpdate(); - curve->updateConnectedEditors(); - } - - RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::setCurrentSummaryCurve(RimSummaryCurve* curve) -{ - m_currentSummaryCurve = curve; - - updateConnectedEditors(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -//std::vector RimEnsambleCurveSet::fieldsToShowInToolbar() -//{ -// RimSummaryCrossPlot* parentCrossPlot; -// firstAncestorOrThisOfType(parentCrossPlot); -// -// if (parentCrossPlot) -// { -// return m_unionSourceStepping->fieldsToShowInToolbar(); -// } -// -// return m_ySourceStepping()->fieldsToShowInToolbar(); -//} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::handleKeyPressEvent(QKeyEvent* keyEvent) -{ - //if (!keyEvent) return; - - //RimSummaryPlotSourceStepping* sourceStepping = nullptr; - //{ - // RimSummaryCrossPlot* summaryCrossPlot = nullptr; - // this->firstAncestorOrThisOfType(summaryCrossPlot); - - // if (summaryCrossPlot) - // { - // sourceStepping = m_unionSourceStepping(); - // } - // else - // { - // sourceStepping = m_ySourceStepping(); - // } - //} - - //if (keyEvent->key() == Qt::Key_PageUp) - //{ - // if (keyEvent->modifiers() & Qt::ShiftModifier) - // { - // sourceStepping->applyPrevCase(); - - // keyEvent->accept(); - // } - // else if (keyEvent->modifiers() & Qt::ControlModifier) - // { - // sourceStepping->applyPrevOtherIdentifier(); - - // keyEvent->accept(); - // } - // else - // { - // sourceStepping->applyPrevQuantity(); - - // keyEvent->accept(); - // } - //} - //else if (keyEvent->key() == Qt::Key_PageDown) - //{ - // if (keyEvent->modifiers() & Qt::ShiftModifier) - // { - // sourceStepping->applyNextCase(); - - // keyEvent->accept(); - // } - // else if (keyEvent->modifiers() & Qt::ControlModifier) - // { - // sourceStepping->applyNextOtherIdentifier(); - - // keyEvent->accept(); - // } - // else - // { - // sourceStepping->applyNextQuantity(); - - // keyEvent->accept(); - // } - //} -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -472,14 +292,11 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection()); - createNewCurves(); - - //RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - //mainPlotWindow->updateSummaryPlotToolBar(); + updateAllCurves(); } else if (changedField == &m_yValuesSummaryGroup) { - createNewCurves(); + updateAllCurves(); } else if (changedField == &m_ensambleParameter || changedField == &m_color || @@ -498,38 +315,7 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } else if (changedField == &m_yPushButtonSelectSummaryAddress) { - //RiuSummaryCurveDefSelectionDialog dlg(nullptr); - //RimSummaryCase* candidateCase = m_yValuesSummaryCase(); - //RifEclipseSummaryAddress candicateAddress = m_yValuesCurveVariable->address(); - - //if (candidateCase == nullptr) - //{ - // candidateCase = m_xValuesSummaryCase(); - //} - - //if (!candicateAddress.isValid()) - //{ - // candicateAddress = m_xValuesCurveVariable->address(); - //} - - //dlg.setCaseAndAddress(candidateCase, candicateAddress); - - //if (dlg.exec() == QDialog::Accepted) - //{ - // auto curveSelection = dlg.curveSelection(); - // if (curveSelection.size() > 0) - // { - // m_yValuesSummaryCase = curveSelection[0].summaryCase(); - // m_yValuesCurveVariable->setAddress(curveSelection[0].summaryAddress()); - - // crossPlotTestForMatchingTimeSteps = true; - // loadAndUpdate = true; - // } - //} - - //m_yPushButtonSelectSummaryAddress = false; } - } //-------------------------------------------------------------------------------------------------- @@ -565,36 +351,6 @@ void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder colorsGroup->add(&m_ensambleParameter); } uiOrdering.skipRemainingFields(true); - - //RimSummaryCrossPlot* parentCrossPlot; - //firstAncestorOrThisOfType(parentCrossPlot); - - //if (parentCrossPlot) - //{ - // { - // auto group = uiOrdering.addNewGroup("Y Source Stepping"); - - // m_ySourceStepping()->uiOrdering(uiConfigName, *group); - // } - - // { - // auto group = uiOrdering.addNewGroup("X Source Stepping"); - - // m_xSourceStepping()->uiOrdering(uiConfigName, *group); - // } - - // { - // auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); - - // m_unionSourceStepping()->uiOrdering(uiConfigName, *group); - // } - //} - //else - //{ - // auto group = uiOrdering.addNewGroup("Plot Source Stepping"); - - // m_ySourceStepping()->uiOrdering(uiConfigName, *group); - //} } //-------------------------------------------------------------------------------------------------- @@ -619,12 +375,6 @@ caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() //-------------------------------------------------------------------------------------------------- void RimEnsambleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - //caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); - //if (myAttr && m_currentSummaryCurve.notNull()) - //{ - // myAttr->currentObject = m_currentSummaryCurve.p(); - //} - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); if (attrib) { @@ -655,8 +405,6 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c { RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - //options.push_back(caf::PdmOptionItemInfo("None", "")); - if (group) { std::set paramSet; @@ -679,32 +427,6 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c { appendOptionItemsForSummaryAddresses(&options, m_yValuesSummaryGroup(), m_yValuesSummaryFilter()); } - else if (fieldNeedingOptions == &m_yValuesSelectedVariableDisplayField) - { - - //RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - //std::map allOpts; - - //if (group) - //{ - // for (auto& sumCase : group->allSummaryCases()) - // { - // std::map opts; - // RimSummaryFilter filter; - // getOptionsForSummaryAddresses(&opts, sumCase, &filter); - - // for (auto& opt : opts) allOpts.insert(opt); - // } - //} - - //for (const auto& opt : allOpts) options.push_back(caf::PdmOptionItemInfo(opt.first, QVariant::fromValue(opt.second))); - //options.push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); - } - - //else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) - //{ - // appendOptionItemsForSummaryAddresses(&options, m_yValuesSummaryCase(), m_yValuesSummaryFilter()); - //} return options; } @@ -736,34 +458,31 @@ void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map* options, RimSummaryCaseCollection* summaryCaseGroup, RimSummaryFilter* summaryFilter) { - // BEJ - RimSummaryCase* summaryCase = summaryCaseGroup->allSummaryCases().front(); - - if (summaryCase) + std::set allAddresses; + + for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases()) { RifSummaryReaderInterface* reader = summaryCase->summaryReader(); - if (reader) - { - const std::vector allAddresses = reader->allResultAddresses(); - - for (auto& address : allAddresses) - { - if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; + const std::vector addrs = reader ? reader->allResultAddresses() : std::vector(); + allAddresses.insert(addrs.begin(), addrs.end()); + } - std::string name = address.uiText(); - QString s = QString::fromStdString(name); - options->push_back(caf::PdmOptionItemInfo(s, QVariant::fromValue(address))); - } - } + for (auto& address : allAddresses) + { + if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; - options->push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); + std::string name = address.uiText(); + QString s = QString::fromStdString(name); + options->push_back(caf::PdmOptionItemInfo(s, QVariant::fromValue(address))); } + + options->push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); } //-------------------------------------------------------------------------------------------------- @@ -833,7 +552,7 @@ void RimEnsambleCurveSet::updateQwtPlotAxis() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::createNewCurves() +void RimEnsambleCurveSet::updateAllCurves() { RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType(plot); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h index 74800d2488..430e31485c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h @@ -64,23 +64,14 @@ class RimEnsambleCurveSet : public caf::PdmObject void setParentQwtPlotNoReplot(QwtPlot* plot); void detachQwtCurves(); - RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; - void addCurve(RimSummaryCurve* curve); void deleteCurve(RimSummaryCurve* curve); std::vector curves() const; std::vector visibleCurves() const; - void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); void deleteAllCurves(); - void updateCaseNameHasChanged(); - - void setCurrentSummaryCurve(RimSummaryCurve* curve); - //std::vector fieldsToShowInToolbar(); - - void handleKeyPressEvent(QKeyEvent* keyEvent); RimRegularLegendConfig* legendConfig(); private: @@ -104,32 +95,28 @@ class RimEnsambleCurveSet : public caf::PdmObject void updateCurveColors(); void updateQwtPlotAxis(); - void createNewCurves(); + void updateAllCurves(); private: - caf::PdmField m_showCurves; - caf::PdmChildArrayField m_curves; // Convert to PtrField ? - - //caf::PdmChildField m_ySourceStepping; - //caf::PdmChildField m_xSourceStepping; - //caf::PdmChildField m_unionSourceStepping; + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curves; - caf::PdmPointer m_currentSummaryCurve; + caf::PdmPointer m_currentSummaryCurve; // Y values - caf::PdmPtrField m_yValuesSummaryGroup; - caf::PdmChildField m_yValuesCurveVariable; - caf::PdmField m_yValuesSelectedVariableDisplayField; - caf::PdmChildField m_yValuesSummaryFilter; - caf::PdmField m_yValuesUiFilterResultSelection; - caf::PdmField m_yPushButtonSelectSummaryAddress; + caf::PdmPtrField m_yValuesSummaryGroup; + caf::PdmChildField m_yValuesCurveVariable; + caf::PdmField m_yValuesSelectedVariableDisplayField; + caf::PdmChildField m_yValuesSummaryFilter; + caf::PdmField m_yValuesUiFilterResultSelection; + caf::PdmField m_yPushButtonSelectSummaryAddress; - caf::PdmField> m_colorMode; - caf::PdmField m_color; - caf::PdmField m_ensambleParameter; + caf::PdmField> m_colorMode; + caf::PdmField m_color; + caf::PdmField m_ensambleParameter; caf::PdmField> m_plotAxis; - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; }; From cdbfed9f3669ddacfd6dfbdcfe662696c4c3cc19 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 08:01:37 +0200 Subject: [PATCH 0710/1027] Legends : Changed to private functions, added override, other cleanup --- .../ProjectDataModel/RimRegularLegendConfig.h | 14 +++-- .../RimTernaryLegendConfig.cpp | 4 +- .../ProjectDataModel/RimTernaryLegendConfig.h | 51 ++++++++++--------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index ef659695f2..67864eb2f8 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -125,17 +125,15 @@ class RimRegularLegendConfig : public RimLegendConfig const caf::TitledOverlayFrame* titledOverlayFrame() const override; caf::TitledOverlayFrame* titledOverlayFrame() override; -protected: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void initAfterRead(); - virtual caf::PdmFieldHandle* objectToggleField(); +private: + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void initAfterRead() override; + caf::PdmFieldHandle* objectToggleField() override; friend class RimStimPlanLegendConfig; - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); - - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; -private: void updateLegend(); void updateFieldVisibility(); double roundToNumSignificantDigits(double value, double precision); diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 6b5a73c1b2..d58583441e 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaPreferences.h" #include "RimEclipseView.h" #include "RimIntersectionCollection.h" @@ -35,7 +36,6 @@ #include "cvfqtUtils.h" #include -#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig"); @@ -78,7 +78,6 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() ternaryRangeSummary.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); ternaryRangeSummary.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&userDefinedMaxValueSoil, "UserDefinedMaxSoil", 1.0, "Max", "", "Min value of the legend", ""); CAF_PDM_InitField(&userDefinedMinValueSoil, "UserDefinedMinSoil", 0.0, "Min", "", "Max value of the legend", ""); @@ -104,7 +103,6 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() //-------------------------------------------------------------------------------------------------- RimTernaryLegendConfig::~RimTernaryLegendConfig() { - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index b1eea5d12d..cfd124fea2 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -35,8 +35,6 @@ namespace cvf class OverlayItem; } - - //================================================================================================== /// /// @@ -65,32 +63,35 @@ class RimTernaryLegendConfig : public RimLegendConfig RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); - void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); - void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); - void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const; - - void recreateLegend(); - - bool showLegend() const; + void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); + void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); - void setTitle(const QString& title); - - const RivTernaryScalarMapper* scalarMapper() const; - - const caf::TitledOverlayFrame* titledOverlayFrame() const override; - caf::TitledOverlayFrame* titledOverlayFrame() override; - -protected: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); - virtual caf::PdmFieldHandle* objectToggleField(); + void recreateLegend(); + bool showLegend() const; + void setTitle(const QString& title); + const RivTernaryScalarMapper* scalarMapper() const; + const caf::TitledOverlayFrame* titledOverlayFrame() const override; + caf::TitledOverlayFrame* titledOverlayFrame() override; private: - void updateLegend(); - void updateLabelText(); - double roundToNumSignificantDigits(double value, double precision); - + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + caf::PdmFieldHandle* objectToggleField() override; + + void updateLegend(); + void updateLabelText(); + double roundToNumSignificantDigits(double value, double precision); + + void ternaryRanges(double& soilLower, + double& soilUpper, + double& sgasLower, + double& sgasUpper, + double& swatLower, + double& swatUpper) const; + private: caf::PdmField precision; caf::PdmField rangeMode; From dcde9ccf722e3251a2af013294c3beabe49caedc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 08:37:37 +0200 Subject: [PATCH 0711/1027] #2727 Legends : Move enum to RimLegendConfig --- .../ProjectDataModel/RimEclipseFaultColors.cpp | 2 -- ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 11 +++++++++++ ApplicationCode/ProjectDataModel/RimLegendConfig.h | 9 +++++++++ .../ProjectDataModel/RimRegularLegendConfig.cpp | 10 ---------- .../ProjectDataModel/RimRegularLegendConfig.h | 9 --------- .../ProjectDataModel/RimTernaryLegendConfig.cpp | 10 ---------- .../ProjectDataModel/RimTernaryLegendConfig.h | 8 -------- 7 files changed, 20 insertions(+), 39 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index 52afeb264e..4810907227 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -22,8 +22,6 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimRegularLegendConfig.h" -#include "RimTernaryLegendConfig.h" #include "RiuMainWindow.h" diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 644c2e8127..c95c9ab734 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -21,6 +21,17 @@ // NB! Special macro for pure virtual class CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimLegendConfig, "LegendConfig"); +namespace caf { + template<> + void AppEnum::setUp() + { + addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); + addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP, "AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); + addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); + setDefault(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 705dabe2e1..dacedeba67 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -38,6 +38,15 @@ class RimLegendConfig : public caf::PdmObject RimLegendConfig(); virtual ~RimLegendConfig(); + enum RangeModeType + { + AUTOMATIC_ALLTIMESTEPS, + AUTOMATIC_CURRENT_TIMESTEP, + USER_DEFINED + }; + + typedef caf::AppEnum RangeModeEnum; + virtual const caf::TitledOverlayFrame* titledOverlayFrame() const = 0; virtual caf::TitledOverlayFrame* titledOverlayFrame() = 0; }; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 43b47f04d0..a85cba27df 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -54,16 +54,6 @@ CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend"); -namespace caf { - template<> - void AppEnum::setUp() - { - addItem(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); - addItem(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); - addItem(RimRegularLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); - setDefault(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS); - } -} namespace caf { template<> diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 67864eb2f8..8457a2f5e9 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -62,15 +62,6 @@ class RimRegularLegendConfig : public RimLegendConfig caf::PdmField resultVariableName; // Used internally to describe the variable this legend setup is used for - enum RangeModeType - { - AUTOMATIC_ALLTIMESTEPS, - AUTOMATIC_CURRENT_TIMESTEP, - USER_DEFINED - }; - - typedef caf::AppEnum RangeModeEnum; - enum ColorRangesType { NORMAL, diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index d58583441e..bf12807d96 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -40,16 +40,6 @@ CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig"); -namespace caf { - template<> - void AppEnum::setUp() - { - addItem(RimTernaryLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Global range"); - addItem(RimTernaryLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Local range"); - addItem(RimTernaryLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User defined range"); - setDefault(RimTernaryLegendConfig::AUTOMATIC_ALLTIMESTEPS); - } -} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index cfd124fea2..3d651b318d 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -51,14 +51,6 @@ class RimTernaryLegendConfig : public RimLegendConfig TERNARY_SWAT_IDX }; - enum RangeModeType - { - AUTOMATIC_ALLTIMESTEPS, - AUTOMATIC_CURRENT_TIMESTEP, - USER_DEFINED - }; - typedef caf::AppEnum RangeModeEnum; - public: RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); From 02049abe78109df907f91e4f61fcdcbe706fbd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 19 Apr 2018 09:18:09 +0200 Subject: [PATCH 0712/1027] Fix crash and typo and set stat Ensemble index to 1 --- ApplicationCode/Commands/RicImportEnsambleFeature.cpp | 8 ++++---- .../ProjectDataModel/Summary/RimEnsambleCurveSet.cpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp index 0bd4969308..5a90924554 100644 --- a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp @@ -144,13 +144,13 @@ bool RicImportEnsambleFeature::validateEnsambleCases(std::vectorproject(); - int groupCount = (int)project->summaryGroups().size(); + int groupCount = (int)project->summaryGroups().size() + 1; QInputDialog dialog; dialog.setInputMode(QInputDialog::TextInput); - dialog.setWindowTitle("Ensamble Name"); - dialog.setLabelText("Ensamble Name"); - dialog.setTextValue(QString("Ensamble %1").arg(groupCount)); + dialog.setWindowTitle("Ensemble Name"); + dialog.setLabelText("Ensemble Name"); + dialog.setTextValue(QString("Ensemble %1").arg(groupCount)); dialog.resize(300, 50); dialog.exec(); return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString(""); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 36cd5d42a2..5f06a136ed 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -464,6 +464,8 @@ void RimEnsambleCurveSet::appendOptionItemsForSummaryAddresses(QList allAddresses; for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases()) From bc05621812206fec922f2f932fc9cf84e0c51304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 19 Apr 2018 09:24:36 +0200 Subject: [PATCH 0713/1027] Fix assert in Ensemble Curveset destructor --- .../ProjectDataModel/Summary/RimEnsambleCurveSet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 5f06a136ed..676bdbd34f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -121,8 +121,8 @@ RimEnsambleCurveSet::~RimEnsambleCurveSet() m_curves.deleteAllChildObjects(); RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if (parentPlot->qwtPlot()) + firstAncestorOrThisOfType(parentPlot); + if (parentPlot && parentPlot->qwtPlot()) { parentPlot->qwtPlot()->removeEnsambleCurveSetLegend(this); } From b3ee1c1f9b67d6b3002aa1caeb07026398bead4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 19 Apr 2018 12:03:24 +0200 Subject: [PATCH 0714/1027] #2755 Fix import dialog path filter matching --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 98977a879b..653fdb4fb3 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -419,7 +419,9 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName //-------------------------------------------------------------------------------------------------- bool RicFileHierarchyDialog::pathFilterMatch(const QString& pathFilter, const QString& relPath) { - QRegExp regexp(pathFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + QString pattern = pathFilter; + if (relPath.endsWith(SEPARATOR) && !pathFilter.endsWith(SEPARATOR)) pattern += SEPARATOR; + QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); return regexp.exactMatch(relPath); } From 32fb519073c86963b0a9c6dbbf3ef7bae4bf3568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 19 Apr 2018 13:38:07 +0200 Subject: [PATCH 0715/1027] #2754 Fix ensemble import workflow --- .../Commands/RicImportEnsambleFeature.cpp | 1 + .../Commands/RicImportSummaryCasesFeature.cpp | 42 +++++++++++++++---- .../Commands/RicImportSummaryCasesFeature.h | 2 + .../Summary/RimSummaryCaseMainCollection.cpp | 23 +++++++++- .../Summary/RimSummaryCaseMainCollection.h | 2 + 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp index 5a90924554..7def86b367 100644 --- a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsambleFeature.cpp @@ -70,6 +70,7 @@ void RicImportEnsambleFeature::onActionTriggered(bool isChecked) QString ensambleName = askForEnsambleName(); if (ensambleName.isEmpty()) return; + RicImportSummaryCasesFeature::addSummaryCases(cases); RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensambleName); std::vector allCases; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 83b7618672..64c32bafef 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -66,6 +66,8 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); std::vector cases = importSummaryCases("Import Summary Cases"); + addSummaryCases(cases); + for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); std::vector allCases; @@ -90,6 +92,21 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) +{ + std::vector temp; + std::vector* cases = newCases ? newCases : &temp; + if (createSummaryCasesFromFiles(fileNames, cases)) + { + addSummaryCases(*cases); + return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); @@ -101,19 +118,30 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStri RifSummaryCaseRestartSelector fileSelector; std::vector importFileInfos = fileSelector.getFilesToImportFromSummaryFiles(fileNames); - std::vector sumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(importFileInfos); + std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos); + + if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::addSummaryCases(const std::vector cases) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + sumCaseColl->addCases(cases); sumCaseColl->updateAllRequiredEditors(); RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow && !sumCases.empty()) + if (mainPlotWindow && !cases.empty()) { - mainPlotWindow->selectAsCurrentItem(sumCases.back()); + mainPlotWindow->selectAsCurrentItem(cases.back()); mainPlotWindow->updateSummaryPlotToolBar(); } - - if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); - return true; } //-------------------------------------------------------------------------------------------------- @@ -139,6 +167,6 @@ std::vector RicImportSummaryCasesFeature::importSummaryCases(co if (fileNames.isEmpty()) return std::vector(); std::vector newCases; - createAndAddSummaryCasesFromFiles(fileNames, &newCases); + createSummaryCasesFromFiles(fileNames, &newCases); return newCases; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 53e07b3f9d..d99b7cbbb0 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -39,6 +39,8 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature RicImportSummaryCasesFeature() { } static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases = nullptr); + static bool createSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases); + static void addSummaryCases(const std::vector cases); static std::vector importSummaryCases(const QString& dialogTitle); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 9e7be37866..99978b8170 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -170,6 +170,17 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::addCases(const std::vector cases) +{ + for (RimSummaryCase* sumCase : cases) + { + addCase(sumCase); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -298,6 +309,16 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() /// //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) +{ + std::vector newCases = createSummaryCasesFromFileInfos(summaryHeaderFileInfos); + addCases(newCases); + return newCases; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) { RimProject* project = RiaApplication::instance()->project(); @@ -316,7 +337,6 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa { RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); - this->m_cases.push_back(newSumCase); newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); newSumCase->setAssociatedEclipseCase(eclCase); newSumCase->createSummaryReaderInterface(); @@ -328,7 +348,6 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa { RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - this->m_cases.push_back(newSumCase); newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); newSumCase->setSummaryHeaderFileName(fileInfo.fileName); newSumCase->createSummaryReaderInterface(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 736a71e5cd..87d5e5f0cb 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -46,10 +46,12 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void createSummaryCasesFromRelevantEclipseResultCases(); std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; + void addCases(const std::vector cases); void addCase(RimSummaryCase* summaryCase); void removeCase(RimSummaryCase* summaryCase); From 4dc9d1ba8a5fa70fbb64f1a084616a4b9231411d Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 19 Apr 2018 11:26:03 +0200 Subject: [PATCH 0716/1027] 3D Well Log Curve (#2747): Add "Add new curve" command to 3D track and other curves. --- ApplicationCode/Commands/RicWellLogTools.cpp | 33 +++++++++++++++++++ ApplicationCode/Commands/RicWellLogTools.h | 23 +++++++------ .../RicAdd3dWellLogCurveFeature.cpp | 5 +-- .../RicAdd3dWellLogFileCurveFeature.cpp | 4 +-- .../RicAdd3dWellLogRftCurveFeature.cpp | 11 ++++--- .../RimContextCommandBuilder.cpp | 13 ++++++++ 6 files changed, 71 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index 7afa502394..3eaa5e3c8e 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -84,6 +84,26 @@ RimWellPath* RicWellLogTools::selectedWellPath() return selection.size() > 0 ? selection[0] : nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RicWellLogTools::findWellPathFromSelection() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + if (selection.size() > 0) + { + caf::PdmObject* firstSelection = selection[0]; + RimWellPath* wellPath; + firstSelection->firstAncestorOrThisOfType(wellPath); + if (wellPath) + { + return wellPath; + } + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -170,6 +190,19 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile() return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RicWellLogTools::findWellPathWithLogFileFromSelection() +{ + RimWellPath* wellPath = findWellPathFromSelection(); + if (wellPath->wellLogFiles().size() > 0) + { + return wellPath; + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicWellLogTools.h b/ApplicationCode/Commands/RicWellLogTools.h index 1543a821e3..e9f671288c 100644 --- a/ApplicationCode/Commands/RicWellLogTools.h +++ b/ApplicationCode/Commands/RicWellLogTools.h @@ -24,6 +24,7 @@ class RimSimWellInView; class Rim3dView; +class Rim3dWellLogCurveCollection; class RimWellLogExtractionCurve; class RimWellLogFileChannel; class RimWellLogFileCurve; @@ -37,17 +38,19 @@ class RimWellPath; class RicWellLogTools { public: - static RimWellLogTrack* selectedWellLogPlotTrack(); - static RimSimWellInView* selectedSimulationWell(int* branchIndex); - static RimWellPath* selectedWellPath(); - static bool wellHasRftData(const QString& wellName); - static bool isWellPathOrSimWellSelectedInView(); - static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, + static RimWellLogTrack* selectedWellLogPlotTrack(); + static RimSimWellInView* selectedSimulationWell(int* branchIndex); + static RimWellPath* selectedWellPath(); + static RimWellPath* findWellPathFromSelection(); + static bool wellHasRftData(const QString& wellName); + static bool isWellPathOrSimWellSelectedInView(); + static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels); - static RimWellPath* selectedWellPathWithLogFile(); - static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, + static RimWellPath* selectedWellPathWithLogFile(); + static RimWellPath* findWellPathWithLogFileFromSelection(); + static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection); - static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell); - static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack); + static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell); + static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack); }; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp index b1acef8728..af045fc8c4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp @@ -42,7 +42,7 @@ bool RicAdd3dWellLogCurveFeature::isCommandEnabled() RiaApplication::instance()->project()->allCases(cases); if (cases.empty()) return false; - return (RicWellLogTools::selectedWellPath() != nullptr); + return RicWellLogTools::findWellPathFromSelection() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -50,7 +50,8 @@ bool RicAdd3dWellLogCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) { - RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathFromSelection(); + if (!selectedWellPath) return; Rim3dWellLogExtractionCurve* rim3dWellLogExtractionCurve = new Rim3dWellLogExtractionCurve(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp index 2befb1cac1..e0be2d927f 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -41,7 +41,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() RiaApplication::instance()->project()->allCases(cases); if (cases.empty()) return false; - return (RicWellLogTools::selectedWellPathWithLogFile() != nullptr); + return (RicWellLogTools::findWellPathWithLogFileFromSelection() != nullptr); } //-------------------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAdd3dWellLogFileCurveFeature::onActionTriggered(bool isChecked) { - RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPathWithLogFile(); + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFileFromSelection(); if (!selectedWellPath) return; Rim3dWellLogFileCurve* rim3dWellLogFileCurve = new Rim3dWellLogFileCurve(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp index 1f9def91cc..b67f57feef 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp @@ -41,9 +41,12 @@ bool RicAdd3dWellLogRftCurveFeature::isCommandEnabled() RiaApplication::instance()->project()->allCases(cases); if (cases.empty()) return false; - RimWellPath* wellPath = RicWellLogTools::selectedWellPath(); - - return RicWellLogTools::wellHasRftData(wellPath->name()); + RimWellPath* wellPath = RicWellLogTools::findWellPathFromSelection(); + if (wellPath) + { + return RicWellLogTools::wellHasRftData(wellPath->name()); + } + return false; } //-------------------------------------------------------------------------------------------------- @@ -51,7 +54,7 @@ bool RicAdd3dWellLogRftCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAdd3dWellLogRftCurveFeature::onActionTriggered(bool isChecked) { - RimWellPath* selectedWellPath = RicWellLogTools::selectedWellPath(); + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathFromSelection(); if (!selectedWellPath) return; Rim3dWellLogRftCurve* rim3dWellLogRftCurve = new Rim3dWellLogRftCurve(); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 87b3a44eac..414347af88 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -22,6 +22,10 @@ #include "RiaApplication.h" #include "Rim3dOverlayInfoConfig.h" +#include "Rim3dWellLogCurveCollection.h" +#include "Rim3dWellLogExtractionCurve.h" +#include "Rim3dWellLogFileCurve.h" +#include "Rim3dWellLogRftCurve.h" #include "RimCalcScript.h" #include "RimCaseCollection.h" #include "RimCellRangeFilter.h" @@ -291,6 +295,15 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; } + else if (dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem)) + { + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + menuBuilder << "RicAdd3dWellLogRftCurveFeature"; + } else if (dynamic_cast(uiItem)) { menuBuilder << "RicWellPathsImportFileFeature"; From 5d89ad3a6d097db48b5b3c2f7623ae4e82d55c73 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 19 Apr 2018 13:35:11 +0200 Subject: [PATCH 0717/1027] 3D Well Log Curves (#2674): Show what the value axis direction is --- .../Riv3dWellLogGridGeomertyGenerator.cpp | 50 +++++++++-------- .../Riv3dWellLogGridGeomertyGenerator.h | 11 ++-- .../Riv3dWellLogPlanePartMgr.cpp | 20 +++++-- Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp | 54 +++++++++++++++++++ Fwk/AppFwk/CommonCode/cafEffectGenerator.h | 17 ++++++ Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp | 6 +++ Fwk/VizFwk/LibRender/cvfDrawableVectors.h | 1 + 7 files changed, 127 insertions(+), 32 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index 72083bf04a..dba5542126 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -25,12 +25,14 @@ #include "RigWellPathGeometryTools.h" #include "cafDisplayCoordTransform.h" + #include "cvfObject.h" -#include "cvfDrawableGeo.h" #include "cvfPrimitiveSetIndexedUInt.h" - #include "cvfBoundingBox.h" +#include "cvfGeometryBuilderTriangles.h" +#include "cvfArrowGenerator.h" +#include #include //-------------------------------------------------------------------------------------------------- @@ -195,34 +197,38 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* } std::vector vertices; + std::vector arrowVectors; vertices.reserve(interpolatedGridPoints.size()); + arrowVectors.reserve(interpolatedGridPoints.size()); - std::vector indices; - indices.reserve(interpolatedGridPoints.size()); - cvf::uint indexCounter = 0; - // Normal lines. Start from one to avoid drawing at surface edge. + double shaftRelativeRadius = 0.0125f; + double arrowHeadRelativeRadius = shaftRelativeRadius * 3; + double arrowHeadRelativeLength = arrowHeadRelativeRadius * 3; + double totalArrowScaling = 1.0 / (1.0 - arrowHeadRelativeLength); + // Normal lines. Start from one to avoid drawing at surface edge. for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++) { vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter)); - vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); - - indices.push_back(indexCounter++); - indices.push_back(indexCounter++); + arrowVectors.push_back(cvf::Vec3f(interpolatedGridCurveNormals[i] * planeWidth * totalArrowScaling)); } - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); - - cvf::ref normalLinesDrawable = new cvf::DrawableGeo(); - - indexedUInt->setIndices(indexArray.p()); - normalLinesDrawable->addPrimitiveSet(indexedUInt.p()); + m_curveNormalVectors = new cvf::DrawableVectors(); cvf::ref vertexArray = new cvf::Vec3fArray(vertices); - normalLinesDrawable->setVertexArray(vertexArray.p()); - - m_curveNormalLines = normalLinesDrawable; + cvf::ref vectorArray = new cvf::Vec3fArray(arrowVectors); + + // Create the arrow glyph for the vector drawer + cvf::GeometryBuilderTriangles arrowBuilder; + cvf::ArrowGenerator gen; + gen.setShaftRelativeRadius(shaftRelativeRadius); + gen.setHeadRelativeRadius(arrowHeadRelativeRadius); + gen.setHeadRelativeLength(arrowHeadRelativeLength); + gen.setNumSlices(4); + gen.generate(&arrowBuilder); + + m_curveNormalVectors->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); + m_curveNormalVectors->setVectors(vertexArray.p(), vectorArray.p()); } return true; } @@ -237,9 +243,9 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::border() return m_border; } -cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalLines() +cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalVectors() { - return m_curveNormalLines; + return m_curveNormalVectors; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index a0363811e0..36e69aef76 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -20,6 +20,7 @@ #include "cvfBase.h" #include "cvfDrawableGeo.h" +#include "cvfDrawableVectors.h" #include "cvfObject.h" #include "cafPdmPointer.h" @@ -53,13 +54,13 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object cvf::ref background(); cvf::ref border(); - cvf::ref curveNormalLines(); + cvf::ref curveNormalVectors(); private: const RigWellPath* wellPathGeometry() const; private: - caf::PdmPointer m_wellPath; - cvf::ref m_background; - cvf::ref m_border; - cvf::ref m_curveNormalLines; + caf::PdmPointer m_wellPath; + cvf::ref m_background; + cvf::ref m_border; + cvf::ref m_curveNormalVectors; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index c7ab52fda0..8cccfe30d7 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,8 +18,9 @@ #include "Riv3dWellLogPlanePartMgr.h" -#include "RiaColorTables.h" +#include "RiaApplication.h" +#include "RiuViewer.h" #include "Rim3dView.h" #include "Rim3dWellLogCurveCollection.h" #include "RimCase.h" @@ -36,7 +37,9 @@ #include "cvfColor3.h" #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" +#include "cvfOpenGLResourceManager.h" #include "cvfPart.h" +#include "cvfShaderProgram.h" #include @@ -225,9 +228,10 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* bool showGrid = curveCollection->isShowingGrid(); bool showBackground = curveCollection->isShowingBackground(); + cvf::Color3f gridColor(0.4f, 0.4f, 0.4f); caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); - caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); - caf::MeshEffectGenerator curveNormalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); + caf::MeshEffectGenerator gridBorderEffectGen(gridColor); + caf::VectorEffectGenerator curveNormalsEffectGen; backgroundEffectGen.enableLighting(false); bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, @@ -241,7 +245,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* cvf::ref backgroundEffect = backgroundEffectGen.generateCachedEffect(); cvf::ref borderEffect = gridBorderEffectGen.generateCachedEffect(); cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); - + cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); if (showBackground && background.notNull()) { @@ -263,9 +267,15 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalLines(); + cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalVectors(); if (normals.notNull()) { + normals->setSingleColor(gridColor); + if (RiaApplication::instance()->useShaders()) + { + normals->setUniformNames("u_transformationMatrix", "u_color"); + } + cvf::ref part = createPart(normals.p(), curveNormalsEffect.p()); if (part.notNull()) { diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index 38d953b83f..813bf2e423 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -991,4 +991,58 @@ void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) c } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VectorEffectGenerator::VectorEffectGenerator() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool VectorEffectGenerator::isEqual(const EffectGenerator* other) const +{ + const VectorEffectGenerator* otherSurfaceEffect = dynamic_cast(other); + if (otherSurfaceEffect) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +EffectGenerator* VectorEffectGenerator::copy() const +{ + VectorEffectGenerator* effGen = new VectorEffectGenerator; + + return effGen; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void VectorEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const +{ + cvf::ShaderProgramGenerator gen("VectorDrawerShaderProgram", cvf::ShaderSourceProvider::instance()); + gen.addVertexCode(cvf::ShaderSourceRepository::vs_VectorDrawer); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_VectorDrawer); + + cvf::ref shaderProg = gen.generate(); + shaderProg->disableUniformTrackingForUniform("u_transformationMatrix"); + shaderProg->disableUniformTrackingForUniform("u_color"); + + cvf::ref eff = effect; + eff->setShaderProgram(shaderProg.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void VectorEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const {} + } // End namespace caf diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h index 48768cdefc..95875971b8 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h @@ -276,4 +276,21 @@ class TextEffectGenerator : public EffectGenerator }; +//================================================================================================== +// +// VectorEffectGenerator +// +//================================================================================================== +class VectorEffectGenerator : public EffectGenerator +{ +public: + VectorEffectGenerator(); + +protected: + virtual bool isEqual(const EffectGenerator* other) const; + virtual EffectGenerator* copy() const; + + virtual void updateForShaderBasedRendering(cvf::Effect* effect) const; + virtual void updateForFixedFunctionRendering(cvf::Effect* effect) const; +}; } diff --git a/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp b/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp index d07c79291d..a7c191ac1f 100644 --- a/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp +++ b/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp @@ -125,6 +125,12 @@ void DrawableVectors::setSingleColor(Color3f color) } +void DrawableVectors::setUniformNames(String vectorMatrixUniformName, String colorUniformName) +{ + m_vectorMatrixUniformName = vectorMatrixUniformName; + m_colorUniformName = colorUniformName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/LibRender/cvfDrawableVectors.h b/Fwk/VizFwk/LibRender/cvfDrawableVectors.h index 18798b1fce..bdf9f9c901 100644 --- a/Fwk/VizFwk/LibRender/cvfDrawableVectors.h +++ b/Fwk/VizFwk/LibRender/cvfDrawableVectors.h @@ -63,6 +63,7 @@ class DrawableVectors : public Drawable void setGlyph(UShortArray* triangles, Vec3fArray* vertices); void setSingleColor(Color3f color); + void setUniformNames(String vectorMatrixUniformName, String colorUniformName); void setVectors(Vec3fArray* vertexArray, Vec3fArray* vectorArray); void setColors(Color3fArray* vectorColorArray); size_t vectorCount() const; From bf5d95d8732fe885875692e45fc0b56b866cb357 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 19 Apr 2018 13:42:53 +0200 Subject: [PATCH 0718/1027] 3D Well Log Curves (#2672): Max and min value control for each curve. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 32 +++++-- .../Riv3dWellLogCurveGeomertyGenerator.h | 6 +- .../Riv3dWellLogPlanePartMgr.cpp | 2 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 94 +++++++++++++++++++ .../ProjectDataModel/Rim3dWellLogCurve.h | 14 ++- .../Rim3dWellLogFileCurve.cpp | 13 +++ .../ProjectDataModel/Rim3dWellLogFileCurve.h | 5 + .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 13 +++ .../ProjectDataModel/Rim3dWellLogRftCurve.h | 5 + .../RimEclipseResultDefinition.cpp | 1 + 10 files changed, 175 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 4157ee7df9..9d920eebd1 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -48,6 +48,8 @@ cvf::ref const cvf::BoundingBox& wellPathClipBoundingBox, const std::vector& resultValues, const std::vector& resultMds, + double minResultValue, + double maxResultValue, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth) const @@ -57,6 +59,8 @@ cvf::ref createCurveVerticesAndIndices(resultValues, resultMds, + minResultValue, + maxResultValue, planeAngle, planeOffsetFromWellPathCenter, planeWidth, @@ -89,6 +93,8 @@ cvf::ref //-------------------------------------------------------------------------------------------------- void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector& resultValues, const std::vector& resultMds, + double minResultValue, + double maxResultValue, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, @@ -104,6 +110,11 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == resultMds.size()); + if (maxResultValue - minResultValue < 1.0e-6) + { + return; + } + RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); @@ -145,20 +156,27 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); - double maxResult = -HUGE_VAL; - double minResult = HUGE_VAL; + double maxClampedResult = -HUGE_VAL; + double minClampedResult = HUGE_VAL; - for (double result : resultValuesForInterpolatedPoints) + for (double& result : resultValuesForInterpolatedPoints) { if (!RigCurveDataTools::isValidValue(result, false)) continue; - maxResult = std::max(result, maxResult); - minResult = std::min(result, minResult); + result = cvf::Math::clamp(result, minResultValue, maxResultValue); + + maxClampedResult = std::max(result, maxClampedResult); + minClampedResult = std::min(result, minClampedResult); + } + + if (minClampedResult >= maxClampedResult) + { + return; } vertices->resize(interpolatedWellPathPoints.size()); - double plotRangeToResultRangeFactor = planeWidth / (maxResult - minResult); + double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); for (size_t i = 0; i < interpolatedCurveNormals.size(); i++) { @@ -167,7 +185,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false)) { scaledResult = - planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor; + planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minClampedResult) * plotRangeToResultRangeFactor; } (*vertices)[i] = cvf::Vec3f(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index bc4c90a733..eaa2df0404 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -51,10 +51,14 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const std::vector& resultMds, double planeAngle, double planeOffsetFromWellPathCenter, - double planeWidth) const; + double planeWidth, + double minResultValue, + double maxResultValue) const; private: void createCurveVerticesAndIndices(const std::vector& resultValues, const std::vector& resultMds, + double minResultValue, + double maxResultValue, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 8cccfe30d7..33f541ebc9 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -107,6 +107,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* wellPathClipBoundingBox, resultValues, resultMds, + rim3dWellLogCurve->minCurveValue(), + rim3dWellLogCurve->maxCurveValue(), planeAngle(curveCollection, rim3dWellLogCurve), wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), planeWidth()); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index a668a297ac..75b3f2a0a5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -18,9 +18,16 @@ #include "Rim3dWellLogCurve.h" +#include "RigCurveDataTools.h" + #include "Rim3dWellLogCurveCollection.h" #include "RimProject.h" +#include "cafPdmUiDoubleSliderEditor.h" + +#include +#include // Needed for HUGE_VAL on Linux + //================================================================================================== /// /// @@ -45,11 +52,17 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::Rim3dWellLogCurve() + : m_minCurveDataValue(-HUGE_VAL) + , m_maxCurveDataValue(HUGE_VAL) { CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_minCurveValue, "MinCurveValue", -HUGE_VAL, "Minimum Curve Value", "", "Clip curve values below this.", ""); + CAF_PDM_InitField(&m_maxCurveValue, "MaxCurveValue", HUGE_VAL, "Maximum Curve Value", "", "Clip curve values above this.", ""); + m_minCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + m_maxCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); @@ -106,6 +119,22 @@ void Rim3dWellLogCurve::setColor(const cvf::Color3f& color) m_color = color; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Rim3dWellLogCurve::minCurveValue() const +{ + return m_minCurveValue(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Rim3dWellLogCurve::maxCurveValue() const +{ + return m_maxCurveValue(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -147,6 +176,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Configuration"); configurationGroup->add(&m_drawPlane); configurationGroup->add(&m_color); + configurationGroup->add(&m_minCurveValue); + configurationGroup->add(&m_maxCurveValue); } QList Rim3dWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) @@ -177,3 +208,66 @@ QList Rim3dWellLogCurve::calculateValueOptions(const caf } return options; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiDoubleSliderEditorAttribute* sliderAttribute = dynamic_cast(attribute); + if (sliderAttribute) + { + if (m_minCurveDataValue == -HUGE_VAL && + m_maxCurveDataValue == HUGE_VAL) + { + this->resetMinMaxValues(); + } + if (field == &m_minCurveValue) + { + sliderAttribute->m_minimum = m_minCurveDataValue; + sliderAttribute->m_maximum = m_maxCurveDataValue; + } + else if (field == &m_maxCurveValue) + { + sliderAttribute->m_minimum = m_minCurveDataValue; + sliderAttribute->m_maximum = m_maxCurveDataValue; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI() +{ + this->resetMinMaxValues(); + this->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resetMinMaxValues() +{ + std::vector values; + std::vector measuredDepths; + this->curveValuesAndMds(&values, &measuredDepths); + double foundMinValue = HUGE_VAL; + double foundMaxValue = -HUGE_VAL; + for (double value : values) + { + if (RigCurveDataTools::isValidValue(value, false)) + { + foundMinValue = std::min(foundMinValue, value); + foundMaxValue = std::max(foundMaxValue, value); + } + } + + // Update data boundaries + m_minCurveDataValue = foundMinValue; + m_maxCurveDataValue = foundMaxValue; + + // Update selected GUI boundaries + m_minCurveValue = m_minCurveDataValue; + m_maxCurveValue = m_maxCurveDataValue; +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index e12ebe3e2c..2702a3289a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -54,19 +54,29 @@ class Rim3dWellLogCurve : public caf::PdmObject virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; void setColor(const cvf::Color3f& color); + + double minCurveValue() const; + double maxCurveValue() const; + void resetMinMaxValuesAndUpdateUI(); protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* userDescriptionField() override; void configurationUiOrdering(caf::PdmUiOrdering& uiOrdering); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; - + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); +private: + void resetMinMaxValues(); protected: caf::PdmField m_name; caf::PdmField> m_drawPlane; caf::PdmField m_color; - + caf::PdmField m_minCurveValue; + caf::PdmField m_maxCurveValue; + double m_minCurveDataValue; + double m_maxCurveDataValue; private: caf::PdmField m_showCurve; + }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index 7458ca7872..c556075a34 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -96,6 +96,19 @@ void Rim3dWellLogFileCurve::curveValuesAndMds(std::vector* values, std:: } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_wellLogFile || changedField == &m_wellLogChannnelName) + { + this->resetMinMaxValuesAndUpdateUI(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h index b05f2fa4b1..502f9da1bd 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -41,6 +41,11 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve void setDefaultFileCurveDataInfo(); virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) override; + private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index 33c50ce9a3..ef684ba127 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -76,6 +76,19 @@ void Rim3dWellLogRftCurve::curveValuesAndMds(std::vector* values, std::v *measuredDepthValues = curveData->measuredDepths(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_wellLogChannelName) + { + this->resetMinMaxValuesAndUpdateUI(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h index 638c573aa1..286fe072a4 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -44,6 +44,11 @@ class Rim3dWellLogRftCurve : public Rim3dWellLogCurve virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) override; + private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 30e3821ca9..e92be876d5 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -342,6 +342,7 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() this->firstAncestorOrThisOfType(rim3dWellLogCurve); if (rim3dWellLogCurve) { + rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI(); rim3dWellLogCurve->updateConnectedEditors(); } } From 53d5c809ac0c78521e332127d836d243e6198f56 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 19 Apr 2018 13:53:57 +0200 Subject: [PATCH 0719/1027] 3D Well Log Curves (#2764): Rim3dWellLogFileCurve does not react to draw plane changes --- ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp | 1 + ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index c556075a34..a7913612b9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -107,6 +107,7 @@ void Rim3dWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedF { this->resetMinMaxValuesAndUpdateUI(); } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index ef684ba127..3ace215855 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -87,6 +87,7 @@ void Rim3dWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFi { this->resetMinMaxValuesAndUpdateUI(); } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); } //-------------------------------------------------------------------------------------------------- From 2a840bae769869802ad40048d5878e01d2daef69 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 13:12:28 +0200 Subject: [PATCH 0720/1027] System : Use numeric_limits::max instead of INT_MAX --- .../GeoMech/GeoMechDataModel/RigFemFaceComparator.h | 6 +++--- ApplicationCode/ProjectDataModel/Rim3dView.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h index 794f2681a3..baf4a1f97f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h @@ -26,12 +26,12 @@ class RigFemFaceComparator { public: - RigFemFaceComparator() : m_minMainFaceNodeIdx(INT_MAX), m_faceIdxToMinMainFaceNodeIdx(0) {} + RigFemFaceComparator() : m_minMainFaceNodeIdx(std::numeric_limits::max()), m_faceIdxToMinMainFaceNodeIdx(0) {} void setMainFace(const int* elmNodes, const int * localFaceIndices, int faceNodeCount) { m_canonizedMainFaceIdxes.resize(faceNodeCount); - m_minMainFaceNodeIdx = INT_MAX; + m_minMainFaceNodeIdx = std::numeric_limits::max(); m_faceIdxToMinMainFaceNodeIdx = 0; for(int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) @@ -51,7 +51,7 @@ class RigFemFaceComparator if (faceNodeCount != static_cast(m_canonizedMainFaceIdxes.size())) return false; // Find min node index in face - int minNodeIdx = INT_MAX; + int minNodeIdx = std::numeric_limits::max(); int faceIdxToMinNodeIdx = 0; for (int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 95020e7c7d..167ae37887 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -591,7 +591,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const // !! Should be able to specify legal range for number properties if (m_viewer) { - m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); + m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : std::numeric_limits::max()); } } } From fd0228ee013daec13b4d474aeebc14d812cc1873 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 13:20:25 +0200 Subject: [PATCH 0721/1027] System : Use numeric_limits::infinity instead of HUGE_VALF --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 8b28a8cb01..cbd8a8cabb 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1477,7 +1477,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues if (refElement.elementIdx != cvf::UNDEFINED_SIZE_T) { - float shortestDist = HUGE_VALF; + float shortestDist = std::numeric_limits::infinity(); size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; for (size_t nodeIdx : refElement.elementFaceNodeIdxs) @@ -2618,7 +2618,7 @@ void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t const std::vector& nodeCoords = part.nodes().coordinates; refElement->elementIdx = cvf::UNDEFINED_SIZE_T; - refElement->intersectionPointToCurrentNodeDistance = HUGE_VALF; + refElement->intersectionPointToCurrentNodeDistance = std::numeric_limits::infinity(); size_t i, j, k; for (const size_t elemIdx : refElementCandidates) { From 6ff50f3bcabac3f99969f2d227125c86805f7017 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 13:51:23 +0200 Subject: [PATCH 0722/1027] #2762 System : Use infinity() instead of HUGE_VAL (gcc6 fix) --- .../ProjectDataModel/Summary/RimEnsambleCurveSet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp index 676bdbd34f..5f0f73f01a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp @@ -498,15 +498,15 @@ void RimEnsambleCurveSet::updateCurveColors() QString parameterName = m_ensambleParameter(); if (group && !parameterName.isEmpty()) { - double minValue = HUGE_VAL; - double maxValue = -HUGE_VAL; + double minValue = std::numeric_limits::infinity(); + double maxValue = -std::numeric_limits::infinity(); for (RimSummaryCase* rimCase : group->allSummaryCases()) { if (!rimCase->caseRealizationParameters().isNull()) { double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - if (value != HUGE_VAL) + if (value != std::numeric_limits::infinity()) { if (value < minValue) minValue = value; if (value > maxValue) maxValue = value; From e5570441f6f634482a99fbf3c9d6f8a8bb4fb217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 19 Apr 2018 14:00:00 +0200 Subject: [PATCH 0723/1027] #2751 Rename ensamble to ensemble --- .../Commands/CMakeLists_files.cmake | 4 +- .../Commands/RicDeleteItemFeature.cpp | 4 +- ...ature.cpp => RicImportEnsembleFeature.cpp} | 32 +++---- ...leFeature.h => RicImportEnsembleFeature.h} | 6 +- .../CMakeLists_files.cmake | 4 +- ... RicNewSummaryEnsembleCurveSetFeature.cpp} | 22 ++--- ...=> RicNewSummaryEnsembleCurveSetFeature.h} | 2 +- .../RicSummaryCurveCreator.cpp | 14 +-- .../RicSummaryCurveCreator.h | 4 +- .../FileInterface/CMakeLists_files.cmake | 4 +- .../RifCaseRealizationParametersReader.cpp | 6 +- ...er.cpp => RifEnsembleParametersReader.cpp} | 10 +-- ...Reader.h => RifEnsembleParametersReader.h} | 8 +- .../RimContextCommandBuilder.cpp | 12 +-- .../ProjectDataModel/RimPlotCurve.cpp | 8 +- .../Summary/CMakeLists_files.cmake | 8 +- ...leCurveSet.cpp => RimEnsembleCurveSet.cpp} | 90 +++++++++---------- ...sambleCurveSet.h => RimEnsembleCurveSet.h} | 10 +-- ....cpp => RimEnsembleCurveSetCollection.cpp} | 56 ++++++------ ...tion.h => RimEnsembleCurveSetCollection.h} | 18 ++-- .../Summary/RimSummaryPlot.cpp | 36 ++++---- .../ProjectDataModel/Summary/RimSummaryPlot.h | 10 +-- .../UserInterface/RiuMainPlotWindow.cpp | 2 +- .../UserInterface/RiuMainWindow.cpp | 2 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 6 +- .../UserInterface/RiuSummaryQwtPlot.h | 8 +- 26 files changed, 193 insertions(+), 193 deletions(-) rename ApplicationCode/Commands/{RicImportEnsambleFeature.cpp => RicImportEnsembleFeature.cpp} (85%) rename ApplicationCode/Commands/{RicImportEnsambleFeature.h => RicImportEnsembleFeature.h} (89%) rename ApplicationCode/Commands/SummaryPlotCommands/{RicNewSummaryEnsambleCurveSetFeature.cpp => RicNewSummaryEnsembleCurveSetFeature.cpp} (81%) rename ApplicationCode/Commands/SummaryPlotCommands/{RicNewSummaryEnsambleCurveSetFeature.h => RicNewSummaryEnsembleCurveSetFeature.h} (95%) rename ApplicationCode/FileInterface/{RifEnsambleParametersReader.cpp => RifEnsembleParametersReader.cpp} (86%) rename ApplicationCode/FileInterface/{RifEnsambleParametersReader.h => RifEnsembleParametersReader.h} (87%) rename ApplicationCode/ProjectDataModel/Summary/{RimEnsambleCurveSet.cpp => RimEnsembleCurveSet.cpp} (88%) rename ApplicationCode/ProjectDataModel/Summary/{RimEnsambleCurveSet.h => RimEnsembleCurveSet.h} (95%) rename ApplicationCode/ProjectDataModel/Summary/{RimEnsambleCurveSetCollection.cpp => RimEnsembleCurveSetCollection.cpp} (88%) rename ApplicationCode/ProjectDataModel/Summary/{RimEnsambleCurveSetCollection.h => RimEnsembleCurveSetCollection.h} (87%) diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 0498e2eb5f..aff0f66133 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -66,7 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h -${CMAKE_CURRENT_LIST_DIR}/RicImportEnsambleFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.h ) @@ -131,7 +131,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp -${CMAKE_CURRENT_LIST_DIR}/RicImportEnsambleFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.cpp ) diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index df4ac23e09..5f3b678afb 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -25,7 +25,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipseView.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RimFishbonesMultipleSubs.h" #include "RimFormationNames.h" #include "RimFormationNamesCollection.h" @@ -118,7 +118,7 @@ bool isDeletable(caf::PdmUiItem* uiItem) if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; - if (dynamic_cast(uiItem)) return true; + if (dynamic_cast(uiItem)) return true; return false; } diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp similarity index 85% rename from ApplicationCode/Commands/RicImportEnsambleFeature.cpp rename to ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 7def86b367..327596281d 100644 --- a/ApplicationCode/Commands/RicImportEnsambleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicImportEnsambleFeature.h" +#include "RicImportEnsembleFeature.h" #include "RiaApplication.h" #include "RiaPreferences.h" @@ -45,12 +45,12 @@ #include -CAF_CMD_SOURCE_INIT(RicImportEnsambleFeature, "RicImportEnsambleFeature"); +CAF_CMD_SOURCE_INIT(RicImportEnsembleFeature, "RicImportEnsembleFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportEnsambleFeature::isCommandEnabled() +bool RicImportEnsembleFeature::isCommandEnabled() { return true; } @@ -58,20 +58,20 @@ bool RicImportEnsambleFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicImportEnsambleFeature::onActionTriggered(bool isChecked) +void RicImportEnsembleFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); - std::vector cases = RicImportSummaryCasesFeature::importSummaryCases("Import Ensamble"); + std::vector cases = RicImportSummaryCasesFeature::importSummaryCases("Import Ensemble"); if (cases.empty()) return; - validateEnsambleCases(cases); + validateEnsembleCases(cases); - QString ensambleName = askForEnsambleName(); - if (ensambleName.isEmpty()) return; + QString ensembleName = askForEnsembleName(); + if (ensembleName.isEmpty()) return; RicImportSummaryCasesFeature::addSummaryCases(cases); - RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensambleName); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName); std::vector allCases; app->project()->allCases(allCases); @@ -85,18 +85,18 @@ void RicImportEnsambleFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicImportEnsambleFeature::setupActionLook(QAction* actionToSetup) +void RicImportEnsembleFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); - actionToSetup->setText("Import Ensamble"); + actionToSetup->setText("Import Ensemble"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportEnsambleFeature::validateEnsambleCases(std::vector cases) +bool RicImportEnsembleFeature::validateEnsembleCases(std::vector cases) { - // Validate ensamble parameters + // Validate ensemble parameters try { std::hash paramsHasher; @@ -106,7 +106,7 @@ bool RicImportEnsambleFeature::validateEnsambleCases(std::vectorcaseRealizationParameters().isNull() || rimCase->caseRealizationParameters()->parameters().empty()) { - throw QString("The case %1 has no ensamble parameters").arg(rimCase->summaryHeaderFilename()); + throw QString("The case %1 has no ensemble parameters").arg(rimCase->summaryHeaderFilename()); } else { @@ -123,7 +123,7 @@ bool RicImportEnsambleFeature::validateEnsambleCases(std::vectorproject(); int groupCount = (int)project->summaryGroups().size() + 1; diff --git a/ApplicationCode/Commands/RicImportEnsambleFeature.h b/ApplicationCode/Commands/RicImportEnsembleFeature.h similarity index 89% rename from ApplicationCode/Commands/RicImportEnsambleFeature.h rename to ApplicationCode/Commands/RicImportEnsembleFeature.h index c112927f49..197fc57b9a 100644 --- a/ApplicationCode/Commands/RicImportEnsambleFeature.h +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.h @@ -31,7 +31,7 @@ class RimSummaryCase; //================================================================================================== /// //================================================================================================== -class RicImportEnsambleFeature : public caf::CmdFeature +class RicImportEnsembleFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; @@ -41,8 +41,8 @@ class RicImportEnsambleFeature : public caf::CmdFeature virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook( QAction* actionToSetup ) override; - bool validateEnsambleCases(std::vector cases); - QString askForEnsambleName(); + bool validateEnsembleCases(std::vector cases); + QString askForEnsembleName(); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 07a81c1a78..2976bac7f4 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -32,7 +32,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h -${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsambleCurveSetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -68,7 +68,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp -${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsambleCurveSetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp similarity index 81% rename from ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp rename to ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 09a04a3436..c242830c03 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicNewSummaryEnsambleCurveSetFeature.h" +#include "RicNewSummaryEnsembleCurveSetFeature.h" #include "RiaApplication.h" @@ -28,8 +28,8 @@ #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RimEnsambleCurveSet.h" -#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" #include "RiuMainPlotWindow.h" @@ -42,12 +42,12 @@ #include -CAF_CMD_SOURCE_INIT(RicNewSummaryEnsambleCurveSetFeature, "RicNewSummaryEnsambleCurveSetFeature"); +CAF_CMD_SOURCE_INIT(RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembleCurveSetFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewSummaryEnsambleCurveSetFeature::isCommandEnabled() +bool RicNewSummaryEnsembleCurveSetFeature::isCommandEnabled() { return (selectedSummaryPlot()); } @@ -55,7 +55,7 @@ bool RicNewSummaryEnsambleCurveSetFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewSummaryEnsambleCurveSetFeature::onActionTriggered(bool isChecked) +void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) { RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); @@ -63,9 +63,9 @@ void RicNewSummaryEnsambleCurveSetFeature::onActionTriggered(bool isChecked) RimSummaryPlot* plot = selectedSummaryPlot(); if (plot) { - RimEnsambleCurveSet* curveSet = new RimEnsambleCurveSet(); + RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - plot->ensambleCurveSets()->addCurveSet(curveSet); + plot->ensembleCurveSets()->addCurveSet(curveSet); plot->updateConnectedEditors(); RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(curveSet); @@ -78,16 +78,16 @@ void RicNewSummaryEnsambleCurveSetFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewSummaryEnsambleCurveSetFeature::setupActionLook(QAction* actionToSetup) +void RicNewSummaryEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("New Summary Ensamble Curve Set"); + actionToSetup->setText("New Summary Ensemble Curve Set"); actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryPlot* RicNewSummaryEnsambleCurveSetFeature::selectedSummaryPlot() const +RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::selectedSummaryPlot() const { RimSummaryPlot* sumPlot = nullptr; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h similarity index 95% rename from ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h rename to ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h index 89b491e90c..23fd99166f 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsambleCurveSetFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h @@ -27,7 +27,7 @@ class RimSummaryPlot; //================================================================================================== /// //================================================================================================== -class RicNewSummaryEnsambleCurveSetFeature : public caf::CmdFeature +class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; protected: diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 408236e184..c4a0ace6bf 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -40,8 +40,8 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryCalculationCollection.h" -#include "RimEnsambleCurveSetCollection.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSet.h" #include "RiuPlotMainWindowTools.h" #include "RiuSummaryCurveDefSelection.h" @@ -544,10 +544,10 @@ void RicSummaryCurveCreator::updateTargetPlot() // DEBUG //{ - // m_targetPlot->ensambleCurveSets()->deleteAllCurveSets(); + // m_targetPlot->ensembleCurveSets()->deleteAllCurveSets(); - // RimEnsambleCurveSet* curveSet = new RimEnsambleCurveSet(); - // m_targetPlot->ensambleCurveSets()->addCurveSet(curveSet); + // RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); + // m_targetPlot->ensembleCurveSets()->addCurveSet(curveSet); // for (const auto& editedCurve : m_previewPlot->summaryCurves()) // { @@ -555,7 +555,7 @@ void RicSummaryCurveCreator::updateTargetPlot() // { // continue; // } - // copyEnsambleCurveAndAddToPlot(editedCurve, curveSet); + // copyEnsembleCurveAndAddToPlot(editedCurve, curveSet); // } //} @@ -592,7 +592,7 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::copyEnsambleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsambleCurveSet *curveSet, bool forceVisible) +void RicSummaryCurveCreator::copyEnsembleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsembleCurveSet *curveSet, bool forceVisible) { RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index fdbf8309f6..c12ef90a2d 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -41,7 +41,7 @@ class RimSummaryCase; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; -class RimEnsambleCurveSet; +class RimEnsembleCurveSet; //================================================================================================== /// @@ -86,7 +86,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot); void updateTargetPlot(); static void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false); - static void copyEnsambleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsambleCurveSet* curveSet, bool forceVisible = false); + static void copyEnsembleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible = false); void setDefaultCurveSelection(); void resetAllFields(); diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 1879567717..99a41a6bbe 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -39,7 +39,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.h ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h -${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.h +${CMAKE_CURRENT_LIST_DIR}/RifEnsembleParametersReader.h ${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.h ${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.h @@ -85,7 +85,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp -${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEnsembleParametersReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.cpp diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp index c4d77d7b1d..eab4490088 100644 --- a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -94,7 +94,7 @@ void RifCaseRealizationParametersReader::parse() if (cols.size() != 2) { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo)); + throw FileParseException(QString("RifEnsembleParametersReader: Invalid file format in line %1").arg(lineNo)); } QString& name = cols[0]; @@ -102,14 +102,14 @@ void RifCaseRealizationParametersReader::parse() if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); } bool parseOk = true; double value = QLocale::c().toDouble(strValue, &parseOk); if (!parseOk) { - throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo)); + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); } m_parameters->addParameter(name, value); diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp b/ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp similarity index 86% rename from ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp rename to ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp index 34aaa131ec..b91be08d0b 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RifEnsambleParametersReader.h" +#include "RifEnsembleParametersReader.h" #include "RifCaseRealizationParametersReader.h" #include "RifFileParseTools.h" @@ -31,7 +31,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& modelDirectory) +RifEnsembleParametersReader::RifEnsembleParametersReader(const QString& modelDirectory) { m_modelDirectory = modelDirectory; } @@ -39,16 +39,16 @@ RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& modelDir //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEnsambleParametersReader::~RifEnsambleParametersReader() +RifEnsembleParametersReader::~RifEnsembleParametersReader() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -//RifEnsambleParameters RifEnsambleParametersReader::import() +//RifEnsembleParameters RifEnsembleParametersReader::import() //{ -// RifEnsambleParameters parameters; +// RifEnsembleParameters parameters; // // // return ; diff --git a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h b/ApplicationCode/FileInterface/RifEnsembleParametersReader.h similarity index 87% rename from ApplicationCode/FileInterface/RifEnsambleParametersReader.h rename to ApplicationCode/FileInterface/RifEnsembleParametersReader.h index 066bb845fb..67c1f78c8d 100644 --- a/ApplicationCode/FileInterface/RifEnsambleParametersReader.h +++ b/ApplicationCode/FileInterface/RifEnsembleParametersReader.h @@ -32,13 +32,13 @@ class QFile; // // UNDER CONSTRUCTION //================================================================================================== -class RifEnsambleParametersReader +class RifEnsembleParametersReader { public: - RifEnsambleParametersReader(const QString& modelDirectory); - ~RifEnsambleParametersReader(); + RifEnsembleParametersReader(const QString& modelDirectory); + ~RifEnsembleParametersReader(); - //RifEnsambleParameters import(); + //RifEnsembleParameters import(); private: QString m_modelDirectory; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 414347af88..3551959f6c 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -39,7 +39,7 @@ #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" -#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimFaultInView.h" #include "RimFlowCharacteristicsPlot.h" #include "RimFlowDiagSolution.h" @@ -462,27 +462,27 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryCurveFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; } - else if (dynamic_cast(uiItem)) + else if (dynamic_cast(uiItem)) { - menuBuilder << "RicNewSummaryEnsambleCurveSetFeature"; + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; } else if (dynamic_cast(uiItem)) { menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; - menuBuilder << "RicImportEnsambleFeature"; + menuBuilder << "RicImportEnsembleFeature"; } else if (dynamic_cast(uiItem)) { menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; - menuBuilder << "RicImportEnsambleFeature"; + menuBuilder << "RicImportEnsembleFeature"; } else if (dynamic_cast(uiItem)) { menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; - menuBuilder << "RicImportEnsambleFeature"; + menuBuilder << "RicImportEnsembleFeature"; if (!dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 48272a30bb..8cdffdd573 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -19,7 +19,7 @@ #include "RimPlotCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RiuLineSegmentQwtPlotCurve.h" @@ -190,9 +190,9 @@ void RimPlotCurve::updateCurveVisibility(bool updateParentPlot) this->firstAncestorOrThisOfType(summaryCurveCollection); if (summaryCurveCollection) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); - RimEnsambleCurveSet* ensambleCurveSet = nullptr; - firstAncestorOrThisOfType(ensambleCurveSet); - if (ensambleCurveSet) isVisibleInPossibleParent = ensambleCurveSet->isCurvesVisible(); + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); } if (m_showCurve() && m_parentQwtPlot && isVisibleInPossibleParent) diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index 1bc0c3b6af..3dbf1bbceb 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -29,8 +29,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.h ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h -${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSetCollection.h -${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSet.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -63,8 +63,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.cpp ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp -${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSetCollection.cpp -${CMAKE_CURRENT_LIST_DIR}/RimEnsambleCurveSet.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp similarity index 88% rename from ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp rename to ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5f0f73f01a..97b0439d91 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RiaApplication.h" @@ -29,7 +29,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryFilter.h" #include "RimSummaryAddress.h" -#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsembleCurveSetCollection.h" #include "RiuSummaryQwtPlot.h" @@ -44,25 +44,25 @@ namespace caf { template<> - void AppEnum< RimEnsambleCurveSet::ColorMode >::setUp() + void AppEnum< RimEnsembleCurveSet::ColorMode >::setUp() { - addItem(RimEnsambleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); - addItem(RimEnsambleCurveSet::BY_ENSAMBLE_PARAM, "BY_ENSAMBLE_PARAM", "By Ensamble Parameter"); - setDefault(RimEnsambleCurveSet::SINGLE_COLOR); + addItem(RimEnsembleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); + addItem(RimEnsembleCurveSet::BY_ENSEMBLE_PARAM, "BY_ENSEMBLE_PARAM", "By Ensemble Parameter"); + setDefault(RimEnsembleCurveSet::SINGLE_COLOR); } } -CAF_PDM_SOURCE_INIT(RimEnsambleCurveSet, "RimEnsambleCurveSet"); +CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsambleCurveSet::RimEnsambleCurveSet() +RimEnsembleCurveSet::RimEnsembleCurveSet() { - CAF_PDM_InitObject("Ensamble Curve Set", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensemble Curve Set", ":/SummaryCurveFilter16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_curves, "EnsambleCurveSet", "Ensamble Curve Set", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_curves, "EnsembleCurveSet", "Ensemble Curve Set", "", "", ""); m_curves.uiCapability()->setUiHidden(true); m_curves.uiCapability()->setUiTreeChildrenHidden(false); @@ -105,7 +105,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() CAF_PDM_InitField(&m_color, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); - CAF_PDM_InitField(&m_ensambleParameter, "EnsambleParameter", QString(""), "Ensamble Parameter", "", "", ""); + CAF_PDM_InitField(&m_ensembleParameter, "EnsembleParameter", QString(""), "Ensemble Parameter", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_plotAxis, "PlotAxis", "Axis", "", "", ""); @@ -116,7 +116,7 @@ RimEnsambleCurveSet::RimEnsambleCurveSet() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsambleCurveSet::~RimEnsambleCurveSet() +RimEnsembleCurveSet::~RimEnsembleCurveSet() { m_curves.deleteAllChildObjects(); @@ -124,16 +124,16 @@ RimEnsambleCurveSet::~RimEnsambleCurveSet() firstAncestorOrThisOfType(parentPlot); if (parentPlot && parentPlot->qwtPlot()) { - parentPlot->qwtPlot()->removeEnsambleCurveSetLegend(this); + parentPlot->qwtPlot()->removeEnsembleCurveSetLegend(this); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEnsambleCurveSet::isCurvesVisible() +bool RimEnsembleCurveSet::isCurvesVisible() { - RimEnsambleCurveSetCollection* coll = nullptr; + RimEnsembleCurveSetCollection* coll = nullptr; firstAncestorOrThisOfType(coll); return m_showCurves() && (coll ? coll->isCurveSetsVisible() : true); } @@ -141,7 +141,7 @@ bool RimEnsambleCurveSet::isCurvesVisible() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::setColor(cvf::Color3f color) +void RimEnsembleCurveSet::setColor(cvf::Color3f color) { m_color = color; } @@ -149,7 +149,7 @@ void RimEnsambleCurveSet::setColor(cvf::Color3f color) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) +void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) { m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText()); @@ -171,13 +171,13 @@ void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); - if (m_showCurves() && m_colorMode() == BY_ENSAMBLE_PARAM) + if (m_showCurves() && m_colorMode() == BY_ENSEMBLE_PARAM) { - parentPlot->qwtPlot()->addOrUpdateEnsambleCurveSetLegend(this); + parentPlot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); } else { - parentPlot->qwtPlot()->removeEnsambleCurveSetLegend(this); + parentPlot->qwtPlot()->removeEnsembleCurveSetLegend(this); } } } @@ -186,7 +186,7 @@ void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) +void RimEnsembleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) { for (RimSummaryCurve* curve : m_curves) { @@ -197,7 +197,7 @@ void RimEnsambleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::detachQwtCurves() +void RimEnsembleCurveSet::detachQwtCurves() { for (RimSummaryCurve* curve : m_curves) { @@ -208,7 +208,7 @@ void RimEnsambleCurveSet::detachQwtCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::addCurve(RimSummaryCurve* curve) +void RimEnsembleCurveSet::addCurve(RimSummaryCurve* curve) { if (curve) { @@ -224,7 +224,7 @@ void RimEnsambleCurveSet::addCurve(RimSummaryCurve* curve) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::deleteCurve(RimSummaryCurve* curve) +void RimEnsembleCurveSet::deleteCurve(RimSummaryCurve* curve) { if (curve) { @@ -236,7 +236,7 @@ void RimEnsambleCurveSet::deleteCurve(RimSummaryCurve* curve) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSet::curves() const +std::vector RimEnsembleCurveSet::curves() const { return m_curves.childObjects(); } @@ -244,7 +244,7 @@ std::vector RimEnsambleCurveSet::curves() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSet::visibleCurves() const +std::vector RimEnsembleCurveSet::visibleCurves() const { std::vector visible; @@ -262,7 +262,7 @@ std::vector RimEnsambleCurveSet::visibleCurves() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::deleteAllCurves() +void RimEnsembleCurveSet::deleteAllCurves() { m_curves.deleteAllChildObjects(); } @@ -270,7 +270,7 @@ void RimEnsambleCurveSet::deleteAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimRegularLegendConfig* RimEnsambleCurveSet::legendConfig() +RimRegularLegendConfig* RimEnsembleCurveSet::legendConfig() { return m_legendConfig; } @@ -278,7 +278,7 @@ RimRegularLegendConfig* RimEnsambleCurveSet::legendConfig() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType(plot); @@ -298,7 +298,7 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { updateAllCurves(); } - else if (changedField == &m_ensambleParameter || + else if (changedField == &m_ensembleParameter || changedField == &m_color || changedField == &m_colorMode) { @@ -321,7 +321,7 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { { QString curveDataGroupName = "Summary Vector"; @@ -346,9 +346,9 @@ void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder { colorsGroup->add(&m_color); } - else if (m_colorMode == BY_ENSAMBLE_PARAM) + else if (m_colorMode == BY_ENSEMBLE_PARAM) { - colorsGroup->add(&m_ensambleParameter); + colorsGroup->add(&m_ensembleParameter); } uiOrdering.skipRemainingFields(true); } @@ -356,7 +356,7 @@ void RimEnsambleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +void RimEnsembleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { uiTreeOrdering.add(m_legendConfig()); uiTreeOrdering.skipRemainingChildren(true); @@ -365,7 +365,7 @@ void RimEnsambleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() +caf::PdmFieldHandle* RimEnsembleCurveSet::objectToggleField() { return &m_showCurves; } @@ -373,7 +373,7 @@ caf::PdmFieldHandle* RimEnsambleCurveSet::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimEnsembleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); if (attrib) @@ -385,7 +385,7 @@ void RimEnsambleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimEnsambleCurveSet::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RimEnsembleCurveSet::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { QList options; @@ -401,7 +401,7 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c options.push_front(caf::PdmOptionItemInfo("None", nullptr)); } - else if (fieldNeedingOptions == &m_ensambleParameter) + else if (fieldNeedingOptions == &m_ensembleParameter) { RimSummaryCaseCollection* group = m_yValuesSummaryGroup; @@ -434,7 +434,7 @@ QList RimEnsambleCurveSet::calculateValueOptions(const c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map* options, +void RimEnsembleCurveSet::getOptionsForSummaryAddresses(std::map* options, RimSummaryCase* summaryCase, RimSummaryFilter* summaryFilter) { @@ -460,7 +460,7 @@ void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map* options, +void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses(QList* options, RimSummaryCaseCollection* summaryCaseGroup, RimSummaryFilter* summaryFilter) { @@ -490,12 +490,12 @@ void RimEnsambleCurveSet::appendOptionItemsForSummaryAddresses(QList::infinity(); @@ -543,7 +543,7 @@ void RimEnsambleCurveSet::updateCurveColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::updateQwtPlotAxis() +void RimEnsembleCurveSet::updateQwtPlotAxis() { for (RimSummaryCurve* curve : curves()) { @@ -554,7 +554,7 @@ void RimEnsambleCurveSet::updateQwtPlotAxis() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSet::updateAllCurves() +void RimEnsembleCurveSet::updateAllCurves() { RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType(plot); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h similarity index 95% rename from ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h rename to ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 430e31485c..97e7bbbc9f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -47,15 +47,15 @@ class QKeyEvent; //================================================================================================== /// //================================================================================================== -class RimEnsambleCurveSet : public caf::PdmObject +class RimEnsembleCurveSet : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - enum ColorMode {SINGLE_COLOR, BY_ENSAMBLE_PARAM}; + enum ColorMode {SINGLE_COLOR, BY_ENSEMBLE_PARAM}; - RimEnsambleCurveSet(); - virtual ~RimEnsambleCurveSet(); + RimEnsembleCurveSet(); + virtual ~RimEnsembleCurveSet(); bool isCurvesVisible(); void setColor(cvf::Color3f color); @@ -113,7 +113,7 @@ class RimEnsambleCurveSet : public caf::PdmObject caf::PdmField> m_colorMode; caf::PdmField m_color; - caf::PdmField m_ensambleParameter; + caf::PdmField m_ensembleParameter; caf::PdmField> m_plotAxis; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp similarity index 88% rename from ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp rename to ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index d05b104da9..4570e1b3fe 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsembleCurveSetCollection.h" #include "RiaApplication.h" #include "RiaColorTables.h" @@ -24,7 +24,7 @@ #include "RifReaderEclipseSummary.h" #include "RimProject.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RimSummaryCase.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" @@ -39,16 +39,16 @@ #include -CAF_PDM_SOURCE_INIT(RimEnsambleCurveSetCollection, "RimEnsambleCurveSetCollection"); +CAF_PDM_SOURCE_INIT(RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsambleCurveSetCollection::RimEnsambleCurveSetCollection() +RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() { - CAF_PDM_InitObject("Ensamble Curve Sets", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensemble Curve Sets", ":/SummaryCurveFilter16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_curveSets, "EnsambleCurveSets", "Ensamble Curve Sets", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets", "", "", ""); m_curveSets.uiCapability()->setUiHidden(true); m_curveSets.uiCapability()->setUiTreeChildrenHidden(false); @@ -80,7 +80,7 @@ RimEnsambleCurveSetCollection::RimEnsambleCurveSetCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsambleCurveSetCollection::~RimEnsambleCurveSetCollection() +RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() { m_curveSets.deleteAllChildObjects(); } @@ -88,7 +88,7 @@ RimEnsambleCurveSetCollection::~RimEnsambleCurveSetCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimEnsambleCurveSetCollection::isCurveSetsVisible() +bool RimEnsembleCurveSetCollection::isCurveSetsVisible() { return m_showCurves(); } @@ -96,9 +96,9 @@ bool RimEnsambleCurveSetCollection::isCurveSetsVisible() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) +void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) { - for (RimEnsambleCurveSet* curveSet : m_curveSets) + for (RimEnsembleCurveSet* curveSet : m_curveSets) { curveSet->loadDataAndUpdate(updateParentPlot); } @@ -125,9 +125,9 @@ void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) +void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) { - for (RimEnsambleCurveSet* curveSet : m_curveSets) + for (RimEnsembleCurveSet* curveSet : m_curveSets) { curveSet->setParentQwtPlotNoReplot(plot); } @@ -138,7 +138,7 @@ void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::detachQwtCurves() +void RimEnsembleCurveSetCollection::detachQwtCurves() { for(const auto& curveSet : m_curveSets) { @@ -149,7 +149,7 @@ void RimEnsambleCurveSetCollection::detachQwtCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::addCurveSet(RimEnsambleCurveSet* curveSet) +void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet) { static int nextAutoColorIndex = 1; static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size(); @@ -166,7 +166,7 @@ void RimEnsambleCurveSetCollection::addCurveSet(RimEnsambleCurveSet* curveSet) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::deleteCurveSet(RimEnsambleCurveSet* curveSet) +void RimEnsembleCurveSetCollection::deleteCurveSet(RimEnsembleCurveSet* curveSet) { if (curveSet) { @@ -178,7 +178,7 @@ void RimEnsambleCurveSetCollection::deleteCurveSet(RimEnsambleCurveSet* curveSet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSetCollection::curveSets() const +std::vector RimEnsembleCurveSetCollection::curveSets() const { return m_curveSets.childObjects(); } @@ -186,9 +186,9 @@ std::vector RimEnsambleCurveSetCollection::curveSets() con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEnsambleCurveSetCollection::visibleCurveSets() const +std::vector RimEnsembleCurveSetCollection::visibleCurveSets() const { - std::vector visible; + std::vector visible; for (auto c : m_curveSets) { @@ -204,7 +204,7 @@ std::vector RimEnsambleCurveSetCollection::visibleCurveSet ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- -//void RimEnsambleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) +//void RimEnsembleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) //{ // std::vector summaryCurvesToDelete; // @@ -229,7 +229,7 @@ std::vector RimEnsambleCurveSetCollection::visibleCurveSet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::deleteAllCurveSets() +void RimEnsembleCurveSetCollection::deleteAllCurveSets() { m_curveSets.deleteAllChildObjects(); } @@ -237,7 +237,7 @@ void RimEnsambleCurveSetCollection::deleteAllCurveSets() ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- -//void RimEnsambleCurveSetCollection::updateCaseNameHasChanged() +//void RimEnsembleCurveSetCollection::updateCaseNameHasChanged() //{ // for (RimSummaryCurve* curve : m_curves) // { @@ -253,7 +253,7 @@ void RimEnsambleCurveSetCollection::deleteAllCurveSets() ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- -//void RimEnsambleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) +//void RimEnsembleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) //{ // m_currentSummaryCurve = curve; // @@ -263,7 +263,7 @@ void RimEnsambleCurveSetCollection::deleteAllCurveSets() ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- -//std::vector RimEnsambleCurveSetCollection::fieldsToShowInToolbar() +//std::vector RimEnsembleCurveSetCollection::fieldsToShowInToolbar() //{ // RimSummaryCrossPlot* parentCrossPlot; // firstAncestorOrThisOfType(parentCrossPlot); @@ -279,7 +279,7 @@ void RimEnsambleCurveSetCollection::deleteAllCurveSets() ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- -//void RimEnsambleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) +//void RimEnsembleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) //{ // if (!keyEvent) return; // @@ -345,7 +345,7 @@ void RimEnsambleCurveSetCollection::deleteAllCurveSets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &m_showCurves) { @@ -356,7 +356,7 @@ void RimEnsambleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEnsembleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { //RimSummaryCrossPlot* parentCrossPlot; //firstAncestorOrThisOfType(parentCrossPlot); @@ -392,7 +392,7 @@ void RimEnsambleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimEnsambleCurveSetCollection::objectToggleField() +caf::PdmFieldHandle* RimEnsembleCurveSetCollection::objectToggleField() { return &m_showCurves; } @@ -400,7 +400,7 @@ caf::PdmFieldHandle* RimEnsambleCurveSetCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsambleCurveSetCollection::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimEnsembleCurveSetCollection::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { //caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); //if (myAttr && m_currentSummaryCurve.notNull()) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h similarity index 87% rename from ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h rename to ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 6eb4e22955..f28887d781 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsambleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -26,19 +26,19 @@ #include "cafPdmPtrArrayField.h" class RimSummaryCase; -class RimEnsambleCurveSet; +class RimEnsembleCurveSet; class QwtPlot; //================================================================================================== /// //================================================================================================== -class RimEnsambleCurveSetCollection : public caf::PdmObject +class RimEnsembleCurveSetCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimEnsambleCurveSetCollection(); - virtual ~RimEnsambleCurveSetCollection(); + RimEnsembleCurveSetCollection(); + virtual ~RimEnsembleCurveSetCollection(); bool isCurveSetsVisible(); @@ -48,11 +48,11 @@ class RimEnsambleCurveSetCollection : public caf::PdmObject //RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; - void addCurveSet(RimEnsambleCurveSet* curveSet); - void deleteCurveSet(RimEnsambleCurveSet* curveSet); + void addCurveSet(RimEnsembleCurveSet* curveSet); + void deleteCurveSet(RimEnsembleCurveSet* curveSet); - std::vector curveSets() const; - std::vector visibleCurveSets() const; + std::vector curveSets() const; + std::vector visibleCurveSets() const; //void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); void deleteAllCurveSets(); @@ -76,7 +76,7 @@ class RimEnsambleCurveSetCollection : public caf::PdmObject private: caf::PdmField m_showCurves; - caf::PdmChildArrayField m_curveSets; + caf::PdmChildArrayField m_curveSets; //caf::PdmPointer m_currentSummaryCurve; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 812e789d18..316346b3f2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -22,14 +22,14 @@ #include "RiaSummaryCurveAnalyzer.h" #include "RimAsciiDataCurve.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RimGridTimeHistoryCurve.h" #include "RimProject.h" #include "RimSummaryAxisProperties.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" -#include "RimEnsambleCurveSetCollection.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryCurvesCalculator.h" #include "RimSummaryPlotCollection.h" @@ -85,9 +85,9 @@ RimSummaryPlot::RimSummaryPlot() m_summaryCurveCollection.uiCapability()->setUiTreeHidden(true); m_summaryCurveCollection = new RimSummaryCurveCollection; - CAF_PDM_InitFieldNoDefault(&m_ensambleCurveSetCollection, "EnsambleCurveSetCollection", "", "", "", ""); - m_ensambleCurveSetCollection.uiCapability()->setUiTreeHidden(true); - m_ensambleCurveSetCollection = new RimEnsambleCurveSetCollection(); + CAF_PDM_InitFieldNoDefault(&m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "", "", "", ""); + m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden(true); + m_ensembleCurveSetCollection = new RimEnsembleCurveSetCollection(); CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden(true); @@ -139,7 +139,7 @@ RimSummaryPlot::~RimSummaryPlot() m_summaryCurves_OBSOLETE.deleteAllChildObjects(); m_curveFilters_OBSOLETE.deleteAllChildObjects(); delete m_summaryCurveCollection; - delete m_ensambleCurveSetCollection; + delete m_ensembleCurveSetCollection; } //-------------------------------------------------------------------------------------------------- @@ -672,9 +672,9 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis(RiaDef } } - if (m_ensambleCurveSetCollection && m_ensambleCurveSetCollection->isCurveSetsVisible()) + if (m_ensembleCurveSetCollection && m_ensembleCurveSetCollection->isCurveSetsVisible()) { - for (RimEnsambleCurveSet* curveSet : m_ensambleCurveSetCollection->curveSets()) + for (RimEnsembleCurveSet* curveSet : m_ensembleCurveSetCollection->curveSets()) { for (RimSummaryCurve* curve : curveSet->curves()) { @@ -961,13 +961,13 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -//void RimSummaryPlot::addEnsambleCurve(const RimEnsambleCurveSet* curveSet, RimSummaryCurve* curve) +//void RimSummaryPlot::addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve) //{ // if (curveSet && curve) // { -// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensambleCurveSetCollection->curveSets().size())); +// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensembleCurveSetCollection->curveSets().size())); // -// const_cast(curveSet)->addCurve(curve); +// const_cast(curveSet)->addCurve(curve); // curve->setParentQwtPlotAndReplot(m_qwtPlot); // } //} @@ -1000,9 +1000,9 @@ void RimSummaryPlot::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsambleCurveSetCollection* RimSummaryPlot::ensambleCurveSets() const +RimEnsembleCurveSetCollection* RimSummaryPlot::ensembleCurveSets() const { - return m_ensambleCurveSetCollection; + return m_ensembleCurveSetCollection; } //-------------------------------------------------------------------------------------------------- @@ -1162,7 +1162,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(&m_summaryCurveCollection); if (!m_isCrossPlot) { - uiTreeOrdering.add(&m_ensambleCurveSetCollection); + uiTreeOrdering.add(&m_ensembleCurveSetCollection); } uiTreeOrdering.add(&m_gridTimeHistoryCurves); uiTreeOrdering.add(&m_asciiDataCurves); @@ -1184,7 +1184,7 @@ void RimSummaryPlot::onLoadDataAndUpdate() m_summaryCurveCollection->loadDataAndUpdate(false); } - m_ensambleCurveSetCollection->loadDataAndUpdate(false); + m_ensembleCurveSetCollection->loadDataAndUpdate(false); for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { @@ -1358,9 +1358,9 @@ QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent) m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); } - if (m_ensambleCurveSetCollection) + if (m_ensembleCurveSetCollection) { - m_ensambleCurveSetCollection->setParentQwtPlotAndReplot(m_qwtPlot); + m_ensembleCurveSetCollection->setParentQwtPlotAndReplot(m_qwtPlot); } } @@ -1519,7 +1519,7 @@ void RimSummaryPlot::detachAllCurves() m_summaryCurveCollection->detachQwtCurves(); } - m_ensambleCurveSetCollection->detachQwtCurves(); + m_ensembleCurveSetCollection->detachQwtCurves(); for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 25790ce491..4eb6a2c279 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -38,8 +38,8 @@ class RimGridTimeHistoryCurve; class RimSummaryCase; class RimSummaryCurve; class RimSummaryCurveCollection; -class RimEnsambleCurveSet; -class RimEnsambleCurveSetCollection; +class RimEnsembleCurveSet; +class RimEnsembleCurveSetCollection; class RimSummaryCurveFilter_OBSOLETE; class RimSummaryTimeAxisProperties; class RimSummaryAxisProperties; @@ -71,13 +71,13 @@ class RimSummaryPlot : public RimViewWindow void addCurveAndUpdate(RimSummaryCurve* curve); void addCurveNoUpdate(RimSummaryCurve* curve); - //void addEnsambleCurve(const RimEnsambleCurveSet* curveSet, RimSummaryCurve* curve); + //void addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve); void deleteCurve(RimSummaryCurve* curve); void setCurveCollection(RimSummaryCurveCollection* curveCollection); void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); - RimEnsambleCurveSetCollection* ensambleCurveSets() const; + RimEnsembleCurveSetCollection* ensembleCurveSets() const; void addGridTimeHistoryCurve(RimGridTimeHistoryCurve* curve); @@ -171,7 +171,7 @@ class RimSummaryPlot : public RimViewWindow caf::PdmChildArrayField m_gridTimeHistoryCurves; caf::PdmChildField m_summaryCurveCollection; - caf::PdmChildField m_ensambleCurveSetCollection; + caf::PdmChildField m_ensembleCurveSetCollection; caf::PdmChildArrayField m_asciiDataCurves; diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index fa26dd910a..38d7708928 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -189,7 +189,7 @@ void RiuMainPlotWindow::createMenus() importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEnsambleFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e1b48b3e39..34ce8a2e14 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -381,7 +381,7 @@ void RiuMainWindow::createMenus() #endif importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEnsambleFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 732a0d0832..f6ce7965c8 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -54,7 +54,7 @@ #include "RiuWidgetDragger.h" #include "RiuCvfOverlayItemWidget.h" -#include "RimEnsambleCurveSet.h" +#include "RimEnsembleCurveSet.h" #include "RimRegularLegendConfig.h" #include "cafTitledOverlayFrame.h" @@ -167,7 +167,7 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::addOrUpdateEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor) +void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor) { RiuCvfOverlayItemWidget* overlayWidget = nullptr; @@ -195,7 +195,7 @@ void RiuSummaryQwtPlot::addOrUpdateEnsambleCurveSetLegend(RimEnsambleCurveSet * //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::removeEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor) +void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor) { auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor); if ( it != m_ensembleLegendWidgets.end() ) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 763e1ae044..69f35ecb00 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -37,7 +37,7 @@ class QwtScaleWidget; class RiuCvfOverlayItemWidget; class RimSummaryPlot; -class RimEnsambleCurveSet; +class RimEnsembleCurveSet; //================================================================================================== // @@ -65,8 +65,8 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow const QwtInterval& rightAxis, const QwtInterval& timeAxis); - void addOrUpdateEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor); - void removeEnsambleCurveSetLegend(RimEnsambleCurveSet * curveSetToShowLegendFor); + void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor); + void removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor); static void setCommonPlotBehaviour(QwtPlot* plot); static void enableDateBasedBottomXAxis(QwtPlot* plot); @@ -93,7 +93,7 @@ private slots: QPointer m_zoomerLeft; QPointer m_zoomerRight; - std::map< caf::PdmPointer, QPointer > m_ensembleLegendWidgets; + std::map< caf::PdmPointer, QPointer > m_ensembleLegendWidgets; }; From d5bdd1f7a1be6ca518c3723a79867dcaa57c494e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 14:55:14 +0200 Subject: [PATCH 0724/1027] #2765 Completions : Use max available diameter when combining multiple completions in same cell --- ...ellPathExportCompletionDataFeatureImpl.cpp | 10 +++++---- .../Completions/RigCompletionData.cpp | 21 ++++++++++++------- .../Completions/RigCompletionData.h | 12 +++++++---- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 6f98e92a52..7df2e64d29 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -407,7 +407,6 @@ RigCompletionData RigCompletionData resultCompletion(wellName, cellIndexIJK, firstCompletion.firstOrderingValue()); resultCompletion.setSecondOrderingValue(firstCompletion.secondOrderingValue()); - resultCompletion.setDiameter(firstCompletion.diameter()); bool anyNonDarcyFlowPresent = false; for (const auto& c : completions) @@ -438,7 +437,10 @@ RigCompletionData for (const RigCompletionData& completion : completions) { - if (completion.isMainBore()) + // Use data from the completion with largest diameter + // This is more robust than checking for main bore flag + // See also https://github.com/OPM/ResInsight/issues/2765 + if (completion.diameter() > wellBoreDiameter) { skinfactor = completion.skinFactor(); wellBoreDiameter = completion.diameter(); @@ -487,7 +489,7 @@ RigCompletionData if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) { - resultCompletion.setCombinedValuesExplicitTrans(totalTrans, completionType); + resultCompletion.setCombinedValuesExplicitTrans(totalTrans, skinfactor, wellBoreDiameter, cellDirection, completionType); } else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { @@ -498,7 +500,7 @@ RigCompletionData double wpimult = totalTrans / transmissibilityEclipseCalculation; resultCompletion.setCombinedValuesImplicitTransWPImult( - wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); + wpimult, skinfactor, wellBoreDiameter, cellDirection, completionType); } return resultCompletion; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp index e66bf0b21d..c83f33515d 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp @@ -122,7 +122,7 @@ void RigCompletionData::setSecondOrderingValue(double orderingValue) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCompletionData::setDiameter(double diameter) { @@ -130,7 +130,7 @@ void RigCompletionData::setDiameter(double diameter) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RigCompletionData::setTransmissibility(double transmissibility) { @@ -173,26 +173,33 @@ void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double //================================================================================================== /// //================================================================================================== -void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, CompletionType completionType) +void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, + double skinFactor, + double diameter, + CellDirection celldirection, + CompletionType completionType) { - m_completionType = completionType; m_transmissibility = transmissibility; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = celldirection; + m_completionType = completionType; } //================================================================================================== /// //================================================================================================== void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, double skinFactor, - double wellDiameter, + double diameter, + CellDirection celldirection, CompletionType completionType) { m_wpimult = wpimult; m_direction = celldirection; m_completionType = completionType; m_skinFactor = skinFactor; - m_diameter = wellDiameter; + m_diameter = diameter; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h index 0e6e337366..de8c255c75 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h @@ -92,12 +92,16 @@ class RigCompletionData double diameter, CellDirection direction); - void setCombinedValuesExplicitTrans(double transmissibility, CompletionType completionType); - + void setCombinedValuesExplicitTrans(double transmissibility, + double skinFactor, + double diameter, + CellDirection celldirection, + CompletionType completionType); + void setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, double skinFactor, - double wellDiameter, + double diameter, + CellDirection celldirection, CompletionType completionType); bool isNonDarcyFlow() const; From 39cb9326e410ca79c827e6f2e4eb24f7db0ee395 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 16:13:18 +0200 Subject: [PATCH 0725/1027] #2683 Well CF Visualization: Sim Well pipe color should be gray for closed existing connections --- .../RivSimWellPipesPartMgr.cpp | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 0d9ab92959..5f1f40c04b 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -20,6 +20,7 @@ #include "RivSimWellPipesPartMgr.h" +#include "RiaColorTables.h" #include "RiaExtractionTools.h" #include "RigEclipseWellLogExtractor.h" @@ -355,7 +356,11 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) if (!simWellData->hasWellResult(frameIndex)) return; // Or reset colors or something - const double closed = -0.1, producing = 1.5, water = 2.5, hcInjection = 3.5; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper. + const double defaultState = -0.1; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper. + const double producerState = 1.5; + const double waterInjectorState = 2.5; + const double hcInjectorState = 3.5; + const double closedState = 4.5; std::list::iterator brIt; const RigWellResultFrame& wResFrame = simWellData->wellResultFrame(frameIndex); @@ -366,14 +371,15 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; { cvf::Color3ubArray legendColors; - legendColors.resize(4); + legendColors.resize(5); legendColors[0] = cvf::Color3ub(m_rimWell->wellPipeColor()); legendColors[1] = cvf::Color3::GREEN; legendColors[2] = cvf::Color3::BLUE; legendColors[3] = cvf::Color3::RED; + legendColors[4] = cvf::Color3ub(RiaColorTables::undefinedCellColor()); scalarMapper->setColors(legendColors); - scalarMapper->setRange(0.0, 4.0); - scalarMapper->setLevelCount(4, true); + scalarMapper->setRange(0.0, 5.0); + scalarMapper->setLevelCount(5, true); } caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); @@ -392,7 +398,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { // Initialize well states to "closed" state wellCellStates.clear(); - wellCellStates.resize(brIt->m_cellIds.size(), closed); + wellCellStates.resize(brIt->m_cellIds.size(), defaultState); RimSimWellInViewCollection* wellColl = nullptr; if (m_rimWell) @@ -419,29 +425,33 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) } else { - double cellState = closed; + double cellState = defaultState; if (wResCell->m_isOpen) { switch (wResFrame.m_productionType) { case RigWellResultFrame::PRODUCER: - cellState = producing; + cellState = producerState; break; case RigWellResultFrame::OIL_INJECTOR: - cellState = hcInjection; + cellState = hcInjectorState; break; case RigWellResultFrame::GAS_INJECTOR: - cellState = hcInjection; + cellState = hcInjectorState; break; case RigWellResultFrame::WATER_INJECTOR: - cellState = water; + cellState = waterInjectorState; break; case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE: - cellState = closed; + cellState = defaultState; break; } } + else + { + cellState = closedState; + } wellCellStates[wcIdx] = cellState; } From 7676ba4f203a2c4672241a2c16f07bd803f2680a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 16:20:43 +0200 Subject: [PATCH 0726/1027] #2683 Refactoring : Use range based for and rename --- .../RivSimWellPipesPartMgr.cpp | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 5f1f40c04b..33ca8f2651 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -362,10 +362,8 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) const double hcInjectorState = 3.5; const double closedState = 4.5; - std::list::iterator brIt; const RigWellResultFrame& wResFrame = simWellData->wellResultFrame(frameIndex); - std::vector wellCellStates; // Setup a scalar mapper cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; @@ -394,11 +392,10 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); cvf::ref scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); - for (brIt = m_wellBranches.begin(); brIt != m_wellBranches.end(); ++brIt) + for (auto& wellBranch : m_wellBranches) { - // Initialize well states to "closed" state - wellCellStates.clear(); - wellCellStates.resize(brIt->m_cellIds.size(), defaultState); + std::vector wellCellStates; + wellCellStates.resize(wellBranch.m_cellIds.size(), defaultState); RimSimWellInViewCollection* wellColl = nullptr; if (m_rimWell) @@ -408,7 +405,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) if (wellColl && wellColl->showConnectionStatusColors()) { - const std::vector & cellIds = brIt->m_cellIds; + const std::vector & cellIds = wellBranch.m_cellIds; for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx) { // we need a faster lookup, I guess @@ -419,11 +416,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex); } - if (wResCell == nullptr) - { - // We cant find any state. This well cell is closed. - } - else + if (wResCell) { double cellState = defaultState; @@ -460,37 +453,37 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) // Find or create texture coords array for pipe surface - if (brIt->m_surfaceDrawable.notNull()) + if (wellBranch.m_surfaceDrawable.notNull()) { - cvf::ref surfTexCoords = const_cast(brIt->m_surfaceDrawable->textureCoordArray()); + cvf::ref surfTexCoords = const_cast(wellBranch.m_surfaceDrawable->textureCoordArray()); if (surfTexCoords.isNull()) { surfTexCoords = new cvf::Vec2fArray; } - brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords(surfTexCoords.p(), wellCellStates, scalarMapper.p()); + wellBranch.m_pipeGeomGenerator->pipeSurfaceTextureCoords(surfTexCoords.p(), wellCellStates, scalarMapper.p()); - brIt->m_surfaceDrawable->setTextureCoordArray(surfTexCoords.p()); - brIt->m_largeSurfaceDrawable->setTextureCoordArray(surfTexCoords.p()); + wellBranch.m_surfaceDrawable->setTextureCoordArray(surfTexCoords.p()); + wellBranch.m_largeSurfaceDrawable->setTextureCoordArray(surfTexCoords.p()); if (wResFrame.m_isOpen) { // Use slightly larger geometry for open wells to avoid z-fighting when two wells are located at the same position - brIt->m_surfacePart->setDrawable(brIt->m_largeSurfaceDrawable.p()); + wellBranch.m_surfacePart->setDrawable(wellBranch.m_largeSurfaceDrawable.p()); } else { - brIt->m_surfacePart->setDrawable(brIt->m_surfaceDrawable.p()); + wellBranch.m_surfacePart->setDrawable(wellBranch.m_surfaceDrawable.p()); } - brIt->m_surfacePart->setEffect(scalarMapperSurfaceEffect.p()); + wellBranch.m_surfacePart->setEffect(scalarMapperSurfaceEffect.p()); } // Find or create texture coords array for pipe center line - if (brIt->m_centerLineDrawable.notNull()) + if (wellBranch.m_centerLineDrawable.notNull()) { - cvf::ref lineTexCoords = const_cast(brIt->m_centerLineDrawable->textureCoordArray()); + cvf::ref lineTexCoords = const_cast(wellBranch.m_centerLineDrawable->textureCoordArray()); if (lineTexCoords.isNull()) { @@ -498,15 +491,15 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) } // Calculate new texture coordinates - brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p()); + wellBranch.m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p()); // Set the new texture coordinates - brIt->m_centerLineDrawable->setTextureCoordArray( lineTexCoords.p()); + wellBranch.m_centerLineDrawable->setTextureCoordArray( lineTexCoords.p()); // Set effects - brIt->m_centerLinePart->setEffect(scalarMapperMeshEffect.p()); + wellBranch.m_centerLinePart->setEffect(scalarMapperMeshEffect.p()); } } } From c16c10e774d2bdd9c66263c219f03533e05ced3e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 20:18:15 +0200 Subject: [PATCH 0727/1027] #2683 Well CF Visualization: Show connection factors on closed connections --- ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp | 2 +- ApplicationCode/ProjectDataModel/RimEclipseCase.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 33ca8f2651..1e57b5be6f 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -308,7 +308,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform cvf::Vec3d anchor = displayXf->transformToDisplayCoord(defaultLocationInDomainCoord);; const RigWellResultPoint* wResCell = wResFrame.findResultCell(wellResultPoint.m_gridIndex, wellResultPoint.m_gridCellIndex); - if (wResCell && wResCell->m_isOpen) + if (wResCell->isValid()) { CompletionVizData data(anchor, defaultWellPathDirection, wResCell->connectionFactor(), globalCellIndex); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 3109a37139..0f7397be7a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -408,7 +408,7 @@ const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirt { for (const auto& r : wellResultBranch.m_branchResultPoints) { - if (r.isValid() && r.m_isOpen) + if (r.isValid()) { RigCompletionData compData(wellRes->m_wellName, RigCompletionDataGridCell(r.m_gridCellIndex, rigEclipseCase->mainGrid()), 0); compData.setTransmissibility(r.connectionFactor()); From 7156779e3d6af65327922a4d4c23befb82b69dd6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 20:20:57 +0200 Subject: [PATCH 0728/1027] Rename --- .../RivSimWellPipesPartMgr.cpp | 40 +++++++++---------- .../RivSimWellPipesPartMgr.h | 2 +- .../RivWellConnectionFactorPartMgr.cpp | 14 +++---- .../RivWellConnectionFactorPartMgr.h | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 1e57b5be6f..7a621dd844 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -54,7 +54,7 @@ /// //-------------------------------------------------------------------------------------------------- RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well) - : m_rimWell(well) + : m_simWellInView(well) { } @@ -72,7 +72,7 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr() Rim3dView* RivSimWellPipesPartMgr::viewWithSettings() { Rim3dView* view = nullptr; - if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(view); + if (m_simWellInView) m_simWellInView->firstAncestorOrThisOfType(view); return view; } @@ -86,7 +86,7 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi { if (!viewWithSettings()) return; - if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + if (!m_simWellInView->isWellPipeVisible(frameIndex)) return; buildWellPipeParts(displayXf, false, 0.0, -1, frameIndex); @@ -121,7 +121,7 @@ void RivSimWellPipesPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::Mod { if (!viewWithSettings()) return; - if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + if (!m_simWellInView->isWellPipeVisible(frameIndex)) return; buildWellPipeParts(displayXf, true, flattenedIntersectionExtentLength, branchIndex, frameIndex); @@ -156,10 +156,10 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform m_pipeBranchesCLCoords.clear(); std::vector< std::vector > pipeBranchesCellIds; - m_rimWell->calculateWellPipeStaticCenterLine(m_pipeBranchesCLCoords, pipeBranchesCellIds); + m_simWellInView->calculateWellPipeStaticCenterLine(m_pipeBranchesCLCoords, pipeBranchesCellIds); - double pipeRadius = m_rimWell->pipeRadius(); - int crossSectionVertexCount = m_rimWell->pipeCrossSectionVertexCount(); + double pipeRadius = m_simWellInView->pipeRadius(); + int crossSectionVertexCount = m_simWellInView->pipeCrossSectionVertexCount(); // Take branch selection into account size_t branchIdxStart = 0; @@ -181,7 +181,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform for (size_t brIdx = branchIdxStart; brIdx sourceInfo = new RivSimWellPipeSourceInfo(m_rimWell, brIdx); + cvf::ref sourceInfo = new RivSimWellPipeSourceInfo(m_simWellInView, brIdx); m_wellBranches.push_back(RivPipeBranchData()); RivPipeBranchData& pbd = m_wellBranches.back(); @@ -231,7 +231,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform pbd.m_surfacePart = new cvf::Part(0,"SimWellPipeSurface"); pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWell->wellPipeColor()), caf::PO_1); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_simWellInView->wellPipeColor()), caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); pbd.m_surfacePart->setEffect(eff.p()); @@ -244,7 +244,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform pbd.m_centerLinePart = new cvf::Part(0,"SimWellPipeCenterLine"); pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); - caf::MeshEffectGenerator gen(m_rimWell->wellPipeColor()); + caf::MeshEffectGenerator gen(m_simWellInView->wellPipeColor()); cvf::ref eff = gen.generateCachedEffect(); pbd.m_centerLinePart->setEffect(eff.p()); @@ -261,11 +261,11 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform pbd.m_connectionFactorsPart = nullptr; RimEclipseView* eclipseView = nullptr; - m_rimWell->firstAncestorOrThisOfType(eclipseView); + m_simWellInView->firstAncestorOrThisOfType(eclipseView); if (eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible()) { - RigSimWellData* simWellData = m_rimWell->simWellData(); + RigSimWellData* simWellData = m_simWellInView->simWellData(); if (simWellData && simWellData->hasWellResult(frameIndex)) { @@ -275,11 +275,11 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform RimVirtualPerforationResults* virtualPerforationResult = eclipseView->virtualPerforationResult(); { - auto wellPaths = m_rimWell->wellPipeBranches(); + auto wellPaths = m_simWellInView->wellPipeBranches(); const RigWellPath* wellPath = wellPaths[brIdx]; - RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor(m_rimWell, wellPath); + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor(m_simWellInView, wellPath); if (extractor) { std::vector wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); @@ -331,7 +331,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform cvf::ref part = pbd.m_connectionFactorGeometryGenerator->createSurfacePart(scalarMapper, eclipseView->isLightingDisabled()); if (part.notNull()) { - cvf::ref sourceInfo = new RivSimWellConnectionSourceInfo(m_rimWell, pbd.m_connectionFactorGeometryGenerator.p()); + cvf::ref sourceInfo = new RivSimWellConnectionSourceInfo(m_simWellInView, pbd.m_connectionFactorGeometryGenerator.p()); part->setSourceInfo(sourceInfo.p()); } @@ -349,9 +349,9 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { - if (m_rimWell == nullptr) return; + if (m_simWellInView == nullptr) return; - RigSimWellData* simWellData = m_rimWell->simWellData(); + RigSimWellData* simWellData = m_simWellInView->simWellData(); if (simWellData == nullptr) return; if (!simWellData->hasWellResult(frameIndex)) return; // Or reset colors or something @@ -370,7 +370,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { cvf::Color3ubArray legendColors; legendColors.resize(5); - legendColors[0] = cvf::Color3ub(m_rimWell->wellPipeColor()); + legendColors[0] = cvf::Color3ub(m_simWellInView->wellPipeColor()); legendColors[1] = cvf::Color3::GREEN; legendColors[2] = cvf::Color3::BLUE; legendColors[3] = cvf::Color3::RED; @@ -398,9 +398,9 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) wellCellStates.resize(wellBranch.m_cellIds.size(), defaultState); RimSimWellInViewCollection* wellColl = nullptr; - if (m_rimWell) + if (m_simWellInView) { - m_rimWell->firstAncestorOrThisOfType(wellColl); + m_simWellInView->firstAncestorOrThisOfType(wellColl); } if (wellColl && wellColl->showConnectionStatusColors()) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 465f840131..fbe1a485a1 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -74,7 +74,7 @@ class RivSimWellPipesPartMgr : public cvf::Object int branchIndex, size_t frameIndex); - caf::PdmPointer m_rimWell; + caf::PdmPointer m_simWellInView; struct RivPipeBranchData { diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 5e200e2f86..61af8e2f20 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -50,7 +50,7 @@ //-------------------------------------------------------------------------------------------------- RivWellConnectionFactorPartMgr::RivWellConnectionFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult) - : m_rimWell(well) + : m_rimWellPath(well) , m_virtualPerforationResult(virtualPerforationResult) { } @@ -80,11 +80,11 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); if (!trans) return; - auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex); + auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWellPath, frameIndex); std::vector wellPathCellIntersections; { - RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase); + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWellPath, eclipseCase); if (extractor) { wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); @@ -109,11 +109,11 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode double middleMD = (startMD + endMD) / 2.0; - cvf::Vec3d defaultLocationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + cvf::Vec3d defaultLocationInDomainCoord = m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); cvf::Vec3d p1; cvf::Vec3d p2; - m_rimWell->wellPathGeometry()->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); + m_rimWellPath->wellPathGeometry()->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); cvf::Vec3d defaultWellPathDirection = (p2 - p1).getNormalized(); @@ -151,7 +151,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode { double characteristicCellSize = eclView->ownerCase()->characteristicCellSize(); - double radius = m_rimWell->wellPathRadius(characteristicCellSize) * m_virtualPerforationResult->geometryScaleFactor(); + double radius = m_rimWellPath->wellPathRadius(characteristicCellSize) * m_virtualPerforationResult->geometryScaleFactor(); radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry scale factor is set to 1.0 m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); @@ -160,7 +160,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode cvf::ref part = m_geometryGenerator->createSurfacePart(scalarMapper, eclView->isLightingDisabled()); if (part.notNull()) { - cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p()); + cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWellPath, m_geometryGenerator.p()); part->setSourceInfo(sourceInfo.p()); model->addPart(part.p()); diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h index ac1b5e0f11..659c9093f3 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h @@ -46,7 +46,7 @@ class RivWellConnectionFactorPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); private: - caf::PdmPointer m_rimWell; + caf::PdmPointer m_rimWellPath; caf::PdmPointer m_virtualPerforationResult; cvf::ref m_geometryGenerator; From f365dae014be5ce69d5212d08b37e960bc5a2a3d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 20:29:24 +0200 Subject: [PATCH 0729/1027] #2683 Well CF Visualization: Add missing null pointer test --- ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 7a621dd844..70cb7ed08d 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -308,7 +308,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform cvf::Vec3d anchor = displayXf->transformToDisplayCoord(defaultLocationInDomainCoord);; const RigWellResultPoint* wResCell = wResFrame.findResultCell(wellResultPoint.m_gridIndex, wellResultPoint.m_gridCellIndex); - if (wResCell->isValid()) + if (wResCell && wResCell->isValid()) { CompletionVizData data(anchor, defaultWellPathDirection, wResCell->connectionFactor(), globalCellIndex); From e6781e2de438eac13f0bba55abec468ee81b9093 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 21:49:01 +0200 Subject: [PATCH 0730/1027] #2683 Well CF Visualization: Refactor computation of connection factor location --- .../RivWellConnectionFactorPartMgr.cpp | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 61af8e2f20..94da1013f4 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -98,10 +98,15 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode const RigCell& rigCell = mainGrid->cell(gridIndex); - std::vector> locationAndDirection; + cvf::Vec3d locationInDomainCoord = rigCell.center(); + cvf::Vec3d direction = cvf::Vec3d::X_AXIS; + bool foundLocation = false; - for (const auto& intersectionInfo : wellPathCellIntersections) + size_t i = 0; + while (!foundLocation && (i < wellPathCellIntersections.size())) { + const WellPathCellIntersectionInfo& intersectionInfo = wellPathCellIntersections[i]; + if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) { double startMD = intersectionInfo.startMD; @@ -109,41 +114,30 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode double middleMD = (startMD + endMD) / 2.0; - cvf::Vec3d defaultLocationInDomainCoord = m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + locationInDomainCoord = m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); cvf::Vec3d p1; cvf::Vec3d p2; - m_rimWellPath->wellPathGeometry()->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); + m_rimWellPath->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); - cvf::Vec3d defaultWellPathDirection = (p2 - p1).getNormalized(); + direction = (p2 - p1).getNormalized(); - locationAndDirection.push_back(std::make_pair(defaultLocationInDomainCoord, defaultWellPathDirection)); - } - else if (!locationAndDirection.empty()) - { - continue; + foundLocation = true; } + + i++; } + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); + for (size_t i = 0; i < cell.second.size(); i++) { const RigCompletionData& completionData = cell.second[i]; double transmissibility = completionData.transmissibility(); - cvf::Vec3d locationInDomainCoord = rigCell.center(); - cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS; - - if (i < locationAndDirection.size()) - { - locationInDomainCoord = locationAndDirection[i].first; - wellPathDirection = locationAndDirection[i].second; - } - - cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); - completionVizDataItems.push_back( - CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex())); + CompletionVizData(displayCoord, direction, transmissibility, cell.first.globalCellIndex())); } } @@ -157,10 +151,12 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); + cvf::ref part = m_geometryGenerator->createSurfacePart(scalarMapper, eclView->isLightingDisabled()); if (part.notNull()) { - cvf::ref sourceInfo = new RivWellConnectionSourceInfo(m_rimWellPath, m_geometryGenerator.p()); + cvf::ref sourceInfo = + new RivWellConnectionSourceInfo(m_rimWellPath, m_geometryGenerator.p()); part->setSourceInfo(sourceInfo.p()); model->addPart(part.p()); From 9e40ba39c8524728a8e3e1c120955e94881110a1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Apr 2018 22:28:22 +0200 Subject: [PATCH 0731/1027] #2684 Well CF Visualization: Option to turn off CF visualization on closed connections --- .../RivSimWellPipesPartMgr.cpp | 40 ++++++++++--------- .../RivWellConnectionFactorPartMgr.cpp | 11 +++++ .../ProjectDataModel/RimEclipseView.cpp | 4 +- .../RimVirtualPerforationResults.cpp | 26 ++++++------ .../RimVirtualPerforationResults.h | 7 ++-- 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 70cb7ed08d..29dfef3c0d 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -287,34 +287,36 @@ void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform for (const auto& intersectionInfo : wellPathCellIntersections) { size_t globalCellIndex = intersectionInfo.globCellIndex; + const RigWellResultPoint* wResCell = wResFrame.findResultCell(0, globalCellIndex); - for (const auto& wellResultPoint : pbd.m_cellIds) + if (!wResCell || !wResCell->isValid()) { - if (wellResultPoint.m_gridCellIndex == globalCellIndex) - { - double startMD = intersectionInfo.startMD; - double endMD = intersectionInfo.endMD; + continue; + } - double middleMD = (startMD + endMD) / 2.0; + if (!virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell->m_isOpen) + { + continue; + } - cvf::Vec3d defaultLocationInDomainCoord = wellPath->interpolatedPointAlongWellPath(middleMD); + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; - cvf::Vec3d p1; - cvf::Vec3d p2; - wellPath->twoClosestPoints(defaultLocationInDomainCoord, &p1, &p2); + double middleMD = (startMD + endMD) / 2.0; - cvf::Vec3d defaultWellPathDirection = (p2 - p1).getNormalized(); + cvf::Vec3d domainCoord = wellPath->interpolatedPointAlongWellPath(middleMD); - cvf::Vec3d anchor = displayXf->transformToDisplayCoord(defaultLocationInDomainCoord);; + cvf::Vec3d p1; + cvf::Vec3d p2; + wellPath->twoClosestPoints(domainCoord, &p1, &p2); - const RigWellResultPoint* wResCell = wResFrame.findResultCell(wellResultPoint.m_gridIndex, wellResultPoint.m_gridCellIndex); - if (wResCell && wResCell->isValid()) - { - CompletionVizData data(anchor, defaultWellPathDirection, wResCell->connectionFactor(), globalCellIndex); + cvf::Vec3d direction = (p2 - p1).getNormalized(); + + cvf::Vec3d anchor = displayXf->transformToDisplayCoord(domainCoord); + { + CompletionVizData data(anchor, direction, wResCell->connectionFactor(), globalCellIndex); - completionVizDataItems.push_back(data); - } - } + completionVizDataItems.push_back(data); } } } diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index 94da1013f4..eb1aa443c5 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -94,6 +94,17 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode std::vector completionVizDataItems; for (const auto& cell : conn) { + if (!m_virtualPerforationResult->showConnectionFactorsOnClosedConnections()) + { + for (const auto& completion : cell.second) + { + if (completion.connectionState() == SHUT) + { + continue; + } + } + } + size_t gridIndex = cell.first.globalCellIndex(); const RigCell& rigCell = mainGrid->cell(gridIndex); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 065882265c..3ed7908914 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1108,7 +1108,7 @@ void RimEclipseView::updateLegends() } } - if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->showLegend()) + if (m_virtualPerforationResult->showConnectionFactors() && m_virtualPerforationResult->legendConfig()->showLegend()) { updateVirtualConnectionLegendRanges(); @@ -1433,7 +1433,7 @@ bool RimEclipseView::isVirtualConnectionFactorGeometryVisible() const { if (!m_showWindow()) return false; - if (!m_virtualPerforationResult->isActive()) return false; + if (!m_virtualPerforationResult->showConnectionFactors()) return false; // TODO: Consider check if no well paths are visible diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index e457b7fd86..64a36202df 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -36,7 +36,8 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() CAF_PDM_InitObject(connectionFactorUiName, ":/CellResult.png", "", ""); CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", false, "", "", "", ""); - CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 1.0, "Geometry Scale Factor", "", "", ""); + CAF_PDM_InitField(&m_showClosedConnections, "ShowClosedConnections", true, "Show On Closed Connections", "", "", ""); + CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 2.0, "Geometry Scale Factor", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); m_legendConfig.uiCapability()->setUiHidden(true); @@ -55,11 +56,19 @@ RimVirtualPerforationResults::~RimVirtualPerforationResults() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimVirtualPerforationResults::isActive() const +bool RimVirtualPerforationResults::showConnectionFactors() const { return m_isActive(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimVirtualPerforationResults::showConnectionFactorsOnClosedConnections() const +{ + return m_showClosedConnections(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -117,24 +126,13 @@ caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() return &m_isActive; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimVirtualPerforationResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) -{ - QList options; - *useOptionsOnly = true; - - return options; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&m_geometryScaleFactor); + uiOrdering.add(&m_showClosedConnections); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h index 9b0ce42896..6f1b6abeb9 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -22,7 +22,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" - #include class RimRegularLegendConfig; @@ -39,21 +38,21 @@ class RimVirtualPerforationResults : public caf::PdmObject RimVirtualPerforationResults(); virtual ~RimVirtualPerforationResults(); - bool isActive() const; + bool showConnectionFactors() const; + bool showConnectionFactorsOnClosedConnections() const; double geometryScaleFactor() const; RimRegularLegendConfig* legendConfig() const; - void loadData(); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* objectToggleField() override; - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; private: caf::PdmField m_isActive; + caf::PdmField m_showClosedConnections; caf::PdmField m_geometryScaleFactor; caf::PdmChildField m_legendConfig; From c3ae45e748d9d968320678ea6970c966361f4dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 08:27:42 +0200 Subject: [PATCH 0732/1027] #2766 Bugfix. Import egrid files even though there are no associated summary files --- .../Tools/RiaImportEclipseCaseTools.cpp | 7 +- .../Commands/RicImportSummaryCasesFeature.cpp | 6 +- .../Commands/RicSummaryCaseRestartDialog.cpp | 42 +++++--- .../Commands/RicSummaryCaseRestartDialog.h | 3 +- .../RifSummaryCaseRestartSelector.cpp | 101 +++++++++++------- .../RifSummaryCaseRestartSelector.h | 23 ++-- 6 files changed, 109 insertions(+), 73 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 8ec09c909e..bbb7fc70f9 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -64,8 +64,11 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file // Get list of files to import RifSummaryCaseRestartSelector selector; if(noDialog) selector.showDialog(false); - selector.buildGridCaseFileList(true); - std::vector summaryFileInfos = selector.getFilesToImportFromGridFiles(fileNames); + std::vector summaryFileInfos; + if (selector.getFilesToImportFromGridFiles(fileNames)) + { + summaryFileInfos = selector.summaryFileInfos(); + } // Import eclipse case files for (const QString& gridCaseFile : selector.gridCaseFiles()) diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 64c32bafef..df4cc293df 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -116,7 +116,11 @@ bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList if (!sumCaseColl) return false; RifSummaryCaseRestartSelector fileSelector; - std::vector importFileInfos = fileSelector.getFilesToImportFromSummaryFiles(fileNames); + std::vector importFileInfos; + if (fileSelector.getFilesToImportFromSummaryFiles(fileNames)) + { + importFileInfos = fileSelector.summaryFileInfos(); + } std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 1b6a0e3b90..7054f82eaf 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -193,17 +193,30 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& summaryHeaderFile, +RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const std::pair& initialFiles, bool showApplyToAllWidget, - bool buildGridCaseFileList, ImportOptions defaultSummaryImportOption, ImportOptions defaultGridImportOption, RicSummaryCaseRestartDialogResult *lastResult, QWidget *parent) { RicSummaryCaseRestartDialog dialog(parent); + QString initialSummaryFile = initialFiles.first; + QString initialGridFile = initialFiles.second; + bool handleGridFile = !initialGridFile.isEmpty(); - RifRestartFileInfo currentFileInfo = dialog.getFileInfo(summaryHeaderFile); + // If only grid file is present, return + if (initialSummaryFile.isEmpty() && !initialGridFile.isEmpty()) + { + return RicSummaryCaseRestartDialogResult(true, + defaultSummaryImportOption, + defaultGridImportOption, + {}, + QStringList({ initialGridFile }), + lastResult && lastResult->applyToAll); + } + + RifRestartFileInfo currentFileInfo = dialog.getFileInfo(initialSummaryFile); if (!currentFileInfo.valid()) { return RicSummaryCaseRestartDialogResult(); @@ -211,13 +224,12 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const RifReaderEclipseSummary reader; bool hasWarnings = false; - std::vector originFileInfos = reader.getRestartFiles(summaryHeaderFile, &hasWarnings); + std::vector originFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); // If no restart files are found and no warnings, do not show dialog if (originFileInfos.empty() &&!hasWarnings) { - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); - return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ summaryHeaderFile }), QStringList({ gridCaseFile }), false); + return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); } RicSummaryCaseRestartDialogResult dialogResult; @@ -238,12 +250,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const std::vector originSummaryFileInfos; std::vector originGridFileInfos; - // Build lists of files - if (buildGridCaseFileList) + // Grid file + if (handleGridFile) { dialog.m_currentFilesGroup->setTitle("Current Grid and Summary Files"); - QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(currentFileInfo.fileName); - currentFileInfos.push_back(RifRestartFileInfo(gridFile, currentFileInfo.startDate, currentFileInfo.endDate)); + currentFileInfos.push_back(RifRestartFileInfo(initialGridFile, currentFileInfo.startDate, currentFileInfo.endDate)); for (const auto& ofi : originFileInfos) { @@ -269,7 +280,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const case ImportOptions::NOT_IMPORT: dialog.m_summaryNotReadBtn->setChecked(true); break; } - if (buildGridCaseFileList) + if (handleGridFile) { switch (defaultGridImportOption) { @@ -312,7 +323,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); } - dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(summaryHeaderFile)); + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(initialSummaryFile)); if (dialogResult.summaryImportOption == SEPARATE_CASES) { for (const auto& ofi : originFileInfos) @@ -321,17 +332,16 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } } - if (buildGridCaseFileList) + if (handleGridFile) { - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile); - dialogResult.gridFiles.push_back(gridCaseFile); + dialogResult.gridFiles.push_back(initialGridFile); if (dialogResult.gridImportOption == SEPARATE_CASES) { for (const auto& ofi : originFileInfos) { QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); - if (buildGridCaseFileList && !gridCaseFile.isEmpty()) dialogResult.gridFiles.push_back(gridFile); + if (handleGridFile) dialogResult.gridFiles.push_back(gridFile); } } } diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 356aeca999..022ae4f6d7 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -52,9 +52,8 @@ class RicSummaryCaseRestartDialog : public QDialog RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); - static RicSummaryCaseRestartDialogResult openDialog(const QString& summaryHeaderFile, + static RicSummaryCaseRestartDialogResult openDialog(const std::pair& initialFiles, bool showApplyToAllWidget, - bool buildGridCaseFileList, ImportOptions defaultSummaryImportOption, ImportOptions defaultGridImportOption, RicSummaryCaseRestartDialogResult *lastResult = nullptr, diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 94909f16ec..9eb4dc6542 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -70,7 +70,7 @@ RifSummaryCaseRestartSelector::RifSummaryCaseRestartSelector() m_defaultSummaryImportMode = mapReadOption(prefs->summaryImportMode()); m_defaultGridImportMode = mapReadOption(prefs->gridImportMode()); - m_buildGridFileList = false; + //m_buildGridFileList = false; m_gridFiles.clear(); } @@ -85,52 +85,58 @@ RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) +bool RifSummaryCaseRestartSelector::getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) { - return getFilesToImport(initialSummaryFiles); + std::vector> files; + for (QString f : initialSummaryFiles) + { + files.push_back(std::make_pair(f, "")); + } + return getFilesToImport(files); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportFromGridFiles(const QStringList& initialGridFiles) +bool RifSummaryCaseRestartSelector::getFilesToImportFromGridFiles(const QStringList& initialGridFiles) { - QStringList summaryFiles = getSummaryFilesFromGridFiles(initialGridFiles); - return getFilesToImport(summaryFiles); + std::vector> files; + for (QString f : initialGridFiles) + { + files.push_back(std::make_pair(getSummaryFileFromGridFile(f), f)); + } + return getFilesToImport(files); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImport(const QStringList& initialSummaryFiles) +bool RifSummaryCaseRestartSelector::getFilesToImport(const std::vector>& initialFiles) { std::vector fileInfos; if (m_showDialog) { - bool enableApplyToAllField = initialSummaryFiles.size() > 1; - fileInfos = getFilesToImportByAskingUser(initialSummaryFiles, enableApplyToAllField); + bool enableApplyToAllField = initialFiles.size() > 1; + return getFilesToImportByAskingUser(initialFiles, enableApplyToAllField); } else { - fileInfos = getFilesToImportUsingPrefs(initialSummaryFiles); + return getFilesToImportUsingPrefs(initialFiles); } - return fileInfos; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const QStringList& initialSummaryFiles, +bool RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const std::vector>& initialFiles, bool enableApplyToAllField) { - std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; - for (const QString& summaryFile : initialSummaryFiles) + for (const std::pair& initialFile : initialFiles) { - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(summaryFile, + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile, enableApplyToAllField, - m_buildGridFileList, m_defaultSummaryImportMode, m_defaultGridImportMode, &lastResult); @@ -139,9 +145,9 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp for (const QString& file : result.summaryFiles) { RifSummaryCaseFileInfo fi(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); - if (!vectorContains(filesToImport, fi)) + if (!vectorContains(m_summaryFileInfos, fi)) { - filesToImport.push_back(fi); + m_summaryFileInfos.push_back(fi); } } lastResult = result; @@ -154,42 +160,45 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp else { // Cancel pressed, cancel everything + m_summaryFileInfos.clear(); m_gridFiles.clear(); - return std::vector(); + return false; } } - return std::vector(filesToImport.begin(), filesToImport.end()); + return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const QStringList& initialSummaryFiles) +bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector>& initialFiles) { std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; m_gridFiles.clear(); - for (const QString& summaryFile : initialSummaryFiles) + for (const std::pair& initialFile : initialFiles) { - QString file = RiaFilePathTools::toInternalSeparator(summaryFile); + QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.first); + QString initialGridFile = RiaFilePathTools::toInternalSeparator(initialFile.second); + bool handleGridFile = !initialGridFile.isEmpty(); if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { - filesToImport.push_back(RifSummaryCaseFileInfo(file, true)); + filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) { - filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); + filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { - filesToImport.push_back(RifSummaryCaseFileInfo(file, false)); + filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); RifReaderEclipseSummary reader; bool hasWarnings = false; - std::vector restartFileInfos = reader.getRestartFiles(file, &hasWarnings); + std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); for (const auto& rfi : restartFileInfos) { RifSummaryCaseFileInfo fi(rfi.fileName, false); @@ -200,15 +209,15 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp } } - if (m_buildGridFileList) + if (handleGridFile) { - m_gridFiles.push_back(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(file)); + m_gridFiles.push_back(initialGridFile); if (m_defaultGridImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { RifReaderEclipseSummary reader; bool hasWarnings = false; - std::vector restartFileInfos = reader.getRestartFiles(file, &hasWarnings); + std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); for (const auto& rfi : restartFileInfos) { RifSummaryCaseFileInfo fi(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName), false); @@ -225,7 +234,7 @@ std::vector RifSummaryCaseRestartSelector::getFilesToImp } } } - return filesToImport; + return true; } //-------------------------------------------------------------------------------------------------- @@ -238,18 +247,28 @@ QStringList RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(const QS // Find summary header file names from eclipse case file names for (const auto& gridFile : gridFiles) { - if (!gridFile.isEmpty()) - { - QString summaryHeaderFile; - bool formatted; + summaryFiles.push_back(getSummaryFileFromGridFile(gridFile)); + } + return summaryFiles; +} - RifEclipseSummaryTools::findSummaryHeaderFile(gridFile, &summaryHeaderFile, &formatted); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifSummaryCaseRestartSelector::getSummaryFileFromGridFile(const QString& gridFile) +{ + // Find summary header file names from eclipse case file names + if (!gridFile.isEmpty()) + { + QString summaryHeaderFile; + bool formatted; - if (!summaryHeaderFile.isEmpty()) - { - summaryFiles.push_back(summaryHeaderFile); - } + RifEclipseSummaryTools::findSummaryHeaderFile(gridFile, &summaryHeaderFile, &formatted); + + if (!summaryHeaderFile.isEmpty()) + { + return summaryHeaderFile; } } - return summaryFiles; + return ""; } diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index f3f73a1274..837a42406d 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -41,27 +41,28 @@ class RifSummaryCaseRestartSelector RifSummaryCaseRestartSelector(); ~RifSummaryCaseRestartSelector(); - std::vector getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); - std::vector getFilesToImportFromGridFiles(const QStringList& initialGridFiles); + bool getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); + bool getFilesToImportFromGridFiles(const QStringList& initialGridFiles); - void showDialog(bool show) { m_showDialog = show; } - void buildGridCaseFileList(bool build) { m_buildGridFileList = build; } - QStringList gridCaseFiles() const { return m_gridFiles; } + void showDialog(bool show) { m_showDialog = show; } + std::vector summaryFileInfos() const { return m_summaryFileInfos; } + QStringList gridCaseFiles() const { return m_gridFiles; } - static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); + static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); + static QString getSummaryFileFromGridFile(const QString& gridFile); private: - std::vector getFilesToImport(const QStringList& initialSummaryFiles); + bool getFilesToImport(const std::vector>& initialFiles); - std::vector getFilesToImportByAskingUser(const QStringList& initialSummaryFiles, - bool enableApplyToAllField); - std::vector getFilesToImportUsingPrefs(const QStringList& initialSummaryFiles); + bool getFilesToImportByAskingUser(const std::vector>& initialFiles, + bool enableApplyToAllField); + bool getFilesToImportUsingPrefs(const std::vector>& initialFiles); bool m_showDialog; RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; - bool m_buildGridFileList; + std::vector m_summaryFileInfos; QStringList m_gridFiles; }; From d48c2b7aa9fe02d463bc158e0e624ab8a8c59c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 09:23:19 +0200 Subject: [PATCH 0733/1027] Rename layout variables in legends to make their intent and use clearer --- .../cafVizExtensions/cafCategoryLegend.cpp | 82 +++++++------- .../cafVizExtensions/cafCategoryLegend.h | 13 ++- .../cafOverlayScalarMapperLegend.cpp | 100 ++++++++++-------- .../cafOverlayScalarMapperLegend.h | 7 +- 4 files changed, 106 insertions(+), 96 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 6b28e94875..af676c5750 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -95,10 +95,10 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c layoutInfo(&layoutInViewPortCoords); Vec2i legendBarOrigin = oglRect.min(); - legendBarOrigin.x() += static_cast(layoutInViewPortCoords.legendRect.min().x()); - legendBarOrigin.y() += static_cast(layoutInViewPortCoords.legendRect.min().y()); + legendBarOrigin.x() += static_cast(layoutInViewPortCoords.colorBarRect.min().x()); + legendBarOrigin.y() += static_cast(layoutInViewPortCoords.colorBarRect.min().y()); - Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.legendRect.width()), static_cast(layoutInViewPortCoords.legendRect.height())); + Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.colorBarRect.width()), static_cast(layoutInViewPortCoords.colorBarRect.height())); if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) @@ -162,7 +162,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, /// //-------------------------------------------------------------------------------------------------- void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, - OverlayColorLegendLayoutInfo* layout, + const OverlayColorLegendLayoutInfo* layout, float* maxLegendRightPos) { if (m_categoryMapper.isNull()) @@ -179,7 +179,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, m_visibleCategoryLabels.clear(); - const float textX = layout->tickX + 5; + const float textX = layout->tickEndX + 5; const float overlapTolerance = 1.2f * layout->charHeight; float lastVisibleTextY = 0.0; @@ -187,11 +187,11 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, CVF_ASSERT(m_categoryMapper.notNull()); size_t numLabels = m_categoryMapper->categoryCount(); - float categoryHeight = static_cast(layout->legendRect.height() / numLabels); + float categoryHeight = static_cast(layout->colorBarRect.height() / numLabels); for (size_t it = 0; it < numLabels; it++) { - float textY = static_cast(layout->legendRect.min().y() + it * categoryHeight + categoryHeight / 2); + float textY = static_cast(layout->colorBarRect.min().y() + it * categoryHeight + categoryHeight / 2); // Always draw first and last tick label. For all others, skip drawing if text ends up // on top of the previous label. @@ -204,7 +204,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, } // Make sure it does not overlap the last tick as well - float lastTickY = static_cast(layout->legendRect.max().y()); + float lastTickY = static_cast(layout->colorBarRect.max().y()); if (cvf::Math::abs(textY - lastTickY) < overlapTolerance) { @@ -276,8 +276,8 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Connects static const ushort trianglesConnects[] = { 0, 1, 4, 0, 4, 3 }; @@ -297,15 +297,15 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->legendRect.height()); + int legendHeightPixelCount = static_cast(layout->colorBarRect.height()); if (m_categoryMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_categoryMapper->mapToColor(m_categoryMapper->domainValue((iPx + 0.5) / legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -331,10 +331,10 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x() - 0.5f; - v1[0] = v3[0] = layout->legendRect.max().x() - 0.5f; - v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; - v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x() - 0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x() - 0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y() - 0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y() - 0.5f; static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0 }; UniformFloat uniformColor("u_color", Color4f(this->lineColor())); @@ -400,20 +400,20 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->legendRect.height()); + int legendHeightPixelCount = static_cast(layout->colorBarRect.height()); if (m_categoryMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_categoryMapper->mapToColor(m_categoryMapper->domainValue((iPx + 0.5) / legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -436,10 +436,10 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x() - 0.5f; - v1[0] = v3[0] = layout->legendRect.max().x() - 0.5f; - v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; - v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x() - 0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x() - 0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y() - 0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y() - 0.5f; glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); @@ -472,23 +472,29 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) { CVF_TIGHT_ASSERT(layout); - ref glyph = this->font()->getGlyph(L'A'); - layout->charHeight = static_cast(glyph->height()); + ref glyph = this->font()->getGlyph(L'A'); + layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; - layout->margins = Vec2f(8.0f, 8.0f); - - float legendWidth = 25.0f; - float legendHeight = static_cast(layout->size.y()) - 2 * layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; - layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight / 2.0f, legendWidth, legendHeight); - - if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) + layout->margins = Vec2f(8.0f, 8.0f); + + float colorBarWidth = 25.0f; + float colorBarHeight = static_cast(layout->size.y()) + - 2 * layout->margins.y() + - static_cast(this->titleStrings().size()) * layout->lineSpacing + - layout->lineSpacing; + layout->colorBarRect = Rectf(layout->margins.x(), + layout->margins.y() + layout->charHeight / 2.0f, + colorBarWidth, + colorBarHeight); + + if (layout->colorBarRect.width() < 1 || layout->colorBarRect.height() < 1) { return; } - layout->x0 = layout->margins.x(); - layout->x1 = layout->margins.x() + layout->legendRect.width(); - layout->tickX = layout->x1 + 5; + layout->tickStartX = layout->margins.x(); + layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); + layout->tickEndX = layout->tickMidX + 5; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index bb9ddcc393..2d3585c2f3 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -45,9 +45,9 @@ class CategoryLegend : public caf::TitledOverlayFrame charHeight = 0.0f; lineSpacing = 0.0f; margins = cvf::Vec2f::ZERO; - tickX = 0.0f; - x0 = 0.0f; - x1 = 0.0f; + tickEndX = 0.0f; + tickStartX = 0.0f; + tickMidX = 0.0f; position = pos; size = setSize; @@ -56,10 +56,9 @@ class CategoryLegend : public caf::TitledOverlayFrame float charHeight; float lineSpacing; cvf::Vec2f margins; - float tickX; - float x0, x1; + float tickStartX, tickMidX, tickEndX; - cvf::Rectf legendRect; + cvf::Rectf colorBarRect; cvf::Vec2i position; cvf::Vec2ui size; @@ -72,7 +71,7 @@ class CategoryLegend : public caf::TitledOverlayFrame const cvf::Vec2ui& size, bool software); void setupTextDrawer(cvf::TextDrawer* textDrawer, - OverlayColorLegendLayoutInfo* layout, + const OverlayColorLegendLayoutInfo* layout, float* maxLegendRightPos); void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index d0967f0602..069719fabe 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -151,10 +151,10 @@ bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& layoutInfo(&layoutInViewPortCoords); Vec2i legendBarOrigin = oglRect.min(); - legendBarOrigin.x() += static_cast(layoutInViewPortCoords.legendRect.min().x()); - legendBarOrigin.y() += static_cast(layoutInViewPortCoords.legendRect.min().y()); + legendBarOrigin.x() += static_cast(layoutInViewPortCoords.colorBarRect.min().x()); + legendBarOrigin.y() += static_cast(layoutInViewPortCoords.colorBarRect.min().y()); - Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.legendRect.width()), static_cast(layoutInViewPortCoords.legendRect.height())); + Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.colorBarRect.width()), static_cast(layoutInViewPortCoords.colorBarRect.height())); if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) @@ -220,7 +220,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov m_visibleTickLabels.clear(); - const float textX = layout->tickX + 5; + const float textX = layout->tickEndX + 5; const float overlapTolerance = 1.2f * layout->charHeight; float lastVisibleTextY = 0.0; @@ -229,7 +229,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov size_t it; for (it = 0; it < numTicks; it++) { - float textY = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(it)); + float textY = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(it)); // Always draw first and last tick label. For all others, skip drawing if text ends up // on top of the previous label. @@ -242,7 +242,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov } // Make sure it does not overlap the last tick as well - float lastTickY = static_cast(layout->legendRect.max().y() ); + float lastTickY = static_cast(layout->colorBarRect.max().y() ); if (cvf::Math::abs(textY - lastTickY) < overlapTolerance) { @@ -327,8 +327,8 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Connects static const ushort trianglesConnects[] = { 0, 1, 4, 0, 4, 3 }; @@ -348,15 +348,15 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->tickPixelPos->get(m_tickValues.size()-1) - layout->tickPixelPos->get(0) + 0.01); + int legendHeightPixelCount = static_cast(layout->tickYPixelPos->get(m_tickValues.size()-1) - layout->tickYPixelPos->get(0) + 0.01); if (m_scalarMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -382,10 +382,10 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x()-0.5f; - v1[0] = v3[0] = layout->legendRect.max().x()-0.5f; - v0[1] = v1[1] = layout->legendRect.min().y()-0.5f; - v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x()-0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x()-0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y()-0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y()-0.5f; static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0}; UniformFloat uniformColor("u_color", Color4f(this->lineColor())); @@ -404,11 +404,11 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte if (isRenderingTicks) { // Constant coordinates - v0[0] = layout->x0; - v1[0] = layout->x1 - 0.5f*(layout->tickX - layout->x1) - 0.5f; - v2[0] = layout->x1; - v3[0] = layout->tickX - 0.5f*(layout->tickX - layout->x1) - 0.5f; - v4[0] = layout->tickX; + v0[0] = layout->tickStartX; + v1[0] = layout->tickMidX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v2[0] = layout->tickMidX; + v3[0] = layout->tickEndX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v4[0] = layout->tickEndX; static const ushort tickLinesWithLabel[] = { 0, 4 }; static const ushort tickLinesWoLabel[] = { 2, 3 }; @@ -416,7 +416,7 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte size_t ic; for (ic = 0; ic < m_tickValues.size(); ic++) { - float y0 = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(ic) - 0.5f); + float y0 = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(ic) - 0.5f); // Dynamic coordinates for tickmarks-lines v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; @@ -495,20 +495,20 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->tickPixelPos->get(m_tickValues.size() - 1) - layout->tickPixelPos->get(0) + 0.01); + int legendHeightPixelCount = static_cast(layout->tickYPixelPos->get(m_tickValues.size() - 1) - layout->tickYPixelPos->get(0) + 0.01); if (m_scalarMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -531,10 +531,10 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x()-0.5f; - v1[0] = v3[0] = layout->legendRect.max().x()-0.5f; - v0[1] = v1[1] = layout->legendRect.min().y()-0.5f; - v2[1] = v3[1] = layout->legendRect.max().y()-0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x()-0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x()-0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y()-0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y()-0.5f; glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); @@ -556,16 +556,16 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont if (isRenderingTicks) { // Constant coordinates - v0[0] = layout->x0; - v1[0] = layout->x1 - 0.5f*(layout->tickX - layout->x1) - 0.5f; - v2[0] = layout->x1; - v3[0] = layout->tickX - 0.5f*(layout->tickX - layout->x1) - 0.5f; - v4[0] = layout->tickX; + v0[0] = layout->tickStartX; + v1[0] = layout->tickMidX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v2[0] = layout->tickMidX; + v3[0] = layout->tickEndX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v4[0] = layout->tickEndX; size_t ic; for (ic = 0; ic < m_tickValues.size(); ic++) { - float y0 = static_cast(layout->legendRect.min().y() + layout->tickPixelPos->get(ic) - 0.5f); + float y0 = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(ic) - 0.5f); // Dynamic coordinates for tickmarks-lines v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; @@ -608,22 +608,28 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->lineSpacing = layout->charHeight*1.5f; layout->margins = Vec2f(8.0f, 8.0f); - float legendWidth = 25.0f; - float legendHeight = static_cast(layout->size.y()) - 2*layout->margins.y() - static_cast(this->titleStrings().size())*layout->lineSpacing - layout->lineSpacing; - layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight/2.0f, legendWidth, legendHeight); - - if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) + float colorBarWidth = 25.0f; + float colorBarHeight = static_cast(layout->size.y()) + - 2*layout->margins.y() + - static_cast(this->titleStrings().size()) * layout->lineSpacing + - layout->lineSpacing; + layout->colorBarRect = Rectf(layout->margins.x(), + layout->margins.y() + layout->charHeight/2.0f, + colorBarWidth, + colorBarHeight); + + if (layout->colorBarRect.width() < 1 || layout->colorBarRect.height() < 1) { return; } - layout->x0 = layout->margins.x(); - layout->x1 = layout->margins.x() + layout->legendRect.width(); - layout->tickX = layout->x1 + 5; + layout->tickStartX = layout->margins.x(); + layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); + layout->tickEndX = layout->tickMidX + 5; // Build array containing the pixel positions of all the ticks size_t numTicks = m_tickValues.size(); - layout->tickPixelPos = new DoubleArray(numTicks); + layout->tickYPixelPos = new DoubleArray(numTicks); size_t i; for (i = 0; i < numTicks; i++) @@ -634,11 +640,11 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) t = Math::clamp(t, 0.0, 1.1); if (i != numTicks -1) { - layout->tickPixelPos->set(i, t*layout->legendRect.height()); + layout->tickYPixelPos->set(i, t*layout->colorBarRect.height()); } else { - layout->tickPixelPos->set(i, layout->legendRect.height()); // Make sure we get a value at the top even if the scalarmapper range is zero + layout->tickYPixelPos->set(i, layout->colorBarRect.height()); // Make sure we get a value at the top even if the scalarmapper range is zero } } } diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index db22015825..52c8d493c1 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -102,12 +102,11 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame float charHeight; float lineSpacing; Vec2f margins; - float tickX; - float x0, x1; + float tickStartX, tickMidX, tickEndX; - Rectf legendRect; + Rectf colorBarRect; - cvf::ref tickPixelPos; + cvf::ref tickYPixelPos; Vec2i position; Vec2ui size; From 9550864c9eccd9b43f26e3eeac608d44bfa745fe Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 10:03:07 +0200 Subject: [PATCH 0734/1027] #2711 Project File : Use forward slash for project file path in XML --- ApplicationCode/Application/RiaApplication.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index c55671f0cd..7907a8b94f 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -22,6 +22,7 @@ #include "RiaArgumentParser.h" #include "RiaBaseDefs.h" +#include "RiaFilePathTools.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferences.h" @@ -909,7 +910,8 @@ bool RiaApplication::askUserToSaveModifiedProject() //-------------------------------------------------------------------------------------------------- bool RiaApplication::saveProjectAs(const QString& fileName) { - m_project->fileName = fileName; + // Make sure we always store path with forward slash to avoid issues when opening the project file on Linux + m_project->fileName = RiaFilePathTools::toInternalSeparator(fileName); storeTreeViewState(); From 6c45725b19193fa52799d3323376357dd8ffc74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 10:17:02 +0200 Subject: [PATCH 0735/1027] #2689 ensemble curves. Make the curve set legend work. Cache summary addresses for performance reasons --- .../RimRegularLegendConfig.cpp | 9 +++ .../Summary/RimEnsembleCurveSet.cpp | 56 +++++++++++++------ .../Summary/RimEnsembleCurveSet.h | 9 ++- .../Summary/RimSummaryPlot.cpp | 15 ----- .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 - 5 files changed, 56 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index a85cba27df..b9d2ea5378 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -26,6 +26,7 @@ #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" +#include "RimEnsembleCurveSet.h" #include "RimEclipseView.h" #include "RimGeoMechResultDefinition.h" #include "RimIntersectionCollection.h" @@ -205,6 +206,14 @@ void RimRegularLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed { stimPlanColors->updateStimPlanTemplates(); } + + // Update ensemble curve set if relevant + RimEnsembleCurveSet* ensembleCurveSet; + firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) + { + ensembleCurveSet->onLegendDefinitionChanged(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 97b0439d91..0a23e06529 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -23,6 +23,7 @@ #include "RifReaderEclipseSummary.h" #include "RimProject.h" +#include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" @@ -38,7 +39,7 @@ #include "cafPdmObject.h" #include "cafPdmUiPushButtonEditor.h" -#include "cvfScalarMapperContinuousLinear.h" +#include "cvfScalarMapper.h" namespace caf @@ -181,6 +182,8 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) } } } + + updateCurveColors(); } //-------------------------------------------------------------------------------------------------- @@ -275,6 +278,14 @@ RimRegularLegendConfig* RimEnsembleCurveSet::legendConfig() return m_legendConfig; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::onLegendDefinitionChanged() +{ + updateCurveColors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -296,6 +307,8 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } else if (changedField == &m_yValuesSummaryGroup) { + // Empty address cache + m_allAddressesCache.clear(); updateAllCurves(); } else if (changedField == &m_ensembleParameter || @@ -313,9 +326,6 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie updateQwtPlotAxis(); plot->updateAxes(); } - else if (changedField == &m_yPushButtonSelectSummaryAddress) - { - } } //-------------------------------------------------------------------------------------------------- @@ -358,7 +368,10 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { - uiTreeOrdering.add(m_legendConfig()); + if (m_colorMode == BY_ENSEMBLE_PARAM) + { + uiTreeOrdering.add(m_legendConfig()); + } uiTreeOrdering.skipRemainingChildren(true); } @@ -466,16 +479,17 @@ void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses(QList allAddresses; - - for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases()) + if (m_allAddressesCache.empty()) { - RifSummaryReaderInterface* reader = summaryCase->summaryReader(); - const std::vector addrs = reader ? reader->allResultAddresses() : std::vector(); - allAddresses.insert(addrs.begin(), addrs.end()); + for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases()) + { + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + const std::vector addrs = reader ? reader->allResultAddresses() : std::vector(); + m_allAddressesCache.insert(addrs.begin(), addrs.end()); + } } - for (auto& address : allAddresses) + for (auto& address : m_allAddressesCache) { if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; @@ -514,14 +528,13 @@ void RimEnsembleCurveSet::updateCurveColors() } } - cvf::ScalarMapperContinuousLinear colorMapper; - colorMapper.setRange(minValue, maxValue); + m_legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); for (auto& curve : m_curves) { RimSummaryCase* rimCase = curve->summaryCaseY(); double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - curve->setColor(cvf::Color3f(colorMapper.mapToColor(value))); + curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); curve->updateCurveAppearance(); } } @@ -537,7 +550,18 @@ void RimEnsembleCurveSet::updateCurveColors() RimSummaryPlot* plot; firstAncestorOrThisOfType(plot); - if (plot && plot->qwtPlot()) plot->qwtPlot()->replot(); + if (plot && plot->qwtPlot()) + { + if (m_colorMode == BY_ENSEMBLE_PARAM) + { + plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); + } + else + { + plot->qwtPlot()->removeEnsembleCurveSetLegend(this); + } + plot->qwtPlot()->replot(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 97e7bbbc9f..69d39f13af 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -34,6 +34,8 @@ #include "cafPdmPtrField.h" #include "cafAppEnum.h" +#include "RifEclipseSummaryAddressQMetaType.h" + class QwtPlot; class QwtPlotCurve; class RimSummaryCase; @@ -72,7 +74,8 @@ class RimEnsembleCurveSet : public caf::PdmObject void deleteAllCurves(); - RimRegularLegendConfig* legendConfig(); + RimRegularLegendConfig* legendConfig(); + void onLegendDefinitionChanged(); private: caf::PdmFieldHandle* objectToggleField(); @@ -89,7 +92,7 @@ class RimEnsembleCurveSet : public caf::PdmObject RimSummaryCase* summaryCase, RimSummaryFilter* summaryFilter); - static void appendOptionItemsForSummaryAddresses(QList* options, + void appendOptionItemsForSummaryAddresses(QList* options, RimSummaryCaseCollection* summaryCaseGroup, RimSummaryFilter* summaryFilter); @@ -118,5 +121,7 @@ class RimEnsembleCurveSet : public caf::PdmObject caf::PdmField> m_plotAxis; caf::PdmChildField m_legendConfig; + + std::set m_allAddressesCache; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 316346b3f2..542fb96b55 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -957,21 +957,6 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve) } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -//void RimSummaryPlot::addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve) -//{ -// if (curveSet && curve) -// { -// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensembleCurveSetCollection->curveSets().size())); -// -// const_cast(curveSet)->addCurve(curve); -// curve->setParentQwtPlotAndReplot(m_qwtPlot); -// } -//} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 4eb6a2c279..dbeb607466 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -71,8 +71,6 @@ class RimSummaryPlot : public RimViewWindow void addCurveAndUpdate(RimSummaryCurve* curve); void addCurveNoUpdate(RimSummaryCurve* curve); - //void addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve); - void deleteCurve(RimSummaryCurve* curve); void setCurveCollection(RimSummaryCurveCollection* curveCollection); void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); From 27ba7c5d9d9d02edaf5b2b08bc5479540c984b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 11:28:28 +0200 Subject: [PATCH 0736/1027] #2689 Ensemble curves. Adapt legend range settings to curve set --- .../ProjectDataModel/RimRegularLegendConfig.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index b9d2ea5378..f95ca3f985 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -777,11 +777,16 @@ void RimRegularLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr QList RimRegularLegendConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { bool hasStimPlanParent = false; + bool hasEnsembleCurveSetParent = false; RimStimPlanColors* stimPlanColors = nullptr; this->firstAncestorOrThisOfType(stimPlanColors); if (stimPlanColors) hasStimPlanParent = true; + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) hasEnsembleCurveSetParent = true; + bool isCategoryResult = false; { RimEclipseCellColors* eclCellColors = nullptr; @@ -849,9 +854,13 @@ QList RimRegularLegendConfig::calculateValueOptions(cons { if (!m_isAllTimeStepsRangeDisabled) { - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + QString uiText; + if(!hasEnsembleCurveSetParent) uiText = RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS); + else uiText = "Auto Range"; + + options.push_back(caf::PdmOptionItemInfo(uiText, RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); } - if (!hasStimPlanParent) + if (!hasStimPlanParent && !hasEnsembleCurveSetParent) { options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); } From b4fae86aea2b9dd9508d1893e2dc55e29b30cc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 11:33:45 +0200 Subject: [PATCH 0737/1027] #2689 Ensemble curves. Hide vector selection button --- ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 0a23e06529..a0a3445939 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -99,6 +99,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() caf::PdmUiPushButtonEditor::configureEditorForField(&m_yPushButtonSelectSummaryAddress); m_yPushButtonSelectSummaryAddress = false; m_yPushButtonSelectSummaryAddress.uiCapability()->setUiReadOnly(true); + m_yPushButtonSelectSummaryAddress.uiCapability()->setUiHidden(true); m_yValuesCurveVariable = new RimSummaryAddress; From 68b360a03fb5b5fe0f6d0637c723239d1fe49b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 12:30:59 +0200 Subject: [PATCH 0738/1027] #2769 Ensemble curves. Fix crash when clicking on ensemble curve --- .../Summary/RimEnsembleCurveSetCollection.cpp | 41 ++++++++++++++----- .../Summary/RimEnsembleCurveSetCollection.h | 7 ++-- .../Summary/RimSummaryPlot.cpp | 13 +++++- .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 8 ++-- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 4570e1b3fe..aad83c655b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -75,6 +75,8 @@ RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() //m_unionSourceStepping.uiCapability()->setUiHidden(true); //m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); //m_unionSourceStepping.xmlCapability()->disableIO(); + + } //-------------------------------------------------------------------------------------------------- @@ -146,6 +148,25 @@ void RimEnsembleCurveSetCollection::detachQwtCurves() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve(const QwtPlotCurve* qwtCurve) const +{ + for (RimEnsembleCurveSet* curveSet : m_curveSets) + { + for (RimSummaryCurve* rimCurve : curveSet->curves()) + { + if (rimCurve->qwtPlotCurve() == qwtCurve) + { + return curveSet; + } + } + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -250,16 +271,16 @@ void RimEnsembleCurveSetCollection::deleteAllCurveSets() // if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); //} // -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -//void RimEnsembleCurveSetCollection::setCurrentSummaryCurve(RimSummaryCurve* curve) -//{ -// m_currentSummaryCurve = curve; -// -// updateConnectedEditors(); -//} -// +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet) +{ + m_currentEnsembleCurveSet = curveSet; + + updateConnectedEditors(); +} + ////-------------------------------------------------------------------------------------------------- ///// ////-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index f28887d781..756ba20aee 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -28,6 +28,7 @@ class RimSummaryCase; class RimEnsembleCurveSet; class QwtPlot; +class QwtPlotCurve; //================================================================================================== /// @@ -46,7 +47,7 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject void setParentQwtPlotAndReplot(QwtPlot* plot); void detachQwtCurves(); - //RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; + RimEnsembleCurveSet* findRimCurveSetFromQwtCurve(const QwtPlotCurve* qwtCurve) const; void addCurveSet(RimEnsembleCurveSet* curveSet); void deleteCurveSet(RimEnsembleCurveSet* curveSet); @@ -58,7 +59,7 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject void deleteAllCurveSets(); //void updateCaseNameHasChanged(); - //void setCurrentSummaryCurve(RimSummaryCurve* curve); + void setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet); //std::vector fieldsToShowInToolbar(); @@ -78,6 +79,6 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject caf::PdmField m_showCurves; caf::PdmChildArrayField m_curveSets; - //caf::PdmPointer m_currentSummaryCurve; + caf::PdmPointer m_currentEnsembleCurveSet; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 542fb96b55..86f5380d16 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1520,7 +1520,7 @@ void RimSummaryPlot::detachAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const +caf::PdmObject* RimSummaryPlot::findRimPlotObjectFromQwtCurve(const QwtPlotCurve* qwtCurve) const { for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { @@ -1550,6 +1550,17 @@ caf::PdmObject* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qwt } } + if (m_ensembleCurveSetCollection) + { + RimEnsembleCurveSet* foundCurveSet = m_ensembleCurveSetCollection->findRimCurveSetFromQwtCurve(qwtCurve); + + if (foundCurveSet) + { + m_ensembleCurveSetCollection->setCurrentSummaryCurveSet(foundCurveSet); + + return foundCurveSet; + } + } return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index dbeb607466..e3c4e39327 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -81,7 +81,7 @@ class RimSummaryPlot : public RimViewWindow void addAsciiDataCruve(RimAsciiDataCurve* curve); - caf::PdmObject* findRimCurveFromQwtCurve(const QwtPlotCurve* curve) const; + caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const; size_t curveCount() const; void detachAllCurves(); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index f6ce7965c8..589d5869f2 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -409,15 +409,15 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos) if(closestCurve && distMin < 20) { - caf::PdmObject* selectedCurve = m_plotDefinition->findRimCurveFromQwtCurve(closestCurve); + caf::PdmObject* selectedPlotObject = m_plotDefinition->findRimPlotObjectFromQwtCurve(closestCurve); RimProject* proj = nullptr; - selectedCurve->firstAncestorOrThisOfType(proj); + selectedPlotObject->firstAncestorOrThisOfType(proj); - if(proj && selectedCurve) + if(proj && selectedPlotObject) { RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve); + RiuPlotMainWindowTools::selectAsCurrentItem(selectedPlotObject); } } } From 69630211ca5436bb34eb512bfc199dede2ed3627 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 12:58:42 +0200 Subject: [PATCH 0739/1027] #2770 Fracture : Recompute completion type when required --- .../Completions/RimEllipseFractureTemplate.cpp | 3 +-- .../ProjectDataModel/Completions/RimFracture.cpp | 8 +++++++- .../Completions/RimFractureTemplate.cpp | 10 ++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 2a59ca046d..fd9f9dfb7d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -321,8 +321,7 @@ void RimEllipseFractureTemplate::reload() this->firstAncestorOrThisOfType(proj); if (proj) { - //Regenerate geometry - proj->createDisplayModelAndRedrawAllViews(); + proj->reloadCompletionTypeResultsInAllViews(); assignConductivityToCellsInsideEllipse(); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 3ec570aea0..d805211568 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -230,7 +230,13 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons this->firstAncestorOrThisOfType(rimView); if (rimView) { - rimView->createDisplayModelAndRedraw(); + RimEclipseCase* eclipseCase = nullptr; + rimView->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase) + { + eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); + eclipseCase->deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); + } } else { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index b4e2270ed9..1e3e012bba 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -237,6 +237,7 @@ caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { + bool createDisplayModelAndRedraw = false; if (changedField == &m_azimuthAngle || changedField == &m_orientationType) { //Changes to one of these parameters should change all fractures with this fracture template attached. @@ -268,7 +269,7 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } } - proj->createDisplayModelAndRedrawAllViews(); + createDisplayModelAndRedraw = true; } } @@ -301,12 +302,17 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } if (changedField == &m_perforationLength) + { + createDisplayModelAndRedraw = true; + } + + if (createDisplayModelAndRedraw) { RimProject* proj; this->firstAncestorOrThisOfType(proj); if (proj) { - proj->createDisplayModelAndRedrawAllViews(); + proj->reloadCompletionTypeResultsInAllViews(); } } } From 95151193e9d7113ea2aab5da9a105c8c5fbb1f5d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 12:59:40 +0200 Subject: [PATCH 0740/1027] #2770 Fracture : Only evaluate visibble geometry for completion types --- .../RimCompletionCellIntersectionCalc.cpp | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index a717a42f96..294ab03bdd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -63,11 +63,14 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) + if (project->activeOilField()->wellPathCollection->isActive) { - if (wellPath->showWellPath()) + for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) { - calculateWellPathIntersections(wellPath, eclipseCaseData, completionTypeCellResults, fromDate); + if (wellPath->showWellPath()) + { + calculateWellPathIntersections(wellPath, eclipseCaseData, completionTypeCellResults, fromDate); + } } } @@ -76,11 +79,20 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP { for (RimEclipseView* view : eclipseCase->reservoirViews()) { - for (RimSimWellInView* simWell : view->wellCollection()->wells()) + if (view->viewer() && view->wellCollection()->isActive()) { - for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) + for (RimSimWellInView* simWell : view->wellCollection()->wells()) { - calculateFractureIntersections(mainGrid, fracture, completionTypeCellResults); + if (simWell->showWell()) + { + for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) + { + if (fracture->isChecked()) + { + calculateFractureIntersections(mainGrid, fracture, completionTypeCellResults); + } + } + } } } } From 4eec46cbdcbf6c3b6cbdd2fa79c7d045ffd3a731 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 13:20:46 +0200 Subject: [PATCH 0741/1027] #2770 Fracture : Extract startTimer() --- .../RiaCompletionTypeCalculationScheduler.cpp | 36 ++++++++++--------- .../RiaCompletionTypeCalculationScheduler.h | 8 +++-- .../ProjectDataModel/RimEclipseCase.cpp | 1 - 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 2f1c2e6a44..984afb860c 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -17,12 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaCompletionTypeCalculationScheduler.h" + #include "RiaApplication.h" + #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimOilField.h" #include "RimProject.h" + #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -53,14 +56,7 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd m_eclipseCasesToRecalculate.push_back(eclipseCase); } - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(1500); + startTimer(); } //-------------------------------------------------------------------------------------------------- @@ -70,14 +66,7 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd { m_eclipseCasesToRecalculate.push_back(eclipseCase); - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(1500); + startTimer(); } //-------------------------------------------------------------------------------------------------- @@ -120,3 +109,18 @@ RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() { delete m_recalculateCompletionTypeTimer; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::startTimer() +{ + if (!m_recalculateCompletionTypeTimer) + { + m_recalculateCompletionTypeTimer = new QTimer(this); + m_recalculateCompletionTypeTimer->setSingleShot(true); + connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); + } + + m_recalculateCompletionTypeTimer->start(1500); +} diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h index 256b864c53..7a72bde95d 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -18,14 +18,15 @@ #pragma once +#include "cafPdmPointer.h" + #include + #include -#include "cafPdmPointer.h" class QTimer; class RimEclipseCase; - class RiaCompletionTypeCalculationScheduler : public QObject { Q_OBJECT; @@ -44,6 +45,9 @@ private slots: RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; + void startTimer(); + +private: std::vector > m_eclipseCasesToRecalculate; QTimer* m_recalculateCompletionTypeTimer; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 0f7397be7a..e266c30df4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -394,7 +394,6 @@ const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirt } } - ; for (const auto& wellRes : rigEclipseCase->wellResults()) { std::vector> completionsPerTimeStep; From 98e95fe5bfde799998593d4110f67f6f0d01461a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 14:11:57 +0200 Subject: [PATCH 0742/1027] #2770 Fracture : Trigger recompute when well collection is toggeled --- ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index ef72217b5e..ed2ed64361 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -407,7 +407,7 @@ void RimWellPathCollection::scheduleRedrawAffectedViews() { RimProject* proj; this->firstAncestorOrThisOfType(proj); - if (proj) proj->createDisplayModelAndRedrawAllViews(); + if (proj) proj->reloadCompletionTypeResultsInAllViews(); } //-------------------------------------------------------------------------------------------------- From ac10c4b9ac319c883763605c9b54a2c303701af8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 14:13:01 +0200 Subject: [PATCH 0743/1027] #2770 : Never compute completion type for simulation well fractures --- .../RimCompletionCellIntersectionCalc.cpp | 26 ++----------------- .../RimCompletionCellIntersectionCalc.h | 4 +-- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 294ab03bdd..8a3cc450b9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -74,29 +74,7 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP } } - const RigMainGrid* mainGrid = eclipseCaseData->mainGrid(); - if (mainGrid) - { - for (RimEclipseView* view : eclipseCase->reservoirViews()) - { - if (view->viewer() && view->wellCollection()->isActive()) - { - for (RimSimWellInView* simWell : view->wellCollection()->wells()) - { - if (simWell->showWell()) - { - for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) - { - if (fracture->isChecked()) - { - calculateFractureIntersections(mainGrid, fracture, completionTypeCellResults); - } - } - } - } - } - } - } + // NOTE : Never compute completion type result for simulation well fractures, as these are defined per view } //-------------------------------------------------------------------------------------------------- @@ -198,7 +176,7 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const /// //-------------------------------------------------------------------------------------------------- void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimFracture* fracture, + const RimWellPathFracture* fracture, std::vector& values) { if (!fracture->fractureTemplate()) return; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index da399c70d4..98da985a44 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -23,7 +23,7 @@ class RigMainGrid; class RimEclipseCase; class RimFishbonesMultipleSubs; -class RimFracture; +class RimWellPathFracture; class RimPerforationInterval; class RimProject; class RimWellPath; @@ -59,6 +59,6 @@ class RimCompletionCellIntersectionCalc std::vector& values); static void calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimFracture* fracture, + const RimWellPathFracture* fracture, std::vector& values); }; From 8bcec233908a27f4514a82a22ca23d6646126417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 13:25:46 +0200 Subject: [PATCH 0744/1027] #2689 Ensemble curves. Set default ensemble parameter --- .../Summary/RimEnsembleCurveSet.cpp | 54 ++++++++++++------- .../Summary/RimEnsembleCurveSet.h | 1 + 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index a0a3445939..6f8e47779a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -313,11 +313,19 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie updateAllCurves(); } else if (changedField == &m_ensembleParameter || - changedField == &m_color || - changedField == &m_colorMode) + changedField == &m_color) { updateCurveColors(); } + else if (changedField == &m_colorMode) + { + if (m_ensembleParameter().isEmpty()) + { + auto params = ensembleParameters(); + m_ensembleParameter = !params.empty() ? params.front() : ""; + } + updateCurveColors(); + } else if (changedField == &m_plotAxis) { for (RimSummaryCurve* curve : curves()) @@ -351,6 +359,7 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder } caf::PdmUiGroup* colorsGroup = uiOrdering.addNewGroup("Colors"); + m_colorMode.uiCapability()->setUiReadOnly(!m_yValuesSummaryGroup()); colorsGroup->add(&m_colorMode); if (m_colorMode == SINGLE_COLOR) @@ -359,6 +368,7 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder } else if (m_colorMode == BY_ENSEMBLE_PARAM) { + m_ensembleParameter.uiCapability()->setUiReadOnly(!m_yValuesSummaryGroup()); colorsGroup->add(&m_ensembleParameter); } uiOrdering.skipRemainingFields(true); @@ -417,24 +427,10 @@ QList RimEnsembleCurveSet::calculateValueOptions(const c } else if (fieldNeedingOptions == &m_ensembleParameter) { - RimSummaryCaseCollection* group = m_yValuesSummaryGroup; - if (group) + for (auto param : ensembleParameters()) { - std::set paramSet; - for (RimSummaryCase* rimCase : group->allSummaryCases()) - { - if (!rimCase->caseRealizationParameters().isNull()) - { - auto ps = rimCase->caseRealizationParameters()->parameters(); - for (auto p : ps) paramSet.insert(p.first); - } - } - - for (auto param : paramSet) - { - options.push_back(caf::PdmOptionItemInfo(param, param)); - } + options.push_back(caf::PdmOptionItemInfo(param, param)); } } else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) @@ -615,3 +611,25 @@ void RimEnsembleCurveSet::updateAllCurves() } updateCurveColors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsembleCurveSet::ensembleParameters() const +{ + RimSummaryCaseCollection* group = m_yValuesSummaryGroup; + + std::set paramSet; + if (group) + { + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (!rimCase->caseRealizationParameters().isNull()) + { + auto ps = rimCase->caseRealizationParameters()->parameters(); + for (auto p : ps) paramSet.insert(p.first); + } + } + } + return std::vector(paramSet.begin(), paramSet.end()); +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 69d39f13af..9d9b6e2b7f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -99,6 +99,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void updateCurveColors(); void updateQwtPlotAxis(); void updateAllCurves(); + std::vector ensembleParameters() const; private: caf::PdmField m_showCurves; From 8a02fc309528d0926af11a8858f48bcb1b820e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 14:58:39 +0200 Subject: [PATCH 0745/1027] #2771 Ensemble curves. Add 'Add curve set' command to more tree nodes. Hide curve set collection when empty --- ApplicationCode/Commands/RicDeleteItemExec.cpp | 11 +++++++++++ .../ProjectDataModel/RimContextCommandBuilder.cpp | 6 ++++++ .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 6ac93cf0a7..df6983541a 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -28,12 +28,14 @@ #include "RimCellRangeFilterCollection.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimFormationNamesCollection.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimIntersectionCollection.h" #include "RimProject.h" #include "RimSimWellInView.h" #include "RimSummaryCrossPlotCollection.h" +#include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimViewLinkerCollection.h" #include "RimWellLogPlot.h" @@ -271,6 +273,15 @@ void RicDeleteItemExec::redo() RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } + + RimEnsembleCurveSetCollection* ensembleCurveSetColl = nullptr; + parentObj->firstAncestorOrThisOfType(ensembleCurveSetColl); + if (ensembleCurveSetColl) + { + RimSummaryPlot* plot = nullptr; + ensembleCurveSetColl->firstAncestorOrThisOfType(plot); + if (plot) plot->updateConnectedEditors(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 3551959f6c..e8d8369f6d 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -40,6 +40,7 @@ #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" #include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSet.h" #include "RimFaultInView.h" #include "RimFlowCharacteristicsPlot.h" #include "RimFlowDiagSolution.h" @@ -425,6 +426,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryPlotFeature"; menuBuilder << "RicDuplicateSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; menuBuilder << "RicDuplicateSummaryCrossPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; @@ -466,6 +468,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; + } else if (dynamic_cast(uiItem)) { menuBuilder << "RicImportSummaryCaseFeature"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 86f5380d16..1be67dbfc6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -87,6 +87,7 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitFieldNoDefault(&m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "", "", "", ""); m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden(true); + m_ensembleCurveSetCollection.uiCapability()->setUiHidden(true); m_ensembleCurveSetCollection = new RimEnsembleCurveSetCollection(); CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); @@ -1145,7 +1146,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering axisFolder->add(&m_rightYAxisProperties); uiTreeOrdering.add(&m_summaryCurveCollection); - if (!m_isCrossPlot) + if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) { uiTreeOrdering.add(&m_ensembleCurveSetCollection); } From 1ff149c6680f11813287911291933db0ef259eca Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Apr 2018 15:08:18 +0200 Subject: [PATCH 0746/1027] #2580 Export Completion Data : Add command in File/Export menu --- ...tCompletionsForVisibleWellPathsFeature.cpp | 28 ++++++++++++++++--- .../UserInterface/RiuMainWindow.cpp | 5 ++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp index 5d2787da80..5e1136df8b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -18,9 +18,12 @@ #include "RicExportCompletionsForVisibleWellPathsFeature.h" +#include "RiaApplication.h" + #include "RicWellPathExportCompletionDataFeature.h" #include "RimWellPath.h" +#include "RimProject.h" #include "RimWellPathCollection.h" #include "cafSelectionManager.h" @@ -93,16 +96,33 @@ std::vector RicExportCompletionsForVisibleWellPathsFeature::visibl } } - for (auto wellPathCollection : wellPathCollections) + if (!wellPathCollections.empty()) { - for (auto wellPath : wellPathCollection->wellPaths()) + for (auto wellPathCollection : wellPathCollections) { - if (wellPath->showWellPath()) + for (const auto& wellPath : wellPathCollection->wellPaths()) { - wellPaths.push_back(wellPath); + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } } } } + else + { + // No well path or well path collection selected + + auto allWellPaths = RiaApplication::instance()->project()->allWellPaths(); + for (const auto& w : allWellPaths) + { + if (w->showWellPath()) + { + wellPaths.push_back(w); + } + } + + } } std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 34ce8a2e14..e0d522a2ec 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -398,6 +398,7 @@ void RiuMainWindow::createMenus() exportMenu->addAction(cmdFeatureMgr->action("RicExportMultipleSnapshotsFeature")); exportMenu->addSeparator(); exportMenu->addAction(cmdFeatureMgr->action("RicSaveEclipseInputActiveVisibleCellsFeature")); + exportMenu->addAction(cmdFeatureMgr->action("RicExportCompletionsForVisibleWellPathsFeature")); fileMenu->addSeparator(); fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectFeature")); @@ -753,6 +754,10 @@ void RiuMainWindow::slotRefreshFileActions() CVF_ASSERT(cmdFeatureMgr); cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")->setEnabled(projectFileExists); + + QStringList commandIdList; + commandIdList << "RicExportCompletionsForVisibleWellPathsFeature"; + cmdFeatureMgr->refreshStates(commandIdList); } From b102b3025a4554a54293df98ab2a0056f97f2600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 20 Apr 2018 15:48:56 +0200 Subject: [PATCH 0747/1027] #2689 Ensemble curves. Hide legend when toggling off legend tree node --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 6f8e47779a..7065d265aa 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -549,7 +549,7 @@ void RimEnsembleCurveSet::updateCurveColors() firstAncestorOrThisOfType(plot); if (plot && plot->qwtPlot()) { - if (m_colorMode == BY_ENSEMBLE_PARAM) + if (m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) { plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); } From 1f8d4437bf55f38b57a6e0090a35e6ae0e389d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 10:13:43 +0200 Subject: [PATCH 0748/1027] Remove the unused, unnecessary "position" from several methods and the overlay layout struct --- .../RivTernarySaturationOverlayItem.cpp | 4 ++-- .../RivTernarySaturationOverlayItem.h | 2 +- .../ProjectDataModel/RimRegularLegendConfig.cpp | 2 +- ApplicationCode/UserInterface/RiuViewer.cpp | 2 +- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 10 +++++----- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h | 6 ++---- .../cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 10 +++++----- .../cafVizExtensions/cafOverlayScalarMapperLegend.h | 6 ++---- Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h | 2 +- 9 files changed, 20 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 2150a35556..739f2af6d2 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -43,7 +43,7 @@ RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) : TitledOverlayFrame(font, 120, 150) { - this->computeLayoutAndExtents(cvf::Vec2i(0, 0), this->sizeHint()); + this->computeLayoutAndExtents( this->sizeHint()); } //-------------------------------------------------------------------------------------------------- @@ -57,7 +57,7 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) +void RivTernarySaturationOverlayItem::computeLayoutAndExtents(const cvf::Vec2ui& size) { this->setMinimumWidth(size.x()); } diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index ee7f77603d..d7e73077de 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -41,7 +41,7 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); ~RivTernarySaturationOverlayItem(); - virtual void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + virtual void computeLayoutAndExtents(const cvf::Vec2ui& size) override; void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index f95ca3f985..fe651caf14 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -371,7 +371,7 @@ void RimRegularLegendConfig::updateLegend() numDecimalDigits -= static_cast(decadesInRange); } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); - m_scalarMapperLegend->computeLayoutAndExtents(cvf::Vec2i(0, 0), m_scalarMapperLegend->sizeHint()); + m_scalarMapperLegend->computeLayoutAndExtents( m_scalarMapperLegend->sizeHint()); RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 10ca6fb5d3..2411b1d504 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -622,7 +622,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend unsigned int requiredLegendWidth = 0u; for (auto legend : overlayItems) { - legend->computeLayoutAndExtents(cvf::Vec2i(0, 0), legend->sizeHint()); + legend->computeLayoutAndExtents(legend->sizeHint()); requiredLegendWidth = std::max(requiredLegendWidth, legend->minimumWidth()); } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index af676c5750..26efa853f3 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -41,7 +41,7 @@ namespace caf { CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) : TitledOverlayFrame(font, 200, 200) , m_categoryMapper(categoryMapper) - , m_Layout(Vec2i(0, 0), Vec2ui(200u, 200u)) + , m_Layout(Vec2ui(200u, 200u)) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -91,7 +91,7 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c { Recti oglRect(position, size.x(), size.y()); - OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height())); + OverlayColorLegendLayoutInfo layoutInViewPortCoords( Vec2ui(oglRect.width(), oglRect.height())); layoutInfo(&layoutInViewPortCoords); Vec2i legendBarOrigin = oglRect.min(); @@ -129,7 +129,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - this->computeLayoutAndExtents(position, size); + this->computeLayoutAndExtents(size); Vec2f backgroundSize(CVF_MIN((float)this->minimumWidth(), (float)size.x()), (float)size.y()); @@ -500,10 +500,10 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CategoryLegend::computeLayoutAndExtents(const Vec2i& position, const Vec2ui& size) +void CategoryLegend::computeLayoutAndExtents(const Vec2ui& size) { // Todo: Cache this between renderings. Update only when needed. - m_Layout = OverlayColorLegendLayoutInfo(position, size); + m_Layout = OverlayColorLegendLayoutInfo(size); layoutInfo(&m_Layout); m_textDrawer = new TextDrawer(this->font()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 2d3585c2f3..8c5d04fff6 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -31,7 +31,7 @@ class CategoryLegend : public caf::TitledOverlayFrame virtual ~CategoryLegend(); size_t categoryCount() const; - void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + void computeLayoutAndExtents(const cvf::Vec2ui& size) override; protected: void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; @@ -40,7 +40,7 @@ class CategoryLegend : public caf::TitledOverlayFrame struct OverlayColorLegendLayoutInfo { - OverlayColorLegendLayoutInfo(const cvf::Vec2i& pos, const cvf::Vec2ui& setSize) + OverlayColorLegendLayoutInfo(const cvf::Vec2ui& setSize) { charHeight = 0.0f; lineSpacing = 0.0f; @@ -49,7 +49,6 @@ class CategoryLegend : public caf::TitledOverlayFrame tickStartX = 0.0f; tickMidX = 0.0f; - position = pos; size = setSize; } @@ -60,7 +59,6 @@ class CategoryLegend : public caf::TitledOverlayFrame cvf::Rectf colorBarRect; - cvf::Vec2i position; cvf::Vec2ui size; }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 069719fabe..e1dce44148 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -86,7 +86,7 @@ OverlayScalarMapperLegend::OverlayScalarMapperLegend(Font* font) : TitledOverlayFrame(font, 200, 200) , m_tickNumberPrecision(4) , m_numberFormat(AUTO) - , m_Layout(Vec2i(0, 0), Vec2ui(200u, 200u)) + , m_Layout(Vec2ui(200u, 200u)) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -147,7 +147,7 @@ bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& { Recti oglRect(position, size.x(), size.y()); - OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height())); + OverlayColorLegendLayoutInfo layoutInViewPortCoords(Vec2ui(oglRect.width(), oglRect.height())); layoutInfo(&layoutInViewPortCoords); Vec2i legendBarOrigin = oglRect.min(); @@ -183,7 +183,7 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - this->computeLayoutAndExtents(position, size); + this->computeLayoutAndExtents( size); Vec2f backgroundSize((float)this->matchedWidth(), (float)size.y()); @@ -668,10 +668,10 @@ void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::computeLayoutAndExtents(const Vec2i& position, const Vec2ui& size) +void OverlayScalarMapperLegend::computeLayoutAndExtents( const Vec2ui& size) { // Todo: Cache this between renderings. Update only when needed. - //m_Layout = OverlayColorLegendLayoutInfo(position, size); + //m_Layout = OverlayColorLegendLayoutInfo( size ); layoutInfo(&m_Layout); m_textDrawer = new TextDrawer(this->font()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index 52c8d493c1..9254f4f32a 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -85,7 +85,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame void setTickPrecision(int precision); enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); - void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + void computeLayoutAndExtents(const cvf::Vec2ui& size) override; protected: void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; @@ -93,9 +93,8 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame struct OverlayColorLegendLayoutInfo { - OverlayColorLegendLayoutInfo(const Vec2i& pos, const Vec2ui& setSize) + OverlayColorLegendLayoutInfo(const Vec2ui& setSize) { - position = pos; size = setSize; } @@ -108,7 +107,6 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame cvf::ref tickYPixelPos; - Vec2i position; Vec2ui size; }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 76fb30370f..fb2bdab308 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -35,7 +35,7 @@ namespace caf { void setBackgroundColor(const cvf::Color4f& backgroundColor); void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); - virtual void computeLayoutAndExtents(const cvf::Vec2i& position, const cvf::Vec2ui& size) = 0; + virtual void computeLayoutAndExtents(const cvf::Vec2ui& size) = 0; virtual cvf::Vec2ui sizeHint() override; unsigned int minimumWidth(); From 0192f66a4d3d0ba6e9675fabde8679682fe5133a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 11:27:34 +0200 Subject: [PATCH 0749/1027] More renaming and reformatting of legend code --- .../cafVizExtensions/cafCategoryLegend.cpp | 4 +-- .../cafVizExtensions/cafCategoryLegend.h | 4 +-- .../cafOverlayScalarMapperLegend.cpp | 25 +++++++++++++++---- .../cafOverlayScalarMapperLegend.h | 4 +-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 26efa853f3..894dbd037d 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -225,7 +225,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, m_visibleCategoryLabels.push_back(true); } - float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight / 2.0f; + float titleY = static_cast(layout->overallLegendSize.y()) - layout->margins.y() - layout->charHeight / 2.0f; for (size_t it = 0; it < this->titleStrings().size(); it++) { Vec2f pos(layout->margins.x(), titleY); @@ -478,7 +478,7 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->margins = Vec2f(8.0f, 8.0f); float colorBarWidth = 25.0f; - float colorBarHeight = static_cast(layout->size.y()) + float colorBarHeight = static_cast(layout->overallLegendSize.y()) - 2 * layout->margins.y() - static_cast(this->titleStrings().size()) * layout->lineSpacing - layout->lineSpacing; diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 8c5d04fff6..25d6c303ca 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -49,7 +49,7 @@ class CategoryLegend : public caf::TitledOverlayFrame tickStartX = 0.0f; tickMidX = 0.0f; - size = setSize; + overallLegendSize = setSize; } float charHeight; @@ -59,7 +59,7 @@ class CategoryLegend : public caf::TitledOverlayFrame cvf::Rectf colorBarRect; - cvf::Vec2ui size; + cvf::Vec2ui overallLegendSize; }; void layoutInfo(OverlayColorLegendLayoutInfo* layout); diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index e1dce44148..459f732fad 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -154,7 +154,9 @@ bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& legendBarOrigin.x() += static_cast(layoutInViewPortCoords.colorBarRect.min().x()); legendBarOrigin.y() += static_cast(layoutInViewPortCoords.colorBarRect.min().y()); - Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.colorBarRect.width()), static_cast(layoutInViewPortCoords.colorBarRect.height())); + Recti legendBarRect = Recti(legendBarOrigin, + static_cast(layoutInViewPortCoords.colorBarRect.width()), + static_cast(layoutInViewPortCoords.colorBarRect.height())); if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) @@ -190,14 +192,27 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V // Do the actual rendering if (software) { - if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); + if ( this->backgroundEnabled() ) + { + InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + } renderLegendImmediateMode(oglContext, &m_Layout); m_textDrawer->renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); - if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, matrixState, backgroundSize, this->backgroundColor(), this->backgroundFrameColor()); + if ( this->backgroundEnabled() ) + { + InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + } renderLegendUsingShaders(oglContext, &m_Layout, matrixState); m_textDrawer->render(oglContext, camera); } @@ -276,7 +291,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov m_visibleTickLabels.push_back(true); } - float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight/2.0f; + float titleY = static_cast(layout->overallLegendSize.y()) - layout->margins.y() - layout->charHeight/2.0f; for (it = 0; it < this->titleStrings().size(); it++) { Vec2f pos(layout->margins.x(), titleY); @@ -609,7 +624,7 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->margins = Vec2f(8.0f, 8.0f); float colorBarWidth = 25.0f; - float colorBarHeight = static_cast(layout->size.y()) + float colorBarHeight = static_cast(layout->overallLegendSize.y()) - 2*layout->margins.y() - static_cast(this->titleStrings().size()) * layout->lineSpacing - layout->lineSpacing; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index 9254f4f32a..d7b6eb519f 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -95,7 +95,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame { OverlayColorLegendLayoutInfo(const Vec2ui& setSize) { - size = setSize; + overallLegendSize = setSize; } float charHeight; @@ -107,7 +107,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame cvf::ref tickYPixelPos; - Vec2ui size; + Vec2ui overallLegendSize; }; void layoutInfo(OverlayColorLegendLayoutInfo* layout); From 03ec76c20acb8955f3d2a303851de0d5d20e48c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 13:33:44 +0200 Subject: [PATCH 0750/1027] #2657 Add a preferredSize method to the legends --- .../RivTernarySaturationOverlayItem.cpp | 20 ++++++-- .../RivTernarySaturationOverlayItem.h | 7 ++- .../UserInterface/RiuCvfOverlayItemWidget.cpp | 9 ++-- .../cafVizExtensions/cafCategoryLegend.cpp | 34 ++++++++++++- .../cafVizExtensions/cafCategoryLegend.h | 3 ++ .../cafOverlayScalarMapperLegend.cpp | 48 ++++++++++++++++++- .../cafOverlayScalarMapperLegend.h | 4 ++ .../cafVizExtensions/cafTitledOverlayFrame.h | 4 +- 8 files changed, 116 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index 739f2af6d2..aa29298255 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -177,7 +177,7 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte textDrawer.renderSoftware(oglContext, camera); textPosY -= 3; - renderAxisImmediateMode(textPosY, 2*lineHeightInPixels + border, border, oglContext); + renderAxisImmediateMode(textPosY, 2*lineHeightInPixels + border, border, sizeFrameBox.x(), oglContext); CVF_CHECK_OGL(oglContext); } @@ -187,7 +187,11 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte //-------------------------------------------------------------------------------------------------- /// Draw the axis using immediate mode OpenGL //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, float lowerBoundY, float border, cvf::OpenGLContext* oglContext) +void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, + float lowerBoundY, + float border, + unsigned int totalWidth, + cvf::OpenGLContext* oglContext) { #ifdef CVF_OPENGL_ES CVF_UNUSED(layout); @@ -207,8 +211,8 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, //float upperBoundY = static_cast(this->sizeHint().y() - 20); cvf::Vec3f a(float(border), lowerBoundY, 0); - cvf::Vec3f b(static_cast(this->sizeHint().x() - border), lowerBoundY, 0); - cvf::Vec3f c(static_cast(this->sizeHint().x() / 2), upperBoundY, 0); + cvf::Vec3f b(static_cast(totalWidth - border), lowerBoundY, 0); + cvf::Vec3f c(static_cast(totalWidth / 2), upperBoundY, 0); // Draw filled rectangle elements @@ -256,3 +260,11 @@ void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange, m_sgasRange = sgasRange; m_swatRange = swatRange; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui RivTernarySaturationOverlayItem::preferredSize() +{ + return {120, 150}; // Could do more elaborate text width checks. +} diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index d7e73077de..914069e682 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -46,6 +46,7 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); void setAxisLabelsColor(const cvf::Color3f& color); + cvf::Vec2ui preferredSize() override; private: void render(cvf::OpenGLContext* oglContext, @@ -59,7 +60,11 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - void renderAxisImmediateMode(float upperY, float lowerBoundY, float border, cvf::OpenGLContext* oglContext); + void renderAxisImmediateMode(float upperY, + float lowerBoundY, + float border, + unsigned int totalWidth, + cvf::OpenGLContext* oglContext); private: cvf::String m_soilRange; diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index 88d46b6d8a..35b98d8b43 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -61,11 +61,10 @@ RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() //-------------------------------------------------------------------------------------------------- void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) { - //m_scalarMapperLegend->setTitle("Hei og hopp"); - //m_scalarMapperLegend->computeLayoutAndExtents({0,0}, {100, 400}); - //unsigned int width = m_scalarMapperLegend->minimumWidth() + 100; - unsigned int width = item->sizeHint().x(); - unsigned int height = item->sizeHint().y(); + // Use the render size of the overlayItem (sizeHint should be renamed) + + unsigned int width = item->sizeHint().x(); + unsigned int height = item->sizeHint().y(); QGLFormat glFormat; glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 894dbd037d..c534488fe7 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -179,7 +179,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, m_visibleCategoryLabels.clear(); - const float textX = layout->tickEndX + 5; + const float textX = layout->tickEndX + layout->tickTextLeadSpace; const float overlapTolerance = 1.2f * layout->charHeight; float lastVisibleTextY = 0.0; @@ -476,6 +476,7 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; layout->margins = Vec2f(8.0f, 8.0f); + layout->tickTextLeadSpace = 5.0f; float colorBarWidth = 25.0f; float colorBarHeight = static_cast(layout->overallLegendSize.y()) @@ -515,6 +516,37 @@ void CategoryLegend::computeLayoutAndExtents(const Vec2ui& size) this->setMinimumWidth(contentWidth); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui CategoryLegend::preferredSize() +{ + OverlayColorLegendLayoutInfo layout({200,200}); // Use default size + layoutInfo(&layout); + + unsigned int prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() )* layout.lineSpacing ; + + unsigned int maxTickTextWidth = 0; + for (size_t cIdx = 0; cIdx < m_categoryMapper->categoryCount(); ++cIdx ) + { + cvf::String cathegoryText = m_categoryMapper->textForCategoryIndex(cIdx); + unsigned int textWidth = this->font()->textExtent(cathegoryText).x(); + maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; + } + + unsigned int prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + + for (const cvf::String& titleLine : titleStrings()) + { + unsigned int titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; + } + + prefferredXSize = std::min(prefferredXSize, 400u); + + return { prefferredXSize, prefferredYSize }; + +} } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 25d6c303ca..f122b3bcd7 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -33,6 +33,8 @@ class CategoryLegend : public caf::TitledOverlayFrame size_t categoryCount() const; void computeLayoutAndExtents(const cvf::Vec2ui& size) override; + cvf::Vec2ui preferredSize() override; + protected: void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; @@ -56,6 +58,7 @@ class CategoryLegend : public caf::TitledOverlayFrame float lineSpacing; cvf::Vec2f margins; float tickStartX, tickMidX, tickEndX; + float tickTextLeadSpace; cvf::Rectf colorBarRect; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 459f732fad..aa25418f4e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -65,6 +65,7 @@ #include "cvfScalarMapper.h" #include #include "cvfRenderStateBlending.h" +#include namespace caf { @@ -235,7 +236,7 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov m_visibleTickLabels.clear(); - const float textX = layout->tickEndX + 5; + const float textX = layout->tickEndX + layout->tickTextLeadSpace; const float overlapTolerance = 1.2f * layout->charHeight; float lastVisibleTextY = 0.0; @@ -622,6 +623,7 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; layout->margins = Vec2f(8.0f, 8.0f); + layout->tickTextLeadSpace = 5.0f; float colorBarWidth = 25.0f; float colorBarHeight = static_cast(layout->overallLegendSize.y()) @@ -699,5 +701,49 @@ void OverlayScalarMapperLegend::computeLayoutAndExtents( const Vec2ui& size) this->setMinimumWidth(contentWidth); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui OverlayScalarMapperLegend::preferredSize() +{ + OverlayColorLegendLayoutInfo layout({200,200}); // Use default size + layoutInfo(&layout); + + unsigned int prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_tickValues.size() )* layout.lineSpacing ; + + unsigned int maxTickTextWidth = 0; + for (double tickValue : m_tickValues ) + { + String valueString; + switch ( m_numberFormat ) + { + case FIXED: + valueString = String::number(tickValue, 'f', m_tickNumberPrecision); + break; + case SCIENTIFIC: + valueString = String::number(tickValue, 'e', m_tickNumberPrecision); + break; + default: + valueString = String::number(tickValue); + break; + } + unsigned int textWidth = this->font()->textExtent(valueString).x(); + maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; + } + + unsigned int prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + + for (const cvf::String& titleLine : titleStrings()) + { + unsigned int titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; + } + + prefferredXSize = std::min(prefferredXSize, 400u); + + return { prefferredXSize, prefferredYSize }; + +} + } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index d7b6eb519f..c80bd98065 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -86,6 +86,9 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); void computeLayoutAndExtents(const cvf::Vec2ui& size) override; + + virtual cvf::Vec2ui preferredSize() override; + protected: void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; @@ -102,6 +105,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame float lineSpacing; Vec2f margins; float tickStartX, tickMidX, tickEndX; + float tickTextLeadSpace; Rectf colorBarRect; diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index fb2bdab308..686096593e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -37,7 +37,8 @@ namespace caf { virtual void computeLayoutAndExtents(const cvf::Vec2ui& size) = 0; - virtual cvf::Vec2ui sizeHint() override; + virtual cvf::Vec2ui preferredSize() = 0; + unsigned int minimumWidth(); unsigned int matchedWidth(); @@ -53,6 +54,7 @@ namespace caf { cvf::Font* font(); private: + cvf::Vec2ui sizeHint() override final; // Will return the size to use for rendering, and is really not a hint. cvf::Vec2ui m_sizeHint; // The desired pixel size of the color legend area unsigned int m_minimumWidth; // Minimum width required to fit content unsigned int m_matchedWidth; // Width matched to other legends (>= minimumWidth) From 3957027b4beb2514bdb14be0ac15f60704cbbd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 16:55:51 +0200 Subject: [PATCH 0751/1027] #2657 Final cleanup and refactoring of legends size system --- .../RivTernarySaturationOverlayItem.cpp | 11 +--- .../RivTernarySaturationOverlayItem.h | 1 - .../RimRegularLegendConfig.cpp | 1 - ApplicationCode/UserInterface/RiuViewer.cpp | 15 +++--- .../cafVizExtensions/cafCategoryLegend.cpp | 51 ++++++------------- .../cafVizExtensions/cafCategoryLegend.h | 4 +- .../cafOverlayScalarMapperLegend.cpp | 51 +++++-------------- .../cafOverlayScalarMapperLegend.h | 4 +- .../cafTitledOverlayFrame.cpp | 38 +++----------- .../cafVizExtensions/cafTitledOverlayFrame.h | 14 ++--- 10 files changed, 49 insertions(+), 141 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index aa29298255..fa8239daf0 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -43,7 +43,7 @@ RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) : TitledOverlayFrame(font, 120, 150) { - this->computeLayoutAndExtents( this->sizeHint()); + } //-------------------------------------------------------------------------------------------------- @@ -54,14 +54,6 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::computeLayoutAndExtents(const cvf::Vec2ui& size) -{ - this->setMinimumWidth(size.x()); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -102,7 +94,6 @@ void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglConte float border = 0.0f; cvf::Vec2ui sizeFrameBox = size; - sizeFrameBox.x() = this->matchedWidth(); // Match to other legends cvf::Camera camera; camera.setViewport(position.x(), position.y(), sizeFrameBox.x(), sizeFrameBox.y()); diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index 914069e682..af5db4772e 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -41,7 +41,6 @@ class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); ~RivTernarySaturationOverlayItem(); - virtual void computeLayoutAndExtents(const cvf::Vec2ui& size) override; void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index fe651caf14..93c5bd76c6 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -371,7 +371,6 @@ void RimRegularLegendConfig::updateLegend() numDecimalDigits -= static_cast(decadesInRange); } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); - m_scalarMapperLegend->computeLayoutAndExtents( m_scalarMapperLegend->sizeHint()); RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 2411b1d504..d1966b7a68 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -602,11 +602,11 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend if (catLegend->categoryCount() > categoryThreshold) { - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2 * border - axisCrossHeight - 2 * edgeAxisBorderHeight)); + catLegend->setRenderSize(cvf::Vec2ui(categoryWidth, height - 3 * border - axisCrossHeight - 2 * edgeAxisBorderHeight)); } else { - catLegend->setSizeHint(cvf::Vec2ui(200, 200)); + catLegend->setRenderSize(cvf::Vec2ui(categoryWidth, 200)); } xPos += categoryWidth + border; } @@ -615,20 +615,21 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend { item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - yPos += item->sizeHint().y() + border + edgeAxisBorderHeight; + yPos += item->renderSize().y() + border + edgeAxisBorderHeight; } } unsigned int requiredLegendWidth = 0u; for (auto legend : overlayItems) { - legend->computeLayoutAndExtents(legend->sizeHint()); - requiredLegendWidth = std::max(requiredLegendWidth, legend->minimumWidth()); + requiredLegendWidth = std::max(requiredLegendWidth, legend->preferredSize().x()); } for (auto legend : overlayItems) { - legend->setMatchedWidth(requiredLegendWidth); + cvf::Vec2ui widthAdjustedSize = legend->renderSize(); + widthAdjustedSize.x() = requiredLegendWidth; + legend->setRenderSize(widthAdjustedSize); } } @@ -890,7 +891,7 @@ cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend(int winPosX, int winPosY) for (auto overlayItem : m_visibleLegends) { if (overlayItem->layoutScheme() == cvf::OverlayItem::FIXED_POSITION && - overlayItem->pick(translatedMousePosX, translatedMousePosY, overlayItem->fixedPosition(), overlayItem->sizeHint())) + overlayItem->pick(translatedMousePosX, translatedMousePosY, overlayItem->fixedPosition(), overlayItem->renderSize())) { return overlayItem.p(); } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index c534488fe7..287acdbb88 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -29,6 +29,7 @@ #include "cvfScalarMapper.h" #include "cafInternalLegendRenderTools.h" +#include using namespace cvf; @@ -129,9 +130,15 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - this->computeLayoutAndExtents(size); + m_Layout = OverlayColorLegendLayoutInfo(size); + layoutInfo(&m_Layout); + m_textDrawer = new TextDrawer(this->font()); + + // Set up text drawer + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout); - Vec2f backgroundSize(CVF_MIN((float)this->minimumWidth(), (float)size.x()), (float)size.y()); + Vec2f backgroundSize(size); // Do the actual rendering if (software) @@ -162,8 +169,7 @@ void CategoryLegend::renderGeneric(OpenGLContext* oglContext, /// //-------------------------------------------------------------------------------------------------- void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, - const OverlayColorLegendLayoutInfo* layout, - float* maxLegendRightPos) + const OverlayColorLegendLayoutInfo* layout) { if (m_categoryMapper.isNull()) { @@ -172,8 +178,6 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, CVF_ASSERT(layout); - float legendRight = 0.0f; - textDrawer->setVerticalAlignment(TextDrawer::CENTER); textDrawer->setTextColor(this->textColor()); @@ -218,9 +222,6 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, Vec2f pos(textX, textY); textDrawer->addText(displayText, pos); - float neededRightPos = pos.x() + this->font()->textExtent(displayText).x(); - legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; - lastVisibleTextY = textY; m_visibleCategoryLabels.push_back(true); } @@ -231,13 +232,9 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, Vec2f pos(layout->margins.x(), titleY); textDrawer->addText(this->titleStrings()[it], pos); - float neededRightPos = pos.x() + this->font()->textExtent(this->titleStrings()[it]).x(); - legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; - titleY -= layout->lineSpacing; } - *maxLegendRightPos = legendRight; } //-------------------------------------------------------------------------------------------------- @@ -498,24 +495,6 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) layout->tickEndX = layout->tickMidX + 5; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::computeLayoutAndExtents(const Vec2ui& size) -{ - // Todo: Cache this between renderings. Update only when needed. - m_Layout = OverlayColorLegendLayoutInfo(size); - layoutInfo(&m_Layout); - m_textDrawer = new TextDrawer(this->font()); - - // Set up text drawer - float maxLegendRightPos = 0; - setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); - - unsigned int contentWidth = static_cast(cvf::Math::ceil(maxLegendRightPos + m_Layout.margins.x())); - this->setMinimumWidth(contentWidth); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -524,7 +503,7 @@ cvf::Vec2ui CategoryLegend::preferredSize() OverlayColorLegendLayoutInfo layout({200,200}); // Use default size layoutInfo(&layout); - unsigned int prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() )* layout.lineSpacing ; + float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() )* layout.lineSpacing ; unsigned int maxTickTextWidth = 0; for (size_t cIdx = 0; cIdx < m_categoryMapper->categoryCount(); ++cIdx ) @@ -534,17 +513,17 @@ cvf::Vec2ui CategoryLegend::preferredSize() maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; } - unsigned int prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + float prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; for (const cvf::String& titleLine : titleStrings()) { - unsigned int titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + float titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; } - prefferredXSize = std::min(prefferredXSize, 400u); + prefferredXSize = std::min(prefferredXSize, 400.0f); - return { prefferredXSize, prefferredYSize }; + return { (unsigned int)(std::ceil(prefferredXSize)), (unsigned int)(std::ceil(prefferredYSize)) }; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index f122b3bcd7..33090e6a39 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -31,7 +31,6 @@ class CategoryLegend : public caf::TitledOverlayFrame virtual ~CategoryLegend(); size_t categoryCount() const; - void computeLayoutAndExtents(const cvf::Vec2ui& size) override; cvf::Vec2ui preferredSize() override; @@ -72,8 +71,7 @@ class CategoryLegend : public caf::TitledOverlayFrame const cvf::Vec2ui& size, bool software); void setupTextDrawer(cvf::TextDrawer* textDrawer, - const OverlayColorLegendLayoutInfo* layout, - float* maxLegendRightPos); + const OverlayColorLegendLayoutInfo* layout); void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const cvf::MatrixState& matrixState); diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index aa25418f4e..8b564c3172 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -186,9 +186,15 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - this->computeLayoutAndExtents( size); + m_Layout = OverlayColorLegendLayoutInfo(size); + layoutInfo(&m_Layout); + m_textDrawer = new TextDrawer(this->font()); + + // Set up text drawer + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout ); - Vec2f backgroundSize((float)this->matchedWidth(), (float)size.y()); + Vec2f backgroundSize(size); // Do the actual rendering if (software) @@ -225,12 +231,10 @@ void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const V //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const OverlayColorLegendLayoutInfo* layout, float* maxLegendRightPos) +void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const OverlayColorLegendLayoutInfo* layout) { CVF_ASSERT(layout); - float legendRight = 0.0f; - textDrawer->setVerticalAlignment(TextDrawer::CENTER); textDrawer->setTextColor(this->textColor()); @@ -285,9 +289,6 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov Vec2f pos(textX, textY); textDrawer->addText(valueString, pos); - float neededRightPos = pos.x() + this->font()->textExtent(valueString).x(); - legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; - lastVisibleTextY = textY; m_visibleTickLabels.push_back(true); } @@ -298,14 +299,9 @@ void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const Ov Vec2f pos(layout->margins.x(), titleY); textDrawer->addText(this->titleStrings()[it], pos); - float neededRightPos = pos.x() + this->font()->textExtent(this->titleStrings()[it]).x(); - legendRight = legendRight >= neededRightPos ? legendRight :neededRightPos; - - titleY -= layout->lineSpacing; } - *maxLegendRightPos = legendRight; } @@ -682,25 +678,6 @@ void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) m_numberFormat = format; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void OverlayScalarMapperLegend::computeLayoutAndExtents( const Vec2ui& size) -{ - // Todo: Cache this between renderings. Update only when needed. - //m_Layout = OverlayColorLegendLayoutInfo( size ); - layoutInfo(&m_Layout); - - m_textDrawer = new TextDrawer(this->font()); - - // Set up text drawer - float maxLegendRightPos = 0; - setupTextDrawer(m_textDrawer.p(), &m_Layout, &maxLegendRightPos); - - unsigned int contentWidth = static_cast(cvf::Math::ceil(maxLegendRightPos + m_Layout.margins.x())); - this->setMinimumWidth(contentWidth); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -709,7 +686,7 @@ cvf::Vec2ui OverlayScalarMapperLegend::preferredSize() OverlayColorLegendLayoutInfo layout({200,200}); // Use default size layoutInfo(&layout); - unsigned int prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_tickValues.size() )* layout.lineSpacing ; + float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_tickValues.size() )* layout.lineSpacing ; unsigned int maxTickTextWidth = 0; for (double tickValue : m_tickValues ) @@ -731,17 +708,17 @@ cvf::Vec2ui OverlayScalarMapperLegend::preferredSize() maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; } - unsigned int prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + float prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; for (const cvf::String& titleLine : titleStrings()) { - unsigned int titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + float titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; } - prefferredXSize = std::min(prefferredXSize, 400u); + prefferredXSize = std::min(prefferredXSize, 400.0f); - return { prefferredXSize, prefferredYSize }; + return { (unsigned int)(std::ceil(prefferredXSize)), (unsigned int)(std::ceil(prefferredYSize)) }; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h index c80bd98065..2cb28c654d 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -85,7 +85,6 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame void setTickPrecision(int precision); enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; void setTickFormat(NumberFormat format); - void computeLayoutAndExtents(const cvf::Vec2ui& size) override; virtual cvf::Vec2ui preferredSize() override; @@ -126,8 +125,7 @@ class OverlayScalarMapperLegend : public caf::TitledOverlayFrame void renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout); void setupTextDrawer(TextDrawer* textDrawer, - const OverlayColorLegendLayoutInfo* layout, - float* maxLegendRightPos); + const OverlayColorLegendLayoutInfo* layout); protected: DoubleArray m_tickValues; // Ticks between each level + top and bottom of legend (n+1 entries) diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp index 14ce1943bd..4e7b1fe79a 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -13,8 +13,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- TitledOverlayFrame::TitledOverlayFrame(Font* font, unsigned int width, unsigned int height) : m_font(font) - , m_sizeHint(width, height) - , m_minimumWidth(0u) + , m_renderSize(width, height) , m_textColor(Color3::BLACK) , m_lineColor(Color3::BLACK) , m_lineWidth(1) @@ -31,26 +30,17 @@ namespace caf { //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - void TitledOverlayFrame::setSizeHint(const Vec2ui& size) + void TitledOverlayFrame::setRenderSize(const Vec2ui& size) { - m_sizeHint = size; - } - - //-------------------------------------------------------------------------------------------------- - /// Will also update the matched width since this should always be >= minimum width - //-------------------------------------------------------------------------------------------------- - void TitledOverlayFrame::setMinimumWidth(unsigned int width) - { - m_minimumWidth = width; - m_matchedWidth = std::max(m_minimumWidth, m_matchedWidth); + m_renderSize = size; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - void TitledOverlayFrame::setMatchedWidth(unsigned int width) + cvf::Vec2ui TitledOverlayFrame::renderSize() const { - m_matchedWidth = width; + return m_renderSize; } //-------------------------------------------------------------------------------------------------- @@ -124,23 +114,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- cvf::Vec2ui TitledOverlayFrame::sizeHint() { - return m_sizeHint; - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - unsigned int TitledOverlayFrame::minimumWidth() - { - return m_minimumWidth; - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - unsigned int TitledOverlayFrame::matchedWidth() - { - return m_matchedWidth; + return m_renderSize; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 686096593e..007713d9bb 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -21,9 +21,8 @@ namespace caf { TitledOverlayFrame(cvf::Font* font, unsigned int width = 100, unsigned int height = 200); virtual ~TitledOverlayFrame(); - virtual void setSizeHint(const cvf::Vec2ui& size); - void setMinimumWidth(unsigned int width); - void setMatchedWidth(unsigned int width); + void setRenderSize(const cvf::Vec2ui& size); + cvf::Vec2ui renderSize() const; void setTextColor(const cvf::Color3f& color); void setLineColor(const cvf::Color3f& lineColor); @@ -35,12 +34,7 @@ namespace caf { void setBackgroundColor(const cvf::Color4f& backgroundColor); void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); - virtual void computeLayoutAndExtents(const cvf::Vec2ui& size) = 0; - virtual cvf::Vec2ui preferredSize() = 0; - - unsigned int minimumWidth(); - unsigned int matchedWidth(); protected: cvf::Color3f textColor() const; @@ -55,9 +49,7 @@ namespace caf { private: cvf::Vec2ui sizeHint() override final; // Will return the size to use for rendering, and is really not a hint. - cvf::Vec2ui m_sizeHint; // The desired pixel size of the color legend area - unsigned int m_minimumWidth; // Minimum width required to fit content - unsigned int m_matchedWidth; // Width matched to other legends (>= minimumWidth) + cvf::Vec2ui m_renderSize; // The rendered size of the color legend area in pixels cvf::Color3f m_textColor; cvf::Color3f m_lineColor; From 72fc66f8276cfad7b10b1a380c93d9ab159487d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 16:58:00 +0200 Subject: [PATCH 0752/1027] #2657 Better initial position of Ensemble curve color legend. Use preferred size --- ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp | 6 +++++- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index 35b98d8b43..4ba0ae163a 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -33,7 +33,11 @@ RiuCvfOverlayItemWidget::RiuCvfOverlayItemWidget(QWidget* parent/*=0*/) : QWidget(parent) { - this->setLayout(new QHBoxLayout(this)); + auto hblayout = new QHBoxLayout(this); + hblayout->setMargin(0); + hblayout->setSpacing(0); + + this->setLayout(hblayout); m_overlayItemLabel = new QLabel(this); this->layout()->addWidget(m_overlayItemLabel); } diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 589d5869f2..8a5e77c320 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -178,7 +178,7 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * new RiuWidgetDragger(overlayWidget); m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget; - overlayWidget->move(30, 30); + overlayWidget->move(65, 30); } else { @@ -187,6 +187,9 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * if ( overlayWidget ) { + caf::TitledOverlayFrame* overlyItem = curveSetToShowLegendFor->legendConfig()->titledOverlayFrame(); + overlyItem->setRenderSize(overlyItem->preferredSize()); + overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame()); overlayWidget->show(); } From 4d1595681afc377165ee6e1fe1d0d3f46792d741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 18:34:36 +0200 Subject: [PATCH 0753/1027] #2657 Add title to legend, and hide the legend when ensemble curve set are not visible --- .../Summary/RimEnsembleCurveSet.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 7065d265aa..330119542b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -172,15 +172,6 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); - - if (m_showCurves() && m_colorMode() == BY_ENSEMBLE_PARAM) - { - parentPlot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); - } - else - { - parentPlot->qwtPlot()->removeEnsembleCurveSetLegend(this); - } } } @@ -507,6 +498,8 @@ void RimEnsembleCurveSet::updateCurveColors() { RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); QString parameterName = m_ensembleParameter(); + m_legendConfig->setTitle(parameterName); + if (group && !parameterName.isEmpty()) { double minValue = std::numeric_limits::infinity(); @@ -549,7 +542,7 @@ void RimEnsembleCurveSet::updateCurveColors() firstAncestorOrThisOfType(plot); if (plot && plot->qwtPlot()) { - if (m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) + if (isCurvesVisible() && m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) { plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); } From 48814e33c429c5d191bb6c3c8f8128ac5d1bc6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 18:36:29 +0200 Subject: [PATCH 0754/1027] #2775 Add progress when loading summary cases --- .../Summary/RimSummaryCaseMainCollection.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 99978b8170..ce1148bfe0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -30,6 +30,7 @@ #include "RimSummaryCaseCollection.h" #include +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimSummaryCaseMainCollection,"SummaryCaseCollection"); @@ -295,13 +296,19 @@ std::vector RimSummaryCaseMainCollection::summaryCase //-------------------------------------------------------------------------------------------------- void RimSummaryCaseMainCollection::loadAllSummaryCaseData() { - for (RimSummaryCase* sumCase : allSummaryCases()) + std::vector sumCases = allSummaryCases(); + + caf::ProgressInfo progInfo(sumCases.size(), "Loading Summary Cases"); + + for (size_t cIdx = 0; cIdx < sumCases.size(); ++cIdx) { + RimSummaryCase* sumCase = sumCases[cIdx]; if (sumCase) { sumCase->createSummaryReaderInterface(); addCaseRealizationParametersIfFound(*sumCase, sumCase->summaryHeaderFilename()); } + progInfo.incrementProgress(); } } From 977fe0fb963ebb557277be4329f182d9ac042e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 18:37:27 +0200 Subject: [PATCH 0755/1027] #2657 Make ensemble curve set legends appear in snapshot images --- .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 1be67dbfc6..687734dca5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1110,6 +1110,8 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //-------------------------------------------------------------------------------------------------- QImage RimSummaryPlot::snapshotWindowContent() { +#if 0 +// This does not work with the color legend widgets. Is there a reason for doing this, and not to grab the widget ? QImage image; if (m_qwtPlot) @@ -1124,6 +1126,16 @@ QImage RimSummaryPlot::snapshotWindowContent() plotRenderer.render(m_qwtPlot, &painter, rect); } + return image; + #endif + QImage image; + + if (m_qwtPlot) + { + QPixmap pix = QPixmap::grabWidget(m_qwtPlot); + image = pix.toImage(); + } + return image; } From c2704727cebb808f34b31b06f39b0e514bef271c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 19:30:12 +0200 Subject: [PATCH 0756/1027] #2657 Made a sensible stable default layout --- .../UserInterface/RiuSummaryQwtPlot.cpp | 51 ++++++++++++++++++- .../UserInterface/RiuSummaryQwtPlot.h | 2 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 8a5e77c320..557e312dbb 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -57,6 +57,7 @@ #include "RimEnsembleCurveSet.h" #include "RimRegularLegendConfig.h" #include "cafTitledOverlayFrame.h" +#include "RimEnsembleCurveSetCollection.h" //-------------------------------------------------------------------------------------------------- /// @@ -164,6 +165,40 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::updateEnsembleLegendLayout() +{ + const int startMarginX = 65; + const int startMarginY = 35; + const int spacing = 5; + + int xpos = startMarginX; + int ypos = startMarginY; + int maxColumnWidth = 0; + + for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSets()->curveSets()) + { + auto pairIt = m_ensembleLegendWidgets.find(curveSet); + if (pairIt != m_ensembleLegendWidgets.end()) + { + if (ypos + pairIt->second->height() + spacing > this->canvas()->height()) + { + xpos += spacing + maxColumnWidth; + ypos = startMarginY; + maxColumnWidth = 0; + } + + RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; + overlayWidget->move(xpos, ypos); + + ypos += pairIt->second->height() + spacing; + maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width()); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -175,10 +210,11 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * if (it == m_ensembleLegendWidgets.end() || it->second == nullptr) { overlayWidget = new RiuCvfOverlayItemWidget(this); + new RiuWidgetDragger(overlayWidget); m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget; - overlayWidget->move(65, 30); + } else { @@ -193,6 +229,8 @@ void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame()); overlayWidget->show(); } + + this->updateEnsembleLegendLayout(); } //-------------------------------------------------------------------------------------------------- @@ -207,6 +245,8 @@ void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curve m_ensembleLegendWidgets.erase(it); } + + this->updateEnsembleLegendLayout(); } //-------------------------------------------------------------------------------------------------- @@ -237,6 +277,15 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::resizeEvent(QResizeEvent *e) +{ + QwtPlot::resizeEvent(e); + updateEnsembleLegendLayout(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 69f35ecb00..28829053f0 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -78,10 +78,12 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; virtual void contextMenuEvent(QContextMenuEvent *) override; + virtual void resizeEvent(QResizeEvent *e) override; private: void setDefaults(); void selectClosestCurve(const QPoint& pos); + void updateEnsembleLegendLayout(); private slots: void onZoomedSlot( ); From 22a1448ea6e60f41f73a38b76d74fc95703bcc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 19:38:21 +0200 Subject: [PATCH 0757/1027] Fix gcc 6 linux errors --- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 3 ++- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 557e312dbb..e5c2b23eef 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -50,7 +50,6 @@ #include #include -#include #include "RiuWidgetDragger.h" #include "RiuCvfOverlayItemWidget.h" @@ -59,6 +58,8 @@ #include "cafTitledOverlayFrame.h" #include "RimEnsembleCurveSetCollection.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 8b564c3172..3b614cd8d3 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -66,6 +66,7 @@ #include #include "cvfRenderStateBlending.h" #include +#include namespace caf { From e2d5dd0381655c3b24674fa9718c51a5a9ed7158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 20 Apr 2018 19:57:40 +0200 Subject: [PATCH 0758/1027] #2657 Improved ensemble curve set legend placement and update --- .../UserInterface/RiuSummaryQwtPlot.cpp | 22 +++++++++---------- .../UserInterface/RiuSummaryQwtPlot.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index e5c2b23eef..ed6a469bd0 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -171,9 +171,9 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::updateEnsembleLegendLayout() { - const int startMarginX = 65; - const int startMarginY = 35; const int spacing = 5; + int startMarginX = this->canvas()->pos().x() + spacing; + int startMarginY = this->canvas()->pos().y() + spacing; int xpos = startMarginX; int ypos = startMarginY; @@ -278,15 +278,6 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuSummaryQwtPlot::resizeEvent(QResizeEvent *e) -{ - QwtPlot::resizeEvent(e); - updateEnsembleLegendLayout(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -407,6 +398,15 @@ void RiuSummaryQwtPlot::enableDateBasedBottomXAxis(QwtPlot* plot) plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::updateLayout() +{ + QwtPlot::updateLayout(); + updateEnsembleLegendLayout(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 28829053f0..a166206284 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -78,7 +78,7 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; virtual void contextMenuEvent(QContextMenuEvent *) override; - virtual void resizeEvent(QResizeEvent *e) override; + virtual void updateLayout() override; private: void setDefaults(); From 803b6b81796fe8fa37f83036daaa8408b12b496d Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 20 Apr 2018 16:08:17 +0200 Subject: [PATCH 0759/1027] 3D Well Log Curves(#2676): Enable pick selection of the 3D Tracks and curves --- .../WellLogCommands/CMakeLists_files.cmake | 2 + .../Ric3dWellLogCurveViewerEventHandler.cpp | 73 ++++++++ .../Ric3dWellLogCurveViewerEventHandler.h | 33 ++++ .../Riv3dWellLogCurveGeomertyGenerator.cpp | 170 ++++++++++-------- .../Riv3dWellLogCurveGeomertyGenerator.h | 43 ++--- .../Riv3dWellLogPlanePartMgr.cpp | 44 +++-- .../Riv3dWellLogPlanePartMgr.h | 12 +- .../Rim3dWellLogCurveCollection.cpp | 31 ++++ .../Completions/Rim3dWellLogCurveCollection.h | 7 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 25 +++ .../ProjectDataModel/Rim3dWellLogCurve.h | 32 +++- .../UserInterface/RiuViewerCommands.cpp | 5 + 12 files changed, 348 insertions(+), 129 deletions(-) create mode 100644 ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp create mode 100644 ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index dd55b9252d..2d98f85c33 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -27,6 +27,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -57,6 +58,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp new file mode 100644 index 0000000000..ea5337d7e8 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Ric3dWellLogCurveViewerEventHandler.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RiuMainWindow.h" +#include "RivObjectSourceInfo.h" + +#include "cvfPart.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Ric3dWellLogCurveViewerEventHandler* Ric3dWellLogCurveViewerEventHandler::instance() +{ + static Ric3dWellLogCurveViewerEventHandler* singleton = new Ric3dWellLogCurveViewerEventHandler; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) +{ + if (eventObject.m_partAndTriangleIndexPairs.empty()) return false; + + cvf::uint triangleIndex = cvf::UNDEFINED_UINT; + + const auto& partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); + const cvf::Part* part = partAndTriangleIndexPair.first; + + const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); + if (sourceInfo) + { + Rim3dWellLogCurveCollection* curveCollection = dynamic_cast(sourceInfo->object()); + if (curveCollection) + { + cvf::Vec3d closestPoint; + double measuredDepthAtPoint; + double valueAtPoint; + Rim3dWellLogCurve* curve = curveCollection->checkForCurveIntersection( + eventObject.m_globalIntersectionPoint, &closestPoint, &measuredDepthAtPoint, &valueAtPoint); + if (curve) + { + RiuMainWindow::instance()->selectAsCurrentItem(curve); + } + else + { + RiuMainWindow::instance()->selectAsCurrentItem(curveCollection); + } + return true; + } + } + return false; +} diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h new file mode 100644 index 0000000000..8299a191d7 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicViewerEventInterface.h" + +//================================================================================================== +/// +//================================================================================================== +class Ric3dWellLogCurveViewerEventHandler : public RicViewerEventInterface +{ +public: + static Ric3dWellLogCurveViewerEventHandler* instance(); + + bool handleEvent(const RicViewerEventObject& eventObject) override; +}; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 9d920eebd1..9088d2f5db 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -29,6 +29,7 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfBoundingBox.h" +#include "cvfMath.h" #include @@ -37,72 +38,25 @@ //-------------------------------------------------------------------------------------------------- Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath) : m_wellPath(wellPath) + , m_planeWidth(0.0) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref - Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - const std::vector& resultValues, - const std::vector& resultMds, - double minResultValue, - double maxResultValue, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth) const +void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const std::vector& resultValues, + const std::vector& resultMds, + double minResultValue, + double maxResultValue, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth) { - std::vector vertices; - std::vector indices; - - createCurveVerticesAndIndices(resultValues, - resultMds, - minResultValue, - maxResultValue, - planeAngle, - planeOffsetFromWellPathCenter, - planeWidth, - displayCoordTransform, - wellPathClipBoundingBox, - &vertices, - &indices); - - if (vertices.empty() || indices.empty()) - { - return nullptr; - } - - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); - - cvf::ref drawable = new cvf::DrawableGeo(); - - indexedUInt->setIndices(indexArray.p()); - drawable->addPrimitiveSet(indexedUInt.p()); - - cvf::ref vertexArray = new cvf::Vec3fArray(vertices); - drawable->setVertexArray(vertexArray.p()); - - return drawable; -} + m_planeWidth = planeWidth; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector& resultValues, - const std::vector& resultMds, - double minResultValue, - double maxResultValue, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - std::vector* vertices, - std::vector* indices) const -{ if (!wellPathGeometry()) return; if (wellPathGeometry()->m_wellPathPoints.empty()) return; if (!wellPathClipBoundingBox.isValid()) return; @@ -153,13 +107,15 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end()); // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size - std::vector resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), - resultValues.end()); + m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), + resultValues.end()); + m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), + resultMds.end()); double maxClampedResult = -HUGE_VAL; double minClampedResult = HUGE_VAL; - for (double& result : resultValuesForInterpolatedPoints) + for (double& result : m_curveValues) { if (!RigCurveDataTools::isValidValue(result, false)) continue; @@ -174,34 +130,54 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std return; } - vertices->resize(interpolatedWellPathPoints.size()); + m_curveVertices = std::vector(); + m_curveVertices.reserve(interpolatedWellPathPoints.size()); double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); - for (size_t i = 0; i < interpolatedCurveNormals.size(); i++) + for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++) { double scaledResult = 0; - if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false)) + if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) { scaledResult = - planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minClampedResult) * plotRangeToResultRangeFactor; + planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor; } - - (*vertices)[i] = cvf::Vec3f(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); + cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); + m_curveVertices.push_back(cvf::Vec3f(curvePoint)); } - std::vector> valuesIntervals = - RigCurveDataTools::calculateIntervalsOfValidValues(resultValuesForInterpolatedPoints, false); - - for (const std::pair& interval : valuesIntervals) + std::vector indices; + indices.reserve(interpolatedWellPathPoints.size()); + for (size_t i = 0; i < m_curveValues.size() - 1; ++i) { - for (size_t i = interval.first; i < interval.second; i++) + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) { - indices->push_back(cvf::uint(i)); - indices->push_back(cvf::uint(i + 1)); + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); } } + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + m_curveDrawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + m_curveDrawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices); + m_curveDrawable->setVertexArray(vertexArray.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogCurveGeometryGenerator::curveDrawable() +{ + return m_curveDrawable; } //-------------------------------------------------------------------------------------------------- @@ -211,3 +187,49 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const { return m_wellPath->wellPathGeometry(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtClosestPoint) const +{ + cvf::Vec3f globalIntersectionFloat(globalIntersection); + float closestDistance = m_planeWidth * 0.1; + *closestPoint = cvf::Vec3d::UNDEFINED; + *measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE; + *valueAtClosestPoint = cvf::UNDEFINED_DOUBLE; + if (m_curveVertices.size() < 2u) false; + CVF_ASSERT(m_curveVertices.size() == m_curveValues.size()); + for (size_t i = 1; i < m_curveVertices.size(); ++i) + { + bool validCurveSegment = RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i - 1], false); + if (validCurveSegment) + { + cvf::Vec3f a = m_curveVertices[i - 1]; + cvf::Vec3f b = m_curveVertices[i]; + cvf::Vec3f ap = globalIntersectionFloat - a; + cvf::Vec3f ab = b - a; + // Projected point is clamped to one of the end points of the segment. + float distanceToProjectedPointAlongAB = ap * ab / (ab * ab); + float clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0f, 1.0f); + cvf::Vec3f projectionOfGlobalIntersection = a + clampedDistance * ab; + float distance = (projectionOfGlobalIntersection - globalIntersectionFloat).length(); + if (distance < closestDistance) + { + *closestPoint = cvf::Vec3d(projectionOfGlobalIntersection); + closestDistance = distance; + *measuredDepthAtPoint = m_curveMeasuredDepths[i - 1] * (1.0f - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; + *valueAtClosestPoint = m_curveValues[i - 1] * (1.0f - clampedDistance) + m_curveValues[i] * clampedDistance; + } + } + } + + if (closestPoint->isUndefined()) + return false; + + return true; +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index eaa2df0404..0f09fca27a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -43,32 +43,33 @@ class RimWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: + typedef std::pair PointValuePair; Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath); - cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - const std::vector& resultValues, - const std::vector& resultMds, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double minResultValue, - double maxResultValue) const; -private: - void createCurveVerticesAndIndices(const std::vector& resultValues, - const std::vector& resultMds, - double minResultValue, - double maxResultValue, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - std::vector* vertices, - std::vector* indices) const; + void createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const std::vector& resultValues, + const std::vector& resultMds, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double minResultValue, + double maxResultValue); const RigWellPath* wellPathGeometry() const; + cvf::ref curveDrawable(); + + bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtClosestPoint) const; + private: caf::PdmPointer m_wellPath; + cvf::ref m_curveDrawable; + std::vector m_curveVertices; + std::vector m_curveMeasuredDepths; + std::vector m_curveValues; + double m_planeWidth; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 33f541ebc9..bf7d916190 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -29,6 +29,7 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" #include "Riv3dWellLogGridGeomertyGenerator.h" +#include "RivObjectSourceInfo.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -51,7 +52,6 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri , m_gridView(gridView) { CVF_ASSERT(m_wellPath.notNull()); - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p()); } @@ -89,29 +89,34 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (!m_wellPath->rim3dWellLogCurveCollection()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; - const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - - size_t colorIndex = 0; + Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { - colorIndex++; + cvf::ref generator = rim3dWellLogCurve->geometryGenerator(); + if (generator.isNull()) + { + generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); + rim3dWellLogCurve->setGeometryGenerator(generator.p()); + } + if (!rim3dWellLogCurve->isShowingCurve()) continue; std::vector resultValues; std::vector resultMds; rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); - cvf::ref curveDrawable = - m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, - wellPathClipBoundingBox, - resultValues, - resultMds, - rim3dWellLogCurve->minCurveValue(), - rim3dWellLogCurve->maxCurveValue(), - planeAngle(curveCollection, rim3dWellLogCurve), - wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), - planeWidth()); + generator->createCurveDrawables(displayCoordTransform, + wellPathClipBoundingBox, + resultValues, + resultMds, + rim3dWellLogCurve->minCurveValue(), + rim3dWellLogCurve->maxCurveValue(), + planeAngle(curveCollection, rim3dWellLogCurve), + wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), + planeWidth()); + + cvf::ref curveDrawable = generator->curveDrawable(); if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { @@ -226,9 +231,9 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* const Rim3dWellLogCurve* rim3dWellLogCurve, double gridIntervalSize) { - const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - bool showGrid = curveCollection->isShowingGrid(); - bool showBackground = curveCollection->isShowingBackground(); + Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + bool showGrid = curveCollection->isShowingGrid(); + bool showBackground = curveCollection->isShowingBackground(); cvf::Color3f gridColor(0.4f, 0.4f, 0.4f); caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); @@ -249,12 +254,14 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); + cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); if (showBackground && background.notNull()) { cvf::ref part = createPart(background.p(), backgroundEffect.p()); if (part.notNull()) { model->addPart(part.p()); + part->setSourceInfo(sourceInfo.p()); } } @@ -282,6 +289,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* if (part.notNull()) { model->addPart(part.p()); + part->setSourceInfo(sourceInfo.p()); } } } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 860ddb9c9e..fa6b639612 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -20,13 +20,13 @@ #include "cvfBase.h" #include "cvfObject.h" +#include "cvfVector3.h" #include "Rim3dWellLogCurve.h" #include "Rim3dWellLogCurveCollection.h" #include "cafPdmPointer.h" -#include namespace cvf { @@ -45,7 +45,6 @@ class DisplayCoordTransform; class RimGridView; class RimWellPath; -class Riv3dWellLogCurveGeometryGenerator; class Riv3dWellLogGridGeometryGenerator; class Riv3dWellLogPlanePartMgr : public cvf::Object @@ -74,9 +73,8 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object double planeWidth() const; private: - cvf::ref m_3dWellLogCurveGeometryGenerator; - cvf::ref m_3dWellLogGridGeometryGenerator; - - caf::PdmPointer m_wellPath; - caf::PdmPointer m_gridView; + cvf::ref m_3dWellLogGridGeometryGenerator; + + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index bbe0e64ba3..fbf49270d9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -24,6 +24,7 @@ #include "RimProject.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "cvfMath.h" CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); @@ -176,6 +177,36 @@ void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve* Rim3dWellLogCurveCollection::checkForCurveIntersection(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) +{ + double smallestDistance = std::numeric_limits::max(); + Rim3dWellLogCurve* closestCurve = nullptr; + for (auto& wellLogCurve : m_3dWellLogCurves) + { + cvf::Vec3d closestPointOnCurve; + double measuredDepthAtPointOnCurve; + double valueAtPointOnCurve; + if (wellLogCurve->findClosestPointOnCurve(globalIntersection, &closestPointOnCurve, &measuredDepthAtPointOnCurve, &valueAtPointOnCurve)) + { + double distance = globalIntersection.pointDistance(closestPointOnCurve); + if (distance < smallestDistance) + { + closestCurve = wellLogCurve.p(); + *closestPoint = closestPointOnCurve; + *measuredDepthAtPoint = measuredDepthAtPointOnCurve; + *valueAtPoint = valueAtPointOnCurve; + } + } + } + return closestCurve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index 1a633d0478..f495e9ab0e 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -23,6 +23,9 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cvfBase.h" +#include "cvfVector3.h" + class Rim3dWellLogCurve; //================================================================================================== @@ -58,6 +61,10 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject std::vector vectorOf3dWellLogCurves() const; void redrawAffectedViewsAndEditors(); + Rim3dWellLogCurve* checkForCurveIntersection(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 75b3f2a0a5..05218ebe85 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -19,12 +19,15 @@ #include "Rim3dWellLogCurve.h" #include "RigCurveDataTools.h" +#include "Riv3dWellLogCurveGeomertyGenerator.h" #include "Rim3dWellLogCurveCollection.h" #include "RimProject.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "cvfVector3.h" + #include #include // Needed for HUGE_VAL on Linux @@ -244,6 +247,28 @@ void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI() this->updateConnectedEditors(); } +void Rim3dWellLogCurve::setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator) +{ + m_geometryGenerator = generator; +} + +bool Rim3dWellLogCurve::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) const +{ + if (m_geometryGenerator.notNull()) + { + return m_geometryGenerator->findClosestPointOnCurve(globalIntersection, closestPoint, measuredDepthAtPoint, valueAtPoint); + } + return false; +} + +cvf::ref Rim3dWellLogCurve::geometryGenerator() +{ + return m_geometryGenerator; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 2702a3289a..979608b736 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -24,6 +24,11 @@ #include "cafPdmFieldCvfColor.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +class Riv3dWellLogCurveGeometryGenerator; + //================================================================================================== /// /// @@ -47,17 +52,26 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); - DrawPlane drawPlane() const; - cvf::Color3f color() const; - bool isShowingCurve() const; + DrawPlane drawPlane() const; + cvf::Color3f color() const; + bool isShowingCurve() const; + + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; + void setColor(const cvf::Color3f& color); - void setColor(const cvf::Color3f& color); + double minCurveValue() const; + double maxCurveValue() const; + void resetMinMaxValuesAndUpdateUI(); + bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) const; - double minCurveValue() const; - double maxCurveValue() const; - void resetMinMaxValuesAndUpdateUI(); + void setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator); + cvf::ref geometryGenerator(); + + protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -75,7 +89,7 @@ class Rim3dWellLogCurve : public caf::PdmObject caf::PdmField m_maxCurveValue; double m_minCurveDataValue; double m_maxCurveDataValue; - + cvf::ref m_geometryGenerator; private: caf::PdmField m_showCurve; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 714ebf12f5..3d93e42fa1 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -26,6 +26,7 @@ #include "RicEclipsePropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h" #include "RicViewerEventInterface.h" +#include "WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h" #include "WellPathCommands/RicIntersectionViewerEventHandler.h" #include "WellPathCommands/RicWellPathViewerEventHandler.h" @@ -121,6 +122,10 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) m_viewerEventHandlers.push_back(dynamic_cast(RicIntersectionViewerEventHandler::instance())); } + { + m_viewerEventHandlers.push_back(dynamic_cast(Ric3dWellLogCurveViewerEventHandler::instance())); + } + { m_viewerEventHandlers.push_back(dynamic_cast(RicWellPathViewerEventHandler::instance())); } From f507a35c8f54e5aef16f30c22072b0c3fea4b194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 23 Apr 2018 10:29:11 +0200 Subject: [PATCH 0760/1027] #2785 Fix crash detected by regression test. --- .../FileInterface/RifSummaryCaseRestartSelector.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 9eb4dc6542..fa80af028c 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -247,7 +247,11 @@ QStringList RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(const QS // Find summary header file names from eclipse case file names for (const auto& gridFile : gridFiles) { - summaryFiles.push_back(getSummaryFileFromGridFile(gridFile)); + QString sumFile = getSummaryFileFromGridFile(gridFile); + if (!sumFile.isEmpty()) + { + summaryFiles.push_back(sumFile); + } } return summaryFiles; } From 851e68ac31ec897f0befa0c013be9d322c5d2e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 23 Apr 2018 10:30:40 +0200 Subject: [PATCH 0761/1027] #2663 Code adjustment to avoid creating a geometry generator when not needed --- .../ModelVisualization/RivWellPathPartMgr.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 243abeb15a..5d53e9630d 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -305,14 +305,6 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); - // Generate the well path geometry as a line and pipe structure - - m_pipeGeomGenerator = new RivPipeGeometryGenerator; - - m_pipeGeomGenerator->setRadius(wellPathRadius); - m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - - std::vector clippedWellPathCenterLine; // Skip visualization if outside the domain of this case @@ -337,6 +329,13 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di } } + // Generate the well path geometry as a line and pipe structure + + m_pipeGeomGenerator = new RivPipeGeometryGenerator; + + m_pipeGeomGenerator->setRadius(wellPathRadius); + m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); + double horizontalLengthAlongWellToClipPoint = 0.0; size_t idxToFirstVisibleSegment = 0; if ( wellPathCollection->wellPathClip ) From 9d406fef8a5374975e4bab7a8481ffe46d537db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 23 Apr 2018 11:07:15 +0200 Subject: [PATCH 0762/1027] Fix crash in summary plot due to missing guarding in ensemble legend layout --- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index ed6a469bd0..6b566bd41a 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -179,6 +179,8 @@ void RiuSummaryQwtPlot::updateEnsembleLegendLayout() int ypos = startMarginY; int maxColumnWidth = 0; + if (!ownerPlotDefinition() || !ownerPlotDefinition()->ensembleCurveSets()) return; + for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSets()->curveSets()) { auto pairIt = m_ensembleLegendWidgets.find(curveSet); From c5e58df75158ecd15a5825a18f03d574d850444c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 23 Apr 2018 10:35:19 +0200 Subject: [PATCH 0763/1027] 3d Well Log Curves (#2783): Enable picking with the track background switched off. * Add part to the model, but set the color mask false, depth test/write off. * Result is an invisible part that is present for picking. --- .../Riv3dWellLogPlanePartMgr.cpp | 13 +++++++-- Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp | 27 ++++++++++++++----- Fwk/AppFwk/CommonCode/cafEffectGenerator.h | 5 ++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index bf7d916190..415f8104f0 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -240,6 +240,14 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* caf::MeshEffectGenerator gridBorderEffectGen(gridColor); caf::VectorEffectGenerator curveNormalsEffectGen; backgroundEffectGen.enableLighting(false); + + if (!showBackground) + { + // Make the background invisible but still present for picking. + backgroundEffectGen.enableColorMask(false); + backgroundEffectGen.enableDepthTest(false); + backgroundEffectGen.enableDepthWrite(false); + } bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, wellPathClipBoundingBox, @@ -255,7 +263,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); - if (showBackground && background.notNull()) + if (background.notNull()) { cvf::ref part = createPart(background.p(), backgroundEffect.p()); if (part.notNull()) @@ -265,7 +273,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - if (showGrid) { + if (showGrid) + { cvf::ref border = m_3dWellLogGridGeometryGenerator->border(); if (border.notNull()) { diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index 813bf2e423..f07976e1c7 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -43,6 +43,7 @@ #include "cvfMatrixState.h" #include "cvfRenderState_FF.h" #include "cvfRenderStateBlending.h" +#include "cvfRenderStateColorMask.h" #include "cvfRenderStateCullFace.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStateLine.h" @@ -264,6 +265,8 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, Polygo m_color = color; m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; + m_enableColorMask = true; + m_enableDepthTest = true; m_enableDepthWrite = true; m_enableLighting = true; } @@ -278,11 +281,12 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color3f& color, Polygo m_color = cvf::Color4f(color, 1.0f); m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; + m_enableColorMask = true; + m_enableDepthTest = true; m_enableDepthWrite = true; m_enableLighting = true; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -373,10 +377,17 @@ void SurfaceEffectGenerator::updateCommonEffect(cvf::Effect* effect) const effect->setRenderState(faceCulling.p()); } - if (!m_enableDepthWrite) + if (!m_enableColorMask) + { + cvf::ref color = new cvf::RenderStateColorMask(m_enableColorMask); + effect->setRenderState(color.p()); + } + + if (!m_enableDepthTest || !m_enableDepthWrite) { cvf::ref depth = new cvf::RenderStateDepth; - depth->enableDepthWrite(false); + depth->enableDepthTest(m_enableDepthTest); + depth->enableDepthWrite(m_enableDepthWrite); effect->setRenderState(depth.p()); } } @@ -390,11 +401,13 @@ bool SurfaceEffectGenerator::isEqual(const EffectGenerator* other) const if (otherSurfaceEffect) { - if (m_color == otherSurfaceEffect->m_color + if (m_color == otherSurfaceEffect->m_color && m_polygonOffset == otherSurfaceEffect->m_polygonOffset + && m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces + && m_enableColorMask == otherSurfaceEffect->m_enableColorMask + && m_enableDepthTest == otherSurfaceEffect->m_enableDepthTest && m_enableDepthWrite == otherSurfaceEffect->m_enableDepthWrite - && m_enableLighting == otherSurfaceEffect->m_enableLighting - && m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces) + && m_enableLighting == otherSurfaceEffect->m_enableLighting) { return true; } @@ -410,6 +423,8 @@ EffectGenerator* SurfaceEffectGenerator::copy() const { SurfaceEffectGenerator* effGen = new SurfaceEffectGenerator(m_color, m_polygonOffset); effGen->m_cullBackfaces = m_cullBackfaces; + effGen->m_enableColorMask = m_enableColorMask; + effGen->m_enableDepthTest = m_enableDepthTest; effGen->m_enableDepthWrite = m_enableDepthWrite; effGen->m_enableLighting = m_enableLighting; return effGen; diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h index 95875971b8..4ed3278d02 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h @@ -134,6 +134,9 @@ class SurfaceEffectGenerator : public EffectGenerator SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset); void setCullBackfaces(FaceCulling cullBackFaces) { m_cullBackfaces = cullBackFaces; } + + void enableColorMask(bool enableColors) { m_enableColorMask = enableColors; } + void enableDepthTest(bool enableTest) { m_enableDepthTest = enableTest; } void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } void enableLighting(bool enableLighting) { m_enableLighting = enableLighting; } @@ -151,6 +154,8 @@ class SurfaceEffectGenerator : public EffectGenerator cvf::Color4f m_color; PolygonOffset m_polygonOffset; FaceCulling m_cullBackfaces; + bool m_enableColorMask; + bool m_enableDepthTest; bool m_enableDepthWrite; bool m_enableLighting; }; From 765b170efd3af37f7e2ab23a24187db40b55c789 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 23 Apr 2018 11:18:41 +0200 Subject: [PATCH 0764/1027] 3d Well Log Curves (#2784): call createDisplayModelAndRedraw...() when adding LAS and RFT curves. * Causes the parts to be created and added to the model. * This is already done when adding extraction curves. --- .../Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp | 1 + .../Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp index e0be2d927f..00b1e8d1e9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -57,6 +57,7 @@ void RicAdd3dWellLogFileCurveFeature::onActionTriggered(bool isChecked) rim3dWellLogFileCurve->setDefaultFileCurveDataInfo(); + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); RiaApplication::instance()->project()->updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogFileCurve); diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp index b67f57feef..a715d82fe7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp @@ -60,6 +60,7 @@ void RicAdd3dWellLogRftCurveFeature::onActionTriggered(bool isChecked) Rim3dWellLogRftCurve* rim3dWellLogRftCurve = new Rim3dWellLogRftCurve(); selectedWellPath->add3dWellLogCurve(rim3dWellLogRftCurve); + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); RiaApplication::instance()->project()->updateConnectedEditors(); Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogRftCurve); From 517a557efe2448c41439814ddc1a21887258b056 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 23 Apr 2018 13:08:35 +0200 Subject: [PATCH 0765/1027] Legends (#2786): Fix Debug-build of Resinsight. --- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 8 ++++---- .../cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 287acdbb88..1a3d4b87a7 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -247,8 +247,8 @@ void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, CVF_CALLSITE_OPENGL(oglContext); CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); @@ -370,8 +370,8 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla CVF_FAIL_MSG("Not supported on OpenGL ES"); #else CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 3b614cd8d3..a66e2c9442 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -314,8 +314,8 @@ void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglConte CVF_CALLSITE_OPENGL(oglContext); CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); @@ -481,8 +481,8 @@ void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglCont CVF_FAIL_MSG("Not supported on OpenGL ES"); #else CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); From 51fb8a69357a3cb80671262224b85e475af4a050 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 23 Apr 2018 14:50:12 +0200 Subject: [PATCH 0766/1027] #2787 Import summary case does not work on linux * Make sure summary files are added to class member in getFilesToImportUsingPrefs. * The code used to return a vector of summary files, now just a boolean and the files are meant to be added to the vector for later retrieval. --- .../FileInterface/RifSummaryCaseRestartSelector.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index fa80af028c..9198c6d3fc 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -173,7 +173,6 @@ bool RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const std::vect //-------------------------------------------------------------------------------------------------- bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector>& initialFiles) { - std::vector filesToImport; RicSummaryCaseRestartDialogResult lastResult; m_gridFiles.clear(); @@ -186,15 +185,15 @@ bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { - filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) { - filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { - filesToImport.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); RifReaderEclipseSummary reader; bool hasWarnings = false; @@ -202,9 +201,9 @@ bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector for (const auto& rfi : restartFileInfos) { RifSummaryCaseFileInfo fi(rfi.fileName, false); - if (!vectorContains(filesToImport, fi)) + if (!vectorContains(m_summaryFileInfos, fi)) { - filesToImport.push_back(fi); + m_summaryFileInfos.push_back(fi); } } } From 54c7932806ddda0e457579dadd4ab4613158622f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 23 Apr 2018 16:35:19 +0200 Subject: [PATCH 0767/1027] Fix crashes when reading an odb file fails due to corruption --- .../RivGeoMechVizLogic.cpp | 11 +++++++++-- .../Rim3dOverlayInfoConfig.cpp | 4 +++- .../ProjectDataModel/RimCellRangeFilter.cpp | 4 ++++ .../RimGeoMechResultDefinition.cpp | 18 ++++++++++++------ .../UserInterface/RiuFemResultTextBuilder.cpp | 13 ++++++++----- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index c310c17460..6e84adbc19 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -184,8 +184,13 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: } RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr(pMgrKey); - RigGeoMechCaseData* caseData = m_geomechView->geoMechCase()->geoMechData(); - int partCount = caseData->femParts()->partCount(); + int partCount = 0; + RigGeoMechCaseData* caseData = nullptr; + if ( m_geomechView->geoMechCase() ) + { + caseData = m_geomechView->geoMechCase()->geoMechData(); + partCount = caseData->femParts()->partCount(); + } if (partMgrToUpdate->initializedFemPartCount() != partCount) { @@ -254,6 +259,8 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex) { + if (!m_geomechView->geoMechCase()) return; + size_t gridCount = m_geomechView->geoMechCase()->geoMechData()->femParts()->partCount(); if (gridCount == 0) return; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index d6b1aaff5c..a761bb0175 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -914,7 +914,9 @@ QString Rim3dOverlayInfoConfig::timeStepText(RimEclipseView* eclipseView) QString Rim3dOverlayInfoConfig::timeStepText(RimGeoMechView* geoMechView) { int currTimeStepIndex = geoMechView->currentTimeStep(); - QStringList timeSteps = geoMechView->geoMechCase()->timeStepStrings(); + + QStringList timeSteps; + if (geoMechView->geoMechCase()) timeSteps = geoMechView->geoMechCase()->timeStepStrings(); QString dateTimeString; if (currTimeStepIndex >= 0 && currTimeStepIndex < timeSteps.size()) diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index 82c4edc2ee..ecec2521cd 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -147,6 +147,8 @@ void RimCellRangeFilter::setDefaultValues() const cvf::StructGridInterface* grid = selectedGrid(); + if (!grid) return; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); @@ -208,6 +210,8 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, } const cvf::StructGridInterface* grid = selectedGrid(); + + if (!grid) return; if (field == &startIndexI || field == &cellCountI) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index d96100f54a..7da009b301 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -139,7 +139,10 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm if (m_compactionRefLayerUiField == (int)RigFemResultAddress::NO_COMPACTION) { - m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); + if (m_geomCase && m_geomCase->geoMechData() ) + { + m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); + } } } @@ -199,10 +202,13 @@ QList RimGeoMechResultDefinition::calculateValueOptions( } else if (&m_compactionRefLayerUiField == fieldNeedingOptions) { - size_t kCount = m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->gridPointCountK() - 1; - for (size_t layerIdx = 0; layerIdx < kCount; ++layerIdx) + if (m_geomCase->geoMechData()) { - options.push_back(caf::PdmOptionItemInfo(QString::number(layerIdx + 1), (int)layerIdx)); + size_t kCount = m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->gridPointCountK() - 1; + for ( size_t layerIdx = 0; layerIdx < kCount; ++layerIdx ) + { + options.push_back(caf::PdmOptionItemInfo(QString::number(layerIdx + 1), (int)layerIdx)); + } } } } @@ -288,7 +294,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha m_compactionRefLayer = m_compactionRefLayerUiField(); } - if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) + if (m_geomCase->geoMechData() && m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) { if (view) view->hasUserRequestedAnimation = true; } @@ -416,7 +422,7 @@ void RimGeoMechResultDefinition::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimGeoMechResultDefinition::loadResult() { - if (m_geomCase) + if (m_geomCase && m_geomCase->geoMechData()) { m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()); } diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 1157757aff..204860b147 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -215,12 +215,15 @@ QString RiuFemResultTextBuilder::formationDetails() size_t k = cvf::UNDEFINED_SIZE_T; { - RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); - if(geomData) + if ( m_reservoirView->geoMechCase() ) { - size_t i = 0; - size_t j = 0; - geomData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k); + RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + if ( geomData ) + { + size_t i = 0; + size_t j = 0; + geomData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k); + } } } From a9b1883dc8a39372ab8904cbe5a338d75bb85b7a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Apr 2018 22:52:44 +0200 Subject: [PATCH 0768/1027] #2663 Zoom All : Check if completions intersects bounding box of model --- .../ModelVisualization/RivWellPathPartMgr.cpp | 70 +++++++++++++------ .../ModelVisualization/RivWellPathPartMgr.h | 4 +- .../RivWellPathsPartMgr.cpp | 5 +- .../ModelVisualization/RivWellPathsPartMgr.h | 4 +- .../ProjectDataModel/RimEclipseView.cpp | 2 +- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 5d53e9630d..d2570f97f8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -88,7 +88,43 @@ RivWellPathPartMgr::~RivWellPathPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) +bool RivWellPathPartMgr::isWellPathWithinBoundingBox(const cvf::BoundingBox& wellPathClipBoundingBox) const +{ + if (!m_rimWellPath->wellPathGeometry()) return false; + + const std::vector& wellpathCenterLine = m_rimWellPath->wellPathGeometry()->m_wellPathPoints; + if (wellpathCenterLine.size() < 2) return false; + + // Skip visualization if outside the domain of this case + { + cvf::Vec3d casemax = wellPathClipBoundingBox.max(); + cvf::Vec3d casemin = wellPathClipBoundingBox.min(); + cvf::Vec3d caseext = wellPathClipBoundingBox.extent(); + + // Add up to the sealevel + cvf::BoundingBox relevantWellpathBBox = wellPathClipBoundingBox; + relevantWellpathBBox.add(cvf::Vec3d(casemax.x(), casemax.y(), 0.0)); + + // Add some sideways leeway + + cvf::Vec3d addSize = 3.0*cvf::Vec3d(caseext.x(), caseext.y(), 0.0); + relevantWellpathBBox.add(casemax + addSize); + relevantWellpathBBox.add(casemin - addSize); + + if (!RigWellPath::isPolylineTouchingBBox(wellpathCenterLine, relevantWellpathBBox)) + { + return false; + } + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, + const cvf::BoundingBox& wellPathClipBoundingBox) { if (m_rimView.isNull()) return; @@ -97,6 +133,8 @@ void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* m if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return; + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + for (RimWellPathFracture* f : m_rimWellPath->fractureCollection()->fractures()) { CVF_ASSERT(f); @@ -307,28 +345,6 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di std::vector clippedWellPathCenterLine; - // Skip visualization if outside the domain of this case - { - cvf::Vec3d casemax = wellPathClipBoundingBox.max(); - cvf::Vec3d casemin = wellPathClipBoundingBox.min(); - cvf::Vec3d caseext = wellPathClipBoundingBox.extent(); - - // Add up to the sealevel - cvf::BoundingBox relevantWellpathBBox = wellPathClipBoundingBox; - relevantWellpathBBox.add(cvf::Vec3d(casemax.x(), casemax.y(), 0.0)); - - // Add some sideways leeway - - cvf::Vec3d addSize = 3.0*cvf::Vec3d(caseext.x(), caseext.y(), 0.0); - relevantWellpathBBox.add(casemax + addSize); - relevantWellpathBBox.add(casemin - addSize); - - if ( !RigWellPath::isPolylineTouchingBBox(wellpathCenterLine, relevantWellpathBBox) ) - { - return; - } - } - // Generate the well path geometry as a line and pipe structure m_pipeGeomGenerator = new RivPipeGeometryGenerator; @@ -464,6 +480,8 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false ) return; + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, false); @@ -494,6 +512,8 @@ void RivWellPathPartMgr::appendFlattenedStaticGeometryPartsToModel(cvf::ModelBas double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox) { + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, true); @@ -536,6 +556,8 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* return; } + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false); appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); @@ -562,6 +584,8 @@ void RivWellPathPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBa if (m_rimWellPath.isNull()) return; + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, true); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index ab1f660877..39195027a2 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -81,7 +81,7 @@ class RivWellPathPartMgr : public cvf::Object double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox); - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const cvf::BoundingBox& wellPathClipBoundingBox); private: void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, @@ -113,6 +113,8 @@ class RivWellPathPartMgr : public cvf::Object inline RimWellPathCollection* wellPathCollection(); inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); + bool isWellPathWithinBoundingBox(const cvf::BoundingBox& wellPathClipBoundingBox) const; + private: caf::PdmPointer m_rimWellPath; caf::PdmPointer m_rimView; diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp index 8d4228836f..38cac4d069 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -61,7 +61,8 @@ void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model) +void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, + const cvf::BoundingBox& wellPathClipBoundingBox) { if (!isWellPathVisible()) return; @@ -69,7 +70,7 @@ void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* for (auto& partMgr : m_wellPathsPartMgrs) { - partMgr->appendStaticFracturePartsToModel(model); + partMgr->appendStaticFracturePartsToModel(model, wellPathClipBoundingBox); } } diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h index 62330ea03d..c3dbd73d8c 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -65,8 +65,8 @@ class RivWellPathsPartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox); - - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model); + + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const cvf::BoundingBox& wellPathClipBoundingBox); private: void clearGeometryCache(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 3ed7908914..b91b97abb8 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -511,7 +511,7 @@ void RimEclipseView::createDisplayModel() addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); - m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p()); + m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); m_wellPathPipeVizModel->updateBoundingBoxesRecursive(); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); From 9ac3d806e2eba1f2989746e1a9a6100108fe15ec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 23 Apr 2018 23:06:21 +0200 Subject: [PATCH 0769/1027] #2663 Rename --- ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigWellPath.cpp | 8 +++----- ApplicationCode/ReservoirDataModel/RigWellPath.h | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index d2570f97f8..453aa00993 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -111,7 +111,7 @@ bool RivWellPathPartMgr::isWellPathWithinBoundingBox(const cvf::BoundingBox& wel relevantWellpathBBox.add(casemax + addSize); relevantWellpathBBox.add(casemin - addSize); - if (!RigWellPath::isPolylineTouchingBBox(wellpathCenterLine, relevantWellpathBBox)) + if (!RigWellPath::isAnyPointInsideBoundingBox(wellpathCenterLine, relevantWellpathBBox)) { return false; } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index f76af2b5fe..73697b9d73 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -282,18 +282,16 @@ std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigWellPath::isPolylineTouchingBBox(const std::vector &polyLine, - const cvf::BoundingBox& caseBB) +bool RigWellPath::isAnyPointInsideBoundingBox(const std::vector& points, const cvf::BoundingBox& boundingBox) { - for ( const cvf::Vec3d& point : polyLine ) + for (const cvf::Vec3d& point : points) { - if ( caseBB.contains(point) ) return true; + if (boundingBox.contains(point)) return true; } return false; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index b61cbd35a2..7280a9a563 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -60,8 +60,8 @@ class RigWellPath : public cvf::Object std::vector wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const; - static bool isPolylineTouchingBBox(const std::vector &polyLine, - const cvf::BoundingBox& caseBB); + static bool isAnyPointInsideBoundingBox(const std::vector& points, const cvf::BoundingBox& boundingBox); + static std::vector clipPolylineStartAboveZ(const std::vector &polyLine, double maxZ, double * horizontalLengthAlongWellToClipPoint, From b6aa35bf110b311e110fe7ea41ca551107d19daf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Apr 2018 12:56:28 +0200 Subject: [PATCH 0770/1027] #2793 RegTest, Fault visibility : Add translation code for older project files --- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 2 +- .../ProjectDataModel/RimGridView.cpp | 21 +++++++++++++++++++ .../ProjectDataModel/RimGridView.h | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index b91b97abb8..d4c1ce3499 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -857,7 +857,7 @@ void RimEclipseView::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- void RimEclipseView::initAfterRead() { - RimViewWindow::initAfterRead(); + RimGridView::initAfterRead(); this->faultResultSettings()->setReservoirView(this); this->cellResult()->setReservoirView(this); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 842a3eb30b..e6517d6b0b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -582,7 +582,7 @@ void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //-------------------------------------------------------------------------------------------------- void RimGeoMechView::initAfterRead() { - RimViewWindow::initAfterRead(); + RimGridView::initAfterRead(); this->cellResult()->setGeoMechCase(m_geomechCase); this->updateUiIconFromToggleField(); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index bbd27691fa..5a1b2be9b7 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -268,6 +268,27 @@ Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const return m_overlayInfoConfig; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::initAfterRead() +{ + RimViewWindow::initAfterRead(); + + RimProject* proj = nullptr; + firstAncestorOrThisOfType(proj); + if (proj && proj->isProjectFileVersionEqualOrOlderThan("2018.1.1")) + { + // For version prior to 2018.1.1 : Grid visualization mode was derived from surfaceMode and meshMode + // Current : Grid visualization mode is directly defined by m_gridCollection->isActive + // This change was introduced in https://github.com/OPM/ResInsight/commit/f7bfe8d0 + + bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RimGridView::FULL_MESH)); + + m_gridCollection->isActive = isGridVisualizationModeBefore_2018_1_1; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h index 7d6baeebc1..cb4d8f2143 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.h +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -59,7 +59,7 @@ class RimGridView : public Rim3dView virtual bool isGridVisualizationMode() const override; protected: - + virtual void initAfterRead() override; virtual void onTimeStepChanged() override; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; virtual void selectOverlayInfoConfig() override; From f456911c800b052220959fc919ff2343be60b0f9 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 24 Apr 2018 14:12:02 +0200 Subject: [PATCH 0771/1027] #2794 Summary Case Import: Improve error reporting. * When an error is found with one summary case file, continue importing all the files that worked. * Report an error in the log window and a message box afterwards about the case that failed. * Fix crash when loading .EGRID file without a summary case. --- .../Tools/RiaImportEclipseCaseTools.cpp | 79 ++++++----- .../Commands/RicImportSummaryCaseFeature.cpp | 11 +- .../Commands/RicImportSummaryCasesFeature.cpp | 22 ++- .../Commands/RicSummaryCaseRestartDialog.cpp | 16 ++- .../Commands/RicSummaryCaseRestartDialog.h | 16 ++- .../FileInterface/RifReaderEclipseSummary.cpp | 23 ++- .../RifSummaryCaseRestartSelector.cpp | 133 +++++++++++++----- .../RifSummaryCaseRestartSelector.h | 15 +- 8 files changed, 209 insertions(+), 106 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index bbb7fc70f9..61d9702c65 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -21,6 +21,7 @@ #include "../SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "RiaApplication.h" +#include "RiaLogging.h" #include "RiaPreferences.h" #include "RifEclipseSummaryTools.h" @@ -51,6 +52,7 @@ #include "cafProgressInfo.h" #include +#include //-------------------------------------------------------------------------------------------------- @@ -64,11 +66,8 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file // Get list of files to import RifSummaryCaseRestartSelector selector; if(noDialog) selector.showDialog(false); - std::vector summaryFileInfos; - if (selector.getFilesToImportFromGridFiles(fileNames)) - { - summaryFileInfos = selector.summaryFileInfos(); - } + selector.determineFilesToImportFromGridFiles(fileNames); + std::vector summaryFileInfos = selector.summaryFileInfos(); // Import eclipse case files for (const QString& gridCaseFile : selector.gridCaseFiles()) @@ -80,52 +79,62 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file } // Import summary cases - RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; - std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(summaryFileInfos); - - for (RimSummaryCase* newSumCase : newSumCases) + if (!summaryFileInfos.empty()) { - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); - RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); - if (gridCase) + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(summaryFileInfos); + + for (RimSummaryCase* newSumCase : newSumCases) { - RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); - if (existingFileSummaryCase) + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); + RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); + if (gridCase) { - // Replace all occurrences of file sum with ecl sum + RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); + if (existingFileSummaryCase) + { + // Replace all occurrences of file sum with ecl sum - std::vector referringObjects; - existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); + std::vector referringObjects; + existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); - // UI settings of a curve filter is updated based - // on the new case association for the curves in the curve filter - // UI is updated by loadDataAndUpdate() + // UI settings of a curve filter is updated based + // on the new case association for the curves in the curve filter + // UI is updated by loadDataAndUpdate() - for (caf::PdmObjectHandle* objHandle : referringObjects) - { - RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); - if (summaryCurve) + for (caf::PdmObjectHandle* objHandle : referringObjects) { - RimSummaryCurveCollection* parentCollection = nullptr; - summaryCurve->firstAncestorOrThisOfType(parentCollection); - if (parentCollection) + RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); + if (summaryCurve) { - parentCollection->loadDataAndUpdate(true); - parentCollection->updateConnectedEditors(); - break; + RimSummaryCurveCollection* parentCollection = nullptr; + summaryCurve->firstAncestorOrThisOfType(parentCollection); + if (parentCollection) + { + parentCollection->loadDataAndUpdate(true); + parentCollection->updateConnectedEditors(); + break; + } } } - } - sumCaseColl->removeCase(existingFileSummaryCase); + sumCaseColl->removeCase(existingFileSummaryCase); - delete existingFileSummaryCase; + delete existingFileSummaryCase; - } + } - sumCaseColl->updateAllRequiredEditors(); + sumCaseColl->updateAllRequiredEditors(); + } } } + + if (selector.foundErrors()) + { + QString errorMessage = selector.createCombinedErrorMessage(); + RiaLogging::error(errorMessage); + } + return true; } diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index c71283f016..9c223179fc 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -73,15 +73,18 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) if (fileNames.isEmpty()) return; - if (RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(fileNames)) + std::vector newCases; + if (RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(fileNames, &newCases)) { - for(const auto& fileName : fileNames) RiaApplication::instance()->addToRecentFiles(fileName); + for (const RimSummaryCase* newCase : newCases) + { + RiaApplication::instance()->addToRecentFiles(newCase->summaryHeaderFilename()); + } } std::vector cases; app->project()->allCases(cases); - - if (cases.size() == 0) + if (cases.size() == 0 && !newCases.empty()) { RiuMainWindow::instance()->close(); } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index df4cc293df..d7ca987e85 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -19,6 +19,7 @@ #include "RicImportSummaryCasesFeature.h" #include "RiaApplication.h" +#include "RiaLogging.h" #include "RiaPreferences.h" #include "RicFileHierarchyDialog.h" @@ -40,6 +41,7 @@ #include #include +#include CAF_CMD_SOURCE_INIT(RicImportSummaryCasesFeature, "RicImportSummaryCasesFeature"); @@ -116,16 +118,24 @@ bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList if (!sumCaseColl) return false; RifSummaryCaseRestartSelector fileSelector; - std::vector importFileInfos; - if (fileSelector.getFilesToImportFromSummaryFiles(fileNames)) + fileSelector.determineFilesToImportFromSummaryFiles(fileNames); + + std::vector importFileInfos = fileSelector.summaryFileInfos(); + + if (!importFileInfos.empty()) { - importFileInfos = fileSelector.summaryFileInfos(); + std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos); + if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); } - std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos); + if (fileSelector.foundErrors()) + { + QString errorMessage = fileSelector.createCombinedErrorMessage(); + RiaLogging::error(errorMessage); + QMessageBox::warning(NULL, QString("Problem Importing Summary Case File(s)"), errorMessage); + } - if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); - return true; + return !importFileInfos.empty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 7054f82eaf..ff7569e042 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -208,7 +208,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If only grid file is present, return if (initialSummaryFile.isEmpty() && !initialGridFile.isEmpty()) { - return RicSummaryCaseRestartDialogResult(true, + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::OK, defaultSummaryImportOption, defaultGridImportOption, {}, @@ -229,7 +229,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If no restart files are found and no warnings, do not show dialog if (originFileInfos.empty() &&!hasWarnings) { - return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::OK, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); } RicSummaryCaseRestartDialogResult dialogResult; @@ -310,7 +310,13 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); - dialogResult = RicSummaryCaseRestartDialogResult(dialog.result() == QDialog::Accepted, + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::OK; + if (dialog.result() == QDialog::Rejected) + { + status = RicSummaryCaseRestartDialogResult::CANCELLED; + } + + dialogResult = RicSummaryCaseRestartDialogResult(status, dialog.selectedSummaryImportOption(), dialog.selectedGridImportOption(), {}, @@ -318,9 +324,9 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.applyToAllSelected()); } - if (!dialogResult.ok) + if (dialogResult.status != RicSummaryCaseRestartDialogResult::OK) { - return RicSummaryCaseRestartDialogResult(false, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); + return RicSummaryCaseRestartDialogResult(dialogResult.status, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); } dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(initialSummaryFile)); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 022ae4f6d7..0af3ec846f 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -102,19 +102,25 @@ private slots: class RicSummaryCaseRestartDialogResult { public: - RicSummaryCaseRestartDialogResult() : - ok(false), + enum Status + { + OK = 0, + CANCELLED = 1, + ERROR = 2 + }; + RicSummaryCaseRestartDialogResult(Status _status = ERROR) : + status(_status), summaryImportOption(RicSummaryCaseRestartDialog::IMPORT_ALL), gridImportOption(RicSummaryCaseRestartDialog::NOT_IMPORT), applyToAll(false) {} - RicSummaryCaseRestartDialogResult(bool _ok, + RicSummaryCaseRestartDialogResult(Status _status, RicSummaryCaseRestartDialog::ImportOptions _summaryImportOption, RicSummaryCaseRestartDialog::ImportOptions _gridImportOption, QStringList _summaryFiles, QStringList _gridFiles, bool _applyToAll) : - ok(_ok), + status(_status), summaryImportOption(_summaryImportOption), gridImportOption(_gridImportOption), summaryFiles(_summaryFiles), @@ -123,7 +129,7 @@ class RicSummaryCaseRestartDialogResult { } - bool ok; + Status status; RicSummaryCaseRestartDialog::ImportOptions summaryImportOption; RicSummaryCaseRestartDialog::ImportOptions gridImportOption; QStringList summaryFiles; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 720a602278..37a2bda0a3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -147,18 +147,6 @@ std::vector RifReaderEclipseSummary::getRestartFiles(const Q currFile.fileName = headerFileName; while(!currFile.fileName.isEmpty()) { - QString prevFile = currFile.fileName; - - currFile = getRestartFile(currFile.fileName); - - // Fix to stop potential infinite loop - if (currFile.fileName == prevFile) - { - m_warnings.push_back("RifReaderEclipseSummary: Restart file reference loop detected"); - *hasWarnings = true; - break; - } - // Due to a weakness in libecl regarding restart summary header file selection, // do some extra checking { @@ -187,6 +175,17 @@ std::vector RifReaderEclipseSummary::getRestartFiles(const Q break; } } + QString prevFile = currFile.fileName; + currFile = getRestartFile(currFile.fileName); + + // Fix to stop potential infinite loop + if (currFile.fileName == prevFile) + { + m_warnings.push_back("RifReaderEclipseSummary: Restart file reference loop detected"); + *hasWarnings = true; + break; + } + } if (!currFile.fileName.isEmpty()) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 9198c6d3fc..18fda3cf06 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -26,6 +26,7 @@ #include "RicSummaryCaseRestartDialog.h" #include "RifEclipseSummaryTools.h" +#include "RifReaderEclipseSummary.h" #include #include @@ -85,54 +86,58 @@ RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifSummaryCaseRestartSelector::getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) +void RifSummaryCaseRestartSelector::determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) { std::vector> files; for (QString f : initialSummaryFiles) { files.push_back(std::make_pair(f, "")); } - return getFilesToImport(files); + determineFilesToImport(files); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifSummaryCaseRestartSelector::getFilesToImportFromGridFiles(const QStringList& initialGridFiles) +void RifSummaryCaseRestartSelector::determineFilesToImportFromGridFiles(const QStringList& initialGridFiles) { std::vector> files; for (QString f : initialGridFiles) { files.push_back(std::make_pair(getSummaryFileFromGridFile(f), f)); } - return getFilesToImport(files); + determineFilesToImport(files); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifSummaryCaseRestartSelector::getFilesToImport(const std::vector>& initialFiles) +void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector>& initialFiles) { std::vector fileInfos; if (m_showDialog) { bool enableApplyToAllField = initialFiles.size() > 1; - return getFilesToImportByAskingUser(initialFiles, enableApplyToAllField); + determineFilesToImportByAskingUser(initialFiles, enableApplyToAllField); } else { - return getFilesToImportUsingPrefs(initialFiles); + determineFilesToImportUsingPrefs(initialFiles); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const std::vector>& initialFiles, - bool enableApplyToAllField) +void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std::vector>& initialFiles, + bool enableApplyToAllField) { RicSummaryCaseRestartDialogResult lastResult; + m_summaryFileInfos.clear(); + m_gridFiles.clear(); + m_summaryFileErrors.clear(); + for (const std::pair& initialFile : initialFiles) { RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile, @@ -140,8 +145,9 @@ bool RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const std::vect m_defaultSummaryImportMode, m_defaultGridImportMode, &lastResult); - if (result.ok) + switch (result.status) { + case RicSummaryCaseRestartDialogResult::OK: for (const QString& file : result.summaryFiles) { RifSummaryCaseFileInfo fi(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); @@ -156,54 +162,76 @@ bool RifSummaryCaseRestartSelector::getFilesToImportByAskingUser(const std::vect { m_gridFiles.push_back(gridFile); } - } - else + break; + case RicSummaryCaseRestartDialogResult::ERROR: { + // An error occurred with one of the files. The others may still have worked. + m_summaryFileErrors.push_back(initialFile.first); + break; + } + case RicSummaryCaseRestartDialogResult::CANCELLED: // Cancel pressed, cancel everything m_summaryFileInfos.clear(); m_gridFiles.clear(); - return false; + m_summaryFileErrors.clear(); } } - return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector>& initialFiles) +void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std::vector>& initialFiles) { RicSummaryCaseRestartDialogResult lastResult; + m_summaryFileInfos.clear(); m_gridFiles.clear(); + m_summaryFileErrors.clear(); for (const std::pair& initialFile : initialFiles) { QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.first); QString initialGridFile = RiaFilePathTools::toInternalSeparator(initialFile.second); - bool handleGridFile = !initialGridFile.isEmpty(); + bool handleSummaryFile = false; + bool handleGridFile = !initialGridFile.isEmpty(); - if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) - { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); - } - else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) - { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + RifReaderEclipseSummary reader; + if (!initialSummaryFile.isEmpty()) + { + RifRestartFileInfo fileInfo = reader.getFileInfo(initialSummaryFile); + if (!fileInfo.valid()) + { + m_summaryFileErrors.push_back(initialSummaryFile); + } + else + { + handleSummaryFile = true; + } } - else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + + if (handleSummaryFile) { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); - - RifReaderEclipseSummary reader; - bool hasWarnings = false; - std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); - for (const auto& rfi : restartFileInfos) + if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { - RifSummaryCaseFileInfo fi(rfi.fileName, false); - if (!vectorContains(m_summaryFileInfos, fi)) + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); + } + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) + { + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + } + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + { + m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + bool hasWarnings = false; + std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); + for (const auto& rfi : restartFileInfos) { - m_summaryFileInfos.push_back(fi); + RifSummaryCaseFileInfo fi(RiaFilePathTools::toInternalSeparator(rfi.fileName), false); + if (!vectorContains(m_summaryFileInfos, fi)) + { + m_summaryFileInfos.push_back(fi); + } } } } @@ -231,9 +259,46 @@ bool RifSummaryCaseRestartSelector::getFilesToImportUsingPrefs(const std::vector for (const QString& warning : reader.warnings()) RiaLogging::error(warning); } } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseRestartSelector::foundErrors() const +{ + return !m_summaryFileErrors.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QStringList& RifSummaryCaseRestartSelector::summaryFilesWithErrors() const +{ + return m_summaryFileErrors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifSummaryCaseRestartSelector::createCombinedErrorMessage() const +{ + QString errorMessage; + if (!m_summaryFileErrors.empty()) + { + errorMessage = QString("Failed to import the following summary file"); + if (m_summaryFileErrors.size() > 1) + { + errorMessage += QString("s"); + } + errorMessage += QString(":\n"); + for (const QString& fileWarning : m_summaryFileErrors) + { + errorMessage += fileWarning + QString("\n"); } } - return true; + return errorMessage; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index 837a42406d..fea270bad6 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -41,22 +41,26 @@ class RifSummaryCaseRestartSelector RifSummaryCaseRestartSelector(); ~RifSummaryCaseRestartSelector(); - bool getFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); - bool getFilesToImportFromGridFiles(const QStringList& initialGridFiles); + void determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); + void determineFilesToImportFromGridFiles(const QStringList& initialGridFiles); void showDialog(bool show) { m_showDialog = show; } std::vector summaryFileInfos() const { return m_summaryFileInfos; } QStringList gridCaseFiles() const { return m_gridFiles; } + bool foundErrors() const; + const QStringList& summaryFilesWithErrors() const; + QString createCombinedErrorMessage() const; + static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); static QString getSummaryFileFromGridFile(const QString& gridFile); private: - bool getFilesToImport(const std::vector>& initialFiles); + void determineFilesToImport(const std::vector>& initialFiles); - bool getFilesToImportByAskingUser(const std::vector>& initialFiles, + void determineFilesToImportByAskingUser(const std::vector>& initialFiles, bool enableApplyToAllField); - bool getFilesToImportUsingPrefs(const std::vector>& initialFiles); + void determineFilesToImportUsingPrefs(const std::vector>& initialFiles); bool m_showDialog; RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; @@ -64,6 +68,7 @@ class RifSummaryCaseRestartSelector std::vector m_summaryFileInfos; QStringList m_gridFiles; + QStringList m_summaryFileErrors; }; //================================================================================================== From e953d6800ced0367879fbd9d2b7563f950d4cc80 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 24 Apr 2018 15:55:51 +0200 Subject: [PATCH 0772/1027] #2795 Summary Case Import: When importing grids keep going even if summary file import fails. --- .../Commands/RicSummaryCaseRestartDialog.cpp | 53 ++++++--- .../Commands/RicSummaryCaseRestartDialog.h | 7 +- .../RifSummaryCaseRestartSelector.cpp | 104 +++++++++++++----- .../RifSummaryCaseRestartSelector.h | 41 ++++--- 4 files changed, 148 insertions(+), 57 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index ff7569e042..48ea405fe2 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -193,22 +193,48 @@ RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const std::pair& initialFiles, - bool showApplyToAllWidget, - ImportOptions defaultSummaryImportOption, - ImportOptions defaultGridImportOption, - RicSummaryCaseRestartDialogResult *lastResult, - QWidget *parent) +RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& initialSummaryFile, + const QString& initialGridFile, + bool failOnSummaryImportError, + bool showApplyToAllWidget, + ImportOptions defaultSummaryImportOption, + ImportOptions defaultGridImportOption, + RicSummaryCaseRestartDialogResult* lastResult, + QWidget* parent) { RicSummaryCaseRestartDialog dialog(parent); - QString initialSummaryFile = initialFiles.first; - QString initialGridFile = initialFiles.second; + bool handleSummaryFile = false; + + RifRestartFileInfo currentFileInfo; + if (!initialSummaryFile.isEmpty()) + { + currentFileInfo = dialog.getFileInfo(initialSummaryFile); + + if (!currentFileInfo.valid()) + { + if (failOnSummaryImportError) + { + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::ERROR); + } + } + else + { + handleSummaryFile = true; + } + } + bool handleGridFile = !initialGridFile.isEmpty(); // If only grid file is present, return - if (initialSummaryFile.isEmpty() && !initialGridFile.isEmpty()) + if (!handleSummaryFile && !initialGridFile.isEmpty()) { - return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::OK, + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::OK; + if (!initialSummaryFile.isEmpty()) + { + // We were meant to have a summary file but due to an error we don't. + status = RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING; + } + return RicSummaryCaseRestartDialogResult(status, defaultSummaryImportOption, defaultGridImportOption, {}, @@ -216,11 +242,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const lastResult && lastResult->applyToAll); } - RifRestartFileInfo currentFileInfo = dialog.getFileInfo(initialSummaryFile); - if (!currentFileInfo.valid()) - { - return RicSummaryCaseRestartDialogResult(); - } + RifReaderEclipseSummary reader; bool hasWarnings = false; @@ -311,6 +333,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.exec(); RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::OK; + if (dialog.result() == QDialog::Rejected) { status = RicSummaryCaseRestartDialogResult::CANCELLED; diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 0af3ec846f..b6e49b9e7c 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -52,7 +52,9 @@ class RicSummaryCaseRestartDialog : public QDialog RicSummaryCaseRestartDialog(QWidget* parent); ~RicSummaryCaseRestartDialog(); - static RicSummaryCaseRestartDialogResult openDialog(const std::pair& initialFiles, + static RicSummaryCaseRestartDialogResult openDialog(const QString& initialSummaryFile, + const QString& initialGridFile, + bool failOnSummaryImportError, bool showApplyToAllWidget, ImportOptions defaultSummaryImportOption, ImportOptions defaultGridImportOption, @@ -106,7 +108,8 @@ class RicSummaryCaseRestartDialogResult { OK = 0, CANCELLED = 1, - ERROR = 2 + SUMMARY_FILE_WARNING = 2, + ERROR = 3 }; RicSummaryCaseRestartDialogResult(Status _status = ERROR) : status(_status), diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 18fda3cf06..db7d1e51ba 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -88,10 +88,10 @@ RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() //-------------------------------------------------------------------------------------------------- void RifSummaryCaseRestartSelector::determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) { - std::vector> files; + std::vector files; for (QString f : initialSummaryFiles) { - files.push_back(std::make_pair(f, "")); + files.push_back(RifSummaryCaseFileImportInfo(f, "", true)); } determineFilesToImport(files); } @@ -101,10 +101,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportFromSummaryFiles(const //-------------------------------------------------------------------------------------------------- void RifSummaryCaseRestartSelector::determineFilesToImportFromGridFiles(const QStringList& initialGridFiles) { - std::vector> files; + std::vector files; for (QString f : initialGridFiles) { - files.push_back(std::make_pair(getSummaryFileFromGridFile(f), f)); + files.push_back(RifSummaryCaseFileImportInfo(getSummaryFileFromGridFile(f), f)); } determineFilesToImport(files); } @@ -112,7 +112,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImportFromGridFiles(const QS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector>& initialFiles) +void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector& initialFiles) { std::vector fileInfos; if (m_showDialog) @@ -129,7 +129,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector>& initialFiles, +void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std::vector& initialFiles, bool enableApplyToAllField) { RicSummaryCaseRestartDialogResult lastResult; @@ -138,16 +138,35 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std m_gridFiles.clear(); m_summaryFileErrors.clear(); - for (const std::pair& initialFile : initialFiles) + for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) { - RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile, + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile.summaryFileName(), + initialFile.gridFileName(), + initialFile.failOnSummaryFileError(), enableApplyToAllField, m_defaultSummaryImportMode, m_defaultGridImportMode, &lastResult); - switch (result.status) + + lastResult = result; + + if (result.status == RicSummaryCaseRestartDialogResult::CANCELLED) + { + // Cancel pressed, cancel everything and return early + m_summaryFileInfos.clear(); + m_gridFiles.clear(); + m_summaryFileErrors.clear(); + return; + } + + if (result.status == RicSummaryCaseRestartDialogResult::ERROR || + result.status == RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING) + { + // A summary import failure occurred with one of the files. The others may still have worked. + m_summaryFileErrors.push_back(initialFile.summaryFileName()); + } + else { - case RicSummaryCaseRestartDialogResult::OK: for (const QString& file : result.summaryFiles) { RifSummaryCaseFileInfo fi(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); @@ -156,24 +175,15 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std m_summaryFileInfos.push_back(fi); } } - lastResult = result; + } + if (result.status == RicSummaryCaseRestartDialogResult::OK || + result.status == RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING) + { for (const QString& gridFile : result.gridFiles) { m_gridFiles.push_back(gridFile); } - break; - case RicSummaryCaseRestartDialogResult::ERROR: - { - // An error occurred with one of the files. The others may still have worked. - m_summaryFileErrors.push_back(initialFile.first); - break; - } - case RicSummaryCaseRestartDialogResult::CANCELLED: - // Cancel pressed, cancel everything - m_summaryFileInfos.clear(); - m_gridFiles.clear(); - m_summaryFileErrors.clear(); } } } @@ -181,7 +191,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std::vector>& initialFiles) +void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std::vector& initialFiles) { RicSummaryCaseRestartDialogResult lastResult; @@ -189,10 +199,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: m_gridFiles.clear(); m_summaryFileErrors.clear(); - for (const std::pair& initialFile : initialFiles) + for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) { - QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.first); - QString initialGridFile = RiaFilePathTools::toInternalSeparator(initialFile.second); + QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.summaryFileName()); + QString initialGridFile = RiaFilePathTools::toInternalSeparator(initialFile.gridFileName()); bool handleSummaryFile = false; bool handleGridFile = !initialGridFile.isEmpty(); @@ -203,6 +213,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: if (!fileInfo.valid()) { m_summaryFileErrors.push_back(initialSummaryFile); + if (initialFile.failOnSummaryFileError()) + { + handleGridFile = false; + } } else { @@ -340,3 +354,39 @@ QString RifSummaryCaseRestartSelector::getSummaryFileFromGridFile(const QString& } return ""; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseFileImportInfo::RifSummaryCaseFileImportInfo(const QString& summaryFileName, + const QString& gridFileName, + bool failOnSummaryFileImportError /*= false*/) + : m_summaryFileName(summaryFileName) + , m_gridFileName(gridFileName) + , m_failOnSummaryFileImportError(failOnSummaryFileImportError) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileImportInfo::failOnSummaryFileError() const +{ + return m_failOnSummaryFileImportError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::summaryFileName() const +{ + return m_summaryFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::gridFileName() const +{ + return m_gridFileName; +} \ No newline at end of file diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index fea270bad6..fda07b1e4b 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -26,10 +26,9 @@ #include #include -#include class RifSummaryCaseFileInfo; - +class RifSummaryCaseFileImportInfo; //================================================================================================== // @@ -56,19 +55,17 @@ class RifSummaryCaseRestartSelector static QString getSummaryFileFromGridFile(const QString& gridFile); private: - void determineFilesToImport(const std::vector>& initialFiles); - - void determineFilesToImportByAskingUser(const std::vector>& initialFiles, - bool enableApplyToAllField); - void determineFilesToImportUsingPrefs(const std::vector>& initialFiles); + void determineFilesToImport(const std::vector& initialFiles); + void determineFilesToImportByAskingUser(const std::vector& initialFiles, bool enableApplyToAllField); + void determineFilesToImportUsingPrefs(const std::vector& initialFiles); - bool m_showDialog; - RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; - RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; + bool m_showDialog; + RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; + RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; - std::vector m_summaryFileInfos; - QStringList m_gridFiles; - QStringList m_summaryFileErrors; + std::vector m_summaryFileInfos; + QStringList m_gridFiles; + QStringList m_summaryFileErrors; }; //================================================================================================== @@ -86,3 +83,21 @@ class RifSummaryCaseFileInfo bool operator<(const RifSummaryCaseFileInfo& other) const { return fileName < other.fileName; } bool operator==(const RifSummaryCaseFileInfo& other) const { return fileName == other.fileName; } }; + +//================================================================================================== +/// +//================================================================================================== +class RifSummaryCaseFileImportInfo +{ +public: + RifSummaryCaseFileImportInfo(const QString& summaryFileName, const QString& gridFileName, bool failOnSummaryFileImportError = false); + + const QString& summaryFileName() const; + const QString& gridFileName() const; + bool failOnSummaryFileError() const; + +private: + QString m_summaryFileName; + QString m_gridFileName; + bool m_failOnSummaryFileImportError; +}; From c5e4bf93a60afdb468a23c030f20ca6b8023eb42 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 25 Apr 2018 08:57:00 +0200 Subject: [PATCH 0773/1027] Summary Case Import cleanup (#2795) --- .../Tools/RiaImportEclipseCaseTools.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 2 +- .../RifSummaryCaseRestartSelector.cpp | 125 ++++++++++++++---- .../RifSummaryCaseRestartSelector.h | 60 +++++---- .../Summary/RimSummaryCaseMainCollection.cpp | 20 +-- .../Summary/RimSummaryCaseMainCollection.h | 6 +- 6 files changed, 150 insertions(+), 65 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 61d9702c65..add46133d6 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -67,7 +67,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file RifSummaryCaseRestartSelector selector; if(noDialog) selector.showDialog(false); selector.determineFilesToImportFromGridFiles(fileNames); - std::vector summaryFileInfos = selector.summaryFileInfos(); + std::vector summaryFileInfos = selector.summaryFileInfos(); // Import eclipse case files for (const QString& gridCaseFile : selector.gridCaseFiles()) diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index d7ca987e85..4ecd413135 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -120,7 +120,7 @@ bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList RifSummaryCaseRestartSelector fileSelector; fileSelector.determineFilesToImportFromSummaryFiles(fileNames); - std::vector importFileInfos = fileSelector.summaryFileInfos(); + std::vector importFileInfos = fileSelector.summaryFileInfos(); if (!importFileInfos.empty()) { diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index db7d1e51ba..7e5466c79b 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -91,7 +91,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportFromSummaryFiles(const std::vector files; for (QString f : initialSummaryFiles) { - files.push_back(RifSummaryCaseFileImportInfo(f, "", true)); + RifSummaryCaseFileImportInfo importInfo(f, ""); + importInfo.setFailOnSummaryFileError(true); + files.push_back(importInfo); + } determineFilesToImport(files); } @@ -104,17 +107,43 @@ void RifSummaryCaseRestartSelector::determineFilesToImportFromGridFiles(const QS std::vector files; for (QString f : initialGridFiles) { - files.push_back(RifSummaryCaseFileImportInfo(getSummaryFileFromGridFile(f), f)); + RifSummaryCaseFileImportInfo importInfo(getSummaryFileFromGridFile(f), f); + importInfo.setFailOnSummaryFileError(false); + files.push_back(importInfo); } determineFilesToImport(files); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::showDialog(bool show) +{ + m_showDialog = show; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::summaryFileInfos() const +{ + return m_summaryFileInfos; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifSummaryCaseRestartSelector::gridCaseFiles() const +{ + return m_gridFiles; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector& initialFiles) { - std::vector fileInfos; + std::vector fileInfos; if (m_showDialog) { bool enableApplyToAllField = initialFiles.size() > 1; @@ -169,10 +198,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std { for (const QString& file : result.summaryFiles) { - RifSummaryCaseFileInfo fi(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); - if (!vectorContains(m_summaryFileInfos, fi)) + RifSummaryCaseFileResultInfo resultFileInfo(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); + if (!vectorContains(m_summaryFileInfos, resultFileInfo)) { - m_summaryFileInfos.push_back(fi); + m_summaryFileInfos.push_back(resultFileInfo); } } } @@ -228,23 +257,23 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: { if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, true)); + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, true)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, false)); } else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) { - m_summaryFileInfos.push_back(RifSummaryCaseFileInfo(initialSummaryFile, false)); + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, false)); bool hasWarnings = false; std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); for (const auto& rfi : restartFileInfos) { - RifSummaryCaseFileInfo fi(RiaFilePathTools::toInternalSeparator(rfi.fileName), false); - if (!vectorContains(m_summaryFileInfos, fi)) + RifSummaryCaseFileResultInfo resultFileInfo(RiaFilePathTools::toInternalSeparator(rfi.fileName), false); + if (!vectorContains(m_summaryFileInfos, resultFileInfo)) { - m_summaryFileInfos.push_back(fi); + m_summaryFileInfos.push_back(resultFileInfo); } } } @@ -261,10 +290,10 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); for (const auto& rfi : restartFileInfos) { - RifSummaryCaseFileInfo fi(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName), false); - if (!m_gridFiles.contains(fi.fileName) && QFileInfo(fi.fileName).exists()) + QString gridFileName = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName); + if (!m_gridFiles.contains(gridFileName) && QFileInfo(gridFileName).exists()) { - m_gridFiles.push_back(fi.fileName); + m_gridFiles.push_back(gridFileName); } } @@ -356,15 +385,31 @@ QString RifSummaryCaseRestartSelector::getSummaryFileFromGridFile(const QString& } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RifSummaryCaseFileImportInfo::RifSummaryCaseFileImportInfo(const QString& summaryFileName, - const QString& gridFileName, - bool failOnSummaryFileImportError /*= false*/) + const QString& gridFileName) : m_summaryFileName(summaryFileName) , m_gridFileName(gridFileName) - , m_failOnSummaryFileImportError(failOnSummaryFileImportError) + , m_failOnSummaryFileImportError(false) +{ + CVF_ASSERT(!m_summaryFileName.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::summaryFileName() const { + return m_summaryFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::gridFileName() const +{ + return m_gridFileName; } //-------------------------------------------------------------------------------------------------- @@ -378,7 +423,25 @@ bool RifSummaryCaseFileImportInfo::failOnSummaryFileError() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString& RifSummaryCaseFileImportInfo::summaryFileName() const +void RifSummaryCaseFileImportInfo::setFailOnSummaryFileError(bool failOnSummaryFileImportError) +{ + m_failOnSummaryFileImportError = failOnSummaryFileImportError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseFileResultInfo::RifSummaryCaseFileResultInfo(const QString& summaryFileName, bool includeRestartFiles) + : m_summaryFileName(summaryFileName) + , m_includeRestartFiles(includeRestartFiles) +{ + CVF_ASSERT(!m_summaryFileName.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileResultInfo::summaryFileName() const { return m_summaryFileName; } @@ -386,7 +449,23 @@ const QString& RifSummaryCaseFileImportInfo::summaryFileName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString& RifSummaryCaseFileImportInfo::gridFileName() const +bool RifSummaryCaseFileResultInfo::includeRestartFiles() const { - return m_gridFileName; -} \ No newline at end of file + return m_includeRestartFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileResultInfo::operator<(const RifSummaryCaseFileResultInfo& other) const +{ + return m_summaryFileName < other.summaryFileName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileResultInfo::operator==(const RifSummaryCaseFileResultInfo& other) const +{ + return m_summaryFileName == other.summaryFileName(); +} diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h index fda07b1e4b..bf6d1a69ff 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -27,8 +27,8 @@ #include #include -class RifSummaryCaseFileInfo; class RifSummaryCaseFileImportInfo; +class RifSummaryCaseFileResultInfo; //================================================================================================== // @@ -43,16 +43,15 @@ class RifSummaryCaseRestartSelector void determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); void determineFilesToImportFromGridFiles(const QStringList& initialGridFiles); - void showDialog(bool show) { m_showDialog = show; } - std::vector summaryFileInfos() const { return m_summaryFileInfos; } - QStringList gridCaseFiles() const { return m_gridFiles; } - bool foundErrors() const; - const QStringList& summaryFilesWithErrors() const; - QString createCombinedErrorMessage() const; + void showDialog(bool show); + std::vector summaryFileInfos() const; + QStringList gridCaseFiles() const; + bool foundErrors() const; + const QStringList& summaryFilesWithErrors() const; + QString createCombinedErrorMessage() const; - - static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); - static QString getSummaryFileFromGridFile(const QString& gridFile); + static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); + static QString getSummaryFileFromGridFile(const QString& gridFile); private: void determineFilesToImport(const std::vector& initialFiles); @@ -63,41 +62,48 @@ class RifSummaryCaseRestartSelector RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; - std::vector m_summaryFileInfos; - QStringList m_gridFiles; - QStringList m_summaryFileErrors; + std::vector m_summaryFileInfos; + QStringList m_gridFiles; + QStringList m_summaryFileErrors; }; //================================================================================================== /// //================================================================================================== -class RifSummaryCaseFileInfo +class RifSummaryCaseFileImportInfo { public: - RifSummaryCaseFileInfo(const QString _fileName, bool _includeRestartFiles) : - fileName(_fileName), includeRestartFiles(_includeRestartFiles) {} + RifSummaryCaseFileImportInfo(const QString& summaryFileName, + const QString& gridFileName); - QString fileName; - bool includeRestartFiles; + const QString& summaryFileName() const; + const QString& gridFileName() const; + bool failOnSummaryFileError() const; + void setFailOnSummaryFileError(bool failOnSummaryFileImportError); - bool operator<(const RifSummaryCaseFileInfo& other) const { return fileName < other.fileName; } - bool operator==(const RifSummaryCaseFileInfo& other) const { return fileName == other.fileName; } +private: + QString m_summaryFileName; + QString m_gridFileName; + bool m_failOnSummaryFileImportError; }; //================================================================================================== -/// +/// //================================================================================================== -class RifSummaryCaseFileImportInfo +class RifSummaryCaseFileResultInfo { public: - RifSummaryCaseFileImportInfo(const QString& summaryFileName, const QString& gridFileName, bool failOnSummaryFileImportError = false); + RifSummaryCaseFileResultInfo(const QString& summaryFileName, + bool includeRestartFiles); const QString& summaryFileName() const; - const QString& gridFileName() const; - bool failOnSummaryFileError() const; + bool includeRestartFiles() const; + + bool operator<(const RifSummaryCaseFileResultInfo& other) const; + bool operator==(const RifSummaryCaseFileResultInfo& other) const; private: QString m_summaryFileName; - QString m_gridFileName; - bool m_failOnSummaryFileImportError; + bool m_includeRestartFiles; }; + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index ce1148bfe0..8ed1c9bd30 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -117,7 +117,7 @@ void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCa QStringList summaryFileNames = RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(QStringList({ eclResCase->gridFileName() })); if (!summaryFileNames.isEmpty()) { - RifSummaryCaseFileInfo fileInfo(summaryFileNames.front(), false); + RifSummaryCaseFileResultInfo fileInfo(summaryFileNames.front(), false); createAndAddSummaryCasesFromFileInfos({ fileInfo }); } } @@ -315,7 +315,7 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) +std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) { std::vector newCases = createSummaryCasesFromFileInfos(summaryHeaderFileInfos); addCases(newCases); @@ -325,16 +325,16 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) +std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) { RimProject* project = RiaApplication::instance()->project(); std::vector sumCases; - for (RifSummaryCaseFileInfo fileInfo : summaryHeaderFileInfos) + for (RifSummaryCaseFileResultInfo fileInfo : summaryHeaderFileInfos) { RimEclipseCase* eclCase = nullptr; - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.fileName); + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.summaryFileName()); if (!gridCaseFile.isEmpty()) { eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); @@ -344,22 +344,22 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro { RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); newSumCase->setAssociatedEclipseCase(eclCase); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.summaryFileName()); sumCases.push_back(newSumCase); } else { RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles); - newSumCase->setSummaryHeaderFileName(fileInfo.fileName); + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); + newSumCase->setSummaryHeaderFileName(fileInfo.summaryFileName()); newSumCase->createSummaryReaderInterface(); newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName); + addCaseRealizationParametersIfFound(*newSumCase, fileInfo.summaryFileName()); sumCases.push_back(newSumCase); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 87d5e5f0cb..a3ef6d3bda 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -25,7 +25,7 @@ class RimSummaryCase; class RimEclipseResultCase; class RimSummaryCaseCollection; -class RifSummaryCaseFileInfo; +class RifSummaryCaseFileResultInfo; //================================================================================================== /// @@ -45,8 +45,8 @@ class RimSummaryCaseMainCollection : public caf::PdmObject std::vector summaryCaseCollections() const; void createSummaryCasesFromRelevantEclipseResultCases(); - std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); - std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; From a7c72b549b99c0fec890846c1752de8c1cf5d4f8 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 24 Apr 2018 16:02:45 +0200 Subject: [PATCH 0774/1027] #2790 Progress bar when importing summary cases. --- .../RifSummaryCaseRestartSelector.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 7e5466c79b..ae86f1aa17 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -28,6 +28,8 @@ #include "RifEclipseSummaryTools.h" #include "RifReaderEclipseSummary.h" +#include "cafProgressInfo.h" + #include #include @@ -166,7 +168,8 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std m_summaryFileInfos.clear(); m_gridFiles.clear(); m_summaryFileErrors.clear(); - + + caf::ProgressInfo progress(initialFiles.size(), QString("Importing files")); for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) { RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile.summaryFileName(), @@ -177,8 +180,6 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std m_defaultGridImportMode, &lastResult); - lastResult = result; - if (result.status == RicSummaryCaseRestartDialogResult::CANCELLED) { // Cancel pressed, cancel everything and return early @@ -206,14 +207,17 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std } } - if (result.status == RicSummaryCaseRestartDialogResult::OK || - result.status == RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING) + if (result.status != RicSummaryCaseRestartDialogResult::ERROR) { + lastResult = result; + for (const QString& gridFile : result.gridFiles) { m_gridFiles.push_back(gridFile); } } + + progress.incrementProgress(); } } @@ -228,6 +232,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: m_gridFiles.clear(); m_summaryFileErrors.clear(); + caf::ProgressInfo progress(initialFiles.size(), QString("Importing files")); for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) { QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.summaryFileName()); @@ -302,7 +307,9 @@ void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std:: for (const QString& warning : reader.warnings()) RiaLogging::error(warning); } } - } + } + + progress.incrementProgress(); } } From 87ccdd06afefc35c80226ae37f2bb7ea18daeb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 24 Apr 2018 17:49:47 +0200 Subject: [PATCH 0775/1027] #2768 First shot on faster search regime. Some issues left --- .../Commands/RicFileHierarchyDialog.cpp | 118 +++++++++++++++++- .../Commands/RicFileHierarchyDialog.h | 6 +- 2 files changed, 121 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 653fdb4fb3..9159ef1c79 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -267,7 +267,7 @@ void RicFileHierarchyDialog::clearFileList() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicFileHierarchyDialog::updateStatus(Status status, bool force) +void RicFileHierarchyDialog::updateStatus(Status status, bool force, const QString& extraText) { static time_t lastStatusUpdate = 0; time_t now = time(nullptr); @@ -284,6 +284,7 @@ void RicFileHierarchyDialog::updateStatus(Status status, bool force) else if (currStatus == WORKING_TEXT_1) newStatus = WORKING_TEXT_2; else if (currStatus == WORKING_TEXT_2) newStatus = WORKING_TEXT_3; else if (currStatus == WORKING_TEXT_3) newStatus = WORKING_TEXT_1; + newStatus += " " + extraText; } else if (status == NO_FILES_FOUND) { @@ -309,7 +310,10 @@ QStringList RicFileHierarchyDialog::findMatchingFiles() { if (m_rootDir->text().isEmpty()) return QStringList(); - const QStringList& dirs = buildDirectoryListRecursive(rootDir()); + //const QStringList& dirs = buildDirectoryListRecursive(rootDir()); + QStringList dirs; + buildDirectoryListRecursiveSimple(this->rootDir(), this->pathFilter(), &dirs ); + const QStringList& files = findFilesInDirs(dirs); for (const auto& file : files) @@ -367,6 +371,116 @@ QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& c return cancelPressed() ? QStringList() : allDirs; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& rootDir, + const QString& remainingPathFilter, + QStringList* accumulatedDirs) +{ + if (cancelPressed()) return; + + QString currentRemainingpathFilter = remainingPathFilter; + { + // Remove prefixing or trailing path separators from filter + + int pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + while ( pathSepIdx == 0 ) + { + currentRemainingpathFilter.remove(pathSepIdx, 1); + pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + } + + if ( currentRemainingpathFilter.endsWith(SEPARATOR) ) + { + currentRemainingpathFilter.chop(1); + } + } + + QString effectiveRootDir = rootDir; + { + // Remove trailing path separator from root + if ( effectiveRootDir.endsWith(SEPARATOR) ) + { + effectiveRootDir.chop(1); + } + } + + // Search pathfilter for the first wildcard. use the path up to that directory directly, short-cutting the search + { + std::set sortedWildCardPositions; + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("*")); + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("?")); + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("[")); + + int minWildCardPos = -1; + for ( int wildCardPos : sortedWildCardPositions ) + { + if ( wildCardPos == -1 ) continue; + + minWildCardPos = wildCardPos; + break; + } + + if ( minWildCardPos == -1 ) + { + effectiveRootDir += SEPARATOR + currentRemainingpathFilter; + currentRemainingpathFilter = ""; + //(*accumulatedDirs) += effectiveRootDir; + } + else + { + int pathSepPos = currentRemainingpathFilter.indexOf(SEPARATOR); + while ( pathSepPos != -1 && pathSepPos < minWildCardPos ) + { + effectiveRootDir += SEPARATOR + currentRemainingpathFilter.left(pathSepPos); + currentRemainingpathFilter.remove(0, pathSepPos + 1); // include the separator + minWildCardPos -= (pathSepPos + 1); + pathSepPos = currentRemainingpathFilter.indexOf(SEPARATOR); + } + } + } + + // Find the filter to use for this directory level + // Assumes no prefixed path separator + + QStringList subDirsFullPath; + { + int pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + QString currentDirNameFilter = currentRemainingpathFilter.left(pathSepIdx); + + if ( pathSepIdx == -1 ) + { + currentRemainingpathFilter = ""; + } + else + { + currentRemainingpathFilter.remove(0, pathSepIdx); + } + + if ( currentDirNameFilter.isEmpty() ) currentDirNameFilter = "*"; + + QDir qdir(effectiveRootDir, currentDirNameFilter, QDir::NoSort, QDir::Dirs | QDir::NoDotAndDotDot); + QStringList subDirs = qdir.entryList(); + + + for ( const QString& subDir : subDirs ) + { + QString fullPath = qdir.absoluteFilePath(subDir); + subDirsFullPath += fullPath; + (*accumulatedDirs) += fullPath; + } + } + + for (const QString& subDir : subDirsFullPath) + { + updateStatus(WORKING, true, subDir); + QApplication::processEvents(); + buildDirectoryListRecursiveSimple(subDir, currentRemainingpathFilter, accumulatedDirs); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 4ec28889db..0a2ba928da 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -62,12 +62,16 @@ class RicFileHierarchyDialog : public QDialog bool cancelPressed() const; void appendToFileList(const QString& fileName); void clearFileList(); - void updateStatus(Status status, bool force = false); + void updateStatus(Status status, bool force = false, const QString& extraText = ""); QString currentStatus() const; QStringList findMatchingFiles(); QStringList buildDirectoryListRecursive(const QString& currentDir, int level = 0); + void buildDirectoryListRecursiveSimple(const QString& rootDir, + const QString& remainingPathFilter, + QStringList* accumulatedDirs); + QStringList findFilesInDirs(const QStringList& dirs); From 9f43da2d10ece02345b119e779ac9665612fd97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 08:50:53 +0200 Subject: [PATCH 0776/1027] #2768 Fix missing matches when root + path filter ends with an exact dir-name --- .../Commands/RicFileHierarchyDialog.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 9159ef1c79..96c29fa4db 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -311,8 +311,13 @@ QStringList RicFileHierarchyDialog::findMatchingFiles() if (m_rootDir->text().isEmpty()) return QStringList(); //const QStringList& dirs = buildDirectoryListRecursive(rootDir()); + QStringList dirs; - buildDirectoryListRecursiveSimple(this->rootDir(), this->pathFilter(), &dirs ); + + if ( this->pathFilter().isEmpty() ) dirs.append(this->rootDir()); + + buildDirectoryListRecursiveSimple(this->rootDir(), this->pathFilter(), &dirs); + const QStringList& files = findFilesInDirs(dirs); @@ -406,7 +411,8 @@ void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& ro } } - // Search pathfilter for the first wildcard. use the path up to that directory directly, short-cutting the search + // Search pathfilter for the first wildcard. + // Use the path up to that directory directly, short-cutting the search { std::set sortedWildCardPositions; sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("*")); @@ -426,7 +432,6 @@ void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& ro { effectiveRootDir += SEPARATOR + currentRemainingpathFilter; currentRemainingpathFilter = ""; - //(*accumulatedDirs) += effectiveRootDir; } else { @@ -460,9 +465,20 @@ void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& ro if ( currentDirNameFilter.isEmpty() ) currentDirNameFilter = "*"; + + QDir qdir(effectiveRootDir, currentDirNameFilter, QDir::NoSort, QDir::Dirs | QDir::NoDotAndDotDot); - QStringList subDirs = qdir.entryList(); + // Add effectiveRoot if current dir name filter =""or"*" or "?" and currentRemainingpathFilter = "" + // and remainingPathFilter not empty + if ( (currentDirNameFilter == "*" || currentDirNameFilter == "?") + && currentRemainingpathFilter.isEmpty() + && !remainingPathFilter.isEmpty()) + { + (*accumulatedDirs) += qdir.absolutePath(); + } + + QStringList subDirs = qdir.entryList(); for ( const QString& subDir : subDirs ) { From cee99af32409e275e17245e9d4a409403b031250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 10:17:19 +0200 Subject: [PATCH 0777/1027] #2768 Improved progress feedback in FileHierarchy dialog --- .../Commands/RicFileHierarchyDialog.cpp | 57 +++++++++++-------- .../Commands/RicFileHierarchyDialog.h | 4 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 96c29fa4db..17000e886e 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -55,9 +55,8 @@ #define FIND_BUTTON_FIND_TEXT "Find" #define FIND_BUTTON_CANCEL_TEXT "Cancel" #define NO_FILES_FOUND_TEXT "No files found" -#define WORKING_TEXT_1 "Working ." -#define WORKING_TEXT_2 "Working .." -#define WORKING_TEXT_3 "Working ..." +#define SCANNING_DIRS_TEXT "Scanning Directories" +#define FINDING_FILES_TEXT "Finding Files" //-------------------------------------------------------------------------------------------------- /// Internal variables @@ -246,10 +245,9 @@ bool RicFileHierarchyDialog::cancelPressed() const //-------------------------------------------------------------------------------------------------- void RicFileHierarchyDialog::appendToFileList(const QString& fileName) { - if (currentStatus().startsWith(WORKING_TEXT_1)) clearFileList(); - QString itemText = fileName; - QListWidgetItem* item = new QListWidgetItem(itemText.remove(0, rootDir().size()), m_fileList); + itemText.remove(0, rootDir().size()); + QListWidgetItem* item = new QListWidgetItem(itemText, m_fileList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(Qt::Checked); } @@ -267,30 +265,39 @@ void RicFileHierarchyDialog::clearFileList() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicFileHierarchyDialog::updateStatus(Status status, bool force, const QString& extraText) +void RicFileHierarchyDialog::updateStatus(Status status, const QString& extraText) { + static int progressLoopStep = 0; static time_t lastStatusUpdate = 0; time_t now = time(nullptr); - // If less than one second since last update, then return - if (!force && now == lastStatusUpdate) return; - lastStatusUpdate = now; - QString newStatus; - if (status == WORKING) + if (status == SEARCHING_FOR_DIRS || status == SEARCHING_FOR_FILES ) { - QString currStatus = currentStatus(); - if (currStatus == "") newStatus = WORKING_TEXT_1; - else if (currStatus == WORKING_TEXT_1) newStatus = WORKING_TEXT_2; - else if (currStatus == WORKING_TEXT_2) newStatus = WORKING_TEXT_3; - else if (currStatus == WORKING_TEXT_3) newStatus = WORKING_TEXT_1; - newStatus += " " + extraText; + switch ( status ) + { + case SEARCHING_FOR_DIRS: newStatus = SCANNING_DIRS_TEXT; break; + case SEARCHING_FOR_FILES: newStatus = FINDING_FILES_TEXT; break; + } + + for (int progress = 0; progress < progressLoopStep; ++progress) + { + newStatus += " ."; + } + + if (now != lastStatusUpdate) progressLoopStep++; // If less than one second since last update, do not increment + + if (progressLoopStep >= 5) progressLoopStep = 0; + + if (!extraText.isEmpty()) newStatus += "\n" + extraText; } else if (status == NO_FILES_FOUND) { newStatus = NO_FILES_FOUND_TEXT; } + lastStatusUpdate = now; + m_fileList->clear(); new QListWidgetItem(newStatus, m_fileList); } @@ -318,9 +325,10 @@ QStringList RicFileHierarchyDialog::findMatchingFiles() buildDirectoryListRecursiveSimple(this->rootDir(), this->pathFilter(), &dirs); - const QStringList& files = findFilesInDirs(dirs); + this->clearFileList(); + for (const auto& file : files) { appendToFileList(file); @@ -369,9 +377,10 @@ QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& c QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (QString subDir : subDirs) { - updateStatus(WORKING); + QString subDirFullPath = qdir.absoluteFilePath(subDir); + updateStatus(SEARCHING_FOR_DIRS, subDirFullPath); QApplication::processEvents(); - allDirs += buildDirectoryListRecursive(qdir.absoluteFilePath(subDir), level + 1); + allDirs += buildDirectoryListRecursive(subDirFullPath, level + 1); } return cancelPressed() ? QStringList() : allDirs; } @@ -490,7 +499,7 @@ void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& ro for (const QString& subDir : subDirsFullPath) { - updateStatus(WORKING, true, subDir); + updateStatus(SEARCHING_FOR_DIRS, subDir); QApplication::processEvents(); buildDirectoryListRecursiveSimple(subDir, currentRemainingpathFilter, accumulatedDirs); } @@ -510,7 +519,7 @@ QStringList RicFileHierarchyDialog::findFilesInDirs(const QStringList& dirs) QDir qdir(dir); QStringList files = qdir.entryList(filters, QDir::Files); - updateStatus(WORKING); + updateStatus(SEARCHING_FOR_FILES, qdir.absolutePath()); QApplication::processEvents(); for (QString file : files) @@ -694,7 +703,7 @@ void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() } else if(m_files.isEmpty()) { - updateStatus(NO_FILES_FOUND, true); + updateStatus(NO_FILES_FOUND); } setOkButtonEnabled(!m_files.isEmpty()); diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 0a2ba928da..0f2743012b 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -40,7 +40,7 @@ class RicFileHierarchyDialog : public QDialog { Q_OBJECT - enum Status {WORKING, NO_FILES_FOUND}; + enum Status {SEARCHING_FOR_DIRS, SEARCHING_FOR_FILES, NO_FILES_FOUND}; public: RicFileHierarchyDialog(QWidget* parent); @@ -62,7 +62,7 @@ class RicFileHierarchyDialog : public QDialog bool cancelPressed() const; void appendToFileList(const QString& fileName); void clearFileList(); - void updateStatus(Status status, bool force = false, const QString& extraText = ""); + void updateStatus(Status status, const QString& extraText = ""); QString currentStatus() const; QStringList findMatchingFiles(); From 4a7f54689e33f9f9e2b00ff61cca932c49fd7cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 11:21:30 +0200 Subject: [PATCH 0778/1027] #2799 Origin Summary Cases: Fix option order in preference dialog --- ApplicationCode/Application/RiaPreferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index d23e0540ab..d11752f110 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -33,8 +33,8 @@ namespace caf void RiaPreferences::SummaryRestartFilesImportModeType::setUp() { addItem(RiaPreferences::IMPORT, "IMPORT", "Unified"); - addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Skip"); addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Separate Cases"); + addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Skip"); setDefault(RiaPreferences::IMPORT); } } From 54b21a8a495808cfdd438dbfeb3e2731ebdc6836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 11:25:29 +0200 Subject: [PATCH 0779/1027] Rename of static recursive search dialog method --- .../RicCreateGridCaseGroupFromFilesFeature.cpp | 7 ++++++- .../EclipseCommands/RicImportEclipseCasesFeature.cpp | 12 ++++++------ ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 12 ++++++------ ApplicationCode/Commands/RicFileHierarchyDialog.h | 12 ++++++------ .../Commands/RicImportSummaryCasesFeature.cpp | 7 ++++++- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp index 496cd7fedb..567ae6c791 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp @@ -50,7 +50,12 @@ void RicCreateGridCaseGroupFromFilesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, "Create Grid Case Group from Files", defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".EGRID")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + "Create Grid Case Group from Files", + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList(".EGRID")); // Remember filters m_pathFilter = result.pathFilter; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index aa67053010..f5cb90e476 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -52,12 +52,12 @@ void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, - "Import Eclipse Cases", - defaultDir, - m_pathFilter, - m_fileNameFilter, - QStringList() << ".EGRID" << ".GRID"); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + "Import Eclipse Cases", + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList() << ".EGRID" << ".GRID"); // Remember filters m_pathFilter = result.pathFilter; diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 17000e886e..eb34202432 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -159,12 +159,12 @@ RicFileHierarchyDialog::~RicFileHierarchyDialog() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicFileHierarchyDialogResult RicFileHierarchyDialog::getOpenFileNames(QWidget *parent /*= 0*/, - const QString &caption /*= QString()*/, - const QString &dir /*= QString()*/, - const QString &pathFilter /*= QString()*/, - const QString &fileNameFilter /*= QString()*/, - const QStringList &fileExtensions /*= QStringList()*/) +RicFileHierarchyDialogResult RicFileHierarchyDialog::runRecursiveSearchDialog(QWidget *parent /*= 0*/, + const QString &caption /*= QString()*/, + const QString &dir /*= QString()*/, + const QString &pathFilter /*= QString()*/, + const QString &fileNameFilter /*= QString()*/, + const QStringList &fileExtensions /*= QStringList()*/) { QStringList files; RicFileHierarchyDialog dialog(parent); diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index 0f2743012b..f3100cc3a9 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -46,12 +46,12 @@ class RicFileHierarchyDialog : public QDialog RicFileHierarchyDialog(QWidget* parent); ~RicFileHierarchyDialog(); - static RicFileHierarchyDialogResult getOpenFileNames(QWidget *parent = nullptr, - const QString& caption = QString(), - const QString& dir = QString(), - const QString& pathFilter = QString(), - const QString& fileNameFilter = QString(), - const QStringList& fileExtensions = QStringList()); + static RicFileHierarchyDialogResult runRecursiveSearchDialog(QWidget *parent = nullptr, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& pathFilter = QString(), + const QString& fileNameFilter = QString(), + const QStringList& fileExtensions = QStringList()); private: QStringList files() const; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 4ecd413135..a44dba7865 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -166,7 +166,12 @@ std::vector RicImportSummaryCasesFeature::importSummaryCases(co RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - RicFileHierarchyDialogResult result = RicFileHierarchyDialog::getOpenFileNames(nullptr, dialogTitle, defaultDir, m_pathFilter, m_fileNameFilter, QStringList(".SMSPEC")); + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + dialogTitle, + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList(".SMSPEC")); // Remember filters m_pathFilter = result.pathFilter; From e86c39b189cf43511cd78512ceaa453b31eb0190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 12:01:26 +0200 Subject: [PATCH 0780/1027] #2774 Import Ensemble: Ask for name before importing cases --- .../Commands/RicImportEnsembleFeature.cpp | 13 +++++++----- .../Commands/RicImportSummaryCasesFeature.cpp | 21 +++++++++---------- .../Commands/RicImportSummaryCasesFeature.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 327596281d..adcdfb44dd 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -60,16 +60,19 @@ bool RicImportEnsembleFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicImportEnsembleFeature::onActionTriggered(bool isChecked) { - RiaApplication* app = RiaApplication::instance(); - - std::vector cases = RicImportSummaryCasesFeature::importSummaryCases("Import Ensemble"); + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble"); - if (cases.empty()) return; - validateEnsembleCases(cases); + if (fileNames.isEmpty()) return; QString ensembleName = askForEnsembleName(); if (ensembleName.isEmpty()) return; + std::vector cases; + RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); + + validateEnsembleCases(cases); + RicImportSummaryCasesFeature::addSummaryCases(cases); RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName); diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index a44dba7865..8588665b99 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -65,9 +65,12 @@ bool RicImportSummaryCasesFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) { - RiaApplication* app = RiaApplication::instance(); - std::vector cases = importSummaryCases("Import Summary Cases"); + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = runRecursiveSummaryCaseFileSearchDialog("Import Summary Cases"); + std::vector cases; + if (!fileNames.isEmpty()) createSummaryCasesFromFiles(fileNames, &cases); + addSummaryCases(cases); for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); @@ -108,7 +111,8 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) +bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList& fileNames, + std::vector* newCases) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); @@ -161,7 +165,7 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vector RicImportSummaryCasesFeature::importSummaryCases(const QString& dialogTitle) +QStringList RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); @@ -177,15 +181,10 @@ std::vector RicImportSummaryCasesFeature::importSummaryCases(co m_pathFilter = result.pathFilter; m_fileNameFilter = result.fileNameFilter; - if (!result.ok) return std::vector(); + if (!result.ok) return QStringList(); // Remember the path to next time app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); - QStringList fileNames = result.files; - if (fileNames.isEmpty()) return std::vector(); - - std::vector newCases; - createSummaryCasesFromFiles(fileNames, &newCases); - return newCases; + return result.files; } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index d99b7cbbb0..68d9ca017d 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -42,7 +42,7 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature static bool createSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases); static void addSummaryCases(const std::vector cases); - static std::vector importSummaryCases(const QString& dialogTitle); + static QStringList runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle); protected: // Overrides From fdcf9f3ba49fb5f24ba915b8ca066362d580ddd8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Apr 2018 14:09:39 +0200 Subject: [PATCH 0781/1027] #2715 Mohr Circle plot : Hide dock widet by default --- .../UserInterface/RiuMainWindow.cpp | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e0d522a2ec..d392dfb3dd 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -599,26 +599,6 @@ void RiuMainWindow::createDockPanels() connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(customMenuRequested(const QPoint&))); } -/* - { - QDockWidget* dockWidget = new QDockWidget("Undo stack", this); - dockWidget->setObjectName("dockWidget"); - dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); - - m_undoView = new QUndoView(this); - m_undoView->setStack(caf::CmdExecCommandManager::instance()->undoStack()); - //connect(caf::CmdExecCommandManager::instance()->undoStack(), SIGNAL(indexChanged(int)), SLOT(slotIndexChanged())); - - dockWidget->setWidget(m_undoView); - - addDockWidget(Qt::RightDockWidgetArea, dockWidget); - - dockWidget->hide(); - - //m_windowsMenu->addAction(dockWidget->toggleViewAction()); - } -*/ - QDockWidget* resultPlotDock = nullptr; QDockWidget* relPermPlotDock = nullptr; QDockWidget* pvtPlotDock = nullptr; @@ -677,6 +657,8 @@ void RiuMainWindow::createDockPanels() addDockWidget(Qt::BottomDockWidgetArea, dockPanel); mohrsCirclePlotDock = dockPanel; + + dockPanel->hide(); } #endif From bc26fa697c9a6012fc90e8d42ee6e16565796332 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Apr 2018 14:32:46 +0200 Subject: [PATCH 0782/1027] #2715 Mohr Circle plot : Do as little as possible if not visible --- .../UserInterface/RiuMohrsCirclePlot.cpp | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index a414befbf5..5792a7efc5 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -97,28 +97,25 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::appendSelection(const RiuSelectionItem* selectionItem) { - const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); - - m_sourceGeoMechViewOfLastPlot = nullptr; - - if (!geoMechSelectionItem) + if (this->isVisible()) { - return; - } + m_sourceGeoMechViewOfLastPlot = nullptr; - RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; - CVF_ASSERT(geoMechView); + const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); + if (geoMechSelectionItem) + { + RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; + CVF_ASSERT(geoMechView); - if (this->isVisible()) - { - const size_t gridIndex = geoMechSelectionItem->m_gridIndex; - const size_t cellIndex = geoMechSelectionItem->m_cellIndex; - const cvf::Color3f color = geoMechSelectionItem->m_color; + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t cellIndex = geoMechSelectionItem->m_cellIndex; + const cvf::Color3f color = geoMechSelectionItem->m_color; - queryData(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); - updatePlot(); + queryData(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); + updatePlot(); - m_sourceGeoMechViewOfLastPlot = geoMechView; + m_sourceGeoMechViewOfLastPlot = geoMechView; + } } else { @@ -133,6 +130,8 @@ void RiuMohrsCirclePlot::clearPlot() { deletePlotItems(); + m_sourceGeoMechViewOfLastPlot = nullptr; + this->replot(); } From 9856038524530c70ab8640a4f65221d9e0881023 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 25 Apr 2018 07:46:04 +0200 Subject: [PATCH 0783/1027] #2715 Geo Mech : Show element type in Result Info --- .../GeoMech/GeoMechDataModel/RigFemTypes.cpp | 74 +++++++++++++------ .../GeoMech/GeoMechDataModel/RigFemTypes.h | 18 +++-- .../UserInterface/RiuFemResultTextBuilder.cpp | 6 +- 3 files changed, 65 insertions(+), 33 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp index 566d09f74c..e3233be517 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp @@ -2,63 +2,64 @@ // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigFemTypes.h" +#include - +#include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RigFemTypes::elmentNodeCount(RigElementType elmType) { - static int elementTypeCounts[3] ={ 8, 8, 4 }; + static int elementTypeCounts[3] = {8, 8, 4}; return elementTypeCounts[elmType]; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RigFemTypes::elmentFaceCount(RigElementType elmType) { - const static int elementFaceCounts[3] ={ 6, 6, 1 }; + const static int elementFaceCounts[3] = {6, 6, 1}; return elementFaceCounts[elmType]; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- // HEX8 // 7---------6 Increased k -> Increased depth : 4 5 6 7 is the deepest quad -// /| /| |k -// / | / | | /j -// 4---------5 | |/ -// | 3------|--2 *---i -// | / | / -// |/ |/ -// 0---------1 +// /| /| |k +// / | / | | /j +// 4---------5 | |/ +// | 3------|--2 *---i +// | / | / +// |/ |/ +// 0---------1 const int* RigFemTypes::localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount) { - static const int HEX8_Faces[6][4] ={ { 1, 2, 6, 5 }, { 0, 4, 7, 3 }, { 3, 7, 6, 2 }, { 0, 1, 5, 4 }, { 4, 5, 6, 7 }, { 0, 3, 2, 1 } }; - static const int CAX4_Faces[4] ={ 0, 1, 2, 3 }; + static const int HEX8_Faces[6][4] = {{1, 2, 6, 5}, {0, 4, 7, 3}, {3, 7, 6, 2}, {0, 1, 5, 4}, {4, 5, 6, 7}, {0, 3, 2, 1}}; + static const int CAX4_Faces[4] = {0, 1, 2, 3}; switch (elmType) { @@ -81,8 +82,8 @@ const int* RigFemTypes::localElmNodeIndicesForFace(RigElementType elmType, int f int RigFemTypes::oppositeFace(RigElementType elmType, int faceIdx) { - static const int HEX8_OppositeFaces[6]={ 1, 0, 3, 2, 5, 4}; - + static const int HEX8_OppositeFaces[6] = {1, 0, 3, 2, 5, 4}; + switch (elmType) { case HEX8: @@ -101,12 +102,12 @@ int RigFemTypes::oppositeFace(RigElementType elmType, int faceIdx) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const int* RigFemTypes::localElmNodeToIntegrationPointMapping(RigElementType elmType) { - static const int HEX8_Mapping[8] ={ 0, 1, 3, 2, 4, 5, 7, 6 }; + static const int HEX8_Mapping[8] = {0, 1, 3, 2, 4, 5, 7, 6}; switch (elmType) { @@ -124,3 +125,30 @@ const int* RigFemTypes::localElmNodeToIntegrationPointMapping(RigElementType elm return HEX8_Mapping; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigFemTypes::elementTypeText(RigElementType elemType) +{ + QString txt = "UNKNOWN_ELM_TYPE"; + + switch (elemType) + { + case HEX8: + txt = "HEX8"; + break; + case HEX8P: + txt = "HEX8P"; + break; + case CAX4: + txt = "CAX4"; + break; + case UNKNOWN_ELM_TYPE: + break; + default: + break; + } + + return txt; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h index eb9a70dfcb..723685fd68 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h @@ -2,23 +2,24 @@ // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include + +class QString; enum RigElementType { @@ -31,9 +32,10 @@ enum RigElementType class RigFemTypes { public: - static int elmentNodeCount(RigElementType elmType); - static int elmentFaceCount(RigElementType elmType); + static int elmentNodeCount(RigElementType elmType); + static int elmentFaceCount(RigElementType elmType); static const int* localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount); - static int oppositeFace(RigElementType elmType, int faceIdx); + static int oppositeFace(RigElementType elmType, int faceIdx); static const int* localElmNodeToIntegrationPointMapping(RigElementType elmType); + static QString elementTypeText(RigElementType elemType); }; diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 204860b147..926377aaeb 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -129,7 +129,9 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) RigFemPart* femPart = geomData->femParts()->part(m_gridIndex); int elementId = femPart->elmId(m_cellIndex); - text += QString("Element : Id[%1]").arg(elementId); + auto elementType = femPart->elementType(m_cellIndex); + + text += QString("Element : Id[%1], Type[%2]").arg(elementId).arg(RigFemTypes::elementTypeText(elementType)); size_t i = 0; size_t j = 0; @@ -141,7 +143,7 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) j++; k++; - cvf::Vec3d domainCoord = m_intersectionPoint; // + geomCase->femParts()->displayModelOffset(); + cvf::Vec3d domainCoord = m_intersectionPoint; //cvf::StructGridInterface::FaceEnum faceEnum(m_face); From 8383ee12cf8cedd920d3fd30a31c0320d78edc03 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 25 Apr 2018 07:53:15 +0200 Subject: [PATCH 0784/1027] #2715 Mohr Circle plot: Early exit if element type is not HEX8P --- .../UserInterface/RiuMohrsCirclePlot.cpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 5792a7efc5..bd501eb10a 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -341,18 +341,17 @@ void RiuMohrsCirclePlot::deleteEnvelopes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, - size_t gridIndex, - size_t elmIndex, - const cvf::Color3ub& color) +void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color) { CVF_ASSERT(geoMechView); m_sourceGeoMechViewOfLastPlot = geoMechView; - RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + if (femPart->elementType(elmIndex) != HEX8P) return; - int frameIdx = geoMechView->currentTimeStep(); - RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", ""); + int frameIdx = geoMechView->currentTimeStep(); + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", ""); // TODO: All tensors are calculated every time this function is called. FIX std::vector vertexTensors = resultCollection->tensors(address, 0, frameIdx); @@ -361,8 +360,6 @@ void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, return; } - RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); - // Calculate average tensor in element caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, 0)]; for (int i = 1; i < 8; i++) @@ -384,13 +381,14 @@ void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); - MohrsCirclesInfo mohrsCircle(principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color); + MohrsCirclesInfo mohrsCircle( + principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color); addMohrsCirclesInfo(mohrsCircle); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::updatePlot() { @@ -578,7 +576,7 @@ void RiuMohrsCirclePlot::deletePlotItems() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::scheduleUpdateAxisScale() { From a0e4f71138a1c6e761439e4bd5a9d296146864ad Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 25 Apr 2018 08:14:48 +0200 Subject: [PATCH 0785/1027] #2715 Add direct access to RigFemPartCollection from a GeoMechView --- .../RivGeoMechVizLogic.cpp | 4 +-- .../RivIntersectionBoxPartMgr.cpp | 2 +- .../Intersections/RivIntersectionPartMgr.cpp | 2 +- .../RivTensorResultPartMgr.cpp | 2 +- .../ProjectDataModel/RimGeoMechView.cpp | 30 +++++++++++++++++-- .../ProjectDataModel/RimGeoMechView.h | 8 +++-- .../ProjectDataModel/RimViewController.cpp | 16 +++++----- .../SocketInterface/RiaCaseInfoCommands.cpp | 2 +- .../UserInterface/RiuMohrsCirclePlot.cpp | 2 +- .../UserInterface/RiuViewerCommands.cpp | 2 +- 10 files changed, 50 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 6e84adbc19..33c489f26c 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -261,11 +261,11 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility(cvf::UByteArray* to { if (!m_geomechView->geoMechCase()) return; - size_t gridCount = m_geomechView->geoMechCase()->geoMechData()->femParts()->partCount(); + size_t gridCount = m_geomechView->femParts()->partCount(); if (gridCount == 0) return; - RigFemPart* part = m_geomechView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* part = m_geomechView->femParts()->part(0); int elmCount = part->elementCount(); totalVisibility->resize(elmCount); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index 7506558e71..000d5decf3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -371,7 +371,7 @@ cvf::ref RivIntersectionBoxPartMgr::createHexGr m_rimIntersectionBox->firstAncestorOrThisOfType(geoView); if (geoView) { - RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geoView->femParts()->part(0); return new RivFemIntersectionGrid(femPart); } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 4464ec8e0d..b4501571c6 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -1021,7 +1021,7 @@ cvf::ref RivIntersectionPartMgr::createHexGridI m_rimCrossSection->firstAncestorOrThisOfType(geoView); if (geoView) { - RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geoView->femParts()->part(0); return new RivFemIntersectionGrid(femPart); } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 18a4ced74e..3c70fa5515 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -78,7 +78,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi if (!m_rimReservoirView->tensorResults()->showTensors()) return; - RigFemPartCollection* femParts = m_rimReservoirView->geoMechCase()->geoMechData()->femParts(); + RigFemPartCollection* femParts = m_rimReservoirView->femParts(); if (!femParts) return; std::vector tensorVisualizations; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index e6517d6b0b..5d49cacebc 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -220,7 +220,7 @@ void RimGeoMechView::createDisplayModel() // Well path model - cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::BoundingBox femBBox = femParts()->boundingBox(); m_wellPathPipeVizModel->removeAllParts(); addWellPathsToModel(m_wellPathPipeVizModel.p(), femBBox); @@ -285,7 +285,7 @@ void RimGeoMechView::updateCurrentTimeStep() cvf::ref wellPathModelBasicList = new cvf::ModelBasicList; wellPathModelBasicList->setName(name); - cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::BoundingBox femBBox = femParts()->boundingBox(); addDynamicWellPathsToModel(wellPathModelBasicList.p(), femBBox); frameScene->addModel(wellPathModelBasicList.p()); @@ -530,6 +530,32 @@ std::vector RimGeoMechView::legendConfigs() const } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartCollection* RimGeoMechView::femParts() const +{ + if (m_geomechCase && m_geomechCase->geoMechData()) + { + return m_geomechCase->geoMechData()->femParts(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection* RimGeoMechView::femParts() +{ + if (m_geomechCase && m_geomechCase->geoMechData()) + { + return m_geomechCase->geoMechData()->femParts(); + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 18954b1a41..2463ffdf51 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -32,17 +32,18 @@ #include "cvfObject.h" class RigFemPart; +class RigFemPartCollection; class Rim3dOverlayInfoConfig; class RimCellRangeFilterCollection; class RimGeoMechCase; class RimGeoMechCellColors; -class RimGeoMechResultDefinition; class RimGeoMechPropertyFilterCollection; +class RimGeoMechResultDefinition; +class RimRegularLegendConfig; class RimTensorResults; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; -class RimRegularLegendConfig; class RivTensorResultPartMgr; namespace cvf { @@ -95,6 +96,9 @@ class RimGeoMechView : public RimGridView std::vector legendConfigs() const override; + const RigFemPartCollection* femParts() const; + RigFemPartCollection* femParts(); + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index 2cc1cbcbd6..9aed000ab7 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -590,15 +590,15 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() } if (masterGeomechView && masterGeomechView->geoMechCase()->geoMechData() - && masterGeomechView->geoMechCase()->geoMechData()->femParts()->partCount()) + && masterGeomechView->femParts()->partCount()) { - masterFemPart = masterGeomechView->geoMechCase()->geoMechData()->femParts()->part(0); + masterFemPart = masterGeomechView->femParts()->part(0); } if (dependGeomechView && dependGeomechView->geoMechCase()->geoMechData() - && dependGeomechView->geoMechCase()->geoMechData()->femParts()->partCount()) + && dependGeomechView->femParts()->partCount()) { - dependFemPart = dependGeomechView->geoMechCase()->geoMechData()->femParts()->part(0); + dependFemPart = dependGeomechView->femParts()->part(0); } // If we have the correct mapping already, return it. @@ -839,7 +839,7 @@ bool RimViewController::isRangeFilterControlPossible() const if (eclipseView->eclipseCase()->reservoirData() && geomView->geoMechCase()->geoMechData()) { RigMainGrid* eclGrid = eclipseView->eclipseCase()->reservoirData()->mainGrid(); - RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geomView->femParts()->part(0); if (eclGrid && femPart) { @@ -871,7 +871,7 @@ bool RimViewController::isRangeFilterMappingApliccable() const if (eclipseView->eclipseCase()->eclipseCaseData() && geomView->geoMechCase() && geomView->geoMechCase()->geoMechData()) { RigMainGrid* eclGrid = eclipseView->mainGrid(); - RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geomView->femParts()->part(0); if (eclGrid && femPart) { @@ -988,7 +988,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa if (eclipseMasterView->mainGrid()) { RigMainGrid* srcEclGrid = eclipseMasterView->mainGrid(); - RigFemPart* dstFemPart = depGeomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* dstFemPart = depGeomView->femParts()->part(0); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { RimCellRangeFilter* srcRFilter = sourceFilterCollection->rangeFilters[rfIdx]; @@ -1002,7 +1002,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa { if (depEclView->mainGrid()) { - RigFemPart* srcFemPart = geoMasterView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* srcFemPart = geoMasterView->femParts()->part(0); RigMainGrid* dstEclGrid = depEclView->mainGrid(); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { diff --git a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp index f72589d343..851cc99adf 100644 --- a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -616,7 +616,7 @@ class RiaGetSelectedCells: public RiaSocketCommand { const RiuGeoMechSelectionItem* geomechItem = static_cast(item); - geomechItem->m_view->geoMechCase()->geoMechData()->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k); + geomechItem->m_view->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k); gridIndex = geomechItem->m_gridIndex; caseId = geomechItem->m_view->geoMechCase()->caseId; } diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index bd501eb10a..d2908d7ef7 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -346,7 +346,7 @@ void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex CVF_ASSERT(geoMechView); m_sourceGeoMechViewOfLastPlot = geoMechView; - RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); + RigFemPart* femPart = geoMechView->femParts()->part(gridIndex); if (femPart->elementType(elmIndex) != HEX8P) return; int frameIdx = geoMechView->currentTimeStep(); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 3d93e42fa1..dd1cbf91a9 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -1045,7 +1045,7 @@ void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size if (geomView && geomView->geoMechCase()) { - geomView->geoMechCase()->geoMechData()->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); + geomView->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); } } From 3a670d94a2db8a263a3336e7d6b165a50ba079a9 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 25 Apr 2018 14:07:24 +0200 Subject: [PATCH 0786/1027] #2801 Fix Cotire build. --- .../Commands/RicSummaryCaseRestartDialog.cpp | 14 +++++++------- .../Commands/RicSummaryCaseRestartDialog.h | 10 +++++----- .../RifSummaryCaseRestartSelector.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 48ea405fe2..e89a2dcba6 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -214,7 +214,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const { if (failOnSummaryImportError) { - return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::ERROR); + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_ERROR); } } else @@ -228,11 +228,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If only grid file is present, return if (!handleSummaryFile && !initialGridFile.isEmpty()) { - RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::OK; + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK; if (!initialSummaryFile.isEmpty()) { // We were meant to have a summary file but due to an error we don't. - status = RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING; + status = RicSummaryCaseRestartDialogResult::SUMMARY_WARNING; } return RicSummaryCaseRestartDialogResult(status, defaultSummaryImportOption, @@ -251,7 +251,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If no restart files are found and no warnings, do not show dialog if (originFileInfos.empty() &&!hasWarnings) { - return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::OK, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_OK, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); } RicSummaryCaseRestartDialogResult dialogResult; @@ -332,11 +332,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); - RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::OK; + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK; if (dialog.result() == QDialog::Rejected) { - status = RicSummaryCaseRestartDialogResult::CANCELLED; + status = RicSummaryCaseRestartDialogResult::SUMMARY_CANCELLED; } dialogResult = RicSummaryCaseRestartDialogResult(status, @@ -347,7 +347,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.applyToAllSelected()); } - if (dialogResult.status != RicSummaryCaseRestartDialogResult::OK) + if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK) { return RicSummaryCaseRestartDialogResult(dialogResult.status, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); } diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index b6e49b9e7c..9dfc7f98a4 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -106,12 +106,12 @@ class RicSummaryCaseRestartDialogResult public: enum Status { - OK = 0, - CANCELLED = 1, - SUMMARY_FILE_WARNING = 2, - ERROR = 3 + SUMMARY_OK = 0, + SUMMARY_CANCELLED, + SUMMARY_WARNING, + SUMMARY_ERROR }; - RicSummaryCaseRestartDialogResult(Status _status = ERROR) : + RicSummaryCaseRestartDialogResult(Status _status = SUMMARY_ERROR) : status(_status), summaryImportOption(RicSummaryCaseRestartDialog::IMPORT_ALL), gridImportOption(RicSummaryCaseRestartDialog::NOT_IMPORT), diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index ae86f1aa17..177fb65ccb 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -180,7 +180,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std m_defaultGridImportMode, &lastResult); - if (result.status == RicSummaryCaseRestartDialogResult::CANCELLED) + if (result.status == RicSummaryCaseRestartDialogResult::SUMMARY_CANCELLED) { // Cancel pressed, cancel everything and return early m_summaryFileInfos.clear(); @@ -189,8 +189,8 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std return; } - if (result.status == RicSummaryCaseRestartDialogResult::ERROR || - result.status == RicSummaryCaseRestartDialogResult::SUMMARY_FILE_WARNING) + if (result.status == RicSummaryCaseRestartDialogResult::SUMMARY_ERROR || + result.status == RicSummaryCaseRestartDialogResult::SUMMARY_WARNING) { // A summary import failure occurred with one of the files. The others may still have worked. m_summaryFileErrors.push_back(initialFile.summaryFileName()); @@ -207,7 +207,7 @@ void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std } } - if (result.status != RicSummaryCaseRestartDialogResult::ERROR) + if (result.status != RicSummaryCaseRestartDialogResult::SUMMARY_ERROR) { lastResult = result; From 029369d187d78fda16fe92c069778475a3f90546 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 25 Apr 2018 11:00:27 +0200 Subject: [PATCH 0787/1027] #2677 Show curve value when clicking the curve This change will show the following: - Curve name - Well path name - Measured depth - name of variable - value --- .../Ric3dWellLogCurveViewerEventHandler.cpp | 12 +++++++++ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 8 ++++++ .../ProjectDataModel/Rim3dWellLogCurve.h | 25 ++++++++++--------- .../Rim3dWellLogExtractionCurve.cpp | 8 ++++++ .../Rim3dWellLogExtractionCurve.h | 5 ++-- .../Rim3dWellLogFileCurve.cpp | 22 ++++++++++------ .../ProjectDataModel/Rim3dWellLogFileCurve.h | 7 +++--- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 8 ++++++ .../ProjectDataModel/Rim3dWellLogRftCurve.h | 2 ++ 9 files changed, 73 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp index ea5337d7e8..a9434787a6 100644 --- a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp @@ -21,6 +21,7 @@ #include "Rim3dWellLogCurve.h" #include "Rim3dWellLogCurveCollection.h" +#include "RimWellPath.h" #include "RiuMainWindow.h" #include "RivObjectSourceInfo.h" @@ -53,6 +54,9 @@ bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject Rim3dWellLogCurveCollection* curveCollection = dynamic_cast(sourceInfo->object()); if (curveCollection) { + RimWellPath* wellPath; + curveCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + QString wellPathName = wellPath->name(); cvf::Vec3d closestPoint; double measuredDepthAtPoint; double valueAtPoint; @@ -61,6 +65,14 @@ bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject if (curve) { RiuMainWindow::instance()->selectAsCurrentItem(curve); + + QString curveText; + curveText += QString("Curve name : %1\n").arg(curve->name());; + curveText += QString("Well path name: %1\n").arg(wellPathName); + curveText += QString("Measured depth: %1\n").arg(measuredDepthAtPoint); + curveText += QString("%1 at depth: %2\n").arg(curve->resultPropertyString()).arg(valueAtPoint); + + RiuMainWindow::instance()->setResultInfo(curveText); } else { diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 05218ebe85..ead33dd23f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -90,6 +90,14 @@ void Rim3dWellLogCurve::updateCurveIn3dView() proj->createDisplayModelAndRedrawAllViews(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& Rim3dWellLogCurve::name() const +{ + return m_name(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 979608b736..5d1e100338 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -52,25 +52,26 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); - DrawPlane drawPlane() const; - cvf::Color3f color() const; - bool isShowingCurve() const; + const QString& name() const; + virtual QString resultPropertyString() const = 0; + DrawPlane drawPlane() const; + cvf::Color3f color() const; + bool isShowingCurve() const; - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; - void setColor(const cvf::Color3f& color); + void setColor(const cvf::Color3f& color); - double minCurveValue() const; - double maxCurveValue() const; - void resetMinMaxValuesAndUpdateUI(); - bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + double minCurveValue() const; + double maxCurveValue() const; + void resetMinMaxValuesAndUpdateUI(); + bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, - double* measuredDepthAtPoint, - double* valueAtPoint) const; + double* measuredDepthAtPoint, + double* valueAtPoint) const; void setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator); cvf::ref geometryGenerator(); - protected: virtual caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index 9470119b7e..30f6b27928 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -112,6 +112,14 @@ void Rim3dWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogExtractionCurve::resultPropertyString() const +{ + return m_eclipseResultDefinition->resultVariableUiName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h index de566a1160..5ab17dbea6 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h @@ -41,8 +41,9 @@ class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve Rim3dWellLogExtractionCurve(); virtual ~Rim3dWellLogExtractionCurve(); - void setPropertiesFromView(Rim3dView* view); - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + void setPropertiesFromView(Rim3dView* view); + virtual QString resultPropertyString() const override; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index a7913612b9..3f7f7d1835 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -40,7 +40,7 @@ Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() { CAF_PDM_InitObject("3d Well Log File Curve", ":/WellLogCurve16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_wellLogChannnelName, "CurveWellLogChannel", "Well Log Channel", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "Well Log File", "", "", ""); @@ -71,8 +71,8 @@ void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() if (!fileLogs.empty()) { - m_wellLogChannnelName = fileLogs[0]->name(); - m_name = "LAS: " + m_wellLogChannnelName; + m_wellLogChannelName = fileLogs[0]->name(); + m_name = "LAS: " + m_wellLogChannelName; } } } @@ -90,12 +90,20 @@ void Rim3dWellLogFileCurve::curveValuesAndMds(std::vector* values, std:: RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); if (wellLogFile) { - *values = wellLogFile->values(m_wellLogChannnelName); + *values = wellLogFile->values(m_wellLogChannelName); *measuredDepthValues = wellLogFile->depthValues(); } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::resultPropertyString() const +{ + return m_wellLogChannelName(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -103,7 +111,7 @@ void Rim3dWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedF const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &m_wellLogFile || changedField == &m_wellLogChannnelName) + if (changedField == &m_wellLogFile || changedField == &m_wellLogChannelName) { this->resetMinMaxValuesAndUpdateUI(); } @@ -122,7 +130,7 @@ QList Rim3dWellLogFileCurve::calculateValueOptions(const if (!options.empty()) return options; - if (fieldNeedingOptions == &m_wellLogChannnelName) + if (fieldNeedingOptions == &m_wellLogChannelName) { if (m_wellLogFile) { @@ -166,7 +174,7 @@ void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd { caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); curveDataGroup->add(&m_wellLogFile); - curveDataGroup->add(&m_wellLogChannnelName); + curveDataGroup->add(&m_wellLogChannelName); Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h index 502f9da1bd..9f537df3cc 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -38,8 +38,9 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve Rim3dWellLogFileCurve(); virtual ~Rim3dWellLogFileCurve(); - void setDefaultFileCurveDataInfo(); - virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + void setDefaultFileCurveDataInfo(); + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + virtual QString resultPropertyString() const override; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, @@ -54,5 +55,5 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve private: caf::PdmPtrField m_wellLogFile; - caf::PdmField m_wellLogChannnelName; + caf::PdmField m_wellLogChannelName; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index 3ace215855..a3eef10699 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -76,6 +76,14 @@ void Rim3dWellLogRftCurve::curveValuesAndMds(std::vector* values, std::v *measuredDepthValues = curveData->measuredDepths(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::resultPropertyString() const +{ + return caf::AppEnum::uiText(m_wellLogChannelName()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h index 286fe072a4..e922d1059a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -44,6 +44,8 @@ class Rim3dWellLogRftCurve : public Rim3dWellLogCurve virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + virtual QString resultPropertyString() const override; + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, From f61512ef946804d5f4bb4caf75f4f895d523373c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 25 Apr 2018 14:38:17 +0200 Subject: [PATCH 0788/1027] Add Copyright headers to cafTitledOverlayFrame.h|cpp --- .../cafTitledOverlayFrame.cpp | 36 ++++++++++++++++++ .../cafVizExtensions/cafTitledOverlayFrame.h | 37 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp index 4e7b1fe79a..5745dd2206 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -1,3 +1,39 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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 "cafTitledOverlayFrame.h" #include "cafCategoryMapper.h" #include "cvfFont.h" diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h index 007713d9bb..6852622c2e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -1,4 +1,41 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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" #include "cvfColor3.h" #include "cvfColor4.h" From fa6edf14e641844bf4c7f1ff3e48f8168fca2277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 25 Apr 2018 16:07:44 +0200 Subject: [PATCH 0789/1027] Upped to version 2018.01.1-dev.109 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 07e0aaefc2..32abe5535f 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,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 ".108") +set(RESINSIGHT_DEV_VERSION ".109") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 93304360fa3a0fa59a648f7f4046087676dd44d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 26 Apr 2018 09:47:43 +0200 Subject: [PATCH 0790/1027] #2810 import ensemble. Import all summary files even though some files miss ensemble parameters --- ApplicationCode/Commands/RicImportEnsembleFeature.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index adcdfb44dd..520aed55ea 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -102,6 +102,7 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vector paramsHasher; size_t paramsHash = 0; @@ -109,7 +110,7 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vectorcaseRealizationParameters().isNull() || rimCase->caseRealizationParameters()->parameters().empty()) { - throw QString("The case %1 has no ensemble parameters").arg(rimCase->summaryHeaderFilename()); + errors.append(QString("The case %1 has no ensemble parameters\n").arg(QFileInfo(rimCase->summaryHeaderFilename()).fileName())); } else { @@ -130,6 +131,11 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vector Date: Thu, 26 Apr 2018 09:51:35 +0200 Subject: [PATCH 0791/1027] #2806 Origin summary files dialog. Replace text 'Apply settings to...' to 'OK to All' --- ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index e89a2dcba6..4a84e80899 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -121,7 +121,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn->setText("Skip"); m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridNotReadBtn->setText("Skip"); - m_applyToAllCheckBox->setText("Apply Settings to Remaining Files"); + m_applyToAllCheckBox->setText("OK to All"); m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft); // Define layout From 3bc102bb019807ad5bc89d3dc5dbc97f040a8a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 26 Apr 2018 10:58:59 +0200 Subject: [PATCH 0792/1027] #2779 Ensemble curves. Reorganize import menu in main and plot windows --- .../UserInterface/RiuMainPlotWindow.cpp | 45 ++++++++++++------- .../UserInterface/RiuMainWindow.cpp | 45 +++++++++++-------- 2 files changed, 55 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 38d7708928..8d0af790e6 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -184,27 +184,38 @@ void RiuMainPlotWindow::createMenus() fileMenu->addSeparator(); QMenu* importMenu = fileMenu->addMenu("&Import"); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); - importMenu->addSeparator(); + + QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + #ifdef USE_ODB_API - importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + + importMenu->addSeparator(); + QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); + + importMenu->addSeparator(); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index d392dfb3dd..74e78ed30c 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -367,30 +367,39 @@ void RiuMainWindow::createMenus() QMenu* importMenu = fileMenu->addMenu("&Import"); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); - importMenu->addSeparator(); + + QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + #ifdef USE_ODB_API - importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); + + importMenu->addSeparator(); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); From 145b85cc1b4a2ed71e6a27fcd1f1f50269f86d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 26 Apr 2018 11:20:47 +0200 Subject: [PATCH 0793/1027] #2779 Ensemble curves. Add import sub menu --- ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e8d8369f6d..bc69112829 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -128,11 +128,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if (dynamic_cast(uiItem)) { + menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportEclipseCaseFeature"; menuBuilder << "RicImportEclipseCasesFeature"; menuBuilder << "RicImportInputEclipseCaseFeature"; menuBuilder << "RicCreateGridCaseGroupFeature"; menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; + menuBuilder.subMenuEnd(); menuBuilder << "RicEclipseCaseNewGroupFeature"; } else if (dynamic_cast(uiItem)) From fb384e596d6f188dc41b22e26d20d0d6ad5d3a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 26 Apr 2018 11:48:12 +0200 Subject: [PATCH 0794/1027] #2811 Ensemble curve set. Set initial ensemble --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 330119542b..29d55c58b9 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -346,7 +346,6 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder curveVarSelectionGroup->setCollapsedByDefault(true); m_yValuesSummaryFilter->uiOrdering(uiConfigName, *curveVarSelectionGroup); curveVarSelectionGroup->add(&m_yValuesUiFilterResultSelection); - } caf::PdmUiGroup* colorsGroup = uiOrdering.addNewGroup("Colors"); @@ -362,6 +361,14 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder m_ensembleParameter.uiCapability()->setUiReadOnly(!m_yValuesSummaryGroup()); colorsGroup->add(&m_ensembleParameter); } + + // Set default initial ensemble + RimProject* project = RiaApplication::instance()->project(); + if (m_yValuesSummaryGroup() == nullptr && project->summaryGroups().size() == 1) + { + m_yValuesSummaryGroup = project->summaryGroups().front(); + } + uiOrdering.skipRemainingFields(true); } From 3647792eb9813f707fc274254ed3c1a9b6bf4e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 26 Apr 2018 14:27:23 +0200 Subject: [PATCH 0795/1027] #2807 Origin summary files. Fix 'OK to all' not working issue --- ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 4a84e80899..3414f1d4f1 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -251,7 +251,10 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // If no restart files are found and no warnings, do not show dialog if (originFileInfos.empty() &&!hasWarnings) { - return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_OK, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false); + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_OK, NOT_IMPORT, NOT_IMPORT, + QStringList({ initialSummaryFile }), + QStringList({ initialGridFile }), + lastResult->applyToAll); } RicSummaryCaseRestartDialogResult dialogResult; From 97baff4e0f9b8111cd13539abbe9697e2aec07e8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Apr 2018 19:52:27 +0200 Subject: [PATCH 0796/1027] #2798 Dock Widgets : Add RiuDockWidgetTools --- .../UserInterface/CMakeLists_files.cmake | 2 + .../UserInterface/RiuDockWidgetTools.cpp | 290 ++++++++++++++++++ .../UserInterface/RiuDockWidgetTools.h | 74 +++++ 3 files changed, 366 insertions(+) create mode 100644 ApplicationCode/UserInterface/RiuDockWidgetTools.cpp create mode 100644 ApplicationCode/UserInterface/RiuDockWidgetTools.h diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 5c12f75e59..0ea3d2d894 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -69,6 +69,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTools.h ${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.h ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h +${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -138,6 +139,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.cpp ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp b/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp new file mode 100644 index 0000000000..36dc01aff6 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuDockWidgetTools.h" + +#include "RimEclipseView.h" +#include "RimGeoMechView.h" + +#include "RiuMainWindow.h" + +#include "cvfAssert.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools::RiuDockWidgetTools() +{ + loadDockWidgetsState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools* RiuDockWidgetTools::instance() +{ + static RiuDockWidgetTools staticInstance; + + return &staticInstance; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::projectTreeName() const +{ + return "dockProjectTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::propertyEditorName() const +{ + return "dockpropertyEditor"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::resultInfoName() const +{ + return "dockResultInfo"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::processMonitorName() const +{ + return "dockProcessMonitor"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::resultPlotName() const +{ + return "dockResultPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::relPermPlotName() const +{ + return "dockRelPermPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::pvtPlotName() const +{ + return "dockPvtPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::mohrsCirclePlotName() const +{ + return "dockMohrsCirclePlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::messagesName() const +{ + return "dockMessages"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDockWidget* RiuDockWidgetTools::findDockWidget(const QObject* parent, const QString& dockWidgetName) +{ + QList dockWidgets = parent->findChildren(); + + for (QDockWidget* dock : dockWidgets) + { + if (dock->objectName() == dockWidgetName) + { + return dock; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAction* RiuDockWidgetTools::toggleActionForWidget(const QObject* parent, const QString& dockWidgetName) +{ + auto w = RiuDockWidgetTools::findDockWidget(parent, dockWidgetName); + CVF_ASSERT(w); + + return w->toggleViewAction(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse() +{ + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::mohrsCirclePlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } + + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::relPermPlotName(), true); + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::pvtPlotName(), true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setVisibleDockingWindowsForGeoMech() +{ + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::mohrsCirclePlotName(), false); + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::relPermPlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::pvtPlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::trySetDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible) +{ + QDockWidget* dockWidget = findDockWidget(parent, dockWidgetName); + if (dockWidget) + { + bool unifiedIsVisible = isVisible; + + auto state = visibilityForWidget(dockWidgetName); + if (state != RiuDockWidgetTools::USER_DEFINED_UNKNOWN) + { + if (state == RiuDockWidgetTools::USER_DEFINED_ON) + { + unifiedIsVisible = true; + } + else if (state == RiuDockWidgetTools::USER_DEFINED_OFF) + { + unifiedIsVisible = false; + } + } + + dockWidget->setVisible(unifiedIsVisible); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools::UserDefinedVisibility RiuDockWidgetTools::visibilityForWidget(const QString& objectName) +{ + RiuDockWidgetTools::UserDefinedVisibility visibility = USER_DEFINED_UNKNOWN; + + auto windowStateIt = m_userDefinedDockWidgetVisibility.find(objectName); + if (windowStateIt != m_userDefinedDockWidgetVisibility.end()) + { + bool isVisible = windowStateIt.value().toBool(); + if (isVisible) + { + visibility = USER_DEFINED_ON; + } + else + { + visibility = USER_DEFINED_OFF; + } + } + + return visibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setDockWidgetVisibility(const QString& dockingWindowName, bool isVisible) +{ + m_userDefinedDockWidgetVisibility[dockingWindowName] = isVisible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::loadDockWidgetsState() +{ + // Company and appname set through QCoreApplication + QSettings settings; + + m_userDefinedDockWidgetVisibility = settings.value("dockWindowStates").toMap(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::saveDockWidgetsState() +{ + // Company and appname set through QCoreApplication + QSettings settings; + + QVariant v(m_userDefinedDockWidgetVisibility); + settings.setValue("dockWindowStates", v); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::changeDockWidgetVisibilityBasedOnView(Rim3dView* view) +{ + if (dynamic_cast(view)) + { + setVisibleDockingWindowsForEclipse(); + } + else if (dynamic_cast(view)) + { + setVisibleDockingWindowsForGeoMech(); + } +} diff --git a/ApplicationCode/UserInterface/RiuDockWidgetTools.h b/ApplicationCode/UserInterface/RiuDockWidgetTools.h new file mode 100644 index 0000000000..7e071d67e4 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuDockWidgetTools.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +class QDockWidget; +class QObject; +class QAction; + +class Rim3dView; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuDockWidgetTools +{ +public: + static RiuDockWidgetTools* instance(); + + QString projectTreeName() const; + QString propertyEditorName() const; + QString resultInfoName() const; + QString processMonitorName() const; + QString resultPlotName() const; + QString relPermPlotName() const; + QString pvtPlotName() const; + QString messagesName() const; + QString mohrsCirclePlotName() const; + + QAction* toggleActionForWidget(const QObject* parent, const QString& dockWidgetName); + void setDockWidgetVisibility(const QString& dockWidgetName, bool isVisible); + void changeDockWidgetVisibilityBasedOnView(Rim3dView* view); + void saveDockWidgetsState(); + +private: + enum UserDefinedVisibility + { + USER_DEFINED_ON, + USER_DEFINED_OFF, + USER_DEFINED_UNKNOWN + }; + + RiuDockWidgetTools(); + void setVisibleDockingWindowsForEclipse(); + void setVisibleDockingWindowsForGeoMech(); + void loadDockWidgetsState(); + UserDefinedVisibility visibilityForWidget(const QString& dockWidgetName); + static QDockWidget* findDockWidget(const QObject* parent, const QString& dockWidgetName); + void trySetDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible); + +private: + QMap m_userDefinedDockWidgetVisibility; +}; From 014944b4c065fe19d4e7445026805d288d7d6d82 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Apr 2018 19:57:51 +0200 Subject: [PATCH 0797/1027] #2798 Dock Widgets : Raise widget to make it top most widget if tabbed --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 74e78ed30c..e5a2152cc3 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1589,6 +1589,8 @@ void RiuMainWindow::showDockPanel(const QString &dockPanelName) if (dock && dock->objectName() == dockPanelName) { dock->show(); + dock->raise(); + return; } } From 132db2bb1e1bbb1e2c19fc22a4702eea4ee70900 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Apr 2018 20:05:42 +0200 Subject: [PATCH 0798/1027] #2798 Dock Widgets : Improve menus and handling of tabbed dock widgets Create dock widgets based on static names Build Windows menu based on static names Wire up toggleView actions to RiuDockWidgetTools Change dock widget visibility based on view --- .../Application/RiaApplication.cpp | 9 +- .../UserInterface/RiuMainPlotWindow.cpp | 18 +- .../UserInterface/RiuMainWindow.cpp | 211 +++++++----------- .../UserInterface/RiuMainWindowBase.cpp | 29 ++- .../UserInterface/RiuMainWindowBase.h | 26 ++- 5 files changed, 141 insertions(+), 152 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 7907a8b94f..13dc8cd302 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -72,6 +72,7 @@ #include "RimWellPltPlot.h" #include "RimWellRftPlot.h" +#include "RiuDockWidgetTools.h" #include "RiuMainPlotWindow.h" #include "RiuMainWindow.h" #include "RiuProcessMonitor.h" @@ -195,12 +196,13 @@ RiaApplication::RiaApplication(int& argc, char** argv) //-------------------------------------------------------------------------------------------------- RiaApplication::~RiaApplication() { + RiuDockWidgetTools::instance()->saveDockWidgetsState(); + deleteMainPlotWindow(); delete m_preferences; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -209,7 +211,6 @@ RiaApplication* RiaApplication::instance() return static_castqApp; } - //-------------------------------------------------------------------------------------------------- /// Return -1 if unit test is not executed, returns 0 if test passed, returns 1 if tests failed //-------------------------------------------------------------------------------------------------- @@ -1074,8 +1075,6 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName) return true; } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1167,6 +1166,8 @@ RimViewWindow* RiaApplication::activePlotWindow() const void RiaApplication::setActiveReservoirView(Rim3dView* rv) { m_activeReservoirView = rv; + + RiuDockWidgetTools::instance()->changeDockWidgetVisibilityBasedOnView(rv); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp index 8d0af790e6..ef2c97a978 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp @@ -394,6 +394,12 @@ void RiuMainPlotWindow::createDockPanels() setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); + + QList dockWidgets = findChildren(); + for (QDockWidget* dock : dockWidgets) + { + connect(dock->toggleViewAction(), SIGNAL(triggered()), SLOT(slotDockWidgetToggleViewActionTriggered())); + } } //-------------------------------------------------------------------------------------------------- @@ -596,17 +602,9 @@ void RiuMainPlotWindow::slotBuildWindowActions() m_windowMenu->clear(); QList dockWidgets = findChildren(); - - int i = 0; - foreach (QDockWidget* dock, dockWidgets) + for (QDockWidget* dock : dockWidgets) { - if (dock) - { - if (i == 4) - m_windowMenu->addSeparator(); - m_windowMenu->addAction(dock->toggleViewAction()); - ++i; - } + m_windowMenu->addAction(dock->toggleViewAction()); } m_windowMenu->addSeparator(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e5a2152cc3..9e722848a3 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -84,10 +84,7 @@ #include #include #include - - -#define DOCK_PANEL_NAME_PROCESS_MONITOR "dockProcessMonitor" - +#include "RiuDockWidgetTools.h" //================================================================================================== @@ -367,39 +364,30 @@ void RiuMainWindow::createMenus() QMenu* importMenu = fileMenu->addMenu("&Import"); - - QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); - importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); - + importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + importMenu->addSeparator(); #ifdef USE_ODB_API + importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); - QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); - importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); - importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif + importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); - + importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); importMenu->addSeparator(); - QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); - importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); - - importMenu->addSeparator(); - QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); @@ -575,9 +563,11 @@ void RiuMainWindow::createToolBars() void RiuMainWindow::createDockPanels() { + auto dwt = RiuDockWidgetTools::instance(); + { QDockWidget* dockWidget = new QDockWidget("Project Tree", this); - dockWidget->setObjectName("dockWidget"); + dockWidget->setObjectName(dwt->projectTreeName()); dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); m_projectTreeView = new caf::PdmUiTreeView(this); @@ -615,7 +605,7 @@ void RiuMainWindow::createDockPanels() { QDockWidget* dockWidget = new QDockWidget("Property Editor", this); - dockWidget->setObjectName("dockWidget"); + dockWidget->setObjectName(dwt->propertyEditorName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget); @@ -625,84 +615,84 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockPanel = new QDockWidget("Result Info", this); - dockPanel->setObjectName("dockResultInfoPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_resultInfoPanel = new RiuResultInfoPanel(dockPanel); - dockPanel->setWidget(m_resultInfoPanel); + QDockWidget* dockWidget = new QDockWidget("Result Info", this); + dockWidget->setObjectName(dwt->resultInfoName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_resultInfoPanel = new RiuResultInfoPanel(dockWidget); + dockWidget->setWidget(m_resultInfoPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); } { - QDockWidget* dockPanel = new QDockWidget("Process Monitor", this); - dockPanel->setObjectName(DOCK_PANEL_NAME_PROCESS_MONITOR); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_processMonitor = new RiuProcessMonitor(dockPanel); - dockPanel->setWidget(m_processMonitor); + QDockWidget* dockWidget = new QDockWidget("Process Monitor", this); + dockWidget->setObjectName(dwt->processMonitorName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_processMonitor = new RiuProcessMonitor(dockWidget); + dockWidget->setWidget(m_processMonitor); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - dockPanel->hide(); + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + dockWidget->hide(); } { - QDockWidget* dockPanel = new QDockWidget("Result Plot", this); - dockPanel->setObjectName("dockTimeHistoryPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_resultQwtPlot = new RiuResultQwtPlot(dockPanel); - dockPanel->setWidget(m_resultQwtPlot); + QDockWidget* dockWidget = new QDockWidget("Result Plot", this); + dockWidget->setObjectName(dwt->resultPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_resultQwtPlot = new RiuResultQwtPlot(dockWidget); + dockWidget->setWidget(m_resultQwtPlot); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - resultPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + resultPlotDock = dockWidget; } #ifdef USE_ODB_API { - QDockWidget* dockPanel = new QDockWidget("Mohr's Circle Plot", this); - dockPanel->setObjectName("dockTimeHistoryPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_mohrsCirclePlot = new RiuMohrsCirclePlot(dockPanel); - dockPanel->setWidget(m_mohrsCirclePlot); + QDockWidget* dockWidget = new QDockWidget("Mohr's Circle Plot", this); + dockWidget->setObjectName(dwt->mohrsCirclePlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_mohrsCirclePlot = new RiuMohrsCirclePlot(dockWidget); + dockWidget->setWidget(m_mohrsCirclePlot); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - mohrsCirclePlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + mohrsCirclePlotDock = dockWidget; - dockPanel->hide(); + dockWidget->hide(); } #endif { - QDockWidget* dockPanel = new QDockWidget("Relative Permeability Plot", this); - dockPanel->setObjectName("dockRelativePermeabilityPlotPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_relPermPlotPanel = new RiuRelativePermeabilityPlotPanel(dockPanel); - dockPanel->setWidget(m_relPermPlotPanel); + QDockWidget* dockWidget = new QDockWidget("Relative Permeability Plot", this); + dockWidget->setObjectName(dwt->relPermPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_relPermPlotPanel = new RiuRelativePermeabilityPlotPanel(dockWidget); + dockWidget->setWidget(m_relPermPlotPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - relPermPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + relPermPlotDock = dockWidget; } { - QDockWidget* dockPanel = new QDockWidget("PVT Plot", this); - dockPanel->setObjectName("dockPvtPlotPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_pvtPlotPanel = new RiuPvtPlotPanel(dockPanel); - dockPanel->setWidget(m_pvtPlotPanel); + QDockWidget* dockWidget = new QDockWidget("PVT Plot", this); + dockWidget->setObjectName(dwt->pvtPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_pvtPlotPanel = new RiuPvtPlotPanel(dockWidget); + dockWidget->setWidget(m_pvtPlotPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - pvtPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + pvtPlotDock = dockWidget; } { QDockWidget* dockWidget = new QDockWidget("Messages", this); - dockWidget->setObjectName("dockMessages"); + dockWidget->setObjectName(dwt->messagesName()); m_messagePanel = new RiuMessagePanel(dockWidget); dockWidget->setWidget(m_messagePanel); addDockWidget(Qt::BottomDockWidgetArea, dockWidget); dockWidget->hide(); } - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); // Tabify docks @@ -714,6 +704,11 @@ void RiuMainWindow::createDockPanels() tabifyDockWidget(relPermPlotDock, resultPlotDock); #endif + QList dockWidgets = findChildren(); + for (QDockWidget* dock : dockWidgets) + { + connect(dock->toggleViewAction(), SIGNAL(triggered()), SLOT(slotDockWidgetToggleViewActionTriggered())); + } } //-------------------------------------------------------------------------------------------------- @@ -1270,18 +1265,20 @@ void RiuMainWindow::slotBuildWindowActions() m_windowMenu->addAction(m_newPropertyView); m_windowMenu->addSeparator(); - QList dockWidgets = findChildren(); + auto dwt = RiuDockWidgetTools::instance(); - int i = 0; - foreach (QDockWidget* dock, dockWidgets) - { - if (dock) - { - if (i == 4) m_windowMenu->addSeparator(); - m_windowMenu->addAction(dock->toggleViewAction()); - ++i; - } - } + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->projectTreeName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->propertyEditorName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->messagesName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->processMonitorName())); + + m_windowMenu->addSeparator(); + + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->resultInfoName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->resultPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->relPermPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->pvtPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->mohrsCirclePlotName())); m_windowMenu->addSeparator(); QAction* cascadeWindowsAction = new QAction("Cascade Windows", this); @@ -1406,42 +1403,6 @@ void RiuMainWindow::hideAllDockWindows() } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -/*void RiuMainWindow::slotOpenMultipleCases() -{ -#if 1 - QAction* action = caf::CmdFeatureManager::instance()->action("RicCreateGridCaseGroupFeature"); - CVF_ASSERT(action); - - action->trigger(); - -#else // Code to fast generate a test project - RiaApplication* app = RiaApplication::instance(); - - QStringList gridFileNames; - - if (1) - { - gridFileNames += RiaDefines::mockModelBasicWithResults(); - gridFileNames += RiaDefines::mockModelBasicWithResults(); - gridFileNames += RiaDefines::mockModelBasicWithResults(); - } - else - { - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID"; - } - - app->addEclipseCases(gridFileNames); -#endif - -} -*/ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1635,7 +1596,7 @@ void RiuMainWindow::updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectT //-------------------------------------------------------------------------------------------------- void RiuMainWindow::showProcessMonitorDockPanel() { - showDockPanel(DOCK_PANEL_NAME_PROCESS_MONITOR); + showDockPanel(RiuDockWidgetTools::instance()->processMonitorName()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp index 709e68234c..93e4ac482b 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp @@ -20,9 +20,13 @@ #include "RiaVersionInfo.h" -#include -#include "cafPdmUiTreeView.h" +#include "RiuDockWidgetTools.h" + #include "cafPdmObject.h" +#include "cafPdmUiTreeView.h" + +#include +#include //-------------------------------------------------------------------------------------------------- /// @@ -118,3 +122,24 @@ void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) { m_projectTreeView->setExpanded(uiItem, expanded); } + +//-------------------------------------------------------------------------------------------------- +/// +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered() +{ + if (!sender()) return; + + auto dockWidget = dynamic_cast(sender()->parent()); + if (dockWidget) + { + if (dockWidget->isVisible()) + { + // Raise the dock widget to make it visible if the widget is part of a tab widget + dockWidget->raise(); + } + + RiuDockWidgetTools::instance()->setDockWidgetVisibility(dockWidget->objectName(), dockWidget->isVisible()); + } +} diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.h b/ApplicationCode/UserInterface/RiuMainWindowBase.h index 5ac3f39663..bef70f453a 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.h @@ -39,28 +39,32 @@ class RiuMainWindowBase : public QMainWindow public: RiuMainWindowBase(); - virtual QString mainWindowName() = 0; + virtual QString mainWindowName() = 0; - virtual void removeViewer( QWidget* viewer ) = 0; - virtual void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)= 0; - virtual void setActiveViewer(QWidget* subWindow) = 0; + virtual void removeViewer( QWidget* viewer ) = 0; + virtual void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)= 0; + virtual void setActiveViewer(QWidget* subWindow) = 0; virtual RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) = 0; - void loadWinGeoAndDockToolBarLayout(); - void saveWinGeoAndDockToolBarLayout(); - void showWindow(); + void loadWinGeoAndDockToolBarLayout(); + void saveWinGeoAndDockToolBarLayout(); + void showWindow(); caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); - void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + +protected slots: + void slotDockWidgetToggleViewActionTriggered(); protected: - caf::PdmUiTreeView* m_projectTreeView; - bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control + caf::PdmUiTreeView* m_projectTreeView; + bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control // whether to select the corresponding active view or not + private: - QString registryFolderName(); + QString registryFolderName(); }; From 515ed8a649bf5d46c4597f81988b9cab13113a2a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 26 Apr 2018 20:40:06 +0200 Subject: [PATCH 0799/1027] #2798 Dock Widgets : Store dock widget state when closed by "x" --- .../UserInterface/RiuMainWindow.cpp | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 9e722848a3..c1d67c7fc0 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -556,17 +556,35 @@ void RiuMainWindow::createToolBars() refreshDrawStyleActions(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +class RiuDockWidget : public QDockWidget +{ +public: + explicit RiuDockWidget(const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0) + : QDockWidget(title, parent, flags) + { + } + + void closeEvent(QCloseEvent* event) override + { + // This event is called when the user clicks the "x" in upper right corner to close the dock widget + RiuDockWidgetTools::instance()->setDockWidgetVisibility(objectName(), false); + QDockWidget::closeEvent(event); + } +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RiuMainWindow::createDockPanels() { auto dwt = RiuDockWidgetTools::instance(); { - QDockWidget* dockWidget = new QDockWidget("Project Tree", this); + QDockWidget* dockWidget = new RiuDockWidget("Project Tree", this); dockWidget->setObjectName(dwt->projectTreeName()); dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); @@ -604,7 +622,7 @@ void RiuMainWindow::createDockPanels() QDockWidget* mohrsCirclePlotDock = nullptr; { - QDockWidget* dockWidget = new QDockWidget("Property Editor", this); + QDockWidget* dockWidget = new RiuDockWidget("Property Editor", this); dockWidget->setObjectName(dwt->propertyEditorName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -615,7 +633,7 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockWidget = new QDockWidget("Result Info", this); + QDockWidget* dockWidget = new RiuDockWidget("Result Info", this); dockWidget->setObjectName(dwt->resultInfoName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_resultInfoPanel = new RiuResultInfoPanel(dockWidget); @@ -625,7 +643,7 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockWidget = new QDockWidget("Process Monitor", this); + QDockWidget* dockWidget = new RiuDockWidget("Process Monitor", this); dockWidget->setObjectName(dwt->processMonitorName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_processMonitor = new RiuProcessMonitor(dockWidget); @@ -636,7 +654,7 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockWidget = new QDockWidget("Result Plot", this); + QDockWidget* dockWidget = new RiuDockWidget("Result Plot", this); dockWidget->setObjectName(dwt->resultPlotName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_resultQwtPlot = new RiuResultQwtPlot(dockWidget); @@ -648,7 +666,7 @@ void RiuMainWindow::createDockPanels() #ifdef USE_ODB_API { - QDockWidget* dockWidget = new QDockWidget("Mohr's Circle Plot", this); + QDockWidget* dockWidget = new RiuDockWidget("Mohr's Circle Plot", this); dockWidget->setObjectName(dwt->mohrsCirclePlotName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_mohrsCirclePlot = new RiuMohrsCirclePlot(dockWidget); @@ -662,7 +680,7 @@ void RiuMainWindow::createDockPanels() #endif { - QDockWidget* dockWidget = new QDockWidget("Relative Permeability Plot", this); + QDockWidget* dockWidget = new RiuDockWidget("Relative Permeability Plot", this); dockWidget->setObjectName(dwt->relPermPlotName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_relPermPlotPanel = new RiuRelativePermeabilityPlotPanel(dockWidget); @@ -673,7 +691,7 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockWidget = new QDockWidget("PVT Plot", this); + QDockWidget* dockWidget = new RiuDockWidget("PVT Plot", this); dockWidget->setObjectName(dwt->pvtPlotName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); m_pvtPlotPanel = new RiuPvtPlotPanel(dockWidget); @@ -684,7 +702,7 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockWidget = new QDockWidget("Messages", this); + QDockWidget* dockWidget = new RiuDockWidget("Messages", this); dockWidget->setObjectName(dwt->messagesName()); m_messagePanel = new RiuMessagePanel(dockWidget); dockWidget->setWidget(m_messagePanel); From c267f3263830a1700a4c10c6d9fdf3b52d80dab3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 06:28:08 +0200 Subject: [PATCH 0800/1027] Rename to RiuPlotMainWindow --- .../Application/RiaApplication.cpp | 12 ++-- ApplicationCode/Application/RiaApplication.h | 8 +-- .../Application/Tools/RiaArgumentParser.cpp | 2 +- .../Tools/RiaImportEclipseCaseTools.cpp | 2 +- .../Tools/RiaRegressionTestRunner.cpp | 4 +- .../RicShowPlotDataFeature.cpp | 6 +- .../RicTileWindowsFeature.cpp | 6 +- .../RicSnapshotAllPlotsToFileFeature.cpp | 2 +- .../RicSnapshotViewToClipboardFeature.cpp | 2 +- .../RicSnapshotViewToFileFeature.cpp | 2 +- .../RicPlotProductionRateFeature.cpp | 4 +- .../Commands/RicCloseSummaryCaseFeature.cpp | 4 +- ...RicCloseSummaryCaseInCollectionFeature.cpp | 4 +- .../Commands/RicDeleteItemExec.cpp | 6 +- .../Commands/RicFileHierarchyDialog.cpp | 2 +- .../Commands/RicGridStatisticsDialog.cpp | 2 +- .../Commands/RicImportEnsembleFeature.cpp | 2 +- .../Commands/RicImportSummaryCaseFeature.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 4 +- .../Commands/RicSummaryCaseRestartDialog.cpp | 2 +- ...cDuplicateSummaryCrossPlotCurveFeature.cpp | 2 +- .../RicNewSummaryCrossPlotCurveFeature.cpp | 4 +- .../RicNewSummaryCurveFeature.cpp | 4 +- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 4 +- .../RicNewSummaryPlotFeature.cpp | 2 +- .../RicSummaryCurveCreatorDialog.cpp | 4 +- .../RicViewZoomAllFeature.cpp | 6 +- .../RicToggleItemsFeatureImpl.cpp | 4 +- .../RicNewWellLogCurveExtractionFeature.cpp | 2 +- .../RicNewWellLogFileCurveFeature.cpp | 2 +- .../RicNewWellLogRftCurveFeature.cpp | 2 +- .../RimTofAccumulatedPhaseFractionsPlot.cpp | 2 +- .../Flow/RimTotalWellAllocationPlot.cpp | 2 +- .../Flow/RimWellAllocationPlot.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 2 +- .../ProjectDataModel/RimWellLogPlot.cpp | 2 +- .../Summary/RimSummaryCurve.cpp | 6 +- .../Summary/RimSummaryPlotSourceStepping.cpp | 4 +- .../UserInterface/CMakeLists_files.cmake | 6 +- .../UserInterface/RiuMdiSubWindow.cpp | 2 +- ...inPlotWindow.cpp => RiuPlotMainWindow.cpp} | 69 +++++++++---------- ...iuMainPlotWindow.h => RiuPlotMainWindow.h} | 4 +- .../UserInterface/RiuPlotMainWindowTools.cpp | 8 +-- .../UserInterface/RiuPlotObjectPicker.cpp | 4 +- .../UserInterface/RiuTreeViewEventFilter.cpp | 2 +- 45 files changed, 111 insertions(+), 118 deletions(-) rename ApplicationCode/UserInterface/{RiuMainPlotWindow.cpp => RiuPlotMainWindow.cpp} (93%) rename ApplicationCode/UserInterface/{RiuMainPlotWindow.h => RiuPlotMainWindow.h} (97%) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 13dc8cd302..2f208c4974 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -73,7 +73,7 @@ #include "RimWellRftPlot.h" #include "RiuDockWidgetTools.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuProcessMonitor.h" #include "RiuRecentFileActionProvider.h" @@ -1291,7 +1291,7 @@ void RiaApplication::createMainPlotWindow() { CVF_ASSERT(m_mainPlotWindow == nullptr); - m_mainPlotWindow = new RiuMainPlotWindow; + m_mainPlotWindow = new RiuPlotMainWindow; m_mainPlotWindow->setWindowTitle("Plots - ResInsight"); m_mainPlotWindow->setDefaultWindowSize(); @@ -1314,7 +1314,7 @@ void RiaApplication::deleteMainPlotWindow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() +RiuPlotMainWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() { if (!m_mainPlotWindow) { @@ -1341,7 +1341,7 @@ RiuMainPlotWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow* RiaApplication::mainPlotWindow() +RiuPlotMainWindow* RiaApplication::mainPlotWindow() { return m_mainPlotWindow; } @@ -1369,9 +1369,9 @@ RimViewWindow* RiaApplication::activeViewWindow() { viewWindow = RiaApplication::instance()->activeReservoirView(); } - else if (dynamic_cast(mainWindowWidget)) + else if (dynamic_cast(mainWindowWidget)) { - RiuMainPlotWindow* mainPlotWindow = dynamic_cast(mainWindowWidget); + RiuPlotMainWindow* mainPlotWindow = dynamic_cast(mainWindowWidget); QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); if (subwindows.size() > 0) diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 5584192dee..a5e611bc9b 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -57,7 +57,7 @@ class RimWellLogPlot; class RimWellAllocationPlot; class RiuMainWindowBase; -class RiuMainPlotWindow; +class RiuPlotMainWindow; class RiuRecentFileActionProvider; class RiaArgumentParser; @@ -180,8 +180,8 @@ class RiaApplication : public QApplication int launchUnitTests(); int launchUnitTestsWithConsole(); - RiuMainPlotWindow* getOrCreateAndShowMainPlotWindow(); - RiuMainPlotWindow* mainPlotWindow(); + RiuPlotMainWindow* getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow(); RiuMainWindowBase* mainWindowByID(int mainWindowID); static RimViewWindow* activeViewWindow(); @@ -249,7 +249,7 @@ private slots: bool m_runningWorkerProcess; - RiuMainPlotWindow* m_mainPlotWindow; + RiuPlotMainWindow* m_mainPlotWindow; std::unique_ptr m_recentFileActionProvider; }; diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index 432dc7029c..618544f9ac 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -28,7 +28,7 @@ #include "RimProject.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicfMessages.h" #include "RicfCommandFileExecutor.h" diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index add46133d6..7c7696b2a1 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -45,7 +45,7 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "cafUtils.h" diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp index 66ea48252f..bd84b6eb81 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -32,7 +32,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -432,7 +432,7 @@ void RiaRegressionTestRunner::resizeMaximizedPlotWindows() RimProject* proj = RiaApplication::instance()->project(); if (!proj) return; - RiuMainPlotWindow* plotMainWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotMainWindow = RiaApplication::instance()->mainPlotWindow(); if (!plotMainWindow) return; std::vector viewWindows; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index d304712541..91f523f009 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -25,7 +25,7 @@ #include "RimSummaryPlot.h" #include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTextDialog.h" #include "cafSelectionManagerTools.h" @@ -82,7 +82,7 @@ void RicShowPlotDataFeature::onActionTriggered(bool isChecked) return; } - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); CVF_ASSERT(plotwindow); for (RimSummaryPlot* summaryPlot : selectedSummaryPlots) @@ -117,7 +117,7 @@ void RicShowPlotDataFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- void RicShowPlotDataFeature::showTextWindow(const QString& title, const QString& text) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); CVF_ASSERT(plotwindow); RiuTextDialog* textWiget = new RiuTextDialog(); diff --git a/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp index 2160d83258..ea57db2541 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp @@ -20,7 +20,7 @@ #include "RicTileWindowsFeature.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include #include @@ -74,7 +74,7 @@ CAF_CMD_SOURCE_INIT(RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature"); //-------------------------------------------------------------------------------------------------- bool RicTilePlotWindowsFeature::isCommandEnabled() { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow) { return mainPlotWindow->isAnyMdiSubWindowVisible(); @@ -88,7 +88,7 @@ bool RicTilePlotWindowsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicTilePlotWindowsFeature::onActionTriggered(bool isChecked) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow) { mainPlotWindow->tileWindows(); diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index 36cde19d7c..3572a5c125 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -50,7 +50,7 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots() { RiaApplication* app = RiaApplication::instance(); - RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = app->mainPlotWindow(); if (!mainPlotWindow) return; RimProject* proj = app->project(); diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp index 499efe5ed5..79e7002aa0 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp @@ -25,7 +25,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafUtils.h" diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index 1af5521c5e..9404695d3e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -24,7 +24,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicSnapshotFilenameGenerator.h" diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index 6b885ba4b8..c59a8b4e63 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -40,7 +40,7 @@ #include "Rim3dView.h" #include "RiaSummaryTools.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -184,7 +184,7 @@ void RicPlotProductionRateFeature::onActionTriggered(bool isChecked) if (summaryPlotToSelect) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow) { mainPlotWindow->selectAsCurrentItem(summaryPlotToSelect); diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp index 39c24fae14..8471ef0cd7 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -28,7 +28,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -71,7 +71,7 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vectorupdateAllRequiredEditors(); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp index b93d26675a..efe1de1016 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp @@ -30,7 +30,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -86,7 +86,7 @@ void RicCloseSummaryCaseInCollectionFeature::onActionTriggered(bool isChecked) RicCloseSummaryCaseFeature::deleteSummaryCases(summaryCaseCollection->allSummaryCases()); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index df6983541a..7daa0f6285 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -44,7 +44,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RimFractureTemplateCollection.h" @@ -262,7 +262,7 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(summaryPlotCollection); if (summaryPlotCollection) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } @@ -270,7 +270,7 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(summaryCrossPlotCollection); if (summaryCrossPlotCollection) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index eb34202432..aac2f9439e 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -27,7 +27,7 @@ #include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp index 9135c04f18..69479cf6cb 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp @@ -26,7 +26,7 @@ #include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 520aed55ea..447b9db731 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -34,7 +34,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 9c223179fc..0e1d7029fa 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -32,7 +32,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 8588665b99..9c2367912b 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -34,7 +34,7 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" @@ -153,7 +153,7 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vectoraddCases(cases); sumCaseColl->updateAllRequiredEditors(); - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow && !cases.empty()) { mainPlotWindow->selectAsCurrentItem(cases.back()); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 3414f1d4f1..4d6fdd66d7 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -32,7 +32,7 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimTools.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp index f8496965b4..6e158dafb7 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp @@ -31,7 +31,7 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp index 3f39f73545..e61d1e9961 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp @@ -30,7 +30,7 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -78,7 +78,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked) RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index 9f0d2d8773..3d040f8929 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -29,7 +29,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -82,7 +82,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index c242830c03..358622ea1e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -31,7 +31,7 @@ #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -70,7 +70,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(curveSet); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp index 308b18f54e..0728f41cff 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -30,7 +30,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cvfAssert.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp index 2a7c5daec5..52ad89ddc3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp @@ -23,7 +23,7 @@ #include "RicSummaryCurveCreator.h" #include "RicSummaryCurveCreatorSplitterUi.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTools.h" #include @@ -70,7 +70,7 @@ void RicSummaryCurveCreatorDialog::updateFromSummaryPlot(RimSummaryPlot* summary //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreatorDialog::slotDialogFinished() { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); if (plotwindow) { plotwindow->cleanUpTemporaryWidgets(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp index 8e7e903b61..d1f2b59ec9 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -26,7 +26,7 @@ #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuWellAllocationPlot.h" @@ -62,9 +62,9 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView(); viewWindow->zoomAll(); } - else if (dynamic_cast(topLevelWidget)) + else if (dynamic_cast(topLevelWidget)) { - RiuMainPlotWindow* mainPlotWindow = dynamic_cast(topLevelWidget); + RiuPlotMainWindow* mainPlotWindow = dynamic_cast(topLevelWidget); QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); if (subwindows.size() > 0) { diff --git a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index adcaa5b475..5b5ec4b58e 100644 --- a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -20,7 +20,7 @@ #include "RicToggleItemsFeatureImpl.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiaApplication.h" #include "cafPdmUiFieldHandle.h" @@ -161,7 +161,7 @@ caf::PdmUiTreeOrdering* RicToggleItemsFeatureImpl::findTreeItemFromSelectedUiIte QModelIndex modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex(uiItem); if(!modIndex.isValid()) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if(mainPlotWindow) { modIndex = mainPlotWindow->projectTreeView()->findModelIndex(uiItem); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index 1fdfae38b9..c75fe4711a 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -37,7 +37,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index 8ddc6a65a7..5aa90c4cd7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -32,7 +32,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicWellLogTools.h" diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp index 16fa64deca..de127dd677 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp @@ -28,7 +28,7 @@ #include "RigWellLogCurveData.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicNewWellLogPlotFeatureImpl.h" #include "RicWellLogPlotCurveFeatureImpl.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp index 7f06884d8f..65f697ed4b 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp @@ -30,7 +30,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTofAccumulatedPhaseFractionsPlot.h" #include "RiuWellAllocationPlot.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index de2ff98810..d90f21c660 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -28,7 +28,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuNightchartsWidget.h" #include "RiuWellAllocationPlot.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index f178b4ab3a..b539bb7746 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -43,7 +43,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuWellAllocationPlot.h" #include "RiuWellLogTrack.h" #include "RimWellLogFile.h" diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 2626e4332a..0538582d81 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -65,7 +65,7 @@ #include "RimWellPathCollection.h" #include "RimWellPathImport.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h" diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index db01263cec..020ce00d99 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -29,7 +29,7 @@ #include "RimWellRftPlot.h" #include "RimWellPltPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuWellLogPlot.h" #include "RiuWellLogTrack.h" diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 70d0f77225..4f2ce4aa90 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -40,7 +40,7 @@ #include "RimTools.h" #include "RiuLineSegmentQwtPlotCurve.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryCurveDefSelectionDialog.h" #include "RiuSummaryQwtPlot.h" @@ -653,7 +653,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, plot->updatePlotTitle(); plot->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } else if (changedField == &m_plotAxis) @@ -797,7 +797,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, plot->updatePlotTitle(); plot->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 94ec272b8c..1a91990a65 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -32,7 +32,7 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" @@ -448,7 +448,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c // have been changed due to the updates in this function curveCollection->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 0ea3d2d894..0702225453 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -7,7 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h -${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h ${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h @@ -80,7 +80,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp -${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.cpp @@ -153,7 +153,7 @@ ${SOURCE_GROUP_SOURCE_FILES} list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h -${CMAKE_CURRENT_LIST_DIR}/RiuMainPlotWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h ${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h diff --git a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp index a55c073c9f..fdc16117eb 100644 --- a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp @@ -24,7 +24,7 @@ #include "Rim3dView.h" #include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuViewer.h" diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp similarity index 93% rename from ApplicationCode/UserInterface/RiuMainPlotWindow.cpp rename to ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index ef2c97a978..b05000e771 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiaApplication.h" #include "RiaBaseDefs.h" @@ -51,18 +51,11 @@ #include #include -//================================================================================================== -/// -/// \class RiuMainPlotWindow -/// -/// Contains our main window -/// -//================================================================================================== //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) +RiuPlotMainWindow::RiuPlotMainWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { m_mdiArea = new QMdiArea; m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); @@ -86,15 +79,15 @@ RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_wind //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuMainPlotWindow::mainWindowName() +QString RiuPlotMainWindow::mainWindowName() { - return "RiuMainPlotWindow"; + return "RiuPlotMainWindow"; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::initializeGuiNewProjectLoaded() +void RiuPlotMainWindow::initializeGuiNewProjectLoaded() { setPdmRoot(RiaApplication::instance()->project()); restoreTreeViewState(); @@ -110,7 +103,7 @@ void RiuMainPlotWindow::initializeGuiNewProjectLoaded() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() +void RiuPlotMainWindow::cleanupGuiBeforeProjectClose() { setPdmRoot(nullptr); @@ -129,7 +122,7 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::cleanUpTemporaryWidgets() +void RiuPlotMainWindow::cleanUpTemporaryWidgets() { for (QWidget* w : m_temporaryWidgets) { @@ -143,7 +136,7 @@ void RiuMainPlotWindow::cleanUpTemporaryWidgets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::closeEvent(QCloseEvent* event) +void RiuPlotMainWindow::closeEvent(QCloseEvent* event) { RiaApplication* app = RiaApplication::instance(); @@ -169,7 +162,7 @@ void RiuMainPlotWindow::closeEvent(QCloseEvent* event) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createMenus() +void RiuPlotMainWindow::createMenus() { caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance(); @@ -263,7 +256,7 @@ void RiuMainPlotWindow::createMenus() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) +QStringList RiuPlotMainWindow::toolbarCommandIds(const QString& toolbarName) { QStringList commandIds; @@ -301,7 +294,7 @@ QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createToolBars() +void RiuPlotMainWindow::createToolBars() { caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance(); CVF_ASSERT(cmdFeatureMgr); @@ -331,7 +324,7 @@ void RiuMainPlotWindow::createToolBars() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::refreshToolbars() +void RiuPlotMainWindow::refreshToolbars() { QStringList allToolbarCommandNames = toolbarCommandIds(); @@ -341,7 +334,7 @@ void RiuMainPlotWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createDockPanels() +void RiuPlotMainWindow::createDockPanels() { { QDockWidget* dockWidget = new QDockWidget("Plot Project Tree", this); @@ -406,7 +399,7 @@ void RiuMainPlotWindow::createDockPanels() /// //-------------------------------------------------------------------------------------------------- -QMdiSubWindow* RiuMainPlotWindow::findMdiSubWindow(QWidget* viewer) +QMdiSubWindow* RiuPlotMainWindow::findMdiSubWindow(QWidget* viewer) { QList subws = m_mdiArea->subWindowList(); int i; @@ -424,7 +417,7 @@ QMdiSubWindow* RiuMainPlotWindow::findMdiSubWindow(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RiuMainPlotWindow::subWindowList(QMdiArea::WindowOrder order) +QList RiuPlotMainWindow::subWindowList(QMdiArea::WindowOrder order) { return m_mdiArea->subWindowList(order); } @@ -432,7 +425,7 @@ QList RiuMainPlotWindow::subWindowList(QMdiArea::WindowOrder ord //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) +void RiuPlotMainWindow::addToTemporaryWidgets(QWidget* widget) { CVF_ASSERT(widget); @@ -442,7 +435,7 @@ void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::updateSummaryPlotToolBar() +void RiuPlotMainWindow::updateSummaryPlotToolBar() { RimSummaryPlot* summaryPlot = dynamic_cast(m_activePlotViewWindow.p()); if (summaryPlot) @@ -469,7 +462,7 @@ void RiuMainPlotWindow::updateSummaryPlotToolBar() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::removeViewer(QWidget* viewer) +void RiuPlotMainWindow::removeViewer(QWidget* viewer) { m_blockSlotSubWindowActivated = true; m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); @@ -481,7 +474,7 @@ void RiuMainPlotWindow::removeViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) +void RiuPlotMainWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) { RiuMdiSubWindow* subWin = new RiuMdiSubWindow(m_mdiArea); subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed @@ -544,7 +537,7 @@ void RiuMainPlotWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& w //-------------------------------------------------------------------------------------------------- /// This method needs to handle memory deallocation !!! //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot) +void RiuPlotMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) { m_projectTreeView->setPdmItem(pdmRoot); // For debug only : m_projectTreeView->treeView()->expandAll(); @@ -554,7 +547,7 @@ void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) +void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) { if (!subWindow) return; @@ -583,7 +576,7 @@ void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) +void RiuPlotMainWindow::setActiveViewer(QWidget* viewer) { m_blockSlotSubWindowActivated = true; @@ -597,7 +590,7 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::slotBuildWindowActions() +void RiuPlotMainWindow::slotBuildWindowActions() { m_windowMenu->clear(); @@ -622,7 +615,7 @@ void RiuMainPlotWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::selectedObjectsChanged() +void RiuPlotMainWindow::selectedObjectsChanged() { std::vector uiItems; m_projectTreeView->selectedUiItems(uiItems); @@ -682,7 +675,7 @@ void RiuMainPlotWindow::selectedObjectsChanged() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::hideAllDockWindows() +void RiuPlotMainWindow::hideAllDockWindows() { QList dockWidgets = findChildren(); @@ -695,7 +688,7 @@ void RiuMainPlotWindow::hideAllDockWindows() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::restoreTreeViewState() +void RiuPlotMainWindow::restoreTreeViewState() { if (m_projectTreeView) { @@ -720,7 +713,7 @@ void RiuMainPlotWindow::restoreTreeViewState() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setDefaultWindowSize() +void RiuPlotMainWindow::setDefaultWindowSize() { resize(1000, 810); } @@ -728,7 +721,7 @@ void RiuMainPlotWindow::setDefaultWindowSize() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::customMenuRequested(const QPoint& pos) +void RiuPlotMainWindow::customMenuRequested(const QPoint& pos) { QMenu menu; @@ -749,7 +742,7 @@ void RiuMainPlotWindow::customMenuRequested(const QPoint& pos) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimMdiWindowGeometry RiuMainPlotWindow::windowGeometryForViewer(QWidget* viewer) +RimMdiWindowGeometry RiuPlotMainWindow::windowGeometryForViewer(QWidget* viewer) { QMdiSubWindow* mdiWindow = findMdiSubWindow(viewer); if (mdiWindow) @@ -763,7 +756,7 @@ RimMdiWindowGeometry RiuMainPlotWindow::windowGeometryForViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::tileWindows() +void RiuPlotMainWindow::tileWindows() { // Based on workaround described here // https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode @@ -783,7 +776,7 @@ void RiuMainPlotWindow::tileWindows() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuMainPlotWindow::isAnyMdiSubWindowVisible() +bool RiuPlotMainWindow::isAnyMdiSubWindowVisible() { return m_mdiArea->subWindowList().size() > 0; } diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuPlotMainWindow.h similarity index 97% rename from ApplicationCode/UserInterface/RiuMainPlotWindow.h rename to ApplicationCode/UserInterface/RiuPlotMainWindow.h index 680e30498e..43aa9d4ada 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.h @@ -48,12 +48,12 @@ namespace caf // // //================================================================================================== -class RiuMainPlotWindow : public RiuMainWindowBase +class RiuPlotMainWindow : public RiuMainWindowBase { Q_OBJECT public: - RiuMainPlotWindow(); + RiuPlotMainWindow(); QString mainWindowName() override; diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp index 2d70cf9b78..d056806ed8 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -18,7 +18,7 @@ #include "RiuPlotMainWindowTools.h" #include "RiaApplication.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" //-------------------------------------------------------------------------------------------------- /// @@ -33,7 +33,7 @@ void RiuPlotMainWindowTools::showPlotMainWindow() //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow) { - RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); if (mpw) mpw->setActiveViewer(subWindow); } @@ -43,7 +43,7 @@ void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow) //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/) { - RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); if (mpw) mpw->setExpanded(uiItem, expanded); } @@ -53,7 +53,7 @@ void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expa //-------------------------------------------------------------------------------------------------- void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/) { - RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange); } diff --git a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp index 46c1f6d6f3..ca09f25809 100644 --- a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp +++ b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp @@ -19,7 +19,7 @@ #include "RiuPlotObjectPicker.h" #include "RiaApplication.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include @@ -39,7 +39,7 @@ RiuPlotObjectPicker::RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associ //-------------------------------------------------------------------------------------------------- bool RiuPlotObjectPicker::eventFilter(QObject* watchedObject, QEvent* event) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow && m_associatedObject.notNull()) { if (event->type() == QEvent::MouseButtonPress) diff --git a/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp b/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp index e390dc143c..094858d8ec 100644 --- a/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp +++ b/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp @@ -30,7 +30,7 @@ #include "RimIdenticalGridCaseGroup.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" From 6ed6a55c4e05f711e4b992a1d3204861312688d2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 06:55:26 +0200 Subject: [PATCH 0801/1027] #2831 System : Display text in status bar to ensure the widget is created --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index c1d67c7fc0..7584257405 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -40,6 +40,7 @@ #include "RimProject.h" #include "RimSimWellInViewCollection.h" +#include "RiuDockWidgetTools.h" #include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" #include "RiuMessagePanel.h" @@ -81,10 +82,10 @@ #include #include #include +#include #include #include #include -#include "RiuDockWidgetTools.h" //================================================================================================== @@ -174,6 +175,11 @@ void RiuMainWindow::initializeGuiNewProjectLoaded() } m_processMonitor->slotClearTextEdit(); + + if (statusBar()) + { + statusBar()->showMessage("Ready ..."); + } } //-------------------------------------------------------------------------------------------------- From 478955d0f6bb51e39d414e588aea0059129e6701 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 07:38:32 +0200 Subject: [PATCH 0802/1027] #2816 Summary Curves : Replace empty auto name with plot title Also add a fallback if everything else ends up with an empty name --- .../ProjectDataModel/Summary/RimSummaryCurve.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 4f2ce4aa90..ba698dda55 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -356,9 +356,18 @@ QString RimSummaryCurve::createCurveAutoName() firstAncestorOrThisOfTypeAsserted(plot); QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + if (curveName.isEmpty()) + { + curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), nullptr); + } + if (isCrossPlotCurve()) { QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); + if (curveNameX.isEmpty()) + { + curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), nullptr); + } if (!curveName.isEmpty() || !curveNameX.isEmpty()) { @@ -366,6 +375,11 @@ QString RimSummaryCurve::createCurveAutoName() } } + if (curveName.isEmpty()) + { + curveName = "Curve Name Placeholder"; + } + return curveName; } From 0fcdfadddc484c508c82cdd0ce0d56262d2a1fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 08:26:44 +0200 Subject: [PATCH 0803/1027] #2813 Origin summary dialog. 'Ok to all' button --- .../Commands/RicSummaryCaseRestartDialog.cpp | 41 ++++++++----------- .../Commands/RicSummaryCaseRestartDialog.h | 8 ++-- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 4d6fdd66d7..d3cd23924c 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -107,13 +107,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn = new QRadioButton(this); m_gridSeparateCasesBtn = new QRadioButton(this); m_gridNotReadBtn = new QRadioButton(this); - m_applyToAllCheckBox = new QCheckBox(this); m_warnings = new QListWidget(this); - m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); // Connect to signals - connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); - connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); + connect(m_buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotDialogButtonClicked(QAbstractButton*))); // Set widget properties m_summaryReadAllBtn->setText("Unified"); @@ -121,8 +119,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn->setText("Skip"); m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridNotReadBtn->setText("Skip"); - m_applyToAllCheckBox->setText("OK to All"); - m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft); + m_buttons->button(QDialogButtonBox::Apply)->setText("OK to All"); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); @@ -171,7 +168,6 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Apply to all checkbox and buttons QHBoxLayout* buttonsLayout = new QHBoxLayout(); buttonsLayout->addStretch(1); - buttonsLayout->addWidget(m_applyToAllCheckBox); buttonsLayout->addWidget(m_buttons); dialogLayout->addWidget(m_currentFilesGroup); @@ -181,6 +177,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) dialogLayout->addLayout(buttonsLayout); setLayout(dialogLayout); + + m_okToAllPressed = false; } //-------------------------------------------------------------------------------------------------- @@ -331,7 +329,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // Set properties and show dialog dialog.setWindowTitle("Restart Files"); - dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); + dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -347,7 +345,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.selectedGridImportOption(), {}, {}, - dialog.applyToAllSelected()); + dialog.okToAllSelected()); } if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK) @@ -403,9 +401,9 @@ RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selected //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCaseRestartDialog::applyToAllSelected() const +bool RicSummaryCaseRestartDialog::okToAllSelected() const { - return m_applyToAllCheckBox->isChecked(); + return m_okToAllPressed; } //-------------------------------------------------------------------------------------------------- @@ -476,20 +474,13 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::slotDialogOkClicked() +void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* button) { - accept(); -} + bool okButtonClicked = m_buttons->button(QDialogButtonBox::Ok) == button; + bool cancelButtonClicked = m_buttons->button(QDialogButtonBox::Cancel) == button; + bool okToAllButtonClicked = m_buttons->button(QDialogButtonBox::Apply) == button; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::slotDialogCancelClicked() -{ - reject(); + m_okToAllPressed = okToAllButtonClicked; + if (cancelButtonClicked) reject(); + else accept(); } - -//-------------------------------------------------------------------------------------------------- -/// Internal functions -//-------------------------------------------------------------------------------------------------- - diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 9dfc7f98a4..63856868d0 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -38,6 +38,7 @@ class QGridLayout; class QCheckBox; class QGroupBox; class RicSummaryCaseRestartDialogResult; +class QAbstractButton; //================================================================================================== /// @@ -63,7 +64,7 @@ class RicSummaryCaseRestartDialog : public QDialog ImportOptions selectedSummaryImportOption() const; ImportOptions selectedGridImportOption() const; - bool applyToAllSelected() const; + bool okToAllSelected() const; private: void populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos); @@ -72,8 +73,7 @@ class RicSummaryCaseRestartDialog : public QDialog void displayWarningsIfAny(const QStringList& warnings); private slots: - void slotDialogOkClicked(); - void slotDialogCancelClicked(); + void slotDialogButtonClicked(QAbstractButton* button); private: QGroupBox* m_currentFilesGroup; @@ -91,9 +91,9 @@ private slots: QRadioButton* m_gridNotReadBtn; QRadioButton* m_gridSeparateCasesBtn; - QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; + bool m_okToAllPressed; QListWidget* m_warnings; }; From 101ed70cc989eaa99d12cd7b6678f33005871d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 09:00:34 +0200 Subject: [PATCH 0804/1027] Doc. Remove proposed classes --- doc/case_collections.plantuml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/case_collections.plantuml b/doc/case_collections.plantuml index bfebd6b19f..9c4f823606 100644 --- a/doc/case_collections.plantuml +++ b/doc/case_collections.plantuml @@ -13,22 +13,15 @@ package "Summary case ensamble" { RimSummaryCase -> RigCaseRealizationParameters - 'RimSummaryCaseMainCollection ..> RifEnsambleParametersReader RimSummaryCaseMainCollection ..> RifCaseRealizationParametersReader : create RifCaseRealizationParametersReader ..> RimSummaryCase : set parameters class RifSummaryReaderInterface { allResultAddresses() } - class RimEnsambleSummaryCase << New >> - class RifReaderEnsambleSummary << New >> RimSummaryCase <|-- RimGridSummaryCase - RimSummaryCase <|-- RimEnsambleSummaryCase RimSummaryCase --> RifSummaryReaderInterface RifSummaryReaderInterface <|-- RifReaderEclipseSummary - RifSummaryReaderInterface <|-- RifReaderEnsambleSummary - RimEnsambleSummaryCase ..> RifReaderEnsambleSummary - RimEnsambleSummaryCase --> RimSummaryCaseCollection RimGridSummaryCase ..> RifReaderEclipseSummary } From ae3cc0010d6aef92848e9e0055514e2910b42f09 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 09:29:05 +0200 Subject: [PATCH 0805/1027] Reapply import menu improvements in 3bc102bb019807ad5bc89d3dc5dbc97f040a8a9f Changes was unitentionally reverted by 132db2bb1e1bbb1e2c19fc22a4702eea4ee70900 --- .../UserInterface/RiuMainWindow.cpp | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 7584257405..0a6ee7af3f 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -370,30 +370,39 @@ void RiuMainWindow::createMenus() QMenu* importMenu = fileMenu->addMenu("&Import"); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); - importMenu->addSeparator(); + + QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + #ifdef USE_ODB_API - importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); + + importMenu->addSeparator(); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); From f1fbe4d8ac419636af1d0d708352067bcf8eb99a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 11:58:22 +0200 Subject: [PATCH 0806/1027] PlotCurve : Remove duplicate code --- .../ProjectDataModel/RimPlotCurve.cpp | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 8cdffdd573..57a0c53328 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -550,7 +550,7 @@ void RimPlotCurve::showLegend(bool show) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::setZOrder(double z) { @@ -561,24 +561,11 @@ void RimPlotCurve::setZOrder(double z) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() { - if (m_showLegend()) { - if (m_curveName().isEmpty()) - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, true); - } - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } + updateLegendEntryVisibilityNoPlotUpdate(); if (m_parentQwtPlot != nullptr) { @@ -587,11 +574,12 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { - if (m_showLegend()) { + if (m_showLegend()) + { if (m_curveName().isEmpty()) { m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); @@ -605,4 +593,4 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); } -} \ No newline at end of file +} From 23c439fe6b77d6aa9410ae214228e721e6387aec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 12:40:46 +0200 Subject: [PATCH 0807/1027] #2831 StatusBar : Hide statusBar during regression test execution --- ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp | 2 ++ ApplicationCode/Application/Tools/RiaRegressionTestRunner.h | 4 ++-- ApplicationCode/UserInterface/RiuMainWindow.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp index bd84b6eb81..44d3631b17 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -494,6 +495,7 @@ void RiaRegressionTestRunner::executeRegressionTests(const QString& regressionTe if (mainWnd) { mainWnd->hideAllDockWindows(); + mainWnd->statusBar()->close(); mainWnd->setDefaultWindowSize(); runRegressionTest(regressionTestPath, testFilter); diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h index 7a622f9ff8..40ec63cf9d 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h @@ -29,8 +29,6 @@ class QDir; class RiaRegressionTestRunner { public: - RiaRegressionTestRunner(); - static RiaRegressionTestRunner* instance(); void executeRegressionTests(const QString& regressionTestPath, const QStringList& testFilter); @@ -41,6 +39,8 @@ class RiaRegressionTestRunner static void updateRegressionTest(const QString& testRootPath); private: + RiaRegressionTestRunner(); + void runRegressionTest(const QString& testRootPath, const QStringList& testFilter); static void removeDirectoryWithContent(QDir& dirToDelete); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 0a6ee7af3f..d598cf9919 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -176,14 +176,14 @@ void RiuMainWindow::initializeGuiNewProjectLoaded() m_processMonitor->slotClearTextEdit(); - if (statusBar()) + if (statusBar() && !RiaRegressionTestRunner::instance()->isRunningRegressionTests()) { statusBar()->showMessage("Ready ..."); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMainWindow::cleanupGuiCaseClose() { From 7ff30a13d159328d7f99669a03dd2895fbd57155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 10:46:54 +0200 Subject: [PATCH 0808/1027] #2813 Fix logic for removing common root path --- .../Application/Tools/RiaFilePathTools.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp index 025837684b..3328871ac9 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -100,22 +100,30 @@ QString RiaFilePathTools::canonicalPath(const QString& path) //-------------------------------------------------------------------------------------------------- QString RiaFilePathTools::commonRootPath(const QStringList& paths) { - QString root = paths.front(); - for (const auto& item : paths) + if (paths.size() < 2) return ""; + + int i = 0; + int iDir = 0; + for(i = 0; ; i++) { - if (root.length() > item.length()) root.truncate(item.length()); + bool isCommon = true; + QChar ch = i < paths.front().size() ? paths.front()[i] : 0; - int iDir = 0; - for (int i = 0; i < root.length(); ++i) - { - if (i > 0 && (root[i-1] == '/' || root[i-1] == '\\')) iDir = i; + // Remember last directory separator + if (i > 0 && (ch == '/' || ch == '\\')) iDir = i; - if (root[i] != item[i] || i == root.length() - 1) + // Compare characters at position i + for (const QString& path : paths) + { + if (ch == 0 || path[i] != ch) { - root.truncate(std::min(i, iDir)); + isCommon = false; break; } } + + if (!isCommon) break; } - return root; + + return paths.front().left(iDir + 1); } From 9a5134332147347481c6b3d5d6e83b95ff7d090c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 11:46:32 +0200 Subject: [PATCH 0809/1027] #2813 Origin import dialog. Remove misplaced assert --- ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp index 177fb65ccb..9cb9c54d82 100644 --- a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -400,7 +400,6 @@ RifSummaryCaseFileImportInfo::RifSummaryCaseFileImportInfo(const QString& summar , m_gridFileName(gridFileName) , m_failOnSummaryFileImportError(false) { - CVF_ASSERT(!m_summaryFileName.isEmpty()); } //-------------------------------------------------------------------------------------------------- From fa2c188452614559f9bf61bacc37aa6620713d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 11:51:39 +0200 Subject: [PATCH 0810/1027] #2813 Origin import dialog. Import options group box replaced by label --- .../Commands/RicSummaryCaseRestartDialog.cpp | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index d3cd23924c..ec21a846fd 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -66,7 +66,7 @@ //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -std::vector> removeRootPath(const std::vector>& fileInfoLists) +std::vector> removeCommonRootPath(const std::vector>& fileInfoLists) { // Find common root path among all paths QStringList allPaths; @@ -129,40 +129,45 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_currentFilesGroup->setLayout(m_currentFilesLayout); // Summary files - QGroupBox* summaryFilesGroup = new QGroupBox("Found Origin Summary Files"); + QGroupBox* summaryFilesGroup = new QGroupBox("Origin Summary Files"); { QVBoxLayout* filesGroupLayout = new QVBoxLayout(); summaryFilesGroup->setLayout(filesGroupLayout); m_summaryFilesLayout = new QGridLayout(); filesGroupLayout->addLayout(m_summaryFilesLayout); - m_summaryFilesLayout->setContentsMargins(0, 0, 0, 20); + m_summaryFilesLayout->setContentsMargins(0, 0, 0, 5); + + QLabel* optionsLabel = new QLabel("Import Options"); + optionsLabel->setStyleSheet("font-weight: bold;"); + filesGroupLayout->addWidget(optionsLabel); - QGroupBox* optionsGroup = new QGroupBox("Import Options"); QVBoxLayout* optionsLayout = new QVBoxLayout(); - optionsGroup->setLayout(optionsLayout); + optionsLayout->setContentsMargins(0, 0, 0, 0); optionsLayout->addWidget(m_summaryReadAllBtn); optionsLayout->addWidget(m_summarySeparateCasesBtn); optionsLayout->addWidget(m_summaryNotReadBtn); - filesGroupLayout->addWidget(optionsGroup); + filesGroupLayout->addLayout(optionsLayout); } // Grid files - m_gridFilesGroup = new QGroupBox("Found Origin Grid Files"); + m_gridFilesGroup = new QGroupBox("Origin Grid Files"); { QVBoxLayout* filesGroupLayout = new QVBoxLayout(); m_gridFilesGroup->setLayout(filesGroupLayout); m_gridFilesLayout = new QGridLayout(); filesGroupLayout->addLayout(m_gridFilesLayout); - m_gridFilesLayout->setContentsMargins(0, 0, 0, 20); + m_gridFilesLayout->setContentsMargins(0, 0, 0, 5); + + QLabel* optionsLabel = new QLabel("Import Options"); + optionsLabel->setStyleSheet("font-weight: bold;"); + filesGroupLayout->addWidget(optionsLabel); - QGroupBox* optionsGroup = new QGroupBox("Import Options"); QVBoxLayout* optionsLayout = new QVBoxLayout(); - optionsGroup->setLayout(optionsLayout); optionsLayout->addWidget(m_gridSeparateCasesBtn); optionsLayout->addWidget(m_gridNotReadBtn); - filesGroupLayout->addWidget(optionsGroup); + filesGroupLayout->addLayout(optionsLayout); } // Apply to all checkbox and buttons @@ -313,7 +318,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } // Remove common root path - std::vector> fileInfosNoRoot = removeRootPath( + std::vector> fileInfosNoRoot = removeCommonRootPath( { currentFileInfos, originSummaryFileInfos, originGridFileInfos } From fd3bdff4e5a88b2e25f90edac509cc56cc0bd0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 12:41:38 +0200 Subject: [PATCH 0811/1027] Hierarchy dialog. Do not clear root path field when clicking cancel in browse dialog --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index aac2f9439e..16ccde8836 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -749,7 +749,7 @@ void RicFileHierarchyDialog::slotDialogCancelClicked() void RicFileHierarchyDialog::slotBrowseButtonClicked() { QString folder = QFileDialog::getExistingDirectory(this, "Select root folder", m_rootDir->text()); - m_rootDir->setText(folder); + if(!folder.isEmpty()) m_rootDir->setText(folder); } From 4c2eeb9a9f53272014e0e0b79466f5e49243cb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 12:43:16 +0200 Subject: [PATCH 0812/1027] #2813 Origin import dialog. Full path in tool tip --- .../Commands/RicSummaryCaseRestartDialog.cpp | 21 ++++++++++--------- .../Commands/RicSummaryCaseRestartDialog.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index ec21a846fd..eb535e195a 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -66,7 +66,7 @@ //-------------------------------------------------------------------------------------------------- /// Internal functions //-------------------------------------------------------------------------------------------------- -std::vector> removeCommonRootPath(const std::vector>& fileInfoLists) +std::vector>> removeCommonRootPath(const std::vector>& fileInfoLists) { // Find common root path among all paths QStringList allPaths; @@ -78,15 +78,16 @@ std::vector> removeCommonRootPath(const std::vec int commonRootSize = commonRoot.size(); // Build output lists - std::vector> output; + std::vector>> output; for (const auto& fileInfoList : fileInfoLists) { - std::vector currList; + std::vector> currList; for (auto& fi : fileInfoList) { - RifRestartFileInfo newFi = fi; - newFi.fileName.remove(0, commonRootSize); + std::pair newFi; + newFi = std::make_pair(fi, fi.fileName); + newFi.first.fileName.remove(0, commonRootSize); currList.push_back(newFi); } output.push_back(currList); @@ -318,7 +319,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } // Remove common root path - std::vector> fileInfosNoRoot = removeCommonRootPath( + std::vector>> fileInfosNoRoot = removeCommonRootPath( { currentFileInfos, originSummaryFileInfos, originGridFileInfos } @@ -414,7 +415,7 @@ bool RicSummaryCaseRestartDialog::okToAllSelected() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos) +void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, const std::vector>& fileInfos) { if (fileInfos.empty()) { @@ -424,14 +425,14 @@ void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, cons for (const auto& fileInfo : fileInfos) { - appendFileInfoToGridLayout(gridLayout, fileInfo); + appendFileInfoToGridLayout(gridLayout, fileInfo.first, fileInfo.second); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo) +void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName) { CVF_ASSERT(gridLayout); @@ -451,7 +452,7 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa gridLayout->addWidget(dateLabel, rowCount, 1); // Full path in tooltip - fileNameLabel->setToolTip(fileInfo.fileName); + fileNameLabel->setToolTip(fullPathFileName); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 63856868d0..ade32aa26e 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -67,8 +67,8 @@ class RicSummaryCaseRestartDialog : public QDialog bool okToAllSelected() const; private: - void populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos); - void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo); + void populateFileList(QGridLayout* gridLayout, const std::vector>& fileInfos); + void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); void displayWarningsIfAny(const QStringList& warnings); From 313ae8f5053a19520ebfad516b3a973a6005d3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 13:07:53 +0200 Subject: [PATCH 0813/1027] #2813 Origin import dialog. Spacing between groups --- .../Commands/RicSummaryCaseRestartDialog.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index eb535e195a..5556a95bef 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -144,7 +144,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) filesGroupLayout->addWidget(optionsLabel); QVBoxLayout* optionsLayout = new QVBoxLayout(); - optionsLayout->setContentsMargins(0, 0, 0, 0); + optionsLayout->setSpacing(0); optionsLayout->addWidget(m_summaryReadAllBtn); optionsLayout->addWidget(m_summarySeparateCasesBtn); optionsLayout->addWidget(m_summaryNotReadBtn); @@ -166,6 +166,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) filesGroupLayout->addWidget(optionsLabel); QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsLayout->setSpacing(0); optionsLayout->addWidget(m_gridSeparateCasesBtn); optionsLayout->addWidget(m_gridNotReadBtn); filesGroupLayout->addLayout(optionsLayout); @@ -176,9 +177,13 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) buttonsLayout->addStretch(1); buttonsLayout->addWidget(m_buttons); - dialogLayout->addWidget(m_currentFilesGroup); - dialogLayout->addWidget(summaryFilesGroup); - dialogLayout->addWidget(m_gridFilesGroup); + QVBoxLayout* innerDialogLayout = new QVBoxLayout(); + innerDialogLayout->setSpacing(20); + innerDialogLayout->addWidget(m_currentFilesGroup); + innerDialogLayout->addWidget(summaryFilesGroup); + innerDialogLayout->addWidget(m_gridFilesGroup); + + dialogLayout->addLayout(innerDialogLayout); dialogLayout->addWidget(m_warnings); dialogLayout->addLayout(buttonsLayout); From 6463a671073da31e1d0158093b64f3afc5242c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 13:21:00 +0200 Subject: [PATCH 0814/1027] #2813 Origin import dialog. Bold group box titles --- ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 5556a95bef..a26c1a42a9 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -126,12 +126,15 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) QVBoxLayout* dialogLayout = new QVBoxLayout(); m_currentFilesGroup = new QGroupBox("Current Summary File"); + m_currentFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); m_currentFilesLayout = new QGridLayout(); m_currentFilesGroup->setLayout(m_currentFilesLayout); // Summary files QGroupBox* summaryFilesGroup = new QGroupBox("Origin Summary Files"); { + summaryFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); summaryFilesGroup->setLayout(filesGroupLayout); @@ -154,6 +157,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Grid files m_gridFilesGroup = new QGroupBox("Origin Grid Files"); { + m_gridFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); m_gridFilesGroup->setLayout(filesGroupLayout); From c831553cc2624100693530f352db1c4481f4fa89 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 13:03:39 +0200 Subject: [PATCH 0815/1027] #2816 Summary Curves : Hide legend in Qwt if only one curve is present --- .../ProjectDataModel/RimPlotCurve.cpp | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 57a0c53328..cef2b397a4 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -17,9 +17,11 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPlotCurve.h" + +#include "RimEnsembleCurveSet.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" -#include "RimEnsembleCurveSet.h" +#include "RimSummaryPlot.h" #include "RiuLineSegmentQwtPlotCurve.h" @@ -578,19 +580,15 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { - if (m_showLegend()) - { - if (m_curveName().isEmpty()) - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, true); - } - } - else + bool showLegendInQwt = m_showLegend(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfType(summaryPlot); + if (summaryPlot && summaryPlot->curveCount() == 1) { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); + // Disable display of legend if the summary plot has only one single curve + showLegendInQwt = false; } + + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } From 44c3e2c60211a850e0f9e9703a264ea6b31313b7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 13:07:33 +0200 Subject: [PATCH 0816/1027] #2780 Ensemble Curve Set : Add basic auto name of curve set --- .../Summary/RimEnsembleCurveSet.cpp | 79 ++++++++++++++++++- .../Summary/RimEnsembleCurveSet.h | 12 ++- .../Summary/RimSummaryCurveAutoName.cpp | 15 ++++ 3 files changed, 101 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 29d55c58b9..63b28d7259 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -22,15 +22,16 @@ #include "RifReaderEclipseSummary.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" +#include "RimSummaryAddress.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" -#include "RimSummaryPlot.h" +#include "RimSummaryCurveAutoName.h" #include "RimSummaryFilter.h" -#include "RimSummaryAddress.h" -#include "RimEnsembleCurveSetCollection.h" +#include "RimSummaryPlot.h" #include "RiuSummaryQwtPlot.h" @@ -113,6 +114,20 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); m_legendConfig = new RimRegularLegendConfig(); + + CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensamble Curve Set"), "Curve Set Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", ""); + m_autoGeneratedName.registerGetMethod(this, &RimEnsembleCurveSet::createAutoName); + m_autoGeneratedName.uiCapability()->setUiReadOnly(true); + m_autoGeneratedName.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_summaryAddressNameTools, "SummaryAddressNameTools", "SummaryAddressNameTools", "", "", ""); + m_summaryAddressNameTools.uiCapability()->setUiHidden(true); + m_summaryAddressNameTools.uiCapability()->setUiTreeChildrenHidden(true); + + m_summaryAddressNameTools = new RimSummaryCurveAutoName; } //-------------------------------------------------------------------------------------------------- @@ -326,6 +341,10 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie updateQwtPlotAxis(); plot->updateAxes(); } + else if (changedField == &m_isUsingAutoName && !m_isUsingAutoName) + { + m_userDefinedName = createAutoName(); + } } //-------------------------------------------------------------------------------------------------- @@ -333,6 +352,21 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + { + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); + nameGroup->setCollapsedByDefault(true); + nameGroup->add(&m_isUsingAutoName); + if (m_isUsingAutoName) + { + nameGroup->add(&m_autoGeneratedName); + m_summaryAddressNameTools->uiOrdering(uiConfigName, *nameGroup); + } + else + { + nameGroup->add(&m_userDefinedName); + } + } + { QString curveDataGroupName = "Summary Vector"; caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y"); @@ -387,6 +421,21 @@ void RimEnsembleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsembleCurveSet::userDescriptionField() +{ + if (m_isUsingAutoName) + { + return &m_autoGeneratedName; + } + else + { + return &m_userDefinedName; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimEnsembleCurveSet::objectToggleField() { return &m_showCurves; @@ -632,4 +681,26 @@ std::vector RimEnsembleCurveSet::ensembleParameters() const } } return std::vector(paramSet.begin(), paramSet.end()); -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEnsembleCurveSet::createAutoName() const +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted(plot); + + QString curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + if (curveSetName.isEmpty()) + { + curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), nullptr); + } + + if (curveSetName.isEmpty()) + { + curveSetName = "Name Placeholder"; + } + + return curveSetName; +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 9d9b6e2b7f..1431393f39 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -35,6 +35,7 @@ #include "cafAppEnum.h" #include "RifEclipseSummaryAddressQMetaType.h" +#include "cafPdmProxyValueField.h" class QwtPlot; class QwtPlotCurve; @@ -44,6 +45,7 @@ class RimSummaryCurve; class RimSummaryAddress; class RimSummaryFilter; class RimSummaryPlotSourceStepping; +class RimSummaryCurveAutoName; class QKeyEvent; //================================================================================================== @@ -78,6 +80,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void onLegendDefinitionChanged(); private: + caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField(); virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; @@ -101,13 +104,15 @@ class RimEnsembleCurveSet : public caf::PdmObject void updateAllCurves(); std::vector ensembleParameters() const; + QString createAutoName() const; + + private: caf::PdmField m_showCurves; caf::PdmChildArrayField m_curves; caf::PdmPointer m_currentSummaryCurve; - // Y values caf::PdmPtrField m_yValuesSummaryGroup; caf::PdmChildField m_yValuesCurveVariable; caf::PdmField m_yValuesSelectedVariableDisplayField; @@ -123,6 +128,11 @@ class RimEnsembleCurveSet : public caf::PdmObject caf::PdmChildField m_legendConfig; + caf::PdmField m_isUsingAutoName; + caf::PdmField m_userDefinedName; + caf::PdmProxyValueField m_autoGeneratedName; + caf::PdmChildField m_summaryAddressNameTools; + std::set m_allAddressesCache; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 0bd7b9f400..fa86d4bad0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -27,6 +27,7 @@ #include "SummaryPlotCommands/RicSummaryCurveCreator.h" #include "cafPdmUiPushButtonEditor.h" +#include "RimEnsembleCurveSet.h" CAF_PDM_SOURCE_INIT(RimSummaryCurveAutoName, "SummaryCurveAutoName"); @@ -323,6 +324,8 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change { summaryCurve->updateCurveNameAndUpdatePlotLegend(); summaryCurve->updateConnectedEditors(); + + return; } RicSummaryCurveCreator* curveCreator = dynamic_cast(this->parentField()->ownerObject()); @@ -330,6 +333,18 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change { curveCreator->updateCurveNames(); curveCreator->updateConnectedEditors(); + + return; + } + + { + auto ensambleCurveSet = dynamic_cast(this->parentField()->ownerObject()); + if (ensambleCurveSet) + { + ensambleCurveSet->updateConnectedEditors(); + + return; + } } } From 67eedc0f4693727e69ce6be81c0761577b86fcd3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 13:30:51 +0200 Subject: [PATCH 0817/1027] Move implementation to source file and whitespace cleanup --- .../Summary/RimSummaryCaseCollection.cpp | 42 ++++++++++++------- .../Summary/RimSummaryCaseCollection.h | 23 +++++----- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 2dd30d41d9..90d6e63f5e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -22,12 +22,10 @@ #include "RimProject.h" #include "RimSummaryCase.h" -#include - -CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection,"SummaryCaseSubCollection"); +CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection, "SummaryCaseSubCollection"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::RimSummaryCaseCollection() { @@ -40,7 +38,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::~RimSummaryCaseCollection() { @@ -48,7 +46,7 @@ RimSummaryCaseCollection::~RimSummaryCaseCollection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase) { @@ -56,7 +54,7 @@ void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::addCase(RimSummaryCase* summaryCase) { @@ -64,7 +62,7 @@ void RimSummaryCaseCollection::addCase(RimSummaryCase* summaryCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCaseCollection::allSummaryCases() { @@ -72,11 +70,25 @@ std::vector RimSummaryCaseCollection::allSummaryCases() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() +void RimSummaryCaseCollection::setName(const QString& name) { - return &m_name; + m_name = name; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseCollection::name() const +{ + return m_name; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() +{ + return &m_name; +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 84985633f3..8881db1d3b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -1,20 +1,21 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #pragma once #include "cafPdmChildArrayField.h" @@ -28,19 +29,19 @@ class RimSummaryCase; class RimSummaryCaseCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; + public: RimSummaryCaseCollection(); virtual ~RimSummaryCaseCollection(); - - void removeCase(RimSummaryCase* summaryCase); - void addCase(RimSummaryCase* summaryCase); - std::vector allSummaryCases(); - void setName(const QString& name) { m_name = name; } - QString name() const { return m_name; } + void removeCase(RimSummaryCase* summaryCase); + void addCase(RimSummaryCase* summaryCase); + std::vector allSummaryCases(); + void setName(const QString& name); + QString name() const; private: - virtual caf::PdmFieldHandle* userDescriptionField() override; + caf::PdmFieldHandle* userDescriptionField() override; private: caf::PdmChildArrayField m_cases; From c0777e4950eee737052e5181f5fcb259b474e70f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 13:36:23 +0200 Subject: [PATCH 0818/1027] #2780 Ensemble Curve Set : Use ensamble name as case name --- .../Summary/RimEnsembleCurveSet.cpp | 8 +++++++ .../Summary/RimEnsembleCurveSet.h | 2 ++ .../Summary/RimSummaryCurveAutoName.cpp | 23 ++++++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 63b28d7259..15858e7b66 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -293,6 +293,14 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged() updateCurveColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RimEnsembleCurveSet::summaryCaseCollection() const +{ + return m_yValuesSummaryGroup(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 1431393f39..68da28d220 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -79,6 +79,8 @@ class RimEnsembleCurveSet : public caf::PdmObject RimRegularLegendConfig* legendConfig(); void onLegendDefinitionChanged(); + RimSummaryCaseCollection* summaryCaseCollection() const; + private: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index fa86d4bad0..663de98d87 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -20,14 +20,15 @@ #include "RifEclipseSummaryAddress.h" +#include "RimEnsembleCurveSet.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryPlotNameHelper.h" #include "SummaryPlotCommands/RicSummaryCurveCreator.h" #include "cafPdmUiPushButtonEditor.h" -#include "RimEnsembleCurveSet.h" CAF_PDM_SOURCE_INIT(RimSummaryCurveAutoName, "SummaryCurveAutoName"); @@ -49,7 +50,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() CAF_PDM_InitField(&m_completion, "Completion", true, "I, J, K", "", "", ""); CAF_PDM_InitField(&m_aquiferNumber, "Aquifer", true, "Aquifer Number", "", "", ""); - CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case Name", "", "", ""); + CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case/Ensemble Name", "", "", ""); // clang-format on } @@ -81,7 +82,23 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ appendAddressDetails(text, summaryAddress, nameHelper); - if (summaryCurve) + RimEnsembleCurveSet* ensambleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensambleCurveSet); + + if (ensambleCurveSet) + { + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); + + if (m_caseName && !skipSubString) + { + if (ensambleCurveSet && ensambleCurveSet->summaryCaseCollection()) + { + if (text.size() > 0) text += ", "; + text += ensambleCurveSet->summaryCaseCollection()->name().toStdString(); + } + } + } + else if (summaryCurve) { bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); From 6bbe02546721b6c61eef15e7a23efb0af5329762 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Apr 2018 13:38:10 +0200 Subject: [PATCH 0819/1027] Use emtyp() instead of size() --- .../Summary/RimSummaryCurveAutoName.cpp | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 663de98d87..759a1732cd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -59,7 +59,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper) const + const RimSummaryPlotNameHelper* nameHelper) const { std::string text; @@ -93,7 +93,7 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ { if (ensambleCurveSet && ensambleCurveSet->summaryCaseCollection()) { - if (text.size() > 0) text += ", "; + if (!text.empty()) text += ", "; text += ensambleCurveSet->summaryCaseCollection()->name().toStdString(); } } @@ -106,7 +106,7 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ { if (summaryCurve && summaryCurve->summaryCaseY()) { - if (text.size() > 0) text += ", "; + if (!text.empty()) text += ", "; text += summaryCurve->summaryCaseY()->caseName().toStdString(); } } @@ -150,7 +150,7 @@ QString RimSummaryCurveAutoName::curveNameX(const RifEclipseSummaryAddress& summ { if (summaryCurve && summaryCurve->summaryCaseX()) { - if (text.size() > 0) text += ", "; + if (!text.empty()) text += ", "; text += summaryCurve->summaryCaseX()->caseName().toStdString(); } } @@ -179,7 +179,8 @@ void RimSummaryCurveAutoName::applySettings(const RimSummaryCurveAutoName& other //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, +void RimSummaryCurveAutoName::appendWellName(std::string& text, + const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { bool skipSubString = nameHelper && nameHelper->isWellNameInTitle(); @@ -187,7 +188,7 @@ void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipse if (m_wellName) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += summaryAddress.wellName(); } } @@ -199,7 +200,7 @@ void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseS { if (m_lgrName) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += ":" + summaryAddress.lgrName(); } } @@ -207,7 +208,8 @@ void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifEclipseSummaryAddress& summaryAddress, +void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, + const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { switch (summaryAddress.category()) @@ -216,7 +218,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_aquiferNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.aquiferNumber()); } } @@ -228,7 +230,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE bool skipSubString = nameHelper && nameHelper->isRegionInTitle(); if (!skipSubString) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.regionNumber()); } } @@ -238,7 +240,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_regionNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.regionNumber()); text += "-" + std::to_string(summaryAddress.regionNumber2()); } @@ -251,13 +253,15 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE bool skipSubString = nameHelper && nameHelper->isWellGroupNameInTitle(); if (!skipSubString) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += summaryAddress.wellGroupName(); } } } break; - case RifEclipseSummaryAddress::SUMMARY_WELL: { appendWellName(text, summaryAddress, nameHelper); + case RifEclipseSummaryAddress::SUMMARY_WELL: + { + appendWellName(text, summaryAddress, nameHelper); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: @@ -266,7 +270,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -285,7 +289,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -297,7 +301,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_wellSegmentNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += ":" + summaryAddress.wellSegmentNumber(); } } @@ -306,7 +310,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -318,7 +322,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -330,8 +334,9 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, - const QVariant& newValue) +void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { // NOTE: The curve filter is parent object of a summary curve, and the update is supposed to update // the first parent, not the grandparent. This is the reason for not using firstAncestorOrThisOfType() @@ -359,7 +364,7 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change if (ensambleCurveSet) { ensambleCurveSet->updateConnectedEditors(); - + return; } } From 14d78571a84663915b09fb7df6da0cd930c52d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 15:37:18 +0200 Subject: [PATCH 0820/1027] #2813 Origin import dialog. Add toggle 'show full paths' --- .../Commands/RicSummaryCaseRestartDialog.cpp | 77 ++++++++++++++++--- .../Commands/RicSummaryCaseRestartDialog.h | 13 +++- 2 files changed, 80 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index a26c1a42a9..64514cd9c4 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -95,6 +95,36 @@ std::vector>> removeCommonRoo return output; } +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +std::vector>> makeShortPath(const std::vector>& fileInfoLists) +{ + // Build output lists + std::vector>> output; + + QString currentFilePath = QFileInfo(fileInfoLists[CURRENT_FILES_LIST_INDEX].front().fileName).absoluteDir().absolutePath(); + + for (const auto& fileInfoList : fileInfoLists) + { + std::vector> currList; + + for (auto& fi : fileInfoList) + { + std::pair newFi; + newFi = std::make_pair(fi, fi.fileName); + QFileInfo(fi.fileName).fileName(); + + QString absPath = QFileInfo(fi.fileName).absoluteDir().absolutePath(); + QString prefix = RiaFilePathTools::equalPaths(currentFilePath, absPath) ? "" : ".../"; + newFi.first.fileName = prefix + QFileInfo(fi.fileName).fileName(); + currList.push_back(newFi); + } + output.push_back(currList); + } + return output; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -109,9 +139,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_gridSeparateCasesBtn = new QRadioButton(this); m_gridNotReadBtn = new QRadioButton(this); m_warnings = new QListWidget(this); + m_showFullPathCheckBox = new QCheckBox(this); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); // Connect to signals + connect(m_showFullPathCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotShowFullPathToggled(int))); connect(m_buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotDialogButtonClicked(QAbstractButton*))); // Set widget properties @@ -120,6 +152,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn->setText("Skip"); m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridNotReadBtn->setText("Skip"); + m_showFullPathCheckBox->setText("Show full paths"); m_buttons->button(QDialogButtonBox::Apply)->setText("OK to All"); // Define layout @@ -179,6 +212,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Apply to all checkbox and buttons QHBoxLayout* buttonsLayout = new QHBoxLayout(); + buttonsLayout->addWidget(m_showFullPathCheckBox); buttonsLayout->addStretch(1); buttonsLayout->addWidget(m_buttons); @@ -329,16 +363,21 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const } // Remove common root path - std::vector>> fileInfosNoRoot = removeCommonRootPath( + std::vector>> fileInfosNoRoot = makeShortPath( { currentFileInfos, originSummaryFileInfos, originGridFileInfos } ); - // Populate file list widgets - dialog.populateFileList(dialog.m_currentFilesLayout, fileInfosNoRoot[0]); - dialog.populateFileList(dialog.m_summaryFilesLayout, fileInfosNoRoot[1]); - dialog.populateFileList(dialog.m_gridFilesLayout, fileInfosNoRoot[2]); + // Populate file list backing lists + dialog.m_fileLists.push_back(fileInfosNoRoot[CURRENT_FILES_LIST_INDEX]); + dialog.m_fileLists.push_back(fileInfosNoRoot[SUMMARY_FILES_LIST_INDEX]); + dialog.m_fileLists.push_back(fileInfosNoRoot[GRID_FILES_LIST_INDEX]); + + // Update file list widgets + dialog.updateFileListWidget(dialog.m_currentFilesLayout, CURRENT_FILES_LIST_INDEX); + dialog.updateFileListWidget(dialog.m_summaryFilesLayout, SUMMARY_FILES_LIST_INDEX); + dialog.updateFileListWidget(dialog.m_gridFilesLayout, GRID_FILES_LIST_INDEX); // Display warnings if any dialog.displayWarningsIfAny(reader.warnings()); @@ -425,15 +464,24 @@ bool RicSummaryCaseRestartDialog::okToAllSelected() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, const std::vector>& fileInfos) +void RicSummaryCaseRestartDialog::updateFileListWidget(QGridLayout* gridLayout, int listIndex) { - if (fileInfos.empty()) + // Remove current items + QLayoutItem* item; + while (item = gridLayout->takeAt(0)) + { + gridLayout->removeItem(item); + delete item->widget(); + delete item; + } + + if (m_fileLists[listIndex].empty()) { QWidget* parent = gridLayout->parentWidget(); if (parent) parent->setVisible(false); } - for (const auto& fileInfo : fileInfos) + for (const auto& fileInfo : m_fileLists[listIndex]) { appendFileInfoToGridLayout(gridLayout, fileInfo.first, fileInfo.second); } @@ -454,7 +502,7 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa QLabel* fileNameLabel = new QLabel(); QLabel* dateLabel = new QLabel(); - fileNameLabel->setText(fileInfo.fileName); + fileNameLabel->setText(m_showFullPathCheckBox->isChecked() ? fullPathFileName : fileInfo.fileName); dateLabel->setText(startDateString + " - " + endDateString); fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -487,6 +535,17 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotShowFullPathToggled(int state) +{ + // Update file list widgets + updateFileListWidget(m_currentFilesLayout, CURRENT_FILES_LIST_INDEX); + updateFileListWidget(m_summaryFilesLayout, SUMMARY_FILES_LIST_INDEX); + updateFileListWidget(m_gridFilesLayout, GRID_FILES_LIST_INDEX); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index ade32aa26e..8ae598088c 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -40,6 +40,13 @@ class QGroupBox; class RicSummaryCaseRestartDialogResult; class QAbstractButton; +//================================================================================================== +/// Constants +//================================================================================================== +#define CURRENT_FILES_LIST_INDEX 0 +#define SUMMARY_FILES_LIST_INDEX 1 +#define GRID_FILES_LIST_INDEX 2 + //================================================================================================== /// //================================================================================================== @@ -67,12 +74,13 @@ class RicSummaryCaseRestartDialog : public QDialog bool okToAllSelected() const; private: - void populateFileList(QGridLayout* gridLayout, const std::vector>& fileInfos); + void updateFileListWidget(QGridLayout* gridLayout, int listIndex); void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); void displayWarningsIfAny(const QStringList& warnings); private slots: + void slotShowFullPathToggled(int state); void slotDialogButtonClicked(QAbstractButton* button); private: @@ -91,10 +99,13 @@ private slots: QRadioButton* m_gridNotReadBtn; QRadioButton* m_gridSeparateCasesBtn; + QCheckBox* m_showFullPathCheckBox; QDialogButtonBox* m_buttons; bool m_okToAllPressed; QListWidget* m_warnings; + + std::vector>> m_fileLists; }; From 1a0f242c0b5bc39050b9870edb2ecd16593bcf4c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 06:48:22 +0200 Subject: [PATCH 0821/1027] #2780 Ensemble Curve Set : Improve plot title including ensembles --- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 5 ++ .../Summary/RimEnsembleCurveSet.cpp | 47 +++++++++------- .../Summary/RimEnsembleCurveSet.h | 2 + .../Summary/RimSummaryCurveAutoName.cpp | 37 ++++++------- .../Summary/RimSummaryPlot.cpp | 11 ++++ .../Summary/RimSummaryPlotNameHelper.cpp | 55 ++++++++++++++++--- .../Summary/RimSummaryPlotNameHelper.h | 5 +- 7 files changed, 114 insertions(+), 48 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 358622ea1e..1ae97b29de 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -65,6 +65,11 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) { RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); + if (!project->summaryGroups().empty()) + { + curveSet->setSummaryCaseCollection(project->summaryGroups().back()); + } + plot->ensembleCurveSets()->addCurveSet(curveSet); plot->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 15858e7b66..075e1edd83 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -243,6 +243,14 @@ void RimEnsembleCurveSet::deleteCurve(RimSummaryCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddress() const +{ + return m_yValuesCurveVariable->address(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -293,6 +301,14 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged() updateCurveColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setSummaryCaseCollection(RimSummaryCaseCollection* sumCaseCollection) +{ + m_yValuesSummaryGroup = sumCaseCollection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -360,21 +376,6 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - { - caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); - nameGroup->setCollapsedByDefault(true); - nameGroup->add(&m_isUsingAutoName); - if (m_isUsingAutoName) - { - nameGroup->add(&m_autoGeneratedName); - m_summaryAddressNameTools->uiOrdering(uiConfigName, *nameGroup); - } - else - { - nameGroup->add(&m_userDefinedName); - } - } - { QString curveDataGroupName = "Summary Vector"; caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y"); @@ -404,11 +405,19 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder colorsGroup->add(&m_ensembleParameter); } - // Set default initial ensemble - RimProject* project = RiaApplication::instance()->project(); - if (m_yValuesSummaryGroup() == nullptr && project->summaryGroups().size() == 1) { - m_yValuesSummaryGroup = project->summaryGroups().front(); + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); + nameGroup->setCollapsedByDefault(true); + nameGroup->add(&m_isUsingAutoName); + if (m_isUsingAutoName) + { + nameGroup->add(&m_autoGeneratedName); + m_summaryAddressNameTools->uiOrdering(uiConfigName, *nameGroup); + } + else + { + nameGroup->add(&m_userDefinedName); + } } uiOrdering.skipRemainingFields(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 68da28d220..7ff6ef433d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -71,6 +71,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void addCurve(RimSummaryCurve* curve); void deleteCurve(RimSummaryCurve* curve); + RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; std::vector visibleCurves() const; @@ -79,6 +80,7 @@ class RimEnsembleCurveSet : public caf::PdmObject RimRegularLegendConfig* legendConfig(); void onLegendDefinitionChanged(); + void setSummaryCaseCollection(RimSummaryCaseCollection* sumCaseCollection); RimSummaryCaseCollection* summaryCaseCollection() const; private: diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 759a1732cd..9e7e6f6ad0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -82,33 +82,30 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ appendAddressDetails(text, summaryAddress, nameHelper); - RimEnsembleCurveSet* ensambleCurveSet = nullptr; - this->firstAncestorOrThisOfType(ensambleCurveSet); + QString caseName; - if (ensambleCurveSet) { - bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); - - if (m_caseName && !skipSubString) + RimEnsembleCurveSet* ensambleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensambleCurveSet); + if (ensambleCurveSet && ensambleCurveSet->summaryCaseCollection()) { - if (ensambleCurveSet && ensambleCurveSet->summaryCaseCollection()) - { - if (!text.empty()) text += ", "; - text += ensambleCurveSet->summaryCaseCollection()->name().toStdString(); - } + caseName = ensambleCurveSet->summaryCaseCollection()->name(); } } - else if (summaryCurve) + + if (caseName.isEmpty() && summaryCurve && summaryCurve->summaryCaseY()) + { + caseName = summaryCurve->summaryCaseY()->caseName(); + } + + if (!caseName.isEmpty()) { bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); if (m_caseName && !skipSubString) { - if (summaryCurve && summaryCurve->summaryCaseY()) - { - if (!text.empty()) text += ", "; - text += summaryCurve->summaryCaseY()->caseName().toStdString(); - } + if (!text.empty()) text += ", "; + text += caseName.toStdString(); } } @@ -142,8 +139,10 @@ QString RimSummaryCurveAutoName::curveNameX(const RifEclipseSummaryAddress& summ appendAddressDetails(text, summaryAddress, nameHelper); - if (summaryCurve) + if (summaryCurve && summaryCurve->summaryCaseX()) { + QString caseName = summaryCurve->summaryCaseX()->caseName(); + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); if (m_caseName && !skipSubString) @@ -151,7 +150,7 @@ QString RimSummaryCurveAutoName::curveNameX(const RifEclipseSummaryAddress& summ if (summaryCurve && summaryCurve->summaryCaseX()) { if (!text.empty()) text += ", "; - text += summaryCurve->summaryCaseX()->caseName().toStdString(); + text += caseName.toStdString(); } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 687734dca5..435b1cd7ac 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1460,6 +1460,7 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) std::vector addresses; std::vector sumCases; + std::vector ensambleCases; if (m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible()) { @@ -1483,9 +1484,19 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) } } + for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) + { + if (curveSet->isCurvesVisible()) + { + addresses.push_back(curveSet->summaryAddress()); + ensambleCases.push_back(curveSet->summaryCaseCollection()); + } + } + nameHelper->clear(); nameHelper->appendAddresses(addresses); nameHelper->appendSummaryCases(sumCases); + nameHelper->appendEnsembleCases(ensambleCases); return nameHelper->plotTitle(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 4d480e8f7d..425cd43c62 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -21,6 +21,8 @@ #include "RifEclipseSummaryAddress.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" + #include "RiuSummaryVectorDescriptionMap.h" //-------------------------------------------------------------------------------------------------- @@ -29,7 +31,7 @@ RimSummaryPlotNameHelper::RimSummaryPlotNameHelper() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::clear() { @@ -51,7 +53,7 @@ void RimSummaryPlotNameHelper::appendAddresses(const std::vector& summaryCases) { @@ -65,6 +67,21 @@ void RimSummaryPlotNameHelper::appendSummaryCases(const std::vector& ensembleCases) +{ + m_ensembleCases.clear(); + + for (auto c : ensembleCases) + { + m_ensembleCases.insert(c); + } + + extractPlotTitleSubStrings(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -143,7 +160,7 @@ bool RimSummaryPlotNameHelper::isRegionInTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryPlotNameHelper::isCaseInTitle() const { @@ -151,7 +168,7 @@ bool RimSummaryPlotNameHelper::isCaseInTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::clearTitleSubStrings() { @@ -195,11 +212,31 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() m_titleRegion = std::to_string(*(regions.begin())); } - // Case mane - if (m_summaryCases.size() == 1) { - auto summaryCase = *(m_summaryCases.begin()); - - m_titleCaseName = summaryCase->caseName(); + QString summaryCaseTitle; + if (m_summaryCases.size() == 1) + { + auto summaryCase = *(m_summaryCases.begin()); + + summaryCaseTitle = summaryCase->caseName(); + } + + QString ensembleCaseTitle; + if (m_titleCaseName.isEmpty() && m_ensembleCases.size() == 1) + { + auto ensembleCase = *(m_ensembleCases.begin()); + + ensembleCaseTitle = ensembleCase->name(); + } + + // If one case title is the single available, use the single title + if (summaryCaseTitle.isEmpty() && !ensembleCaseTitle.isEmpty()) + { + m_titleCaseName = ensembleCaseTitle; + } + else if (!summaryCaseTitle.isEmpty() && ensembleCaseTitle.isEmpty()) + { + m_titleCaseName = summaryCaseTitle; + } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h index dfbde9919f..7698dada30 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -29,6 +29,7 @@ class RimSummaryCurve; class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== // @@ -42,6 +43,7 @@ class RimSummaryPlotNameHelper void appendAddresses(const std::vector& addresses); void appendSummaryCases(const std::vector& summaryCases); + void appendEnsembleCases(const std::vector& ensembleCases); QString plotTitle() const; @@ -58,7 +60,8 @@ class RimSummaryPlotNameHelper private: RiaSummaryCurveAnalyzer m_analyzer; - std::set m_summaryCases; + std::set m_summaryCases; + std::set m_ensembleCases; std::string m_titleQuantity; std::string m_titleWellName; From 0da7686cdbf933080e5e324eb6fa916e4a3ac2c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 08:01:12 +0200 Subject: [PATCH 0822/1027] #2760 Ensemble Curves: Show one curve legend --- .../ProjectDataModel/RimPlotCurve.cpp | 13 +++++++++++ .../Summary/RimEnsembleCurveSet.cpp | 11 +++++++++ .../Summary/RimEnsembleCurveSet.h | 1 + .../Summary/RimEnsembleCurveSetCollection.cpp | 23 ++++++++++--------- .../Summary/RimSummaryCurveCollection.cpp | 1 + .../Summary/RimSummaryPlot.cpp | 10 ++++++++ .../Summary/RimSummaryPlotNameHelper.cpp | 21 ++++------------- 7 files changed, 52 insertions(+), 28 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index cef2b397a4..f2bdb24a11 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -19,6 +19,7 @@ #include "RimPlotCurve.h" #include "RimEnsembleCurveSet.h" +#include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" @@ -590,5 +591,17 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() showLegendInQwt = false; } + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) + { + auto firstCurve = ensembleCurveSet->firstCurve(); + if (firstCurve != this) + { + // Hide legend display for curves other than the first + showLegendInQwt = false; + } + } + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 075e1edd83..4da5c0f306 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -184,6 +184,7 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) firstAncestorOrThisOfTypeAsserted(parentPlot); if (parentPlot->qwtPlot()) { + parentPlot->updatePlotTitle(); parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); @@ -277,6 +278,16 @@ std::vector RimEnsembleCurveSet::visibleCurves() const return visible; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimEnsembleCurveSet::firstCurve() const +{ + if (!curves().empty()) return curves().front(); + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 7ff6ef433d..802de95035 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -74,6 +74,7 @@ class RimEnsembleCurveSet : public caf::PdmObject RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; std::vector visibleCurves() const; + RimSummaryCurve* firstCurve() const; void deleteAllCurves(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index aad83c655b..8b41f6593f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -111,17 +111,18 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) // curve->updateQwtPlotAxis(); //} - //if ( updateParentPlot ) - //{ - // RimSummaryPlot* parentPlot; - // firstAncestorOrThisOfTypeAsserted(parentPlot); - // if ( parentPlot->qwtPlot() ) - // { - // parentPlot->qwtPlot()->updateLegend(); - // parentPlot->updateAxes(); - // parentPlot->updateZoomInQwt(); - // } - //} + if ( updateParentPlot ) + { + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if ( parentPlot->qwtPlot() ) + { + parentPlot->updatePlotTitle(); + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 38a005e209..4a8dd74cd6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -107,6 +107,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate(bool updateParentPlot) firstAncestorOrThisOfTypeAsserted(parentPlot); if ( parentPlot->qwtPlot() ) { + parentPlot->updatePlotTitle(); parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 435b1cd7ac..b21d15a69e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1516,6 +1516,16 @@ void RimSummaryPlot::updateCurveNames() } } } + + for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) + { + if (curveSet->isCurvesVisible() && curveSet->firstCurve()) + { + // Only the first curve in the set is used in the legend, + // skip update of other curves + curveSet->firstCurve()->updateCurveNameNoLegendUpdate(); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 425cd43c62..e553e3bf8a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -213,30 +213,17 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() } { - QString summaryCaseTitle; - if (m_summaryCases.size() == 1) + if (m_summaryCases.size() == 1 && m_ensembleCases.empty()) { auto summaryCase = *(m_summaryCases.begin()); - summaryCaseTitle = summaryCase->caseName(); + m_titleCaseName = summaryCase->caseName(); } - - QString ensembleCaseTitle; - if (m_titleCaseName.isEmpty() && m_ensembleCases.size() == 1) + else if (m_ensembleCases.size() == 1 && m_summaryCases.empty()) { auto ensembleCase = *(m_ensembleCases.begin()); - ensembleCaseTitle = ensembleCase->name(); - } - - // If one case title is the single available, use the single title - if (summaryCaseTitle.isEmpty() && !ensembleCaseTitle.isEmpty()) - { - m_titleCaseName = ensembleCaseTitle; - } - else if (!summaryCaseTitle.isEmpty() && ensembleCaseTitle.isEmpty()) - { - m_titleCaseName = summaryCaseTitle; + m_titleCaseName = ensembleCase->name(); } } } From 6715ef5a8a5e18ef6ec761b7b3ccf9faa5715233 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 08:15:55 +0200 Subject: [PATCH 0823/1027] #2821 Export Completions: Use Split on Well And Completions as default --- .../RicExportCompletionDataSettingsUi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 5d680609e4..f0f59d47b8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -26,7 +26,7 @@ namespace caf addItem(RicExportCompletionDataSettingsUi::UNIFIED_FILE, "UNIFIED_FILE", "Unified File"); addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL, "SPLIT_ON_WELL", "Split on Well"); addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE, "SPLIT_ON_WELL_AND_COMPLETION_TYPE", "Split on Well and Completion Type"); - setDefault(RicExportCompletionDataSettingsUi::UNIFIED_FILE); + setDefault(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE); } template<> From 39cfc687bda11cfe439043f0bb47e31b5e943030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 10:43:52 +0200 Subject: [PATCH 0824/1027] #2813 Origin import dialog. Copy file name context menu --- .../Commands/RicSummaryCaseRestartDialog.cpp | 56 +++++++++++++++++++ .../Commands/RicSummaryCaseRestartDialog.h | 6 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 64514cd9c4..95da7f359a 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -509,6 +510,10 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa gridLayout->addWidget(fileNameLabel, rowCount, 0); gridLayout->addWidget(dateLabel, rowCount, 1); + // File name copy context menu + fileNameLabel->setContextMenuPolicy(Qt::CustomContextMenu); + connect(fileNameLabel, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotFileNameCopyCustomMenuRequested(const QPoint&))); + // Full path in tooltip fileNameLabel->setToolTip(fullPathFileName); } @@ -535,6 +540,22 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryCaseRestartDialog::fullFileName(const QString& shortOrFullFileName) +{ + for (const auto& fileInfos : m_fileLists) + { + for (const auto& fileInfo : fileInfos) + { + if (fileInfo.first.fileName == shortOrFullFileName || fileInfo.second == shortOrFullFileName) + return fileInfo.second; + } + } + return ""; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -559,3 +580,38 @@ void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* butto if (cancelButtonClicked) reject(); else accept(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotFileNameCopyCustomMenuRequested(const QPoint& point) +{ + QMenu menu; + QPoint globalPoint = point; + QAction* action; + + QLabel* sourceLabel = dynamic_cast(sender()); + + action = new QAction("Copy file name", this); + action->setData(fullFileName(sourceLabel->text())); + connect(action, SIGNAL(triggered()), SLOT(slotCopyFileNameToClipboard())); + menu.addAction(action); + + globalPoint = sourceLabel->mapToGlobal(point); + menu.exec(globalPoint); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotCopyFileNameToClipboard() +{ + QAction* a = dynamic_cast(sender()); + + QClipboard* cb = RiaApplication::clipboard(); + if (cb) + { + QString fullFileName = a->data().toString(); + cb->setText(QDir::toNativeSeparators(fullFileName)); + } +} diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 8ae598088c..b05fa1362a 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -25,6 +25,7 @@ #include "cafPdmPointer.h" #include +#include class QLabel; class QRadioButton; @@ -78,10 +79,13 @@ class RicSummaryCaseRestartDialog : public QDialog void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); void displayWarningsIfAny(const QStringList& warnings); + QString fullFileName(const QString& shortOrFullFileName); private slots: void slotShowFullPathToggled(int state); void slotDialogButtonClicked(QAbstractButton* button); + void slotFileNameCopyCustomMenuRequested(const QPoint& point); + void slotCopyFileNameToClipboard(); private: QGroupBox* m_currentFilesGroup; @@ -149,4 +153,4 @@ class RicSummaryCaseRestartDialogResult QStringList summaryFiles; QStringList gridFiles; bool applyToAll; -}; \ No newline at end of file +}; From b34deb103817f044433a1f30c8abda8970a47434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 11:26:31 +0200 Subject: [PATCH 0825/1027] #2813 Origin import dialog. Add text '+ xxx more files' if number of origin files exceedes 4 --- .../Commands/RicSummaryCaseRestartDialog.cpp | 26 ++++++++++++++++++- .../Commands/RicSummaryCaseRestartDialog.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 95da7f359a..51f163eeb5 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -476,15 +476,23 @@ void RicSummaryCaseRestartDialog::updateFileListWidget(QGridLayout* gridLayout, delete item; } - if (m_fileLists[listIndex].empty()) + if (m_fileLists[listIndex].empty()) { QWidget* parent = gridLayout->parentWidget(); if (parent) parent->setVisible(false); } + int maxFilesToDisplay = 4; + int currFiles = 0; for (const auto& fileInfo : m_fileLists[listIndex]) { appendFileInfoToGridLayout(gridLayout, fileInfo.first, fileInfo.second); + if (++currFiles == maxFilesToDisplay) + { + size_t remainingFileCount = m_fileLists[listIndex].size() - maxFilesToDisplay; + appendTextToGridLayout(gridLayout, QString("+ %1 more files").arg(remainingFileCount)); + break; + } } } @@ -518,6 +526,22 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa fileNameLabel->setToolTip(fullPathFileName); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::appendTextToGridLayout(QGridLayout* gridLayout, const QString& text) +{ + CVF_ASSERT(gridLayout); + + int rowCount = gridLayout->rowCount(); + + QLabel* textLabel = new QLabel(); + textLabel->setText(text); + + textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + gridLayout->addWidget(textLabel, rowCount, 0, 1, 2); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index b05fa1362a..56ead54171 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -77,6 +77,7 @@ class RicSummaryCaseRestartDialog : public QDialog private: void updateFileListWidget(QGridLayout* gridLayout, int listIndex); void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName); + void appendTextToGridLayout(QGridLayout* gridLayout, const QString& text); RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); void displayWarningsIfAny(const QStringList& warnings); QString fullFileName(const QString& shortOrFullFileName); From 5ae536cfc700f8092519303241bacc3ab73c3264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 12:53:32 +0200 Subject: [PATCH 0826/1027] #2833 Origin import dialog. Prevent error dialog after pressing cancel --- ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 9c2367912b..4e4d717d50 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -139,7 +139,7 @@ bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList QMessageBox::warning(NULL, QString("Problem Importing Summary Case File(s)"), errorMessage); } - return !importFileInfos.empty(); + return true; } //-------------------------------------------------------------------------------------------------- From d5037bd98235ec13ff0fc5326140fb79a4fc7394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 14:03:46 +0200 Subject: [PATCH 0827/1027] #2812 Origin import dialog. Set arrow cursor while dialog is open --- ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 51f163eeb5..daa2f124f4 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -387,7 +387,10 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.setWindowTitle("Restart Files"); dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + + QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); dialog.exec(); + QApplication::restoreOverrideCursor(); RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK; From 9ba93c6385e094ec672f125245ba3638a1b16e00 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 14:03:41 +0200 Subject: [PATCH 0828/1027] #2820 Legends: Select tensors when clicking on tensor legend --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 5d49cacebc..223d43c9cf 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -525,6 +525,7 @@ std::vector RimGeoMechView::legendConfigs() const std::vector absLegendConfigs; absLegendConfigs.push_back(cellResult()->legendConfig()); + absLegendConfigs.push_back(tensorResults()->arrowColorLegendConfig()); return absLegendConfigs; From c989d4eb0dc02de4a466f9354f88021ba7a8d002 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 14:04:46 +0200 Subject: [PATCH 0829/1027] Fix crash when picking on legends in 2D intersection view --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 9e67fbae24..c876463382 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -345,13 +345,8 @@ std::vector Rim2dIntersectionView::legendConfigs() const { std::vector legendsIn3dView; - Rim3dView* associated3dView = nullptr; - this->firstAncestorOrThisOfType(associated3dView); - - if (associated3dView) - { - legendsIn3dView = associated3dView->legendConfigs(); - } + legendsIn3dView.push_back(m_legendConfig); + legendsIn3dView.push_back(m_ternaryLegendConfig); return legendsIn3dView; } From ccac7643b86cc45dac3717c63485fbf61aa44cc9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 14:47:44 +0200 Subject: [PATCH 0830/1027] #2820 Legends : Support selection of legend items when clicking in 2D intersection view --- .../Rim2dIntersectionView.cpp | 44 ++++++++++++++----- .../ProjectDataModel/Rim2dIntersectionView.h | 4 ++ .../UserInterface/RiuViewerCommands.cpp | 19 +++++--- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index c876463382..8629f6f81b 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -17,24 +17,26 @@ ///////////////////////////////////////////////////////////////////////////////// #include "Rim2dIntersectionView.h" -#include "RimCase.h" -#include "RimIntersection.h" -#include "RimGridView.h" + #include "Rim3dOverlayInfoConfig.h" -#include "RimEclipseView.h" +#include "RimCase.h" #include "RimEclipseCellColors.h" -#include "RimGeoMechView.h" +#include "RimEclipseView.h" #include "RimGeoMechCellColors.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" +#include "RimIntersection.h" #include "RimRegularLegendConfig.h" -#include "RimTernaryLegendConfig.h" #include "RimSimWellInView.h" +#include "RimTernaryLegendConfig.h" #include "RimWellPath.h" +#include "RiuMainWindow.h" #include "RiuViewer.h" #include "RivIntersectionPartMgr.h" -#include "RivTernarySaturationOverlayItem.h" #include "RivSimWellPipesPartMgr.h" +#include "RivTernarySaturationOverlayItem.h" #include "RivWellHeadPartMgr.h" #include "RivWellPathPartMgr.h" @@ -345,12 +347,26 @@ std::vector Rim2dIntersectionView::legendConfigs() const { std::vector legendsIn3dView; - legendsIn3dView.push_back(m_legendConfig); - legendsIn3dView.push_back(m_ternaryLegendConfig); - + // Return empty list, as the intersection view has a copy of the legend items. Picking and selection of the corresponding + // item is handeled by handleOverlayItemPicked() return legendsIn3dView; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::handleOverlayItemPicked(const cvf::OverlayItem* pickedOverlayItem) const +{ + if (m_legendObjectToSelect) + { + RiuMainWindow::instance()->selectAsCurrentItem(m_legendObjectToSelect); + + return true; + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -574,6 +590,8 @@ void Rim2dIntersectionView::updateCurrentTimeStep() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionView::updateLegends() { + m_legendObjectToSelect = nullptr; + if (!m_viewer) return; m_viewer->removeAllColorLegends(); @@ -598,11 +616,15 @@ void Rim2dIntersectionView::updateLegends() { m_ternaryLegendConfig()->setTitle("Cell Result:\n"); legend = m_ternaryLegendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = eclView->cellResult()->ternaryLegendConfig(); } else { m_legendConfig()->setTitle("Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName()); legend = m_legendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = eclView->cellResult()->legendConfig(); } } @@ -612,6 +634,8 @@ void Rim2dIntersectionView::updateLegends() geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); legend = m_legendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = geoView->cellResult()->legendConfig(); } if ( legend ) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 958670e8a3..5a0e29da22 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -32,6 +32,7 @@ class RivIntersectionPartMgr; namespace cvf { class ModelBasicList; + class OverlayItem; } //================================================================================================== @@ -69,6 +70,7 @@ class Rim2dIntersectionView : public Rim3dView bool showDefiningPoints() const; std::vector legendConfigs() const override; + bool handleOverlayItemPicked(const cvf::OverlayItem* pickedOverlayItem) const; protected: void updateLegends() override; @@ -108,4 +110,6 @@ class Rim2dIntersectionView : public Rim3dView cvf::ref m_scaleTransform; caf::PdmField m_showDefiningPoints; + + caf::PdmPointer m_legendObjectToSelect; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index dd1cbf91a9..841074d545 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -1062,15 +1062,22 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY) if (pickedOverlayItem) { - std::vector legendConfigs = m_reservoirView->legendConfigs(); - - for (const auto& legendConfig : legendConfigs) + auto intersectionView = dynamic_cast(m_reservoirView.p()); + if (intersectionView && intersectionView->handleOverlayItemPicked(pickedOverlayItem)) + { + return true; + } + else { - if (legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem) + std::vector legendConfigs = m_reservoirView->legendConfigs(); + for (const auto& legendConfig : legendConfigs) { - RiuMainWindow::instance()->selectAsCurrentItem(legendConfig); + if (legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem) + { + RiuMainWindow::instance()->selectAsCurrentItem(legendConfig); - return true; + return true; + } } } } From dc81c889cadc9400a98195822672d35dc4bf175a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 14:57:43 +0200 Subject: [PATCH 0831/1027] #2789 Hierarchy dialog. Prevent double file extension --- .../Commands/RicFileHierarchyDialog.cpp | 97 +++++++++++++++++-- .../Commands/RicFileHierarchyDialog.h | 6 +- 2 files changed, 92 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index 16ccde8836..d55ca74555 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -67,6 +67,9 @@ static QString SEPARATOR = "/"; /// Internal functions //-------------------------------------------------------------------------------------------------- static QStringList prefixStrings(const QStringList& strings, const QString& prefix); +static QStringList trimLeftStrings(const QStringList& strings, const QString& trimText); +static void sortStringsByLength(QStringList& strings, bool ascending = true); + //-------------------------------------------------------------------------------------------------- /// @@ -82,7 +85,7 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) m_pathFilter = new QLineEdit(); m_fileFilterLabel = new QLabel(); m_fileFilter = new QLineEdit(); - m_fileExtension = new QLabel(); + m_fileExtensionLabel = new QLabel(); m_effectiveFilterLabel = new QLabel(); m_effectiveFilter = new QLabel(); m_fileListLabel = new QLabel(); @@ -130,7 +133,7 @@ RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) inputGridLayout->addWidget(m_pathFilter, 1, 1); inputGridLayout->addWidget(m_fileFilterLabel, 2, 0); inputGridLayout->addWidget(m_fileFilter, 2, 1); - inputGridLayout->addWidget(m_fileExtension, 2, 2); + inputGridLayout->addWidget(m_fileExtensionLabel, 2, 2); inputGroup->setLayout(inputGridLayout); QGroupBox* outputGroup = new QGroupBox("Files"); @@ -174,7 +177,7 @@ RicFileHierarchyDialogResult RicFileHierarchyDialog::runRecursiveSearchDialog(QW dialog.m_rootDir->setText(QDir::toNativeSeparators(dir)); dialog.m_pathFilter->setText(pathFilter); dialog.m_fileFilter->setText(fileNameFilter); - dialog.m_fileExtension->setText(prefixStrings(fileExtensions, ".").join(" | ")); + dialog.m_fileExtensions = trimLeftStrings(fileExtensions, "."); dialog.updateEffectiveFilter(); dialog.clearFileList(); @@ -224,14 +227,42 @@ QString RicFileHierarchyDialog::fileNameFilter() const //-------------------------------------------------------------------------------------------------- QStringList RicFileHierarchyDialog::fileExtensions() const { - QStringList exts = m_fileExtension->text().split("|"); - for (QString& ext : exts) + QString extFromFilter = extensionFromFileNameFilter(); + if (!extFromFilter.isEmpty()) { - ext = ext.trimmed(); + return QStringList({ extFromFilter }); } + + QStringList exts = m_fileExtensions; + sortStringsByLength(exts); return exts; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::fileExtensionsText() const +{ + QString extFromFilter = extensionFromFileNameFilter(); + if (!extFromFilter.isEmpty()) return ""; + else return prefixStrings(fileExtensions(), ".").join(" | "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::extensionFromFileNameFilter() const +{ + for (const QString& ext : m_fileExtensions) + { + if (m_fileFilter->text().endsWith(ext, Qt::CaseInsensitive)) + { + return ext; + } + } + return ""; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -539,7 +570,7 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName QStringList nameFilter; QString effectiveFileNameFilter = !fileNameFilter.isEmpty() ? fileNameFilter : "*"; - if (fileExtensions.size() == 0) + if (fileExtensions.size() == 0 || !extensionFromFileNameFilter().isEmpty()) { nameFilter.append(effectiveFileNameFilter); } @@ -547,7 +578,7 @@ QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileName { for (QString fileExtension : fileExtensions) { - nameFilter.append(effectiveFileNameFilter + fileExtension); + nameFilter.append(effectiveFileNameFilter + "." + fileExtension); } } return nameFilter; @@ -572,8 +603,8 @@ void RicFileHierarchyDialog::updateEffectiveFilter() QString effFilter = QString("%1/%2/%3%4") .arg(m_rootDir->text()) .arg(m_pathFilter->text()) - .arg(m_fileFilter->text()) - .arg(m_fileExtension->text()); + .arg(fileNameFilter()) + .arg(fileExtensionsText()); QString internalFilter(RiaFilePathTools::toInternalSeparator(effFilter)); @@ -776,3 +807,49 @@ QStringList prefixStrings(const QStringList& strings, const QString& prefix) } return prefixedStrings; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList trimLeftStrings(const QStringList& strings, const QString& trimText) +{ + QStringList trimmedStrings; + for (const auto& string : strings) + { + QString trimmedString = string; + if (string.startsWith(trimText)) + { + trimmedString = string.right(string.size() - trimText.size()); + } + trimmedStrings.append(trimmedString); + } + return trimmedStrings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void sortStringsByLength(QStringList& strings, bool ascending /*= true*/) +{ + QStringList sorted = strings; + int numItems = sorted.size(); + bool swapped; + do + { + swapped = false; + for (int i = 0; i < numItems - 1; i++) + { + int s0 = strings[i].size(); + int s1 = strings[i + 1].size(); + if (ascending && s0 > s1 || !ascending && s0 < s1) + { + const QString temp = strings[i]; + strings[i] = strings[i + 1]; + strings[i + 1] = temp; + swapped = true; + } + } + } while (swapped); + + +} diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h index f3100cc3a9..0e42e23b4c 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.h +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -59,6 +59,9 @@ class RicFileHierarchyDialog : public QDialog QString pathFilter() const; QString fileNameFilter() const; QStringList fileExtensions() const; + QString fileExtensionsText() const; + QString extensionFromFileNameFilter() const; + bool cancelPressed() const; void appendToFileList(const QString& fileName); void clearFileList(); @@ -105,7 +108,7 @@ private slots: QLabel* m_fileFilterLabel; QLineEdit* m_fileFilter; - QLabel* m_fileExtension; + QLabel* m_fileExtensionLabel; QLabel* m_effectiveFilterLabel; QLabel* m_effectiveFilter; @@ -117,6 +120,7 @@ private slots: QDialogButtonBox* m_buttons; QStringList m_files; + QStringList m_fileExtensions; bool m_cancelPressed; }; From b686c1a08193becc7ef5b6e7f357f40fd4fe12ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 30 Apr 2018 15:33:04 +0200 Subject: [PATCH 0832/1027] Hierarchy dialog. Removed duplicate definition --- ApplicationCode/Application/Tools/RiaFilePathTools.cpp | 5 +++-- ApplicationCode/Application/Tools/RiaFilePathTools.h | 2 ++ ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp index 3328871ac9..2e844daf74 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -21,10 +21,11 @@ #include "RiaFilePathTools.h" #include + //-------------------------------------------------------------------------------------------------- -/// Internal variables +/// //-------------------------------------------------------------------------------------------------- -static QString SEPARATOR = "/"; +const QChar RiaFilePathTools::SEPARATOR = '/'; //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.h b/ApplicationCode/Application/Tools/RiaFilePathTools.h index 9dbb0735fd..255a93e6f6 100644 --- a/ApplicationCode/Application/Tools/RiaFilePathTools.h +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.h @@ -32,6 +32,8 @@ class RiaFilePathTools { public: + static const QChar SEPARATOR; + static QString toInternalSeparator(const QString& path); static QString& appendSeparatorIfNo(QString& path); static QString relativePath(const QString& rootDir, const QString& dir); diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index d55ca74555..bdc9ea4c62 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -61,7 +61,7 @@ //-------------------------------------------------------------------------------------------------- /// Internal variables //-------------------------------------------------------------------------------------------------- -static QString SEPARATOR = "/"; +static const QChar SEPARATOR = RiaFilePathTools::SEPARATOR; //-------------------------------------------------------------------------------------------------- /// Internal functions @@ -613,7 +613,7 @@ void RicFileHierarchyDialog::updateEffectiveFilter() do { len = internalFilter.size(); - internalFilter.replace(SEPARATOR + SEPARATOR, SEPARATOR); + internalFilter.replace(QString("%1%1").arg(SEPARATOR), SEPARATOR); } while (internalFilter.size() != len); // Present native separators to the user From 04f793c19d2b9e9ed008f5e670e957a96c6b67b9 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 27 Apr 2018 15:30:34 +0200 Subject: [PATCH 0833/1027] #2782 Auto name for 3d Well Log Curves --- .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../Rim3dWellLogCurveCollection.cpp | 1 + .../ProjectDataModel/Rim3dWellLogCurve.cpp | 45 ++- .../ProjectDataModel/Rim3dWellLogCurve.h | 13 +- .../Rim3dWellLogExtractionCurve.cpp | 120 +++++++- .../Rim3dWellLogExtractionCurve.h | 8 +- .../Rim3dWellLogFileCurve.cpp | 82 +++++- .../ProjectDataModel/Rim3dWellLogFileCurve.h | 6 +- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 59 +++- .../ProjectDataModel/Rim3dWellLogRftCurve.h | 6 + .../RimWellLogCurveNameConfig.cpp | 274 ++++++++++++++++++ .../RimWellLogCurveNameConfig.h | 115 ++++++++ 12 files changed, 692 insertions(+), 39 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index f1781a8b9e..0851d05385 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -104,6 +104,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.h ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h ${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.h ) @@ -212,6 +213,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp ${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index fbf49270d9..bb5524a750 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -85,6 +85,7 @@ void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) size_t index = m_3dWellLogCurves.size(); curve->setColor(RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index)); m_3dWellLogCurves.push_back(curve); + curve->createCurveAutoName(); } } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index ead33dd23f..9d3d75f0b0 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -69,8 +69,6 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); - CAF_PDM_InitField(&m_name, "Name", QString("3D Well Log Curve"), "3d Well Log Curve", "", "", ""); - m_name.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -90,14 +88,6 @@ void Rim3dWellLogCurve::updateCurveIn3dView() proj->createDisplayModelAndRedrawAllViews(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const QString& Rim3dWellLogCurve::name() const -{ - return m_name(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -171,14 +161,6 @@ void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* Rim3dWellLogCurve::userDescriptionField() -{ - return &m_name; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -249,17 +231,23 @@ void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI() +void Rim3dWellLogCurve::initAfterRead() { - this->resetMinMaxValues(); - this->updateConnectedEditors(); + this->createCurveAutoName(); } -void Rim3dWellLogCurve::setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI() { - m_geometryGenerator = generator; + this->resetMinMaxValues(); + this->updateConnectedEditors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- bool Rim3dWellLogCurve::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, double* measuredDepthAtPoint, @@ -272,6 +260,17 @@ bool Rim3dWellLogCurve::findClosestPointOnCurve(const cvf::Vec3d& globalIntersec return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator) +{ + m_geometryGenerator = generator; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- cvf::ref Rim3dWellLogCurve::geometryGenerator() { return m_geometryGenerator; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 5d1e100338..1b3f68ad47 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -23,17 +23,19 @@ #include "cafPdmObject.h" #include "cafPdmFieldCvfColor.h" - +#include "cafPdmChildField.h" #include "cvfObject.h" #include "cvfVector3.h" +#include "RimWellLogCurveNameConfig.h" + class Riv3dWellLogCurveGeometryGenerator; //================================================================================================== /// /// //================================================================================================== -class Rim3dWellLogCurve : public caf::PdmObject +class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolderInterface { CAF_PDM_HEADER_INIT; @@ -52,7 +54,7 @@ class Rim3dWellLogCurve : public caf::PdmObject void updateCurveIn3dView(); - const QString& name() const; + virtual QString name() const = 0; virtual QString resultPropertyString() const = 0; DrawPlane drawPlane() const; cvf::Color3f color() const; @@ -72,18 +74,17 @@ class Rim3dWellLogCurve : public caf::PdmObject void setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator); cvf::ref geometryGenerator(); - + protected: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual caf::PdmFieldHandle* userDescriptionField() override; void configurationUiOrdering(caf::PdmUiOrdering& uiOrdering); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + virtual void initAfterRead(); private: void resetMinMaxValues(); protected: - caf::PdmField m_name; caf::PdmField> m_drawPlane; caf::PdmField m_color; caf::PdmField m_minCurveValue; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index 30f6b27928..8d02ef6745 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -21,10 +21,17 @@ #include "RigWellLogFile.h" #include "RiaExtractionTools.h" +#include "RigEclipseCaseData.h" +#include "RigGeoMechCaseData.h" #include "RigEclipseWellLogExtractor.h" #include "RigGeoMechWellLogExtractor.h" #include "RigResultAccessorFactory.h" +#include "RigCaseCellResultsData.h" +#include "RigFemPartResultsCollection.h" +#include "RimEclipseCase.h" +#include "RimGeoMechCase.h" #include "Rim3dView.h" +#include "RimWellLogCurveNameConfig.h" #include "RimCase.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -71,7 +78,8 @@ Rim3dWellLogExtractionCurve::Rim3dWellLogExtractionCurve() m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); m_geomResultDefinition = new RimGeoMechResultDefinition; - m_name = "3D Well Log Curve"; + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameGenerator", "", "", "", ""); + m_nameConfig = new RimWellLogExtractionCurveNameConfig(this); } //-------------------------------------------------------------------------------------------------- @@ -81,6 +89,7 @@ Rim3dWellLogExtractionCurve::~Rim3dWellLogExtractionCurve() { delete m_geomResultDefinition; delete m_eclipseResultDefinition; + delete m_nameConfig; } //-------------------------------------------------------------------------------------------------- @@ -174,6 +183,88 @@ void Rim3dWellLogExtractionCurve::curveValuesAndMds(std::vector* values, } } +QString Rim3dWellLogExtractionCurve::name() const +{ + return m_nameConfig()->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogExtractionCurve::createCurveAutoName() const +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QStringList generatedCurveName; + + if (m_nameConfig->addWellName()) + { + RimWellPath* wellPath; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + if (!wellPath->name().isEmpty()) + { + generatedCurveName += wellPath->name(); + } + } + + if (m_nameConfig->addCaseName() && m_case()) + { + generatedCurveName.push_back(m_case->caseUserDescription()); + } + + if (m_nameConfig->addProperty() && !resultPropertyString().isEmpty()) + { + generatedCurveName.push_back(resultPropertyString()); + } + + if (m_nameConfig->addTimeStep() || m_nameConfig->addDate()) + { + size_t maxTimeStep = 0; + + if (eclipseCase) + { + RigEclipseCaseData* data = eclipseCase->eclipseCaseData(); + if (data) + { + maxTimeStep = data->results(m_eclipseResultDefinition->porosityModel())->maxTimeStepCount(); + } + } + else if (geomCase) + { + RigGeoMechCaseData* data = geomCase->geoMechData(); + if (data) + { + maxTimeStep = data->femPartResults()->frameCount(); + } + } + + if (m_nameConfig->addDate()) + { + QString dateString = wellDate(); + if (!dateString.isEmpty()) + { + generatedCurveName.push_back(dateString); + } + } + + if (m_nameConfig->addTimeStep()) + { + generatedCurveName.push_back(QString("[%1/%2]").arg(m_timeStep()).arg(maxTimeStep)); + } + } + + return generatedCurveName.join(", "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogExtractionCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -237,6 +328,8 @@ void Rim3dWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::Pd Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + caf::PdmUiGroup* nameGroup = m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); } @@ -251,3 +344,28 @@ void Rim3dWellLogExtractionCurve::initAfterRead() m_eclipseResultDefinition->setEclipseCase(eclipseCase); m_geomResultDefinition->setGeoMechCase(geomCase); } + +QString Rim3dWellLogExtractionCurve::wellDate() const +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QStringList timeStepNames; + + if (eclipseCase) + { + if (eclipseCase->eclipseCaseData()) + { + timeStepNames = eclipseCase->timeStepStrings(); + } + } + else if (geomCase) + { + if (geomCase->geoMechData()) + { + timeStepNames = geomCase->timeStepStrings(); + } + } + + return (m_timeStep >= 0 && m_timeStep < timeStepNames.size()) ? timeStepNames[m_timeStep] : ""; +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h index 5ab17dbea6..cdbb90a382 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h @@ -28,6 +28,7 @@ class Rim3dView; class RimCase; class RimGeoMechResultDefinition; class RimEclipseResultDefinition; +class RimWellLogExtractionCurveNameConfig; //================================================================================================== /// @@ -45,17 +46,22 @@ class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve virtual QString resultPropertyString() const override; virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + virtual QString name() const override; + virtual QString createCurveAutoName() const override; +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; - + QString wellDate() const; private: caf::PdmPtrField m_case; caf::PdmField m_timeStep; caf::PdmChildField m_eclipseResultDefinition; caf::PdmChildField m_geomResultDefinition; + caf::PdmChildField m_nameConfig; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index 3f7f7d1835..dcd47d0bca 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -20,6 +20,7 @@ #include "RigWellLogFile.h" +#include "RimWellLogCurveNameConfig.h" #include "RimWellLogFile.h" #include "RimWellLogFileChannel.h" #include "RimWellPath.h" @@ -44,13 +45,17 @@ Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "Well Log File", "", "", ""); - m_name = "3D Well Log LAS Curve"; + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); + m_nameConfig = new RimWellLogFileCurveNameConfig(this); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dWellLogFileCurve::~Rim3dWellLogFileCurve() {} +Rim3dWellLogFileCurve::~Rim3dWellLogFileCurve() +{ + delete m_nameConfig; +} //-------------------------------------------------------------------------------------------------- /// @@ -72,7 +77,6 @@ void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() if (!fileLogs.empty()) { m_wellLogChannelName = fileLogs[0]->name(); - m_name = "LAS: " + m_wellLogChannelName; } } } @@ -104,6 +108,76 @@ QString Rim3dWellLogFileCurve::resultPropertyString() const return m_wellLogChannelName(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::name() const +{ + return m_nameConfig->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::createCurveAutoName() const +{ + QStringList name; + QString unit; + bool channelNameAvailable = false; + + RimWellPath* wellPath; + this->firstAncestorOrThisOfType(wellPath); + + if (wellPath) + { + name.push_back(wellPath->name()); + name.push_back("LAS"); + + if (!m_wellLogChannelName().isEmpty()) + { + name.push_back(m_wellLogChannelName); + channelNameAvailable = true; + } + + RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + + if (wellLogFile) + { + if (channelNameAvailable) + { + /* RimWellLogPlot* wellLogPlot; + firstAncestorOrThisOfType(wellLogPlot); + CVF_ASSERT(wellLogPlot); + QString unitName = wellLogFile->wellLogChannelUnitString(m_wellLogChannelName, wellLogPlot->depthUnit()); + + if (!unitName.isEmpty()) + { + name.back() += QString(" [%1]").arg(unitName); + } */ + } + + QString date = wellLogFile->date(); + if (!date.isEmpty()) + { + name.push_back(wellLogFile->date()); + } + + } + + return name.join(", "); + } + + return "Empty curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogFileCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -178,5 +252,7 @@ void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + caf::PdmUiGroup* nameGroup = m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h index 9f537df3cc..58390e7a7f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -25,6 +25,7 @@ #include "cafPdmPtrField.h" class RimWellLogFile; +class RimWellLogFileCurveNameConfig; //================================================================================================== /// @@ -41,8 +42,10 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve void setDefaultFileCurveDataInfo(); virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; virtual QString resultPropertyString() const override; - + virtual QString name() const override; + virtual QString createCurveAutoName() const override; protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -56,4 +59,5 @@ class Rim3dWellLogFileCurve : public Rim3dWellLogCurve private: caf::PdmPtrField m_wellLogFile; caf::PdmField m_wellLogChannelName; + caf::PdmChildField m_nameConfig; }; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index a3eef10699..85ad411929 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -18,12 +18,14 @@ #include "Rim3dWellLogRftCurve.h" -#include "RimWellPath.h" -#include "RimWellLogCurve.h" +#include "RifReaderEclipseRft.h" #include "RigWellLogCurveData.h" + +#include "RimWellLogCurveNameConfig.h" #include "RimEclipseResultCase.h" -#include "RifReaderEclipseRft.h" #include "RimTools.h" +#include "RimWellPath.h" +#include "RimWellLogCurve.h" //================================================================================================== /// @@ -49,7 +51,8 @@ Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() m_2dWellLogRftCurve = new RimWellLogRftCurve(); m_2dWellLogRftCurve.xmlCapability()->disableIO(); - m_name = "3D Well Log RFT Curve"; + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); + m_nameConfig = new RimWellLogRftCurveNameConfig(this); } //-------------------------------------------------------------------------------------------------- @@ -57,6 +60,7 @@ Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() //-------------------------------------------------------------------------------------------------- Rim3dWellLogRftCurve::~Rim3dWellLogRftCurve() { + delete m_nameConfig; } //-------------------------------------------------------------------------------------------------- @@ -84,6 +88,53 @@ QString Rim3dWellLogRftCurve::resultPropertyString() const return caf::AppEnum::uiText(m_wellLogChannelName()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::name() const +{ + return m_nameConfig->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::createCurveAutoName() const +{ + QStringList name; + + if (!wellName().isEmpty()) + { + name.push_back(wellName()); + } + + name.push_back("RFT"); + + if (m_eclipseResultCase) + { + name.push_back(m_eclipseResultCase->caseUserDescription()); + } + if (m_wellLogChannelName().text() != caf::AppEnum::text(RifEclipseRftAddress::NONE)) + { + RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = m_wellLogChannelName(); + name.push_back(caf::AppEnum::uiText(channelNameEnum)); + } + if (!m_timeStep().isNull()) + { + name.push_back(m_timeStep().toString(RimTools::dateFormatString())); + } + + return name.join(", "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogRftCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h index e922d1059a..ee9b157fe0 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -28,6 +28,7 @@ #include "RimWellLogRftCurve.h" class RimEclipseResultCase; +class RimWellLogRftCurveNameConfig; class QString; //================================================================================================== @@ -45,8 +46,12 @@ class Rim3dWellLogRftCurve : public Rim3dWellLogCurve virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; virtual QString resultPropertyString() const override; + virtual QString name() const override; + virtual QString createCurveAutoName() const override; protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -66,4 +71,5 @@ class Rim3dWellLogRftCurve : public Rim3dWellLogCurve caf::PdmField> m_wellLogChannelName; caf::PdmChildField m_2dWellLogRftCurve; + caf::PdmChildField m_nameConfig; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp new file mode 100644 index 0000000000..7bbc4903b8 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp @@ -0,0 +1,274 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// + m_addWellName {m_fieldValue=true m_defaultFieldValue=true } caf::PdmField + +// 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 "RimProject.h" +#include "RimWellLogCurveNameConfig.h" +#include "Rim3dWellLogCurve.h" + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimCurveNameConfig, "RimCurveNameGenerator"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCurveNameConfig::RimCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder /*= nullptr*/) + : m_configHolder(configHolder) +{ + CAF_PDM_InitObject("Curve Name Generator", "", "", ""); + + CAF_PDM_InitField(&m_isUsingAutoName, "IsUsingAutoName", true, "Generate Name Automatically", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_customName, "CustomCurveName", "Curve Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_autoName, "AutoCurveName", "Curve Name", "", "", ""); + m_autoName.registerGetMethod(this, &RimCurveNameConfig::autoName); + m_autoName.registerSetMethod(this, &RimCurveNameConfig::setCustomName); + m_autoName.xmlCapability()->disableIO(); + + CVF_ASSERT(configHolder); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCurveNameConfig::~RimCurveNameConfig() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCurveNameConfig::isUsingAutoName() const +{ + return m_isUsingAutoName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCurveNameConfig::nameField() +{ + if (isUsingAutoName()) + { + return &m_autoName; + } + return &m_customName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCurveNameConfig::name() const +{ + if (isUsingAutoName()) + { + return m_autoName(); + } + return m_customName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiGroup* RimCurveNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name Configuration"); + nameGroup->add(&m_isUsingAutoName); + return nameGroup; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_customName) + { + m_isUsingAutoName = false; + } + + if (changedField == &m_isUsingAutoName && !isUsingAutoName()) + { + m_customName = m_configHolder->createCurveAutoName(); + m_customName.uiCapability()->updateConnectedEditors(); + } + + updateAllSettings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCurveNameConfig::autoName() const +{ + return m_configHolder->createCurveAutoName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::setCustomName(const QString& name) +{ + m_isUsingAutoName = false; + m_customName = name; + updateAllSettings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::updateAllSettings() +{ + m_isUsingAutoName.uiCapability()->updateConnectedEditors(); + m_autoName.uiCapability()->updateConnectedEditors(); + m_customName.uiCapability()->updateConnectedEditors(); + + Rim3dWellLogCurve* curve; + this->firstAncestorOrThisOfTypeAsserted(curve); + curve->updateConnectedEditors(); + +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogExtractionCurveNameConfig, "RimWellLogExtractionCurveNameGenerator"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogExtractionCurveNameConfig::RimWellLogExtractionCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log Extraction Curve Name Generator", "", "", ""); + + CAF_PDM_InitField(&m_addCaseName, "AddCaseName", false, "Add Case Name To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addProperty, "AddProperty", true, "Add Property Type To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addWellName, "AddWellName", true, "Add Well Name To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addTimestep, "AddTimeStep", true, "Add Time Step To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addDate, "AddDate", true, "Add Date To Auto Name", "", "", ""); + + m_customName = "Extraction Curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiGroup* RimWellLogExtractionCurveNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* nameGroup = RimCurveNameConfig::createUiGroup(uiConfigName, uiOrdering); + nameGroup->add(&m_addCaseName); + nameGroup->add(&m_addProperty); + nameGroup->add(&m_addWellName); + nameGroup->add(&m_addTimestep); + nameGroup->add(&m_addDate); + return nameGroup; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addCaseName() const +{ + return m_addCaseName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addProperty() const +{ + return m_addProperty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addWellName() const +{ + return m_addWellName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addTimeStep() const +{ + return m_addTimestep(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addDate() const +{ + return m_addDate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogExtractionCurveNameConfig::updateAllSettings() +{ + m_addCaseName.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addProperty.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addWellName.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addTimestep.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addDate.uiCapability()->setUiReadOnly(!isUsingAutoName()); + + RimCurveNameConfig::updateAllSettings(); +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogFileCurveNameConfig, "RimWellLogFileCurveNameGenerator"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileCurveNameConfig::RimWellLogFileCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log File Curve Name Generator", "", "", ""); + m_customName = "Las Curve"; +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogRftCurveNameConfig, "RimWellLogRftCurveNameGenerator"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogRftCurveNameConfig::RimWellLogRftCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log Rft Curve Name Generator", "", "", ""); + m_customName = "Rft Curve"; +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h new file mode 100644 index 0000000000..0ad17339e4 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCurveNameConfigHolderInterface +{ +public: + virtual QString createCurveAutoName() const = 0; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCurveNameConfig : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); + virtual ~RimCurveNameConfig(); + bool isUsingAutoName() const; + caf::PdmFieldHandle* nameField(); + QString name() const; + virtual caf::PdmUiGroup* createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + QString autoName() const; + void setCustomName(const QString& name); + virtual void updateAllSettings(); +protected: + caf::PdmField m_isUsingAutoName; + caf::PdmField m_customName; + caf::PdmProxyValueField m_autoName; + + const RimCurveNameConfigHolderInterface* m_configHolder; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogExtractionCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogExtractionCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); + virtual caf::PdmUiGroup* createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + bool addCaseName() const; + bool addProperty() const; + bool addWellName() const; + bool addTimeStep() const; + bool addDate() const; + +protected: + virtual void updateAllSettings(); + +private: + caf::PdmField m_addCaseName; + caf::PdmField m_addProperty; + caf::PdmField m_addWellName; + caf::PdmField m_addTimestep; + caf::PdmField m_addDate; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogFileCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogFileCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogRftCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogRftCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); +}; From 7307b97466bbc51b0de1f3a8353cefcb7b91f5a3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 30 Apr 2018 08:11:06 +0200 Subject: [PATCH 0834/1027] #2823 Switching curve plane does not work * The previous drawable and geometry was kept if switching to a result type without valid points. * The drawable is then stuck in position until switching back to a result type that has valid points. * This commit fixes this by clearing the geometry every time you draw. * TODO: cache values when it is possible to do so. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 15 +++++++++++++++ .../Riv3dWellLogCurveGeomertyGenerator.h | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 9088d2f5db..4d0dcc4b49 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -57,6 +57,10 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display { m_planeWidth = planeWidth; + // Make sure all drawables are cleared in case we return early to avoid a + // previous drawable being "stuck" when changing result type. + clearCurvePointsAndGeometry(); + if (!wellPathGeometry()) return; if (wellPathGeometry()->m_wellPathPoints.empty()) return; if (!wellPathClipBoundingBox.isValid()) return; @@ -172,6 +176,17 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveDrawable->setVertexArray(vertexArray.p()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::clearCurvePointsAndGeometry() +{ + m_curveDrawable = nullptr; + m_curveVertices.clear(); + m_curveMeasuredDepths.clear(); + m_curveValues.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 0f09fca27a..5905300657 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -55,6 +55,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double planeWidth, double minResultValue, double maxResultValue); + + void clearCurvePointsAndGeometry(); const RigWellPath* wellPathGeometry() const; @@ -67,9 +69,10 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object private: caf::PdmPointer m_wellPath; + double m_planeWidth; + cvf::ref m_curveDrawable; std::vector m_curveVertices; std::vector m_curveMeasuredDepths; std::vector m_curveValues; - double m_planeWidth; }; From 1f44ea1ea3b9c075d3cab7d018fb57bc5f3f9c25 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 30 Apr 2018 09:22:59 +0200 Subject: [PATCH 0835/1027] Make draw plane selection for curves be unrelated to 3d Track (somewhat related to #2825). * Makes more sense user wise and makes for better code. * Helps refactor code to relate grids to curves so the curves can have access to the grid it is being drawn on. * This will help fix #2825 by being able to project curve points onto the exact triangle geometry. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 16 +-- .../Riv3dWellLogCurveGeomertyGenerator.h | 9 +- .../Riv3dWellLogGridGeomertyGenerator.cpp | 73 +++++++--- .../Riv3dWellLogGridGeomertyGenerator.h | 13 +- .../Riv3dWellLogPlanePartMgr.cpp | 130 +++++------------- .../Riv3dWellLogPlanePartMgr.h | 10 +- .../Rim3dWellLogCurveCollection.cpp | 31 ----- .../Completions/Rim3dWellLogCurveCollection.h | 11 -- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 53 ++++--- .../ProjectDataModel/Rim3dWellLogCurve.h | 10 +- .../Rim3dWellLogExtractionCurve.cpp | 4 +- .../Rim3dWellLogFileCurve.cpp | 2 +- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 2 + .../RimWellLogCurveNameConfig.cpp | 9 +- 14 files changed, 155 insertions(+), 218 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 4d0dcc4b49..d7c5ef1a1b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -47,14 +47,14 @@ Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPa //-------------------------------------------------------------------------------------------------- void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const std::vector& resultValues, - const std::vector& resultMds, - double minResultValue, - double maxResultValue, - double planeAngle, + const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, double planeWidth) { + std::vector resultValues; + std::vector resultMds; + rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); + m_planeWidth = planeWidth; // Make sure all drawables are cleared in case we return early to avoid a @@ -68,7 +68,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == resultMds.size()); - if (maxResultValue - minResultValue < 1.0e-6) + if (rim3dWellLogCurve->maxCurveValue() - rim3dWellLogCurve->minCurveValue() < 1.0e-6) { return; } @@ -90,7 +90,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); } - std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); + std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, rim3dWellLogCurve->drawPlaneAngle()); std::vector interpolatedWellPathPoints; std::vector interpolatedCurveNormals; @@ -123,7 +123,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display { if (!RigCurveDataTools::isValidValue(result, false)) continue; - result = cvf::Math::clamp(result, minResultValue, maxResultValue); + result = cvf::Math::clamp(result, rim3dWellLogCurve->minCurveValue(), rim3dWellLogCurve->maxCurveValue()); maxClampedResult = std::max(result, maxClampedResult); minClampedResult = std::min(result, minClampedResult); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 5905300657..23dd4e27a9 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -39,6 +39,7 @@ class BoundingBox; class RigWellPath; class RimWellPath; +class Rim3dWellLogCurve; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { @@ -48,13 +49,9 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object void createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - const std::vector& resultValues, - const std::vector& resultMds, - double planeAngle, + const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, - double planeWidth, - double minResultValue, - double maxResultValue); + double planeWidth); void clearCurvePointsAndGeometry(); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp index dba5542126..4d44520580 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp @@ -56,6 +56,8 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* { CVF_ASSERT(gridIntervalSize > 0); + clearGeometry(); + if (!wellPathGeometry() || wellPathGeometry()->m_measuredDepths.empty()) { return false; @@ -81,7 +83,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); } - std::vector wellPathSegmentNormals = + std::vector segmentNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); @@ -106,11 +108,10 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* // Note that normals are calculated on the full non-clipped well path to increase the likelihood of creating good normals // for the end points of the curve. So we need to clip the remainder here. - wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); + segmentNormals.erase(segmentNormals.begin(), segmentNormals.end() - wellPathPoints.size()); { - std::vector vertices; - vertices.reserve(wellPathPoints.size() * 2); + m_vertices.reserve(wellPathPoints.size() * 2); std::vector backgroundIndices; backgroundIndices.reserve(wellPathPoints.size() * 2); @@ -118,15 +119,15 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* // Vertices are used for both surface and border for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter)); - vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); + m_vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + segmentNormals[i] * planeOffsetFromWellPathCenter)); + m_vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + segmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); backgroundIndices.push_back((cvf::uint) (2 * i)); backgroundIndices.push_back((cvf::uint) (2 * i + 1)); } - cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices); { // Background specific @@ -141,9 +142,9 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* { std::vector borderIndices; - borderIndices.reserve(vertices.size()); + borderIndices.reserve(m_vertices.size()); - int secondLastEvenVertex = (int) vertices.size() - 4; + int secondLastEvenVertex = (int) m_vertices.size() - 4; // Border close to the well. All even indices. for (int i = 0; i <= secondLastEvenVertex; i += 2) @@ -153,11 +154,11 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* } // Connect to border away from well - borderIndices.push_back((cvf::uint) (vertices.size() - 2)); - borderIndices.push_back((cvf::uint) (vertices.size() - 1)); + borderIndices.push_back((cvf::uint) (m_vertices.size() - 2)); + borderIndices.push_back((cvf::uint) (m_vertices.size() - 1)); int secondOddVertex = 3; - int lastOddVertex = (int) vertices.size() - 1; + int lastOddVertex = (int) m_vertices.size() - 1; // Border away from from well are odd indices in reverse order to create a closed surface. for (int i = lastOddVertex; i >= secondOddVertex; i -= 2) @@ -190,15 +191,15 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* while (md >= firstMd) { cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); - cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathSegmentNormals, md); + cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(segmentNormals, md); interpolatedGridPoints.push_back(point); interpolatedGridCurveNormals.push_back(curveNormal.getNormalized()); md -= gridIntervalSize; } - std::vector vertices; + std::vector arrowVertices; std::vector arrowVectors; - vertices.reserve(interpolatedGridPoints.size()); + arrowVertices.reserve(interpolatedGridPoints.size()); arrowVectors.reserve(interpolatedGridPoints.size()); double shaftRelativeRadius = 0.0125f; @@ -208,14 +209,14 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* // Normal lines. Start from one to avoid drawing at surface edge. for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter)); + arrowVertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter)); arrowVectors.push_back(cvf::Vec3f(interpolatedGridCurveNormals[i] * planeWidth * totalArrowScaling)); } m_curveNormalVectors = new cvf::DrawableVectors(); - cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + cvf::ref vertexArray = new cvf::Vec3fArray(arrowVertices); cvf::ref vectorArray = new cvf::Vec3fArray(arrowVectors); // Create the arrow glyph for the vector drawer @@ -233,21 +234,49 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* return true; } -cvf::ref Riv3dWellLogGridGeometryGenerator::background() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogGridGeometryGenerator::clearGeometry() +{ + m_background = nullptr; + m_border = nullptr; + m_curveNormalVectors = nullptr; + m_vertices.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogGridGeometryGenerator::background() const { return m_background; } -cvf::ref Riv3dWellLogGridGeometryGenerator::border() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogGridGeometryGenerator::border() const { return m_border; } -cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalVectors() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalVectors() const { return m_curveNormalVectors; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& Riv3dWellLogGridGeometryGenerator::vertices() const +{ + return m_vertices; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h index 36e69aef76..b506115127 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h @@ -51,10 +51,15 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object double planeOffsetFromWellPathCenter, double planeWidth, double gridIntervalSize); + + void clearGeometry(); + + cvf::ref background() const; + cvf::ref border() const; + cvf::ref curveNormalVectors() const; + + const std::vector& vertices() const; - cvf::ref background(); - cvf::ref border(); - cvf::ref curveNormalVectors(); private: const RigWellPath* wellPathGeometry() const; @@ -63,4 +68,6 @@ class Riv3dWellLogGridGeometryGenerator : public cvf::Object cvf::ref m_background; cvf::ref m_border; cvf::ref m_curveNormalVectors; + + std::vector m_vertices; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 415f8104f0..b169a5c9bd 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -70,71 +70,55 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; - append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox); - for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); + append3dWellLogCurveToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox) +void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + Rim3dWellLogCurve* rim3dWellLogCurve) { - if (m_wellPath.isNull()) return; - if (!m_wellPath->rim3dWellLogCurveCollection()) return; - if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; + CVF_ASSERT(rim3dWellLogCurve); + if (!rim3dWellLogCurve->isShowingCurve()) return; + + cvf::ref generator = rim3dWellLogCurve->geometryGenerator(); + if (generator.isNull()) + { + generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); + rim3dWellLogCurve->setGeometryGenerator(generator.p()); + } - Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + generator->createCurveDrawables(displayCoordTransform, + wellPathClipBoundingBox, + rim3dWellLogCurve, + wellPathCenterToPlotStartOffset(rim3dWellLogCurve), + planeWidth()); - for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) + cvf::ref curveDrawable = generator->curveDrawable(); + + if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) { - cvf::ref generator = rim3dWellLogCurve->geometryGenerator(); - if (generator.isNull()) - { - generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); - rim3dWellLogCurve->setGeometryGenerator(generator.p()); - } - - if (!rim3dWellLogCurve->isShowingCurve()) continue; - - std::vector resultValues; - std::vector resultMds; - rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); - - generator->createCurveDrawables(displayCoordTransform, - wellPathClipBoundingBox, - resultValues, - resultMds, - rim3dWellLogCurve->minCurveValue(), - rim3dWellLogCurve->maxCurveValue(), - planeAngle(curveCollection, rim3dWellLogCurve), - wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), - planeWidth()); - - cvf::ref curveDrawable = generator->curveDrawable(); - - if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) - { - continue; - } + return; + } - caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); - meshEffectGen.setLineWidth(2.0f); - cvf::ref effect = meshEffectGen.generateCachedEffect(); + caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); + meshEffectGen.setLineWidth(2.0f); + cvf::ref effect = meshEffectGen.generateCachedEffect(); - cvf::ref part = new cvf::Part; - part->setDrawable(curveDrawable.p()); - part->setEffect(effect.p()); + cvf::ref part = new cvf::Part; + part->setDrawable(curveDrawable.p()); + part->setEffect(effect.p()); - if (part.notNull()) - { - model->addPart(part.p()); - } + if (part.notNull()) + { + model->addPart(part.p()); } } @@ -157,48 +141,10 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurveCollection* collection, - const Rim3dWellLogCurve* curve) +double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(const Rim3dWellLogCurve* curve) const { - switch (curve->drawPlane()) - { - case Rim3dWellLogCurve::HORIZONTAL_LEFT: - return cvf::PI_D / 2.0; - case Rim3dWellLogCurve::HORIZONTAL_RIGHT: - if (collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ON_WELLPATH) - { - return cvf::PI_D / 2.0; // Always left when on well path - } - return -cvf::PI_D / 2.0; - case Rim3dWellLogCurve::VERTICAL_ABOVE: - return 0.0; - case Rim3dWellLogCurve::VERTICAL_BELOW: - if (collection->planePositionVertical() == Rim3dWellLogCurveCollection::ON_WELLPATH) - { - return 0.0; // Always above when on well path. - } - return cvf::PI_D; - default: - return 0; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve) const -{ - bool centered = false; - if (curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_LEFT || - curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_RIGHT) - { - centered = collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ON_WELLPATH; - } - else - { - centered = collection->planePositionVertical() == Rim3dWellLogCurveCollection::ON_WELLPATH; - } - if (centered) + if (curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_CENTER || + curve->drawPlane() == Rim3dWellLogCurve::VERTICAL_CENTER) { return -0.5*planeWidth(); } @@ -251,8 +197,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, wellPathClipBoundingBox, - planeAngle(curveCollection, rim3dWellLogCurve), - wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), + rim3dWellLogCurve->drawPlaneAngle(), + wellPathCenterToPlotStartOffset(rim3dWellLogCurve), planeWidth(), gridIntervalSize); if (!gridCreated) return; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index fa6b639612..44772acb03 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -56,9 +56,10 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox); private: - void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox); + void append3dWellLogCurveToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + Rim3dWellLogCurve* rim3dWellLogCurve); void appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, @@ -68,8 +69,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); - static double planeAngle(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve); - double wellPathCenterToPlotStartOffset(const Rim3dWellLogCurveCollection* collection, const Rim3dWellLogCurve* curve) const; + double wellPathCenterToPlotStartOffset(const Rim3dWellLogCurve* curve) const; double planeWidth() const; private: diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index bb5524a750..2ad6866768 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -28,17 +28,6 @@ CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); -namespace caf -{ - template<> - void AppEnum< Rim3dWellLogCurveCollection::PlanePosition >::setUp() - { - addItem(Rim3dWellLogCurveCollection::ALONG_WELLPATH, "ALONG_WELLPATH", "Beside Well Path"); - addItem(Rim3dWellLogCurveCollection::ON_WELLPATH, "ON_WELLPATH", "Centered On Well Path"); - setDefault(Rim3dWellLogCurveCollection::ALONG_WELLPATH); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -49,8 +38,6 @@ Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() CAF_PDM_InitField(&m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); m_showPlot.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_planePositionVertical, "PlanePositionVertical", "Vertical Position", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_planePositionHorizontal, "PlanePositionHorizontal", "Horizontal Position", "", "", ""); CAF_PDM_InitField(&m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Width Scaling", "", "", ""); m_planeWidthScaling.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); @@ -121,22 +108,6 @@ bool Rim3dWellLogCurveCollection::isShowingBackground() const return m_showBackground; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePositionVertical() const -{ - return m_planePositionVertical(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurveCollection::PlanePosition Rim3dWellLogCurveCollection::planePositionHorizontal() const -{ - return m_planePositionHorizontal(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -232,8 +203,6 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Configuration"); - settingsGroup->add(&m_planePositionVertical); - settingsGroup->add(&m_planePositionHorizontal); settingsGroup->add(&m_planeWidthScaling); caf::PdmUiGroup* appearanceSettingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h index f495e9ab0e..1121aefa26 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -36,13 +36,6 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; -public: - enum PlanePosition - { - ALONG_WELLPATH, - ON_WELLPATH - }; - public: Rim3dWellLogCurveCollection(); virtual ~Rim3dWellLogCurveCollection(); @@ -55,8 +48,6 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject bool isShowingGrid() const; bool isShowingBackground() const; - PlanePosition planePositionVertical() const; - PlanePosition planePositionHorizontal() const; float planeWidthScaling() const; std::vector vectorOf3dWellLogCurves() const; @@ -73,8 +64,6 @@ class Rim3dWellLogCurveCollection : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); private: caf::PdmField m_showPlot; - caf::PdmField> m_planePositionVertical; - caf::PdmField> m_planePositionHorizontal; caf::PdmField m_planeWidthScaling; caf::PdmField m_showGrid; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 9d3d75f0b0..421caa654a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -44,8 +44,10 @@ namespace caf void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() { addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Above"); + addItem(Rim3dWellLogCurve::VERTICAL_CENTER, "VERTICAL_CENTER", "Centered - Vertical"); addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Below"); addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_CENTER, "HORIZONTAL_CENTER", "Centered - Horizontal"); addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Right"); setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); } @@ -96,6 +98,28 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Rim3dWellLogCurve::drawPlaneAngle() const +{ + switch (drawPlane()) + { + case HORIZONTAL_LEFT: + case HORIZONTAL_CENTER: + return cvf::PI_D / 2.0; + case HORIZONTAL_RIGHT: + return -cvf::PI_D / 2.0; + case VERTICAL_ABOVE: + case VERTICAL_CENTER: + return 0.0; + case VERTICAL_BELOW: + return cvf::PI_D; + default: + return 0; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -173,35 +197,6 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) configurationGroup->add(&m_maxCurveValue); } -QList Rim3dWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) -{ - QList options; - if (fieldNeedingOptions == &m_drawPlane) - { - Rim3dWellLogCurveCollection* collection; - this->firstAncestorOrThisOfTypeAsserted(collection); - if (collection->planePositionVertical() == Rim3dWellLogCurveCollection::ALONG_WELLPATH) - { - options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::VERTICAL_ABOVE), Rim3dWellLogCurve::VERTICAL_ABOVE)); - options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::VERTICAL_BELOW), Rim3dWellLogCurve::VERTICAL_BELOW)); - } - else - { - options.push_back(caf::PdmOptionItemInfo(QString("Vertical"), Rim3dWellLogCurve::VERTICAL_ABOVE)); - } - if (collection->planePositionHorizontal() == Rim3dWellLogCurveCollection::ALONG_WELLPATH) - { - options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::HORIZONTAL_LEFT), Rim3dWellLogCurve::HORIZONTAL_LEFT)); - options.push_back(caf::PdmOptionItemInfo(DrawPlaneEnum::uiText(Rim3dWellLogCurve::HORIZONTAL_RIGHT), Rim3dWellLogCurve::HORIZONTAL_RIGHT)); - } - else - { - options.push_back(caf::PdmOptionItemInfo(QString("Horizontal"), Rim3dWellLogCurve::HORIZONTAL_LEFT)); - } - } - return options; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 1b3f68ad47..b14fe8e0bf 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -43,9 +43,11 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder enum DrawPlane { VERTICAL_ABOVE, - VERTICAL_BELOW, + VERTICAL_CENTER, + VERTICAL_BELOW, HORIZONTAL_LEFT, - HORIZONTAL_RIGHT + HORIZONTAL_CENTER, + HORIZONTAL_RIGHT }; typedef caf::AppEnum DrawPlaneEnum; public: @@ -56,7 +58,10 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder virtual QString name() const = 0; virtual QString resultPropertyString() const = 0; + DrawPlane drawPlane() const; + double drawPlaneAngle() const; + cvf::Color3f color() const; bool isShowingCurve() const; @@ -79,7 +84,6 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void configurationUiOrdering(caf::PdmUiOrdering& uiOrdering); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual void initAfterRead(); private: diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index 8d02ef6745..d7cb84510b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -78,7 +78,7 @@ Rim3dWellLogExtractionCurve::Rim3dWellLogExtractionCurve() m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); m_geomResultDefinition = new RimGeoMechResultDefinition; - CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameGenerator", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); m_nameConfig = new RimWellLogExtractionCurveNameConfig(this); } @@ -328,7 +328,7 @@ void Rim3dWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::Pd Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); - caf::PdmUiGroup* nameGroup = m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp index dcd47d0bca..40976b2b95 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -252,7 +252,7 @@ void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); - caf::PdmUiGroup* nameGroup = m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index 85ad411929..94cf60912d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -213,6 +213,8 @@ void Rim3dWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrde Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp index 7bbc4903b8..c153c7c271 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp @@ -26,7 +26,7 @@ /// //================================================================================================== -CAF_PDM_SOURCE_INIT(RimCurveNameConfig, "RimCurveNameGenerator"); +CAF_PDM_SOURCE_INIT(RimCurveNameConfig, "RimCurveNameConfig"); //-------------------------------------------------------------------------------------------------- /// @@ -108,7 +108,6 @@ void RimCurveNameConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel if (changedField == &m_isUsingAutoName && !isUsingAutoName()) { m_customName = m_configHolder->createCurveAutoName(); - m_customName.uiCapability()->updateConnectedEditors(); } updateAllSettings(); @@ -152,7 +151,7 @@ void RimCurveNameConfig::updateAllSettings() /// //================================================================================================== -CAF_PDM_SOURCE_INIT(RimWellLogExtractionCurveNameConfig, "RimWellLogExtractionCurveNameGenerator"); +CAF_PDM_SOURCE_INIT(RimWellLogExtractionCurveNameConfig, "RimWellLogExtractionCurveNameConfig"); //-------------------------------------------------------------------------------------------------- /// @@ -244,7 +243,7 @@ void RimWellLogExtractionCurveNameConfig::updateAllSettings() /// //================================================================================================== -CAF_PDM_SOURCE_INIT(RimWellLogFileCurveNameConfig, "RimWellLogFileCurveNameGenerator"); +CAF_PDM_SOURCE_INIT(RimWellLogFileCurveNameConfig, "RimWellLogFileCurveNameConfig"); //-------------------------------------------------------------------------------------------------- /// @@ -261,7 +260,7 @@ RimWellLogFileCurveNameConfig::RimWellLogFileCurveNameConfig(const RimCurveNameC /// //================================================================================================== -CAF_PDM_SOURCE_INIT(RimWellLogRftCurveNameConfig, "RimWellLogRftCurveNameGenerator"); +CAF_PDM_SOURCE_INIT(RimWellLogRftCurveNameConfig, "RimWellLogRftCurveNameConfig"); //-------------------------------------------------------------------------------------------------- /// From 6e3d989b2fbc12a7fabc5b4ae7d6edb8d1dd9349 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 10:21:27 +0200 Subject: [PATCH 0836/1027] #2825 Fix curve stitching issues against 3dwell log curve background. --- .../Riv3dWellLogCurveGeomertyGenerator.cpp | 207 ++++++++++++++---- .../Riv3dWellLogCurveGeomertyGenerator.h | 12 +- .../Riv3dWellLogPlanePartMgr.cpp | 18 +- .../Riv3dWellLogPlanePartMgr.h | 3 +- Fwk/AppFwk/cafVizExtensions/CMakeLists.txt | 2 + .../cafBoxManipulatorPartManager.cpp | 81 +------ .../cafBoxManipulatorPartManager.h | 3 - Fwk/AppFwk/cafVizExtensions/cafLine.h | 68 ++++++ Fwk/AppFwk/cafVizExtensions/cafLine.inl | 111 ++++++++++ 9 files changed, 381 insertions(+), 124 deletions(-) create mode 100644 Fwk/AppFwk/cafVizExtensions/cafLine.h create mode 100644 Fwk/AppFwk/cafVizExtensions/cafLine.inl diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index d7c5ef1a1b..a4eab920aa 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -25,6 +25,7 @@ #include "RigWellPath.h" #include "RigWellPathGeometryTools.h" +#include "cafLine.h" #include "cafDisplayCoordTransform.h" #include "cvfPrimitiveSetIndexedUInt.h" @@ -49,18 +50,19 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, - double planeWidth) + double planeWidth, + const std::vector& gridVertices) { + // Make sure all drawables are cleared in case we return early to avoid a + // previous drawable being "stuck" when changing result type. + clearCurvePointsAndGeometry(); + std::vector resultValues; std::vector resultMds; rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); m_planeWidth = planeWidth; - // Make sure all drawables are cleared in case we return early to avoid a - // previous drawable being "stuck" when changing result type. - clearCurvePointsAndGeometry(); - if (!wellPathGeometry()) return; if (wellPathGeometry()->m_wellPathPoints.empty()) return; if (!wellPathClipBoundingBox.isValid()) return; @@ -80,7 +82,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (wellPathCollection->wellPathClip) { double clipZDistance = wellPathCollection->wellPathClipZDistance; - clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); + clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); } clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); @@ -90,14 +92,15 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); } - std::vector wellPathCurveNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, rim3dWellLogCurve->drawPlaneAngle()); + std::vector wellPathCurveNormals = + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, rim3dWellLogCurve->drawPlaneAngle()); std::vector interpolatedWellPathPoints; std::vector interpolatedCurveNormals; // Iterate from bottom of well path and up to be able to stop at given Z max clipping height for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) { - cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, *md); + cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, *md); cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, *md); if (point.z() > clipLocation.z()) break; @@ -111,10 +114,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end()); // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size - m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), - resultValues.end()); - m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), - resultMds.end()); + m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); + m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end()); double maxClampedResult = -HUGE_VAL; double minClampedResult = HUGE_VAL; @@ -145,27 +146,26 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) { - scaledResult = - planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor; + scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor; } cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint)); } + createNewVerticesAlongTriangleEdges(gridVertices); + projectVerticesOntoTriangles(gridVertices); + + std::vector indices; - indices.reserve(interpolatedWellPathPoints.size()); - for (size_t i = 0; i < m_curveValues.size() - 1; ++i) + indices.reserve(m_curveVertices.size() * 2); + for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) { - if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && - RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) - { - indices.push_back(cvf::uint(i)); - indices.push_back(cvf::uint(i + 1)); - } + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); } - + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); + cvf::ref indexArray = new cvf::UIntArray(indices); m_curveDrawable = new cvf::DrawableGeo(); @@ -173,7 +173,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveDrawable->addPrimitiveSet(indexedUInt.p()); cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices); - m_curveDrawable->setVertexArray(vertexArray.p()); + m_curveDrawable->setVertexArray(vertexArray.p()); } //-------------------------------------------------------------------------------------------------- @@ -212,10 +212,10 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 double* valueAtClosestPoint) const { cvf::Vec3f globalIntersectionFloat(globalIntersection); - float closestDistance = m_planeWidth * 0.1; - *closestPoint = cvf::Vec3d::UNDEFINED; - *measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE; - *valueAtClosestPoint = cvf::UNDEFINED_DOUBLE; + float closestDistance = m_planeWidth * 0.1; + *closestPoint = cvf::Vec3d::UNDEFINED; + *measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE; + *valueAtClosestPoint = cvf::UNDEFINED_DOUBLE; if (m_curveVertices.size() < 2u) false; CVF_ASSERT(m_curveVertices.size() == m_curveValues.size()); for (size_t i = 1; i < m_curveVertices.size(); ++i) @@ -224,27 +224,154 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 RigCurveDataTools::isValidValue(m_curveValues[i - 1], false); if (validCurveSegment) { - cvf::Vec3f a = m_curveVertices[i - 1]; - cvf::Vec3f b = m_curveVertices[i]; + cvf::Vec3f a = m_curveVertices[i - 1]; + cvf::Vec3f b = m_curveVertices[i]; cvf::Vec3f ap = globalIntersectionFloat - a; cvf::Vec3f ab = b - a; // Projected point is clamped to one of the end points of the segment. - float distanceToProjectedPointAlongAB = ap * ab / (ab * ab); - float clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0f, 1.0f); - cvf::Vec3f projectionOfGlobalIntersection = a + clampedDistance * ab; - float distance = (projectionOfGlobalIntersection - globalIntersectionFloat).length(); + float distanceToProjectedPointAlongAB = ap * ab / (ab * ab); + float clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0f, 1.0f); + cvf::Vec3f projectionOfGlobalIntersection = a + clampedDistance * ab; + float distance = (projectionOfGlobalIntersection - globalIntersectionFloat).length(); if (distance < closestDistance) { - *closestPoint = cvf::Vec3d(projectionOfGlobalIntersection); + *closestPoint = cvf::Vec3d(projectionOfGlobalIntersection); closestDistance = distance; - *measuredDepthAtPoint = m_curveMeasuredDepths[i - 1] * (1.0f - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; + *measuredDepthAtPoint = + m_curveMeasuredDepths[i - 1] * (1.0f - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; *valueAtClosestPoint = m_curveValues[i - 1] * (1.0f - clampedDistance) + m_curveValues[i] * clampedDistance; } } } - if (closestPoint->isUndefined()) - return false; - + if (closestPoint->isUndefined()) return false; + return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& gridVertices) +{ + std::vector expandedCurveVertices; + std::vector expandedMeasuredDepths; + std::vector expandedValues; + size_t estimatedNumberOfPoints = m_curveVertices.size() + gridVertices.size(); + expandedCurveVertices.reserve(estimatedNumberOfPoints); + expandedMeasuredDepths.reserve(estimatedNumberOfPoints); + expandedValues.reserve(estimatedNumberOfPoints); + for (size_t i = 0; i < m_curveVertices.size() - 1; i += 2) + { + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) + { + expandedCurveVertices.push_back(m_curveVertices[i]); + expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); + expandedValues.push_back(m_curveValues[i]); + // Find segments that intersects the triangle edge + caf::Line curveLine(m_curveVertices[i], m_curveVertices[i + 1]); + + for (size_t j = 0; j < gridVertices.size() - 1; ++j) + { + caf::Line gridLine(gridVertices[j], gridVertices[j + 1]); + bool withinSegments = false; + caf::Line connectingLine = curveLine.findLineBetweenNearestPoints(gridLine, &withinSegments); + + if (withinSegments) + { + cvf::Vec3f closestGridPoint = connectingLine.end(); + double measuredDepth; + double valueAtPoint; + cvf::Vec3d closestPoint(closestGridPoint); + cvf::Vec3d dummyArgument; + // Interpolate measured depth and value + bool worked = findClosestPointOnCurve(closestPoint, &dummyArgument, &measuredDepth, &valueAtPoint); + if (worked) + { + expandedCurveVertices.push_back(closestGridPoint); + expandedMeasuredDepths.push_back(measuredDepth); + expandedValues.push_back(valueAtPoint); + } + + } + } + + // Next original segment point + expandedCurveVertices.push_back(m_curveVertices[i + 1]); + expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i + 1]); + expandedValues.push_back(m_curveValues[i + 1]); + } + } + + m_curveVertices.swap(expandedCurveVertices); + m_curveMeasuredDepths.swap(expandedMeasuredDepths); + m_curveValues.swap(expandedValues); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& gridVertices) +{ + for (size_t i = 0; i < m_curveVertices.size(); ++i) + { + for (size_t j = 0; j < gridVertices.size() - 2; j += 1) + { + cvf::Vec3f triangleVertex1, triangleVertex2, triangleVertex3; + if (j % 2 == 0) + { + triangleVertex1 = gridVertices[j]; + triangleVertex2 = gridVertices[j + 1]; + triangleVertex3 = gridVertices[j + 2]; + } + else + { + triangleVertex1 = gridVertices[j]; + triangleVertex2 = gridVertices[j + 2]; + triangleVertex3 = gridVertices[j + 1]; + } + + bool wasInsideTriangle = false; + cvf::Vec3f projectedPoint = projectPointOntoTriangle( + m_curveVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); + if (wasInsideTriangle) + { + m_curveVertices[i] = projectedPoint; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3f Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cvf::Vec3f& point, + const cvf::Vec3f& triangleVertex1, + const cvf::Vec3f& triangleVertex2, + const cvf::Vec3f& triangleVertex3, + bool* wasInsideTriangle) +{ + *wasInsideTriangle = false; + cvf::Vec3f e1 = triangleVertex2 - triangleVertex1; + cvf::Vec3f e2 = triangleVertex3 - triangleVertex1; + cvf::Vec3f n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); + + // Project vertex onto triangle plane + cvf::Vec3f av = point - triangleVertex1; + cvf::Vec3f projectedPoint = point - (av * n) * n; + + // Calculate barycentric coordinates + float areaABC = n * (e1 ^ e2); + float areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); + float areaPCA = n * ((triangleVertex3 - projectedPoint) ^ (triangleVertex1 - projectedPoint)); + float u = areaPBC / areaABC; + float v = areaPCA / areaABC; + float w = 1.0 - u - v; + + if (u >= 0.0 && v >= 0.0 && w >= 0.0) + { + *wasInsideTriangle = true; + } + return projectedPoint; +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 23dd4e27a9..702eb95cec 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -51,8 +51,9 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, - double planeWidth); - + double planeWidth, + const std::vector& gridVertices); + void clearCurvePointsAndGeometry(); const RigWellPath* wellPathGeometry() const; @@ -65,6 +66,13 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double* valueAtClosestPoint) const; private: + void createNewVerticesAlongTriangleEdges(const std::vector& gridVertices); + void projectVerticesOntoTriangles(const std::vector& gridVertices); + static cvf::Vec3f projectPointOntoTriangle(const cvf::Vec3f& point, + const cvf::Vec3f& triangleVertex1, + const cvf::Vec3f& triangleVertex2, + const cvf::Vec3f& triangleVertex3, + bool* wasInsideTriangle); caf::PdmPointer m_wellPath; double m_planeWidth; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index b169a5c9bd..d0ec737db2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -72,8 +72,15 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) { - appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); - append3dWellLogCurveToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve); + if (rim3dWellLogCurve->isShowingCurve()) + { + appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); + append3dWellLogCurveToModel(model, + displayCoordTransform, + wellPathClipBoundingBox, + rim3dWellLogCurve, + m_3dWellLogGridGeometryGenerator->vertices()); + } } } @@ -83,10 +90,10 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - Rim3dWellLogCurve* rim3dWellLogCurve) + Rim3dWellLogCurve* rim3dWellLogCurve, + const std::vector& gridVertices) { CVF_ASSERT(rim3dWellLogCurve); - if (!rim3dWellLogCurve->isShowingCurve()) return; cvf::ref generator = rim3dWellLogCurve->geometryGenerator(); if (generator.isNull()) @@ -99,7 +106,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* wellPathClipBoundingBox, rim3dWellLogCurve, wellPathCenterToPlotStartOffset(rim3dWellLogCurve), - planeWidth()); + planeWidth(), + gridVertices); cvf::ref curveDrawable = generator->curveDrawable(); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 44772acb03..92cd584846 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -59,7 +59,8 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object void append3dWellLogCurveToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, - Rim3dWellLogCurve* rim3dWellLogCurve); + Rim3dWellLogCurve* rim3dWellLogCurve, + const std::vector& gridVertices); void appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index 136ab8146f..2d0f236581 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -26,6 +26,8 @@ add_library( ${PROJECT_NAME} cafFixedAtlasFont.cpp cafTransparentWBRenderConfiguration.h cafTransparentWBRenderConfiguration.cpp + cafLine.h + cafLine.inl TranspWB_CombinationFrag.glsl TranspWB_PartlyTranspPartsFrag.glsl TranspWB_TransparentPartsFrag.glsl diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp index b254736d0c..0a388addd5 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp @@ -3,6 +3,7 @@ #include "cafBoxManipulatorGeometryGenerator.h" #include "cafEffectGenerator.h" +#include "cafLine.h" #include "cvfBoxGenerator.h" #include "cvfDrawableGeo.h" @@ -150,11 +151,12 @@ void BoxManipulatorPartManager::updateManipulatorFromRay(const cvf::Ray* ray) BoxFace face = m_handleIds[m_currentHandleIndex].first; cvf::Vec3d faceDir = normalFromFace(face); - cvf::Vec3d closestPointOnMouseRay; - cvf::Vec3d closestPointOnHandleRay; - BoxManipulatorPartManager::closestPointOfTwoLines(ray->origin(), ray->origin() + ray->direction(), - m_initialPickPoint, m_initialPickPoint + faceDir, - &closestPointOnMouseRay, &closestPointOnHandleRay); + caf::Line rayLine(ray->origin(), ray->origin() + ray->direction()); + caf::Line pickLine(m_initialPickPoint, m_initialPickPoint + faceDir); + + caf::Line mouseHandleLine = rayLine.findLineBetweenNearestPoints(pickLine); + cvf::Vec3d closestPointOnMouseRay = mouseHandleLine.start(); + cvf::Vec3d closestPointOnHandleRay = mouseHandleLine.end(); cvf::Vec3d newOrigin = m_origin; cvf::Vec3d newSize = m_size; @@ -402,72 +404,5 @@ void BoxManipulatorPartManager::createBoundingBoxPart() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool BoxManipulatorPartManager::closestPointOfTwoLines(const cvf::Vec3d& L1p1, const cvf::Vec3d& L1p2, - const cvf::Vec3d& L2p1, const cvf::Vec3d& L2p2, - cvf::Vec3d* closestPointOnL1, cvf::Vec3d* closestPointOnL2) -{ - // qDebug() << p1 << " " << q1 << " " << p2 << " " << q2; - - // Taken from Real-Time Collistion Detection, Christer Ericson, 2005, p146-147 - - // L1(s) = P1 + sd1 - // L2(t) = P2 + td2 - - // d1 = Q1-P1 - // d2 = Q2-P2 - - // r = P1-P2 - - // a = d1*d1 - // b = d1*d2 - // c = d1*r - // e = d2*d2; - // d = ae-b^2 - // f = d2*r - - // s = (bf-ce)/d - // t = (af-bc)/d - - - cvf::Vec3d d1 = L1p2 - L1p1; - cvf::Vec3d d2 = L2p2 - L2p1; - - double a = d1.dot(d1); - double b = d1.dot(d2); - double e = d2.dot(d2); - - double d = a*e - b*b; - - if (d < std::numeric_limits::epsilon()) - { - // Parallel lines - if (closestPointOnL1) *closestPointOnL1 = L1p1; - if (closestPointOnL2) *closestPointOnL2 = L2p1; - return false; - } - - cvf::Vec3d r = L1p1 - L2p1; - double c = d1.dot(r); - double f = d2.dot(r); - - double s = (b*f - c*e) / d; - double t = (a*f - b*c) / d; - - if (closestPointOnL1) *closestPointOnL1 = L1p1 + s*d1; - if (closestPointOnL2) *closestPointOnL2 = L2p1 + t*d2; - - if (s >= 0 && s <= 1 && t >= 0 && t <= 1) - { - return true; - } - else - { - return false; - } -} - -} // namespace cvf +} // namespace caf diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h index 757f982aa8..dd9612c50e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h @@ -79,9 +79,6 @@ class BoxManipulatorPartManager : public cvf::Object const cvf::Vec3f& v3, const cvf::Vec3f& v4, const cvf::Vec3f& v5); - static bool closestPointOfTwoLines(const cvf::Vec3d& p1, const cvf::Vec3d& q1, - const cvf::Vec3d& p2, const cvf::Vec3d& q2, - cvf::Vec3d* closestPoint1, cvf::Vec3d* closestPoint2); private: std::vector< std::pair > m_handleIds; // These arrays have the same length diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.h b/Fwk/AppFwk/cafVizExtensions/cafLine.h new file mode 100644 index 0000000000..aea0b7a710 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.h @@ -0,0 +1,68 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- 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" +#include "cvfVector3.h" + +namespace caf +{ +template +class Line +{ +public: + Line(); + Line(const cvf::Vector3& startPoint, const cvf::Vector3& endPoint); + Line(const Line& copyFrom); + Line& operator=(const Line& copyFrom); + + const cvf::Vector3& start() const; + const cvf::Vector3& end() const; + cvf::Vector3 vector() const; + + Line findLineBetweenNearestPoints(const Line& otherLine, bool* withinLineSegments = nullptr); + +private: + cvf::Vector3 m_start; + cvf::Vector3 m_end; +}; + +} + +#include "cafLine.inl" + + diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.inl b/Fwk/AppFwk/cafVizExtensions/cafLine.inl new file mode 100644 index 0000000000..34ddf1a46b --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.inl @@ -0,0 +1,111 @@ +#include "cafLine.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line() + : m_start(cvf::Vector3::UNDEFINED) + , m_end(cvf::Vector3::UNDEFINED) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line(const cvf::Vector3& startPoint, const cvf::Vector3& endPoint) + : m_start(startPoint) + , m_end(endPoint) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line(const Line& copyFrom) +{ + m_start = copyFrom.start(); + m_end = copyFrom.end(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line& caf::Line::operator=(const Line& copyFrom) +{ + m_start = copyFrom.start(); + m_end = copyFrom.end(); + return *this; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +const cvf::Vector3& caf::Line::start() const +{ + return m_start; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +const cvf::Vector3& caf::Line::end() const +{ + return m_end; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +cvf::Vector3 caf::Line::vector() const +{ + return m_end - m_start; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line caf::Line::findLineBetweenNearestPoints(const Line& otherLine, bool* withinLineSegments) +{ + // Taken from Real-Time Collision Detection, Christer Ericson, 2005, p146-147 + cvf::Vector3 d1 = vector(); + cvf::Vector3 d2 = otherLine.vector(); + + S a = d1.dot(d1); + S b = d1.dot(d2); + S e = d2.dot(d2); + + S d = a * e - b * b; + + if (d < std::numeric_limits::epsilon()) + { + // Parallel lines. Choice of closest points is arbitrary. + // Just use start to start. + if (withinLineSegments) *withinLineSegments = true; + return Line(start(), otherLine.start()); + } + + cvf::Vector3 r = start() - otherLine.start(); + S c = d1.dot(r); + S f = d2.dot(r); + + S s = (b*f - c * e) / d; + S t = (a*f - b * c) / d; + + if (withinLineSegments) + { + *withinLineSegments = s >= 0 && s <= 1 && t >= 0 && t <= 1; + } + return Line(start() + s * d1, otherLine.start() + t * d2); +} + From a37957824a937aab9a028fdcf611e97408acfe43 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 12:10:05 +0200 Subject: [PATCH 0837/1027] Clean up 3D well log generator code. Renamed Grid -> DrawSurface and fixed spelling. --- .../ModelVisualization/CMakeLists_files.cmake | 8 ++-- ...=> Riv3dWellLogCurveGeometryGenerator.cpp} | 40 +++++++++--------- ...h => Riv3dWellLogCurveGeometryGenerator.h} | 6 +-- ...p => Riv3dWellLogDrawSurfaceGenerator.cpp} | 24 +++++------ ...r.h => Riv3dWellLogDrawSurfaceGenerator.h} | 8 ++-- .../Riv3dWellLogPlanePartMgr.cpp | 42 +++++++++---------- .../Riv3dWellLogPlanePartMgr.h | 16 +++---- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 2 +- 8 files changed, 73 insertions(+), 73 deletions(-) rename ApplicationCode/ModelVisualization/{Riv3dWellLogCurveGeomertyGenerator.cpp => Riv3dWellLogCurveGeometryGenerator.cpp} (92%) rename ApplicationCode/ModelVisualization/{Riv3dWellLogCurveGeomertyGenerator.h => Riv3dWellLogCurveGeometryGenerator.h} (95%) rename ApplicationCode/ModelVisualization/{Riv3dWellLogGridGeomertyGenerator.cpp => Riv3dWellLogDrawSurfaceGenerator.cpp} (93%) rename ApplicationCode/ModelVisualization/{Riv3dWellLogGridGeomertyGenerator.h => Riv3dWellLogDrawSurfaceGenerator.h} (87%) diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 29bef15533..16b6117694 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -38,12 +38,12 @@ ${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h -${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.h -${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -80,12 +80,12 @@ ${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp -${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeomertyGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.cpp -${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogGridGeomertyGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp similarity index 92% rename from ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp rename to ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index a4eab920aa..197fb4f429 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "Riv3dWellLogCurveGeometryGenerator.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -51,7 +51,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, double planeWidth, - const std::vector& gridVertices) + const std::vector& drawSurfaceVertices) { // Make sure all drawables are cleared in case we return early to avoid a // previous drawable being "stuck" when changing result type. @@ -152,8 +152,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveVertices.push_back(cvf::Vec3f(curvePoint)); } - createNewVerticesAlongTriangleEdges(gridVertices); - projectVerticesOntoTriangles(gridVertices); + createNewVerticesAlongTriangleEdges(drawSurfaceVertices); + projectVerticesOntoTriangles(drawSurfaceVertices); std::vector indices; @@ -252,12 +252,12 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& gridVertices) +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) { std::vector expandedCurveVertices; std::vector expandedMeasuredDepths; std::vector expandedValues; - size_t estimatedNumberOfPoints = m_curveVertices.size() + gridVertices.size(); + size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); expandedCurveVertices.reserve(estimatedNumberOfPoints); expandedMeasuredDepths.reserve(estimatedNumberOfPoints); expandedValues.reserve(estimatedNumberOfPoints); @@ -272,24 +272,24 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con // Find segments that intersects the triangle edge caf::Line curveLine(m_curveVertices[i], m_curveVertices[i + 1]); - for (size_t j = 0; j < gridVertices.size() - 1; ++j) + for (size_t j = 0; j < drawSurfaceVertices.size() - 1; ++j) { - caf::Line gridLine(gridVertices[j], gridVertices[j + 1]); + caf::Line drawSurfaceLine(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); bool withinSegments = false; - caf::Line connectingLine = curveLine.findLineBetweenNearestPoints(gridLine, &withinSegments); + caf::Line connectingLine = curveLine.findLineBetweenNearestPoints(drawSurfaceLine, &withinSegments); if (withinSegments) { - cvf::Vec3f closestGridPoint = connectingLine.end(); + cvf::Vec3f closestDrawSurfacePoint = connectingLine.end(); double measuredDepth; double valueAtPoint; - cvf::Vec3d closestPoint(closestGridPoint); + cvf::Vec3d closestPoint(closestDrawSurfacePoint); cvf::Vec3d dummyArgument; // Interpolate measured depth and value bool worked = findClosestPointOnCurve(closestPoint, &dummyArgument, &measuredDepth, &valueAtPoint); if (worked) { - expandedCurveVertices.push_back(closestGridPoint); + expandedCurveVertices.push_back(closestDrawSurfacePoint); expandedMeasuredDepths.push_back(measuredDepth); expandedValues.push_back(valueAtPoint); } @@ -312,24 +312,24 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& gridVertices) +void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& drawSurfaceVertices) { for (size_t i = 0; i < m_curveVertices.size(); ++i) { - for (size_t j = 0; j < gridVertices.size() - 2; j += 1) + for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { cvf::Vec3f triangleVertex1, triangleVertex2, triangleVertex3; if (j % 2 == 0) { - triangleVertex1 = gridVertices[j]; - triangleVertex2 = gridVertices[j + 1]; - triangleVertex3 = gridVertices[j + 2]; + triangleVertex1 = drawSurfaceVertices[j]; + triangleVertex2 = drawSurfaceVertices[j + 1]; + triangleVertex3 = drawSurfaceVertices[j + 2]; } else { - triangleVertex1 = gridVertices[j]; - triangleVertex2 = gridVertices[j + 2]; - triangleVertex3 = gridVertices[j + 1]; + triangleVertex1 = drawSurfaceVertices[j]; + triangleVertex2 = drawSurfaceVertices[j + 2]; + triangleVertex3 = drawSurfaceVertices[j + 1]; } bool wasInsideTriangle = false; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h similarity index 95% rename from ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h rename to ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h index 702eb95cec..a9fecac7a4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h @@ -52,7 +52,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, double planeWidth, - const std::vector& gridVertices); + const std::vector& drawSurfaceVertices); void clearCurvePointsAndGeometry(); @@ -66,8 +66,8 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double* valueAtClosestPoint) const; private: - void createNewVerticesAlongTriangleEdges(const std::vector& gridVertices); - void projectVerticesOntoTriangles(const std::vector& gridVertices); + void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); + void projectVerticesOntoTriangles(const std::vector& drawSurfaceVertices); static cvf::Vec3f projectPointOntoTriangle(const cvf::Vec3f& point, const cvf::Vec3f& triangleVertex1, const cvf::Vec3f& triangleVertex2, diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp similarity index 93% rename from ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp rename to ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 4d44520580..48e7e8646e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "Riv3dWellLogGridGeomertyGenerator.h" +#include "Riv3dWellLogDrawSurfaceGenerator.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" @@ -38,7 +38,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath) +Riv3dWellLogDrawSurfaceGenerator::Riv3dWellLogDrawSurfaceGenerator(RimWellPath* wellPath) : m_wellPath(wellPath) { } @@ -47,14 +47,14 @@ Riv3dWellLogGridGeometryGenerator::Riv3dWellLogGridGeometryGenerator(RimWellPath /// //-------------------------------------------------------------------------------------------------- bool -Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, +Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, - double gridIntervalSize) + double samplingIntervalSize) { - CVF_ASSERT(gridIntervalSize > 0); + CVF_ASSERT(samplingIntervalSize > 0); clearGeometry(); @@ -194,7 +194,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(segmentNormals, md); interpolatedGridPoints.push_back(point); interpolatedGridCurveNormals.push_back(curveNormal.getNormalized()); - md -= gridIntervalSize; + md -= samplingIntervalSize; } std::vector arrowVertices; @@ -237,7 +237,7 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogGridGeometryGenerator::clearGeometry() +void Riv3dWellLogDrawSurfaceGenerator::clearGeometry() { m_background = nullptr; m_border = nullptr; @@ -248,7 +248,7 @@ void Riv3dWellLogGridGeometryGenerator::clearGeometry() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogGridGeometryGenerator::background() const +cvf::ref Riv3dWellLogDrawSurfaceGenerator::background() const { return m_background; } @@ -256,7 +256,7 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::background() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogGridGeometryGenerator::border() const +cvf::ref Riv3dWellLogDrawSurfaceGenerator::border() const { return m_border; } @@ -264,7 +264,7 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::border() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalVectors() const +cvf::ref Riv3dWellLogDrawSurfaceGenerator::curveNormalVectors() const { return m_curveNormalVectors; } @@ -272,7 +272,7 @@ cvf::ref Riv3dWellLogGridGeometryGenerator::curveNormalVec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& Riv3dWellLogGridGeometryGenerator::vertices() const +const std::vector& Riv3dWellLogDrawSurfaceGenerator::vertices() const { return m_vertices; } @@ -280,7 +280,7 @@ const std::vector& Riv3dWellLogGridGeometryGenerator::vertices() con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigWellPath* Riv3dWellLogGridGeometryGenerator::wellPathGeometry() const +const RigWellPath* Riv3dWellLogDrawSurfaceGenerator::wellPathGeometry() const { return m_wellPath->wellPathGeometry(); } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h similarity index 87% rename from ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h rename to ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h index b506115127..d1fdb66494 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogGridGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h @@ -40,17 +40,17 @@ class BoundingBox; class RigWellPath; class RimWellPath; -class Riv3dWellLogGridGeometryGenerator : public cvf::Object +class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object { public: - Riv3dWellLogGridGeometryGenerator(RimWellPath* wellPath); + Riv3dWellLogDrawSurfaceGenerator(RimWellPath* wellPath); - bool createGrid(const caf::DisplayCoordTransform* displayCoordTransform, + bool createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, double planeAngle, double planeOffsetFromWellPathCenter, double planeWidth, - double gridIntervalSize); + double samplingIntervalSize); void clearGeometry(); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index d0ec737db2..208d3ca3cd 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -27,8 +27,8 @@ #include "RimGridView.h" #include "RimWellPath.h" -#include "Riv3dWellLogCurveGeomertyGenerator.h" -#include "Riv3dWellLogGridGeomertyGenerator.h" +#include "Riv3dWellLogCurveGeometryGenerator.h" +#include "Riv3dWellLogDrawSurfaceGenerator.h" #include "RivObjectSourceInfo.h" #include "cafDisplayCoordTransform.h" @@ -52,7 +52,7 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri , m_gridView(gridView) { CVF_ASSERT(m_wellPath.notNull()); - m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p()); + m_3dWellLogDrawSurfaceGeometryGenerator = new Riv3dWellLogDrawSurfaceGenerator(m_wellPath.p()); } //-------------------------------------------------------------------------------------------------- @@ -74,12 +74,12 @@ void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* { if (rim3dWellLogCurve->isShowingCurve()) { - appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); + appendDrawSurfaceToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); append3dWellLogCurveToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, - m_3dWellLogGridGeometryGenerator->vertices()); + m_3dWellLogDrawSurfaceGeometryGenerator->vertices()); } } } @@ -91,7 +91,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, Rim3dWellLogCurve* rim3dWellLogCurve, - const std::vector& gridVertices) + const std::vector& drawSurfaceVertices) { CVF_ASSERT(rim3dWellLogCurve); @@ -107,7 +107,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* rim3dWellLogCurve, wellPathCenterToPlotStartOffset(rim3dWellLogCurve), planeWidth(), - gridVertices); + drawSurfaceVertices); cvf::ref curveDrawable = generator->curveDrawable(); @@ -179,19 +179,19 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, +void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, const Rim3dWellLogCurve* rim3dWellLogCurve, - double gridIntervalSize) + double samplingInterval) { Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - bool showGrid = curveCollection->isShowingGrid(); + bool showCoordinateSystemMesh = curveCollection->isShowingGrid(); bool showBackground = curveCollection->isShowingBackground(); - cvf::Color3f gridColor(0.4f, 0.4f, 0.4f); + cvf::Color3f borderColor(0.4f, 0.4f, 0.4f); caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); - caf::MeshEffectGenerator gridBorderEffectGen(gridColor); + caf::MeshEffectGenerator borderEffectGen(borderColor); caf::VectorEffectGenerator curveNormalsEffectGen; backgroundEffectGen.enableLighting(false); @@ -203,19 +203,19 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* backgroundEffectGen.enableDepthWrite(false); } - bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform, + bool drawSurfaceCreated = m_3dWellLogDrawSurfaceGeometryGenerator->createDrawSurface(displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve->drawPlaneAngle(), wellPathCenterToPlotStartOffset(rim3dWellLogCurve), planeWidth(), - gridIntervalSize); - if (!gridCreated) return; + samplingInterval); + if (!drawSurfaceCreated) return; cvf::ref backgroundEffect = backgroundEffectGen.generateCachedEffect(); - cvf::ref borderEffect = gridBorderEffectGen.generateCachedEffect(); + cvf::ref borderEffect = borderEffectGen.generateCachedEffect(); cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); - cvf::ref background = m_3dWellLogGridGeometryGenerator->background(); + cvf::ref background = m_3dWellLogDrawSurfaceGeometryGenerator->background(); cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); if (background.notNull()) { @@ -227,9 +227,9 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - if (showGrid) + if (showCoordinateSystemMesh) { - cvf::ref border = m_3dWellLogGridGeometryGenerator->border(); + cvf::ref border = m_3dWellLogDrawSurfaceGeometryGenerator->border(); if (border.notNull()) { cvf::ref part = createPart(border.p(), borderEffect.p()); @@ -239,10 +239,10 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* } } - cvf::ref normals = m_3dWellLogGridGeometryGenerator->curveNormalVectors(); + cvf::ref normals = m_3dWellLogDrawSurfaceGeometryGenerator->curveNormalVectors(); if (normals.notNull()) { - normals->setSingleColor(gridColor); + normals->setSingleColor(borderColor); if (RiaApplication::instance()->useShaders()) { normals->setUniformNames("u_transformationMatrix", "u_color"); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 92cd584846..f7fb4c39a6 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -45,7 +45,7 @@ class DisplayCoordTransform; class RimGridView; class RimWellPath; -class Riv3dWellLogGridGeometryGenerator; +class Riv3dWellLogDrawSurfaceGenerator; class Riv3dWellLogPlanePartMgr : public cvf::Object { @@ -60,13 +60,13 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, Rim3dWellLogCurve* rim3dWellLogCurve, - const std::vector& gridVertices); + const std::vector& drawSurfaceVertices); - void appendGridToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - const Rim3dWellLogCurve* rim3dWellLogCurve, - double gridIntervalSize); + void appendDrawSurfaceToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double samplingInterval); cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); @@ -74,7 +74,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object double planeWidth() const; private: - cvf::ref m_3dWellLogGridGeometryGenerator; + cvf::ref m_3dWellLogDrawSurfaceGeometryGenerator; caf::PdmPointer m_wellPath; caf::PdmPointer m_gridView; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 421caa654a..f18a73b372 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -19,7 +19,7 @@ #include "Rim3dWellLogCurve.h" #include "RigCurveDataTools.h" -#include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "Riv3dWellLogCurveGeometryGenerator.h" #include "Rim3dWellLogCurveCollection.h" #include "RimProject.h" From 98af9e00abaa6b6cffbc73f98d98b1dce5cccaee Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 12:11:15 +0200 Subject: [PATCH 0838/1027] Fix build issue on Linux --- Fwk/AppFwk/cafVizExtensions/cafLine.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.inl b/Fwk/AppFwk/cafVizExtensions/cafLine.inl index 34ddf1a46b..6a4b1c39fd 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafLine.inl +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.inl @@ -87,7 +87,7 @@ caf::Line caf::Line::findLineBetweenNearestPoints(const Line& otherLine, b S d = a * e - b * b; - if (d < std::numeric_limits::epsilon()) + if (d < std::numeric_limits::epsilon()) { // Parallel lines. Choice of closest points is arbitrary. // Just use start to start. From ffccb078e87cd102d969d44ad64b118e4cac6330 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 14:01:50 +0200 Subject: [PATCH 0839/1027] #2841 Fix bad result when z-clipping is applied. --- .../Riv3dWellLogDrawSurfaceGenerator.cpp | 284 ++++++++++-------- .../Riv3dWellLogDrawSurfaceGenerator.h | 24 +- 2 files changed, 169 insertions(+), 139 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 48e7e8646e..072e6a906c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -73,8 +73,9 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; - if (wellPathPoints.empty()) + if (wellPathPoints.size() < (size_t)2) { + // Need at least two well path points to create a valid path. return false; } @@ -83,154 +84,46 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); } - std::vector segmentNormals = + std::vector wellPathSegmentNormals = RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); - - size_t originalWellPathSize = wellPathPoints.size(); - + size_t indexToFirstVisibleSegment = 0u; if (wellPathCollection->wellPathClip) { double clipZDistance = wellPathCollection->wellPathClipZDistance; - double horizontalLengthAlongWellToClipPoint; - cvf::Vec3d clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); + cvf::Vec3d clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); - size_t indexToFirstVisibleSegment; + double horizontalLengthAlongWellToClipPoint; + wellPathPoints = RigWellPath::clipPolylineStartAboveZ( wellPathPoints, clipLocation.z(), &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); } + + // Create curve normal vectors using the unclipped well path points and normals. + createCurveNormalVectors(displayCoordTransform, indexToFirstVisibleSegment, planeOffsetFromWellPathCenter, planeWidth, samplingIntervalSize, wellPathSegmentNormals); - if (wellPathPoints.size() < (size_t) 2) + // Note that normals are calculated on the full non-clipped well path. So we need to clip the remainder here. + wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); + + if (wellPathPoints.size() < (size_t)2) { // Need at least two well path points to create a valid path. return false; } - // Note that normals are calculated on the full non-clipped well path to increase the likelihood of creating good normals - // for the end points of the curve. So we need to clip the remainder here. - segmentNormals.erase(segmentNormals.begin(), segmentNormals.end() - wellPathPoints.size()); - + m_vertices.reserve(wellPathPoints.size() * 2); + for (size_t i = 0; i < wellPathPoints.size(); i++) { - m_vertices.reserve(wellPathPoints.size() * 2); - - std::vector backgroundIndices; - backgroundIndices.reserve(wellPathPoints.size() * 2); - - // Vertices are used for both surface and border - for (size_t i = 0; i < wellPathPoints.size(); i++) - { - m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + segmentNormals[i] * planeOffsetFromWellPathCenter)); - m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + segmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); - backgroundIndices.push_back((cvf::uint) (2 * i)); - backgroundIndices.push_back((cvf::uint) (2 * i + 1)); - } - - cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices); - - { - // Background specific - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); - cvf::ref indexArray = new cvf::UIntArray(backgroundIndices); - indexedUInt->setIndices(indexArray.p()); - - m_background = new cvf::DrawableGeo(); - m_background->addPrimitiveSet(indexedUInt.p()); - m_background->setVertexArray(vertexArray.p()); - } - - { - std::vector borderIndices; - borderIndices.reserve(m_vertices.size()); - - int secondLastEvenVertex = (int) m_vertices.size() - 4; - - // Border close to the well. All even indices. - for (int i = 0; i <= secondLastEvenVertex; i += 2) - { - borderIndices.push_back((cvf::uint) i); - borderIndices.push_back((cvf::uint) i+2); - } - - // Connect to border away from well - borderIndices.push_back((cvf::uint) (m_vertices.size() - 2)); - borderIndices.push_back((cvf::uint) (m_vertices.size() - 1)); - - int secondOddVertex = 3; - int lastOddVertex = (int) m_vertices.size() - 1; - - // Border away from from well are odd indices in reverse order to create a closed surface. - for (int i = lastOddVertex; i >= secondOddVertex; i -= 2) - { - borderIndices.push_back((cvf::uint) i); - borderIndices.push_back((cvf::uint) i - 2); - } - // Close border - borderIndices.push_back(1u); - borderIndices.push_back(0u); - - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(borderIndices); - indexedUInt->setIndices(indexArray.p()); - - m_border = new cvf::DrawableGeo(); - m_border->addPrimitiveSet(indexedUInt.p()); - m_border->setVertexArray(vertexArray.p()); - } - } - { - std::vector interpolatedGridPoints; - std::vector interpolatedGridCurveNormals; - - size_t newStartIndex = originalWellPathSize - wellPathPoints.size(); - double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex); - double lastMd = wellPathGeometry()->m_measuredDepths.back(); - - double md = lastMd; - while (md >= firstMd) - { - cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); - cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(segmentNormals, md); - interpolatedGridPoints.push_back(point); - interpolatedGridCurveNormals.push_back(curveNormal.getNormalized()); - md -= samplingIntervalSize; - } - - std::vector arrowVertices; - std::vector arrowVectors; - arrowVertices.reserve(interpolatedGridPoints.size()); - arrowVectors.reserve(interpolatedGridPoints.size()); - - double shaftRelativeRadius = 0.0125f; - double arrowHeadRelativeRadius = shaftRelativeRadius * 3; - double arrowHeadRelativeLength = arrowHeadRelativeRadius * 3; - double totalArrowScaling = 1.0 / (1.0 - arrowHeadRelativeLength); - // Normal lines. Start from one to avoid drawing at surface edge. - for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++) - { - arrowVertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter)); - - arrowVectors.push_back(cvf::Vec3f(interpolatedGridCurveNormals[i] * planeWidth * totalArrowScaling)); - } - - m_curveNormalVectors = new cvf::DrawableVectors(); - - cvf::ref vertexArray = new cvf::Vec3fArray(arrowVertices); - cvf::ref vectorArray = new cvf::Vec3fArray(arrowVectors); - - // Create the arrow glyph for the vector drawer - cvf::GeometryBuilderTriangles arrowBuilder; - cvf::ArrowGenerator gen; - gen.setShaftRelativeRadius(shaftRelativeRadius); - gen.setHeadRelativeRadius(arrowHeadRelativeRadius); - gen.setHeadRelativeLength(arrowHeadRelativeLength); - gen.setNumSlices(4); - gen.generate(&arrowBuilder); - - m_curveNormalVectors->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); - m_curveNormalVectors->setVectors(vertexArray.p(), vectorArray.p()); + m_vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter)); + m_vertices.push_back(cvf::Vec3f( + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); } + + cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices); + createBackground(vertexArray.p()); + createBorder(vertexArray.p()); + return true; } @@ -277,6 +170,133 @@ const std::vector& Riv3dWellLogDrawSurfaceGenerator::vertices() cons return m_vertices; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createCurveNormalVectors(const caf::DisplayCoordTransform* displayCoordTransform, + size_t clipStartIndex, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize, + const std::vector& segmentNormals) +{ + std::vector interpolatedWellPathPoints; + std::vector interpolatedWellPathNormals; + + double firstMd = wellPathGeometry()->m_measuredDepths.at(clipStartIndex); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + + double md = lastMd; + while (md >= firstMd) + { + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); + point = displayCoordTransform->transformToDisplayCoord(point); + cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(segmentNormals, md); + interpolatedWellPathPoints.push_back(point); + interpolatedWellPathNormals.push_back(curveNormal.getNormalized()); + md -= samplingIntervalSize; + } + + std::vector arrowVertices; + std::vector arrowVectors; + arrowVertices.reserve(interpolatedWellPathPoints.size()); + arrowVectors.reserve(interpolatedWellPathPoints.size()); + + double shaftRelativeRadius = 0.0125f; + double arrowHeadRelativeRadius = shaftRelativeRadius * 3; + double arrowHeadRelativeLength = arrowHeadRelativeRadius * 3; + double totalArrowScaling = 1.0 / (1.0 - arrowHeadRelativeLength); + // Normal lines. Start from one to avoid drawing at surface edge. + for (size_t i = 1; i < interpolatedWellPathNormals.size(); i++) + { + arrowVertices.push_back(cvf::Vec3f(interpolatedWellPathPoints[i] + interpolatedWellPathNormals[i] * planeOffsetFromWellPathCenter)); + + arrowVectors.push_back(cvf::Vec3f(interpolatedWellPathNormals[i] * planeWidth * totalArrowScaling)); + } + + m_curveNormalVectors = new cvf::DrawableVectors(); + + cvf::ref vertexArray = new cvf::Vec3fArray(arrowVertices); + cvf::ref vectorArray = new cvf::Vec3fArray(arrowVectors); + + // Create the arrow glyph for the vector drawer + cvf::GeometryBuilderTriangles arrowBuilder; + cvf::ArrowGenerator gen; + gen.setShaftRelativeRadius(shaftRelativeRadius); + gen.setHeadRelativeRadius(arrowHeadRelativeRadius); + gen.setHeadRelativeLength(arrowHeadRelativeLength); + gen.setNumSlices(4); + gen.generate(&arrowBuilder); + + m_curveNormalVectors->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); + m_curveNormalVectors->setVectors(vertexArray.p(), vectorArray.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createBackground(cvf::Vec3fArray* vertexArray) +{ + std::vector backgroundIndices; + backgroundIndices.reserve(vertexArray->size()); + for (size_t i = 0; i < vertexArray->size(); ++i) + { + backgroundIndices.push_back((cvf::uint) (i)); + } + + // Background specific + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); + cvf::ref indexArray = new cvf::UIntArray(backgroundIndices); + indexedUInt->setIndices(indexArray.p()); + + m_background = new cvf::DrawableGeo(); + m_background->addPrimitiveSet(indexedUInt.p()); + m_background->setVertexArray(vertexArray); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createBorder(cvf::Vec3fArray* vertexArray) +{ + std::vector borderIndices; + borderIndices.reserve(m_vertices.size()); + + int secondLastEvenVertex = (int)vertexArray->size() - 4; + + // Border close to the well. All even indices. + for (int i = 0; i <= secondLastEvenVertex; i += 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i + 2); + } + + // Connect to border away from well + borderIndices.push_back((cvf::uint) (vertexArray->size() - 2)); + borderIndices.push_back((cvf::uint) (vertexArray->size() - 1)); + + int secondOddVertex = 3; + int lastOddVertex = (int)vertexArray->size() - 1; + + // Border away from from well are odd indices in reverse order to create a closed surface. + for (int i = lastOddVertex; i >= secondOddVertex; i -= 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i - 2); + } + // Close border + borderIndices.push_back(1u); + borderIndices.push_back(0u); + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(borderIndices); + indexedUInt->setIndices(indexArray.p()); + + m_border = new cvf::DrawableGeo(); + m_border->addPrimitiveSet(indexedUInt.p()); + m_border->setVertexArray(vertexArray); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h index d1fdb66494..01d0ed186b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h @@ -45,13 +45,13 @@ class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object public: Riv3dWellLogDrawSurfaceGenerator(RimWellPath* wellPath); - bool createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, - const cvf::BoundingBox& wellPathClipBoundingBox, - double planeAngle, - double planeOffsetFromWellPathCenter, - double planeWidth, - double samplingIntervalSize); - + bool createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize); + void clearGeometry(); cvf::ref background() const; @@ -61,6 +61,16 @@ class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object const std::vector& vertices() const; private: + void createCurveNormalVectors(const caf::DisplayCoordTransform* displayCoordTransform, + size_t clipStartIndex, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize, + const std::vector& wellPathSegmentNormals); + + void createBackground(cvf::Vec3fArray* vertexArray); + void createBorder(cvf::Vec3fArray* vertexArray); + const RigWellPath* wellPathGeometry() const; private: From 26975e3ce36be4bbb0667c57669cbc73bbca849e Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 14:22:49 +0200 Subject: [PATCH 0840/1027] Fix unit tests by removing assert in RimWellLogCurveNameConfig --- ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp index c153c7c271..579f1d345d 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp @@ -42,8 +42,6 @@ RimCurveNameConfig::RimCurveNameConfig(const RimCurveNameConfigHolderInterface* m_autoName.registerGetMethod(this, &RimCurveNameConfig::autoName); m_autoName.registerSetMethod(this, &RimCurveNameConfig::setCustomName); m_autoName.xmlCapability()->disableIO(); - - CVF_ASSERT(configHolder); } //-------------------------------------------------------------------------------------------------- From b023bd02a3080c264b537ffb58966f115adf0403 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 2 May 2018 12:00:21 +0200 Subject: [PATCH 0841/1027] #2838 Ensemble Curve Name : Improve logic for display of legend --- .../ProjectDataModel/RimPlotCurve.cpp | 24 ++++++++++++------- .../Summary/RimEnsembleCurveSetCollection.cpp | 9 ++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index f2bdb24a11..3c6b7f6b4a 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -19,6 +19,7 @@ #include "RimPlotCurve.h" #include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" @@ -583,14 +584,6 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { bool showLegendInQwt = m_showLegend(); - RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfType(summaryPlot); - if (summaryPlot && summaryPlot->curveCount() == 1) - { - // Disable display of legend if the summary plot has only one single curve - showLegendInQwt = false; - } - RimEnsembleCurveSet* ensembleCurveSet = nullptr; this->firstAncestorOrThisOfType(ensembleCurveSet); if (ensembleCurveSet) @@ -602,6 +595,21 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() showLegendInQwt = false; } } + else + { + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfType(summaryPlot); + if (summaryPlot) + { + if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) + { + // Disable display of legend if the summary plot has only one single curve + showLegendInQwt = false; + } + } + + } + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 8b41f6593f..0fb9583945 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -212,11 +212,14 @@ std::vector RimEnsembleCurveSetCollection::visibleCurveSet { std::vector visible; - for (auto c : m_curveSets) + if (m_showCurves()) { - if (c->isCurvesVisible()) + for (auto c : m_curveSets) { - visible.push_back(c); + if (c->isCurvesVisible()) + { + visible.push_back(c); + } } } From 95c11d00853ffa636d73341be88848f666006917 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 2 May 2018 12:06:36 +0200 Subject: [PATCH 0842/1027] #2838 Ensemble Curve Name : Call updateConnectedEditors on RimSummaryPlot --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 6 ++++++ .../Summary/RimEnsembleCurveSetCollection.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 4da5c0f306..8a4a1611dd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -340,6 +340,12 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (changedField == &m_showCurves) { loadDataAndUpdate(true); + + updateConnectedEditors(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + summaryPlot->updateConnectedEditors(); } else if (changedField == &m_yValuesUiFilterResultSelection) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 0fb9583945..6ba4bf20a2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -375,6 +375,10 @@ void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* if (changedField == &m_showCurves) { loadDataAndUpdate(true); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + summaryPlot->updateConnectedEditors(); } } From cfab9102721a19f3e88d07d89d38c1df253fc897 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 2 May 2018 12:47:12 +0200 Subject: [PATCH 0843/1027] Remove unused code --- .../Summary/RimEnsembleCurveSetCollection.cpp | 276 +++--------------- .../Summary/RimEnsembleCurveSetCollection.h | 14 +- 2 files changed, 38 insertions(+), 252 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 6ba4bf20a2..905e7b8b91 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -23,26 +23,22 @@ #include "RifReaderEclipseSummary.h" -#include "RimProject.h" #include "RimEnsembleCurveSet.h" +#include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCurve.h" +#include "RimSummaryCurveAppearanceCalculator.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotSourceStepping.h" -#include "RimSummaryCurveAppearanceCalculator.h" #include "RiuLineSegmentQwtPlotCurve.h" #include "RiuSummaryQwtPlot.h" -#include "cafPdmUiTreeViewEditor.h" - -#include - CAF_PDM_SOURCE_INIT(RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() { @@ -54,33 +50,10 @@ RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); m_showCurves.uiCapability()->setUiHidden(true); - - //CAF_PDM_InitFieldNoDefault(&m_ySourceStepping, "YSourceStepping", "", "", "", ""); - //m_ySourceStepping = new RimSummaryPlotSourceStepping; - //m_ySourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::Y_AXIS); - //m_ySourceStepping.uiCapability()->setUiHidden(true); - //m_ySourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_ySourceStepping.xmlCapability()->disableIO(); - - //CAF_PDM_InitFieldNoDefault(&m_xSourceStepping, "XSourceStepping", "", "", "", ""); - //m_xSourceStepping = new RimSummaryPlotSourceStepping; - //m_xSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::X_AXIS); - //m_xSourceStepping.uiCapability()->setUiHidden(true); - //m_xSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_xSourceStepping.xmlCapability()->disableIO(); - - //CAF_PDM_InitFieldNoDefault(&m_unionSourceStepping, "UnionSourceStepping", "", "", "", ""); - //m_unionSourceStepping = new RimSummaryPlotSourceStepping; - //m_unionSourceStepping->setSourceSteppingType(RimSummaryPlotSourceStepping::UNION_X_Y_AXIS); - //m_unionSourceStepping.uiCapability()->setUiHidden(true); - //m_unionSourceStepping.uiCapability()->setUiTreeChildrenHidden(true); - //m_unionSourceStepping.xmlCapability()->disableIO(); - - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() { @@ -88,7 +61,7 @@ RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimEnsembleCurveSetCollection::isCurveSetsVisible() { @@ -96,7 +69,7 @@ bool RimEnsembleCurveSetCollection::isCurveSetsVisible() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) { @@ -105,28 +78,22 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) curveSet->loadDataAndUpdate(updateParentPlot); } - //for (RimSummaryCurve* curve : m_curves) - //{ - // curve->loadDataAndUpdate(false); - // curve->updateQwtPlotAxis(); - //} - - if ( updateParentPlot ) + if (updateParentPlot) { - RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if ( parentPlot->qwtPlot() ) - { - parentPlot->updatePlotTitle(); - parentPlot->qwtPlot()->updateLegend(); - parentPlot->updateAxes(); - parentPlot->updateZoomInQwt(); - } + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) + { + parentPlot->updatePlotTitle(); + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) { @@ -139,18 +106,18 @@ void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::detachQwtCurves() { - for(const auto& curveSet : m_curveSets) + for (const auto& curveSet : m_curveSets) { curveSet->detachQwtCurves(); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve(const QwtPlotCurve* qwtCurve) const { @@ -169,12 +136,12 @@ RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve( } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet) { static int nextAutoColorIndex = 1; - static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size(); + static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size(); if (curveSet) { @@ -186,7 +153,7 @@ void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::deleteCurveSet(RimEnsembleCurveSet* curveSet) { @@ -198,7 +165,7 @@ void RimEnsembleCurveSetCollection::deleteCurveSet(RimEnsembleCurveSet* curveSet } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleCurveSetCollection::curveSets() const { @@ -206,7 +173,7 @@ std::vector RimEnsembleCurveSetCollection::curveSets() con } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimEnsembleCurveSetCollection::visibleCurveSets() const { @@ -214,7 +181,7 @@ std::vector RimEnsembleCurveSetCollection::visibleCurveSet if (m_showCurves()) { - for (auto c : m_curveSets) + for (const auto& c : m_curveSets) { if (c->isCurvesVisible()) { @@ -226,57 +193,16 @@ std::vector RimEnsembleCurveSetCollection::visibleCurveSet return visible; } -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -//void RimEnsembleCurveSetCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) -//{ -// std::vector summaryCurvesToDelete; -// -// for (RimSummaryCurve* summaryCurve : m_curves) -// { -// if (!summaryCurve) continue; -// if (!summaryCurve->summaryCaseY()) continue; -// -// if (summaryCurve->summaryCaseY() == summaryCase) -// { -// summaryCurvesToDelete.push_back(summaryCurve); -// } -// } -// for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete) -// { -// m_curves.removeChildObject(summaryCurve); -// delete summaryCurve; -// } -// -//} - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::deleteAllCurveSets() { m_curveSets.deleteAllChildObjects(); } -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -//void RimEnsembleCurveSetCollection::updateCaseNameHasChanged() -//{ -// for (RimSummaryCurve* curve : m_curves) -// { -// curve->updateCurveNameNoLegendUpdate(); -// curve->updateConnectedEditors(); -// } -// -// RimSummaryPlot* parentPlot; -// firstAncestorOrThisOfTypeAsserted(parentPlot); -// if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); -//} -// //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet) { @@ -285,92 +211,12 @@ void RimEnsembleCurveSetCollection::setCurrentSummaryCurveSet(RimEnsembleCurveSe updateConnectedEditors(); } -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -//std::vector RimEnsembleCurveSetCollection::fieldsToShowInToolbar() -//{ -// RimSummaryCrossPlot* parentCrossPlot; -// firstAncestorOrThisOfType(parentCrossPlot); -// -// if (parentCrossPlot) -// { -// return m_unionSourceStepping->fieldsToShowInToolbar(); -// } -// -// return m_ySourceStepping()->fieldsToShowInToolbar(); -//} -// -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -//void RimEnsembleCurveSetCollection::handleKeyPressEvent(QKeyEvent* keyEvent) -//{ -// if (!keyEvent) return; -// -// RimSummaryPlotSourceStepping* sourceStepping = nullptr; -// { -// RimSummaryCrossPlot* summaryCrossPlot = nullptr; -// this->firstAncestorOrThisOfType(summaryCrossPlot); -// -// if (summaryCrossPlot) -// { -// sourceStepping = m_unionSourceStepping(); -// } -// else -// { -// sourceStepping = m_ySourceStepping(); -// } -// } -// -// if (keyEvent->key() == Qt::Key_PageUp) -// { -// if (keyEvent->modifiers() & Qt::ShiftModifier) -// { -// sourceStepping->applyPrevCase(); -// -// keyEvent->accept(); -// } -// else if (keyEvent->modifiers() & Qt::ControlModifier) -// { -// sourceStepping->applyPrevOtherIdentifier(); -// -// keyEvent->accept(); -// } -// else -// { -// sourceStepping->applyPrevQuantity(); -// -// keyEvent->accept(); -// } -// } -// else if (keyEvent->key() == Qt::Key_PageDown) -// { -// if (keyEvent->modifiers() & Qt::ShiftModifier) -// { -// sourceStepping->applyNextCase(); -// -// keyEvent->accept(); -// } -// else if (keyEvent->modifiers() & Qt::ControlModifier) -// { -// sourceStepping->applyNextOtherIdentifier(); -// -// keyEvent->accept(); -// } -// else -// { -// sourceStepping->applyNextQuantity(); -// -// keyEvent->accept(); -// } -// } -//} - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { if (changedField == &m_showCurves) { @@ -383,57 +229,9 @@ void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* } //-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - //RimSummaryCrossPlot* parentCrossPlot; - //firstAncestorOrThisOfType(parentCrossPlot); - - //if (parentCrossPlot) - //{ - // { - // auto group = uiOrdering.addNewGroup("Y Source Stepping"); - - // m_ySourceStepping()->uiOrdering(uiConfigName, *group); - // } - - // { - // auto group = uiOrdering.addNewGroup("X Source Stepping"); - - // m_xSourceStepping()->uiOrdering(uiConfigName, *group); - // } - - // { - // auto group = uiOrdering.addNewGroup("XY Union Source Stepping"); - - // m_unionSourceStepping()->uiOrdering(uiConfigName, *group); - // } - //} - //else - //{ - // auto group = uiOrdering.addNewGroup("Plot Source Stepping"); - - // m_ySourceStepping()->uiOrdering(uiConfigName, *group); - //} -} - -//-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimEnsembleCurveSetCollection::objectToggleField() { return &m_showCurves; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) -{ - //caf::PdmUiTreeViewEditorAttribute* myAttr = dynamic_cast(attribute); - //if (myAttr && m_currentSummaryCurve.notNull()) - //{ - // myAttr->currentObject = m_currentSummaryCurve.p(); - //} -} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 756ba20aee..2eb506aa84 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -23,9 +23,7 @@ #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "cafPdmPtrArrayField.h" -class RimSummaryCase; class RimEnsembleCurveSet; class QwtPlot; class QwtPlotCurve; @@ -55,22 +53,12 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject std::vector curveSets() const; std::vector visibleCurveSets() const; - //void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); void deleteAllCurveSets(); - //void updateCaseNameHasChanged(); void setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet); - //std::vector fieldsToShowInToolbar(); - - //void handleKeyPressEvent(QKeyEvent* keyEvent); - private: - caf::PdmFieldHandle* objectToggleField(); - virtual void defineObjectEditorAttribute(QString uiConfigName, - caf::PdmUiEditorAttribute* attribute) override; - - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From cff95a1880bed4f4799a7bbbbebe7e6c1f0ca1df Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 2 May 2018 14:59:38 +0200 Subject: [PATCH 0844/1027] #2838 Ensemble Curve Name : Hide Qwt legend if result legend is used --- ApplicationCode/ProjectDataModel/RimPlotCurve.cpp | 10 ++++++++-- .../Summary/RimEnsembleCurveSet.cpp | 13 +++++++++++++ .../ProjectDataModel/Summary/RimEnsembleCurveSet.h | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 3c6b7f6b4a..95738dd12f 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -594,6 +594,13 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() // Hide legend display for curves other than the first showLegendInQwt = false; } + else + { + if (ensembleCurveSet->colorMode() == RimEnsembleCurveSet::BY_ENSEMBLE_PARAM) + { + showLegendInQwt = false; + } + } } else { @@ -608,8 +615,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() showLegendInQwt = false; } } - } - + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 8a4a1611dd..8ccfc56e4d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -328,6 +328,14 @@ RimSummaryCaseCollection* RimEnsembleCurveSet::summaryCaseCollection() const return m_yValuesSummaryGroup(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::ColorMode RimEnsembleCurveSet::colorMode() const +{ + return m_colorMode(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -642,6 +650,11 @@ void RimEnsembleCurveSet::updateCurveColors() } plot->qwtPlot()->replot(); } + + if (firstCurve()) + { + firstCurve()->updateLegendEntryVisibilityAndPlotLegend(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 802de95035..685791cc39 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -84,6 +84,8 @@ class RimEnsembleCurveSet : public caf::PdmObject void setSummaryCaseCollection(RimSummaryCaseCollection* sumCaseCollection); RimSummaryCaseCollection* summaryCaseCollection() const; + ColorMode colorMode() const; + private: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField(); From 483f19e5ca8e180ed495d664d17b5c647d5574db Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 2 May 2018 15:14:17 +0200 Subject: [PATCH 0845/1027] #2838 Ensemble Curve Name : Show curve name in parameter legend title --- .../Summary/RimEnsembleCurveSet.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 8ccfc56e4d..75291d47b5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -595,8 +595,25 @@ void RimEnsembleCurveSet::updateCurveColors() if(m_colorMode == BY_ENSEMBLE_PARAM) { RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + QString parameterName = m_ensembleParameter(); - m_legendConfig->setTitle(parameterName); + + { + QString legendTitle; + if (m_isUsingAutoName) + { + legendTitle = m_autoGeneratedName(); + } + else + { + legendTitle += m_userDefinedName(); + } + + legendTitle += "\n"; + legendTitle += parameterName; + + m_legendConfig->setTitle(legendTitle); + } if (group && !parameterName.isEmpty()) { From 736277e0efba0042682d55af08dfbf106d8a8d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 09:50:52 +0200 Subject: [PATCH 0846/1027] #2797 Ensemble curves. Slightly increased cateory legend height --- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 1a3d4b87a7..d95259c2a0 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -503,7 +503,7 @@ cvf::Vec2ui CategoryLegend::preferredSize() OverlayColorLegendLayoutInfo layout({200,200}); // Use default size layoutInfo(&layout); - float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() )* layout.lineSpacing ; + float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() + 1)* layout.lineSpacing ; unsigned int maxTickTextWidth = 0; for (size_t cIdx = 0; cIdx < m_categoryMapper->categoryCount(); ++cIdx ) From 92fd4183a96a5c933a7e926b3545b90659604a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 09:53:25 +0200 Subject: [PATCH 0847/1027] #2797 Ensemble curves. Support for text ensemble parameters. Unit test --- .../Application/Tools/RiaDateStringParser.cpp | 14 +- .../Application/Tools/RiaDateStringParser.h | 1 - .../Application/Tools/RiaStdStringTools.cpp | 18 +++ .../Application/Tools/RiaStdStringTools.h | 2 + .../Commands/RicImportEnsembleFeature.cpp | 4 +- .../RifCaseRealizationParametersReader.cpp | 31 +++-- .../RifCaseRealizationParametersReader.h | 9 +- .../RimRegularLegendConfig.cpp | 76 ++++++++--- .../ProjectDataModel/RimRegularLegendConfig.h | 3 + .../Summary/RimEnsembleCurveSet.cpp | 125 +++++++++++++++--- .../Summary/RimEnsembleCurveSet.h | 3 + .../Summary/RimSummaryCase.cpp | 4 +- .../ProjectDataModel/Summary/RimSummaryCase.h | 8 +- .../RigCaseRealizationParameters.cpp | 72 +++++++++- .../RigCaseRealizationParameters.h | 35 ++++- ...ifCaseRealizationParametersReader-Test.cpp | 16 ++- .../parameters.txt | 1 + .../UserInterface/RiuCvfOverlayItemWidget.cpp | 2 +- 18 files changed, 339 insertions(+), 85 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaDateStringParser.cpp b/ApplicationCode/Application/Tools/RiaDateStringParser.cpp index cd8d96fa21..c28575a548 100644 --- a/ApplicationCode/Application/Tools/RiaDateStringParser.cpp +++ b/ApplicationCode/Application/Tools/RiaDateStringParser.cpp @@ -139,7 +139,7 @@ bool RiaDateStringParser::tryParseMonthFirst(const std::string& s, int& year, in //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseYear(const std::string& s, int &year) { - if (containsAlphabetic(s)) return false; + if (RiaStdStringTools::containsAlphabetic(s)) return false; auto today = QDate::currentDate(); int y = RiaStdStringTools::toInt(s); @@ -158,7 +158,7 @@ bool RiaDateStringParser::tryParseYear(const std::string& s, int &year) //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month) { - if (containsAlphabetic(s)) + if (RiaStdStringTools::containsAlphabetic(s)) { auto sMonth = s; sMonth = trimString(sMonth); @@ -190,7 +190,7 @@ bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month) //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseDay(const std::string& s, int &day) { - if (containsAlphabetic(s)) return false; + if (RiaStdStringTools::containsAlphabetic(s)) return false; int d = RiaStdStringTools::toInt(s); if (d >= 1 && d <= 31) @@ -203,14 +203,6 @@ bool RiaDateStringParser::tryParseDay(const std::string& s, int &day) return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiaDateStringParser::containsAlphabetic(const std::string& s) -{ - return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaDateStringParser.h b/ApplicationCode/Application/Tools/RiaDateStringParser.h index bd573078a8..4e23b44053 100644 --- a/ApplicationCode/Application/Tools/RiaDateStringParser.h +++ b/ApplicationCode/Application/Tools/RiaDateStringParser.h @@ -42,7 +42,6 @@ class RiaDateStringParser static bool tryParseMonth(const std::string& s, int &month); static bool tryParseDay(const std::string& s, int &day); - static bool containsAlphabetic(const std::string& s); static std::string trimString(const std::string& s); }; diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp index a81e04068f..b144d8fc82 100644 --- a/ApplicationCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp @@ -76,6 +76,24 @@ double RiaStdStringTools::toDouble(const std::string& s) return doubleValue; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaStdStringTools::containsAlphabetic(const std::string& s) +{ + return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaStdStringTools::startsWithAlphabetic(const std::string& s) +{ + if (s.empty()) return false; + + return isalpha(s[0]); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.h b/ApplicationCode/Application/Tools/RiaStdStringTools.h index 60788302f4..dd1f15e59d 100644 --- a/ApplicationCode/Application/Tools/RiaStdStringTools.h +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.h @@ -35,6 +35,8 @@ class RiaStdStringTools static int toInt(const std::string& s); static double toDouble(const std::string& s); + static bool containsAlphabetic(const std::string& s); + static bool startsWithAlphabetic(const std::string& s); static std::vector splitStringBySpace(const std::string& s); diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 447b9db731..3440acf67a 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -108,14 +108,14 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vectorcaseRealizationParameters().isNull() || rimCase->caseRealizationParameters()->parameters().empty()) + if (rimCase->caseRealizationParameters() == nullptr || rimCase->caseRealizationParameters()->parameters().empty()) { errors.append(QString("The case %1 has no ensemble parameters\n").arg(QFileInfo(rimCase->summaryHeaderFilename()).fileName())); } else { QString paramNames; - for (std::pair paramPair : rimCase->caseRealizationParameters()->parameters()) + for (std::pair paramPair : rimCase->caseRealizationParameters()->parameters()) { paramNames.append(paramPair.first); } diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp index eab4490088..8ef6f884a2 100644 --- a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -38,7 +38,7 @@ //-------------------------------------------------------------------------------------------------- RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QString& fileName) { - m_parameters = new RigCaseRealizationParameters(); + m_parameters = std::shared_ptr(new RigCaseRealizationParameters()); m_fileName = fileName; m_file = nullptr; m_textStream = nullptr; @@ -49,7 +49,7 @@ RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QSt //-------------------------------------------------------------------------------------------------- RifCaseRealizationParametersReader::RifCaseRealizationParametersReader() { - m_parameters = new RigCaseRealizationParameters(); + m_parameters = std::shared_ptr(new RigCaseRealizationParameters()); m_fileName = ""; m_file = nullptr; m_textStream = nullptr; @@ -100,19 +100,26 @@ void RifCaseRealizationParametersReader::parse() QString& name = cols[0]; QString& strValue = cols[1]; - if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) + if (RiaStdStringTools::startsWithAlphabetic(strValue.toStdString())) { - throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + m_parameters->addParameter(name, strValue); } - - bool parseOk = true; - double value = QLocale::c().toDouble(strValue, &parseOk); - if (!parseOk) + else { - throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) + { + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + bool parseOk = true; + double value = QLocale::c().toDouble(strValue, &parseOk); + if (!parseOk) + { + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + m_parameters->addParameter(name, value); } - - m_parameters->addParameter(name, value); } closeDataStream(); @@ -182,7 +189,7 @@ void RifCaseRealizationParametersReader::closeFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const cvf::ref RifCaseRealizationParametersReader::parameters() const +const std::shared_ptr RifCaseRealizationParametersReader::parameters() const { return m_parameters; } diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h index 56e8a793db..5b2c65da72 100644 --- a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h @@ -30,6 +30,7 @@ #include #include #include +#include class QStringList; class QTextStream; @@ -46,9 +47,9 @@ class RifCaseRealizationParametersReader RifCaseRealizationParametersReader(const QString& fileName); ~RifCaseRealizationParametersReader(); - void setFileName(const QString& fileName); - void parse(); - const cvf::ref parameters() const; + void setFileName(const QString& fileName); + void parse(); + const std::shared_ptr parameters() const; private: QTextStream* openDataStream(); @@ -56,7 +57,7 @@ class RifCaseRealizationParametersReader void openFile(); void closeFile(); private: - cvf::ref m_parameters; + std::shared_ptr m_parameters; QString m_fileName; QFile* m_file; diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 93c5bd76c6..501e1031cf 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -51,7 +51,7 @@ #include "cvfqtUtils.h" #include - +#include CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend"); @@ -153,6 +153,36 @@ RimRegularLegendConfig::~RimRegularLegendConfig() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setNamedCategories(const std::vector& categoryNames, bool inverse) +{ + std::list nameIndices; + std::list names; + + int categoriesCount = static_cast(categoryNames.size()); + for (int i = 0; i < categoriesCount; i++) + { + if (!inverse) + { + nameIndices.push_back(i); + names.push_back(cvfqt::Utils::toString(categoryNames[i])); + } + else + { + nameIndices.push_front(i); + names.push_front(cvfqt::Utils::toString(categoryNames[i])); + } + } + + m_categories = std::vector(nameIndices.begin(), nameIndices.end()); + m_categoryNames = std::vector(names.begin(), names.end()); + m_categoryColors.clear(); + + updateLegend(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -585,21 +615,17 @@ void RimRegularLegendConfig::setIntegerCategories(const std::vector& catego //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimRegularLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) +void RimRegularLegendConfig::setNamedCategories(const std::vector& categoryNames) { - std::vector nameIndices; - std::vector names; - for(int i = static_cast(categoryNames.size()) - 1; i >= 0; --i) - { - nameIndices.push_back(i); - names.push_back(cvfqt::Utils::toString(categoryNames[i])); - } - - m_categories = nameIndices; - m_categoryNames = names; - m_categoryColors.clear(); + setNamedCategories(categoryNames, false); +} - updateLegend(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) +{ + setNamedCategories(categoryNames, true); } //-------------------------------------------------------------------------------------------------- @@ -643,6 +669,21 @@ QString RimRegularLegendConfig::categoryNameFromCategoryValue(double categoryRes return QString("%1").arg(categoryResultValue); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimRegularLegendConfig::categoryValueFromCategoryName(const QString& categoryName) const +{ + for (int i = 0; i < m_categoryNames.size(); i++) + { + if (cvfqt::Utils::toQString(m_categoryNames[i]).compare(categoryName, Qt::CaseInsensitive) == 0) + { + return i; + } + } + return HUGE_VAL; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -795,9 +836,10 @@ QList RimRegularLegendConfig::calculateValueOptions(cons RimCellEdgeColors* eclCellEdgColors = nullptr; this->firstAncestorOrThisOfType(eclCellEdgColors); - if ( ( eclCellColors && eclCellColors->hasCategoryResult()) - || ( gmCellColors && gmCellColors->hasCategoryResult()) - || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult()) ) + if ( ( eclCellColors && eclCellColors->hasCategoryResult()) + || ( gmCellColors && gmCellColors->hasCategoryResult()) + || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult()) + || ( ensembleCurveSet && ensembleCurveSet->currentEnsembleParameterType() == RimEnsembleCurveSet::TYPE_TEXT) ) { isCategoryResult = true; } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 8457a2f5e9..5a0bba03ed 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -102,9 +102,11 @@ class RimRegularLegendConfig : public RimLegendConfig void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero); void setIntegerCategories(const std::vector& categories); + void setNamedCategories(const std::vector& categoryNames); void setNamedCategoriesInverse(const std::vector& categoryNames); void setCategoryItems(const std::vector>& categories); QString categoryNameFromCategoryValue(double categoryResultValue) const; + double categoryValueFromCategoryName(const QString& categoryName) const; void setTitle(const QString& title); @@ -117,6 +119,7 @@ class RimRegularLegendConfig : public RimLegendConfig caf::TitledOverlayFrame* titledOverlayFrame() override; private: + void setNamedCategories(const std::vector& categoryNames, bool inverse); void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void initAfterRead() override; caf::PdmFieldHandle* objectToggleField() override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 75291d47b5..4302640a9c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -336,6 +336,27 @@ RimEnsembleCurveSet::ColorMode RimEnsembleCurveSet::colorMode() const return m_colorMode(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::EnsembleParameterType RimEnsembleCurveSet::currentEnsembleParameterType() const +{ + if (m_colorMode() == BY_ENSEMBLE_PARAM) + { + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + QString parameterName = m_ensembleParameter(); + + if (group && !parameterName.isEmpty() && !group->allSummaryCases().empty()) + { + bool isTextParameter = group->allSummaryCases().front()->caseRealizationParameters() != nullptr ? + group->allSummaryCases().front()->caseRealizationParameters()->parameterValue(parameterName).isText() : false; + + return isTextParameter ? TYPE_TEXT : TYPE_NUMERIC; + } + } + return TYPE_NONE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -367,9 +388,13 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie m_allAddressesCache.clear(); updateAllCurves(); } - else if (changedField == &m_ensembleParameter || - changedField == &m_color) + else if (changedField == &m_color) + { + updateCurveColors(); + } + else if (changedField == &m_ensembleParameter) { + updateLegendMappingMode(); updateCurveColors(); } else if (changedField == &m_colorMode) @@ -615,32 +640,75 @@ void RimEnsembleCurveSet::updateCurveColors() m_legendConfig->setTitle(legendTitle); } - if (group && !parameterName.isEmpty()) + if (group && !parameterName.isEmpty() && !group->allSummaryCases().empty()) { - double minValue = std::numeric_limits::infinity(); - double maxValue = -std::numeric_limits::infinity(); + bool isTextParameter = group->allSummaryCases().front()->caseRealizationParameters() != nullptr ? + group->allSummaryCases().front()->caseRealizationParameters()->parameterValue(parameterName).isText() : false; - for (RimSummaryCase* rimCase : group->allSummaryCases()) + if (isTextParameter) { - if (!rimCase->caseRealizationParameters().isNull()) + std::set categories; + + for (RimSummaryCase* rimCase : group->allSummaryCases()) { - double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - if (value != std::numeric_limits::infinity()) + if (rimCase->caseRealizationParameters() != nullptr) { - if (value < minValue) minValue = value; - if (value > maxValue) maxValue = value; + RigCaseRealizationParameters::Value value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value.isText()) + { + categories.insert(value.textValue()); + } } } - } - m_legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + std::vector categoryNames = std::vector(categories.begin(), categories.end()); + m_legendConfig->setNamedCategories(categoryNames); + m_legendConfig->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1); - for (auto& curve : m_curves) + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + QString tValue = rimCase->caseRealizationParameters()->parameterValue(parameterName).textValue(); + double nValue = m_legendConfig->categoryValueFromCategoryName(tValue); + if (nValue != HUGE_VAL) + { + int iValue = static_cast(nValue); + curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(iValue))); + } + curve->updateCurveAppearance(); + } + } + else { - RimSummaryCase* rimCase = curve->summaryCaseY(); - double value = rimCase->caseRealizationParameters()->parameterValue(parameterName); - curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); - curve->updateCurveAppearance(); + double minValue = std::numeric_limits::infinity(); + double maxValue = -std::numeric_limits::infinity(); + + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (rimCase->caseRealizationParameters() != nullptr) + { + RigCaseRealizationParameters::Value value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value.isNumeric()) + { + double nValue = value.numericValue(); + if (nValue != std::numeric_limits::infinity()) + { + if (nValue < minValue) minValue = nValue; + if (nValue > maxValue) maxValue = nValue; + } + } + } + } + + m_legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + double value = rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue(); + curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); + curve->updateCurveAppearance(); + } } } } @@ -737,7 +805,7 @@ std::vector RimEnsembleCurveSet::ensembleParameters() const { for (RimSummaryCase* rimCase : group->allSummaryCases()) { - if (!rimCase->caseRealizationParameters().isNull()) + if (rimCase->caseRealizationParameters() != nullptr) { auto ps = rimCase->caseRealizationParameters()->parameters(); for (auto p : ps) paramSet.insert(p.first); @@ -768,3 +836,22 @@ QString RimEnsembleCurveSet::createAutoName() const return curveSetName; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateLegendMappingMode() +{ + switch (currentEnsembleParameterType()) + { + case TYPE_TEXT: + if (m_legendConfig->mappingMode() != RimRegularLegendConfig::MappingType::CATEGORY_INTEGER) + m_legendConfig->setMappingMode(RimRegularLegendConfig::MappingType::CATEGORY_INTEGER); + break; + + case TYPE_NUMERIC: + if (m_legendConfig->mappingMode() == RimRegularLegendConfig::MappingType::CATEGORY_INTEGER) + m_legendConfig->setMappingMode(RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS); + break; + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 685791cc39..740f625aff 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -57,6 +57,7 @@ class RimEnsembleCurveSet : public caf::PdmObject public: enum ColorMode {SINGLE_COLOR, BY_ENSEMBLE_PARAM}; + enum EnsembleParameterType {TYPE_NONE, TYPE_NUMERIC, TYPE_TEXT}; RimEnsembleCurveSet(); virtual ~RimEnsembleCurveSet(); @@ -85,6 +86,7 @@ class RimEnsembleCurveSet : public caf::PdmObject RimSummaryCaseCollection* summaryCaseCollection() const; ColorMode colorMode() const; + EnsembleParameterType currentEnsembleParameterType() const; private: caf::PdmFieldHandle* userDescriptionField() override; @@ -113,6 +115,7 @@ class RimEnsembleCurveSet : public caf::PdmObject QString createAutoName() const; + void updateLegendMappingMode(); private: caf::PdmField m_showCurves; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 6e5a8595c6..80a071dc43 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -86,7 +86,7 @@ bool RimSummaryCase::isObservedData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCase::setCaseRealizationParameters(cvf::ref crlParameters) +void RimSummaryCase::setCaseRealizationParameters(const std::shared_ptr& crlParameters) { m_crlParameters = crlParameters; } @@ -94,7 +94,7 @@ void RimSummaryCase::setCaseRealizationParameters(cvf::ref RimSummaryCase::caseRealizationParameters() const +std::shared_ptr RimSummaryCase::caseRealizationParameters() const { return m_crlParameters; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index 80d08e83cf..ebb7c191cd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -22,6 +22,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include + class RifSummaryReaderInterface; //================================================================================================== @@ -54,8 +56,8 @@ class RimSummaryCase : public caf::PdmObject bool isObservedData(); - void setCaseRealizationParameters(cvf::ref crlParameters); - cvf::ref caseRealizationParameters() const; + void setCaseRealizationParameters(const std::shared_ptr& crlParameters); + std::shared_ptr caseRealizationParameters() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -66,7 +68,7 @@ class RimSummaryCase : public caf::PdmObject caf::PdmField m_summaryHeaderFilename; bool m_isObservedData; - cvf::ref m_crlParameters; + std::shared_ptr m_crlParameters; private: virtual void initAfterRead() override; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp index 558a1e50ba..9c24814311 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp @@ -19,18 +19,84 @@ #include "RigCaseRealizationParameters.h" #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value() : m_valueType(TYPE_NONE), m_numericValue(HUGE_VAL) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value(double value) : Value() +{ + setValue(value); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value(const QString& value) : Value() +{ + setValue(value); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::Value::setValue(double value) +{ + m_valueType = TYPE_NUMERIC; + m_numericValue = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::Value::setValue(const QString& value) +{ + m_valueType = TYPE_TEXT; + m_textValue = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCaseRealizationParameters::Value::numericValue() const +{ + return m_numericValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RigCaseRealizationParameters::Value::textValue() const +{ + return m_textValue; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RigCaseRealizationParameters::addParameter(const QString& name, double value) { - m_parameters[name] = value; + m_parameters[name].setValue(value); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::addParameter(const QString& name, const QString& value) +{ + m_parameters[name].setValue(value); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RigCaseRealizationParameters::parameterValue(const QString& name) +RigCaseRealizationParameters::Value RigCaseRealizationParameters::parameterValue(const QString& name) { if (m_parameters.count(name) == 0) return HUGE_VAL; return m_parameters[name]; @@ -39,7 +105,7 @@ double RigCaseRealizationParameters::parameterValue(const QString& name) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map RigCaseRealizationParameters::parameters() const +std::map RigCaseRealizationParameters::parameters() const { return m_parameters; } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h index 801458e04b..0ad579281a 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h @@ -31,14 +31,41 @@ // // //================================================================================================== -class RigCaseRealizationParameters : public cvf::Object +class RigCaseRealizationParameters { public: + // Internal class + class Value + { + enum ValueType { TYPE_NONE, TYPE_NUMERIC, TYPE_TEXT }; + + public: + Value(); + Value(double value); + Value(const QString& value); + + void setValue(double value); + void setValue(const QString& value); + + bool isEmpty() const { return m_valueType == TYPE_NONE; } + bool isNumeric() const { return m_valueType == TYPE_NUMERIC; } + bool isText() const { return m_valueType == TYPE_TEXT; } + + double numericValue() const; + const QString& textValue() const; + + private: + ValueType m_valueType; + double m_numericValue; + QString m_textValue; + }; + void addParameter(const QString& name, double value); - double parameterValue(const QString& name); + void addParameter(const QString& name, const QString& value); + Value parameterValue(const QString& name); - std::map parameters() const; + std::map parameters() const; private: - std::map m_parameters; + std::map m_parameters; }; diff --git a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp index 4d447ff60c..0f004f0a3d 100644 --- a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp +++ b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp @@ -42,16 +42,20 @@ TEST(RifCaseRealizationParametersReaderTest, SuccessfulParsing) { reader.parse(); - const cvf::ref parameters = reader.parameters(); - std::map params = parameters->parameters(); + const std::shared_ptr parameters(reader.parameters()); + std::map params = parameters->parameters(); EXPECT_EQ(1U, params.count("LETSWOF:L_1OW")); EXPECT_EQ(1U, params.count("LETSGOF:KRG1")); EXPECT_EQ(1U, params.count("LOG10_MULTFLT:MULTFLT_F1")); - - EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"]); - EXPECT_EQ(0.97, params["LETSGOF:KRG1"]); - EXPECT_EQ(-0.168356, params["LOG10_MULTFLT:MULTFLT_F1"]); + EXPECT_EQ(1U, params.count("TST:TEXT_PARAM")); + + EXPECT_TRUE(params["LETSWOF:L_1OW"].isNumeric()); + EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"].numericValue()); + EXPECT_TRUE(params["LETSGOF:KRG1"].isNumeric()); + EXPECT_EQ(0.97, params["LETSGOF:KRG1"].numericValue()); + EXPECT_TRUE(params["TST:TEXT_PARAM"].isText()); + EXPECT_EQ(std::string("YES"), params["TST:TEXT_PARAM"].textValue().toStdString()); } catch (...) { diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt index c7f910e6df..a98fe50a12 100644 --- a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt +++ b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt @@ -26,4 +26,5 @@ LETSGOF:L_1OG 3.90509 LETSGOF:E_1OG 4.00383 LETSGOF:T_1OG 1.03539 LETSGOF:SORG1 0.34 +TST:TEXT_PARAM YES LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index 4ba0ae163a..45028c5fc1 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -76,7 +76,7 @@ void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); viewer->resize(width, height); - + // Create a rendering cvf::ref rendering = new cvf::Rendering; From 2f80e99abc5fca2ad84f3aff8a9a9d0668ebca04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 3 May 2018 09:53:54 +0200 Subject: [PATCH 0848/1027] #2829 Add overall handling of std::bad_alloc exception with a message box. Now the user can know what is happening, and possibly save his work. On linux this will only work sometimes unless sysctl vm.overcommit_memory = 2 --- .../Application/RiaApplication.cpp | 34 +++++++++++++++++++ ApplicationCode/Application/RiaApplication.h | 2 ++ ApplicationCode/Application/RiaMain.cpp | 17 +++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 2f208c4974..83ed4cddc4 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -134,6 +134,40 @@ void AppEnum< RiaApplication::RINavigationPolicy >::setUp() //================================================================================================== +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaApplication::notify(QObject* receiver, QEvent* event) +{ + // Pre-allocating a memory exhaustion message + // Doing som e trickery to avoid deadlock, as creating a messagebox actually triggers a call to this notify method. + + static QMessageBox* memoryExhaustedBox = nullptr; + static bool allocatingMessageBox = false; + if (!memoryExhaustedBox && !allocatingMessageBox) + { + allocatingMessageBox = true; + memoryExhaustedBox = new QMessageBox(QMessageBox::Critical, + "ResInsight Exhausted Memory", + "Memory is Exhausted!\n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon."); + } + + bool done = true; + try + { + done = QApplication::notify(receiver, event); + } + catch ( const std::bad_alloc& ) + { + if (memoryExhaustedBox) memoryExhaustedBox->exec(); + std::cout << "ResInsight: Memory is Exhausted!\n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon." << std::endl; + // If we really want to crash instead of limping forward: + // throw; + } + + return done; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index a5e611bc9b..f920cadfcd 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -216,6 +216,8 @@ class RiaApplication : public QApplication friend RiaArgumentParser; void setHelpText(const QString& helpText); + virtual bool notify(QObject *, QEvent *) override; + private slots: void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); diff --git a/ApplicationCode/Application/RiaMain.cpp b/ApplicationCode/Application/RiaMain.cpp index 0e6e55a784..0332149550 100644 --- a/ApplicationCode/Application/RiaMain.cpp +++ b/ApplicationCode/Application/RiaMain.cpp @@ -49,7 +49,22 @@ int main(int argc, char *argv[]) RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel())); RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG); - int exitCode = app.exec(); + int exitCode = 0; + try + { + exitCode = app.exec(); + } + catch (std::exception& exep ) + { + std::cout << "A standard c++ exception that terminated ResInsight caught in RiaMain.cpp: " << exep.what() << std::endl; + throw; + } + catch(...) + { + std::cout << "An unknown exception that terminated ResInsight caught in RiaMain.cpp. " << std::endl; + throw; + } + RiaLogging::deleteLoggerInstance(); return exitCode; From 8b6c226f5bc309c9b5e0193867c284474d9b925d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 3 May 2018 09:55:08 +0200 Subject: [PATCH 0849/1027] #2843 Fix missing 2d intersection view name updates --- .../ProjectDataModel/Rim2dIntersectionView.cpp | 18 ++++++++++++++---- .../ProjectDataModel/Rim2dIntersectionView.h | 1 + .../ProjectDataModel/RimIntersection.cpp | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 8629f6f81b..7508c16ae2 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -116,11 +116,8 @@ void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) CAF_ASSERT(intersection); m_intersection = intersection; - Rim3dView * parentView = nullptr; - intersection->firstAncestorOrThisOfTypeAsserted(parentView); - name = parentView->name() + ": " + intersection->name(); - + this->updateName(); } //-------------------------------------------------------------------------------------------------- @@ -296,6 +293,19 @@ void Rim2dIntersectionView::update3dInfo() m_viewer->update(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateName() +{ + if ( m_intersection ) + { + Rim3dView * parentView = nullptr; + m_intersection->firstAncestorOrThisOfTypeAsserted(parentView); + name = parentView->name() + ": " + m_intersection->name(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 5a0e29da22..7a06559d66 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -61,6 +61,7 @@ class Rim2dIntersectionView : public Rim3dView virtual bool isTimeStepDependentDataVisible() const override; void update3dInfo(); + void updateName(); cvf::ref flatIntersectionPartMgr() const; cvf::Vec3d transformToUtm(const cvf::Vec3d& unscaledPointInFlatDomain) const; diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 116d1dd608..07688ccf98 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -165,6 +165,16 @@ void RimIntersection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateName(); } + if (changedField == &name) + { + Rim2dIntersectionView* iView = correspondingIntersectionView(); + if (iView) + { + iView->updateName(); + iView->updateConnectedEditors(); + } + } + if (changedField == &inputPolyLineFromViewerEnabled || changedField == &m_userPolyline) { @@ -612,6 +622,12 @@ void RimIntersection::updateName() name = wellPath()->name(); } + Rim2dIntersectionView* iView = correspondingIntersectionView(); + if (iView) + { + iView->updateName(); + iView->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- From dd23fa2eade512c449df24d9331f89179e2b8218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 11:03:43 +0200 Subject: [PATCH 0850/1027] #2844 Ensemble curve set. Show only relevant color modes. Use gray curves for cases without emsemble params --- .../Summary/RimEnsembleCurveSet.cpp | 29 +++++++++++++++---- .../Summary/RimSummaryCase.cpp | 8 +++++ .../ProjectDataModel/Summary/RimSummaryCase.h | 1 + .../Summary/RimSummaryPlotNameHelper.cpp | 2 +- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 4302640a9c..f2fc01fb3b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -539,9 +539,19 @@ QList RimEnsembleCurveSet::calculateValueOptions(const c options.push_front(caf::PdmOptionItemInfo("None", nullptr)); } - else if (fieldNeedingOptions == &m_ensembleParameter) + else if (fieldNeedingOptions == &m_colorMode) { + auto singleColorOption = caf::AppEnum(RimEnsembleCurveSet::SINGLE_COLOR); + auto byEnsParamOption = caf::AppEnum(RimEnsembleCurveSet::BY_ENSEMBLE_PARAM); + options.push_back(caf::PdmOptionItemInfo(singleColorOption.uiText(), RimEnsembleCurveSet::SINGLE_COLOR)); + if (!ensembleParameters().empty()) + { + options.push_back(caf::PdmOptionItemInfo(byEnsParamOption.uiText(), RimEnsembleCurveSet::BY_ENSEMBLE_PARAM)); + } + } + else if (fieldNeedingOptions == &m_ensembleParameter) + { for (auto param : ensembleParameters()) { options.push_back(caf::PdmOptionItemInfo(param, param)); @@ -668,13 +678,19 @@ void RimEnsembleCurveSet::updateCurveColors() for (auto& curve : m_curves) { RimSummaryCase* rimCase = curve->summaryCaseY(); - QString tValue = rimCase->caseRealizationParameters()->parameterValue(parameterName).textValue(); + QString tValue = rimCase->hasCaseRealizationParameters() ? + rimCase->caseRealizationParameters()->parameterValue(parameterName).textValue() : + ""; double nValue = m_legendConfig->categoryValueFromCategoryName(tValue); if (nValue != HUGE_VAL) { int iValue = static_cast(nValue); curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(iValue))); } + else + { + curve->setColor(cvf::Color3f::GRAY); + } curve->updateCurveAppearance(); } } @@ -705,8 +721,11 @@ void RimEnsembleCurveSet::updateCurveColors() for (auto& curve : m_curves) { RimSummaryCase* rimCase = curve->summaryCaseY(); - double value = rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue(); - curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); + double value = rimCase->hasCaseRealizationParameters() ? + rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue() : + HUGE_VAL; + if(value != HUGE_VAL) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); + else curve->setColor(cvf::Color3f::GRAY); curve->updateCurveAppearance(); } } @@ -725,7 +744,7 @@ void RimEnsembleCurveSet::updateCurveColors() firstAncestorOrThisOfType(plot); if (plot && plot->qwtPlot()) { - if (isCurvesVisible() && m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) + if (m_yValuesSummaryGroup() && isCurvesVisible() && m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) { plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 80a071dc43..ca1235e26f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -99,6 +99,14 @@ std::shared_ptr RimSummaryCase::caseRealizationPar return m_crlParameters; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCase::hasCaseRealizationParameters() const +{ + return m_crlParameters != nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index ebb7c191cd..3beaf41cf5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -58,6 +58,7 @@ class RimSummaryCase : public caf::PdmObject void setCaseRealizationParameters(const std::shared_ptr& crlParameters); std::shared_ptr caseRealizationParameters() const; + bool hasCaseRealizationParameters() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index e553e3bf8a..5d97cc4d91 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -76,7 +76,7 @@ void RimSummaryPlotNameHelper::appendEnsembleCases(const std::vector Date: Thu, 3 May 2018 11:50:19 +0200 Subject: [PATCH 0851/1027] #2844 Ensemble curve set. Fix HUGE_VAL -> numerical_limits --- .../Summary/RimEnsembleCurveSet.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index f2fc01fb3b..c7e665e34d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -54,6 +54,11 @@ namespace caf } } +//-------------------------------------------------------------------------------------------------- +/// Internal constants +//-------------------------------------------------------------------------------------------------- +#define DOUBLE_INF std::numeric_limits::infinity() + CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet"); @@ -682,7 +687,7 @@ void RimEnsembleCurveSet::updateCurveColors() rimCase->caseRealizationParameters()->parameterValue(parameterName).textValue() : ""; double nValue = m_legendConfig->categoryValueFromCategoryName(tValue); - if (nValue != HUGE_VAL) + if (nValue != DOUBLE_INF) { int iValue = static_cast(nValue); curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(iValue))); @@ -696,8 +701,8 @@ void RimEnsembleCurveSet::updateCurveColors() } else { - double minValue = std::numeric_limits::infinity(); - double maxValue = -std::numeric_limits::infinity(); + double minValue = DOUBLE_INF; + double maxValue = -DOUBLE_INF; for (RimSummaryCase* rimCase : group->allSummaryCases()) { @@ -707,7 +712,7 @@ void RimEnsembleCurveSet::updateCurveColors() if (value.isNumeric()) { double nValue = value.numericValue(); - if (nValue != std::numeric_limits::infinity()) + if (nValue != DOUBLE_INF) { if (nValue < minValue) minValue = nValue; if (nValue > maxValue) maxValue = nValue; @@ -723,9 +728,9 @@ void RimEnsembleCurveSet::updateCurveColors() RimSummaryCase* rimCase = curve->summaryCaseY(); double value = rimCase->hasCaseRealizationParameters() ? rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue() : - HUGE_VAL; - if(value != HUGE_VAL) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); - else curve->setColor(cvf::Color3f::GRAY); + DOUBLE_INF; + if(value != DOUBLE_INF) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); + else curve->setColor(cvf::Color3f::GRAY); curve->updateCurveAppearance(); } } From 9150981e133c89e2468eb4de3af9f702938fc824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 12:05:28 +0200 Subject: [PATCH 0852/1027] #2842 Ensemble curve set. Update referring curve sets when adding or removing cases from an ensemble --- .../Summary/RimEnsembleCurveSet.h | 3 ++- .../Summary/RimSummaryCaseCollection.cpp | 20 +++++++++++++++++++ .../Summary/RimSummaryCaseCollection.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 740f625aff..9c905abf14 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -88,6 +88,8 @@ class RimEnsembleCurveSet : public caf::PdmObject ColorMode colorMode() const; EnsembleParameterType currentEnsembleParameterType() const; + void updateAllCurves(); + private: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField(); @@ -110,7 +112,6 @@ class RimEnsembleCurveSet : public caf::PdmObject void updateCurveColors(); void updateQwtPlotAxis(); - void updateAllCurves(); std::vector ensembleParameters() const; QString createAutoName() const; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 90d6e63f5e..beedbe85b7 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -19,6 +19,7 @@ #include "RimSummaryCaseCollection.h" #include "RimGridSummaryCase.h" +#include "RimEnsembleCurveSet.h" #include "RimProject.h" #include "RimSummaryCase.h" @@ -43,6 +44,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() RimSummaryCaseCollection::~RimSummaryCaseCollection() { m_cases.deleteAllChildObjects(); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- @@ -51,6 +53,7 @@ RimSummaryCaseCollection::~RimSummaryCaseCollection() void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase) { m_cases.removeChildObject(summaryCase); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- @@ -59,6 +62,7 @@ void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase) void RimSummaryCaseCollection::addCase(RimSummaryCase* summaryCase) { m_cases.push_back(summaryCase); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- @@ -92,3 +96,19 @@ caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() { return &m_name; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::updateReferringCurveSets() const +{ + // Update curve set referring to this group + std::vector referringObjects; + objectsWithReferringPtrFields(referringObjects); + + for (PdmObjectHandle* obj : referringObjects) + { + RimEnsembleCurveSet* curveSet = dynamic_cast(obj); + if (curveSet) curveSet->updateAllCurves(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 8881db1d3b..efb9500549 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -42,6 +42,7 @@ class RimSummaryCaseCollection : public caf::PdmObject private: caf::PdmFieldHandle* userDescriptionField() override; + void updateReferringCurveSets() const; private: caf::PdmChildArrayField m_cases; From ccd0c0d9f96a34d2a2eb285b8abc8f372995a26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 12:46:15 +0200 Subject: [PATCH 0853/1027] #2836 Hierarchy import dialog. Insert * in effective filter when path filter is empty --- ApplicationCode/Commands/RicFileHierarchyDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp index bdc9ea4c62..f4dbe65eb9 100644 --- a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -602,7 +602,7 @@ void RicFileHierarchyDialog::updateEffectiveFilter() { QString effFilter = QString("%1/%2/%3%4") .arg(m_rootDir->text()) - .arg(m_pathFilter->text()) + .arg(!m_pathFilter->text().isEmpty() ? m_pathFilter->text() : "*") .arg(fileNameFilter()) .arg(fileExtensionsText()); From 58f99a848ead03f17be659b769eca6f0f6357dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 3 May 2018 13:35:40 +0200 Subject: [PATCH 0854/1027] #2802 Summary cases import. Display progress info during summary cases creation as well --- .../Commands/RicImportSummaryCasesFeature.cpp | 4 +++- .../Summary/RimSummaryCaseMainCollection.cpp | 11 ++++++++++- .../Summary/RimSummaryCaseMainCollection.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 4e4d717d50..8f6f60ffac 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -39,6 +39,8 @@ #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" +#include "cafProgressInfo.h" + #include #include #include @@ -128,7 +130,7 @@ bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList if (!importFileInfos.empty()) { - std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos); + std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos, true); if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 8ed1c9bd30..b5dbb4186e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -325,11 +325,18 @@ std::vector RimSummaryCaseMainCollection::createAndAddSummaryCa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) +std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos, + bool showProgress) { RimProject* project = RiaApplication::instance()->project(); std::vector sumCases; + std::unique_ptr progress; + + if (showProgress) + { + progress.reset(new caf::ProgressInfo(summaryHeaderFileInfos.size(), "Creating summary cases")); + } for (RifSummaryCaseFileResultInfo fileInfo : summaryHeaderFileInfos) { @@ -362,6 +369,8 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro addCaseRealizationParametersIfFound(*newSumCase, fileInfo.summaryFileName()); sumCases.push_back(newSumCase); } + + if (progress != nullptr) progress->incrementProgress(); } return sumCases; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index a3ef6d3bda..2bf970ac4d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -46,7 +46,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void createSummaryCasesFromRelevantEclipseResultCases(); std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); - std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos, bool showProgress = false); RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; From 944baee00e767e9ffcb0b54260279cecf2db0ba3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 14:52:07 +0200 Subject: [PATCH 0855/1027] Fix comment in DrawSurfaceGenerator --- .../ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 072e6a906c..725a27671b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -102,7 +102,7 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans // Create curve normal vectors using the unclipped well path points and normals. createCurveNormalVectors(displayCoordTransform, indexToFirstVisibleSegment, planeOffsetFromWellPathCenter, planeWidth, samplingIntervalSize, wellPathSegmentNormals); - // Note that normals are calculated on the full non-clipped well path. So we need to clip the remainder here. + // Note that normals are calculated on the full non-clipped well path. So we need to clip the start here. wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); if (wellPathPoints.size() < (size_t)2) From f6cbf0f34fabab97c830e94ddfb14bab4e367aba Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 3 May 2018 10:08:24 +0200 Subject: [PATCH 0856/1027] #2824 Geomech 3d Well Log Curves: update UI and 3d view when user changes settings --- .../RimGeoMechResultDefinition.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 7da009b301..c8b2d20710 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -28,6 +28,8 @@ #include "RigFemPartGrid.h" #include "RiaDefines.h" + +#include "Rim3dWellLogCurve.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilter.h" @@ -262,6 +264,9 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha this->firstAncestorOrThisOfType(view); RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + if (&m_resultVariableUiField == changedField || &m_compactionRefLayerUiField == changedField) { @@ -330,6 +335,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha { curve->loadDataAndUpdate(true); } + + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->updateCurveIn3dView(); + } } } @@ -342,6 +352,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha { curve->updateConnectedEditors(); } + + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI(); + } } //-------------------------------------------------------------------------------------------------- From a1651727232a72fdfd13bac65db72494eaae3b52 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 2 May 2018 14:51:53 +0200 Subject: [PATCH 0857/1027] #2847 Add a fall back dominant direction (0, -1, 0) if the path does not extrude in z-direction. * This direction means Left will cause it to go -x and Right +x so that the directions are correct with respect to "Left" and "Right" when you look "North". --- .../ReservoirDataModel/RigWellPathGeometryTools.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp index f7e1fcff60..bdd4b033b4 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -139,5 +139,11 @@ cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const st } directionSum += vec; } + + if (directionSum.length() < 1.0e-8) + { + directionSum = cvf::Vec3d(0, -1, 0); + } + return directionSum.getNormalized(); } From 23c90bd6eb24f756e6a7cd46b5e50d990680c430 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 3 May 2018 09:24:23 +0200 Subject: [PATCH 0858/1027] #2846 Fix bad curve projection * Project existing points onto triangles first and make sure we choose the right triangle by sorting possible projections by distance. * Also allow some tolerance for the inside check. * Create the new vertices by projecting the curve segment vector onto each triangle plane before looking for intersections with the triangle edges. --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 70 +++++++++++++------ 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 197fb4f429..5acd335c6a 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -152,8 +152,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveVertices.push_back(cvf::Vec3f(curvePoint)); } - createNewVerticesAlongTriangleEdges(drawSurfaceVertices); projectVerticesOntoTriangles(drawSurfaceVertices); + createNewVerticesAlongTriangleEdges(drawSurfaceVertices); std::vector indices; @@ -266,34 +266,42 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) { - expandedCurveVertices.push_back(m_curveVertices[i]); + caf::Line fullSegmentLine(m_curveVertices[i], m_curveVertices[i + 1]); + cvf::Vec3f fullSegmentVector = fullSegmentLine.vector(); + cvf::Vec3f lastVertex = m_curveVertices[i]; + expandedCurveVertices.push_back(lastVertex); expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); expandedValues.push_back(m_curveValues[i]); - // Find segments that intersects the triangle edge - caf::Line curveLine(m_curveVertices[i], m_curveVertices[i + 1]); - - for (size_t j = 0; j < drawSurfaceVertices.size() - 1; ++j) + // Find segments that intersects the triangle edges + for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { - caf::Line drawSurfaceLine(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); + cvf::Vec3f currentSubSegment = m_curveVertices[i + 1] - lastVertex; + caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); + caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); + cvf::Vec3f triangleNormal = (triangleEdge1.vector().getNormalized() ^ triangleEdge2.vector().getNormalized()).getNormalized(); + cvf::Vec3f projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; + caf::Line projectedCurveLine (lastVertex, lastVertex + projectedSegmentVector); + + // Only attempt to find intersections with the first edge. The other edge is handled with the next triangle. bool withinSegments = false; - caf::Line connectingLine = curveLine.findLineBetweenNearestPoints(drawSurfaceLine, &withinSegments); - + caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); if (withinSegments) { - cvf::Vec3f closestDrawSurfacePoint = connectingLine.end(); - double measuredDepth; - double valueAtPoint; - cvf::Vec3d closestPoint(closestDrawSurfacePoint); - cvf::Vec3d dummyArgument; - // Interpolate measured depth and value - bool worked = findClosestPointOnCurve(closestPoint, &dummyArgument, &measuredDepth, &valueAtPoint); - if (worked) + cvf::Vec3f newVertex = connectingLine.end(); + + cvf::Vec3f newSegmentVector = newVertex - lastVertex; + if (newSegmentVector.lengthSquared() < fullSegmentVector.lengthSquared()) { - expandedCurveVertices.push_back(closestDrawSurfacePoint); + expandedCurveVertices.push_back(newVertex); + // Scalar projection (a * b / |b|) divided by full segment length to become (a * b / |b|^2) + float dotProduct = newSegmentVector * fullSegmentVector; + float fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); + float measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; + float valueAtPoint = m_curveValues[i] * (1 - fractionAlongFullSegment) + m_curveValues[i + 1] * fractionAlongFullSegment; expandedMeasuredDepths.push_back(measuredDepth); expandedValues.push_back(valueAtPoint); + lastVertex = newVertex; } - } } @@ -316,6 +324,8 @@ void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std: { for (size_t i = 0; i < m_curveVertices.size(); ++i) { + // Sort projections onto triangle by the distance of the projection. + std::map projectionsInsideTriangle; for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { cvf::Vec3f triangleVertex1, triangleVertex2, triangleVertex3; @@ -337,9 +347,16 @@ void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std: m_curveVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); if (wasInsideTriangle) { - m_curveVertices[i] = projectedPoint; + projectionsInsideTriangle.insert(std::make_pair((projectedPoint - m_curveVertices[i]).lengthSquared(), + projectedPoint)); } } + + // Take the closest projection + if (!projectionsInsideTriangle.empty()) + { + m_curveVertices[i] = projectionsInsideTriangle.begin()->second; + } } } @@ -359,8 +376,9 @@ cvf::Vec3f Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cv // Project vertex onto triangle plane cvf::Vec3f av = point - triangleVertex1; - cvf::Vec3f projectedPoint = point - (av * n) * n; - + cvf::Vec3f projectedAv = av - (av * n) * n; + cvf::Vec3f projectedPoint = projectedAv + triangleVertex1; + // Calculate barycentric coordinates float areaABC = n * (e1 ^ e2); float areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); @@ -369,9 +387,15 @@ cvf::Vec3f Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cv float v = areaPCA / areaABC; float w = 1.0 - u - v; - if (u >= 0.0 && v >= 0.0 && w >= 0.0) + if (u >= -1.0e-6 && v >= -1.0e-6 && w >= -1.0e-6) { *wasInsideTriangle = true; + // Clamp to ensure it is inside the triangle + u = cvf::Math::clamp(u, 0.0f, 1.0f); + v = cvf::Math::clamp(v, 0.0f, 1.0f); + w = cvf::Math::clamp(w, 0.0f, 1.0f); + projectedPoint = triangleVertex1 * u + triangleVertex2 * v + triangleVertex3 * w; + } return projectedPoint; } From a22f8ed0325a85fc34fc4ca27f6dac594f46cee2 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 3 May 2018 10:14:12 +0200 Subject: [PATCH 0859/1027] Remove superfluous updateConnectedEditor for rim3dWellLogCurves. * Already happens in resetMinMaxValuesAndUpdateUI --- ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index e92be876d5..0c0be159a1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -343,7 +343,6 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() if (rim3dWellLogCurve) { rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI(); - rim3dWellLogCurve->updateConnectedEditors(); } } From b21e6414f9b858c15fb2e21905d579439c9df7bc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 3 May 2018 07:58:47 +0200 Subject: [PATCH 0860/1027] #2845 Ensemble Curve Set Legend : Add name --- .../Summary/RimEnsembleCurveSet.cpp | 18 ++++++++++++++++++ .../Summary/RimEnsembleCurveSet.h | 1 + 2 files changed, 19 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index c7e665e34d..13909f33fa 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -839,6 +839,24 @@ std::vector RimEnsembleCurveSet::ensembleParameters() const return std::vector(paramSet.begin(), paramSet.end()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEnsembleCurveSet::name() const +{ + QString curveSetName; + if (m_isUsingAutoName) + { + curveSetName = m_autoGeneratedName(); + } + else + { + curveSetName += m_userDefinedName(); + } + + return curveSetName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 9c905abf14..84f5afab4c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -114,6 +114,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void updateQwtPlotAxis(); std::vector ensembleParameters() const; + QString name() const; QString createAutoName() const; void updateLegendMappingMode(); From c5cd8b2a4be5f971f6ea21087555a228cc2ac4a8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 3 May 2018 08:05:41 +0200 Subject: [PATCH 0861/1027] Do not plot ensemble curve set legend --- .../ProjectDataModel/RimPlotCurve.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 95738dd12f..1efdeca913 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -588,19 +588,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() this->firstAncestorOrThisOfType(ensembleCurveSet); if (ensembleCurveSet) { - auto firstCurve = ensembleCurveSet->firstCurve(); - if (firstCurve != this) - { - // Hide legend display for curves other than the first - showLegendInQwt = false; - } - else - { - if (ensembleCurveSet->colorMode() == RimEnsembleCurveSet::BY_ENSEMBLE_PARAM) - { - showLegendInQwt = false; - } - } + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); } else { @@ -615,7 +603,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() showLegendInQwt = false; } } + + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } - - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } From 4b6bd3d9fcd4a753d63c172bef2cb3a721b44788 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 3 May 2018 14:50:35 +0200 Subject: [PATCH 0862/1027] #2845 Ensemble Curve Set Legend : Update ensemble legend item text Use special symbol for curve color by parameter --- .../ProjectDataModel/RimPlotCurve.cpp | 24 +++--- .../Summary/RimEnsembleCurveSet.cpp | 86 +++++++++++++++---- .../Summary/RimEnsembleCurveSet.h | 4 +- .../Summary/RimSummaryPlot.cpp | 11 +-- 4 files changed, 87 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 1efdeca913..968c96703d 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -582,28 +582,26 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { - bool showLegendInQwt = m_showLegend(); - RimEnsembleCurveSet* ensembleCurveSet = nullptr; this->firstAncestorOrThisOfType(ensembleCurveSet); if (ensembleCurveSet) { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); + return; } - else + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfType(summaryPlot); + + if (summaryPlot) { - RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfType(summaryPlot); + bool showLegendInQwt = m_showLegend(); - if (summaryPlot) + if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) { - if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) - { - // Disable display of legend if the summary plot has only one single curve - showLegendInQwt = false; - } + // Disable display of legend if the summary plot has only one single curve + showLegendInQwt = false; } - + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 13909f33fa..83ce3d7f8b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -42,6 +42,9 @@ #include "cvfScalarMapper.h" +#include "qwt_plot_curve.h" +#include "qwt_symbol.h" + namespace caf { @@ -133,6 +136,9 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_summaryAddressNameTools.uiCapability()->setUiTreeChildrenHidden(true); m_summaryAddressNameTools = new RimSummaryCurveAutoName; + + m_qwtPlotCurveForLegendText = new QwtPlotCurve; + m_qwtPlotCurveForLegendText->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true); } //-------------------------------------------------------------------------------------------------- @@ -180,6 +186,12 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) for (RimSummaryCurve* curve : m_curves) { curve->loadDataAndUpdate(false); + + if (curve->qwtPlotCurve()) + { + curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); + } + curve->updateQwtPlotAxis(); } @@ -208,6 +220,8 @@ void RimEnsembleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) { curve->setParentQwtPlotNoReplot(plot); } + + m_qwtPlotCurveForLegendText->attach(plot); } //-------------------------------------------------------------------------------------------------- @@ -219,6 +233,8 @@ void RimEnsembleCurveSet::detachQwtCurves() { curve->detachQwtCurve(); } + + m_qwtPlotCurveForLegendText->detach(); } //-------------------------------------------------------------------------------------------------- @@ -283,16 +299,6 @@ std::vector RimEnsembleCurveSet::visibleCurves() const return visible; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCurve* RimEnsembleCurveSet::firstCurve() const -{ - if (!curves().empty()) return curves().front(); - - return nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -424,10 +430,25 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { m_userDefinedName = createAutoName(); } + + if (changedField == &m_isUsingAutoName || + changedField == &m_userDefinedName || + changedField == &m_colorMode || + changedField == &m_color) + { + updateEnsembleLegendItem(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + if (summaryPlot->qwtPlot()) + { + summaryPlot->qwtPlot()->updateLegend(); + } + } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -759,11 +780,6 @@ void RimEnsembleCurveSet::updateCurveColors() } plot->qwtPlot()->replot(); } - - if (firstCurve()) - { - firstCurve()->updateLegendEntryVisibilityAndPlotLegend(); - } } //-------------------------------------------------------------------------------------------------- @@ -804,6 +820,11 @@ void RimEnsembleCurveSet::updateAllCurves() curve->updateCurveVisibility(true); curve->loadDataAndUpdate(true); + + if (curve->qwtPlotCurve()) + { + curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); + } } RimSummaryPlot* plot; @@ -817,6 +838,39 @@ void RimEnsembleCurveSet::updateAllCurves() updateCurveColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateEnsembleLegendItem() +{ + m_qwtPlotCurveForLegendText->setTitle(name()); + + { + QwtSymbol* symbol = nullptr; + + if (m_colorMode == SINGLE_COLOR) + { + symbol = new QwtSymbol(QwtSymbol::HLine); + + QColor curveColor(m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte()); + QPen curvePen(curveColor); + curvePen.setWidth(2); + + symbol->setPen(curvePen); + } + else if (m_colorMode == BY_ENSEMBLE_PARAM) + { + symbol = new QwtSymbol(QwtSymbol::Star1); + } + + symbol->setSize(6, 6); + m_qwtPlotCurveForLegendText->setSymbol(symbol); + } + + bool showLegendItem = isCurvesVisible(); + m_qwtPlotCurveForLegendText->setItemAttribute(QwtPlotItem::Legend, showLegendItem); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 84f5afab4c..28fb9ebd9c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -75,7 +75,6 @@ class RimEnsembleCurveSet : public caf::PdmObject RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; std::vector visibleCurves() const; - RimSummaryCurve* firstCurve() const; void deleteAllCurves(); @@ -86,6 +85,7 @@ class RimEnsembleCurveSet : public caf::PdmObject RimSummaryCaseCollection* summaryCaseCollection() const; ColorMode colorMode() const; + void updateEnsembleLegendItem(); EnsembleParameterType currentEnsembleParameterType() const; void updateAllCurves(); @@ -146,5 +146,7 @@ class RimEnsembleCurveSet : public caf::PdmObject caf::PdmChildField m_summaryAddressNameTools; std::set m_allAddressesCache; + + QwtPlotCurve* m_qwtPlotCurveForLegendText; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index b21d15a69e..bf98095889 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -506,10 +506,10 @@ void RimSummaryPlot::updatePlotTitle() if (m_useAutoPlotTitle) { m_userDefinedPlotTitle = generatePlotTitle(m_nameHelper.get()); - - updateCurveNames(); } + updateCurveNames(); + updateMdiWindowTitle(); } @@ -1519,12 +1519,7 @@ void RimSummaryPlot::updateCurveNames() for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) { - if (curveSet->isCurvesVisible() && curveSet->firstCurve()) - { - // Only the first curve in the set is used in the legend, - // skip update of other curves - curveSet->firstCurve()->updateCurveNameNoLegendUpdate(); - } + curveSet->updateEnsembleLegendItem(); } } From c400223bc6897ae084c8d7c26d613e9ffafba291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 3 May 2018 16:15:31 +0200 Subject: [PATCH 0863/1027] #2848 Add a resize in OverlayItem Widget to tighten the widget to the possibly resized overly item --- ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index 45028c5fc1..f5a8abffc4 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -128,6 +128,7 @@ void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) m_overlayItemLabel->setPixmap(pixmap); this->setMinimumSize(QSize(width, height)); + this->resize(QSize(width, height)); } From 25dc96fb3bf4ea4b8f098de8c3fcd20316f42ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 4 May 2018 13:06:48 +0200 Subject: [PATCH 0864/1027] #2721 Ensemble curves. Color ranges, cyclic color range assignment. Minor refactoring --- .../RimRegularLegendConfig.cpp | 73 ++++++++++----- .../ProjectDataModel/RimRegularLegendConfig.h | 11 ++- .../Summary/CMakeLists_files.cmake | 2 + .../Summary/RimEnsembleCurveSet.cpp | 19 ++-- .../RimEnsembleCurveSetColorManager.cpp | 89 +++++++++++++++++++ .../Summary/RimEnsembleCurveSetColorManager.h | 54 +++++++++++ 6 files changed, 220 insertions(+), 28 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp create mode 100644 ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 501e1031cf..ff385d3a8c 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -27,6 +27,8 @@ #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" #include "RimEclipseView.h" #include "RimGeoMechResultDefinition.h" #include "RimIntersectionCollection.h" @@ -53,6 +55,11 @@ #include #include +using ColorManager = RimEnsembleCurveSetColorManager; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend"); @@ -60,17 +67,22 @@ namespace caf { template<> void RimRegularLegendConfig::ColorRangeEnum::setUp() { - addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); - addItem(RimRegularLegendConfig::OPPOSITE_NORMAL,"OPPOSITE_NORMAL", "Full color, Blue on top"); - addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); - addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); - addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); - addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); - addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); - addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); - addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors"); - addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); - addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); + addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); + addItem(RimRegularLegendConfig::OPPOSITE_NORMAL, "OPPOSITE_NORMAL", "Full color, Blue on top"); + addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); + addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); + addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); + addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); + addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); + addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); + addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors"); + addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); + addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); + addItem(RimRegularLegendConfig::RED_LIGHT_DARK, "RED_DARK_LIGHT", "Red Light to Dark"); + addItem(RimRegularLegendConfig::GREEN_LIGHT_DARK, "GREEN_DARK_LIGHT", "Green Light to Dark"); + addItem(RimRegularLegendConfig::BLUE_LIGHT_DARK, "BLUE_DARK_LIGHT", "Blue Light to Dark"); + addItem(RimRegularLegendConfig::GREEN_RED, "GREEN_RED", "Green to Red"); + addItem(RimRegularLegendConfig::BLUE_MAGENTA, "BLUE_MAGENTA", "Blue to Magenta"); setDefault(RimRegularLegendConfig::NORMAL); } } @@ -732,6 +744,15 @@ const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() cons } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet) +{ + // Set default color palette for ensemble curve sets + setColorRangeMode(ColorManager::nextColorRange(curveSet)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -783,6 +804,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy return RiaColorTables::stimPlanPaletteColors().color3ubArray(); break; default: + if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::ENSEMBLE_COLOR_RANGES.at(colorType); break; } @@ -870,15 +892,26 @@ QList RimRegularLegendConfig::calculateValueOptions(cons { // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type std::vector rangeTypes; - rangeTypes.push_back(NORMAL); - rangeTypes.push_back(OPPOSITE_NORMAL); - rangeTypes.push_back(WHITE_PINK); - rangeTypes.push_back(PINK_WHITE); - rangeTypes.push_back(BLUE_WHITE_RED); - rangeTypes.push_back(RED_WHITE_BLUE); - rangeTypes.push_back(WHITE_BLACK); - rangeTypes.push_back(BLACK_WHITE); - rangeTypes.push_back(ANGULAR); + if (!hasEnsembleCurveSetParent) + { + rangeTypes.push_back(NORMAL); + rangeTypes.push_back(OPPOSITE_NORMAL); + rangeTypes.push_back(WHITE_PINK); + rangeTypes.push_back(PINK_WHITE); + rangeTypes.push_back(BLUE_WHITE_RED); + rangeTypes.push_back(RED_WHITE_BLUE); + rangeTypes.push_back(WHITE_BLACK); + rangeTypes.push_back(BLACK_WHITE); + rangeTypes.push_back(ANGULAR); + } + else + { + for (const auto& col : ColorManager::ENSEMBLE_COLOR_RANGES) + { + rangeTypes.push_back(col.first); + } + } + if (hasStimPlanParent) rangeTypes.push_back(STIMPLAN); if (isCategoryResult) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index 5a0bba03ed..c7345561a3 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -48,6 +48,7 @@ namespace caf } class Rim3dView; +class RimEnsembleCurveSet; //================================================================================================== /// @@ -74,7 +75,13 @@ class RimRegularLegendConfig : public RimLegendConfig RED_WHITE_BLUE, CATEGORY, ANGULAR, - STIMPLAN + STIMPLAN, + + GREEN_RED, + BLUE_MAGENTA, + RED_LIGHT_DARK, + GREEN_LIGHT_DARK, + BLUE_LIGHT_DARK }; typedef caf::AppEnum ColorRangeEnum; @@ -118,6 +125,8 @@ class RimRegularLegendConfig : public RimLegendConfig const caf::TitledOverlayFrame* titledOverlayFrame() const override; caf::TitledOverlayFrame* titledOverlayFrame() override; + void initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet); + private: void setNamedCategories(const std::vector& categoryNames, bool inverse); void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index 3dbf1bbceb..09bc668aec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -31,6 +31,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -65,6 +66,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 83ce3d7f8b..3a147fa310 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -19,6 +19,7 @@ #include "RimEnsembleCurveSet.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RifReaderEclipseSummary.h" @@ -46,6 +47,14 @@ #include "qwt_symbol.h" +//-------------------------------------------------------------------------------------------------- +/// Internal constants +//-------------------------------------------------------------------------------------------------- +#define DOUBLE_INF std::numeric_limits::infinity() + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- namespace caf { template<> @@ -57,11 +66,6 @@ namespace caf } } -//-------------------------------------------------------------------------------------------------- -/// Internal constants -//-------------------------------------------------------------------------------------------------- -#define DOUBLE_INF std::numeric_limits::infinity() - CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet"); @@ -208,6 +212,7 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) } } + m_legendConfig->initForEnsembleCurveSet(this); updateCurveColors(); } @@ -715,7 +720,7 @@ void RimEnsembleCurveSet::updateCurveColors() } else { - curve->setColor(cvf::Color3f::GRAY); + curve->setColor(RiaColorTables::undefinedCellColor()); } curve->updateCurveAppearance(); } @@ -751,7 +756,7 @@ void RimEnsembleCurveSet::updateCurveColors() rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue() : DOUBLE_INF; if(value != DOUBLE_INF) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); - else curve->setColor(cvf::Color3f::GRAY); + else curve->setColor(RiaColorTables::undefinedCellColor()); curve->updateCurveAppearance(); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp new file mode 100644 index 0000000000..cfeae62e06 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsembleCurveSetColorManager.h" +#include "RimEnsembleCurveSetCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map RimEnsembleCurveSetColorManager::ENSEMBLE_COLOR_RANGES( + { + { RimRegularLegendConfig::GREEN_RED, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0xff, 0x00), cvf::Color3ub(0xff, 0x00, 0x00) }) }, + { RimRegularLegendConfig::BLUE_MAGENTA, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0x00, 0xff), cvf::Color3ub(0xff, 0x00, 0xff) }) }, + { RimRegularLegendConfig::RED_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xff, 0xcc, 0xcc), cvf::Color3ub(0x99, 0x00, 0x00) }) }, + { RimRegularLegendConfig::GREEN_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xff, 0xcc), cvf::Color3ub(0x00, 0x99, 0x00) }) }, + { RimRegularLegendConfig::BLUE_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xcc, 0xff), cvf::Color3ub(0x00, 0x00, 0x99) }) } + }); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE = RimRegularLegendConfig::GREEN_RED; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::nextColorRange(RimEnsembleCurveSet* curveSet) +{ + CVF_ASSERT(curveSet); + + RimEnsembleCurveSetCollection* coll; + curveSet->firstAncestorOrThisOfType(coll); + + if (coll) + { + if (m_colorCache.find(coll) != m_colorCache.end()) + { + if (m_colorCache[coll].find(curveSet) != m_colorCache[coll].end()) + { + // CurveSet found in cache, use same color range as last time + return m_colorCache[coll][curveSet]; + } + } + else + { + m_colorCache.insert(std::make_pair(coll, std::map())); + m_nextColorIndexes.insert(std::make_pair(coll, 0)); + } + + int currColorIndex = m_nextColorIndexes[coll]; + RimRegularLegendConfig::ColorRangesType resultColorRange = colorRangeByIndex(currColorIndex); + m_nextColorIndexes[coll] = (currColorIndex < (int)ENSEMBLE_COLOR_RANGES.size() - 1) ? currColorIndex + 1 : 0; + m_colorCache[coll][curveSet] = resultColorRange; + return resultColorRange; + } + return DEFAULT_ENSEMBLE_COLOR_RANGE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::colorRangeByIndex(int index) +{ + int i = 0; + for (auto item : ENSEMBLE_COLOR_RANGES) + { + if (i++ == index) return item.first; + } + return DEFAULT_ENSEMBLE_COLOR_RANGE; +} + +std::map RimEnsembleCurveSetColorManager::m_nextColorIndexes; + +std::map> RimEnsembleCurveSetColorManager::m_colorCache; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h new file mode 100644 index 0000000000..0149ff0de2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "RiaDefines.h" + +#include "RimRegularLegendConfig.h" +#include "RimEnsembleCurveSet.h" + +#include + +class RimEnsembleCurveSetCollection; + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RimEnsembleCurveSetColorManager +{ +public: + static const std::map ENSEMBLE_COLOR_RANGES; + + static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE; + + static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange) + { + return ENSEMBLE_COLOR_RANGES.find(colorRange) != ENSEMBLE_COLOR_RANGES.end(); + } + + static RimRegularLegendConfig::ColorRangesType nextColorRange(RimEnsembleCurveSet* curveSet); + +private: + static RimRegularLegendConfig::ColorRangesType colorRangeByIndex(int index); + + static std::map m_nextColorIndexes; + static std::map> m_colorCache; +}; From df6c9f69d1552fde7e8294dd951ba351e0aa0c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 4 May 2018 13:17:45 +0200 Subject: [PATCH 0865/1027] ScalarMapperRangeBased: Avoid adding duplicate ticks. Typically when max == min value --- Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp index 9fd13eaea2..ca4ee0fbf0 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp @@ -244,15 +244,21 @@ void ScalarMapperRangeBased::majorTickValues( std::vector* domainValues) if (normalizedValue(newLevel) > 1.0 - stepSizeNorm*0.4) break; - domainValues->push_back(newLevel); + if (newLevel != prevDomValue) domainValues->push_back(newLevel); + prevDomValue = newLevel; } } else { + double prevDomValue = domainValue(0); for (i = 1; i < m_levelCount; ++i) { - domainValues->push_back(domainValue(stepSizeNorm*i)); + double newLevel = domainValue(stepSizeNorm*i); + + if (newLevel != prevDomValue) domainValues->push_back(newLevel); + + prevDomValue = newLevel; } } } From d413df0aeb10117bc5d527c9103351ff115e1b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 4 May 2018 13:21:56 +0200 Subject: [PATCH 0866/1027] #2730 Category and Scalarmapper Legend: Improve the preferred size --- .../ModelVisualization/RivTernarySaturationOverlayItem.cpp | 2 +- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 4 +++- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index fa8239daf0..c057098303 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -257,5 +257,5 @@ void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange, //-------------------------------------------------------------------------------------------------- cvf::Vec2ui RivTernarySaturationOverlayItem::preferredSize() { - return {120, 150}; // Could do more elaborate text width checks. + return {140, 180}; // Could do more elaborate text width checks. } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index d95259c2a0..8be6e9ee61 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -503,7 +503,9 @@ cvf::Vec2ui CategoryLegend::preferredSize() OverlayColorLegendLayoutInfo layout({200,200}); // Use default size layoutInfo(&layout); - float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_categoryMapper->categoryCount() + 1)* layout.lineSpacing ; + float prefferredYSize = 2 * layout.margins.y() + + layout.lineSpacing * (this->titleStrings().size()) + + 1.5f * layout.lineSpacing * (m_categoryMapper->categoryCount() + 1); unsigned int maxTickTextWidth = 0; for (size_t cIdx = 0; cIdx < m_categoryMapper->categoryCount(); ++cIdx ) diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index a66e2c9442..738af2cf02 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -687,7 +687,9 @@ cvf::Vec2ui OverlayScalarMapperLegend::preferredSize() OverlayColorLegendLayoutInfo layout({200,200}); // Use default size layoutInfo(&layout); - float prefferredYSize = 2*layout.margins.y() + (this->titleStrings().size() + m_tickValues.size() )* layout.lineSpacing ; + float prefferredYSize = 2 * layout.margins.y() + + layout.lineSpacing * this->titleStrings().size() + + 1.5f * layout.lineSpacing * m_tickValues.size(); unsigned int maxTickTextWidth = 0; for (double tickValue : m_tickValues ) From 4713700c24269ae89f4c5ce68b76799a3eae082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 4 May 2018 13:26:34 +0200 Subject: [PATCH 0867/1027] Clean up obsolete code --- .../UserInterface/RiuCvfOverlayItemWidget.cpp | 104 ++---------------- 1 file changed, 12 insertions(+), 92 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp index f5a8abffc4..46b015fd43 100644 --- a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -16,9 +16,19 @@ // ///////////////////////////////////////////////////////////////////////////////// - #include "RiuCvfOverlayItemWidget.h" +#include "RiaApplication.h" + +#include "cafViewer.h" + +#include "cvfqtUtils.h" +#include "cvfRenderSequence.h" +#include "cvfFramebufferObject.h" +#include "cvfRenderbufferObject.h" +#include "cvfRendering.h" +#include "cvfCamera.h" + #include #include #include @@ -27,6 +37,7 @@ #include #include +#include "glew/GL/glew.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -50,16 +61,6 @@ RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() } -#include "cafViewer.h" -#include "cvfRendering.h" -#include "cvfRenderSequence.h" -#include "cvfFramebufferObject.h" -#include "cvfRenderbufferObject.h" -#include "cvfqtUtils.h" -#include "glew/GL/glew.h" -#include "RiaApplication.h" -#include "cvfCamera.h" - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -131,84 +132,3 @@ void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) this->resize(QSize(width, height)); } - -#if 0 - -#include "cafViewer.h" -#include "cvfRendering.h" -#include "cvfRenderSequence.h" -#include "cvfFramebufferObject.h" -#include "cvfRenderbufferObject.h" -#include "cvfqtUtils.h" -#include "glew/GL/glew.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QPixmap RimLegendConfig::drawLegend() -{ - m_scalarMapperLegend->setTitle("Hei og hopp"); - m_scalarMapperLegend->computeLayoutAndExtents({0,0}, {100, 400}); - unsigned int width = m_scalarMapperLegend->minimumWidth() + 100; - unsigned int height = m_scalarMapperLegend->sizeHint().y(); - - QGLFormat glFormat; - glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - - caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); - cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); - viewer->resize(width, height); - - - // Create a rendering - - cvf::ref rendering = new cvf::Rendering; - m_scalarMapperLegend->setLayoutFixedPosition({0,0}); - rendering->addOverlayItem(m_scalarMapperLegend.p()); - - - rendering->camera()->setViewport(0,0,width, height); - rendering->camera()->viewport()->setClearColor({1,1,1,0}); - - cvf::ref renderingSequence = new cvf::RenderSequence; - renderingSequence->addRendering(rendering.p()); - - if (RiaApplication::instance()->useShaders()) - { - // Set up frame and render buffers - - cvf::ref fbo = new cvf::FramebufferObject; - - cvf::ref rboColor = new cvf::RenderbufferObject(cvf::RenderbufferObject::RGBA, width, height); - cvf::ref rboDepth = new cvf::RenderbufferObject(cvf::RenderbufferObject::DEPTH_COMPONENT24, width, height); - - fbo->attachDepthRenderbuffer(rboDepth.p()); - fbo->attachColorRenderbuffer(0, rboColor.p()); - - fbo->applyOpenGL(cvfOglContext); - rendering->setTargetFramebuffer(fbo.p()); - fbo->bind(cvfOglContext); - } - - renderingSequence->render(cvfOglContext); - - // Read data from framebuffer - - cvf::UByteArray arr(4*width*height); - glReadPixels(0, 0, static_cast(width), static_cast(height), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr()); - - // Create a cvf texture image - - cvf::ref img = new cvf::TextureImage; - img->setData(arr.ptr(), width, height); - - QImage image = cvfqt::Utils::toQImage(*img.p()); - //image.save("jjsLegendImageTest.png"); - - QPixmap pixmap = QPixmap::fromImage(image); - - delete viewer; - - return pixmap; -} -#endif \ No newline at end of file From 1fe4f67a8e462239c9552699d1a4e151bb4e0ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 4 May 2018 13:32:41 +0200 Subject: [PATCH 0868/1027] #2822, #2731, #2730 Rewrote the legend layout completely. Now using preferred size unless it is higher than 0.7 viewer height. If higher, then use viewer height. Stacks legend in columns not higher then the viewer. Update layout on resize without triggering recreation of legends. Place axiscross in right bottom corner. --- ApplicationCode/UserInterface/RiuViewer.cpp | 135 ++++++++++---------- ApplicationCode/UserInterface/RiuViewer.h | 1 + 2 files changed, 65 insertions(+), 71 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index d1966b7a68..3e7ff17476 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -63,6 +63,7 @@ #include #include #include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h" +#include using cvf::ManipulatorTrackball; @@ -88,7 +89,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) cvf::Font* standardFont = RiaApplication::instance()->standardFont(); m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont); m_axisCross->setAxisLabels("X", "Y", "Z"); - m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT); m_mainRendering->addOverlayItem(m_axisCross.p()); m_showAxisCross = true; @@ -536,7 +537,7 @@ void RiuViewer::removeAllColorLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend) +void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedLegend) { RiaApplication* app = RiaApplication::instance(); CVF_ASSERT(app); @@ -545,91 +546,97 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend CVF_ASSERT(preferences); CVF_ASSERT(firstRendering); - if (legend) + if (addedLegend) { cvf::Color4f backgroundColor = mainCamera()->viewport()->clearColor(); backgroundColor.a() = 0.8f; cvf::Color3f frameColor(backgroundColor.r(), backgroundColor.g(), backgroundColor.b()); - updateLegendTextAndTickMarkColor(legend); + updateLegendTextAndTickMarkColor(addedLegend); - firstRendering->addOverlayItem(legend); - legend->enableBackground(preferences->showLegendBackground()); - legend->setBackgroundColor(backgroundColor); - legend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(frameColor, 0.3f), 0.9f)); + firstRendering->addOverlayItem(addedLegend); + addedLegend->enableBackground(preferences->showLegendBackground()); + addedLegend->setBackgroundColor(backgroundColor); + addedLegend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(frameColor, 0.3f), 0.9f)); - m_visibleLegends.push_back(legend); + m_visibleLegends.push_back(addedLegend); } - // Category count used to switch between standard height and full height of legend - const size_t categoryThreshold = 13; + updateLegendLayout(); - std::vector categoryLegends; - std::vector overlayItems; - for (auto legend : m_visibleLegends) - { - legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::updateLegendLayout() +{ + int viewPortHeight = static_cast(m_mainCamera->viewport()->height()); + + const float maxFreeLegendHeight = 0.7f*viewPortHeight; + const int border = 3; + int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; + int xPos = border + edgeAxisBorderWidth; + int yPos = border + edgeAxisBorderHeight; - caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); - if (catLegend) + std::vector standardHeightLegends; + + // Place the legends needing the full height, and sort out the standard height legends + + for ( cvf::ref legend : m_visibleLegends ) + { + cvf::Vec2ui prefSize = legend->preferredSize(); + if (prefSize.y() > maxFreeLegendHeight) { - categoryLegends.push_back(catLegend); + int legendWidth = prefSize.x(); + legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setRenderSize(cvf::Vec2ui(legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight)); + xPos += legendWidth + border; } else { - overlayItems.push_back(legend.p()); + standardHeightLegends.push_back(legend.p()); } } - if (categoryLegends.size() > 0 || m_showWindowEdgeAxes) - { - const int border = 3; - const int categoryWidth = 150; - int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; - int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; - - // This value is taken from OverlayAxisCross, as the axis cross is always shown in the lower left corner - const int axisCrossHeight = m_showAxisCross? 120 : 0; - - int height = static_cast(m_mainCamera->viewport()->height()); - int xPos = border + edgeAxisBorderWidth; + // Place the rest of the legends in columns that fits within the screen height + + int maxColumnWidht = 0; + std::vector columnLegends; - int yPos = axisCrossHeight + 2*border + edgeAxisBorderHeight; + for ( caf::TitledOverlayFrame* legend : standardHeightLegends ) + { + cvf::Vec2ui prefSize = legend->preferredSize(); - for (auto catLegend : categoryLegends) + // Check if we need a new column + if ((yPos + (int)prefSize.y() + border) > viewPortHeight) { - catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + xPos += border + maxColumnWidht; + yPos = border + edgeAxisBorderHeight; - if (catLegend->categoryCount() > categoryThreshold) + // Set same width to all legends in the column + for (caf::TitledOverlayFrame* legend : columnLegends ) { - catLegend->setRenderSize(cvf::Vec2ui(categoryWidth, height - 3 * border - axisCrossHeight - 2 * edgeAxisBorderHeight)); + legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y())); } - else - { - catLegend->setRenderSize(cvf::Vec2ui(categoryWidth, 200)); - } - xPos += categoryWidth + border; + maxColumnWidht = 0; + columnLegends.clear(); } - for (auto item : overlayItems) - { - item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setRenderSize(cvf::Vec2ui(prefSize.x(), prefSize.y())); + columnLegends.push_back(legend); - yPos += item->renderSize().y() + border + edgeAxisBorderHeight; - } + yPos += legend->renderSize().y() + border; + maxColumnWidht = std::max(maxColumnWidht, (int)prefSize.x()); } - unsigned int requiredLegendWidth = 0u; - for (auto legend : overlayItems) - { - requiredLegendWidth = std::max(requiredLegendWidth, legend->preferredSize().x()); - } + // Set same width to all legends in the last column - for (auto legend : overlayItems) + for (caf::TitledOverlayFrame* legend : columnLegends ) { - cvf::Vec2ui widthAdjustedSize = legend->renderSize(); - widthAdjustedSize.x() = requiredLegendWidth; - legend->setRenderSize(widthAdjustedSize); + legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y())); } } @@ -758,21 +765,7 @@ void RiuViewer::optimizeClippingPlanes() void RiuViewer::resizeGL(int width, int height) { caf::Viewer::resizeGL(width, height); - - bool hasCategoryLegend = false; - for (size_t i = 0; i < m_visibleLegends.size(); i++) - { - caf::CategoryLegend* categoryLegend = dynamic_cast(m_visibleLegends.at(i)); - if (categoryLegend) - { - hasCategoryLegend = true; - } - } - - if (hasCategoryLegend) - { - m_rimView->updateCurrentTimeStepAndRedraw(); - } + this->updateLegendLayout(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 8c3266d80e..c2b8eda882 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -127,6 +127,7 @@ public slots: virtual void leaveEvent(QEvent *) override; private: + void updateLegendLayout(); void updateTextAndTickMarkColorForOverlayItems(); void updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend); From a6b94f7e6696b825c83c3623577b5fbfadf9ce09 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 May 2018 07:18:25 +0200 Subject: [PATCH 0869/1027] #2803 Ensemble Cases Performance: Show case count in UI --- .../Summary/RimSummaryCaseCollection.cpp | 25 ++++++++++++++++--- .../Summary/RimSummaryCaseCollection.h | 17 +++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index beedbe85b7..859178dd4c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -18,8 +18,8 @@ #include "RimSummaryCaseCollection.h" -#include "RimGridSummaryCase.h" #include "RimEnsembleCurveSet.h" +#include "RimGridSummaryCase.h" #include "RimProject.h" #include "RimSummaryCase.h" @@ -36,6 +36,11 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() m_cases.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Case Group"), "Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_nameAndItemCount, "NameCount", "Name", "", "", ""); + m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount); + m_nameAndItemCount.uiCapability()->setUiReadOnly(true); + m_nameAndItemCount.xmlCapability()->setIOWritable(false); } //-------------------------------------------------------------------------------------------------- @@ -94,11 +99,11 @@ QString RimSummaryCaseCollection::name() const //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() { - return &m_name; + return &m_nameAndItemCount; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::updateReferringCurveSets() const { @@ -112,3 +117,17 @@ void RimSummaryCaseCollection::updateReferringCurveSets() const if (curveSet) curveSet->updateAllCurves(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseCollection::nameAndItemCount() const +{ + size_t itemCount = m_cases.size(); + if (itemCount > 20) + { + return QString("%1 (%2)").arg(m_name()).arg(itemCount); + } + + return m_name(); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index efb9500549..d8102e1e03 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -21,6 +21,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" #include @@ -34,17 +35,19 @@ class RimSummaryCaseCollection : public caf::PdmObject RimSummaryCaseCollection(); virtual ~RimSummaryCaseCollection(); - void removeCase(RimSummaryCase* summaryCase); - void addCase(RimSummaryCase* summaryCase); - std::vector allSummaryCases(); - void setName(const QString& name); - QString name() const; + void removeCase(RimSummaryCase* summaryCase); + void addCase(RimSummaryCase* summaryCase); + std::vector allSummaryCases(); + void setName(const QString& name); + QString name() const; private: - caf::PdmFieldHandle* userDescriptionField() override; - void updateReferringCurveSets() const; + caf::PdmFieldHandle* userDescriptionField() override; + void updateReferringCurveSets() const; + QString nameAndItemCount() const; private: caf::PdmChildArrayField m_cases; caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndItemCount; }; From 89930e15f754333ce2c0f5681dd7d48701f7e40a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 May 2018 07:36:51 +0200 Subject: [PATCH 0870/1027] #2803 Logging : Make calling of RiaLogging thread safe --- ApplicationCode/Application/Tools/RiaLogging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/Tools/RiaLogging.cpp b/ApplicationCode/Application/Tools/RiaLogging.cpp index a104ca1d66..cb1fa56ec2 100644 --- a/ApplicationCode/Application/Tools/RiaLogging.cpp +++ b/ApplicationCode/Application/Tools/RiaLogging.cpp @@ -192,7 +192,6 @@ void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance) delete sm_logger; } -// VF_ASSERT(loggerInstance); sm_logger = loggerInstance; } @@ -213,6 +212,7 @@ void RiaLogging::error(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_ERROR) { +#pragma omp critical sm_logger->error(message.toLatin1().constData()); } } @@ -224,6 +224,7 @@ void RiaLogging::warning(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_WARNING) { +#pragma omp critical sm_logger->warning(message.toLatin1().constData()); } } @@ -235,6 +236,7 @@ void RiaLogging::info(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_INFO) { +#pragma omp critical sm_logger->info(message.toLatin1().constData()); } } @@ -246,6 +248,7 @@ void RiaLogging::debug(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_DEBUG) { +#pragma omp critical sm_logger->debug(message.toLatin1().constData()); } } From d2e48ef153ed87bc75460b41325369d8ab305dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 4 May 2018 14:06:42 +0200 Subject: [PATCH 0871/1027] Update ecllib from statoil master repo commit 0188b08081eb1ac4ade89ac224b8128b4c9b0481 --- ResInsightVersion.cmake | 2 +- ThirdParty/Ert/.travis.yml | 2 - ThirdParty/Ert/CMakeLists.txt | 12 +- ThirdParty/Ert/applications/ecl/esummary.c | 198 -- .../cmake/Tests/test_have_readlinkat_decl.c | 17 + ThirdParty/Ert/lib/CMakeLists.txt | 190 +- ThirdParty/Ert/lib/build_config.hpp.in | 1 + ThirdParty/Ert/lib/ecl/FortIO.cpp | 3 +- ThirdParty/Ert/lib/ecl/Smspec.cpp | 2 +- .../Ert/lib/ecl/{ecl_box.c => ecl_box.cpp} | 14 +- ...{ecl_coarse_cell.c => ecl_coarse_cell.cpp} | 12 +- .../Ert/lib/ecl/{ecl_file.c => ecl_file.cpp} | 31 +- .../ecl/{ecl_file_kw.c => ecl_file_kw.cpp} | 22 +- .../{ecl_file_view.c => ecl_file_view.cpp} | 56 +- .../Ert/lib/ecl/{ecl_grav.c => ecl_grav.cpp} | 46 +- .../{ecl_grav_calc.c => ecl_grav_calc.cpp} | 10 +- ...{ecl_grav_common.c => ecl_grav_common.cpp} | 15 +- .../Ert/lib/ecl/{ecl_grid.c => ecl_grid.cpp} | 147 +- .../{ecl_grid_cache.c => ecl_grid_cache.cpp} | 24 +- .../{ecl_grid_dims.c => ecl_grid_dims.cpp} | 18 +- .../{ecl_init_file.c => ecl_init_file.cpp} | 13 +- .../{ecl_io_config.c => ecl_io_config.cpp} | 8 +- .../Ert/lib/ecl/{ecl_kw.c => ecl_kw.cpp} | 451 ++--- ...cl_kw_functions.c => ecl_kw_functions.cpp} | 2 +- .../{ecl_kw_grdecl.c => ecl_kw_grdecl.cpp} | 16 +- .../ecl/{ecl_nnc_data.c => ecl_nnc_data.cpp} | 16 +- .../{ecl_nnc_export.c => ecl_nnc_export.cpp} | 14 +- ...cl_nnc_geometry.c => ecl_nnc_geometry.cpp} | 18 +- .../lib/ecl/{ecl_region.c => ecl_region.cpp} | 18 +- .../ecl/{ecl_rft_cell.c => ecl_rft_cell.cpp} | 22 +- .../ecl/{ecl_rft_file.c => ecl_rft_file.cpp} | 34 +- .../ecl/{ecl_rft_node.c => ecl_rft_node.cpp} | 48 +- .../ecl/{ecl_rst_file.c => ecl_rst_file.cpp} | 28 +- .../ecl/{ecl_rsthead.c => ecl_rsthead.cpp} | 26 +- .../lib/ecl/{ecl_smspec.c => ecl_smspec.cpp} | 108 +- .../{ecl_subsidence.c => ecl_subsidence.cpp} | 38 +- .../Ert/lib/ecl/{ecl_sum.c => ecl_sum.cpp} | 112 +- .../ecl/{ecl_sum_data.c => ecl_sum_data.cpp} | 185 +- .../{ecl_sum_index.c => ecl_sum_index.cpp} | 2 +- .../{ecl_sum_tstep.c => ecl_sum_tstep.cpp} | 28 +- .../{ecl_sum_vector.c => ecl_sum_vector.cpp} | 18 +- .../Ert/lib/ecl/{ecl_type.c => ecl_type.cpp} | 30 +- ...{ecl_type_python.c => ecl_type_python.cpp} | 22 +- .../Ert/lib/ecl/{ecl_util.c => ecl_util.cpp} | 34 +- .../ecl/{fault_block.c => fault_block.cpp} | 12 +- ...lt_block_layer.c => fault_block_layer.cpp} | 8 +- ThirdParty/Ert/lib/ecl/fortio.c | 2 +- .../lib/ecl/{grid_dims.c => grid_dims.cpp} | 6 +- ThirdParty/Ert/lib/ecl/{layer.c => layer.cpp} | 12 +- .../Ert/lib/ecl/{nnc_info.c => nnc_info.cpp} | 22 +- .../lib/ecl/{nnc_vector.c => nnc_vector.cpp} | 14 +- .../ecl/{smspec_node.c => smspec_node.cpp} | 38 +- ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c | 21 + ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp | 131 +- ...ollection.c => well_branch_collection.cpp} | 18 +- .../lib/ecl/{well_conn.c => well_conn.cpp} | 141 +- ..._collection.c => well_conn_collection.cpp} | 23 +- .../lib/ecl/{well_info.c => well_info.cpp} | 34 +- ...ell_rseg_loader.c => well_rseg_loader.cpp} | 18 +- .../ecl/{well_segment.c => well_segment.cpp} | 24 +- ...llection.c => well_segment_collection.cpp} | 24 +- .../lib/ecl/{well_state.c => well_state.cpp} | 60 +- .../Ert/lib/ecl/{well_ts.c => well_ts.cpp} | 28 +- ThirdParty/Ert/lib/ert_api_config.h.in | 1 + ThirdParty/Ert/lib/ert_api_config.hpp.in | 1 + .../{geo_pointset.c => geo_pointset.cpp} | 12 +- .../{geo_polygon.c => geo_polygon.cpp} | 16 +- ...ollection.c => geo_polygon_collection.cpp} | 18 +- .../geometry/{geo_region.c => geo_region.cpp} | 20 +- .../{geo_surface.c => geo_surface.cpp} | 12 +- .../lib/geometry/{geo_util.c => geo_util.cpp} | 4 +- ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp | 123 +- .../Ert/lib/include/ert/ecl/ecl_box.hpp | 19 + .../lib/include/ert/ecl/ecl_coarse_cell.hpp | 19 + .../lib/include/ert/ecl/ecl_endian_flip.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_file.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_file_kw.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_file_view.hpp | 19 + ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h | 5 +- .../Ert/lib/include/ert/ecl/ecl_grav.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_grav_calc.hpp | 19 + .../lib/include/ert/ecl/ecl_grav_common.hpp | 19 + ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h | 4 + .../Ert/lib/include/ert/ecl/ecl_grid.hpp | 19 + .../lib/include/ert/ecl/ecl_grid_cache.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_grid_dims.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_init_file.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_io_config.h | 6 + .../Ert/lib/include/ert/ecl/ecl_io_config.hpp | 19 + ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h | 8 +- ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp | 19 + .../ert/ecl/ecl_kw_grdecl.hpp} | 13 +- .../Ert/lib/include/ert/ecl/ecl_kw_magic.hpp | 20 + .../Ert/lib/include/ert/ecl/ecl_nnc_data.hpp | 19 + .../lib/include/ert/ecl/ecl_nnc_export.hpp | 20 + .../lib/include/ert/ecl/ecl_nnc_geometry.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_region.h | 14 + .../Ert/lib/include/ert/ecl/ecl_region.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_rft_cell.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_rft_file.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_rft_node.h | 2 + .../Ert/lib/include/ert/ecl/ecl_rft_node.hpp | 20 + .../Ert/lib/include/ert/ecl/ecl_rst_file.hpp | 20 + .../Ert/lib/include/ert/ecl/ecl_rsthead.h | 2 + .../Ert/lib/include/ert/ecl/ecl_rsthead.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_smspec.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_subsidence.h | 8 +- .../lib/include/ert/ecl/ecl_subsidence.hpp | 19 + ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h | 22 +- .../Ert/lib/include/ert/ecl/ecl_sum.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_sum_data.h | 20 +- .../Ert/lib/include/ert/ecl/ecl_sum_data.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_sum_index.hpp | 20 + .../Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_sum_vector.h | 2 + .../lib/include/ert/ecl/ecl_sum_vector.hpp | 19 + ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h | 12 +- .../Ert/lib/include/ert/ecl/ecl_type.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_units.hpp | 19 + .../Ert/lib/include/ert/ecl/ecl_util.hpp | 19 + .../Ert/lib/include/ert/ecl/fault_block.hpp | 20 + .../lib/include/ert/ecl/fault_block_layer.hpp | 19 + .../Ert/lib/include/ert/ecl/grid_dims.hpp | 20 + ThirdParty/Ert/lib/include/ert/ecl/layer.h | 3 + ThirdParty/Ert/lib/include/ert/ecl/layer.hpp | 19 + .../Ert/lib/include/ert/ecl/nnc_info.hpp | 19 + .../Ert/lib/include/ert/ecl/nnc_vector.hpp | 19 + .../Ert/lib/include/ert/ecl/smspec_node.hpp | 20 + .../ert/ecl_well/well_branch_collection.hpp | 20 + .../lib/include/ert/ecl_well/well_conn.hpp | 20 + .../ert/ecl_well/well_conn_collection.hpp | 20 + .../lib/include/ert/ecl_well/well_const.hpp | 20 + .../lib/include/ert/ecl_well/well_info.hpp | 20 + .../include/ert/ecl_well/well_rseg_loader.hpp | 20 + .../lib/include/ert/ecl_well/well_segment.hpp | 20 + .../ert/ecl_well/well_segment_collection.hpp | 20 + .../Ert/lib/include/ert/ecl_well/well_state.h | 4 + .../lib/include/ert/ecl_well/well_state.hpp | 20 + .../Ert/lib/include/ert/ecl_well/well_ts.hpp | 20 + .../lib/include/ert/geometry/geo_pointset.hpp | 19 + .../lib/include/ert/geometry/geo_polygon.hpp | 19 + .../ert/geometry/geo_polygon_collection.hpp | 19 + .../lib/include/ert/geometry/geo_region.hpp | 19 + .../lib/include/ert/geometry/geo_surface.h | 10 + .../lib/include/ert/geometry/geo_surface.hpp | 19 + .../Ert/lib/include/ert/geometry/geo_util.hpp | 19 + .../Ert/lib/include/ert/nexus/nexus_plot.hpp | 63 - .../Ert/lib/include/ert/util/arg_pack.hpp | 24 + .../Ert/lib/include/ert/util/buffer.hpp | 24 + .../Ert/lib/include/ert/util/ecl_version.hpp | 24 + ThirdParty/Ert/lib/include/ert/util/hash.hpp | 24 + .../Ert/lib/include/ert/util/hash_node.hpp | 24 + .../Ert/lib/include/ert/util/hash_sll.hpp | 24 + ThirdParty/Ert/lib/include/ert/util/lars.h | 50 - ThirdParty/Ert/lib/include/ert/util/log.h | 62 - .../Ert/lib/include/ert/util/lookup_table.h | 2 +- .../Ert/lib/include/ert/util/lookup_table.hpp | 24 + ThirdParty/Ert/lib/include/ert/util/matrix.h | 194 -- .../Ert/lib/include/ert/util/matrix_blas.h | 45 - .../Ert/lib/include/ert/util/matrix_lapack.h | 93 - .../Ert/lib/include/ert/util/matrix_stat.h | 43 - ThirdParty/Ert/lib/include/ert/util/menu.h | 51 - ThirdParty/Ert/lib/include/ert/util/msg.h | 47 - ThirdParty/Ert/lib/include/ert/util/mzran.hpp | 24 + .../Ert/lib/include/ert/util/node_ctype.hpp | 24 + .../Ert/lib/include/ert/util/node_data.hpp | 24 + .../Ert/lib/include/ert/util/parser.hpp | 24 + .../Ert/lib/include/ert/util/path_fmt.h | 49 - .../Ert/lib/include/ert/util/path_stack.hpp | 24 + .../Ert/lib/include/ert/util/perm_vector.hpp | 24 + .../Ert/lib/include/ert/util/regression.h | 34 - ThirdParty/Ert/lib/include/ert/util/rng.hpp | 24 + ThirdParty/Ert/lib/include/ert/util/set.hpp | 24 + .../Ert/lib/include/ert/util/ssize_t.hpp | 24 + .../Ert/lib/include/ert/util/statistics.hpp | 24 + .../Ert/lib/include/ert/util/stepwise.h | 42 - .../Ert/lib/include/ert/util/string_util.hpp | 24 + .../Ert/lib/include/ert/util/stringlist.hpp | 24 + .../lib/include/ert/util/struct_vector.hpp | 24 + .../Ert/lib/include/ert/util/subst_func.h | 56 - .../Ert/lib/include/ert/util/test_util.h | 2 + .../lib/include/ert/util/test_work_area.hpp | 24 + .../Ert/lib/include/ert/util/thread_pool.h | 43 - .../Ert/lib/include/ert/util/time_interval.h | 53 - .../lib/include/ert/util/time_interval.hpp | 24 + ThirdParty/Ert/lib/include/ert/util/timer.hpp | 24 + .../Ert/lib/include/ert/util/type_macros.hpp | 24 + .../ert/util/type_vector_functions.hpp | 24 + .../Ert/lib/include/ert/util/ui_return.h | 57 - ThirdParty/Ert/lib/include/ert/util/util.h | 1 + ThirdParty/Ert/lib/include/ert/util/util.hpp | 24 + .../Ert/lib/include/ert/util/util_env.h | 37 - .../Ert/lib/include/ert/util/vector.hpp | 24 + ThirdParty/Ert/lib/nexus/nexus_plot.cpp | 170 -- ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp | 55 - .../Ert/lib/nexus/tests/nexus_plot_load.cpp | 142 -- ThirdParty/Ert/lib/util/TestArea.cpp | 2 +- .../Ert/lib/util/{arg_pack.c => arg_pack.cpp} | 8 +- .../Ert/lib/util/{buffer.c => buffer.cpp} | 18 +- .../util/{ecl_version.c => ecl_version.cpp} | 4 +- ThirdParty/Ert/lib/util/{hash.c => hash.cpp} | 12 +- .../lib/util/{hash_node.c => hash_node.cpp} | 6 +- .../Ert/lib/util/{hash_sll.c => hash_sll.cpp} | 6 +- ThirdParty/Ert/lib/util/lars.c | 448 ----- ThirdParty/Ert/lib/util/log.c | 253 --- .../util/{lookup_table.c => lookup_table.cpp} | 8 +- ThirdParty/Ert/lib/util/matrix.c | 1751 ----------------- ThirdParty/Ert/lib/util/matrix_blas.c | 286 --- ThirdParty/Ert/lib/util/matrix_lapack.c | 640 ------ ThirdParty/Ert/lib/util/matrix_stat.c | 114 -- ThirdParty/Ert/lib/util/menu.c | 462 ----- ThirdParty/Ert/lib/util/msg.c | 161 -- .../Ert/lib/util/{mzran.c => mzran.cpp} | 6 +- .../lib/util/{node_ctype.c => node_ctype.cpp} | 4 +- .../lib/util/{node_data.c => node_data.cpp} | 6 +- .../Ert/lib/util/{parser.c => parser.cpp} | 10 +- ThirdParty/Ert/lib/util/path_fmt.c | 314 --- .../lib/util/{path_stack.c => path_stack.cpp} | 6 +- .../util/{perm_vector.c => perm_vector.cpp} | 6 +- ThirdParty/Ert/lib/util/regression.c | 143 -- ThirdParty/Ert/lib/util/{rng.c => rng.cpp} | 10 +- ThirdParty/Ert/lib/util/{set.c => set.cpp} | 8 +- .../lib/util/{statistics.c => statistics.cpp} | 6 +- ThirdParty/Ert/lib/util/stepwise.c | 456 ----- .../util/{string_util.c => string_util.cpp} | 14 +- .../lib/util/{stringlist.c => stringlist.cpp} | 10 +- .../{struct_vector.c => struct_vector.cpp} | 4 +- ThirdParty/Ert/lib/util/subst_func.c | 210 -- .../lib/util/{test_util.c => test_util.cpp} | 12 +- .../{test_work_area.c => test_work_area.cpp} | 10 +- .../Ert/lib/util/tests/ert_util_PATH_test.c | 59 - ThirdParty/Ert/lib/util/tests/ert_util_logh.c | 110 -- .../Ert/lib/util/tests/ert_util_matrix.c | 242 --- .../lib/util/tests/ert_util_matrix_lapack.c | 92 - .../Ert/lib/util/tests/ert_util_matrix_stat.c | 169 -- .../lib/util/tests/ert_util_time_interval.c | 245 --- .../Ert/lib/util/tests/ert_util_ui_return.c | 97 - ThirdParty/Ert/lib/util/thread_pool1.c | 90 - ThirdParty/Ert/lib/util/thread_pool_posix.c | 485 ----- ThirdParty/Ert/lib/util/time_interval.c | 174 -- .../Ert/lib/util/{timer.c => timer.cpp} | 4 +- ..._functions.c => type_vector_functions.cpp} | 8 +- ThirdParty/Ert/lib/util/ui_return.c | 116 -- ThirdParty/Ert/lib/util/util.c | 51 +- ThirdParty/Ert/lib/util/util_abort_gnu.c | 4 +- ThirdParty/Ert/lib/util/util_abort_simple.c | 2 +- .../util/{util_endian.c => util_endian.cpp} | 0 ThirdParty/Ert/lib/util/util_env.c | 280 --- .../util/{util_getuid.c => util_getuid.cpp} | 2 +- .../lib/util/{util_lockf.c => util_lockf.cpp} | 2 +- .../util/{util_opendir.c => util_opendir.cpp} | 2 +- .../lib/util/{util_spawn.c => util_spawn.cpp} | 6 +- .../util/{util_symlink.c => util_symlink.cpp} | 8 +- .../util/{util_unlink.c => util_unlink.cpp} | 4 +- .../lib/util/{util_zlib.c => util_zlib.cpp} | 6 +- .../Ert/lib/util/{vector.c => vector.cpp} | 8 +- ...{vector_template.c => vector_template.cpp} | 6 +- .../thread_pool.c => vector_template.hpp.in} | 13 +- ThirdParty/Ert/python/CMakeLists.txt | 6 + ThirdParty/Ert/python/ecl/ecl_type.py | 2 +- ThirdParty/Ert/python/ecl/summary/ecl_sum.py | 166 +- .../ecl/util/test/ecl_mock/ecl_sum_mock.py | 4 +- ThirdParty/Ert/python/python/CMakeLists.txt | 8 - .../Ert/python/python/cwrap/CMakeLists.txt | 12 - .../Ert/python/python/cwrap/__init__.py | 52 - .../Ert/python/python/cwrap/basecclass.py | 156 -- .../Ert/python/python/cwrap/basecenum.py | 169 -- .../Ert/python/python/cwrap/basecvalue.py | 67 - ThirdParty/Ert/python/python/cwrap/cfile.py | 70 - ThirdParty/Ert/python/python/cwrap/clib.py | 90 - .../Ert/python/python/cwrap/metacwrap.py | 67 - .../Ert/python/python/cwrap/prototype.py | 177 -- .../Ert/python/python/ecl/CMakeLists.txt | 14 - ThirdParty/Ert/python/python/ecl/__init__.py | 130 -- .../Ert/python/python/ecl/ecl/CMakeLists.txt | 37 - .../Ert/python/python/ecl/ecl/__init__.py | 115 -- ThirdParty/Ert/python/python/ecl/ecl/cell.py | 127 -- .../Ert/python/python/ecl/ecl/ecl_3d_file.py | 41 - .../Ert/python/python/ecl/ecl/ecl_3dkw.py | 239 --- .../Ert/python/python/ecl/ecl/ecl_cmp.py | 184 -- .../Ert/python/python/ecl/ecl/ecl_file.py | 718 ------- .../python/python/ecl/ecl/ecl_file_view.py | 200 -- .../Ert/python/python/ecl/ecl/ecl_grav.py | 217 -- .../python/python/ecl/ecl/ecl_grav_calc.py | 84 - .../Ert/python/python/ecl/ecl/ecl_grid.py | 1301 ------------ .../python/ecl/ecl/ecl_grid_generator.py | 708 ------- .../python/python/ecl/ecl/ecl_init_file.py | 29 - .../Ert/python/python/ecl/ecl/ecl_kw.py | 1173 ----------- .../Ert/python/python/ecl/ecl/ecl_npv.py | 220 --- .../Ert/python/python/ecl/ecl/ecl_region.py | 1054 ---------- .../python/python/ecl/ecl/ecl_restart_file.py | 157 -- .../Ert/python/python/ecl/ecl/ecl_rft.py | 355 ---- .../Ert/python/python/ecl/ecl/ecl_rft_cell.py | 171 -- .../python/python/ecl/ecl/ecl_smspec_node.py | 196 -- .../python/python/ecl/ecl/ecl_subsidence.py | 143 -- .../Ert/python/python/ecl/ecl/ecl_sum.py | 1300 ------------ .../python/ecl/ecl/ecl_sum_keyword_vector.py | 72 - .../Ert/python/python/ecl/ecl/ecl_sum_node.py | 28 - .../python/python/ecl/ecl/ecl_sum_tstep.py | 83 - .../python/python/ecl/ecl/ecl_sum_var_type.py | 56 - .../python/python/ecl/ecl/ecl_sum_vector.py | 304 --- .../Ert/python/python/ecl/ecl/ecl_type.py | 184 -- .../Ert/python/python/ecl/ecl/ecl_util.py | 166 -- .../python/ecl/ecl/faults/CMakeLists.txt | 12 - .../python/python/ecl/ecl/faults/__init__.py | 7 - .../Ert/python/python/ecl/ecl/faults/fault.py | 654 ------ .../python/ecl/ecl/faults/fault_block.py | 190 -- .../ecl/ecl/faults/fault_block_collection.py | 84 - .../ecl/ecl/faults/fault_block_layer.py | 235 --- .../python/ecl/ecl/faults/fault_collection.py | 135 -- .../python/ecl/ecl/faults/fault_line.py | 253 --- .../python/ecl/ecl/faults/fault_segments.py | 174 -- .../Ert/python/python/ecl/ecl/faults/layer.py | 274 --- .../Ert/python/python/ecl/ecl/fortio.py | 211 -- .../Ert/python/python/ecl/ecl/local.cmake | 13 - .../python/python/ecl/ecl/rft/CMakeLists.txt | 6 - .../Ert/python/python/ecl/ecl/rft/__init__.py | 1 - .../python/ecl/ecl/rft/well_trajectory.py | 84 - .../python/ecl/ecl_lib_info_build.py.in | 3 - .../python/ecl/ecl_lib_info_install.py.in | 3 - .../Ert/python/python/ecl/geo/CMakeLists.txt | 13 - .../Ert/python/python/ecl/geo/__init__.py | 37 - .../Ert/python/python/ecl/geo/cpolyline.py | 210 -- .../python/ecl/geo/cpolyline_collection.py | 120 -- .../Ert/python/python/ecl/geo/geo_pointset.py | 79 - .../Ert/python/python/ecl/geo/geo_region.py | 121 -- .../python/python/ecl/geo/geometry_tools.py | 448 ----- .../Ert/python/python/ecl/geo/polyline.py | 171 -- .../Ert/python/python/ecl/geo/surface.py | 285 --- .../Ert/python/python/ecl/geo/xyz_io.py | 62 - .../Ert/python/python/ecl/test/CMakeLists.txt | 18 - .../Ert/python/python/ecl/test/__init__.py | 11 - .../Ert/python/python/ecl/test/debug_msg.py | 7 - .../python/ecl/test/ecl_mock/CMakeLists.txt | 6 - .../python/ecl/test/ecl_mock/__init__.py | 1 - .../python/ecl/test/ecl_mock/ecl_sum_mock.py | 30 - .../python/ecl/test/ert_test_context.py | 117 -- .../python/python/ecl/test/ert_test_runner.py | 63 - .../python/ecl/test/extended_testcase.py | 181 -- .../python/ecl/test/import_test_case.py | 52 - .../python/python/ecl/test/lint_test_case.py | 61 - .../python/python/ecl/test/path_context.py | 46 - .../python/ecl/test/source_enumerator.py | 39 - .../Ert/python/python/ecl/test/temp_area.py | 81 - .../Ert/python/python/ecl/test/test_area.py | 149 -- .../Ert/python/python/ecl/test/test_run.py | 158 -- .../Ert/python/python/ecl/util/CMakeLists.txt | 33 - .../Ert/python/python/ecl/util/__init__.py | 135 -- .../Ert/python/python/ecl/util/arg_pack.py | 57 - .../Ert/python/python/ecl/util/bool_vector.py | 143 -- .../Ert/python/python/ecl/util/buffer.py | 29 - .../python/python/ecl/util/cthread_pool.py | 85 - .../Ert/python/python/ecl/util/ctime.py | 148 -- .../Ert/python/python/ecl/util/cwd_context.py | 16 - .../python/python/ecl/util/double_vector.py | 70 - .../python/ecl/util/enums/CMakeLists.txt | 11 - .../python/python/ecl/util/enums/__init__.py | 5 - .../python/ecl/util/enums/llsq_result_enum.py | 13 - .../ecl/util/enums/message_level_enum.py | 18 - .../ecl/util/enums/rng_alg_type_enum.py | 8 - .../ecl/util/enums/rng_init_mode_enum.py | 14 - .../ecl/util/enums/ui_return_status_enum.py | 11 - ThirdParty/Ert/python/python/ecl/util/hash.py | 133 -- .../python/ecl/util/install_abort_signals.py | 16 - .../Ert/python/python/ecl/util/int_vector.py | 108 - ThirdParty/Ert/python/python/ecl/util/log.py | 44 - .../python/python/ecl/util/lookup_table.py | 122 -- .../Ert/python/python/ecl/util/matrix.py | 227 --- .../Ert/python/python/ecl/util/path_format.py | 42 - .../python/ecl/util/permutation_vector.py | 38 - .../Ert/python/python/ecl/util/profiler.py | 34 - ThirdParty/Ert/python/python/ecl/util/rng.py | 81 - ThirdParty/Ert/python/python/ecl/util/stat.py | 78 - .../Ert/python/python/ecl/util/stringlist.py | 308 --- .../Ert/python/python/ecl/util/thread_pool.py | 151 -- .../Ert/python/python/ecl/util/time_vector.py | 170 -- .../Ert/python/python/ecl/util/ui_return.py | 116 -- .../Ert/python/python/ecl/util/util_func.py | 54 - .../python/python/ecl/util/vector_template.py | 647 ------ .../Ert/python/python/ecl/util/version.py | 118 -- .../Ert/python/python/ecl/well/CMakeLists.txt | 13 - .../Ert/python/python/ecl/well/__init__.py | 20 - .../python/python/ecl/well/well_connection.py | 108 - .../well/well_connection_direction_enum.py | 15 - .../Ert/python/python/ecl/well/well_info.py | 122 -- .../python/python/ecl/well/well_segment.py | 76 - .../Ert/python/python/ecl/well/well_state.py | 164 -- .../python/python/ecl/well/well_time_line.py | 42 - .../python/python/ecl/well/well_type_enum.py | 16 - .../python/python/legacy/ert/CMakeLists.txt | 11 - .../Ert/python/python/legacy/ert/__init__.py | 0 .../python/python/legacy/ert/ecl/__init__.py | 26 - .../python/legacy/ert/ecl/faults/__init__.py | 7 - .../python/python/legacy/ert/geo/__init__.py | 8 - .../python/python/legacy/ert/test/__init__.py | 10 - .../python/python/legacy/ert/util/__init__.py | 29 - .../python/python/legacy/ert/well/__init__.py | 7 - ThirdParty/Ert/python/python/test_env.py.in | 6 - .../tests/bin_tests/test_summary_resample.py | 2 +- .../Ert/python/tests/cwrap/CMakeLists.txt | 17 - ThirdParty/Ert/python/tests/cwrap/__init__.py | 0 .../Ert/python/tests/cwrap/test_basecclass.py | 19 - .../Ert/python/tests/cwrap/test_basecenum.py | 91 - .../Ert/python/tests/cwrap/test_basecvalue.py | 71 - .../Ert/python/tests/cwrap/test_cfile.py | 31 - .../Ert/python/tests/cwrap/test_metawrap.py | 122 -- .../Ert/python/tests/ecl/CMakeLists.txt | 97 - ThirdParty/Ert/python/tests/ecl/__init__.py | 0 ThirdParty/Ert/python/tests/ecl/test_cell.py | 98 - ThirdParty/Ert/python/tests/ecl/test_debug.py | 24 - .../Ert/python/tests/ecl/test_deprecation.py | 50 - .../Ert/python/tests/ecl/test_ecl_3dkw.py | 202 -- .../Ert/python/tests/ecl/test_ecl_cmp.py | 68 - .../Ert/python/tests/ecl/test_ecl_file.py | 256 --- .../python/tests/ecl/test_ecl_file_statoil.py | 277 --- .../python/tests/ecl/test_ecl_init_file.py | 47 - .../Ert/python/tests/ecl/test_ecl_kw.py | 475 ----- .../python/tests/ecl/test_ecl_kw_statoil.py | 112 -- .../python/tests/ecl/test_ecl_restart_file.py | 67 - .../Ert/python/tests/ecl/test_ecl_sum.py | 144 -- .../python/tests/ecl/test_ecl_sum_tstep.py | 41 - .../python/tests/ecl/test_ecl_sum_vector.py | 54 - .../Ert/python/tests/ecl/test_ecl_type.py | 139 -- .../Ert/python/tests/ecl/test_ecl_util.py | 42 - .../Ert/python/tests/ecl/test_fault_blocks.py | 468 ----- .../tests/ecl/test_fault_blocks_statoil.py | 40 - .../Ert/python/tests/ecl/test_faults.py | 796 -------- .../Ert/python/tests/ecl/test_fk_user_data.py | 48 - .../Ert/python/tests/ecl/test_fortio.py | 139 -- .../Ert/python/tests/ecl/test_geertsma.py | 144 -- ThirdParty/Ert/python/tests/ecl/test_grav.py | 25 - .../Ert/python/tests/ecl/test_grdecl.py | 124 -- ThirdParty/Ert/python/tests/ecl/test_grid.py | 587 ------ .../python/tests/ecl/test_grid_generator.py | 272 --- .../Ert/python/tests/ecl/test_grid_statoil.py | 408 ---- .../Ert/python/tests/ecl/test_indexed_read.py | 116 -- .../Ert/python/tests/ecl/test_kw_function.py | 57 - ThirdParty/Ert/python/tests/ecl/test_layer.py | 306 --- ThirdParty/Ert/python/tests/ecl/test_npv.py | 194 -- .../Ert/python/tests/ecl/test_region.py | 89 - .../python/tests/ecl/test_region_statoil.py | 205 -- .../Ert/python/tests/ecl/test_removed.py | 34 - .../Ert/python/tests/ecl/test_restart.py | 129 -- .../Ert/python/tests/ecl/test_restart_head.py | 41 - ThirdParty/Ert/python/tests/ecl/test_rft.py | 38 - .../Ert/python/tests/ecl/test_rft_cell.py | 95 - .../Ert/python/tests/ecl/test_rft_statoil.py | 142 -- .../python/tests/ecl/test_statoil_faults.py | 128 -- ThirdParty/Ert/python/tests/ecl/test_sum.py | 315 --- .../Ert/python/tests/ecl/test_sum_statoil.py | 500 ----- .../Ert/python/tests/ecl_tests/test_ecl_kw.py | 4 +- .../Ert/python/tests/ecl_tests/test_sum.py | 94 +- .../Ert/python/tests/geometry/CMakeLists.txt | 28 - .../Ert/python/tests/geometry/__init__.py | 0 .../python/tests/geometry/test_convex_hull.py | 27 - .../python/tests/geometry/test_cpolyline.py | 171 -- .../geometry/test_cpolyline_collection.py | 133 -- .../tests/geometry/test_geo_pointset.py | 27 - .../python/tests/geometry/test_geo_region.py | 88 - .../tests/geometry/test_geometry_tools.py | 80 - .../tests/geometry/test_intersection.py | 47 - .../tests/geometry/test_point_in_polygon.py | 60 - .../tests/geometry/test_polygon_slicing.py | 139 -- .../python/tests/geometry/test_polyline.py | 193 -- .../Ert/python/tests/geometry/test_surface.py | 210 -- .../Ert/python/tests/global/CMakeLists.txt | 12 - .../Ert/python/tests/global/__init__.py | 0 .../Ert/python/tests/global/test_import.py | 26 - .../Ert/python/tests/global/test_pylint.py | 34 - .../Ert/python/tests/install/test_install.py | 13 - .../Ert/python/tests/legacy/CMakeLists.txt | 16 - .../Ert/python/tests/legacy/__init__.py | 0 .../Ert/python/tests/legacy/test_ecl.py | 41 - .../Ert/python/tests/legacy/test_geo.py | 14 - .../Ert/python/tests/legacy/test_test.py | 16 - .../Ert/python/tests/legacy/test_util.py | 34 - .../Ert/python/tests/legacy/test_well.py | 13 - .../Ert/python/tests/share/CMakeLists.txt | 8 - ThirdParty/Ert/python/tests/share/__init__.py | 0 .../python/tests/share/test_synthesizer.py | 50 - ThirdParty/Ert/python/tests/test_pylint.py | 34 - .../Ert/python/tests/util/CMakeLists.txt | 46 - ThirdParty/Ert/python/tests/util/__init__.py | 0 .../Ert/python/tests/util/test_arg_pack.py | 35 - .../Ert/python/tests/util/test_cstring.py | 24 - .../python/tests/util/test_cthread_pool.py | 47 - .../Ert/python/tests/util/test_ctime.py | 131 -- ThirdParty/Ert/python/tests/util/test_hash.py | 68 - ThirdParty/Ert/python/tests/util/test_log.py | 8 - .../python/tests/util/test_lookup_table.py | 88 - .../Ert/python/tests/util/test_matrix.py | 247 --- .../python/tests/util/test_path_context.py | 49 - .../Ert/python/tests/util/test_path_fmt.py | 10 - ThirdParty/Ert/python/tests/util/test_rng.py | 45 - .../Ert/python/tests/util/test_spawn.py | 63 - ThirdParty/Ert/python/tests/util/test_stat.py | 43 - .../Ert/python/tests/util/test_string_list.py | 159 -- .../Ert/python/tests/util/test_thread_pool.py | 101 - .../Ert/python/tests/util/test_ui_return.py | 69 - .../Ert/python/tests/util/test_vectors.py | 552 ------ .../Ert/python/tests/util/test_version.py | 110 -- .../Ert/python/tests/util/test_work_area.py | 95 - .../Ert/python/tests/well/CMakeLists.txt | 14 - ThirdParty/Ert/python/tests/well/__init__.py | 0 .../Ert/python/tests/well/test_ecl_well.py | 446 ----- .../Ert/python/tests/well/test_ecl_well2.py | 43 - .../Ert/python/tests/well/test_ecl_well3.py | 48 - .../python/tests/well_tests/test_ecl_well.py | 7 + ThirdParty/Ert/redhat/ert.ecl.spec | 108 - ThirdParty/Ert/requirements.txt | 1 + patches/fix-synthetic-odb-cases.patch | 8 +- 511 files changed, 3905 insertions(+), 42027 deletions(-) delete mode 100644 ThirdParty/Ert/applications/ecl/esummary.c create mode 100644 ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c create mode 100644 ThirdParty/Ert/lib/build_config.hpp.in rename ThirdParty/Ert/lib/ecl/{ecl_box.c => ecl_box.cpp} (91%) rename ThirdParty/Ert/lib/ecl/{ecl_coarse_cell.c => ecl_coarse_cell.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{ecl_file.c => ecl_file.cpp} (98%) rename ThirdParty/Ert/lib/ecl/{ecl_file_kw.c => ecl_file_kw.cpp} (95%) rename ThirdParty/Ert/lib/ecl/{ecl_file_view.c => ecl_file_view.cpp} (93%) rename ThirdParty/Ert/lib/ecl/{ecl_grav.c => ecl_grav.cpp} (94%) rename ThirdParty/Ert/lib/ecl/{ecl_grav_calc.c => ecl_grav_calc.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{ecl_grav_common.c => ecl_grav_common.cpp} (94%) rename ThirdParty/Ert/lib/ecl/{ecl_grid.c => ecl_grid.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{ecl_grid_cache.c => ecl_grid_cache.cpp} (82%) rename ThirdParty/Ert/lib/ecl/{ecl_grid_dims.c => ecl_grid_dims.cpp} (91%) rename ThirdParty/Ert/lib/ecl/{ecl_init_file.c => ecl_init_file.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{ecl_io_config.c => ecl_io_config.cpp} (95%) rename ThirdParty/Ert/lib/ecl/{ecl_kw.c => ecl_kw.cpp} (88%) rename ThirdParty/Ert/lib/ecl/{ecl_kw_functions.c => ecl_kw_functions.cpp} (98%) rename ThirdParty/Ert/lib/ecl/{ecl_kw_grdecl.c => ecl_kw_grdecl.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{ecl_nnc_data.c => ecl_nnc_data.cpp} (95%) rename ThirdParty/Ert/lib/ecl/{ecl_nnc_export.c => ecl_nnc_export.cpp} (96%) rename ThirdParty/Ert/lib/ecl/{ecl_nnc_geometry.c => ecl_nnc_geometry.cpp} (88%) rename ThirdParty/Ert/lib/ecl/{ecl_region.c => ecl_region.cpp} (99%) rename ThirdParty/Ert/lib/ecl/{ecl_rft_cell.c => ecl_rft_cell.cpp} (94%) rename ThirdParty/Ert/lib/ecl/{ecl_rft_file.c => ecl_rft_file.cpp} (91%) rename ThirdParty/Ert/lib/ecl/{ecl_rft_node.c => ecl_rft_node.cpp} (92%) rename ThirdParty/Ert/lib/ecl/{ecl_rst_file.c => ecl_rst_file.cpp} (94%) rename ThirdParty/Ert/lib/ecl/{ecl_rsthead.c => ecl_rsthead.cpp} (93%) rename ThirdParty/Ert/lib/ecl/{ecl_smspec.c => ecl_smspec.cpp} (94%) rename ThirdParty/Ert/lib/ecl/{ecl_subsidence.c => ecl_subsidence.cpp} (90%) rename ThirdParty/Ert/lib/ecl/{ecl_sum.c => ecl_sum.cpp} (92%) rename ThirdParty/Ert/lib/ecl/{ecl_sum_data.c => ecl_sum_data.cpp} (88%) rename ThirdParty/Ert/lib/ecl/{ecl_sum_index.c => ecl_sum_index.cpp} (98%) rename ThirdParty/Ert/lib/ecl/{ecl_sum_tstep.c => ecl_sum_tstep.cpp} (93%) rename ThirdParty/Ert/lib/ecl/{ecl_sum_vector.c => ecl_sum_vector.cpp} (93%) rename ThirdParty/Ert/lib/ecl/{ecl_type.c => ecl_type.cpp} (91%) rename ThirdParty/Ert/lib/ecl/{ecl_type_python.c => ecl_type_python.cpp} (90%) rename ThirdParty/Ert/lib/ecl/{ecl_util.c => ecl_util.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{fault_block.c => fault_block.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{fault_block_layer.c => fault_block_layer.cpp} (96%) rename ThirdParty/Ert/lib/ecl/{grid_dims.c => grid_dims.cpp} (89%) rename ThirdParty/Ert/lib/ecl/{layer.c => layer.cpp} (98%) rename ThirdParty/Ert/lib/ecl/{nnc_info.c => nnc_info.cpp} (90%) rename ThirdParty/Ert/lib/ecl/{nnc_vector.c => nnc_vector.cpp} (91%) rename ThirdParty/Ert/lib/ecl/{smspec_node.c => smspec_node.cpp} (97%) rename ThirdParty/Ert/lib/ecl/{well_branch_collection.c => well_branch_collection.cpp} (87%) rename ThirdParty/Ert/lib/ecl/{well_conn.c => well_conn.cpp} (77%) rename ThirdParty/Ert/lib/ecl/{well_conn_collection.c => well_conn_collection.cpp} (86%) rename ThirdParty/Ert/lib/ecl/{well_info.c => well_info.cpp} (95%) rename ThirdParty/Ert/lib/ecl/{well_rseg_loader.c => well_rseg_loader.cpp} (85%) rename ThirdParty/Ert/lib/ecl/{well_segment.c => well_segment.cpp} (92%) rename ThirdParty/Ert/lib/ecl/{well_segment_collection.c => well_segment_collection.cpp} (90%) rename ThirdParty/Ert/lib/ecl/{well_state.c => well_state.cpp} (93%) rename ThirdParty/Ert/lib/ecl/{well_ts.c => well_ts.cpp} (90%) create mode 100644 ThirdParty/Ert/lib/ert_api_config.hpp.in rename ThirdParty/Ert/lib/geometry/{geo_pointset.c => geo_pointset.cpp} (92%) rename ThirdParty/Ert/lib/geometry/{geo_polygon.c => geo_polygon.cpp} (95%) rename ThirdParty/Ert/lib/geometry/{geo_polygon_collection.c => geo_polygon_collection.cpp} (86%) rename ThirdParty/Ert/lib/geometry/{geo_region.c => geo_region.cpp} (92%) rename ThirdParty/Ert/lib/geometry/{geo_surface.c => geo_surface.cpp} (97%) rename ThirdParty/Ert/lib/geometry/{geo_util.c => geo_util.cpp} (98%) create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp rename ThirdParty/Ert/lib/{ecl/ecl_sum_file.c => include/ert/ecl/ecl_kw_grdecl.hpp} (69%) create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/layer.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/buffer.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/hash.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/hash_node.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/lars.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/log.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/matrix.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/matrix_blas.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/matrix_stat.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/menu.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/msg.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/mzran.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/node_data.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/parser.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/path_fmt.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/path_stack.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/regression.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/rng.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/set.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/statistics.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/stepwise.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/string_util.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/stringlist.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/subst_func.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/thread_pool.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/time_interval.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/time_interval.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/timer.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/type_macros.hpp create mode 100644 ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/ui_return.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/util.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/util_env.h create mode 100644 ThirdParty/Ert/lib/include/ert/util/vector.hpp delete mode 100644 ThirdParty/Ert/lib/nexus/nexus_plot.cpp delete mode 100644 ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp delete mode 100644 ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp rename ThirdParty/Ert/lib/util/{arg_pack.c => arg_pack.cpp} (99%) rename ThirdParty/Ert/lib/util/{buffer.c => buffer.cpp} (98%) rename ThirdParty/Ert/lib/util/{ecl_version.c => ecl_version.cpp} (93%) rename ThirdParty/Ert/lib/util/{hash.c => hash.cpp} (99%) rename ThirdParty/Ert/lib/util/{hash_node.c => hash_node.cpp} (96%) rename ThirdParty/Ert/lib/util/{hash_sll.c => hash_sll.cpp} (97%) delete mode 100644 ThirdParty/Ert/lib/util/lars.c delete mode 100644 ThirdParty/Ert/lib/util/log.c rename ThirdParty/Ert/lib/util/{lookup_table.c => lookup_table.cpp} (97%) delete mode 100644 ThirdParty/Ert/lib/util/matrix.c delete mode 100644 ThirdParty/Ert/lib/util/matrix_blas.c delete mode 100644 ThirdParty/Ert/lib/util/matrix_lapack.c delete mode 100644 ThirdParty/Ert/lib/util/matrix_stat.c delete mode 100644 ThirdParty/Ert/lib/util/menu.c delete mode 100644 ThirdParty/Ert/lib/util/msg.c rename ThirdParty/Ert/lib/util/{mzran.c => mzran.cpp} (98%) rename ThirdParty/Ert/lib/util/{node_ctype.c => node_ctype.cpp} (95%) rename ThirdParty/Ert/lib/util/{node_data.c => node_data.cpp} (98%) rename ThirdParty/Ert/lib/util/{parser.c => parser.cpp} (99%) delete mode 100644 ThirdParty/Ert/lib/util/path_fmt.c rename ThirdParty/Ert/lib/util/{path_stack.c => path_stack.cpp} (97%) rename ThirdParty/Ert/lib/util/{perm_vector.c => perm_vector.cpp} (94%) delete mode 100644 ThirdParty/Ert/lib/util/regression.c rename ThirdParty/Ert/lib/util/{rng.c => rng.cpp} (98%) rename ThirdParty/Ert/lib/util/{set.c => set.cpp} (97%) rename ThirdParty/Ert/lib/util/{statistics.c => statistics.cpp} (97%) delete mode 100644 ThirdParty/Ert/lib/util/stepwise.c rename ThirdParty/Ert/lib/util/{string_util.c => string_util.cpp} (96%) rename ThirdParty/Ert/lib/util/{stringlist.c => stringlist.cpp} (99%) rename ThirdParty/Ert/lib/util/{struct_vector.c => struct_vector.cpp} (98%) delete mode 100644 ThirdParty/Ert/lib/util/subst_func.c rename ThirdParty/Ert/lib/util/{test_util.c => test_util.cpp} (98%) rename ThirdParty/Ert/lib/util/{test_work_area.c => test_work_area.cpp} (98%) delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_logh.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_matrix.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c delete mode 100644 ThirdParty/Ert/lib/util/thread_pool1.c delete mode 100644 ThirdParty/Ert/lib/util/thread_pool_posix.c delete mode 100644 ThirdParty/Ert/lib/util/time_interval.c rename ThirdParty/Ert/lib/util/{timer.c => timer.cpp} (98%) rename ThirdParty/Ert/lib/util/{type_vector_functions.c => type_vector_functions.cpp} (93%) delete mode 100644 ThirdParty/Ert/lib/util/ui_return.c rename ThirdParty/Ert/lib/util/{util_endian.c => util_endian.cpp} (100%) delete mode 100644 ThirdParty/Ert/lib/util/util_env.c rename ThirdParty/Ert/lib/util/{util_getuid.c => util_getuid.cpp} (99%) rename ThirdParty/Ert/lib/util/{util_lockf.c => util_lockf.cpp} (99%) rename ThirdParty/Ert/lib/util/{util_opendir.c => util_opendir.cpp} (99%) rename ThirdParty/Ert/lib/util/{util_spawn.c => util_spawn.cpp} (97%) rename ThirdParty/Ert/lib/util/{util_symlink.c => util_symlink.cpp} (94%) rename ThirdParty/Ert/lib/util/{util_unlink.c => util_unlink.cpp} (93%) rename ThirdParty/Ert/lib/util/{util_zlib.c => util_zlib.cpp} (97%) rename ThirdParty/Ert/lib/util/{vector.c => vector.cpp} (99%) rename ThirdParty/Ert/lib/util/{vector_template.c => vector_template.cpp} (99%) rename ThirdParty/Ert/lib/{util/thread_pool.c => vector_template.hpp.in} (71%) delete mode 100644 ThirdParty/Ert/python/python/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/cwrap/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/cwrap/__init__.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/basecclass.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/basecenum.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/basecvalue.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/cfile.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/clib.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/metacwrap.py delete mode 100644 ThirdParty/Ert/python/python/cwrap/prototype.py delete mode 100644 ThirdParty/Ert/python/python/ecl/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/cell.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_init_file.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/fortio.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/local.cmake delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in delete mode 100644 ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/cpolyline.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/geo_region.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/polyline.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/surface.py delete mode 100644 ThirdParty/Ert/python/python/ecl/geo/xyz_io.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/test/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/debug_msg.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/ert_test_context.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/extended_testcase.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/import_test_case.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/lint_test_case.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/path_context.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/source_enumerator.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/temp_area.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/test_area.py delete mode 100644 ThirdParty/Ert/python/python/ecl/test/test_run.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/util/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/arg_pack.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/bool_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/buffer.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/cthread_pool.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/ctime.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/cwd_context.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/double_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/hash.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/int_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/log.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/lookup_table.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/matrix.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/path_format.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/permutation_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/profiler.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/rng.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/stat.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/stringlist.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/thread_pool.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/time_vector.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/ui_return.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/util_func.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/vector_template.py delete mode 100644 ThirdParty/Ert/python/python/ecl/util/version.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/ecl/well/__init__.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_connection.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_info.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_segment.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_state.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_time_line.py delete mode 100644 ThirdParty/Ert/python/python/ecl/well/well_type_enum.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/test/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/util/__init__.py delete mode 100644 ThirdParty/Ert/python/python/legacy/ert/well/__init__.py delete mode 100644 ThirdParty/Ert/python/python/test_env.py.in delete mode 100644 ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/cwrap/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/cwrap/test_basecclass.py delete mode 100644 ThirdParty/Ert/python/tests/cwrap/test_basecenum.py delete mode 100644 ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py delete mode 100644 ThirdParty/Ert/python/tests/cwrap/test_cfile.py delete mode 100644 ThirdParty/Ert/python/tests/cwrap/test_metawrap.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/ecl/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_cell.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_debug.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_deprecation.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_file.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_type.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_ecl_util.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_faults.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_fortio.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_geertsma.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_grav.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_grdecl.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_grid.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_grid_generator.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_indexed_read.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_kw_function.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_layer.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_npv.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_region.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_region_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_removed.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_restart.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_restart_head.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_rft.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_rft_cell.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_sum.py delete mode 100644 ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/geometry/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_convex_hull.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_cpolyline.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_geo_region.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_intersection.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_polyline.py delete mode 100644 ThirdParty/Ert/python/tests/geometry/test_surface.py delete mode 100644 ThirdParty/Ert/python/tests/global/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/global/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/global/test_import.py delete mode 100644 ThirdParty/Ert/python/tests/global/test_pylint.py delete mode 100644 ThirdParty/Ert/python/tests/install/test_install.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/legacy/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/test_ecl.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/test_geo.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/test_test.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/test_util.py delete mode 100644 ThirdParty/Ert/python/tests/legacy/test_well.py delete mode 100644 ThirdParty/Ert/python/tests/share/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/share/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/share/test_synthesizer.py delete mode 100644 ThirdParty/Ert/python/tests/test_pylint.py delete mode 100644 ThirdParty/Ert/python/tests/util/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/util/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_arg_pack.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_cstring.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_cthread_pool.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_ctime.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_hash.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_log.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_lookup_table.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_matrix.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_path_context.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_path_fmt.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_rng.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_spawn.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_stat.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_string_list.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_thread_pool.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_ui_return.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_vectors.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_version.py delete mode 100644 ThirdParty/Ert/python/tests/util/test_work_area.py delete mode 100644 ThirdParty/Ert/python/tests/well/CMakeLists.txt delete mode 100644 ThirdParty/Ert/python/tests/well/__init__.py delete mode 100644 ThirdParty/Ert/python/tests/well/test_ecl_well.py delete mode 100644 ThirdParty/Ert/python/tests/well/test_ecl_well2.py delete mode 100644 ThirdParty/Ert/python/tests/well/test_ecl_well3.py delete mode 100644 ThirdParty/Ert/redhat/ert.ecl.spec diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 32abe5535f..b107893293 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -16,7 +16,7 @@ set(RESINSIGHT_DEV_VERSION ".109") set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") # https://github.com/Statoil/libecl -set(ECL_GITHUB_SHA "b31b055af2d6b887f47aec84c65ec497a5d12973") +set(ECL_GITHUB_SHA "0188b08081eb1ac4ade89ac224b8128b4c9b0481") # https://github.com/OPM/opm-flowdiagnostics set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f") diff --git a/ThirdParty/Ert/.travis.yml b/ThirdParty/Ert/.travis.yml index 78fa0c189b..5d137e94ad 100644 --- a/ThirdParty/Ert/.travis.yml +++ b/ThirdParty/Ert/.travis.yml @@ -24,8 +24,6 @@ env: matrix: fast_finish: true - allow_failures: - - env: PYTHON_VERSION=3.6 exclude: - os: osx compiler: gcc diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 070dc78d7e..6f1ab299fd 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -268,6 +268,13 @@ try_compile( HAVE_PID_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/ try_compile( HAVE_MODE_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mode_t.c ) try_compile( ERT_HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c) +if (ERT_HAVE_READLINKAT) + try_compile( ERT_HAVE_READLINKAT_DECLARATION + ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_readlinkat_decl.c + ) +endif() + set( BUILD_CXX ON ) try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp ) if (NOT HAVE_CXX_SHARED_PTR) @@ -357,9 +364,6 @@ if (ENABLE_PYTHON) endif() endif() -if (INSTALL_ERT) - install(EXPORT ecl-config DESTINATION share/cmake/ecl) -endif() - +install(EXPORT ecl-config DESTINATION share/cmake/ecl) export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/applications/ecl/esummary.c b/ThirdParty/Ert/applications/ecl/esummary.c deleted file mode 100644 index b7a7b4c75f..0000000000 --- a/ThirdParty/Ert/applications/ecl/esummary.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'esummary.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include - -#include -#include - - -void install_SIGNALS(void) { - signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ - signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ -} - -void usage() { - fprintf(stderr," The esummary.x program can be used to extract summary vectors from \n"); - fprintf(stderr," an ensemble of summary files: \n\n"); - fprintf(stderr," bash%% esummary.x ECLIPSE1.DATA ECLIPSE2.DATA KEY1 KEY2 ... \n\n"); - exit(1); -} - - -#define MISSING_STRING " 0.000" - - - -int main(int argc , char ** argv) { - install_SIGNALS(); - { - if (argc < 3) usage(); - - { - ecl_sum_type * first_ecl_sum = NULL; /* This governs the timing */ - vector_type * ecl_sum_list = vector_alloc_new(); - time_interval_type * time_union = NULL; - time_interval_type * time_intersect = NULL; - time_interval_type * time = NULL; - bool use_time_union = true; - - int load_count = 0; - int nvars; - char ** var_list; - bool * has_var; - - /** Loading the data */ - { - int iarg = 1; - /* Some sorting here??? */ - while (iarg < argc && util_file_exists( argv[iarg] )) { - char * path , * basename; - ecl_sum_type * ecl_sum; - util_alloc_file_components( argv[iarg] , &path , &basename , NULL); - fprintf(stderr,"Loading case: %s/%s" , path , basename); fflush(stderr); - ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":"); - if (ecl_sum) { - if (first_ecl_sum == NULL) { - first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */ - time_union = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); - time_intersect = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); - - if (use_time_union) - time = time_union; - else - time = time_intersect; - - vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); - load_count++; - } else { - const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum ); - if (time_interval_has_overlap(time , ti)) { - time_interval_intersect( time_intersect , ti ); - time_interval_extend( time_union , ti ); - - vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); - load_count++; - } else { - fprintf(stderr,"** Warning case:%s has no time overlap - discarded \n",ecl_sum_get_case( ecl_sum )); - ecl_sum_free( ecl_sum ); - } - } - } else - fprintf(stderr," --- no data found?!"); - - iarg++; - fprintf(stderr,"\n"); - util_safe_free( path ); - free( basename ); - } - } - if (load_count == 0) - usage(); - - nvars = argc - load_count - 1; - if (nvars == 0) util_exit(" --- No variables \n"); - var_list = &argv[load_count + 1]; - has_var = util_calloc( nvars , sizeof * has_var ); - - /* - Checking that the summary files have the various variables - - if a variable is missing from one of the cases it is - completely discarded. - */ - { - int iens,ivar; - - /* Checking the variables */ - for (ivar = 0; ivar < nvars; ivar++) - has_var[ivar] = true; - - for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { - const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens ); - for (ivar = 0; ivar < nvars; ivar++) { - if (has_var[ivar]) { - if (!ecl_sum_has_general_var( ecl_sum , var_list[ivar] )) { - fprintf(stderr,"** Warning: could not find variable: \'%s\' in case:%s - completely discarded.\n", var_list[ivar] , ecl_sum_get_case(ecl_sum)); - has_var[ivar] = false; - } - } - } - } - } - - if (!time_interval_equal(time_union , time_intersect )) { - fprintf(stderr,"** Warning: not all simulations have the same length. "); - if (use_time_union) - fprintf(stderr,"Using %s for missing values.\n" , MISSING_STRING); - else - fprintf(stderr,"Only showing common time period.\n"); - } - - /** The actual summary lookup. */ - { - time_t_vector_type * date_list = time_t_vector_alloc(0,0); - time_t start_time = time_interval_get_start( time ); - FILE * stream = stdout; - int iens,ivar,itime; - - ecl_util_init_month_range( date_list , time_interval_get_start( time ) , time_interval_get_end( time )); - for (itime = 0; itime < time_t_vector_size( date_list ); itime++) { - time_t current_time = time_t_vector_iget( date_list , itime ); - for (ivar = 0; ivar < nvars; ivar++) { /* Iterating over the variables */ - if (has_var[ivar]) { - for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { /* Iterating over the ensemble members */ - const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens ); - - if (ivar == 0 && iens == 0) { /* Display time info in the first columns */ - int day,month,year; - util_set_date_values_utc( current_time , &day , &month, &year); - fprintf(stream , "%7.2f %02d/%02d/%04d " , util_difftime_days( start_time , current_time ) , day , month , year); - } - - { - const time_interval_type * sim_time = ecl_sum_get_sim_time( ecl_sum ); - - if (time_interval_arg_before( sim_time , current_time)) - fprintf(stream , " %s " , MISSING_STRING); // We are before this case has data. - else if (time_interval_arg_after( sim_time , current_time)) - fprintf(stream , " %s " , MISSING_STRING); // We are after this case has data. - else { - double value = ecl_sum_get_general_var_from_sim_time(ecl_sum , current_time , var_list[ivar]); - fprintf(stream , " %12.3f " , value); - } - - } - } - } - } - fprintf(stream , "\n"); - } - time_t_vector_free( date_list ); - } - vector_free( ecl_sum_list ); - free( has_var ); - } - } -} diff --git a/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c b/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c new file mode 100644 index 0000000000..3d77e99904 --- /dev/null +++ b/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c @@ -0,0 +1,17 @@ +#include +#include + +#include + +#define NCHAR 63 + +int main(int argc, char *argv[]) +{ + char linkname[NCHAR + 1] = { 0 }; + ssize_t r; + + r = (argc < 2) ? -1 + : readlinkat(1, argv[1], linkname, NCHAR); + + return (r > 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index f1bcff4fdb..5852d41847 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -9,23 +9,23 @@ else() endif() if (ERT_HAVE_GETUID AND ERT_HAVE_OPENDIR) - list(APPEND opt_srcs util/test_work_area.c util/util_getuid.c) + list(APPEND opt_srcs util/test_work_area.cpp util/util_getuid.cpp) endif() if (ERT_HAVE_OPENDIR) - list(APPEND opt_srcs util/util_opendir.c) + list(APPEND opt_srcs util/util_opendir.cpp) endif() if (ERT_HAVE_SPAWN) - list(APPEND opt_srcs util/util_spawn.c) + list(APPEND opt_srcs util/util_spawn.cpp) endif() if (ERT_HAVE_LOCKF) - list(APPEND opt_srcs util/util_lockf.c) + list(APPEND opt_srcs util/util_lockf.cpp) endif () if (ERT_HAVE_UNISTD) - list(APPEND opt_srcs util/path_stack.c) + list(APPEND opt_srcs util/path_stack.cpp) endif () if (MSVC) @@ -36,20 +36,22 @@ foreach (type int double long time_t float) set(TYPE ${type}) set(SIGNED_TYPE true) configure_file(vector_template.h.in include/ert/util/${type}_vector.h) - configure_file(util/vector_template.c ${type}_vector.c) - list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c) + configure_file(vector_template.hpp.in include/ert/util/${type}_vector.hpp) + configure_file(util/vector_template.cpp ${type}_vector.cpp) + list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.cpp) endforeach () foreach (type bool size_t) set(TYPE ${type}) set(SIGNED_TYPE false) configure_file(vector_template.h.in include/ert/util/${type}_vector.h) - configure_file(util/vector_template.c ${type}_vector.c) - list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c) + configure_file(vector_template.hpp.in include/ert/util/${type}_vector.hpp) + configure_file(util/vector_template.cpp ${type}_vector.cpp) + list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.cpp) endforeach () if (ZLIB_FOUND) - list(APPEND opt_srcs util/util_zlib.c) + list(APPEND opt_srcs util/util_zlib.cpp) endif () if (ERT_BUILD_CXX) @@ -60,95 +62,96 @@ if (ERT_BUILD_CXX) ) endif () - configure_file(build_config.h.in include/ert/util/build_config.h) configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h) - -add_library(ecl util/rng.c - util/lookup_table.c - util/statistics.c - util/mzran.c - util/set.c - util/hash_node.c - util/hash_sll.c - util/hash.c - util/node_data.c - util/node_ctype.c +configure_file(build_config.hpp.in include/ert/util/build_config.hpp) +configure_file(ert_api_config.hpp.in include/ert/util/ert_api_config.hpp) + +add_library(ecl util/rng.cpp + util/lookup_table.cpp + util/statistics.cpp + util/mzran.cpp + util/set.cpp + util/hash_node.cpp + util/hash_sll.cpp + util/hash.cpp + util/node_data.cpp + util/node_ctype.cpp util/util.c - util/util_symlink.c + util/util_symlink.cpp util/util_lfs.c - util/util_unlink.c - util/arg_pack.c - util/vector.c - util/parser.c - util/stringlist.c - util/buffer.c - util/timer.c - util/string_util.c - util/type_vector_functions.c - util/ecl_version.c - util/struct_vector.c - util/perm_vector.c - util/test_util.c + util/util_unlink.cpp + util/arg_pack.cpp + util/vector.cpp + util/parser.cpp + util/stringlist.cpp + util/buffer.cpp + util/timer.cpp + util/string_util.cpp + util/type_vector_functions.cpp + util/ecl_version.cpp + util/struct_vector.cpp + util/perm_vector.cpp + util/test_util.cpp ${opt_srcs} - ecl/ecl_rsthead.c - ecl/ecl_sum_tstep.c - ecl/ecl_rst_file.c - ecl/ecl_init_file.c - ecl/ecl_grid_cache.c - ecl/smspec_node.c - ecl/ecl_kw_grdecl.c - ecl/ecl_file_kw.c - ecl/ecl_file_view.c - ecl/ecl_grav.c - ecl/ecl_grav_calc.c - ecl/ecl_smspec.c - ecl/ecl_sum_data.c - ecl/ecl_util.c - ecl/ecl_kw.c - ecl/ecl_sum.c - ecl/ecl_sum_vector.c + ecl/ecl_rsthead.cpp + ecl/ecl_sum_tstep.cpp + ecl/ecl_rst_file.cpp + ecl/ecl_init_file.cpp + ecl/ecl_grid_cache.cpp + ecl/smspec_node.cpp + ecl/ecl_kw_grdecl.cpp + ecl/ecl_file_kw.cpp + ecl/ecl_file_view.cpp + ecl/ecl_grav.cpp + ecl/ecl_grav_calc.cpp + ecl/ecl_smspec.cpp + ecl/ecl_sum_data.cpp + ecl/ecl_util.cpp + ecl/ecl_kw.cpp + ecl/ecl_sum.cpp + ecl/ecl_sum_vector.cpp ecl/fortio.c - ecl/ecl_rft_file.c - ecl/ecl_rft_node.c - ecl/ecl_rft_cell.c - ecl/ecl_grid.c - ecl/ecl_coarse_cell.c - ecl/ecl_box.c - ecl/ecl_io_config.c - ecl/ecl_file.c - ecl/ecl_region.c - ecl/ecl_subsidence.c - ecl/ecl_grid_dims.c - ecl/grid_dims.c - ecl/nnc_info.c - ecl/ecl_grav_common.c - ecl/nnc_vector.c - ecl/ecl_nnc_export.c - ecl/ecl_nnc_data.c - ecl/ecl_nnc_geometry.c - ecl/layer.c - ecl/fault_block.c - ecl/fault_block_layer.c - ecl/ecl_type.c - ecl/ecl_type_python.c - ecl/well_state.c - ecl/well_conn.c - ecl/well_info.c - ecl/well_ts.c - ecl/well_conn_collection.c - ecl/well_segment.c - ecl/well_segment_collection.c - ecl/well_branch_collection.c - ecl/well_rseg_loader.c - - geometry/geo_surface.c - geometry/geo_util.c - geometry/geo_pointset.c - geometry/geo_region.c - geometry/geo_polygon.c - geometry/geo_polygon_collection.c + ecl/ecl_rft_file.cpp + ecl/ecl_rft_node.cpp + ecl/ecl_rft_cell.cpp + ecl/ecl_grid.cpp + ecl/ecl_coarse_cell.cpp + ecl/ecl_box.cpp + ecl/ecl_io_config.cpp + ecl/ecl_file.cpp + ecl/ecl_region.cpp + ecl/ecl_subsidence.cpp + ecl/ecl_grid_dims.cpp + ecl/grid_dims.cpp + ecl/nnc_info.cpp + ecl/ecl_grav_common.cpp + ecl/nnc_vector.cpp + ecl/ecl_nnc_export.cpp + ecl/ecl_nnc_data.cpp + ecl/ecl_nnc_geometry.cpp + ecl/layer.cpp + ecl/fault_block.cpp + ecl/fault_block_layer.cpp + ecl/ecl_type.cpp + ecl/ecl_type_python.cpp + ecl/well_state.cpp + ecl/well_conn.cpp + ecl/well_info.cpp + ecl/well_ts.cpp + ecl/well_conn_collection.cpp + ecl/well_segment.cpp + ecl/well_segment_collection.cpp + ecl/well_branch_collection.cpp + ecl/well_rseg_loader.cpp + + geometry/geo_surface.cpp + geometry/geo_util.cpp + geometry/geo_pointset.cpp + geometry/geo_region.cpp + geometry/geo_polygon.cpp + geometry/geo_polygon_collection.cpp ) target_link_libraries(ecl PUBLIC ${m} @@ -190,7 +193,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) -if (INSTALL_ERT) + install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -215,7 +218,6 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () -endif() if (NOT BUILD_TESTS) return () diff --git a/ThirdParty/Ert/lib/build_config.hpp.in b/ThirdParty/Ert/lib/build_config.hpp.in new file mode 100644 index 0000000000..3c81293d5b --- /dev/null +++ b/ThirdParty/Ert/lib/build_config.hpp.in @@ -0,0 +1 @@ +#include diff --git a/ThirdParty/Ert/lib/ecl/FortIO.cpp b/ThirdParty/Ert/lib/ecl/FortIO.cpp index 7732390422..803640ad6e 100644 --- a/ThirdParty/Ert/lib/ecl/FortIO.cpp +++ b/ThirdParty/Ert/lib/ecl/FortIO.cpp @@ -19,8 +19,7 @@ #include -#include -#include +#include #include diff --git a/ThirdParty/Ert/lib/ecl/Smspec.cpp b/ThirdParty/Ert/lib/ecl/Smspec.cpp index 558c652bf8..ba81341bef 100644 --- a/ThirdParty/Ert/lib/ecl/Smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/Smspec.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace ERT { diff --git a/ThirdParty/Ert/lib/ecl/ecl_box.c b/ThirdParty/Ert/lib/ecl/ecl_box.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_box.c rename to ThirdParty/Ert/lib/ecl/ecl_box.cpp index 9c5b0350c1..f5fc900fab 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_box.c +++ b/ThirdParty/Ert/lib/ecl/ecl_box.cpp @@ -21,10 +21,10 @@ #include #include -#include +#include -#include -#include +#include +#include #define ECL_BOX_TYPE_ID 6610643 @@ -60,7 +60,7 @@ UTIL_SAFE_CAST_FUNCTION( ecl_box , ECL_BOX_TYPE_ID) */ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 , int __j1 , int __j2 , int __k1, int __k2) { - ecl_box_type * ecl_box = util_malloc(sizeof * ecl_box ); + ecl_box_type * ecl_box = (ecl_box_type *)util_malloc(sizeof * ecl_box ); UTIL_TYPE_ID_INIT( ecl_box , ECL_BOX_TYPE_ID); ecl_box->parent_grid = ecl_grid; /* Properties of the parent grid. */ @@ -102,8 +102,8 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 int global_counter = 0; int i,j,k; ecl_box->active_size = 0; - ecl_box->active_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list ); - ecl_box->global_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list ); + ecl_box->active_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list ); + ecl_box->global_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list ); for (k=k1; k <= k2; k++) for (j=j1; j <= j2; j++) for (i=i1; i <= i2; i++) { @@ -121,7 +121,7 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 } } - ecl_box->active_list = util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list ); + ecl_box->active_list = (int*)util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list ); } } return ecl_box; diff --git a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c rename to ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp index 3716b9fa0a..48e688d011 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c +++ b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp @@ -20,12 +20,12 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include /******************************************************************/ /* @@ -140,7 +140,7 @@ void ecl_coarse_cell_assert( ecl_coarse_cell_type * coarse_cell ) { ecl_coarse_cell_type * ecl_coarse_cell_alloc() { const int LARGE = 1 << 30; - ecl_coarse_cell_type * coarse_cell = util_malloc( sizeof * coarse_cell ); + ecl_coarse_cell_type * coarse_cell = (ecl_coarse_cell_type *) util_malloc( sizeof * coarse_cell ); UTIL_TYPE_ID_INIT( coarse_cell , ECL_COARSE_CELL_TYPE_ID ); coarse_cell->ijk[0] = LARGE; diff --git a/ThirdParty/Ert/lib/ecl/ecl_file.c b/ThirdParty/Ert/lib/ecl/ecl_file.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/ecl_file.c rename to ThirdParty/Ert/lib/ecl/ecl_file.cpp index 7c9d3f652c..510c87f2cf 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file.cpp @@ -22,21 +22,21 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /** This file implements functionality to load an ECLIPSE file in @@ -178,7 +178,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file , ECL_FILE_ID) ecl_file_type * ecl_file_alloc_empty( int flags ) { - ecl_file_type * ecl_file = util_malloc( sizeof * ecl_file ); + ecl_file_type * ecl_file = (ecl_file_type *)util_malloc( sizeof * ecl_file ); UTIL_TYPE_ID_INIT(ecl_file , ECL_FILE_ID); ecl_file->map_stack = vector_alloc_new(); ecl_file->inv_view = inv_map_alloc( ); @@ -800,7 +800,6 @@ ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file ) { return FRONTSIM; util_abort("%s: Simulator version value:%d not recognized \n",__func__ , int_value ); - return -1; } /* @@ -887,7 +886,7 @@ void ecl_file_push_block( ecl_file_type * ecl_file ) { } void ecl_file_pop_block( ecl_file_type * ecl_file ) { - ecl_file->active_view = vector_pop_back( ecl_file->map_stack ); + ecl_file->active_view = (ecl_file_view_type *)vector_pop_back( ecl_file->map_stack ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_kw.c b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_file_kw.c rename to ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp index d8fe735202..e07c9884d6 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_kw.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp @@ -21,12 +21,12 @@ #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #include /* @@ -69,7 +69,7 @@ struct ecl_file_kw_struct { /*****************************************************************/ inv_map_type * inv_map_alloc() { - inv_map_type * map = util_malloc( sizeof * map ); + inv_map_type * map = (inv_map_type *)util_malloc( sizeof * map ); map->file_kw_ptr = size_t_vector_alloc( 0 , 0 ); map->ecl_kw_ptr = size_t_vector_alloc( 0 , 0 ); map->sorted = false; @@ -137,7 +137,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file_kw , ECL_FILE_KW_TYPE_ID ) ecl_file_kw_type * ecl_file_kw_alloc0( const char * header , ecl_data_type data_type , int size , offset_type offset) { - ecl_file_kw_type * file_kw = util_malloc( sizeof * file_kw ); + ecl_file_kw_type * file_kw = (ecl_file_kw_type *)util_malloc( sizeof * file_kw ); UTIL_TYPE_ID_INIT( file_kw , ECL_FILE_KW_TYPE_ID ); file_kw->header = util_alloc_string_copy( header ); @@ -363,14 +363,14 @@ void ecl_file_kw_fwrite( const ecl_file_kw_type * file_kw , FILE * stream ) { util_fwrite_int( file_kw->kw_size , stream ); util_fwrite_offset( file_kw->file_offset , stream ); util_fwrite_int( ecl_type_get_type( file_kw->data_type ) , stream ); - util_fwrite_size_t( ecl_type_get_sizeof_ctype_fortio( file_kw->data_type ) , stream ); + util_fwrite_size_t( ecl_type_get_sizeof_iotype( file_kw->data_type ) , stream ); } ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) { - + size_t file_kw_size = ECL_STRING8_LENGTH + 2 * sizeof(int) + sizeof(offset_type) + sizeof(size_t); size_t buffer_size = num * file_kw_size; - char * buffer = util_malloc( buffer_size * sizeof * buffer ); + char * buffer = (char*)util_malloc( buffer_size * sizeof * buffer ); size_t num_read = fread( buffer, 1 , buffer_size , stream); if (num_read != buffer_size) { @@ -379,7 +379,7 @@ ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) { } { - ecl_file_kw_type ** kw_list = util_malloc( num * sizeof * kw_list ); + ecl_file_kw_type ** kw_list = (ecl_file_kw_type **)util_malloc( num * sizeof * kw_list ); for (int ikw = 0; ikw < num; ikw++) { int buffer_offset = ikw * file_kw_size; char header[ECL_STRING8_LENGTH + 1]; diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_view.c b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_file_view.c rename to ThirdParty/Ert/lib/ecl/ecl_file_view.cpp index 0d42d7fd7a..ed3e549ebd 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_view.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp @@ -17,17 +17,17 @@ */ -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct ecl_file_view_struct { @@ -71,7 +71,7 @@ const char * ecl_file_view_get_src_file( const ecl_file_view_type * file_view ) ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , inv_map_type * inv_map , bool owner ) { - ecl_file_view_type * ecl_file_view = util_malloc( sizeof * ecl_file_view ); + ecl_file_view_type * ecl_file_view = (ecl_file_view_type*)util_malloc( sizeof * ecl_file_view ); ecl_file_view->kw_list = vector_alloc_new(); ecl_file_view->kw_index = hash_alloc(); ecl_file_view->distinct_kw = stringlist_alloc_new(); @@ -84,7 +84,7 @@ ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , i } int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) { - const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); int global_index = int_vector_iget( index_vector , ith); return global_index; } @@ -106,7 +106,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) { { int i; for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i); const char * header = ecl_file_kw_get_header( file_kw ); if ( !hash_has_key( ecl_file_view->kw_index , header )) { int_vector_type * index_vector = int_vector_alloc( 0 , -1 ); @@ -115,7 +115,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) { } { - int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header); + int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header); int_vector_append( index_vector , i); } } @@ -128,7 +128,7 @@ bool ecl_file_view_has_kw( const ecl_file_view_type * ecl_file_view, const char ecl_file_kw_type * ecl_file_view_iget_file_kw( const ecl_file_view_type * ecl_file_view , int global_index) { - ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , global_index); + ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , global_index); return file_kw; } @@ -169,7 +169,7 @@ ecl_kw_type * ecl_file_view_iget_kw( const ecl_file_view_type * ecl_file_view , return ecl_file_view_get_kw(ecl_file_view, file_kw); } -void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, const char* kw, int index, const int_vector_type * index_map, char* buffer) { +void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, const char* kw, int index, const int_vector_type * index_map, char* io_buffer) { ecl_file_kw_type * file_kw = ecl_file_view_iget_named_file_kw( ecl_file_view , kw , index); if (fortio_assert_stream_open( ecl_file_view->fortio )) { @@ -177,7 +177,7 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons ecl_data_type data_type = ecl_file_kw_get_data_type(file_kw); int element_count = ecl_file_kw_get_size(file_kw); - ecl_kw_fread_indexed_data(ecl_file_view->fortio, offset + ECL_KW_HEADER_FORTIO_SIZE, data_type, element_count, index_map, buffer); + ecl_kw_fread_indexed_data(ecl_file_view->fortio, offset + ECL_KW_HEADER_FORTIO_SIZE, data_type, element_count, index_map, io_buffer); } } @@ -185,7 +185,7 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons int ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) { int global_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , kw)) { - const int_vector_type * index_list = hash_get( ecl_file_view->kw_index , kw ); + const int_vector_type * index_list = (const int_vector_type*)hash_get( ecl_file_view->kw_index , kw ); int index = 0; while (index < int_vector_size( index_list )) { const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index )); @@ -247,7 +247,7 @@ int ecl_file_view_iget_named_size( const ecl_file_view_type * ecl_file_view , co void ecl_file_view_replace_kw( ecl_file_view_type * ecl_file_view , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy) { int index = 0; while (index < vector_get_size( ecl_file_view->kw_list )) { - ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index ); + ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); if (ecl_file_kw_ptr_eq( ikw , old_kw)) { /* Found it; observe that the vector_iset() function will @@ -274,7 +274,7 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) { if (fortio_assert_stream_open( ecl_file_view->fortio )) { int index; for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) { - ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index ); + ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); ecl_file_kw_get_kw( ikw , ecl_file_view->fortio , ecl_file_view->inv_map); } loadOK = true; @@ -314,7 +314,7 @@ void ecl_file_view_free__( void * arg ) { int ecl_file_view_get_num_named_kw(const ecl_file_view_type * ecl_file_view , const char * kw) { if (hash_has_key(ecl_file_view->kw_index , kw)) { - const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); return int_vector_size( index_vector ); } else return 0; @@ -332,9 +332,9 @@ void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_typ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int global_index) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , global_index); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , global_index); const char * header = ecl_file_kw_get_header( file_kw ); - const int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header ); + const int_vector_type * index_vector = (const int_vector_type*)hash_get( ecl_file_view->kw_index , header ); const int * index_data = int_vector_get_const_ptr( index_vector ); int occurence = -1; @@ -354,7 +354,7 @@ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) { int i; for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i ); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i ); char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw)); fprintf(stream , "%-8s %7d:%s\n", ecl_file_kw_get_header( file_kw ) , @@ -376,7 +376,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence ); { - ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , kw_index ); + ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , kw_index ); while (true) { ecl_file_view_add_kw( block_map , file_kw ); @@ -385,7 +385,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e break; else { if (end_kw) { - file_kw = vector_iget(ecl_file_view->kw_list , kw_index); + file_kw = (ecl_file_kw_type*)vector_iget(ecl_file_view->kw_list , kw_index); if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0) break; } @@ -589,7 +589,7 @@ double ecl_file_view_iget_restart_sim_days(const ecl_file_view_type * ecl_file_v int ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) { int seqnum_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) { - const int_vector_type * intehead_index_list = hash_get( ecl_file_view->kw_index , INTEHEAD_KW ); + const int_vector_type * intehead_index_list = (const int_vector_type *)hash_get( ecl_file_view->kw_index , INTEHEAD_KW ); int index = 0; while (index < int_vector_size( intehead_index_list )) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index )); @@ -807,10 +807,10 @@ ecl_file_view_type * ecl_file_view_fread_alloc( fortio_type * fortio , int * fla ecl_file_transaction_type * ecl_file_view_start_transaction(ecl_file_view_type * file_view) { - ecl_file_transaction_type * t = util_malloc(sizeof * t); + ecl_file_transaction_type * t = (ecl_file_transaction_type *)util_malloc(sizeof * t); int size = ecl_file_view_get_size(file_view); t->file_view = file_view; - t->ref_count = util_malloc( size * sizeof * t->ref_count ); + t->ref_count = (int*)util_malloc( size * sizeof * t->ref_count ); for (int i = 0; i < size; i++) { ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i); ecl_file_kw_start_transaction(file_kw, &t->ref_count[i]); diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav.c b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_grav.c rename to ThirdParty/Ert/lib/ecl/ecl_grav.cpp index a763f111f0..5d25b9b966 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp @@ -20,19 +20,19 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -157,7 +157,7 @@ static const char * get_den_kw( ecl_phase_enum phase , ecl_version_enum ecl_vers static void ecl_grav_phase_ensure_work( ecl_grav_phase_type * grav_phase) { if (grav_phase->work == NULL) - grav_phase->work = util_calloc( ecl_grid_cache_get_size( grav_phase->grid_cache ) , sizeof * grav_phase->work ); + grav_phase->work = (double*)util_calloc( ecl_grid_cache_get_size( grav_phase->grid_cache ) , sizeof * grav_phase->work ); } @@ -213,19 +213,19 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , const ecl_grid_cache_type * grid_cache = ecl_grav->grid_cache; const char * sat_kw_name = ecl_util_get_phase_name( phase ); { - ecl_grav_phase_type * grav_phase = util_malloc( sizeof * grav_phase ); + ecl_grav_phase_type * grav_phase = (ecl_grav_phase_type*)util_malloc( sizeof * grav_phase ); const int size = ecl_grid_cache_get_size( grid_cache ); UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID ); grav_phase->grid_cache = grid_cache; grav_phase->aquifer_cell = ecl_grav->aquifer_cell; - grav_phase->fluid_mass = util_calloc( size , sizeof * grav_phase->fluid_mass ); + grav_phase->fluid_mass = (double*)util_calloc( size , sizeof * grav_phase->fluid_mass ); grav_phase->phase = phase; grav_phase->work = NULL; if (calc_type == GRAV_CALC_FIP) { ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 ); - double_vector_type * std_density = hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); + double_vector_type * std_density = (double_vector_type*)hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); ecl_kw_type * fip_kw; if ( phase == ECL_OIL_PHASE) @@ -349,7 +349,7 @@ static void ecl_grav_survey_add_phases( ecl_grav_type * ecl_grav , ecl_grav_surv static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav , const char * name , grav_calc_type calc_type) { - ecl_grav_survey_type * survey = util_malloc( sizeof * survey ); + ecl_grav_survey_type * survey = (ecl_grav_survey_type*)util_malloc( sizeof * survey ); UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID ); survey->grid_cache = ecl_grav->grid_cache; survey->aquifer_cell = ecl_grav->aquifer_cell; @@ -358,7 +358,7 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * survey->phase_map = hash_alloc(); if (calc_type & GRAV_CALC_USE_PORV) - survey->porv = util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv ); + survey->porv = (double*)util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv ); else survey->porv = NULL; @@ -549,10 +549,10 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey, int phase_nr; double deltag = 0; for (phase_nr = 0; phase_nr < vector_get_size( base_survey->phase_list ); phase_nr++) { - ecl_grav_phase_type * base_phase = vector_iget( base_survey->phase_list , phase_nr ); + ecl_grav_phase_type * base_phase = (ecl_grav_phase_type*)vector_iget( base_survey->phase_list , phase_nr ); if (base_phase->phase & phase_mask) { if (monitor_survey != NULL) { - const ecl_grav_phase_type * monitor_phase = vector_iget_const( monitor_survey->phase_list , phase_nr ); + const ecl_grav_phase_type * monitor_phase = (const ecl_grav_phase_type*)vector_iget_const( monitor_survey->phase_list , phase_nr ); deltag += ecl_grav_phase_eval( base_phase , monitor_phase , region , utm_x , utm_y , depth ); } else deltag += ecl_grav_phase_eval( base_phase , NULL , region , utm_x , utm_y , depth ); @@ -570,7 +570,7 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey, */ ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) { - ecl_grav_type * ecl_grav = util_malloc( sizeof * ecl_grav ); + ecl_grav_type * ecl_grav = (ecl_grav_type*)util_malloc( sizeof * ecl_grav ); ecl_grav->init_file = init_file; ecl_grav->grid_cache = ecl_grid_cache_alloc( ecl_grid ); ecl_grav->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( ecl_grav->grid_cache , ecl_grav->init_file ); @@ -619,7 +619,7 @@ static ecl_grav_survey_type * ecl_grav_get_survey( const ecl_grav_type * grav , return NULL; // Calling scope must determine if this is OK? else { if (hash_has_key( grav->surveys , name)) - return hash_get( grav->surveys , name ); + return (ecl_grav_survey_type*)hash_get( grav->surveys , name ); else { hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys ); fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n " , name); @@ -680,7 +680,7 @@ void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , dou void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density) { - double_vector_type * std_density = hash_get( grav->std_density , ecl_util_get_phase_name( phase )); + double_vector_type * std_density = (double_vector_type*)hash_get( grav->std_density , ecl_util_get_phase_name( phase )); double_vector_iset( std_density , pvtnum , density ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.c b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_grav_calc.c rename to ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp index 66618bbbe6..ae41b98c69 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp @@ -20,12 +20,12 @@ #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_common.c b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_grav_common.c rename to ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp index 024a44c09f..37da5a000c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_common.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp @@ -21,13 +21,14 @@ #include #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* This file contains code which is common to both the ecl_grav @@ -36,7 +37,7 @@ */ bool * ecl_grav_common_alloc_aquifer_cell( const ecl_grid_cache_type * grid_cache , const ecl_file_type * init_file) { - bool * aquifer_cell = util_calloc( ecl_grid_cache_get_size( grid_cache ) , sizeof * aquifer_cell ); + bool * aquifer_cell = (bool*)util_calloc( ecl_grid_cache_get_size( grid_cache ) , sizeof * aquifer_cell ); for (int active_index = 0; active_index < ecl_grid_cache_get_size( grid_cache ); active_index++) aquifer_cell[ active_index ] = false; diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.c b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_grid.c rename to ThirdParty/Ert/lib/ecl/ecl_grid.cpp index d04f6715d5..4f494d0ffc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp @@ -22,26 +22,26 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -861,7 +861,7 @@ static void ecl_cell_fwrite_GRID(const ecl_grid_type * grid, ecl_kw_fwrite( coords_kw , fortio ); { - float * corners = ecl_kw_get_void_ptr( corners_kw ); + float * corners = (float*)ecl_kw_get_void_ptr( corners_kw ); point_type point; int c; @@ -1288,7 +1288,8 @@ static double ecl_cell_get_signed_volume( ecl_cell_type * cell) { point_type corners[ 8 ]; memcpy( corners, cell->corner_list, sizeof( point_type ) * 8 ); - tetrahedron_type tet = { .p0 = center }; + tetrahedron_type tet; + tet.p0 = center; double volume = 0; /* using both tetrahedron decompositions - gives good agreement @@ -1567,7 +1568,7 @@ static void ecl_grid_free_cells( ecl_grid_type * grid ) { } static bool ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) { - grid->cells = malloc(grid->size * sizeof * grid->cells ); + grid->cells = (ecl_cell_type*)malloc(grid->size * sizeof * grid->cells ); if (!grid->cells) return false; @@ -1600,7 +1601,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, int nz, int lgr_nr, bool init_valid) { - ecl_grid_type * grid = util_malloc(sizeof * grid ); + ecl_grid_type * grid = (ecl_grid_type*)util_malloc(sizeof * grid ); UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID); grid->total_active = 0; grid->total_active_fracture = 0; @@ -1845,9 +1846,9 @@ static void ecl_grid_init_index_map__(ecl_grid_type * ecl_grid, static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { /* Creating the inverse mapping for the matrix cells. */ - ecl_grid->index_map = util_realloc(ecl_grid->index_map, + ecl_grid->index_map = (int*)util_realloc(ecl_grid->index_map, ecl_grid->size * sizeof * ecl_grid->index_map); - ecl_grid->inv_index_map = util_realloc(ecl_grid->inv_index_map, + ecl_grid->inv_index_map = (int*)util_realloc(ecl_grid->inv_index_map, ecl_grid->total_active * sizeof * ecl_grid->inv_index_map); ecl_grid_init_index_map__(ecl_grid, ecl_grid->index_map, @@ -1858,9 +1859,9 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { /* Create the inverse mapping for the fractures. */ if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { - ecl_grid->fracture_index_map = util_realloc(ecl_grid->fracture_index_map, + ecl_grid->fracture_index_map = (int*)util_realloc(ecl_grid->fracture_index_map, ecl_grid->size * sizeof * ecl_grid->fracture_index_map); - ecl_grid->inv_fracture_index_map = util_realloc(ecl_grid->inv_fracture_index_map, + ecl_grid->inv_fracture_index_map = (int*)util_realloc(ecl_grid->inv_fracture_index_map, ecl_grid->total_active_fracture * sizeof * ecl_grid->inv_fracture_index_map); ecl_grid_init_index_map__(ecl_grid, ecl_grid->fracture_index_map, @@ -2023,7 +2024,7 @@ static ecl_coarse_cell_type * ecl_grid_get_or_create_coarse_cell( ecl_grid_type if (vector_safe_iget( ecl_grid->coarse_cells , coarse_nr ) == NULL) vector_iset_owned_ref( ecl_grid->coarse_cells , coarse_nr , ecl_coarse_cell_alloc() , ecl_coarse_cell_free__); - return vector_iget( ecl_grid->coarse_cells , coarse_nr ); + return (ecl_coarse_cell_type*)vector_iget( ecl_grid->coarse_cells , coarse_nr ); } @@ -2044,7 +2045,7 @@ static void ecl_grid_init_coarse_cells( ecl_grid_type * ecl_grid ) { ecl_coarse_cell_type * ecl_grid_iget_coarse_group( const ecl_grid_type * ecl_grid , int coarse_nr ) { - return vector_iget( ecl_grid->coarse_cells , coarse_nr ); + return (ecl_coarse_cell_type*)vector_iget( ecl_grid->coarse_cells , coarse_nr ); } @@ -2123,7 +2124,7 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , bool apply_mapaxes } ecl_grid->origo[0] = mapaxes[2]; ecl_grid->origo[1] = mapaxes[3]; - ecl_grid->mapaxes = util_malloc( 6 * sizeof * ecl_grid->mapaxes ); + ecl_grid->mapaxes = (float*)util_malloc( 6 * sizeof * ecl_grid->mapaxes ); memcpy( ecl_grid->mapaxes , mapaxes , 6 * sizeof( float )); /* @@ -2230,10 +2231,10 @@ static void ecl_grid_install_lgr_GRID(ecl_grid_type * host_grid , ecl_grid_type static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_file_type * ecl_file , int grid_nr) { ecl_kw_type * lgrname_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1); - lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */ + lgr_grid->name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */ if (ecl_file_has_kw( ecl_file , LGR_PARENT_KW)) { ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr -1); - char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( parent_kw , 0)); + char * parent = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( parent_kw , 0)); if (strlen( parent ) > 0) lgr_grid->parent_name = parent; @@ -2251,7 +2252,7 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_fil static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file_type * ecl_file , int grid_nr) { ecl_kw_type * lgr_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1); - lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgr_kw , 0) ); /* trailing zeros are stripped away. */ + lgr_grid->name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgr_kw , 0) ); /* trailing zeros are stripped away. */ { /** the lgr keyword can have one or two elements; in the case of two elements @@ -2259,7 +2260,7 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file only one element the current lgr is assumed to descend from the main grid */ if (ecl_kw_get_size( lgr_kw ) == 2) { - char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( lgr_kw , 1)); + char * parent = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgr_kw , 1)); if ((strlen(parent) == 0) || (strcmp(parent , GLOBAL_STRING ) == 0)) free( parent ); @@ -2430,9 +2431,9 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, static void ecl_grid_copy_mapaxes( ecl_grid_type * target_grid , const ecl_grid_type * src_grid ) { target_grid->use_mapaxes = src_grid->use_mapaxes; if (src_grid->mapaxes) - target_grid->mapaxes = util_realloc_copy(target_grid->mapaxes , src_grid->mapaxes , 6 * sizeof * src_grid->mapaxes ); + target_grid->mapaxes = (float*)util_realloc_copy(target_grid->mapaxes , src_grid->mapaxes , 6 * sizeof * src_grid->mapaxes ); else - target_grid->mapaxes = util_realloc_copy(target_grid->mapaxes , NULL , 0 ); + target_grid->mapaxes = (float*)util_realloc_copy(target_grid->mapaxes , NULL , 0 ); for (int i=0; i < 2; i++) { target_grid->unit_x[i] = src_grid->unit_x[i]; @@ -2485,7 +2486,7 @@ ecl_grid_type * ecl_grid_alloc_copy( const ecl_grid_type * src_grid ) { { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( src_grid->LGR_list ); grid_nr++) { - const ecl_grid_type * src_lgr = vector_iget_const( src_grid->LGR_list , grid_nr); + const ecl_grid_type * src_lgr = (const ecl_grid_type*)vector_iget_const( src_grid->LGR_list , grid_nr); ecl_grid_type * copy_lgr = ecl_grid_alloc_copy__( src_lgr , copy_grid ); ecl_grid_type * host_grid; @@ -2528,12 +2529,12 @@ ecl_grid_type * ecl_grid_alloc_processed_copy( const ecl_grid_type * src_grid , } else { int nx,ny,nz,na; int zcorn_size = ecl_grid_get_zcorn_size( src_grid ); - float * zcorn_float = util_malloc( zcorn_size * sizeof * zcorn_float ); + float * zcorn_float = (float*)util_malloc( zcorn_size * sizeof * zcorn_float ); float * coord = ecl_grid_alloc_coord_data( src_grid ); float * mapaxes = NULL; if (ecl_grid_get_mapaxes( src_grid )) { - mapaxes = util_malloc( 6 * sizeof * mapaxes ); + mapaxes = (float*)util_malloc( 6 * sizeof * mapaxes ); ecl_grid_init_mapaxes_data_float(src_grid, mapaxes); } ecl_grid_get_dims( src_grid , &nx, &ny , &nz , &na); @@ -3160,8 +3161,8 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const int coords_size = -1; int index; - int ** coords = util_calloc( num_coords , sizeof * coords ); - float ** corners = util_calloc( num_coords , sizeof * corners ); + int ** coords = (int **)util_calloc( num_coords , sizeof * coords ); + float ** corners = (float**)util_calloc( num_coords , sizeof * corners ); for (index = 0; index < num_coords; index++) { const ecl_kw_type * coords_kw = ecl_file_iget_named_kw(ecl_file , COORDS_KW , index + cell_offset); @@ -3449,7 +3450,7 @@ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const do 0, true); if (grid) { int i, j, k; - double * y0 = util_calloc( nx, sizeof * y0 ); + double * y0 = (double*)util_calloc( nx, sizeof * y0 ); for (k=0; k < nz; k++) { for (i=0; i < nx; i++) { @@ -3744,8 +3745,8 @@ static bool ecl_grid_compare_coarse_cells(const ecl_grid_type * g1 , const ecl_g int c; for (c = 0; c < vector_get_size( g1->coarse_cells ); c++) { - const ecl_coarse_cell_type * coarse_cell1 = vector_iget_const( g1->coarse_cells , c); - const ecl_coarse_cell_type * coarse_cell2 = vector_iget_const( g2->coarse_cells , c); + const ecl_coarse_cell_type * coarse_cell1 = (const ecl_coarse_cell_type*)vector_iget_const( g1->coarse_cells , c); + const ecl_coarse_cell_type * coarse_cell2 = (const ecl_coarse_cell_type*)vector_iget_const( g2->coarse_cells , c); equal = ecl_coarse_cell_equal( coarse_cell1 , coarse_cell2 ); if (!equal) @@ -3909,8 +3910,8 @@ bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool if (vector_get_size( g1->LGR_list ) == vector_get_size( g2->LGR_list )) { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( g1->LGR_list ); grid_nr++) { - const ecl_grid_type * lgr1 = vector_iget_const( g1->LGR_list , grid_nr); - const ecl_grid_type * lgr2 = vector_iget_const( g2->LGR_list , grid_nr); + const ecl_grid_type * lgr1 = (const ecl_grid_type*)vector_iget_const( g1->LGR_list , grid_nr); + const ecl_grid_type * lgr2 = (const ecl_grid_type*)vector_iget_const( g2->LGR_list , grid_nr); printf("Comparing lgr grid:%d \n",grid_nr); equal = ecl_grid_compare__(lgr1 , lgr2 , include_nnc , verbose); @@ -4185,7 +4186,7 @@ int ecl_grid_get_global_index_from_xy_bottom( const ecl_grid_type * ecl_grid , d static void ecl_grid_clear_visited( ecl_grid_type * grid ) { if (grid->visited == NULL) - grid->visited = util_calloc( grid->size , sizeof * grid->visited ); + grid->visited = (bool*)util_calloc( grid->size , sizeof * grid->visited ); { int i; @@ -4407,7 +4408,7 @@ void ecl_grid_alloc_blocking_variables(ecl_grid_type * grid, int block_dim) { else util_abort("%: valid values are two and three. Value:%d invaid \n",__func__ , block_dim); - grid->values = util_calloc( grid->block_size , sizeof * grid->values ); + grid->values = (double_vector_type**)util_calloc( grid->block_size , sizeof * grid->values ); for (index = 0; index < grid->block_size; index++) grid->values[index] = double_vector_alloc( 0 , 0.0 ); } @@ -5128,7 +5129,7 @@ ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * _ __assert_main_grid( main_grid ); { char * lgr_name = util_alloc_strip_copy( __lgr_name ); - ecl_grid_type * lgr_grid = hash_get(main_grid->LGR_hash , lgr_name); + ecl_grid_type * lgr_grid = (ecl_grid_type*)hash_get(main_grid->LGR_hash , lgr_name); free(lgr_name); return lgr_grid; } @@ -5195,7 +5196,7 @@ int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ) { ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_index) { __assert_main_grid( main_grid ); - return vector_iget( main_grid->LGR_list , lgr_index); + return (ecl_grid_type*)vector_iget( main_grid->LGR_list , lgr_index); } /* @@ -5212,7 +5213,7 @@ ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, in __assert_main_grid( main_grid ); { int lgr_index = int_vector_iget( main_grid->lgr_index_map , lgr_nr ); - return vector_iget( main_grid->LGR_list , lgr_index); + return (ecl_grid_type*)vector_iget( main_grid->LGR_list , lgr_index); } } @@ -5276,7 +5277,7 @@ stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) { const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_index) { __assert_main_grid( ecl_grid ); if (lgr_index < (vector_get_size( ecl_grid->LGR_list ))) { - const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_index); + const ecl_grid_type * lgr = (const ecl_grid_type*)vector_iget( ecl_grid->LGR_list , lgr_index); return lgr->name; } else return NULL; @@ -5421,7 +5422,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) { int grid_nr; for (grid_nr=1; grid_nr < vector_get_size( ecl_grid->LGR_list ); grid_nr++) { printf("\n"); - ecl_grid_summarize( vector_iget_const( ecl_grid->LGR_list , grid_nr )); + ecl_grid_summarize( (const ecl_grid_type*)vector_iget_const( ecl_grid->LGR_list , grid_nr )); } } ecl_grid_test_lgr_consistency( ecl_grid ); @@ -5643,7 +5644,7 @@ int ecl_grid_get_region_cells(const ecl_grid_type * ecl_grid , const ecl_kw_type int cells_found = 0; if (ecl_kw_get_size( region_kw ) == ecl_grid->size) { if (ecl_type_is_int(ecl_kw_get_data_type( region_kw ))) { - const int * region_ptr = ecl_kw_iget_ptr( region_kw , 0); + const int * region_ptr = (const int*)ecl_kw_iget_ptr( region_kw , 0); int_vector_reset( index_list ); @@ -5748,7 +5749,7 @@ bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) { hash_iter_type * lgr_iter = hash_iter_alloc( ecl_grid->children ); bool consistent = true; while (!hash_iter_is_complete( lgr_iter )) { - const ecl_grid_type * lgr = hash_iter_get_next_value( lgr_iter ); + const ecl_grid_type * lgr = (const ecl_grid_type*)hash_iter_get_next_value( lgr_iter ); consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr ); consistent &= ecl_grid_test_lgr_consistency( lgr ); } @@ -5815,7 +5816,7 @@ void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream) { { int i; for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream ); + ecl_grid_dump__( (const ecl_grid_type*)vector_iget_const( grid->LGR_list , i) , stream ); } } @@ -5824,7 +5825,7 @@ void ecl_grid_dump_ascii(ecl_grid_type * grid , bool active_only , FILE * stream { int i; for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump_ascii__( vector_iget( grid->LGR_list , i) , active_only , stream ); + ecl_grid_dump_ascii__( (ecl_grid_type*)vector_iget( grid->LGR_list , i) , active_only , stream ); } } @@ -6068,7 +6069,7 @@ void ecl_grid_fwrite_GRID2( const ecl_grid_type * grid , const char * filename, { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - const ecl_grid_type * igrid = vector_iget_const( grid->LGR_list , grid_nr ); + const ecl_grid_type * igrid = (const ecl_grid_type*)vector_iget_const( grid->LGR_list , grid_nr ); ecl_grid_fwrite_GRID__( igrid , coords_size , fortio , output_unit ); } } @@ -6296,7 +6297,7 @@ void ecl_grid_init_coord_data_double( const ecl_grid_type * grid , double * coor float * ecl_grid_alloc_coord_data( const ecl_grid_type * grid ) { - float * coord = util_calloc( ecl_grid_get_coord_size(grid) , sizeof * coord ); + float * coord = (float*)util_calloc( ecl_grid_get_coord_size(grid) , sizeof * coord ); ecl_grid_init_coord_data( grid , coord ); return coord; } @@ -6304,7 +6305,7 @@ float * ecl_grid_alloc_coord_data( const ecl_grid_type * grid ) { void ecl_grid_assert_coord_kw( ecl_grid_type * grid ) { if (grid->coord_kw == NULL) { grid->coord_kw = ecl_kw_alloc( COORD_KW , ecl_grid_get_coord_size( grid ) , ECL_FLOAT); - ecl_grid_init_coord_data( grid , ecl_kw_get_void_ptr( grid->coord_kw )); + ecl_grid_init_coord_data( grid , (float*)ecl_kw_get_void_ptr( grid->coord_kw )); } } @@ -6366,7 +6367,7 @@ void ecl_grid_init_zcorn_data_double( const ecl_grid_type * grid , double * zcor float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ) { - float * zcorn = util_calloc( 8 * grid->size , sizeof * zcorn ); + float * zcorn = (float*)util_calloc( 8 * grid->size , sizeof * zcorn ); ecl_grid_init_zcorn_data( grid , zcorn ); return zcorn; } @@ -6375,7 +6376,7 @@ float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_zcorn_kw( const ecl_grid_type * grid ) { ecl_kw_type * zcorn_kw = ecl_kw_alloc( ZCORN_KW , ecl_grid_get_zcorn_size(grid), ECL_FLOAT); - ecl_grid_init_zcorn_data(grid , ecl_kw_get_void_ptr(zcorn_kw)); + ecl_grid_init_zcorn_data(grid , (float*)ecl_kw_get_void_ptr(zcorn_kw)); return zcorn_kw; } @@ -6444,7 +6445,7 @@ void ecl_grid_init_actnum_data( const ecl_grid_type * grid , int * actnum ) { int * ecl_grid_alloc_actnum_data( const ecl_grid_type * grid ) { - int * actnum = util_calloc( grid->size , sizeof * actnum); + int * actnum = (int*)util_calloc( grid->size , sizeof * actnum); ecl_grid_init_actnum_data( grid , actnum ); return actnum; } @@ -6453,7 +6454,7 @@ int * ecl_grid_alloc_actnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_actnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * actnum_kw = ecl_kw_alloc( ACTNUM_KW , grid->size , ECL_INT); - ecl_grid_init_actnum_data( grid , ecl_kw_get_void_ptr( actnum_kw )); + ecl_grid_init_actnum_data( grid , (int*)ecl_kw_get_void_ptr( actnum_kw )); return actnum_kw; } @@ -6499,7 +6500,7 @@ static void ecl_grid_init_hostnum_data( const ecl_grid_type * grid , int * hostn } int * ecl_grid_alloc_hostnum_data( const ecl_grid_type * grid ) { - int * hostnum = util_calloc( grid->size , sizeof * hostnum ); + int * hostnum = (int*)util_calloc( grid->size , sizeof * hostnum ); ecl_grid_init_hostnum_data( grid , hostnum ); return hostnum; } @@ -6507,7 +6508,7 @@ int * ecl_grid_alloc_hostnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * hostnum_kw = ecl_kw_alloc( HOSTNUM_KW , grid->size , ECL_INT); - ecl_grid_init_hostnum_data( grid , ecl_kw_get_void_ptr( hostnum_kw )); + ecl_grid_init_hostnum_data( grid , (int*)ecl_kw_get_void_ptr( hostnum_kw )); return hostnum_kw; } @@ -6522,7 +6523,7 @@ static void ecl_grid_init_corsnum_data( const ecl_grid_type * grid , int * corsn } int * ecl_grid_alloc_corsnum_data( const ecl_grid_type * grid ) { - int * corsnum = util_calloc( grid->size , sizeof * corsnum ); + int * corsnum = (int*)util_calloc( grid->size , sizeof * corsnum ); ecl_grid_init_corsnum_data( grid , corsnum ); return corsnum; } @@ -6530,7 +6531,7 @@ int * ecl_grid_alloc_corsnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_corsnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * corsnum_kw = ecl_kw_alloc( CORSNUM_KW , grid->size , ECL_INT); - ecl_grid_init_corsnum_data( grid , ecl_kw_get_void_ptr( corsnum_kw )); + ecl_grid_init_corsnum_data( grid , (int*)ecl_kw_get_void_ptr( corsnum_kw )); return corsnum_kw; } @@ -6698,7 +6699,7 @@ void ecl_grid_fwrite_EGRID2( ecl_grid_type * grid , const char * filename, ert_e { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); + ecl_grid_type * igrid = (ecl_grid_type*)vector_iget( grid->LGR_list , grid_nr ); ecl_grid_fwrite_EGRID__( igrid , fortio, output_unit ); } } @@ -6726,7 +6727,7 @@ void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename, bool o void ecl_grid_fwrite_depth( const ecl_grid_type * grid , fortio_type * init_file , ert_ecl_unit_enum output_unit) { ecl_kw_type * depth_kw = ecl_kw_alloc("DEPTH" , ecl_grid_get_nactive(grid) , ECL_FLOAT); { - float * depth_ptr = ecl_kw_get_ptr(depth_kw); + float * depth_ptr = (float*)ecl_kw_get_ptr(depth_kw); for (int i = 0; i < ecl_grid_get_nactive( grid ); i++) depth_ptr[i] = ecl_grid_get_cdepth1A( grid , i ); } @@ -6742,9 +6743,9 @@ void ecl_grid_fwrite_dims( const ecl_grid_type * grid , fortio_type * init_file, ecl_kw_type * dz = ecl_kw_alloc("DZ" , ecl_grid_get_nactive(grid) , ECL_FLOAT); { { - float * dx_ptr = ecl_kw_get_ptr(dx); - float * dy_ptr = ecl_kw_get_ptr(dy); - float * dz_ptr = ecl_kw_get_ptr(dz); + float * dx_ptr = (float*)ecl_kw_get_ptr(dx); + float * dy_ptr = (float*)ecl_kw_get_ptr(dy); + float * dz_ptr = (float*)ecl_kw_get_ptr(dz); for (int i = 0; i < ecl_grid_get_nactive( grid ); i++) { dx_ptr[i] = ecl_grid_get_cell_dx1A( grid , i ); @@ -6883,7 +6884,7 @@ int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) { { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); + ecl_grid_type * igrid = (ecl_grid_type*)vector_iget( grid->LGR_list , grid_nr ); num_nnc += ecl_grid_get_num_nnc__( igrid ); } } @@ -6894,7 +6895,7 @@ int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) { static ecl_kw_type * ecl_grid_alloc_volume_kw_active( const ecl_grid_type * grid) { ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_active_size(grid) , ECL_DOUBLE); { - double * volume_data = ecl_kw_get_ptr( volume_kw ); + double * volume_data = (double*)ecl_kw_get_ptr( volume_kw ); int active_index; for (active_index = 0; active_index < ecl_grid_get_active_size(grid); active_index++) { double cell_volume = ecl_grid_get_cell_volume1A(grid , active_index); @@ -6908,7 +6909,7 @@ static ecl_kw_type * ecl_grid_alloc_volume_kw_active( const ecl_grid_type * grid static ecl_kw_type * ecl_grid_alloc_volume_kw_global( const ecl_grid_type * grid) { ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_global_size(grid) , ECL_DOUBLE); { - double * volume_data = ecl_kw_get_ptr( volume_kw ); + double * volume_data = (double*)ecl_kw_get_ptr( volume_kw ); int global_index; for (global_index = 0; global_index < ecl_grid_get_global_size(grid); global_index++) { double cell_volume = ecl_grid_get_cell_volume1(grid , global_index); diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.c b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp similarity index 82% rename from ThirdParty/Ert/lib/ecl/ecl_grid_cache.c rename to ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp index 3c11f46231..f856b9cc41 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp @@ -21,13 +21,13 @@ #include #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include @@ -54,15 +54,15 @@ struct ecl_grid_cache_struct { ecl_grid_cache_type * ecl_grid_cache_alloc( const ecl_grid_type * grid ) { - ecl_grid_cache_type * grid_cache = util_malloc( sizeof * grid_cache ); + ecl_grid_cache_type * grid_cache = (ecl_grid_cache_type*)util_malloc( sizeof * grid_cache ); grid_cache->grid = grid; grid_cache->volume = NULL; grid_cache->size = ecl_grid_get_active_size( grid ); - grid_cache->xpos = util_calloc( grid_cache->size , sizeof * grid_cache->xpos ); - grid_cache->ypos = util_calloc( grid_cache->size , sizeof * grid_cache->ypos ); - grid_cache->zpos = util_calloc( grid_cache->size , sizeof * grid_cache->zpos ); - grid_cache->global_index = util_calloc( grid_cache->size , sizeof * grid_cache->global_index ); + grid_cache->xpos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->xpos ); + grid_cache->ypos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->ypos ); + grid_cache->zpos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->zpos ); + grid_cache->global_index = (int*)util_calloc( grid_cache->size , sizeof * grid_cache->global_index ); { int active_index; @@ -113,7 +113,7 @@ const double * ecl_grid_cache_get_volume( const ecl_grid_cache_type * grid_cache if (!grid_cache->volume) { // C++ style const cast. ecl_grid_cache_type * gc = (ecl_grid_cache_type *) grid_cache; - gc->volume = util_calloc( gc->size , sizeof * gc->volume ); + gc->volume = (double*)util_calloc( gc->size , sizeof * gc->volume ); for (int active_index = 0; active_index < grid_cache->size; active_index++) gc->volume[active_index] = ecl_grid_get_cell_volume1A( gc->grid , active_index ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.c b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_grid_dims.c rename to ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp index 23d4b40838..24e6b671c3 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp @@ -18,15 +18,15 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include struct ecl_grid_dims_struct { @@ -101,7 +101,7 @@ ecl_grid_dims_type * ecl_grid_dims_alloc( const char * grid_file , const char * if ((grid_file_type == ECL_GRID_FILE) || (grid_file_type == ECL_EGRID_FILE)) { fortio_type * grid_fortio = fortio_open_reader( grid_file , grid_fmt_file , ECL_ENDIAN_FLIP ); if (grid_fortio) { - grid_dims = util_malloc( sizeof * grid_dims ); + grid_dims = (ecl_grid_dims_type*)util_malloc( sizeof * grid_dims ); grid_dims->dims_list = vector_alloc_new( ); { @@ -144,6 +144,6 @@ int ecl_grid_dims_get_num_grids( const ecl_grid_dims_type * grid_dims ) { const grid_dims_type * ecl_grid_dims_iget_dims( const ecl_grid_dims_type * grid_dims , int grid_nr ) { - return vector_iget_const( grid_dims->dims_list , grid_nr ); + return (const grid_dims_type*)vector_iget_const( grid_dims->dims_list , grid_nr ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_init_file.c b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_init_file.c rename to ThirdParty/Ert/lib/ecl/ecl_init_file.cpp index eb20dc8674..98b1ce5ba9 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_init_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp @@ -31,14 +31,15 @@ */ -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include static ecl_kw_type * ecl_init_file_alloc_INTEHEAD( const ecl_grid_type * ecl_grid , ert_ecl_unit_enum unit_system, int phases, time_t start_date , int simulator) { ecl_kw_type * intehead_kw = ecl_kw_alloc( INTEHEAD_KW , INTEHEAD_INIT_SIZE , ECL_INT ); diff --git a/ThirdParty/Ert/lib/ecl/ecl_io_config.c b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_io_config.c rename to ThirdParty/Ert/lib/ecl/ecl_io_config.cpp index 924bc15c6b..5c5ee3a4d8 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_io_config.c +++ b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp @@ -20,10 +20,10 @@ #include #include -#include +#include -#include -#include +#include +#include /** @@ -61,7 +61,7 @@ struct ecl_io_config_struct { /*****************************************************************/ static ecl_io_config_type * ecl_io_config_alloc__() { - ecl_io_config_type * ecl_io_config = util_malloc(sizeof * ecl_io_config ); + ecl_io_config_type * ecl_io_config = (ecl_io_config_type*)util_malloc(sizeof * ecl_io_config ); ecl_io_config->formatted = FMT_UNDEFINED; ecl_io_config->unified_restart = UNIF_UNDEFINED; diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw.c b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp similarity index 88% rename from ThirdParty/Ert/lib/ecl/ecl_kw.c rename to ThirdParty/Ert/lib/ecl/ecl_kw.cpp index 82dd68a1d2..8fed785eed 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp @@ -22,15 +22,15 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include -#include -#include +#include +#include #define ECL_KW_TYPE_ID 6111098 @@ -162,7 +162,7 @@ void ecl_kw_set_data_type(ecl_kw_type * ecl_kw, ecl_data_type data_type); static char * alloc_read_fmt_string(const ecl_data_type ecl_type) { return util_alloc_sprintf( "%%%dc", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -191,7 +191,7 @@ static char * alloc_read_fmt(const ecl_data_type data_type ) { static char * alloc_write_fmt_string(const ecl_data_type ecl_type) { return util_alloc_sprintf( " '%%-%ds'", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -258,12 +258,105 @@ static void ecl_kw_assert_index(const ecl_kw_type *ecl_kw , int index, const cha -static void ecl_kw_endian_convert_data(ecl_kw_type *ecl_kw) { - if (ecl_type_is_numeric(ecl_kw->data_type) || ecl_type_is_bool(ecl_kw->data_type)) - util_endian_flip_vector(ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); +static char * ecl_kw_alloc_output_buffer(const ecl_kw_type * ecl_kw) { + size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + size_t buffer_size = ecl_kw->size * sizeof_iotype; + char * buffer = (char*)util_malloc( buffer_size ); + + if (ecl_type_is_bool(ecl_kw->data_type)) { + int * int_data = (int *) buffer; + bool * bool_data = (bool *) ecl_kw->data; + + for (int i=0; i < ecl_kw->size; i++) + if (bool_data[i]) + int_data[i] = ECL_BOOL_TRUE_INT; + else + int_data[i] = ECL_BOOL_FALSE_INT; + + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + return buffer; + } + + + if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); + for (int i=0; i < ecl_kw->size; i++) { + size_t buffer_offset = i * sizeof_iotype; + size_t data_offset = i * sizeof_ctype; + memcpy(&buffer[buffer_offset], &ecl_kw->data[data_offset], sizeof_iotype); + } + + return buffer; + } + + if (ecl_type_is_mess(ecl_kw->data_type)) + return buffer; + + memcpy(buffer, ecl_kw->data, buffer_size); + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + return buffer; +} + + +static char * ecl_kw_alloc_input_buffer(const ecl_kw_type * ecl_kw) { + size_t buffer_size = ecl_kw->size * ecl_type_get_sizeof_iotype(ecl_kw->data_type); + char * buffer = (char*)util_malloc( buffer_size ); + + return buffer; +} + + +static void ecl_kw_load_from_input_buffer(ecl_kw_type * ecl_kw, char * buffer) { + size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); + size_t buffer_size = ecl_kw->size * sizeof_iotype; + if (ECL_ENDIAN_FLIP) { + if (ecl_type_is_numeric(ecl_kw->data_type) || ecl_type_is_bool(ecl_kw->data_type)) + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + } + + /* + Special case bool: Return Eclipse integer representation of bool to native bool. + */ + if (ecl_type_is_bool(ecl_kw->data_type)) { + int * int_data = (int *) buffer; + bool * bool_data = (bool *) ecl_kw->data; + + for (int i=0; i < ecl_kw->size; i++) { + if (int_data[i] == ECL_BOOL_TRUE_INT) + bool_data[i] = true; + else + bool_data[i] = false; + } + return; + } + + /* + Special case: insert '\0' termination at end of strings loaded from file. + */ + if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { + const char null_char = '\0'; + for (int i=0; i < ecl_kw->size; i++) { + size_t buffer_offset = i * sizeof_iotype; + size_t data_offset = i * sizeof_ctype; + memcpy(&ecl_kw->data[data_offset], &buffer[buffer_offset], sizeof_iotype); + ecl_kw->data[data_offset + sizeof_iotype] = null_char; + } + return; + } + + if (ecl_type_is_mess(ecl_kw->data_type)) + return; + + /* + Plain int, double, float data - that can be copied straight over to the ->data field. + */ + memcpy(ecl_kw->data, buffer, buffer_size); } + + const char * ecl_kw_get_header8(const ecl_kw_type *ecl_kw) { return ecl_kw->header8; } @@ -282,7 +375,7 @@ bool ecl_kw_name_equal( const ecl_kw_type * ecl_kw , const char * name) { void ecl_kw_get_memcpy_data(const ecl_kw_type *ecl_kw , void *target) { - memcpy(target , ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(target , ecl_kw->data , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw , int * target) { @@ -303,14 +396,14 @@ if (ecl_type_is_double(ecl_kw->data_type)) /** Allocates a untyped buffer with exactly the same content as the ecl_kw instances data. */ void * ecl_kw_alloc_data_copy(const ecl_kw_type * ecl_kw) { - void * buffer = util_alloc_copy( ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw) ); + void * buffer = util_alloc_copy( ecl_kw->data , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type) ); return buffer; } void ecl_kw_set_memcpy_data(ecl_kw_type *ecl_kw , const void *src) { if (src != NULL) - memcpy(ecl_kw->data , src , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , src , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } @@ -363,7 +456,7 @@ bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2) } static bool ecl_kw_data_equal__( const ecl_kw_type * ecl_kw , const void * data , int cmp_elements) { - int cmp = memcmp( ecl_kw->data , data , cmp_elements * ecl_kw_get_sizeof_ctype(ecl_kw)); + int cmp = memcmp( ecl_kw->data , data , cmp_elements * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); if (cmp == 0) return true; else @@ -468,7 +561,7 @@ static void ecl_kw_set_shared_ref(ecl_kw_type * ecl_kw , void *data_ptr) { util_abort("%s: can not change to shared for keyword with allocated storage - aborting \n",__func__); } ecl_kw->shared_data = true; - ecl_kw->data = data_ptr; + ecl_kw->data = (char*)data_ptr; } @@ -484,7 +577,7 @@ static size_t ecl_kw_fortio_data_size( const ecl_kw_type * ecl_kw) { const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); return num_blocks * (4 + 4) + // Fortran fluff for each block - ecl_kw->size * ecl_type_get_sizeof_ctype_fortio( ecl_kw->data_type ); // Actual data + ecl_kw->size * ecl_type_get_sizeof_iotype( ecl_kw->data_type ); // Actual data } @@ -543,7 +636,7 @@ ecl_kw_type * ecl_kw_alloc_new_shared(const char * header , int size, ecl_data_ ecl_kw_type * ecl_kw_alloc_empty() { ecl_kw_type *ecl_kw; - ecl_kw = util_malloc(sizeof *ecl_kw ); + ecl_kw = (ecl_kw_type*)util_malloc(sizeof *ecl_kw ); ecl_kw->header = NULL; ecl_kw->header8 = NULL; ecl_kw->data = NULL; @@ -573,7 +666,7 @@ void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src) { if (!ecl_kw_size_and_type_equal( target , src )) util_abort("%s: type/size mismatch \n",__func__); - memcpy(target->data , src->data , target->size * ecl_kw_get_sizeof_ctype(target)); + memcpy(target->data , src->data , target->size * ecl_type_get_sizeof_ctype(target->data_type)); } @@ -589,10 +682,10 @@ void ecl_kw_memcpy(ecl_kw_type *target, const ecl_kw_type *src) { ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { - ecl_kw_type *new; - new = ecl_kw_alloc_empty(); - ecl_kw_memcpy(new , src); - return new; + ecl_kw_type *new_; + new_ = ecl_kw_alloc_empty(); + ecl_kw_memcpy(new_ , src); + return new_; } /** @@ -637,7 +730,7 @@ ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int int target_index = 0; const char * src_ptr = src->data; char * new_ptr = new_kw->data; - int sizeof_ctype = ecl_kw_get_sizeof_ctype(new_kw); + int sizeof_ctype = ecl_type_get_sizeof_ctype(new_kw->data_type); while ( src_index < index2 ) { memcpy( &new_ptr[ target_index * sizeof_ctype ] , &src_ptr[ src_index * sizeof_ctype ] , sizeof_ctype ); @@ -658,10 +751,10 @@ void ecl_kw_resize( ecl_kw_type * ecl_kw, int new_size) { util_abort("%s: trying to allocate data for ecl_kw object which has been declared with shared storage - aborting \n",__func__); if (new_size != ecl_kw->size) { - size_t old_byte_size = ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw); - size_t new_byte_size = new_size * ecl_kw_get_sizeof_ctype(ecl_kw); + size_t old_byte_size = ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + size_t new_byte_size = new_size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); - ecl_kw->data = util_realloc(ecl_kw->data , new_byte_size ); + ecl_kw->data = (char*)util_realloc(ecl_kw->data , new_byte_size ); if (new_byte_size > old_byte_size) { size_t offset = old_byte_size; memset(&ecl_kw->data[offset] , 0 , new_byte_size - old_byte_size); @@ -703,18 +796,19 @@ const void * ecl_kw_copyc__(const void * void_kw) { static void * ecl_kw_iget_ptr_static(const ecl_kw_type *ecl_kw , int i) { ecl_kw_assert_index(ecl_kw , i , __func__); - return &ecl_kw->data[i * ecl_kw_get_sizeof_ctype(ecl_kw)]; + return &ecl_kw->data[i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]; } static void ecl_kw_iget_static(const ecl_kw_type *ecl_kw , int i , void *iptr) { - memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } static void ecl_kw_iset_static(ecl_kw_type *ecl_kw , int i , const void *iptr) { + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); ecl_kw_assert_index(ecl_kw , i , __func__); - memcpy(&ecl_kw->data[i * ecl_kw_get_sizeof_ctype(ecl_kw)] , iptr, ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(&ecl_kw->data[i * sizeof_ctype] , iptr, sizeof_ctype); } @@ -768,34 +862,20 @@ ctype ecl_kw_iget_ ## ctype(const ecl_kw_type * ecl_kw, int i) { ECL_KW_IGET_TYPED(double , ECL_DOUBLE_TYPE); ECL_KW_IGET_TYPED(float , ECL_FLOAT_TYPE); ECL_KW_IGET_TYPED(int , ECL_INT_TYPE); +ECL_KW_IGET_TYPED(bool , ECL_BOOL_TYPE); #undef ECL_KW_IGET_TYPED -bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - ecl_kw_iget_static(ecl_kw , i , &int_value); - if (int_value == ECL_BOOL_TRUE_INT) - return true; - else if (int_value == ECL_BOOL_FALSE_INT) - return false; - else { - util_abort("%s: fuckup - wrong integer in BOOL type \n",__func__); - return false; - } -} - const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i) { if (ecl_kw_get_type(ecl_kw) != ECL_CHAR_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - return ecl_kw_iget_ptr( ecl_kw , i ); + return (const char *)ecl_kw_iget_ptr( ecl_kw , i ); } const char * ecl_kw_iget_string_ptr( const ecl_kw_type * ecl_kw, int i) { if (ecl_kw_get_type(ecl_kw) != ECL_STRING_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - return ecl_kw_iget_ptr( ecl_kw , i ); + return (const char *)ecl_kw_iget_ptr( ecl_kw , i ); } @@ -864,7 +944,7 @@ void ecl_kw_iset_string_ptr( ecl_kw_type * ecl_kw, int index, const char * s) { } size_t input_len = strlen(s); - size_t type_len = ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw)); + size_t type_len = ecl_type_get_sizeof_iotype(ecl_kw->data_type); if(input_len > type_len) util_abort("%s: String of length %d cannot hold input string of length %d\n", __func__, type_len, input_len); @@ -892,9 +972,9 @@ void ecl_kw_iset_string_ptr( ecl_kw_type * ecl_kw, int index, const char * s) { */ bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * other_string) { - const char * kw_string = ecl_kw_iget_char_ptr( ecl_kw , index ); + const char * kw_string = (const char *)ecl_kw_iget_char_ptr( ecl_kw , index ); if (strlen(other_string)) { - char * match = strstr( kw_string , other_string); + const char * match = strstr( kw_string , other_string); if (match == kw_string) return true; } @@ -914,6 +994,7 @@ void ecl_kw_iset_ ## ctype(ecl_kw_type * ecl_kw, int i, ctype value) { ECL_KW_ISET_TYPED(double , ECL_DOUBLE_TYPE); ECL_KW_ISET_TYPED(float , ECL_FLOAT_TYPE); ECL_KW_ISET_TYPED(int , ECL_INT_TYPE); +ECL_KW_ISET_TYPED(bool , ECL_BOOL_TYPE); #undef ECL_KW_ISET_TYPED @@ -978,20 +1059,6 @@ ECL_KW_SCALE_INDEXED( int , ECL_INT_TYPE); #undef ECL_KW_SCALE_INDEXED -void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - - if (bool_value) - int_value = ECL_BOOL_TRUE_INT; - else - int_value = ECL_BOOL_FALSE_INT; - - ecl_kw_iset_static(ecl_kw , i , &int_value); -} - - /*****************************************************************/ /* Various ways to get pointers to the underlying data. */ @@ -1006,6 +1073,7 @@ ctype * ecl_kw_get_ ## ctype ## _ptr(const ecl_kw_type * ecl_kw) { ECL_KW_GET_TYPED_PTR(double , ECL_DOUBLE_TYPE); ECL_KW_GET_TYPED_PTR(float , ECL_FLOAT_TYPE); ECL_KW_GET_TYPED_PTR(int , ECL_INT_TYPE); +ECL_KW_GET_TYPED_PTR(bool , ECL_BOOL_TYPE); #undef ECL_KW_GET_TYPED_PTR void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw) { @@ -1091,7 +1159,6 @@ static double __fscanf_ECL_double( FILE * stream , const char * fmt) { } bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - const char null_char = '\0'; bool fmt_file = fortio_fmt_file( fortio ); if (ecl_kw->size > 0) { const int blocksize = get_blocksize( ecl_kw->data_type ); @@ -1113,7 +1180,7 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { ecl_kw_fscanf_qstring( &ecl_kw->data[offset], read_fmt, - ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw)), + ecl_type_get_sizeof_iotype(ecl_kw_get_data_type(ecl_kw)), stream ); break; @@ -1121,16 +1188,19 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { { int iread = fscanf(stream , read_fmt , (int *) &ecl_kw->data[offset]); if (iread != 1) - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , offset / ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->header8 , fortio_filename_ref(fortio)); + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__, + offset / ecl_type_get_sizeof_ctype(ecl_kw->data_type), + ecl_kw->header8, + fortio_filename_ref(fortio)); } break; case(ECL_FLOAT_TYPE): { int iread = fscanf(stream , read_fmt , (float *) &ecl_kw->data[offset]); if (iread != 1) { - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , - offset / ecl_kw_get_sizeof_ctype(ecl_kw) , - ecl_kw->header8 , + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__, + offset / ecl_type_get_sizeof_ctype(ecl_kw->data_type), + ecl_kw->header8, fortio_filename_ref(fortio)); } } @@ -1161,7 +1231,7 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { default: util_abort("%s: Internal error: internal eclipse_type: %d not recognized - aborting \n",__func__ , ecl_kw_get_type(ecl_kw)); } - offset += ecl_kw_get_sizeof_ctype(ecl_kw); + offset += ecl_type_get_sizeof_ctype(ecl_kw->data_type); index++; } } @@ -1171,46 +1241,14 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { free(read_fmt); return true; } else { - bool read_ok = true; - if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { - const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); - int ib = 0; - while (true) { - /* - Due to the necessary terminating \0 characters there is - not a continous file/memory mapping. - */ - int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; - FILE * stream = fortio_get_FILE(fortio); - int record_size = fortio_init_read(fortio); - if (record_size >= 0) { - int ir; - const int sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); - const int sizeof_ctype_fortio = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type); - for (ir = 0; ir < read_elm; ir++) { - util_fread( &ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype] , 1 , sizeof_ctype_fortio , stream , __func__); - ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype + sizeof_ctype_fortio] = null_char; - } - read_ok = fortio_complete_read(fortio , record_size); - } else - read_ok = false; + char * buffer = ecl_kw_alloc_input_buffer(ecl_kw); + const int sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + bool read_ok = fortio_fread_buffer(fortio, buffer, ecl_kw->size * sizeof_iotype); - if (!read_ok) - break; + if (read_ok) + ecl_kw_load_from_input_buffer(ecl_kw, buffer); - ib++; - if (ib == blocks) - break; - } - } else { - /** - This function handles the fuc***g blocks transparently at a - low level. - */ - read_ok = fortio_fread_buffer(fortio , ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); - if (read_ok && ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); - } + free(buffer); return read_ok; } } else @@ -1219,30 +1257,24 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { } -void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type data_type, int element_count, const int_vector_type* index_map, char* buffer) { +void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type data_type, int element_count, const int_vector_type* index_map, char* io_buffer) { const int block_size = get_blocksize(data_type); FILE *stream = fortio_get_FILE( fortio ); int index; - int element_size = ecl_type_get_sizeof_ctype(data_type); - - if(ecl_type_is_char(data_type) || ecl_type_is_mess(data_type)) { - element_size = ECL_STRING8_LENGTH; - } - + int sizeof_iotype = ecl_type_get_sizeof_iotype(data_type); for(index = 0; index < int_vector_size(index_map); index++) { int element_index = int_vector_iget(index_map, index); - if(element_index < 0 || element_index >= element_count) { + if(element_index < 0 || element_index >= element_count) util_abort("%s: Element index is out of range 0 <= %d < %d\n", __func__, element_index, element_count); - } - fortio_data_fseek(fortio, data_offset, element_index, element_size, element_count, block_size); - util_fread(&buffer[index * element_size], element_size, 1, stream, __func__); - } - if (ECL_ENDIAN_FLIP) { - util_endian_flip_vector(buffer, element_size, int_vector_size(index_map)); + fortio_data_fseek(fortio, data_offset, element_index, sizeof_iotype, element_count, block_size); + util_fread(&io_buffer[index * sizeof_iotype], sizeof_iotype, 1, stream, __func__); } + + if (ECL_ENDIAN_FLIP) + util_endian_flip_vector(io_buffer, sizeof_iotype, int_vector_size(index_map)); } /** @@ -1272,7 +1304,7 @@ bool ecl_kw_fskip_data__( ecl_data_type data_type , const int element_count , fo } else { const int blocksize = get_blocksize( data_type ); const int block_count = element_count / blocksize + (element_count % blocksize != 0); - int element_size = ecl_type_get_sizeof_ctype_fortio(data_type); + int element_size = ecl_type_get_sizeof_iotype(data_type); if(!fortio_data_fskip(fortio, element_size, element_count, block_count)) return false; @@ -1452,7 +1484,7 @@ bool ecl_kw_fseek_last_kw(const char * kw , bool abort_on_error , fortio_type *f void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , void * data) { if (!ecl_kw->shared_data) util_safe_free( ecl_kw->data ); - ecl_kw->data = data; + ecl_kw->data = (char*)data; } @@ -1464,8 +1496,8 @@ void ecl_kw_alloc_data(ecl_kw_type *ecl_kw) { util_abort("%s: trying to allocate data for ecl_kw object which has been declared with shared storage - aborting \n",__func__); { - size_t byte_size = ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw); - ecl_kw->data = util_realloc(ecl_kw->data , byte_size ); + size_t byte_size = ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + ecl_kw->data = (char*)util_realloc(ecl_kw->data , byte_size ); memset(ecl_kw->data , 0 , byte_size); } } @@ -1482,7 +1514,7 @@ void ecl_kw_free_data(ecl_kw_type *ecl_kw) { void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) { - ecl_kw->header8 = realloc(ecl_kw->header8 , ECL_STRING8_LENGTH + 1); + ecl_kw->header8 = (char*)realloc(ecl_kw->header8 , ECL_STRING8_LENGTH + 1); if (strlen(header) <= 8) { sprintf(ecl_kw->header8 , "%-8s" , header); @@ -1491,7 +1523,7 @@ void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) { ecl_kw->header = util_alloc_strip_copy( ecl_kw->header8 ); } else { - ecl_kw->header = util_alloc_copy(header, strlen( header ) + 1); + ecl_kw->header = (char*)util_alloc_copy(header, strlen( header ) + 1); } } @@ -1545,10 +1577,9 @@ void ecl_kw_fskip(fortio_type *fortio) { -static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * fortio ) { - if (ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); - +static void ecl_kw_fwrite_data_unformatted( const ecl_kw_type * ecl_kw , fortio_type * fortio ) { + char * iobuffer = ecl_kw_alloc_output_buffer(ecl_kw); + int sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); { const int blocksize = get_blocksize( ecl_kw->data_type ); const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); @@ -1556,29 +1587,11 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = util_int_min((block_nr + 1)*blocksize , ecl_kw->size) - block_nr*blocksize; - if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { - /* - Due to the terminating \0 characters there is not a - continous file/memory mapping - the \0 characters arel - skipped. - */ - FILE *stream = fortio_get_FILE(fortio); - int word_size = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type); - int record_size = this_blocksize * word_size; /* The total size in bytes of the record written by the fortio layer. */ - int i; - fortio_init_write(fortio , record_size ); - for (i = 0; i < this_blocksize; i++) - fwrite(&ecl_kw->data[(block_nr * blocksize + i) * ecl_kw_get_sizeof_ctype(ecl_kw)] , 1 , word_size , stream); - fortio_complete_write(fortio , record_size); - } else { - int record_size = this_blocksize * ecl_kw_get_sizeof_ctype(ecl_kw); /* The total size in bytes of the record written by the fortio layer. */ - fortio_fwrite_record(fortio , &ecl_kw->data[block_nr * blocksize * ecl_kw_get_sizeof_ctype(ecl_kw)] , record_size); - } + int record_size = this_blocksize * sizeof_iotype; /* The total size in bytes of the record written by the fortio layer. */ + fortio_fwrite_record(fortio , &iobuffer[block_nr * blocksize * sizeof_iotype] , record_size); } } - - if (ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); + free(iobuffer); } @@ -1761,10 +1774,6 @@ ecl_data_type ecl_kw_get_data_type(const ecl_kw_type * ecl_kw) { return ecl_kw->data_type; } -size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type * ecl_kw) { - return ecl_type_get_sizeof_ctype(ecl_kw->data_type); -} - /******************************************************************/ @@ -1772,14 +1781,14 @@ size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type * ecl_kw) { ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer) { const char * header = buffer_fread_string( buffer ); int size = buffer_fread_int( buffer ); - ecl_type_enum ecl_type = buffer_fread_int( buffer ); + ecl_type_enum ecl_type = (ecl_type_enum)buffer_fread_int( buffer ); size_t element_size = buffer_fread_int( buffer ); ecl_data_type data_type = ecl_type_create(ecl_type, element_size); ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); ecl_kw_initialize( ecl_kw , header , size , data_type ); ecl_kw_alloc_data(ecl_kw); - buffer_fread(buffer , ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); + buffer_fread(buffer , ecl_kw->data , ecl_type_get_sizeof_ctype(ecl_kw->data_type) , ecl_kw->size); return ecl_kw; } @@ -1789,7 +1798,7 @@ void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer) { buffer_fwrite_int( buffer , ecl_kw->size ); buffer_fwrite_int( buffer , ecl_type_get_type(ecl_kw->data_type) ); buffer_fwrite_int( buffer , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); - buffer_fwrite( buffer , ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); + buffer_fwrite( buffer , ecl_kw->data , ecl_type_get_sizeof_ctype(ecl_kw->data_type) , ecl_kw->size); } @@ -1877,7 +1886,7 @@ ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target int default_int = 0; double default_double = 0; float default_float = 0; - int default_bool = ECL_BOOL_FALSE_INT; + bool default_bool = false; const char * default_char = ""; ecl_kw_type * new_kw = ecl_kw_alloc( src_kw->header , target_size , src_kw->data_type ); @@ -1982,7 +1991,7 @@ void ecl_kw_summarize(const ecl_kw_type * ecl_kw) { #define ECL_KW_SCALAR_SET_TYPED( ctype , ECL_TYPE ) \ void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value){ \ if (ecl_kw_get_type(ecl_kw) == ECL_TYPE) { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int i; \ for (i=0;i < ecl_kw->size; i++) \ data[i] = value; \ @@ -1992,26 +2001,9 @@ void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value){ \ ECL_KW_SCALAR_SET_TYPED( int , ECL_INT_TYPE ) ECL_KW_SCALAR_SET_TYPED( float , ECL_FLOAT_TYPE ) ECL_KW_SCALAR_SET_TYPED( double , ECL_DOUBLE_TYPE ) +ECL_KW_SCALAR_SET_TYPED( bool , ECL_BOOL_TYPE ) #undef ECL_KW_SCALAR_SET_TYPED -void ecl_kw_scalar_set_bool( ecl_kw_type * ecl_kw , bool bool_value) { - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - { - int * data = ecl_kw_get_data_ref(ecl_kw); - int int_value; - if (bool_value) - int_value = ECL_BOOL_TRUE_INT; - else - int_value = ECL_BOOL_FALSE_INT; - { - int i; - for ( i=0; i < ecl_kw->size; i++) - data[i] = int_value; - } - } -} - void ecl_kw_scalar_set_float_or_double( ecl_kw_type * ecl_kw , double value ) { ecl_type_enum ecl_type = ecl_kw_get_type(ecl_kw); @@ -2040,12 +2032,12 @@ void ecl_kw_scalar_set__(ecl_kw_type * ecl_kw , const void * value) { void ecl_kw_alloc_double_data(ecl_kw_type * ecl_kw , double * values) { ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data , values , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , values , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } void ecl_kw_alloc_float_data(ecl_kw_type * ecl_kw , float * values) { ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data , values , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , values , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } /*****************************************************************/ @@ -2056,7 +2048,7 @@ void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) { if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); \ { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int size = ecl_kw_get_size(ecl_kw); \ int i; \ for (i=0; i < size; i++) \ @@ -2085,7 +2077,7 @@ void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_value) { if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); \ { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int size = ecl_kw_get_size(ecl_kw); \ int i; \ for (i=0; i < size; i++) \ @@ -2134,8 +2126,8 @@ void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * inde if (!ecl_kw_size_and_type_equal( target_kw , src_kw )) util_abort("%s: type/size mismatch\n",__func__); { - char * target_data = ecl_kw_get_data_ref( target_kw ); - const char * src_data = ecl_kw_get_data_ref( src_kw ); + char * target_data = (char *)ecl_kw_get_data_ref( target_kw ); + const char * src_data = (const char *)ecl_kw_get_data_ref( src_kw ); int sizeof_ctype = ecl_type_get_sizeof_ctype(target_kw->data_type); int set_size = int_vector_size( index_set ); const int * index_data = int_vector_get_const_ptr( index_set ); @@ -2154,8 +2146,8 @@ static void ecl_kw_inplace_add_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2197,8 +2189,8 @@ static void ecl_kw_inplace_add_ ## ctype( ecl_kw_type * target_kw , const ecl_kw if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] += add_data[i]; \ @@ -2232,8 +2224,8 @@ static void ecl_kw_inplace_add_squared_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] += add_data[i] * add_data[i]; \ @@ -2272,8 +2264,8 @@ void ecl_kw_inplace_sub_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * if (!ecl_kw_assert_binary_ ## ctype( target_kw , sub_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * sub_data = ecl_kw_get_data_ref( sub_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * sub_data = (const ctype *)ecl_kw_get_data_ref( sub_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] -= sub_data[i]; \ @@ -2306,8 +2298,8 @@ static void ecl_kw_inplace_sub_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , sub_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * sub_data = ecl_kw_get_data_ref( sub_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * sub_data = (const ctype *)ecl_kw_get_data_ref( sub_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2346,7 +2338,7 @@ void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type #define ECL_KW_TYPED_INPLACE_ABS( ctype , abs_func) \ void ecl_kw_inplace_abs_ ## ctype( ecl_kw_type * kw ) { \ - ctype * data = ecl_kw_get_data_ref( kw ); \ + ctype * data = (ctype *)ecl_kw_get_data_ref( kw ); \ int i; \ for (i=0; i < kw->size; i++) \ data[i] = abs_func(data[i]); \ @@ -2384,7 +2376,7 @@ static int sqrti(int x) { #define ECL_KW_TYPED_INPLACE_SQRT( ctype, sqrt_func ) \ void ecl_kw_inplace_sqrt_ ## ctype( ecl_kw_type * kw ) { \ - ctype * data = ecl_kw_get_data_ref( kw ); \ + ctype * data = (ctype *)ecl_kw_get_data_ref( kw ); \ int i; \ for (i=0; i < kw->size; i++) \ data[i] = sqrt_func(data[i]); \ @@ -2423,8 +2415,8 @@ void ecl_kw_inplace_mul_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * if (!ecl_kw_assert_binary_ ## ctype( target_kw , mul_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * mul_data = ecl_kw_get_data_ref( mul_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * mul_data = (const ctype *)ecl_kw_get_data_ref( mul_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] *= mul_data[i]; \ @@ -2457,8 +2449,8 @@ static void ecl_kw_inplace_mul_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , mul_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * mul_data = ecl_kw_get_data_ref( mul_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * mul_data = (const ctype *)ecl_kw_get_data_ref( mul_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2501,8 +2493,8 @@ void ecl_kw_inplace_div_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * if (!ecl_kw_assert_binary_ ## ctype( target_kw , div_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * div_data = ecl_kw_get_data_ref( div_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * div_data = (const ctype *)ecl_kw_get_data_ref( div_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] /= div_data[i]; \ @@ -2536,8 +2528,8 @@ static void ecl_kw_inplace_div_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , div_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * div_data = ecl_kw_get_data_ref( div_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * div_data = (const ctype *)ecl_kw_get_data_ref( div_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2582,8 +2574,8 @@ bool ecl_kw_inplace_safe_div(ecl_kw_type * target_kw, const ecl_kw_type * diviso if (ecl_kw_get_type(divisor) != ECL_INT_TYPE) return false; - float * target_data = ecl_kw_get_data_ref( target_kw ); - const int* div_data = ecl_kw_get_data_ref( divisor ); + float * target_data = (float*)ecl_kw_get_data_ref( target_kw ); + const int* div_data = (const int*)ecl_kw_get_data_ref( divisor ); for (int i=0; i < target_kw->size; i++) { if (div_data[i] != 0) target_data[i] /= div_data[i]; @@ -2685,14 +2677,14 @@ bool ecl_kw_is_kw_file(fortio_type * fortio) { #define KW_MAX_MIN(type) \ { \ - type * data = ecl_kw_get_data_ref(ecl_kw); \ + type * data = (type*)ecl_kw_get_data_ref(ecl_kw); \ type max = data[0]; \ type min = data[0]; \ int i; \ for (i=1; i < ecl_kw_get_size(ecl_kw); i++) \ util_update_ ## type ## _max_min(data[i] , &max , &min); \ - memcpy(_max , &max , ecl_kw_get_sizeof_ctype(ecl_kw)); \ - memcpy(_min , &min , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_max , &max , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ + memcpy(_min , &min , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2753,13 +2745,13 @@ ECL_KW_MIN( double ) #define KW_SUM_INDEXED(type) \ { \ - const type * data = ecl_kw_get_data_ref(ecl_kw); \ + const type * data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ type sum = 0; \ int size = int_vector_size( index_list ); \ const int * index_ptr = int_vector_get_const_ptr( index_list ); \ for (int i = 0; i < size; i++) \ sum += data[index_ptr[i]]; \ - memcpy(_sum , &sum , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_sum , &sum , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2776,12 +2768,12 @@ void ecl_kw_element_sum_indexed(const ecl_kw_type * ecl_kw , const int_vector_ty break; case(ECL_BOOL_TYPE): { - const int * data = ecl_kw_get_data_ref(ecl_kw); + const bool * data = (const bool *)ecl_kw_get_data_ref(ecl_kw); const int * index_ptr = int_vector_get_const_ptr( index_list ); const int size = int_vector_size( index_list ); int sum = 0; for (int i = 0; i < size; i++) - sum += (data[index_ptr[i]] == ECL_BOOL_TRUE_INT); + sum += (data[index_ptr[i]]); memcpy(_sum , &sum , sizeof sum); } @@ -2801,11 +2793,11 @@ void ecl_kw_element_sum_indexed(const ecl_kw_type * ecl_kw , const int_vector_ty #define KW_SUM(type) \ { \ - const type * data = ecl_kw_get_data_ref(ecl_kw); \ + const type * data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ type sum = 0; \ for (int i=0; i < ecl_kw_get_size(ecl_kw); i++) \ sum += data[i]; \ - memcpy(_sum , &sum , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_sum , &sum , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2872,24 +2864,13 @@ static void ecl_kw_fprintf_data_ ## ctype(const ecl_kw_type * ecl_kw , const cha ECL_KW_FPRINTF_DATA( int ) ECL_KW_FPRINTF_DATA( float ) ECL_KW_FPRINTF_DATA( double ) +ECL_KW_FPRINTF_DATA( bool ) #undef ECL_KW_FPRINTF_DATA -static void ecl_kw_fprintf_data_bool( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) { - const int * data = (const int *) ecl_kw->data; - int i; - for (i=0; i < ecl_kw->size; i++) { - if (data[i] == ECL_BOOL_TRUE_INT) - fprintf(stream , fmt , 1); - else - fprintf(stream , fmt , 0); - } -} - - static void ecl_kw_fprintf_data_string( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) { int i; for (i=0; i < ecl_kw->size; i++) - fprintf(stream , fmt , &ecl_kw->data[ i * ecl_kw_get_sizeof_ctype(ecl_kw)]); + fprintf(stream , fmt , &ecl_kw->data[ i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]); } @@ -2916,8 +2897,8 @@ static bool ecl_kw_elm_equal_numeric__( const ecl_kw_type * ecl_kw1 , const ecl_ static bool ecl_kw_elm_equal__( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int offset) { - size_t data_offset = ecl_kw_get_sizeof_ctype(ecl_kw1) * offset; - int cmp = memcmp( &ecl_kw1->data[ data_offset ] , &ecl_kw2->data[ data_offset ] , ecl_kw_get_sizeof_ctype(ecl_kw1)); + size_t data_offset = ecl_type_get_sizeof_ctype(ecl_kw1->data_type) * offset; + int cmp = memcmp( &ecl_kw1->data[ data_offset ] , &ecl_kw2->data[ data_offset ] , ecl_type_get_sizeof_ctype(ecl_kw1->data_type)); if (cmp == 0) return true; else @@ -2956,4 +2937,4 @@ int ecl_kw_first_different( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ec } } -#include "ecl_kw_functions.c" +#include "ecl_kw_functions.cpp" diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/ecl_kw_functions.c rename to ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp index edc577d0cc..d10646fd33 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp @@ -23,7 +23,7 @@ void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum) { int i,j,k; - int * data = ecl_kw_get_ptr( ecl_kw ); + int * data = (int*)ecl_kw_get_ptr( ecl_kw ); int_vector_type * undetermined1 = int_vector_alloc(0,0); int_vector_type * undetermined2 = int_vector_alloc(0,0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c rename to ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp index f71b75ad6c..fc51a42e8d 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp @@ -19,11 +19,11 @@ #include #include -#include +#include -#include -#include -#include +#include +#include +#include #define MAX_GRDECL_HEADER_SIZE 512 @@ -260,8 +260,8 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ int data_index = 0; int sizeof_ctype = ecl_type_get_sizeof_ctype( data_type ); int data_size = init_size; - char * buffer = util_calloc( (buffer_size + 1) , sizeof * buffer ); - char * data = util_calloc( sizeof_ctype * data_size , sizeof * data ); + char * buffer = (char*)util_calloc( (buffer_size + 1) , sizeof * buffer ); + char * data = (char*)util_calloc( sizeof_ctype * data_size , sizeof * data ); while (true) { if (fscanf(stream , "%32s" , buffer) == 1) { @@ -347,7 +347,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ data_size = util_size_t_min( ECL_KW_MAX_SIZE , 2*(data_index + multiplier)); byte_size *= data_size; - data = util_realloc( data , byte_size ); + data = (char*)util_realloc( data , byte_size ); } else { /* We are asking for more elements than can possible be adressed in @@ -371,7 +371,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ } free( buffer ); *kw_size = data_index; - data = util_realloc( data , sizeof_ctype * data_index * sizeof * data ); + data = (char*)util_realloc( data , sizeof_ctype * data_index * sizeof * data ); return data; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_data.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp index c96f9c202c..ca35f63fb8 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp @@ -18,12 +18,12 @@ #define ECL_NNC_DATA_TYPE_ID 83756236 -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include enum kw_data_type { TRANS_DATA = 1, @@ -211,12 +211,12 @@ static bool ecl_nnc_data_set_values(ecl_nnc_data_type * data, const ecl_grid_typ } static ecl_nnc_data_type * ecl_nnc_data_alloc__(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file, int kw_type) { - ecl_nnc_data_type * data = util_malloc(sizeof * data); + ecl_nnc_data_type * data = (ecl_nnc_data_type*)util_malloc(sizeof * data); int nnc_size = ecl_nnc_geometry_size( nnc_geo ); data->size = nnc_size; - data->values = util_malloc( nnc_size * sizeof(double)); + data->values = (double*)util_malloc( nnc_size * sizeof(double)); if (ecl_nnc_data_set_values(data, grid, nnc_geo, init_file, kw_type)) return data; diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp similarity index 96% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_export.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp index ec549de43d..79cec6dabb 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp @@ -17,13 +17,13 @@ */ #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int ecl_nnc_export_get_size( const ecl_grid_type * grid ) { @@ -147,7 +147,7 @@ bool ecl_nnc_equal( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2) { static int ecl_nnc_sort_cmp__( const void * nnc1 , const void * nnc2) { - return ecl_nnc_sort_cmp( nnc1 , nnc2 ); + return ecl_nnc_sort_cmp( (const ecl_nnc_type*)nnc1 , (const ecl_nnc_type*)nnc2 ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp similarity index 88% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp index 064862c16a..84251d8f47 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp @@ -18,7 +18,7 @@ #include -#include +#include #define ECL_NNC_GEOMETRY_TYPE_ID 6124343 @@ -65,12 +65,12 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector ); for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { - ecl_nnc_pair_type pair = {.grid_nr1 = lgr_nr1, - .global_index1 = global_index1, - .grid_nr2 = lgr_nr2, - .global_index2 = int_vector_iget( grid2_index_list , index2 ), - .input_index = int_vector_iget( nnc_index_list, index2 )}; - + ecl_nnc_pair_type pair; + pair.grid_nr1 = lgr_nr1; + pair.global_index1 = global_index1; + pair.grid_nr2 = lgr_nr2; + pair.global_index2 = int_vector_iget( grid2_index_list , index2 ); + pair.input_index = int_vector_iget( nnc_index_list, index2 ); struct_vector_append( nnc_geo->data , &pair); } } @@ -100,7 +100,7 @@ static int ecl_nnc_cmp(const void * _nnc1 , const void * _nnc2) { ecl_nnc_geometry_type * ecl_nnc_geometry_alloc( const ecl_grid_type * grid ) { - ecl_nnc_geometry_type * nnc_geo = util_malloc( sizeof * nnc_geo ); + ecl_nnc_geometry_type * nnc_geo = (ecl_nnc_geometry_type*)util_malloc( sizeof * nnc_geo ); UTIL_TYPE_ID_INIT( nnc_geo , ECL_NNC_GEOMETRY_TYPE_ID ); nnc_geo->data = struct_vector_alloc( sizeof( struct ecl_nnc_pair_struct )); @@ -121,7 +121,7 @@ void ecl_nnc_geometry_free( ecl_nnc_geometry_type * nnc_geo) { const ecl_nnc_pair_type * ecl_nnc_geometry_iget( const ecl_nnc_geometry_type * nnc_geo , int index) { - return struct_vector_iget_ptr( nnc_geo->data , index ); + return (const ecl_nnc_pair_type*)struct_vector_iget_ptr( nnc_geo->data , index ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_region.c b/ThirdParty/Ert/lib/ecl/ecl_region.cpp similarity index 99% rename from ThirdParty/Ert/lib/ecl/ecl_region.c rename to ThirdParty/Ert/lib/ecl/ecl_region.cpp index 08410ddfc4..f76c7fc5a0 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_region.c +++ b/ThirdParty/Ert/lib/ecl/ecl_region.cpp @@ -20,17 +20,17 @@ #include #include -#include -#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** @@ -137,12 +137,12 @@ void ecl_region_unlock( ecl_region_type * region ){ ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool preselect) { - ecl_region_type * region = util_malloc( sizeof * region ); + ecl_region_type * region = (ecl_region_type*)util_malloc( sizeof * region ); UTIL_TYPE_ID_INIT( region , ECL_REGION_TYPE_ID); region->parent_grid = ecl_grid; ecl_grid_get_dims( ecl_grid , ®ion->grid_nx , ®ion->grid_ny , ®ion->grid_nz , ®ion->grid_active); region->grid_vol = region->grid_nx * region->grid_ny * region->grid_nz; - region->active_mask = util_calloc(region->grid_vol , sizeof * region->active_mask ); + region->active_mask = (bool*)util_calloc(region->grid_vol , sizeof * region->active_mask ); region->active_index_list = int_vector_alloc(0 , 0); region->global_index_list = int_vector_alloc(0 , 0); region->global_active_list = int_vector_alloc(0 , 0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.c b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_rft_cell.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp index 0a2bced36e..ae683086f4 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp @@ -23,13 +23,13 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define ECL_RFT_CELL_TYPE_ID 99164012 @@ -78,7 +78,7 @@ struct plt_data_struct { /*****************************************************************/ static rft_data_type * rft_data_alloc( double swat , double sgas) { - rft_data_type * data = util_malloc( sizeof * data ); + rft_data_type * data = (rft_data_type*)util_malloc( sizeof * data ); UTIL_TYPE_ID_INIT( data , RFT_DATA_TYPE_ID ); data->swat = swat; @@ -98,7 +98,7 @@ static UTIL_IS_INSTANCE_FUNCTION( rft_data , RFT_DATA_TYPE_ID) /*****************************************************************/ static plt_data_type * plt_data_alloc( double orat , double grat , double wrat,double connection_start, double connection_end, double flowrate , double oil_flowrate , double gas_flowrate , double water_flowrate) { - plt_data_type * data = util_malloc( sizeof * data ); + plt_data_type * data = (plt_data_type*)util_malloc( sizeof * data ); UTIL_TYPE_ID_INIT( data , PLT_DATA_TYPE_ID ); data->orat = orat; @@ -133,7 +133,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_rft_cell , ECL_RFT_CELL_TYPE_ID) static ecl_rft_cell_type * ecl_rft_cell_alloc_common(int i , int j , int k , double depth , double pressure) { - ecl_rft_cell_type * cell = util_malloc( sizeof * cell ); + ecl_rft_cell_type * cell = (ecl_rft_cell_type*)util_malloc( sizeof * cell ); UTIL_TYPE_ID_INIT( cell , ECL_RFT_CELL_TYPE_ID ); cell->i = i; @@ -180,9 +180,9 @@ ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i , void ecl_rft_cell_free( ecl_rft_cell_type * cell ) { if (rft_data_is_instance( cell->data )) - rft_data_free( cell->data ); + rft_data_free( (rft_data_type*)cell->data ); else if (plt_data_is_instance( cell->data )) - plt_data_free( cell->data ); + plt_data_free( (plt_data_type*)cell->data ); free( cell ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_rft_file.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp index 17c381087a..0600a94efe 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp @@ -25,16 +25,16 @@ #include #endif -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** @@ -63,7 +63,7 @@ struct ecl_rft_file_struct { static ecl_rft_file_type * ecl_rft_file_alloc_empty(const char * filename) { - ecl_rft_file_type * rft_vector = util_malloc(sizeof * rft_vector ); + ecl_rft_file_type * rft_vector = (ecl_rft_file_type*)util_malloc(sizeof * rft_vector ); UTIL_TYPE_ID_INIT( rft_vector , ECL_RFT_FILE_ID ); rft_vector->data = vector_alloc_new(); rft_vector->filename = util_alloc_string_copy(filename); @@ -106,7 +106,7 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { if (!hash_has_key( rft_vector->well_index , well_name)) hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__); { - int_vector_type * index_list = hash_get( rft_vector->well_index , well_name ); + int_vector_type * index_list = (int_vector_type*)hash_get( rft_vector->well_index , well_name ); int_vector_append(index_list , global_index); } global_index++; @@ -228,7 +228,7 @@ int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * we int match_count = 0; int i; for ( i=0; i < vector_get_size( rft_file->data ); i++) { - const ecl_rft_node_type * rft = vector_iget_const( rft_file->data , i); + const ecl_rft_node_type * rft = (const ecl_rft_node_type*)vector_iget_const( rft_file->data , i); if (well_pattern) { if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0) @@ -274,7 +274,7 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) { */ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) { - return vector_iget( rft_file->data , index ); + return (ecl_rft_node_type*)vector_iget( rft_file->data , index ); } @@ -306,7 +306,7 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); return ecl_rft_file_iget_node( rft_file , int_vector_iget(index_vector , index)); } @@ -314,7 +314,7 @@ ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_fi static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) { int global_index = -1; if (hash_has_key( rft_file->well_index , well)) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); int well_index = 0; while (true) { if (well_index == int_vector_size( index_vector )) @@ -364,7 +364,7 @@ bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * we */ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); return int_vector_size( index_vector ); } @@ -423,7 +423,7 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp); for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) { - const ecl_rft_node_type *new_node = vector_iget_const(rft_file->data, node_index); + const ecl_rft_node_type *new_node = (const ecl_rft_node_type*)vector_iget_const(rft_file->data, node_index); ecl_rft_node_fwrite(new_node, fortio, unit_set); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp similarity index 92% rename from ThirdParty/Ert/lib/ecl/ecl_rft_node.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp index dc19a5ea30..d4681bf3f6 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp @@ -23,18 +23,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /** @@ -106,7 +106,7 @@ static ecl_rft_enum translate_from_sting_to_ecl_rft_enum(const char * data_type_ ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days){ ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string); - ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); + ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->well_name = util_alloc_string_copy(well_name); rft_node->cells = vector_alloc_new(); @@ -130,7 +130,7 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin } { - ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); + ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->cells = vector_alloc_new(); @@ -269,11 +269,11 @@ static void ecl_rft_node_init_cells( ecl_rft_node_type * rft_node , const ecl_fi ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) { ecl_kw_type * welletc = ecl_file_view_iget_named_kw(rft_view , WELLETC_KW , 0); - ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX)); + ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty((const char*)ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX)); if (rft_node != NULL) { ecl_kw_type * date_kw = ecl_file_view_iget_named_kw( rft_view , DATE_KW , 0); - rft_node->well_name = util_alloc_strip_copy( ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); + rft_node->well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); /* Time information. */ { @@ -325,7 +325,7 @@ ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return /* various functions to access properties at the cell level */ const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) { - return vector_iget_const( rft_node->cells , index ); + return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); } @@ -349,7 +349,7 @@ const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft if (!rft_node->sort_perm_in_sync) ecl_rft_node_create_sort_perm( rft_node ); - return vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); + return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); } } @@ -403,7 +403,7 @@ static void assert_type_and_index( const ecl_rft_node_type * rft_node , ecl_rft_ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_sgas( cell ); } } @@ -412,7 +412,7 @@ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_swat( cell ); } } @@ -424,7 +424,7 @@ double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ){ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_soil( cell ); } } @@ -435,7 +435,7 @@ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_orat( cell ); } } @@ -444,7 +444,7 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); return ecl_rft_cell_get_wrat( cell ); } } @@ -453,7 +453,7 @@ double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); return ecl_rft_cell_get_grat( cell ); } } @@ -594,7 +594,7 @@ void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * forti int i; for(i =0;icells , i); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , i); ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell)+1); ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell)+1); ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell)+1); diff --git a/ThirdParty/Ert/lib/ecl/ecl_rst_file.c b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_rst_file.c rename to ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp index 2bc6fd70cd..646f6c6598 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rst_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp @@ -23,21 +23,21 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include struct ecl_rst_file_struct { fortio_type * fortio; @@ -50,7 +50,7 @@ struct ecl_rst_file_struct { static ecl_rst_file_type * ecl_rst_file_alloc( const char * filename ) { bool unified = ecl_util_unified_file( filename ); bool fmt_file; - ecl_rst_file_type * rst_file = util_malloc( sizeof * rst_file ); + ecl_rst_file_type * rst_file = (ecl_rst_file_type*)util_malloc( sizeof * rst_file ); if (ecl_util_fmt_file( filename , &fmt_file)) { rst_file->unified = unified; diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_rsthead.c rename to ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index 52d40a9aab..49b797d1cc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -17,13 +17,13 @@ */ #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static time_t rsthead_date( int day , int month , int year) { @@ -55,7 +55,7 @@ int ecl_rsthead_get_report_step( const ecl_rsthead_type * header ) { ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw ) { - ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + ecl_rsthead_type * rsthead = (ecl_rsthead_type*)util_malloc( sizeof * rsthead ); rsthead->report_step = report_step; { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); @@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - - if (doubhead_kw) - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = NULL; + const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); - if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) - doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); - if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); @@ -135,7 +129,7 @@ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int r ecl_rsthead_type * ecl_rsthead_alloc_empty() { - ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + ecl_rsthead_type * rsthead = (ecl_rsthead_type*)util_malloc( sizeof * rsthead ); rsthead->day = 0; rsthead->month = 0; diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_smspec.c rename to ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index ebdd880dee..2e774554b2 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -22,21 +22,21 @@ #include #include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_FNMATCH #include @@ -251,7 +251,7 @@ static const char* smspec_required_keywords[] = { ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string) { ecl_smspec_type *ecl_smspec; - ecl_smspec = util_malloc(sizeof *ecl_smspec ); + ecl_smspec = (ecl_smspec_type*)util_malloc(sizeof *ecl_smspec ); UTIL_TYPE_ID_INIT(ecl_smspec , ECL_SMSPEC_ID); ecl_smspec->well_var_index = hash_alloc(); @@ -295,7 +295,7 @@ ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_type * other) { int params_size = ecl_smspec_get_params_size( self ); - int * mapping = util_malloc( params_size * sizeof * mapping ); + int * mapping = (int*)util_malloc( params_size * sizeof * mapping ); for (int i = 0; i < params_size; i++) mapping[i] = -1; @@ -326,7 +326,7 @@ int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_t const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index ) { - return vector_iget_const( smspec->smspec_nodes , index ); + return (const smspec_node_type*)vector_iget_const( smspec->smspec_nodes , index ); } int ecl_smspec_num_nodes( const ecl_smspec_type * smspec) { @@ -844,13 +844,13 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->well_completion_var_index , well)) hash_insert_hash_owned_ref(ecl_smspec->well_completion_var_index , well , hash_alloc() , hash_free__); { - hash_type * cell_hash = hash_get(ecl_smspec->well_completion_var_index , well); + hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); char cell_str[16]; sprintf(cell_str , "%d" , num); if (!hash_has_key(cell_hash , cell_str)) hash_insert_hash_owned_ref(cell_hash , cell_str , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(cell_hash , cell_str); + hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); hash_insert_ref(var_hash , keyword , smspec_node ); } } @@ -865,7 +865,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->group_var_index , group)) hash_insert_hash_owned_ref(ecl_smspec->group_var_index , group, hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->group_var_index , group); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->group_var_index , group); hash_insert_ref(var_hash , keyword , smspec_node ); } break; @@ -873,7 +873,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->region_var_index , keyword)) hash_insert_hash_owned_ref( ecl_smspec->region_var_index , keyword , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->region_var_index , keyword); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , keyword); char num_str[16]; sprintf( num_str , "%d" , num); hash_insert_ref(var_hash , num_str , smspec_node); @@ -884,7 +884,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->well_var_index , well)) hash_insert_hash_owned_ref(ecl_smspec->well_var_index , well , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->well_var_index , well); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->well_var_index , well); hash_insert_ref(var_hash , keyword , smspec_node ); } break; @@ -897,7 +897,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->block_var_index , keyword)) hash_insert_hash_owned_ref(ecl_smspec->block_var_index , keyword , hash_alloc() , hash_free__); { - hash_type * block_hash = hash_get(ecl_smspec->block_var_index , keyword); + hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , keyword); char block_nr[16]; sprintf( block_nr , "%d" , num ); hash_insert_ref(block_hash , block_nr , smspec_node); @@ -1018,8 +1018,8 @@ bool ecl_smspec_equal(const ecl_smspec_type * self, return false; for (int i=0; i < vector_get_size( self->smspec_nodes ); i++) { - const smspec_node_type * node1 = vector_iget_const(self->smspec_nodes, i); - const smspec_node_type * node2 = vector_iget_const(other->smspec_nodes, i); + const smspec_node_type * node1 = (const smspec_node_type*)vector_iget_const(self->smspec_nodes, i); + const smspec_node_type * node2 = (const smspec_node_type*)vector_iget_const(other->smspec_nodes, i); if (!smspec_node_equal(node1, node2)) return false; @@ -1039,7 +1039,7 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi int i; tmp_base[0] = '\0'; for (i=0; i < ecl_kw_get_size( restart_kw ); i++) - strcat( tmp_base , ecl_kw_iget_ptr( restart_kw , i )); + strcat( tmp_base , (const char*)ecl_kw_iget_ptr( restart_kw , i )); restart_base = util_alloc_strip_copy( tmp_base ); if (strlen(restart_base)) { /* We ignore the empty ones. */ @@ -1204,7 +1204,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h if (ecl_file_has_kw(header, INTEHEAD_KW)) { const ecl_kw_type * intehead = ecl_file_iget_named_kw(header, INTEHEAD_KW, 0); - ecl_smspec->unit_system = ecl_kw_iget_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX); + ecl_smspec->unit_system = (ert_ecl_unit_enum)ecl_kw_iget_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX); /* The second item in the INTEHEAD vector is an integer designating which simulator has been used for the current simulation, that is currently @@ -1240,9 +1240,9 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h for (params_index=0; params_index < ecl_kw_get_size(wells); params_index++) { float default_value = PARAMS_GLOBAL_DEFAULT; int num = SMSPEC_NUMS_INVALID; - char * well = util_alloc_strip_copy(ecl_kw_iget_ptr(wells , params_index)); - char * kw = util_alloc_strip_copy(ecl_kw_iget_ptr(keywords , params_index)); - char * unit = util_alloc_strip_copy(ecl_kw_iget_ptr(units , params_index)); + char * well = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(wells , params_index)); + char * kw = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(keywords , params_index)); + char * unit = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(units , params_index)); char * lgr_name = NULL; smspec_node_type * smspec_node; @@ -1252,7 +1252,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h int lgr_i = ecl_kw_iget_int( numlx , params_index ); int lgr_j = ecl_kw_iget_int( numly , params_index ); int lgr_k = ecl_kw_iget_int( numlz , params_index ); - lgr_name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrs , params_index )); + lgr_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrs , params_index )); smspec_node = smspec_node_alloc_lgr( var_type , well , kw , unit , lgr_name , ecl_smspec->key_join_string , lgr_i , lgr_j , lgr_k , params_index, default_value); } else smspec_node = smspec_node_alloc( var_type , well , kw , unit , ecl_smspec->key_join_string , ecl_smspec->grid_dims , num , params_index , default_value); @@ -1293,7 +1293,7 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k if (ecl_smspec_fread_header(ecl_smspec , header_file , include_restart)) { if (hash_has_key( ecl_smspec->misc_var_index , "TIME")) { - const smspec_node_type * time_node = hash_get(ecl_smspec->misc_var_index , "TIME"); + const smspec_node_type * time_node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "TIME"); const char * time_unit = smspec_node_get_unit( time_node ); ecl_smspec->time_index = smspec_node_get_params_index( time_node ); @@ -1306,9 +1306,9 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k } if (hash_has_key(ecl_smspec->misc_var_index , "DAY")) { - ecl_smspec->day_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "DAY") ); - ecl_smspec->month_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "MONTH") ); - ecl_smspec->year_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "YEAR") ); + ecl_smspec->day_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "DAY") ); + ecl_smspec->month_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "MONTH") ); + ecl_smspec->year_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "YEAR") ); } if ((ecl_smspec->time_index == -1) && ( ecl_smspec->day_index == -1)) { @@ -1392,9 +1392,9 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { const smspec_node_type * ecl_smspec_get_well_var_node( const ecl_smspec_type * smspec , const char * well , const char * var) { const smspec_node_type * node = NULL; if (hash_has_key( smspec->well_var_index , well)) { - hash_type * var_hash = hash_get(smspec->well_var_index , well); + hash_type * var_hash = (hash_type*)hash_get(smspec->well_var_index , well); if (hash_has_key(var_hash , var)) - node = hash_get(var_hash , var); + node = (const smspec_node_type*)hash_get(var_hash , var); } return node; } @@ -1419,9 +1419,9 @@ bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * w const smspec_node_type * ecl_smspec_get_group_var_node( const ecl_smspec_type * smspec , const char * group , const char * var) { const smspec_node_type * node = NULL; if (hash_has_key(smspec->group_var_index , group)) { - hash_type * var_hash = hash_get(smspec->group_var_index , group); + hash_type * var_hash = (hash_type*)hash_get(smspec->group_var_index , group); if (hash_has_key(var_hash , var)) - node = hash_get(var_hash , var); + node = (const smspec_node_type*)hash_get(var_hash , var); } return node; } @@ -1445,7 +1445,7 @@ bool ecl_smspec_has_group_var(const ecl_smspec_type * ecl_smspec , const char * const smspec_node_type * ecl_smspec_get_field_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->field_var_index , var)) - node = hash_get(ecl_smspec->field_var_index , var); + node = (const smspec_node_type*)hash_get(ecl_smspec->field_var_index , var); return node; } @@ -1479,9 +1479,9 @@ static const smspec_node_type * ecl_smspec_get_block_var_node_string(const ecl_s const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->block_var_index , block_var)) { - hash_type * block_hash = hash_get(ecl_smspec->block_var_index , block_var); + hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , block_var); if (hash_has_key(block_hash , block_str)) - node = hash_get(block_hash , block_str); + node = (const smspec_node_type*)hash_get(block_hash , block_str); } return node; @@ -1539,9 +1539,9 @@ const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * if (hash_has_key(ecl_smspec->region_var_index , region_var)) { char * nr_str = util_alloc_sprintf( "%d" , region_nr ); - hash_type * nr_hash = hash_get(ecl_smspec->region_var_index , region_var); + hash_type * nr_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , region_var); if (hash_has_key( nr_hash , nr_str)) - node = hash_get( nr_hash , nr_str ); + node = (const smspec_node_type*)hash_get( nr_hash , nr_str ); free( nr_str ); } @@ -1567,7 +1567,7 @@ const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ec const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->misc_var_index , var)) - node = hash_get(ecl_smspec->misc_var_index , var); + node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , var); return node; } @@ -1593,12 +1593,12 @@ const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspe char * cell_str = util_alloc_sprintf("%d" , cell_nr); if (hash_has_key(ecl_smspec->well_completion_var_index , well)) { - hash_type * cell_hash = hash_get(ecl_smspec->well_completion_var_index , well); + hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); if (hash_has_key(cell_hash , cell_str)) { - hash_type * var_hash = hash_get(cell_hash , cell_str); + hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); if (hash_has_key(var_hash , var)) - node = hash_get( var_hash , var); + node = (const smspec_node_type*)hash_get( var_hash , var); } } free(cell_str); @@ -1630,7 +1630,7 @@ int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ) { if (hash_has_key( smspec->gen_var_index , lookup_kw )) { - const smspec_node_type * smspec_node = hash_get( smspec->gen_var_index , lookup_kw ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , lookup_kw ); return smspec_node; } else return NULL; @@ -1651,7 +1651,7 @@ bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char /** DIES if the lookup_kw is not present. */ const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec , const char * lookup_kw) { - const smspec_node_type * smspec_node = hash_get( ecl_smspec->gen_var_index , lookup_kw ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( ecl_smspec->gen_var_index , lookup_kw ); return smspec_node_get_unit( smspec_node ); } @@ -1768,7 +1768,7 @@ int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec ) { bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * gen_key) { - const smspec_node_type * smspec_node = hash_get( smspec->gen_var_index , gen_key ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , gen_key ); return smspec_node_is_total( smspec_node ); } @@ -1914,7 +1914,7 @@ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec ) { hash_iter_type * well_iter = hash_iter_alloc( smspec->well_var_index ); - hash_type * var_hash = hash_iter_get_next_value( well_iter ); + hash_type * var_hash = (hash_type*)hash_iter_get_next_value( well_iter ); hash_iter_free( well_iter ); return hash_alloc_stringlist( var_hash ); } @@ -1949,7 +1949,7 @@ void ecl_smspec_sort( ecl_smspec_type * smspec ) { vector_sort( smspec->smspec_nodes , smspec_node_cmp__); for (int i=0; i < vector_get_size( smspec->smspec_nodes ); i++) { - smspec_node_type * node = vector_iget( smspec->smspec_nodes , i ); + smspec_node_type * node = (smspec_node_type*)vector_iget( smspec->smspec_nodes , i ); smspec_node_set_params_index( node , i ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_subsidence.c b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/ecl_subsidence.c rename to ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp index 4fe053f6f9..301e3ce9a9 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_subsidence.c +++ b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp @@ -22,19 +22,19 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -84,14 +84,14 @@ struct ecl_subsidence_survey_struct { static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_empty(const ecl_subsidence_type * sub, const char * name) { - ecl_subsidence_survey_type * survey = util_malloc( sizeof * survey ); + ecl_subsidence_survey_type * survey = (ecl_subsidence_survey_type*)util_malloc( sizeof * survey ); UTIL_TYPE_ID_INIT( survey , ECL_SUBSIDENCE_SURVEY_ID ); survey->grid_cache = sub->grid_cache; survey->aquifer_cell = sub->aquifer_cell; survey->name = util_alloc_string_copy( name ); - survey->porv = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->porv ); - survey->pressure = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->pressure ); + survey->porv = (double*)util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->porv ); + survey->pressure = (double*)util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->pressure ); return survey; } @@ -144,7 +144,7 @@ static double ecl_subsidence_survey_eval( const ecl_subsidence_survey_type * bas const ecl_grid_cache_type * grid_cache = base_survey->grid_cache; const int size = ecl_grid_cache_get_size( grid_cache ); - double * weight = util_calloc( size , sizeof * weight ); + double * weight = (double*)util_calloc( size , sizeof * weight ); double deltaz; int index; @@ -174,7 +174,7 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t const double * cell_volume = ecl_grid_cache_get_volume( grid_cache ); const int size = ecl_grid_cache_get_size( grid_cache ); double scale_factor = 1e4 *(1 + poisson_ratio) * ( 1 - 2*poisson_ratio) / ( 4*M_PI*( 1 - poisson_ratio) * youngs_modulus ); - double * weight = util_calloc( size , sizeof * weight ); + double * weight = (double*)util_calloc( size , sizeof * weight ); double deltaz; for (int index = 0; index < size; index++) { @@ -202,7 +202,7 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t */ ecl_subsidence_type * ecl_subsidence_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) { - ecl_subsidence_type * ecl_subsidence = util_malloc( sizeof * ecl_subsidence ); + ecl_subsidence_type * ecl_subsidence = (ecl_subsidence_type*)util_malloc( sizeof * ecl_subsidence ); ecl_subsidence->init_file = init_file; ecl_subsidence->grid_cache = ecl_grid_cache_alloc( ecl_grid ); ecl_subsidence->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( ecl_subsidence->grid_cache , init_file ); @@ -232,7 +232,7 @@ static ecl_subsidence_survey_type * ecl_subsidence_get_survey( const ecl_subside if (name == NULL) return NULL; // Calling scope must determine if this is OK? else - return hash_get( subsidence->surveys , name ); + return (ecl_subsidence_survey_type*)hash_get( subsidence->surveys , name ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.c b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp similarity index 92% rename from ThirdParty/Ert/lib/ecl/ecl_sum.c rename to ThirdParty/Ert/lib/ecl/ecl_sum.cpp index 3d5d0ed627..070a70d00b 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp @@ -22,23 +22,23 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include /** @@ -123,7 +123,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_sum , ECL_SUM_ID ); The actual loading is implemented in the ecl_sum_data.c file. */ -void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { +void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * input_arg) { util_safe_free( ecl_sum->ecl_case ); util_safe_free( ecl_sum->path ); util_safe_free( ecl_sum->abs_path ); @@ -132,9 +132,9 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { { char *path , *base, *ext; - util_alloc_file_components( ecl_case , &path , &base , &ext); + util_alloc_file_components( input_arg, &path , &base , &ext); - ecl_sum->ecl_case = util_alloc_string_copy( ecl_case ); + ecl_sum->ecl_case = util_alloc_filename( path, base, NULL ); ecl_sum->path = util_alloc_string_copy( path ); ecl_sum->base = util_alloc_string_copy( base ); ecl_sum->ext = util_alloc_string_copy( ext ); @@ -154,7 +154,7 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key if (!ecl_util_path_access(input_arg)) return NULL; - ecl_sum_type * ecl_sum = util_malloc( sizeof * ecl_sum ); + ecl_sum_type * ecl_sum = (ecl_sum_type*)util_malloc( sizeof * ecl_sum ); UTIL_TYPE_ID_INIT( ecl_sum , ECL_SUM_ID ); ecl_sum->ecl_case = NULL; @@ -183,11 +183,17 @@ static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * static void ecl_sum_fread_history( ecl_sum_type * ecl_sum ) { - ecl_sum_type * restart_case = ecl_sum_fread_alloc_case__( ecl_smspec_get_restart_case( ecl_sum->smspec ) , ":" , true); + char * restart_header = ecl_util_alloc_filename(NULL, + ecl_smspec_get_restart_case(ecl_sum->smspec), + ECL_SUMMARY_HEADER_FILE, + ecl_smspec_get_formatted(ecl_sum->smspec), + -1); + ecl_sum_type * restart_case = ecl_sum_fread_alloc_case__(restart_header, ":" , true); if (restart_case) { ecl_sum->restart_case = restart_case; ecl_sum_data_add_case(ecl_sum->data , restart_case->data ); } + free(restart_header); } @@ -711,6 +717,9 @@ double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , c return ecl_sum_data_iget( ecl_sum->data , time_index , params_index); } +#ifdef __cplusplus +extern "C" { + void ecl_sum_get_interp_vector(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, double_vector_type * data){ ecl_sum_data_get_interp_vector(ecl_sum->data, sim_time, key_words, data); } @@ -719,6 +728,9 @@ void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_tim ecl_sum_data_fwrite_interp_csv_line(ecl_sum->data, sim_time, key_words, fp); } +} +#endif + double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) { @@ -901,6 +913,38 @@ void ecl_sum_init_data_vector( const ecl_sum_type * ecl_sum , double_vector_type } +void ecl_sum_init_double_vector__(const ecl_sum_type * ecl_sum, int params_index, double * data) { + ecl_sum_data_init_double_vector(ecl_sum->data, params_index, data); +} + + +void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_key, double * data) { + int params_index = ecl_sum_get_general_var_params_index(ecl_sum, gen_key); + ecl_sum_init_double_vector__(ecl_sum, params_index, data); +} + +void ecl_sum_init_double_vector_interp(const ecl_sum_type * ecl_sum, const char * gen_key, const time_t_vector_type * time_points, double * data) { + const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); + ecl_sum_data_init_double_vector_interp(ecl_sum->data, node, time_points, data); +} + + + + +void ecl_sum_init_datetime64_vector(const ecl_sum_type * ecl_sum, int64_t * data, int multiplier) { + ecl_sum_data_init_datetime64_vector(ecl_sum->data, data, multiplier); +} + +void ecl_sum_init_double_frame(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, double * data) { + ecl_sum_data_init_double_frame(ecl_sum->data, keywords, data); +} + + +void ecl_sum_init_double_frame_interp(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, const time_t_vector_type * time_points, double * data) { + ecl_sum_data_init_double_frame_interp(ecl_sum->data, keywords, time_points, data); +} + + double_vector_type * ecl_sum_alloc_data_vector( const ecl_sum_type * ecl_sum , int data_index , bool report_only) { return ecl_sum_data_alloc_data_vector( ecl_sum->data , data_index , report_only ); } @@ -1082,7 +1126,7 @@ static void ecl_sum_fprintf_header( const ecl_sum_type * ecl_sum , const stringl void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const stringlist_type * var_list , bool report_only , const ecl_sum_fmt_type * fmt) { bool_vector_type * has_var = bool_vector_alloc( stringlist_get_size( var_list ), false ); int_vector_type * var_index = int_vector_alloc( stringlist_get_size( var_list ), -1 ); - char * date_string = util_malloc( DATE_STRING_LENGTH * sizeof * date_string); + char * date_string = (char*)util_malloc( DATE_STRING_LENGTH * sizeof * date_string); char * current_locale = NULL; if (fmt->locale != NULL) @@ -1420,3 +1464,29 @@ time_t_vector_type * ecl_sum_alloc_time_solution( const ecl_sum_type * ecl_sum , ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type * ecl_sum) { return ecl_smspec_get_unit_system(ecl_sum->smspec); } + +double ecl_sum_iget_last_value(const ecl_sum_type * ecl_sum, int param_index) { + return ecl_sum_data_iget_last_value(ecl_sum->data, param_index); +} + +double ecl_sum_get_last_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) { + return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_iget_first_value(const ecl_sum_type * ecl_sum, int param_index) { + return ecl_sum_data_iget_first_value(ecl_sum->data, param_index); +} + +double ecl_sum_get_first_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) { + return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node)); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp similarity index 88% rename from ThirdParty/Ert/lib/ecl/ecl_sum_data.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp index 6f38d91f21..a1d3e0f3f1 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp @@ -19,22 +19,22 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include @@ -258,7 +258,7 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { - ecl_sum_data_type * data = util_malloc( sizeof * data ); + ecl_sum_data_type * data = (ecl_sum_data_type*)util_malloc( sizeof * data ); data->data = vector_alloc_new(); data->smspec = smspec; @@ -293,7 +293,7 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { static ecl_sum_tstep_type * ecl_sum_data_iget_ministep( const ecl_sum_data_type * data , int internal_index ) { - return vector_iget( data->data , internal_index ); + return (ecl_sum_tstep_type*)vector_iget( data->data , internal_index ); } @@ -709,8 +709,8 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { /* Identify various global first and last values. */ { - const ecl_sum_tstep_type * first_ministep = vector_iget_const( sum_data->data, 0 ); - const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); + const ecl_sum_tstep_type * first_ministep = (const ecl_sum_tstep_type*)vector_iget_const( sum_data->data, 0 ); + const ecl_sum_tstep_type * last_ministep = (const ecl_sum_tstep_type*)vector_get_last_const( sum_data->data ); /* In most cases the days_start and data_start_time will agree with the global simulation start; however in the case where we @@ -772,7 +772,7 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int ecl_sum_tstep_type * prev_tstep = NULL; if (vector_get_size( data->data ) > 0) - prev_tstep = vector_get_last( data->data ); + prev_tstep = (ecl_sum_tstep_type*)vector_get_last( data->data ); ecl_sum_data_append_tstep__( data , tstep ); { @@ -1234,7 +1234,7 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); - const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); + const ecl_sum_tstep_type * ministep = (const ecl_sum_tstep_type*)vector_iget_const( data->data , ministep_index ); double_vector_iset( days_map , i , ecl_sum_tstep_get_sim_days( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); @@ -1288,7 +1288,7 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); - const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); + const ecl_sum_tstep_type * ministep = (const ecl_sum_tstep_type*)vector_iget_const( data->data , ministep_index ); time_t_vector_iset( time_map , i , ecl_sum_tstep_get_sim_time( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); @@ -1412,6 +1412,132 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d } +void ecl_sum_data_init_double_vector(const ecl_sum_data_type * data, int params_index, double * output_data) { + int i; + for (i = 0; i < vector_get_size(data->data); i++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); + output_data[i] = ecl_sum_tstep_iget(ministep, params_index); + } +} + +void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type * data, int64_t * output_data, int multiplier) { + int i; + for (i = 0; i < vector_get_size(data->data); i++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); + output_data[i] = ecl_sum_tstep_get_sim_time(ministep) * multiplier; + } +} + +void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, + const smspec_node_type * smspec_node, + const time_t_vector_type * time_points, + double * output_data) { + bool is_rate = smspec_node_is_rate(smspec_node); + int params_index = smspec_node_get_params_index(smspec_node); + time_t start_time = ecl_sum_data_get_data_start(data); + time_t end_time = ecl_sum_data_get_sim_end(data); + double start_value = 0; + double end_value = 0; + + if (!is_rate) { + start_value = ecl_sum_data_iget_first_value(data, params_index); + end_value = ecl_sum_data_iget_last_value(data, params_index); + } + + for (int time_index=0; time_index < time_t_vector_size(time_points); time_index++) { + time_t sim_time = time_t_vector_iget( time_points, time_index); + double value; + if (sim_time < start_time) + value = start_value; + + else if (sim_time > end_time) + value = end_value; + + else { + int time_index1, time_index2; + double weight1, weight2; + ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); + value = ecl_sum_data_vector_iget( data, + sim_time, + params_index, + is_rate, + time_index1, + time_index2, + weight1, + weight2); + } + + output_data[time_index] = value; + } +} + + + + +void ecl_sum_data_init_double_frame(const ecl_sum_data_type * data, const ecl_sum_vector_type * keywords, double *output_data) { + int time_stride = ecl_sum_vector_get_size(keywords); + int key_stride = 1; + for (int time_index=0; time_index < vector_get_size(data->data); time_index++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep(data , time_index); + for (int key_index = 0; key_index < ecl_sum_vector_get_size(keywords); key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index * time_stride; + + output_data[data_index] = ecl_sum_tstep_iget(ministep, param_index); + } + } +} + + +void ecl_sum_data_init_double_frame_interp(const ecl_sum_data_type * data, + const ecl_sum_vector_type * keywords, + const time_t_vector_type * time_points, + double * output_data) { + int num_keywords = ecl_sum_vector_get_size(keywords); + int time_stride = num_keywords; + int key_stride = 1; + time_t start_time = ecl_sum_data_get_data_start(data); + time_t end_time = ecl_sum_data_get_sim_end(data); + + + for (int time_index=0; time_index < time_t_vector_size(time_points); time_index++) { + time_t sim_time = time_t_vector_iget( time_points, time_index); + if (sim_time < start_time) { + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + if (is_rate) + output_data[data_index] = 0; + else + output_data[data_index] = ecl_sum_data_iget_first_value(data, param_index); + } + } else if (sim_time > end_time) { + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + if (is_rate) + output_data[data_index] = 0; + else + output_data[data_index] = ecl_sum_data_iget_last_value(data, param_index); + } + } else { + double weight1, weight2; + int time_index1, time_index2; + + ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); + + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + double value = ecl_sum_data_vector_iget( data, sim_time, param_index , is_rate, time_index1, time_index2, weight1, weight2); + output_data[data_index] = value; + } + } + } +} /** This function will return the total number of ministeps in the @@ -1487,3 +1613,18 @@ bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , cons } return compatible; } + + +double ecl_sum_data_iget_last_value(const ecl_sum_data_type * data, int param_index) { + const ecl_sum_tstep_type * tstep = (const ecl_sum_tstep_type*)vector_get_last_const(data->data); + return ecl_sum_tstep_iget( tstep, param_index); +} + +double ecl_sum_data_get_last_value(const ecl_sum_data_type * data, int param_index) { + return ecl_sum_data_iget_last_value(data, param_index); +} + +double ecl_sum_data_iget_first_value(const ecl_sum_data_type * data, int param_index) { + const ecl_sum_tstep_type * tstep = (const ecl_sum_tstep_type*) vector_iget_const(data->data, 0); + return ecl_sum_tstep_iget(tstep, param_index); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_index.c b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/ecl_sum_index.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp index 92f8d73bc5..051aca0b97 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_index.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp @@ -16,7 +16,7 @@ for more details. */ -#include +#include /* This file contains all the internalized information from parsing a diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp index 8228400d02..86eeaf7ecc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp @@ -19,14 +19,14 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define ECL_SUM_TSTEP_ID 88631 @@ -72,10 +72,10 @@ struct ecl_sum_tstep_struct { ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * src , const ecl_smspec_type * new_smspec, float default_value , const int * params_map) { int params_size = ecl_smspec_get_params_size( new_smspec ); - ecl_sum_tstep_type * target = util_alloc_copy(src , sizeof * src ); + ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); target->smspec = new_smspec; - target->data = util_malloc( params_size * sizeof * target->data ); + target->data = (float*)util_malloc( params_size * sizeof * target->data ); target->data_size = params_size; for (int i=0; i < params_size; i++) { @@ -89,20 +89,20 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * } ecl_sum_tstep_type * ecl_sum_tstep_alloc_copy( const ecl_sum_tstep_type * src ) { - ecl_sum_tstep_type * target = util_alloc_copy(src , sizeof * src ); - target->data = util_alloc_copy( src->data , src->data_size * sizeof * src->data ); + ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); + target->data = (float*)util_alloc_copy( src->data , src->data_size * sizeof * src->data ); return target; } static ecl_sum_tstep_type * ecl_sum_tstep_alloc( int report_step , int ministep_nr , const ecl_smspec_type * smspec) { - ecl_sum_tstep_type * tstep = util_malloc( sizeof * tstep ); + ecl_sum_tstep_type * tstep = (ecl_sum_tstep_type*)util_malloc( sizeof * tstep ); UTIL_TYPE_ID_INIT( tstep , ECL_SUM_TSTEP_ID); tstep->smspec = smspec; tstep->report_step = report_step; tstep->ministep = ministep_nr; tstep->data_size = ecl_smspec_get_params_size( smspec ); - tstep->data = util_calloc( tstep->data_size , sizeof * tstep->data ); + tstep->data = (float*)util_calloc( tstep->data_size , sizeof * tstep->data ); return tstep; } @@ -282,7 +282,7 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto ecl_kw_type * params_kw = ecl_kw_alloc( PARAMS_KW , compact_size , ECL_FLOAT ); const int * index = int_vector_get_ptr( index_map ); - float * data = ecl_kw_get_ptr( params_kw ); + float * data = (float*)ecl_kw_get_ptr( params_kw ); { int i; diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_sum_vector.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp index bc735e7b99..731d7a5cf5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp @@ -16,15 +16,15 @@ for more details. */ #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define ECL_SUM_VECTOR_TYPE_ID 8768778 @@ -59,7 +59,7 @@ static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const smspec_n ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords) { - ecl_sum_vector_type * ecl_sum_vector = util_malloc( sizeof * ecl_sum_vector ); + ecl_sum_vector_type * ecl_sum_vector = (ecl_sum_vector_type*)util_malloc( sizeof * ecl_sum_vector ); UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID); ecl_sum_vector->ecl_sum = ecl_sum; ecl_sum_vector->node_index_list = int_vector_alloc(0,0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_type.c b/ThirdParty/Ert/lib/ecl/ecl_type.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_type.c rename to ThirdParty/Ert/lib/ecl/ecl_type.cpp index a259bb5428..acf8bf4043 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_type.c +++ b/ThirdParty/Ert/lib/ecl/ecl_type.cpp @@ -20,8 +20,8 @@ #include #include -#include -#include +#include +#include /*****************************************************************/ /* The string names for the different ECLIPSE low-level @@ -37,7 +37,7 @@ static char * alloc_string_name(const ecl_data_type ecl_type) { return util_alloc_sprintf( "C%03d", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -64,11 +64,11 @@ ecl_data_type ecl_type_create(const ecl_type_enum type, const size_t element_siz ecl_type_create_from_type(type) ); - if(ecl_type_get_sizeof_ctype_fortio(ecl_type) != element_size) + if(ecl_type_get_sizeof_iotype(ecl_type) != element_size) util_abort( "%s: element_size mismatch for type %d, was: %d, expected: %d\n", __func__, type, - element_size, ecl_type_get_sizeof_ctype_fortio(ecl_type) + element_size, ecl_type_get_sizeof_iotype(ecl_type) ); return ecl_type; @@ -146,17 +146,25 @@ ecl_data_type ecl_type_create_from_name( const char * type_name ) { } -int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type ecl_type) { - if(ecl_type_is_char(ecl_type) || ecl_type_is_string(ecl_type)) - return ecl_type.element_size - 1; - else - return ecl_type_get_sizeof_ctype(ecl_type); +int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) { + return ecl_type.element_size; } -int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) { + +int ecl_type_get_sizeof_iotype(const ecl_data_type ecl_type) { + if (ecl_type_is_bool(ecl_type)) + return sizeof(int); + + if (ecl_type_is_char(ecl_type)) + return ecl_type.element_size -1; + + if (ecl_type_is_string(ecl_type)) + return ecl_type.element_size - 1; + return ecl_type.element_size; } + bool ecl_type_is_numeric(const ecl_data_type ecl_type) { return (ecl_type_is_int(ecl_type) || ecl_type_is_float(ecl_type) || diff --git a/ThirdParty/Ert/lib/ecl/ecl_type_python.c b/ThirdParty/Ert/lib/ecl/ecl_type_python.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/ecl_type_python.c rename to ThirdParty/Ert/lib/ecl/ecl_type_python.cpp index 8e5f843dd9..98bd5f8673 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_type_python.c +++ b/ThirdParty/Ert/lib/ecl/ecl_type_python.cpp @@ -1,14 +1,18 @@ -#include -#include -#include +#include +#include +#include /** * * Functions only to be used by the *PYTHON* prototype for EclDataType * */ + +#ifdef __cplusplus +extern "C" { + ecl_data_type * ecl_type_alloc_copy_python(const ecl_data_type * src_type) { - ecl_data_type * data_type = util_malloc(sizeof * src_type); + ecl_data_type * data_type = (ecl_data_type*)util_malloc(sizeof * src_type); memcpy(data_type, src_type, sizeof * data_type); return data_type; } @@ -40,10 +44,12 @@ const char * ecl_type_alloc_name_python(const ecl_data_type * ecl_type) { return ecl_type_alloc_name(*ecl_type); } -int ecl_type_get_sizeof_ctype_fortio_python(const ecl_data_type * ecl_type) { - return ecl_type_get_sizeof_ctype_fortio(*ecl_type); + +int ecl_type_get_sizeof_iotype_python(const ecl_data_type * ecl_type) { + return ecl_type_get_sizeof_iotype(*ecl_type); } + int ecl_type_get_sizeof_ctype_python(const ecl_data_type * ecl_type) { return ecl_type_get_sizeof_ctype(*ecl_type); } @@ -106,3 +112,7 @@ ecl_data_type * ecl_kw_get_data_type_python( const ecl_kw_type * ecl_kw ) { void ecl_kw_fread_indexed_data_python(fortio_type * fortio, offset_type data_offset, const ecl_data_type * data_type, int element_count, const int_vector_type* index_map, char* buffer) { return ecl_kw_fread_indexed_data(fortio, data_offset, *data_type, element_count, index_map, buffer); } + + +} +#endif diff --git a/ThirdParty/Ert/lib/ecl/ecl_util.c b/ThirdParty/Ert/lib/ecl/ecl_util.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_util.c rename to ThirdParty/Ert/lib/ecl/ecl_util.cpp index 3aac4927b5..f94bcb8f6c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_util.c +++ b/ThirdParty/Ert/lib/ecl/ecl_util.cpp @@ -24,13 +24,13 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #define ECL_PHASE_NAME_OIL "SOIL" // SHould match the keywords found in restart file @@ -218,7 +218,7 @@ ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int ecl_file_enum ecl_util_get_file_type(const char * filename, bool *fmt_file, int * report_nr) { - char *ext = strrchr(filename , '.'); + char *ext = (char*)strrchr(filename , '.'); if (ext == NULL) return ECL_OTHER_FILE; @@ -568,35 +568,35 @@ static bool numeric_extension_predicate(const char * filename, const char * base static bool summary_UPPERCASE_ASCII(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'A'); + return numeric_extension_predicate(filename, (const char*)base, 'A'); } static bool summary_UPPERCASE_BINARY(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'S'); + return numeric_extension_predicate(filename, (const char*)base, 'S'); } static bool summary_lowercase_ASCII(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'a'); + return numeric_extension_predicate(filename, (const char*)base, 'a'); } static bool summary_lowercase_BINARY(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 's'); + return numeric_extension_predicate(filename, (const char*)base, 's'); } static bool restart_UPPERCASE_ASCII(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'F'); + return numeric_extension_predicate(filename, (const char*)base, 'F'); } static bool restart_UPPERCASE_BINARY(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'X'); + return numeric_extension_predicate(filename, (const char*)base, 'X'); } static bool restart_lowercase_ASCII(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'f'); + return numeric_extension_predicate(filename, (const char*)base, 'f'); } static bool restart_lowercase_BINARY(const char * filename, const void * base) { - return numeric_extension_predicate(filename, base, 'x'); + return numeric_extension_predicate(filename, (const char*)base, 'x'); } static int ecl_util_select_predicate_filelist(const char * path, const char * base, ecl_file_enum file_type, bool fmt_file, bool upper_case, stringlist_type * filelist) { @@ -1211,7 +1211,7 @@ time_t ecl_util_get_start_date(const char * data_file) { util_abort("%s: sorry - could not find \"/\" termination of START keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; - buffer = util_calloc( buffer_size + 1 , sizeof * buffer ); + buffer = (char*)util_calloc( buffer_size + 1 , sizeof * buffer ); util_fseek( stream , start_pos , SEEK_SET); util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__); buffer[buffer_size] = '\0'; @@ -1248,7 +1248,7 @@ static int ecl_util_get_num_parallel_cpu__(basic_parser_type* parser, FILE* stre util_abort("%s: sorry - could not find \"/\" termination of PARALLEL keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; - buffer = util_calloc( buffer_size + 1 , sizeof * buffer ); + buffer = (char*)util_calloc( buffer_size + 1 , sizeof * buffer ); util_fseek( stream , start_pos , SEEK_SET); util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__); buffer[buffer_size] = '\0'; diff --git a/ThirdParty/Ert/lib/ecl/fault_block.c b/ThirdParty/Ert/lib/ecl/fault_block.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/fault_block.c rename to ThirdParty/Ert/lib/ecl/fault_block.cpp index d0b4f91e86..c8faddd136 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block.c +++ b/ThirdParty/Ert/lib/ecl/fault_block.cpp @@ -23,11 +23,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define FAULT_BLOCK_ID 3297376 @@ -52,7 +52,7 @@ static UTIL_SAFE_CAST_FUNCTION( fault_block , FAULT_BLOCK_ID ) fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id ) { - fault_block_type * block = util_malloc( sizeof * block ); + fault_block_type * block = (fault_block_type*)util_malloc( sizeof * block ); UTIL_TYPE_ID_INIT( block , FAULT_BLOCK_ID ); block->parent_layer = parent_layer; block->grid = fault_block_layer_get_grid( parent_layer ); diff --git a/ThirdParty/Ert/lib/ecl/fault_block_layer.c b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp similarity index 96% rename from ThirdParty/Ert/lib/ecl/fault_block_layer.c rename to ThirdParty/Ert/lib/ecl/fault_block_layer.cpp index a73e4e91ea..8f44f521cb 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block_layer.c +++ b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp @@ -201,7 +201,7 @@ fault_block_layer_type * fault_block_layer_alloc( const ecl_grid_type * grid , i if ((k < 0) || (k >= ecl_grid_get_nz( grid ))) return NULL; else { - fault_block_layer_type * layer = util_malloc( sizeof * layer ); + fault_block_layer_type * layer = (fault_block_layer_type*)util_malloc( sizeof * layer ); UTIL_TYPE_ID_INIT( layer , FAULT_BLOCK_LAYER_ID); layer->grid = grid; layer->k = k; @@ -215,7 +215,7 @@ fault_block_layer_type * fault_block_layer_alloc( const ecl_grid_type * grid , i fault_block_type * fault_block_layer_iget_block( const fault_block_layer_type * layer , int storage_index) { - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } @@ -224,7 +224,7 @@ fault_block_type * fault_block_layer_get_block( const fault_block_layer_type * l if (storage_index < 0) return NULL; else - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } @@ -233,7 +233,7 @@ fault_block_type * fault_block_layer_safe_get_block( fault_block_layer_type * la if (storage_index < 0) return fault_block_layer_add_block( layer , block_id ); else - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } diff --git a/ThirdParty/Ert/lib/ecl/fortio.c b/ThirdParty/Ert/lib/ecl/fortio.c index c9aad26b78..65478d7102 100644 --- a/ThirdParty/Ert/lib/ecl/fortio.c +++ b/ThirdParty/Ert/lib/ecl/fortio.c @@ -97,7 +97,7 @@ UTIL_IS_INSTANCE_FUNCTION( fortio , FORTIO_ID ); UTIL_SAFE_CAST_FUNCTION( fortio, FORTIO_ID ); static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner , bool writable) { - fortio_type * fortio = util_malloc(sizeof * fortio ); + fortio_type * fortio = (fortio_type*)util_malloc(sizeof * fortio ); UTIL_TYPE_ID_INIT( fortio, FORTIO_ID ); fortio->filename = util_alloc_string_copy(filename); fortio->endian_flip_header = endian_flip_header; diff --git a/ThirdParty/Ert/lib/ecl/grid_dims.c b/ThirdParty/Ert/lib/ecl/grid_dims.cpp similarity index 89% rename from ThirdParty/Ert/lib/ecl/grid_dims.c rename to ThirdParty/Ert/lib/ecl/grid_dims.cpp index 0d013fd5a8..1d2115b089 100644 --- a/ThirdParty/Ert/lib/ecl/grid_dims.c +++ b/ThirdParty/Ert/lib/ecl/grid_dims.cpp @@ -18,9 +18,9 @@ #include -#include +#include -#include +#include void grid_dims_init( grid_dims_type * dims , int nx, int ny , int nz , int nactive) { @@ -33,7 +33,7 @@ void grid_dims_init( grid_dims_type * dims , int nx, int ny , int nz , int nacti grid_dims_type * grid_dims_alloc( int nx, int ny , int nz , int nactive) { - grid_dims_type * dims = util_malloc( sizeof * dims ); + grid_dims_type * dims = (grid_dims_type*)util_malloc( sizeof * dims ); grid_dims_init( dims , nx , ny , nz , nactive ); return dims; } diff --git a/ThirdParty/Ert/lib/ecl/layer.c b/ThirdParty/Ert/lib/ecl/layer.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/layer.c rename to ThirdParty/Ert/lib/ecl/layer.cpp index 20a2180eec..7a79809f31 100644 --- a/ThirdParty/Ert/lib/ecl/layer.c +++ b/ThirdParty/Ert/lib/ecl/layer.cpp @@ -18,10 +18,10 @@ #include #include -#include -#include +#include +#include -#include +#include #define LAYER_TYPE_ID 55185409 @@ -50,14 +50,14 @@ UTIL_SAFE_CAST_FUNCTION( layer , LAYER_TYPE_ID ) layer_type * layer_alloc(int nx , int ny) { - layer_type * layer = util_malloc( sizeof * layer ); + layer_type * layer = (layer_type*)util_malloc( sizeof * layer ); UTIL_TYPE_ID_INIT( layer , LAYER_TYPE_ID ); layer->nx = nx; layer->ny = ny; layer->cell_sum = 0; { int data_size = (layer->nx + 1)* (layer->ny + 1); - layer->data = util_malloc( data_size * sizeof * layer->data ); + layer->data = (cell_type*)util_malloc( data_size * sizeof * layer->data ); { int g; for (g=0; g < data_size; g++) { @@ -524,7 +524,7 @@ static void layer_trace_block_content__( layer_type * layer , bool erase , int i static bool * layer_alloc_visited_mask( const layer_type * layer ) { int total_size = (layer->nx + 1)* (layer->ny + 1); - bool * visited = util_malloc( total_size * sizeof * visited ); + bool * visited = (bool*)util_malloc( total_size * sizeof * visited ); int g; for (g = 0; g < total_size; g++) visited[g] = false; diff --git a/ThirdParty/Ert/lib/ecl/nnc_info.c b/ThirdParty/Ert/lib/ecl/nnc_info.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/nnc_info.c rename to ThirdParty/Ert/lib/ecl/nnc_info.cpp index a60e1f4c9e..3db9cf4c42 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_info.c +++ b/ThirdParty/Ert/lib/ecl/nnc_info.cpp @@ -18,13 +18,13 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #define NNC_INFO_TYPE_ID 675415078 @@ -41,7 +41,7 @@ UTIL_IS_INSTANCE_FUNCTION( nnc_info , NNC_INFO_TYPE_ID ) nnc_info_type * nnc_info_alloc(int lgr_nr) { - nnc_info_type * nnc_info = util_malloc( sizeof * nnc_info ); + nnc_info_type * nnc_info = (nnc_info_type*)util_malloc( sizeof * nnc_info ); UTIL_TYPE_ID_INIT(nnc_info , NNC_INFO_TYPE_ID); nnc_info->lgr_list = vector_alloc_new(); nnc_info->lgr_index_map = int_vector_alloc(0, -1); @@ -56,7 +56,7 @@ nnc_info_type * nnc_info_alloc_copy( const nnc_info_type * src_info ) { int ivec; for (ivec = 0; ivec < vector_get_size( src_info->lgr_list ); ivec++) { - nnc_vector_type * copy_vector = nnc_vector_alloc_copy( vector_iget_const( src_info->lgr_list , ivec)); + nnc_vector_type * copy_vector = nnc_vector_alloc_copy( (const nnc_vector_type*)vector_iget_const( src_info->lgr_list , ivec)); nnc_info_add_vector( copy_info , copy_vector ); } @@ -112,12 +112,12 @@ nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_ if (-1 == lgr_index) return NULL; else - return vector_iget( nnc_info->lgr_list , lgr_index ); + return (nnc_vector_type*)vector_iget( nnc_info->lgr_list , lgr_index ); } nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index) { - return vector_iget( nnc_info->lgr_list , lgr_index ); + return (nnc_vector_type*)vector_iget( nnc_info->lgr_list , lgr_index ); } @@ -189,7 +189,7 @@ int nnc_info_get_total_size( const nnc_info_type * nnc_info ) { int num_nnc = 0; int ivec; for (ivec = 0; ivec < vector_get_size( nnc_info->lgr_list ); ivec++) { - const nnc_vector_type * nnc_vector = vector_iget( nnc_info->lgr_list , ivec ); + const nnc_vector_type * nnc_vector = (const nnc_vector_type*)vector_iget( nnc_info->lgr_list , ivec ); num_nnc += nnc_vector_get_size( nnc_vector ); } return num_nnc; diff --git a/ThirdParty/Ert/lib/ecl/nnc_vector.c b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/nnc_vector.c rename to ThirdParty/Ert/lib/ecl/nnc_vector.cpp index 253e44f4be..385fa91fe4 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_vector.c +++ b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp @@ -19,12 +19,12 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include @@ -45,7 +45,7 @@ static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID) nnc_vector_type * nnc_vector_alloc(int lgr_nr) { - nnc_vector_type * nnc_vector = util_malloc( sizeof * nnc_vector ); + nnc_vector_type * nnc_vector = (nnc_vector_type*)util_malloc( sizeof * nnc_vector ); UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID); nnc_vector->grid_index_list = int_vector_alloc(0,0); nnc_vector->nnc_index_list = int_vector_alloc(0,0); @@ -54,7 +54,7 @@ nnc_vector_type * nnc_vector_alloc(int lgr_nr) { } nnc_vector_type * nnc_vector_alloc_copy(const nnc_vector_type * src_vector) { - nnc_vector_type * copy_vector = util_malloc( sizeof * src_vector ); + nnc_vector_type * copy_vector = (nnc_vector_type*)util_malloc( sizeof * src_vector ); UTIL_TYPE_ID_INIT(copy_vector , NNC_VECTOR_TYPE_ID); copy_vector->lgr_nr = src_vector->lgr_nr; diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.c b/ThirdParty/Ert/lib/ecl/smspec_node.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/smspec_node.c rename to ThirdParty/Ert/lib/ecl/smspec_node.cpp index b96e0b69e8..a59428f3fb 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.c +++ b/ThirdParty/Ert/lib/ecl/smspec_node.cpp @@ -21,20 +21,20 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include @@ -363,7 +363,7 @@ float smspec_node_get_default( const smspec_node_type * smspec_node ) { smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) { - smspec_node_type * node = util_malloc( sizeof * node ); + smspec_node_type * node = (smspec_node_type*)util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , SMSPEC_TYPE_ID); node->params_index = params_index; @@ -404,7 +404,7 @@ static void smspec_node_set_lgr_name( smspec_node_type * index , const char * lg static void smspec_node_set_lgr_ijk( smspec_node_type * index , int lgr_i , int lgr_j , int lgr_k) { if (index->lgr_ijk == NULL) - index->lgr_ijk = util_calloc( 3 , sizeof * index->lgr_ijk ); + index->lgr_ijk = (int*)util_calloc( 3 , sizeof * index->lgr_ijk ); index->lgr_ijk[0] = lgr_i; index->lgr_ijk[1] = lgr_j; @@ -434,7 +434,7 @@ static void smspec_node_set_num( smspec_node_type * index , const int grid_dims[ index->num = num; if ((index->var_type == ECL_SMSPEC_COMPLETION_VAR) || (index->var_type == ECL_SMSPEC_BLOCK_VAR)) { int global_index = num - 1; - index->ijk = util_calloc( 3 , sizeof * index->ijk ); + index->ijk = (int*)util_calloc( 3 , sizeof * index->ijk ); index->ijk[2] = global_index / ( grid_dims[0] * grid_dims[1] ); global_index -= index->ijk[2] * (grid_dims[0] * grid_dims[1]); index->ijk[1] = global_index / grid_dims[0] ; global_index -= index->ijk[1] * grid_dims[0]; @@ -776,7 +776,7 @@ smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) { if( !node ) return NULL; { - smspec_node_type* copy = util_malloc( sizeof * copy ); + smspec_node_type* copy = (smspec_node_type*)util_malloc( sizeof * copy ); UTIL_TYPE_ID_INIT( copy, SMSPEC_TYPE_ID ); copy->gen_key1 = util_alloc_string_copy( node->gen_key1 ); copy->gen_key2 = util_alloc_string_copy( node->gen_key2 ); @@ -788,14 +788,14 @@ smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) { copy->ijk = NULL; if( node->ijk ) { - copy->ijk = util_calloc( 3 , sizeof * node->ijk ); + copy->ijk = (int*)util_calloc( 3 , sizeof * node->ijk ); memcpy( copy->ijk, node->ijk, 3 * sizeof( * node->ijk ) ); } copy->lgr_name = util_alloc_string_copy( node->lgr_name ); copy->lgr_ijk = NULL; if( node->lgr_ijk ) { - copy->lgr_ijk = util_calloc( 3 , sizeof * node->lgr_ijk ); + copy->lgr_ijk = (int*)util_calloc( 3 , sizeof * node->lgr_ijk ); memcpy( copy->lgr_ijk, node->lgr_ijk, 3 * sizeof( * node->lgr_ijk ) ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c index 9a95fdfe7e..5ebcee8f88 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -57,9 +58,29 @@ void test_float() { } +void test_bool() { + size_t N = 100; + bool * data = util_malloc(N * sizeof * data); + ecl_kw_type * kw = ecl_kw_alloc("BOOL", N , ECL_BOOL); + for (int i=0; i < N/2; i++) { + ecl_kw_iset_bool(kw, 2*i, true); + ecl_kw_iset_bool(kw, 2*i + 1, false); + + data[2*i] = true; + data[2*i + 1] = false; + } + + const bool * internal_data = ecl_kw_get_bool_ptr(kw); + + test_assert_int_equal( memcmp(internal_data, data, N * sizeof * data), 0); + ecl_kw_free(kw); + free(data); +} + int main( int argc , char ** argv) { test_int(); test_double(); test_float(); + test_bool(); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp index 3191250797..7c3e30215c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp @@ -20,10 +20,13 @@ #include #include -#include +#include + +#include #include #include +#include void test_kw_name() { ERT::EclKW< int > kw1( "short", 1 ); @@ -54,10 +57,10 @@ void test_kw_vector_string() { std::vector< const char* > vec = { "short", "sweet", - "padded ", - "verylongkeyword" + "padded " }; + std::vector too_long = {"1234567890"}; ERT::EclKW< const char* > kw( "XYZ", vec ); test_assert_size_t_equal( kw.size(), vec.size() ); @@ -65,10 +68,38 @@ void test_kw_vector_string() { test_assert_string_equal( kw.at( 0 ), "short " ); test_assert_string_equal( kw.at( 1 ), "sweet " ); test_assert_string_equal( kw.at( 2 ), vec.at( 2 ) ); - test_assert_string_equal( kw.at( 3 ), "verylong" ); - test_assert_string_not_equal( kw.at( 2 ), "verylongkeyword" ); + + test_assert_throw( ERT::EclKW("XY", too_long), std::range_error); +} + +void test_kw_vector_std_string() { + std::vector< const char* > vec = { + "short", + "sweet", + "padded ", + }; + std::vector too_long = {"1234567890"}; + ERT::EclKW< std::string > kw( "XYZ", vec ); + + test_assert_size_t_equal( kw.size(), vec.size() ); + + test_assert_string_equal( kw.at( 0 ).c_str(), "short " ); + test_assert_string_equal( kw.at( 1 ).c_str(), "sweet " ); + test_assert_string_equal( kw.at( 2 ).c_str(), vec.at( 2 ) ); + + test_assert_throw( ERT::EclKW("XY", too_long), std::range_error); +} + +void test_logical() { + //std::vector vec = {true,false,true,false}; + // ERT::EclKW kw("BOOL", vec); + // test_assert_int_equal(kw.size(), vec.size()); + + // for (size_t i=0; i < vec.size(); i++) + // test_assert_true( kw.at(i) == vec[i] ); } + void test_move_semantics_no_crash() { std::vector< int > vec = { 1, 2, 3, 4, 5 }; ERT::EclKW< int > kw1( "XYZ", vec ); @@ -96,13 +127,103 @@ void test_resize() { test_assert_int_equal( kw1.size() , 100 ); } +void test_data() { + std::vector d_data = {1,2,3,4}; + std::vector f_data = {10,20,30,40}; + std::vector i_data = {100,200,300,400}; + std::vector b_data = {true,false}; + std::vector s_data = {"S1", "S2", "S3"}; + + ERT::EclKW d_kw("DOUBLE", d_data); + auto d_data2 = d_kw.data(); + for (size_t i=0; i < d_data.size(); i++) + test_assert_true(d_data[i] == d_data2[i]); + + ERT::EclKW f_kw("FLOATx", f_data); + auto f_data2 = f_kw.data(); + for (size_t i=0; i < f_data.size(); i++) + test_assert_true(f_data[i] == f_data2[i]); + + ERT::EclKW i_kw("INT", i_data); + auto i_data2 = i_kw.data(); + for (size_t i=0; i < i_data.size(); i++) + test_assert_true(i_data[i] == i_data2[i]); + + //ERT::EclKW b_kw("bbb", b_data); + //auto b_data2 = b_kw.data(); + //for (size_t i=0; i < b_data.size(); i++) + // test_assert_true(b_data[i] == b_data2[i]); + + ERT::EclKW s_kw("sss", s_data); + auto s_data2 = s_kw.data(); + for (size_t i=0; i < s_data.size(); i++) + test_assert_true(s_data[i] == s_data2[i]); + +} + + +void test_read_write() { + std::vector d_data = {1,2,3,4}; + std::vector f_data = {10,20,30,40}; + std::vector i_data = {100,200,300,400}; + std::vector b_data = {true,false}; + std::vector s_data = {"S1", "S2", "S3"}; + + { + ERT::TestArea ta("test_fwrite"); + { + ERT::FortIO f("test_file", std::ios_base::out); + ERT::write_kw(f, "DOUBLE", d_data); + ERT::write_kw(f, "FLOAT", f_data); + ERT::write_kw(f, "INT", i_data); + ERT::write_kw(f, "BOOL", b_data); + ERT::write_kw(f, "STRING", s_data); + } + + { + ecl_file_type * f = ecl_file_open("test_file", 0); + ecl_kw_type * d_kw = ecl_file_iget_named_kw(f, "DOUBLE", 0); + ecl_kw_type * f_kw = ecl_file_iget_named_kw(f, "FLOAT", 0); + ecl_kw_type * i_kw = ecl_file_iget_named_kw(f, "INT", 0); + ecl_kw_type * b_kw = ecl_file_iget_named_kw(f, "BOOL", 0); + ecl_kw_type * s_kw = ecl_file_iget_named_kw(f, "STRING", 0); + + for (size_t i=0; i < d_data.size(); i++) + test_assert_true(d_data[i] == ecl_kw_iget_double(d_kw,i)); + + for (size_t i=0; i < f_data.size(); i++) + test_assert_true(f_data[i] == ecl_kw_iget_float(f_kw,i)); + + for (size_t i=0; i < i_data.size(); i++) + test_assert_true(i_data[i] == ecl_kw_iget_int(i_kw,i)); + + for (size_t i=0; i < b_data.size(); i++) + test_assert_true(b_data[i] == ecl_kw_iget_bool(b_kw,i)); + + for (size_t i=0; i < s_data.size(); i++) { + std::string s8 = ecl_kw_iget_char_ptr(s_kw, i); + test_assert_int_equal(s8.size(), 8); + s8.erase(s8.find_last_not_of(' ')+1); + test_assert_true( s_data[i] == s8); + } + + ecl_file_close(f); + } + } +} + + int main (int argc, char **argv) { test_kw_name(); test_kw_vector_assign(); test_kw_vector_string(); + test_kw_vector_std_string(); + test_logical(); test_move_semantics_no_crash(); test_exception_assing_ref_wrong_type(); test_resize(); + test_data(); + test_read_write(); } diff --git a/ThirdParty/Ert/lib/ecl/well_branch_collection.c b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp similarity index 87% rename from ThirdParty/Ert/lib/ecl/well_branch_collection.c rename to ThirdParty/Ert/lib/ecl/well_branch_collection.cpp index 959159de67..dfc43b96b3 100644 --- a/ThirdParty/Ert/lib/ecl/well_branch_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp @@ -18,14 +18,14 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #define WELL_BRANCH_COLLECTION_TYPE_ID 67177087 @@ -43,7 +43,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_branch_collection , WELL_BRANCH_COLLECTION_ well_branch_collection_type * well_branch_collection_alloc() { - well_branch_collection_type * branch_collection = util_malloc( sizeof * branch_collection ); + well_branch_collection_type * branch_collection = (well_branch_collection_type*)util_malloc( sizeof * branch_collection ); UTIL_TYPE_ID_INIT( branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID ); branch_collection->__start_segments = vector_alloc_new(); branch_collection->index_map = int_vector_alloc(0 , -1 ); @@ -82,7 +82,7 @@ bool well_branch_collection_has_branch( const well_branch_collection_type * bran const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index ) { if (index < vector_get_size( branches->__start_segments)) - return vector_iget_const( branches->__start_segments , index); + return (const well_segment_type*)vector_iget_const( branches->__start_segments , index); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_conn.c b/ThirdParty/Ert/lib/ecl/well_conn.cpp similarity index 77% rename from ThirdParty/Ert/lib/ecl/well_conn.c rename to ThirdParty/Ert/lib/ecl/well_conn.cpp index 74e87521b7..aaa394901c 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn.c +++ b/ThirdParty/Ert/lib/ecl/well_conn.cpp @@ -19,14 +19,14 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #define WELL_CONN_NORMAL_WELL_SEGMENT_ID -999 @@ -92,7 +92,7 @@ UTIL_SAFE_CAST_FUNCTION( well_conn , WELL_CONN_TYPE_ID) static well_conn_type * well_conn_alloc__( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) { if (well_conn_assert_direction( dir , matrix_connection)) { - well_conn_type * conn = util_malloc( sizeof * conn ); + well_conn_type * conn = (well_conn_type*)util_malloc( sizeof * conn ); UTIL_TYPE_ID_INIT( conn , WELL_CONN_TYPE_ID ); conn->i = i; conn->j = j; @@ -142,9 +142,6 @@ well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , double co return well_conn_alloc__(i , j , k , connection_factor , dir , open , segment_id , false); } - - - /* Observe that the (ijk) and branch values are shifted to zero offset to be aligned with the rest of the ert libraries. @@ -157,73 +154,74 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , int conn_nr ) { const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr ); - int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_INDEX ); - if (IC > 0) { - well_conn_type * conn; - int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_INDEX ) - 1; - int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_INDEX ) - 1; - int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_INDEX ) - 1; - double connection_factor = -1; - bool matrix_connection = true; - bool open; - well_conn_dir_enum dir = well_conn_fracX; - - /* Set the status */ - { - int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_INDEX ); - if (int_status > 0) - open = true; - else - open = false; - } + int IC =ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_INDEX ); + if (IC <= 0) + return NULL; /* IC < 0: Connection not in current LGR. */ - /* Set the K value and fracture flag. */ - { - if (header->dualp) { - int geometric_nz = header->nz / 2; - if (k >= geometric_nz) { - k -= geometric_nz; - matrix_connection = false; - } - } - } + /* + Out in the wild we have encountered files where the integer value used to + indicate direction has had an invalid value for some connections. In this + case we just return NULL and forget about the connection - it seems to work. + */ + int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_INDEX ); + if ((int_direction < 0) || (int_direction > ICON_FRACY)) { + fprintf(stderr,"Invalid direction value:%d encountered for well - connection ignored\n",int_direction); + return NULL; + } + + + int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_INDEX ) - 1; + int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_INDEX ) - 1; + int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_INDEX ) - 1; + double connection_factor = -1; + bool matrix_connection = true; + bool is_open = (ecl_kw_iget_int(icon_kw, icon_offset + ICON_STATUS_INDEX) > 0); + well_conn_dir_enum dir = well_conn_fracX; - /* Set the direction flag */ - { - int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_INDEX ); - if (int_direction == ICON_DEFAULT_DIR_VALUE) - int_direction = ICON_DEFAULT_DIR_TARGET; - - switch (int_direction) { - case(ICON_DIRX): - dir = well_conn_dirX; - break; - case(ICON_DIRY): - dir = well_conn_dirY; - break; - case(ICON_DIRZ): - dir = well_conn_dirZ; - break; - case(ICON_FRACX): - dir = well_conn_fracX; - break; - case(ICON_FRACY): - dir = well_conn_fracY; - break; - default: - util_abort("%s: icon direction value:%d not recognized\n",__func__ , int_direction); + /* Set the K value and fracture flag. */ + { + if (header->dualp) { + int geometric_nz = header->nz / 2; + if (k >= geometric_nz) { + k -= geometric_nz; + matrix_connection = false; } } + } - if (scon_kw) { - const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr ); - connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_INDEX); - } + /* Set the direction flag */ + if (int_direction == ICON_DEFAULT_DIR_VALUE) + int_direction = ICON_DEFAULT_DIR_TARGET; + + switch (int_direction) { + case(ICON_DIRX): + dir = well_conn_dirX; + break; + case(ICON_DIRY): + dir = well_conn_dirY; + break; + case(ICON_DIRZ): + dir = well_conn_dirZ; + break; + case(ICON_FRACX): + dir = well_conn_fracX; + break; + case(ICON_FRACY): + dir = well_conn_fracY; + break; + } + + if (scon_kw) { + const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr ); + connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_INDEX); + } + + { int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_INDEX ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; - conn = well_conn_alloc__(i,j,k,connection_factor,dir,open,segment_id,matrix_connection); + well_conn_type * conn = well_conn_alloc__(i,j,k,connection_factor,dir,is_open,segment_id,matrix_connection); if (xcon_kw) { const int xcon_offset = header->nxconz * (header->ncwmax * well_nr + conn_nr); @@ -242,8 +240,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , */ return conn; - } else - return NULL; /* IC < 0: Connection not in current LGR. */ + } } @@ -279,9 +276,9 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e } if (matrix_connection) - return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ ); + return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , (well_conn_dir_enum)open , well_conn_dirZ ); else - return well_conn_alloc_fracture( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ ); + return well_conn_alloc_fracture( conn_i , conn_j , conn_k , connection_factor , (well_conn_dir_enum)open , well_conn_dirZ ); } else // The well is completed in this LGR - however the wellhead is in another LGR. return NULL; diff --git a/ThirdParty/Ert/lib/ecl/well_conn_collection.c b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp similarity index 86% rename from ThirdParty/Ert/lib/ecl/well_conn_collection.c rename to ThirdParty/Ert/lib/ecl/well_conn_collection.cpp index 6277279614..2e77fd61a3 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp @@ -18,16 +18,16 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #define WELL_CONN_COLLECTION_TYPE_ID 67150087 @@ -43,7 +43,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_conn_collection , WELL_CONN_COLLECTION_TYPE well_conn_collection_type * well_conn_collection_alloc() { - well_conn_collection_type * wellcc = util_malloc( sizeof * wellcc ); + well_conn_collection_type * wellcc = (well_conn_collection_type*)util_malloc( sizeof * wellcc ); UTIL_TYPE_ID_INIT( wellcc , WELL_CONN_COLLECTION_TYPE_ID ); wellcc->connection_list = vector_alloc_new(); return wellcc; @@ -86,15 +86,16 @@ int well_conn_collection_get_size( const well_conn_collection_type * wellcc ) { const well_conn_type * well_conn_collection_iget_const(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return vector_iget_const( wellcc->connection_list , index ); + return (const well_conn_type*)vector_iget_const( wellcc->connection_list , index ); else return NULL; } + well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return vector_iget( wellcc->connection_list , index ); + return (well_conn_type*)vector_iget( wellcc->connection_list , index ); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_info.c b/ThirdParty/Ert/lib/ecl/well_info.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/well_info.c rename to ThirdParty/Ert/lib/ecl/well_info.cpp index d57fdf8de3..d2e00429b4 100644 --- a/ThirdParty/Ert/lib/ecl/well_info.c +++ b/ThirdParty/Ert/lib/ecl/well_info.cpp @@ -19,23 +19,23 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* @@ -192,7 +192,7 @@ struct well_info_struct { */ well_info_type * well_info_alloc( const ecl_grid_type * grid) { - well_info_type * well_info = util_malloc( sizeof * well_info ); + well_info_type * well_info = (well_info_type*)util_malloc( sizeof * well_info ); well_info->wells = hash_alloc(); well_info->well_names = stringlist_alloc_new(); well_info->grid = grid; @@ -205,7 +205,7 @@ bool well_info_has_well( well_info_type * well_info , const char * well_name ) { } well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name) { - return hash_get( well_info->wells , well_name ); + return (well_ts_type*)hash_get( well_info->wells , well_name ); } static void well_info_add_new_ts( well_info_type * well_info , const char * well_name) { diff --git a/ThirdParty/Ert/lib/ecl/well_rseg_loader.c b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp similarity index 85% rename from ThirdParty/Ert/lib/ecl/well_rseg_loader.c rename to ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp index f457cf1f77..29e507409b 100644 --- a/ThirdParty/Ert/lib/ecl/well_rseg_loader.c +++ b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp @@ -18,15 +18,15 @@ #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include @@ -41,14 +41,14 @@ struct well_rseg_loader_struct { well_rseg_loader_type * well_rseg_loader_alloc(ecl_file_view_type * rst_view) { - well_rseg_loader_type * loader = util_malloc(sizeof * loader); + well_rseg_loader_type * loader = (well_rseg_loader_type*)util_malloc(sizeof * loader); int element_count = 4; loader->rst_view = rst_view; loader->relative_index_map = int_vector_alloc(0, 0); loader->absolute_index_map = int_vector_alloc(0, 0); - loader->buffer = util_malloc(element_count * sizeof(double)); + loader->buffer = (char*)util_malloc(element_count * sizeof(double)); loader->kw = RSEG_KW; int_vector_append(loader->relative_index_map, RSEG_DEPTH_INDEX); diff --git a/ThirdParty/Ert/lib/ecl/well_segment.c b/ThirdParty/Ert/lib/ecl/well_segment.cpp similarity index 92% rename from ThirdParty/Ert/lib/ecl/well_segment.c rename to ThirdParty/Ert/lib/ecl/well_segment.cpp index b1b4912cdd..8209506788 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment.c +++ b/ThirdParty/Ert/lib/ecl/well_segment.cpp @@ -18,17 +18,17 @@ #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define WELL_SEGMENT_TYPE_ID 2209166 @@ -53,7 +53,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_segment , WELL_SEGMENT_TYPE_ID ) well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data) { - well_segment_type * segment = util_malloc( sizeof * segment ); + well_segment_type * segment = (well_segment_type*)util_malloc( sizeof * segment ); UTIL_TYPE_ID_INIT( segment , WELL_SEGMENT_TYPE_ID ); segment->link_count = 0; @@ -212,7 +212,7 @@ bool well_segment_add_connection( well_segment_type * segment , const char * gri hash_insert_hash_owned_ref( segment->connections , grid_name , well_conn_collection_alloc() , well_conn_collection_free__ ); { - well_conn_collection_type * connections = hash_get( segment->connections , grid_name ); + well_conn_collection_type * connections = (well_conn_collection_type*)hash_get( segment->connections , grid_name ); well_conn_collection_add_ref( connections , conn ); } return true; @@ -223,7 +223,7 @@ bool well_segment_add_connection( well_segment_type * segment , const char * gri const well_conn_collection_type * well_segment_get_connections(const well_segment_type * segment , const char * grid_name ) { if (well_segment_has_grid_connections( segment , grid_name)) - return hash_get( segment->connections , grid_name); + return (const well_conn_collection_type*)hash_get( segment->connections , grid_name); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_segment_collection.c b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/well_segment_collection.c rename to ThirdParty/Ert/lib/ecl/well_segment_collection.cpp index a919ea0c33..dadfe69449 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp @@ -18,18 +18,18 @@ #include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct well_segment_collection_struct { @@ -40,7 +40,7 @@ struct well_segment_collection_struct { well_segment_collection_type * well_segment_collection_alloc(void) { - well_segment_collection_type * segment_collection = util_malloc( sizeof * segment_collection ); + well_segment_collection_type * segment_collection = (well_segment_collection_type*)util_malloc( sizeof * segment_collection ); segment_collection->__segment_storage = vector_alloc_new(); segment_collection->segment_index_map = int_vector_alloc( 0 , -1 ); @@ -77,7 +77,7 @@ void well_segment_collection_add( well_segment_collection_type * segment_collect well_segment_type * well_segment_collection_iget( const well_segment_collection_type * segment_collection , int index) { - return vector_iget( segment_collection->__segment_storage , index ); + return (well_segment_type*)vector_iget( segment_collection->__segment_storage , index ); } diff --git a/ThirdParty/Ert/lib/ecl/well_state.c b/ThirdParty/Ert/lib/ecl/well_state.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/well_state.c rename to ThirdParty/Ert/lib/ecl/well_state.cpp index 91d91862a6..7ee3129efe 100644 --- a/ThirdParty/Ert/lib/ecl/well_state.c +++ b/ThirdParty/Ert/lib/ecl/well_state.cpp @@ -25,27 +25,27 @@ #include #include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include /* @@ -193,7 +193,7 @@ UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID) well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from) { - well_state_type * well_state = util_malloc( sizeof * well_state ); + well_state_type * well_state = (well_state_type*)util_malloc( sizeof * well_state ); UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID ); well_state->index_wellhead = vector_alloc_new(); well_state->name_wellhead = hash_alloc(); @@ -340,7 +340,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons while (true) { bool found = false; { - char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); + char * lgr_well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); if ( strcmp( well_state->name , lgr_well_name) == 0) found = true; @@ -425,7 +425,7 @@ static void well_state_add_connections__( well_state_type * well_state , xcon_kw = ecl_file_view_iget_named_kw(rst_view, XCON_KW, 0); } - well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name ); + well_conn_collection_type * wellcc = (well_conn_collection_type*)hash_get( well_state->connections , grid_name ); well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw, xcon_kw , well_nr , header ); } ecl_rsthead_free( header ); @@ -518,7 +518,7 @@ bool well_state_add_MSW2( well_state_type * well_state , hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections ); while (!hash_iter_is_complete( grid_iter )) { const char * grid_name = hash_iter_get_next_key( grid_iter ); - const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name ); + const well_conn_collection_type * connections = (const well_conn_collection_type*)hash_get( well_state->connections , grid_name ); well_segment_collection_add_connections( well_state->segments , grid_name , connections ); } hash_iter_free( grid_iter ); @@ -581,7 +581,7 @@ well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , { const int zwel_offset = global_header->nzwelz * global_well_nr; - name = util_alloc_strip_copy(ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name + name = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name } well_state = well_state_alloc(name , global_well_nr , open , type , report_nr , global_header->sim_time); @@ -631,20 +631,20 @@ time_t well_state_get_sim_time( const well_state_type * well_state ) { Will return NULL if no wellhead in this grid. */ const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr) { - return vector_safe_iget_const( well_state->index_wellhead , grid_nr ); + return (const well_conn_type*)vector_safe_iget_const( well_state->index_wellhead , grid_nr ); } const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name) { if (hash_has_key( well_state->name_wellhead , grid_name)) - return hash_get( well_state->name_wellhead , grid_name ); + return (const well_conn_type*)hash_get( well_state->name_wellhead , grid_name ); else return NULL; } const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ) { if (hash_has_key( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID)) - return hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID ); + return (const well_conn_type*)hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID ); else return NULL; } @@ -672,7 +672,7 @@ const char * well_state_get_name( const well_state_type * well_state ) { const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) { if (hash_has_key( well_state->connections , grid_name)) - return hash_get( well_state->connections , grid_name); + return (const well_conn_collection_type*)hash_get( well_state->connections , grid_name); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_ts.c b/ThirdParty/Ert/lib/ecl/well_ts.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/well_ts.c rename to ThirdParty/Ert/lib/ecl/well_ts.cpp index 9680131eb1..2a51809e72 100644 --- a/ThirdParty/Ert/lib/ecl/well_ts.c +++ b/ThirdParty/Ert/lib/ecl/well_ts.cpp @@ -62,12 +62,12 @@ #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include @@ -91,7 +91,7 @@ struct well_ts_struct { /******************************************************************/ static well_node_type * well_node_alloc( well_state_type * well_state) { - well_node_type * node = util_malloc( sizeof * node ); + well_node_type * node = (well_node_type*)util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , WELL_NODE_TYPE_ID ); node->report_nr = well_state_get_report_nr( well_state ); node->sim_time = well_state_get_sim_time( well_state ); @@ -131,7 +131,7 @@ static int well_node_time_cmp( const void * arg1 , const void * arg2) { /*****************************************************************/ static well_ts_type * well_ts_alloc_empty( ) { - well_ts_type * well_ts = util_malloc( sizeof * well_ts ); + well_ts_type * well_ts = (well_ts_type*)util_malloc( sizeof * well_ts ); UTIL_TYPE_ID_INIT( well_ts , WELL_TS_TYPE_ID ); well_ts->ts = vector_alloc_new(); @@ -157,8 +157,8 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , return 0; else { - const well_node_type * first_node = vector_iget_const( well_ts->ts , 0 ); - const well_node_type * last_node = vector_get_last_const( well_ts->ts ); + const well_node_type * first_node = (const well_node_type*)vector_iget_const( well_ts->ts , 0 ); + const well_node_type * last_node = (const well_node_type*)vector_get_last_const( well_ts->ts ); if (use_report) { if (report_step < first_node->report_nr) @@ -181,7 +181,7 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , while (true) { int center_index = (lower_index + upper_index) / 2; - const well_node_type * center_node = vector_iget_const( well_ts->ts , center_index ); + const well_node_type * center_node = (const well_node_type*)vector_iget_const( well_ts->ts , center_index ); double cmp; if (use_report) cmp = center_node->report_nr - report_step; @@ -221,11 +221,11 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t // Inline check that the index is correct { bool OK = true; - const well_node_type * node = vector_iget_const( well_ts->ts , index ); + const well_node_type * node = (const well_node_type*)vector_iget_const( well_ts->ts , index ); well_node_type * next_node = NULL; if (index < (vector_get_size( well_ts->ts ) - 1)) - next_node = vector_iget( well_ts->ts , index + 1); + next_node = (well_node_type*)vector_iget( well_ts->ts , index + 1); if (use_report) { if (index < 0) { @@ -268,7 +268,7 @@ void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) { vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); if (vector_get_size( well_ts->ts ) > 1) { - const well_node_type * last_node = vector_get_last_const(well_ts->ts ); + const well_node_type * last_node = (const well_node_type*)vector_get_last_const(well_ts->ts ); if (new_node->sim_time < last_node->sim_time) // The new node is chronologically before the previous node; // i.e. we must sort the nodes in time. This should probably happen @@ -309,7 +309,7 @@ well_state_type * well_ts_get_last_state( const well_ts_type * well_ts) { well_state_type * well_ts_iget_state( const well_ts_type * well_ts , int index) { - well_node_type * node = vector_iget( well_ts->ts , index ); + well_node_type * node = (well_node_type*)vector_iget( well_ts->ts , index ); return node->well_state; } diff --git a/ThirdParty/Ert/lib/ert_api_config.h.in b/ThirdParty/Ert/lib/ert_api_config.h.in index 08c3e5da96..0a74e7d730 100644 --- a/ThirdParty/Ert/lib/ert_api_config.h.in +++ b/ThirdParty/Ert/lib/ert_api_config.h.in @@ -7,6 +7,7 @@ #cmakedefine ERT_HAVE_OPENDIR #cmakedefine ERT_HAVE_SYMLINK #cmakedefine ERT_HAVE_READLINKAT +#cmakedefine ERT_HAVE_READLINKAT_DECLARATION #cmakedefine ERT_HAVE_GLOB #cmakedefine ERT_HAVE_GETUID #cmakedefine ERT_HAVE_REGEXP diff --git a/ThirdParty/Ert/lib/ert_api_config.hpp.in b/ThirdParty/Ert/lib/ert_api_config.hpp.in new file mode 100644 index 0000000000..78411e4360 --- /dev/null +++ b/ThirdParty/Ert/lib/ert_api_config.hpp.in @@ -0,0 +1 @@ +#include diff --git a/ThirdParty/Ert/lib/geometry/geo_pointset.c b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp similarity index 92% rename from ThirdParty/Ert/lib/geometry/geo_pointset.c rename to ThirdParty/Ert/lib/geometry/geo_pointset.cpp index 32eaa2ea2d..970b2fd2cb 100644 --- a/ThirdParty/Ert/lib/geometry/geo_pointset.c +++ b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp @@ -21,9 +21,9 @@ #include #include -#include +#include -#include +#include #define INIT_SIZE 256 @@ -42,17 +42,17 @@ struct geo_pointset_struct { static void geo_pointset_resize( geo_pointset_type * pointset, int new_alloc_size) { - pointset->xcoord = util_realloc( pointset->xcoord , new_alloc_size * sizeof * pointset->xcoord ); - pointset->ycoord = util_realloc( pointset->ycoord , new_alloc_size * sizeof * pointset->ycoord ); + pointset->xcoord = (double*)util_realloc( pointset->xcoord , new_alloc_size * sizeof * pointset->xcoord ); + pointset->ycoord = (double*)util_realloc( pointset->ycoord , new_alloc_size * sizeof * pointset->ycoord ); if (pointset->internal_z) - pointset->zcoord = util_realloc( pointset->zcoord , new_alloc_size * sizeof * pointset->zcoord); + pointset->zcoord = (double*)util_realloc( pointset->zcoord , new_alloc_size * sizeof * pointset->zcoord); pointset->alloc_size = new_alloc_size; } geo_pointset_type * geo_pointset_alloc( bool internal_z) { - geo_pointset_type * pointset = util_malloc( sizeof * pointset ); + geo_pointset_type * pointset = (geo_pointset_type*)util_malloc( sizeof * pointset ); pointset->xcoord = NULL; pointset->ycoord = NULL; pointset->zcoord = NULL; diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon.c b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp similarity index 95% rename from ThirdParty/Ert/lib/geometry/geo_polygon.c rename to ThirdParty/Ert/lib/geometry/geo_polygon.cpp index 1780a9d0db..516d90de04 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon.c +++ b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp @@ -21,12 +21,12 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include @@ -45,7 +45,7 @@ UTIL_IS_INSTANCE_FUNCTION( geo_polygon , GEO_POLYGON_TYPE_ID); geo_polygon_type * geo_polygon_alloc(const char * name) { - geo_polygon_type * polygon = util_malloc( sizeof * polygon ); + geo_polygon_type * polygon = (geo_polygon_type*)util_malloc( sizeof * polygon ); UTIL_TYPE_ID_INIT( polygon , GEO_POLYGON_TYPE_ID ); polygon->xcoord = double_vector_alloc( 0 , 0 ); @@ -189,11 +189,11 @@ void geo_polygon_iget_xy(const geo_polygon_type * polygon , int index , double * bool geo_polygon_segment_intersects(const geo_polygon_type * polygon , double x1 , double y1 , double x2 , double y2) { bool intersects = false; - double ** points = util_malloc( 4 * sizeof * points); + double ** points = (double**)util_malloc( 4 * sizeof * points); { int i; for (i = 0; i < 4; i++) - points[i] = util_malloc( 2 * sizeof * points[i]); + points[i] = (double*)util_malloc( 2 * sizeof * points[i]); } points[0][0] = x1; diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.c b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp similarity index 86% rename from ThirdParty/Ert/lib/geometry/geo_polygon_collection.c rename to ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp index 269a9032fa..f02ddb1374 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.c +++ b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp @@ -20,13 +20,13 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include @@ -42,7 +42,7 @@ struct geo_polygon_collection_struct { UTIL_IS_INSTANCE_FUNCTION( geo_polygon_collection , GEO_POLYGON_COLLECTION_TYPE_ID) geo_polygon_collection_type * geo_polygon_collection_alloc( ) { - geo_polygon_collection_type * polygons = util_malloc( sizeof * polygons ); + geo_polygon_collection_type * polygons = (geo_polygon_collection_type*)util_malloc( sizeof * polygons ); UTIL_TYPE_ID_INIT( polygons , GEO_POLYGON_COLLECTION_TYPE_ID ); polygons->polygon_list = vector_alloc_new(); polygons->polygon_map = hash_alloc(); @@ -106,10 +106,10 @@ void geo_polygon_collection_free( geo_polygon_collection_type * polygons ) { geo_polygon_type * geo_polygon_collection_iget_polygon(const geo_polygon_collection_type * polygons , int index) { - return vector_iget( polygons->polygon_list , index ); + return (geo_polygon_type*)vector_iget( polygons->polygon_list , index ); } geo_polygon_type * geo_polygon_collection_get_polygon(const geo_polygon_collection_type * polygons , const char * polygon_name) { - return hash_get( polygons->polygon_map , polygon_name ); + return (geo_polygon_type*)hash_get( polygons->polygon_map , polygon_name ); } diff --git a/ThirdParty/Ert/lib/geometry/geo_region.c b/ThirdParty/Ert/lib/geometry/geo_region.cpp similarity index 92% rename from ThirdParty/Ert/lib/geometry/geo_region.c rename to ThirdParty/Ert/lib/geometry/geo_region.cpp index e1def85bec..76a1a1f11a 100644 --- a/ThirdParty/Ert/lib/geometry/geo_region.c +++ b/ThirdParty/Ert/lib/geometry/geo_region.cpp @@ -20,15 +20,15 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define GEO_REGION_TYPE_ID 4431973 @@ -47,14 +47,14 @@ struct geo_region_struct { static UTIL_SAFE_CAST_FUNCTION( geo_region , GEO_REGION_TYPE_ID ) geo_region_type * geo_region_alloc( const geo_pointset_type * pointset , bool preselect) { - geo_region_type * region = util_malloc( sizeof * region ); + geo_region_type * region = (geo_region_type*)util_malloc( sizeof * region ); UTIL_TYPE_ID_INIT( region , GEO_REGION_TYPE_ID ); region->pointset = pointset; region->pointset_size = geo_pointset_get_size( pointset ); region->preselect = preselect; region->index_list = int_vector_alloc( 0, 0); - region->active_mask = util_calloc( region->pointset_size , sizeof * region->active_mask ); + region->active_mask = (bool*)util_calloc( region->pointset_size , sizeof * region->active_mask ); geo_region_reset( region ); return region; diff --git a/ThirdParty/Ert/lib/geometry/geo_surface.c b/ThirdParty/Ert/lib/geometry/geo_surface.cpp similarity index 97% rename from ThirdParty/Ert/lib/geometry/geo_surface.c rename to ThirdParty/Ert/lib/geometry/geo_surface.cpp index 7d9b443c77..c3b25e25e4 100644 --- a/ThirdParty/Ert/lib/geometry/geo_surface.c +++ b/ThirdParty/Ert/lib/geometry/geo_surface.cpp @@ -20,11 +20,11 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #define __PI 3.14159265 #define GEO_SURFACE_TYPE_ID 111743 @@ -61,7 +61,7 @@ static void geo_surface_copy_header( const geo_surface_type * src , geo_surface_ } static geo_surface_type * geo_surface_alloc_empty( bool internal_z ) { - geo_surface_type * surface = util_malloc( sizeof * surface ); + geo_surface_type * surface = (geo_surface_type*)util_malloc( sizeof * surface ); UTIL_TYPE_ID_INIT( surface , GEO_SURFACE_TYPE_ID ) surface->pointset = geo_pointset_alloc( internal_z ); return surface; @@ -242,7 +242,7 @@ static bool geo_surface_fload_irap( geo_surface_type * surface , const char * fi double * zcoord = NULL; if (loadz) { - zcoord = util_calloc( surface->nx * surface->ny , sizeof * zcoord ); + zcoord = (double*)util_calloc( surface->nx * surface->ny , sizeof * zcoord ); read_ok = geo_surface_fscanf_zcoord( surface , stream , zcoord ); } diff --git a/ThirdParty/Ert/lib/geometry/geo_util.c b/ThirdParty/Ert/lib/geometry/geo_util.cpp similarity index 98% rename from ThirdParty/Ert/lib/geometry/geo_util.c rename to ThirdParty/Ert/lib/geometry/geo_util.cpp index a0a7a1d077..2dda526704 100644 --- a/ThirdParty/Ert/lib/geometry/geo_util.c +++ b/ThirdParty/Ert/lib/geometry/geo_util.cpp @@ -21,9 +21,9 @@ #include #include -#include +#include -#include +#include #define EPSILON 0.000001 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp index 34ad650fcd..68f834428d 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp @@ -26,11 +26,9 @@ #include #include -#include -#include -#include - #include +#include +#include #include namespace ERT { @@ -45,12 +43,27 @@ namespace ERT { template<> struct ecl_type< int > { static const ecl_type_enum type { ECL_INT_TYPE }; }; + template<> struct ecl_type + { static const ecl_type_enum type {ECL_BOOL_TYPE}; }; + template<> struct ecl_type< char* > { static const ecl_type_enum type { ECL_CHAR_TYPE }; }; template<> struct ecl_type< const char* > { static const ecl_type_enum type { ECL_CHAR_TYPE }; }; + /* + Both std::string and char* are mapped to the eight character string type + ECL_CHAR_TYPE. That implies that the variable length string type + ECL_STRING is invisible from this API. + */ + + template<> struct ecl_type< std::string > + { static const ecl_type_enum type { ECL_CHAR_TYPE}; }; + + template<> struct ecl_type + { static const ecl_type_enum type {ECL_CHAR_TYPE}; }; + template class EclKW_ref { public: @@ -98,21 +111,36 @@ namespace ERT { ecl_kw_type* m_kw = nullptr; }; +template<> +inline bool EclKW_ref< bool >::at( size_t i ) const { + return ecl_kw_iget_bool( this->m_kw, i ); +} + + template<> inline const char* EclKW_ref< const char* >::at( size_t i ) const { return ecl_kw_iget_char_ptr( this->m_kw, i ); } +template<> +inline std::string EclKW_ref< std::string >::at( size_t i ) const { + return ecl_kw_iget_char_ptr( this->m_kw, i ); +} + + + /* - The current implementation of "string" storage in the underlying C - ecl_kw structure does not lend itself to easily implement - operator[]. We have therefore explicitly deleted it here. + The current implementation of "string" and "bool" storage in the underlying C + ecl_kw structure does not lend itself to easily implement operator[]. We have + therefore explicitly deleted them here. */ template<> const char*& EclKW_ref< const char* >::operator[]( size_t i ) = delete; +template<> +bool& EclKW_ref::operator[]( size_t i) = delete; template< typename T > class EclKW : public EclKW_ref< T > { @@ -151,6 +179,14 @@ class EclKW : public EclKW_ref< T > { target[ i ] = T( data[ i ] ); } + + std::vector data() const { + const T* ptr = static_cast(ecl_kw_get_ptr(this->m_kw)); + std::vector vector; + vector.assign(ptr, ptr + this->size()); + return vector; + } + static EclKW load( FortIO& fortio ) { ecl_kw_type* c_ptr = ecl_kw_fread_alloc( fortio.get() ); @@ -159,16 +195,87 @@ class EclKW : public EclKW_ref< T > { return EclKW( c_ptr ); } + }; + template<> inline EclKW< const char* >::EclKW( const std::string& kw, const std::vector< const char* >& data ) : EclKW( kw, data.size() ) { auto* ptr = this->get(); - for( size_t i = 0; i < data.size(); ++i ) + for( size_t i = 0; i < data.size(); ++i ) { + if (strlen(data[i]) > 8) + throw std::range_error("Strings must be maximum 8 characters long"); ecl_kw_iset_string8( ptr, i, data[ i ] ); + } +} + +template<> inline +EclKW< std::string >::EclKW( const std::string& kw, + const std::vector< std::string >& data ) : + EclKW( kw, data.size() ) +{ + auto* ptr = this->get(); + for( size_t i = 0; i < data.size(); ++i ) { + if (data[i].size() > 8) + throw std::range_error("Strings must be maximum 8 characters long"); + ecl_kw_iset_string8( ptr, i, data[ i ].c_str() ); + } +} + + +template<> +template<> inline +EclKW< std::string >::EclKW( const std::string& kw, + const std::vector< const char* >& data ) : + EclKW( kw, data.size() ) +{ + auto* ptr = this->get(); + for( size_t i = 0; i < data.size(); ++i) { + if (strlen(data[i]) > 8) + throw std::range_error("Strings must be maximum 8 characters long"); + ecl_kw_iset_string8( ptr, i, data[ i ]); + } +} + +template<> inline +EclKW::EclKW( const std::string& kw, const std::vector< bool >& data ) : + EclKW( kw, data.size() ) +{ + for (size_t i = 0; i < data.size(); i++) + ecl_kw_iset_bool( this->m_kw, i, data[i]); +} + +template<> inline +std::vector EclKW::data() const +{ + std::vector strings; + auto* ptr = this->get(); + for( size_t i = 0; i < this->size(); ++i ) { + std::string s8 = ecl_kw_iget_char_ptr(ptr, i); + s8.erase(s8.find_last_not_of(' ')+1); + strings.push_back( s8 ); + } + return strings; +} + +/* + Will write an ecl_kw instance to the open Fortio file. +*/ +template +void write_kw(FortIO& fortio, const std::string& kw, const std::vector& data) { + EclKW ecl_kw(kw, data); + ecl_kw_fwrite(ecl_kw.get(), fortio.get()); +} + +/* + Will write an empty ecl_kw instance of type 'MESS' to the Fortio file. +*/ +inline void write_mess(FortIO& fortio, const std::string& kw) { + ecl_kw_type * ecl_kw = ecl_kw_alloc(kw.c_str(), 0, ECL_MESS); + ecl_kw_fwrite(ecl_kw, fortio.get()); } } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp new file mode 100644 index 0000000000..4b1a822b03 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp new file mode 100644 index 0000000000..289c1dd7c4 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp new file mode 100644 index 0000000000..a0b3ac55e9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp new file mode 100644 index 0000000000..6fade2adb9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp new file mode 100644 index 0000000000..35352ecfd1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp new file mode 100644 index 0000000000..4fbb391a83 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h index c3f78f2029..67c44b9bfb 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h @@ -18,7 +18,7 @@ #ifndef ERT_ECL_GRAV_H #define ERT_ECL_GRAV_H -#ifdef __plusplus +#ifdef __cplusplus extern "C" { #endif @@ -36,11 +36,12 @@ ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl ecl_grav_survey_type * ecl_grav_add_survey_FIP( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); ecl_grav_survey_type * ecl_grav_add_survey_PORMOD( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); ecl_grav_survey_type * ecl_grav_add_survey_RPORV( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); +ecl_grav_survey_type * ecl_grav_add_survey_RFIP( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char * monitor , ecl_region_type * region , double utm_x, double utm_y , double depth, int phase_mask); void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , double default_density); void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density); -#ifdef __plusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp new file mode 100644 index 0000000000..9dbd0ae404 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp new file mode 100644 index 0000000000..df878a9337 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp new file mode 100644 index 0000000000..555ef8dc1c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h index 0e8689fa6f..5ae7b115db 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h @@ -76,6 +76,7 @@ extern "C" { double ecl_grid_get_cell_dz3( const ecl_grid_type * grid , int i , int j , int k); double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j , int k); + void ecl_grid_get_distance(const ecl_grid_type * grid , int global_index1, int global_index2 , double *dx , double *dy , double *dz); double ecl_grid_get_cdepth1A(const ecl_grid_type * grid , int active_index); double ecl_grid_get_cdepth1(const ecl_grid_type * grid , int global_index); double ecl_grid_get_cdepth3(const ecl_grid_type * grid , int i, int j , int k); @@ -118,6 +119,9 @@ extern "C" { ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const double * depthz , const int * actnum); + ecl_kw_type * ecl_grid_alloc_volume_kw( const ecl_grid_type * grid , bool active_size); + ecl_kw_type * ecl_grid_alloc_mapaxes_kw( const ecl_grid_type * grid ); + ecl_kw_type * ecl_grid_alloc_coord_kw( const ecl_grid_type * grid); bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp new file mode 100644 index 0000000000..a27e4887ee --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp new file mode 100644 index 0000000000..32ca2236ef --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp new file mode 100644 index 0000000000..d32e7d5d77 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp new file mode 100644 index 0000000000..ef37a89689 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h index 6792346101..c33f01274b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h @@ -18,6 +18,9 @@ #ifndef ERT_ECL_IO_CONFIG_H #define ERT_ECL_IO_CONFIG_H +#ifdef __cplusplus +extern "C" { +#endif typedef struct ecl_io_config_struct ecl_io_config_type; @@ -38,4 +41,7 @@ bool ecl_io_config_get_unified_summary(ecl_io_config_type *); ecl_io_config_type * ecl_io_config_alloc(bool ,bool ,bool); void ecl_io_config_free(ecl_io_config_type * ); +#ifdef __cplusplus +} +#endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp new file mode 100644 index 0000000000..fdbe583b39 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h index 9eacaf31ef..21b22bd385 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h @@ -72,7 +72,6 @@ extern "C" { void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio); bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio); ecl_data_type ecl_kw_get_data_type(const ecl_kw_type *); - size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type *); const char * ecl_kw_get_header8(const ecl_kw_type *); const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw ); ecl_kw_type * ecl_kw_alloc_empty(void); @@ -88,6 +87,7 @@ extern "C" { bool ecl_kw_fread_realloc(ecl_kw_type *, fortio_type *); void ecl_kw_fread(ecl_kw_type * , fortio_type * ); ecl_kw_type * ecl_kw_fread_alloc(fortio_type *); + ecl_kw_type * ecl_kw_alloc_actnum(const ecl_kw_type * porv_kw, float porv_limit); void ecl_kw_free_data(ecl_kw_type *); void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type, int element_count, const int_vector_type* index_map, char* buffer); void ecl_kw_free(ecl_kw_type *); @@ -119,6 +119,7 @@ extern "C" { ecl_kw_type * ecl_kw_alloc( const char * header , int size , ecl_data_type ); ecl_kw_type * ecl_kw_alloc_new(const char * , int , ecl_data_type , const void * ); ecl_kw_type * ecl_kw_alloc_new_shared(const char * , int , ecl_data_type , void * ); + ecl_kw_type * ecl_kw_alloc_global_copy(const ecl_kw_type * src, const ecl_kw_type * actnum); void ecl_kw_fwrite_param(const char * , bool , const char * , ecl_data_type , int , void * ); void ecl_kw_fwrite_param_fortio(fortio_type *, const char * , ecl_data_type , int , void * ); void ecl_kw_summarize(const ecl_kw_type * ecl_kw); @@ -140,6 +141,9 @@ extern "C" { bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); void ecl_kw_fskip_header( fortio_type * fortio); + bool ecl_kw_size_and_numeric_type_equal( const ecl_kw_type * kw1, const ecl_kw_type * kw2); + bool ecl_kw_inplace_safe_div(ecl_kw_type * target_kw, const ecl_kw_type * divisor); + void ecl_kw_inplace_sqrt( ecl_kw_type * kw ); bool ecl_kw_is_kw_file(fortio_type * fortio); @@ -263,6 +267,8 @@ extern "C" { void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum); + ecl_type_enum ecl_kw_get_type(const ecl_kw_type *); + #include #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp new file mode 100644 index 0000000000..f4ed8bfb4a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_file.c b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp similarity index 69% rename from ThirdParty/Ert/lib/ecl/ecl_sum_file.c rename to ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp index 0d9a033d8c..eb27171f48 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_file.c +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2018 Statoil ASA, Norway. - The file 'ecl_sum_file.c' is part of ERT - Ensemble based Reservoir Tool. + This file is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,12 +16,5 @@ for more details. */ -#include -#include -#include -#include - -struct ecl_sum_struct { - -}; +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp new file mode 100644 index 0000000000..d7cfba7c96 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp new file mode 100644 index 0000000000..5cca194e38 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp new file mode 100644 index 0000000000..e2d16c2eb3 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp new file mode 100644 index 0000000000..8c9f3c9ab7 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h index 87be80a3a0..9ad8e40310 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h @@ -70,10 +70,13 @@ typedef struct ecl_region_struct ecl_region_type; bool ecl_region_contains_global( const ecl_region_type * ecl_region , int global_index); bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active_index); + void ecl_region_select_true( ecl_region_type * region , const ecl_kw_type * ecl_kw); void ecl_region_invert_selection( ecl_region_type * region ); void ecl_region_select_all( ecl_region_type * region); void ecl_region_deselect_all( ecl_region_type * region ); + void ecl_region_deselect_true( ecl_region_type * region , const ecl_kw_type * ecl_kw); + void ecl_region_select_false( ecl_region_type * region , const ecl_kw_type * ecl_kw); void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); @@ -152,6 +155,7 @@ typedef struct ecl_region_struct ecl_region_type; void ecl_region_select_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); void ecl_region_deselect_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); + void ecl_region_deselect_false( ecl_region_type * region , const ecl_kw_type * ecl_kw); /*****************************************************************/ @@ -170,6 +174,16 @@ typedef struct ecl_region_struct ecl_region_type; bool ecl_region_equal( const ecl_region_type * region1 , const ecl_region_type * region2); + void ecl_region_scale_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active); + void ecl_region_scale_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active); + void ecl_region_scale_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value , bool force_active); + void ecl_region_shift_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value , bool force_active); + void ecl_region_shift_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active); + void ecl_region_shift_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active); + + const int_vector_type * ecl_region_get_kw_index_list( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , bool force_active); + + /*****************************************************************/ /* set/get the name */ void ecl_region_set_name( ecl_region_type * region , const char * name ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp new file mode 100644 index 0000000000..d51112ae82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp new file mode 100644 index 0000000000..65ba3f48fc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp new file mode 100644 index 0000000000..3545ee0d42 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h index 8faef7cda0..b7f6418cbd 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h @@ -67,6 +67,8 @@ int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell); ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days); +ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp new file mode 100644 index 0000000000..623405e7d0 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp new file mode 100644 index 0000000000..9ecc8a91e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h index 28aa0dbaee..cf58ec3e53 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h @@ -95,6 +95,8 @@ extern "C" { double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header ); int ecl_rsthead_get_report_step( const ecl_rsthead_type * header ); time_t ecl_rsthead_get_sim_time( const ecl_rsthead_type * header ); + int ecl_rsthead_get_nxconz( const ecl_rsthead_type * rsthead ); + int ecl_rsthead_get_ncwmax( const ecl_rsthead_type * rsthead ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp new file mode 100644 index 0000000000..44550950a1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp new file mode 100644 index 0000000000..7f59f6a7fe --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h index 7da533e338..71d0747a1f 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h @@ -19,7 +19,7 @@ #ifndef ERT_ECL_SUBSIDENCE_H #define ERT_ECL_SUBSIDENCE_H -#ifdef __plusplus +#ifdef __cplusplus extern "C" { #endif @@ -43,8 +43,12 @@ extern "C" { ecl_region_type * region , double utm_x, double utm_y , double depth, double compressibility, double poisson_ratio); + double ecl_subsidence_eval_geertsma( const ecl_subsidence_type * subsidence , const char * base, const char * monitor , ecl_region_type * region , + double utm_x, double utm_y , double depth, + double youngs_modulus, double poisson_ratio, double seabed); -#ifdef __plusplus + +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp new file mode 100644 index 0000000000..a8b535ef8a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h index 4585fec8c4..780add6010 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h @@ -35,7 +35,6 @@ extern "C" { #include #include - typedef struct { char * locale; const char * sep; @@ -53,6 +52,8 @@ extern "C" { /*****************************************************************/ + /* This is a forward declaration. */ +typedef struct ecl_sum_vector_struct ecl_sum_vector_type; typedef struct ecl_sum_struct ecl_sum_type; @@ -136,6 +137,8 @@ typedef struct ecl_sum_struct ecl_sum_type; double ecl_sum_get_general_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var); double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var); const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var); + ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type * ecl_sum); + /***************/ void ecl_sum_fprintf(const ecl_sum_type * , FILE * , const stringlist_type * , bool report_only , const ecl_sum_fmt_type * fmt); @@ -143,6 +146,7 @@ typedef struct ecl_sum_struct ecl_sum_type; /* Time related functions */ + int ecl_sum_get_restart_step(const ecl_sum_type * ecl_sum); int ecl_sum_get_first_gt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_first_lt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_last_report_step( const ecl_sum_type * ecl_sum ); @@ -211,7 +215,8 @@ typedef struct ecl_sum_struct ecl_sum_type; int nx, int ny, int nz); - + void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * input_arg); + ecl_sum_type * ecl_sum_alloc_restart_writer(const char * ecl_case , const char * restart_case , bool fmt_output , @@ -229,7 +234,6 @@ typedef struct ecl_sum_struct ecl_sum_type; time_t sim_start , bool time_in_days , int nx , int ny , int nz); - void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node); @@ -265,6 +269,18 @@ typedef struct ecl_sum_struct ecl_sum_type; double_vector_type * ecl_sum_alloc_days_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower); time_t_vector_type * ecl_sum_alloc_time_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower); + double ecl_sum_iget_last_value(const ecl_sum_type * ecl_sum, int param_index); + double ecl_sum_get_last_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key); + double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node); + double ecl_sum_iget_first_value(const ecl_sum_type * ecl_sum, int param_index); + double ecl_sum_get_first_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key); + double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node); + + void ecl_sum_init_datetime64_vector(const ecl_sum_type * ecl_sum, int64_t * data, int multiplier); + void ecl_sum_init_double_vector_interp(const ecl_sum_type * ecl_sum, const char * gen_key, const time_t_vector_type * time_points, double * data); + void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_key, double * data); + void ecl_sum_init_double_frame(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, double * data); + void ecl_sum_init_double_frame_interp(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, const time_t_vector_type * time_points, double * data); UTIL_IS_INSTANCE_HEADER( ecl_sum ); #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp new file mode 100644 index 0000000000..7370f32e97 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h index a04d5363f5..929c1114a6 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h @@ -24,6 +24,7 @@ extern "C" { #endif #include +#include #include #include @@ -86,8 +87,23 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp); - - double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double value, bool rates_clamp_lower); + double ecl_sum_data_get_last_value(const ecl_sum_data_type * data, int param_index); + double ecl_sum_data_iget_last_value(const ecl_sum_data_type * data, int param_index); + double ecl_sum_data_iget_first_value(const ecl_sum_data_type * data, int param_index); + void ecl_sum_data_init_double_vector(const ecl_sum_data_type * data, int params_index, double * output_data); + void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type * data, int64_t * output_data, int multiplier); + + void ecl_sum_data_init_double_frame(const ecl_sum_data_type * data, const ecl_sum_vector_type * keywords, double *output_data); + double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double value, bool rates_clamp_lower); + void ecl_sum_data_init_double_frame_interp(const ecl_sum_data_type * data, + const ecl_sum_vector_type * keywords, + const time_t_vector_type * time_points, + double * output_data); + + void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, + const smspec_node_type * smspec_node, + const time_t_vector_type * time_points, + double * output_data); #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp new file mode 100644 index 0000000000..9d54a02f6c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp new file mode 100644 index 0000000000..1317fbf5a4 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp new file mode 100644 index 0000000000..5350247752 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h index 1ab5dc1e8f..6994160437 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h @@ -41,6 +41,8 @@ typedef struct ecl_sum_vector_struct ecl_sum_vector_type; int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector); bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index); + ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type * src_vector, const ecl_sum_type * ecl_sum); + UTIL_IS_INSTANCE_HEADER( ecl_sum_vector); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp new file mode 100644 index 0000000000..8b06dae566 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h index 4848e34dc7..a218330974 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h @@ -59,7 +59,6 @@ typedef enum { {.value = 5 , .name = "ECL_MESS_TYPE"}, \ {.value = 7 , .name = "ECL_STRING_TYPE"} -#define ECL_TYPE_ENUM_SIZE 7 /* Character data in ECLIPSE files comes as an array of fixed-length @@ -68,7 +67,6 @@ typedef enum { */ #define ECL_STRING8_LENGTH 8 // 'Normal' 8 characters 'CHAR' type. -#define ECL_STRING10_LENGTH 10 // 'Normal' 8 characters 'CHAR' type. #define ECL_TYPE_LENGTH 4 struct ecl_type_struct { @@ -81,7 +79,7 @@ struct ecl_type_struct { #define ECL_INT ecl_data_type{ ECL_INT_TYPE, sizeof(int)} #define ECL_FLOAT ecl_data_type{ ECL_FLOAT_TYPE, sizeof(float)} #define ECL_DOUBLE ecl_data_type{ ECL_DOUBLE_TYPE, sizeof(double)} -#define ECL_BOOL ecl_data_type{ ECL_BOOL_TYPE, sizeof(int)} +#define ECL_BOOL ecl_data_type{ ECL_BOOL_TYPE, sizeof(bool)} #define ECL_CHAR ecl_data_type{ ECL_CHAR_TYPE, ECL_STRING8_LENGTH + 1} #define ECL_MESS ecl_data_type{ ECL_MESS_TYPE, 0} #define ECL_STRING(size) ecl_data_type{ECL_STRING_TYPE, (size) + 1} @@ -94,7 +92,7 @@ struct ecl_type_struct { #define ECL_INT (ecl_data_type) {.type = ECL_INT_TYPE, .element_size = sizeof(int)} #define ECL_FLOAT (ecl_data_type) {.type = ECL_FLOAT_TYPE, .element_size = sizeof(float)} #define ECL_DOUBLE (ecl_data_type) {.type = ECL_DOUBLE_TYPE, .element_size = sizeof(double)} -#define ECL_BOOL (ecl_data_type) {.type = ECL_BOOL_TYPE, .element_size = sizeof(int)} +#define ECL_BOOL (ecl_data_type) {.type = ECL_BOOL_TYPE, .element_size = sizeof(bool)} #define ECL_MESS (ecl_data_type) {.type = ECL_MESS_TYPE, .element_size = 0} #define ECL_STRING(size) (ecl_data_type) {.type = ECL_STRING_TYPE, .element_size = (size) + 1} @@ -114,7 +112,7 @@ ecl_type_enum ecl_type_get_type(const ecl_data_type); char * ecl_type_alloc_name(const ecl_data_type); int ecl_type_get_sizeof_ctype(const ecl_data_type); -int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type); +int ecl_type_get_sizeof_iotype(const ecl_data_type); bool ecl_type_is_equal(const ecl_data_type, const ecl_data_type); @@ -129,8 +127,8 @@ bool ecl_type_is_bool(const ecl_data_type); bool ecl_type_is_string(const ecl_data_type); // Temporary fixup for OPM. -char * ecl_type_get_name(const ecl_data_type); - +char * ecl_type_get_name(const ecl_data_type); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp new file mode 100644 index 0000000000..982417c0ea --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp new file mode 100644 index 0000000000..09fd7dbafa --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp new file mode 100644 index 0000000000..6118488a7e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp new file mode 100644 index 0000000000..901d2167b2 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp new file mode 100644 index 0000000000..d2266cd641 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp new file mode 100644 index 0000000000..215e1daf11 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.h b/ThirdParty/Ert/lib/include/ert/ecl/layer.h index bf9dfcf58d..f1aacf1135 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/layer.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.h @@ -76,6 +76,9 @@ extern "C" { void layer_add_barrier( layer_type * layer , int c1 , int c2); void layer_memcpy(layer_type * target_layer , const layer_type * src_layer); void layer_update_active( layer_type * layer , const ecl_grid_type * grid , int k); + void layer_clear_cells( layer_type * layer); + void layer_update_connected_cells( layer_type * layer , int i , int j , int org_value , int new_value); + void layer_assign( layer_type * layer, int value); void layer_cells_equal( const layer_type * layer , int value , int_vector_type * i_list , int_vector_type * j_list); int layer_count_equal( const layer_type * layer , int value ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp new file mode 100644 index 0000000000..97de3b6bcc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp new file mode 100644 index 0000000000..93b5b155e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp new file mode 100644 index 0000000000..c2194dcd82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp new file mode 100644 index 0000000000..0a6f2f7f18 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp new file mode 100644 index 0000000000..3815a62422 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp new file mode 100644 index 0000000000..98459f44e6 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp new file mode 100644 index 0000000000..bbbecd3e6e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp new file mode 100644 index 0000000000..9daefcf46f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp new file mode 100644 index 0000000000..df5625079d --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp new file mode 100644 index 0000000000..3fbdb9a8e3 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp new file mode 100644 index 0000000000..1a423cf493 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp new file mode 100644 index 0000000000..f15cf65a7e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h index 163b4cecb8..aa9427c858 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h @@ -97,6 +97,10 @@ extern "C" { double well_state_get_gas_rate( const well_state_type * well_state ); double well_state_get_water_rate( const well_state_type * well_state); double well_state_get_volume_rate( const well_state_type * well_state); + double well_state_get_water_rate_si( const well_state_type * well_state); + double well_state_get_oil_rate_si( const well_state_type * well_state ); + double well_state_get_volume_rate_si( const well_state_type * well_state); + double well_state_get_gas_rate_si( const well_state_type * well_state ); UTIL_IS_INSTANCE_HEADER( well_state ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp new file mode 100644 index 0000000000..4166742c82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp new file mode 100644 index 0000000000..9f4463d1c7 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp new file mode 100644 index 0000000000..a1f54f309d --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp new file mode 100644 index 0000000000..47a0198653 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp new file mode 100644 index 0000000000..0b956ad4b8 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp new file mode 100644 index 0000000000..aca4548a42 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h index a6707372a0..0e6dd12801 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h @@ -46,6 +46,16 @@ extern "C" { int geo_surface_get_ny( const geo_surface_type * surface ); void geo_surface_iget_xy( const geo_surface_type* surface, int index, double* x, double* y); + void geo_surface_shift( const geo_surface_type * src , double value); + void geo_surface_scale( const geo_surface_type * src , double value); + void geo_surface_isub( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_iset_zvalue(geo_surface_type * surface, int index , double value); + void geo_surface_assign_value( const geo_surface_type * src , double value); + geo_surface_type * geo_surface_alloc_copy( const geo_surface_type * src , bool copy_zdata); + void geo_surface_iadd( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_imul( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_isqrt( geo_surface_type * surface ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp new file mode 100644 index 0000000000..f4030b6ca1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp new file mode 100644 index 0000000000..b0b3bf1e52 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 diff --git a/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp b/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp deleted file mode 100644 index 0fc46cd011..0000000000 --- a/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot.hpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef NEXUS_PLOT_H -#define NEXUS_PLOT_H - -#include -#include -#include -#include -#include - -typedef struct ecl_sum_struct ecl_sum_type; - -namespace nex { - -struct bad_header : public std::runtime_error { - using std::runtime_error::runtime_error; -}; -struct read_error : public std::runtime_error { - using std::runtime_error::runtime_error; -}; -struct unexpected_eof : public std::runtime_error { - using std::runtime_error::runtime_error; -}; - -class NexusPlot { -public: - NexusPlot( const std::string& ); - NexusPlot( std::istream& ); - - int32_t num_classes = 0; - int32_t day, month, year; - int32_t nx, ny, nz; - int32_t ncomp; - std::vector class_names; - std::vector vars_in_class; - std::vector< std::vector > var_names; - - ecl_sum_type* ecl_summary( const std::string& ecl_case ); - -private: - void load( std::istream& ); -}; - -} - -#endif // NEXUS_PLOT_H diff --git a/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp b/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp new file mode 100644 index 0000000000..94c71385e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef ARG_PACK_CXX +#define ARG_PACK_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/buffer.hpp b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp new file mode 100644 index 0000000000..b002e8981e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef BUFFER_CXX +#define BUFFER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp new file mode 100644 index 0000000000..3af2a9706b --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef ECL_VERSION_CXX +#define ECL_VERSION_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash.hpp b/ThirdParty/Ert/lib/include/ert/util/hash.hpp new file mode 100644 index 0000000000..1a2758952a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_CXX +#define HASH_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp new file mode 100644 index 0000000000..2d6176c592 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_NODE_CXX +#define HASH_NODE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp new file mode 100644 index 0000000000..70c64a0b03 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_SLL_CXX +#define HASH_SLL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/lars.h b/ThirdParty/Ert/lib/include/ert/util/lars.h deleted file mode 100644 index 4acdeb37c6..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/lars.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lars.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - - -#ifndef ERT_LARS_H -#define ERT_LARS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -typedef struct lars_struct lars_type; - -int lars_get_sample( const lars_type * lars ); -int lars_get_nvar( const lars_type * lars ); -lars_type * lars_alloc1( int nsample , int nvars); -lars_type * lars_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy ); -void lars_estimate(lars_type * lars , int max_vars , double max_beta , bool verbose); -void lars_isetX( lars_type * lars, int sample, int var , double value); -void lars_isetY( lars_type * lars, int sample, double value); -void lars_select_beta( lars_type * lars , int beta_index); -void lars_free( lars_type * lars ); -double lars_eval1( const lars_type * lars , const matrix_type * x); -double lars_eval2( const lars_type * lars , double * x); -double lars_getY0( const lars_type * lars); -double lars_iget_beta( const lars_type * lars , int index); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/log.h b/ThirdParty/Ert/lib/include/ert/util/log.h deleted file mode 100644 index dcaad30d89..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/log.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'log.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_LOG_H -#define ERT_LOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -//Same as pythons default log levels, but with different numeric values. -typedef enum { - LOG_CRITICAL=0, //OOM. - LOG_ERROR=1, //When something we really expected to work does not, e.g. IO failure. - LOG_WARNING=2, //Important, but not error. E.g. combination of settings which can be intended, but probably are not. - LOG_INFO=3, //Entering functions/parts of the code - LOG_DEBUG=4 //Inside the for-loop, when you need the nitty gritty details. Think TRACE. -} message_level_type; - - -typedef struct log_struct log_type; - - FILE * log_get_stream(log_type * logh ); - void log_reopen( log_type * logh , const char * filename ); - log_type * log_open(const char *filename, int log_level); - void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message); - void log_add_message_str(log_type *logh, message_level_type message_level , const char* message); - void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...); - int log_get_level( const log_type * logh); - void log_set_level( log_type * logh , int new_level); - void log_close( log_type * logh ); - void log_sync(log_type * logh); - const char * log_get_filename( const log_type * logh ); - int log_get_level( const log_type * logh); - void log_set_level( log_type * logh , int log_level); - bool log_is_open( const log_type * logh); - bool log_include_message(const log_type *logh , int message_level); - int log_get_msg_count(const log_type * logh); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/lookup_table.h b/ThirdParty/Ert/lib/include/ert/util/lookup_table.h index d08cc7c421..a2ebb1d32e 100644 --- a/ThirdParty/Ert/lib/include/ert/util/lookup_table.h +++ b/ThirdParty/Ert/lib/include/ert/util/lookup_table.h @@ -37,7 +37,7 @@ typedef struct lookup_table_struct lookup_table_type; double lookup_table_get_max_value( lookup_table_type * lookup_table ); double lookup_table_get_min_value( lookup_table_type * lookup_table ); double lookup_table_get_max_arg( lookup_table_type * lookup_table ); - double lookup_table_get_max_arg( lookup_table_type * lookup_table ); + double lookup_table_get_min_arg( lookup_table_type * lookup_table ); int lookup_table_get_size( const lookup_table_type * lt ); void lookup_table_set_low_limit( lookup_table_type * lt , double limit); bool lookup_table_has_low_limit(const lookup_table_type * lt ); diff --git a/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp new file mode 100644 index 0000000000..a3fcd045ac --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef LOOKUP_TABLE_CXX +#define LOOKUP_TABLE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix.h b/ThirdParty/Ert/lib/include/ert/util/matrix.h deleted file mode 100644 index cdbcc26640..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_MATRIX_H -#define ERT_MATRIX_H -#include -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_THREAD_POOL -#include -#endif - -#ifdef _MSC_VER -#define __forceinline inline -#elif __GNUC__ -/* Also clang defines the __GNUC__ symbol */ -#define __forceinline inline __attribute__((always_inline)) -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -struct matrix_struct { - UTIL_TYPE_ID_DECLARATION; - char * name; /* A name of the matrix - for printing - can be NULL. */ - double * data; /* The actual storage */ - bool data_owner; /* is this matrix instance the owner of data? */ - size_t data_size; /* What is the length of data (number of double values). */ - - int rows; /* The number of rows in the matrix. */ - int columns; /* The number of columns in the matrix. */ - int alloc_rows; - int alloc_columns; - int row_stride; /* The distance in data between two conscutive row values. */ - int column_stride; /* The distance in data between to consecutive column values. */ - - /* - Observe that the stride is considered an internal property - if - the matrix is stored to disk and then recovered the strides might - change, and also matrix_alloc_copy() will not respect strides. - */ -}; - -typedef struct matrix_struct matrix_type; - - __forceinline size_t GET_INDEX( const matrix_type * m , size_t i , size_t j) {return m->row_stride *i + m->column_stride *j;} - matrix_type * matrix_fread_alloc(FILE * stream); - void matrix_fread(matrix_type * matrix , FILE * stream); - void matrix_fwrite(const matrix_type * matrix , FILE * stream); - bool matrix_check_dims( const matrix_type * m , int rows , int columns); - void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * stream ); - void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream ); - void matrix_dump_csv( const matrix_type * matrix ,const char * filename); - void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream); - void matrix_pretty_fprint_submat(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream, int m, int M, int n, int N); - matrix_type * matrix_alloc(int rows, int columns); - matrix_type * matrix_alloc_identity(int dim); - matrix_type * matrix_safe_alloc(int rows, int columns); - bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content); - bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content); - matrix_type * matrix_alloc_sub_copy( const matrix_type * src , int row_offset , int column_offset , int rows, int columns); - matrix_type * matrix_alloc_copy(const matrix_type * src); - matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask); - void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask); - matrix_type * matrix_safe_alloc_copy(const matrix_type * src); - matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src); - - matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns); - void matrix_free(matrix_type * matrix); - void matrix_safe_free( matrix_type * matrix ); - void matrix_pretty_print(const matrix_type * matrix , const char * name , const char * fmt); - void matrix_set(matrix_type * matrix, double value); - void matrix_set_name( matrix_type * matrix , const char * name); - void matrix_scale(matrix_type * matrix, double value); - void matrix_shift(matrix_type * matrix, double value); - - void matrix_assign(matrix_type * A , const matrix_type * B); - void matrix_inplace_add(matrix_type * A , const matrix_type * B); - void matrix_inplace_sub(matrix_type * A , const matrix_type * B); - void matrix_inplace_mul(matrix_type * A , const matrix_type * B); - void matrix_inplace_div(matrix_type * A , const matrix_type * B); - void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C); - void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C); - void matrix_transpose(const matrix_type * A , matrix_type * T); - void matrix_inplace_add_column(matrix_type * A , const matrix_type * B, int colA , int colB); - void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB); - void matrix_inplace_transpose(matrix_type * A ); - - void matrix_iset_safe(matrix_type * matrix , int i , int j, double value); - void matrix_iset(matrix_type * matrix , int i , int j, double value); - double matrix_iget(const matrix_type * matrix , int i , int j); - double matrix_iget_safe(const matrix_type * matrix , int i , int j); - void matrix_iadd(matrix_type * matrix , int i , int j , double value); - void matrix_isub(matrix_type * matrix , int i , int j , double value); - void matrix_imul(matrix_type * matrix , int i , int j , double value); - - - void matrix_inplace_matmul(matrix_type * A, const matrix_type * B); - void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads); -#ifdef HAVE_THREAD_POOL - void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool); -#endif - - void matrix_shift_column(matrix_type * matrix , int column, double shift); - void matrix_shift_row(matrix_type * matrix , int row , double shift); - double matrix_get_column_sum(const matrix_type * matrix , int column); - double matrix_get_row_sum(const matrix_type * matrix , int column); - double matrix_get_column_sum2(const matrix_type * matrix , int column); - double matrix_get_row_abssum(const matrix_type * matrix , int row); - double matrix_get_column_abssum(const matrix_type * matrix , int column); - double matrix_get_row_sum2(const matrix_type * matrix , int column); - void matrix_subtract_row_mean(matrix_type * matrix); - void matrix_subtract_and_store_row_mean(matrix_type * matrix, matrix_type * row_mean); - void matrix_scale_column(matrix_type * matrix , int column , double scale_factor); - void matrix_scale_row(matrix_type * matrix , int row , double scale_factor); - void matrix_set_const_column(matrix_type * matrix , const double value , int column); - void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int src_column, int target_column); - void matrix_set_const_row(matrix_type * matrix , const double value , int row); - - double * matrix_get_data(const matrix_type * matrix); - double matrix_orthonormality( const matrix_type * matrix ); - - matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size); - void matrix_set_column(matrix_type * matrix , const double * data , int column); - void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column); - void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content); - void matrix_shrink_header(matrix_type * matrix , int rows , int columns); - void matrix_full_size( matrix_type * matrix ); - int matrix_get_rows(const matrix_type * matrix); - int matrix_get_columns(const matrix_type * matrix); - int matrix_get_row_stride(const matrix_type * matrix); - int matrix_get_column_stride(const matrix_type * matrix); - void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , int * row_stride , int * column_stride); - bool matrix_is_quadratic(const matrix_type * matrix); - bool matrix_equal( const matrix_type * m1 , const matrix_type * m2); - bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); - - void matrix_diag_set_scalar(matrix_type * matrix , double value); - void matrix_diag_set(matrix_type * matrix , const double * diag); - void matrix_random_init(matrix_type * matrix , rng_type * rng); - void matrix_matlab_dump(const matrix_type * matrix, const char * filename); - - void matrix_imul_col( matrix_type * matrix , int column , double factor); - double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); - double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2); - matrix_type * matrix_alloc_view(double * data , int rows , int columns); - matrix_type * matrix_alloc_transpose( const matrix_type * A); - void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row); - void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns, - const matrix_type * src_matrix , int src_row , int src_column); - - void matrix_scalar_set( matrix_type * matrix , double value); - void matrix_inplace_diag_sqrt(matrix_type *Cd); - void matrix_create_identiy(int n,matrix_type *Id); - double matrix_trace(const matrix_type *matrix); - double matrix_diag_std(const matrix_type * Sk,double mean); - double matrix_det2( const matrix_type * A); - double matrix_det3( const matrix_type * A); - double matrix_det4( const matrix_type * A); - - #ifdef ERT_HAVE_ISFINITE - bool matrix_is_finite(const matrix_type * matrix); - void matrix_assert_finite( const matrix_type * matrix ); - #endif - - UTIL_SAFE_CAST_HEADER( matrix ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h b/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h deleted file mode 100644 index de28979c5f..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_MATRIX_BLAS -#define ERT_MATRIX_BLAS -#include - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB , double alpha , double beta); -void matrix_matmul_with_transpose(matrix_type * C, const matrix_type * A , const matrix_type * B , bool transA , bool transB); -void matrix_matmul(matrix_type * A, const matrix_type *B , const matrix_type * C); -matrix_type * matrix_alloc_matmul(const matrix_type * A, const matrix_type * B); -void matrix_dgemv(const matrix_type * A , const double * x , double * y , bool transA , double alpha , double beta); -void matrix_mul_vector(const matrix_type * A , const double * x , double * y); -void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col); -matrix_type * matrix_alloc_gram( const matrix_type * X , bool col); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h b/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h deleted file mode 100644 index 0ddb89545e..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ -#ifndef ERT_MATRIX_LAPACK_H -#define ERT_MATRIX_LAPACK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - This enum is just a simple way to label the different ways the - singular vectors in U and VT are returned to the calling scope. The - low level lapack routine uses a character variable, indicated - below. -*/ - - - - - - typedef enum { - /* A */ DGESVD_ALL, /* Returns all the singular vectors in U/VT. */ - /* S */ DGESVD_MIN_RETURN, /* Return the first min(m,n) vectors in U/VT. */ - /* O */ DGESVD_MIN_OVERWRITE, /* Return the first min(m,n) vectors of U/VT by overwriteing in A. */ - /* N */ DGESVD_NONE} /* Do not compute any singular vectors for U/VT */ - dgesvd_vector_enum; - - - typedef enum { - /* A */ DSYEVX_ALL, /* Compute all the eigenvalues */ - /* V */ DSYEVX_VALUE_INTERVAL, /* Computes eigenvalues in half open interval - for more details. -*/ - - -#ifndef ERT_MATRIX_STAT_H -#define ERT_MATRIX_STAT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -typedef enum { - LLSQ_SUCCESS = 0, - LLSQ_INVALID_DIM = 1, - LLSQ_UNDETERMINED = 2 -} llsq_result_enum; - - -llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X , const matrix_type * Y , const matrix_type * S); -llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/menu.h b/ThirdParty/Ert/lib/include/ert/util/menu.h deleted file mode 100644 index 6306a4abde..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/menu.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'menu.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_MENU_H -#define ERT_MENU_H - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -typedef struct menu_struct menu_type; -typedef struct menu_item_struct menu_item_type; - -typedef void (menu_func_type) (void *); -typedef void (arg_free_ftype) (void *); - -menu_type * menu_alloc(const char * , const char * , const char *); -void menu_run(const menu_type * ); -void menu_free(menu_type * ); -menu_item_type * menu_get_item(const menu_type * , char ); -menu_item_type * menu_add_item(menu_type *, const char * , const char * , menu_func_type * , void * , arg_free_ftype * ); -void menu_add_separator(menu_type * ); -void menu_add_helptext(menu_type * , const char * ); -menu_item_type * menu_get_item(const menu_type * , char ); -void menu_set_title(menu_type *, const char *); - -void menu_item_set_label( menu_item_type * , const char *); -void menu_item_disable( menu_item_type * item ); -void menu_item_enable( menu_item_type * item ); -void menu_add_helptext(menu_type * menu, const char * label ); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/msg.h b/ThirdParty/Ert/lib/include/ert/util/msg.h deleted file mode 100644 index 02b7674a1d..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/msg.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'msg.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_MSG_H -#define ERT_MSG_H -#ifdef __cplusplus -extern "C" { -#endif -#include - -#include - - -typedef struct msg_struct msg_type; - - - -msg_type * msg_alloc(const char * , bool debug); -void msg_show(msg_type * ); -void msg_free(msg_type * , bool); -void msg_update(msg_type * , const char * ); -void msg_update_int(msg_type * , const char * , int ); -void msg_hide(msg_type *); -void msg_clear_msg(msg_type * msg); - - -UTIL_SAFE_CAST_HEADER( msg ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/mzran.hpp b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp new file mode 100644 index 0000000000..512eb56ad9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef MZRAN_CXX +#define MZRAN_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp new file mode 100644 index 0000000000..6618717f82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef NODE_CTYPE_CXX +#define NODE_CTYPE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/node_data.hpp b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp new file mode 100644 index 0000000000..91f5d8c634 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef NODE_DATA_CXX +#define NODE_DATA_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/parser.hpp b/ThirdParty/Ert/lib/include/ert/util/parser.hpp new file mode 100644 index 0000000000..72e400d2d1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/parser.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PARSER_CXX +#define PARSER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/path_fmt.h b/ThirdParty/Ert/lib/include/ert/util/path_fmt.h deleted file mode 100644 index da7fd5db67..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/path_fmt.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'path_fmt.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_PATH_FMT_H -#define ERT_PATH_FMT_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct path_fmt_struct path_fmt_type; - - path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); - path_fmt_type * path_fmt_alloc_path_fmt(const char * ); - path_fmt_type * path_fmt_copyc(const path_fmt_type *); - path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); - char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); - char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); - void path_fmt_free(path_fmt_type * ); - void path_fmt_free__( void * arg ); - const char * path_fmt_get_fmt(const path_fmt_type * ); - void path_fmt_reset_fmt(path_fmt_type * , const char * ); - void path_fmt_make_path(const path_fmt_type * ); - path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp new file mode 100644 index 0000000000..2dbea35ffd --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PATH_STACK_CXX +#define PATH_STACK_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp new file mode 100644 index 0000000000..53758b9ea9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PERM_VECTOR_CXX +#define PERM_VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/regression.h b/ThirdParty/Ert/lib/include/ert/util/regression.h deleted file mode 100644 index 564461e768..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/regression.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'regression.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_REGRESSION_H -#define ERT_REGRESSION_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif -double regression_scale( matrix_type * X , matrix_type * Y , matrix_type * X_mean , matrix_type * X_norm); -double regression_unscale(const matrix_type * beta , const matrix_type * X_norm , const matrix_type * X_mean , double Y_mean , matrix_type * beta0); -void regression_augmented_OLS(const matrix_type * X , const matrix_type * Y , const matrix_type *E, matrix_type * beta); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/rng.hpp b/ThirdParty/Ert/lib/include/ert/util/rng.hpp new file mode 100644 index 0000000000..d75be17013 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/rng.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef RNG_CXX +#define RNG_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/set.hpp b/ThirdParty/Ert/lib/include/ert/util/set.hpp new file mode 100644 index 0000000000..4a5936ab31 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/set.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef SET_CXX +#define SET_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp new file mode 100644 index 0000000000..df855a99cc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef SSIZE_T_CXX +#define SSIZE_T_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/statistics.hpp b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp new file mode 100644 index 0000000000..2d1fe6f10a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STATISTICS_CXX +#define STATISTICS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/stepwise.h b/ThirdParty/Ert/lib/include/ert/util/stepwise.h deleted file mode 100644 index f1eb0a4f21..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/stepwise.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ERT_STEPWISE_H -#define ERT_STEPWISE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - typedef struct stepwise_struct stepwise_type; - - - stepwise_type * stepwise_alloc1(int nsample, int nvar, rng_type * rng, const matrix_type* St, const matrix_type* Et); - stepwise_type * stepwise_alloc0(rng_type * rng); - void stepwise_free( stepwise_type * stepwise); - - void stepwise_set_Y0( stepwise_type * stepwise , matrix_type * Y); - void stepwise_set_X0( stepwise_type * stepwise , matrix_type * X); - void stepwise_set_E0( stepwise_type * stepwise , matrix_type * E); - void stepwise_set_beta( stepwise_type * stepwise , matrix_type * b); - void stepwise_set_R2( stepwise_type * stepwise , const double R2); - void stepwise_set_active_set( stepwise_type * stepwise , bool_vector_type * a); - void stepwise_isetY0( stepwise_type * stepwise , int i , double value ); - double stepwise_get_R2(const stepwise_type * stepwise ); - int stepwise_get_nvar( stepwise_type * stepwise ); - int stepwise_get_nsample( stepwise_type * stepwise ); - int stepwise_get_n_active( stepwise_type * stepwise ); - bool_vector_type * stepwise_get_active_set( stepwise_type * stepwise ); - double stepwise_iget_beta(const stepwise_type * stepwise, const int index ); - double stepwise_get_sum_beta(const stepwise_type * stepwise ); - - void stepwise_estimate( stepwise_type * stepwise , double deltaR2_limit , int CV_blocks); - double stepwise_eval( const stepwise_type * stepwise , const matrix_type * x ); - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/string_util.hpp b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp new file mode 100644 index 0000000000..4cfb76138f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRING_UTIL_CXX +#define STRING_UTIL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp new file mode 100644 index 0000000000..ea149225dc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRINGLIST_CXX +#define STRINGLIST_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp new file mode 100644 index 0000000000..d91ac14230 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRUCT_VECTOR_CXX +#define STRUCT_VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/subst_func.h b/ThirdParty/Ert/lib/include/ert/util/subst_func.h deleted file mode 100644 index 5dc1369ff5..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/subst_func.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'subst_func.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_SUBST_FUNC_H -#define ERT_SUBST_FUNC_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef char * (subst_func_ftype) (const stringlist_type * , void * ); -typedef struct subst_func_struct subst_func_type; -typedef struct subst_func_pool_struct subst_func_pool_type; - - - char * subst_func_eval( const subst_func_type * subst_func , const stringlist_type * args); - -/*****************************************************************/ - - subst_func_pool_type * subst_func_pool_alloc( ); - void subst_func_pool_free( subst_func_pool_type * pool ); - void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg); -subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name ); -bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name ); -UTIL_IS_INSTANCE_HEADER( subst_func_pool ); - -/*****************************************************************/ -char * subst_func_randint( const stringlist_type * args , void * arg); -char * subst_func_randfloat( const stringlist_type * args , void * arg); -char * subst_func_add( const stringlist_type * args , void * arg); -char * subst_func_mul( const stringlist_type * args , void * arg); -char * subst_func_exp( const stringlist_type * args , void * arg); -char * subst_func_log( const stringlist_type * args , void * arg); -char * subst_func_pow10( const stringlist_type * args , void * arg); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/test_util.h b/ThirdParty/Ert/lib/include/ert/util/test_util.h index 131ef67735..b1326deeef 100644 --- a/ThirdParty/Ert/lib/include/ert/util/test_util.h +++ b/ThirdParty/Ert/lib/include/ert/util/test_util.h @@ -36,6 +36,8 @@ extern "C" { void test_error_exit( const char * fmt , ...); + void * test_argpack_is_stringlist( void * arg ); + void * thread_pool_test_func1( void * arg ); #define test_exit( fmt, ...) test_exit__( __FILE__ , __LINE__ , fmt , __VA_ARGS__); void test_exit__(const char * file , int line , const char * fmt , ...); diff --git a/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp new file mode 100644 index 0000000000..5d9fbc90bd --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TEST_WORK_AREA_CXX +#define TEST_WORK_AREA_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/thread_pool.h b/ThirdParty/Ert/lib/include/ert/util/thread_pool.h deleted file mode 100644 index 23abb308a2..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/thread_pool.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ -#ifndef ERT_THREAD_POOL_H -#define ERT_THREAD_POOL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - typedef struct thread_pool_struct thread_pool_type; - - void thread_pool_join(thread_pool_type * ); - thread_pool_type * thread_pool_alloc(int , bool start_queue); - void thread_pool_add_job(thread_pool_type * ,void * (*) (void *) , void *); - void thread_pool_free(thread_pool_type *); - void thread_pool_restart( thread_pool_type * tp ); - void * thread_pool_iget_return_value( const thread_pool_type * pool , int queue_index ); - int thread_pool_get_max_running( const thread_pool_type * pool ); - bool thread_pool_try_join(thread_pool_type * pool, int timeout_seconds); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/time_interval.h b/ThirdParty/Ert/lib/include/ert/util/time_interval.h deleted file mode 100644 index 6d2f13cb83..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/time_interval.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'time_interval.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_TIME_INTERVAL_H -#define ERT_TIME_INTERVAL_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - typedef struct time_interval_struct time_interval_type; - - time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ); - time_interval_type * time_interval_alloc_open( ); - time_interval_type * time_interval_alloc_copy( const time_interval_type * src); - void time_interval_reopen( time_interval_type * time_interval); - void time_interval_free( time_interval_type * ti ); - bool time_interval_is_empty( time_interval_type * ti ); - bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time); - bool time_interval_contains( const time_interval_type * ti , time_t t); - bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_update_start( time_interval_type * ti , time_t start_time ); - bool time_interval_update_end( time_interval_type * ti , time_t end_time ); - time_t time_interval_get_start( const time_interval_type * ti); - time_t time_interval_get_end( const time_interval_type * ti); - bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_arg_before( const time_interval_type * ti , time_t arg); - bool time_interval_arg_after( const time_interval_type * ti , time_t arg); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp new file mode 100644 index 0000000000..26073dbf06 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TIME_INTERVAL_CXX +#define TIME_INTERVAL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/timer.hpp b/ThirdParty/Ert/lib/include/ert/util/timer.hpp new file mode 100644 index 0000000000..14a83dd14f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/timer.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TIMER_CXX +#define TIMER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp b/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp new file mode 100644 index 0000000000..704643272e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TYPE_MACROS_CXX +#define TYPE_MACROS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp new file mode 100644 index 0000000000..142f711db9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TYPE_VECTOR_FUNCTIONS_CXX +#define TYPE_VECTOR_FUNCTIONS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ui_return.h b/ThirdParty/Ert/lib/include/ert/util/ui_return.h deleted file mode 100644 index 43044a9348..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/ui_return.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ui_return.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_UI_RETURN_H -#define ERT_UI_RETURN_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ui_return_struct ui_return_type; - - -typedef enum { - UI_RETURN_OK = 1, - UI_RETURN_FAIL = 2 -} ui_return_status_enum; - - - -ui_return_type * ui_return_alloc(ui_return_status_enum status); -void ui_return_free(ui_return_type * ui_return); -ui_return_status_enum ui_return_get_status(const ui_return_type * ui_return); -int ui_return_get_error_count(const ui_return_type * ui_return); -bool ui_return_add_error(ui_return_type * ui_return, const char * error_msg); -void ui_return_add_help(ui_return_type * ui_return, const char * help_text); -const char * ui_return_get_first_error(const ui_return_type * ui_return); -const char * ui_return_get_last_error(const ui_return_type * ui_return); -const char * ui_return_get_help(const ui_return_type * ui_return); -const char * ui_return_iget_error( const ui_return_type * ui_return , int index); - - -UTIL_IS_INSTANCE_HEADER(ui_return); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/util.h b/ThirdParty/Ert/lib/include/ert/util/util.h index fe0fe48e06..84b406b9d3 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.h +++ b/ThirdParty/Ert/lib/include/ert/util/util.h @@ -163,6 +163,7 @@ typedef enum {left_pad = 0, void util_move_file(const char * src_file , const char * target_file); void util_move_file4( const char * src_name , const char * target_name , const char *src_path , const char * target_path); bool util_copy_file(const char * , const char * ); + bool util_copy_file__(const char * src_file , const char * target_file, size_t buffer_size , void * buffer , bool abort_on_error); char * util_alloc_cwd(void); bool util_is_cwd( const char * path ); char * util_alloc_normal_path( const char * input_path ); diff --git a/ThirdParty/Ert/lib/include/ert/util/util.hpp b/ThirdParty/Ert/lib/include/ert/util/util.hpp new file mode 100644 index 0000000000..8d293d4382 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/util.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef UTIL_CXX +#define UTIL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/util_env.h b/ThirdParty/Ert/lib/include/ert/util/util_env.h deleted file mode 100644 index 2270867ae1..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/util_env.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'util_env.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef ERT_UTIL_ENV_H -#define ERT_UTIL_ENV_H - - - -#ifdef __cplusplus -extern"C" { -#endif - - char * util_alloc_PATH_executable(const char * executable ); - void util_setenv( const char * variable , const char * value); - const char * util_interp_setenv( const char * variable , const char * value); - void util_unsetenv( const char * variable); - char * util_alloc_envvar( const char * value ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/vector.hpp b/ThirdParty/Ert/lib/include/ert/util/vector.hpp new file mode 100644 index 0000000000..99ddd5a31c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef VECTOR_CXX +#define VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/nexus/nexus_plot.cpp b/ThirdParty/Ert/lib/nexus/nexus_plot.cpp deleted file mode 100644 index c3c404bf8f..0000000000 --- a/ThirdParty/Ert/lib/nexus/nexus_plot.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot.cpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -#include -#ifdef HAVE_NETINET_IN_H -#include -#elif defined(HAVE_ARPA_INET_H) -#include -#elif defined(HAVE_WINSOCK2_H) -#include -#endif - -#include -#include - - -const std::string NEXUS_PLOT_TYPE_HEADER = "PLOT BIN "; - -namespace { - -template< int N > -std::string read_str(std::istream& stream) { - std::array< char, N> buf; - stream.read( buf.data(), N ); - return std::string( buf.data(), N ); -} - -struct hinfo { - int32_t num_classes; - int32_t day, month, year; - int32_t nx, ny, nz; - int32_t ncomp; - std::vector class_names; - std::vector vars_in_class; - std::vector< std::vector > var_names; -}; - -hinfo headerinfo( std::istream& stream ) { - stream.seekg(4 + 10 + 562 + 264, std::ios::beg); - - std::array< int32_t, 8 > buf {}; - stream.read( (char*)buf.data(), buf.max_size() * 4 ); - if ( !stream.good() ) throw nex::unexpected_eof(""); - - auto ntoh = []( int32_t x ) { return ntohl( x ); }; - std::transform( buf.begin(), buf.end(), buf.begin(), ntoh ); - auto negative = []( int32_t x ) { return x < 0; }; - if ( std::any_of( buf.begin(), buf.end(), negative ) ) - throw nex::bad_header("Negative value, corrupted file"); - - hinfo h = { - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], - {}, - std::vector< int32_t >( buf[0], 0 ), - std::vector< std::vector >( buf[0], - std::vector()), - }; - - stream.seekg(8, std::ios::cur); - std::array< char, 8 > class_name; - for (int i = 0; i < h.num_classes; i++) { - stream.read(class_name.data(), 8); - h.class_names.push_back(std::string( class_name.data(), 8 )); - } - - stream.seekg(8, std::ios::cur); - stream.read((char*) h.vars_in_class.data(), h.num_classes * 4); - std::transform( h.vars_in_class.begin(), - h.vars_in_class.end(), - h.vars_in_class.begin(), - ntoh ); - if (std::any_of( h.vars_in_class.begin(), h.vars_in_class.end(), negative)) - throw nex::bad_header("Negative value, corrupted file"); - - stream.seekg(8, std::ios::cur); - for (int i = 0; i < h.num_classes; ++i) { - stream.seekg(4, std::ios::cur); - std::vector< char > var_names( h.vars_in_class[i] * 4, 0 ); - stream.read( var_names.data(), h.vars_in_class[i] * 4 ); - for (int k = 0; k < h.vars_in_class[i]; ++k) - h.var_names[i].push_back( std::string( var_names.data() + k*4 ,4 )); - stream.seekg(8, std::ios::cur); - } - stream.seekg(4, std::ios::cur); - - return h; -} - -} - -nex::NexusPlot::NexusPlot( const std::string& filename ) { - std::ifstream stream(filename, std::ios::binary); - if ( !stream.good() ) - throw nex::read_error("Could not open file " + filename); - this->load(stream); -} - -nex::NexusPlot::NexusPlot( std::istream& stream ) { - this->load(stream); -} - -void nex::NexusPlot::load(std::istream& stream) { - struct stream_guard { - stream_guard( std::istream& stream ) : - mask( stream.exceptions() ), - s( stream ) {} - ~stream_guard() { this->s.exceptions( this->mask ); } - std::ios::iostate mask; - std::istream& s; - } g { stream }; - stream.exceptions( std::ios::goodbit ); - - stream.seekg(4, std::ios::beg); // skip 4 bytes - auto type_header = read_str<10>(stream); - - if (type_header.compare(NEXUS_PLOT_TYPE_HEADER) != 0 || !stream.good()) - throw nex::bad_header("Could not verify file type"); - - auto header = headerinfo( stream ); - this->num_classes = header.num_classes; - this->day = header.day; - this->month = header.month; - this->year = header.year; - this->nx = header.nx; - this->ny = header.ny; - this->nz = header.nz; - this->ncomp = header.ncomp; - this->class_names = header.class_names; - this->vars_in_class = header.vars_in_class; - this->var_names = header.var_names; -} - -ecl_sum_type* nex::NexusPlot::ecl_summary( const std::string& ecl_case ) { - bool unified = true; - bool fmt_output = false; - const char* key_join_string = ":"; - time_t sim_start = 0; - bool time_in_days = true; - - ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( ecl_case.c_str(), - fmt_output, - unified, - key_join_string, - sim_start, - time_in_days, - this->nx, this->ny, this->nz); - - return ecl_sum; -} diff --git a/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp b/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp deleted file mode 100644 index 6c8620c958..0000000000 --- a/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus2ecl.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -#include -#include - -#include - -#include - - -void test_create_ecl_sum(char *root_folder) { - test_work_area_type *work_area = test_work_area_alloc("nexus_header"); - - std::stringstream ss; - ss << root_folder << "/test-data/local/nexus/SPE1.plt"; - std::cout << ss.str() << std::endl; - nex::NexusPlot plt = nex::NexusPlot { ss.str() }; - - ecl_sum_type *ecl_sum = plt.ecl_summary( "ECL_CASE" ); - test_assert_true( ecl_sum_is_instance( ecl_sum )); - ecl_sum_fwrite( ecl_sum ); - ecl_sum_free( ecl_sum ); - test_assert_true( util_file_exists( "ECL_CASE.SMSPEC")); - - test_work_area_free(work_area); -} - - - -int main(int argc, char **argv) { - util_install_signals(); - test_create_ecl_sum(argv[1]); - exit(0); -} diff --git a/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp b/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp deleted file mode 100644 index 34e778cd68..0000000000 --- a/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot_constructor.cpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - - -#include -#include - -void test_invalid_header1() { - std::stringstream stream( "xxxxINVALID_HEADER" ); - test_assert_throw(nex::NexusPlot { stream }, nex::bad_header); -} - -void test_invalid_header2() { - std::stringstream stream( "xxx" ); - test_assert_throw(nex::NexusPlot { stream }, nex::bad_header); -} - -void test_valid_header() { - std::stringstream stream( "xxxxPLOT BIN " ); - test_assert_throw(nex::NexusPlot { stream }, nex::unexpected_eof); -} - -void test_spe1_header(char *argv) { - std::stringstream ss; - ss << argv << "/test-data/local/nexus/SPE1.plt"; - auto plt = nex::NexusPlot { ss.str() }; - - std::array< std::string, 9 > class_names = { - "WELL ", "WLLYR ", "NODE ", "CONN ", "REGION ", "FIELD ", - "CONNLIST", "TARGET ", "FLOSTA " - }; - std::array< int, 9 > vars_in_class = { - 56, 52, 4, 43, 69, 58, 20, 25, 25 - }; - - std::array< std::vector< std::string >, 9 > var_names = { - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "CGI ", "CWI ", "QOP ", "QGP ", "QWP ", - "QGI ", "QWI ", "BHP ", "WPH ", "WKH ", "WPAV", "THP ", "COWP", - "QOWP", "GOR ", "WCUT", "WOR ", "QGLG", "CGLG", "DRDN", "DRMX", - "CROP", "CRGP", "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", - "RWP ", "ROI ", "RGI ", "RWI ", "ONTM", "ALQ ", "API ", "QCDP", - "CCDP", "YCDP", "ACTV", "STAT", "Q1P ", "Q1I ", "C1P ", "C1I ", - "X1P ", "Y1P ", "Q2P ", "Q2I ", "C2P ", "C2I ", "X2P ", "Y2P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "COP ", "CGP ", "CWP ", "CGI ", "CWI ", - "PRES", "HEAD", "RW ", "SKIN", "WI ", "WBC ", "PWB ", "QGI ", - "QWI ", "COWP", "QOWP", "GOR ", "WCUT", "ACTV", "CROP", "CRGP", - "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", "ROI ", - "RGI ", "RWI ", "QCDP", "CCDP", "YCDP", "API ", "MD ", "FSEC", - "Q1P ", "Q1I ", "C1P ", "C1I ", "X1P ", "Y1P ", "Q2P ", "Q2I ", - "C2P ", "C2I ", "X2P ", "Y2P " }, - std::vector< std::string > { "PNOD", "PDAT", "TNOD", "ACTV" }, - std::vector< std::string > { - "QGAS", "QOIL", "QWTR", "CGAS", "COIL", "CWTR", "CBFG", "CBFO", - "CBFW", "QGIS", "QOIS", "QWIS", "P_IN", "POUT", "T_IN", "TOUT", - "ACTV", "STAT", "CSTR", "ITRG", "ONTM", "ALQ ", "SETM", "SETA", - "POWM", "POWA", "SPDM", "SPDA", "API ", "DELP", "QTOT", "GVF ", - "EFF ", "POSN", "WCUT", "GOR ", "WOR ", "Q1 ", "Q2 ", "X1 ", - "X2 ", "Y1 ", "Y2 " }, - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "COI ", "CGI ", "CWI ", "PAVT", "PAVH", - "OIP ", "GIP ", "WIP ", "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", - "QWI ", "OIN ", "GIN ", "WIN ", "SO ", "SG ", "SW ", "OREC", - "FGIP", "CIP ", "PAVE", "PAVD", "ROIP", "RGIP", "RWIP", "MRO ", - "MRG ", "MRW ", "NFLX", "PV ", "HCPV", "TAVT", "TAVH", "CROP", - "CRGP", "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", - "ROI ", "RGI ", "RWI ", "QCDP", "CCDP", "YCDP", "API ", "GOR ", - "WCUT", "WOR ", "Z1 ", "Z2 ", "MC1 ", "MC2 ", "MC3 ", "C1P ", - "C2P ", "C3P ", "C1I ", "C2I ", "C3I " }, - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "CGI ", "CWI ", "QOP ", "QGP ", "QWP ", - "QGI ", "QWI ", "COWP", "QOWP", "GOR ", "OREC", "GREC", "PAVT", - "PAVH", "QGLG", "CGLG", "WCUT", "NFLX", "CROP", "CRGP", "CRWP", - "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", "ROI ", "RGI ", - "RWI ", "OIP ", "GIP ", "WIP ", "QCDP", "CCDP", "YCDP", "WLLS", - "PRDW", "GLFW", "WINJ", "GINJ", "ACTW", "API ", "Q1P ", "Q1I ", - "C1P ", "C1I ", "X1P ", "Y1P ", "Q2P ", "Q2I ", "C2P ", "C2I ", - "X2P ", "Y2P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", "QWI ", "COP ", "CGP ", - "CWP ", "COI ", "CGI ", "CWI ", "API ", "WCUT", "GOR ", "WOR ", - "Q1P ", "Q1I ", "Q2P ", "Q2I " }, - std::vector< std::string > { - "SQO ", "SQG ", "SQW ", "SQL ", "SQA ", "SQH ", "RQO ", "RQG ", - "RQW ", "RQL ", "RQA ", "RQH ", "TSQO", "TSQG", "TSQW", "TSQL", - "TSQA", "TSQH", "TRQO", "TRQG", "TRQW", "TRQL", "TRQA", "TRQH", - "P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", "QWI ", "COP ", "CGP ", - "CWP ", "COI ", "CGI ", "CWI ", "WLLS", "PRDW", "GLFW", "WINJ", - "GINJ", "ACTW", "WCUT", "GOR ", "WOR ", "Q1P ", "Q1I ", "Q2P ", - "Q2I " } - }; - - test_assert_int_equal(plt.num_classes, 9); - test_assert_int_equal(plt.day, 1); - test_assert_int_equal(plt.month, 1); - test_assert_int_equal(plt.year, 1980); - test_assert_int_equal(plt.nx, 1); - test_assert_int_equal(plt.ny, 1); - test_assert_int_equal(plt.nz, 1); - test_assert_int_equal(plt.ncomp, 2); - for (int i = 0; i < plt.num_classes; i++) - test_assert_std_string_equal(class_names[i], plt.class_names[i]); - for (int i = 0; i < plt.num_classes; i++) - test_assert_int_equal(vars_in_class[i], plt.vars_in_class[i]); - for (int i = 0; i < plt.num_classes; ++i) { - for (int k = 0; k < plt.vars_in_class[i]; ++k) { - test_assert_std_string_equal(var_names[i][k], plt.var_names[i][k]); - } - } -} - -int main(int argc, char* argv[]) { - test_invalid_header1(); - test_invalid_header2(); - test_valid_header(); - test_spe1_header(argv[1]); - return 0; -} diff --git a/ThirdParty/Ert/lib/util/TestArea.cpp b/ThirdParty/Ert/lib/util/TestArea.cpp index bc6212e2ef..afd204f9ea 100644 --- a/ThirdParty/Ert/lib/util/TestArea.cpp +++ b/ThirdParty/Ert/lib/util/TestArea.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include diff --git a/ThirdParty/Ert/lib/util/arg_pack.c b/ThirdParty/Ert/lib/util/arg_pack.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/arg_pack.c rename to ThirdParty/Ert/lib/util/arg_pack.cpp index ce67984434..e204c11be0 100644 --- a/ThirdParty/Ert/lib/util/arg_pack.c +++ b/ThirdParty/Ert/lib/util/arg_pack.cpp @@ -21,13 +21,13 @@ #include #include -#include -#include -#include +#include +#include +#include /** - This file implements a arg_pack structure which is a small + This file implements an arg_pack structure which is a small convienence utility to pack several arguments into one argument. The generic use situtation is when calling functions like e.g. pthread_create() which take one (void *) as argument. You can diff --git a/ThirdParty/Ert/lib/util/buffer.c b/ThirdParty/Ert/lib/util/buffer.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/buffer.c rename to ThirdParty/Ert/lib/util/buffer.cpp index a590ce8c22..a1546dd32f 100644 --- a/ThirdParty/Ert/lib/util/buffer.c +++ b/ThirdParty/Ert/lib/util/buffer.cpp @@ -23,11 +23,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include @@ -272,7 +272,7 @@ void buffer_fseek(buffer_type * buffer , ssize_t offset , int whence) { a buffer with content_size == 20 we can seek to position 20. */ - if ((new_pos >= 0) && (new_pos <= buffer->content_size)) + if ((new_pos >= 0) && (new_pos <= (ssize_t)buffer->content_size)) buffer->pos = new_pos; else util_abort("%s: tried to seek to position:%ld - outside of bounds: [0,%d) \n", @@ -839,7 +839,7 @@ void buffer_fwrite_string(buffer_type * buffer , const char * string) { void buffer_fprintf(const buffer_type * buffer, const char * fmt, FILE * stream) { - int index=0; + size_t index=0; size_t offset = 0; while (true) { char fmt_char = fmt[index]; @@ -891,7 +891,7 @@ static size_t __compress_bound (size_t sourceLen) Return value is the size (in bytes) of the compressed buffer. */ size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size) { - size_t compressed_size = 0; + unsigned long compressed_size = 0; bool abort_on_error = true; buffer->content_size = buffer->pos; /* Invalidating possible buffer content coming after the compressed content; that is uninterpretable anyway. */ @@ -916,7 +916,7 @@ size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t */ size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size) { size_t remaining_size = buffer->content_size - buffer->pos; - size_t uncompressed_size = target_size; + unsigned long uncompressed_size = target_size; if (remaining_size < compressed_size) util_abort("%s: trying to read beyond end of buffer\n",__func__); diff --git a/ThirdParty/Ert/lib/util/ecl_version.c b/ThirdParty/Ert/lib/util/ecl_version.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/ecl_version.c rename to ThirdParty/Ert/lib/util/ecl_version.cpp index 664fa9efd2..24acac01e9 100644 --- a/ThirdParty/Ert/lib/util/ecl_version.c +++ b/ThirdParty/Ert/lib/util/ecl_version.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #define xstr(s) #s #define str(s) xstr(s) diff --git a/ThirdParty/Ert/lib/util/hash.c b/ThirdParty/Ert/lib/util/hash.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/hash.c rename to ThirdParty/Ert/lib/util/hash.cpp index 68e636b8ba..60b62b6590 100644 --- a/ThirdParty/Ert/lib/util/hash.c +++ b/ThirdParty/Ert/lib/util/hash.cpp @@ -23,12 +23,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/util/hash_node.c b/ThirdParty/Ert/lib/util/hash_node.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/hash_node.c rename to ThirdParty/Ert/lib/util/hash_node.cpp index 4d9f6bbbf5..c77b19f993 100644 --- a/ThirdParty/Ert/lib/util/hash_node.c +++ b/ThirdParty/Ert/lib/util/hash_node.cpp @@ -22,9 +22,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/hash_sll.c b/ThirdParty/Ert/lib/util/hash_sll.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/hash_sll.c rename to ThirdParty/Ert/lib/util/hash_sll.cpp index a91b683be6..569d59f948 100644 --- a/ThirdParty/Ert/lib/util/hash_sll.c +++ b/ThirdParty/Ert/lib/util/hash_sll.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/lars.c b/ThirdParty/Ert/lib/util/lars.c deleted file mode 100644 index f7585904b9..0000000000 --- a/ThirdParty/Ert/lib/util/lars.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lars.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define LARS_TYPE_ID 77125439 - -struct lars_struct { - UTIL_TYPE_ID_DECLARATION; - matrix_type * X; - matrix_type * Y; - bool data_owner; - double Y0; - matrix_type * beta0; - - matrix_type * beta; - matrix_type * X_norm; - matrix_type * X_mean; - double Y_mean; -}; - - - -static lars_type * lars_alloc__() { - lars_type * lars = (lars_type*)util_malloc( sizeof * lars ); - UTIL_TYPE_ID_INIT( lars , LARS_TYPE_ID ); - lars->X = NULL; - lars->Y = NULL; - - lars->X_norm = NULL; - lars->X_mean = NULL; - lars->beta = NULL; - lars->beta0 = NULL; - lars->Y = 0; - - return lars; -} - -lars_type * lars_alloc1( int nsample , int nvars) { - lars_type * lars = lars_alloc__(); - lars->X = matrix_alloc( nsample , nvars ); - lars->Y = matrix_alloc( nsample , 1 ); - lars->data_owner = true; - return lars; -} - - -lars_type * lars_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy ) { - lars_type * lars = lars_alloc__(); - if (internal_copy) { - lars->X = matrix_alloc_copy( X ); - lars->Y = matrix_alloc_copy( Y ); - lars->data_owner = true; - } else { - lars->X = X; - lars->Y = Y; - lars->data_owner = false; - } - return lars; -} - -int lars_get_sample( const lars_type * lars ) { - return matrix_get_rows( lars->X ); -} - - -int lars_get_nvar( const lars_type * lars ) { - return matrix_get_columns( lars->X ); -} - - -void lars_isetX( lars_type * lars, int sample, int var , double value) { - matrix_iset( lars->X , sample , var , value ); -} - -void lars_isetY( lars_type * lars, int sample, double value) { - matrix_iset( lars->Y , sample , 0 , value ); -} - -#define MATRIX_SAFE_FREE( m ) if (m != NULL) matrix_free( m ) -void lars_free( lars_type * lars ) { - - if (lars->data_owner) { - MATRIX_SAFE_FREE( lars->X ); - MATRIX_SAFE_FREE( lars->Y ); - } - MATRIX_SAFE_FREE( lars->X_norm ); - MATRIX_SAFE_FREE( lars->X_mean ); - MATRIX_SAFE_FREE( lars->beta ); - MATRIX_SAFE_FREE( lars->beta0 ); - - free( lars ); -} -#undef MATRIX_SAFE_FREE - -/*****************************************************************/ - -static double sgn(double x) { - return copysign(1 , x); // C99 -} - - -static void lars_estimate_init( lars_type * lars, matrix_type * X , matrix_type * Y) { - int nvar = matrix_get_columns( lars->X ); - - matrix_assign( X , lars->X ); - matrix_assign( Y , lars->Y ); - if (lars->X_norm != NULL) - matrix_free( lars->X_norm ); - lars->X_norm = matrix_alloc(1 , nvar ); - - if (lars->X_mean != NULL) - matrix_free( lars->X_mean ); - lars->X_mean = matrix_alloc(1 , nvar ); - - if (lars->beta != NULL) - matrix_free( lars->beta ); - lars->beta = matrix_alloc( nvar , nvar ); - lars->Y_mean = regression_scale( X , Y , lars->X_mean , lars->X_norm); -} - - -double lars_getY0( const lars_type * lars) { - return lars->Y0; -} - -double lars_iget_beta( const lars_type * lars , int index) { - return matrix_iget( lars->beta0 , index , 0 ); -} - - - -void lars_select_beta( lars_type * lars , int beta_index) { - int nvars = matrix_get_rows( lars->beta ); - if (lars->beta0 == NULL) - lars->beta0 = matrix_alloc( nvars , 1 ); - { - matrix_type * beta_vector = matrix_alloc( nvars , 1 ); - matrix_copy_column( beta_vector , lars->beta , 0 , beta_index ); - lars->Y0 = regression_unscale( beta_vector , lars->X_norm , lars->X_mean , lars->Y_mean , lars->beta0 ); - matrix_free( beta_vector ); - } -} - - - -/* - The algorithm can very briefly be summarized as: - - 1. Determine the covariate with greatest correlation to the data and - add this covariate to the model. In the current implementation the - correlations are stored in the matrix @C and the greatest - correlation is stored in the scalar variable @maxC. - - 2. Determine an update direction in the set of active covariates - which is equiangular to all covariates. - - 3. Determine the step length @gamma - which is the exact step length - before a new covariate will enter the active set at the current - correlation level. - - 4. Update the beta estimate and the current 'location' mu. -*/ - -void lars_estimate(lars_type * lars , int max_vars , double max_beta , bool verbose) { - int nvars = matrix_get_columns( lars->X ); - int nsample = matrix_get_rows( lars->X ); - matrix_type * X = matrix_alloc( nsample, nvars ); // Allocate local X and Y variables - matrix_type * Y = matrix_alloc( nsample, 1 ); // which will hold the normalized data - lars_estimate_init( lars , X , Y); // during the estimation process. - { - matrix_type * G = matrix_alloc_gram( X , true ); - matrix_type * mu = matrix_alloc( nsample , 1 ); - matrix_type * C = matrix_alloc( nvars , 1 ); - matrix_type * Y_mu = matrix_alloc_copy( Y ); - int_vector_type * active_set = int_vector_alloc(0,0); - int_vector_type * inactive_set = int_vector_alloc(0,0); - int active_size; - - - if ((max_vars <= 0) || (max_vars > nvars)) - max_vars = nvars; - - { - int i; - for (i=0; i < nvars; i++) - int_vector_iset( inactive_set , i , i ); - } - matrix_set( mu , 0 ); - - while (true) { - double maxC = 0; - - /* - The first step is to calculate the correlations between the - covariates, and the current residual. All the currently inactive - covariates are searched; the covariate with the greatest - correlation with (Y - mu) is selected and added to the active set. - */ - matrix_sub( Y_mu , Y , mu ); // Y_mu = Y - mu - matrix_dgemm( C , X , Y_mu , true , false , 1.0 , 0); // C = X' * Y_mu - { - int i; - int max_set_index = 0; - - for (i=0; i < int_vector_size( inactive_set ); i++) { - int set_index = i; - int var_index = int_vector_iget( inactive_set , set_index ); - double value = fabs( matrix_iget(C , var_index , 0) ); - if (value > maxC) { - maxC = value; - max_set_index = set_index; - } - } - /* - Remove element corresponding to max_set_index from the - inactive set and add it to the active set: - */ - int_vector_append( active_set , int_vector_idel( inactive_set , max_set_index )); - } - active_size = int_vector_size( active_set ); - /* - Now we have calculated the correlations between all the - covariates and the current residual @Y_mu. The correlations are - stored in the matrix @C. The value of the maximum correlation is - stored in @maxC. - - Based on the value of @maxC we have added one new covariate to - the model, technically by moving the index from @inactive_set to - @active_set. - */ - - /*****************************************************************/ - - - { - matrix_type * weights = matrix_alloc( active_size , 1); - double scale; - - /*****************************************************************/ - /* This scope should compute and initialize the variables - @weights and @scale. */ - { - matrix_type * subG = matrix_alloc( active_size , active_size ); - matrix_type * STS = matrix_alloc( active_size , active_size ); - matrix_type * sign_vector = matrix_alloc( active_size , 1); - int i , j; - - /* - STS = S' o S where 'o' is the Schur product and S is given - by: - - [ s1 s2 s3 s4 ] - S = [ s1 s2 s3 s4 ] - [ s1 s2 s3 s4 ] - [ s1 s2 s3 s4 ] - - Where si is the sign of the correlation between (active) - variable 'i' and Y_mu. - */ - - - for (i=0; i < active_size ; i++) { - int vari = int_vector_iget( active_set , i ); - double signi = sgn( matrix_iget( C , vari , 0)); - matrix_iset( sign_vector , i , 0 , signi ); - for (j=0; j < active_size; j++) { - int varj = int_vector_iget( active_set , j ); - double signj = sgn( matrix_iget( C , varj , 0)); - - matrix_iset( STS , i , j , signi * signj ); - } - } - - // Extract the elements from G corresponding to active indices and - // copy to the matrix subG: - for (i=0; i < active_size ; i++) { - int ii = int_vector_iget( active_set , i ); - for (j=0; j < active_size; j++) { - int jj = int_vector_iget( active_set , j ); - - matrix_iset( subG , i , j , matrix_iget(G , ii , jj)); - } - } - - // Weights - matrix_inplace_mul( subG , STS ); - matrix_inv( subG ); - - { - matrix_type * ones = matrix_alloc( active_size , 1 ); - matrix_type * GA1 = matrix_alloc( active_size , 1 ); - - matrix_set( ones , 1.0 ); - matrix_matmul( GA1 , subG , ones ); - scale = 1.0 / sqrt( matrix_get_column_sum( GA1 , 0 )); - - matrix_mul( weights , GA1 , sign_vector ); - matrix_scale( weights , scale ); - - matrix_free( GA1 ); - matrix_free( ones ); - } - - matrix_free( sign_vector ); - matrix_free( subG ); - matrix_free( STS ); - } - - /******************************************************************/ - /* The variables weight and scale have been calculated, proceed - to calculate the step length @gamma. */ - { - int i; - double gamma; - - { - matrix_type * u = matrix_alloc( nsample , 1 ); - int j; - - for (i=0; i < nsample; i++) { - double row_sum = 0; - for (j =0; j < active_size; j++) - row_sum += matrix_iget( X , i , int_vector_iget( active_set , j)) * matrix_iget(weights , j , 0 ); - - matrix_iset( u , i , 0 , row_sum ); - } - - gamma = maxC / scale; - if (active_size < matrix_get_columns( X )) { - matrix_type * equi_corr = matrix_alloc( nvars , 1 ); - matrix_dgemm( equi_corr , X , u , true , false , 1.0 , 0); // equi_corr = X'·u - for (i=0; i < (nvars - active_size); i++) { - int var_index = int_vector_iget( inactive_set , i ); - double gamma1 = (maxC - matrix_iget(C , var_index , 0 )) / ( scale - matrix_iget( equi_corr , var_index , 0)); - double gamma2 = (maxC + matrix_iget(C , var_index , 0 )) / ( scale + matrix_iget( equi_corr , var_index , 0)); - - if ((gamma1 > 0) && (gamma1 < gamma)) - gamma = gamma1; - - if ((gamma2 > 0) && (gamma2 < gamma)) - gamma = gamma2; - - } - matrix_free( equi_corr ); - } - /* Update the current estimated 'location' mu. */ - matrix_scale( u , gamma ); - matrix_inplace_add( mu , u ); - matrix_free( u ); - } - - /* - We have calculated the step length @gamma, and the @weights. Update the @beta matrix. - */ - for (i=0; i < active_size; i++) - matrix_iset( lars->beta , int_vector_iget( active_set , i ) , active_size - 1 , gamma * matrix_iget( weights , i , 0)); - - if (active_size > 1) - for (i=0; i < nvars; i++) - matrix_iadd( lars->beta , i , active_size - 1 , matrix_iget( lars->beta , i , active_size - 2)); - - matrix_free( weights ); - } - } - - if (active_size == max_vars) - break; - - if (max_beta > 0) { - double beta_norm2 = matrix_get_column_abssum( lars->beta , active_size - 1 ); - if (beta_norm2 > max_beta) { - // We stop - we will use an interpolation between this beta estimate and - // the previous, to ensure that the |beta| = max_beta criteria is satisfied. - if (active_size >= 2) { - double beta_norm1 = matrix_get_column_abssum( lars->beta , active_size - 2 ); - double s = (max_beta - beta_norm1)/(beta_norm2 - beta_norm1); - { - int j; - for (j=0; j < nvars; j++) { - double beta1 = matrix_iget( lars->beta , j , active_size - 2 ); - double beta2 = matrix_iget( lars->beta , j , active_size - 1 ); - matrix_iset( lars->beta , j , active_size - 1 , beta1 + s*(beta2 - beta1)); - } - } - } - break; - } - } - } - matrix_free( G ); - matrix_free( mu ); - matrix_free( C ); - matrix_free( Y_mu ); - int_vector_free( active_set ); - int_vector_free( inactive_set ); - matrix_resize( lars->beta , nvars , active_size , true ); - if (verbose) - matrix_pretty_fprint( lars->beta , "beta" , "%12.5f" , stdout ); - lars_select_beta( lars , active_size - 1); - } - matrix_free( X ); - matrix_free( Y ); -} - - -double lars_eval1( const lars_type * lars , const matrix_type * x) { - return lars->Y0 + matrix_row_column_dot_product( x , 0 , lars->beta0 , 0 ); -} - - -double lars_eval2( const lars_type * lars , double * x) { - matrix_type * x_view = matrix_alloc_view( x , 1 , matrix_get_columns( lars->X_mean )); - double y = lars_eval1( lars , x_view ); - matrix_free( x_view ); - return y; -} - - - - - diff --git a/ThirdParty/Ert/lib/util/log.c b/ThirdParty/Ert/lib/util/log.c deleted file mode 100644 index 7e74ebc28b..0000000000 --- a/ThirdParty/Ert/lib/util/log.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'log.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ert/util/build_config.h" - -#ifdef HAVE_FSYNC -#include -#endif - -#ifdef HAVE_PTHREAD -#include -#endif - -#include -#include - -struct log_struct { - char * filename; - FILE * stream; - int fd; - int log_level; - int msg_count; -#ifdef HAVE_PTHREAD - pthread_mutex_t mutex; -#endif -}; - - - -static void log_delete_empty(const log_type * logh) { - if (logh->filename && util_file_exists( logh->filename ) ) { - size_t file_size = util_file_size( logh->filename ); - if (file_size == 0) - remove( logh->filename ); - } -} - -void log_reopen(log_type *logh , const char *filename) { - if (logh->stream != NULL) { /* Close the existing file descriptor. */ - fclose( logh->stream ); - log_delete_empty( logh ); - } - - logh->filename = util_realloc_string_copy( logh->filename , filename ); -#ifdef HAVE_PTHREAD - pthread_mutex_lock( &logh->mutex ); -#endif - - if (filename != NULL) { - logh->stream = util_mkdir_fopen( filename , "a+"); - logh->fd = fileno( logh->stream ); - } else { /* It is ~OK to open a log with NULL filename, but then - log_reopen() with a VALID filename must be - called before it is actually used. */ - logh->stream = NULL; - logh->fd = -1; - } - logh->msg_count = 0; -#ifdef HAVE_PTHREAD - pthread_mutex_unlock( &logh->mutex ); -#endif -} - - -const char * log_get_filename( const log_type * logh ) { - return logh->filename; -} - -int log_get_msg_count( const log_type * logh) { - return logh->msg_count; -} - -int log_get_level( const log_type * logh) { - return logh->log_level; -} - -/** - * If an incoming message is below or equal to the configured log_level, it is included. So a high log_level will - * include more messages. - */ -void log_set_level( log_type * logh , int log_level) { - logh->log_level = log_level; -} - - - -log_type * log_open( const char * filename , int log_level) { - log_type *logh; - - logh = (log_type*)util_malloc(sizeof *logh ); - - logh->msg_count = 0; - logh->log_level = log_level; - logh->filename = NULL; - logh->stream = NULL; -#ifdef HAVE_PTHREAD - pthread_mutex_init( &logh->mutex , NULL ); -#endif - if (filename != NULL && log_level > 0) - log_reopen( logh , filename); - - return logh; -} - - -/** - * The message_level is compared to the configured log_level. Low message_level means "more important". - */ -bool log_include_message(const log_type *logh , int message_level) { - if (message_level <= logh->log_level) - return true; - else - return false; -} - -/** - * Adds a string to the log if message_level is below the threshold. It is the callers duty to either free the string - * or make sure that it is a string literal. - */ -void log_add_message_str(log_type *logh, message_level_type message_level , const char* message){ - //The conversion to (char*) is safe since free_message=false - log_add_message(logh,message_level, NULL, (char*) message,false); -} - - -/** - If dup_stream != NULL the message (without the date/time header) is duplicated on this stream. -*/ -void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message) { - if (log_include_message(logh,message_level)) { - - if (logh->stream == NULL) - util_abort("%s: logh->stream == NULL - must call log_reset_filename() first \n",__func__); - -#ifdef HAVE_PTHREAD - pthread_mutex_lock( &logh->mutex ); -#endif - { - struct tm time_fields; - time_t epoch_time; - - time(&epoch_time); - util_time_utc(&epoch_time , &time_fields); - - if (message != NULL) - fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d %s\n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec , message); - else - fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d \n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec); - - /** We duplicate the message to the stream 'dup_stream'. */ - if ((dup_stream != NULL) && (message != NULL)) - fprintf(dup_stream , "%s\n", message); - - log_sync( logh ); - logh->msg_count++; - } -#ifdef HAVE_PTHREAD - pthread_mutex_unlock( &logh->mutex ); -#endif - if (free_message) - free( message ); - } -} - - - - - -/** - * Adds a formated log message if message_level is below the threshold, fmt is expected to be the format string, - * and "..." contains any arguments to it. - */ -void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...) { - if (log_include_message(logh,message_level)) { - char * message; - va_list ap; - va_start(ap , fmt); - message = util_alloc_sprintf_va( fmt , ap ); - log_add_message( logh , message_level , dup_stream , message , true); - va_end(ap); - } -} - - - - - - -/** - This function can be used to get low level to the FILE pointer of - the stream. To 'ensure' that the data actually hits the disk - you should call log_sync() after writing. - - It is your responsabiulity to avoid racing++ when using the - log_get_stream() function. -*/ - -FILE * log_get_stream(log_type * logh ) { - return logh->stream; -} - - -void log_sync(log_type * logh) { -#ifdef HAVE_FSYNC - fsync( logh->fd ); -#endif - util_fseek( logh->stream , 0 , SEEK_END ); -} - - - -void log_close( log_type * logh ) { - if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL)) - fclose( logh->stream ); /* This closes BOTH the FILE * stream and the integer file descriptor. */ - - log_delete_empty( logh ); - util_safe_free( logh->filename ); - free( logh ); -} - - -bool log_is_open( const log_type * logh) { - if (logh->stream != NULL) - return true; - else - return false; -} diff --git a/ThirdParty/Ert/lib/util/lookup_table.c b/ThirdParty/Ert/lib/util/lookup_table.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/lookup_table.c rename to ThirdParty/Ert/lib/util/lookup_table.cpp index 0e0a139461..f6d0bdf640 100644 --- a/ThirdParty/Ert/lib/util/lookup_table.c +++ b/ThirdParty/Ert/lib/util/lookup_table.cpp @@ -19,10 +19,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include struct lookup_table_struct { bool data_owner; diff --git a/ThirdParty/Ert/lib/util/matrix.c b/ThirdParty/Ert/lib/util/matrix.c deleted file mode 100644 index 8d2b28111e..0000000000 --- a/ThirdParty/Ert/lib/util/matrix.c +++ /dev/null @@ -1,1751 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/** - This is V E R Y S I M P L E matrix implementation. It is not - designed to be fast/efficient or anything. It is purely a minor - support functionality for the enkf program, and should N O T be - considered as general matrix functionality. -*/ - - - -/** - Many of matrix functions can potentially involve laaarge amounts of - memory. The functions: - - o matrix_alloc(), matrix_resize() and matrix_alloc_copy() will - abort with util_abort() if the memory requirements can not be - satisfied. - - o The corresponding functions matrix_safe_alloc(), - matrix_safe_resize() and matrix_safe_alloc_copy() will not abort, - instead NULL or an unchanged matrix will be returned. When using - these functons it is the responsability of the calling scope to - check return values. - - So the expression "safe" should be interpreted as 'can not abort' - - however the responsability of the calling scope is greater when it - comes to using these functions - things can surely blow up! -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#define MATRIX_TYPE_ID 712108 - -/*#define GET_INDEX(m,i,j) (m->row_stride * (i) + m->column_stride * (j))*/ - -/* - This GET_INDEX function has been forcely inlined for performance. -*/ -/*static size_t GET_INDEX( const matrix_type * m , size_t i , size_t j) { - return m->row_stride *i + m->column_stride *j; -}*/ - -static size_t MATRIX_DATA_SIZE( const matrix_type * m) { - size_t col = m->columns; - size_t stride = m->column_stride; - - return col*stride; -} - - - - -static void matrix_init_header(matrix_type * matrix , int rows , int columns , int row_stride , int column_stride) { - - if (!((column_stride * columns <= row_stride) || (row_stride * rows <= column_stride))) - util_abort("%s: invalid stride combination \n",__func__); - - matrix->data_size = 0; - matrix->alloc_rows = rows; - matrix->alloc_columns = columns; - matrix->row_stride = row_stride; - matrix->column_stride = column_stride; - - matrix_full_size( matrix ); -} - - -/** - This is the low-level function allocating storage. If the input - flag 'safe_mode' is equal to true, the function will return NULL if - the allocation fails, otherwise the function will abort() if the - allocation fails. - - Before returning all elements will be initialized to zero. - - 1. It is based on first free() of the original pointer, and then - subsequently calling malloc() to get new storage. This is to - avoid prohibitive temporary memory requirements during the - realloc() call. - - 2. If the malloc() fails the function will return NULL, i.e. you - will NOT keep the original data pointer. I.e. in this case the - matrix will be invalid. It is the responsability of the calling - scope to do the right thing. - - 3. realloc() functionality - i.e. keeping the original content of - the matrix is implemented at higher level. The memory layout of - the matrix will in general change anyway; so the promise made - by realloc() is not very interesting. -*/ - -static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { - if (matrix->data_owner) { - size_t data_size = MATRIX_DATA_SIZE( matrix ); - if (matrix->data_size == data_size) return; - if (matrix->data != NULL) - free(matrix->data); - - if (safe_mode) { - /* - If safe_mode == true it is 'OK' to fail in the allocation, - otherwise we use util_malloc() which will abort if the memory - is not available. - */ - matrix->data = (double*)malloc( sizeof * matrix->data * data_size ); - } else - matrix->data = (double*)util_malloc( sizeof * matrix->data * data_size ); - - - /* Initializing matrix content to zero. */ - if (matrix->data != NULL) { - size_t i; - for (i = 0; i < data_size; i++) - matrix->data[i] = 0; - } else - data_size = 0; - - /** - Observe that if the allocation failed the matrix will - be returned with data == NULL, and data_size == 0. - */ - matrix->data_size = data_size; - } else - util_abort("%s: can not manipulate memory when is not data owner\n",__func__); -} - - -UTIL_SAFE_CAST_FUNCTION( matrix , MATRIX_TYPE_ID ) - -/** - The matrix objecty is NOT ready for use after this function. -*/ -static matrix_type * matrix_alloc_empty( ) { - matrix_type * matrix = (matrix_type*)util_malloc( sizeof * matrix ); - UTIL_TYPE_ID_INIT( matrix , MATRIX_TYPE_ID ); - matrix->name = NULL; - return matrix; -} - -/* - The freshly allocated matrix is explicitly initialized to zero. If - the variable safe_mode equals true the function will return NULL if - the allocation of data fails, otherwise it will abort() if the - allocation fails. -*/ -static matrix_type * matrix_alloc_with_stride(int rows , int columns , int row_stride , int column_stride, bool safe_mode) { - matrix_type * matrix = NULL; - if ((rows > 0) && (columns > 0)) { - matrix = matrix_alloc_empty(); - matrix->data = NULL; - matrix->data_size = 0; - matrix_init_header( matrix , rows , columns , row_stride , column_stride); - matrix->data_owner = true; - matrix_realloc_data__( matrix , safe_mode ); - if (safe_mode) { - if (matrix->data == NULL) { - /* Allocation failed - we return NULL */ - matrix_free(matrix); - matrix = NULL; - } - } - } - return matrix; -} - - -void matrix_set_name( matrix_type * matrix , const char * name) { - matrix->name = util_realloc_string_copy( matrix->name , name ); -} - - -/** - This function will allocate a matrix object where the data is - shared with the 'src' matrix. A matrix allocated in this way can be - used with all the matrix_xxx functions, but you should be careful - when exporting the data pointer to e.g. lapack routines. -*/ - -matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns) { - if (((row + rows) > src->rows) || ((column + columns) > src->columns)) - util_abort("%s: Invalid matrix subsection src:[%d,%d] Offset:[%d,%d] SubSize:[%d,%d] \n", - __func__, - src->rows , src->columns, - row,column, - rows,columns); - - { - matrix_type * matrix = matrix_alloc_empty(); - - matrix_init_header( matrix , rows , columns , src->row_stride , src->column_stride); - matrix->data = &src->data[ GET_INDEX(src , row , column) ]; - matrix->data_owner = false; - - return matrix; - } -} - - -matrix_type * matrix_alloc_view(double * data , int rows , int columns) { - matrix_type * matrix = matrix_alloc_empty(); - - matrix_init_header( matrix , rows , columns , 1 , rows); - matrix->data = data; - matrix->data_owner = false; - - return matrix; -} - - -/** - This function will allocate a matrix structure; this matrix - structure will TAKE OWNERSHIP OF THE SUPPLIED DATA. This means that - it is (at the very best) highly risky to use the data pointer in - the calling scope after the matrix has been allocated. If the - supplied pointer is too small it is immediately realloced ( in - which case the pointer in the calling scope will be immediately - invalid). -*/ - -matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size) { - matrix_type * matrix = matrix_alloc_empty(); - matrix_init_header( matrix , rows , columns , 1 , rows ); - matrix->data_size = data_size; /* Can in general be different from rows * columns */ - matrix->data_owner = true; - matrix->data = data; - if (data_size < rows * columns) - matrix_realloc_data__(matrix , false); - - return matrix; -} - - - -/*****************************************************************/ - -static matrix_type * matrix_alloc__(int rows, int columns , bool safe_mode) { - return matrix_alloc_with_stride( rows , columns , 1 , rows , safe_mode ); /* Must be the stride (1,rows) to use the lapack routines. */ -} - -matrix_type * matrix_alloc(int rows, int columns) { - return matrix_alloc__( rows , columns , false ); -} - -matrix_type * matrix_safe_alloc(int rows, int columns) { - return matrix_alloc__( rows , columns , true ); -} - -matrix_type * matrix_alloc_identity(int dim) { - if (dim < 1) - util_abort("%s: identity matrix must have positive size. \n",__func__); - - matrix_type * idty = matrix_alloc(dim, dim); - for (int i = 0; i < dim; ++i) - matrix_iset(idty, i, i, 1); - return idty; -} - -/*****************************************************************/ - -/** - Will not respect strides - that is considered low level data - layout. -*/ -static matrix_type * matrix_alloc_copy__( const matrix_type * src , bool safe_mode) { - matrix_type * copy = matrix_alloc__( matrix_get_rows( src ), matrix_get_columns( src ) , safe_mode); - if (copy != NULL) - matrix_assign(copy , src); - return copy; -} - - -matrix_type * matrix_alloc_copy(const matrix_type * src) { - return matrix_alloc_copy__(src , false ); -} - -matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask) { - if (bool_vector_size( mask ) != matrix_get_columns( src )) - util_abort("%s: size mismatch. Src matrix has %d rows mask has:%d elements\n", __func__ , matrix_get_rows( src ) , bool_vector_size( mask )); - { - int target_columns = bool_vector_count_equal( mask , true ); - matrix_type * target = matrix_alloc( matrix_get_rows( src ) , target_columns ); - - matrix_column_compressed_memcpy( target , src , mask ); - return target; - } -} - - -void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask) { - if (bool_vector_count_equal( mask , true ) != matrix_get_columns( target )) - util_abort("%s: size mismatch. \n",__func__); - - if (bool_vector_size( mask ) != matrix_get_columns( src)) - util_abort("%s: size mismatch. \n",__func__); - - { - int target_col = 0; - int src_col; - for (src_col = 0; src_col < bool_vector_size( mask ); src_col++) { - if (bool_vector_iget( mask , src_col)) { - matrix_copy_column( target , src , target_col , src_col); - target_col++; - } - } - } -} - - - -matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src) { - if (T == NULL) - return matrix_alloc_copy( src ); - else { - matrix_resize( T , src->rows , src->columns , false ); - matrix_assign( T , src ); - return T; - } -} - - - - -/** - Will return NULL if allocation of the copy failed. -*/ - -matrix_type * matrix_safe_alloc_copy(const matrix_type * src) { - return matrix_alloc_copy__(src , true); -} - -void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns, - const matrix_type * src_matrix , int src_row , int src_column) { - matrix_type * target_view = matrix_alloc_shared(target_matrix , target_row , target_column , rows , columns); - matrix_type * src_view = matrix_alloc_shared( src_matrix , src_row , src_column , rows , columns); - matrix_assign( target_view , src_view ); - matrix_free( target_view ); - matrix_free( src_view ); -} - -matrix_type * matrix_alloc_sub_copy( const matrix_type * src , int row_offset , int column_offset , int rows, int columns) { - matrix_type * copy = matrix_alloc( rows, columns ); - matrix_copy_block( copy , 0 , 0 , rows , columns , src , row_offset , column_offset ); - return copy; -} - - -/*****************************************************************/ - -static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool copy_content , bool safe_mode) { - if (!matrix->data_owner) - util_abort("%s: sorry - can not resize shared matrizes. \n",__func__); - { - bool resize_OK = true; - - if ((rows != matrix->rows) || (columns != matrix->columns)) { - int copy_rows = util_int_min( rows , matrix->rows ); - int copy_columns = util_int_min( columns , matrix->columns); - matrix_type * copy_view = NULL; - matrix_type * copy = NULL; - - if (copy_content) { - copy_view = matrix_alloc_shared( matrix , 0 , 0 , copy_rows , copy_columns); /* This is the part of the old matrix which should be copied over to the new. */ - copy = matrix_alloc_copy__( copy_view , safe_mode ); /* Now copy contains the part of the old matrix which should be copied over - with private storage. */ - } - { - int old_rows , old_columns, old_row_stride , old_column_stride; - matrix_get_dims( matrix , &old_rows , &old_columns , &old_row_stride , &old_column_stride); /* Storing the old header information - in case the realloc() fails. */ - - matrix_init_header(matrix , rows , columns , 1 , rows); /* Resetting the header for the matrix */ - matrix_realloc_data__(matrix , safe_mode); - if (matrix->data != NULL) { /* Realloc succeeded */ - if (copy_content) { - matrix_type * target_view = matrix_alloc_shared(matrix , 0 , 0 , copy_rows , copy_columns); - matrix_assign( target_view , copy); - matrix_free( target_view ); - } - } else { - /* Failed to realloc new storage; RETURNING AN INVALID MATRIX */ - matrix_init_header(matrix , old_rows , old_columns , old_row_stride , old_column_stride); - resize_OK = false; - } - } - - if (copy_content) { - matrix_free(copy_view); - matrix_free(copy); - } - } - return resize_OK; - } -} - - -/** - If copy content is true the content of the old matrix is carried - over to the new one, otherwise the new matrix is cleared. - - Will always return true (or abort). -*/ -bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content) { - return matrix_resize__(matrix , rows , columns , copy_content , false); -} - - -/** - Return true if the resize succeded, otherwise it will return false - and leave the matrix unchanged. When resize implies expanding a - dimension, the newly created elements will be explicitly - initialized to zero. - - If copy_content is set to false the new matrix will be fully - initialized to zero. -*/ - -bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content) { - return matrix_resize__(matrix , rows , columns , copy_content , true); -} - - - -/** - This function will ensure that the matrix has at least 'rows' - rows. If the present matrix already has >= rows it will return - immediately, otherwise the matrix will be resized. -*/ - -void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content) { - if (matrix->rows < rows) - matrix_resize( matrix , rows , matrix->columns , copy_content); -} - - - -/** - This function will reduce the size of the matrix. It will only - affect the headers, and not touch the actual memory of the matrix. -*/ - -void matrix_shrink_header(matrix_type * matrix , int rows , int columns) { - - if (rows <= matrix->rows) - matrix->rows = rows; - - if (columns <= matrix->columns) - matrix->columns = columns; - -} - - -void matrix_full_size( matrix_type * matrix ) { - matrix->rows = matrix->alloc_rows; - matrix->columns = matrix->alloc_columns; -} - - -/*****************************************************************/ - -static void matrix_free_content(matrix_type * matrix) { - if (matrix->data_owner) - util_safe_free(matrix->data); - util_safe_free( matrix->name ); -} - -void matrix_free(matrix_type * matrix) { - matrix_free_content( matrix ); - free(matrix); -} - - -void matrix_safe_free( matrix_type * matrix ) { - if (matrix != NULL) - matrix_free( matrix ); -} - - -/*****************************************************************/ -void matrix_pretty_fprint_submat(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream, int m, int M, int n, int N) { - int i,j; - - if (m<0 || m>M || M >= matrix->rows || n<0 || n>N || N >= matrix->columns) - util_abort("%s: matrix:%s not compatible with print subdimensions. \n",__func__ , matrix->name); - - fprintf(stream , "%s =" , name); - for (i=m; i < M; i++) { - fprintf(stream , " ["); - for (j=n; j < N; j++) - fprintf(stream , fmt , matrix_iget(matrix , i,j)); - fprintf(stream , "]\n"); - } -} -/*****************************************************************/ - -void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream) { - int i,j; - for (i=0; i < matrix->rows; i++) { - - if (i == (matrix->rows / 2)) - fprintf(stream , "%s =" , name); - else { - int l; - for (l = 0; l < strlen(name) + 2; l++) - fprintf(stream , " "); - } - - fprintf(stream , " ["); - for (j=0; j < matrix->columns; j++) - fprintf(stream , fmt , matrix_iget(matrix , i,j)); - fprintf(stream , "]\n"); - } -} - - -void matrix_pretty_print(const matrix_type * matrix , const char * name , const char * fmt) { - matrix_pretty_fprint(matrix , name , fmt , stdout ); -} - - -void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream ) { - int i,j; - for (i=0; i < matrix->rows; i++) { - for (j=0; j < matrix->columns; j++) - fprintf(stream , fmt , matrix_iget( matrix , i , j)); - fprintf(stream , "\n"); - } -} - - -void matrix_dump_csv( const matrix_type * matrix ,const char * filename) { - FILE * stream = util_fopen(filename , "w"); - for (int i=0; i < matrix->rows; i++) { - for (int j=0; j < matrix->columns - 1; j++) - fprintf(stream , "%g, " , matrix_iget( matrix , i , j)); - fprintf(stream , "%g\n" , matrix_iget( matrix , i , matrix->columns - 1)); - } - fclose( stream ); -} - - -void matrix_fwrite(const matrix_type * matrix , FILE * stream) { - util_fwrite_int( matrix->rows , stream ); - util_fwrite_int( matrix->columns , stream ); - - if (matrix->column_stride == matrix->rows) - util_fwrite( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); - else { - int column; - for (column=0; column < matrix->columns; column++) { - if (matrix->row_stride == 1) { - const double * column_data = &matrix->data[ column * matrix->column_stride ]; - util_fwrite( column_data , sizeof * column_data , matrix->rows , stream , __func__); - } else { - int row; - for (row=0; row < matrix->rows; row++) - util_fwrite_double( matrix->data[ GET_INDEX( matrix , row , column )] , stream); - } - } - } -} - - -void matrix_fread(matrix_type * matrix , FILE * stream) { - int rows = util_fread_int( stream ); - int columns = util_fread_int( stream ); - - matrix_resize( matrix , rows , columns , false); - if (matrix->column_stride == matrix->rows) - util_fread( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); - else { - int column; - for (column=0; column < matrix->columns; column++) { - if (matrix->row_stride == 1) { - double * column_data = &matrix->data[ column * matrix->column_stride ]; - util_fread( column_data , sizeof * column_data , matrix->rows , stream , __func__); - } else { - int row; - for (row=0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column )] = util_fread_double( stream ); - } - } - } -} - -matrix_type * matrix_fread_alloc(FILE * stream) { - matrix_type * matrix = matrix_alloc(1,1); - matrix_fread(matrix , stream); - return matrix; -} - - -/** - [ a11 a12 ] - [ a21 a22 ] - - - - - row_major_order == true - ----------------------- - a_11 - a_12 - a_21 - a_22 - - - row_major_order == false - ----------------------- - a_11 - a_12 - a_21 - a_22 - - - The @orw_major_order parameter ONLY affects the layout on the file, - and NOT the memory layout of the matrix. -*/ - - -static void __fscanf_and_set( matrix_type * matrix , int row , int col , FILE * stream) { - double value; - if (fscanf(stream , "%lg" , &value) == 1) - matrix_iset( matrix , row , col , value ); - else - util_abort("%s: reading of matrix failed at row:%d col:%d \n",__func__ , row , col); -} - - -void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * stream ) { - int row,col; - if (row_major_order) { - for (row = 0; row < matrix->columns; row++) { - for (col = 0; col < matrix->columns; col++) { - __fscanf_and_set( matrix , row , col ,stream); - } - } - } else { - for (row = 0; row < matrix->columns; row++) { - for (col = 0; col < matrix->columns; col++) { - __fscanf_and_set( matrix , row , col , stream); - } - } - } -} - - - -/*****************************************************************/ -/* Functions which manipulate one element in the matrix. */ - -static void matrix_assert_ij( const matrix_type * matrix , int i , int j) { - if ((i < 0) || (i >= matrix->rows) || (j < 0) || (j >= matrix->columns)) - util_abort("%s: (i,j) = (%d,%d) invalid. Matrix size: %d x %d \n",__func__ , i,j,matrix->rows , matrix->columns); -} - - -static void matrix_assert_equal_rows( const matrix_type * m1 , const matrix_type * m2) { - if (m1->rows != m2->rows) - util_abort("%s: size mismatch in binary matrix operation %d %d \n",__func__ , m1->rows , m2->rows); -} - - -static void matrix_assert_equal_columns( const matrix_type * m1 , const matrix_type * m2) { - if (m1->columns != m2->columns) - util_abort("%s: size mismatch in binary matrix operation %d %d \n",__func__ , m1->columns , m2->columns); -} - - -void matrix_iset(matrix_type * matrix , int i , int j, double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] = value; -} - - - -void matrix_iset_safe(matrix_type * matrix , int i , int j, double value) { - matrix_assert_ij( matrix , i , j ); - matrix_iset( matrix , i , j , value ); -} - - -double matrix_iget(const matrix_type * matrix , int i , int j) { - return matrix->data[ GET_INDEX(matrix , i, j) ]; -} - - -double matrix_iget_safe(const matrix_type * matrix , int i , int j) { - matrix_assert_ij( matrix , i , j ); - return matrix_iget( matrix , i , j ); -} - - -void matrix_iadd(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] += value; -} - - -void matrix_isub(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] -= value; -} - - -void matrix_imul(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] *= value; -} - - -/*****************************************************************/ -/* One scalar operating on all the elements in the matrix */ - -void matrix_set(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_iset(matrix , i , j , value); -} - - -void matrix_shift(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_iadd(matrix , i , j , value); -} - - -void matrix_scale(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_imul(matrix , i , j , value); -} - -/*****************************************************************/ -/* Functions working on rows & columns */ - -void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column) { - if ((row_offset + elements) <= matrix->rows) { - if (matrix->row_stride == 1) /* Memory is continous ... */ - memcpy( &matrix->data[ GET_INDEX( matrix , row_offset , column) ] , data , elements * sizeof * data); - else { - int i; - for (i = 0; i < elements; i++) - matrix->data[ row_offset + GET_INDEX( matrix , i , column) ] = data[i]; - } - } else - util_abort("%s: range violation \n" , __func__); -} - -void matrix_set_column(matrix_type * matrix , const double * data , int column) { - matrix_set_many_on_column( matrix , 0 , matrix->rows , data , column ); -} - - -void matrix_set_const_column(matrix_type * matrix , const double value , int column) { - int row; - for (row = 0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column) ] = value; -} - - -void matrix_set_const_row(matrix_type * matrix , const double value , int row) { - int column; - for (column = 0; column < matrix->columns; column++) - matrix->data[ GET_INDEX( matrix , row , column) ] = value; -} - - -void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int target_column, int src_column) { - matrix_assert_equal_rows( target_matrix , src_matrix ); - { - int row; - for(row = 0; row < target_matrix->rows; row++) - target_matrix->data[ GET_INDEX( target_matrix, row , target_column)] = src_matrix->data[ GET_INDEX( src_matrix, row, src_column)]; - } -} - - -void matrix_scale_column(matrix_type * matrix , int column , double scale_factor) { - int row; - for (row = 0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column) ] *= scale_factor; -} - -void matrix_scale_row(matrix_type * matrix , int row , double scale_factor) { - int column; - for (column = 0; column < matrix->columns; column++) - matrix->data[ GET_INDEX( matrix , row , column) ] *= scale_factor; -} - -void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row) { - matrix_assert_equal_columns( target_matrix , src_matrix ); - { - int col; - for(col = 0; col < target_matrix->columns; col++) - target_matrix->data[ GET_INDEX( target_matrix , target_row , col)] = src_matrix->data[ GET_INDEX( src_matrix, src_row, col)]; - } -} - - -/*****************************************************************/ -/* Functions for dot products between rows/columns in matrices. */ - -double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) { - if (m1->rows != m2->rows) - util_abort("%s: size mismatch \n",__func__); - - if (col1 >= m1->columns || col2 >= m2->columns) - util_abort("%s: size mismatch \n",__func__); - { - int row; - double sum = 0; - for( row = 0; row < m1->rows; row++) - sum += m1->data[ GET_INDEX(m1 , row , col1) ] * m2->data[ GET_INDEX(m2, row , col2) ]; - - return sum; - } -} - - -double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2) { - if (m1->columns != m2->rows) - util_abort("%s: size mismatch: m1:[%d,%d] m2:[%d,%d] \n",__func__ , matrix_get_rows( m1 ) , matrix_get_columns( m1 ) , matrix_get_rows( m2 ) , matrix_get_columns( m2 )); - - { - int k; - double sum = 0; - for( k = 0; k < m1->columns; k++) - sum += m1->data[ GET_INDEX(m1 , row1 , k) ] * m2->data[ GET_INDEX(m2, k , col2) ]; - - return sum; - } -} - - - - -/*****************************************************************/ -/* Matrix - matrix operations */ - - -/* Implements assignement: A = B */ -void matrix_assign(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - if (A->row_stride == B->row_stride) { - if (A->columns == A->row_stride) /** Memory is just one continous block */ - memcpy( A->data , B->data , A->rows * A->columns * sizeof * A->data); - else { - /* Copying columns of data */ - for (j = 0; j < A->columns; j++) - memcpy( &A->data[ GET_INDEX(A , 0 , j)] , &B->data[ GET_INDEX(B , 0 , j) ] , A->rows * sizeof * A->data); - } - } else { - /* Copying element by element */ - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ]; - } - } else - util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d] \n",__func__ , A->rows , A->columns , B->rows , B->columns); -} - - - -void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB) { - if ((A->rows == B->rows) && - (colA < A->columns) && - (colB < B->columns)) { - int row; - - for (row = 0; row < A->rows; row++) - A->data[ GET_INDEX(A , row , colA)] -= B->data[ GET_INDEX(B , row , colB)]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - -void matrix_inplace_add_column(matrix_type * A , const matrix_type * B, int colA , int colB) { - if ((A->rows == B->rows) && - (colA < A->columns) && - (colB < B->columns)) { - int row; - - for (row = 0; row < A->rows; row++) - A->data[ GET_INDEX(A , row , colA)] += B->data[ GET_INDEX(B , row , colB)]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - -/* Updates matrix A by adding in matrix B - elementwise. */ -void matrix_inplace_add(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] += B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/* Updates matrix A by multiplying in matrix B - elementwise - i.e. Schur product. */ -void matrix_inplace_mul(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] *= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/* - Schur product: A = B * C -*/ - -void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C) { - if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] * C->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - - -/* Updates matrix A by subtracting matrix B - elementwise. */ -void matrix_inplace_sub(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] -= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d]\n",__func__ , - matrix_get_rows(A), - matrix_get_columns(A), - matrix_get_rows(B), - matrix_get_columns(B)); -} - - -/* Does the matrix operation: - - A = B - C - - elementwise. -*/ -void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C) { - if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] - C->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - - - -/* Updates matrix A by dividing matrix B - elementwise. */ -void matrix_inplace_div(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] /= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/** - Observe that A and T should not overlap, i.e. the call - - matrix_transpose(X , X) - - will fail in mysterious ways. -*/ - -void matrix_transpose(const matrix_type * A , matrix_type * T) { - if ((A->columns == T->rows) && (A->rows == T->columns)) { - int i,j; - for (i=0; i < A->rows; i++) { - for (j=0; j < A->columns; j++) { - size_t src_index = GET_INDEX(A , i , j ); - size_t target_index = GET_INDEX(T , j , i ); - - T->data[ target_index ] = A->data[ src_index ]; - } - } - } else - util_abort("%s: size mismatch\n",__func__); -} - - -void matrix_inplace_transpose(matrix_type * A ) { - matrix_type * B = matrix_alloc_transpose( A ); - matrix_free_content( A ); - memcpy( A , B , sizeof * A ); - free( B ); -} - - - -matrix_type * matrix_alloc_transpose( const matrix_type * A) { - matrix_type * B = matrix_alloc( matrix_get_columns( A ) , matrix_get_rows( A )); - matrix_transpose( A , B ); - return B; -} - - - -/** - For this function to work the following must be satisfied: - - columns in A == rows in B == columns in B - - For general matrix multiplactions where A = B * C all have - different dimensions you can use matrix_matmul() (which calls the - BLAS routine dgemm()); -*/ - - -void matrix_inplace_matmul(matrix_type * A, const matrix_type * B) { - if ((A->columns == B->rows) && (B->rows == B->columns)) { - double * tmp = (double*)util_malloc( sizeof * A->data * A->columns ); - int i,j,k; - - for (i=0; i < A->rows; i++) { - - /* Clearing the tmp vector */ - for (k=0; k < B->rows; k++) - tmp[k] = 0; - - for (j=0; j < B->rows; j++) { - double scalar_product = 0; - for (k=0; k < A->columns; k++) - scalar_product += A->data[ GET_INDEX(A,i,k) ] * B->data[ GET_INDEX(B,k,j) ]; - - /* Assign first to tmp[j] */ - tmp[j] = scalar_product; - } - for (j=0; j < A->columns; j++) - A->data[ GET_INDEX(A , i, j) ] = tmp[j]; - } - free(tmp); - } else - util_abort("%s: size mismatch: A:[%d,%d] B:[%d,%d]\n",__func__ , matrix_get_rows(A) , matrix_get_columns(A) , matrix_get_rows(B) , matrix_get_columns(B)); -} - -/*****************************************************************/ -/* If the current build has a thread_pool implementation enabled a - proper matrix_implace_matmul_mt() function will be built, otherwise - only the serial version matrix_inplace_matmul() will be used. */ - - -#ifdef ERT_HAVE_THREAD_POOL - -static void * matrix_inplace_matmul_mt__(void * arg) { - - arg_pack_type * arg_pack = arg_pack_safe_cast( arg ); - int row_offset = arg_pack_iget_int( arg_pack , 0 ); - int rows = arg_pack_iget_int( arg_pack , 1 ); - matrix_type * A = (matrix_type*) arg_pack_iget_ptr( arg_pack , 2 ); - const matrix_type * B = (const matrix_type*)arg_pack_iget_const_ptr( arg_pack , 3 ); - - matrix_type * A_view = matrix_alloc_shared( A , row_offset , 0 , rows , matrix_get_columns( A )); - matrix_inplace_matmul( A_view , B ); - matrix_free( A_view ); - return NULL; -} - -/** - Observe that the calling scope is responsible for passing a - thread_pool in suitable state to this function. This implies one of - the following: - - 1. The thread_pool is newly created, with the @start_queue - argument set to false. - - 2. The thread_pool has been joined __without__ an interevening - call to thread_pool_restart(). - - If the thread_pool has not been correctly prepared, according to - this specification, it will be crash and burn. -*/ - -void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool){ - int num_threads = thread_pool_get_max_running( thread_pool ); - arg_pack_type ** arglist = (arg_pack_type**)util_malloc( num_threads * sizeof * arglist ); - int it; - thread_pool_restart( thread_pool ); - { - int rows = matrix_get_rows( A ) / num_threads; - int rows_mod = matrix_get_rows( A ) % num_threads; - int row_offset = 0; - - for (it = 0; it < num_threads; it++) { - int row_size; - arglist[it] = arg_pack_alloc(); - row_size = rows; - if (it < rows_mod) - row_size += 1; - - arg_pack_append_int(arglist[it] , row_offset ); - arg_pack_append_int(arglist[it] , row_size ); - arg_pack_append_ptr(arglist[it] , A ); - arg_pack_append_const_ptr(arglist[it] , B ); - - thread_pool_add_job( thread_pool , matrix_inplace_matmul_mt__ , arglist[it]); - row_offset += row_size; - } - } - thread_pool_join( thread_pool ); - - for (it = 0; it < num_threads; it++) - arg_pack_free( arglist[it] ); - free( arglist ); -} - -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ - thread_pool_type * thread_pool = thread_pool_alloc( num_threads , false ); - matrix_inplace_matmul_mt2( A , B , thread_pool ); - thread_pool_free( thread_pool ); -} - -#else - -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ - matrix_inplace_matmul( A , B ); -} - -#endif - - - - -/*****************************************************************/ -/* Row/column functions */ - -double matrix_get_row_sum(const matrix_type * matrix , int row) { - double sum = 0; - int j; - for (j=0; j < matrix->columns; j++) - sum += matrix->data[ GET_INDEX( matrix , row , j ) ]; - return sum; -} - - -double matrix_get_column_sum(const matrix_type * matrix , int column) { - double sum = 0; - int i; - for (i=0; i < matrix->rows; i++) - sum += matrix->data[ GET_INDEX( matrix , i , column ) ]; - return sum; -} - - -double matrix_get_column_abssum(const matrix_type * matrix , int column) { - double sum = 0; - int i; - for (i=0; i < matrix->rows; i++) - sum += fabs( matrix->data[ GET_INDEX( matrix , i , column ) ] ); - return sum; -} - - -double matrix_get_row_sum2(const matrix_type * matrix , int row) { - double sum2 = 0; - int j; - for ( j=0; j < matrix->columns; j++) { - double m = matrix->data[ GET_INDEX( matrix , row , j ) ]; - sum2 += m*m; - } - return sum2; -} - - -double matrix_get_row_abssum(const matrix_type * matrix , int row) { - double sum_abs = 0; - int j; - for ( j=0; j < matrix->columns; j++) { - double m = matrix->data[ GET_INDEX( matrix , row , j ) ]; - sum_abs += fabs( m ); - } - return sum_abs; -} - -/** - Return the sum of the squares on column. -*/ -double matrix_get_column_sum2(const matrix_type * matrix , int column) { - double sum2 = 0; - int i; - for ( i=0; i < matrix->rows; i++) { - double m = matrix->data[ GET_INDEX( matrix , i , column ) ]; - sum2 += m*m; - } - return sum2; -} - - - -void matrix_shift_column(matrix_type * matrix , int column, double shift) { - int i; - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX( matrix , i , column) ] += shift; -} - - -void matrix_shift_row(matrix_type * matrix , int row , double shift) { - int j; - for ( j=0; j < matrix->columns; j++) - matrix->data[ GET_INDEX( matrix , row , j ) ] += shift; -} - - - -/** - For each row in the matrix we will do the operation - - R -> R - -*/ - -void matrix_subtract_row_mean(matrix_type * matrix) { - int i; - for ( i=0; i < matrix->rows; i++) { - double row_mean = matrix_get_row_sum(matrix , i) / matrix->columns; - matrix_shift_row( matrix , i , -row_mean); - } -} - -void matrix_subtract_and_store_row_mean(matrix_type * matrix, matrix_type * row_mean) { - int i; - for ( i=0; i < matrix->rows; i++) { - double mean = matrix_get_row_sum(matrix , i) / matrix->columns; - matrix_shift_row( matrix , i , -mean); - matrix_iset(row_mean , i , 0, mean ); - } -} - -void matrix_imul_col( matrix_type * matrix , int column , double factor) { - int i; - for ( i=0; i < matrix->rows; i++) - matrix_imul( matrix , i , column , factor ); -} - - -/*****************************************************************/ -/** - This function will return the double data pointer of the matrix, - when you use this explicitly you ARE ON YOUR OWN. -*/ - -double * matrix_get_data(const matrix_type * matrix) { - return matrix->data; -} - -/** - The query functions below can be used to ask for the dimensions & - strides of the matrix. -*/ - -int matrix_get_rows(const matrix_type * matrix) { - return matrix->rows; -} - -int matrix_get_columns(const matrix_type * matrix) { - return matrix->columns; -} - -int matrix_get_row_stride(const matrix_type * matrix) { - return matrix->row_stride; -} - -int matrix_get_column_stride(const matrix_type * matrix) { - return matrix->column_stride; -} - - -void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , int * row_stride , int * column_stride) { - - *rows = matrix->rows; - *columns = matrix->columns; - *row_stride = matrix->row_stride; - *column_stride = matrix->column_stride; - -} - - -bool matrix_is_quadratic(const matrix_type * matrix) { - if (matrix->rows == matrix->columns) - return true; - else - return false; -} - -/** - Goes through all the elements in the matrix - and return true if they are all finite. -*/ - -#ifdef ERT_HAVE_ISFINITE - -bool matrix_is_finite(const matrix_type * matrix) { - int i,j; - for (i = 0; i < matrix->rows; i++) - for (j =0; j< matrix->columns; j++) - if ( !isfinite( matrix->data[ GET_INDEX( matrix , i , j) ])) { - printf("%s(%d,%d) = %g \n",matrix->name , i,j,matrix->data[ GET_INDEX( matrix , i , j) ]); - return false; - } - - return true; -} - -void matrix_assert_finite( const matrix_type * matrix ) { - if (!matrix_is_finite( matrix )) { - if ((matrix->rows * matrix->columns) < 400) - matrix_pretty_fprint( matrix , matrix->name , " %6.3f" , stdout); - - util_abort("%s: matrix:%s is not finite. \n",__func__ , matrix->name); - } -} - -#endif - - - -/** - This function will return the largest deviance from orthonormal - conditions for the matrix - i.e. when this function returns - 0.000000 the matrix is perfectly orthonormal; otherwise it is the - responsability of the calling scope to evaluate. -*/ - -double matrix_orthonormality( const matrix_type * matrix ) { - double max_dev = 0.0; - int col1,col2; - for (col1=0; col1 < matrix->columns; col1++) { - for (col2=col1; col2 < matrix->columns; col2++) { - double dot_product = matrix_column_column_dot_product( matrix , col1 , matrix , col2); - double dev; - - if (col1 == col2) - dev = fabs( dot_product - 1.0 ); - else - dev = fabs( dot_product ); - - if (dev > max_dev) - max_dev = dev; - } - } - return max_dev; -} - - - - - -/** - Return true if the two matrices m1 and m2 are equal. The equality - test is based on element-by-element memcmp() comparison, i.e. the - there is ZERO numerical tolerance in the comparison. - - If the two matrices do not have equal dimension false is returned. -*/ - -bool matrix_equal( const matrix_type * m1 , const matrix_type * m2) { - if (! ((m1->rows == m2->rows) && (m1->columns == m2->columns))) - return false; - { - int i,j; - for (i=0; i < m1->rows; i++) { - for (j=0; j < m1->columns; j++) { - int index1 = GET_INDEX(m1 , i , j); - int index2 = GET_INDEX(m2 , i , j); - double d1 = m1->data[ index1 ]; - double d2 = m2->data[ index2 ]; - - if (d1 != d2) - return false; - } - } - } - - /** OK - we came all the way through - they are equal. */ - return true; -} - - -bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) { - if (m1->rows != m2->rows) - return false; - - { - int row; - for (row=0; row < m1->rows; row++) { - if (memcmp( &m1->data[ GET_INDEX(m1 , row , col1)] , &m2->data[ GET_INDEX(m2 , row , col2)] , sizeof * m1->data) != 0) - return false; - } - } - - return true; -} - - -/*****************************************************************/ -/* Various special matrices */ - - -/** - Will set the diagonal elements in matrix to the values in diag, - and all remaining elements to zero. Assumes that matrix is - rectangular. -*/ - -void matrix_diag_set(matrix_type * matrix , const double * diag) { - if (matrix->rows == matrix->columns) { - int i; - matrix_set(matrix , 0); - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , i) ] = diag[i]; - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/** - Will set the scalar @value on all the diagonal elements of the - matrix; all off-diagonal elements are explicitly set to zero. -*/ - -void matrix_diag_set_scalar(matrix_type * matrix , double value) { - if (matrix->rows == matrix->columns) { - int i; - matrix_set(matrix , 0); - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , i) ] = value; - } else - util_abort("%s: size mismatch \n",__func__); -} - - -void matrix_scalar_set( matrix_type * matrix , double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , j) ] = value; -} - - - -/** - Fills the matrix with uniformly distributed random numbers in - [0,1). -*/ - -void matrix_random_init(matrix_type * matrix , rng_type * rng) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , j) ] = rng_get_double( rng ); -} - - - -void matrix_clear( matrix_type * matrix ) { - matrix_set( matrix , 0 ); -} - - - -/** - This function dumps the following binary file: - - rows - columns - data(1,1) - data(2,1) - data(3,1) - .... - data(1,2) - data(2,2) - .... - - Not exactly a matlab format. - - The following matlab code can be used to instatiate a matrix based - on the file: - - function m = load_matrix(filename) - fid = fopen(filename); - dims = fread(fid , 2 , 'int32'); - m = fread(fid , [dims(1) , dims(2)] , 'double'); - fclose(fid); - - - >> A = load_matrix( 'filename' ); -*/ - - -void matrix_matlab_dump(const matrix_type * matrix, const char * filename) { - FILE * stream = util_fopen( filename , "w"); - int i,j; - util_fwrite_int( matrix->rows , stream); - util_fwrite_int( matrix->columns , stream); - - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - util_fwrite_double( matrix->data[ GET_INDEX(matrix , i , j) ] , stream); - - fclose(stream); -} - - -// Comment -void matrix_inplace_diag_sqrt(matrix_type *Cd) -{ - int nrows = Cd->rows; - - if (Cd->rows != Cd->columns) { - util_abort("%s: size mismatch \n",__func__); - } - else{ - int i; - for ( i=0; idata[GET_INDEX(Cd , i , i)] = sqrt(Cd->data[GET_INDEX(Cd , i , i)]); - } - } -} - - - -double matrix_trace(const matrix_type *matrix) { - - int nrows = matrix->rows; - double sum = 0; - - if (matrix->rows != matrix->columns) { - util_abort("%s: matrix is not square \n",__func__); - } - else{ - int i; - for ( i=0; idata[GET_INDEX(matrix , i , i)]; - } - } - return sum; -} - - -bool matrix_check_dims( const matrix_type * m , int rows , int columns) { - if (m) { - if ((m->rows == rows) && (m->columns == columns)) - return true; - else - return false; - } else { - util_abort("%s: internal error - trying to dereference NULL matrix pointer \n",__func__); - return false; - } -} - - -double matrix_diag_std(const matrix_type * Sk,double mean) -{ - - if (Sk->rows != Sk->columns) { - util_abort("%s: matrix is not square \n",__func__); - return 0; - } - else{ - int nrows = Sk->rows; - double std = 0; - int i; - - for ( i=0; idata[GET_INDEX(Sk , i , i)] - mean; - std += d*d; - } - - - std = sqrt(std / nrows); - return std; - } -} - -/** - The matrix_det3() and matrix_det4() are explicit implementations of - the determinant of a 3x3 and 4x4 matrices. The ecl_grid class uses - these determinants determine whether a point is inside a cell. By - using this explicit implementation the ecl_grid library has no - LAPACK dependency. -*/ - -double matrix_det2( const matrix_type * A) { - if ((A->rows == 2) && (A->columns == 2)) { - double a00 = A->data[GET_INDEX(A,0,0)]; - double a01 = A->data[GET_INDEX(A,0,1)]; - double a10 = A->data[GET_INDEX(A,1,0)]; - double a11 = A->data[GET_INDEX(A,1,1)]; - - return a00 * a11 - a10 * a01; - } else { - util_abort("%s: hardcoded for 2x2 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - -double matrix_det3( const matrix_type * A) { - if ((A->rows == 3) && (A->columns == 3)) { - double a = A->data[GET_INDEX(A,0,0)]; - double b = A->data[GET_INDEX(A,0,1)]; - double c = A->data[GET_INDEX(A,0,2)]; - - double d = A->data[GET_INDEX(A,1,0)]; - double e = A->data[GET_INDEX(A,1,1)]; - double f = A->data[GET_INDEX(A,1,2)]; - - double g = A->data[GET_INDEX(A,2,0)]; - double h = A->data[GET_INDEX(A,2,1)]; - double i = A->data[GET_INDEX(A,2,2)]; - - return a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h; - } else { - util_abort("%s: hardcoded for 3x3 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - - -double matrix_det4( const matrix_type * A) { - if ((A->rows == 4) && (A->columns == 4)) { - double a00 = A->data[GET_INDEX(A,0,0)]; - double a01 = A->data[GET_INDEX(A,0,1)]; - double a02 = A->data[GET_INDEX(A,0,2)]; - double a03 = A->data[GET_INDEX(A,0,3)]; - double a10 = A->data[GET_INDEX(A,1,0)]; - double a11 = A->data[GET_INDEX(A,1,1)]; - double a12 = A->data[GET_INDEX(A,1,2)]; - double a13 = A->data[GET_INDEX(A,1,3)]; - double a20 = A->data[GET_INDEX(A,2,0)]; - double a21 = A->data[GET_INDEX(A,2,1)]; - double a22 = A->data[GET_INDEX(A,2,2)]; - double a23 = A->data[GET_INDEX(A,2,3)]; - double a30 = A->data[GET_INDEX(A,3,0)]; - double a31 = A->data[GET_INDEX(A,3,1)]; - double a32 = A->data[GET_INDEX(A,3,2)]; - double a33 = A->data[GET_INDEX(A,3,3)]; - - /* - double det = (a00*(a11*(a22*a33 - a23*a32)-a12*(a21*a33 - a23*a31)+a13*(a21*a32 - a22*a31)) - - a01*(a10*(a22*a33 - a23*a32)-a12*(a20*a33 - a23*a30)+a13*(a20*a32 - a22*a30)) + - a02*(a10*(a21*a33 - a23*a31)-a11*(a20*a33 - a23*a30)+a13*(a20*a31 - a21*a30)) - - a03*(a10*(a21*a32 - a22*a31)-a11*(a20*a32 - a22*a30)+a12*(a20*a31 - a21*a30))); - */ - double det = 0; - - { - double factors[24] = { a00*a12*a23*a31, - a00*a13*a21*a32, - a00*a11*a22*a33, - a01*a10*a23*a32, - a01*a12*a20*a33, - a01*a13*a22*a30, - a02*a10*a21*a33, - a02*a11*a23*a30, - a02*a13*a20*a31, - a03*a10*a22*a31, - a03*a11*a20*a32, - a03*a12*a21*a30 - -a02*a13*a21*a30, - -a03*a10*a21*a32, - -a03*a11*a22*a30, - -a03*a12*a20*a31, - -a00*a11*a23*a32, - -a00*a12*a21*a33, - -a00*a13*a22*a31, - -a01*a10*a22*a33, - -a01*a12*a23*a30, - -a01*a13*a20*a32, - -a02*a10*a23*a31, - -a02*a11*a20*a33}; - int i; - - for (i = 0; i < 12; i++) - det += (factors[i] + factors[i + 12]); - } - - return det; - } else { - util_abort("%s: hardcoded for 4x4 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - - -#ifdef __cplusplus -} -#endif diff --git a/ThirdParty/Ert/lib/util/matrix_blas.c b/ThirdParty/Ert/lib/util/matrix_blas.c deleted file mode 100644 index 2ac5438433..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_blas.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************/ -void dgemm_(char * , char * , int * , int * , int * , double * , double * , int * , double * , int * , double * , double * , int *); -void dgemv_(char * , int * , int * , double * , double * , int * , const double * , int * , double * , double * , int * ); -/*****************************************************************/ - - - -/** - y = alpha * op(A)*x + beta * y - - alpha,beta: scalars - x,y : vectors - A : matrix - - - x and y are entered as (double * ). -*/ - - -void matrix_dgemv(const matrix_type * A , const double *x , double * y, bool transA , double alpha , double beta) { - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - int lda = matrix_get_column_stride( A ); - int incx = 1; - int incy = 1; - - char transA_c; - if (transA) - transA_c = 'T'; - else - transA_c = 'N'; - - dgemv_(&transA_c , &m , &n , &alpha , matrix_get_data( A ) , &lda , x , &incx , &beta , y , &incy); -} - - -/** - y = A*x -*/ - -void matrix_mul_vector(const matrix_type * A , const double * x , double * y) { - matrix_dgemv(A , x , y , false , 1 , 0); -} - - - -static void dgemm_debug(const matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB) { - printf("\nC = [%d , %d]\n",matrix_get_rows( C ) , matrix_get_columns(C)); - - printf("A: [%d , %d]", matrix_get_rows( A ) , matrix_get_columns(A)); - if (transA) - printf("^T"); - - printf("\nB: [%d , %d]", matrix_get_rows( B ) , matrix_get_columns(B)); - if (transB) - printf("^T"); - - printf("\n\n"); - printf("[%d ,%d] = ",matrix_get_rows( C ) , matrix_get_columns(C)); - if (transA) - printf("[%d ,%d] x ",matrix_get_rows( A ) , matrix_get_columns(A)); - else - printf("[%d ,%d] x ",matrix_get_columns( A ) , matrix_get_rows(A)); - - - if (transB) - printf("[%d ,%d]\n",matrix_get_rows( B ) , matrix_get_columns(B)); - else - printf("[%d ,%d]\n",matrix_get_columns( B ) , matrix_get_rows(B)); - - -} - - - -/** - C = alpha * op(A) * op(B) + beta * C - - op(·) can either be unity or Transpose. -*/ - -void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB , double alpha , double beta) { - int m = matrix_get_rows( C ); - int n = matrix_get_columns( C ); - int lda = matrix_get_column_stride( A ); - int ldb = matrix_get_column_stride( B ); - int ldc = matrix_get_column_stride( C ); - char transA_c; - char transB_c; - int k , innerA, innerB , outerA , outerB; - - if (transA) - k = matrix_get_rows( A ); - else - k = matrix_get_columns( A ); - - - if (transA) { - innerA = matrix_get_rows(A); - outerA = matrix_get_columns(A); - transA_c = 'T'; - } else { - innerA = matrix_get_columns(A); - outerA = matrix_get_rows(A); - transA_c = 'N'; - } - - - if (transB) { - innerB = matrix_get_columns( B ); - outerB = matrix_get_rows( B ); - transB_c = 'T'; - } else { - transB_c = 'N'; - innerB = matrix_get_rows( B ); - outerB = matrix_get_columns( B ); - } - - /* - This is the dimension check which must pass: - - -------------------------------------------------- - A | B | Columns(A) = Rows(B) - Trans(A) | Trans(B) | Rows(A) = Columns(B) - A | Trans(B) | Columns(A) = Columns(B) - Trans(A) | B | Rows(A) = Rows(B) - -------------------------------------------------- - - -------------------------------------------------- - A | Rows(A) = Rows(C) - Trans(A) | Columns(A) = Rows(C) - B | Columns(B) = Columns(C) - Trans(B) | Rows(B) = Columns(B) - -------------------------------------------------- - - */ - - if (innerA != innerB) { - dgemm_debug(C,A,B,transA , transB); - util_abort("%s: matrix size mismatch between A and B \n", __func__); - } - - - if (outerA != matrix_get_rows( C )) { - dgemm_debug(C,A,B,transA , transB); - printf("outerA:%d rows(C):%d \n",outerA , matrix_get_rows( C )); - util_abort("%s: matrix size mismatch between A and C \n",__func__); - } - - - if (outerB != matrix_get_columns( C )) { - dgemm_debug(C,A,B,transA , transB); - util_abort("%s: matrix size mismatch between B and C \n",__func__); - } - - if (ldc < util_int_max(1 , m)) { - dgemm_debug(C,A,B,transA , transB); - fprintf(stderr,"Tried to capture blas message: \"** On entry to DGEMM parameter 13 had an illegal value\"\n"); - fprintf(stderr,"m:%d ldc:%d ldc should be >= max(1,%d) \n",m,ldc,m); - util_abort("%s: invalid value for ldc\n",__func__); - } - - - dgemm_(&transA_c , // 1 - &transB_c , // 2 - &m , // 3 - &n , // 4 - &k , // 5 - &alpha , // 6 - matrix_get_data( A ) , // 7 - &lda , // 8 - matrix_get_data( B ) , // 9 - &ldb , // 10 - &beta , // 11 - matrix_get_data( C ) , // 12 - &ldc); // 13 -} - - - -void matrix_matmul_with_transpose(matrix_type * C, const matrix_type * A , const matrix_type * B , bool transA , bool transB) { - matrix_dgemm( C , A , B , transA , transB , 1 , 0); -} - - -/* - This function does a general matrix multiply of A * B, and stores - the result in C. -*/ - -void matrix_matmul(matrix_type * C, const matrix_type * A , const matrix_type * B) { - matrix_dgemm( C , A , B , false , false , 1 , 0); -} - - -/** - Allocates new matrix C = A·B -*/ - -matrix_type * matrix_alloc_matmul(const matrix_type * A, const matrix_type * B) { - matrix_type * C = matrix_alloc( matrix_get_rows( A ) , matrix_get_columns( B )); - matrix_matmul( C , A , B ); - return C; -} - - - - - -/*****************************************************************/ -/** - Will calculate the Gram matrix: G = X'*X -*/ - -void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col) { - int G_rows = matrix_get_rows( G ); - int G_cols = matrix_get_columns( G ); - int X_rows = matrix_get_rows( X ); - int X_cols = matrix_get_columns( X ); - if (col) { - // Calculate X' · X - if ((G_rows == G_cols) && (X_cols == G_rows)) - matrix_dgemm( G , X , X , true , false , 1 , 0); - else - util_abort("%s: dimension mismatch \n",__func__); - } else { - // Calculate X · X' - if ((G_rows == G_cols) && (X_rows == G_rows)) - matrix_dgemm( G , X , X , false , true , 1 , 0); - else - util_abort("%s: dimension mismatch \n",__func__); - } -} - - -/** - If col == true: G = X' · X - col == false: G = X · X' -*/ - - -matrix_type * matrix_alloc_gram( const matrix_type * X , bool col) { - int X_rows = matrix_get_rows( X ); - int X_columns = matrix_get_columns( X ); - matrix_type * G; - - if (col) - G = matrix_alloc( X_columns , X_columns ); - else - G = matrix_alloc( X_rows , X_rows ); - - matrix_gram_set( X , G , col); - return G; -} - -#ifdef __cplusplus -} -#endif diff --git a/ThirdParty/Ert/lib/util/matrix_lapack.c b/ThirdParty/Ert/lib/util/matrix_lapack.c deleted file mode 100644 index 2a62b0fcbd..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_lapack.c +++ /dev/null @@ -1,640 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - The external lapack routines -*/ -/*****************************************************************/ -void dgesv_(int * n, - int * nrhs, - double * A, - int * lda, - long int * ipivot, - double * B, - int * ldb, - int * info); -void dgesvd_(char * jobu, - char * jobvt, - int * m, - int * n, - double * A, - int * lda, - double * S, - double * U, - int * ldu, - double * VT, - int * ldvt, - double * work, - int * worksize, - int * info); -void dsyevx_(char * jobz, - char * range, - char * uplo, - int *n, - double * A, - int * lda, - double * vl, - double * vu, - int * il, - int * iu, - double * abstol, - int * m, - double * w, - double *z, - int * ldz, - double * work, - int * lwork, - int * iwork, - int * ifail, - int * info); -void dgeqrf_(int * m, - int * n, - double * A, - int * lda, - double * tau, - double * work, - int * lwork, - int * info); -void dorgqr_(int * m, - int * n, - int * k, - double * A, - int * lda, - double * tau, - double * work, - int * lwork, - int * info); -void dgetrf_(int * M, - int * n, - double * A, - int * lda, - int * ipiv, - int * info); -void dgedi_(double * A, - int * lda, - int * n, - int * ipiv, - double * det, - double * work, - int * job); -void dgetri_(int * n, - double * A, - int * lda, - int * ipiv, - double * work, - int * work_size, - int * info); -/*****************************************************************/ - - - - - - -/** - This file implements (very thin) interfaces for the matrix_type to - some lapack functions. The file does not contain any data - structures, only functions. -*/ - - - -static void matrix_lapack_assert_fortran_layout( const matrix_type * matrix ) { - int rows, columns, row_stride , column_stride; - matrix_get_dims( matrix , &rows , &columns , &row_stride , &column_stride); - if (!( (column_stride >= rows) && (row_stride == 1))) - util_abort("%s: lapack routines require Fortran layout of memory - aborting \n",__func__); -} - - -static void matrix_lapack_assert_square(const matrix_type * matrix) { - matrix_lapack_assert_fortran_layout(matrix ); - { - int rows, columns, row_stride , column_stride; - matrix_get_dims( matrix , &rows , &columns , &row_stride , &column_stride); - if (rows != columns) - util_abort("%s: must have square matrices \n",__func__); - } -} - - -/*****************************************************************/ -/** - Solves the linear equations Ax = B. The solution is stored in B on - return. -*/ - - -void matrix_dgesv(matrix_type * A , matrix_type * B) { - matrix_lapack_assert_square( A ); - matrix_lapack_assert_fortran_layout( B ); - { - int n = matrix_get_rows( A ); - int lda = matrix_get_column_stride( A ); - int ldb = matrix_get_column_stride( B ); - int nrhs = matrix_get_columns( B ); - long int * ipivot = (long int*)util_calloc( n , sizeof * ipivot ); - int info; - - dgesv_(&n , &nrhs , matrix_get_data( A ) , &lda , ipivot , matrix_get_data( B ), &ldb , &info); - if (info != 0) - util_abort("%s: low level lapack routine: dgesv() failed with info:%d \n",__func__ , info); - free(ipivot); - } -} - - -/*****************************************************************/ -/** - Singular Value Decomposition -*/ - - -/** - This little function translates between an integer identifier - (i.e. and enum instance) to one of the characters used by the low - level lapack routine to indicate how the singular vectors should be - returned to the calling scope. - - The meaning of the different enum values is documented in the enum - definition in the header file matrix_lapack.h. -*/ - -static char dgesvd_get_vector_job( dgesvd_vector_enum vector_job) { - char job = 'X'; - switch (vector_job) { - case(DGESVD_ALL): - job = 'A'; - break; - case(DGESVD_MIN_RETURN): - job = 'S'; - break; - case(DGESVD_MIN_OVERWRITE): - job = 'O'; - break; - case(DGESVD_NONE): - job = 'N'; - break; - default: - util_abort("%s: internal error - unrecognized code:%d \n",vector_job); - } - return job; -} - - - -/** - If jobu == DGSEVD_NONE the U matrix can be NULL, same for jobvt. -*/ - -void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_type * A , double * S , matrix_type * U , matrix_type * VT) { - char _jobu = dgesvd_get_vector_job( jobu ); - char _jobvt = dgesvd_get_vector_job( jobvt ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - int lda = matrix_get_column_stride( A ); - int ldu, ldvt; - double * VT_data , *U_data; - int info = 0; - int min_worksize = util_int_max(3* util_int_min(m , n) + util_int_max(m , n) , 5 * util_int_min(m , n)); - double * work; - int worksize; - - - if (U == NULL) { - ldu = 1; - U_data = NULL; - if (jobu != DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } else { - ldu = matrix_get_column_stride( U ); - U_data = matrix_get_data( U ); - if (jobu == DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } - - if (VT == NULL) { - ldvt = 1; /* Will fail if set to zero */ - VT_data = NULL; - if (jobvt != DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } else { - ldvt = matrix_get_column_stride( VT ); - VT_data = matrix_get_data( VT ); - if (jobvt == DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } - - /* - Query the routine for optimal worksize. - */ - - work = (double*)util_calloc( 1 , sizeof * work ); - worksize = -1; - dgesvd_(&_jobu , /* 1 */ - &_jobvt , /* 2 */ - &m , /* 3 */ - &n , /* 4 */ - matrix_get_data( A ) , /* 5 */ - &lda , /* 6 */ - S , /* 7 */ - U_data , /* 8 */ - &ldu , /* 9 */ - VT_data , /* 10 */ - &ldvt , /* 11 */ - work , /* 12 */ - &worksize , /* 13 */ - &info); /* 14 */ - - - /* Try to allocate optimal worksize. */ - worksize = (int) work[0]; - double * tmp = (double*)realloc( work , sizeof * work * worksize ); - if (tmp == NULL) { - /* Could not allocate optimal worksize - settle for the minimum. This can not fail. */ - worksize = min_worksize; - free(work); - work = (double*)util_calloc( worksize , sizeof * work ); - }else{ - work = tmp; /* The request for optimal worksize succeeded */ - } - - dgesvd_(&_jobu , &_jobvt , &m , &n , matrix_get_data( A ) , &lda , S , U_data , &ldu , VT_data , &ldvt , work , &worksize , &info); - free( work ); -} - - - -/******************************************************************/ -/* Eigenvalues of a symmetric matrix */ -/* Return value is the number of eigenvalues found. */ -/******************************************************************/ - -int matrix_dsyevx(bool compute_eig_vectors , - dsyevx_eig_enum which_values , /* DSYEVX | DSYEVX_VALUE_INTERVAL | DSYEVX_INDEX_INTERVAL */ - dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ - double VL , /* Lower limit when using DSYEVX_VALUE_INTERVAL */ - double VU , /* Upper limit when using DSYEVX_VALUE_INTERVAL */ - int IL , /* Lower index when using DSYEVX_INDEX_INTERVAL */ - int IU , /* Upper index when using DSYEVX_INDEX_INTERVAL */ - double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ - - int lda = matrix_get_column_stride( A ); - int n = matrix_get_rows( A ); - char jobz; - char range; - char uplo_c; - - if (compute_eig_vectors) - jobz = 'V'; - else - jobz = 'N'; - - switch(which_values) { - case(DSYEVX_ALL): - range = 'A'; - break; - case(DSYEVX_VALUE_INTERVAL): - range = 'V'; - break; - case(DSYEVX_INDEX_INTERVAL): - range = 'I'; - break; - default: - util_abort("%s: internal error \n",__func__); - } - - if (uplo == DSYEVX_AUPPER) - uplo_c = 'U'; - else if (uplo == DSYEVX_ALOWER) - uplo_c = 'L'; - else - util_abort("%s: internal error \n",__func__); - - - if (!matrix_is_quadratic( A )) - util_abort("%s: matrix A must be quadratic \n",__func__); - - { - int num_eigenvalues , ldz, info , worksize; - int * ifail = (int*) util_calloc( n , sizeof * ifail ); - int * iwork = (int*) util_calloc( 5 * n , sizeof * iwork ); - double * work = (double*)util_calloc( 1 , sizeof * work ); - double * z_data; - double abstol = 0.0; /* SHopuld */ - - - if (compute_eig_vectors) { - ldz = matrix_get_column_stride( Z ); - z_data = matrix_get_data( Z ); - } else { - /* In this case we can accept that Z == NULL */ - ldz = 1; - z_data = NULL; - } - - /* First call to determine optimal worksize. */ - worksize = -1; - info = 0; - dsyevx_( &jobz, /* 1 */ - &range, /* 2 */ - &uplo_c, /* 3 */ - &n, /* 4 */ - matrix_get_data( A ), /* 5 */ - &lda , /* 6 */ - &VL , /* 7 */ - &VU , /* 8 */ - &IL , /* 9 */ - &IU , /* 10 */ - &abstol , /* 11 */ - &num_eigenvalues , /* 12 */ - eig_values , /* 13 */ - z_data , /* 14 */ - &ldz , /* 15 */ - work , /* 16 */ - &worksize , /* 17 */ - iwork , /* 18 */ - ifail , /* 19 */ - &info); /* 20 */ - - - worksize = (int) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = 8 * n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - /* Second call: do the job */ - info = 0; - dsyevx_( &jobz, - &range, - &uplo_c, - &n, - matrix_get_data( A ), - &lda , - &VL , - &VU , - &IL , - &IU , - &abstol , - &num_eigenvalues , - eig_values , - z_data , - &ldz , - work , - &worksize , - iwork , - ifail , - &info); - - free( ifail ); - free( work ); - free( iwork ); - return num_eigenvalues; - } -} - - -/** - Wrapper function to compute all eigenvalues + eigenvectors with the - matrix_dsyevx() function. -*/ - -int matrix_dsyevx_all(dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ - double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ - int num_eigenvalues; - num_eigenvalues = matrix_dsyevx(true , DSYEVX_ALL , uplo , A , 0,0,0,0, eig_values , Z); - return num_eigenvalues; - -} - - - -/*****************************************************************/ -/* Function to compute QR factorization withe the routine dgeqrf */ - -void matrix_dgeqrf(matrix_type * A , double * tau) { - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - double * work = (double*)util_calloc(1 , sizeof * work ); - int worksize; - int info; - - - /* Determine optimal worksize. */ - worksize = -1; - dgeqrf_(&m , &n , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dgerqf routine failed with info:%d \n",__func__ , info); - worksize = ( int ) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - - - /* Second call - do the actual computation. */ - dgeqrf_(&m , &n , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dgerqf routine failed with info:%d \n",__func__ , info); - free( work ); -} - - -/** - Typically to be used after the matrix_dgeqrf() function to construct a orthormal matrix. -*/ - -void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num_reflectors == length of tau. */ - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - double * work = (double*)util_malloc(sizeof * work ); - int worksize; - int info; - - - /* Determine optimal worksize. */ - worksize = -1; - dorgqr_(&m , &n , &num_reflectors , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dorgqf routine failed with info:%d \n",__func__ , info); - worksize = ( int ) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - - - /* Second call - do the actual computation. */ - dorgqr_(&m , &n , &num_reflectors , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dorqf routine failed with info:%d \n",__func__ , info); - free( work ); -} - -/*****************************************************************/ - -/*****************************************************************/ -/* Factorization */ - -/* Currently only used as 'support' function for the matrix_det function. */ -static void matrix_dgetrf__( matrix_type * A, int * ipiv, int * info) { - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - - dgetrf_( &m , &n , matrix_get_data( A ) , &lda , ipiv , info); -} - - -/** - Calculated the determinant of A. The matrix content will be - destroyed. -*/ - -double matrix_det( matrix_type *A ) { - matrix_lapack_assert_square( A ); - { - - int dgetrf_info; - double det = 1; - double det_scale = 0; - int n = matrix_get_columns( A ); - int * ipiv = (int*)util_malloc( n * sizeof * ipiv ); - matrix_dgetrf__( A , ipiv , &dgetrf_info ); - { - int i; - for (i=0; i < n; i++) { - det *= matrix_iget(A , i , i); - if (det == 0) return 0; /* Holy fuck - a float == comparison ?? */ - - if (ipiv[i] != (i + 1)) /* A permutation has taken place. */ - det *= -1; - - - /* Try to avoid overflow/underflow by factoring out the order of magnitude. */ - while (fabs(det) > 10.0) { - det /= 10; - det_scale += 1; - } - - while (fabs(det) < 1.0) { - det *= 10; - det_scale -= 1; - } - } - } - - free( ipiv ); - return det * pow(10 , det_scale ); - } -} - - - - - -/*****************************************************************/ -/* The matrix will be inverted in-place, the inversion is based on LU - factorisation in the routine matrix_dgetrf__( ). - - The return value: - - =0 : Success - >0 : Singular matrix - <0 : Invalid input -*/ - - - - -int matrix_inv( matrix_type * A ) { - matrix_lapack_assert_square( A ); - { - int dgetrf_info; - int info; - int n = matrix_get_columns( A ); - int * ipiv = (int*)util_malloc( n * sizeof * ipiv ); - matrix_dgetrf__( A , ipiv , &dgetrf_info ); - { - int lda = matrix_get_column_stride( A ); - double * work = (double*)util_malloc( sizeof * work ); - int work_size; - - /* First call: determine optimal worksize: */ - work_size = -1; - dgetri_( &n , matrix_get_data( A ), &lda , ipiv , work , &work_size , &info); - - if (info == 0) { - work_size = (int) work[0]; - work = (double*)util_realloc( work , sizeof * work * work_size ); - dgetri_( &n , matrix_get_data( A ), &lda , ipiv , work , &work_size , &info); - } else - util_abort("%s: dgetri_ returned info:%d \n",__func__ , info); - - free( work ); - } - free( ipiv ); - return info; - } -} - - -#ifdef __cplusplus -} -#endif - diff --git a/ThirdParty/Ert/lib/util/matrix_stat.c b/ThirdParty/Ert/lib/util/matrix_stat.c deleted file mode 100644 index d8b47300f5..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_stat.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { - if (matrix_get_rows( beta ) != matrix_get_columns( X0 )) - return LLSQ_INVALID_DIM; - - if (matrix_get_rows( X0 ) != matrix_get_rows( Y0 )) - return LLSQ_INVALID_DIM; - - if (S && matrix_get_rows( S ) != matrix_get_rows( Y0 )) - return LLSQ_INVALID_DIM; - - if (matrix_get_rows(beta) > matrix_get_rows( X0 )) - return LLSQ_UNDETERMINED; - - { - int num_data = matrix_get_rows( X0 ); - int num_var = matrix_get_columns( X0 ); - matrix_type * XX = matrix_alloc( num_var , num_var ); - matrix_type * A = matrix_alloc( num_var , num_data ); - - matrix_type * X,*Y; - - if (S == NULL) { - X = (matrix_type *) X0; - Y = (matrix_type *) Y0; - } else { - X = matrix_alloc_copy( X0 ); - Y = matrix_alloc_copy( Y0 ); - - { - int row,col; - for (row = 0; row < matrix_get_rows( X0 ); row++) { - double sigma = matrix_iget(S , row , 0); - double weigth = 1.0 / (sigma * sigma ); - - for (col = 0; col < matrix_get_columns( X0 ); col++) - matrix_imul( X , row , col , weigth ); - - matrix_imul( Y , row , col , weigth ); - } - } - } - - matrix_matmul_with_transpose( XX , X , X , true , false ); - matrix_inv( XX ); - matrix_matmul_with_transpose( A , XX , X , false , true ); - matrix_matmul(beta , A , Y); - - matrix_free( XX ); - matrix_free( A ); - if (S) { - matrix_free( X ); - matrix_free( Y ); - } - } - - return LLSQ_SUCCESS; -} - - - - -llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { - int num_data = matrix_get_rows( X0 ); - int num_var = matrix_get_rows( beta ); - llsq_result_enum result; - matrix_type * X = matrix_alloc( num_data , num_var ); - int row,col; - - for (row = 0; row < matrix_get_rows( X0 ); row++) { - double x1 = matrix_iget( X0 , row , 0 ); - double xp = 1; - for (col = 0; col < num_var; col++) { - matrix_iset(X , row , col , xp); - xp *= x1; - } - } - - result = matrix_stat_llsq_estimate( beta , X , Y0 , S); - matrix_free( X ); - return result; -} - diff --git a/ThirdParty/Ert/lib/util/menu.c b/ThirdParty/Ert/lib/util/menu.c deleted file mode 100644 index f2b791045b..0000000000 --- a/ThirdParty/Ert/lib/util/menu.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'menu.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include - -#include -#include -#include - -/** - This file implements a simple character based menu system. The menu - consists of a list of items, where each item has a description, a - function to call, an argument to send to this function, and a set - of keys which will invoke this function. - - - Example: - - menu_type * menu = menu_alloc("Tittel paa menyen" , "qQ"); - menu_add_item(menu , "Alternativ 1" , "1aA" , func1 , arg1); - menu_add_item(menu , "Alternativ 2" , 2Bb" , func2 , arg2); - menu_run(menu); - menu_free(menu); - - In this case we will get a menu looking like this: - - - Tittel paa menyen - 1: Alternativ 1 - 2: Alternativ 2 - q: Quit - ==> __ - - Now typing '1' will invoke the function func1() with argument - arg1. In addition the characters 'a' and 'A' can also be used to - invoke the same function. Function func2(arg2) is invoked with '2', - 'b' or 'B'; finally the menu is exited with 'q' or 'Q' (the - arguments to the alloc call). - - - Observe that (in the current implementation) only single characters - are allowed as activator keys for the various items. I.e. 'save' to - save is not an option' -*/ - - - - - -struct menu_item_struct { - bool separator; /* If this is a separator - in that case all the following fields are moot. */ - bool helptext; /* If this is help text - Only label is present */ - char * key_set; /* The characters which will activate this item , e.g. "sS" - must be a \0 terminated string */ - char * label; /* The label/description of this menu item */ - menu_func_type * func; /* The function called when this item is activated. */ - void * arg; /* The argument passed to func. */ - int label_length; /* The length of the label - zero for separators. */ - arg_free_ftype * free_arg; /* Destructor for the argument - will typically be NULL */ - bool enabled; -}; - - - - -struct menu_struct { - vector_type * items; /* Vector of menu_item_type instances */ - char * quit_keys; /* The keys which can be used to quit from this menu - typically "qQ" */ - char * title; /* The title of this menu */ - char * quit_label; /* The text printed on the back/quit item at the bottom. */ - char * complete_key_set; /* A string containing all the allowed characters - to validata input */ -}; - - - -/** - Free's the menu occupied by one menu item. -*/ -static void menu_item_free(menu_item_type * item) { - if (!item->separator) { - free(item->label); - } - if (!item->separator && !item->helptext){ - free(item->key_set); - } - - - if (item->free_arg != NULL) - item->free_arg(item->arg); - - free(item); -} - -static void menu_item_free__(void * arg) { - menu_item_free( (menu_item_type *) arg ); -} - - - -/** - This function returns true if the first argument contains _any_ of the characters in - the second argument. It is implemented by repeated calss to strchr(); -*/ - -static bool __string_contains(const char * string , const char * char_set) { - bool contains = false; - int i = 0; - do { - if (strchr(string , char_set[i]) != NULL) - contains = true; - i++; - } while (!contains && i < strlen(char_set)); - return contains; -} - - - -/** - This function allocates an empty menu, with title 'title'. This - particular menu will exit when one the keys in quit_keys is - entered. */ - - -menu_type * menu_alloc(const char * title , const char * quit_label , const char * quit_keys) { - menu_type * menu = (menu_type*)util_malloc(sizeof * menu ); - - menu->title = util_alloc_sprintf_escape( title , 0 ); - menu->quit_keys = util_alloc_string_copy( quit_keys ); - menu->items = vector_alloc_new(); - menu->complete_key_set = util_alloc_string_copy( quit_keys ); - menu->quit_label = util_alloc_string_copy( quit_label ); - - return menu; -} - -static menu_item_type * menu_item_alloc_empty() { - menu_item_type * item = (menu_item_type*)util_malloc(sizeof * item ); - - item->label = NULL; - item->key_set = NULL; - item->func = NULL; - item->arg = NULL; - item->separator = false; - item->helptext = false; - item->label_length = 0; - item->free_arg = NULL; - item->enabled = true; - - return item; -} - - -/** - Low level function doing the actual append of a complete item. -*/ -static void menu_append_item__(menu_type * menu , menu_item_type * item) { - vector_append_owned_ref( menu->items , item , menu_item_free__); -} - - -void menu_set_title(menu_type * menu, const char * title) { - menu->title = util_realloc_string_copy(menu->title, title); -} - - -void menu_item_disable( menu_item_type * item ) { - item->enabled = false; -} - -void menu_item_enable( menu_item_type * item ) { - item->enabled = true; -} - - -char menu_item_get_key( const menu_item_type * item ) { - if (item->enabled) - return item->key_set[0]; - else - return '-'; -} - - -void menu_item_call( const menu_item_type * item ) { - if (item->enabled) - item->func(item->arg); -} - - - -void menu_item_set_label(menu_item_type * item , const char * label) { - item->label = util_realloc_string_copy(item->label , label); - item->label_length = strlen(item->label); -} - -/** - Adds (appends) an item to the menu. - - - Obsereve that several keys can be used to invoke a particular - function, however *only* the first key in the key_set is displayed - when the menu is printed on stdout. -*/ - -menu_item_type * menu_add_item(menu_type * menu , const char * label , const char * key_set , menu_func_type * func, void * arg , arg_free_ftype * free_arg) { - if (__string_contains(menu->complete_key_set , key_set)) - util_abort("%s:fatal error when building menu - key(s) in:%s already in use \n",__func__ , key_set); - { - menu_item_type * item = menu_item_alloc_empty(); - item->key_set = util_alloc_string_copy(key_set); - item->func = func; - item->arg = arg; - item->separator = false; - item->helptext = false; - item->free_arg = free_arg; - menu_append_item__(menu , item); - menu_item_set_label(item , label); - menu->complete_key_set = util_strcat_realloc(menu->complete_key_set , key_set); - return item; - } -} - - - - -/** - Will add a '-------------' line to the menu. -*/ -void menu_add_separator(menu_type * menu) { - menu_item_type * item = menu_item_alloc_empty(); - item->separator = true; - menu_append_item__(menu , item); -} - - -/** - Will print helptext to screen -*/ - -void menu_add_helptext(menu_type * menu, const char * label ) { - menu_item_type * item = menu_item_alloc_empty(); - item->helptext = true; - menu_append_item__(menu , item); - menu_item_set_label(item , label); -} - - - - - -/** level == 0 : top line - level == 1 : separator line - level == 2 : bottom line -*/ - -static void __print_line(int l , int level) { - int i; - if (level == 0) - fputc('/' , stdout); - else if (level == 1) - fputc('|' , stdout); - else - fputc('\\' , stdout); - - - for (i=1; i < (l - 1); i++) - fputc('-' , stdout); - - - if (level == 0) - fputc('\\' , stdout); - else if (level == 1) - fputc('|' , stdout); - else - fputc('/' , stdout); - - - fputc('\n' , stdout); -} - -static void __print_sep(int l) { - int i; - printf("| "); - for (i=0; i < l; i++) - fputc('-' , stdout); - printf(" |\n"); -} - - -static void __print_helptext(char * label, int l){ - bool end_reached = false; - char * label_copy = util_alloc_string_copy( label ); - char * first_part = "Dummy3"; - char * second_part = "Dummy4"; - while(!end_reached){ - int i; - if(strlen(label_copy) > l){ - util_binary_split_string_from_max_length(label_copy , " ", l , &first_part , &second_part); - printf("| %s",first_part); - for (i=strlen(first_part); i < l; i++) - fputc(' ' , stdout); - printf(" |\n"); - label_copy = util_realloc_string_copy(label_copy, second_part); - } - else{ - printf("| %s",label_copy); - for (i=strlen(label_copy); i < l; i++) - fputc(' ' , stdout); - printf(" |\n"); - end_reached = true; - } - } -} - - - - -static void menu_display(const menu_type * menu) { - int i; - int length = strlen(menu->title); - for (i = 0; i < vector_get_size(menu->items); i++) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const( menu->items , i); - if(!item->helptext) - length = util_int_max(length , item->label_length); - if(item->helptext) - length = util_int_max(length , 60); /* Hardcoded length for helptext*/ - } - - - printf("\n"); - __print_line(length + 10 , 0); - printf("| "); - util_fprintf_string(menu->title , length + 6 , center_pad , stdout); printf(" |\n"); - __print_line(length + 10 , 1); - for (i=0; i < vector_get_size(menu->items); i++) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const( menu->items , i); - if (item->separator) - __print_sep(length + 6); - else if (item->helptext) - __print_helptext(item->label,length); - else { - printf("| %c: ", menu_item_get_key( item )); - util_fprintf_string(item->label , length + 3 , right_pad , stdout); - printf(" |\n"); - } - } - __print_sep(length + 6); - printf("| %c: ",menu->quit_keys[0]); - util_fprintf_string(menu->quit_label , length + 3 , right_pad , stdout); - printf(" |\n"); - __print_line(length + 10 , 2); - printf("\n"); -} - - - -/** - Reads a string from stdin: If the string is longer than one single - character it is discarded, if it is exactly one character long we - check if it is in the menus set of available command characters, - and return it *IF* it is a valid character. I.e. the return value - from this function is *GUARANTEED* to correspond to a menu item. - - Observe that the function ends with a call to getchar() - this - should remove the traling from the stdin input buffer. -*/ - -static int menu_read_cmd(const menu_type * menu) { - char cmd[256]; - - do { - printf("==> "); - fflush(stdout); fscanf(stdin , "%s" , cmd); /* We read a full string - - but we only consider it if it is exactly *ONE* character long. */ - } while ((strchr(menu->complete_key_set , cmd[0]) == NULL) || strlen(cmd) > 1); - - getchar(); /* Discards trailing from standard input buffer? */ - return cmd[0]; -} - - - - -menu_item_type * menu_get_item(const menu_type * menu, char cmd) { - int item_index = 0; - menu_item_type * item = NULL; - while (item_index < vector_get_size(menu->items)) { - menu_item_type * current_item = (menu_item_type*)vector_iget(menu->items , item_index); - if (!current_item->separator || !current_item->helptext) { - if (strchr(current_item->key_set , cmd) != NULL) { - item = current_item; - break; - } - item_index++; - } - } - - if (item == NULL) - util_abort("%s: could not locate item with key: %c \n",__func__ , cmd); - return item; -} - - - -void menu_run(const menu_type * menu) { - while (1) { - int cmd; - - - menu_display(menu); - cmd = menu_read_cmd(menu); - if (strchr(menu->quit_keys , cmd) != NULL) /* We have recieved a quit command - leave the building. */ - break; - - /* - OK - we start looking through all the available commands to see - which this is. */ - { - int item_index = 0; - while (1) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const(menu->items , item_index); - if (!item->separator) { - if(!item->helptext) { - if (strchr(item->key_set , cmd) != NULL) { - /* Calling the function ... */ - menu_item_call( item ); - break; - } - } - } - item_index++; - } - } - } -} - - - -void menu_free(menu_type * menu) { - free(menu->quit_keys); - free(menu->title); - free(menu->complete_key_set); - free(menu->quit_label); - vector_free(menu->items); - free(menu); -} diff --git a/ThirdParty/Ert/lib/util/msg.c b/ThirdParty/Ert/lib/util/msg.c deleted file mode 100644 index bedc0c49f1..0000000000 --- a/ThirdParty/Ert/lib/util/msg.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'msg.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include - -#include -#include -#include - -#define MSG_TYPE_ID 1999867 - -struct msg_struct { - UTIL_TYPE_ID_DECLARATION; - char * prompt; - char * msg; - int msg_len; - bool visible; - bool debug; -}; - - -static void __msg_assert_visible(const msg_type * msg) { - if (!msg->visible) - util_abort("%s: you must call msg_show() first - aborting.\n",__func__); -} - - -static void __blank_string(int len) { - int i; - for (i = 0; i < len; i++) - fputc('\b' , stdout); - - for (i = 0; i < len; i++) - fputc(' ' , stdout); - - for (i = 0; i < len; i++) - fputc('\b' , stdout); - -} - - -void msg_clear_msg(msg_type * msg) { - __msg_assert_visible(msg); - __blank_string(msg->msg_len); - if (msg->msg != NULL) { - free(msg->msg); - msg->msg_len = 0; - msg->msg = NULL; - } -} - - - -static void msg_clear_prompt(const msg_type * msg) { - __blank_string(strlen(msg->prompt)); -} - - -void msg_hide(msg_type * msg) { - msg_clear_msg(msg); - msg_clear_prompt(msg); - msg->visible = false; -} - - -void msg_set_prompt(msg_type * msg , const char * prompt) { - msg->prompt = util_realloc_string_copy(msg->prompt , prompt); -} - - -void msg_print_msg(const msg_type * msg) { - if (msg->msg != NULL) - printf("%s" , msg->msg); - fflush(stdout); -} - - -void msg_show(msg_type * msg) { - if (!msg->visible) { - printf("%s" , msg->prompt); - msg_print_msg(msg); - msg->visible = true; - } -} - - -void msg_update(msg_type * msg , const char * new_msg) { - __msg_assert_visible(msg); - if (!msg->debug) - msg_clear_msg(msg); - - { - msg->msg = util_realloc_string_copy(msg->msg , new_msg); - if (new_msg == NULL) - msg->msg_len = 0; - else - msg->msg_len = strlen(new_msg); - } - - if (msg->debug) - printf("%s\n",msg->msg); - else - msg_print_msg(msg); -} - - -void msg_update_int(msg_type * msg , const char * fmt , int value) { - char buffer[16]; - sprintf(buffer , fmt , value); - msg_update(msg , buffer); -} - - -UTIL_SAFE_CAST_FUNCTION( msg , MSG_TYPE_ID ) - -msg_type * msg_alloc(const char * prompt, bool debug) { - msg_type * msg = (msg_type*)util_malloc(sizeof * msg ); - UTIL_TYPE_ID_INIT( msg , MSG_TYPE_ID); - msg->prompt = util_alloc_string_copy(prompt); - - msg->msg = NULL; - msg->msg_len = 0; - msg->visible = false; - msg->debug = debug; - return msg; -} - - -void msg_free(msg_type * msg , bool clear) { - if (clear) - msg_hide(msg); - else - printf("\n"); - - free(msg->prompt); - if (msg->msg != NULL) - free(msg->msg); - - free(msg); -} - - - diff --git a/ThirdParty/Ert/lib/util/mzran.c b/ThirdParty/Ert/lib/util/mzran.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/mzran.c rename to ThirdParty/Ert/lib/util/mzran.cpp index 326cfb083d..a6c54eb9b4 100644 --- a/ThirdParty/Ert/lib/util/mzran.c +++ b/ThirdParty/Ert/lib/util/mzran.cpp @@ -19,9 +19,9 @@ #include #include -#include -#include -#include +#include +#include +#include /*****************************************************************/ /* diff --git a/ThirdParty/Ert/lib/util/node_ctype.c b/ThirdParty/Ert/lib/util/node_ctype.cpp similarity index 95% rename from ThirdParty/Ert/lib/util/node_ctype.c rename to ThirdParty/Ert/lib/util/node_ctype.cpp index 08c9219273..32aa3790e3 100644 --- a/ThirdParty/Ert/lib/util/node_ctype.c +++ b/ThirdParty/Ert/lib/util/node_ctype.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include const char * node_ctype_name(node_ctype ctype) { diff --git a/ThirdParty/Ert/lib/util/node_data.c b/ThirdParty/Ert/lib/util/node_data.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/node_data.c rename to ThirdParty/Ert/lib/util/node_data.cpp index c45362b7a6..88af1a6abd 100644 --- a/ThirdParty/Ert/lib/util/node_data.c +++ b/ThirdParty/Ert/lib/util/node_data.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* diff --git a/ThirdParty/Ert/lib/util/parser.c b/ThirdParty/Ert/lib/util/parser.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/parser.c rename to ThirdParty/Ert/lib/util/parser.cpp index 1105a61f46..0d1c1fdc11 100644 --- a/ThirdParty/Ert/lib/util/parser.c +++ b/ThirdParty/Ert/lib/util/parser.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define PARSER_ESCAPE_CHAR '\\' @@ -498,7 +498,7 @@ static bool fseek_quote_end( char quoter , FILE * stream ) { static bool fgetc_while_equal( FILE * stream , const char * string , bool case_sensitive) { bool equal = true; long int current_pos = util_ftell(stream); - int string_index; + size_t string_index; for ( string_index = 0; string_index < strlen(string); string_index++) { int c = fgetc( stream ); if (!case_sensitive) @@ -625,7 +625,7 @@ void basic_parser_strip_buffer(const basic_parser_type * parser , char ** __buff char * src = *__buffer; char * target = (char*)util_calloc( ( strlen( *__buffer ) + 1) , sizeof * target ); - int src_position = 0; + size_t src_position = 0; int target_position = 0; while (src_position < strlen( src )) { int comment_length; diff --git a/ThirdParty/Ert/lib/util/path_fmt.c b/ThirdParty/Ert/lib/util/path_fmt.c deleted file mode 100644 index 49191ab623..0000000000 --- a/ThirdParty/Ert/lib/util/path_fmt.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'path_fmt.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -#include "ert/util/build_config.h" -#include -#include -#include -#include - -/** -The basic idea of the path_fmt_type is that it should be possible for -a user to specify an arbirtrary path *WITH* embedded format -strings. It is implemented with the the help av variable length -argument lists. This has the following disadvantages: - - o The code gets ugly - really ugly. - - o It is difficult to provide type-safety on user input. - -Example: - - -path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt("/tmp/ECLIPSE/%s/Run-%d"); - - -Here we have allocated a path_fmt instance which will require two -additional arguments when a full path is created, a string for the -"%s" placeholder and an integer for the %d placeholder: - -char * path = path_fmt_alloc(path_fmt , "BaseCase" , 67); - -=> path = /tmp/ECLIPSE/Basecase/Run-67 - -*/ - -#define PATH_FMT_ID 7519200 - - -struct path_fmt_struct { - UTIL_TYPE_ID_DECLARATION; - char *fmt; - char *file_fmt; - bool is_directory; -}; - - -static UTIL_SAFE_CAST_FUNCTION( path_fmt , PATH_FMT_ID) - -void path_fmt_reset_fmt(path_fmt_type * path , const char * fmt) { - path->fmt = util_realloc_string_copy(path->fmt , fmt); - if (path->is_directory) - path->file_fmt = util_alloc_sprintf("%s/%%s" , fmt); -} - - - -static path_fmt_type * path_fmt_alloc__(const char * fmt , bool is_directory) { - path_fmt_type * path = (path_fmt_type*)util_malloc(sizeof * path ); - UTIL_TYPE_ID_INIT(path , PATH_FMT_ID); - path->fmt = NULL; - path->file_fmt = NULL; - path->is_directory = is_directory; - - path_fmt_reset_fmt(path , fmt); - return path; -} - - -/** - - This function is used to allocate a path_fmt instance which is - intended to hold a directory, if the second argument is true, the - resulting directory will be automatically created when - path_fmt_alloc_path() is later invoked. - - Example: - ------- - path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt("/tmp/scratch/member%d/%d.%d" , true); - .... - .... - char * path = path_fmt_alloc_path(path_fmt , 10 , 12 , 15); - char * file = path_fmt_alloc_file(path_fmt , 8 , 12 , 17, "SomeFile"); - - After the two last function calls we will have: - - o path = "/tmp/scratch/member10/12.15" - and this directory has - been created. - - o file = "/tmp/scratch/member8/12.17/SomeFile - and the directory - /tmp/scratch/member8/12.17 has been created. - - - Observe that the functionality is implemented with the help av - variable length argument lists, and **NO** checking of argument list - versus format string is performed. -*/ - - -path_fmt_type * path_fmt_alloc_directory_fmt(const char * fmt) { - return path_fmt_alloc__(fmt , true); -} - - - -/* - Most general. Can afterwards be used to allocate strings - representing both directories and files. -*/ - -path_fmt_type * path_fmt_alloc_path_fmt(const char * fmt) { - return path_fmt_alloc__(fmt , false ); -} - - - -/** - Present the user with a prompt, and reads format specifier string - from stdin. Currently not possible to specify argument types. -*/ - -path_fmt_type * path_fmt_scanf_alloc(const char * prompt , int types , const node_ctype * type_list, bool is_directory) { - char * fmt; - fmt = util_scanf_alloc_string(prompt); - return path_fmt_alloc__(fmt , is_directory); -} - -path_fmt_type * path_fmt_copyc(const path_fmt_type *path) { - path_fmt_type *new_path = path_fmt_alloc__(path->fmt , path->is_directory); - return new_path; -} - -char * path_fmt_alloc_path_va(const path_fmt_type * path ,bool auto_mkdir, va_list ap) { - char * new_path = util_alloc_sprintf_va(path->fmt , ap ); - if (auto_mkdir) - if (! util_is_directory(new_path) ) - util_make_path(new_path); - return new_path; -} - - -char * path_fmt_alloc_path(const path_fmt_type * path , bool auto_mkdir , ...) { - char * new_path; - va_list ap; - va_start(ap , auto_mkdir); - new_path = path_fmt_alloc_path_va(path ,auto_mkdir , ap); - va_end(ap); - return new_path; -} - - - -/** - This function is used to allocate a filename (full path) from a - path_fmt instance: - - Eaxample: - - path_fmt_type * path_fmt = path_fmt_alloc_directory("/tmp/path%d/X.%02d"); - char * file = path_fmt_alloc_file(path_fmt , 100 , 78 , "SomeFile.txt") - - This will allocate the filename: /tmp/path100/X.78/SomeFile.txt; if - it does not already exist, the underlying directory will be - created. Observe that there is nothing special about the filename - argument (i.e. 'SomeFile.txt' in the current example), it is just - the last argument to the path_fmt_alloc_file() function call - - however it must be a string; i.e. if you are making a purely numeric - filename you must convert to a string. - - Observe that the handling of the variable length argument lists gets - seriously ugly. - - ----------------------------------------------------------------- - - If auto_mkdir == true the function behaves in two different ways - depending on whether the path_instance was allocated as a directory - or as a path: - - * [Directory]: When the path_fmt instance was allocated as a - directory, "/%s" format decriptor will be appended to the format. - - * [Path]: The resulting string will be split on "/", and the path - component will be created. -*/ - - -char * path_fmt_alloc_file(const path_fmt_type * path , bool auto_mkdir , ...) { - if (path->is_directory) { - char * filename; - va_list tmp_va , ap; - va_start(ap , auto_mkdir); - UTIL_VA_COPY(tmp_va , ap); - filename = util_alloc_sprintf_va( path->file_fmt , tmp_va ); - if (auto_mkdir) { - const char * __path = util_alloc_sprintf_va( path->fmt , tmp_va ); - if (! util_is_directory(__path)) - util_make_path( __path ); - free((char *) __path ); - } - va_end(ap); - return filename; - } else { - - char * filename; - va_list tmp_va , ap; - va_start(ap , auto_mkdir); - UTIL_VA_COPY(tmp_va , ap); - filename = util_alloc_sprintf_va( path->fmt , tmp_va ); - if (auto_mkdir) { - char * __path; - util_alloc_file_components(filename , &__path , NULL , NULL); - util_make_path(__path); - free(__path); - } - va_end(ap); - - return filename; - } -} - - - -/** - This function is used to assert that the format in a path_fmt - instance is according to specification. What is checked is that the - format string contains %d, %lfg and %s in as specified in the - input_types vector. - - Observe that %s is mapped to void_pointer - as the node_ctype does not - have typed pointers. -*/ - - -/* -void path_fmt_assert_fmt(const path_fmt_type * path , int num_input , const node_ctype * input_types) { - int input_nr = 0; - int char_nr = 0; - do { - if (path->fmt[char_nr] == '%') { - - } - } -} -*/ - -/* - fmt == NULL - ----------- - The function will return NULL, possibly freeing the incoming - path_fmt instance if that is different from NULL. - - - fmt != NULL - ----------- - The current path_fmt instance will be updated, or a new created. The - new/updated path_fmt instance is returned. -*/ - -path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ) { - if (fmt == NULL) { - if (path_fmt != NULL) - path_fmt_free( path_fmt ); - return NULL; - } else { - if (path_fmt == NULL) - return path_fmt_alloc_path_fmt( fmt ); - else { - path_fmt_reset_fmt( path_fmt , fmt ); - return path_fmt; - } - } -} - - -const char * path_fmt_get_fmt(const path_fmt_type * path) { - if (path == NULL) - return NULL; - else - return path->fmt; -} - - -void path_fmt_free(path_fmt_type * path) { - free(path->fmt); - if (path->is_directory) - free(path->file_fmt); - free(path); -} - - -void path_fmt_free__( void * arg ) { - path_fmt_type * path_fmt = path_fmt_safe_cast( arg ); - path_fmt_free( path_fmt ); -} diff --git a/ThirdParty/Ert/lib/util/path_stack.c b/ThirdParty/Ert/lib/util/path_stack.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/path_stack.c rename to ThirdParty/Ert/lib/util/path_stack.cpp index 3d248849e1..3f71a9191b 100644 --- a/ThirdParty/Ert/lib/util/path_stack.c +++ b/ThirdParty/Ert/lib/util/path_stack.cpp @@ -23,9 +23,9 @@ #include #include -#include -#include -#include +#include +#include +#include /** This file implements the structure path_stack which is vaguely diff --git a/ThirdParty/Ert/lib/util/perm_vector.c b/ThirdParty/Ert/lib/util/perm_vector.cpp similarity index 94% rename from ThirdParty/Ert/lib/util/perm_vector.c rename to ThirdParty/Ert/lib/util/perm_vector.cpp index ff4a1b323b..0b6ccde713 100644 --- a/ThirdParty/Ert/lib/util/perm_vector.c +++ b/ThirdParty/Ert/lib/util/perm_vector.cpp @@ -17,9 +17,9 @@ */ #include -#include -#include -#include +#include +#include +#include #define PERM_VECTOR_TYPE_ID 661433 diff --git a/ThirdParty/Ert/lib/util/regression.c b/ThirdParty/Ert/lib/util/regression.c deleted file mode 100644 index 4b1c3b8dba..0000000000 --- a/ThirdParty/Ert/lib/util/regression.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'regression.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include -#include -#include - - - -/** - Will normalize the the data in X and Y: - - 1. Y -> Y - - 2. For each column: X -> X - - 3. For each column: ||X|| = 1 - - The mean Y value is returned from the function, and the mean X and - normalization factor for X is returned, for each column, in the - matrices (row vectors) X_mean and X_norm. -*/ - - -double regression_scale(matrix_type * X , matrix_type * Y , matrix_type * X_mean , matrix_type * X_norm) { - int nvar = matrix_get_columns( X ); - int nsample = matrix_get_rows( X ); - - if ( matrix_get_rows( Y ) != nsample) - util_abort("%s: dimension mismatch X:[%d,%d] Y:%d \n",__func__ , nsample , nvar , matrix_get_rows( Y )); - - if ( matrix_get_columns( X_norm ) != nvar) - util_abort("%s: dimension mismtach X_norm \n",__func__); - - if ( matrix_get_columns( X_mean ) != nvar) - util_abort("%s: dimension mismtach X_mean \n",__func__); - - { - double y_mean = matrix_get_column_sum( Y , 0 ) / nsample; - matrix_shift_column( Y , 0 , -y_mean ); - - { - int col; - for (col = 0; col < nvar; col++) { - double mean = matrix_get_column_sum(X , col ) / nsample; - matrix_shift_column(X , col , -mean); - matrix_iset( X_mean , 0 , col , mean ); - } - - for (col=0; col < nvar; col++) { - double norm = 1.0/sqrt( (1.0 / (nsample - 1)) * matrix_get_column_sum2( X , col )); - matrix_iset( X_norm , 0 , col , norm ); - } - } - return y_mean; - } -} - - -double regression_unscale(const matrix_type * beta , const matrix_type * X_norm , const matrix_type * X_mean , double Y_mean , matrix_type * beta0) { - int nvars = matrix_get_rows( beta0 ); - int k; - double yshift = 0; - - for (k=0; k < nvars; k++) { - double scaled_beta = matrix_iget( beta , k , 0 ) * matrix_iget( X_norm , 0 , k); - matrix_iset( beta0 , k , 0 , scaled_beta); - yshift += scaled_beta * matrix_iget( X_mean , 0 , k ); - } - return Y_mean - yshift; -} - - -/** - Performs an ordinary least squares estimation of the parameter - vector beta. - - beta = inv(X'·X)·X'·y -*/ - -void regression_augmented_OLS( const matrix_type * X , const matrix_type * Y , const matrix_type* Z, matrix_type * beta) { - /* - Solves the following especial augmented regression problem: - - [Y ; 0] = [X ; Z] beta + epsilon - - where 0 is the zero matrix of same size as Y. - - The solution to this OLS is: - - inv(X'X + Z'Z) * X' * Y - - The semicolon denotes row concatenation and the apostrophe the transpose. - - */ - int nvar = matrix_get_columns( X ); - matrix_type * Xt = matrix_alloc_transpose( X ); - matrix_type * Xinv = matrix_alloc( nvar , nvar); - matrix_matmul( Xinv , Xt , X ); - - matrix_type * Zt = matrix_alloc_transpose( Z ); - matrix_type * ZtZ = matrix_alloc( nvar , nvar); - matrix_matmul( ZtZ , Zt , Z ); - - // Xinv <- X'X + Z'Z - matrix_inplace_add(Xinv, ZtZ); - - // Sometimes the inversion fails - add a small regularization to diagonal - for (int i = 0; i < nvar; ++i) - matrix_iadd(Xinv, i, i, 1e-10); - - matrix_inv( Xinv ); // Xinv is always invertible - { - matrix_type * tmp = matrix_alloc_matmul( Xinv , Xt ); - matrix_matmul( beta , tmp , Y ); - matrix_free( tmp ); - } - - matrix_free( Xt ); - matrix_free( Xinv ); - matrix_free( Zt ); - matrix_free( ZtZ ); -} - diff --git a/ThirdParty/Ert/lib/util/rng.c b/ThirdParty/Ert/lib/util/rng.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/rng.c rename to ThirdParty/Ert/lib/util/rng.cpp index 2408cd5baf..c940eed166 100644 --- a/ThirdParty/Ert/lib/util/rng.c +++ b/ThirdParty/Ert/lib/util/rng.cpp @@ -20,10 +20,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define RNG_TYPE_ID 66154432 #ifdef __cplusplus @@ -263,7 +263,7 @@ unsigned int rng_get_max_int(const rng_type * rng) { void rng_shuffle( rng_type * rng , char * data , size_t element_size , size_t num_elements) { void * tmp = util_malloc( element_size ); - int index1; + size_t index1; for ( index1=0; index1 < num_elements; index1++) { int index2 = rng_get_int( rng , num_elements ); diff --git a/ThirdParty/Ert/lib/util/set.c b/ThirdParty/Ert/lib/util/set.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/set.c rename to ThirdParty/Ert/lib/util/set.cpp index 68ea5ba2ee..0ee87f81f5 100644 --- a/ThirdParty/Ert/lib/util/set.c +++ b/ThirdParty/Ert/lib/util/set.cpp @@ -21,10 +21,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define SET_TYPE_ID 816523 diff --git a/ThirdParty/Ert/lib/util/statistics.c b/ThirdParty/Ert/lib/util/statistics.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/statistics.c rename to ThirdParty/Ert/lib/util/statistics.cpp index cc6734198e..ead3d3ff45 100644 --- a/ThirdParty/Ert/lib/util/statistics.c +++ b/ThirdParty/Ert/lib/util/statistics.cpp @@ -19,9 +19,9 @@ #include #include -#include -#include -#include +#include +#include +#include double statistics_mean( const double_vector_type * data_vector ) { diff --git a/ThirdParty/Ert/lib/util/stepwise.c b/ThirdParty/Ert/lib/util/stepwise.c deleted file mode 100644 index 4a166bc1f9..0000000000 --- a/ThirdParty/Ert/lib/util/stepwise.c +++ /dev/null @@ -1,456 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include - - - -#define STEPWISE_TYPE_ID 8722106 - -struct stepwise_struct { - UTIL_TYPE_ID_DECLARATION; - - matrix_type * X0; // Externally supplied data. - matrix_type * E0; // Externally supplied data. - matrix_type * Y0; - - matrix_type * beta; // Quantities estimated by the stepwise algorithm - double Y_mean; - matrix_type * X_mean; - matrix_type * X_norm; - bool_vector_type * active_set; - rng_type * rng; // Needed in the cross-validation - double R2; // Final R2 -}; - - - -static double stepwise_estimate__( stepwise_type * stepwise , bool_vector_type * active_rows) { - matrix_type * X; - matrix_type * E; - matrix_type * Y; - - double y_mean = 0; - int ncols = matrix_get_columns( stepwise->X0 ); - int nrows = matrix_get_rows( stepwise->X0 ); - - int nsample = bool_vector_count_equal( active_rows , true ); - int nvar = bool_vector_count_equal( stepwise->active_set , true ); - - - matrix_set( stepwise->beta , 0 ); // It is essential to make sure that old finite values in the beta0 vector do not hang around. - - - /* - Extracting the data used for regression, and storing them in the - temporary local matrices X and Y. Selecting data is based both on - which varibles are active (stepwise->active_set) and which rows - should be used for regression, versus which should be used for - validation (@active_rows). - */ - if ((nsample < nrows) || (nvar < ncols)) { - X = matrix_alloc( nsample , nvar ); - E = matrix_alloc( nsample , nvar ); - Y = matrix_alloc( nsample , 1); - - { - int icol,irow; // Running over all values. - int arow,acol; // Running over active values. - arow = 0; - for (irow = 0; irow < nrows; irow++) { - if (bool_vector_iget( active_rows , irow )) { - acol = 0; - for (icol = 0; icol < ncols; icol++) { - if (bool_vector_iget( stepwise->active_set , icol )) { - matrix_iset( X , arow , acol , matrix_iget( stepwise->X0 , irow , icol )); - matrix_iset( E , arow , acol , matrix_iget( stepwise->E0 , irow , icol )); - acol++; - } - } - - matrix_iset( Y , arow , 0 , matrix_iget( stepwise->Y0 , irow , 0 )); - arow++; - } - } - } - } else { - X = matrix_alloc_copy( stepwise->X0 ); - E = matrix_alloc_copy( stepwise->E0 ); - Y = matrix_alloc_copy( stepwise->Y0 ); - } - - - { - - if (stepwise->X_mean != NULL) - matrix_free( stepwise->X_mean); - - stepwise->X_mean = matrix_alloc( 1 , nvar ); - - if (stepwise->X_norm != NULL) - matrix_free( stepwise->X_norm); - - stepwise->X_norm = matrix_alloc( 1 , nvar ); - - matrix_type * beta = matrix_alloc( nvar , 1); /* This is the beta vector as estimated from the OLS estimator. */ - - regression_augmented_OLS( X , Y , E, beta ); - - - /* - In this code block the beta/tmp_beta vector which is dense with - fewer elements than the full model is scattered into the beta0 - vector which has full size and @nvar elements. - */ - { - int ivar,avar; - avar = 0; - for (ivar = 0; ivar < ncols; ivar++) { - if (bool_vector_iget( stepwise->active_set , ivar )) { - matrix_iset( stepwise->beta , ivar , 0 , matrix_iget( beta , avar , 0)); - avar++; - } - } - } - - - matrix_free( beta ); - } - - matrix_free( X ); - matrix_free( E ); - matrix_free( Y ); - return y_mean; -} - - - - -static double stepwise_eval__( const stepwise_type * stepwise , const matrix_type * x ) { - return matrix_row_column_dot_product( x , 0 , stepwise->beta , 0 ); -} - - - -static double stepwise_test_var( stepwise_type * stepwise , int test_var , int blocks) { - double prediction_error = 0; - - bool_vector_iset( stepwise->active_set , test_var , true ); // Temporarily activate this variable - { - - int nvar = matrix_get_columns( stepwise->X0 ); - int nsample = matrix_get_rows( stepwise->X0 ); - int block_size = nsample / blocks; - bool_vector_type * active_rows = bool_vector_alloc( nsample, true ); - - - - - - /*True Cross-Validation: */ - int * randperms = (int*)util_calloc( nsample , sizeof * randperms ); - for (int i=0; i < nsample; i++) - randperms[i] = i; - - /* Randomly perturb ensemble indices */ - rng_shuffle_int( stepwise->rng , randperms , nsample ); - - - for (int iblock = 0; iblock < blocks; iblock++) { - - int validation_start = iblock * block_size; - int validation_end = validation_start + block_size - 1; - - if (iblock == (blocks - 1)) - validation_end = nsample - 1; - - /* - Ensure that the active_rows vector has a block consisting of - the interval [validation_start : validation_end] which is set to - false, and the remaining part of the vector is set to true. - */ - { - bool_vector_set_all(active_rows, true); - /* - If blocks == 1 that means all datapoint are used in the - regression, and then subsequently reused in the R2 - calculation. - */ - if (blocks > 1) { - for (int i = validation_start; i <= validation_end; i++) { - bool_vector_iset( active_rows , randperms[i] , false ); - } - } - } - - - /* - Evaluate the prediction error on the validation part of the - dataset. - */ - { - stepwise_estimate__( stepwise , active_rows ); - { - int irow; - matrix_type * x_vector = matrix_alloc( 1 , nvar ); - //matrix_type * e_vector = matrix_alloc( 1 , nvar ); - for (irow=validation_start; irow <= validation_end; irow++) { - matrix_copy_row( x_vector , stepwise->X0 , 0 , randperms[irow]); - //matrix_copy_row( e_vector , stepwise->E0 , 0 , randperms[irow]); - { - double true_value = matrix_iget( stepwise->Y0 , randperms[irow] , 0 ); - double estimated_value = stepwise_eval__( stepwise , x_vector ); - prediction_error += (true_value - estimated_value) * (true_value - estimated_value); - //double e_estimated_value = stepwise_eval__( stepwise , e_vector ); - //prediction_error += e_estimated_value*e_estimated_value; - } - - } - matrix_free( x_vector ); - } - } - } - - free( randperms ); - bool_vector_free( active_rows ); - } - - /*inactivate the test_var-variable after completion*/ - bool_vector_iset( stepwise->active_set , test_var , false ); - return prediction_error; -} - - -void stepwise_estimate( stepwise_type * stepwise , double deltaR2_limit , int CV_blocks) { - int nvar = matrix_get_columns( stepwise->X0 ); - int nsample = matrix_get_rows( stepwise->X0 ); - double currentR2 = -1; - bool_vector_type * active_rows = bool_vector_alloc( nsample , true ); - - - /*Reset beta*/ - for (int i = 0; i < nvar; i++) { - matrix_iset(stepwise->beta, i , 0 , 0.0); - } - - - - bool_vector_set_all( stepwise->active_set , false ); - - double MSE_min = 10000000; - double Prev_MSE_min = MSE_min; - double minR2 = -1; - - while (true) { - int best_var = 0; - Prev_MSE_min = MSE_min; - - /* - Go through all the inactive variables, and calculate the - resulting prediction error IF this particular variable is added; - keep track of the variable which gives the lowest prediction error. - */ - for (int ivar = 0; ivar < nvar; ivar++) { - if (!bool_vector_iget( stepwise->active_set , ivar)) { - double newR2 = stepwise_test_var(stepwise , ivar , CV_blocks); - if ((minR2 < 0) || (newR2 < minR2)) { - minR2 = newR2; - best_var = ivar; - } - } - } - - /* - If the best relative improvement in prediction error is better - than @deltaR2_limit, the corresponding variable is added to the - active set, and we return to repeat the loop one more - time. Otherwise we just exit. - */ - - { - MSE_min = minR2; - double deltaR2 = MSE_min / Prev_MSE_min; - - if (( currentR2 < 0) || deltaR2 < deltaR2_limit) { - bool_vector_iset( stepwise->active_set , best_var , true ); - currentR2 = minR2; - bool_vector_set_all(active_rows, true); - stepwise_estimate__( stepwise , active_rows ); - } else { - /* The gain in prediction error is so small that we just leave the building. */ - /* NB! Need one final compuation of beta (since the test_var function does not reset the last tested beta value !) */ - bool_vector_set_all(active_rows, true); - stepwise_estimate__( stepwise , active_rows ); - break; - } - - if (bool_vector_count_equal( stepwise->active_set , true) == matrix_get_columns( stepwise->X0 )) { - stepwise_estimate__( stepwise , active_rows ); - break; /* All variables are active. */ - } - } - } - - stepwise_set_R2(stepwise, currentR2); - bool_vector_free( active_rows ); -} - - - -double stepwise_eval( const stepwise_type * stepwise , const matrix_type * x ) { - double yHat = stepwise_eval__(stepwise, x ); - return yHat; -} - - - -static stepwise_type * stepwise_alloc__( int nsample , int nvar , rng_type * rng) { - stepwise_type * stepwise = (stepwise_type*)util_malloc( sizeof * stepwise ); - - stepwise->X_mean = NULL; - stepwise->X_norm = NULL; - stepwise->Y_mean = 0.0; - stepwise->rng = rng; - stepwise->X0 = NULL; - stepwise->E0 = NULL; - stepwise->Y0 = NULL; - stepwise->active_set = bool_vector_alloc( nvar , true ); - stepwise->beta = matrix_alloc( nvar , 1 ); - - return stepwise; -} - - -stepwise_type * stepwise_alloc0( rng_type * rng) { - stepwise_type * stepwise = (stepwise_type*)util_malloc( sizeof * stepwise ); - - stepwise->rng = rng; - stepwise->X0 = NULL; - stepwise->E0 = NULL; - stepwise->Y0 = NULL; - stepwise->beta = NULL; - stepwise->active_set = NULL; - stepwise->X_mean = NULL; - stepwise->X_norm = NULL; - stepwise->Y_mean = 0.0; - stepwise->R2 = -1.0; - - return stepwise; -} - - - -stepwise_type * stepwise_alloc1( int nsample , int nvar, rng_type * rng, const matrix_type* St, const matrix_type* Et) { - stepwise_type * stepwise = stepwise_alloc__( nsample , nvar , rng); - - stepwise->rng = rng; - stepwise->X0 = matrix_alloc_copy(St); // It would be nice to get rid of these copies, but due to data race it is not possible at the moment - stepwise->E0 = matrix_alloc_copy(Et); - stepwise->Y0 = NULL; //matrix_alloc( nsample , 1 ); - - return stepwise; -} - - -void stepwise_set_Y0( stepwise_type * stepwise , matrix_type * Y) { - stepwise->Y0 = Y; -} - -void stepwise_set_X0( stepwise_type * stepwise , matrix_type * X) { - stepwise->X0 = X; -} - -void stepwise_set_E0( stepwise_type * stepwise , matrix_type * E) { - stepwise->E0 = E; -} - - -void stepwise_set_beta( stepwise_type * stepwise , matrix_type * b) { -if (stepwise->beta != NULL) - matrix_free( stepwise->beta ); - - stepwise->beta = b; -} - -void stepwise_set_active_set( stepwise_type * stepwise , bool_vector_type * a) { - if (stepwise->active_set != NULL) - bool_vector_free( stepwise->active_set ); - - stepwise->active_set = a; -} - -void stepwise_set_R2( stepwise_type * stepwise , const double R2) { - stepwise->R2 = R2; -} - -matrix_type * stepwise_get_X0( stepwise_type * stepwise ) { - return stepwise->X0; -} - -matrix_type * stepwise_get_Y0( stepwise_type * stepwise ) { - return stepwise->Y0; -} - -double stepwise_get_R2(const stepwise_type * stepwise ) { - return stepwise->R2; -} - -int stepwise_get_nsample( stepwise_type * stepwise ) { - return matrix_get_rows( stepwise->X0 ); -} - -int stepwise_get_nvar( stepwise_type * stepwise ) { - return matrix_get_columns( stepwise->X0 ); -} - -int stepwise_get_n_active( stepwise_type * stepwise ) { - return bool_vector_count_equal( stepwise->active_set , true); -} - -bool_vector_type * stepwise_get_active_set( stepwise_type * stepwise ) { - return stepwise->active_set; -} - -double stepwise_iget_beta(const stepwise_type * stepwise, const int index ) { - return matrix_iget( stepwise->beta, index, 0); -} - -double stepwise_get_sum_beta(const stepwise_type * stepwise ) { - return matrix_get_column_abssum( stepwise->beta, 0); -} - -void stepwise_isetY0( stepwise_type * stepwise , int i , double value ) { - matrix_iset( stepwise->Y0, i , 0 , value ); -} - - -void stepwise_free( stepwise_type * stepwise ) { - if (stepwise->active_set != NULL) { - bool_vector_free( stepwise->active_set ); - } - - - if (stepwise->beta != NULL) - matrix_free( stepwise->beta ); - - - if (stepwise->X_mean != NULL) - matrix_free( stepwise->X_mean ); - - - if (stepwise->X_norm != NULL) - matrix_free( stepwise->X_norm ); - - - matrix_free( stepwise->X0 ); - matrix_free( stepwise->E0 ); - matrix_free( stepwise->Y0 ); - - free( stepwise ); -} - diff --git a/ThirdParty/Ert/lib/util/string_util.c b/ThirdParty/Ert/lib/util/string_util.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/string_util.c rename to ThirdParty/Ert/lib/util/string_util.cpp index 12db74bdab..509c565c5b 100644 --- a/ThirdParty/Ert/lib/util/string_util.c +++ b/ThirdParty/Ert/lib/util/string_util.cpp @@ -20,12 +20,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /*****************************************************************/ @@ -59,7 +59,7 @@ static bool valid_characters( const char * range_string ) { bool valid = false; if (range_string) { - int offset = 0; + size_t offset = 0; valid = true; while (true) { char c = range_string[offset]; diff --git a/ThirdParty/Ert/lib/util/stringlist.c b/ThirdParty/Ert/lib/util/stringlist.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/stringlist.c rename to ThirdParty/Ert/lib/util/stringlist.cpp index 6bd06f9bfe..bf134c4f03 100644 --- a/ThirdParty/Ert/lib/util/stringlist.c +++ b/ThirdParty/Ert/lib/util/stringlist.cpp @@ -32,9 +32,9 @@ #include #endif -#include -#include -#include +#include +#include +#include #define STRINGLIST_TYPE_ID 671855 @@ -718,7 +718,7 @@ int stringlist_select_matching(stringlist_type * names , const char * pattern) { stringlist_clear( names ); { - int i; + size_t i; glob_t * pglob = (glob_t*)util_malloc( sizeof * pglob ); int glob_flags = 0; glob( pattern , glob_flags , NULL , pglob); @@ -843,7 +843,7 @@ int stringlist_append_matching_elements(stringlist_type * target , const stringl static int void_strcmp(const void* s1, const void *s2) { - return strcmp(s1,s2); + return strcmp((char*)s1, (char*)s2); } bool stringlist_unique(const stringlist_type * stringlist ) diff --git a/ThirdParty/Ert/lib/util/struct_vector.c b/ThirdParty/Ert/lib/util/struct_vector.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/struct_vector.c rename to ThirdParty/Ert/lib/util/struct_vector.cpp index d50d108ea8..c79891b810 100644 --- a/ThirdParty/Ert/lib/util/struct_vector.c +++ b/ThirdParty/Ert/lib/util/struct_vector.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #define STRUCT_VECTOR_TYPE_ID 772562097 diff --git a/ThirdParty/Ert/lib/util/subst_func.c b/ThirdParty/Ert/lib/util/subst_func.c deleted file mode 100644 index 5484872acd..0000000000 --- a/ThirdParty/Ert/lib/util/subst_func.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'subst_func.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include -#include -#include -#include -#include - - -#define SUBST_FUNC_TYPE_ID 646781 -#define SUBST_FUNC_POOL_TYPE_ID 7641 - -struct subst_func_pool_struct { - UTIL_TYPE_ID_DECLARATION; - hash_type * func_table; -}; - - - -struct subst_func_struct { - UTIL_TYPE_ID_DECLARATION; - subst_func_ftype * func; - char * name; - char * doc_string; /* doc_string for this function - can be NULL. */ - bool vararg; - int argc_min; - int argc_max; - void * arg; /* 100% unmanaged void argument passed in from the construction. */ -}; - - - -char * subst_func_eval( const subst_func_type * subst_func , const stringlist_type * args) { - if (!subst_func->vararg) { - /* Checking that we have the right number of arguments. */ - int argc = stringlist_get_size( args ); - if (argc < subst_func->argc_min || argc > subst_func->argc_max) { - fprintf(stderr,"Fatal error when appying function:%s - got %d arguments: [",subst_func->name , argc); - stringlist_fprintf(args , " " , stderr); - fprintf(stderr,"] expected %d-%d arguments.\n", subst_func->argc_min , subst_func->argc_max); - util_abort("%s: Fatal error - aborting \n",__func__); - } - } - printf("Running:%s \n",subst_func->name); - return subst_func->func( args , subst_func->arg ); -} - - -subst_func_type * subst_func_alloc( const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg) { - subst_func_type * subst_func = (subst_func_type*)util_malloc( sizeof * subst_func ); - UTIL_TYPE_ID_INIT( subst_func , SUBST_FUNC_TYPE_ID ); - subst_func->func = func; - subst_func->name = util_alloc_string_copy( func_name ); - subst_func->vararg = vararg; - subst_func->argc_min = argc_min; - subst_func->argc_max = argc_max; - subst_func->doc_string = util_alloc_string_copy( doc_string ); - subst_func->arg = arg; - return subst_func; -} - - -void subst_func_free( subst_func_type * subst_func ) { - util_safe_free( subst_func->doc_string ); - free( subst_func->name ); - free( subst_func ); -} - - -UTIL_SAFE_CAST_FUNCTION( subst_func , SUBST_FUNC_TYPE_ID); - -static void subst_func_free__( void * arg ) { - subst_func_free( subst_func_safe_cast( arg )); -} - - - - -/*****************************************************************/ - -UTIL_IS_INSTANCE_FUNCTION( subst_func_pool , SUBST_FUNC_POOL_TYPE_ID); - -subst_func_pool_type * subst_func_pool_alloc( ) { - subst_func_pool_type * pool = (subst_func_pool_type*)util_malloc( sizeof * pool ); - UTIL_TYPE_ID_INIT( pool , SUBST_FUNC_POOL_TYPE_ID ); - pool->func_table = hash_alloc_unlocked(); - return pool; -} - - - -void subst_func_pool_free( subst_func_pool_type * pool ) { - hash_free( pool->func_table ); - free( pool ); -} - - -void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg) { - subst_func_type * subst_func = subst_func_alloc( func_name , doc_string , func , vararg , argc_min , argc_max , arg); - hash_insert_hash_owned_ref( pool->func_table , func_name , subst_func , subst_func_free__); -} - - -subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name ) { - return (subst_func_type*)hash_get( pool->func_table , func_name ); -} - -bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name ) { - return hash_has_key( pool->func_table , func_name ); -} - - -/*****************************************************************/ - -char * subst_func_randint( const stringlist_type * args , void * arg) { - rng_type * rng = rng_safe_cast( arg ); - return util_alloc_sprintf("%u" , rng_forward( rng )); -} - -char * subst_func_randfloat( const stringlist_type * args , void * arg) { - rng_type * rng = rng_safe_cast( arg ); - return util_alloc_sprintf("%12.10f" , 1e9 * rng_get_double( rng )); -} - - -char * subst_func_exp( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , exp(arg)); - else - return NULL; -} - - -char * subst_func_log( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , log(arg)); - else - return NULL; -} - - -char * subst_func_pow10( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , pow(10 , arg)); - else - return NULL; -} - - - -char * subst_func_add( const stringlist_type * args , void * ext_arg) { - double sum = 0; - bool OK = true; - int index; - for (index = 0; index < stringlist_get_size( args ); index++) { - double term; - if (util_sscanf_double( stringlist_iget(args , index ) , &term)) - sum += term; - else - OK = false; - } - - if (OK) - return util_alloc_sprintf("%g" , sum); - else - return NULL; -} - - -char * subst_func_mul( const stringlist_type * args , void * ext_arg) { - double product = 0; - bool OK = true; - int index; - for (index = 0; index < stringlist_get_size( args ); index++) { - double factor; - if (util_sscanf_double( stringlist_iget(args , index ) , &factor)) - product *= factor; - else - OK = false; - } - - - if (OK) - return util_alloc_sprintf("%g" , product); - else - return NULL; -} diff --git a/ThirdParty/Ert/lib/util/test_util.c b/ThirdParty/Ert/lib/util/test_util.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/test_util.c rename to ThirdParty/Ert/lib/util/test_util.cpp index 3d2684d540..9115af6feb 100644 --- a/ThirdParty/Ert/lib/util/test_util.c +++ b/ThirdParty/Ert/lib/util/test_util.cpp @@ -24,12 +24,12 @@ #include #include -#include "ert/util/build_config.h" -#include -#include -#include -#include -#include +#include "ert/util/build_config.hpp" +#include +#include +#include +#include +#include void test_error_exit( const char * fmt , ...) { char * s; diff --git a/ThirdParty/Ert/lib/util/test_work_area.c b/ThirdParty/Ert/lib/util/test_work_area.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/test_work_area.c rename to ThirdParty/Ert/lib/util/test_work_area.cpp index 88116c7e1c..09e394fa92 100644 --- a/ThirdParty/Ert/lib/util/test_work_area.c +++ b/ThirdParty/Ert/lib/util/test_work_area.cpp @@ -16,7 +16,7 @@ for more details. */ -#include +#include #ifdef ERT_HAVE_GETUID #include @@ -29,11 +29,11 @@ #include #include -#include -#include -#include +#include +#include +#include -#include +#include #ifdef ERT_HAVE_OPENDIR #include #include diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c deleted file mode 100644 index 8b84bb56b8..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include - - - -int main(int argc , char ** argv) { - unsetenv("PATH"); - { - char ** path_list = util_alloc_PATH_list(); - if (path_list[0] != NULL) - test_error_exit("Failed on empty PATH\n"); - - util_free_NULL_terminated_stringlist( path_list ); - } - - - setenv("PATH" , "/usr/bin:/bin:/usr/local/bin" , 1); - { - char ** path_list = util_alloc_PATH_list(); - if (strcmp(path_list[0] , "/usr/bin") != 0) - test_error_exit("Failed on first path element\n"); - - if (strcmp(path_list[1] , "/bin") != 0) - test_error_exit("Failed on second path element\n"); - - if (strcmp(path_list[2] , "/usr/local/bin") != 0) - test_error_exit("Failed on third path element\n"); - - if (path_list[3] != NULL) - test_error_exit("Failed termination \n"); - - util_free_NULL_terminated_stringlist( path_list ); - } - - - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_logh.c b/ThirdParty/Ert/lib/util/tests/ert_util_logh.c deleted file mode 100644 index 91ae801756..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_logh.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_logh.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include -#include -#include -#include - -#define LOG_FILE "log.txt" - - -void test_open() { - test_work_area_type * work_area = test_work_area_alloc("util/logh"); - { - log_type * logh = log_open( NULL , 0 ); - test_assert_int_equal( 0 , log_get_msg_count( logh )); - test_assert_false( log_is_open( logh )); - log_reopen( logh , LOG_FILE ); - test_assert_true( log_is_open( logh )); - - log_close( logh ); - } - - { - log_type * logh = log_open( LOG_FILE , 0 ); - test_assert_not_NULL(logh); - log_close( logh ); - } - - { - log_type * logh = log_open( LOG_FILE , 1 ); - test_assert_true( log_is_open( logh )); - log_add_message( logh , 1 , NULL , "Message" , false); - test_assert_int_equal( 1 , log_get_msg_count( logh )); - log_close( logh ); - } - - test_work_area_free( work_area ); -} - - -void test_delete_empty() { - test_work_area_type * work_area = test_work_area_alloc("logh_delete_empty"); - { - log_type * logh = log_open( LOG_FILE , 0 ); - test_assert_not_NULL(logh); - log_close( logh ); - - test_assert_false( util_file_exists( LOG_FILE )); - } - - { - log_type * logh = log_open( LOG_FILE , 0 ); - log_reopen( logh , "LOG2.txt"); - log_close( logh ); - - test_assert_false( util_file_exists( LOG_FILE )); - } - - { - log_type * logh = log_open( LOG_FILE , 1 ); - log_add_message( logh , 1 , NULL , "Message" , false); - log_close( logh ); - test_assert_true( util_file_exists( LOG_FILE )); - - logh = log_open( LOG_FILE , 1 ); - log_close( logh ); - test_assert_true( util_file_exists( LOG_FILE )); - } - - test_work_area_free( work_area ); -} - - -/* - Someone else deletes the file before closing - that should not kill the thing. -*/ - -void test_file_deleted() { - log_type * logh = log_open( LOG_FILE , 1 ); - log_add_message( logh , 1 , NULL , "Message" , false); - util_unlink( LOG_FILE ); - test_assert_false( util_file_exists( LOG_FILE )); - log_close( logh ); - test_assert_false( util_file_exists( LOG_FILE )); -} - -int main(int argc , char ** argv) { - test_open(); - test_delete_empty(); - test_file_deleted( ); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c deleted file mode 100644 index c3c47a0953..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include -#include -#include -#include -#include -#include -#include - - -void test_resize() { - matrix_type * m1 = matrix_alloc(5,5); - matrix_type * m2 = matrix_alloc(5,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - - test_assert_true( matrix_equal( m1 , m2 )); - matrix_resize( m1 , 5 , 5 , false ); - test_assert_true( matrix_equal( m1 , m2 )); - matrix_resize( m1 , 5 , 5 , true ); - test_assert_true( matrix_equal( m1 , m2 )); - - rng_free( rng ); - matrix_free( m1 ); - matrix_free( m2 ); -} - - -void test_column_equal() { - matrix_type * m1 = matrix_alloc(5,5); - matrix_type * m2 = matrix_alloc(5,5); - matrix_type * m3 = matrix_alloc(6,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - - test_assert_true( matrix_columns_equal( m1 , 2 , m2 , 2 )); - test_assert_false( matrix_columns_equal( m1 , 2 , m2 , 3 )); - test_assert_false( matrix_columns_equal( m1 , 2 , m3 , 3 )); - - rng_free( rng ); - matrix_free( m1 ); - matrix_free( m2 ); - matrix_free( m3 ); -} - - - - -void test_create_invalid() { - test_assert_NULL( matrix_alloc(0, 100)); - test_assert_NULL( matrix_alloc(100, 0)); - test_assert_NULL( matrix_alloc(0, 0)); - test_assert_NULL( matrix_alloc(-1, -1)); -} - - - -void test_dims() { - const int rows = 10; - const int columns = 13; - matrix_type * m = matrix_alloc(rows , columns); - - test_assert_true( matrix_check_dims(m , rows , columns)); - test_assert_false( matrix_check_dims(m , rows + 1 , columns)); - test_assert_false( matrix_check_dims(m , rows , columns + 1)); - - matrix_free( m ); -} - - - - -void test_readwrite() { - test_work_area_type * test_area = test_work_area_alloc("matrix-test"); - { - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc(3 , 3); - matrix_type * m2 = matrix_alloc(3 , 3); - matrix_random_init( m1 , rng ); - matrix_assign(m2 , m1); - - test_assert_true( matrix_equal( m1 , m2 ) ); - { - FILE * stream = util_fopen("m1" , "w"); - matrix_fwrite( m1 , stream ); - fclose( stream ); - } - matrix_random_init( m1 , rng ); - test_assert_false( matrix_equal( m1 , m2 ) ); - { - FILE * stream = util_fopen("m1" , "r"); - matrix_free( m1 ); - m1 = matrix_alloc(1,1); - printf("-----------------------------------------------------------------\n"); - matrix_fread( m1 , stream ); - test_assert_int_equal( matrix_get_rows(m1) , matrix_get_rows( m2)); - test_assert_int_equal( matrix_get_columns(m1) , matrix_get_columns( m2)); - util_fseek( stream , 0 , SEEK_SET); - { - matrix_type * m3 = matrix_fread_alloc( stream ); - test_assert_true( matrix_equal( m2 , m3 )); - matrix_free( m3 ); - } - fclose( stream ); - } - test_assert_true( matrix_equal( m1 , m2 ) ); - - matrix_free( m2 ); - matrix_free( m1 ); - rng_free( rng ); - } - test_work_area_free( test_area ); -} - - -void test_diag_std() { - const int N = 25; - double_vector_type * data = double_vector_alloc( 0,0); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m = matrix_alloc( N , N ); - double sum1 = 0; - double sum2 = 0; - int i; - - for (i=0; i < N; i++) { - double R = rng_get_double( rng ); - matrix_iset(m , i , i , R); - double_vector_iset( data , i , R ); - - sum1 += R; - sum2 += R*R; - } - { - double mean = sum1 / N; - double std = sqrt( sum2 / N - mean * mean ); - - test_assert_double_equal( std , matrix_diag_std( m , mean )); - test_assert_double_equal( statistics_std( data ) , matrix_diag_std( m , mean )); - test_assert_double_equal( statistics_mean( data ) , mean ); - } - matrix_free( m ); - rng_free( rng ); -} - - - -void test_masked_copy() { - const int N = 25; - bool_vector_type * mask = bool_vector_alloc(N , true); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc( N , N ); - matrix_random_init( m1 , rng ); - - bool_vector_iset( mask , 0 , false ); - bool_vector_iset( mask , 10 , false ); - - { - matrix_type * m2 = matrix_alloc_column_compressed_copy( m1 , mask ); - matrix_type * m3 = matrix_alloc( N , N - 2 ); - - test_assert_int_equal( matrix_get_rows( m1 ) , matrix_get_rows( m2 )); - test_assert_int_equal( matrix_get_columns( m1 ) , matrix_get_columns( m2 ) + 2); - - matrix_column_compressed_memcpy( m3 , m1 , mask ); - { - int src_col; - int target_col = 0; - for (src_col = 0; src_col < N; src_col++) { - if (bool_vector_iget( mask , src_col)) { - test_assert_true( matrix_columns_equal( m1 , src_col , m3 , target_col )); - target_col++; - } - } - } - - test_assert_true( matrix_equal( m2 , m3 )); - matrix_free( m3 ); - matrix_free( m2 ); - } - - matrix_free( m1 ); - rng_free( rng ); -} - - -void test_inplace_sub_column() { - const int N = 25; - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc( N , N ); - matrix_type * m2 = matrix_alloc( N , N ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - matrix_inplace_sub_column( m1 , m2 , 0 , 0 ); - { - int row; - for (row = 0; row < N; row++) { - double diff = matrix_iget( m1 , row , 0); - test_assert_true( fabs( diff ) < 1e-6); - } - } -} - - -int main( int argc , char ** argv) { - test_create_invalid(); - test_resize(); - test_column_equal(); - test_dims(); - - test_readwrite(); - test_diag_std(); - test_masked_copy(); - test_inplace_sub_column(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c deleted file mode 100644 index 233a46c711..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'ert_util_matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - - - -void test_det4() { - matrix_type * m = matrix_alloc(4 , 4 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - for (int i=0; i < 10; i++) { - matrix_random_init( m , rng ); - { - double det4 = matrix_det4( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det4 ); - } - } - - matrix_free( m ); - rng_free( rng ); -} - - -void test_det3() { - matrix_type * m = matrix_alloc(3 , 3 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_random_init( m , rng ); - - { - double det3 = matrix_det3( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det3 ); - } - - matrix_free( m ); - rng_free( rng ); -} - - -void test_det2() { - matrix_type * m = matrix_alloc(2,2); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_random_init( m , rng ); - { - double det2 = matrix_det2( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det2 ); - } - matrix_free( m ); - rng_free( rng ); -} - - - -int main( int argc , char ** argv) { - test_det2(); - test_det3(); - test_det4(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c deleted file mode 100644 index 6e2ce86bf5..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'ert_util_matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include - - - -void test_invalid_dimensions() { - matrix_type * X = matrix_alloc(10,2); - matrix_type * Y = matrix_alloc(11,1); - matrix_type * S = matrix_alloc(10,1); - matrix_type * beta = matrix_alloc(2,1); - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_INVALID_DIM ); - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_INVALID_DIM ); - - matrix_resize(beta , 4 , 1 , false ); - matrix_resize(Y , 3 , 1 , false ); - matrix_resize(X , 3 , 4 , false ); - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_UNDETERMINED ); - - matrix_free( Y ); - matrix_free( S ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_no_sigma() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,P); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , 1 ); - matrix_iset( X , i , 1 , x ); - matrix_iset( X , i , 2 , x*x ); - - matrix_iset( Y , i , 0 , y); - } - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_with_sigma() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,P); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - matrix_type * S = matrix_alloc(size,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , 1 ); - matrix_iset( X , i , 1 , x ); - matrix_iset( X , i , 2 , x*x ); - - matrix_iset( Y , i , 0 , y); - matrix_iset( S , i , 0 , 1); - } - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - matrix_free( S ); - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_polyfit() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,1); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , x ); - matrix_iset( Y , i , 0 , y); - } - - test_assert_true( matrix_stat_polyfit( beta , X , Y , NULL) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - - - - -int main() { - util_install_signals(); - test_invalid_dimensions(); - test_no_sigma(); - test_with_sigma(); - test_polyfit(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c b/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c deleted file mode 100644 index 7a40e4e145..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_time_interval.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include - - - -int main( int argc , char ** argv) { - time_t start_time = util_make_date_utc(1,1,2000); - time_t end_time = util_make_date_utc(1,1,2010); - time_t in = util_make_date_utc( 1,1,2005); - time_t before = util_make_date_utc( 1,1,1995); - time_t after = util_make_date_utc( 1,1,2015); - - { - time_interval_type * ti = time_interval_alloc( start_time , end_time ); - test_assert_not_NULL( ti ); - test_assert_false( time_interval_is_empty( ti )); - - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_contains( ti , in )); - test_assert_false( time_interval_contains( ti , before )); - test_assert_false( time_interval_contains( ti , end_time )); - test_assert_false( time_interval_contains( ti , after )); - - test_assert_false( time_interval_update( ti , end_time , start_time )); - test_assert_true( time_interval_is_empty( ti )); - - test_assert_false( time_interval_contains( ti , start_time )); - test_assert_false( time_interval_contains( ti , in )); - test_assert_false( time_interval_contains( ti , before )); - test_assert_false( time_interval_contains( ti , end_time )); - test_assert_false( time_interval_contains( ti , after )); - - test_assert_true( time_interval_update( ti , start_time , end_time )); - test_assert_false( time_interval_is_empty( ti )); - - time_interval_free( ti ); - } - - { - time_interval_type * ti = time_interval_alloc( end_time , start_time ); - test_assert_not_NULL( ti ); - test_assert_true( time_interval_is_empty( ti )); - test_assert_true( time_interval_update( ti , start_time , end_time )); - test_assert_false( time_interval_is_empty( ti )); - time_interval_free( ti ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , after ); - time_interval_type * t3 = time_interval_alloc( end_time , start_time ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - time_interval_type * t5 = time_interval_alloc( end_time , after ); - - test_assert_true( time_interval_has_overlap( t1 , t2 )); - - test_assert_true( time_interval_is_empty( t3 )); - test_assert_false( time_interval_has_overlap( t1 , t3 )); - test_assert_false( time_interval_has_overlap( t3 , t1 )); - test_assert_false( time_interval_has_overlap( t3 , t3 )); - test_assert_false( time_interval_has_overlap( t4 , t5 )); - test_assert_false( time_interval_has_overlap( t1 , t5 )); - - - time_interval_free( t1 ); - time_interval_free( t2 ); - } - - { - time_interval_type * ti = time_interval_alloc_open(); - - test_assert_false( time_interval_is_empty( ti )); - - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_contains( ti , in )); - test_assert_true( time_interval_contains( ti , before )); - test_assert_true( time_interval_contains( ti , end_time )); - test_assert_true( time_interval_contains( ti , after )); - - test_assert_true( time_interval_update_start( ti , start_time )); - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_update_start( ti , in )); - test_assert_false( time_interval_contains( ti , start_time )); - test_assert_false( time_interval_is_empty( ti )); - - test_assert_false( time_interval_update_end( ti , start_time )); - test_assert_true( time_interval_is_empty( ti )); - test_assert_true( time_interval_update_end( ti , end_time )); - test_assert_false( time_interval_is_empty( ti )); - test_assert_false( time_interval_contains( ti , start_time )); - - time_interval_free( ti ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - test_assert_false( time_interval_is_empty( t1 )); - - test_assert_false( time_interval_update_end( t1 , before )); - test_assert_true( time_interval_is_empty( t1 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( before , time_interval_get_end( t1 )); - - test_assert_true( time_interval_update_end( t1 , in )); - test_assert_false( time_interval_is_empty( t1 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( in , time_interval_get_end( t1 )); - - time_interval_free( t1 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , in ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( start_time , end_time); - - test_assert_true( time_interval_is_adjacent( t1 , t2 )); - test_assert_true( time_interval_is_adjacent( t2 , t1 )); - - test_assert_false( time_interval_is_adjacent( t1 , t3 )); - test_assert_false( time_interval_is_adjacent( t3 , t1 )); - test_assert_false( time_interval_is_adjacent( t2 , t3 )); - test_assert_false( time_interval_is_adjacent( t3 , t2 )); - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - } - - - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - - test_assert_true( time_interval_extend(t1 , t2 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - - test_assert_true( time_interval_extend(t1 , t3 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - test_assert_true( time_interval_update_start(t1 , in )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - - - test_assert_false( time_interval_extend(t1 , t4 )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - - test_assert_true( time_interval_update_end(t4 , in )); - test_assert_true( time_interval_extend(t1 , t4 )); - test_assert_time_t_equal( before , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - - test_assert_true( time_interval_intersect(t1 , t2 )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( start_time , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc_copy( t1 ); - - test_assert_true( time_interval_equal( t1 , t2 )); - test_assert_false( time_interval_equal( t1 , t3 )); - - test_assert_true( time_interval_equal( t4 , t2 )); - test_assert_false( time_interval_equal( t4 , t3 )); - - test_assert_ptr_not_equal( t4 , t1 ); - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - - test_assert_true( time_interval_arg_before( t1 , before )); - test_assert_true( time_interval_arg_after( t1 , after)); - - test_assert_false( time_interval_arg_before( t1 , start_time )); - test_assert_false( time_interval_arg_before( t1 , in )); - test_assert_false( time_interval_arg_before( t1 , after )); - - test_assert_false( time_interval_arg_after( t1 , start_time)); - test_assert_false( time_interval_arg_after( t1 , in)); - test_assert_true( time_interval_arg_after( t1 , after)); - - time_interval_free( t1 ); - } - - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c b/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c deleted file mode 100644 index 82a711d12d..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_ui_return_type.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - -#include -#include - - - - -void test_create() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - test_assert_true( ui_return_is_instance( ui_return )); - test_assert_int_equal( status , ui_return_get_status(ui_return)); - ui_return_free( ui_return ); -} - - -void test_default() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_NULL( ui_return_get_first_error( ui_return)); - test_assert_NULL( ui_return_get_last_error( ui_return)); - test_assert_NULL( ui_return_get_help(ui_return)); - ui_return_free( ui_return); -} - -void test_errors_inconsistent() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_false( ui_return_add_error( ui_return , "ERROR1")); - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - ui_return_free( ui_return); -} - - -void test_errors_consistent() { - ui_return_status_enum status = UI_RETURN_FAIL; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_true( ui_return_add_error( ui_return , "ERROR1")); - test_assert_int_equal(1, ui_return_get_error_count(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_first_error(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_last_error(ui_return)); - - test_assert_true(ui_return_add_error(ui_return, "ERROR2")); - test_assert_int_equal(2, ui_return_get_error_count(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_first_error(ui_return)); - test_assert_string_equal("ERROR2", ui_return_get_last_error(ui_return)); - - test_assert_string_equal("ERROR1" , ui_return_iget_error(ui_return , 0)); - test_assert_string_equal("ERROR2" , ui_return_iget_error(ui_return , 1)); - - ui_return_free( ui_return); -} - - -void test_help() { - ui_return_type * ui_return = ui_return_alloc(UI_RETURN_OK); - - ui_return_add_help(ui_return , "HELP1"); - test_assert_string_equal( "HELP1" , ui_return_get_help(ui_return)); - - ui_return_add_help(ui_return , "HELP2"); - test_assert_string_equal( "HELP1 HELP2" , ui_return_get_help(ui_return)); - - ui_return_free( ui_return); -} - -int main(int argc , char ** argv) { - test_create(); - test_default(); - test_errors_inconsistent(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/thread_pool1.c b/ThirdParty/Ert/lib/util/thread_pool1.c deleted file mode 100644 index d365a67e30..0000000000 --- a/ThirdParty/Ert/lib/util/thread_pool1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool1.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include -#include -#include - -struct thread_pool_struct { - int pool_size; - int jobs_running; - pthread_t *thread_list; -}; - - - - - -static void thread_pool_resize(thread_pool_type * pool, int new_size) { - pool->pool_size = new_size; - pool->thread_list = realloc(pool->thread_list , new_size * sizeof * pool->thread_list); -} - - - -void thread_pool_join(thread_pool_type * pool) { - int i; - if (pool->pool_size == 0) - return; - else { - for (i=0; i < pool->jobs_running; i++) - pthread_join(pool->thread_list[i] , NULL); /* Second argument: void **value_ptr */ - pool->jobs_running = 0; - } -} - - -thread_pool_type * thread_pool_alloc(int pool_size) { - thread_pool_type * pool = util_malloc(sizeof *pool); - pool->thread_list = NULL; - thread_pool_resize(pool , pool_size); - pool->jobs_running = 0; - return pool; -} - - - -void thread_pool_add_job(thread_pool_type * pool , - void * (start_func) (void *) , void *arg) { - - if (pool->pool_size == 0) - start_func(arg); - else { - - if (pool->jobs_running == pool->pool_size) - thread_pool_join(pool); - - { - int pthread_return = pthread_create( &pool->thread_list[pool->jobs_running] , NULL , start_func , arg); - if (pthread_return != 0) - util_abort("%s: failed to add new job pthread_create return value: %d.\n",__func__ , pthread_return); - } - - pool->jobs_running++; - } - -} - -void thread_pool_free(thread_pool_type * pool) { - if (pool->thread_list != NULL) free(pool->thread_list); - free(pool); -} - - diff --git a/ThirdParty/Ert/lib/util/thread_pool_posix.c b/ThirdParty/Ert/lib/util/thread_pool_posix.c deleted file mode 100644 index 8288013b48..0000000000 --- a/ThirdParty/Ert/lib/util/thread_pool_posix.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool_posix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ -#include -#include -#include -#include -#include -#include - -#include "ert/util/build_config.h" - -#include -#include -#include - - -/** - This file implements a small thread_pool object based on - pthread_create() function calls. The characetristics of this - implementation is as follows: - - 1. The jobs are mangaged by a separate thread - dispatch_thread. - 2. The new jobs are just appended to the queue, the - dispatch_thread sees them in the queue and dispatches them. - 3. The dispatch thread manages a list of thread_pool_job_slot_type - instances - one slot for each actually running job. - - Example - ------- - - 1. Start with creating a thread pool object. The arguments to the - allocater are the (maximum) number of concurrently running - threads and a boolean flag of whether the queue should start - immediately (that is in general the case). - - thread_pool_type * tp = thread_pool_alloc( NUM_THREADS , immediate_start); - - - 2. Add the jobs you want to run: - - thread_pool_add_job( tp , some_function , argument_to_some_function ); - - Here the prototype for the function which is being run is - - void * (some_func) (void *); - - I.e. it expects a (void *) input pointer, and also returns a - (void *) pointer as output. The thread pool implementation does - not touch the input and output of some_function. - - - 3. When all the jobs have been added you inform the thread pool of - that by calling: - - thread_pool_join( tp ); - - This function will not return before all the added jobs have run - to completion. - - - 4. Optional: If you want to get the return value from the function - you supplied, you can use: - - thread_pool_iget_return_value( tp , index ); - - To get the return value from function nr index. - - - 5. Optional: The thread pool will probably mainly be used only once, - but after a join it is possible to reuse a thread pool, but then - you MUST call thread_pool_restart() before adding jobs again. - - - 6. When you are really finished: thread_pool_free( tp ); - -*/ - - -typedef void * (start_func_ftype) (void *) ; - - -/** - Internal struct which is used as queue node. -*/ -typedef struct { - thread_pool_type * pool; /* A back-reference to the thread_pool holding the queue. */ - int slot_index; /* The index in the space [0,max_running) of the job slot where this job is running. */ - int queue_index; /* The index of the current tp_arg in the queue. */ - void * func_arg; /* The arguments to this job - supplied by the calling scope. */ - start_func_ftype * func; /* The function to call - supplied by the calling scope. */ - void * return_value; -} thread_pool_arg_type; - - - -/** - Internal struct used to keep track of the job slots. -*/ -typedef struct { - pthread_t thread; /* The thread variable currently (or more correct:last) running. */ - int run_count; /* The number of times this slot has been used - just to check whether the slot has been used AT ALL when/if joining. */ - bool running; /* Is the job_slot running now?? */ -} thread_pool_job_slot_type; - - - - -#define THREAD_POOL_TYPE_ID 71443207 -struct thread_pool_struct { - UTIL_TYPE_ID_DECLARATION; - thread_pool_arg_type * queue; /* The jobs to be executed are appended in this vector. */ - int queue_index; /* The index of the next job to run. */ - int queue_size; /* The number of jobs in the queue - including those which are complete. [Should be protected / atomic / ... ] */ - int queue_alloc_size; /* The allocated size of the queue. */ - - int max_running; /* The max number of concurrently running jobs. */ - bool join; /* Flag set by the main thread to inform the dispatch thread that joining should start. */ - bool accepting_jobs; /* True|False whether the dispatch thread is running. */ - - thread_pool_job_slot_type * job_slots; /* A vector to @max_running job slots, each slot can be reused several times.*/ - pthread_t dispatch_thread; - pthread_rwlock_t queue_lock; -}; - - -static UTIL_SAFE_CAST_FUNCTION( thread_pool , THREAD_POOL_TYPE_ID ) - - -/** - This function will grow the queue. It is called by the main thread - (i.e. the context of the calling scope), and the queue is read by - the dispatch_thread - i.e. access to the queue must be protected by - rwlock. -*/ - -static void thread_pool_resize_queue( thread_pool_type * pool, int queue_length ) { - pthread_rwlock_wrlock( &pool->queue_lock ); - { - pool->queue = (thread_pool_arg_type*)util_realloc( pool->queue , queue_length * sizeof * pool->queue ); - pool->queue_alloc_size = queue_length; - } - pthread_rwlock_unlock( &pool->queue_lock ); -} - - -/** - This function updates an element in the queue, the function is - called by the executing threads, on the same time the main thread - might be resizing the thread, we therefor take a read lock during - execution of this function. (Write lock is not necessary because we - will not change the queue pointer itself, only something it points - to.) -*/ - -static void thread_pool_iset_return_value( thread_pool_type * pool , int index , void * return_value) { - pthread_rwlock_rdlock( &pool->queue_lock ); - { - pool->queue[ index ].return_value = return_value; - } - pthread_rwlock_unlock( &pool->queue_lock ); -} - - -void * thread_pool_iget_return_value( const thread_pool_type * pool , int queue_index ) { - return pool->queue[ queue_index ].return_value; -} - - -/** - The pthread_create() call which this is all about, does not start - the user supplied function. Instead it will start an instance of - this function, which will do some housekeeping before calling the - user supplied function. -*/ - -static void * thread_pool_start_job( void * arg ) { - thread_pool_arg_type * tp_arg = (thread_pool_arg_type * ) arg; - thread_pool_type * tp = tp_arg->pool; - int slot_index = tp_arg->slot_index; - void * func_arg = tp_arg->func_arg; - start_func_ftype * func = tp_arg->func; - void * return_value; - - - return_value = func( func_arg ); /* Starting the real external function */ - tp->job_slots[ slot_index ].running = false; /* We mark the job as completed. */ - free( arg ); - - if (return_value != NULL) - thread_pool_iset_return_value( tp , tp_arg->queue_index , return_value); - - return NULL; -} - - - -/** - This function is run by the dispatch_thread. The thread will keep - an eye on the queue, and dispatch new jobs when there are free - slots available. -*/ - -static void * thread_pool_main_loop( void * arg ) { - thread_pool_type * tp = thread_pool_safe_cast( arg ); - { - const int usleep_init = 1000; /* The sleep time when there are free slots available - but no jobs wanting to run. */ - int internal_offset = 0; /* Keep track of the (index of) the last job slot fired off - minor time saving. */ - while (true) { - if (tp->queue_size > tp->queue_index) { - /* - There are jobs in the queue which would like to run - - let us see if we can find a slot for them. - */ - int counter = 0; - bool slot_found = false; - do { - int slot_index = (counter + internal_offset) % tp->max_running; - thread_pool_job_slot_type * job_slot = &tp->job_slots[ slot_index ]; - if (!job_slot->running) { - /* OK thread[slot_index] is ready to take this job.*/ - thread_pool_arg_type * tp_arg; - - /* - The queue might be updated by the main thread - we must - take a copy of the node we are interested in. - */ - pthread_rwlock_rdlock( &tp->queue_lock ); - tp_arg = (thread_pool_arg_type*)util_alloc_copy( &tp->queue[ tp->queue_index ] , sizeof * tp_arg ); - pthread_rwlock_unlock( &tp->queue_lock ); - - tp_arg->slot_index = slot_index; - job_slot->running = true; - /* - Here is the actual pthread_create() call creating an - additional running thread. - */ - - /*Cleanup of previous run threads. Needed to avoid memory leak*/ - if (job_slot->run_count > 0) - pthread_join(job_slot->thread, NULL); - - pthread_create( &job_slot->thread , NULL , thread_pool_start_job , tp_arg ); - job_slot->run_count += 1; - tp->queue_index++; - internal_offset += (counter + 1); - slot_found = true; - } else - counter++; - } while (!slot_found && (counter < tp->max_running)); - - if (!slot_found) { - util_yield(); - } - } else - util_usleep(usleep_init); /* There are no jobs wanting to run. */ - - /*****************************************************************/ - /* - We exit explicitly from this loop when both conditions apply: - - 1. tp->join == true : The calling scope has signaled that it will not submit more jobs. - 2. tp->queue_size == tp->queue_index : This function has submitted all the jobs in the queue. - */ - if ((tp->join) && (tp->queue_size == tp->queue_index)) - break; - } /* End of while() loop */ - } - - /* - There are no more jobs in the queue, and the main scope has - signaled that join should start. Observe that we join only the - jobs corresponding to explicitly running job_slots; when a job - slot is used multiple times the first jobs run in the job_slot - will not be explicitly joined. - */ - { - int i; - for (i=0; i < tp->max_running; i++) { - thread_pool_job_slot_type job_slot = tp->job_slots[i]; - if (job_slot.run_count > 0) - pthread_join( job_slot.thread , NULL ); - } - } - /* When we are here all the jobs have completed. */ - return NULL; -} - - - - -/** - This function initializes a couple of counters, and starts up the - dispatch thread. If the thread_pool should be reused after a join, - this function must be called before adding new jobs. - - The functions thread_pool_restart() and thread_pool_join() should - be joined up like open/close and malloc/free combinations. -*/ - -void thread_pool_restart( thread_pool_type * tp ) { - if (tp->accepting_jobs) - util_abort("%s: fatal error - tried restart already running thread pool\n",__func__); - { - tp->join = false; - tp->queue_index = 0; - tp->queue_size = 0; - { - int i; - for (i=0; i < tp->max_running; i++) { - tp->job_slots[i].run_count = 0; - tp->job_slots[i].running = false; - } - } - - /* Starting the dispatch thread. */ - pthread_create( &tp->dispatch_thread , NULL , thread_pool_main_loop , tp ); - tp->accepting_jobs = true; - } -} - - - -/** - This function is called by the calling scope when all the jobs have - been submitted, and we just wait for them to complete. - - This function just sets the join switch to true - this again tells - the dispatch_thread to start the join process on the worker - threads. -*/ - -void thread_pool_join(thread_pool_type * pool) { - pool->join = true; /* Signals to the main thread that joining can start. */ - if (pool->max_running > 0) { - pthread_join( pool->dispatch_thread , NULL ); /* Wait for the main thread to complete. */ - pool->accepting_jobs = false; - } -} - -/* - This will try to join the thread; if the manager thread has not - completed within @timeout_seconds the function will return false. If - the join fails the queue will be reset in a non-joining state and it - will be open for more jobs. Probably not in a 100% sane state. -*/ - -bool thread_pool_try_join(thread_pool_type * pool, int timeout_seconds) { - bool join_ok = true; - - pool->join = true; /* Signals to the main thread that joining can start. */ - if (pool->max_running > 0) { - time_t timeout_time = time( NULL ); - util_inplace_forward_seconds_utc(&timeout_time , timeout_seconds ); - -#ifdef HAVE_TIMEDJOIN - - struct timespec ts; - ts.tv_sec = timeout_time; - ts.tv_nsec = 0; - - { - int join_return = pthread_timedjoin_np( pool->dispatch_thread , NULL , &ts); /* Wait for the main thread to complete. */ - if (join_return == 0) - pool->accepting_jobs = false; - else { - pool->join = false; - join_ok = false; - } - } - -#else - - while(true) { - if (pthread_kill(pool->dispatch_thread, 0) == 0){ - util_yield(); - } else { - pthread_join(pool->dispatch_thread, NULL); - pool->accepting_jobs = false; - break; - } - - time_t now = time(NULL); - - if(util_difftime_seconds(now, timeout_time) <= 0) { - join_ok = false; - break; - } - } - -#endif - - - - } - return join_ok; -} - - - - -/** - max_running is the maximum number of concurrent threads. If - @start_queue is true the dispatch thread will start immediately. If - the function is called with @start_queue == false you must first - call thread_pool_restart() BEFORE you can start adding jobs. -*/ - -thread_pool_type * thread_pool_alloc(int max_running , bool start_queue) { - thread_pool_type * pool = (thread_pool_type*)util_malloc( sizeof *pool ); - UTIL_TYPE_ID_INIT( pool , THREAD_POOL_TYPE_ID ); - pool->job_slots = (thread_pool_job_slot_type*)util_calloc( max_running , sizeof * pool->job_slots ); - pool->max_running = max_running; - pool->queue = NULL; - pool->accepting_jobs = false; - pthread_rwlock_init( &pool->queue_lock , NULL); - thread_pool_resize_queue( pool , 32 ); - if (start_queue) - thread_pool_restart( pool ); - return pool; -} - - - -void thread_pool_add_job(thread_pool_type * pool , start_func_ftype * start_func , void * func_arg ) { - if (pool->max_running == 0) /* Blocking non-threaded mode: */ - start_func( func_arg ); - else { - if (pool->accepting_jobs) { - if (pool->queue_size == pool->queue_alloc_size) - thread_pool_resize_queue( pool , pool->queue_alloc_size * 2); - - /* - The new job is added to the queue - the main thread is watching - the queue and will pick up the new job. - */ - { - int queue_index = pool->queue_size; - - pool->queue[ queue_index ].pool = pool; - pool->queue[ queue_index ].func_arg = func_arg; - pool->queue[ queue_index ].func = start_func; - pool->queue[ queue_index ].return_value = NULL; - pool->queue[ queue_index ].queue_index = queue_index; - } - pool->queue_size++; /* <- This is shared between this thread and the dispatch thread */ - } else - util_abort("%s: thread_pool is not running - restart with thread_pool_restart()?? \n",__func__); - } -} - - - -/* - Observe that this function does not join the worker threads, - i.e. you should call thread_pool_join() first (otherwise the thing - will go up in flames). -*/ - - -void thread_pool_free(thread_pool_type * pool) { - util_safe_free( pool->job_slots ); - util_safe_free( pool->queue ); - free(pool); -} - -int thread_pool_get_max_running( const thread_pool_type * pool ) { - return pool->max_running; -} diff --git a/ThirdParty/Ert/lib/util/time_interval.c b/ThirdParty/Ert/lib/util/time_interval.c deleted file mode 100644 index 32d1a9be54..0000000000 --- a/ThirdParty/Ert/lib/util/time_interval.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'time_interval.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include -#include - -#define TIME_INTERVAL_EMPTY (time_t) -1 -#define TIME_T_MAX (time_t) ((1UL << (( sizeof(time_t) << 3) -1 )) -1 ) -#define TIME_T_MIN -TIME_T_MAX - - -struct time_interval_struct { - bool valid; - time_t start_time; - time_t end_time; -}; - - -/* - If you set something invalid - the whole interval is destroyed. -*/ - -bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time) { - ti->start_time = start_time; - ti->end_time = end_time; - - ti->valid = (start_time <= end_time) ? true : false; - return ti->valid; -} - - -bool time_interval_update_start( time_interval_type * ti , time_t start_time ) { - return time_interval_update( ti , start_time , ti->end_time ); -} - - -bool time_interval_update_end( time_interval_type * ti , time_t end_time ) { - return time_interval_update( ti , ti->start_time , end_time ); -} - - -void time_interval_reopen( time_interval_type * time_interval) { - time_interval_update( time_interval , TIME_T_MIN , TIME_T_MAX); -} - - -time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ) { - time_interval_type * ti = (time_interval_type*)util_malloc( sizeof * ti ); - time_interval_update( ti , start_time , end_time ); - return ti; -} - - -time_interval_type * time_interval_alloc_open( ) { - return time_interval_alloc( TIME_T_MIN , TIME_T_MAX ); -} - -time_interval_type * time_interval_alloc_copy( const time_interval_type * src) { - return time_interval_alloc( src->start_time , src->end_time ); -} - - -void time_interval_free( time_interval_type * ti ) { - free( ti ); -} - - -bool time_interval_is_empty( time_interval_type * ti ) { - return (ti->end_time <= ti->start_time); -} - - -bool time_interval_contains( const time_interval_type * ti , time_t t) { - if (!ti->valid) - return false; - else { - if (t < ti->start_time) - return false; - else if (t >= ti->end_time) - return false; - else - return true; - } -} - - - -bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2) { - if (t1->valid && t2->valid) { - if (time_interval_contains(t1 , t2->start_time)) - return true; - - if (time_interval_contains(t1 , t2->end_time)) - return true; - - return false; - } else - return false; -} - -bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2) { - if ((t1->end_time == t2->start_time) || (t1->start_time == t2->end_time)) - return true; - else - return false; -} - - -time_t time_interval_get_start( const time_interval_type * ti) { - return ti->start_time; -} - - - -time_t time_interval_get_end( const time_interval_type * ti) { - return ti->end_time; -} - - -bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2) { - if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { - time_t start_time = util_time_t_min( t1->start_time , t2->start_time ); - time_t end_time = util_time_t_max( t1->end_time , t2->end_time ); - - return time_interval_update(t1 , start_time , end_time); - } else - return false; -} - - -bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2) { - if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { - time_t start_time = util_time_t_max( t1->start_time , t2->start_time ); - time_t end_time = util_time_t_min( t1->end_time , t2->end_time ); - - return time_interval_update(t1 , start_time , end_time); - } else - return false; -} - - -bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2) { - if ((t1->start_time == t2->start_time) && (t1->end_time == t2->end_time)) - return true; - else - return false; -} - - -bool time_interval_arg_after( const time_interval_type * ti , time_t arg) { - return util_after( arg , ti->end_time ); -} - - -bool time_interval_arg_before( const time_interval_type * ti , time_t arg) { - return util_before( arg , ti->start_time ); -} diff --git a/ThirdParty/Ert/lib/util/timer.c b/ThirdParty/Ert/lib/util/timer.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/timer.c rename to ThirdParty/Ert/lib/util/timer.cpp index e4672fa7c9..49dd562754 100644 --- a/ThirdParty/Ert/lib/util/timer.c +++ b/ThirdParty/Ert/lib/util/timer.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/type_vector_functions.c b/ThirdParty/Ert/lib/util/type_vector_functions.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/type_vector_functions.c rename to ThirdParty/Ert/lib/util/type_vector_functions.cpp index 8aab49197b..2dec9f3f1e 100644 --- a/ThirdParty/Ert/lib/util/type_vector_functions.c +++ b/ThirdParty/Ert/lib/util/type_vector_functions.cpp @@ -18,11 +18,11 @@ #include -#include -#include -#include +#include +#include +#include -#include +#include int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ) { diff --git a/ThirdParty/Ert/lib/util/ui_return.c b/ThirdParty/Ert/lib/util/ui_return.c deleted file mode 100644 index e1b30f8e80..0000000000 --- a/ThirdParty/Ert/lib/util/ui_return.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - - * - * Created on: Aug 28, 2013 - * Author: joaho - */ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ui_return.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - -#include -#include -#include -#include - - -#define UI_RETURN_TYPE_ID 6122209 - -struct ui_return_struct { - UTIL_TYPE_ID_DECLARATION; - ui_return_status_enum status; - stringlist_type * error_list; - char * help_text; -}; - - -UTIL_IS_INSTANCE_FUNCTION(ui_return , UI_RETURN_TYPE_ID) - - -ui_return_type * ui_return_alloc(ui_return_status_enum status) { - ui_return_type * ui_return = (ui_return_type*)util_malloc( sizeof * ui_return ); - UTIL_TYPE_ID_INIT(ui_return , UI_RETURN_TYPE_ID); - ui_return->status = status; - ui_return->help_text = NULL; - ui_return->error_list = stringlist_alloc_new(); - return ui_return; -} - - -void ui_return_free( ui_return_type * ui_return ) { - stringlist_free(ui_return->error_list); - util_safe_free( ui_return->help_text); - free( ui_return); -} - - -ui_return_status_enum ui_return_get_status(const ui_return_type * ui_return) { - return ui_return->status; -} - - -bool ui_return_add_error(ui_return_type *ui_return , const char * error_msg) { - if (ui_return->status != UI_RETURN_OK) - stringlist_append_copy( ui_return->error_list , error_msg); - - return (ui_return->status != UI_RETURN_OK); -} - - -int ui_return_get_error_count( const ui_return_type * ui_return ) { - return stringlist_get_size( ui_return->error_list ); -} - - -const char * ui_return_get_first_error( const ui_return_type * ui_return) { - if (stringlist_get_size(ui_return->error_list)) - return stringlist_front( ui_return->error_list); - else - return NULL; -} - - -const char * ui_return_get_last_error( const ui_return_type * ui_return) { - if (stringlist_get_size(ui_return->error_list)) - return stringlist_back( ui_return->error_list); - else - return NULL; -} - -const char * ui_return_iget_error( const ui_return_type * ui_return , int index) { - return stringlist_iget(ui_return->error_list , index); -} - - -const char * ui_return_get_help(const ui_return_type * ui_return) { - return ui_return->help_text; -} - - -void ui_return_add_help(ui_return_type * ui_return, const char * help_text) { - if (ui_return->help_text) { - int new_length = strlen(ui_return->help_text) + strlen(help_text) + 1 + 1; - ui_return->help_text = (char*)util_realloc(ui_return->help_text , new_length * sizeof * ui_return->help_text); - - strcat(ui_return->help_text , " "); - strcat(ui_return->help_text , help_text); - } else - ui_return->help_text = util_alloc_string_copy( help_text); -} - - diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 8b301cb4e1..94e42f9c81 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -284,7 +284,8 @@ static bool EOL_CHAR(char c) { numbers, but deterministic runtime. */ -void util_fread_dev_random(int buffer_size , char * buffer) { +void util_fread_dev_random(int buffer_size_ , char * buffer) { + size_t buffer_size = buffer_size_; FILE * stream = util_fopen("/dev/random" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); @@ -293,7 +294,8 @@ void util_fread_dev_random(int buffer_size , char * buffer) { } -void util_fread_dev_urandom(int buffer_size , char * buffer) { +void util_fread_dev_urandom(int buffer_size_ , char * buffer) { + size_t buffer_size = buffer_size_; FILE * stream = util_fopen("/dev/urandom" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); @@ -401,7 +403,8 @@ bool util_double_approx_equal( double d1 , double d2) { } -char * util_alloc_substring_copy(const char *src , int offset , int N) { +char * util_alloc_substring_copy(const char *src , int offset , int N_) { + size_t N = N_; char *copy; if ((N + offset) < strlen(src)) { copy = (char*)util_calloc(N + 1 , sizeof * copy ); @@ -461,7 +464,7 @@ char * util_realloc_dequoted_string(char *s) { } void util_strupr(char *s) { - int i; + size_t i; for (i=0; i < strlen(s); i++) s[i] = toupper(s[i]); } @@ -478,7 +481,7 @@ char * util_alloc_strupr_copy(const char * s) { Replaces all occurences of c1 in s with c2. */ void util_string_tr(char * s, char c1, char c2) { - int i; + size_t i; for (i=0; i < strlen(s);i++) if (s[i] == c1) s[i] = c2; } @@ -811,11 +814,11 @@ char * util_alloc_realpath__(const char * input_path) { { char ** path_list; - char ** path_stack; + const char ** path_stack; int path_len; util_path_split( abs_path , &path_len , &path_list ); - path_stack = util_malloc( path_len * sizeof * path_stack ); + path_stack = (const char **) util_malloc( path_len * sizeof * path_stack ); for (int i=0; i < path_len; i++) path_stack[i] = NULL; @@ -1135,7 +1138,7 @@ bool util_char_in(char c , int set_size , const char * set) { isspace(). */ bool util_string_isspace(const char * s) { - int index = 0; + size_t index = 0; while (index < strlen(s)) { if (!isspace( s[index] )) return false; @@ -2000,8 +2003,8 @@ char * util_fread_alloc_file_content(const char * filename , int * buffer_size) bool util_copy_stream(FILE *src_stream , FILE *target_stream , size_t buffer_size , void * buffer , bool abort_on_error) { while ( ! feof(src_stream)) { - int bytes_read; - int bytes_written; + size_t bytes_read; + size_t bytes_written; bytes_read = fread (buffer , 1 , buffer_size , src_stream); if (bytes_read < buffer_size && !feof(src_stream)) { @@ -2419,7 +2422,7 @@ bool util_entry_writable( const char * entry ) { -static int util_get_path_length(const char * file) { +static size_t util_get_path_length(const char * file) { if (util_is_directory(file)) return strlen(file); else { @@ -2434,7 +2437,7 @@ static int util_get_path_length(const char * file) { static int util_get_base_length(const char * file) { - int path_length = util_get_path_length(file); + size_t path_length = util_get_path_length(file); const char * base_start; const char * last_point; long character_index; @@ -3304,9 +3307,10 @@ char * util_realloc_string_copy(char * old_string , const char *src ) { } -char * util_realloc_substring_copy(char * old_string , const char *src , int len) { +char * util_realloc_substring_copy(char * old_string , const char *src , int len_) { + size_t len = len_; if (src != NULL) { - int str_len; + size_t str_len; char *copy; if (strlen(src) < len) str_len = strlen(src); @@ -3692,7 +3696,7 @@ void util_binary_split_string(const char * __src , const char * sep_set, bool sp char * src; if (__src != NULL) { - int offset = 0; + size_t offset = 0; int len; /* 1: Remove leading split characters. */ while ((offset < strlen(__src)) && (strchr(sep_set , __src[offset]) != NULL)) @@ -3781,7 +3785,7 @@ void util_binary_split_string_from_max_length(const char * __src , const char * char * second_part = NULL; if (__src != NULL) { char * src; - int pos; + size_t pos; /* Removing leading separators. */ pos = 0; while ((pos < strlen(__src)) && (strchr(sep_set , __src[pos]) != NULL)) @@ -3863,7 +3867,7 @@ int static util_string_replace_inplace__(char ** _buffer , const char * expr , c int len_expr = strlen( expr ); int len_subs = strlen( subs ); int size = strlen(buffer); - int offset = 0; + size_t offset = 0; int match_count = 0; char * match = NULL; @@ -4355,14 +4359,14 @@ FILE * util_mkdir_fopen( const char * filename , const char * mode ) { void util_fwrite(const void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { - int items_written = fwrite(ptr , element_size , items , stream); + size_t items_written = fwrite(ptr , element_size , items , stream); if (items_written != items) util_abort("%s/%s: only wrote %d/%d items to disk - aborting: %s(%d) .\n",caller , __func__ , items_written , items , strerror(errno) , errno); } void util_fread(void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { - int items_read = fread(ptr , element_size , items , stream); + size_t items_read = fread(ptr , element_size , items , stream); if (items_read != items) util_abort("%s/%s: only read %d/%d items from disk - aborting.\n %s(%d) \n",caller , __func__ , items_read , items , strerror(errno) , errno); } @@ -4491,9 +4495,10 @@ void util_fprintf_int(int value , int width , FILE * stream) { -void util_fprintf_string(const char * s , int width , string_alignement_type alignement , FILE * stream) { +void util_fprintf_string(const char * s , int width_ , string_alignement_type alignement , FILE * stream) { char fmt[32]; - int i; + size_t i; + size_t width = width_; if (alignement == left_pad) { i = 0; if (width > strlen(s)) { @@ -4502,7 +4507,7 @@ void util_fprintf_string(const char * s , int width , string_alignement_type ali } fprintf(stream , "%s", s); } else if (alignement == right_pad) { - sprintf(fmt , "%%-%ds" , width); + sprintf(fmt , "%%-%lus" , width); fprintf(stream , fmt , s); } else { int total_pad = width - strlen(s); @@ -4908,7 +4913,7 @@ void util_make_path(const char *_path) { int i = 0; active_path = (char*)util_calloc(strlen(path) + 1 , sizeof * active_path ); do { - int n = strcspn(path , UTIL_PATH_SEP_STRING); + size_t n = strcspn(path , UTIL_PATH_SEP_STRING); if (n < strlen(path)) n += 1; path += n; diff --git a/ThirdParty/Ert/lib/util/util_abort_gnu.c b/ThirdParty/Ert/lib/util/util_abort_gnu.c index 153fff6843..1e651fd8b9 100644 --- a/ThirdParty/Ert/lib/util/util_abort_gnu.c +++ b/ThirdParty/Ert/lib/util/util_abort_gnu.c @@ -179,7 +179,7 @@ static void util_fprintf_backtrace(FILE * stream) { if (util_addr2line_lookup(bt_addr[i], &func_name , &file_name , &line_nr)) { int pad_length; - char * function; + const char * function; // Seems it can return true - but with func_name == NULL?! Static/inlinded functions? if (func_name) function = func_name; @@ -282,7 +282,7 @@ void util_abort__(const char * file , const char * function , int line , const c if (__abort_program_message != NULL) { #if !defined(__GLIBC__) /* allocate a temporary buffer to hold the path */ - char* program_invocation_name = alloca (PATH_MAX); + char* program_invocation_name = (char*)alloca (PATH_MAX); # if defined(__APPLE__) uint32_t buflen = PATH_MAX; _NSGetExecutablePath (program_invocation_name, &buflen); diff --git a/ThirdParty/Ert/lib/util/util_abort_simple.c b/ThirdParty/Ert/lib/util/util_abort_simple.c index 9f7363f414..56586fd994 100644 --- a/ThirdParty/Ert/lib/util/util_abort_simple.c +++ b/ThirdParty/Ert/lib/util/util_abort_simple.c @@ -4,7 +4,7 @@ */ #include #include - +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_endian.c b/ThirdParty/Ert/lib/util/util_endian.cpp similarity index 100% rename from ThirdParty/Ert/lib/util/util_endian.c rename to ThirdParty/Ert/lib/util/util_endian.cpp diff --git a/ThirdParty/Ert/lib/util/util_env.c b/ThirdParty/Ert/lib/util/util_env.c deleted file mode 100644 index 753646b86a..0000000000 --- a/ThirdParty/Ert/lib/util/util_env.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'util_env.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include "ert/util/build_config.h" - -#include -#include -#include - -#ifdef HAVE_POSIX_SETENV -#define PATHVAR_SPLIT ":" - -void util_unsetenv( const char * variable ) { - unsetenv( variable ); -} - -void util_setenv( const char * variable , const char * value) { - int overwrite = 1; - setenv( variable , value , overwrite ); -} - -#else - -#include - -#define PATHVAR_SPLIT ";" -void util_setenv( const char * variable , const char * value) { - SetEnvironmentVariable( variable , NULL ); -} - -void util_unsetenv( const char * variable ) { - util_setenv( variable , NULL ); -} -#endif - -/** - Will return a NULL terminated list char ** of the paths in the PATH - variable. -*/ - -char ** util_alloc_PATH_list() { - char ** path_list = NULL; - char * path_env = getenv("PATH"); - if (path_env != NULL) { - int path_size; - - util_split_string(path_env , PATHVAR_SPLIT , &path_size , &path_list); - path_list = (char**)util_realloc( path_list , (path_size + 1) * sizeof * path_list); - path_list[path_size] = NULL; - } else { - path_list = (char**)util_malloc( sizeof * path_list); - path_list[0] = NULL; - } - return path_list; -} - -/** - This function searches through the content of the (currently set) - PATH variable, and allocates a string containing the full path - (first match) to the executable given as input. - - * If the entered executable already is an absolute path, a copy of - the input is returned *WITHOUT* consulting the PATH variable (or - checking that it exists). - - * If the executable starts with "./" getenv("PWD") is prepended. - - * If the executable is not found in the PATH list NULL is returned. -*/ - - -char * util_alloc_PATH_executable(const char * executable) { - if (util_is_abs_path(executable)) { - if (util_is_executable(executable)) - return util_alloc_string_copy(executable); - else - return NULL; - } else if (strncmp(executable , "./" , 2) == 0) { - char * cwd = util_alloc_cwd(); - char * path = util_alloc_filename(cwd , &executable[2] , NULL); - - /* The program has been invoked as ./xxxx */ - if (!(util_is_file(path) && util_is_executable( path ))) { - free( path ); - path = NULL; - } - free( cwd ); - - return path; - } else { - char * full_path = NULL; - char ** path_list = util_alloc_PATH_list(); - int ipath = 0; - - while (true) { - if (path_list[ipath] != NULL) { - char * current_attempt = util_alloc_filename(path_list[ipath] , executable , NULL); - - if ( util_is_file( current_attempt ) && util_is_executable( current_attempt )) { - full_path = current_attempt; - break; - } else { - free(current_attempt); - ipath++; - } - } else - break; - } - - util_free_NULL_terminated_stringlist(path_list); - return full_path; - } -} - - - - - -/** - This function updates an environment variable representing a path, - before actually updating the environment variable the current value - is checked, and the following rules apply: - - 1. If @append == true, and @value is already included in the - environment variable; nothing is done. - - 2. If @append == false, and the variable already starts with - @value, nothing is done. - - A pointer to the updated(?) environment variable is returned. -*/ - -const char * util_update_path_var(const char * variable, const char * value, bool append) { - const char * current_value = getenv( variable ); - if (current_value == NULL) - /* The (path) variable is not currently set. */ - util_setenv( variable , value ); - else { - bool update = true; - - { - char ** path_list; - int num_path; - util_split_string( current_value , ":" , &num_path , &path_list); - if (append) { - int i; - for (i = 0; i < num_path; i++) { - if (util_string_equal( path_list[i] , value)) - update = false; /* The environment variable already contains @value - no point in appending it at the end. */ - } - } else { - if (util_string_equal( path_list[0] , value)) - update = false; /* The environment variable already starts with @value. */ - } - util_free_stringlist( path_list , num_path ); - } - - if (update) { - char * new_value; - if (append) - new_value = util_alloc_sprintf("%s:%s" , current_value , value); - else - new_value = util_alloc_sprintf("%s:%s" , value , current_value); - util_setenv( variable , new_value ); - free( new_value ); - } - - } - return getenv( variable ); -} - - - -/** - This is a thin wrapper around the setenv() call, with the twist - that all $VAR expressions in the @value parameter are replaced with - getenv() calls, so that the function call: - - util_setenv("PATH" , "$HOME/bin:$PATH") - - Should work as in the shell. If the variables referred to with ${} - in @value do not exist the literal string, i.e. '$HOME' is - retained. - - If @value == NULL a call to unsetenv( @variable ) will be issued. -*/ - -const char * util_interp_setenv( const char * variable , const char * value) { - char * interp_value = util_alloc_envvar( value ); - if (interp_value != NULL) { - util_setenv( variable , interp_value); - free( interp_value ); - } else - util_unsetenv( variable ); - - return getenv( variable ); -} - - - -/** - This function will take a string as input, and then replace all if - $VAR expressions with the corresponding environment variable. If - the environament variable VAR is not set, the string literal $VAR - is retained. The return value is a newly allocated string. - - If the input value is NULL - the function will just return NULL; -*/ - - -char * util_alloc_envvar( const char * value ) { - if (value == NULL) - return NULL; - else { - buffer_type * buffer = buffer_alloc( 1024 ); /* Start by filling up a buffer instance with - the current content of @value. */ - buffer_fwrite_char_ptr( buffer , value ); - buffer_rewind( buffer ); - - - while (true) { - if (buffer_strchr( buffer , '$')) { - const char * data = (const char*)buffer_get_data( buffer ); - int offset = buffer_get_offset( buffer ) + 1; /* Points at the first character following the '$' */ - int var_length = 0; - - /* Find the length of the variable name */ - while (true) { - char c; - c = data[offset + var_length]; - if (!(isalnum( c ) || c == '_')) /* Any character which is NOT in the set [a-Z,0-9_] marks the end of the variable. */ - break; - - if (c == '\0') /* The end of the string. */ - break; - - var_length += 1; - } - - { - char * var_name = util_alloc_substring_copy( data , offset - 1 , var_length + 1); /* Include the leading $ */ - const char * var_value = getenv( &var_name[1] ); - - if (var_value != NULL) - buffer_search_replace( buffer , var_name , var_value); /* The actual string replacement. */ - else - buffer_fseek( buffer , var_length , SEEK_CUR ); /* The variable is not defined, and we leave the $name. */ - - free( var_name ); - } - } else break; /* No more $ to replace */ - } - - - buffer_shrink_to_fit( buffer ); - { - char * expanded_value = (char*)buffer_get_data( buffer ); - buffer_free_container( buffer ); - return expanded_value; - } - } -} diff --git a/ThirdParty/Ert/lib/util/util_getuid.c b/ThirdParty/Ert/lib/util/util_getuid.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/util_getuid.c rename to ThirdParty/Ert/lib/util/util_getuid.cpp index 678803a476..4b22ab5752 100644 --- a/ThirdParty/Ert/lib/util/util_getuid.c +++ b/ThirdParty/Ert/lib/util/util_getuid.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_lockf.c b/ThirdParty/Ert/lib/util/util_lockf.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/util_lockf.c rename to ThirdParty/Ert/lib/util/util_lockf.cpp index 6b7b120de2..9114b9d0d9 100644 --- a/ThirdParty/Ert/lib/util/util_lockf.c +++ b/ThirdParty/Ert/lib/util/util_lockf.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_opendir.c b/ThirdParty/Ert/lib/util/util_opendir.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/util_opendir.c rename to ThirdParty/Ert/lib/util/util_opendir.cpp index 3205364699..6984baf67f 100644 --- a/ThirdParty/Ert/lib/util/util_opendir.c +++ b/ThirdParty/Ert/lib/util/util_opendir.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_spawn.c b/ThirdParty/Ert/lib/util/util_spawn.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/util_spawn.c rename to ThirdParty/Ert/lib/util/util_spawn.cpp index 76a08ea9f5..429e05c95d 100644 --- a/ThirdParty/Ert/lib/util/util_spawn.c +++ b/ThirdParty/Ert/lib/util/util_spawn.cpp @@ -1,5 +1,5 @@ -#include -#include "ert/util/build_config.h" +#include +#include "ert/util/build_config.hpp" #include #include @@ -10,7 +10,7 @@ #include #include -#include +#include extern char **environ; diff --git a/ThirdParty/Ert/lib/util/util_symlink.c b/ThirdParty/Ert/lib/util/util_symlink.cpp similarity index 94% rename from ThirdParty/Ert/lib/util/util_symlink.c rename to ThirdParty/Ert/lib/util/util_symlink.cpp index e68796d534..bfa79dd893 100644 --- a/ThirdParty/Ert/lib/util/util_symlink.c +++ b/ThirdParty/Ert/lib/util/util_symlink.cpp @@ -2,9 +2,9 @@ #include #include -#include "ert/util/build_config.h" -#include -#include +#include "ert/util/build_config.hpp" +#include +#include #ifndef ERT_HAVE_SYMLINK @@ -91,12 +91,14 @@ char * util_alloc_link_target(const char * link) { #ifdef ERT_HAVE_READLINKAT +#if !defined(ERT_HAVE_READLINKAT_DECLARATION) /* The manual page says that the readlinkat() function should be in the unistd.h header file, but not on RedHat5. On RedHat6 it is. */ extern ssize_t readlinkat (int __fd, __const char *__restrict __path, char *__restrict __buf, size_t __len); +#endif /* !defined(ERT_HAVE_READLINKAT_DECLARATION) */ char * util_alloc_atlink_target(const char * path , const char * link) { if (util_is_abs_path( link )) diff --git a/ThirdParty/Ert/lib/util/util_unlink.c b/ThirdParty/Ert/lib/util/util_unlink.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/util_unlink.c rename to ThirdParty/Ert/lib/util/util_unlink.cpp index 5f3af54979..4cf13ecfa8 100644 --- a/ThirdParty/Ert/lib/util/util_unlink.c +++ b/ThirdParty/Ert/lib/util/util_unlink.cpp @@ -16,9 +16,9 @@ for more details. */ -#include "ert/util/build_config.h" +#include "ert/util/build_config.hpp" -#include +#include #if defined(HAVE_WINDOWS_UNLINK) diff --git a/ThirdParty/Ert/lib/util/util_zlib.c b/ThirdParty/Ert/lib/util/util_zlib.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/util_zlib.c rename to ThirdParty/Ert/lib/util/util_zlib.cpp index 17d59e586f..95c813b68b 100644 --- a/ThirdParty/Ert/lib/util/util_zlib.c +++ b/ThirdParty/Ert/lib/util/util_zlib.cpp @@ -5,7 +5,7 @@ #include -#include +#include /** This function reads data from the input pointer data, and writes a @@ -134,7 +134,7 @@ void util_fwrite_compressed(const void * _data , int size , FILE * stream) { util_compress_buffer(&data[offset] , this_block_size , zbuffer , &compressed_size); fwrite(&compressed_size , sizeof compressed_size , 1 , stream); { - int bytes_written = fwrite(zbuffer , 1 , compressed_size , stream); + unsigned long bytes_written = fwrite(zbuffer , 1 , compressed_size , stream); if (bytes_written < compressed_size) util_abort("%s: wrote only %d/%ld bytes to compressed file - aborting \n",__func__ , bytes_written , compressed_size); } @@ -171,7 +171,7 @@ void util_fread_compressed(void *__data , FILE * stream) { int uncompress_result; fread(&compressed_size , sizeof compressed_size , 1 , stream); { - int bytes_read = fread(zbuffer , 1 , compressed_size , stream); + unsigned long bytes_read = fread(zbuffer , 1 , compressed_size , stream); if (bytes_read < compressed_size) util_abort("%s: read only %d/%d bytes from compressed file - aborting \n",__func__ , bytes_read , compressed_size); diff --git a/ThirdParty/Ert/lib/util/vector.c b/ThirdParty/Ert/lib/util/vector.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/vector.c rename to ThirdParty/Ert/lib/util/vector.cpp index 09ae564438..64b0043038 100644 --- a/ThirdParty/Ert/lib/util/vector.c +++ b/ThirdParty/Ert/lib/util/vector.cpp @@ -19,10 +19,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define VECTOR_TYPE_ID 551087 diff --git a/ThirdParty/Ert/lib/util/vector_template.c b/ThirdParty/Ert/lib/util/vector_template.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/vector_template.c rename to ThirdParty/Ert/lib/util/vector_template.cpp index ccd85fd551..80958d44e9 100644 --- a/ThirdParty/Ert/lib/util/vector_template.c +++ b/ThirdParty/Ert/lib/util/vector_template.cpp @@ -98,9 +98,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/thread_pool.c b/ThirdParty/Ert/lib/vector_template.hpp.in similarity index 71% rename from ThirdParty/Ert/lib/util/thread_pool.c rename to ThirdParty/Ert/lib/vector_template.hpp.in index e23026b4ea..f4574fdda5 100644 --- a/ThirdParty/Ert/lib/util/thread_pool.c +++ b/ThirdParty/Ert/lib/vector_template.hpp.in @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Statoil ASA, Norway. - The file 'thread_pool.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'vector_template.hpp' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,12 +16,9 @@ for more details. */ -#include "ert/util/build_config.h" -#include +#ifndef ERT_@TYPE@_VECTOR_CXX +#define ERT_@TYPE@_VECTOR_CXX -#ifdef HAVE_PTHREAD -#include "thread_pool_posix.c" -#else -Error - should not be be here. -#endif +#include +#endif diff --git a/ThirdParty/Ert/python/CMakeLists.txt b/ThirdParty/Ert/python/CMakeLists.txt index f3d5cd1a9a..4ed4cd838e 100644 --- a/ThirdParty/Ert/python/CMakeLists.txt +++ b/ThirdParty/Ert/python/CMakeLists.txt @@ -4,6 +4,12 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/M include(init_python) init_python( 2.7 ) +find_python_package(pandas 0.17 ${PYTHON_INSTALL_PREFIX}) +if (NOT DEFINED PY_pandas) + message(WARNING "Pandas module not found Python wrappers not enabled. Install with: \"pip install pandas\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) + return() +endif() find_python_package(numpy 1.7.1 ${PYTHON_INSTALL_PREFIX}) if (NOT DEFINED PY_numpy) diff --git a/ThirdParty/Ert/python/ecl/ecl_type.py b/ThirdParty/Ert/python/ecl/ecl_type.py index ca4d9c6831..477aeddb50 100644 --- a/ThirdParty/Ert/python/ecl/ecl_type.py +++ b/ThirdParty/Ert/python/ecl/ecl_type.py @@ -46,7 +46,7 @@ class EclDataType(BaseCClass): _alloc_from_name = EclPrototype("void* ecl_type_alloc_from_name_python(char*)", bind=False) _free = EclPrototype("void ecl_type_free_python(ecl_data_type)") _get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)") - _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_fortio_python(ecl_data_type)") + _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_iotype_python(ecl_data_type)") _is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)") _is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)") _is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)") diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py index 1b7c79568a..2d2970ad9e 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py @@ -21,10 +21,11 @@ libecl/src directory. """ - +import warnings import numpy import datetime import os.path +import ctypes # Observe that there is some convention conflict with the C code # regarding order of arguments: The C code generally takes the time @@ -142,7 +143,11 @@ class EclSum(BaseCClass): _add_tstep = EclPrototype("ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)") _export_csv = EclPrototype("void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)") _identify_var_type = EclPrototype("ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind = False) - + _get_last_value = EclPrototype("double ecl_sum_get_last_value_gen_key(ecl_sum, char*)") + _get_first_value = EclPrototype("double ecl_sum_get_first_value_gen_key(ecl_sum, char*)") + _init_numpy_vector = EclPrototype("void ecl_sum_init_double_vector(ecl_sum, char*, double*)") + _init_numpy_vector_interp = EclPrototype("void ecl_sum_init_double_vector_interp(ecl_sum, char*, time_t_vector, double*)") + _init_numpy_datetime64 = EclPrototype("void ecl_sum_init_datetime64_vector(ecl_sum, int64*, int)") def __init__(self, load_case, join_string=":", include_restart=True): @@ -395,6 +400,7 @@ def get_values(self, key, report_only=False): also available as the 'values' property of an EclSumVector instance. """ + warnings.warn("The method get_values() has been deprecated - use numpy_vector() instead.", DeprecationWarning) if self.has_key(key): key_index = self._get_general_var_index(key) if report_only: @@ -413,6 +419,121 @@ def get_values(self, key, report_only=False): else: raise KeyError("Summary object does not have key:%s" % key) + def _make_time_vector(self, time_index): + time_points = TimeVector() + for t in time_index: + time_points.append(t) + return time_points + + def numpy_vector(self, key, time_index = None): + """Will return numpy vector of all the values corresponding to @key. + + The optional argument @time_index can be used to limit the time points + where you want evaluation. The time_index argument should be a list of + datetime instances. The values will be interpolated to the time points + given in the time_index vector. If the time points in the time_inedx + vector are outside of the simulated range you will get an extrapolated + value: + + Rates -> 0 + Not rate -> first or last simulated value. + + The function will raise KeyError if the requested key does not exist. + If many keys are needed it will be faster to use the pandas_frame() + function. + """ + if key not in self: + raise KeyError("No such key:%s" % key) + + if time_index is None: + np_vector = numpy.zeros(len(self)) + self._init_numpy_vector(key ,np_vector.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + return np_vector + else: + time_vector = self._make_time_vector(time_index) + np_vector = numpy.zeros(len(time_vector)) + self._init_numpy_vector_interp(key, time_vector, np_vector.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + return np_vector + + + @property + def numpy_dates(self): + """ + Will return numpy vector of numpy.datetime64() values for all the simulated timepoints. + """ + np_dates = numpy.zeros(len(self), dtype="datetime64[ms]") + self._init_numpy_datetime64(np_dates.ctypes.data_as(ctypes.POINTER(ctypes.c_int64)), 1000) + return np_dates + + + @property + def dates(self): + """ + Will return ordinary Python list of datetime.datetime() objects of simulated timepoints. + """ + np_dates = self.numpy_dates + return np_dates.tolist() + + + def pandas_frame(self, time_index = None, column_keys = None): + """Will create a pandas frame with summary data. + + By default you will get all time points in the summary case, but by + using the time_index argument you can control which times you are + interested in. If you have supplied a time_index argument the data will + be interpolated to these time values. If the time points in the + time_index vector are outside of the simulated range you will get an + extrapolated value: + + Rates -> 0 + Not rate -> first or last simulated value. + + + By default the frame will contain all the summary vectors in the case, + but this can be controlled by using the column_keys argument. The + column_keys should be a list of strings, and each summary vector + matching one of the elements in the @column_keys will get a column in + the frame, you can use wildcards like "WWCT:*" and "*:OP". If you + supply a column_keys argument which does not resolve to any valid + summary keys you will get a ValueError exception. + + + sum = EclSum(case) + monthly_dates = sum.time_range(interval="1M") + data = sum.pandas_frame(time_index = monthly_dates, column_keys=["F*PT"]) + + FOPT FGPT FWPT + 2010-01-01 100.7 200.0 25.0 + 2010-02-01 150.7 275.0 67.6 + 2010-03-01 276.7 310.6 67.0 + 2010-04-01 672.7 620.4 78.7 + .... + """ + from ecl.summary import EclSumKeyWordVector + import pandas + if column_keys is None: + keywords = EclSumKeyWordVector(self, add_keywords = True) + else: + keywords = EclSumKeyWordVector(self) + for key in column_keys: + keywords.add_keywords(key) + + + if len(keywords) == 0: + raise ValueError("No valid key") + + if time_index is None: + time_index = self.numpy_dates + data = numpy.zeros([len(time_index), len(keywords)]) + EclSum._init_pandas_frame(self, keywords,data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + else: + time_points = self._make_time_vector(time_index) + data = numpy.zeros([len(time_points), len(keywords)]) + EclSum._init_pandas_frame_interp(self, keywords, time_points, data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + + frame = pandas.DataFrame(index = time_index, columns=list(keywords), data=data) + return frame + def get_key_index(self, key): """ @@ -440,7 +561,7 @@ def get_key_index(self, key): return None - def get_last_value(self, key): + def last_value(self, key): """ Will return the last value corresponding to @key. @@ -452,14 +573,31 @@ def get_last_value(self, key): The alternative method 'last' will return a EclSumNode instance with some extra time related information. """ - return self[key].last_value + if not key in self: + raise KeyError("No such key:%s" % key) + + return self._get_last_value(key) + + + def first_value(self, key): + """ + Will return first value corresponding to @key. + """ + if not key in self: + raise KeyError("No such key:%s" % key) + + return self._get_first_value(key) + + def get_last_value(self,key): + warnings.warn("The function get_last_value() is deprecated, use last_value() instead",DeprecationWarning) + return self.last_value(key) def get_last(self, key): """ Will return the last EclSumNode corresponding to @key. If you are only interested in the final value, you can use the - get_last_value() method. + last_value() method. """ return self[key].last @@ -694,7 +832,7 @@ def blocked_production(self, totalKey, timeRange): if t < CTime(self.start_time): total.append(0) elif t >= CTime(self.end_time): - total.append(self.get_last_value(totalKey)) + total.append(self.last_value(totalKey)) else: total.append(self.get_interp(totalKey, date=t)) tmp = total << 1 @@ -899,16 +1037,6 @@ def get_days(self, report_only=False): else: return self.__days - @property - def dates(self): - """ - Will return a list of simulation dates. - - The list will be an ordinary Python list, and the dates will - be in terms ordinary Python datetime values. - """ - return self.get_dates(False) - def get_dates(self, report_only=False): """ Will return a list of simulation dates. @@ -1373,8 +1501,10 @@ def resample(self, new_case_name, time_points): import ecl.summary.ecl_sum_keyword_vector -EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) -EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) +EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) +EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) +EclSum._init_pandas_frame = EclPrototype("void ecl_sum_init_double_frame(ecl_sum, ecl_sum_vector, double*)", bind=False) +EclSum._init_pandas_frame_interp = EclPrototype("void ecl_sum_init_double_frame_interp(ecl_sum, ecl_sum_vector, time_t_vector, double*)", bind=False) monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod) monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable) diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py index a2f1e210f2..9fc8b7a8b1 100644 --- a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py @@ -20,8 +20,8 @@ def createEclSum( case, ecl_sum = EclSum.restart_writer(case , restart_case, restart_step, sim_start , dims[0] , dims[1] , dims[2]) var_list = [] - for (kw,wgname,num) in keys: - var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num) ) + for (kw,wgname,num,unit) in keys: + var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num, unit =unit) ) # This is a bug! This should not be integer division, but tests are written # around that assumption. diff --git a/ThirdParty/Ert/python/python/CMakeLists.txt b/ThirdParty/Ert/python/python/CMakeLists.txt deleted file mode 100644 index 59be104ca7..0000000000 --- a/ThirdParty/Ert/python/python/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/test_env.py ) - -add_subdirectory(cwrap) -add_subdirectory( ecl ) - -if (INSTALL_ERT_LEGACY) - add_subdirectory( legacy/ert ) -endif() diff --git a/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt b/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt deleted file mode 100644 index a6b98b1b08..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - basecclass.py - basecenum.py - basecvalue.py - cfile.py - clib.py - metacwrap.py - prototype.py -) - -add_python_package("cwrap" ${PYTHON_INSTALL_PREFIX}/cwrap "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/cwrap/__init__.py b/ThirdParty/Ert/python/python/cwrap/__init__.py deleted file mode 100644 index 027cab1f70..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -""" -The cwrap package contains several small utility modules to simplify -the process of interacting with a C library: - - clib: This module contains the function load() which will load a - shared library using the ctypes.CDLL(); the function has - facilities for trying several different names when loading the - library. - - cfile: This module implemenets the class CFILE which can be used to - extract the underlying FILE pointer from a Python filehandle, to - facilitate use of Python filehandles for functions expecting a - FILE pointer. -""" - -__author__ = 'Jean-Paul Balabanian, Joakim Hove, and PG Drange' -__copyright__ = 'Copyright 2016, Statoil ASA' -__credits__ = __author__ -__license__ = 'GPL' -__version__ = '0.0.1' -__maintainer__ = __author__ -__email__ = __author__ -__status__ = 'Prototype' - -from .basecclass import BaseCClass -from .basecenum import BaseCEnum -from .basecvalue import BaseCValue - -from .cfile import CFILE -from .clib import load, lib_name - -from .metacwrap import MetaCWrap -from .prototype import REGISTERED_TYPES, Prototype, PrototypeError - -__all__ = ['BaseCClass', 'BaseCEnum', 'BaseCValue', 'CFILE', - 'MetaCWrap', 'Prototype', 'load', 'lib_name'] diff --git a/ThirdParty/Ert/python/python/cwrap/basecclass.py b/ThirdParty/Ert/python/python/cwrap/basecclass.py deleted file mode 100644 index 306a8375bd..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecclass.py +++ /dev/null @@ -1,156 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -import six - -import ctypes -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCClass(object): - namespaces = {} - - def __init__(self, c_pointer, parent=None, is_reference=False): - if not c_pointer: - raise ValueError("Must have a valid (not null) pointer value!") - - if c_pointer < 0: - raise ValueError("The pointer value is negative! This may be correct, but usually is not!") - - self.__c_pointer = c_pointer - self.__parent = parent - self.__is_reference = is_reference - - def __new__(cls, *more, **kwargs): - obj = super(BaseCClass, cls).__new__(cls) - obj.__c_pointer = None - obj.__parent = None - obj.__is_reference = False - - return obj - - def _address(self): - return self.__c_pointer - - def _ad_str(self): - return 'at 0x%x' % self._address() - - @classmethod - def from_param(cls, c_class_object): - if c_class_object is not None and not isinstance(c_class_object, BaseCClass): - raise ValueError("c_class_object must be a BaseCClass instance!") - - if c_class_object is None: - return ctypes.c_void_p() - else: - return ctypes.c_void_p(c_class_object.__c_pointer) - - @classmethod - def createPythonObject(cls, c_pointer): - if c_pointer is not None: - new_obj = cls.__new__(cls) - BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=None, is_reference=False) - return new_obj - else: - return None - - @classmethod - def createCReference(cls, c_pointer, parent=None): - if c_pointer is not None: - new_obj = cls.__new__(cls) - BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=parent, is_reference=True) - return new_obj - else: - return None - - @classmethod - def storageType(cls): - return ctypes.c_void_p - - def convertToCReference(self, parent): - self.__is_reference = True - self.__parent = parent - - - def setParent(self, parent=None): - if self.__is_reference: - self.__parent = parent - else: - raise UserWarning("Can only set parent on reference types!") - - return self - - def isReference(self): - """ @rtype: bool """ - return self.__is_reference - - def parent(self): - return self.__parent - - def __eq__(self, other): - # This is the last resort comparison function; it will do a - # plain pointer comparison on the underlying C object; or - # Python is-same-object comparison. - if isinstance(other, BaseCClass): - return self.__c_pointer == other.__c_pointer - else: - return super(BaseCClass , self) == other - - def __hash__(self): - # Similar to last resort comparison; this returns the hash of the - # underlying C pointer. - return hash(self.__c_pointer) - - def free(self): - raise NotImplementedError("A BaseCClass requires a free method implementation!") - - def _create_repr(self, args = ''): - """Representation on the form (e.g.) 'EclFile(...) at 0x1729'.""" - return "{0}({1}) {2}".format(self.__class__.__name__, args, self._ad_str()) - - def __repr__(self): - """Representation on the form (e.g.) 'EclFile(...) at 0x1729'.""" - return self._create_repr() - - def __del__(self): - if self.free is not None: - if not self.__is_reference: - # Important to check the c_pointer; in the case of failed object creation - # we can have a Python object with c_pointer == None. - if self.__c_pointer: - self.free() - - def _invalidateCPointer(self): - self.__c_pointer = None - - - def __bool__(self): - """The BaseCClass instance will evaluate to true if it is bound to an - underlying C object, otherwise it will evaluate to False. More - elaborate bool tests should be implemented in the derived - class. - """ - if self.__c_pointer: - return True - else: - return False - - - def __nonzero__(self): - return self.__bool__( ) diff --git a/ThirdParty/Ert/python/python/cwrap/basecenum.py b/ThirdParty/Ert/python/python/cwrap/basecenum.py deleted file mode 100644 index b86e1b0d64..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecenum.py +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import absolute_import, division, print_function, unicode_literals - -import six - -import ctypes -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCEnum(object): - enum_namespace = {} - - def __init__(self, *args, **kwargs): - if not self in self.enum_namespace[self.__class__]: - raise NotImplementedError("Can not be instantiated directly!") - - def __new__(cls, *args, **kwargs): - if len(args) == 1: - enum = cls.__resolveEnum(args[0]) - - if enum is None: - raise ValueError("Unknown enum value: %i" % args[0]) - - return enum - else: - obj = super(BaseCEnum, cls).__new__(cls, *args) - obj.name = None - obj.value = None - return obj - - @classmethod - def from_param(cls, c_class_object): - if not isinstance(c_class_object, BaseCEnum): - raise ValueError("c_class_object must be an BaseCEnum instance!") - return c_class_object.value - - @classmethod - def addEnum(cls, name, value): - name = str(name) - if not isinstance(value, int): - raise ValueError("Value must be an integer!") - - enum = cls.__new__(cls) - enum.name = name - enum.value = value - - setattr(cls, name, enum) - - if cls not in cls.enum_namespace: - cls.enum_namespace[cls] = [] - - cls.enum_namespace[cls].append(enum) - - @classmethod - def enums(cls): - return list(cls.enum_namespace[cls]) - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.value == other.value - - if isinstance(other, int): - return self.value == other - - return False - - def __hash__(self): - return hash(self.value) - - def __str__(self): - return self.name - - def __repr__(self): - cn = self.__class__.__name__ - na = self.name - va = self.value - return '%s(name = "%s", value = %s)' % (cn, na, va) - - def __add__(self, other): - self.__assertOtherIsSameType(other) - value = self.value + other.value - return self.__resolveOrCreateEnum(value) - - def __or__(self, other): - self.__assertOtherIsSameType(other) - value = self.value | other.value - return self.__resolveOrCreateEnum(value) - - - def __xor__(self, other): - self.__assertOtherIsSameType(other) - value = self.value ^ other.value - return self.__resolveOrCreateEnum(value) - - def __and__(self, other): - self.__assertOtherIsSameType(other) - value = self.value & other.value - return self.__resolveOrCreateEnum(value) - - def __int__(self): - return self.value - - def __contains__(self, item): - return self & item == item - - @classmethod - def __createEnum(cls, value): - enum = cls.__new__(cls) - enum.name = "Unnamed '%s' enum with value: %i" % (str(cls.__name__), value) - enum.value = value - return enum - - @classmethod - def __resolveOrCreateEnum(cls, value): - enum = cls.__resolveEnum(value) - - if enum is not None: - return enum - - return cls.__createEnum(value) - - @classmethod - def __resolveEnum(cls, value): - for enum in cls.enum_namespace[cls]: - if enum.value == value: - return enum - return None - - def __assertOtherIsSameType(self, other): - assert isinstance(other, self.__class__), "Can only operate on enums of same type: %s =! %s" % ( - self.__class__.__name__, other.__class__.__name__) - - - @classmethod - def populateEnum(cls, library, enum_provider_function): - try: - func = getattr(library, enum_provider_function) - except AttributeError: - raise ValueError("Could not find enum description function: %s - can not load enum: %s." % (enum_provider_function, cls.__name__)) - - func.restype = ctypes.c_char_p - func.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)] - - index = 0 - while True: - value = ctypes.c_int() - name = func(index, ctypes.byref(value)) - - if name: - cls.addEnum(name, value.value) - index += 1 - else: - break - diff --git a/ThirdParty/Ert/python/python/cwrap/basecvalue.py b/ThirdParty/Ert/python/python/cwrap/basecvalue.py deleted file mode 100644 index 2c9f582792..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecvalue.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -import six - -from ctypes import (pointer, c_long, c_int, c_bool, c_float, c_double, c_byte, - c_short, c_char, c_ubyte, c_ushort, c_uint, c_ulong) - -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCValue(object): - DATA_TYPE = None - LEGAL_TYPES = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_bool, c_char, c_float, c_double] - - def __init__(self, value): - super(BaseCValue, self).__init__() - - if not self.DATA_TYPE in self.LEGAL_TYPES: - raise ValueError("DATA_TYPE must be one of these CTypes classes: %s" % BaseCValue.LEGAL_TYPES) - - self.__value = self.cast(value) - - - def value(self): - return self.__value.value - - @classmethod - def storageType(cls): - return cls.type() - - @classmethod - def type(cls): - return cls.DATA_TYPE - - @classmethod - def cast(cls, value): - return cls.DATA_TYPE(value) - - def setValue(self, value): - self.__value = self.cast(value) - - def asPointer(self): - return pointer(self.__value) - - @classmethod - def from_param(cls, c_value_object): - if c_value_object is not None and not isinstance(c_value_object, BaseCValue): - raise ValueError("c_class_object must be a BaseCValue instance!") - - return c_value_object.__value diff --git a/ThirdParty/Ert/python/python/cwrap/cfile.py b/ThirdParty/Ert/python/python/cwrap/cfile.py deleted file mode 100644 index 4b46d420f9..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/cfile.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import ctypes -import six -from .prototype import Prototype, PrototypeError -from .basecclass import BaseCClass - -class CFILE(BaseCClass): - """ - Utility class to map a Python file handle <-> FILE* in C - """ - TYPE_NAME = "FILE" - - _as_file = Prototype(ctypes.pythonapi, "void* PyFile_AsFile(py_object)") - - def __init__(self, py_file): - """ - Takes a python file handle and looks up the underlying FILE * - - The purpose of the CFILE class is to be able to use python - file handles when calling C functions which expect a FILE - pointer. A CFILE instance should be created based on the - Python file handle, and that should be passed to the function - expecting a FILE pointer. - - The implementation is based on the ctypes object - pythonapi which is ctypes wrapping of the CPython api. - - C-function: - void fprintf_hello(FILE * stream , const char * msg); - - Python wrapper: - lib = clib.load( "lib.so" ) - fprintf_hello = Prototype(lib, "void fprintf_hello( FILE , char* )") - - Python use: - py_fileH = open("file.txt" , "w") - fprintf_hello( CFILE( py_fileH ) , "Message ...") - py_fileH.close() - - If the supplied argument is not of type py_file the function - will raise a TypeException. - - Examples: ecl.ecl.ecl_kw.EclKW.fprintf_grdecl() - """ - c_ptr = self._as_file(py_file) - try: - super(CFILE, self).__init__(c_ptr) - except ValueError as e: - raise TypeError("Sorry - the supplied argument is not a valid Python file handle!") - - self.py_file = py_file - - - def __del__(self): - pass diff --git a/ThirdParty/Ert/python/python/cwrap/clib.py b/ThirdParty/Ert/python/python/cwrap/clib.py deleted file mode 100644 index 8fb87a6518..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/clib.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'clib.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -"""Convenience module for loading shared library. -""" - -import platform -import ctypes -import os - -so_extension = {"linux" : "so", - "linux2" : "so", - "linux3" : "so", - "win32" : "dll", - "win64" : "dll", - "darwin" : "dylib" } - - -# Passing None to the CDLL() function means to open a lib handle to -# the current runnning process, i.e. like dlopen( NULL ). We must -# special case this to avoid creating the bogus argument 'None.so'. - -def lib_name(lib , path = None , so_version = ""): - if lib is None: - return None - else: - platform_key = platform.system().lower() - - if platform_key == "darwin": - so_name = "%s%s.%s" % (lib, so_version, so_extension[ platform_key ]) - else: - so_name = "%s.%s%s" % (lib, so_extension[ platform_key ], so_version) - - if path: - return os.path.join( path , so_name ) - else: - return so_name - - - - -def load( lib, so_version = None, path = None): - """Thin wrapper around the ctypes.CDLL function for loading shared - library. - - If the path argument is non Null the function will first try to - load with full path. If that fails it wil also try to load without - a path component, invoking normal dlopen() semantics. - """ - - dll = None - lib_files = [ lib_name( lib , path = path , so_version = so_version) ] - if path: - lib_files.append( lib_name( lib , path = None , so_version = so_version) ) - - for lib_file in lib_files: - try: - dll = ctypes.CDLL(lib_file , ctypes.RTLD_GLOBAL) - return dll - except Exception as exc: - error = exc - - error_msg = "\nFailed to load shared library:%s\n\ndlopen() error: %s\n" % (lib , error) - - LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH") - if not LD_LIBRARY_PATH: - LD_LIBRARY_PATH = "" - - error_msg += """ -The runtime linker has searched through the default location of shared -libraries, and also the locations mentioned in your LD_LIBRARY_PATH -variable. Your current LD_LIBRARY_PATH setting is: - - LD_LIBRARY_PATH: %s - -You might need to update this variable? -""" % LD_LIBRARY_PATH - raise ImportError(error_msg) diff --git a/ThirdParty/Ert/python/python/cwrap/metacwrap.py b/ThirdParty/Ert/python/python/cwrap/metacwrap.py deleted file mode 100644 index 52ccb970ce..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/metacwrap.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) -import six - -import re -from types import MethodType - -from .prototype import Prototype - - -def snakeCase(name): - s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) - return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() - - -class MetaCWrap(type): - def __init__(cls, name, bases, attrs): - super(MetaCWrap, cls).__init__(name, bases, attrs) - - is_return_type = False - storage_type = None - - if "TYPE_NAME" in attrs: - type_name = attrs["TYPE_NAME"] - else: - type_name = snakeCase(name) - - if hasattr(cls, "DATA_TYPE") or hasattr(cls, "enums"): - is_return_type = True - - if hasattr(cls, "storageType"): - storage_type = cls.storageType() - - Prototype.registerType(type_name, cls, is_return_type=is_return_type, storage_type=storage_type) - - if hasattr(cls, "createCReference"): - Prototype.registerType("%s_ref" % type_name, cls.createCReference, is_return_type=True, storage_type=storage_type) - - if hasattr(cls, "createPythonObject"): - Prototype.registerType("%s_obj" % type_name, cls.createPythonObject, is_return_type=True, storage_type=storage_type) - - - for key, attr in attrs.items(): - if isinstance(attr, Prototype): - attr.resolve() - attr.__name__ = key - - if attr.shouldBeBound(): - method = MethodType(attr, None, cls) - #method = six.create_bound_method(attr, cls) - setattr(cls, key, method) diff --git a/ThirdParty/Ert/python/python/cwrap/prototype.py b/ThirdParty/Ert/python/python/cwrap/prototype.py deleted file mode 100644 index 28348e31d7..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/prototype.py +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import ctypes -import inspect -import re - -import sys - -class TypeDefinition(object): - def __init__(self, type_class_or_function, is_return_type, storage_type): - self.storage_type = storage_type - self.is_return_type = is_return_type - self.type_class_or_function = type_class_or_function - - -REGISTERED_TYPES = {} -""":type: dict[str,TypeDefinition]""" - - -def _registerType(type_name, type_class_or_function, is_return_type=True, storage_type=None): - if type_name in REGISTERED_TYPES: - raise PrototypeError("Type: '%s' already registered!" % type_name) - - REGISTERED_TYPES[type_name] = TypeDefinition(type_class_or_function, is_return_type, storage_type) - - # print("Registered: %s for class: %s" % (type_name, repr(type_class_or_function))) - -_registerType("void", None) -_registerType("void*", ctypes.c_void_p) -_registerType("uint", ctypes.c_uint) -_registerType("uint*", ctypes.POINTER(ctypes.c_uint)) -_registerType("int", ctypes.c_int) -_registerType("int*", ctypes.POINTER(ctypes.c_int)) -_registerType("int64", ctypes.c_int64) -_registerType("int64*", ctypes.POINTER(ctypes.c_int64)) -_registerType("size_t", ctypes.c_size_t) -_registerType("size_t*", ctypes.POINTER(ctypes.c_size_t)) -_registerType("bool", ctypes.c_bool) -_registerType("bool*", ctypes.POINTER(ctypes.c_bool)) -_registerType("long", ctypes.c_long) -_registerType("long*", ctypes.POINTER(ctypes.c_long)) -_registerType("char", ctypes.c_char) -_registerType("char*", ctypes.c_char_p) -_registerType("char**", ctypes.POINTER(ctypes.c_char_p)) -_registerType("float", ctypes.c_float) -_registerType("float*", ctypes.POINTER(ctypes.c_float)) -_registerType("double", ctypes.c_double) -_registerType("double*", ctypes.POINTER(ctypes.c_double)) -_registerType("py_object", ctypes.py_object) - -PROTOTYPE_PATTERN = "(?P[a-zA-Z][a-zA-Z0-9_*]*) +(?P[a-zA-Z]\w*) *[(](?P[a-zA-Z0-9_*, ]*)[)]" - -class PrototypeError(Exception): - pass - - -class Prototype(object): - pattern = re.compile(PROTOTYPE_PATTERN) - - def __init__(self, lib, prototype, bind=False, allow_attribute_error=False): - super(Prototype, self).__init__() - self._lib = lib - self._prototype = prototype - self._bind = bind - self._func = None - self.__name__ = prototype - self._resolved = False - self._allow_attribute_error = allow_attribute_error - - - - def _parseType(self, type_name): - """Convert a prototype definition type from string to a ctypes legal type.""" - type_name = type_name.strip() - - if type_name in REGISTERED_TYPES: - type_definition = REGISTERED_TYPES[type_name] - return type_definition.type_class_or_function, type_definition.storage_type - raise ValueError("Unknown type: %s" % type_name) - - - def shouldBeBound(self): - return self._bind - - def resolve(self): - match = re.match(Prototype.pattern, self._prototype) - if not match: - raise PrototypeError("Illegal prototype definition: %s\n" % self._prototype) - else: - restype = match.groupdict()["return"] - function_name = match.groupdict()["function"] - self.__name__ = function_name - arguments = match.groupdict()["arguments"].split(",") - - try: - func = getattr(self._lib, function_name) - except AttributeError: - if self._allow_attribute_error: - return - raise PrototypeError("Can not find function: %s in library: %s" % (function_name , self._lib)) - - if not restype in REGISTERED_TYPES or not REGISTERED_TYPES[restype].is_return_type: - sys.stderr.write("The type used as return type: %s is not registered as a return type.\n" % restype) - - return_type = self._parseType(restype) - - if inspect.isclass(return_type): - sys.stderr.write(" Correct type may be: %s_ref or %s_obj.\n" % (restype, restype)) - - return None - - return_type, storage_type = self._parseType(restype) - - func.restype = return_type - - if storage_type is not None: - func.restype = storage_type - - def returnFunction(result, func, arguments): - return return_type(result) - - func.errcheck = returnFunction - - if len(arguments) == 1 and arguments[0].strip() == "": - func.argtypes = [] - else: - argtypes = [self._parseType(arg)[0] for arg in arguments] - if len(argtypes) == 1 and argtypes[0] is None: - argtypes = [] - func.argtypes = argtypes - - self._func = func - - - def __call__(self, *args): - if not self._resolved: - self.resolve() - self._resolved = True - - if self._func is None: - if self._allow_attribute_error: - raise NotImplementedError("Function:%s has not been properly resolved - missing library symbol?" % self.__name__) - else: - raise PrototypeError("Prototype has not been properly resolved") - - return self._func(*args) - - def __repr__(self): - bound = "" - if self.shouldBeBound(): - bound = ", bind=True" - - return 'Prototype("%s"%s)' % (self._prototype, bound) - - @classmethod - def registerType(cls, type_name, type_class_or_function, is_return_type=True, storage_type=None): - if storage_type is None and (inspect.isfunction(type_class_or_function)): - storage_type = ctypes.c_void_p - - _registerType(type_name, - type_class_or_function, - is_return_type = is_return_type, - storage_type = storage_type) diff --git a/ThirdParty/Ert/python/python/ecl/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/CMakeLists.txt deleted file mode 100644 index 3ba6f862bc..0000000000 --- a/ThirdParty/Ert/python/python/ecl/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -set(PYTHON_SOURCES - __init__.py -) -add_python_package("python.ecl" ${PYTHON_INSTALL_PREFIX}/ecl "${PYTHON_SOURCES}" True) - -add_subdirectory(ecl) -add_subdirectory(geo) -add_subdirectory(test) -add_subdirectory(util) -add_subdirectory(well) - -configure_file(ecl_lib_info_build.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl/__ecl_lib_info.py ) -configure_file(ecl_lib_info_install.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py ) -install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py DESTINATION ${PYTHON_INSTALL_PREFIX}/ecl RENAME __ecl_lib_info.py) diff --git a/ThirdParty/Ert/python/python/ecl/__init__.py b/ThirdParty/Ert/python/python/ecl/__init__.py deleted file mode 100644 index 3163485b17..0000000000 --- a/ThirdParty/Ert/python/python/ecl/__init__.py +++ /dev/null @@ -1,130 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -ert - Ensemble Reservoir Tool - a package for reservoir modeling. - -The ert package itself has no code, but contains several subpackages: - -ecl.ecl: Package for working with ECLIPSE files. The far most mature - package in ert. - -ecl.util: - -The ert package is based on wrapping the libriaries from the ERT C -code with ctypes; an essential part of ctypes approach is to load the -shared libraries with the ctypes.CDLL() function. The ctypes.CDLL() -function uses the standard methods of the operating system, -i.e. standard locations configured with ld.so.conf and the environment -variable LD_LIBRARY_PATH. - -To avoid conflict with other application using the ert libraries the -Python code should be able to locate the shared libraries without -(necessarily) using the LD_LIBRARY_PATH variable. The default -behaviour is to try to load from the library ../../lib64, but by using -the enviornment variable ERT_LIBRARY_PATH you can alter how ert looks -for shared libraries. - - 1. By default the code will try to load the shared libraries from - '../../lib64' relative to the location of this file. - - 2. Depending on the value of ERT_LIBRARY_PATH two different - behaviours can be imposed: - - Existing path: the package will look in the path pointed to - by ERT_LIBRARY_PATH for shared libraries. - - Arbitrary value: the package will use standard load order for - the operating system. - -If the fixed path, given by the default ../../lib64 or ERT_LIBRARY_PATH -alternative fails, the loader will try the default load behaviour -before giving up completely. -""" -import os.path -import sys - -import warnings -warnings.simplefilter('always', DeprecationWarning) # see #1437 - -from cwrap import load as cwrapload - -try: - import ert_site_init -except ImportError: - pass - - -required_version_hex = 0x02070000 - -ecl_lib_path = None -ert_so_version = "" -__version__ = "0.0.0" - - -# 1. Try to load the __ecl_lib_info module; this module has been -# configured by cmake during the build configuration process. The -# module should contain the variable lib_path pointing to the -# directory with shared object files. -try: - import __ecl_lib_info - ecl_lib_path = __ecl_lib_info.lib_path - ert_so_version = __ecl_lib_info.so_version - __version__ = __ecl_lib_info.__version__ -except ImportError: - pass -except AttributeError: - pass - - -# 2. Using the environment variable ERT_LIBRARY_PATH it is possible to -# override the default algorithms. If the ERT_LIBRARY_PATH is set -# to a non existing directory a warning will go to stderr and the -# setting will be ignored. -env_lib_path = os.getenv("ERT_LIBRARY_PATH") -if env_lib_path: - if os.path.isdir( env_lib_path ): - ert_lib_path = os.getenv("ERT_LIBRARY_PATH") - else: - sys.stderr.write("Warning: Environment variable ERT_LIBRARY_PATH points to nonexisting directory:%s - ignored" % env_lib_path) - - -# Check that the final ert_lib_path setting corresponds to an existing -# directory. -if ecl_lib_path: - if not os.path.isdir( ecl_lib_path ): - ecl_lib_path = None - - -if sys.hexversion < required_version_hex: - raise Exception("ERT Python requires Python 2.7.") - -# This load() function is *the* function actually loading shared -# libraries. - -def load(name): - return cwrapload(name, path=ecl_lib_path, so_version=ert_so_version) - - -from .util import EclVersion -from .util import updateAbortSignals - -updateAbortSignals( ) - -def root(): - """ - Will print the filesystem root of the current ert package. - """ - return os.path.abspath( os.path.join( os.path.dirname( __file__ ) , "../")) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt deleted file mode 100644 index 9b9ba88b03..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ecl_3d_file.py - ecl_3dkw.py - ecl_file.py - ecl_file_view.py - ecl_grav.py - ecl_grav_calc.py - ecl_grid.py - ecl_init_file.py - ecl_kw.py - ecl_npv.py - ecl_region.py - ecl_restart_file.py - ecl_rft.py - ecl_rft_cell.py - ecl_smspec_node.py - ecl_subsidence.py - ecl_sum.py - ecl_sum_keyword_vector.py - ecl_sum_node.py - ecl_sum_tstep.py - ecl_sum_vector.py - ecl_util.py - fortio.py - ecl_sum_keyword_vector.py - ecl_cmp.py - ecl_sum_var_type.py - ecl_type.py - ecl_grid_generator.py - cell.py -) - -add_python_package("python.ecl.ecl" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "${PYTHON_SOURCES}" True) - -add_subdirectory(faults) -add_subdirectory(rft) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/__init__.py b/ThirdParty/Ert/python/python/ecl/ecl/__init__.py deleted file mode 100644 index 8f0d16b365..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/__init__.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Package for working with ECLIPSE files. - -The ecl package contains several classes for working with ECLIPSE -files. The ecl package is a wrapper around the libecl library from the -ERT distribution. Mainly the package is organized with modules -ecl_xxx.py with a class EclXXX. The module ecl_xxx.py will generaly -wrap the content of the c-file ecl_xxx.c The main content is: - - fortio/FortIO: This is functionality to read and write binary - fortran files. - - ecl_kw/EclKW: This class holds one ECLIPSE keyword, like SWAT, in - restart format. - - ecl_type/EclDataType: This class is used to represent the data type - of the elements in EclKW. - - ecl_file/EclFile: This class is used to load an ECLIPSE file in - restart format, alternatively only parts of the file can be - loaded. Internally it consists of a collection of EclKW - instances. - - ecl_grid/EclGrid: This will load an ECLIPSE GRID or EGRID file, and - can then subsequently be used for queries about the grid. - - ecl_grid_generator/EclGridGenerator: This can be used to generate various - grids. - - ecl_sum/EclSum: This will load summary results from an ECLIPSE run; - both data file(s) and the SMSPEC file. The EclSum object can be - used as basis for queries on summary vectors. - - ecl_rft/[EclRFTFile , EclRFT , EclRFTCell]: Loads an ECLIPSE RFT/PLT - file, and can afterwords be used to support various queries. - - ecl_region/EclRegion: Convenience class to support selecting cells - in a grid based on a wide range of criteria. Can be used as a - mask in operations on EclKW instances. - - ecl_grav/EclGrav: Class used to simplify evaluation of ECLIPSE - modelling time-lapse gravitational surveys. - - ecl_subsidence/EclSubsidence: Small class used to evaluate simulated - subsidence from ECLIPSE simulations; analogous to the EcLGrav - functionality. - -In addition there are some modules which do not follow the one class -per module organization: - - ecl_util: This is mainly a collection of constants, and a few - stateless functions. - - ecl: This module is purely for convenience, all the symbols in the - package are explicitly imported into this module, ensuring that - all symbols in the package are available under the common - namespace 'ecl'. - -""" -import ecl.util -import ecl.geo - -from cwrap import Prototype - - -class EclPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) - -ECL_LIB = ecl.load("libecl") - -from .cell import Cell -from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil -from .ecl_type import EclTypeEnum, EclDataType -from .ecl_sum_var_type import EclSumVarType -from .ecl_sum_tstep import EclSumTStep -from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode -from .ecl_sum_keyword_vector import EclSumKeyWordVector -from .ecl_rft_cell import EclPLTCell, EclRFTCell -from .ecl_rft import EclRFT, EclRFTFile -from .fortio import FortIO, openFortIO -from .ecl_kw import EclKW -from .ecl_3dkw import Ecl3DKW -from .ecl_file_view import EclFileView -from .ecl_file import EclFile , openEclFile -from .ecl_3d_file import Ecl3DFile -from .ecl_init_file import EclInitFile -from .ecl_restart_file import EclRestartFile -from .ecl_grid import EclGrid -from .ecl_region import EclRegion -from .ecl_subsidence import EclSubsidence -from .ecl_grav_calc import phase_deltag, deltag -from .ecl_grav import EclGrav -from .ecl_sum_node import EclSumNode -from .ecl_sum_vector import EclSumVector -from .ecl_npv import EclNPV , NPVPriceVector -from .ecl_cmp import EclCmp -from .ecl_grid_generator import EclGridGenerator diff --git a/ThirdParty/Ert/python/python/ecl/ecl/cell.py b/ThirdParty/Ert/python/python/ecl/ecl/cell.py deleted file mode 100644 index 5824d6fc47..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/cell.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -class Cell(object): - - def __init__(self, grid, global_index): - self._grid = grid - self._idx = global_index - self._ijk = grid.get_ijk(global_index=self._idx) - self._aidx = grid.get_active_index(global_index=self._idx) - - @property - def volume(self): - return self._grid.cell_volume(global_index=self._idx) - - @property - def global_index(self): - return self._idx - - @property - def active_index(self): - return self._aidx - - @property - def ijk(self): - return self._ijk - @property - def i(self): - return self._ijk[0] - @property - def j(self): - return self._ijk[1] - @property - def k(self): - return self._ijk[2] - - @property - def active(self): - return self._aidx >= 0 - - def eval(self, kw): - return self._grid.grid_value(kw, self.i, self.j, self.k) - - @property - def fracture(self): - return self._grid.active_fracture_index(global_index=self._idx) - - @property - def dz(self): - return self._grid.cell_dz(global_index=self._idx) - - @property - def dimension(self): - return self._grid.get_cell_dims(global_index=self._idx) - - @property - def valid_geometry(self): - return self._grid.valid_cell_geometry(global_index=self._idx) - - @property - def valid(self): - return not self._grid.cell_invalid(global_index=self._idx) - - def __contains__(self, coord): - """ - Will check if this cell contains point given by world - coordinates (x,y,z)=coord. - """ - if len(coord) != 3: - raise ValueError('Cell contains takes a triple (x,y,z), was given %s.' % coord) - x,y,z = coord - return self._grid._cell_contains(self._idx, x,y,z) - - def __eq__(self, other): - if isinstance(other, Cell): - idx_eq = self.global_index == other.global_index - return idx_eq and self._grid == other._grid - return NotImplemented - - def __neq__(self, other): - if isinstance(other, Cell): - return not self == other - return NotImplemented - - def hash(self): - return hash((self._idx, self._aidx, self.ijk)) - - @property - def coordinate(self): - return self._grid.get_xyz(global_index=self._idx) - - @property - def corners(self): - """ - Return xyz for each of the eight vertices, indexed by: - - lower layer: upper layer - - 2---3 6---7 - | | | | - 0---1 4---5 - """ - cs = lambda c : self._grid.get_cell_corner(c, global_index=self._idx) - return [cs(i) for i in range(8)] - - def __repr__(self): - act = 'active' if self.active else 'inactive' - pos = '(%.3f, %.3f, %.3f)' % self.coordinate - cnt = '%d, %d, %d, %s, %s, grid=%s' % (self.i, self.j, self.k, - act, pos, - self._grid.get_name()) - - return 'Cell(%s)' % cnt diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py deleted file mode 100644 index 7625a2de7c..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.ecl import EclFile, Ecl3DKW - - -class Ecl3DFile(EclFile): - - def __init__(self, grid, filename, flags=0): - self.grid = grid - super(Ecl3DFile, self).__init__(filename, flags) - - - def __getitem__(self, index): - return_arg = super(Ecl3DFile, self).__getitem__(index) - if isinstance(return_arg,list): - kw_list = return_arg - else: - kw_list = [return_arg] - - # Go through all the keywords and try inplace promotion to Ecl3DKW - for kw in kw_list: - try: - Ecl3DKW.castFromKW(kw, self.grid) - except ValueError: - pass - - return return_arg diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py deleted file mode 100644 index 0f6a91994a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py +++ /dev/null @@ -1,239 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'ecl_3dkw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -from ecl.util import monkey_the_camel -from .ecl_kw import EclKW - -class Ecl3DKW(EclKW): - """ - Class for working with Eclipse keywords defined over a grid - - The Ecl3DKW class is derived from the EclKW class, and most of the - methods are implemented in the EclKW base class. The purpose of - the Ecl3DKW class is to simplify working with 3D properties like - PORO or SATNUM. - - The Ecl3DKW class has an attached EclGrid which is used to support - [i,j,k] indexing, and a defined default value which is used when - reading an inactive value. The Ecl3DKW keyword instances are - returned from the EclInitFile and EclRestartFile classes, in - addition you can excplicitly \"cast\" a EclKW keyword to Ecl3DKW - with the Ecl3DKW.castFromKW() classmethod. - - Usage example: - - from ecl.ecl import EclInitFile,EclGrid - - grid = EclGrid("ECLIPSE.EGRID") - file = EclInitFile(grid , "ECLIPSE.INIT") - - permx_kw = file["PORO"][0] - porv_kw = file["PORV"][0] - - permx_kw.setDefault( -1 ) - for k in range(grid.getNZ()): - for j in range(grid.getNY()): - for i in range(grid.getNX()): - print('"(%d,%d,%d) Permx:%g Porv:%g"' % (i,j,k,permx_kw[i,j,k] , porv_kw[i,j,k])) - - In the example we open an ECLIPSE INIT file and extract the PERMX - and PORV properties, and then iterate over all the cells in the - grid. - - In the INIT file the PORV keyword is stored with all cells, - whereas the PERMX keyword typically only has the active cells - stored, this active/inactive gymnastics is handled - transparently. With the call: - - permx_kw.setDefault( -1 ) - - we say that we want the value -1 for all inactive cells in the - PERMX property. - - """ - def __init__(self, kw , grid , value_type , default_value = 0 , global_active = False): - if global_active: - size = grid.getGlobalSize() - else: - size = grid.getNumActive( ) - super(Ecl3DKW , self).__init__( kw , size , value_type) - self.grid = grid - self.global_active = global_active - self.setDefault( default_value ) - - - @classmethod - def create(cls , kw , grid , value_type , default_value = 0 , global_active = False): - new_kw = Ecl3DKW(kw , grid , value_type , default_value , global_active) - return new_kw - - @classmethod - def read_grdecl( cls , grid , fileH , kw , strict = True , ecl_type = None): - """ - Will load an Ecl3DKW instance from a grdecl formatted filehandle. - - See the base class EclKW.read_grdecl() for more documentation. - """ - kw = super(Ecl3DKW , cls).read_grdecl( fileH , kw , strict , ecl_type) - Ecl3DKW.castFromKW(kw , grid) - return kw - - - - def __getitem__(self , index): - """Will return item [g] or [i,j,k]. - - The __getitem__() methods supports both scalar indexing like - [g] and tuples [i,j,k]. If the input argument is given as a - [i,j,k] tuple it is converted to an active index before the - final lookup. - - If the [i,j,k] input corresponds to an inactive cell in a - keyword with only nactive elements the default value will be - returned. By default the default value will be 0, but another - value can be assigned with the setDefault() method. - """ - if isinstance(index , tuple): - global_index = self.grid.get_global_index( ijk = index ) - if self.global_active: - index = global_index - else: - if not self.grid.active( global_index = global_index): - return self.getDefault() - else: - index = self.grid.get_active_index( ijk = index ) - - - return super(Ecl3DKW , self).__getitem__( index ) - - - - - def __setitem__(self , index , value): - """Set the value of at index [g] or [i,j,k]. - - The __setitem__() methods supports both scalar indexing like - [g] and tuples [i,j,k]. If the input argument is given as a - [i,j,k] tuple it is converted to an active index before the - final assignment. - - If you try to assign an inactive cell in a keyword with only - nactive elements a ValueError() exception will be raised. - """ - if isinstance(index , tuple): - global_index = self.grid.get_global_index( ijk = index ) - if self.global_active: - index = global_index - else: - if not self.grid.active( global_index = global_index): - raise ValueError("Tried to assign value to inactive cell: (%d,%d,%d)" % index) - else: - index = self.grid.get_active_index( ijk = index ) - - - return super(Ecl3DKW , self).__setitem__( index , value ) - - - @classmethod - def cast_from_kw(cls, kw, grid, default_value=0): - """Will convert a normal EclKW to a Ecl3DKW. - - The method will convert a normal EclKW instance to Ecl3DKw - instance with an attached grid and a default value. - - The method will check that size of the keyword is compatible - with the grid dimensions, i.e. the keyword must have either - nactive or nx*ny*nz elements. If the size of the keyword is - not compatible with the grid dimensions a ValueError exception - is raised. - - Example: - - 1. Load the poro keyword from a grdecl formatted file. - 2. Convert the keyword to a 3D keyword. - - - from ecl.ecl import EclGrid,EclKW,Ecl3DKW - - grid = EclGrid("ECLIPSE.EGRID") - poro = EclKW.read_grdecl(open("poro.grdecl") , "PORO") - Ecl3DKW.castFromKW( poro , grid ) - - print('Porosity in cell (10,11,12):%g' % poro[10,11,12]) - """ - if len(kw) == grid.getGlobalSize(): - kw.global_active = True - elif len(kw) == grid.getNumActive(): - kw.global_active = False - else: - raise ValueError("Size mismatch - must have size matching global/active size of grid") - - - kw.__class__ = cls - kw.default_value = default_value - kw.grid = grid - if len(kw) == grid.getGlobalSize(): - kw.global_active = True - else: - kw.global_active = False - - kw.setDefault( default_value ) - return kw - - - def compressed_copy(self): - """Will return a EclKW copy with nactive elements. - - The returned copy will be of type EclKW; i.e. no default - interpolation and only linear access in the [] operator. The - main purpose of this is to facilitate iteration over the - active index, and for writing binary files. - """ - return self.grid.compressedKWCopy( self ) - - - def global_copy(self): - """Will return a EclKW copy with nx*ny*nz elements. - - The returned copy will be of type EclKW; i.e. no default - interpolation and only linear access in the [] operator. The - main purpose of this is to facilitate iteration over the - global index, and for writing binary files. - """ - return self.grid.globalKWCopy( self , self.getDefault() ) - - - - def dims(self): - return (self.grid.getNX() , self.grid.getNY() , self.grid.getNZ()) - - - def set_default(self, default_value): - self.default_value = default_value - - - def get_default(self): - return self.default_value - - -monkey_the_camel(Ecl3DKW, 'castFromKW', Ecl3DKW.cast_from_kw, classmethod) -monkey_the_camel(Ecl3DKW, 'compressedCopy', Ecl3DKW.compressed_copy) -monkey_the_camel(Ecl3DKW, 'globalCopy', Ecl3DKW.global_copy) -monkey_the_camel(Ecl3DKW, 'setDefault', Ecl3DKW.set_default) -monkey_the_camel(Ecl3DKW, 'getDefault', Ecl3DKW.get_default) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py deleted file mode 100644 index bd85dcde2b..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.util import monkey_the_camel -from ecl.ecl import EclSum - -class EclCase(object): - - def __init__(self, case): - self.case = case - - self.grid = None - self.restart = None - self.init = None - self.summary = None - - self.loadSummary() - - - def __contains__(self, key): - return key in self.summary - - - def keys(self): - return self.summary.keys() - - - def wells(self): - return self.summary.wells() - - def load_summary(self): - self.summary = EclSum(self.case) - - - def start_time_equal(self, other): - if self.summary.getDataStartTime() == other.summary.getDataStartTime(): - return True - else: - return False - - def end_time_equal(self, other): - if self.summary.getEndTime() == other.summary.getEndTime(): - return True - else: - return False - - - def cmp_summary_vector(self, other, key, sample=100): - if key in self and key in other: - days_total = min(self.summary.getSimulationLength(), other.summary.getSimulationLength()) - dt = days_total / (sample - 1) - days = [ x * dt for x in range(sample) ] - - ref_data = self.summary.get_interp_vector(key, days_list=days) - test_data = other.summary.get_interp_vector(key, days_list=days) - diff_data = ref_data - test_data - - ref_sum = sum(ref_data) - diff_sum = sum(abs(diff_data)) - return (diff_sum, ref_sum) - else: - raise KeyError("Key:%s was not present in both cases" % key) - - - - - -class EclCmp(object): - - def __init__(self, test_case, ref_case): - """Class to compare to simulation cases with Eclipse formatted result files. - - The first argument is supposed to be the test_case and the - second argument is the reference case. The arguemnts should be - the basenames of the simulation, with an optional path - prefix - an extension is accepted, but will be ignored. - - The constructor will start be calling the method initCheck() - to check that the two cases are 'in the same ballpark'. - """ - self.test_case = EclCase(test_case) - self.ref_case = EclCase(ref_case) - - self.initCheck() - - - def init_check(self): - """A crude initial check to verify that the cases can be meaningfully - compared. - """ - if not self.test_case.startTimeEqual(self.ref_case): - raise ValueError("The two cases do not start at the same time - can not be compared") - - - def has_summary_vector(self, key): - """ - Will check if both test and refernce have @key. - """ - return (key in self.test_case, key in self.ref_case) - - - def end_time_equal(self): - """ - Will check that ref_case and test_case are equally long. - """ - return self.test_case.endTimeEqual(self.ref_case) - - - - def cmp_summary_vector(self, key, sample=100): - """Will compare the summary vectors according to @key. - - The comparison is based on evaluating the integrals: - - I0 = \int R(t) dt - - delta = \int | R(t) - T(t)| dt - - numericall. R(t) is the reference solution and T(t) is - testcase solution. The return value is a tuple: - - (delta, I0) - - So that a natural way to evaluate the check for numerical - equality, based on the relative error could be: - - delta, scale = ecl_cmp.cmpSummaryVector("WWCT:OP_1") - - if delta/scale < 0.0001: - print("Equal enough") - else: - print("Different ..") - - The upper limit for the integrals is: - - max(length(ref_case), length(test_case)) - - meaning that two simulations which don't have the same - end-time will compare as equal if they compare equal in the - common part. If that is not OK you should call the - endTimeEqual() method independently. - """ - return self.test_case.cmpSummaryVector(self.ref_case, key, sample=sample) - - - def test_keys(self): - """ - Will return a list of summary keys in the test case. - """ - return self.test_case.keys() - - - def test_wells(self): - """ - Will return a list of wells keys in the test case. - """ - return self.test_case.wells() - - - -monkey_the_camel(EclCase, 'loadSummary', EclCase.load_summary) -monkey_the_camel(EclCase, 'startTimeEqual', EclCase.start_time_equal) -monkey_the_camel(EclCase, 'endTimeEqual', EclCase.end_time_equal) -monkey_the_camel(EclCase, 'cmpSummaryVector', EclCase.cmp_summary_vector) - -monkey_the_camel(EclCmp, 'initCheck', EclCmp.init_check) -monkey_the_camel(EclCmp, 'hasSummaryVector', EclCmp.has_summary_vector) -monkey_the_camel(EclCmp, 'endTimeEqual', EclCmp.end_time_equal) -monkey_the_camel(EclCmp, 'cmpSummaryVector', EclCmp.cmp_summary_vector) -monkey_the_camel(EclCmp, 'testKeys', EclCmp.test_keys) -monkey_the_camel(EclCmp, 'testWells', EclCmp.test_wells) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py deleted file mode 100644 index c8fd6c7280..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py +++ /dev/null @@ -1,718 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -The ecl_file module contains functionality to load a an ECLIPSE file -in 'restart format'. Files of 'restart format' include restart files, -init files, grid files, summary files and RFT files. - -The ecl_file implementation is agnostic[1] to the content and -structure of the file; more specialized classes like EclSum and -EclGrid use the EclFile functionality for low level file loading. - -The typical usage involves loading a complete file, and then -subsequently querying for various keywords. In the example below we -load a restart file, and ask for the SWAT keyword: - - file = EclFile( "ECLIPSE.X0067" ) - swat_kw = file.iget_named_kw( "SWAT" , 0 ) - -The ecl_file module is a thin wrapper around the ecl_file.c -implementation from the libecl library. - -[1]: In particular for restart files, which do not have a special - RestartFile class, there is some specialized functionality. -""" -import re -import types -import datetime -import ctypes - -from cwrap import BaseCClass -from ecl.util import CTime -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype, EclKW, EclFileEnum, EclFileView - - -class EclFile(BaseCClass): - TYPE_NAME = "ecl_file" - _open = EclPrototype("void* ecl_file_open( char* , int )" , bind = False) - _get_file_type = EclPrototype("ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)" , bind = False) - _writable = EclPrototype("bool ecl_file_writable( ecl_file )") - _save_kw = EclPrototype("void ecl_file_save_kw( ecl_file , ecl_kw )") - _close = EclPrototype("void ecl_file_close( ecl_file )") - _iget_restart_time = EclPrototype("time_t ecl_file_iget_restart_sim_date( ecl_file , int )") - _iget_restart_days = EclPrototype("double ecl_file_iget_restart_sim_days( ecl_file , int )") - _get_restart_index = EclPrototype("int ecl_file_get_restart_index( ecl_file , time_t)") - _get_src_file = EclPrototype("char* ecl_file_get_src_file( ecl_file )") - _replace_kw = EclPrototype("void ecl_file_replace_kw( ecl_file , ecl_kw , ecl_kw , bool)") - _fwrite = EclPrototype("void ecl_file_fwrite_fortio( ecl_file , fortio , int)") - _has_report_step = EclPrototype("bool ecl_file_has_report_step( ecl_file , int)") - _has_sim_time = EclPrototype("bool ecl_file_has_sim_time( ecl_file , time_t )") - _get_global_view = EclPrototype("ecl_file_view_ref ecl_file_get_global_view( ecl_file )") - _write_index = EclPrototype("bool ecl_file_write_index( ecl_file , char*)") - _fast_open = EclPrototype("void* ecl_file_fast_open( char* , char* , int )" , bind=False) - - - @staticmethod - def get_filetype(filename): - fmt_file = ctypes.c_bool() - report_step = ctypes.c_int() - - file_type = EclFile._get_file_type( filename , ctypes.byref( fmt_file ) , ctypes.byref(report_step)) - if file_type in [EclFileEnum.ECL_RESTART_FILE , EclFileEnum.ECL_SUMMARY_FILE]: - report_step = report_step.value - else: - report_step = None - - if file_type in [EclFileEnum.ECL_OTHER_FILE , EclFileEnum.ECL_DATA_FILE]: - fmt_file = None - else: - fmt_file = fmt_file.value - - - return (file_type , report_step , fmt_file ) - - - - @classmethod - def restart_block( cls , filename , dtime = None , report_step = None): - raise NotImplementedError("The restart_block implementation has been removed - open file normally and use EclFileView.") - - - - @classmethod - def contains_report_step( cls , filename , report_step ): - """ - Will check if the @filename contains @report_step. - - This classmethod works by opening the file @filename and - searching through linearly to see if an ecl_kw with value - corresponding to @report_step can be found. Since this is a - classmethod it is invoked like this: - - import ecl.ecl.ecl as ecl - .... - if ecl.EclFile.contains_report_step("ECLIPSE.UNRST" , 20): - print "OK - file contains report step 20" - else: - print "File does not contain report step 20" - - If you have already loaded the file into an EclFile instance - you should use the has_report_step() method instead. - """ - obj = EclFile( filename ) - return obj.has_report_step( report_step ) - - - @classmethod - def contains_sim_time( cls , filename , dtime ): - """ - Will check if the @filename contains simulation at @dtime. - - This classmethod works by opening the file @filename and - searching through linearly to see if a result block at the - time corresponding to @dtime can be found. Since this is a - classmethod it is invoked like this: - - import ecl.ecl.ecl as ecl - .... - if ecl.EclFile.contains_sim_time("ECLIPSE.UNRST" , datetime.datetime( 2007 , 10 , 10) ): - print "OK - file contains 10th of October 2007" - else: - print "File does not contain 10th of October 2007" - - If you have already loaded the file into an EclFile instance - you should use the has_sim_time() method instead. - """ - obj = EclFile( filename ) - return obj.has_sim_time( dtime ) - - @property - def report_list(self): - report_steps = [] - try: - seqnum_list = self["SEQNUM"] - for s in seqnum_list: - report_steps.append( s[0] ) - except KeyError: - # OK - we did not have seqnum; that might be because this - # a non-unified restart file; or because this is not a - # restart file at all. - fname = self.getFilename( ) - matchObj = re.search("\.[XF](\d{4})$" , fname) - if matchObj: - report_steps.append( int(matchObj.group(1)) ) - else: - raise TypeError('Tried get list of report steps from file "%s" - which is not a restart file' % fname) - - - return report_steps - - - - @classmethod - def file_report_list( cls , filename ): - """ - Will identify the available report_steps from @filename. - """ - - file = EclFile( filename ) - return file.report_list - - - - def __repr__(self): - fn = self.getFilename() - wr = ', read/write' if self._writable() else '' - return self._create_repr('"%s"%s' % (fn,wr)) - - - def __init__( self , filename , flags = 0 , index_filename = None): - """ - Loads the complete file @filename. - - Will create a new EclFile instance with the content of file - @filename. The file @filename must be in 'restart format' - - otherwise it will be crash and burn. - - The optional argument flags can be an or'ed combination of the - flags: - - ecl.ECL_FILE_WRITABLE : It is possible to update the - content of the keywords in the file. - - ecl.ECL_FILE_CLOSE_STREAM : The underlying FILE * is closed - when not used; to save number of open file descriptors - in cases where a high number of EclFile instances are - open concurrently. - - When the file has been loaded the EclFile instance can be used - to query for and get reference to the EclKW instances - constituting the file, like e.g. SWAT from a restart file or - FIPNUM from an INIT file. - """ - if index_filename is None: - c_ptr = self._open( filename , flags ) - else: - c_ptr = self._fast_open(filename, index_filename, flags) - - if c_ptr is None: - raise IOError('Failed to open file "%s"' % filename) - else: - super(EclFile , self).__init__(c_ptr) - self.global_view = self._get_global_view( ) - self.global_view.setParent( self ) - - - def save_kw( self , kw ): - """ - Will write the @kw back to file. - - This function should typically be used in situations like this: - - 1. Create an EclFile instance around an ECLIPSE output file. - 2. Extract a keyword of interest and modify it. - 3. Call this method to save the modifications to disk. - - There are several restrictions to the use of this function: - - 1. The EclFile instance must have been created with the - optional read_only flag set to False. - - 2. You can only modify the content of the keyword; if you - try to modify the header in any way (i.e. size, datatype - or name) the function will fail. - - 3. The keyword you are trying to save must be exactly the - keyword you got from this EclFile instance, otherwise the - function will fail. - """ - if self._writable( ): - self._save_kw( kw ) - else: - raise IOError('save_kw: the file "%s" has been opened read only.' % self.getFilename( )) - - - def __len__(self): - return len(self.global_view) - - - def close(self): - if self: - self._close( ) - self._invalidateCPointer( ) - - - def free(self): - self.close() - - - def block_view(self, kw, kw_index): - if not kw in self: - raise KeyError('No such keyword "%s".' % kw) - ls = self.global_view.numKeywords(kw) - idx = kw_index - if idx < 0: - idx += ls - if 0 <= idx < ls: - return self.global_view.blockView(kw, idx) - raise IndexError('Index out of range, must be in [0, %d), was %d.' % (ls, kw_index)) - - - def block_view2(self, start_kw, stop_kw, start_index): - return self.global_view.blockView2( start_kw , stop_kw, start_index ) - - - def restart_view(self, seqnum_index=None, report_step=None, sim_time=None, sim_days=None): - return self.global_view.restartView( seqnum_index, report_step , sim_time, sim_days ) - - - def select_block(self, kw, kw_index): - raise NotImplementedError("The select_block implementation has been removed - use EclFileView") - - - def select_global( self ): - raise NotImplementedError("The select_global implementation has been removed - use EclFileView") - - - def select_restart_section( self, index = None , report_step = None , sim_time = None): - raise NotImplementedError("The select_restart_section implementation has been removed - use EclFileView") - """ - Will select a restart section as the active section. - - You must specify a report step with the @report_step argument, - a true time with the @sim_time argument or a plain index to - select restart block. If none of arguments are given exception - TypeError will be raised. If present the @sim_time argument - should be a datetime instance. - - If the restart section you ask for can not be found the method - will raise a ValueError exeception. To protect against this - you can query first with the has_report_step(), - has_sim_time() or num_report_steps() methods. - - This method should be used when you have already loaded the - complete file; if you only want to load a section from the - file you can use the classmethod restart_block(). - - The method will return 'self' which can be used to aid - readability. - """ - - - - def select_last_restart( self ): - raise NotImplementedError("The select_restart_section implementation has been removed - use EclFileView") - """ - Will select the last SEQNUM block in restart file. - - Works by searching for the last SEQNUM keyword; the SEQNUM - Keywords are only present in unified restart files. If this - is a non-unified restart file (or not a restart file at all), - the method will do nothing and return False. - """ - - - - - - def __getitem__(self , index): - """ - Implements [] operator; index can be integer or key. - - Will look up EclKW instances from the current EclFile - instance. The @index argument can either be an integer, in - which case the method will return EclKW number @index, or - alternatively a keyword string, in which case the method will - return a list of EclKW instances with that keyword: - - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") - kw9 = restart_file[9] - swat_list = restart_file["SWAT"] - - The keyword based lookup can be combined with an extra [] to - get EclKW instance nr: - - swat9 = restart_file["SWAT"][9] - - Will return the 10'th SWAT keyword from the restart file. The - following example will iterate over all the SWAT keywords in a - restart file: - - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") - for swat in restart_file["SWAT"]: - .... - """ - if isinstance(index, int): - ls = len(self) - idx = index - if idx < 0: - idx += ls - if 0 <= idx < ls: - return self.global_view[idx] - else: - raise IndexError('Index must be in [0, %d), was: %d.' % (ls, index)) - return self.global_view[index] - - - def iget_kw( self , index , copy = False): - """ - Will return EclKW instance nr @index. - - In the files loaded with the EclFile implementation the - ECLIPSE keywords come sequentially in a long series, an INIT - file might have the following keywords: - - INTEHEAD - LOGIHEAD - DOUBHEAD - PORV - DX - DY - DZ - PERMX - PERMY - PERMZ - MULTX - MULTY - ..... - - The iget_kw() method will give you a EclKW reference to - keyword nr @index. This functionality is also available - through the index operator []: - - file = EclFile( "ECLIPSE.INIT" ) - permx = file.iget_kw( 7 ) - permz = file[ 9 ] - - Observe that the returned EclKW instance is only a reference - to the data owned by the EclFile instance. - - The method iget_named_kw() which lets you specify the name of - the keyword you are interested in is in general more useful - than this method. - """ - kw = self[index] - if copy: - return EclKW.copy( kw ) - else: - return kw - - - def iget_named_kw( self , kw_name , index , copy = False): - return self.global_view.iget_named_kw( kw_name , index ) - - - - def restart_get_kw( self , kw_name , dtime , copy = False): - """Will return EclKW @kw_name from restart file at time @dtime. - - This function assumes that the current EclFile instance - represents a restart file. It will then look for keyword - @kw_name exactly at the time @dtime; @dtime is a datetime - instance: - - file = EclFile( "ECLIPSE.UNRST" ) - swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 )) - - By default the returned kw instance is a reference to the - ecl_kw still contained in the EclFile instance; i.e. the kw - will become a dangling reference if the EclFile instance goes - out of scope. If the optional argument @copy is True the - returned kw will be a true copy. - - If the file does not have the keyword at the specified time - the function will raise IndexError(); if the file does not - have the keyword at all - KeyError will be raised. - """ - index = self._get_restart_index( CTime( dtime ) ) - if index >= 0: - if self.num_named_kw(kw_name) > index: - kw = self.iget_named_kw( kw_name , index ) - if copy: - return EclKW.copy( kw ) - else: - return kw - else: - if self.has_kw(kw_name): - raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime)) - else: - raise KeyError('Keyword "%s" not recognized.' % kw_name) - else: - raise IndexError('Does not have keyword "%s" at time:%s.' % (kw_name , dtime)) - - - def replace_kw( self , old_kw , new_kw): - """ - Will replace @old_kw with @new_kw in current EclFile instance. - - This method can be used to replace one of the EclKW instances - in the current EclFile. The @old_kw reference must be to the - actual EclKW instance in the current EclFile instance (the - final comparison is based on C pointer equality!), i.e. it - must be a reference (not a copy) from one of the ??get_kw?? - methods of the EclFile class. In the example below we replace - the SWAT keyword from a restart file: - - swat = file.iget_named_kw( "SWAT" , 0 ) - new_swat = swat * 0.25 - file.replace_kw( swat , new_swat ) - - - The C-level ecl_file_type structure takes full ownership of - all installed ecl_kw instances; mixing the garbage collector - into it means that this is quite low level - and potentially - dangerous! - """ - - # We ensure that this scope owns the new_kw instance; the - # new_kw will be handed over to the ecl_file instance, and we - # can not give away something we do not alreeady own. - if not new_kw.data_owner: - new_kw = EclKW.copy( new_kw ) - - # The ecl_file instance will take responsability for freeing - # this ecl_kw instance. - new_kw.data_owner = False - self._replace_kw( old_kw , new_kw , False ) - - - - @property - def size(self): - """ - The number of keywords in the current EclFile object. - """ - return len(self) - - @property - def unique_size( self ): - """ - The number of unique keyword (names) in the current EclFile object. - """ - return self.global_view.uniqueSize( ) - - - - def keys(self): - """ - Will return a list of unique kw names - like keys() on a dict. - """ - header_dict = {} - for index in range(len(self)): - kw = self[index] - header_dict[ kw.getName() ] = True - return header_dict.keys() - - - @property - def headers(self): - """ - Will return a list of the headers of all the keywords. - """ - header_list = [] - for index in range(self.size): - kw = self[index] - header_list.append( kw.header ) - return header_list - - @property - def report_steps( self ): - """ - Will return a list of all report steps. - - The method works by iterating through the whole restart file - looking for 'SEQNUM' keywords; if the current EclFile instance - is not a restart file it will not contain any 'SEQNUM' - keywords and the method will simply return an empty list. - """ - steps = [] - seqnum_list = self["SEQNUM"] - for kw in self["SEQNUM"]: - steps.append( kw[0] ) - return steps - - @property - def report_dates( self ): - """ - Will return a list of the dates for all report steps. - - The method works by iterating through the whole restart file - looking for 'SEQNUM/INTEHEAD' keywords; the method can - probably be tricked by other file types also containing an - INTEHEAD keyword. - """ - if self.has_kw('SEQNUM'): - dates = [] - for index in range( self.num_named_kw( 'SEQNUM' )): - dates.append( self.iget_restart_sim_time( index )) - return dates - elif 'INTEHEAD' in self: - # This is a uber-hack; should export the ecl_rsthead - # object as ctypes structure. - intehead = self["INTEHEAD"][0] - year = intehead[66] - month = intehead[65] - day = intehead[64] - date = datetime.datetime( year , month , day ) - return [ date ] - return None - - - @property - def dates( self ): - """ - Will return a list of the dates for all report steps. - """ - return self.report_dates - - - def num_named_kw( self , kw): - """ - The number of keywords with name == @kw in the current EclFile object. - """ - return self.global_view.numKeywords( kw ) - - - def has_kw( self , kw , num = 0): - """ - Check if current EclFile instance has a keyword @kw. - - If the optional argument @num is given it will check if the - EclFile has at least @num occurences of @kw. - """ - - return self.num_named_kw( kw ) > num - - def __contains__(self , kw): - """ - Check if the current file contains keyword @kw. - """ - return self.has_kw( kw ) - - def has_report_step( self , report_step ): - """ - Checks if the current EclFile has report step @report_step. - - If the EclFile in question is not a restart file, you will - just get False. If you want to check if the file contains the - actual report_step before loading the file, you should use the - classmethod contains_report_step() instead. - """ - return self._has_report_step( report_step ) - - def num_report_steps( self ): - """ - Returns the total number of report steps in the restart file. - - Works by counting the number of 'SEQNUM' instances, and will - happily return 0 for a non-restart file. Observe that the - report_steps present in a unified restart file are in general - not consecutive, i.e. the last report step will typically be - much higher than the return value from this function. - """ - return len( self["SEQNUM"] ) - - - - def has_sim_time( self , dtime ): - """ - Checks if the current EclFile has data for time @dtime. - - The implementation goes through all the INTEHEAD headers in - the EclFile, i.e. it can be fooled (and probably crash and - burn) if the EclFile instance in question is has INTEHEAD - keyword(s), but is still not a restart file. The @dtime - argument should be a normal python datetime instance. - """ - return self._has_sim_time( CTime(dtime) ) - - - def iget_restart_sim_time( self , index ): - """ - Will locate restart block nr @index and return the true time - as a datetime instance. - """ - ct = CTime(self._iget_restart_time( index )) - return ct.datetime() - - - def iget_restart_sim_days( self , index ): - """ - Will locate restart block nr @index and return the number of days - (in METRIC at least ...) since the simulation started. - - """ - return self._iget_restart_days( index ) - - - def get_filename(self): - """ - Name of the file currently loaded. - """ - fn = self._get_src_file() - return str(fn) if fn else '' - - def fwrite( self , fortio ): - """ - Will write current EclFile instance to fortio stream. - - ECLIPSE is written in Fortran; and a "special" handle for - Fortran IO must be used when reading and writing these files. - This method will write the current EclFile instance to a - FortIO stream already opened for writing: - - import ecl.ecl.ecl as ecl - ... - fortio = ecl.FortIO( "FILE.XX" ) - file.fwrite( fortio ) - fortio.close() - - """ - self._fwrite( fortio , 0 ) - - def write_index(self, index_file_name): - if not self._write_index(index_file_name): - raise IOError("Failed to write index file:%s" % index_file_name) - - -class EclFileContextManager(object): - - def __init__(self , ecl_file): - self.__ecl_file = ecl_file - - def __enter__(self): - return self.__ecl_file - - def __exit__(self, exc_type, exc_val, exc_tb): - self.__ecl_file.close() - return False - - -def openEclFile( file_name , flags = 0): - print('The function openEclFile is deprecated, use open_ecl_file.') - return open_ecl_file(file_name, flags) - -def open_ecl_file(file_name, flags=0): - return EclFileContextManager(EclFile(file_name, flags)) - - - -monkey_the_camel(EclFile, 'getFileType', EclFile.get_filetype, staticmethod) -monkey_the_camel(EclFile, 'blockView', EclFile.block_view) -monkey_the_camel(EclFile, 'blockView2', EclFile.block_view2) -monkey_the_camel(EclFile, 'restartView', EclFile.restart_view) -monkey_the_camel(EclFile, 'getFilename', EclFile.get_filename) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py deleted file mode 100644 index 1c90a235a7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py +++ /dev/null @@ -1,200 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import absolute_import, division, print_function, unicode_literals -from six import string_types -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype - -class EclFileView(BaseCClass): - TYPE_NAME = "ecl_file_view" - _iget_kw = EclPrototype("ecl_kw_ref ecl_file_view_iget_kw( ecl_file_view , int)") - _iget_named_kw = EclPrototype("ecl_kw_ref ecl_file_view_iget_named_kw( ecl_file_view , char* , int)") - _get_size = EclPrototype("int ecl_file_view_get_size( ecl_file_view )") - _get_num_named_kw = EclPrototype("int ecl_file_view_get_num_named_kw( ecl_file_view , char* )") - _get_unique_size = EclPrototype("int ecl_file_view_get_num_distinct_kw( ecl_file_view )") - _create_block_view = EclPrototype("ecl_file_view_ref ecl_file_view_add_blockview( ecl_file_view , char*, int )") - _create_block_view2 = EclPrototype("ecl_file_view_ref ecl_file_view_add_blockview2( ecl_file_view , char*, char*, int )") - _restart_view = EclPrototype("ecl_file_view_ref ecl_file_view_add_restart_view( ecl_file_view , int, int, time_t, double )") - - - def __init__(self): - raise NotImplementedError("Can not instantiate directly") - - - def __iget(self, index): - return self._iget_kw(index).setParent(parent=self) - - - def __repr__(self): - return 'EclFileView(size=%d) %s' % (len(self), self._ad_str()) - - def iget_named_kw(self, kw_name, index): - if not kw_name in self: - raise KeyError("No such keyword: %s" % kw_name) - - if index >= self.numKeywords(kw_name): - raise IndexError("Too large index: %d" % index) - - return self._iget_named_kw(kw_name, index).setParent(parent=self) - - - - def __getitem__(self, index): - """ - Implements [] operator; index can be integer or key. - - Will look up EclKW instances from the current EclFile - instance. The @index argument can either be an integer, in - which case the method will return EclKW number @index, or - alternatively a keyword string, in which case the method will - return a list of EclKW instances with that keyword: - - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") - kw9 = restart_file[9] - swat_list = restart_file["SWAT"] - - The keyword based lookup can be combined with an extra [] to - get EclKW instance nr: - - swat9 = restart_file["SWAT"][9] - - Will return the 10'th SWAT keyword from the restart file. The - following example will iterate over all the SWAT keywords in a - restart file: - - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") - for swat in restart_file["SWAT"]: - .... - """ - - if isinstance(index, int): - ls = len(self) - idx = index - if idx < 0: - idx += ls - if 0 <= idx < ls: - return self.__iget(idx) - else: - raise IndexError('Index must be in [0, %d), was: %d.' % (ls, index)) - - if isinstance(index, slice): - indices = index.indices(len(self)) - kw_list = [] - for i in range(*indices): - kw_list.append(self[i]) - return kw_list - else: - if isinstance(index, bytes): - index = index.decode('ascii') - if isinstance(index, string_types): - if index in self: - kw_index = index - kw_list = [] - for index in range(self.numKeywords(kw_index)): - kw_list.append( self.iget_named_kw(kw_index, index)) - return kw_list - else: - raise KeyError("Unrecognized keyword:\'%s\'" % index) - else: - raise TypeError("Index must be integer or string (keyword)") - - - def __len__(self): - return self._get_size() - - - def __contains__(self, kw): - if self.numKeywords(kw) > 0: - return True - else: - return False - - - def num_keywords(self, kw): - return self._get_num_named_kw(kw) - - - def unique_size(self): - return self._get_unique_size() - - def block_view2(self, start_kw, stop_kw, start_index): - idx = start_index - if start_kw: - if not start_kw in self: - raise KeyError("The keyword:%s is not in file" % start_kw) - - ls = self.numKeywords(start_kw) - if idx < 0: - idx += ls - if not (0 <= idx < ls): - raise IndexError('Index must be in [0, %d), was: %d.' % (ls, start_index)) - - if stop_kw: - if not stop_kw in self: - raise KeyError("The keyword:%s is not in file" % stop_kw) - - view = self._create_block_view2(start_kw, stop_kw, idx) - view.setParent(parent=self) - return view - - - def block_view(self, kw, kw_index): - num = self.numKeywords(kw) - - if num == 0: - raise KeyError("Unknown keyword: %s" % kw) - - idx = kw_index - if idx < 0: - idx += num - - if not (0 <= idx < num): - raise IndexError('Index must be in [0, %d), was: %d.' % (num, kw_index)) - - view = self._create_block_view(kw, kw_index) - view.setParent(parent=self) - return view - - - def restart_view(self, seqnum_index=None, report_step=None, sim_time=None, sim_days=None): - if report_step is None: - report_step = -1 - - if sim_time is None: - sim_time = -1 - - if sim_days is None: - sim_days = -1 - - if seqnum_index is None: - seqnum_index = -1 - - view = self._restart_view(seqnum_index, report_step, CTime(sim_time), sim_days) - if view is None: - raise ValueError("No such restart block could be identiefied") - - view.setParent(parent=self) - return view - - -monkey_the_camel(EclFileView, 'numKeywords', EclFileView.num_keywords) -monkey_the_camel(EclFileView, 'uniqueSize', EclFileView.unique_size) -monkey_the_camel(EclFileView, 'blockView2', EclFileView.block_view2) -monkey_the_camel(EclFileView, 'blockView', EclFileView.block_view) -monkey_the_camel(EclFileView, 'restartView', EclFileView.restart_view) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py deleted file mode 100644 index caffe5d597..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_grav.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Calculate dynamic change in gravitational strength. - -The ecl_grav module contains functionality to load time-lapse ECLIPSE -results and calculate the change in gravitational strength between the -different surveys. The implementation is a thin wrapper around the -ecl_grav.c implementation in the libecl library. -""" -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPhaseEnum, EclPrototype - -class EclGrav(BaseCClass): - """ - Holding ECLIPSE results for calculating gravity changes. - - The EclGrav class is a collection class holding the results from - ECLIPSE forward modelling of gravity surveys. Observe that the - class is focused on the ECLIPSE side of things, and does not have - any notion of observed values or measurement locations; that - should be handled by the scope using the EclGrav class. - - Typical use of the EclGrav class involves the following steps: - - 1. Create the EclGrav instance. - 2. Add surveys with the add_survey_XXXX() methods. - 3. Evalute the gravitational response with the eval() method. - """ - TYPE_NAME = "ecl_grav" - _grav_alloc = EclPrototype("void* ecl_grav_alloc(ecl_grid, ecl_file)", bind=False) - _free = EclPrototype("void ecl_grav_free(ecl_grav)") - _add_survey_RPORV = EclPrototype("void* ecl_grav_add_survey_RPORV(ecl_grav, char*, ecl_file_view)") - _add_survey_PORMOD = EclPrototype("void* ecl_grav_add_survey_PORMOD(ecl_grav, char*, ecl_file_view)") - _add_survey_FIP = EclPrototype("void* ecl_grav_add_survey_FIP(ecl_grav, char*, ecl_file_view)") - _add_survey_RFIP = EclPrototype("void* ecl_grav_add_survey_RFIP(ecl_grav, char*, ecl_file_view)") - _new_std_density = EclPrototype("void ecl_grav_new_std_density(ecl_grav, int, double)") - _add_std_density = EclPrototype("void ecl_grav_add_std_density(ecl_grav, int, int, double)") - _eval = EclPrototype("double ecl_grav_eval(ecl_grav, char*, char*, ecl_region, double, double, double, int)") - - - - def __init__(self, grid, init_file): - """ - Creates a new EclGrav instance. - - The input arguments @grid and @init_file should be instances - of EclGrid and EclFile respectively. - """ - self.init_file = init_file # Inhibit premature garbage collection of init_file - - c_ptr = self._grav_alloc(grid, init_file) - super(EclGrav, self).__init__(c_ptr) - - self.dispatch = {"FIP" : self.add_survey_FIP, - "RFIP" : self.add_survey_RFIP, - "PORMOD" : self.add_survey_PORMOD, - "RPORV" : self.add_survey_RPORV} - - - def add_survey_RPORV(self, survey_name, restart_view): - """ - Add new survey based on RPORV keyword. - - Add a new survey; in this context a survey is the state of - reservoir, i.e. an ECLIPSE restart file. The @survey_name - input argument will be used when refering to this survey at a - later stage. The @restart_view input argument should be an - EclFile instance with data from one report step. A typical way - to load the @restart_view argument is: - - import datetime - from ecl.ecl import EclRestartFile - ... - ... - date = datetime.datetime(year, month, day) - rst_file = EclRestartFile("ECLIPSE.UNRST") - restart_view1 = rst_file.restartView(sim_time=date) - restart_view2 = rst_file.restartView(report_step=67) - - The pore volume of each cell will be calculated based on the - RPORV keyword from the restart files. The methods - add_survey_PORMOD() and add_survey_FIP() are alternatives - which are based on other keywords. - """ - self._add_survey_RPORV(survey_name, restart_view) - - def add_survey_PORMOD(self, survey_name, restart_view): - """ - Add new survey based on PORMOD keyword. - - The pore volum is calculated from the initial pore volume and - the PORV_MOD keyword from the restart file; see - add_survey_RPORV() for further details. - """ - self._add_survey_PORMOD(survey_name, restart_view) - - def add_survey_FIP(self, survey_name, restart_view): - """ - Add new survey based on FIP keywords. - - This method adds a survey as add_survey_RPORV() and - add_survey_PORMOD; but the mass content in each cell is - calculated based on the FIPxxx keyword along with the mass - density at standard conditions of the respective phases. - - The mass density at standard conditions must be specified with - the new_std_density() (and possibly also add_std_density()) - method before calling the add_survey_FIP() method. - """ - self._add_survey_FIP(survey_name, restart_view) - - def add_survey_RFIP(self, survey_name, restart_view): - """ - Add new survey based on RFIP keywords. - - This method adds a survey as add_survey_RPORV() and - add_survey_PORMOD; but the mass content in each cell is - calculated based on the RFIPxxx keyword along with the - per-cell mass density of the respective phases. - """ - self._add_survey_RFIP(survey_name, restart_view) - - def add_survey(self, name, restart_view, method): - method = self.dispatch[ method ] - return method(name, restart_view) - - def eval(self, base_survey, monitor_survey, pos, region=None, - phase_mask=EclPhaseEnum.ECL_OIL_PHASE + EclPhaseEnum.ECL_GAS_PHASE + EclPhaseEnum.ECL_WATER_PHASE): - """ - Calculates the gravity change between two surveys. - - This is the method everything is leading up to; will calculate - the change in gravitational strength, in units of micro Gal, - between the two surveys named @base_survey and - @monitor_survey. - - The monitor survey can be 'None' - the resulting answer has - nothing whatsovever to do with gravitation, but can be - interesting to determine the numerical size of the quantities - which are subtracted in a 4D study. - - The @pos argument should be a tuple of three elements with the - (utm_x, utm_y, depth) position where we want to evaluate the - change in gravitational strength. - - If supplied the optional argument @region should be an - EclRegion() instance; this region will be used to limit the - part of the reserviour included in the gravity calculations. - - The optional argument @phase_mask is an integer flag to - indicate which phases you are interested in. It should be a - sum of the relevant integer constants 'ECL_OIL_PHASE', - 'ECL_GAS_PHASE' and 'ECL_WATER_PHASE'. - """ - return self._eval(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], phase_mask) - - - def new_std_density(self, phase_enum, default_density): - """ - Adds a new phase with a corresponding density. - - @phase_enum is one of the integer constants ECL_OIL_PHASE, - ECL_GAS_PHASE or ECL_WATER_PHASE, all available in the - ecl_util and also ecl modules. - - @default_density is the density, at standard conditions, for - this particular phase. By default @default_density will be - used for all the cells in the model; by using the - add_std_density() method you can specify different densities - for different PVT regions. - - The new_std_density() and add_std_density() methods must be - used before you use the add_survey_FIP() method to add a - survey based on the FIP keyword. - """ - self._new_std_density(phase_enum, default_density) - - def add_std_density(self, phase_enum, pvtnum, density): - """ - Add standard conditions density for PVT region @pvtnum. - - The new_std_density() method will add a standard conditions - density which applies to all cells in the model. Using the - add_std_density() method it is possible to add standard - conditions densities on a per PVT region basis. You can add - densities for as many PVT regions as you like, and then fall - back to the default density for the others. - - The new_std_density() method must be called before calling the - add_std_density() method. - - The new_std_density() and add_std_density() methods must be - used before you use the add_survey_FIP() method to add a - survey based on the FIP keyword. - """ - self._add_std_density(phase_enum, pvtnum, density) - - - def free(self): - self._free() - -monkey_the_camel(EclGrav, 'addSurvey', EclGrav.add_survey) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py deleted file mode 100644 index ef98811eb8..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.ecl import EclPrototype - -__arglist = 'double, double, double, ' -__arglist += 'ecl_grid, ecl_file, ' -__arglist += 'ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw' -_phase_deltag = EclPrototype("double ecl_grav_phase_deltag(%s)" % __arglist) - -def phase_deltag(xyz, grid, init, sat1, rho1, porv1, sat2, rho2, porv2): - return _phase_deltag(xyz[0], xyz[1], xyz[2], - grid.c_ptr, init.c_ptr, - sat1.c_ptr, rho1.c_ptr, porv1.c_ptr, - sat2.c_ptr, rho2.c_ptr, porv2.c_ptr) - - -def deltag(xyz, grid, init_file, restart_file1, restart_file2): - """ - 1. All restart files should have water, i.e. the SWAT keyword. - 2. All phases present in the restart file should also be present as densities, - in addition the model must contain one additional phase - which should have a density. - 3. The restart files can never contain oil saturation. - """ - - swat1 = restart_file1.iget_named_kw("SWAT", 0) - swat2 = restart_file2.iget_named_kw("SWAT", 0) - - phase_list = [(swat1, swat2)] - - if restart_file1.has_kw("SGAS"): - # This is a three phase Water / Gas / Oil system - sgas1 = restart_file1.iget_named_kw("SGAS", 0) - sgas2 = restart_file2.iget_named_kw("SGAS", 0) - - soil1 = 1 - (sgas1 + swat1) - soil2 = 1 - (sgas2 + swat2) - soil1.name = "SOIL" - soil2.name = "SOIL" - phase_list += [(sgas1, sgas2), - (soil1, soil2)] - else: - # This is a two phase Water / xxx System. Will look for - # OIL_DEN and GAS_DEN keywords to determine whether it is a - # Water / Oil or Water / Gas system. - - if restart_file1.has_kw("OIL_DEN"): - # Oil / Water system - soil1 = 1 - swat1 - soil2 = 1 - swat2 - soil1.name = "SOIL" - soil2.name = "SOIL" - phase_list += [(soil1, soil2)] - else: - # Gas / Water system - sgas1 = 1 - swat1 - sgas2 = 1 - swat2 - sgas1.name = "SGAS" - sgas2.name = "SGAS" - phase_list += [(sgas1, sgas2)] - - porv1 = restart_file1.iget_named_kw("RPORV", 0) - porv2 = restart_file2.iget_named_kw("RPORV", 0) - - deltag = 0 - for (sat1, sat2) in phase_list: - rho_name = "%s_DEN" % sat1.name[1:] - rho1 = restart_file1.iget_named_kw(rho_name, 0) - rho2 = restart_file2.iget_named_kw(rho_name, 0) - deltag += phase_deltag(xyz, grid, init_file, sat1, rho1, porv1, sat2, rho2, porv2) - return deltag diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py deleted file mode 100644 index a2db004a11..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py +++ /dev/null @@ -1,1301 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_grid.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -""" -Module to load and query ECLIPSE GRID/EGRID files. - -The ecl_grid module contains functionality to load and query an -ECLIPSE grid file; it is currently not possible to manipulate or let -alone create a grid with ecl_grid module. The functionality is -implemented in the EclGrid class. The ecl_grid module is a thin -wrapper around the ecl_grid.c implementation from the libecl library. -""" -import ctypes - -import warnings -import numpy -import sys -import os.path -import math -import itertools -from cwrap import CFILE, BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclPrototype, EclDataType, EclKW, FortIO, EclUnitTypeEnum, Cell - - -class EclGrid(BaseCClass): - """ - Class for loading and internalizing ECLIPSE GRID/EGRID files. - """ - - TYPE_NAME = "ecl_grid" - _fread_alloc = EclPrototype("void* ecl_grid_load_case__(char*, bool)", bind = False) - _grdecl_create = EclPrototype("ecl_grid_obj ecl_grid_alloc_GRDECL_kw(int, int, int, ecl_kw, ecl_kw, ecl_kw, ecl_kw)", bind = False) - _alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind = False) - _exists = EclPrototype("bool ecl_grid_exists(char*)", bind = False) - - _get_numbered_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr_from_lgr_nr(ecl_grid, int)") - _get_named_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr(ecl_grid, char*)") - _get_cell_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_cell_lgr1(ecl_grid, int)") - _num_coarse_groups = EclPrototype("int ecl_grid_get_num_coarse_groups(ecl_grid)") - _in_coarse_group1 = EclPrototype("bool ecl_grid_cell_in_coarse_group1(ecl_grid, int)") - _free = EclPrototype("void ecl_grid_free(ecl_grid)") - _get_nx = EclPrototype("int ecl_grid_get_nx(ecl_grid)") - _get_ny = EclPrototype("int ecl_grid_get_ny(ecl_grid)") - _get_nz = EclPrototype("int ecl_grid_get_nz(ecl_grid)") - _get_global_size = EclPrototype("int ecl_grid_get_global_size(ecl_grid)") - _get_active = EclPrototype("int ecl_grid_get_active_size(ecl_grid)") - _get_active_fracture = EclPrototype("int ecl_grid_get_nactive_fracture(ecl_grid)") - _get_name = EclPrototype("char* ecl_grid_get_name(ecl_grid)") - _ijk_valid = EclPrototype("bool ecl_grid_ijk_valid(ecl_grid, int, int, int)") - _get_active_index3 = EclPrototype("int ecl_grid_get_active_index3(ecl_grid, int, int, int)") - _get_global_index3 = EclPrototype("int ecl_grid_get_global_index3(ecl_grid, int, int, int)") - _get_active_index1 = EclPrototype("int ecl_grid_get_active_index1(ecl_grid, int)") - _get_active_fracture_index1 = EclPrototype("int ecl_grid_get_active_fracture_index1(ecl_grid, int)") - _get_global_index1A = EclPrototype("int ecl_grid_get_global_index1A(ecl_grid, int)") - _get_global_index1F = EclPrototype("int ecl_grid_get_global_index1F(ecl_grid, int)") - _get_ijk1 = EclPrototype("void ecl_grid_get_ijk1(ecl_grid, int, int*, int*, int*)") - _get_ijk1A = EclPrototype("void ecl_grid_get_ijk1A(ecl_grid, int, int*, int*, int*)") - _get_xyz3 = EclPrototype("void ecl_grid_get_xyz3(ecl_grid, int, int, int, double*, double*, double*)") - _get_xyz1 = EclPrototype("void ecl_grid_get_xyz1(ecl_grid, int, double*, double*, double*)") - _get_cell_corner_xyz1 = EclPrototype("void ecl_grid_get_cell_corner_xyz1(ecl_grid, int, int, double*, double*, double*)") - _get_corner_xyz = EclPrototype("void ecl_grid_get_corner_xyz(ecl_grid, int, int, int, double*, double*, double*)") - _get_xyz1A = EclPrototype("void ecl_grid_get_xyz1A(ecl_grid, int, double*, double*, double*)") - _get_ij_xy = EclPrototype("bool ecl_grid_get_ij_from_xy(ecl_grid, double, double, int, int*, int*)") - _get_ijk_xyz = EclPrototype("int ecl_grid_get_global_index_from_xyz(ecl_grid, double, double, double, int)") - _cell_contains = EclPrototype("bool ecl_grid_cell_contains_xyz1(ecl_grid, int, double, double, double)") - _cell_regular = EclPrototype("bool ecl_grid_cell_regular1(ecl_grid, int)") - _num_lgr = EclPrototype("int ecl_grid_get_num_lgr(ecl_grid)") - _has_numbered_lgr = EclPrototype("bool ecl_grid_has_lgr_nr(ecl_grid, int)") - _has_named_lgr = EclPrototype("bool ecl_grid_has_lgr(ecl_grid, char*)") - _grid_value = EclPrototype("double ecl_grid_get_property(ecl_grid, ecl_kw, int, int, int)") - _get_cell_volume = EclPrototype("double ecl_grid_get_cell_volume1(ecl_grid, int)") - _get_cell_thickness = EclPrototype("double ecl_grid_get_cell_thickness1(ecl_grid, int)") - _get_cell_dx = EclPrototype("double ecl_grid_get_cell_dx1(ecl_grid, int)") - _get_cell_dy = EclPrototype("double ecl_grid_get_cell_dy1(ecl_grid, int)") - _get_depth = EclPrototype("double ecl_grid_get_cdepth1(ecl_grid, int)") - _fwrite_grdecl = EclPrototype("void ecl_grid_grdecl_fprintf_kw(ecl_grid, ecl_kw, char*, FILE, double)") - _load_column = EclPrototype("void ecl_grid_get_column_property(ecl_grid, ecl_kw, int, int, double_vector)") - _get_top = EclPrototype("double ecl_grid_get_top2(ecl_grid, int, int)") - _get_top1A = EclPrototype("double ecl_grid_get_top1A(ecl_grid, int)") - _get_bottom = EclPrototype("double ecl_grid_get_bottom2(ecl_grid, int, int)") - _locate_depth = EclPrototype("int ecl_grid_locate_depth(ecl_grid, double, int, int)") - _invalid_cell = EclPrototype("bool ecl_grid_cell_invalid1(ecl_grid, int)") - _valid_cell = EclPrototype("bool ecl_grid_cell_valid1(ecl_grid, int)") - _get_distance = EclPrototype("void ecl_grid_get_distance(ecl_grid, int, int, double*, double*, double*)") - _fprintf_grdecl2 = EclPrototype("void ecl_grid_fprintf_grdecl2(ecl_grid, FILE, ecl_unit_enum) ") - _fwrite_GRID2 = EclPrototype("void ecl_grid_fwrite_GRID2(ecl_grid, char*, ecl_unit_enum)") - _fwrite_EGRID2 = EclPrototype("void ecl_grid_fwrite_EGRID2(ecl_grid, char*, ecl_unit_enum)") - _equal = EclPrototype("bool ecl_grid_compare(ecl_grid, ecl_grid, bool, bool)") - _dual_grid = EclPrototype("bool ecl_grid_dual_grid(ecl_grid)") - _init_actnum = EclPrototype("void ecl_grid_init_actnum_data(ecl_grid, int*)") - _compressed_kw_copy = EclPrototype("void ecl_grid_compressed_kw_copy(ecl_grid, ecl_kw, ecl_kw)") - _global_kw_copy = EclPrototype("void ecl_grid_global_kw_copy(ecl_grid, ecl_kw, ecl_kw)") - _create_volume_keyword = EclPrototype("ecl_kw_obj ecl_grid_alloc_volume_kw(ecl_grid, bool)") - _use_mapaxes = EclPrototype("bool ecl_grid_use_mapaxes(ecl_grid)") - _export_coord = EclPrototype("ecl_kw_obj ecl_grid_alloc_coord_kw(ecl_grid)") - _export_zcorn = EclPrototype("ecl_kw_obj ecl_grid_alloc_zcorn_kw(ecl_grid)") - _export_actnum = EclPrototype("ecl_kw_obj ecl_grid_alloc_actnum_kw(ecl_grid)") - _export_mapaxes = EclPrototype("ecl_kw_obj ecl_grid_alloc_mapaxes_kw(ecl_grid)") - - - - @classmethod - def load_from_grdecl(cls, filename): - """Will create a new EclGrid instance from grdecl file. - - This function will scan the input file @filename and look for - the keywords required to build a grid. The following keywords - are required: - - SPECGRID ZCORN COORD - - In addition the function will look for and use the ACTNUM and - MAPAXES keywords if they are found; if ACTNUM is not found all - cells are assumed to be active. - - Slightly more exotic grid concepts like dual porosity, NNC - mapping, LGR and coarsened cells will be completely ignored; - if you need such concepts you must have an EGRID file and use - the default EclGrid() constructor - that is also considerably - faster. - """ - - if os.path.isfile(filename): - with open(filename) as f: - specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) - zcorn = EclKW.read_grdecl(f, "ZCORN") - coord = EclKW.read_grdecl(f, "COORD") - try: - actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclDataType.ECL_INT) - except ValueError: - actnum = None - - try: - mapaxes = EclKW.read_grdecl(f, "MAPAXES") - except ValueError: - mapaxes = None - - return EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes) - else: - raise IOError("No such file:%s" % filename) - - @classmethod - def load_from_file(cls, filename): - """ - Will inspect the @filename argument and create a new EclGrid instance. - """ - if FortIO.isFortranFile(filename): - return EclGrid(filename) - else: - return EclGrid.loadFromGrdecl(filename) - - - @classmethod - def create(cls, specgrid, zcorn, coord, actnum, mapaxes=None): - - """ - Create a new grid instance from existing keywords. - - This is a class method which can be used to create an EclGrid - instance based on the EclKW instances @specgrid, @zcorn, - @coord and @actnum. An ECLIPSE EGRID file contains the - SPECGRID, ZCORN, COORD and ACTNUM keywords, so a somewhat - involved way to create a EclGrid instance could be: - - file = ecl.EclFile("ECLIPSE.EGRID") - specgrid_kw = file.iget_named_kw("SPECGRID", 0) - zcorn_kw = file.iget_named_kw("ZCORN", 0) - coord_kw = file.iget_named_kw("COORD", 0) - actnum_kw = file.iget_named_kw("ACTNUM", 0) - - grid = EclGrid.create(specgrid_kw, zcorn_kw, coord_kw, actnum_kw) - - If you are so inclined ... - """ - return cls._grdecl_create(specgrid[0], specgrid[1], specgrid[2], zcorn, coord, actnum, mapaxes) - - @classmethod - def create_rectangular(cls, dims, dV, actnum=None): - """ - Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz) - - With the default value @actnum == None all cells will be active, - """ - - warnings.warn("EclGrid.createRectangular is deprecated. " + - "Please used the similar method in EclGridGenerator!", - DeprecationWarning) - - if actnum is None: - ecl_grid = cls._alloc_rectangular(dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], None) - else: - if not isinstance(actnum, IntVector): - tmp = IntVector(initial_size=len(actnum)) - for (index, value) in enumerate(actnum): - tmp[index] = value - actnum = tmp - - if not len(actnum) == dims[0] * dims[1] * dims[2]: - raise ValueError("ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" % (len(actnum), dims[0] * dims[1] * dims[2])) - ecl_grid = cls._alloc_rectangular(dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], actnum.getDataPtr()) - - # If we have not succeeded in creatin the grid we *assume* the - # error is due to a failed malloc. - if ecl_grid is None: - raise MemoryError("Failed to allocated regualar grid") - - return ecl_grid - - def __init__(self, filename, apply_mapaxes=True): - """ - Will create a grid structure from an EGRID or GRID file. - """ - c_ptr = self._fread_alloc(filename, apply_mapaxes) - if c_ptr: - super(EclGrid, self).__init__(c_ptr) - else: - raise IOError("Loading grid from:%s failed" % filename) - - - def free(self): - self._free() - - def _nicename(self): - """name is often full path to grid, if so, output basename, else name""" - name = self.getName() - if os.path.isfile(name): - name = os.path.basename(name) - return name - - def __repr__(self): - """Returns, e.g.: - EclGrid("NORNE_ATW2013.EGRID", 46x112x22, global_size=113344, active_size=44431) at 0x28c4a70 - """ - name = self._nicename() - if name: - name = '"%s", ' % name - g_size = self.getGlobalSize() - a_size = self.getNumActive() - xyz_s = '%dx%dx%d' % (self.getNX(),self.getNY(),self.getNZ()) - return self._create_repr('%s%s, global_size=%d, active_size=%d' % (name, xyz_s, g_size, a_size)) - - def __len__(self): - """ - len(grid) wil return the total number of cells. - """ - return self._get_global_size() - - def equal(self, other, include_lgr=True, include_nnc=False, verbose=False): - """ - Compare the current grid with the other grid. - """ - if not isinstance(other, EclGrid): - raise TypeError("The other argument must be an EclGrid instance") - return self._equal(other, include_lgr, include_nnc, verbose) - - - def dual_grid(self): - """Is this grid dual porosity model?""" - return self._dual_grid() - - def get_dims(self): - """A tuple of four elements: (nx, ny, nz, nactive).""" - return (self.getNX(), - self.getNY(), - self.getNZ(), - self.getNumActive()) - - - @property - def nx(self): - return self._get_nx() - - def get_nx(self): - """ The number of elements in the x direction""" - return self._get_nx() - - @property - def ny(self): - return self._get_ny() - - def get_ny(self): - """ The number of elements in the y direction""" - return self._get_ny() - - @property - def nz(self): - return self._get_nz() - - def get_nz(self): - """ The number of elements in the z direction""" - return self._get_nz() - - def get_global_size(self): - """Returns the total number of cells in this grid""" - return self._get_global_size() - - def get_num_active(self): - """The number of active cells in the grid.""" - return self._get_active() - - - def get_num_active_fracture(self): - """The number of active cells in the grid.""" - return self._get_active_fracture() - - - def get_bounding_box_2d(self, layer=0, lower_left=None, upper_right=None): - if 0 <= layer <= self.getNZ(): - x = ctypes.c_double() - y = ctypes.c_double() - z = ctypes.c_double() - - if lower_left is None: - i1 = 0 - j1 = 0 - else: - i1,j1 = lower_left - if not 0 < i1 < self.getNX(): - raise ValueError("lower_left i coordinate invalid") - - if not 0 < j1 < self.getNY(): - raise ValueError("lower_left j coordinate invalid") - - - if upper_right is None: - i2 = self.getNX() - j2 = self.getNY() - else: - i2,j2 = upper_right - - if not 1 < i2 <= self.getNX(): - raise ValueError("upper_right i coordinate invalid") - - if not 1 < j2 <= self.getNY(): - raise ValueError("upper_right j coordinate invalid") - - if not i1 < i2: - raise ValueError("Must have lower_left < upper_right") - - if not j1 < j2: - raise ValueError("Must have lower_left < upper_right") - - - - self._get_corner_xyz(i1, j1, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - p0 = (x.value, y.value) - - self._get_corner_xyz(i2, j1, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - p1 = (x.value, y.value ) - - self._get_corner_xyz( i2, j2, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - p2 = (x.value, y.value ) - - self._get_corner_xyz(i1, j2, layer, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - p3 = (x.value, y.value ) - - return (p0,p1,p2,p3) - else: - raise ValueError("Invalid layer value:%d Valid range: [0,%d]" % (layer, self.getNZ())) - - - def get_name(self): - """ - Name of the current grid, returns a string. - - For the main grid this is the filename given to the - constructor when loading the grid; for an LGR this is the name - of the LGR. If the grid instance has been created with the - create() classmethod this can be None. - """ - n = self._get_name() - return str(n) if n else '' - - def cell(self, global_index=None, active_index=None, i=None, j=None, k=None): - if global_index is not None: - return Cell(self, global_index) - if active_index is not None: - return Cell(self, self.global_index(active_index=active_index)) - if i is not None: - return Cell(self, self.global_index(ijk=(i,j,k))) - - def __getitem__(self, global_index): - if isinstance(global_index, tuple): - i,j,k = global_index - return self.cell(i=i, j=j, k=k) - return self.cell(global_index=global_index) - - def __iter__(self): - for i in range(len(self)): - yield self[i] - - def cells(self, active=False): - """Iterator over all the (active) cells""" - if not active: - for c in self: - yield c - else: - for i in range(self.get_num_active()): - yield self.cell(active_index=i) - - def global_index(self, active_index=None, ijk=None): - """ - Will convert either active_index or (i,j,k) to global index. - """ - return self.__global_index(active_index=active_index, ijk=ijk) - - def __global_index(self, active_index=None, global_index=None, ijk=None): - """ - Will convert @active_index or @ijk to global_index. - - This method will convert @active_index or @ijk to a global - index. Exactly one of the arguments @active_index, - @global_index or @ijk must be supplied. - - The method is used extensively internally in the EclGrid - class; most methods which take coordinate input pass through - this method to normalize the coordinate representation. - """ - - set_count = 0 - if not active_index is None: - set_count += 1 - - if not global_index is None: - set_count += 1 - - if ijk: - set_count += 1 - - if not set_count == 1: - raise ValueError("Exactly one of the kewyord arguments active_index, global_index or ijk must be set") - - if not active_index is None: - global_index = self._get_global_index1A( active_index) - elif ijk: - nx = self.getNX() - ny = self.getNY() - nz = self.getNZ() - - i,j,k = ijk - - if not 0 <= i < nx: - raise IndexError("Invalid value i:%d Range: [%d,%d)" % (i, 0, nx)) - - if not 0 <= j < ny: - raise IndexError("Invalid value j:%d Range: [%d,%d)" % (j, 0, ny)) - - if not 0 <= k < nz: - raise IndexError("Invalid value k:%d Range: [%d,%d)" % (k, 0, nz)) - - global_index = self._get_global_index3(i,j,k) - else: - if not 0 <= global_index < self.getGlobalSize(): - raise IndexError("Invalid value global_index:%d Range: [%d,%d)" % (global_index, 0, self.getGlobalSize())) - return global_index - - - def get_active_index(self, ijk=None, global_index=None): - """ - Lookup active index based on ijk or global index. - - Will determine the active_index of a cell, based on either - @ijk = (i,j,k) or @global_index. If the cell specified by the - input arguments is not active the function will return -1. - """ - gi = self.__global_index(global_index=global_index, ijk=ijk) - return self._get_active_index1(gi) - - - def get_active_fracture_index(self, ijk=None, global_index=None): - """ - For dual porosity - get the active fracture index. - """ - gi = self.__global_index(global_index=global_index, ijk=ijk) - return self._get_active_fracture_index1(gi) - - - def get_global_index1F(self, active_fracture_index): - """ - Will return the global index corresponding to active fracture index. - """ - return self._get_global_index1F(active_fracture_index) - - - def cell_invalid(self, ijk=None, global_index=None, active_index=None): - """ - Tries to check if a cell is invalid. - - Cells which are used to represent numerical aquifers are - typically located in UTM position (0,0); these cells have - completely whacked up shape and size, and should **NOT** be - used in calculations involving real world coordinates. To - protect against this a heuristic is used identify such cells - and mark them as invalid. There might be other sources than - numerical aquifers to this problem. - """ - gi = self.__global_index(global_index=global_index, ijk=ijk, active_index=active_index) - return self._invalid_cell(gi) - - - def valid_cell_geometry(self, ijk=None, global_index=None, active_index=None): - """Checks if the cell has valid geometry. - - There are at least two reasons why a cell might have invalid - gemetry: - - 1. In the case of GRID files it is not necessary to supply - the geometry for all the cells; in that case this - function will return false for cells which do not have - valid coordinates. - - 2. Cells which are used to represent numerical aquifers are - typically located in UTM position (0,0); these cells have - completely whacked up shape and size; these cells are - identified by a heuristic - which might fail - - If the validCellGeometry() returns false for a particular - cell functions which calculate cell volumes, real world - coordinates and so on - should not be used. - """ - gi = self.__global_index(global_index=global_index, ijk=ijk, active_index=active_index) - return self._valid_cell(gi) - - - - def active(self, ijk=None, global_index=None): - """ - Is the cell active? - - See documentation og get_xyz() for explanation of parameters - @ijk and @global_index. - """ - gi = self.__global_index(global_index=global_index, ijk=ijk) - active_index = self._get_active_index1(gi) - if active_index >= 0: - return True - else: - return False - - - def get_global_index(self, ijk=None, active_index=None): - """ - Lookup global index based on ijk or active index. - """ - gi = self.__global_index(active_index=active_index, ijk=ijk) - return gi - - - def get_ijk(self, active_index=None, global_index=None): - """ - Lookup (i,j,k) for a cell, based on either active index or global index. - - The return value is a tuple with three elements (i,j,k). - """ - i = ctypes.c_int() - j = ctypes.c_int() - k = ctypes.c_int() - - gi = self.__global_index(active_index=active_index, global_index=global_index) - self._get_ijk1(gi, ctypes.byref(i), ctypes.byref(j), ctypes.byref(k)) - - return (i.value, j.value, k.value) - - - def get_xyz(self, active_index=None, global_index=None, ijk=None): - """ - Find true position of cell center. - - Will return world position of the center of a cell in the - grid. The return value is a tuple of three elements: - (utm_x, utm_y, depth). - - The cells of a grid can be specified in three different ways: - - (i,j,k) : As a tuple of i,j,k values. - - global_index : A number in the range [0,nx*ny*nz). The - global index is related to (i,j,k) as: - - global_index = i + j*nx + k*nx*ny - - active_index : A number in the range [0,nactive). - - For many of the EclGrid methods a cell can be specified using - any of these three methods. Observe that one and only method is - allowed: - - OK: - pos1 = grid.get_xyz(active_index=100) - pos2 = grid.get_xyz(ijk=(10,20,7)) - - Crash and burn: - pos3 = grid.get_xyz(ijk=(10,20,7), global_index=10) - pos4 = grid.get_xyz() - - All the indices in the EclGrid() class are zero offset, this - is in contrast to ECLIPSE which has an offset 1 interface. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - - x = ctypes.c_double() - y = ctypes.c_double() - z = ctypes.c_double() - self._get_xyz1(gi, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - return (x.value, y.value, z.value) - - - def get_node_pos(self, i, j, k): - """Will return the (x,y,z) for the node given by (i,j,k). - - Observe that this method does not consider cells, but the - nodes in the grid. This means that the valid input range for - i,j and k are are upper end inclusive. To get the four - bounding points of the lower layer of the grid: - - p0 = grid.getNodePos(0, 0, 0) - p1 = grid.getNodePos(grid.getNX(), 0, 0) - p2 = grid.getNodePos(0, grid.getNY(), 0) - p3 = grid.getNodePos(grid.getNX(), grid.getNY(), 0) - - """ - if not 0 <= i <= self.getNX(): - raise IndexError("Invalid I value:%d - valid range: [0,%d]" % (i, self.getNX())) - - if not 0 <= j <= self.getNY(): - raise IndexError("Invalid J value:%d - valid range: [0,%d]" % (j, self.getNY())) - - if not 0 <= k <= self.getNZ(): - raise IndexError("Invalid K value:%d - valid range: [0,%d]" % (k, self.getNZ())) - - x = ctypes.c_double() - y = ctypes.c_double() - z = ctypes.c_double() - self._get_corner_xyz(i,j,k, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - return (x.value, y.value, z.value) - - - def get_cell_corner(self, corner_nr, active_index=None, global_index=None, ijk=None): - """ - Will look up xyz of corner nr @corner_nr - - - lower layer: upper layer - - 2---3 6---7 - | | | | - 0---1 4---5 - - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - x = ctypes.c_double() - y = ctypes.c_double() - z = ctypes.c_double() - self._get_cell_corner_xyz1(gi, corner_nr, ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - return (x.value, y.value, z.value) - - def get_node_xyz(self, i,j,k): - """ - This function returns the position of Vertex (i,j,k). - - The coordinates are in the inclusive interval [0,nx] x [0,ny] x [0,nz]. - """ - nx = self.getNX() - ny = self.getNY() - nz = self.getNZ() - - corner = 0 - - if i == nx: - i -= 1 - corner += 1 - - if j == ny: - j -= 1 - corner += 2 - - if k == nz: - k -= 1 - corner += 4 - - if self._ijk_valid(i, j, k): - return self.getCellCorner(corner, global_index=i + j*nx + k*nx*ny) - else: - raise IndexError("Invalid coordinates: (%d,%d,%d) " % (i,j,k)) - - - - def get_layer_xyz(self, xy_corner, layer): - nx = self.getNX() - - (j, i) = divmod(xy_corner, nx + 1) - k = layer - return self.getNodeXYZ(i,j,k) - - - - def distance(self, global_index1, global_index2): - dx = ctypes.c_double() - dy = ctypes.c_double() - dz = ctypes.c_double() - self._get_distance(global_index1, global_index2, ctypes.byref(dx), ctypes.byref(dy), ctypes.byref(dz)) - return (dx.value, dy.value, dz.value) - - - def depth(self, active_index=None, global_index=None, ijk=None): - """ - Depth of the center of a cell. - - Returns the depth of the center of the cell given by - @active_index, @global_index or @ijk. See method get_xyz() for - documentation of @active_index, @global_index and @ijk. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - return self._get_depth( gi) - - def top(self, i, j): - """ - Top of the reservoir; in the column (@i, @j). - Returns average depth of the four top corners. - """ - return self._get_top(i, j) - - def top_active(self, i, j): - """ - Top of the active part of the reservoir; in the column (@i, @j). - Raises ValueError if (i,j) column is inactive. - """ - for k in range(self.getNZ()): - a_idx = self.get_active_index(ijk=(i,j,k)) - if a_idx >= 0: - return self._get_top1A(a_idx) - raise ValueError('No active cell in column (%d,%d)' % (i,j)) - - def bottom(self, i, j): - """ - Bottom of the reservoir; in the column (@i, @j). - """ - return self._get_bottom( i, j) - - def locate_depth(self, depth, i, j): - """ - Will locate the k value of cell containing specified depth. - - Will scan through the grid column specified by the input - arguments @i and @j and search for a cell containing the depth - given by input argument @depth. The return value is the k - value of cell containing @depth. - - If @depth is above the top of the reservoir the function will - return -1, and if @depth is below the bottom of the reservoir - the function will return -nz. - """ - return self._locate_depth( depth, i, j) - - - def find_cell(self, x, y, z, start_ijk=None): - """ - Lookup cell containg true position (x,y,z). - - Will locate the cell in the grid which contains the true - position (@x,@y,@z), the return value is as a triplet - (i,j,k). The underlying C implementation is not veeery - efficient, and can potentially take quite long time. If you - provide a good intial guess with the parameter @start_ijk (a - tuple (i,j,k)) things can speed up quite substantially. - - If the location (@x,@y,@z) can not be found in the grid, the - method will return None. - """ - start_index = 0 - if start_ijk: - start_index = self.__global_index(ijk=start_ijk) - - global_index = self._get_ijk_xyz(x, y, z, start_index) - if global_index >= 0: - i = ctypes.c_int() - j = ctypes.c_int() - k = ctypes.c_int() - self._get_ijk1(global_index, - ctypes.byref(i), ctypes.byref(j), ctypes.byref(k)) - return (i.value, j.value, k.value) - return None - - def cell_contains(self, x, y, z, active_index=None, global_index=None, ijk=None): - """ - Will check if the cell contains point given by world - coordinates (x,y,z). - - See method get_xyz() for documentation of @active_index, - @global_index and @ijk. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - return self._cell_contains(gi, x,y,z) - - - def find_cell_xy(self, x, y, k): - """Will find the i,j of cell with utm coordinates x,y. - - The @k input is the layer you are interested in, the allowed - values for k are [0,nz]. If the coordinates (x,y) are found to - be outside the grid a ValueError exception is raised. - """ - if 0 <= k <= self.getNZ(): - i = ctypes.c_int() - j = ctypes.c_int() - ok = self._get_ij_xy(x,y,k, ctypes.byref(i), ctypes.byref(j)) - if ok: - return (i.value, j.value) - else: - raise ValueError("Could not find the point:(%g,%g) in layer:%d" % (x,y,k)) - else: - raise IndexError("Invalid layer value:%d" % k) - - - @staticmethod - def d_cmp(a,b): - return cmp(a[0], b[0]) - - - def find_cell_corner_xy(self, x, y, k): - """Will find the corner nr of corner closest to utm coordinates x,y. - - The @k input is the layer you are interested in, the allowed - values for k are [0,nz]. If the coordinates (x,y) are found to - be outside the grid a ValueError exception is raised. - """ - i,j = self.findCellXY(x,y,k) - if k == self.getNZ(): - k -= 1 - corner_shift = 4 - else: - corner_shift = 0 - - nx = self.getNX() - x0,y0,z0 = self.getCellCorner(corner_shift, ijk=(i,j,k)) - d0 = math.sqrt((x0 - x)*(x0 - x) + (y0 - y)*(y0 - y)) - c0 = i + j*(nx + 1) - - x1,y1,z1 = self.getCellCorner(1 + corner_shift, ijk=(i,j,k)) - d1 = math.sqrt((x1 - x)*(x1 - x) + (y1 - y)*(y1 - y)) - c1 = i + 1 + j*(nx + 1) - - x2,y2,z2 = self.getCellCorner(2 + corner_shift, ijk=(i,j,k)) - d2 = math.sqrt((x2 - x)*(x2 - x) + (y2 - y)*(y2 - y)) - c2 = i + (j + 1)*(nx + 1) - - x3,y3,z3 = self.getCellCorner(3 + corner_shift, ijk=(i,j,k)) - d3 = math.sqrt((x3 - x)*(x3 - x) + (y3 - y)*(y3 - y)) - c3 = i + 1 + (j + 1)*(nx + 1) - - l = [(d0, c0), (d1,c1), (d2, c2), (d3,c3)] - l.sort(EclGrid.d_cmp) - return l[0][1] - - - - def cell_regular(self, active_index=None, global_index=None, ijk=None): - """ - The ECLIPSE grid models often contain various degenerate cells, - which are twisted, have overlapping corners or what not. This - function gives a moderate sanity check on a cell, essentially - what the function does is to check if the cell contains it's - own centerpoint - which is actually not as trivial as it - sounds. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - return self._cell_regular( gi) - - - def cell_volume(self, active_index=None, global_index=None, ijk=None): - """ - Calculate the volume of a cell. - - Will calculate the total volume of the cell. See method - get_xyz() for documentation of @active_index, @global_index - and @ijk. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - return self._get_cell_volume(gi) - - - def cell_dz(self, active_index=None, global_index=None, ijk=None): - """ - The thickness of a cell. - - Will calculate the (average) thickness of the cell. See method - get_xyz() for documentation of @active_index, @global_index - and @ijk. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - return self._get_cell_thickness( gi) - - - def get_cell_dims(self, active_index=None, global_index=None, ijk=None): - """Will return a tuple (dx,dy,dz) for cell dimension. - - The dx and dy values are best effor estimates of the cell size - along the i and j directions respectively. The three values - are guaranteed to satisfy: - - dx * dy * dz = dV - - See method get_xyz() for documentation of @active_index, - @global_index and @ijk. - - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - dx = self._get_cell_dx(gi) - dy = self._get_cell_dy(gi) - dz = self._get_cell_thickness( gi) - return (dx,dy,dz) - - - - def get_num_lgr(self): - - """ - How many LGRs are attached to this main grid? - - How many LGRs are attached to this main grid; the grid - instance doing the query must itself be a main grid. - """ - return self._num_lgr() - - - - def has_lgr(self, lgr_name): - """ - Query if the grid has an LGR with name @lgr_name. - """ - if self._has_named_lgr(lgr_name): - return True - else: - return False - - - def get_lgr(self, lgr_key): - """Get EclGrid instance with LGR content. - - Return an EclGrid instance based on the LGR @lgr, the input - argument can either be the name of an LGR or the grid number - of the LGR. The LGR grid instance is mostly like an ordinary - grid instance; the only difference is that it can not be used - for further queries about LGRs. - - If the grid does not contain an LGR with this name/nr - exception KeyError will be raised. - - """ - lgr = None - if isinstance(lgr_key, int): - if self._has_numbered_lgr(lgr_key): - lgr = self._get_numbered_lgr(lgr_key) - else: - if self._has_named_lgr(lgr_key): - lgr = self._get_named_lgr(lgr_key) - - if lgr is None: - raise KeyError("No such LGR: %s" % lgr_key) - - lgr.setParent(self) - return lgr - - - - def get_cell_lgr(self, active_index=None, global_index=None, ijk=None): - """ - Get EclGrid instance located in cell. - - Will query the current grid instance if the cell given by - @active_index, @global_index or @ijk has been refined with an - LGR. Will return None if the cell in question has not been - refined, the return value can be used for further queries. - - See get_xyz() for documentation of the input parameters. - """ - gi = self.__global_index(ijk=ijk, active_index=active_index, global_index=global_index) - lgr = self._get_cell_lgr(gi) - if lgr: - lgr.setParent(self) - return lgr - else: - raise IndexError("No LGR defined for this cell") - - - def grid_value(self, kw, i, j, k): - """ - Will evalute @kw in location (@i,@j,@k). - - The ECLIPSE properties and solution vectors are stored in - restart and init files as 1D vectors of length nx*nx*nz or - nactive. The grid_value() method is a minor convenience - function to convert the (@i,@j,@k) input values to an - appropriate 1D index. - - Depending on the length of kw the input arguments are - converted either to an active index or to a global index. If - the length of kw does not fit with either the global size of - the grid or the active size of the grid things will fail hard. - """ - return self._grid_value(kw, i, j, k) - - - def load_column(self, kw, i, j, column): - """ - Load the values of @kw from the column specified by (@i,@j). - - The method will scan through all k values of the input field - @kw for fixed values of i and j. The size of @kw must be - either nactive or nx*ny*nz. - - The input argument @column should be a DoubleVector instance, - observe that if size of @kw == nactive k values corresponding - to inactive cells will not be modified in the @column - instance; in that case it is important that @column is - initialized with a suitable default value. - """ - self._load_column( kw, i, j, column) - - - def create_kw(self, array, kw_name, pack): - """ - Creates an EclKW instance based on existing 3D numpy object. - - The method create3D() does the inverse operation; creating a - 3D numpy object from an EclKW instance. If the argument @pack - is true the resulting keyword will have length 'nactive', - otherwise the element will have length nx*ny*nz. - """ - if array.ndim == 3: - dims = array.shape - if dims[0] == self.getNX() and dims[1] == self.getNY() and dims[2] == self.getNZ(): - dtype = array.dtype - if dtype == numpy.int32: - type = EclDataType.ECL_INT - elif dtype == numpy.float32: - type = EclDataType.ECL_FLOAT - elif dtype == numpy.float64: - type = EclDataType.ECL_DOUBLE - else: - sys.exit("Do not know how to create ecl_kw from type:%s" % dtype) - - if pack: - size = self.getNumActive() - else: - size = self.getGlobalSize() - - if len(kw_name) > 8: - # Silently truncate to length 8 - ECLIPSE has it's challenges. - kw_name = kw_name[0:8] - - kw = EclKW(kw_name, size, type) - active_index = 0 - global_index = 0 - for k in range(self.getNZ()): - for j in range(self.getNY()): - for i in range(self.getNX()): - if pack: - if self.active(global_index=global_index): - kw[active_index] = array[i,j,k] - active_index += 1 - else: - if dtype == numpy.int32: - kw[global_index] = int(array[i,j,k]) - else: - kw[global_index] = array[i,j,k] - - global_index += 1 - return kw - raise ValueError("Wrong size / dimension on array") - - - def coarse_groups(self): - """ - Will return the number of coarse groups in this grid. - """ - return self._num_coarse_groups() - - - def in_coarse_group(self, global_index=None, ijk=None, active_index=None): - """ - Will return True or False if the cell is part of coarse group. - """ - global_index = self.__global_index(active_index=active_index, ijk=ijk, global_index=global_index) - return self._in_coarse_group1(global_index) - - - def create_3d(self, ecl_kw, default = 0): - """ - Creates a 3D numpy array object with the data from @ecl_kw. - - Observe that 3D numpy object is a copy of the data in the - EclKW instance, i.e. modification to the numpy object will not - be reflected in the ECLIPSE keyword. - - The methods createKW() does the inverse operation; creating an - EclKW instance from a 3D numpy object. - - Alternative: Creating the numpy array object is not very - efficient; if you only need a limited number of elements from - the ecl_kw instance it might be wiser to use the grid_value() - method: - - value = grid.grid_value(ecl_kw, i, j, k) - - """ - if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): - array = numpy.ones([ self.getGlobalSize() ], dtype=ecl_kw.dtype) * default - kwa = ecl_kw.array - if len(ecl_kw) == self.getGlobalSize(): - for i in range(kwa.size): - array[i] = kwa[i] - else: - data_index = 0 - for global_index in range(self.getGlobalSize()): - if self.active(global_index=global_index): - array[global_index] = kwa[data_index] - data_index += 1 - - array = array.reshape([self.getNX(), self.getNY(), self.getNZ()], order='F') - return array - else: - err_msg_fmt = 'Keyword "%s" has invalid size %d; must be either nactive=%d or nx*ny*nz=%d' - err_msg = err_msg_fmt % (ecl_kw, len(ecl_kw), self.getNumActive(), - self.getGlobalSize()) - raise ValueError(err_msg) - - def save_grdecl(self, pyfile, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): - """ - Will write the the grid content as grdecl formatted keywords. - - Will only write the main grid. - """ - cfile = CFILE(pyfile) - self._fprintf_grdecl2(cfile, output_unit) - - def save_EGRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): - """ - Will save the current grid as a EGRID file. - """ - self._fwrite_EGRID2(filename, output_unit) - - def save_GRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): - """ - Will save the current grid as a EGRID file. - """ - self._fwrite_GRID2( filename, output_unit) - - - def write_grdecl(self, ecl_kw, pyfile, special_header=None, default_value=0): - """ - Writes an EclKW instance as an ECLIPSE grdecl formatted file. - - The input argument @ecl_kw must be an EclKW instance of size - nactive or nx*ny*nz. If the size is nactive the inactive cells - will be filled with @default_value; hence the function will - always write nx*ny*nz elements. - - The data in the @ecl_kw argument can be of type integer, - float, double or bool. In the case of bool the default value - must be specified as 1 (True) or 0 (False). - - The input argument @pyfile should be a valid python filehandle - opened for writing; i.e. - - pyfile = open("PORO.GRDECL", "w") - grid.write_grdecl(poro_kw , pyfile, default_value=0.0) - grid.write_grdecl(permx_kw, pyfile, default_value=0.0) - pyfile.close() - - """ - - if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): - cfile = CFILE(pyfile) - self._fwrite_grdecl(ecl_kw, special_header, cfile, default_value) - else: - raise ValueError("Keyword: %s has invalid size(%d), must be either nactive:%d or nx*ny*nz:%d" % (ecl_kw.getName(), len(ecl_kw), self.getNumActive(), self.getGlobalSize())) - - - def exportACTNUM(self): - actnum = IntVector(initial_size=self.getGlobalSize()) - self._init_actnum(actnum.getDataPtr()) - return actnum - - - def compressed_kw_copy(self, kw): - if len(kw) == self.getNumActive(): - return kw.copy() - elif len(kw) == self.getGlobalSize(): - kw_copy = EclKW(kw.getName(), self.getNumActive(), kw.data_type) - self._compressed_kw_copy(kw_copy, kw) - return kw_copy - else: - raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) - - def global_kw_copy(self, kw, default_value): - if len(kw) == self.getGlobalSize(): - return kw.copy() - elif len(kw) == self.getNumActive(): - kw_copy = EclKW(kw.getName(), self.getGlobalSize(), kw.data_type) - kw_copy.assign(default_value) - self._global_kw_copy(kw_copy, kw) - return kw_copy - else: - raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) - - - def export_ACTNUM_kw(self): - actnum = EclKW("ACTNUM", self.getGlobalSize(), EclDataType.ECL_INT) - self._init_actnum(actnum.getDataPtr()) - return actnum - - - def create_volume_keyword(self, active_size=True): - """Will create a EclKW initialized with cell volumes. - - The purpose of this method is to create a EclKW instance which - is initialized with all the cell volumes, this can then be - used to perform volume summation; i.e. to calculate the total - oil volume: - - soil = 1 - sgas - swat - cell_volume = grid.createVolumeKeyword() - tmp = cell_volume * soil - oip = tmp.sum() - - The oil in place calculation shown above could easily be - implemented by iterating over the soil kw, however using the - volume keyword has two advantages: - - 1. The calculation of cell volumes is quite time consuming, - by storing the results in a kw they can be reused. - - 2. By using the compact form 'oip = cell_volume * soil' the - inner loop iteration will go in C - which is faster. - - By default the kw will only have values for the active cells, - but by setting the optional variable @active_size to False you - will get volume values for all cells in the grid. - """ - - return self._create_volume_keyword(active_size) - - def export_coord(self): - return self._export_coord() - - def export_zcorn(self): - return self._export_zcorn() - - def export_actnum(self): - return self._export_actnum() - - def export_mapaxes(self): - if not self._use_mapaxes(): - return None - - return self._export_mapaxes() - -monkey_the_camel(EclGrid, 'loadFromGrdecl', EclGrid.load_from_grdecl, classmethod) -monkey_the_camel(EclGrid, 'loadFromFile', EclGrid.load_from_file, classmethod) -monkey_the_camel(EclGrid, 'createRectangular', EclGrid.create_rectangular, classmethod) -monkey_the_camel(EclGrid, 'dualGrid', EclGrid.dual_grid) -monkey_the_camel(EclGrid, 'getDims', EclGrid.get_dims) -monkey_the_camel(EclGrid, 'getNX', EclGrid.get_nx) -monkey_the_camel(EclGrid, 'getNY', EclGrid.get_ny) -monkey_the_camel(EclGrid, 'getNZ', EclGrid.get_nz) -monkey_the_camel(EclGrid, 'getGlobalSize', EclGrid.get_global_size) -monkey_the_camel(EclGrid, 'getNumActive', EclGrid.get_num_active) -monkey_the_camel(EclGrid, 'getNumActiveFracture', EclGrid.get_num_active_fracture) -monkey_the_camel(EclGrid, 'getBoundingBox2D', EclGrid.get_bounding_box_2d) -monkey_the_camel(EclGrid, 'getName', EclGrid.get_name) -monkey_the_camel(EclGrid, 'validCellGeometry', EclGrid.valid_cell_geometry) -monkey_the_camel(EclGrid, 'getNodePos', EclGrid.get_node_pos) -monkey_the_camel(EclGrid, 'getCellCorner', EclGrid.get_cell_corner) -monkey_the_camel(EclGrid, 'getNodeXYZ', EclGrid.get_node_xyz) -monkey_the_camel(EclGrid, 'getLayerXYZ', EclGrid.get_layer_xyz) -monkey_the_camel(EclGrid, 'findCellXY', EclGrid.find_cell_xy) -monkey_the_camel(EclGrid, 'findCellCornerXY', EclGrid.find_cell_corner_xy) -monkey_the_camel(EclGrid, 'getCellDims', EclGrid.get_cell_dims) -monkey_the_camel(EclGrid, 'getNumLGR', EclGrid.get_num_lgr) -monkey_the_camel(EclGrid, 'createKW', EclGrid.create_kw) -monkey_the_camel(EclGrid, 'create3D', EclGrid.create_3d) -monkey_the_camel(EclGrid, 'compressedKWCopy', EclGrid.compressed_kw_copy) -monkey_the_camel(EclGrid, 'globalKWCopy', EclGrid.global_kw_copy) -monkey_the_camel(EclGrid, 'exportACTNUMKw', EclGrid.export_ACTNUM_kw) -monkey_the_camel(EclGrid, 'createVolumeKeyword', EclGrid.create_volume_keyword) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py deleted file mode 100644 index 6837439f39..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py +++ /dev/null @@ -1,708 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'ecl_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import itertools, numpy -from math import sqrt - -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclGrid, EclKW, EclDataType, EclPrototype - -def flatten(l): - return [elem for sublist in l for elem in sublist] - -def divide(l, size): - return [l[i:i+size:] for i in range(0, len(l), size)] - -def duplicate_inner(l): - return [elem for elem in l for i in range(2)][1:-1:] - -def construct_floatKW(name, values): - kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) - for i, value in enumerate(values): - kw[i] = value - return kw - -def pre_mapaxes_translation(translation, mapaxes): - if mapaxes is None: - return translation - - x, y, z = translation - - unit_y = numpy.array((mapaxes[0]-mapaxes[2], mapaxes[1]-mapaxes[3])); - unit_y /= sqrt(numpy.sum(unit_y*unit_y)) - - unit_x = numpy.array((mapaxes[4]-mapaxes[2], mapaxes[5]-mapaxes[3])); - unit_x /= sqrt(numpy.sum(unit_x*unit_x)) - - det = 1.0 / (unit_x[0]*unit_y[1] - unit_x[1] * unit_y[0]); - - return ( - ( x*unit_y[1] - y*unit_y[0]) * det, - (-x*unit_x[1] + y*unit_x[0]) * det, - z - ) - -class EclGridGenerator: - - _alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind=False) - - @classmethod - def create_rectangular(cls, dims, dV, actnum=None): - """ - Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz) - - With the default value @actnum == None all cells will be active, - """ - if actnum is None: - ecl_grid = cls._alloc_rectangular( - dims[0], dims[1], dims[2], - dV[0], dV[1], dV[2], - None - ) - else: - if not isinstance(actnum, IntVector): - tmp = IntVector(initial_size=len(actnum)) - for (index, value) in enumerate(actnum): - tmp[index] = value - actnum = tmp - - if not len(actnum) == dims[0]*dims[1]*dims[2]: - raise ValueError( - "ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" - % (len(actnum), dims[0]*dims[1]*dims[2]) - ) - - ecl_grid = cls._alloc_rectangular( - dims[0], dims[1], dims[2], - dV[0], dV[1], dV[2], - actnum.getDataPtr() - ) - - # If we have not succeeded in creatin the grid we *assume* the - # error is due to a failed malloc. - if ecl_grid is None: - raise MemoryError("Failed to allocated regualar grid") - - return ecl_grid - - @classmethod - def create_single_cell_grid(cls, corners): - """ - Provided with the corners of the grid in a similar manner as the eight - corners are output for a single cell, this method will create a grid - consisting of a single cell with the specified corners as its corners. - """ - - zcorn = [corners[i][2] for i in range(8)] - - coord = [(corners[i], corners[i+4]) for i in range(4)] - coord = flatten(flatten(coord)) - - def construct_floatKW(name, values): - kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) - for i in range(len(values)): - kw[i] = values[i] - return kw - - grid = EclGrid.create( - (1, 1, 1), - construct_floatKW("ZCORN", zcorn), - construct_floatKW("COORD", coord), - None - ) - - if not corners == [grid.getCellCorner(i, 0) for i in range(8)]: - raise AssertionError("Failed to generate single cell grid. " + - "Did not end up the expected corners.") - - return grid - - @classmethod - def create_zcorn(cls, dims, dV, offset=1, escape_origo_shift=(1,1,0), - irregular_offset=False, irregular=False, concave=False, - faults=False): - - cls.__assert_zcorn_parameters(dims, dV, offset, escape_origo_shift, - irregular_offset, irregular, concave, faults) - - nx, ny, nz = dims - dx, dy, dz = dV - - # Compute zcorn - z = escape_origo_shift[2] - zcorn = [z]*(4*nx*ny) - for k in range(nz-1): - z = z+dz - local_offset = offset + (dz/2. if irregular_offset and k%2 == 0 else 0) - - layer = [] - for i in range(ny+1): - shift = ((i if concave else 0) + (k/2 if irregular else 0)) % 2 - path = [z if i%2 == shift else z+local_offset for i in range(nx+1)] - layer.append(duplicate_inner(path)) - - zcorn = zcorn + (2*flatten(duplicate_inner(layer))) - - z = z+dz - zcorn = zcorn + ([z]*(4*nx*ny)) - - if faults: - # Ensure that drop does not align with grid structure - drop = (offset+dz)/2. if abs(offset-dz/2.) > 0.2 else offset + 0.4 - zcorn = cls.__create_faults(nx, ny, nz, zcorn, drop) - - - if z != escape_origo_shift[2] + nz*dz: - raise ValueError("%f != %f" % (z, escape_origo_shift[2] + nz*dz)) - - cls.assert_zcorn(nx, ny, nz, zcorn) - return construct_floatKW("ZCORN", zcorn) - - @classmethod - def create_coord(cls, dims, dV, escape_origo_shift=(1,1,0), - scale=1, translation=(0,0,0), rotate=False, misalign=False): - - nx, ny, nz = dims - dx, dy, dz = dV - - # Compute coord - z = escape_origo_shift[2] + nz*dz - coord = [] - for j, i in itertools.product(range(ny+1), range(nx+1)): - x, y = i*dx+escape_origo_shift[0], j*dy+escape_origo_shift[1] - coord = coord + [x, y, escape_origo_shift[2], x, y, z] - - # Apply transformations - lower_center = ( - nx*dx/2. + escape_origo_shift[0], - ny*dy/2. + escape_origo_shift[1] - ) - - if misalign: - coord = cls.__misalign_coord(coord, dims, dV) - - coord = cls.__scale_coord(coord, scale, lower_center) - - if rotate: - coord = cls.__rotate_coord(coord, lower_center) - - coord = cls.__translate_lower_coord(coord, translation) - - cls.assert_coord(nx, ny, nz, coord) - return construct_floatKW("COORD", coord) - - @classmethod - def __assert_zcorn_parameters(cls, dims, dV, offset, escape_origo_shift, - irregular_offset, irregular, concave, faults): - - nx, ny, nz = dims - dx, dy, dz = dV - - # Validate arguments - if min(dims + dV) <= 0: - raise ValueError("Expected positive grid and cell dimentions") - - if offset < 0: - raise ValueError("Expected non-negative offset") - - if irregular and offset + (dz/2. if irregular_offset else 0) > dz: - raise AssertionError("Arguments can result in self-" + - "intersecting cells. Increase dz, deactivate eiter " + - "irregular or irregular_offset, or decrease offset to avoid " + - "any problems") - - @classmethod - def create_grid(cls, dims, dV, offset=1, - escape_origo_shift=(1,1,0), - irregular_offset=False, irregular=False, concave=False, - faults=False, scale=1, translation=(0,0,0), rotate=False, - misalign=False): - """ - Will create a new grid where each cell is a parallelogram (skewed by z-value). - The number of cells are given by @dims = (nx, ny, nz) and the dimention - of each cell by @dV = (dx, dy, dz). - - All cells are guaranteed to not be self-intersecting. Hence, no twisted - cells and somewhat meaningfull cells. - - @offset gives how much the layers should fluctuate or "wave" as you - move along the X-axis. - - @irregular_offset decides whether the offset should be constant or - increase by dz/2 every now and then. - - @irregular if true some of the layers will be inclining and others - declining at the start. - - @concave decides whether the cells are to be convex or not. In - particular, if set to False, all cells of the grid will be concave. - - @escape_origo_shift is used to prevent any cell of having corners in (0,0,z) - as there is a heuristic in ecl_grid.c that marks such cells as tainted. - - @faults decides if there are to be faults in the grid. - - @scale A positive number that scales the "lower" endpoint of all - coord's. In particular, @scale != 1 creates trapeziod cells in both the XZ - and YZ-plane. - - @translation the lower part of the grid is translated ("slided") by the specified - additive factor. - - @rotate the lower part of the grid is rotated 90 degrees around its - center. - - @misalign will toggle COORD's slightly in various directions to break - alignment - - Note that cells in the lowermost layer can have multiple corners - at the same point. - - For testing it should give good coverage of the various scenarios this - method can produce, by leting @dims be (10,10,10), @dV=(2,2,2), @offset=1, - and try all 4 different configurations of @concave and - @irregular_offset. - """ - - zcorn = cls.create_zcorn(dims, dV, offset, escape_origo_shift, - irregular_offset, irregular, concave, faults) - - coord = cls.create_coord(dims, dV, escape_origo_shift, scale, - translation, rotate, misalign) - - return EclGrid.create(dims, zcorn, coord, None) - - @classmethod - def __create_faults(cls, nx, ny, nz, zcorn, drop): - """ - Will create several faults consisting of all cells such that either its - i or j index is 1 modulo 3. - """ - - plane_size = 4*nx*ny - for x, y, z in itertools.product(range(nx), range(ny), range(nz)): - if x%3 != 1 and y%3 != 1: - continue - - corner = [0]*8 - corner[0] = 2*z*plane_size + 4*y*nx + 2*x - corner[1] = corner[0] + 1 - corner[2] = corner[0] + 2*nx - corner[3] = corner[2] + 1 - - for i in range(4, 8): - corner[i] = corner[i-4] + plane_size - - for c in corner: - zcorn[c] = zcorn[c] + drop - - return zcorn - - @classmethod - def assert_zcorn(cls, nx, ny, nz, zcorn, twisted_check=True): - """ - - Raises an AssertionError if the zcorn is not as expected. In - patricular, it is verified that: - - - zcorn has the approperiate length (8*nx*ny*nz) and - - that no cell is twisted. - - """ - - if len(zcorn) != 8*nx*ny*nz: - raise AssertionError( - "Expected len(zcorn) to be %d, was %d" % - (8*nx*ny*nz, len(zcorn)) - ) - - plane_size = 4*nx*ny - for p in range(8*nx*ny*nz - plane_size): - if zcorn[p] > zcorn[p + plane_size] and twisted_check: - raise AssertionError( - "Twisted cell was created. " + - "Decrease offset or increase dz to avoid this!" - ) - - @classmethod - def __scale_coord(cls, coord, scale, lower_center): - coord = numpy.array([ - map(float, coord[i:i+6:]) - for i in range(0, len(coord), 6) - ]) - origo = numpy.array(3*[0.] + list(lower_center) + [0]) - scale = numpy.array(3*[1.] + 2*[scale] + [1]) - - coord = scale * (coord-origo) + origo - return coord.flatten().tolist() - - @classmethod - def __misalign_coord(cls, coord, dims, dV): - nx, ny, nz = dims - - coord = numpy.array([ - map(float, coord[i:i+6:]) - for i in range(0, len(coord), 6) - ]) - - tf = lambda i, j: 1./2 if abs(i)+abs(j) <= 1 else 0.25 - adjustment = numpy.array([ - (0, 0, 0, i*tf(i,j)*dV[0], j*tf(i,j)*dV[1], 0) for i, j in itertools.product([-1, 0, 1], repeat=2) - ]) - - for i, c in enumerate(coord): - # Leave the outermost coords alone - if i < nx+1 or i >= len(coord)-(nx+1): - continue - if i%(nx+1) in [0, nx]: - continue - - c += adjustment[i%len(adjustment)] - - return coord.flatten().tolist() - - @classmethod - def __rotate_coord(cls, coord, lower_center): - coord = numpy.array([ - map(float, coord[i:i+6:]) - for i in range(0, len(coord), 6) - ]) - - origo = numpy.array(3*[0.] + list(lower_center) + [0]) - coord -= origo - - for c in coord: - c[3], c[4] = -c[4], c[3] - - coord += origo - return coord.flatten().tolist() - - @classmethod - def __translate_lower_coord(cls, coord, translation): - coord = numpy.array([ - map(float, coord[i:i+6:]) - for i in range(0, len(coord), 6) - ]) - translation = numpy.array(3*[0.] + list(translation)) - - coord = coord + translation - return coord.flatten().tolist() - - @classmethod - def assert_coord(cls, nx, ny, nz, coord, negative_values=False): - """ - - Raises an AssertionError if the coord is not as expected. In - particular, it is verified that: - - - coord has the approperiate length (6*(nx+1)*(ny+1)) and - - that all values are positive unless negative_values are - explicitly allowed. - - """ - - if len(coord) != 6*(nx+1)*(ny+1): - raise AssertionError( - "Expected len(coord) to be %d, was %d" % - (6*(nx+1)*(ny+1), len(coord)) - ) - - if not negative_values and min(coord) < 0: - raise AssertionError("Negative COORD values was generated. " + - "This is likely due to a tranformation. " + - "Increasing the escape_origio_shift will most likely " + - "fix the problem") - - @classmethod - def assert_actnum(cls, nx, ny, nz, actnum): - """ - - Raises an AssertionError if the actnum is not as expected. In - particular, it is verified that: - - - actnum has the approperiate length nx*ny*nz and - - that all values are either 0 or 1. - - """ - - if actnum is None: - return - - if len(actnum) != nx*ny*nz: - raise AssertionError( - "Expected the length of ACTNUM to be %d, was %s." - %(nx*ny*nz, len(actnum)) - ) - - if set(actnum)-set([0,1]): - raise AssertionError( - "Expected ACTNUM to consist of 0's and 1's, was %s." - % ", ".join(map(str, set(actnum))) - ) - - @classmethod - def extract_coord(cls, dims, coord, ijk_bounds): - nx, ny, nz = dims - (lx, ux), (ly, uy), (lz, uz) = ijk_bounds - new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 - - cls.assert_coord(nx, ny, nz, coord, negative_values=True) - - # Format COORD - coord = divide(divide(coord, 6), nx+1) - - # Extract new COORD - new_coord = [coord_slice[lx:ux+2:] - for coord_slice in coord[ly:uy+2]] - - # Flatten and verify - new_coord = flatten(flatten(new_coord)) - cls.assert_coord(new_nx, new_ny, new_nz, new_coord, - negative_values=True) - - return construct_floatKW("COORD", new_coord) - - @classmethod - def extract_zcorn(cls, dims, zcorn, ijk_bounds): - nx, ny, nz = dims - (lx, ux), (ly, uy), (lz, uz) = ijk_bounds - new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 - - cls.assert_zcorn(nx, ny, nz, zcorn, twisted_check=False) - - # Format ZCORN - zcorn = divide(divide(zcorn, 2*nx), 2*ny) - - # Extract new ZCORN - new_zcorn = [ - y_slice[2*lx:2*ux+2:] - for z_slice in zcorn[2*lz:2*uz+2:] - for y_slice in z_slice[2*ly:2*uy+2:] - ] - - # Flatten and verify - new_zcorn = flatten(new_zcorn) - cls.assert_zcorn(new_nx, new_ny, new_nz, new_zcorn) - - return construct_floatKW("ZCORN", new_zcorn) - - @classmethod - def extract_actnum(cls, dims, actnum, ijk_bounds): - if actnum is None: - return None - - nx, ny, nz = dims - (lx, ux), (ly, uy), (lz, uz) = ijk_bounds - new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 - - cls.assert_actnum(nx, ny, nz, actnum) - - actnum = divide(divide(actnum, nx), ny) - - new_actnum = [ - y_slice[lx:ux+1:] - for z_slice in actnum[lz:uz+1:] - for y_slice in z_slice[ly:uy+1:] - ] - - new_actnum = flatten(new_actnum) - cls.assert_actnum(new_nx, new_ny, new_nz, new_actnum) - - actnumkw = EclKW("ACTNUM", len(new_actnum), EclDataType.ECL_INT) - for i, value in enumerate(new_actnum): - actnumkw[i] = value - - return actnumkw - - @classmethod - def __translate_coord(cls, coord, translation): - coord = numpy.array([ - map(float, coord[i:i+6:]) - for i in range(0, len(coord), 6) - ]) - translation = numpy.array(list(translation) + list(translation)) - - coord = coord + translation - return construct_floatKW("COORD", coord.flatten().tolist()) - - - @classmethod - def extract_subgrid(cls, grid, ijk_bounds, - decomposition_change=False, translation=None): - - """ - Extracts a subgrid from the given grid according to the specified - bounds. - - @ijk_bounds: The bounds describing the subgrid. Should be a tuple of - length 3, where each element gives the bound for the i, j, k - coordinates of the subgrid to be described, respectively. Each bound - should either be an interval of the form (a, b) where 0 <= a <= b < nx - or a single integer a which is equivialent to the bound (a, a). - - NOTE: The given bounds are including endpoints. - - @decomposition_change: Depending on the given ijk_bounds, libecl might - decompose the cells of the subgrid differently when extracted from - grid. This is somewhat unexpected behaviour and if this event occur we - give an exception together with an description for how to avoid this, - unless decompostion_change is set to True. - - @translation: Gives the possibility of translating the subgrid. Should - be given as a tuple (dx, dy, dz), where each coordinate of the grid - will be moved by di in direction i. - - """ - - gdims = grid.getDims()[:-1:] - nx, ny, nz = gdims - ijk_bounds = cls.assert_ijk_bounds(gdims, ijk_bounds) - - coord = grid.export_coord() - cls.assert_coord(nx, ny, nz, coord, negative_values=True) - - zcorn = grid.export_zcorn() - cls.assert_zcorn(nx, ny, nz, zcorn) - - actnum = grid.export_actnum() - cls.assert_actnum(nx, ny, nz, actnum) - - mapaxes = grid.export_mapaxes() - - sub_data = cls.extract_subgrid_data( - gdims, - coord, zcorn, - ijk_bounds=ijk_bounds, - actnum=actnum, - mapaxes=mapaxes, - decomposition_change=decomposition_change, - translation=translation - ) - - sdim = tuple([b-a+1 for a,b in ijk_bounds]) - sub_coord, sub_zcorn, sub_actnum = sub_data - - return EclGrid.create(sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes) - - @classmethod - def extract_subgrid_data(cls, dims, coord, zcorn, ijk_bounds, actnum=None, - mapaxes=None, decomposition_change=False, translation=None): - """ - - Extracts subgrid data from COORD, ZCORN and potentially ACTNUM. It - returns similar formatted data for the subgrid described by the bounds. - - @dims: The dimentions (nx, ny, nz) of the grid - - @coord: The COORD data of the grid. - - @zcorn: The ZCORN data of the grid. - - @ijk_bounds: The bounds describing the subgrid. Should be a tuple of - length 3, where each element gives the bound for the i, j, k - coordinates of the subgrid to be described, respectively. Each bound - should either be an interval of the form (a, b) where 0 <= a <= b < nx - or a single integer a which is equivialent to the bound (a, a). - - NOTE: The given bounds are including endpoints. - - @actnum: The ACTNUM data of the grid. - - @mapaxes The MAPAXES data of the grid. - - @decomposition_change: Depending on the given ijk_bounds, libecl might - decompose the cells of the subgrid differently when extracted from - grid. This is somewhat unexpected behaviour and if this event occur we - give an exception together with an description for how to avoid this, - unless decompostion_change is set to True. - - @translation: Gives the possibility of translating the subgrid. Should - be given as a tuple (dx, dy, dz), where each coordinate of the grid - will be moved by di in direction i. - - """ - coord, zcorn = list(coord), list(zcorn) - actnum = None if actnum is None else list(actnum) - - ijk_bounds = cls.assert_ijk_bounds(dims, ijk_bounds) - cls.assert_decomposition_change(ijk_bounds, decomposition_change) - - nx, ny, nz = dims - (lx, ux), (ly, uy), (lz, uz) = ijk_bounds - new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1 - - new_coord = cls.extract_coord(dims, coord, ijk_bounds) - new_zcorn = cls.extract_zcorn(dims, zcorn, ijk_bounds) - new_actnum = cls.extract_actnum(dims, actnum, ijk_bounds) - - if translation is not None: - mtranslation = pre_mapaxes_translation(translation, mapaxes) - new_coord = cls.__translate_coord(new_coord, mtranslation) - - for i in range(len(new_zcorn)): - new_zcorn[i] += translation[2] - - return new_coord, new_zcorn, new_actnum - - @classmethod - def assert_ijk_bounds(cls, dims, ijk_bounds): - ijk_bounds = list(ijk_bounds) - - for i in range(len(ijk_bounds)): - if isinstance(ijk_bounds[i], int): - ijk_bounds[i] = [ijk_bounds[i]] - if len(ijk_bounds[i]) == 1: - ijk_bounds[i] += ijk_bounds[i] - - if len(ijk_bounds) != 3: - raise ValueError( - "Expected ijk_bounds to contain three intervals, " + - "contained only %d" % len(ijk_bounds)) - - for n, bound in zip(dims, ijk_bounds): - if len(bound) != 2: - raise ValueError( - "Expected bound to consist of two elements, was %s", - str(bound)) - - if not (isinstance(bound[0], int) and isinstance(bound[1], int)): - raise TypeError( - "Expected bound to consist of two integers, ", - "was %s (%s)" - %(str(bound), str((map(type,bound)))) - ) - - if not (0 <= bound[0] <= bound[1] < n): - raise ValueError( - "Expected bounds to have the following format: " + - "0 <= lower bound <= upper_bound < ni, "+ - "was %d <=? %d <=? %d -# for more details. - -from ecl.ecl import EclFileEnum, EclFile, Ecl3DFile - - -class EclInitFile(Ecl3DFile): - - def __init__(self, grid, filename, flags=0): - file_type, report_step, fmt_file = EclFile.getFileType(filename) - if file_type == EclFileEnum.ECL_INIT_FILE: - super(EclInitFile, self).__init__(grid, filename, flags) - else: - err = 'The input filename "%s" does not correspond to a restart file.' - err += ' Please follow the Eclipse naming conventions.' - raise ValueError(err % filename) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py deleted file mode 100644 index 6618abdd90..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py +++ /dev/null @@ -1,1173 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_kw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Support for working with one keyword from ECLIPSE file. - -ECLIPSE files in "restart format" are organized in keywords consisting -of a simple header and blocks of data. A keyword typically looks like: - - 'SWAT ' 10000 'REAL' - 0.05 0.08 0.08 0.10 - 0.11 0.11 0.10 0.09 - .... - -I.e. it starts with of header consisting of a 8 characters name, a -length and a datatype, immediately followed by the actual -data. - -Altough the term "restart format" is used to describe the format, this -particular format is not limited to restart files; it is (at least) -used in INIT, EGRID, GRID, Snnn, UNSMRY, SMSPEC, UNRST, Xnnnn and RFT -files. This module also has (some) support for working with GRDECL -'formatted' files. - -The ecl_kw.py implementation wraps the ecl_kw.c implementation from -the libecl library. -""" - -from __future__ import absolute_import, division, print_function, unicode_literals - -import ctypes -import warnings -import numpy - -from cwrap import CFILE, BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclDataType -from ecl.ecl import EclTypeEnum, EclUtil, EclPrototype - -def dump_type_deprecation_warning(): - warnings.warn("EclTypeEnum is deprecated. " + - "You should instead provide an EclDataType", - DeprecationWarning) - -def constant_size_data_type(ecl_type): - return (ecl_type in [ - EclTypeEnum.ECL_CHAR_TYPE, - EclTypeEnum.ECL_FLOAT_TYPE, - EclTypeEnum.ECL_DOUBLE_TYPE, - EclTypeEnum.ECL_INT_TYPE, - EclTypeEnum.ECL_BOOL_TYPE, - EclTypeEnum.ECL_MESS_TYPE - ]) - -def warn_and_cast_data_type(data_type): - if isinstance(data_type, EclDataType): - return data_type - if isinstance(data_type, EclTypeEnum): - if not constant_size_data_type(data_type): - raise ValueError("Cannot cast EclTypeEnum (%d) to EclDataType due " - "to non-constant size. Please provide an EclDataType instead.") - - dump_type_deprecation_warning() - return EclDataType(data_type) - -class EclKW(BaseCClass): - """ - The EclKW class contains the information from one ECLIPSE keyword. - - The ecl_kw type is the lowest level type in the libecl C library, - and all the other datatypes like e.g. ecl_grid and ecl_sum are - based on collections of ecl_kw instances, and interpreting the - content of the ecl_kw keywords. - - Many of the special __xxx___() functions have been implemented, so - that the EclKW class supports both numerical operations and also - [] based lookup. Many of the methods accept an optional @mask - argument; this should be a EclRegion instance which can be used to - limit the operation to a part of the EclKW. - """ - - int_kw_set = set(["PVTNUM", "FIPNUM", "EQLNUM", "FLUXNUM", "MULTNUM", "ACTNUM", "SPECGRID", "REGIONS"]) - - TYPE_NAME = "ecl_kw" - _alloc_new = EclPrototype("void* ecl_kw_alloc_python(char*, int, ecl_data_type)", bind = False) - _fread_alloc = EclPrototype("ecl_kw_obj ecl_kw_fread_alloc(fortio)", bind = False) - _load_grdecl = EclPrototype("ecl_kw_obj ecl_kw_fscanf_alloc_grdecl_dynamic_python(FILE, char*, bool, ecl_data_type)", bind = False) - _fseek_grdecl = EclPrototype("bool ecl_kw_grdecl_fseek_kw(char*, bool, FILE)", bind = False) - - _sub_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_sub_copy(ecl_kw, char*, int, int)") - _copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_copy(ecl_kw)") - _slice_copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_slice_copy(ecl_kw, int, int, int)") - _fprintf_grdecl = EclPrototype("void ecl_kw_fprintf_grdecl(ecl_kw, FILE)") - _fprintf_data = EclPrototype("void ecl_kw_fprintf_data(ecl_kw, char*, FILE)") - - _get_size = EclPrototype("int ecl_kw_get_size(ecl_kw)") - _get_fortio_size = EclPrototype("size_t ecl_kw_fortio_size(ecl_kw)") - _get_type = EclPrototype("ecl_type_enum ecl_kw_get_type(ecl_kw)") - _iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr(ecl_kw, int)") - _iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr(ecl_kw, int, char*)") - _iget_string_ptr = EclPrototype("char* ecl_kw_iget_string_ptr(ecl_kw, int)") - _iset_string_ptr = EclPrototype("void ecl_kw_iset_string_ptr(ecl_kw, int, char*)") - _iget_bool = EclPrototype("bool ecl_kw_iget_bool(ecl_kw, int)") - _iset_bool = EclPrototype("bool ecl_kw_iset_bool(ecl_kw, int, bool)") - _iget_int = EclPrototype("int ecl_kw_iget_int(ecl_kw, int)") - _iget_double = EclPrototype("double ecl_kw_iget_double(ecl_kw, int)") - _iget_float = EclPrototype("float ecl_kw_iget_float(ecl_kw, int)") - _float_ptr = EclPrototype("float* ecl_kw_get_float_ptr(ecl_kw)") - _int_ptr = EclPrototype("int* ecl_kw_get_int_ptr(ecl_kw)") - _double_ptr = EclPrototype("double* ecl_kw_get_double_ptr(ecl_kw)") - _free = EclPrototype("void ecl_kw_free(ecl_kw)") - _fwrite = EclPrototype("void ecl_kw_fwrite(ecl_kw, fortio)") - _get_header = EclPrototype("char* ecl_kw_get_header (ecl_kw)") - _set_header = EclPrototype("void ecl_kw_set_header_name (ecl_kw, char*)") - _get_data_type = EclPrototype("ecl_data_type_obj ecl_kw_get_data_type_python(ecl_kw)"); - - _int_sum = EclPrototype("int ecl_kw_element_sum_int(ecl_kw)") - _float_sum = EclPrototype("double ecl_kw_element_sum_float(ecl_kw)") - _iadd = EclPrototype("void ecl_kw_inplace_add(ecl_kw, ecl_kw)") - _imul = EclPrototype("void ecl_kw_inplace_mul(ecl_kw, ecl_kw)") - _idiv = EclPrototype("void ecl_kw_inplace_div(ecl_kw, ecl_kw)") - _isub = EclPrototype("void ecl_kw_inplace_sub(ecl_kw, ecl_kw)") - _iabs = EclPrototype("void ecl_kw_inplace_abs(ecl_kw)") - _equal = EclPrototype("bool ecl_kw_equal(ecl_kw, ecl_kw)") - _equal_numeric = EclPrototype("bool ecl_kw_numeric_equal(ecl_kw, ecl_kw, double, double)") - - _assert_binary = EclPrototype("bool ecl_kw_size_and_numeric_type_equal(ecl_kw, ecl_kw)") - _scale_int = EclPrototype("void ecl_kw_scale_int(ecl_kw, int)") - _scale_float = EclPrototype("void ecl_kw_scale_float_or_double(ecl_kw, double)") - _shift_int = EclPrototype("void ecl_kw_shift_int(ecl_kw, int)") - _shift_float = EclPrototype("void ecl_kw_shift_float_or_double(ecl_kw, double)") - _copy_data = EclPrototype("void ecl_kw_memcpy_data(ecl_kw, ecl_kw)") - _set_int = EclPrototype("void ecl_kw_scalar_set_int(ecl_kw, int)") - _set_float = EclPrototype("void ecl_kw_scalar_set_float_or_double(ecl_kw, double)") - - _max_min_int = EclPrototype("void ecl_kw_max_min_int(ecl_kw, int*, int*)") - _max_min_float = EclPrototype("void ecl_kw_max_min_float(ecl_kw, float*, float*)") - _max_min_double = EclPrototype("void ecl_kw_max_min_double(ecl_kw, double*, double*)") - _fix_uninitialized = EclPrototype("void ecl_kw_fix_uninitialized(ecl_kw,int, int, int, int*)") - _first_different = EclPrototype("int ecl_kw_first_different(ecl_kw, ecl_kw, int, double, double)") - _resize = EclPrototype("void ecl_kw_resize(ecl_kw, int)") - - @classmethod - def createCReference(cls, c_ptr, parent=None): - ecl_kw = super(EclKW, cls).createCReference(c_ptr, parent=parent) - if ecl_kw is None: - raise ValueError("Failed to create EclKW instance") - - ecl_kw.__private_init() - return ecl_kw - - - @classmethod - def createPythonObject(cls, c_ptr): - ecl_kw = super(EclKW, cls).createPythonObject(c_ptr) - if ecl_kw is None: - raise ValueError("Failed to create EclKW instance") - - ecl_kw.__private_init() - return ecl_kw - - - - @classmethod - def add_int_kw(cls, kw): - """Will add keyword @kw to the standard set of integer keywords.""" - cls.int_kw_set.add(kw) - - @classmethod - def del_int_kw(cls, kw): - """Will remove keyword @kw from the standard set of integer keywords.""" - cls.int_kw_set.discard(kw) - - @classmethod - def int_keywords(cls): - """Will return the current set of integer keywords.""" - return cls.int_kw_set - - - def slice_copy(self, slice_range): - (start, stop, step) = slice_range.indices(len(self)) - if stop > start: - return self._slice_copyc(start, stop, step) - else: - return None - - - def copy(self): - """ - Will create a deep copy of the current kw instance. - """ - return self._copyc() - - - - - @classmethod - def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): - """ - Function to load an EclKW instance from a grdecl formatted filehandle. - - This constructor can be used to load an EclKW instance from a - grdecl formatted file; the input files for petrophysical - properties are typically given as grdecl files. - - The @file argument should be a Python filehandle to an open - file. The @kw argument should be the keyword header you are - searching for, e.g. "PORO" or "PVTNUM"[1], the method will - then search forward through the file to look for this @kw. If - the keyword can not be found the method will return None. The - searching will start from the current position in the file; so - if you want to reposition the file pointer you should use the - seek() method of the file object first. - - Observe that there is a strict 8 character limit on @kw - - altough you could in principle use an arbitrary external - program to create grdecl files with more than 8 character - length headers, this implementation will refuse to even try - loading them. In that case you will have to rename the - keywords in your file - sorry. A TypeError exception - will be raised if @kw has more than 8 characters. - - The implementation in ert can read integer and float type - keywords from grdecl files; however the grdecl files have no - datatype header, and it is impossible to determine the type - reliably by inspection. Hence the type must be known when - reading the file. The algorithm for specifying type, in order - of presedence, is as follows: - - 1. The optional argument @ecl_type can be used to specify - the type: - - special_int_kw = EclKW.read_grdecl(fileH, 'INTKW', ecl_type=ECL_INT) - - If ecl_type is different from ECL_INT or - ECL_FLOAT a TypeError exception will be raised. - - If ecl_type == None (the default), the method will continue - to point 2. or 3. to determine the correct type. - - - 2. If the keyword is included in the set built in set - 'int_kw_set' the type will be ECL_INT_TYPE. - - pvtnum_kw = EclKW.read_grdecl(fileH, 'PVTNUM') - - Observe that (currently) no case conversions take place - when checking the 'int_kw_set'. The current built in set is - accesible through the int_kw property. - - - 3. Otherwise the default is float, i.e. ECL_FLOAT. - - EclKw reads grdecl with EclDataType - poro_kw = EclKW.read_grdecl(fileH, 'PORO') - - - Observe that since the grdecl files are quite weakly - structured it is difficult to verify the integrity of the - files, malformed input might therefor pass unnoticed before - things blow up at a later stage. - - [1]: It is possible, but not recommended, to pass in None for - @kw, in which case the method will load the first keyword - it finds in the file. - """ - - cfile = CFILE(fileH) - if kw: - if len(kw) > 8: - raise TypeError("Sorry keyword:%s is too long, must be eight characters or less." % kw) - - if ecl_type is None: - if cls.int_kw_set.__contains__(kw): - ecl_type = EclDataType.ECL_INT - else: - ecl_type = EclDataType.ECL_FLOAT - - ecl_type = warn_and_cast_data_type(ecl_type) - - if not isinstance(ecl_type, EclDataType): - raise TypeError("Expected EclDataType, was: %s" % type(ecl_type)) - - if not ecl_type in [EclDataType.ECL_FLOAT, EclDataType.ECL_INT]: - raise ValueError("The type:%s is invalid when loading keyword:%s" % (ecl_type.type_name, kw)) - - return cls._load_grdecl(cfile, kw, strict, ecl_type) - - - @classmethod - def fseek_grdecl(cls, fileH, kw, rewind=False): - """ - Will search through the open file and look for string @kw. - - If the search succeeds the function will return and the file - pointer will be positioned at the start of the kw, if the - search fails the function will return false and the file - pointer will be repositioned at the position it had prior to - the call. - - Only @kw instances which are found at the beginning of a line - (with optional leading space characters) are considered, - i.e. searching for the string PERMX in the cases below will - fail: - - -- PERMX - EQUIL PERMX / - - - The function will start searching from the current position in - the file and forwards, if the optional argument @rewind is - true the function rewind to the beginning of the file and - search from there after the initial search. - """ - cfile = CFILE(fileH) - return cls._fseek_grdecl(kw, rewind, cfile) - - - @classmethod - def fread(cls, fortio): - """ - Will read a new EclKW instance from the open FortIO file. - """ - return cls._fread_alloc(fortio) - - - def free(self): - self._free() - - def __repr__(self): - si = len(self) - nm = self.getName() - mm = 'type=%s' % str(self.getEclType()) - if self.isNumeric(): - mi, ma = self.getMinMax() - mm = 'min=%.2f, max=%.2f' % (mi,ma) - ad = self._ad_str() - fmt = 'EclKW(size=%d, name="%s", %s) %s' - return fmt % (si,nm,mm,ad) - - def __init__(self, name, size, data_type): - """Creates a brand new EclKW instance. - - This method will create a grand spanking new EclKW - instance. The instance will get name @name @size elements and - datatype @data_type. Using this method you could create a SOIL - keyword with: - - soil_kw = EclKW("SOIL", 10000, ECL_FLOAT_TYPE) - - """ - if len(name) > 8: - raise ValueError("Sorry - maximum eight characters in keyword name") - - data_type = warn_and_cast_data_type(data_type) - - if not isinstance(data_type, EclDataType): - raise TypeError("Expected an EclDataType, received: %s" % - type(data_type)) - - c_ptr = self._alloc_new(name, size, data_type) - super(EclKW, self).__init__(c_ptr) - self.__private_init() - - - - def __private_init(self): - self.data_ptr = None - - if self.data_type.is_int(): - self.data_ptr = self._int_ptr() - self.dtype = numpy.int32 - self.str_fmt = "%8d" - elif self.data_type.is_float(): - self.data_ptr = self._float_ptr() - self.dtype = numpy.float32 - self.str_fmt = "%13.4f" - elif self.data_type.is_double(): - self.data_ptr = self._double_ptr() - self.dtype = numpy.float64 - self.str_fmt = "%13.4f" - else: - # Iteration not supported for CHAR / BOOL - self.data_ptr = None - self.dtype = None - if self.data_type.is_char(): - self.str_fmt = "%8s" - elif self.data_type.is_bool(): - self.str_fmt = "%d" - elif self.data_type.is_mess(): - self.str_fmt = "%s" #"Message type" - elif self.data_type.is_string(): - self.str_fmt = "%" + str(self.data_type.element_size) + "s" - else: - raise ValueError("Unknown EclDataType (%s)!" % self.data_type.type_name) - - def sub_copy(self, offset, count, new_header=None): - """ - Will create a new block copy of the src keyword. - - If @new_header == None the copy will get the same 'name' as - the src, otherwise the keyword will get the @new_header as - header. - - The copy will start at @block of the src keyword and copy - @count elements; a negative value of @count is interpreted as - 'the rest of the elements' - - new1 = src.sub_copy(0, 10, new_header="NEW1") - new2 = src.sub_copy(10, -1, new_header="NEW2") - - If the count or index arguments are in some way invalid the - method will raise IndexError. - """ - if offset < 0 or offset >= len(self): - raise IndexError("Offset:%d invalid - valid range:[0,%d)" % (offset, len(self))) - - if offset + count > len(self): - raise IndexError("Invalid value of (offset + count):%d" % (offset + count)) - - return self._sub_copy(new_header, offset, count) - - - def is_numeric(self): - """ - Will check if the keyword contains numeric data, i.e int, float or double. - """ - return self.data_type.is_numeric() - - def ecl_kw_instance(self): - return True - - - - def __len__(self): - """ - Returns the number of elements. Implements len() - """ - return self._get_size() - - - def __deep_copy__(self, memo): - """ - Python special routine used to perform deep copy. - """ - ecl_kw = self.copy() - return ecl_kw - - - def __getitem__(self, index): - """ - Function to support index based lookup: y = kw[index] - """ - if isinstance(index,int): - length = len(self) - if index < 0: - # We allow one level of negative indexing - index += len(self) - - if index < 0 or index >= length: - raise IndexError - else: - if self.data_ptr: - return self.data_ptr[ index ] - else: - if self.data_type.is_bool(): - return self._iget_bool(index) - elif self.data_type.is_char(): - return self._iget_char_ptr(index) - elif self.data_type.is_string(): - return self._iget_string_ptr(index) - else: - raise TypeError("Internal implementation error ...") - elif isinstance(index, slice): - return self.slice_copy(index) - else: - raise TypeError("Index should be integer type") - - - def __setitem__(self, index,value): - """ - Function to support index based assignment: kw[index] = value - """ - if isinstance(index, int): - length = len(self) - if index < 0: - # Will only wrap backwards once - index = len(self) + index - - if index < 0 or index >= length: - raise IndexError - else: - if self.data_ptr: - self.data_ptr[ index ] = value - else: - if self.data_type.is_bool(): - self._iset_bool(index, value) - elif self.data_type.is_char(): - return self._iset_char_ptr(index, value) - elif self.data_type.is_string(): - return self._iset_string_ptr(index, value) - else: - raise SystemError("Internal implementation error ...") - elif isinstance(index, slice): - (start, stop, step) = index.indices(len(self)) - index = start - while index < stop: - self[index] = value - index += step - else: - raise TypeError("Index should be integer type") - - - ################################################################# - - - def __IMUL__(self, factor, mul=True): - if self.isNumeric(): - if hasattr(factor, "ecl_kw_instance"): - if self.assert_binary(factor): - if mul: - self._imul(factor) - else: - self._idiv(factor) - else: - raise TypeError("Type mismatch") - else: - if not mul: - factor = 1.0 / factor - - if self.data_type.is_int(): - if isinstance(factor, int): - self._scale_int(factor) - else: - raise TypeError("Type mismatch") - else: - if isinstance(factor, int) or isinstance(factor, float): - self._scale_float(factor) - else: - raise TypeError("Only muliplication with scalar supported") - else: - raise TypeError("Not numeric type") - - return self - - - def __IADD__(self, delta, add=True): - if self.isNumeric(): - if type(self) == type(delta): - if self.assert_binary(delta): - if add: - self._iadd(delta) - else: - self._isub(delta) - else: - raise TypeError("Type / size mismatch") - else: - if add: - sign = 1 - else: - sign = -1 - - if self.data_type.is_int(): - if isinstance(delta, int): - self._shift_int(delta * sign) - else: - raise TypeError("Type mismatch") - else: - if isinstance(delta, int) or isinstance(delta, float): - self._shift_float(delta * sign) # Will call the _float() or _double() function in the C layer. - else: - raise TypeError("Type mismatch") - else: - raise TypeError("Type / size mismatch") - - return self - - def __iadd__(self, delta): - return self.__IADD__(delta, True) - - def __isub__(self, delta): - return self.__IADD__(delta, False) - - def __imul__(self, delta): - return self.__IMUL__(delta, True) - - def __idiv__(self, delta): - return self.__IMUL__(delta, False) - - - ################################################################# - - def __abs__(self): - if self.isNumeric(): - copy = self.copy() - copy._iabs() - return copy - else: - raise TypeError("The __abs__() function is only implemented for numeric types") - - - - def __add__(self, delta): - copy = self.copy() - copy += delta - return copy - - def __radd__(self, delta): - return self.__add__(delta) - - def __sub__(self, delta): - copy = self.copy() - copy -= delta - return copy - - def __rsub__(self, delta): - return self.__sub__(delta) * -1 - - def __mul__(self, factor): - copy = self.copy() - copy *= factor - return copy - - def __rmul__(self, factor): - return self.__mul__(factor) - - def __div__(self, factor): - copy = self.copy() - copy /= factor - return copy - - # No __rdiv__() - - def sum(self, mask = None, force_active = False): - """ - Will calculate the sum of all the elements in the keyword. - - String: Raise ValueError exception. - Bool: The number of true values - """ - if mask is None: - if self.data_type.is_int(): - return self._int_sum() - elif self.data_type.is_float(): - return self._float_sum() - elif self.data_type.is_double(): - return self._float_sum() - elif self.data_type.is_bool(): - sum = 0 - for elm in self: - if elm: - sum += 1 - return sum - else: - raise ValueError('The keyword "%s" is of string type - sum is not implemented' % self.getName()) - - return mask.sum_kw(self, force_active) - - - - def assert_binary(self, other): - """ - Utility function to assert that keywords @self and @other can - be combined. - """ - return self._assert_binary(other) - - ################################################################# - - def assign(self, value, mask=None, force_active=False): - """ - Assign a value to current kw instance. - - This method is used to assign value(s) to the current EclKW - instance. The @value parameter can either be a scalar, or - another EclKW instance. To set all elements of a keyword to - 1.0: - - kw.assign(1.0) - - The numerical type of @value must be compatible with the - current keyword. The optional @mask argument should be an - EclRegion instance which can be used to limit the assignment - to only parts of the EclKW. In the example below we select all - the elements with PORO below 0.10, and then assign EQLNUM - value 88 to those cells: - - grid = ecl.EclGrid("ECLIPSE.EGRID") - reg = ecl.EclRegion(grid, false) - init = ecl.EclFile("ECLIPSE.INIT") - - poro = init["PORO"][0] - eqlnum = init["EQLNUM"][0] - reg.select_below(poro, 0.10) - - eqlnum.assign(88, mask = reg) - - The EclRegion instance has two equivalent sets of selected - indices; one consisting of active indices and one consisting - of global indices. By default the assign() method will select - the global indices if the keyword has nx*ny*nz elements and - the active indices if the kw has nactive elements. By setting - the optional argument @force_active to true, you can force the - method to only modify the active indices, even though the - keyword has nx*ny*nz elements; if the keyword has nactive - elements the @force_active flag is not considered. - """ - if self.isNumeric(): - if type(value) == type(self): - if mask is not None: - mask.copy_kw(self, value, force_active) - else: - if self.assert_binary(value): - self._copy_data(value) - else: - raise TypeError("Type / size mismatch") - else: - if mask is not None: - mask.set_kw(self, value, force_active) - else: - if self.data_type.is_int(): - if isinstance(value, int): - self._set_int(value) - else: - raise TypeError("Type mismatch") - else: - if isinstance(value, int) or isinstance(value, float): - self._set_float(value) - else: - raise TypeError("Only muliplication with scalar supported") - - - def add(self, other, mask=None, force_active=False): - """ - See method assign() for documentation of optional arguments - @mask and @force_active. - """ - if mask is not None: - mask.iadd_kw(self, other, force_active) - else: - return self.__iadd__(other) - - def sub(self, other, mask=None, force_active=False): - """ - See method assign() for documentation of optional arguments - @mask and @force_active. - """ - if mask is not None: - mask.isub_kw(self, other, force_active) - else: - return self.__isub__(other) - - def mul(self, other, mask=None, force_active=False): - """ - See method assign() for documentation of optional arguments - @mask and @force_active. - """ - if mask is not None: - mask.imul_kw(self, other, force_active) - else: - return self.__imul__(other) - - def div(self, other, mask=None, force_active=False): - """ - See method assign() for documentation of optional arguments - @mask and @force_active. - """ - if mask is not None: - mask.idiv_kw(self, other, force_active) - else: - return self.__idiv__(other) - - def apply(self, func, arg=None, mask=None, force_active=False): - """ - Will apply the function @func on the keyword - inplace. - - The function @func should take a scalar value from the ecl_kw - vector as input, and return a scalar value of the same type; - optionally you can supply a second argument with the @arg - attribute: - - def cutoff(x, limit): - if x > limit: - return x - else: - return 0 - - - kw.apply(math.sin) - kw.apply(cutoff, arg=0.10) - - - See method assign() for documentation of optional arguments - @mask and @force_active. - """ - if mask is not None: - active_list = mask.kw_index_list(self, force_active) - if arg: - for index in active_list: - self.data_ptr[index] = func(self.data_ptr[index], arg) - else: - for index in active_list: - self.data_ptr[index] = func(self.data_ptr[index]) - else: - if arg: - for i in range(len(self)): - self.data_ptr[i] = func(self.data_ptr[i], arg) - else: - for i in range(len(self)): - self.data_ptr[i] = func(self.data_ptr[i]) - - - def equal(self, other): - """ - Will check if the two keywords are (exactly) equal. - - The check is based on the content of the keywords, and not - pointer comparison. - """ - if isinstance(other, EclKW): - return self._equal(other) - else: - raise TypeError("Can only compare with another EclKW") - - - def __eq__(self, other): - return self.equal(other) - - def __hash__(self): - return hash(self._get_header()) - - - def equal_numeric(self, other, epsilon=1e-6, abs_epsilon=None, rel_epsilon=None): - """Will check if two numerical keywords are ~nearly equal. - - - If the keywords are of type integer, the comparison is - absolute. - - If you pass in xxx_epsilon <= 0 the xxx_epsilon will be - ignored in the test. - - """ - if isinstance(other, EclKW): - if abs_epsilon is None: - abs_epsilon = epsilon - - if rel_epsilon is None: - rel_epsilon = epsilon - - return self._equal_numeric(other, abs_epsilon, rel_epsilon) - else: - raise TypeError("Can only compare with another EclKW") - - - ################################################################# - - def deep_copy(self): - ecl_kw = self.__deep_copy__({}) - return ecl_kw - - def fort_io_size(self): - """ - The number of bytes this keyword would occupy in a BINARY file. - """ - return self._get_fortio_size() - - def set_name(self, name): - if len(name) > 8: - raise ValueError("Sorry: the name property must be max 8 characters long :-(") - self._set_header(name) - - @property - def name(self): - n = self._get_header() - return str(n) if n else '' - - @name.setter - def name(self, value): - self.set_name(value) - - def get_name(self): - return self.name - - def resize(self, new_size): - """ - Will set the new size of the kw to @new_size. - """ - if new_size >= 0: - self._resize(new_size) - - # Iteration is based on a pointer to the underlying storage, - # that will generally by reset by the resize() call; i.e. we - # need to call the __private_init() method again. - self.__private_init() - - - def get_min_max(self): - """ - Will return a touple (min,max) for numerical types. - - Will raise TypeError exception if the keyword is not of - numerical type. - """ - if self.data_type.is_float(): - min_ = ctypes.c_float() - max_ = ctypes.c_float() - self._max_min_float(ctypes.byref(max_), ctypes.byref(min_)) - elif self.data_type.is_double(): - min_ = ctypes.c_double() - max_ = ctypes.c_double() - self._max_min_double(ctypes.byref(max_), ctypes.byref(min_)) - elif self.data_type.is_int(): - min_ = ctypes.c_int() - max_ = ctypes.c_int() - self._max_min_int(ctypes.byref(max_), ctypes.byref(min_)) - else: - raise TypeError("min_max property not defined for keywords of type: %s" % self.type) - return (min_.value, max_.value) - - - def get_max(self): - mm = self.getMinMax() - return mm[1] - - - def get_min(self): - mm = self.getMinMax() - return mm[0] - - @property - def type(self): - return self.getEclType() - - @property - def data_type(self): - return self._get_data_type() - - @property - def type_name(self): - return self.data_type.type_name - - def type_name(self): - return self.data_type.type_name - - def get_ecl_type(self): - warnings.warn("EclTypeEnum is deprecated. " + - "You should instead provide an EclDataType", - DeprecationWarning) - - return self._get_type() - - - - - @property - def header(self): - return (self.getName(), len(self), self.typeName()) - - @property - def array(self): - a = self.data_ptr - if not a == None: - a.size = len(self) - a.__parent__ = self # Inhibit GC - return a - - - def str_data(self, width, index1, index2, fmt): - """ - Helper function for str() method. - """ - data = [] - s = "" - for index in range(index1, index2): - data.append(self[index]) - for index in range(len(data)): - s += fmt % data[ index ] - if index % width == (width - 1): - s+= "\n" - return s - - - def str(self, width=5, max_lines=10, fmt=None): - """ - Return string representation of kw for pretty printing. - - The function will return a string consisting of a header, and - then a chunk of data. The data will be formatted in @width - columns, and a maximum of @max_lines lines. If @max_lines is - not sufficient the first elements in the kewyord are - represented, a .... continuation line and then the last part - of the keyword. If @max_lines is None all of the vector will - be printed, irrespective of how long it is. - - If a value is given for @fmt that is used as format string for - each element, otherwise a type-specific default format is - used. If given the @fmt string should contain spacing between - the elements. The implementation of the builtin method - __str__() is based on this method. - """ - s = "%-8s %8d %-4s\n" % (self.getName(), len(self), self.typeName()) - lines = len(self) // width - if not fmt: - fmt = self.str_fmt + " " - - if max_lines is None or lines <= max_lines: - s += self.str_data(width, 0, len(self), fmt) - else: - s1 = width * max_lines // 2 - s += self.str_data(width , 0, s1, fmt) - s += " .... \n" - s += self.str_data(width , len(self) - s1, len(self), fmt) - - return s - - def __str__(self): - """ - Return string representation - see method str(). - """ - return self.str(width=5, max_lines=10) - - - def numpy_view(self): - """Will return a numpy view to the underlying data. - - The data in this numpy array is *shared* with the EclKW - instance, meaning that updates in one will be reflected in the - other. - """ - - if self.dtype is numpy.float64: - ct = ctypes.c_double - elif self.dtype is numpy.float32: - ct = ctypes.c_float - elif self.dtype is numpy.int32: - ct = ctypes.c_int - else: - raise ValueError("Invalid type - numpy array only valid for int/float/double") - - ap = ctypes.cast(self.data_ptr, ctypes.POINTER(ct * len(self))) - return numpy.frombuffer(ap.contents, dtype=self.dtype) - - - def numpy_copy(self): - """Will return a numpy array which contains a copy of the EclKW data. - - The numpy array has a separate copy of the data, so that - changes to either the numpy array or the EclKW will *not* be - reflected in the other datastructure. This is in contrast to - the EclKW.numpyView() method where the underlying data is - shared. - """ - view = self.numpyView() - return numpy.copy(view) - - def fwrite(self, fortio): - self._fwrite(fortio) - - def write_grdecl(self, file): - """ - Will write keyword in GRDECL format. - - This method will write the current keyword in GRDECL format, - the @file argument must be a Python file handle to an already - opened file. In the example below we load the porosity from an - existing GRDECL file, set all poro values below 0.05 to 0.00 - and write back an updated GRDECL file. - - poro = ecl.EclKW.read_grdecl(open("poro1.grdecl", "r"), "PORO") - grid = ecl.EclGrid("ECLIPSE.EGRID") - reg = ecl.EclRegion(grid, False) - - reg.select_below(poro, 0.05) - poro.assign(0.0, mask=reg) - - fileH = open("poro2.grdecl", "w") - poro.write_grdecl(fileH) - fileH.close() - - """ - cfile = CFILE(file) - self._fprintf_grdecl(cfile) - - - - def fprintf_data(self, file, fmt=None): - """ - Will print the keyword data formatted to file. - - The @file argument should be a python file handle to a file - opened for writing. The @fmt argument is used as fprintf() - format specifier, observe that the format specifier should - include a separation character between the elements. If no - @fmt argument is supplied the default str_fmt specifier is - used for every element, separated by a newline. - - In the case of boolean data the function will print o and 1 - for False and True respectively. For string data the function - will print the data as 8 characters long string with blank - padding on the right. - """ - if fmt is None: - fmt = self.str_fmt + "\n" - cfile = CFILE(file) - self._fprintf_data(fmt, cfile) - - - def fix_uninitialized(self, grid): - """ - Special case function for region code. - """ - dims = grid.getDims() - actnum = grid.exportACTNUM() - self._fix_uninitialized(dims[0], dims[1], dims[2], actnum.getDataPtr()) - - - def get_data_ptr(self): - if self.data_type.is_int(): - return self._int_ptr() - elif self.data_type.is_float(): - return self._float_ptr() - elif self.data_type.is_double(): - return self._double_ptr() - else: - raise ValueError("Only numeric types can export data pointer") - - - def first_different(self, other, offset=0, epsilon=0, abs_epsilon=None, rel_epsilon=None): - if len(self) != len(other): - raise ValueError("Keywords must have equal size") - - if offset >= len(self): - raise IndexError("Offset:%d invalid - size:%d" % (offset, len(self))) - - if self.getEclType() != other.getEclType(): - raise TypeError("The two keywords have different type") - - if abs_epsilon is None: - abs_epsilon = epsilon - - if rel_epsilon is None: - rel_epsilon = epsilon - - return self._first_different(other, offset, abs_epsilon, rel_epsilon) - -monkey_the_camel(EclKW, 'intKeywords', EclKW.int_keywords, classmethod) -monkey_the_camel(EclKW, 'isNumeric', EclKW.is_numeric) -monkey_the_camel(EclKW, 'fortIOSize', EclKW.fort_io_size) -monkey_the_camel(EclKW, 'setName', EclKW.set_name) -monkey_the_camel(EclKW, 'getName', EclKW.get_name) -monkey_the_camel(EclKW, 'getMinMax', EclKW.get_min_max) -monkey_the_camel(EclKW, 'getMax', EclKW.get_max) -monkey_the_camel(EclKW, 'getMin', EclKW.get_min) -monkey_the_camel(EclKW, 'typeName', EclKW.type_name) -monkey_the_camel(EclKW, 'getEclType', EclKW.get_ecl_type) -monkey_the_camel(EclKW, 'numpyView', EclKW.numpy_view) -monkey_the_camel(EclKW, 'numpyCopy', EclKW.numpy_copy) -monkey_the_camel(EclKW, 'fixUninitialized', EclKW.fix_uninitialized) -monkey_the_camel(EclKW, 'getDataPtr', EclKW.get_data_ptr) -monkey_the_camel(EclKW, 'firstDifferent', EclKW.first_different) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py deleted file mode 100644 index df3860203e..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py +++ /dev/null @@ -1,220 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'ecl_npv.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import re -import datetime -import numbers - -from ecl.util import monkey_the_camel -from ecl.ecl import EclSum - - -class NPVParseKey(object): - def __init__(self, eclNPV): - self.baseCase = eclNPV.baseCase - self.NPV = eclNPV - - - def __call__(self, matchObject): - key = matchObject.group(1) - smspecNode = self.baseCase.smspec_node(key) - if smspecNode.isTotal(): - var = key.replace(":", "_") - self.NPV.addKey(key, var) - return var + "[i]" - else: - raise ValueError("Sorry - the key: %s is not a total key - aborting" % key) - - -class NPVPriceVector(object): - def __init__(self, argList): - self.dateList = [] - if isinstance(argList, list): - for item in argList: - if isinstance(item, tuple) and len(item) == 2: - self.addItem(item) - else: - raise ValueError("Each element in list must be tuple with two elements") - else: - raise ValueError("Constructor argument must be list") - - - - def add_item(self, item): - dateItem = item[0] - try: - year = dateItem.year - month = dateItem.month - day = dateItem.day - date = datetime.date(year, month, day) - except AttributeError: - try: - tmp = re.split("[ .-/]", dateItem) - day = int(tmp[0]) - month = int(tmp[1]) - year = int(tmp[2]) - - date = datetime.date(year, month, day) - except Exception: - raise ValueError("First element was invalid date item") - - - if len(self.dateList): - prevItem = self.dateList[-1] - if prevItem[0] >= date: - raise ValueError("The dates must be in a strictly increasing order") - - value = item[1] - if isinstance(value, numbers.Real) or callable(value): - self.dateList.append((date, value)) - else: - raise ValueError("The value argument must be a scalar number or callable") - - @staticmethod - def assert_date(date): - try: - year = date.year - month = date.month - day = date.day - date = datetime.date(year, month, day) - - return date - except AttributeError: - return date.date() - - - - def eval_date(self, dateItem, date): - value = dateItem[1] - if callable(value): - td = date - dateItem[0] - return value(td.days) - else: - return value - - - def eval(self, date): - date = self.assertDate(date) - startDate = self.dateList[0][0] - if date >= startDate: - endDate = self.dateList[-1][0] - if date >= endDate: - return self.evalDate(self.dateList[-1], date) - else: - index1 = 0 - index2 = len(self.dateList) - 1 - while True: - if (index2 - index1) == 1: - index = index1 - break - - index = (index1 + index2) >> 1 - item = self.dateList[index] - if date >= item[0]: - index1 = index - else: - index2 = index - return self.evalDate(self.dateList[index], date) - else: - raise ValueError("Input date:%s before start of vector" % date) - - - - - -class EclNPV(object): - sumKeyRE = re.compile("[[]([\w:,]+)[]]") - - - def __init__(self, baseCase): - sum = EclSum(baseCase) - if sum: - self.baseCase = sum - else: - raise Error("Failed to open ECLIPSE sumamry case:%s" % baseCase) - self.expression = None - self.keyList = {} - self.start = None - self.end = None - self.interval = "1Y" - - - def eval(self): - if self.expression is None: - raise ValueError("Can not eval with an expression to evaluate") - pass - - - def get_expression(self): - return self.expression - - - def set_expression(self, expression): - self.compiled_expr = self.compile(expression) - self.expression = expression - - - def get_key_list(self): - return self.keyList.keys() - - - def add_key(self, key, var): - self.keyList[key] = var - - - def parse_expression(self, expression): - self.keyList = {} - if expression.count("[") != expression.count("]"): - raise ValueError("Expression:%s invalid - not matching [ and ]" % expression) - - replaceKey = NPVParseKey(self) - parsedExpression = self.sumKeyRE.sub(replaceKey, expression) - return parsedExpression - - - def compile(self, expression): - parsedExpression = self.parseExpression(expression) - self.code = "trange = self.baseCase.timeRange(self.start, self.end, self.interval)\n" - for (key,var) in self.keyList.items(): - self.code += "%s = self.baseCase.blockedProduction(\"%s\", trange)\n" % (var, key) - - self.code += "npv = 0\n" - self.code += """ -for i in range(len(trange) - 1): - npv += %s -varDict[\"npv\"] = npv -""" % parsedExpression - - - - def eval_npv(self): - byteCode = compile(self.code, "", 'exec') - varDict = {} - eval(byteCode) - return varDict["npv"] - - - -monkey_the_camel(NPVPriceVector, 'addItem', NPVPriceVector.add_item) -monkey_the_camel(NPVPriceVector, 'assertDate', NPVPriceVector.assert_date, staticmethod) -monkey_the_camel(NPVPriceVector, 'evalDate', NPVPriceVector.eval_date) - -monkey_the_camel(EclNPV, 'getExpression', EclNPV.get_expression) -monkey_the_camel(EclNPV, 'setExpression', EclNPV.set_expression) -monkey_the_camel(EclNPV, 'getKeyList', EclNPV.get_key_list) -monkey_the_camel(EclNPV, 'addKey', EclNPV.add_key) -monkey_the_camel(EclNPV, 'parseExpression', EclNPV.parse_expression) -monkey_the_camel(EclNPV, 'evalNPV', EclNPV.eval_npv) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py deleted file mode 100644 index 30cf71e9e4..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py +++ /dev/null @@ -1,1054 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_region.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Module used to select cells based on many different criteria. - -This module implements the class EclRegion which can be used to select -cells in a grid matching a criteria. A wide range of different -criteria are supported. Many of the special functions for implementing -mathematical operations are implemented, so that regions can be -combined e.g. with logical &. - -When the selection process is complete the region instance can be -queried for the corresponding list of indices. -""" -import ctypes - -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.util import IntVector - -from ecl.ecl.faults import Layer -from ecl.ecl import EclKW, EclDataType, EclPrototype -from ecl.geo import CPolyline - - -def select_method(select): - """ - The select_method method decorator is applied to all the - select_xxx() methods. The purpose of this decorator is to - allow the select_xxx() methods to have an optional argument - @intersect. If the @intersect argument is True the results of - the current select method will be and'ed with the current - selection, instead of or'ed which is the default. - - Consider this example: - - region = EclRegion( grid , False ) - region.select_islice(0 , 5) # Selects all cells with i:[0:5] - region.select_jslice(0 , 5) # Selects all cells with j:[0:5] - - When these two calls have completed selection will contain all - the cells which are either in i-interval [0:5] or in - j-interval [0:5]. If we supply the @intersect argument in the - second call the j selection will only be applied to the cells - in i:[0:5] interval: - - region = EclRegion( grid , False ) - region.select_islice(0 , 5) # Selects all cells with i:[0:5] - region.select_jslice(0 , 5) # Selects all cells with j:[0:5] AND i:[0:5] - """ - - def select_wrapper(self , *args , **kwargs): - intersect = kwargs.has_key('intersect') and kwargs['intersect'] - if intersect: - new_region = EclRegion( self.grid , False ) - select(new_region , *args ) - - self &= new_region - else: - select(self , *args ) - - return select_wrapper - -class EclRegion(BaseCClass): - TYPE_NAME = "ecl_region" - _alloc = EclPrototype("void* ecl_region_alloc( ecl_grid , bool )", bind = False) - _alloc_copy = EclPrototype("ecl_region_obj ecl_region_alloc_copy( ecl_region )") - - _set_kw_int = EclPrototype("void ecl_region_set_kw_int( ecl_region , ecl_kw , int, bool) ") - _set_kw_float = EclPrototype("void ecl_region_set_kw_float( ecl_region , ecl_kw , float, bool ) ") - _set_kw_double = EclPrototype("void ecl_region_set_kw_double( ecl_region , ecl_kw , double , bool) ") - _shift_kw_int = EclPrototype("void ecl_region_shift_kw_int( ecl_region , ecl_kw , int, bool) ") - _shift_kw_float = EclPrototype("void ecl_region_shift_kw_float( ecl_region , ecl_kw , float, bool ) ") - _shift_kw_double = EclPrototype("void ecl_region_shift_kw_double( ecl_region , ecl_kw , double , bool) ") - _scale_kw_int = EclPrototype("void ecl_region_scale_kw_int( ecl_region , ecl_kw , int, bool) ") - _scale_kw_float = EclPrototype("void ecl_region_scale_kw_float( ecl_region , ecl_kw , float, bool ) ") - _scale_kw_double = EclPrototype("void ecl_region_scale_kw_double( ecl_region , ecl_kw , double , bool) ") - _sum_kw_int = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ") - _sum_kw_float = EclPrototype("float ecl_region_sum_kw_float( ecl_region , ecl_kw , bool ) ") - _sum_kw_double = EclPrototype("double ecl_region_sum_kw_double( ecl_region , ecl_kw , bool) ") - _sum_kw_bool = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ") - - _free = EclPrototype("void ecl_region_free( ecl_region )") - _reset = EclPrototype("void ecl_region_reset( ecl_region )") - _select_all = EclPrototype("void ecl_region_select_all( ecl_region )") - _deselect_all = EclPrototype("void ecl_region_deselect_all( ecl_region )") - _select_equal = EclPrototype("void ecl_region_select_equal( ecl_region , ecl_kw , int )") - _deselect_equal = EclPrototype("void ecl_region_deselect_equal( ecl_region , ecl_kw , int)") - _select_less = EclPrototype("void ecl_region_select_smaller( ecl_region , ecl_kw , float )") - _deselect_less = EclPrototype("void ecl_region_deselect_smaller( ecl_region , ecl_kw , float )") - _select_more = EclPrototype("void ecl_region_select_larger( ecl_region , ecl_kw , float )") - _deselect_more = EclPrototype("void ecl_region_deselect_larger( ecl_region , ecl_kw , float )") - _select_in_interval = EclPrototype("void ecl_region_select_in_interval( ecl_region, ecl_kw , float , float )") - _deselect_in_interval = EclPrototype("void ecl_region_deselect_in_interval( ecl_region, ecl_kw, float , float )") - _invert_selection = EclPrototype("void ecl_region_invert_selection( ecl_region )") - - _select_box = EclPrototype("void ecl_region_select_from_ijkbox(ecl_region , int , int , int , int , int , int)") - _deselect_box = EclPrototype("void ecl_region_deselect_from_ijkbox(ecl_region , int , int , int , int , int , int)") - _imul_kw = EclPrototype("void ecl_region_kw_imul( ecl_region , ecl_kw , ecl_kw , bool)") - _idiv_kw = EclPrototype("void ecl_region_kw_idiv( ecl_region , ecl_kw , ecl_kw , bool)") - _iadd_kw = EclPrototype("void ecl_region_kw_iadd( ecl_region , ecl_kw , ecl_kw , bool)") - _isub_kw = EclPrototype("void ecl_region_kw_isub( ecl_region , ecl_kw , ecl_kw , bool)") - _copy_kw = EclPrototype("void ecl_region_kw_copy( ecl_region , ecl_kw , ecl_kw , bool)") - _intersect = EclPrototype("void ecl_region_intersection( ecl_region , ecl_region )") - _combine = EclPrototype("void ecl_region_union( ecl_region , ecl_region )") - _subtract = EclPrototype("void ecl_region_subtract( ecl_region , ecl_region )") - _xor = EclPrototype("void ecl_region_xor( ecl_region , ecl_region )") - _get_kw_index_list = EclPrototype("int_vector_ref ecl_region_get_kw_index_list( ecl_region , ecl_kw , bool )") - _get_active_list = EclPrototype("int_vector_ref ecl_region_get_active_list( ecl_region )") - _get_global_list = EclPrototype("int_vector_ref ecl_region_get_global_list( ecl_region )") - _get_active_global = EclPrototype("int_vector_ref ecl_region_get_global_active_list( ecl_region )") - _select_cmp_less = EclPrototype("void ecl_region_cmp_select_less( ecl_region , ecl_kw , ecl_kw)") - _select_cmp_more = EclPrototype("void ecl_region_cmp_select_more( ecl_region , ecl_kw , ecl_kw)") - _deselect_cmp_less = EclPrototype("void ecl_region_cmp_deselect_less( ecl_region , ecl_kw , ecl_kw)") - _deselect_cmp_more = EclPrototype("void ecl_region_cmp_deselect_more( ecl_region , ecl_kw , ecl_kw)") - _select_islice = EclPrototype("void ecl_region_select_i1i2( ecl_region , int , int )") - _deselect_islice = EclPrototype("void ecl_region_deselect_i1i2( ecl_region , int , int )") - _select_jslice = EclPrototype("void ecl_region_select_j1j2( ecl_region , int , int )") - _deselect_jslice = EclPrototype("void ecl_region_deselect_j1j2( ecl_region , int , int )") - _select_kslice = EclPrototype("void ecl_region_select_k1k2( ecl_region , int , int )") - _deselect_kslice = EclPrototype("void ecl_region_deselect_k1k2( ecl_region , int , int )") - _select_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )") - _deselect_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )") - _select_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )") - _deselect_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )") - _select_small = EclPrototype("void ecl_region_select_small_cells( ecl_region , double )") - _deselect_small = EclPrototype("void ecl_region_deselect_small_cells( ecl_region , double )") - _select_large = EclPrototype("void ecl_region_select_large_cells( ecl_region , double )") - _deselect_large = EclPrototype("void ecl_region_deselect_large_cells( ecl_region , double )") - _select_thin = EclPrototype("void ecl_region_select_thin_cells( ecl_region , double )") - _deselect_thin = EclPrototype("void ecl_region_deselect_thin_cells( ecl_region , double )") - _select_thick = EclPrototype("void ecl_region_select_thick_cells( ecl_region , double )") - _deselect_thick = EclPrototype("void ecl_region_deselect_thick_cells( ecl_region , double )") - _select_active = EclPrototype("void ecl_region_select_active_cells( ecl_region )") - _select_inactive = EclPrototype("void ecl_region_select_inactive_cells( ecl_region )") - _deselect_active = EclPrototype("void ecl_region_deselect_active_cells( ecl_region )") - _deselect_inactive = EclPrototype("void ecl_region_deselect_inactive_cells( ecl_region )") - _select_above_plane = EclPrototype("void ecl_region_select_above_plane( ecl_region , double* , double* )") - _select_below_plane = EclPrototype("void ecl_region_select_below_plane( ecl_region , double* , double* )") - _deselect_above_plane = EclPrototype("void ecl_region_deselect_above_plane( ecl_region, double* , double* )") - _deselect_below_plane = EclPrototype("void ecl_region_deselect_below_plane( ecl_region, double* , double* )") - _select_inside_polygon = EclPrototype("void ecl_region_select_inside_polygon( ecl_region , geo_polygon)") - _select_outside_polygon = EclPrototype("void ecl_region_select_outside_polygon( ecl_region , geo_polygon)") - _deselect_inside_polygon = EclPrototype("void ecl_region_deselect_inside_polygon( ecl_region , geo_polygon)") - _deselect_outside_polygon = EclPrototype("void ecl_region_deselect_outside_polygon( ecl_region , geo_polygon)") - _set_name = EclPrototype("void ecl_region_set_name( ecl_region , char*)") - _get_name = EclPrototype("char* ecl_region_get_name( ecl_region )") - _contains_ijk = EclPrototype("void ecl_region_contains_ijk( ecl_region , int , int , int)") - _contains_global = EclPrototype("void ecl_region_contains_global( ecl_region, int )") - _contains_active = EclPrototype("void ecl_region_contains_active( ecl_region , int )") - _equal = EclPrototype("bool ecl_region_equal( ecl_region , ecl_region )") - _select_true = EclPrototype("void ecl_region_select_true( ecl_region , ecl_kw)") - _select_false = EclPrototype("void ecl_region_select_false( ecl_region , ecl_kw)") - _deselect_true = EclPrototype("void ecl_region_deselect_true( ecl_region , ecl_kw)") - _deselect_false = EclPrototype("void ecl_region_deselect_false( ecl_region , ecl_kw)") - _select_from_layer = EclPrototype("void ecl_region_select_from_layer( ecl_region , layer , int , int)") - _deselect_from_layer = EclPrototype("void ecl_region_deselect_from_layer( ecl_region , layer , int , int)") - - - def __init__(self , grid , preselect): - """ - Create a new region selector for cells in @grid. - - Will create a new region selector to select and deselect the - cells in the grid given by @grid. The input argument @grid - should be a EclGrid instance. You can start with either all - cells, or no cells, selected, depending on the value of - @preselect. - """ - - self.grid = grid - self.active_index = False - c_ptr = self._alloc( grid , preselect ) - super(EclRegion , self).__init__( c_ptr ) - - - def free(self): - self._free( ) - - - def __eq__(self , other): - return self._equal(other) - - def __hash__(self): - return hash(hash(self.grid) + hash(self.active_index)) - - - def __deep_copy__(self , memo): - """ - Creates a deep copy of the current region. - """ - return self._alloc_copy( ) - - - def __nonzero__(self): - global_list = self.get_global_list() - return len(global_list) > 0 - - - def __iand__(self , other): - """ - Will perform set intersection operation inplace. - - Will update the current region selection so that the elements - selected in self are also selected in @other. Bound to the - inplace & operator, i.e. - - reg1 &= reg2 - - will eventually call this method. - """ - if isinstance(other , EclRegion): - self._intersect( other) - else: - raise TypeError("Ecl region can only intersect with other EclRegion instances") - - return self - - - def __isub__(self , other): - """ - Inplace "subtract" one selection from another. - - Bound to reg -= reg2 - """ - if isinstance( other , EclRegion ): - self._subtract( other) - else: - raise TypeError("Ecl region can only subtract with other EclRegion instances") - - return self - - - def __ior__(self , other): - """ - Will perform set operation union in place. - - The current region selection will be updated to contain all - the elements which are selected either in the current region, - or in @other; bound to to inplace | operator, so you can write e.g. - - reg1 |= reg2 - - to update reg1 with the selections from reg2. - """ - if isinstance( other , EclRegion): - self._combine( other) - else: - raise TypeError("Ecl region can only be combined with other EclRegion instances") - - return self - - def __iadd__(self , other): - """ - Combines to regions - see __ior__(). - """ - return self.__ior__( other ) - - def __or__(self , other): - """ - Creates a new region which is the union of @self and other. - - The method will create a new region which selection status is - given by the logical or of regions @self and @other; the two - initial regions will not be modified. Bound to the unary | - operator: - - new_reg = reg1 | reg2 - - """ - new_region = self.copy() - new_region.__ior__( other ) - return new_region - - def __and__(self , other): - """ - Creates a new region which is the intersection of @self and other. - - The method will create a new region which selection status is - given by the logical and of regions @self and @other; the two - initial regions will not be modified. Bound to the unary & - operator: - - new_reg = reg1 & reg2 - """ - new_region = self.copy() - new_region.__iand__( other ) - return new_region - - def __add__(self , other): - """ - Unary add operator for two regions - implemented by __or__(). - """ - return self.__or__( other ) - - - def __sub__( self, other): - """ - Unary del operator for two regions. - """ - new_region = self.copy() - new_region.__isub__( other ) - return new_region - - - def union_with( self, other): - """ - Will update self with the union of @self and @other. - - See doscumentation of __ior__(). - """ - return self.__ior__( other ) - - def intersect_with( self, other): - """ - Will update self with the intersection of @self and @other. - - See doscumentation of __iand__(). - """ - return self.__iand__( other ) - - - def copy( self ): - return self.__deep_copy__( {} ) - - def reset(self): - """ - Clear selections according to constructor argument @preselect. - - Will clear all selections, depending on the value of the - constructor argument @preselect. If @preselect is true - everything will be selected after calling reset(), otherwise - no cells will be selected after calling reset(). - """ - self._reset( ) - - ################################################################## - - - @select_method - def select_more( self , ecl_kw , limit , intersect = False): - """ - Select all cells where keyword @ecl_kw is above @limit. - - This method is used to select all the cells where an arbitrary - field, contained in @ecl_kw, is above a limiting value - @limit. The EclKW instance must have either nactive or - nx*ny*nz elements; if this is not satisfied method will fail - hard. The datatype of @ecl_kw must be numeric, - i.e. ECL_INT_TYPE, ECL_DOUBLE_TYPE or ECL_FLOAT_TYPE. In the - example below we select all the cells with water saturation - above 0.85: - - restart_file = ecl.EclFile( "ECLIPSE.X0067" ) - swat_kw = restart_file["SWAT"][0] - grid = ecl.EclGrid( "ECLIPSE.EGRID" ) - region = ecl.EclRegion( grid , False ) - - region.select_more( swat_kw , 0.85 ) - - """ - self._select_more( ecl_kw , limit ) - - - - def deselect_more( self , ecl_kw , limit): - """ - Deselects cells with value above limit. - - See select_more() for further documentation. - """ - self._deselect_more( ecl_kw , limit ) - - @select_method - def select_less( self , ecl_kw , limit , intersect = False): - """ - Select all cells where keyword @ecl_kw is below @limit. - - See select_more() for further documentation. - """ - self._select_less( ecl_kw , limit ) - - def deselect_less( self , ecl_kw , limit): - """ - Deselect all cells where keyword @ecl_kw is below @limit. - - See select_more() for further documentation. - """ - self._deselect_less( ecl_kw , limit ) - - @select_method - def select_equal( self , ecl_kw , value , intersect = False): - """ - Select all cells where @ecl_kw is equal to @value. - - The EclKW instance @ecl_kw must be of size nactive or - nx*ny*nz, and it must be of integer type; testing for equality - is not supported for floating point numbers. In the example - below we select all the cells in PVT regions 2 and 4: - - init_file = ecl.EclFile( "ECLIPSE.INIT" ) - pvtnum_kw = init_file.iget_named_kw( "PVTNUM" , 0 ) - grid = ecl.EclGrid( "ECLIPSE.GRID" ) - region = ecl.EclRegion( grid , False ) - - region.select_equal( pvtnum_kw , 2 ) - region.select_equal( pvtnum_kw , 4 ) - - """ - if not ecl_kw.data_type.is_int(): - raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( )) - self._select_equal( ecl_kw , value ) - - - def deselect_equal( self , ecl_kw , value ): - """ - Select all cells where @ecl_kw is equal to @value. - - See select_equal() for further documentation. - """ - if not ecl_kw.data_type.is_int(): - raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( )) - self._deselect_equal( ecl_kw , value ) - - @select_method - def select_in_range( self , ecl_kw , lower_limit , upper_limit , select = False): - """ - Select all cells where @ecl_kw is in the half-open interval [ , ). - - Will select all the cells where EclKW instance @ecl_kw has - value in the half-open interval [@lower_limit , - @upper_limit). The input argument @ecl_kw must have size - nactive or nx*ny*nz, and it must be of type ECL_FLOAT_TYPE. - - The following example will select all cells with porosity in - the range [0.15,0.20): - - init_file = ecl.EclFile( "ECLIPSE.INIT" ) - poro_kw = init_file.iget_named_kw( "PORO" , 0 ) - grid = ecl.EclGrid( "ECLIPSE.GRID" ) - region = ecl.EclRegion( grid , False ) - - region.select_in_range( poro_kw , 0.15, 0.20 ) - - """ - self._select_in_interval( ecl_kw , lower_limit , upper_limit) - - def deselect_in_range( self , ecl_kw , lower_limit , upper_limit): - """ - Deselect all cells where @ecl_kw is in the half-open interval [ , ). - - See select_in_range() for further documentation. - """ - self._deselect_in_interval( ecl_kw , lower_limit , upper_limit) - - - @select_method - def select_cmp_less( self , kw1 , kw2 , intersect = False): - """ - Will select all cells where kw2 < kw1. - - Will compare the ECLIPSE keywords @kw1 and @kw2, and select - all the cells where the numerical value of @kw1 is less than - the numerical value of @kw2. The ECLIPSE keywords @kw1 and - @kw2 must both be of the same size, nactive or nx*ny*nz. In - addition they must both be of type type ECL_FLOAT_TYPE. In the - example below we select all the cells where the pressure has - dropped: - - restart_file = ecl.EclFile("ECLIPSE.UNRST") - pressure1 = restart_file.iget_named_kw( "PRESSURE" , 0) - pressure2 = restart_file.iget_named_kw( "PRESSURE" , 100) - - region.select_cmp_less( pressure2 , pressure1) - - """ - self._select_cmp_less( kw1 , kw2 ) - - def deselect_cmp_less( self , kw1 , kw2): - """ - Will deselect all cells where kw2 < kw1. - - See select_cmp_less() for further documentation. - """ - self._deselect_cmp_less( kw1 , kw2 ) - - @select_method - def select_cmp_more( self , kw1 , kw2 , intersect = False): - """ - Will select all cells where kw2 > kw1. - - See select_cmp_less() for further documentation. - """ - self._select_cmp_more( kw1 , kw2 ) - - def deselect_cmp_more( self , kw1 , kw2): - """ - Will deselect all cells where kw2 > kw1. - - See select_cmp_less() for further documentation. - """ - self._deselect_cmp_more( kw1 , kw2 ) - - @select_method - def select_active( self , intersect = False): - """ - Will select all the active grid cells. - """ - self._select_active( ) - - def deselect_active( self ): - """ - Will deselect all the active grid cells. - """ - self._deselect_active( ) - - @select_method - def select_inactive( self , intersect = False): - """ - Will select all the inactive grid cells. - """ - self._select_inactive( ) - - - def deselect_inactive( self ): - """ - Will deselect all the inactive grid cells. - """ - self._deselect_inactive( ) - - - def select_all( self ): - """ - Will select all the cells. - """ - self._select_all( ) - - def deselect_all( self ): - """ - Will deselect all the cells. - """ - self._deselect_all( ) - - def clear( self ): - """ - Will deselect all cells. - """ - self.deselect_all() - - @select_method - def select_deep( self , depth , intersect = False): - """ - Will select all cells below @depth. - """ - self._select_deep_cells(depth) - - def deselect_deep( self, depth): - """ - Will deselect all cells below @depth. - """ - self._deselect_deep_cells(depth) - - @select_method - def select_shallow( self, depth , intersect = False): - """ - Will select all cells above @depth. - """ - self._select_shallow_cells(depth) - - def deselect_shallow( self, depth): - """ - Will deselect all cells above @depth. - """ - self._deselect_shallow_cells(depth) - - @select_method - def select_small( self , size_limit , intersect = False): - """ - Will select all cells smaller than @size_limit. - """ - self._select_small( size_limit ) - - def deselect_small( self , size_limit ): - """ - Will deselect all cells smaller than @size_limit. - """ - self._deselect_small( size_limit ) - - @select_method - def select_large( self , size_limit , intersect = False): - """ - Will select all cells larger than @size_limit. - """ - self._select_large( size_limit ) - - def deselect_large( self , size_limit ): - """ - Will deselect all cells larger than @size_limit. - """ - self._deselect_large( size_limit ) - - @select_method - def select_thin( self , size_limit , intersect = False): - """ - Will select all cells thinner than @size_limit. - """ - self._select_thin( size_limit ) - - def deselect_thin( self , size_limit ): - """ - Will deselect all cells thinner than @size_limit. - """ - self._deselect_thin( size_limit ) - - @select_method - def select_thick( self , size_limit , intersect = False): - """ - Will select all cells thicker than @size_limit. - """ - self._select_thick( size_limit ) - - def deselect_thick( self , size_limit ): - """ - Will deselect all cells thicker than @size_limit. - """ - self._deselect_thick( size_limit ) - - @select_method - def select_box( self , ijk1 , ijk2 , intersect = False): - """ - Will select all cells in box. - - Will select all the the cells in the box given by @ijk1 and - @ijk2. The two arguments @ijk1 and @ijk2 are tuples (1,j,k) - representing two arbitrary - diagonally opposed corners - of a - box. All the elements in @ijk1 and @ijk2 are inclusive, i.e. - - select_box( (10,12,8) , (8 , 16,4) ) - - will select the box defined by [8,10] x [12,16] x [4,8]. - """ - self._select_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2]) - - def deselect_box( self , ijk1 , ijk2 ): - """ - Will deselect all elements in box. - - See select_box() for further documentation. - """ - self._deselect_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2]) - - @select_method - def select_islice( self , i1 , i2, intersect = False): - """ - Will select all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset. - """ - self._select_islice( i1,i2) - - def deselect_islice( self , i1 , i2): - """ - Will deselect all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset. - """ - self._deselect_islice( i1,i2) - - @select_method - def select_jslice( self , j1 , j2 , intersect = False): - """ - Will select all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset. - """ - self._select_jslice( j1,j2) - - def deselect_jslice( self , j1 , j2): - """ - Will deselect all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset. - """ - self._deselect_jslice( j1,j2) - - @select_method - def select_kslice( self , k1 , k2 , intersect = False): - """ - Will select all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset. - """ - self._select_kslice( k1,k2) - - def deselect_kslice( self , k1 , k2): - """ - Will deselect all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset. - """ - self._deselect_kslice( k1,k2) - - def invert( self ): - """ - Will invert the current selection. - """ - self._invert_selection( ) - - def __init_plane_select( self , n , p ): - n_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double )) - p_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double )) - for i in range(3): - n_vec[i] = n[i] - p_vec[i] = p[i] - return ( n_vec , p_vec ) - - @select_method - def select_above_plane( self , n , p , intersect = False): - """ - Will select all the cells 'above' the plane defined by n & p. - - @n is the surface normal vector of the plane in question and - @p is a point on the plane surface. The point @p should be - given in (utm_x , utm_y , tvd) coordinates. The term 'above' - means that the cell center has a positive distance to the - plain; correspondingly 'below' means that the cell center has - a negative disatnce to the plane. - """ - (n_vec , p_vec) = self.__init_plane_select( n , p ) - self._select_above_plane( n_vec , p_vec ) - - @select_method - def select_below_plane( self , n , p , interscet = False): - """ - Will select all the cells 'below' the plane defined by n & p. - - See method 'select_above_plane' for further documentation. - """ - (n_vec , p_vec) = self.__init_plane_select( n , p ) - self._select_below_plane( n_vec , p_vec ) - - def deselect_above_plane( self , n , p): - """ - Will deselect all the cells 'above' the plane defined by n & p. - - See method 'select_above_plane' for further documentation. - """ - (n_vec , p_vec) = self.__init_plane_select( n , p ) - self._deselect_above_plane( n_vec , p_vec ) - - def deselect_below_plane( self , n , p): - """ - Will deselect all the cells 'below' the plane defined by n & p. - - See method 'select_above_plane' for further documentation. - """ - (n_vec , p_vec) = self.__init_plane_select( n , p ) - self._deselect_below_plane( n_vec , p_vec ) - - @select_method - def select_inside_polygon( self , points , intersect = False): - """ - Will select all points inside polygon. - - Will select all points inside polygon specified by input - variable @points. Points should be a list of two-element - tuples (x,y). So to select all the points within the rectangle - bounded by the lower left rectangle (0,0) and upper right - (100,100) the @points list should be: - - points = [(0,0) , (0,100) , (100,100) , (100,0)] - - The elements in the points list should be (utm_x, utm_y) - values. These values will be compared with the centerpoints of - the cells in the grid. The selection is based the top k=0 - layer, and then extending this selection to all k values; this - implies that the selection polygon will effectively be - translated if the pillars are not vertical. - """ - self._select_inside_polygon( CPolyline( init_points = points )) - - @select_method - def select_outside_polygon( self , points , intersect = False): - """ - Will select all points outside polygon. - - See select_inside_polygon for more docuemntation. - """ - self._select_outside_polygon( CPolyline( init_points = points )) - - def deselect_inside_polygon( self , points ): - """ - Will select all points outside polygon. - - See select_inside_polygon for more docuemntation. - """ - self._deselect_inside_polygon( CPolyline( init_points = points )) - - def deselect_outside_polygon( self , points ): - """ - Will select all points outside polygon. - - See select_inside_polygon for more docuemntation. - """ - self._deselect_outside_polygon( CPolyline( init_points = points )) - - - @select_method - def select_true( self , ecl_kw , intersect = False): - """ - Assume that input ecl_kw is a boolean mask. - """ - self._select_true( ecl_kw ) - - - @select_method - def select_false( self , ecl_kw , intersect = False): - """ - Assume that input ecl_kw is a boolean mask. - """ - self._select_false( ecl_kw ) - - - @select_method - def select_from_layer(self , layer , k , value, intersect = False): - """Will select all the cells in in @layer with value @value - at - vertical coordinate @k. - - The input @layer should be of type Layer - from the - ecl.ecl.faults.layer module. The k value must in the range - [0,grid.nz) and the dimensions of the layer must correspond - exactly to nx,ny of the grid. - """ - grid = self.grid - if k < 0 or k >= grid.getNZ(): - raise ValueError("Invalid k value:%d - must be in range [0,%d)" % (k , grid.getNZ())) - - if grid.getNX() != layer.getNX(): - raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX() , layer.getNX())) - - if grid.getNY() != layer.getNY(): - raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY() , layer.getNY())) - - self._select_from_layer( layer , k , value ) - - - - ################################################################# - - def scalar_apply_kw( self , target_kw , scalar , func_dict , force_active = False): - - """ - Helper function to apply a function with one scalar arg on target_kw. - """ - data_type = target_kw.data_type - if func_dict.has_key( data_type ): - func = func_dict[ data_type ] - func( target_kw, scalar , force_active ) - else: - raise Exception("scalar_apply_kw() only supported for INT/FLOAT/DOUBLE") - - def iadd_kw( self , target_kw , delta_kw , force_active = False): - """ - The functions iadd_kw(), copy_kw(), set_kw(), scale_kw() and - shift_kw() are not meant to be used as methods of the - EclRegion class (altough that is of course perfectly OK) - - rather a EclRegion instance is passed as an argument to an - EclKW method, and then that method "flips things around" and - calls one of these methods with the EclKW instance as - argument. This applies to all the EclKW methods which take an - optional "mask" argument. - """ - if isinstance(delta_kw , EclKW): - if target_kw.assert_binary( delta_kw ): - self._iadd_kw( target_kw , delta_kw , force_active ) - else: - raise TypeError("Type mismatch") - else: - self.shift_kw( target_kw , delta_kw , force_active = force_active) - - - def shift_kw( self , ecl_kw , shift , force_active = False): - """ - See usage documentation on iadd_kw(). - """ - self.scalar_apply_kw( ecl_kw , shift , {EclDataType.ECL_INT : self._shift_kw_int, - EclDataType.ECL_FLOAT : self._shift_kw_float , - EclDataType.ECL_DOUBLE : self._shift_kw_double} , force_active) - - def isub_kw( self , target_kw , delta_kw , force_active = False): - if isinstance(delta_kw , EclKW): - if target_kw.assert_binary( delta_kw ): - self._isub_kw( target_kw , delta_kw , force_active ) - else: - raise TypeError("Type mismatch") - else: - self.shift_kw( target_kw , -delta_kw , force_active = force_active) - - - def scale_kw( self , ecl_kw , scale , force_active = False): - """ - See usage documentation on iadd_kw(). - """ - self.scalar_apply_kw( ecl_kw , scale , {EclDataType.ECL_INT : self._scale_kw_int, - EclDataType.ECL_FLOAT : self._scale_kw_float , - EclDataType.ECL_DOUBLE : self._scale_kw_double} , force_active) - - def imul_kw(self, target_kw , other , force_active = False): - if isinstance(other , EclKW): - if target_kw.assert_binary( other): - self._imul_kw( target_kw , other ) - else: - raise TypeError("Type mismatch") - else: - self.scale_kw( target_kw , other , force_active ) - - - def idiv_kw( self , target_kw , other , force_active = False): - if isinstance(other , EclKW): - if target_kw.assert_binary( other): - self._idiv_kw( target_kw , other ) - else: - raise TypeError("Type mismatch") - else: - self.scale_kw( target_kw , 1/other , force_active ) - - - def copy_kw( self , target_kw , src_kw , force_active = False): - """ - See usage documentation on iadd_kw(). - """ - if target_kw.assert_binary( src_kw ): - self._copy_kw( target_kw , src_kw , force_active ) - else: - raise TypeError("Type mismatch") - - def set_kw( self , ecl_kw , value , force_active = False): - """ - See usage documentation on iadd_kw(). - """ - self.scalar_apply_kw( ecl_kw , value , {EclDataType.ECL_INT : self._set_kw_int, - EclDataType.ECL_FLOAT : self._set_kw_float , - EclDataType.ECL_DOUBLE : self._set_kw_double} , force_active) - - - def sum_kw(self, kw, force_active = False): - data_type = kw.data_type - if data_type == EclDataType.ECL_FLOAT: - return self._sum_kw_float( kw, force_active ) - - if data_type == EclDataType.ECL_INT: - return self._sum_kw_int( kw, force_active ) - - if data_type == EclDataType.ECL_DOUBLE: - return self._sum_kw_double( kw, force_active ) - - if data_type == EclDataType.ECL_BOOL: - return self._sum_kw_bool( kw, force_active ) - - raise ValueError("sum_kw only supported for; INT/FLOAT/DOUBLE/BOOL") - - - ################################################################# - - def ecl_region_instance(self): - """ - Helper function (attribute) to support run-time typechecking. - """ - return True - - - def active_size(self): - return len(self._get_active_list()) - - - def global_size(self): - return len(self._get_global_list()) - - - def get_active_list(self): - """ - IntVector instance with active indices in the region. - """ - active_list = self._get_active_list() - active_list.setParent(self) - return active_list - - - def get_global_list(self): - """ - IntVector instance with global indices in the region. - """ - global_list = self._get_global_list() - global_list.setParent(self) - return global_list - - - def get_ijk_list(self): - """ - WIll return a Python list of (ij,k) tuples for the region. - """ - global_list = self.getGlobalList() - ijk_list = [] - for g in global_list: - ijk_list.append( self.grid.get_ijk( global_index = g ) ) - - return ijk_list - - def contains_ijk( self , i,j,k): - """ - Will check if the cell given by i,j,k is part of the region. - """ - return self._contains_ijk( i , j , k ) - - - def contains_global( self , global_index): - """ - Will check if the cell given by @global_index is part of the region. - """ - return self._contains_global( global_index ) - - - def contains_active( self , active_index): - """ - Will check if the cell given by @active_index is part of the region. - """ - return self._contains_active( active_index ) - - - def kw_index_list(self , ecl_kw , force_active): - c_ptr = self._get_kw_index_list( ecl_kw , force_active) - index_list = IntVector.createCReference( c_ptr, self ) - return index_list - - @property - def name(self): - return self._get_name() - - def get_name(self): - return self._get_name( ) - - def set_name(self , name): - self._set_name( name ) - -monkey_the_camel(EclRegion, 'selectTrue', EclRegion.select_true) -monkey_the_camel(EclRegion, 'selectFalse', EclRegion.select_false) -monkey_the_camel(EclRegion, 'selectFromLayer', EclRegion.select_from_layer) -monkey_the_camel(EclRegion, 'getActiveList', EclRegion.get_active_list) -monkey_the_camel(EclRegion, 'getGlobalList', EclRegion.get_global_list) -monkey_the_camel(EclRegion, 'getIJKList', EclRegion.get_ijk_list) -monkey_the_camel(EclRegion, 'getName', EclRegion.get_name) -monkey_the_camel(EclRegion, 'setName', EclRegion.set_name) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py deleted file mode 100644 index 749f1cd912..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'ecl_restart_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype , EclFile, Ecl3DKW , Ecl3DFile, EclFileEnum - -class EclRestartHead(BaseCClass): - TYPE_NAME = "ecl_rsthead" - _alloc = EclPrototype("void* ecl_rsthead_alloc(ecl_file_view , int )", bind = False) - _alloc_from_kw = EclPrototype("void* ecl_rsthead_alloc_from_kw(int , ecl_kw , ecl_kw , ecl_kw )", bind = False) - _free = EclPrototype("void ecl_rsthead_free(ecl_rsthead)") - _get_report_step = EclPrototype("int ecl_rsthead_get_report_step(ecl_rsthead)") - _get_sim_time = EclPrototype("time_t ecl_rsthead_get_sim_time(ecl_rsthead)") - _get_sim_days = EclPrototype("double ecl_rsthead_get_sim_days(ecl_rsthead)") - _get_nxconz = EclPrototype("int ecl_rsthead_get_nxconz(ecl_rsthead)") - _get_ncwmax = EclPrototype("int ecl_rsthead_get_ncwmax(ecl_rsthead)") - - def __init__(self , kw_arg = None , rst_view = None): - if kw_arg is None and rst_view is None: - raise ValueError('Cannot construct EclRestartHead without one of kw_arg and rst_view, both were None!') - - if not kw_arg is None: - report_step , intehead_kw , doubhead_kw , logihead_kw = kw_arg - c_ptr = self._alloc_from_kw( report_step , intehead_kw , doubhead_kw , logihead_kw ) - else: - c_ptr = self._alloc( rst_view , -1 ) - - super(EclRestartHead, self).__init__(c_ptr) - - - def free(self): - self._free( ) - - def get_report_step(self): - return self._get_report_step( ) - - def get_sim_date(self): - ct = CTime( self._get_sim_time( ) ) - return ct.datetime( ) - - def get_sim_days(self): - return self._get_sim_days( ) - - def well_details(self): - return {"NXCONZ" : self._get_nxconz(), - "NCWMAX" : self._get_ncwmax()} - - - - -class EclRestartFile(Ecl3DFile): - - def __init__(self , grid , filename , flags = 0): - """Will open an Eclipse restart file. - - The EclRestartFile class will open an eclipse restart file, in - unified or non unified format. The constructor will infer the - file type based on the filename, and will raise a ValueError - exception if the file type is not ECL_RESTART_FILE or - ECL_UNIFIED_RESTART_FILE. - - The EclRestartFile will use a grid reference to create Ecl3DKw - instances for all the keyword elements which have either - 'nactive' or 'nx*ny*nz' elements. - """ - - file_type , report_step , fmt_file = EclFile.getFileType( filename ) - if not file_type in [EclFileEnum.ECL_RESTART_FILE, EclFileEnum.ECL_UNIFIED_RESTART_FILE]: - raise ValueError('The input filename "%s" does not correspond to a restart file. Please follow the Eclipse naming conventions' - % filename) - - super(EclRestartFile , self).__init__( grid, filename , flags) - self.rst_headers = None - if file_type == EclFileEnum.ECL_RESTART_FILE: - self.is_unified = False - self.report_step = report_step - else: - self.is_unified = True - - - - def unified(self): - """ - Will return True if the file we have opened is unified. - """ - return self.is_unified - - - def assert_headers(self): - if self.rst_headers is None: - self.rst_headers = [] - if self.unified(): - for index in range(self.num_named_kw("SEQNUM")): - self.rst_headers.append( EclRestartHead( rst_view = self.restartView( seqnum_index = index ))) - else: - intehead_kw = self["INTEHEAD"][0] - doubhead_kw = self["DOUBHEAD"][0] - if "LOGIHEAD" in self: - logihead_kw = self["LOGIHEAD"][0] - else: - logihead_kw = None - - self.rst_headers.append( EclRestartHead( kw_arg = (self.report_step , intehead_kw , doubhead_kw , logihead_kw) )) - - - def time_list(self): - """Will return a list of report_step, simulation time and days. - - The return value will be a list tuples. For a unified restart - file with the three report steps {10,15,20} it can look like: - - [ (10, datetime.datetime( 2010 , 1 , 1 , 0 , 0 , 0 ) , 100.0), - (15, datetime.datetime( 2010 , 3 , 1 , 0 , 0 , 0 ) , 160.0), - (20, datetime.datetime( 2010 , 5 , 1 , 0 , 0 , 0 ) , 220.0) ] - - For a non-unified restart file the list will have only one element. - """ - - self.assertHeaders() - time_list = [] - for header in self.rst_headers: - time_list.append( (header.getReportStep() , header.getSimDate( ) , header.getSimDays( )) ) - - return time_list - - - def headers(self): - self.assertHeaders() - return self.rst_headers - - - def get_header(self, index): - self.assertHeaders() - return self.rst_headers[index] - -monkey_the_camel(EclRestartHead, 'getReportStep', EclRestartHead.get_report_step) -monkey_the_camel(EclRestartHead, 'getSimDate', EclRestartHead.get_sim_date) -monkey_the_camel(EclRestartHead, 'getSimDays', EclRestartHead.get_sim_days) - -monkey_the_camel(EclRestartFile, 'assertHeaders', EclRestartFile.assert_headers) -monkey_the_camel(EclRestartFile, 'timeList', EclRestartFile.time_list) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py deleted file mode 100644 index 59dda841cc..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py +++ /dev/null @@ -1,355 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_rft.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Module for loading ECLIPSE RFT files. -""" - -from __future__ import absolute_import, division, print_function, unicode_literals - -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclRFTCell, EclPLTCell, EclPrototype - -class EclRFT(BaseCClass): - """The EclRFT class contains the information for *one* RFT. - - The ECLIPSE RFT file can contain three different types of RFT like - objects which are lumped together; the EclRFTClass is a container - for such objects. The three different object types which can be - found in an RFT file are: - - RFT: This is old-fashioned RFT which contains measurements of - saturations for each of the completed cells. - - PLT: This contains production and flow rates for each phase in - each cell. - - SEGMENT: Not implemented. - - In addition to the measurements specific for RFT and PLT each cell - has coordinates, pressure and depth. - """ - TYPE_NAME = "ecl_rft" - _alloc = EclPrototype("void* ecl_rft_node_alloc_new( char* , char* , time_t , double)" , bind = False) - _free = EclPrototype("void ecl_rft_node_free( ecl_rft )") - _get_type = EclPrototype("int ecl_rft_node_get_type( ecl_rft )") - _get_well = EclPrototype("char* ecl_rft_node_get_well_name( ecl_rft )") - _get_date = EclPrototype("time_t ecl_rft_node_get_date( ecl_rft )") - _get_size = EclPrototype("int ecl_rft_node_get_size( ecl_rft )") - _iget_cell = EclPrototype("void* ecl_rft_node_iget_cell( ecl_rft )") - _iget_cell_sorted = EclPrototype("void* ecl_rft_node_iget_cell_sorted( ecl_rft )") - _sort_cells = EclPrototype("void* ecl_rft_node_inplace_sort_cells( ecl_rft )") - _iget_depth = EclPrototype("double ecl_rft_node_iget_depth( ecl_rft )") - _iget_pressure = EclPrototype("double ecl_rft_node_iget_pressure(ecl_rft)") - _iget_ijk = EclPrototype("void ecl_rft_node_iget_ijk( ecl_rft , int , int*, int*, int*)") - _iget_swat = EclPrototype("double ecl_rft_node_iget_swat(ecl_rft)") - _iget_sgas = EclPrototype("double ecl_rft_node_iget_sgas(ecl_rft)") - _iget_orat = EclPrototype("double ecl_rft_node_iget_orat(ecl_rft)") - _iget_wrat = EclPrototype("double ecl_rft_node_iget_wrat(ecl_rft)") - _iget_grat = EclPrototype("double ecl_rft_node_iget_grat(ecl_rft)") - _lookup_ijk = EclPrototype("void* ecl_rft_node_lookup_ijk( ecl_rft , int , int , int)") - _is_RFT = EclPrototype("bool ecl_rft_node_is_RFT( ecl_rft )") - _is_PLT = EclPrototype("bool ecl_rft_node_is_PLT( ecl_rft )") - _is_SEGMENT = EclPrototype("bool ecl_rft_node_is_SEGMENT( ecl_rft )") - _is_MSW = EclPrototype("bool ecl_rft_node_is_MSW( ecl_rft )") - - - def __init__(self , name , type_string , date , days): - c_ptr = self._alloc( name , type_string , CTime( date ) , days ) - super(EclRFT , self).__init__( c_ptr ) - - - def free(self): - self._free( ) - - def __repr__(self): - rs = [] - rs.append('completed_cells = %d' % len(self)) - rs.append('date = %s' % self.getDate()) - if self.is_RFT(): - rs.append('RFT') - if self.is_PLT(): - rs.append('PLT') - if self.is_SEGMENT(): - rs.append('SEGMENT') - if self.is_MSW(): - rs.append('MSW') - rstr = ', '.join(rs) - return self._create_repr(rstr) - - def __len__(self): - """ - The number of completed cells in this RFT. - """ - return self._get_size( ) - - def is_RFT(self): - """ - Is instance an RFT; in that case all the cells will be EclRFTCell instances. - """ - return self._is_RFT( ) - - def is_PLT(self): - """ - Is instance a PLT; in that case all the cells will be EclPLTCell instances. - """ - return self._is_PLT( ) - - def is_SEGMENT(self): - """ - Is this a SEGMENT - not implemented. - """ - return self._is_SEGMENT( ) - - def is_MSW(self): - """ - Is this well a MSW well. Observe that the test ONLY applies to PLTs. - """ - return self._is_MSW( ) - - - def get_well_name(self): - """ - The name of the well we are considering. - """ - return self._get_well( ) - - def get_date(self): - """ - The date when this RFT/PLT/... was recorded. - """ - ct = CTime(self._get_date( )) - return ct.date() - - def __cell_ref( self , cell_ptr ): - if self.is_RFT(): - return EclRFTCell.createCReference( cell_ptr , self ) - elif self.is_PLT(): - return EclPLTCell.createCReference( cell_ptr , self ) - else: - raise NotImplementedError("Only RFT and PLT cells are implemented") - - - def assert_cell_index( self , index ): - if isinstance( index , int): - length = self.__len__() - if index < 0 or index >= length: - raise IndexError - else: - raise TypeError("Index should be integer type") - - - def __getitem__(self , index): - """Implements the [] operator to return the cells. - - To get the object related to cell nr 5: - - cell = rft[4] - - The return value from the __getitem__() method is either an - EclRFTCell instance or a EclPLTCell instance, depending on the - type of this particular RFT object. - """ - self.assert_cell_index( index ) - cell_ptr = self._iget_cell( index ) - return self.__cell_ref( cell_ptr ) - - - def iget( self , index ): - return self[index] - - - def iget_sorted( self , index ): - """ - Will return the cell nr @index in the list of sorted cells. - - See method sort() for further documentation. - """ - self.assert_cell_index( index ) - cell_ptr = self._iget_cell_sorted( index ) - return self.__cell_ref( cell_ptr ) - - - def sort(self): - """ - Will sort cells in RFT; currently only applies to MSW wells. - - By default the cells in the RFT come in the order they are - specified in the ECLIPSE input file; that is not necessarily - in a suitable order. In the case of MSW wells it is possible - to sort the connections after distance along the wellpath. To - access the cells in sort order you have two options: - - 1. Sort the cells using the sort() method, and then - subsequently access them sequentially: - - rft.sort() - for cell in rft: - print cell - - 2. Let the rft object stay unsorted, but access the cells - using the iget_sorted() method: - - for i in range(len(rft)): - cell = rft.iget_sorted( i ) - - Currently only MSW/PLTs are sorted, based on the CONLENST - keyword; for other wells the sort() method does nothing. - """ - self._sort_cells( ) - - - # ijk are zero offset - def ijkget( self , ijk ): - """ - Will look up the cell based on (i,j,k). - - If the cell (i,j,k) is not part of this RFT/PLT None will be - returned. The (i,j,k) input values should be zero offset, - i.e. you must subtract 1 from the (i,j,k) values given in the ECLIPSE input. - """ - cell_ptr = self._lookup_ijk( ijk[0] , ijk[1] , ijk[2]) - if cell_ptr: - return self.__cell_ref( cell_ptr ) - else: - return None - - - - -class EclRFTFile(BaseCClass): - TYPE_NAME = "ecl_rft_file" - _load = EclPrototype("void* ecl_rft_file_alloc_case( char* )", bind = False) - _iget = EclPrototype("ecl_rft_ref ecl_rft_file_iget_node( ecl_rft_file , int )") - _get_rft = EclPrototype("ecl_rft_ref ecl_rft_file_get_well_time_rft( ecl_rft_file , char* , time_t)") - _has_rft = EclPrototype("bool ecl_rft_file_case_has_rft( char* )", bind = False) - _free = EclPrototype("void ecl_rft_file_free( ecl_rft_file )") - _get_size = EclPrototype("int ecl_rft_file_get_size__( ecl_rft_file , char* , time_t)") - _get_num_wells = EclPrototype("int ecl_rft_file_get_num_wells( ecl_rft_file )") - - - """ - The EclRFTFile class is used to load an ECLIPSE RFT file. - - The EclRFTFile serves as a container which can load and hold the - content of an ECLIPSE RFT file. The RFT files will in general - contain data for several wells and several times in one large - container. The EclRFTClass class contains methods get the the RFT - results for a specific time and/or well. - - The EclRFTFile class can in general contain a mix of RFT and PLT - measurements. The class does not really differentiate between - these. - """ - - def __init__(self , case): - c_ptr = self._load( case ) - super(EclRFTFile , self).__init__(c_ptr) - - - def __len__(self): - return self._get_size( None , CTime(-1)) - - - def __getitem__(self, index): - if isinstance(index, int): - if 0 <= index < len(self): - rft = self._iget(index) - rft.setParent( self ) - return rft - else: - raise IndexError("Index '%d' must be in range: [0, %d]" % (index, len(self) - 1)) - else: - raise TypeError("Index must be integer type") - - - def size(self, well=None, date=None): - """ - The number of elements in EclRFTFile container. - - By default the size() method will return the total number of - RFTs/PLTs in the container, but by specifying the optional - arguments date and/or well the function will only count the - number of well measurements matching that time or well - name. The well argument can contain wildcards. - - rftFile = ecl.EclRFTFile( "ECLIPSE.RFT" ) - print "Total number of RFTs : %d" % rftFile.size( ) - print "RFTs matching OP* : %d" % rftFile.size( well = "OP*" ) - print "RFTs at 01/01/2010 : %d" % rftFile.size( date = datetime.date( 2010 , 1 , 1 )) - - """ - if date: - cdate = CTime( date ) - else: - cdate = CTime( -1 ) - - return self._get_size( well , cdate) - - - def get_num_wells(self): - """ - Returns the total number of distinct wells in the RFT file. - """ - return self._get_num_wells( ) - - - def get_headers(self): - """ - Returns a list of two tuples (well_name , date) for the whole file. - """ - header_list = [] - for i in (range(self._get_size( None , CTime(-1)))): - rft = self.iget( i ) - header_list.append( (rft.getWellName() , rft.getDate()) ) - return header_list - - - def iget(self , index): - """ - Will lookup RFT @index - equivalent to [@index]. - """ - return self[index] - - - def get(self , well_name , date ): - """ - Will look up the RFT object corresponding to @well and @date. - - Raise Exception if not found. - """ - if self.size( well = well_name , date = date) == 0: - raise KeyError("No RFT for well:%s at %s" % (well_name , date)) - - rft = self._get_rft( well_name , CTime( date )) - rft.setParent( self ) - return rft - - def free(self): - self._free( ) - - def __repr__(self): - w = len(self) - return self._create_repr('wells = %d' % w) - - -monkey_the_camel(EclRFT, 'getWellName', EclRFT.get_well_name) -monkey_the_camel(EclRFT, 'getDate', EclRFT.get_date) - -monkey_the_camel(EclRFTFile, 'getNumWells', EclRFTFile.get_num_wells) -monkey_the_camel(EclRFTFile, 'getHeaders', EclRFTFile.get_headers) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py deleted file mode 100644 index c875d1f52f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py +++ /dev/null @@ -1,171 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass -from ecl.ecl import EclPrototype - - -class RFTCell(BaseCClass): - """The RFTCell is a base class for the cells which are part of an RFT/PLT. - - The RFTCell class contains the elements which are common to both - RFT and PLT. The list of common elements include the corrdinates - (i,j,k) the pressure and the depth of the cell. Actual user access - should be based on the derived classes EclRFTCell and EclPLTCell. - - Observe that from june 2013 the properties i,j and k which return - offset 1 coordinate values are deprecated, and you should rather - use the methods get_i(), get_j() and get_k() which return offset 0 - coordinate values. - """ - TYPE_NAME = "rft_cell" - _free = EclPrototype("void ecl_rft_cell_free(rft_cell)") - _get_pressure = EclPrototype("double ecl_rft_cell_get_pressure(rft_cell)") - _get_depth = EclPrototype("double ecl_rft_cell_get_depth(rft_cell)") - _get_i = EclPrototype("int ecl_rft_cell_get_i(rft_cell)") - _get_j = EclPrototype("int ecl_rft_cell_get_j(rft_cell)") - _get_k = EclPrototype("int ecl_rft_cell_get_k(rft_cell)") - - - def free(self): - self._free() - - def get_i(self): - return self._get_i() - - def get_j(self): - return self._get_j() - - def get_k(self): - return self._get_k() - - def get_ijk(self): - return (self.get_i(), self.get_j(), self.get_k()) - - @property - def pressure(self): - return self._get_pressure() - - @property - def depth(self): - return self._get_depth() - - -################################################################# - - -class EclRFTCell(RFTCell): - TYPE_NAME = "ecl_rft_cell" - _alloc_RFT = EclPrototype("void* ecl_rft_cell_alloc_RFT(int, int, int, double, double, double, double)", bind = False) - _get_swat = EclPrototype("double ecl_rft_cell_get_swat(ecl_rft_cell)") - _get_soil = EclPrototype("double ecl_rft_cell_get_soil(ecl_rft_cell)") - _get_sgas = EclPrototype("double ecl_rft_cell_get_sgas(ecl_rft_cell)") - - def __init__(self, i, j, k, depth, pressure, swat, sgas): - c_ptr = self._alloc_RFT(i, j, k, depth, pressure, swat, sgas) - super(EclRFTCell, self).__init__(c_ptr) - - @property - def swat(self): - return self._get_swat() - - @property - def sgas(self): - return self._get_sgas() - - @property - def soil(self): - return 1 - (self._get_sgas() + self._get_swat()) - - -################################################################# - - -class EclPLTCell(RFTCell): - TYPE_NAME = "ecl_plt_cell" - _alloc_PLT = EclPrototype("void* ecl_rft_cell_alloc_PLT(int, int, int, double, double, double, double, double, double, double, double, double, double, double)", bind=False) - _get_orat = EclPrototype("double ecl_rft_cell_get_orat(ecl_plt_cell)") - _get_grat = EclPrototype("double ecl_rft_cell_get_grat(ecl_plt_cell)") - _get_wrat = EclPrototype("double ecl_rft_cell_get_wrat(ecl_plt_cell)") - - _get_flowrate = EclPrototype("double ecl_rft_cell_get_flowrate(ecl_plt_cell)") - _get_oil_flowrate = EclPrototype("double ecl_rft_cell_get_oil_flowrate(ecl_plt_cell)") - _get_gas_flowrate = EclPrototype("double ecl_rft_cell_get_gas_flowrate(ecl_plt_cell)") - _get_water_flowrate = EclPrototype("double ecl_rft_cell_get_water_flowrate(ecl_plt_cell)") - - _get_conn_start = EclPrototype("double ecl_rft_cell_get_connection_start(ecl_plt_cell)") - _get_conn_end = EclPrototype("double ecl_rft_cell_get_connection_end(ecl_plt_cell)") - - - def __init__(self, i, j, k, depth, pressure, orat, grat, wrat, conn_start, - conn_end, flowrate, oil_flowrate, gas_flowrate, water_flowrate): - c_ptr = self._alloc_PLT(i, j, k, depth, pressure, orat, grat, wrat, - conn_start, conn_end, flowrate, oil_flowrate, - gas_flowrate, water_flowrate) - super(EclPLTCell, self).__init__(c_ptr) - - - @property - def orat(self): - return self._get_orat() - - @property - def grat(self): - return self._get_grat() - - @property - def wrat(self): - return self._get_wrat() - - @property - def conn_start(self): - """Will return the length from wellhead(?) to connection. - - For MSW wells this property will return the distance from a - fixed point (wellhead) to the current connection. This value - will be used to sort the completed cells along the well - path. In the case of non MSW wells this will just return a - fixed default value. - """ - return self._get_conn_start() - - @property - def conn_end(self): - """Will return the length from wellhead(?) to connection end. - - For MSW wells this property will return the distance from a - fixed point (wellhead) to the current connection end. This value - will be used to sort the completed cells along the well - path. In the case of non MSW wells this will just return a - fixed default value. - """ - return self._get_conn_end() - - @property - def flowrate(self): - return self._get_flowrate() - - @property - def oil_flowrate(self): - return self._get_oil_flowrate() - - @property - def gas_flowrate(self): - return self._get_gas_flowrate() - - @property - def water_flowrate(self): - return self._get_water_flowrate() diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py deleted file mode 100644 index 2a903bc964..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype - - -class EclSMSPECNode(BaseCClass): - """ - Small class with some meta information about a summary variable. - - The summary variables have different attributes, like if they - represent a total quantity, a rate or a historical quantity. These - quantities, in addition to the underlying values like WGNAMES, - KEYWORD and NUMS taken from the the SMSPEC file are stored in this - structure. - """ - TYPE_NAME = "smspec_node" - _node_is_total = EclPrototype("bool smspec_node_is_total( smspec_node )") - _node_is_historical = EclPrototype("bool smspec_node_is_historical( smspec_node )") - _node_is_rate = EclPrototype("bool smspec_node_is_rate( smspec_node )") - _node_unit = EclPrototype("char* smspec_node_get_unit( smspec_node )") - _node_wgname = EclPrototype("char* smspec_node_get_wgname( smspec_node )") - _node_keyword = EclPrototype("char* smspec_node_get_keyword( smspec_node )") - _node_num = EclPrototype("int smspec_node_get_num( smspec_node )") - _node_need_num = EclPrototype("bool smspec_node_need_nums( smspec_node )") - _gen_key1 = EclPrototype("char* smspec_node_get_gen_key1( smspec_node )") - _gen_key2 = EclPrototype("char* smspec_node_get_gen_key2( smspec_node )") - _var_type = EclPrototype("ecl_sum_var_type smspec_node_get_var_type( smspec_node )") - _cmp = EclPrototype("int smspec_node_cmp( smspec_node , smspec_node)") - - def __init__(self): - super(EclSMSPECNode, self).__init__(0) # null pointer - raise NotImplementedError("Class can not be instantiated directly!") - - def cmp(self, other): - if isinstance(other, EclSMSPECNode): - return self._cmp( other ) - else: - raise TypeError("Other argument must be of type EclSMSPECNode") - - - def __lt__(self , other): - return self.cmp( other ) < 0 - - - def __gt__(self , other): - return self.cmp( other ) > 0 - - - def __eq__(self , other): - return self.cmp( other ) == 0 - - - def __hash__(self , other): - return hash(self._gen_key1( )) - - - @property - def unit(self): - """ - Returns the unit of this node as a string. - """ - return self._node_unit( ) - - @property - def wgname(self): - """ - Returns the WGNAME property for this node. - - Many variables do not have the WGNAME property, i.e. the field - related variables like FOPT and the block properties like - BPR:10,10,10. For these variables the function will return - None, and not the ECLIPSE dummy value: ":+:+:+:+". - """ - return self._node_wgname( ) - - - @property - def keyword(self): - """ - Returns the KEYWORD property for this node. - - The KEYWORD property is the main classification property in - the ECLIPSE SMSPEC file. The properties of a variable can be - read from the KEWYORD value; see table 3.4 in the ECLIPSE file - format reference manual. - """ - return self._node_keyword( ) - - @property - def num(self): - return self.getNum( ) - - def get_key1(self): - """ - Returns the primary composite key, i.e. like 'WOPR:OPX' for this - node. - """ - return self._gen_key1( ) - - - def get_key2(self): - """Returns the secondary composite key for this node. - - Most variables have only one composite key, but in particular - nodes which involve (i,j,k) coordinates will contain two - forms: - - getKey1() => "BPR:10,11,6" - getKey2() => "BPR:52423" - - Where the '52423' in getKey2() corresponds to i + j*nx + - k*nx*ny. - """ - return self._gen_key2( ) - - - def var_type(self): - return self._var_type( ) - - - def get_num(self): - """ - Returns the NUMS value for this keyword; or None. - - Many of the summary keywords have an integer stored in the - vector NUMS as an attribute, i.e. the block properties have - the global index of the cell in the nums vector. If the - variable in question makes use of the NUMS value this property - will return the value, otherwise it will return None: - - sum.smspec_node("FOPT").num => None - sum.smspec_node("BPR:1000").num => 1000 - - """ - if self._node_need_num( ): - return self._node_num( ) - else: - return None - - def is_rate(self): - """ - Will check if the variable in question is a rate variable. - - The conecpt of rate variabel is important (internally) when - interpolation values to arbitrary times. - """ - return self._node_is_rate() - - - def is_total(self): - """ - Will check if the node corresponds to a total quantity. - - The question of whether a variable corresponds to a 'total' - quantity or not can be interesting for e.g. interpolation - purposes. The actual question whether a quantity is total or - not is based on a hardcoded list in smspec_node_set_flags() in - smspec_node.c; this list again is based on the tables 2.7 - - 2.11 in the ECLIPSE fileformat documentation. - """ - return self._node_is_total( ) - - - def is_historical(self): - """ - Checks if the key corresponds to a historical variable. - - The check is only based on the last character; all variables - ending with 'H' are considered historical. - """ - return self._node_is_historical( ) - - -monkey_the_camel(EclSMSPECNode, 'getKey1', EclSMSPECNode.get_key1) -monkey_the_camel(EclSMSPECNode, 'getKey2', EclSMSPECNode.get_key2) -monkey_the_camel(EclSMSPECNode, 'varType', EclSMSPECNode.var_type) -monkey_the_camel(EclSMSPECNode, 'getNum', EclSMSPECNode.get_num) -monkey_the_camel(EclSMSPECNode, 'isRate', EclSMSPECNode.is_rate) -monkey_the_camel(EclSMSPECNode, 'isTotal', EclSMSPECNode.is_total) -monkey_the_camel(EclSMSPECNode, 'isHistorical', EclSMSPECNode.is_historical) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py deleted file mode 100644 index 1299e4b781..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_subsidence.py' is part of ERT - Ensemble based -# Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Calculate dynamic change in gravitational strength. - -The ecl_subsidence module contains functionality to load time-lapse ECLIPSE -results and calculate the change in seafloor subsidence between the -different surveys. The implementation is a thin wrapper around the -ecl_subsidence.c implementation in the libecl library. -""" -from cwrap import BaseCClass -from ecl.ecl import EclPrototype -from ecl.util import monkey_the_camel - -class EclSubsidence(BaseCClass): - """ - Holding ECLIPSE results for calculating subsidence changes. - - The EclSubsidence class is a collection class holding the results from - ECLIPSE forward modelling of subsidence surveys. Observe that the - class is focused on the ECLIPSE side of things, and does not have - any notion of observed values or measurement locations; that - should be handled by the scope using the EclSubsidence class. - - Typical use of the EclSubsidence class involves the following steps: - - 1. Create the EclSubsidence instance. - 2. Add surveys with the add_survey_XXXX() methods. - 3. Evalute the subsidence response with the eval() method. - """ - TYPE_NAME = "ecl_subsidence" - _alloc = EclPrototype("void* ecl_subsidence_alloc( ecl_grid , ecl_file )" , bind = False) - _free = EclPrototype("void ecl_subsidence_free( ecl_subsidence )") - _add_survey_PRESSURE = EclPrototype("void* ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file_view )") - _eval = EclPrototype("double ecl_subsidence_eval( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double)") - _eval_geertsma = EclPrototype("double ecl_subsidence_eval_geertsma( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double, double)") - _has_survey = EclPrototype("bool ecl_subsidence_has_survey( ecl_subsidence , char*)") - - def __init__( self, grid, init_file ): - """ - Creates a new EclSubsidence instance. - - The input arguments @grid and @init_file should be instances - of EclGrid and EclFile respectively. - """ - self.init_file = init_file # Inhibit premature garbage collection of init_file - c_ptr = self._alloc( grid , init_file ) - super( EclSubsidence , self ).__init__( c_ptr ) - - - def __contains__(self , survey_name): - return self._has_survey( survey_name ) - - - - def add_survey_PRESSURE( self, survey_name, restart_file ): - """ - Add new survey based on PRESSURE keyword. - - Add a new survey; in this context a survey is the state of - reservoir, i.e. an ECLIPSE restart file. The @survey_name - input argument will be used when refering to this survey at a - later stage. The @restart_file input argument should be an - EclFile instance with data from one report step. A typical way - to load the @restart_file argument is: - - import datetime - import ecl.ecl.ecl as ecl - ... - ... - date = datetime.datetime( year , month , day ) - restart_file1 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , dtime = date) - restart_file2 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 ) - - The pore volume is calculated from the initial pore volume and - the PRESSURE keyword from the restart file. - """ - self._add_survey_PRESSURE( survey_name, restart_file) - - - def eval_geertsma(self, base_survey, monitor_survey, pos, youngs_modulus, poisson_ratio, seabed, region=None): - if not base_survey in self: - raise KeyError("No such survey: %s" % base_survey) - - if monitor_survey is not None: - if not monitor_survey in self: - raise KeyError("No such survey: %s" % monitor_survey) - - return self._eval_geertsma(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], youngs_modulus, poisson_ratio, seabed) - - def eval(self, base_survey, monitor_survey, pos, compressibility, poisson_ratio, region=None): - """ - Calculates the subsidence change between two surveys. - - This is the method everything is leading up to; will calculate - the change in subsidence, in centimeters, - between the two surveys named @base_survey and - @monitor_survey. - - The monitor survey can be 'None' - the resulting answer has - nothing whatsovever to do with subsidence, but can be - interesting to determine the numerical size of the quantities - which are subtracted in a 4D study. - - The @pos argument should be a tuple of three elements with the - (utm_x , utm_y , depth) position where we want to evaluate the - change in subsidence. - - If supplied the optional argument @region should be an - EclRegion() instance; this region will be used to limit the - part of the reserviour included in the subsidence calculations. - - The argument @compressibility is the total reservoir compressibility. - """ - if not base_survey in self: - raise KeyError("No such survey: %s" % base_survey) - - if not monitor_survey in self: - raise KeyError("No such survey: %s" % monitor_survey) - - return self._eval(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], compressibility,poisson_ratio) - - - - def free(self): - self._free( ) - - -monkey_the_camel(EclSubsidence, 'evalGeertsma', EclSubsidence.eval_geertsma) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py deleted file mode 100644 index fe6ca681e2..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py +++ /dev/null @@ -1,1300 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Module for loading and querying summary data. - -The low-level organisation of summary data is extensively documented -in the C source files ecl_sum.c, ecl_smspec.c and ecl_sum_data in the -libecl/src directory. -""" - - -import numpy -import datetime -import os.path - -# Observe that there is some convention conflict with the C code -# regarding order of arguments: The C code generally takes the time -# index as the first argument and the key/key_index as second -# argument. In the python code this order has been reversed. -from cwrap import BaseCClass, CFILE - -from ecl.util import monkey_the_camel -from ecl.util import StringList, CTime, DoubleVector, TimeVector, IntVector - -from ecl.ecl import EclSumTStep -from ecl.ecl import EclSumVarType -from ecl.ecl.ecl_sum_vector import EclSumVector -from ecl.ecl.ecl_smspec_node import EclSMSPECNode -from ecl.ecl import EclPrototype -#, EclSumKeyWordVector - - - - -#import ecl.ecl_plot.sum_plot as sum_plot - -# The date2num function is a verbatim copy of the _to_ordinalf() -# function from the matplotlib.dates module. Inserted here only to -# avoid importing the full matplotlib library. The date2num -# implementation could be replaced with: -# -# from matplotlib.dates import date2num - - -HOURS_PER_DAY = 24.0 -MINUTES_PER_DAY = 60 * HOURS_PER_DAY -SECONDS_PER_DAY = 60 * MINUTES_PER_DAY -MUSECONDS_PER_DAY = 1e6 * SECONDS_PER_DAY - -def date2num(dt): - """ - Convert a python datetime instance to UTC float days. - - Convert datetime to the Gregorian date as UTC float days, - preserving hours, minutes, seconds and microseconds, return value - is a float. The function is a verbatim copy of the _to_ordinalf() - function from the matplotlib.dates module. - """ - - if hasattr(dt, 'tzinfo') and dt.tzinfo is not None: - delta = dt.tzinfo.utcoffset(dt) - if delta is not None: - dt -= delta - - base = float(dt.toordinal()) - if hasattr(dt, 'hour'): - base += (dt.hour/HOURS_PER_DAY + - dt.minute/MINUTES_PER_DAY + - dt.second/SECONDS_PER_DAY + - dt.microsecond/MUSECONDS_PER_DAY) - return base - - -class EclSum(BaseCClass): - TYPE_NAME = "ecl_sum" - _fread_alloc_case = EclPrototype("void* ecl_sum_fread_alloc_case__(char*, char*, bool)", bind=False) - _fread_alloc = EclPrototype("void* ecl_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False) - _create_restart_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_restart_writer(char*, char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False) - _iiget = EclPrototype("double ecl_sum_iget(ecl_sum, int, int)") - _free = EclPrototype("void ecl_sum_free(ecl_sum)") - _data_length = EclPrototype("int ecl_sum_get_data_length(ecl_sum)") - _scale_vector = EclPrototype("void ecl_sum_scale_vector(ecl_sum, int, double)") - _shift_vector = EclPrototype("void ecl_sum_shift_vector(ecl_sum, int, double)") - _iget_sim_days = EclPrototype("double ecl_sum_iget_sim_days(ecl_sum, int) ") - _iget_report_step = EclPrototype("int ecl_sum_iget_report_step(ecl_sum, int) ") - _iget_mini_step = EclPrototype("int ecl_sum_iget_mini_step(ecl_sum, int) ") - _iget_sim_time = EclPrototype("time_t ecl_sum_iget_sim_time(ecl_sum, int) ") - _get_report_end = EclPrototype("int ecl_sum_iget_report_end(ecl_sum, int)") - _get_general_var = EclPrototype("double ecl_sum_get_general_var(ecl_sum, int, char*)") - _get_general_var_index = EclPrototype("int ecl_sum_get_general_var_params_index(ecl_sum, char*)") - _get_general_var_from_sim_days = EclPrototype("double ecl_sum_get_general_var_from_sim_days(ecl_sum, double, char*)") - _get_general_var_from_sim_time = EclPrototype("double ecl_sum_get_general_var_from_sim_time(ecl_sum, time_t, char*)") - _solve_days = EclPrototype("double_vector_obj ecl_sum_alloc_days_solution(ecl_sum, char*, double, bool)") - _solve_dates = EclPrototype("time_t_vector_obj ecl_sum_alloc_time_solution(ecl_sum, char*, double, bool)") - _get_first_gt = EclPrototype("int ecl_sum_get_first_gt(ecl_sum, int, double)") - _get_first_lt = EclPrototype("int ecl_sum_get_first_lt(ecl_sum, int, double)") - _get_start_date = EclPrototype("time_t ecl_sum_get_start_time(ecl_sum)") - _get_end_date = EclPrototype("time_t ecl_sum_get_end_time(ecl_sum)") - _get_last_report_step = EclPrototype("int ecl_sum_get_last_report_step(ecl_sum)") - _get_first_report_step = EclPrototype("int ecl_sum_get_first_report_step(ecl_sum)") - _select_matching_keys = EclPrototype("void ecl_sum_select_matching_general_var_list(ecl_sum, char*, stringlist)") - _has_key = EclPrototype("bool ecl_sum_has_general_var(ecl_sum, char*)") - _check_sim_time = EclPrototype("bool ecl_sum_check_sim_time(ecl_sum, time_t)") - _check_sim_days = EclPrototype("bool ecl_sum_check_sim_days(ecl_sum, double)") - _sim_length = EclPrototype("double ecl_sum_get_sim_length(ecl_sum)") - _get_first_day = EclPrototype("double ecl_sum_get_first_day(ecl_sum)") - _get_data_start = EclPrototype("time_t ecl_sum_get_data_start(ecl_sum)") - _get_unit = EclPrototype("char* ecl_sum_get_unit(ecl_sum, char*)") - _get_simcase = EclPrototype("char* ecl_sum_get_case(ecl_sum)") - _get_base = EclPrototype("char* ecl_sum_get_base(ecl_sum)") - _get_path = EclPrototype("char* ecl_sum_get_path(ecl_sum)") - _get_abs_path = EclPrototype("char* ecl_sum_get_abs_path(ecl_sum)") - _get_report_step_from_time = EclPrototype("int ecl_sum_get_report_step_from_time(ecl_sum, time_t)") - _get_report_step_from_days = EclPrototype("int ecl_sum_get_report_step_from_days(ecl_sum, double)") - _get_report_time = EclPrototype("time_t ecl_sum_get_report_time(ecl_sum, int)") - _fwrite_sum = EclPrototype("void ecl_sum_fwrite(ecl_sum)") - _set_case = EclPrototype("void ecl_sum_set_case(ecl_sum, char*)") - _alloc_time_vector = EclPrototype("time_t_vector_obj ecl_sum_alloc_time_vector(ecl_sum, bool)") - _alloc_data_vector = EclPrototype("double_vector_obj ecl_sum_alloc_data_vector(ecl_sum, int, bool)") - _get_var_node = EclPrototype("smspec_node_ref ecl_sum_get_general_var_node(ecl_sum, char*)") - _create_well_list = EclPrototype("stringlist_obj ecl_sum_alloc_well_list(ecl_sum, char*)") - _create_group_list = EclPrototype("stringlist_obj ecl_sum_alloc_group_list(ecl_sum, char*)") - _add_variable = EclPrototype("smspec_node_ref ecl_sum_add_var(ecl_sum, char*, char*, int, char*, double)") - _add_tstep = EclPrototype("ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)") - _export_csv = EclPrototype("void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)") - _identify_var_type = EclPrototype("ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind = False) - - - - def __init__(self, load_case, join_string=":", include_restart=True): - """ - Loads a new EclSum instance with summary data. - - Loads a new summary results from the ECLIPSE case given by - argument @load_case; @load_case should be the basename of the ECLIPSE - simulation you want to load. @load_case can contain a leading path - component, and also an extension - the latter will be ignored. - - The @join_string is the string used when combining elements - from the WGNAMES, KEYWORDS and NUMS vectors into a composit - key; with @join_string == ":" the water cut in well OP_1 will - be available as "WWCT:OP_1". - - If the @include_restart parameter is set to true the summary - loader will, in the case of a restarted ECLIPSE simulation, - try to load summary results also from the restarted case. - """ - if not load_case: - raise ValueError('load_case must be the basename of the simulation') - c_pointer = self._fread_alloc_case(load_case, join_string, include_restart) - if c_pointer is None: - raise IOError("Failed to create summary instance from argument:%s" % load_case) - - super(EclSum, self).__init__(c_pointer) - self.__private_init() - self._load_case = load_case - - - @classmethod - def load(cls, smspec_file, unsmry_file, key_join_string = ":", include_restart = True): - if not os.path.isfile( smspec_file ): - raise IOError("No such file: %s" % smspec_file) - - if not os.path.isfile( unsmry_file ): - raise IOError("No such file: %s" % unsmry_file ) - - data_files = StringList( ) - data_files.append( unsmry_file ) - c_ptr = cls._fread_alloc(smspec_file, data_files, key_join_string, include_restart) - if c_ptr is None: - raise IOError("Failed to create summary instance") - - ecl_sum = cls.createPythonObject( c_ptr ) - ecl_sum._load_case = smspec_file - return ecl_sum - - - @classmethod - def createCReference(cls, c_pointer, parent=None): - result = super(EclSum, cls).createCReference(c_pointer, parent) - if not result is None: - result.__private_init() - return result - - - @classmethod - def createPythonObject(cls, c_pointer): - result = super(EclSum, cls).createPythonObject(c_pointer) - result.__private_init() - return result - - - @classmethod - def var_type(cls, keyword): - return cls._identify_var_type(keyword) - - - @staticmethod - def writer(case, start_time, nx,ny,nz, fmt_output=False, unified=True, time_in_days=True, key_join_string=":"): - """ - The writer is not generally usable. - @rtype: EclSum - """ - return EclSum._create_restart_writer(case, None, fmt_output, unified, key_join_string, CTime(start_time), time_in_days, nx, ny, nz) - - @staticmethod - def restart_writer(case, restart_case, start_time, nx,ny,nz, fmt_output=False, unified=True, time_in_days=True, key_join_string=":"): - """ - The writer is not generally usable. - @rtype: EclSum - """ - return EclSum._create_restart_writer(case, restart_case, fmt_output, unified, key_join_string, CTime(start_time), time_in_days, nx, ny, nz) - - def add_variable(self, variable, wgname=None, num=0, unit="None", default_value=0): - return self._add_variable(variable, wgname, num, unit, default_value).setParent(parent=self) - - - def add_t_step(self, report_step, sim_days): - """ @rtype: EclSumTStep """ - sim_seconds = sim_days * 24 * 60 * 60 - return self._add_tstep(report_step, sim_seconds).setParent(parent=self) - - - - def __private_init(self): - # Initializing the time vectors - length = self.length - self.__dates = [0] * length - self.__report_step = numpy.zeros(length, dtype=numpy.int32) - self.__mini_step = numpy.zeros(length, dtype=numpy.int32) - self.__days = numpy.zeros(length) - self.__mpl_dates = numpy.zeros(length) - - for i in range(length): - self.__days[i] = self._iget_sim_days(i) - self.__dates[i] = self.iget_date(i) - self.__report_step[i] = self._iget_report_step(i) - self.__mini_step[i] = self._iget_mini_step(i) - self.__mpl_dates[i] = date2num(self.__dates[i]) - - index_list = self.report_index_list() - - length = len(index_list) - index_list.count(-1) - self.__datesR = [0] * length - self.__report_stepR = numpy.zeros(length, dtype=numpy.int32) - self.__mini_stepR = numpy.zeros(length, dtype=numpy.int32) - self.__daysR = numpy.zeros(length) - self.__mpl_datesR = numpy.zeros(length) - - # Slightly hysterical heuristics to accomoate for the - # situation where there are holes in the report steps series; - # when a report step is completely missing there will be -1 - # entries in the index_list. - i1 = 0 - for i0 in range(length): - while True: - time_index = index_list[i1] - if time_index >= 0: - break - i1 += 1 - - self.__daysR[i0] = self._iget_sim_days(time_index) - self.__datesR[i0] = self.iget_date(time_index) - self.__report_stepR[i0] = self._iget_report_step(time_index) - self.__mini_stepR[i0] = self._iget_mini_step(time_index) - self.__mpl_datesR[i0] = date2num(self.__datesR[i0]) - - - def get_vector(self, key, report_only=False): - """ - Will return EclSumVector according to @key. - - Will raise exception KeyError if the summary object does not - have @key. - """ - self.assertKeyValid(key) - if report_only: - return EclSumVector(self, key, report_only=True) - else: - return EclSumVector(self, key) - - - def report_index_list(self): - """ - Internal function for working with report_steps. - """ - first_report = self.first_report - last_report = self.last_report - index_list = IntVector() - for report_step in range(first_report, last_report + 1): - time_index = self._get_report_end(report_step) - index_list.append(time_index) - return index_list - - - - def wells(self, pattern=None): - """ - Will return a list of all the well names in case. - - If the pattern variable is different from None only wells - matching the pattern will be returned; the matching is based - on fnmatch(), i.e. shell style wildcards. - """ - return self._create_well_list(pattern) - - - def groups(self, pattern=None): - """ - Will return a list of all the group names in case. - - If the pattern variable is different from None only groups - matching the pattern will be returned; the matching is based - on fnmatch(), i.e. shell style wildcards. - """ - return self._create_group_list(pattern) - - - def get_values(self, key, report_only=False): - """ - Will return numpy vector of all values according to @key. - - If the optional argument report_only is true only the values - corresponding to report steps are included. The method is - also available as the 'values' property of an EclSumVector - instance. - """ - if self.has_key(key): - key_index = self._get_general_var_index(key) - if report_only: - index_list = self.report_index_list() - values = numpy.zeros(len(index_list)) - for i in range(len(index_list)): - time_index = index_list[i] - values[i] = self._iiget(time_index, key_index) - else: - length = self._data_length() - values = numpy.zeros(length) - for i in range(length): - values[i] = self._iiget(i, key_index) - - return values - else: - raise KeyError("Summary object does not have key:%s" % key) - - - def get_key_index(self, key): - """ - Lookup parameter index of @key. - - All the summary keys identified in the SMSPEC file have a - corresponding index which is used internally. This function - will return that index for input key @key, this can then be - used in subsequent calls to e.g. the iiget() method. This is a - minor optimization in the case of many lookups of the same - key: - - sum = ecl.EclSum(case) - key_index = sum.get_key_index(key) - for time_index in range(sum.length): - value = sum.iiget(time_index, key_index) - - Quite low-level function, should probably rather use a - EclSumVector based function? - """ - index = self._get_general_var_index(key) - if index >= 0: - return index - else: - return None - - - def get_last_value(self, key): - """ - Will return the last value corresponding to @key. - - Typically useful to get the total production at end of - simulation: - - total_production = sum.last_value("FOPT") - - The alternative method 'last' will return a EclSumNode - instance with some extra time related information. - """ - return self[key].last_value - - def get_last(self, key): - """ - Will return the last EclSumNode corresponding to @key. - - If you are only interested in the final value, you can use the - get_last_value() method. - """ - return self[key].last - - - def iiget(self, time_index, key_index): - """ - Lookup a summary value based on naive @time_index and - @key_index. - - The iiget() method will lookup a summary value based on the - 'time' value give by @time_index (i.e. naive counting of - time steps starting at zero), and a key index given by - @key_index. The @key_index value will typically be obtained - with the get_key_index() method first. - - This is a quite low level function, in most cases it will be - natural to go via e.g. an EclSumVector instance. - """ - return self._iiget(time_index, key_index) - - - def iget(self, key, time_index): - """ - Lookup summary value based on @time_index and key. - - The @time_index value should be an integer [0,num_steps) and - @key should be string key. To get all the water cut values - from a well: - - for time_index in range(sum.length): - wwct = sum.iget(time_index, "WWCT:W5") - - This is a quite low level function, in most cases it will be - natural to go via e.g. an EclSumVector instance. - """ - return self._get_general_var(time_index, key) - - - def __len__(self): - """ - The number of timesteps in the dataset; the return when evaluating - len(case). - - """ - return self._data_length() - - - def __contains__(self, key): - if self._has_key(key): - return True - else: - return False - - def assert_key_valid(self, key): - if not key in self: - raise KeyError("The summary key:%s was not recognized" % key) - - def __iter__(self): - return iter(self.keys()) - - def __getitem__(self, key): - """ - Implements [] operator - @key should be a summary key. - - The returned value will be a EclSumVector instance. - """ - return self.get_vector(key) - - def scale_vector(self, key, scalar): - """ecl_sum.scaleVector("WOPR:OPX", 0.78) - will scale all the elements in the 'WOPR:OPX' vector with 0.78. - """ - if not key in self: - raise KeyError("Summary object does not have key:%s" % key) - - key_index = self._get_general_var_index(key) - self._scale_vector(key_index, float(scalar)) - - def shift_vector(self, key, addend): - """ecl_sum.shiftVector("WOPR:OPX", 0.78) - will shift (add) all the elements in the 'WOPR:OPX' vector with 0.78. - """ - if not key in self: - raise KeyError("Summary object does not have key:%s" % key) - key_index = self._get_general_var_index(key) - self._shift_vector(key_index, float(addend)) - - def check_sim_time(self, date): - """ - Will check if the input date is in the time span [sim_start, sim_end]. - """ - if not isinstance(date, CTime): - date = CTime(date) - return self._check_sim_time(date) - - def get_interp_direct(self,key, date): - - if not isinstance(date, CTime): - date = CTime(date) - return self._get_general_var_from_sim_time(date, key) - - def get_interp(self, key, days=None, date=None): - """ - Will lookup vector @key at time given by @days or @date. - - Requiers exactly one input argument @days or @date; will raise - exception ValueError if this is not satisfied. - - The method will check that the time argument is within the - time limits of the simulation; if else the method will raise - exception ValueError. - - Also available as method get_interp() on the EclSumVector - class. - """ - self.assertKeyValid(key) - if days is None and date is None: - raise ValueError("Must supply either days or date") - - if days is None: - t = CTime(date) - if self.check_sim_time(t): - return self._get_general_var_from_sim_time(t, key) - else: - - raise ValueError("date:%s is outside range of simulation data" % date) - elif date is None: - if self._check_sim_days(days): - return self._get_general_var_from_sim_days(days, key) - else: - raise ValueError("days:%s is outside range of simulation: [%g,%g]" % (days, self.first_day, self.sim_length)) - else: - raise ValueError("Must supply either days or date") - - - def get_interp_row(self, key_list, sim_time): - ctime = CTime(sim_time) - data = DoubleVector( initial_size = len(key_list) ) - EclSum._get_interp_vector(self, ctime, key_list, data) - return data - - - def time_range(self, start=None, end=None, interval="1Y", extend_end=True): - (num, timeUnit) = TimeVector.parseTimeUnit(interval) - - if start is None: - start = self.getDataStartTime() - else: - if isinstance(start, datetime.date): - start = datetime.datetime(start.year, start.month, start.day, 0, 0, 0) - - if start < self.getDataStartTime(): - start = self.getDataStartTime() - - - if end is None: - end = self.getEndTime() - else: - if isinstance(end, datetime.date): - end = datetime.datetime(end.year, end.month, end.day, 0, 0, 0) - - if end > self.getEndTime(): - end = self.getEndTime() - - if end < start: - raise ValueError("Invalid time interval start after end") - - - range_start = start - range_end = end - if not timeUnit == "d": - year1 = start.year - year2 = end.year - month1 = start.month - month2 = end.month - day1 = start.day - day2 = end.day - if extend_end: - if timeUnit == 'm': - if day2 > 1: - month2 += 1 - if month2 == 13: - year2 += 1 - month2 = 1 - elif timeUnit == "y": - month1 = 1 - if year2 > 1 or day2 > 1: - year2 += 1 - month2 = 1 - day1 = 1 - day2 = 1 - - range_start = datetime.date(year1, month1, day1) - range_end = datetime.date(year2, month2, day2) - - trange = TimeVector.createRegular(range_start, range_end, interval) - - # If the simulation does not start at the first of the month - # the start value will be before the simulation start; we - # manually shift the first element in the trange to the start - # value; the same for the end of list. - - if trange[-1] < end: - if extend_end: - trange.appendTime(num, timeUnit) - else: - trange.append(end) - - data_start = self.getDataStartTime() - if trange[0] < data_start: - trange[0] = CTime(data_start) - - return trange - - - - def blocked_production(self, totalKey, timeRange): - node = self.smspec_node(totalKey) - if node.isTotal(): - total = DoubleVector() - for t in timeRange: - if t < CTime(self.start_time): - total.append(0) - elif t >= CTime(self.end_time): - total.append(self.get_last_value(totalKey)) - else: - total.append(self.get_interp(totalKey, date=t)) - tmp = total << 1 - total.pop() - return tmp - total - else: - raise TypeError("The blockedProduction method must be called with one of the TOTAL keys like e.g. FOPT or GWIT") - - - def get_report(self, date=None, days=None): - """ - Will return the report step corresponding to input @date or @days. - - If the input argument does not correspond to any report steps - the function will return -1. Observe that the function - requires strict equality. - """ - if date: - if days: - raise ValueError("Must supply either days or date") - step = self._get_report_step_from_time(CTime(date)) - elif days: - step = self._get_report_step_from_days(days) - - return step - - - def get_report_time(self, report): - """ - Will return the datetime corresponding to the report_step @report. - """ - return CTime(self._get_report_time(report)).date() - - - def get_interp_vector(self, key, days_list=None, date_list=None): - """ - Will return numpy vector with interpolated values. - - Requiers exactly one input argument @days or @date; will raise - exception ValueError if this is not satisfied. - - The method will check that the time arguments are within the - time limits of the simulation; if else the method will raise - exception ValueError. - - Also available as method get_interp_vector() on the - EclSumVector class. - """ - self.assertKeyValid(key) - if days_list: - if date_list: - raise ValueError("Must supply either days_list or date_list") - else: - vector = numpy.zeros(len(days_list)) - sim_length = self.sim_length - sim_start = self.first_day - index = 0 - for days in days_list: - if (days >= sim_start) and (days <= sim_length): - vector[index] = self._get_general_var_from_sim_days(days, key) - else: - raise ValueError("Invalid days value") - index += 1 - elif date_list: - start_time = self.data_start - end_time = self.end_date - vector = numpy.zeros(len(date_list)) - index = 0 - - for date in date_list: - ct = CTime(date) - if start_time <= ct <= end_time: - vector[index] = self._get_general_var_from_sim_time(ct, key) - else: - raise ValueError("Invalid date value") - index += 1 - else: - raise ValueError("Must supply either days_list or date_list") - return vector - - - def get_from_report(self, key, report_step): - """ - Return summary value of @key at time @report_step. - """ - time_index = self._get_report_end(report_step) - return self._get_general_var(time_index, key) - - - def has_key(self, key): - """ - Check if summary object has key @key. - """ - return key in self - - - def smspec_node(self, key): - """ - Will return a EclSMSPECNode instance corresponding to @key. - - The returned EclSMPECNode instance can then be used to ask for - various properties of the variable; i.e. if it is a rate - variable, what is the unit, if it is a total variable and so - on. - """ - if self.has_key(key): - node = self._get_var_node(key).setParent(self) - return node - else: - raise KeyError("Summary case does not have key:%s" % key) - - - def unit(self, key): - """ - Will return the unit of @key. - """ - node = self.smspec_node(key) - return node.unit - - - @property - def case(self): - """ - Will return the case name of the current instance - optionally including path. - """ - return self._get_simcase() - - - @property - def path(self): - """ - Will return the path to the current case. Will be None for - case in CWD. See also abs_path. - """ - return self._get_path() - - @property - def base(self): - """ - Will return the basename of the current case - no path. - """ - return self._get_base() - - @property - def abs_path(self): - """ - Will return the absolute path to the current case. - """ - return self._get_abs_path() - - #----------------------------------------------------------------- - # Here comes functions for getting vectors of the time - # dimension. All the get_xxx() functions have an optional boolean - # argument @report_only. If this argument is set to True the - # functions will return time vectors only corresponding to the - # report times. - # - # In addition to the get_xxx() methods there are properties with - # the same name (excluding the 'get'); these properties correspond - # to an get_xxx() invocation with optional argument report_only - # set to False (i.e. the defualt). - - @property - def days(self): - """ - Will return a numpy vector of simulations days. - """ - return self.get_days(False) - - def get_days(self, report_only=False): - """ - Will return a numpy vector of simulations days. - - If the optional argument @report_only is set to True, only - 'days' values corresponding to report steps will be included. - """ - if report_only: - return self.__daysR - else: - return self.__days - - @property - def dates(self): - """ - Will return a list of simulation dates. - - The list will be an ordinary Python list, and the dates will - be in terms ordinary Python datetime values. - """ - return self.get_dates(False) - - def get_dates(self, report_only=False): - """ - Will return a list of simulation dates. - - The list will be an ordinary Python list, and the dates will - be in terms ordinary Python datetime values. If the optional - argument @report_only is set to True, only dates corresponding - to report steps will be included. - """ - if report_only: - return self.__datesR - else: - return self.__dates - - @property - def mpl_dates(self): - """ - Will return a numpy vector of dates ready for matplotlib - - The content of the vector are dates in matplotlib format, - i.e. floats - generated by the date2num() function at the top - of this file. - """ - return self.get_mpl_dates(False) - - def get_mpl_dates(self, report_only=False): - """ - Will return a numpy vector of dates ready for matplotlib - - If the optional argument @report_only is set to True, only - dates values corresponding to report steps will be - included. The content of the vector are dates in matplotlib - format, i.e. floats - generated by the date2num() function at - the top of this file. - """ - if report_only: - return self.__mpl_datesR - else: - return self.__mpl_dates - - @property - def mini_step(self): - """ - Will return a a python list of ministep values. - - Will return a Python list of ministep values from this summary - case; the ministep values are the internal indexing of - timesteps provided by the reservoir simulator. In normal cases - this will be: [0,1,2,3,4,5,....], but in the case of restarted - simulations it can start at a higher value, and there can also - be 'holes' in the series if 'RPTONLY' has been used in THE - ECLIPSE datafile. - """ - return self.get_mini_step(False) - - def get_mini_step(self, report_only=False): - """ - Will return a a python list of ministep values. - - If the optional argument @report_only is set to True, only - dates values corresponding to report steps will be - included. See documentation of property: 'mini_step' for - further documentation. - """ - if report_only: - return self.__mini_stepR - else: - return self.__mini_step - - - @property - def report_step(self): - """ - Will return a list of report steps. - - The simulator will typically use several simulation timesteps - for each report step, and the number will change between - different report steps. So - assuming that the first report - step one has five simulations timesteps and the next two have - three the report_step vector can look like: - - [...,1,1,1,1,1,2,2,2,3,3,3,....] - - """ - return self.get_report_step(False) - - def get_report_step(self, report_only=False): - if report_only: - return self.__report_stepR - else: - return self.__report_step - - #----------------------------------------------------------------- - - def iget_days(self, time_index): - """ - Returns the number of simulation days for element nr @time_index. - """ - return self._iget_sim_days(time_index) - - def iget_date(self, time_index): - """ - Returns the simulation date for element nr @time_index. - """ - long_time = self._iget_sim_time(time_index) - ct = CTime(long_time) - return ct.datetime() - - - def iget_report(self, time_index): - """ - Returns the report step corresponding to @time_index. - - One report step will in general contain many ministeps. - """ - return self._iget_report_step(time_index) - - - @property - def length(self): - """ - The number of timesteps in the dataset. - """ - return self._data_length() - - @property - def first_day(self): - """ - The first day we have simulation data for; normally 0. - """ - return self._get_first_day() - - @property - def sim_length(self): - return self.getSimulationLength() - - @property - def start_date(self): - """ - A Python date instance with the start date. - - The start time is taken from the SMSPEC file, and in case not - all timesteps have been loaded, e.g. for a restarted case, the - returned start_date might be different from the datetime of - the first (loaded) timestep. - """ - ct = self._get_start_date() - return CTime(ct).date() - - - @property - def end_date(self): - """ - The date of the last (loaded) time step. - """ - return CTime(self._get_end_date()).date() - - - - @property - def data_start(self): - return self.getDataStartTime() - - - - @property - def end_time(self): - """ - The time of the last (loaded) time step. - """ - return self.getEndTime() - - - @property - def start_time(self): - return self.getStartTime() - - - def get_data_start_time(self): - """The first date we have data for. - - Thiw will mostly be equal to getStartTime(), but in the case - of restarts, where the case we have restarted from is not - found, this time will be later than the true start of the - field. - """ - return CTime(self._get_data_start()).datetime() - - - - def get_start_time(self): - """ - A Python datetime instance with the start time. - - See start_date() for further details. - """ - return CTime(self._get_start_date()).datetime() - - - def get_end_time(self): - """ - A Python datetime instance with the last loaded time. - """ - return CTime(self._get_end_date()).datetime() - - def getSimulationLength(self): - """ - The length of the current dataset in simulation days. - - Will include the length of a leading restart section, - irrespective of whether we have data for this or not. - """ - return self._sim_length() - - - - @property - def last_report(self): - """ - The number of the last report step in the dataset. - """ - return self._get_last_report_step() - - @property - def first_report(self): - """ - The number of the first report step in the dataset. - """ - return self._get_first_report_step() - - def first_gt_index(self, key, limit): - """ - Returns the first index where @key is above @limit. - """ - key_index = self._get_general_var_index(key) - time_index = self._get_first_gt(key_index, limit) - return time_index - - def first_lt_index(self, key, limit): - """ - Returns the first index where @key is below @limit. - """ - key_index = self._get_general_var_index(key) - time_index = self._get_first_lt(key_index, limit) - return time_index - - def first_gt(self, key, limit): - """ - First EclSumNode of @key which is above @limit. - """ - vector = self[key] - return vector.first_gt(limit) - - def first_lt(self, key, limit): - """ - First EclSumNode of @key which is below @limit. - """ - vector = self[key] - return vector.first_lt(limit) - - def solve_dates(self, key, value, rates_clamp_lower=True): - """Will solve the equation vector[@key] == value for dates. - - See solveDays() for further details. - """ - if not key in self: - raise KeyError("Unrecognized key:%s" % key) - - if len(self) < 2: - raise ValueError("Must have at least two elements to start solving") - - return [ x.datetime() for x in self._solve_dates(key, value, rates_clamp_lower)] - - - def solve_days(self, key, value, rates_clamp_lower=True): - """Will solve the equation vector[@key] == value. - - This method will solve find tha approximate simulation days - where the vector @key is equal @value. The method will return - a list of values, which can have zero, one or multiple values: - - case = EclSum("CASE") - days = case.solveDays("RPR:2", 200) - - if len(days) == 0: - print("Pressure was never equal to 200 BARSA") - elif len(days) == 1: - print("Pressure equal to 200 BARSA after %s simulation days" % days[0]) - else: - print("Pressure equal to 200 BARSA multiple times") - for index,day in enumerate(days): - print("Solution[%d] : %s days" % (index, day)) - - For variables like pressure and total volumes the solution is - based on straightforward linear interpolation between the - simulated values; that is quite intuitive. However - rates is - less intuitive, and how a rate like FOPR is handled can be - surprising: - - Fundamentally the simulator works with *volumes*. Assume that - the simulator calculates that between the times t1 and t2 the - total volume of oil produced is V, then the oil production - rate is given as: - - FOPR = V / (t2 - t1) - - This is the average production rate in the timespan (t1,t2]; - the simulator does not have any information on a finer time - scale than this - so the natural assumption is that the - production is constant at this value for the whole time - period. The logical consequence of this is that production - rates should be visualized as a piecewise constant function: - - - - A B - | | - /|\ OPR | | - | \|/ \|/ - | - | +============X - | | | - |-------------------------------------------------- X - | | | - | +=============X - | | - | | +===========X - |=========X | - | - +---------+-------------+------------+-----------+--> - t0 t1 t2 t3 t4 time - - - This figure shows a plot of the OPR as a piecewise constant - function. In a strict mathematical sense the equation: - - OPR = X - - Does not have a solution at all, but since this inequality: - - OPR(t2) < X < OPR(t3) - - it is natural to say that the equation has a solution. The - default behaviour is to say that the (first) solution in this - case is: - - tx = t2 + epsilon - - corresponding to the arrow 'A' on the figure. Alternatively if - you set the optional argument 'rates_clamp_lower' to false the - method will find the solution: - - tx = t3 - - corresponding to the arrow 'B* in the figure. - - """ - if not key in self: - raise KeyError("Unrecognized key:%s" % key) - - if len(self) < 2: - raise ValueError("Must have at least two elements to start solving") - - return self._solve_days(key, value, rates_clamp_lower) - - - def keys(self, pattern=None): - """ - Return a StringList of summary keys matching @pattern. - - The matching algorithm is ultimately based on the fnmatch() - function, i.e. normal shell-character syntax is used. With - @pattern == "WWCT:*" you will get a list of watercut keys for - all wells. - - If pattern is None you will get all the keys of summary - object. - """ - s = StringList() - self._select_matching_keys(pattern, s) - return s - - - - - def fwrite(self, ecl_case=None): - if ecl_case: - self._set_case(ecl_case) - - self._fwrite_sum() - - - def alloc_time_vector(self, report_only): - return self._alloc_time_vector(report_only) - - def alloc_data_vector(self, data_index, report_only): - return self._alloc_data_vector(data_index, report_only) - - def get_general_var_index(self, key): - return self._get_general_var_index(key) - - def free(self): - self._free() - - def _nicename(self): - """load_case is often full path to summary file, - if so, output basename, else name - """ - name = self._load_case - if name and os.path.isfile(name): - name = os.path.basename(name) - return name - - def __repr__(self): - """Returns, e.g. - EclSum("NORNE_ATW2013.UNSMRY", [1997-11-06 00:00:00, 2006-12-01 00:00:00], keys=3781) at 0x1609e20 - """ - name = self._nicename() - s_time = self.getStartTime() - e_time = self.getEndTime() - num_keys = len(self.keys()) - content = 'name="%s", time=[%s, %s], keys=%d' % (name, s_time, e_time, num_keys) - return self._create_repr(content) - - def dump_csv_line(self, time, keywords, pfile): - """ - Will dump a csv formatted line of the keywords in @keywords, - evaluated at the intertpolated time @time. @pfile should point to an open Python file handle. - """ - cfile = CFILE(pfile) - ctime = CTime(time) - EclSum._dump_csv_line(self, ctime, keywords, cfile) - - - - def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"): - """Will create a CSV file with summary data. - - By default all the vectors in the summary case will be - exported, but by using the optional keys parameter you can - limit the keys which are exported: - - ecl_sum = EclSum("CASE") - ecl_sum.exportCSV("case.csv", keys=["W*:OP1", "W*:OP2", "F*T"]) - - Will export all well related variables for wells 'OP1' and - 'OP2' and all total field vectors. - """ - - if keys is None: - var_list = self.keys() - else: - var_list = StringList() - for key in keys: - var_list |= self.keys(pattern=key) - self._export_csv(filename, var_list, date_format, sep) - - - - -import ecl.ecl.ecl_sum_keyword_vector -EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) -EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) - -monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod) -monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable) -monkey_the_camel(EclSum, 'addTStep', EclSum.add_t_step) -monkey_the_camel(EclSum, 'assertKeyValid', EclSum.assert_key_valid) -monkey_the_camel(EclSum, 'scaleVector', EclSum.scale_vector) -monkey_the_camel(EclSum, 'shiftVector', EclSum.shift_vector) -monkey_the_camel(EclSum, 'timeRange', EclSum.time_range) -monkey_the_camel(EclSum, 'blockedProduction', EclSum.blocked_production) -monkey_the_camel(EclSum, 'getDataStartTime', EclSum.get_data_start_time) -monkey_the_camel(EclSum, 'getStartTime', EclSum.get_start_time) -monkey_the_camel(EclSum, 'getEndTime', EclSum.get_end_time) -monkey_the_camel(EclSum, 'solveDates', EclSum.solve_dates) -monkey_the_camel(EclSum, 'solveDays', EclSum.solve_days) -monkey_the_camel(EclSum, 'dumpCSVLine', EclSum.dump_csv_line) -monkey_the_camel(EclSum, 'exportCSV', EclSum.export_csv) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py deleted file mode 100644 index 1dea8aaa7a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_sum_keyword_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -import numpy -import datetime - -# Observe that there is some convention conflict with the C code -# regarding order of arguments: The C code generally takes the time -# index as the first argument and the key/key_index as second -# argument. In the python code this order has been reversed. - -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype - - - -class EclSumKeyWordVector(BaseCClass): - TYPE_NAME = "ecl_sum_vector" - _alloc = EclPrototype("void* ecl_sum_vector_alloc(ecl_sum)", bind=False) - _free = EclPrototype("void ecl_sum_vector_free(ecl_sum_vector)") - _add = EclPrototype("bool ecl_sum_vector_add_key(ecl_sum_vector, char*)") - _add_multiple = EclPrototype("void ecl_sum_vector_add_keys(ecl_sum_vector, char*)") - _get_size = EclPrototype("int ecl_sum_vector_get_size(ecl_sum_vector)") - _iget_key = EclPrototype("char* ecl_sum_vector_iget_key(ecl_sum_vector, int)") - - def __init__(self, ecl_sum): - c_pointer = self._alloc(ecl_sum) - super(EclSumKeyWordVector, self).__init__(c_pointer) - - def __getitem__(self, index): - if index < 0: - index += len(self) - - if index >= len(self): - raise IndexError("Out of range") - - return self._iget_key( index ) - - def __len__(self): - return self._get_size() - - def free(self): - self._free() - - def add_keyword(self, keyword): - success = self._add(keyword) - if not success: - raise KeyError("Failed to add keyword to vector") - - def add_keywords(self, keyword_pattern): - self._add_multiple(keyword_pattern) - - def __repr__(self): - return self._create_repr('len=%d' % len(self)) - -monkey_the_camel(EclSumKeyWordVector, 'addKeyword', EclSumKeyWordVector.add_keyword) -monkey_the_camel(EclSumKeyWordVector, 'addKeywords', EclSumKeyWordVector.add_keywords) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py deleted file mode 100644 index ed4ccfc680..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py +++ /dev/null @@ -1,28 +0,0 @@ -class EclSumNode(object): - - def __init__(self, mini_step, report_step, days, date, mpl_date, value): - """ - EclSumNode is a 'struct' with a summary value and time. - - EclSumNode - a small 'struct' with a summary value and time in - several formats. When iterating over a EclSumVector instance - you will get EclSumNode instances. The content of the - EclSumNode type is stored as plain attributes: - - value : The actual value - report_step : The report step - mini_step : The ministep - days : Days since simulation start - date : The simulation date - mpl_date : A date format suitable for matplotlib - - """ - self.value = value - self.report_step = report_step - self.mini_step = mini_step - self.days = days - self.date = date - self.mpl_date = mpl_date - - def __repr__(self): - return "EclSumNode(days=%d, value=%g)" % (self.days, self.value) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py deleted file mode 100644 index 3a759ae9c5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype - - - -class EclSumTStep(BaseCClass): - TYPE_NAME = "ecl_sum_tstep" - _alloc = EclPrototype("void* ecl_sum_tstep_alloc_new(int, int, float, void*)", bind=False) - _free = EclPrototype("void ecl_sum_tstep_free(ecl_sum_tstep)") - _get_sim_days = EclPrototype("double ecl_sum_tstep_get_sim_days(ecl_sum_tstep)") - _get_sim_time = EclPrototype("time_t ecl_sum_tstep_get_sim_time(ecl_sum_tstep)") - _get_report = EclPrototype("int ecl_sum_tstep_get_report(ecl_sum_tstep)") - _get_ministep = EclPrototype("int ecl_sum_tstep_get_ministep(ecl_sum_tstep)") - _set_from_key = EclPrototype("void ecl_sum_tstep_set_from_key(ecl_sum_tstep, char*, float)") - _get_from_key = EclPrototype("double ecl_sum_tstep_get_from_key(ecl_sum_tstep, char*)") - _has_key = EclPrototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep)") - - - - def __init__(self, report_step, mini_step, sim_days, smspec): - sim_seconds = sim_days * 24 * 60 * 60 - c_pointer = self._alloc(report_step, mini_step, sim_seconds, smspec) - super(EclSumTStep, self).__init__(c_pointer) - - - def get_sim_days(self): - """ @rtype: double """ - return self._get_sim_days() - - def get_report(self): - """ @rtype: int """ - return self._get_report() - - def get_mini_step(self): - """ @rtype: int """ - return self._get_ministep() - - def get_sim_time(self): - """ @rtype: CTime """ - return self._get_sim_time() - - def __getitem__(self, key): - """ @rtype: double """ - if not key in self: - raise KeyError("Key '%s' is not available." % key) - - return self._get_from_key(key) - - def __setitem__(self, key, value): - if not key in self: - raise KeyError("Key '%s' is not available." % key) - - self._set_from_key(key, value) - - def __contains__(self, key): - return self._has_key(key) - - def free(self): - self._free(self) - -monkey_the_camel(EclSumTStep, 'getSimDays', EclSumTStep.get_sim_days) -monkey_the_camel(EclSumTStep, 'getReport', EclSumTStep.get_report) -monkey_the_camel(EclSumTStep, 'getMiniStep', EclSumTStep.get_mini_step) -monkey_the_camel(EclSumTStep, 'getSimTime', EclSumTStep.get_sim_time) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py deleted file mode 100644 index d9f9e8cf99..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# The file 'ecl_sum_var_type.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCEnum -from ecl.ecl import ECL_LIB - - -class EclSumVarType(BaseCEnum): - TYPE_NAME = "ecl_sum_var_type" - ECL_SMSPEC_INVALID_VAR = None - ECL_SMSPEC_FIELD_VAR = None - ECL_SMSPEC_REGION_VAR = None - ECL_SMSPEC_GROUP_VAR = None - ECL_SMSPEC_WELL_VAR = None - ECL_SMSPEC_SEGMENT_VAR = None - ECL_SMSPEC_BLOCK_VAR = None - ECL_SMSPEC_AQUIFER_VAR = None - ECL_SMSPEC_COMPLETION_VAR = None - ECL_SMSPEC_NETWORK_VAR = None - ECL_SMSPEC_REGION_2_REGION_VAR = None - ECL_SMSPEC_LOCAL_BLOCK_VAR = None - ECL_SMSPEC_LOCAL_COMPLETION_VAR = None - ECL_SMSPEC_LOCAL_WELL_VAR = None - ECL_SMSPEC_MISC_VAR = None - - -EclSumVarType.addEnum("ECL_SMSPEC_INVALID_VAR", 0) -EclSumVarType.addEnum("ECL_SMSPEC_FIELD_VAR", 1) -EclSumVarType.addEnum("ECL_SMSPEC_REGION_VAR", 2) -EclSumVarType.addEnum("ECL_SMSPEC_GROUP_VAR", 3) -EclSumVarType.addEnum("ECL_SMSPEC_WELL_VAR", 4) -EclSumVarType.addEnum("ECL_SMSPEC_SEGMENT_VAR", 5) -EclSumVarType.addEnum("ECL_SMSPEC_BLOCK_VAR", 6) -EclSumVarType.addEnum("ECL_SMSPEC_AQUIFER_VAR", 7) -EclSumVarType.addEnum("ECL_SMSPEC_COMPLETION_VAR", 8) -EclSumVarType.addEnum("ECL_SMSPEC_NETWORK_VAR", 9) -EclSumVarType.addEnum("ECL_SMSPEC_REGION_2_REGION_VAR", 10) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_BLOCK_VAR", 11) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_COMPLETION_VAR", 12) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_WELL_VAR", 13) -EclSumVarType.addEnum("ECL_SMSPEC_MISC_VAR", 14) - - diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py deleted file mode 100644 index 5cde9f119a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py +++ /dev/null @@ -1,304 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function -import warnings -from ecl.ecl.ecl_sum_node import EclSumNode - - -class EclSumVector(object): - def __init__(self, parent, key, report_only = False): - """ - A summary vector with a vector of values and time. - - A summary vector contains the the full time history of one - key, along with the corresponding time vectors in several - different time formats. Depending on the report_only argument - the data vectors in the EclSumVector can either contain all - the time values, or only those corresponding to report_steps. - - The EclSumVector contains a reference to the parent EclSum - structure and this is used to implement several of the - properties and methods of the object; the EclSum vector - instances should therefor only be instantiated through the - EclSum.get_vector() method, and not manually with the - EclSumVector() constructor. - """ - self.parent = parent - self.key = key - self.report_only = report_only - - if report_only: - warnings.warn("The report_only flag to the EclSumVector will be removed", DeprecationWarning) - - self.__dates = parent.get_dates(report_only) - self.__days = parent.get_days(report_only) - self.__mpl_dates = parent.get_mpl_dates(report_only) - self.__mini_step = parent.get_mini_step(report_only) - self.__report_step = parent.get_report_step(report_only) - self.__values = None - - - def __str__(self): - return "

" % self.key - - def __repr__(self): - return 'EclSumVector(key = %s, size = %d, unit = %s)' % (self.key, len(self), self.unit) - - @property - def unit(self): - """ - The unit of this vector. - """ - return self.parent.unit(self.key) - - def assert_values(self): - """ - This function will load and internalize all the values. - """ - if self.__values is None: - self.__values = self.parent.get_values(self.key, self.report_only) - - @property - def values(self): - """ - All the summary values of the vector, as a numpy vector. - """ - self.assert_values() - return self.__values - - @property - def dates(self): - """ - All the dates of the vector, list of datetime() instances. - """ - return self.__dates - - @property - def days(self): - """ - The time in days as a numpy vector. - - In the case of lab unit this will be hours. - """ - return self.__days - - @property - def mpl_dates(self): - """ - All the dates as numpy vector of dates in matplotlib format. - """ - return self.__mpl_dates - - @property - def mini_step(self): - """ - All the ministeps of the vector. - - Ministeps is the ECLIPSE notion of timesteps. The ministeps - are numbered sequentially starting at zero; if you have loaded - the entire simulation the ministep number will correspond to - the natural indexing. The length of each ministep is - determined by the convergence properties of the ECLIPSE - simulation. - """ - return self.__mini_step - - @property - def report_step(self): - """ - All the report_step of the vector. - """ - return self.__report_step - - - def __iget(self, index): - """ - Will return an EclSumNode for element @index; should be called - through the [] operator, otherwise you can come across - unitialized data. - """ - return EclSumNode(self.__mini_step[index], - self.__report_step[index], - self.__days[index], - self.__dates[index], - self.__mpl_dates[index], - self.__values[index]) - - - def __len__(self): - """ - The length of the vector - used for the len() builtin. - """ - return len(self.__days) - - - def __getitem__(self, index): - """ - Implements the [] operator. - - Will return EclSumNode instance according to @index. The index - value will be interpreted as in a normal python [] lookup, - i.e. negative values will be interpreted as starting from the - right and also slice notation is allowed[*]. - - [*] Observe that in the case of slices the return value will - not be a proper EclSumVector instance, but rather a normal - Python list of EclSumNode instances. - """ - self.assert_values() - length = len(self.values) - if isinstance(index, int): - if index < 0: - index += len(self.__values) - if index < 0 or index > length: - raise KeyError("Invalid index:%d out of range [0:%d)" % (index, length)) - else: - return self.__iget(index) - elif isinstance(index, slice): - # Observe that the slice based lookup does __not__ return - # a proper EclSumVector instance; it will merely return - # a simple Python list with EclSumNode instances. - (start, stop, step) = index.indices(length) - index = start - sub_vector = [] - while index < stop: - sub_vector.append(self.__iget(index)) - index += step - return sub_vector - - raise KeyError("Invalid index:%s - must have integer or slice." % index) - - @property - def first(self): - """ - Will return the first EclSumNode in this vector. - """ - self.assert_values() - return self.__iget(0) - - @property - def last(self): - """ - Will return the last EclSumNode in this vector. - """ - self.assert_values() - - index = len(self.__values) - 1 - return self.__iget(index) - - @property - def last_value(self): - """ - Will return the last value in this vector. - """ - self.assert_values() - - index = len(self.__values) - 1 - return self.__iget(index).value - - - def get_interp(self, days=None, date=None): - """ - Will lookup value interpolated to @days or @date. - - The function requires one, and only one, time indicator in - terms of @days or @date. If the @date variable is given that - should be Python datetime instance. - - vec = sum["WWCT:A-3"] - vec.get_interp(days = 100) - vec.get_interp(date = datetime.date(year, month, day)) - - This function will crash and burn if the time arguments are - invalid; if in doubt you should check first. - """ - return self.parent.get_interp(self.key, days, date) - - - def get_interp_vector(self, days_list=None, date_list=None): - """ - Will return Python list of interpolated values. - - See get_interp() for further details. - """ - return self.parent.get_interp_vector(self.key, days_list, date_list) - - - def get_from_report(self, report_step): - """ - Will lookup the value based on @report_step. - """ - return self.parent.get_from_report(self.key, report_step) - - ################################################################# - - def first_gt_index(self, limit): - """ - Locates first index where the value is above @limit. - - Observe that this method will raise an exception if it is - called from a vector instance with report_only = True. - """ - if not self.report_only: - key_index = self.parent._get_general_var_index(self.key) - time_index = self.parent._get_first_gt(key_index, limit) - return time_index - else: - raise Exception("Sorry - first_gt_index() can not be called for vectors with report_only=True") - - def first_gt(self, limit): - """ - Locate the first EclSumNode where value is above @limit. - - vec = sum["WWCT:A-3"] - w = vec.first_gt(0.50) - print('Water cut above 0.50 in well A-3 at: %s' % w.date) - - Uses first_gt_index() internally and can not be called for - vectors with report_only = True. - """ - time_index = self.first_gt_index(limit) - print(time_index) - if time_index >= 0: - return self.__iget(time_index) - else: - return None - - def first_lt_index(self, limit): - """ - Locates first index where the value is below @limit. - - See first_gt_index() for further details. - """ - if not self.report_only: - key_index = self.parent._get_general_var_index(self.key) - time_index = self.parent._get_first_lt(key_index, limit) - return time_index - else: - raise Exception("Sorry - first_lt_index() can not be called for vectors with report_only=True") - - def first_lt(self, limit): - """ - Locates first element where the value is below @limit. - - See first_gt() for further details. - """ - time_index = self.first_lt_index(limit) - if time_index >= 0: - return self.__iget(time_index) - else: - return None diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py deleted file mode 100644 index 1ac3cc6556..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'ecl_type.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass, BaseCEnum -from ecl.ecl import EclPrototype - -class EclTypeEnum(BaseCEnum): - TYPE_NAME="ecl_type_enum" - ECL_CHAR_TYPE = None - ECL_FLOAT_TYPE = None - ECL_DOUBLE_TYPE = None - ECL_INT_TYPE = None - ECL_BOOL_TYPE = None - ECL_MESS_TYPE = None - ECL_STRING_TYPE = None - -EclTypeEnum.addEnum("ECL_CHAR_TYPE", 0) -EclTypeEnum.addEnum("ECL_FLOAT_TYPE", 1) -EclTypeEnum.addEnum("ECL_DOUBLE_TYPE", 2) -EclTypeEnum.addEnum("ECL_INT_TYPE", 3) -EclTypeEnum.addEnum("ECL_BOOL_TYPE", 4) -EclTypeEnum.addEnum("ECL_MESS_TYPE", 5) -EclTypeEnum.addEnum("ECL_STRING_TYPE", 7) - -#----------------------------------------------------------------- - -class EclDataType(BaseCClass): - - TYPE_NAME = "ecl_data_type" - - _alloc = EclPrototype("void* ecl_type_alloc_python(ecl_type_enum, size_t)", bind=False) - _alloc_from_type = EclPrototype("void* ecl_type_alloc_from_type_python(ecl_type_enum)", bind=False) - _alloc_from_name = EclPrototype("void* ecl_type_alloc_from_name_python(char*)", bind=False) - _free = EclPrototype("void ecl_type_free_python(ecl_data_type)") - _get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)") - _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_fortio_python(ecl_data_type)") - _is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)") - _is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)") - _is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)") - _is_double = EclPrototype("bool ecl_type_is_double_python(ecl_data_type)") - _is_mess = EclPrototype("bool ecl_type_is_mess_python(ecl_data_type)") - _is_bool = EclPrototype("bool ecl_type_is_bool_python(ecl_data_type)") - _is_string = EclPrototype("bool ecl_type_is_string_python(ecl_data_type)") - _get_name = EclPrototype("char* ecl_type_alloc_name_python(ecl_data_type)") - _is_numeric = EclPrototype("bool ecl_type_is_numeric_python(ecl_data_type)") - _is_equal = EclPrototype("bool ecl_type_is_equal_python(ecl_data_type, ecl_data_type)") - - def __init__(self, type_enum=None, element_size=None, type_name=None): - self._assert_valid_arguments(type_enum, element_size, type_name) - - if type_name: - c_ptr = self._alloc_from_name(type_name) - elif element_size is None: - c_ptr = self._alloc_from_type(type_enum) - else: - c_ptr = self._alloc(type_enum, element_size) - - super(EclDataType, self).__init__(c_ptr) - - def _assert_valid_arguments(self, type_enum, element_size, type_name): - if type_name is not None: - if type_enum is not None or element_size is not None: - err_msg = ("Type name given (%s). Expected both " + - "type_enum and element_size to be None") - raise ValueError(err_msg % type_name) - - elif type_enum is None: - raise ValueError("Both type_enum and type_name is None!") - - elif type_enum == EclTypeEnum.ECL_STRING_TYPE: - if element_size is None: - raise ValueError("When creating an ECL_STRING one must " + - "provide an element size!") - - if not (0 <= element_size <= 999): - raise ValueError("Expected element_size to be in the range " + - "[0, 999], was: %d" % element_size) - - @property - def type(self): - return self._get_type() - - @property - def element_size(self): - return self._get_element_size() - - @property - def type_name(self): - return self._get_name() - - def free(self): - self._free() - - def is_int(self): - return self._is_int() - - def is_char(self): - return self._is_char() - - def is_float(self): - return self._is_float() - - def is_double(self): - return self._is_double() - - def is_mess(self): - return self._is_mess() - - def is_bool(self): - return self._is_bool() - - def is_string(self): - return self._is_string() - - def is_numeric(self): - return self._is_numeric() - - def is_equal(self, other): - return self._is_equal(other) - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.is_equal(other) - return False - - def __ne__(self, other): - return not self.__eq__(other) - - def __hash__(self): - return hash((self.type, self. element_size)) - - @classmethod - def create_from_type_name(cls, name): - return EclDataType(type_name=name) - - # Enables one to fetch a type as EclDataType.ECL_XXXX - class classproperty(object): - - def __init__(self, fget): - self.fget = fget - - def __get__(self, owner_self, owner_cls): - return self.fget(owner_cls) - - @classproperty - def ECL_INT(cls): - return EclDataType(EclTypeEnum.ECL_INT_TYPE) - - @classproperty - def ECL_FLOAT(cls): - return EclDataType(EclTypeEnum.ECL_FLOAT_TYPE) - - @classproperty - def ECL_DOUBLE(cls): - return EclDataType(EclTypeEnum.ECL_DOUBLE_TYPE) - - @classproperty - def ECL_BOOL(cls): - return EclDataType(EclTypeEnum.ECL_BOOL_TYPE) - - @classproperty - def ECL_MESS(cls): - return EclDataType(EclTypeEnum.ECL_MESS_TYPE) - - @classproperty - def ECL_CHAR(cls): - return EclDataType(EclTypeEnum.ECL_CHAR_TYPE) - - @classmethod - def ECL_STRING(cls, elem_size): - return EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py b/ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py deleted file mode 100644 index b7f4f19b05..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py +++ /dev/null @@ -1,166 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_util.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Constants from the header ecl_util.h - some stateless functions. - -This module does not contain any class definitions; it mostly consists -of enum definitions/values from ecl_util.h; the enum values are -extracted from the shared library in a semi-automagic manner using the -BaseCEnum class from cwrap. - -In addition to the enum definitions there are a few stateless -functions from ecl_util.c which are not bound to any class type. -""" - -import ctypes - -from cwrap import BaseCEnum -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype, ECL_LIB - -class EclFileEnum(BaseCEnum): - TYPE_NAME = "ecl_file_enum" - ECL_OTHER_FILE = None - ECL_RESTART_FILE = None - ECL_UNIFIED_RESTART_FILE = None - ECL_SUMMARY_FILE = None - ECL_UNIFIED_SUMMARY_FILE = None - ECL_GRID_FILE = None - ECL_EGRID_FILE = None - ECL_INIT_FILE = None - ECL_RFT_FILE = None - ECL_DATA_FILE = None - - -EclFileEnum.addEnum("ECL_OTHER_FILE", 0) -EclFileEnum.addEnum("ECL_RESTART_FILE", 1) -EclFileEnum.addEnum("ECL_UNIFIED_RESTART_FILE", 2) -EclFileEnum.addEnum("ECL_SUMMARY_FILE", 4) -EclFileEnum.addEnum("ECL_UNIFIED_SUMMARY_FILE", 8) -EclFileEnum.addEnum("ECL_SUMMARY_HEADER_FILE", 16) -EclFileEnum.addEnum("ECL_GRID_FILE", 32) -EclFileEnum.addEnum("ECL_EGRID_FILE", 64) -EclFileEnum.addEnum("ECL_INIT_FILE", 128) -EclFileEnum.addEnum("ECL_RFT_FILE", 256) -EclFileEnum.addEnum("ECL_DATA_FILE", 512) - - -#----------------------------------------------------------------- - -class EclPhaseEnum(BaseCEnum): - TYPE_NAME="ecl_phase_enum" - ECL_OIL_PHASE = None - ECL_GAS_PHASE = None - ECL_WATER_PHASE = None - -EclPhaseEnum.addEnum("ECL_OIL_PHASE", 1) -EclPhaseEnum.addEnum("ECL_GAS_PHASE", 2) -EclPhaseEnum.addEnum("ECL_WATER_PHASE", 4) - - -#----------------------------------------------------------------- - -class EclUnitTypeEnum(BaseCEnum): - TYPE_NAME = "ecl_unit_enum" - - ECL_METRIC_UNITS = None - ECL_FIELD_UNITS = None - ECL_LAB_UNITS = None - ECL_PVT_M_UNITS = None - -EclUnitTypeEnum.addEnum("ECL_METRIC_UNITS", 1) -EclUnitTypeEnum.addEnum("ECL_FIELD_UNITS", 2) -EclUnitTypeEnum.addEnum("ECL_LAB_UNITS", 3) -EclUnitTypeEnum.addEnum("ECL_PVT_M_UNITS", 4) - - - -#----------------------------------------------------------------- - -class EclFileFlagEnum(BaseCEnum): - TYPE_NAME="ecl_file_flag_enum" - ECL_FILE_CLOSE_STREAM = None - ECL_FILE_WRITABLE = None - -EclFileFlagEnum.addEnum("ECL_FILE_CLOSE_STREAM", 1) -EclFileFlagEnum.addEnum("ECL_FILE_WRITABLE", 2) - - -#----------------------------------------------------------------- - -class EclUtil(object): - _get_num_cpu = EclPrototype("int ecl_util_get_num_cpu(char*)", bind = False) - _get_file_type = EclPrototype("ecl_file_enum ecl_util_get_file_type(char*, bool*, int*)", bind = False) - _get_start_date = EclPrototype("time_t ecl_util_get_start_date(char*)", bind = False) - _get_report_step = EclPrototype("int ecl_util_filename_report_nr(char*)", bind = False) - - - @staticmethod - def get_num_cpu(datafile): - """ - Parse ECLIPSE datafile and determine how many CPUs are needed. - - Will look for the "PARALLELL" keyword, and then read off the - number of CPUs required. Will return one if no PARALLELL keyword - is found. - """ - return EclUtil._get_num_cpu(datafile) - - @staticmethod - def get_file_type(filename): - """ - Will inspect an ECLIPSE filename and return an integer type flag. - """ - file_type, fmt, step = EclUtil.inspectExtension(filename) - return file_type - - @staticmethod - def get_start_date(datafile): - return EclUtil._get_start_date(datafile).datetime() - - @staticmethod - def inspect_extension(filename): - """Will inspect an ECLIPSE filename and return a tuple consisting of - file type (EclFileEnum), a bool for formatted or not, and an - integer for the step number. - - """ - fmt_file = ctypes.c_bool() - report_step = ctypes.c_int(-1) - file_type = EclUtil._get_file_type(filename, ctypes.byref(fmt_file), ctypes.byref(report_step)) - if report_step.value == -1: - step = None - else: - step = report_step.value - - return (file_type, fmt_file.value, step) - - @staticmethod - def report_step(filename): - report_step = EclUtil._get_report_step(filename) - if report_step < 0: - raise ValueError("Could not infer report step from: %s" % filename) - - return report_step - - - -get_num_cpu = EclUtil.get_num_cpu -get_file_type = EclUtil.get_file_type -get_start_date = EclUtil.get_start_date - -monkey_the_camel(EclUtil, 'inspectExtension', EclUtil.inspect_extension, staticmethod) -monkey_the_camel(EclUtil, 'reportStep', EclUtil.report_step, staticmethod) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt deleted file mode 100644 index d7955a8c6e..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - fault_block.py - fault_block_layer.py - fault_collection.py - fault.py - fault_line.py - fault_segments.py - layer.py -) - -add_python_package("python.ecl.ecl.faults" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/faults "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py deleted file mode 100644 index cc9670e15c..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .layer import Layer -from .fault_collection import FaultCollection -from .fault import Fault -from .fault_line import FaultLine -from .fault_segments import FaultSegment , SegmentMap -from .fault_block import FaultBlock , FaultBlockCell -from .fault_block_layer import FaultBlockLayer diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py deleted file mode 100644 index ae62f8b582..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py +++ /dev/null @@ -1,654 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.util import monkey_the_camel -from ecl.util import stat -from ecl.util import Matrix -from ecl.geo import Polyline, CPolyline, GeometryTools - -from .fault_line import FaultLine -from .fault_segments import FaultSegment, SegmentMap - - -class FaultLayer(object): - def __init__(self, grid, K): - assert(isinstance(K, int)) - self.__grid = grid - self.__K = K - self.__fault_lines = [] - self.__segment_map = SegmentMap() - self.__processed = False - - - def add_segment(self, segment): - self.__segment_map.addSegment(segment) - self.__processed = False - - def __len__(self): - self.processSegments() - return len(self.__fault_lines) - - def __iter__(self): - self.processSegments() - return iter(self.__fault_lines) - - def __getitem__(self, index): - self.processSegments() - return self.__fault_lines[index] - - def get_k(self): - return self.__K - - @property - def k(self): - return self.__K - - - def get_neighbor_cells(self): - neighbor_cells = [] - for fl in self: - neighbor_cells += fl.getNeighborCells() - return neighbor_cells - - def get_polyline(self, name=None): - polyline = CPolyline(name=name) - for fl in self: - polyline += fl.getPolyline() - return polyline - - - def get_ij_polyline(self): - """ - Will return a python list of (int,int) tuple. - """ - polyline = [] - for fl in self: - polyline += fl.getIJPolyline() - return polyline - - - def num_lines(self): - return len(self) - - def __sort_fault_lines(self): - """A fault can typically consist of several non connected fault - segments; right after reading the fault input these can be in - a complete mess: - - 1. The different part of the fault can be in random order. - - 2. Within each fault line the micro segments can be ordered in - reverse. - - This method goes through some desparate heuristics trying to sort - things out. - - """ - - N = len(self.__fault_lines) - x = Matrix(N, 1) - y = Matrix(N, 1) - - for index,line in enumerate(self.__fault_lines): - xc,yc = line.center() - - x[index,0] = xc - y[index,0] = yc - - # y = beta[0] + beta[1] * x - # = a + b * x - beta = stat.polyfit(2, x, y) - a = beta[0] - b = beta[1] - - perm_list = [] - for index,line in enumerate(self.__fault_lines): - x0, y0 = line.center() - d = x0 + b*(y0 - a) - perm_list.append((index, d)) - perm_list.sort(key=lambda x: x[1]) - - fault_lines = [] - for (index,d) in perm_list: - fault_lines.append(self.__fault_lines[ index ]) - self.__fault_lines = fault_lines - - - for line in self.__fault_lines: - x1,y1 = line.startPoint() - x2,y2 = line.endPoint() - d1 = x1 + b*(y1 - a) - d2 = x2 + b*(y2 - a) - - if d1 > d2: - line.reverse() - - - - - def process_segments(self): - if self.__processed: - return - - while self.__segment_map: - fault_line = FaultLine(self.__grid, self.__K) - self.__fault_lines.append(fault_line) - - current_segment = self.__segment_map.popStart() - while current_segment: - append = fault_line.tryAppend(current_segment) - if not append: - fault_line = FaultLine(self.__grid, self.__K) - self.__fault_lines.append(fault_line) - fault_line.tryAppend(current_segment) - - current_segment.next_segment = self.__segment_map.popNext(current_segment) - current_segment = current_segment.next_segment - - if len(self.__fault_lines) > 1: - self.__sort_fault_lines() - - self.__processed = True - - -################################################################# - - -class Fault(object): - allowed_faces = ["X","Y","Z","I","J","K","X-","Y-","Z-","I-","J-","K-"] - - def __init__(self, grid, name): - self.__grid = grid - self.__name = name - self.__layer_map = {} - self.__layer_list = [] - (self.nx, self.ny, self.nz, nactive) = grid.getDims() - - - def __str__(self): - return "Fault:%s" % self.__name - - def __getitem__(self, K): - if not self.hasLayer(K): - self.addLayer(K) - layer = self.__layer_map[K] - return layer - - def __len__(self): - return len(self.__layer_map) - - - def __iter__(self): - for layer in self.__layer_list: - yield layer - - - def has_layer(self, K): - return self.__layer_map.has_key(K) - - - def add_layer(self, K): - layer = FaultLayer(self.__grid, K) - self.__layer_map[K] = layer - self.__layer_list.append(layer) - - - def create_segment(self, I1, I2, J1, J2, face): - if face in ["X", "I"]: - C1 = I1 + 1 + J1*(self.nx + 1) - C2 = C1 + (1 + J2 - J1) * (self.nx + 1) - elif face in ["X-", "I-"]: - C1 = I1 + J1*(self.nx + 1) - C2 = C1 + (1 + J2 - J1) * (self.nx + 1) - elif face in ["Y", "J"]: - C1 = I1 + (J1 + 1) * (self.nx + 1) - C2 = C1 + (1 + I2 - I1) - elif face in ["Y-", "J-"]: - C1 = I1 + J1 * (self.nx + 1) - C2 = C1 + (1 + I2 - I1) - else: - return None - - return FaultSegment(C1,C2) - - - - def add_record(self, I1, I2, J1, J2, K1, K2, face): - if not face in Fault.allowed_faces: - raise ValueError("Invalid face:%s" % face) - - if I1 > I2: - raise ValueError("Invalid I1 I2 indices") - - if J1 > J2: - raise ValueError("Invalid J1 J2 indices") - - if K1 > K2: - raise ValueError("Invalid K1 K2 indices") - - if I1 < 0 or I1 >= self.nx: - raise ValueError("Invalid I1:%d" % I1) - if I2 < 0 or I2 >= self.nx: - raise ValueError("Invalid I2:%d" % I2) - - if J1 < 0 or J1 >= self.ny: - raise ValueError("Invalid J1:%d" % J1) - if J2 < 0 or J2 >= self.ny: - raise ValueError("Invalid J2:%d" % J2) - - if K1 < 0 or K1 >= self.nz: - raise ValueError("Invalid K1:%d" % K1) - if K2 < 0 or K2 >= self.nz: - raise ValueError("Invalid K2:%d" % K2) - - if face in ["X","I"]: - if I1 != I2: - raise ValueError("For face:%s we must have I1 == I2" % face) - - if face in ["Y","J"]: - if J1 != J2: - raise ValueError("For face:%s we must have J1 == J2" % face) - - if face in ["Z","K"]: - if K1 != K2: - raise ValueError("For face:%s we must have K1 == K2" % face) - - #----------------------------------------------------------------- - - for K in range(K1,K2+1): - if not self.hasLayer(K): - self.addLayer(K) - layer = self.__layer_map[K] - segment = self.createSegment(I1,I2,J1,J2,face) - if segment: - layer.addSegment(segment) - - - - @property - def name(self): - return self.__name - - def get_name(self): - return self.__name - - - def get_neighbor_cells(self): - neighbor_cells = [] - for layer in self: - neighbor_cells += layer.getNeighborCells() - return neighbor_cells - - - def get_polyline(self, k): - layer = self[k] - return layer.getPolyline(name="Polyline[%s]" % self.getName()) - - - def get_ij_polyline(self, k): - layer = self[k] - return layer.getIJPolyline() - - - def num_lines(self, k): - layer = self[k] - return layer.numLines() - - - @staticmethod - def __ray_intersect(p0, p1, polyline): - ray_dir = GeometryTools.lineToRay(p0, p1) - intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, polyline) - if intersections: - if len(intersections) > 1: - d_list = [ GeometryTools.distance(p1, p[1]) for p in intersections ] - index = d_list.index(min(d_list)) - else: - index = 0 - p2 = intersections[index][1] - return [p1, p2] - else: - return None - - - def connect_with_polyline(self, polyline, k): - """ - """ - if self.intersectsPolyline(polyline, k): - return None - else: - self_polyline = self.getPolyline(k) - if len(self_polyline) > 0: - return self_polyline.connect(polyline) - else: - return None - - - def connect(self, target, k): - if isinstance(target, Fault): - polyline = target.getPolyline(k) - else: - polyline = target - return self.connectWithPolyline(polyline, k) - - - - def extend_to_polyline(self, polyline, k): - """Extends the fault until it intersects @polyline in layer @k. - - The return value is a list [(x1,y1), (x2,y2)] where (x1,y1) - is on the tip of the fault, and (x2,y2) is on the polyline. If - the fault already intersects polyline None is returned, if no - intersection is found a ValueError exception is raised. - - The method will try four different strategies for finding an - intersection between the extension of the fault and the - polyline. Assume the fault and the polyline looks like: - - - Polyline: ---------------------------------------------- - - +------------+ D - | | | - | +-------C - B-----+ - | - A - - The algorithm will then try to intersect the following rays - with the polyline, the first match will return: - - 1. (Pc, Pd) - 2. (Pb, Pa) - 3. (Pa, Pd) - 4. (Pd, Pa) - - The fault object is not directed in any way; i.e. in the case - both (Pc,Pd) and (Pb,Pa) intersects the polyline it is - impossible to know which intersection is returned, without - actually consulting the construction of the fault object. - """ - if self.intersectsPolyline(polyline, k): - return None - - fault_polyline = self.getPolyline(k) - p0 = fault_polyline[-2] - p1 = fault_polyline[-1] - extension = self.__ray_intersect(p0, p1, polyline) - if extension: - return extension - - p0 = fault_polyline[1] - p1 = fault_polyline[0] - extension = self.__ray_intersect(p0, p1, polyline) - if extension: - return extension - - p0 = fault_polyline[0] - p1 = fault_polyline[-1] - extension = self.__ray_intersect(p0, p1, polyline) - if extension: - return extension - - p0 = fault_polyline[-1] - p1 = fault_polyline[0] - extension = self.__ray_intersect(p0, p1, polyline) - if extension: - return extension - - raise ValueError("The fault %s can not be extended to intersect with polyline:%s in layer:%d" % (self.getName(), polyline.getName(), k+1)) - - - - def intersects_polyline(self, polyline, k): - fault_line = self.getPolyline(k) - return fault_line.intersects(polyline) - - - def intersects_fault(self, other_fault, k): - fault_line = other_fault.getPolyline(k) - return self.intersectsPolyline(fault_line, k) - - def extend_to_fault(self, fault, k): - fault_line = fault.getPolyline(k) - return self.extendToPolyline(fault_line, k) - - def extend_to_edge(self, edge, k): - if isinstance(edge, Fault): - return self.extendToFault(edge, k) - else: - return self.extendToPolyline(edge, k) - - - def extend_to_b_box(self, bbox, k, start=True): - fault_polyline = self.getPolyline(k) - if start: - p0 = fault_polyline[1] - p1 = fault_polyline[0] - else: - p0 = fault_polyline[-2] - p1 = fault_polyline[-1] - - ray_dir = GeometryTools.lineToRay(p0,p1) - intersections = GeometryTools.rayPolygonIntersections(p1, ray_dir, bbox) - if intersections: - p2 = intersections[0][1] - if self.getName(): - name = "Extend:%s" % self.getName() - else: - name = None - - return CPolyline(name=name, init_points=[(p1[0], p1[1]), p2]) - else: - raise Exception("Logical error - must intersect with bounding box") - - - def end_join(self, other, k): - fault_polyline = self.getPolyline(k) - - if isinstance(other, Fault): - other_polyline = other.getPolyline(k) - else: - other_polyline = other - - return GeometryTools.joinPolylines(fault_polyline, other_polyline) - - - - def connect_polyline_onto(self, polyline, k): - if self.intersectsPolyline(polyline, k): - return None - - self_polyline = self.getPolyline(k) - return polyline.connect(self_polyline) - - - - def extend_polyline_onto(self, polyline, k): - if self.intersectsPolyline(polyline, k): - return None - - if len(polyline) > 1: - fault_polyline = self.getPolyline(k) - ext1 = self.__ray_intersect(polyline[-2], polyline[-1], fault_polyline) - ext2 = self.__ray_intersect(polyline[0] , polyline[1] , fault_polyline) - - if ext1 and ext2: - d1 = GeometryTools.distance(ext1[0], ext1[1]) - d2 = GeometryTools.distance(ext2[0], ext2[1]) - - if d1 < d2: - return ext1 - else: - return ext2 - - if ext1: - return ext1 - else: - return ext2 - else: - raise ValueError("Polyline must have length >= 2") - - - - @staticmethod - def intersect_fault_rays(ray1, ray2): - p1,dir1 = ray1 - p2,dir2 = ray2 - if p1 == p2: - return [] - - dx = p2[0] - p1[0] - dy = p2[1] - p1[1] - if dx != 0: - if dir1[0] * dx <= 0 and dir2[0] * dx >= 0: - raise ValueError("Rays will never intersect") - - if dy != 0: - if dir1[1] * dy <= 0 and dir2[1] * dy >= 0: - raise ValueError("Rays will never intersect") - - if dx*dy != 0: - if dir1[0] != 0: - xc = p2[0] - yc = p1[1] - else: - xc = p1[0] - yc = p2[1] - - coord_list = [p1, (xc,yc), p2] - else: - coord_list = [p1,p2] - - return coord_list - - - @staticmethod - def int_ray(p1,p2): - if p1 == p2: - raise Exception("Can not form ray from coincident points") - - if p1[0] == p2[0]: - # Vertical line - dx = 0 - if p2[1] > p1[1]: - dy = 1 - elif p2[1] < p1[1]: - dy = -1 - else: - # Horizontal line - if p2[1] != p1[1]: - raise Exception("Invalid direction") - - dy = 0 - if p2[0] > p1[0]: - dx = 1 - else: - dx = -1 - - return [p2, (dx,dy)] - - - - def get_end_rays(self, k): - polyline = self.getIJPolyline(k) - - p0 = polyline[0] - p1 = polyline[1] - p2 = polyline[-2] - p3 = polyline[-1] - - return (Fault.intRay(p1,p0), Fault.intRay(p2,p3)) - - - - - @staticmethod - def join_faults(fault1, fault2, k): - fault1_rays = fault1.getEndRays(k) - fault2_rays = fault2.getEndRays(k) - - if fault1.intersectsFault(fault2, k): - return None - - count = 0 - join = None - try: - join = Fault.intersectFaultRays(fault1_rays[0], fault2_rays[0]) - count += 1 - except ValueError: - pass - - try: - join = Fault.intersectFaultRays(fault1_rays[0], fault2_rays[1]) - count += 1 - except ValueError: - pass - - try: - join = Fault.intersectFaultRays(fault1_rays[1], fault2_rays[0]) - count += 1 - except ValueError: - pass - - try: - join = Fault.intersectFaultRays(fault1_rays[1], fault2_rays[1]) - count += 1 - except ValueError: - pass - - if count == 1: - xy_list = [] - for ij in join: - xyz = fault1.__grid.getNodeXYZ(ij[0], ij[1], k) - xy_list.append((xyz[0], xyz[1])) - - return xy_list - else: - return fault1.endJoin(fault2, k) - - -monkey_the_camel(FaultLayer, 'addSegment', FaultLayer.add_segment) -monkey_the_camel(FaultLayer, 'getK', FaultLayer.get_k) -monkey_the_camel(FaultLayer, 'getNeighborCells', FaultLayer.get_neighbor_cells) -monkey_the_camel(FaultLayer, 'getPolyline', FaultLayer.get_polyline) -monkey_the_camel(FaultLayer, 'getIJPolyline', FaultLayer.get_ij_polyline) -monkey_the_camel(FaultLayer, 'numLines', FaultLayer.num_lines) -monkey_the_camel(FaultLayer, 'processSegments', FaultLayer.process_segments) - -monkey_the_camel(Fault, 'hasLayer', Fault.has_layer) -monkey_the_camel(Fault, 'addLayer', Fault.add_layer) -monkey_the_camel(Fault, 'createSegment', Fault.create_segment) -monkey_the_camel(Fault, 'addRecord', Fault.add_record) -monkey_the_camel(Fault, 'getName', Fault.get_name) -monkey_the_camel(Fault, 'getNeighborCells', Fault.get_neighbor_cells) -monkey_the_camel(Fault, 'getPolyline', Fault.get_polyline) -monkey_the_camel(Fault, 'getIJPolyline', Fault.get_ij_polyline) -monkey_the_camel(Fault, 'numLines', Fault.num_lines) -monkey_the_camel(Fault, 'connectWithPolyline', Fault.connect_with_polyline) -monkey_the_camel(Fault, 'extendToPolyline', Fault.extend_to_polyline) -monkey_the_camel(Fault, 'intersectsPolyline', Fault.intersects_polyline) -monkey_the_camel(Fault, 'intersectsFault', Fault.intersects_fault) -monkey_the_camel(Fault, 'extendToFault', Fault.extend_to_fault) -monkey_the_camel(Fault, 'extendToEdge', Fault.extend_to_edge) -monkey_the_camel(Fault, 'extendToBBox', Fault.extend_to_b_box) -monkey_the_camel(Fault, 'endJoin', Fault.end_join) -monkey_the_camel(Fault, 'connectPolylineOnto', Fault.connect_polyline_onto) -monkey_the_camel(Fault, 'extendPolylineOnto', Fault.extend_polyline_onto) -monkey_the_camel(Fault, 'intersectFaultRays', Fault.intersect_fault_rays, staticmethod) -monkey_the_camel(Fault, 'intRay', Fault.int_ray, staticmethod) -monkey_the_camel(Fault, 'getEndRays', Fault.get_end_rays) -monkey_the_camel(Fault, 'joinFaults', Fault.join_faults, staticmethod) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py deleted file mode 100644 index c4d03db926..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault_block.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import ctypes -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.util import DoubleVector, IntVector -from ecl.ecl import EclPrototype -from ecl.geo import Polyline, GeometryTools, CPolylineCollection - -class FaultBlockCell(object): - - def __init__(self, i, j, k, x, y, z): - self.i = i - self.j = j - self.k = k - - self.x = x - self.y = y - self.z = z - - - def __str__(self): - return "(%d,%d)" % (self.i, self.j) - - - -class FaultBlock(BaseCClass): - TYPE_NAME = "fault_block" - - _get_xc = EclPrototype("double fault_block_get_xc(fault_block)") - _get_yc = EclPrototype("double fault_block_get_yc(fault_block)") - _get_block_id = EclPrototype("int fault_block_get_id(fault_block)") - _get_size = EclPrototype("int fault_block_get_size(fault_block)") - _export_cell = EclPrototype("void fault_block_export_cell(fault_block, int, int*, int*, int*, double*, double*, double*)") - _assign_to_region = EclPrototype("void fault_block_assign_to_region(fault_block, int)") - _get_region_list = EclPrototype("int_vector_ref fault_block_get_region_list(fault_block)") - _add_cell = EclPrototype("void fault_block_add_cell(fault_block, int, int)") - _get_global_index_list = EclPrototype("int_vector_ref fault_block_get_global_index_list(fault_block)") - _trace_edge = EclPrototype("void fault_block_trace_edge(fault_block, double_vector, double_vector, int_vector)") - _get_neighbours = EclPrototype("void fault_block_list_neighbours(fault_block, bool, geo_polygon_collection, int_vector)") - _free = EclPrototype("void fault_block_free__(fault_block)") - - - def __init__(self, *args, **kwargs): - raise NotImplementedError("Class can not be instantiated directly!") - - - def __getitem__(self, index): - if isinstance(index, int): - if index < 0: - index += len(self) - - if 0 <= index < len(self): - x = ctypes.c_double() - y = ctypes.c_double() - z = ctypes.c_double() - - i = ctypes.c_int() - j = ctypes.c_int() - k = ctypes.c_int() - - self._export_cell(index, - ctypes.byref(i), ctypes.byref(j), ctypes.byref(k), - ctypes.byref(x), ctypes.byref(y), ctypes.byref(z)) - return FaultBlockCell(i.value, j.value, k.value, x.value, y.value, z.value) - else: - raise IndexError("Index:%d out of range: [0,%d)" % (index, len(self))) - else: - raise TypeError("Index:%s wrong type - integer expected") - - def __str__(self): - return "Block ID: %d" % self.getBlockID() - - - def __len__(self): - return self._get_size() - - def free(self): - self._free() - - def get_centroid(self): - xc = self._get_xc() - yc = self._get_yc() - return (xc,yc) - - - def count_inside(self, polygon): - """ - Will count the number of points in block which are inside polygon. - """ - inside = 0 - for p in self: - if GeometryTools.pointInPolygon((p.x, p.y), polygon): - inside += 1 - - return inside - - - def get_block_id(self): - return self._get_block_id() - - - def assign_to_region(self, region_id): - self._assign_to_region(region_id) - - - def get_region_list(self): - regionList = self._get_region_list() - return regionList.copy() - - def add_cell(self, i, j): - self._add_cell(i, j) - - def get_global_index_list(self): - return self._get_global_index_list() - - - def get_edge_polygon(self): - x_list = DoubleVector() - y_list = DoubleVector() - cell_list = IntVector() - - self._trace_edge(x_list, y_list, cell_list) - p = Polyline() - for (x,y) in zip(x_list, y_list): - p.addPoint(x,y) - return p - - - def contains_polyline(self, polyline): - """ - Will return true if at least one point from the polyline is inside the block. - """ - edge_polyline = self.getEdgePolygon() - for p in polyline: - if GeometryTools.pointInPolygon(p, edge_polyline): - return True - else: - edge_polyline.assertClosed() - return GeometryTools.polylinesIntersect(edge_polyline, polyline) - - - def get_neighbours(self, polylines=None, connected_only=True): - """ - Will return a list of FaultBlock instances which are in direct - contact with this block. - """ - neighbour_id_list = IntVector() - if polylines is None: - polylines = CPolylineCollection() - - self._get_neighbours(connected_only, polylines, neighbour_id_list) - - parent_layer = self.getParentLayer() - neighbour_list = [] - for id in neighbour_id_list: - neighbour_list.append(parent_layer.getBlock(id)) - return neighbour_list - - - def get_parent_layer(self): - return self.parent() - - -monkey_the_camel(FaultBlock, 'getCentroid', FaultBlock.get_centroid) -monkey_the_camel(FaultBlock, 'countInside', FaultBlock.count_inside) -monkey_the_camel(FaultBlock, 'getBlockID', FaultBlock.get_block_id) -monkey_the_camel(FaultBlock, 'assignToRegion', FaultBlock.assign_to_region) -monkey_the_camel(FaultBlock, 'getRegionList', FaultBlock.get_region_list) -monkey_the_camel(FaultBlock, 'addCell', FaultBlock.add_cell) -monkey_the_camel(FaultBlock, 'getGlobalIndexList', FaultBlock.get_global_index_list) -monkey_the_camel(FaultBlock, 'getEdgePolygon', FaultBlock.get_edge_polygon) -monkey_the_camel(FaultBlock, 'containsPolyline', FaultBlock.contains_polyline) -monkey_the_camel(FaultBlock, 'getNeighbours', FaultBlock.get_neighbours) -monkey_the_camel(FaultBlock, 'getParentLayer', FaultBlock.get_parent_layer) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py deleted file mode 100644 index 88333268fe..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault_block_collection.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype - - -class FaultBlockCollection(BaseCClass): - TYPE_NAME = "fault_block_collection" - _alloc = EclPrototype("void* fault_block_collection_alloc(ecl_grid)", bind=False) - _free = EclPrototype("void fault_block_collection_free(fault_block_collection)") - _num_layers = EclPrototype("int fault_block_collection_num_layers(fault_block_collection)") - _scan_keyword = EclPrototype("bool fault_block_collection_scan_kw(fault_block_collection, ecl_kw)") - _get_layer = EclPrototype("fault_block_layer_ref fault_block_collection_get_layer(fault_block_collection, int)") - - def __init__(self, grid): - c_ptr = self._alloc(grid) - if c_ptr: - super(FaultBlockCollection, self).__init__(c_ptr) - else: - raise ValueError("Invalid input - failed to create FaultBlockCollection") - - # The underlying C implementation uses lazy evaluation and - # needs to hold on to the grid reference. We therefor take - # references to it here, to protect against premature garbage - # collection. - self.grid_ref = grid - - - def __len__(self): - return self._num_layers() - - - def __repr__(self): - return self._create_repr('len=%s' % len(self)) - - - def __getitem__(self, index): - """ - @rtype: FaultBlockLayer - """ - if isinstance(index, int): - if 0 <= index < len(self): - return self._get_layer(index).setParent(self) - else: - raise IndexError("Index:%d out of range [0,%d)" % (index, len(self))) - else: - raise TypeError("Index should be integer type") - - - def get_layer(self, k): - """ - @rtype: FaultBlockLayer - """ - return self[k] - - def free(self): - self._free() - - - def scan_keyword(self, fault_block_kw): - ok = self._scan_keyword(fault_block_kw) - if not ok: - raise ValueError("The fault block keyword had wrong type/size") - - -monkey_the_camel(FaultBlockCollection, 'getLayer', FaultBlockCollection.get_layer) -monkey_the_camel(FaultBlockCollection, 'scanKeyword', FaultBlockCollection.scan_keyword) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py deleted file mode 100644 index 7bffe6a608..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py +++ /dev/null @@ -1,235 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault_block_layer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function -from cwrap import BaseCClass - -from ecl.util import monkey_the_camel -from ecl.ecl import EclDataType, EclPrototype -from ecl.ecl.faults import Fault - -class FaultBlockLayer(BaseCClass): - TYPE_NAME = "fault_block_layer" - _alloc = EclPrototype("void* fault_block_layer_alloc(ecl_grid, int)", bind = False) - _free = EclPrototype("void fault_block_layer_free(fault_block_layer)") - _size = EclPrototype("int fault_block_layer_get_size(fault_block_layer)") - _iget_block = EclPrototype("fault_block_ref fault_block_layer_iget_block(fault_block_layer, int)") - _add_block = EclPrototype("fault_block_ref fault_block_layer_add_block(fault_block_layer, int)") - _get_block = EclPrototype("fault_block_ref fault_block_layer_get_block(fault_block_layer, int)") - _del_block = EclPrototype("void fault_block_layer_del_block(fault_block_layer, int)") - _has_block = EclPrototype("bool fault_block_layer_has_block(fault_block_layer, int)") - _scan_keyword = EclPrototype("bool fault_block_layer_scan_kw(fault_block_layer, ecl_kw)") - _load_keyword = EclPrototype("bool fault_block_layer_load_kw(fault_block_layer, ecl_kw)") - _getK = EclPrototype("int fault_block_layer_get_k(fault_block_layer)") - _get_next_id = EclPrototype("int fault_block_layer_get_next_id(fault_block_layer)") - _scan_layer = EclPrototype("void fault_block_layer_scan_layer(fault_block_layer, layer)") - _insert_block_content = EclPrototype("void fault_block_layer_insert_block_content(fault_block_layer, fault_block)") - _export_kw = EclPrototype("bool fault_block_layer_export(fault_block_layer, ecl_kw)") - _get_layer = EclPrototype("layer_ref fault_block_layer_get_layer(fault_block_layer)") - - - def __init__(self, grid, k): - c_ptr = self._alloc(grid, k) - if c_ptr: - super(FaultBlockLayer, self).__init__(c_ptr) - else: - raise ValueError("Invalid input - failed to create FaultBlockLayer") - - # The underlying C implementation uses lazy evaluation and - # needs to hold on to the grid reference. We therefor take - # references to it here, to protect against premature garbage - # collection. - self.grid_ref = grid - - - def __len__(self): - return self._size() - - - def __repr__(self): - return self._create_repr('size=%d, k=%d' % (len(self), self.get_k())) - - def __getitem__(self, index): - """ - @rtype: FaultBlock - """ - if isinstance(index, int): - if index < 0: - index += len(self) - - if 0 <= index < len(self): - return self._iget_block(index).setParent(self) - else: - raise IndexError("Index:%d out of range: [0,%d)" % (index, len(self))) - elif isinstance(index,tuple): - i,j = index - if 0 <= i < self.grid_ref.getNX() and 0 <= j < self.grid_ref.getNY(): - geo_layer = self.getGeoLayer() - block_id = geo_layer[i,j] - if block_id == 0: - raise ValueError("No fault block defined for location (%d,%d)" % (i,j)) - else: - return self.getBlock(block_id) - else: - raise IndexError("Invalid i,j : (%d,%d)" % (i,j)) - else: - raise TypeError("Index should be integer type") - - def __contains__(self, block_id): - return self._has_block(block_id) - - - def scan_keyword(self, fault_block_kw): - """ - Will reorder the block ids, and ensure single connectedness. Assign block_id to zero blocks. - """ - ok = self._scan_keyword(fault_block_kw) - if not ok: - raise ValueError("The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d" % (fault_block_kw.type_name, len(fault_block_kw), self.grid_ref.getGlobalSize())) - - - def load_keyword(self, fault_block_kw): - """ - Will load directly from keyword - without reorder; ignoring zero. - """ - ok = self._load_keyword(fault_block_kw) - if not ok: - raise ValueError("The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d" % (fault_block_kw.typeName(), len(fault_block_kw), self.grid_ref.getGlobalSize())) - - - def get_block(self, block_id): - """ - @rtype: FaultBlock - """ - if block_id in self: - return self._get_block(block_id).setParent(self) - else: - raise KeyError("No blocks with ID:%d in this layer" % block_id) - - - def delete_block(self, block_id): - if block_id in self: - self._del_block(block_id) - else: - raise KeyError("No blocks with ID:%d in this layer" % block_id) - - def add_block(self, block_id=None): - if block_id is None: - block_id = self.getNextID() - - if block_id in self: - raise KeyError("Layer already contains block with ID:%s" % block_id) - else: - return self._add_block(block_id).setParent(self) - - def get_next_id(self): - return self._get_next_id() - - - def get_k(self): - return self._getK() - - @property - def k(self): - return self._getK() - - def free(self): - self._free() - - - def scan_layer(self, layer): - self._scan_layer(layer) - - - def insert_block_content(self, block): - self._insert_block_content(block) - - def export_keyword(self, kw): - if len(kw) != self.grid_ref.getGlobalSize(): - msg = 'The size of the target keyword must be equal to the size of the grid.' - msg += ' Got:%d Expected:%d.' - raise ValueError(msg % (len(kw), self.grid_ref.getGlobalSize())) - - if not kw.data_type.is_int(): - raise TypeError("The target kewyord must be of integer type") - - self._export_kw(kw) - - - def add_fault_barrier(self, fault, link_segments=False): - layer = self.getGeoLayer() - layer.addFaultBarrier(fault, self.getK(), link_segments) - - - def add_fault_link(self, fault1, fault2): - if not fault1.intersectsFault(fault2, self.getK()): - layer = self.getGeoLayer() - layer.addIJBarrier(fault1.extendToFault(fault2, self.getK())) - - - def join_faults(self, fault1, fault2): - if not fault1.intersectsFault(fault2, self.getK()): - layer = self.getGeoLayer() - try: - layer.addIJBarrier(Fault.joinFaults(fault1, fault2, self.getK())) - except ValueError: - err = 'Failed to join faults %s and %s' - names = (fault1.getName(), fault2.getName()) - print(err % names) - raise ValueError(err % names) - - - def add_polyline_barrier(self, polyline): - layer = self.getGeoLayer() - p0 = polyline[0] - c0 = self.grid_ref.findCellCornerXY(p0[0], p0[1], self.getK()) - i,j = self.grid_ref.findCellXY(p0[0], p0[1], self.getK()) - print('%g,%g -> %d,%d %d' % (p0[0], p0[1], i,j,c0)) - for index in range(1,len(polyline)): - p1 = polyline[index] - c1 = self.grid_ref.findCellCornerXY(p1[0], p1[1], self.getK()) - i,j = self.grid_ref.findCellXY(p1[0], p1[1], self.getK()) - layer.addInterpBarrier(c0, c1) - print('%g,%g -> %d,%d %d' % (p1[0], p1[1], i,j,c1)) - print('Adding barrier %d -> %d' % (c0, c1)) - c0 = c1 - - - def get_geo_layer(self): - """Returns the underlying geometric layer.""" - return self._get_layer() - - - def cell_contact(self, p1, p2): - layer = self.getGeoLayer() - return layer.cellContact(p1,p2) - -monkey_the_camel(FaultBlockLayer, 'scanKeyword', FaultBlockLayer.scan_keyword) -monkey_the_camel(FaultBlockLayer, 'loadKeyword', FaultBlockLayer.load_keyword) -monkey_the_camel(FaultBlockLayer, 'getBlock', FaultBlockLayer.get_block) -monkey_the_camel(FaultBlockLayer, 'deleteBlock', FaultBlockLayer.delete_block) -monkey_the_camel(FaultBlockLayer, 'addBlock', FaultBlockLayer.add_block) -monkey_the_camel(FaultBlockLayer, 'getNextID', FaultBlockLayer.get_next_id) -monkey_the_camel(FaultBlockLayer, 'getK', FaultBlockLayer.get_k) -monkey_the_camel(FaultBlockLayer, 'scanLayer', FaultBlockLayer.scan_layer) -monkey_the_camel(FaultBlockLayer, 'insertBlockContent', FaultBlockLayer.insert_block_content) -monkey_the_camel(FaultBlockLayer, 'exportKeyword', FaultBlockLayer.export_keyword) -monkey_the_camel(FaultBlockLayer, 'addFaultBarrier', FaultBlockLayer.add_fault_barrier) -monkey_the_camel(FaultBlockLayer, 'addFaultLink', FaultBlockLayer.add_fault_link) -monkey_the_camel(FaultBlockLayer, 'joinFaults', FaultBlockLayer.join_faults) -monkey_the_camel(FaultBlockLayer, 'addPolylineBarrier', FaultBlockLayer.add_polyline_barrier) -monkey_the_camel(FaultBlockLayer, 'getGeoLayer', FaultBlockLayer.get_geo_layer) -monkey_the_camel(FaultBlockLayer, 'cellContact', FaultBlockLayer.cell_contact) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py deleted file mode 100644 index 7daf0fce44..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault_collection.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import re - -from ecl.util import monkey_the_camel -from ecl.ecl import EclGrid -from .fault import Fault - -comment_regexp = re.compile("--.*") - -def dequote(s): - if s[0] in ["'", '"']: - if s[0] == s[-1]: - return s[1:-1] - else: - raise ValueError("Quote fuckup") - else: - return s - - -class FaultCollection(object): - def __init__(self, grid=None, *file_list): - self.__fault_list = [] - self.__fault_map = {} - self.__grid = grid - - if self.__grid is not None: - if not isinstance(self.__grid, EclGrid): - raise ValueError("When supplying a list of files to load - you must have a grid") - for file in file_list: - self.load(self.__grid, file) - - - def __contains__(self, fault_name): - return self.__fault_map.has_key(fault_name) - - - def __len__(self): - return len(self.__fault_list) - - - def __getitem__(self, index): - if isinstance(index, str): - return self.__fault_map[index] - elif isinstance(index, int): - return self.__fault_list[index] - else: - raise TypeError("Argument must be fault name or number") - - def __iter__(self): - return iter(self.__fault_list) - - - def get_grid(self): - return self.__grid - - - def get_fault(self, name): - return self[name] - - - def has_fault(self, fault_name): - return fault_name in self - - - def add_fault(self, fault): - self.__fault_map[fault.getName()] = fault - self.__fault_list.append(fault) - - - def split_line(self, line): - tmp = line.split() - if not tmp[-1] == "/": - raise ValueError("Line:%s does not end with /" % line) - - if len(tmp) != 9: - raise ValueError("Line:%s not correct number of items" % line) - - fault_name = dequote(tmp[0]) - I1 = int(tmp[1]) - 1 - I2 = int(tmp[2]) - 1 - J1 = int(tmp[3]) - 1 - J2 = int(tmp[4]) - 1 - K1 = int(tmp[5]) - 1 - K2 = int(tmp[6]) - 1 - face = dequote(tmp[7]) - - return (fault_name, I1,I2,J1,J2,K1,K2, face) - - - - def load_faults(self, grid, fileH): - for line in fileH: - line = comment_regexp.sub("", line) - line = line.strip() - if line == "/": - break - - if line: - (name, I1, I2, J1, J2, K1, K2, face) = self.splitLine(line) - if not self.hasFault(name): - fault = Fault(grid, name) - self.addFault(fault) - else: - fault = self.getFault(name) - - fault.addRecord(I1, I2, J1, J2, K1, K2, face) - - - def load(self, grid, file_name): - with open(file_name) as fileH: - for line in fileH: - if line.startswith("FAULTS"): - self.loadFaults(grid, fileH) - - -monkey_the_camel(FaultCollection, 'getGrid', FaultCollection.get_grid) -monkey_the_camel(FaultCollection, 'getFault', FaultCollection.get_fault) -monkey_the_camel(FaultCollection, 'hasFault', FaultCollection.has_fault) -monkey_the_camel(FaultCollection, 'addFault', FaultCollection.add_fault) -monkey_the_camel(FaultCollection, 'splitLine', FaultCollection.split_line) -monkey_the_camel(FaultCollection, 'loadFaults', FaultCollection.load_faults) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py deleted file mode 100644 index 3436d7454d..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py +++ /dev/null @@ -1,253 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'fault_line.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function -import sys - -from ecl.util import monkey_the_camel -from ecl.util import DoubleVector,stat -from ecl.geo import CPolyline - -from .fault_segments import FaultSegment - - -def cmp_index_pair(p1, p2): - if p1[0] == p2[0]: - return cmp(p1[1], p2[1]) - else: - return cmp(p1[0], p2[0]) - - -class FaultLine(object): - def __init__(self, grid, k): - self.__grid = grid - self.__k = k - self.__segment_list = [] - self.__polyline = None - self.__ijpolyline = None - self.__neighborCells = None - - def __len__(self): - return len(self.__segment_list) - - - def __getitem__(self, index): - return self.__segment_list[index] - - def __iter__(self): - return iter(self.__segment_list) - - - def verify(self): - if len(self.__segment_list) > 1: - current = self.__segment_list[0] - for next_segment in self.__segment_list[1:]: - if not current.getC2() == next_segment.getC1(): - sys.stdout.write("Current: %d ---- %d \n" % (current.getC1() , current.getC2())) - sys.stdout.write("Next : %d ---- %d \n" % (next_segment.getC1(), next_segment.getC2())) - assert current.getC2() == next_segment.getC1() - current = next_segment - - - def try_append(self, segment): - if len(self.__segment_list) > 0: - tail = self.__segment_list[-1] - if tail.getC2() != segment.getC1(): - if len(self.__segment_list) == 1: - if tail.getC2() == segment.getC2(): - segment.swap() - else: - tail.swap() - if tail.getC2() == segment.getC2(): - segment.swap() - else: - segment.swap() - - if not tail.getC2() == segment.getC1(): - return False - - self.__segment_list.append(segment) - self.__polyline = None - self.__ijpolyline = None - return True - - - def get_k(self): - return self.__k - - @property - def k(self): - return self.__k - - - def __init_ij_polyline(self): - pl = [] - nx = self.__grid.getNX() - ny = self.__grid.getNY() - for segment in self: - corner = segment.getC1() - i = corner % (nx + 1) - j = corner / (nx + 1) - pl.append((i,j)) - - segment = self[-1] - corner = segment.getC2() - i = corner % (nx + 1) - j = corner / (nx + 1) - pl.append((i,j)) - - self.__ijpolyline = pl - - - - def __init_polyline(self): - pl = CPolyline() - for (i,j) in self.getIJPolyline(): - x,y,z = self.__grid.getNodeXYZ(i, j, self.__k) - pl.addPoint(x, y) - self.__polyline = pl - - - - def get_polyline(self): - if self.__polyline is None: - self.__init_polyline() - return self.__polyline - - - def get_ij_polyline(self): - if self.__ijpolyline is None: - self.__init_ij_polyline() - return self.__ijpolyline - - - - def __init_neighbor_cells(self): - self.__neighborCells = [] - nx = self.__grid.getNX() - ny = self.__grid.getNY() - k = self.__k - - for segment in self: - (j1,i1) = divmod(segment.getC1(), (nx + 1)) - (j2,i2) = divmod(segment.getC2(), (nx + 1)) - - if j1 > j2: - j1,j2 = j2,j1 - - if i1 > i2: - i1,i2 = i2,i1 - - - if i1 == i2: - i = i1 - for j in range(j1, j2): - g2 = i + j * nx + k * nx*ny - if i == 0: - g1 = -1 - else: - g1 = g2 - 1 - - if i == nx: - g2 = -1 - - self.__neighborCells.append((g1,g2)) - elif j1 == j2: - j = j1 - for i in range(i1,i2): - g2 = i + j * nx + k * nx*ny - if j == 0: - g1 = -1 - else: - g1 = g2 - nx - - if j == ny: - g2 = -1 - - self.__neighborCells.append((g1,g2)) - else: - raise Exception("Internal error: found fault segment with variation in two directions") - self.__neighborCells.sort(cmp_index_pair) - - - def get_neighbor_cells(self): - if self.__neighborCells is None: - self.__init_neighbor_cells() - - return self.__neighborCells - - - def center(self): - xlist = DoubleVector() - ylist = DoubleVector() - for segment in self: - C1 = segment.getC1() - C2 = segment.getC2() - (J1, I1) = divmod(C1, self.__grid.getNX() + 1) - (J2, I2) = divmod(C2, self.__grid.getNX() + 1) - - (x1,y1,z) = self.__grid.getNodePos(I1, J1, self.__k) - (x2,y2,z) = self.__grid.getNodePos(I2, J2, self.__k) - - xlist.append(x1) - xlist.append(x2) - - ylist.append(y1) - ylist.append(y2) - - - N = len(xlist) - return (xlist.elementSum()/N, ylist.elementSum()/N) - - - - def reverse(self): - reverse_list = reversed(self.__segment_list) - self.__segment_list = [] - for segment in reverse_list: - C1 = segment.getC1() - C2 = segment.getC2() - - rseg = FaultSegment(C2, C1) - self.tryAppend(rseg) - - - def start_point(self): - pl = self.getPolyline() - return pl[0] - - def end_point(self): - pl = self.getPolyline() - return pl[-1] - - def dump(self): - print('-----------------------------------------------------------------') - for segment in self: - C1 = segment.getC1() - C2 = segment.getC2() - (J1, I1) = divmod(C1, self.__grid.getNX() + 1) - (J2, I2) = divmod(C2, self.__grid.getNX() + 1) - print('[Corner:%5d IJ:(%3d,%d)] -> [Corner:%5d IJ:(%3d,%d)]' - % (C1, I1, J1, C2, I2, J2)) - - -monkey_the_camel(FaultLine, 'tryAppend', FaultLine.try_append) -monkey_the_camel(FaultLine, 'getK', FaultLine.get_k) -monkey_the_camel(FaultLine, 'getPolyline', FaultLine.get_polyline) -monkey_the_camel(FaultLine, 'getIJPolyline', FaultLine.get_ij_polyline) -monkey_the_camel(FaultLine, 'getNeighborCells', FaultLine.get_neighbor_cells) -monkey_the_camel(FaultLine, 'startPoint', FaultLine.start_point) -monkey_the_camel(FaultLine, 'endPoint', FaultLine.end_point) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py deleted file mode 100644 index 9b579a57d9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py +++ /dev/null @@ -1,174 +0,0 @@ -# Copyright (C) 2014. Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function - -from ecl.util import monkey_the_camel - - -class FaultSegment(object): - - def __init__(self, C1, C2): - self.__C1 = C1 - self.__C2 = C2 - self.__next_segment = None - - - def __eq__(self, other): - s = self.c1, self.c2 - o = other.c1, other.c2 - o_flipped = other.c2, other.c1 - return s == o or s == o_flipped - - def __hash__(self): - return hash(hash(self.__C1) + hash(self.__C2) + hash(self.__next_segment)) - - def get_corners(self): - return (self.__C1, self.__C2) - - def joins(self, other): - if self.__C1 == other.__C1: - return True - if self.__C1 == other.__C2: - return True - if self.__C2 == other.__C1: - return True - if self.__C2 == other.__C2: - return True - - return False - - def get_c1(self): - return self.__C1 - - @property - def c1(self): - return self.__C1 - - def get_c2(self): - return self.__C2 - - @property - def c2(self): - return self.__C2 - - def swap(self): - C1 = self.__C1 - self.__C1 = self.__C2 - self.__C2 = C1 - - - def __repr__(self): - return "%d -> %d" % (self.__C1, self.__C2) - - - -class SegmentMap(object): - - def __init__(self): - self.__segment_map = {} - self.__count_map = {} - - def __len__(self): - return len(self.__segment_map) - - def __str__(self): - return self.__segment_map.__str__() - - def verify(self): - for (C, count) in self.__count_map.iteritems(): - if count > 0: - d = self.__segment_map[C] - if len(d) != count: - print('CornerPoint:%d count:%d len(d):%d map:%s' % (C, count, len(d), d)) - assert len(d) == count - else: - assert self.__segment_map.get(C) is None - - - def add_segment(self, segment): - (C1,C2) = segment.getCorners() - if not self.__segment_map.has_key(C1): - self.__segment_map[C1] = {} - self.__count_map[C1] = 0 - if not self.__segment_map.has_key(C2): - self.__segment_map[C2] = {} - self.__count_map[C2] = 0 - - if not self.__segment_map[C1].has_key(C2): - self.__segment_map[C1][C2] = segment - self.__count_map[C1] += 1 - - if not self.__segment_map[C2].has_key(C1): - self.__segment_map[C2][C1] = segment - self.__count_map[C2] += 1 - - - - def del_segment(self, segment): - (C1,C2) = segment.getCorners() - self.__count_map[C1] -= 1 - self.__count_map[C2] -= 1 - del self.__segment_map[C1][C2] - del self.__segment_map[C2][C1] - - if len(self.__segment_map[C1]) == 0: - del self.__segment_map[C1] - - if len(self.__segment_map[C2]) == 0: - del self.__segment_map[C2] - - - def pop_start(self): - end_segments = [] - for (C, count) in self.__count_map.iteritems(): - if count == 1: - end_segments.append(self.__segment_map[C].values()[0]) - - start_segment = end_segments[0] - self.delSegment(start_segment) - return start_segment - - def pop_next(self, segment): - (C1,C2) = segment.getCorners() - if self.__count_map[C1] >= 1: - next_segment = self.__segment_map[C1].values()[0] - elif self.__count_map[C2] >= 1: - next_segment = self.__segment_map[C2].values()[0] - else: - next_segment = None - - if next_segment: - self.delSegment(next_segment) - return next_segment - - - def print_content(self): - for d in self.__segment_map.values(): - for (C,S) in d.iteritems(): - print(S) - - - -monkey_the_camel(FaultSegment, 'getCorners', FaultSegment.get_corners) -monkey_the_camel(FaultSegment, 'getC1', FaultSegment.get_c1) -monkey_the_camel(FaultSegment, 'getC2', FaultSegment.get_c2) - -monkey_the_camel(SegmentMap, 'addSegment', SegmentMap.add_segment) -monkey_the_camel(SegmentMap, 'delSegment', SegmentMap.del_segment) -monkey_the_camel(SegmentMap, 'popStart', SegmentMap.pop_start) -monkey_the_camel(SegmentMap, 'popNext', SegmentMap.pop_next) -monkey_the_camel(SegmentMap, 'printContent', SegmentMap.print_content) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py b/ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py deleted file mode 100644 index 464fd891df..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py +++ /dev/null @@ -1,274 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'layer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import ctypes - -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclPrototype - - -class Layer(BaseCClass): - TYPE_NAME = "layer" - _alloc = EclPrototype("void* layer_alloc(int, int)", bind=False) - _copy = EclPrototype("void layer_memcpy(layer, layer)") - _free = EclPrototype("void layer_free(layer)") - _get_nx = EclPrototype("int layer_get_nx(layer)") - _get_ny = EclPrototype("int layer_get_ny(layer)") - _set_cell = EclPrototype("void layer_iset_cell_value(layer, int, int, int)") - _get_cell = EclPrototype("int layer_iget_cell_value(layer, int, int)") - _get_bottom_barrier = EclPrototype("bool layer_iget_bottom_barrier(layer, int, int)") - _get_left_barrier = EclPrototype("bool layer_iget_left_barrier(layer, int, int)") - _cell_contact = EclPrototype("bool layer_cell_contact(layer, int, int, int, int)") - _add_barrier = EclPrototype("void layer_add_barrier(layer, int, int)") - _add_ijbarrier = EclPrototype("void layer_add_ijbarrier(layer, int, int, int, int)") - _add_interp_barrier = EclPrototype("void layer_add_interp_barrier(layer, int, int)") - _clear_cells = EclPrototype("void layer_clear_cells(layer)") - _assign = EclPrototype("void layer_assign(layer, int)") - _cell_sum = EclPrototype("int layer_get_cell_sum(layer)") - _update_connected = EclPrototype("void layer_update_connected_cells(layer,int,int,int,int)") - _cells_equal = EclPrototype("void layer_cells_equal(layer, int,int_vector,int_vector)") - _count_equal = EclPrototype("int layer_count_equal(layer, int)") - _active_cell = EclPrototype("bool layer_iget_active(layer, int,int)") - _update_active = EclPrototype("bool layer_update_active(layer, ecl_grid, int)") - - def __init__(self, nx, ny): - c_ptr = self._alloc(nx, ny) - if c_ptr: - super(Layer, self).__init__(c_ptr) - else: - raise ValueError("Invalid input - no Layer object created") - - @classmethod - def copy(cls, src): - layer = Layer(src.getNX(), src.getNY()) - layer._copy(layer, src) - return layer - - - def _assert_ij(self, i,j): - if i < 0 or i >= self.getNX(): - raise ValueError("Invalid layer i:%d" % i) - - if j < 0 or j >= self.getNY(): - raise ValueError("Invalid layer j:%d" % j) - - - def __unpack_index(self, index): - try: - (i,j) = index - except TypeError: - raise ValueError("Index:%s is invalid - must have two integers" % str(index)) - - self._assert_ij(i,j) - - return (i,j) - - - def __setitem__(self, index, value): - (i,j) = self.__unpack_index(index) - self._set_cell(i, j, value) - - def active_cell(self, i,j): - self._assert_ij(i,j) - return self._active_cell(i, j) - - - def update_active(self, grid, k): - if grid.getNX() != self.getNX(): - raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX(), self.getNX())) - - if grid.getNY() != self.getNY(): - raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY(), self.getNY())) - - if k >= grid.getNZ(): - raise ValueError("K value invalid: Grid range [0,%d)" % grid.getNZ()) - - self._update_active(grid, k) - - - def __getitem__(self, index): - (i,j) = self.__unpack_index(index) - return self._get_cell(i, j) - - def bottom_barrier(self, i,j): - self._assert_ij(i,j) - return self._get_bottom_barrier(i, j) - - def left_barrier(self, i,j): - self._assert_ij(i,j) - return self._get_left_barrier(i, j) - - def get_nx(self): - return self._get_nx() - - @property - def nx(self): - return self._get_nx() - - def get_ny(self): - return self._get_ny() - - @property - def ny(self): - return self._get_ny() - - def free(self): - self._free() - - def cell_contact(self, p1, p2): - i1,j1 = p1 - i2,j2 = p2 - - if not 0 <= i1 < self.getNX(): - raise IndexError("Invalid i1:%d" % i1) - - if not 0 <= i2 < self.getNX(): - raise IndexError("Invalid i2:%d" % i2) - - if not 0 <= j1 < self.getNY(): - raise IndexError("Invalid i1:%d" % j1) - - if not 0 <= j2 < self.getNY(): - raise IndexError("Invalid i2:%d" % j2) - - return self._cell_contact(i1, j1, i2, j2) - - - def add_interp_barrier(self, c1, c2): - self._add_interp_barrier(c1, c2) - - - def add_polyline_barrier(self, polyline, grid, k): - if len(polyline) > 1: - for i in range(len(polyline) - 1): - x1,y1 = polyline[i] - x2,y2 = polyline[i + 1] - - c1 = grid.findCellCornerXY(x1, y1, k) - c2 = grid.findCellCornerXY(x2, y2, k) - - self.addInterpBarrier(c1, c2) - - - def add_fault_barrier(self, fault, K, link_segments=True): - fault_layer = fault[K] - num_lines = len(fault_layer) - for index, fault_line in enumerate(fault_layer): - for segment in fault_line: - c1, c2 = segment.getCorners() - self._add_barrier(c1, c2) - - if index < num_lines - 1: - next_line = fault_layer[index + 1] - next_segment = next_line[0] - next_c1, next_c2 = next_segment.getCorners() - - if link_segments: - self.addInterpBarrier(c2, next_c1) - - - def add_ij_barrier(self, ij_list): - if len(ij_list) < 2: - raise ValueError("Must have at least two (i,j) points") - - nx = self.getNX() - ny = self.getNY() - p1 = ij_list[0] - i1,j1 = p1 - for p2 in ij_list[1:]: - i2,j2 = p2 - if i1 == i2 or j1 == j2: - if not 0 <= i2 <= nx: - raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (i1, i2)) - - if not 0 <= j2 <= ny: - raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (j1, j2)) - - self._add_ijbarrier(i1, j1, i2, j2) - p1 = p2 - i1,j1 = p1 - else: - raise ValueError("Must have i1 == i2 or j1 == j2") - - - def cell_sum(self): - return self._cell_sum() - - def clear_cells(self): - """ - Will reset all cell and edge values to zero. Barriers will be left - unchanged. - """ - self._clear_cells() - - - def assign(self, value): - """ - Will set the cell value to @value in all cells. Barriers will not be changed - """ - self._assign(value) - - def update_connected(self, ij, new_value, org_value=None): - """ - Will update cell value of all cells in contact with cell ij to the - value @new_value. If org_value is not supplied, the current - value in cell ij is used. - """ - if org_value is None: - org_value = self[ij] - - if self[ij] == org_value: - self._update_connected(ij[0], ij[1], org_value, new_value) - else: - raise ValueError("Cell %s is not equal to %d \n" % (ij, org_value)) - - - def cells_equal(self, value): - """ - Will return a list [(i1,j1),(i2,j2), ...(in,jn)] of all cells with value @value. - """ - i_list = IntVector() - j_list = IntVector() - self._cells_equal(value, i_list, j_list) - ij_list= [] - for (i,j) in zip(i_list, j_list): - ij_list.append((i,j)) - return ij_list - - - def count_equal(self, value): - return self._count_equal(value) - - - -monkey_the_camel(Layer, 'activeCell', Layer.active_cell) -monkey_the_camel(Layer, 'updateActive', Layer.update_active) -monkey_the_camel(Layer, 'bottomBarrier', Layer.bottom_barrier) -monkey_the_camel(Layer, 'leftBarrier', Layer.left_barrier) -monkey_the_camel(Layer, 'getNX', Layer.get_nx) -monkey_the_camel(Layer, 'getNY', Layer.get_ny) -monkey_the_camel(Layer, 'cellContact', Layer.cell_contact) -monkey_the_camel(Layer, 'addInterpBarrier', Layer.add_interp_barrier) -monkey_the_camel(Layer, 'addPolylineBarrier', Layer.add_polyline_barrier) -monkey_the_camel(Layer, 'addFaultBarrier', Layer.add_fault_barrier) -monkey_the_camel(Layer, 'addIJBarrier', Layer.add_ij_barrier) -monkey_the_camel(Layer, 'cellSum', Layer.cell_sum) -monkey_the_camel(Layer, 'clearCells', Layer.clear_cells) -monkey_the_camel(Layer, 'updateConnected', Layer.update_connected) -monkey_the_camel(Layer, 'cellsEqual', Layer.cells_equal) -monkey_the_camel(Layer, 'countEqual', Layer.count_equal) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/fortio.py b/ThirdParty/Ert/python/python/ecl/ecl/fortio.py deleted file mode 100644 index 75d7b917fd..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/fortio.py +++ /dev/null @@ -1,211 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'fortio.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Module to support transparent binary IO of Fortran created files. - -Fortran is a a funny language; when writing binary blobs of data to -file the Fortran runtime will silently add a header and footer around -the date. The Fortran code: - - integer array(100) - write(unit) array - -it actually writes a head and tail in addition to the actual -data. The header and tail is a 4 byte integer, which value is the -number of bytes in the immediately following record. I.e. what is -actually found on disk after the Fortran code above is: - - | 400 | array ...... | 400 | - -The fortio.c file implements the fortio_type C structure which can be -used to read and write these structures transparently. The current -python module is a minimal wrapping of this datastructure; mainly to -support passing of FortIO handles to the underlying C functions. A -more extensive wrapping of the fortio implementation would be easy. -""" -import ctypes -import os - -from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype - - -class FortIO(BaseCClass): - TYPE_NAME = "fortio" - - READ_MODE = 1 - WRITE_MODE = 2 - READ_AND_WRITE_MODE = 3 - APPEND_MODE = 4 - - _open_reader = EclPrototype("void* fortio_open_reader(char*, bool, bool)", bind=False) - _open_writer = EclPrototype("void* fortio_open_writer(char*, bool, bool)", bind=False) - _open_readwrite = EclPrototype("void* fortio_open_readwrite(char*, bool, bool)", bind=False) - _open_append = EclPrototype("void* fortio_open_append(char*, bool, bool)", bind=False) - _guess_fortran = EclPrototype("bool fortio_looks_like_fortran_file(char*, bool)", bind=False) - - _write_record = EclPrototype("void fortio_fwrite_record(fortio, char*, int)") - _get_position = EclPrototype("long fortio_ftell(fortio)") - _seek = EclPrototype("void fortio_fseek(fortio, long, int)") - _close = EclPrototype("bool fortio_fclose(fortio)") - _truncate = EclPrototype("bool fortio_ftruncate(fortio, long)") - _filename = EclPrototype("char* fortio_filename_ref(fortio)") - - - def __init__(self, file_name, mode=READ_MODE, fmt_file=False, endian_flip_header=True): - """Will open a new FortIO handle to @file_name - default for reading. - - The newly created FortIO handle will open the underlying FILE* - for reading, but if you pass the flag mode=FortIO.WRITE_MODE - the file will be opened for writing. - - Observe that the flag @endian_flip_header will only affect the - interpretation of the block size markers in the file, endian - flipping of the actual data blocks must be handled at a higher - level. - - When you are finished working with the FortIO instance you can - manually close it with the close() method, alternatively that - will happen automagically when it goes out of scope. - - Small example script opening a restart file, and then writing - all the pressure keywords to another file: - - import sys - from ecl.ecl import FortIO, EclFile - - rst_file = EclFile(sys.argv[1]) - fortio = FortIO("PRESSURE", mode=FortIO.WRITE_MODE) - - for kw in rst_file: - if kw.name() == "PRESSURE": - kw.write(fortio) - - fortio.close() - - See the documentation of openFortIO() for an alternative - method based on a context manager and the with statement. - - """ - read_modes = (FortIO.READ_MODE, FortIO.APPEND_MODE, FortIO.READ_AND_WRITE_MODE) - if mode in read_modes and not os.path.exists(file_name): - raise IOError('No such file "%s".' % file_name) - if mode == FortIO.READ_MODE: - c_pointer = self._open_reader(file_name, fmt_file, endian_flip_header) - elif mode == FortIO.WRITE_MODE: - c_pointer = self._open_writer(file_name, fmt_file, endian_flip_header) - elif mode == FortIO.READ_AND_WRITE_MODE: - c_pointer = self._open_readwrite(file_name, fmt_file, endian_flip_header) - elif mode == FortIO.APPEND_MODE: - c_pointer = self._open_append(file_name, fmt_file, endian_flip_header) - else: - raise UserWarning("Unknown mode: %d" % mode) - - self.__mode = mode - if not c_pointer: - raise IOError('Failed to open FortIO file "%s".' % file_name) - super(FortIO, self).__init__(c_pointer) - - - - def close(self): - if self: - self._close() - self._invalidateCPointer() - - - def get_position(self): - """ @rtype: long """ - return self._get_position() - - - def truncate(self, size=None): - """Will truncate the file to new size. - - If the method is called without a size argument the stream - will be truncated to the current position. - """ - if size is None: - size = self.getPosition() - - if not self._truncate(size): - raise IOError("Truncate of fortran filehandle:%s failed" % self.filename()) - - - def filename(self): - return self._filename() - - - def seek(self, position, whence=0): - # SEEK_SET = 0 - # SEEK_CUR = 1 - # SEEK_END = 2 - self._seek(position, whence) - - - @classmethod - def is_fortran_file(cls, filename, endian_flip=True): - - """@rtype: bool - @type filename: str - - - Will use heuristics to try to guess if @filename is a binary - file written in fortran style. ASCII files will return false, - even if they are structured as ECLIPSE keywords. - """ - return cls._guess_fortran(filename, endian_flip) - - - def free(self): - self.close() - - -class FortIOContextManager(object): - - def __init__(self, fortio): - self.__fortio = fortio - - def __enter__(self): - return self.__fortio - - def __exit__(self, exc_type, exc_val, exc_tb): - self.__fortio.close() - return exc_type is not None - - -def openFortIO(file_name, mode=FortIO.READ_MODE, fmt_file=False, endian_flip_header=True): - """Will create FortIO based context manager for use with with. - - The with: statement and context managers is a good alternative in - the situation where you need to ensure resource cleanup. - - import sys - from ecl.ecl import FortIO, EclFile - - rst_file = EclFile(sys.argv[1]) - with openFortIO("PRESSURE", mode=FortIO.WRITE_MODE) as fortio: - for kw in rst_file: - if kw.name() == "PRESSURE": - kw.write(fortio) - - """ - return FortIOContextManager(FortIO(file_name, mode=mode, fmt_file=fmt_file, - endian_flip_header=endian_flip_header)) - -monkey_the_camel(FortIO, 'getPosition', FortIO.get_position) -monkey_the_camel(FortIO, 'isFortranFile', FortIO.is_fortran_file, classmethod) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/local.cmake b/ThirdParty/Ert/python/python/ecl/ecl/local.cmake deleted file mode 100644 index f2431a2a7a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/local.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set( ECL_LOCAL_TARGET "" CACHE FILE "Name of optional external ecl_local module") - -if (EXISTS ${ECL_LOCAL_TARGET}) - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - endif() - - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ECL_LOCAL_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") -endif() - -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - add_python_package( "Python ecl.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "ecl_local.py" True) -endif() diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt deleted file mode 100644 index d41bccb489..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - well_trajectory.py -) - -add_python_package("python.ecl.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/rft "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py b/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py deleted file mode 100644 index d5a91dfba7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .well_trajectory import WellTrajectory diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py b/ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py deleted file mode 100644 index abe0cadcd5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'well_trajectory.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import sys -from os.path import isfile -from collections import namedtuple - -TrajectoryPoint = namedtuple('TrajectoryPoint', - ['utm_x', 'utm_y', - 'measured_depth', 'true_vertical_depth', - 'zone']) - -def _read_point(line): - line = line.partition("--")[0] - line = line.strip() - if not line: - return None - - point = line.split() - if len(point) not in (4, 5): - fmt = 'utm_x utm_y md tvd [zone]' - err = 'Trajectory data file not on correct format: "%s".' - err += ' zone is optional.' - raise UserWarning(err % fmt) - return point - -def _parse_point(point): - try: - utm_x = float(point[0]) - utm_y = float(point[1]) - md = float(point[2]) - tvd = float(point[3]) - except ValueError: - raise UserWarning("Error: Failed to extract data from line %s\n" % str(point)) - zone = None - if len(point) > 4: - zone = point[4] - return TrajectoryPoint(utm_x, utm_y, md, tvd, zone) - - -class WellTrajectory: - - def __init__(self, filename): - self._points = [] - if not isfile(filename): - raise IOError('No such file "%s"' % filename) - - with open(filename) as fileH: - for line in fileH.readlines(): - point = _read_point(line) - if not point: - continue - traj = _parse_point(point) - self._points.append(traj) - - def __len__(self): - return len(self._points) - - - def __getitem__(self, index): - if index < 0: - index += len(self) - - return self._points[index] - - - def __repr__(self): - return 'WellTrajectory(len=%d)' % len(self) - - def __str__(self): - return 'WellTrajectory(%s)' % str(self._points) diff --git a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in b/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in deleted file mode 100644 index eaf570f7ca..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in +++ /dev/null @@ -1,3 +0,0 @@ -lib_path = "${LIBRARY_OUTPUT_PATH}" -so_version = "${ECL_BINARY_POSTFIX}" -__version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" diff --git a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in b/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in deleted file mode 100644 index fc3e9a08d5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in +++ /dev/null @@ -1,3 +0,0 @@ -lib_path = "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" -so_version = "${ECL_BINARY_POSTFIX}" -__version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" diff --git a/ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt deleted file mode 100644 index 563a73db75..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - cpolyline.py - cpolyline_collection.py - geometry_tools.py - geo_pointset.py - geo_region.py - polyline.py - xyz_io.py - surface.py -) - -add_python_package("python.ecl.geo" ${PYTHON_INSTALL_PREFIX}/ecl/geo "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/geo/__init__.py b/ThirdParty/Ert/python/python/ecl/geo/__init__.py deleted file mode 100644 index b2d982a580..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Simple package for working with 2D geometry. - -""" -import ecl -from cwrap import Prototype - -class GeoPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(GeoPrototype, self).__init__(GeoPrototype.lib, prototype, bind=bind) - - -from .geo_pointset import GeoPointset -from .geo_region import GeoRegion -from .cpolyline import CPolyline -from .cpolyline_collection import CPolylineCollection -from .polyline import Polyline -from .xyz_io import XYZIo -from .geometry_tools import GeometryTools -from .surface import Surface diff --git a/ThirdParty/Ert/python/python/ecl/geo/cpolyline.py b/ThirdParty/Ert/python/python/ecl/geo/cpolyline.py deleted file mode 100644 index 4014059ed8..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/cpolyline.py +++ /dev/null @@ -1,210 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Create a polygon -""" -import ctypes -import os.path - -from cwrap import BaseCClass -from ecl.geo import GeoPrototype -from .geometry_tools import GeometryTools - - -class CPolyline(BaseCClass): - TYPE_NAME = "geo_polygon" - - _alloc_new = GeoPrototype("void* geo_polygon_alloc( char* )" , bind = False) - _fread_alloc_irap = GeoPrototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )" , bind = False) - _add_point = GeoPrototype("void geo_polygon_add_point( geo_polygon , double , double )") - _add_point_front = GeoPrototype("void geo_polygon_add_point_front( geo_polygon , double , double )") - _free = GeoPrototype("void geo_polygon_free( geo_polygon )") - _size = GeoPrototype("int geo_polygon_get_size( geo_polygon )") - _iget_xy = GeoPrototype("void geo_polygon_iget_xy( geo_polygon , int , double* , double* )") - _segment_intersects = GeoPrototype("bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)") - _get_name = GeoPrototype("char* geo_polygon_get_name( geo_polygon )") - _set_name = GeoPrototype("void geo_polygon_set_name( geo_polygon , char* )") - _segment_length = GeoPrototype("double geo_polygon_get_length( geo_polygon)") - _equal = GeoPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") - - - def __init__(self, name = None , init_points = ()): - c_ptr = self._alloc_new( name ) - super(CPolyline , self).__init__( c_ptr ) - for (xc, yc) in init_points: - self.addPoint(xc, yc) - - - @classmethod - def createFromXYZFile(cls , filename , name = None): - if not os.path.isfile(filename): - raise IOError("No such file:%s" % filename) - - polyline = cls._fread_alloc_irap( filename ) - if not name is None: - polyline._set_name( name ) - return polyline - - def __str__(self): - name = self.getName() - if name: - str = "%s [" % name - else: - str = "[" - - for index,p in enumerate(self): - str += "(%g,%g)" % p - if index < len(self) - 1: - str += "," - str += "]" - return str - - def __repr__(self): - return str(self) - - - def __len__(self): - return self._size() - - - def __getitem__(self , index): - if not isinstance(index,int): - raise TypeError("Index argument must be integer. Index:%s invalid" % index) - - if index < 0: - index += len(self) - - if 0 <= index < len(self): - x = ctypes.c_double() - y = ctypes.c_double() - self._iget_xy( index , ctypes.byref(x) , ctypes.byref(y) ) - - return (x.value , y.value) - else: - raise IndexError("Invalid index:%d valid range: [0,%d)" % (index , len(self))) - - - def segmentIntersects(self, p1 , p2): - return self._segment_intersects(p1[0] , p1[1] , p2[0] , p2[1]) - - - def intersects(self , polyline): - if len(self) > 1: - for index,p2 in enumerate(polyline): - if index == 0: - continue - - p1 = polyline[index - 1] - if self.segmentIntersects(p1 , p2): - return True - return False - - - def __iadd__(self , other ): - for p in other: - self.addPoint( p[0] , p[1] ) - return self - - - def __add__(self , other ): - copy = CPolyline( init_points = self) - copy.__iadd__(other) - return copy - - - def __radd__(self , other ): - copy = CPolyline( init_points = other ) - copy.__iadd__(self) - return copy - - def __eq__(self , other): - if super(CPolyline , self).__eq__( other ): - return True - else: - return self._equal( other ) - - - def segmentLength(self): - if len(self) == 0: - raise ValueError("Can not measure length of zero point polyline") - - return self._segment_length( ) - - def extendToBBox(self , bbox , start = True): - if start: - p0 = self[1] - p1 = self[0] - else: - p0 = self[-2] - p1 = self[-1] - - ray_dir = GeometryTools.lineToRay(p0,p1) - intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , bbox) - if intersections: - p2 = intersections[0][1] - if self.getName(): - name = "Extend:%s" % self.getName() - else: - name = None - - return CPolyline( name = name , init_points = [(p1[0] , p1[1]) , p2]) - else: - raise ValueError("Logical error - must intersect with bounding box") - - - def addPoint( self, xc, yc , front = False): - if front: - self._add_point_front(xc, yc) - else: - self._add_point(xc, yc) - - - def getName(self): - return self._get_name( ) - - - def free(self): - self._free( ) - - - def unzip(self): - x_list = [ ] - y_list = [ ] - for x,y in self: - x_list.append(x) - y_list.append(y) - - return (x_list , y_list) - - - def unzip2(self): - return self.unzip() - - - def connect(self , target): - end1 = self[0] - end2 = self[-1] - - p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) - p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) - - d1 = GeometryTools.distance( p1 , end1 ) - d2 = GeometryTools.distance( p2 , end2 ) - - if d1 < d2: - return [end1 , p1] - else: - return [end2 , p2] diff --git a/ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py b/ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py deleted file mode 100644 index b93f5596d9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'cpolyline_collection.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Create a polygon -""" -import ctypes - -from cwrap import BaseCClass -from ecl.geo import GeoPrototype, CPolyline - - -class CPolylineCollection(BaseCClass): - TYPE_NAME = "geo_polygon_collection" - - _alloc_new = GeoPrototype("void* geo_polygon_collection_alloc( )" , bind = False) - _free = GeoPrototype("void geo_polygon_collection_free( geo_polygon_collection )" ) - _size = GeoPrototype("int geo_polygon_collection_size( geo_polygon_collection)" ) - _create_polyline = GeoPrototype("geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) - _has_polyline = GeoPrototype("bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) - _iget = GeoPrototype("geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) - _get = GeoPrototype("geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) - _add_polyline = GeoPrototype("void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)") - - - - def __init__(self): - c_ptr = self._alloc_new( ) - super(CPolylineCollection , self).__init__( c_ptr ) - self.parent_ref = None - - - def __contains__(self , name): - return self._has_polyline(name) - - - def __len__(self): - return self._size( ) - - - def __iter__(self): - index = 0 - - while index < len(self): - yield self[index] - index += 1 - - - def __getitem__(self , index): - if isinstance(index , int): - if index < 0: - index += len(self) - - if 0 <= index < len(self): - return self._iget( index).setParent( self ) - else: - raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , len(self))) - elif isinstance(index , str): - if index in self: - return self._get(index) - else: - raise KeyError("No polyline named:%s" % index) - else: - raise TypeError("The index argument must be string or integer") - - - def shallowCopy(self): - copy = CPolylineCollection() - for pl in self: - copy._add_polyline(pl , False) - - # If we make a shallow copy we must ensure that source, owning - # all the polyline objects does not go out of scope. - copy.parent_ref = self - return copy - - - - def addPolyline(self , polyline , name = None): - if not isinstance(polyline , CPolyline): - polyline = CPolyline( init_points = polyline , name = name) - else: - if not name is None: - raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object") - - name = polyline.getName() - if name and name in self: - raise KeyError("The polyline collection already has an object:%s" % name) - - if polyline.isReference(): - self._add_polyline( polyline , False) - else: - polyline.convertToCReference( self ) - self._add_polyline( polyline , True) - - - - def createPolyline(self , name = None): - if name and name in self: - raise KeyError("The polyline collection already has an object:%s" % name) - - polyline = self._create_polyline(name) - polyline.setParent( parent = self ) - return polyline - - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py b/ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py deleted file mode 100644 index ff9fa3b2ec..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from cwrap import BaseCClass -from ecl.geo import GeoPrototype - -class GeoPointset(BaseCClass): - TYPE_NAME = "geo_pointset" - - _alloc = GeoPrototype("void* geo_pointset_alloc(bool)", bind=False) - _free = GeoPrototype("void geo_pointset_free(geo_pointset)") - #_add_xyz = GeoPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") - _get_size = GeoPrototype("int geo_pointset_get_size(geo_pointset)") - #_iget_xy = GeoPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") - #_get_zcoord = GeoPrototype("double* geo_pointset_get_zcoord(geo_pointset)") - _equal = GeoPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") - _iget_z = GeoPrototype("double geo_pointset_iget_z(geo_pointset, int)") - #_iset_z = GeoPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") - #_memcpy = GeoPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") - #_shift_z = GeoPrototype("void geo_pointset_shift_z(geo_pointset, double)") - #_assign_z = GeoPrototype("void geo_pointset_assign_z(geo_pointset, double)") - #_scale_z = GeoPrototype("void geo_pointset_scale_z(geo_pointset, double)") - #_imul = GeoPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") - #_iadd = GeoPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") - #_isub = GeoPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") - #_isqrt = GeoPrototype("void geo_pointset_isqrt(geo_pointset)") - - - def __init__(self, external_z=False): - c_ptr = self._alloc(external_z) - if c_ptr: - super(GeoPointset, self).__init__(c_ptr) - else: - ext = 'external' if external_z else 'internal' - raise ValueError('Failed to construct GeoPointset with %s_z.' % ext) - - @staticmethod - def fromSurface(surface): - return surface.getPointset() - - def __eq__(self, other): - if isinstance(other, GeoPointset): - return self._equal(other) - return NotImplemented - - def __getitem__(self, key): - size = len(self) - if isinstance(key, int): - idx = key - if idx < 0: - idx += size - if 0 <= idx < size: - return self._iget_z(idx) - else: - raise IndexError('Invalid index, must be in [0, %d), was: %d.' % (size, key)) - else: - # TODO implement slicing? - raise ValueError('Index must be int, not %s.' % type(key)) - - def __len__(self): - return self._get_size() - - def __repr__(self): - return self._create_repr('len=%d' % len(self)) - - def free(self): - self._free() diff --git a/ThirdParty/Ert/python/python/ecl/geo/geo_region.py b/ThirdParty/Ert/python/python/ecl/geo/geo_region.py deleted file mode 100644 index a4238d8650..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/geo_region.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from cwrap import BaseCClass -from ecl.util import IntVector -from ecl.geo import GeoPrototype -from .cpolyline import CPolyline -from ctypes import c_double - -cpair = c_double * 2 # this is a function that maps two doubles to a double* - -class GeoRegion(BaseCClass): - TYPE_NAME = "geo_region" - - _alloc = GeoPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) - _free = GeoPrototype("void geo_region_free(geo_region)") - _reset = GeoPrototype("void geo_region_reset(geo_region)") - _get_index_list = GeoPrototype("int_vector_ref geo_region_get_index_list(geo_region)") - _select_inside_polygon = GeoPrototype("void geo_region_select_inside_polygon(geo_region, geo_polygon)") - _select_outside_polygon = GeoPrototype("void geo_region_select_outside_polygon(geo_region, geo_polygon)") - _deselect_inside_polygon = GeoPrototype("void geo_region_deselect_inside_polygon(geo_region, geo_polygon)") - _deselect_outside_polygon = GeoPrototype("void geo_region_deselect_outside_polygon(geo_region, geo_polygon)") - _select_above_line = GeoPrototype("void geo_region_select_above_line(geo_region, double*, double*)") - _select_below_line = GeoPrototype("void geo_region_select_below_line(geo_region, double*, double*)") - _deselect_above_line = GeoPrototype("void geo_region_deselect_above_line(geo_region, double*, double*)") - _deselect_below_line = GeoPrototype("void geo_region_deselect_below_line(geo_region, double*, double*)") - - - def __init__(self, pointset, preselect=False): - self._preselect = True if preselect else False - c_ptr = self._alloc(pointset, self._preselect) - if c_ptr: - super(GeoRegion, self).__init__(c_ptr) - else: - raise ValueError('Could not construct GeoRegion from pointset %s.' % pointset) - - - def getActiveList(self): - return self._get_index_list() - - def _assert_polygon(self, polygon): - if not isinstance(polygon, CPolyline): - raise ValueError('Need to select with a CPolyline, not %s.' - % type(polygon)) - - - def _construct_cline(self, line): - """Takes a line ((x1,y1), (x2,y2)) and returns two double[2]* but - reordered to (x1x2, y1y2). - """ - try: - p1, p2 = line - x1, y1 = map(float, p1) - x2, y2 = map(float, p2) - except Exception as err: - err_msg = 'Select with pair ((x1,y1), (x2,y2)), not %s (%s).' - raise ValueError(err_msg % (line, err)) - x1x2_ptr = cpair(x1, x2) - y1y2_ptr = cpair(y1, y2) - return x1x2_ptr, y1y2_ptr - - - def select_inside(self, polygon): - self._assert_polygon(polygon) - self._select_inside_polygon(polygon) - - def select_outside(self, polygon): - self._assert_polygon(polygon) - self._select_outside_polygon(polygon) - - def deselect_inside(self, polygon): - self._assert_polygon(polygon) - self._deselect_inside_polygon(polygon) - - def deselect_outside(self, polygon): - self._assert_polygon(polygon) - self._deselect_outside_polygon(polygon) - - - def select_above(self, line): - x_ptr, y_ptr = self._construct_cline(line) - self._select_above_line(x_ptr, y_ptr) - - def select_below(self, line): - x_ptr, y_ptr = self._construct_cline(line) - self._select_below_line(x_ptr, y_ptr) - - def deselect_above(self, line): - x_ptr, y_ptr = self._construct_cline(line) - self._deselect_above_line(x_ptr, y_ptr) - - def deselect_below(self, line): - x_ptr, y_ptr = self._construct_cline(line) - self._deselect_below_line(x_ptr, y_ptr) - - - def __len__(self): - """Returns the size of the active list, not the size of the - underlying pointset""" - return len(self._get_index_list()) - - def __repr__(self): - ls = len(self) - il = repr(self.getActiveList()) - pres = 'preselected' if self._preselect else 'not preselected' - return self._create_repr('size=%d, active_list=<%s>, %s' % (ls, il, pres)) - - def free(self): - self._free() diff --git a/ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py b/ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py deleted file mode 100644 index 9c33b89010..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py +++ /dev/null @@ -1,448 +0,0 @@ -from math import sqrt -import sys - -class GeometryTools(object): - EPSILON = 0.000001 - - @staticmethod - def lineIntersection(p1, p2, p3, p4): - """ - Finds intersection between line segments. Returns None if no intersection found. - Algorithm provided by Paul Bourke - - @type p1: tuple of (float, float) - @type p2: tuple of (float, float) - @type p3: tuple of (float, float) - @type p4: tuple of (float, float) - @rtype: tuple of (float, float) - """ - - denominator = (p4[1] - p3[1]) * (p2[0] - p1[0]) - (p4[0] - p3[0]) * (p2[1] - p1[1]) - numerator_a = (p4[0] - p3[0]) * (p1[1] - p3[1]) - (p4[1] - p3[1]) * (p1[0] - p3[0]) - numerator_b = (p2[0] - p1[0]) * (p1[1] - p3[1]) - (p2[1] - p1[1]) * (p1[0] - p3[0]) - - # coincident? - if abs(numerator_a) < GeometryTools.EPSILON and abs(numerator_b) < GeometryTools.EPSILON and abs(denominator) < GeometryTools.EPSILON: - return None - - # parallel? - if abs(denominator) < GeometryTools.EPSILON: - return None - - - # intersection along the segments? - mua = numerator_a / denominator - mub = numerator_b / denominator - - if mua < 0.0 or mua > 1.0 or mub < 0.0 or mub > 1.0: - return None - - x = p1[0] + mua * (p2[0] - p1[0]) - y = p1[1] + mua * (p2[1] - p1[1]) - return x, y - - @staticmethod - def polylinesIntersect(polyline1 , polyline2): - """Test if the polylines polyline1 and polyline2 intersect. - - The input arguments must be either Polyline instances[1], or a - list of (float,float) tuples. The method performs a super - naive n^2 check and should not be used for large polyline objects. - - @type polyline1: Polyline or list of tuple of (float, float) - @type polyline2: Polyline or list of tuple of (float, float) - - [1]: The z - coordinate will be ignored. - - """ - - for index1 in range(len(polyline1) - 1): - p1 = polyline1[index1] - p2 = polyline1[index1 + 1] - for index2 in range(len(polyline2) - 1): - p3 = polyline2[index2] - p4 = polyline2[index2 + 1] - - if GeometryTools.lineIntersection(p1,p2,p3,p4): - return True - - return False - - - - - @staticmethod - def ccw(p1, p2, p3): - """ - Three points are a counter-clockwise turn if ccw > 0, clockwise if - ccw < 0, and collinear if ccw = 0 because ccw is a determinant that - gives the signed area of the triangle formed by p1, p2 and p3. - - @type p1: tuple of (float, float) - @type p2: tuple of (float, float) - @type p3: tuple of (float, float) - @rtype: float - """ - return (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0]) - - - @staticmethod - def convexHull(points): - """ - Given a list of points finds the convex hull - @type points: list of tuple of (float, float) - @rtype: list of tuple of (float, float) - """ - points = sorted(points) - - def keepLeft(hull, r): - while len(hull) > 1 and GeometryTools.ccw(hull[-2], hull[-1], r) > 0: - hull.pop() - - if len(hull) == 0 or hull[-1] != r: - hull.append(r) - - return hull - - l = reduce(keepLeft, points, []) - u = reduce(keepLeft, reversed(points), []) - l.extend([u[i] for i in xrange(1, len(u) - 1)]) - - return l - - - @staticmethod - def pointInPolygon(p, polygon): - """ - Finds out if a point is inside a polygon or not - @type p: tuple of (float, float) - @type polygon: Polyline or list of tuple of (float, float) - @rtype: bool - """ - x = p[0] - y = p[1] - n = len(polygon) - - inside = False - - p1x, p1y = polygon[0][0:2] - for index in range(n + 1): - p2x, p2y = polygon[index % n][0:2] - - if min(p1y, p2y) < y <= max(p1y, p2y): - if x <= max(p1x, p2x): - if p1y != p2y: - xints = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x - - if p1x == p2x or x <= xints: - inside = not inside - - p1x, p1y = p2x, p2y - - return inside - - - @staticmethod - def extendToEdge(bounding_polygon, poly_line): - """ - """ - assert(bounding_polygon.isClosed()) - for p in poly_line: - if not GeometryTools.pointInPolygon( p , bounding_polygon): - raise ValueError("The point:%s was not inside bounding polygon") - - p1 = poly_line[0] - ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) - intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex - - - p2 = poly_line[-1] - assert(GeometryTools.pointInPolygon(p2 , bounding_polygon)) - - ray2 = GeometryTools.lineToRay(poly_line[-2], poly_line[-1]) - intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon) - intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex - - return [intersection1[1]] + poly_line + [intersection2[1]] - - - @staticmethod - def slicePolygon(bounding_polygon, poly_line): - """ - This algorithm extends the end-points of the line and find intersections between the line - and the enclosing polygon. The result is a polygon sliced by the extended line. - - The enclosing polygon must be convex, closed and completely enclose the line. - - @type bounding_polygon: Polyline or list of tuple of (float, float) - @type poly_line: Polyline or list of tuple of (float, float) - @rtype: list of tuple of (float, float) - """ - - p1 = poly_line[0] - ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) - tmp = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon) - intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex - - p2 = poly_line[-1] - ray2 = GeometryTools.lineToRay(poly_line[-2], poly_line[-1]) - intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex - - - # Check for intersection between the polyline extensions on the inside of the bounadary - internal_intersection = GeometryTools.lineIntersection( p1 , intersection1[1] , p2 , intersection2[1]) - if internal_intersection: - start_point = poly_line[0] - return poly_line + [ internal_intersection , start_point] - - - - if intersection2[0] < intersection1[0]: - intersection1, intersection2 = intersection2, intersection1 - poly_line = list(reversed(poly_line)) - - result = [intersection1[1]] - - for index in range(intersection1[0] + 1, intersection2[0] + 1): - result.append(bounding_polygon[index]) - - result.append(intersection2[1]) - - for point in reversed(poly_line): - result.append(point) - - result.append(intersection1[1]) - - return result - - - - - @staticmethod - def lineToRay(p0, p1): - """ - Converts a line segment to a unit vector starting at p0 pointing towards p1. - @type p0: tuple of (float, float) - @type p1: tuple of (float, float) - @rtype: tuple of (float, float) - """ - - x = p1[0] - p0[0] - y = p1[1] - p0[1] - - length = sqrt(x * x + y * y) - - return x / length, y / length - - - @staticmethod - def rayLineIntersection(point, ray, p1, p2 , flip_ray = False): - """ - Finds the intersection between the ray starting at point and the line [p1, p2]. - @type point: tuple of (float, float) - @type ray: tuple of (float, float) - @type p1: tuple of (float, float) - @type p2: tuple of (float, float) - @rtype: tuple of (float, float) or None - - stackoverflow: 563198 - """ - s = (p2[0] - p1[0] , p2[1] - p1[1]) - q = p1 - r = ray - p = point - - p_m_q = (p[0] - q[0] , p[1] - q[1]) - q_m_p = (q[0] - p[0] , q[1] - p[1]) - r_x_s = r[0] * s[1] - r[1]*s[0] - - q_m_p_x_r = q_m_p[0] * r[1] - q_m_p[1] * r[0] - q_m_p_x_s = q_m_p[0] * s[1] - q_m_p[1] * s[0] - - if abs(r_x_s) < GeometryTools.EPSILON and abs(q_m_p_x_r) < GeometryTools.EPSILON: - q_m_p_dot_r = q_m_p[0] * r[0] + q_m_p[1] * r[1] - r_dot_r = r[0] * r[0] + r[1] * r[1] - - p_m_q_dot_s = p_m_q[0] * s[0] + p_m_q[1] * s[1] - s_dot_s = s[0] * s[0] + s[1] * s[1] - - # Coincident - if 0 <= q_m_p_dot_r <= r_dot_r: - return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) - - # Coincident - if 0 <= p_m_q_dot_s <= s_dot_s: - return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) - - return None - - - if abs(r_x_s) < GeometryTools.EPSILON: - # Parallell - return None - - - t = 1.0 * q_m_p_x_s / r_x_s - u = 1.0 * q_m_p_x_r / r_x_s - - if t >= 0 and 0 <= u <= 1: - x = p[0] + t*r[0] - y = p[1] + t*r[1] - - return x,y - - if flip_ray: - return GeometryTools.rayLineIntersection( point , (-ray[0] , -ray[1]) , p1 , p2 , False) - else: - return None - - - - - @staticmethod - def rayPolygonIntersections(point, ray, polygon): - """ - Finds all intersections along the ray with the polygon. - The returned value is a tuple containing the line segment in the polygon and the intersection coordinate. - - @type point: tuple of (float, float) - @type ray: tuple of (float, float) - @type polygon: Polyline or [tuple of (float, float)] - @rtype: list of tuple of (int, tuple of (float, float)) - """ - results = [] - for index in range(len(polygon) - 1): - lp1 = polygon[index] - lp2 = polygon[index + 1] - - intersection = GeometryTools.rayLineIntersection(point, ray, lp1, lp2) - if intersection is not None: - results.append((index, intersection)) - - return results - - - @staticmethod - def distance(p1,p2): - if len(p1) != len(p2): - raise ValueError("Different lenght of objects") - - sqr_distance = 0 - for x1,x2 in zip(p1,p2): - sqr_distance += (x1 - x2) * (x1 - x2) - - return sqrt( sqr_distance ) - - - @staticmethod - def joinPolylines(polyline1 , polyline2): - """The shortest straight line connecting polyline1 and polyline2. - - The joinPolylines function does not extend the polylines with - a ray from the end, only the length of the straight line - connecting the various endpoints is considered. If the two - polylines already intersect the function returns None. - """ - - - if len(polyline1) < 1: - raise ValueError("Length of polyline must be >= 1") - - if len(polyline2) < 1: - raise ValueError("Length of polyline must be >= 1") - - if GeometryTools.polylinesIntersect( polyline1 , polyline2): - return None - - p0 = polyline1[0] - p1 = polyline1[-1] - pa = polyline2[0] - pb = polyline2[-1] - - d_list = [ (GeometryTools.distance( p0 , pa ), [p0 , pa]), - (GeometryTools.distance( p0 , pb ), [p0 , pb]), - (GeometryTools.distance( p1 , pa ), [p1 , pa]), - (GeometryTools.distance( p1 , pb ), [p1 , pb]) ] - - d_list.sort( key = lambda x: x[0]) - return d_list[0][1] - - - @staticmethod - def connectPolylines( polyline , target_polyline): - if GeometryTools.polylinesIntersect( polyline , target_polyline ): - return None - - if len(polyline) < 2: - raise ValueError("Polyline must have at least two points") - - d_list = [] - - p0 = polyline[-1] - p1 = polyline[-2] - ray = GeometryTools.lineToRay( p1 , p0 ) - for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): - d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) - - p0 = polyline[0] - p1 = polyline[1] - ray = GeometryTools.lineToRay( p1 , p0 ) - for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): - d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) - - if len(d_list) == 0: - raise ValueError("Polyline %s can not be extended to %s" % (polyline.getName() , target_polyline.getName())) - - d_list.sort( key = lambda x: x[0]) - return d_list[0][1] - - - - @staticmethod - def nearestPointOnPolyline( p , polyline ): - if len(polyline) > 1: - d_list = [ GeometryTools.distance( p , pi ) for pi in polyline ] - index0 = d_list.index( min(d_list) ) - p0 = polyline[index0] - dist0 = d_list[index0] - - dist1 = sys.float_info.max - dist2 = sys.float_info.max - intercept1 = None - intercept2 = None - - index1 = None - index2 = None - if index0 > 0: - index1 = index0 - 1 - - if index0 < len(polyline) - 1: - index2 = index0 + 1 - - if not index1 is None: - p1 = polyline[index1] - dy1 = p1[1] - p0[1] - dx1 = p1[0] - p0[0] - intercept1 = GeometryTools.rayLineIntersection( p , (dy1 , -dx1) , p0 , p1 , True) - if intercept1: - dist1 = GeometryTools.distance( intercept1 , p ) - - - if not index2 is None: - p2 = polyline[index2] - dy2 = p2[1] - p0[1] - dx2 = p2[0] - p0[0] - intercept2 = GeometryTools.rayLineIntersection( p , (dy2 , -dx2) , p0 , p2 , True) - if intercept2: - dist2 = GeometryTools.distance( intercept2 , p ) - - - point_list = [ p0 , intercept1 , intercept2 ] - d_list = [ dist0 , dist1 , dist2 ] - index = d_list.index( min(d_list) ) - - - return point_list[index] - else: - raise ValueError("Polyline must have len() >= 2") - diff --git a/ThirdParty/Ert/python/python/ecl/geo/polyline.py b/ThirdParty/Ert/python/python/ecl/geo/polyline.py deleted file mode 100644 index 8a11571a31..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/polyline.py +++ /dev/null @@ -1,171 +0,0 @@ -import collections -from .geometry_tools import GeometryTools - -class Polyline(object): - def __init__(self, name=None , init_points = None): - super(Polyline, self).__init__() - self.__name = name - self.__points = [] - if init_points: - self.loadPoints( init_points ) - - def __str__(self): - s = "Polyline:[ " - for p in self: - s += "(%s,%s) " % (p[0],p[1]) - s += "]" - return s - - def getName(self): - """ @rtype: str """ - return self.__name - - - def __iadd__(self , other ): - for p in other: - self.__points.append( p ) - return self - - - def __add__(self , other ): - copy = Polyline( init_points = self) - copy.__iadd__(other) - return copy - - - def __radd__(self , other ): - copy = Polyline( init_points = other ) - copy.__iadd__(self) - return copy - - - def __eq__(self, other): - if len(self) != len(other): - return False - - for (p1,p2) in zip(self , other): - if p1 != p2: - return False - - return True - - - - def __len__(self): - return len(self.__points) - - def addPoint(self, x, y, z=None): - if z is None: - p = (x, y) - else: - p = (x, y, z) - self.__points.append(p) - - def __getitem__(self, index): - """ @rtype: tuple of (float, float, float) """ - if index < 0: - index += len(self) - - if not 0 <= index < len(self): - raise IndexError("Index:%d invalid must be in range: [0, %d]" % (index, (len(self) - 1))) - return self.__points[index] - - def isClosed(self): - first = self[0] - last = self[-1] - - return first == last - - - def assertClosed(self): - if not self.isClosed(): - first_point = self[0] - - x = first_point[0] - y = first_point[1] - try: - z = first_point[2] - self.addPoint(x,y,z) - except IndexError: - self.addPoint(x,y) - - - - - - def loadPoints(self , points): - for point in points: - x = point[0] - y = point[1] - try: - z = point[2] - except IndexError: - z = None - - self.addPoint(x,y,z) - - def intersects(self, other_polyline): - """ - Test if instances intersects with other polyline. - - @type other_polyline: Polyline or list of tuple of (float, float) - @rtype: bool - """ - return GeometryTools.polylinesIntersect( self , other_polyline ) - - - def __iter__(self): - index = 0 - - while index < len(self): - yield self[index] - index += 1 - - - def unzip2(self): - x = [] - y = [] - for p in self: - x.append(p[0]) - y.append(p[1]) - - return (x,y) - - - def unzip(self): - first_point = self[0] - x = [] - y = [] - - try: - z = first_point[2] - z = [] - for p in self: - x.append(p[0]) - y.append(p[1]) - z.append(p[2]) - - return (x,y,z) - except IndexError: - for p in self: - x.append(p[0]) - y.append(p[1]) - - return (x,y) - - - def connect(self , target): - end1 = self[0] - end2 = self[-1] - - p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) - p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) - - d1 = GeometryTools.distance( p1 , end1 ) - d2 = GeometryTools.distance( p2 , end2 ) - - if d1 < d2: - return [end1 , p1] - else: - return [end2 , p2] - diff --git a/ThirdParty/Ert/python/python/ecl/geo/surface.py b/ThirdParty/Ert/python/python/ecl/geo/surface.py deleted file mode 100644 index 6dfeae9b9a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/surface.py +++ /dev/null @@ -1,285 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# The file 'surface' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Create a polygon -""" -import os.path -import ctypes -from numpy import zeros - -from cwrap import BaseCClass -from ecl.geo import GeoPrototype -from ecl.geo import GeoPointset - -class Surface(BaseCClass): - TYPE_NAME = "surface" - - _alloc = GeoPrototype("void* geo_surface_fload_alloc_irap( char* , bool )" , bind = False) - _free = GeoPrototype("void geo_surface_free( surface )") - _new = GeoPrototype("void* geo_surface_alloc_new( int, int, double, double, double, double, double )", bind = False) - _get_nx = GeoPrototype("int geo_surface_get_nx( surface )") - _get_ny = GeoPrototype("int geo_surface_get_ny( surface )") - _iget_zvalue = GeoPrototype("double geo_surface_iget_zvalue( surface , int)") - _iset_zvalue = GeoPrototype("void geo_surface_iset_zvalue( surface , int , double)") - _write = GeoPrototype("void geo_surface_fprintf_irap( surface , char* )") - _equal = GeoPrototype("bool geo_surface_equal( surface , surface )") - _header_equal = GeoPrototype("bool geo_surface_equal_header( surface , surface )") - _copy = GeoPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") - _assign = GeoPrototype("void geo_surface_assign_value( surface , double )") - _scale = GeoPrototype("void geo_surface_scale( surface , double )") - _shift = GeoPrototype("void geo_surface_shift( surface , double )") - _iadd = GeoPrototype("void geo_surface_iadd( surface , surface )") - _imul = GeoPrototype("void geo_surface_imul( surface , surface )") - _isub = GeoPrototype("void geo_surface_isub( surface , surface )") - _isqrt = GeoPrototype("void geo_surface_isqrt( surface )") - _iget_xy = GeoPrototype("void geo_surface_iget_xy(surface, int, double*, double*)") - _get_pointset = GeoPrototype("geo_pointset_ref geo_surface_get_pointset(surface)") - - - def __init__(self, filename=None, nx=None, ny=None, xinc=None, yinc=None, - xstart=None, ystart=None, angle=None): - """ - This will load a irap surface from file. The surface should - consist of a header and a set z values. - """ - if filename is not None: - filename = str(filename) - if os.path.isfile( filename ): - c_ptr = self._alloc(filename , True) - super(Surface , self).__init__(c_ptr) - else: - raise IOError('No such file "%s".' % filename) - else: - s_args = [nx, ny, xinc, yinc, xstart, ystart, angle] - if None in s_args: - raise ValueError('Missing argument for creating surface, all values must be set, was: %s' % str(s_args)) - c_ptr = self._new(*s_args) - super(Surface , self).__init__(c_ptr) - - def __eq__(self , other): - """ - Compares two Surface instances, both header and data must be equal - to compare as equal. - """ - if isinstance( other , Surface): - return self._equal(other) - else: - return False - - - def headerEqual(self , other): - return self._header_equal( other) - - - def __iadd__(self , other): - if isinstance(other , Surface): - if self.headerEqual(other): - self._iadd(other) - else: - raise ValueError("Tried to add incompatible surfaces") - else: - self._shift(other) - return self - - - def __isub__(self , other): - if isinstance(other , Surface): - if self.headerEqual(other): - self._isub(other) - else: - raise ValueError("Tried to subtract incompatible surfaces") - else: - self._shift( -other) - return self - - - def __imul__(self , other): - if isinstance(other , Surface): - if self.headerEqual(other): - self._imul( other) - else: - raise ValueError("Tried to add multiply ncompatible surfaces") - else: - self._scale( other) - return self - - - def __idiv__(self , other): - self._scale( 1.0/other) - return self - - - def __add__(self , other): - copy = self.copy() - copy += other - return copy - - - def __mul__(self , other): - copy = self.copy() - copy *= other - return copy - - - def __sub__(self , other): - copy = self.copy() - copy -= other - return copy - - - def __div__(self , other): - copy = self.copy() - copy /= other - return copy - - - def __len__(self): - """ - The number of values in the surface. - """ - return self.getNX() * self.getNY() - - - def inplaceSqrt(self): - """ - Will do an inplace sqrt operation. - """ - self._isqrt( ) - return self - - - def sqrt(self): - """ - Will return a new surface where all elements have been sqrt{ .. }. - """ - copy = self.copy( ) - copy.inplaceSqrt( ) - return copy - - - def copy(self , copy_data = True): - """Will create a deep copy of self, if copy_data is set to False the - copy will have all z-values set to zero. - """ - return self._copy( copy_data) - - - def write(self , filename): - - """ - Will write the surface as an ascii formatted file to @filename. - """ - self._write( filename ) - - - - def assign(self , value): - """ - Will set all the values in the surface to @value" - """ - self._assign(value) - - - def __setitem__(self , index , value): - if isinstance(index , int): - if index >= len(self): - raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self))) - if index < 0: - index += len(self) - - self._iset_zvalue(index , value) - else: - raise TypeError("Invalid index type:%s - must be integer" % index) - - - def __getitem__(self , index): - if isinstance(index , int): - idx = index - ls = len(self) - if idx < 0: - idx += ls - if 0 <= idx < ls: - return self._iget_zvalue(idx) - else: - raise IndexError("Invalid index:%d - valid range [0,%d)" % (index , len(self))) - else: - raise TypeError("Invalid index type:%s - must be integer" % index) - - - def getXY(self, index): - """Gets the index'th (x,y) coordinate""" - if isinstance(index, int): - idx = index - if idx < 0: - idx += len(self) - if not 0 <= idx < len(self): - raise IndexError("Invalid index:%d - valid range [0,%d)" % (index, len(self))) - index = idx - else: - raise TypeError("Invalid index type:%s - must be integer" % index) - - x = ctypes.c_double() - y = ctypes.c_double() - self._iget_xy(index, ctypes.byref(x), ctypes.byref(y)) - - return x.value, y.value - - - def getNX(self): - return self._get_nx() - - - def getNY(self): - return self._get_ny() - - def getPointset(self): - return self._get_pointset() - - def _assert_idx_or_i_and_j(self, idx, i, j): - if idx is None: - if i is None or j is None: - raise ValueError('idx is None, i and j must be ints, was %s and %s.' % (i, j)) - else: - if i is not None or j is not None: - raise ValueError('idx is set, i and j must be None, was %s and %s.' % (i, j)) - - - def getXYZ(self, idx=None, i=None, j=None): - """Returns a tuple of 3 floats, (x,y,z) for given global index, or i and j.""" - self._assert_idx_or_i_and_j(idx, i, j) - if idx is None: - nx, ny = self.getNX(), self.getNY() - i_idx, j_idx = i,j - if i_idx < 0: - i_idx += self.getNX() - if j_idx < 0: - j_idx += self.getNY() - if 0 <= i_idx < self.getNX() and 0 <= j_idx < self.getNY(): - idx = j_idx * self.getNX() + i_idx - else: - fmt = 'Index error: i=%d not in [0,nx=%d) or j=%d not in [0,ny=%d).' - raise IndexError(fmt % (i, nx, j, ny)) - x,y = self.getXY(idx) - z = self[idx] - return (x,y,z) - - - def free(self): - self._free() - - def __repr__(self): - cnt = 'nx=%d, ny=%d' % (self.getNX(), self.getNY()) - return self._create_repr(cnt) diff --git a/ThirdParty/Ert/python/python/ecl/geo/xyz_io.py b/ThirdParty/Ert/python/python/ecl/geo/xyz_io.py deleted file mode 100644 index 9f349b339f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/geo/xyz_io.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -from .polyline import Polyline - -class XYZIo(object): - - @staticmethod - def readXYZFile(path): - """ @rtype: Polyline """ - - if not os.path.exists(path): - raise IOError("Path does not exist '%s'!" % path) - - name = os.path.basename(path) - - polyline = Polyline(name=name) - - with open(path, "r") as f: - for line in f: - line = line.strip() - if line: - x, y, z = map(float, line.split()) - - if x != 999.000000 and y != 999.000000 and z != 999.000000: - polyline.addPoint(x, y, z) - else: - break - else: - break - - return polyline - - - @staticmethod - def readXYFile(path): - """ @rtype: Polyline """ - - if not os.path.exists(path): - raise IOError("Path does not exist '%s'!" % path) - - name = os.path.basename(path) - - polyline = Polyline(name=name) - - with open(path, "r") as f: - for line in f: - x, y= map(float, line.split()) - polyline.addPoint(x, y) - - return polyline - - - @staticmethod - def saveXYFile(polyline , filename): - """ - @type polyline: Polyline or list of tuple of (float, float) - """ - with open(filename , "w") as fileH: - for p in polyline: - fileH.write("%g %g\n" % (p[0] , p[1])) - - - diff --git a/ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt deleted file mode 100644 index 9e4bec490d..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ert_test_context.py - ert_test_runner.py - extended_testcase.py - test_run.py - source_enumerator.py - test_area.py - temp_area.py - path_context.py - lint_test_case.py - import_test_case.py - debug_msg.py -) - -add_python_package("python.ecl.test" ${PYTHON_INSTALL_PREFIX}/ecl/test "${PYTHON_SOURCES}" True) - -add_subdirectory(ecl_mock) diff --git a/ThirdParty/Ert/python/python/ecl/test/__init__.py b/ThirdParty/Ert/python/python/ecl/test/__init__.py deleted file mode 100644 index 1cc89f8d32..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -from .test_run import TestRun -from .test_run import path_exists -from .extended_testcase import ExtendedTestCase -from .source_enumerator import SourceEnumerator -from .test_area import TestArea , TestAreaContext -from .temp_area import TempArea , TempAreaContext -from .ert_test_runner import ErtTestRunner -from .path_context import PathContext -from .lint_test_case import LintTestCase -from .import_test_case import ImportTestCase -from .debug_msg import debug_msg diff --git a/ThirdParty/Ert/python/python/ecl/test/debug_msg.py b/ThirdParty/Ert/python/python/ecl/test/debug_msg.py deleted file mode 100644 index 4f479b9b74..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/debug_msg.py +++ /dev/null @@ -1,7 +0,0 @@ -import inspect - -def debug_msg(msg): - record = inspect.stack()[1] - frame = record[0] - info = inspect.getframeinfo( frame ) - return "FILE: %s LINE: %s Msg: %s" % (info.filename, info.lineno, msg) diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt deleted file mode 100644 index bfa1896cd5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ecl_sum_mock.py -) - -add_python_package("python.ecl.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/test/ecl_mock "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py b/ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py deleted file mode 100644 index eb49177fc0..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .ecl_sum_mock import createEclSum diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py deleted file mode 100644 index eb2b779229..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py +++ /dev/null @@ -1,30 +0,0 @@ -import datetime -from ecl.ecl import EclSum - - -def mock_func(ecl_sum , key , days): - return days * 10 - - -def createEclSum( case , keys , start = datetime.date(2010 , 1, 1) , sim_length_days = 5 * 365 , num_report_step = 5, num_mini_step = 10, dims = (20,10,5) , func_table = {}): - ecl_sum = EclSum.writer(case , start , dims[0] , dims[1] , dims[2]) - var_list = [] - for (kw,wgname,num) in keys: - var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num) ) - - report_step_length = sim_length_days / num_report_step - mini_step_length = report_step_length / num_mini_step - for report_step in range(num_report_step): - for mini_step in range(num_mini_step): - days = report_step * report_step_length + mini_step * mini_step_length - t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days ) - - for var in var_list: - key = var.getKey1( ) - if key in func_table: - func = func_table[key] - t_step[key] = func( days ) - else: - t_step[key] = mock_func( ecl_sum , key , days) - - return ecl_sum diff --git a/ThirdParty/Ert/python/python/ecl/test/ert_test_context.py b/ThirdParty/Ert/python/python/ecl/test/ert_test_context.py deleted file mode 100644 index dd89c5a720..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ert_test_context.py +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os.path - -from cwrap import BaseCClass -from ert.enkf import EnKFMain, EnkfPrototype - -class ErtTest(BaseCClass): - TYPE_NAME = "ert_test" - - _alloc = EnkfPrototype("void* ert_test_context_alloc_python( char* , char*)", bind = False) - _set_store = EnkfPrototype("void* ert_test_context_set_store( ert_test , bool)") - _free = EnkfPrototype("void ert_test_context_free( ert_test )") - _get_cwd = EnkfPrototype("char* ert_test_context_get_cwd( ert_test )") - _get_enkf_main = EnkfPrototype("enkf_main_ref ert_test_context_get_main( ert_test )") - - - - def __init__(self, test_name, model_config, store_area=False): - if not os.path.exists(model_config): - raise IOError("The configuration file: %s does not exist" % model_config) - else: - c_ptr = self._alloc(test_name, model_config) - super(ErtTest, self).__init__(c_ptr) - self.setStore(store_area) - - self.__ert = None - - def setStore(self, store): - self._set_store(store) - - def getErt(self): - """ @rtype: EnKFMain """ - if self.__ert is None: - self.__ert = self._get_enkf_main() - - return self.__ert - - def free(self): - ert = self.getErt() - ert.umount() - self._free() - - def installWorkflowJob(self, job_name, job_path): - """ @rtype: bool """ - if os.path.exists(job_path) and os.path.isfile(job_path): - ert = self.getErt() - workflow_list = ert.getWorkflowList() - - workflow_list.addJob(job_name, job_path) - return workflow_list.hasJob(job_name) - else: - return False - - def runWorkflowJob(self, job_name, *arguments): - """ @rtype: bool """ - ert = self.getErt() - workflow_list = ert.getWorkflowList() - - if workflow_list.hasJob(job_name): - job = workflow_list.getJob(job_name) - job.run(ert, [arg for arg in arguments]) - return True - else: - return False - - - def getCwd(self): - """ - Returns the current working directory of this context. - @rtype: string - """ - return self._get_cwd() - - - -class ErtTestContext(object): - def __init__(self, test_name, model_config, store_area=False): - self.__test_name = test_name - self.__model_config = model_config - self.__store_area = store_area - self.__test_context = ErtTest(self.__test_name, self.__model_config, store_area=self.__store_area) - - - def __enter__(self): - """ @rtype: ErtTest """ - return self.__test_context - - - def __exit__(self, exc_type, exc_val, exc_tb): - del self.__test_context - return False - - - def getErt(self): - return self.__test_context.getErt() - - - def getCwd(self): - """ - Returns the current working directory of this context. - @rtype: string - """ - return self.__test_context.getCwd() diff --git a/ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py b/ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py deleted file mode 100644 index 0ca274508f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py +++ /dev/null @@ -1,63 +0,0 @@ -import os - -try: - from unittest2 import TestLoader, TextTestRunner -except ImportError: - from unittest import TestLoader, TextTestRunner - - -class ErtTestRunner(object): - - @staticmethod - def runTestSuite(tests , test_verbosity = 3): - test_runner = TextTestRunner(verbosity=test_verbosity) - result = test_runner.run(tests) - - return result.wasSuccessful() - - - @staticmethod - def findTestsInDirectory(path, recursive=True , pattern = "test*.py"): - loader = TestLoader() - test_suite = loader.discover(path , pattern = pattern) - - for (root, dirnames, filenames) in os.walk( path ): - for directory in dirnames: - test_suite.addTests(ErtTestRunner.findTestsInDirectory(os.path.join(root, directory), recursive , pattern)) - - return test_suite - - - @staticmethod - def runTestsInDirectory(path=".", recursive=True, test_verbosity=3): - test_suite = ErtTestRunner.findTestsInDirectory(path, recursive) - return ErtTestRunner.runTestSuite(test_suite) - - - @staticmethod - def runTestsInClass(classpath, test_verbosity=3): - klass = ErtTestRunner.importClass(classpath) - loader = TestLoader() - tests = loader.loadTestsFromTestCase(klass) - testRunner = TextTestRunner(verbosity=test_verbosity) - testRunner.run(tests) - - - @staticmethod - def importClass(classpath): - dot = classpath.rfind(".") - class_name = classpath[dot + 1:] - try: - m = __import__(classpath[0:dot], globals(), locals(), [class_name]) - return getattr(m, class_name) - except ImportError: - print("Failed to import: %s" % classpath) - raise - - - @staticmethod - def getTestsFromTestClass(test_class_path, argv=None): - klass = ErtTestRunner.importClass(test_class_path) - klass.argv = argv - loader = TestLoader() - return loader.loadTestsFromTestCase(klass) diff --git a/ThirdParty/Ert/python/python/ecl/test/extended_testcase.py b/ThirdParty/Ert/python/python/ecl/test/extended_testcase.py deleted file mode 100644 index 70bf73f918..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/extended_testcase.py +++ /dev/null @@ -1,181 +0,0 @@ -import numbers -import os -import os.path -import traceback -import sys - -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase - -from .source_enumerator import SourceEnumerator -from ecl.util import installAbortSignals -from ecl.util import Version - -TESTDATA_ROOT = None -SHARE_ROOT = None -SOURCE_ROOT = None -BUILD_ROOT = None -try: - from test_env import * - assert( os.path.isdir( TESTDATA_ROOT )) - assert( os.path.isdir( SOURCE_ROOT )) - assert( os.path.isdir( BUILD_ROOT )) - if not SHARE_ROOT is None: - assert( os.path.isdir( SHARE_ROOT )) -except ImportError: - sys.stderr.write("Warning: could not import file test_env.py - this might lead to test failures.") - - -class _AssertNotRaisesContext(object): - - def __init__(self, test_class): - super(_AssertNotRaisesContext, self).__init__() - self._test_class = test_class - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, tb): - if exc_type is not None: - try: - exc_name = exc_type.__name__ - except AttributeError: - exc_name = str(exc_type) - self._test_class.fail("Exception: %s raised\n%s" % (exc_name, traceback.print_exception(exc_type, exc_value, tb))) - return True - - -""" -This class provides some extra functionality for testing values that are almost equal. -""" -class ExtendedTestCase(TestCase): - def __init__(self , *args , **kwargs): - self.__testdata_root = None - self.__share_root = None - installAbortSignals() - super(ExtendedTestCase , self).__init__(*args , **kwargs) - - - def __str__(self): - return 'ExtendedTestCase( TESTADATA_ROOT=%s, SOURCE_ROOT=%s, SHARE_ROOT=%s, BUILD_ROOT=%s)' % (TESTDATA_ROOT, - SOURCE_ROOT, - SHARE_ROOT, - BUILD_ROOT) - - def assertFloatEqual(self, first, second, msg=None, tolerance=1e-6): - try: - f_first, f_second = float(first), float(second) - diff = abs(f_first - f_second) - scale = max(1, abs(first) + abs(second)) - if msg is None: - msg = "Floats not equal: |%f - %f| > %g" % (f_first, f_second, tolerance) - self.assertTrue(diff < tolerance * scale, msg=msg) - except TypeError: - self.fail("Cannot compare as floats: %s (%s) and %s (%s)" % - (first, type(first), second, type(second))) - - - def assertAlmostEqualList(self, first, second, msg=None, tolerance=1e-6): - if len(first) != len(second): - self.fail("Lists are not of same length!") - - for index in range(len(first)): - self.assertFloatEqual( - first[index], second[index], - msg=msg, tolerance=tolerance - ) - - - def assertImportable(self, module_name): - try: - __import__(module_name) - except ImportError: - tb = traceback.format_exc() - self.fail("Module %s not found!\n\nTrace:\n%s" % (module_name, str(tb))) - except Exception: - tb = traceback.format_exc() - self.fail("Import of module %s caused errors!\n\nTrace:\n%s" % (module_name, str(tb))) - - - def assertFilesAreEqual(self, first, second): - if not self.__filesAreEqual(first, second): - self.fail("Buffer contents of files are not identical!") - - - def assertFilesAreNotEqual(self, first, second): - if self.__filesAreEqual(first, second): - self.fail("Buffer contents of files are identical!") - - def assertFileExists(self, path): - if not os.path.exists(path) or not os.path.isfile(path): - self.fail("The file: %s does not exist!" % path) - - def assertDirectoryExists(self, path): - if not os.path.exists(path) or not os.path.isdir(path): - self.fail("The directory: %s does not exist!" % path) - - def assertFileDoesNotExist(self, path): - if os.path.exists(path) and os.path.isfile(path): - self.fail("The file: %s exists!" % path) - - def assertDirectoryDoesNotExist(self, path): - if os.path.exists(path) and os.path.isdir(path): - self.fail("The directory: %s exists!" % path) - - def __filesAreEqual(self, first, second): - buffer1 = open(first).read() - buffer2 = open(second).read() - - return buffer1 == buffer2 - - def assertEnumIsFullyDefined(self, enum_class, enum_name, source_path, verbose=False): - enum_values = SourceEnumerator.findEnumerators(enum_name, os.path.join( SOURCE_ROOT , source_path)) - - for identifier, value in enum_values: - if verbose: - print("%s = %d" % (identifier, value)) - - self.assertTrue(enum_class.__dict__.has_key(identifier), "Enum does not have identifier: %s" % identifier) - class_value = enum_class.__dict__[identifier] - self.assertEqual(class_value, value, "Enum value for identifier: %s does not match: %s != %s" % (identifier, class_value, value)) - - - @staticmethod - def createSharePath(path): - return os.path.realpath(os.path.join(SHARE_ROOT , path)) - - - @staticmethod - def createTestPath(path): - return os.path.realpath(os.path.join(TESTDATA_ROOT , path)) - - - def assertNotRaises(self, func=None): - - context = _AssertNotRaisesContext(self) - if func is None: - return context - - with context: - func() - - @staticmethod - def slowTestShouldNotRun(): - """ - @param: The slow test flag can be set by environment variable SKIP_SLOW_TESTS = [True|False] - """ - - return os.environ.get("SKIP_SLOW_TESTS", "False") == "True" - - - @staticmethod - def requireVersion(major , minor , micro = "git"): - required_version = Version(major, minor , micro) - current_version = Version.currentVersion() - - if required_version < current_version: - return True - else: - return False diff --git a/ThirdParty/Ert/python/python/ecl/test/import_test_case.py b/ThirdParty/Ert/python/python/ecl/test/import_test_case.py deleted file mode 100644 index 761b029018..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/import_test_case.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import importlib -import os -import sys -import traceback -import unittest -import inspect -import imp - -class ImportTestCase(unittest.TestCase): - - def import_file(self, path): - return imp.load_source( "module", path) - - def import_module(self , module): - mod = importlib.import_module( module ) - return mod - - def import_package(self, package): - module = self.import_module( package ) - path = os.path.dirname( inspect.getfile( module ) ) - - for entry in sorted(os.listdir(path)): - entry_path = os.path.join(path, entry) - if os.path.isdir( entry_path ): - module = os.path.basename( entry ) - sub_module = "%s.%s" % (package , module) - self.import_package( sub_module ) - else: - module, ext = os.path.splitext( entry ) - if module == "__init__": - continue - - if ext == "py": - self.import_module("%s.%s" % (package , module)) - - return True diff --git a/ThirdParty/Ert/python/python/ecl/test/lint_test_case.py b/ThirdParty/Ert/python/python/ecl/test/lint_test_case.py deleted file mode 100644 index ff3bd729d6..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/lint_test_case.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import sys -import fnmatch -import os -import unittest -try: - from pylint import epylint as lint -except ImportError: - sys.stderr.write("Could not import pylint module - lint based testing will be skipped\n") - lint = None - - -class LintTestCase(unittest.TestCase): - """This class is a test case for linting.""" - - LINT_ARGS = ['-d', 'R,C,W'] + \ - ['--extension-pkg-whitelist=numpy'] - - - @staticmethod - def _get_lintable_files(paths, whitelist=()): - """Recursively traverses all folders in paths for *.py files""" - matches = [] - for folder in paths: - for root, _, filenames in os.walk(folder): - for filename in fnmatch.filter(filenames, '*.py'): - if filename not in whitelist: - matches.append(os.path.join(root, filename)) - return matches - - - def assertLinted(self, paths, whitelist=()): # noqa - """Takes a path to a folder or a list of paths to folders and recursively finds - all *.py files within that folder except the ones with filenames in whitelist. - - Will assert lint.lint(fname) == 0 for every *.py file found. - """ - if lint is None: - self.skipTest("pylint not installed") - - if isinstance(paths, str): - paths = [paths] - files = self._get_lintable_files(paths, whitelist=whitelist) - for f in files: - self.assertEqual(0, lint.lint(f, self.LINT_ARGS), 'Linting required for %s' % f) diff --git a/ThirdParty/Ert/python/python/ecl/test/path_context.py b/ThirdParty/Ert/python/python/ecl/test/path_context.py deleted file mode 100644 index 98dda72040..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/path_context.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import shutil - -class PathContext(object): - def __init__(self , path , store = False): - self.path = path - self.cwd = os.getcwd() - self.store = store - self.path_list = [ ] - - if not os.path.exists(path): - work_path = path - - while True: - work_path , base = os.path.split(work_path) - if work_path: - if os.path.isdir(work_path): - break - else: - self.path_list.append( work_path ) - else: - break - - os.makedirs( path ) - else: - if not self.store: - raise OSError("Entry %s already exists" % path) - os.chdir( path ) - - - - def __exit__(self , exc_type , exc_val , exc_tb): - os.chdir( self.cwd ) - if self.store == False: - shutil.rmtree( self.path ) - for path in self.path_list: - try: - os.rmdir( path ) - except OSError: - break - - return False - - - def __enter__(self): - return self diff --git a/ThirdParty/Ert/python/python/ecl/test/source_enumerator.py b/ThirdParty/Ert/python/python/ecl/test/source_enumerator.py deleted file mode 100644 index e0c76300f1..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/source_enumerator.py +++ /dev/null @@ -1,39 +0,0 @@ -import os -import re - -class SourceEnumerator(object): - - @classmethod - def removeComments(cls, code_string): - code_string = re.sub(re.compile("/\*.*?\*/",re.DOTALL ) ,"" ,code_string) # remove all occurance streamed comments (/*COMMENT */) from string - code_string = re.sub(re.compile("//.*?\n" ) ,"" ,code_string) # remove all occurance singleline comments (//COMMENT\n ) from string - return code_string - - - @classmethod - def findEnum(cls, enum_name, full_source_file_path): - with open(full_source_file_path, "r") as f: - text = f.read() - - text = SourceEnumerator.removeComments(text) - - enum_pattern = re.compile("typedef\s+enum\s+\{(.*?)\}\s*(\w+?);", re.DOTALL) - - for enum in enum_pattern.findall(text): - if enum[1] == enum_name: - return enum[0] - - raise ValueError("Enum with name: '%s' not found!" % enum_name) - - - @classmethod - def findEnumerators(cls, enum_name, source_file): - enum_text = SourceEnumerator.findEnum(enum_name, source_file) - - enumerator_pattern = re.compile("(\w+?)\s*?=\s*?(\d+)") - - enumerators = [] - for enumerator in enumerator_pattern.findall(enum_text): - enumerators.append((enumerator[0], int(enumerator[1]))) - - return enumerators diff --git a/ThirdParty/Ert/python/python/ecl/test/temp_area.py b/ThirdParty/Ert/python/python/ecl/test/temp_area.py deleted file mode 100644 index 4679eed017..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/temp_area.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# The file 'temp_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -import os.path -from ecl.util import UtilPrototype -from . import TestArea - -class TempArea(TestArea): - """TempArea class is essentially similar to the TestArea class, with - the only difference that the cwd is *not* changed into the newly - created area. - """ - - _temp_area_alloc = UtilPrototype("void* temp_area_alloc( char* )" , bind = False) - _temp_area_alloc_relative = UtilPrototype("void* temp_area_alloc_relative( char* , char* )" , bind = False) - - def __init__(self, name, prefix = None , store_area=False): - if prefix: - if os.path.exists( prefix ): - c_ptr = self._temp_area_alloc_relative(prefix , name) - else: - raise IOError("The prefix path:%s must exist" % prefix) - else: - c_ptr = self._temp_area_alloc(name) - super(TempArea, self).__init__(name , c_ptr = c_ptr , store_area = store_area) - - - def __str__(self): - return self.getPath() - - - def get_cwd(self): - """ - Since the TempArea class does *not* change the cwd this method - just returns the ordinary os.getcwd(). - """ - return os.getcwd() - - - def getPath(self): - """ - Will return the full path to the temporary working area. - """ - return self._get_cwd( ) - - - -class TempAreaContext(object): - def __init__(self, name, prefix = None , store_area=False): - self.name = name - self.store_area = store_area - self.prefix = prefix - - def __enter__(self): - """ - @rtype: TempArea - """ - self.temp_area = TempArea(self.name, prefix = self.prefix , store_area = self.store_area ) - return self.temp_area - - - def __exit__(self, exc_type, exc_val, exc_tb): - del self.temp_area - return False - - - diff --git a/ThirdParty/Ert/python/python/ecl/test/test_area.py b/ThirdParty/Ert/python/python/ecl/test/test_area.py deleted file mode 100644 index 0d2cb1cf57..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/test_area.py +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os.path - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class TestArea(BaseCClass): - _test_area_alloc = UtilPrototype("void* test_work_area_alloc( char* )" , bind = False) - _test_area_alloc_relative = UtilPrototype("void* test_work_area_alloc_relative( char* , char* )" , bind = False) - _free = UtilPrototype("void test_work_area_free( test_area )") - _install_file = UtilPrototype("void test_work_area_install_file( test_area , char* )") - _copy_directory = UtilPrototype("void test_work_area_copy_directory( test_area , char* )") - _copy_file = UtilPrototype("void test_work_area_copy_file( test_area , char* )") - _copy_directory_content = UtilPrototype("void test_work_area_copy_directory_content( test_area , char* )") - _copy_parent_directory = UtilPrototype("void test_work_area_copy_parent_directory( test_area , char* )") - _copy_parent_content = UtilPrototype("void test_work_area_copy_parent_content( test_area , char* )") - _get_cwd = UtilPrototype("char* test_work_area_get_cwd( test_area )") - _get_original_cwd = UtilPrototype("char* test_work_area_get_original_cwd( test_area )") - _set_store = UtilPrototype("void test_work_area_set_store( test_area , bool)") - _sync = UtilPrototype("void test_work_area_sync( test_area )") - - def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): - - if c_ptr is None: - if prefix: - if os.path.exists( prefix ): - c_ptr = self._test_area_alloc_relative(prefix , test_name) - else: - raise IOError("The prefix path:%s must exist" % prefix) - else: - c_ptr = self._test_area_alloc(test_name) - - super(TestArea, self).__init__(c_ptr) - self.set_store( store_area ) - - - def get_original_cwd(self): - return self._get_original_cwd() - - def get_cwd(self): - return self._get_cwd() - - def orgPath(self , path): - if os.path.isabs( path ): - return path - else: - return os.path.abspath( os.path.join( self.get_original_cwd( ) , path ) ) - - - # All the methods install_file() , copy_directory(), - # copy_parent_directory(), copy_parent_content(), - # copy_directory_content() and copy_file() expect an input - # argument which is relative to the original CWD - or absolute. - - def install_file( self, filename): - if os.path.isfile(self.orgPath(filename)): - self._install_file(filename) - else: - raise IOError("No such file:%s" % filename) - - - def copy_directory( self, directory): - if os.path.isdir( self.orgPath(directory) ): - self._copy_directory(directory) - else: - raise IOError("No such directory: %s" % directory) - - def copy_parent_directory( self , path): - if os.path.exists( self.orgPath(path) ): - self._copy_parent_directory( path) - else: - raise IOError("No such file or directory: %s" % path) - - - def copy_parent_content( self , path): - if os.path.exists( self.orgPath(path) ): - self._copy_parent_content(path) - else: - raise IOError("No such file or directory: %s" % path) - - def copy_directory_content( self, directory): - if os.path.isdir( self.orgPath(directory) ): - self._copy_directory_content(directory) - else: - raise IOError("No such directory: %s" % directory ) - - - def copy_file( self, filename): - if os.path.isfile( self.orgPath(filename) ): - self._copy_file(filename) - else: - raise IOError("No such file:%s" % filename) - - - def free(self): - self._free() - - - def set_store(self, store): - self._set_store(store) - - - def getFullPath(self , path): - if not os.path.exists( path ): - raise IOError("Path not found:%s" % path) - - if os.path.isabs( path ): - raise IOError("Path:%s is already absolute" % path) - - return os.path.join( self.get_cwd() , path ) - - - def sync(self): - return self._sync( ) - - - -class TestAreaContext(object): - def __init__(self, test_name, prefix = None , store_area=False): - self.test_name = test_name - self.store_area = store_area - self.prefix = prefix - - def __enter__(self): - """ - @rtype: TestArea - """ - self.test_area = TestArea(self.test_name, prefix = self.prefix , store_area = self.store_area ) - return self.test_area - - - def __exit__(self, exc_type, exc_val, exc_tb): - del self.test_area - return False diff --git a/ThirdParty/Ert/python/python/ecl/test/test_run.py b/ThirdParty/Ert/python/python/ecl/test/test_run.py deleted file mode 100644 index 496353ba4d..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/test_run.py +++ /dev/null @@ -1,158 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_run.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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, teither version 3 of the License, or -# (at your option) any later version. -# -# ERT 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. -import random -import os.path -import subprocess -import argparse -from .test_area import TestAreaContext - - -def path_exists( path ): - if os.path.exists( path ): - return (True , "Path:%s exists" % path) - else: - return (False , "ERROR: Path:%s does not exist" % path) - - -class TestRun(object): - default_ert_cmd = "ert" - default_ert_version = "stable" - default_path_prefix = None - - def __init__(self , config_file , args = [] , name = None): - if os.path.exists( config_file ) and os.path.isfile( config_file ): - self.parseArgs(args) - self.__ert_cmd = TestRun.default_ert_cmd - self.path_prefix = TestRun.default_path_prefix - self.config_file = config_file - - self.check_list = [] - self.workflows = [] - if name: - self.name = name - else: - self.name = config_file.replace("/" , ".") - while True: - if self.name[0] == ".": - self.name = self.name[1:] - else: - break - self.name += "/%08d" % random.randint(0,100000000) - else: - raise IOError("No such config file: %s" % config_file) - - - def parseArgs(self , args): - parser = argparse.ArgumentParser() - parser.add_argument("-v" , "--version" , default = self.default_ert_version) - parser.add_argument("args" , nargs="*") - result = parser.parse_args(args) - self.ert_version = result.version - self.args = result.args - - - def get_config_file(self): - return self.__config_file - - def set_config_file(self , input_config_file): - self.__config_file = os.path.basename( input_config_file ) - self.abs_config_file = os.path.abspath( input_config_file ) - - config_file = property( get_config_file , set_config_file ) - - #----------------------------------------------------------------- - - def set_path_prefix(self , path_prefix): - self.__path_prefix = path_prefix - - def get_path_prefix(self): - return self.__path_prefix - - path_prefix = property( get_path_prefix , set_path_prefix ) - - #----------------------------------------------------------------- - - def get_ert_cmd(self): - return self.__ert_cmd - - def set_ert_cmd(self , cmd): - self.__ert_cmd = cmd - - ert_cmd = property( get_ert_cmd , set_ert_cmd) - - #----------------------------------------------------------------- - - def get_workflows(self): - return self.workflows - - - def add_workflow(self , workflow): - self.workflows.append( workflow ) - - #----------------------------------------------------------------- - - def get_args(self): - return self.args - - #----------------------------------------------------------------- - - def add_check( self , check_func , arg): - if callable(check_func): - self.check_list.append( (check_func , arg) ) - else: - raise Exception("The checker:%s is not callable" % check_func ) - - #----------------------------------------------------------------- - - def __run(self , work_area ): - argList = [ self.ert_cmd , "-v" , self.ert_version ] - for arg in self.args: - argList.append( arg ) - - argList.append( self.config_file ) - for wf in self.workflows: - argList.append( wf ) - - status = subprocess.call( argList ) - if status == 0: - return (True , "ert has run successfully") - else: - return (False , "ERROR:: ert exited with status code:%s" % status) - - - def run(self): - if len(self.workflows): - with TestAreaContext(self.name , prefix = self.path_prefix , store_area = False) as work_area: - test_cwd = work_area.get_cwd() - work_area.copy_parent_content( self.abs_config_file ) - status = self.__run( work_area ) - global_status = status[0] - - status_list = [ status ] - if status[0]: - for (check_func , arg) in self.check_list: - status = check_func( arg ) - status_list.append( status ) - if not status[0]: - global_status = False - - if not global_status: - work_area.set_store( True ) - - return (global_status , test_cwd , status_list) - else: - raise Exception("Must have added workflows before invoking start()") - diff --git a/ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt deleted file mode 100644 index 2a950d6958..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - bool_vector.py - buffer.py - ctime.py - double_vector.py - hash.py - int_vector.py - install_abort_signals.py - log.py - lookup_table.py - matrix.py - profiler.py - rng.py - stat.py - stringlist.py - #substitution_list.py - thread_pool.py - cthread_pool.py - time_vector.py - ui_return.py - util_func.py - vector_template.py - permutation_vector.py - version.py - arg_pack.py - path_format.py - cwd_context.py -) - -add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/ecl/util "${PYTHON_SOURCES}" True) - -add_subdirectory(enums) diff --git a/ThirdParty/Ert/python/python/ecl/util/__init__.py b/ThirdParty/Ert/python/python/ecl/util/__init__.py deleted file mode 100644 index 6519f170c8..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/__init__.py +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Package with utility classes, used by other ERT classes. - -The libutil library implements many utility functions and classes of -things like hash table and vector; these classes are extensively used -by the other ert libraries. The present wrapping here is to facilitate -use and interaction with various ert classes, in a pure python context -you are probably better served by using a plain python solution; -either based on built in python objects or well established third -party packages. - -The modules included in the util package are: - - tvector.py: This module implements the classes IntVector, - DoubleVector and BoolVector. This is a quite normal - implementation of a typed growable vector; but with a special - twist regarding default values. - - util_func.py: This module wraps a couple of stateless (i.e. there is - no class involved) functions from the util.c file. - -""" - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -import ecl -from cwrap import Prototype - - -class UtilPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True, allow_attribute_error=False): - super(UtilPrototype, self).__init__(UtilPrototype.lib, prototype, bind=bind, allow_attribute_error=allow_attribute_error) - - - -from .version import Version, EclVersion - -from .enums import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum - -from .ctime import CTime - -from .permutation_vector import PermutationVector -from .vector_template import VectorTemplate -from .double_vector import DoubleVector -from .int_vector import IntVector -from .bool_vector import BoolVector -from .time_vector import TimeVector -from .stringlist import StringList -from .rng import RandomNumberGenerator -from .matrix import Matrix -from .stat import quantile, quantile_sorted, polyfit -from .log import Log -from .lookup_table import LookupTable -from .buffer import Buffer -from .hash import Hash, StringHash, DoubleHash, IntegerHash -from .ui_return import UIReturn -from .thread_pool import ThreadPool -from .cthread_pool import CThreadPool, startCThreadPool -from .install_abort_signals import installAbortSignals, updateAbortSignals -from .profiler import Profiler -from .arg_pack import ArgPack -from .path_format import PathFormat -from .cwd_context import CWDContext - - - -### -### monkey_the_camel is a function temporarily added to libecl while we are in -### the process of changing camelCase function names to snake_case function -### names. -### -### See https://github.com/Statoil/libecl/issues/142 for a discussion and for -### usage. -### - -import os -import warnings - -__cc = os.environ.get('ECLWARNING', None) # __cc in (None, 'user', 'dev', 'hard') - -def __silencio(msg): - pass - -def __user_warning(msg): - print('User warning: ' + msg) - -def __dev_warning(msg): - warnings.warn(msg, DeprecationWarning) - -def __hard_warning(msg): - raise UserWarning('CamelCase exception: ' + msg) - - -__ecl_camel_case_warning = __silencio -if __cc == 'user': - __ecl_camel_case_warning = __user_warning -elif __cc == 'dev': - __ecl_camel_case_warning = __dev_warning -elif __cc == 'hard': - __ecl_camel_case_warning = __hard_warning - - -def monkey_the_camel(class_, camel, method_, method_type=None): - """Creates a method "class_.camel" in class_ which prints a warning and forwards - to method_. method_type should be one of (None, classmethod, staticmethod), - and generates new methods accordingly. - """ - def shift(*args): - return args if (method_type != classmethod) else args[1:] - def warned_method(*args, **kwargs): - __ecl_camel_case_warning('Warning, %s is deprecated, use %s' % (camel, str(method_))) - return method_(*shift(*args), **kwargs) - if method_type == staticmethod: - warned_method = staticmethod(warned_method) - elif method_type == classmethod: - warned_method = classmethod(warned_method) - setattr(class_, camel, warned_method) diff --git a/ThirdParty/Ert/python/python/ecl/util/arg_pack.py b/ThirdParty/Ert/python/python/ecl/util/arg_pack.py deleted file mode 100644 index e20bd3fe99..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/arg_pack.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'arg_pack.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class ArgPack(BaseCClass): - TYPE_NAME = "arg_pack" - - _alloc = UtilPrototype("void* arg_pack_alloc()" , bind = False) - _append_int = UtilPrototype("void arg_pack_append_int(arg_pack, int)") - _append_double = UtilPrototype("void arg_pack_append_double(arg_pack, double)") - _append_ptr = UtilPrototype("void arg_pack_append_ptr(arg_pack, void*)") - - _size = UtilPrototype("int arg_pack_size(arg_pack)") - _free = UtilPrototype("void arg_pack_free(arg_pack)") - - def __init__(self, *args): - c_ptr = self._alloc() - super(ArgPack, self).__init__(c_ptr) - self.child_list = [] - for arg in args: - self.append(arg) - - - def append(self, data): - if isinstance(data, int): - self._append_int(data) - elif isinstance(data, float): - self._append_double(data) - elif isinstance(data, BaseCClass): - self._append_ptr(BaseCClass.from_param(data)) - self.child_list.append(data) - else: - raise TypeError("Can only add int/double/basecclass") - - - def __len__(self): - return self._size() - - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/util/bool_vector.py b/ThirdParty/Ert/python/python/ecl/util/bool_vector.py deleted file mode 100644 index 9f920628a9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/bool_vector.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.util import VectorTemplate, UtilPrototype - - -class BoolVector(VectorTemplate): - default_format = "%8d" - - _alloc = UtilPrototype("void* bool_vector_alloc( int , bool )" , bind = False) - _create_active_mask = UtilPrototype("bool_vector_obj string_util_alloc_active_mask( char* )" , bind = False) - _active_list = UtilPrototype("int_vector_obj bool_vector_alloc_active_list(bool_vector)", bind = False) - _alloc_copy = UtilPrototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )") - _update_active_mask = UtilPrototype("bool string_util_update_active_mask(char*, bool_vector)" , bind = False) - - _strided_copy = UtilPrototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)") - _free = UtilPrototype("void bool_vector_free( bool_vector )") - _iget = UtilPrototype("bool bool_vector_iget( bool_vector , int )") - _safe_iget = UtilPrototype("bool bool_vector_safe_iget( bool_vector , int )") - _iset = UtilPrototype("void bool_vector_iset( bool_vector , int , bool)") - _size = UtilPrototype("int bool_vector_size( bool_vector )") - _append = UtilPrototype("void bool_vector_append( bool_vector , bool )") - _idel_block = UtilPrototype("void bool_vector_idel_block( bool_vector , bool , bool )") - _idel = UtilPrototype("void bool_vector_idel( bool_vector , int )") - _pop = UtilPrototype("bool bool_vector_pop( bool_vector )") - _lshift = UtilPrototype("void bool_vector_lshift( bool_vector , int )") - _rshift = UtilPrototype("void bool_vector_rshift( bool_vector , int )") - _insert = UtilPrototype("void bool_vector_insert( bool_vector , int , bool)") - _fprintf = UtilPrototype("void bool_vector_fprintf( bool_vector , FILE , char* , char*)") - _sort = UtilPrototype("void bool_vector_sort( bool_vector )") - _rsort = UtilPrototype("void bool_vector_rsort( bool_vector )") - _reset = UtilPrototype("void bool_vector_reset( bool_vector )") - _set_read_only = UtilPrototype("void bool_vector_set_read_only( bool_vector , bool )") - _get_read_only = UtilPrototype("bool bool_vector_get_read_only( bool_vector )") - _get_max = UtilPrototype("bool bool_vector_get_max( bool_vector )") - _get_min = UtilPrototype("bool bool_vector_get_min( bool_vector )") - _get_max_index = UtilPrototype("int bool_vector_get_max_index( bool_vector , bool)") - _get_min_index = UtilPrototype("int bool_vector_get_min_index( bool_vector , bool)") - _shift = UtilPrototype("void bool_vector_shift( bool_vector , bool )") - _scale = UtilPrototype("void bool_vector_scale( bool_vector , bool )") - _div = UtilPrototype("void bool_vector_div( bool_vector , bool )") - _inplace_add = UtilPrototype("void bool_vector_inplace_add( bool_vector , bool_vector )") - _inplace_mul = UtilPrototype("void bool_vector_inplace_mul( bool_vector , bool_vector )") - _assign = UtilPrototype("void bool_vector_set_all( bool_vector , bool)") - _memcpy = UtilPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") - _set_default = UtilPrototype("void bool_vector_set_default( bool_vector , bool)") - _get_default = UtilPrototype("bool bool_vector_get_default( bool_vector )") - _element_size = UtilPrototype("int bool_vector_element_size( bool_vector )") - - _permute = UtilPrototype("void bool_vector_permute(bool_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj bool_vector_alloc_rsort_perm(bool_vector)") - - _contains = UtilPrototype("bool bool_vector_contains(bool_vector, bool)") - _select_unique = UtilPrototype("void bool_vector_select_unique(bool_vector)") - _element_sum = UtilPrototype("bool bool_vector_sum(bool_vector)") - _get_data_ptr = UtilPrototype("bool* bool_vector_get_ptr(bool_vector)") - _count_equal = UtilPrototype("int bool_vector_count_equal(bool_vector, bool)") - - def __init__(self, default_value=False, initial_size=0): - super(BoolVector, self).__init__(default_value, initial_size) - - def count(self, value=True): - """ @rtype: int """ - return self._count_equal(self, value) - - @classmethod - def createActiveMask(cls, range_string): - """ - Will create a BoolVector instance with the values from @range_string. - - The range_string input should be of the type "1,3-5,9,17", - i.e. integer values separated by commas, and dashes to - represent ranges. If the input string contains ANY invalid - characters the returned active list will be empty: - - "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} - "1,4-7,10X" => {} - - The empty list will evaluate to false - @rtype: BoolVector - """ - return cls._create_active_mask(range_string) - - def updateActiveMask(self, range_string): - """ - Updates a bool vector based on a range string. - @type range_string: str - @type bool_vector: BoolVector - @rtype: bool - """ - return self._update_active_mask(range_string , self) - - @classmethod - def createFromList(cls, size, source_list): - """ - Allocates a bool vector from a Python list of indexes - @rtype: BoolVector - """ - bool_vector = BoolVector(False, size) - - for index in source_list: - index = int(index) - bool_vector[index] = True - - return bool_vector - - def createActiveList(self): - """ @rtype: ecl.util.IntVector """ - return self._active_list(self) - - def _tostr(self, arr = None): - if arr is None: - arr = self - return "".join(['1' if x else '0' for x in arr]) - - def __repr__(self): - """Will return BoolVector(size = 4, content = "0010") at 0x1729 and - if size > 10, will return content = "0001...100", i.e., |content|<=10. - """ - cnt = '' - ls = len(self) - if ls <= 20: - cnt = self._tostr() - else: - a,b = self[:9], self[-8:] - cnt = self._tostr(a) - cnt += "..." - cnt += self._tostr(b) - return 'BoolVector(size = %d, content = "%s") %s' % (ls, cnt, self._ad_str()) diff --git a/ThirdParty/Ert/python/python/ecl/util/buffer.py b/ThirdParty/Ert/python/python/ecl/util/buffer.py deleted file mode 100644 index 44a96cfd62..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/buffer.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'buffer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class Buffer(BaseCClass): - _alloc = UtilPrototype("void* buffer_alloc(int)" , bind = False) - _free = UtilPrototype("void buffer_free(buffer)") - - def __init__(self, size): - super(Buffer, self).__init__(self._alloc(size)) - - def free(self): - self._free() diff --git a/ThirdParty/Ert/python/python/ecl/util/cthread_pool.py b/ThirdParty/Ert/python/python/ecl/util/cthread_pool.py deleted file mode 100644 index 5c5824b2b7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/cthread_pool.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'cthread_pool.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import ctypes - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class CThreadPool(BaseCClass): - TYPE_NAME = "thread_pool" - - _alloc = UtilPrototype("void* thread_pool_alloc(int, bool)", bind = False) - _free = UtilPrototype("void thread_pool_free(thread_pool)") - _add_job = UtilPrototype("void thread_pool_add_job(thread_pool, void*, void*)") - _join = UtilPrototype("void thread_pool_join(thread_pool)") - - def __init__(self, pool_size, start=True): - c_ptr = self._alloc(pool_size, start) - super(CThreadPool, self).__init__(c_ptr) - self.arg_list = [] - - def addTaskFunction(self, name, lib, c_function_name): - function = CThreadPool.lookupCFunction(lib, c_function_name) - - def wrappedFunction(arg): - return self.addTask(function, arg) - - setattr(self, name, wrappedFunction) - - def addTask(self, cfunc, arg): - """ - The function should come from CThreadPool.lookupCFunction(). - """ - if isinstance(arg, BaseCClass): - arg_ptr = BaseCClass.from_param(arg) - else: - arg_ptr = arg - - self.arg_list.append(arg) - self._add_job(cfunc, arg_ptr) - - def join(self): - self._join() - - def free(self): - self.join() - self._free() - - @staticmethod - def lookupCFunction(lib, name): - if isinstance(lib, ctypes.CDLL): - func = getattr(lib, name) - return func - else: - raise TypeError("The lib argument must be of type ctypes.CDLL") - - -class CThreadPoolContextManager(object): - def __init__(self, tp): - self.__tp = tp - - def __enter__(self): - return self.__tp - - def __exit__(self, exc_type, exc_val, exc_tb): - self.__tp.join() - return False - - -def startCThreadPool(size): - return CThreadPoolContextManager(CThreadPool(size, start=True)) diff --git a/ThirdParty/Ert/python/python/ecl/util/ctime.py b/ThirdParty/Ert/python/python/ecl/util/ctime.py deleted file mode 100644 index 04d7d42e2a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/ctime.py +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ctime.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -import ctypes -import datetime -import time - -from cwrap import BaseCValue -from ecl.util import UtilPrototype - - -class CTime(BaseCValue): - TYPE_NAME = "time_t" - DATA_TYPE = ctypes.c_long - _timezone = UtilPrototype("char* util_get_timezone()" , bind = False) - _timegm = UtilPrototype("long util_make_datetime_utc(int, int, int, int, int, int)" , bind = False) - - def __init__(self, value): - if isinstance(value, int): - value = value - elif isinstance(value, CTime): - value = value.value() - elif isinstance(value, datetime.datetime): - value = CTime._timegm(value.second, value.minute, value.hour, value.day, value.month, value.year) - elif isinstance(value, datetime.date): - value = CTime._timegm(0, 0, 0, value.day, value.month, value.year) - else: - raise NotImplementedError("Can not convert class %s to CTime" % value.__class__) - - super(CTime, self).__init__(value) - - def ctime(self): - """ @rtype: int """ - return self.value() - - def time(self): - """Return this time_t as a time.gmtime() object""" - return time.gmtime(self.value()) - - def date(self): - """Return this time_t as a datetime.date([year, month, day])""" - return datetime.date(*self.time()[0:3]) - - def datetime(self): - return datetime.datetime(*self.time()[0:6]) - - def __str__(self): - return self.datetime().strftime("%Y-%m-%d %H:%M:%S%z") - - def __ge__(self, other): - return self > other or self == other - - def __le__(self, other): - return self < other or self == other - - def __gt__(self, other): - if isinstance(other, CTime): - return self.value() > other.value() - elif isinstance(other, (int, datetime.datetime, datetime.date)): - return self > CTime(other) - else: - raise TypeError("CTime does not support type: %s" % other.__class__) - - def __lt__(self, other): - if isinstance(other, CTime): - return self.value() < other.value() - elif isinstance(other, (int, datetime.datetime, datetime.date)): - return self < CTime(other) - else: - raise TypeError("CTime does not support type: %s" % other.__class__) - - def __ne__(self, other): - return not self == other - - def __eq__(self, other): - if isinstance(other, CTime): - return self.value() == other.value() - elif isinstance(other, (int, datetime.datetime, datetime.date)): - return self == CTime(other) - elif isinstance(other, type(None)): - return False - else: - raise TypeError("CTime does not support type: %s" % other.__class__) - - def __imul__(self, other): - value = int(self.value() * other) - self.setValue(value) - return self - - def __hash__(self): - return hash(self.value()) - - def __iadd__(self, other): - if isinstance(other, CTime): - self.setValue(self.value() + other.value()) - return self - else: - self.setValue(self.value() + CTime(other).value()) - return self - - def __add__(self, other): - copy = CTime(self) - copy += other - return copy - - def __radd__(self, other): - return self + other - - def __mul__(self, other): - copy = CTime(self) - copy *= other - return copy - - def __rmul__(self, other): - return self * other - - def timetuple(self): - # this function is a requirement for comparing against datetime objects where the CTime is on the right side - pass - - def __repr__(self): - return "time_t value: %d [%s]" % (self.value(), str(self)) - - @property - def stripped(self): - return time.strptime(self, "%Y-%m-%d %H:%M:S%") - - @classmethod - def timezone(cls): - """ - Returns the current timezone "in" C - @rtype: str - """ - return CTime._timezone() diff --git a/ThirdParty/Ert/python/python/ecl/util/cwd_context.py b/ThirdParty/Ert/python/python/ecl/util/cwd_context.py deleted file mode 100644 index c51eb81399..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/cwd_context.py +++ /dev/null @@ -1,16 +0,0 @@ -import os - -class CWDContext(object): - def __init__(self , path): - self.cwd = os.getcwd() - if os.path.isdir( path ): - os.chdir( path ) - else: - raise IOError("Path:%s does not exist" % path) - - def __exit__(self , exc_type , exc_val , exc_tb): - os.chdir( self.cwd ) - return False - - def __enter__(self): - return self diff --git a/ThirdParty/Ert/python/python/ecl/util/double_vector.py b/ThirdParty/Ert/python/python/ecl/util/double_vector.py deleted file mode 100644 index 28a39cfc20..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/double_vector.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'double_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.util import VectorTemplate, UtilPrototype - - -class DoubleVector(VectorTemplate): - default_format = "%8.4f" - - _alloc = UtilPrototype("void* double_vector_alloc( int , double )" , bind = False) - _alloc_copy = UtilPrototype("double_vector_obj double_vector_alloc_copy( double_vector )") - _strided_copy = UtilPrototype("double_vector_obj double_vector_alloc_strided_copy( double_vector , int , int , int)") - _free = UtilPrototype("void double_vector_free( double_vector )") - _iget = UtilPrototype("double double_vector_iget( double_vector , int )") - _safe_iget = UtilPrototype("double double_vector_safe_iget(double_vector , int )") - _iset = UtilPrototype("double double_vector_iset( double_vector , int , double)") - _size = UtilPrototype("int double_vector_size( double_vector )") - _append = UtilPrototype("void double_vector_append( double_vector , double )") - _idel_block = UtilPrototype("void double_vector_idel_block( double_vector , int , int )") - _pop = UtilPrototype("double double_vector_pop( double_vector )") - _idel = UtilPrototype("void double_vector_idel( double_vector , int )") - _lshift = UtilPrototype("void double_vector_lshift( double_vector , int )") - _rshift = UtilPrototype("void double_vector_rshift( double_vector , int )") - _insert = UtilPrototype("void double_vector_insert( double_vector , int , double)") - _fprintf = UtilPrototype("void double_vector_fprintf( double_vector , FILE , char* , char*)") - _sort = UtilPrototype("void double_vector_sort( double_vector )") - _rsort = UtilPrototype("void double_vector_rsort( double_vector )") - _reset = UtilPrototype("void double_vector_reset( double_vector )") - _get_read_only = UtilPrototype("bool double_vector_get_read_only( double_vector )") - _set_read_only = UtilPrototype("void double_vector_set_read_only( double_vector , bool )") - _get_max = UtilPrototype("double double_vector_get_max( double_vector )") - _get_min = UtilPrototype("double double_vector_get_min( double_vector )") - _get_max_index = UtilPrototype("int double_vector_get_max_index( double_vector , bool)") - _get_min_index = UtilPrototype("int double_vector_get_min_index( double_vector , bool)") - _shift = UtilPrototype("void double_vector_shift( double_vector , double )") - _scale = UtilPrototype("void double_vector_scale( double_vector , double )") - _div = UtilPrototype("void double_vector_div( double_vector , double )") - _inplace_add = UtilPrototype("void double_vector_inplace_add( double_vector , double_vector )") - _inplace_mul = UtilPrototype("void double_vector_inplace_mul( double_vector , double_vector )") - _assign = UtilPrototype("void double_vector_set_all( double_vector , double)") - _memcpy = UtilPrototype("void double_vector_memcpy(double_vector , double_vector )") - _set_default = UtilPrototype("void double_vector_set_default( double_vector , double)") - _get_default = UtilPrototype("double double_vector_get_default( double_vector )") - _element_size = UtilPrototype("int double_vector_element_size( double_vector )") - - _permute = UtilPrototype("void double_vector_permute(double_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj double_vector_alloc_sort_perm(double_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)") - _contains = UtilPrototype("bool double_vector_contains(double_vector, double)") - _select_unique = UtilPrototype("void double_vector_select_unique(double_vector)") - _element_sum = UtilPrototype("double double_vector_sum(double_vector)") - _get_data_ptr = UtilPrototype("double* double_vector_get_ptr(double_vector)") - _count_equal = UtilPrototype("int double_vector_count_equal(double_vector, double)") - _init_range = UtilPrototype("void double_vector_init_range(double_vector, double , double , double)") - - def __init__(self, default_value=0, initial_size=0): - super(DoubleVector, self).__init__(default_value, initial_size) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt deleted file mode 100644 index fbf4917449..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - rng_alg_type_enum.py - rng_init_mode_enum.py - ui_return_status_enum.py - llsq_result_enum.py - message_level_enum.py -) - -add_python_package("python.ecl.util.enums" ${PYTHON_INSTALL_PREFIX}/ecl/util/enums "${PYTHON_SOURCES}" True) - diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py b/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py deleted file mode 100644 index 85882d14bd..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .rng_init_mode_enum import RngInitModeEnum -from .rng_alg_type_enum import RngAlgTypeEnum -from .ui_return_status_enum import UIReturnStatusEnum -from .llsq_result_enum import LLSQResultEnum -from .message_level_enum import MessageLevelEnum diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py deleted file mode 100644 index 3a0c70c2f1..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py +++ /dev/null @@ -1,13 +0,0 @@ -from cwrap import BaseCEnum - - -class LLSQResultEnum(BaseCEnum): - TYPE_NAME = "llsq_result_enum" - LLSQ_SUCCESS = None - LLSQ_INVALID_DIM = None - LLSQ_UNDETERMINED = None - - -LLSQResultEnum.addEnum("LLSQ_SUCCESS" , 0) -LLSQResultEnum.addEnum("LLSQ_INVALID_DIM" , 1) -LLSQResultEnum.addEnum("LLSQ_UNDETERMINED" , 2) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py deleted file mode 100644 index efb2a61006..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py +++ /dev/null @@ -1,18 +0,0 @@ -from cwrap import BaseCEnum - - -class MessageLevelEnum(BaseCEnum): - TYPE_NAME = "message_level_enum" - - LOG_CRITICAL = None - LOG_ERROR = None - LOG_WARNING = None - LOG_INFO = None - LOG_DEBUG = None - - -MessageLevelEnum.addEnum("LOG_CRITICAL", 0) -MessageLevelEnum.addEnum("LOG_ERROR", 1) -MessageLevelEnum.addEnum("LOG_WARNING", 2) -MessageLevelEnum.addEnum("LOG_INFO", 3) -MessageLevelEnum.addEnum("LOG_DEBUG", 4) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py deleted file mode 100644 index a93b47194e..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py +++ /dev/null @@ -1,8 +0,0 @@ -from cwrap import BaseCEnum - -class RngAlgTypeEnum(BaseCEnum): - TYPE_NAME = "rng_alg_type_enum" - MZRAN = None - - -RngAlgTypeEnum.addEnum("MZRAN", 1) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py deleted file mode 100644 index 049ec0dd6a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py +++ /dev/null @@ -1,14 +0,0 @@ -from cwrap import BaseCEnum - -class RngInitModeEnum(BaseCEnum): - TYPE_NAME = "rng_init_mode_enum" - INIT_DEFAULT = None - INIT_CLOCK = None - INIT_DEV_RANDOM = None - INIT_DEV_URANDOM = None - - -RngInitModeEnum.addEnum("INIT_DEFAULT", 0) -RngInitModeEnum.addEnum("INIT_CLOCK", 1) -RngInitModeEnum.addEnum("INIT_DEV_RANDOM", 2) -RngInitModeEnum.addEnum("INIT_DEV_URANDOM", 3) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py deleted file mode 100644 index 5c810ec127..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py +++ /dev/null @@ -1,11 +0,0 @@ -from cwrap import BaseCEnum - - -class UIReturnStatusEnum(BaseCEnum): - TYPE_NAME = "ui_return_status" - UI_RETURN_OK = None - UI_RETURN_FAIL = None - - -UIReturnStatusEnum.addEnum("UI_RETURN_OK", 1) -UIReturnStatusEnum.addEnum("UI_RETURN_FAIL", 2) diff --git a/ThirdParty/Ert/python/python/ecl/util/hash.py b/ThirdParty/Ert/python/python/ecl/util/hash.py deleted file mode 100644 index bd2a18289d..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/hash.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'hash.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from ctypes import c_void_p - -from cwrap import BaseCClass -from ecl.util import StringList, UtilPrototype - - -class Hash(BaseCClass): - _alloc = UtilPrototype("void* hash_alloc()" , bind = False) - _free = UtilPrototype("void hash_free(hash)") - _size = UtilPrototype("int hash_get_size(hash)") - _keys = UtilPrototype("stringlist_obj hash_alloc_stringlist(hash)") - _has_key = UtilPrototype("bool hash_has_key(hash, char*)") - _get = UtilPrototype("void* hash_get(hash, char*)") - _insert_ref = UtilPrototype("void hash_insert_ref(hash, char*, void*)") - - """ - Base hash class that supports string:void* values - """ - - def __init__(self): - c_ptr = self._alloc() - super(Hash, self).__init__(c_ptr) - - def __len__(self): - return self._size() - - def __getitem__(self, key): - if self._has_key(key): - return self._get(key) - else: - raise KeyError("Hash does not have key: %s" % key) - - def __setitem__(self, key, value): - if isinstance(value, c_void_p): - self._insert_ref(key, value) - else: - raise ValueError("Hash does not support type: %s" % value.__class__) - - def __contains__(self, key): - """ @rtype: bool """ - return self._has_key(key) - - def __iter__(self): - for key in self.keys(): - yield key - - def keys(self): - """ @rtype: StringList """ - return self._keys() - - def free(self): - self._free() - - def __str__(self): - return str(["%s: %s" % (key, self[key]) for key in self.keys()]) - - -class StringHash(Hash): - _get_string = UtilPrototype("char* hash_get_string(hash, char*)") - _insert_string = UtilPrototype("void hash_insert_string(hash, char*, char*)") - - def __init__(self): - super(StringHash, self).__init__() - - def __setitem__(self, key, value): - if isinstance(value, str): - self._insert_string(key, value) - else: - raise ValueError("StringHash does not support type: %s" % value.__class__) - - def __getitem__(self, key): - if key in self: - return self._get_string(key) - else: - raise KeyError("Hash does not have key: %s" % key) - - -class IntegerHash(Hash): - _get_int = UtilPrototype("int hash_get_int(hash, char*)") - _insert_int = UtilPrototype("void hash_insert_int(hash, char*, int)") - - def __init__(self): - super(IntegerHash, self).__init__() - - def __setitem__(self, key, value): - if isinstance(value, int): - self._insert_int(key, value) - else: - raise ValueError("IntegerHash does not support type: %s" % value.__class__) - - def __getitem__(self, key): - if key in self: - return self._get_int(key) - else: - raise KeyError("Hash does not have key: %s" % key) - - -class DoubleHash(Hash): - _get_double = UtilPrototype("double hash_get_double(hash, char*)") - _insert_double = UtilPrototype("void hash_insert_double(hash, char*, double)") - - def __init__(self): - super(DoubleHash, self).__init__() - - def __setitem__(self, key, value): - if isinstance(value, int): - value = float(value) - - if isinstance(value, float): - self._insert_double(key, value) - else: - raise ValueError("DoubleHash does not support type: %s" % value.__class__) - - def __getitem__(self, key): - if key in self: - return self._get_double( key) - else: - raise KeyError("Hash does not have key: %s" % key) diff --git a/ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py b/ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py deleted file mode 100644 index 59cddabe75..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py +++ /dev/null @@ -1,16 +0,0 @@ -from ecl.util import UtilPrototype - - -def installAbortSignals(): - install_signals() - - -def updateAbortSignals(): - """ - Will install the util_abort_signal for all UNMODIFIED signals. - """ - update_signals() - - -install_signals = UtilPrototype("void util_install_signals()") -update_signals = UtilPrototype("void util_update_signals()") diff --git a/ThirdParty/Ert/python/python/ecl/util/int_vector.py b/ThirdParty/Ert/python/python/ecl/util/int_vector.py deleted file mode 100644 index 277a76f9eb..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/int_vector.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'int_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.util import VectorTemplate, UtilPrototype - - -class IntVector(VectorTemplate): - default_format = "%d" - - _alloc = UtilPrototype("void* int_vector_alloc( int , int )" , bind = False) - _create_active_list = UtilPrototype("int_vector_obj string_util_alloc_active_list( char*)" , bind = False) - _create_value_list = UtilPrototype("int_vector_obj string_util_alloc_value_list( char*)" , bind = False) - _alloc_copy = UtilPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") - _strided_copy = UtilPrototype("int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)") - _free = UtilPrototype("void int_vector_free( int_vector )") - _iget = UtilPrototype("int int_vector_iget( int_vector , int )") - _safe_iget = UtilPrototype("int int_vector_safe_iget( int_vector , int )") - _iset = UtilPrototype("int int_vector_iset( int_vector , int , int)") - _size = UtilPrototype("int int_vector_size( int_vector )") - _append = UtilPrototype("void int_vector_append( int_vector , int )") - _idel_block = UtilPrototype("void int_vector_idel_block( int_vector , int , int )") - _pop = UtilPrototype("int int_vector_pop( int_vector )") - _idel = UtilPrototype("void int_vector_idel( int_vector , int )") - _insert = UtilPrototype("void int_vector_insert( int_vector , int , int)") - _lshift = UtilPrototype("void int_vector_lshift( int_vector , int )") - _rshift = UtilPrototype("void int_vector_rshift( int_vector , int )") - _fprintf = UtilPrototype("void int_vector_fprintf( int_vector , FILE , char* , char*)") - _sort = UtilPrototype("void int_vector_sort( int_vector )") - _rsort = UtilPrototype("void int_vector_rsort( int_vector )") - _reset = UtilPrototype("void int_vector_reset( int_vector )") - _set_read_only = UtilPrototype("void int_vector_set_read_only( int_vector , bool )") - _get_read_only = UtilPrototype("bool int_vector_get_read_only( int_vector )") - _get_max = UtilPrototype("int int_vector_get_max( int_vector )") - _get_min = UtilPrototype("int int_vector_get_min( int_vector )") - _get_max_index = UtilPrototype("int int_vector_get_max_index( int_vector , bool)") - _get_min_index = UtilPrototype("int int_vector_get_min_index( int_vector , bool)") - _shift = UtilPrototype("void int_vector_shift( int_vector , int )") - _scale = UtilPrototype("void int_vector_scale( int_vector , int )") - _div = UtilPrototype("void int_vector_div( int_vector , int )") - _inplace_add = UtilPrototype("void int_vector_inplace_add( int_vector , int_vector )") - _inplace_mul = UtilPrototype("void int_vector_inplace_mul( int_vector , int_vector )") - _assign = UtilPrototype("void int_vector_set_all( int_vector , int)") - _memcpy = UtilPrototype("void int_vector_memcpy(int_vector , int_vector )") - _set_default = UtilPrototype("void int_vector_set_default( int_vector , int)") - _get_default = UtilPrototype("int int_vector_get_default( int_vector )") - _element_size = UtilPrototype("int int_vector_element_size( int_vector )") - - _permute = UtilPrototype("void int_vector_permute(int_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj int_vector_alloc_sort_perm(int_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)") - _contains = UtilPrototype("bool int_vector_contains(int_vector, int)") - _select_unique = UtilPrototype("void int_vector_select_unique(int_vector)") - _element_sum = UtilPrototype("int int_vector_sum(int_vector)") - _get_data_ptr = UtilPrototype("int* int_vector_get_ptr(int_vector)") - _count_equal = UtilPrototype("int int_vector_count_equal(int_vector, int)") - _init_range = UtilPrototype("void int_vector_init_range(int_vector, int , int , int)") - - def __init__(self, default_value=0, initial_size=0): - super(IntVector, self).__init__(default_value, initial_size) - - @classmethod - def active_list(cls, range_string): - """Will create a IntVector instance with the values from @range_string. - - The range_string input should be of the type "1,3-5,9,17", - i.e. integer values separated by commas, and dashes to - represent ranges. If the input string contains ANY invalid - characters the returned active list will be empty: - - "1,4-7,10" => {1,4,5,6,7,10} - "1,4-7,10X" => {} - - The empty list will evaluate to false. The values in the input - string are meant to indicate "active values", i.e. the output - values are sorted and repeated values are only counted once: - - "1,1,7,2" => {1,2,7} - - """ - return cls._create_active_list(range_string) - - @classmethod - def valueList(cls , range_string): - """Will create a IntVecter of all the values in the @range_string. - - Will not sort the values, and not uniquiefy - in contrast to - the active_list() method. - - """ - return cls._create_value_list(range_string) - - - def count(self, value): - """ @rtype: int """ - return self._count_equal(value) diff --git a/ThirdParty/Ert/python/python/ecl/util/log.py b/ThirdParty/Ert/python/python/ecl/util/log.py deleted file mode 100644 index 2e766b83a6..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/log.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'log.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class Log(BaseCClass): - _get_filename = UtilPrototype("char* log_get_filename(log)") - _reopen = UtilPrototype("void log_reopen(log, char*)") - _get_level = UtilPrototype("int log_get_level(log)") - _set_level = UtilPrototype("void log_set_level(log, int)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - - def get_filename(self): - return self._get_filename() - # return "ert_config.log" - - def reopen(self, filename): - print('Logfile cannot be reopened') - # cfunc.reopen( self , filename) - - def get_level(self): - return self._get_level() - - def set_level(self, level): - pass - # self._set_level(self, level) diff --git a/ThirdParty/Ert/python/python/ecl/util/lookup_table.py b/ThirdParty/Ert/python/python/ecl/util/lookup_table.py deleted file mode 100644 index 6497a8273c..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/lookup_table.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'lookup_table.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class LookupTable(BaseCClass): - _alloc = UtilPrototype("void* lookup_table_alloc_empty()" , bind = False) - _max = UtilPrototype("double lookup_table_get_max_value( lookup_table )") - _min = UtilPrototype("double lookup_table_get_min_value( lookup_table )") - _arg_max = UtilPrototype("double lookup_table_get_max_arg( lookup_table )") - _arg_min = UtilPrototype("double lookup_table_get_min_arg( lookup_table )") - _append = UtilPrototype("void lookup_table_append( lookup_table , double , double )") - _size = UtilPrototype("int lookup_table_get_size( lookup_table )") - _interp = UtilPrototype("double lookup_table_interp( lookup_table , double)") - _free = UtilPrototype("void lookup_table_free( lookup_table )") - _set_low_limit = UtilPrototype("void lookup_table_set_low_limit( lookup_table , double)") - _set_high_limit = UtilPrototype("void lookup_table_set_high_limit( lookup_table , double)") - _has_low_limit = UtilPrototype("bool lookup_table_has_low_limit( lookup_table)") - _has_high_limit = UtilPrototype("bool lookup_table_has_high_limit( lookup_table)") - - def __init__(self, lower_limit=None, upper_limit=None): - super(LookupTable, self).__init__(self._alloc()) - - if not lower_limit is None: - self.setLowerLimit(lower_limit) - - if not upper_limit is None: - self.setUpperLimit(upper_limit) - - def getMaxValue(self): - self.assertSize(1) - return self._max() - - def getMinValue(self): - self.assertSize(1) - return self._min() - - def getMinArg(self): - self.assertSize(1) - return self._arg_min() - - def getMaxArg(self): - self.assertSize(1) - return self._arg_max() - - def assertSize(self, N): - if len(self) < N: - raise ValueError("Lookup table is too small") - - def __len__(self): - return self._size() - - @property - def size(self): - return len(self) - - # Deprecated properties - @property - def max(self): - return self.getMaxValue() - - @property - def min(self): - return self.getMinValue() - - @property - def arg_max(self): - return self.getMaxArg() - - @property - def arg_min(self): - return self.getMinArg() - - def setLowerLimit(self, value): - self._set_low_limit(value) - - def hasLowerLimit(self): - return self._has_low_limit() - - def setUpperLimit(self, value): - self._set_high_limit(value) - - def hasUpperLimit(self): - return self._has_high_limit() - - def interp(self, x): - self.assertSize(2) - if x < self.getMinArg(): - if not self.hasLowerLimit(): - raise ValueError("Interpolate argument:%g is outside valid interval: [%g,%g]" % (x, self.getMinArg(), self.getMaxArg())) - elif x > self.getMaxArg(): - if not self.hasUpperLimit(): - raise ValueError("Interpolate argument:%g is outside valid interval: [%g,%g]" % (x, self.getMinArg(), self.getMaxArg())) - - return self._interp(x) - - def append(self, x, y): - self._append( x, y) - - #todo: necessary??? - def __del__(self): - self._free() - - def free(self): - self._free( ) - diff --git a/ThirdParty/Ert/python/python/ecl/util/matrix.py b/ThirdParty/Ert/python/python/ecl/util/matrix.py deleted file mode 100644 index cfb99f7046..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/matrix.py +++ /dev/null @@ -1,227 +0,0 @@ - -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'matrix.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -# The Matrix class implemented here wraps the C matrix implementation -# in matrix.c from the libutil library. The C matrix implementation -# has the very limited ambition of just barely satisfying the matrix -# needs of the EnKF algorithm, i.e. for general linear algebra -# applications you will probably be better served by a more complete -# matrix library. This applies even more so to this Python -# implementation; it is only here facilitate use of C libraries which -# expect a matrix instance as input (i.e. the LARS estimator). For -# general linear algebra in Python the numpy library is a natural -# choice. - - -from cwrap import BaseCClass,CFILE -from ecl.util import UtilPrototype - - -class Matrix(BaseCClass): - _matrix_alloc = UtilPrototype("void* matrix_alloc(int, int )" , bind = False) - _matrix_alloc_identity = UtilPrototype("matrix_obj matrix_alloc_identity( int )" , bind = False) - _alloc_transpose = UtilPrototype("matrix_obj matrix_alloc_transpose(matrix)") - _inplace_transpose = UtilPrototype("void matrix_inplace_transpose(matrix)") - _copy = UtilPrototype("matrix_obj matrix_alloc_copy(matrix)" ) - _sub_copy = UtilPrototype("matrix_obj matrix_alloc_sub_copy(matrix, int , int , int , int)" ) - _free = UtilPrototype("void matrix_free(matrix)") - _iget = UtilPrototype("double matrix_iget( matrix , int , int )") - _iset = UtilPrototype("void matrix_iset( matrix , int , int , double)") - _set_all = UtilPrototype("void matrix_scalar_set( matrix , double)") - _scale_column = UtilPrototype("void matrix_scale_column(matrix , int , double)") - _scale_row = UtilPrototype("void matrix_scale_row(matrix , int , double)") - _copy_column = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False) - _rows = UtilPrototype("int matrix_get_rows(matrix)") - _columns = UtilPrototype("int matrix_get_columns(matrix)") - _equal = UtilPrototype("bool matrix_equal(matrix, matrix)") - _pretty_print = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)") - _fprint = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)") - _random_init = UtilPrototype("void matrix_random_init(matrix, rng)") - _dump_csv = UtilPrototype("void matrix_dump_csv(matrix, char*)") - - # Requires BLAS. If the library does not have the - # matrix_alloc_matmul() function the prototype will have _func = - # None, and NotImplementedError( ) will be raised int the - # __call__() method if we try to use this function. - _alloc_matmul = UtilPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True) - - # Requires BLAS! - @classmethod - def matmul(cls, m1,m2): - """ - Will return a new matrix which is matrix product of m1 and m2. - """ - if m1.columns( ) == m2.rows( ): - return cls._alloc_matmul( m1, m2) - else: - raise ValueError("Matrix size mismatch") - - - def __init__(self, rows, columns, value=0): - c_ptr = self._matrix_alloc(rows, columns) - super(Matrix, self).__init__(c_ptr) - self.setAll(value) - - def copy(self): - return self._copy( ) - - @classmethod - def identity(cls, dim): - """Returns a dim x dim identity matrix.""" - if dim < 1: - raise ValueError('Identity matrix must have positive size, %d not allowed.' % dim) - return cls._matrix_alloc_identity(dim) - - def subCopy(self, row_offset, column_offset, rows, columns): - if row_offset < 0 or row_offset >= self.rows(): - raise ValueError("Invalid row offset") - - if column_offset < 0 or column_offset >= self.columns(): - raise ValueError("Invalid column offset") - - if row_offset + rows > self.rows(): - raise ValueError("Invalid rows") - - if column_offset + columns > self.columns(): - raise ValueError("Invalid columns") - - return self._sub_copy( row_offset , column_offset , rows , columns) - - - def __str__(self): - s = "" - for i in range(self.rows()): - s += "[" - for j in range(self.columns()): - d = self._iget(i, j) - s += "%6.3g " % d - s += "]\n" - return s - - def __getitem__(self, index_tuple): - if not 0 <= index_tuple[0] < self.rows(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) - - if not 0 <= index_tuple[1] < self.columns(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) - - return self._iget(index_tuple[0], index_tuple[1]) - - def __setitem__(self, index_tuple, value): - if not 0 <= index_tuple[0] < self.rows(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) - - if not 0 <= index_tuple[1] < self.columns(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) - - return self._iset(index_tuple[0], index_tuple[1], value) - - def dims(self): - return self._rows(), self._columns() - - def rows(self): - """ @rtype: int """ - return self._rows() - - def transpose(self , inplace = False): - """ - Will transpose the matrix. By default a transposed copy is returned. - """ - if inplace: - self._inplace_transpose( ) - return self - else: - return self._alloc_transpose( ) - - - def columns(self): - """ @rtype: int """ - return self._columns() - - def __eq__(self, other): - assert isinstance(other, Matrix) - return self._equal(other) - - def scaleColumn(self, column, factor): - if not 0 <= column < self.columns(): - raise IndexError("Expected column: [0,%d) got:%d" % (self.columns(), column)) - self._scale_column(column, factor) - - def scaleRow(self, row, factor): - if not 0 <= row < self.rows(): - raise IndexError("Expected row: [0,%d) got:%d" % (self.rows(), row)) - self._scale_row(row, factor) - - def setAll(self, value): - self._set_all(value) - - def copyColumn(self, target_column, src_column): - columns = self.columns() - if not 0 <= src_column < columns: - raise ValueError("src column:%d invalid" % src_column) - - if not 0 <= target_column < columns: - raise ValueError("target column:%d invalid" % target_column) - - if src_column != target_column: - # The underlying C function accepts column copy between matrices. - Matrix._copy_column(self, self, target_column, src_column) - - - def dumpCSV(self , filename): - self._dump_csv( filename ) - - - def prettyPrint(self, name, fmt="%6.3g"): - self._pretty_print(name, fmt) - - def fprint(self , fileH , fmt = "%g "): - """Will print ASCII representation of matrix. - - The fileH argument should point to an open Python - filehandle. If you supply a fmt string it is important that it - contains a separator, otherwise you might risk that elements - overlap in the output. For the matrix: - - [0 1 2] - m = [3 4 5] - [6 7 8] - - The code: - - with open("matrix.txt" , "w") as f: - m.fprintf( f ) - - The file 'matrix.txt' will look like: - - 0 1 2 - 3 4 5 - 6 7 8 - - """ - self._fprint( fmt , CFILE( fileH)) - - - def randomInit(self, rng): - self._random_init(rng) - - def free(self): - self._free() - - - diff --git a/ThirdParty/Ert/python/python/ecl/util/path_format.py b/ThirdParty/Ert/python/python/ecl/util/path_format.py deleted file mode 100644 index 07d565c46f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/path_format.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - -# The path_fmt implementation hinges strongly on variable length -# argument lists in C - not clear if/how that maps over to Python, -# this Python class therefor has *very* limited functionality. - - -class PathFormat(BaseCClass): - TYPE_NAME = "path_fmt" - _alloc = UtilPrototype("void* path_fmt_alloc_directory_fmt(char*)", bind = False) - _str = UtilPrototype("char* path_fmt_get_fmt(path_fmt)") - _free = UtilPrototype("void path_fmt_free(path_fmt)") - - def __init__(self, path_fmt): - c_ptr = self._alloc( path_fmt ) - if c_ptr: - super(PathFormat, self).__init__(c_ptr) - else: - raise ValueError('Unable to construct path format "%s"' % path_fmt) - - def __repr__(self): - return self._create_repr('fmt=%s' % self._str()) - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/util/permutation_vector.py b/ThirdParty/Ert/python/python/ecl/util/permutation_vector.py deleted file mode 100644 index dabbd3788f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/permutation_vector.py +++ /dev/null @@ -1,38 +0,0 @@ -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class PermutationVector(BaseCClass): - TYPE_NAME = "permutation_vector" - _free = UtilPrototype("void perm_vector_free( permutation_vector )") - _size = UtilPrototype("int perm_vector_get_size( permutation_vector )") - _iget = UtilPrototype("int perm_vector_iget( permutation_vector , int)") - - - def __init__(self): - raise NotImplementedError("Can not instantiate PermutationVector directly") - - - def __len__(self): - return self._size( ) - - - def __str__(self): - s = "(" - for index in self: - s += " %d" % index - return s + ")" - - - def __getitem__(self, index): - if index < 0: - index += len(self) - - if 0 <= index < len(self): - return self._iget( index ) - else: - raise IndexError("Invalid index:%d" % index) - - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/util/profiler.py b/ThirdParty/Ert/python/python/ecl/util/profiler.py deleted file mode 100644 index ab35189cc9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/profiler.py +++ /dev/null @@ -1,34 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -try: - from StringIO import StringIO -except ImportError: - from io import StringIO - -import cProfile -import pstats -import sys - - -class Profiler(object): - - __profiler = None - """ :type: Profile """ - - @classmethod - def startProfiler(cls, subcalls=True, builtins=True): - cls.__profiler = cProfile.Profile() - cls.__profiler.enable(subcalls=subcalls, builtins=builtins) - - @classmethod - def stopProfiler(cls, sort_method="cumulative"): - if cls.__profiler is not None: - cls.__profiler.disable() - stream = StringIO() - stats_printer = pstats.Stats(cls.__profiler, stream=stream).sort_stats(sort_method) - stats_printer.print_stats() - cls.__profiler = None - print(stream.getvalue()) - else: - sys.stderr.write("WARNING: Profiler has not been started!\n") - diff --git a/ThirdParty/Ert/python/python/ecl/util/rng.py b/ThirdParty/Ert/python/python/ecl/util/rng.py deleted file mode 100644 index a747d31887..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/rng.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'rng.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os.path - -from cwrap import BaseCClass -from ecl.util import UtilPrototype -from ecl.util.enums import RngInitModeEnum, RngAlgTypeEnum - - -class RandomNumberGenerator(BaseCClass): - TYPE_NAME = "rng" - - _rng_alloc = UtilPrototype("void* rng_alloc(rng_alg_type_enum, rng_init_mode_enum)" , bind = False) - _free = UtilPrototype("void rng_free(rng)") - _get_double = UtilPrototype("double rng_get_double(rng)") - _get_int = UtilPrototype("int rng_get_int(rng, int)") - _get_max_int = UtilPrototype("uint rng_get_max_int(rng)") - _state_size = UtilPrototype("int rng_state_size(rng)") - _set_state = UtilPrototype("void rng_set_state(rng , char*)") - _load_state = UtilPrototype("void rng_load_state(rng , char*)") - _save_state = UtilPrototype("void rng_save_state(rng , char*)") - - def __init__(self, alg_type=RngAlgTypeEnum.MZRAN, init_mode=RngInitModeEnum.INIT_CLOCK): - assert isinstance(alg_type, RngAlgTypeEnum) - assert isinstance(init_mode, RngInitModeEnum) - - c_ptr = self._rng_alloc(alg_type, init_mode) - super(RandomNumberGenerator, self).__init__(c_ptr) - - def stateSize(self): - return self._state_size() - - def setState(self, seed_string): - state_size = self.stateSize() - if len(seed_string) < state_size: - raise ValueError("The seed string must be at least %d characters long" % self.stateSize()) - self._set_state( seed_string) - - def getDouble(self): - """ @rtype: float """ - return self._get_double() - - def getInt(self, max=None): - """ @rtype: float """ - if max is None: - max = self._get_max_int() - - return self._get_int(max) - - def free(self): - self._free() - - def loadState(self , seed_file): - """ - Will seed the RNG from the file @seed_file. - """ - if os.path.isfile( seed_file ): - self._load_state( seed_file ) - else: - raise IOError("No such file: %s" % seed_file) - - - def saveState(self , seed_file): - """ - Will save the state of the rng to @seed_file - """ - self._save_state( seed_file ) - diff --git a/ThirdParty/Ert/python/python/ecl/util/stat.py b/ThirdParty/Ert/python/python/ecl/util/stat.py deleted file mode 100644 index d219a7869a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/stat.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'stat.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from collections import Sequence - -from cwrap import PrototypeError -from ecl.util import LLSQResultEnum, UtilPrototype, Matrix - - -quantile = UtilPrototype("double statistics_empirical_quantile(double_vector, double)") -"""@type: (ecl.util.DoubleVector, float)->float""" - -quantile_sorted = UtilPrototype("double statistics_empirical_quantile(double_vector, double)") -"""@type: (ecl.util.DoubleVector, float)->float""" - -try: - _polyfit = UtilPrototype("llsq_result_enum matrix_stat_polyfit(matrix, matrix, matrix, matrix)") -except PrototypeError: - _polyfit = None - -def polyfit(n, x, y, s=None): - """ - @type n: int - @type x: Matrix or Sequence - @type y: Matrix or Sequence - @type s: Matrix or Sequence or None - @return: tuple - """ - if _polyfit is None: - raise NotImplementedError("Sorry - your ert distribution has been built without lapack support") - - if isinstance(x, Matrix): - xm = x - else: - xm = Matrix(len(x), 1) - for i in range(len(x)): - xm[i, 0] = x[i] - - if isinstance(y, Matrix): - ym = y - else: - ym = Matrix(len(y), 1) - for i in range(len(y)): - ym[i, 0] = y[i] - - if s: - if isinstance(s, Matrix): - sm = s - else: - sm = Matrix(len(s), 1) - for i in range(len(s)): - sm[i, 0] = s[i] - else: - sm = s - - beta = Matrix(n, 1) - res = _polyfit(beta, xm, ym, sm) - - if not res == LLSQResultEnum.LLSQ_SUCCESS: - raise Exception("Linear Least Squares Estimator failed?") - - l = [] - for i in range(n): - l.append(beta[i, 0]) - - return tuple(l) diff --git a/ThirdParty/Ert/python/python/ecl/util/stringlist.py b/ThirdParty/Ert/python/python/ecl/util/stringlist.py deleted file mode 100644 index f4e22b03c6..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/stringlist.py +++ /dev/null @@ -1,308 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'stringlist.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Simple wrapping of stringlist 'class' from C library. - -The stringlist type from the libutil C library is a simple structure -consisting of a vector of \0 terminated char pointers - slightly -higher level than the (char ** string , int size) convention. - -For a pure Python application you should just stick with a normal -Python list of string objects; but when interfacing with the C -libraries there are situations where you might need to instantiate a -StringList object. - -The StringList constructor can take an optional argument which should -be an iterable consisting of strings, and the strings property will -return a normal python list of string objects, used in this way you -hardly need to notice that the StringList class is at play. -""" -from __future__ import absolute_import, division, print_function, unicode_literals -from six import string_types -from ecl.util import UtilPrototype -from cwrap import BaseCClass - - -class StringList(BaseCClass): - TYPE_NAME = "stringlist" - - _alloc = UtilPrototype("void* stringlist_alloc_new( )", bind = False) - _free = UtilPrototype("void stringlist_free(stringlist )") - _append = UtilPrototype("void stringlist_append_copy(stringlist , char* )") - _iget = UtilPrototype("char* stringlist_iget(stringlist , int )") - _front = UtilPrototype("char* stringlist_front( stringlist )") - _back = UtilPrototype("char* stringlist_back( stringlist )") - _iget_copy = UtilPrototype("char* stringlist_iget_copy(stringlist, int)") - _iset = UtilPrototype("void stringlist_iset_copy( stringlist , int , char* )") - _get_size = UtilPrototype("int stringlist_get_size( stringlist )") - _contains = UtilPrototype("bool stringlist_contains(stringlist , char*)") - _equal = UtilPrototype("bool stringlist_equal(stringlist , stringlist)") - _sort = UtilPrototype("void stringlist_python_sort( stringlist , int)") - _pop = UtilPrototype("char* stringlist_pop(stringlist)") - _last = UtilPrototype("char* stringlist_get_last(stringlist)") - _find_first = UtilPrototype("int stringlist_find_first(stringlist, char*)") - - def __init__(self, initial=None): - """ - Creates a new stringlist instance. - - Creates a new stringlist instance. The optional argument - @initial should be an iterable of strings which will be the - initial content of the StringList; the content will be copied - from the initial list: - - S = StringList( initial = ["My" , "name" , "is", "John" , "Doe"] ) - - If an element in the @initial argument is not a string the - TypeError exception will be raised. - - If c_ptr argument is different from None, that should refer to - an already created stringlist instance; this Python will take - ownership of the underlying object. - """ - - c_ptr = self._alloc() - super(StringList, self).__init__(c_ptr) - if initial: - self._append_all(initial) - - def _append_all(self, lst): - for s in lst: - if isinstance(s, bytes): - s.decode('ascii') - if isinstance(s, string_types): - self.append(s) - else: - raise TypeError('Item is not a string: "%s".' % s) - - - def __eq__(self , other): - if len(self) == len(other): - if isinstance( other , StringList): - return self._equal(other) - else: - equal = True - for index,s2 in enumerate(other): - if self[index] != s2: - equal = False - break - return equal - else: - return False - - - def __setitem__(self, index, value): - if isinstance(index, int): - length = len(self) - if index < 0: - # Will only wrap backwards once - index = len(self) + index - - if index < 0 or index >= length: - raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) - if isinstance(value, bytes): - value = value.decode('ascii') - if isinstance(value, string_types): - self._iset(index, value) - else: - raise TypeError("Item: %s not string type" % value) - - - def __getitem__(self, index): - """ - Implements [] read operator on the stringlist. - - The __getitem__ method supports negative, i.e. from the right, - indexing; but not slices. - """ - if isinstance(index, int): - length = len(self) - if index < 0: - index += length - if index < 0 or index >= length: - raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) - else: - return self._iget(index) - else: - raise TypeError("Index should be integer type") - - def __contains__(self, s): - """ - Implements the 'in' operator. - - The 'in' check is based on string equality. - """ - return self._contains(s) - - - def __iadd__(self , other): - if isinstance(other, bytes): - other.decode('ascii') - if isinstance(other , string_types): - raise TypeError("Can not add strings with + - use append()") - for s in other: - self.append( s ) - return self - - - def __add__(self , other): - copy = StringList( initial = self ) - copy += other - return copy - - - def __ior__(self , other): - if isinstance(other, bytes): - other.decode('ascii') - if isinstance(other , string_types): - raise TypeError("Can not | with string.") - for s in other: - if not s in self: - self.append( s ) - return self - - - def __or__(self , other): - copy = StringList( initial = self ) - copy |= other - return copy - - - - def contains(self, s): - """ - Checks if the list contains @s. - - Functionality also available through the 'in' builtin in - Python. - """ - return s in self - - - def __len__(self): - """ - The length of the list - used to support builtin len(). - """ - return self._get_size( ) - - - def __str__(self): - """ - String representation of list; used when calling print." - """ - buffer = "[" - length = len(self) - for i in range(length): - if i == length - 1: - buffer += "\'%s\'" % self[i] - else: - buffer += "\'%s\'," % self[i] - buffer += "]" - return buffer - - def __repr__(self): - return 'StringList(size = %d) %s' % (len(self), self._ad_str()) - - def empty(self): - """Returns true if and only if list is empty.""" - return len(self) == 0 - - def pop(self): - """ - Will remove the last element from the list and return it. - - Will raise IndexError if list is empty. - """ - if not self.empty(): - return self._pop() - else: - raise IndexError("List empty. Cannot call pop().") - - - def append(self, s): - """ - Appends a new string @s to list. If the input argument is not a - string the string representation will be appended. - """ - if isinstance(s, bytes): - s.decode('ascii') - if isinstance(s, string_types): - self._append(s) - else: - self._append(str(s)) - - - @property - def strings(self): - """ - The strings in as a normal Python list of strings. - - The content is copied, so the StringList() instance can safely go - out of scope after the call has completed. Hmmmm - is that true? - """ - slist = [] - for s in self: - slist.append(s) - return slist - - @property - def last(self): - """ - Will return the last element in list. Raise IndexError if empty. - """ - if not self.empty(): - return self._last() - else: - raise IndexError("List empty. No such element last().") - - - def sort(self, cmp_flag=0): - """ - Will sort the list inplace. - - The string comparison can be altered with the value of the - optional cmp_flag parameter: - - 0 : Normal strcmp() string comparison - 1 : util_strcmp_int() string comparison - 2 : util_strcmp_float() string comparison - - """ - self._sort(cmp_flag) - - def index(self, value): - """ @rtype: int """ - if isinstance(value, bytes): - value.decode('ascii') - if isinstance(value, string_types): - return self._find_first(value) - raise KeyError('Cannot index by "%s", lst.index() needs a string.' % str(type(value))) - - def free(self): - self._free() - - - def front(self): - if not self.empty(): - return self._front() - else: - raise IndexError('List empty. No such element front().') - - def back(self): - if not self.empty(): - return self._back() - else: - raise IndexError('List empty. No such element back().') diff --git a/ThirdParty/Ert/python/python/ecl/util/thread_pool.py b/ThirdParty/Ert/python/python/ecl/util/thread_pool.py deleted file mode 100644 index fa5597398a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/thread_pool.py +++ /dev/null @@ -1,151 +0,0 @@ -import multiprocessing -from threading import Thread -import time -import traceback - - -class Task(Thread): - def __init__(self, func, *args, **kwargs): - super(Task, self).__init__() - self.__func = func - self.__args = args - self.__kwargs = kwargs - - self.__started = False - self.__done = False - self.__failed = False - self.__start_time = None - - self.__verbose = False - - def setVerbose(self, verbose): - self.__verbose = verbose - - def run(self): - self.__start_time = time.time() - self.__started = True - try: - self.__func(*self.__args, **self.__kwargs) - except Exception: - self.__failed = True - traceback.print_exc() - finally: - self.__done = True - - if self.__verbose: - running_time = time.time() - self.__start_time - print("Running time of task: %f" % running_time) - - def isDone(self): - return self.__done - - def hasStarted(self): - return self.__started or self.isAlive() - - def isRunning(self): - return self.hasStarted() and not self.__done - - def hasFailed(self): - return self.__failed - - def join(self, timeout=None): - while not self.hasStarted() or self.isRunning(): - time.sleep(0.01) - - - -class ThreadPool(object): - - def __init__(self, size=None, verbose=False): - super(ThreadPool, self).__init__() - - if size is None: - size = multiprocessing.cpu_count() - - self.__size = size - self.__task_list = [] - self.__pool_finished = False - self.__runner_thread = None - self.__verbose = verbose - self.__start_time = None - - - def addTask(self, func, *args, **kwargs): - if self.__start_time is None: - task = Task(func, *args, **kwargs) - # task.setVerbose(self.__verbose) - self.__task_list.append(task) - else: - raise UserWarning("Can not add task after the pool has started!") - - def poolSize(self): - return self.__size - - def taskCount(self): - return len(self.__task_list) - - def __allTasksFinished(self): - for task in self.__task_list: - if not task.isDone(): - return False - - return True - - def runningCount(self): - count = 0 - - for task in self.__task_list: - if task.isRunning(): - count += 1 - - return count - - def doneCount(self): - count = 0 - - for task in self.__task_list: - if task.isDone(): - count += 1 - - return count - - def __findNextTask(self): - for task in self.__task_list: - if not task.hasStarted(): - return task - - return None - - def __start(self): - while not self.__allTasksFinished(): - if self.runningCount() < self.poolSize(): - task = self.__findNextTask() - - if task is not None: - task.start() - - time.sleep(0.001) - - self.__pool_finished = True - - - def nonBlockingStart(self): - self.__runner_thread = Thread() - self.__runner_thread.run = self.__start - self.__runner_thread.start() - self.__start_time = time.time() - - def join(self): - while not self.__pool_finished: - time.sleep(0.001) - - if self.__verbose: - running_time = time.time() - self.__start_time - print("Running time: %f using a pool size of: %d" % (running_time, self.poolSize())) - - def hasFailedTasks(self): - for task in self.__task_list: - if task.hasFailed(): - return True - - return False diff --git a/ThirdParty/Ert/python/python/ecl/util/time_vector.py b/ThirdParty/Ert/python/python/ecl/util/time_vector.py deleted file mode 100644 index 7821057fc7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/time_vector.py +++ /dev/null @@ -1,170 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import datetime -import re - -from ecl.util import VectorTemplate, CTime, UtilPrototype - - -class TimeVector(VectorTemplate): - TYPE_NAME = "time_t_vector" - default_format = "%d" - - _alloc = UtilPrototype("void* time_t_vector_alloc(int, time_t )" , bind = False) - _alloc_copy = UtilPrototype("time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )") - _strided_copy = UtilPrototype("time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , int , int , int)") - _free = UtilPrototype("void time_t_vector_free( time_t_vector )") - _iget = UtilPrototype("time_t time_t_vector_iget( time_t_vector , int )") - _safe_iget = UtilPrototype("time_t time_t_vector_safe_iget( time_t_vector , int )") - _iset = UtilPrototype("time_t time_t_vector_iset( time_t_vector , int , time_t)") - _size = UtilPrototype("int time_t_vector_size( time_t_vector )") - _append = UtilPrototype("void time_t_vector_append( time_t_vector , time_t )") - _idel_block = UtilPrototype("void time_t_vector_idel_block( time_t_vector , int , int )") - _idel = UtilPrototype("void time_t_vector_idel( time_t_vector , int )") - _pop = UtilPrototype("time_t time_t_vector_pop( time_t_vector )") - _lshift = UtilPrototype("void time_t_vector_lshift( time_t_vector , int )") - _rshift = UtilPrototype("void time_t_vector_rshift( time_t_vector , int )") - _insert = UtilPrototype("void time_t_vector_insert( time_t_vector , int , time_t)") - _fprintf = UtilPrototype("void time_t_vector_fprintf( time_t_vector , FILE , char* , char*)") - _sort = UtilPrototype("void time_t_vector_sort( time_t_vector )") - _rsort = UtilPrototype("void time_t_vector_rsort( time_t_vector )") - _reset = UtilPrototype("void time_t_vector_reset( time_t_vector )") - _set_read_only = UtilPrototype("void time_t_vector_set_read_only( time_t_vector , bool )") - _get_read_only = UtilPrototype("bool time_t_vector_get_read_only( time_t_vector )") - _get_max = UtilPrototype("time_t time_t_vector_get_max( time_t_vector )") - _get_min = UtilPrototype("time_t time_t_vector_get_min( time_t_vector )") - _get_max_index = UtilPrototype("int time_t_vector_get_max_index( time_t_vector , bool)") - _get_min_index = UtilPrototype("int time_t_vector_get_min_index( time_t_vector , bool)") - _shift = UtilPrototype("void time_t_vector_shift( time_t_vector , time_t )") - _scale = UtilPrototype("void time_t_vector_scale( time_t_vector , time_t )") - _div = UtilPrototype("void time_t_vector_div( time_t_vector , time_t )") - _inplace_add = UtilPrototype("void time_t_vector_inplace_add( time_t_vector , time_t_vector )") - _inplace_mul = UtilPrototype("void time_t_vector_inplace_mul( time_t_vector , time_t_vector )") - _assign = UtilPrototype("void time_t_vector_set_all( time_t_vector , time_t)") - _memcpy = UtilPrototype("void time_t_vector_memcpy(time_t_vector , time_t_vector )") - _set_default = UtilPrototype("void time_t_vector_set_default( time_t_vector , time_t)") - _get_default = UtilPrototype("time_t time_t_vector_get_default( time_t_vector )") - _element_size = UtilPrototype("int time_t_vector_element_size( time_t_vector )") - - _permute = UtilPrototype("void time_t_vector_permute(time_t_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj time_t_vector_alloc_sort_perm(time_t_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)") - _contains = UtilPrototype("bool time_t_vector_contains(time_t_vector, time_t)") - _select_unique = UtilPrototype("void time_t_vector_select_unique(time_t_vector)") - _element_sum = UtilPrototype("time_t time_t_vector_sum(time_t_vector)") - _count_equal = UtilPrototype("int time_t_vector_count_equal(time_t_vector, time_t)") - _init_range = UtilPrototype("void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)") - - def __init__(self, default_value=None, initial_size=0): - if default_value is None: - super(TimeVector, self).__init__(CTime(0), initial_size) - else: - try: - default = CTime(default_value) - except: - raise ValueError("default value invalid - must be type ctime() or date/datetime") - - super(TimeVector, self).__init__(default, initial_size) - - @classmethod - def parseTimeUnit(cls, deltaString): - deltaRegexp = re.compile("(?P\d*)(?P[dmy])", re.IGNORECASE) - matchObj = deltaRegexp.match(deltaString) - if matchObj: - try: - num = int(matchObj.group("num")) - except: - num = 1 - - timeUnit = matchObj.group("unit").lower() - return num, timeUnit - else: - raise TypeError("The delta string must be on form \'1d\', \'2m\', \'Y\' for one day, two months or one year respectively") - - def __str__(self): - """ - Returns string representantion of vector. - """ - string_list = [] - for d in self: - string_list.append("%s" % d) - - return str(string_list) - - def append(self, value): - self._append(CTime(value)) - - def __contains__(self, value): - return self._contains(CTime(value)) - - def nextTime(self, num, timeUnit): - currentTime = self[-1].datetime() - hour = currentTime.hour - minute = currentTime.minute - second = currentTime.second - - if timeUnit == "d": - td = datetime.timedelta(days=num) - currentTime += td - else: - day = currentTime.day - month = currentTime.month - year = currentTime.year - - if timeUnit == "y": - year += num - else: - month += num - 1 - (deltaYear, newMonth) = divmod(month, 12) - month = newMonth + 1 - year += deltaYear - currentTime = datetime.datetime(year, month, day, hour, minute, second) - - return currentTime - - def appendTime(self, num, timeUnit): - next = self.nextTime(num, timeUnit) - self.append(CTime(next)) - - @classmethod - def createRegular(cls, start, end, deltaString): - """ - The last element in the vector will be <= end; i.e. if the - question of whether the range is closed in the upper end - depends on the commensurability of the [start,end] interval - and the delta: - - createRegular(0 , 10 , delta=3) => [0,3,6,9] - createRegular(0 , 10 , delta=2) => [0,2,4,6,8,10] - """ - start = CTime(start) - end = CTime(end) - if start > end: - raise ValueError("The time interval is invalid start is after end") - - (num, timeUnit) = cls.parseTimeUnit(deltaString) - - timeVector = TimeVector() - currentTime = start - while currentTime <= end: - ct = CTime(currentTime) - timeVector.append(ct) - currentTime = timeVector.nextTime(num, timeUnit) - - return timeVector - - def getDataPtr(self): - raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors") diff --git a/ThirdParty/Ert/python/python/ecl/util/ui_return.py b/ThirdParty/Ert/python/python/ecl/util/ui_return.py deleted file mode 100644 index cfe4b28180..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/ui_return.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'ui_return.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -from cwrap import BaseCClass -from ecl.util import UtilPrototype -from .enums import UIReturnStatusEnum - - -class UIReturn(BaseCClass): - TYPE_NAME = "ui_return" - - _alloc = UtilPrototype("void* ui_return_alloc( ui_return_status )" , bind = False) - _free = UtilPrototype("void ui_return_free(ui_return)") - _get_status = UtilPrototype("ui_return_status ui_return_get_status(ui_return)") - _get_help = UtilPrototype("char* ui_return_get_help(ui_return)") - _add_help = UtilPrototype("void ui_return_add_help(ui_return)") - _add_error = UtilPrototype("void ui_return_add_error(ui_return)") - _num_error = UtilPrototype("int ui_return_get_error_count(ui_return)") - _last_error = UtilPrototype("char* ui_return_get_last_error(ui_return)") - _first_error = UtilPrototype("char* ui_return_get_first_error(ui_return)") - _iget_error = UtilPrototype("char* ui_return_iget_error(ui_return , int)") - - def __init__(self , status): - c_ptr = self._alloc(status) - if c_ptr: - super(UIReturn, self).__init__(c_ptr) - else: - raise ValueError('Unable to construct UIReturn with status = %s' % str(status)) - - - def __nonzero__(self): - if self.status() == UIReturnStatusEnum.UI_RETURN_OK: - return True - else: - return False - - - def __len__(self): - return self._num_error() - - - def __getitem__(self , index): - if isinstance(index , int): - if index < 0: - index += len(self) - if 0 <= index < len(self): - return self._iget_error( index) - else: - raise IndexError('Invalid index. Valid range: [0, %d)' % len(self)) - else: - raise TypeError("Lookup type must be integer") - - - def iget_error(self , index): - return self[index] - - - def help_text(self): - help_text = self._get_help() - if help_text: - return help_text - else: - return "" - - def add_help(self, help_text): - self._add_help(help_text) - - - def status(self): - return self._get_status() - - - def __assert_error(self): - if self.status() == UIReturnStatusEnum.UI_RETURN_OK: - raise ValueError("Can not add error messages to object in state RETURN_OK") - - - def add_error(self, error): - self.__assert_error() - self._add_error(error) - - - def last_error(self): - self.__assert_error() - return self._last_error() - - - def first_error(self): - self.__assert_error() - return self._first_error() - - - def free(self): - self._free() - - def __repr__(self): - ec = len(self) - st = self.status() - ad = self._ad_str() - return 'UIReturn(error_count = %d, status = %s) %s' % (ec, st, ad) diff --git a/ThirdParty/Ert/python/python/ecl/util/util_func.py b/ThirdParty/Ert/python/python/ecl/util/util_func.py deleted file mode 100644 index 0d9e4aa2ac..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/util_func.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'util_func.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Module with utility functions from util.c -""" - -from ecl.util import UtilPrototype - -strcmp_int = UtilPrototype("int util_strcmp_int( char* , char* )") -""" -Function to compare strings with embedded integers. - -Will use proper numeric comparison when comparing strings with -embedded numbers, i.e. "CASE-9" will follow after "CASE-10" when -sorting: - - >> l = ["CASE-9" , "CASE-10"] - >> l.sort() - >> print(l) - ["CASE-10" , "CASE-9"] - >> l.sort( strcmp_int ) - >> print(l) - ["CASE-9" , "CASE-10"] - -When the standard strcmp() function is used for comparing strings -the '1' will compare as less than the '9' and the order will be -the reverse. Observe that the '-' is not interpreted as a sign -prefix. The strcmp_int function will interpret '.' as separating -character, wheras the strcmp_float() function will interpret '.' -as a descimal point. - -@type: (str, str) -> int -""" - -strcmp_float = UtilPrototype("int util_strcmp_float( char* , char* )") -""" -Function to compare strings with embedded numbers. - -See documentation of strcmp_int() for further details. -@type: (str, str) -> int -""" diff --git a/ThirdParty/Ert/python/python/ecl/util/vector_template.py b/ThirdParty/Ert/python/python/ecl/util/vector_template.py deleted file mode 100644 index 56b96c582b..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/vector_template.py +++ /dev/null @@ -1,647 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -""" -Typed vectors IntVector, DoubleVector and BoolVector. - -This module implements a quite simple typed vector which will grow -transparently as needed. The vector is created with a default value, -which will be used for not explicitly set indices. - - vec = IntVector( default_value = 66 ) - vec[0] = 10 - vec[2] = 10 - -After the 'vec[2] = 10' statement the vector has grown to contain -three elements. The element vec[1] has not been explicitly assigned by -the user, in that case the implementation has 'filled the hole' with -the default value (i.e. 66 in this case). So the statement - - print(vec[1]) - -will give '66'. The main part of the implementation is in terms of an -"abstract base class" TVector. The TVector class should be not -instantiated directly, instead the child classes IntVector, -DoubleVector or BoolVector should be used. - -The C-level has implementations for several fundamental types like -float and size_t not currently implemented in the Python version. -""" - -from __future__ import absolute_import, division, print_function, unicode_literals - -import sys - -from cwrap import CFILE, BaseCClass -from ecl.util import UtilPrototype - - - -class VectorTemplate(BaseCClass): - - def strided_copy(self, slice_range): - """ - Will create a new copy according to @slice. - - Mainly a support function to support slice based lookup like - - v = IntVector() - v[0] = 1 - v[1] = 1 - v[100] = 100 - ... - c = v[0:100:10] - - Now 'c' will be a Intvector() instance containing every tenth - element from 'v'. - """ - (start, stop, step) = slice_range.indices(len(self)) - if stop > start: - return self._strided_copy(start, stop, step) - else: - return None - - def __bool__(self): - """ - Will evaluate to False for empty vector. - """ - if len(self) == 0: - return False - else: - return True - - def __nonzero__(self): - return self.__bool__( ) - - - def copy(self): - """ - Create a new copy of the current vector. - """ - new = self._alloc_copy( ) - return new - - def __irshift__(self,shift): - if shift < 0: - raise ValueError("The shift must be positive") - self._rshift(shift) - return self - - def __ilshift__(self,shift): - if shift < 0: - raise ValueError("The shift must be positive") - if shift > len(self): - raise ValueError("The shift is too large %d > %d" % (shift, len(self))) - self._lshift( shift) - return self - - - def __rshift__(self,shift): - copy = self.copy() - copy >>= shift - return copy - - - def __lshift__(self,shift): - copy = self.copy() - copy <<= shift - return copy - - def __deepcopy__(self, memo): - new = self.copy() - return new - - def __init__(self, default_value=0, initial_size=0): - """ - Creates a new TVector instance. - """ - c_pointer = self._alloc(initial_size, default_value) - super(VectorTemplate, self).__init__(c_pointer) - self.element_size = self._element_size() - - def __contains__(self , value): - return self._contains( value) - - - def pop(self): - if len(self) > 0: - return self._pop() - else: - raise ValueError("Trying to pop from empty vector") - - - def str_data(self, width, index1, index2, fmt): - """ - Helper function for str() method. - """ - data = [] - s = "" - for index in range(index1, index2): - data.append(self[index]) - for index in range(len(data)): - s += fmt % data[index] - if index % width == (width - 1): - s += "\n" - return s - - - # The str() method is a verbatim copy of the implementation in - # ecl_kw.py. - def str(self, width=5, max_lines=10, fmt=None): - """ - Return string representation of vector for pretty printing. - - The function will return a string consisting of a header, and - then a chunk of data. The data will be formatted in @width - columns, and a maximum of @max_lines lines. If @max_lines is - not sufficient the first elements in the kewyord are - represented, a .... continuation line and then the last part - of the vector. If @max_lines is None all of the vector will be - printed, irrespectiv of how long it is. - - If a value is given for @fmt that is used as format string for - each element, otherwise a type-specific default format is - used. If given the @fmt string should contain spacing between - the elements. The implementation of the builtin method - __str__() is based on this method. - """ - - s = "" - lines = len(self) // width - if not fmt: - fmt = self.default_format + " " - - if max_lines is None or lines <= max_lines: - s += self.str_data(width, 0, len(self), fmt) - else: - s1 = width * max_lines // 2 - s += self.str_data(width, 0, s1, fmt) - s += " .... \n" - s += self.str_data(width, len(self) - s1, len(self), fmt) - - return s - - def __str__(self): - """ - Returns string representantion of vector. - """ - return self.str(max_lines=10, width=5) - - - def __getitem__(self, index): - """ - Implements read [] operator - @index can be slice instance. - """ - if isinstance(index, int): - length = len(self) - idx = index - if idx < 0: - idx += length - - if 0 <= idx < length: - return self._iget(idx) - else: - raise IndexError('Index must be in range %d <= %d < %d.' % (0, index, length)) - elif isinstance(index, slice): - return self.strided_copy(index) - else: - raise TypeError("Index should be integer or slice type.") - - def __setitem__(self, index, value): - """ - Implements write [] operator - @index must be integer or slice. - """ - ls = len(self) - if isinstance(index, int): - idx = index - if idx < 0: - idx += ls - self._iset(idx, value) - elif isinstance( index, slice ): - for i in range(*index.indices(ls)): - self[i] = value - else: - raise TypeError("Index should be integer type") - - ################################################################## - # Mathematical operations: - - def __IADD(self, delta, add): - """ - Low-level function implementing inplace add. - - The __IADD__ function implements the operation: - - v += a - - The variable which is added, i.e. @delta, can either be of the - same type as the current instance, or a numerical scalar. The - __IADD__ method implements both add and subtract, based on the - boolean flag @add. - - The __IADD__ method should not be called directly; but rather - via the __iadd__, __add__ and __radd__ methods which implement - the various addition operation, and the corresponding - subtraction operations: __isub__, __sub__ and __rsub__. - """ - if type(self) == type(delta): - if len(self) == len(delta): - # This is vector + vector operation. - if not add: - delta *= -1 - self._inplace_add(delta) - else: - raise ValueError("Incompatible sizes for add self:%d other:%d" % (len(self), len(delta))) - else: - if isinstance(delta, int) or isinstance(delta, float): - if not add: - delta *= -1 - self._shift(delta) - else: - raise TypeError("delta has wrong type:%s " % type(delta)) - - return self - - - def __iadd__(self, delta): - """ - Implements inplace add. @delta can be vector or scalar. - """ - return self.__IADD(delta, True) - - - def __isub__(self, delta): - """ - Implements inplace subtract. @delta can be vector or scalar. - """ - return self.__IADD(delta, False) - - - def __radd__(self, delta): - return self.__add__(delta) - - - def __add__(self, delta): - """ - Implements add operation - creating a new copy. - - b = DoubleVector() - c = DoubleVector() // Or alternatively scalar - .... - a = b + c - """ - copy = self._alloc_copy( ) - copy += delta - return copy - - def __sub__(self, delta): - """ - Implements subtraction - creating new copy. - """ - copy = self._alloc_copy( ) - copy -= delta - return copy - - - def __rsub__(self, delta): - return self.__sub__(delta) * -1 - - - def __imul__(self, factor): - """ - Low-level function implementing inplace multiplication. - - The __IMUL__ function implements the operation: - - v *= a - - The variable which is multiplied in, i.e. @factor, can either - be of the same type as the current instance, or a numerical - scalar. The __IMUL__ method should not be called directly, but - rather via the __mul__, __imul__ and __rmul__ functions. - """ - - if type(self) == type(factor): - # This is vector * vector operation. - if len(self) == len(factor): - self._inplace_mul(factor) - else: - raise ValueError("Incompatible sizes for mul self:%d other:%d" % (len(self), len(factor))) - else: - if isinstance(factor, int) or isinstance(factor, float): - self._scale(factor) - else: - raise TypeError("factor has wrong type:%s " % type(factor)) - - return self - - - def __mul__(self, factor): - copy = self._alloc_copy( ) - copy *= factor - return copy - - def __rmul__(self, factor): - return self.__mul__(factor) - - - def __div__(self, divisor): - if isinstance(divisor, int) or isinstance(divisor, float): - copy = self._alloc_copy( ) - copy._div(divisor) - return copy - else: - raise TypeError("Divisor has wrong type:%s" % type(divisor)) - - # End mathematical operations - ################################################################# - - # Essentally implements a = b - def assign(self, value): - """ - Implements assignment of type a = b. - - The @value parameter can either be a vector instance, in which - case the content of @value is copied into the current - instance, or a scalar in which case all the elements of the - vector are set to this value: - - v1 = IntVector() - v2 = IntVector() - - v1[10] = 77 - v2.assign( v1 ) # Now v2 contains identicall content to v1 - .... - v1.assign( 66 ) # Now v1 is a vector of 11 elements - all equal to 66 - - """ - if type(self) == type(value): - # This is a copy operation - self._memcpy(value) - else: - if isinstance(value, int) or isinstance(value, float): - self._assign(value) - else: - raise TypeError("Value has wrong type") - - def __len__(self): - """ - The number of elements in the vector. - """ - return self._size( ) - - - def printf(self, fmt=None, name=None, stream=sys.stdout): - """ - See also the str() method which returns string representantion - of the vector. - """ - cfile = CFILE(stream) - if not fmt: - fmt = self.default_format - self._fprintf(cfile, name, fmt) - - - def max(self): - if len(self) > 0: - return self._get_max() - else: - raise IndexError("The vector is empty!") - - def min(self): - if len(self) > 0: - return self._get_min() - else: - raise IndexError("The vector is empty!") - - - def minIndex(self, reverse=False): - """ - @type reverse: bool - @rtype: int - """ - if len(self) > 0: - return self._get_min_index(reverse) - else: - raise IndexError("The vector is empty!") - - def maxIndex(self, reverse=False): - """ - @type reverse: bool - @rtype: int - """ - if len(self) > 0: - return self._get_max_index(reverse) - else: - raise IndexError("The vector is empty!") - - def append(self, value): - self._append(value) - - def deleteBlock(self, index, block_size): - """ - Remove a block of size @block_size starting at @index. - - After the removal data will be left shifted. - """ - self._idel_block(index, block_size) - - def sort(self, reverse=False): - """ - Sort the vector inplace in increasing numerical order or decreasing order if reverse is True. - @type reverse: bool - """ - if not reverse: - self._sort() - else: - self._rsort() - - def clear(self): - self._reset() - - def safeGetByIndex(self, index): - return self._safe_iget(index) - - def setReadOnly(self, read_only): - self._set_read_only(read_only) - - def getReadOnly(self): - return self._get_read_only() - - def setDefault(self, value): - self._set_default(value) - - def getDefault(self): - return self._get_default() - - - def free(self): - self._free() - - def __repr__(self): - return self._create_repr('size = %d' % len(self)) - - def permute(self, permutation_vector): - """ - Reorders this vector based on the indexes in permutation_vector. - @type permutation_vector: PermutationVector - """ - - self._permute( permutation_vector) - - def permutationSort(self, reverse=False): - """ - Returns the permutation vector for sorting of this vector. Vector is not sorted. - @type reverse: bool - @@rtype: PermutationVector - """ - if len(self) > 0: - if not reverse: - return self._sort_perm() - else: - return self._rsort_perm() - - return None - - - def asList(self): - l = [0] * len(self) - for (index,value) in enumerate(self): - l[index] = value - - return l - - def selectUnique(self): - self._select_unique() - - - def elementSum(self): - return self._element_sum( ) - - - def getDataPtr(self): - "Low level function which returns a pointer to underlying storage" - # Observe that the get_data_ptr() function is not implemented - # for the TimeVector class. - return self._get_data_ptr() - - def countEqual(self , value): - return self._count_equal( value ) - - - def initRange(self , min_value , max_value , delta): - """ - Will fill the vector with the values from min_value to - max_value in steps of delta. The upper limit is guaranteed to - be inclusive, even if it is not commensurable with the delta. - """ - if delta == 0: - raise ValueError("Invalid range") - else: - self._init_range( min_value , max_value , delta ) - - @classmethod - def createRange(cls , min_value , max_value , delta): - """ - Will create new vector and initialize a range. - """ - vector = cls( ) - vector.initRange( min_value , max_value , delta ) - return vector - - def _strided_copy(self, *_): - raise NotImplementedError() - def _rshift(self, *_): - raise NotImplementedError() - def _lshift(self, *_): - raise NotImplementedError() - def _alloc(self, *_): - raise NotImplementedError() - def _element_size(self, *_): - raise NotImplementedError() - def _contains(self, *_): - raise NotImplementedError() - def _pop(self, *_): - raise NotImplementedError() - def default_format(self, *_): - raise NotImplementedError() - def _iget(self, *_): - raise NotImplementedError() - def _iset(self, *_): - raise NotImplementedError() - def _inplace_add(self, *_): - raise NotImplementedError() - def _shift(self, *_): - raise NotImplementedError() - def _alloc_copy(self, *_): - raise NotImplementedError() - def _inplace_mul(self, *_): - raise NotImplementedError() - def _scale(self, *_): - raise NotImplementedError() - def _memcpy(self, *_): - raise NotImplementedError() - def _assign(self, *_): - raise NotImplementedError() - def _size(self, *_): - raise NotImplementedError() - def _fprintf(self, *_): - raise NotImplementedError() - def _get_max(self, *_): - raise NotImplementedError() - def _get_min(self, *_): - raise NotImplementedError() - def _get_min_index(self, *_): - raise NotImplementedError() - def _get_max_index(self, *_): - raise NotImplementedError() - def _append(self, *_): - raise NotImplementedError() - def _idel_block(self, *_): - raise NotImplementedError() - def _sort(self, *_): - raise NotImplementedError() - def _rsort(self, *_): - raise NotImplementedError() - def _reset(self, *_): - raise NotImplementedError() - def _safe_iget(self, *_): - raise NotImplementedError() - def _set_read_only(self, *_): - raise NotImplementedError() - def _get_read_only(self, *_): - raise NotImplementedError() - def _set_default(self, *_): - raise NotImplementedError() - def _get_default(self, *_): - raise NotImplementedError() - def _free(self, *_): - raise NotImplementedError() - def _permute(self, *_): - raise NotImplementedError() - def _sort_perm(self, *_): - raise NotImplementedError() - def _rsort_perm(self, *_): - raise NotImplementedError() - def _select_unique(self, *_): - raise NotImplementedError() - def _element_sum(self, *_): - raise NotImplementedError() - def _get_data_ptr(self, *_): - raise NotImplementedError() - def _count_equal(self, *_): - raise NotImplementedError() - def _init_range(self, *_): - raise NotImplementedError() diff --git a/ThirdParty/Ert/python/python/ecl/util/version.py b/ThirdParty/Ert/python/python/ecl/util/version.py deleted file mode 100644 index dbbc66c74d..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/version.py +++ /dev/null @@ -1,118 +0,0 @@ -from ecl.util import UtilPrototype - - -def cmp_method(method): - def cmp_wrapper(self, other): - if not isinstance(other, Version): - other = Version(other[0], other[1], other[2]) - - return method(self, other) - - return cmp_wrapper - - - -class Version(object): - - - def __init__(self, major, minor, micro, git_commit = None, build_time = None): - self.major = major - self.minor = minor - self.micro = micro - try: - self.micro_int = int(micro) - self.is_devel = False - except ValueError: - self.micro_int = -1 - self.is_devel = True - self.build_time = build_time - self.git_commit = git_commit - - def isDevelVersion(self): - return self.is_devel - - def versionString(self): - return "%d.%d.%s" % (self.major, self.minor, self.micro) - - def versionTuple(self): - return self.major, self.minor, self.micro - - def __cmpTuple(self): - return self.major, self.minor, self.micro_int - - def __str__(self): - return self.versionString() - - def __repr__(self): - status = 'production' - git_commit = self.getGitCommit( short = True ) - if self.is_devel: - status = 'development' - fmt = 'Version(major=%d, minor=%d, micro="%s", commit="%s", status="%s")' - return fmt % (self.major, self.minor, self.micro, git_commit, status) - - @cmp_method - def __eq__(self, other): - return self.versionTuple() == other.versionTuple() - - def __ne__(self, other): - return not (self == other) - - def __hash__(self): - return hash(self.versionTuple()) - - # All development versions are compared with micro version == -1; - # i.e. the two versions version(1,2,"Alpha") and - # ecl_version(1,2,"Beta") compare as equal in the >= and <= tests - - # but not in the == test. - - @cmp_method - def __ge__(self, other): - return self.__cmpTuple() >= other.__cmpTuple() - - @cmp_method - def __lt__(self, other): - return not (self >= other) - - @cmp_method - def __le__(self, other): - return self.__cmpTuple() <= other.__cmpTuple() - - @cmp_method - def __gt__(self, other): - return not (self <= other) - - def getBuildTime(self): - if self.build_time is None: - return "?????" - else: - return self.build_time - - def getGitCommit(self, short=False): - if self.git_commit is None: - return "???????" - else: - if short: - return self.git_commit[0:8] - else: - return self.git_commit - - -class EclVersion(Version): - _build_time = UtilPrototype("char* ecl_version_get_build_time()") - _git_commit = UtilPrototype("char* ecl_version_get_git_commit()") - _major_version = UtilPrototype("int ecl_version_get_major_version()") - _minor_version = UtilPrototype("int ecl_version_get_minor_version()") - _micro_version = UtilPrototype("char* ecl_version_get_micro_version()") - _is_devel = UtilPrototype("bool ecl_version_is_devel_version()") - - def __init__(self): - major = self._major_version( ) - minor = self._minor_version( ) - micro = self._micro_version( ) - git_commit = self._git_commit( ) - build_time = self._build_time( ) - super( EclVersion, self).__init__( major, minor , micro , git_commit, build_time) - - - diff --git a/ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt deleted file mode 100644 index b37c7f17c4..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - well_connection.py - well_connection_direction_enum.py - well_info.py - well_segment.py - well_state.py - well_time_line.py - well_type_enum.py -) - -add_python_package("python.ecl.well" ${PYTHON_INSTALL_PREFIX}/ecl/well "${PYTHON_SOURCES}" True) - diff --git a/ThirdParty/Ert/python/python/ecl/well/__init__.py b/ThirdParty/Ert/python/python/ecl/well/__init__.py deleted file mode 100644 index 8616443f30..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -import ecl -import ecl.util -import ecl.geo -import ecl.ecl - -from cwrap import Prototype - -class WellPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(WellPrototype, self).__init__(WellPrototype.lib, prototype, bind=bind) - -from .well_type_enum import WellTypeEnum -from .well_connection_direction_enum import WellConnectionDirectionEnum -from .well_connection import WellConnection -from .well_segment import WellSegment -from .well_state import WellState -from .well_time_line import WellTimeLine -from .well_info import WellInfo diff --git a/ThirdParty/Ert/python/python/ecl/well/well_connection.py b/ThirdParty/Ert/python/python/ecl/well/well_connection.py deleted file mode 100644 index 8dc86af3ac..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_connection.py +++ /dev/null @@ -1,108 +0,0 @@ -from cwrap import BaseCClass -from ecl.well import WellPrototype, WellConnectionDirectionEnum - -class WellConnection(BaseCClass): - TYPE_NAME = "well_connection" - - _i = WellPrototype("int well_conn_get_i(well_connection)") - _j = WellPrototype("int well_conn_get_j(well_connection)") - _k = WellPrototype("int well_conn_get_k(well_connection)") - _segment_id = WellPrototype("int well_conn_get_segment_id(well_connection)") - _is_open = WellPrototype("bool well_conn_open(well_connection)") - _is_msw = WellPrototype("bool well_conn_MSW(well_connection)") - _fracture_connection = WellPrototype("bool well_conn_fracture_connection(well_connection)") - _matrix_connection = WellPrototype("bool well_conn_matrix_connection(well_connection)") - _connection_factor = WellPrototype("double well_conn_get_connection_factor(well_connection)") - _equal = WellPrototype("bool well_conn_equal(well_connection, well_connection)") - _get_dir = WellPrototype("void* well_conn_get_dir(well_connection)") - _oil_rate = WellPrototype("double well_conn_get_oil_rate(well_connection)") - _gas_rate = WellPrototype("double well_conn_get_gas_rate(well_connection)") - _water_rate = WellPrototype("double well_conn_get_water_rate(well_connection)") - _volume_rate = WellPrototype("double well_conn_get_volume_rate(well_connection)") - - _oil_rate_si = WellPrototype("double well_conn_get_oil_rate_si(well_connection)") - _gas_rate_si = WellPrototype("double well_conn_get_gas_rate_si(well_connection)") - _water_rate_si = WellPrototype("double well_conn_get_water_rate_si(well_connection)") - _volume_rate_si = WellPrototype("double well_conn_get_volume_rate_si(well_connection)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly") - - - def isOpen(self): - """ @rtype: bool """ - return self._is_open() - - - def ijk(self): - """ @rtype: tuple of (int, int, int) """ - i = self._i() - j = self._j() - k = self._k() - return i, j, k - - def direction(self): - """ @rtype: WellConnectionDirectionEnum """ - return self._get_dir() - - def segmentId(self): - """ @rtype: int """ - return self._segment_id() - - def isFractureConnection(self): - """ @rtype: bool """ - return self._fracture_connection() - - def isMatrixConnection(self): - """ @rtype: bool """ - return self._matrix_connection() - - def connectionFactor(self): - """ @rtype: float """ - return self._connection_factor() - - def __eq__(self, other): - return self._equal(other) - - def __ne__(self, other): - return not self == other - - def free(self): - pass - - def isMultiSegmentWell(self): - """ @rtype: bool """ - return self._is_msw() - - def __repr__(self): - ijk = str(self.ijk()) - frac = 'fracture ' if self.isFractureConnection() else '' - open_ = 'open ' if self.isOpen() else 'shut ' - msw = ' (multi segment)' if self.isMultiSegmentWell() else '' - dir = WellConnectionDirectionEnum(self.direction()) - addr = self._address() - return 'WellConnection(%s %s%s%s, rates = (O:%s,G:%s,W:%s), direction = %s) at 0x%x' % (ijk, frac, open_, msw, self.oilRate(), self.gasRate(), self.waterRate(), dir, addr) - - def gasRate(self): - return self._gas_rate() - - def waterRate(self): - return self._water_rate() - - def oilRate(self): - return self._oil_rate() - - def volumeRate(self): - return self._volume_rate() - - def gasRateSI(self): - return self._gas_rate_si() - - def waterRateSI(self): - return self._water_rate_si() - - def oilRateSI(self): - return self._oil_rate_si() - - def volumeRateSI(self): - return self._volume_rate_si() diff --git a/ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py b/ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py deleted file mode 100644 index 084d796f94..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py +++ /dev/null @@ -1,15 +0,0 @@ -from cwrap import BaseCEnum - -class WellConnectionDirectionEnum(BaseCEnum): - TYPE_NAME = "well_connection_dir_enum" - well_conn_dirX = None - well_conn_dirY = None - well_conn_dirZ = None - well_conn_fracX = None - well_conn_fracY = None - -WellConnectionDirectionEnum.addEnum("well_conn_dirX", 1) -WellConnectionDirectionEnum.addEnum("well_conn_dirY", 2) -WellConnectionDirectionEnum.addEnum("well_conn_dirZ", 3) -WellConnectionDirectionEnum.addEnum("well_conn_fracX", 4) -WellConnectionDirectionEnum.addEnum("well_conn_fracY", 5) diff --git a/ThirdParty/Ert/python/python/ecl/well/well_info.py b/ThirdParty/Ert/python/python/ecl/well/well_info.py deleted file mode 100644 index 3ec514854c..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_info.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from os.path import isfile -from cwrap import BaseCClass -from ecl.ecl import EclGrid -from ecl.ecl.ecl_file import EclFile -from ecl.well import WellTimeLine, WellPrototype - - -class WellInfo(BaseCClass): - TYPE_NAME = "well_info" - - _alloc = WellPrototype("void* well_info_alloc(ecl_grid)", bind = False) - _free = WellPrototype("void well_info_free(well_info)") - _load_rstfile = WellPrototype("void well_info_load_rstfile(well_info, char*, bool)") - _load_rst_eclfile = WellPrototype("void well_info_load_rst_eclfile(well_info, ecl_file, bool)") - _get_well_count = WellPrototype("int well_info_get_num_wells(well_info)") - _iget_well_name = WellPrototype("char* well_info_iget_well_name(well_info, int)") - _has_well = WellPrototype("bool well_info_has_well(well_info, char*)") - _get_ts = WellPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") - - - def __init__(self, grid, rst_file=None, load_segment_information=True): - """ - @type grid: EclGrid - @type rst_file: str or EclFile or list of str or list of EclFile - """ - c_ptr = self._alloc(grid) - super(WellInfo, self).__init__(c_ptr) - if not c_ptr: - raise ValueError('Unable to construct WellInfo from grid %s.' % str(grid)) - - if rst_file is not None: - if isinstance(rst_file, list): - for item in rst_file: - self.addWellFile(item, load_segment_information) - else: - self.addWellFile(rst_file, load_segment_information) - - - def __repr__(self): - return 'WellInfo(well_count = %d) at 0x%x' % (len(self), self._address()) - - def __len__(self): - """ @rtype: int """ - return self._get_well_count( ) - - - def __getitem__(self, item): - """ - @type item: int or str - @rtype: WellTimeLine - """ - - if isinstance(item, str): - if not item in self: - raise KeyError("The well '%s' is not in this set." % item) - well_name = item - - elif isinstance(item, int): - if not 0 <= item < len(self): - raise IndexError("Index must be in range 0 <= %d < %d" % (item, len(self))) - well_name = self._iget_well_name( item ) - - return self._get_ts(well_name).setParent(self) - - def __iter__(self): - """ @rtype: iterator of WellTimeLine """ - index = 0 - - while index < len(self): - yield self[index] - index += 1 - - - def allWellNames(self): - """ @rtype: list of str """ - return [self._iget_well_name(index) for index in range(0, len(self))] - - - def __contains__(self, item): - """ - @type item: str - @rtype: bool - """ - return self._has_well( item ) - - def _assert_file_exists(self, rst_file): - if not isfile(rst_file): - raise IOError('No such file %s' % rst_file) - - def addWellFile(self, rst_file, load_segment_information): - """ @type rstfile: str or EclFile """ - if isinstance(rst_file, str): - self._assert_file_exists(rst_file) - self._load_rstfile(rst_file, load_segment_information) - elif isinstance(rst_file, EclFile): - self._load_rst_eclfile(rst_file, load_segment_information) - else: - raise TypeError("Expected the RST file to be a filename or an EclFile instance.") - - - def hasWell(self , well_name): - return well_name in self - - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/well/well_segment.py b/ThirdParty/Ert/python/python/ecl/well/well_segment.py deleted file mode 100644 index 6e7aeb2f40..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_segment.py +++ /dev/null @@ -1,76 +0,0 @@ -from cwrap import BaseCClass -from ecl.well import WellPrototype - -class WellSegment(BaseCClass): - TYPE_NAME = "well_segment" - - _active = WellPrototype("bool well_segment_active(well_segment)") - _main_stem = WellPrototype("bool well_segment_main_stem(well_segment)") - _nearest_wellhead = WellPrototype("bool well_segment_nearest_wellhead(well_segment)") - _id = WellPrototype("int well_segment_get_id(well_segment)") - _link_count = WellPrototype("int well_segment_get_link_count(well_segment)") - _branch_id = WellPrototype("int well_segment_get_branch_id(well_segment)") - _outlet_id = WellPrototype("int well_segment_get_outlet_id(well_segment)") - _depth = WellPrototype("double well_segment_get_depth(well_segment)") - _length = WellPrototype("double well_segment_get_length(well_segment)") - _total_length = WellPrototype("double well_segment_get_total_length(well_segment)") - _diameter = WellPrototype("double well_segment_get_diameter(well_segment)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly") - - def free(self): - pass - - def __repr__(self): - return 'WellSegment(%s) at 0x%x' % (str(self), self._address()) - - def __str__(self): - return "{Segment ID:%d BranchID:%d Length:%g}" % (self.id() , self.branchId() , self.length()) - - def id(self): - """ @rtype: int """ - return self._id() - - def linkCount(self): - """ @rtype: int """ - return self._link_count() - - def branchId(self): - """ @rtype: int """ - return self._branch_id() - - def outletId(self): - """ @rtype: int """ - return self._outlet_id() - - def isActive(self): - """ @rtype: bool """ - return self._active() - - def isMainStem(self): - """ @rtype: bool """ - return self._main_stem() - - def isNearestWellHead(self): - """ @rtype: bool """ - return self._nearest_wellhead() - - def depth(self): - """ @rtype: float """ - return self._depth() - - def __len__(self): - return self.length() - - def length(self): - """ @rtype: float """ - return self._length() - - def totalLength(self): - """ @rtype: float """ - return self._total_length() - - def diameter(self): - """ @rtype: float """ - return self._diameter() diff --git a/ThirdParty/Ert/python/python/ecl/well/well_state.py b/ThirdParty/Ert/python/python/ecl/well/well_state.py deleted file mode 100644 index 6d0cadf567..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_state.py +++ /dev/null @@ -1,164 +0,0 @@ -from cwrap import BaseCClass -from ecl.well import WellTypeEnum, WellConnection, WellPrototype -from ecl.util import CTime - -class WellState(BaseCClass): - TYPE_NAME = "well_state" - - _global_connections_size = WellPrototype("int well_conn_collection_get_size(void*)", bind = False) - _global_connections_iget = WellPrototype("well_connection_ref well_conn_collection_iget(void*, int)", bind = False) - _segment_collection_size = WellPrototype("int well_segment_collection_get_size(void*)", bind = False) - _segment_collection_iget = WellPrototype("well_segment_ref well_segment_collection_iget(void*, int)", bind = False) - _has_global_connections = WellPrototype("bool well_state_has_global_connections(well_state)") - _get_global_connections = WellPrototype("void* well_state_get_global_connections(well_state)") - _get_segment_collection = WellPrototype("void* well_state_get_segments(well_state)") - _branches = WellPrototype("void* well_state_get_branches(well_state)") - _segments = WellPrototype("void* well_state_get_segments(well_state)") - _get_name = WellPrototype("char* well_state_get_name(well_state)") - _is_open = WellPrototype("bool well_state_is_open(well_state)") - _is_msw = WellPrototype("bool well_state_is_MSW(well_state)") - _well_number = WellPrototype("int well_state_get_well_nr(well_state)") - _report_number = WellPrototype("int well_state_get_report_nr(well_state)") - _has_segment_data = WellPrototype("bool well_state_has_segment_data(well_state)") - _sim_time = WellPrototype("time_t well_state_get_sim_time(well_state)") - _well_type = WellPrototype("well_type_enum well_state_get_type(well_state)") - _oil_rate = WellPrototype("double well_state_get_oil_rate(well_state)") - _gas_rate = WellPrototype("double well_state_get_gas_rate(well_state)") - _water_rate = WellPrototype("double well_state_get_water_rate(well_state)") - _volume_rate = WellPrototype("double well_state_get_volume_rate(well_state)") - _oil_rate_si = WellPrototype("double well_state_get_oil_rate_si(well_state)") - _gas_rate_si = WellPrototype("double well_state_get_gas_rate_si(well_state)") - _water_rate_si = WellPrototype("double well_state_get_water_rate_si(well_state)") - _volume_rate_si = WellPrototype("double well_state_get_volume_rate_si(well_state)") - _get_global_well_head = WellPrototype("well_connection_ref well_state_get_global_wellhead(well_state)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly") - - def name(self): - """ @rtype: str """ - return self._get_name( ) - - def isOpen(self): - """ @rtype: bool """ - return self._is_open( ) - - def free(self): - pass - - def wellHead(self): - well_head = self._get_global_well_head() - well_head.setParent( self ) - return well_head - - def wellNumber(self): - """ @rtype: int """ - return self._well_number( ) - - def reportNumber(self): - """ @rtype: int """ - return self._report_number( ) - - def simulationTime(self): - """ @rtype: CTime """ - return self._sim_time( ) - - def wellType(self): - """ @rtype: WellTypeEnum """ - return self._well_type( ) - - def hasGlobalConnections(self): - """ @rtype: bool """ - return self._has_global_connections( ) - - def globalConnections(self): - """ @rtype: list of WellConnection """ - global_connections = self._get_global_connections( ) - count = self._global_connections_size( global_connections ) - - values = [] - for index in range(count): - value = self._global_connections_iget(global_connections, index).setParent( self ) - values.append(value) - return values - - def __len__(self): - return self.numSegments() - - def __getitem__(self, idx): - return self.igetSegment(idx) - - def numSegments(self): - """ @rtype: int """ - segment_collection = self._get_segment_collection( ) - count = self._segment_collection_size(segment_collection) - return count - - - def segments(self): - """ @rtype: list of WellSegment """ - segment_collection = self._get_segment_collection( ) - - values = [] - for index in range(self.numSegments()): - value = self._segment_collection_iget(segment_collection, index).setParent(self) - values.append(value) - - return values - - - def igetSegment(self , seg_idx): - """ @rtype: WellSegment """ - if seg_idx < 0: - seg_idx += len(self) - - if not 0 <= seg_idx < self.numSegments(): - raise IndexError("Invalid index:%d - valid range [0,%d)" % (seg_idx , len(self))) - - segment_collection = self._get_segment_collection( ) - return self._segment_collection_iget(segment_collection, seg_idx).setParent(self) - - def isMultiSegmentWell(self): - """ @rtype: bool """ - return self._is_msw( ) - - def hasSegmentData(self): - """ @rtype: bool """ - return self._has_segment_data( ) - - def __repr__(self): - name = self.name() - if name: - name = '%s' % name - else: - name = '[no name]' - msw = ' (multi segment)' if self.isMultiSegmentWell() else '' - wn = str(self.wellNumber()) - type_ = self.wellType() - open_ = 'open' if self.isOpen() else 'shut' - cnt = '%s%s, number = %s, type = "%s", state = %s' % (name, msw, wn, type_, open_) - return self._create_repr(cnt) - - def gasRate(self): - return self._gas_rate( ) - - def waterRate(self): - return self._water_rate( ) - - def oilRate(self): - return self._oil_rate( ) - - def volumeRate(self): - return self._volume_rate( ) - - def gasRateSI(self): - return self._gas_rate_si( ) - - def waterRateSI(self): - return self._water_rate_si( ) - - def oilRateSI(self): - return self._oil_rate_si( ) - - def volumeRateSI(self): - return self._volume_rate_si( ) diff --git a/ThirdParty/Ert/python/python/ecl/well/well_time_line.py b/ThirdParty/Ert/python/python/ecl/well/well_time_line.py deleted file mode 100644 index bc42a20e82..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_time_line.py +++ /dev/null @@ -1,42 +0,0 @@ -from cwrap import BaseCClass -from ecl.well import WellState, WellPrototype - -class WellTimeLine(BaseCClass): - TYPE_NAME = "well_time_line" - _size = WellPrototype("int well_ts_get_size(well_time_line)") - _name = WellPrototype("char* well_ts_get_name(well_time_line)") - _iget = WellPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly") - - def getName(self): - return self._name() - - def __len__(self): - """ @rtype: int """ - return self._size() - - - def __getitem__(self, index): - """ - @type index: int - @rtype: WellState - """ - - if index < 0: - index += len(self) - - if not 0 <= index < len(self): - raise IndexError("Index must be in range 0 <= %d < %d" % (index, len(self))) - - return self._iget(index).setParent(self) - - def free(self): - pass - - def __repr__(self): - n = self.getName() - l = len(self) - cnt = 'name = %s, size = %d' % (n,l) - return self._create_repr(cnt) diff --git a/ThirdParty/Ert/python/python/ecl/well/well_type_enum.py b/ThirdParty/Ert/python/python/ecl/well/well_type_enum.py deleted file mode 100644 index f44e01fd22..0000000000 --- a/ThirdParty/Ert/python/python/ecl/well/well_type_enum.py +++ /dev/null @@ -1,16 +0,0 @@ -from cwrap import BaseCEnum - -class WellTypeEnum(BaseCEnum): - TYPE_NAME = "well_type_enum" - ECL_WELL_ZERO = None - ECL_WELL_PRODUCER = None - ECL_WELL_WATER_INJECTOR = None - ECL_WELL_GAS_INJECTOR = None - ECL_WELL_OIL_INJECTOR = None - -WellTypeEnum.addEnum("ECL_WELL_ZERO", 0) -WellTypeEnum.addEnum("ECL_WELL_PRODUCER", 1) -WellTypeEnum.addEnum("ECL_WELL_OIL_INJECTOR", 2) -WellTypeEnum.addEnum("ECL_WELL_WATER_INJECTOR", 3) -WellTypeEnum.addEnum("ECL_WELL_GAS_INJECTOR", 4) - diff --git a/ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt b/ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt deleted file mode 100644 index dc308b5229..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ecl/__init__.py - ecl/faults/__init__.py - geo/__init__.py - well/__init__.py - util/__init__.py - test/__init__.py -) -add_python_package("python.ert" ${PYTHON_INSTALL_PREFIX}/ert "${PYTHON_SOURCES}" True) - diff --git a/ThirdParty/Ert/python/python/legacy/ert/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py deleted file mode 100644 index bdc9ad8458..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -from ecl.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil -from ecl.ecl import EclTypeEnum, EclDataType -from ecl.ecl import EclSumVarType -from ecl.ecl import EclSumTStep -from ecl.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode -from ecl.ecl import EclSumKeyWordVector -from ecl.ecl import EclPLTCell, EclRFTCell -from ecl.ecl import EclRFT, EclRFTFile -from ecl.ecl import FortIO, openFortIO -from ecl.ecl import EclKW -from ecl.ecl import Ecl3DKW -from ecl.ecl import EclFileView -from ecl.ecl import EclFile , openEclFile -from ecl.ecl import Ecl3DFile -from ecl.ecl import EclInitFile -from ecl.ecl import EclRestartFile -from ecl.ecl import EclGrid -from ecl.ecl import EclRegion -from ecl.ecl import EclSubsidence -from ecl.ecl import phase_deltag, deltag -from ecl.ecl import EclGrav -from ecl.ecl import EclSumNode -from ecl.ecl import EclSumVector -from ecl.ecl import EclNPV , NPVPriceVector -from ecl.ecl import EclCmp -from ecl.ecl import EclGridGenerator diff --git a/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py deleted file mode 100644 index 2d336c1fd6..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from ecl.ecl.faults import Layer -from ecl.ecl.faults import FaultCollection -from ecl.ecl.faults import Fault -from ecl.ecl.faults import FaultLine -from ecl.ecl.faults import FaultSegment , SegmentMap -from ecl.ecl.faults import FaultBlock , FaultBlockCell -from ecl.ecl.faults import FaultBlockLayer diff --git a/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py deleted file mode 100644 index 67f4193aa3..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from ecl.geo import GeoPointset -from ecl.geo import GeoRegion -from ecl.geo import CPolyline -from ecl.geo import CPolylineCollection -from ecl.geo import Polyline -from ecl.geo import XYZIo -from ecl.geo import GeometryTools -from ecl.geo import Surface diff --git a/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py deleted file mode 100644 index 912a43a595..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from ecl.test import TestRun -from ecl.test import path_exists -from ecl.test import ExtendedTestCase -from ecl.test import SourceEnumerator -from ecl.test import TestArea , TestAreaContext -from ecl.test import TempArea , TempAreaContext -from ecl.test import ErtTestRunner -from ecl.test import PathContext -from ecl.test import LintTestCase -from ecl.test import ImportTestCase diff --git a/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py deleted file mode 100644 index 926907fc6a..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -from ecl.util import Version -from ecl.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum -from ecl.util import CTime -from ecl.util import PermutationVector -from ecl.util import VectorTemplate -from ecl.util import DoubleVector -from ecl.util import IntVector -from ecl.util import BoolVector -from ecl.util import TimeVector -from ecl.util import StringList -from ecl.util import RandomNumberGenerator -from ecl.util import Matrix -from ecl.util import quantile, quantile_sorted, polyfit -from ecl.util import Log -from ecl.util import LookupTable -from ecl.util import Buffer -from ecl.util import Hash, StringHash, DoubleHash, IntegerHash -from ecl.util import UIReturn -from ecl.util import ThreadPool -from ecl.util import CThreadPool, startCThreadPool -from ecl.util import installAbortSignals, updateAbortSignals -from ecl.util import Profiler -from ecl.util import ArgPack -from ecl.util import PathFormat - -try: - from res.util import SubstitutionList -except ImportError: - pass \ No newline at end of file diff --git a/ThirdParty/Ert/python/python/legacy/ert/well/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/well/__init__.py deleted file mode 100644 index 5a699e5689..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/well/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from ecl.well import WellTypeEnum -from ecl.well import WellConnectionDirectionEnum -from ecl.well import WellConnection -from ecl.well import WellSegment -from ecl.well import WellState -from ecl.well import WellTimeLine -from ecl.well import WellInfo diff --git a/ThirdParty/Ert/python/python/test_env.py.in b/ThirdParty/Ert/python/python/test_env.py.in deleted file mode 100644 index 9fd11ea156..0000000000 --- a/ThirdParty/Ert/python/python/test_env.py.in +++ /dev/null @@ -1,6 +0,0 @@ -import os - -TESTDATA_ROOT = os.getenv("ERT_TEST_ROOT_PATH") or "${PROJECT_SOURCE_DIR}/test-data" -SOURCE_ROOT = "${PROJECT_SOURCE_DIR}" -BUILD_ROOT = "${PROJECT_BINARY_DIR}" - diff --git a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py index fbd1e6c178..c265382c00 100644 --- a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py +++ b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py @@ -39,7 +39,7 @@ def fgpt(days): def create_case(num_mini_step = 10, case = "CSV"): length = 100 - return createEclSum(case, [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], + return createEclSum(case, [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("FGPT" , None , 0, "SM3")], sim_length_days = length, num_report_step = 10, num_mini_step = num_mini_step, diff --git a/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt b/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt deleted file mode 100644 index 56200ef2d9..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_basecclass.py - test_basecenum.py - test_basecvalue.py - test_metawrap.py - test_cfile.py -) - -add_python_package("python.tests.cwrap" ${PYTHON_INSTALL_PREFIX}/tests/cwrap "${TEST_SOURCES}" False) - -addPythonTest(tests.cwrap.test_basecclass.BaseCClassTest) -addPythonTest(tests.cwrap.test_basecenum.BaseCEnumTest) -addPythonTest(tests.cwrap.test_basecvalue.BaseCValueTest) -addPythonTest(tests.cwrap.test_metawrap.MetaWrapTest) -addPythonTest(tests.cwrap.test_cfile.CFILETest) - diff --git a/ThirdParty/Ert/python/tests/cwrap/__init__.py b/ThirdParty/Ert/python/tests/cwrap/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py b/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py deleted file mode 100644 index f2925d67b6..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py +++ /dev/null @@ -1,19 +0,0 @@ -from cwrap import BaseCClass -from ecl.test import ExtendedTestCase - - -class BaseCClassTest(ExtendedTestCase): - - def test_none_assertion(self): - self.assertFalse(None > 0) - - def test_creation(self): - with self.assertRaises(ValueError): - obj = BaseCClass(0) - - - obj = BaseCClass( 10 ) - self.assertTrue( obj ) - - obj._invalidateCPointer( ) - self.assertFalse( obj ) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py b/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py deleted file mode 100644 index b5f44efa95..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py +++ /dev/null @@ -1,91 +0,0 @@ -from cwrap import BaseCEnum -from ecl.test import ExtendedTestCase - - - -class BaseCEnumTest(ExtendedTestCase): - def test_base_c_enum(self): - class enum(BaseCEnum): - pass - - enum.addEnum("ONE", 1) - enum.addEnum("TWO", 2) - enum.addEnum("THREE", 3) - enum.addEnum("FOUR", 4) - - class enum2(BaseCEnum): - pass - - enum2.addEnum("ONE", 1) - enum2.addEnum("TWO", 4) - - self.assertEqual(enum.ONE, 1) - self.assertEqual(enum.TWO, 2) - self.assertEqual(enum.FOUR, 4) - - self.assertListEqual(enum.enums(), [enum.ONE, enum.TWO, enum.THREE, enum.FOUR]) - - self.assertEqual(enum(4), enum.FOUR) - - self.assertNotEqual(enum2(4), enum.FOUR) - self.assertEqual(enum2(4), enum2.TWO) - - self.assertEqual(str(enum.ONE), "ONE") - - - self.assertEqual(enum.ONE + enum.TWO, enum.THREE) - self.assertEqual(enum.ONE + enum.FOUR, 5) - - with self.assertRaises(ValueError): - e = enum(5) - - - self.assertEqual(enum.THREE & enum.ONE, enum.ONE) - self.assertEqual(enum.ONE | enum.TWO, enum.THREE) - self.assertEqual(enum.THREE ^ enum.TWO, enum.ONE) - - - with self.assertRaises(AssertionError): - e = enum.ONE + enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE & enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE | enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE ^ enum2.ONE - - - def test_in_operator(self): - class PowerOf2(BaseCEnum): - pass - - PowerOf2.addEnum("ONE", 1) - PowerOf2.addEnum("TWO", 2) - PowerOf2.addEnum("FOUR", 4) - - three = PowerOf2.ONE | PowerOf2.TWO - - self.assertEqual(int(three), 3) - - self.assertIn(PowerOf2.TWO, three) - self.assertIn(PowerOf2.ONE, three) - self.assertNotIn(PowerOf2.FOUR, three) - - def test_repr_and_str(self): - class MyLonelyEnum(BaseCEnum): - pass - - MyLonelyEnum.addEnum("ONE", 1) - MyLonelyEnum.addEnum("TWO", 2) - MyLonelyEnum.addEnum("THREE", 3) - MyLonelyEnum.addEnum("FOUR", 4) - - tri = MyLonelyEnum.THREE - - self.assertEqual(repr(tri), 'MyLonelyEnum(name = "THREE", value = 3)') - self.assertEqual(str(tri), 'THREE') - self.assertEqual(tri.name, 'THREE') - self.assertEqual(tri.value, 3) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py b/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py deleted file mode 100644 index 4066333221..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py +++ /dev/null @@ -1,71 +0,0 @@ -import ecl -from ctypes import c_ubyte, c_double -from cwrap import BaseCValue, Prototype -from ecl.test import ExtendedTestCase - -class TestPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype): - super(TestPrototype, self).__init__(self.lib, prototype) - -class UnsignedByteValue(BaseCValue): - DATA_TYPE = c_ubyte - - -class MaxDouble(BaseCValue): - TYPE_NAME = "pow_double" - DATA_TYPE = c_double - - -class BaseCValueTest(ExtendedTestCase): - def setUp(self): - self.double_max = TestPrototype("pow_double util_double_max(double, double)") - - - def test_illegal_type(self): - class ExceptionValueTest(BaseCValue): - DATA_TYPE = str - def __init__(self, value): - super(ExceptionValueTest, self).__init__(value) - - with self.assertRaises(ValueError): - test = ExceptionValueTest("Failure") - - - class NoDataTypeTest(BaseCValue): - def __init__(self, value): - super(NoDataTypeTest, self).__init__(value) - - with self.assertRaises(ValueError): - test = ExceptionValueTest(0) - - - def test_creation(self): - test_value = UnsignedByteValue(255) - - self.assertEqual(test_value.value(), 255) - - test_value.setValue(256) - self.assertEqual(test_value.value(), 0) - - self.assertEqual(test_value.type(), c_ubyte) - - - def test_from_param(self): - test_value = UnsignedByteValue(127) - - self.assertEqual(UnsignedByteValue.from_param(test_value).value, 127) - - with self.assertRaises(AttributeError): - UnsignedByteValue.from_param(None) - - with self.assertRaises(ValueError): - UnsignedByteValue.from_param("exception") - - - def test_double_max(self): - double_max = self.double_max(2.97, 2.98) - - self.assertIsInstance(double_max, MaxDouble) - self.assertEqual(double_max.value(), 2.98) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_cfile.py b/ThirdParty/Ert/python/tests/cwrap/test_cfile.py deleted file mode 100644 index 1df29bfe8c..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_cfile.py +++ /dev/null @@ -1,31 +0,0 @@ -import ecl -from cwrap import Prototype, CFILE -from ecl.test.extended_testcase import ExtendedTestCase -from ecl.test.test_area import TestAreaContext - - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -fileno = TestUtilPrototype("int fileno(FILE)") - - -class CFILETest(ExtendedTestCase): - - def test_cfile(self): - with TestAreaContext("cfile_tests") as test_area: - - with open("test", "w") as f: - f.write("some content") - - with open("test", "r") as f: - cfile = CFILE(f) - - self.assertEqual(fileno(cfile), f.fileno()) - - def test_cfile_error(self): - with self.assertRaises(TypeError): - cfile = CFILE("some text") diff --git a/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py b/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py deleted file mode 100644 index e82db53d6d..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py +++ /dev/null @@ -1,122 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -from six import string_types -import ctypes - -import ecl -from cwrap import BaseCClass, Prototype, PrototypeError -from ecl.test import ExtendedTestCase - - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -class BoundTestUtilPrototype(TestUtilPrototype): - def __init__(self, prototype): - super(BoundTestUtilPrototype, self).__init__(prototype, bind=True) - - -class StringList(BaseCClass): - TYPE_NAME = "test_stringlist" - - __len__ = BoundTestUtilPrototype("int stringlist_get_size(test_stringlist)") - free = BoundTestUtilPrototype("void stringlist_free(test_stringlist)") - - _alloc = TestUtilPrototype("void* stringlist_alloc_new()", bind = False) - _iget = TestUtilPrototype("char* stringlist_iget(test_stringlist, int)") - _append = TestUtilPrototype("void stringlist_append_copy(test_stringlist, char*)") - - def __init__(self, initial=None): - c_ptr = self._alloc() - super(StringList, self).__init__(c_ptr) - - if initial: - for s in initial: - if isinstance(s, bytes): - s.decode('ascii') - if isinstance(s, string_types): - self.append(s) - else: - raise TypeError("Item: %s not a string" % s) - - def __getitem__(self, index): - if isinstance(index, int): - length = len(self) - if index < 0: - index += length - if index < 0 or index >= length: - raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) - else: - return self._iget(self, index) - else: - raise TypeError("Index should be integer type") - - def append(self, string): - if isinstance(string, bytes): - s.decode('ascii') - if isinstance(string, string_types): - self._append(self, string) - else: - self._append(self, str(string)) - - - -class MetaWrapTest(ExtendedTestCase): - - def test_stringlist_wrap(self): - items = ["A", "C", "E"] - stringlist = StringList(items) - self.assertEqual(len(stringlist), len(items)) - - self.assertIn("free", StringList.__dict__) - self.assertEqual(StringList.free.__name__, "stringlist_free") - - for index, item in enumerate(items): - self.assertEqual(item, stringlist[index]) - - - def test_already_registered(self): - with self.assertRaises(PrototypeError): - Prototype.registerType("test_stringlist", None) - - def test_error_in_prototype_illegal_return_type(self): - func = TestUtilPrototype("test_stringlist util_alloc_date_stamp_utc()") - - with self.assertRaises(PrototypeError): - func() - - def test_prototype_known_return_type(self): - stringlist = StringList(["B", "D", "F"]) - func = TestUtilPrototype("test_stringlist_ref stringlist_alloc_shallow_copy(stringlist)") - result = func(stringlist) - self.assertIsInstance(result, StringList) - - for index, value in enumerate(stringlist): - self.assertEqual(result[index], value) - - - def test_invalid_function(self): - func = TestUtilPrototype("void stringlist_missing_function()") - with self.assertRaises(PrototypeError): - func() - - - def test_invalid_prototype(self): - func = TestUtilPrototype("void util_alloc_date_stamp_utc(") - with self.assertRaises(PrototypeError): - func() - - - def test_function_type(self): - def stringObj(c_ptr): - char_ptr = ctypes.c_char_p(c_ptr) - python_string = char_ptr.value - return python_string.decode('ascii') - - Prototype.registerType("string_obj", stringObj) - - dateStamp = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()") - date_stamp = dateStamp() - self.assertIsInstance(date_stamp, string_types) diff --git a/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt deleted file mode 100644 index 5eb3c91721..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -set(NFS_RUNPATH "" CACHE STRING "Disk area which is shared among cluster nodes and can be used as CWD for LSF/RSH jobs.") -set(RSH_SERVERS "" CACHE STRING "List of nodes which will be used to test the RSH driver") - -set(TEST_SOURCES - __init__.py - test_deprecation.py - test_removed.py - test_ecl_3dkw.py - test_ecl_file_statoil.py - test_ecl_file.py - test_ecl_init_file.py - test_ecl_restart_file.py - test_debug.py - test_ecl_sum.py - test_ecl_sum_vector.py - test_fault_blocks.py - test_fault_blocks_statoil.py - test_faults.py - test_fortio.py - test_grdecl.py - test_grid.py - test_cell.py - test_grid_statoil.py - test_grid_generator.py - test_indexed_read.py - test_ecl_kw_statoil.py - test_ecl_kw.py - test_kw_function.py - test_layer.py - test_npv.py - test_region.py - test_region_statoil.py - test_restart.py - test_rft.py - test_rft_statoil.py - test_rft_cell.py - test_statoil_faults.py - test_sum_statoil.py - test_ecl_util.py - test_ecl_cmp.py - test_sum.py - test_grav.py - test_geertsma.py - test_ecl_type.py - test_restart_head.py - test_fk_user_data.py -) - -add_python_package("python.tests.ecl" ${PYTHON_INSTALL_PREFIX}/tests/ecl "${TEST_SOURCES}" False) - -addPythonTest(tests.ecl.test_fk_user_data.FKTest) -addPythonTest(tests.ecl.test_cell.CellTest) -addPythonTest(tests.ecl.test_grid.GridTest LABELS SLOW_1) -addPythonTest(tests.ecl.test_grid_generator.GridGeneratorTest LABELS SLOW_2) -addPythonTest(tests.ecl.test_ecl_kw.KWTest LABELS SLOW_2) -addPythonTest(tests.ecl.test_kw_function.KWFunctionTest) -addPythonTest(tests.ecl.test_ecl_3dkw.Ecl3DKWTest ) -addPythonTest(tests.ecl.test_rft.RFTTest) -addPythonTest(tests.ecl.test_rft_cell.RFTCellTest) -addPythonTest(tests.ecl.test_sum.SumTest) -addPythonTest(tests.ecl.test_layer.LayerTest ) -addPythonTest(tests.ecl.test_faults.FaultTest ) -addPythonTest(tests.ecl.test_fault_blocks.FaultBlockTest ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_1_9_Test ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_2_0_Test ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_2_1_Test ) -addPythonTest(tests.ecl.test_removed.Removed_2_1_Test ) -addPythonTest(tests.ecl.test_ecl_util.EclUtilTest ) -addPythonTest(tests.ecl.test_fortio.FortIOTest) -addPythonTest(tests.ecl.test_ecl_file.EclFileTest) -addPythonTest(tests.ecl.test_grav.EclGravTest) -addPythonTest(tests.ecl.test_geertsma.GeertsmaTest) -addPythonTest(tests.ecl.test_ecl_type.EclDataTypeTest) -addPythonTest(tests.ecl.test_region.RegionTest) -addPythonTest(tests.ecl.test_debug.DebugTest) - - -if (STATOIL_TESTDATA_ROOT) - addPythonTest(tests.ecl.test_ecl_file_statoil.EclFileStatoilTest LABELS StatoilData) - addPythonTest(tests.ecl.test_grdecl.GRDECLTest LABELS StatoilData) - addPythonTest(tests.ecl.test_grid_statoil.GridTest LABELS StatoilData:Slow) - addPythonTest(tests.ecl.test_ecl_kw_statoil.KWTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_init_file.InitFileTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_restart_file.RestartFileTest LABELS StatoilData) - addPythonTest(tests.ecl.test_restart.RestartTest LABELS StatoilData ) - addPythonTest(tests.ecl.test_region_statoil.RegionTest LABELS StatoilData) - addPythonTest(tests.ecl.test_rft_statoil.RFTTest LABELS StatoilData) - addPythonTest(tests.ecl.test_sum_statoil.SumTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_sum_vector.EclSumVectorTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_sum.EclSumTest LABELS StatoilData) - addPythonTest(tests.ecl.test_statoil_faults.StatoilFaultTest LABELS StatoilData) - addPythonTest(tests.ecl.test_fault_blocks_statoil.FaultBlockTest LABELS StatoilData) - addPythonTest(tests.ecl.test_npv.NPVTest LABELS StatoilData) - addPythonTest(tests.ecl.test_indexed_read.EclIndexedReadTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_cmp.EclCmpTest LABELS StatoilData) - addPythonTest(tests.ecl.test_restart_head.RestartHeadTest LABELS StatoilData) -endif() diff --git a/ThirdParty/Ert/python/tests/ecl/__init__.py b/ThirdParty/Ert/python/tests/ecl/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/ecl/test_cell.py b/ThirdParty/Ert/python/tests/ecl/test_cell.py deleted file mode 100644 index 1764b7fe7c..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_cell.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.ecl import Cell, EclGrid -from ecl.test import ExtendedTestCase - -class CellTest(ExtendedTestCase): - - def setUp(self): - fk = self.createTestPath('local/ECLIPSE/faarikaal/faarikaal1.EGRID') - self.grid = EclGrid(fk) - self.cell = self.grid[3455] - self.actives = [c for c in self.grid if c.active] - - def test_init(self): - cell = self.grid[0] - self.assertEqual(0, cell.global_index) - - def test_actives(self): - self.assertEqual(4160, len(self.actives)) - - def test_volumes(self): - actives = self.actives - vols = [c.volume for c in actives] - vmin, vmax = min(vols), max(vols) - self.assertFloatEqual(vmin, 1332.328921) - self.assertFloatEqual(vmax, 10104.83204) - self.assertFloatEqual(actives[2000].dz, 1.68506) - - act_dim = (48.5676, 54.1515, 1.685) # cell dimension in meter - cel_dim = self.cell.dimension - self.assertEqual(3, len(cel_dim)) - for d in range(2): - self.assertFloatEqual(act_dim[d], cel_dim[d]) - - def test_indices(self): - c = self.cell - self.assertEqual(3455, c.global_index) - self.assertEqual(2000, c.active_index) - self.assertEqual((4,1,82), c.ijk) - self.assertEqual(c.ijk, (c.i, c.j, c.k)) - - def test_coordinates(self): - c = self.cell - corners = c.corners - self.assertEqual(8, len(corners)) - se0 = corners[5] # upper south east - se0_act = (606900.002, 5202050.07, 5149.26) - for i in range(3): - self.assertFloatEqual(se0[i], se0_act[i]) - - coordinate = c.coordinate - coor_act = (606866.883, 5202064.939, 5154.52) - - for i in range(3): - self.assertFloatEqual(coordinate[i], coor_act[i]) - - xyz = c.coordinate - self.assertIn(xyz, c) - - def test_eq(self): - c1 = self.cell - c2 = self.grid[4,1,82] - c3 = self.grid[1,1,82] - self.assertEqual(c1,c2) - self.assertEqual(c2,c1) - self.assertNotEqual(c1, 'notacell') - self.assertNotEqual(c1,c3) - self.assertNotEqual(c3,c1) - - def test_getitem_3(self): - c = self.cell - d = self.grid[4,1,82] - self.assertEqual(c, d) - - def test_validity(self): - self.assertTrue(self.cell.valid_geometry) - self.assertTrue(self.cell.valid) - - def test_repr(self): - c = self.cell - r = repr(c) - self.assertTrue(r.startswith('Cell(4, 1, 82, active, ')) - self.assertIn('faarikaal1.EGRID', r) diff --git a/ThirdParty/Ert/python/tests/ecl/test_debug.py b/ThirdParty/Ert/python/tests/ecl/test_debug.py deleted file mode 100644 index 344527d34a..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_debug.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'test_debug.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.test import debug_msg, ExtendedTestCase - -class DebugTest(ExtendedTestCase): - - def test_create(self): - msg = debug_msg( "DEBUG" ) - self.assertIn( __file__[:-1] , msg ) - self.assertIn( "DEBUG" , msg ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_deprecation.py b/ThirdParty/Ert/python/tests/ecl/test_deprecation.py deleted file mode 100644 index cd818abc5e..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_deprecation.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_deprecation.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import warnings -import time -import datetime - -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.ecl import EclFile, EclGrid, EclKW, EclDataType, EclGrid, EclRegion -from ecl.ecl import FortIO, openFortIO, EclRFT, EclGridGenerator -from ecl.test.ecl_mock import createEclSum -from ecl.util import BoolVector - -# The class Deprecation_1_9_Test contains methods which will be marked -# as deprecated in the 1.9.x versions. - -warnings.simplefilter("error" , DeprecationWarning) - -class Deprecation_2_1_Test(ExtendedTestCase): - pass - -class Deprecation_2_0_Test(ExtendedTestCase): - - def test_EclFile_name_property(self): - with TestAreaContext("name") as t: - kw = EclKW("TEST", 3, EclDataType.ECL_INT) - with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: - kw.fwrite( f ) - - t.sync() - f = EclFile( "TEST" ) - -class Deprecation_1_9_Test(ExtendedTestCase): - - def test_EclRegion_properties(self): - grid = EclGridGenerator.createRectangular( (10,10,10) , (1,1,1)) - region = EclRegion( grid , False ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py deleted file mode 100644 index f6bdabb0c3..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os -import random - -from ecl.util import IntVector -from ecl.ecl import Ecl3DKW , EclKW, EclDataType, EclFile, FortIO, EclFileFlagEnum , EclGrid -from ecl.test import ExtendedTestCase , TestAreaContext - - - -class Ecl3DKWTest(ExtendedTestCase): - - def test_create( self ): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(100): - actnum[i] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT ) - self.assertEqual( len(kw) , grid.getNumActive()) - - self.assertEqual( (10,10,10) , kw.dims() ) - - - def test_create_global_size( self ): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(100): - actnum[i] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , global_active = True) - self.assertEqual( len(kw) , grid.getGlobalSize()) - - kw.assign(50) - self.assertEqual( kw[0,0,0] , 50 ) - - kw[0,0,0] = 45 - self.assertEqual( kw[0,0,0] , 45 ) - - - def test_fix_uninitialized(self): - nx = 10 - ny = 11 - nz = 12 - grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) - kw = Ecl3DKW("REGIONS" , grid , EclDataType.ECL_INT , global_active = True) - kw.assign(3) - self.assertEqual( 3 * nx*ny*nz , sum(kw)) - - kw[1,1,1] = 0 - kw[3,3,3] = 0 - kw[6,6,6] = 0 - - self.assertEqual( 3 * nx*ny*nz - 9 , sum(kw)) - kw.fixUninitialized( grid ) - self.assertEqual( 3 * nx*ny*nz , sum(kw)) - - - - def test_getitem( self ): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(100): - actnum[i] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77) - - with self.assertRaises(IndexError): - kw[1000] - - with self.assertRaises(IndexError): - kw[0,10,100] - - with self.assertRaises(ValueError): - kw[1,1] - - with self.assertRaises(ValueError): - kw[1,1,1,1] - - kw.assign(99) - - self.assertEqual( kw[0,0,0] , 77 ) - self.assertEqual( kw[0,0,1] , 99 ) - - - - def test_setitem( self ): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(100): - actnum[i] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT , default_value = 77) - - with self.assertRaises(IndexError): - kw[1000] - - with self.assertRaises(IndexError): - kw[0,10,100] - - with self.assertRaises(ValueError): - kw[1,1] - - with self.assertRaises(ValueError): - kw[1,1,1,1] - - kw.assign(99) - self.assertEqual( kw[0,0,0] , 77 ) - self.assertEqual( kw[0,0,1] , 99 ) - - - with self.assertRaises(ValueError): - kw[0,0,0] = 88 - - kw[0,0,1] = 100 - self.assertEqual( kw[0,0,1] , 100 ) - - - - def test_cast(self): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(100): - actnum[i] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw_wrong_size = EclKW( "KW" , 27 , EclDataType.ECL_FLOAT ) - kw_global_size = EclKW( "KW" , grid.getGlobalSize() , EclDataType.ECL_FLOAT ) - kw_active_size = EclKW( "KW" , grid.getNumActive() , EclDataType.ECL_FLOAT ) - - with self.assertRaises(ValueError): - Ecl3DKW.castFromKW(kw_wrong_size , grid) - - Ecl3DKW.castFromKW(kw_global_size , grid) - self.assertTrue( isinstance( kw_global_size , Ecl3DKW)) - - Ecl3DKW.castFromKW(kw_active_size , grid , default_value = 66) - self.assertTrue( isinstance( kw_active_size , Ecl3DKW)) - - self.assertEqual( kw_active_size[0,0,0] , 66) - with self.assertRaises(ValueError): - kw_active_size[0,0,0] = 88 - - - def test_default(self): - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1)) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_FLOAT ) - kw.setDefault(55) - self.assertTrue( 55 , kw.getDefault()) - - - def test_compressed_copy(self): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(500): - actnum[2*i + 1] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_INT , global_active = True) - for i in range(len(kw)): - kw[i] = i - - kw_copy = kw.compressedCopy() - self.assertTrue( isinstance( kw_copy , EclKW ) ) - - self.assertEqual(len(kw_copy) , 500) - for i in range(len(kw_copy)): - self.assertEqual(kw_copy[i] , 2*i) - - - - def test_global_copy(self): - actnum = IntVector(default_value = 1 , initial_size = 1000) - for i in range(500): - actnum[2*i + 1] = 0 - - grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) - kw = Ecl3DKW( "KW" , grid , EclDataType.ECL_INT , global_active = False) - for i in range(len(kw)): - kw[i] = i - - kw.setDefault( 177 ) - kw_copy = kw.globalCopy() - self.assertTrue( isinstance( kw_copy , EclKW ) ) - - self.assertEqual(len(kw_copy) , 1000) - for i in range(len(kw)): - self.assertEqual(kw_copy[2*i] , i) - self.assertEqual(kw_copy[2*i + 1] , kw.getDefault()) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py deleted file mode 100644 index 807c0b9ab0..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.test import ExtendedTestCase , TestAreaContext -from ecl.test.ecl_mock import createEclSum -from ecl.ecl import EclCmp - -class EclCmpTest(ExtendedTestCase): - def setUp(self): - self.root1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") - self.root2 = self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") - - - def test_not_existing(self): - with self.assertRaises(IOError): - ecl_cmp = EclCmp( "missing/case1" , "missing/case2") - - with self.assertRaises(IOError): - ecl_cmp = EclCmp( "missing/case1" , self.root1 ) - - with self.assertRaises(IOError): - ecl_cmp = EclCmp( self.root1 , "missing/case1") - - ecl_cmp = EclCmp( self.root1 , self.root1) - ecl_cmp = EclCmp( self.root2 , self.root2) - - - def test_different_start(self): - with self.assertRaises(ValueError): - ecl_cmp = EclCmp(self.root1 , self.root2) - - - def test_summary_cmp(self): - ecl_cmp = EclCmp( self.root1 , self.root1) - self.assertEqual( (False , False) , ecl_cmp.hasSummaryVector("MISSING")) - self.assertEqual( (True , True) , ecl_cmp.hasSummaryVector("FOPT")) - - with self.assertRaises(KeyError): - diff = ecl_cmp.cmpSummaryVector("MISSING") - - diff_sum , ref_sum = ecl_cmp.cmpSummaryVector("FOPT") - self.assertEqual( diff_sum , 0.0 ) - self.assertTrue( ecl_cmp.endTimeEqual( ) ) - - - def test_wells(self): - ecl_cmp = EclCmp( self.root1 , self.root1) - wells = ecl_cmp.testWells() - - well_set = set( ["OP_1" , "OP_2" , "OP_3" , "OP_4" , "OP_5" , "WI_1" , "WI_2" , "WI_3"] ) - self.assertEqual( len(wells) , len(well_set)) - for well in wells: - self.assertTrue( well in well_set ) - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_file.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_file.py deleted file mode 100644 index bd6ff62248..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_file.py +++ /dev/null @@ -1,256 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import shutil -import datetime -import os.path -import gc -from unittest import skipIf - - -from ecl.ecl import EclFile, FortIO, EclKW , openFortIO , openEclFile -from ecl.ecl import EclFileFlagEnum, EclDataType, EclFileEnum -from ecl.util import CWDContext -from ecl.test import ExtendedTestCase , TestAreaContext, PathContext - -def createFile( name , kw_list ): - with openFortIO(name , mode = FortIO.WRITE_MODE) as f: - for kw in kw_list: - kw.fwrite( f ) - - -def loadKeywords( name ): - kw_list = [] - f = EclFile( name ) - for kw in f: - kw_list.append( kw ) - - return kw_list - - - - -class EclFileTest(ExtendedTestCase): - - def assertFileType(self , filename , expected): - file_type , step , fmt_file = EclFile.getFileType(filename) - self.assertEqual( file_type , expected[0] ) - self.assertEqual( fmt_file , expected[1] ) - self.assertEqual( step , expected[2] ) - - - def test_file_type(self): - self.assertFileType( "ECLIPSE.UNRST" , (EclFileEnum.ECL_UNIFIED_RESTART_FILE , False , None)) - self.assertFileType( "ECLIPSE.X0030" , (EclFileEnum.ECL_RESTART_FILE , False , 30 )) - self.assertFileType( "ECLIPSE.DATA" , (EclFileEnum.ECL_DATA_FILE , None , None )) - self.assertFileType( "ECLIPSE.FINIT" , (EclFileEnum.ECL_INIT_FILE , True , None )) - self.assertFileType( "ECLIPSE.A0010" , (EclFileEnum.ECL_SUMMARY_FILE , True , 10 )) - self.assertFileType( "ECLIPSE.EGRID" , (EclFileEnum.ECL_EGRID_FILE , False , None )) - - - def test_IOError(self): - with self.assertRaises(IOError): - EclFile("No/Does/not/exist") - - - def test_context( self ): - with TestAreaContext("python/ecl_file/context"): - kw1 = EclKW( "KW1" , 100 , EclDataType.ECL_INT) - kw2 = EclKW( "KW2" , 100 , EclDataType.ECL_INT) - with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - kw2.fwrite( f ) - - with openEclFile("TEST") as ecl_file: - self.assertEqual( len(ecl_file) , 2 ) - self.assertTrue( ecl_file.has_kw("KW1")) - self.assertTrue( ecl_file.has_kw("KW2")) - self.assertEqual(ecl_file[1], ecl_file[-1]) - - def test_ecl_index(self): - with TestAreaContext("python/ecl_file/context"): - kw1 = EclKW( "KW1" , 100 , EclDataType.ECL_INT) - kw2 = EclKW( "KW2" , 100 , EclDataType.ECL_FLOAT) - kw3 = EclKW( "KW3" , 100 , EclDataType.ECL_CHAR) - kw4 = EclKW( "KW4" , 100 , EclDataType.ECL_STRING(23)) - with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - kw2.fwrite( f ) - kw3.fwrite( f ) - kw4.fwrite( f ) - - ecl_file = EclFile("TEST") - ecl_file.write_index("INDEX_FILE") - ecl_file.close() - - ecl_file_index = EclFile("TEST", 0, "INDEX_FILE") - for kw in ["KW1","KW2","KW3","KW4"]: - self.assertIn( kw , ecl_file_index ) - - with self.assertRaises(IOError): - ecl_file.write_index("does-not-exist/INDEX") - - os.mkdir("read-only") - os.chmod("read-only", 0o444) - - with self.assertRaises(IOError): - ecl_file.write_index("read-only/INDEX") - - with self.assertRaises(IOError): - ecl_file_index = EclFile("TEST", 0, "index_does_not_exist") - - shutil.copyfile( "INDEX_FILE" , "INDEX_perm_denied") - os.chmod("INDEX_perm_denied", 0o000) - with self.assertRaises(IOError): - ecl_file_index = EclFile("TEST", 0, "INDEX_perm_denied") - - - os.mkdir("path") - shutil.copyfile("TEST" , "path/TEST") - ecl_file = EclFile("path/TEST") - ecl_file.write_index("path/index") - - with CWDContext("path"): - ecl_file = EclFile("TEST" , 0 , "index") - - - def test_save_kw(self): - with TestAreaContext("python/ecl_file/save_kw"): - data = range(1000) - kw = EclKW("MY_KEY", len(data), EclDataType.ECL_INT) - for index, val in enumerate(data): - kw[index] = val - - clean_dump = "my_clean_file" - fortio = FortIO(clean_dump, FortIO.WRITE_MODE) - kw.fwrite(fortio) - fortio.close() - - test_file = "my_dump_file" - fortio = FortIO(test_file, FortIO.WRITE_MODE) - kw.fwrite(fortio) - fortio.close() - - self.assertFilesAreEqual(clean_dump, test_file) - - ecl_file = EclFile(test_file, flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - loaded_kw = ecl_file["MY_KEY"][0] - self.assertTrue(kw.equal(loaded_kw)) - - ecl_file.save_kw(loaded_kw) - ecl_file.close() - - self.assertFilesAreEqual(clean_dump, test_file) - - ecl_file = EclFile(test_file) - loaded_kw = ecl_file["MY_KEY"][0] - self.assertTrue(kw.equal(loaded_kw)) - - def test_gc(self): - kw1 = EclKW("KW1" , 100 , EclDataType.ECL_INT) - kw2 = EclKW("KW2" , 100 , EclDataType.ECL_INT) - kw3 = EclKW("KW3" , 100 , EclDataType.ECL_INT) - - for i in range(len(kw1)): - kw1[i] = i - kw2[i] = 2*i - kw3[i] = 3*i - - kw_list = [kw1 , kw2 , kw2] - - with TestAreaContext("context") as ta: - createFile("TEST" , kw_list ) - gc.collect() - kw_list2 = loadKeywords( "TEST" ) - - for kw1,kw2 in zip(kw_list,kw_list2): - self.assertEqual( kw1, kw2 ) - - - def test_broken_file(self): - with TestAreaContext("test_broken_file"): - with open("CASE.FINIT", "w") as f: - f.write("This - is not a ECLISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc") - - - with self.assertRaises(IOError): - f = EclFile("CASE.FINIT") - - - def test_block_view(self): - with TestAreaContext("python/ecl_file/view"): - with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: - for i in range(5): - header = EclKW("HEADER" , 1 , EclDataType.ECL_INT ) - header[0] = i - - data1 = EclKW("DATA1" , 100 , EclDataType.ECL_INT ) - data1.assign( i ) - - - data2 = EclKW("DATA2" , 100 , EclDataType.ECL_INT ) - data2.assign( i*10 ) - - header.fwrite( f ) - data1.fwrite( f ) - data2.fwrite( f ) - - - ecl_file = EclFile("TEST") - pfx = 'EclFile(' - self.assertEqual(pfx, repr(ecl_file)[:len(pfx)]) - with self.assertRaises(KeyError): - ecl_file.blockView("NO" , 1) - - with self.assertRaises(IndexError): - ecl_file.blockView("HEADER" , 100) - - with self.assertRaises(IndexError): - ecl_file.blockView("HEADER" , 1000) - - bv = ecl_file.blockView("HEADER" , -1) - - - for i in range(5): - view = ecl_file.blockView("HEADER" , i) - self.assertEqual( len(view) , 3) - header = view["HEADER"][0] - data1 = view["DATA1"][0] - data2 = view["DATA2"][0] - - self.assertEqual( header[0] , i ) - self.assertEqual( data1[99] , i ) - self.assertEqual( data2[99] , i*10 ) - - - for i in range(5): - view = ecl_file.blockView2("HEADER" , "DATA2", i ) - self.assertEqual( len(view) , 2) - header = view["HEADER"][0] - data1 = view["DATA1"][0] - - self.assertEqual( header[0] , i ) - self.assertEqual( data1[99] , i ) - - self.assertFalse( "DATA2" in view ) - - view = ecl_file.blockView2("HEADER" , None, 0 ) - self.assertEqual( len(view) , len(ecl_file)) - - view = ecl_file.blockView2(None , "DATA2", 0 ) - #self.assertEqual( len(view) , 2) - #self.assertTrue( "HEADER" in view ) - #self.assertTrue( "DATA1" in view ) - #self.assertFalse( "DATA2" in view ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py deleted file mode 100644 index 63b6a628da..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import datetime -import os.path -from unittest import skipIf - -from ecl.ecl import EclFile, FortIO, EclKW , openFortIO , openEclFile -from ecl.ecl import EclFileFlagEnum, EclFileEnum - -from ecl.test import ExtendedTestCase , TestAreaContext - - - - -class EclFileStatoilTest(ExtendedTestCase): - def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.test_fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") - - def assertFileType(self , filename , expected): - file_type , step , fmt_file = EclFile.getFileType(filename) - self.assertEqual( file_type , expected[0] ) - self.assertEqual( fmt_file , expected[1] ) - self.assertEqual( step , expected[2] ) - - - def test_fast_open(self): - with TestAreaContext("index"): - f0 = EclFile( self.test_file ) - f0.write_index("index") - f1 = EclFile( self.test_file , 0 , "index") - for kw0,kw1 in zip(f0,f1): - self.assertEqual( kw0,kw1 ) - - - def test_restart_days(self): - rst_file = EclFile( self.test_file ) - self.assertAlmostEqual( 0.0 , rst_file.iget_restart_sim_days(0) ) - self.assertAlmostEqual( 31.0 , rst_file.iget_restart_sim_days(1) ) - self.assertAlmostEqual( 274.0 , rst_file.iget_restart_sim_days(10) ) - - with self.assertRaises(KeyError): - rst_file.restart_get_kw("Missing" , dtime = datetime.date( 2004,1,1)) - - with self.assertRaises(IndexError): - rst_file.restart_get_kw("SWAT" , dtime = datetime.date( 1985 , 1 , 1)) - - - - def test_iget_named(self): - f = EclFile(self.test_file) - N = f.num_named_kw( "SWAT" ) - with self.assertRaises(IndexError): - s = f.iget_named_kw( "SWAT" , N + 1) - - - - def test_fwrite( self ): - #work_area = TestArea("python/ecl_file/fwrite") - with TestAreaContext("python/ecl_file/fwrite"): - rst_file = EclFile(self.test_file) - fortio = FortIO("ECLIPSE.UNRST", FortIO.WRITE_MODE) - rst_file.fwrite(fortio) - fortio.close() - rst_file.close() - self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) - - - - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow file test skipped!") - def test_save(self): - #work_area = TestArea("python/ecl_file/save") - with TestAreaContext("python/ecl_file/save", store_area=False) as work_area: - work_area.copy_file(self.test_file) - rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - swat0 = rst_file["SWAT"][0] - swat0.assign(0.75) - rst_file.save_kw(swat0) - rst_file.close() - self.assertFilesAreNotEqual("ECLIPSE.UNRST",self.test_file) - - rst_file1 = EclFile(self.test_file) - rst_file2 = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - - swat1 = rst_file1["SWAT"][0] - swat2 = rst_file2["SWAT"][0] - swat2.assign(swat1) - - rst_file2.save_kw(swat2) - self.assertTrue(swat1.equal(swat2)) - rst_file1.close() - rst_file2.close() - - # Random failure .... - self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) - - - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow file test skipped!") - def test_save_fmt(self): - #work_area = TestArea("python/ecl_file/save_fmt") - with TestAreaContext("python/ecl_file/save_fmt") as work_area: - work_area.copy_file(self.test_fmt_file) - rst_file = EclFile("ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - swat0 = rst_file["SWAT"][0] - swat0.assign(0.75) - rst_file.save_kw(swat0) - rst_file.close() - self.assertFilesAreNotEqual("ECLIPSE.FUNRST", self.test_fmt_file) - - rst_file1 = EclFile(self.test_fmt_file) - rst_file2 = EclFile("ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - - swat1 = rst_file1["SWAT"][0] - swat2 = rst_file2["SWAT"][0] - - swat2.assign(swat1) - rst_file2.save_kw(swat2) - self.assertTrue(swat1.equal(swat2)) - rst_file1.close() - rst_file2.close() - - # Random failure .... - self.assertFilesAreEqual("ECLIPSE.FUNRST", self.test_fmt_file) - - - def test_truncated(self): - with TestAreaContext("python/ecl_file/truncated") as work_area: - work_area.copy_file(self.test_file) - size = os.path.getsize("ECLIPSE.UNRST") - with open("ECLIPSE.UNRST" , "r+") as f: - f.truncate( size / 2 ) - - with self.assertRaises(IOError): - rst_file = EclFile("ECLIPSE.UNRST") - - with self.assertRaises(IOError): - rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - - def test_restart_view(self): - f = EclFile( self.test_file ) - with self.assertRaises(ValueError): - v = f.restartView( ) - - v = f.restartView( sim_days = 274 ) - v = f.restartView( sim_time = datetime.date( 2004,1,1) ) - v = f.restartView( report_step = 30 ) - v = f.restartView( seqnum_index = 30 ) - - - def test_index(self): - with TestAreaContext("python/ecl_file/truncated"): - f0 = EclFile( self.test_file ) - f0.write_index( "index" ) - - f1 = EclFile( self.test_file , index_filename = "index") - for kw0,kw1 in zip(f0,f1): - self.assertEqual(kw0,kw1) - - - def test_ix_case(self): - f = EclFile( self.createTestPath( "Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well.SMSPEC")) - - # Keywords - self.assertTrue( "KEYWORDS" in f ) - keywords_loaded = list(f["KEYWORDS"][0]) - keywords_from_file = [ - 'TIME', 'YEARS', 'AAQR', 'AAQT', 'AAQP', 'AAQR', 'AAQT', - 'AAQP', 'AAQR', 'AAQT', 'AAQP', 'FPPW', 'FPPO', 'FPPG', 'FNQT', - 'FNQR', 'FEIP', 'FWPT', 'FWIT', 'FWIP', 'FWGR', 'FVPT', 'FVPR', - 'FVIT', 'FVIR', 'FPR', 'FOPT', 'FOIT', 'FOIR', 'FOIPL', - 'FOIPG', 'FOIP', 'FGPT', 'FGIT', 'FGIPL', 'FGIPG', 'FGIP', - 'FAQT', 'FAQR', 'FGOR', 'FWCT', 'FGSR', 'FGIR', 'FGPR', 'FWIR', - 'FWPR', 'FOPR', 'MEMORYTS', 'NAIMFRAC', 'TCPUDAY', 'TCPUTS', - 'NBAKFL', 'NNUMST', 'NNUMFL', 'NEWTFL', 'MSUMNEWT', 'MSUMLINS', - 'MLINEARS', 'NLINEARS', 'NEWTON', 'ELAPSED', 'TCPU', - 'TIMESTEP', 'GOPR', 'GOPR', 'GOPR', 'GWPR', 'GWPR', 'GWPR', - 'GWIR', 'GWIR', 'GWIR', 'GGPR', 'GGPR', 'GGPR', 'GWCT', 'GWCT', - 'GWCT', 'GGOR', 'GGOR', 'GGOR', 'GGIR', 'GGIR', 'GGIR', 'GGIT', - 'GGIT', 'GGIT', 'GGPT', 'GGPT', 'GGPT', 'GOIR', 'GOIR', 'GOIR', - 'GOIT', 'GOIT', 'GOIT', 'GOPT', 'GOPT', 'GOPT', 'GVIR', 'GVIR', - 'GVIR', 'GVIT', 'GVIT', 'GVIT', 'GVPR', 'GVPR', 'GVPR', 'GVPT', - 'GVPT', 'GVPT', 'GWGR', 'GWGR', 'GWGR', 'GWIT', 'GWIT', 'GWIT', - 'GWPT', 'GWPT', 'GWPT', 'WOPR', 'WOPR', 'WOPR', 'WOPR', 'WOPR', - 'WOPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWPR', 'WWIR', - 'WWIR', 'WWIR', 'WWIR', 'WWIR', 'WWIR', 'WGPR', 'WGPR', 'WGPR', - 'WGPR', 'WGPR', 'WGPR', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', - 'WWCT', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', 'WMCTL', - 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WGOR', 'WAPI', 'WAPI', - 'WAPI', 'WAPI', 'WAPI', 'WAPI', 'WBHP', 'WBHP', 'WBHP', 'WBHP', - 'WBHP', 'WBHP', 'WGIR', 'WGIR', 'WGIR', 'WGIR', 'WGIR', 'WGIR', - 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGIT', 'WGPT', 'WGPT', - 'WGPT', 'WGPT', 'WGPT', 'WGPT', 'WOIR', 'WOIR', 'WOIR', 'WOIR', - 'WOIR', 'WOIR', 'WOIT', 'WOIT', 'WOIT', 'WOIT', 'WOIT', 'WOIT', - 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WOPT', 'WPIG', 'WPIG', - 'WPIG', 'WPIG', 'WPIG', 'WPIG', 'WPIO', 'WPIO', 'WPIO', 'WPIO', - 'WPIO', 'WPIO', 'WPIW', 'WPIW', 'WPIW', 'WPIW', 'WPIW', 'WPIW', - 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WTHP', 'WVIR', 'WVIR', - 'WVIR', 'WVIR', 'WVIR', 'WVIR', 'WVIT', 'WVIT', 'WVIT', 'WVIT', - 'WVIT', 'WVIT', 'WVPR', 'WVPR', 'WVPR', 'WVPR', 'WVPR', 'WVPR', - 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WVPT', 'WWGR', 'WWGR', - 'WWGR', 'WWGR', 'WWGR', 'WWGR', 'WWIT', 'WWIT', 'WWIT', 'WWIT', - 'WWIT', 'WWIT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', 'WWPT', - 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBHT', 'WBP', 'WBP', - 'WBP', 'WBP', 'WBP', 'WBP', 'WWCT', 'WWCT', 'WWCT', 'WWCT', - 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', - 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', - 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT', 'WWCT' - ] - - padd = lambda str_len : (lambda s : s + (" " * (max(0, str_len-len(s))))) - self.assertEqual(map(padd(8), keywords_from_file), keywords_loaded) - - # Names - self.assertTrue( "NAMES" in f ) - names_loaded = list(f["NAMES"][0]) - names_from_file = [ - '', '', 'AQFR_1', 'AQFR_1', 'AQFR_1', 'AQFR_2', 'AQFR_2', - 'AQFR_2', 'AQFR_3', 'AQFR_3', 'AQFR_3', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', 'FIELD', - 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', - 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', - 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', - 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', - 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', - 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', - 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', 'TWO', 'FIELD', 'ONE', - 'TWO', 'FIELD', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', - 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', - 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', - 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', - 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', - 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', - 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', - 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', - 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', - 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', - 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', - 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', - 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', - 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', - 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', - 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', - 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', - 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', - 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', - 'GI', 'I2', 'I4', 'I6', 'I8', 'HWELL_PROD', 'GI', 'I2', 'I4', - 'I6', 'I8', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', - ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', - ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', - ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', - ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', - ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+' - ] - - self.assertEqual(map(padd(10), names_from_file), names_loaded) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py deleted file mode 100644 index 3792354d54..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -from ecl.test import ExtendedTestCase -from ecl.ecl import (Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO, - EclFileFlagEnum, EclGrid) - -class InitFileTest(ExtendedTestCase): - - - def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.init_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT") - - - def test_wrong_type(self): - g = EclGrid(self.grid_file) - with self.assertRaises(ValueError): - f = EclInitFile(g, self.grid_file) - - - def test_load(self): - g = EclGrid(self.grid_file) - f = EclInitFile(g, self.init_file) - - head = f["INTEHEAD"][0] - self.assertTrue(isinstance(head, EclKW)) - - porv = f["PORV"][0] - self.assertTrue(isinstance(porv, Ecl3DKW)) - - poro = f["PORO"][0] - self.assertTrue(isinstance(poro, Ecl3DKW)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py deleted file mode 100644 index f88f5e4c91..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py +++ /dev/null @@ -1,475 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os -import random -import numpy -import warnings - -from ecl.ecl import (EclKW, EclDataType, EclTypeEnum, EclFile, FortIO, - EclFileFlagEnum, openFortIO) - -from ecl.test import ExtendedTestCase, TestAreaContext - - -def copy_long(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) - copy = src.sub_copy(0, 2000) - - -def copy_offset(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) - copy = src.sub_copy(200, 100) - - -class KWTest(ExtendedTestCase): - - def test_name(self): - kw = EclKW('TEST', 3, EclDataType.ECL_INT) - self.assertEqual(kw.name, 'TEST') - self.assertIn('TEST', repr(kw)) - kw.name = 'SCHMEST' - self.assertEqual(kw.name, 'SCHMEST') - self.assertIn('SCHMEST', repr(kw)) - - def test_min_max(self): - kw = EclKW("TEST", 3, EclDataType.ECL_INT) - kw[0] = 10 - kw[1] = 5 - kw[2] = 0 - - self.assertEqual(10, kw.getMax()) - self.assertEqual(0 , kw.getMin()) - self.assertEqual((0,10) , kw.getMinMax()) - - - def test_deprecated_datatypes(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - kw = EclKW("Test", 10, EclTypeEnum.ECL_INT_TYPE) - self.assertTrue(len(w) > 0) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - kw = EclKW("Test", 10, EclDataType.ECL_INT) - self.assertTrue(len(w) == 0) - - self.assertEqual(EclTypeEnum.ECL_INT_TYPE, kw.type) - - self.assertTrue(len(w) > 0) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - - def kw_test(self, data_type, data, fmt): - name1 = "file1.txt" - name2 = "file2.txt" - kw = EclKW("TEST", len(data), data_type) - i = 0 - for d in data: - kw[i] = d - i += 1 - - file1 = open(name1, "w") - kw.fprintf_data(file1, fmt) - file1.close() - - file2 = open(name2, "w") - for d in data: - file2.write(fmt % d) - file2.close() - self.assertFilesAreEqual(name1, name2) - self.assertEqual(kw.data_type, data_type) - - def test_create(self): - with self.assertRaises(ValueError): - EclKW("ToGodDamnLong", 100, EclDataType.ECL_CHAR) - - def test_sum(self): - for ecl_type in [EclDataType.ECL_CHAR, EclDataType.ECL_STRING(42)]: - kw_string = EclKW("STRING", 100, ecl_type) - with self.assertRaises(ValueError): - kw_string.sum() - - kw_int = EclKW("INT", 4, EclDataType.ECL_INT) - kw_int[0] = 1 - kw_int[1] = 2 - kw_int[2] = 3 - kw_int[3] = 4 - self.assertEqual(kw_int.sum(), 10) - - kw_d = EclKW("D", 4, EclDataType.ECL_DOUBLE) - kw_d[0] = 1 - kw_d[1] = 2 - kw_d[2] = 3 - kw_d[3] = 4 - self.assertEqual(kw_d.sum(), 10) - - kw_f = EclKW("F", 4, EclDataType.ECL_FLOAT) - kw_f[0] = 1 - kw_f[1] = 2 - kw_f[2] = 3 - kw_f[3] = 4 - self.assertEqual(kw_f.sum(), 10) - - kw_b = EclKW("F", 4, EclDataType.ECL_BOOL) - kw_b[0] = False - kw_b[1] = True - kw_b[2] = False - kw_b[3] = True - self.assertEqual(kw_b.sum(), 2) - - - - def test_fprintf(self): - with TestAreaContext("python.ecl_kw"): - self.kw_test(EclDataType.ECL_INT, [0, 1, 2, 3, 4, 5], "%4d\n") - self.kw_test(EclDataType.ECL_FLOAT, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n") - self.kw_test(EclDataType.ECL_DOUBLE, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n") - self.kw_test(EclDataType.ECL_BOOL, [True, True, True, False, True], "%4d\n") - self.kw_test(EclDataType.ECL_CHAR, ["1", "22", "4444", "666666", "88888888"], "%-8s\n") - - for str_len in range(1000): - self.kw_test(EclDataType.ECL_STRING(str_len), [str(i)*str_len for i in range(10)], "%s\n") - - def test_kw_write(self): - with TestAreaContext("python/ecl_kw/writing"): - - data = [random.random() for i in range(10000)] - - kw = EclKW("TEST", len(data), EclDataType.ECL_DOUBLE) - i = 0 - for d in data: - kw[i] = d - i += 1 - - pfx = 'EclKW(' - self.assertEqual(pfx, repr(kw)[:len(pfx)]) - - fortio = FortIO("ECL_KW_TEST", FortIO.WRITE_MODE) - kw.fwrite(fortio) - fortio.close() - - fortio = FortIO("ECL_KW_TEST") - - kw2 = EclKW.fread(fortio) - - self.assertTrue(kw.equal(kw2)) - - ecl_file = EclFile("ECL_KW_TEST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - kw3 = ecl_file["TEST"][0] - self.assertTrue(kw.equal(kw3)) - ecl_file.save_kw(kw3) - ecl_file.close() - - fortio = FortIO("ECL_KW_TEST", FortIO.READ_AND_WRITE_MODE) - kw4 = EclKW.fread(fortio) - self.assertTrue(kw.equal(kw4)) - fortio.seek(0) - kw4.fwrite(fortio) - fortio.close() - - ecl_file = EclFile("ECL_KW_TEST") - kw5 = ecl_file["TEST"][0] - self.assertTrue(kw.equal(kw5)) - - - - def test_fprintf_data(self): - with TestAreaContext("kw_no_header"): - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) - for i in range(len(kw)): - kw[i] = i - - fileH = open("test", "w") - kw.fprintf_data(fileH) - fileH.close() - - fileH = open("test", "r") - data = [] - for line in fileH.readlines(): - tmp = line.split() - for elm in tmp: - data.append(int(elm)) - - for (v1,v2) in zip(data,kw): - self.assertEqual(v1,v2) - - - def test_sliced_set(self): - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) - kw.assign(99) - kw[0:5] = 66 - self.assertEqual(kw[0], 66) - self.assertEqual(kw[4], 66) - self.assertEqual(kw[5], 99) - - - def test_long_name(self): - with self.assertRaises(ValueError): - EclKW("LONGLONGNAME", 10, EclDataType.ECL_INT) - - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) - with self.assertRaises(ValueError): - kw.name = "LONGLONGNAME" - - - def test_abs(self): - for ecl_type in [ - EclDataType.ECL_CHAR, - EclDataType.ECL_BOOL, - EclDataType.ECL_STRING(32) - ]: - kw = EclKW("NAME", 10, ecl_type) - with self.assertRaises(TypeError): - abs_kw = abs(kw) - - kw = EclKW("NAME", 10, EclDataType.ECL_INT) - for i in range(len(kw)): - kw[i] = -i - - abs_kw = abs(kw) - for i in range(len(kw)): - self.assertEqual(kw[i], -i) - self.assertEqual(abs_kw[i], i) - - - def test_fmt(self): - kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) - kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) - - for i in range(len(kw1)): - kw1[i] = i + 1 - kw2[i] = len(kw1) - kw1[i] - - with TestAreaContext("ecl_kw/fmt") as ta: - with openFortIO("TEST.FINIT", FortIO.WRITE_MODE, fmt_file=True) as f: - kw1.fwrite(f) - kw2.fwrite(f) - - with openFortIO("TEST.FINIT", fmt_file=True) as f: - kw1b = EclKW.fread(f) - kw2b = EclKW.fread(f) - - self.assertTrue(kw1 == kw1b) - self.assertTrue(kw2 == kw2b) - - f = EclFile("TEST.FINIT") - self.assertTrue(kw1 == f[0]) - self.assertTrue(kw2 == f[1]) - - - def test_first_different(self): - kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) - kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) - kw3 = EclKW("NAME2", 200, EclDataType.ECL_INT) - kw4 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) - kw5 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) - - - with self.assertRaises(IndexError): - EclKW.firstDifferent(kw1, kw2, offset=100) - - with self.assertRaises(ValueError): - EclKW.firstDifferent(kw1, kw3) - - with self.assertRaises(TypeError): - EclKW.firstDifferent(kw1, kw4) - - - with self.assertRaises(IndexError): - kw1.firstDifferent(kw2, offset=100) - - with self.assertRaises(ValueError): - kw1.firstDifferent(kw3) - - with self.assertRaises(TypeError): - kw1.firstDifferent(kw4) - - - kw1.assign(1) - kw2.assign(1) - - self.assertEqual(kw1.firstDifferent(kw2), len(kw1)) - - kw1[0] = 100 - self.assertEqual(kw1.firstDifferent(kw2), 0) - self.assertEqual(kw1.firstDifferent(kw2, offset=1), len(kw1)) - kw1[10] = 100 - self.assertEqual(kw1.firstDifferent(kw2, offset=1), 10) - - - kw4.assign(1.0) - kw5.assign(1.0) - self.assertEqual(kw4.firstDifferent(kw5), len(kw4)) - - kw4[10] *= 1.0001 - self.assertEqual(kw4.firstDifferent(kw5), 10) - - self.assertEqual(kw4.firstDifferent(kw5, epsilon=1.0), len(kw4)) - self.assertEqual(kw4.firstDifferent(kw5, epsilon=0.0000001), 10) - - - def test_numeric_equal(self): - kw1 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) - kw2 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) - - - shift = 0.0001 - value = 1000 - - abs_diff = shift - rel_diff = shift / (shift + 2* value) - kw1.assign(value) - kw2.assign(value + shift) - - - self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=rel_diff * 1.1)) - self.assertFalse(kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=rel_diff * 0.9)) - self.assertFalse(kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 0.9, rel_epsilon=rel_diff * 1.1)) - self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=0, rel_epsilon=rel_diff * 1.1)) - self.assertTrue( kw1.equal_numeric(kw2, abs_epsilon=abs_diff * 1.1, rel_epsilon=0)) - - def test_mul(self): - kw1 = EclKW("Name1", 10, EclDataType.ECL_INT) - kw1.assign(10) - - kw2 = EclKW("Name1", 10, EclDataType.ECL_INT) - kw2.assign(2) - - kw3 = kw1 * kw2 - kw4 = kw1 + kw2 - self.assertEqual(len(kw3), len(kw1)) - self.assertEqual(len(kw4), len(kw1)) - for v in kw3: - self.assertEqual(v, 20) - - for v in kw4: - self.assertEqual(v, 12) - - - def test_numpy(self): - kw1 = EclKW("DOUBLE", 10, EclDataType.ECL_DOUBLE) - - view = kw1.numpyView() - copy = kw1.numpyCopy() - - self.assertTrue(copy[ 0 ] == kw1[ 0 ]) - self.assertTrue(view[ 0 ] == kw1[ 0 ]) - - kw1[ 0 ] += 1 - self.assertTrue(view[ 0 ] == kw1[ 0 ]) - self.assertTrue(copy[ 0 ] == kw1[ 0 ] - 1) - - for ecl_type in [ - EclDataType.ECL_CHAR, - EclDataType.ECL_BOOL, - EclDataType.ECL_STRING(19)]: - kw2 = EclKW("TEST_KW", 10, ecl_type) - with self.assertRaises(ValueError): - kw2.numpyView() - - def test_slice(self): - N = 100 - kw = EclKW("KW", N, EclDataType.ECL_INT) - for i in range(len(kw)): - kw[i] = i - - even = kw[0:len(kw):2] - odd = kw[1:len(kw):2] - - self.assertEqual(len(even), N/2) - self.assertEqual(len(odd) , N/2) - - for i in range(len(even)): - self.assertEqual(even[i], 2*i) - self.assertEqual(odd[i], 2*i + 1) - - - def test_resize(self): - N = 4 - kw = EclKW("KW", N, EclDataType.ECL_INT) - for i in range(N): - kw[i] = i - - kw.resize(2*N) - self.assertEqual(len(kw), 2*N) - for i in range(N): - self.assertEqual(kw[i], i) - - kw.resize(N/2) - self.assertEqual(len(kw), N/2) - for i in range(N/2): - self.assertEqual(kw[i], i) - - - def test_typename(self): - kw = EclKW("KW", 100, EclDataType.ECL_INT) - - self.assertEqual(kw.typeName(), "INTE") - - def test_string_alloc(self): - kw = EclKW("KW", 10, EclDataType.ECL_STRING(30)) - - for i in range(10): - kw[i] = str(i)*30 - - for i in range(10): - self.assertEqual(str(i)*30, kw[i]) - - def test_string_write_read_unformatted(self): - for str_len in range(1000): - with TestAreaContext("my_space"): - - kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) - for i in range(10): - kw[i] = str(i)*str_len - - file_name = "ecl_kw_test" - - with openFortIO(file_name, mode=FortIO.WRITE_MODE) as fortio: - kw.fwrite(fortio) - - with openFortIO(file_name) as fortio: - loaded_kw = EclKW.fread(fortio) - - self.assertEqual(kw, loaded_kw) - - def test_string_write_read_formatted(self): - for str_len in range(1000): - with TestAreaContext("my_space"): - - kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) - for i in range(10): - kw[i] = str(i)*str_len - - file_name = "ecl_kw_test" - with openFortIO(file_name, mode=FortIO.WRITE_MODE, fmt_file=True) as fortio: - kw.fwrite(fortio) - - with openFortIO(file_name, fmt_file=True) as fortio: - loaded_kw = EclKW.fread(fortio) - - self.assertEqual(kw, loaded_kw) - - - def test_string_padding(self): - kw = EclKW("TEST_KW", 1, EclDataType.ECL_STRING(4)) - kw[0] = "AB" - self.assertEqual(kw[0], "AB ") - - kw = EclKW("TEST_KW", 1, EclDataType.ECL_CHAR) - kw[0] = "ABCD" - self.assertEqual(kw[0], "ABCD ") diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py deleted file mode 100644 index 21d6b63c40..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os -import random -from ecl.ecl import EclKW, EclDataType, EclFile, FortIO, EclFileFlagEnum - -from ecl.test import ExtendedTestCase , TestAreaContext - - -def copy_long(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) - copy = src.sub_copy(0, 2000) - - -def copy_offset(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) - copy = src.sub_copy(200, 100) - - -class KWTest(ExtendedTestCase): - def test_fortio_size( self ): - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) - size = 0 - for kw in unrst_file: - size += kw.fortIOSize() - - stat = os.stat(unrst_file_path) - self.assertTrue(size == stat.st_size) - - - - - def test_sub_copy(self): - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) - swat = unrst_file["SWAT"][0] - - swat1 = swat.sub_copy(0, -1) - swat2 = swat.sub_copy(0, len(swat)) - - self.assertTrue(swat.equal(swat1)) - self.assertTrue(swat.equal(swat2)) - - swat3 = swat.sub_copy(20000, 100, new_header="swat") - self.assertTrue(swat3.getName() == "swat") - self.assertTrue(len(swat3) == 100) - equal = True - for i in range(len(swat3)): - if swat3[i] != swat[i + 20000]: - equal = False - self.assertTrue(equal) - - self.assertRaises(IndexError, copy_long) - self.assertRaises(IndexError, copy_offset) - - - def test_equal(self): - kw1 = EclKW("TEST", 3, EclDataType.ECL_CHAR) - kw1[0] = "Test1" - kw1[1] = "Test13" - kw1[2] = "Test15" - - kw2 = EclKW("TEST", 3, EclDataType.ECL_CHAR) - kw2[0] = "Test1" - kw2[1] = "Test13" - kw2[2] = "Test15" - - self.assertTrue(kw1.equal(kw2)) - self.assertTrue(kw1.equal_numeric(kw2)) - - kw2[2] = "Test15X" - self.assertFalse(kw1.equal(kw2)) - self.assertFalse(kw1.equal_numeric(kw2)) - - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) - kw1 = unrst_file["PRESSURE"][0] - kw2 = kw1.deep_copy() - - self.assertTrue(kw1.equal(kw2)) - self.assertTrue(kw1.equal_numeric(kw2)) - - kw2 *= 1.00001 - self.assertFalse(kw1.equal(kw2)) - self.assertFalse(kw1.equal_numeric(kw2, epsilon=1e-8)) - self.assertTrue(kw1.equal_numeric(kw2, epsilon=1e-2)) - - kw1 = unrst_file["ICON"][10] - kw2 = kw1.deep_copy() - self.assertTrue(kw1.equal(kw2)) - self.assertTrue(kw1.equal_numeric(kw2)) - - kw1[-1] += 1 - self.assertFalse(kw1.equal(kw2)) - self.assertFalse(kw1.equal_numeric(kw2)) - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py deleted file mode 100644 index e2779e6d5e..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import datetime - -from ecl.test import ExtendedTestCase -from ecl.ecl import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO, EclFileFlagEnum , EclGrid - -class RestartFileTest(ExtendedTestCase): - def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") - self.xrst_file10 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0010") - self.xrst_file20 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0020") - - - def test_load(self): - g = EclGrid( self.grid_file ) - f = EclRestartFile( g , self.unrst_file ) - - head = f["INTEHEAD"][0] - self.assertTrue( isinstance( head , EclKW )) - - swat = f["SWAT"][0] - self.assertTrue( isinstance( swat , Ecl3DKW )) - - pressure = f["PRESSURE"][0] - self.assertTrue( isinstance( pressure , Ecl3DKW )) - - - def test_type(self): - g = EclGrid( self.grid_file ) - with self.assertRaises(ValueError): - f = EclRestartFile( g , "NOT_A_RESTART_FILE") - - - def test_unified(self): - g = EclGrid( self.grid_file ) - f_unrst = EclRestartFile( g , self.unrst_file ) - f_x0 = EclRestartFile( g , self.xrst_file0 ) - f_x10 = EclRestartFile( g , self.xrst_file10 ) - f_x20 = EclRestartFile( g , self.xrst_file20 ) - - self.assertTrue( f_unrst.unified() ) - self.assertFalse( f_x0.unified() ) - self.assertFalse( f_x10.unified() ) - self.assertFalse( f_x20.unified() ) - - self.assertEqual( [(10 , datetime.datetime( 2000 , 10 , 1 , 0 , 0 , 0 ) , 274.0)] , f_x10.timeList()) - - unrst_timeList = f_unrst.timeList() - self.assertEqual( len(unrst_timeList) , 63 ) - self.assertEqual( (62 , datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0 ) , 1826.0) , unrst_timeList[62]); - diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py deleted file mode 100644 index f729589909..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import datetime -import os.path - -from cwrap import CFILE -from ecl.ecl import EclSum, EclSumKeyWordVector, EclFile -from ecl.ecl import FortIO, openFortIO, openEclFile, EclKW -from ecl.test import ExtendedTestCase, TestAreaContext - - -class EclSumTest(ExtendedTestCase): - - - def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - self.ecl_sum = EclSum(self.test_file) - - - def test_time_range_year(self): - real_range = self.ecl_sum.timeRange(interval="1y", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1y", extend_end=True) - assert real_range[-1] < extended_range[-1] - - - def test_time_range_day(self): - real_range = self.ecl_sum.timeRange(interval="1d", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1d", extend_end=True) - assert real_range[-1] == extended_range[-1] - - - def test_time_range_month(self): - real_range = self.ecl_sum.timeRange(interval="1m", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1m", extend_end=True) - assert real_range[-1] < extended_range[-1] - - - def test_dump_csv_line(self): - ecl_sum_vector = EclSumKeyWordVector(self.ecl_sum) - ecl_sum_vector.addKeywords("F*") - - with self.assertRaises(KeyError): - ecl_sum_vector.addKeyword("MISSING") - - dtime = datetime.datetime(2002, 1, 1, 0, 0, 0) - with TestAreaContext("EclSum/csv_dump"): - test_file_name = self.createTestPath("dump.csv") - outputH = open(test_file_name, "w") - self.ecl_sum.dumpCSVLine(dtime, ecl_sum_vector, outputH) - assert os.path.isfile(test_file_name) - - - def test_truncated_smspec(self): - with TestAreaContext("EclSum/truncated_smspec") as ta: - ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - - file_size = os.path.getsize("ECLIPSE.SMSPEC") - with open("ECLIPSE.SMSPEC","r+") as f: - f.truncate(file_size / 2) - - with self.assertRaises(IOError): - EclSum("ECLIPSE") - - - def test_truncated_data(self): - with TestAreaContext("EclSum/truncated_data") as ta: - ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - - - file_size = os.path.getsize("ECLIPSE.UNSMRY") - with open("ECLIPSE.UNSMRY","r+") as f: - f.truncate(file_size / 2) - - with self.assertRaises(IOError): - EclSum("ECLIPSE") - - - def test_missing_smspec_keyword(self): - with TestAreaContext("EclSum/truncated_data") as ta: - ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - - with openEclFile("ECLIPSE.SMSPEC") as f: - kw_list = [] - for kw in f: - kw_list.append(EclKW.copy(kw)) - - with openFortIO("ECLIPSE.SMSPEC", mode=FortIO.WRITE_MODE) as f: - for kw in kw_list: - if kw.getName() == "KEYWORDS": - continue - kw.fwrite(f) - - with self.assertRaises(IOError): - EclSum("ECLIPSE") - - - def test_missing_unsmry_keyword(self): - with TestAreaContext("EclSum/truncated_data") as ta: - ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - - with openEclFile("ECLIPSE.UNSMRY") as f: - kw_list = [] - for kw in f: - kw_list.append(EclKW.copy(kw)) - - - with openFortIO("ECLIPSE.UNSMRY", mode=FortIO.WRITE_MODE) as f: - c = 0 - for kw in kw_list: - if kw.getName() == "PARAMS": - if c % 5 == 0: - continue - c += 1 - kw.fwrite(f) - - with self.assertRaises(IOError): - EclSum("ECLIPSE") - - - def test_labscale(self): - case = self.createTestPath("Statoil/ECLIPSE/LabScale/HDMODEL") - sum = EclSum(case) - self.assertEqual(sum.getStartTime(), datetime.datetime(2013,1,1,0,0,0)) - self.assertEqual(sum.getEndTime() , datetime.datetime(2013,1,1,19,30,0)) - self.assertFloatEqual(sum.getSimulationLength(), 0.8125) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py deleted file mode 100644 index 8a15241a09..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py +++ /dev/null @@ -1,41 +0,0 @@ -from datetime import datetime -import random -from ecl.ecl import EclSumTStep, EclSum -from ecl.test import ExtendedTestCase - - -class EclSumTStepTest(ExtendedTestCase): - - def test_creation(self): - ecl_sum = EclSum.writer("TEST", datetime(2010, 1, 1), 10, 10, 10) - ecl_sum.addVariable("FOPT") - ecl_sum.addVariable("FOPR") - - smspec = ecl_sum.cNamespace().get_smspec(ecl_sum) - - test_data = [(1, 0, 10), (1, 1, 20), (1, 2, 30), (2, 0, 40)] - - for report_step, mini_step, sim_days in test_data: - ecl_sum_tstep = EclSumTStep(report_step, mini_step, sim_days, smspec) - - self.assertEqual(ecl_sum_tstep.getSimDays(), sim_days) - self.assertEqual(ecl_sum_tstep.getReport(), report_step) - self.assertEqual(ecl_sum_tstep.getMiniStep(), mini_step) - - self.assertTrue("FOPT" in ecl_sum_tstep) - self.assertTrue("FOPR" in ecl_sum_tstep) - self.assertFalse("WWCT" in ecl_sum_tstep) - - random_float = random.random() - ecl_sum_tstep["FOPT"] = random_float - ecl_sum_tstep["FOPR"] = random_float + 1 - - self.assertAlmostEqual(random_float, ecl_sum_tstep["FOPT"], places=5) - self.assertAlmostEqual(random_float + 1, ecl_sum_tstep["FOPR"], places=5) - - with self.assertRaises(KeyError): - ecl_sum_tstep["FROPR"] = 2 - - with self.assertRaises(KeyError): - value = ecl_sum_tstep["FROPR"] - diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py deleted file mode 100644 index a5bfebf7fb..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_ecl_sum_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import warnings - -from ecl.ecl import EclSumVector, EclSum -from ecl.test import ExtendedTestCase - - -class EclSumVectorTest(ExtendedTestCase): - - - def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - self.ecl_sum = EclSum(self.test_file) - - def test_reportOnly_warns(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - vector = EclSumVector(self.ecl_sum, "FOPT", True) - assert len(w) == 1 - assert issubclass(w[-1].category, DeprecationWarning) - - - def test_basic(self): - self.assertEqual(512, len(self.ecl_sum.keys())) - pfx = 'EclSum(name' - self.assertEqual(pfx, repr(self.ecl_sum)[:len(pfx)]) - it = iter(self.ecl_sum) - t = self.ecl_sum[it.next()] # EclSumVector - self.assertEqual(63, len(t)) - self.assertEqual('BARSA', t.unit) - pfx = 'EclSumVector(key = ' - self.assertEqual(pfx, repr(t)[:len(pfx)]) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_type.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_type.py deleted file mode 100644 index 48da066718..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_type.py +++ /dev/null @@ -1,139 +0,0 @@ -from ecl.test import TestAreaContext, ExtendedTestCase - -from ecl.ecl import EclDataType, EclTypeEnum - -def get_const_size_types(): - return EclTypeEnum.enums()[:-1:] - -class EclDataTypeTest(ExtendedTestCase): - - # All of the below should list their elements in the same order as - # EclTypeEnum! - # [char, float, double, int, bool, mess] - - CONST_SIZES = [8, 4, 8, 4, 4, 0] - - CONST_VERIFIERS = [ - EclDataType.is_char, - EclDataType.is_float, - EclDataType.is_double, - EclDataType.is_int, - EclDataType.is_bool, - EclDataType.is_mess - ] - - CONST_NAMES = ["CHAR", "REAL", "DOUB", "INTE", "LOGI", "MESS"] - - STRING_NAMES = ["C000", "C010", "C020", "C042", "C999"] - - STRING_SIZES = [0, 10, 20, 42, 999] - - TYPES = (get_const_size_types() + - len(STRING_SIZES) * [EclTypeEnum.ECL_STRING_TYPE]) - - SIZES = CONST_SIZES + STRING_SIZES - - NAMES = CONST_NAMES + STRING_NAMES - - - def test_alloc_from_type(self): - types, sizes = get_const_size_types(), self.CONST_SIZES - for (ecl_type, element_size) in zip(types, sizes): - data_type = EclDataType(ecl_type) - self.assertEqual(ecl_type, data_type.type) - self.assertEqual(element_size, data_type.element_size) - - def test_invalid_string_alloc(self): - with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE) - - with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, -1) - - with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, 1000) - - def test_alloc(self): - for (ecl_type, element_size) in zip(self.TYPES, self.SIZES): - data_type = EclDataType(ecl_type, element_size) - self.assertEqual(ecl_type, data_type.type) - self.assertEqual(element_size, data_type.element_size) - - def test_type_verifiers(self): - test_base = zip(self.TYPES, self.SIZES, self.CONST_VERIFIERS) - for (ecl_type, elem_size, verifier) in test_base: - data_type = EclDataType(ecl_type, elem_size) - self.assertTrue(verifier(data_type)) - - def test_get_type_name(self): - test_base = zip(self.TYPES, self.SIZES, self.NAMES) - for (ecl_type, elem_size, type_name) in test_base: - data_type = EclDataType(ecl_type, elem_size) - self.assertEqual(type_name, data_type.type_name) - - def test_initialization_validation(self): - invalid_args = [ - (None, 0, self.CONST_NAMES[0]), - (1, None, self.CONST_NAMES[0]), - (1, 0, self.CONST_NAMES[0]), - (None, None, None), - (None, 12, None) - ] - - for inv_arg in invalid_args: - with self.assertRaises(ValueError): - EclDataType(inv_arg[0], inv_arg[1], inv_arg[2]) - - def test_create_from_type_name(self): - test_base = zip(self.TYPES, self.SIZES, self.NAMES) - for (ecl_type, elem_size, type_name) in test_base: - data_type = EclDataType.create_from_type_name(type_name) - self.assertEqual(ecl_type, data_type.type) - self.assertEqual(elem_size, data_type.element_size) - self.assertEqual(type_name, data_type.type_name) - - def test_is_numeric(self): - numeric_types = [ - EclTypeEnum.ECL_INT_TYPE, - EclTypeEnum.ECL_FLOAT_TYPE, - EclTypeEnum.ECL_DOUBLE_TYPE - ] - - for ecl_type in numeric_types: - self.assertTrue(EclDataType(ecl_type).is_numeric()) - - for ecl_type in set(get_const_size_types())-set(numeric_types): - self.assertFalse(EclDataType(ecl_type).is_numeric()) - - for elem_size in self.STRING_SIZES: - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) - self.assertFalse(data_type.is_numeric()) - - def test_equals(self): - test_base = zip(self.TYPES, self.SIZES) - for ecl_type, elem_size in test_base: - a = EclDataType(ecl_type, elem_size) - b = EclDataType(ecl_type, elem_size) - - self.assertTrue(a.is_equal(b)) - self.assertEqual(a, b) - - for otype, osize in set(test_base)-set([(ecl_type, elem_size)]): - self.assertFalse(a.is_equal(EclDataType(otype, osize))) - self.assertNotEqual(a, EclDataType(otype, osize)) - - def test_hash(self): - all_types = set() - test_base = zip(self.TYPES, self.SIZES) - - for index, (ecl_type, elem_size) in enumerate(test_base): - all_types.add(EclDataType(ecl_type, elem_size)) - self.assertEqual(index+1, len(all_types)) - - for index, (ecl_type, elem_size) in enumerate(test_base): - all_types.add(EclDataType(ecl_type, elem_size)) - - for index, ecl_type in enumerate(get_const_size_types()): - all_types.add(EclDataType(ecl_type)) - - self.assertEqual(len(test_base), len(all_types)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_util.py b/ThirdParty/Ert/python/tests/ecl/test_ecl_util.py deleted file mode 100644 index 497f52769c..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_util.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.ecl import EclGrid , EclUtil, EclTypeEnum , EclFileEnum, EclPhaseEnum, EclUnitTypeEnum -from ecl.test import ExtendedTestCase - - -class EclUtilTest(ExtendedTestCase): - - def test_enums(self): - source_file_path = "lib/include/ert/ecl/ecl_util.h" - self.assertEnumIsFullyDefined(EclFileEnum, "ecl_file_enum", source_file_path) - self.assertEnumIsFullyDefined(EclPhaseEnum, "ecl_phase_enum", source_file_path) - self.assertEnumIsFullyDefined(EclUnitTypeEnum, "ert_ecl_unit_enum", source_file_path) - - source_file_path = "lib/include/ert/ecl/ecl_type.h" - self.assertEnumIsFullyDefined(EclTypeEnum, "ecl_type_enum", source_file_path) - - def test_file_type(self): - file_type , fmt , report = EclUtil.inspectExtension("CASE.X0078") - self.assertEqual( file_type , EclFileEnum.ECL_RESTART_FILE ) - - def test_file_report_nr(self): - report_nr = EclUtil.reportStep("CASE.X0080") - self.assertEqual( report_nr , 80 ) - - with self.assertRaises(ValueError): - EclUtil.reportStep("CASE.EGRID") - diff --git a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py b/ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py deleted file mode 100644 index 9275c9a5dc..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py +++ /dev/null @@ -1,468 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from __future__ import print_function -from unittest import skipIf -import warnings - -from ecl.ecl import EclGrid, EclKW , EclRegion, EclDataType -from ecl.ecl.faults import FaultBlock, FaultBlockLayer, FaultBlockCell,FaultCollection -from ecl.geo import Polyline , CPolylineCollection -from ecl.test import ExtendedTestCase , TestAreaContext - - -class FaultBlockTest(ExtendedTestCase): - def setUp(self): - self.grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) ) - self.kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_INT ) - self.kw.assign( 1 ) - - reg = EclRegion( self.grid , False ) - - for k in range(self.grid.getNZ()): - reg.clear( ) - reg.select_kslice( k , k ) - self.kw.assign( k , mask = reg ) - self.kw[ k * self.grid.getNX() * self.grid.getNY() + 7] = 177 - - - - def test_fault_block(self): - grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) - kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT ) - kw.assign( 0 ) - for j in range(1,4): - for i in range(1,4): - g = i + j*grid.getNX() - kw[g] = 1 - - layer = FaultBlockLayer( grid , 0 ) - layer.scanKeyword( kw ) - block = layer[1] - - self.assertEqual( (2.50 , 2.50) , block.getCentroid() ) - self.assertEqual( len(block) , 9) - self.assertEqual( layer , block.getParentLayer() ) - - def test_get_ijk(self): - with TestAreaContext("python/fault_block_layer/neighbour") as work_area: - with open("kw.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 0 0\n") - fileH.write("1 2 2 0 3\n") - fileH.write("4 2 2 3 3\n") - fileH.write("4 4 4 0 0\n") - fileH.write("4 4 4 0 5\n") - fileH.write("/\n") - - kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - - grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - layer.loadKeyword( kw ) - - block = layer[0,0] - self.assertEqual( block.getBlockID() , 1 ) - - block = layer[2,2] - self.assertEqual( block.getBlockID() , 2 ) - - with self.assertRaises(ValueError): - layer[3,3] - - with self.assertRaises(IndexError): - layer[5,5] - - - - def test_neighbours(self): - - with TestAreaContext("python/fault_block_layer/neighbour") as work_area: - with open("kw.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 0 0\n") - fileH.write("1 2 2 0 3\n") - fileH.write("4 2 2 3 3\n") - fileH.write("4 4 4 0 0\n") - fileH.write("4 4 4 0 5\n") - fileH.write("/\n") - - kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - - grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - - layer.loadKeyword( kw ) - block1 = layer.getBlock( 1 ) - block2 = layer.getBlock( 2 ) - block3 = layer.getBlock( 3 ) - block4 = layer.getBlock( 4 ) - block5 = layer.getBlock( 5 ) - self.assertEqual( block1.getParentLayer() , layer ) - - #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {} - - neighbours = block1.getNeighbours() - self.assertEqual( len(neighbours) , 2) - self.assertTrue( block2 in neighbours ) - self.assertTrue( block4 in neighbours ) - - neighbours = block2.getNeighbours() - self.assertEqual( len(neighbours) , 3) - self.assertTrue( block1 in neighbours ) - self.assertTrue( block3 in neighbours ) - self.assertTrue( block4 in neighbours ) - - neighbours = block3.getNeighbours() - self.assertEqual( len(neighbours) , 1) - self.assertTrue( block2 in neighbours ) - - neighbours = block4.getNeighbours() - self.assertEqual( len(neighbours) , 2) - self.assertTrue( block1 in neighbours ) - self.assertTrue( block2 in neighbours ) - - neighbours = block5.getNeighbours() - self.assertEqual( len(neighbours) , 0) - - - - - def test_neighbours2(self): - nx = 8 - ny = 8 - nz = 1 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - with TestAreaContext("python/FaultBlocks/neighbours"): - with open("faultblock.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("3 3 3 3 2 2 2 2 \n") - fileH.write("3 3 3 3 2 2 2 2 \n") - fileH.write("3 3 3 3 2 2 2 2 \n") - fileH.write("3 3 3 3 2 2 2 2 \n") - fileH.write("/\n") - - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - with open("faults.grdecl" , "w") as f: - f.write("FAULTS\n") - f.write("\'FY\' 1 4 4 4 1 1 'Y' /\n") - f.write("\'FX\' 4 4 1 8 1 1 'X' /\n") - f.write("/") - - faults = FaultCollection( grid , "faults.grdecl") - layer.loadKeyword( kw ) - b1 = layer.getBlock( 1 ) - b2 = layer.getBlock( 2 ) - b3 = layer.getBlock( 3 ) - - nb = b1.getNeighbours() - self.assertTrue( b2 in nb ) - self.assertTrue( b3 in nb ) - - polylines1 = CPolylineCollection() - p1 = polylines1.createPolyline(name="P1") - p1.addPoint(4,0) - p1.addPoint(4,4) - p1.addPoint(4,8) - nb = b1.getNeighbours( polylines = polylines1 ) - self.assertFalse( b2 in nb ) - self.assertTrue( b3 in nb ) - - - polylines2 = CPolylineCollection() - p1 = polylines2.createPolyline(name="P2") - p1.addPoint(0,4) - p1.addPoint(4,4) - nb = b1.getNeighbours( polylines = polylines2 ) - self.assertTrue( b2 in nb ) - self.assertFalse( b3 in nb ) - - - - layer.addFaultBarrier( faults["FY"] ) - nb = b1.getNeighbours() - self.assertTrue( b2 in nb ) - self.assertFalse( b3 in nb ) - - layer.addFaultBarrier( faults["FX"] ) - nb = b1.getNeighbours() - self.assertEqual( len(nb) , 0 ) - - - def test_neighbours3(self): - nx = 8 - ny = 8 - nz = 1 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - with TestAreaContext("python/FaultBlocks/neighbours"): - with open("faultblock.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("/\n") - - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - with open("faults.grdecl" , "w") as f: - f.write("FAULTS\n") - f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") - f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") - f.write("/") - - faults = FaultCollection( grid , "faults.grdecl") - layer.loadKeyword( kw ) - b1 = layer.getBlock( 1 ) - b2 = layer.getBlock( 2 ) - - nb = b1.getNeighbours() - self.assertTrue( b2 in nb ) - - layer.addFaultBarrier( faults["FX"] , link_segments = False) - nb = b1.getNeighbours() - self.assertTrue( b2 in nb ) - - - - - - - - def test_fault_block_edge(self): - grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) - kw = EclKW( "FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT ) - kw.assign( 0 ) - for j in range(1,4): - for i in range(1,4): - g = i + j*grid.getNX() - kw[g] = 1 - - layer = FaultBlockLayer( grid , 0 ) - #with self.assertRaises: - # layer.getEdgePolygon( ) - - - - def test_fault_block_layer(self): - with self.assertRaises(ValueError): - layer = FaultBlockLayer( self.grid , -1 ) - - with self.assertRaises(ValueError): - layer = FaultBlockLayer( self.grid , self.grid.getGlobalSize() ) - - layer = FaultBlockLayer( self.grid , 1 ) - self.assertEqual( 1 , layer.getK() ) - - kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) - with self.assertRaises(ValueError): - layer.scanKeyword( kw ) - - layer.scanKeyword( self.kw ) - self.assertEqual( 2 , len(layer) ) - - with self.assertRaises(TypeError): - ls = layer["JJ"] - - l = [] - for blk in layer: - l.append( blk ) - self.assertEqual( len(l) , 2 ) - - l0 = layer[0] - l1 = layer[1] - self.assertTrue( isinstance(l1 , FaultBlock )) - l0.getCentroid() - l1.getBlockID() - - with self.assertRaises(IndexError): - l2 = layer[2] - - - self.assertEqual( True , 1 in layer) - self.assertEqual( True , 2 in layer) - self.assertEqual( False , 77 in layer) - self.assertEqual( False , 177 in layer) - - l1 = layer.getBlock( 1 ) - self.assertTrue( isinstance(l1 , FaultBlock )) - - with self.assertRaises(KeyError): - l =layer.getBlock(66) - - with self.assertRaises(KeyError): - layer.deleteBlock(66) - - layer.deleteBlock(2) - self.assertEqual( 1 , len(layer)) - blk = layer[0] - self.assertEqual( blk.getBlockID() , 1 ) - - with self.assertRaises(KeyError): - layer.addBlock(1) - - blk2 = layer.addBlock(2) - self.assertEqual( len(layer) , 2 ) - - blk3 = layer.addBlock() - self.assertEqual( len(layer) , 3 ) - - - layer.addBlock(100) - layer.addBlock(101) - layer.addBlock(102) - layer.addBlock(103) - - layer.deleteBlock(2) - blk1 = layer.getBlock( 103 ) - blk2 = layer[-1] - self.assertEqual( blk1.getBlockID() , blk2.getBlockID() ) - - fault_block = layer[0] - fault_block.assignToRegion( 2 ) - self.assertEqual( [2] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 2 ) - self.assertEqual( [2] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 3 ) - self.assertEqual( [2,3] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 1 ) - self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 2 ) - self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) - - - def test_add_polyline_barrier1(self): - grid = EclGrid.createRectangular( (4,1,1) , (1,1,1) ) - layer = FaultBlockLayer( self.grid , 0 ) - polyline = Polyline( init_points = [ (1.99 , 0.001) , (2.01 , 0.99)]) - - points = [((1,0) , (2,0))] - - geo_layer = layer.getGeoLayer() - for p1,p2 in points: - self.assertTrue(geo_layer.cellContact( p1 , p2 )) - - layer.addPolylineBarrier( polyline ) - for p1,p2 in points: - print(p1,p2) - self.assertFalse(geo_layer.cellContact( p1 , p2 )) - - - - def test_add_polyline_barrier2(self): - grid = EclGrid.createRectangular( (10,10,1) , (1,1,1) ) - layer = FaultBlockLayer( self.grid , 0 ) - polyline = Polyline( init_points = [ (0.1 , 0.9) , (8.9,0.9) , (8.9,8.9) ]) - - points = [((0,0) , (0,1)), - ((2,0) , (2,1)), - ((4,0) , (4,1)), - ((6,0) , (6,1)), - ((8,0) , (8,1)), - # - ((8,1) , (9,1)), - ((8,3) , (9,3)), - ((8,5) , (9,5)), - ((8,7) , (9,7))] - - geo_layer = layer.getGeoLayer() - for p1,p2 in points: - self.assertTrue(geo_layer.cellContact( p1 , p2 )) - - layer.addPolylineBarrier( polyline ) - for p1,p2 in points: - print(p1,p2) - self.assertFalse(geo_layer.cellContact( p1 , p2 )) - - - - - - - def test_fault_block_layer_export(self): - layer = FaultBlockLayer( self.grid , 1 ) - kw1 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() + 1 , EclDataType.ECL_INT ) - with self.assertRaises(ValueError): - layer.exportKeyword( kw1 ) - - kw2 = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) - with self.assertRaises(TypeError): - layer.exportKeyword(kw2) - - - def test_internal_blocks(self): - nx = 8 - ny = 8 - nz = 1 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - with TestAreaContext("python/FaultBlocks/internal_blocks"): - with open("faultblock.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 4 4 1 2 5 5 2 \n") - fileH.write("1 4 4 1 2 5 5 2 \n") - fileH.write("1 1 1 1 2 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("1 1 3 1 1 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("1 1 1 1 1 2 2 2 \n") - fileH.write("/\n") - - - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - with open("faults.grdecl" , "w") as f: - f.write("FAULTS\n") - f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") - f.write("\'FX\' 5 5 4 4 1 1 'Y' /\n") - f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") - f.write("/") - - faults = FaultCollection( grid , "faults.grdecl") - - layer.loadKeyword( kw ) - layer.addFaultBarrier( faults["FX"] ) - b1 = layer.getBlock( 1 ) - b2 = layer.getBlock( 2 ) - b3 = layer.getBlock( 3 ) - b4 = layer.getBlock( 4 ) - b5 = layer.getBlock( 5 ) - - - nb = b1.getNeighbours() - for b in nb: - print('Block:%d' % b.getBlockID()) - - self.assertTrue( len(nb) == 2 ) - self.assertTrue( b3 in nb ) - self.assertTrue( b4 in nb ) - - nb = b2.getNeighbours() - self.assertTrue( len(nb) == 1 ) - self.assertTrue( b5 in nb ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py deleted file mode 100644 index 8be7f2fc0a..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -from ecl.ecl import EclGrid, EclDataType , EclKW -from ecl.test import ExtendedTestCase -from ecl.ecl.faults import FaultBlock, FaultBlockLayer - -class FaultBlockTest(ExtendedTestCase): - def setUp(self): - self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID")) - fileH = open( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) - self.kw = EclKW.read_grdecl( fileH , "FAULTBLK" , ecl_type = EclDataType.ECL_INT ) - - - - def test_load(self): - for k in range(self.grid.getNZ()): - faultBlocks = FaultBlockLayer(self.grid , k) - faultBlocks.scanKeyword( self.kw ) - for block in faultBlocks: - centroid = block.getCentroid() - diff --git a/ThirdParty/Ert/python/tests/ecl/test_faults.py b/ThirdParty/Ert/python/tests/ecl/test_faults.py deleted file mode 100644 index aa73ceae9f..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_faults.py +++ /dev/null @@ -1,796 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from unittest import skipIf -import time -from ecl import util - -from ecl.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment,FaultBlockLayer -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.geo import Polyline , CPolyline - - -class FaultTest(ExtendedTestCase): - @classmethod - def setUpClass(cls): - cls.grid = EclGrid.createRectangular( (151,100,50) , (1,1,1)) - - def setUp(self): - self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") - self.faults2 = self.createTestPath("local/ECLIPSE/FAULTS/fault2.grdecl") - - - def test_PolylineIJ(self): - nx = 10 - ny = 10 - nz = 10 - grid = EclGrid.createRectangular( (nx,ny,nz) , (0.1,0.1,0.1)) - f = Fault(grid , "F") - f.addRecord(0 , 1 , 0 , 0 , 0,0 , "Y-") - f.addRecord(2 , 2 , 0 , 1 , 0,0 , "X-") - f.addRecord(2 , 2 , 1 , 1 , 0,0 , "Y") - - pl = f.getIJPolyline( 0 ) - self.assertEqual(pl , [(0,0) , (2,0) , (2,2) , (3,2)]) - - - def test_empty_collection(self): - faults = FaultCollection() - self.assertEqual(0 , len(faults)) - - self.assertFalse( faults.hasFault("FX") ) - - with self.assertRaises(TypeError): - f = faults[ [] ] - - with self.assertRaises(KeyError): - f = faults["FX"] - - with self.assertRaises(IndexError): - f = faults[0] - - self.assertFalse( "NAME" in faults ) - - def test_collection_invalid_arg(self): - with self.assertRaises(ValueError): - faults = FaultCollection(self.faults1) - - with self.assertRaises(ValueError): - faults = FaultCollection(self.faults1 , self.faults2) - - - - def test_splitLine(self): - faults = FaultCollection(self.grid) - with self.assertRaises(ValueError): - # Not slash terminated - t = faults.splitLine("'F1' 149 149 29 29 1 43 'Y'") - - with self.assertRaises(ValueError): - # Not integer - t = faults.splitLine("'F1' 149 149 29 29 1 43X 'Y' /") - - with self.assertRaises(ValueError): - # Missing item - t = faults.splitLine("'F1' 149 29 29 1 43 'Y' /") - - with self.assertRaises(ValueError): - # Quote fuckup - t = faults.splitLine("'F1 149 149 29 29 1 43 'X' /") - - - def test_empty_fault( self ): - f = Fault(self.grid , "NAME") - self.assertEqual("NAME" , f.getName()) - - with self.assertRaises(Exception): - g = f["Key"] - - - def test_empty_faultLine(self): - fl = FaultLine(self.grid , 10) - self.assertEqual( 10 , fl.getK()) - self.assertEqual( 0 , len(fl) ) - - with self.assertRaises(TypeError): - f = fl[ "Test" ] - - with self.assertRaises(IndexError): - f = fl[0] - - - - def test_faultLine_center(self): - nx = 10 - ny = 10 - nz = 2 - grid = EclGrid.createRectangular( (nx,ny,nz) , (0.1,0.1,0.1)) - fl = FaultLine(grid , 0) - C1 = (nx + 1) * 5 + 3 - C2 = C1 + 2 - C3 = C2 + 2 - - s1 = FaultSegment( C1 , C2 ) - s2 = FaultSegment( C2 , C3 ) - - fl.tryAppend( s1 ) - fl.tryAppend( s2 ) - - self.assertEqual( len(fl) , 2 ) - self.assertEqual( fl.center() , (0.50 , 0.50) ) - - - - def test_faultLine(self): - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(0 , 10) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - S3 = FaultSegment(20 , 30) - fl.tryAppend( S3 ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(0 , 10) - S2 = FaultSegment(20 , 10) - fl.tryAppend( S1 ) - self.assertTrue( fl.tryAppend( S2 ) ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(20 , 10) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - S3 = FaultSegment(40 , 30) - self.assertTrue( fl.tryAppend(S3) == False ) - self.assertEqual( len(fl) , 2 ) - - pl = fl.getPolyline( ) - self.assertIsInstance( pl , CPolyline ) - self.assertEqual( len(pl) , len(fl) + 1 ) - - S3 = FaultSegment(20 , 30) - fl.tryAppend( S3 ) - pl = fl.getPolyline( ) - self.assertIsInstance( pl , CPolyline ) - self.assertEqual( len(pl) , len(fl) + 1 ) - - - - - def test_load(self): - faults = FaultCollection(self.grid , self.faults1) - self.assertEqual( 3 , len(faults)) - faults.load( self.grid , self.faults2 ) - self.assertEqual( 7 , len(faults)) - fault1 = faults["F1"] - layer8 = fault1[8] - self.assertEqual( len(layer8) , 1 ) - - with self.assertRaises(IOError): - faults.load(self.grid , "No/this/does/not/exist") - - - def test_connect_faults(self): - grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) - - # Fault1 Fault4 - # | | - # | | - # | | - # | ------- Fault2 | - # | | - # | | - # - # -------- Fault3 - # - - fault1 = Fault(grid , "Fault1") - fault2 = Fault(grid , "Fault2") - fault3 = Fault(grid , "Fault3") - fault4 = Fault(grid , "Fault4") - - fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") - fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") - fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - - - for other_fault in [fault2 , fault3,fault4]: - with self.assertRaises(ValueError): - fault1.extendToFault( other_fault ,0) - - with self.assertRaises(ValueError): - fault2.extendToFault( fault3 , 0) - - for other_fault in [fault1 , fault2,fault4]: - with self.assertRaises(ValueError): - fault3.extendToFault( other_fault ,0 ) - - for other_fault in [fault1 , fault2,fault3]: - with self.assertRaises(ValueError): - fault4.extendToFault( other_fault , 0) - - ext21 = fault2.extendToFault( fault1 , 0) - self.assertEqual(len(ext21) , 2) - p0 = ext21[0] - p1 = ext21[1] - self.assertEqual(p0 , (5 , 16)) - self.assertEqual(p1 , (2 , 16)) - - - ext24 = fault2.extendToFault( fault4,0 ) - self.assertEqual(len(ext24) , 2) - p0 = ext24[0] - p1 = ext24[1] - self.assertEqual(p0 , (11 , 16)) - self.assertEqual(p1 , (21 , 16)) - - - def test_intersect_intRays(self): - p1 = (0,0) - dir1 = (1,0) - p2 = (0,0) - dir2 = (0,1) - - line = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - self.assertEqual( line , [] ) - - # Opposite direction - p3 = (-1,0) - dir3 = (-1,0) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p3,dir3)) - - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p3,dir3),(p1,dir1)) - - # Parallell with offset - p4 = (0,1) - dir4 = (1,0) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p4,dir4)) - - p5 = (0,1) - dir5 = (-1,0) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p5,dir5)) - - p6 = (1,1) - dir6 = (1,0) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p6,dir6)) - - p2 = (-1,0) - dir2 = (-1,0) - join = Fault.intersectFaultRays(( p2,dir1),(p1,dir2)) - self.assertEqual( join , [p2 , p1]) - - join = Fault.intersectFaultRays(( p1,dir3),(p3,dir1)) - self.assertEqual( join , [p1 , p3]) - - p2 = (1,0) - dir2 = (1,0) - join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2)) - self.assertEqual( join , [p1 , p2]) - - # Orthogonal - p2 = (1,1) - dir2 = (0,1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (0,1) - dir2 = (0,1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (-1,0) - dir2 = (0,1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (-1,1) - dir2 = (0,1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (-1,1) - dir2 = (0,-1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (3,-1) - dir2 = (0,-1) - with self.assertRaises(ValueError): - Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - - p2 = (1,-1) - dir2 = (0,1) - join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - self.assertEqual(join , [p1 , (1,0) , p2]) - - p2 = (1,1) - dir2 = (0,-1) - join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - self.assertEqual(join , [p1 , (1,0) , p2]) - - p2 = (0,3) - dir2 = (0,-1) - join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - self.assertEqual(join , [p1 , p2]) - - p2 = (3,0) - dir2 = (0,-1) - join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) - self.assertEqual(join , [p1 , p2]) - - - def test_join_faults(self): - grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) - - # Fault1 Fault4 - # | | - # | | - # | | - # | ------- Fault2 | - # | | - # | | - # - # -------- Fault3 - # - - fault1 = Fault(grid , "Fault1") - fault2 = Fault(grid , "Fault2") - fault3 = Fault(grid , "Fault3") - fault4 = Fault(grid , "Fault4") - - fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") - fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") - fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - - rays = fault1.getEndRays(0) - self.assertEqual( rays[0] , [(2,10) , (0,-1)]) - self.assertEqual( rays[1] , [(2,100) , (0,1)]) - - extra = Fault.joinFaults( fault1 , fault3 , 0) - self.assertEqual( extra , [(2,10) , (2,6) , (5,6)] ) - - - def test_contact(self): - grid = EclGrid.createRectangular( (100,100,10) , (1,1,1)) - - # Fault1 Fault4 - # | | - # | | - # | | - # | ----------------------+-- Fault2 - # | | - # | | - # - # -------- Fault3 - # - - fault1 = Fault(grid , "Fault1") - fault2 = Fault(grid , "Fault2") - fault3 = Fault(grid , "Fault3") - fault4 = Fault(grid , "Fault4") - - fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - fault2.addRecord(5 , 30 , 15 , 15 , 0 , 0 , "Y") - fault3.addRecord(2 , 10 , 9 , 9 , 0 , 0 , "Y") - fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - - #self.assertFalse( fault1.intersectsFault(fault2 , 0) ) - #self.assertFalse( fault2.intersectsFault(fault1 , 0) ) - - #self.assertTrue( fault2.intersectsFault(fault4 , 0) ) - #self.assertTrue( fault4.intersectsFault(fault2 , 0) ) - - self.assertTrue( fault1.intersectsFault(fault1 , 0) ) - #self.assertTrue( fault3.intersectsFault(fault3 , 0) ) - - - - def test_iter(self): - faults = FaultCollection(self.grid , self.faults1 , self.faults2) - self.assertEqual( 7 , len(faults)) - c = 0 - for f in faults: - c += 1 - self.assertEqual( c , len(faults)) - - for f in ["F1","F2","F3" ,"F4"]: - self.assertTrue( f in faults ) - - self.assertFalse("FX" in faults ) - - - - def test_fault(self): - f = Fault(self.grid , "NAME") - - with self.assertRaises(ValueError): - # Invalid face - f.addRecord( 10 , 10 , 11 , 11 , 1 , 43 , "F") - - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( -1 , 10 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10000 , 10 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") - - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates/face combination - f.addRecord( 10 , 11 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates/face combination - f.addRecord( 10 , 11 , 11 , 12 , 1 , 43 , "Y") - - f.addRecord(10 , 10 , 0 , 10 , 1 , 10 , "X") - - - def test_segment(self ): - s0 = FaultSegment(0 , 10) - self.assertEqual(s0.getC1() , 0 ) - self.assertEqual(s0.getC2() , 10 ) - - s0.swap() - self.assertEqual(s0.getC1() , 10 ) - self.assertEqual(s0.getC2() , 0 ) - - - - - def test_fault_line(self ): - faults = FaultCollection(self.grid , self.faults1 , self.faults2) - for fault in faults: - for layer in fault: - for fl in layer: - fl.verify() - - - def test_fault_line_order(self): - nx = 120 - ny = 60 - nz = 43 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - with TestAreaContext("python/faults/line_order"): - with open("faults.grdecl" , "w") as f: - f.write("""FAULTS -\'F\' 105 107 50 50 1 43 \'Y\' / -\'F\' 108 108 50 50 1 43 \'X\' / -\'F\' 108 108 50 50 22 43 \'Y\' / -\'F\' 109 109 49 49 1 43 \'Y\' / -\'F\' 110 110 49 49 1 43 \'X\' / -\'F\' 111 111 48 48 1 43 \'Y\' / -/ -""") - faults = FaultCollection( grid , "faults.grdecl" ) - - fault = faults["F"] - layer = fault[29] - self.assertEqual(len(layer) , 2) - - line1 = layer[0] - line2 = layer[1] - self.assertEqual(len(line1) , 4) - self.assertEqual(len(line2) , 2) - - seg0 = line1[0] - seg1 = line1[1] - seg2 = line1[2] - seg3 = line1[3] - self.assertEqual( seg0.getCorners() , (50 * (nx + 1) + 104 , 50 * (nx + 1) + 107)) - self.assertEqual( seg1.getCorners() , (50 * (nx + 1) + 107 , 50 * (nx + 1) + 108)) - self.assertEqual( seg2.getCorners() , (50 * (nx + 1) + 108 , 49 * (nx + 1) + 108)) - self.assertEqual( seg3.getCorners() , (49 * (nx + 1) + 108 , 49 * (nx + 1) + 109)) - - - - - - def test_neighbour_cells(self): - nx = 10 - ny = 8 - nz = 7 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") - faults = FaultCollection( grid , faults_file ) - - fault = faults["FY"] - self.assertEqual(len(fault),1) - fault_layer = fault[0] - - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(0, nx) , (1,nx + 1), (2,nx+2) , (3,nx + 3) , (4,nx+4)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fl2 = fault_layer[1] - nb_cells2 = fl2.getNeighborCells() - true_nb_cells2 = [(6, nx+6) , (7,nx + 7), (8 , nx+8) , (9,nx + 9)] - self.assertListEqual( nb_cells2 , true_nb_cells2 ) - - nb_cells = fault_layer.getNeighborCells() - self.assertListEqual( nb_cells , true_nb_cells1 + true_nb_cells2) - - - fault = faults["FY0"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(-1,0) , (-1,1), (-1,2)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - - fault = faults["FYNY"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(nx * (ny - 1) , -1), (nx * (ny - 1) + 1 , -1), (nx * (ny - 1) + 2, -1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fault = faults["FX"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(0,1) , (nx , nx+1) , (2*nx , 2*nx + 1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - - fault = faults["FX0"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(-1 , 0) , (-1 , nx) , (-1 , 2*nx)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fault = faults["FXNX"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(nx -1 , -1) , (2*nx -1 , -1) , (3*nx - 1 , -1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - - def test_polyline_intersection(self): - grid = EclGrid.createRectangular( (100,100,10) , (0.25 , 0.25 , 1)) - - # Fault1 Fault4 - # | | - # | | - # | | - # | ------- Fault2 | - # | | - # | | - # (5 , 2.50) - # -------- Fault3 - # - - fault1 = Fault(grid , "Fault1") - fault2 = Fault(grid , "Fault2") - fault3 = Fault(grid , "Fault3") - fault4 = Fault(grid , "Fault4") - - fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") - fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") - fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") - - - polyline = Polyline( init_points = [(4 , 4) , (8,4)]) - self.assertTrue( fault4.intersectsPolyline( polyline , 0)) - - cpolyline = CPolyline( init_points = [(4 , 4) , (8,4)]) - self.assertTrue( fault4.intersectsPolyline( cpolyline , 0)) - - polyline = Polyline( init_points = [(8 , 4) , (16,4)]) - self.assertFalse( fault4.intersectsPolyline( polyline , 0)) - - cpolyline = CPolyline( init_points = [(8 , 4) , (16,4)]) - self.assertFalse( fault4.intersectsPolyline( cpolyline , 0)) - - - def test_num_linesegment(self): - nx = 10 - ny = 10 - nz = 1 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - with TestAreaContext("python/faults/line_order"): - with open("faults.grdecl" , "w") as f: - f.write("""FAULTS -\'F1\' 1 4 2 2 1 1 \'Y\' / -\'F1\' 6 8 2 2 1 1 \'Y\' / -\'F2\' 1 8 2 2 1 1 \'Y\' / -/ -""") - faults = FaultCollection( grid , "faults.grdecl" ) - - f1 = faults["F1"] - f2 = faults["F2"] - self.assertEqual( 2 , f1.numLines(0)) - self.assertEqual( 1 , f2.numLines(0)) - - - def test_extend_to_polyline(self): - grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1)) - - # o o o o - # - # o---o---o---o - # - # o===+ o o - # | - # o o o o - - fault1 = Fault(grid , "Fault") - - fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "X-") - fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "Y") - - polyline = CPolyline( init_points = [(0,2) , (3,2)]) - points = fault1.extendToPolyline( polyline , 0 ) - self.assertEqual( points , [(1,1) , (2,2)]) - - end_join = fault1.endJoin( polyline , 0 ) - self.assertEqual( end_join, [(1,1) , (0,2)] ) - - polyline2 = CPolyline( init_points = [(0.8,2) , (0.8,0.8)]) - end_join = fault1.endJoin( polyline2 , 0 ) - self.assertIsNone( end_join ) - - - def test_extend_polyline_on(self): - grid = EclGrid.createRectangular( (3,3,1) , (1 , 1 , 1)) - - # o o o o - # - # o---o---o---o - # - # o===o===o===o - # - # o o o o - - fault1 = Fault(grid , "Fault") - fault1.addRecord(0 , 2 , 0 , 0 , 0 , 0 , "Y") - - polyline0 = CPolyline( init_points = [(0,2)]) - polyline1 = CPolyline( init_points = [(0,2) , (3,2)]) - polyline2 = CPolyline( init_points = [(1,3) , (1,2)]) - polyline3 = CPolyline( init_points = [(1,3) , (1,0)]) - - with self.assertRaises(ValueError): - fault1.extendPolylineOnto( polyline0 , 0 ) - - points = fault1.extendPolylineOnto( polyline1 , 0 ) - self.assertIsNone( points ) - - points = fault1.extendPolylineOnto( polyline2 , 0) - self.assertEqual( points , [(1,2) , (1,1)]) - - points = fault1.extendPolylineOnto( polyline3 , 0) - self.assertIsNone( points ) - - - def test_stepped(self): - grid = EclGrid.createRectangular( (6,1,4) , (1,1,1)) - f = Fault(grid , "F") - f.addRecord(4,4,0,0,0,1,"X") - f.addRecord(2,2,0,0,1,1,"Z") - f.addRecord(1,1,0,0,2,3,"X") - - block_kw = EclKW("FAULTBLK" , grid.getGlobalSize() , EclDataType.ECL_INT) - block_kw.assign(1) - block_kw[5] = 2 - block_kw[11] = 2 - block_kw[14:18] = 2 - block_kw[14:18] = 2 - block_kw[20:23] = 2 - - layer0 = FaultBlockLayer( grid , 0 ) - layer0.scanKeyword( block_kw ) - layer0.addFaultBarrier( f ) - self.assertTrue( layer0.cellContact((0,0) , (1,0))) - self.assertFalse( layer0.cellContact((4,0) , (5,0))) - - layer1 = FaultBlockLayer( grid , 1 ) - layer1.scanKeyword( block_kw ) - layer1.addFaultBarrier( f ) - self.assertTrue( layer1.cellContact((0,0) , (1,0))) - self.assertFalse( layer1.cellContact((4,0) , (5,0))) - - layer2 = FaultBlockLayer( grid , 2 ) - layer2.scanKeyword( block_kw ) - layer2.addFaultBarrier( f ) - self.assertTrue( layer2.cellContact((0,0) , (1,0))) - self.assertFalse( layer2.cellContact((1,0) , (2,0))) - - layer3 = FaultBlockLayer( grid , 3 ) - layer3.scanKeyword( block_kw ) - layer3.addFaultBarrier( f ) - self.assertTrue( layer3.cellContact((0,0) , (1,0))) - self.assertFalse( layer3.cellContact((1,0) , (2,0))) - - - - def test_connectWithPolyline(self): - grid = EclGrid.createRectangular( (4,4,1) , (1 , 1 , 1)) - - - # o o o o o - # - # o o o o o - # - # o---o---o---o---o - # - # o o o o o - # | - # o o o o o - - fault1 = Fault(grid , "Fault1") - fault1.addRecord(0 , 3 , 1 , 1 , 0 , 0 , "Y") - - fault2 = Fault(grid , "Fault2") - fault2.addRecord(1 , 1 , 0 , 0 , 0 , 0 , "X") - - fault3 = Fault(grid , "Fault3") - fault3.addRecord(1 , 1 , 0 , 2 , 0 , 0 , "X") - - self.assertIsNone( fault3.connect( fault1 , 0 )) - - - intersect = fault2.connect( fault1 , 0 ) - self.assertEqual( len(intersect) , 2 ) - p1 = intersect[0] - p2 = intersect[1] - - self.assertEqual( p1 , (2,1)) - self.assertEqual( p2 , (2,2)) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py b/ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py deleted file mode 100644 index b3d48befea..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'test_ecl_cell_containment.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.ecl import EclGrid -from ecl.test import ExtendedTestCase, TestAreaContext - -class FKTest(ExtendedTestCase): - - def test_cell_containment(self): - - grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID" - well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt" - - for i in range(1, 8): - grid_file = self.createTestPath(grid_location % i) - well_file = self.createTestPath(well_location % i) - - grid = EclGrid(grid_file) - - # Load well data - with open(well_file, "r") as f: - lines = [line.split() for line in f.readlines()] - - points = [map(float, line[:3:]) for line in lines] - exp_cells = [tuple(map(int, line[3::])) for line in lines] - - msg = "Expected point %s to be in cell %s, was in %s." - for point, exp_cell in zip(points, exp_cells): - reported_cell = grid.find_cell(*point) - self.assertEqual( - exp_cell, - reported_cell, - msg % (str(point), str(exp_cell), str(reported_cell)) - ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_fortio.py b/ThirdParty/Ert/python/tests/ecl/test_fortio.py deleted file mode 100644 index 01e51ff3d3..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_fortio.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os -from random import randint -from ecl.ecl import FortIO, EclDataType, EclKW , openFortIO, EclFile -from ecl.test import ExtendedTestCase, TestAreaContext - - - - -class FortIOTest(ExtendedTestCase): - - - - - def test_open_write(self): - with TestAreaContext("python/fortio/write"): - f = FortIO("newfile", FortIO.WRITE_MODE) - self.assertTrue(os.path.exists("newfile")) - - def test_noex(self): - with self.assertRaises(IOError): - f = FortIO("odes_not_exist", FortIO.READ_MODE) - - def test_kw(self): - kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) - - kw1[0] = 99 - kw1[1] = 77 - kw2[0] = 113 - kw2[1] = 335 - - with TestAreaContext("python/fortio/write-kw"): - f = FortIO("test", FortIO.WRITE_MODE, fmt_file=False) - kw1.fwrite(f) - - f = FortIO("test", FortIO.APPEND_MODE) - kw2.fwrite(f) - - f = FortIO("test", fmt_file=False) - k1 = EclKW.fread(f) - k2 = EclKW.fread(f) - - self.assertTrue(k1.equal(kw1)) - self.assertTrue(k2.equal(kw2)) - - - def test_truncate(self): - kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) - - kw1[0] = 99 - kw1[1] = 77 - kw2[0] = 113 - kw2[1] = 335 - - with TestAreaContext("python/fortio/ftruncate") as t: - with openFortIO("file" , mode = FortIO.WRITE_MODE) as f: - kw1.fwrite(f) - pos1 = f.getPosition( ) - kw2.fwrite(f) - - t.sync( ) - # Truncate file in read mode; should fail hard. - with openFortIO("file") as f: - with self.assertRaises(IOError): - f.truncate( ) - - - with openFortIO("file" , mode = FortIO.READ_AND_WRITE_MODE) as f: - f.seek( pos1 ) - f.truncate( ) - - - f = EclFile("file") - self.assertEqual( len(f) , 1) - kw1_ = f[0] - self.assertEqual( kw1 , kw1_) - - - - def test_fortio_creation(self): - with TestAreaContext("python/fortio/create"): - w = FortIO("test", FortIO.WRITE_MODE) - rw = FortIO("test", FortIO.READ_AND_WRITE_MODE) - r = FortIO("test", FortIO.READ_MODE) - a = FortIO("test", FortIO.APPEND_MODE) - - w.close() - w.close() # should not fail - - - - - - def test_context(self): - with TestAreaContext("python/fortio/context") as t: - kw1 = EclKW("KW" , 2456 , EclDataType.ECL_FLOAT) - for i in range(len(kw1)): - kw1[i] = randint(0,1000) - - with openFortIO("file" , mode = FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - self.assertEqual( f.filename() , "file") - - t.sync( ) - - with openFortIO("file") as f: - kw2 = EclKW.fread( f ) - - self.assertTrue( kw1 == kw2 ) - - - def test_is_fortran_file(self): - with TestAreaContext("python/fortio/guess"): - kw1 = EclKW("KW" , 12345 , EclDataType.ECL_FLOAT) - with openFortIO("fortran_file" , mode = FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - - with open("text_file" , "w") as f: - kw1.write_grdecl( f ) - - self.assertTrue( FortIO.isFortranFile( "fortran_file" )) - self.assertFalse( FortIO.isFortranFile( "text_file" )) diff --git a/ThirdParty/Ert/python/tests/ecl/test_geertsma.py b/ThirdParty/Ert/python/tests/ecl/test_geertsma.py deleted file mode 100644 index 5ff2850716..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_geertsma.py +++ /dev/null @@ -1,144 +0,0 @@ -import datetime -from ecl.ecl import EclGrid, EclKW, EclDataType, openFortIO, FortIO, EclFile, EclSubsidence - -from ecl.test import ExtendedTestCase , TestAreaContext - -import numpy as np - - -def create_init(grid, case): - poro = EclKW("PORO", grid.getNumActive(), EclDataType.ECL_FLOAT) - porv = poro.copy() - porv.setName("PORV") - for g in range(grid.getGlobalSize()): - porv[g] *= grid.cell_volume(global_index=g) - - with openFortIO("%s.INIT" % case, mode=FortIO.WRITE_MODE) as f: - poro.fwrite(f) - porv.fwrite(f) - - -def create_restart(grid, case, p1, p2=None): - with openFortIO("%s.UNRST" % case, mode=FortIO.WRITE_MODE) as f: - seq_hdr = EclKW("SEQNUM", 1, EclDataType.ECL_FLOAT) - seq_hdr[0] = 10 - p = EclKW("PRESSURE", grid.getNumActive(), EclDataType.ECL_FLOAT) - for i in range(len(p1)): - p[i] = p1[i] - - header = EclKW("INTEHEAD", 67, EclDataType.ECL_INT) - header[64] = 1 - header[65] = 1 - header[66] = 2000 - - seq_hdr.fwrite(f) - header.fwrite(f) - p.fwrite(f) - - if p2: - seq_hdr[0] = 20 - header[66] = 2010 - for i in range(len(p2)): - p[i] = p2[i] - - seq_hdr.fwrite(f) - header.fwrite(f) - p.fwrite(f) - - -class GeertsmaTest(ExtendedTestCase): - - @staticmethod - def test_geertsma_kernel(): - grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) - with TestAreaContext("Subsidence"): - p1 = [1] - create_restart(grid, "TEST", p1) - create_init(grid, "TEST") - - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") - - restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - - subsidence = EclSubsidence(grid, init) - subsidence.add_survey_PRESSURE("S1", restart_view1) - - youngs_modulus = 5E8 - poisson_ratio = 0.3 - seabed = 0 - above = 100 - topres = 2000 - receiver = (1000, 1000, 0) - - dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz, 3.944214576168326e-09) - - receiver = (1000, 1000, topres - seabed - above) - - dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz, 5.8160298201497136e-08) - - @staticmethod - def test_geertsma_kernel_2_source_points_2_vintages(): - grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) - - with TestAreaContext("Subsidence"): - p1 = [1, 10] - p2 = [10, 20] - create_restart(grid, "TEST", p1, p2) - create_init(grid, "TEST") - - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") - - restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1)) - - subsidence = EclSubsidence(grid, init) - subsidence.add_survey_PRESSURE("S1", restart_view1) - subsidence.add_survey_PRESSURE("S2", restart_view2) - - youngs_modulus = 5E8 - poisson_ratio = 0.3 - seabed = 0 - receiver = (1000, 1000, 0) - - dz1 = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz1, 8.65322541521704e-07) - - dz2 = subsidence.evalGeertsma("S2", None, receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz2, 2.275556615015282e-06) - - np.testing.assert_almost_equal(dz1-dz2, -1.4102340734935779e-06) - - dz = subsidence.evalGeertsma("S1", "S2", receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz, dz1-dz2) - - @staticmethod - def test_geertsma_kernel_seabed(): - grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) - with TestAreaContext("Subsidence"): - p1 = [1] - create_restart(grid, "TEST", p1) - create_init(grid, "TEST") - - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") - - restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - - subsidence = EclSubsidence(grid, init) - subsidence.add_survey_PRESSURE("S1", restart_view1) - - youngs_modulus = 5E8 - poisson_ratio = 0.3 - seabed = 300 - above = 100 - topres = 2000 - receiver = (1000, 1000, topres - seabed - above) - - dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) - np.testing.assert_almost_equal(dz, 5.819790154474284e-08) - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_grav.py b/ThirdParty/Ert/python/tests/ecl/test_grav.py deleted file mode 100644 index 3772db8448..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_grav.py +++ /dev/null @@ -1,25 +0,0 @@ -import time -from ecl.ecl import EclGrav, EclKW, EclGrid, EclFile, EclDataType, openFortIO, FortIO -from ecl.test import ExtendedTestCase , TestAreaContext - - -class EclGravTest(ExtendedTestCase): - - - def setUp(self): - self.grid = EclGrid.createRectangular( (10,10,10) , (1,1,1)) - - - def test_create(self): - # The init file created here only contains a PORO field. More - # properties must be added to this before it can be used for - # any usefull gravity calculations. - poro = EclKW( "PORO" , self.grid.getGlobalSize() , EclDataType.ECL_FLOAT ) - with TestAreaContext("grav_init"): - with openFortIO( "TEST.INIT" , mode = FortIO.WRITE_MODE ) as f: - poro.fwrite( f ) - self.init = EclFile( "TEST.INIT") - - grav = EclGrav( self.grid , self.init ) - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_grdecl.py b/ThirdParty/Ert/python/tests/ecl/test_grdecl.py deleted file mode 100644 index 7c6b1b05c6..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_grdecl.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -from ecl.ecl import EclKW,EclGrid,Ecl3DKW -from ecl.test import ExtendedTestCase - - - - - -class GRDECLTest(ExtendedTestCase): - def setUp(self): - self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") - self.file_list = [] - - def addFile(self, filename): - self.file_list.append(filename) - - def tearDown(self): - for f in self.file_list: - if os.path.exists(f): - os.unlink(f) - - - def test_Load( self ): - kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") - self.assertTrue(kw) - - grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) - kw = Ecl3DKW.read_grdecl(grid , open(self.src_file, "r"), "PERMX") - self.assertTrue( isinstance( kw , Ecl3DKW )) - - - - def test_reload( self ): - kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") - tmp_file1 = "/tmp/permx1.grdecl" - tmp_file2 = "/tmp/permx2.grdecl" - self.addFile(tmp_file1) - self.addFile(tmp_file2) - - fileH = open(tmp_file1, "w") - kw.write_grdecl(fileH) - fileH.close() - - kw1 = EclKW.read_grdecl(open(tmp_file1, "r"), "PERMX") - - fileH = open(tmp_file2, "w") - kw1.write_grdecl(fileH) - fileH.close() - - self.assertFilesAreEqual(tmp_file1, tmp_file2) - - - def test_fseek( self ): - file = open(self.src_file, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - file.close() - - file = open(self.src_file, "r") - kw1 = EclKW.read_grdecl(file, "PERMX") - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - file.close() - - - def test_fseek2(self): - test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") - # Test kw at the the very start - file = open(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - - # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) - - # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - - # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - - # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) - - - def test_fseek_dos(self): - test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl_dos") # File formatted with \r\n line endings. - # Test kw at the the very start - file = open(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - - # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) - - # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - - # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - - # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid.py b/ThirdParty/Ert/python/tests/ecl/test_grid.py deleted file mode 100644 index 0152414bb9..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_grid.py +++ /dev/null @@ -1,587 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os.path -from unittest import skipIf -import time -import itertools -from numpy import linspace - -from ecl.util import IntVector -from ecl.ecl import EclGrid, EclKW, EclDataType, EclUnitTypeEnum, EclFile -from ecl.ecl import EclGridGenerator as GridGen -from ecl.ecl.faults import Layer , FaultCollection -from ecl.test import ExtendedTestCase , TestAreaContext - -# This dict is used to verify that corners are mapped to the correct -# cell with respect to containment. -CORNER_HOME = { - (0, 0, 0) : 0, (0, 0, 1) : 9, (0, 0, 2) : 18, (0, 0, 3) : 18, - (0, 1, 0) : 3, (0, 1, 1) : 12, (0, 1, 2) : 21, (0, 1, 3) : 21, - (0, 2, 0) : 6, (0, 2, 1) : 15, (0, 2, 2) : 24, (0, 2, 3) : 24, - (0, 3, 0) : 6, (0, 3, 1) : 15, (0, 3, 2) : 24, (0, 3, 3) : 24, - (1, 0, 0) : 1, (1, 0, 1) : 10, (1, 0, 2) : 19, (1, 0, 3) : 19, - (1, 1, 0) : 4, (1, 1, 1) : 13, (1, 1, 2) : 22, (1, 1, 3) : 22, - (1, 2, 0) : 7, (1, 2, 1) : 16, (1, 2, 2) : 25, (1, 2, 3) : 25, - (1, 3, 0) : 7, (1, 3, 1) : 16, (1, 3, 2) : 25, (1, 3, 3) : 25, - (2, 0, 0) : 2, (2, 0, 1) : 11, (2, 0, 2) : 20, (2, 0, 3) : 20, - (2, 1, 0) : 5, (2, 1, 1) : 14, (2, 1, 2) : 23, (2, 1, 3) : 23, - (2, 2, 0) : 8, (2, 2, 1) : 17, (2, 2, 2) : 26, (2, 2, 3) : 26, - (2, 3, 0) : 8, (2, 3, 1) : 17, (2, 3, 2) : 26, (2, 3, 3) : 26, - (3, 0, 0) : 2, (3, 0, 1) : 11, (3, 0, 2) : 20, (3, 0, 3) : 20, - (3, 1, 0) : 5, (3, 1, 1) : 14, (3, 1, 2) : 23, (3, 1, 3) : 23, - (3, 2, 0) : 8, (3, 2, 1) : 17, (3, 2, 2) : 26, (3, 2, 3) : 26, - (3, 3, 0) : 8, (3, 3, 1) : 17, (3, 3, 2) : 26, (3, 3, 3) : 26 -} - -def createVolumeTestGridBase(dim, dV, offset=1): - return [ - GridGen.create_grid(dim, dV, offset=0), - GridGen.create_grid(dim, dV, offset=offset), - GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True), - GridGen.create_grid(dim, dV, offset=offset, concave=True), - GridGen.create_grid(dim, dV, offset=offset, irregular=True), - GridGen.create_grid(dim, dV, offset=offset, concave=True, irregular=True), - GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True, concave=True), - GridGen.create_grid(dim, dV, offset=0, faults=True), - GridGen.create_grid(dim, dV, offset=offset, faults=True), - GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=2), - GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=0.5), - GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), translation=(50,50,0)), - GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), rotate=True), - GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), misalign=True), - GridGen.create_grid(dim, dV, offset=offset, escape_origo_shift=(100, 100, 0), - irregular_offset=True, concave=True, irregular=True, - scale=1.5, translation=(5,5,0), rotate=True, - misalign=True) - ] - -def createContainmentTestBase(): - return [ - (3, GridGen.create_grid((6,6,6), (1,1,1), offset=1)), - (10, GridGen.create_grid((3,3,3), (1,1,1), offset=1, concave=True)), - (4, GridGen.create_grid((10,10,1), (1,1,1), offset=0., misalign=True)), - (3, - GridGen.create_grid((6,6,6), (1,1,1), offset=0., - escape_origo_shift=(100, 100, 0), - irregular_offset=True, concave=True, irregular=True, - scale=1.5, translation=(5,5,0), - misalign=True - ) - ) - ] - -def getMinMaxValue(grid): - corners = [ - grid.getCellCorner(i, cell) - for i in range(8) - for cell in range(grid.getGlobalSize()) - ] - - return [(min(values), max(values)) for values in zip(*corners)] - -def createWrapperGrid(grid): - """ - Creates a grid that occupies the same space as the given grid, - but that consists of a single cell. - """ - - x, y, z = grid.getNX()-1, grid.getNY()-1, grid.getNZ()-1 - corner_pos = [ - (0, 0, 0), (x, 0, 0), (0, y, 0), (x, y, 0), - (0, 0, z), (x, 0, z), (0, y, z), (x, y, z) - ] - - corners = [ - grid.getCellCorner(i, ijk=pos) - for i, pos in enumerate(corner_pos) - ] - - return GridGen.create_single_cell_grid(corners) - -def average(points): - p = reduce(lambda a,b: (a[0]+b[0], a[1]+b[1], a[2]+b[2]), points) - return [elem/float(len(points)) for elem in p] - -# This test class should only have test cases which do not require -# external test data. Tests involving Statoil test data are in the -# test_grid_statoil module. -class GridTest(ExtendedTestCase): - - def test_oom_grid(self): - nx = 2000 - ny = 2000 - nz = 2000 - - with self.assertRaises(MemoryError): - grid = GridGen.createRectangular( (nx,ny,nz), (1,1,1)) - - - - def test_posXYEdge(self): - nx = 10 - ny = 11 - grid = GridGen.createRectangular( (nx,ny,1) , (1,1,1) ) - self.assertEqual( grid.findCellCornerXY(0,0,0) , 0 ) - self.assertEqual( grid.findCellCornerXY(nx,0,0) , nx) - self.assertEqual( grid.findCellCornerXY(0 , ny , 0) , (nx + 1 ) * ny ) - self.assertEqual( grid.findCellCornerXY(nx,ny,0) , (nx + 1 ) * (ny + 1) - 1) - - self.assertEqual( grid.findCellCornerXY(0.25,0,0) , 0 ) - self.assertEqual( grid.findCellCornerXY(0,0.25,0) , 0 ) - - self.assertEqual( grid.findCellCornerXY(nx - 0.25,0,0) , nx ) - self.assertEqual( grid.findCellCornerXY(nx , 0.25,0) , nx ) - - self.assertEqual( grid.findCellCornerXY(0 , ny - 0.25, 0) , (nx + 1 ) * ny ) - self.assertEqual( grid.findCellCornerXY(0.25 , ny , 0) , (nx + 1 ) * ny ) - - self.assertEqual( grid.findCellCornerXY(nx -0.25 ,ny,0) , (nx + 1 ) * (ny + 1) - 1) - self.assertEqual( grid.findCellCornerXY(nx , ny - 0.25,0) , (nx + 1 ) * (ny + 1) - 1) - - - def test_dims(self): - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) - self.assertEqual( grid.getNX() , 10 ) - self.assertEqual( grid.getNY() , 20 ) - self.assertEqual( grid.getNZ() , 30 ) - self.assertEqual( grid.getGlobalSize() , 30*10*20 ) - - self.assertEqual( grid.getDims() , (10,20,30,6000) ) - - def test_create(self): - with self.assertRaises(ValueError): - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = [0,1,1,2]) - - with self.assertRaises(ValueError): - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = IntVector(initial_size = 10)) - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) # actnum=None -> all active - self.assertEqual( grid.getNumActive( ) , 30*20*10) - actnum = IntVector(default_value = 1 , initial_size = 6000) - actnum[0] = 0 - actnum[1] = 0 - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) , actnum = actnum) - self.assertEqual( grid.getNumActive( ) , 30*20*10 - 2) - - def test_all_iters(self): - fk = self.createTestPath('local/ECLIPSE/faarikaal/faarikaal1.EGRID') - grid = EclGrid(fk) - cell = grid[3455] - self.assertEqual(3455, cell.global_index) - cell = grid[(4,1,82)] - self.assertEqual(3455, cell.global_index) - self.assertEqual(grid.cell(global_index=3455), - grid.cell(active_index=2000)) - self.assertEqual(grid.cell(global_index=3455), - grid.cell(i=4, j=1, k=82)) - - na = grid.get_num_active() - self.assertEqual(na, 4160) - cnt = 0 - for c in grid.cells(active=True): - cnt += 1 - self.assertTrue(c.active) - self.assertEqual(cnt, 4160) - - cnt = len([c for c in grid.cells()]) - self.assertEqual(cnt, len(grid)) - - - def test_repr_and_name(self): - grid = GridGen.createRectangular((2,2,2), (10,10,10), actnum=[0,0,0,0,1,1,1,1]) - pfx = 'EclGrid(' - rep = repr(grid) - self.assertEqual(pfx, rep[:len(pfx)]) - self.assertEqual(type(rep), type('')) - self.assertEqual(type(grid.getName()), type('')) - with TestAreaContext("python/ecl_grid/repr"): - grid.save_EGRID("CASE.EGRID") - g2 = EclGrid("CASE.EGRID") - r2 = repr(g2) - self.assertEqual(pfx, r2[:len(pfx)]) - self.assertEqual(type(r2), type('')) - self.assertEqual(type(g2.getName()), type('')) - - def test_node_pos(self): - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) - with self.assertRaises(IndexError): - grid.getNodePos(-1,0,0) - - with self.assertRaises(IndexError): - grid.getNodePos(11,0,0) - - p0 = grid.getNodePos(0,0,0) - self.assertEqual( p0 , (0,0,0)) - - p7 = grid.getNodePos(10,20,30) - self.assertEqual( p7 , (10,20,30)) - - - def test_truncated_file(self): - grid = GridGen.createRectangular( (10,20,30) , (1,1,1) ) - with TestAreaContext("python/ecl_grid/truncated"): - grid.save_EGRID( "TEST.EGRID") - - size = os.path.getsize( "TEST.EGRID") - with open("TEST.EGRID" , "r+") as f: - f.truncate( size / 2 ) - - with self.assertRaises(IOError): - EclGrid("TEST.EGRID") - - def test_posXY1(self): - nx = 4 - ny = 1 - nz = 1 - grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) - (i,j) = grid.findCellXY( 0.5 , 0.5, 0 ) - self.assertEqual(i , 0) - self.assertEqual(j , 0) - - (i,j) = grid.findCellXY( 3.5 , 0.5, 0 ) - self.assertEqual(i , 3) - self.assertEqual(j , 0) - - - def test_init_ACTNUM(self): - nx = 10 - ny = 23 - nz = 7 - grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) - actnum = grid.exportACTNUM() - - self.assertEqual( len(actnum) , nx*ny*nz ) - self.assertEqual( actnum[0] , 1 ) - self.assertEqual( actnum[nx*ny*nz - 1] , 1 ) - - actnum_kw = grid.exportACTNUMKw( ) - self.assertEqual(len(actnum_kw) , len(actnum)) - for a1,a2 in zip(actnum, actnum_kw): - self.assertEqual(a1, a2) - - - def test_posXY(self): - nx = 10 - ny = 23 - nz = 7 - grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) - with self.assertRaises(IndexError): - grid.findCellXY( 1 , 1, -1 ) - - with self.assertRaises(IndexError): - grid.findCellXY( 1 , 1, nz + 1 ) - - with self.assertRaises(ValueError): - grid.findCellXY(15 , 78 , 2) - - - i,j = grid.findCellXY( 1.5 , 1.5 , 2 ) - self.assertEqual(i , 1) - self.assertEqual(j , 1) - - - for i in range(nx): - for j in range(ny): - p = grid.findCellXY(i + 0.5 , j+ 0.5 , 0) - self.assertEqual( p[0] , i ) - self.assertEqual( p[1] , j ) - - c = grid.findCellCornerXY( 0.10 , 0.10 , 0 ) - self.assertEqual(c , 0) - - c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) - self.assertEqual( c , (nx + 1) + 1 ) - - c = grid.findCellCornerXY( 0.10 , 0.90 , 0 ) - self.assertEqual( c , (nx + 1) ) - - c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) - self.assertEqual( c , (nx + 1) + 1 ) - - c = grid.findCellCornerXY( 0.90 , 0.10 , 0 ) - self.assertEqual( c , 1 ) - - def test_compressed_copy(self): - nx = 10 - ny = 10 - nz = 10 - grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1) ) - kw1 = EclKW("KW" , 1001 , EclDataType.ECL_INT ) - with self.assertRaises(ValueError): - cp = grid.compressedKWCopy( kw1 ) - - - def test_dxdydz(self): - nx = 10 - ny = 10 - nz = 10 - grid = GridGen.createRectangular( (nx,ny,nz) , (2,3,4) ) - - (dx,dy,dz) = grid.getCellDims( active_index = 0 ) - self.assertEqual( dx , 2 ) - self.assertEqual( dy , 3 ) - self.assertEqual( dz , 4 ) - - def test_numpy3D(self): - nx = 10 - ny = 7 - nz = 5 - grid = GridGen.createRectangular((nx,ny,nz) , (1,1,1)) - kw = EclKW( "SWAT" , nx*ny*nz , EclDataType.ECL_FLOAT ) - numpy_3d = grid.create3D( kw ) - - def test_len(self): - nx = 10 - ny = 11 - nz = 12 - actnum = EclKW( "ACTNUM" , nx*ny*nz , EclDataType.ECL_INT ) - actnum[0] = 1 - actnum[1] = 1 - actnum[2] = 1 - actnum[3] = 1 - - grid = GridGen.createRectangular( (nx,ny,nz) , (1,1,1), actnum = actnum) - self.assertEqual( len(grid) , nx*ny*nz ) - self.assertEqual( grid.getNumActive( ) , 4 ) - - def test_export(self): - dims = (3, 3, 3) - coord = GridGen.create_coord(dims, (1,1,1)) - zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) - - grid = EclGrid.create(dims, zcorn, coord, None) - - self.assertEqual(zcorn, grid.export_zcorn()) - self.assertEqual(coord, grid.export_coord()) - - def test_output_units(self): - n = 10 - a = 1 - grid = GridGen.createRectangular( (n,n,n), (a,a,a)) - - with TestAreaContext("python/ecl_grid/units"): - grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_FIELD_UNITS ) - f = EclFile("CASE.EGRID") - g = f["GRIDUNIT"][0] - self.assertEqual( g[0].strip( ) , "FEET" ) - g2 = EclGrid("CASE.EGRID") - self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 3.28084*3.28084*3.28084) - - - grid.save_EGRID( "CASE.EGRID" ) - f = EclFile("CASE.EGRID") - g = f["GRIDUNIT"][0] - self.assertEqual( g[0].strip( ) , "METRES" ) - - grid.save_EGRID( "CASE.EGRID" , output_unit = EclUnitTypeEnum.ECL_LAB_UNITS) - f = EclFile("CASE.EGRID") - g = f["GRIDUNIT"][0] - self.assertEqual( g[0].strip() , "CM" ) - g2 = EclGrid("CASE.EGRID") - self.assertFloatEqual( g2.cell_volume( global_index = 0 ) , 100*100*100 ) - - def test_volume(self): - dim = (10,10,10) - dV = (2,2,2) - - grids = createVolumeTestGridBase(dim, dV) - for grid in grids: - tot_vol = createWrapperGrid(grid).cell_volume(0) - cell_volumes = [grid.cell_volume(i) for i in range(grid.getGlobalSize())] - self.assertTrue(min(cell_volumes) >= 0) - self.assertFloatEqual(sum(cell_volumes), tot_vol) - - def test_unique_containment(self): - test_base = createContainmentTestBase() - - for steps_per_unit, grid in test_base: - wgrid = createWrapperGrid(grid) - - (xmin, xmax), (ymin, ymax), (zmin, zmax) = getMinMaxValue(wgrid) - x_space = linspace(xmin-1, xmax+1, (xmax-xmin+2)*steps_per_unit+1) - y_space = linspace(ymin-1, ymax+1, (ymax-ymin+2)*steps_per_unit+1) - z_space = linspace(zmin-1, zmax+1, (zmax-zmin+2)*steps_per_unit+1) - - for x, y, z in itertools.product(x_space, y_space, z_space): - hits = [ - grid.cell_contains(x, y, z, i) - for i in range(grid.getGlobalSize()) - ].count(True) - - self.assertIn(hits, [0, 1]) - - expected = 1 if wgrid.cell_contains(x, y, z, 0) else 0 - self.assertEqual( - expected, - hits, - 'Expected %d for (%g,%g,%g), got %d' % (expected, x, y, z, hits) - ) - - def test_cell_corner_containment(self): - n = 4 - d = 10 - grid = GridGen.createRectangular( (n, n, n), (d, d, d)) - - for x, y, z in itertools.product(range(0, n*d+1, d), repeat=3): - self.assertEqual( - 1, - [grid.cell_contains(x, y, z, i) for i in range(n**3)].count(True) - ) - - def test_cell_corner_containment_compatability(self): - grid = GridGen.createRectangular( (3,3,3), (1,1,1) ) - - for x, y, z in itertools.product(range(4), repeat=3): - for i in range(27): - if grid.cell_contains(x, y, z, i): - self.assertEqual( - CORNER_HOME[(x,y,z)], - i - ) - - def test_cell_face_containment(self): - n = 4 - d = 10 - grid = GridGen.createRectangular( (n, n, n), (d, d, d)) - - for x, y, z in itertools.product(range(d/2, n*d, d), repeat=3): - for axis, direction in itertools.product(range(3), [-1, 1]): - p = [x, y, z] - p[axis] = p[axis] + direction*d/2 - self.assertEqual( - 1, - [grid.cell_contains(p[0], p[1], p[2], i) for i in range(n**3)].count(True) - ) - - # This test generates a cell that is concave on ALL 6 sides - def test_concave_cell_containment(self): - points = [ - (5, 5, 5), - (20, 10, 10), - (10, 20, 10), - (25, 25, 5), - (10, 10, 20), - (25, 5, 25), - (5, 25, 25), - (20, 20, 20) - ] - - grid = GridGen.create_single_cell_grid(points) - - assertPoint = lambda p : self.assertTrue( - grid.cell_contains(p[0], p[1], p[2], 0) - ) - - assertNotPoint = lambda p : self.assertFalse( - grid.cell_contains(p[0], p[1], p[2], 0) - ) - - # Cell center - assertPoint(average(points)); - - # "Side" center - assertNotPoint(average(points[0:4:])) - assertNotPoint(average(points[4:8:])) - assertNotPoint(average(points[1:8:2])) - assertNotPoint(average(points[0:8:2])) - assertNotPoint(average(points[0:8:4] + points[1:8:4])) - assertNotPoint(average(points[2:8:4] + points[3:8:4])) - - # Corners - for p in points: - assertPoint(p) - - # Edges - edges = ([(i, i+1) for i in range(0, 8, 2)] + - [(i, i+2) for i in [0, 1, 4, 5]] + - [(i, i+4) for i in range(4)] + - [(1,2), (2,7), (1,7), (4,7), (2,4), (4,1)]) - for a,b in edges: - assertPoint(average([points[a], points[b]])) - - # Epsilon inside from corners - middle_point = average(points) - for p in points: - assertPoint(average(20*[p] + [middle_point])) - - # Espilon outside - middle_point[2] = 0 - for p in points[0:4:]: - assertNotPoint(average(20*[p] + [middle_point])) - - middle_point[2] = 30 - for p in points[4:8:]: - assertNotPoint(average(20*[p] + [middle_point])) - - # This test generates a cell that is strictly convex on ALL 6 sides - def test_concvex_cell_containment(self): - points = [ - (10, 10, 10), - (25, 5, 5), - (5, 25, 5), - (20, 20, 10), - (5, 5, 25), - (20, 10, 20), - (10, 20, 20), - (25, 25, 25) - ] - - grid = GridGen.create_single_cell_grid(points) - - assertPoint = lambda p : self.assertTrue( - grid.cell_contains(p[0], p[1], p[2], 0) - ) - - assertNotPoint = lambda p : self.assertFalse( - grid.cell_contains(p[0], p[1], p[2], 0) - ) - - # Cell center - assertPoint(average(points)); - - # "Side" center - assertPoint(average(points[0:4:])) - assertPoint(average(points[4:8:])) - assertPoint(average(points[1:8:2])) - assertPoint(average(points[0:8:2])) - assertPoint(average(points[0:8:4] + points[1:8:4])) - assertPoint(average(points[2:8:4] + points[3:8:4])) - - # Corners - for p in points: - assertPoint(p) - - # Edges - edges = ([(i, i+1) for i in range(0, 8, 2)] + - [(i, i+2) for i in [0, 1, 4, 5]] + - [(i, i+4) for i in range(4)] + - [(1,2), (2,7), (1,7), (4,7), (2,4), (4,1)]) - for a,b in edges: - assertPoint(average([points[a], points[b]])) - - # Epsilon inside from corners - middle_point = average(points) - for p in points: - assertPoint(average(20*[p] + [middle_point])) - - # Espilon outside - middle_point[2] = 0 - for p in points[0:4:]: - assertNotPoint(average(20*[p] + [middle_point])) - - middle_point[2] = 30 - for p in points[4:8:]: - assertNotPoint(average(20*[p] + [middle_point])) diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid_generator.py b/ThirdParty/Ert/python/tests/ecl/test_grid_generator.py deleted file mode 100644 index ff2d8f087d..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_grid_generator.py +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'test_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from itertools import product as prod -import operator, random, numpy - -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.ecl import EclGridGenerator as GridGen -from ecl.test import ExtendedTestCase, TestAreaContext - - -def generate_ijk_bounds(dims): - ibounds = [(l, u) for l in range(dims[0]) for u in range(l, dims[0])] - jbounds = [(l, u) for l in range(dims[1]) for u in range(l, dims[1])] - kbounds = [(l, u) for l in range(dims[2]) for u in range(l, dims[2])] - return prod(ibounds, jbounds, kbounds) - -def decomposition_preserving(ijk_bound): - return sum(zip(*ijk_bound)[0])%2 is 0 - -class GridGeneratorTest(ExtendedTestCase): - - def setUp(self): - self.test_base = [ - ( - list(GridGen.create_coord((4,4,4), (1,1,1))), - list(GridGen.create_zcorn((4,4,4), (1,1,1), offset=0)), - GridGen.create_grid((4,4,4), (1,1,1), offset=0) - ), - ( - list( - GridGen.create_coord((5,5,5), (1,1,1), - translation=(10,10,0)) - ), - list( - GridGen.create_zcorn((5,5,5), (1,1,1), offset=0.5, - irregular_offset=True, concave=True, irregular=True) - ), - GridGen.create_grid( - (5,5,5), (1,1,1), offset=0.5, - irregular=True, irregular_offset=True, concave=True, - translation=(10,10,0) - ) - ) - ] - - def test_extract_grid_decomposition_change(self): - dims = (4,4,4) - zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) - coord = list(GridGen.create_coord(dims, (1,1,1))) - - ijk_bounds = generate_ijk_bounds(dims) - for ijk_bounds in ijk_bounds: - if decomposition_preserving(ijk_bounds): - GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds) - else: - with self.assertRaises(ValueError): - GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds) - - GridGen.extract_subgrid_data(dims, - coord, zcorn, - ijk_bounds, - decomposition_change=True) - - def test_extract_grid_invalid_bounds(self): - dims = (3,3,3) - zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) - coord = list(GridGen.create_coord(dims, (1,1,1))) - - with self.assertRaises(ValueError): - GridGen.extract_subgrid_data(dims, coord, zcorn, ((-1,0), (2,2), (2,2))) - - with self.assertRaises(ValueError): - GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,6), (2,2), (2,2))) - - with self.assertRaises(ValueError): - GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,2), (2,0), (2,2))) - - def test_extract_grid_slice_spec(self): - dims = (4,4,4) - zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0)) - coord = list(GridGen.create_coord(dims, (1,1,1))) - - ijk_bounds = generate_ijk_bounds(dims) - for ijk in ijk_bounds: - ijk = list(ijk) - for i in range(3): - if len(set(ijk[i])) == 1: - ijk[i] = ijk[i][0] - - GridGen.extract_subgrid_data(dims, - coord, zcorn, - ijk, - decomposition_change=True) - - def assertSubgrid(self, grid, subgrid, ijk_bound): - sijk_space = prod(*[range(d) for d in subgrid.getDims()[:-1:]]) - for sijk in sijk_space: - gijk = tuple([a+b for a, b in zip(sijk, zip(*ijk_bound)[0])]) - - self.assertEqual( - [subgrid.getCellCorner(i, ijk=sijk) for i in range(8)], - [grid.getCellCorner(i, ijk=gijk) for i in range(8)] - ) - - self.assertEqual(grid.active(ijk=gijk), subgrid.active(ijk=sijk)) - - def test_validate_cells(self): - for coord, zcorn, grid in self.test_base: - grid_dims = grid.getDims()[:-1:] - ijk_bounds = generate_ijk_bounds(grid_dims) - for ijk_bound in ijk_bounds: - if not decomposition_preserving(ijk_bound): - continue - - sub_dims = tuple([u-l+1 for l, u in ijk_bound]) - sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data( - grid_dims, - coord, - zcorn, - ijk_bound - ) - - subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, None) - self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) - self.assertSubgrid(grid, subgrid, ijk_bound) - - def test_actnum_extraction(self): - dims = (4,4,4) - - coord = GridGen.create_coord(dims, (1,1,1)) - zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) - - actnum = EclKW("ACTNUM", reduce(operator.mul, dims), EclDataType.ECL_INT) - random.seed(1337) - for i in range(len(actnum)): - actnum[i] = random.randint(0, 1) - - grid = EclGrid.create(dims, zcorn, coord, actnum) - - ijk_bounds = generate_ijk_bounds(dims) - for ijk_bound in ijk_bounds: - if not decomposition_preserving(ijk_bound): - continue - - sub = GridGen.extract_subgrid_data( - dims, - coord, - zcorn, - ijk_bound, - actnum=actnum - ) - - sub_coord, sub_zcorn, sub_actnum = sub - sub_dims = tuple([u-l+1 for l, u in ijk_bound]) - subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum) - self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) - self.assertSubgrid(grid, subgrid, ijk_bound) - - def test_translation(self): - dims = (3,3,3) - - coord = GridGen.create_coord(dims, (1,1,1)) - zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) - grid = EclGrid.create(dims, zcorn, coord, None) - - ijk_bound = [(0, d-1) for d in dims] - translation = (1, 2, 3) - sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data( - dims, - coord, - zcorn, - ijk_bound, - translation=translation - ) - - tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None) - self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize()) - - for gi in range(grid.getGlobalSize()): - translation = numpy.array(translation) - corners = [grid.getCellCorner(i, gi) for i in range(8)] - corners = [tuple(numpy.array(c)+translation) for c in corners] - - tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)] - - self.assertEqual(corners, tcorners) - - def test_subgrid_extration(self): - for _, _, grid in self.test_base[:-1:]: - grid_dims = grid.getDims()[:-1:] - ijk_bounds = generate_ijk_bounds(grid_dims) - for ijk_bound in ijk_bounds: - if not decomposition_preserving(ijk_bound): - continue - - sub_dims = tuple([u-l+1 for l, u in ijk_bound]) - subgrid = GridGen.extract_subgrid(grid, ijk_bound) - - self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) - self.assertSubgrid(grid, subgrid, ijk_bound) - - def test_subgrid_translation(self): - grid = GridGen.create_grid((4,4,4), (1,1,1), offset=0.5, - irregular=True, irregular_offset=True, concave=True, - translation=(10,10,0)) - - # Create grid with MAPAXES - mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT) - for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]): - mapaxes[i] = val - - grid = EclGrid.create( - grid.getDims(), - grid.export_zcorn(), - grid.export_coord(), - None, - mapaxes=mapaxes - ) - - for translation in [ - (0,0,0), - (10, 10, 100), - (-1, -1, -1) - ]: - subgrid = GridGen.extract_subgrid( - grid, - ((0,3), (0,3), (0,3)), - translation=translation - ) - - self.assertEqual(grid.getDims(), subgrid.getDims()) - - translation = numpy.array(translation) - for gindex in range(grid.getGlobalSize()): - grid_corners = [ - grid.getCellCorner(i, global_index=gindex) - for i in range(8) - ] - - subgrid_corners = [ - subgrid.getCellCorner(i, global_index=gindex) - for i in range(8) - ] - - subgrid_corners = [ - list(numpy.array(corner) - translation) - for corner in subgrid_corners - ] - - for gc, sc in zip(grid_corners, subgrid_corners): - self.assertAlmostEqualList( - gc, - sc, - msg="Failed to translate corners correctly." + - "Expected %s, was %s." % (gc, sc), - tolerance=10e-10 - ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py deleted file mode 100644 index 89129deadc..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py +++ /dev/null @@ -1,408 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import math - -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ecl.ecl import EclDataType, EclKW, EclGrid, EclFile, openEclFile -from ecl.util import DoubleVector, IntVector -from ecl.test import ExtendedTestCase , TestAreaContext - - -class GridTest(ExtendedTestCase): - def egrid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - - - def grid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID") - - - def grdecl_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_grid_sim.GRDECL") - - def test_loadFromFile(self): - g1 = EclGrid.loadFromFile( self.egrid_file() ) - g2 = EclGrid.loadFromFile( self.grdecl_file() ) - - self.assertTrue( isinstance( g1 , EclGrid ) ) - self.assertTrue( isinstance( g2 , EclGrid ) ) - - - def test_corner(self): - grid = EclGrid(self.egrid_file()) - nx = grid.getNX() - ny = grid.getNY() - nz = grid.getNZ() - - (x1,y1,z1) = grid.getCellCorner( 0 , ijk = (0,0,0)) - (x2,y2,z2) = grid.getLayerXYZ( 0 , 0 ) - self.assertEqual(x1,x2) - self.assertEqual(y1,y2) - self.assertEqual(z1,z2) - - (x1,y1,z1) = grid.getCellCorner( 0 , ijk = (0,1,0)) - (x2,y2,z2) = grid.getLayerXYZ( (nx + 1) , 0 ) - self.assertEqual(x1,x2) - self.assertEqual(y1,y2) - self.assertEqual(z1,z2) - - (x1,y1,z1) = grid.getCellCorner( 1 , ijk = (nx - 1,0,0)) - (x2,y2,z2) = grid.getLayerXYZ( nx , 0 ) - self.assertEqual(x1,x2) - self.assertEqual(y1,y2) - self.assertEqual(z1,z2) - - (x1,y1,z1) = grid.getCellCorner( 4 , ijk = (0,0,nz-1)) - (x2,y2,z2) = grid.getLayerXYZ( 0 , nz ) - self.assertEqual(x1,x2) - self.assertEqual(y1,y2) - self.assertEqual(z1,z2) - - (x1,y1,z1) = grid.getCellCorner( 7 , ijk = (nx-1,ny-1,nz-1)) - (x2,y2,z2) = grid.getLayerXYZ( (nx + 1)*(ny + 1) - 1 , nz ) - self.assertEqual(x1,x2) - self.assertEqual(y1,y2) - self.assertEqual(z1,z2) - - - - with self.assertRaises(IndexError): - grid.getLayerXYZ( -1 , 0 ) - - with self.assertRaises(IndexError): - grid.getLayerXYZ( (nx + 1)*(ny + 1) , 0 ) - - with self.assertRaises(IndexError): - grid.getLayerXYZ( 0 , -1 ) - - with self.assertRaises(IndexError): - grid.getLayerXYZ( 0 , nz + 1 ) - - - def test_GRID( self ): - grid = EclGrid(self.grid_file()) - self.assertTrue(grid) - - - - def test_EGRID( self ): - grid = EclGrid(self.egrid_file()) - self.assertTrue(grid) - dims = grid.getDims() - self.assertEqual(dims[0] , grid.getNX()) - self.assertEqual(dims[1] , grid.getNY()) - self.assertEqual(dims[2] , grid.getNZ()) - - - - def create(self, filename, load_actnum=True): - fileH = open(filename, "r") - specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) - zcorn = EclKW.read_grdecl(fileH, "ZCORN") - coord = EclKW.read_grdecl(fileH, "COORD") - if load_actnum: - actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) - else: - actnum = None - - mapaxes = EclKW.read_grdecl(fileH, "MAPAXES") - grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes) - return grid - - - def test_rect(self): - with TestAreaContext("python/grid-test/testRect"): - a1 = 1.0 - a2 = 2.0 - a3 = 3.0 - grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3)) - grid.save_EGRID("rect.EGRID") - grid2 = EclGrid("rect.EGRID") - self.assertTrue(grid) - self.assertTrue(grid2) - - (x, y, z) = grid.get_xyz(ijk=(4, 4, 4)) - self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3]) - - v = grid.cell_volume(ijk=(4, 4, 4)) - self.assertFloatEqual(v, a1 * a2 * a3) - - z = grid.depth(ijk=(4, 4, 4 )) - self.assertFloatEqual(z, 4.5 * a3) - - g1 = grid.global_index(ijk=(2, 2, 2)) - g2 = grid.global_index(ijk=(4, 4, 4)) - (dx, dy, dz) = grid.distance(g2, g1) - self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3]) - - self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2))) - - #ijk = grid.find_cell(1.5 * a1 , 2.5 * a2 , 3.5 * a3) - #self.assertAlmostEqualList(ijk, [1, 2, 3]) - - - def test_create(self): - grid = self.create(self.grdecl_file()) - self.assertTrue(grid) - - - def test_grdecl_load(self): - with self.assertRaises(IOError): - grid = EclGrid.loadFromGrdecl("/file/does/not/exists") - - with TestAreaContext("python/grid-test/grdeclLoad"): - with open("grid.grdecl","w") as f: - f.write("Hei ...") - - with self.assertRaises(ValueError): - grid = EclGrid.loadFromGrdecl("grid.grdecl") - - actnum = IntVector(default_value = 1 , initial_size = 1000) - actnum[0] = 0 - g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum ) - self.assertEqual( g1.getNumActive() , actnum.elementSum() ) - g1.save_EGRID("G.EGRID") - - with openEclFile("G.EGRID") as f: - with open("grid.grdecl" , "w") as f2: - f2.write("SPECGRID\n") - f2.write(" 10 10 10 \'F\' /\n") - - coord_kw = f["COORD"][0] - coord_kw.write_grdecl( f2 ) - - zcorn_kw = f["ZCORN"][0] - zcorn_kw.write_grdecl( f2 ) - - actnum_kw = f["ACTNUM"][0] - actnum_kw.write_grdecl( f2 ) - - g2 = EclGrid.loadFromGrdecl("grid.grdecl") - self.assertTrue( g1.equal( g2 )) - - - - def test_ACTNUM(self): - g1 = self.create(self.grdecl_file()) - g2 = self.create(self.grdecl_file(), load_actnum=False) - self.assertTrue(g1.equal(g2)) - - - def test_time(self): - t0 = time.clock() - g1 = EclGrid(self.egrid_file()) - t1 = time.clock() - t = t1 - t0 - self.assertTrue(t < 1.0) - - - def test_save(self): - with TestAreaContext("python/grid-test/testSave"): - g1 = EclGrid(self.egrid_file()) - - g1.save_EGRID("test.EGRID") - g2 = EclGrid("test.EGRID") - self.assertTrue(g1.equal(g2)) - - g1.save_GRID("test.GRID") - g2 = EclGrid("test.GRID") - self.assertTrue(g1.equal(g2)) - - fileH = open("test.grdecl", "w") - g1.save_grdecl(fileH) - fileH.close() - g2 = self.create("test.grdecl") - self.assertTrue(g1.equal(g2)) - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of coarse grid skipped!") - def test_coarse(self): - #work_area = TestArea("python/grid-test/testCoarse") - with TestAreaContext("python/grid-test/testCoarse"): - testGRID = True - g1 = EclGrid(self.createTestPath("Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID")) - - g1.save_EGRID("LGC.EGRID") - g2 = EclGrid("LGC.EGRID") - self.assertTrue(g1.equal(g2, verbose=True)) - - if testGRID: - g1.save_GRID("LGC.GRID") - g3 = EclGrid("LGC.GRID") - self.assertTrue(g1.equal(g3, verbose=True)) - - self.assertTrue(g1.coarse_groups() == 3384) - - - def test_raise_IO_error(self): - with self.assertRaises(IOError): - g = EclGrid("/does/not/exist.EGRID") - - def test_boundingBox(self): - grid = EclGrid.createRectangular((10,10,10) , (1,1,1)) - with self.assertRaises(ValueError): - bbox = grid.getBoundingBox2D(layer = -1 ) - - with self.assertRaises(ValueError): - bbox = grid.getBoundingBox2D( layer = 11 ) - - bbox = grid.getBoundingBox2D( layer = 10 ) - self.assertEqual( bbox , ((0,0) , (10, 0) , (10 , 10) , (0,10))) - - - with self.assertRaises(ValueError): - grid.getBoundingBox2D( lower_left = (-1,0) ) - - with self.assertRaises(ValueError): - grid.getBoundingBox2D( lower_left = (6,10) ) - - bbox = grid.getBoundingBox2D( lower_left = (3,3) ) - self.assertEqual( bbox , ((3,3) , (10,3) , (10,10) , (3,10))) - - with self.assertRaises(ValueError): - grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (2,2)) - - bbox = grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (7,7)) - self.assertEqual( bbox , ((3,3) , (7,3) , (7,7) , (3,7))) - - - - - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of dual grid skipped!") - def test_dual(self): - with TestAreaContext("python/grid-test/testDual"): - grid = EclGrid(self.egrid_file()) - self.assertFalse(grid.dualGrid()) - self.assertTrue(grid.getNumActiveFracture() == 0) - - grid2 = EclGrid(self.grid_file()) - self.assertFalse(grid.dualGrid()) - self.assertTrue(grid.getNumActiveFracture() == 0) - - dgrid = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.EGRID")) - self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) - self.assertTrue(dgrid.getNumActive() == 46118) - - dgrid2 = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.GRID")) - self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) - self.assertTrue(dgrid.getNumActive() == 46118) - self.assertTrue(dgrid.equal(dgrid2)) - - - # The DUAL_DIFF grid has been manipulated to create a - # situation where some cells are only matrix active, and some - # cells are only fracture active. - dgrid = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID")) - self.assertTrue(dgrid.getNumActive() == 106) - self.assertTrue(dgrid.getNumActiveFracture() == 105) - - self.assertTrue(dgrid.get_active_fracture_index(global_index=0) == -1) - self.assertTrue(dgrid.get_active_fracture_index(global_index=2) == -1) - self.assertTrue(dgrid.get_active_fracture_index(global_index=3) == 0) - self.assertTrue(dgrid.get_active_fracture_index(global_index=107) == 104) - - self.assertTrue(dgrid.get_active_index(global_index=1) == 1) - self.assertTrue(dgrid.get_active_index(global_index=105) == 105) - self.assertTrue(dgrid.get_active_index(global_index=106) == -1) - self.assertTrue(dgrid.get_global_index1F(2) == 5) - - dgrid.save_EGRID("DUAL_DIFF.EGRID") - dgrid2 = EclGrid("DUAL_DIFF.EGRID") - self.assertTrue(dgrid.equal(dgrid2 , verbose = True)) - - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!") - def test_num_active_large_memory(self): - case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") - vecList = [] - for i in range(12500): - vec = DoubleVector() - vec[81920] = 0 - vecList.append(vec) - - grid1 = EclGrid(case) - grid2 = EclGrid(case) - self.assertEqual(grid1.getNumActive(), grid2.getNumActive()) - self.assertEqual(grid1.getNumActive(), 34770) - - - def test_no_mapaxes_check_for_nan(self): - grid_paths = ["Statoil/ECLIPSE/NoMapaxes/ECLIPSE.EGRID", "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.GRID"] - - for grid_path in grid_paths: - test_grid_path = self.createTestPath(grid_path) - grid = EclGrid(test_grid_path) - - xyz = grid.get_xyz(ijk=(0, 0, 0)) - self.assertFalse(math.isnan(xyz[0])) - self.assertFalse(math.isnan(xyz[1])) - self.assertFalse(math.isnan(xyz[2])) - - xyz = grid.get_xyz(ijk=(1, 1, 1)) - self.assertFalse(math.isnan(xyz[0])) - self.assertFalse(math.isnan(xyz[1])) - self.assertFalse(math.isnan(xyz[2])) - - - def test_valid_geometry(self): - grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/GRID_INVALID_CELL/PRED_RESEST_0_R_13_0.GRID")) - self.assertTrue( grid.validCellGeometry( ijk = (27,0,0)) ) - self.assertFalse( grid.validCellGeometry( ijk = (0,0,0)) ) - - - def test_volume_kw(self): - grid = EclGrid(self.egrid_file()) - vol = grid.createVolumeKeyword( ) - self.assertEqual( len(vol) , grid.getNumActive()) - for active_index , volume in enumerate(vol): - self.assertEqual( volume , grid.cell_volume( active_index = active_index )) - - vol = grid.createVolumeKeyword( active_size = False ) - self.assertEqual( len(vol) , grid.getGlobalSize()) - for global_index , volume in enumerate(vol): - self.assertEqual( volume , grid.cell_volume( global_index = global_index )) - - - - def test_large_case(self): - grdecl_file = self.createTestPath("Statoil/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl") - grid = EclGrid.loadFromGrdecl( grdecl_file ) - - - def test_lgr_get(self): - grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID")) - for (nr,name) in [ ( 104 , "LG003017"), - (2 , "LG006024"), - ( 4 , "LG005025"), - ( 82 , "LG011029"), - (100 , "LG007021"), - (110 , "LG003014")]: - lgr_name = grid.get_lgr( name ) - lgr_nr = grid.get_lgr( nr ) - - self.assertEqual( lgr_name , lgr_nr ) - - with self.assertRaises(KeyError): - grid.get_lgr("NO/SUCHLGR") - - with self.assertRaises(KeyError): - grid.get_lgr(1024) diff --git a/ThirdParty/Ert/python/tests/ecl/test_indexed_read.py b/ThirdParty/Ert/python/tests/ecl/test_indexed_read.py deleted file mode 100644 index 8de919409a..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_indexed_read.py +++ /dev/null @@ -1,116 +0,0 @@ -import ctypes -import ecl - -from ecl.ecl import EclPrototype -from ecl.ecl import EclKW, EclFile, EclDataType, FortIO -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.util import IntVector - -class EclIndexedReadTest(ExtendedTestCase): - _freadIndexedData = EclPrototype("void ecl_kw_fread_indexed_data_python(fortio, int, ecl_data_type, int, int_vector, char*)", bind = False) # fortio, offset, type, count, index_map, buffer - _eclFileIndexedRead = EclPrototype("void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)", bind = False) # ecl_file, kw, index, index_map, buffer - - def test_ecl_kw_indexed_read(self): - with TestAreaContext("ecl_kw_indexed_read") as area: - fortio = FortIO("index_test", mode=FortIO.WRITE_MODE) - - element_count = 100000 - ecl_kw = EclKW("TEST", element_count, EclDataType.ECL_INT) - - for index in range(element_count): - ecl_kw[index] = index - - ecl_kw.fwrite(fortio) - - fortio.close() - - - fortio = FortIO("index_test", mode=FortIO.READ_MODE) - - new_ecl_kw = EclKW.fread(fortio) - - for index in range(element_count): - self.assertEqual(new_ecl_kw[index], index) - - index_map = IntVector() - index_map.append(2) - index_map.append(3) - index_map.append(5) - index_map.append(7) - index_map.append(11) - index_map.append(13) - index_map.append(313) - index_map.append(1867) - index_map.append(5227) - index_map.append(7159) - index_map.append(12689) - index_map.append(18719) - index_map.append(32321) - index_map.append(37879) - index_map.append(54167) - index_map.append(77213) - index_map.append(88843) - index_map.append(99991) - - char_buffer = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) - - self._freadIndexedData(fortio, 24, EclDataType.ECL_INT, element_count, index_map, char_buffer) - - int_buffer = ctypes.cast(char_buffer, ctypes.POINTER(ctypes.c_int)) - - for index, index_map_value in enumerate(index_map): - self.assertEqual(index_map_value, int_buffer[index]) - - - - def test_ecl_file_indexed_read(self): - with TestAreaContext("ecl_file_indexed_read") as area: - fortio = FortIO("ecl_file_index_test", mode=FortIO.WRITE_MODE) - - element_count = 100000 - ecl_kw_1 = EclKW("TEST1", element_count, EclDataType.ECL_INT) - ecl_kw_2 = EclKW("TEST2", element_count, EclDataType.ECL_INT) - - for index in range(element_count): - ecl_kw_1[index] = index - ecl_kw_2[index] = index + 3 - - ecl_kw_1.fwrite(fortio) - ecl_kw_2.fwrite(fortio) - - fortio.close() - - ecl_file = EclFile("ecl_file_index_test") - - index_map = IntVector() - index_map.append(2) - index_map.append(3) - index_map.append(5) - index_map.append(7) - index_map.append(11) - index_map.append(13) - index_map.append(313) - index_map.append(1867) - index_map.append(5227) - index_map.append(7159) - index_map.append(12689) - index_map.append(18719) - index_map.append(32321) - index_map.append(37879) - index_map.append(54167) - index_map.append(77213) - index_map.append(88843) - index_map.append(99991) - - char_buffer_1 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) - char_buffer_2 = ctypes.create_string_buffer(len(index_map) * ctypes.sizeof(ctypes.c_int)) - - self._eclFileIndexedRead(ecl_file, "TEST2", 0, index_map, char_buffer_2) - self._eclFileIndexedRead(ecl_file, "TEST1", 0, index_map, char_buffer_1) - - int_buffer_1 = ctypes.cast(char_buffer_1, ctypes.POINTER(ctypes.c_int)) - int_buffer_2 = ctypes.cast(char_buffer_2, ctypes.POINTER(ctypes.c_int)) - - for index, index_map_value in enumerate(index_map): - self.assertEqual(index_map_value, int_buffer_1[index]) - self.assertEqual(index_map_value, int_buffer_2[index] - 3) diff --git a/ThirdParty/Ert/python/tests/ecl/test_kw_function.py b/ThirdParty/Ert/python/tests/ecl/test_kw_function.py deleted file mode 100644 index 4f45f2f313..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_kw_function.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_kw_function.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os -import random -from ecl.ecl import EclKW, EclDataType, EclGrid , Ecl3DKW -from ecl.util import IntVector -from ecl.test import ExtendedTestCase - -class KWFunctionTest(ExtendedTestCase): - - def test_region_filter(self): - nx = 10 - ny = 10 - nz = 1 - actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 ) - actnum[nx*ny - 1] = 0 - - grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum) - self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 ) - - kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True ) - kw.assign( 0 ) - kw[0:nx*ny/2] = 1 - kw[5,2,0] = 0 - kw[0,9,0] = 2 - - kw.fixUninitialized( grid ) - - # Not assigned because they are in contact with a '2'; these - # two are problem cells. - self.assertEqual( kw[0,ny - 2,0] , 0) - self.assertEqual( kw[1,ny - 1,0] , 0) - - # Not assigned because it is inactive - self.assertEqual( kw[nx - 1,ny - 1,0] , 0) - - self.assertEqual( kw[5,2,0] , 1 ) - for j in range(5,10): - self.assertEqual( kw[5,j,0] , 1 ) - - for i in range(10): - self.assertEqual( kw[i,7,0] , 1 ) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_layer.py b/ThirdParty/Ert/python/tests/ecl/test_layer.py deleted file mode 100644 index 370eb6ae8e..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_layer.py +++ /dev/null @@ -1,306 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_layer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from unittest import skipIf -import time - -from ecl.util import IntVector -from ecl.ecl import EclGrid -from ecl.geo import CPolyline -from ecl.ecl.faults import Layer , FaultCollection -from ecl.test import ExtendedTestCase , TestAreaContext - - -class LayerTest(ExtendedTestCase): - def setUp(self): - pass - - - def test_create_layer(self): - layer = Layer(10,10) - self.assertTrue( isinstance( layer , Layer )) - - - def test_add_cell(self): - layer = Layer(10,10) - with self.assertRaises(ValueError): - layer[100,100] = 199 - - with self.assertRaises(ValueError): - layer[100,"X"] = 199 - - with self.assertRaises(ValueError): - layer[100] = 199 - - layer[5,5] = 88 - self.assertEqual(layer[5,5] , 88) - - - - def test_contact(self): - nx = 20 - ny = 10 - layer = Layer(nx,ny) - grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) - - with self.assertRaises(IndexError): - layer.cellContact( (-1,0),(1,1) ) - - with self.assertRaises(IndexError): - layer.cellContact( (20,0),(1,1) ) - - - self.assertFalse( layer.cellContact((0,0) , (2,0)) ) - self.assertFalse( layer.cellContact((1,0) , (1,0)) ) - - self.assertTrue( layer.cellContact((0,0) , (1,0)) ) - self.assertTrue( layer.cellContact((1,0) , (0,0)) ) - - self.assertTrue( layer.cellContact((0,0) , (0,1)) ) - self.assertTrue( layer.cellContact((0,1) , (0,0)) ) - - self.assertFalse( layer.cellContact((0,0) , (1,1)) ) - self.assertFalse( layer.cellContact((1,1) , (0,0)) ) - - self.assertTrue( layer.cellContact((4,0) , (5,0)) ) - self.assertTrue( layer.cellContact((0,4) , (0,5)) ) - - with TestAreaContext("Layer/barrier"): - with open("faults.grdecl" , "w") as f: - f.write("FAULTS\n") - f.write("\'FX\' 5 5 1 10 1 1 'X' /\n") - f.write("\'FY\' 1 10 5 5 1 1 'Y' /\n") - f.write("/") - - faults = FaultCollection( grid , "faults.grdecl") - - layer.addFaultBarrier( faults["FX"] , 0 ) - self.assertFalse( layer.cellContact((4,0) , (5,0)) ) - - layer.addFaultBarrier( faults["FY"] , 0 ) - self.assertFalse( layer.cellContact((0,4) , (0,5)) ) - - self.assertFalse( layer.cellContact((9,4) , (9,5)) ) - self.assertTrue( layer.cellContact((10,4) , (10,5)) ) - - def test_get_barrier(self): - layer = Layer(10,10) - self.assertFalse( layer.leftBarrier(5,5) ) - self.assertFalse( layer.bottomBarrier(5,5) ) - - layer.addIJBarrier([(1,1),(2,1),(2,2)]) - self.assertTrue( layer.bottomBarrier(1,1) ) - self.assertTrue( layer.leftBarrier(2,1) ) - - - - def test_fault_barrier(self): - nx = 120 - ny = 60 - nz = 43 - grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) - with TestAreaContext("python/faults/line_order"): - with open("faults.grdecl" , "w") as f: - f.write("""FAULTS -\'F\' 105 107 50 50 1 43 \'Y\' / -\'F\' 108 108 50 50 1 43 \'X\' / -\'F\' 108 108 50 50 22 43 \'Y\' / -\'F\' 109 109 49 49 1 43 \'Y\' / -\'F\' 110 110 49 49 1 43 \'X\' / -\'F\' 111 111 48 48 1 43 \'Y\' / -/ -""") - with open("faults.grdecl") as f: - faults = FaultCollection( grid , "faults.grdecl" ) - - - # Fault layout: - # - # +---+---+---+---+ - # | - # +---+ + - # | - # +---+ - - - fault = faults["F"] - layer = Layer(nx,ny) - fault_pairs = [((104,49),(104,50)), - ((105,49),(105,50)), - ((106,49),(106,50)), - ((107,49),(108,49)), - ((107,49),(107,50)), - ((108,48),(108,49)), - ((109,48),(110,48)), - ((110,47),(110,48))] - gap_pair = ((109,48),(109,49)) - - - for p1,p2 in fault_pairs: - self.assertTrue(layer.cellContact( p1 , p2 )) - - p1,p2 = gap_pair - self.assertTrue(layer.cellContact( p1 , p2 )) - - - layer.addFaultBarrier(fault , 30 , link_segments = False) - for p1,p2 in fault_pairs: - self.assertFalse(layer.cellContact( p1 , p2 )) - p1,p2 = gap_pair - self.assertTrue(layer.cellContact( p1 , p2 )) - - layer.addFaultBarrier(fault , 30) - p1,p2 = gap_pair - self.assertFalse(layer.cellContact( p1 , p2 )) - - - def test_contact2(self): - nx = 10 - ny = 10 - layer = Layer(nx,ny) - grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) - - # Too short - with self.assertRaises(ValueError): - layer.addIJBarrier( [(1,5)] ) - - # Out of range - with self.assertRaises(ValueError): - layer.addIJBarrier( [(10,15),(5,5)] ) - - # Out of range - with self.assertRaises(ValueError): - layer.addIJBarrier( [(7,7),(-5,5)] ) - - # Must have either i1 == i2 or j1 == j2 - with self.assertRaises(ValueError): - layer.addIJBarrier( [(7,8),(6,5)] ) - - p1 = (0 , 4) - p2 = (0 , 5) - self.assertTrue(layer.cellContact( p1 , p2 )) - layer.addIJBarrier( [(0,5) , (nx , 5)] ) - self.assertFalse(layer.cellContact( p1 , p2 )) - - - - def test_update_connected(self): - nx = 10 - ny = 10 - layer = Layer(nx,ny) - - layer[0,0] = 100 - self.assertEqual( layer[0,0], 100 ) - layer.clearCells() - self.assertEqual( layer[0,0], 0 ) - self.assertEqual( layer.cellSum( ) , 0 ) - - with self.assertRaises(ValueError): - layer.updateConnected( (10,10) , 10 ) - - layer[0,0] = 77 - with self.assertRaises(ValueError): - layer.updateConnected( (0,0) , 10 , org_value = 0) - - layer.updateConnected( (0,0) , 10 ) - self.assertEqual( 10 , layer.cellSum() ) - - layer[0,0] = 0 - layer.updateConnected( (0,0) , 3 ) - self.assertEqual( nx*ny*3 , layer.cellSum() ) - - layer.addIJBarrier( [(5,0), (5,10)] ) - layer.clearCells( ) - self.assertEqual( 0 , layer.cellSum( ) ) - layer.updateConnected( (0,0) , 1 ) - - self.assertEqual( 50 , layer.cellSum( ) ) - self.assertEqual( layer[4,0] , 1 ) - self.assertEqual( layer[5,0] , 0 ) - - layer = Layer(nx,ny) - layer.addIJBarrier( [(5,0), (5,5)] ) - layer.updateConnected( (0,0) , 1 ) - self.assertEqual( 100 , layer.cellSum( ) ) - - - def test_matching(self): - d = 10 - layer = Layer(d,d) - - for i in range(d): - layer[i,i] = 10 - - cell_list = layer.cellsEqual( 1 ) - self.assertEqual( cell_list , [] ) - - cell_list = layer.cellsEqual( 10 ) - self.assertEqual( cell_list , [ (i,i) for i in range(d)] ) - - - def test_add_polyline_barrier(self): - d = 10 - layer = Layer(d,d) - grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) - pl = CPolyline( init_points = [(0 , 0) , (d/2 , d/2) , (d,d)]) - layer.addPolylineBarrier( pl , grid , 0) - for i in range(d): - self.assertTrue( layer.bottomBarrier(i,i) ) - if i < (d - 1): - self.assertTrue( layer.leftBarrier(i+1,i) ) - - - def test_active(self): - d = 10 - layer = Layer(d,d) - with self.assertRaises( ValueError ): - layer.activeCell(d+1,d+2) - - self.assertTrue( layer.activeCell(1,2) ) - - grid = EclGrid.createRectangular( (d,d+1,1) , (1,1,1) ) - with self.assertRaises( ValueError ): - layer.updateActive( grid , 0 ) - - grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) - with self.assertRaises( ValueError ): - layer.updateActive( grid , 10 ) - - actnum = IntVector( initial_size = d*d*1 , default_value = 1) - actnum[0] = 0 - grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) , actnum = actnum) - layer.updateActive( grid , 0 ) - self.assertTrue( layer.activeCell(1,2) ) - self.assertFalse( layer.activeCell(0,0) ) - - - def test_assign(self): - layer = Layer(10,5) - self.assertEqual( layer.cellSum() , 0 ) - - layer.assign(10) - self.assertEqual( layer.cellSum() , 500 ) - - - - def test_count_equal(self): - layer = Layer(10,10) - self.assertEqual( 100 , layer.countEqual( 0 )) - self.assertEqual( 0 , layer.countEqual( 1 )) - - layer[3,3] = 3 - self.assertEqual( 1 , layer.countEqual( 3 )) diff --git a/ThirdParty/Ert/python/tests/ecl/test_npv.py b/ThirdParty/Ert/python/tests/ecl/test_npv.py deleted file mode 100644 index dceda077c1..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_npv.py +++ /dev/null @@ -1,194 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -import datetime -import math - -try: - from unittest2 import skipIf, skipUnless, skipIf -except ImportError: - from unittest import skipIf, skipUnless, skipIf - -from ecl.ecl import EclSum -from ecl.ecl import EclNPV , NPVPriceVector - -from ecl.util import StringList, TimeVector, DoubleVector , CTime -from ecl.test import ExtendedTestCase , TestAreaContext - - -base = "ECLIPSE" -path = "Statoil/ECLIPSE/Gurbat" -case = "%s/%s" % (path, base) - -def callable(x): - return 1 - -def linear1(x): - return x - -def linear2(x): - return 2*x - - -class NPVTest(ExtendedTestCase): - def setUp(self): - self.case = self.createTestPath(case) - - - def test_create(self): - with self.assertRaises(Exception): - npv = EclNPV("/does/not/exist") - - npv = EclNPV( self.case ) - - - def test_eval_npv(self): - npv = EclNPV( self.case ) - with self.assertRaises(ValueError): - npv.eval() - - - def test_expression(self): - npv = EclNPV( self.case ) - self.assertIsNone( npv.getExpression() ) - npv.setExpression( "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") - self.assertEqual( npv.getExpression() , "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") - self.assertIn( "FOPT" , npv.getKeyList() ) - self.assertIn( "FGIT" , npv.getKeyList() ) - - with self.assertRaises(ValueError): - npv.parseExpression("[FOPT") - - with self.assertRaises(ValueError): - npv.parseExpression("FOPT]") - - with self.assertRaises(KeyError): - npv.parseExpression("[FoPT]") - - with self.assertRaises(ValueError): - npv.parseExpression("[FOPR]") - - parsedExpression = npv.parseExpression("[FOPT]") - self.assertEqual( parsedExpression , "FOPT[i]") - self.assertEqual( 1 , len(npv.getKeyList() )) - - - parsedExpression = npv.parseExpression("[FOPT]*2 + [FGPT] - [WOPT:OP_1]") - self.assertEqual( parsedExpression , "FOPT[i]*2 + FGPT[i] - WOPT_OP_1[i]") - keyList = npv.getKeyList() - self.assertEqual( 3 , len(keyList)) - self.assertIn( "FOPT" , keyList ) - self.assertIn( "FGPT" , keyList ) - self.assertIn( "WOPT:OP_1" , keyList ) - - - def test_period(self): - npv = EclNPV( self.case ) - self.assertIsNone(npv.start) - self.assertIsNone(npv.end) - self.assertEqual("1Y" , npv.interval) - - - def test_eval(self): - npv = EclNPV(self.case) - npv.compile("[FOPT]") - npv1 = npv.evalNPV() - - npv2 = 0 - sum = EclSum(self.case) - trange = sum.timeRange() - fopr = sum.blockedProduction("FOPT" , trange) - for v in fopr: - npv2 += v - self.assertAlmostEqual( npv1 , npv2 ) - - npv.compile("[FOPT] - 0.5*[FOPT] - 0.5*[FOPT]") - npv1 = npv.evalNPV() - self.assertTrue( abs(npv1) < 1e-2 ) - - npv.compile("[WOPT:OP_1] - 0.5*[WOPT:OP_1] - 0.5*[WOPT:OP_1]") - npv1 = npv.evalNPV() - self.assertTrue( abs(npv1) < 1e-2 ) - - - - def test_price_vector(self): - with self.assertRaises(ValueError): - NPVPriceVector("NotList") - - with self.assertRaises(ValueError): - NPVPriceVector(1.25) - - with self.assertRaises(ValueError): - NPVPriceVector((1,25)) - - with self.assertRaises(ValueError): - NPVPriceVector([1,2,3]) - - with self.assertRaises(ValueError): - NPVPriceVector([(1,25) , ("String",100,100)]) - - with self.assertRaises(ValueError): - NPVPriceVector([(1,25) , ("String",100)]) - - NPVPriceVector([(datetime.datetime(2010 , 1 , 1 , 0 , 0 , 0) , 100)]) - NPVPriceVector([(datetime.date(2010 , 1 , 1 ) , 100)]) - NPVPriceVector([("19/06/2010" , 100)]) - - with self.assertRaises(ValueError): - NPVPriceVector([("01/01/2000" , 100), - ("01/01/1999" , 100)]) - - with self.assertRaises(ValueError): - NPVPriceVector([("01/01/2000" , "String")]) - - NPVPriceVector([("01/01/2000" , 100)]) - NPVPriceVector([("01/01/2000" , 77.99)]) - NPVPriceVector([("01/01/2000" , callable)]) - - - vec = NPVPriceVector([("01/01/2000" , 100), - ("01/02/2000" , 200), - ("01/03/2000" , 300)]) - - with self.assertRaises(ValueError): - vec.eval( datetime.date( 1999 , 1 , 1)) - - self.assertEqual( datetime.date( 2000 , 1 , 1 ) , NPVPriceVector.assertDate( datetime.date(2000,1,1) )) - self.assertEqual( datetime.date( 2000 , 1 , 1 ) , NPVPriceVector.assertDate( CTime(datetime.date(2000,1,1)) )) - - - self.assertEqual( 100 , vec.eval( datetime.date( 2000 , 1 , 10))) - self.assertEqual( 100 , vec.eval( datetime.datetime( 2000 , 1 , 10 , 0,0,0))) - self.assertEqual( 100 , vec.eval( CTime(datetime.datetime( 2000 , 1 , 10 , 0,0,0)))) - - self.assertEqual( 300 , vec.eval( datetime.date( 2000 , 4, 1))) - - - vec = NPVPriceVector([("01/01/2000" , linear1), - ("01/02/2000" , linear2), - ("01/03/2000" , 300)]) - - self.assertEqual( 300 , vec.eval( datetime.date( 2000 , 3 , 10))) - self.assertEqual( 0 , vec.eval( datetime.date( 2000 , 1 , 1) )) - self.assertEqual( 10 , vec.eval( datetime.date( 2000 , 1 , 11) )) - self.assertEqual( 20 , vec.eval( datetime.date( 2000 , 1 , 21) )) - - self.assertEqual( 0 , vec.eval( datetime.date( 2000 , 2 , 1) )) - self.assertEqual( 20 , vec.eval( datetime.date( 2000 , 2 , 11) )) - self.assertEqual( 40 , vec.eval( datetime.date( 2000 , 2 , 21) )) diff --git a/ThirdParty/Ert/python/tests/ecl/test_region.py b/ThirdParty/Ert/python/tests/ecl/test_region.py deleted file mode 100644 index b24b3d7969..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_region.py +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from ecl.ecl import EclGrid, EclKW, EclRegion, EclDataType -from ecl.ecl.faults import Layer -from ecl.test import ExtendedTestCase -from ecl.util import IntVector - -class RegionTest(ExtendedTestCase): - - def test_equal(self): - grid = EclGrid.createRectangular( (10,10,1) , (1,1,1)) - kw_int = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) - kw_float = EclKW( "FLOAT" , grid.getGlobalSize( ) , EclDataType.ECL_FLOAT ) - - kw_int[0:49] = 1 - region = EclRegion(grid, False) - region.select_equal( kw_int , 1 ) - glist = region.getGlobalList() - for g in glist: - self.assertEqual( kw_int[g] , 1 ) - - with self.assertRaises(ValueError): - region.select_equal( kw_float , 1 ) - - def test_sum(self): - grid = EclGrid.createRectangular( (10,10,1) , (1,1,1)) - kw_mask = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) - int_value = EclKW( "INT" , grid.getGlobalSize( ) , EclDataType.ECL_INT ) - float_value = EclKW( "FLOAT" , grid.getGlobalSize( ) , EclDataType.ECL_FLOAT) - double_value = EclKW( "DOUBLE" , grid.getGlobalSize( ) , EclDataType.ECL_DOUBLE ) - bool_value = EclKW( "BOOL" , grid.getGlobalSize( ) , EclDataType.ECL_BOOL ) - - kw_mask[0:50] = 1 - - for i in range(len(int_value)): - float_value[i] = i - double_value[i] = i - int_value[i] = i - bool_value[i] = True - - region = EclRegion(grid, False) - region.select_equal( kw_mask , 1 ) - - self.assertEqual( int_value.sum( ) , 99*100/2 ) - self.assertEqual( int_value.sum( mask = region ) , 49*50/2 ) - self.assertEqual( double_value.sum( mask = region ) , 1.0*49*50/2 ) - self.assertEqual( float_value.sum( mask = region ) , 1.0*49*50/2 ) - self.assertEqual( bool_value.sum( mask = region ) , 50 ) - - - def test_truth_and_size(self): - actnum = IntVector( initial_size = 100, default_value = 0) - actnum[0:50] = 1 - grid = EclGrid.createRectangular( (10,10,1) , (1,1,1), actnum = actnum) - region = EclRegion(grid, False) - - self.assertFalse( region ) - self.assertEqual( 0, region.active_size( )) - self.assertEqual( 0, region.global_size( )) - - region.select_all( ) - self.assertTrue( region ) - self.assertEqual( 50, region.active_size( )) - self.assertEqual( 100, region.global_size( )) - - region.deselect_all() - self.assertFalse( region ) - self.assertEqual( 0, region.active_size( )) - self.assertEqual( 0, region.global_size( )) - - region = EclRegion(grid, False) - region.select_inactive() - self.assertTrue( region ) - self.assertEqual( 0 , region.active_size( )) - self.assertEqual( 50, region.global_size( )) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_region_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_region_statoil.py deleted file mode 100644 index fbe0c8035c..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_region_statoil.py +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from ecl.ecl import EclFile, EclGrid, EclRegion -from ecl.ecl.faults import Layer -from ecl.test import ExtendedTestCase - - -class RegionTest(ExtendedTestCase): - def setUp(self): - case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") - self.grid = EclGrid(case) - self.rst_file = EclFile("%s.UNRST" % case) - self.init_file = EclFile("%s.INIT" % case) - - - def test_kw_imul(self): - P = self.rst_file["PRESSURE"][5] - fipnum = self.init_file["FIPNUM"][0] - fipnum_copy = fipnum.deep_copy() - - reg = EclRegion(self.grid, False) - reg.select_more(P, 260) - fipnum.mul(-1, mask=reg) - self.assertFalse(fipnum.equal(fipnum_copy)) - - fipnum.mul(-1, mask=reg) - self.assertTrue(fipnum.equal(fipnum_copy)) - - def test_equal(self): - reg1 = EclRegion(self.grid , False) - reg2 = EclRegion(self.grid , False) - - self.assertTrue( reg1 == reg2 ) - - reg1.select_islice(4 , 6) - self.assertFalse( reg1 == reg2 ) - reg2.select_islice(4,7) - self.assertFalse( reg1 == reg2 ) - reg1.select_islice(7,7) - self.assertTrue( reg1 == reg2 ) - - - def test_kw_idiv(self): - P = self.rst_file["PRESSURE"][5] - fipnum = self.init_file["FIPNUM"][0] - fipnum_copy = fipnum.deep_copy() - - reg = EclRegion(self.grid, False) - reg.select_more(P, 260) - fipnum.div(-1, mask=reg) - self.assertFalse(fipnum.equal(fipnum_copy)) - - fipnum.div(-1, mask=reg) - self.assertTrue(fipnum.equal(fipnum_copy)) - - - def test_kw_iadd(self): - P = self.rst_file["PRESSURE"][5] - fipnum = self.init_file["FIPNUM"][0] - fipnum_copy = fipnum.deep_copy() - - reg = EclRegion(self.grid, False) - reg.select_more(P, 260) - fipnum.add(1, mask=reg) - self.assertFalse(fipnum.equal(fipnum_copy)) - - reg.invert() - fipnum.add(1, mask=reg) - - fipnum.sub(1) - self.assertTrue(fipnum.equal(fipnum_copy)) - - - def test_kw_isub(self): - P = self.rst_file["PRESSURE"][5] - fipnum = self.init_file["FIPNUM"][0] - fipnum_copy = fipnum.deep_copy() - - reg = EclRegion(self.grid, False) - reg.select_more(P, 260) - fipnum.sub(1, mask=reg) - self.assertFalse(fipnum.equal(fipnum_copy)) - fipnum.add(1, mask=reg) - self.assertTrue(fipnum.equal(fipnum_copy)) - - - def test_slice(self): - reg = EclRegion(self.grid, False) - reg.select_islice(0, 5) - OK = True - - global_list = reg.getGlobalList() - self.assertEqual(global_list.parent(), reg) - - for gi in global_list: - (i, j, k) = self.grid.get_ijk(global_index=gi) - if i > 5: - OK = False - self.assertTrue(OK) - self.assertTrue(self.grid.getNY() * self.grid.getNZ() * 6 == len(reg.getGlobalList())) - - reg.select_jslice(7, 8, intersect=True) - OK = True - for gi in reg.getGlobalList(): - (i, j, k) = self.grid.get_ijk(global_index=gi) - if i > 5: - OK = False - - if j < 7 or j > 8: - OK = False - - self.assertTrue(OK) - self.assertTrue(2 * self.grid.getNZ() * 6 == len(reg.getGlobalList())) - - reg2 = EclRegion(self.grid, False) - reg2.select_kslice(3, 5) - reg &= reg2 - OK = True - for gi in reg.getGlobalList(): - (i, j, k) = self.grid.get_ijk(global_index=gi) - if i > 5: - OK = False - - if j < 7 or j > 8: - OK = False - - if k < 3 or k > 5: - OK = False - - self.assertTrue(OK) - self.assertTrue(2 * 3 * 6 == len(reg.getGlobalList())) - - - - def test_index_list(self): - reg = EclRegion(self.grid, False) - reg.select_islice(0, 5) - active_list = reg.getActiveList() - global_list = reg.getGlobalList() - - - - def test_polygon(self): - reg = EclRegion(self.grid, False) - (x,y,z) = self.grid.get_xyz( ijk=(10,10,0) ) - dx = 0.1 - dy = 0.1 - reg.select_inside_polygon( [(x-dx,y-dy) , (x-dx,y+dy) , (x+dx,y+dy) , (x+dx,y-dy)] ) - self.assertTrue( self.grid.getNZ() == len(reg.getGlobalList())) - - - def test_heidrun(self): - root = self.createTestPath("Statoil/ECLIPSE/Heidrun") - grid = EclGrid( "%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root) - - polygon = [] - with open("%s/polygon.ply" % root) as fileH: - for line in fileH.readlines(): - tmp = line.split() - polygon.append( (float(tmp[0]) , float(tmp[1]))) - self.assertEqual( len(polygon) , 11 ) - - reg = EclRegion( grid , False ) - reg.select_inside_polygon( polygon ) - self.assertEqual( 0 , len(reg.getGlobalList()) % grid.getNZ()) - - - def test_layer(self): - region = EclRegion(self.grid, False) - layer = Layer( self.grid.getNX() , self.grid.getNY() + 1) - with self.assertRaises(ValueError): - region.selectFromLayer( layer , 0 , 1 ) - - layer = Layer( self.grid.getNX() , self.grid.getNY() ) - layer[0,0] = 1 - layer[1,1] = 1 - layer[2,2] = 1 - - with self.assertRaises(ValueError): - region.selectFromLayer( layer , -1 , 1 ) - - with self.assertRaises(ValueError): - region.selectFromLayer( layer , self.grid.getNZ() , 1 ) - - region.selectFromLayer( layer , 0 , 2 ) - glist = region.getGlobalList() - self.assertEqual(0 , len(glist)) - - region.selectFromLayer( layer , 0 , 1 ) - glist = region.getGlobalList() - self.assertEqual(3 , len(glist)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_removed.py b/ThirdParty/Ert/python/tests/ecl/test_removed.py deleted file mode 100644 index fd41e1e434..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_removed.py +++ /dev/null @@ -1,34 +0,0 @@ -import time -import datetime - -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.ecl import EclFile,EclKW,EclDataType,openFortIO, FortIO - - - -class Removed_2_1_Test(ExtendedTestCase): - def test_ecl_file_block(self): - - with TestAreaContext("name") as t: - kw = EclKW("TEST", 3, EclDataType.ECL_INT) - with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: - kw.fwrite( f ) - - t.sync() - - f = EclFile( "TEST" ) - with self.assertRaises(NotImplementedError): - f.select_block( "KW" , 100 ) - - with self.assertRaises(NotImplementedError): - f.select_global( ) - - with self.assertRaises(NotImplementedError): - f.select_restart_section( index = None , report_step = None , sim_time = None) - - with self.assertRaises(NotImplementedError): - f.select_restart_section( ) - - with self.assertRaises(NotImplementedError): - EclFile.restart_block( "TEST" ) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_restart.py b/ThirdParty/Ert/python/tests/ecl/test_restart.py deleted file mode 100644 index c9e91be399..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_restart.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -from _ctypes import ArgumentError -import os -import datetime -from ecl.ecl import EclFile -from ecl.test import ExtendedTestCase - - - - - -class RestartTest(ExtendedTestCase): - def setUp(self): - self.xfile0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") - self.u_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.file_list = [] - - def addFile( self, filename ): - self.file_list.append(filename) - - - def tearDown(self): - for f in self.file_list: - if os.path.exists(f): - os.unlink(f) - - - def report_file_test(self, fname): - self.assertTrue(EclFile.contains_report_step(fname, 4)) - self.assertTrue(EclFile.contains_report_step(fname, 0)) - self.assertTrue(EclFile.contains_report_step(fname, 62)) - self.assertFalse(EclFile.contains_report_step(fname, -1)) - self.assertFalse(EclFile.contains_report_step(fname, 100)) - - f = EclFile(fname) - self.assertTrue(f.has_report_step(4)) - self.assertTrue(f.has_report_step(0)) - self.assertTrue(f.has_report_step(62)) - - self.assertFalse(f.has_report_step(-1)) - self.assertFalse(f.has_report_step(100)) - - - def test_report(self): - self.report_file_test(self.u_file) - - - def test_date(self): - f = EclFile(self.u_file) - self.assertTrue(f.has_sim_time(datetime.datetime(2001, 6, 1))) - self.assertFalse(f.has_sim_time(datetime.datetime(2005, 6, 1))) - self.assertFalse(f.has_sim_time(datetime.datetime(1999, 6, 1))) - self.assertFalse(f.has_sim_time(datetime.datetime(2001, 6, 11))) - - self.assertTrue(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 1))) - self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2005, 6, 1))) - self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(1999, 6, 1))) - self.assertFalse(EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 11))) - - - def report_list_file_test(self, fname, rlist0): - rlist = EclFile.file_report_list(fname) - self.assertListEqual(rlist, rlist0) - - f = EclFile(fname) - rlist = f.report_list - self.assertListEqual(rlist, rlist0) - - - def test_report_list(self): - rlist0 = range(63) - self.report_list_file_test(self.u_file, rlist0) - - rlist0 = [0] - self.report_list_file_test(self.xfile0, rlist0) - - f = EclFile(self.grid_file) - with self.assertRaises(ArgumentError): #argumentError wraps the expected TypeError - EclFile.file_report_list(f) - - - def test_dates(self): - f = EclFile(self.u_file) - dates = f.dates - self.assertTrue(len(dates) == 63) - - f = EclFile(self.xfile0) - dates = f.dates - self.assertTrue(len(dates) == 1) - self.assertTrue(dates[0] == datetime.datetime(2000, 1, 1)) - - - def test_name(self): - f = EclFile(self.u_file) - self.assertTrue(f.getFilename() == self.u_file) - - f = EclFile(self.xfile0) - self.assertTrue(f.getFilename() == self.xfile0) - - - def test_kw( self ): - f = EclFile(self.u_file) - kw1 = f["SWAT"][40] - kw2 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1)) - kw3 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1), copy=True) - - self.assertTrue(kw1.equal(kw2)) - self.assertTrue(kw1.equal(kw3)) - - with self.assertRaises(IndexError): - kw4 = f.restart_get_kw("SWAT", datetime.datetime(2009, 3, 17)) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_restart_head.py b/ThirdParty/Ert/python/tests/ecl/test_restart_head.py deleted file mode 100644 index bd1468a73e..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_restart_head.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import datetime - -from ecl.test import ExtendedTestCase -from ecl.ecl import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO, EclFileFlagEnum , EclGrid - -class RestartHeadTest(ExtendedTestCase): - def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") - - def test_headers(self): - g = EclGrid( self.grid_file ) - f = EclRestartFile( g , self.unrst_file ) - - headers = f.headers( ) - self.assertEqual( len(headers) , 63 ) - - with self.assertRaises(IndexError): - f.get_header(1000) - - header = f.get_header( 10 ) - details = header.well_details( ) - self.assertTrue( "NXCONZ" in details ) - self.assertTrue( "NCWMAX" in details ) - diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft.py b/ThirdParty/Ert/python/tests/ecl/test_rft.py deleted file mode 100644 index 3ff440b42c..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_rft.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2016 Statoil ASA, Norway. -# -# The file 'test_rft.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -import datetime -from ecl.util import CTime -from ecl.ecl import EclRFTFile, EclRFTCell, EclPLTCell -from ecl.ecl.rft import WellTrajectory -from ecl.test import ExtendedTestCase -from ecl.ecl import EclRFT - -class RFTTest(ExtendedTestCase): - - def test_create(self): - rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) - self.assertEqual( len(rft) , 0 ) - - with self.assertRaises(IndexError): - cell = rft[5] - - def test_repr(self): - rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) - pfx = 'EclRFT(completed_cells = 0, date = 2015-10-01, RFT, MSW)' - self.assertEqual(pfx, repr(rft)[:len(pfx)]) diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft_cell.py b/ThirdParty/Ert/python/tests/ecl/test_rft_cell.py deleted file mode 100644 index 87276f6ad3..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_rft_cell.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -from ecl.ecl import EclRFTCell, EclPLTCell -from ecl.test import ExtendedTestCase - - -# def out_of_range(): -# rftFile = ecl.EclRFTFile(RFT_file) -# rft = rftFile[100] - - -class RFTCellTest(ExtendedTestCase): - def setUp(self): - self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") - self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") - - def test_RFT_cell(self): - i = 10 - j = 8 - k = 100 - depth = 100 - pressure = 65 - swat = 0.56 - sgas = 0.10 - cell = EclRFTCell(i, j, k, depth, pressure, swat, sgas) - - self.assertEqual(i, cell.get_i()) - self.assertEqual(j, cell.get_j()) - self.assertEqual(k, cell.get_k()) - - self.assertFloatEqual(pressure, cell.pressure) - self.assertFloatEqual(depth, cell.depth) - self.assertFloatEqual(swat, cell.swat) - self.assertFloatEqual(sgas, cell.sgas) - self.assertFloatEqual(1 - (sgas + swat), cell.soil) - - - def test_PLT_cell(self): - i = 2 - j = 16 - k = 100 - depth = 100 - pressure = 65 - orat = 0.78 - grat = 88 - wrat = 97213 - conn_start = 214 - conn_end = 400 - flowrate = 111 - oil_flowrate = 12 - gas_flowrate = 132 - water_flowrate = 13344 - - cell = EclPLTCell(i, j, k, depth, pressure, orat, grat, wrat, conn_start, conn_end, flowrate, - oil_flowrate, gas_flowrate, water_flowrate) - - - self.assertEqual(i, cell.get_i()) - self.assertEqual(j, cell.get_j()) - self.assertEqual(k, cell.get_k()) - - self.assertFloatEqual(pressure, cell.pressure) - self.assertFloatEqual(depth, cell.depth) - self.assertFloatEqual(orat, cell.orat) - self.assertFloatEqual(grat, cell.grat) - self.assertFloatEqual(wrat, cell.wrat) - - self.assertFloatEqual(conn_start, cell.conn_start) - self.assertFloatEqual(conn_end, cell.conn_end) - self.assertFloatEqual(flowrate, cell.flowrate) - self.assertFloatEqual(oil_flowrate, cell.oil_flowrate) - self.assertFloatEqual(gas_flowrate, cell.gas_flowrate) - self.assertFloatEqual(water_flowrate, cell.water_flowrate) - - - - - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py deleted file mode 100644 index 22214e9f7f..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_rft_statoil.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from __future__ import print_function -import datetime -from ecl.ecl import EclRFTFile, EclRFTCell, EclPLTCell -from ecl.ecl.rft import WellTrajectory -from ecl.test import ExtendedTestCase - - -class RFTTest(ExtendedTestCase): - def setUp(self): - self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") - self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") - - - def test_RFT_load(self): - rftFile = EclRFTFile(self.RFT_file) - - rft = rftFile[0] - cell = rft.ijkget((32, 53, 0)) - self.assertIsInstance(cell, EclRFTCell) - - self.assertEqual(2, rftFile.size()) - self.assertEqual(0, rftFile.size(well="OP*")) - self.assertEqual(0, rftFile.size(well="XXX")) - self.assertEqual(1, rftFile.size(date=datetime.date(2000, 6, 1))) - self.assertEqual(0, rftFile.size(date=datetime.date(2000, 6, 17))) - - cell = rft.ijkget((30, 20, 1880)) - self.assertIsNone(cell) - - for rft in rftFile: - self.assertTrue(rft.is_RFT()) - self.assertFalse(rft.is_SEGMENT()) - self.assertFalse(rft.is_PLT()) - self.assertFalse(rft.is_MSW()) - - for cell in rft: - self.assertIsInstance(cell, EclRFTCell) - - cell0 = rft.iget_sorted(0) - self.assertIsInstance(cell, EclRFTCell) - rft.sort() - - for h in rftFile.getHeaders(): - print(h) - self.assertIsInstance(h[1], datetime.date) - - - def test_PLT_load(self): - pltFile = EclRFTFile(self.PLT_file) - plt = pltFile[11] - self.assertTrue(plt.is_PLT()) - self.assertFalse(plt.is_SEGMENT()) - self.assertFalse(plt.is_RFT()) - self.assertFalse(plt.is_MSW()) - - for cell in plt: - self.assertIsInstance(cell, EclPLTCell) - - - def test_exceptions(self): - with self.assertRaises(IndexError): - rftFile = EclRFTFile(self.RFT_file) - rft = rftFile[100] - - - def test_basics(self): - wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) - self.assertEqual(len(wt), 38) - self.assertTrue(isinstance(str(wt), str)) - self.assertTrue(isinstance(repr(wt), str)) - self.assertEqual('WellTrajectory(len=38)', repr(wt)) - - def test_trajectory(self): - with self.assertRaises(IOError): - WellTrajectory("/does/no/exist") - - with self.assertRaises(UserWarning): - WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/invalid_float.txt")) - - with self.assertRaises(UserWarning): - WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/missing_item.txt")) - - wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) - self.assertEqual(len(wt), 38) - - with self.assertRaises(IndexError): - p = wt[38] - - p0 = wt[0] - self.assertEqual(p0.utm_x, 458920.671 ) - self.assertEqual(p0.utm_y, 7324939.077 ) - self.assertEqual(p0.measured_depth, 2707.5000) - - pm1 = wt[-1] - p37 = wt[37] - self.assertEqual(p37, pm1) - - - - def test_PLT(self): - rft_file = EclRFTFile(self.createTestPath("Statoil/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT")) - - rft0 = rft_file[0] - rft1 = rft_file[1] - rft2 = rft_file[2] - rft3 = rft_file[3] - - self.assertTrue(rft0.is_RFT()) - self.assertTrue(rft1.is_RFT()) - self.assertTrue(rft2.is_PLT()) - self.assertTrue(rft3.is_PLT()) - - self.assertEqual(len(rft0), 42) - self.assertEqual(len(rft1), 37) - self.assertEqual(len(rft2), 42) - self.assertEqual(len(rft3), 37) - - self.assertFloatEqual(rft0[0].pressure, 0.22919502E+03) - self.assertFloatEqual(rft0[0].depth , 0.21383721E+04) - - self.assertFloatEqual(rft1[0].pressure, 0.22977950E+03) - self.assertFloatEqual(rft1[0].depth , 0.21384775E+04) - - self.assertFloatEqual(rft2[0].pressure, 0.19142435E+03) - self.assertFloatEqual(rft2[0].depth , 0.21383721E+04) diff --git a/ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py b/ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py deleted file mode 100644 index 2d362b8713..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ecl.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.test import ExtendedTestCase - - - -class StatoilFaultTest(ExtendedTestCase): - def loadGrid(self): - grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") - fileH = open(grid_file, "r") - specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) - zcorn = EclKW.read_grdecl(fileH, "ZCORN") - coord = EclKW.read_grdecl(fileH, "COORD") - actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) - - return EclGrid.create(specgrid, zcorn, coord, actnum) - - - - - def test_load(self): - grid = self.loadGrid() - faults_file = self.createTestPath("Statoil/ECLIPSE/Faults/faults.grdecl") - faults = FaultCollection( grid , faults_file ) - for fault in faults: - for layer in fault: - for fl in layer: - fl.verify() - - - - def test_splitLine2(self): - grid = self.loadGrid( ) - f = Fault(grid , "DF41_C") - -# 179 180 181 -# o o o o o o o o o o o o o o -# | -# 78 | -# o o o o o o o o o o o o o o -# | -# 77 | -# o o o o o o o o o o o o o o -# | -# 76 | -# o o o o o o o o o o o o o o -# | -# 75 | -# o o o o o o o o o o o o o o -# -# 74 -# o o o o o o o o o o o o o o -# -# 73 -# o o o o-----o o o o o o o o o o -# | -# 72 | -# o o o o-----o o o o o o o o o o -# -# 71 -# o o o o-----o o o o o o o o o o -# | -# 70 | -# o o o o o o o o o o o o o o -# | -# 69 | -# o o o o o o o o o o o o o o -# -# 68 -# o o o o o o o o o o o o o o -# -# 67 -# o o o o o o o o o o o o o o -# -# 66 -# o o o o o o o o o o o o o o -# | -# 65 | -# o o o o-----o o o o o o o o o o - - - f.addRecord( 179, 179 , 77 , 78 , 0 , 42 , 'X' ) - f.addRecord( 179, 179 , 75 , 76 , 0 , 41 , 'X' ) - f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'X' ) - f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y' ) - f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y-' ) - - f.addRecord( 180, 180 , 70 , 70 , 0 , 42 , 'Y' ) - f.addRecord( 180, 180 , 69 , 70 , 0 , 42 , 'X' ) - f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'X' ) - f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'Y-' ) - - - ij_polyline = f.getIJPolyline( 19 ) - ij_list = [(180, 79), (180, 77), (180, 75), - (180, 73), (181, 73), (181, 72), (180, 72), - (180, 71), (181, 71), (181, 69), - (181, 66), (181, 65), (180, 65)] - - self.assertEqual(ij_polyline , ij_list) - - - - - - diff --git a/ThirdParty/Ert/python/tests/ecl/test_sum.py b/ThirdParty/Ert/python/tests/ecl/test_sum.py deleted file mode 100644 index 2401a4c925..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_sum.py +++ /dev/null @@ -1,315 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -import datetime -import csv -import shutil -from unittest import skipIf, skipUnless, skipIf - -from ecl.ecl import EclSum, EclSumVarType, FortIO, openFortIO, EclKW, EclDataType, EclSumKeyWordVector -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.test.ecl_mock import createEclSum - -def fopr(days): - return days - -def fopt(days): - return days - -def fgpt(days): - if days < 50: - return days - else: - return 100 - days - -class SumTest(ExtendedTestCase): - - - def test_mock(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - self.assertTrue("FOPT" in case) - self.assertFalse("WWCT:OPX" in case) - - def test_TIME_special_case(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - keys = case.keys() - self.assertEqual( len(keys) , 2 ) - self.assertIn( "FOPT" , keys ) - self.assertIn( "FOPR" , keys ) - - - keys = case.keys(pattern = "*") - self.assertEqual( len(keys) , 2 ) - self.assertIn( "FOPT" , keys ) - self.assertIn( "FOPR" , keys ) - - - def test_identify_var_type(self): - self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h") - self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR ) - self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR ) - self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR ) - self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) - - case = createEclSum("CSV" , [("FOPT", None , 0) , - ("FOPR" , None , 0), - ("AARQ" , None , 10), - ("RGPT" , None ,1)]) - - node1 = case.smspec_node( "FOPT" ) - self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) - - node2 = case.smspec_node( "AARQ:10" ) - self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) - self.assertEqual( node2.getNum( ) , 10 ) - - node3 = case.smspec_node("RGPT:1") - self.assertEqual( node3.varType( ) , EclSumVarType.ECL_SMSPEC_REGION_VAR ) - self.assertEqual( node3.getNum( ) , 1 ) - self.assertTrue( node3.isTotal( )) - - self.assertLess( node1, node3 ) - self.assertGreater( node2, node3 ) - self.assertEqual( node1, node1 ) - self.assertNotEqual( node1, node2 ) - - with self.assertRaises(TypeError): - a = node1 < 1 - - def test_csv_export(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - sep = ";" - with TestAreaContext("ecl/csv"): - case.exportCSV( "file.csv" , sep = sep) - self.assertTrue( os.path.isfile( "file.csv" ) ) - input_file = csv.DictReader( open("file.csv") , delimiter = sep ) - for row in input_file: - self.assertIn("DAYS", row) - self.assertIn("DATE", row) - self.assertIn("FOPT", row) - self.assertIn("FOPR", row) - self.assertEqual( len(row) , 4 ) - break - - - - with TestAreaContext("ecl/csv"): - case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep) - self.assertTrue( os.path.isfile( "file.csv" ) ) - input_file = csv.DictReader( open("file.csv") , delimiter=sep) - for row in input_file: - self.assertIn("DAYS", row) - self.assertIn("DATE", row) - self.assertIn("FOPT", row) - self.assertEqual( len(row) , 3 ) - break - - - - with TestAreaContext("ecl/csv"): - date_format = "%y-%m-%d" - sep = "," - case.exportCSV( "file.csv" , keys = ["F*"] , sep=sep , date_format = date_format) - self.assertTrue( os.path.isfile( "file.csv" ) ) - with open("file.csv") as f: - time_index = -1 - for line in f.readlines(): - tmp = line.split( sep ) - self.assertEqual( len(tmp) , 4) - - if time_index >= 0: - d = datetime.datetime.strptime( tmp[1] , date_format ) - self.assertEqual( case.iget_date( time_index ) , d ) - - time_index += 1 - - - def test_solve(self): - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - self.assert_solve( case ) - - def assert_solve(self, case): - with self.assertRaises( KeyError ): - case.solveDays( "MISSING:KEY" , 0.56) - - sol = case.solveDays( "FOPT" , 150 ) - self.assertEqual( len(sol) , 0 ) - - sol = case.solveDays( "FOPT" , -10 ) - self.assertEqual( len(sol) , 0 ) - - sol = case.solveDays( "FOPT" , 50 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50 ) - - sol = case.solveDays( "FOPT" , 50.50 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50.50 ) - - sol = case.solveDays( "FOPR" , 50.90 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50.00 + 1.0/86400 ) - - sol = case.solveDates("FOPR" , 50.90) - t = case.getDataStartTime( ) + datetime.timedelta( days = 50 ) + datetime.timedelta( seconds = 1 ) - self.assertEqual( sol[0] , t ) - - sol = case.solveDays( "FOPR" , 50.90 , rates_clamp_lower = False) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 51.00 ) - - sol = case.solveDays( "FGPT" ,25.0) - self.assertEqual( len(sol) , 2 ) - self.assertFloatEqual( sol[0] , 25.00 ) - self.assertFloatEqual( sol[1] , 75.00 ) - - sol = case.solveDates( "FGPT" , 25 ) - self.assertEqual( len(sol) , 2 ) - t0 = case.getDataStartTime( ) - t1 = t0 + datetime.timedelta( days = 25 ) - t2 = t0 + datetime.timedelta( days = 75 ) - self.assertEqual( sol[0] , t1 ) - self.assertEqual( sol[1] , t2 ) - - - def test_ecl_sum_vector_algebra(self): - scalar = 0.78 - addend = 2.718281828459045 - - # setup - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - with self.assertRaises( KeyError ): - case.scaleVector( "MISSING:KEY" , scalar) - case.shiftVector( "MISSING:KEY" , addend) - - # scale all vectors with scalar - for key in case.keys(): - x = case.get_values(key) # get vector key - case.scaleVector(key , scalar) - y = case.get_values(key) - x = x * scalar # numpy vector scaling - for i in range(len(x)): - self.assertFloatEqual(x[i], y[i]) - - # shift all vectors with addend - for key in case.keys(): - x = case.get_values(key) # get vector key - case.shiftVector(key , addend) - y = case.get_values(key) - x = x + addend # numpy vector shifting - for i in range(len(x)): - self.assertFloatEqual(x[i], y[i]) - - - def test_different_names(self): - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - with TestAreaContext("sum_different"): - case.fwrite( ) - shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC") - with self.assertRaises(IOError): - case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY") - - with self.assertRaises(IOError): - case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY") - - case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" ) - self.assert_solve( case2 ) - - def test_invalid(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = 100, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - with TestAreaContext("sum_invalid"): - case.fwrite( ) - with open("CASE.txt", "w") as f: - f.write("No - this is not EclKW file ....") - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" ) - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" ) - - kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT) - kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT) - - with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - kw2.fwrite( f ) - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW") - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" ) - - - def test_kw_vector(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = 100, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - kw_list = EclSumKeyWordVector( case ) - kw_list.add_keyword("FOPT") - kw_list.add_keyword("FOPR") - kw_list.add_keyword("FGPT") - - t = case.getDataStartTime( ) + datetime.timedelta( days = 43 ); - data = case.get_interp_row( kw_list , t ) - for d1,d2 in zip(data, [ case.get_interp("FOPT", date = t), - case.get_interp("FOPT", date = t), - case.get_interp("FOPT", date = t) ]): - - self.assertFloatEqual(d1,d2) - - tmp = [] - for key in kw_list: - tmp.append(key) - - for (k1,k2) in zip(kw_list,tmp): - self.assertEqual(k1,k2) diff --git a/ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py b/ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py deleted file mode 100644 index aa543b250e..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py +++ /dev/null @@ -1,500 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -import datetime - -from unittest import skipIf, skipUnless, skipIf - -from ecl.ecl import EclSum, EclFile - -from ecl.util import StringList, TimeVector, DoubleVector - -from ecl.test import ExtendedTestCase , TestAreaContext -import csv - -base = "ECLIPSE" -path = "Statoil/ECLIPSE/Gurbat" -case = "%s/%s" % (path, base) - - - - -def sum_get(*args): - sum = args[0] - key = args[1] - vec = sum[key] - - -class SumTest(ExtendedTestCase): - def setUp(self): - self.case = self.createTestPath(case) - self.ecl_sum = EclSum(self.case) - - self.assertIsInstance(self.ecl_sum, EclSum) - - - def test_load(self): - self.assertIsNotNone(self.ecl_sum, "Load failed") - - - def test_invalid(self): - with self.assertRaises(IOError): - sum = EclSum("Does/not/exist") - - - def test_KeyError(self): - sum = self.ecl_sum - with self.assertRaises(KeyError): - v = sum["KeyMissing"] - - with self.assertRaises(KeyError): - v = sum.get_interp("Missing" , days = 750) - - with self.assertRaises(KeyError): - v = sum.get_interp_vector("Missing" , days_list = [750]) - - - - def test_contains(self): - self.assertTrue( "FOPT" in self.ecl_sum) - self.assertFalse( "MISSING" in self.ecl_sum ) - - - def test_interp(self): - sum = self.ecl_sum - - self.assertAlmostEqual(sum.get_interp("WWCT:OP_3", days=750), 0.11719122) - self.assertAlmostEqual(sum.get_interp("WWCT:OP_3", date=datetime.date(2004, 1, 1)), 0.603358387947) - - v = sum.get_interp_vector("WOPT:OP_1", days_list=[100, 200, 400]) - self.assertAlmostEqualList([805817.11875, 1614955.34677419, 3289267.67857143 ], v) - - v = sum.get_interp_vector("WGPT:OP_2", date_list=[datetime.date(2002, 1, 1), datetime.date(2003, 1, 1), datetime.date(2004, 1, 1)]) - self.assertAlmostEqualList(v, [8.20773632e+08, 9.68444032e+08, 1.02515213e+09]) - - self.assertEqual(sum.get_interp("FOPT" , days = 0) , 0) - - self.assertEqual(sum.get_interp("WOPR:OP_1" , days = 0) , 0) - self.assertEqual(sum.get_interp("WOPR:OP_1" , date=datetime.date(2000,1,1)) , 0) - - self.assertEqual(sum.get_interp("WOPR:OP_1" , days = 31) , 7996) - self.assertEqual(sum.get_interp("WOPR:OP_1" , date=datetime.date(2000,2,1)) , 7996) - - FPR = sum["FPR"] - self.assertFloatEqual(sum.get_interp("FPR" , days = 0) , FPR[0].value) - self.assertFloatEqual(sum.get_interp("FPR" , days = 31) , FPR[1].value) - - with self.assertRaises(ValueError): - sum.get_interp("WOPR:OP_1") - - with self.assertRaises(ValueError): - sum.get_interp("WOPR:OP_1" , days=10 , date = datetime.date(2000,1,1)) - - - def test_LLINEAR(self): - sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/LGRISSUE/EM-LTAA-ISEG_CARFIN_NWPROPS")) - self.assertTrue( sum.has_key("LLINEARS") ) - - - - def test_wells(self): - wells = self.ecl_sum.wells() - wells.sort() - self.assertListEqual([well for well in wells], ["OP_1", "OP_2", "OP_3", "OP_4", "OP_5", "WI_1", "WI_2", "WI_3"]) - - wells = self.ecl_sum.wells(pattern="*_3") - wells.sort() - self.assertListEqual([well for well in wells], ["OP_3", "WI_3"]) - - groups = self.ecl_sum.groups() - groups.sort() - self.assertListEqual([group for group in groups], ['GMWIN', 'OP', 'WI']) - - - def test_last( self ): - last = self.ecl_sum.get_last("FOPT") - self.assertFloatEqual(last.value, 38006336.0) - self.assertFloatEqual(last.days, 1826.0) - self.assertEqual(last.date, datetime.datetime(2004, 12, 31, 0, 0, 0)) - - self.assertFloatEqual(self.ecl_sum.get_last_value("FGPT"), 6605249024.0) - self.assertEqual( len(self.ecl_sum) , 63 ) - - - def test_dates( self ): - sum = self.ecl_sum - d = sum.dates - - self.assertEqual(d[0], datetime.datetime(2000, 1, 1, 0, 0, 0)) - self.assertEqual(d[62], datetime.datetime(2004, 12, 31, 0, 0, 0)) - self.assertEqual(len(d), 63) - self.assertEqual(d[25], datetime.datetime(2001, 12, 1, 0, 0, 0)) - self.assertEqual(sum.iget_date(25), datetime.datetime(2001, 12, 1, 0, 0, 0)) - - mpl_dates = sum.mpl_dates - self.assertAlmostEqual(mpl_dates[25], 730820) - - days = sum.days - self.assertAlmostEqual(days[50], 1461) - - self.assertEqual(sum.start_time, datetime.datetime(2000, 1, 1, 0, 0, 0)) - self.assertEqual(sum.end_time, datetime.datetime(2004, 12, 31, 0, 0, 0)) - self.assertTrue(sum.check_sim_time(datetime.datetime(2004, 12, 31, 0, 0, 0))) - self.assertEqual(sum.end_date , datetime.date(2004, 12, 31)) - - - - def test_dates2( self ): - sum = EclSum(self.createTestPath("Statoil/ECLIPSE/FF12/FF12_2013B3_AMAP2")) - self.assertEqual(sum.end_date , datetime.date(2045, 1, 1)) - - - - - - def test_keys(self): - sum = self.ecl_sum - self.assertRaises(KeyError, sum.__getitem__, "BJARNE") - - v = sum["FOPT"] - self.assertEqual(len(v), 63) - - - def test_index(self): - sum = self.ecl_sum - index = sum.get_key_index("TCPUDAY") - self.assertEqual(index, 10239) - - - def test_report(self): - sum = self.ecl_sum - self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 1)), 10) - self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 3)), -1) - self.assertEqual(sum.get_report(date=datetime.date(1980, 10, 3)), -1) - self.assertEqual(sum.get_report(date=datetime.date(2012, 10, 3)), -1) - - self.assertEqual(sum.get_report(days=91), 3) - self.assertEqual(sum.get_report(days=92), -1) - self.assertAlmostEqual(sum.get_interp("FOPT", days=91), sum.get_from_report("FOPT", 3)) - - self.assertEqual(sum.first_report, 1) - self.assertEqual(sum.last_report, 62) - - self.assertEqual(sum.get_report_time(10), datetime.date(2000, 10, 1)) - self.assertFloatEqual(sum.get_from_report("FOPT", 10), 6.67447e+06) - - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test skipped") - def test_fwrite(self): - # todo: What is tested here? - # work_area = TestArea("python/sum-test/fwrite", True) - with TestAreaContext("python/sum-test/fwrite") as work_area: - self.ecl_sum.fwrite(ecl_case="CASE") - self.assertTrue(True) - - - def test_block(self): - sum = self.ecl_sum - index_ijk = sum.get_key_index("BPR:15,28,1") - index_num = sum.get_key_index("BPR:1095") - self.assertEqual(index_ijk, index_num) - - - def test_restart(self): - hist = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/history/T07-4A-W2011-18-P1")) - base = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE")) - pred = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE"), include_restart=False) - - self.assertIsNotNone(hist) - self.assertIsNotNone(base) - self.assertIsNotNone(pred) - - - def test_case1(self ): - self.assertTrue(self.ecl_sum.path == self.createTestPath(path)) - self.assertTrue(self.ecl_sum.base == base) - self.assertTrue(self.ecl_sum.case == self.createTestPath(case)) - self.assertTrue(self.ecl_sum.abs_path == self.createTestPath(path)) - - - def test_case2( self ): - cwd = os.getcwd() - os.chdir(self.createTestPath(path)) - sum = EclSum(base) - self.assertIsNone(sum.path) - self.assertTrue(sum.base == base) - self.assertTrue(sum.case == base) - self.assertTrue(sum.abs_path == self.createTestPath(path)) - os.chdir(cwd) - - - def test_var_properties( self ): - sum = self.ecl_sum - self.assertRaises(KeyError, sum.smspec_node, "BJARNE") - - node = sum.smspec_node("FOPT") - self.assertTrue(node.isTotal()) - self.assertFalse(node.isHistorical()) - - node = sum.smspec_node("FOPR") - self.assertFalse(node.isTotal()) - self.assertFalse(node.isHistorical()) - self.assertTrue(node.keyword == "FOPR") - - node = sum.smspec_node("FOPRH") - self.assertFalse(node.isTotal()) - self.assertTrue(node.isHistorical()) - self.assertTrue(node.isRate()) - self.assertTrue(node.keyword == "FOPRH") - - node = sum.smspec_node("WOPR:OP_1") - self.assertFalse(node.isTotal()) - self.assertTrue(node.isRate()) - self.assertTrue(node.keyword == "WOPR") - - node = sum.smspec_node("WOPT:OP_1") - self.assertTrue(node.isTotal()) - self.assertFalse(node.isRate()) - self.assertTrue(node.unit == "SM3") - self.assertTrue(node.wgname == "OP_1") - self.assertTrue(node.keyword == "WOPT") - - self.assertTrue(sum.unit("FOPR") == "SM3/DAY") - - node = sum.smspec_node("FOPTH") - self.assertTrue(node.isTotal()) - self.assertFalse(node.isRate()) - self.assertIsNone(node.wgname) - node = sum.smspec_node("BPR:1095") - self.assertEqual(node.num, 1095) - - def test_stringlist_gc(self): - sum = EclSum(self.case) - wells = sum.wells() - well1 = wells[0] - del wells - self.assertTrue(well1 == "OP_1") - - - def test_stringlist_reference(self): - sum = EclSum(self.case) - wells = sum.wells() - self.assertListEqual([well for well in wells], ['OP_1', 'OP_2', 'OP_3', 'OP_4', 'OP_5', 'WI_1', 'WI_2', 'WI_3']) - self.assertIsInstance(wells, StringList) - - - def test_stringlist_setitem(self): - sum = EclSum(self.case) - wells = sum.wells() - wells[0] = "Bjarne" - well0 = wells[0] - self.assertTrue(well0 == "Bjarne") - self.assertTrue(wells[0] == "Bjarne") - wells[0] = "XXX" - self.assertTrue(well0 == "Bjarne") - self.assertTrue(wells[0] == "XXX") - - - def test_segment(self): - sum = EclSum(self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4")) - segment_vars = sum.keys("SOFR:F-8:*") - self.assertIn("SOFR:F-8:1", segment_vars) - for var in segment_vars: - tmp = var.split(":") - nr = int(tmp[2]) - self.assertTrue(nr >= 0) - - def test_return_types(self): - self.assertIsInstance(self.ecl_sum.alloc_time_vector(True), TimeVector) - key_index = self.ecl_sum.get_general_var_index("FOPT") - self.assertIsInstance(self.ecl_sum.alloc_data_vector(key_index, True), DoubleVector) - - def test_timeRange(self): - sum = EclSum(self.case) - with self.assertRaises(TypeError): - trange = sum.timeRange(interval = "1") - trange = sum.timeRange(interval = "1X") - trange = sum.timeRange(interval = "YY") - trange = sum.timeRange(interval = "MY") - - with self.assertRaises(ValueError): - trange = sum.timeRange( start = datetime.datetime(2000,1,1) , end = datetime.datetime(1999,1,1) ) - - sim_start = datetime.datetime(2000, 1, 1, 0, 0, 0) - sim_end = datetime.datetime(2004, 12, 31, 0, 0, 0) - trange = sum.timeRange( interval = "1Y") - self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) - self.assertTrue( trange[1] == datetime.date( 2001 , 1 , 1 )) - self.assertTrue( trange[2] == datetime.date( 2002 , 1 , 1 )) - self.assertTrue( trange[3] == datetime.date( 2003 , 1 , 1 )) - self.assertTrue( trange[4] == datetime.date( 2004 , 1 , 1 )) - self.assertTrue( trange[5] == datetime.date( 2005 , 1 , 1 )) - - trange = sum.timeRange( interval = "1M") - self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) - - trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15), interval = "1M") - self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) - - trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15) , end = datetime.date( 2003 , 1 , 15), interval = "1M") - self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2003 , 2 , 1 )) - - trange = sum.timeRange( start = datetime.date( 2002 , 1 , 15) , end = datetime.datetime( 2003 , 1 , 15,0,0,0), interval = "1M") - self.assertTrue( trange[0] == datetime.date( 2002 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2003 , 2 , 1 )) - - - - # Loading this dataset is a test of loading a case where one report step is missing. - def test_Heidrun(self): - sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS")) - self.assertEqual( 452 , len(sum)) - self.assertFloatEqual( 1.8533144e+8 , sum.get_last_value("FOPT")) - - trange = sum.timeRange( start = datetime.date( 2015 , 1 , 1), interval = "1M") - self.assertTrue( trange[0] == datetime.date( 2016 , 2 , 1 )) - for t in trange: - sum.get_interp( "FOPT" , date = t ) - - - - def test_regularProduction(self): - sum = EclSum(self.case) - with self.assertRaises(TypeError): - trange = TimeVector.createRegular( sum.start_time , sum.end_time , "1M" ) - prod = sum.blockedProduction("FOPR" , trange) - - with self.assertRaises(KeyError): - trange = TimeVector.createRegular( sum.start_time , sum.end_time , "1M" ) - prod = sum.blockedProduction("NoNotThis" , trange) - - trange = sum.timeRange(interval = "2Y") - self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2006 , 1 , 1 )) - - trange = sum.timeRange(interval = "5Y") - self.assertTrue( trange[0] == datetime.date( 2000 , 1 , 1 )) - self.assertTrue( trange[-1] == datetime.date( 2005 , 1 , 1 )) - - trange = sum.timeRange(interval = "6M") - wprod1 = sum.blockedProduction("WOPT:OP_1" , trange) - wprod2 = sum.blockedProduction("WOPT:OP_2" , trange) - wprod3 = sum.blockedProduction("WOPT:OP_3" , trange) - wprod4 = sum.blockedProduction("WOPT:OP_4" , trange) - wprod5 = sum.blockedProduction("WOPT:OP_5" , trange) - - fprod = sum.blockedProduction("FOPT" , trange) - gprod = sum.blockedProduction("GOPT:OP" , trange) - wprod = wprod1 + wprod2 + wprod3 + wprod4 + wprod5 - for (w,f,g) in zip(wprod, fprod,gprod): - self.assertFloatEqual( w , f ) - self.assertFloatEqual( w , g ) - - - - def test_writer(self): - writer = EclSum.writer("CASE" , datetime.date( 2000 , 1 , 1) , 10 , 10 , 5) - self.assertIsInstance(self.ecl_sum, EclSum) - - - writer.addVariable( "FOPT" ) - self.assertTrue( writer.has_key( "FOPT" )) - - writer.addTStep( 1 , 100 ) - - - def test_aquifer(self): - case = EclSum( self.createTestPath( "Statoil/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) - self.assertTrue( "AAQR:2" in case ) - - - def test_restart_mapping(self): - history = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) - total = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0") , include_restart = True) - - history_dates = history.get_dates( ) - total_dates = total.get_dates( ) - for i in range(len(history_dates)): - self.assertEqual( history_dates[i] , total_dates[i] ) - - - keys = history.keys( pattern = "W*") - for key in keys: - if key in total: - self.assertEqual( history.iget( key , 5 ) , total.iget( key , 5 )) - - self.assertFalse( "WGPR:NOT_21_D" in history ) - self.assertTrue( "WGPR:NOT_21_D" in total ) - - self.assertEqual( total.iget( "WGPR:NOT_21_D", 5) , 0) # Default value - - def test_write(self): - with TestAreaContext("my_space") as area: - intersect_summary = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) - self.assertIsNotNone(intersect_summary) - - write_location = os.path.join(os.getcwd(), "CASE") - intersect_summary.fwrite(ecl_case=write_location) - - reloaded_summary = EclSum(write_location) - self.assertEqual(intersect_summary.keys(), reloaded_summary.keys()) - - def test_ix_case(self): - intersect_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well")) - self.assertIsNotNone(intersect_summary) - - self.assertTrue( - "HWELL_PROD" in - [intersect_summary.smspec_node(key).wgname for key in intersect_summary.keys()] - ) - - eclipse_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/ECL100/E100_CREATE_REGION_AROUND_WELL")) - self.assertIsNotNone(eclipse_summary) - - hwell_padder = lambda key : key if key.split(":")[-1] != "HWELL_PR" else key + "OD" - self.assertEqual( - intersect_summary.keys("WWCT*"), - map(hwell_padder, eclipse_summary.keys("WWCT*")) - ) - - def test_ix_write(self): - for data_set in [ - "Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well", - "Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_grid2.SMSPEC" - ]: - - with TestAreaContext("my_space" + data_set.split("/")[-1]) as area: - intersect_summary = EclSum(self.createTestPath(data_set)) - self.assertIsNotNone(intersect_summary) - - write_location = os.path.join(os.getcwd(), "CASE") - intersect_summary.fwrite(ecl_case=write_location) - - reloaded_summary = EclSum(write_location) - self.assertEqual( - list(intersect_summary.keys()), - list(reloaded_summary.keys()) - ) - - def test_ix_caseII(self): - troll_summary = EclSum( self.createTestPath("Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_grid2.SMSPEC")) - self.assertIsNotNone(troll_summary) - self.assertTrue("WMCTL:Q21BH1" in list(troll_summary.keys())) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py index 19617aad8d..88d4fa9fb7 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py @@ -79,10 +79,8 @@ def kw_test(self, data_type, data, fmt): name1 = "file1.txt" name2 = "file2.txt" kw = EclKW("TEST", len(data), data_type) - i = 0 - for d in data: + for (i,d) in enumerate(data): kw[i] = d - i += 1 file1 = cwrap.open(name1, "w") kw.fprintf_data(file1, fmt) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py index 811e7ec6db..c4dc3f46a5 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py @@ -67,7 +67,7 @@ def fgpt(days): def create_case(case = "CSV", restart_case = None, restart_step = -1, data_start = None): length = 100 - return createEclSum(case , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], + return createEclSum(case , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("FGPT" , None , 0, "SM3")], sim_length_days = length, num_report_step = 10, num_mini_step = 10, @@ -82,12 +82,12 @@ class SumTest(EclTest): def test_mock(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) self.assertTrue("FOPT" in case) self.assertFalse("WWCT:OPX" in case) def test_TIME_special_case(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) keys = case.keys() self.assertEqual( len(keys) , 2 ) self.assertIn( "FOPT" , keys ) @@ -107,10 +107,10 @@ def test_identify_var_type(self): self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR ) self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) - case = createEclSum("CSV" , [("FOPT", None , 0) , - ("FOPR" , None , 0), - ("AARQ" , None , 10), - ("RGPT" , None ,1)]) + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , + ("FOPR" , None , 0, "SM3/DAY"), + ("AARQ" , None , 10, "???"), + ("RGPT" , None ,1, "SM3")]) node1 = case.smspec_node( "FOPT" ) self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) @@ -133,7 +133,7 @@ def test_identify_var_type(self): a = node1 < 1 def test_csv_export(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) sep = ";" with TestAreaContext("ecl/csv"): case.exportCSV( "file.csv" , sep = sep) @@ -147,7 +147,7 @@ def test_csv_export(self): self.assertEqual( len(row) , 4 ) break - + self.assertEqual(case.unit("FOPT"), "SM3") with TestAreaContext("ecl/csv"): case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep) @@ -270,6 +270,7 @@ def test_different_names(self): case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" ) self.assert_solve( case2 ) + self.assertEqual(case.unit("FOPR"), "SM3/DAY") def test_invalid(self): case = create_case() @@ -300,7 +301,7 @@ def test_invalid(self): def test_kw_vector(self): case1 = create_case() - case2 = createEclSum("CSV" , [("FOPR", None , 0) , ("FOPT" , None , 0), ("FWPT" , None , 0)], + case2 = createEclSum("CSV" , [("FOPR", None , 0, "SM3/DAY") , ("FOPT" , None , 0, "SM3"), ("FWPT" , None , 0, "SM3")], sim_length_days = 100, num_report_step = 10, num_mini_step = 10, @@ -366,6 +367,21 @@ def test_vector_select_all(self): self.assertIn(key, ecl_sum_vector) + def test_first_last(self): + case = create_case() + with self.assertRaises(KeyError): + case.last_value("NO_SUCH_KEY") + last_fopt = case.last_value("FOPT") + values = case.get_values("FOPT") + self.assertEqual( last_fopt, values[-1]) + + with self.assertRaises(KeyError): + case.first_value("NO_SUCH_KEY") + + first_fopt = case.first_value("FOPT") + self.assertEqual(first_fopt, values[0]) + + def test_time_range(self): case = create_case() with self.assertRaises(ValueError): @@ -486,3 +502,61 @@ def test_units(self): case = EclSum("UNITS") self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_LAB_UNITS) + + + def test_numpy_vector(self): + case = create_case() + + with self.assertRaises(KeyError): + case.numpy_vector("NO_SUCH_KEY") + + numpy_vector = case.numpy_vector("FOPT") + self.assertEqual(len(numpy_vector), len(case)) + numpy_dates = case.numpy_dates + self.assertEqual( numpy_dates[0].tolist(), case.getDataStartTime()) + self.assertEqual( numpy_dates[-1].tolist(), case.getEndTime()) + + dates = case.dates + self.assertEqual( dates[0], case.getDataStartTime()) + self.assertEqual( dates[-1], case.getEndTime()) + + dates = [datetime.datetime(2000,1,1)] + case.dates + [datetime.datetime(2020,1,1)] + fopr = case.numpy_vector("FOPR", time_index = dates) + fopt = case.numpy_vector("FOPT", time_index = dates) + + + self.assertEqual(fopr[0], 0) + self.assertEqual(fopr[-1], 0) + + self.assertEqual(fopt[0], 0) + self.assertEqual(fopt[0], case.first_value("FOPT")) + self.assertEqual(fopt[-1], case.last_value("FOPT")) + + + + def test_pandas(self): + case = create_case() + dates = [datetime.datetime(2000,1,1)] + case.dates + [datetime.datetime(2020,1,1)] + frame = case.pandas_frame(column_keys=["FOPT", "FOPR"], time_index = dates) + + fopr = frame["FOPR"] + fopt = frame["FOPT"] + + self.assertEqual(fopr[0], 0) + self.assertEqual(fopr[-1], 0) + + self.assertEqual(fopt[0], 0) + self.assertEqual(fopt[0], case.first_value("FOPT")) + self.assertEqual(fopt[-1], case.last_value("FOPT")) + + + with self.assertRaises(ValueError): + frame = case.pandas_frame(column_keys=[]) + + with self.assertRaises(ValueError): + frame = case.pandas_frame(column_keys=["NO_KEY"]) + + frame = case.pandas_frame( ) + rows, columns = frame.shape + self.assertEqual(len(case.keys()), columns) + self.assertEqual(len(case), rows) diff --git a/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt b/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt deleted file mode 100644 index 1795decd10..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_convex_hull.py - test_cpolyline.py - test_cpolyline_collection.py - test_geometry_tools.py - test_intersection.py - test_point_in_polygon.py - test_polygon_slicing.py - test_polyline.py - test_surface.py - test_geo_pointset.py - test_geo_region.py -) - -add_python_package("python.tests.geometry" ${PYTHON_INSTALL_PREFIX}/tests/geometry "${TEST_SOURCES}" False) - -addPythonTest(tests.geometry.test_geo_pointset.GeoPointsetTest) -addPythonTest(tests.geometry.test_geo_region.GeoRegionTest) -addPythonTest(tests.geometry.test_surface.SurfaceTest) -addPythonTest(tests.geometry.test_polyline.PolylineTest) -addPythonTest(tests.geometry.test_intersection.IntersectionTest) -addPythonTest(tests.geometry.test_convex_hull.ConvexHullTest) -addPythonTest(tests.geometry.test_point_in_polygon.PointInPolygonTest) -addPythonTest(tests.geometry.test_polygon_slicing.PolygonSlicingTest) -addPythonTest(tests.geometry.test_cpolyline.CPolylineTest) -addPythonTest(tests.geometry.test_cpolyline_collection.CPolylineCollectionTest) -addPythonTest(tests.geometry.test_geometry_tools.GeometryToolsTest ) diff --git a/ThirdParty/Ert/python/tests/geometry/__init__.py b/ThirdParty/Ert/python/tests/geometry/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/geometry/test_convex_hull.py b/ThirdParty/Ert/python/tests/geometry/test_convex_hull.py deleted file mode 100644 index e0c27305f6..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_convex_hull.py +++ /dev/null @@ -1,27 +0,0 @@ -from ecl.geo.geometry_tools import GeometryTools -from ecl.test.extended_testcase import ExtendedTestCase - - -class ConvexHullTest(ExtendedTestCase): - - def test_ccw(self): - p1 = (0, 0) - p2 = (1, 0) - p3 = (0, 1) - p4 = (0, 2) - - - self.assertTrue(GeometryTools.ccw(p1, p2, p3) > 0) # Counter-clockwise - self.assertTrue(GeometryTools.ccw(p1, p3, p2) < 0) # Clockwise - self.assertTrue(GeometryTools.ccw(p1, p3, p4) == 0) # Colinear - - - def test_convex_hull(self): - points = [(0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0.5, 0.5), (0.25, 0.25), (0.5, 1.25), (0.5, 0.75)] - result = GeometryTools.convexHull(points) - self.assertEqual(result, [(0, 0), (0, 1), (0.5, 1.25), (1, 1), (1, 0)]) - - - points = [(0, -0.5), (0, 0.5), (-0.5, 0), (0.5, 0), (0, 0), (0.5, 0.5)] - result = GeometryTools.convexHull(points) - self.assertEqual(result, [(-0.5, 0), (0, 0.5), (0.5, 0.5), (0.5, 0), (0, -0.5)]) \ No newline at end of file diff --git a/ThirdParty/Ert/python/tests/geometry/test_cpolyline.py b/ThirdParty/Ert/python/tests/geometry/test_cpolyline.py deleted file mode 100644 index 6439f15923..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_cpolyline.py +++ /dev/null @@ -1,171 +0,0 @@ -import math - -from ecl.geo import CPolyline , Polyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext - - -class CPolylineTest(ExtendedTestCase): - def setUp(self): - self.polyline1 = self.createTestPath("local/geometry/pol11.xyz") - self.polyline2 = self.createTestPath("local/geometry/pol8.xyz") - self.polyline3 = self.createTestPath("local/geometry/pol8_noend.xyz") - - - - def test_construction(self): - polyline = CPolyline() - self.assertEqual( len(polyline) , 0 ) - - with self.assertRaises(IOError): - CPolyline.createFromXYZFile( "Does/not/exist" ) - - p1 = CPolyline.createFromXYZFile( self.polyline1 ) - self.assertEqual( len(p1) , 13 ) - x,y = p1[-1] - self.assertEqual(x , 389789.263184) - self.assertEqual(y , 6605784.945099) - - p2 = CPolyline.createFromXYZFile( self.polyline2 ) - self.assertEqual( len(p2) , 20 ) - x,y = p2[-1] - self.assertEqual(x , 396056.314697) - self.assertEqual(y , 6605835.119461) - - p3 = CPolyline.createFromXYZFile( self.polyline3 ) - self.assertEqual( len(p3) , 20 ) - x,y = p3[-1] - self.assertEqual(x , 396056.314697) - self.assertEqual(y , 6605835.119461) - - - - def test_front(self): - polyline = CPolyline() - polyline.addPoint( 1 , 1 ) - polyline.addPoint( 0 , 0 , front = True ) - self.assertEqual( len(polyline) , 2 ) - - x,y = polyline[0] - self.assertEqual(x,0) - self.assertEqual(y,0) - - x,y = polyline[1] - self.assertEqual(x,1) - self.assertEqual(y,1) - - - def test_equal(self): - pl1 = CPolyline(name = "Poly1" , init_points = [(0,0) , (1,1) , (2,2)]) - pl2 = CPolyline(name = "Poly2" , init_points = [(0,0) , (1,1) , (2,2)]) - pl3 = CPolyline(init_points = [(0,0) , (1,1) , (2,3)]) - - self.assertEqual( pl1 , pl1 ) - self.assertEqual( pl1 , pl2 ) - self.assertFalse( pl1 == pl3 ) - - - def test_length(self): - polyline = CPolyline( init_points = [(0,1)]) - self.assertEqual( polyline.segmentLength() , 0 ) - - polyline = CPolyline( init_points = [(0,0) , (1,0) , (1,1) , (2,2)]) - self.assertEqual( polyline.segmentLength() , 2 + math.sqrt(2)) - - - def test_extend_to_bbox(self): - bbox = [(0,0) , (10,0) , (10,10) , (0,10)] - - polyline = CPolyline( init_points = [(11,11) , (13,13)]) - with self.assertRaises(ValueError): - polyline.extendToBBox( bbox , start = False ) - - - polyline = CPolyline( init_points = [(1,1) , (3,3)]) - - line1 = polyline.extendToBBox( bbox , start = True ) - self.assertEqual( line1 , CPolyline( init_points = [(1,1) , (0,0)])) - - line1 = polyline.extendToBBox( bbox , start = False ) - self.assertEqual( line1 , CPolyline( init_points = [(3,3) , (10,10)])) - - - - - def test_item(self): - polyline = CPolyline() - polyline.addPoint( 10 , 20 ) - self.assertEqual( len(polyline) , 1 ) - - with self.assertRaises(TypeError): - (x,y) = polyline["KEY"] - - with self.assertRaises(IndexError): - (x,y) = polyline[10] - - (x,y) = polyline[0] - self.assertEqual( x , 10 ) - self.assertEqual( y , 20 ) - - polyline.addPoint(20,20) - (x,y) = polyline[-1] - self.assertEqual( x , 20 ) - self.assertEqual( y , 20 ) - - - def test_cross_segment(self): - polyline = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) - # - # x - # | - # | - # | - # x-------x - # - - self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (0.5 , -0.5))) - self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (1.5 , 0.5))) - - self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , ( 0.5 , 1.5))) - self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , (-0.5 , 0.5))) - self.assertFalse(polyline.segmentIntersects( (0.5 , 1.5) , ( 1.5 , 1.5))) - - self.assertTrue( polyline.segmentIntersects( (1.0 , 1.0) , ( 1.5 , 1.5))) - self.assertTrue( polyline.segmentIntersects( ( 1.5 , 1.5) , (1.0 , 1.0))) - self.assertTrue( polyline.segmentIntersects( ( 1 , 0) , (1.0 , 1.0))) - - - - def test_intersects(self): - polyline1 = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) - polyline2 = CPolyline( init_points = [(0.50,0.50) , (1.50,0.50)]) - polyline3 = Polyline( init_points = [(0.50,0.50) , (1.50,0.50)]) - polyline4 = CPolyline( init_points = [(0.50,1.50) , (1.50,1.50)]) - - self.assertTrue( polyline1.intersects( polyline2 )) - self.assertTrue( polyline1.intersects( polyline3 )) - self.assertFalse( polyline1.intersects( polyline4 )) - - - def test_intersects2(self): - polyline = CPolyline( init_points = [(2,10),(2,100)]) - self.assertTrue( polyline.intersects( polyline )) - - - - def test_name(self): - p1 = CPolyline() - self.assertTrue( p1.getName() is None ) - - p2 = CPolyline( name = "Poly2" ) - self.assertEqual( p2.getName() , "Poly2") - - - def test_unzip(self): - pl = CPolyline( init_points = [(0,3) , (1,4) , (2,5)] ) - x,y = pl.unzip() - self.assertEqual(x , [0,1,2]) - self.assertEqual(y , [3,4,5]) - - - diff --git a/ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py b/ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py deleted file mode 100644 index 11ab6a63cd..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py +++ /dev/null @@ -1,133 +0,0 @@ -import gc - -from ecl.geo import CPolylineCollection , CPolyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext -from ecl.util import DoubleVector - -class CPolylineCollectionTest(ExtendedTestCase): - - def test_construction(self): - pc = CPolylineCollection() - self.assertEqual(len(pc) , 0) - - - def test_add_polyline(self): - pc = CPolylineCollection() - pl = pc.createPolyline( name = "TestP" ) - self.assertTrue( isinstance(pl , CPolyline)) - self.assertEqual(len(pc) , 1) - self.assertTrue( "TestP" in pc ) - - with self.assertRaises(IndexError): - pl = pc[2] - - p0 = pc[0] - self.assertTrue( p0 == pl ) - - with self.assertRaises(KeyError): - pn = pc["missing"] - - pn = pc["TestP"] - self.assertTrue( pn == pl ) - - px = CPolyline( name = "TestP") - with self.assertRaises(KeyError): - pc.addPolyline( px ) - self.assertEqual(len(pc) , 1) - - - p2 = CPolyline( name = "Poly2") - pc.addPolyline( p2 ) - - self.assertEqual( len(pc) , 2 ) - self.assertTrue( "Poly2" in pc ) - - l = [] - for p in pc: - l.append(p) - self.assertEqual( len(pc) , 2 ) - - - points = [(0,1) , (1,1)] - pc.addPolyline( points , name = "XYZ") - self.assertTrue( "XYZ" in pc ) - - - - - def create_collection(self): - collection = CPolylineCollection() - p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)]) - p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)]) - collection.addPolyline( p1 ) - collection.addPolyline( p2 ) - - tail = p1[-1] - self.assertEqual( tail , (2,12)) - self.assertEqual(p1.getName() , "POLY1") - - tail = p2[-1] - self.assertEqual( tail , (20,120)) - self.assertEqual(p2.getName() , "POLY2") - - return collection - - - def test_gc_polyline(self): - # This should test that the elements in the collection can be - # safely accessed, even after the polyline objects p1 and p2 - # from create_collection() have gone out of scope. - c = self.create_collection() - v = DoubleVector(initial_size = 10000) - - p1 = c[0] - tail = p1[-1] - self.assertEqual( tail , (2,12)) - self.assertEqual(p1.getName() , "POLY1") - - p2 = c[1] - tail = p2[-1] - self.assertEqual( tail , (20,120)) - self.assertEqual(p2.getName() , "POLY2") - - - def get_polyline(self): - collection = self.create_collection() - return collection[0] - - - def test_gc_collection(self): - p1 = self.get_polyline() - tail = p1[-1] - self.assertEqual( tail , (2,12)) - self.assertEqual( p1.getName() , "POLY1") - - def create_coll2(self): - coll1 = self.create_collection() - coll2 = coll1.shallowCopy() - coll1.addPolyline( CPolyline( name = "POLY3" , init_points = [(1,1) , (2,2) , (1,3) , (1,1)])) - - self.assertEqual(len(coll1) , 3) - self.assertTrue( "POLY3" in coll1 ) - - self.assertEqual(len(coll2) , 2) - self.assertFalse( "POLY3" in coll2 ) - - return coll2 - - - def test_shallow_copy(self): - coll2 = self.create_coll2() - self.assertEqual(len(coll2) , 2) - - p1 = coll2["POLY1"] - tail = p1[-1] - self.assertEqual( tail , (2,12)) - self.assertEqual(p1.getName() , "POLY1") - - p2 = coll2["POLY2"] - tail = p2[-1] - self.assertEqual( tail , (20,120)) - self.assertEqual(p2.getName() , "POLY2") - diff --git a/ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py b/ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py deleted file mode 100644 index 1d1c423f17..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py +++ /dev/null @@ -1,27 +0,0 @@ -from ecl.geo import GeoPointset, Surface -from ecl.test import ExtendedTestCase, TestAreaContext - - -class GeoPointsetTest(ExtendedTestCase): - - def test_init(self): - gp = GeoPointset() - self.assertEqual(0, len(gp)) - - def test_repr(self): - gp = GeoPointset() - self.assertTrue(repr(gp).startswith('GeoPointset')) - - def test_from_surface(self): - srf_path = self.createTestPath("local/geometry/surface/valid_ascii.irap") - srf = Surface(srf_path) - gp = GeoPointset.fromSurface(srf) - self.assertEqual(3871, len(srf)) - self.assertEqual(len(srf), len(gp)) - - def test_getitem(self): - srf_path = self.createTestPath("local/geometry/surface/valid_ascii.irap") - srf = Surface(srf_path) - gp = GeoPointset.fromSurface(srf) - for i in (561, 1105, 1729, 2465, 2821): - self.assertEqual(gp[i], srf[i]) diff --git a/ThirdParty/Ert/python/tests/geometry/test_geo_region.py b/ThirdParty/Ert/python/tests/geometry/test_geo_region.py deleted file mode 100644 index 949ced3128..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_geo_region.py +++ /dev/null @@ -1,88 +0,0 @@ -from ecl.geo import GeoRegion, GeoPointset, CPolyline, Surface -from ecl.test import ExtendedTestCase, TestAreaContext - - -class GeoRegionTest(ExtendedTestCase): - - def test_init(self): - pointset = GeoPointset() - georegion = GeoRegion(pointset) - self.assertEqual(0, len(georegion)) - - def test_repr(self): - pointset = GeoPointset() - georegion = GeoRegion(pointset) - self.assertTrue(repr(georegion).startswith('GeoRegion')) - - @staticmethod - def small_surface(): - ny,nx = 12,12 - xinc,yinc = 1, 1 - xstart,ystart = -1, -1 - angle = 0.0 - s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) - return Surface(*s_args) - - def test_select_polygon(self): - surface = self.small_surface() - pointset = GeoPointset.fromSurface(surface) - georegion = GeoRegion(pointset) - self.assertEqual(0, len(georegion)) - points = [(-0.1,2.0), (1.9,8.1), (6.1,8.1), (9.1,5), (7.1,0.9)] - polygon = CPolyline(name='test_polygon', init_points=points) - picked = 52 # https://www.futilitycloset.com/2013/04/24/picks-theorem/ - georegion.select_inside(polygon) - self.assertEqual(picked, len(georegion)) - georegion.deselect_inside(polygon) - self.assertEqual(0, len(georegion)) - georegion.select_outside(polygon) - self.assertEqual(len(surface) - picked, len(georegion)) - georegion.deselect_outside(polygon) - self.assertEqual(0, len(georegion)) - - georegion.select_inside(polygon) - georegion.select_outside(polygon) - self.assertEqual(len(surface), len(georegion)) - georegion.deselect_inside(polygon) - georegion.deselect_outside(polygon) - self.assertEqual(0, len(georegion)) - - georegion.select_inside(polygon) - self.assertEqual(picked, len(georegion)) - internal_square = [(2.5,2.5), (2.5,6.5), (6.5,6.5), (6.5,2.5)] - georegion.deselect_inside(CPolyline(init_points=internal_square)) - self.assertEqual(picked - 4*4, len(georegion)) # internal square is 4x4 - - - def test_select_halfspace(self): - surface = self.small_surface() - pointset = GeoPointset.fromSurface(surface) - georegion = GeoRegion(pointset) - self.assertEqual(0, len(georegion)) - line = [(-0.1,2.0), (1.9,8.1)] - picked = 118 - georegion.select_above(line) - self.assertEqual(picked, len(georegion)) - georegion.deselect_above(line) - self.assertEqual(0, len(georegion)) - georegion.select_below(line) - self.assertEqual(len(surface) - picked, len(georegion)) - georegion.deselect_below(line) - self.assertEqual(0, len(georegion)) - - georegion.select_above(line) - georegion.select_below(line) - self.assertEqual(len(surface), len(georegion)) - georegion.deselect_above(line) - georegion.deselect_below(line) - self.assertEqual(0, len(georegion)) - - - def test_raises(self): - surface = self.small_surface() - pointset = GeoPointset.fromSurface(surface) - georegion = GeoRegion(pointset) - with self.assertRaises(ValueError): - georegion.select_above(((2,), (1, 3))) - with self.assertRaises(ValueError): - georegion.select_above((('not-a-number', 2), (1, 3))) diff --git a/ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py b/ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py deleted file mode 100644 index 0656677ad6..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py +++ /dev/null @@ -1,80 +0,0 @@ -import math - -from ecl.geo import Polyline, GeometryTools , CPolyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext - - -class GeometryToolsTest(ExtendedTestCase): - - def test_distance(self): - p1 = (1,1) - p2 = (1,2,3) - with self.assertRaises(ValueError): - GeometryTools.distance( p1 , p2) - - with self.assertRaises(TypeError): - GeometryTools.distance( 1 , p2 ) - - p2 = (2,2) - self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(2)) - - p1 = (1,1,1) - p2 = (2,2,2) - self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(3)) - - - def test_join__polylines(self): - l1 = Polyline( init_points = [(0,1) , (1,1)]) - l2 = CPolyline( init_points = [(2,-1) , (2,0)]) - l3 = CPolyline( init_points = [(2,2) , (2,3)]) - l4 = Polyline( ) - l5 = CPolyline( init_points = [(0.5,0),(0.5,2)] ) - - with self.assertRaises( ValueError ): - GeometryTools.joinPolylines( l1 , l4 ) - - with self.assertRaises( ValueError ): - GeometryTools.joinPolylines( l4 , l1 ) - - self.assertIsNone( GeometryTools.joinPolylines( l1 , l5 )) - - self.assertEqual( GeometryTools.joinPolylines( l1 , l2 ) , [(1,1) , (2,0)] ) - - - def test_join_extend_polylines_onto(self): - l1 = Polyline( init_points = [(0,1) , (1,1)]) - l2 = CPolyline( init_points = [(2,0) , (2,2)]) - l3 = CPolyline( init_points = [(0.5 , 0) , (0.5 , 2)]) - l4 = Polyline( init_points = [(0,5) , (1,5)]) - l5 = Polyline( init_points = [(0,5)]) - - self.assertIsNone( GeometryTools.connectPolylines( l1 , l3 )) - - with self.assertRaises( ValueError ): - GeometryTools.connectPolylines( l1 , l5 ) - - with self.assertRaises( ValueError ): - GeometryTools.connectPolylines( l1 , l4 ) - - self.assertEqual( GeometryTools.connectPolylines( l1 , l2 ) , [(1,1) , (2,1)]) - - def test_ray_line_intersection(self): - p = GeometryTools.rayLineIntersection((0,0) , (1,0) , (5,-1),(5,1)) - self.assertEqual( p , (5,0)) - - self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (-1,0) , (5,-1),(5,1)) ) - self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,1) , (5,-1),(5,1)) ) - self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,-1) , (5,-1),(5,1)) ) - - p = GeometryTools.rayLineIntersection((0,0) , (1,1) , (5,-6),(5,6)) - self.assertEqual( p , (5,5)) - - - def test_nearest_point(self): - l1 = Polyline( init_points = [(0,0) , (10,0)]) - - p = GeometryTools.nearestPointOnPolyline( (5 , 5) , l1 ) - self.assertEqual( p , (5 , 0) ) - - diff --git a/ThirdParty/Ert/python/tests/geometry/test_intersection.py b/ThirdParty/Ert/python/tests/geometry/test_intersection.py deleted file mode 100644 index af78512e84..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_intersection.py +++ /dev/null @@ -1,47 +0,0 @@ -from ecl.geo import GeometryTools -from ecl.test.extended_testcase import ExtendedTestCase - - -class IntersectionTest(ExtendedTestCase): - - def test_intersection(self): - - p1 = (0.0, 0.0) - p2 = (10.0, 0.0) - p3 = (5.0, -5.0) - p4 = (5.0, 5.0) - - self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p4), (5.0, 0.0)) - - p5 = (0.0, 5.0) - self.assertEqual(GeometryTools.lineIntersection(p1, p2, p3, p5), (2.5, 0)) - - - self.assertEqual(GeometryTools.lineIntersection((0.0, 0.0), (1.0, 1.0), (0.0, 1.0), (1.0, 0.0)), (0.5, 0.5)) - - - def test_coincident(self): - p1 = (0.0, 0.0) - p2 = (10.0, 10.0) - - self.assertIsNone( GeometryTools.lineIntersection(p1, p2, p1, p2) ) - - - def test_parallel(self): - p1 = (0.0, 0.0) - p2 = (10.0, 0.0) - - p3 = (0.0, 1.0) - p4 = (10.0, 1.0) - - self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) - - - def test_intersection_outside_segments(self): - p1 = (0.0, 0.0) - p2 = (10.0, 0.0) - - p3 = (-1.0, -1.0) - p4 = (-1.0, 1.0) - - self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) diff --git a/ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py b/ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py deleted file mode 100644 index 8faeb9ca5f..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py +++ /dev/null @@ -1,60 +0,0 @@ -from ecl.geo.geometry_tools import GeometryTools -from ecl.geo.polyline import Polyline -from ecl.test.extended_testcase import ExtendedTestCase - - -class PointInPolygonTest(ExtendedTestCase): - - def test_point_in_polygon(self): - p1 = (0.5, 0.5) - p2 = (2, 2) - p3 = (1, 0.5) # on the edge - - poly1 = [(0, 0), (1, 0), (1, 1), (0, 1)] # Not explicitly closed - poly2 = [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] # explicitly closed - - self.assertTrue(GeometryTools.pointInPolygon(p1, poly1)) - self.assertTrue(GeometryTools.pointInPolygon(p1, poly2)) - - self.assertFalse(GeometryTools.pointInPolygon(p2, poly1)) - self.assertFalse(GeometryTools.pointInPolygon(p2, poly2)) - - self.assertTrue(GeometryTools.pointInPolygon(p3, poly1)) - - - def test_point_in_polyline(self): - p1 = (0.5, 0.5) - p2 = (2, 2) - - poly = Polyline() - poly.addPoint(0, 0) - poly.addPoint(1, 0) - poly.addPoint(1, 1) - poly.addPoint(0, 1) - poly.addPoint(0, 0) - - self.assertTrue(GeometryTools.pointInPolygon(p1, poly)) - self.assertTrue(GeometryTools.pointInPolygon(p1, poly)) - - self.assertFalse(GeometryTools.pointInPolygon(p2, poly)) - self.assertFalse(GeometryTools.pointInPolygon(p2, poly)) - - - def test_point_in_strange_polygon(self): - p1 = (0.5, 0.51) - p2 = (0.5, 0.49) - - poly = [(0,0), (0, 1), (0.6, 0.5), (0.4, 0.5), (1, 1), (1, 0)] - - self.assertFalse(GeometryTools.pointInPolygon(p1, poly)) - self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) - - - def test_point_in_polygon_with_3_element_points(self): - p1 = (0.5, 0.51, 0.2) - p2 = (0.5, 0.49, 0.1) - - poly = [(0,0,9), (0,1,9), (0.6,0.5), (0.4,0.5,9), (1,1), (1,0,9)] - - self.assertFalse(GeometryTools.pointInPolygon(p1, poly)) - self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) \ No newline at end of file diff --git a/ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py b/ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py deleted file mode 100644 index e2493e6822..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py +++ /dev/null @@ -1,139 +0,0 @@ -from math import sqrt -from ecl.geo.geometry_tools import GeometryTools -from ecl.test import ExtendedTestCase - - -class PolygonSlicingTest(ExtendedTestCase): - - def test_slicing_internal_hull(self): - polygon = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4)] - edge = [(0,0) , (10,0) , (10,10), (0,10) , (0,0)] - - sliced = GeometryTools.slicePolygon(edge , polygon) - expected = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4),(2.0,4.0),(2,2)] - self.assertEqual(sliced, expected) - - - - def test_line_to_ray(self): - p0 = (0.0, 0.0) - p1 = (1.0, 1.0) - p2 = (1.0, 0.0) - - ray = GeometryTools.lineToRay(p0, p1) - self.assertEqual(ray, (1.0 / sqrt(2.0), 1.0 / sqrt(2.0))) - - ray = GeometryTools.lineToRay(p1, p0) - self.assertEqual(ray, (-1.0 / sqrt(2.0), -1.0 / sqrt(2.0))) - - ray = GeometryTools.lineToRay(p0, p2) - self.assertEqual(ray, (1.0, 0.0)) - - - def test_ray_line_intersection(self): - p0 = (0.0, 0.0) - p1 = (0.0, 1.0) - p2 = (1.0, 1.0) - p3 = (1.0, 0.0) - p5 = (2.0, 1.0) - - ray1 = GeometryTools.lineToRay(p0, p2) - ray2 = GeometryTools.lineToRay(p2, p0) - ray3 = GeometryTools.lineToRay(p0, p5) - - self.assertEqual((0.5, 0.5), GeometryTools.rayLineIntersection(p0, ray1, p1, p3)) - self.assertIsNone(GeometryTools.rayLineIntersection(p0, ray2, p1, p3)) #ray2 is ray1 reversed (no backwards intersections) - - self.assertEqual((1.0, 0.5), GeometryTools.rayLineIntersection(p0, ray3, p2, p3)) - self.assertIsNone(GeometryTools.rayLineIntersection(p0, ray3, p1, p2)) - - - - - def test_slicing_short_line_segment(self): - p0 = (0.0, 0.0) - p1 = (0.0, 1.0) - p2 = (1.0, 1.0) - p3 = (1.0, 0.0) - polygon = [p0, p1, p2, p3, p0] - lp0 = (0.2, 0.5) - lp1 = (0.4, 0.5) - line = [lp0, lp1] - - result = GeometryTools.slicePolygon(polygon, line) - - expected = [(0.0, 0.5), p1, p2, (1.0, 0.5), lp1, lp0, (0.0, 0.5)] - - self.assertEqual(result, expected) - - - def test_slicing_bendy_line_segments(self): - p0 = (0.0, 0.0) - p1 = (0.0, 1.0) - p2 = (1.0, 1.0) - p3 = (1.0, 0.0) - polygon = [p0, p1, p2, p3, p0] - - lp0 = (0.2, 0.5) - lp1 = (0.4, 0.5) - lp2 = (0.4, 0.3) - line = [lp0, lp1, lp2] - - expected = [(0.0, 0.5), p1, p2, p3, (0.4, 0.0), lp2, lp1, lp0, (0.0, 0.5)] - - result = GeometryTools.slicePolygon(polygon, line) - self.assertEqual(result, expected) - - line = [lp2, lp1, lp0] - result = GeometryTools.slicePolygon(polygon, line) - self.assertEqual(result, expected) - - - def test_slicing_same_segment(self): - p0 = (0.0, 0.0) - p1 = (0.0, 1.0) - p2 = (1.0, 1.0) - p3 = (1.0, 0.0) - polygon = [p0, p1, p2, p3, p0] - - lp0 = (0.2, 0.5) - lp1 = (0.4, 0.5) - lp2 = (0.4, 0.3) - lp3 = (0.2, 0.3) - - line = [lp0, lp1, lp2, lp3] - result = GeometryTools.slicePolygon(polygon, line) - expected = [(0.0, 0.5), (0.0, 0.3), lp3, lp2, lp1, lp0, (0.0, 0.5)] - self.assertEqual(result, expected) - - line = [lp3, lp2, lp1, lp0] - result = GeometryTools.slicePolygon(polygon, line) - expected = [(0.0, 0.3), (0.0, 0.5), lp0, lp1, lp2, lp3, (0.0, 0.3)] - self.assertEqual(result, expected) - - - def test_ray_polyline_intersections(self): - # /.\ - # . - # . - # (4)---------+----(3) - # /________:_____:_________ - # \ . | - # (1)--+----(2) - # | . - # | . - # (0) . - - - polygon = [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 2.0), (-1.0, 2.0)] - - p0 = (0.5, 0.0) - ray0 = (0.0, 1.0) - intersections0 = GeometryTools.rayPolygonIntersections(p0, ray0, polygon) - self.assertEqual(intersections0, [(1, (0.5, 1.0)), (3, (0.5, 2.0))]) - - - p1 = (1.5, 1.5) - ray1 = (-1.0, 0.0) - intersections1 = GeometryTools.rayPolygonIntersections(p1, ray1, polygon) - self.assertEqual(intersections1, [(2, (1, 1.5))]) diff --git a/ThirdParty/Ert/python/tests/geometry/test_polyline.py b/ThirdParty/Ert/python/tests/geometry/test_polyline.py deleted file mode 100644 index bd9e262cff..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_polyline.py +++ /dev/null @@ -1,193 +0,0 @@ - -from ecl.geo import Polyline, GeometryTools -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext - - -class PolylineTest(ExtendedTestCase): - def setUp(self): - self.polyline = self.createTestPath("local/geometry/pol11.xyz") - self.closed_polyline = self.createTestPath("local/geometry/pol8.xyz") - - def test_construction(self): - polyline = Polyline(name="test line") - - with self.assertRaises(IndexError): - polyline.isClosed() - - self.assertEqual(polyline.getName(), "test line") - - self.assertEqual(len(polyline), 0) - - polyline.addPoint(0, 0, 0) - self.assertEqual(len(polyline), 1) - - polyline.addPoint(1, 1, 0) - self.assertEqual(len(polyline), 2) - - polyline.addPoint(1, 1.5) - self.assertEqual(len(polyline), 3) - - self.assertEqual(polyline[0], (0, 0, 0)) - self.assertEqual(polyline[1], (1, 1, 0)) - self.assertEqual(polyline[2], (1, 1.5)) - - polyline.addPoint(0, 1, 0) - self.assertFalse(polyline.isClosed()) - - polyline.addPoint(0, 0, 0) - self.assertTrue(polyline.isClosed()) - - - - def test_construction_default(self): - with self.assertRaises(TypeError): - pl = Polyline( init_points = 1 ) - - with self.assertRaises(TypeError): - pl = Polyline( init_points = [1.23] ) - - pl = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) - self.assertEqual( len(pl) , 3 ) - - - - - def test_iteration(self): - values = [(0, 0, 0), - (1, 0, 0), - (1, 1, 0), - (1, 1, 1)] - - polyline = Polyline(name="iteration line") - - for p in values: - polyline.addPoint(*p) - - for index, point in enumerate(polyline): - self.assertEqual(point, values[index]) - - - - def test_read_xyz_from_file(self): - with self.assertRaises(IOError): - XYZIo.readXYZFile("does/not/exist.xyz") - - polyline = XYZIo.readXYZFile(self.polyline) - - self.assertEqual(polyline.getName(), "pol11.xyz") - self.assertEqual(len(polyline), 13) - self.assertFalse(polyline.isClosed()) - self.assertEqual(polyline[0], (390271.843750, 6606121.334396, 1441.942627)) # first point - self.assertEqual(polyline[12], (389789.263184, 6605784.945099, 1446.627808)) # last point - - polyline = XYZIo.readXYZFile(self.closed_polyline) - - self.assertEqual(polyline.getName(), "pol8.xyz") - self.assertEqual(len(polyline), 21) - self.assertTrue(polyline.isClosed()) - self.assertEqual(polyline[0], (396202.413086, 6606091.935028, 1542.620972)) # first point - self.assertEqual(polyline[20], (396202.413086, 6606091.935028, 1542.620972)) # last point - - - def test_closed(self): - pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)]) - self.assertFalse( pl.isClosed() ) - pl.addPoint( 1,0 ) - self.assertEqual( 4 , len(pl) ) - self.assertTrue( pl.isClosed() ) - - pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)]) - self.assertFalse( pl.isClosed() ) - pl.assertClosed( ) - self.assertEqual( 4 , len(pl) ) - self.assertTrue( pl.isClosed() ) - - - def test_save(self): - with TestAreaContext("polyline/fwrite") as work_area: - p1 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) - p2 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) - self.assertTrue( p1 == p2 ) - - XYZIo.saveXYFile(p1 , "poly.xy") - - p2 = XYZIo.readXYFile("poly.xy") - self.assertTrue( p1 == p2 ) - - - def test_unzip(self): - p2 = Polyline( init_points = [(1,0) , (1,1) , (1,2)]) - p3 = Polyline( init_points = [(1,0,1) , (1,1,2) , (1,2,3)]) - (x,y) = p2.unzip() - self.assertEqual( x , [1,1,1]) - self.assertEqual( y , [0,1,2]) - - (x,y,z) = p3.unzip() - self.assertEqual( x , [1,1,1]) - self.assertEqual( y , [0,1,2]) - self.assertEqual( z , [1,2,3]) - - - with self.assertRaises(ValueError): - (x,y,z) = p2.unzip() - - with self.assertRaises(ValueError): - (x,y) = p3.unzip() - - - def test_intersection(self): - p1 = Polyline( init_points = [(0,0) , (1,0)]) - p2 = Polyline( init_points = [(0.5 , 0.5) , (0.5,-0.5)]) - p3 = Polyline( init_points = [(0,1) , (1,1)]) - - self.assertTrue(GeometryTools.polylinesIntersect( p1 , p2 )) - self.assertFalse( GeometryTools.polylinesIntersect( p2 , p3 )) - self.assertFalse( GeometryTools.polylinesIntersect( p1 , p3 )) - - self.assertTrue( p1.intersects(p2) ) - self.assertTrue( p2.intersects(p1) ) - - self.assertTrue( not p1.intersects(p3) ) - self.assertTrue( not p3.intersects(p1) ) - - - def test_add(self): - l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) - l2 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) - - l3 = l1 + l2 - self.assertEqual( len(l3) , 4 ) - self.assertEqual( l1[0] , l3[0] ) - self.assertEqual( l1[1] , l3[1] ) - self.assertEqual( l1[0] , l3[2] ) - self.assertEqual( l1[1] , l3[3] ) - - l4 = l1 - l4 += l2 - self.assertEqual(l3 , l4) - - - - def test_extend_to_edge(self): - bound = Polyline( init_points = [(0,0) , (1,0) , (1,1) , (0,1)] ) - l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) - l2 = Polyline( init_points = [(0.25,0.25) , (0.75, 0.75)]) - - # Bound is not closed - with self.assertRaises(AssertionError): - GeometryTools.extendToEdge( bound , l1 ) - - bound.assertClosed() - # l1 is not fully contained in bound - with self.assertRaises(ValueError): - GeometryTools.extendToEdge( bound , l1 ) - - l3 = GeometryTools.extendToEdge( bound , l2 ) - self.assertEqual( l3[0] , (0.00,0.00)) - self.assertEqual( l3[1] , (0.25,0.25)) - self.assertEqual( l3[2] , (0.75,0.75)) - self.assertEqual( l3[3] , (1.00,1.00)) - self.assertEqual( len(l3) , 4) - - diff --git a/ThirdParty/Ert/python/tests/geometry/test_surface.py b/ThirdParty/Ert/python/tests/geometry/test_surface.py deleted file mode 100644 index 995c34bcdb..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/test_surface.py +++ /dev/null @@ -1,210 +0,0 @@ -import random -from ecl.geo import Surface -from ecl.test import ExtendedTestCase , TestAreaContext - - -class SurfaceTest(ExtendedTestCase): - def setUp(self): - self.surface_valid = self.createTestPath("local/geometry/surface/valid_ascii.irap") - self.surface_short = self.createTestPath("local/geometry/surface/short_ascii.irap") - self.surface_long = self.createTestPath("local/geometry/surface/long_ascii.irap") - self.surface_valid2 = self.createTestPath("local/geometry/surface/valid2_ascii.irap") - self.surface_small = self.createTestPath("local/geometry/surface/valid_small_ascii.irap") - - def test_xyz(self): - s = Surface(self.surface_valid2) - self.assertEqual(s.getXYZ(i=5,j=13), s.getXYZ(idx=642)) - x,y,z = s.getXYZ(i=5,j=13) - self.assertFloatEqual(464041.44804, x) - self.assertFloatEqual(7336966.309535, y) - self.assertFloatEqual(0.0051, z) - self.assertAlmostEqualList(s.getXYZ(i=6,j=13), s.getXYZ(idx=643)) - self.assertFloatEqual(-0.0006, s.getXYZ(i=6,j=13)[2]) # z value - - def test_create_new(self): - with self.assertRaises(ValueError): - s = Surface(None, 1, 1, 1) - with self.assertRaises(IOError): - s = Surface(50, 1, 1, 1) - - # values copied from irap surface_small - ny,nx = 20,30 - xinc,yinc = 50.0, 50.0 - xstart,ystart = 463325.5625, 7336963.5 - angle = -65.0 - s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) - s = Surface(*s_args) - self.assertEqual(ny*nx, len(s)) - self.assertEqual(nx, s.getNX()) - self.assertEqual(ny, s.getNY()) - small = Surface (self.surface_small) - self.assertTrue(small.headerEqual(s)) - valid = Surface (self.surface_valid) - self.assertFalse(valid.headerEqual(s)) - - self.assertNotEqual(s, small) - idx = 0 - for i in range(nx): - for j in range(ny): - s[idx] = small[idx] - idx += 1 - self.assertEqual(s, small) - - def test_create(self): - with self.assertRaises(IOError): - s = Surface("File/does/not/exist") - - with self.assertRaises(ValueError): - s = Surface(self.surface_short) - - with self.assertRaises(ValueError): - s = Surface(self.surface_long) - - s = Surface( self.surface_valid ) - - self.assertEqual( s.getNX( ) , 49 ) - self.assertEqual( s.getNY( ) , 79 ) - self.assertEqual( len(s) , 49*79 ) - - with self.assertRaises(IndexError): - v = s[49 * 79] - - with self.assertRaises(TypeError): - v = s["KEY"] - - self.assertEqual( s[0] , 0.0051 ) - self.assertEqual( s[-1] , -0.0014 ) - - with self.assertRaises(IndexError): - s[49*79] = 787 - - s[0] = 10 - self.assertEqual( s[0] , 10 ) - - s[-1] = 77 - self.assertEqual( s[len(s) - 1] , 77 ) - - - def test_write(self): - with TestAreaContext("surface/write"): - - s0 = Surface( self.surface_valid ) - s0.write( "new_surface.irap") - - s1 = Surface( "new_surface.irap") - self.assertTrue( s1 == s0 ) - - s0[0] = 99 - self.assertFalse( s1 == s0 ) - - - - def test_copy(self): - with TestAreaContext("surface/copy"): - s0 = Surface( self.surface_valid ) - s1 = s0.copy( ) - - self.assertTrue( s1 == s0 ) - s1[0] = 99 - self.assertFalse( s1 == s0 ) - del s0 - self.assertEqual( s1[0] , 99) - - s2 = s1.copy( copy_data = False ) - self.assertEqual( s2[0] , 0.0 ) - self.assertEqual( s2[10] , 0.0 ) - self.assertEqual( s2[100] , 0.0 ) - - - def test_header_equal(self): - s0 = Surface( self.surface_valid ) - s1 = Surface( self.surface_valid2 ) - s2 = s0.copy( ) - - self.assertTrue( s0.headerEqual( s0 )) - self.assertFalse( s0.headerEqual( s1 )) - self.assertTrue( s0.headerEqual( s2 )) - - - def test_ops(self): - s0 = Surface( self.surface_valid ) - s0.assign(1.0) - for v in s0: - self.assertEqual(v , 1.0) - - s0 += 1 - for v in s0: - self.assertEqual(v , 2.0) - - s0 *= 2 - for v in s0: - self.assertEqual(v , 4.0) - - s1 = s0 + 4 - for v in s1: - self.assertEqual(v , 8.0) - - s2 = Surface( self.surface_valid2 ) - with self.assertRaises(ValueError): - s3 = s1 + s2 - - s4 = s1 + s0 - for v in s4: - self.assertEqual(v , 12.0) - - s5 = s4 / 12 - for v in s5: - self.assertEqual(v , 1.0) - - - def test_ops2(self): - s0 = Surface( self.surface_small ) - surface_list = [] - for i in range(10): - s = s0.copy() - for j in range(len(s)): - s[j] = random.random() - surface_list.append(s) - - mean = s0.copy( copy_data = False ) - for s in surface_list: - mean += s - mean /= len(surface_list) - - std = s0.copy( copy_data = False ) - for s in surface_list: - std += (s - mean) * (s - mean) - std /= (len(surface_list) - 1) - - - def test_sqrt(self): - s0 = Surface( self.surface_small ) - s0.assign(4) - self.assertEqual(20*30, len(s0)) - s_sqrt = s0.sqrt( ) - for i in range(len(s0)): - self.assertEqual(s0[i] , 4) - self.assertEqual(s_sqrt[i] , 2) - s0.inplaceSqrt( ) - self.assertTrue( s0 == s_sqrt ) - - - def test_xy(self): - ny,nx = 20,30 - xinc,yinc = 50.0, 50.0 - xstart,ystart = 463325.5625, 7336963.5 - angle = 0 - s_args = (None, nx, ny, xinc, yinc, xstart, ystart, angle) - s = Surface(*s_args) - - xy = s.getXY(0) - self.assertEqual((xstart, ystart), xy) - - xy = s.getXY(1) - self.assertEqual((xstart+xinc, ystart), xy) - - xy = s.getXY(nx) - self.assertEqual((xstart, ystart+yinc), xy) - - xy = s.getXY(-1) - self.assertEqual((xstart+xinc*(nx-1), ystart+yinc*(ny-1)), xy) diff --git a/ThirdParty/Ert/python/tests/global/CMakeLists.txt b/ThirdParty/Ert/python/tests/global/CMakeLists.txt deleted file mode 100644 index 957c12c570..0000000000 --- a/ThirdParty/Ert/python/tests/global/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_import.py - test_pylint.py -) - -add_python_package("python.tests.global" "${PYTHON_INSTALL_PREFIX}/tests/global" "${TEST_SOURCES}" False) - -addPythonTest(tests.global.test_import.ImportEcl) -addPythonTest(tests.global.test_pylint.LintErt) - - diff --git a/ThirdParty/Ert/python/tests/global/__init__.py b/ThirdParty/Ert/python/tests/global/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/global/test_import.py b/ThirdParty/Ert/python/tests/global/test_import.py deleted file mode 100644 index fe0835809a..0000000000 --- a/ThirdParty/Ert/python/tests/global/test_import.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os -import sys - - -from ecl.test import ImportTestCase - -class ImportEcl(ImportTestCase): - - def test_import_ecl(self): - self.assertTrue( self.import_package( "ecl" )) diff --git a/ThirdParty/Ert/python/tests/global/test_pylint.py b/ThirdParty/Ert/python/tests/global/test_pylint.py deleted file mode 100644 index bebe2f5f48..0000000000 --- a/ThirdParty/Ert/python/tests/global/test_pylint.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.test import LintTestCase - -class LintErt(LintTestCase): - """Tests that no file in ert needs linting""" - - def test_lint_ecl(self): - #white = ['ecl_kw.py', 'ecl_type.py', 'ecl_sum.py', 'ecl_grid.py', 'ecl_npv.py'] # TODO fix issues and remove - #self.assertLinted('ecl/ecl', whitelist=white) - pass # temporarily disable linting due to monkey patching - - def test_lint_geo(self): - self.assertLinted('ecl/geo') - - def test_lint_util(self): - self.assertLinted('ecl/util') - - def test_lint_well(self): - self.assertLinted('ecl/well') diff --git a/ThirdParty/Ert/python/tests/install/test_install.py b/ThirdParty/Ert/python/tests/install/test_install.py deleted file mode 100644 index b43ab9b903..0000000000 --- a/ThirdParty/Ert/python/tests/install/test_install.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -import sys - -# This is a small executable which is used to verify the install, -# Prior to calling this the environment must have been prepared to -# ensure that the newly installed versions are picked up - this can -# typically be achieved with the bash script bin/test_install which is -# generated during the configure process. - -from ecl.ecl import EclSum, EclGrid - - - diff --git a/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt b/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt deleted file mode 100644 index 1ccd83497b..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ecl.py - test_geo.py - test_well.py - test_util.py - test_test.py -) - -add_python_package("python.tests.legacy.ert" ${PYTHON_INSTALL_PREFIX}/tests/legacy "${TEST_SOURCES}" False) - -addPythonTest(tests.legacy.test_ecl.ErtLegacyEclTest) -addPythonTest(tests.legacy.test_geo.ErtLegacyGeoTest) -addPythonTest(tests.legacy.test_well.ErtLegacyWellTest) -addPythonTest(tests.legacy.test_util.ErtLegacyUtilTest) -addPythonTest(tests.legacy.test_test.ErtLegacyTestTest) diff --git a/ThirdParty/Ert/python/tests/legacy/__init__.py b/ThirdParty/Ert/python/tests/legacy/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/legacy/test_ecl.py b/ThirdParty/Ert/python/tests/legacy/test_ecl.py deleted file mode 100644 index f90d3fd628..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/test_ecl.py +++ /dev/null @@ -1,41 +0,0 @@ -from ert.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil -from ert.ecl import EclTypeEnum, EclDataType -from ert.ecl import EclSumVarType -from ert.ecl import EclSumTStep -from ert.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode -from ert.ecl import EclSumKeyWordVector -from ert.ecl import EclPLTCell, EclRFTCell -from ert.ecl import EclRFT, EclRFTFile -from ert.ecl import FortIO, openFortIO -from ert.ecl import EclKW -from ert.ecl import Ecl3DKW -from ert.ecl import EclFileView -from ert.ecl import EclFile , openEclFile -from ert.ecl import Ecl3DFile -from ert.ecl import EclInitFile -from ert.ecl import EclRestartFile -from ert.ecl import EclGrid -from ert.ecl import EclRegion -from ert.ecl import EclSubsidence -from ert.ecl import phase_deltag, deltag -from ert.ecl import EclGrav -from ert.ecl import EclSumNode -from ert.ecl import EclSumVector -from ert.ecl import EclNPV , NPVPriceVector -from ert.ecl import EclCmp -from ert.ecl import EclGridGenerator - -from ert.ecl.faults import Layer -from ert.ecl.faults import FaultCollection -from ert.ecl.faults import Fault -from ert.ecl.faults import FaultLine -from ert.ecl.faults import FaultSegment , SegmentMap -from ert.ecl.faults import FaultBlock , FaultBlockCell -from ert.ecl.faults import FaultBlockLayer - - -from ecl.test import ExtendedTestCase - - -class ErtLegacyEclTest(ExtendedTestCase): - pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_geo.py b/ThirdParty/Ert/python/tests/legacy/test_geo.py deleted file mode 100644 index 669b5ab9d6..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/test_geo.py +++ /dev/null @@ -1,14 +0,0 @@ -from ert.geo import GeoPointset -from ert.geo import GeoRegion -from ert.geo import CPolyline -from ert.geo import CPolylineCollection -from ert.geo import Polyline -from ert.geo import XYZIo -from ert.geo import GeometryTools -from ert.geo import Surface - -from ecl.test import ExtendedTestCase - - -class ErtLegacyGeoTest(ExtendedTestCase): - pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_test.py b/ThirdParty/Ert/python/tests/legacy/test_test.py deleted file mode 100644 index 40d0ef2b73..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/test_test.py +++ /dev/null @@ -1,16 +0,0 @@ -from ert.test import TestRun -from ert.test import path_exists -from ert.test import ExtendedTestCase -from ert.test import SourceEnumerator -from ert.test import TestArea , TestAreaContext -from ert.test import TempArea , TempAreaContext -from ert.test import ErtTestRunner -from ert.test import PathContext -from ert.test import LintTestCase -from ert.test import ImportTestCase - -from ecl.test import ExtendedTestCase - - -class ErtLegacyTestTest(ExtendedTestCase): - pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_util.py b/ThirdParty/Ert/python/tests/legacy/test_util.py deleted file mode 100644 index 712f12f00a..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/test_util.py +++ /dev/null @@ -1,34 +0,0 @@ -from ert.util import Version -from ert.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum -from ert.util import CTime -from ert.util import PermutationVector -from ert.util import VectorTemplate -from ert.util import DoubleVector -from ert.util import IntVector -from ert.util import BoolVector -from ert.util import TimeVector -from ert.util import StringList -from ert.util import RandomNumberGenerator -from ert.util import Matrix -from ert.util import quantile, quantile_sorted, polyfit -from ert.util import Log -from ert.util import LookupTable -from ert.util import Buffer -from ert.util import Hash, StringHash, DoubleHash, IntegerHash -from ert.util import UIReturn -from ert.util import ThreadPool -from ert.util import CThreadPool, startCThreadPool -from ert.util import installAbortSignals, updateAbortSignals -from ert.util import Profiler -from ert.util import ArgPack -from ert.util import PathFormat - -from ecl.test import ExtendedTestCase - -try: - from res.util import SubstitutionList -except ImportError: - pass - -class ErtLegacyUtilTest(ExtendedTestCase): - pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_well.py b/ThirdParty/Ert/python/tests/legacy/test_well.py deleted file mode 100644 index 102b049739..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/test_well.py +++ /dev/null @@ -1,13 +0,0 @@ -from ert.well import WellTypeEnum -from ert.well import WellConnectionDirectionEnum -from ert.well import WellConnection -from ert.well import WellSegment -from ert.well import WellState -from ert.well import WellTimeLine -from ert.well import WellInfo - -from ecl.test import ExtendedTestCase - - -class ErtLegacyWellTest(ExtendedTestCase): - pass diff --git a/ThirdParty/Ert/python/tests/share/CMakeLists.txt b/ThirdParty/Ert/python/tests/share/CMakeLists.txt deleted file mode 100644 index ef80c2d77d..0000000000 --- a/ThirdParty/Ert/python/tests/share/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_synthesizer.py -) - -add_python_package("python.tests.share" ${PYTHON_INSTALL_PREFIX}/tests/share "${TEST_SOURCES}" False) - -addPythonTest(share.test_synthesizer.SynthesizerTest) diff --git a/ThirdParty/Ert/python/tests/share/__init__.py b/ThirdParty/Ert/python/tests/share/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/share/test_synthesizer.py b/ThirdParty/Ert/python/tests/share/test_synthesizer.py deleted file mode 100644 index f5863f5e91..0000000000 --- a/ThirdParty/Ert/python/tests/share/test_synthesizer.py +++ /dev/null @@ -1,50 +0,0 @@ -import sys -import os -from ecl.test import ExtendedTestCase - -try: - from synthesizer import OilSimulator -except ImportError as e: - share_lib_path = os.path.join(ExtendedTestCase.createSharePath("lib")) - - sys.path.insert(0, share_lib_path) - synthesizer_module = __import__("synthesizer") - OilSimulator = synthesizer_module.OilSimulator - sys.path.pop(0) - - -class SynthesizerTest(ExtendedTestCase): - - def test_oil_simulator(self): - sim = OilSimulator() - sim.addWell("OP1", seed=1) - sim.addBlock("6,6,6", seed=2) - - expected_values = [ - [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0], - [0.3359771423145687, 0.3359771423145687, 0.25672494192349865, 0.25672494192349865, 0.010039005455891323, 0.010039005455891323, 0.029013112597713192, 0.7641143089523995, 0.3359771423145687, 0.25672494192349865, 0.010039005455891323, 0.7641143089523995, 0.029013112597713192, 0.8462347957619747], - [0.7252470407619624, 1.0612241830765312, 0.5175173529594699, 0.7742422948829686, 0.017973831236885583, 0.028012836692776905, 0.02418370085402209, 0.7135738912023045, 0.7252470407619624, 0.5175173529594699, 0.017973831236885583, 0.7135738912023045, 0.02418370085402209, 0.6888364145396828], - [0.7723163496234255, 1.8335405326999568, 0.5742386073607806, 1.3484809022437492, 0.11041673583737899, 0.1384295725301559, 0.12508507685507134, 0.7435277106858791, 0.7723163496234255, 0.5742386073607806, 0.11041673583737899, 0.7435277106858791, 0.12508507685507134, 0.6403046565762696], - [0.6038799675664164, 2.437420500266373, 0.6888868738548185, 2.037367776098568, 0.267892132439122, 0.4063217049692779, 0.3072960610203287, 1.140767885762087, 0.6038799675664164, 0.6888868738548185, 0.267892132439122, 1.140767885762087, 0.3072960610203287, 0.5205364945011657], - [0.23016535126253962, 2.6675858515289126, 0.721655666522216, 2.7590234426207836, 0.35552466124555465, 0.7618463662148325, 0.6070184801736589, 3.135379250454838, 0.23016535126253962, 0.721655666522216, 0.35552466124555465, 3.135379250454838, 0.6070184801736589, 0.4800677649914682], - [0.026293782934652718, 2.693879634463565, 0.7131990780527108, 3.4722225206734945, 0.6392372725163122, 1.4010836387311447, 0.8647254356377257, 7.131990780527107, 0.026293782934652718, 0.7131990780527108, 0.6392372725163122, 7.131990780527107, 0.8647254356377257, 0.3872974839053025], - [0.0, 2.693879634463565, 0.8676997908824122, 4.339922311555907, 0.8580356376693129, 2.2591192764004577, 0.8956197493411856, 8.676997908824122, 0.0, 0.8676997908824122, 0.8580356376693129, 8.676997908824122, 0.8956197493411856, 0.22557165737149715], - [0.10560669451549878, 2.799486328979064, 0.869082212788759, 5.209004524344666, 0.8903674796589355, 3.1494867560593933, 0.8939664328113363, 8.229423492288294, 0.10560669451549878, 0.869082212788759, 0.8903674796589355, 8.229423492288294, 0.8939664328113363, 0.1340241573819292], - [0.08615885630000791, 2.885645185279072, 0.44074890315982446, 5.64975342750449, 0.9425699260811738, 4.0920566821405675, 0.9040831722665535, 4.407489031598244, 0.08615885630000791, 0.44074890315982446, 0.9425699260811738, 4.407489031598244, 0.9040831722665535, 0.13404047971467026] - ] - - for report_step in range(10): - sim.step(scale=1.0 / 10.0) - - values = [sim.fopr(), sim.fopt(), sim.fgpr(), sim.fgpt(), sim.fwpr(), sim.fwpt(), sim.fwct(), sim.fgor(), - sim.opr("OP1"), sim.gpr("OP1"), sim.wpr("OP1"), sim.gor("OP1"), sim.wct("OP1"), sim.bpr("6,6,6")] - - self.assertAlmostEqual(values[0], values[8]) # fopr = opr:op1 - self.assertAlmostEqual(values[2], values[9]) # fgpr = gpr:op1 - self.assertAlmostEqual(values[4], values[10]) # fwpr = wpr:op1 - - self.assertAlmostEqual(sim.foip(), sim.ooip - sim.fopt()) - self.assertAlmostEqual(sim.fgip(), sim.goip - sim.fgpt()) - self.assertAlmostEqual(sim.fwip(), sim.woip - sim.fwpt()) - - self.assertAlmostEqualList(values, expected_values[report_step]) diff --git a/ThirdParty/Ert/python/tests/test_pylint.py b/ThirdParty/Ert/python/tests/test_pylint.py deleted file mode 100644 index 84e8ff6a63..0000000000 --- a/ThirdParty/Ert/python/tests/test_pylint.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -from ecl.test import LintTestCase - -class LintErt(LintTestCase): - """Tests that no file in ert needs linting""" - - # Temporarily disabled due to monkey patching camel case - # def test_lint_ecl(self): - # white = ['ecl_kw.py', 'ecl_type.py', 'ecl_sum.py', 'ecl_grid.py', 'ecl_npv.py'] # TODO fix issues and remove - # self.assertLinted('ecl/ecl', whitelist=white) - - def test_lint_geo(self): - self.assertLinted('ecl/geo') - - def test_lint_util(self): - self.assertLinted('ecl/util') - - def test_lint_well(self): - self.assertLinted('ecl/well') diff --git a/ThirdParty/Ert/python/tests/util/CMakeLists.txt b/ThirdParty/Ert/python/tests/util/CMakeLists.txt deleted file mode 100644 index e2b75c8024..0000000000 --- a/ThirdParty/Ert/python/tests/util/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ctime.py - test_cstring.py - test_hash.py - test_lookup_table.py - test_matrix.py - test_rng.py - test_stat.py - test_string_list.py - #test_substitution_list.py - test_thread_pool.py - test_cthread_pool.py - test_ui_return.py - test_vectors.py - test_version.py - test_work_area.py - test_path_context.py - test_path_fmt.py - test_arg_pack.py - test_spawn.py - test_log.py -) - -add_python_package("python.tests.util" ${PYTHON_INSTALL_PREFIX}/tests/util "${TEST_SOURCES}" False) - -addPythonTest(tests.util.test_ctime.CTimeTest) -addPythonTest(tests.util.test_cstring.CStringTest) -addPythonTest(tests.util.test_hash.HashTest) -addPythonTest(tests.util.test_lookup_table.LookupTableTest ) -addPythonTest(tests.util.test_matrix.MatrixTest ) -addPythonTest(tests.util.test_rng.RngTest ) -addPythonTest(tests.util.test_stat.StatTest ) -addPythonTest(tests.util.test_string_list.StringListTest) -addPythonTest(tests.util.test_vectors.UtilTest) -addPythonTest(tests.util.test_ui_return.UIReturnTest) -addPythonTest(tests.util.test_path_fmt.PathFmtTest) -addPythonTest(tests.util.test_work_area.WorkAreaTest) -addPythonTest(tests.util.test_version.VersionTest) -addPythonTest(tests.util.test_path_context.PathContextTest) -addPythonTest(tests.util.test_thread_pool.ThreadPoolTest) -addPythonTest(tests.util.test_cthread_pool.CThreadPoolTest) -addPythonTest(tests.util.test_arg_pack.ArgPackTest) -addPythonTest(tests.util.test_spawn.SpawnTest) -#addPythonTest(tests.util.test_substitution_list.SubstitutionListTest) -addPythonTest(tests.util.test_log.LogTest) diff --git a/ThirdParty/Ert/python/tests/util/__init__.py b/ThirdParty/Ert/python/tests/util/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/util/test_arg_pack.py b/ThirdParty/Ert/python/tests/util/test_arg_pack.py deleted file mode 100644 index 2a73c39112..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_arg_pack.py +++ /dev/null @@ -1,35 +0,0 @@ -import ecl -from ecl.test import ExtendedTestCase -from ecl.util import ArgPack, StringList - -TEST_LIB = ecl.load("libecl") - - -class ArgPackTest(ExtendedTestCase): - def test_create(self): - arg = ArgPack() - self.assertEqual(len(arg), 0) - - arg.append(StringList()) - self.assertEqual(len(arg), 1) - - arg.append(3.14) - self.assertEqual(len(arg), 2) - - o = object() - with self.assertRaises(TypeError): - arg.append(o) - - def test_args(self): - arg = ArgPack(1, 2, 3) - self.assertEqual(len(arg), 3) - - def test_append_ptr(self): - arg = ArgPack(StringList()) - self.assertEqual(len(arg), 1) - - func = getattr(TEST_LIB, "test_argpack_is_stringlist") - func.restype = None - func.argtypes = [ArgPack] - - func(arg) diff --git a/ThirdParty/Ert/python/tests/util/test_cstring.py b/ThirdParty/Ert/python/tests/util/test_cstring.py deleted file mode 100644 index 12f8a58c50..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_cstring.py +++ /dev/null @@ -1,24 +0,0 @@ -import ecl -from cwrap import Prototype -from ecl.test.extended_testcase import ExtendedTestCase - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -alloc_string_copy = TestUtilPrototype("char* util_alloc_string_copy(char*)") - -class CStringTest(ExtendedTestCase): - - def test_get(self): - # this test can safely be deleted, as the type it used to test, - # cstring_obj, has been replaced with char* - s1 = "String123" - print('test_get.s1=' + s1) - s2 = alloc_string_copy(s1) - print('test_get.s2=' + s2) - self.assertEqual(s1, s2) - print('test_get.s1==s2: %s' % (s1 == s2)) diff --git a/ThirdParty/Ert/python/tests/util/test_cthread_pool.py b/ThirdParty/Ert/python/tests/util/test_cthread_pool.py deleted file mode 100644 index dd6b32b952..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_cthread_pool.py +++ /dev/null @@ -1,47 +0,0 @@ -import ctypes -import ecl -from ecl.test import ExtendedTestCase -from ecl.util import CThreadPool, startCThreadPool - -TEST_LIB = ecl.load("libecl") - - -class CThreadPoolTest(ExtendedTestCase): - def test_cfunc(self): - with self.assertRaises(TypeError): - func = CThreadPool.lookupCFunction("WRONG-TYPE", "no-this-does-not-exist") - - with self.assertRaises(AttributeError): - func = CThreadPool.lookupCFunction(TEST_LIB, "no-this-does-not-exist") - - def test_create(self): - pool = CThreadPool(32, start=True) - job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1") - arg = ctypes.c_int(0) - - N = 256 - for i in range(N): - pool.addTask(job, ctypes.byref(arg)) - pool.join() - self.assertEqual(arg.value, N) - - def test_context(self): - N = 256 - arg = ctypes.c_int(0) - job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1") - with startCThreadPool(16) as tp: - for i in range(N): - tp.addTask(job, ctypes.byref(arg)) - self.assertEqual(arg.value, N) - - def test_add_task_function(self): - pool = CThreadPool(32, start=True) - pool.addTaskFunction("testFunction", TEST_LIB, "thread_pool_test_func1") - - arg = ctypes.c_int(0) - task_count = 256 - for i in range(task_count): - pool.testFunction(ctypes.byref(arg)) - - pool.join() - self.assertEqual(arg.value, task_count) diff --git a/ThirdParty/Ert/python/tests/util/test_ctime.py b/ThirdParty/Ert/python/tests/util/test_ctime.py deleted file mode 100644 index 292a13153a..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_ctime.py +++ /dev/null @@ -1,131 +0,0 @@ -import time -from datetime import datetime, date - -from ecl.util import CTime - - -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase - - -class CTimeTest(TestCase): - def test_creation(self): - t0 = CTime(0) - - t2 = CTime(datetime(1970, 1, 1)) - self.assertEqual(t0, t2) - - t3 = CTime(date(1970, 1, 1)) - self.assertEqual(t0, t3) - - with self.assertRaises(NotImplementedError): - CTime("string") - - def test_c_time(self): - delta = 0 - c_time = CTime(0) - py_time = datetime(1970, 1, 1) - - self.assertEqual(str(c_time), py_time.strftime("%Y-%m-%d %H:%M:%S%z")) - - date_time = CTime(py_time) - self.assertEqual(c_time, date_time) - - date_time_after = CTime(datetime(1970, 1, 1, 1, 0, 5)) - - self.assertTrue(date_time_after > date_time) - - def test_math(self): - c1 = CTime(date(2000, 1, 1)) - c2 = CTime(date(2000, 1, 1)) - c3 = CTime(date(2000, 1, 1)) - - c3 += c1 - self.assertTrue(isinstance(c3, CTime)) - - c4 = c1 * 1.0 - self.assertTrue(isinstance(c4, CTime)) - self.assertTrue(isinstance(c1 + c2, CTime)) - - self.assertEqual((c1 + c2) * 0.5, date(2000, 1, 1)) - - def test_comparison(self): - t0 = CTime(0) - t1 = CTime(0) - t2 = CTime(1) - - self.assertTrue(t0 == t1) - self.assertFalse(t0 != t1) - with self.assertRaises(TypeError): - t0 != 0.5 - - self.assertFalse(t0 < t1) - self.assertTrue(t0 < t2) - with self.assertRaises(TypeError): - t0 < 0.5 - - self.assertTrue(t0 <= t1) - self.assertTrue(t0 <= t2) - with self.assertRaises(TypeError): - t0 <= 0.5 - - self.assertFalse(t0 > t1) - self.assertFalse(t0 > t2) - with self.assertRaises(TypeError): - t0 > 0.5 - - self.assertTrue(t0 >= t1) - self.assertFalse(t0 >= t2) - with self.assertRaises(TypeError): - t0 >= 0.5 - - t3 = CTime(date(2050, 1, 1)) - t4 = CTime(date(2060, 1, 1)) - self.assertTrue(t1 < t3) - self.assertTrue(t3 < t4) - - t5 = CTime(t4) - self.assertTrue(t4 == t5) - - def test_range(self): - d1 = date(2000, 1, 1) - dt1 = datetime(2000, 1, 1, 0, 0, 0) - c1 = CTime(d1) - - d0 = date(1999, 1, 1) - dt0 = datetime(1999, 1, 1, 0, 0, 0) - c0 = CTime(d0) - - d2 = date(2001, 1, 1) - dt2 = datetime(2001, 1, 1, 0, 0, 0) - c2 = CTime(d2) - - self.assertTrue(d0 <= c1 < dt2) - self.assertTrue(c0 <= c1 < d2) - self.assertTrue(dt0 <= c1 < c2) - - self.assertFalse(d1 <= c0 < dt2) - self.assertFalse(c1 <= c0 < d2) - self.assertFalse(dt1 <= c0 < c2) - - self.assertTrue(d0 <= c0 < dt2) - self.assertTrue(c0 <= c0 < d2) - self.assertTrue(dt0 <= c0 < c2) - - self.assertFalse(d0 <= c2 < dt2) - self.assertFalse(c0 <= c2 < d2) - self.assertFalse(dt0 <= c2 < c2) - - self.assertTrue(d0 <= c2 <= dt2) - self.assertTrue(c0 <= c2 <= d2) - self.assertTrue(dt0 <= c2 <= c2) - - def test_conversion(self): - t = CTime(0) - - self.assertEqual(t.value(), 0) - self.assertEqual(t.ctime(), 0) - self.assertEqual(t.time(), time.gmtime(0)) - diff --git a/ThirdParty/Ert/python/tests/util/test_hash.py b/ThirdParty/Ert/python/tests/util/test_hash.py deleted file mode 100644 index 528d123ee4..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_hash.py +++ /dev/null @@ -1,68 +0,0 @@ -from ctypes import c_void_p - -from ecl.test import ExtendedTestCase -from ecl.util import Hash, StringHash, DoubleHash, IntegerHash - - -class HashTest(ExtendedTestCase): - def test_string_hash(self): - hash = StringHash() - - self.assertEqual(len(hash), 0) - - hash["hipp"] = "" - - self.assertEqual(len(hash), 1) - - with self.assertRaises(ValueError): - hash["hopp"] = 55 - - with self.assertRaises(KeyError): - hopp = hash["hopp"] - - self.assertTrue("hipp" in hash) - - self.assertEqual(list(hash.keys()), ["hipp"]) - - def test_int_hash(self): - hash = IntegerHash() - - with self.assertRaises(ValueError): - hash["one"] = "ein" - - with self.assertRaises(ValueError): - hash["one"] = 1.0 - - hash["two"] = 2 - - self.assertEqual(hash["two"], 2) - - def test_double_hash(self): - hash = DoubleHash() - - with self.assertRaises(ValueError): - hash["one"] = "ein" - - hash["two"] = 2 - hash["three"] = 3.0 - - self.assertEqual(hash["two"], 2) - self.assertEqual(hash["three"], 3.0) - - def test_c_void_p_hash(self): - hash = Hash() - - cp = c_void_p(512) - hash["1"] = cp - - self.assertEqual(hash["1"], cp.value) - - def test_for_in_hash(self): - hash = StringHash() - - hash["one"] = "one" - hash["two"] = "two" - hash["three"] = "three" - - for key in hash: - self.assertTrue(key in hash) diff --git a/ThirdParty/Ert/python/tests/util/test_log.py b/ThirdParty/Ert/python/tests/util/test_log.py deleted file mode 100644 index dba143dad9..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_log.py +++ /dev/null @@ -1,8 +0,0 @@ -from ecl.util.enums import MessageLevelEnum - -from ecl.test import ExtendedTestCase - -class LogTest(ExtendedTestCase): - - def test_enums(self): - self.assertEnumIsFullyDefined(MessageLevelEnum, "message_level_type", "lib/include/ert/util/log.h") diff --git a/ThirdParty/Ert/python/tests/util/test_lookup_table.py b/ThirdParty/Ert/python/tests/util/test_lookup_table.py deleted file mode 100644 index 9a0fdccdfe..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_lookup_table.py +++ /dev/null @@ -1,88 +0,0 @@ -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase - -from ecl.util import LookupTable - - -class LookupTableTest(TestCase): - def test_lookup_table_no_values(self): - lookup = LookupTable() - - self.assertEqual(len(lookup), 0) - - with self.assertRaises(ValueError): - lookup.getMaxValue() - - with self.assertRaises(ValueError): - lookup.getMinValue() - - with self.assertRaises(ValueError): - lookup.getMaxArg() - - with self.assertRaises(ValueError): - lookup.getMinArg() - - with self.assertRaises(ValueError): - lookup.interp(0.25) - - def test_lookup_table_one_value(self): - lookup = LookupTable() - lookup.append(0, 0) - with self.assertRaises(ValueError): - lookup.interp(0.25) - - def test_lookup_table_min_and_max(self): - lookup = LookupTable() - - lookup.append(0.0, 0.0) - lookup.append(1.0, 10.0) - - self.assertEqual(lookup.getMaxValue(), 10.0) - self.assertEqual(lookup.getMinValue(), 0.0) - self.assertEqual(lookup.getMaxArg(), 1.0) - self.assertEqual(lookup.getMinArg(), 0.0) - self.assertEqual(len(lookup), 2) - - def test_lookup_out_of_bounds(self): - lookup = LookupTable() - - lookup.append(0.0, 0.0) - lookup.append(1.0, 10.0) - - self.assertEqual(lookup.interp(0), 0) - self.assertEqual(lookup.interp(1), 10) - - with self.assertRaises(ValueError): - lookup.interp(-1) - - with self.assertRaises(ValueError): - lookup.interp(2) - - lookup.setLowerLimit(-1) - self.assertEqual(lookup.interp(-0.25), -1) - - with self.assertRaises(ValueError): - lookup.interp(2) - - lookup.setUpperLimit(88) - self.assertEqual(lookup.interp(1.25), 88) - - def test_lookup_table_interpolation(self): - lookup = LookupTable() - - lookup.append(0.0, 0.0) - lookup.append(1.0, 10.0) - - self.assertEqual(lookup.interp(0.5), 5.0) - - def test_optional_arg(self): - lookup = LookupTable(lower_limit=-1, upper_limit=100) - - lookup.append(0.0, 0.0) - lookup.append(1.0, 10.0) - - self.assertEqual(lookup.interp(-1), -1.0) - self.assertEqual(lookup.interp(0.5), 5.0) - self.assertEqual(lookup.interp(2), 100.0) diff --git a/ThirdParty/Ert/python/tests/util/test_matrix.py b/ThirdParty/Ert/python/tests/util/test_matrix.py deleted file mode 100644 index d5d5205890..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_matrix.py +++ /dev/null @@ -1,247 +0,0 @@ -from ecl.util import Matrix , RandomNumberGenerator -from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ecl.test import ExtendedTestCase, TestAreaContext - -class MatrixTest(ExtendedTestCase): - def test_matrix(self): - m = Matrix(2, 3) - - self.assertEqual(m.rows(), 2) - self.assertEqual(m.columns(), 3) - - self.assertEqual(m[(0, 0)], 0) - - m[(1, 1)] = 1.5 - self.assertEqual(m[(1, 1)], 1.5) - - m[1,0] = 5 - self.assertEqual(m[1, 0], 5) - - with self.assertRaises(TypeError): - m[5] = 5 - - with self.assertRaises(IndexError): - m[2, 0] = 0 - - with self.assertRaises(IndexError): - m[0, 3] = 0 - - def test_matrix_set(self): - m1 = Matrix(2,2) - m1.setAll(99) - self.assertEqual( 99 , m1[0,0] ) - self.assertEqual( 99 , m1[1,1] ) - m2 = Matrix(2,2 , value = 99) - self.assertEqual(m1,m2) - - - def test_matrix_random_init(self): - m = Matrix(10,10) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m.randomInit( rng ) - - def test_matrix_copy_column(self): - m = Matrix(10,2) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m.randomInit( rng ) - - with self.assertRaises(ValueError): - m.copyColumn(0,2) - - with self.assertRaises(ValueError): - m.copyColumn(2,0) - - with self.assertRaises(ValueError): - m.copyColumn(-2,0) - - m.copyColumn(1, 0) - for i in range(m.rows()): - self.assertEqual( m[i,0] , m[i,1] ) - - - def test_matrix_scale(self): - m = Matrix(2,2 , value = 1) - m.scaleColumn(0 , 2) - self.assertEqual(2 , m[0,0]) - self.assertEqual(2 , m[1,0]) - - m.setAll(1) - m.scaleRow(1 , 2 ) - self.assertEqual(2 , m[1,0]) - self.assertEqual(2 , m[1,1]) - - with self.assertRaises(IndexError): - m.scaleColumn(10 , 99) - - with self.assertRaises(IndexError): - m.scaleRow(10 , 99) - - - - - def test_matrix_equality(self): - m = Matrix(2, 2) - m[0, 0] = 2 - m[1, 1] = 4 - - s = Matrix(2, 3) - s[0, 0] = 2 - s[1, 1] = 4 - - self.assertNotEqual(m, s) - - r = Matrix(2, 2) - r[0, 0] = 2 - r[1, 1] = 3 - - self.assertNotEqual(m, r) - - r[1, 1] = 4 - - self.assertEqual(m, r) - - def test_str(self): - m = Matrix(2, 2) - s = "%s" % m - - m[0,0] = 0 - m[0,1] = 1 - m[1,0] = 2 - m[1,1] = 3 - - with TestAreaContext("matrix_fprint"): - with open("matrix.txt", "w") as f: - m.fprint( f ) - - with open("matrix.txt") as f: - l1 = [ float(x) for x in f.readline().split()] - l2 = [ float(x) for x in f.readline().split()] - - self.assertEqual( l1[0] , m[0,0]) - self.assertEqual( l1[1] , m[0,1]) - self.assertEqual( l2[0] , m[1,0]) - self.assertEqual( l2[1] , m[1,1]) - - - def test_copy_equal(self): - m1 = Matrix(2, 2) - m1[0,0] = 0 - m1[0,1] = 1 - m1[1,0] = 2 - m1[1,1] = 3 - - m2 = m1.copy( ) - self.assertTrue( m1 == m2 ) - - def test_sub_copy(self): - m1 = Matrix(3,3) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m1.randomInit( rng ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,0,4,2 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,0,2,4 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 4,0,1,1 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,2,1,2 ) - - - m2 = m1.subCopy( 0,0,2,2 ) - for i in range(2): - for j in range(2): - self.assertEqual( m1[i,j] , m2[i,j]) - - - def test_transpose(self): - m = Matrix(3,2) - m[0,0] = 0 - m[1,0] = 2 - m[2,0] = 4 - - m[0,1] = 1 - m[1,1] = 3 - m[2,1] = 5 - - mt = m.transpose( ) - - self.assertEqual(m[0,0] , 0) - self.assertEqual(m[1,0] , 2) - self.assertEqual(m[2,0] , 4) - - self.assertEqual(m[0,1] , 1) - self.assertEqual(m[1,1] , 3) - self.assertEqual(m[2,1] , 5) - - self.assertEqual( mt.rows() , m.columns()) - self.assertEqual( mt.columns() , m.rows()) - self.assertEqual(mt[0,0] , 0) - self.assertEqual(mt[1,0] , 1) - - self.assertEqual(mt[0,1] , 2) - self.assertEqual(mt[1,1] , 3) - - self.assertEqual(mt[0,2] , 4) - self.assertEqual(mt[1,2] , 5) - - m.transpose( inplace = True ) - self.assertEqual( m , mt ) - - - def test_matmul(self): - m1 = Matrix(3,3) - m2 = Matrix(2,2) - - with self.assertRaises(ValueError): - Matrix.matmul( m1 , m2 ) - - m = Matrix(3,2) - m[0,0] = 0 - m[1,0] = 2 - m[2,0] = 4 - - m[0,1] = 1 - m[1,1] = 3 - m[2,1] = 5 - - mt = m.transpose( ) - - m2 = Matrix.matmul( m , mt ) - - self.assertEqual( m2[0,0] , 1 ) - self.assertEqual( m2[1,1] , 13 ) - self.assertEqual( m2[2,2] , 41 ) - - - def test_csv(self): - m = Matrix(2, 2) - m[0, 0] = 2 - m[1, 1] = 4 - with TestAreaContext("matrix_csv"): - m.dumpCSV("matrix.csv") - - def test_identity(self): - m1 = Matrix.identity(1) - self.assertEqual(m1.rows(), 1) - self.assertEqual(m1.columns(), 1) - self.assertEqual(m1[0,0], 1) - - with self.assertRaises(ValueError): - Matrix.identity(0) - with self.assertRaises(ValueError): - Matrix.identity(-3) - - m = Matrix.identity(17) - self.assertEqual(m.rows(), 17) - self.assertEqual(m.columns(), 17) - for i in range(17): - for j in range(17): - elt = m[i, j] - if i == j: - self.assertEqual(elt, 1) - else: - self.assertEqual(elt, 0) diff --git a/ThirdParty/Ert/python/tests/util/test_path_context.py b/ThirdParty/Ert/python/tests/util/test_path_context.py deleted file mode 100644 index 8497e9d193..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_path_context.py +++ /dev/null @@ -1,49 +0,0 @@ -import os -from ecl.test import ExtendedTestCase, PathContext,TestAreaContext - - -class PathContextTest(ExtendedTestCase): - - def test_error(self): - with TestAreaContext("pathcontext"): - # Test failure on creating PathContext with an existing path - os.makedirs("path/1") - with self.assertRaises(OSError): - with PathContext("path/1"): - pass - - # Test failure on non-writable path - os.chmod("path/1", 0o0444) - with self.assertRaises(OSError): - with PathContext("path/1/subfolder"): - pass - os.chmod("path/1", 0o0744) - - # Test failure on creating PathContext with an existing file - with open("path/1/file", "w") as f: - f.write("xx") - with self.assertRaises(OSError): - with PathContext("path/1/file"): - pass - - - def test_chdir(self): - with PathContext("/tmp/pc"): - self.assertEqual( - os.path.realpath(os.getcwd()), - os.path.realpath("/tmp/pc") - ) - - def test_cleanup(self): - with TestAreaContext("pathcontext"): - os.makedirs("path/1") - - with PathContext("path/1/next/2/level"): - with open("../../file" , "w") as f: - f.write("Crap") - - self.assertTrue(os.path.isdir("path/1")) - self.assertTrue(os.path.isdir("path/1/next")) - self.assertFalse(os.path.isdir("path/1/next/2")) - - diff --git a/ThirdParty/Ert/python/tests/util/test_path_fmt.py b/ThirdParty/Ert/python/tests/util/test_path_fmt.py deleted file mode 100644 index 30adf3be51..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_path_fmt.py +++ /dev/null @@ -1,10 +0,0 @@ -import os -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.util import PathFormat - -class PathFmtTest(ExtendedTestCase): - - def test_create(self): - path_fmt = PathFormat("random/path/%d-%d") - self.assertIn('random/path', repr(path_fmt)) - self.assertTrue(str(path_fmt).startswith('PathFormat(')) diff --git a/ThirdParty/Ert/python/tests/util/test_rng.py b/ThirdParty/Ert/python/tests/util/test_rng.py deleted file mode 100644 index fdf0c2d60c..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_rng.py +++ /dev/null @@ -1,45 +0,0 @@ -from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ecl.util.rng import RandomNumberGenerator -from ecl.test import ExtendedTestCase,TestAreaContext - - -class RngTest(ExtendedTestCase): - - def test_enums(self): - self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "lib/include/ert/util/rng.h") - self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "lib/include/ert/util/rng.h") - - def test_rng_default(self): - rng = RandomNumberGenerator() - self.assertIsInstance(rng.getDouble(), float) - - def test_rng_state(self): - rng = RandomNumberGenerator() - with self.assertRaises(ValueError): - rng.setState("12") - - rng.setState("0123456789ABCDEF") - val1 = rng.getInt() - val2 = rng.getInt() - - self.assertFalse( val1 == val2 ) - rng.setState("0123456789ABCDEF") - self.assertEqual( rng.getInt() , val1) - self.assertEqual( rng.getInt() , val2) - - - - def test_load_save(self): - rng = RandomNumberGenerator() - with self.assertRaises(IOError): - rng.loadState("does/not/exist") - - with TestAreaContext("rng_state") as t: - rng.saveState( "rng.txt" ) - t.sync() - val1 = rng.getInt() - val2 = rng.getInt() - rng.loadState( "rng.txt" ) - self.assertEqual( rng.getInt() , val1 ) - self.assertEqual( rng.getInt() , val2 ) - diff --git a/ThirdParty/Ert/python/tests/util/test_spawn.py b/ThirdParty/Ert/python/tests/util/test_spawn.py deleted file mode 100644 index c624ea3d6a..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_spawn.py +++ /dev/null @@ -1,63 +0,0 @@ -import os -import stat -import sys - -import ecl -from ecl.test.extended_testcase import ExtendedTestCase -from ecl.test.test_area import TestAreaContext - -from cwrap import Prototype - -class _TestSpawnPrototype(Prototype): - lib = ecl.load('libecl') - - def __init__(self, prototype, bind=True): - super(_TestSpawnPrototype, self).__init__(_TestSpawnPrototype.lib, prototype, bind=bind) - - -class SpawnTest(ExtendedTestCase): - _spawn = _TestSpawnPrototype("int util_spawn_blocking(char*, int, void*, char*, char*)", bind = False) - def createScript(self, name, stdout_string , stderr_string): - with open(name, "w") as f: - f.write("#!/usr/bin/env python\n") - f.write("import sys\n") - f.write("sys.stdout.write('%s')\n" % stdout_string) - f.write("sys.stdout.flush()\n") - f.write("sys.stderr.write('%s')\n" % stderr_string) - f.write("sys.stderr.flush()\n") - - mode = os.stat(name).st_mode - mode |= stat.S_IXUSR | stat.S_IXGRP - os.chmod(name, stat.S_IMODE(mode)) - - - - def test_spawn_redirect(self): - with TestAreaContext("spawn_test1", store_area=True) as test_area: - stdout_string = "stdout_redirect" - stderr_string = "stderr_redirect" - self.createScript("print.py",stdout_string, stderr_string) - status = self._spawn("print.py",0, None, "print.out", "print.err") - self.assertEqual(status , 0) - - sys.stderr.write("init stderr\n") - sys.stdout.write("init stdout\n") - sys.stderr.write("complete stderr\n") - sys.stdout.write("complete stdout\n") - - with open("print.out", "r") as f: - s = f.read() - self.assertEqual(s , stdout_string) - - with open("print.err", "r") as f: - s = f.read() - self.assertEqual(s , stderr_string) - - - - def test_spawn_noredirect(self): - with TestAreaContext("spawn_test2", store_area=True) as test_area: - self.createScript("print.py","stdout_no_redirect", "stderr_no_redirect") - status = self._spawn("print.py", 0, None, None , None) - self.assertEqual(status , 0) - diff --git a/ThirdParty/Ert/python/tests/util/test_stat.py b/ThirdParty/Ert/python/tests/util/test_stat.py deleted file mode 100644 index f1a79e9701..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_stat.py +++ /dev/null @@ -1,43 +0,0 @@ -from ecl.test import ExtendedTestCase -from ecl.util import DoubleVector, quantile, quantile_sorted, polyfit -from ecl.util.rng import RandomNumberGenerator - - -class StatTest(ExtendedTestCase): - def test_stat_quantiles(self): - rng = RandomNumberGenerator() - rng.setState("0123456789ABCDEF") - v = DoubleVector() - for i in range(100000): - v.append(rng.getDouble( )) - - self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2) - - def test_polyfit(self): - x_list = DoubleVector() - y_list = DoubleVector() - S = DoubleVector() - - A = 7.25 - B = -4 - C = 0.025 - - x = 0 - dx = 0.1 - for i in range(100): - y = A + B * x + C * x * x - x_list.append(x) - y_list.append(y) - - x += dx - S.append(1.0) - - beta = polyfit(3, x_list, y_list, None) - - self.assertAlmostEqual(A, beta[0]) - self.assertAlmostEqual(B, beta[1]) - self.assertAlmostEqual(C, beta[2]) diff --git a/ThirdParty/Ert/python/tests/util/test_string_list.py b/ThirdParty/Ert/python/tests/util/test_string_list.py deleted file mode 100644 index a4076fe2c8..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_string_list.py +++ /dev/null @@ -1,159 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase - -from ecl.util import StringList - - -class StringListTest(TestCase): - def test_del(self): - s = StringList( initial = ["A", "list"] ) - internal_list_of_strings = s.strings - python_list_of_strings = list(s) - - self.assertEqual(internal_list_of_strings, python_list_of_strings) - - del s - - self.assertEqual(python_list_of_strings, ["A", "list"]) - - def test_iterate(self): - s = ["A", "list", "of", "strings"] - s1 = StringList(initial=s) - s2 = s1.strings - s3 = list(s1) - - for index in range(len(s1)): - self.assertEqual(s[index], s1[index]) - - for index in range(len(s2)): - self.assertEqual(s[index], s2[index]) - - for index in range(len(s3)): - self.assertEqual(s[index], s3[index]) - - - def test_pop( self ): - s = StringList(initial=["A", "list", "of", "strings"]) - s1 = s.pop() - self.assertTrue(len(s) == 3) - self.assertTrue(s1 == "strings") - - s1 = s.pop() - self.assertTrue(len(s) == 2) - self.assertTrue(s1 == "of") - - s1 = s.pop() - self.assertTrue(len(s) == 1) - self.assertTrue(s1 == "list") - - s1 = s.pop() - self.assertTrue(len(s) == 0) - self.assertTrue(s1 == "A") - - with self.assertRaises(IndexError): - s.pop() - - def test_last(self): - s = StringList(initial=["A", "list", "of", "strings"]) - self.assertEqual(s.last, "strings") - - with self.assertRaises(IndexError): - s.pop() - s.pop() - s.pop() - s.pop() - s.last - - - def test_in_and_not_in(self): - s = StringList(["A", "list", "of", "strings"]) - - self.assertTrue("A" in s) - self.assertTrue("Bjarne" not in s) - - def test_append(self): - s1 = StringList(["A", "B"]) - s1.append("C") - - s2 = StringList(["A","B","C"]) - self.assertEqual(s1, ["A", "B", "C"]) - self.assertEqual(s1, s2) - self.assertFalse(s1 == ["A","B","D"]) - self.assertFalse(s1 == ["A","B","C" , "D"]) - - pfx = 'StringList(size' # __repr__ - self.assertEqual(pfx, repr(s2)[:len(pfx)]) - - def test_append_not_string(self): - s = StringList() - s.append(10) - self.assertEqual( len(s) , 1) - self.assertEqual(s[0] , "10") - - - def test_negative_index(self): - s = StringList(["A", "B", "C"]) - - self.assertEqual(s[-1], "C") - self.assertEqual(s[-3], "A") - - with self.assertRaises(LookupError): - s = s[-4] - - def test_find_first(self): - s = StringList(["A", "B", "C"]) - - self.assertEqual(s.index("A"), 0) - self.assertEqual(s.index("B"), 1) - self.assertEqual(s.index("C"), 2) - self.assertEqual(s.index("D"), -1) - - - - def test_front_back(self): - s = StringList() - with self.assertRaises(LookupError): - s.front() - - with self.assertRaises(LookupError): - s.back() - - s.append("S1") - s.append("S2") - s.append("S3") - - self.assertEqual( "S1" , s.front() ) - self.assertEqual( "S3" , s.back() ) - - - def test_iadd(self): - s1 = StringList( initial = ["A","B","C"]) - with self.assertRaises(TypeError): - s3 = s1 + 10 - - - s2 = StringList( initial = ["A","B","C"]) - s3 = s1 + s2 - self.assertEqual( s3 , ["A","B","C","A","B","C"]) - - s1 += s2 - self.assertEqual( s1 , ["A","B","C","A","B","C"]) - with self.assertRaises(TypeError): - s3 += "b" - - - def test_ior(self): - s1 = StringList( initial = ["A","B","C"]) - s2 = StringList( initial = ["A","B","C"]) - - s3 = s1 | s2 - self.assertEqual( s3 , ["A","B","C"]) - s1 |= s2 - self.assertEqual( s1 , ["A","B","C"]) - - with self.assertRaises(TypeError): - s1 |= 26 diff --git a/ThirdParty/Ert/python/tests/util/test_thread_pool.py b/ThirdParty/Ert/python/tests/util/test_thread_pool.py deleted file mode 100644 index ffe620dcd6..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_thread_pool.py +++ /dev/null @@ -1,101 +0,0 @@ -import time -from ecl.util import ThreadPool -from ecl.util.thread_pool import Task -from ecl.test import ExtendedTestCase - - -class ThreadPoolTest(ExtendedTestCase): - - - def sleepTask(self, *args, **kwargs): - time.sleep(args[0]) - - def numberer(self, index, result): - result[index] = True - - def test_pool_creation(self): - pool = ThreadPool(4) - - self.assertEqual(4, pool.poolSize()) - - def noop(*args, **kwargs): - pass - - pool.addTask(noop) - self.assertEqual(1, pool.taskCount()) - - pool.addTask(noop, 1, 2, 3) - self.assertEqual(2, pool.taskCount()) - - pool.addTask(noop, 1, 2, 3, name="name", group="group", purpose="porpoise") - self.assertEqual(3, pool.taskCount()) - - self.assertEqual(pool.runningCount(), 0) - self.assertEqual(pool.doneCount(), 0) - - - def test_pool_execution(self): - pool = ThreadPool(4) - - result = {} - for index in range(10): - pool.addTask(self.numberer, index, result=result) - - pool.nonBlockingStart() - pool.join() - - for index in range(10): - self.assertTrue(index in result) - self.assertTrue(result[index]) - - self.assertFalse(pool.hasFailedTasks()) - - - - def test_pool_unbound_fail(self): - pool = ThreadPool(4) - - self.assertEqual(4, pool.poolSize()) - pool.addTask(ThreadPoolTest.numberer, 0, {}) - - pool.nonBlockingStart() - pool.join() - - self.assertTrue(pool.hasFailedTasks()) - - - def test_fill_pool(self): - pool = ThreadPool(4) - - for index in range(10): - pool.addTask(self.sleepTask, 2) - - pool.nonBlockingStart() - time.sleep(0.5) - self.assertEqual(pool.doneCount(), 0) - self.assertEqual(pool.runningCount(), 4) - - pool.join() - - - - def test_task(self): - def sleeping(): - time.sleep(1) - - task = Task(sleeping) - - self.assertFalse(task.hasStarted()) - self.assertFalse(task.isRunning()) - self.assertFalse(task.isDone()) - - task.start() - - self.assertTrue(task.hasStarted()) - self.assertTrue(task.isRunning()) - - task.join() - - self.assertFalse(task.isRunning()) - self.assertTrue(task.isDone()) - diff --git a/ThirdParty/Ert/python/tests/util/test_ui_return.py b/ThirdParty/Ert/python/tests/util/test_ui_return.py deleted file mode 100644 index 8b8da46025..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_ui_return.py +++ /dev/null @@ -1,69 +0,0 @@ -from ecl.test import ExtendedTestCase -from ecl.util import UIReturn -from ecl.util.enums import UIReturnStatusEnum - - -class UIReturnTest(ExtendedTestCase): - def test_create(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - self.assertTrue(ui_return) - - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - self.assertFalse(ui_return) - - self.assertEqual(0, len(ui_return)) - - def test_help(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - self.assertEqual("", ui_return.help_text()) - - ui_return.add_help("Help1") - self.assertEqual("Help1", ui_return.help_text()) - - ui_return.add_help("Help2") - self.assertEqual("Help1 Help2", ui_return.help_text()) - - def test_error_raises_OK(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - with self.assertRaises(ValueError): - ui_return.add_error("Error1") - - with self.assertRaises(ValueError): - ui_return.last_error() - - with self.assertRaises(ValueError): - ui_return.first_error() - - def test_add_error(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - ui_return.add_error("Error1") - ui_return.add_error("Error2") - ui_return.add_error("Error3") - self.assertEqual(3, len(ui_return)) - - self.assertEqual("Error1", ui_return.first_error()) - self.assertEqual("Error3", ui_return.last_error()) - - def test_iget_error(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - ui_return.add_error("Error1") - ui_return.add_error("Error2") - ui_return.add_error("Error3") - - errorList = [] - for index in range(len(ui_return)): - errorList.append(ui_return.iget_error(index)) - self.assertEqual(errorList, ["Error1", "Error2", "Error3"]) - - with self.assertRaises(TypeError): - ui_return.iget_error("XX") - - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - errorList = [] - for index in range(len(ui_return)): - errorList.append(ui_return.iget_error(index)) - self.assertEqual(errorList, []) - - def test_status_enum(self): - source_file_path = "lib/include/ert/util/ui_return.h" - self.assertEnumIsFullyDefined(UIReturnStatusEnum, "ui_return_status_enum", source_file_path) diff --git a/ThirdParty/Ert/python/tests/util/test_vectors.py b/ThirdParty/Ert/python/tests/util/test_vectors.py deleted file mode 100644 index 9b710567eb..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_vectors.py +++ /dev/null @@ -1,552 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'test_vectors.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - - -import copy -import datetime - -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase - -from ecl.util import DoubleVector, IntVector, BoolVector, TimeVector, CTime, PermutationVector - -class UtilTest(TestCase): - def setUp(self): - pass - - def dotest_slicing(self, vec): - self.assertEqual(10, len(vec)) - self.assertEqual(vec[-1], vec[9]) - self.assertEqual(8, len(vec[:8])) - self.assertEqual(9, len(vec[1:])) - self.assertEqual(3, len(vec[1:8:3])) - odds = vec[1::2] - self.assertEqual(4, len(vec[1:8:2])) - for i in range(4): - self.assertEqual(vec[2*i + 1], odds[i]) - - def test_slicing(self): - dv = DoubleVector(initial_size=10) - for i in range(10): - dv[i] = 1.0 / (1+i) - self.dotest_slicing(dv) - iv = IntVector(initial_size=10) - for i in range(10): - iv[i] = i**3 - self.dotest_slicing(iv) - bv = BoolVector(initial_size=10) - for i in range(0,10,3): - bv[i] = True - self.dotest_slicing(bv) - tv = TimeVector(initial_size=10) - for i in range(10): - tv[i] = CTime(datetime.datetime(2016, 12, i+3, 0, 0, 0)) - self.dotest_slicing(tv) - - - - def test_double_vector(self): - v = DoubleVector() - - v[0] = 77.25 - v[1] = 123.25 - v[2] = 66.25 - v[3] = 56.25 - v[4] = 111.25 - v[5] = 99.25 - v[12] = 12 - - self.assertEqual(len(v), 13) - self.assertEqual(list(v), [v[0], v[1], v[2], v[3], v[4], v[5], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v[12]]) - - v.clear() - self.assertEqual(len(v), 0) - - v.clear() - - v[0] = 0.1 - v[1] = 0.2 - v[2] = 0.4 - v[3] = 0.8 - - v2 = v * 2 - - self.assertEqual(list(v2), [v[0] * 2, v[1] * 2, v[2] * 2, v[3] * 2]) - - v2 += v - self.assertEqual(list(v2), [v[0] * 3, v[1] * 3, v[2] * 3, v[3] * 3]) - - v2.assign(0.66) - self.assertEqual(list(v2), [0.66, 0.66, 0.66, 0.66]) - - v.assign(v2) - self.assertEqual(list(v), [0.66, 0.66, 0.66, 0.66]) - - v.clear() - v.setDefault(0.75) - self.assertEqual(v.getDefault(), 0.75) - v[2] = 0.0 - self.assertEqual(v[1], 0.75) - - def test_vector_operations_with_exceptions(self): - iv1 = IntVector() - iv1.append(1) - iv1.append(2) - iv1.append(3) - - iv2 = IntVector() - iv2.append(4) - iv2.append(5) - - dv1 = DoubleVector() - dv1.append(0.5) - dv1.append(0.75) - dv1.append(0.25) - - # Size mismatch - with self.assertRaises(ValueError): - iv3 = iv1 + iv2 - - # Size mismatch - with self.assertRaises(ValueError): - iv3 = iv1 * iv2 - - # Type mismatch - with self.assertRaises(TypeError): - iv1 += dv1 - - # Type mismatch - with self.assertRaises(TypeError): - iv1 *= dv1 - - def test_setitem_getitem(self): - primes = [2,3,5,7,11,13,17,19] - primep = [i in primes for i in range(20)] - b = BoolVector(initial_size = 20) - b[2] = True - b[3:8:2] = True - b[11::2] = True - self.assertTrue(b[15]) - self.assertTrue(b[-5]) - self.assertTrue(b[17]) - self.assertTrue(b[19]) - b[-5] = False - self.assertEqual(list(b), primep) - - def test_repr(self): - primes = [2,3,5,7,11,13,17,19] - b = BoolVector() - for i in primes: - b[i] = True - pfx = 'BoolVector(size = 20, content = "00110101000101000101")' - print(repr(b)) - self.assertEqual(pfx, repr(b)[:len(pfx)]) - b[30] = True - pfx = 'BoolVector(size = 31, content = "001101010...00000001")' - print(repr(b)) - self.assertEqual(pfx, repr(b)[:len(pfx)]) - - - def test_bool_vector(self): - b = BoolVector() - b.setDefault(True) - - b[4] = False - - self.assertEqual(list(b), [True, True, True, True, False]) - - def test_activeList(self): - active_list = IntVector.active_list("1,10,100-105") - self.assertTrue(len(active_list) == 8) - self.assertTrue(active_list[0] == 1) - self.assertTrue(active_list[2] == 100) - self.assertTrue(active_list[7] == 105) - self.assertEqual(active_list.count(100), 1) - active_list.append(100) - active_list.append(100) - self.assertEqual(active_list.count(100), 3) - - active_list = IntVector.active_list("1,10,100-105X") - self.assertFalse(active_list) - - def test_value_list(self): - list2 = IntVector.valueList("3,10-12,0,1") - self.assertTrue(len(list2) == 6) - expected = [3, 10, 11, 12, 0, 1] - for v1, v2 in zip(list2, expected): - self.assertEqual(v1, v2) - - def test_contains_int(self): - iv = IntVector() - iv[0] = 1 - iv[1] = 10 - iv[2] = 100 - iv[3] = 1000 - - self.assertTrue(1 in iv) - self.assertTrue(10 in iv) - self.assertTrue(88 not in iv) - self.assertTrue(99 not in iv) - - def test_activeMask(self): - active_list = BoolVector.createActiveMask("1 , 4 - 7 , 10") - self.assertTrue(len(active_list) == 11) - self.assertTrue(active_list[1]) - self.assertTrue(active_list[4]) - self.assertTrue(active_list[10]) - self.assertFalse(active_list[9]) - self.assertFalse(active_list[8]) - - self.assertEqual(6, active_list.count(True)) - - active_list = BoolVector.createActiveMask("1,4-7,10X") - self.assertFalse(active_list) - - def test_update_active_mask(self): - vec = BoolVector(False, 10) - - self.assertTrue(vec.updateActiveMask("1-2,5")) - self.assertTrue(vec[1]) - self.assertTrue(vec[2]) - self.assertTrue(vec[5]) - self.assertFalse(vec[4]) - - vec = BoolVector(False, 10) - - self.assertTrue(vec.updateActiveMask("1-5,2,3")) - self.assertTrue(vec[1]) - self.assertTrue(vec[2]) - self.assertTrue(vec[3]) - self.assertTrue(vec[4]) - self.assertTrue(vec[5]) - self.assertFalse(vec[0]) - self.assertFalse(vec[6]) - - vec = BoolVector(False, 10) - - self.assertTrue(vec.updateActiveMask("5,6,7,15")) - self.assertTrue(vec[5]) - self.assertTrue(vec[6]) - self.assertTrue(vec[7]) - self.assertFalse(vec[4]) - self.assertFalse(vec[8]) - self.assertEqual(len(vec), 16) - - def test_pop(self): - a = IntVector() - a.append(1) - a.append(2) - - self.assertEqual(a.pop(), 2) - self.assertEqual(len(a), 1) - self.assertEqual(a.pop(), 1) - self.assertEqual(len(a), 0) - with self.assertRaises(ValueError): - a.pop() - -#---- - - def test_shift(self): - a = IntVector() - a.append(1) - a.append(2) - a.append(3) - a.append(4) - a.append(5) - - with self.assertRaises(ValueError): - a >> -1 - - with self.assertRaises(ValueError): - a << -1 - - with self.assertRaises(ValueError): - a << -6 - - b = a << 2 - self.assertEqual(list(b), [3, 4, 5]) - - print(a) - a <<= 2 - print(a) - self.assertEqual(list(a), [3, 4, 5]) - - b = a >> 2 - self.assertEqual(list(b), [0, 0, 3, 4, 5]) - - a >>= 2 - self.assertEqual(list(a), [0, 0, 3, 4, 5]) - - def test_int_vector(self): - a = IntVector() - a.append(1) - a.append(2) - a.append(3) - a.append(4) - a.append(5) - - self.assertEqual(list(a), [1, 2, 3, 4, 5]) - - a.sort(reverse=True) - self.assertEqual(list(a), [5, 4, 3, 2, 1]) - - self.assertTrue(a.max(), 5) - self.assertTrue(a.min(), 1) - self.assertTrue(a.minIndex(), 4) - - self.assertEqual(a.maxIndex(reverse=True), 0) - self.assertEqual(a.maxIndex(reverse=False), 0) - - a[4] = 5 - self.assertTrue(a[4] == 5) - - a_plus_one = a + 1 - self.assertEqual(list(a_plus_one), [6, 5, 4, 3, 6]) - - sliced = a[0:3] - self.assertEqual(list(sliced), [5, 4, 3]) - - with self.assertRaises(IndexError): - item = a[6] - - copy_of_a = a.copy() - self.assertEqual(list(a), list(copy_of_a)) - - another_copy_of_a = copy_of_a.copy( ) - self.assertEqual(list(a), list(another_copy_of_a)) - -#--- - - def test_div(self): - v = IntVector() - v[0] = 100 - v[1] = 10 - v[2] = 1 - v /= 10 - - self.assertEqual(list(v), [10, 1, 0]) - - def test_true(self): - iv = IntVector() - self.assertFalse(iv) # Will invoke the __len__ function; could override with __nonzero__ - iv[0] = 1 - self.assertTrue(iv) - - def test_time_vector(self): - time_vector = TimeVector() - - time1 = CTime(datetime.datetime(2013, 8, 13, 0, 0, 0)) - time2 = CTime(datetime.datetime(2013, 8, 13, 1, 0, 0)) - - time_vector.setDefault(time2) - - time_vector.append(time1) - time_vector[2] = time2 - - self.assertEqual(time_vector[0], time1) - self.assertEqual(time_vector[1], time2) - self.assertEqual(time_vector[2], time2) - - tv1 = TimeVector(default_value=datetime.date(2000, 1, 1), initial_size=2) - self.assertEqual(tv1[0], datetime.date(2000, 1, 1)) - - tv2 = TimeVector() - tv2.append(time2) - print(tv2) - - def test_permutation_vector(self): - vector = DoubleVector() - - for i in range(5, 0, -1): - vector.append(i) - - permutation_vector = vector.permutationSort() - - for index, value in enumerate(range(5, 0, -1)): - self.assertEqual(vector[index], value) - - vector.permute(permutation_vector) - - for index, value in enumerate(range(1, 6)): - self.assertEqual(vector[index], value) - - def test_contains_time(self): - start = datetime.datetime(2010, 1, 1, 0, 0, 0) - end = datetime.datetime(2010, 2, 1, 0, 0, 0) - other = datetime.datetime(2010, 1, 15, 0, 0, 0) - - tv = TimeVector() - tv.append(start) - tv.append(end) - - self.assertTrue(start in tv) - self.assertTrue(end in tv) - self.assertTrue(other not in tv) - - def test_unique(self): - iv = IntVector() - iv.append(1) - iv.append(1) - iv.append(1) - iv.append(0) - iv.append(1) - iv.append(2) - iv.append(2) - iv.append(0) - iv.append(3) - iv.selectUnique() - self.assertEqual(len(iv), 4) - self.assertEqual(iv[0], 0) - self.assertEqual(iv[1], 1) - self.assertEqual(iv[2], 2) - self.assertEqual(iv[3], 3) - - def test_element_sum(self): - dv = DoubleVector() - iv = IntVector() - for i in range(10): - dv.append(i + 1) - iv.append(i + 1) - - self.assertEqual(dv.elementSum(), 55) - self.assertEqual(iv.elementSum(), 55) - - def test_time_vector_regular(self): - start = datetime.datetime(2010, 1, 1, 0, 0, 0) - end = datetime.datetime(2010, 2, 1, 0, 0, 0) - - with self.assertRaises(ValueError): - trange = TimeVector.createRegular(end, start, "1X") - - with self.assertRaises(TypeError): - trange = TimeVector.createRegular(start, end, "1X") - - with self.assertRaises(TypeError): - trange = TimeVector.createRegular(start, end, "1") - - with self.assertRaises(TypeError): - trange = TimeVector.createRegular(start, end, "X") - - with self.assertRaises(TypeError): - trange = TimeVector.createRegular(start, end, "1.5Y") - - trange = TimeVector.createRegular(start, end, "d") - trange = TimeVector.createRegular(start, end, "D") - trange = TimeVector.createRegular(start, end, "1d") - self.assertEqual(trange[0].datetime(), start) - self.assertEqual(trange[-1].datetime(), end) - date = start - delta = datetime.timedelta(days=1) - for t in trange: - self.assertEqual(t, date) - date += delta - - end = datetime.datetime(2010, 1, 10, 0, 0, 0) - trange = TimeVector.createRegular(start, end, "2d") - self.assertEqual(trange[-1].datetime(), datetime.datetime(2010, 1, 9, 0, 0, 0)) - self.assertEqual(5, len(trange)) - - end = datetime.datetime(2012, 1, 10, 0, 0, 0) - trange = TimeVector.createRegular(start, end, "3M") - self.assertTrue(trange[-1] == datetime.datetime(2012, 1, 1, 0, 0, 0)) - self.assertTrue(trange[1] == datetime.datetime(2010, 4, 1, 0, 0, 0)) - self.assertTrue(trange[2] == datetime.datetime(2010, 7, 1, 0, 0, 0)) - self.assertTrue(trange[3] == datetime.datetime(2010, 10, 1, 0, 0, 0)) - self.assertTrue(trange[4] == datetime.datetime(2011, 1, 1, 0, 0, 0)) - - start = datetime.datetime(1980, 1, 1, 0, 0, 0) - end = datetime.datetime(2020, 1, 1, 0, 0, 0) - trange = TimeVector.createRegular(start, end, "2Y") - for (y, t) in zip(xrange(1980, 2022, 2), trange): - self.assertTrue(t == datetime.datetime(y, 1, 1, 0, 0, 0)) - - trange = TimeVector.createRegular(start, datetime.date(2050, 1, 1), "1Y") - - def test_asList(self): - v = IntVector() - v[0] = 100 - v[1] = 10 - v[2] = 1 - - l = v.asList() - self.assertListEqual(l, [100, 10, 1]) - - def test_true_false(self): - v = IntVector(default_value=77) - self.assertFalse(v) - v[10] = 77 - self.assertTrue(v) - - v = DoubleVector(default_value=77) - self.assertFalse(v) - v[10] = 77 - self.assertTrue(v) - - def test_count_equal(self): - v = IntVector(default_value=77) - v[0] = 1 - v[10] = 1 - v[20] = 1 - self.assertEqual(v.countEqual(1), 3) - - v = DoubleVector(default_value=77) - v[0] = 1 - v[10] = 1 - v[20] = 1 - self.assertEqual(v.countEqual(1), 3) - - def range_test(self, v, a, b, d): - v.initRange(a, b, d) - r = range(a, b, d) - - self.assertEqual(len(v), len(r)) - for a, b in zip(v, r): - self.assertEqual(a, b) - - def create_range_test(self, v, a, b, d): - v = IntVector.createRange(a, b, d) - r = range(a, b, d) - - self.assertEqual(len(v), len(r)) - for a, b in zip(v, r): - self.assertEqual(a, b) - - def test_range(self): - v = IntVector() - v[10] = 99 - - with self.assertRaises(ValueError): - v.initRange(1, 2, 0) - - self.range_test(v, 0, 5, 1) - self.range_test(v, 0, 100, 3) - self.range_test(v, 0, 100, -3) - - self.create_range_test(v, 0, 5, 1) - self.create_range_test(v, 0, 100, 3) - self.create_range_test(v, 0, 100, -3) - - - - def test_perm_vector(self): - v = IntVector.createRange( 11 , 0 , -1 ) - perm = v.permutationSort( ) - self.assertEqual( perm[0] , 10 ) - self.assertEqual( perm[5] , 5 ) - self.assertEqual( perm[10] , 0 ) diff --git a/ThirdParty/Ert/python/tests/util/test_version.py b/ThirdParty/Ert/python/tests/util/test_version.py deleted file mode 100644 index fc8de22f6d..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_version.py +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_version.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. -import os.path - -import ecl -from ecl.test import ExtendedTestCase -from ecl.util import Version,EclVersion - - -class VersionTest(ExtendedTestCase): - def setUp(self): - pass - - def test_create(self): - v1 = Version(1, 8, 6) - self.assertFalse(v1.isDevelVersion()) - - self.assertEqual(v1.versionString(), "1.8.6") - self.assertEqual(v1.versionTuple(), (1, 8, 6)) - - v2 = Version(2, 0, "X") - self.assertTrue(v2.isDevelVersion()) - - def test_eq(self): - v1 = Version(1, 2, 3) - v2 = Version(1, 2, 3) - - self.assertTrue(v1 == v2) - self.assertEqual(v1, v2) - self.assertEqual(str(v1), str(v2)) - self.assertEqual(repr(v1), repr(v2)) - self.assertFalse(v1 != v2) - - v1 = Version(1, 2, "X") - v2 = Version(1, 2, "Y") - self.assertTrue(v1 != v2) - self.assertFalse(v1 == v2) - - v1 = Version(1, 2, "X") - v2 = Version(1, 2, 0) - self.assertTrue(v1 != v2) - self.assertFalse(v1 == v2) - - v1 = Version(1, 2, "X") - v2 = Version(1, 3, "X") - self.assertTrue(v1 != v2) - self.assertFalse(v1 == v2) - - v1 = Version(1, 2, "X") - v2 = (1, 3, "X") - self.assertTrue(v1 != v2) - self.assertFalse(v1 == v2) - - def test_ge(self): - v1 = Version(1, 2, 3) - v2 = Version(1, 2, 3) - v3 = (1, 2, 2) - - self.assertEqual(str(v1), str(v2)) - self.assertEqual(repr(v1), repr(v2)) - - self.assertTrue(v1 >= v2) - self.assertFalse(v1 < v2) - - self.assertTrue(v1 >= v3) - self.assertFalse(v1 < v3) - - v1 = Version(1, 2, "X") - v2 = Version(1, 1, 9) - self.assertTrue(v1 > v2) - - v2 = Version(1, 2, "X") - self.assertTrue(v1 >= v2) - - v2 = Version(1, 2, 0) - self.assertFalse(v1 >= v2) - - self.assertNotEqual(str(v1), str(v2)) - self.assertNotEqual(repr(v1), repr(v2)) - - - def test_current(self): - current = EclVersion( ) - self.assertTrue(current > (0, 0, 0)) - pfx = 'Version(major=' - self.assertEqual(pfx, repr(current)[:len(pfx)]) - - - def test_root_version(self): - cv = EclVersion( ) - self.assertEqual( ecl.__version__ , cv.versionString() ) - - - def test_root_path(self): - self.assertTrue( os.path.isdir( os.path.join( ecl.root() , "ecl"))) - self.assertTrue( os.path.isfile( os.path.join( ecl.root() , "ecl", "__init__.py"))) - diff --git a/ThirdParty/Ert/python/tests/util/test_work_area.py b/ThirdParty/Ert/python/tests/util/test_work_area.py deleted file mode 100644 index 51403f817d..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_work_area.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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. - -import os.path -import os - -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -from ecl.test import ExtendedTestCase , TestAreaContext, TempAreaContext - - -class WorkAreaTest(ExtendedTestCase): - - def test_full_path(self): - with TestAreaContext("TestArea") as test_area: - with open("test_file" , "w") as fileH: - fileH.write("Something") - - self.assertTrue( os.path.isfile( "test_file") ) - - with self.assertRaises(IOError): - full_path = test_area.getFullPath( "does/not/exists" ) - - with self.assertRaises(IOError): - full_path = test_area.getFullPath( "/already/absolute" ) - - full_path = test_area.getFullPath( "test_file" ) - self.assertTrue( os.path.isfile( full_path )) - self.assertTrue( os.path.isabs( full_path )) - - - def test_temp_area(self): - with TestAreaContext("TestArea") as test_area: - cwd = os.getcwd() - with open("file.txt" , "w") as f: - f.write("File") - - with TempAreaContext("TempArea") as temp_area: - self.assertEqual( cwd, os.getcwd()) - self.assertEqual( cwd, temp_area.get_cwd()) - temp_area.copy_file( "file.txt" ) - - self.assertTrue( os.path.isfile( os.path.join( temp_area.getPath( ) , "file.txt"))) - - os.mkdir("tmp") - os.chdir("tmp") - - self.assertEqual( os.getcwd() , os.path.join( cwd , "tmp")) - - - def test_IOError(self): - with TestAreaContext("TestArea") as test_area: - with self.assertRaises(IOError): - test_area.copy_file( "Does/not/exist" ) - - with self.assertRaises(IOError): - test_area.install_file( "Does/not/exist" ) - - with self.assertRaises(IOError): - test_area.copy_directory( "Does/not/exist" ) - - with self.assertRaises(IOError): - test_area.copy_parent_directory( "Does/not/exist" ) - - os.makedirs("path1/path2") - with open("path1/file.txt" , "w") as f: - f.write("File ...") - - with self.assertRaises(IOError): - test_area.copy_directory( "path1/file.txt" ) - - def test_sync(self): - with TestAreaContext("test_sync") as t: - with open("file.txt" , "w") as f: - f.write("content") - - t.sync() - self.assertTrue( os.path.isfile( "file.txt")) diff --git a/ThirdParty/Ert/python/tests/well/CMakeLists.txt b/ThirdParty/Ert/python/tests/well/CMakeLists.txt deleted file mode 100644 index b9efe79dca..0000000000 --- a/ThirdParty/Ert/python/tests/well/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ecl_well.py - test_ecl_well2.py - test_ecl_well3.py -) - -add_python_package("python.tests.well" ${PYTHON_INSTALL_PREFIX}/tests/well "${TEST_SOURCES}" False) - -if (STATOIL_TESTDATA_ROOT) - addPythonTest(tests.well.test_ecl_well.EclWellTest LABELS StatoilData) - addPythonTest(tests.well.test_ecl_well2.EclWellTest2 LABELS StatoilData) - addPythonTest(tests.well.test_ecl_well3.EclWellTest3 LABELS StatoilData) -endif() diff --git a/ThirdParty/Ert/python/tests/well/__init__.py b/ThirdParty/Ert/python/tests/well/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well.py b/ThirdParty/Ert/python/tests/well/test_ecl_well.py deleted file mode 100644 index ed3aad2c47..0000000000 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well.py +++ /dev/null @@ -1,446 +0,0 @@ -import datetime -from ecl.ecl import EclGrid, EclFile, EclFileFlagEnum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime -from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - - -class EclWellTest(ExtendedTestCase): - ALL_WELLS = ['E5H', 'G1H', 'M41', 'J41', 'D10H', 'P41', 'L41', 'M42', 'S41', 'S13H', 'Q12HT2', 'O41', 'L11H', 'Q21H', - 'E6CH', 'D4Y1H', 'D4Y2H', 'I13Y1H', 'Q21AY1H', 'F5AH', 'O14Y4HT2', 'K24Y1H', 'K24Y3H', 'S21H', 'N11H', - 'L23Y1H', 'D7AY1H', 'S21AHT2', 'H2AH', 'S21AHT3', 'L23Y6H', 'N11AH', 'N11BY1H', 'X23Y2H', 'N22Y3HT3', - 'G1BY1HT2', 'Q21BY1H', 'Q21BY2T2', 'A08', 'A37', 'P24Y4H', 'A11', 'A33', 'P21BY1H', 'H6BY2H', 'M24AH', - 'TOGIB2H', 'TOGIB3H', 'TOGIB4H', 'TOGIB5H', 'TOGIB6H', 'TAP21', 'D1AH', 'D1BYH', 'D2H', 'D2AYH', 'D4YH', - 'D5AH', 'D6H', 'D7H', 'D7AYH', 'D8AH', 'D8BYH', 'E1AH', 'E1BYH', 'E3YH', 'E4H', 'E5AH', 'E6BH', 'E6DYH', - '31/2-T1', 'F1AH', 'F1BYH', 'F4AHT2', 'F5H', 'F5BYH', 'F6AH', 'F6BYH', '2B3H', 'G1AHT2', 'G1BYH', 'G3H', - 'G3AYH', 'G4AH', 'G4BYH', 'G6HT2', 'G6AYH', '31/5-T1', 'H1AH', 'H2BYH', 'H2HT2', 'H3ABH', 'H3CYH', 'H4HT2', - 'H5AHT2', 'H6AH', 'H6BYH', 'Z1H', 'Z2H', 'I11AH', 'I12AYH', 'I13YH', 'I14AHT2', 'I14BYH', 'I21AHT2', - 'I21BYH', 'I22AH', 'I23AH', 'I32YH', 'J11AH', 'J12H', 'J13H', 'J13AYH', 'J14H', 'J14AYH', 'J21YH', 'J22YH', - 'J22AYH', 'J23AH', 'J24HT2', 'J24AYH', 'K11YH', 'K12AH', 'K12BYH', 'K13AH', 'K14AYH', 'K21AYH', 'K22AH', - 'K23AH', 'K24YH', 'L11AH', 'L11BYH', 'L12Y', 'L13H', 'L13AYH', 'L14YH', 'L21AYH', 'L22AYH', 'L23YH', - 'L24AYH', 'M11H', 'M12H', 'M13YH', 'M14AHT2', 'M14BYH', 'M21H', 'M22H', 'M23AH', 'M24YH', 'N11BYH', - 'N12HT2', 'N13H', 'N14AH', 'N21YH', 'N22YH', 'N23AYH', 'N24YH', 'O11H', 'O11AYH', 'O12AH', 'O13AH', - 'O13BYH', 'O14YH', 'O21YH', 'O23YH', 'O26YH', 'P11YH', 'P11AYH', 'P12H', 'P13AHT2', 'P13BYH', 'P14AHT2', - 'P14BYH', 'P21AYH', 'P21BYH', 'P22AYH', 'P23YH', 'P24YH', 'P24Y1H', 'Q11AHT2', 'Q11BYH', 'Q12AH', 'Q12BH', - 'Q13AH', 'Q14H', 'Q14AYH', 'Q21AYH', 'Q21BH1', 'Q21BH2', 'S11HT3', 'S12H', 'S13AH', 'S14AH', 'S14BYH', - 'S21BYH', 'S22AH', 'S23HT2', 'S23AYH', 'S24YH', 'S31H', 'X11AH', 'X11BYH', 'X12H', 'X12AH', 'X13YH', - 'X14AYH', 'X21H', 'X22H', 'X22AYH', 'X23YH', 'X24AH', 'Y11AH', 'Y11BYH', 'Y12YH', 'Y13AH', 'Y13BYH', - 'Y14AYH', 'Y21YH', 'Y22YH', 'Y23AHT2', 'Y23CYH', 'Y24AH'] - - - @classmethod - def setUpClass(cls): - EclWellTest.__well_info = None - EclWellTest.__well_info_with_no_well_segments = None - - - def getWellInfoWithNoWellSegments(self): - """ @rtype: WellInfo """ - if EclWellTest.__well_info_with_no_well_segments is None: - grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") - - grid = EclGrid(grid_path) - - rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) - - EclWellTest.__well_info_with_no_well_segments = WellInfo(grid, rst_file, False) - - - return EclWellTest.__well_info_with_no_well_segments - - def getWellInfo(self): - """ @rtype: WellInfo """ - if EclWellTest.__well_info is None: - grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") - - grid = EclGrid(grid_path) - - rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) - - EclWellTest.__well_info = WellInfo(grid, rst_file) - - - return EclWellTest.__well_info - - - def test_no_such_well(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - rst_path1 = self.createTestPath("nosuch/path/ECLIPSE.X001") - rst_path2 = self.createTestPath("nosuch/path/ECLIPSE.X002") - grid = EclGrid(grid_path) - with self.assertRaises(IOError): - _ = WellInfo(grid, rst_path1) - with self.assertRaises(IOError): - _ = WellInfo(grid, [rst_path1, rst_path2]) - - def test_construction(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0011") - rst_path_2 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0022") - rst_path_3 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0035") - rst_path_4 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0061") - - grid = EclGrid(grid_path) - - def checkWellInfo(well_info, well_count, report_step_count): - self.assertEqual(len(well_info), well_count) - - for index, well_time_line in enumerate(well_info): - self.assertEqual(len(well_time_line), report_step_count[index]) - - well_info = WellInfo(grid, rst_path_1) - checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) - - well_info = WellInfo(grid, EclFile(rst_path_1)) - checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) - - well_info = WellInfo(grid, [rst_path_1, rst_path_2, rst_path_3]) - checkWellInfo(well_info, well_count=8, report_step_count=[3, 3, 3, 3, 3, 2, 2, 2]) - - well_info = WellInfo(grid, [EclFile(rst_path_1), EclFile(rst_path_2), rst_path_3, EclFile(rst_path_4)]) - checkWellInfo(well_info, well_count=8, report_step_count=[4, 4, 4, 4, 4, 3, 3, 3]) - - - well_info = WellInfo(grid) - well_info.addWellFile(rst_path_1, True) - - checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) - - well_info.addWellFile(EclFile(rst_path_2), True) - checkWellInfo(well_info, well_count=8, report_step_count=[2, 2, 2, 2, 2, 1, 1, 1]) - - well_info.addWellFile(EclFile(rst_path_3), True) - checkWellInfo(well_info, well_count=8, report_step_count=[3, 3, 3, 3, 3, 2, 2, 2]) - - well_info.addWellFile(rst_path_4, True) - checkWellInfo(well_info, well_count=8, report_step_count=[4, 4, 4, 4, 4, 3, 3, 3]) - - - - def test_well_type_enum(self): - source_file_path = "lib/include/ert/ecl_well/well_conn.h" - # The header file has duplicated symbols, so the simple test fails. - # self.assertEnumIsFullyDefined(WellTypeEnum, "well_type_enum", source_file_path) - - - def test_well_connection_direction_enum(self): - source_file_path = "lib/include/ert/ecl_well/well_conn.h" - self.assertEnumIsFullyDefined(WellConnectionDirectionEnum, "well_conn_dir_enum", source_file_path) - - - def test_well_info(self): - well_info = self.getWellInfo() - self.assertEqual(len(well_info), 222) - - all_well_names = well_info.allWellNames() - - self.assertEqual(len(well_info), len(all_well_names)) - self.assertEqual(EclWellTest.ALL_WELLS, all_well_names) - - for well_name in all_well_names: - self.assertTrue(well_name in well_info) - - self.assertEqual(well_info[0], well_info[all_well_names[0]]) - self.assertEqual(well_info[1], well_info[all_well_names[1]]) - self.assertEqual(well_info[221], well_info[all_well_names[221]]) - - self.assertNotEqual(well_info[0], well_info[1]) - - well_time_lines = [wtl for wtl in well_info] - self.assertEqual(len(well_time_lines), len(well_info)) - - with self.assertRaises(IndexError): - err = well_info[222] - - with self.assertRaises(KeyError): - err = well_info["Well"] - - - - - def test_well_time_line(self): - well_info = self.getWellInfo() - - for well_time_line in well_info: - self.assertEqual(len(well_time_line), 1) - - well_states = set() - for well_name in EclWellTest.ALL_WELLS: - well_time_line = well_info[well_name] - well_states.add(well_time_line[0]) - - with self.assertRaises(IndexError): - err = well_time_line[1] - - self.assertEqual(len(well_states), len(EclWellTest.ALL_WELLS)) - - # testing name and repr - info = self.getWellInfo() - wtl = info['G6HT2'] - self.assertEqual('G6HT2', wtl.getName()) - rep = repr(wtl) - print(rep) - pfx = 'WellTimeLine(' - self.assertEqual(pfx, rep[:len(pfx)]) - - # testing __getitem__ and its well state - ws = wtl[0] - self.assertTrue(ws.isOpen()) - self.assertEqual(ws.wellType(), WellTypeEnum.ECL_WELL_PRODUCER) - self.assertTrue(ws.isMultiSegmentWell()) - pfx = 'WellState(' - self.assertEqual(pfx, repr(ws)[:len(pfx)]) - - - def test_well_state(self): - well_info = self.getWellInfo() - - sim_time = CTime(datetime.date(2000, 1, 1)) - open_states = {True: 0, False: 0} - msw_states = {True: 0, False: 0} - well_types = {WellTypeEnum.ECL_WELL_ZERO: 0, - WellTypeEnum.ECL_WELL_PRODUCER: 0, - WellTypeEnum.ECL_WELL_GAS_INJECTOR: 0, - WellTypeEnum.ECL_WELL_OIL_INJECTOR: 0, - WellTypeEnum.ECL_WELL_WATER_INJECTOR: 0} - - segments = set() - branches = set() - connections = set() - connections_count = 0 - - for index, well_name in enumerate(EclWellTest.ALL_WELLS): - well_time_line = well_info[well_name] - well_state = well_time_line[0] - - self.assertEqual(well_state.name(), well_name) - well_number = well_state.wellNumber() - self.assertEqual(well_number, index) - - self.assertEqual(well_state.reportNumber(), 135) - self.assertEqual(well_state.simulationTime(), sim_time) - - open_states[well_state.isOpen()] += 1 - msw_states[well_state.isMultiSegmentWell()] += 1 - - well_types[well_state.wellType()] += 1 - - self.assertTrue(well_state.hasGlobalConnections()) - global_connections = well_state.globalConnections() - connections_count += len(global_connections) - connections.update(global_connections) - - # branches.add(well_state.branches()) - # segments.add(well_state.segments()) - - self.assertEqual(open_states[True], 53) - self.assertEqual(open_states[False], 169) - - self.assertEqual(msw_states[True], 169) - self.assertEqual(msw_states[False], 53) - - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_ZERO], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_WATER_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_OIL_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_GAS_INJECTOR], 1) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_PRODUCER], 221) - - self.assertEqual(len(connections), connections_count) - - - - def test_well_segments(self): - well_info = self.getWellInfo() - - well_name = "X22AYH" - well_time_line = well_info[well_name] - well_state = well_time_line[0] - - segments = well_state.segments() - - branch_ids = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55] - - outlet_ids = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 45, 47, 48, 49, 50, 51, - 52, 53, 54, 55] - - depths = [1554.0, 1557.505, 1557.506, 1557.50540469, 1557.75140469, 1558.24240469, 1558.24240469, 1557.75340469, - 1557.50740469, 1557.50658613, 1557.50628848, 1557.50584678, 1557.50384678, 1557.50484678, 1557.50402823, - 1557.50380498, 1557.50454913, 1557.50425147, 1557.50325147, 1557.50273057, 1557.50473057, 1557.50373057, - 1557.5038794, 1557.5048794, 1557.50398643, 1557.50406085, 1557.50606085, 1557.50670767, 1557.635, 1557.509, - 1557.504, 1557.503, 1557.502, 1557.50242878, 1557.50542878, 1557.50505671, 1557.50602409, 1557.50602409, - 1557.50402409, 1557.50485764, 1557.50563489, 1557.50543796, 1557.50643796, 1557.50843796, 1557.50799148, - 1557.50709851, 1557.50665427, 1557.50865427, 1557.50943383, 1557.50543383, 1557.50443383, 1557.50495473, - 1557.504285, 1557.50473149, 1557.50442009, 1557.505, 1557.506, 1557.50540469, 1557.75140469, 1558.24240469, - 1558.24240469, 1557.75340469, 1557.50740469, 1557.50658613, 1557.50628848, 1557.50584678, 1557.50384678, - 1557.50484678, 1557.50402823, 1557.50380498, 1557.50454913, 1557.50425147, 1557.50325147, 1557.50273057, - 1557.50473057, 1557.50373057, 1557.5038794, 1557.5048794, 1557.50398643, 1557.50406085, 1557.50606085, - 1557.50670767, 1557.635, 1557.509, 1557.504, 1557.503, 1557.502, 1557.50242878, 1557.50542878, 1557.50505671, - 1557.50602409, 1557.50602409, 1557.50402409, 1557.50485764, 1557.50563489, 1557.50543796, 1557.50643796, - 1557.50799148, 1557.50799148, 1557.50665427, 1557.50865427, 1557.50943383, 1557.50543383, 1557.50443383, - 1557.50495473, 1557.504285, 1557.50473149, 1557.50442009] - - lengths = [1853.483, 525.634, 89.101, 148.227, 105.066, 70.981, 50.194, 71.215, 129.929, 141.712, 141.239, 108.247, - 200.032, 116.122, 141.525, 141.983, 112.622, 72.694, 105.195, 149.555, 128.22, 83.537, 112.533, 155.336, - 86.552, 71.427, 129.949, 92.347, 210.312, 58.0, 218.375, 111.0, 250.925, 76.233, 72.565, 127.481, 97.987, - 75.648, 121.119, 129.137, 188.157, 109.433, 142.914, 84.9, 47.458, 57.507, 55.704, 211.767, 121.219, - 143.23, 145.666, 146.044, 88.195, 72.891, 58.92, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, - 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, - 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - - total_lengths = [1853.483, 2379.117, 2468.218, 2616.445, 2721.511, 2792.492, 2842.686, 2913.901, 3043.83, 3185.542, - 3326.781, 3435.028, 3635.06, 3751.182, 3892.707, 4034.69, 4147.312, 4220.006, 4325.201, 4474.756, - 4602.976, 4686.513, 4799.046, 4954.382, 5040.934, 5112.361, 5242.31, 5334.657, 2063.795, 2121.795, - 2340.17, 2451.17, 2702.095, 2778.328, 2850.893, 2978.374, 3076.361, 3152.009, 3273.128, 3402.265, - 3590.422, 3699.855, 3842.769, 3927.669, 3975.127, 4032.634, 4088.338, 4300.105, 4421.324, 4564.554, - 4710.22, 4856.264, 4944.459, 5017.35, 5076.27, 2379.217, 2468.318, 2616.545, 2721.611, 2792.592, - 2842.786, 2914.001, 3043.93, 3185.642, 3326.881, 3435.128, 3635.16, 3751.282, 3892.807, 4034.79, - 4147.412, 4220.106, 4325.301, 4474.856, 4603.076, 4686.613, 4799.146, 4954.482, 5041.034, 5112.461, - 5242.41, 5334.757, 2063.895, 2121.895, 2340.27, 2451.27, 2702.195, 2778.428, 2850.993, 2978.474, - 3076.461, 3152.109, 3273.228, 3402.365, 3590.522, 3699.955, 3842.869, 3975.227, 3975.227, 4088.438, - 4300.205, 4421.424, 4564.654, 4710.32, 4856.364, 4944.559, 5017.45, 5076.37] - - link_count = 0 - main_stem = {True: 0, False: 0} - nearest_wellhead = {True: 0, False: 0} - for index, segment in enumerate(segments): - assert isinstance(segment, WellSegment) - self.assertEqual(segment.id(), index + 1) - link_count += segment.linkCount() - self.assertEqual(segment.branchId(), branch_ids[index]) - self.assertEqual(segment.outletId(), outlet_ids[index]) - - self.assertTrue(segment.isActive()) - main_stem[segment.isMainStem()] += 1 - nearest_wellhead[segment.isNearestWellHead()] += 1 - - self.assertFloatEqual(segment.depth(), depths[index]) - self.assertFloatEqual(segment.length(), lengths[index]) - self.assertFloatEqual(segment.totalLength(), total_lengths[index]) - - if index == 0: - self.assertEqual(segment.diameter(), 0.0) - else: - self.assertEqual(segment.diameter(), 0.159) - - - self.assertEqual(main_stem[True], 28) - self.assertEqual(main_stem[False], 80) - - self.assertEqual(nearest_wellhead[True], 1) - self.assertEqual(nearest_wellhead[False], 107) - - self.assertEqual(link_count, 53) - - - - def test_well_connections(self): - well_info = self.getWellInfo() - - well_name = "H6BY2H" - well_connections_ijk = [(33, 157, 9), (32, 157, 9), (32, 157, 51), (32, 157, 52), - (32, 157, 53), (32, 157, 54), (32, 157, 55), (32, 157, 56), - (32, 157, 57), (31, 157, 57), (31, 158, 57), (31, 158, 56), - (30, 158, 56), (29, 158, 56), (29, 157, 56), (28, 157, 56), - (28, 158, 56), (28, 158, 55), (27, 158, 55), (27, 158, 54), - (26, 158, 54), (26, 158, 53), (25, 158, 53), (24, 158, 53), - (23, 158, 53), (23, 158, 54), (22, 158, 54), (21, 158, 54), - (20, 158, 54), (20, 158, 55), (19, 158, 55), (19, 158, 54), - (18, 158, 54), (17, 158, 54), (16, 158, 54), (16, 158, 55), - (15, 158, 55), (15, 158, 54), (15, 158, 53), (14, 158, 54), - (13, 158, 54), (13, 158, 55), (12, 158, 55), (12, 157, 55)] - - well_connection_factors = [3022.45092773, 171.561004639, 237.263000488, 135.57800293, 177.925994873, 289.058990479, - 1081.09997559, 1575.79101562, 3679.54907227, 2865.51489258, 3999.2199707, 14205.3300781, - 1864.43005371, 1296.47302246, 3.40599989891, 2012.7199707, 2656.25390625, 4144.21923828, - 6.22700023651, 96.4029998779, 0.144999995828, 80.81199646, 114.416999817, 97.5159988403, - 26.8530006409, 0.12800000608, 34238.15625, 34493.7070312, 2618.16894531, 31999.1992188, - 27874.6191406, 7343.23681641, 35418.1679688, 34612.6523438, 3486.13500977, 15446.3691406, - 65.4499969482, 8687.91113281, 13238.8037109, 5644.90380859, 7499.49707031, 12863.5292969, - 12277.4716797, 19404.5488281] - - well_time_line = well_info[well_name] - well_state = well_time_line[0] - - self.assertFalse(well_state.isMultiSegmentWell()) - - self.assertTrue(well_state.hasGlobalConnections()) - global_connections = well_state.globalConnections() - - for index, connection in enumerate(global_connections): - assert isinstance(connection, WellConnection) - self.assertTrue(connection.isOpen()) - self.assertEqual(connection.ijk(), well_connections_ijk[index]) - self.assertFalse(connection.isMultiSegmentWell()) - self.assertEqual(connection.segmentId(), -999) - self.assertFalse(connection.isFractureConnection()) - self.assertTrue(connection.isMatrixConnection()) - self.assertFloatEqual(connection.connectionFactor(), well_connection_factors[index]) - self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirX) - - self.assertNotEqual(global_connections[0], global_connections[1]) - self.assertEqual(global_connections[0], global_connections[0]) - - - def test_well_connections_msw(self): - well_info = self.getWellInfo() - - well_name = "X22AYH" - well_time_line = well_info[well_name] - well_state = well_time_line[0] - - segment_ids = [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108] - - self.assertTrue(well_state.isMultiSegmentWell()) - - self.assertTrue(well_state.hasGlobalConnections()) - global_connections = well_state.globalConnections() - - self.assertEqual(len(global_connections), len(segment_ids)) - - for index, connection in enumerate(global_connections): - assert isinstance(connection, WellConnection) - self.assertTrue(connection.isOpen()) - self.assertTrue(connection.isMultiSegmentWell()) - self.assertEqual(connection.segmentId(), segment_ids[index]) - self.assertFalse(connection.isFractureConnection()) - self.assertTrue(connection.isMatrixConnection()) - self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) - - - def test_well_connections_msw_do_not_load_segments(self): - well_info = self.getWellInfoWithNoWellSegments() - - well_name = "X22AYH" - well_time_line = well_info[well_name] - well_state = well_time_line[0] - - segment_ids = [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108] - - self.assertTrue(well_state.isMultiSegmentWell()) - self.assertFalse(well_state.hasSegmentData()) - - self.assertTrue(well_state.hasGlobalConnections()) - global_connections = well_state.globalConnections() - - self.assertEqual(len(global_connections), len(segment_ids)) - - for index, connection in enumerate(global_connections): - assert isinstance(connection, WellConnection) - self.assertTrue(connection.isOpen()) - self.assertTrue(connection.isMultiSegmentWell()) - self.assertEqual(connection.segmentId(), segment_ids[index]) - self.assertFalse(connection.isFractureConnection()) - self.assertTrue(connection.isMatrixConnection()) - self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well2.py b/ThirdParty/Ert/python/tests/well/test_ecl_well2.py deleted file mode 100644 index 52797e2bfa..0000000000 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well2.py +++ /dev/null @@ -1,43 +0,0 @@ -import datetime -import os.path - -from ecl.ecl import EclGrid, EclFile, EclFileFlagEnum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime -from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - - - -class EclWellTest2(ExtendedTestCase): - grid = None - - - def getGrid(self): - if EclWellTest2.grid is None: - EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) - - return EclWellTest2.grid - - - def checkWell(self , rst_file): - segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, - 128.534 , 165.33 , 59.97 , 936.719 ] - - well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file ))) - well_time_line = well_info["F4BYH"] - for well_state in well_time_line: - self.assertTrue( well_state.isMultiSegmentWell() ) - self.assertTrue( well_state.hasSegmentData() ) - - for index,length in enumerate(segment_length): - segment = well_state.igetSegment(index) - self.assertFloatEqual( segment.length() , length ) - - - - - def testWell(self): - self.checkWell("T07-4A-W2014-06.X0695") - self.checkWell("T07-4A-W2014-06.X0709") - self.checkWell("T07-4A-W2014-06.UNRST") - diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well3.py b/ThirdParty/Ert/python/tests/well/test_ecl_well3.py deleted file mode 100644 index 66283d261e..0000000000 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well3.py +++ /dev/null @@ -1,48 +0,0 @@ -import datetime -import os.path - -from ecl.ecl import EclGrid, EclFile, EclSum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime -from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - - -class EclWellTest3(ExtendedTestCase): - grid = None - - def test_rates(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - rst_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - sum_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - - grid = EclGrid(grid_path) - well_info = WellInfo(grid, rst_path) - sum = EclSum(sum_path) - - for wtl in well_info: - for well_state in wtl: - # print "%03d %g %g " % (R , well_state.oilRate(), sum.get_from_report( "WOPR:%s" % well , R)) - if wtl.getName() == "OP_4": - pass - # print well_state.oilRate(), well_state.waterRate(), well_state.gasRate(), well_state.volumeRate() - # print well_state.oilRateSI(), well_state.waterRateSI(), well_state.gasRateSI(), well_state.volumeRateSI() - self.assertEqual(well_state.oilRate(), well_state.oilRateSI()) - self.assertEqual(well_state.waterRate(), well_state.waterRateSI()) - self.assertEqual(well_state.gasRate(), well_state.gasRateSI()) - self.assertEqual(well_state.volumeRate(), well_state.volumeRateSI()) - # print sum.get_from_report("WOPR:%s" % wtl.getName(), 1) - # print sum.get_from_report( "WWPR:%s" % wtl.getName(), 30 ) - - for conn in well_state.globalConnections(): - # print conn.gasRate(), conn.waterRate(), conn.oilRate() - # print conn.gasRateSI(), conn.waterRateSI(), conn.oilRateSI() - self.assertEqual(conn.gasRate(), conn.gasRateSI()) - self.assertEqual(conn.waterRate(), conn.waterRateSI()) - self.assertEqual(conn.oilRate(), conn.oilRateSI()) - self.assertEqual(conn.volumeRate(), conn.volumeRateSI()) - # - # print sum.get_from_report("WGPR:%s" % wtl.getName(), 30) - # - # self.assertFloatEqual(well_state.oilRate(), sum.get_from_report("WOPR:%s" % wtl.getName(), 30)) - # self.assertFloatEqual(well_state.waterRate(), sum.get_from_report("WWPR:%s" % wtl.getName(), 30)) - # self.assertFloatEqual(well_state.gasRate(), sum.get_from_report("WGPR:%s" % wtl.getName(), 30)) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py index 8f12c67354..1d7d2ee32f 100644 --- a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py @@ -446,3 +446,10 @@ def test_well_connections_msw_do_not_load_segments(self): self.assertFalse(connection.isFractureConnection()) self.assertTrue(connection.isMatrixConnection()) self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) + + + def test_load_broken_direction(self): + grid_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.EGRID") + rst_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST") + grid = EclGrid(grid_path) + well_info = WellInfo(grid, rst_path) diff --git a/ThirdParty/Ert/redhat/ert.ecl.spec b/ThirdParty/Ert/redhat/ert.ecl.spec deleted file mode 100644 index 9aabf2ff86..0000000000 --- a/ThirdParty/Ert/redhat/ert.ecl.spec +++ /dev/null @@ -1,108 +0,0 @@ -# -# spec file for package ert.ecl -# - -%define tag final2 - -Name: ert.ecl -Version: 2015.10 -Release: 0 -Summary: ERT - Ensemble based Reservoir Tool - ECL library -License: GPL-3+ -Group: Development/Libraries/C and C++ -Url: http://ert.nr.no -Source0: https://github.com/OPM/%{name}/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz -BuildRequires: lapack-devel zlib-devel iputils -BuildRequires: gcc -%{?!el6:BuildRequires: python-devel numpy} -%{?el6:BuildRequires: cmake28 devtoolset-3-toolchain} -%{?!el6:BuildRequires: cmake} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -Requires: libert.ecl1 = %{version} - -%description -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). - -%package -n libert.ecl1 -Summary: ERT - Ensemble based Reservoir Tool - ECL library -Group: System/Libraries - -%{?!el6: -%package -n python-ert.ecl -Summary: ERT - Ensemble based Reservoir Tool - Python bindings -Group: Python/Libraries -Requires: libert.ecl1 python-cwrap - -%description -n python-ert.ecl -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). This package contains the Python bindings. - -%package -n python-cwrap -Summary: Simplify ctypes based wrapping of C code. -Group: Python/Libraries - -%description -n python-cwrap -Package to simplify ctypes based wrapping of C code. -} - -%description -n libert.ecl1 -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). - -%package devel -Summary: Development and header files for libert.ecl -Group: Development/Libraries/C and C++ -Requires: %{name} = %{version} -Requires: lapack-devel -Requires: libert.ecl1 = %{version} - -%description devel -This package contains the development and header files for ert.ecl - -%prep -%setup -q -n ert-release-%{version}-%{tag} - -%build -%{?el6:scl enable devtoolset-3 bash} -DESTDIR=${RPM_BUILD_ROOT} %{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 %{?el6:-DBUILD_PYTHON=0} %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gfortran} -make - -%install -make install DESTDIR=${RPM_BUILD_ROOT} - -%clean -rm -rf %{buildroot} - -%post -n libert.ecl1 -p /sbin/ldconfig - -%postun -n libert.ecl1 -p /sbin/ldconfig - -%files -%doc README - -%files -n libert.ecl1 -%defattr(-,root,root,-) -%{_libdir}/*.so.* -%{_bindir}/* - -%files devel -%defattr(-,root,root,-) -%{_libdir}/*.so -%{_includedir}/* - -%{?!el6: -%files -n python-ert.ecl -%defattr(-,root,root,-) -/usr/lib/python2.7/site-packages/ert/* - -%files -n python-cwrap -%defattr(-,root,root,-) -/usr/lib/python2.7/site-packages/cwrap/* -} diff --git a/ThirdParty/Ert/requirements.txt b/ThirdParty/Ert/requirements.txt index 4622ca5be8..4d44c49dca 100644 --- a/ThirdParty/Ert/requirements.txt +++ b/ThirdParty/Ert/requirements.txt @@ -1,2 +1,3 @@ cwrap numpy +pandas diff --git a/patches/fix-synthetic-odb-cases.patch b/patches/fix-synthetic-odb-cases.patch index 050a7e882d..cbdcc000d9 100644 --- a/patches/fix-synthetic-odb-cases.patch +++ b/patches/fix-synthetic-odb-cases.patch @@ -4,13 +4,13 @@ Date: Thu, 4 Jan 2018 20:29:09 +0100 Subject: [PATCH] #2317 Apply fix for synthetic odb files --- - ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 ++++++++-- + ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h index e8d9cef..2993b1e 100644 ---- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c -+++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +--- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h ++++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); From b03109873b01063016eb40662b72cf9006dc92af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 4 May 2018 14:23:37 +0200 Subject: [PATCH 0872/1027] Fix patch due to destination file relocation --- patches/fix-synthetic-odb-cases.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/fix-synthetic-odb-cases.patch b/patches/fix-synthetic-odb-cases.patch index cbdcc000d9..368fb05bd5 100644 --- a/patches/fix-synthetic-odb-cases.patch +++ b/patches/fix-synthetic-odb-cases.patch @@ -4,13 +4,13 @@ Date: Thu, 4 Jan 2018 20:29:09 +0100 Subject: [PATCH] #2317 Apply fix for synthetic odb files --- - ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h | 10 ++++++++-- + ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h +diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index e8d9cef..2993b1e 100644 ---- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h -+++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h +--- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp ++++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); From 7a7a8bed0edd799e0060c76b7f9be9e1e79b6465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 4 May 2018 14:24:13 +0200 Subject: [PATCH 0873/1027] Apply two ecllib patches after upgrade --- ThirdParty/Ert/CMakeLists.txt | 5 ++++- ThirdParty/Ert/lib/CMakeLists.txt | 3 ++- ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 6f1ab299fd..bddc356a17 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -364,6 +364,9 @@ if (ENABLE_PYTHON) endif() endif() -install(EXPORT ecl-config DESTINATION share/cmake/ecl) +if (INSTALL_ERT) + install(EXPORT ecl-config DESTINATION share/cmake/ecl) +endif() + export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index 5852d41847..6b6ef43667 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -193,7 +193,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) - +if (INSTALL_ERT) install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -218,6 +218,7 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () +endif() if (NOT BUILD_TESTS) return () diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index 49b797d1cc..56c3a87ac7 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + + if (doubhead_kw) + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -109,12 +112,15 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); + const ecl_kw_type * doubhead_kw = NULL; const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); + if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) + doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); + if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); From 085a3ea18a9ebdd028145c65b6b089cd5ac5dc72 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 May 2018 14:41:57 +0200 Subject: [PATCH 0874/1027] #2717 Compaction: Use OpenMP for calculation --- .../GeoMechDataModel/RigFemPartResultsCollection.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index cbd8a8cabb..3f8ddab481 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1470,7 +1470,17 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues frameCountProgress.incrementProgress(); compactionFrame.resize(nodeCount); - for (size_t n = 0; n < nodeCount; n++) + + // Make sure the AABB-tree is created before using OpenMP + { + cvf::BoundingBox bb; + std::vector refElementCandidates; + + part->findIntersectingCells(bb, &refElementCandidates); + } + +#pragma omp parallel for + for (long n = 0; n < nodeCount; n++) { RefElement refElement; findReferenceElementForNode(*part, n, resVarAddr.refKLayerIndex, &refElement); From 55796623b5cd564931629273546699bb8c17c42e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 May 2018 15:02:44 +0200 Subject: [PATCH 0875/1027] #2855 Tensor Calculations : Do nothing if tensor is unchecked --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 223d43c9cf..b848c785bb 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -383,11 +383,12 @@ void RimGeoMechView::updateLegends() m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->titledOverlayFrame()); } - updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); - - if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) + if (tensorResults()->showTensors()) { - if (tensorResults()->arrowColorLegendConfig()->showLegend()) + updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); + + if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && + tensorResults()->arrowColorLegendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->titledOverlayFrame()); } From 7421a3f7cd4660f533d3a664824bd0a604acd8d8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 May 2018 15:18:12 +0200 Subject: [PATCH 0876/1027] Fix signed / unsigned compare --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 3f8ddab481..868e812e9a 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1480,7 +1480,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues } #pragma omp parallel for - for (long n = 0; n < nodeCount; n++) + for (long n = 0; n < static_cast(nodeCount); n++) { RefElement refElement; findReferenceElementForNode(*part, n, resVarAddr.refKLayerIndex, &refElement); From 4108c72680e832d0528c045c61449e91c8de8924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 4 May 2018 17:21:06 +0200 Subject: [PATCH 0877/1027] Corrected spelling of ensemble --- .../Summary/RimEnsembleCurveSet.cpp | 2 +- .../Summary/RimSummaryCurveAutoName.cpp | 14 +++++++------- .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 3a147fa310..1849380075 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -127,7 +127,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); m_legendConfig = new RimRegularLegendConfig(); - CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensamble Curve Set"), "Curve Set Name", "", "", ""); + CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensemble Curve Set"), "Curve Set Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", ""); m_autoGeneratedName.registerGetMethod(this, &RimEnsembleCurveSet::createAutoName); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 9e7e6f6ad0..d257dc9fa3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -85,11 +85,11 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ QString caseName; { - RimEnsembleCurveSet* ensambleCurveSet = nullptr; - this->firstAncestorOrThisOfType(ensambleCurveSet); - if (ensambleCurveSet && ensambleCurveSet->summaryCaseCollection()) + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet && ensembleCurveSet->summaryCaseCollection()) { - caseName = ensambleCurveSet->summaryCaseCollection()->name(); + caseName = ensembleCurveSet->summaryCaseCollection()->name(); } } @@ -359,10 +359,10 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change } { - auto ensambleCurveSet = dynamic_cast(this->parentField()->ownerObject()); - if (ensambleCurveSet) + auto ensembleCurveSet = dynamic_cast(this->parentField()->ownerObject()); + if (ensembleCurveSet) { - ensambleCurveSet->updateConnectedEditors(); + ensembleCurveSet->updateConnectedEditors(); return; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index bf98095889..19aea2e178 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1460,7 +1460,7 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) std::vector addresses; std::vector sumCases; - std::vector ensambleCases; + std::vector ensembleCases; if (m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible()) { @@ -1489,14 +1489,14 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) if (curveSet->isCurvesVisible()) { addresses.push_back(curveSet->summaryAddress()); - ensambleCases.push_back(curveSet->summaryCaseCollection()); + ensembleCases.push_back(curveSet->summaryCaseCollection()); } } nameHelper->clear(); nameHelper->appendAddresses(addresses); nameHelper->appendSummaryCases(sumCases); - nameHelper->appendEnsembleCases(ensambleCases); + nameHelper->appendEnsembleCases(ensembleCases); return nameHelper->plotTitle(); } From 9885c9d2d744f5da3175169e80b409a9786c5388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Sun, 6 May 2018 10:07:49 +0200 Subject: [PATCH 0878/1027] #2809, #2858, #2859 Fix icon inconsistencies. Edd icons for ensemble curves and new icons for cross plot --- .../RicDuplicateSummaryCrossPlotFeature.cpp | 2 +- .../RicDuplicateSummaryPlotFeature.cpp | 2 +- .../RicEditSummaryCrossPlotFeature.cpp | 2 +- .../RicEditSummaryPlotFeature.cpp | 2 +- .../RicNewSummaryCrossPlotFeature.cpp | 2 +- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 2 +- .../RicNewSummaryPlotFeature.cpp | 2 +- .../WellLogCommands/RicNewPltPlotFeature.cpp | 2 +- .../WellLogCommands/RicNewRftPlotFeature.cpp | 2 +- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 2 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 2 +- .../RimContextCommandBuilder.cpp | 4 +- .../ProjectDataModel/RimPltPlotCollection.cpp | 2 +- .../Summary/RimEnsembleCurveSet.cpp | 2 +- .../Summary/RimEnsembleCurveSetCollection.cpp | 2 +- .../Summary/RimSummaryCrossPlot.cpp | 2 +- .../Summary/RimSummaryCrossPlotCollection.cpp | 2 +- .../Summary/RimSummaryPlotCollection.cpp | 2 +- .../Resources/EnsembleCurveSet16x16.png | Bin 0 -> 662 bytes .../Resources/EnsembleCurveSets16x16.png | Bin 0 -> 939 bytes ApplicationCode/Resources/ResInsight.qrc | 224 +++++++++--------- .../Resources/SummaryPlot16x16.png | Bin 505 -> 0 bytes .../Resources/SummaryPlotsLight16x16.png | Bin 0 -> 915 bytes .../Resources/SummaryXPlotLight16x16.png | Bin 0 -> 627 bytes .../Resources/SummaryXPlotsLight16x16.png | Bin 0 -> 685 bytes .../UserInterface/RiuViewerCommands.cpp | 4 +- 26 files changed, 135 insertions(+), 131 deletions(-) create mode 100644 ApplicationCode/Resources/EnsembleCurveSet16x16.png create mode 100644 ApplicationCode/Resources/EnsembleCurveSets16x16.png delete mode 100644 ApplicationCode/Resources/SummaryPlot16x16.png create mode 100644 ApplicationCode/Resources/SummaryPlotsLight16x16.png create mode 100644 ApplicationCode/Resources/SummaryXPlotLight16x16.png create mode 100644 ApplicationCode/Resources/SummaryXPlotsLight16x16.png diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp index 994f6176c3..20d6e46b10 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp @@ -70,6 +70,6 @@ void RicDuplicateSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicDuplicateSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Duplicate Summary Cross Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp index 0efdc162e0..747a698c86 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp @@ -70,6 +70,6 @@ void RicDuplicateSummaryPlotFeature::onActionTriggered(bool isChecked) void RicDuplicateSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Duplicate Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp index 4723240255..38c67c532c 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp @@ -108,7 +108,7 @@ void RicEditSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicEditSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Edit Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp index 0d795a4775..6b8c47a56b 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp @@ -110,7 +110,7 @@ void RicEditSummaryPlotFeature::onActionTriggered(bool isChecked) void RicEditSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Edit Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index 880c9afd1e..ccb09a87c2 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -77,6 +77,6 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicNewSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New Summary Cross Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 1ae97b29de..c62996f20e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -86,7 +86,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) void RicNewSummaryEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New Summary Ensemble Curve Set"); - actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); + actionToSetup->setIcon(QIcon(":/EnsembleCurveSet16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp index 0728f41cff..4c6848a513 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -86,6 +86,6 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index 8510149482..2e87c701c3 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -135,7 +135,7 @@ void RicNewPltPlotFeature::onActionTriggered(bool isChecked) void RicNewPltPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New PLT Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/WellFlowPlot16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index 3b964787eb..4d0b01efe4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -96,7 +96,7 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked) void RicNewRftPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New RFT Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/FlowCharPlot16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 9931c41fdf..55a1989977 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -101,7 +101,7 @@ const char RimWellPltPlot::PLOT_NAME_QFORMAT_STRING[] = "PLT: %1"; //-------------------------------------------------------------------------------------------------- RimWellPltPlot::RimWellPltPlot() { - CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", ""); + CAF_PDM_InitObject("Well Allocation Plot", ":/WellFlowPlot16x16.png", "", ""); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("PLT Plot"), "Name", "", "", ""); m_userName.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index adf38bec41..5b92ca35f6 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -70,7 +70,7 @@ const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1"; //-------------------------------------------------------------------------------------------------- RimWellRftPlot::RimWellRftPlot() { - CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", ""); + CAF_PDM_InitObject("Well Allocation Plot", ":/FlowCharPlot16x16.png", "", ""); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("RFT Plot"), "Name", "", "", ""); m_userName.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index bc69112829..500983847f 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -262,7 +262,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; menuBuilder << "RicShowWellAllocationPlotFeature"; @@ -537,7 +537,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewWellLogRftCurveFeature"; menuBuilder << "RicNewSimWellIntersectionFeature"; - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; menuBuilder << "Separator"; diff --git a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp index 3fe7cd5db9..044af69106 100644 --- a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimPltPlotCollection, "WellPltPlotCollection"); //-------------------------------------------------------------------------------------------------- RimPltPlotCollection::RimPltPlotCollection() { - CAF_PDM_InitObject("PLT Plots", ":/WellLogPlots16x16.png", "", ""); + CAF_PDM_InitObject("PLT Plots", ":/WellAllocPlots16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_pltPlots, "PltPlots", "", "", "", ""); m_pltPlots.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 1849380075..f86a69226f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -74,7 +74,7 @@ CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet"); //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSet::RimEnsembleCurveSet() { - CAF_PDM_InitObject("Ensemble Curve Set", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensemble Curve Set", ":/EnsembleCurveSet16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_curves, "EnsembleCurveSet", "Ensemble Curve Set", "", "", ""); m_curves.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 905e7b8b91..f3458f4d04 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -42,7 +42,7 @@ CAF_PDM_SOURCE_INIT(RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollectio //-------------------------------------------------------------------------------------------------- RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() { - CAF_PDM_InitObject("Ensemble Curve Sets", ":/SummaryCurveFilter16x16.png", "", ""); + CAF_PDM_InitObject("Ensemble Curve Sets", ":/EnsembleCurveSets16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets", "", "", ""); m_curveSets.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp index 3ace690695..d50732f8c6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp @@ -26,7 +26,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCrossPlot, "SummaryCrossPlot"); //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlot::RimSummaryCrossPlot() { - CAF_PDM_InitObject("Summary Cross Plot", ":/SummaryPlotLight16x16.png", "", ""); + CAF_PDM_InitObject("Summary Cross Plot", ":/SummaryXPlotLight16x16.png", "", ""); setAsCrossPlot(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 88d3116d25..f4810788b5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -29,7 +29,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCrossPlotCollection, "SummaryCrossPlotCollection") //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlotCollection::RimSummaryCrossPlotCollection() { - CAF_PDM_InitObject("Summary Cross Plots", ":/SummaryPlots16x16.png", "", ""); + CAF_PDM_InitObject("Summary Cross Plots", ":/SummaryXPlotsLight16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_summaryCrossPlots, "SummaryCrossPlots", "Summary Cross Plots", "", "", ""); m_summaryCrossPlots.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp index cf46c2c613..2f2f43204f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp @@ -28,7 +28,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryPlotCollection, "SummaryPlotCollection"); //-------------------------------------------------------------------------------------------------- RimSummaryPlotCollection::RimSummaryPlotCollection() { - CAF_PDM_InitObject("Summary Plots", ":/SummaryPlots16x16.png", "", ""); + CAF_PDM_InitObject("Summary Plots", ":/SummaryPlotsLight16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&summaryPlots, "SummaryPlots", "Summary Plots", "", "", ""); summaryPlots.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/Resources/EnsembleCurveSet16x16.png b/ApplicationCode/Resources/EnsembleCurveSet16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..d38c24308324c2b66de9723495ff8d49ceee8236 GIT binary patch literal 662 zcmV;H0%`q;P)WFU8GbZ8()Nlj2>E@cM*00H_*L_t(I%e9a_XcKW9 zhJXM2%GDm2CZ^DUh=WCket-rSrw-Lv$W{G%l5h89DTv~)yT#6Kzf{Sga(~*R@ z6s~Q=vmGKLSLks~PA+#zW77M`dHLVDNkP=6;Jd#M&-((LFrsJ#006{E%7udZ-Za}E z005|N%j@f91He~x{qSbj27*v&*tWN(s^)c;rPZzgJTFf=PKS;}n3taC?MPCy)D?i^ zsAT{sA>>cEZZHrIpYo6WK|U|1ZM##B#pwBsjc=SV`JxU&CY)O^iKnxmnVH69?~@VOi`M3f*|g59GO^L-1%%-9{klHmy;I|f)xOG z9Rzs1(ePd|4Dp~?)J2TFwN&cT*U12lIo2v8pIm?`WD?FPEDac6Sfho*pJl5V(eMM-jz)SAGF98A%`r z6ju~WQWX1QUtfsPb?=Acn3N>xA(my%R4Vls)6-YKPECz29koWO)M~J`rGa6zl%b*c wIhOUIR&$}ZmjaSR-;>F+%G}(IQTSi^2~)K1-u01%$p8QV07*qoM6N<$f?E$4yZ`_I literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/EnsembleCurveSets16x16.png b/ApplicationCode/Resources/EnsembleCurveSets16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..119a1bec374bade2d78ea420647760c2632a70bf GIT binary patch literal 939 zcmV;c162HpP)WFU8GbZ8()Nlj2>E@cM*00R$6L_t(I%UzORXj^q0 z#XtAv-u{fYf6{21Ub1$jgxaoZY3-^~h7TLX209QSY(gGwzs#Z0DRv^ z*LAkHx3KLfrfDLCz_Kg=q?7~#0gh^Gg#voBQekIvlUy!`Wd+&TXy7;wp68*I!t*>l z&!g399dZd2R#(CIq4fB%`XU}z#ZpO0DHX(3K3`I<>#BOauB4PoN~t{0JLG?^udD3M zo9c%TE-2j)0@JqnBcEp!2Y&J24;KyW=awfxDOG{LDU6w!ll9RKqAoMWh?qQ0J8rpt!{~HSM zQ!+`lSY#@dqPCsm(GHBp-^3ma^V=hbQlUvK*1q4u!MY9%9-KeVi__Ee^z~sH78yCp z%V&GBkF}G@IFw3FY+G>qc9v(m@_oKObqZ@_1pCa}MCa!DdAEa!8JkEX$elZR!eK$N zSf$bMiAFoo52|WZDttFL$3!Z{VB$T@{(io_zsu0j^OVaDAAhvU>n8>2^co{0f~!{_ z5(qT@%V2HsLt^iqBlyxVzho*nuFm9Sh>I6*F*x`t!^2^MqK)*eO?rC;moJYqJ|0Gs zt-saAr=QaiKgVC<1-@V2p-^x*aU#U^>sy3Ef~l!6rBa=0)hCe{;PmNU%H<~IauaRo zldn|j8;j-T9Sp-@etv*RM3Bw8jE;6PI~zp^&~=}g85 - - AppLogo48x48.png - Default.png - NorthViewArrow.png - SouthViewArrow.png - EastViewArrow.png - WestViewArrow.png - UpViewArrow.png - DownViewArrow.png - CellFilter_Values.png - CellFilter_Range.png - CellResult.png - EdgeResult_1.png - EdgeResult_2.png - Legend.png - Plus.png - Minus.png - Save.png - Well.png - WellCollection.png - octave.png - Folder.png - EclipseInput48x48.png - Cases16x16.png - CreateGridCaseGroup16x16.png - GridCaseGroup16x16.png - Histogram16x16.png - Histograms16x16.png - ZoomAll16x16.png - draw_style_lines_24x24.png - draw_style_meshlines_24x24.png - draw_style_meshoutlines_24x24.png - draw_style_outlines_24x24.png - draw_style_surface_24x24.png - disable_lighting_24x24.png - SnapShot.png - SnapShotSave.png - SnapShotSaveViews.png - draw_style_faults_24x24.png - draw_style_faults_label_24x24.png - Case48x48.png - GridModels.png - draw_style_WellCellsToRangeFilter_24x24.png - draw_style_surface_w_fault_mesh_24x24.png - InfoBox16x16.png - GeoMechCase48x48.png - GeoMechCases48x48.png - chain.png - TileWindows24x24.png - LasFile16x16.png - WellLogTrack16x16.png - WellLogPlot16x16.png - WellLogPlots16x16.png - WellLogCurve16x16.png - CrossSection16x16.png - CrossSections16x16.png - Refresh-32.png - SummaryPlot16x16.png - SummaryPlots16x16.png - SummaryCurve16x16.png - SummaryCurveFilter16x16.png - FormationCollection16x16.png - Formations16x16.png - Parallel24x24.png - Perspective24x24.png - IntersectionBox16x16.png - IntersectionXPlane16x16.png - IntersectionYPlane16x16.png - IntersectionZPlane16x16.png - PlotWindow24x24.png - 3DWindow24x24.png - 3DView16x16.png - SummaryCase48x48.png - openFolder24x24.png - clipboard.png - Copy.png - Erase.png - LeftAxis16x16.png - RightAxis16x16.png - BottomAxis16x16.png - Axes16x16.png - FishBones16x16.png - FishBoneGroup16x16.png - FishBoneGroupFromFile16x16.png - FishBoneLateralFromFile16x16.png - PerforationInterval16x16.png - PerforationIntervals16x16.png - CompletionsSymbol16x16.png - WellAllocPlots16x16.png - WellAllocPlot16x16.png - WellFlowPlot16x16.png - WellAllocPie16x16.png - WellAllocLegend16x16.png - SummaryPlotLight16x16.png - FractureLayout16x16.png - FractureSymbol16x16.png - FractureTemplate16x16.png - FractureTemplates16x16.png - TOFAccSatPlot16x16.png - FlowCharPlot16x16.png - SplitterH.png - SplitterV.png - calculator.png - statistics.png - - - fs_CellFace.glsl - vs_CellFace.glsl - vs_2dTextureCellFace.glsl - + + AppLogo48x48.png + Default.png + NorthViewArrow.png + SouthViewArrow.png + EastViewArrow.png + WestViewArrow.png + UpViewArrow.png + DownViewArrow.png + CellFilter_Values.png + CellFilter_Range.png + CellResult.png + EdgeResult_1.png + EdgeResult_2.png + Legend.png + Plus.png + Minus.png + Save.png + Well.png + WellCollection.png + octave.png + Folder.png + EclipseInput48x48.png + Cases16x16.png + CreateGridCaseGroup16x16.png + GridCaseGroup16x16.png + Histogram16x16.png + Histograms16x16.png + ZoomAll16x16.png + draw_style_lines_24x24.png + draw_style_meshlines_24x24.png + draw_style_meshoutlines_24x24.png + draw_style_outlines_24x24.png + draw_style_surface_24x24.png + disable_lighting_24x24.png + SnapShot.png + SnapShotSave.png + SnapShotSaveViews.png + draw_style_faults_24x24.png + draw_style_faults_label_24x24.png + Case48x48.png + GridModels.png + draw_style_WellCellsToRangeFilter_24x24.png + draw_style_surface_w_fault_mesh_24x24.png + InfoBox16x16.png + GeoMechCase48x48.png + GeoMechCases48x48.png + chain.png + TileWindows24x24.png + LasFile16x16.png + WellLogTrack16x16.png + WellLogPlot16x16.png + WellLogPlots16x16.png + WellLogCurve16x16.png + CrossSection16x16.png + CrossSections16x16.png + Refresh-32.png + SummaryPlotLight16x16.png + SummaryPlots16x16.png + SummaryPlotsLight16x16.png + SummaryCurve16x16.png + SummaryCurveFilter16x16.png + EnsembleCurveSet16x16.png + EnsembleCurveSets16x16.png + SummaryXPlotLight16x16.png + SummaryXPlotsLight16x16.png + FormationCollection16x16.png + Formations16x16.png + Parallel24x24.png + Perspective24x24.png + IntersectionBox16x16.png + IntersectionXPlane16x16.png + IntersectionYPlane16x16.png + IntersectionZPlane16x16.png + PlotWindow24x24.png + 3DWindow24x24.png + 3DView16x16.png + SummaryCase48x48.png + openFolder24x24.png + clipboard.png + Copy.png + Erase.png + LeftAxis16x16.png + RightAxis16x16.png + BottomAxis16x16.png + Axes16x16.png + FishBones16x16.png + FishBoneGroup16x16.png + FishBoneGroupFromFile16x16.png + FishBoneLateralFromFile16x16.png + PerforationInterval16x16.png + PerforationIntervals16x16.png + CompletionsSymbol16x16.png + WellAllocPlots16x16.png + WellAllocPlot16x16.png + WellFlowPlot16x16.png + WellAllocPie16x16.png + WellAllocLegend16x16.png + FractureLayout16x16.png + FractureSymbol16x16.png + FractureTemplate16x16.png + FractureTemplates16x16.png + TOFAccSatPlot16x16.png + FlowCharPlot16x16.png + SplitterH.png + SplitterV.png + calculator.png + statistics.png + + + fs_CellFace.glsl + vs_CellFace.glsl + vs_2dTextureCellFace.glsl + diff --git a/ApplicationCode/Resources/SummaryPlot16x16.png b/ApplicationCode/Resources/SummaryPlot16x16.png deleted file mode 100644 index 488bdcd47f21ec2901c2f067c4cab4b556a664aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 505 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNndjlS@mNCm z8OaAn6((t}|FO5~oN*pQ%VkxinMS_1BQ;Mgdz2Df$S`Z0vr4eq?5@kJpNom>xn-2> z67rj_GDpvI@#WZsR_Av<-Yma_YmLe;SMN6w9=}|(SF^D#xbvC+w(dE(`I6hBZ-0Am zfMH6w+s~SLvftH@7Y8@gG7Buda!lRs&9_A_pZ?1F8NyJvjOoMACl6xc7zBJ&7%ld0 zuJoA8Y*1C7d?QcLM`gPEZRQo79XB>k;8`W=zme_gsi-vaF6*2UngA<-%_sl> diff --git a/ApplicationCode/Resources/SummaryPlotsLight16x16.png b/ApplicationCode/Resources/SummaryPlotsLight16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..3042602dc6e4ef572d1318c00c1b55e5608b9d31 GIT binary patch literal 915 zcmV;E18n?>P)WFU8GbZ8()Nlj2>E@cM*00Q?(L_t(I%dL-5NLzOl z#(($ktzK_pR#UYWY_2nGL>HuxU_qv((pg*?V=L^T(yiN|Pkrj!9@jk%24j2Kiye$H zT8weH7`39qB{sPRZK^cW&WtvoGDt}h-5pg`ZH8fNxm+$+JRV>8?2}8WcVF*&Jb8OHCzXwsWl2Eo+}zyD z)z#JGUa!|tK0O%;keHsNFcwBV{npOJgF?St4w#*tb$UFWqb)5hZMv>kH8wUPgupaS zNtR`)SS+$L7Gf(pgL14JaqzI1xcY@A{RjDZJt0@W{U%@D4vf zUw=y8+}uP_6!Q5zjzs(^S?lPe7`(!9tsnW=y~A=W7PBde@~zM3+y5-k>2&_JghwbO zbecZ=fXl^Ewr9@ZwV%bzw6nPQ>F+{S)ry6M1^HiVhevo23{ZLMBvwZ!>ECi_6}=R< z8yFnK+S{wDkO6!?U+Ev_AEzjc1$lV#5TVu(@-HK}tBzykULq1H;C5pzEfx2KrfDoM zFF)U4YLaYVfUmXh2)4~2D)-U-;(4r6Bcr3x+$_=82le&!stn-w`%BM~zYo7hrlSH| z_i5hIKBA6SNT=cY^&wm?J3_3Ox}Mp|WHJRAAdyJOZnqnzCJ2V!r_j^FYkeQ1i5>vv z=V5#tnwkV%U6wg8pkEmp8v4oUbY^9svc0XfL@dJ0_(k&m1Dri|6~Q4&CD3&UhvCQ( zi#vB#%^Nq;MMY8Kxm+%k%jMSOR4PS&XWFU8GbZ8()Nlj2>E@cM*00GxYL_t(I%bk8NuUY5qgt)XK7?Hx#v?5V0+dq3ar{pMq`NkZOkEaEuE4eBg>zJ(EP_xotO0+08Hm+dDFPZn)jAShszV!6Ge?EiuxUB7y#tW0#^(7dG>LJ z+QtjU$8uad_kg3RJi4wY3TOaIsa^MdzIu~rOyl6T!Ije`jv1%+en!V}c0N4}<<*yx zxPD#kR?o|a))NsCS@&u(zceWg-;prfH5T8oZCl#ywup$heqA0eUXuoN~JPX z6~`TPJ>8$ibb7}x7K`bWh&%=|fC)?h2Y^GsuYoo0@dw!Ku5}3Le*qCaqYmBk_&)#u N002ovPDHLkV1j#^2txn> literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/SummaryXPlotsLight16x16.png b/ApplicationCode/Resources/SummaryXPlotsLight16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..344a7a74840c99ea41bce9a906bcb9fa1695b8a7 GIT binary patch literal 685 zcmV;e0#f~nP)WFU8GbZ8()Nlj2>E@cM*00I$7L_t(I%dL}7NYh~$ z$3O2+YYmA7BbF%43Y(244MG;)q)vnCutU%#yn0F2p>^}pMXXMCs6!DEskjJFvp+<| z!W`wV`EQ3{SX$1Ea5ks=y-$bSKdkJ~7hZUu=Y{X*d7k%u6@ORjHs@wlBqB}`X^6#Q zb5fQTk%EX=QY{U%)>axQrM?10qtSwC{xV->LDf-TQ&m=Lsjx$TBx}*4wI!CW25YS) zI)6z-)-({Rtt9vM_8Kmit4OAf`YlcSd_H2sFFDg?D<`|VyBGh3eC=_kXvxXo;9zkE zAp^kg_veacS>{m6z);2(di=>-5F4;j${7HOM8Ymuyjbq1XY3e{K3xO^uo%zY=ix#G zRGv2HIRHlHuK;-fY605Y+jBYVJ2l1*PVJ8{`r$h16_XWfiOl)}K1atUxc~}|I8Oq$ zas{So+A$0YdJX^H)2v%rZYD=T=ucHT_;{-FAr@%TWXm$ipYL|q=;j12x=WMBkcsy Date: Mon, 7 May 2018 09:44:38 +0200 Subject: [PATCH 0879/1027] #2818 Selection manager. Add strict method variant --- .../cafPdmUiCore/cafSelectionManager.h | 16 ++++++++++++++++ .../cafPdmUiCore/cafSelectionManagerTools.h | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index 09adab873b..ca090c019e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -103,6 +103,22 @@ class SelectionManager } } + template + void objectsByTypeStrict(std::vector* typedObjects, int role = SelectionManager::APPLICATION_GLOBAL) + { + std::vector items; + this->selectedItems(items, role); + for (size_t i = 0; i < items.size(); i++) + { + T* obj = dynamic_cast(items[i]); + if (!obj) + { + typedObjects->clear(); + break; + } + typedObjects->push_back(obj); + } + } private: SelectionManager(); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h index f7bf694d6b..a521236751 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h @@ -75,4 +75,17 @@ std::vector selectedObjectsByType() return objectByType; } +//-------------------------------------------------------------------------------------------------- +/// Return all objects of given type from the selection manager. +/// If objects of different type are selected, an empty list is returned. +//-------------------------------------------------------------------------------------------------- +template +std::vector selectedObjectsByTypeStrict() +{ + std::vector objectByType; + caf::SelectionManager::instance()->objectsByTypeStrict(&objectByType); + + return objectByType; +} + } // end namespace caf From 7903a62cc5f87aff4936d03d97ae05131acf9de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 09:45:50 +0200 Subject: [PATCH 0880/1027] #2818 Summary. Add new-plot-commands to context menus --- .../RicNewSummaryCrossPlotFeature.cpp | 23 ++++++++++++++++ .../RicNewSummaryPlotFeature.cpp | 27 ++++++++++++++++--- .../RicSummaryCurveCreator.cpp | 8 +++--- .../RicSummaryCurveCreator.h | 5 ++-- .../RicSummaryCurveCreatorDialog.cpp | 9 +++++++ .../RicSummaryCurveCreatorDialog.h | 2 ++ .../RicSummaryCurveCreatorSplitterUi.cpp | 8 ++++++ .../RicSummaryCurveCreatorSplitterUi.h | 2 ++ .../RimContextCommandBuilder.cpp | 13 +++++++-- .../RiuSummaryCurveDefSelection.cpp | 20 +++++++------- .../RiuSummaryCurveDefSelection.h | 2 +- 11 files changed, 96 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index ccb09a87c2..55803c2e12 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaSummaryTools.h" #include "RicEditSummaryPlotFeature.h" #include "RicSummaryCurveCreator.h" @@ -30,9 +31,13 @@ #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RiuPlotMainWindowTools.h" +#include "cafSelectionManagerTools.h" + #include "cvfAssert.h" #include @@ -45,6 +50,24 @@ CAF_CMD_SOURCE_INIT(RicNewSummaryCrossPlotFeature, "RicNewSummaryCrossPlotFeatur //-------------------------------------------------------------------------------------------------- bool RicNewSummaryCrossPlotFeature::isCommandEnabled() { + RimSummaryCrossPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentCrossPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + // Multiple case selections + std::vector selectedItems = caf::selectedObjectsByTypeStrict(); + + for (auto item : selectedItems) + { + if (!dynamic_cast(item) && !dynamic_cast(item)) + return false; + } return true; } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp index 4c6848a513..6a95c1067e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -29,11 +29,14 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RiuPlotMainWindow.h" #include "cvfAssert.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" +//#include "cafPdmUiItem.h" #include @@ -55,7 +58,15 @@ bool RicNewSummaryPlotFeature::isCommandEnabled() if (sumPlotColl) return true; - return false; + // Multiple case selections + std::vector selectedItems = caf::selectedObjectsByTypeStrict(); + + for (auto item : selectedItems) + { + if (!dynamic_cast(item) && !dynamic_cast(item)) + return false; + } + return true; } //-------------------------------------------------------------------------------------------------- @@ -66,6 +77,16 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); + std::vector selectedCases = caf::selectedObjectsByType(); + std::vector selectedGroups = caf::selectedObjectsByType(); + + // Append grouped cases + for (auto group : selectedGroups) + { + auto groupCases = group->allSummaryCases(); + selectedCases.insert(selectedCases.end(), groupCases.begin(), groupCases.end()); + } + auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog(); if (!dialog->isVisible()) @@ -77,7 +98,7 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) dialog->raise(); } - dialog->updateFromSummaryPlot(nullptr); + dialog->updateFromDefaultCases(selectedCases); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index c4a0ace6bf..39f63962f1 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -129,7 +129,7 @@ RimSummaryPlot* RicSummaryCurveCreator::previewPlot() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot) +void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, const std::vector& defaultCases) { if (targetPlot == nullptr || m_targetPlot != targetPlot) { @@ -145,7 +145,7 @@ void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot) } else { - setDefaultCurveSelection(); + setDefaultCurveSelection(defaultCases); m_previewPlot->enableAutoPlotTitle(true); } @@ -616,9 +616,9 @@ void RicSummaryCurveCreator::copyEnsembleCurveAndAddToPlot(const RimSummaryCurve //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::setDefaultCurveSelection() +void RicSummaryCurveCreator::setDefaultCurveSelection(const std::vector& defaultCases) { - m_summaryCurveSelectionEditor->summaryAddressSelection()->setDefaultSelection(); + m_summaryCurveSelectionEditor->summaryAddressSelection()->setDefaultSelection(defaultCases); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index c12ef90a2d..096ff70f2d 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -59,7 +59,8 @@ class RicSummaryCurveCreator : public caf::PdmObject virtual ~RicSummaryCurveCreator(); RimSummaryPlot* previewPlot() const; - void updateFromSummaryPlot(RimSummaryPlot* targetPlot); + void updateFromSummaryPlot(RimSummaryPlot* targetPlot, + const std::vector& defaultCases = std::vector()); QWidget* addressSelectionWidget(QWidget* parent); @@ -87,7 +88,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void updateTargetPlot(); static void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false); static void copyEnsembleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible = false); - void setDefaultCurveSelection(); + void setDefaultCurveSelection(const std::vector& defaultCases); void resetAllFields(); void initCurveAppearanceCalculator(RimSummaryCurveAppearanceCalculator& curveAppearanceCalc); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp index 52ad89ddc3..4ccfd05e8f 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp @@ -65,6 +65,15 @@ void RicSummaryCurveCreatorDialog::updateFromSummaryPlot(RimSummaryPlot* summary m_curveCreatorSplitterUi->updateUi(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreatorDialog::updateFromDefaultCases(const std::vector defaultCases) +{ + m_curveCreatorSplitterUi->updateFromDefaultCases(defaultCases); + m_curveCreatorSplitterUi->updateUi(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h index 75097a328f..7ffb7194f0 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h @@ -22,6 +22,7 @@ class RicSummaryCurveCreatorSplitterUi; class RimSummaryPlot; +class RimSummaryCase; //================================================================================================== /// @@ -35,6 +36,7 @@ class RicSummaryCurveCreatorDialog : public QDialog ~RicSummaryCurveCreatorDialog(); void updateFromSummaryPlot(RimSummaryPlot* summaryPlot); + void updateFromDefaultCases(const std::vector defaultCases); private slots: void slotDialogFinished(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp index a9974dd82b..84401ca1e0 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp @@ -66,6 +66,14 @@ void RicSummaryCurveCreatorSplitterUi::updateFromSummaryPlot(RimSummaryPlot* sum m_summaryCurveCreator->updateFromSummaryPlot(summaryPlot); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreatorSplitterUi::updateFromDefaultCases(const std::vector defaultCases) +{ + m_summaryCurveCreator->updateFromSummaryPlot(nullptr, defaultCases); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h index cca921ccbf..b7872fbbc2 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h @@ -24,6 +24,7 @@ #include class RimSummaryPlot; +class RimSummaryCase; class RicSummaryCurveCreator; class QMinimizePanel; @@ -52,6 +53,7 @@ class RicSummaryCurveCreatorSplitterUi : public caf::PdmUiWidgetBasedObjectEdito ~RicSummaryCurveCreatorSplitterUi(); void updateFromSummaryPlot(RimSummaryPlot* summaryPlot); + void updateFromDefaultCases(const std::vector defaultCases); private: virtual void recursivelyConfigureAndUpdateTopLevelUiItems(const std::vector& topLevelUiItems, diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 500983847f..2ada56675b 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -485,17 +485,23 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; menuBuilder << "RicImportEnsembleFeature"; + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; + menuBuilder.addSeparator(); } else if (dynamic_cast(uiItem)) { menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; menuBuilder << "RicImportEnsembleFeature"; + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; + menuBuilder.addSeparator(); if (!dynamic_cast(uiItem)) { menuBuilder << "RicShowSummaryCurveCalculatorFeature"; - menuBuilder << "RicNewSummaryPlotFeature"; + //menuBuilder << "RicNewSummaryPlotFeature"; } } else if (dynamic_cast(uiItem)) @@ -652,8 +658,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicShowTotalAllocationDataFeature"; + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder << "RicSummaryCurveSwitchAxisFeature"; - + menuBuilder.addSeparator(); + if (!menuBuilder.isCmdFeatureAdded("RicNewFishbonesSubsFeature")) { menuBuilder << "RicNewFishbonesSubsFeature"; diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 363864bd72..07695e097e 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -296,7 +296,7 @@ void RiuSummaryCurveDefSelection::setFieldChangedHandler(const std::function& defaultCases) { RimProject* proj = RiaApplication::instance()->project(); auto allSumCases = proj->allSummaryCases(); @@ -304,17 +304,15 @@ void RiuSummaryCurveDefSelection::setDefaultSelection() { RifEclipseSummaryAddress defaultAddress = RifEclipseSummaryAddress::fieldVarAddress("FOPT"); - RiaSummaryCurveDefinition curveDef(allSumCases[0], defaultAddress); - std::vector curveDefs; - curveDefs.push_back(curveDef); - - // DEBUG - //{ - // RifEclipseSummaryAddress defaultAddress = RifEclipseSummaryAddress::fieldVarAddress("FOPTH"); + std::vector selectTheseCases = defaultCases; + if (selectTheseCases.empty()) selectTheseCases.push_back(allSumCases[0]); - // RiaSummaryCurveDefinition curveDef(allSumCases[0], defaultAddress); - // curveDefs.push_back(curveDef); - //} + std::vector curveDefs; + for(RimSummaryCase* c : selectTheseCases) + { + RiaSummaryCurveDefinition curveDef(c, defaultAddress); + curveDefs.push_back(curveDef); + } setSelectedCurveDefinitions(curveDefs); } diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index 4cdda0670b..46eb4118ed 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -55,7 +55,7 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject void setMultiSelectionMode(bool multiSelectionMode); void setFieldChangedHandler(const std::function& handlerFunc); - void setDefaultSelection(); + void setDefaultSelection(const std::vector& defaultCases); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, From fba437f59543c41dae2e9990909535f48a2ceb85 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 3 May 2018 14:48:06 +0200 Subject: [PATCH 0881/1027] #2791 Rename misspelled "principalNumber" in TensorResultPartMgr --- ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 3c70fa5515..3b3d4cd2d5 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -420,7 +420,7 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalTextureCoords(cvf::Vec2fA { for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) { - cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.princialNumber); + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.principalNumber); textureCoords->add(texCoord); } } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h index 55df996634..7418de6441 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -61,14 +61,14 @@ class RivTensorResultPartMgr : public cvf::Object , result(result) , faceNormal(faceNormal) , isPressure(isPressure) - , princialNumber(princial) + , principalNumber(princial) , principalValue(principalValue) {}; cvf::Vec3f vertex; cvf::Vec3f result; cvf::Vec3f faceNormal; bool isPressure; - int princialNumber; + int principalNumber; float principalValue; }; From 78326bb19c17e147b357485d4d53eaca3d591bd5 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 4 May 2018 13:20:49 +0200 Subject: [PATCH 0882/1027] #2703 An initial implementation of filled drawing style with problems remaining. * New vertices are successfully created in the intersections between the curve and draw surface triangles * New vertices are also inserted along the bottom edge of the filled curve. * However, new vertices will still need to be inserted in the lines connecting the top of the curve and the bottom where they intersect with the triangles. * The option for filled curves remain hidden in the GUI. See #2860. # Please enter the commit message for your changes. Lines starting --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 286 +++++++++++++----- .../Riv3dWellLogCurveGeometryGenerator.h | 26 +- .../Riv3dWellLogDrawSurfaceGenerator.cpp | 4 +- .../Riv3dWellLogPlanePartMgr.cpp | 50 ++- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 21 +- .../ProjectDataModel/Rim3dWellLogCurve.h | 16 +- 6 files changed, 294 insertions(+), 109 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 5acd335c6a..584040615c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -135,11 +135,9 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display return; } - m_curveVertices = std::vector(); - m_curveVertices.reserve(interpolatedWellPathPoints.size()); - double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); + m_curveVertices.reserve(interpolatedWellPathPoints.size()); for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++) { double scaledResult = 0; @@ -151,29 +149,67 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint)); } + m_curveVertices = projectVerticesOntoTriangles(m_curveVertices, drawSurfaceVertices); + + m_bottomVertices.reserve(m_curveVertices.size() + 2); + for (size_t i = 0; i < m_curveVertices.size(); ++i) + { + double md = m_curveMeasuredDepths[i]; + cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); + cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, md); + point += planeOffsetFromWellPathCenter * normal; + m_bottomVertices.push_back(cvf::Vec3f(point)); + } + m_bottomVertices = projectVerticesOntoTriangles(m_bottomVertices, drawSurfaceVertices); - projectVerticesOntoTriangles(drawSurfaceVertices); createNewVerticesAlongTriangleEdges(drawSurfaceVertices); - - std::vector indices; - indices.reserve(m_curveVertices.size() * 2); - for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) { - indices.push_back(cvf::uint(i)); - indices.push_back(cvf::uint(i + 1)); + std::vector indices; + indices.reserve(m_curveVertices.size() * 2); + for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) + { + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); + } + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + m_curveDrawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + m_curveDrawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices); + m_curveDrawable->setVertexArray(vertexArray.p()); } - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); - cvf::ref indexArray = new cvf::UIntArray(indices); + { + CVF_ASSERT(m_bottomVertices.size() == m_curveVertices.size()); + cvf::ref vertexArray = new cvf::Vec3fArray(m_bottomVertices.size() + m_curveVertices.size()); + for (size_t i = 0; i < m_bottomVertices.size(); ++i) + { + (*vertexArray)[2 * i] = m_bottomVertices[i]; + (*vertexArray)[2 * i + 1] = m_curveVertices[i]; + } + + std::vector indices; + indices.reserve(vertexArray->size()); + for (size_t i = 0; i < vertexArray->size(); ++i) + { + indices.push_back(cvf::uint(i)); + } - m_curveDrawable = new cvf::DrawableGeo(); + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); + cvf::ref indexArray = new cvf::UIntArray(indices); - indexedUInt->setIndices(indexArray.p()); - m_curveDrawable->addPrimitiveSet(indexedUInt.p()); + m_curveFilledDrawable = new cvf::DrawableGeo(); + indexedUInt->setIndices(indexArray.p()); + m_curveFilledDrawable->addPrimitiveSet(indexedUInt.p()); + m_curveFilledDrawable->setVertexArray(vertexArray.p()); + } - cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices); - m_curveDrawable->setVertexArray(vertexArray.p()); } //-------------------------------------------------------------------------------------------------- @@ -182,7 +218,9 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display void Riv3dWellLogCurveGeometryGenerator::clearCurvePointsAndGeometry() { m_curveDrawable = nullptr; + m_curveFilledDrawable = nullptr; m_curveVertices.clear(); + m_bottomVertices.clear(); m_curveMeasuredDepths.clear(); m_curveValues.clear(); } @@ -195,6 +233,14 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::curveDrawable() return m_curveDrawable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogCurveGeometryGenerator::curveFilledDrawable() +{ + return m_curveFilledDrawable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -255,64 +301,58 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) { std::vector expandedCurveVertices; - std::vector expandedMeasuredDepths; - std::vector expandedValues; - size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); + std::vector expandedBottomVertices; + std::vector expandedMeasuredDepths; + std::vector expandedValues; + size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); expandedCurveVertices.reserve(estimatedNumberOfPoints); + expandedBottomVertices.reserve(estimatedNumberOfPoints); expandedMeasuredDepths.reserve(estimatedNumberOfPoints); expandedValues.reserve(estimatedNumberOfPoints); + for (size_t i = 0; i < m_curveVertices.size() - 1; i += 2) { if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) { - caf::Line fullSegmentLine(m_curveVertices[i], m_curveVertices[i + 1]); - cvf::Vec3f fullSegmentVector = fullSegmentLine.vector(); - cvf::Vec3f lastVertex = m_curveVertices[i]; - expandedCurveVertices.push_back(lastVertex); - expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); - expandedValues.push_back(m_curveValues[i]); - // Find segments that intersects the triangle edges - for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) + cvf::Vec3f lastVertex = m_curveVertices[i]; + cvf::Vec3f fullSegmentVector = m_curveVertices[i + 1] - m_curveVertices[i]; + + std::vector extraVertices; + std::vector extraBottomVertices; + + createNewVerticesAlongSegment(m_curveVertices[i], + m_curveVertices[i + 1], + drawSurfaceVertices, + &extraVertices, + &m_bottomVertices[i], + &m_bottomVertices[i + 1], + &extraBottomVertices); + + CVF_ASSERT(extraVertices.size() == extraBottomVertices.size()); + + for (const cvf::Vec3f& extraVertex : extraVertices) { - cvf::Vec3f currentSubSegment = m_curveVertices[i + 1] - lastVertex; - caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); - caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); - cvf::Vec3f triangleNormal = (triangleEdge1.vector().getNormalized() ^ triangleEdge2.vector().getNormalized()).getNormalized(); - cvf::Vec3f projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; - caf::Line projectedCurveLine (lastVertex, lastVertex + projectedSegmentVector); - - // Only attempt to find intersections with the first edge. The other edge is handled with the next triangle. - bool withinSegments = false; - caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); - if (withinSegments) - { - cvf::Vec3f newVertex = connectingLine.end(); - - cvf::Vec3f newSegmentVector = newVertex - lastVertex; - if (newSegmentVector.lengthSquared() < fullSegmentVector.lengthSquared()) - { - expandedCurveVertices.push_back(newVertex); - // Scalar projection (a * b / |b|) divided by full segment length to become (a * b / |b|^2) - float dotProduct = newSegmentVector * fullSegmentVector; - float fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); - float measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; - float valueAtPoint = m_curveValues[i] * (1 - fractionAlongFullSegment) + m_curveValues[i + 1] * fractionAlongFullSegment; - expandedMeasuredDepths.push_back(measuredDepth); - expandedValues.push_back(valueAtPoint); - lastVertex = newVertex; - } - } + cvf::Vec3f newSegmentVector = extraVertex - lastVertex; + // Scalar projection (a * b / |b|) divided by full segment length to become (a * b / |b|^2) + float dotProduct = newSegmentVector * fullSegmentVector; + float fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); + float measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + + m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; + float valueAtPoint = + m_curveValues[i] * (1 - fractionAlongFullSegment) + m_curveValues[i + 1] * fractionAlongFullSegment; + expandedCurveVertices.push_back(extraVertex); + expandedMeasuredDepths.push_back(measuredDepth); + expandedValues.push_back(valueAtPoint); + lastVertex = extraVertex; } - - // Next original segment point - expandedCurveVertices.push_back(m_curveVertices[i + 1]); - expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i + 1]); - expandedValues.push_back(m_curveValues[i + 1]); + expandedBottomVertices.insert(expandedBottomVertices.end(), extraBottomVertices.begin(), extraBottomVertices.end()); } } + CVF_ASSERT(expandedCurveVertices.size() == expandedBottomVertices.size()); m_curveVertices.swap(expandedCurveVertices); + m_bottomVertices.swap(expandedBottomVertices); m_curveMeasuredDepths.swap(expandedMeasuredDepths); m_curveValues.swap(expandedValues); } @@ -320,9 +360,85 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& drawSurfaceVertices) +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf::Vec3f& ptStart, + const cvf::Vec3f& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices, + const cvf::Vec3f* ptBottomStart, + const cvf::Vec3f* ptBottomEnd, + std::vector* extraBottomVertices) { - for (size_t i = 0; i < m_curveVertices.size(); ++i) + cvf::Vec3f fullSegmentVector = ptEnd - ptStart; + extraVertices->push_back(ptStart); + + cvf::Vec3f fullBottomVector; + if (ptBottomStart && ptBottomEnd && extraBottomVertices) + { + fullBottomVector = *ptBottomEnd - *ptBottomStart; + extraBottomVertices->push_back(*ptBottomStart); + } + + // Find segments that intersects the triangle edges + for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) + { + caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); + caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); + cvf::Vec3f triangleNormal = + (triangleEdge1.vector().getNormalized() ^ triangleEdge2.vector().getNormalized()).getNormalized(); + + cvf::Vec3f currentSubSegment = ptEnd - extraVertices->back(); + cvf::Vec3f projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; + caf::Line projectedCurveLine(extraVertices->back(), extraVertices->back() + projectedSegmentVector); + + // Only attempt to find intersections with the first edge. The other edge is handled with the next triangle. + bool withinSegments = false; + caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); + + cvf::Vec3f newVertex = connectingLine.end(); + cvf::Vec3f newSegmentVector = newVertex - extraVertices->back(); + if (withinSegments && newSegmentVector.lengthSquared() < fullSegmentVector.lengthSquared()) + { + extraVertices->push_back(newVertex); + + if (ptBottomStart && ptBottomEnd && extraBottomVertices) + { + // Do the same for the bottom line, however we need to ensure we add the same amount of points. + cvf::Vec3f currentBottomSegment = *ptBottomEnd - extraBottomVertices->back(); + cvf::Vec3f projectedBottomVector = + currentBottomSegment - (currentBottomSegment * triangleNormal) * triangleNormal; + caf::Line projectedBottomLine(extraBottomVertices->back(), + extraBottomVertices->back() + projectedBottomVector); + bool withinBottomSegments = false; + + caf::Line bottomConnectingLine = + projectedBottomLine.findLineBetweenNearestPoints(triangleEdge1, &withinBottomSegments); + cvf::Vec3f newBottomVertex = bottomConnectingLine.end(); + cvf::Vec3f newBottomVector = newBottomVertex - extraBottomVertices->back(); + if (!(withinBottomSegments && newBottomVector.lengthSquared() < fullBottomVector.lengthSquared())) + { + newBottomVertex = extraBottomVertices->back(); + } + extraBottomVertices->push_back(newBottomVertex); + } + } + } + extraVertices->push_back(ptEnd); + if (ptBottomStart && ptBottomEnd && extraBottomVertices) + { + extraBottomVertices->push_back(*ptBottomEnd); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& originalVertices, + const std::vector& drawSurfaceVertices) +{ + std::vector projectedVertices; + projectedVertices.reserve(originalVertices.size()); + for (size_t i = 0; i < originalVertices.size(); ++i) { // Sort projections onto triangle by the distance of the projection. std::map projectionsInsideTriangle; @@ -342,22 +458,27 @@ void Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std: triangleVertex3 = drawSurfaceVertices[j + 1]; } - bool wasInsideTriangle = false; - cvf::Vec3f projectedPoint = projectPointOntoTriangle( - m_curveVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); + bool wasInsideTriangle = false; + cvf::Vec3f projectedPoint = projectPointOntoTriangle( + originalVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); if (wasInsideTriangle) { - projectionsInsideTriangle.insert(std::make_pair((projectedPoint - m_curveVertices[i]).lengthSquared(), - projectedPoint)); + projectionsInsideTriangle.insert( + std::make_pair((projectedPoint - originalVertices[i]).lengthSquared(), projectedPoint)); } } - + // Take the closest projection if (!projectionsInsideTriangle.empty()) { - m_curveVertices[i] = projectionsInsideTriangle.begin()->second; + projectedVertices.push_back(projectionsInsideTriangle.begin()->second); + } + else + { + projectedVertices.push_back(originalVertices[i]); } } + return projectedVertices; } //-------------------------------------------------------------------------------------------------- @@ -370,32 +491,31 @@ cvf::Vec3f Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cv bool* wasInsideTriangle) { *wasInsideTriangle = false; - cvf::Vec3f e1 = triangleVertex2 - triangleVertex1; - cvf::Vec3f e2 = triangleVertex3 - triangleVertex1; - cvf::Vec3f n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); + cvf::Vec3f e1 = triangleVertex2 - triangleVertex1; + cvf::Vec3f e2 = triangleVertex3 - triangleVertex1; + cvf::Vec3f n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); // Project vertex onto triangle plane - cvf::Vec3f av = point - triangleVertex1; - cvf::Vec3f projectedAv = av - (av * n) * n; + cvf::Vec3f av = point - triangleVertex1; + cvf::Vec3f projectedAv = av - (av * n) * n; cvf::Vec3f projectedPoint = projectedAv + triangleVertex1; - + // Calculate barycentric coordinates float areaABC = n * (e1 ^ e2); float areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); float areaPCA = n * ((triangleVertex3 - projectedPoint) ^ (triangleVertex1 - projectedPoint)); - float u = areaPBC / areaABC; - float v = areaPCA / areaABC; - float w = 1.0 - u - v; + float u = areaPBC / areaABC; + float v = areaPCA / areaABC; + float w = 1.0 - u - v; if (u >= -1.0e-6 && v >= -1.0e-6 && w >= -1.0e-6) { *wasInsideTriangle = true; // Clamp to ensure it is inside the triangle - u = cvf::Math::clamp(u, 0.0f, 1.0f); - v = cvf::Math::clamp(v, 0.0f, 1.0f); - w = cvf::Math::clamp(w, 0.0f, 1.0f); + u = cvf::Math::clamp(u, 0.0f, 1.0f); + v = cvf::Math::clamp(v, 0.0f, 1.0f); + w = cvf::Math::clamp(w, 0.0f, 1.0f); projectedPoint = triangleVertex1 * u + triangleVertex2 * v + triangleVertex3 * w; - } return projectedPoint; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h index a9fecac7a4..a4a72a181f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h @@ -59,6 +59,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const RigWellPath* wellPathGeometry() const; cvf::ref curveDrawable(); + cvf::ref curveFilledDrawable(); bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, @@ -66,18 +67,29 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double* valueAtClosestPoint) const; private: - void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); - void projectVerticesOntoTriangles(const std::vector& drawSurfaceVertices); - static cvf::Vec3f projectPointOntoTriangle(const cvf::Vec3f& point, - const cvf::Vec3f& triangleVertex1, - const cvf::Vec3f& triangleVertex2, - const cvf::Vec3f& triangleVertex3, - bool* wasInsideTriangle); + void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); + static void createNewVerticesAlongSegment(const cvf::Vec3f& ptStart, + const cvf::Vec3f& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices, + const cvf::Vec3f* ptBottomStart = nullptr, + const cvf::Vec3f* ptBottomEnd = nullptr, + std::vector* extraBottomVertices = nullptr); + + static std::vector projectVerticesOntoTriangles(const std::vector& originalVertices, const std::vector& drawSurfaceVertices); + static cvf::Vec3f projectPointOntoTriangle(const cvf::Vec3f& point, + const cvf::Vec3f& triangleVertex1, + const cvf::Vec3f& triangleVertex2, + const cvf::Vec3f& triangleVertex3, + bool* wasInsideTriangle); caf::PdmPointer m_wellPath; double m_planeWidth; cvf::ref m_curveDrawable; + cvf::ref m_curveFilledDrawable; std::vector m_curveVertices; + std::vector m_bottomVertices; + std::vector m_curveMeasuredDepths; std::vector m_curveValues; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 725a27671b..2bdf476f03 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -115,9 +115,9 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans for (size_t i = 0; i < wellPathPoints.size(); i++) { m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter)); + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth))); m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))); + wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth))); } cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 208d3ca3cd..73b38e0a62 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -109,24 +109,46 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* planeWidth(), drawSurfaceVertices); + cvf::ref curveDrawable = generator->curveDrawable(); - - if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) + if (curveDrawable.notNull() && curveDrawable->boundingBox().isValid()) { - return; + caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); + meshEffectGen.setLineWidth(2.0f); + cvf::ref effect = meshEffectGen.generateCachedEffect(); + + cvf::ref part = new cvf::Part; + part->setDrawable(curveDrawable.p()); + part->setEffect(effect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + } } - caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); - meshEffectGen.setLineWidth(2.0f); - cvf::ref effect = meshEffectGen.generateCachedEffect(); + if (rim3dWellLogCurve->drawStyle() == Rim3dWellLogCurve::FILLED) + { + Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); - cvf::ref part = new cvf::Part; - part->setDrawable(curveDrawable.p()); - part->setEffect(effect.p()); + cvf::ref curveFilledDrawable = generator->curveFilledDrawable(); + if (curveFilledDrawable.notNull() && curveFilledDrawable->boundingBox().isValid()) + { + caf::SurfaceEffectGenerator filledEffectGen(rim3dWellLogCurve->color(), caf::PO_NONE); + filledEffectGen.enableLighting(false); + cvf::ref filledEffect = filledEffectGen.generateCachedEffect(); - if (part.notNull()) - { - model->addPart(part.p()); + cvf::ref part = new cvf::Part; + part->setDrawable(curveFilledDrawable.p()); + part->setEffect(filledEffect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + part->setSourceInfo(sourceInfo.p()); + } + } } } @@ -186,6 +208,8 @@ void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* double samplingInterval) { Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); + bool showCoordinateSystemMesh = curveCollection->isShowingGrid(); bool showBackground = curveCollection->isShowingBackground(); @@ -216,7 +240,7 @@ void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); cvf::ref background = m_3dWellLogDrawSurfaceGeometryGenerator->background(); - cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); + if (background.notNull()) { cvf::ref part = createPart(background.p(), backgroundEffect.p()); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index f18a73b372..03981c60af 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -50,7 +50,15 @@ namespace caf addItem(Rim3dWellLogCurve::HORIZONTAL_CENTER, "HORIZONTAL_CENTER", "Centered - Horizontal"); addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Right"); setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); - } + } + + template<> + void AppEnum< Rim3dWellLogCurve::DrawStyle >::setUp() + { + addItem(Rim3dWellLogCurve::LINE, "LINE", "Line"); + addItem(Rim3dWellLogCurve::FILLED, "FILLED", "Filled"); + setDefault(Rim3dWellLogCurve::LINE); + } } //-------------------------------------------------------------------------------------------------- @@ -70,6 +78,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() m_maxCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); + CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); } @@ -98,6 +107,14 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::DrawStyle Rim3dWellLogCurve::drawStyle() const +{ + return m_drawStyle(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -192,6 +209,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Configuration"); configurationGroup->add(&m_drawPlane); +// Disable filled draw style in the GUI because of triangle stitching issue #2860. +// configurationGroup->add(&m_drawStyle); configurationGroup->add(&m_color); configurationGroup->add(&m_minCurveValue); configurationGroup->add(&m_maxCurveValue); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index b14fe8e0bf..e0c4ef85bf 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -50,6 +50,14 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder HORIZONTAL_RIGHT }; typedef caf::AppEnum DrawPlaneEnum; + + enum DrawStyle + { + LINE, + FILLED + }; + typedef caf::AppEnum DrawStyleEnum; + public: Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); @@ -60,7 +68,8 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder virtual QString resultPropertyString() const = 0; DrawPlane drawPlane() const; - double drawPlaneAngle() const; + DrawStyle drawStyle() const; + double drawPlaneAngle() const; cvf::Color3f color() const; bool isShowingCurve() const; @@ -73,7 +82,7 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder double maxCurveValue() const; void resetMinMaxValuesAndUpdateUI(); bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, - cvf::Vec3d* closestPoint, + cvf::Vec3d* closestPoint, double* measuredDepthAtPoint, double* valueAtPoint) const; @@ -89,7 +98,8 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder private: void resetMinMaxValues(); protected: - caf::PdmField> m_drawPlane; + caf::PdmField m_drawPlane; + caf::PdmField m_drawStyle; caf::PdmField m_color; caf::PdmField m_minCurveValue; caf::PdmField m_maxCurveValue; From 88cc6ea3f5564bb386ec01d130ebffed76b4b121 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 7 May 2018 11:15:42 +0200 Subject: [PATCH 0883/1027] Fix wrong assert in cvfScalarMapperRangeBased::setLevelsFromValues * Old code always causes assert failure when calling this method. --- Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp index ca4ee0fbf0..3f2467ce55 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp @@ -115,7 +115,7 @@ void ScalarMapperRangeBased::setLevelCount(size_t levelCount, bool adjustLevels) //-------------------------------------------------------------------------------------------------- void ScalarMapperRangeBased::setLevelsFromValues(const std::set& levelValues) { - CVF_ASSERT(!m_userDefinedLevelValues.empty()); + CVF_ASSERT(!levelValues.empty()); m_userDefinedLevelValues = levelValues; m_rangeMax = (*levelValues.rbegin()); From 57b3ad82a8e2884f77dbc695eea850753c1089dd Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 3 May 2018 15:04:37 +0200 Subject: [PATCH 0884/1027] #2791 Fix tensor vector colors so principal to has a single color. --- .../ModelVisualization/RivTensorResultPartMgr.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp index 3b3d4cd2d5..bd301d520c 100644 --- a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -399,8 +399,11 @@ void RivTensorResultPartMgr::createOneColorPerPrincipalScalarMapper(const RimTen } scalarMapper->setColors(arrowColors); - scalarMapper->setRange(0.5, 3.5); - scalarMapper->setLevelCount(3, true); + + // Using a linear color mapper to set colors for three discrete principal numbers (1, 2, 3) + // by setting the 3 + 1 interval levels so the principal numbers match the center of the intervals. + std::set levelValues = { 0.5, 1.5, 2.5, 3.5 }; + scalarMapper->setLevelsFromValues(levelValues); } //-------------------------------------------------------------------------------------------------- From a7b3aa0babece9fbe725aaac9b5b4aebd2eed55b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 08:12:06 +0200 Subject: [PATCH 0885/1027] #2716 #2830 Use OpenMP on calculations --- .../RigFemPartResultsCollection.cpp | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 868e812e9a..407db785c1 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -509,7 +509,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateBarConvertedResu size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = 1.0e-5*srcFrameData[vIdx]; } @@ -1324,7 +1325,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV s3inc.resize(valCount); s3azi.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for ( long vIdx = 0; vIdx < static_cast(valCount); ++vIdx ) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); cvf::Vec3f principalDirs[3]; @@ -1342,7 +1344,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV else { s1inc[vIdx] = std::numeric_limits::infinity(); - s1azi[vIdx] = std::numeric_limits::infinity(); + s1azi[vIdx] = std::numeric_limits::infinity(); } if ( principals[1] != std::numeric_limits::infinity() ) @@ -1354,7 +1356,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV else { s2inc[vIdx] = std::numeric_limits::infinity(); - s2azi[vIdx] = std::numeric_limits::infinity(); + s2azi[vIdx] = std::numeric_limits::infinity(); } if ( principals[2] != std::numeric_limits::infinity() ) @@ -1428,7 +1430,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStrainV s2.resize(valCount); s3.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); cvf::Vec3f principalDirs[3]; @@ -1626,7 +1629,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = -srcFrameData[vIdx]; } @@ -1814,7 +1818,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in size_t valCount = srcSFrameData.size(); dstFrameData.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = -srcSFrameData[vIdx]; } @@ -2193,7 +2199,8 @@ std::vector RigFemPartResultsCollection::tensors(const RigFemResultA size_t valCount = v11.size(); outputTensors.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { caf::Ten3f tensor(v11[vIdx], v22[vIdx], v33[vIdx], v12[vIdx], v23[vIdx], v13[vIdx]); outputTensors[vIdx] = tensor; From d132ecd0368662cca35c5119ab9a617094067051 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 08:36:32 +0200 Subject: [PATCH 0886/1027] #2830 Geomech: Improve performance on results calculations --- .../RigFemPartResultsCollection.cpp | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 407db785c1..5c5bb01a0e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -550,6 +550,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateEnIpPorBarResult dstFrameData.resize(valCount, inf); int elementCount = femPart->elementCount(); + +#pragma omp parallel for for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); @@ -604,7 +606,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult( size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx ) { dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx]; } @@ -680,7 +683,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSEM(in size_t valCount = sa11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (sa11Data[vIdx] + sa22Data[vIdx] + sa33Data[vIdx])/3.0f; } @@ -722,7 +726,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSFI(int partInde size_t valCount = se1Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float se1 = se1Data[vIdx]; float se3 = se3Data[vIdx]; @@ -775,7 +780,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDSM(int partInde size_t valCount = se1Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = dsm(se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle); } @@ -812,7 +818,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFOS(int partInde size_t valCount = dsmData.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float dsm = dsmData[vIdx]; dstFrameData[vIdx] = 1.0f/dsm; @@ -856,7 +863,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSTM(in size_t valCount = st11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx])/3.0f; } @@ -904,7 +912,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDeviatoricStress size_t valCount = st11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float stmVal = stmData[vIdx]; float st11Corr = st11Data[vIdx] - stmVal; @@ -958,7 +967,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateVolumetricStrain size_t valCount = ea11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx]); } @@ -1002,7 +1012,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDeviatoricStrain size_t valCount = ea11Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = 0.666666666666667f*(ea11Data[vIdx] - ea33Data[vIdx]); } @@ -1094,6 +1105,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt PCRITDat.resize(valCount); int elementCount = femPart->elementCount(); + +#pragma omp parallel for for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1206,6 +1219,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAngles(in Pinc.resize(valCount); int elementCount = femPart->elementCount(); +#pragma omp parallel for for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1904,6 +1918,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in frameCountProgress.incrementProgress(); int elementCount = femPart->elementCount(); +#pragma omp parallel for for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1961,6 +1976,8 @@ void RigFemPartResultsCollection::calculateGammaFromFrames(int partIndex, dstFrameData.resize(valCount); int elementCount = femPart->elementCount(); + +#pragma omp parallel for for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { RigElementType elmType = femPart->elementType(elmIdx); From bc4282d8d7ed8be087f4635595c279057b3e5429 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 10:16:04 +0200 Subject: [PATCH 0887/1027] #2830 Geomech: Improve performance : Use dynamic on selected sections Skip computation of formation layers if no formations are present --- .../RigFemPartResultsCollection.cpp | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 5c5bb01a0e..29974d8445 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -551,15 +551,14 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateEnIpPorBarResult int elementCount = femPart->elementCount(); -#pragma omp parallel for +#pragma omp parallel for schedule(dynamic) for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); - if (elmType == HEX8P) { + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); @@ -1339,7 +1338,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV s3inc.resize(valCount); s3azi.resize(valCount); -#pragma omp parallel for +#pragma omp parallel for schedule(dynamic) for ( long vIdx = 0; vIdx < static_cast(valCount); ++vIdx ) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); @@ -1917,32 +1916,32 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in frameCountProgress.incrementProgress(); - int elementCount = femPart->elementCount(); -#pragma omp parallel for - for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + if (activeFormNames) { - RigElementType elmType = femPart->elementType(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); + int elementCount = femPart->elementCount(); - size_t i, j, k; - femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k); - int formNameIdx = -1; - if (activeFormNames) +#pragma omp parallel for + for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { - formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); - } + RigElementType elmType = femPart->elementType(elmIdx); + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); - for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + size_t i, j, k; + femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k); + int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); - if (formNameIdx != -1) - { - dstFrameData[elmNodResIdx] = formNameIdx; - } - else + for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { - dstFrameData[elmNodResIdx] = HUGE_VAL; + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + + if (formNameIdx != -1) + { + dstFrameData[elmNodResIdx] = formNameIdx; + } + else + { + dstFrameData[elmNodResIdx] = HUGE_VAL; + } } } } From 9e5f0abfe9a5ba5e35fcdaafe022fcf455db38d9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 11:17:33 +0200 Subject: [PATCH 0888/1027] #2830 Geomech: Move code into separate calculate functions, add OpenMP --- .../RigFemPartResultsCollection.cpp | 549 ++++++++++-------- .../RigFemPartResultsCollection.h | 6 + 2 files changed, 308 insertions(+), 247 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 29974d8445..0e8d61d9a8 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1533,6 +1533,301 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues return requestedPrincipal; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateNE(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + frameCountProgress.incrementProgress(); + + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcFrameData.size(); + dstFrameData.resize(valCount); + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) + { + dstFrameData[vIdx] = -srcFrameData[vIdx]; + } + + frameCountProgress.incrementProgress(); + } + + return dstDataFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSE(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + frameCountProgress.incrementProgress(); + + const RigFemPart * femPart = m_femParts->part(partIndex); + float inf = std::numeric_limits::infinity(); + + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); + + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + int elementCount = femPart->elementCount(); + +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + { + RigElementType elmType = femPart->elementType(elmIdx); + + int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); + + if (elmType == HEX8P) + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + } + } + else + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + + dstFrameData[elmNodResIdx] = inf; + } + } + } + + frameCountProgress.incrementProgress(); + } + + return dstDataFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_11_22_33(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + frameCountProgress.incrementProgress(); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcSDataFrames->frameCount(); + + frameCountProgress.incrementProgress(); + + const float inf = std::numeric_limits::infinity(); + + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); + + int elementCount = femPart->elementCount(); + +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + { + RigElementType elmType = femPart->elementType(elmIdx); + + int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); + + if (elmType == HEX8P) + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx); + + float por = srcPORFrameData[nodeIdx]; + if (por == inf) por = 0.0f; + + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por; + } + } + else + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + } + } + } + + frameCountProgress.incrementProgress(); + } + + return dstDataFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_12_13_23(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + frameCountProgress.incrementProgress(); + + int frameCount = srcSDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) + { + dstFrameData[vIdx] = -srcSFrameData[vIdx]; + } + + frameCountProgress.incrementProgress(); + } + + return dstDataFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateGamma(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemResultAddress totStressCompAddr(resVarAddr.resultPosType, "ST", ""); + { + std::string scomp; + std::string gcomp = resVarAddr.componentName; + if (gcomp == "Gamma1") scomp = "S1"; + else if (gcomp == "Gamma2") scomp = "S2"; + else if (gcomp == "Gamma3") scomp = "S3"; + else if (gcomp == "Gamma11") scomp = "S11"; + else if (gcomp == "Gamma22") scomp = "S22"; + else if (gcomp == "Gamma33") scomp = "S33"; + totStressCompAddr.componentName = scomp; + } + + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, totStressCompAddr); + + frameCountProgress.incrementProgress(); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + frameCountProgress.incrementProgress(); + + calculateGammaFromFrames(partIndex, srcDataFrames, srcPORDataFrames, dstDataFrames, &frameCountProgress); + + return dstDataFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFormationIndices(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + + RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + resFrames->enableAsSingleFrameResult(); + + const RigFemPart * femPart = m_femParts->part(partIndex); + std::vector& dstFrameData = resFrames->frameData(0); + + size_t valCount = femPart->elementNodeResultCount(); + float inf = std::numeric_limits::infinity(); + dstFrameData.resize(valCount, inf); + + RigFormationNames* activeFormNames = m_activeFormationNamesData.p(); + + frameCountProgress.incrementProgress(); + + if (activeFormNames) + { + int elementCount = femPart->elementCount(); + +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + { + RigElementType elmType = femPart->elementType(elmIdx); + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); + + size_t i, j, k; + femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k); + int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); + + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + + if (formNameIdx != -1) + { + dstFrameData[elmNodResIdx] = formNameIdx; + } + else + { + dstFrameData[elmNodResIdx] = HUGE_VAL; + } + } + } + } + + return resFrames; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1625,33 +1920,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "E13" || resVarAddr.componentName == "E23")) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - - frameCountProgress.incrementProgress(); - - int frameCount = srcDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - size_t valCount = srcFrameData.size(); - dstFrameData.resize(valCount); - -#pragma omp parallel for - for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) - { - dstFrameData[vIdx] = -srcFrameData[vIdx]; - } - - frameCountProgress.incrementProgress(); - } - - return dstDataFrames; + return calculateNE(partIndex, resVarAddr); } if ( (resVarAddr.fieldName == "NE") @@ -1670,60 +1939,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "S13" || resVarAddr.componentName == "S23" )) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - - frameCountProgress.incrementProgress(); - - const RigFemPart * femPart = m_femParts->part(partIndex); - float inf = std::numeric_limits::infinity(); - - int frameCount = srcDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcSFrameData = srcDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); - - const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); - - int elementCount = femPart->elementCount(); - for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) - { - RigElementType elmType = femPart->elementType(elmIdx); - - int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); - - if (elmType == HEX8P) - { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; - } - } - else - { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - - dstFrameData[elmNodResIdx] = inf; - } - } - } - - frameCountProgress.incrementProgress(); - } - - return dstDataFrames; + return calculateSE(partIndex, resVarAddr); } if ( (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST" ) @@ -1746,67 +1962,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "S22" || resVarAddr.componentName == "S33" )) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - const RigFemPart * femPart = m_femParts->part(partIndex); - int frameCount = srcSDataFrames->frameCount(); - - frameCountProgress.incrementProgress(); - - const float inf = std::numeric_limits::infinity(); - - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); - const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); - - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); - - int elementCount = femPart->elementCount(); - for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) - { - RigElementType elmType = femPart->elementType(elmIdx); - - int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); - - if (elmType == HEX8P) - { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx); - - float por = srcPORFrameData[nodeIdx]; - if (por == inf) por = 0.0f; - - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por; - } - } - else - { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; - } - } - } - - frameCountProgress.incrementProgress(); - } - return dstDataFrames; + return calculateST_11_22_33(partIndex, resVarAddr); } if ( resVarAddr.fieldName == "ST" @@ -1814,33 +1970,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "S13" || resVarAddr.componentName == "S23" )) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - - frameCountProgress.incrementProgress(); - - int frameCount = srcSDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); - -#pragma omp parallel for - for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) - { - dstFrameData[vIdx] = -srcSFrameData[vIdx]; - } - - frameCountProgress.incrementProgress(); - } - return dstDataFrames; + return calculateST_12_13_23(partIndex, resVarAddr); } if (resVarAddr.fieldName == "ST" && resVarAddr.componentName == "") @@ -1859,36 +1989,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "Gamma33" )) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemResultAddress totStressCompAddr(resVarAddr.resultPosType, "ST", ""); - { - std::string scomp; - std::string gcomp = resVarAddr.componentName; - if ( gcomp == "Gamma1" ) scomp = "S1"; - else if ( gcomp == "Gamma2" ) scomp = "S2"; - else if ( gcomp == "Gamma3" ) scomp = "S3"; - else if ( gcomp == "Gamma11" ) scomp = "S11"; - else if ( gcomp == "Gamma22" ) scomp = "S22"; - else if ( gcomp == "Gamma33" ) scomp = "S33"; - totStressCompAddr.componentName = scomp; - } - - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, totStressCompAddr); - - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - - frameCountProgress.incrementProgress(); - - calculateGammaFromFrames(partIndex, srcDataFrames, srcPORDataFrames, dstDataFrames, &frameCountProgress); - - return dstDataFrames; + return calculateGamma(partIndex, resVarAddr); } if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName == "") @@ -1899,55 +2000,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in if (resVarAddr.resultPosType == RIG_FORMATION_NAMES) { - caf::ProgressInfo frameCountProgress(2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - - RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - resFrames->enableAsSingleFrameResult(); - - const RigFemPart * femPart = m_femParts->part(partIndex); - std::vector& dstFrameData = resFrames->frameData(0); - - size_t valCount = femPart->elementNodeResultCount(); - float inf = std::numeric_limits::infinity(); - dstFrameData.resize(valCount, inf); - - RigFormationNames* activeFormNames = m_activeFormationNamesData.p(); - - frameCountProgress.incrementProgress(); - - if (activeFormNames) - { - int elementCount = femPart->elementCount(); - -#pragma omp parallel for - for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) - { - RigElementType elmType = femPart->elementType(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); - - size_t i, j, k; - femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k); - int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); - - for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - - if (formNameIdx != -1) - { - dstFrameData[elmNodResIdx] = formNameIdx; - } - else - { - dstFrameData[elmNodResIdx] = HUGE_VAL; - } - } - } - } - - return resFrames; + return calculateFormationIndices(partIndex, resVarAddr); } + return nullptr; } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 63a8abfb0b..63c601c009 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -121,6 +121,12 @@ class RigFemPartResultsCollection: public cvf::Object RigFemScalarResultFrames* calculatePrincipalStressValues(int partIndex, const RigFemResultAddress &resVarAddr); RigFemScalarResultFrames* calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr); RigFemScalarResultFrames* calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateNE(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateSE(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateST_11_22_33(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateST_12_13_23(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateGamma(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateFormationIndices(int partIndex, const RigFemResultAddress &resVarAddr); static std::vector tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr); From 2aeafb509b005fd5e6751a3149feae11b1eaf19f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 11:28:58 +0200 Subject: [PATCH 0889/1027] #2830 Geomech: Apply code improvements suggested by clang --- .../RigFemPartResultsCollection.cpp | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 0e8d61d9a8..3d223d4ce3 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -91,10 +91,10 @@ RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterfa m_femPartResults.resize(m_femParts->partCount()); std::vector stepNames = m_readerInterface->stepNames(); - for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) + for (auto & femPartResult : m_femPartResults) { - m_femPartResults[pIdx] = new RigFemPartResults; - m_femPartResults[pIdx]->initResultSteps(stepNames); + femPartResult = new RigFemPartResults; + femPartResult->initResultSteps(stepNames); } m_cohesion = 10.0; @@ -149,7 +149,7 @@ RigFormationNames* RigFemPartResultsCollection::activeFormationNames() //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) { - for (const QString filename : filenames) + for (const QString& filename : filenames) { m_elementPropertyReader->addFile(filename.toStdString()); } @@ -162,11 +162,11 @@ std::vector RigFemPartResultsCollection::removeElementPrope { std::vector addressesToRemove; - for (const QString filename : filenames) + for (const QString& filename : filenames) { std::vector fields = m_elementPropertyReader->fieldsInFile(filename.toStdString()); - for (std::string field : fields) + for (const std::string& field : fields) { addressesToRemove.push_back(RigFemResultAddress(RIG_ELEMENT, field, "")); } @@ -246,12 +246,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in std::vector< RigFemResultAddress> resultAddressOfComponents = this->getResAddrToComponentsToRead(resVarAddr); - if (resultAddressOfComponents.size()) + if (!resultAddressOfComponents.empty()) { std::vector resultsForEachComponent; - for (size_t cIdx = 0; cIdx < resultAddressOfComponents.size(); ++cIdx) + for (const auto & resultAddressOfComponent : resultAddressOfComponents) { - resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponents[cIdx])); + resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponent)); } int frameCount = this->frameCount(); @@ -265,9 +265,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame { std::vector*> componentDataVectors; - for (size_t cIdx = 0; cIdx < resultsForEachComponent.size(); ++cIdx) + for (auto & componentResult : resultsForEachComponent) { - componentDataVectors.push_back(&(resultsForEachComponent[cIdx]->frameData(stepIndex))); + componentDataVectors.push_back(&(componentResult->frameData(stepIndex))); } switch (resVarAddr.resultPosType) @@ -544,7 +544,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateEnIpPorBarResult const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - if (!srcFrameData.size()) continue; // Create empty results if we have no POR result. + if (srcFrameData.empty()) continue; // Create empty results if we have no POR result. size_t valCount = femPart->elementNodeResultCount(); dstFrameData.resize(valCount, inf); @@ -1973,7 +1973,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return calculateST_12_13_23(partIndex, resVarAddr); } - if (resVarAddr.fieldName == "ST" && resVarAddr.componentName == "") + if (resVarAddr.fieldName == "ST" && resVarAddr.componentName.empty()) { // Create and return an empty result return m_femPartResults[partIndex]->createScalarResult(resVarAddr); @@ -1992,7 +1992,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return calculateGamma(partIndex, resVarAddr); } - if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName == "") + if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName.empty()) { // Create and return an empty result return m_femPartResults[partIndex]->createScalarResult(resVarAddr); @@ -2095,15 +2095,15 @@ std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToCompo if (fcIt != fieldAndComponentNames.end()) { std::vector compNames = fcIt->second; - if (resVarAddr.componentName != "") // If we did not request a particular component, do not add the components + if (!resVarAddr.componentName.empty()) // If we did not request a particular component, do not add the components { - for (size_t cIdx = 0; cIdx < compNames.size(); ++cIdx) + for (const auto & compName : compNames) { - resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compNames[cIdx])); + resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compName)); } } - if (compNames.size() == 0) // This is a scalar field. Add one component named "" + if (compNames.empty()) // This is a scalar field. Add one component named "" { CVF_ASSERT(resVarAddr.componentName == ""); resAddressToComponents.push_back(resVarAddr); @@ -2167,7 +2167,7 @@ bool RigFemPartResultsCollection::assertResultsLoaded(const RigFemResultAddress& RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(pIdx, resVarAddr); for (int fIdx = 0; fIdx < scalarResults->frameCount(); ++fIdx) { - foundResults = foundResults || scalarResults->frameData(fIdx).size(); + foundResults = foundResults || !scalarResults->frameData(fIdx).empty(); } } } @@ -2182,11 +2182,11 @@ void RigFemPartResultsCollection::deleteResult(const RigFemResultAddress& resVar { CVF_ASSERT ( resVarAddr.isValid() ); - for ( int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx ) + for (auto & femPartResult : m_femPartResults) { - if ( m_femPartResults[pIdx].notNull() ) + if ( femPartResult.notNull() ) { - m_femPartResults[pIdx]->deleteScalarResult(resVarAddr); + femPartResult->deleteScalarResult(resVarAddr); } } @@ -2439,7 +2439,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(cons double min, max; - for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) { this->statistics(address)->minMaxCellScalarValues(frameIndex, min, max); if (min < currentMin) @@ -2466,7 +2466,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(cons double min, max; - for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) { this->statistics(address)->minMaxCellScalarValues(min, max); if (min < currentMin) @@ -2493,7 +2493,7 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(con double pos, neg; - for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) { this->statistics(address)->posNegClosestToZero(frameIndex, pos, neg); if (pos < currentPosClosestToZero) @@ -2520,7 +2520,7 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(con double pos, neg; - for (auto address : tensorPrincipalComponentAdresses(resVarAddr)) + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) { this->statistics(address)->posNegClosestToZero(pos, neg); if (pos < currentPosClosestToZero) From d659b8e853d0e8260d09707a67cea704ab901f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 11:03:52 +0200 Subject: [PATCH 0890/1027] #2856 Context menus. Fix logical error during menu build-up --- Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp index e911837c96..fbd46bdb02 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp @@ -202,13 +202,18 @@ void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu) CAF_ASSERT(act); + bool duplicateAct = false; for (QAction* existingAct : currentMenu->actions()) { // If action exist, continue to make sure the action is positioned at the first // location of a command ID if (existingAct == act) - continue; + { + duplicateAct = true; + break; + } } + if (duplicateAct) continue; currentMenu->addAction(const_cast(act)); } From f71bdda4fb64ff8ee2c41996a72c6727da9c8152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 11:04:42 +0200 Subject: [PATCH 0891/1027] #2856 Menus. Restructure context menu --- .../ProjectDataModel/RimContextCommandBuilder.cpp | 6 ++++++ ApplicationCode/UserInterface/RiuMainWindow.cpp | 11 +++++------ ApplicationCode/UserInterface/RiuPlotMainWindow.cpp | 11 +++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 2ada56675b..ed671389f1 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -482,18 +482,24 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; menuBuilder << "RicImportEnsembleFeature"; + menuBuilder.subMenuEnd(); + menuBuilder.addSeparator(); menuBuilder << "RicNewSummaryPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder.addSeparator(); } else if (dynamic_cast(uiItem)) { + menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; menuBuilder << "RicImportEnsembleFeature"; + menuBuilder.subMenuEnd(); + menuBuilder.addSeparator(); menuBuilder << "RicNewSummaryPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder.addSeparator(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index d598cf9919..b233d92bf8 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -391,18 +391,17 @@ void RiuMainWindow::createMenus() importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data"); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); - + importWellMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importMenu->addSeparator(); - QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index b05000e771..02277e6de8 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -197,18 +197,17 @@ void RiuPlotMainWindow::createMenus() importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); - importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Wells"); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data"); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); - + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addSeparator(); - QMenu* importFormationsMenu = importMenu->addMenu(QIcon(":/FormationCollection16x16.png"), "Formations"); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importFormationsMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); From fb518117c0cc7503d32ff8db3c61124f2934542b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 12:00:34 +0200 Subject: [PATCH 0892/1027] #2856 Menus. Import case directly into group --- .../Commands/RicImportEnsembleFeature.cpp | 8 ++++ .../Commands/RicImportSummaryCaseFeature.cpp | 9 +++++ .../Commands/RicImportSummaryCasesFeature.cpp | 39 ++++++++++++++++--- .../Commands/RicImportSummaryCasesFeature.h | 1 + 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 3440acf67a..cf976816d6 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -76,6 +76,14 @@ void RicImportEnsembleFeature::onActionTriggered(bool isChecked) RicImportSummaryCasesFeature::addSummaryCases(cases); RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName); + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + std::vector allCases; app->project()->allCases(allCases); diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 0e1d7029fa..036c24f745 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -76,10 +76,19 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) std::vector newCases; if (RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(fileNames, &newCases)) { + RicImportSummaryCasesFeature::addCasesToGroupIfRelevant(newCases); for (const RimSummaryCase* newCase : newCases) { RiaApplication::instance()->addToRecentFiles(newCase->summaryHeaderFilename()); } + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !newCases.empty()) + { + mainPlotWindow->selectAsCurrentItem(newCases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } } std::vector cases; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 8f6f60ffac..0dc7224729 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -31,6 +31,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" @@ -40,6 +41,7 @@ #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" #include #include @@ -75,8 +77,18 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) addSummaryCases(cases); + addCasesToGroupIfRelevant(cases); + for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + std::vector allCases; app->project()->allCases(allCases); @@ -154,13 +166,30 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vectoractiveOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; sumCaseColl->addCases(cases); sumCaseColl->updateAllRequiredEditors(); +} - RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow && !cases.empty()) - { - mainPlotWindow->selectAsCurrentItem(cases.back()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::addCasesToGroupIfRelevant(const std::vector cases) +{ + std::vector selectedColl = caf::selectedObjectsByTypeStrict(); - mainPlotWindow->updateSummaryPlotToolBar(); + if (selectedColl.size() == 1) + { + RimSummaryCaseCollection* coll = selectedColl.front(); + RimSummaryCaseMainCollection* mainColl; + coll->firstAncestorOrThisOfType(mainColl); + + if (mainColl) + { + for (const auto sumCase : cases) + { + mainColl->removeCase(sumCase); + selectedColl.front()->addCase(sumCase); + } + mainColl->updateConnectedEditors(); + } } } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h index 68d9ca017d..15c6f18a00 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -41,6 +41,7 @@ class RicImportSummaryCasesFeature : public caf::CmdFeature static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases = nullptr); static bool createSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases); static void addSummaryCases(const std::vector cases); + static void addCasesToGroupIfRelevant(const std::vector cases); static QStringList runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle); From c4c0d46692462dc44ed48a53237abc6a4ccda301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 7 May 2018 11:30:19 +0200 Subject: [PATCH 0893/1027] #2857, #2861, #2853, #2862 Icon improvements: Use new Summary plot icon in combined icons, Observed Data icons, Octave Script icon improvements, Summary Case Group icon --- .../RicCreateSummaryCaseCollectionFeature.cpp | 2 +- .../Commands/RicImportEnsembleFeature.cpp | 2 +- .../Commands/RicImportObservedDataFeature.cpp | 2 +- .../RicImportObservedDataInMenuFeature.cpp | 2 +- .../Commands/RicImportSummaryCasesFeature.cpp | 2 +- .../ProjectDataModel/RimCalcScript.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 4 ++-- .../Summary/RimCsvUserData.cpp | 2 +- .../Summary/RimObservedEclipseUserData.cpp | 2 +- .../Summary/RimSummaryCase.cpp | 2 +- .../Summary/RimSummaryCaseCollection.cpp | 2 +- .../Summary/RimSummaryCaseMainCollection.cpp | 2 +- .../Summary/RimSummaryObservedDataFile.cpp | 2 +- ApplicationCode/Resources/Case48x48.png | Bin 2842 -> 2786 bytes .../Resources/EclipseInput48x48.png | Bin 3597 -> 3889 bytes ApplicationCode/Resources/Folder.png | Bin 642 -> 696 bytes ApplicationCode/Resources/InputCase48x48.png | Bin 0 -> 3889 bytes .../Resources/ObservedCSVDataFile16x16.png | Bin 0 -> 629 bytes .../Resources/ObservedDataFile16x16.png | Bin 0 -> 602 bytes .../Resources/ObservedRSMDataFile16x16.png | Bin 0 -> 633 bytes .../Resources/OctaveScriptFile16x16.png | Bin 0 -> 618 bytes ApplicationCode/Resources/PlotWindow24x24.png | Bin 1108 -> 1250 bytes ApplicationCode/Resources/ResInsight.qrc | 7 +++++++ .../Resources/SummaryCase16x16.png | Bin 0 -> 881 bytes .../Resources/SummaryCase48x48.png | Bin 4327 -> 4183 bytes .../Resources/SummaryCases16x16.png | Bin 0 -> 925 bytes .../Resources/SummaryEnsemble16x16.png | Bin 0 -> 900 bytes 27 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 ApplicationCode/Resources/InputCase48x48.png create mode 100644 ApplicationCode/Resources/ObservedCSVDataFile16x16.png create mode 100644 ApplicationCode/Resources/ObservedDataFile16x16.png create mode 100644 ApplicationCode/Resources/ObservedRSMDataFile16x16.png create mode 100644 ApplicationCode/Resources/OctaveScriptFile16x16.png create mode 100644 ApplicationCode/Resources/SummaryCase16x16.png create mode 100644 ApplicationCode/Resources/SummaryCases16x16.png create mode 100644 ApplicationCode/Resources/SummaryEnsemble16x16.png diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 11a13e0130..42f4cf9b53 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -92,5 +92,5 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) void RicCreateSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Group Summary Cases"); - actionToSetup->setIcon(QIcon(":/Folder.png")); + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); } diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index cf976816d6..6001bda188 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -98,7 +98,7 @@ void RicImportEnsembleFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportEnsembleFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); actionToSetup->setText("Import Ensemble"); } diff --git a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp index 6dc98c157b..3679c2c5b3 100644 --- a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp @@ -131,6 +131,6 @@ void RicImportObservedDataFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportObservedDataFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/Default.png")); + actionToSetup->setIcon(QIcon(":/ObservedDataFile16x16.png")); actionToSetup->setText("Import Observed Time History Data"); } diff --git a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp index 1893e13105..2c55ca6726 100644 --- a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp @@ -61,7 +61,7 @@ void RicImportObservedDataInMenuFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportObservedDataInMenuFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/Default.png")); + actionToSetup->setIcon(QIcon(":/ObservedDataFile16x16.png")); actionToSetup->setText("Import Observed Time History Data"); } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index 0dc7224729..b1d9765424 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -103,7 +103,7 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); + actionToSetup->setIcon(QIcon(":/SummaryCases16x16.png")); actionToSetup->setText("Import Summary Cases Recursively"); } diff --git a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp index 7cc376c539..1ffe6debc9 100644 --- a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp +++ b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp @@ -27,7 +27,7 @@ CAF_PDM_SOURCE_INIT(RimCalcScript, "CalcScript"); //-------------------------------------------------------------------------------------------------- RimCalcScript::RimCalcScript() { - CAF_PDM_InitObject("CalcScript", ":/octave.png", "Calc Script", ""); + CAF_PDM_InitObject("CalcScript", ":/OctaveScriptFile16x16.png", "Calc Script", ""); CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,""); CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,""); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 0538582d81..22ed1110f3 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -99,7 +99,7 @@ RimProject::RimProject(void) CAF_PDM_InitFieldNoDefault(&oilFields, "OilFields", "Oil Fields", "", "", ""); oilFields.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", ""); + CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", ""); scriptCollection.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&wellPathImport, "WellPathImport", "WellPathImport", "", "", ""); @@ -156,7 +156,7 @@ RimProject::RimProject(void) scriptCollection = new RimScriptCollection(); scriptCollection->directory.uiCapability()->setUiHidden(true); scriptCollection->uiCapability()->setUiName("Scripts"); - scriptCollection->uiCapability()->setUiIcon(QIcon(":/Default.png")); + scriptCollection->uiCapability()->setUiIcon(QIcon(":/octave.png")); mainPlotCollection = new RimMainPlotCollection(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp b/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp index 4f4ba4d088..fee2e40c42 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp @@ -36,7 +36,7 @@ CAF_PDM_SOURCE_INIT(RimCsvUserData, "RimCsvUserData"); //-------------------------------------------------------------------------------------------------- RimCsvUserData::RimCsvUserData() { - CAF_PDM_InitObject("Observed CSV Data File", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed CSV Data File", ":/ObservedCSVDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); CAF_PDM_InitFieldNoDefault(&m_parseOptions, "ParseOptions", "", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp index bf0ad70b6e..c642ed5ed8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimObservedEclipseUserData, "RimObservedEclipseUserData"); //-------------------------------------------------------------------------------------------------- RimObservedEclipseUserData::RimObservedEclipseUserData() { - CAF_PDM_InitObject("Observed RSMSPEC Column Based Data File", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed RSMSPEC Column Based Data File", ":/ObservedRSMDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index ca1235e26f..6cd6eab509 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -37,7 +37,7 @@ CAF_PDM_ABSTRACT_SOURCE_INIT(RimSummaryCase,"SummaryCase"); //-------------------------------------------------------------------------------------------------- RimSummaryCase::RimSummaryCase() { - CAF_PDM_InitObject("Summary Case",":/SummaryCase48x48.png","",""); + CAF_PDM_InitObject("Summary Case",":/SummaryCase16x16.png","",""); CAF_PDM_InitField(&m_shortName, "ShortName", QString("Display Name"), "Display Name", "", "", ""); CAF_PDM_InitField(&m_useAutoShortName, "AutoShortyName", false, "Use Auto Display Name", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 859178dd4c..ec509da4e4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -30,7 +30,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection, "SummaryCaseSubCollection"); //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::RimSummaryCaseCollection() { - CAF_PDM_InitObject("Summary Case Group", ":/Folder.png", "", ""); + CAF_PDM_InitObject("Summary Case Group", ":/SummaryEnsemble16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); m_cases.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index b5dbb4186e..8382784f3c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -61,7 +61,7 @@ void addCaseRealizationParametersIfFound(RimSummaryCase& sumCase, const QString //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() { - CAF_PDM_InitObject("Summary Cases",":/Cases16x16.png","",""); + CAF_PDM_InitObject("Summary Cases",":/SummaryCases16x16.png","",""); CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_caseCollections, "SummaryCaseCollections", "", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp index c698969c9c..cfe28fde9e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryObservedDataFile, "SummaryObservedDataFile"); //-------------------------------------------------------------------------------------------------- RimSummaryObservedDataFile::RimSummaryObservedDataFile() { - CAF_PDM_InitObject("Observed data file", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed data file", ":/ObservedDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); } diff --git a/ApplicationCode/Resources/Case48x48.png b/ApplicationCode/Resources/Case48x48.png index 8015d06ea7a66a9244b42f3eaf4b0fe542bb6aa6..cfab59e85019829e5c1046d91396d29da70c5635 100644 GIT binary patch delta 2752 zcmV;x3P1Il7UC6O63Oe+yjP`hjy0SQnC-UhY+i@>$93DRFFfXQ(_1B?RQT+t^0mn&S&AFJe^2!JcV-;Yi3 z)sGxta-8RYuKX1E4;))hc@gk^ zPzTnoYIz6I+$&dsZv(H7P4KnJab#>_{iQj8n&K3E4L%>5o5r_nWAb^owbt#tvDn$Coi?}f{#88K_3LD6gv8 z>1B3$zMEcdbnS;17gN1U^ol^W63Ot6s(k#=76}7S^Y@uNz8(OcpB(2u@3_xvU*RQ0 zK8I2V6){FaU)Zs=CY4eoo^RCme~cI-h=Al#sDL`fscK^>PTxJ-=yX$pI3*aWg=AJu zyO*i8D!b~KoRK{*XBBWaBg93>$MEImZfHZf1Gac&F8g)*-h`%|;;f;rB;J*8M+89q+zBt?jN`FTE?!e^TW=g`YnA zH~jH01h5)_stc_|r{}uv+?8dQSp3YQs(9-tZJpwY+@Oe73&`&tzZE1&EX`J|KlyM@ zonmft31)q_z1$Z-lBv!$d;0c=4ecb@%;Gymt?O4_@S`F&OTbxfy2>;+goYmSg-@^V zjWkpK>-EcuLGE_b-W5O+K$;=BlT{J%{D4Ab6FUz+$^&l{Fk^ay%|J}AYXiDeF#-J@!BP=RYF;5C)_S6TnAWtAhW8SUPhc+x=F_A za|;@0NH2xV-gq{}c$8{G4DLOmBM%>^v}x;VU^|PmDW2yGYIS*je~Q!J{aZ=8%eO!b zRp4_^-af!DU0Eg!3|Fo#&}u_=Q)l5F+1lLvv&+rF^H-X3VW#OWTwT`L#g<%{X=`J# zE6pAfr-*a?$_sv>!qA>0y6@;SY(MZAQF%bSoeuMj8F~Mm*R?TxO zJxn{sU+N%Ekt9PhhxEHo#89qpXV-&Iu>UtcOJ#7kTI*;nFUfbl{*u1_!|&?Ce8c?j z*`JWaJssFIBtaAr70OzuZkD*UBx&5i7=x;c2rPBb+4&~>e|N19;dz4R8H$B~Y9(an z_A0|WD$F)kzUO`Z*C+rx6}Bi;^RmKZ_EzN)p|WWQdyhWD?!!;1_@O3A%(*kCIXU@n zI(6}!=d3kxwmXRfh=6b;77jZR>6c zqLPNC`f8d>V$PjC!)venyFo20ON;B(`PW~*(3s}UQ?Gd4?kDV_!@o{#Xg6W8;#$`( zn)byH@WUcD?MafUWESlt=!Lmub!V2fT7+#iBgY;dUKhsSe&F##hoAm~?SOI4;hc4< ziilhd z%X;weQCA(@Z9G5HBxy^#F~!{UIdDCks>CUhq^k=%3EEh3oV|8QjiAmU&VdMLjNujE zc!djDmbDSDYHcRnPFtD_4XxDbQmGB#oTIhUf7HhGl+Mje%gS<76)P@DNaI))RaH%Z z7VuNxrTqIO@GW2g_!O{Zxw$0oz45A~X(o?8@ky<1*{!uL!(>T9w>2*p-uXU_OYdXj zZvXWsibrCNs&k?^$#ecAB3$<0e(S$ao_hVQE`Bt6^zo;U{`j3A6*6lnm8&WOaoj}^ ze@%K_m!v7hVu^NZ+4Q)9kBxI;jKT8*HO8}ue<}PN^ad(^Ups44Ir5~fsT(}kAY`_ z-^pRN_GL8PyZ?|rc6^NCz56AK3OJjQr9G0)GD)w)%EB~QrzQxnS&U0ltjoY!35#Vl zUT{&yNAJ>ii&5V*3Pur}vzc|yB|sDSKJYc*U7#~@;?@b=_$a%9PXb>Ao&rk!f5Gkr z0rgFT?A~`kM)n`leFq*Uh(bicsns-1#ic#6G*-0p2KY_jkMfyPJ@-U#r*)q1Q>hHF@4-iO&w)dDMzq~-(QYnDW9G`j%#}+o%YhgF zO2%G&VH#+IOsSY_qHZf_49w-d@ig#_JVj0ecH#v0)d=Mv<$O%@W#Hq$e-U8dZtFbX zXP`c)B0{g*7N<(m>td}vB{x~A0&H={%S2r&N_RCSssr3FqV!DwYwrtyF92W4Au4@6 z_b^tn^$yqTC4#<`cl794fq-n{$u# z&yLng75PX3Zi4apM)3prCLH!y9{l_ByJmi^Gy%2)fB1hD;R;7n7E8+j0000VGd000McNliru-2(>=04p44jVk~E3YtkoK~!ko?U>nbUDtKSe`}xV z&b$(-nVPK7l5Huqs@e{mLXO#(aNEQWEl{9Hkr;g{$~JHxf`6h91^gET1p@Y=FGhjX zO@k&KkTeP7sHqj%u16?NWJi@!4HQN3a=PT5&an6D0}q8OiJFYMb^$Hm0vGq5z0dmg zTHm+VT5!+q**&{w_w1hiKQ{TWHl7?ufEv&mo4|f-0Zfh)0A-*6><2s`0qVe;z$Rc3 zxH2|D`mq8qIe*S?0i!@Scl0s9g$&exi>9Uj`n`oxU4$fX#s}0>^=GjZN^4 zJ6SyP{MS6d{nztg6p=^Qc?~z5~2E zHo?~?$C0s#^_S)VBtHn1$#I6QcpXn|3rPDHPL4AS4Cnbh3LMVA@5xDPJP$k%>QyL& zaNq7>da-4>m9VrDbEVP3xoZIe*Zh`S7dQb-0LRBBn7^YGnjGgZfO+5?Fq?<94%`Pk z3Tyxl0DlhvMIaIgf&g~ys7tvVP$_yCfiMhn=agP-Nz#mB6kwgwi!(B-H0D?6#VNhS zX&fu6*JMElcn$bl;P3B5wd99?!oR2z084o|ZGOu8a_0?D^?ifq8Baw0!w+o{&p;IV zcTGA~NHfPmv%}eQORg6?=}Tn=dcaq6ZX6$*pnr3#{d^;!!fxlTYWSM27yFb%qR{BZ zdO?OZlqB>GzHe^MQl}WRKD|UB3=CTaE0hX>EG+i)a-*%CZf0@-0q|$Q?*ab={Q0c_ z7~^rp2nF9~&=@v}Fqi}I)&TgvkwWB~dbMB%s?iP3tEzT-nVp{RrWYGs`~LaGRByvx z5r3#wA{pLRl}{enBw^rb{yvlQ>ptMw$#MSumixT&6<$E(b0~FC5o09ug>9Q_QYl5^ z`9^)uh%tf)NX|k9)G1C?8%uHe_UT5an-at+!B8zEvufJCOs!SfQO6uTvg@WHv(|BC zuETq07S^_2Q^+-yngRY{y1}=e{U)zn1AoB2xJ&Oghm*{?b~n?dcA`H$yO8u!yd=Z7 z4!M~$8-dV=-yhwz?*B>Zc>CRHZFk*z@~%Kjm3I_={`6n-#~%p5Dgjj&T8U22b={du z%Pz6_nMGCc)^XZ8#S^*45v>-G-#vOGkR-7*Te1G^{W*1txydD%_1*SzR{)Ysb$_ne z(>LF5XeYsD7T+mqUBB~!9~H4#0?u;XRi^ntXy_qd`0V=8NHgU>UcIOoEGzuS*?BGb9hPDk7dAP^fHR`~Jt-{=la&CP0jk_Bt5j@sk(-5|^dd15qQ$ z7oS=mgen|+<$~5Kp{%qMZYBy>0e`GLkXhAEFC$JZ-6Z4WnFWnAq?bZwugy&{9;Mn4 zgL@9?t_P1&+OT<**v{f?is$))T3w!>;^g=KMw0IG4IqXp@VUotPVfttmI(vHr7H`x z+K^q>S$KywH#h#`Vsr59rKX&lX}WWlmvwfrCFf?^+F0yLvxmef;#|M;f`4DAFtq!S z?mhezTSp!tDi3J4(_y|bBk#WTigr6)5Yebm)W8q5P#cn^>9gW&a!n!Gj-k2SWY4yN zbt5rQi-&4X1o4n&ko0j+k5bE_xr{pKM?dnx<73Ds5)(~j|%I*3yw$&kz;{oxZa zlXAO0813 zZMpAzLHI;iuJ13D2C9BoFj-;=ijkJ8LxklzVN|BJd8Y(XNyAcoRpyeIGpA4S%1i%d zP|M2F;(B%d)t4_crg{CuOJ2A8DSP1HuTmS@Nm#77)|K<7eSiKv{IG~kdy-@-nMFGZ zdTwr6-Kk}*7GX=x$dLz!*9GHm9eMP?!6*M+IA@)zA|hAI2Im}#q0?R_Nm7}; zJf*L{{6p!smjP7~k^J;i;Cx=&2YEfCfZu8^dGDQk!xV~T-GA_~s}Aloo*!wFw58pc zVs82jxE@Yb;(ruL($$5X1Z}K1PG7m8Mo{Mv=Rky0#_*DFyu!IG%i4%nwKkJ(r!CEe zhE{5IsniB=&e2+FYGZmz=Vqp5Wx1(}6_+HWajc4}swO}S_&M-G{(TboHn0GE2H3RR zT#|QQds)&nlZPMswAME5)Y_(DvLvC~nwN8L{eZ@WcYm>QxBvPR#Urss)j3g|8cl zqN+{c{k$1^4w%Y&3V>&TXY&qj&{=Dmi*vm88wL zY-XKv3D5+70DK*I8|X|NyKw?HKFUtu)4&&jCxB8v*}Wj3zG0A^dq-r~z5}{<D_P196d+9OM2Rhs|?V?2pU0~(d8a=V^T1+~tpQ*4I1uBt8qXMp#Be+J%|I7ast zdw)#j0Jr6B>PVkLiA_`HXJ?q7o#Eu`CnSm@Hg4I*@SYKU;Ls8A!w}#1@q!}8j}VMl zRl1#yAbu+2qpM|UU)gB;hEXXHgLFU}z^S}feF?Y-#Os~aoV(M z+R^ml6f(4x4hovMY*3KUC@zDQO%vLNjI;sLpjriClZF6oP&&#O(%4p<5}>8&l}k!* zlnxpBN>j1NdL*CM$Ip4bzsrC3_x=5ju*CZK$3MPZ zL~ad&U?qUI|DehlmWqh@fiD}+8$9Uy{ztCA?z+c$m6yNx#pvj$jE;_KwOTEoyJpSc zn{T+`T+J`7s@Zl9RmD07syKDoGpD%xy?z*+|LB27gTMRaC;$4dKKjx7Urhks;upii z!#7`Z%{5>2jQ4+`LLpkVW$RWkVE~>%jo^S(9dVk{N)j4zOuf-yzE)>uc9wdpMQ?8} z%a<>w(%rS*IlJS+3okmp@4Mf9)jVMqzi2g^9V=I_S~aj?T_KJWX@^fUj;S}B3zwar zukqjm4|4g%7qj!S%Nf4%O7`EspM&EEdFYWxa3b{et>AxxEn9|$wr%^w-+tl~x4fzz z7#$tmG(0@K(^`8&PfyS0FpT`_%naMMZ9{yIRvgocW8x$sP7)qH@KZ+K_r8-3`oZ_U z$D7{r7DR;CTyOzF6cPjh#bRMuu~^(Tv~An!@9y0@cGf-cv5$T1qt3Z+BuVnQG)=Fz z)w7#bjS=iA;M0Q}4Cx64^cVpVN8=Z2Q`^bm$29py5OW;16V$$mueJrDIfynHXU!YINw z1|+*%5CllMgwl&sw@g*v8AefQ?cm^Fyz3qBm^gnc9#GZ2s@kZ{&(qV}OGl+byPZLPy61C5QA8L;1VKPxJVHO9R4lQqr-yUatYL7|=EC|7 z8{WQt{kqTn{bxSYaaKIw`~JaJt95X0Zf=u0XRNg}asZ%+5yTio1XW$|$hM0v;-NrpsZB}KlsJyD*7DR-PXUmoDb6~qwWKyB3IfhMZzIQ#O~0v8uP+1UUoij?Nu6^) z1kP>L>z!$uQg1Xc#$@&v!5D+@`*|$@#m8BTvspN$X$HV}9<64RgX81GaZD1&BymEL zCRl6fEO#(`_0@P7TFs{So*QrUzVziU+gE=CAPmE_R;ztqRj-?$pYKG3M!inCTwcfm zlY?j%v`>HPQ+(kc|LH}Cedy0W!kgdvR*W&kNkW<=BuSD1OcIhfS@5hnM=OqBc?flO zcG~Ib>HVrYU#(VARgxrWtAjitC9`FdktLWUM7Z;(2(Uj|(#J z&N{rnhg_CeYinms3pwZZtLkfvF)J1W`drZ?x8~kUW2EG>Z#FgiHzLiu5$1RE)v%Jd6m=^Dv%=@B5^S zz!)$0fODB3Jd0}derxTKBuTc4$U@j4g3I%w{eh`Xmpsg-mL!fBLd`jcvks#W1_41H zp1H@dXVU|>-FDmLO*h^2T%2E^ov=oP!1po6EX02phD#n+C`5F2cAnHWWYT}zVpEH= zDaJD>3psFh)u^gIrmBZrUUiYY5{tJ56?fb{lF&-L!u}oh$4K?M-_G^ z|N8k4uDk2~V_qJ;Q>ab}_8pot@eA?u5&SI0~MO&@K^E|>ZM2vtc zKJn{}=-&Xhj*alPU-!a;qo05E21h?DOLk<=xyM!YS6S)LFKGnhc^Fk(Zh0~0v`K98 z7+;`V5d<)vpB2QM925dz1@H&JjY8KY`Ud4FKQE>cHuiwC2Dq@BsX3RnCfgp!7%8h}`WwV(ZtW~@asa3jMJOj9 zSp;4Sd=U8ku@Qn_Q_OL>DgiJ9q(k9Pmi;syG|sNbl#mgyZb3?Cs&whY+(|NIQT5In z9B+}HT6=DnOpG@jnW2AV5s2Rb?gw^_jd1VoJ=D(#zzC?Y);Tr;PJdVwi=&a=Libg^16S_jQ?EQ%mPud$i_{B z?7r&iGrIH6JMQ4lJMI8r?>+a>S*cJc7Eg?2I5DCT1D)ka`YJwsy(ND9*inrW+fJ?m zumQMnY=j-V_b_}~08v1INCl+~Dq@WEs1;4!LM1Miiny0q_EVdZq**V}?kN`7Yf%jP zz7Y}FxVDQYpE-ZNIGha72V5~W!Z`46lT-ZrjbG=1lK@<{ec;9yanwYKA3Sq{IqLN~ z*1kLdc9H%O5&R&)&uLgsp##q|Ebl2%F3xDJ;TD6CJfzkDf3kWxJMQ`bkH6vbd|=5s zut0Yxs&0WsyDD8=an+Snlb6|mv@e{CH(5NP)RTsmgn@tI;;pNtI^WXAo|<+}Pb#tk zbc(Q3;PSB%-U~QD%;^9GlIA?8U@{6k?Oq%fr#x?uCgqe6`qq6DFXFN=^yup;$<7`9 zM%|KRXMhlha>gnw3BZWriOVk~n0x|e&a@?OJx_V=i7afhm~I{VwS9+{B;>#suH88x z0$S+^5&3_$`hj-xsn!}P;3P>C4v!yPu;STRQ4~?H*C~QHMZdj&T(5iWfLSW~uDxPF z#wTX!U){mP^T(O5L3)Y|lRIzXHY5C=Z|F6K&^P!K^-6H>)R3fpx3pY{!Qzo%a0|s# z#9;gYKP+Iptc}dtMoXH+nJV@Cd>EkEG$v`(P<4OA&akuN``9$mvTt>HCvyE2{c<{$ zn<>>$ZSQ_)kD4LYm zSP_4LLoc9X4?V~4UN*2Kf*>$?j+CfW9IID$;+*4=1Cw`oZ@iEKaE?MBLMIUT1`~Ns z3ciz4;3$XrjvOmju4L=wuVc%OYqh7ROUp%%=|jKZXAkVvV~2m~1(JxQbuqS~bJK@R zb8cGJuIqOzSM_nusukL|qL=PUB&fx<<}rT;@jav-qerHzdfu9@GtNwn2%abSzG2|p zuJgR>FJdk5I-nnslF9462>3xn5S37M1jRA~L&FSR`)=)Cy#Z7>GBM8hub!6u`~FL2 zjvY0b?pYuq5rO%+8IB%4Y@(>3#f~m5SC$hLI|!q)^sMYBEOt|$Ig*X{Q~2d%Rp)=^ zs;a6~Itnj20QS8gygDp*Z!VO&I{mO<(%2FdBQ13WN{CoFcj`R5Os+QBFB!y-0m zN}Q^s7OltVv(vNco|x6nBCMHA{l=R}Jnsf9voctpbd54(F_EE68?IIp>ukfIyL8b`uTA+lGQ`!K!hiZ;cnk}g=c@$G_4_C zr?sgx>NTkzpVE#>w{%pxaLzG5SJkP>LpptAQs!o>s#tMxOwwv)BP!K6AJje$d@28Z z4EQE+JnuF7W~(#ulLzjRBuV9>%dXH$U%yuR){w?Ajrn8p?2o>~)cDV^t;S-pA&N(A zjjD5^xVE0(BEob2BM(1#?|pywKit5Nc5UA=y#3K1{jiW)OR3zcBG76z5JclulJd22;PUBY7S5?Wadr!W<0Zak$o_*-Zu7wFh;N)#1vHYH7(#PwO?W}Ug?lVF{iAi$U&1PD1vh~wa$OJ7^ni@0lotK7^v^r$BV`lBfIDat^nQzTn&^KC%YE}bT8|r zfBm2gY&>7r4`$!5iGowBNs@?5nxsif)y9Cq7*C>7mqw*d@n5Q?71TPXPO&NK8mjsN z@C@)I@GaosJ^N^!;fzB$z}3J;U~sWqwn@UVqenP)^auwYx=(+iD57WOYSye9)YlAM zB7PX+`#xS!#P|_{5vxk0UKhkqWMo$+OBZQdyJ%jN04FDTU{iZFtcJO>WBU-D?Q>)I%)RBqfM<&K^m%-70klpuu zcoL|A98xjQi@JXmpe-T1ni!DFMmievWs%woct-U4HyEtUh=zO->0j) zS4D(oqb5$3xY@v3d!L+Qr4FFa87~!ei71VX64e3jH@WmF0NS4y0Ph6eorCCDq}UgC zWG~$_@mpFWy9jeux*oUyI0xtjRszd&P~l76@wWzGkw-`bSe9S952)mZP3!-IHL?pYw|XVdi%Wq^^5ox`*P3H(X#%VQ-ur*FEK!yuxQ&_s0000y{D4^000SaNLh0L01m?d01m?e$8V@)00007bV*G` z2jB_^4Iws03W5`nTPuGJaY;l$RA}DqnOlrr)pf^zYwvx|`EGOb7!1B+d%%FX7y|*C z0=7~>C_yc$M4L2e)Vw5`iXastp;YRiDxgv&s@n39NUho^khF@Tst=Hu;0OpoeIsTK|9lf2|QdrghtGw`~=X zZ%0wI0zmr@R8RDpiio(#$;M4%`A_($Z*EEv^tyReT7bO3+aJE-0b=TNg*0pL_PX=$m)k@z>wD_0~t1`kwu$9oW8o z`(Ivp<(2BLpDVK$_?DvW!le((ZJaYqgnfHfi^IjE;`7 zeED()hlfrJ!C!pddFM~=dflNXE21d6V9S;*Zr1}3 zJo>Sv(8R>V=^}Dwuh;v1YivD^VnXnsiii+GAk8we^2+m!J-eUf#;<&JeviMo{hO>^ zvzDMr6vsH{7+t;`V1sk+<~#1ZbLFjH|N6}zX#^%FCPpv6{PLSr^>4lRpUtvt^U&~c zHI5>go}Pc^-1E;voFxyT_@K2o=lIq0FYwhbfBBfb9(-UIfBYvm5JisD$Hs`01VnHy zB97yMB#FwPV~C=N$XL`^Viyr7 z32~B;#7PA)e_E|ptAGEkZ+*dhSO;#u{dRTE?Nil#v$L~7L%@4ar`;|wUlAjSF-Uo; z{fK}3+Yf$l%wGTe-S1GTR4~@Eckf=F-Lspgo_U%lo_vxgpLmizd-gCnHOZz;8;RrS z4?FGl$VXDdB9ey?egUlNwA%xDp40AhFvb+-ieQYvIahK4D2@v*+{QC|_u_p{o)=e| zW%RmT_U+$Knxbs3++_g`)LjC%= zxj7J_({59**XK{%luq;sEvO<|Mx!4gW55Uk7-LAYjC>xo^5Qj8*K?=e9d8YmL-`&Z-eCIpI?RnEJH}lyWZoq%3 zf-0tnFxD92D8k3S00SVXesBkNj&mJw3vj-m4C$M;sx!&anFh`|oO6f>3M>E>v@GnU zmNAw%iVD;cA+r{19U<~%@ds?=pp+%&)0v(!mA$v|6WpP=Qv4eOcNz~csE3Jk zJv~2IB2Ezjq$uP<36+X;2~jG>V6DZ75UjSny!$_j&J9;OIoUHFobbDw`N>VVHZ zS(?tLS_pyQ14bc^BBC-q0VD)X&VaZ?eV!M_#9&m zN?8LUT%t+@OanRK%TwN18gGAq0p|?X8Y`l1>)9*B8c5>fGw{^fEJIP7$xe*VbC5o9 z8H_oGJC@)SgR#d;G^>_iJ-N3y>rgFG$Ox#gE(Fdf#a#r{%hN8H2qcM(E*q}M@{yXv z&fwhQB)+;n!}4U7Bdrm<_wyWp27I2QWeP1NB|`A{c?dq%VO!RO7%6`mA@6a<@}>s1 z7{_P`M5R=)Gl3J|f-^n!InM5sbAM zRYG4*7_(#%n=;4eAy-Orv#ub-5*&gmE{TW`8APdriWnoY6HYyOP#U#FtTXDY5o3y? z?1x^V-va89>0b8KOGkg&os6iL5fLx9A*?P^2rZ&u43T>~}f-qhtTTeI^9b3x&NI^yBRjk8StTqTAEMc@@aCvY{5qjh`uY4E!ye# zNv=4-;(h%9QbHB7Ty<(Lk1`g1bk5g-g`u3 z9!`&gQSTSXkOk~5LKH>wkyBN!Hh1rRUk+qm^{r-CpV)gu+bJRUxS+=x4?-i!X=GD0 zOCyUy?h}+LQ^hTjLT=G#g&wj<`F;V>nz;9J>b=x6IoIXsmyR;sMzS1(V2j6MY!p#x zjIi>I%UF5lB^ZAbvFyde-2c?fd=fUBP43_MQv@N7V_tso#YMljXZLP?a__z5c|ml4 zaP`#;4G+IPmSN$DWS3!)G`rvX#*Po+n z&$^u2$jL=v2T$Y-8iMqhI7(vHu3N`7S8hMyf&K9AyZL|N-FE|U-_Lh}5wbj+?)i zUWZp+c#dZudpI1}|EdMZCXdk8VU2x;7FvS(K!bk^FZl#BdA4-1Y1#ZNB{LTE)u?jm zc_&}tfNm+?YKS-i>CZB)ORz2`OFOuv%Bszmv0>Xa>XIrU_q_4?YaDs=fIRy1`)JQL zk7XteqUB&K1jQQO9sidwUR4VYSSUHPNFryW_=>nbd`6`8ZuIN0dO8XB_(Ve)Pms>G!pgB%$4I zBg29_W$fb3Tekn%DS!zf5P}bV;^>Dfgn(jbx0=Zvkq zmgjj3u>;=c(rLG3X7Y$O28X3FI7A46x!D;#a`1J1>(D`&ZO*9TC8Q}?uU9A%)fAWm zo)5~ury1>+52wF8ZS?W~@KZEnqZb)rM2w-)7-Z8~=d=0Tt)Wt_11dht=(eZj;0u3` zF!jdE__TMN#1=8CA)u%f6)et$Y_)sh@&9@Fkw+iz;F29%FW$cOxhH>7$-SpmA5anK z^*RWmX}1&7ETdYj(VAci@iDp}fIl&&Umkyp#ZG;ZC>Y?Az*owd(r_7x=tS>X=V&yBIPLVab=`m1W~>oywdQEe zOv{l&2PO|4*nf|VP5gsg_0UZRffmT?D&|ema588Qc&qG<4+8%Q>?`m6UAuVSz&^f% zdO4=K5jYn(2N-&{_pEaa4Uejb(CxG&sFHR&c<&#PcbrlKI4KyLi-t^;P63Y^fbc<# zeuo47??u4pfj=*uXq0~g1+!Qe_@3Lv-{czKL0qEJb>)>iIN|DjZOTMeB3EEz5^oDFa8A}@VoW9^--<= Y1EGAH&FM+DivR!s07*qoM6N<$f+Q*Dv;Y7A diff --git a/ApplicationCode/Resources/Folder.png b/ApplicationCode/Resources/Folder.png index 57c2202b25080e938912e4a4d3610678039c5b71..662c906b08405df34e19fbe5cb5deb14ca5b3dab 100644 GIT binary patch delta 622 zcmV-!0+IcK1-JzviBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUaE{3gQI^ z2nq|KLC0E=Xe)mL97#k$R5;6xld-B@RS<^1S$pj(!3Y5fh^4{CkRqj(jjy1sS$SNEu*srmGL;sa&1Nwp#Z4#5QC8g0X%EpmB38KYee{e*5L+ z7mvUC*sRW(9jRmL;46w2ifyQ$CSo;c;M=qVE~fGCu|D|xVW=Iw)G`+d0rY<$Rxy@I z(I#RA5{iF7xz8>KxL3_Ik&CG{C>1nd+#o-r?0bP6%wWgAyTrLp)!Jdo++>nrLViKf zO}T*rlt{uNQEVWgaZSdVO5V)!bCEA#We=t!jotTw-ar!M3&@dQAUf6hv8o@XY?1)0 zCM)0#q9X;0H|h<@4doCqun|@@u8ZPg#3m^PR%Cy(fkA9&Tu?MbU<8VG%j&RgRGC~k zX5}ztf;_RQs7!`B=?iKH6djvp+3lrhbTrOXMegER0s|>gv?QCR;ab zg4;G{qWn(1^AKO5xF}Uf1(RW6n7}f~&FO-vfR%#r7rFiL8U(1h0^BO7ZU6uP07*qo IM6N<$f?wJoN&o-= delta 567 zcmV-70?7Ti1%d@GiBL{Q4GJ0x0000DNk~Le0000F0000D2nGNE0CpZUK>z>%0drDE zLIAGL9O;oEFbdoS2nI9=6#&*8ky|T&0oh4JK~yNum61J8RZ$p4*SYWTG|xZ+wb4jp z8~}-x3AL4kInX!_N}L5!&wr#n-zGgO?fj|;w1`gVPb<5rT z9jB+K&UbA`DFyF6v)K$uc<(tlIACjQ3o}C!wN_$`%;$5?zn-(Rv-8o%7`eT@{i`Pl zNnCxqqSi`EiJUW~6aZ3A?CQu*oTh2;LK|(@VPT2-IVuYz;iiUibq}a4pz*+n zR%@6*trcHuCFhJ%kHP|L){uJSTkJ8TJg0V#G|#3udx12dq20iJ-}ChJgoQP7J=lo+ z3axr%EtUhWiLeN0+C%PW>ah9!=+lvQcXu_JOa%N_{{XQJb`T#OA~yg4002ovPDHLk FV1gvX{#F10 diff --git a/ApplicationCode/Resources/InputCase48x48.png b/ApplicationCode/Resources/InputCase48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..c91c3721d9cdcdbdc3106c33155fd144e8b0388b GIT binary patch literal 3889 zcmV-156VGd000McNliru;spi?CocpRbT$A003B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*01lN&L_t(&-p!eNY@KI) z$3MU4y`77F?AUQGZS36Yq%?8bv})SX^x_mUw3QADnz(FGkkBYDgOyDa+J=m@0n(sa z1!0qh0Buk@${5nvR-6)`rRkMRN^g`78aH;**hzhCpWFMs&-2?K?|U34by7-GvB!EO zpV!CFdA`5P_xJt%j%jo^S(9dVk{ zN)j4zOuf-yzE)>uc9wdpMQ?8}%a<>w(%rS*IlJS+3okmp@4Mf9)jVMqzi2g^9V=I_ zS~aj?T_KJWX@^fUj;S}B3zwarukqjm4|4g%7qj!S%Nf4%O7`EspM&EEdFYWxa3b{e zt>A(!TZV?VZTrOEe&Q3iys91;9Ua{?JUqP9T6;rJPtWEsjQr}%4BNJCLwt``9Mg(p z;v^wX5*|J9Q%2tRzLO66!S}w$o8IykM1BXvO|jPEtmTVe{pv{v-MZ&L>z!$uQg1Xc#$@&v!5D+@`*|$@#m8BTvspN$X$HV} z9<64RgX81GaZD1&BymELCRl6fEO#(`_0@P7TFs{So*QrUzVziU+gAi248ycmt9@Tp zubZEr??i+~y-vAYUdRHIgJ>7DPk-uDeBmGe=|zWq=+8gGo8S6Yj4{MXLYgEbNs<9f z5|TJs@T@vVD~?}z2z7RL+Ue=({i-@&tyWQ0k|b%XgFGQ6vv|8IyQL+Ch~W7?zAC6< z+Ruz33<7LuGcw3o&RSarW?vD2n{U2ZfnVKn%PkYtYV|zd_wju{i+NxXspL6u21YO* zVGv}jB|_qPc%F|7GVsniyugQCmRM_RXH5$^=k}}WYm6}~7A&e+2zkCwWIQBuK0z2P zc~}&Mbar)N(-ddzLT)VHZ4X%IaMp6x0I2GZoO5rq)~=8|Y&44tM1)KU<%;w)qEw8* z^E`|Q&hs#yhwuBOi@+E!_keSmAUum|^nPpYkt9jBipWCPAcD*DqWyuXO_w~(rj{g* z7edWBhqDf&5C#E39-g_!v1ii*x7~Kz3psFh)u^gIrmBZrUUiYY5{tJ56?fb{lF&- zL!u}oh$4K?M-_G^|N8k4uDk2~V_qJ;Q>ab}_8pot@eA?u5&SI0~ zMO&@K^E|>ZM2vtcKJn{}=-&Xhj*alPU-!a;qo4H#M?Wh|c4W@E$5r)LS?SL&X$0eW z7*$+uc`@d+No?{MU!YtO1TdbT6~vqz6aruc@CU$-u@SBW?%%zKuZ)c#yZ3OW{?!{C z{j3Aj9~)tf6|e58orixu`nCFde&JkZamcifF^0fDfz>+=0N=~%!0DFcU^Hj4#CZ~V zHUI{I_W+y5Mwkcg1&%Fs#xF)cXip8HKlaqV6}Setu$!qlm$oL`9>^Fet7iHe#At5q zEN^lEs1ijeCm&e^UJHB>`2DdFf?re2ak(l1FaxAR;ZK(RG#)h0uE>;-5wLDSN@uEc z>BHPfGGtNp&Kn$Wk)B$6ZkJ4qHyxRwWD$tp0qzHOjg4^c?mg7c2*3!au+}*?174pu z9j){_yC>WQ3u10|rpnk|ccH2TVaU@z|M`-KJ$B$x{^vixO`2wPV%O_mPghr0u7|wL zlR41d?h;*vUTM`DdU&d)^+sxPX9d8Y0e=Ym2k@6?2H^3$I<^|0Ugro3+VZ;0jQ?EQ z%mPud$i_{B?7r&iGrIH6JMQ4lJMI8r?>+a>S*cJc7Eg?2I5DCT1D)ka`YJwsy(ND9 z*inrW+fJ?mumQMnY=j-V_b_}~08v1INCl+~Dq@WEs1;4!LM1Miiny0q_EVdZq**V} z?kN`7Yf%jPz7Y}FxVDQYpE|x;Kmnm)I^CN zJad9M>h(I-zB~YSk^T`8{2;*3X;@F81J5%o?M(#M{f zc1}+!vI2C9uv6gju@T-2I6%zl00ffeJf~nX3Owyz92TcMZ;vMBlo0yXeG@O@vM}`M z>nX|39sNe#l4NIq5QuWdDl7@Wh~kOMFD00K0%p#%C2u`XdG3iUY_phd9s0F>hn6Jd zz!$FFIUoXB=?D?|wfcc}@~PGuDc~eY6Aq6bT(IKVSWy&Fuh%JpI7Pp`e_XG7?SNS- z`mViVK*lF#>0jN!#Pi3QuR(f>43j%=;x;4vo^R+ihR`?o6ZJ}P@6?c_ez&w-h{58K zU~mh?Q^a8W06#2XysVAP+D1#7#F;Af{CpUo*fb_-)KGQA&akuN``9$mvTt>HCvyE2 z{c<{$n<>>$ZSQ_)k zD4LYmSP_9kFQ8)&J;(1}Hn1duATW83l&Dl3t55A4-rhkxk>l8B^rF}9&| z(}zrRZd%r^>vtNOs723C=m+nd=sKvJCF$VEHq#mP3rmK41nyxd>OpOShC-}Z$ z;M}hByz4JwE$}*^ACZ#D>%9p0K|~OhP;~^wG6O@y3|;$f?OweBR5&s*&iJpMmi_zw zOJNAR!Tf`MDX69zJZMsG!A;E-hD<6BIiLqq6j@>?bUCQ=d7KjrUXdYkX@&LXU=7`fzvHA{l=R}Jnsf9voctpbd54(F_EE68?IIp>ukfIyL8b`uTA+lGQ`!K!hiZ;cnk}g=f<=ts!2g zwW&1fHK`t-(vC{EbX2-<&M`k%)v3utI(=kP=4Pv^SaESo(rRTRD%Ch2)IJV;DgS*8 z_$F{X?=|{nt26SG2kwz1N#&x;uFy(fzgGIzkj62M`D60zkG{jy_|LGd#$vG{ibrgX zs&k^aww~W2!gKy34?lSCefK}yz>juq-!Z)X(I5S=kXlQr+^HhaYBdl<<7UIfNkXw$ zqBcKknvI4bn=Vv=r+}lthk-*to2{=0ZUoi=z0O)wePNmhzJC`%6tQXRb}5z11YtqT zl@$yOU4)g%(Ijbr7>$Y@QYd$;9~DXBrX=;M+9VM%24~|~KKurMcM_-H1j@O1 zQ{#DA*f=M~7(72vV?2w9qE6#h(^pl=t$R4;%1$>WnjpZYEnJddT?*DpSS+jYf`c-$>m@ox zG3t9p!6<@rHnq;V7^ni@0lotK7^v^r$BV`lBfIDat^nQzTn&^KC%YE}bT8|rfBm2g zY&>7r4`$!5iGowBNs@?5nxsif)y9Cq7*C>7mqw*d@n5Q?71TPXPO&NK8mjsN@C@)I z@GaosJ^N^!;fzB$z}3J;U~sWqwn@UVqenP)^auwYx=*4gqG#o5)~p-U*9=`Eei-8W zK3-77_z{8;t4gC@7sO9wWLG9j7in9&XkL^6Es#3s6!1hoF}NFe4rnc9^(DMufSthm z^Txe9_rw_+chC3f=;&horY*X5@O(TYTC2@dtIo*Ok%{9+CdO}QW5~zV3 zQZdhqx)q=;U^8soMNR8pwAgE6?KUyjf@i20q!@s^eF(^pBDh{1m2y4=vbuK7k6YY-81o9 zS|hs%b5^<@xBxf@=mk~+%X3iSOWpCe24Im#1Xz||x(}%2tTha*2YPak$*Hrl6HV*? zgEg`XFSmLn&x=ceOY-F3nAe(PZD|6m0^a+7v@B7UB)E;500000NkvXXu0mjf3cPW6 literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/ObservedCSVDataFile16x16.png b/ApplicationCode/Resources/ObservedCSVDataFile16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..1413da6369a32813d3e52064959fa97354396c5e GIT binary patch literal 629 zcmV-*0*d{KP) zF43WoLYZl{dW#ujLJV4SOlBH*=q*O#Y9k%d_C6gpHs5@szVPtl$MbwY&mVw?fDBy> ziWs^K1iA$fK*Z3kZ#MQp4E-j5NC3ppEe0`kk?dU6SbdEJ5kpUHhNxR;**UrghEcqy zVcSkxckg24&LezY4`@FD?GP}y+4HeB@>;q!{;@8<$oi@*#3KU8?BqR3&W=e^AC;s& zDnP%rv!P4!eL`w7&3cH4JfD*FYga3)eT~-umKBo8`T9pu>JgsiduW1&z98ezq97)= zH}H3MutjeoY`h4O4|;gqHUmJ}{9zART3)uABd^I#+~qFE>C zv~+$NzRc=T2Tdo>bHR6u77jAb2$YKUfJ7p}p4NR3(Fx65VWW31fit)9slC;FrS4Z* zu?Mub?T5E9qA!OjbTu>B_XHIWr4q#B5Dr6!7n}~U2c%zxSu9S`c%q$4{dZB>K`I5Y z802!$(*uPSK-KI4#^**-pHAWac7){>7nw|kve|;$Jx?IuMOD633eA!|;QEcjOzQ7I zSwhS-zT+;+r6Sv#T##R+kY7X9G${Y&h>9Yd3;Ow|q+Ivdq|fqyGJ)yep8^RU3VaL1 P00000NkvXXu0mjf8?q7J literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/ObservedDataFile16x16.png b/ApplicationCode/Resources/ObservedDataFile16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..6de9304592777e669853bf53467c4e1641339201 GIT binary patch literal 602 zcmV-g0;TaX6H0HW(EdnzlA72(klXjSz_tI*B3u0}+8x2OV_WQRfkz zMWL)(wpuY{>_CKu8^UZ0gj$_M(~a7T?fvM$rH&r03m$HG?(6zJJeNdURyA$0hcs;i zSC_Ah-h3bhF5LTbFYgsX^=!?xp9bi@0U&Nw)6=^HR1Y}zLDv8{_k-OB&OT6_pl$%_ z2oT@0cZ6O2?db>003=Wx&}slsD1Cs|I=~1p0VF#Bg-^c-od~x}*-?pffc}M#bibO% zeQOfz-3Y(1v{cv;lD1DO$$DZI`*@6*mszk(F(48S{axgIhUV)8^_ZV0gL42F<_|HT zT&Z-1Gw-O)KIBpGF^QopvfT!NV(URzVk8{yc=>s1if^YCJm)6461+_>$C%*`=$aUi z&*wRK_y}auB<8Ns96Lnx;$4FBSbM+eYZ;OlFg$n^7II|Y+@x``hxqtYWc=tlEG|MS z1)%`g6iWpOZ*8NVnQpkiHUIzs07*qoM6N<$f*FYaJ^%m! literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/ObservedRSMDataFile16x16.png b/ApplicationCode/Resources/ObservedRSMDataFile16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..ea90a21d80c0f2b61d87380397ababf25dc6f096 GIT binary patch literal 633 zcmV-<0*3vGP)Y5_}U9{R0s~P%nDXpU^)L zy^BIyxz?>)j2II_NZc^yk3gtf2+`U`IMVGty|}YAyHQ^_Jm)+=KIb_P2S5P1IB-hD zGG#d2Bbz?4%v!seTolW^&K3#4fwtW>1!9>ZtJA+=j{lvAWu||JXq%AWp*_xKb()^x zag_fYY}@Jha_^li{Rg0T0Arf~y<*iPV_In3g=!80aH2Z|9-kAn*8xan7GWa?&;bkq zQ5{eKVwt2qtRo_oo*XN-4N4);rdXSd;k_{e_1oF{1OVpdQq_Y})n!D}TR> z0>pL)gt|KUL$BkkJ&%y@Z{XD(E2KI zCvT&y+yTM%gYYIv;>9?H?qMNp2Tz^21Lj{EEEK0`I348D&>b{( zkWND~3E3?4_CjF=&~$fz^{IjM$Fump9b~Gh5Q1A{8uzxhw@*BsFZM_Kg2&J00000NkvXXu0mjf-%}MM literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/OctaveScriptFile16x16.png b/ApplicationCode/Resources/OctaveScriptFile16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..93e7d25d07b9a9c108f093182d2d6015bba98994 GIT binary patch literal 618 zcmV-w0+s!VP)O!dMthLeJ*%-n-|#ckew<(19%E zBz;h?Hwi|pMV#7Q5zpNGyRY;kp@lc&y6u8vjRDiLkelr-poJl@10rK!L_xQ}7y;D) ztqEu;V0ts%M-Gm5Vhp4U2v7sit^kl<_yp}TKnj=yvVH+ALPHqbTdI;M->0E2#tZzVl$FIJc>oCnNf?AQm7r%cuCKBC!(&RXpZ?!6-vb_9=l-t-iO+4k=v5SJ2%0634&gIbsI=f? zD@0PSbr-O{zGWf+G!*LJ@&wI;ARVNX2y+|52)@_?^d2R&Q2va|tq~M$aBKjC5S`m3 z8?M&71oQY=-hFTI;D^b1CBcy{-dc7ez($WLq%$P;M1& literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/PlotWindow24x24.png b/ApplicationCode/Resources/PlotWindow24x24.png index 6d7f5fa745756bd2c945e1155533b095c93f27f6..555a43eff19b58ce078fcbf7bc5b050929904542 100644 GIT binary patch delta 1145 zcmV-<1cv+62;vElQ3~P(1_?VY3~xwBky|T&1V%|jK~zY`)s;_d6lEC3e>30A&hBiP zvQw&y)N0Fu6$u6e(}Pk16e*2{MnljT6AVWWCVDYZZyqr5pdR#SQZGW&Q2e{&tXRxLgU5gG_CAB zZ%*jktJY)cAzPhJ>hvEdk|YyVY*fR4L{&p5s>0!41~OYZHa}foUr#6$s=!cH6#(D& zQ4|FL+qSW7o0^&$?%%&pE|+6qU;x{;kt5+S+3{)Y83)-9XliOEtcA$u^E5U#5|77A z+p;XqoH;`}on~lgh*&H}Pfri=c$~T`X>y-`ijIw87{vrj5;DN1&9AX~%}XSIT9zVY z8C}Y zj;fa>0x%2%(=;oXa|O160y`WfopN5j@Gc(o0nB&+Lr$XZCNk_cd8Vgk#u za2%%uHkXb6dmmR19w4!88`}DR_L4msjg}b%1ax$6sVWFv*D+1A0#t~HDk+)da?d`V ze`721`c3?F8~#bQ{NMQv?$y^~Cm{<)iH+Fs#M(Dyd{;S1Z*R5hu0`J~S(}p&7)$XEZBF4KbzNKD&dbW}w5CotE z0eGHY^#Q16kWBK|p564mIY=SW&)dttArW3(k)IPMd{(Y}Foz^iCMPHOarbUCO(Qmc zKCb6-YwQ+^qF|aPj^iMNVB*Aavip13^VTUkmwe2cC*P@H=XoBzy#d#+mwy1DL?RJ3 zwQsx;jYe&N!NI|1Aq1{}>tb0}u~d^uZXN95SlelKKKDHh^)FW?{oFah@UY8@6$0Nc zE24zd5NFSxT{KsJ0Mj%XJ93yOayj-a{(<*f57AJ+x;$MShfGG{+BJ`3$9z_;lGw08 zA(zV+B?>@s3J&Ymtt&ZYG8xXFKhNakBzOM2%;?`I*<1G;J3A|X!L!+WjExD79PtQ( zfX+^z*4CQJTuM^0iu(Hcsw&8JU8eevGP3jrTVMRD1U@|MGdg;kR7xijky*Z6roCOQ z@XzP-l@iS|5JE6AGD0eq!Y~ZJJg|h2zLAr^hRNqIqG<~#6s9nY1{xYhNhGczM2Nn= zqFl2hB9TZGB?1&=q-q9=q7aYA`REe`RaMb-9a)}_5Q0KMM^zWl5JWRsix4hH6&ghQmYB17=`w+CLj@o2-XXsq?p!Tph+V%wB#Xb@>GZhgt$sy zTy5FZ3#4vcgtSu7gjAGny$tT|%zS;=bam8(K>CscAM<_xbNT+~eCIImw2M^V_MOmw zbPw}OF)Z66wi+X0n%K5r)f5inxCNTx43MS*NW?6ObhnG=cX&}0g~Q>SD7ubnFD+15 zScGNUD00$!`rbU!1}66w{&AeMc4lm1`|_@5Q+x43I&m|G>Smd3L`evX3{N_ykcevw zNp`xv=DckKb(S~RV{sj})5GX56R47ZB;!?MxYBpva%re8l^+AY%}oFC`|gg8jwh=B z&`=QBotDPjfcoYdql8^yPO5bJwn{Tk! z|0;?sqiLFC7{-=PrKP1zO--RF3UhOF`2GGzW}%vv#qH5yT%NTO0aR2}5C{Z+9L700 zIRI2uRi&`Z%*=-dH!TZU*Yr&#vTd90?(Y9(4pf1l?C22(Xjzt2Q&U4%SC<3df8xC3 zJa(mlpMIUDzWqiDyLh^sL;HOHH7hcREg$DO{{cSw;(I##MjXNGDhsHqEC8UhZ-n~x z8`M=6Fm|PZi>J%E8W`pMk2}|YGT16DUDxfe8&6@HCi&Ive0zPEy2=7RJo1*qZX>-^`Shl!)~*(RNn!z5SY)Xgez&R~nldg&K|i&DCqy z&~=?>wr|I@Oz!`6pMik^2iw`+9!h_{P5;5y$vxBh_>b&%yD53+@LjKe*Bb+voSgJ2 zin8_KJOmHq=TdenjA0mfJRXNm)?6B6V`IC5!Jsb~4EpBh=P^w))$?1)-M(G|`MCgu zKmWw>br2Gu#uIUhi;Gj>%*+hq*IrMfny^Jed+ z>{ggNmoG8=!Fwrv?wMBZT)sr;{8t=kXeRSu5i~bLYwI}?jYdT@8Wl@ROClT&i Y7eCnvf9=ypuK)l507*qoM6N<$g3Z0}kpKVy diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 218fd89637..513fc55b8a 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -20,9 +20,12 @@ Well.png WellCollection.png octave.png + OctaveScriptFile16x16.png Folder.png EclipseInput48x48.png Cases16x16.png + SummaryCases16x16.png + SummaryEnsemble16x16.png CreateGridCaseGroup16x16.png GridCaseGroup16x16.png Histogram16x16.png @@ -65,6 +68,9 @@ EnsembleCurveSets16x16.png SummaryXPlotLight16x16.png SummaryXPlotsLight16x16.png + ObservedDataFile16x16.png + ObservedRSMDataFile16x16.png + ObservedCSVDataFile16x16.png FormationCollection16x16.png Formations16x16.png Parallel24x24.png @@ -77,6 +83,7 @@ 3DWindow24x24.png 3DView16x16.png SummaryCase48x48.png + SummaryCase16x16.png openFolder24x24.png clipboard.png Copy.png diff --git a/ApplicationCode/Resources/SummaryCase16x16.png b/ApplicationCode/Resources/SummaryCase16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..a878e4321a4439336527e87d154399b126af3058 GIT binary patch literal 881 zcmV-%1CIQOP)VGd000McNliru;spi_2Q_LtYXtxR0{%%v zK~y-)ZIazjn*|icf9LJnFUq>kGN`ZjA%>1b922T_TZoBKFT8c5YouOW(f78>5@!xj8vca-Q?c z$zf`0>YDy1TU9InRMpd8YyOSbRe$)lq^cckAY*!Z+PtL~zyO4y0scz#(+0%YI7wpg6$;Uv#16hk$cO@P{yZd;sBJrq4UgE|)M)Yj7^C03#f?aiL)~8xGNM=( zjE_Si0pU8!(NHzl)AK0xcMzn85}rBh4DP)T^U^c#W3Y`>3dY7Dn}v=Jh&`!X8u8Xf z!+dtQolQ?4<@mn=iwm|nd-VzY**4~W^)Nd-L#0xK-=88Dt3}8#KBnB|w{aDn4%PA} z$vF3wEA(~u@rM*oK2SdOquacab5N-ixLNk;;?lBus<(>ibhC0fEmdxZHiiPy8Mbg) zd0kq`i{W5ZV9{JFmWo{u7JU;J3e0D2N-1YcLntKMo7-{wg5*|1dU0Yv%DI9zZLbxN zD<}cKo6PEsZTYoIjr1Mjm|<`j5HaDA*sEBsEqeOP6BP0}Y3qpD_iy#`d+MBFT7TM4 zwFD&)s1j_YSh7?`KYC%p^lsVX^#|4I+01X3=1C?_%6h4^B*JA?c6S|o&Qo8%Q_|n{ zOE$BhZWA5~`9;)Tkhh=RJRxH25fN5$`<@NQCfp?D%lZi(;0=yaC)uQcP2dMTq z$X#2Zn7@w8Q@tkfC>H@2P!?g{wmIf-7+-yG)>eRcl)Hfws&tjtarrj6sNWr7N4P<= zS5}uL9u=>OREgRZ+a~wn2$laoOFW7Ij{!YEr`oiL0jlsfiFr^^oL4*o00000NkvXX Hu0mjfMAn^m literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/SummaryCase48x48.png b/ApplicationCode/Resources/SummaryCase48x48.png index 96c327983eb48ae3dba42662e77f8bccf4c0beb2..617d910f432ff314b2f6b20b34ed6403581e7e4a 100644 GIT binary patch delta 4180 zcmV-a5UcO!A=e;~Dt`a~0002_L%V+f000SaNLh0L01m?d01m?e$8V@)00007bV*G` z2jT?=2`M9!BNdYX01xCzL_t(&-p!g>Y+ToQ$A9PCZT1wm=bd39=MHV}Ce`Yov1QB(g0>maUai zM2efZ&vIw(+y5T1e*ZRfPdflT)l5PzxO)=0;GV4NFc3dCau@qq+Tzhwc~VcadbYPxURRLlumfS z<-Yjhi+}XwlTXUf&`{uc-m36wg9TV~&u+M<*LNO|2dd)7JIipP`(1quo zR+-`9ExCL-^t`}%U;yoQdq<`HfV}w_)kk+brr84;=NALy*p-=$SYS3pM z7(gbIA%CCGQ!EyLQy03Y@OEK=G^{i8!yk~;>*NOpC?5SddjG>vDuLFkR`fc7|6l+B zMApZvhR)2F>iy4EdR*9}%p>ggl(nf>q@E%IXjuY(KjZ-LtzOz>YSs?eo09vgU zVHi@c*YSNH$8m5R2d(uTVMSye$Pa)p29}peet&h2*l&%5a*er%s+N%2UI63Sz};s9wuj~UU-w6jdz&HP15Ms z*qvQyaXH@iXZU`B-rRn2td~lZAx$AoHO(emyJpeaI9N~4z4pS_1vVCV zKsgRd1d0a9o!l zlR+B;w`Z`|ZxX+AnT6_mT;6_x_Rb6+>-`M9m7{FW@1qp#xF<_6Mt@PSYsSYd*REMw zEn(L#&6Y0keG8G$=}HHIuK@c_kI(>K1r|1w{Mrj&H|t#JP6kp6v6eK7@M{g2Ss=MR z&g9ZLZs{?ioj#@Ad)c-1I6DiE;Rodp5H*n%p;t1oP_M(yo5GbVLKq4=cPb7XQ24IG zcVpr-TKj-3@X1c6T7Nn{!oQt7#eF%mR)FJq6v|}+#~~UYr+H-*rmM7~8O{~YaJBaa zeS=T&Xx|^Ot^5eSU*4=dlct6^wltfrpTqw;} zx;o17fWHR*5cmP`xAz1PwcE5BA+5Ouq!|*;OfkK9k@4U%X_v>o!QZ2I$K&*MeNcE1 z(ljNC4DGgJet&-D8Xp&?rYu2VIeb`g@Sq}>Qxpmgz7LYF1dZpp^!FB3Pj`-U@6Jk` znAIGX0d@mlK0U&*lc#w8t^ktM5H~}T*(p@CL_NJlJ-bM=A{2W2*gg0R16v-?RX zmZpM;B}pt%WN9>Dc2-ziRNT5HG@DQ^Yj*E;c=S<4ntux2-R`RMVRBM&`?kaKvV-etN+o#oQN_@ZB9{Z-U%A#B&VXq_8m{C-N3*pn zM?SkOVSmf61+mJV`+-02-O90-zQ%i>|3|*|KA~|maROsA5m9QHtZYH+E;6;l)EQ=M zDZq77P(rI^Sz5Bx>j_a5Q>|KNXC2~Lk;@s5AI|{7z<`JEC**Pv$3mmAqV&~-XX6IN zq>W?KJD7Y=bL3#Jsy5p4?&W!FWnD>BKv5~4R)28(^ax+=4A_*L%Xow~%i9wb<`*hR z;UI3V#Py&HM@N{njzZ(OIjmK*+byisI8G7IbMgHq#bTZA?qz0Y6I|CN3>~sr&{{}S zg9tc|11PMuWPC;03E7odUq^l4p{FaSo<269{^#en1kJ{NSZ|zUxQny5u#siHX;^Lt z1b@onMwUp|Fg77cA_T#43J8KV5n4M0L77a}L8}mxHi%kv#IB4)t<_iyD}38vk~Z2| zQK(oUaE0TChqyS_;NeXI({mM{etJ;7^7^=x3cjj`F?Va2RrsrakR(wwBTZ^tl+KXk z9>%&^1cxY2K{;qQSm`K}77B&u=WsojxPN+?Og=-tT*M1JL=u=|?eqE)>O7%?~m+H(F=IZd%bK~;dk-<&b&EU=wNn+`$WC@#XYK?^P z$vR1D5kURZSNJ;-zNldPN_UEH1)cFw2r4!xYu8M3l_po-&i37pF>vTP@v=pU<2J3Z zu3q}?x9#-Q7}-Kei%DhA!;i}0Cx4z+#Zpmh++=a$ik`gqGZik+pcGhZ?zDk@71YUN zgZHIq##)R4Yb|e{pL)sp-NR&nK7k&Aq6i+KQ-ezFN@KcaG(llYFGG)imVtxMigJC4 z<2Iug&-3c(AIikosAG-M?N(F8?MP-O#+=(z6ROm;Rf1fBT%jV_QWst(tADI9#H|nz z1*k?FnVGN3p8m4BckiQc9EIy@26vYCIA3^-hk(xj11Od2oX)J|XE(s}S9r3Q$uoHH zISzjMOH$df8w92&#~8nHMZNaQkJQrqtlmIP6+ol5%iz7}yE&wtj>SN3Oe<)Z6nbQ&AHY#_PfR{VSg zKgd(sHlVy9Cw{K7;=gg5(W@7E{pA-mVyG`KZFYum=g$}Cra1fB%TB9x+#EP~gwoal z{A|HCZjb43>=Le@#Uzo6Q&FiwnlW;7z9#l!O^R9AUefC5BmJ9#aesI0J$B&W^MA4f z(AHY4HFk9(u}U?qwFsJKSR;-TH9I{aXV3gZwZa-8qLfk{?I)eHuU4mm?(Tqb8`Wj! z()l-ZCYzW22Oqb^?g8z%fy8mB!nq0Nr$)g>SP|7uP;s)du^A(Cb<5S;RzP%2}srBScS+|-23&rGR$ttx_1HjYW! z?G*+s5_b;t-UI%*^ZhjNeP9uI4(O>>m(|<9IHQszRgXRSl$3e~q}0<-8ppI63+m=u zKW1+H0;b(s+hZ%iAvRjXS|wQ3DGDD`id*iRZ~XGr*M9y+3x78_@%XXlAAjeqpJh^G z$mNTo6tvqd6iVW#W#c3vo6Qk6YC3AQ^a_cQDsUN?1-=1HbPoOiz5sj~7y`PjF}k`m z&o6%Z5?&Cn@8IJqm(Sz*8OfKnF?i@xxItFUj=n8P(gLL=$QD#4UlBLRlEjfpnpH7L zqLkKH6UXWspMQ5xCUN?GSn1f5QlcGa#cixrT5BBF6RjPCQi52C+mS0Gs-xXAo$I^6 z91x#+1sOSUCk8$b{C)?_wlx_|hK3Kw6Q4Rs|In}sf(+KAq)9~FtPw{|>WfogtZ2`} zq-|`HU~CG;C_kGQ?RaBqy&!e)Xn}J<>)!^^}*|ql(yue2ZSTT|$iLyyVnzThs3~01=RFEr6 zkSi+pekYO&G1iI|Op4f+h%5o4z$M^6fj3UQLhBySnCJlP1%`pWYuja$BrMF%urNEr z`LnO7Ab$wx+TKh5&|Z1?&{5_3KCbKHcv-X?pwP;Q&}udn%1zYBiIui=4L3Dw&U_P~ z4XOz;2VCq-3|Nwrh6tJZubPrJKWUc3cT|igIVrs*y4r=wp{Qt!oIf2vBdZ`l^PXI?d!9U!oH4Ce) eN$2&Qul_IH9Jb8TxhCoW0000y{D4^000SaNLh0L01m?d01m?e$8V@)00007bV*G` z2jB_^4Gkgu=xllb01$LZL_t(&-tC!da9vk*$A5dDbMCn>UA-T+Bulm|*|H>CauP+c z6FW8}gqVcDmp~u{=uBbo3}iYjowPF@(rJe&Os1qIObaa?I)9n8fe;`B5*){|<2VU6 zu`IviNU>x~vYuDc)qS4F-u<9sSxyWN;Ff-1&zzY%clJ5^|KDq^|6Xft!8IC|WtA(X zw)(!`07L-;&|Lc=03XPjrumk6t-k8It_`f{>gu}ww%cx7VVb6$N~JsiAp}xN^7%Z| z)6+~%O))bwLw_t5qq4FR04XK4wY32B_4T2(rnR+|cs!2hd1$Q>LSR{zl}e@3FTM2A z>4AZPN%I=+i~&S%x#gC+haY};V>ld+=5jgrA_2>?NG6jUKYpB3r%o|AI7oSUIV~+M zXsro_LiF_X0PwxKsm6* zah&y&lasa4Xq3jrM#Hi!!!%7pN@;{bA!BT8%m{@-Mr&)U5s$}>>FH@Bl}Z_fLcu5$ z3Pv)SG*YRQQCC-IbaizZQcAolcwG z-QAZ>$bV+Dhr{&u_Y;f7XlQ7luC5N(buo;0?{PMp zbsWc00N0X$2h87e(@mLs@4Z)V*|Ozb6T;yLEiEk+#bW@hZ(B>qxChVkFbo6V^ALtX zG@c+)T!Lv@S6nC&3lp*ypkGS@J}}?e*_pZj{(t)^D=T}~1ltZ#Utf;~=F)jI(9qHz z2#ZE*FbzrAl8f&+o=+y{ptME`u*p`W5TI4e+esz5C z+J6!-1Za&Io0t@1d-hS**v@rZcTiPciqtOghz&q8mF2}lZ}RMc6C_hvmQ^G$q`>nO zBU5uU*H^M-!%8YkVvJ9xICyf1BWH$jJ)eq_IMT2vWYgpd?zJW02S=8@td*js9*$=! z`SLe^LQls^Hg`0#xnm{s*#iIY_=~)7@PAEa(>YojtJ&PKl6cf+WFfIz^ATRNNQX=@-F4lS-bpMNdjdj9W6VAoFW2L1x*1c-$&qZam=6G!;=Hy;sg z8*gIk#uh5e5}Z1FfxM?EwP0PuW%;6< zd=H@Q0Aw|A1F!

q_7OnwnPe!H?g?jvYG||C0fRuyV;BJB)B$R^Imjne#&=4?SJAAdp!+uXI2I$s!BL;GpKz5TIEDe$hH)B$xsW#H>w!SBYv zbuo;Er@R!3i=gwSoB7hiUq?u5(cBkzF*P&C)TvX%8X9T&{1+Md`7?~|d4c@+_^$=4 zJP%bUAT0|S3M~>)zHgzmWdipb+Mfmnfr(u^nE^_GRX{gT3akZMfqw{K3$QE;R@9ad zi&?}Y2E$38(qRYNw%_Him$`vnIJSggfLu6ng_OUR!0gdphJN@Y)myf)`~y1{zv=tF z0T`wb^k|I*%m(?4AMA2d0A2z`rYSKDX$YasuC{7nNU%efJTPQ=fWw8+3miFegw@S! zDJm*LE&(SEV*$9<_zauG7+W#AV}B>^w)d6AFY z^AW!Ft#7^iv<^qmN-Y2fwDR$@S@M$;%=Gng`q8g*@{zBSAAcW1IS!*QJjcwD!ypaj z`_C})+%u3#W5(jb2rO+%gK@2BmnP*(VQGz_HO55|05DA{!nP?&io&9}$i^_lJKaR* z3Z6=3U3@KMI2;zHX`l*um`Rcx8pH^PnICuyY1`Npm4GH%TTjJ}oA7d3MxTF{(dU1L z4BNQr6v8x_*nj^Lne#(Lm)GLV&TwJ(FDNQ2qfpmCW^PUa%Cs#kgh-%?ffhna5i$kK zsuCg|wS{3yZ5mQYDG=h4tZ6_ijnZ0A&KBGQ$0zgW#tCJ7P%U`2@SuN?ovz&YC zzZl*9Jj!vg5(%QUbriRCEL1?(_aMU&&i&vChJN_p6n~~CDedS)6&$j|=a}j1MY#^8 z8#a<2=qGvj5F@b|`PvnFX7KES1#awG@#*(aL|+zzj;B;6=jqvuqmK?GoxF=NmnBwT ziY!~UT(q>TK_;g-_Vkm?9P7gfM~FA9B))1ji8ZYhuWLsbCc==Ev~`dh*@BnLk{caC zhHNhEet!h%MR@88SB{=En(sowfNs<&*TqJL)-GGycDa!en3orzcWF>&B!a&u?Y zZ*>y8zSdKzy#CecNu702o{y3=;l&1@FodPu}V-$x^)VOd0r6U-JW>Dj)Gl0*@u<)5S^B1y)E`Q_99&aHp?_@bmL zrEpyrDdoa}a&d#K5Mpf`tJ*hQO4F6X&F3)<1JklF%gTvu?BYbs!HqeWk~tkXlILrk z&3hDFpPb{-*Pqk{50Q7l^OwYf1|ba*OMg^Q-q@i-l^f`=6XYFDw4{piiXy_cB}T`m zwOzW5eNXFIHet3kx{HuqktEvLv)mLBT zJKz2`JMO%bdq4Iu0OG~vU|0wN=F|Jn{gV{jX-dj1laK(@GBGoG5Fk@|gy$o)zJENf z&2Wsey0yA?O*e_^Rb&cUkB?8|c}ira2KAiPAm*h~7e+7e)HAP(2kz?BKl}Te#RvX; z7YAS4&*T63UB*YxbN7etpsKQx^XG>6@eiKh#EIj4VB2PDckDnb#esdhdFsi>u}#gL zcf5~yqLiUG`*6}}JP*WoKf~9w=6}OtAz3qpAfz-hY$4DH$44l2sYfV;BwAce^{P(l zJ8sohq)0nXfeRPL#olLspvK2XC@Lo*XIM6{Ei7w6wTO(v6J!-fsi)YPDqVqjo^x8Hu7nwlC~TU#-$5P#|UInMT< zB0n>JM*Q0Y+y#6($a^Y*&^x7bX~4xxm(kGqeri@WM)RhoBbo?GpVKRQ=JGyYh&rvl2Md~OhK`- z(!vDtLGl(w2vdLv3I+_*#(ywFxK0k!j!?UH6RWPfLz{L4<@sC~9%OQSM7;LWb7bdJ zvN&?tIx-RhCpAoe?>-}LZu0NBty4wAw#dy-i0+ONiJv1gmt_2G??QvvK*#JEU0Vvv zDiWfuy5y>4Ov4Io4aG{%+4w~@>B_-orYlBlRB6p5?!_>jyDox%)7@ZG#{ zJS{vQopsQIQz@-ZrgTvRsuNONx32DrWXzi8?zQdPK3M}ur4&l}>S79fF>O#vp^;=W zDICWY6BmZ{!IxhUxqk&0&_aldR&#+NAQ#jNs{%4+dT!P@)ptmSBQd?Ey-O99*Gt2+ zwc}(&W^$OR(SA^Ql-8o)A{=+&#jJy#oL8I~Kc}TYE42`lLU2+_cAL@&4|<-LK^R58 z?}=PCBj%EmI-V#I@kB97Dbn+EdUAAFPmPU=`P7`&_(C}jZhxVmHCk(}9Uu*y0RAKR zy$g66NCLM4m8rQ|(fj(#!gW2-dE;iCsI1qC$~rv9A(x&OgKzwT$#ci>3%R8i3qoVy z_)=@7ghq)#^V@{ry!op`zubS|wL>{fdwW;+wyvXZyb|_&pJ=Q|3ju{f4uQ~4KBpYl zB@&5}NvC8!mw%HB?La*ToCYR<2Z7*hd6ZAaoF94pbL9l>?-!p+WU-*ttM66HINc<>JMcGvNq z24X=?s-}_Y;43XH3*RfCTo+$?;QJyJiD_wA zLt^Llt6T#KsZB#_kQ#wfzUM2Y9AFOk1@Jg<7|1@hXL08j$Ik841Dk8GqN{c#v_Shx zX{GT!w909%XMld-6!2r<&|`bZ{f2K02LzV|Woq*hg%ZB&GCeWI^u!o_2M-9_wkfM# zMqOjGZtb{En4u7+X<}Frq-i6N!q=KyHY*UOD}Q!wM=kcZFSW@pri?C70Febf37iD> z1G|CqK;cTeeg!MYpiKRI&{HZ2EMfh|hOuc9j~BDDrA;?9uf>o;XEJFrbF*S{Y$Q20 za_$My{FQHr+h2Zg6v%)W)6GU$ygXniQ9mYas;rTt+CZaq>BQ-#;MUu}g8FQc1%TTDd}#TaZMp0QI|oeg}bz z>si1jfCmB+@!*O|Ua1Ov&*kF(<=DBMP@qb82VK79K^LSNs0c`fu7>dsMqr6WM9_b# z2$IP}pjz92l|fs_T7p$CNmaxjl)yX47+%4yCxW=R0k|#*{-)rpnZB5s05!m8|KAW; z5{E_r&H2U-@V8zwKf>w<9kG{}K`SgP8E T9~nm<00000NkvXXu0mjfwe3|@ diff --git a/ApplicationCode/Resources/SummaryCases16x16.png b/ApplicationCode/Resources/SummaryCases16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..5ca069bbb68d435ca3f8f8de40a42680ffb173d2 GIT binary patch literal 925 zcmV;O17iG%P)WFU8GbZ8()Nlj2>E@cM*00RL@L_t(I%Wae2Ynycx z#y{UT-zIOGHt7#%o7mZ@`$5-P(NrzE-b`naA-mYTkmB&l-FP9x|3J{m5F89|1Q|M5 z9d;dVT{m26DJ^c(n6=#~jaj>lQrpG6Nt-o4n&ds+l&r-*a5$WY!}A;t=MWBuQ}P71 zh?Li}$kktD^^@ZQAR^st0V5KL=nb_33_vk-ne;$E&OtJEhm_nnbDh=;Tu@}-*dM0JOg`2F`QKZG#Ib6ZzVu17JIUT-$HWf zvw(c}!*)6QpjQ%dS42eK+ReEOUw-h#;dXj}j!go6eSH}b5eZ$Fizfnd?#h07P!3fz z!(owAN1bbTzIh`*@~Ls_^btO9_R?9|LC4;<5;w;fy?%m~&PF~wbO8fDr4rn}4MRha zd#rTER_uAc{?%%CX4gsATI-+l44oO}yq>&v*@zae;M%{B-uF&p(8S~O9ri-ktt@*O}4sJ$-++Di=*0Fnw01j?S9K^z>cI_BOn=6C8Y} z1!RGir!>!)DV4@0p{Z56cDq$gjrlYr59&7?f9x8+V;tM#?tkBYWVLs=8&$Dj;c{*x zHs~fAjfvIS-|q_?Z?0#D$3@~&gelWFU8GbZ8()Nlj2>E@cM*00QVqL_t(I%Z-rDYg|5uRC);&pkgE*%V#qvwdD(US2g=zjnvD>=aoK(l*!u*gnAL zr58SUga5!d+doB~KpsQ9^|(9B|G>~*WpgXQ=_h)kltlz5e%qJM%;UkR@x5Q1Sj_%e zpzeQpP5{Q|&Ue6x0u(7;;ehYyLJyZj%B29X~&RuL~LJN+LP+A zNB!y<@|Q+M@MuP6PqvfQ(u7gQ`xi(9L{$YLtWY z8S@4_FoxUpVMfZ+e0Fn}#b=Lzi!iwGATAWi24G_v!2z0sD*Z^X#YrCRb{QM89DUMp zINBzNLkdO#0wNex!C^DVVz3GIJx}g!`YKMWoS4zBT++H54XK^juu_Mqrz*Vr_9T@N zAF?h6^zWEr4I6>B^4v4WIXOG!rMXoThla$coEtaqd#h_rQ!bV4+0&KK^Kxx%w&uC` aqrU<2+@RQ5@UDjd0000 Date: Mon, 7 May 2018 12:28:24 +0200 Subject: [PATCH 0894/1027] #2853 Add a specific ensembles icon. Use Cases icon for recursive import --- .../RicImportEclipseCasesFeature.cpp | 2 +- .../Summary/RimSummaryCaseCollection.cpp | 2 +- ApplicationCode/Resources/ResInsight.qrc | 1 + .../Resources/SummaryEnsemble16x16.png | Bin 900 -> 945 bytes ApplicationCode/Resources/SummaryGroup16x16.png | Bin 0 -> 900 bytes 5 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 ApplicationCode/Resources/SummaryGroup16x16.png diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index f5cb90e476..39cbbec3b6 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -82,6 +82,6 @@ void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportEclipseCasesFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/Case48x48.png")); + actionToSetup->setIcon(QIcon(":/Cases16x16.png")); actionToSetup->setText("Import Eclipse Cases Recursively"); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index ec509da4e4..f74b107526 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -30,7 +30,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection, "SummaryCaseSubCollection"); //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::RimSummaryCaseCollection() { - CAF_PDM_InitObject("Summary Case Group", ":/SummaryEnsemble16x16.png", "", ""); + CAF_PDM_InitObject("Summary Case Group", ":/SummaryGroup16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); m_cases.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 513fc55b8a..76d3deb53e 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -26,6 +26,7 @@ Cases16x16.png SummaryCases16x16.png SummaryEnsemble16x16.png + SummaryGroup16x16.png CreateGridCaseGroup16x16.png GridCaseGroup16x16.png Histogram16x16.png diff --git a/ApplicationCode/Resources/SummaryEnsemble16x16.png b/ApplicationCode/Resources/SummaryEnsemble16x16.png index f0af79850a878c4aa87390d484e4d1f734bc046f..27c94b849002795cbf7562134a1cd27ad36fe8db 100644 GIT binary patch delta 835 zcmV-J1HAl%2eAi`R0jzr1PKk>QjuFLe*+asL_t(I%UzC5XdPu3g`fAEnKU={l9(SG zljbHELTPRVBUCg>BU&^Hk`}EiMY<4|QoAp>aiv|kC|X){Q>=(aX-gF;XcetUNU>>Y zVjz$v&ENgMcjnG~^Sv%Ypm>(&oab<)zHs5DbIIc*6^M&q>tJgDUuU2B^i3Ynf9TYS z%OH)p>Cvckd`b@7VDYI2AyM@mh8To@uGP ze(Gv>vDyr(p_QFM&wx#pzK6|v0)sPf}4x5(uNQRhI6=L!w4WBMu^Pj`}kc0VL;`-WP8 z4qrq)TwS!;1mm-|w$9|_E8C@NjQ!#qb1zut>t*t3lmE*EzUNC)^jus}e+}2@@7=SV zlxr-1beuDTXIOl(4Wfvo0op8~Q4tqz;F<+|Ts2TzGivJ~hRsS04fyr+Buf)9Q!oF- zfQ<9m%wg`7{-$ht7(X-yX$WbIk+|d&msD*{U0l&zo5$k$DbnZLd28|pUBz)eKc_6+ ztCDf6^le?@`uE>ZEtOP~e-xuh*=X7jY+cn>-Q};YaG@|nru!1-zl0Az-lR7t?8_@j#}nBF{``FgjY1?|nXYK#en!(s)H!Bn*X8)!&k_B<=q7T$j8F?>y(DhlF&gc12!a)UFJlYokJu$vm4UY)zXf6tA@Hrl%exp-}p z!w2_*3-NJ{-MEHoQU@EcQr*RBJx486Y^I<4n`Js%Eklnu_Jr$HqXsR$01B%3NQ=WJ zkVIgcEN*!^w;V{+w7P%TxUQ@*<*-#YBA=N>75uRC);&pkgE*%V#qvwdD(US2g=zjnvD>=aoK(l*!u*gnALr58SUga5!df7?Gr zo1bST#}B}M*CWXZ-2Z?wK|PB2TFUc6?&t~->~!i z7_}EqK<4(hiv<`pN{NRXC`l5~hOMn_mX==M4+Saq<15^I*|Ik1Qp=Nnov3}|8I`p? zm$pQrEhfhg@0)I)%?szbG<}KsE5i`SWFbh>LE<(p+QB6)3@-4+_O;jne<;mvFNF|( zdVh(Hg_JX|eaDoV=fjmn{_OlgS67%nJqLLNd5TtP$B=eJY+qd3lj^WX{puO=mqvJV z={Du|JeRKs8xI4DuF1sSb#8t21wp4HD$CK5b+zQ7!VW}i;J*I!2G?3gDIU7c)lcBP zi@S_h700W>T2s>)csyNNf9JPfR**PCrH$pDgpZ1n$4Z=Ib#+_a`gvWO{swWJGk&B< zFSYDFe84*kK6n3W(I2VN2nxLQ>M@MuP6PqvfQ(u7gQ`xi(9L{$YLtWY8S@4_FoxUp zVMfZ+e0Fn}#b=Lzi!iwGATAWi24G_v!2z0sD*Z^X#YrCRb{QM8e;j?%aX8v0h(iiS z0RkczRKa00$YQVw^*vASZTc!stelw9u3XZ(8x5(Q*sxNEsi!Ku`}QQ25g)QH2K4Wk zVhtOCw({IF$2mDW<)yh*6NiSxsGJ)&?|Z9jO;awF?Agp8x;= diff --git a/ApplicationCode/Resources/SummaryGroup16x16.png b/ApplicationCode/Resources/SummaryGroup16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..f0af79850a878c4aa87390d484e4d1f734bc046f GIT binary patch literal 900 zcmV-~1AF|5P)WFU8GbZ8()Nlj2>E@cM*00QVqL_t(I%Z-rDYg|5uRC);&pkgE*%V#qvwdD(US2g=zjnvD>=aoK(l*!u*gnAL zr58SUga5!d+doB~KpsQ9^|(9B|G>~*WpgXQ=_h)kltlz5e%qJM%;UkR@x5Q1Sj_%e zpzeQpP5{Q|&Ue6x0u(7;;ehYyLJyZj%B29X~&RuL~LJN+LP+A zNB!y<@|Q+M@MuP6PqvfQ(u7gQ`xi(9L{$YLtWY z8S@4_FoxUpVMfZ+e0Fn}#b=Lzi!iwGATAWi24G_v!2z0sD*Z^X#YrCRb{QM89DUMp zINBzNLkdO#0wNex!C^DVVz3GIJx}g!`YKMWoS4zBT++H54XK^juu_Mqrz*Vr_9T@N zAF?h6^zWEr4I6>B^4v4WIXOG!rMXoThla$coEtaqd#h_rQ!bV4+0&KK^Kxx%w&uC` aqrU<2+@RQ5@UDjd0000 Date: Mon, 7 May 2018 12:57:12 +0200 Subject: [PATCH 0895/1027] #2803 Ensemble Cases Performance : Use loadAllSummaryCaseData() --- ApplicationCode/ProjectDataModel/RimEclipseCase.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index e266c30df4..5c745998ff 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -905,10 +905,7 @@ void RimEclipseCase::reloadDataAndUpdate() RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if (sumCaseColl) { - for (auto sumCase : sumCaseColl->allSummaryCases()) - { - sumCase->createSummaryReaderInterface(); - } + sumCaseColl->loadAllSummaryCaseData(); } if (project->mainPlotCollection()) From d8afe5740bc05da7432cd5ce5bbd364d98517b5c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 May 2018 13:14:43 +0200 Subject: [PATCH 0896/1027] #2803 Ensemble Cases Performance : Use one function to load summary data --- .../Summary/RimSummaryCaseMainCollection.cpp | 92 +++++++++++-------- .../Summary/RimSummaryCaseMainCollection.h | 3 + 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 8382784f3c..5bccd095ce 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -298,17 +298,28 @@ void RimSummaryCaseMainCollection::loadAllSummaryCaseData() { std::vector sumCases = allSummaryCases(); - caf::ProgressInfo progInfo(sumCases.size(), "Loading Summary Cases"); + RimSummaryCaseMainCollection::loadSummaryCaseData(sumCases); +} - for (size_t cIdx = 0; cIdx < sumCases.size(); ++cIdx) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::loadSummaryCaseData(std::vector summaryCases) +{ + caf::ProgressInfo progInfo(summaryCases.size(), "Loading Summary Cases"); + + for (int cIdx = 0; cIdx < static_cast(summaryCases.size()); ++cIdx) { - RimSummaryCase* sumCase = sumCases[cIdx]; + RimSummaryCase* sumCase = summaryCases[cIdx]; if (sumCase) { sumCase->createSummaryReaderInterface(); addCaseRealizationParametersIfFound(*sumCase, sumCase->summaryHeaderFilename()); } - progInfo.incrementProgress(); + + { + progInfo.incrementProgress(); + } } } @@ -330,48 +341,53 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro { RimProject* project = RiaApplication::instance()->project(); - std::vector sumCases; - std::unique_ptr progress; - - if (showProgress) - { - progress.reset(new caf::ProgressInfo(summaryHeaderFileInfos.size(), "Creating summary cases")); - } + std::vector sumCases; - for (RifSummaryCaseFileResultInfo fileInfo : summaryHeaderFileInfos) + // Split into two stages to be able to use multi threading + // First stage : Create summary case objects + // Second stage : Load data { - RimEclipseCase* eclCase = nullptr; - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.summaryFileName()); - if (!gridCaseFile.isEmpty()) - { - eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); - } + std::unique_ptr progress; - if (eclCase) + if (showProgress) { - RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); - - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); - newSumCase->setAssociatedEclipseCase(eclCase); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.summaryFileName()); - sumCases.push_back(newSumCase); + progress.reset(new caf::ProgressInfo(summaryHeaderFileInfos.size(), "Creating summary cases")); } - else + + for (const RifSummaryCaseFileResultInfo& fileInfo : summaryHeaderFileInfos) { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); - - newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); - newSumCase->setSummaryHeaderFileName(fileInfo.summaryFileName()); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - addCaseRealizationParametersIfFound(*newSumCase, fileInfo.summaryFileName()); - sumCases.push_back(newSumCase); - } + RimEclipseCase* eclCase = nullptr; + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.summaryFileName()); + if (!gridCaseFile.isEmpty()) + { + eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); + } + + if (eclCase) + { + RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); + + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); + newSumCase->setAssociatedEclipseCase(eclCase); + newSumCase->updateOptionSensitivity(); + sumCases.push_back(newSumCase); + } + else + { + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); + newSumCase->setSummaryHeaderFileName(fileInfo.summaryFileName()); + newSumCase->updateOptionSensitivity(); + sumCases.push_back(newSumCase); + } - if (progress != nullptr) progress->incrementProgress(); + if (progress != nullptr) progress->incrementProgress(); + } } + + RimSummaryCaseMainCollection::loadSummaryCaseData(sumCases); + return sumCases; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 2bf970ac4d..423d33c8bf 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -64,6 +64,9 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); +private: + static void loadSummaryCaseData(std::vector summaryCases); + private: caf::PdmChildArrayField m_cases; caf::PdmChildArrayField m_caseCollections; From ff628fa9dd7802734ff595fbaeeec19f86157bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 12:55:46 +0200 Subject: [PATCH 0897/1027] #2852 OPM flowdiag upgrade. Copy from repos --- ResInsightVersion.cmake | 4 +- .../CMakeLists.txt | 9 +- .../dune.module | 6 +- .../examples/exampleSetup.hpp | 2 +- .../examples/extractFromRestart.cpp | 2 +- .../examples/extractPropCurves.cpp | 97 +- ...flowdiagnostics-applications-prereqs.cmake | 2 - .../opm/utility/ECLEndPointScaling.cpp | 1078 +++++++++++++++-- .../opm/utility/ECLEndPointScaling.hpp | 361 +++++- .../opm/utility/ECLFluxCalc.cpp | 8 +- .../opm/utility/ECLGraph.cpp | 93 +- .../opm/utility/ECLGraph.hpp | 23 +- .../opm/utility/ECLPropertyUnitConversion.cpp | 4 +- .../opm/utility/ECLPvtCommon.cpp | 6 +- .../opm/utility/ECLPvtGas.cpp | 2 +- .../opm/utility/ECLPvtOil.cpp | 6 +- .../opm/utility/ECLSaturationFunc.cpp | 565 +++++++-- .../opm/utility/ECLSaturationFunc.hpp | 108 +- .../opm/utility/ECLUnitHandling.cpp | 4 +- .../opm/utility/ECLWellSolution.cpp | 3 +- .../opm/utility/imported/Units.hpp | 367 ++++++ .../tests/runLinearisedCellDataTest.cpp | 12 +- .../tests/test_eclendpointscaling.cpp | 442 ++++++- .../tests/test_eclpropertyunitconversion.cpp | 4 - .../tests/test_eclproptable.cpp | 4 - .../tests/test_eclpvtcommon.cpp | 4 - .../tests/test_eclregionmapping.cpp | 4 - .../tests/test_eclsimple1dinterpolant.cpp | 4 - .../tests/test_eclunithandling.cpp | 4 - .../opm-flowdiagnostics/CMakeLists.txt | 2 +- .../opm-flowdiagnostics/dune.module | 4 +- .../opm-flowdiagnostics-prereqs.cmake | 19 + .../tests/test_assembledconnections.cpp | 6 - .../tests/test_cellset.cpp | 4 - .../tests/test_connectionvalues.cpp | 6 - .../tests/test_connectivitygraph.cpp | 6 - .../tests/test_derivedquantities.cpp | 6 - .../tests/test_flowdiagnosticstool.cpp | 6 - .../opm-flowdiagnostics/tests/test_tarjan.cpp | 4 - 39 files changed, 2830 insertions(+), 461 deletions(-) create mode 100644 ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp create mode 100644 ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index b107893293..ef7e164459 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -19,10 +19,10 @@ set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") set(ECL_GITHUB_SHA "0188b08081eb1ac4ade89ac224b8128b4c9b0481") # https://github.com/OPM/opm-flowdiagnostics -set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f") +set(OPM_FLOWDIAGNOSTICS_SHA "f8af0914f8b1ddcda41f040f539c945a6057f5e4") # https://github.com/OPM/opm-flowdiagnostics-applications -set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "5bcd6d99259a63f5cd820db541b45c4f07aec808") +set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "e769c492ccd3fc4e1f834ed60f4f9279ba8524bc") # https://github.com/OPM/opm-parser/blob/master/opm/parser/eclipse/Units/Units.hpp # This file was moved from opm-core to opm-parser october 2016 diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt index 565b1aafce..3d166e14e7 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt @@ -56,9 +56,9 @@ include(OpmInit) macro (dir_hook) endmacro (dir_hook) -# Look for the opm-data repository; if found the variable -# HAVE_OPM_DATA will be set to true. -include (Findopm-data) +# Look for the "opm-tests" repository (OPM's Regression Test data +# repository)--HAVE_OPM_TESTS true if found. +include (Findopm-tests) # list of prerequisites for this particular project; this is in a # separate file (in cmake/Modules sub-directory) because it is shared @@ -93,6 +93,7 @@ endmacro (install_hook) # all setup common to the OPM library modules is done here include (OpmLibMain) -if (HAVE_OPM_DATA) +if (HAVE_OPM_TESTS) + # Regression test data available. Enable additional tests. include (${CMAKE_CURRENT_SOURCE_DIR}/AcceptanceTests.cmake) endif() diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module index b55f213284..1d257c47cc 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module @@ -5,9 +5,9 @@ Module: opm-flowdiagnostics-applications Description: flow diagnostics applications and examples -Version: 2018.04-pre -Label: 2018.04-pre +Version: 2018.10-pre +Label: 2018.10-pre Maintainer: bard.skaflestad@sintef.no MaintainerName: Bård Skaflestad Url: http://opm-project.org -Depends: opm-common opm-flowdiagnostics opm-core +Depends: opm-common opm-flowdiagnostics diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp index bd4fe47f1a..8c8b67f53e 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp @@ -23,7 +23,7 @@ -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp index 060fba34f7..4a177f5e95 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp @@ -22,7 +22,7 @@ #include #endif -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp index 8ca6f823d4..cbfbfed881 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -98,9 +99,9 @@ namespace { // ----------------------------------------------------------------- // Relative permeability - void krg(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krg(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -115,14 +116,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krg", graph); } - void krog(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krog(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -137,14 +138,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krog", graph); } - void krow(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krow(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -159,14 +160,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krow", graph); } - void krw(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krw(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -181,7 +182,7 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krw", graph); } @@ -189,9 +190,9 @@ namespace { // ----------------------------------------------------------------- // Capillary pressure - void pcgo(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void pcgo(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -206,14 +207,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "pcgo", graph); } - void pcow(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void pcow(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -228,7 +229,7 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "pcow", graph); } @@ -407,13 +408,41 @@ namespace { return acell; } + + Opm::ECLSaturationFunc::SatFuncScaling + saturationFuncScaling(const Opm::ParameterGroup& prm) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + const auto opt = + std::regex_constants::icase | + std::regex_constants::ECMAScript; + + const auto horiz = std::regex { "horizontal", opt }; + const auto vert = std::regex { "vertical" , opt }; + const auto useEPS = + prm.getDefault("useEPS", std::string{"off"}); + + auto scaling = Opm::ECLSaturationFunc::SatFuncScaling{}; + scaling.enable = static_cast(0); + scaling.invalid = handleInvalid(prm); + + if (std::regex_search(useEPS, horiz)) { + scaling.enable |= T::Horizontal; + } + + if (std::regex_search(useEPS, vert)) { + scaling.enable |= T::Vertical; + } + + return scaling; + } } // namespace Anonymous int main(int argc, char* argv[]) try { - const auto prm = example::initParam(argc, argv); - const auto useEPS = prm.getDefault("useEPS", false); - const auto h_inv = handleInvalid(prm); + const auto prm = example::initParam(argc, argv); + const auto scaling = saturationFuncScaling(prm); const auto rset = example::identifyResultSet(prm); const auto init = Opm::ECLInitFileData(rset.initFile()); @@ -421,7 +450,7 @@ try { const auto cellID = getActiveCell(graph, prm); - auto sfunc = Opm::ECLSaturationFunc(graph, init, useEPS, h_inv); + auto sfunc = Opm::ECLSaturationFunc(graph, init); auto pvtCC = Opm::ECLPVT::ECLPvtCurveCollection(graph, init); if (prm.has("unit")) { @@ -434,15 +463,15 @@ try { // ----------------------------------------------------------------- // Relative permeability - if (prm.getDefault("krg" , false)) { krg (sfunc, cellID, useEPS); } - if (prm.getDefault("krog", false)) { krog(sfunc, cellID, useEPS); } - if (prm.getDefault("krow", false)) { krow(sfunc, cellID, useEPS); } - if (prm.getDefault("krw" , false)) { krw (sfunc, cellID, useEPS); } + if (prm.getDefault("krg" , false)) { krg (sfunc, cellID, scaling); } + if (prm.getDefault("krog", false)) { krog(sfunc, cellID, scaling); } + if (prm.getDefault("krow", false)) { krow(sfunc, cellID, scaling); } + if (prm.getDefault("krw" , false)) { krw (sfunc, cellID, scaling); } // ----------------------------------------------------------------- // Capillary pressure - if (prm.getDefault("pcgo", false)) { pcgo(sfunc, cellID, useEPS); } - if (prm.getDefault("pcow", false)) { pcow(sfunc, cellID, useEPS); } + if (prm.getDefault("pcgo", false)) { pcgo(sfunc, cellID, scaling); } + if (prm.getDefault("pcow", false)) { pcow(sfunc, cellID, scaling); } // ----------------------------------------------------------------- // PVT Curves diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake index 5461c566c8..180114cb46 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake @@ -17,10 +17,8 @@ set (opm-flowdiagnostics-applications_DEPS # Prerequisite OPM modules # common -> Parameter System # fdiag -> Solver - # parser -> Unit Conversions "opm-common REQUIRED" "opm-flowdiagnostics REQUIRED" - "opm-parser REQUIRED" ) find_package_deps(opm-flowdiagnostics-applications) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp index 0c9a99bc65..5bd31f9949 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp @@ -27,6 +27,10 @@ #include #include +#include +#include + +#include #include #include #include @@ -37,6 +41,8 @@ #include #include +#include + namespace { std::vector unscaledTwoPt(const std::vector& min, @@ -81,6 +87,39 @@ namespace { return tep; } + template + std::vector + gridDefaultedVector(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::string& vector, + const std::vector& dflt, + CvrtVal&& cvrt) + { + auto ret = std::vector(G.numCells()); + + assert (! dflt.empty() && "Internal Error"); + + auto cellID = std::vector::size_type{0}; + for (const auto& gridID : G.activeGrids()) { + const auto nc = G.numCells(gridID); + + const auto& snum = init.haveKeywordData("SATNUM", gridID) + ? G.rawLinearisedCellData(init, "SATNUM", gridID) + : std::vector(nc, 1); + + const auto& val = init.haveKeywordData(vector, gridID) + ? G.rawLinearisedCellData(init, vector, gridID) + : std::vector(nc, -1.0e21); + + for (auto c = 0*nc; c < nc; ++c, ++cellID) { + ret[cellID] = (std::abs(val[c]) < 1.0e20) + ? cvrt(val[c]) : dflt[snum[c] - 1]; + } + } + + return ret; + } + double defaultedScaledSaturation(const double s, const double dflt) { // Use input scaled saturation ('s') if not defaulted (|s| < 1e20), @@ -114,12 +153,11 @@ namespace { class Opm::SatFunc::TwoPointScaling::Impl { public: - Impl(std::vector smin, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) + Impl(std::vector smin, + std::vector smax) : smin_ (std::move(smin)) , smax_ (std::move(smax)) - , handle_invalid_(handle_invalid) + , handle_invalid_(InvalidEndpointBehaviour::UseUnscaled) { if (this->smin_.size() != this->smax_.size()) { throw std::invalid_argument { @@ -278,6 +316,122 @@ handleInvalidEndpoint(const SaturationAssoc& sp, } } +// --------------------------------------------------------------------- +// Class Opm::SatFunc::PureVerticalScaling::Impl +// --------------------------------------------------------------------- + +class Opm::SatFunc::PureVerticalScaling::Impl +{ +public: + explicit Impl(std::vector fmax) + : fmax_(std::move(fmax)) + {} + + std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const; + +private: + std::vector fmax_; +}; + +std::vector +Opm::SatFunc::PureVerticalScaling::Impl:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const +{ + assert (sp.size() == val.size() && "Internal Error in Vertical Scaling"); + + auto ret = std::move(val); + + const auto maxVal = f.max.val; + + for (auto n = sp.size(), i = 0*n; i < n; ++i) { + ret[i] *= this->fmax_[ sp[i].cell ] / maxVal; + } + + return ret; +} + +// --------------------------------------------------------------------- +// Class Opm::SatFunc::CritSatVerticalScaling::Impl +// --------------------------------------------------------------------- + +class Opm::SatFunc::CritSatVerticalScaling::Impl +{ +public: + explicit Impl(std::vector sdisp, + std::vector fdisp, + std::vector fmax) + : sdisp_(std::move(sdisp)) + , fdisp_(std::move(fdisp)) + , fmax_ (std::move(fmax)) + {} + + std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const; + +private: + std::vector sdisp_; + std::vector fdisp_; + std::vector fmax_; +}; + +std::vector +Opm::SatFunc::CritSatVerticalScaling::Impl:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const +{ + assert ((sp.size() == val.size()) && "Internal Error in Vertical Scaling"); + assert (! (f.max.val < f.disp.val) && "Internal Error in Table Extraction"); + assert (! (f.max.sat < f.disp.sat) && "Internal Error in Table Extraction"); + + auto ret = std::move(val); + + const auto fdisp = f.disp.val; const auto sdisp = f.disp.sat; + const auto fmax = f.max .val; const auto smax = f.max .sat; + const auto sepfv = fmax > fdisp; const auto sep_s = sdisp > smax; + + for (auto n = sp.size(), i = 0*n; i < n; ++i) { + auto& y = ret[i]; + + const auto c = sp[i].cell; + const auto s = sp[i].sat; + const auto sr = this->sdisp_[c]; + const auto fr = this->fdisp_[c]; + const auto fm = this->fmax_ [c]; + + if (! (s > sr)) { + // s <= sr: Pure vertical scaling in left interval. + y *= fr / fdisp; + } + else if (sepfv) { + // Normal case: Kr(Smax) > Kr(Sr) + const auto t = (y - fdisp) / (fmax - fdisp); + + y = fr + t*(fm - fr); + } + else if (sep_s) { + // Special case: Kr(Smax) == Kr(Sr). Use linear function from + // saturations. + const auto t = (s - sdisp) / (smax - sdisp); + + y = fr + t*(fm - fr); + } + else { + // Smax == Sr; Almost arbitrarily pick fmax_[c]. + y = fm; + } + } + + return ret; +} + // --------------------------------------------------------------------- // Class Opm::ThreePointScaling::Impl // --------------------------------------------------------------------- @@ -285,14 +439,13 @@ handleInvalidEndpoint(const SaturationAssoc& sp, class Opm::SatFunc::ThreePointScaling::Impl { public: - Impl(std::vector smin , - std::vector sdisp, - std::vector smax , - InvalidEndpointBehaviour handle_invalid) + Impl(std::vector smin , + std::vector sdisp, + std::vector smax ) : smin_ (std::move(smin )) , sdisp_ (std::move(sdisp)) , smax_ (std::move(smax )) - , handle_invalid_(handle_invalid) + , handle_invalid_(InvalidEndpointBehaviour::UseUnscaled) { if ((this->sdisp_.size() != this->smin_.size()) || (this->sdisp_.size() != this->smax_.size())) @@ -480,6 +633,42 @@ handleInvalidEndpoint(const SaturationAssoc& sp, // EPS factory functions for two-point and three-point scaling options // --------------------------------------------------------------------- +namespace { + bool haveScaledRelPermAtCritSatKeyword(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::string& kw) + { + auto haveKW = false; + + for (const auto& grid : G.activeGrids()) { + haveKW = haveKW || init.haveKeywordData(kw, grid); + } + + return haveKW; + } + + bool haveScaledRelPermAtCritSat(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const ::Opm::ECLPhaseIndex phase, + const ::Opm::SatFunc::CreateEPS::SubSystem subSys) + { + switch (phase) { + case ::Opm::ECLPhaseIndex::Aqua: + return haveScaledRelPermAtCritSatKeyword(G, init, "KRWR"); + + case ::Opm::ECLPhaseIndex::Liquid: + return (subSys == ::Opm::SatFunc::CreateEPS::SubSystem::OilGas) + ? haveScaledRelPermAtCritSatKeyword(G, init, "KROGR") + : haveScaledRelPermAtCritSatKeyword(G, init, "KROWR"); + + case ::Opm::ECLPhaseIndex::Vapour: + return haveScaledRelPermAtCritSatKeyword(G, init, "KRGR"); + } + + return false; + } +} // namespace Anonymous + namespace Create { using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; using RTEP = ::Opm::SatFunc::CreateEPS::RawTableEndPoints; @@ -493,35 +682,29 @@ namespace Create { struct Kr { static EPSPtr G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; struct Pc { static EPSPtr GO(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; static EPSPtr @@ -540,23 +723,19 @@ namespace Create { struct Kr { static EPSPtr G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; static EPSPtr @@ -567,14 +746,95 @@ namespace Create { static std::vector unscaledEndPoints(const RTEP& ep, const EPSOpt& opt); } // namespace ThreePoint + + namespace PureVertical { + using Scaling = ::Opm::SatFunc::PureVerticalScaling; + using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; + using FValVec = ::Opm::SatFunc::CreateEPS::Vertical::FuncValVector; + using ScalPtr = std::unique_ptr; + + struct Kr { + static ScalPtr + G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + O(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + }; + + struct Pc { + static ScalPtr + GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + }; + + static ScalPtr + scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const FValVec& fvals); + } // namespace PureVertical + + namespace CritSatVertical { + using Scaling = ::Opm::SatFunc::CritSatVerticalScaling; + using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; + using FValVec = ::Opm::SatFunc::CreateEPS::Vertical::FuncValVector; + using ScalPtr = std::unique_ptr; + + struct Kr { + static ScalPtr + G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + }; + + static ScalPtr + scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const RTEP& tep, + const FValVec& fvals); + } // namespace CritSatVertical } // namespace Create // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Implementation of Create::TwoPoint::scalingFunction() Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sgcr = G.rawLinearisedCellData(init, "SGCR"); auto sgu = G.rawLinearisedCellData(init, "SGU"); @@ -589,16 +849,13 @@ Create::TwoPoint::Kr::G(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sgcr), std::move(sgu), handle_invalid - } + new EPS { std::move(sgcr), std::move(sgu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sogcr = G.rawLinearisedCellData(init, "SOGCR"); @@ -645,16 +902,13 @@ Create::TwoPoint::Kr::OG(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sogcr), std::move(smax), handle_invalid - } + new EPS { std::move(sogcr), std::move(smax) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sowcr = G.rawLinearisedCellData(init, "SOWCR"); @@ -701,16 +955,13 @@ Create::TwoPoint::Kr::OW(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sowcr), std::move(smax), handle_invalid - } + new EPS { std::move(sowcr), std::move(smax) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto swcr = G.rawLinearisedCellData(init, "SWCR"); auto swu = G.rawLinearisedCellData(init, "SWU"); @@ -722,16 +973,13 @@ Create::TwoPoint::Kr::W(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(swcr), std::move(swu), handle_invalid - } + new EPS { std::move(swcr), std::move(swu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { // Try dedicated scaled Sg_conn for Pc first auto sgl = G.rawLinearisedCellData(init, "SGLPC"); @@ -752,16 +1000,13 @@ Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sgl), std::move(sgu), handle_invalid - } + new EPS { std::move(sgl), std::move(sgu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { // Try dedicated scaled Sw_conn for Pc first auto swl = G.rawLinearisedCellData(init, "SWLPC"); @@ -782,9 +1027,7 @@ Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(swl), std::move(swu), handle_invalid - } + new EPS { std::move(swl), std::move(swu) } }; } @@ -811,10 +1054,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Aqua) { - return Create::TwoPoint::Kr::W(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::W(G, init); } - return Create::TwoPoint::Kr::OW(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::OW(G, init); } if (opt.subSys == SSys::OilGas) { @@ -826,10 +1069,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::TwoPoint::Kr::G(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::G(G, init); } - return Create::TwoPoint::Kr::OG(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::OG(G, init); } } @@ -842,11 +1085,11 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::TwoPoint::Pc::GO(G, init, opt.handle_invalid); + return Create::TwoPoint::Pc::GO(G, init); } if (opt.thisPh == PhIdx::Aqua) { - return Create::TwoPoint::Pc::OW(G, init, opt.handle_invalid); + return Create::TwoPoint::Pc::OW(G, init); } } @@ -931,8 +1174,7 @@ Create::TwoPoint::unscaledEndPoints(const RTEP& ep, const EPSOpt& opt) Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sgcr = G.rawLinearisedCellData(init, "SGCR"); auto sgu = G.rawLinearisedCellData(init, "SGU"); @@ -984,15 +1226,14 @@ Create::ThreePoint::Kr::G(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sgcr), std::move(sr), std::move(sgu), handle_invalid + std::move(sgcr), std::move(sr), std::move(sgu) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sogcr = G.rawLinearisedCellData(init, "SOGCR"); @@ -1060,15 +1301,14 @@ Create::ThreePoint::Kr::OG(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sogcr), std::move(sdisp), std::move(smax), handle_invalid + std::move(sogcr), std::move(sdisp), std::move(smax) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sowcr = G.rawLinearisedCellData(init, "SOWCR"); @@ -1136,15 +1376,14 @@ Create::ThreePoint::Kr::OW(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sowcr), std::move(sdisp), std::move(smax), handle_invalid + std::move(sowcr), std::move(sdisp), std::move(smax) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto swcr = G.rawLinearisedCellData(init, "SWCR"); auto swu = G.rawLinearisedCellData(init, "SWU"); @@ -1195,7 +1434,7 @@ Create::ThreePoint::Kr::W(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(swcr), std::move(sdisp), std::move(swu), handle_invalid + std::move(swcr), std::move(sdisp), std::move(swu) } }; } @@ -1225,10 +1464,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Aqua) { - return Create::ThreePoint::Kr::W(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::W(G, init); } - return Create::ThreePoint::Kr::OW(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::OW(G, init); } if (opt.subSys == SSys::OilGas) { @@ -1240,10 +1479,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::ThreePoint::Kr::G(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::G(G, init); } - return Create::ThreePoint::Kr::OG(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::OG(G, init); } // Invalid. @@ -1327,6 +1566,458 @@ Create::ThreePoint::unscaledEndPoints(const RTEP& ep, const EPSOpt& opt) return {}; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Implementation of Create::PureVertical::scalingFunction() + +namespace { + Create::PureVertical::ScalPtr + pureVerticalRelpermScaling(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt, + const std::string& vector) + { + auto scaledMaxKr = + gridDefaultedVector(G, init, vector, dflt, + [](const double kr) { return kr; }); + + return Create::PureVertical::ScalPtr { + new ::Opm::SatFunc::PureVerticalScaling(std::move(scaledMaxKr)) + }; + } + + Create::PureVertical::ScalPtr + pureVerticalCapPressScaling(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt, + const std::string& vector) + { + const auto& ih = init.keywordData(INTEHEAD_KW); + + const auto pscale = ::Opm::ECLUnits:: + createUnitSystem(ih[ INTEHEAD_UNIT_INDEX ])->pressure(); + + auto scaledMaxPc = + gridDefaultedVector(G, init, vector, dflt, + [pscale](const double pc) + { + return ::ImportedOpm::unit::convert::from(pc, pscale); + }); + + return Create::PureVertical::ScalPtr { + new ::Opm::SatFunc::PureVerticalScaling(std::move(scaledMaxPc)) + }; + } + +} // Anonymous + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRG"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::O(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRO"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRW"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Pc::GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalCapPressScaling(G, init, dflt, "PCG"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Pc::OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalCapPressScaling(G, init, dflt, "PCW"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical:: +scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const FValVec& fvals) +{ + using FCat = ::Opm::SatFunc::CreateEPS::FunctionCategory; + using SSys = ::Opm::SatFunc::CreateEPS::SubSystem; + using PhIdx = ::Opm::ECLPhaseIndex; + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + auto dfltVals = std::vector(fvals.size(), 0.0); + std::transform(std::begin(fvals), std::end(fvals), + std::begin(dfltVals), + [](const FVal& fv) + { + return fv.max.val; + }); + + if (opt.curve == FCat::Relperm) { + if (opt.subSys == SSys::OilGas) { + if (opt.thisPh == PhIdx::Aqua) { + throw std::invalid_argument { + "Cannot Create Vertical Scaling for " + "Water Relperm in an Oil/Gas System" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::PureVertical::Kr::G(G, init, dfltVals); + } + + return Create::PureVertical::Kr::O(G, init, dfltVals); + } + + if (opt.subSys == SSys::OilWater) { + if (opt.thisPh == PhIdx::Vapour) { + throw std::invalid_argument { + "Cannot Create Vertical Scaling for " + "Gas Relperm in an Oil/Water System" + }; + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::PureVertical::Kr::W(G, init, dfltVals); + } + + return Create::PureVertical::Kr::O(G, init, dfltVals); + } + } + + if (opt.curve == FCat::CapPress) { + if (opt.thisPh == PhIdx::Liquid) { + throw std::invalid_argument { + "Creating Capillary Pressure Vertical Scaling " + "as a Function of Oil Saturation is not Supported" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::PureVertical::Pc::GO(G, init, dfltVals); + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::PureVertical::Pc::OW(G, init, dfltVals); + } + } + + // Invalid. + return {}; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Implementation of Create::CritSatVertical::scalingFunction() + +namespace { + template + std::vector + extractCritSat(const std::vector& tep, + Extract&& extract) + { + auto scr = std::vector(tep.size(), 0.0); + + std::transform(std::begin(tep), std::end(tep), std::begin(scr), + std::forward(extract)); + + return scr; + } +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& rtep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto& ih = init.keywordData(INTEHEAD_KW); + const auto iphs = static_cast(ih[INTEHEAD_PHASE_INDEX]); + + auto sdisp = std::vector(G.numCells()); + + if ((iphs & (1u << 0)) != 0) { // Oil active + auto sogcr = + gridDefaultedVector(G, init, "SOGCR", rtep.crit.oil_in_gas, + [](const double s) { return s; }); + + auto swl = + gridDefaultedVector(G, init, "SWL", rtep.conn.water, + [](const double s) { return s; }); + + std::transform(std::begin(sogcr), std::end(sogcr), + std::begin(swl), std::begin(sdisp), + [](const double so, const double sw) + { + return 1.0 - (so + sw); + }); + } + else { // Oil not active (G/W?) + auto swcr = + gridDefaultedVector(G, init, "SWCR", rtep.crit.water, + [](const double s) { return s; }); + + std::transform(std::begin(swcr), std::end(swcr), + std::begin(sdisp), + [](const double sw) + { + return 1.0 - sw; + }); + } + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRGR", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRG", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + auto sdisp = std::vector(G.numCells()); + + auto sgcr = + gridDefaultedVector(G, init, "SGCR", tep.crit.gas, + [](const double s) { return s; }); + + auto swl = + gridDefaultedVector(G, init, "SWL", tep.conn.water, + [](const double s) { return s; }); + + std::transform(std::begin(sgcr), std::end(sgcr), + std::begin(swl), std::begin(sdisp), + [](const double sg, const double sw) + { + return 1.0 - (sg + sw); + }); + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRORG", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRO", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + auto sdisp = std::vector(G.numCells()); + + auto swcr = + gridDefaultedVector(G, init, "SWCR", tep.crit.water, + [](const double s) { return s; }); + + auto sgl = + gridDefaultedVector(G, init, "SGL", tep.conn.gas, + [](const double s) { return s; }); + + std::transform(std::begin(swcr), std::end(swcr), + std::begin(sgl), std::begin(sdisp), + [](const double sw, const double sg) + { + return 1.0 - (sg + sw); + }); + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRORW", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRO", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto& ih = init.keywordData(INTEHEAD_KW); + const auto iphs = static_cast(ih[INTEHEAD_PHASE_INDEX]); + + auto sdisp = std::vector(G.numCells()); + + if ((iphs & (1u << 0)) != 0) { // Oil active + auto sowcr = + gridDefaultedVector(G, init, "SOWCR", tep.crit.oil_in_water, + [](const double s) { return s; }); + + auto sgl = + gridDefaultedVector(G, init, "SGL", tep.conn.gas, + [](const double s) { return s; }); + + std::transform(std::begin(sowcr), std::end(sowcr), + std::begin(sgl), std::begin(sdisp), + [](const double so, const double sg) + { + return 1.0 - (so + sg); + }); + } + else { // Oil not active (G/W?) + auto sgcr = + gridDefaultedVector(G, init, "SGCR", tep.crit.gas, + [](const double s) { return s; }); + + std::transform(std::begin(sgcr), std::end(sgcr), + std::begin(sdisp), + [](const double sg) + { + return 1.0 - sg; + }); + } + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRWR", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRW", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical:: +scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const RTEP& tep, + const FValVec& fvals) +{ + using SSys = ::Opm::SatFunc::CreateEPS::SubSystem; + using PhIdx = ::Opm::ECLPhaseIndex; + + if (opt.subSys == SSys::OilWater) { + if (opt.thisPh == PhIdx::Vapour) { + throw std::invalid_argument { + "Cannot Create Critical Saturation Vertical " + "Scaling for Gas Relperm in an Oil/Water System" + }; + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::CritSatVertical::Kr::W(G, init, tep, fvals); + } + + return Create::CritSatVertical::Kr::OW(G, init, tep, fvals); + } + + if (opt.subSys == SSys::OilGas) { + if (opt.thisPh == PhIdx::Aqua) { + throw std::invalid_argument { + "Cannot Create Critical Saturation Vertical " + "Scaling for Water Relperm in an Oil/Gas System" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::CritSatVertical::Kr::G(G, init, tep, fvals); + } + + return Create::CritSatVertical::Kr::GO(G, init, tep, fvals); + } + + // Invalid. + return {}; +} + // ##################################################################### // ===================================================================== // Public Interface Below Separator @@ -1339,12 +2030,17 @@ Opm::SatFunc::EPSEvalInterface::~EPSEvalInterface() // --------------------------------------------------------------------- +// Class Opm::SatFunc::VerticalScalingInterface +Opm::SatFunc::VerticalScalingInterface::~VerticalScalingInterface() +{} + +// --------------------------------------------------------------------- + // Class Opm::SatFunc::TwoPointScaling Opm::SatFunc::TwoPointScaling:: -TwoPointScaling(std::vector smin, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) - : pImpl_(new Impl(std::move(smin), std::move(smax), handle_invalid)) +TwoPointScaling(std::vector smin, + std::vector smax) + : pImpl_(new Impl(std::move(smin), std::move(smax))) {} Opm::SatFunc::TwoPointScaling::~TwoPointScaling() @@ -1398,16 +2094,65 @@ Opm::SatFunc::TwoPointScaling::clone() const // --------------------------------------------------------------------- +// Class Opm::SatFunc::PureVerticalScaling + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(std::vector fmax) + : pImpl_(new Impl(std::move(fmax))) +{} + +Opm::SatFunc::PureVerticalScaling::~PureVerticalScaling() +{} + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(const PureVerticalScaling& rhs) + : pImpl_(new Impl(*rhs.pImpl_)) +{} + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(PureVerticalScaling&& rhs) + : pImpl_(std::move(rhs.pImpl_)) +{} + +Opm::SatFunc::PureVerticalScaling& +Opm::SatFunc::PureVerticalScaling::operator=(const PureVerticalScaling& rhs) +{ + this->pImpl_.reset(new Impl(*rhs.pImpl_)); + + return *this; +} + +Opm::SatFunc::PureVerticalScaling& +Opm::SatFunc::PureVerticalScaling::operator=(PureVerticalScaling&& rhs) +{ + this->pImpl_ = std::move(rhs.pImpl_); + + return *this; +} + +std::vector +Opm::SatFunc::PureVerticalScaling:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const +{ + return this->pImpl_->vertScale(f, sp, val); +} + +std::unique_ptr +Opm::SatFunc::PureVerticalScaling::clone() const +{ + return std::unique_ptr(new PureVerticalScaling(*this)); +} + +// --------------------------------------------------------------------- + // Class Opm::SatFunc::ThreePointScaling Opm::SatFunc::ThreePointScaling:: -ThreePointScaling(std::vector smin, - std::vector sdisp, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) - : pImpl_(new Impl(std::move(smin) , - std::move(sdisp), - std::move(smax) , - handle_invalid)) +ThreePointScaling(std::vector smin, + std::vector sdisp, + std::vector smax) + : pImpl_(new Impl(std::move(smin), std::move(sdisp), std::move(smax))) {} Opm::SatFunc::ThreePointScaling::~ThreePointScaling() @@ -1459,10 +2204,68 @@ Opm::SatFunc::ThreePointScaling::clone() const } // --------------------------------------------------------------------- -// Factory function Opm::SatFunc::CreateEPS::fromECLOutput() + +// Class Opm::SatFunc::CritSatVerticalScaling +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(std::vector sdisp, + std::vector fdisp, + std::vector fmax) + : pImpl_(new Impl(std::move(sdisp), std::move(fdisp), std::move(fmax))) +{} + +Opm::SatFunc::CritSatVerticalScaling::~CritSatVerticalScaling() +{} + +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(const CritSatVerticalScaling& rhs) + : pImpl_(new Impl(*rhs.pImpl_)) +{} + +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(CritSatVerticalScaling&& rhs) + : pImpl_(std::move(rhs.pImpl_)) +{} + +Opm::SatFunc::CritSatVerticalScaling& +Opm::SatFunc::CritSatVerticalScaling:: +operator=(const CritSatVerticalScaling& rhs) +{ + this->pImpl_.reset(new Impl(*rhs.pImpl_)); + + return *this; +} + +Opm::SatFunc::CritSatVerticalScaling& +Opm::SatFunc::CritSatVerticalScaling:: +operator=(CritSatVerticalScaling&& rhs) +{ + this->pImpl_ = std::move(rhs.pImpl_); + + return *this; +} + +std::vector +Opm::SatFunc::CritSatVerticalScaling:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const +{ + return this->pImpl_->vertScale(f, sp, val); +} + +std::unique_ptr +Opm::SatFunc::CritSatVerticalScaling::clone() const +{ + return std::unique_ptr { + new CritSatVerticalScaling(*this) + }; +} + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Horizontal::fromECLOutput() std::unique_ptr -Opm::SatFunc::CreateEPS:: +Opm::SatFunc::CreateEPS::Horizontal:: fromECLOutput(const ECLGraph& G, const ECLInitFileData& init, const EPSOptions& opt) @@ -1483,10 +2286,10 @@ fromECLOutput(const ECLGraph& G, } // --------------------------------------------------------------------- -// Factory function Opm::SatFunc::CreateEPS::unscaledEndPoints() +// Factory function Opm::SatFunc::CreateEPS::Horizontal::unscaledEndPoints() std::vector -Opm::SatFunc::CreateEPS:: +Opm::SatFunc::CreateEPS::Horizontal:: unscaledEndPoints(const RawTableEndPoints& ep, const EPSOptions& opt) { @@ -1504,3 +2307,84 @@ unscaledEndPoints(const RawTableEndPoints& ep, // Invalid return {}; } + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Vertical::fromECLOutput() + +std::unique_ptr +Opm::SatFunc::CreateEPS::Vertical:: +fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt, + const RawTableEndPoints& tep, + const FuncValVector& fvals) +{ + const auto haveScaleCRS = + haveScaledRelPermAtCritSat(G, init, opt.thisPh, opt.subSys); + + if ((opt.curve == FunctionCategory::CapPress) || (! haveScaleCRS)) + { + return Create::PureVertical:: + scalingFunction(G, init, opt, fvals); + } + + if ((opt.curve == FunctionCategory::Relperm) && haveScaleCRS) + { + return Create::CritSatVertical:: + scalingFunction(G, init, opt, tep, fvals); + } + + // Invalid + return {}; +} + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Vertical::unscaledFunctionValues() + +std::vector +Opm::SatFunc::CreateEPS::Vertical:: +unscaledFunctionValues(const ECLGraph& G, + const ECLInitFileData& init, + const RawTableEndPoints& ep, + const EPSOptions& opt, + const SatFuncEvaluator& evalSF) +{ + auto ret = std::vector{}; + + const auto haveScaleCRS = + haveScaledRelPermAtCritSat(G, init, opt.thisPh, opt.subSys); + + if ((opt.curve == FunctionCategory::CapPress) || (! haveScaleCRS)) { + auto opt_cpy = opt; + opt_cpy.use3PtScaling = false; + + const auto uep = + Create::TwoPoint::unscaledEndPoints(ep, opt_cpy); + + ret.resize(uep.size()); + + for (auto n = uep.size(), i = 0*n; i < n; ++i) { + ret[i].max.sat = uep[i].high; + ret[i].max.val = evalSF(static_cast(i), ret[i].max.sat); + } + } + else { + auto opt_cpy = opt; + opt_cpy.use3PtScaling = true; + + const auto uep = + Create::ThreePoint::unscaledEndPoints(ep, opt_cpy); + + ret.resize(uep.size()); + + for (auto n = uep.size(), i = 0*n; i < n; ++i) { + ret[i].disp.sat = uep[i].disp; + ret[i].disp.val = evalSF(static_cast(i), ret[i].disp.sat); + + ret[i].max.sat = uep[i].high; + ret[i].max.val = evalSF(static_cast(i), ret[i].max.sat); + } + } + + return ret; +} diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp index acdb9e3cc4..42cc2aa679 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp @@ -127,6 +127,52 @@ namespace Opm { namespace SatFunc { virtual ~EPSEvalInterface(); }; + /// Protocol for computing vertically scaled relative permeability and + /// capillary pressure values. + class VerticalScalingInterface + { + public: + struct FunctionValues { + struct Point { + double sat; + double val; + }; + + Point disp; + Point max; + }; + + /// Associate a saturation value to a specific cell. + using SaturationAssoc = EPSEvalInterface::SaturationAssoc; + + /// Convenience type alias. + using SaturationPoints = EPSEvalInterface::SaturationPoints; + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const = 0; + + /// Virtual copy constructor. + virtual std::unique_ptr clone() const = 0; + + /// Destructor. Must be virtual. + virtual ~VerticalScalingInterface(); + }; + /// Implementation of ECLIPSE's standard, two-point, saturation scaling /// option. class TwoPointScaling : public EPSEvalInterface @@ -141,19 +187,8 @@ namespace Opm { namespace SatFunc { /// \param[in] smin Left end points for a set of cells. /// /// \param[in] smax Right end points for a set of cells. - /// - /// \param[in] handle_invalid How to treat scaling requests with - /// invalid scaled saturations. This can, for instance, happen - /// if the scaled saturations are present in the result set but - /// some (or all) cells have irreconcilable values (e.g., minimum - /// saturation greater than maximum saturation, smin < -1E+20, - /// smax < -1E+20). - /// - /// Default behaviour: Use unscaled saturation if this happens. - TwoPointScaling(std::vector smin, - std::vector smax, - const InvalidEndpointBehaviour handle_invalid - = InvalidEndpointBehaviour::UseUnscaled); + TwoPointScaling(std::vector smin, + std::vector smax); /// Destructor. ~TwoPointScaling(); @@ -244,6 +279,74 @@ namespace Opm { namespace SatFunc { std::unique_ptr pImpl_; }; + /// Implementation of ECLIPSE's standard, pure vertical saturation + /// function scaling option. + /// + /// Multiplies function values with a location (cell ID) dependent + /// factor. Applies to both relative permeability and capillary + /// pressure functions. + class PureVerticalScaling : public VerticalScalingInterface + { + public: + /// Constructor. + /// + /// Typically set up to define vertical scaling of saturation + /// function values in all active cells in a model, but could + /// alternatively be used as a means to computing the effective + /// saturation function value of a single cell. + /// + /// \param[in] fmax Scaled maximum saturation function (Kr or Pc) + /// value in collection of cells. Typically an input vector like + /// PCG or KROW from an ECL result set. + explicit PureVerticalScaling(std::vector fmax); + + /// Destructor. + virtual ~PureVerticalScaling(); + + /// Copy constructor. + PureVerticalScaling(const PureVerticalScaling& rhs); + + /// Move constructor. + PureVerticalScaling(PureVerticalScaling&& rhs); + + /// Assignment operator. + PureVerticalScaling& operator=(const PureVerticalScaling& rhs); + + /// Move assignment operator. + PureVerticalScaling& operator=(PureVerticalScaling&& rhs); + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. Method \c PureVerticalScaling + /// uses the maximum value/point only. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. Multiplies entries in \p val with an appropriate + /// location dependent factor. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const override; + + /// Virtual copy constructor. + virtual std::unique_ptr + clone() const override; + + private: + /// Implementation class. + class Impl; + + /// Pimpl idiom. + std::unique_ptr pImpl_; + }; + /// Implementation of ECLIPSE's alternative, three-point, saturation /// scaling option. class ThreePointScaling : public EPSEvalInterface @@ -261,20 +364,9 @@ namespace Opm { namespace SatFunc { /// for a set of cells. /// /// \param[in] smax Right end points for a set of cells. - /// - /// \param[in] handle_invalid How to treat scaling requests with - /// invalid scaled saturations. This can, for instance, happen - /// if the scaled saturations are present in the result set but - /// some (or all) cells have irreconcilable values (e.g., minimum - /// saturation greater than maximum saturation, smin < -1E+20, - /// smax < -1E+20). - /// - /// Default behaviour: Use unscaled saturation if this happens. - ThreePointScaling(std::vector smin, - std::vector sdisp, - std::vector smax, - const InvalidEndpointBehaviour handle_invalid - = InvalidEndpointBehaviour::UseUnscaled); + ThreePointScaling(std::vector smin, + std::vector sdisp, + std::vector smax); /// Destructor. ~ThreePointScaling(); @@ -365,6 +457,67 @@ namespace Opm { namespace SatFunc { std::unique_ptr pImpl_; }; + /// Implementation of ECLIPSE's option for vertical scaling of relative + /// permeability functions honouring critical/residual saturation of + /// displacing phase. + /// + /// Multiplies function values with a location (cell ID) and saturation + /// dependent factor. Not intended for capillary pressure functions. + class CritSatVerticalScaling : public VerticalScalingInterface + { + public: + /// Constructor. + explicit CritSatVerticalScaling(std::vector sdisp, + std::vector fdisp, + std::vector fmax); + + /// Destructor. + virtual ~CritSatVerticalScaling(); + + /// Copy constructor. + CritSatVerticalScaling(const CritSatVerticalScaling& rhs); + + /// Move constructor. + CritSatVerticalScaling(CritSatVerticalScaling&& rhs); + + /// Assignment operator. + CritSatVerticalScaling& operator=(const CritSatVerticalScaling& rhs); + + /// Move assignment operator. + CritSatVerticalScaling& operator=(CritSatVerticalScaling&& rhs); + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. The critical saturation vertical + /// scaling method uses both the displacement and the maximum + /// points. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const override; + + /// Virtual copy constructor. + virtual std::unique_ptr + clone() const override; + + private: + /// Implementation class. + class Impl; + + /// Pimpl idiom. + std::unique_ptr pImpl_; + }; + /// Named constructors for enabling saturation end-point scaling from an /// ECL result set (see class \c ECLInitFileData). struct CreateEPS @@ -494,46 +647,120 @@ namespace Opm { namespace SatFunc { Maximum smax; }; - /// Construct an EPS evaluator from a particular ECL result set. - /// - /// \param[in] G Connected topology of current model's active cells. - /// Needed to linearise table end-points that may be distributed - /// on local grids to all of the model's active cells (\code - /// member function G.rawLinearisedCellData() \endcode). - /// - /// \param[in] init Container of tabulated saturation functions and - /// saturation table end points for all active cells. - /// - /// \param[in] opt Options that identify a particular end-point - /// scaling behaviour of a particular saturation function curve. - /// - /// \return EPS evaluator for the particular curve defined by the - /// input options. - static std::unique_ptr - fromECLOutput(const ECLGraph& G, - const ECLInitFileData& init, - const EPSOptions& opt); - - /// Extract table end points relevant to a particular EPS evaluator - /// from raw tabulated saturation functions. - /// - /// \param[in] ep Collection of all raw table saturation end points - /// for all tabulated saturation functions. Typically computed - /// by direct calls to the \code connateSat() \endcode, \code - /// criticalSat() \endcode, and \code maximumSat() \endcode of - /// the currently active \code Opm::SatFuncInterpolant \code - /// objects. - /// - /// \param[in] opt Options that identify a particular end-point - /// scaling behaviour of a particular saturation function curve. - /// - /// \return Subset of the input end points in a format intended for - /// passing as the first argument of member function \code eval() - /// \endcode of the \code EPSEvalInterface \endcode that - /// corresponds to the input options. - static std::vector - unscaledEndPoints(const RawTableEndPoints& ep, - const EPSOptions& opt); + /// Named constructors for horizontal (saturation) end-point scaling + /// of saturation functions. + struct Horizontal { + /// Construct a horizontal EPS evaluator from a particular ECL + /// result set. + /// + /// \param[in] G Connected topology of current model's active + /// cells. Needed to linearise table end-points that may be + /// distributed on local grids to all of the model's active + /// cells (\code member function G.rawLinearisedCellData() + /// \endcode). + /// + /// \param[in] init Container of tabulated saturation functions + /// and saturation table end points for all active cells. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return EPS evaluator for the particular curve defined by + /// the input options. + static std::unique_ptr + fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt); + + /// Extract table end points relevant to a particular horizontal + /// EPS evaluator from raw tabulated saturation functions. + /// + /// \param[in] ep Collection of all raw table saturation end + /// points for all tabulated saturation functions. Typically + /// computed by direct calls to the \code connateSat() + /// \endcode, \code criticalSat() \endcode, and \code + /// maximumSat() \endcode of the currently active \code + /// Opm::SatFuncInterpolant \code objects. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return Subset of the input end points in a format intended + /// for passing as the first argument of member function + /// \code eval() \endcode of the \code EPSEvalInterface + /// \endcode that corresponds to the input options. + static std::vector + unscaledEndPoints(const RawTableEndPoints& ep, + const EPSOptions& opt); + }; + + /// Named constructors for vertical (value) scaling of saturation + /// functions. + struct Vertical { + using SatFuncEvaluator = std::function; + using FuncValVector = std::vector< + VerticalScalingInterface::FunctionValues>; + + /// Construct a vertical saturation function value scaling from + /// a particular ECL result set. + /// + /// \param[in] G Connected topology of current model's active + /// cells. Needed to linearise table end-points that may be + /// distributed on local grids to all of the model's active + /// cells (member functions \code G.rawLinearisedCellData() + /// \endcode and \code G.linearisedCellData() \endcode). + /// + /// \param[in] init Container of tabulated saturation functions + /// and saturation table end points for all active cells. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \param[in] tep Table end-points. Used to define critical + /// saturations of displacing phase for vertical scaling at + /// displacing saturation. Otherwise unused. + /// + /// \param[in] fvals Function values at selected saturation + /// points. Typically constructed by means of function + /// unscaledFunctionValues(). + /// + /// \return Vertical scaling operator for the particular curve + /// defined by the input options. + static std::unique_ptr + fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt, + const RawTableEndPoints& tep, + const FuncValVector& fvals); + + /// Extract table end points relevant to a particular vertical + /// scaling evaluator from raw tabulated saturation functions. + /// + /// \param[in] ep Collection of all raw table saturation end + /// points for all tabulated saturation functions. Typically + /// computed by direct calls to the \code connateSat() + /// \endcode, \code criticalSat() \endcode, and \code + /// maximumSat() \endcode of the currently active \code + /// Opm::SatFuncInterpolant \code objects. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return Subset of the input end points in a format intended + /// for passing as the first argument of member function + /// \code eval() \endcode of the \code EPSEvalInterface + /// \endcode that corresponds to the input options. + static std::vector + unscaledFunctionValues(const ECLGraph& G, + const ECLInitFileData& init, + const RawTableEndPoints& ep, + const EPSOptions& opt, + const SatFuncEvaluator& evalSF); + }; }; }} // namespace Opm::SatFunc diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp index 5550d376c3..c4f9429d4f 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -90,7 +90,7 @@ namespace { const auto depthscale = usys->depth(); for (auto& zi : depth) { - zi = ::Opm::unit::convert::from(zi, depthscale); + zi = ::ImportedOpm::unit::convert::from(zi, depthscale); } return depth; @@ -183,9 +183,9 @@ namespace Opm ECLFluxCalc::ECLFluxCalc(const ECLGraph& graph, const ECLInitFileData& init, const double grav, - const bool useEPS) + const bool /* useEPS */) : graph_(graph) - , satfunc_(graph, init, useEPS) + , satfunc_(graph, init) , rmap_(pvtnumVector(graph, init)) , neighbours_(graph.neighbours()) , transmissibility_(graph.transmissibility()) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp index 8783275b98..32b6739d32 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -604,7 +604,7 @@ ECL::getPVolVector(const ecl_grid_type* G, getUnitSystem(init, gridID)->reservoirVolume(); for (auto& pv : pvol) { - pv = ::Opm::unit::convert::from(pv, pvol_unit); + pv = ::ImportedOpm::unit::convert::from(pv, pvol_unit); } } @@ -1157,7 +1157,7 @@ connectionData(const ::Opm::ECLRestartData& rstrt, "Direction must be I, J, or K"); for (const auto& cell : cells->second) { - x.push_back(::Opm::unit::convert::from(v[cell], unit)); + x.push_back(::ImportedOpm::unit::convert::from(v[cell], unit)); } } @@ -1208,7 +1208,7 @@ deriveNeighbours(const std::vector& gcells, auto SI_trans = [trans_unit](const double trans) { - return ::Opm::unit::convert::from(trans, trans_unit); + return ::ImportedOpm::unit::convert::from(trans, trans_unit); }; auto& ocell = this->outCell_[d]; @@ -1288,6 +1288,9 @@ class Opm::ECLGraph::Impl /// Retrieve number of active cells in graph. std::size_t numCells() const; + /// Retrieve number of active cells in particular subgrid. + std::size_t numCells(const std::string& gridID) const; + /// Retrieve number of connections in graph. std::size_t numConnections() const; @@ -1364,6 +1367,24 @@ class Opm::ECLGraph::Impl rawLinearisedCellData(const ResultSet& rset, const std::string& vector) const; + /// Retrieve result set vector from current view (e.g., particular + /// report step) linearised on active cells of a particular sub-grid. + /// + /// \tparam T Element type of result set vector. + /// + /// \param[in] vector Name of result set vector. + /// + /// \param[in] gridID Identity of specific grid to which to relate the + /// requested vector. Use empty for main grid and names for any + /// LGRs. + /// + /// \return Result set vector linearised on active cells of sub-grid. + template + std::vector + rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const; + /// Retrieve floating-point result set vector from current view /// (e.g., particular report step) linearised on active cells and /// converted to strict SI unit conventions. @@ -1776,7 +1797,7 @@ NNC::add(const std::vector& grid, // Capture transmissibility field to support on-demand flux calculations // if flux fields are not output to the on-disk result set. - this->trans_.push_back(unit::convert::from(nnc.trans, trans_unit)); + this->trans_.push_back(ImportedOpm::unit::convert::from(nnc.trans, trans_unit)); const auto cat = this->classifyConnection(nnc.grid_nr1, nnc.grid_nr2); @@ -1997,6 +2018,15 @@ Opm::ECLGraph::Impl::numCells() const return this->activeOffset_.back(); } +std::size_t +Opm::ECLGraph::Impl::numCells(const std::string& gridID) const +{ + auto i = this->gridID_.find(gridID); + + return (i == std::end(this->gridID_)) + ? 0 : this->grid_[i->second].numCells(); +} + std::size_t Opm::ECLGraph::Impl::numConnections() const { @@ -2185,6 +2215,21 @@ namespace Opm { return x; } + + template + std::vector + ECLGraph::Impl::rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const + { + auto i = this->gridID_.find(gridID); + + if (i == std::end(this->gridID_)) { + return {}; + } + + return this->grid_[i->second].activeCellData(rset, vector); + } } // namespace Opm std::vector @@ -2211,7 +2256,7 @@ Opm::ECLGraph::Impl::linearisedCellData(const ECLRestartData& rstrt, std::back_inserter(x), [vector_unit](const double value) { - return ::Opm::unit::convert::from(value, vector_unit); + return ::ImportedOpm::unit::convert::from(value, vector_unit); }); } @@ -2285,7 +2330,7 @@ Opm::ECLGraph::Impl::fluxNNC(const ECLRestartData& rstrt, assert (ix.kwIdx < q.size()); v[ix.neighIdx] = - unit::convert::from(q[ix.kwIdx], flux_unit); + ImportedOpm::unit::convert::from(q[ix.kwIdx], flux_unit); assigned[ix.neighIdx] = true; } @@ -2408,6 +2453,11 @@ std::size_t Opm::ECLGraph::numCells() const return this->pImpl_->numCells(); } +std::size_t Opm::ECLGraph::numCells(const std::string& gridID) const +{ + return this->pImpl_->numCells(gridID); +} + std::size_t Opm::ECLGraph::numConnections() const { return this->pImpl_->numConnections(); @@ -2462,6 +2512,15 @@ namespace Opm { return this->pImpl_->rawLinearisedCellData(rset, vector); } + template + std::vector + ECLGraph::rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const + { + return this->pImpl_->rawLinearisedCellData(rset, vector, gridID); + } + // Explicit instantiations of method rawLinearisedCellData() for the // element and result set types we care about. template std::vector @@ -2480,6 +2539,26 @@ namespace Opm { ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, const std::string& vector) const; + template std::vector + ECLGraph::rawLinearisedCellData(const ECLInitFileData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLInitFileData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, + const std::string& vector, + const std::string& gridID) const; + } // namespace Opm std::vector diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp index e8114d7127..bd12218ea3 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp @@ -111,11 +111,14 @@ namespace Opm { /// outside valid range or if the specific cell identified by \p /// ijk and \p gridID is not actually active. int activeCell(const std::array& ijk, - const std::string& gridID = 0) const; + const std::string& gridID = "") const; /// Retrieve number of active cells in graph. std::size_t numCells() const; + /// Retrieve number of active cells in particular subgrid. + std::size_t numCells(const std::string& gridID) const; + /// Retrieve number of connections in graph. std::size_t numConnections() const; @@ -183,6 +186,24 @@ namespace Opm { rawLinearisedCellData(const ResultSet& rset, const std::string& vector) const; + /// Retrieve result set vector from current view (e.g., particular + /// report step) linearised on active cells of a particular sub-grid. + /// + /// \tparam T Element type of result set vector. + /// + /// \param[in] vector Name of result set vector. + /// + /// \param[in] gridID Identity of specific grid to which to relate + /// the requested vector. Use empty for main grid and names for + /// any LGRs. + /// + /// \return Result set vector linearised on active cells of sub-grid. + template + std::vector + rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const; + /// Convenience type alias for \c UnitSystem PMFs (pointer to member /// function). typedef double (ECLUnits::UnitSystem::*UnitConvention)() const; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp index 07a6b05e7c..65f2a18c48 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -315,7 +315,7 @@ namespace { double calculateScaleFactor(const double from, const double to) { - using namespace ::Opm::unit; + using namespace ::ImportedOpm::unit; // "return from / to", essentially. return convert::to(convert::from(1.0, from), to); diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp index 56bb6d075f..f55b771164 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ namespace { return ::Opm::ECLPVT::ConvertUnits::Converter { [uscale](const double q) -> double { - return ::Opm::unit::convert::from(q, uscale); + return ::ImportedOpm::unit::convert::from(q, uscale); } }; } @@ -326,7 +326,7 @@ Opm::ECLPVT::surfaceMassDensity(const ECLInitFileData& init, const auto dens_scale = u->density(); for (auto& rho_i : rho) { - rho_i = unit::convert::from(rho_i, dens_scale); + rho_i = ImportedOpm::unit::convert::from(rho_i, dens_scale); } return rho; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp index e84cba83b9..fef7dd5140 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp index b572ccb35a..362ae167f8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace { return [scale](const double x) -> double { - return Opm::unit::convert::from(x, scale); + return ImportedOpm::unit::convert::from(x, scale); }; } @@ -59,7 +59,7 @@ namespace { return [scale](const double x) -> double { - return Opm::unit::convert::from(x, scale); + return ImportedOpm::unit::convert::from(x, scale); }; } diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp index ec71e996f2..522def78e6 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -121,6 +121,20 @@ namespace { return { std::move(Sx), std::move(y) }; } + + bool enableHorizontalEPS(const Opm::ECLSaturationFunc::SatFuncScaling& scaling) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + return (scaling.enable & T::Horizontal) != 0; + } + + bool enableVerticalSFScaling(const Opm::ECLSaturationFunc::SatFuncScaling& scaling) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + return (scaling.enable & T::Vertical) != 0; + } } // Anonymous // ===================================================================== @@ -589,7 +603,7 @@ Gas::Details::unitConverter(const int usys) const auto pscale = u->pressure(); auto cvrt_press = [pscale](const double p) { - return ::Opm::unit::convert::from(p, pscale); + return ::ImportedOpm::unit::convert::from(p, pscale); }; return CU { @@ -680,7 +694,7 @@ Water::Details::unitConverter(const int usys) const auto pscale = u->pressure(); auto cvrt_press = [pscale](const double p) { - return ::Opm::unit::convert::from(p, pscale); + return ::ImportedOpm::unit::convert::from(p, pscale); }; return CU { @@ -701,10 +715,8 @@ class Opm::ECLSaturationFunc::Impl Impl(Impl&& rhs); Impl(const Impl& rhs); - void init(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid); + void init(const ECLGraph& G, + const ECLInitFileData& init); void setOutputUnits(std::unique_ptr usys); @@ -716,7 +728,7 @@ class Opm::ECLSaturationFunc::Impl std::vector getSatFuncCurve(const std::vector& func, const int activeCell, - const bool useEPS) const; + const SatFuncScaling& scaling) const; private: class EPSEvaluator @@ -738,30 +750,33 @@ class Opm::ECLSaturationFunc::Impl bool wat; }; - void define(const ECLGraph& G, - const ECLInitFileData& init, - const RawTEP& ep, - const bool use3PtScaling, - const ActPh& active, - const InvalidEPBehaviour handle_invalid) + void define(const Impl& host, + const ECLGraph& G, + const ECLInitFileData& init, + const RawTEP& ep, + const bool use3PtScaling, + const ActPh& active) { auto opt = Create::EPSOptions{}; opt.use3PtScaling = use3PtScaling; - opt.handle_invalid = handle_invalid; + opt.handle_invalid = SatFuncScaling::IEB::UseUnscaled; if (active.oil) { - this->create_oil_eps(G, init, ep, active, opt); + this->create_oil_eps(host, G, init, ep, active, opt); } if (active.gas) { - this->create_gas_eps(G, init, ep, opt); + this->create_gas_eps(host, G, init, ep, opt); } if (active.wat) { - this->create_wat_eps(G, init, ep, opt); + this->create_wat_eps(host, G, init, ep, opt); } } + // --------------------------------------------- + // ---------- End-point scaling ---------------- + void scaleKrOG(const ECLRegionMapping& rmap, std::vector& so) const { @@ -798,6 +813,9 @@ class Opm::ECLSaturationFunc::Impl this->scale(this->wat_.pc, rmap, sw); } + // --------------------------------------------- + // ---------- Reverse scaling ------------------ + void reverseScaleKrOG(const ECLRegionMapping& rmap, std::vector& so) const { @@ -834,6 +852,51 @@ class Opm::ECLSaturationFunc::Impl this->reverseScale(this->wat_.pc, rmap, sw); } + // --------------------------------------------- + // ---------- Vertical scaling ----------------- + + void vertScaleKrOG(const ECLRegionMapping& rmap, + const std::vector& so, + std::vector& kr) const + { + this->vertScale(this->oil_in_og_, rmap, so, kr); + } + + void vertScaleKrOW(const ECLRegionMapping& rmap, + const std::vector& so, + std::vector& kr) const + { + this->vertScale(this->oil_in_ow_, rmap, so, kr); + } + + void vertScaleKrGas(const ECLRegionMapping& rmap, + const std::vector& sg, + std::vector& kr) const + { + this->vertScale(this->gas_.kr, rmap, sg, kr); + } + + void vertScaleKrWat(const ECLRegionMapping& rmap, + const std::vector& sw, + std::vector& kr) const + { + this->vertScale(this->wat_.kr, rmap, sw,kr); + } + + void vertScalePcGO(const ECLRegionMapping& rmap, + const std::vector& sg, + std::vector& pc) const + { + this->vertScale(this->gas_.pc, rmap, sg, pc); + } + + void vertScalePcOW(const ECLRegionMapping& rmap, + const std::vector& sw, + std::vector& pc) const + { + this->vertScale(this->wat_.pc, rmap, sw, pc); + } + private: using Create = ::Opm::SatFunc::CreateEPS; using FCat = ::Opm::SatFunc::CreateEPS::FunctionCategory; @@ -844,9 +907,16 @@ class Opm::ECLSaturationFunc::Impl using EPSEndPts = ::Opm::SatFunc::EPSEvalInterface::TableEndPoints; using EPSEndPtVec = std::vector; + using VSInterface = ::Opm::SatFunc::VerticalScalingInterface; + using VSFuncVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + using VSFValVec = std::vector; + using EPSPtr = std::unique_ptr; using EndPtsPtr = std::unique_ptr; + using VScalPtr = std::unique_ptr; + using VScalFVVecPtr = std::unique_ptr; + struct EPS { EPS() {} @@ -859,11 +929,23 @@ class Opm::ECLSaturationFunc::Impl if (rhs.tep) { this->tep = EndPtsPtr(new EPSEndPtVec(*rhs.tep)); } + + if (rhs.vertscaling) { + this->vertscaling = rhs.vertscaling->clone(); + } + + if (rhs.vertfuncval) { + this->vertfuncval = VScalFVVecPtr { + new VSFValVec(*rhs.vertfuncval) + }; + } } EPS(EPS&& rhs) - : scaling(std::move(rhs.scaling)) - , tep (std::move(rhs.tep)) + : scaling (std::move(rhs.scaling)) + , tep (std::move(rhs.tep)) + , vertscaling(std::move(rhs.vertscaling)) + , vertfuncval(std::move(rhs.vertfuncval)) {} EPS& operator=(const EPS& rhs) @@ -876,6 +958,16 @@ class Opm::ECLSaturationFunc::Impl this->tep = EndPtsPtr(new EPSEndPtVec(*rhs.tep)); } + if (rhs.vertscaling) { + this->vertscaling = rhs.vertscaling->clone(); + } + + if (rhs.vertfuncval) { + this->vertfuncval = VScalFVVecPtr { + new VSFValVec(*rhs.vertfuncval) + }; + } + return *this; } @@ -884,11 +976,17 @@ class Opm::ECLSaturationFunc::Impl this->scaling = std::move(rhs.scaling); this->tep = std::move(rhs.tep); + this->vertscaling = std::move(rhs.vertscaling); + this->vertfuncval = std::move(rhs.vertfuncval); + return *this; } EPSPtr scaling; EndPtsPtr tep; + + VScalPtr vertscaling; + VScalFVVecPtr vertfuncval; }; struct FullEPS { @@ -901,6 +999,9 @@ class Opm::ECLSaturationFunc::Impl FullEPS gas_; FullEPS wat_; + // ---------------------------------------------- + // ------- End-point scaling (engine) ----------- + void scale(const EPS& eps, const ECLRegionMapping& rmap, std::vector& s) const @@ -929,10 +1030,13 @@ class Opm::ECLSaturationFunc::Impl const auto sr = eps.scaling->eval((*eps.tep)[regID - 1], sp); - this->assignScaledSaturations(rmap, regID, sr, s); + this->assignScaledResult(rmap, regID, sr, s); } } + // ---------------------------------------------- + // ------- Reverse end-point scaling (engine) --- + void reverseScale(const EPS& eps, const ECLRegionMapping& rmap, std::vector& s) const @@ -961,10 +1065,54 @@ class Opm::ECLSaturationFunc::Impl const auto sr = eps.scaling->reverse((*eps.tep)[regID - 1], sp); - this->assignScaledSaturations(rmap, regID, sr, s); + this->assignScaledResult(rmap, regID, sr, s); } } + // ---------------------------------------------- + // ------- Vertical scaling (engine) ------------ + + void vertScale(const EPS& scalop, + const ECLRegionMapping& rmap, + const std::vector& s, + std::vector& sfval) const + { + assert (rmap.regionSubset().size() == s.size()); + assert (sfval.size() == s.size()); + + if (! scalop.vertscaling) { + // No vertical scaling defined for this curve. Return + // unchanged. + return; + } + + if (! scalop.vertfuncval) { + throw std::logic_error { + "Cannot Perform Vertical Scaling in " + "Absence of Function Value Data" + }; + } + + const auto& fval_table = *scalop.vertfuncval; + + for (const auto& regID : rmap.activeRegions()) { + const auto sp = + this->getSaturationPoints(rmap, regID, s); + + // Assume 'regID' is a traditional ECL-style, one-based + // region ID (e.g., SATNUM entry). + const auto& f = fval_table[regID - 1]; + + const auto scaled_fval = + scalop.vertscaling->vertScale(f, sp, sfval); + + this->assignScaledResult(rmap, regID, scaled_fval, sfval); + } + } + + // ---------------------------------------------- + // ------- Helpers for engine functions --------- + EPSInterface::SaturationPoints getSaturationPoints(const ECLRegionMapping& rmap, const int regID, @@ -988,52 +1136,94 @@ class Opm::ECLSaturationFunc::Impl return sp; } - void - assignScaledSaturations(const ECLRegionMapping& rmap, + void assignScaledResult(const ECLRegionMapping& rmap, const int regID, - const std::vector& sr, - std::vector& s) const + const std::vector& result, + std::vector& output) const { - auto i = static_cast(0); + auto i = static_cast(0); for (const auto& ix : rmap.getRegionIndices(regID)) { - s[ix] = sr[i++]; + output[ix] = result[i++]; } } - void create_oil_eps(const ECLGraph& G, + // ---------------------------------------------- + // ---- Constructor functions for scaling ops --- + + void create_oil_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, const ActPh& active, Create::EPSOptions& opt) { + assert (host.oil_ != nullptr); + opt.thisPh = PhIdx::Liquid; opt.curve = FCat::Relperm; // Oil EPS only applies to Kr + using SOil = Oil::KrFunction::SOil; + if (active.gas) { opt.subSys = SSys::OilGas; - this->oil_in_og_.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->oil_in_og_; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->oil_in_og_.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + const auto ssys = RawCurve::SubSystem::OilGas; + + return host.oil_-> + kro(regID, SOil{ { sat } }, ssys)[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } if (active.wat) { opt.subSys = SSys::OilWater; - this->oil_in_ow_.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->oil_in_ow_; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->oil_in_ow_.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + const auto ssys = RawCurve::SubSystem::OilWater; + + return host.oil_-> + kro(regID, SOil{ { sat } }, ssys)[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } } - void create_gas_eps(const ECLGraph& G, + void create_gas_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, Create::EPSOptions& opt) { + assert (host.gas_ != nullptr); + opt.thisPh = PhIdx::Vapour; opt.subSys = SSys::OilGas; @@ -1041,10 +1231,23 @@ class Opm::ECLSaturationFunc::Impl { opt.curve = FCat::Relperm; - this->gas_.kr.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->gas_.kr; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); - this->gas_.kr.tep = this->endPoints(ep, opt); + eps.tep = this->endPoints(ep, opt); + + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.gas_->krg(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } // Scaling for Gas/Oil capillary pressure @@ -1056,21 +1259,37 @@ class Opm::ECLSaturationFunc::Impl opt.curve = FCat::CapPress; - this->gas_.pc.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->gas_.pc; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->gas_.pc.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.gas_->pcgo(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); // Restore original setting for Alternative scaling option. opt.use3PtScaling = use3Pt; } } - void create_wat_eps(const ECLGraph& G, + void create_wat_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, Create::EPSOptions& opt) { + assert (host.wat_ != nullptr); + opt.thisPh = PhIdx::Aqua; opt.subSys = SSys::OilWater; @@ -1078,10 +1297,23 @@ class Opm::ECLSaturationFunc::Impl { opt.curve = FCat::Relperm; - this->wat_.kr.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->wat_.kr; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->wat_.kr.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.wat_->krw(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } // Scaling for Oil/Water capillary pressure @@ -1093,24 +1325,49 @@ class Opm::ECLSaturationFunc::Impl opt.curve = FCat::CapPress; - this->wat_.pc.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->wat_.pc; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); + + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.wat_->pcow(regID, { sat })[0]; + }); - this->wat_.pc.tep = this->endPoints(ep, opt); + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); // Restore original setting for Alternative scaling option. opt.use3PtScaling = use3Pt; } - } EndPtsPtr endPoints(const RawTEP& ep, const Create::EPSOptions& opt) { return EndPtsPtr { - new EPSEndPtVec(Create::unscaledEndPoints(ep, opt)) + new EPSEndPtVec(Create::Horizontal::unscaledEndPoints(ep, opt)) }; } + + VScalFVVecPtr + vertFuncVal(const ECLGraph& G, + const ECLInitFileData& init, + const RawTEP& ep, + const Create::EPSOptions& opt, + std::function f) + { + auto val = Create::Vertical:: + unscaledFunctionValues(G, init, ep, opt, std::move(f)); + + return VScalFVVecPtr { new VSFValVec(std::move(val)) }; + } }; std::vector satnum_; @@ -1136,76 +1393,75 @@ class Opm::ECLSaturationFunc::Impl void initEPS(const EPSEvaluator::ActPh& active, const bool use3PtScaling, const ECLGraph& G, - const ECLInitFileData& init, - const InvalidEPBehaviour handle_invalid); + const ECLInitFileData& init); void setNumTables(const ECLPropTableRawData::SizeType ntab); std::vector kro(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph kroCurve(const ECLRegionMapping& rmap, const std::size_t regID, const RawCurve::SubSystem subsys, const std::vector& so, - const bool useEPS) const; + const SatFuncScaling& scaling) const; std::vector krg(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph krgCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const; + const SatFuncScaling& scaling) const; FlowDiagnostics::Graph pcgoCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const; + const SatFuncScaling& scaling) const; std::vector krw(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph krwCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const; + const SatFuncScaling& scaling) const; FlowDiagnostics::Graph pcowCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const; + const SatFuncScaling& scaling) const; void scaleKrGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const; void scalePcGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const; void scaleKrOilSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& so_g, std::vector& so_w) const; void scaleKrWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sw) const; void scalePcWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sw) const; void uniqueReverseScaleSat(std::vector& s) const; @@ -1303,10 +1559,8 @@ Opm::ECLSaturationFunc::Impl::Impl(const Impl& rhs) // --------------------------------------------------------------------- void -Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid) +Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, + const ECLInitFileData& init) { // Extract INTEHEAD from main grid const auto& ih = init.keywordData(INTEHEAD_KW); @@ -1316,19 +1570,18 @@ Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, this->initRelPermInterp(active, init, ih[INTEHEAD_UNIT_INDEX]); - if (useEPS) { - const auto& lh = init.keywordData(LOGIHEAD_KW); + // Activate saturation function scaling if present in result set. + const auto& lh = init.keywordData(LOGIHEAD_KW); - const auto haveEPS = static_cast( - lh[LOGIHEAD_ENDPOINT_SCALING_INDEX]); + const auto haveEPS = static_cast( + lh[LOGIHEAD_ENDPOINT_SCALING_INDEX]); - if (haveEPS) { - const auto use3PtScaling = static_cast( - lh[LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX]); + if (haveEPS) { + const auto use3PtScaling = static_cast( + lh[LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX]); - // Must be called *after* initRelPermInterp(). - this->initEPS(active, use3PtScaling, G, init, handle_invalid); - } + // Must be called *after* initRelPermInterp(). + this->initEPS(active, use3PtScaling, G, init); } } @@ -1394,14 +1647,15 @@ void Opm::ECLSaturationFunc:: Impl::initEPS(const EPSEvaluator::ActPh& active, const bool use3PtScaling, const ECLGraph& G, - const ECLInitFileData& init, - const InvalidEPBehaviour handle_invalid) + const ECLInitFileData& init) { const auto ep = this->extractRawTableEndPoints(active); this->eps_.reset(new EPSEvaluator()); - this->eps_->define(G, init, ep, use3PtScaling, active, handle_invalid); + if (this->eps_ != nullptr) { + this->eps_->define(*this, G, init, ep, use3PtScaling, active); + } } void Opm::ECLSaturationFunc:: @@ -1457,7 +1711,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: getSatFuncCurve(const std::vector& func, const int activeCell, - const bool useEPS) const + const SatFuncScaling& scaling) const { using SatPointAssoc = std::pair< std::vector, @@ -1501,9 +1755,9 @@ getSatFuncCurve(const std::vector& func, auto crv = (fi.curve == RawCurve::Function::RelPerm) ? this->krwCurve (*wat_assoc.second, regID, - wat_assoc.first, useEPS) + wat_assoc.first, scaling) : this->pcowCurve(*wat_assoc.second, regID, - wat_assoc.first, useEPS); + wat_assoc.first, scaling); graph.push_back(std::move(crv)); } @@ -1532,7 +1786,7 @@ getSatFuncCurve(const std::vector& func, const auto kro = this->kroCurve(*oil_assoc.second, regID, - fi.subsys, oil_assoc.first, useEPS); + fi.subsys, oil_assoc.first, scaling); const auto So_off = (fi.subsys == RawCurve::SubSystem::OilGas) ? oil_assoc.first.back() // Sg = Max{So} - So in G/O system @@ -1568,9 +1822,9 @@ getSatFuncCurve(const std::vector& func, auto crv = (fi.curve == RawCurve::Function::RelPerm) ? this->krgCurve (*gas_assoc.second, regID, - gas_assoc.first, useEPS) + gas_assoc.first, scaling) : this->pcgoCurve(*gas_assoc.second, regID, - gas_assoc.first, useEPS); + gas_assoc.first, scaling); graph.push_back(std::move(crv)); } @@ -1588,7 +1842,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: kro(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1602,7 +1856,7 @@ kro(const ECLGraph& G, auto so_g = oil_saturation(sg, sw, G, rstrt); auto so_w = so_g; - this->scaleKrOilSat(this->rmap_, useEPS, so_g, so_w); + this->scaleKrOilSat(this->rmap_, scaling, so_g, so_w); // Allocate result. Member function scatterRegionResult() depends on // having an allocated result vector into which to write the values from @@ -1650,7 +1904,7 @@ kroCurve(const ECLRegionMapping& rmap, const std::size_t regID, const RawCurve::SubSystem subsys, const std::vector& so, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->oil_) { return FlowDiagnostics::Graph{}; @@ -1658,7 +1912,7 @@ kroCurve(const ECLRegionMapping& rmap, auto so_g = so; auto so_w = so_g; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrOG(rmap, so_g); this->eps_->reverseScaleKrOW(rmap, so_w); @@ -1681,7 +1935,7 @@ kroCurve(const ECLRegionMapping& rmap, so_g.resize(so.size(), 1.0); so_w.resize(so.size(), 1.0); - this->scaleKrOilSat(rmap, useEPS, so_g, so_w); + this->scaleKrOilSat(rmap, scaling, so_g, so_w); const auto so_inp = Oil::KrFunction::SOil { (subsys == RawCurve::SubSystem::OilGas) ? so_g : so_w @@ -1689,7 +1943,19 @@ kroCurve(const ECLRegionMapping& rmap, // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->oil_->kro(regID - 1, so_inp, subsys); + auto kr = this->oil_->kro(regID - 1, so_inp, subsys); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + if (subsys == RawCurve::SubSystem::OilGas) { + this->eps_->vertScaleKrOG(rmap, so, kr); + } + else { + this->eps_->vertScaleKrOW(rmap, so, kr); + } + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1702,7 +1968,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: krg(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1712,7 +1978,7 @@ krg(const ECLGraph& G, auto sg = G.rawLinearisedCellData(rstrt, "SGAS"); - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrGas(this->rmap_, sg); } @@ -1745,14 +2011,14 @@ Opm::ECLSaturationFunc::Impl:: krgCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->gas_) { return FlowDiagnostics::Graph{}; } auto sg_inp = sg; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrGas(rmap, sg_inp); this->uniqueReverseScaleSat(sg_inp); } @@ -1769,11 +2035,18 @@ krgCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sg_inp.resize(sg.size(), 1.0); - this->scaleKrGasSat(rmap, useEPS, sg_inp); + this->scaleKrGasSat(rmap, scaling, sg_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->gas_->krg(regID - 1, sg_inp); + auto kr = this->gas_->krg(regID - 1, sg_inp); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScaleKrGas(rmap, sg, kr); + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1787,14 +2060,14 @@ Opm::ECLSaturationFunc::Impl:: pcgoCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->gas_) { return FlowDiagnostics::Graph{}; } auto sg_inp = sg; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScalePcGO(rmap, sg_inp); this->uniqueReverseScaleSat(sg_inp); } @@ -1811,12 +2084,19 @@ pcgoCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sg_inp.resize(sg.size(), 1.0); - this->scalePcGasSat(rmap, useEPS, sg_inp); + this->scalePcGasSat(rmap, scaling, sg_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. auto pc = this->gas_->pcgo(regID - 1, sg_inp); + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScalePcGO(rmap, sg, pc); + } + if (this->usys_output_ != nullptr) { ::Opm::ECLUnits::Convert::Pressure() .from(*this->usys_internal_) @@ -1834,7 +2114,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: krw(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1844,7 +2124,7 @@ krw(const ECLGraph& G, auto sw = G.rawLinearisedCellData(rstrt, "SWAT"); - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrWat(this->rmap_, sw); } @@ -1877,14 +2157,14 @@ Opm::ECLSaturationFunc::Impl:: krwCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->wat_) { return FlowDiagnostics::Graph{}; } auto sw_inp = sw; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrWat(rmap, sw_inp); this->uniqueReverseScaleSat(sw_inp); } @@ -1901,11 +2181,18 @@ krwCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sw_inp.resize(sw.size(), 1.0); - this->scaleKrWaterSat(rmap, useEPS, sw_inp); + this->scaleKrWaterSat(rmap, scaling, sw_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->wat_->krw(regID - 1, sw_inp); + auto kr = this->wat_->krw(regID - 1, sw_inp); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScaleKrWat(rmap, sw, kr); + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1919,14 +2206,14 @@ Opm::ECLSaturationFunc::Impl:: pcowCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->wat_) { return FlowDiagnostics::Graph{}; } auto sw_inp = sw; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScalePcOW(rmap, sw_inp); this->uniqueReverseScaleSat(sw_inp); } @@ -1943,12 +2230,19 @@ pcowCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sw_inp.resize(sw.size(), 1.0); - this->scalePcWaterSat(rmap, useEPS, sw_inp); + this->scalePcWaterSat(rmap, scaling, sw_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. auto pc = this->wat_->pcow(regID - 1, sw_inp); + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScalePcOW(rmap, sw, pc); + } + if (this->usys_output_ != nullptr) { ::Opm::ECLUnits::Convert::Pressure() .from(*this->usys_internal_) @@ -1965,10 +2259,10 @@ pcowCurve(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrGas(rmap, sg); } } @@ -1976,10 +2270,10 @@ scaleKrGasSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scalePcGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scalePcGO(rmap, sg); } } @@ -1987,11 +2281,11 @@ scalePcGasSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrOilSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& so_g, std::vector& so_w) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { // Independent scaling of So in O/G and O/W sub-systems of an O/G/W // run. Performs duplicate work in a two-phase case. Need to take // action if this becomes a bottleneck. @@ -2003,10 +2297,10 @@ scaleKrOilSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrWat(rmap, sg); } } @@ -2014,10 +2308,10 @@ scaleKrWaterSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scalePcWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scalePcOW(rmap, sg); } } @@ -2087,13 +2381,11 @@ extractRawTableEndPoints(const EPSEvaluator::ActPh& active) const // ===================================================================== Opm::ECLSaturationFunc:: -ECLSaturationFunc(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid) +ECLSaturationFunc(const ECLGraph& G, + const ECLInitFileData& init) : pImpl_(new Impl(G, init)) { - this->pImpl_->init(G, init, useEPS, handle_invalid); + this->pImpl_->init(G, init); } Opm::ECLSaturationFunc::~ECLSaturationFunc() @@ -2145,5 +2437,20 @@ getSatFuncCurve(const std::vector& func, const int activeCell, const bool useEPS) const { - return this->pImpl_->getSatFuncCurve(func, activeCell, useEPS); + auto scaling = SatFuncScaling{}; + + if (! useEPS) { + scaling.enable = static_cast(0); + } + + return this->getSatFuncCurve(func, activeCell, scaling); +} + +std::vector +Opm::ECLSaturationFunc:: +getSatFuncCurve(const std::vector& func, + const int activeCell, + const SatFuncScaling& scaling) const +{ + return this->pImpl_->getSatFuncCurve(func, activeCell, scaling); } diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp index 52da556bcc..ff9926d0aa 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp @@ -79,8 +79,26 @@ namespace Opm { ECLPhaseIndex thisPh; }; - using InvalidEPBehaviour = ::Opm::SatFunc:: - EPSEvalInterface::InvalidEndpointBehaviour; + struct SatFuncScaling { + enum Type : unsigned char { + Horizontal = 1 << 0u, + Vertical = 1 << 1u, + }; + + using IEB = SatFunc::EPSEvalInterface::InvalidEndpointBehaviour; + + SatFuncScaling() + : enable (Type::Horizontal | Type::Vertical) + , invalid(IEB::UseUnscaled) + {} + + // Default: Use both Horizontal and Vertical if specified. + unsigned char enable; + + // Default: Use unscaled values in case of invalid scaled + // saturations occurring in the result set. + IEB invalid; + }; /// Constructor /// @@ -92,27 +110,8 @@ namespace Opm { /// \param[in] init Container of tabulated saturation functions and /// saturation table end points, if applicable, for all active /// cells in the model \p G. - /// - /// \param[in] useEPS Whether or not to include effects of - /// saturation end-point scaling. No effect if the INIT result - /// set does not actually include saturation end-point scaling - /// data. Otherwise, enables turning EPS off even if associate - /// data is present in the INIT result set. - /// - /// Default value (\c true) means that effects of EPS are - /// included if requisite data is present in the INIT result. - /// - /// \param[in] handle_invalid Run-time policy for how to handle - /// scaling requests relative to invalid scaled saturations - /// (e.g., SWL = -1.0E+20). - /// - /// Default value (\c UseUnscaled) means that invalid scalings - /// are treated as unscaled. - ECLSaturationFunc(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS = true, - const InvalidEPBehaviour handle_invalid - = InvalidEPBehaviour::UseUnscaled); + ECLSaturationFunc(const ECLGraph& G, + const ECLInitFileData& init); /// Destructor. ~ECLSaturationFunc(); @@ -253,6 +252,69 @@ namespace Opm { const int activeCell, const bool useEPS = true) const; + /// Retrieve 2D graph representations of sequence of effective + /// saturation functions in a single cell. + /// + /// \param[in] func Sequence of saturation function descriptions. + /// + /// \param[in] activeCell Index of active cell from which to derive + /// the effective saturation function. Use member function \code + /// ECLGraph::activeCell() \endcode to translate a global cell + /// (I,J,K) tuple--relative to a model grid--to a linear active + /// cell ID. + /// + /// \param[in] scaling Which type of saturation function scaling to + /// apply. No effect if the INIT result set from which the + /// object was constructed does not actually include saturation + /// end-point scaling or function value scaling data. Otherwise, + /// enables turning various scaling effects on or off even if + /// associate data is present in the INIT result set. + /// + /// \return Sequence of 2D graphs for all saturation function + /// requests represented by \p func. In particular, the \c i-th + /// element of the result corresponds to input request \code + /// func[i] \endcode. Abscissas are stored in \code + /// graph[i].first \endcode and ordinates are stored in \code + /// graph[i].second \endcode. If a particular request is + /// semantically invalid, such as when requesting the water + /// relative permeability in the oil-gas system, then the + /// corresponding graph in the result is empty. + /// + /// Example: Retrieve relative permeability curves for oil in active + /// cell 2718 in both the oil-gas and oil-water sub-systems + /// including effects of vertical scaling only. + /// + /// \code + /// using RC = ECLSaturationFunc::RawCurve; + /// auto func = std::vector{}; + /// func.reserve(2); + /// + /// // Request krog (oil rel-perm in oil-gas system) + /// func.push_back(RC{ + /// RC::Function::RelPerm, + /// RC::SubSystem::OilGas, + /// ECLPhaseIndex::Liquid + /// }); + /// + /// // Request krow (oil rel-perm in oil-water system) + /// func.push_back(RC{ + /// RC::Function::RelPerm, + /// RC::SubSystem::OilWater, + /// ECLPhaseIndex::Liquid + /// }); + /// + /// auto scaling = SatFuncScaling{}; + /// scaling.enable = static_cast(0); + /// scaling.enable |= SatFuncScaling::Type::Vertical; + /// + /// const auto graph = + /// sfunc.getSatFuncCurve(func, 2718, scaling); + /// \endcode + std::vector + getSatFuncCurve(const std::vector& func, + const int activeCell, + const SatFuncScaling& scaling) const; + private: /// Implementation backend. class Impl; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp index 3d2815d5c9..7cd052ec8c 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp @@ -23,7 +23,7 @@ #include -#include +#include #include #include @@ -38,6 +38,8 @@ namespace Opm { namespace ECLUnits { template class USys; + using namespace ImportedOpm; + template <> class USys : public ::Opm::ECLUnits::UnitSystem { diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp index 78a477fddd..673ecc8546 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -217,6 +217,7 @@ namespace Opm for (int well = 0; well < ih.nwell; ++well) { // Skip if total rate below threshold (for wells that are // shut or stopped for example). + using namespace ImportedOpm; const double well_reservoir_inflow_rate = -unit::convert::from(xwel[well * ih.nxwel + XWEL_RESV_INDEX], qr_unit); if (std::fabs(well_reservoir_inflow_rate) < rate_threshold_) { continue; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp new file mode 100644 index 0000000000..3c3f74deb1 --- /dev/null +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp @@ -0,0 +1,367 @@ +//=========================================================================== +// +// File: Units.hpp +// +// Created: Thu Jul 2 09:19:08 2009 +// +// Author(s): Halvor M Nilsen +// +// $Date$ +// +// $Revision$ +// +//=========================================================================== + +/* + Copyright 2009, 2010, 2011, 2012 SINTEF ICT, Applied Mathematics. + Copyright 2009, 2010, 2011, 2012 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef IMPORTED_OPM_UNITS_HEADER +#define IMPORTED_OPM_UNITS_HEADER + + +// WARNING! +// This file is a modified duplicate, imported to make this module independent. +// Modifications include file location, the header guard, and using the ImportedOpm namespace. + + +/** + The unit sets emplyed in ECLIPSE, in particular the FIELD units, + are quite inconsistent. Ideally one should choose units for a set + of base quantities like Mass,Time and Length and then derive the + units for e.g. pressure and flowrate in a consisten manner. However + that is not the case; for instance in the metric system we have: + + [Length] = meters + [time] = days + [mass] = kg + + This should give: + + [Pressure] = [mass] / ([length] * [time]^2) = kg / (m * days * days) + + Instead pressure is given in Bars. When it comes to FIELD units the + number of such examples is long. +*/ +namespace ImportedOpm { + namespace prefix + /// Conversion prefix for units. + { + constexpr const double micro = 1.0e-6; /**< Unit prefix [\f$\mu\f$] */ + constexpr const double milli = 1.0e-3; /**< Unit prefix [m] */ + constexpr const double centi = 1.0e-2; /**< Non-standard unit prefix [c] */ + constexpr const double deci = 1.0e-1; /**< Non-standard unit prefix [d] */ + constexpr const double kilo = 1.0e3; /**< Unit prefix [k] */ + constexpr const double mega = 1.0e6; /**< Unit prefix [M] */ + constexpr const double giga = 1.0e9; /**< Unit prefix [G] */ + } // namespace prefix + + namespace unit + /// Definition of various units. + /// All the units are defined in terms of international standard + /// units (SI). Example of use: We define a variable \c k which + /// gives a permeability. We want to set \c k to \f$1\,mD\f$. + /// \code + /// using namespace Opm::unit + /// double k = 0.001*darcy; + /// \endcode + /// We can also use one of the prefixes defined in Opm::prefix + /// \code + /// using namespace Opm::unit + /// using namespace Opm::prefix + /// double k = 1.0*milli*darcy; + /// \endcode + { + ///\name Common powers + /// @{ + constexpr double square(double v) { return v * v; } + constexpr double cubic (double v) { return v * v * v; } + /// @} + + // -------------------------------------------------------------- + // Basic (fundamental) units and conversions + // -------------------------------------------------------------- + + /// \name Length + /// @{ + constexpr const double meter = 1; + constexpr const double inch = 2.54 * prefix::centi*meter; + constexpr const double feet = 12 * inch; + /// @} + + /// \name Time + /// @{ + constexpr const double second = 1; + constexpr const double minute = 60 * second; + constexpr const double hour = 60 * minute; + constexpr const double day = 24 * hour; + constexpr const double year = 365 * day; + /// @} + + /// \name Volume + /// @{ + constexpr const double gallon = 231 * cubic(inch); + constexpr const double stb = 42 * gallon; + constexpr const double liter = 1 * cubic(prefix::deci*meter); + /// @} + + /// \name Mass + /// @{ + constexpr const double kilogram = 1; + constexpr const double gram = 1.0e-3 * kilogram; + // http://en.wikipedia.org/wiki/Pound_(mass)#Avoirdupois_pound + constexpr const double pound = 0.45359237 * kilogram; + /// @} + + /// \name Energy + /// @{ + constexpr const double joule = 1; + constexpr const double btu = 1054.3503*joule; // "british thermal units" + /// @} + + // -------------------------------------------------------------- + // Standardised constants + // -------------------------------------------------------------- + + /// \name Standardised constant + /// @{ + constexpr const double gravity = 9.80665 * meter/square(second); + /// @} + + // -------------------------------------------------------------- + // Derived units and conversions + // -------------------------------------------------------------- + + /// \name Force + /// @{ + constexpr const double Newton = kilogram*meter / square(second); // == 1 + constexpr const double dyne = 1e-5*Newton; + constexpr const double lbf = pound * gravity; // Pound-force + /// @} + + /// \name Pressure + /// @{ + constexpr const double Pascal = Newton / square(meter); // == 1 + constexpr const double barsa = 100000 * Pascal; + constexpr const double atm = 101325 * Pascal; + constexpr const double psia = lbf / square(inch); + /// @} + + /// \name Temperature. This one is more complicated + /// because the unit systems used by Eclipse (i.e. degrees + /// Celsius and degrees Fahrenheit require to add or + /// subtract an offset for the conversion between from/to + /// Kelvin + /// @{ + constexpr const double degCelsius = 1.0; // scaling factor °C -> K + constexpr const double degCelsiusOffset = 273.15; // offset for the °C -> K conversion + + constexpr const double degFahrenheit = 5.0/9; // scaling factor °F -> K + constexpr const double degFahrenheitOffset = 255.37; // offset for the °C -> K conversion + /// @} + + /// \name Viscosity + /// @{ + constexpr const double Pas = Pascal * second; // == 1 + constexpr const double Poise = prefix::deci*Pas; + /// @} + + namespace perm_details { + constexpr const double p_grad = atm / (prefix::centi*meter); + constexpr const double area = square(prefix::centi*meter); + constexpr const double flux = cubic (prefix::centi*meter) / second; + constexpr const double velocity = flux / area; + constexpr const double visc = prefix::centi*Poise; + constexpr const double darcy = (velocity * visc) / p_grad; + // == 1e-7 [m^2] / 101325 + // == 9.869232667160130e-13 [m^2] + } + /// \name Permeability + /// @{ + /// + /// A porous medium with a permeability of 1 darcy permits a flow (flux) + /// of \f$1\,\mathit{cm}^3/s\f$ of a fluid with viscosity + /// \f$1\,\mathit{cP}\f$ (\f$1\,mPa\cdot s\f$) under a pressure gradient + /// of \f$1\,\mathit{atm}/\mathit{cm}\f$ acting across an area of + /// \f$1\,\mathit{cm}^2\f$. + /// + constexpr const double darcy = perm_details::darcy; + /// @} + + /** + * Unit conversion routines. + */ + namespace convert { + /** + * Convert from external units of measurements to equivalent + * internal units of measurements. Note: The internal units of + * measurements are *ALWAYS*, and exclusively, SI. + * + * Example: Convert a double @c kx, containing a permeability value + * in units of milli-darcy (mD) to the equivalent value in SI units + * (i.e., \f$m^2\f$). + * \code + * using namespace Opm::unit; + * using namespace Opm::prefix; + * convert::from(kx, milli*darcy); + * \endcode + * + * @param[in] q Physical quantity. + * @param[in] unit Physical unit of measurement. + * @return Value of @c q in equivalent SI units of measurements. + */ + constexpr double from(const double q, const double unit) + { + return q * unit; + } + + /** + * Convert from internal units of measurements to equivalent + * external units of measurements. Note: The internal units of + * measurements are *ALWAYS*, and exclusively, SI. + * + * Example: Convert a std::vector p, containing + * pressure values in the SI unit Pascal (i.e., unit::Pascal) to the + * equivalent values in Psi (unit::psia). + * \code + * using namespace Opm::unit; + * std::transform(p.begin(), p.end(), p.begin(), + * boost::bind(convert::to, _1, psia)); + * \endcode + * + * @param[in] q Physical quantity, measured in SI units. + * @param[in] unit Physical unit of measurement. + * @return Value of @c q in unit unit. + */ + constexpr double to(const double q, const double unit) + { + return q / unit; + } + } // namespace convert + } + + namespace Metric { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = barsa; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = meter; + constexpr const double Time = day; + constexpr const double Mass = kilogram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*barsa); + constexpr const double LiquidSurfaceVolume = cubic(meter); + constexpr const double GasSurfaceVolume = cubic(meter); + constexpr const double ReservoirVolume = cubic(meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = kilogram/cubic(meter); + constexpr const double PolymerDensity = kilogram/cubic(meter); + constexpr const double Salinity = kilogram/cubic(meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = kilo*joule; + } + + + namespace Field { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = psia; + constexpr const double Temperature = degFahrenheit; + constexpr const double TemperatureOffset = degFahrenheitOffset; + constexpr const double AbsoluteTemperature = degFahrenheit; // actually [°R], but the these two are identical + constexpr const double Length = feet; + constexpr const double Time = day; + constexpr const double Mass = pound; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*stb/(day*psia); + constexpr const double LiquidSurfaceVolume = stb; + constexpr const double GasSurfaceVolume = 1000*cubic(feet); + constexpr const double ReservoirVolume = stb; + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = pound/cubic(feet); + constexpr const double PolymerDensity = pound/stb; + constexpr const double Salinity = pound/stb; + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = btu; + } + + + namespace Lab { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = atm; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = centi*meter; + constexpr const double Time = hour; + constexpr const double Mass = gram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(centi*meter)/(hour*atm); + constexpr const double LiquidSurfaceVolume = cubic(centi*meter); + constexpr const double GasSurfaceVolume = cubic(centi*meter); + constexpr const double ReservoirVolume = cubic(centi*meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = gram/cubic(centi*meter); + constexpr const double PolymerDensity = gram/cubic(centi*meter); + constexpr const double Salinity = gram/cubic(centi*meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = hour; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = joule; + } + + + namespace PVT_M { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = atm; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = meter; + constexpr const double Time = day; + constexpr const double Mass = kilogram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*atm); + constexpr const double LiquidSurfaceVolume = cubic(meter); + constexpr const double GasSurfaceVolume = cubic(meter); + constexpr const double ReservoirVolume = cubic(meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = kilogram/cubic(meter); + constexpr const double PolymerDensity = kilogram/cubic(meter); + constexpr const double Salinity = kilogram/cubic(meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = kilo*joule; + } +} + +#endif // IMPORTED_OPM_UNITS_HEADER diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp index cca335b6e2..6c00681263 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -58,11 +58,11 @@ namespace StringUtils { std::string trim(const std::string& s) { const auto anchor_ws = - boost::regex(R"~~(^\s+([^\s]+)\s+$)~~"); + std::regex(R"~~(^\s+([^\s]+)\s+$)~~"); - auto m = boost::smatch{}; + auto m = std::smatch{}; - if (boost::regex_match(s, m, anchor_ws)) { + if (std::regex_match(s, m, anchor_ws)) { return m[1]; } @@ -77,9 +77,9 @@ namespace StringUtils { return { "" }; } - const auto sep = boost::regex(R"~~([\s,;.|]+)~~"); + const auto sep = std::regex(R"~~([\s,;.|]+)~~"); - using TI = boost::sregex_token_iterator; + using TI = std::sregex_token_iterator; // vector(begin, end) // diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp index 7bef5298bc..b666f08109 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLENDPOINTSCALING @@ -36,6 +32,7 @@ #include #include +#include #include #include @@ -72,6 +69,116 @@ namespace { return sp; } + + std::vector sw_core1d_example() + { + return { + 1.700000000000000e-01, + 1.861700000000000e-01, + 2.023400000000000e-01, + 2.185110000000000e-01, + 2.346810000000000e-01, + 2.508510000000000e-01, + 2.670210000000000e-01, + 2.831910000000000e-01, + 2.993620000000000e-01, + 3.155320000000000e-01, + 3.317020000000000e-01, + 3.478720000000000e-01, + 3.640430000000000e-01, + 3.802130000000000e-01, + 3.963830000000000e-01, + 4.125530000000000e-01, + 4.287230000000000e-01, + 4.448940000000000e-01, + 4.610640000000000e-01, + 4.772340000000000e-01, + 4.934040000000000e-01, + 5.095740000000000e-01, + 5.257450000000000e-01, + 5.419150000000000e-01, + 5.580850000000001e-01, + 5.742550000000000e-01, + 5.904260000000000e-01, + 6.065960000000000e-01, + 6.227660000000000e-01, + 6.389359999999999e-01, + 6.551060000000000e-01, + 6.712770000000000e-01, + 6.874470000000000e-01, + 7.036170000000000e-01, + 7.197870000000000e-01, + 7.359570000000000e-01, + 7.521280000000000e-01, + 7.682980000000000e-01, + 7.844680000000001e-01, + 8.006380000000000e-01, + 8.168090000000000e-01, + 8.329790000000000e-01, + 8.491490000000000e-01, + 8.653189999999999e-01, + 8.814890000000000e-01, + 8.976600000000000e-01, + 9.138300000000000e-01, + 9.300000000000000e-01, + 1.000000000000000e+00, + }; + } + + std::vector krw_core1d_example() + { + return { + 0, + 4.526940000000000e-04, + 1.810770000000000e-03, + 4.074240000000000e-03, + 7.243100000000000e-03, + 1.131730000000000e-02, + 1.629700000000000e-02, + 2.218200000000000e-02, + 2.897240000000000e-02, + 3.666820000000000e-02, + 4.526940000000000e-02, + 5.477590000000000e-02, + 6.518789999999999e-02, + 7.650520000000000e-02, + 8.872790000000000e-02, + 1.018560000000000e-01, + 1.158900000000000e-01, + 1.308280000000000e-01, + 1.466730000000000e-01, + 1.634220000000000e-01, + 1.810770000000000e-01, + 1.996380000000000e-01, + 2.191040000000000e-01, + 2.394750000000000e-01, + 2.607510000000000e-01, + 2.829330000000000e-01, + 3.060210000000000e-01, + 3.300140000000000e-01, + 3.549120000000000e-01, + 3.807150000000000e-01, + 4.074240000000000e-01, + 4.350380000000000e-01, + 4.635580000000000e-01, + 4.929830000000000e-01, + 5.233139999999999e-01, + 5.545500000000000e-01, + 5.866910000000000e-01, + 6.197370000000000e-01, + 6.536890000000000e-01, + 6.885470000000000e-01, + 7.243100000000000e-01, + 7.609780000000000e-01, + 7.985510000000000e-01, + 8.370300000000001e-01, + 8.764150000000001e-01, + 9.167040000000000e-01, + 9.579000000000000e-01, + 1.000000000000000e+00, + 1.000000000000000e+00, + }; + } } // Namespace Anonymous // ===================================================================== @@ -631,3 +738,330 @@ BOOST_AUTO_TEST_CASE (ScaledConnate) } BOOST_AUTO_TEST_SUITE_END () + +// ===================================================================== +// Pure vertical scaling of SF values. +// --------------------------------------------------------------------- + +BOOST_AUTO_TEST_SUITE (PureVerticalScaling_SFValues) + +BOOST_AUTO_TEST_CASE (Parabola_ScaledCell) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 0.5. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 0.5 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 1.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = 0.5 * val + const auto expect = std::vector { + 0, + 5.00e-03, + 2.00e-02, + 4.50e-02, + 8.00e-02, + 1.25e-01, + 1.80e-01, + 2.45e-01, + 3.20e-01, + 4.05e-01, + 5.00e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Parabola_ScaledFunc) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 1. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 1.0 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 2.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = val / 2 + const auto expect = std::vector { + 0, + 5.00e-03, + 2.00e-02, + 4.50e-02, + 8.00e-02, + 1.25e-01, + 1.80e-01, + 2.45e-01, + 3.20e-01, + 4.05e-01, + 5.00e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Parabola_ScaledBoth) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 1.5. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 1.5 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 2.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = val * 0.75 + const auto expect = std::vector { + 0, + 7.500e-03, + 3.000e-02, + 6.750e-02, + 1.200e-01, + 1.875e-01, + 2.700e-01, + 3.675e-01, + 4.800e-01, + 6.075e-01, + 7.500e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_SUITE_END () + +// ===================================================================== +// Critical saturation vertical scaling of SF values. +// --------------------------------------------------------------------- + +BOOST_AUTO_TEST_SUITE (CritSatVScale_SFValues) + +/* + sw = 0.1 : 0.05 : 0.9; + kr = sw .^ 2; + + [sdisp, fdisp, fmax] = deal(0.7, 0.6, 0.7); + + i = ~ (sw > sdisp); + y = 0 * kr; + y( i) = kr(i) .* fdisp./sdisp^2; + y(~i) = fdisp + (kr(~i) - sdisp^2)./(kr(end) - sdisp^2) .* (fmax - fdisp); + + figure, plot(sw, [kr; y], '.-') + legend('Unscaled', 'Vert. Scaled', 'Location', 'Best') +*/ +BOOST_AUTO_TEST_CASE (Sw2_Regular) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto sw = associate({ + 1.0e-01, 1.5e-01, 2.0e-01, 2.5e-01, + 3.0e-01, 3.5e-01, 4.0e-01, 4.5e-01, + 5.0e-01, 5.5e-01, 6.0e-01, 6.5e-01, + 7.0e-01, 7.5e-01, 8.0e-01, 8.5e-01, + 9.0e-01, + }); + + const auto kr = std::vector { // sw^2 + 1.000e-02, 2.250e-02, 4.000e-02, 6.250e-02, // 0 .. 3 + 9.000e-02, 1.225e-01, 1.600e-01, 2.025e-01, // 4 .. 7 + 2.500e-01, 3.025e-01, 3.600e-01, 4.225e-01, // 8 .. 11 + 4.900e-01, 5.625e-01, 6.400e-01, 7.225e-01, // 12 .. 15 + 8.100e-01, // 16 + }; + + const auto f = SFVal{ + SFPt{ 0.7, 0.49 }, // Displacement + SFPt{ 0.9, 0.81 }, // Maximum + }; + + // Scaled residual displacement sat: 0.7 + // Scaled Kr at Scaled Sr (KRxR): 0.6 + // Scaled Kr at Smax: (KRx) 0.7 + const auto scaler = Opm::SatFunc:: + CritSatVerticalScaling({ 0.71 }, { 0.6 }, { 0.7 }); + + const auto y = scaler.vertScale(f, sw, kr); + + // expect = kr .* (KRxR/0.49), S \le Sr + // KRxR + (kr - 0.49)/(0.81 - 0.49)*(KRx - KRxR), Sr < S + const auto expect = std::vector { + 1.224489795918368e-02, // 0 + 2.755102040816328e-02, // 1 + 4.897959183673471e-02, // 2 + 7.653061224489796e-02, // 3 + 1.102040816326531e-01, // 4 + 1.500000000000000e-01, // 5 + 1.959183673469388e-01, // 6 + 2.479591836734695e-01, // 7 + 3.061224489795918e-01, // 8 + 3.704081632653062e-01, // 9 + 4.408163265306123e-01, // 10 + 5.173469387755103e-01, // 11 + + // ------- Sr ------- + + 6.000000000000000e-01, // 12 + 6.226562500000000e-01, // 13 + 6.468750000000000e-01, // 14 + 6.726562500000000e-01, // 15 + 7.000000000000000e-01, // 16 + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Core1D_Coincident_FVal) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto s = associate(sw_core1d_example()); + const auto kr = krw_core1d_example(); + + const auto f = SFVal{ + SFPt{ 0.93, 1.0 }, // Displacement + SFPt{ 1.0 , 1.0 }, // Maximum + }; + + const auto scaler = Opm::SatFunc:: + CritSatVerticalScaling({ 0.93 }, { 0.9 }, { 1.0 }); + + const auto y = scaler.vertScale(f, s, kr); + + const auto expect = std::vector { + 0, + 4.074246000000000e-04, + 1.629693000000000e-03, + 3.666816000000000e-03, + 6.518790000000000e-03, + 1.018557000000000e-02, + 1.466730000000000e-02, + 1.996380000000000e-02, + 2.607516000000000e-02, + 3.300138000000000e-02, + 4.074246000000000e-02, + 4.929831000000000e-02, + 5.866911000000000e-02, + 6.885468000000000e-02, + 7.985511000000001e-02, + 9.167040000000000e-02, + 1.043010000000000e-01, + 1.177452000000000e-01, + 1.320057000000000e-01, + 1.470798000000000e-01, + 1.629693000000000e-01, + 1.796742000000000e-01, + 1.971936000000000e-01, + 2.155275000000000e-01, + 2.346759000000000e-01, + 2.546397000000000e-01, + 2.754189000000000e-01, + 2.970126000000000e-01, + 3.194208000000000e-01, + 3.426435000000000e-01, + 3.666816000000000e-01, + 3.915342000000000e-01, + 4.172022000000000e-01, + 4.436847000000000e-01, + 4.709826000000000e-01, + 4.990950000000000e-01, + 5.280218999999999e-01, + 5.577633000000000e-01, + 5.883201000000000e-01, + 6.196923000000001e-01, + 6.518790000000000e-01, + 6.848802000000001e-01, + 7.186959000000001e-01, + 7.533270000000001e-01, + 7.887735000000000e-01, + 8.250336000000000e-01, + 8.621100000000000e-01, + 9.000000000000000e-01, + 1.000000000000000e+00, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_SUITE_END () diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp index b6c2ae5110..1782ecede2 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPROPERTYUNITCONVERSION diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp index e31a4e0d03..a6ddbedcd8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPROPTABLE diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp index 17588f26a1..2c9b5f60e1 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPVTCOMMON_UNITCONV diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp index fd3c8ca9bc..ae982d07d5 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_REGION_MAPPING diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp index b6ba1959b4..d43df46ab8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECL1DINTERPOLATION diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp index 02d45a51e8..0d3888a1b9 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_UNIT_HANDLING diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt index 8682cb6afe..5dff972ec4 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt @@ -15,7 +15,7 @@ ########################################################################### # Mandatory call to project -project(opm-flowdiagnostics CXX) +project(opm-flowdiagnostics C CXX) cmake_minimum_required (VERSION 2.8) diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module index 64b59849aa..18e86045a3 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module @@ -5,8 +5,8 @@ Module: opm-flowdiagnostics Description: Open Porous Media Initiative flow diagnostics -Version: 2016.10-pre -Label: 2016.10-pre +Version: 2018.10-pre +Label: 2018.10-pre Maintainer: opm@opm-project.org MaintainerName: OPM community Url: http://opm-project.org diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake new file mode 100644 index 0000000000..94fecbdc17 --- /dev/null +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake @@ -0,0 +1,19 @@ +# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*- +# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: + +# defines that must be present in config.h for our headers +set (opm-flowdiagnostics_CONFIG_VAR + ) + +# dependencies +set (opm-flowdiagnostics_DEPS + # compile with C99 support if available + "C99" + # compile with C++0x/11 support if available + "CXX11Features REQUIRED" + "Boost 1.44.0 + COMPONENTS unit_test_framework REQUIRED" + "opm-common REQUIRED" + ) + +find_package_deps(opm-flowdiagnostics) diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp index b0feae8d85..f563375121 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp index 53c2036fc4..15764916dc 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp @@ -20,10 +20,6 @@ #include -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_CELLSET diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp index 647984c96c..907c869633 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp index 8a9672cce9..fe15a2c0f5 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp index 4cd2036712..6a0e6b0ec6 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp @@ -17,13 +17,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif // HAVE_DYNAMIC_BOOST_TEST #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp index b5d34bb030..ee1f92b815 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif // HAVE_DYNAMIC_BOOST_TEST #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp index c07507c64b..784e170af3 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp @@ -20,10 +20,6 @@ #include -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TarjanImplementationTest From e4aa7d681d34425b8fb447494290c22310d5550d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 7 May 2018 14:43:24 +0200 Subject: [PATCH 0898/1027] #2852 OPM. Updated flow diag solver interface after OPM upgrade --- .../ReservoirDataModel/RigFlowDiagSolverInterface.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 5e12433eed..daf17bec06 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -132,7 +132,7 @@ class RigOpmFlowDiagStaticData : public cvf::Object try { - m_eclSaturationFunc.reset(new Opm::ECLSaturationFunc(*m_eclGraph, initData, true, Opm::ECLSaturationFunc::InvalidEPBehaviour::IgnorePoint)); + m_eclSaturationFunc.reset(new Opm::ECLSaturationFunc(*m_eclGraph, initData)); } catch (...) { @@ -676,7 +676,13 @@ std::vector RigFlowDiagSolverInterface for (RelPermCurve::EpsMode epsMode : epsModeArr) { const bool useEps = epsMode == RelPermCurve::EPS_ON ? true : false; - std::vector graphArr = m_opmFlowDiagStaticData->m_eclSaturationFunc->getSatFuncCurve(satFuncRequests, static_cast(activeCellIndex), useEps); + + Opm::ECLSaturationFunc::SatFuncScaling scaling; + if (!useEps) { + scaling.enable = static_cast(0); + } + scaling.invalid = Opm::SatFunc::EPSEvalInterface::InvalidEndpointBehaviour::IgnorePoint; + std::vector graphArr = m_opmFlowDiagStaticData->m_eclSaturationFunc->getSatFuncCurve(satFuncRequests, static_cast(activeCellIndex), scaling); for (size_t i = 0; i < graphArr.size(); i++) { const RelPermCurve::Ident curveIdent = curveIdentNameArr[i].first; From c7bf6172f38df427987a7170204b3a9bc2db4f84 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 7 May 2018 14:47:03 +0200 Subject: [PATCH 0899/1027] #2828 Allow setting curve domain range outside the range of the curve values. * Note that this implementation simply removes vertices that are outside the range. * It would look far better to insert vertices at the boundary when a segment is heading out of range. This is more complicated. --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 62 +++++++++++++------ .../ProjectDataModel/Rim3dWellLogCurve.cpp | 56 ++++++----------- .../ProjectDataModel/Rim3dWellLogCurve.h | 12 ++-- 3 files changed, 70 insertions(+), 60 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 584040615c..44668055e4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -32,8 +32,6 @@ #include "cvfBoundingBox.h" #include "cvfMath.h" -#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -53,9 +51,18 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display double planeWidth, const std::vector& drawSurfaceVertices) { + CVF_ASSERT(rim3dWellLogCurve); + // Make sure all drawables are cleared in case we return early to avoid a // previous drawable being "stuck" when changing result type. clearCurvePointsAndGeometry(); + + float curveUIRange = rim3dWellLogCurve->maxCurveUIValue() - rim3dWellLogCurve->minCurveUIValue(); + if (curveUIRange < 1.0e-6f) + { + return; + } + std::vector resultValues; std::vector resultMds; @@ -70,11 +77,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == resultMds.size()); - if (rim3dWellLogCurve->maxCurveValue() - rim3dWellLogCurve->minCurveValue() < 1.0e-6) - { - return; - } - RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); @@ -117,25 +119,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end()); - double maxClampedResult = -HUGE_VAL; - double minClampedResult = HUGE_VAL; + double maxVisibleResult = -std::numeric_limits::max(); + double minVisibleResult = std::numeric_limits::max(); + + double curveEpsilon = 1.0e-6; for (double& result : m_curveValues) { if (!RigCurveDataTools::isValidValue(result, false)) continue; - result = cvf::Math::clamp(result, rim3dWellLogCurve->minCurveValue(), rim3dWellLogCurve->maxCurveValue()); - - maxClampedResult = std::max(result, maxClampedResult); - minClampedResult = std::min(result, minClampedResult); + if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange) + { + result = -std::numeric_limits::max(); + } + else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange) + { + result = std::numeric_limits::max(); + } + else + { + maxVisibleResult = std::max(result, maxVisibleResult); + minVisibleResult = std::min(result, minVisibleResult); + } } - if (minClampedResult >= maxClampedResult) + if (minVisibleResult > maxVisibleResult) { return; } - double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); + double plotRangeToResultRangeFactor = planeWidth / curveUIRange; m_curveVertices.reserve(interpolatedWellPathPoints.size()); for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++) @@ -144,7 +157,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) { - scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor; + scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - rim3dWellLogCurve->minCurveUIValue()) * plotRangeToResultRangeFactor; } cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint)); @@ -169,8 +182,12 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display indices.reserve(m_curveVertices.size() * 2); for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) { - indices.push_back(cvf::uint(i)); - indices.push_back(cvf::uint(i + 1)); + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) + { + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); + } } cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); @@ -348,6 +365,15 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con } expandedBottomVertices.insert(expandedBottomVertices.end(), extraBottomVertices.begin(), extraBottomVertices.end()); } + else + { + // Add the invalid points and values. + expandedCurveVertices.push_back(m_curveVertices[i]); + expandedBottomVertices.push_back(m_bottomVertices[i]); + expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); + expandedValues.push_back(m_curveValues[i]); + + } } CVF_ASSERT(expandedCurveVertices.size() == expandedBottomVertices.size()); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 03981c60af..4108d72774 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -29,7 +29,6 @@ #include "cvfVector3.h" #include -#include // Needed for HUGE_VAL on Linux //================================================================================================== /// @@ -65,17 +64,15 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::Rim3dWellLogCurve() - : m_minCurveDataValue(-HUGE_VAL) - , m_maxCurveDataValue(HUGE_VAL) + : m_minCurveDataValue(-std::numeric_limits::max()) + , m_maxCurveDataValue(std::numeric_limits::max()) { CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_minCurveValue, "MinCurveValue", -HUGE_VAL, "Minimum Curve Value", "", "Clip curve values below this.", ""); - CAF_PDM_InitField(&m_maxCurveValue, "MaxCurveValue", HUGE_VAL, "Maximum Curve Value", "", "Clip curve values above this.", ""); - m_minCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - m_maxCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits::max(), "Minimum Curve Value", "", "Clip curve values below this.", ""); + CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::max(), "Maximum Curve Value", "", "Clip curve values above this.", ""); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); @@ -164,17 +161,17 @@ void Rim3dWellLogCurve::setColor(const cvf::Color3f& color) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Rim3dWellLogCurve::minCurveValue() const +float Rim3dWellLogCurve::minCurveUIValue() const { - return m_minCurveValue(); + return m_minCurveUIValue(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Rim3dWellLogCurve::maxCurveValue() const +float Rim3dWellLogCurve::maxCurveUIValue() const { - return m_maxCurveValue(); + return m_maxCurveUIValue(); } //-------------------------------------------------------------------------------------------------- @@ -212,8 +209,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) // Disable filled draw style in the GUI because of triangle stitching issue #2860. // configurationGroup->add(&m_drawStyle); configurationGroup->add(&m_color); - configurationGroup->add(&m_minCurveValue); - configurationGroup->add(&m_maxCurveValue); + configurationGroup->add(&m_minCurveUIValue); + configurationGroup->add(&m_maxCurveUIValue); } //-------------------------------------------------------------------------------------------------- @@ -221,24 +218,10 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - caf::PdmUiDoubleSliderEditorAttribute* sliderAttribute = dynamic_cast(attribute); - if (sliderAttribute) + if (m_minCurveDataValue == -std::numeric_limits::max() && + m_maxCurveDataValue == std::numeric_limits::max()) { - if (m_minCurveDataValue == -HUGE_VAL && - m_maxCurveDataValue == HUGE_VAL) - { - this->resetMinMaxValues(); - } - if (field == &m_minCurveValue) - { - sliderAttribute->m_minimum = m_minCurveDataValue; - sliderAttribute->m_maximum = m_maxCurveDataValue; - } - else if (field == &m_maxCurveValue) - { - sliderAttribute->m_minimum = m_minCurveDataValue; - sliderAttribute->m_maximum = m_maxCurveDataValue; - } + this->resetMinMaxValues(); } } @@ -298,8 +281,8 @@ void Rim3dWellLogCurve::resetMinMaxValues() std::vector values; std::vector measuredDepths; this->curveValuesAndMds(&values, &measuredDepths); - double foundMinValue = HUGE_VAL; - double foundMaxValue = -HUGE_VAL; + double foundMinValue = std::numeric_limits::max(); + double foundMaxValue = -std::numeric_limits::max(); for (double value : values) { if (RigCurveDataTools::isValidValue(value, false)) @@ -309,11 +292,12 @@ void Rim3dWellLogCurve::resetMinMaxValues() } } - // Update data boundaries m_minCurveDataValue = foundMinValue; m_maxCurveDataValue = foundMaxValue; - // Update selected GUI boundaries - m_minCurveValue = m_minCurveDataValue; - m_maxCurveValue = m_maxCurveDataValue; + m_minCurveUIValue = m_minCurveDataValue; + m_maxCurveUIValue = m_maxCurveDataValue; + + m_minCurveUIValue.uiCapability()->setUiName(QString("Minimum Curve Value (%1)").arg(m_minCurveDataValue)); + m_maxCurveUIValue.uiCapability()->setUiName(QString("Maximum Curve Value (%1)").arg(m_maxCurveDataValue)); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index e0c4ef85bf..244b58584e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -78,8 +78,8 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder void setColor(const cvf::Color3f& color); - double minCurveValue() const; - double maxCurveValue() const; + float minCurveUIValue() const; + float maxCurveUIValue() const; void resetMinMaxValuesAndUpdateUI(); bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, @@ -101,10 +101,10 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder caf::PdmField m_drawPlane; caf::PdmField m_drawStyle; caf::PdmField m_color; - caf::PdmField m_minCurveValue; - caf::PdmField m_maxCurveValue; - double m_minCurveDataValue; - double m_maxCurveDataValue; + caf::PdmField m_minCurveUIValue; + caf::PdmField m_maxCurveUIValue; + float m_minCurveDataValue; + float m_maxCurveDataValue; cvf::ref m_geometryGenerator; private: caf::PdmField m_showCurve; From b6979f32c6c2b6857a34f958c7d619d0619144e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 7 May 2018 15:56:23 +0200 Subject: [PATCH 0900/1027] #2808 Add Icon for well CF's --- .../RimVirtualPerforationResults.cpp | 2 +- ApplicationCode/Resources/ResInsight.qrc | 1 + ApplicationCode/Resources/WellCF16x16.png | Bin 0 -> 680 bytes 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 ApplicationCode/Resources/WellCF16x16.png diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp index 64a36202df..1f5255a0c9 100644 --- a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -33,7 +33,7 @@ RimVirtualPerforationResults::RimVirtualPerforationResults() QString connectionFactorUiName = "Well Connection Factors"; - CAF_PDM_InitObject(connectionFactorUiName, ":/CellResult.png", "", ""); + CAF_PDM_InitObject(connectionFactorUiName, ":/WellCF16x16.png", "", ""); CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", false, "", "", "", ""); CAF_PDM_InitField(&m_showClosedConnections, "ShowClosedConnections", true, "Show On Closed Connections", "", "", ""); diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 76d3deb53e..0dda72f570 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -57,6 +57,7 @@ WellLogPlot16x16.png WellLogPlots16x16.png WellLogCurve16x16.png + WellCF16x16.png CrossSection16x16.png CrossSections16x16.png Refresh-32.png diff --git a/ApplicationCode/Resources/WellCF16x16.png b/ApplicationCode/Resources/WellCF16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..f9bffaf7c18a1e4a1f028bdb87c9639e99b787c9 GIT binary patch literal 680 zcmV;Z0$2TsP)WFU8GbZ8()Nlj2>E@cM*00In2L_t(I%axPQOH^?b z#Xsl!X5Q#%8leNGm8}X3-3cK^L8~NM1ufeJ{Q)h4+7&^&mbJ=_LVPIiA3&#bDmGnJE$@ zTl!?_s-<{GJ(kWIy)bg-0Zvt9R)cwrHwJ9RrKbLsFX}|gLmcWfD5o4xVxucYW6r2^ zi&dUeR4j2vFc_!lsWs?H0--hwAw@`T@1r&}OXVBq*H&n(E%BLQ%AS+dX9pnUx)^V1 zp-P}Pni$m>iYuYoNd zsOS!05a*hx`6#nbD+`e zA)ZBMorD$4L`PNg9&Y+f+YJh^L literal 0 HcmV?d00001 From 9125619c410754958a70d6934d9b5dc245fdcd1c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 7 May 2018 16:06:54 +0200 Subject: [PATCH 0901/1027] 3D Well Log Curves: Fix crash bug due to wrong value used to force invalid values. --- .../ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 44668055e4..9f86eb23d2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -130,11 +130,11 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange) { - result = -std::numeric_limits::max(); + result = -HUGE_VAL; } else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange) { - result = std::numeric_limits::max(); + result = HUGE_VAL; } else { From 20a1e52323c01505752e72e5d48db90288c844d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 7 May 2018 18:06:09 +0200 Subject: [PATCH 0902/1027] #2850 Fix missing fault-label toggle and color setting awareness in 2D intersection view --- .../Intersections/RivIntersectionPartMgr.cpp | 8 ++- .../RimFaultInViewCollection.cpp | 3 + .../UserInterface/RiuMainWindow.cpp | 57 ++++++++++++++----- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index b4501571c6..449ea7f50b 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -31,6 +31,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" @@ -599,6 +600,12 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vectorfirstAncestorOrThisOfType(eclipseView); + + if (!(eclipseView && eclipseView->faultCollection()->showFaultLabel())) return; + + cvf::Color3f defWellLabelColor = eclipseView->faultCollection()->faultLabelColor(); cvf::Font* font = RiaApplication::instance()->customFont(); std::vector lineVertices; @@ -610,7 +617,6 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vectorsetDrawBorder(false); drawableText->setDrawBackground(false); drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE); - cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor(); drawableText->setTextColor(defWellLabelColor); } diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 8c144b3b1b..1c906bc74c 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -29,6 +29,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimFaultInView.h" +#include "RimIntersectionCollection.h" #include "RimNoCommonAreaNNC.h" #include "RimNoCommonAreaNncCollection.h" @@ -108,6 +109,7 @@ void RimFaultInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if (&faultLabelColor == changedField) { m_reservoirView->scheduleReservoirGridGeometryRegen(); + m_reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } if (&showFaultFaces == changedField || @@ -124,6 +126,7 @@ void RimFaultInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if (m_reservoirView) { m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + m_reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index b233d92bf8..fac4d9bf46 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -26,6 +26,7 @@ #include "RiaRegressionTest.h" #include "RiaRegressionTestRunner.h" +#include "Rim2dIntersectionView.h" #include "Rim3dView.h" #include "RimCellEdgeColors.h" #include "RimCommandObject.h" @@ -37,6 +38,7 @@ #include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" +#include "RimIntersection.h" #include "RimProject.h" #include "RimSimWellInViewCollection.h" @@ -1478,7 +1480,18 @@ void RiuMainWindow::slotToggleHideGridCellsAction(bool hideGridCells) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) { - RimEclipseView* activeRiv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + + RimEclipseView* activeRiv = dynamic_cast(activeView); + if (!activeRiv) + { + Rim2dIntersectionView* isectView = dynamic_cast(activeView); + if (isectView) + { + isectView->intersection()->firstAncestorOrThisOfType(activeRiv); + } + } + if (!activeRiv) return; activeRiv->faultCollection()->showFaultLabel.setValueWithFieldChanged(showLabels); @@ -1492,14 +1505,14 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) void RiuMainWindow::refreshDrawStyleActions() { Rim3dView* view = RiaApplication::instance()->activeReservoirView(); - bool enable = view != nullptr; + bool is3DView = view != nullptr; bool isGridView = RiaApplication::instance()->activeGridView() != nullptr; - m_drawStyleLinesAction->setEnabled(enable); - m_drawStyleLinesSolidAction->setEnabled(enable); - m_drawStyleSurfOnlyAction->setEnabled(enable); - m_drawStyleFaultLinesSolidAction->setEnabled(enable); - m_disableLightingAction->setEnabled(enable); + m_drawStyleLinesAction->setEnabled(is3DView); + m_drawStyleLinesSolidAction->setEnabled(is3DView); + m_drawStyleSurfOnlyAction->setEnabled(is3DView); + m_drawStyleFaultLinesSolidAction->setEnabled(is3DView); + m_disableLightingAction->setEnabled(is3DView); bool lightingDisabledInView = view ? view->isLightingDisabled() : false; @@ -1516,22 +1529,36 @@ void RiuMainWindow::refreshDrawStyleActions() } RimEclipseView* eclView = dynamic_cast(view); - enable = enable && eclView; - m_toggleFaultsLabelAction->setEnabled(enable); - m_showWellCellsAction->setEnabled(enable); + bool hasEclipseView = eclView != nullptr; + m_showWellCellsAction->setEnabled(hasEclipseView); - if (enable) + if (hasEclipseView) { - m_toggleFaultsLabelAction->blockSignals(true); - m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); - m_toggleFaultsLabelAction->blockSignals(false); - m_showWellCellsAction->blockSignals(true); eclView->wellCollection()->updateStateForVisibilityCheckboxes(); m_showWellCellsAction->setChecked(eclView->wellCollection()->showWellCells()); m_showWellCellsAction->blockSignals(false); } + + if (!eclView) + { + Rim2dIntersectionView * intView = dynamic_cast(view); + if (intView) + { + intView->intersection()->firstAncestorOrThisOfType(eclView); + } + } + + m_toggleFaultsLabelAction->setEnabled(eclView != nullptr); + + if (eclView ) + { + m_toggleFaultsLabelAction->blockSignals(true); + m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); + m_toggleFaultsLabelAction->blockSignals(false); + } + } From 0d8a034886dc14e389df3b83089d6415542367cb Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 7 May 2018 19:34:22 +0200 Subject: [PATCH 0903/1027] Fix Linux build by replacing a HUGE_VAL with std::numeric_limits::infinity * This build problem was introduced when fixing a crash issue that came from replacing HUGE_VAL with std::numeric_limits::max --- .../ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 9f86eb23d2..bd8caa0cc4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -130,11 +130,11 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange) { - result = -HUGE_VAL; + result = -std::numeric_limits::infinity(); } else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange) { - result = HUGE_VAL; + result = std::numeric_limits::infinity(); } else { From 043eaf7db624ef502fc8c7dae511dbdd1075a007 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 7 May 2018 20:07:12 +0200 Subject: [PATCH 0904/1027] Make new vertex creation more robust * Require that the length of the new segment is shorter than the *current* distance to the end of the original segment, rather than the length of the complete original segment. --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 2 +- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index bd8caa0cc4..2a8bd2e35e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -422,7 +422,7 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf cvf::Vec3f newVertex = connectingLine.end(); cvf::Vec3f newSegmentVector = newVertex - extraVertices->back(); - if (withinSegments && newSegmentVector.lengthSquared() < fullSegmentVector.lengthSquared()) + if (withinSegments && newSegmentVector.lengthSquared() < currentSubSegment.lengthSquared()) { extraVertices->push_back(newVertex); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 4108d72774..7fcf8767d3 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -64,15 +64,15 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::Rim3dWellLogCurve() - : m_minCurveDataValue(-std::numeric_limits::max()) - , m_maxCurveDataValue(std::numeric_limits::max()) + : m_minCurveDataValue(-std::numeric_limits::infinity()) + , m_maxCurveDataValue(std::numeric_limits::infinity()) { CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits::max(), "Minimum Curve Value", "", "Clip curve values below this.", ""); - CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::max(), "Maximum Curve Value", "", "Clip curve values above this.", ""); + CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits::infinity(), "Minimum Curve Value", "", "Clip curve values below this.", ""); + CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::infinity(), "Maximum Curve Value", "", "Clip curve values above this.", ""); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); @@ -218,8 +218,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - if (m_minCurveDataValue == -std::numeric_limits::max() && - m_maxCurveDataValue == std::numeric_limits::max()) + if (m_minCurveDataValue == -std::numeric_limits::infinity() && + m_maxCurveDataValue == std::numeric_limits::infinity()) { this->resetMinMaxValues(); } @@ -281,8 +281,8 @@ void Rim3dWellLogCurve::resetMinMaxValues() std::vector values; std::vector measuredDepths; this->curveValuesAndMds(&values, &measuredDepths); - double foundMinValue = std::numeric_limits::max(); - double foundMaxValue = -std::numeric_limits::max(); + double foundMinValue = std::numeric_limits::infinity(); + double foundMaxValue = -std::numeric_limits::infinity(); for (double value : values) { if (RigCurveDataTools::isValidValue(value, false)) From 763d25040e6636a44f74078b98cd9eb362abd1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 8 May 2018 10:17:05 +0200 Subject: [PATCH 0905/1027] #2840 Ensemble curve. Copy/paste og curve sets --- .../RicCopyReferencesToClipboardFeature.cpp | 5 + .../CMakeLists_files.cmake | 2 + .../RicPasteEnsembleCurveSetFeature.cpp | 128 ++++++++++++++++++ .../RicPasteEnsembleCurveSetFeature.h | 45 ++++++ .../RimContextCommandBuilder.cpp | 2 + .../Summary/RimEnsembleCurveSet.cpp | 33 +---- 6 files changed, 185 insertions(+), 30 deletions(-) create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index c5c5d7eb6d..a09af8470a 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -21,6 +21,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSet.h" #include "RimFractureTemplate.h" #include "RimGeoMechView.h" #include "RimIntersection.h" @@ -167,6 +168,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { return true; } + else if (dynamic_cast(pdmObject)) + { + return true; + } return false; } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 2976bac7f4..ff9d3e59fc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -33,6 +33,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -69,6 +70,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp new file mode 100644 index 0000000000..e843b81d7d --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteEnsembleCurveSetFeature.h" + +#include "RiaSummaryTools.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +//#include "RimSummaryCurve.h" +//#include "RimSummaryCurveFilter.h" +#include "RimSummaryPlot.h" +//#include "RimSummaryCrossPlot.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteEnsembleCurveSetFeature, "RicPasteEnsembleCurveSetFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet) +{ + RimSummaryPlot* plot = caf::firstAncestorOfTypeFromSelectedObject(); + RimEnsembleCurveSetCollection* coll = caf::firstAncestorOfTypeFromSelectedObject(); + + RimEnsembleCurveSet* newCurveSet = dynamic_cast(sourceCurveSet->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newCurveSet); + + if (!coll) coll = plot->ensembleCurveSets(); + + coll->addCurveSet(newCurveSet); + + // Resolve references after object has been inserted into the project data model + newCurveSet->resolveReferencesRecursively(); + newCurveSet->initAfterReadRecursively(); + newCurveSet->loadDataAndUpdate(true); + newCurveSet->updateConnectedEditors(); + + coll->updateConnectedEditors(); + + return newCurveSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteEnsembleCurveSetFeature::isCommandEnabled() +{ + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimSummaryPlot* plot; + RimEnsembleCurveSetCollection* coll = nullptr; + destinationObject->firstAncestorOrThisOfType(plot); + destinationObject->firstAncestorOrThisOfType(coll); + if(!coll && !plot) + { + return false; + } + + if (ensembleCurveSetsOnClipboard().size() == 0) + { + return false; + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEnsembleCurveSetFeature::onActionTriggered(bool isChecked) +{ + std::vector > sourceObjects = RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard(); + + for (size_t i = 0; i < sourceObjects.size(); i++) + { + copyCurveSetAndAddToCollection(sourceObjects[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Ensemble Curve Set"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector > RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector > typedObjects; + objectGroup.objectsByType(&typedObjects); + + return typedObjects; +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h new file mode 100644 index 0000000000..c4511b0cc4 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimEnsembleCurveSet; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteEnsembleCurveSetFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static RimEnsembleCurveSet* copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; + + static std::vector > ensembleCurveSetsOnClipboard(); +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index ed671389f1..052679e542 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -423,6 +423,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "RicPasteSummaryPlotFeature"; menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature"; + menuBuilder << "RicPasteEnsembleCurveSetFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryPlotFeature"; @@ -469,6 +470,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; + menuBuilder << "RicPasteEnsembleCurveSetFeature"; } else if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index f86a69226f..84466010ef 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -184,36 +184,10 @@ void RimEnsembleCurveSet::setColor(cvf::Color3f color) void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) { m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText()); - - m_yValuesSummaryFilter->updateFromAddress(m_yValuesCurveVariable->address()); - - for (RimSummaryCurve* curve : m_curves) - { - curve->loadDataAndUpdate(false); - - if (curve->qwtPlotCurve()) - { - curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); - } - - curve->updateQwtPlotAxis(); - } - - if (updateParentPlot) - { - RimSummaryPlot* parentPlot; - firstAncestorOrThisOfTypeAsserted(parentPlot); - if (parentPlot->qwtPlot()) - { - parentPlot->updatePlotTitle(); - parentPlot->qwtPlot()->updateLegend(); - parentPlot->updateAxes(); - parentPlot->updateZoomInQwt(); - } - } + m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address(); m_legendConfig->initForEnsembleCurveSet(this); - updateCurveColors(); + updateAllCurves(); } //-------------------------------------------------------------------------------------------------- @@ -809,8 +783,6 @@ void RimEnsembleCurveSet::updateAllCurves() deleteAllCurves(); - plot->loadDataAndUpdate(); - RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); RimSummaryAddress* addr = m_yValuesCurveVariable(); if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) @@ -831,6 +803,7 @@ void RimEnsembleCurveSet::updateAllCurves() curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); } } + m_yValuesSummaryFilter->updateFromAddress(addr->address()); RimSummaryPlot* plot; firstAncestorOrThisOfType(plot); From 9d51b9193186847260ddac2d78d22008ab36fcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 8 May 2018 12:52:33 +0200 Subject: [PATCH 0906/1027] #2724 Ensemble curves. Show case name in mouse tracking tooltip --- .../UserInterface/RiuQwtCurvePointTracker.cpp | 23 +++++++--- .../UserInterface/RiuQwtCurvePointTracker.h | 17 +++++++- .../UserInterface/RiuSummaryQwtPlot.cpp | 42 ++++++++++++++++++- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp index 3c83ce3ae8..bb9c108bd4 100644 --- a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp +++ b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp @@ -32,8 +32,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal) - : QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal) +RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider) + : QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal), m_curveInfoTextProvider(curveInfoTextProvider) { this->setTrackerMode(QwtPicker::AlwaysOn); m_plotMarker = new QwtPlotMarker; @@ -91,12 +91,15 @@ QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const QwtPlot::Axis relatedYAxis = QwtPlot::yLeft; QwtPlot::Axis relatedXAxis = QwtPlot::xBottom; + QString curveInfoText; QString mainAxisValueString; QString valueAxisValueString; - QPointF closestPoint = closestCurvePoint(pos, &valueAxisValueString, &mainAxisValueString, &relatedXAxis, &relatedYAxis); + QPointF closestPoint = closestCurvePoint(pos, &curveInfoText, &valueAxisValueString, &mainAxisValueString, &relatedXAxis, &relatedYAxis); if ( !closestPoint.isNull() ) { - QString str = valueAxisValueString; + QString str = !curveInfoText.isEmpty() ? + QString("%1: %2").arg(curveInfoText).arg(valueAxisValueString) : + valueAxisValueString; if ( !mainAxisValueString.isEmpty() ) { @@ -115,7 +118,12 @@ QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, QString* valueAxisValueString, QString* mainAxisValueString, QwtPlot::Axis* relatedXAxis, QwtPlot::Axis* relatedYAxis) const +QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, + QString* curveInfoText, + QString* valueAxisValueString, + QString* mainAxisValueString, + QwtPlot::Axis* relatedXAxis, + QwtPlot::Axis* relatedYAxis) const { QPointF samplePoint; @@ -160,6 +168,11 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, else mainAxisSampleVal = samplePoint.y(); + if (curveInfoText && closestCurve && m_curveInfoTextProvider) + { + *curveInfoText = m_curveInfoTextProvider->curveInfoText(closestCurve); + } + if ( dateScaleDraw ) { QDateTime date = dateScaleDraw->toDateTime(mainAxisSampleVal); diff --git a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h index 9142950532..80a4b467f8 100644 --- a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h +++ b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h @@ -23,6 +23,9 @@ #include class QwtPlotMarker; +class QwtPlotCurve; +class IPlotCurveInfoTextProvider; + //-------------------------------------------------------------------------------------------------- /// Class to add mouse over-tracking of curve points with text marker @@ -30,7 +33,7 @@ class QwtPlotMarker; class RiuQwtCurvePointTracker : public QwtPlotPicker { public: - explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal); + explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr); ~RiuQwtCurvePointTracker(); protected: @@ -39,7 +42,8 @@ class RiuQwtCurvePointTracker : public QwtPlotPicker void removeMarkerOnFocusLeave(); virtual QwtText trackerText(const QPoint& pos) const override; - QPointF closestCurvePoint(const QPoint& cursorPosition, + QPointF closestCurvePoint(const QPoint& cursorPosition, + QString* curveInfoText, QString* valueAxisValueString, QString* mainAxisValueString, QwtPlot::Axis* relatedXAxis, @@ -51,5 +55,14 @@ class RiuQwtCurvePointTracker : public QwtPlotPicker QPointer m_plot; QwtPlotMarker* m_plotMarker; bool m_isMainAxisHorizontal; + IPlotCurveInfoTextProvider* m_curveInfoTextProvider; }; +//-------------------------------------------------------------------------------------------------- +/// Interface for retrieving curve info text +//-------------------------------------------------------------------------------------------------- +class IPlotCurveInfoTextProvider +{ +public: + virtual QString curveInfoText(QwtPlotCurve* curve) = 0; +}; diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 6b566bd41a..4d5f5cf2e1 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -57,9 +57,49 @@ #include "RimRegularLegendConfig.h" #include "cafTitledOverlayFrame.h" #include "RimEnsembleCurveSetCollection.h" +#include "RimMainPlotCollection.h" +#include "RimSummaryPlotCollection.h" +#include "RimSummaryCase.h" #include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider +{ +public: + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual QString curveInfoText(QwtPlotCurve* curve) override + { + RimProject* project = RiaApplication::instance()->project(); + RimSummaryCurve* sumCurve = nullptr; + + // Lookup RimSummaryCurve from QwtPlotCurve + for (auto const plot : project->mainPlotCollection->summaryPlotCollection()->summaryPlots()) + { + RimSummaryPlot* sumPlot = plot->qwtPlot()->ownerPlotDefinition(); + for (auto const curveSet : sumPlot->ensembleCurveSets()->curveSets()) + { + for (auto const currSumCurve : curveSet->curves()) + { + if (currSumCurve->qwtPlotCurve() == curve) + { + sumCurve = currSumCurve; + break; + } + } + } + } + + return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->caseName() : ""; + } +}; +static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -376,7 +416,7 @@ void RiuSummaryQwtPlot::setCommonPlotBehaviour(QwtPlot* plot) plot->canvas()->installEventFilter(plot); plot->plotLayout()->setAlignCanvasToScales(true); - new RiuQwtCurvePointTracker(plot, true); + new RiuQwtCurvePointTracker(plot, true, &ensembleCurveInfoTextProvider); } //-------------------------------------------------------------------------------------------------- From 98daab46a3369116f5488d1a006d80260d8b8275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 8 May 2018 15:22:38 +0200 Subject: [PATCH 0907/1027] #2819 Ensemble curves. Distinguish between summary case group and ensemble --- .../Commands/CMakeLists_files.cmake | 2 + .../RicCreateSummaryCaseCollectionFeature.cpp | 6 +- .../RicCreateSummaryCaseCollectionFeature.h | 2 +- .../RicDeleteSummaryCaseCollectionFeature.cpp | 2 +- .../Commands/RicImportEnsembleFeature.cpp | 9 +- .../Commands/RicImportSummaryGroupFeature.cpp | 98 +++++++++++++++++++ .../Commands/RicImportSummaryGroupFeature.h | 45 +++++++++ .../RicNewSummaryEnsembleCurveSetFeature.cpp | 2 +- .../RimContextCommandBuilder.cpp | 3 + .../Summary/RimEnsembleCurveSet.cpp | 4 +- .../Summary/RimSummaryCaseCollection.cpp | 48 +++++++++ .../Summary/RimSummaryCaseCollection.h | 7 ++ .../Summary/RimSummaryCaseMainCollection.cpp | 3 +- .../Summary/RimSummaryCaseMainCollection.h | 2 +- .../UserInterface/RiuMainWindow.cpp | 1 + .../UserInterface/RiuPlotMainWindow.cpp | 1 + 16 files changed, 222 insertions(+), 13 deletions(-) create mode 100644 ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp create mode 100644 ApplicationCode/Commands/RicImportSummaryGroupFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index aff0f66133..9eb3be9209 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -67,6 +67,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.h ) @@ -132,6 +133,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.cpp ) diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 42f4cf9b53..7e0ac8a2e0 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -36,14 +36,14 @@ CAF_CMD_SOURCE_INIT(RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCase //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector cases, const QString& groupName) +void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector cases, const QString& groupName, bool isEnsemble) { RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; if (!cases.empty()) { cases[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); - summaryCaseMainCollection->addCaseCollection(cases, groupName); + summaryCaseMainCollection->addCaseCollection(cases, groupName, isEnsemble); summaryCaseMainCollection->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); @@ -92,5 +92,5 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) void RicCreateSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Group Summary Cases"); - actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png")); } diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h index 411ed16028..eb8a1fbb78 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h @@ -31,7 +31,7 @@ class RicCreateSummaryCaseCollectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; - static void groupSummaryCases(std::vector cases, const QString& groupName); + static void groupSummaryCases(std::vector cases, const QString& groupName, bool isEnsemble = false); private: virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp index 5f5a22107f..3181e20f48 100644 --- a/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp @@ -125,7 +125,7 @@ void RicDeleteSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicDeleteSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Delete Summary Case Group"); + actionToSetup->setText("Delete Summary Case Group/Ensemble"); actionToSetup->setIcon(QIcon(":/Erase.png")); } diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index 6001bda188..fac7fbe633 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -31,6 +31,7 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" @@ -74,7 +75,7 @@ void RicImportEnsembleFeature::onActionTriggered(bool isChecked) validateEnsembleCases(cases); RicImportSummaryCasesFeature::addSummaryCases(cases); - RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName, true); RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow && !cases.empty()) @@ -162,13 +163,15 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vectorproject(); - int groupCount = (int)project->summaryGroups().size() + 1; + std::vector groups = project->summaryGroups(); + int ensembleCount = std::count_if(groups.begin(), groups.end(), [](RimSummaryCaseCollection* group) { return group->isEnsemble(); }); + ensembleCount += 1; QInputDialog dialog; dialog.setInputMode(QInputDialog::TextInput); dialog.setWindowTitle("Ensemble Name"); dialog.setLabelText("Ensemble Name"); - dialog.setTextValue(QString("Ensemble %1").arg(groupCount)); + dialog.setTextValue(QString("Ensemble %1").arg(ensembleCount)); dialog.resize(300, 50); dialog.exec(); return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString(""); diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp new file mode 100644 index 0000000000..9b947f2449 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp @@ -0,0 +1,98 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportSummaryGroupFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportSummaryCasesFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicImportSummaryGroupFeature, "RicImportSummaryGroupFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryGroupFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryGroupFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble"); + + if (fileNames.isEmpty()) return; + + std::vector cases; + RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); + + RicImportSummaryCasesFeature::addSummaryCases(cases); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, "", false); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryGroupFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png")); + actionToSetup->setText("Import Summary Case Group"); +} diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.h b/ApplicationCode/Commands/RicImportSummaryGroupFeature.h new file mode 100644 index 0000000000..c75b1a89c2 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicImportSummaryGroupFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index c62996f20e..c3185b7b88 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -85,7 +85,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicNewSummaryEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("New Summary Ensemble Curve Set"); + actionToSetup->setText("New Ensemble Curve Set"); actionToSetup->setIcon(QIcon(":/EnsembleCurveSet16x16.png")); } diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 052679e542..8e7c11155e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -480,6 +480,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; menuBuilder << "RicImportEnsembleFeature"; } else if (dynamic_cast(uiItem)) @@ -487,6 +488,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; menuBuilder << "RicImportEnsembleFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); @@ -499,6 +501,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportSummaryCaseFeature"; menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; menuBuilder << "RicImportEnsembleFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 84466010ef..af184fce19 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -84,7 +84,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_showCurves.uiCapability()->setUiHidden(true); // Y Values - CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Group", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Ensemble", "", "", ""); m_yValuesSummaryGroup.uiCapability()->setUiTreeChildrenHidden(true); m_yValuesSummaryGroup.uiCapability()->setAutoAddingOptionFromValue(false); @@ -539,7 +539,7 @@ QList RimEnsembleCurveSet::calculateValueOptions(const c for (RimSummaryCaseCollection* group : groups) { - options.push_back(caf::PdmOptionItemInfo(group->name(), group)); + if(group->isEnsemble()) options.push_back(caf::PdmOptionItemInfo(group->name(), group)); } options.push_front(caf::PdmOptionItemInfo("None", nullptr)); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index f74b107526..078d90deec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -41,6 +41,9 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount); m_nameAndItemCount.uiCapability()->setUiReadOnly(true); m_nameAndItemCount.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitField(&m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", ""); + m_isEnsemble.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -94,6 +97,23 @@ QString RimSummaryCaseCollection::name() const return m_name; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCaseCollection::isEnsemble() const +{ + return m_isEnsemble(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::setAsEnsemble(bool isEnsemble) +{ + m_isEnsemble = isEnsemble; + updateIcon(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -131,3 +151,31 @@ QString RimSummaryCaseCollection::nameAndItemCount() const return m_name(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::updateIcon() +{ + if (m_isEnsemble) setUiIcon(QIcon(":/SummaryEnsemble16x16.png")); + else setUiIcon(QIcon(":/SummaryGroup16x16.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::initAfterRead() +{ + updateIcon(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_isEnsemble) + { + updateIcon(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index d8102e1e03..974bb3035b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -40,14 +40,21 @@ class RimSummaryCaseCollection : public caf::PdmObject std::vector allSummaryCases(); void setName(const QString& name); QString name() const; + bool isEnsemble() const; + void setAsEnsemble(bool isEnsemble); private: caf::PdmFieldHandle* userDescriptionField() override; void updateReferringCurveSets() const; QString nameAndItemCount() const; + void updateIcon(); + + virtual void initAfterRead() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: caf::PdmChildArrayField m_cases; caf::PdmField m_name; caf::PdmProxyValueField m_nameAndItemCount; + caf::PdmField m_isEnsemble; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 5bccd095ce..0f99777eaa 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -205,10 +205,11 @@ void RimSummaryCaseMainCollection::removeCase(RimSummaryCase* summaryCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases, const QString& collectionName) +void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases, const QString& collectionName, bool isEnsemble) { RimSummaryCaseCollection* summaryCaseCollection = new RimSummaryCaseCollection(); if(!collectionName.isEmpty()) summaryCaseCollection->setName(collectionName); + summaryCaseCollection->setAsEnsemble(isEnsemble); for (RimSummaryCase* summaryCase : summaryCases) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 423d33c8bf..ed85373a67 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -55,7 +55,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void addCase(RimSummaryCase* summaryCase); void removeCase(RimSummaryCase* summaryCase); - void addCaseCollection(std::vector summaryCases, const QString& coolectionName); + void addCaseCollection(std::vector summaryCases, const QString& coolectionName, bool isEnsemble); void removeCaseCollection(RimSummaryCaseCollection* caseCollection); void loadAllSummaryCaseData(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index fac4d9bf46..bce08755b9 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -392,6 +392,7 @@ void RiuMainWindow::createMenus() QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); importMenu->addSeparator(); diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index 02277e6de8..b47263d26e 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -196,6 +196,7 @@ void RiuPlotMainWindow::createMenus() QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); importMenu->addSeparator(); From 9a5f3fb47ee93349637a016482475b93a82258bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 8 May 2018 15:57:34 +0200 Subject: [PATCH 0908/1027] Fix Linux build warning --- ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index ff385d3a8c..22e680a2bb 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -686,7 +686,7 @@ QString RimRegularLegendConfig::categoryNameFromCategoryValue(double categoryRes //-------------------------------------------------------------------------------------------------- double RimRegularLegendConfig::categoryValueFromCategoryName(const QString& categoryName) const { - for (int i = 0; i < m_categoryNames.size(); i++) + for (int i = 0; i < (int)m_categoryNames.size(); i++) { if (cvfqt::Utils::toQString(m_categoryNames[i]).compare(categoryName, Qt::CaseInsensitive) == 0) { From 43082b49527b2ef9f1de85f73f997a73c9f3ad4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 8 May 2018 16:26:15 +0200 Subject: [PATCH 0909/1027] #2871 Fault visibility toggle now controls fault label visibility in 2D intersection views also. --- .../Intersections/RivIntersectionPartMgr.cpp | 16 +++++++++++++--- .../ProjectDataModel/RimFaultInView.cpp | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 449ea7f50b..4f11900fd8 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -75,6 +75,7 @@ #include #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RimFaultInView.h" //-------------------------------------------------------------------------------------------------- @@ -602,10 +603,11 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vectorfirstAncestorOrThisOfType(eclipseView); + RimFaultInViewCollection* faultInViewColl = eclipseView->faultCollection(); - if (!(eclipseView && eclipseView->faultCollection()->showFaultLabel())) return; + if (!(eclipseView && faultInViewColl->showFaultLabel())) return; - cvf::Color3f defWellLabelColor = eclipseView->faultCollection()->faultLabelColor(); + cvf::Color3f defWellLabelColor = faultInViewColl->faultLabelColor(); cvf::Font* font = RiaApplication::instance()->customFont(); std::vector lineVertices; @@ -622,9 +624,14 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vectorboundingBox(); double labelZOffset = bb.extent().z() / 10; - + int visibleFaultNameCount = 0; + for (const auto& labelAndAnchorPair : labelAndAnchors) { + RimFaultInView* fault = faultInViewColl->findFaultByName(labelAndAnchorPair.first); + + if (!(fault && fault->showFault())) continue; + cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first); cvf::Vec3f textCoord(labelAndAnchorPair.second); @@ -633,8 +640,11 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector part = new cvf::Part; diff --git a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp index 851c66b70a..04deaa447a 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp @@ -22,6 +22,7 @@ #include "RigFault.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimFaultInView, "Fault"); @@ -75,6 +76,7 @@ void RimFaultInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c if (reservoirView) { reservoirView->scheduleCreateDisplayModelAndRedraw(); + reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } From 0ebedc844fbfbf774018a6324edce4292e688463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 8 May 2018 16:59:29 +0200 Subject: [PATCH 0910/1027] #2849 Rename some Fishbone commands --- .../RicNewFishbonesSubsAtMeasuredDepthFeature.cpp | 2 +- .../CompletionCommands/RicNewFishbonesSubsFeature.cpp | 2 +- .../RicWellPathImportCompletionsFileFeature.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp index b651e70431..218993877b 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp @@ -84,7 +84,7 @@ RiuWellPathSelectionItem* RicNewFishbonesSubsAtMeasuredDepthFeature::wellPathSel void RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setIcon(QIcon(":/FishBoneGroup16x16.png")); - actionToSetup->setText("New Fishbones Subs Definition"); + actionToSetup->setText("New Fishbones"); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index 93ae30e992..ef7007617e 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -123,7 +123,7 @@ RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection( void RicNewFishbonesSubsFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setIcon(QIcon(":/FishBoneGroup16x16.png")); - actionToSetup->setText("New Fishbones Subs Definition"); + actionToSetup->setText("New Fishbones"); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp index 0a006a5982..2fbc001077 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -60,7 +60,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Fishbone Laterals", defaultDir, "Well Path Laterals (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -87,7 +87,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Import Completions from File"); + actionToSetup->setText("Import Fishbone Laterals"); actionToSetup->setIcon(QIcon(":/FishBoneGroupFromFile16x16.png")); } From f24fb4aaece51fe7d00fb69d1c00d51c1d3e32d0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 8 May 2018 14:37:23 +0200 Subject: [PATCH 0911/1027] Fix crash due to global/local grid index mixup when creating fractures on SimWellPaths. * Introduces a convenience method on the main grid * Also converts some callers to use the convenience method. --- .../Completions/RimSimWellFracture.cpp | 7 ++-- .../RimFaultInViewCollection.cpp | 12 +++---- .../Completions/RigCompletionDataGridCell.cpp | 7 ++-- .../ReservoirDataModel/RigMainGrid.cpp | 33 +++++++++++++++++-- .../ReservoirDataModel/RigMainGrid.h | 3 ++ .../UserInterface/RiuViewerCommands.cpp | 7 ++-- 6 files changed, 48 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index c30da5922c..d6f67a8d4b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -360,9 +360,12 @@ QString RimSimWellFracture::createOneBasedIJKText() const size_t i,j,k; size_t anchorCellIdx = findAnchorEclipseCell(mainGrid); if (anchorCellIdx == cvf::UNDEFINED_SIZE_T) return ""; + + size_t gridLocalCellIdx; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(anchorCellIdx, &gridLocalCellIdx); - bool ok = mainGrid->ijkFromCellIndex(anchorCellIdx, &i, &j, &k); + bool ok = hostGrid->ijkFromCellIndex(gridLocalCellIdx, &i, &j, &k); if (!ok) return ""; - return QString("[%1, %2, %3]").arg(i + 1).arg(j + 1).arg(k + 1); + return QString("Grid %1: [%2, %3, %4]").arg(QString::fromStdString(hostGrid->gridName())).arg(i + 1).arg(j + 1).arg(k + 1); } diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 1c906bc74c..5bfafccde1 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -285,10 +285,8 @@ void RimFaultInViewCollection::syncronizeFaults() QString secondConnectionText; { - const RigCell& cell = mainGrid->globalCellArray()[nncConnections[i].m_c1GlobIdx]; - - RigGridBase* hostGrid = cell.hostGrid(); - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConnections[i].m_c1GlobIdx, &gridLocalCellIndex); size_t i, j, k; if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) @@ -308,10 +306,8 @@ void RimFaultInViewCollection::syncronizeFaults() } { - const RigCell& cell = mainGrid->globalCellArray()[nncConnections[i].m_c2GlobIdx]; - - RigGridBase* hostGrid = cell.hostGrid(); - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConnections[i].m_c2GlobIdx, &gridLocalCellIndex); size_t i, j, k; if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp index ea48f8c42c..5e2c3a8c2a 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp @@ -33,12 +33,11 @@ RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, con { if (mainGrid) { - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; - RigGridBase* grid = cell.hostGrid(); + size_t gridLocalCellIndex; + const RigGridBase* grid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, &gridLocalCellIndex); + if (grid) { - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); - size_t i = 0; size_t j = 0; size_t k = 0; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 5853a121a4..adcd09cd42 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -47,6 +47,33 @@ RigMainGrid::~RigMainGrid(void) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) +{ + CVF_ASSERT(globalCellIdx < m_cells.size()); + RigCell& cell = m_cells[globalCellIdx]; + RigGridBase* hostGrid = cell.hostGrid(); + CVF_ASSERT(hostGrid); + *gridLocalCellIdx = cell.gridLocalCellIndex(); + return hostGrid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) const +{ + CVF_ASSERT(globalCellIdx < m_cells.size()); + const RigCell& cell = m_cells[globalCellIdx]; + const RigGridBase* hostGrid = cell.hostGrid(); + CVF_ASSERT(hostGrid); + *gridLocalCellIdx = cell.gridLocalCellIndex(); + return hostGrid; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -313,8 +340,10 @@ void RigMainGrid::calculateFaults(const RigActiveCellInfo* activeCellInfo) // Find neighbor cell if (firstNO_FAULTFaceForCell) // To avoid doing this for every face, and only when detecting a NO_FAULT { - hostGrid = m_cells[gcIdx].hostGrid(); - hostGrid->ijkFromCellIndex(m_cells[gcIdx].gridLocalCellIndex(), &i,&j, &k); + size_t gridLocalCellIndex; + hostGrid = this->gridAndGridLocalIdxFromGlobalCellIdx(gcIdx, &gridLocalCellIndex); + + hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i,&j, &k); isCellActive = activeCellInfo->isActive(gcIdx); firstNO_FAULTFaceForCell = false; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index 2b5b1e431f..7e1fdb6098 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -51,6 +51,9 @@ class RigMainGrid : public RigGridBase std::vector& globalCellArray() {return m_cells;} const std::vector& globalCellArray() const {return m_cells;} + RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx); + const RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) const; + const RigCell& cellByGridAndGridLocalCellIdx(size_t gridIdx, size_t gridLocalCellIdx) const; size_t reservoirCellIndexByGridAndGridLocalCellIndex(size_t gridIdx, size_t gridLocalCellIdx) const; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 930316aebb..3f114e3962 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -853,11 +853,8 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* cr crossSectionSourceInfo->crossSection()->firstAncestorOrThisOfType(eclipseView); size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; - - const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex]; - - *cellIndex = cell.gridLocalCellIndex(); - *gridIndex = cell.hostGrid()->gridIndex(); + const RigGridBase* hostGrid = eclipseView->mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, cellIndex); + *gridIndex = hostGrid->gridIndex(); } else if (geomCase) { From 47ed8dac74706e854ac63c41533ab888d4332066 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 8 May 2018 14:38:17 +0200 Subject: [PATCH 0912/1027] Fix crash due to wrong closest index comparison in RigSimulationWellCoordsAndMD --- .../ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp index 3a4f6fe839..9535232f91 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp @@ -92,7 +92,7 @@ double RigSimulationWellCoordsAndMD::locationAlongWellCoords(const cvf::Vec3d& p size_t closestIndex = findClosestIndex(position); - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if (closestIndex != cvf::UNDEFINED_SIZE_T) { cvf::Vec3d p1 = m_wellPathPoints[closestIndex - 1]; cvf::Vec3d p2 = m_wellPathPoints[closestIndex - 0]; From 9da54a115be992641c60b950c9aa27f8aa7b439c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 8 May 2018 15:53:17 +0200 Subject: [PATCH 0913/1027] Fix crash in cafHexGridIntersectionTools when exporting fracture completions. * Account for two new triangle plane intersection cases where one vertex is touching the plane. --- .../cafHexGridIntersectionTools.cpp | 76 +++++++++++++++---- .../cafHexGridIntersectionTools.h | 3 +- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp index abd5a460c7..6eaa0a4cb8 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp @@ -4,7 +4,7 @@ #include "cvfPlane.h" #include - +#include namespace caf { @@ -31,10 +31,16 @@ HexGridIntersectionTools::ClipVx::ClipVx() /// \param normalizedDistFromA Returns the normalized (0..1) position from a to b of the intersection point. /// Will return values along the infinite line defined by the a-b direcion, /// and HUGE_VAL if plane and line are parallel. +/// \param epsilon Tolerance margin for accepting the position being within (0..1) /// /// \return True if line segment intersects the plane //-------------------------------------------------------------------------------------------------- -bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const cvf::Vec3d& a, const cvf::Vec3d& b, cvf::Vec3d* intersection, double* normalizedDistFromA) +bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, + const cvf::Vec3d& a, + const cvf::Vec3d& b, + cvf::Vec3d* intersection, + double* normalizedDistFromA, + double epsilon) { // From Real-Time Collision Detection by Christer Eriscon, published by Morgen Kaufmann Publishers, (c) 2005 Elsevier Inc @@ -53,7 +59,7 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const (*intersection) = a + interpolationParameter * ab; (*normalizedDistFromA) = interpolationParameter; - return (interpolationParameter >= 0.0 && interpolationParameter <= 1.0); + return (interpolationParameter >= -epsilon && interpolationParameter <= 1.0 + epsilon); } @@ -66,7 +72,8 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // The permutations except for the trivial cases where all vertices are in front or behind plane: // -// Single vertex on positive side of plane => isMostVxesOnPositiveSide = false +// +// 1. Single vertex on positive side of plane => isMostVxesOnPositiveSide = false // // +\ /\3 /\3 /+ /\3 . // \ / \ / \ / + / \ + . @@ -75,7 +82,8 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // 1/___\1___\2 1/____2/__\2 1/________\2 . // +\ /+ // -// Two vertices vertex on positive side of plane => isMostVxesOnPositiveSide = true +// +// 2. Two vertices vertex on positive side of plane => isMostVxesOnPositiveSide = true // // \+ /\3 /\3 +/ /\3 . // \ / \ / \ / / \ . @@ -83,6 +91,20 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // / \ \ / /\ + / \ + . // 1/___\1___\2 1/____2/__\2 1/________\2 . // \+ +/ +// +// 3. The special cases of touching one vertex, either exactly or "close enough" +// in finite precision. These occur for both 2. and 3 and in any rotation. +// +// a) Should not be counted b) May need a tolerance margin to intersect +// as intersecting: both 1->3 and 2->3 as it is theoretically required to: +// 3 +// \ /\ /|\ +// \ / \ / | \ +// \ / \ / | \ +// \ / \ / | \ +// \/________\ /____|____\ +// \ 1 | 2 + //-------------------------------------------------------------------------------------------------- bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane, @@ -92,10 +114,21 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane ClipVx* newVx1, ClipVx* newVx2, bool * isMostVxesOnPositiveSide) { - int onPosSide[3]; - onPosSide[0] = plane.distanceSquared(p1) >= 0; - onPosSide[1] = plane.distanceSquared(p2) >= 0; - onPosSide[2] = plane.distanceSquared(p3) >= 0; + const double epsilon = 1.0e-8; + + double sqrSignedDistances[3]; + sqrSignedDistances[0] = plane.distanceSquared(p1); + sqrSignedDistances[1] = plane.distanceSquared(p2); + sqrSignedDistances[2] = plane.distanceSquared(p3); + + double maxSqrAbsDistance = std::max(std::abs(sqrSignedDistances[0]), + std::max(std::abs(sqrSignedDistances[1]), + std::abs(sqrSignedDistances[2]))); + + int onPosSide[3]; + onPosSide[0] = sqrSignedDistances[0] >= 0; + onPosSide[1] = sqrSignedDistances[1] >= 0; + onPosSide[2] = sqrSignedDistances[2] >= 0; const int numPositiveVertices = onPosSide[0] + onPosSide[1] + onPosSide[2]; @@ -122,12 +155,24 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (onPosSide[0]) topVx = 1; if (onPosSide[1]) topVx = 2; if (onPosSide[2]) topVx = 3; + + // Case 3a: Two negative distances and the last is within tolerance of zero. + if (sqrSignedDistances[topVx - 1] < epsilon * maxSqrAbsDistance) + { + return false; + } } else if (numPositiveVertices == 2) { if (!onPosSide[0]) topVx = 1; if (!onPosSide[1]) topVx = 2; if (!onPosSide[2]) topVx = 3; + + // Case 3a: Two positive distances and the last is within tolerance of zero. + if (sqrSignedDistances[topVx - 1] > -epsilon * maxSqrAbsDistance) + { + return false; + } } else { @@ -139,29 +184,28 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (topVx == 1) { - ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); (*newVx1).clippedEdgeVx1Id = p1Id; (*newVx1).clippedEdgeVx2Id = p2Id; - ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); (*newVx2).clippedEdgeVx1Id = p1Id; (*newVx2).clippedEdgeVx2Id = p3Id; - CVF_TIGHT_ASSERT(ok1 && ok2); } else if (topVx == 2) { - ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); (*newVx1).clippedEdgeVx1Id = p2Id; (*newVx1).clippedEdgeVx2Id = p3Id; - ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); (*newVx2).clippedEdgeVx1Id = p2Id; (*newVx2).clippedEdgeVx2Id = p1Id; } else if (topVx == 3) { - ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); (*newVx1).clippedEdgeVx1Id = p3Id; (*newVx1).clippedEdgeVx2Id = p1Id; - ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); (*newVx2).clippedEdgeVx1Id = p3Id; (*newVx2).clippedEdgeVx2Id = p2Id; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h index 36ea201dd0..8e9fc2d3ea 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h @@ -44,7 +44,8 @@ class HexGridIntersectionTools const cvf::Vec3d& a, const cvf::Vec3d& b, cvf::Vec3d* intersection, - double* normalizedDistFromA); + double* normalizedDistFromA, + double epsilon); static bool planeTriangleIntersection(const cvf::Plane& plane, const cvf::Vec3d& p1, From 923fc9815a9da4eb1362872f1b89771bf823f88c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 9 May 2018 08:42:11 +0200 Subject: [PATCH 0914/1027] #2713 Implement viewName parameter for RicfExportSimWellFractureCompletions. * View names are not unique! * This change will export fracture completions for *all* views that matches the view name. --- .../RicfExportSimWellFractureCompletions.cpp | 43 +++++++++++-------- .../RicfExportSimWellFractureCompletions.h | 2 +- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp index e841fb196f..1fa44efdda 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp @@ -44,7 +44,8 @@ CAF_PDM_SOURCE_INIT(RicfExportSimWellFractureCompletions, "exportSimWellFracture //-------------------------------------------------------------------------------------------------- RicfExportSimWellFractureCompletions::RicfExportSimWellFractureCompletions() { - RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", ""); + RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); + RICF_InitField(&m_viewName, "viewName", QString(""), "View Name", "", "", ""); RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); RICF_InitField(&m_simWellNames, "simulationWellNames", std::vector(), "Simulation Well Names", "", "", ""); RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); @@ -88,38 +89,46 @@ void RicfExportSimWellFractureCompletions::execute() } exportSettings->folder = exportFolder; - // FIXME : Select correct view? - RimEclipseView* view; + std::vector views; for (Rim3dView* v : exportSettings->caseToApply->views()) { - view = dynamic_cast(v); - if (view) break; + RimEclipseView* eclipseView = dynamic_cast(v); + if (eclipseView && eclipseView->name() == m_viewName()) + { + views.push_back(eclipseView); + } } - if (!view) + if (views.empty()) { - RiaLogging::error(QString("exportSimWellCompletions: Could not find a view for case with ID %1").arg(m_caseId())); + RiaLogging::error(QString("exportSimWellCompletions: Could not find any views named \"%1\" in the case with ID %2").arg(m_viewName).arg(m_caseId())); return; } std::vector simWells; if (m_simWellNames().empty()) { - std::copy(view->wellCollection()->wells.begin(), - view->wellCollection()->wells.end(), - std::back_inserter(simWells)); + for (RimEclipseView* view : views) + { + std::copy(view->wellCollection()->wells.begin(), + view->wellCollection()->wells.end(), + std::back_inserter(simWells)); + } } else { for (const QString& wellPathName : m_simWellNames()) { - RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName); - if (simWell) - { - simWells.push_back(simWell); - } - else + for (RimEclipseView* view : views) { - RiaLogging::warning(QString("exportSimWellCompletions: Could not find well with name %1 on case with ID %2").arg(wellPathName).arg(m_caseId())); + RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName); + if (simWell) + { + simWells.push_back(simWell); + } + else + { + RiaLogging::warning(QString("exportSimWellCompletions: Could not find well with name %1 in view \"%2\" on case with ID %2").arg(wellPathName).arg(m_viewName).arg(m_caseId())); + } } } } diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h index fff7f75bae..98bfb9fb0d 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h @@ -41,8 +41,8 @@ class RicfExportSimWellFractureCompletions : public RicfCommandObject private: caf::PdmField m_caseId; + caf::PdmField m_viewName; caf::PdmField m_timeStep; - caf::PdmField< std::vector > m_simWellNames; caf::PdmField m_fileSplit; From 15c2b19f59c15df9b966c27bfcccdd56127c5b70 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 9 May 2018 11:34:04 +0200 Subject: [PATCH 0915/1027] Slightly improve naming of epsilon/tolerance variable in plane triangle intersection. --- .../cafHexGridIntersectionTools.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp index 6eaa0a4cb8..a7934f5935 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp @@ -114,7 +114,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane ClipVx* newVx1, ClipVx* newVx2, bool * isMostVxesOnPositiveSide) { - const double epsilon = 1.0e-8; + const double nonDimensionalTolerance = 1.0e-8; double sqrSignedDistances[3]; sqrSignedDistances[0] = plane.distanceSquared(p1); @@ -125,6 +125,8 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane std::max(std::abs(sqrSignedDistances[1]), std::abs(sqrSignedDistances[2]))); + const double sqrDistanceTolerance = nonDimensionalTolerance * maxSqrAbsDistance; + int onPosSide[3]; onPosSide[0] = sqrSignedDistances[0] >= 0; onPosSide[1] = sqrSignedDistances[1] >= 0; @@ -157,7 +159,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (onPosSide[2]) topVx = 3; // Case 3a: Two negative distances and the last is within tolerance of zero. - if (sqrSignedDistances[topVx - 1] < epsilon * maxSqrAbsDistance) + if (sqrSignedDistances[topVx - 1] < sqrDistanceTolerance) { return false; } @@ -169,7 +171,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (!onPosSide[2]) topVx = 3; // Case 3a: Two positive distances and the last is within tolerance of zero. - if (sqrSignedDistances[topVx - 1] > -epsilon * maxSqrAbsDistance) + if (sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance) { return false; } @@ -184,28 +186,28 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (topVx == 1) { - ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); + ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p1Id; (*newVx1).clippedEdgeVx2Id = p2Id; - ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); + ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p1Id; (*newVx2).clippedEdgeVx2Id = p3Id; } else if (topVx == 2) { - ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); + ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p2Id; (*newVx1).clippedEdgeVx2Id = p3Id; - ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); + ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p2Id; (*newVx2).clippedEdgeVx2Id = p1Id; } else if (topVx == 3) { - ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), epsilon); + ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p3Id; (*newVx1).clippedEdgeVx2Id = p1Id; - ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), epsilon); + ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p3Id; (*newVx2).clippedEdgeVx2Id = p2Id; } From 9e6e2e8735db1c015b04749bf488637483226c9b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 8 May 2018 13:37:04 +0200 Subject: [PATCH 0916/1027] #2868 Completion Type : Use const pointer --- .../Completions/RigVirtualPerforationTransmissibilities.cpp | 6 +++--- .../Completions/RigVirtualPerforationTransmissibilities.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index b130555583..2f15706166 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -68,7 +68,7 @@ RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilitie /// //-------------------------------------------------------------------------------------------------- void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( - RimWellPath* wellPath, + const RimWellPath* wellPath, std::vector>& completionsPerTimeStep) { auto item = m_mapFromWellToCompletionData.find(wellPath); @@ -85,7 +85,7 @@ void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( values.push_back(oneTimeStep); } - auto pair = std::pair>(wellPath, values); + auto pair = std::pair>(wellPath, values); m_mapFromWellToCompletionData.insert(pair); } @@ -95,7 +95,7 @@ void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( /// //-------------------------------------------------------------------------------------------------- const std::map>& - RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const + RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, size_t timeStepIndex) const { static std::map> dummy; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h index 6e7134b06d..1ebac53592 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -56,10 +56,10 @@ class RigVirtualPerforationTransmissibilities : public cvf::Object RigVirtualPerforationTransmissibilities(); ~RigVirtualPerforationTransmissibilities(); - void setCompletionDataForWellPath(RimWellPath* wellPath, std::vector>& completionsPerTimeStep); + void setCompletionDataForWellPath(const RimWellPath* wellPath, std::vector>& completionsPerTimeStep); const std::map>& - multipleCompletionsPerEclipseCell(RimWellPath* wellPath, size_t timeStepIndex) const; + multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, size_t timeStepIndex) const; void setCompletionDataForSimWell(const RigSimWellData* simWellData, std::vector>& completionsPerTimeStep); @@ -68,6 +68,6 @@ class RigVirtualPerforationTransmissibilities : public cvf::Object void computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; private: - std::map> m_mapFromWellToCompletionData; + std::map> m_mapFromWellToCompletionData; std::map>> m_mapFromSimWellToCompletionData; }; From 9bb8f360520f4a9d15655d7091a40dd68a010857 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 8 May 2018 14:21:16 +0200 Subject: [PATCH 0917/1027] #2868 Completion Type : Compute completion type based on virtual connection factors --- .../RiaCompletionTypeCalculationScheduler.cpp | 36 +++++-- .../RiaCompletionTypeCalculationScheduler.h | 2 + .../RimCompletionCellIntersectionCalc.cpp | 96 ++++++++++++++++++- .../RimCompletionCellIntersectionCalc.h | 4 + .../RigCaseCellResultsData.cpp | 7 +- 5 files changed, 129 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 984afb860c..d125d4de23 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -20,6 +20,8 @@ #include "RiaApplication.h" +#include "RigEclipseCaseData.h" + #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" @@ -51,12 +53,10 @@ RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::in //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() { - for (RimEclipseCase* eclipseCase : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases()) - { - m_eclipseCasesToRecalculate.push_back(eclipseCase); - } + std::vector eclipseCases = + RiaApplication::instance()->project()->activeOilField()->analysisModels->cases().childObjects(); - startTimer(); + scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); } //-------------------------------------------------------------------------------------------------- @@ -64,7 +64,29 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) { - m_eclipseCasesToRecalculate.push_back(eclipseCase); + std::vector eclipseCases; + eclipseCases.push_back(eclipseCase); + + scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCases( + const std::vector& eclipseCases) +{ + for (RimEclipseCase* eclipseCase : eclipseCases) + { + CVF_ASSERT(eclipseCase); + + if (eclipseCase->eclipseCaseData()) + { + eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities(nullptr); + } + + m_eclipseCasesToRecalculate.push_back(eclipseCase); + } startTimer(); } @@ -111,7 +133,7 @@ RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::startTimer() { diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h index 7a72bde95d..ecc58a91ae 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -45,6 +45,8 @@ private slots: RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; + void scheduleRecalculateCompletionTypeAndRedrawEclipseCases(const std::vector& eclipseCases); + void startTimer(); private: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 8a3cc450b9..6f5df15e0b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -21,11 +21,13 @@ #include "RiaDefines.h" #include "RigCellGeometryTools.h" +#include "RigCompletionData.h" #include "RigEclipseCaseData.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RigWellPathIntersectionTools.h" @@ -49,6 +51,7 @@ #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" +#include "RiaApplication.h" #include //-------------------------------------------------------------------------------------------------- @@ -77,6 +80,93 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP // NOTE : Never compute completion type result for simulation well fractures, as these are defined per view } +std::vector fromCompletionData(const std::vector& data) +{ + std::vector appCompletionTypes; + + for (const auto& d : data) + { + switch (d.completionType()) + { + case RigCompletionData::FRACTURE: + appCompletionTypes.push_back(RiaDefines::FRACTURE); + break; + case RigCompletionData::PERFORATION: + appCompletionTypes.push_back(RiaDefines::PERFORATION_INTERVAL); + break; + case RigCompletionData::FISHBONES: + appCompletionTypes.push_back(RiaDefines::FISHBONES); + break; + default: + break; + } + } + + return appCompletionTypes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep) +{ + CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); + + RimProject* project = nullptr; + eclipseCase->firstAncestorOrThisOfTypeAsserted(project); + + if (project->activeOilField()->wellPathCollection->isActive) + { + const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) + { + if (wellPath->showWellPath() && wellPath->wellPathGeometry()) + { + auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); + + for (auto& intersection : intersectedCells) + { + completionTypeCellResult[intersection] = RiaDefines::WELL_PATH; + } + + auto conn = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (conn) + { + for (const auto& connForWell : conn->multipleCompletionsPerEclipseCell(wellPath, timeStep)) + { + RiaDefines::CompletionType appCompletionType = RiaDefines::WELL_PATH; + + auto appCompletionTypes = fromCompletionData(connForWell.second); + + if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FISHBONES; + } + else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FRACTURE; + } + else if (std::find(appCompletionTypes.begin(), + appCompletionTypes.end(), + RiaDefines::PERFORATION_INTERVAL) != appCompletionTypes.end()) + { + appCompletionType = RiaDefines::PERFORATION_INTERVAL; + } + + completionTypeCellResult[connForWell.first.globalCellIndex()] = appCompletionType; + } + } + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -175,9 +265,9 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimWellPathFracture* fracture, - std::vector& values) +void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, + const RimWellPathFracture* fracture, + std::vector& values) { if (!fracture->fractureTemplate()) return; if (!fracture->fractureTemplate()->fractureGrid()) return; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index 98da985a44..c6852ea4a9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -43,6 +43,10 @@ class RimCompletionCellIntersectionCalc std::vector& completionTypeCellResult, const QDateTime& fromDate); + static void calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep); + private: static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigEclipseCaseData* eclipseCaseData, diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 3561ca9f00..fe4e457b3e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2254,12 +2254,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) if (!eclipseCase) return; - RimProject* project; - eclipseCase->firstAncestorOrThisOfTypeAsserted(project); - - QDateTime timeStepDate = this->timeStepDates()[timeStep]; - - RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, completionTypeResult, timeStepDate); + RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(eclipseCase, completionTypeResult, timeStep); } From a986f3a4d22da98ba83c8794890fbe1a7cac1057 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 08:39:36 +0200 Subject: [PATCH 0918/1027] #2868 Completion Type : Simplify update code paths --- .../RiaCompletionTypeCalculationScheduler.cpp | 24 ++++++++---- .../RiaCompletionTypeCalculationScheduler.h | 4 +- .../Completions/RimFracture.cpp | 6 +-- .../ProjectDataModel/RimEclipseCase.cpp | 39 ------------------- .../ProjectDataModel/RimEclipseCase.h | 3 -- .../ProjectDataModel/RimProject.cpp | 2 +- 6 files changed, 23 insertions(+), 55 deletions(-) diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index d125d4de23..6a5dd39b71 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -21,10 +21,11 @@ #include "RiaApplication.h" #include "RigEclipseCaseData.h" +#include "RigCaseCellResultsData.h" -#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" +#include "RimEclipseView.h" #include "RimOilField.h" #include "RimProject.h" @@ -56,24 +57,24 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd std::vector eclipseCases = RiaApplication::instance()->project()->activeOilField()->analysisModels->cases().childObjects(); - scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); + scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCases); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews(RimEclipseCase* eclipseCase) { std::vector eclipseCases; eclipseCases.push_back(eclipseCase); - scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); + scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCases); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCases( +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews( const std::vector& eclipseCases) { for (RimEclipseCase* eclipseCase : eclipseCases) @@ -82,6 +83,9 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd if (eclipseCase->eclipseCaseData()) { + eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); + + // Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities(nullptr); } @@ -103,8 +107,14 @@ void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() for (RimEclipseCase* eclipseCase : uniqueCases) { - eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); - eclipseCase->deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); + for (const auto& w : eclipseCase->views()) + { + RimEclipseView* eclView = dynamic_cast(w); + if (eclView) + { + eclView->calculateCompletionTypeAndRedrawIfRequired(); + } + } } m_eclipseCasesToRecalculate.clear(); diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h index ecc58a91ae..205f415f9f 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -33,7 +33,7 @@ class RiaCompletionTypeCalculationScheduler : public QObject public: static RiaCompletionTypeCalculationScheduler* instance(); void scheduleRecalculateCompletionTypeAndRedrawAllViews(); - void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); + void scheduleRecalculateCompletionTypeAndRedrawAllViews(RimEclipseCase* eclipseCase); private slots: void slotRecalculateCompletionType(); @@ -45,7 +45,7 @@ private slots: RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; - void scheduleRecalculateCompletionTypeAndRedrawEclipseCases(const std::vector& eclipseCases); + void scheduleRecalculateCompletionTypeAndRedrawAllViews(const std::vector& eclipseCases); void startTimer(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index d805211568..8edc8a8dc1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -19,6 +19,7 @@ #include "RimFracture.h" #include "RiaApplication.h" +#include "RiaCompletionTypeCalculationScheduler.h" #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" @@ -226,7 +227,7 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons changedField == &m_tilt || changedField == &m_perforationLength) { - Rim3dView* rimView = nullptr; + RimEclipseView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -234,8 +235,7 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons rimView->firstAncestorOrThisOfType(eclipseCase); if (eclipseCase) { - eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); - eclipseCase->deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCase); } } else diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 5c745998ff..04e6ea9c39 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -297,45 +297,6 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView(const RimEclipseView* sourc return rimEclipseView; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseCase::recalculateCompletionTypeAndRedrawAllViews() -{ - results(RiaDefines::MATRIX_MODEL)->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); - - for (Rim3dView* view : views()) - { - RimEclipseView* eclipseView = dynamic_cast(view); - if (eclipseView) - { - eclipseView->calculateCompletionTypeAndRedrawIfRequired(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseCase::deleteVirtualConnectionFactorDataAndRedrawRequiredViews() -{ - RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); - - if (rigEclipseCase) - { - rigEclipseCase->setVirtualPerforationTransmissibilities(nullptr); - } - - for (Rim3dView* view : views()) - { - RimEclipseView* eclipseView = dynamic_cast(view); - if (eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible()) - { - eclipseView->scheduleCreateDisplayModelAndRedraw(); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index a658c2547b..16faea32cc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -87,9 +87,6 @@ class RimEclipseCase : public RimCase RimEclipseView* createAndAddReservoirView(); RimEclipseView* createCopyAndAddView(const RimEclipseView* sourceView); - void recalculateCompletionTypeAndRedrawAllViews(); - - void deleteVirtualConnectionFactorDataAndRedrawRequiredViews(); const RigVirtualPerforationTransmissibilities* computeAndGetVirtualPerforationTransmissibilities(); virtual QString locationOnDisc() const { return QString(); } diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 22ed1110f3..76b8eb90a4 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -1016,7 +1016,7 @@ void RimProject::reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclip views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); } - RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCase); } //-------------------------------------------------------------------------------------------------- From e820bd44c7e47d99c55302618bcb5aee57d75788 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 09:02:53 +0200 Subject: [PATCH 0919/1027] #2868 Completion Type : Remove obsolete code --- .../RimCompletionCellIntersectionCalc.cpp | 217 ------------------ .../RimCompletionCellIntersectionCalc.h | 40 +--- 2 files changed, 4 insertions(+), 253 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 6f5df15e0b..ad26c2e525 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -20,66 +20,20 @@ #include "RiaDefines.h" -#include "RigCellGeometryTools.h" #include "RigCompletionData.h" -#include "RigEclipseCaseData.h" -#include "RigFractureCell.h" -#include "RigFractureGrid.h" -#include "RigHexIntersectionTools.h" -#include "RigMainGrid.h" #include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RigWellPathIntersectionTools.h" #include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimFishbonesCollection.h" -#include "RimFishbonesMultipleSubs.h" -#include "RimFracture.h" -#include "RimFractureTemplate.h" #include "RimOilField.h" -#include "RimPerforationCollection.h" -#include "RimPerforationInterval.h" #include "RimProject.h" -#include "RimSimWellFracture.h" -#include "RimSimWellFractureCollection.h" -#include "RimSimWellInView.h" -#include "RimSimWellInViewCollection.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RimWellPathCompletions.h" -#include "RimWellPathFracture.h" -#include "RimWellPathFractureCollection.h" - -#include "RiaApplication.h" -#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - std::vector& completionTypeCellResults, - const QDateTime& fromDate) -{ - CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); - - const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - if (project->activeOilField()->wellPathCollection->isActive) - { - for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) - { - if (wellPath->showWellPath()) - { - calculateWellPathIntersections(wellPath, eclipseCaseData, completionTypeCellResults, fromDate); - } - } - } - - // NOTE : Never compute completion type result for simulation well fractures, as these are defined per view -} - std::vector fromCompletionData(const std::vector& data) { std::vector appCompletionTypes; @@ -166,174 +120,3 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipse } } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values, - const QDateTime& fromDate) -{ - if (wellPath->wellPathGeometry()) - { - auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( - eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); - for (auto& intersection : intersectedCells) - { - values[intersection] = RiaDefines::WELL_PATH; - } - } - - if (wellPath->fishbonesCollection()->isChecked()) - { - for (const RimFishbonesMultipleSubs* fishbones : wellPath->fishbonesCollection()->fishbonesSubs) - { - if (fishbones->isActive()) - { - calculateFishbonesIntersections(fishbones, eclipseCaseData, values); - } - } - } - - if (wellPath->fractureCollection()->isChecked()) - { - const RigMainGrid* grid = eclipseCaseData->mainGrid(); - - for (const RimWellPathFracture* fracture : wellPath->fractureCollection()->fractures()) - { - if (fracture->isChecked()) - { - calculateFractureIntersections(grid, fracture, values); - } - } - } - - if (wellPath->perforationIntervalCollection()->isChecked()) - { - for (const RimPerforationInterval* perforationInterval : wellPath->perforationIntervalCollection()->perforations()) - { - if (perforationInterval->isChecked() && perforationInterval->isActiveOnDate(fromDate)) - { - calculatePerforationIntersections(wellPath, perforationInterval, eclipseCaseData, values); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values) -{ - for (auto& sub : fishbonesSubs->installedLateralIndices()) - { - for (size_t lateralIndex : sub.lateralIndices) - { - auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( - eclipseCaseData, fishbonesSubs->coordsForLateral(sub.subIndex, lateralIndex)); - for (auto& intersection : intersectedCells) - { - values[intersection] = RiaDefines::FISHBONES; - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const RimWellPath* wellPath, - const RimPerforationInterval* perforationInterval, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values) -{ - using namespace std; - pair, vector> clippedWellPathData = - wellPath->wellPathGeometry()->clippedPointSubset(perforationInterval->startMD(), perforationInterval->endMD()); - - auto intersections = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( - eclipseCaseData, clippedWellPathData.first, clippedWellPathData.second); - for (auto& intersection : intersections) - { - values[intersection] = RiaDefines::PERFORATION_INTERVAL; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimWellPathFracture* fracture, - std::vector& values) -{ - if (!fracture->fractureTemplate()) return; - if (!fracture->fractureTemplate()->fractureGrid()) return; - - for (const RigFractureCell& fractureCell : fracture->fractureTemplate()->fractureGrid()->fractureCells()) - { - if (!fractureCell.hasNonZeroConductivity()) continue; - - std::vector fractureCellTransformed; - for (const auto& v : fractureCell.getPolygon()) - { - cvf::Vec3d polygonNode = v; - polygonNode.transformPoint(fracture->transformMatrix()); - fractureCellTransformed.push_back(polygonNode); - } - - std::vector potentialCells; - - { - cvf::BoundingBox boundingBox; - - for (const cvf::Vec3d& nodeCoord : fractureCellTransformed) - { - boundingBox.add(nodeCoord); - } - - mainGrid->findIntersectingCells(boundingBox, &potentialCells); - } - - for (size_t cellIndex : potentialCells) - { - if (!fracture->isEclipseCellWithinContainment(mainGrid, cellIndex)) continue; - - std::array hexCorners; - mainGrid->cellCornerVertices(cellIndex, hexCorners.data()); - - std::vector> planeCellPolygons; - - bool isPlaneIntersected = - RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, fracture->transformMatrix(), planeCellPolygons); - if (!isPlaneIntersected || planeCellPolygons.empty()) continue; - - { - cvf::Mat4d invertedTransformMatrix = cvf::Mat4d(fracture->transformMatrix().getInverted()); - for (std::vector& planeCellPolygon : planeCellPolygons) - { - for (cvf::Vec3d& v : planeCellPolygon) - { - v.transformPoint(invertedTransformMatrix); - } - } - } - - for (const std::vector& planeCellPolygon : planeCellPolygons) - { - std::vector> clippedPolygons = - RigCellGeometryTools::intersectPolygons(planeCellPolygon, fractureCell.getPolygon()); - for (const auto& clippedPolygon : clippedPolygons) - { - if (!clippedPolygon.empty()) - { - values[cellIndex] = RiaDefines::FRACTURE; - break; - } - } - } - } - } -} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index c6852ea4a9..f4cfac4aa6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -18,18 +18,10 @@ #pragma once +#include #include -class RigMainGrid; class RimEclipseCase; -class RimFishbonesMultipleSubs; -class RimWellPathFracture; -class RimPerforationInterval; -class RimProject; -class RimWellPath; -class RigEclipseCaseData; - -class QDateTime; //================================================================================================== /// @@ -38,31 +30,7 @@ class QDateTime; class RimCompletionCellIntersectionCalc { public: - static void calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - std::vector& completionTypeCellResult, - const QDateTime& fromDate); - - static void calculateCompletionTypeResult(RimEclipseCase* eclipseCase, - std::vector& completionTypeCellResult, - size_t timeStep); - -private: - static void calculateWellPathIntersections(const RimWellPath* wellPath, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values, - const QDateTime& fromDate); - - static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values); - - static void calculatePerforationIntersections(const RimWellPath* wellPath, - const RimPerforationInterval* perforationInterval, - const RigEclipseCaseData* eclipseCaseData, - std::vector& values); - - static void calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimWellPathFracture* fracture, - std::vector& values); + static void calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep); }; From 4f4a12b6367f558643291f29ff59da7c1dcb0f3e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 10:54:01 +0200 Subject: [PATCH 0920/1027] #2868 Completion Type : Rename --- .../Completions/RimCompletionCellIntersectionCalc.cpp | 10 +++++----- .../RigVirtualPerforationTransmissibilities.cpp | 9 +++++---- .../RigVirtualPerforationTransmissibilities.h | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index ad26c2e525..60c51470e9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -87,14 +87,14 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipse completionTypeCellResult[intersection] = RiaDefines::WELL_PATH; } - auto conn = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); - if (conn) + auto completions = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (completions) { - for (const auto& connForWell : conn->multipleCompletionsPerEclipseCell(wellPath, timeStep)) + for (const auto& completionsForWell : completions->multipleCompletionsPerEclipseCell(wellPath, timeStep)) { RiaDefines::CompletionType appCompletionType = RiaDefines::WELL_PATH; - auto appCompletionTypes = fromCompletionData(connForWell.second); + auto appCompletionTypes = fromCompletionData(completionsForWell.second); if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != appCompletionTypes.end()) @@ -113,7 +113,7 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipse appCompletionType = RiaDefines::PERFORATION_INTERVAL; } - completionTypeCellResult[connForWell.first.globalCellIndex()] = appCompletionType; + completionTypeCellResult[completionsForWell.first.globalCellIndex()] = appCompletionType; } } } diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp index 2f15706166..12a4fafd3d 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -69,7 +69,7 @@ RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilitie //-------------------------------------------------------------------------------------------------- void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( const RimWellPath* wellPath, - std::vector>& completionsPerTimeStep) + const std::vector>& completionsPerTimeStep) { auto item = m_mapFromWellToCompletionData.find(wellPath); @@ -95,7 +95,8 @@ void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( /// //-------------------------------------------------------------------------------------------------- const std::map>& - RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, size_t timeStepIndex) const + RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, + size_t timeStepIndex) const { static std::map> dummy; @@ -118,8 +119,8 @@ const std::map>& /// //-------------------------------------------------------------------------------------------------- void RigVirtualPerforationTransmissibilities::setCompletionDataForSimWell( - const RigSimWellData* simWellData, - std::vector>& completionsPerTimeStep) + const RigSimWellData* simWellData, + const std::vector>& completionsPerTimeStep) { m_mapFromSimWellToCompletionData[simWellData] = completionsPerTimeStep; } diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h index 1ebac53592..411d2a28be 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -56,12 +56,12 @@ class RigVirtualPerforationTransmissibilities : public cvf::Object RigVirtualPerforationTransmissibilities(); ~RigVirtualPerforationTransmissibilities(); - void setCompletionDataForWellPath(const RimWellPath* wellPath, std::vector>& completionsPerTimeStep); + void setCompletionDataForWellPath(const RimWellPath* wellPath, const std::vector>& completionsPerTimeStep); const std::map>& multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, size_t timeStepIndex) const; - void setCompletionDataForSimWell(const RigSimWellData* simWellData, std::vector>& completionsPerTimeStep); + void setCompletionDataForSimWell(const RigSimWellData* simWellData, const std::vector>& completionsPerTimeStep); const std::vector& completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const; From d6d894f631f0823f4baaf3fab4ce89bb66a2a389 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 11:26:47 +0200 Subject: [PATCH 0921/1027] #2868 Completion Type : Change priority order --- .../Completions/RimCompletionCellIntersectionCalc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 60c51470e9..aa0638dfcc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -96,15 +96,15 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipse auto appCompletionTypes = fromCompletionData(completionsForWell.second); - if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != + if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != appCompletionTypes.end()) { - appCompletionType = RiaDefines::FISHBONES; + appCompletionType = RiaDefines::FRACTURE; } - else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != + else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != appCompletionTypes.end()) { - appCompletionType = RiaDefines::FRACTURE; + appCompletionType = RiaDefines::FISHBONES; } else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), From 83d3a033d8dad01baddc6b872a94c07ddad03532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 9 May 2018 13:47:58 +0200 Subject: [PATCH 0922/1027] #2872 Fix creating range filter slices on LGR --- .../Commands/RicNewSliceRangeFilterFeature.cpp | 4 +++- ApplicationCode/Commands/RicRangeFilterExecImpl.cpp | 9 +++++++-- ApplicationCode/Commands/RicRangeFilterExecImpl.h | 6 ++++-- ApplicationCode/Commands/RicRangeFilterInsertExec.cpp | 2 +- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp index f3262f58a5..5efbbed1ee 100644 --- a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp +++ b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp @@ -63,11 +63,13 @@ void RicNewSliceRangeFilterFeature::onActionTriggered(bool isChecked) RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection); QVariantList list = userData.toList(); - CAF_ASSERT(list.size() == 2); + CAF_ASSERT(list.size() == 3); int direction = list[0].toInt(); int sliceStart = list[1].toInt(); + int gridIndex = list[2].toInt(); + filterExec->m_gridIndex = gridIndex; if (direction == 0) { filterExec->m_iSlice = true; diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp index b25e7192ab..6e1315ec3b 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp @@ -27,18 +27,20 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicRangeFilterExecImpl::RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter) +RicRangeFilterExecImpl::RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, + RimCellRangeFilter* insertBeforeCellRangeFilter) : CmdExecuteCommand(nullptr) { CVF_ASSERT(rangeFilterCollection); m_cellRangeFilterCollection = rangeFilterCollection; - m_cellRangeFilter = rangeFilter; + m_insertBeforeCellRangeFilter = insertBeforeCellRangeFilter; m_iSlice = false; m_jSlice = false; m_kSlice = false; + m_gridIndex = 0; m_iSliceStart = -1; m_jSliceStart = -1; m_kSliceStart = -1; @@ -61,6 +63,8 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter() RimCellRangeFilter* rangeFilter = new RimCellRangeFilter(); size_t flterIndex = m_cellRangeFilterCollection->rangeFilters().size() + 1; + + rangeFilter->gridIndex = m_gridIndex; rangeFilter->name = QString("New Filter (%1)").arg(flterIndex); @@ -87,6 +91,7 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter() //-------------------------------------------------------------------------------------------------- void RicRangeFilterExecImpl::applyCommandDataOnFilter(RimCellRangeFilter* rangeFilter) { + rangeFilter->gridIndex = m_gridIndex; if (m_iSlice) { rangeFilter->cellCountI = 1; diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.h b/ApplicationCode/Commands/RicRangeFilterExecImpl.h index c0f7f03296..c63a21edc0 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.h +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.h @@ -31,7 +31,8 @@ class RimCellRangeFilterCollection; class RicRangeFilterExecImpl : public caf::CmdExecuteCommand { public: - RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); + RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, + RimCellRangeFilter* insertBeforeCellRangeFilter = nullptr); virtual ~RicRangeFilterExecImpl(); virtual QString name() = 0; @@ -43,6 +44,7 @@ class RicRangeFilterExecImpl : public caf::CmdExecuteCommand bool m_jSlice; bool m_kSlice; + int m_gridIndex; int m_iSliceStart; int m_jSliceStart; int m_kSliceStart; @@ -53,7 +55,7 @@ class RicRangeFilterExecImpl : public caf::CmdExecuteCommand protected: caf::PdmPointer m_cellRangeFilterCollection; - caf::PdmPointer m_cellRangeFilter; + caf::PdmPointer m_insertBeforeCellRangeFilter; }; diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp index c811959d32..224b4f4b13 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp @@ -57,7 +57,7 @@ void RicRangeFilterInsertExec::redo() RimCellRangeFilter* rangeFilter = createRangeFilter(); if (rangeFilter) { - size_t index = m_cellRangeFilterCollection->rangeFilters.index(m_cellRangeFilter); + size_t index = m_cellRangeFilterCollection->rangeFilters.index(m_insertBeforeCellRangeFilter); CVF_ASSERT(index < m_cellRangeFilterCollection->rangeFilters.size()); m_cellRangeFilterCollection->rangeFilters.insertAt(static_cast(index), rangeFilter); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 3f114e3962..25c80809e7 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -278,14 +278,17 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) QVariantList iSliceList; iSliceList.push_back(0); iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); + iSliceList.push_back(m_currentGridIdx); QVariantList jSliceList; jSliceList.push_back(1); jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); + jSliceList.push_back(m_currentGridIdx); QVariantList kSliceList; kSliceList.push_back(2); kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); + kSliceList.push_back(m_currentGridIdx); menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); From 52c2a93c051478a484e08dcd3e0faa4eceef3ebd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 14:30:46 +0200 Subject: [PATCH 0923/1027] #2882 CF Visualization : Never show connection factor for parent grid cells --- .../RivWellConnectionFactorPartMgr.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp index eb1aa443c5..a2f8d3d269 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -80,7 +80,23 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); if (!trans) return; - auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWellPath, frameIndex); + auto completionsForWellPath = trans->multipleCompletionsPerEclipseCell(m_rimWellPath, frameIndex); + + // Remove connection factors for parent grid, they are not supposed to be visualized, but are relevant for export + for (auto it = completionsForWellPath.begin(); it != completionsForWellPath.end();) + { + size_t gridIndex = it->first.globalCellIndex(); + + const RigCell& rigCell = mainGrid->cell(gridIndex); + if (rigCell.subGrid()) + { + it = completionsForWellPath.erase(it); + } + else + { + ++it; + } + } std::vector wellPathCellIntersections; { @@ -92,11 +108,11 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode } std::vector completionVizDataItems; - for (const auto& cell : conn) + for (const auto& completionsForCell : completionsForWellPath) { if (!m_virtualPerforationResult->showConnectionFactorsOnClosedConnections()) { - for (const auto& completion : cell.second) + for (const auto& completion : completionsForCell.second) { if (completion.connectionState() == SHUT) { @@ -105,7 +121,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode } } - size_t gridIndex = cell.first.globalCellIndex(); + size_t gridIndex = completionsForCell.first.globalCellIndex(); const RigCell& rigCell = mainGrid->cell(gridIndex); @@ -118,7 +134,7 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode { const WellPathCellIntersectionInfo& intersectionInfo = wellPathCellIntersections[i]; - if (intersectionInfo.globCellIndex == cell.first.globalCellIndex()) + if (intersectionInfo.globCellIndex == completionsForCell.first.globalCellIndex()) { double startMD = intersectionInfo.startMD; double endMD = intersectionInfo.endMD; @@ -141,14 +157,14 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); - for (size_t i = 0; i < cell.second.size(); i++) + for (size_t i = 0; i < completionsForCell.second.size(); i++) { - const RigCompletionData& completionData = cell.second[i]; + const RigCompletionData& completionData = completionsForCell.second[i]; double transmissibility = completionData.transmissibility(); completionVizDataItems.push_back( - CompletionVizData(displayCoord, direction, transmissibility, cell.first.globalCellIndex())); + CompletionVizData(displayCoord, direction, transmissibility, completionsForCell.first.globalCellIndex())); } } From cfad0bab63ff8cbdabd0c0bbd48a2839d52a0f01 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 15:10:39 +0200 Subject: [PATCH 0924/1027] Fix Linux issue --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 25c80809e7..3ff7f6bd8b 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -278,17 +278,17 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) QVariantList iSliceList; iSliceList.push_back(0); iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); - iSliceList.push_back(m_currentGridIdx); + iSliceList.push_back(static_cast(m_currentGridIdx)); QVariantList jSliceList; jSliceList.push_back(1); jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); - jSliceList.push_back(m_currentGridIdx); + jSliceList.push_back(static_cast(m_currentGridIdx)); QVariantList kSliceList; kSliceList.push_back(2); kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); - kSliceList.push_back(m_currentGridIdx); + kSliceList.push_back(static_cast(m_currentGridIdx)); menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); From 43bb955ba2f4d3a9136a309f747f738f23c97d07 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 15:43:07 +0200 Subject: [PATCH 0925/1027] #1777 Make access of data in RimStimPlanFractureTemplate robust This commit makes it possible to open a project with invalid path to StimPlan, only displaying an error in the message window. --- .../Completions/RimFractureTemplateCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index b79b7cb6c0..46caf585da 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -185,7 +185,7 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni for (RimFractureTemplate* fractureTemplate : m_fractureDefinitions()) { - if (fractureTemplate) + if (fractureTemplate && fractureTemplate->fractureGrid()) { RimFractureTemplate* templateWithMatchingUnit = nullptr; From 5310d28433283975296d875738525c56b2c869ed Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 9 May 2018 12:40:57 +0200 Subject: [PATCH 0926/1027] #2880 export completions if the the well path name is explictly provided even if unchecked --- .../RicfExportSimWellFractureCompletions.cpp | 10 +++++--- .../RicfExportWellPathCompletions.cpp | 10 +++++--- ...ellPathExportCompletionDataFeatureImpl.cpp | 24 +++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp index 1fa44efdda..3310009243 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp @@ -109,9 +109,13 @@ void RicfExportSimWellFractureCompletions::execute() { for (RimEclipseView* view : views) { - std::copy(view->wellCollection()->wells.begin(), - view->wellCollection()->wells.end(), - std::back_inserter(simWells)); + for (auto simWell : view->wellCollection()->wells) + { + if (simWell->showWell()) + { + simWells.push_back(simWell); + } + } } } else diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index 36fc6f242b..a99148a1d7 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -112,9 +112,13 @@ void RicfExportWellPathCompletions::execute() std::vector wellPaths; if (m_wellPathNames().empty()) { - std::copy(RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().begin(), - RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().end(), - std::back_inserter(wellPaths)); + for (auto wellPath : RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths()) + { + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } + } } else { diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 7df2e64d29..f2c37441ef 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -63,8 +63,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, - const std::vector& simWells, +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& usedWellPaths, + const std::vector& usedSimWells, const RicExportCompletionDataSettingsUi& exportSettings) { if (exportSettings.caseToApply() == nullptr) @@ -73,15 +73,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve return; } - std::vector usedWellPaths; - for (auto wellPath : wellPaths) - { - if (wellPath->showWellPath) - { - usedWellPaths.push_back(wellPath); - } - } - + { bool unitSystemMismatch = false; for (const RimWellPath* wellPath : usedWellPaths) @@ -93,7 +85,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } - for (const RimSimWellInView* simWell : simWells) + for (const RimSimWellInView* simWell : usedSimWells) { RimEclipseCase* eclipseCase; simWell->firstAncestorOrThisOfType(eclipseCase); @@ -137,13 +129,13 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } - size_t maxProgress = usedWellPaths.size() * 3 + simWells.size() + + size_t maxProgress = usedWellPaths.size() * 3 + usedSimWells.size() + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + - simWells.size(); + usedSimWells.size(); caf::ProgressInfo progress(maxProgress, "Export Completions"); @@ -219,7 +211,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve progress.incrementProgress(); } - for (auto simWell : simWells) + for (auto simWell : usedSimWells) { std::map> completionsPerEclipseCell; @@ -307,7 +299,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) { - for (auto simWell : simWells) + for (auto simWell : usedSimWells) { std::vector wellCompletions; for (const auto& completion : completions) From b9cbd7c5031d2d2fb329d0db908ddea5e4f6291e Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 9 May 2018 13:05:50 +0200 Subject: [PATCH 0927/1027] #2881 Continue exporting other completions if one has a unit mismatch. * Report an error and continue rather than abort. --- ...ellPathExportCompletionDataFeatureImpl.cpp | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index f2c37441ef..9398094783 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -63,8 +63,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& usedWellPaths, - const std::vector& usedSimWells, +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings) { if (exportSettings.caseToApply() == nullptr) @@ -74,31 +74,19 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } + std::vector usedWellPaths; + for (RimWellPath* wellPath : wellPaths) { - bool unitSystemMismatch = false; - for (const RimWellPath* wellPath : usedWellPaths) + if (wellPath->unitSystem() == exportSettings.caseToApply->eclipseCaseData()->unitsType()) { - if (wellPath->unitSystem() != exportSettings.caseToApply->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } - } - - for (const RimSimWellInView* simWell : usedSimWells) - { - RimEclipseCase* eclipseCase; - simWell->firstAncestorOrThisOfType(eclipseCase); - if (exportSettings.caseToApply->eclipseCaseData()->unitsType() != eclipseCase->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } + usedWellPaths.push_back(wellPath); } - if (unitSystemMismatch) + else { - RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); - return; + int caseId = exportSettings.caseToApply->caseId(); + QString format = QString("Unit systems for well path \"%1\" must match unit system of chosen eclipse case \"%2\""); + QString errMsg = format.arg(wellPath->name()).arg(caseId); + RiaLogging::error(errMsg); } } @@ -129,13 +117,13 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve } } - size_t maxProgress = usedWellPaths.size() * 3 + usedSimWells.size() + + size_t maxProgress = usedWellPaths.size() * 3 + simWells.size() + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + - usedSimWells.size(); + simWells.size(); caf::ProgressInfo progress(maxProgress, "Export Completions"); @@ -211,7 +199,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve progress.incrementProgress(); } - for (auto simWell : usedSimWells) + for (auto simWell : simWells) { std::map> completionsPerEclipseCell; @@ -299,7 +287,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) { - for (auto simWell : usedSimWells) + for (auto simWell : simWells) { std::vector wellCompletions; for (const auto& completion : completions) From c959db73a1b620126c79628c67061564ec72f201 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 9 May 2018 15:55:54 +0200 Subject: [PATCH 0928/1027] #2887 Tidy up 3D well log curve configuration to more obvious documentation. --- .../ModelVisualization/Riv3dWellLogPlanePartMgr.cpp | 2 +- .../Completions/Rim3dWellLogCurveCollection.cpp | 8 +++----- ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp | 2 +- .../ProjectDataModel/RimWellLogCurveNameConfig.cpp | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 73b38e0a62..f7a8e7b50c 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -114,7 +114,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* if (curveDrawable.notNull() && curveDrawable->boundingBox().isValid()) { caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); - meshEffectGen.setLineWidth(2.0f); + meshEffectGen.setLineWidth(3.0f); cvf::ref effect = meshEffectGen.generateCachedEffect(); cvf::ref part = new cvf::Part; diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp index 2ad6866768..f1709c5f69 100644 --- a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -202,12 +202,10 @@ caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Configuration"); + caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); + settingsGroup->add(&m_showGrid); + settingsGroup->add(&m_showBackground); settingsGroup->add(&m_planeWidthScaling); - - caf::PdmUiGroup* appearanceSettingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); - appearanceSettingsGroup->add(&m_showGrid); - appearanceSettingsGroup->add(&m_showBackground); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 7fcf8767d3..1c4c13953f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -204,7 +204,7 @@ void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Configuration"); + caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Appearance"); configurationGroup->add(&m_drawPlane); // Disable filled draw style in the GUI because of triangle stitching issue #2860. // configurationGroup->add(&m_drawStyle); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp index 579f1d345d..1cd7555830 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp @@ -88,7 +88,7 @@ QString RimCurveNameConfig::name() const //-------------------------------------------------------------------------------------------------- caf::PdmUiGroup* RimCurveNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name Configuration"); + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); nameGroup->add(&m_isUsingAutoName); return nameGroup; } From 9560e23b6635f3358eafbf91881643c0e759f690 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 16:01:59 +0200 Subject: [PATCH 0929/1027] #2888 Auto Title : Crash when single summary case is nullptr --- .../Summary/RimSummaryPlotNameHelper.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 5d97cc4d91..59789ed6fc 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -59,9 +59,9 @@ void RimSummaryPlotNameHelper::appendSummaryCases(const std::vectorcaseName(); } - else if (m_ensembleCases.size() == 1 && m_summaryCases.empty()) + } + else if (m_ensembleCases.size() == 1 && m_summaryCases.empty()) + { + auto ensembleCase = *(m_ensembleCases.begin()); + if (ensembleCase) { - auto ensembleCase = *(m_ensembleCases.begin()); - m_titleCaseName = ensembleCase->name(); } } From 090435a2ea4c4d7f77ae7bdfbfb12260a1984474 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 9 May 2018 16:29:14 +0200 Subject: [PATCH 0930/1027] OpenMP : Make sure grid is created before using OpenMP --- .../GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 3d223d4ce3..ece1c4d4cc 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1487,12 +1487,15 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues compactionFrame.resize(nodeCount); - // Make sure the AABB-tree is created before using OpenMP { + // Make sure the AABB-tree is created before using OpenMP cvf::BoundingBox bb; std::vector refElementCandidates; part->findIntersectingCells(bb, &refElementCandidates); + + // Also make sure the struct grid is created, as this is required before using OpenMP + part->structGrid(); } #pragma omp parallel for From 6270dd3bc903aa77cb88153afb4d9d091385a7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 10 May 2018 21:29:55 +0200 Subject: [PATCH 0931/1027] #2692 Ensemble curves. Add ensemble selection support to curve editor --- .../Application/RiaSummaryCurveDefinition.cpp | 21 ++- .../Application/RiaSummaryCurveDefinition.h | 10 +- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 2 +- .../RicPasteEnsembleCurveSetFeature.cpp | 2 +- .../RicSummaryCurveCreator.cpp | 94 ++++++++----- .../RicSummaryCurveCreator.h | 2 +- .../ProjectDataModel/RimPlotCurve.cpp | 2 +- .../Summary/RimEnsembleCurveSet.cpp | 18 +++ .../Summary/RimEnsembleCurveSet.h | 2 + .../Summary/RimSummaryCaseCollection.cpp | 2 + .../Summary/RimSummaryCaseCollection.h | 2 + .../Summary/RimSummaryPlot.cpp | 46 ++++++- .../ProjectDataModel/Summary/RimSummaryPlot.h | 3 +- .../RiuSummaryCurveDefSelection.cpp | 123 +++++++++++++----- .../RiuSummaryCurveDefSelection.h | 11 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 6 +- 16 files changed, 264 insertions(+), 82 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index d6027a2d76..9f114937d6 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -24,9 +24,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress) +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, + const RifEclipseSummaryAddress& summaryAddress, + RimSummaryCaseCollection* ensemble) { m_curveDefinition = std::make_pair(summaryCase, summaryAddress); + m_ensemble = ensemble; } //-------------------------------------------------------------------------------------------------- @@ -37,6 +40,14 @@ RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const return m_curveDefinition.first; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const +{ + return m_ensemble; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -45,6 +56,14 @@ const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() cons return m_curveDefinition.second; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryCurveDefinition::isEnsembleCurve() const +{ + return m_ensemble != nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.h b/ApplicationCode/Application/RiaSummaryCurveDefinition.h index 7978a90a02..608a5f3951 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.h @@ -26,6 +26,7 @@ #include class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== /// @@ -33,10 +34,14 @@ class RimSummaryCase; class RiaSummaryCurveDefinition { public: - explicit RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress); + explicit RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, + const RifEclipseSummaryAddress& summaryAddress, + RimSummaryCaseCollection* emsemble = nullptr); RimSummaryCase* summaryCase() const; const RifEclipseSummaryAddress& summaryAddress() const; + RimSummaryCaseCollection* ensemble() const; + bool isEnsembleCurve() const; bool operator < (const RiaSummaryCurveDefinition& other) const; @@ -51,5 +56,6 @@ class RiaSummaryCurveDefinition private: private: - std::pair m_curveDefinition; + std::pair m_curveDefinition; + RimSummaryCaseCollection* m_ensemble; }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index c3185b7b88..c95f5e4261 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -70,7 +70,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) curveSet->setSummaryCaseCollection(project->summaryGroups().back()); } - plot->ensembleCurveSets()->addCurveSet(curveSet); + plot->ensembleCurveSetCollection()->addCurveSet(curveSet); plot->updateConnectedEditors(); RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(curveSet); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp index e843b81d7d..5a8ef7a69e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp @@ -52,7 +52,7 @@ RimEnsembleCurveSet* RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollec RimEnsembleCurveSet* newCurveSet = dynamic_cast(sourceCurveSet->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(newCurveSet); - if (!coll) coll = plot->ensembleCurveSets(); + if (!coll) coll = plot->ensembleCurveSetCollection(); coll->addCurveSet(newCurveSet); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 39f63962f1..c7b3c09b8a 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -309,7 +309,7 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() std::vector allCurveDefinitionsVector = m_summaryCurveSelectionEditor->summaryAddressSelection()->selectedCurveDefinitions(); std::set allCurveDefinitions = std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); - std::vector currentCurvesInPreviewPlot = m_previewPlot->summaryCurves(); + std::vector currentCurvesInPreviewPlot = m_previewPlot->summaryAndEnsembleCurves(); if (allCurveDefinitions.size() != currentCurvesInPreviewPlot.size()) { std::set currentCurveDefs; @@ -374,8 +374,33 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: curve->setSummaryCaseY(currentCase); curve->setSummaryAddressY(curveDef.summaryAddress()); curve->applyCurveAutoNameSettings(*m_curveNameConfig()); - m_previewPlot->addCurveNoUpdate(curve); - curveLookCalc.setupCurveLook(curve); + + if (curveDef.isEnsembleCurve()) + { + // Find curveSet + RimEnsembleCurveSet* curveSet = nullptr; + for (const auto& cs : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + if (cs->summaryCaseCollection() == curveDef.ensemble() && cs->summaryAddress() == curveDef.summaryAddress()) + { + curveSet = cs; + break; + } + } + if (!curveSet) + { + curveSet = new RimEnsembleCurveSet(); + curveSet->setSummaryCaseCollection(curveDef.ensemble()); + curveSet->setSummaryAddress(curveDef.summaryAddress()); + m_previewPlot->ensembleCurveSetCollection()->addCurveSet(curveSet); + } + curveSet->addCurve(curve); + } + else + { + m_previewPlot->addCurveNoUpdate(curve); + curveLookCalc.setupCurveLook(curve); + } } m_previewPlot->loadDataAndUpdate(); @@ -489,24 +514,40 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu std::vector curveDefs; m_previewPlot->deleteAllSummaryCurves(); + m_previewPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); + for (const auto& curve : sourceSummaryPlot.summaryCurves()) { - bool isObservedDataCase = isObservedData(curve->summaryCaseY()); - curveDefs.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); // Copy curve object to the preview plot copyCurveAndAddToPlot(curve, m_previewPlot.get(), true); } + RimEnsembleCurveSetCollection* previewCurveSetColl = m_previewPlot->ensembleCurveSetCollection(); + for (const auto& curveSet : sourceSummaryPlot.ensembleCurveSetCollection()->curveSets()) + { + RimEnsembleCurveSet* newCurveSet = curveSet->clone(); + previewCurveSetColl->addCurveSet(newCurveSet); + + RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); + for (const auto& curve : curveSet->curves()) + { + curveDefs.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY(), ensemble)); + + // Copy curve object to the preview plot + copyEnsembleCurveAndAddToCurveSet(curve, newCurveSet, true); + } + } + // Set visibility for imported curves which were not checked in source plot std::set > sourceCurveDefs; - for (const auto& curve : sourceSummaryPlot.summaryCurves()) + for (const auto& curve : sourceSummaryPlot.summaryAndEnsembleCurves()) { sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); } - for (const auto& curve : m_previewPlot->summaryCurves()) + for (const auto& curve : m_previewPlot->summaryAndEnsembleCurves()) { auto curveDef = std::make_pair(curve->summaryCaseY(), curve->summaryAddressY()); if (sourceCurveDefs.count(curveDef) == 0) @@ -531,6 +572,7 @@ void RicSummaryCurveCreator::updateTargetPlot() if (m_targetPlot == nullptr) m_targetPlot = new RimSummaryPlot(); m_targetPlot->deleteAllSummaryCurves(); + m_targetPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); // Add edited curves to target plot for (const auto& editedCurve : m_previewPlot->summaryCurves()) @@ -542,22 +584,20 @@ void RicSummaryCurveCreator::updateTargetPlot() copyCurveAndAddToPlot(editedCurve, m_targetPlot); } - // DEBUG - //{ - // m_targetPlot->ensembleCurveSets()->deleteAllCurveSets(); - - // RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - // m_targetPlot->ensembleCurveSets()->addCurveSet(curveSet); + for (const auto& editedCurveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + if (!editedCurveSet->isCurvesVisible()) + { + continue; + } - // for (const auto& editedCurve : m_previewPlot->summaryCurves()) - // { - // if (!editedCurve->isCurveVisible()) - // { - // continue; - // } - // copyEnsembleCurveAndAddToPlot(editedCurve, curveSet); - // } - //} + RimEnsembleCurveSet* newCurveSet = editedCurveSet->clone(); + m_targetPlot->ensembleCurveSetCollection()->addCurveSet(newCurveSet); + for (const auto& editedCurve : newCurveSet->curves()) + { + copyEnsembleCurveAndAddToCurveSet(editedCurve, editedCurveSet); + } + } m_targetPlot->enableAutoPlotTitle(m_useAutoPlotTitleProxy()); @@ -580,9 +620,6 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, plot->addCurveNoUpdate(curveCopy); - // Resolve references after object has been inserted into the project data model - curveCopy->resolveReferencesRecursively(); - // The curve creator is not a descendant of the project, and need to be set manually curveCopy->setSummaryCaseY(curve->summaryCaseY()); curveCopy->initAfterReadRecursively(); @@ -592,7 +629,7 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::copyEnsembleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsembleCurveSet *curveSet, bool forceVisible) +void RicSummaryCurveCreator::copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible) { RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); @@ -604,9 +641,6 @@ void RicSummaryCurveCreator::copyEnsembleCurveAndAddToPlot(const RimSummaryCurve curveSet->addCurve(curveCopy); - // Resolve references after object has been inserted into the project data model - curveCopy->resolveReferencesRecursively(); - // The curve creator is not a descendant of the project, and need to be set manually curveCopy->setSummaryCaseY(curve->summaryCaseY()); curveCopy->initAfterReadRecursively(); @@ -703,7 +737,7 @@ std::set RicSummaryCurveCreator::allPreviewCurveDefs( { std::set allCurveDefs; - for (const auto& curve : m_previewPlot->summaryCurves()) + for (const auto& curve : m_previewPlot->summaryAndEnsembleCurves()) { allCurveDefs.insert(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index 096ff70f2d..d80b37e1be 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -87,7 +87,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot); void updateTargetPlot(); static void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false); - static void copyEnsembleCurveAndAddToPlot(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible = false); + static void copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible = false); void setDefaultCurveSelection(const std::vector& defaultCases); void resetAllFields(); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 968c96703d..833c8820f3 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -596,7 +596,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { bool showLegendInQwt = m_showLegend(); - if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) + if (summaryPlot->ensembleCurveSetCollection()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) { // Disable display of legend if the summary plot has only one single curve showLegendInQwt = false; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index af184fce19..1855876272 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -244,6 +244,14 @@ void RimEnsembleCurveSet::deleteCurve(RimSummaryCurve* curve) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setSummaryAddress(RifEclipseSummaryAddress address) +{ + m_yValuesCurveVariable->setAddress(address); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -816,6 +824,16 @@ void RimEnsembleCurveSet::updateAllCurves() updateCurveColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const +{ + RimEnsembleCurveSet* copy = dynamic_cast(this->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + copy->m_yValuesSummaryGroup = m_yValuesSummaryGroup(); + return copy; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 28fb9ebd9c..ad011ead94 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -72,6 +72,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void addCurve(RimSummaryCurve* curve); void deleteCurve(RimSummaryCurve* curve); + void setSummaryAddress(RifEclipseSummaryAddress address); RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; std::vector visibleCurves() const; @@ -89,6 +90,7 @@ class RimEnsembleCurveSet : public caf::PdmObject EnsembleParameterType currentEnsembleParameterType() const; void updateAllCurves(); + RimEnsembleCurveSet* clone() const; private: caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 078d90deec..027964f571 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -23,6 +23,8 @@ #include "RimProject.h" #include "RimSummaryCase.h" +#include "RifSummaryReaderInterface.h" + CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection, "SummaryCaseSubCollection"); //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 974bb3035b..c5d6897c16 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -18,6 +18,8 @@ #pragma once +#include "RifEclipseSummaryAddress.h" + #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 19aea2e178..ae9f0d4bfd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -466,6 +466,23 @@ QString RimSummaryPlot::asciiDataForPlotExport() const return out; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::summaryAndEnsembleCurves() const +{ + std::vector curves = summaryCurves(); + + for (const auto& curveSet : ensembleCurveSetCollection()->curveSets()) + { + for (const auto& curve : curveSet->curves()) + { + curves.push_back(curve); + } + } + return curves; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -967,7 +984,32 @@ void RimSummaryPlot::deleteCurve(RimSummaryCurve* curve) { if (m_summaryCurveCollection) { - m_summaryCurveCollection->deleteCurve(curve); + for (auto& c : m_summaryCurveCollection->curves()) + { + if (c == curve) + { + m_summaryCurveCollection->deleteCurve(curve); + return; + } + } + } + if (m_ensembleCurveSetCollection) + { + for (auto& curveSet : m_ensembleCurveSetCollection->curveSets()) + { + for (auto& c : curveSet->curves()) + { + if (c == curve) + { + curveSet->deleteCurve(curve); + if (curveSet->curves().empty()) + { + m_ensembleCurveSetCollection->deleteCurveSet(curveSet); + } + return; + } + } + } } } } @@ -986,7 +1028,7 @@ void RimSummaryPlot::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSetCollection* RimSummaryPlot::ensembleCurveSets() const +RimEnsembleCurveSetCollection* RimSummaryPlot::ensembleCurveSetCollection() const { return m_ensembleCurveSetCollection; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index e3c4e39327..226a830a7b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -75,7 +75,7 @@ class RimSummaryPlot : public RimViewWindow void setCurveCollection(RimSummaryCurveCollection* curveCollection); void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); - RimEnsembleCurveSetCollection* ensembleCurveSets() const; + RimEnsembleCurveSetCollection* ensembleCurveSetCollection() const; void addGridTimeHistoryCurve(RimGridTimeHistoryCurve* curve); @@ -108,6 +108,7 @@ class RimSummaryPlot : public RimViewWindow QString asciiDataForPlotExport() const; + std::vector summaryAndEnsembleCurves() const; std::vector summaryCurves() const; void deleteAllSummaryCurves(); RimSummaryCurveCollection* summaryCurveCollection() const; diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 07695e097e..d7c7e852ce 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -39,6 +39,8 @@ #include "RiuSummaryVectorDescriptionMap.h" #include "cafPdmUiTreeSelectionEditor.h" +//#include "cafPdmObject.h" +#include "cafPdmPointer.h" #include @@ -147,8 +149,8 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM } }, }) { - CAF_PDM_InitFieldNoDefault(&m_selectedCases, "SummaryCases", "Cases", "", "", ""); - m_selectedCases.uiCapability()->setAutoAddingOptionFromValue(false); + CAF_PDM_InitFieldNoDefault(&m_selectedSources, "SummaryCases", "Cases", "", "", ""); + m_selectedSources.uiCapability()->setAutoAddingOptionFromValue(false); CAF_PDM_InitFieldNoDefault(&m_currentSummaryCategory, "CurrentSummaryCategory", "Current Summary Category", "", "", ""); @@ -217,9 +219,9 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM itemTypes.second.back()->pdmField()->uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); } - m_selectedCases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - m_selectedCases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); - m_selectedCases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); + m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); m_selectedSummaryCategories.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); m_selectedSummaryCategories.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); @@ -247,34 +249,55 @@ RiuSummaryCurveDefSelection::~RiuSummaryCurveDefSelection() //-------------------------------------------------------------------------------------------------- std::vector RiuSummaryCurveDefSelection::selectedCurveDefinitions() const { - std::vector caseAndAddressVector; + std::vector curveDefVector; { std::set caseAndAddressPairs; std::set selectedAddressesFromUi = buildAddressListFromSelections(); - for (RimSummaryCase* currCase : selectedSummaryCases()) + for (SummarySource* currSource : selectedSummarySources()) { - if (currCase && currCase->summaryReader()) + std::vector sourceCases; + RimSummaryCaseCollection* ensemble = dynamic_cast(currSource); + + // Build case list + if (ensemble) + { + auto sumCases = ensemble->allSummaryCases(); + sourceCases.insert(sourceCases.end(), sumCases.begin(), sumCases.end()); + } + else { - RifSummaryReaderInterface* reader = currCase->summaryReader(); + RimSummaryCase* sourceCase = dynamic_cast(currSource); + if (sourceCase) + { + sourceCases.push_back(sourceCase); + } + } - const std::vector& readerAddresses = reader->allResultAddresses(); - for (const auto& readerAddress : readerAddresses) + for (const auto& currCase : sourceCases) + { + if (currCase && currCase->summaryReader()) { - if (selectedAddressesFromUi.count(readerAddress) > 0) + RifSummaryReaderInterface* reader = currCase->summaryReader(); + + const std::vector& readerAddresses = reader->allResultAddresses(); + for (const auto& readerAddress : readerAddresses) { - caseAndAddressPairs.insert(RiaSummaryCurveDefinition(currCase, readerAddress)); + if (selectedAddressesFromUi.count(readerAddress) > 0) + { + caseAndAddressPairs.insert(RiaSummaryCurveDefinition(currCase, readerAddress, ensemble)); + } } } } } - std::copy(caseAndAddressPairs.begin(), caseAndAddressPairs.end(), std::back_inserter(caseAndAddressVector)); + std::copy(caseAndAddressPairs.begin(), caseAndAddressPairs.end(), std::back_inserter(curveDefVector)); } - return caseAndAddressVector; + return curveDefVector; } //-------------------------------------------------------------------------------------------------- @@ -325,15 +348,15 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< { resetAllFields(); - for (const auto& caseAddressPair : curveDefinitions) + for (const auto& curveDef : curveDefinitions) { - RimSummaryCase* summaryCase = caseAddressPair.summaryCase(); + RimSummaryCase* summaryCase = curveDef.summaryCase(); if (!summaryCase) continue; - RifEclipseSummaryAddress summaryAddress = caseAddressPair.summaryAddress(); + RifEclipseSummaryAddress summaryAddress = curveDef.summaryAddress(); if (summaryAddress.category() == RifEclipseSummaryAddress::SUMMARY_INVALID) { - // If we have an invalid address, set the default adress to Field + // If we have an invalid address, set the default address to Field summaryAddress = RifEclipseSummaryAddress::fieldVarAddress(summaryAddress.quantityName()); } @@ -352,11 +375,13 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< } // Select case if not already selected - if (std::find(m_selectedCases.begin(), m_selectedCases.end(), summaryCase) == m_selectedCases.end()) + if (std::find(m_selectedSources.begin(), m_selectedSources.end(), + curveDef.isEnsembleCurve() ? (SummarySource*)curveDef.ensemble() : summaryCase) == m_selectedSources.end()) { if (summaryCase != calculatedSummaryCase()) { - m_selectedCases.push_back(summaryCase); + + m_selectedSources.push_back(curveDef.isEnsembleCurve() ? (SummarySource*)curveDef.ensemble() : summaryCase); } } @@ -421,7 +446,7 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions { QList options; - if (fieldNeedingOptions == &m_selectedCases) + if (fieldNeedingOptions == &m_selectedSources) { RimProject* proj = RiaApplication::instance()->project(); std::vector topLevelCases; @@ -439,9 +464,28 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions options.push_back(caf::PdmOptionItemInfo(sumCase->caseName(), sumCase)); } + // Ensembles + bool ensembleHeaderCreated = false; + for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + { + if (!sumCaseColl->isEnsemble()) continue; + + if (!ensembleHeaderCreated) + { + options.push_back(caf::PdmOptionItemInfo::createHeader("Ensembles", true)); + ensembleHeaderCreated = true; + } + + auto optionItem = caf::PdmOptionItemInfo(sumCaseColl->name(), sumCaseColl); + optionItem.setLevel(1); + options.push_back(optionItem); + } + // Grouped cases for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) { + if (sumCaseColl->isEnsemble()) continue; + options.push_back(caf::PdmOptionItemInfo::createHeader(sumCaseColl->name(), true)); for (const auto& sumCase : sumCaseColl->allSummaryCases()) @@ -575,7 +619,7 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", RiuSummaryCurveDefinitionKeywords::sources()); - sourcesGroup->add(&m_selectedCases); + sourcesGroup->add(&m_selectedSources); caf::PdmUiGroup* itemTypesGroup = uiOrdering.addNewGroupWithKeyword("Summary Types", RiuSummaryCurveDefinitionKeywords::summaryTypes()); itemTypesGroup->add(&m_selectedSummaryCategories); @@ -729,9 +773,11 @@ void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::Pd std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedCases(const SummaryIdentifierAndField *identifierAndField) { std::vector cases; - for (const auto& sumCase : m_selectedCases()) + for (const auto& source : m_selectedSources()) { - if(isObservedData(sumCase)) continue; + RimSummaryCase* sumCase = dynamic_cast(source.p()); + + if(!sumCase || isObservedData(sumCase)) continue; cases.push_back(sumCase); } return findPossibleSummaryAddresses(cases, identifierAndField); @@ -743,9 +789,11 @@ std::set RiuSummaryCurveDefSelection::findPossibleSumm std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedObservedData(const SummaryIdentifierAndField *identifierAndField) { std::vector obsData; - for (const auto& sumCase : m_selectedCases()) + for (const auto& source : m_selectedSources()) { - if (isObservedData(sumCase)) + RimSummaryCase* sumCase = dynamic_cast(source.p()); + + if (sumCase && isObservedData(sumCase)) { obsData.push_back(sumCase); } @@ -964,7 +1012,7 @@ void RiuSummaryCurveDefSelection::defineEditorAttribute(const caf::PdmFieldHandl //-------------------------------------------------------------------------------------------------- void RiuSummaryCurveDefSelection::resetAllFields() { - m_selectedCases.clear(); + m_selectedSources.clear(); m_selectedSummaryCategories = std::vector>(); // clear all state in fields @@ -980,27 +1028,30 @@ void RiuSummaryCurveDefSelection::resetAllFields() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuSummaryCurveDefSelection::isObservedData(RimSummaryCase *sumCase) const +bool RiuSummaryCurveDefSelection::isObservedData(const RimSummaryCase *sumCase) const { - return dynamic_cast(sumCase) != nullptr; + return dynamic_cast(sumCase) != nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuSummaryCurveDefSelection::selectedSummaryCases() const +std::vector RiuSummaryCurveDefSelection::selectedSummarySources() const { - std::vector cases; + std::vector sources; - for (RimSummaryCase* currCase : m_selectedCases) + for (const auto& source : m_selectedSources) { - cases.push_back(currCase); + RimSummaryCase* c = dynamic_cast(source.p()); + RimSummaryCaseCollection* cc = dynamic_cast(source.p()); + + sources.push_back(source); } // Always add the summary case for calculated curves as this case is not displayed in UI - cases.push_back(RiuSummaryCurveDefSelection::calculatedSummaryCase()); + sources.push_back(RiuSummaryCurveDefSelection::calculatedSummaryCase()); - return cases; + return sources; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index 46eb4118ed..d0b0df5783 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -33,11 +33,16 @@ #define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA" class RimSummaryCase; +class RimSummaryCaseCollection; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; class SummaryIdentifierAndField; + +using SummarySource = caf::PdmObject; + + //================================================================================================== /// /// @@ -86,13 +91,13 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject std::set& addressSet) const; void resetAllFields(); - bool isObservedData(RimSummaryCase *sumCase) const; + bool isObservedData(const RimSummaryCase *sumCase) const; - std::vector selectedSummaryCases() const; + std::vector selectedSummarySources() const; static RimSummaryCase* calculatedSummaryCase(); private: - caf::PdmPtrArrayField m_selectedCases; + caf::PdmPtrArrayField m_selectedSources; caf::PdmField>> m_selectedSummaryCategories; caf::PdmField> m_currentSummaryCategory; diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 4d5f5cf2e1..9e6df6c007 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -82,7 +82,7 @@ class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider for (auto const plot : project->mainPlotCollection->summaryPlotCollection()->summaryPlots()) { RimSummaryPlot* sumPlot = plot->qwtPlot()->ownerPlotDefinition(); - for (auto const curveSet : sumPlot->ensembleCurveSets()->curveSets()) + for (auto const curveSet : sumPlot->ensembleCurveSetCollection()->curveSets()) { for (auto const currSumCurve : curveSet->curves()) { @@ -219,9 +219,9 @@ void RiuSummaryQwtPlot::updateEnsembleLegendLayout() int ypos = startMarginY; int maxColumnWidth = 0; - if (!ownerPlotDefinition() || !ownerPlotDefinition()->ensembleCurveSets()) return; + if (!ownerPlotDefinition() || !ownerPlotDefinition()->ensembleCurveSetCollection()) return; - for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSets()->curveSets()) + for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSetCollection()->curveSets()) { auto pairIt = m_ensembleLegendWidgets.find(curveSet); if (pairIt != m_ensembleLegendWidgets.end()) From bb033eb561c9fb2a55b996ffbe1a0634cf5658ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 08:01:10 +0200 Subject: [PATCH 0932/1027] #2883, #2890 Fix color assignment and stability for ensemble curve sets --- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 6 +++ .../ProjectDataModel/RimEclipseCellColors.cpp | 6 +-- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimGeoMechCellColors.cpp | 6 +-- .../RimRegularLegendConfig.cpp | 15 ++---- .../ProjectDataModel/RimRegularLegendConfig.h | 6 +-- .../ProjectDataModel/RimStimPlanColors.cpp | 2 +- .../Summary/RimEnsembleCurveSet.cpp | 3 +- .../Summary/RimEnsembleCurveSetCollection.cpp | 14 ++++-- .../Summary/RimEnsembleCurveSetCollection.h | 1 + .../RimEnsembleCurveSetColorManager.cpp | 47 +++---------------- .../Summary/RimEnsembleCurveSetColorManager.h | 6 +-- 12 files changed, 41 insertions(+), 73 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index c95f5e4261..5c85ead3bf 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -19,6 +19,7 @@ #include "RicNewSummaryEnsembleCurveSetFeature.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" @@ -30,6 +31,7 @@ #include "RimSummaryPlotCollection.h" #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" #include "RiuPlotMainWindow.h" @@ -65,6 +67,10 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) { RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); + size_t colorIndex = plot->ensembleCurveSets()->curveSetCount(); + curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); + curveSet->legendConfig()->setColorRange(RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(static_cast(colorIndex))); + if (!project->summaryGroups().empty()) { curveSet->setSummaryCaseCollection(project->summaryGroups().back()); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 7c15f9065c..fe3d9148dd 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -209,7 +209,7 @@ void RimEclipseCellColors::updateLegendCategorySettings() if (this->hasCategoryResult()) { legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); - legendConfig()->setColorRangeMode(RimRegularLegendConfig::CATEGORY); + legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY); } else { @@ -218,9 +218,9 @@ void RimEclipseCellColors::updateLegendCategorySettings() legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if (legendConfig()->colorRangeMode() == RimRegularLegendConfig::CATEGORY) + if (legendConfig()->colorRange() == RimRegularLegendConfig::CATEGORY) { - legendConfig()->setColorRangeMode(RimRegularLegendConfig::NORMAL); + legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL); } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index d4c1ce3499..d422703c6e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -151,7 +151,7 @@ RimEclipseView::RimEclipseView() this->cellResult()->setReservoirView(this); this->cellEdgeResult()->setReservoirView(this); - this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimRegularLegendConfig::PINK_WHITE); + this->cellEdgeResult()->legendConfig()->setColorRange(RimRegularLegendConfig::PINK_WHITE); this->faultResultSettings()->setReservoirView(this); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index 835d1fbdb4..98c9bdf542 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -88,7 +88,7 @@ void RimGeoMechCellColors::updateLegendCategorySettings() if(this->hasCategoryResult()) { legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); - legendConfig->setColorRangeMode(RimRegularLegendConfig::CATEGORY); + legendConfig->setColorRange(RimRegularLegendConfig::CATEGORY); } else { @@ -97,9 +97,9 @@ void RimGeoMechCellColors::updateLegendCategorySettings() legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if(legendConfig->colorRangeMode() == RimRegularLegendConfig::CATEGORY) + if(legendConfig->colorRange() == RimRegularLegendConfig::CATEGORY) { - legendConfig->setColorRangeMode(RimRegularLegendConfig::NORMAL); + legendConfig->setColorRange(RimRegularLegendConfig::NORMAL); } } } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 22e680a2bb..0513d231d6 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -513,7 +513,7 @@ void RimRegularLegendConfig::updateFieldVisibility() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimRegularLegendConfig::setColorRangeMode(ColorRangesType colorMode) +void RimRegularLegendConfig::setColorRange(ColorRangesType colorMode) { m_colorRangeMode = colorMode; updateLegend(); @@ -744,15 +744,6 @@ const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() cons } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimRegularLegendConfig::initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet) -{ - // Set default color palette for ensemble curve sets - setColorRangeMode(ColorManager::nextColorRange(curveSet)); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -804,7 +795,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy return RiaColorTables::stimPlanPaletteColors().color3ubArray(); break; default: - if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::ENSEMBLE_COLOR_RANGES.at(colorType); + if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges.at(colorType); break; } @@ -906,7 +897,7 @@ QList RimRegularLegendConfig::calculateValueOptions(cons } else { - for (const auto& col : ColorManager::ENSEMBLE_COLOR_RANGES) + for (const auto& col : ColorManager::EnsembleColorRanges) { rangeTypes.push_back(col.first); } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h index c7345561a3..8dafd2af15 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -99,8 +99,8 @@ class RimRegularLegendConfig : public RimLegendConfig typedef caf::AppEnum MappingEnum; void recreateLegend(); - void setColorRangeMode(ColorRangesType colorMode); - ColorRangesType colorRangeMode() { return m_colorRangeMode();} + void setColorRange(ColorRangesType colorMode); + ColorRangesType colorRange() { return m_colorRangeMode();} void setMappingMode(MappingType mappingType); MappingType mappingMode() { return m_mappingMode();} void disableAllTimeStepsRange(bool doDisable); @@ -125,8 +125,6 @@ class RimRegularLegendConfig : public RimLegendConfig const caf::TitledOverlayFrame* titledOverlayFrame() const override; caf::TitledOverlayFrame* titledOverlayFrame() override; - void initForEnsembleCurveSet(RimEnsembleCurveSet* curveSet); - private: void setNamedCategories(const std::vector& categoryNames, bool inverse); void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 2b7afe1325..a9850e13d4 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -152,7 +152,7 @@ void RimStimPlanColors::loadDataAndUpdate() RimRegularLegendConfig* legendConfig = new RimRegularLegendConfig(); legendConfig->resultVariableName = resultNameUnitString; legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE); - legendConfig->setColorRangeMode(RimRegularLegendConfig::STIMPLAN); + legendConfig->setColorRange(RimRegularLegendConfig::STIMPLAN); m_legendConfigurations.push_back(legendConfig); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 1855876272..3b97e9d3a5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -24,6 +24,7 @@ #include "RifReaderEclipseSummary.h" #include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimSummaryAddress.h" @@ -126,6 +127,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); m_legendConfig = new RimRegularLegendConfig(); + m_legendConfig->setColorRange( RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE ); CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensemble Curve Set"), "Curve Set Name", "", "", ""); @@ -186,7 +188,6 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText()); m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address(); - m_legendConfig->initForEnsembleCurveSet(this); updateAllCurves(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index f3458f4d04..ac4a3c25f5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -140,15 +140,13 @@ RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve( //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet) { - static int nextAutoColorIndex = 1; - static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size(); if (curveSet) { - curveSet->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor(nextAutoColorIndex)); + m_curveSets.push_back(curveSet); - nextAutoColorIndex = (++nextAutoColorIndex) % numberOfColors; + } } @@ -193,6 +191,14 @@ std::vector RimEnsembleCurveSetCollection::visibleCurveSet return visible; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimEnsembleCurveSetCollection::curveSetCount() const +{ + return m_curveSets.size(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 2eb506aa84..6f80d235dc 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -52,6 +52,7 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject std::vector curveSets() const; std::vector visibleCurveSets() const; + size_t curveSetCount() const; void deleteAllCurveSets(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp index cfeae62e06..8866abddc7 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -22,7 +22,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::map RimEnsembleCurveSetColorManager::ENSEMBLE_COLOR_RANGES( +const std::map RimEnsembleCurveSetColorManager::EnsembleColorRanges( { { RimRegularLegendConfig::GREEN_RED, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0xff, 0x00), cvf::Color3ub(0xff, 0x00, 0x00) }) }, { RimRegularLegendConfig::BLUE_MAGENTA, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0x00, 0xff), cvf::Color3ub(0xff, 0x00, 0xff) }) }, @@ -39,49 +39,14 @@ const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::D //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::nextColorRange(RimEnsembleCurveSet* curveSet) +RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(int index) { - CVF_ASSERT(curveSet); + size_t modIndex = index % EnsembleColorRanges.size(); - RimEnsembleCurveSetCollection* coll; - curveSet->firstAncestorOrThisOfType(coll); + auto crIt = EnsembleColorRanges.begin(); + for (int i = 0; i < modIndex; ++i) ++crIt; - if (coll) - { - if (m_colorCache.find(coll) != m_colorCache.end()) - { - if (m_colorCache[coll].find(curveSet) != m_colorCache[coll].end()) - { - // CurveSet found in cache, use same color range as last time - return m_colorCache[coll][curveSet]; - } - } - else - { - m_colorCache.insert(std::make_pair(coll, std::map())); - m_nextColorIndexes.insert(std::make_pair(coll, 0)); - } - - int currColorIndex = m_nextColorIndexes[coll]; - RimRegularLegendConfig::ColorRangesType resultColorRange = colorRangeByIndex(currColorIndex); - m_nextColorIndexes[coll] = (currColorIndex < (int)ENSEMBLE_COLOR_RANGES.size() - 1) ? currColorIndex + 1 : 0; - m_colorCache[coll][curveSet] = resultColorRange; - return resultColorRange; - } - return DEFAULT_ENSEMBLE_COLOR_RANGE; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::colorRangeByIndex(int index) -{ - int i = 0; - for (auto item : ENSEMBLE_COLOR_RANGES) - { - if (i++ == index) return item.first; - } - return DEFAULT_ENSEMBLE_COLOR_RANGE; + return crIt->first; } std::map RimEnsembleCurveSetColorManager::m_nextColorIndexes; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h index 0149ff0de2..e3ff7e3768 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h @@ -35,19 +35,19 @@ class RimEnsembleCurveSetCollection; class RimEnsembleCurveSetColorManager { public: - static const std::map ENSEMBLE_COLOR_RANGES; + static const std::map EnsembleColorRanges; static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE; + static RimRegularLegendConfig::ColorRangesType cycledEnsembleColorRange(int index); static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange) { - return ENSEMBLE_COLOR_RANGES.find(colorRange) != ENSEMBLE_COLOR_RANGES.end(); + return EnsembleColorRanges.find(colorRange) != EnsembleColorRanges.end(); } static RimRegularLegendConfig::ColorRangesType nextColorRange(RimEnsembleCurveSet* curveSet); private: - static RimRegularLegendConfig::ColorRangesType colorRangeByIndex(int index); static std::map m_nextColorIndexes; static std::map> m_colorCache; From 368cca8b8d626bc57902c5f3a6f710b797bd9f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 08:32:44 +0200 Subject: [PATCH 0933/1027] #2886 Summary groups. Add convert group to ensemble command --- .../Commands/CMakeLists_files.cmake | 2 + .../RicConvertGroupToEnsembleFeature.cpp | 91 +++++++++++++++ .../RicConvertGroupToEnsembleFeature.h | 45 ++++++++ .../Commands/RicImportEnsembleFeature.cpp | 109 +++++++++--------- .../Commands/RicImportEnsembleFeature.h | 4 +- .../RimContextCommandBuilder.cpp | 4 + 6 files changed, 200 insertions(+), 55 deletions(-) create mode 100644 ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp create mode 100644 ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 9eb3be9209..ea1f4736cd 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -68,6 +68,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.h ) @@ -134,6 +135,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.cpp ) diff --git a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp new file mode 100644 index 0000000000..628f42bdd4 --- /dev/null +++ b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicConvertGroupToEnsembleFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportEnsembleFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include "cafSelectionManagerTools.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicConvertGroupToEnsembleFeature, "RicConvertGroupToEnsembleFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicConvertGroupToEnsembleFeature::isCommandEnabled() +{ + const auto& selGroups = caf::selectedObjectsByTypeStrict(); + if (selGroups.empty()) return false; + + for (const auto& group : selGroups) + { + if (!group->isEnsemble()) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicConvertGroupToEnsembleFeature::onActionTriggered(bool isChecked) +{ + const auto& selGroups = caf::selectedObjectsByTypeStrict(); + + for (const auto& group : selGroups) + { + if (group->isEnsemble()) continue; + + RicImportEnsembleFeature::validateEnsembleCases(group->allSummaryCases()); + group->setAsEnsemble(true); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicConvertGroupToEnsembleFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); + actionToSetup->setText("Convert to Ensemble"); +} diff --git a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h new file mode 100644 index 0000000000..f27f883ac0 --- /dev/null +++ b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicConvertGroupToEnsembleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index fac7fbe633..f07f96d69d 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -48,60 +48,6 @@ CAF_CMD_SOURCE_INIT(RicImportEnsembleFeature, "RicImportEnsembleFeature"); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportEnsembleFeature::isCommandEnabled() -{ - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportEnsembleFeature::onActionTriggered(bool isChecked) -{ - RiaApplication* app = RiaApplication::instance(); - QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble"); - - if (fileNames.isEmpty()) return; - - QString ensembleName = askForEnsembleName(); - if (ensembleName.isEmpty()) return; - - std::vector cases; - RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); - - validateEnsembleCases(cases); - - RicImportSummaryCasesFeature::addSummaryCases(cases); - RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName, true); - - RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow && !cases.empty()) - { - mainPlotWindow->selectAsCurrentItem(cases.back()); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - - std::vector allCases; - app->project()->allCases(allCases); - - if (allCases.size() == 0) - { - RiuMainWindow::instance()->close(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicImportEnsembleFeature::setupActionLook(QAction* actionToSetup) -{ - actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); - actionToSetup->setText("Import Ensemble"); -} //-------------------------------------------------------------------------------------------------- /// @@ -157,6 +103,61 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vector cases; + RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); + + validateEnsembleCases(cases); + + RicImportSummaryCasesFeature::addSummaryCases(cases); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName, true); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEnsembleFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); + actionToSetup->setText("Import Ensemble"); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.h b/ApplicationCode/Commands/RicImportEnsembleFeature.h index 197fc57b9a..62a7a80366 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.h +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.h @@ -35,13 +35,15 @@ class RicImportEnsembleFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static bool validateEnsembleCases(std::vector cases); + protected: // Overrides virtual bool isCommandEnabled() override; virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook( QAction* actionToSetup ) override; - bool validateEnsembleCases(std::vector cases); QString askForEnsembleName(); }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 8e7c11155e..f3297af89e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -495,6 +495,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder.addSeparator(); + menuBuilder << "RicConvertGroupToEnsembleFeature"; + menuBuilder.addSeparator(); } else if (dynamic_cast(uiItem)) { @@ -673,6 +675,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder << "RicSummaryCurveSwitchAxisFeature"; menuBuilder.addSeparator(); + menuBuilder << "RicConvertGroupToEnsembleFeature"; + menuBuilder.addSeparator(); if (!menuBuilder.isCmdFeatureAdded("RicNewFishbonesSubsFeature")) { From 1a725de91b26e24be13db48e8d078853fd6fccd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 08:35:56 +0200 Subject: [PATCH 0934/1027] Fix build error --- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 5c85ead3bf..17c7954952 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -67,7 +67,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) { RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - size_t colorIndex = plot->ensembleCurveSets()->curveSetCount(); + size_t colorIndex = plot->ensembleCurveSetCollection()->curveSetCount(); curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); curveSet->legendConfig()->setColorRange(RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(static_cast(colorIndex))); From 3ad7c1104062cf3b3d69510e0ace38a50fec5d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 09:08:14 +0200 Subject: [PATCH 0935/1027] #2894 Summary cases. Select case after import from recent file menu --- ApplicationCode/Application/RiaApplication.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 83ed4cddc4..ce383b15fe 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1914,8 +1914,15 @@ bool RiaApplication::openFile(const QString& fileName) { getOrCreateAndShowMainPlotWindow(); - std::vector cases; - m_project->allCases(cases); + const auto& cases = m_project->allSummaryCases(); + + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } if (cases.size() == 0) { From d1e55c64d3a8e1a36e5954a449efb176a474d57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 09:12:04 +0200 Subject: [PATCH 0936/1027] #2895 Fix crash due to hidden plot. --- ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 9e6df6c007..11df480f36 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -81,8 +81,7 @@ class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider // Lookup RimSummaryCurve from QwtPlotCurve for (auto const plot : project->mainPlotCollection->summaryPlotCollection()->summaryPlots()) { - RimSummaryPlot* sumPlot = plot->qwtPlot()->ownerPlotDefinition(); - for (auto const curveSet : sumPlot->ensembleCurveSetCollection()->curveSets()) + for (auto const curveSet : plot->ensembleCurveSetCollection()->curveSets()) { for (auto const currSumCurve : curveSet->curves()) { From ca30c58a772c60662c1ae7add479c1d31aee8ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 09:24:42 +0200 Subject: [PATCH 0937/1027] Cleanup in EnsembleColormanager --- .../ProjectDataModel/RimRegularLegendConfig.cpp | 4 ++-- .../Summary/RimEnsembleCurveSetColorManager.cpp | 14 +++++++++++--- .../Summary/RimEnsembleCurveSetColorManager.h | 8 ++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 0513d231d6..f07d096d52 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -795,7 +795,7 @@ cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesTy return RiaColorTables::stimPlanPaletteColors().color3ubArray(); break; default: - if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges.at(colorType); + if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges().at(colorType); break; } @@ -897,7 +897,7 @@ QList RimRegularLegendConfig::calculateValueOptions(cons } else { - for (const auto& col : ColorManager::EnsembleColorRanges) + for (const auto& col : ColorManager::EnsembleColorRanges()) { rangeTypes.push_back(col.first); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp index 8866abddc7..e705cf953f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -22,7 +22,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::map RimEnsembleCurveSetColorManager::EnsembleColorRanges( +const std::map RimEnsembleCurveSetColorManager::m_ensembleColorRanges( { { RimRegularLegendConfig::GREEN_RED, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0xff, 0x00), cvf::Color3ub(0xff, 0x00, 0x00) }) }, { RimRegularLegendConfig::BLUE_MAGENTA, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0x00, 0xff), cvf::Color3ub(0xff, 0x00, 0xff) }) }, @@ -31,6 +31,14 @@ const std::map RimE { RimRegularLegendConfig::BLUE_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xcc, 0xff), cvf::Color3ub(0x00, 0x00, 0x99) }) } }); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map& RimEnsembleCurveSetColorManager::EnsembleColorRanges() +{ + return m_ensembleColorRanges; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -41,9 +49,9 @@ const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::D //-------------------------------------------------------------------------------------------------- RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(int index) { - size_t modIndex = index % EnsembleColorRanges.size(); + size_t modIndex = index % m_ensembleColorRanges.size(); - auto crIt = EnsembleColorRanges.begin(); + auto crIt = m_ensembleColorRanges.begin(); for (int i = 0; i < modIndex; ++i) ++crIt; return crIt->first; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h index e3ff7e3768..ca03e688c3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h @@ -35,20 +35,20 @@ class RimEnsembleCurveSetCollection; class RimEnsembleCurveSetColorManager { public: - static const std::map EnsembleColorRanges; + static const std::map& EnsembleColorRanges(); static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE; static RimRegularLegendConfig::ColorRangesType cycledEnsembleColorRange(int index); static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange) { - return EnsembleColorRanges.find(colorRange) != EnsembleColorRanges.end(); + return m_ensembleColorRanges.find(colorRange) != m_ensembleColorRanges.end(); } - static RimRegularLegendConfig::ColorRangesType nextColorRange(RimEnsembleCurveSet* curveSet); - private: + static const std::map m_ensembleColorRanges; + static std::map m_nextColorIndexes; static std::map> m_colorCache; }; From 4e9dfafe027f536f13fb44dc2e3b61f30d55ba92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 09:52:46 +0200 Subject: [PATCH 0938/1027] #2894 Summary cases. Moved code to more appropriate location --- .../Application/RiaApplication.cpp | 15 --------------- .../Commands/RicImportSummaryCaseFeature.cpp | 15 --------------- .../Commands/RicImportSummaryCasesFeature.cpp | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index ce383b15fe..6021ba10b8 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1914,21 +1914,6 @@ bool RiaApplication::openFile(const QString& fileName) { getOrCreateAndShowMainPlotWindow(); - const auto& cases = m_project->allSummaryCases(); - - RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow && !cases.empty()) - { - mainPlotWindow->selectAsCurrentItem(cases.back()); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - - if (cases.size() == 0) - { - RiuMainWindow::instance()->close(); - } - m_project->updateConnectedEditors(); } } diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 036c24f745..b7384398d2 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -81,21 +81,6 @@ void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) { RiaApplication::instance()->addToRecentFiles(newCase->summaryHeaderFilename()); } - - RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow && !newCases.empty()) - { - mainPlotWindow->selectAsCurrentItem(newCases.back()); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - } - - std::vector cases; - app->project()->allCases(cases); - if (cases.size() == 0 && !newCases.empty()) - { - RiuMainWindow::instance()->close(); } } diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index b1d9765424..82f162376c 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -112,13 +112,32 @@ void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) { + RiaApplication* app = RiaApplication::instance(); + std::vector temp; std::vector* cases = newCases ? newCases : &temp; if (createSummaryCasesFromFiles(fileNames, cases)) { addSummaryCases(*cases); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases->empty()) + { + mainPlotWindow->selectAsCurrentItem(cases->back()); + mainPlotWindow->updateSummaryPlotToolBar(); + + // Close main window if there are no eclipse cases imported + std::vector cases; + app->project()->allCases(cases); + + if (cases.size() == 0) + { + RiuMainWindow::instance()->close(); + } + } return true; } + return false; } From 1b2f287579347aebe14031bb9894254188a81be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 10:08:06 +0200 Subject: [PATCH 0939/1027] Update UML diagram for curve creator --- doc/curve_creator.plantuml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/curve_creator.plantuml b/doc/curve_creator.plantuml index 1727120710..4725b2f8e2 100644 --- a/doc/curve_creator.plantuml +++ b/doc/curve_creator.plantuml @@ -28,20 +28,16 @@ class RiuSummaryCurveDefSelection { ' ' Class Hierarchy ' -PdmUiWidgetBasedObjectEditor <|- RicSummaryCurveCreatorSplitterUi -PdmUiWidgetBasedObjectEditor <|- RicSummaryCurveCreatorTabsUi +PdmUiWidgetBasedObjectEditor <|-- RicSummaryCurveCreatorSplitterUi PdmUiWidgetBasedObjectEditor <|-- RiuSummaryCurveDefSelectionEditor ' ' Class references ' -RicSummaryCurveCreatorDialog --> RicSummaryCurveCreatorTabsUi +RicSummaryCurveCreatorDialog --> RicSummaryCurveCreatorSplitterUi RicSummaryCurveCreatorSplitterUi ->RicSummaryCurveCreator -RicSummaryCurveCreatorTabsUi -> RicSummaryCurveCreatorSplitterUi : curves -RicSummaryCurveCreatorTabsUi -> RicSummaryCurveCreatorSplitterUi : ensambles - RicSummaryCurveCreator --> RiuSummaryCurveDefSelectionEditor RicSummaryCurveCreator --> RimSummaryPlot : Target plot From 0d233e256881a09998742f58ae7615725a0906bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 10:34:09 +0200 Subject: [PATCH 0940/1027] #2895 Fix performance related to case name in plot tracking text --- .../ProjectDataModel/RimPlotCurve.cpp | 4 +- .../UserInterface/CMakeLists_files.cmake | 2 + .../UserInterface/RiuRimQwtPlotCurve.cpp | 38 +++++++++++++++++++ .../UserInterface/RiuRimQwtPlotCurve.h | 36 ++++++++++++++++++ .../UserInterface/RiuSummaryQwtPlot.cpp | 20 +++------- 5 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp create mode 100644 ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 833c8820f3..15aedc2069 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -25,7 +25,7 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" -#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuRimQwtPlotCurve.h" #include "cafPdmUiComboBoxEditor.h" @@ -110,7 +110,7 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", ""); - m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; + m_qwtPlotCurve = new RiuRimQwtPlotCurve(this); m_parentQwtPlot = nullptr; } diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 0702225453..29557d6499 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h @@ -80,6 +81,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp new file mode 100644 index 0000000000..56914e98d7 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuRimQwtPlotCurve.h" +#include "RimPlotCurve.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuRimQwtPlotCurve::RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title /*= QString::null*/) + : RiuLineSegmentQwtPlotCurve(title) + , m_ownerRimCurve(ownerRimCurve) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotCurve * RiuRimQwtPlotCurve::ownerRimCurve() +{ + return m_ownerRimCurve; +} diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h new file mode 100644 index 0000000000..a8cebb632a --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiuLineSegmentQwtPlotCurve.h" + +#include "cafPdmPointer.h" + +class RimPlotCurve; + +class RiuRimQwtPlotCurve: public RiuLineSegmentQwtPlotCurve +{ +public: + explicit RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title = QString::null); + + RimPlotCurve * ownerRimCurve(); + +private: + caf::PdmPointer m_ownerRimCurve; +}; + diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 11df480f36..f9f3ccb412 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -60,6 +60,8 @@ #include "RimMainPlotCollection.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryCase.h" +#include "RiuRimQwtPlotCurve.h" +#include "RimSummaryCurve.h" #include @@ -75,23 +77,11 @@ class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider //-------------------------------------------------------------------------------------------------- virtual QString curveInfoText(QwtPlotCurve* curve) override { - RimProject* project = RiaApplication::instance()->project(); + RiuRimQwtPlotCurve* riuCurve = dynamic_cast(curve); RimSummaryCurve* sumCurve = nullptr; - - // Lookup RimSummaryCurve from QwtPlotCurve - for (auto const plot : project->mainPlotCollection->summaryPlotCollection()->summaryPlots()) + if (riuCurve) { - for (auto const curveSet : plot->ensembleCurveSetCollection()->curveSets()) - { - for (auto const currSumCurve : curveSet->curves()) - { - if (currSumCurve->qwtPlotCurve() == curve) - { - sumCurve = currSumCurve; - break; - } - } - } + sumCurve = dynamic_cast(riuCurve->ownerRimCurve()); } return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->caseName() : ""; From 9b16d55ddfaeb1cb0f29424881a9078e70c25474 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 12:26:33 +0200 Subject: [PATCH 0941/1027] #2892 RimSummaryCaseCollection : Hide display text field --- .../ProjectDataModel/Summary/RimSummaryCaseCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 027964f571..e3f3ecf267 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -41,7 +41,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() CAF_PDM_InitFieldNoDefault(&m_nameAndItemCount, "NameCount", "Name", "", "", ""); m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount); - m_nameAndItemCount.uiCapability()->setUiReadOnly(true); + m_nameAndItemCount.uiCapability()->setUiHidden(true); m_nameAndItemCount.xmlCapability()->setIOWritable(false); CAF_PDM_InitField(&m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", ""); From fcea3ec40ff4e1d98f5b626deec60f14ea11021a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 11:46:50 +0200 Subject: [PATCH 0942/1027] #2658 Curve creator. Update curve tree view to display ensembles as well --- .../RicSummaryCurveCreator.cpp | 5 +++ .../RicSummaryCurveCreator.h | 3 ++ .../RicSummaryCurveCreatorSplitterUi.cpp | 8 +++- .../Summary/RimSummaryPlot.cpp | 41 ++++++++++++------- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index c7b3c09b8a..cf892ba100 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -59,6 +59,11 @@ CAF_PDM_SOURCE_INIT(RicSummaryCurveCreator, "RicSummaryCurveCreator"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RicSummaryCurveCreator::CONFIGURATION_NAME = "CurveCreatorCfg"; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index d80b37e1be..864bb64f63 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -51,6 +51,9 @@ class RicSummaryCurveCreator : public caf::PdmObject { CAF_PDM_HEADER_INIT; +public: + static const QString CONFIGURATION_NAME; + private: typedef caf::AppEnum AppearanceTypeAppEnum; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp index 84401ca1e0..2f63189fd9 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp @@ -19,6 +19,7 @@ #include "RicSummaryCurveCreatorSplitterUi.h" #include "RicSummaryCurveCreator.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" @@ -194,8 +195,11 @@ QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreateCurveTreeWidget() if (m_summaryCurveCreator) { - RimSummaryCurveCollection* sumColl = m_summaryCurveCreator->previewPlot()->summaryCurveCollection(); - m_curveTreeView->setPdmItem(sumColl); + RimSummaryPlot* previewPlot = m_summaryCurveCreator->previewPlot(); + m_curveTreeView->setPdmItem(previewPlot); + m_curveTreeView->setUiConfigurationName(RicSummaryCurveCreator::CONFIGURATION_NAME); + m_curveTreeView->setExpanded(previewPlot->summaryCurveCollection(), true); + m_curveTreeView->setExpanded(previewPlot->ensembleCurveSetCollection(), true); } return m_curvesPanel; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index ae9f0d4bfd..3f46ecfae3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -21,6 +21,8 @@ #include "RiaApplication.h" #include "RiaSummaryCurveAnalyzer.h" +#include "SummaryPlotCommands/RicSummaryCurveCreator.h" + #include "RimAsciiDataCurve.h" #include "RimEnsembleCurveSet.h" #include "RimGridTimeHistoryCurve.h" @@ -1186,26 +1188,37 @@ QImage RimSummaryPlot::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { - caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add("Axes", ":/Axes16x16.png"); - - if (m_isCrossPlot) + if (uiConfigName == RicSummaryCurveCreator::CONFIGURATION_NAME) { - axisFolder->add(&m_bottomAxisProperties); + uiTreeOrdering.add(&m_summaryCurveCollection); + if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) + { + uiTreeOrdering.add(&m_ensembleCurveSetCollection); + } } else { - axisFolder->add(&m_timeAxisProperties); - } - axisFolder->add(&m_leftYAxisProperties); - axisFolder->add(&m_rightYAxisProperties); + caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add("Axes", ":/Axes16x16.png"); - uiTreeOrdering.add(&m_summaryCurveCollection); - if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) - { - uiTreeOrdering.add(&m_ensembleCurveSetCollection); + if (m_isCrossPlot) + { + axisFolder->add(&m_bottomAxisProperties); + } + else + { + axisFolder->add(&m_timeAxisProperties); + } + axisFolder->add(&m_leftYAxisProperties); + axisFolder->add(&m_rightYAxisProperties); + + uiTreeOrdering.add(&m_summaryCurveCollection); + if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) + { + uiTreeOrdering.add(&m_ensembleCurveSetCollection); + } + uiTreeOrdering.add(&m_gridTimeHistoryCurves); + uiTreeOrdering.add(&m_asciiDataCurves); } - uiTreeOrdering.add(&m_gridTimeHistoryCurves); - uiTreeOrdering.add(&m_asciiDataCurves); uiTreeOrdering.skipRemainingChildren(true); } From a203452ebfc5b56ad7f82ee35204e426c47bacd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 12:34:54 +0200 Subject: [PATCH 0943/1027] #2900 Plot editor. Fix missing vectors bug --- .../UserInterface/RiuSummaryCurveDefSelection.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index d7c7e852ce..346d318386 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -740,7 +740,7 @@ void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::Pd summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK][1]->pdmField(); } else if (sumCategory == RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR) - { + { { caf::PdmUiGroup* myGroup = uiOrdering.addNewGroup("LGR Blocks"); myGroup->add(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][0]->pdmField()); @@ -776,9 +776,17 @@ std::set RiuSummaryCurveDefSelection::findPossibleSumm for (const auto& source : m_selectedSources()) { RimSummaryCase* sumCase = dynamic_cast(source.p()); + RimSummaryCaseCollection* ensemble = dynamic_cast(source.p()); - if(!sumCase || isObservedData(sumCase)) continue; - cases.push_back(sumCase); + if (sumCase) + { + if(!isObservedData(sumCase)) cases.push_back(sumCase); + } + else if (ensemble) + { + const auto& ensembleCases = ensemble->allSummaryCases(); + cases.insert(cases.end(), ensembleCases.begin(), ensembleCases.end()); + } } return findPossibleSummaryAddresses(cases, identifierAndField); } From ff9fbe95b85115e6f31df0b7faaa729482eca308 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 12:46:26 +0200 Subject: [PATCH 0944/1027] #2893 RimSummaryCaseCollection : Use basic name without count as edit name Use proxy field with item count when we have a solution for one display field handle and one edit field handle --- .../ProjectDataModel/Summary/RimSummaryCaseCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index e3f3ecf267..1f3d8d8229 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -121,7 +121,7 @@ void RimSummaryCaseCollection::setAsEnsemble(bool isEnsemble) //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() { - return &m_nameAndItemCount; + return &m_name; } //-------------------------------------------------------------------------------------------------- From 450d1177f6cf5326bea06ba998c6b4129c96a95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 13:24:46 +0200 Subject: [PATCH 0945/1027] #2898 Ensemble curves. Add vector selection button and dialog --- .../Summary/RimEnsembleCurveSet.cpp | 35 ++++++- .../Summary/RimSummaryCurve.cpp | 2 + .../RiuSummaryCurveDefSelection.cpp | 93 ++++++++++++------- .../RiuSummaryCurveDefSelection.h | 5 + .../RiuSummaryCurveDefSelectionDialog.cpp | 43 ++++++++- .../RiuSummaryCurveDefSelectionDialog.h | 4 + 6 files changed, 144 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 3b97e9d3a5..4289d715d7 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -35,7 +35,9 @@ #include "RimSummaryFilter.h" #include "RimSummaryPlot.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryQwtPlot.h" +#include "RiuSummaryCurveDefSelectionDialog.h" #include "cafPdmUiTreeOrdering.h" #include "cafPdmUiListEditor.h" @@ -112,8 +114,6 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault(&m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", ""); caf::PdmUiPushButtonEditor::configureEditorForField(&m_yPushButtonSelectSummaryAddress); m_yPushButtonSelectSummaryAddress = false; - m_yPushButtonSelectSummaryAddress.uiCapability()->setUiReadOnly(true); - m_yPushButtonSelectSummaryAddress.uiCapability()->setUiHidden(true); m_yValuesCurveVariable = new RimSummaryAddress; @@ -418,6 +418,37 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { m_userDefinedName = createAutoName(); } + else if (changedField == &m_yPushButtonSelectSummaryAddress) + { + RiuSummaryCurveDefSelectionDialog dlg(nullptr); + RimSummaryCaseCollection* candidateEnsemble = m_yValuesSummaryGroup(); + RifEclipseSummaryAddress candicateAddress = m_yValuesCurveVariable->address(); + + dlg.hideSummaryCases(); + dlg.setEnsembleAndAddress(candidateEnsemble, candicateAddress); + + if (dlg.exec() == QDialog::Accepted) + { + auto curveSelection = dlg.curveSelection(); + if (curveSelection.size() > 0) + { + m_yValuesSummaryGroup = curveSelection[0].ensemble(); + m_yValuesCurveVariable->setAddress(curveSelection[0].summaryAddress()); + + this->loadDataAndUpdate(true); + + plot->updateAxes(); + plot->updatePlotTitle(); + plot->updateConnectedEditors(); + + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateSummaryPlotToolBar(); + } + } + + m_yPushButtonSelectSummaryAddress = false; + } + if (changedField == &m_isUsingAutoName || changedField == &m_userDefinedName || diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index ba698dda55..b96cf025b8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -697,6 +697,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, candicateAddress = m_xValuesCurveVariable->address(); } + dlg.hideEnsembles(); dlg.setCaseAndAddress(candidateCase, candicateAddress); if (dlg.exec() == QDialog::Accepted) @@ -730,6 +731,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, candicateAddress = m_yValuesCurveVariable->address(); } + dlg.hideEnsembles(); dlg.setCaseAndAddress(candidateCase, candicateAddress); if (dlg.exec() == QDialog::Accepted) diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 346d318386..a88eacc11d 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -228,6 +228,8 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM m_currentSummaryCategory.uiCapability()->setUiHidden(true); m_multiSelectionMode = false; + m_hideEnsembles = false; + m_hideSummaryCases = false; } //-------------------------------------------------------------------------------------------------- @@ -308,6 +310,22 @@ void RiuSummaryCurveDefSelection::setMultiSelectionMode(bool multiSelectionMode) m_multiSelectionMode = multiSelectionMode; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::hideEnsembles(bool hide) +{ + m_hideEnsembles = hide; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::hideSummaryCases(bool hide) +{ + m_hideSummaryCases = hide; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -458,55 +476,64 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); if (sumCaseMainColl) { - // Top level cases - for (const auto& sumCase : sumCaseMainColl->topLevelSummaryCases()) + if (!m_hideSummaryCases) { - options.push_back(caf::PdmOptionItemInfo(sumCase->caseName(), sumCase)); - } - - // Ensembles - bool ensembleHeaderCreated = false; - for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) - { - if (!sumCaseColl->isEnsemble()) continue; - - if (!ensembleHeaderCreated) + // Top level cases + for (const auto& sumCase : sumCaseMainColl->topLevelSummaryCases()) { - options.push_back(caf::PdmOptionItemInfo::createHeader("Ensembles", true)); - ensembleHeaderCreated = true; + options.push_back(caf::PdmOptionItemInfo(sumCase->caseName(), sumCase)); } - - auto optionItem = caf::PdmOptionItemInfo(sumCaseColl->name(), sumCaseColl); - optionItem.setLevel(1); - options.push_back(optionItem); } - // Grouped cases - for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + // Ensembles + if (!m_hideEnsembles) { - if (sumCaseColl->isEnsemble()) continue; + bool ensembleHeaderCreated = false; + for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + { + if (!sumCaseColl->isEnsemble()) continue; - options.push_back(caf::PdmOptionItemInfo::createHeader(sumCaseColl->name(), true)); + if (!ensembleHeaderCreated) + { + options.push_back(caf::PdmOptionItemInfo::createHeader("Ensembles", true)); + ensembleHeaderCreated = true; + } - for (const auto& sumCase : sumCaseColl->allSummaryCases()) - { - auto optionItem = caf::PdmOptionItemInfo(sumCase->caseName(), sumCase); + auto optionItem = caf::PdmOptionItemInfo(sumCaseColl->name(), sumCaseColl); optionItem.setLevel(1); options.push_back(optionItem); } } - // Observed data - auto observedDataColl = oilField->observedDataCollection(); - if (observedDataColl->allObservedData().size() > 0) + if (!m_hideSummaryCases) { - options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Data", true)); + // Grouped cases + for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + { + if (sumCaseColl->isEnsemble()) continue; - for (const auto& obsData : observedDataColl->allObservedData()) + options.push_back(caf::PdmOptionItemInfo::createHeader(sumCaseColl->name(), true)); + + for (const auto& sumCase : sumCaseColl->allSummaryCases()) + { + auto optionItem = caf::PdmOptionItemInfo(sumCase->caseName(), sumCase); + optionItem.setLevel(1); + options.push_back(optionItem); + } + } + + // Observed data + auto observedDataColl = oilField->observedDataCollection(); + if (observedDataColl->allObservedData().size() > 0) { - auto optionItem = caf::PdmOptionItemInfo(obsData->caseName(), obsData); - optionItem.setLevel(1); - options.push_back(optionItem); + options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Data", true)); + + for (const auto& obsData : observedDataColl->allObservedData()) + { + auto optionItem = caf::PdmOptionItemInfo(obsData->caseName(), obsData); + optionItem.setLevel(1); + options.push_back(optionItem); + } } } } diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index d0b0df5783..5c17420571 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -58,6 +58,8 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject void setSelectedCurveDefinitions(const std::vector& curveDefinitions); std::vector selectedCurveDefinitions() const; void setMultiSelectionMode(bool multiSelectionMode); + void hideEnsembles(bool hide); + void hideSummaryCases(bool hide); void setFieldChangedHandler(const std::function& handlerFunc); void setDefaultSelection(const std::vector& defaultCases); @@ -105,6 +107,9 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject std::map> m_identifierFieldsMap; bool m_multiSelectionMode; + + bool m_hideEnsembles; + bool m_hideSummaryCases; std::function m_toggleChangedHandler; }; diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp index 31abcd6971..3ba3327b16 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp @@ -20,6 +20,8 @@ #include "RiaSummaryCurveDefinition.h" +#include "RimSummaryCaseCollection.h" + #include "RiuSummaryCurveDefSelection.h" #include "RiuSummaryCurveDefSelectionEditor.h" #include "RiuTools.h" @@ -77,9 +79,28 @@ void RiuSummaryCurveDefSelectionDialog::setCaseAndAddress(RimSummaryCase* summar { if (summaryCase) { - std::vector sumCasePairs; - sumCasePairs.push_back(RiaSummaryCurveDefinition(summaryCase, address)); - summaryAddressSelection()->setSelectedCurveDefinitions(sumCasePairs); + std::vector curveDefs; + curveDefs.push_back(RiaSummaryCurveDefinition(summaryCase, address)); + summaryAddressSelection()->setSelectedCurveDefinitions(curveDefs); + } + + summaryAddressSelection()->updateConnectedEditors(); + updateLabel(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::setEnsembleAndAddress(RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address) +{ + if (ensemble) + { + std::vector curveDefs; + for (const auto& summaryCase : ensemble->allSummaryCases()) + { + curveDefs.push_back(RiaSummaryCurveDefinition(summaryCase, address, ensemble)); + } + summaryAddressSelection()->setSelectedCurveDefinitions(curveDefs); } summaryAddressSelection()->updateConnectedEditors(); @@ -94,6 +115,22 @@ std::vector RiuSummaryCurveDefSelectionDialog::curveS return summaryAddressSelection()->selectedCurveDefinitions(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::hideEnsembles() +{ + summaryAddressSelection()->hideEnsembles(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::hideSummaryCases() +{ + summaryAddressSelection()->hideSummaryCases(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h index c3cc896f32..f8784337fc 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h @@ -40,8 +40,12 @@ class RiuSummaryCurveDefSelectionDialog : public QDialog ~RiuSummaryCurveDefSelectionDialog(); void setCaseAndAddress(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address); + void setEnsembleAndAddress(RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address); std::vector curveSelection() const; + void hideEnsembles(); + void hideSummaryCases(); + private: RiuSummaryCurveDefSelection* summaryAddressSelection() const; void updateLabel(); From 9f1ea2c42abf6010ab4bb2c4673a7b82f6dca019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 13:46:42 +0200 Subject: [PATCH 0946/1027] Curve creator. Fix curve visibility settings --- .../Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index cf892ba100..a7b4800688 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -549,7 +549,7 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu std::set > sourceCurveDefs; for (const auto& curve : sourceSummaryPlot.summaryAndEnsembleCurves()) { - sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); + if(curve->isCurveVisible()) sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); } for (const auto& curve : m_previewPlot->summaryAndEnsembleCurves()) From f0be8214b090facb53bd2c85270993dbfed43416 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 11 May 2018 13:18:53 +0200 Subject: [PATCH 0947/1027] #2448 Summary plot: Retain auto zoom for axes you haven't modified the range for. --- .../Summary/RimSummaryAxisProperties.cpp | 21 +- .../Summary/RimSummaryAxisProperties.h | 3 + .../Summary/RimSummaryPlot.cpp | 229 ++++++++++-------- .../ProjectDataModel/Summary/RimSummaryPlot.h | 12 +- .../Summary/RimSummaryTimeAxisProperties.cpp | 23 +- .../Summary/RimSummaryTimeAxisProperties.h | 4 + 6 files changed, 174 insertions(+), 118 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index c9506375a0..82b66119b2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -83,6 +83,7 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() numberOfDecimals.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", ""); CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", ""); updateOptionSensitivity(); @@ -251,6 +252,22 @@ bool RimSummaryAxisProperties::showUnitText() const return m_displayUnitText(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::isAutoZoom() const +{ + return m_isAutoZoom(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAxisProperties::setAutoZoom(bool enableAutoZoom) +{ + m_isAutoZoom = enableAutoZoom; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -278,13 +295,13 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang { if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &visibleRangeMin) { if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } if (changedField == &isLogarithmicScaleEnabled) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h index 8b33b27e7b..2c56271a18 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h @@ -61,6 +61,8 @@ class RimSummaryAxisProperties : public caf::PdmObject bool showDescription() const; bool showAcronym() const; bool showUnitText() const; + bool isAutoZoom() const; + void setAutoZoom(bool enableAutoZoom); caf::PdmField customTitle; caf::PdmField titleFontSize; @@ -98,6 +100,7 @@ class RimSummaryAxisProperties : public caf::PdmObject caf::PdmField m_displayShortName; caf::PdmField m_displayLongName; caf::PdmField m_displayUnitText; + caf::PdmField m_isAutoZoom; caf::PdmField m_name; QwtPlot::Axis m_axis; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 3f46ecfae3..76199aacdc 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -120,9 +120,9 @@ RimSummaryPlot::RimSummaryPlot() m_timeAxisProperties.uiCapability()->setUiTreeHidden(true); m_timeAxisProperties = new RimSummaryTimeAxisProperties; - CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Auto Zoom", "", "", ""); - m_isAutoZoom.uiCapability()->setUiHidden(true); - + CAF_PDM_InitField(&m_isAutoZoom_OBSOLETE, "AutoZoom", true, "Auto Zoom", "", "", ""); + m_isAutoZoom_OBSOLETE.uiCapability()->setUiHidden(true); + m_isAutoZoom_OBSOLETE.xmlCapability()->setIOWritable(false); setAsPlotMdiWindow(); m_isCrossPlot = false; @@ -153,8 +153,6 @@ void RimSummaryPlot::updateAxes() updateAxis(RiaDefines::PLOT_AXIS_LEFT); updateAxis(RiaDefines::PLOT_AXIS_RIGHT); - updateZoomInQwt(); - if (m_isCrossPlot) { updateBottomXAxis(); @@ -163,6 +161,8 @@ void RimSummaryPlot::updateAxes() { updateTimeAxis(); } + + updateZoomInQwt(); } //-------------------------------------------------------------------------------------------------- @@ -619,43 +619,79 @@ void RimSummaryPlot::updateAxis(RiaDefines::PlotAxis plotAxis) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis) { - RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis); - - if (yAxisProps->isLogarithmicScaleEnabled) + if (plotAxis == RiaDefines::PLOT_AXIS_BOTTOM) { - std::vector yValues; - std::vector plotCurves; - - for (RimSummaryCurve* c : visibleSummaryCurvesForAxis(plotAxis)) + if (m_isCrossPlot) { - std::vector curveValues = c->valuesY(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); + if (m_bottomAxisProperties->isAutoZoom()) + { + m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); + } + else + { + m_qwtPlot->setAxisScale(QwtPlot::xBottom, m_bottomAxisProperties->visibleRangeMin(), m_bottomAxisProperties->visibleRangeMax()); + } } - - for (RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis(plotAxis)) + else { - std::vector curveValues = c->yValues(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); - } + if (m_timeAxisProperties->isAutoZoom()) + { + m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); + } + else + { + m_qwtPlot->setAxisScale(QwtPlot::xBottom, m_timeAxisProperties->visibleRangeMin(), m_timeAxisProperties->visibleRangeMax()); + } - for (RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis(plotAxis)) - { - std::vector curveValues = c->yValues(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); } - - double min, max; - RimSummaryPlotYAxisRangeCalculator calc(plotCurves, yValues); - calc.computeYRange(&min, &max); - - m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), min, max); } else { - m_qwtPlot->setAxisAutoScale(yAxisProps->qwtPlotAxisType(), true); + RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis); + + if (yAxisProps->isAutoZoom()) + { + if (yAxisProps->isLogarithmicScaleEnabled) + { + std::vector yValues; + std::vector plotCurves; + + for (RimSummaryCurve* c : visibleSummaryCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->valuesY(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + for (RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->yValues(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + for (RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->yValues(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + double min, max; + RimSummaryPlotYAxisRangeCalculator calc(plotCurves, yValues); + calc.computeYRange(&min, &max); + + m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), min, max); + } + else + { + m_qwtPlot->setAxisAutoScale(yAxisProps->qwtPlotAxisType(), true); + } + } + else + { + m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), yAxisProps->visibleRangeMin(), yAxisProps->visibleRangeMax()); + } } } @@ -895,53 +931,15 @@ void RimSummaryPlot::updateCaseNameHasChanged() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInterval& rightAxis, const QwtInterval& timeAxis) -{ - m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue(); - m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue(); - m_leftYAxisProperties->updateConnectedEditors(); - - m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue(); - m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue(); - m_rightYAxisProperties->updateConnectedEditors(); - - if (m_isCrossPlot) - { - m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue(); - m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue(); - m_bottomAxisProperties->updateConnectedEditors(); - } - else - { - m_timeAxisProperties->setVisibleRangeMin(timeAxis.minValue()); - m_timeAxisProperties->setVisibleRangeMax(timeAxis.maxValue()); - m_timeAxisProperties->updateConnectedEditors(); - } - - disableAutoZoom(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::zoomAll() { - if (m_qwtPlot) - { - m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); - - updateZoomForAxis(RiaDefines::PLOT_AXIS_LEFT); - updateZoomForAxis(RiaDefines::PLOT_AXIS_RIGHT); - - m_qwtPlot->replot(); - } - - updateZoomWindowFromQwt(); + setAutoZoomForAllAxes(true); + updateZoomInQwt(); + updateAxisRangesFromQwt(); - m_isAutoZoom = true; } //-------------------------------------------------------------------------------------------------- @@ -1260,63 +1258,75 @@ void RimSummaryPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateZoomInQwt() { - if (!m_qwtPlot) return; - - if (m_isAutoZoom) - { - zoomAll(); - } - else + if (m_qwtPlot) { - setZoomIntervalsInQwtPlot(); + + updateZoomForAxis(RiaDefines::PLOT_AXIS_BOTTOM); + updateZoomForAxis(RiaDefines::PLOT_AXIS_LEFT); + updateZoomForAxis(RiaDefines::PLOT_AXIS_RIGHT); + + m_qwtPlot->replot(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setZoomIntervalsInQwtPlot() +void RimSummaryPlot::updateZoomWindowFromQwt() { - QwtInterval left, right, time; + updateAxisRangesFromQwt(); + setAutoZoomForAllAxes(false); +} - left.setMinValue(m_leftYAxisProperties->visibleRangeMin()); - left.setMaxValue(m_leftYAxisProperties->visibleRangeMax()); - right.setMinValue(m_rightYAxisProperties->visibleRangeMin()); - right.setMaxValue(m_rightYAxisProperties->visibleRangeMax()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::updateAxisRangesFromQwt() +{ + if (!m_qwtPlot) return; + + QwtInterval leftAxis, rightAxis, timeAxis; + m_qwtPlot->currentVisibleWindow(&leftAxis, &rightAxis, &timeAxis); + + m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue(); + m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue(); + m_leftYAxisProperties->updateConnectedEditors(); + + m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue(); + m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue(); + m_rightYAxisProperties->updateConnectedEditors(); if (m_isCrossPlot) { - time.setMinValue(m_bottomAxisProperties->visibleRangeMin()); - time.setMaxValue(m_bottomAxisProperties->visibleRangeMax()); + m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue(); + m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue(); + m_bottomAxisProperties->updateConnectedEditors(); } else { - time.setMinValue(m_timeAxisProperties->visibleRangeMin()); - time.setMaxValue(m_timeAxisProperties->visibleRangeMax()); + m_timeAxisProperties->setVisibleRangeMin(timeAxis.minValue()); + m_timeAxisProperties->setVisibleRangeMax(timeAxis.maxValue()); + m_timeAxisProperties->updateConnectedEditors(); } - m_qwtPlot->setZoomWindow(left, right, time); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomWindowFromQwt() +void RimSummaryPlot::setAutoZoomForAllAxes(bool enableAutoZoom) { - if (!m_qwtPlot) return; + m_leftYAxisProperties->setAutoZoom(enableAutoZoom); + m_rightYAxisProperties->setAutoZoom(enableAutoZoom); - QwtInterval left, right, time; - m_qwtPlot->currentVisibleWindow(&left, &right, &time); - - setZoomWindow(left, right, time); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::disableAutoZoom() -{ - m_isAutoZoom = false; + if (m_isCrossPlot) + { + m_bottomAxisProperties->setAutoZoom(enableAutoZoom); + } + else + { + m_timeAxisProperties->setAutoZoom(enableAutoZoom); + } } //-------------------------------------------------------------------------------------------------- @@ -1458,6 +1468,11 @@ void RimSummaryPlot::initAfterRead() m_summaryCurveCollection->addCurve(curve); } + if (!m_isAutoZoom_OBSOLETE()) + { + setAutoZoomForAllAxes(false); + } + RimProject* proj = nullptr; this->firstAncestorOrThisOfType(proj); if (proj) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 226a830a7b..13bc433faa 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -89,13 +89,9 @@ class RimSummaryPlot : public RimViewWindow void updateAxes(); virtual void zoomAll() override; - void setZoomWindow(const QwtInterval& leftAxis, - const QwtInterval& rightAxis, - const QwtInterval& timeAxis); void updateZoomInQwt(); void updateZoomWindowFromQwt(); - void disableAutoZoom(); bool isLogarithmicScaleEnabled(RiaDefines::PlotAxis plotAxis) const; @@ -154,11 +150,14 @@ class RimSummaryPlot : public RimViewWindow RimSummaryAxisProperties* yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const; void updateAxis(RiaDefines::PlotAxis plotAxis); + void updateZoomForAxis(RiaDefines::PlotAxis plotAxis); void updateTimeAxis(); void updateBottomXAxis(); - void setZoomIntervalsInQwtPlot(); + + void updateAxisRangesFromQwt(); + void setAutoZoomForAllAxes(bool enableAutoZoom); private: caf::PdmField m_showPlotTitle; @@ -174,7 +173,6 @@ class RimSummaryPlot : public RimViewWindow caf::PdmChildArrayField m_asciiDataCurves; - caf::PdmField m_isAutoZoom; caf::PdmChildField m_leftYAxisProperties; caf::PdmChildField m_rightYAxisProperties; @@ -191,4 +189,6 @@ class RimSummaryPlot : public RimViewWindow // Obsolete fields caf::PdmChildArrayField m_summaryCurves_OBSOLETE; caf::PdmChildArrayField m_curveFilters_OBSOLETE; + caf::PdmField m_isAutoZoom_OBSOLETE; + }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp index 320cd2c864..c6af806b1a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp @@ -82,6 +82,7 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties() CAF_PDM_InitField(&titleFontSize, "FontSize", 11, "Font Size", "", "", ""); CAF_PDM_InitField(&valuesFontSize, "ValuesFontSize", 11, "Font Size", "", "", ""); + CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_timeMode, "TimeMode", "Time Mode", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_timeUnit, "TimeUnit", "Time Unit", "", "", ""); @@ -158,6 +159,22 @@ void RimSummaryTimeAxisProperties::setVisibleRangeMax(double value) auto s = m_visibleDateRangeMax().toString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryTimeAxisProperties::isAutoZoom() const +{ + return m_isAutoZoom; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryTimeAxisProperties::setAutoZoom(bool enableAutoZoom) +{ + m_isAutoZoom = enableAutoZoom; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -362,7 +379,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c } updateTimeVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_visibleDateRangeMin) { @@ -373,12 +390,12 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c } updateTimeVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_visibleTimeRangeMin || changedField == &m_visibleTimeRangeMax) { updateDateVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_timeMode) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h index b476775466..451236dca2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h @@ -78,6 +78,9 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject void setVisibleRangeMin(double value); void setVisibleRangeMax(double value); + bool isAutoZoom() const; + void setAutoZoom(bool enableAutoZoom); + bool isActive() const; protected: @@ -100,4 +103,5 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject caf::PdmField m_visibleDateRangeMax; caf::PdmField m_visibleTimeRangeMin; caf::PdmField m_visibleTimeRangeMax; + caf::PdmField m_isAutoZoom; }; From d37ed9bb7cbad48f228e38f6fcede52e65c7855c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 13:36:08 +0200 Subject: [PATCH 0948/1027] #2889 Fix crash when few tick marks in legend. Set legend title before adding to view to make size calculaltion correct first time. --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 4 ++-- Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp | 5 ----- Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp | 5 ----- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index d422703c6e..969156944b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1087,8 +1087,8 @@ void RimEclipseView::updateLegends() } } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); } else { @@ -1128,8 +1128,8 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) { - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->titledOverlayFrame()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->titledOverlayFrame()); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 8be6e9ee61..c1eb88ac3e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -485,11 +485,6 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) colorBarWidth, colorBarHeight); - if (layout->colorBarRect.width() < 1 || layout->colorBarRect.height() < 1) - { - return; - } - layout->tickStartX = layout->margins.x(); layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); layout->tickEndX = layout->tickMidX + 5; diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp index 738af2cf02..7cf1630953 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -632,11 +632,6 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) colorBarWidth, colorBarHeight); - if (layout->colorBarRect.width() < 1 || layout->colorBarRect.height() < 1) - { - return; - } - layout->tickStartX = layout->margins.x(); layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); layout->tickEndX = layout->tickMidX + 5; From 803da0668bcfa19d089770b1e58083148b238703 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 13:14:49 +0200 Subject: [PATCH 0949/1027] #2901 RFT Plot : Whitespace cleanup --- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 283 +++++++++--------- .../ProjectDataModel/Flow/RimWellRftPlot.h | 8 +- 2 files changed, 147 insertions(+), 144 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 5b92ca35f6..83901354eb 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -30,7 +30,6 @@ #include "RigSimWellData.h" #include "RigWellPath.h" -#include "RimWellPlotTools.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseResultCase.h" @@ -47,6 +46,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPlotTools.h" #include "RimWellPltPlot.h" #include "RiuWellRftPlot.h" @@ -61,12 +61,12 @@ CAF_PDM_SOURCE_INIT(RimWellRftPlot, "WellRftPlot"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1"; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellRftPlot::RimWellRftPlot() { @@ -84,8 +84,13 @@ RimWellRftPlot::RimWellRftPlot() CAF_PDM_InitFieldNoDefault(&m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", ""); CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", ""); - CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "", - "Compute branches based on how simulation well cells are organized", ""); + CAF_PDM_InitField(&m_branchDetection, + "BranchDetection", + true, + "Branch Detection", + "", + "Compute branches based on how simulation well cells are organized", + ""); CAF_PDM_InitFieldNoDefault(&m_selectedSources, "Sources", "Sources", "", "", ""); m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); @@ -101,7 +106,7 @@ RimWellRftPlot::RimWellRftPlot() this->setAsPlotMdiWindow(); m_selectedSourcesOrTimeStepsFieldsChanged = false; - m_isOnLoad = true; + m_isOnLoad = true; } //-------------------------------------------------------------------------------------------------- @@ -115,7 +120,7 @@ RimWellRftPlot::~RimWellRftPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::deleteViewWidget() { @@ -127,7 +132,7 @@ void RimWellRftPlot::deleteViewWidget() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) { @@ -136,25 +141,22 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) std::vector colorTable; RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable); - std::vector symbolTable = - { - RimPlotCurve::SYMBOL_ELLIPSE, - RimPlotCurve::SYMBOL_RECT, - RimPlotCurve::SYMBOL_DIAMOND, - RimPlotCurve::SYMBOL_TRIANGLE, - RimPlotCurve::SYMBOL_CROSS, - RimPlotCurve::SYMBOL_XCROSS - }; + std::vector symbolTable = {RimPlotCurve::SYMBOL_ELLIPSE, + RimPlotCurve::SYMBOL_RECT, + RimPlotCurve::SYMBOL_DIAMOND, + RimPlotCurve::SYMBOL_TRIANGLE, + RimPlotCurve::SYMBOL_CROSS, + RimPlotCurve::SYMBOL_XCROSS}; // State variables - static size_t defaultColorTableIndex = 0; - static size_t defaultSymbolTableIndex = 0; + static size_t defaultColorTableIndex = 0; + static size_t defaultSymbolTableIndex = 0; - cvf::Color3f currentColor; - RimPlotCurve::PointSymbolEnum currentSymbol = symbolTable.front(); - RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID; - bool isCurrentColorSet = false; - bool isCurrentSymbolSet = false; + cvf::Color3f currentColor; + RimPlotCurve::PointSymbolEnum currentSymbol = symbolTable.front(); + RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID; + bool isCurrentColorSet = false; + bool isCurrentSymbolSet = false; std::set assignedColors; std::set assignedSymbols; @@ -167,12 +169,12 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) RiaRftPltCurveDefinition cDef = RimWellPlotTools::curveDefFromCurve(curve); if (cDef.address() == newCurveDef.address()) { - currentColor = curve->color(); + currentColor = curve->color(); isCurrentColorSet = true; } if (cDef.timeStep() == newCurveDef.timeStep()) { - currentSymbol = curve->symbol(); + currentSymbol = curve->symbol(); isCurrentSymbolSet = true; } assignedColors.insert(curve->color()); @@ -182,11 +184,11 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) // Assign color if (!isCurrentColorSet) { - for(const auto& color : colorTable) + for (const auto& color : colorTable) { if (assignedColors.count(color) == 0) { - currentColor = color; + currentColor = color; isCurrentColorSet = true; break; } @@ -194,9 +196,7 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) if (!isCurrentColorSet) { currentColor = colorTable[defaultColorTableIndex]; - if (++defaultColorTableIndex == colorTable.size()) - defaultColorTableIndex = 0; - + if (++defaultColorTableIndex == colorTable.size()) defaultColorTableIndex = 0; } } @@ -207,7 +207,7 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) { if (assignedSymbols.count(symbol) == 0) { - currentSymbol = symbol; + currentSymbol = symbol; isCurrentSymbolSet = true; break; } @@ -215,29 +215,27 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) if (!isCurrentSymbolSet) { currentSymbol = symbolTable[defaultSymbolTableIndex]; - if (++defaultSymbolTableIndex == symbolTable.size()) - defaultSymbolTableIndex = 0; + if (++defaultSymbolTableIndex == symbolTable.size()) defaultSymbolTableIndex = 0; } } // Observed data - currentLineStyle = newCurveDef.address().sourceType() == RifDataSourceForRftPlt::OBSERVED - ? RimPlotCurve::STYLE_NONE : RimPlotCurve::STYLE_SOLID; + currentLineStyle = newCurveDef.address().sourceType() == RifDataSourceForRftPlt::OBSERVED ? RimPlotCurve::STYLE_NONE + : RimPlotCurve::STYLE_SOLID; newCurve->setColor(currentColor); newCurve->setSymbol(currentSymbol); newCurve->setLineStyle(currentLineStyle); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateFormationsOnPlot() const { if (m_wellLogPlot->trackCount() > 0) { - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = proj->wellPathByName(m_wellPathNameOrSimWellName); RimCase* formationNamesCase = m_wellLogPlot->trackByIndex(0)->formationNamesCase(); @@ -248,7 +246,7 @@ void RimWellRftPlot::updateFormationsOnPlot() const std::vector cases; proj->allCases(cases); - if ( !cases.empty() ) + if (!cases.empty()) { formationNamesCase = cases[0]; } @@ -260,13 +258,14 @@ void RimWellRftPlot::updateFormationsOnPlot() const } else { - m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData(formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection); + m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData( + formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection); } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::associatedSimWellName() const { @@ -279,25 +278,25 @@ QString RimWellRftPlot::associatedSimWellName() const void RimWellRftPlot::applyInitialSelections() { std::vector sourcesToSelect; - std::set rftTimeSteps; - std::set observedTimeSteps; - std::set gridTimeSteps; - const QString simWellName = associatedSimWellName(); + std::set rftTimeSteps; + std::set observedTimeSteps; + std::set gridTimeSteps; + const QString simWellName = associatedSimWellName(); - for(RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell(simWellName)) + for (RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase)); RimWellPlotTools::appendSet(rftTimeSteps, RimWellPlotTools::timeStepsFromRftCase(rftCase, simWellName)); } - + for (RimEclipseResultCase* const gridCase : RimWellPlotTools::gridCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase)); RimWellPlotTools::appendSet(gridTimeSteps, RimWellPlotTools::timeStepsFromGridCase(gridCase)); } - + std::vector wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName); - if(wellLogFiles.size() > 0) + if (wellLogFiles.size() > 0) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED)); for (RimWellLogFile* const wellLogFile : wellLogFiles) @@ -307,7 +306,7 @@ void RimWellRftPlot::applyInitialSelections() } m_selectedSources = sourcesToSelect; - + std::set timeStepsToSelect; for (const QDateTime& timeStep : rftTimeSteps) { @@ -317,8 +316,7 @@ void RimWellRftPlot::applyInitialSelections() { timeStepsToSelect.insert(timeStep); } - if (gridTimeSteps.size() > 0) - timeStepsToSelect.insert(*gridTimeSteps.begin()); + if (gridTimeSteps.size() > 0) timeStepsToSelect.insert(*gridTimeSteps.begin()); m_selectedTimeSteps = std::vector(timeStepsToSelect.begin(), timeStepsToSelect.end()); @@ -326,13 +324,13 @@ void RimWellRftPlot::applyInitialSelections() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateEditorsFromCurves() { - std::set selectedSources; - std::set selectedTimeSteps; - std::map> selectedTimeStepsMap; + std::set selectedSources; + std::set selectedTimeSteps; + std::map> selectedTimeStepsMap; for (const RiaRftPltCurveDefinition& curveDef : curveDefsFromCurves()) { @@ -341,21 +339,18 @@ void RimWellRftPlot::updateEditorsFromCurves() else selectedSources.insert(curveDef.address()); - auto newTimeStepMap = std::map> - { - { curveDef.timeStep(), std::set { curveDef.address()} } - }; + auto newTimeStepMap = std::map>{ + {curveDef.timeStep(), std::set{curveDef.address()}}}; RimWellPlotTools::addTimeStepsToMap(selectedTimeStepsMap, newTimeStepMap); selectedTimeSteps.insert(curveDef.timeStep()); } - m_selectedSources = std::vector(selectedSources.begin(), selectedSources.end()); + m_selectedSources = std::vector(selectedSources.begin(), selectedSources.end()); m_selectedTimeSteps = std::vector(selectedTimeSteps.begin(), selectedTimeSteps.end()); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateWidgetTitleWindowTitle() { @@ -375,25 +370,27 @@ void RimWellRftPlot::updateWidgetTitleWindowTitle() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::syncCurvesFromUiSelection() { RimWellLogTrack* plotTrack = m_wellLogPlot->trackByIndex(0); - const std::set& allCurveDefs = selectedCurveDefs(); + const std::set& allCurveDefs = selectedCurveDefs(); const std::set& curveDefsInPlot = curveDefsFromCurves(); - std::set curvesToDelete; + std::set curvesToDelete; std::set newCurveDefs; if (allCurveDefs.size() < curveDefsInPlot.size()) { // Determine which curves to delete from plot std::set deleteCurveDefs; - - std::set_difference(curveDefsInPlot.begin(), curveDefsInPlot.end(), - allCurveDefs.begin(), allCurveDefs.end(), + + std::set_difference(curveDefsInPlot.begin(), + curveDefsInPlot.end(), + allCurveDefs.begin(), + allCurveDefs.end(), std::inserter(deleteCurveDefs, deleteCurveDefs.end())); for (RimWellLogCurve* const curve : plotTrack->curvesVector()) @@ -408,8 +405,10 @@ void RimWellRftPlot::syncCurvesFromUiSelection() else { // Determine which curves are new since last time - std::set_difference(allCurveDefs.begin(), allCurveDefs.end(), - curveDefsInPlot.begin(), curveDefsInPlot.end(), + std::set_difference(allCurveDefs.begin(), + allCurveDefs.end(), + curveDefsInPlot.begin(), + curveDefsInPlot.end(), std::inserter(newCurveDefs, newCurveDefs.end())); } @@ -417,18 +416,16 @@ void RimWellRftPlot::syncCurvesFromUiSelection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set < RiaRftPltCurveDefinition > RimWellRftPlot::selectedCurveDefs() const +std::set RimWellRftPlot::selectedCurveDefs() const { - return RimWellPlotTools::curveDefsFromTimesteps(associatedSimWellName(), - m_selectedTimeSteps.v(), - true, - selectedSourcesExpanded()); + return RimWellPlotTools::curveDefsFromTimesteps( + associatedSimWellName(), m_selectedTimeSteps.v(), true, selectedSourcesExpanded()); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimWellRftPlot::curveDefsFromCurves() const { @@ -443,14 +440,14 @@ std::set RimWellRftPlot::curveDefsFromCurves() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateCurvesInPlot(const std::set& allCurveDefs, const std::set& curveDefsToAdd, - const std::set& curvesToDelete) + const std::set& curvesToDelete) { - const QString simWellName = associatedSimWellName(); - RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); + const QString simWellName = associatedSimWellName(); + RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); // Delete curves plotTrack->deleteAllCurves(); @@ -488,15 +485,20 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set { // Case curve->setCase(gridCase); - curve->setEclipseResultVariable("PRESSURE"); + curve->setEclipseResultVariable("PRESSURE"); // Time step - std::vector timeSteps = gridCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); + std::vector timeSteps = + gridCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); int currentTimeStepIndex = -1; - for (size_t tsIdx = 0; tsIdx < timeSteps.size(); ++tsIdx) + for (size_t tsIdx = 0; tsIdx < timeSteps.size(); ++tsIdx) { - if (timeSteps[tsIdx] == curveDefToAdd.timeStep()){ currentTimeStepIndex = static_cast(tsIdx); break;} + if (timeSteps[tsIdx] == curveDefToAdd.timeStep()) + { + currentTimeStepIndex = static_cast(tsIdx); + break; + } } curve->setCurrentTimeStep(currentTimeStepIndex); @@ -508,11 +510,12 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set else if (curveDefToAdd.address().sourceType() == RifDataSourceForRftPlt::OBSERVED) { RimWellLogFile* const wellLogFile = curveDefToAdd.address().wellLogFile(); - RimWellPath* const wellPath = RimWellPlotTools::wellPathFromWellLogFile(wellLogFile); - if(wellLogFile!= nullptr) + RimWellPath* const wellPath = RimWellPlotTools::wellPathFromWellLogFile(wellLogFile); + if (wellLogFile != nullptr) { RimWellLogFileChannel* pressureChannel = RimWellPlotTools::getPressureChannelFromWellFile(wellLogFile); - auto curve = new RimWellLogFileCurve(); + auto curve = new RimWellLogFileCurve(); + plotTrack->addCurve(curve); curve->setWellPath(wellPath); curve->setWellLogFile(wellLogFile); @@ -525,15 +528,14 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set } m_wellLogPlot->loadDataAndUpdate(); - if ( plotTrack->curveCount() ) + if (plotTrack->curveCount()) { m_wellLogPlot->zoomAll(); } } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellRftPlot::selectedSourcesExpanded() const { @@ -542,7 +544,8 @@ std::vector RimWellRftPlot::selectedSourcesExpanded() co { if (addr.sourceType() == RifDataSourceForRftPlt::OBSERVED) { - for (RimWellLogFile* const wellLogFile : RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName)) + for (RimWellLogFile* const wellLogFile : + RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName)) { sources.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile)); } @@ -554,7 +557,7 @@ std::vector RimWellRftPlot::selectedSourcesExpanded() co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RimWellRftPlot::viewWidget() { @@ -562,7 +565,7 @@ QWidget* RimWellRftPlot::viewWidget() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::zoomAll() { @@ -570,7 +573,7 @@ void RimWellRftPlot::zoomAll() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellLogPlot* RimWellRftPlot::wellLogPlot() const { @@ -578,7 +581,7 @@ RimWellLogPlot* RimWellRftPlot::wellLogPlot() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::setSimWellOrWellPathName(const QString& currWellName) { @@ -590,7 +593,7 @@ void RimWellRftPlot::setSimWellOrWellPathName(const QString& currWellName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::simWellOrWellPathName() const { @@ -598,7 +601,7 @@ QString RimWellRftPlot::simWellOrWellPathName() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RimWellRftPlot::branchIndex() const { @@ -606,7 +609,7 @@ int RimWellRftPlot::branchIndex() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const char* RimWellRftPlot::plotNameFormatString() { @@ -614,9 +617,10 @@ const char* RimWellRftPlot::plotNameFormatString() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RimWellRftPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimWellRftPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; @@ -631,7 +635,8 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P const std::vector rftCases = RimWellPlotTools::rftCasesForWell(simWellName); if (rftCases.size() > 0) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::RFT), true)); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::RFT), true)); } for (const auto& rftCase : rftCases) { @@ -644,7 +649,8 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P const std::vector gridCases = RimWellPlotTools::gridCasesForWell(simWellName); if (gridCases.size() > 0) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::GRID), true)); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::GRID), true)); } for (const auto& gridCase : gridCases) { @@ -656,7 +662,8 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P if (RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName).size() > 0) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::OBSERVED), true)); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::OBSERVED), true)); auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED); auto item = caf::PdmOptionItemInfo("Observed Data", QVariant::fromValue(addr)); @@ -666,10 +673,8 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P } else if (fieldNeedingOptions == &m_selectedTimeSteps) { - RimWellPlotTools::calculateValueOptionsForTimeSteps( associatedSimWellName(), - selectedSourcesExpanded(), - { RifEclipseRftAddress::PRESSURE }, - options); + RimWellPlotTools::calculateValueOptionsForTimeSteps( + associatedSimWellName(), selectedSourcesExpanded(), {RifEclipseRftAddress::PRESSURE}, options); } else if (fieldNeedingOptions == &m_branchIndex) { @@ -682,7 +687,7 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { @@ -706,18 +711,15 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c updateEditorsFromCurves(); updateFormationsOnPlot(); } - else if (changedField == &m_branchIndex || - changedField == &m_branchDetection) + else if (changedField == &m_branchIndex || changedField == &m_branchDetection) { const QString simWellName = associatedSimWellName(); - m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection); + m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection); updateFormationsOnPlot(); syncCurvesFromUiSelection(); - } - else if (changedField == &m_selectedSources || - changedField == &m_selectedTimeSteps) + else if (changedField == &m_selectedSources || changedField == &m_selectedTimeSteps) { updateFormationsOnPlot(); syncCurvesFromUiSelection(); @@ -725,12 +727,12 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } else if (changedField == &m_showPlotTitle) { - //m_wellLogPlot->setShowDescription(m_showPlotTitle); + // m_wellLogPlot->setShowDescription(m_showPlotTitle); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) { @@ -738,7 +740,7 @@ void RimWellRftPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QImage RimWellRftPlot::snapshotWindowContent() { @@ -747,14 +749,14 @@ QImage RimWellRftPlot::snapshotWindowContent() if (m_wellLogPlotWidget) { QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget); - image = pix.toImage(); + image = pix.toImage(); } return image; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -767,10 +769,8 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add(&m_userName); uiOrdering.add(&m_wellPathNameOrSimWellName); - RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName(&uiOrdering, - m_wellPathNameOrSimWellName, - m_branchDetection, - m_branchIndex); + RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName( + &uiOrdering, m_wellPathNameOrSimWellName, m_branchDetection, m_branchIndex); caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources"); sourcesGroup->add(&m_selectedSources); @@ -786,7 +786,7 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup("Legend and Axis"); legendAndAxisGroup->setCollapsedByDefault(true); - + m_wellLogPlot->uiOrderingForPlot(*legendAndAxisGroup); track->uiOrderingForVisibleXRange(*legendAndAxisGroup); @@ -798,18 +798,18 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::calculateValueOptionsForWells(QList& options) { - RimProject * proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); options.push_back(caf::PdmOptionItemInfo("None", "None")); if (proj != nullptr) { - const std::vector simWellNames = proj->simulationWellNames(); - std::set simWellsAssociatedWithWellPath; + const std::vector simWellNames = proj->simulationWellNames(); + std::set simWellsAssociatedWithWellPath; std::set> wellNames; // Observed wells @@ -840,7 +840,7 @@ void RimWellRftPlot::calculateValueOptionsForWells(QList } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::setDescription(const QString& description) { @@ -850,7 +850,7 @@ void RimWellRftPlot::setDescription(const QString& description) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::description() const { @@ -858,7 +858,7 @@ QString RimWellRftPlot::description() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::onLoadDataAndUpdate() { @@ -871,19 +871,22 @@ void RimWellRftPlot::onLoadDataAndUpdate() m_isOnLoad = false; } + updateMdiWindowVisibility(); updateFormationsOnPlot(); + m_wellLogPlot->loadDataAndUpdate(); + updateEditorsFromCurves(); updateWidgetTitleWindowTitle(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent) { m_wellLogPlotWidget = new RiuWellRftPlot(this, mainWindowParent); + return m_wellLogPlotWidget; } - diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h index f1995a020c..106d37be79 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -93,7 +93,7 @@ class RimWellRftPlot : public RimViewWindow // Overridden PDM methods virtual caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; } virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName); + void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; @@ -117,7 +117,7 @@ class RimWellRftPlot : public RimViewWindow void updateCurvesInPlot(const std::set& allCurveDefs, const std::set& curveDefsToAdd, const std::set& curvesToDelete); - std::vector selectedSourcesExpanded() const; + std::vector selectedSourcesExpanded() const; // RimViewWindow overrides @@ -141,10 +141,10 @@ class RimWellRftPlot : public RimViewWindow caf::PdmField> m_selectedTimeSteps; - QPointer m_wellLogPlotWidget; - caf::PdmChildField m_wellLogPlot; + QPointer m_wellLogPlotWidget; + bool m_selectedSourcesOrTimeStepsFieldsChanged; bool m_isOnLoad; }; From e1abaa1b6ce88fdb1174e2e4237a65bf6c250039 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 13:26:14 +0200 Subject: [PATCH 0950/1027] #2901 RFT Plot : Use empty() and move for loops --- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 83901354eb..89cc7648ec 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -296,7 +296,7 @@ void RimWellRftPlot::applyInitialSelections() } std::vector wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName); - if (wellLogFiles.size() > 0) + if (!wellLogFiles.empty()) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED)); for (RimWellLogFile* const wellLogFile : wellLogFiles) @@ -316,7 +316,7 @@ void RimWellRftPlot::applyInitialSelections() { timeStepsToSelect.insert(timeStep); } - if (gridTimeSteps.size() > 0) timeStepsToSelect.insert(*gridTimeSteps.begin()); + if (!gridTimeSteps.empty()) timeStepsToSelect.insert(*gridTimeSteps.begin()); m_selectedTimeSteps = std::vector(timeStepsToSelect.begin(), timeStepsToSelect.end()); @@ -633,34 +633,36 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P else if (fieldNeedingOptions == &m_selectedSources) { const std::vector rftCases = RimWellPlotTools::rftCasesForWell(simWellName); - if (rftCases.size() > 0) + if (!rftCases.empty()) { options.push_back(caf::PdmOptionItemInfo::createHeader( RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::RFT), true)); - } - for (const auto& rftCase : rftCases) - { - auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase); - auto item = caf::PdmOptionItemInfo(rftCase->caseUserDescription(), QVariant::fromValue(addr)); - item.setLevel(1); - options.push_back(item); + + for (const auto& rftCase : rftCases) + { + auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase); + auto item = caf::PdmOptionItemInfo(rftCase->caseUserDescription(), QVariant::fromValue(addr)); + item.setLevel(1); + options.push_back(item); + } } const std::vector gridCases = RimWellPlotTools::gridCasesForWell(simWellName); - if (gridCases.size() > 0) + if (!gridCases.empty()) { options.push_back(caf::PdmOptionItemInfo::createHeader( RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::GRID), true)); - } - for (const auto& gridCase : gridCases) - { - auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase); - auto item = caf::PdmOptionItemInfo(gridCase->caseUserDescription(), QVariant::fromValue(addr)); - item.setLevel(1); - options.push_back(item); + + for (const auto& gridCase : gridCases) + { + auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase); + auto item = caf::PdmOptionItemInfo(gridCase->caseUserDescription(), QVariant::fromValue(addr)); + item.setLevel(1); + options.push_back(item); + } } - if (RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName).size() > 0) + if (!RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName).empty()) { options.push_back(caf::PdmOptionItemInfo::createHeader( RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::OBSERVED), true)); From bf2f524d34531476f93466341e09509eefd6a12d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 14:18:13 +0200 Subject: [PATCH 0951/1027] #2901 RFT Plot : Initialize default time step selection based on all sources --- .../Flow/RimWellPlotTools.cpp | 107 ++++++++++-------- .../ProjectDataModel/Flow/RimWellPlotTools.h | 6 + .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 26 ++--- 3 files changed, 76 insertions(+), 63 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 0649d83772..9211f73aa5 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -792,78 +792,76 @@ QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condit } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellName, - const std::vector& selSources, - const std::set& interestingRFTResults, - QList& options) +std::map> RimWellPlotTools::calculateRelevantTimeStepsFromCases( + const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults) { - //std::vector selSources = selectedSourcesExpanded(); - bool addFirstTimestep = (interestingRFTResults.count(RifEclipseRftAddress::PRESSURE) == 1); - bool hasObservedData = false; - bool hasRftData = false; - bool hasGridData = false; + bool hasObservedData = false; + bool hasRftData = false; + bool hasGridData = false; - for (const auto& source : selSources ) + for (const auto& source : selSources) { switch (source.sourceType()) { case RifDataSourceForRftPlt::RFT: - hasRftData = true; - break; + hasRftData = true; + break; case RifDataSourceForRftPlt::GRID: - hasGridData = true; - break; + hasGridData = true; + break; case RifDataSourceForRftPlt::OBSERVED: - hasObservedData = true; - break; + hasObservedData = true; + break; } } - std::map > observedTimeStepsWithSources; - std::map > rftTimeStepsWithSources; - std::map > gridTimestepsWithSources; - - + std::map> observedTimeStepsWithSources; + std::map> rftTimeStepsWithSources; + std::map> gridTimestepsWithSources; if (hasObservedData) { - for (const auto& source : selSources ) + for (const auto& source : selSources) { if (source.sourceType() == RifDataSourceForRftPlt::OBSERVED && source.wellLogFile()) { observedTimeStepsWithSources[source.wellLogFile()->date()].insert(source); - } + } } } if (hasRftData) { - for (const auto& source : selSources ) + for (const auto& source : selSources) { if (source.sourceType() == RifDataSourceForRftPlt::RFT && source.rftReader()) - { - std::set rftTimes = source.rftReader()->availableTimeSteps(simWellName, interestingRFTResults ); - for ( const QDateTime& date: rftTimes) + { + std::set rftTimes = + source.rftReader()->availableTimeSteps(wellPathNameOrSimWellName, interestingRFTResults); + for (const QDateTime& date : rftTimes) { rftTimeStepsWithSources[date].insert(source); } - } + } } } - if ( hasGridData ) + if (hasGridData) { - for ( const auto& source : selSources ) + for (const auto& source : selSources) { - if ( source.sourceType() == RifDataSourceForRftPlt::GRID && source.eclCase() ) + if (source.sourceType() == RifDataSourceForRftPlt::GRID && source.eclCase()) { - std::set wellTimeSteps = RimWellPlotTools::availableSimWellTimesteps(source.eclCase(), simWellName, addFirstTimestep); + std::set wellTimeSteps = + RimWellPlotTools::availableSimWellTimesteps(source.eclCase(), wellPathNameOrSimWellName, addFirstTimestep); - for ( const QDateTime& date: wellTimeSteps) + for (const QDateTime& date : wellTimeSteps) { gridTimestepsWithSources[date].insert(source); } @@ -873,8 +871,8 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN // If we have a time baseline add the equal or adjacent grid timesteps - std::map > timestepsToShowWithSources; - std::map >* timeBaseline = nullptr; + std::map> timestepsToShowWithSources; + std::map>* timeBaseline = nullptr; if (hasObservedData) { @@ -888,39 +886,43 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN if (timeBaseline) { std::set baseTimeSteps; - for (const auto& dateSourceSetPair: *timeBaseline) baseTimeSteps.insert(dateSourceSetPair.first); - + for (const auto& dateSourceSetPair : *timeBaseline) + baseTimeSteps.insert(dateSourceSetPair.first); + std::set rftTimeSteps; - for (const auto& dateSourceSetPair: rftTimeStepsWithSources) rftTimeSteps.insert(dateSourceSetPair.first); + for (const auto& dateSourceSetPair : rftTimeStepsWithSources) + rftTimeSteps.insert(dateSourceSetPair.first); std::set gridTimeSteps; - for (const auto& dateSourceSetPair: gridTimestepsWithSources) gridTimeSteps.insert(dateSourceSetPair.first); + for (const auto& dateSourceSetPair : gridTimestepsWithSources) + gridTimeSteps.insert(dateSourceSetPair.first); std::set filteredRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, rftTimeSteps); - std::set filteredGridTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps); + std::set filteredGridTimeSteps = + RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps); if (addFirstTimestep && gridTimeSteps.size()) { filteredGridTimeSteps.insert(*gridTimeSteps.begin()); } - // Fill final map + // Fill final map timestepsToShowWithSources = observedTimeStepsWithSources; std::set& allFilteredTimesteps = filteredRftTimeSteps; allFilteredTimesteps.insert(filteredGridTimeSteps.begin(), filteredGridTimeSteps.end()); - for (const QDateTime& time: allFilteredTimesteps) + for (const QDateTime& time : allFilteredTimesteps) { auto rftTimeSourceSetIt = rftTimeStepsWithSources.find(time); - if ( rftTimeSourceSetIt != rftTimeStepsWithSources.end() ) + if (rftTimeSourceSetIt != rftTimeStepsWithSources.end()) { std::set& sourceSet = rftTimeSourceSetIt->second; timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end()); } auto gridTimeSourceSetIt = gridTimestepsWithSources.find(time); - if ( gridTimeSourceSetIt != gridTimestepsWithSources.end() ) + if (gridTimeSourceSetIt != gridTimestepsWithSources.end()) { std::set& sourceSet = gridTimeSourceSetIt->second; timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end()); @@ -932,7 +934,20 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN timestepsToShowWithSources = gridTimestepsWithSources; } - // Create formatted options of all the timesteps + return timestepsToShowWithSources; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults, + QList& options) +{ + auto timestepsToShowWithSources = calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults); + + // Create formatted options of all the time steps QString dateFormatString; { std::vector allTimeSteps; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h index 48545d81c5..51819d6b60 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -86,10 +86,16 @@ class RimWellPlotTools static std::vector rftCasesForWell(const QString& simWellName); static QString simWellName(const QString& wellPathNameOrSimWellName); + static std::map> + calculateRelevantTimeStepsFromCases(const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults); + static void calculateValueOptionsForTimeSteps(const QString& wellPathNameOrSimWellName, const std::vector& selSources, const std::set& interestingRFTResults, QList& options); + static std::set < RiaRftPltCurveDefinition > curveDefsFromTimesteps(const QString& simWellName, const std::vector& selectedTimeStepVector, bool firstReportTimeStepIsValid, diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 89cc7648ec..0bcee43d44 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -278,47 +278,39 @@ QString RimWellRftPlot::associatedSimWellName() const void RimWellRftPlot::applyInitialSelections() { std::vector sourcesToSelect; - std::set rftTimeSteps; - std::set observedTimeSteps; - std::set gridTimeSteps; const QString simWellName = associatedSimWellName(); for (RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase)); - RimWellPlotTools::appendSet(rftTimeSteps, RimWellPlotTools::timeStepsFromRftCase(rftCase, simWellName)); } for (RimEclipseResultCase* const gridCase : RimWellPlotTools::gridCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase)); - RimWellPlotTools::appendSet(gridTimeSteps, RimWellPlotTools::timeStepsFromGridCase(gridCase)); } std::vector wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName); if (!wellLogFiles.empty()) { - sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED)); for (RimWellLogFile* const wellLogFile : wellLogFiles) { - observedTimeSteps.insert(RimWellPlotTools::timeStepFromWellLogFile(wellLogFile)); + sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile)); } } m_selectedSources = sourcesToSelect; - std::set timeStepsToSelect; - for (const QDateTime& timeStep : rftTimeSteps) { - timeStepsToSelect.insert(timeStep); - } - for (const QDateTime& timeStep : observedTimeSteps) - { - timeStepsToSelect.insert(timeStep); - } - if (!gridTimeSteps.empty()) timeStepsToSelect.insert(*gridTimeSteps.begin()); + auto relevantTimeSteps = RimWellPlotTools::calculateRelevantTimeStepsFromCases( + associatedSimWellName(), m_selectedSources, {RifEclipseRftAddress::PRESSURE}); - m_selectedTimeSteps = std::vector(timeStepsToSelect.begin(), timeStepsToSelect.end()); + std::vector timeStepVector; + for (const auto& item : relevantTimeSteps) + timeStepVector.push_back(item.first); + + m_selectedTimeSteps = timeStepVector; + } syncCurvesFromUiSelection(); } From b02bf07568b2d1d6ae56dd18c25c1eb883449610 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 14:20:16 +0200 Subject: [PATCH 0952/1027] #2901 Whitespace --- .../Flow/RimWellPlotTools.cpp | 364 ++++++++++-------- 1 file changed, 199 insertions(+), 165 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 9211f73aa5..838da84278 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -39,24 +39,23 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include #include "RimTools.h" - +#include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -const std::set RimWellPlotTools::PRESSURE_DATA_NAMES = { "PRESSURE", "PRES_FORM" }; +const std::set RimWellPlotTools::PRESSURE_DATA_NAMES = {"PRESSURE", "PRES_FORM"}; -const std::set RimWellPlotTools::OIL_CHANNEL_NAMES = { "QOZT", "QOIL", "^.*\\D_QOIL" }; -const std::set RimWellPlotTools::GAS_CHANNEL_NAMES = { "QGZT", "QGAS", "^.*\\D_QGAS" }; -const std::set RimWellPlotTools::WATER_CHANNEL_NAMES = { "QWZT", "QWAT", "^.*\\D_QWAT" }; -const std::set RimWellPlotTools::TOTAL_CHANNEL_NAMES = { "QTZT", "QTOT", "^.*\\D_QTOT" }; +const std::set RimWellPlotTools::OIL_CHANNEL_NAMES = {"QOZT", "QOIL", "^.*\\D_QOIL"}; +const std::set RimWellPlotTools::GAS_CHANNEL_NAMES = {"QGZT", "QGAS", "^.*\\D_QGAS"}; +const std::set RimWellPlotTools::WATER_CHANNEL_NAMES = {"QWZT", "QWAT", "^.*\\D_QWAT"}; +const std::set RimWellPlotTools::TOTAL_CHANNEL_NAMES = {"QTZT", "QTOT", "^.*\\D_QTOT"}; std::set RimWellPlotTools::FLOW_DATA_NAMES = {}; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- class StaticFieldsInitializer { @@ -64,15 +63,19 @@ class StaticFieldsInitializer StaticFieldsInitializer() { // Init static list - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), RimWellPlotTools::OIL_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), RimWellPlotTools::GAS_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), RimWellPlotTools::WATER_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), RimWellPlotTools::TOTAL_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), + RimWellPlotTools::OIL_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), + RimWellPlotTools::GAS_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), + RimWellPlotTools::WATER_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), + RimWellPlotTools::TOTAL_CHANNEL_NAMES.end()); } } staticFieldsInitializer; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(const RimWellLogFile* wellLogFile) { @@ -84,7 +87,7 @@ bool RimWellPlotTools::hasPressureData(const RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(RimWellPath* wellPath) { @@ -99,7 +102,7 @@ bool RimWellPlotTools::hasPressureData(RimWellPath* wellPath) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::pair RimWellPlotTools::pressureResultDataInfo(const RigEclipseCaseData* eclipseCaseData) { @@ -107,8 +110,8 @@ std::pair RimWellPlotTools::pressureResultDataInfo(const RigEcl { for (const auto& pressureDataName : PRESSURE_DATA_NAMES) { - size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> - findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName); + size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL) + ->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName); if (index != cvf::UNDEFINED_SIZE_T) { return std::make_pair(index, pressureDataName); @@ -119,7 +122,7 @@ std::pair RimWellPlotTools::pressureResultDataInfo(const RigEcl } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isPressureChannel(RimWellLogFileChannel* channel) { @@ -131,14 +134,14 @@ bool RimWellPlotTools::isPressureChannel(RimWellLogFileChannel* channel) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(RimEclipseResultCase* gridCase) { return pressureResultDataInfo(gridCase->eclipseCaseData()).first != cvf::UNDEFINED_SIZE_T; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(const RimWellLogFile* wellLogFile) { @@ -150,7 +153,7 @@ bool RimWellPlotTools::hasFlowData(const RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(const RimWellPath* wellPath) { @@ -165,7 +168,7 @@ bool RimWellPlotTools::hasFlowData(const RimWellPath* wellPath) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasAssociatedWellPath(const QString& wellName) { @@ -176,7 +179,7 @@ bool RimWellPlotTools::hasAssociatedWellPath(const QString& wellName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isFlowChannel(RimWellLogFileChannel* channel) { @@ -184,7 +187,7 @@ bool RimWellPlotTools::isFlowChannel(RimWellLogFileChannel* channel) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isOilFlowChannel(const QString& channelName) { @@ -192,7 +195,7 @@ bool RimWellPlotTools::isOilFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isGasFlowChannel(const QString& channelName) { @@ -200,7 +203,7 @@ bool RimWellPlotTools::isGasFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isWaterFlowChannel(const QString& channelName) { @@ -208,7 +211,7 @@ bool RimWellPlotTools::isWaterFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isTotalFlowChannel(const QString& channelName) { @@ -216,7 +219,7 @@ bool RimWellPlotTools::isTotalFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) { @@ -224,8 +227,8 @@ bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) for (const QString& channelName : FLOW_DATA_NAMES) { - size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> - findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName); + size_t resultIndex = + eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName); if (resultIndex != cvf::UNDEFINED_SIZE_T) return true; } @@ -233,7 +236,7 @@ bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- FlowPhase RimWellPlotTools::flowPhaseFromChannelName(const QString& channelName) { @@ -244,12 +247,11 @@ FlowPhase RimWellPlotTools::flowPhaseFromChannelName(const QString& channelName) return FLOW_PHASE_NONE; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::addTimeStepsToMap(std::map>& destMap, - const std::map>& timeStepsToAdd) +void RimWellPlotTools::addTimeStepsToMap(std::map>& destMap, + const std::map>& timeStepsToAdd) { for (const auto& timeStepPair : timeStepsToAdd) { @@ -262,19 +264,18 @@ void RimWellPlotTools::addTimeStepsToMap(std::map RimWellPlotTools::wellLogFilesContainingPressure(const QString& wellPathNameOrSimWellName) { std::vector wellLogFiles; - const RimProject* const project = RiaApplication::instance()->project(); - std::vector wellPaths = project->allWellPaths(); + const RimProject* const project = RiaApplication::instance()->project(); + std::vector wellPaths = project->allWellPaths(); for (auto wellPath : wellPaths) { - if (!wellPathNameOrSimWellName.isEmpty() && - (wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() || - wellPathNameOrSimWellName == wellPath->name())) + if (!wellPathNameOrSimWellName.isEmpty() && (wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() || + wellPathNameOrSimWellName == wellPath->name())) { const std::vector files = wellPath->wellLogFiles(); @@ -283,7 +284,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure(co if (hasPressureData(file)) { wellLogFiles.push_back(file); - } + } } } } @@ -292,7 +293,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure(co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellLogFileChannel* RimWellPlotTools::getPressureChannelFromWellFile(const RimWellLogFile* wellLogFile) { @@ -310,23 +311,23 @@ RimWellLogFileChannel* RimWellPlotTools::getPressureChannelFromWellFile(const Ri } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::wellLogFilesContainingFlow(const QString& wellPathName) { std::vector wellLogFiles; - const RimProject* const project = RiaApplication::instance()->project(); - std::vector wellPaths = project->allWellPaths(); + const RimProject* const project = RiaApplication::instance()->project(); + std::vector wellPaths = project->allWellPaths(); - for ( auto wellPath : wellPaths ) + for (auto wellPath : wellPaths) { - if ( wellPath->name() == wellPathName ) + if (wellPath->name() == wellPathName) { std::vector files = wellPath->wellLogFiles(); - for ( RimWellLogFile* file : files ) + for (RimWellLogFile* file : files) { - if ( hasFlowData(file) ) + if (hasFlowData(file)) { wellLogFiles.push_back(file); } @@ -337,14 +338,15 @@ std::vector RimWellPlotTools::wellLogFilesContainingFlow(const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellPath* RimWellPlotTools::wellPathFromWellLogFile(const RimWellLogFile* wellLogFile) { RimProject* const project = RiaApplication::instance()->project(); for (const auto& oilField : project->oilFields) { - auto wellPaths = std::vector(oilField->wellPathCollection()->wellPaths.begin(), oilField->wellPathCollection()->wellPaths.end()); + auto wellPaths = std::vector(oilField->wellPathCollection()->wellPaths.begin(), + oilField->wellPathCollection()->wellPaths.end()); for (const auto& wellPath : wellPaths) { @@ -362,19 +364,19 @@ RimWellPath* RimWellPlotTools::wellPathFromWellLogFile(const RimWellLogFile* wel } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::gridCasesForWell(const QString& simWellName) { std::vector cases; - const RimProject* project = RiaApplication::instance()->project(); + const RimProject* project = RiaApplication::instance()->project(); for (RimEclipseCase* eclCase : project->eclipseCases()) { RimEclipseResultCase* resultCase = dynamic_cast(eclCase); if (resultCase != nullptr) { - if ( eclCase->eclipseCaseData()->findSimWellData(simWellName) ) + if (eclCase->eclipseCaseData()->findSimWellData(simWellName)) { cases.push_back(resultCase); break; @@ -385,20 +387,18 @@ std::vector RimWellPlotTools::gridCasesForWell(const QStr } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::rftCasesForWell(const QString& simWellName) { std::vector cases; - const RimProject* project = RiaApplication::instance()->project(); + const RimProject* project = RiaApplication::instance()->project(); for (RimEclipseCase* eclCase : project->eclipseCases()) { RimEclipseResultCase* resultCase = dynamic_cast(eclCase); - if (resultCase - && resultCase->rftReader() - && resultCase->rftReader()->wellNames().count(simWellName)) + if (resultCase && resultCase->rftReader() && resultCase->rftReader()->wellNames().count(simWellName)) { cases.push_back(resultCase); } @@ -407,12 +407,11 @@ std::vector RimWellPlotTools::rftCasesForWell(const QStri } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, - const QString& simWellName) +std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, const QString& simWellName) { - std::set timeSteps; + std::set timeSteps; RifReaderEclipseRft* const reader = rftCase->rftReader(); if (reader != nullptr) { @@ -425,12 +424,12 @@ std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimWellPlotTools::timeStepsFromGridCase(RimEclipseCase* gridCase) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); - std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); + std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); std::set timeSteps; if (resultDataInfo.first != cvf::UNDEFINED_SIZE_T) @@ -444,7 +443,7 @@ std::set RimWellPlotTools::timeStepsFromGridCase(RimEclipseCase* grid } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QDateTime RimWellPlotTools::timeStepFromWellLogFile(RimWellLogFile* wellLogFile) { @@ -453,12 +452,12 @@ QDateTime RimWellPlotTools::timeStepFromWellLogFile(RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::map> RimWellPlotTools::timeStepsMapFromGridCase(RimEclipseCase* gridCase) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); - std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); + std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); std::map> timeStepsMap; if (resultDataInfo.first != cvf::UNDEFINED_SIZE_T) @@ -476,32 +475,31 @@ std::map> RimWellPlotTools::timeStep } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std::set& baseTimeLine, +std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std::set& baseTimeLine, const std::set& availableTimeSteps) { std::set resultTimeSteps; - for (const QDateTime& baseTimeStep: baseTimeLine ) + for (const QDateTime& baseTimeStep : baseTimeLine) { auto itToEqualOrLargerTime = availableTimeSteps.lower_bound(baseTimeStep); if (itToEqualOrLargerTime != availableTimeSteps.end()) { resultTimeSteps.insert(*itToEqualOrLargerTime); - if ( *itToEqualOrLargerTime != baseTimeStep - && itToEqualOrLargerTime != availableTimeSteps.begin() ) + if (*itToEqualOrLargerTime != baseTimeStep && itToEqualOrLargerTime != availableTimeSteps.begin()) { // Found a larger time, then add the timestep before it as the adjacent timestep before the base timestep itToEqualOrLargerTime--; resultTimeSteps.insert(*itToEqualOrLargerTime); - } + } } } // The above will only work if there are at least one available timestep equal or after any of the basetimeline times. // If no timesteps matched but we have some, add the last available because the above code missed it. - if (!resultTimeSteps.size() && baseTimeLine.size() && availableTimeSteps.size()) + if (!resultTimeSteps.size() && baseTimeLine.size() && availableTimeSteps.size()) { resultTimeSteps.insert(*availableTimeSteps.rbegin()); } @@ -510,20 +508,19 @@ std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std: } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase * eclCase, - const QString& simWellName, - bool addFirstReportTimestep) +std::set + RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimestep) { - std::set availebleTimeSteps; + std::set availebleTimeSteps; std::vector allTimeSteps = eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); - const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData(simWellName); + const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData(simWellName); - for ( size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx ) + for (size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx) { - if ( simWell->hasWellResult(tsIdx) || (addFirstReportTimestep && tsIdx == 0) ) + if (simWell->hasWellResult(tsIdx) || (addFirstReportTimestep && tsIdx == 0)) { availebleTimeSteps.insert(allTimeSteps[tsIdx]); } @@ -533,13 +530,13 @@ std::set RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase * } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCurve* curve) { - const RimWellLogRftCurve* rftCurve = dynamic_cast(curve); - const RimWellLogExtractionCurve* gridCurve = dynamic_cast(curve); - const RimWellLogFileCurve* wellLogFileCurve = dynamic_cast(curve); + const RimWellLogRftCurve* rftCurve = dynamic_cast(curve); + const RimWellLogExtractionCurve* gridCurve = dynamic_cast(curve); + const RimWellLogFileCurve* wellLogFileCurve = dynamic_cast(curve); if (rftCurve != nullptr) { @@ -547,7 +544,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur if (rftCase != nullptr) { const RifEclipseRftAddress rftAddress = rftCurve->rftAddress(); - const QDateTime timeStep = rftAddress.timeStep(); + const QDateTime timeStep = rftAddress.timeStep(); return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase), timeStep); } } @@ -556,21 +553,21 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur RimEclipseResultCase* gridCase = dynamic_cast(gridCurve->rimCase()); if (gridCase != nullptr) { - size_t timeStepIndex = gridCurve->currentTimeStep(); - const std::map>& timeStepsMap = timeStepsMapFromGridCase(gridCase); - auto timeStepsVector = std::vector>>( - timeStepsMap.begin(), timeStepsMap.end()); + size_t timeStepIndex = gridCurve->currentTimeStep(); + const std::map>& timeStepsMap = timeStepsMapFromGridCase(gridCase); + auto timeStepsVector = + std::vector>>(timeStepsMap.begin(), timeStepsMap.end()); if (timeStepIndex < timeStepsMap.size()) { return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase), - timeStepsVector[timeStepIndex].first); + timeStepsVector[timeStepIndex].first); } } } else if (wellLogFileCurve != nullptr) { - const RimWellPath* const wellPath = wellLogFileCurve->wellPath(); - RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile(); + const RimWellPath* const wellPath = wellLogFileCurve->wellPath(); + RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile(); if (wellLogFile != nullptr) { @@ -590,7 +587,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur //-------------------------------------------------------------------------------------------------- RimWellPath* RimWellPlotTools::wellPathByWellPathNameOrSimWellName(const QString& wellPathNameOrSimwellName) { - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = proj->wellPathByName(wellPathNameOrSimwellName); return wellPath != nullptr ? wellPath : proj->wellPathFromSimWellName(wellPathNameOrSimwellName); @@ -610,8 +607,7 @@ QString RimWellPlotTools::simWellName(const QString& wellPathNameOrSimWellName) //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::tryMatchChannelName(const std::set& channelNames, const QString& channelNameToMatch) { - auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) - { + auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) { if (channelName.startsWith('^')) { std::regex pattern(channelName.toStdString()); @@ -625,51 +621,51 @@ bool RimWellPlotTools::tryMatchChannelName(const std::set& channelNames return itr != channelNames.end(); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName, - const std::vector& selectedTimeSteps, - bool firstSimWellTimeStepIsValid, - const std::vector& selectedSourcesExpanded) +std::set + RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName, + const std::vector& selectedTimeSteps, + bool firstSimWellTimeStepIsValid, + const std::vector& selectedSourcesExpanded) { std::set curveDefs; std::set selectedTimeStepSet(selectedTimeSteps.begin(), selectedTimeSteps.end()); - for ( const RifDataSourceForRftPlt& addr : selectedSourcesExpanded ) + for (const RifDataSourceForRftPlt& addr : selectedSourcesExpanded) { - if ( addr.rftReader() ) + if (addr.rftReader()) { - std::set rftTimes = addr.rftReader()->availableTimeSteps(simWellName, { RifEclipseRftAddress::ORAT, - RifEclipseRftAddress::WRAT, - RifEclipseRftAddress::GRAT }); - for ( const QDateTime& time : rftTimes ) + std::set rftTimes = addr.rftReader()->availableTimeSteps( + simWellName, {RifEclipseRftAddress::ORAT, RifEclipseRftAddress::WRAT, RifEclipseRftAddress::GRAT}); + for (const QDateTime& time : rftTimes) { - if ( selectedTimeStepSet.count(time) ) + if (selectedTimeStepSet.count(time)) { curveDefs.insert(RiaRftPltCurveDefinition(addr, time)); } } } - else if ( addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase() ) + else if (addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase()) { - std::set timeSteps = RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid); + std::set timeSteps = + RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid); - for ( const QDateTime& time : timeSteps ) + for (const QDateTime& time : timeSteps) { - if ( selectedTimeStepSet.count(time) ) + if (selectedTimeStepSet.count(time)) { curveDefs.insert(RiaRftPltCurveDefinition(addr, time)); } } } - else if ( addr.sourceType() == RifDataSourceForRftPlt::OBSERVED ) + else if (addr.sourceType() == RifDataSourceForRftPlt::OBSERVED) { - if ( addr.wellLogFile() ) + if (addr.wellLogFile()) { - if ( selectedTimeStepSet.count(addr.wellLogFile()->date()) ) + if (selectedTimeStepSet.count(addr.wellLogFile()->date())) { curveDefs.insert(RiaRftPltCurveDefinition(addr, addr.wellLogFile()->date())); } @@ -680,12 +676,11 @@ std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(c return curveDefs; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition condition, - RiaEclipseUnitTools::UnitSystem unitSystem) +QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition condition, + RiaEclipseUnitTools::UnitSystem unitSystem) { QString axisTitle; @@ -706,7 +701,7 @@ QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString flowConditionReservoirUnitText(RiaEclipseUnitTools::UnitSystem unitSystem) { @@ -714,17 +709,24 @@ QString flowConditionReservoirUnitText(RiaEclipseUnitTools::UnitSystem unitSyste switch (unitSystem) { - case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[m3/day]"; break; - case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Brl/day]"; break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_METRIC: + unitText = "[m3/day]"; + break; + case RiaEclipseUnitTools::UNITS_FIELD: + unitText = "[Brl/day]"; + break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } return unitText; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellPlotTools::flowUnitText(RimWellLogFile::WellFlowCondition condition, RiaEclipseUnitTools::UnitSystem unitSystem) { @@ -738,21 +740,29 @@ QString RimWellPlotTools::flowUnitText(RimWellLogFile::WellFlowCondition conditi { switch (unitSystem) { - case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; break; - case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_METRIC: + unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; + break; + case RiaEclipseUnitTools::UNITS_FIELD: + unitText = "[Liquid BBL/day], [Gas BOE/day]"; + break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } } return unitText; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition, RiaEclipseUnitTools::UnitSystem unitSystem, FlowPhase flowPhase) +QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition, + RiaEclipseUnitTools::UnitSystem unitSystem, + FlowPhase flowPhase) { QString unitText; @@ -767,24 +777,39 @@ QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condit case RiaEclipseUnitTools::UNITS_METRIC: switch (flowPhase) { - case FLOW_PHASE_GAS: unitText = "[kSm3/day]"; break; + case FLOW_PHASE_GAS: + unitText = "[kSm3/day]"; + break; case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: unitText = "[Sm3/day]"; break; - default: unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; break; + case FLOW_PHASE_OIL: + unitText = "[Sm3/day]"; + break; + default: + unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; + break; } break; case RiaEclipseUnitTools::UNITS_FIELD: switch (flowPhase) { - case FLOW_PHASE_GAS: unitText = "[BOE/day]"; break; + case FLOW_PHASE_GAS: + unitText = "[BOE/day]"; + break; case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: unitText = "[BBL/day]"; break; - default: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; + case FLOW_PHASE_OIL: + unitText = "[BBL/day]"; + break; + default: + unitText = "[Liquid BBL/day], [Gas BOE/day]"; + break; } break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } } @@ -938,20 +963,22 @@ std::map> RimWellPlotTools::calculat } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& wellPathNameOrSimWellName, - const std::vector& selSources, - const std::set& interestingRFTResults, - QList& options) +void RimWellPlotTools::calculateValueOptionsForTimeSteps( + const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults, + QList& options) { - auto timestepsToShowWithSources = calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults); + auto timestepsToShowWithSources = + calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults); // Create formatted options of all the time steps QString dateFormatString; { std::vector allTimeSteps; - for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) + for (const std::pair>& timeStepPair : timestepsToShowWithSources) { allTimeSteps.push_back(timeStepPair.first); } @@ -960,17 +987,24 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& wellPath for (const std::pair>& timeStepPair : timestepsToShowWithSources) { - QString optionText = timeStepPair.first.toString(dateFormatString); - bool hasObs = false; - bool hasRft = false; - bool hasGrid = false; + QString optionText = timeStepPair.first.toString(dateFormatString); + bool hasObs = false; + bool hasRft = false; + bool hasGrid = false; - for (const auto& source : timeStepPair.second) + for (const auto& source : timeStepPair.second) { - switch (source.sourceType()){ - case RifDataSourceForRftPlt::OBSERVED: hasObs = true; break; - case RifDataSourceForRftPlt::RFT : hasRft = true; break; - case RifDataSourceForRftPlt::GRID : hasGrid = true; break; + switch (source.sourceType()) + { + case RifDataSourceForRftPlt::OBSERVED: + hasObs = true; + break; + case RifDataSourceForRftPlt::RFT: + hasRft = true; + break; + case RifDataSourceForRftPlt::GRID: + hasGrid = true; + break; } } From b24b93eba331f1726dd43d4aee619eedbe7d7709 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 14:32:31 +0200 Subject: [PATCH 0953/1027] Fix signed / unsigned compare --- .../Summary/RimEnsembleCurveSetColorManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp index e705cf953f..715d78143f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -52,7 +52,7 @@ RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledE size_t modIndex = index % m_ensembleColorRanges.size(); auto crIt = m_ensembleColorRanges.begin(); - for (int i = 0; i < modIndex; ++i) ++crIt; + for (int i = 0; i < static_cast(modIndex); ++i) ++crIt; return crIt->first; } From 38540a0a39bf725af0fb4c5e7de8cb29fd278d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 11 May 2018 15:42:56 +0200 Subject: [PATCH 0954/1027] #2904 Curve creator. .Fix initial curve visibility --- .../RicSummaryCurveCreator.cpp | 57 +++++++++++++------ .../RicSummaryCurveCreator.h | 1 + .../Summary/RimEnsembleCurveSet.cpp | 8 +++ .../Summary/RimEnsembleCurveSet.h | 1 + 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index a7b4800688..6dd1bd75f9 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -147,15 +147,17 @@ void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, c if (m_targetPlot) { populateCurveCreator(*m_targetPlot); + syncPreviewCurvesFromUiSelection(); + setInitialCurveVisibility(targetPlot); + m_previewPlot->loadDataAndUpdate(); } else { setDefaultCurveSelection(defaultCases); m_previewPlot->enableAutoPlotTitle(true); + syncPreviewCurvesFromUiSelection(); } - syncPreviewCurvesFromUiSelection(); - caf::PdmUiItem::updateConnectedEditors(); } @@ -545,20 +547,6 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu } } - // Set visibility for imported curves which were not checked in source plot - std::set > sourceCurveDefs; - for (const auto& curve : sourceSummaryPlot.summaryAndEnsembleCurves()) - { - if(curve->isCurveVisible()) sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); - } - - for (const auto& curve : m_previewPlot->summaryAndEnsembleCurves()) - { - auto curveDef = std::make_pair(curve->summaryCaseY(), curve->summaryAddressY()); - if (sourceCurveDefs.count(curveDef) == 0) - curve->setCurveVisiblity(false); - } - m_previewPlot->copyAxisPropertiesFromOther(sourceSummaryPlot); m_previewPlot->enableAutoPlotTitle(sourceSummaryPlot.autoPlotTitle()); m_previewPlot->updatePlotTitle(); @@ -860,3 +848,40 @@ bool RicSummaryCurveCreator::proxyPlotAutoTitle() const { return m_previewPlot->autoPlotTitle(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::setInitialCurveVisibility(const RimSummaryPlot* targetPlot) +{ + // Set visibility for imported curves which were not checked in source plot + std::set > sourceCurveDefs; + for (const auto& curve : targetPlot->summaryCurves()) + { + sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); + } + + for (const auto& curve : m_previewPlot->summaryCurves()) + { + auto curveDef = std::make_pair(curve->summaryCaseY(), curve->summaryAddressY()); + if (sourceCurveDefs.count(curveDef) == 0) + { + curve->setCurveVisiblity(false); + } + } + + std::set > sourceCurveSetDefs; + for (const auto& curveSet : targetPlot->ensembleCurveSetCollection()->curveSets()) + { + sourceCurveSetDefs.insert(std::make_pair(curveSet->summaryCaseCollection(), curveSet->summaryAddress())); + } + + for (const auto& curveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + auto curveDef = std::make_pair(curveSet->summaryCaseCollection(), curveSet->summaryAddress()); + if (sourceCurveSetDefs.count(curveDef) == 0) + { + curveSet->showCurves(false); + } + } +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index 864bb64f63..b27afbaa4c 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -106,6 +106,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void proxyEnablePlotAutoTitle(const bool& enable); bool proxyPlotAutoTitle() const; + void setInitialCurveVisibility(const RimSummaryPlot* targetPlot); private: caf::PdmPtrField m_targetPlot; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 4289d715d7..c5bc8d61e9 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -866,6 +866,14 @@ RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const return copy; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::showCurves(bool show) +{ + m_showCurves = show; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index ad011ead94..17f25e64b3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -91,6 +91,7 @@ class RimEnsembleCurveSet : public caf::PdmObject void updateAllCurves(); RimEnsembleCurveSet* clone() const; + void showCurves(bool show); private: caf::PdmFieldHandle* userDescriptionField() override; From 4ca931336610780e6cecb4212398c729c686576d Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 11 May 2018 15:13:43 +0200 Subject: [PATCH 0955/1027] #2756 Remove pseudo length as depth type. * That also means there's only option left for PLT-plots: Measured Depth, so may as well remove the drop down list from the UI. --- ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 020ce00d99..d75f5c9b9f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -562,10 +562,9 @@ void RimWellLogPlot::uiOrderingForVisibleDepthRange(caf::PdmUiOrdering& uiOrderi //-------------------------------------------------------------------------------------------------- void RimWellLogPlot::uiOrderingForPlot(caf::PdmUiOrdering& uiOrdering) { - RimWellRftPlot* rftp; - firstAncestorOrThisOfType(rftp); + RimWellRftPlot* rftp = rftPlot(); - if (!rftp) + if (!(rftp || pltPlot())) { uiOrdering.add(&m_depthType); } @@ -883,6 +882,7 @@ void RimWellLogPlot::updateDisabledDepthTypes() else if (isPltPlotChild()) { m_disabledDepthTypes.insert(TRUE_VERTICAL_DEPTH); + m_disabledDepthTypes.insert(PSEUDO_LENGTH); m_disabledDepthTypes.insert(CONNECTION_NUMBER); } else From 3360973e876e84cf82afab2e03ad3bb8c357a8a3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 11 May 2018 15:36:04 +0200 Subject: [PATCH 0956/1027] Use SSOLVENT in calculating SOIL if present --- .../RigCaseCellResultsData.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index fe4e457b3e..e45e05add7 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1270,8 +1270,9 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) // Compute SGAS based on SWAT if the simulation contains no oil testAndComputeSgasForTimeStep(timeStepIndex); - size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); - size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); + size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + size_t scalarIndexSSOLVENT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOLVENT", timeStepIndex); // Early exit if none of SWAT or SGAS is present if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) @@ -1317,8 +1318,9 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) this->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount); - std::vector* swatForTimeStep = nullptr; - std::vector* sgasForTimeStep = nullptr; + std::vector* swatForTimeStep = nullptr; + std::vector* sgasForTimeStep = nullptr; + std::vector* ssolventForTimeStep = nullptr; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { @@ -1338,6 +1340,15 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) } } + if (scalarIndexSSOLVENT != cvf::UNDEFINED_SIZE_T) + { + ssolventForTimeStep = &(this->cellScalarResults(scalarIndexSSOLVENT, timeStepIndex)); + if (ssolventForTimeStep->size() == 0) + { + ssolventForTimeStep = nullptr; + } + } + std::vector& soilForTimeStep = this->cellScalarResults(soilResultScalarIndex, timeStepIndex); #pragma omp parallel for @@ -1354,6 +1365,11 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) soilValue -= swatForTimeStep->at(idx); } + if (ssolventForTimeStep) + { + soilValue -= ssolventForTimeStep->at(idx); + } + soilForTimeStep[idx] = soilValue; } } From 7e54eb055cc4dba8124c6f95cd485132115409a4 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 11 May 2018 14:38:44 +0200 Subject: [PATCH 0957/1027] #2897 Make Export Completion only show up if the user has selected a well path collection or a descendant. --- ...tCompletionsForVisibleWellPathsFeature.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp index 5e1136df8b..7c5fb9adff 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -22,6 +22,8 @@ #include "RicWellPathExportCompletionDataFeature.h" +#include "RiuPlotMainWindow.h" + #include "RimWellPath.h" #include "RimProject.h" #include "RimWellPathCollection.h" @@ -37,6 +39,26 @@ CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCo //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() { + bool foundWellPathCollection = false; + std::vector selectedObjects; + caf::SelectionManager::instance()->objectsByType(&selectedObjects); + for (caf::PdmObject* object : selectedObjects) + { + RimWellPathCollection* wellPathCollection; + + object->firstAncestorOrThisOfType(wellPathCollection); + if (wellPathCollection) + { + foundWellPathCollection = true; + break; + } + } + + if (!foundWellPathCollection) + { + return false; + } + std::vector wellPaths = visibleWellPaths(); if (wellPaths.empty()) From 52047819d68e1aece4873df8f9a48c9674383ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 16:39:57 +0200 Subject: [PATCH 0958/1027] #2891 Convert 2018.01.01 drawstyle from fault to full if it was in none-grid mode Makes the setup more consistent with what they had, and what the user will get when turning the grid back on. --- ApplicationCode/ProjectDataModel/RimGridView.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 5a1b2be9b7..2353dbba16 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -286,6 +286,14 @@ void RimGridView::initAfterRead() bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RimGridView::FULL_MESH)); m_gridCollection->isActive = isGridVisualizationModeBefore_2018_1_1; + if (!isGridVisualizationModeBefore_2018_1_1) + { + // Was showing faults and intersections. + // If was showing with mesh and/or surfaces, turn to full mesh/surf mode to show the mesh, + // and to avoid a strange setup when dropping out into grid mode again + if (surfaceMode() != RimGridView::NO_SURFACE) surfaceMode = RimGridView::SURFACE; + if (meshMode() != RimGridView::NO_MESH) meshMode = RimGridView::FULL_MESH; + } } } From f75995e9333b5731ac0eda998ef302312ef0286c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 15:05:12 +0200 Subject: [PATCH 0959/1027] #2903 Plot Name and Legend Text : Rebuild legends if ensemble is toggled --- ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index c5bc8d61e9..18a24b04be 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -452,6 +452,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (changedField == &m_isUsingAutoName || changedField == &m_userDefinedName || + changedField == &m_showCurves || changedField == &m_colorMode || changedField == &m_color) { From 4c1bcf96138619bc3594b2a57a6468a9bfc4a495 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 19:29:03 +0200 Subject: [PATCH 0960/1027] #2903 Plot Name and Legend Text : Update all plot text when curve changes --- .../Summary/RimEnsembleCurveSet.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 18a24b04be..5c1b49f672 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -365,6 +365,8 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie firstAncestorOrThisOfType(plot); CVF_ASSERT(plot); + bool updateTextInPlot = false; + if (changedField == &m_showCurves) { loadDataAndUpdate(true); @@ -374,22 +376,27 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie RimSummaryPlot* summaryPlot = nullptr; this->firstAncestorOrThisOfTypeAsserted(summaryPlot); summaryPlot->updateConnectedEditors(); + + updateTextInPlot = true; } else if (changedField == &m_yValuesUiFilterResultSelection) { m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection()); updateAllCurves(); + updateTextInPlot = true; } else if (changedField == &m_yValuesSummaryGroup) { // Empty address cache m_allAddressesCache.clear(); updateAllCurves(); + updateTextInPlot = true; } else if (changedField == &m_color) { updateCurveColors(); + updateTextInPlot = true; } else if (changedField == &m_ensembleParameter) { @@ -413,10 +420,16 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } updateQwtPlotAxis(); plot->updateAxes(); + updateTextInPlot = true; } else if (changedField == &m_isUsingAutoName && !m_isUsingAutoName) { - m_userDefinedName = createAutoName(); + if (!m_isUsingAutoName) + { + m_userDefinedName = createAutoName(); + } + + updateTextInPlot = true; } else if (changedField == &m_yPushButtonSelectSummaryAddress) { @@ -449,12 +462,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie m_yPushButtonSelectSummaryAddress = false; } - - if (changedField == &m_isUsingAutoName || - changedField == &m_userDefinedName || - changedField == &m_showCurves || - changedField == &m_colorMode || - changedField == &m_color) + if (updateTextInPlot) { updateEnsembleLegendItem(); @@ -462,7 +470,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie this->firstAncestorOrThisOfTypeAsserted(summaryPlot); if (summaryPlot->qwtPlot()) { - summaryPlot->qwtPlot()->updateLegend(); + summaryPlot->updatePlotTitle(); } } } From 4bd7b1eeb67c3f18a6ccdc0d993e3d7489eb2aa7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 19:44:01 +0200 Subject: [PATCH 0961/1027] #2903 Plot Name and Legend Text : Add updateAllTextInPlot --- .../Summary/RimEnsembleCurveSet.cpp | 30 +++++++++++++------ .../Summary/RimEnsembleCurveSet.h | 2 ++ .../Summary/RimSummaryCurveAutoName.cpp | 1 + 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5c1b49f672..984757ddad 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -422,7 +422,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie plot->updateAxes(); updateTextInPlot = true; } - else if (changedField == &m_isUsingAutoName && !m_isUsingAutoName) + else if (changedField == &m_isUsingAutoName) { if (!m_isUsingAutoName) { @@ -431,6 +431,10 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie updateTextInPlot = true; } + else if (changedField == &m_userDefinedName) + { + updateTextInPlot = true; + } else if (changedField == &m_yPushButtonSelectSummaryAddress) { RiuSummaryCurveDefSelectionDialog dlg(nullptr); @@ -464,14 +468,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (updateTextInPlot) { - updateEnsembleLegendItem(); - - RimSummaryPlot* summaryPlot = nullptr; - this->firstAncestorOrThisOfTypeAsserted(summaryPlot); - if (summaryPlot->qwtPlot()) - { - summaryPlot->updatePlotTitle(); - } + updateAllTextInPlot(); } } @@ -883,6 +880,21 @@ void RimEnsembleCurveSet::showCurves(bool show) m_showCurves = show; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateAllTextInPlot() +{ + updateEnsembleLegendItem(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + if (summaryPlot->qwtPlot()) + { + summaryPlot->updatePlotTitle(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 17f25e64b3..5bbf20760b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -93,6 +93,8 @@ class RimEnsembleCurveSet : public caf::PdmObject RimEnsembleCurveSet* clone() const; void showCurves(bool show); + void updateAllTextInPlot(); + private: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index d257dc9fa3..8a84b18399 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -362,6 +362,7 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change auto ensembleCurveSet = dynamic_cast(this->parentField()->ownerObject()); if (ensembleCurveSet) { + ensembleCurveSet->updateAllTextInPlot(); ensembleCurveSet->updateConnectedEditors(); return; From 2cb123474b801655e6bc00b84aa0b8883b542470 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 19:49:47 +0200 Subject: [PATCH 0962/1027] Use const reference and use empty() --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 984757ddad..ea147ee33f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -276,7 +276,7 @@ std::vector RimEnsembleCurveSet::visibleCurves() const { std::vector visible; - for (auto c : m_curves) + for (const auto& c : m_curves) { if (c->isCurveVisible()) { @@ -447,7 +447,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (dlg.exec() == QDialog::Accepted) { auto curveSelection = dlg.curveSelection(); - if (curveSelection.size() > 0) + if (!curveSelection.empty()) { m_yValuesSummaryGroup = curveSelection[0].ensemble(); m_yValuesCurveVariable->setAddress(curveSelection[0].summaryAddress()); @@ -603,7 +603,7 @@ QList RimEnsembleCurveSet::calculateValueOptions(const c } else if (fieldNeedingOptions == &m_ensembleParameter) { - for (auto param : ensembleParameters()) + for (const auto& param : ensembleParameters()) { options.push_back(caf::PdmOptionItemInfo(param, param)); } @@ -628,9 +628,7 @@ void RimEnsembleCurveSet::getOptionsForSummaryAddresses(std::mapsummaryReader(); if (reader) { - const std::vector allAddresses = reader->allResultAddresses(); - - for (auto& address : allAddresses) + for (const auto& address : reader->allResultAddresses()) { if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; From 078191610cbd96401709642b3f87a4b0924379e8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 20:21:44 +0200 Subject: [PATCH 0963/1027] #2903 Plot Name and Legend Text : Fix update of ensembles from curve creator --- .../Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp | 4 ++++ .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 6dd1bd75f9..375b4f3348 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -590,11 +590,15 @@ void RicSummaryCurveCreator::updateTargetPlot() { copyEnsembleCurveAndAddToCurveSet(editedCurve, editedCurveSet); } + + newCurveSet->setParentQwtPlotNoReplot(m_targetPlot->qwtPlot()); } m_targetPlot->enableAutoPlotTitle(m_useAutoPlotTitleProxy()); m_targetPlot->loadDataAndUpdate(); + + m_targetPlot->updatePlotTitle(); m_targetPlot->updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index ea147ee33f..b119eb8ce3 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -158,8 +158,11 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet() firstAncestorOrThisOfType(parentPlot); if (parentPlot && parentPlot->qwtPlot()) { + m_qwtPlotCurveForLegendText->detach(); parentPlot->qwtPlot()->removeEnsembleCurveSetLegend(this); } + + delete m_qwtPlotCurveForLegendText; } //-------------------------------------------------------------------------------------------------- From f22dcf0872521001df9f7628891704ce92b3259f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 11 May 2018 22:23:06 +0200 Subject: [PATCH 0964/1027] #2903 Plot Name and Legend Text : Update text when color mode changes --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index b119eb8ce3..67ebac45ad 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -387,6 +387,7 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection()); updateAllCurves(); + updateTextInPlot = true; } else if (changedField == &m_yValuesSummaryGroup) @@ -394,11 +395,13 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie // Empty address cache m_allAddressesCache.clear(); updateAllCurves(); + updateTextInPlot = true; } else if (changedField == &m_color) { updateCurveColors(); + updateTextInPlot = true; } else if (changedField == &m_ensembleParameter) @@ -414,6 +417,8 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie m_ensembleParameter = !params.empty() ? params.front() : ""; } updateCurveColors(); + + updateTextInPlot = true; } else if (changedField == &m_plotAxis) { @@ -421,8 +426,10 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { curve->setLeftOrRightAxisY(m_plotAxis()); } + updateQwtPlotAxis(); plot->updateAxes(); + updateTextInPlot = true; } else if (changedField == &m_isUsingAutoName) From 17226dabbcc374954e7dd229a6c85a0f2f82af1b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 09:20:47 +0200 Subject: [PATCH 0965/1027] #2908 Ensemble Curve Sets: Use legend icon for colorlegend-using icon in the normal curve legend --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 67ebac45ad..ad25822fe8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -922,13 +922,17 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem() curvePen.setWidth(2); symbol->setPen(curvePen); + symbol->setSize(6, 6); } else if (m_colorMode == BY_ENSEMBLE_PARAM) { - symbol = new QwtSymbol(QwtSymbol::Star1); + QPixmap p = QPixmap(":/Legend.png"); + + symbol = new QwtSymbol; + symbol->setPixmap(p); + symbol->setSize(8, 8); } - symbol->setSize(6, 6); m_qwtPlotCurveForLegendText->setSymbol(symbol); } From 090a79cf906d41ff6e729e3540b41c879bdc77c5 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 14 May 2018 09:27:38 +0200 Subject: [PATCH 0966/1027] #2854 UNRST and EGRID file matching confused by . in basename * Need to send in QFileInfo::completeBaseName() rather than just baseName() * The change will cause libECL to match only files where the base name is everything except what is after the LAST dot. --- ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 898b003a4d..e36114342d 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -274,7 +274,7 @@ bool RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(const QString& QString filePath = QFileInfo(fullPathFileName).absoluteFilePath(); filePath = QFileInfo(filePath).path(); - QString fileNameBase = QFileInfo(fullPathFileName).baseName(); + QString fileNameBase = QFileInfo(fullPathFileName).completeBaseName(); stringlist_type* eclipseFiles = stringlist_alloc_new(); ecl_util_select_filelist(RiaStringEncodingTools::toNativeEncoded(filePath).data(), RiaStringEncodingTools::toNativeEncoded(fileNameBase).data(), ECL_OTHER_FILE, false, eclipseFiles); From dc319646b2fbe9b14f74fe806087db7a39bc7785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 14 May 2018 09:51:06 +0200 Subject: [PATCH 0967/1027] #2658 Ensemble curves. Fix curve set coloring. Minor fixes.Some ClangFormat auto-changes --- .../RicSummaryCurveCreator.cpp | 228 ++++++++++-------- .../Summary/RimSummaryPlot.cpp | 8 +- 2 files changed, 131 insertions(+), 105 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 375b4f3348..5d8e8df56e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016 Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,6 +19,7 @@ #include "RicSummaryCurveCreator.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaSummaryCurveDefinition.h" #include "RicSelectSummaryPlotUI.h" @@ -26,11 +27,15 @@ #include "RifReaderEclipseSummary.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" #include "RimMainPlotCollection.h" #include "RimObservedData.h" #include "RimObservedDataCollection.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -39,9 +44,6 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RimSummaryCalculationCollection.h" -#include "RimEnsembleCurveSetCollection.h" -#include "RimEnsembleCurveSet.h" #include "RiuPlotMainWindowTools.h" #include "RiuSummaryCurveDefSelection.h" @@ -56,16 +58,15 @@ #include #include - CAF_PDM_SOURCE_INIT(RicSummaryCurveCreator, "RicSummaryCurveCreator"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const QString RicSummaryCurveCreator::CONFIGURATION_NAME = "CurveCreatorCfg"; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RicSummaryCurveCreator::RicSummaryCurveCreator() { @@ -111,20 +112,18 @@ RicSummaryCurveCreator::RicSummaryCurveCreator() m_summaryCurveSelectionEditor.reset(new RiuSummaryCurveDefSelectionEditor()); - m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler([this]() { this->selectionEditorFieldChanged(); }); + m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler( + [this]() { this->selectionEditorFieldChanged(); }); m_summaryCurveSelectionEditor->summaryAddressSelection()->setMultiSelectionMode(true); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCreator::~RicSummaryCurveCreator() -{ -} +RicSummaryCurveCreator::~RicSummaryCurveCreator() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryPlot* RicSummaryCurveCreator::previewPlot() const { @@ -132,7 +131,7 @@ RimSummaryPlot* RicSummaryCurveCreator::previewPlot() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, const std::vector& defaultCases) { @@ -140,8 +139,8 @@ void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, c { resetAllFields(); } - - m_targetPlot = targetPlot; + + m_targetPlot = targetPlot; m_useAutoAppearanceAssignment = true; if (m_targetPlot) @@ -162,7 +161,7 @@ void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, c } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RicSummaryCurveCreator::addressSelectionWidget(QWidget* parent) { @@ -170,7 +169,7 @@ QWidget* RicSummaryCurveCreator::addressSelectionWidget(QWidget* parent) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicSummaryCurveCreator::isCloseButtonPressed() const { @@ -178,7 +177,7 @@ bool RicSummaryCurveCreator::isCloseButtonPressed() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::clearCloseButton() { @@ -186,9 +185,11 @@ void RicSummaryCurveCreator::clearCloseButton() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { if (changedField == &m_applyButtonField || changedField == &m_okButtonField) { @@ -209,7 +210,7 @@ void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changed } m_applyButtonField = false; - m_okButtonField = false; + m_okButtonField = false; caf::PdmField* field = dynamic_cast*>(m_targetPlot->uiCapability()->objectToggleField()); field->setValueWithFieldChanged(true); @@ -233,16 +234,17 @@ void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changed } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RicSummaryCurveCreator::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RicSummaryCurveCreator::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; if (fieldNeedingOptions == &m_targetPlot) { RimProject* proj = RiaApplication::instance()->project(); - + RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection(); // Create New Plot item @@ -259,12 +261,13 @@ QList RicSummaryCurveCreator::calculateValueOptions(cons } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { // Appearance settings - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroupWithKeyword("Curve Appearance Assignment", RiuSummaryCurveDefinitionKeywords::appearance()); + caf::PdmUiGroup* appearanceGroup = + uiOrdering.addNewGroupWithKeyword("Curve Appearance Assignment", RiuSummaryCurveDefinitionKeywords::appearance()); caf::PdmUiGroup* appearanceSubGroup = appearanceGroup->addNewGroup("Appearance Type Assignment"); appearanceSubGroup->setCollapsedByDefault(true); @@ -288,7 +291,8 @@ void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOr } // Name config - caf::PdmUiGroup* autoNameGroup = uiOrdering.addNewGroupWithKeyword("Plot and Curve Name Configuration", RiuSummaryCurveDefinitionKeywords::nameConfig()); + caf::PdmUiGroup* autoNameGroup = + uiOrdering.addNewGroupWithKeyword("Plot and Curve Name Configuration", RiuSummaryCurveDefinitionKeywords::nameConfig()); autoNameGroup->setCollapsedByDefault(true); autoNameGroup->add(&m_useAutoPlotTitleProxy); @@ -313,41 +317,46 @@ void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() { - std::vector allCurveDefinitionsVector = m_summaryCurveSelectionEditor->summaryAddressSelection()->selectedCurveDefinitions(); - std::set allCurveDefinitions = std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); + std::vector allCurveDefinitionsVector = + m_summaryCurveSelectionEditor->summaryAddressSelection()->selectedCurveDefinitions(); + std::set allCurveDefinitions = + std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); std::vector currentCurvesInPreviewPlot = m_previewPlot->summaryAndEnsembleCurves(); if (allCurveDefinitions.size() != currentCurvesInPreviewPlot.size()) { std::set currentCurveDefs; std::set newCurveDefs; - std::set curvesToDelete; + std::set curvesToDelete; for (const auto& curve : currentCurvesInPreviewPlot) { currentCurveDefs.insert(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); } - + if (allCurveDefinitions.size() < currentCurvesInPreviewPlot.size()) { // Determine which curves to delete from plot std::set deleteCurveDefs; - std::set_difference(currentCurveDefs.begin(), currentCurveDefs.end(), - allCurveDefinitions.begin(), allCurveDefinitions.end(), + std::set_difference(currentCurveDefs.begin(), + currentCurveDefs.end(), + allCurveDefinitions.begin(), + allCurveDefinitions.end(), std::inserter(deleteCurveDefs, deleteCurveDefs.end())); for (const auto& curve : currentCurvesInPreviewPlot) { RiaSummaryCurveDefinition curveDef = RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY()); - if (deleteCurveDefs.count(curveDef) > 0) - curvesToDelete.insert(curve); + if (deleteCurveDefs.count(curveDef) > 0) curvesToDelete.insert(curve); } } else { // Determine which curves are new since last time - std::set_difference(allCurveDefinitions.begin(), allCurveDefinitions.end(), - currentCurveDefs.begin(), currentCurveDefs.end(), + std::set_difference(allCurveDefinitions.begin(), + allCurveDefinitions.end(), + currentCurveDefs.begin(), + currentCurveDefs.end(), std::inserter(newCurveDefs, newCurveDefs.end())); } @@ -356,15 +365,22 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std::set& allCurveDefsToDisplay, +void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std::set& allCurveDefsToDisplay, const std::set& curveDefsToAdd, - const std::set& curvesToDelete) + const std::set& curvesToDelete) { - RimSummaryCase* prevCase = nullptr; - RimSummaryCurveAppearanceCalculator curveLookCalc(allCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); + RimSummaryCase* prevCase = nullptr; + std::set summaryCurveDefsToDisplay; + + // Ignore curve sets when assigning colors to singe summary curves + for (const auto& def : allCurveDefsToDisplay) + { + if (!def.isEnsembleCurve()) summaryCurveDefsToDisplay.insert(def); + } + RimSummaryCurveAppearanceCalculator curveLookCalc(summaryCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); // Delete curves @@ -376,8 +392,8 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: // Add new curves for (const auto& curveDef : curveDefsToAdd) { - RimSummaryCase* currentCase = curveDef.summaryCase(); - RimSummaryCurve* curve = new RimSummaryCurve(); + RimSummaryCase* currentCase = curveDef.summaryCase(); + RimSummaryCurve* curve = new RimSummaryCurve(); curve->setSummaryCaseY(currentCase); curve->setSummaryAddressY(curveDef.summaryAddress()); curve->applyCurveAutoNameSettings(*m_curveNameConfig()); @@ -400,6 +416,10 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: curveSet->setSummaryCaseCollection(curveDef.ensemble()); curveSet->setSummaryAddress(curveDef.summaryAddress()); m_previewPlot->ensembleCurveSetCollection()->addCurveSet(curveSet); + + // Set single curve set color + size_t colorIndex = m_previewPlot->ensembleCurveSetCollection()->curveSetCount(); + curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); } curveSet->addCurve(curve); } @@ -417,13 +437,13 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::getAllSummaryCaseNames() { std::set summaryCaseHashes; - RimProject* proj = RiaApplication::instance()->project(); - + RimProject* proj = RiaApplication::instance()->project(); + std::vector cases = proj->allSummaryCases(); for (RimSummaryCase* rimCase : cases) { @@ -434,12 +454,12 @@ std::set RicSummaryCurveCreator::getAllSummaryCaseNames() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::getAllSummaryWellNames() { std::set summaryWellNames; - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); std::vector cases = proj->allSummaryCases(); for (RimSummaryCase* rimCase : cases) @@ -467,13 +487,15 @@ std::set RicSummaryCurveCreator::getAllSummaryWellNames() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) { if (&m_applyButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Apply"; @@ -481,7 +503,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_closeButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Cancel"; @@ -489,7 +511,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_okButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "OK"; @@ -497,7 +519,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_appearanceApplyButton == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Apply"; @@ -505,7 +527,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_targetPlot == field) { - caf::PdmUiComboBoxEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiComboBoxEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->adjustWidthToContents = true; @@ -562,7 +584,7 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateTargetPlot() { - if (m_targetPlot == nullptr) m_targetPlot = new RimSummaryPlot(); + if (m_targetPlot == nullptr) m_targetPlot = new RimSummaryPlot(); m_targetPlot->deleteAllSummaryCurves(); m_targetPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); @@ -590,7 +612,7 @@ void RicSummaryCurveCreator::updateTargetPlot() { copyEnsembleCurveAndAddToCurveSet(editedCurve, editedCurveSet); } - + newCurveSet->setParentQwtPlotNoReplot(m_targetPlot->qwtPlot()); } @@ -603,14 +625,15 @@ void RicSummaryCurveCreator::updateTargetPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible) +void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible) { - RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + RimSummaryCurve* curveCopy = + dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); - if (forceVisible) + if (forceVisible) { curveCopy->setCurveVisiblity(true); } @@ -624,11 +647,14 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible) +void RicSummaryCurveCreator::copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve* curve, + RimEnsembleCurveSet* curveSet, + bool forceVisible) { - RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + RimSummaryCurve* curveCopy = + dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); if (forceVisible) @@ -645,7 +671,7 @@ void RicSummaryCurveCreator::copyEnsembleCurveAndAddToCurveSet(const RimSummaryC } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::setDefaultCurveSelection(const std::vector& defaultCases) { @@ -653,7 +679,7 @@ void RicSummaryCurveCreator::setDefaultCurveSelection(const std::vector allCurveDefs = allPreviewCurveDefs(); - + RimSummaryCurveAppearanceCalculator curveLookCalc(allCurveDefs, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); @@ -717,7 +739,7 @@ void RicSummaryCurveCreator::applyAppearanceToAllPreviewCurves() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateAppearanceEditor() { @@ -728,7 +750,7 @@ void RicSummaryCurveCreator::updateAppearanceEditor() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::allPreviewCurveDefs() const { @@ -742,7 +764,7 @@ std::set RicSummaryCurveCreator::allPreviewCurveDefs( } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::createNewPlot() { @@ -764,14 +786,14 @@ void RicSummaryCurveCreator::createNewPlot() candidatePlotName = m_previewPlot->generatedPlotTitleFromVisibleCurves(); } - { - bool ok = false; + bool ok = false; candidatePlotName = QInputDialog::getText(nullptr, - "New Summary Plot Name", "New Summary Plot Name", + "New Summary Plot Name", + "New Summary Plot Name", QLineEdit::Normal, - candidatePlotName, - &ok, + candidatePlotName, + &ok, RiuTools::defaultDialogFlags()); if (!ok) { @@ -795,7 +817,7 @@ void RicSummaryCurveCreator::createNewPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateCurveNames() { @@ -805,19 +827,19 @@ void RicSummaryCurveCreator::updateCurveNames() curve->updateCurveNameNoLegendUpdate(); } - if (m_previewPlot && m_previewPlot->qwtPlot()) m_previewPlot->qwtPlot()->updateLegend(); + if (m_previewPlot && m_previewPlot->qwtPlot()) m_previewPlot->qwtPlot()->updateLegend(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCurveCreator::isObservedData(RimSummaryCase *sumCase) const +bool RicSummaryCurveCreator::isObservedData(RimSummaryCase* sumCase) const { return dynamic_cast(sumCase) != nullptr; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCase* RicSummaryCurveCreator::calculatedSummaryCase() { @@ -827,7 +849,7 @@ RimSummaryCase* RicSummaryCurveCreator::calculatedSummaryCase() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::selectionEditorFieldChanged() { @@ -835,7 +857,7 @@ void RicSummaryCurveCreator::selectionEditorFieldChanged() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::proxyEnablePlotAutoTitle(const bool& enable) { @@ -846,7 +868,7 @@ void RicSummaryCurveCreator::proxyEnablePlotAutoTitle(const bool& enable) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicSummaryCurveCreator::proxyPlotAutoTitle() const { @@ -854,12 +876,12 @@ bool RicSummaryCurveCreator::proxyPlotAutoTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::setInitialCurveVisibility(const RimSummaryPlot* targetPlot) { // Set visibility for imported curves which were not checked in source plot - std::set > sourceCurveDefs; + std::set> sourceCurveDefs; for (const auto& curve : targetPlot->summaryCurves()) { sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); @@ -874,7 +896,7 @@ void RicSummaryCurveCreator::setInitialCurveVisibility(const RimSummaryPlot* tar } } - std::set > sourceCurveSetDefs; + std::set> sourceCurveSetDefs; for (const auto& curveSet : targetPlot->ensembleCurveSetCollection()->curveSets()) { sourceCurveSetDefs.insert(std::make_pair(curveSet->summaryCaseCollection(), curveSet->summaryAddress())); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 76199aacdc..95287dfc87 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1004,6 +1004,10 @@ void RimSummaryPlot::deleteCurve(RimSummaryCurve* curve) curveSet->deleteCurve(curve); if (curveSet->curves().empty()) { + if (curveSet->colorMode() == RimEnsembleCurveSet::BY_ENSEMBLE_PARAM) + { + qwtPlot()->removeEnsembleCurveSetLegend(curveSet); + } m_ensembleCurveSetCollection->deleteCurveSet(curveSet); } return; @@ -1189,7 +1193,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering if (uiConfigName == RicSummaryCurveCreator::CONFIGURATION_NAME) { uiTreeOrdering.add(&m_summaryCurveCollection); - if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) + if (!m_isCrossPlot) { uiTreeOrdering.add(&m_ensembleCurveSetCollection); } @@ -1210,7 +1214,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering axisFolder->add(&m_rightYAxisProperties); uiTreeOrdering.add(&m_summaryCurveCollection); - if (!m_isCrossPlot && !m_ensembleCurveSetCollection->curveSets().empty()) + if (!m_isCrossPlot) { uiTreeOrdering.add(&m_ensembleCurveSetCollection); } From 551c74cd28b545b2934b7dc21ee71ddedf7deab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 14 May 2018 10:07:58 +0200 Subject: [PATCH 0968/1027] Import Summary Case Group : Fix dialog title --- ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp index 9b947f2449..fb3c3f9647 100644 --- a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp @@ -61,7 +61,7 @@ bool RicImportSummaryGroupFeature::isCommandEnabled() void RicImportSummaryGroupFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); - QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble"); + QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Summary Case Group"); if (fileNames.isEmpty()) return; From 0982af4ad0b64d76dcd1cb1de072f3a31c1824f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 14 May 2018 10:11:00 +0200 Subject: [PATCH 0969/1027] #2856 Import menu: Fix wrong position of wellpicks vs formation names Moved geomech below eclipse. --- .../UserInterface/RiuMainWindow.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index bce08755b9..40a90f3567 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -370,7 +370,6 @@ void RiuMainWindow::createMenus() fileMenu->addAction(cmdFeatureMgr->action("RicOpenLastUsedFileFeature")); fileMenu->addSeparator(); - QMenu* importMenu = fileMenu->addMenu("&Import"); QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); @@ -381,13 +380,6 @@ void RiuMainWindow::createMenus() importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); - #ifdef USE_ODB_API - importMenu->addSeparator(); - QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); - importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); - importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); - #endif - importMenu->addSeparator(); QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); @@ -395,16 +387,23 @@ void RiuMainWindow::createMenus() importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature")); importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + #ifdef USE_ODB_API + importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); + #endif + importMenu->addSeparator(); QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data"); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); - importWellMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); importMenu->addSeparator(); importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); From ae8fa06e4d88b5506a8126570399ada5bea6e845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 14 May 2018 10:14:13 +0200 Subject: [PATCH 0970/1027] #2909 RFT Plot: Created icons --- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 2 +- .../ProjectDataModel/RimRftPlotCollection.cpp | 2 +- ApplicationCode/Resources/RFTPlot16x16.png | Bin 0 -> 873 bytes ApplicationCode/Resources/RFTPlots16x16.png | Bin 0 -> 863 bytes ApplicationCode/Resources/ResInsight.qrc | 2 ++ 5 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 ApplicationCode/Resources/RFTPlot16x16.png create mode 100644 ApplicationCode/Resources/RFTPlots16x16.png diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 0bcee43d44..98e0371597 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -70,7 +70,7 @@ const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1"; //-------------------------------------------------------------------------------------------------- RimWellRftPlot::RimWellRftPlot() { - CAF_PDM_InitObject("Well Allocation Plot", ":/FlowCharPlot16x16.png", "", ""); + CAF_PDM_InitObject("Well Allocation Plot", ":/RFTPlot16x16.png", "", ""); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("RFT Plot"), "Name", "", "", ""); m_userName.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp index 9f31899811..ede492a3b0 100644 --- a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimRftPlotCollection, "WellRftPlotCollection"); //-------------------------------------------------------------------------------------------------- RimRftPlotCollection::RimRftPlotCollection() { - CAF_PDM_InitObject("RFT Plots", ":/WellLogPlots16x16.png", "", ""); + CAF_PDM_InitObject("RFT Plots", ":/RFTPlots16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_rftPlots, "RftPlots", "", "", "", ""); m_rftPlots.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/Resources/RFTPlot16x16.png b/ApplicationCode/Resources/RFTPlot16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..31adc3ecf8f378b7b05138399af9823576495d7b GIT binary patch literal 873 zcmV-v1D5=WP)Qxi03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00PZPL_t(I%cYaQYa4eM z#y=3!OW5DfF+%RNSEm8oHE(4oM-D zfD{~%L~;eYmL*v~awjSAT_wx%y&c>LI_H_5;pOFhKRk~nBEknKR(pNKJFkzfD^%Rz z_{iat;wD$~Oa4AN;j=HkCbA20r-n94J~ zxWF_`0DRxawv&WcA?LnNDwSd~nV^(nKA)3Lr$IuIpC0}!)oN8lM7rIsh=_du>$lSF zcBNS^i-<_C*OO+sEZyhN<-G=jfy8?K9&)8I@H~Pbpx^KF*RW1!*rN698OyU7K@f2K z4La`eVwEwxV6by>N47hTs;qY+D`5=tp7 z%Oa6TU>F85+qN;34uDb$(=_S4J!Lbug&OJCe**D%{CbgLU>L??K31tz7`QIENQ8E~ zO{3AE)ob!;{&UXG>Vyv-klEj-v%XGPt>Qm@ic$)t6c@X@5Qd=~92_hldY&iW{P^|4 zH_K%i9v(`o)e;er>2xY0at*ZGm6-F|A(cuo@I1!jF^{Xiad~;gcs!VNk2FR4NfpCiuf4k*(4enx>JpI_k^#huw6Z1TBH*YTBhS4Y=-MK?N9tR*2i4gN# zkBixi;c!U1-DWfzG3uPte)J2yUXSG79>ITbZ;Z#djRuxwVObXM&d-SzJ}ywN*T`ft z6bc3QcK2CcxAD_y3is}j$z%Zd=hZ6`=`{JBoy7&U!WFU8GbZ8()Nlj2>E@cM*00P5FL_t(I%cavzXdGn# z#_|7ry)&ELX0yqDCAbNuO{P$&r@$&=R0<-3B%mOkdXN?ra_g<<-W16pU|4;9*Gw@sq?Xu6r~W_ETm+nr?h^GzID`xV19LZO;^+tLn0&ofkE9=5`kFm=7tderi+UAubWpGIG}d*`lf22ClYlpp>0 zq1-BbEv1xlvsjcnOG{EpDQmTw2aM~F%NcpB|N58LNpvTu98{=mtkF#P$h8&1tu4B8 zgPgT(c6WCVfM@=TEQ`gWbR0(lQ~HtIdte#g&ELS(1a-sZ_tG-@KpSs*1+!YEol0}o zw%OU<=G&PW%=70x0Da%{dOrQ&@^7x|Udlh4=i=oHyqkTI%GfKUJ&)4nCNED-v9Pef z+}s=!6BER9Ir@5gn*b^xt9!Le!%q)WSo)l(77|7*hKGjOTVH2nd>r5R$)-}=o1f?Y zty_pp1|uF<0MvLSdSIF6o5{W;W#u7+HE}3#1H~S(}Kmt#h*v*(HMXl zG=ruo#Ox2t-w-ik1iLPQ<8bWMDeAXxQ{UJicJkz3vg?XMp-`WknEVVt?MM_wQO@lj z`n>WellFlowPlot16x16.png WellAllocPie16x16.png WellAllocLegend16x16.png + RFTPlot16x16.png + RFTPlots16x16.png FractureLayout16x16.png FractureSymbol16x16.png FractureTemplate16x16.png From f31bef92c18ad06d36ea4383bf87ec5aa2cc91b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 14 May 2018 10:18:52 +0200 Subject: [PATCH 0971/1027] #2910 Summary Groups: Set default group name to "Group" --- .../ProjectDataModel/Summary/RimSummaryCaseCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 1f3d8d8229..7b1e2fa776 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -37,7 +37,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); m_cases.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Case Group"), "Name", "", "", ""); + CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Group"), "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_nameAndItemCount, "NameCount", "Name", "", "", ""); m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount); From 956d221c48b4895ff818bcd4f66cd179a43ce376 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 14 May 2018 10:19:54 +0200 Subject: [PATCH 0972/1027] #2878 Use correct keyword for solvent data (SSOL not SSOLVENT) --- .../RigCaseCellResultsData.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index e45e05add7..f7bbe9defe 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1272,7 +1272,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); - size_t scalarIndexSSOLVENT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOLVENT", timeStepIndex); + size_t scalarIndexSSOL = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOL", timeStepIndex); // Early exit if none of SWAT or SGAS is present if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) @@ -1320,7 +1320,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) std::vector* swatForTimeStep = nullptr; std::vector* sgasForTimeStep = nullptr; - std::vector* ssolventForTimeStep = nullptr; + std::vector* ssolForTimeStep = nullptr; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { @@ -1340,12 +1340,12 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) } } - if (scalarIndexSSOLVENT != cvf::UNDEFINED_SIZE_T) + if (scalarIndexSSOL != cvf::UNDEFINED_SIZE_T) { - ssolventForTimeStep = &(this->cellScalarResults(scalarIndexSSOLVENT, timeStepIndex)); - if (ssolventForTimeStep->size() == 0) + ssolForTimeStep = &(this->cellScalarResults(scalarIndexSSOL, timeStepIndex)); + if (ssolForTimeStep->size() == 0) { - ssolventForTimeStep = nullptr; + ssolForTimeStep = nullptr; } } @@ -1365,9 +1365,9 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) soilValue -= swatForTimeStep->at(idx); } - if (ssolventForTimeStep) + if (ssolForTimeStep) { - soilValue -= ssolventForTimeStep->at(idx); + soilValue -= ssolForTimeStep->at(idx); } soilForTimeStep[idx] = soilValue; From 7c0017923c9e6a0391d43a4dfd1c476d0b6ab107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 14 May 2018 14:51:52 +0200 Subject: [PATCH 0973/1027] #2658 Ensemble curves. Warning when too many ensemble curves --- .../Application/RiaSummaryCurveDefinition.cpp | 17 +++++++ .../Application/RiaSummaryCurveDefinition.h | 3 ++ .../RicSummaryCurveCreator.cpp | 46 +++++++++++++++++-- .../RicSummaryCurveCreator.h | 3 +- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index 9f114937d6..2194af40e1 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -21,6 +21,15 @@ #include "RifSummaryReaderInterface.h" #include "RimSummaryCase.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition() +{ + m_curveDefinition = std::make_pair(nullptr, RifEclipseSummaryAddress()); + m_ensemble = nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -64,6 +73,14 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const return m_ensemble != nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryCurveDefinition::isValid() const +{ + return m_curveDefinition.first != nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.h b/ApplicationCode/Application/RiaSummaryCurveDefinition.h index 608a5f3951..2e8d62a879 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.h @@ -34,6 +34,7 @@ class RimSummaryCaseCollection; class RiaSummaryCurveDefinition { public: + RiaSummaryCurveDefinition(); explicit RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress, RimSummaryCaseCollection* emsemble = nullptr); @@ -43,6 +44,8 @@ class RiaSummaryCurveDefinition RimSummaryCaseCollection* ensemble() const; bool isEnsembleCurve() const; + bool isValid() const; + bool operator < (const RiaSummaryCurveDefinition& other) const; // TODO: Consider moving to a separate tools class diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 5d8e8df56e..94ca875076 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -54,6 +54,7 @@ #include "cafPdmUiPushButtonEditor.h" #include +#include #include #include @@ -65,6 +66,11 @@ CAF_PDM_SOURCE_INIT(RicSummaryCurveCreator, "RicSummaryCurveCreator"); //-------------------------------------------------------------------------------------------------- const QString RicSummaryCurveCreator::CONFIGURATION_NAME = "CurveCreatorCfg"; +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +int ensembleCurveCount(const std::set& allCurveDefs); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -367,10 +373,14 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std::set& allCurveDefsToDisplay, - const std::set& curveDefsToAdd, - const std::set& curvesToDelete) +void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions( + const std::set& allCurveDefsToDisplay, + const std::set& curveDefsToAdd, + const std::set& curvesToDelete) { + const size_t ENSEMBLE_CURVE_COUNT_THRESHOLD = 200; + static bool warningDisplayed = false; + RimSummaryCase* prevCase = nullptr; std::set summaryCurveDefsToDisplay; @@ -380,7 +390,8 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: if (!def.isEnsembleCurve()) summaryCurveDefsToDisplay.insert(def); } - RimSummaryCurveAppearanceCalculator curveLookCalc(summaryCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); + RimSummaryCurveAppearanceCalculator curveLookCalc( + summaryCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); // Delete curves @@ -389,6 +400,8 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: m_previewPlot->deleteCurve(curve); } + size_t ensembleCurveCnt = ensembleCurveCount(allCurveDefsToDisplay); + // Add new curves for (const auto& curveDef : curveDefsToAdd) { @@ -420,6 +433,22 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: // Set single curve set color size_t colorIndex = m_previewPlot->ensembleCurveSetCollection()->curveSetCount(); curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); + + if (m_previewPlot->ensembleCurveSetCollection()->curveSets().size() > 1 && ensembleCurveCnt > ENSEMBLE_CURVE_COUNT_THRESHOLD) + { + // Toggle off new curve set and display warning + curveSet->showCurves(false); + + if (!warningDisplayed) + { + QMessageBox mbox; + mbox.setIcon(QMessageBox::Icon::Warning); + mbox.setInformativeText( + "The new curve set is hidden. Too many visible curve sets may lead to poor performance"); + mbox.exec(); + warningDisplayed = true; + } + } } curveSet->addCurve(curve); } @@ -911,3 +940,12 @@ void RicSummaryCurveCreator::setInitialCurveVisibility(const RimSummaryPlot* tar } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int ensembleCurveCount(const std::set& allCurveDefs) +{ + return std::count_if( + allCurveDefs.begin(), allCurveDefs.end(), [](const RiaSummaryCurveDefinition& def) { return def.isEnsembleCurve(); }); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index b27afbaa4c..ff11e78fa5 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -34,7 +34,6 @@ #include - #define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA" class RimSummaryCase; @@ -107,7 +106,7 @@ class RicSummaryCurveCreator : public caf::PdmObject void proxyEnablePlotAutoTitle(const bool& enable); bool proxyPlotAutoTitle() const; void setInitialCurveVisibility(const RimSummaryPlot* targetPlot); - + private: caf::PdmPtrField m_targetPlot; From 6fcc91cdcdb1996044ab9ca345e3944db11f4c75 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 09:52:27 +0200 Subject: [PATCH 0974/1027] #955 Cleanup includes and fix whitespace --- .../RicViewZoomAllFeature.cpp | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp index d1f2b59ec9..752f17d564 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -20,28 +20,20 @@ #include "RiaApplication.h" -#include "RimSummaryPlot.h" #include "Rim3dView.h" #include "RimViewWindow.h" -#include "RimWellAllocationPlot.h" -#include "RimWellLogPlot.h" -#include "RiuPlotMainWindow.h" +#include "RiuInterfaceToViewWindow.h" #include "RiuMainWindow.h" -#include "RiuSummaryQwtPlot.h" -#include "RiuWellAllocationPlot.h" -#include "RiuWellLogPlot.h" +#include "RiuPlotMainWindow.h" #include -#include #include -#include "RiuFlowCharacteristicsPlot.h" -#include "RimFlowCharacteristicsPlot.h" CAF_CMD_SOURCE_INIT(RicViewZoomAllFeature, "RicViewZoomAllFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicViewZoomAllFeature::isCommandEnabled() { @@ -49,7 +41,7 @@ bool RicViewZoomAllFeature::isCommandEnabled() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicViewZoomAllFeature::onActionTriggered(bool isChecked) { @@ -64,9 +56,9 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) } else if (dynamic_cast(topLevelWidget)) { - RiuPlotMainWindow* mainPlotWindow = dynamic_cast(topLevelWidget); - QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); - if (subwindows.size() > 0) + RiuPlotMainWindow* mainPlotWindow = dynamic_cast(topLevelWidget); + QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); + if (!subwindows.empty()) { RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(subwindows.back()->widget()); @@ -79,11 +71,10 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicViewZoomAllFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Zoom All"); actionToSetup->setIcon(QIcon(":/ZoomAll16x16.png")); } - From 94ab7b792324cd74b86a3869d457f951ef57f693 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 09:53:26 +0200 Subject: [PATCH 0975/1027] #955 Guard nullptr access --- .../Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp index 752f17d564..5ec633e894 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -52,7 +52,10 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) if (dynamic_cast(topLevelWidget)) { RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView(); - viewWindow->zoomAll(); + if (viewWindow) + { + viewWindow->zoomAll(); + } } else if (dynamic_cast(topLevelWidget)) { From b6d3446fe87dde163448f2b74cdd4569732a79ec Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 13:18:56 +0200 Subject: [PATCH 0976/1027] #955 Add zoom all to list of command ids --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 40a90f3567..37ba5431ea 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -806,7 +806,13 @@ void RiuMainWindow::slotRefreshViewActions() updateScaleValue(); - caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature" << "RicTogglePerspectiveViewFeature"); + QStringList commandIds; + commandIds << "RicLinkVisibleViewsFeature" + << "RicTileWindowsFeature" + << "RicTogglePerspectiveViewFeature" + << "RicViewZoomAllFeature"; + + caf::CmdFeatureManager::instance()->refreshEnabledState(commandIds); } //-------------------------------------------------------------------------------------------------- From e5227c15f08d739190a509233c1e961edad6c9de Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 20:39:25 +0200 Subject: [PATCH 0977/1027] #2915 Return if no target plot is available --- .../Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 94ca875076..6c1e6a2abb 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -613,7 +613,7 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateTargetPlot() { - if (m_targetPlot == nullptr) m_targetPlot = new RimSummaryPlot(); + if (!m_targetPlot) return; m_targetPlot->deleteAllSummaryCurves(); m_targetPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); From ca2a46a5883b63e26db88c57373f0a887c6d39cc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 20:48:44 +0200 Subject: [PATCH 0978/1027] #2915 Summary Preview Plot : Do not add to MDI aread to avoid ghost MDI window --- ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp | 1 - .../ProjectDataModel/Summary/RimSummaryPlotCollection.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 95287dfc87..595565a1f8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -123,7 +123,6 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitField(&m_isAutoZoom_OBSOLETE, "AutoZoom", true, "Auto Zoom", "", "", ""); m_isAutoZoom_OBSOLETE.uiCapability()->setUiHidden(true); m_isAutoZoom_OBSOLETE.xmlCapability()->setIOWritable(false); - setAsPlotMdiWindow(); m_isCrossPlot = false; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp index 2f2f43204f..44fad92fd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp @@ -48,6 +48,8 @@ RimSummaryPlotCollection::~RimSummaryPlotCollection() RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotWithAutoTitle() { RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setAsPlotMdiWindow(); + plot->enableAutoPlotTitle(true); summaryPlots.push_back(plot); @@ -60,6 +62,8 @@ RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotWithAutoTitle() RimSummaryPlot* RimSummaryPlotCollection::createNamedSummaryPlot(const QString& name) { RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setAsPlotMdiWindow(); + summaryPlots.push_back(plot); plot->setDescription(name); From e2dc1486e7504275e872f334c864b7d52be6fb2a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 14 May 2018 21:31:56 +0200 Subject: [PATCH 0979/1027] #2914 Curve Calculator: Remove Ensembles from the vector selection --- .../ProjectDataModel/RimSummaryCalculationVariable.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 0a00dad0c2..cb583abdf7 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -85,6 +85,7 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* { RiuSummaryCurveDefSelectionDialog dlg(nullptr); + dlg.hideEnsembles(); dlg.setCaseAndAddress(m_case(), m_summaryAddress->address()); if (dlg.exec() == QDialog::Accepted) From 77dd3cbc437267c70c7c878630e82b7a7e352bd7 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 08:43:36 +0200 Subject: [PATCH 0980/1027] #2690 Update all summary curves, not just visible when changing the vector for the whole collection * Also make sure the curve names take into account all curves in the project tree and in the legend text. * Make sure plot name is updated when a curve is deleted. --- .../Commands/RicDeleteItemExec.cpp | 1 + .../RicSummaryCurveCreator.cpp | 2 +- .../Summary/RimEnsembleCurveSet.cpp | 20 +------ .../Summary/RimEnsembleCurveSet.h | 1 - .../Summary/RimSummaryCurve.cpp | 5 +- .../Summary/RimSummaryCurve.h | 1 - .../Summary/RimSummaryCurveCollection.cpp | 21 ++------ .../Summary/RimSummaryCurveCollection.h | 1 - .../Summary/RimSummaryPlot.cpp | 48 ++++++++--------- .../ProjectDataModel/Summary/RimSummaryPlot.h | 10 ++-- .../Summary/RimSummaryPlotSourceStepping.cpp | 52 +++++++------------ .../Summary/RimSummaryPlotSourceStepping.h | 7 ++- 12 files changed, 57 insertions(+), 112 deletions(-) diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 7daa0f6285..356955e036 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -262,6 +262,7 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(summaryPlotCollection); if (summaryPlotCollection) { + summaryPlotCollection->updateSummaryNameHasChanged(); RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 6c1e6a2abb..78089f0885 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -812,7 +812,7 @@ void RicSummaryCurveCreator::createNewPlot() QString candidatePlotName; if (m_previewPlot) { - candidatePlotName = m_previewPlot->generatedPlotTitleFromVisibleCurves(); + candidatePlotName = m_previewPlot->generatedPlotTitleFromAllCurves(); } { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index ad25822fe8..99042685db 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -272,24 +272,6 @@ std::vector RimEnsembleCurveSet::curves() const return m_curves.childObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimEnsembleCurveSet::visibleCurves() const -{ - std::vector visible; - - for (const auto& c : m_curves) - { - if (c->isCurveVisible()) - { - visible.push_back(c); - } - } - - return visible; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -988,7 +970,7 @@ QString RimEnsembleCurveSet::createAutoName() const RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted(plot); - QString curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + QString curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelperAllCurves()); if (curveSetName.isEmpty()) { curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), nullptr); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 5bbf20760b..a07f9b00c2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -75,7 +75,6 @@ class RimEnsembleCurveSet : public caf::PdmObject void setSummaryAddress(RifEclipseSummaryAddress address); RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; - std::vector visibleCurves() const; void deleteAllCurves(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index b96cf025b8..fd52dbec7b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -355,7 +355,8 @@ QString RimSummaryCurve::createCurveAutoName() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted(plot); - QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + const RimSummaryPlotNameHelper* nameHelper = plot->activePlotTitleHelperAllCurves(); + QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), nameHelper); if (curveName.isEmpty()) { curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), nullptr); @@ -363,7 +364,7 @@ QString RimSummaryCurve::createCurveAutoName() if (isCrossPlotCurve()) { - QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); + QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), nameHelper); if (curveNameX.isEmpty()) { curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), nullptr); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h index f356d0bdfa..43a745edd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -76,7 +76,6 @@ class RimSummaryCurve : public RimPlotCurve protected: // RimPlotCurve overrides - virtual QString createCurveAutoName() override; virtual void updateZoomInParentPlot() override; virtual void onLoadDataAndUpdate(bool updateParentPlot) override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 4a8dd74cd6..42ec50d008 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -175,6 +175,7 @@ void RimSummaryCurveCollection::deleteCurve(RimSummaryCurve* curve) { m_curves.removeChildObject(curve); delete curve; + updateCaseNameHasChanged(); } } @@ -186,24 +187,6 @@ std::vector RimSummaryCurveCollection::curves() const return m_curves.childObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCurveCollection::visibleCurves() const -{ - std::vector visible; - - for (auto c : m_curves) - { - if (c->isCurveVisible()) - { - visible.push_back(c); - } - } - - return visible; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -250,6 +233,8 @@ void RimSummaryCurveCollection::updateCaseNameHasChanged() RimSummaryPlot* parentPlot; firstAncestorOrThisOfTypeAsserted(parentPlot); + + parentPlot->updatePlotTitle(); if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h index d53c1c9682..a1c2fd89ec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h @@ -55,7 +55,6 @@ class RimSummaryCurveCollection : public caf::PdmObject void deleteCurve(RimSummaryCurve* curve); std::vector curves() const; - std::vector visibleCurves() const; void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); void deleteAllCurves(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 595565a1f8..fc82d77913 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -126,7 +126,7 @@ RimSummaryPlot::RimSummaryPlot() m_isCrossPlot = false; - m_nameHelper.reset(new RimSummaryPlotNameHelper); + m_nameHelperAllCurves.reset(new RimSummaryPlotNameHelper); } //-------------------------------------------------------------------------------------------------- @@ -521,24 +521,25 @@ RiuSummaryQwtPlot* RimSummaryPlot::qwtPlot() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updatePlotTitle() { + updateNameHelperWithCurveData(m_nameHelperAllCurves.get()); + if (m_useAutoPlotTitle) { - m_userDefinedPlotTitle = generatePlotTitle(m_nameHelper.get()); + m_userDefinedPlotTitle = m_nameHelperAllCurves->plotTitle(); } - + updateCurveNames(); - updateMdiWindowTitle(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelper() const +const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelperAllCurves() const { if (m_useAutoPlotTitle()) { - return m_nameHelper.get(); + return m_nameHelperAllCurves.get(); } return nullptr; @@ -547,11 +548,11 @@ const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelper() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::generatedPlotTitleFromVisibleCurves() const +QString RimSummaryPlot::generatedPlotTitleFromAllCurves() const { RimSummaryPlotNameHelper nameHelper; - - return generatePlotTitle(&nameHelper); + updateNameHelperWithCurveData(&nameHelper); + return nameHelper.plotTitle(); } //-------------------------------------------------------------------------------------------------- @@ -1527,10 +1528,11 @@ void RimSummaryPlot::updateMdiWindowTitle() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) const +void RimSummaryPlot::updateNameHelperWithCurveData(RimSummaryPlotNameHelper* nameHelper) const { - if (!nameHelper) return ""; + if (!nameHelper) return; + nameHelper->clear(); std::vector addresses; std::vector sumCases; std::vector ensembleCases; @@ -1539,19 +1541,16 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) { for (RimSummaryCurve* curve : m_summaryCurveCollection->curves()) { - if (curve->isCurveVisible()) + addresses.push_back(curve->summaryAddressY()); + sumCases.push_back(curve->summaryCaseY()); + + if (curve->summaryCaseX()) { - addresses.push_back(curve->summaryAddressY()); - sumCases.push_back(curve->summaryCaseY()); + sumCases.push_back(curve->summaryCaseX()); - if (curve->summaryCaseX()) + if (curve->summaryAddressX().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) { - sumCases.push_back(curve->summaryCaseX()); - - if (curve->summaryAddressX().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) - { - addresses.push_back(curve->summaryAddressX()); - } + addresses.push_back(curve->summaryAddressX()); } } } @@ -1570,8 +1569,6 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) nameHelper->appendAddresses(addresses); nameHelper->appendSummaryCases(sumCases); nameHelper->appendEnsembleCases(ensembleCases); - - return nameHelper->plotTitle(); } //-------------------------------------------------------------------------------------------------- @@ -1583,10 +1580,7 @@ void RimSummaryPlot::updateCurveNames() { for (auto c : summaryCurves()) { - if (c->isCurveVisible()) - { - c->updateCurveNameNoLegendUpdate(); - } + c->updateCurveNameNoLegendUpdate(); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 13bc433faa..9049ed8373 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -112,9 +112,9 @@ class RimSummaryPlot : public RimViewWindow void updatePlotTitle(); - const RimSummaryPlotNameHelper* activePlotTitleHelper() const; + const RimSummaryPlotNameHelper* activePlotTitleHelperAllCurves() const; void updateCurveNames(); - QString generatedPlotTitleFromVisibleCurves() const; + QString generatedPlotTitleFromAllCurves() const; void copyAxisPropertiesFromOther(const RimSummaryPlot& sourceSummaryPlot); @@ -126,7 +126,7 @@ class RimSummaryPlot : public RimViewWindow private: void updateMdiWindowTitle() override; - QString generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) const; + void updateNameHelperWithCurveData(RimSummaryPlotNameHelper* nameHelper) const; protected: // Overridden PDM methods @@ -168,7 +168,7 @@ class RimSummaryPlot : public RimViewWindow caf::PdmField m_userDefinedPlotTitle; caf::PdmChildArrayField m_gridTimeHistoryCurves; - caf::PdmChildField m_summaryCurveCollection; + caf::PdmChildField m_summaryCurveCollection; caf::PdmChildField m_ensembleCurveSetCollection; caf::PdmChildArrayField m_asciiDataCurves; @@ -184,7 +184,7 @@ class RimSummaryPlot : public RimViewWindow bool m_isCrossPlot; - std::unique_ptr m_nameHelper; + std::unique_ptr m_nameHelperAllCurves; // Obsolete fields caf::PdmChildArrayField m_summaryCurves_OBSOLETE; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 1a91990a65..bf02610c2c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -229,7 +229,7 @@ QList RimSummaryPlotSourceStepping::calculateValueOption std::vector identifierTexts; - RifSummaryReaderInterface* reader = firstSummaryReaderForVisibleCurves(); + RifSummaryReaderInterface* reader = firstSummaryReaderForCurves(); if (reader) { RiaSummaryCurveAnalyzer* analyzer = analyzerForReader(reader); @@ -253,9 +253,9 @@ QList RimSummaryPlotSourceStepping::calculateValueOption RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; - if (curveCollection->visibleCurves().size() > 0) + if (curveCollection->curves().size() > 0) { - category = curveCollection->visibleCurves()[0]->summaryAddressY().category(); + category = curveCollection->curves()[0]->summaryAddressY().category(); } RiaSummaryCurveAnalyzer quantityAnalyzer; @@ -301,7 +301,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c { if (m_summaryCase()) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -324,7 +324,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_wellName) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -353,7 +353,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_region) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -382,7 +382,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_quantity) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -405,7 +405,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_wellGroupName) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -457,35 +457,21 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifSummaryReaderInterface* RimSummaryPlotSourceStepping::firstSummaryReaderForVisibleCurves() const -{ - RimSummaryCase* sumCase = firstSummaryCaseForVisibleCurves(); - if (sumCase) - { - return sumCase->summaryReader(); - } - - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryPlotSourceStepping::firstSummaryCaseForVisibleCurves() const +RifSummaryReaderInterface* RimSummaryPlotSourceStepping::firstSummaryReaderForCurves() const { RimSummaryCurveCollection* curveCollection = nullptr; this->firstAncestorOrThisOfTypeAsserted(curveCollection); - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping() && curve->summaryCaseY()) { - return curve->summaryCaseY(); + return curve->summaryCaseY()->summaryReader(); } if (isXAxisStepping() && curve->summaryCaseX()) { - return curve->summaryCaseX(); + return curve->summaryCaseX()->summaryReader(); } } @@ -498,7 +484,7 @@ RimSummaryCase* RimSummaryPlotSourceStepping::firstSummaryCaseForVisibleCurves() caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() { RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses(visibleAddressesCurveCollection()); + analyzer.appendAdresses(addressesCurveCollection()); if (analyzer.wellNames().size() == 1) { @@ -521,7 +507,7 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::visibleAddressesCurveCollection() const +std::set RimSummaryPlotSourceStepping::addressesCurveCollection() const { std::set addresses; @@ -530,7 +516,7 @@ std::set RimSummaryPlotSourceStepping::visibleAddresse if (!curveCollection) return addresses; - auto curves = curveCollection->visibleCurves(); + auto curves = curveCollection->curves(); for (auto c : curves) { if (isYAxisStepping()) @@ -550,7 +536,7 @@ std::set RimSummaryPlotSourceStepping::visibleAddresse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::visibleSummaryCasesCurveCollection() const +std::set RimSummaryPlotSourceStepping::summaryCasesCurveCollection() const { std::set sumCases; @@ -559,7 +545,7 @@ std::set RimSummaryPlotSourceStepping::visibleSummaryCasesCurve if (!curveCollection) return sumCases; - auto curves = curveCollection->visibleCurves(); + auto curves = curveCollection->curves(); for (auto c : curves) { if (isYAxisStepping()) @@ -589,7 +575,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi std::vector fields; - auto sumCases = visibleSummaryCasesCurveCollection(); + auto sumCases = summaryCasesCurveCollection(); if (sumCases.size() == 1) { RimProject* proj = RiaApplication::instance()->project(); @@ -604,7 +590,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi } RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses(visibleAddressesCurveCollection()); + analyzer.appendAdresses(addressesCurveCollection()); RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index 866108e79d..65601060e1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -77,12 +77,11 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject caf::PdmUiEditorAttribute* attribute) override; private: - RifSummaryReaderInterface* firstSummaryReaderForVisibleCurves() const; - RimSummaryCase* firstSummaryCaseForVisibleCurves() const; + RifSummaryReaderInterface* firstSummaryReaderForCurves() const; caf::PdmValueField* fieldToModify(); - std::set visibleAddressesCurveCollection() const; - std::set visibleSummaryCasesCurveCollection() const; + std::set addressesCurveCollection() const; + std::set summaryCasesCurveCollection() const; std::vector computeVisibleFieldsAndSetFieldVisibility(); bool isXAxisStepping() const; From 6edd240c4c306f8bf71d2c9f87bda27c463b6097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 15 May 2018 10:11:49 +0200 Subject: [PATCH 0981/1027] #2912 Ensemble curves. Fixes regarding summary curve definitions --- .../Application/RiaSummaryCurveDefinition.cpp | 5 ++++- .../RicSummaryCurveCreator.cpp | 9 ++++----- .../Summary/RimEnsembleCurveSet.cpp | 6 ++++++ .../Summary/RimSummaryCase.cpp | 19 +++++++++++++++++++ .../ProjectDataModel/Summary/RimSummaryCase.h | 3 +++ .../RiuSummaryCurveDefSelection.cpp | 3 --- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index 2194af40e1..99f1602636 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -146,9 +146,12 @@ bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other { if (m_curveDefinition.first == other.summaryCase()) { + if (m_curveDefinition.second == other.summaryAddress()) + { + return m_ensemble < other.m_ensemble; + } return (m_curveDefinition.second < other.summaryAddress()); } - return (m_curveDefinition.first < other.summaryCase()); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 78089f0885..bf814cb0bd 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -337,7 +337,8 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() for (const auto& curve : currentCurvesInPreviewPlot) { - currentCurveDefs.insert(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); + RimSummaryCase* sumCase = curve->summaryCaseY(); + currentCurveDefs.insert(RiaSummaryCurveDefinition(sumCase, curve->summaryAddressY(), sumCase ? sumCase->ensemble() : nullptr)); } if (allCurveDefinitions.size() < currentCurvesInPreviewPlot.size()) @@ -352,7 +353,8 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() for (const auto& curve : currentCurvesInPreviewPlot) { - RiaSummaryCurveDefinition curveDef = RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY()); + RimSummaryCase* sumCase = curve->summaryCaseY(); + RiaSummaryCurveDefinition curveDef = RiaSummaryCurveDefinition(sumCase, curve->summaryAddressY(), sumCase ? sumCase->ensemble() : nullptr); if (deleteCurveDefs.count(curveDef) > 0) curvesToDelete.insert(curve); } } @@ -592,9 +594,6 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu for (const auto& curve : curveSet->curves()) { curveDefs.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY(), ensemble)); - - // Copy curve object to the preview plot - copyEnsembleCurveAndAddToCurveSet(curve, newCurveSet, true); } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 99042685db..1101c86fec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -859,6 +859,12 @@ RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const { RimEnsembleCurveSet* copy = dynamic_cast(this->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); copy->m_yValuesSummaryGroup = m_yValuesSummaryGroup(); + + // Update summary case references + for (int i = 0; i < m_curves.size(); i++) + { + copy->m_curves[i]->setSummaryCaseY(m_curves[i]->summaryCaseY()); + } return copy; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 6cd6eab509..bc94b1ed2f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -25,6 +25,7 @@ #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" +#include "RimSummaryCaseCollection.h" #include "cvfAssert.h" @@ -107,6 +108,24 @@ bool RimSummaryCase::hasCaseRealizationParameters() const return m_crlParameters != nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RimSummaryCase::ensemble() const +{ + RimSummaryCaseCollection* e; + firstAncestorOrThisOfType(e); + return e; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCase::isEnsembleCase() const +{ + return ensemble() != nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index 3beaf41cf5..bbad294128 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -25,6 +25,7 @@ #include class RifSummaryReaderInterface; +class RimSummaryCaseCollection; //================================================================================================== // @@ -59,6 +60,8 @@ class RimSummaryCase : public caf::PdmObject void setCaseRealizationParameters(const std::shared_ptr& crlParameters); std::shared_ptr caseRealizationParameters() const; bool hasCaseRealizationParameters() const; + RimSummaryCaseCollection* ensemble() const; + bool isEnsembleCase() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index a88eacc11d..151a6aa0e4 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -1077,9 +1077,6 @@ std::vector RiuSummaryCurveDefSelection::selectedSummarySources( for (const auto& source : m_selectedSources) { - RimSummaryCase* c = dynamic_cast(source.p()); - RimSummaryCaseCollection* cc = dynamic_cast(source.p()); - sources.push_back(source); } From 225aa34775f725ca2a2997ef7870145ce10e5e65 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 May 2018 10:17:03 +0200 Subject: [PATCH 0982/1027] #2915 Summary Preview Plot : Register cross plot as MDI window --- .../ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index f4810788b5..b1a519cdfc 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -89,6 +89,7 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos(QListsetAsPlotMdiWindow(); plot->setDescription(QString("Summary Cross Plot %1").arg(m_summaryCrossPlots.size())); From 19125396a171512b9c371a9aa6b8677b0a229897 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 May 2018 10:41:27 +0200 Subject: [PATCH 0983/1027] #955 Toolbar Button State : Mark calculator button as disabled if no case is open --- .../RicShowSummaryCurveCalculatorFeature.cpp | 5 +++- .../Summary/RimObservedDataCollection.cpp | 25 +++++++++++++------ .../UserInterface/RiuPlotMainWindow.cpp | 2 ++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp index 03a0a56d74..85b9898a96 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp @@ -54,7 +54,10 @@ void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog() //-------------------------------------------------------------------------------------------------- bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled() { - return true; + RimProject* proj = RiaApplication::instance()->project(); + const auto& allSumCases = proj->allSummaryCases(); + + return !allSumCases.empty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp index f6ac04f011..d0f6d8b149 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp @@ -32,6 +32,7 @@ #include "RimSummaryObservedDataFile.h" #include "RiuPlotMainWindowTools.h" +#include "RiuPlotMainWindow.h" #include "cafUtils.h" #include "cafPdmSettings.h" @@ -108,6 +109,18 @@ bool RimObservedDataCollection::fileExists(const QString& fileName, QString* err return true; } +void updateNewSummaryObjectCreated(caf::PdmObject* object) +{ + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(object); + RiuPlotMainWindowTools::setExpanded(object); + + caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + if (mpw) mpw->updateSummaryPlotToolBar(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -130,12 +143,10 @@ RimObservedData* RimObservedDataCollection::createAndAddRsmObservedDataFromFile( errorText->append(observedData->errorMessagesFromReader()); } - RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem(observedData); - RiuPlotMainWindowTools::setExpanded(observedData); + updateNewSummaryObjectCreated(observedData); this->updateConnectedEditors(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + return observedData; } @@ -189,11 +200,9 @@ RimObservedData* RimObservedDataCollection::createAndAddCvsObservedDataFromFile( return nullptr; } - RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem(userData); - RiuPlotMainWindowTools::setExpanded(userData); + updateNewSummaryObjectCreated(observedData); this->updateConnectedEditors(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + return observedData; } diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index b47263d26e..9586dd002c 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -457,6 +457,8 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar() m_summaryPlotToolBarEditor->hide(); } + + refreshToolbars(); } //-------------------------------------------------------------------------------------------------- From 9eb16f22cdee7934e0f4bc9dee07f9b2b4ddc560 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 May 2018 10:56:31 +0200 Subject: [PATCH 0984/1027] #955 Toolbar Button State : Update plot toolbars when eclipse case is imported --- .../Application/Tools/RiaImportEclipseCaseTools.cpp | 5 ++++- ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp | 9 +++++++++ ApplicationCode/UserInterface/RiuPlotMainWindowTools.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 7c7696b2a1..e28f5dfd20 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -45,8 +45,9 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlotCollection.h" -#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" +#include "RiuPlotMainWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafUtils.h" #include "cafProgressInfo.h" @@ -135,6 +136,8 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file RiaLogging::error(errorMessage); } + RiuPlotMainWindowTools::refreshToolbars(); + return true; } diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp index d056806ed8..cd161b6315 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -58,5 +58,14 @@ void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, b if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::refreshToolbars() +{ + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->updateSummaryPlotToolBar(); +} diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h index 646aa89e91..6400a6467a 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h @@ -33,5 +33,6 @@ class RiuPlotMainWindowTools static void setActiveViewer(QWidget* subWindow) ; static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + static void refreshToolbars(); }; From 76f8b9ac903d39ba7e0d7b93c7fe6a95791c924f Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 10:52:14 +0200 Subject: [PATCH 0985/1027] #1909 Fix assertation failure in RimSummaryCurveAppearanceCalculator --- .../RimSummaryCurveAppearanceCalculator.cpp | 31 ++++++++----------- .../RimSummaryCurveAppearanceCalculator.h | 7 ++--- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index 44092c21d9..e28dcbcc22 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -91,14 +91,7 @@ RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator(const s } } - m_caseCount = m_caseToAppearanceIdxMap.size(); - m_variableCount = m_varToAppearanceIdxMap .size(); - m_wellCount = m_welToAppearanceIdxMap .size(); - m_groupCount = m_grpToAppearanceIdxMap .size(); - m_regionCount = m_regToAppearanceIdxMap .size(); - // Select the default appearance type for each data "dimension" - m_caseAppearanceType = NONE; m_varAppearanceType = NONE; m_wellAppearanceType = NONE; @@ -114,11 +107,11 @@ RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator(const s m_currentCurveGradient = 0.0f; m_dimensionCount = 0; - if(m_variableCount > 1) { m_varAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_caseCount > 1) { m_caseAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_wellCount > 1) { m_wellAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_groupCount > 1) { m_groupAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_regionCount > 1) { m_regionAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_varToAppearanceIdxMap.size() > 1) { m_varAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_caseToAppearanceIdxMap.size() > 1) { m_caseAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_welToAppearanceIdxMap.size() > 1) { m_wellAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_grpToAppearanceIdxMap.size() > 1) { m_groupAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_regToAppearanceIdxMap.size() > 1) { m_regionAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } if (m_dimensionCount == 0) m_varAppearanceType = COLOR; // basically one curve @@ -291,7 +284,9 @@ void RimSummaryCurveAppearanceCalculator::getDimensions(CurveAppearanceType* cas //-------------------------------------------------------------------------------------------------- void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) { - m_currentCurveBaseColor = cvf::Color3f(0, 0, 0); + // The gradient is from negative to positive. + // Choose default base color as the midpoint between black and white. + m_currentCurveBaseColor = cvf::Color3f(0.5f, 0.5f, 0.5f); m_currentCurveGradient = 0.0f; int caseAppearanceIdx = m_caseToAppearanceIdxMap[curve->summaryCaseY()]; @@ -305,10 +300,10 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) if(curve->summaryAddressY().wellGroupName().empty()) grpAppearanceIdx = -1; if(curve->summaryAddressY().regionNumber() < 0) regAppearanceIdx = -1; - setOneCurveAppearance(m_caseAppearanceType, m_caseCount, caseAppearanceIdx, curve); - setOneCurveAppearance(m_wellAppearanceType, m_wellCount, welAppearanceIdx, curve); - setOneCurveAppearance(m_groupAppearanceType, m_groupCount, grpAppearanceIdx, curve); - setOneCurveAppearance(m_regionAppearanceType, m_regionCount, regAppearanceIdx, curve); + setOneCurveAppearance(m_caseAppearanceType, m_allSummaryCaseNames.size(), caseAppearanceIdx, curve); + setOneCurveAppearance(m_wellAppearanceType, m_allSummaryWellNames.size(), welAppearanceIdx, curve); + setOneCurveAppearance(m_groupAppearanceType, m_grpToAppearanceIdxMap.size(), grpAppearanceIdx, curve); + setOneCurveAppearance(m_regionAppearanceType, m_regToAppearanceIdxMap.size(), regAppearanceIdx, curve); if (m_varAppearanceType == COLOR && m_secondCharToVarToAppearanceIdxMap.size() > 1) { @@ -353,7 +348,7 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) } else { - setOneCurveAppearance(m_varAppearanceType, m_variableCount, varAppearanceIdx, curve); + setOneCurveAppearance(m_varAppearanceType, m_varToAppearanceIdxMap.size(), varAppearanceIdx, curve); } curve->setColor(gradeColor(m_currentCurveBaseColor, m_currentCurveGradient)); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h index 6df22d8b2b..0980661538 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h @@ -67,6 +67,8 @@ class RimSummaryCurveAppearanceCalculator static RimPlotCurve::PointSymbolEnum cycledSymbol(int index); private: + template + int findMaxApperanceIndexInMap(const std::map& mapToSearch) const; void setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve); void updateApperanceIndices(); std::map mapNameToAppearanceIndex(CurveAppearanceType & appearance, const std::set& names); @@ -81,11 +83,6 @@ class RimSummaryCurveAppearanceCalculator cvf::Color3f m_currentCurveBaseColor; float m_currentCurveGradient; - size_t m_caseCount; - size_t m_variableCount; - size_t m_wellCount; - size_t m_groupCount; - size_t m_regionCount; int m_dimensionCount; CurveAppearanceType m_caseAppearanceType; From 2e0cd60fc4d10a84482429a82a4cb094c3dac324 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 11:31:06 +0200 Subject: [PATCH 0986/1027] #2466 Fix the one occurence of non-guarded activeReservoirView access found. --- .../Commands/RicImportFormationNamesFeature.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 88a5669e75..90aae06f40 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -84,11 +84,13 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) if (!cases.empty()) { Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - RimCase* ownerCase = activeView->ownerCase(); - - if (ownerCase) + if (activeView) { - ownerCase->setFormationNames(formationName); + RimCase* ownerCase = activeView->ownerCase(); + if (ownerCase) + { + ownerCase->setFormationNames(formationName); + } } } From ea50722cdd48e7a9ab8af85f9114f1496efde8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 15 May 2018 12:10:39 +0200 Subject: [PATCH 0987/1027] #2911 Ensemble curves. Fix disappearing right axis --- .../Summary/RimEnsembleCurveSet.cpp | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 1101c86fec..c38a798316 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -823,23 +823,27 @@ void RimEnsembleCurveSet::updateAllCurves() RimSummaryAddress* addr = m_yValuesCurveVariable(); if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) { - for (auto& sumCase : group->allSummaryCases()) + if(m_showCurves) { - RimSummaryCurve* curve = new RimSummaryCurve(); - curve->setSummaryCaseY(sumCase); - curve->setSummaryAddressY(addr->address()); + for (auto& sumCase : group->allSummaryCases()) + { + RimSummaryCurve* curve = new RimSummaryCurve(); + curve->setSummaryCaseY(sumCase); + curve->setSummaryAddressY(addr->address()); + curve->setLeftOrRightAxisY(m_plotAxis()); - addCurve(curve); + addCurve(curve); - curve->updateCurveVisibility(true); - curve->loadDataAndUpdate(true); + curve->updateCurveVisibility(true); + curve->loadDataAndUpdate(true); - if (curve->qwtPlotCurve()) - { - curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); + if (curve->qwtPlotCurve()) + { + curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); + } } + m_yValuesSummaryFilter->updateFromAddress(addr->address()); } - m_yValuesSummaryFilter->updateFromAddress(addr->address()); RimSummaryPlot* plot; firstAncestorOrThisOfType(plot); From 3effc4ca662a860103dd4acafc7cee31ff3d16e2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 May 2018 13:58:39 +0200 Subject: [PATCH 0988/1027] #2918 Summary Plot Title : Make sure title and curve names are stable when deselecting ensemble curve --- .../ProjectDataModel/RimPlotCurve.cpp | 2 +- .../Summary/RimEnsembleCurveSetCollection.cpp | 21 ------------------- .../Summary/RimEnsembleCurveSetCollection.h | 1 - .../Summary/RimSummaryPlot.cpp | 7 ++----- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 15aedc2069..b1a8f070ee 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -596,7 +596,7 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { bool showLegendInQwt = m_showLegend(); - if (summaryPlot->ensembleCurveSetCollection()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1) + if (summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1) { // Disable display of legend if the summary plot has only one single curve showLegendInQwt = false; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index ac4a3c25f5..a51722f143 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -170,27 +170,6 @@ std::vector RimEnsembleCurveSetCollection::curveSets() con return m_curveSets.childObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimEnsembleCurveSetCollection::visibleCurveSets() const -{ - std::vector visible; - - if (m_showCurves()) - { - for (const auto& c : m_curveSets) - { - if (c->isCurvesVisible()) - { - visible.push_back(c); - } - } - } - - return visible; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 6f80d235dc..423479b553 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -51,7 +51,6 @@ class RimEnsembleCurveSetCollection : public caf::PdmObject void deleteCurveSet(RimEnsembleCurveSet* curveSet); std::vector curveSets() const; - std::vector visibleCurveSets() const; size_t curveSetCount() const; void deleteAllCurveSets(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index fc82d77913..6947a80619 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1558,11 +1558,8 @@ void RimSummaryPlot::updateNameHelperWithCurveData(RimSummaryPlotNameHelper* nam for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) { - if (curveSet->isCurvesVisible()) - { - addresses.push_back(curveSet->summaryAddress()); - ensembleCases.push_back(curveSet->summaryCaseCollection()); - } + addresses.push_back(curveSet->summaryAddress()); + ensembleCases.push_back(curveSet->summaryCaseCollection()); } nameHelper->clear(); From 9b591f622c878c2171f1e6c94e0e8de208295428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 10:14:18 +0200 Subject: [PATCH 0989/1027] #2917 SummaryCurveDefinition: Remove pair, improve less operator --- .../Application/RiaSummaryCurveDefinition.cpp | 38 +++++++++---------- .../Application/RiaSummaryCurveDefinition.h | 5 +-- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index 99f1602636..ee94b22f85 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -25,9 +25,10 @@ /// //-------------------------------------------------------------------------------------------------- RiaSummaryCurveDefinition::RiaSummaryCurveDefinition() +: m_summaryCase(nullptr) +, m_ensemble(nullptr) + { - m_curveDefinition = std::make_pair(nullptr, RifEclipseSummaryAddress()); - m_ensemble = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -36,9 +37,11 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition() RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress, RimSummaryCaseCollection* ensemble) + : m_summaryCase(summaryCase) + , m_ensemble(ensemble) + , m_summaryAddress(summaryAddress) { - m_curveDefinition = std::make_pair(summaryCase, summaryAddress); - m_ensemble = ensemble; + } //-------------------------------------------------------------------------------------------------- @@ -46,7 +49,7 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase //-------------------------------------------------------------------------------------------------- RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const { - return m_curveDefinition.first; + return m_summaryCase; } //-------------------------------------------------------------------------------------------------- @@ -62,7 +65,7 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const //-------------------------------------------------------------------------------------------------- const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() const { - return m_curveDefinition.second; + return m_summaryAddress; } //-------------------------------------------------------------------------------------------------- @@ -73,13 +76,6 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const return m_ensemble != nullptr; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiaSummaryCurveDefinition::isValid() const -{ - return m_curveDefinition.first != nullptr; -} //-------------------------------------------------------------------------------------------------- /// @@ -144,14 +140,16 @@ QString RiaSummaryCurveDefinition::curveDefinitionText(RimSummaryCase* summaryCa //-------------------------------------------------------------------------------------------------- bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other) const { - if (m_curveDefinition.first == other.summaryCase()) + if (m_summaryCase != other.summaryCase()) { - if (m_curveDefinition.second == other.summaryAddress()) - { - return m_ensemble < other.m_ensemble; - } - return (m_curveDefinition.second < other.summaryAddress()); + return m_summaryCase < other.summaryCase(); } - return (m_curveDefinition.first < other.summaryCase()); + + if (m_ensemble != other.ensemble()) + { + return (m_ensemble < other.ensemble()); + } + + return (m_summaryAddress < other.summaryAddress()); } diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.h b/ApplicationCode/Application/RiaSummaryCurveDefinition.h index 2e8d62a879..ec12ad6969 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.h @@ -44,8 +44,6 @@ class RiaSummaryCurveDefinition RimSummaryCaseCollection* ensemble() const; bool isEnsembleCurve() const; - bool isValid() const; - bool operator < (const RiaSummaryCurveDefinition& other) const; // TODO: Consider moving to a separate tools class @@ -59,6 +57,7 @@ class RiaSummaryCurveDefinition private: private: - std::pair m_curveDefinition; + RimSummaryCase* m_summaryCase; + RifEclipseSummaryAddress m_summaryAddress; RimSummaryCaseCollection* m_ensemble; }; From 6c6e7df3c9676e2c7e08155ce684d971ac872ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 11:32:26 +0200 Subject: [PATCH 0990/1027] #2917 Vector Selection Dialog: Fixed problem with dialog initialization when single selecting ensemble curve sets. --- .../Application/RiaSummaryCurveDefinition.cpp | 20 +++++++++---------- .../Application/RiaSummaryCurveDefinition.h | 2 +- .../RimSummaryCalculationVariable.cpp | 5 ++++- .../RiuSummaryCurveDefSelection.cpp | 10 +++++----- .../RiuSummaryCurveDefSelectionDialog.cpp | 5 +---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index ee94b22f85..93d26a97a9 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -37,9 +37,9 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition() RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress, RimSummaryCaseCollection* ensemble) - : m_summaryCase(summaryCase) - , m_ensemble(ensemble) - , m_summaryAddress(summaryAddress) + : m_summaryCase(summaryCase) + , m_ensemble(ensemble) + , m_summaryAddress(summaryAddress) { } @@ -114,21 +114,21 @@ const std::vector& RiaSummaryCurveDefinition::timeSteps(const RiaSummary //-------------------------------------------------------------------------------------------------- QString RiaSummaryCurveDefinition::curveDefinitionText() const { - return RiaSummaryCurveDefinition::curveDefinitionText(summaryCase(), summaryAddress()); + QString caseName; + if (summaryCase() ) caseName = summaryCase()->caseName(); + + return RiaSummaryCurveDefinition::curveDefinitionText(caseName, summaryAddress()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaSummaryCurveDefinition::curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress) +QString RiaSummaryCurveDefinition::curveDefinitionText(const QString& caseName, const RifEclipseSummaryAddress& summaryAddress) { QString txt; - if (summaryCase) - { - txt += summaryCase->caseName(); - txt += ", "; - } + txt += caseName; + txt += ", "; txt += QString::fromStdString(summaryAddress.uiText()); diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.h b/ApplicationCode/Application/RiaSummaryCurveDefinition.h index ec12ad6969..3fd0940eb7 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.h @@ -52,7 +52,7 @@ class RiaSummaryCurveDefinition QString curveDefinitionText() const; - static QString curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress); + static QString curveDefinitionText(const QString& caseName, const RifEclipseSummaryAddress& summaryAddress); private: diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index cb583abdf7..051be7fd3f 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -123,7 +123,10 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- QString RimSummaryCalculationVariable::summaryAddressDisplayString() const { - return RiaSummaryCurveDefinition::curveDefinitionText(m_case(), m_summaryAddress()->address()); + QString caseName; + if (m_case() ) caseName = m_case()->caseName(); + + return RiaSummaryCurveDefinition::curveDefinitionText(caseName, m_summaryAddress()->address()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 151a6aa0e4..15bcf2a3e9 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -368,8 +368,9 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< for (const auto& curveDef : curveDefinitions) { + if (!(curveDef.summaryCase() || curveDef.isEnsembleCurve()) ) continue; + RimSummaryCase* summaryCase = curveDef.summaryCase(); - if (!summaryCase) continue; RifEclipseSummaryAddress summaryAddress = curveDef.summaryAddress(); if (summaryAddress.category() == RifEclipseSummaryAddress::SUMMARY_INVALID) @@ -393,13 +394,12 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< } // Select case if not already selected - if (std::find(m_selectedSources.begin(), m_selectedSources.end(), - curveDef.isEnsembleCurve() ? (SummarySource*)curveDef.ensemble() : summaryCase) == m_selectedSources.end()) + SummarySource* summSource = curveDef.isEnsembleCurve() ? static_cast(curveDef.ensemble()) : summaryCase; + if (std::find(m_selectedSources.begin(), m_selectedSources.end(), summSource) == m_selectedSources.end()) { if (summaryCase != calculatedSummaryCase()) { - - m_selectedSources.push_back(curveDef.isEnsembleCurve() ? (SummarySource*)curveDef.ensemble() : summaryCase); + m_selectedSources.push_back(summSource); } } diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp index 3ba3327b16..14a896a6ec 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp @@ -96,10 +96,7 @@ void RiuSummaryCurveDefSelectionDialog::setEnsembleAndAddress(RimSummaryCaseColl if (ensemble) { std::vector curveDefs; - for (const auto& summaryCase : ensemble->allSummaryCases()) - { - curveDefs.push_back(RiaSummaryCurveDefinition(summaryCase, address, ensemble)); - } + curveDefs.push_back(RiaSummaryCurveDefinition(nullptr, address, ensemble)); summaryAddressSelection()->setSelectedCurveDefinitions(curveDefs); } From 1b5c1b5e56eda486ac3c27c062fafa27faae3dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 13:54:22 +0200 Subject: [PATCH 0991/1027] #2917 Add method to retreive union of possible summary addresses from ensemble --- .../Summary/RimSummaryCaseCollection.cpp | 23 +++++++++++++++++++ .../Summary/RimSummaryCaseCollection.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 7b1e2fa776..6d962faaff 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -116,6 +116,29 @@ void RimSummaryCaseCollection::setAsEnsemble(bool isEnsemble) updateIcon(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryCaseCollection::calculateUnionOfSummaryAddresses() const +{ + std::set addressUnion; + + for (RimSummaryCase* currCase: m_cases) + { + if ( !currCase ) continue; + + RifSummaryReaderInterface* reader = currCase->summaryReader(); + + if ( !reader ) continue; + + const std::vector& readerAddresses = reader->allResultAddresses(); + addressUnion.insert(readerAddresses.begin(), readerAddresses.end()); + + } + + return addressUnion; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index c5d6897c16..7c35fa1b77 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -44,7 +44,7 @@ class RimSummaryCaseCollection : public caf::PdmObject QString name() const; bool isEnsemble() const; void setAsEnsemble(bool isEnsemble); - + std::set calculateUnionOfSummaryAddresses() const; private: caf::PdmFieldHandle* userDescriptionField() override; void updateReferringCurveSets() const; From a222c096f3f782f63d5a57f089aad6c731b5c860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 13:56:25 +0200 Subject: [PATCH 0992/1027] #2917 Vector Selection Dialog: Rename method for retreiving all expanded curve defintions. Add method to retreive only the selection (one definition pr ensemble curve set) --- .../RicSummaryCurveCreator.cpp | 2 +- .../RiuSummaryCurveDefSelection.cpp | 48 +++++++++++++++++-- .../RiuSummaryCurveDefSelection.h | 4 +- .../RiuSummaryCurveDefSelectionDialog.cpp | 4 +- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index bf814cb0bd..471182f19b 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -324,7 +324,7 @@ void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOr void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() { std::vector allCurveDefinitionsVector = - m_summaryCurveSelectionEditor->summaryAddressSelection()->selectedCurveDefinitions(); + m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveDefinitionsFromSelection(); std::set allCurveDefinitions = std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 15bcf2a3e9..abd0941df9 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -249,12 +249,12 @@ RiuSummaryCurveDefSelection::~RiuSummaryCurveDefSelection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuSummaryCurveDefSelection::selectedCurveDefinitions() const +std::vector RiuSummaryCurveDefSelection::allCurveDefinitionsFromSelection() const { std::vector curveDefVector; { - std::set caseAndAddressPairs; + std::set curveDefinitions; std::set selectedAddressesFromUi = buildAddressListFromSelections(); @@ -289,19 +289,59 @@ std::vector RiuSummaryCurveDefSelection::selectedCurv { if (selectedAddressesFromUi.count(readerAddress) > 0) { - caseAndAddressPairs.insert(RiaSummaryCurveDefinition(currCase, readerAddress, ensemble)); + curveDefinitions.insert(RiaSummaryCurveDefinition(currCase, readerAddress, ensemble)); } } } } } - std::copy(caseAndAddressPairs.begin(), caseAndAddressPairs.end(), std::back_inserter(curveDefVector)); + std::copy(curveDefinitions.begin(), curveDefinitions.end(), std::back_inserter(curveDefVector)); } return curveDefVector; } +//-------------------------------------------------------------------------------------------------- +/// One CurveDefinition pr ensemble curve set +//-------------------------------------------------------------------------------------------------- +std::vector RiuSummaryCurveDefSelection::selection() const +{ + std::vector curveDefSelection; + std::set selectedAddressesFromUi = buildAddressListFromSelections(); + for (SummarySource* currSource : selectedSummarySources()) + { + RimSummaryCaseCollection* ensemble = dynamic_cast(currSource); + RimSummaryCase* sourceCase = dynamic_cast(currSource); + if (ensemble) + { + std::set addressUnion = ensemble->calculateUnionOfSummaryAddresses(); + for ( const auto& addr : selectedAddressesFromUi) + { + if (addressUnion.count(addr)) + { + curveDefSelection.push_back(RiaSummaryCurveDefinition(nullptr, addr, ensemble)); + } + } + } + else + { + if (!(sourceCase && sourceCase->summaryReader())) continue; + + const std::vector& readerAddresses = sourceCase->summaryReader()->allResultAddresses(); + for ( const auto& addr : readerAddresses) + { + if (selectedAddressesFromUi.count(addr)) + { + curveDefSelection.push_back(RiaSummaryCurveDefinition(sourceCase, addr, nullptr)); + } + } + } + } + + return curveDefSelection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index 5c17420571..0c88bdbbc7 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -56,7 +56,9 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject virtual ~RiuSummaryCurveDefSelection(); void setSelectedCurveDefinitions(const std::vector& curveDefinitions); - std::vector selectedCurveDefinitions() const; + std::vector allCurveDefinitionsFromSelection() const; + std::vector selection() const; + void setMultiSelectionMode(bool multiSelectionMode); void hideEnsembles(bool hide); void hideSummaryCases(bool hide); diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp index 14a896a6ec..4a89a98beb 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp @@ -109,7 +109,7 @@ void RiuSummaryCurveDefSelectionDialog::setEnsembleAndAddress(RimSummaryCaseColl //-------------------------------------------------------------------------------------------------- std::vector RiuSummaryCurveDefSelectionDialog::curveSelection() const { - return summaryAddressSelection()->selectedCurveDefinitions(); + return summaryAddressSelection()->allCurveDefinitionsFromSelection(); } //-------------------------------------------------------------------------------------------------- @@ -142,7 +142,7 @@ RiuSummaryCurveDefSelection* RiuSummaryCurveDefSelectionDialog::summaryAddressSe void RiuSummaryCurveDefSelectionDialog::updateLabel() { QString curveAddressText; - std::vector sumCasePairs = this->summaryAddressSelection()->selectedCurveDefinitions(); + std::vector sumCasePairs = this->summaryAddressSelection()->allCurveDefinitionsFromSelection(); if (sumCasePairs.size() == 1) { curveAddressText = sumCasePairs.front().curveDefinitionText(); From d34e517968c51af3169f04558d9d30d6d5f6cd44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 14:25:53 +0200 Subject: [PATCH 0993/1027] #2917 Vector Selection Dialog: Fix missing selection text --- ApplicationCode/Application/RiaSummaryCurveDefinition.cpp | 4 +++- .../UserInterface/RiuSummaryCurveDefSelectionDialog.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index 93d26a97a9..4ebc23a301 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -20,6 +20,7 @@ #include "RifSummaryReaderInterface.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" //-------------------------------------------------------------------------------------------------- /// @@ -116,7 +117,8 @@ QString RiaSummaryCurveDefinition::curveDefinitionText() const { QString caseName; if (summaryCase() ) caseName = summaryCase()->caseName(); - + else if (ensemble()) caseName = ensemble()->name(); + return RiaSummaryCurveDefinition::curveDefinitionText(caseName, summaryAddress()); } diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp index 4a89a98beb..d12beebecc 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp @@ -109,7 +109,7 @@ void RiuSummaryCurveDefSelectionDialog::setEnsembleAndAddress(RimSummaryCaseColl //-------------------------------------------------------------------------------------------------- std::vector RiuSummaryCurveDefSelectionDialog::curveSelection() const { - return summaryAddressSelection()->allCurveDefinitionsFromSelection(); + return summaryAddressSelection()->selection(); } //-------------------------------------------------------------------------------------------------- @@ -142,7 +142,7 @@ RiuSummaryCurveDefSelection* RiuSummaryCurveDefSelectionDialog::summaryAddressSe void RiuSummaryCurveDefSelectionDialog::updateLabel() { QString curveAddressText; - std::vector sumCasePairs = this->summaryAddressSelection()->allCurveDefinitionsFromSelection(); + std::vector sumCasePairs = this->summaryAddressSelection()->selection(); if (sumCasePairs.size() == 1) { curveAddressText = sumCasePairs.front().curveDefinitionText(); From e355651b99154c8098464a01aa32d53e706aabcc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 15 May 2018 14:37:46 +0200 Subject: [PATCH 0994/1027] #2919 Summary Plot Title : Always show "Composed Plot" for curve combinations --- .../Summary/RimSummaryPlotNameHelper.cpp | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 59789ed6fc..e7cd195bd5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -191,25 +191,29 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() auto wellNames = m_analyzer.wellNames(); auto wellGroupNames = m_analyzer.wellGroupNames(); auto regions = m_analyzer.regionNumbers(); + auto categories = m_analyzer.categories(); - if (quantities.size() == 1) + if (categories.size() == 1) { - m_titleQuantity = *(quantities.begin()); - } + if (quantities.size() == 1) + { + m_titleQuantity = *(quantities.begin()); + } - if (wellNames.size() == 1) - { - m_titleWellName = *(wellNames.begin()); - } + if (wellNames.size() == 1) + { + m_titleWellName = *(wellNames.begin()); + } - if (wellGroupNames.size() == 1) - { - m_titleWellGroupName = *(wellGroupNames.begin()); - } + if (wellGroupNames.size() == 1) + { + m_titleWellGroupName = *(wellGroupNames.begin()); + } - if (regions.size() == 1) - { - m_titleRegion = std::to_string(*(regions.begin())); + if (regions.size() == 1) + { + m_titleRegion = std::to_string(*(regions.begin())); + } } if (m_summaryCases.size() == 1 && m_ensembleCases.empty()) From 7103ff73a2fe2346f1fd84881a65e1dec2a0147f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 15 May 2018 15:08:02 +0200 Subject: [PATCH 0995/1027] Renaming 'Restart Files' to 'Origin Files' --- ApplicationCode/Application/RiaPreferences.cpp | 2 +- ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index d11752f110..7de821f1a7 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -193,7 +193,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& m_readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup); - caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Restart Files"); + caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Origin Files"); restartBehaviourGroup->add(&summaryRestartFilesShowImportDialog); caf::PdmUiGroup* summaryImportOptionGroup = restartBehaviourGroup->addNewGroup("Origin Summary Files"); summaryImportOptionGroup->add(&summaryImportMode); diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index daa2f124f4..ecc1b08d56 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -384,7 +384,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.displayWarningsIfAny(reader.warnings()); // Set properties and show dialog - dialog.setWindowTitle("Restart Files"); + dialog.setWindowTitle("Origin Files"); dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); From 0c9470fdf059827dc4a997ee687c0ee35f4542c9 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 15:43:04 +0200 Subject: [PATCH 0996/1027] #2913 Improve coupling between egrid and summary cases * Convert RimGridSummaryCase to RimFileSummaryCase when closing grid. --- .../Tools/RiaImportEclipseCaseTools.cpp | 82 ++++++++++++------- .../Commands/RicCloseCaseFeature.cpp | 19 +++++ .../Summary/RimGridSummaryCase.cpp | 11 +++ .../Summary/RimGridSummaryCase.h | 2 + .../Summary/RimSummaryCase.cpp | 14 ++++ .../ProjectDataModel/Summary/RimSummaryCase.h | 1 + .../Summary/RimSummaryCaseMainCollection.cpp | 68 +++++++++++++++ .../Summary/RimSummaryCaseMainCollection.h | 2 + 8 files changed, 169 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index e28f5dfd20..139741cb1d 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -34,12 +34,15 @@ #include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" +#include "RimFileSummaryCase.h" +#include "RimGridSummaryCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" @@ -83,48 +86,67 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file if (!summaryFileInfos.empty()) { RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; - std::vector newSumCases = sumCaseColl->createAndAddSummaryCasesFromFileInfos(summaryFileInfos); - - for (RimSummaryCase* newSumCase : newSumCases) + if (sumCaseColl) { - QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); - RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); - if (gridCase) + std::vector newSumCases = sumCaseColl->createSummaryCasesFromFileInfos(summaryFileInfos); + + for (RimSummaryCase* newSumCase : newSumCases) { - RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); - if (existingFileSummaryCase) + RimSummaryCaseCollection* existingCollection = nullptr; + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); + RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); + if (gridCase) { - // Replace all occurrences of file sum with ecl sum + RimSummaryCase* existingSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); + RimGridSummaryCase* existingGridSummaryCase = dynamic_cast(existingSummaryCase); + RimFileSummaryCase* existingFileSummaryCase = dynamic_cast(existingSummaryCase); + if (existingGridSummaryCase) + { + delete newSumCase; // No need to add anything new. Already have one. + continue; + } + else if (existingFileSummaryCase) + { + existingFileSummaryCase->firstAncestorOrThisOfType(existingCollection); - std::vector referringObjects; - existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); + // Replace all occurrences of file sum with ecl sum - // UI settings of a curve filter is updated based - // on the new case association for the curves in the curve filter - // UI is updated by loadDataAndUpdate() + std::vector referringObjects; + existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); - for (caf::PdmObjectHandle* objHandle : referringObjects) - { - RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); - if (summaryCurve) + // UI settings of a curve filter is updated based + // on the new case association for the curves in the curve filter + // UI is updated by loadDataAndUpdate() + + for (caf::PdmObjectHandle* objHandle : referringObjects) { - RimSummaryCurveCollection* parentCollection = nullptr; - summaryCurve->firstAncestorOrThisOfType(parentCollection); - if (parentCollection) + RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); + if (summaryCurve) { - parentCollection->loadDataAndUpdate(true); - parentCollection->updateConnectedEditors(); - break; + RimSummaryCurveCollection* parentCollection = nullptr; + summaryCurve->firstAncestorOrThisOfType(parentCollection); + if (parentCollection) + { + parentCollection->loadDataAndUpdate(true); + parentCollection->updateConnectedEditors(); + break; + } } } - } - - sumCaseColl->removeCase(existingFileSummaryCase); - - delete existingFileSummaryCase; + // Remove existing case + sumCaseColl->removeCase(existingFileSummaryCase); + delete existingFileSummaryCase; + } + } + if (existingCollection) + { + existingCollection->addCase(newSumCase); + } + else + { + sumCaseColl->addCase(newSumCase); } - sumCaseColl->updateAllRequiredEditors(); } } diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.cpp b/ApplicationCode/Commands/RicCloseCaseFeature.cpp index 6a3200a546..6f76b80e81 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseCaseFeature.cpp @@ -23,6 +23,7 @@ #include "RimCaseCollection.h" #include "RimEclipseCase.h" +#include "RimEclipseResultCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimGeoMechCase.h" @@ -31,6 +32,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimMainPlotCollection.h" +#include "RimGridSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" #include "RimWellLogPlotCollection.h" #include "RiuMainWindow.h" @@ -186,6 +189,22 @@ void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) removeCaseFromAllGroups(eclipseCase); } + RimEclipseResultCase* resultCase = dynamic_cast(eclipseCase); + if (resultCase) + { + RimProject* project = RiaApplication::instance()->project(); + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + if (sumCaseColl) + { + RimSummaryCase* summaryCase = sumCaseColl->findSummaryCaseFromEclipseResultCase(resultCase); + if (summaryCase) + { + RimGridSummaryCase* gridSummaryCase = dynamic_cast(summaryCase); + sumCaseColl->convertGridSummaryCasesToFileSummaryCases(gridSummaryCase); + } + } + } + delete eclipseCase; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index e62b51e6b8..987a545385 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -196,3 +196,14 @@ void RimGridSummaryCase::setIncludeRestartFiles(bool includeRestartFiles) m_includeRestartFiles = includeRestartFiles; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileSummaryCase* RimGridSummaryCase::createFileSummaryCaseCopy() +{ + RimFileSummaryCase* fileSummaryCase = new RimFileSummaryCase(); + fileSummaryCase->copyFrom(*this); + fileSummaryCase->setIncludeRestartFiles(m_includeRestartFiles()); + return fileSummaryCase; +} + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h index 7adfcf4eb4..4242be37d8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h @@ -26,6 +26,7 @@ class RimEclipseCase; class RifReaderEclipseSummary; +class RimFileSummaryCase; //================================================================================================== // @@ -52,6 +53,7 @@ class RimGridSummaryCase : public RimSummaryCase void setIncludeRestartFiles(bool includeRestartFiles); + RimFileSummaryCase* createFileSummaryCaseCopy(); private: QString eclipseGridFileName() const; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index bc94b1ed2f..563c87501f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -126,6 +126,20 @@ bool RimSummaryCase::isEnsembleCase() const return ensemble() != nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::copyFrom(const RimSummaryCase& rhs) +{ + m_shortName = rhs.m_shortName; + m_useAutoShortName = rhs.m_useAutoShortName; + m_summaryHeaderFilename = rhs.m_summaryHeaderFilename; + m_isObservedData = rhs.m_isObservedData; + + this->updateTreeItemName(); + this->updateOptionSensitivity(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index bbad294128..44d661febd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -62,6 +62,7 @@ class RimSummaryCase : public caf::PdmObject bool hasCaseRealizationParameters() const; RimSummaryCaseCollection* ensemble() const; bool isEnsembleCase() const; + void copyFrom(const RimSummaryCase& rhs); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 0f99777eaa..abc9b141d5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -111,6 +111,19 @@ void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCa } } + for (size_t sccIdx = 0; sccIdx < m_caseCollections.size() && !isFound; ++sccIdx) + { + for (RimSummaryCase* sumCase : m_caseCollections[sccIdx]->allSummaryCases()) + { + RimGridSummaryCase* grdSumCase = dynamic_cast(sumCase); + if (grdSumCase && grdSumCase->associatedEclipseCase() == eclResCase) + { + isFound = true; + break; + } + } + } + if (!isFound) { // Create new GridSummaryCase @@ -143,6 +156,18 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromEclipseResultCa } } + for (auto collection : m_caseCollections) + { + for (RimSummaryCase* sumCase : collection->allSummaryCases()) + { + RimGridSummaryCase* gridSummaryCase = dynamic_cast(sumCase); + if (gridSummaryCase && gridSummaryCase->associatedEclipseCase()->gridFileName() == eclipseResultCase->gridFileName()) + { + return gridSummaryCase; + } + } + } + return nullptr; } @@ -168,9 +193,52 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const } } + for (auto collection : m_caseCollections) + { + for (RimSummaryCase* summaryCase : collection->allSummaryCases()) + { + RimFileSummaryCase* fileSummaryCase = dynamic_cast(summaryCase); + if (fileSummaryCase) + { + QFileInfo summaryFileInfo(fileSummaryCase->summaryHeaderFilename()); + if (incomingFileInfo == summaryFileInfo) + { + return fileSummaryCase; + } + } + } + } + return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::convertGridSummaryCasesToFileSummaryCases(RimGridSummaryCase* gridSummaryCase) +{ + RimFileSummaryCase* fileSummaryCase = gridSummaryCase->createFileSummaryCaseCopy(); + addCaseRealizationParametersIfFound(*fileSummaryCase, fileSummaryCase->summaryHeaderFilename()); + + RimSummaryCaseCollection* collection; + gridSummaryCase->firstAncestorOrThisOfType(collection); + + removeCase(gridSummaryCase); + delete gridSummaryCase; + + if (collection) + { + collection->addCase(fileSummaryCase); + collection->updateConnectedEditors(); + } + else + { + this->addCase(fileSummaryCase); + this->updateConnectedEditors(); + } + loadSummaryCaseData({ fileSummaryCase }); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index ed85373a67..401152410b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -22,6 +22,7 @@ #include +class RimGridSummaryCase; class RimSummaryCase; class RimEclipseResultCase; class RimSummaryCaseCollection; @@ -50,6 +51,7 @@ class RimSummaryCaseMainCollection : public caf::PdmObject RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; + void convertGridSummaryCasesToFileSummaryCases(RimGridSummaryCase* gridSummaryCase); void addCases(const std::vector cases); void addCase(RimSummaryCase* summaryCase); From d1a706de553c12530c64d9c12096cfbeaf7b13c8 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 16:12:12 +0200 Subject: [PATCH 0997/1027] #2913 Make sure only one grid summary case is created per egrid loaded. * If you open two of the same eclipse case, you will still have two grid summary cases * But if you open multiple summary cases of the same eclipse case the additional summary cases are file summary cases. --- .../Summary/RimSummaryCaseMainCollection.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index abc9b141d5..9a2ec83784 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -182,13 +182,12 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const for (RimSummaryCase* summaryCase : m_cases) { - RimFileSummaryCase* fileSummaryCase = dynamic_cast(summaryCase); - if (fileSummaryCase) + if (summaryCase) { - QFileInfo summaryFileInfo(fileSummaryCase->summaryHeaderFilename()); + QFileInfo summaryFileInfo(summaryCase->summaryHeaderFilename()); if (incomingFileInfo == summaryFileInfo) { - return fileSummaryCase; + return summaryCase; } } } @@ -197,13 +196,12 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const { for (RimSummaryCase* summaryCase : collection->allSummaryCases()) { - RimFileSummaryCase* fileSummaryCase = dynamic_cast(summaryCase); - if (fileSummaryCase) + if (summaryCase) { - QFileInfo summaryFileInfo(fileSummaryCase->summaryHeaderFilename()); + QFileInfo summaryFileInfo(summaryCase->summaryHeaderFilename()); if (incomingFileInfo == summaryFileInfo) { - return fileSummaryCase; + return summaryCase; } } } @@ -432,7 +430,9 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); } - if (eclCase) + RimGridSummaryCase* existingGridSummaryCase = dynamic_cast(findSummaryCaseFromFileName(fileInfo.summaryFileName())); + + if (eclCase && !existingGridSummaryCase) { RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); From 461d22b2b50d6b44fbaefc65a2ca44e211452f00 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 16:20:25 +0200 Subject: [PATCH 0998/1027] #1908 Stop creating new summary cases when opening a project file. --- .../Application/RiaApplication.cpp | 1 - .../Summary/RimSummaryCaseMainCollection.cpp | 60 ------------------- .../Summary/RimSummaryCaseMainCollection.h | 1 - 3 files changed, 62 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 6021ba10b8..2269e84847 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -478,7 +478,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { oilField->summaryCaseMainCollection = new RimSummaryCaseMainCollection(); } - oilField->summaryCaseMainCollection()->createSummaryCasesFromRelevantEclipseResultCases(); oilField->summaryCaseMainCollection()->loadAllSummaryCaseData(); if (!oilField->observedDataCollection()) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 9a2ec83784..45b2a78c0c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -79,66 +79,6 @@ RimSummaryCaseMainCollection::~RimSummaryCaseMainCollection() m_caseCollections.deleteAllChildObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCases() -{ - RimProject* proj = nullptr; - firstAncestorOrThisOfType(proj); - if (proj) - { - std::vector all3DCases; - proj->allCases(all3DCases); - for (RimCase* aCase: all3DCases) - { - RimEclipseResultCase* eclResCase = dynamic_cast(aCase); - if (eclResCase) - { - // If we have no summary case corresponding to this eclipse case, - // try to create one. - bool isFound = false; - for (size_t scIdx = 0; scIdx < m_cases.size(); ++scIdx) - { - RimGridSummaryCase* grdSumCase = dynamic_cast(m_cases[scIdx]); - if (grdSumCase) - { - if (grdSumCase->associatedEclipseCase() == eclResCase) - { - isFound = true; - break; - } - } - } - - for (size_t sccIdx = 0; sccIdx < m_caseCollections.size() && !isFound; ++sccIdx) - { - for (RimSummaryCase* sumCase : m_caseCollections[sccIdx]->allSummaryCases()) - { - RimGridSummaryCase* grdSumCase = dynamic_cast(sumCase); - if (grdSumCase && grdSumCase->associatedEclipseCase() == eclResCase) - { - isFound = true; - break; - } - } - } - - if (!isFound) - { - // Create new GridSummaryCase - QStringList summaryFileNames = RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(QStringList({ eclResCase->gridFileName() })); - if (!summaryFileNames.isEmpty()) - { - RifSummaryCaseFileResultInfo fileInfo(summaryFileNames.front(), false); - createAndAddSummaryCasesFromFileInfos({ fileInfo }); - } - } - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index 401152410b..45f837edd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -45,7 +45,6 @@ class RimSummaryCaseMainCollection : public caf::PdmObject std::vector topLevelSummaryCases() const; std::vector summaryCaseCollections() const; - void createSummaryCasesFromRelevantEclipseResultCases(); std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos, bool showProgress = false); From 79a8af0e117682ebfb13c49e7a95c08ad4ce0428 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 17:14:59 +0200 Subject: [PATCH 0999/1027] #2921 Hide name config in tree view --- ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 1c4c13953f..d65ee13fb9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -77,6 +77,7 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); + this->uiCapability()->setUiTreeChildrenHidden(true); } //-------------------------------------------------------------------------------------------------- From 1b6d6e714ca8fd3eb2230cb2f919ea0c4ac4d3d0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 17:16:43 +0200 Subject: [PATCH 1000/1027] #2923 Show sensible curve segments to range limits when points are outside range --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 2a8bd2e35e..927967d576 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -122,19 +122,22 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display double maxVisibleResult = -std::numeric_limits::max(); double minVisibleResult = std::numeric_limits::max(); + double minCurveValue = rim3dWellLogCurve->minCurveUIValue(); + double maxCurveValue = rim3dWellLogCurve->maxCurveUIValue(); + double curveEpsilon = 1.0e-6; for (double& result : m_curveValues) { if (!RigCurveDataTools::isValidValue(result, false)) continue; - if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange) + if ((minCurveValue - result) > curveEpsilon * curveUIRange) { - result = -std::numeric_limits::infinity(); + result = minCurveValue - curveEpsilon; } - else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange) + else if ((result - maxCurveValue) > curveEpsilon * curveUIRange) { - result = std::numeric_limits::infinity(); + result = maxCurveValue + curveEpsilon; } else { @@ -157,7 +160,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) { - scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - rim3dWellLogCurve->minCurveUIValue()) * plotRangeToResultRangeFactor; + scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minCurveValue) * plotRangeToResultRangeFactor; } cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint)); @@ -185,8 +188,12 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) { - indices.push_back(cvf::uint(i)); - indices.push_back(cvf::uint(i + 1)); + if (cvf::Math::valueInRange(m_curveValues[i], minCurveValue, maxCurveValue) || + cvf::Math::valueInRange(m_curveValues[i + 1], minCurveValue, maxCurveValue)) + { + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); + } } } From 5aa6ebbd76c2487f56d5cba3f9b3ba1a508f68ae Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 17:54:20 +0200 Subject: [PATCH 1001/1027] #2922 Change curve min/max when updating case and timestep. --- .../ProjectDataModel/Rim3dWellLogExtractionCurve.cpp | 12 ++++++++++++ .../ProjectDataModel/Rim3dWellLogExtractionCurve.h | 1 + .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index d7cb84510b..6bbac0de76 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -265,6 +265,18 @@ caf::PdmFieldHandle* Rim3dWellLogExtractionCurve::userDescriptionField() return m_nameConfig()->nameField(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_timeStep || changedField == &m_case) + { + this->resetMinMaxValuesAndUpdateUI(); + } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h index cdbb90a382..a37e06aec5 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h @@ -50,6 +50,7 @@ class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve virtual QString createCurveAutoName() const override; protected: virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp index 94cf60912d..29fb3db642 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -142,7 +142,7 @@ void Rim3dWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFi const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &m_wellLogChannelName) + if (changedField == &m_wellLogChannelName || changedField == &m_timeStep) { this->resetMinMaxValuesAndUpdateUI(); } From 66e548ac04ce4de0e91692d7286f5e97dcf77b43 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 15 May 2018 18:04:27 +0200 Subject: [PATCH 1002/1027] #2924 3D well Log curves: Implement variable name for geomech result --- .../Rim3dWellLogExtractionCurve.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp index 6bbac0de76..afde7d1128 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -45,6 +45,8 @@ #include "RimWellLogFileChannel.h" #include "RimWellPath.h" +#include "cafUtils.h" + #include //================================================================================================== @@ -126,7 +128,28 @@ void Rim3dWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) //-------------------------------------------------------------------------------------------------- QString Rim3dWellLogExtractionCurve::resultPropertyString() const { - return m_eclipseResultDefinition->resultVariableUiName(); + RimGeoMechCase* geoMechCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QString name; + if (eclipseCase) + { + name = caf::Utils::makeValidFileBasename(m_eclipseResultDefinition->resultVariableUiName()); + } + else if (geoMechCase) + { + QString resCompName = m_geomResultDefinition->resultComponentUiName(); + if (resCompName.isEmpty()) + { + name = m_geomResultDefinition->resultFieldUiName(); + } + else + { + name = m_geomResultDefinition->resultFieldUiName() + "." + resCompName; + } + } + + return name; } //-------------------------------------------------------------------------------------------------- From c1b4cfc3e67610b79764934c2fa78528ca679c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 18:07:32 +0200 Subject: [PATCH 1003/1027] #2925 3D Well Log Curves: Fix missing plot/curves when Color Result = None. Moved the part generation from appendDynamicGeometryParts to appendStatic... --- .../ModelVisualization/RivWellPathPartMgr.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 453aa00993..4a45594996 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -502,6 +502,12 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize); appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); + + RimGridView* gridView = dynamic_cast(m_rimView.p()); + if (!gridView) return; + + m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); + m_3dWellLogPlanePartMgr->appendPlaneToModel(model, displayCoordTransform, wellPathClipBoundingBox); } //-------------------------------------------------------------------------------------------------- @@ -560,12 +566,6 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false); appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); - - RimGridView* gridView = dynamic_cast(m_rimView.p()); - if (!gridView) return; - - m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); - m_3dWellLogPlanePartMgr->appendPlaneToModel(model, displayCoordTransform, wellPathClipBoundingBox); } //-------------------------------------------------------------------------------------------------- From 260e8537f610d175e16d3f47b3aebf617bdaf265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 15 May 2018 18:15:47 +0200 Subject: [PATCH 1004/1027] Upped to version 2018.01.1-devRC.110 before final testing and documentation before release 2018.05 --- ResInsightVersion.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index ef7e164459..666258a6d3 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -4,13 +4,13 @@ set(RESINSIGHT_MINOR_VERSION 01) set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-dev") +set(RESINSIGHT_VERSION_TEXT "-devRC") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".109") +set(RESINSIGHT_DEV_VERSION ".110") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 79928702bf1507d39248583c798b61ac10170d8c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 16 May 2018 08:35:11 +0200 Subject: [PATCH 1005/1027] #2920 Save window state for main window when closing plot window last (and vice versa). --- ApplicationCode/Application/RiaApplication.cpp | 17 +++++++++++++++++ ApplicationCode/Application/RiaApplication.h | 2 +- ApplicationCode/UserInterface/RiuMainWindow.cpp | 2 +- .../UserInterface/RiuPlotMainWindow.cpp | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 2269e84847..c66410e092 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1536,6 +1536,23 @@ void RiaApplication::waitUntilCommandObjectsHasBeenProcessed() m_commandQueueLock.unlock(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::saveWinGeoAndDockToolBarLayout() +{ + if (m_mainPlotWindow) + { + m_mainPlotWindow->saveWinGeoAndDockToolBarLayout(); + } + + if (RiuMainWindow::instance()) + { + RiuMainWindow::instance()->saveWinGeoAndDockToolBarLayout(); + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index f920cadfcd..0d538520c8 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -200,7 +200,7 @@ class RiaApplication : public QApplication static std::vector readFileListFromTextFile(QString listFileName); void waitUntilCommandObjectsHasBeenProcessed(); - + void saveWinGeoAndDockToolBarLayout(); private: void onProjectOpenedOrClosed(); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 37ba5431ea..b0d0bfa289 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -250,7 +250,7 @@ void RiuMainWindow::closeEvent(QCloseEvent* event) return; } - saveWinGeoAndDockToolBarLayout(); + app->saveWinGeoAndDockToolBarLayout(); if (!app->tryClosePlotWindow()) return; diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index 9586dd002c..c80bfe031c 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -151,7 +151,7 @@ void RiuPlotMainWindow::closeEvent(QCloseEvent* event) return; } - saveWinGeoAndDockToolBarLayout(); + app->saveWinGeoAndDockToolBarLayout(); if (!app->tryCloseMainWindow()) return; From 3bc952b77f78aecfebec64d758fa8c9c157bcf7a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 16 May 2018 10:57:43 +0200 Subject: [PATCH 1006/1027] #2933 Calculator : Auto fill address selection based on last entered address --- .../RimSummaryCalculationVariable.cpp | 54 ++++++++++++++++++- .../RimSummaryCalculationVariable.h | 4 ++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 051be7fd3f..c5f31f6842 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -18,8 +18,12 @@ #include "RimSummaryCalculationVariable.h" +#include "RiaApplication.h" #include "RiaSummaryCurveDefinition.h" +#include "RifEclipseSummaryAddressQMetaType.h" + +#include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCalculation.h" #include "RimSummaryCase.h" @@ -86,7 +90,8 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* { RiuSummaryCurveDefSelectionDialog dlg(nullptr); dlg.hideEnsembles(); - dlg.setCaseAndAddress(m_case(), m_summaryAddress->address()); + + readDataFromApplicationStore(&dlg); if (dlg.exec() == QDialog::Accepted) { @@ -96,6 +101,8 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* m_case = curveSelection[0].summaryCase(); m_summaryAddress->setAddress(curveSelection[0].summaryAddress()); + writeDataToApplicationStore(); + updateContainingEditor = true; } } @@ -168,3 +175,48 @@ void RimSummaryCalculationVariable::defineObjectEditorAttribute(QString uiConfig attr->registerPushButtonTextForFieldKeyword(m_button.keyword(), "Edit"); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::readDataFromApplicationStore(RiuSummaryCurveDefSelectionDialog* selectionDialog) const +{ + if (!selectionDialog) return; + + auto sumCase = m_case(); + auto sumAddress = m_summaryAddress->address(); + if (!sumCase && !sumAddress.isValid()) + { + QVariant var = RiaApplication::instance()->cacheDataObject("CalculatorSummaryAddress"); + + auto lastUsedAddress = var.value(); + if (lastUsedAddress.isValid()) + { + sumAddress = lastUsedAddress; + } + + QString lastUsedSummaryCaseString = RiaApplication::instance()->cacheDataObject("CalculatorSummaryCase").toString(); + + auto* lastUsedSummaryCase = dynamic_cast( + caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedSummaryCaseString)); + if (lastUsedSummaryCase) + { + sumCase = lastUsedSummaryCase; + } + } + + selectionDialog->setCaseAndAddress(sumCase, sumAddress); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::writeDataToApplicationStore() const +{ + QString refFromProjectToObject = + caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), m_case); + RiaApplication::instance()->setCacheDataObject("CalculatorSummaryCase", refFromProjectToObject); + + QVariant sumAdrVar = QVariant::fromValue(m_summaryAddress->address()); + RiaApplication::instance()->setCacheDataObject("CalculatorSummaryAddress", sumAdrVar); +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h index be9b9c2967..baff8ada55 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h @@ -28,6 +28,7 @@ class RimSummaryCase; class RimSummaryAddress; +class RiuSummaryCurveDefSelectionDialog; //================================================================================================== /// @@ -53,6 +54,9 @@ class RimSummaryCalculationVariable : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + void readDataFromApplicationStore(RiuSummaryCurveDefSelectionDialog* selectionDialog) const; + void writeDataToApplicationStore() const; + private: caf::PdmField m_name; caf::PdmProxyValueField m_summaryAddressUi; From cb74354bc24ba436f315550e703376a2b6787f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 16 May 2018 14:54:16 +0200 Subject: [PATCH 1007/1027] Ensemble curves. Increased ensemble curve count threshold from 200 to 600 --- .../Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 471182f19b..fba1f1dcdc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -61,6 +61,11 @@ CAF_PDM_SOURCE_INIT(RicSummaryCurveCreator, "RicSummaryCurveCreator"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const size_t ENSEMBLE_CURVE_COUNT_THRESHOLD = 600; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -380,7 +385,6 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions( const std::set& curveDefsToAdd, const std::set& curvesToDelete) { - const size_t ENSEMBLE_CURVE_COUNT_THRESHOLD = 200; static bool warningDisplayed = false; RimSummaryCase* prevCase = nullptr; From 2c2a2c6102c907e6888bf3f54d1116942b68b715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 18 May 2018 10:44:21 +0200 Subject: [PATCH 1008/1027] Fix Linux build warning --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index c38a798316..dd352de616 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -865,7 +865,7 @@ RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const copy->m_yValuesSummaryGroup = m_yValuesSummaryGroup(); // Update summary case references - for (int i = 0; i < m_curves.size(); i++) + for (size_t i = 0; i < m_curves.size(); i++) { copy->m_curves[i]->setSummaryCaseY(m_curves[i]->summaryCaseY()); } From 439b8e22adda341d1ce731610941e5243bbadf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 May 2018 13:39:20 +0200 Subject: [PATCH 1009/1027] #2940 Geomech: Use display offset for FEM parts --- .../RivFemPartGeometryGenerator.cpp | 20 +++++++++---------- .../ProjectDataModel/RimGeoMechCase.cpp | 8 ++++++++ .../ProjectDataModel/RimGeoMechCase.h | 4 ++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index 07f8789d71..02590b7e91 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -188,7 +188,7 @@ void RivFemPartGeometryGenerator::computeArrays() trianglesToElements.reserve(estimatedQuadVxCount/2); trianglesToElementFaces.reserve(estimatedQuadVxCount/2); - cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset(); + cvf::Vec3d displayOffset = m_part->boundingBox().min(); const std::vector& nodeCoordinates = m_part->nodes().coordinates; #pragma omp parallel for schedule(dynamic) @@ -217,12 +217,10 @@ void RivFemPartGeometryGenerator::computeArrays() if (faceNodeCount == 4) { - const cvf::Vec3f* quadVxs[4]; - - quadVxs[0] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]); - quadVxs[1] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[1]] ]); - quadVxs[2] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[2]] ]); - quadVxs[3] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[3]] ]); + cvf::Vec3f quadVxs0 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]) - displayOffset); + cvf::Vec3f quadVxs1 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[1]] ]) - displayOffset); + cvf::Vec3f quadVxs2 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[2]] ]) - displayOffset); + cvf::Vec3f quadVxs3 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[3]] ]) - displayOffset); int qNodeIdx[4]; qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]]; @@ -238,10 +236,10 @@ void RivFemPartGeometryGenerator::computeArrays() #pragma omp critical { - vertices.push_back(*quadVxs[0]); - vertices.push_back(*quadVxs[1]); - vertices.push_back(*quadVxs[2]); - vertices.push_back(*quadVxs[3]); + vertices.push_back(quadVxs0); + vertices.push_back(quadVxs1); + vertices.push_back(quadVxs2); + vertices.push_back(quadVxs3); m_quadVerticesToNodeIdx.push_back(qNodeIdx[0]); m_quadVerticesToNodeIdx.push_back(qNodeIdx[1]); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 90b3360c8c..2e4dd648f1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -399,6 +399,14 @@ double RimGeoMechCase::frictionAngleDeg() const return m_frictionAngleDeg; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimGeoMechCase::displayModelOffset() const +{ + return this->allCellsBoundingBox().min(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 13c6b897d4..3caae63564 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -78,7 +78,11 @@ class RimGeoMechCase : public RimCase caf::PdmChildArrayField geoMechViews; + + + private: + virtual cvf::Vec3d displayModelOffset() const override; static std::vector dateTimeVectorFromTimeStepStrings(const QStringList& timeStepStrings); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; From 3119ab24cb3db35c55d0168109fbf0381b51fe19 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 18 May 2018 14:01:04 +0200 Subject: [PATCH 1010/1027] #2934 Delete all selected cases, not just the first one when right clicking and choosing close. --- .../Commands/RicCloseCaseFeature.cpp | 72 +++++++++---------- .../Commands/RicCloseCaseFeature.h | 4 +- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.cpp b/ApplicationCode/Commands/RicCloseCaseFeature.cpp index 6f76b80e81..0fb3100b0c 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseCaseFeature.cpp @@ -52,7 +52,7 @@ CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature"); //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::isCommandEnabled() { - return selectedEclipseCase() != nullptr || selectedGeoMechCase() != nullptr; + return !selectedCases().empty(); } //-------------------------------------------------------------------------------------------------- @@ -60,24 +60,44 @@ bool RicCloseCaseFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::onActionTriggered(bool isChecked) { - RimEclipseCase* eclipseCase = selectedEclipseCase(); - RimGeoMechCase* geoMechCase = selectedGeoMechCase(); - if (eclipseCase) + std::vector rimCases = selectedCases(); + std::vector eclipseCases; + std::vector geoMechCases; + for (RimCase* rimCase : selectedCases()) { - std::vector casesToBeDeleted; - casesToBeDeleted.push_back(eclipseCase); - - if (userConfirmedGridCaseGroupChange(casesToBeDeleted)) + RimEclipseCase* eclipseCase = dynamic_cast(rimCase); + if (eclipseCase) { - deleteEclipseCase(eclipseCase); + eclipseCases.push_back(eclipseCase); + } + else + { + RimGeoMechCase* geoMechCase = dynamic_cast(rimCase); + if (geoMechCase) + { + geoMechCases.push_back(geoMechCase); + } + } + } + if (!eclipseCases.empty()) + { + if (userConfirmedGridCaseGroupChange(eclipseCases)) + { + for (RimEclipseCase* eclipseCase : eclipseCases) + { + deleteEclipseCase(eclipseCase); + } RiuMainWindow::instance()->cleanupGuiCaseClose(); } } - else if (geoMechCase) + + if (!geoMechCases.empty()) { - deleteGeoMechCase(geoMechCase); - + for (RimGeoMechCase* geoMechCase : geoMechCases) + { + deleteGeoMechCase(geoMechCase); + } RiuMainWindow::instance()->cleanupGuiCaseClose(); } } @@ -95,33 +115,11 @@ void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseCase* RicCloseCaseFeature::selectedEclipseCase() const +std::vector RicCloseCaseFeature::selectedCases() const { - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType(&selection); - - if (selection.size() > 0) - { - return selection[0]; - } - - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeoMechCase* RicCloseCaseFeature::selectedGeoMechCase() const -{ - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); - - if (selection.size() > 0) - { - return selection[0]; - } - - return nullptr; + return selection; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.h b/ApplicationCode/Commands/RicCloseCaseFeature.h index 7e6199f9b1..fd8224dcb9 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.h +++ b/ApplicationCode/Commands/RicCloseCaseFeature.h @@ -25,6 +25,7 @@ class RimEclipseCase; class RimGeoMechCase; +class RimCase; class RimIdenticalGridCaseGroup; //================================================================================================== @@ -45,8 +46,7 @@ class RicCloseCaseFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ); private: - RimEclipseCase* selectedEclipseCase() const; - RimGeoMechCase* selectedGeoMechCase() const; + std::vector selectedCases() const; void deleteGeoMechCase(RimGeoMechCase* geoMechCase); From 73c0373264b62ece0151af3b053d022d7b155b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 May 2018 14:02:54 +0200 Subject: [PATCH 1011/1027] #2940 Geomech: Display offset in place for intersections --- .../Intersections/RivHexGridIntersectionTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp index 98bca93107..778d5df51c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp @@ -111,7 +111,7 @@ RivFemIntersectionGrid::RivFemIntersectionGrid(const RigFemPart * femPart) : m_f //-------------------------------------------------------------------------------------------------- cvf::Vec3d RivFemIntersectionGrid::displayOffset() const { - return cvf::Vec3d::ZERO; + return m_femPart->boundingBox().min(); } //-------------------------------------------------------------------------------------------------- From 62c3e8324ac618983a581d45e2083e48ea3c697a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 18 May 2018 14:04:36 +0200 Subject: [PATCH 1012/1027] #2940 Geomech: Display offset in place for result info --- .../UserInterface/RiuFemResultTextBuilder.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 926377aaeb..d0fcd44f82 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -25,14 +25,19 @@ #include "RigFemPartResultsCollection.h" #include "RigFormationNames.h" #include "RigGeoMechCaseData.h" + +#include "Rim2dIntersectionView.h" #include "RimFormationNames.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" -#include "Rim2dIntersectionView.h" + #include "RiuGeoMechXfTensorResultAccessor.h" + #include "RivIntersectionPartMgr.h" +#include "cafDisplayCoordTransform.h" + //-------------------------------------------------------------------------------------------------- @@ -143,20 +148,12 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) j++; k++; - cvf::Vec3d domainCoord = m_intersectionPoint; - - //cvf::StructGridInterface::FaceEnum faceEnum(m_face); - - //QString faceText = faceEnum.text(); - - //text += QString("Face : %1").arg(faceText) + itemSeparator; - //text += QString("Fem Part %1").arg(m_gridIndex) + itemSeparator; text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; QString formattedText; if (m_2dIntersectionView) { - formattedText.sprintf("Horizontal length from well start: %.2f", domainCoord.x()); + formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); text += formattedText + itemSeparator; cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); @@ -169,6 +166,9 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) } else { + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); text += formattedText; } From 68dd0ba13ecd528496d3ab828f2f87b23e70bf45 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 18 May 2018 10:50:13 +0200 Subject: [PATCH 1013/1027] Switch calculation of extra curve vertices to double precision --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 179 +++++++++--------- .../Riv3dWellLogCurveGeometryGenerator.h | 34 ++-- .../Riv3dWellLogDrawSurfaceGenerator.cpp | 14 +- .../Riv3dWellLogDrawSurfaceGenerator.h | 4 +- .../Riv3dWellLogPlanePartMgr.cpp | 2 +- .../Riv3dWellLogPlanePartMgr.h | 2 +- 6 files changed, 121 insertions(+), 114 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 927967d576..3ce784da74 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -49,7 +49,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, double planeWidth, - const std::vector& drawSurfaceVertices) + const std::vector& drawSurfaceVertices) { CVF_ASSERT(rim3dWellLogCurve); @@ -119,8 +119,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end()); - double maxVisibleResult = -std::numeric_limits::max(); - double minVisibleResult = std::numeric_limits::max(); + double maxVisibleResult = -std::numeric_limits::max(); + double minVisibleResult = std::numeric_limits::max(); double minCurveValue = rim3dWellLogCurve->minCurveUIValue(); double maxCurveValue = rim3dWellLogCurve->maxCurveUIValue(); @@ -163,7 +163,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minCurveValue) * plotRangeToResultRangeFactor; } cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); - m_curveVertices.push_back(cvf::Vec3f(curvePoint)); + m_curveVertices.push_back(curvePoint); } m_curveVertices = projectVerticesOntoTriangles(m_curveVertices, drawSurfaceVertices); @@ -174,7 +174,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, md); point += planeOffsetFromWellPathCenter * normal; - m_bottomVertices.push_back(cvf::Vec3f(point)); + m_bottomVertices.push_back(point); } m_bottomVertices = projectVerticesOntoTriangles(m_bottomVertices, drawSurfaceVertices); @@ -205,17 +205,23 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display indexedUInt->setIndices(indexArray.p()); m_curveDrawable->addPrimitiveSet(indexedUInt.p()); - cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices); + cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices.size()); + for (size_t i = 0; i < m_curveVertices.size(); ++i) + { + (*vertexArray)[i] = cvf::Vec3f(m_curveVertices[i]); + } m_curveDrawable->setVertexArray(vertexArray.p()); } + // Disable filled draw style in the GUI because of triangle stitching issue #2860. +#if 0 { CVF_ASSERT(m_bottomVertices.size() == m_curveVertices.size()); cvf::ref vertexArray = new cvf::Vec3fArray(m_bottomVertices.size() + m_curveVertices.size()); for (size_t i = 0; i < m_bottomVertices.size(); ++i) { - (*vertexArray)[2 * i] = m_bottomVertices[i]; - (*vertexArray)[2 * i + 1] = m_curveVertices[i]; + (*vertexArray)[2 * i] = cvf::Vec3f(m_bottomVertices[i]); + (*vertexArray)[2 * i + 1] = cvf::Vec3f(m_curveVertices[i]); } std::vector indices; @@ -233,7 +239,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveFilledDrawable->addPrimitiveSet(indexedUInt.p()); m_curveFilledDrawable->setVertexArray(vertexArray.p()); } - +#endif } //-------------------------------------------------------------------------------------------------- @@ -281,8 +287,7 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 double* measuredDepthAtPoint, double* valueAtClosestPoint) const { - cvf::Vec3f globalIntersectionFloat(globalIntersection); - float closestDistance = m_planeWidth * 0.1; + double closestDistance = m_planeWidth * 0.1; *closestPoint = cvf::Vec3d::UNDEFINED; *measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE; *valueAtClosestPoint = cvf::UNDEFINED_DOUBLE; @@ -294,22 +299,22 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 RigCurveDataTools::isValidValue(m_curveValues[i - 1], false); if (validCurveSegment) { - cvf::Vec3f a = m_curveVertices[i - 1]; - cvf::Vec3f b = m_curveVertices[i]; - cvf::Vec3f ap = globalIntersectionFloat - a; - cvf::Vec3f ab = b - a; + cvf::Vec3d a = m_curveVertices[i - 1]; + cvf::Vec3d b = m_curveVertices[i]; + cvf::Vec3d ap = globalIntersection - a; + cvf::Vec3d ab = b - a; // Projected point is clamped to one of the end points of the segment. - float distanceToProjectedPointAlongAB = ap * ab / (ab * ab); - float clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0f, 1.0f); - cvf::Vec3f projectionOfGlobalIntersection = a + clampedDistance * ab; - float distance = (projectionOfGlobalIntersection - globalIntersectionFloat).length(); + double distanceToProjectedPointAlongAB = ap * ab / (ab * ab); + double clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0, 1.0); + cvf::Vec3d projectionOfGlobalIntersection = a + clampedDistance * ab; + double distance = (projectionOfGlobalIntersection - globalIntersection).length(); if (distance < closestDistance) { *closestPoint = cvf::Vec3d(projectionOfGlobalIntersection); closestDistance = distance; *measuredDepthAtPoint = - m_curveMeasuredDepths[i - 1] * (1.0f - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; - *valueAtClosestPoint = m_curveValues[i - 1] * (1.0f - clampedDistance) + m_curveValues[i] * clampedDistance; + m_curveMeasuredDepths[i - 1] * (1.0 - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; + *valueAtClosestPoint = m_curveValues[i - 1] * (1.0 - clampedDistance) + m_curveValues[i] * clampedDistance; } } } @@ -322,10 +327,10 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) { - std::vector expandedCurveVertices; - std::vector expandedBottomVertices; + std::vector expandedCurveVertices; + std::vector expandedBottomVertices; std::vector expandedMeasuredDepths; std::vector expandedValues; size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); @@ -339,11 +344,11 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) { - cvf::Vec3f lastVertex = m_curveVertices[i]; - cvf::Vec3f fullSegmentVector = m_curveVertices[i + 1] - m_curveVertices[i]; + cvf::Vec3d lastVertex = m_curveVertices[i]; + cvf::Vec3d fullSegmentVector = m_curveVertices[i + 1] - m_curveVertices[i]; - std::vector extraVertices; - std::vector extraBottomVertices; + std::vector extraVertices; + std::vector extraBottomVertices; createNewVerticesAlongSegment(m_curveVertices[i], m_curveVertices[i + 1], @@ -355,15 +360,15 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con CVF_ASSERT(extraVertices.size() == extraBottomVertices.size()); - for (const cvf::Vec3f& extraVertex : extraVertices) + for (const cvf::Vec3d& extraVertex : extraVertices) { - cvf::Vec3f newSegmentVector = extraVertex - lastVertex; + cvf::Vec3d newSegmentVector = extraVertex - lastVertex; // Scalar projection (a * b / |b|) divided by full segment length to become (a * b / |b|^2) - float dotProduct = newSegmentVector * fullSegmentVector; - float fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); - float measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + - m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; - float valueAtPoint = + double dotProduct = newSegmentVector * fullSegmentVector; + double fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); + double measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + + m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; + double valueAtPoint = m_curveValues[i] * (1 - fractionAlongFullSegment) + m_curveValues[i + 1] * fractionAlongFullSegment; expandedCurveVertices.push_back(extraVertex); expandedMeasuredDepths.push_back(measuredDepth); @@ -393,18 +398,18 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf::Vec3f& ptStart, - const cvf::Vec3f& ptEnd, - const std::vector& drawSurfaceVertices, - std::vector* extraVertices, - const cvf::Vec3f* ptBottomStart, - const cvf::Vec3f* ptBottomEnd, - std::vector* extraBottomVertices) +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, + const cvf::Vec3d& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices, + const cvf::Vec3d* ptBottomStart, + const cvf::Vec3d* ptBottomEnd, + std::vector* extraBottomVertices) { - cvf::Vec3f fullSegmentVector = ptEnd - ptStart; + cvf::Vec3d fullSegmentVector = ptEnd - ptStart; extraVertices->push_back(ptStart); - cvf::Vec3f fullBottomVector; + cvf::Vec3d fullBottomVector; if (ptBottomStart && ptBottomEnd && extraBottomVertices) { fullBottomVector = *ptBottomEnd - *ptBottomStart; @@ -414,21 +419,21 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf // Find segments that intersects the triangle edges for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { - caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); - caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); - cvf::Vec3f triangleNormal = + caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); + caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); + cvf::Vec3d triangleNormal = (triangleEdge1.vector().getNormalized() ^ triangleEdge2.vector().getNormalized()).getNormalized(); - cvf::Vec3f currentSubSegment = ptEnd - extraVertices->back(); - cvf::Vec3f projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; - caf::Line projectedCurveLine(extraVertices->back(), extraVertices->back() + projectedSegmentVector); + cvf::Vec3d currentSubSegment = ptEnd - extraVertices->back(); + cvf::Vec3d projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; + caf::Line projectedCurveLine(extraVertices->back(), extraVertices->back() + projectedSegmentVector); // Only attempt to find intersections with the first edge. The other edge is handled with the next triangle. - bool withinSegments = false; - caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); + bool withinSegments = false; + caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); - cvf::Vec3f newVertex = connectingLine.end(); - cvf::Vec3f newSegmentVector = newVertex - extraVertices->back(); + cvf::Vec3d newVertex = connectingLine.end(); + cvf::Vec3d newSegmentVector = newVertex - extraVertices->back(); if (withinSegments && newSegmentVector.lengthSquared() < currentSubSegment.lengthSquared()) { extraVertices->push_back(newVertex); @@ -436,17 +441,17 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf if (ptBottomStart && ptBottomEnd && extraBottomVertices) { // Do the same for the bottom line, however we need to ensure we add the same amount of points. - cvf::Vec3f currentBottomSegment = *ptBottomEnd - extraBottomVertices->back(); - cvf::Vec3f projectedBottomVector = + cvf::Vec3d currentBottomSegment = *ptBottomEnd - extraBottomVertices->back(); + cvf::Vec3d projectedBottomVector = currentBottomSegment - (currentBottomSegment * triangleNormal) * triangleNormal; - caf::Line projectedBottomLine(extraBottomVertices->back(), + caf::Line projectedBottomLine(extraBottomVertices->back(), extraBottomVertices->back() + projectedBottomVector); - bool withinBottomSegments = false; + bool withinBottomSegments = false; - caf::Line bottomConnectingLine = + caf::Line bottomConnectingLine = projectedBottomLine.findLineBetweenNearestPoints(triangleEdge1, &withinBottomSegments); - cvf::Vec3f newBottomVertex = bottomConnectingLine.end(); - cvf::Vec3f newBottomVector = newBottomVertex - extraBottomVertices->back(); + cvf::Vec3d newBottomVertex = bottomConnectingLine.end(); + cvf::Vec3d newBottomVector = newBottomVertex - extraBottomVertices->back(); if (!(withinBottomSegments && newBottomVector.lengthSquared() < fullBottomVector.lengthSquared())) { newBottomVertex = extraBottomVertices->back(); @@ -465,19 +470,19 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector - Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& originalVertices, - const std::vector& drawSurfaceVertices) +std::vector + Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& originalVertices, + const std::vector& drawSurfaceVertices) { - std::vector projectedVertices; + std::vector projectedVertices; projectedVertices.reserve(originalVertices.size()); for (size_t i = 0; i < originalVertices.size(); ++i) { // Sort projections onto triangle by the distance of the projection. - std::map projectionsInsideTriangle; + std::map projectionsInsideTriangle; for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { - cvf::Vec3f triangleVertex1, triangleVertex2, triangleVertex3; + cvf::Vec3d triangleVertex1, triangleVertex2, triangleVertex3; if (j % 2 == 0) { triangleVertex1 = drawSurfaceVertices[j]; @@ -492,7 +497,7 @@ std::vector } bool wasInsideTriangle = false; - cvf::Vec3f projectedPoint = projectPointOntoTriangle( + cvf::Vec3d projectedPoint = projectPointOntoTriangle( originalVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); if (wasInsideTriangle) { @@ -517,37 +522,37 @@ std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3f Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cvf::Vec3f& point, - const cvf::Vec3f& triangleVertex1, - const cvf::Vec3f& triangleVertex2, - const cvf::Vec3f& triangleVertex3, +cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cvf::Vec3d& point, + const cvf::Vec3d& triangleVertex1, + const cvf::Vec3d& triangleVertex2, + const cvf::Vec3d& triangleVertex3, bool* wasInsideTriangle) { *wasInsideTriangle = false; - cvf::Vec3f e1 = triangleVertex2 - triangleVertex1; - cvf::Vec3f e2 = triangleVertex3 - triangleVertex1; - cvf::Vec3f n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); + cvf::Vec3d e1 = triangleVertex2 - triangleVertex1; + cvf::Vec3d e2 = triangleVertex3 - triangleVertex1; + cvf::Vec3d n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); // Project vertex onto triangle plane - cvf::Vec3f av = point - triangleVertex1; - cvf::Vec3f projectedAv = av - (av * n) * n; - cvf::Vec3f projectedPoint = projectedAv + triangleVertex1; + cvf::Vec3d av = point - triangleVertex1; + cvf::Vec3d projectedAv = av - (av * n) * n; + cvf::Vec3d projectedPoint = projectedAv + triangleVertex1; // Calculate barycentric coordinates - float areaABC = n * (e1 ^ e2); - float areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); - float areaPCA = n * ((triangleVertex3 - projectedPoint) ^ (triangleVertex1 - projectedPoint)); - float u = areaPBC / areaABC; - float v = areaPCA / areaABC; - float w = 1.0 - u - v; + double areaABC = n * (e1 ^ e2); + double areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); + double areaPCA = n * ((triangleVertex3 - projectedPoint) ^ (triangleVertex1 - projectedPoint)); + double u = areaPBC / areaABC; + double v = areaPCA / areaABC; + double w = 1.0 - u - v; if (u >= -1.0e-6 && v >= -1.0e-6 && w >= -1.0e-6) { *wasInsideTriangle = true; // Clamp to ensure it is inside the triangle - u = cvf::Math::clamp(u, 0.0f, 1.0f); - v = cvf::Math::clamp(v, 0.0f, 1.0f); - w = cvf::Math::clamp(w, 0.0f, 1.0f); + u = cvf::Math::clamp(u, 0.0, 1.0); + v = cvf::Math::clamp(v, 0.0, 1.0); + w = cvf::Math::clamp(w, 0.0, 1.0); projectedPoint = triangleVertex1 * u + triangleVertex2 * v + triangleVertex3 * w; } return projectedPoint; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h index a4a72a181f..54623244da 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h @@ -52,7 +52,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const Rim3dWellLogCurve* rim3dWellLogCurve, double planeOffsetFromWellPathCenter, double planeWidth, - const std::vector& drawSurfaceVertices); + const std::vector& drawSurfaceVertices); void clearCurvePointsAndGeometry(); @@ -67,28 +67,28 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double* valueAtClosestPoint) const; private: - void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); - static void createNewVerticesAlongSegment(const cvf::Vec3f& ptStart, - const cvf::Vec3f& ptEnd, - const std::vector& drawSurfaceVertices, - std::vector* extraVertices, - const cvf::Vec3f* ptBottomStart = nullptr, - const cvf::Vec3f* ptBottomEnd = nullptr, - std::vector* extraBottomVertices = nullptr); - - static std::vector projectVerticesOntoTriangles(const std::vector& originalVertices, const std::vector& drawSurfaceVertices); - static cvf::Vec3f projectPointOntoTriangle(const cvf::Vec3f& point, - const cvf::Vec3f& triangleVertex1, - const cvf::Vec3f& triangleVertex2, - const cvf::Vec3f& triangleVertex3, + void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); + static void createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, + const cvf::Vec3d& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices, + const cvf::Vec3d* ptBottomStart = nullptr, + const cvf::Vec3d* ptBottomEnd = nullptr, + std::vector* extraBottomVertices = nullptr); + + static std::vector projectVerticesOntoTriangles(const std::vector& originalVertices, const std::vector& drawSurfaceVertices); + static cvf::Vec3d projectPointOntoTriangle(const cvf::Vec3d& point, + const cvf::Vec3d& triangleVertex1, + const cvf::Vec3d& triangleVertex2, + const cvf::Vec3d& triangleVertex3, bool* wasInsideTriangle); caf::PdmPointer m_wellPath; double m_planeWidth; cvf::ref m_curveDrawable; cvf::ref m_curveFilledDrawable; - std::vector m_curveVertices; - std::vector m_bottomVertices; + std::vector m_curveVertices; + std::vector m_bottomVertices; std::vector m_curveMeasuredDepths; std::vector m_curveValues; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 2bdf476f03..30cbfe216e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -114,13 +114,15 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans m_vertices.reserve(wellPathPoints.size() * 2); for (size_t i = 0; i < wellPathPoints.size(); i++) { - m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth))); - m_vertices.push_back(cvf::Vec3f( - wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth))); + m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth)); + m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth)); } - cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices); + cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices.size()); + for (size_t i = 0; i < m_vertices.size(); ++i) + { + (*vertexArray)[i] = cvf::Vec3f(m_vertices[i]); + } createBackground(vertexArray.p()); createBorder(vertexArray.p()); @@ -165,7 +167,7 @@ cvf::ref Riv3dWellLogDrawSurfaceGenerator::curveNormalVect //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& Riv3dWellLogDrawSurfaceGenerator::vertices() const +const std::vector& Riv3dWellLogDrawSurfaceGenerator::vertices() const { return m_vertices; } diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h index 01d0ed186b..8b7922c28b 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h @@ -58,7 +58,7 @@ class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object cvf::ref border() const; cvf::ref curveNormalVectors() const; - const std::vector& vertices() const; + const std::vector& vertices() const; private: void createCurveNormalVectors(const caf::DisplayCoordTransform* displayCoordTransform, @@ -79,5 +79,5 @@ class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object cvf::ref m_border; cvf::ref m_curveNormalVectors; - std::vector m_vertices; + std::vector m_vertices; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index f7a8e7b50c..370c1fe6f2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -91,7 +91,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, Rim3dWellLogCurve* rim3dWellLogCurve, - const std::vector& drawSurfaceVertices) + const std::vector& drawSurfaceVertices) { CVF_ASSERT(rim3dWellLogCurve); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index f7fb4c39a6..bed7b20347 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -60,7 +60,7 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox, Rim3dWellLogCurve* rim3dWellLogCurve, - const std::vector& drawSurfaceVertices); + const std::vector& drawSurfaceVertices); void appendDrawSurfaceToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, From 9e665d5ab143b0cb2264a4e48aa8bfedf3092ec0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 18 May 2018 11:04:42 +0200 Subject: [PATCH 1014/1027] 3d Well Log Plots: Remove curve filled code --- .../Riv3dWellLogCurveGeometryGenerator.cpp | 100 +----------------- .../Riv3dWellLogCurveGeometryGenerator.h | 8 +- .../Riv3dWellLogPlanePartMgr.cpp | 24 ----- .../ProjectDataModel/Rim3dWellLogCurve.cpp | 18 ---- .../ProjectDataModel/Rim3dWellLogCurve.h | 9 -- 5 files changed, 3 insertions(+), 156 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 3ce784da74..26385a699e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -167,17 +167,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display } m_curveVertices = projectVerticesOntoTriangles(m_curveVertices, drawSurfaceVertices); - m_bottomVertices.reserve(m_curveVertices.size() + 2); - for (size_t i = 0; i < m_curveVertices.size(); ++i) - { - double md = m_curveMeasuredDepths[i]; - cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, md); - cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, md); - point += planeOffsetFromWellPathCenter * normal; - m_bottomVertices.push_back(point); - } - m_bottomVertices = projectVerticesOntoTriangles(m_bottomVertices, drawSurfaceVertices); - createNewVerticesAlongTriangleEdges(drawSurfaceVertices); { @@ -212,34 +201,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display } m_curveDrawable->setVertexArray(vertexArray.p()); } - - // Disable filled draw style in the GUI because of triangle stitching issue #2860. -#if 0 - { - CVF_ASSERT(m_bottomVertices.size() == m_curveVertices.size()); - cvf::ref vertexArray = new cvf::Vec3fArray(m_bottomVertices.size() + m_curveVertices.size()); - for (size_t i = 0; i < m_bottomVertices.size(); ++i) - { - (*vertexArray)[2 * i] = cvf::Vec3f(m_bottomVertices[i]); - (*vertexArray)[2 * i + 1] = cvf::Vec3f(m_curveVertices[i]); - } - - std::vector indices; - indices.reserve(vertexArray->size()); - for (size_t i = 0; i < vertexArray->size(); ++i) - { - indices.push_back(cvf::uint(i)); - } - - cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); - cvf::ref indexArray = new cvf::UIntArray(indices); - - m_curveFilledDrawable = new cvf::DrawableGeo(); - indexedUInt->setIndices(indexArray.p()); - m_curveFilledDrawable->addPrimitiveSet(indexedUInt.p()); - m_curveFilledDrawable->setVertexArray(vertexArray.p()); - } -#endif } //-------------------------------------------------------------------------------------------------- @@ -248,9 +209,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display void Riv3dWellLogCurveGeometryGenerator::clearCurvePointsAndGeometry() { m_curveDrawable = nullptr; - m_curveFilledDrawable = nullptr; m_curveVertices.clear(); - m_bottomVertices.clear(); m_curveMeasuredDepths.clear(); m_curveValues.clear(); } @@ -263,14 +222,6 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::curveDrawable() return m_curveDrawable; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref Riv3dWellLogCurveGeometryGenerator::curveFilledDrawable() -{ - return m_curveFilledDrawable; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -330,12 +281,10 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3 void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) { std::vector expandedCurveVertices; - std::vector expandedBottomVertices; std::vector expandedMeasuredDepths; std::vector expandedValues; size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); expandedCurveVertices.reserve(estimatedNumberOfPoints); - expandedBottomVertices.reserve(estimatedNumberOfPoints); expandedMeasuredDepths.reserve(estimatedNumberOfPoints); expandedValues.reserve(estimatedNumberOfPoints); @@ -348,17 +297,11 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con cvf::Vec3d fullSegmentVector = m_curveVertices[i + 1] - m_curveVertices[i]; std::vector extraVertices; - std::vector extraBottomVertices; createNewVerticesAlongSegment(m_curveVertices[i], m_curveVertices[i + 1], drawSurfaceVertices, - &extraVertices, - &m_bottomVertices[i], - &m_bottomVertices[i + 1], - &extraBottomVertices); - - CVF_ASSERT(extraVertices.size() == extraBottomVertices.size()); + &extraVertices); for (const cvf::Vec3d& extraVertex : extraVertices) { @@ -375,22 +318,18 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con expandedValues.push_back(valueAtPoint); lastVertex = extraVertex; } - expandedBottomVertices.insert(expandedBottomVertices.end(), extraBottomVertices.begin(), extraBottomVertices.end()); } else { // Add the invalid points and values. expandedCurveVertices.push_back(m_curveVertices[i]); - expandedBottomVertices.push_back(m_bottomVertices[i]); expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); expandedValues.push_back(m_curveValues[i]); } } - CVF_ASSERT(expandedCurveVertices.size() == expandedBottomVertices.size()); m_curveVertices.swap(expandedCurveVertices); - m_bottomVertices.swap(expandedBottomVertices); m_curveMeasuredDepths.swap(expandedMeasuredDepths); m_curveValues.swap(expandedValues); } @@ -401,21 +340,11 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, const cvf::Vec3d& ptEnd, const std::vector& drawSurfaceVertices, - std::vector* extraVertices, - const cvf::Vec3d* ptBottomStart, - const cvf::Vec3d* ptBottomEnd, - std::vector* extraBottomVertices) + std::vector* extraVertices) { cvf::Vec3d fullSegmentVector = ptEnd - ptStart; extraVertices->push_back(ptStart); - cvf::Vec3d fullBottomVector; - if (ptBottomStart && ptBottomEnd && extraBottomVertices) - { - fullBottomVector = *ptBottomEnd - *ptBottomStart; - extraBottomVertices->push_back(*ptBottomStart); - } - // Find segments that intersects the triangle edges for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) { @@ -437,34 +366,9 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf if (withinSegments && newSegmentVector.lengthSquared() < currentSubSegment.lengthSquared()) { extraVertices->push_back(newVertex); - - if (ptBottomStart && ptBottomEnd && extraBottomVertices) - { - // Do the same for the bottom line, however we need to ensure we add the same amount of points. - cvf::Vec3d currentBottomSegment = *ptBottomEnd - extraBottomVertices->back(); - cvf::Vec3d projectedBottomVector = - currentBottomSegment - (currentBottomSegment * triangleNormal) * triangleNormal; - caf::Line projectedBottomLine(extraBottomVertices->back(), - extraBottomVertices->back() + projectedBottomVector); - bool withinBottomSegments = false; - - caf::Line bottomConnectingLine = - projectedBottomLine.findLineBetweenNearestPoints(triangleEdge1, &withinBottomSegments); - cvf::Vec3d newBottomVertex = bottomConnectingLine.end(); - cvf::Vec3d newBottomVector = newBottomVertex - extraBottomVertices->back(); - if (!(withinBottomSegments && newBottomVector.lengthSquared() < fullBottomVector.lengthSquared())) - { - newBottomVertex = extraBottomVertices->back(); - } - extraBottomVertices->push_back(newBottomVertex); - } } } extraVertices->push_back(ptEnd); - if (ptBottomStart && ptBottomEnd && extraBottomVertices) - { - extraBottomVertices->push_back(*ptBottomEnd); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h index 54623244da..d53d078640 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h @@ -59,7 +59,6 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object const RigWellPath* wellPathGeometry() const; cvf::ref curveDrawable(); - cvf::ref curveFilledDrawable(); bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, @@ -71,10 +70,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object static void createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, const cvf::Vec3d& ptEnd, const std::vector& drawSurfaceVertices, - std::vector* extraVertices, - const cvf::Vec3d* ptBottomStart = nullptr, - const cvf::Vec3d* ptBottomEnd = nullptr, - std::vector* extraBottomVertices = nullptr); + std::vector* extraVertices); static std::vector projectVerticesOntoTriangles(const std::vector& originalVertices, const std::vector& drawSurfaceVertices); static cvf::Vec3d projectPointOntoTriangle(const cvf::Vec3d& point, @@ -86,9 +82,7 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object double m_planeWidth; cvf::ref m_curveDrawable; - cvf::ref m_curveFilledDrawable; std::vector m_curveVertices; - std::vector m_bottomVertices; std::vector m_curveMeasuredDepths; std::vector m_curveValues; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 370c1fe6f2..8eb5f33f26 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -126,30 +126,6 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* model->addPart(part.p()); } } - - if (rim3dWellLogCurve->drawStyle() == Rim3dWellLogCurve::FILLED) - { - Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); - cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); - - cvf::ref curveFilledDrawable = generator->curveFilledDrawable(); - if (curveFilledDrawable.notNull() && curveFilledDrawable->boundingBox().isValid()) - { - caf::SurfaceEffectGenerator filledEffectGen(rim3dWellLogCurve->color(), caf::PO_NONE); - filledEffectGen.enableLighting(false); - cvf::ref filledEffect = filledEffectGen.generateCachedEffect(); - - cvf::ref part = new cvf::Part; - part->setDrawable(curveFilledDrawable.p()); - part->setEffect(filledEffect.p()); - - if (part.notNull()) - { - model->addPart(part.p()); - part->setSourceInfo(sourceInfo.p()); - } - } - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index d65ee13fb9..dfceae1f9d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -51,13 +51,6 @@ namespace caf setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); } - template<> - void AppEnum< Rim3dWellLogCurve::DrawStyle >::setUp() - { - addItem(Rim3dWellLogCurve::LINE, "LINE", "Line"); - addItem(Rim3dWellLogCurve::FILLED, "FILLED", "Filled"); - setDefault(Rim3dWellLogCurve::LINE); - } } //-------------------------------------------------------------------------------------------------- @@ -75,7 +68,6 @@ Rim3dWellLogCurve::Rim3dWellLogCurve() CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::infinity(), "Maximum Curve Value", "", "Clip curve values above this.", ""); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); - CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); this->uiCapability()->setUiTreeChildrenHidden(true); } @@ -105,14 +97,6 @@ Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const return m_drawPlane(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Rim3dWellLogCurve::DrawStyle Rim3dWellLogCurve::drawStyle() const -{ - return m_drawStyle(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -207,8 +191,6 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Appearance"); configurationGroup->add(&m_drawPlane); -// Disable filled draw style in the GUI because of triangle stitching issue #2860. -// configurationGroup->add(&m_drawStyle); configurationGroup->add(&m_color); configurationGroup->add(&m_minCurveUIValue); configurationGroup->add(&m_maxCurveUIValue); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 244b58584e..fce0067f9e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -51,13 +51,6 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder }; typedef caf::AppEnum DrawPlaneEnum; - enum DrawStyle - { - LINE, - FILLED - }; - typedef caf::AppEnum DrawStyleEnum; - public: Rim3dWellLogCurve(); virtual ~Rim3dWellLogCurve(); @@ -68,7 +61,6 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder virtual QString resultPropertyString() const = 0; DrawPlane drawPlane() const; - DrawStyle drawStyle() const; double drawPlaneAngle() const; cvf::Color3f color() const; @@ -99,7 +91,6 @@ class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolder void resetMinMaxValues(); protected: caf::PdmField m_drawPlane; - caf::PdmField m_drawStyle; caf::PdmField m_color; caf::PdmField m_minCurveUIValue; caf::PdmField m_maxCurveUIValue; From bef7535eff010a765bc801862fa04dd4032aea08 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 18 May 2018 14:26:31 +0200 Subject: [PATCH 1015/1027] #2941 3d well log curves: Fix crash if the draw surface width becomes larger than well path length --- .../ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp index 30cbfe216e..b42245c2de 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -216,6 +216,11 @@ void Riv3dWellLogDrawSurfaceGenerator::createCurveNormalVectors(const caf::Displ arrowVectors.push_back(cvf::Vec3f(interpolatedWellPathNormals[i] * planeWidth * totalArrowScaling)); } + if (arrowVertices.empty() || arrowVectors.empty()) + { + return; + } + m_curveNormalVectors = new cvf::DrawableVectors(); cvf::ref vertexArray = new cvf::Vec3fArray(arrowVertices); From 06ae9cf155c68b9c39c259ffdd741141c9fedb48 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 18 May 2018 14:28:55 +0200 Subject: [PATCH 1016/1027] --- .../RivFemPartGeometryGenerator.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index 02590b7e91..c6545d675d 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -310,16 +310,18 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi const int* elmNodeIndices = part->connectivities(elmIdx); + cvf::Vec3d displayOffset = part->boundingBox().min(); + for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx) { int faceNodeCount = 0; const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, lfIdx, &faceNodeCount); if (faceNodeCount == 4) { - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]) - displayOffset)); } else { From 86c9ca1fd3ef0ba2c92aa76688a4d60b1613cdc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 May 2018 16:05:39 +0200 Subject: [PATCH 1017/1027] Documentation: Add formations to the documentation project file --- TestModels/20Layers.lyr | 13 + TestModels/Documenetation.rsp | 4827 +++++++++++++++++++++++++++------ 2 files changed, 4044 insertions(+), 796 deletions(-) create mode 100644 TestModels/20Layers.lyr diff --git a/TestModels/20Layers.lyr b/TestModels/20Layers.lyr new file mode 100644 index 0000000000..286d4016ae --- /dev/null +++ b/TestModels/20Layers.lyr @@ -0,0 +1,13 @@ + +'Fm. 1.1' 15 - 15 +'Fm. 1.2' 16 - 17 +'Fm. 2 HD' 18 - 18 +'Fm. 2.1 HD' 19 - 19 +' Fm. 3.1 HD' 20 - 20 +' Fm. 3.2 HD' 21 - 23 +' Fm. 3.2.1 HD' 24 - 26 +' Fm. 3.3 HD' 27 - 29 +' Fm. 3.4 HD' 30 - 31 +' Fm. 3.5 HD' 32 - 32 +' Fm. 4 HD' 33 - 33 +' Fm. 4.1 HD' 34 - 34 diff --git a/TestModels/Documenetation.rsp b/TestModels/Documenetation.rsp index 220c94a5a8..809a1b8ea7 100644 --- a/TestModels/Documenetation.rsp +++ b/TestModels/Documenetation.rsp @@ -1,8 +1,7 @@ - C:/gitRoot/OPM/ResInsight/TestModels/Documenetation.rsp - 0.9.31 + 2018.01.1-devRC.110 11 3 @@ -13,15 +12,105 @@ TEST10K_FLT_LGR_NNC 0 + .. .. FormationNamesCollection 0 FormationNamesList 0 + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 0.990313 0.137942 0.0158881 -1512.91 -0.108227 0.695124 0.710697 -1652.45 0.0869907 -0.705531 0.703319 -4090.21 0 0 0 1 + 0 0 0 + True + 11 + 0.752941191196442 0.823529422283173 0.87058824300766 + 10 + True + 5 + NO_MESH + SURFACE + True + False + + + + + New Filter (1) + True + EXCLUDE + 0 + True + 31 + 16 + 23 + 28 + 13 + 14 + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL SOIL - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -32,18 +121,35 @@ 0 SOIL - - + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -55,71 +161,291 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 11 - True - 5 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0 0 0 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0 0 0 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN - GP1 + GI1 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - GI1 + GP1 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + GP2 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False + + + True + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + + + + True + + + New Filter (1) + False + INCLUDE + + + + DYNAMIC_NATIVE + MATRIX_MODEL + SOIL + .. .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + 0 + 0.646495 + False + + + + + True + False + False + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 2 + 0.701898795447785 -0.712270228219442 -0.00303363497680109 358.817761221941 0.0733074277453067 0.0680022300575077 0.994988300305372 -467.44443386495 -0.708494249790579 -0.698603477445847 0.0999453816554576 -218.844742120346 0 0 0 1 + 18.6498219292924 545.189477193059 393.149390063892 + True + 5 + 0.752941191196442 0.823529422283173 0.87058824300766 + 10 + True + 5 + FULL_MESH + SURFACE + True + False @@ -137,51 +463,374 @@ 14 - True + False + + + + + True + + + + + True + + + + + False + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + + + + FORMATION_NAMES + MATRIX_MODEL + Active Formation Names + .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 2 + FIXED + NORMAL + LinearContinuous + USER_DEFINED_MAX_MIN + 0.4 + 0 + SOIL + + + True + 8 + 4 + FIXED + CATEGORY + Category + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + Active Formation Names + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 1 + + + + + True + MULTI_AXIS_STATIC_PROPERTY + + True + True + True + + + True + 8 + 2 + FIXED + PINK_WHITE + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + False + True + 1 + 0.1 + 0.2 + 0 0 0 + True + 1 1 0 + 12 + WELLPIPE_INTERPOLATED + K_DIRECTION + 0.5 + True + WELLHEAD_POS_TOP_COLUMN + + + GI1 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + GP1 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + GP2 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + False + + + + + True + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + + False New Filter (1) False INCLUDE + DYNAMIC_NATIVE MATRIX_MODEL SOIL + .. .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + 0 0.646495 + False - True - NO_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 0.990313 0.137942 0.0158881 -1512.91 -0.108227 0.695124 0.710697 -1652.45 0.0869907 -0.705531 0.703319 -4090.21 0 0 0 1 C:/gitRoot/OPM/ResInsight/TestModels/Documenetation_cache/{3fb560c2-fab1-4397-8174-c9783de1ab58} - - - GENERATED - KSlice - - 8 - - + @@ -192,20 +841,103 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID + + + All Wells + + + BRUGGE_0040 6 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 0.0886273 -0.975863 0.199593 5826.88 -0.026925 0.197962 0.97984 -15330.1 -0.995701 -0.0922146 -0.0087303 -23559.7 0 0 0 1 + 0 0 0 + True + 5 + 0.752941012382507 0.823529005050659 0.870588004589081 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL SOIL - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -216,18 +948,35 @@ 0 SOIL - - + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -239,1191 +988,2222 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 5 - True - 0 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0.898039 0.898039 0.898039 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0.898038983345032 0.898038983345032 0.898038983345032 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN I01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02 + I01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03 + I01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04 + I01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05 + I02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06 + I02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07 + I02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08 + I02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09 + I03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10 + I03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01 + I03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02 + I03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03 + I04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04 + I04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05 + I04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06 + I04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07 + I05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08 + I05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09 + I05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10 + I05-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11 + I06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12 + I06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13 + I06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14 + I06-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15 + I07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16 + I07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17 + I07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18 + I07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19 + I08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P20 + I08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-01 + I08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-02 + I08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-03 + I09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-01 + I09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-02 + I09-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-03 + I09-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-01 + I10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-02 + I10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-03 + I10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-01 + I10-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-02 + P01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-03 + P01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-01 + P01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-02 + P01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-03 + P02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-01 + P02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-02 + P02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-03 + P02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-01 + P03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-02 + P03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-03 + P03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-01 + P03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-02 + P04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-03 + P04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-01 + P04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-02 + P04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-03 + P05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-01 + P05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-02 + P05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-03 + P06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-01 + P06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-02 + P06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-03 + P07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-01 + P07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-02 + P07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-03 + P07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-01 + P08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-02 + P08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-03 + P08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-01 + P08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-02 + P09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-03 + P09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-01 + P10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-02 + P10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-01 + P10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-02 + P11 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-01 + P11-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-02 + P11-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-03 + P11-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-01 + P12 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-02 + P12-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-03 + P12-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09-01 + P12-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-01 + P13 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-02 + P13-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-01 + P13-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-02 + P13-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-03 + P14 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-01 + P14-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-02 + P14-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-03 + P15 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-01 + P15-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-02 + P15-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-03 + P16 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-01 + P16-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-02 + P16-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-01 + P16-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-02 + P17 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-01 + P17-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-02 + P17-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-03 + P17-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-01 + P18 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-02 + P18-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-03 + P18-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-01 + P18-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-02 + P19 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-03 + P19-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-01 + P19-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-02 + P19-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-03 + P20 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False - - - + + True - - + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + - True + - FULL_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 0.0886273 -0.975863 0.199593 5826.88 -0.026925 0.197962 0.97984 -15330.1 -0.995701 -0.0922146 -0.0087303 -23559.7 0 0 0 1 @@ -1440,7 +3220,14 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID + + + All Wells + + + @@ -1453,6 +3240,21 @@ Statistics 1 2 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -1468,6 +3270,7 @@ False False + PRESSURE PERMX PORO @@ -1482,6 +3285,7 @@ 50 90 None + False @@ -1492,15 +3296,91 @@ BRUGGE_0000 1 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 1 0 0 -31314.5 0 1 0 -26550.5 0 0 1 -64567.3 0 0 0 1 + 0 0 0 + True + 5 + 0.752941012382507 0.823529005050659 0.870588004589081 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL PRESSURE - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -1509,11 +3389,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - PRESSURE + - - + True 8 2 FIXED @@ -1522,9 +3401,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - + SOIL + True 8 2 FIXED @@ -1533,9 +3413,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - SOIL + SWAT + True 8 2 FIXED @@ -1544,19 +3425,37 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - SWAT + PRESSURE + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 3 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -1568,1191 +3467,2222 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 5 - True - 0 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0.890196 0.890196 0.890196 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0.890196025371552 0.890196025371552 0.890196025371552 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN I01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02 + I01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03 + I01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04 + I01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05 + I02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06 + I02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07 + I02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08 + I02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09 + I03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10 + I03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01 + I03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02 + I03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03 + I04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04 + I04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05 + I04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06 + I04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07 + I05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08 + I05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09 + I05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10 + I05-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11 + I06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12 + I06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13 + I06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14 + I06-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15 + I07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16 + I07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17 + I07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18 + I07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19 + I08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P20 + I08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-01 + I08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-02 + I08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-03 + I09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-01 + I09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-02 + I09-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-03 + I09-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-01 + I10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-02 + I10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-03 + I10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-01 + I10-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-02 + P01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-03 + P01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-01 + P01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-02 + P01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-03 + P02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-01 + P02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-02 + P02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-03 + P02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-01 + P03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-02 + P03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-03 + P03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-01 + P03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-02 + P04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-03 + P04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-01 + P04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-02 + P04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-03 + P05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-01 + P05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-02 + P05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-03 + P06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-01 + P06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-02 + P06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-03 + P07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-01 + P07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-02 + P07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-03 + P07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-01 + P08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-02 + P08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-03 + P08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-01 + P08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-02 + P09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-03 + P09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-01 + P10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-02 + P10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-01 + P10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-02 + P11 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-01 + P11-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-02 + P11-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-03 + P11-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-01 + P12 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-02 + P12-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-03 + P12-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09-01 + P12-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-01 + P13 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-02 + P13-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-01 + P13-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-02 + P13-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-03 + P14 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-01 + P14-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-02 + P14-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-03 + P15 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-01 + P15-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-02 + P15-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-03 + P16 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-01 + P16-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-02 + P16-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-01 + P16-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-02 + P17 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-01 + P17-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-02 + P17-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-03 + P17-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-01 + P18 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-02 + P18-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-03 + P18-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-01 + P18-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-02 + P19 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-03 + P19-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-01 + P19-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-02 + P19-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-03 + P20 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False - - - + + True - - + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + - True + - FULL_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 1 0 0 -31314.5 0 1 0 -26550.5 0 0 1 -64567.3 0 0 0 1 @@ -2769,11 +5699,33 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID + + + All Wells + + + BRUGGE_0010 3 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2789,11 +5741,29 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID + + BRUGGE_0030 4 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2809,11 +5779,29 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID + + BRUGGE_0040 5 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2829,7 +5817,10 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID + + @@ -2844,6 +5835,21 @@ Statistics 1 7 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2859,6 +5865,7 @@ False False + PRESSURE PERMX PORO @@ -2873,6 +5880,7 @@ 50 90 None + False @@ -2883,6 +5891,21 @@ BRUGGE_0000 8 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2898,11 +5921,33 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID + + + All Wells + + + BRUGGE_0010 9 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2918,7 +5963,10 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID + + @@ -2927,10 +5975,12 @@ + + True True - 0.870588 0.870588 0.870588 + 0.870588004589081 0.870588004589081 0.870588004589081 ALL_ON 0.1 True @@ -2938,6 +5988,33 @@ + + + UNITS_METRIC + + 0 + + + + + + + + + + + + + C:\gitRoot\OPM\ResInsight\TestModels\20Layers.lyr + + + + + + + + + @@ -2961,16 +6038,52 @@ C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\LGRSOIL.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\OctaveInterfaceTest.m + C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SatNum.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\ResInsightIterfaceUnitTest.m + C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + + + + + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts + - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SatNum.m + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts\OctaveInterfaceTest.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts\ResInsightInterfaceUnitTest.m + + + + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D_2WellCells.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D_printDetails.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\Calc_InfConductive_Frac_Transm.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\findPathFuncs.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\Sum_WaterInfluxWithTime.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\virtualCF_2D.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\virtualCF_2D_MatrixReduction.m @@ -2978,7 +6091,6 @@ - -1-100000000;-1-100000040;-1-100000050;-1-1000000;-1-10000;-1-1001000;-1-10010;-1-10020100000;-1-100201000;-1-1002010;-1-10020;-1-100;-1-12000;-1-120 True @@ -2991,6 +6103,129 @@ + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + 0 + -1 + -1 + False + + + False + + + SELECTED + + + 0.1 + True + CELLS_ACTIVE + + + + 0 + 146000 + + + + + + + + + + + + True + + + + + + + + + + -1-10000;-1-100;-1-120 0 0;0 0;0 0 + + 0 0 + True + True + + + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + + + + + 2 + 2 + 2 + 8 + + + + + D:/Tools/DropBox/Dropbox (Ceetron Solutions)/Projects/20059 ResInsight Deeper Reservoir Insight/Meetings/2018.01.18_ProjectMeeting + + UNIFIED_FILE + TRANSMISSIBILITIES + 0 + False + True + True + True + False + INDIVIDUALLY + + + + From 5f07b3f2be3ce78db7a8db110f20cc68ee806550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 May 2018 16:18:19 +0200 Subject: [PATCH 1018/1027] Upped version to 2018.01.1-devRC.111 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 666258a6d3..0323edad9e 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,7 @@ set(RESINSIGHT_VERSION_TEXT "-devRC") # 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 ".110") +set(RESINSIGHT_DEV_VERSION ".111") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 82d6db94cb4d1df09e4d5ef6d662fb4886cd8b1e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 18 May 2018 19:23:36 +0200 Subject: [PATCH 1019/1027] WIP : try to fix import of geomech project files --- .../Application/RiaApplication.cpp | 8 ++- .../ProjectDataModel/Rim3dView.cpp | 16 +++++ ApplicationCode/ProjectDataModel/Rim3dView.h | 3 + .../ProjectDataModel/RimGeoMechView.cpp | 67 ++++++++++++++++++- .../ProjectDataModel/RimGeoMechView.h | 2 + 5 files changed, 94 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index c66410e092..f51455bbdb 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -47,7 +47,6 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechModels.h" #include "RimGeoMechView.h" -#include "RimGeoMechView.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimObservedData.h" @@ -562,7 +561,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi } } + auto* geoView = dynamic_cast(riv); + if (geoView) + { + geoView->updateDisplayModelCoordinates(); + } + riv->loadDataAndUpdate(); + this->setActiveReservoirView(riv); RimGridView* rigv = dynamic_cast(riv); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 167ae37887..4a6399938b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -834,6 +834,22 @@ cvf::ref Rim3dView::displayCoordTransform() const return coordTrans; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d Rim3dView::cameraPosition() const +{ + return m_cameraPosition(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Rim3dView::cameraPointOfInterest() const +{ + return m_cameraPointOfInterest(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index b96923292d..7846fec34b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -141,6 +141,9 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual RimCase* ownerCase() const = 0; virtual std::vector legendConfigs() const = 0; + cvf::Mat4d cameraPosition() const; + cvf::Vec3d cameraPointOfInterest() const; + protected: static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index b848c785bb..04464a4639 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -20,6 +20,7 @@ #include "RimGeoMechView.h" #include "RiaApplication.h" +#include "RiaLogging.h" #include "RiaPreferences.h" #include "RigFemPartCollection.h" @@ -36,6 +37,7 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" #include "RimIntersectionCollection.h" +#include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimTensorResults.h" #include "RimViewLinker.h" @@ -52,10 +54,11 @@ #include "cafCadNavigation.h" #include "cafCeetronPlusNavigation.h" +#include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" +#include "cafOverlayScalarMapperLegend.h" #include "cafPdmUiTreeOrdering.h" #include "cafProgressInfo.h" -#include "cafOverlayScalarMapperLegend.h" #include "cvfModelBasicList.h" #include "cvfPart.h" @@ -561,6 +564,68 @@ RigFemPartCollection* RimGeoMechView::femParts() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateDisplayModelCoordinates() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (!proj) return; + + if (proj->isProjectFileVersionEqualOrOlderThan("2018.1.1.110")) + { + auto geoMechCase = this->geoMechCase(); + if (geoMechCase) + { + std::string errorMessage; + if (!geoMechCase->openGeoMechCase(&errorMessage)) + { + QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + geoMechCase->caseFileName() + : QString::fromStdString(errorMessage); + + RiaLogging::error(displayMessage); + } + else + { + // Up-cast to get access to public interface for camera functions + RimCase* rimCase = geoMechCase; + RiuViewerToViewInterface* viewerToViewInterface = this; + auto offset = -rimCase->displayModelOffset(); + + auto diplayCoordTrans = this->displayCoordTransform(); + +/* Does not work as expected + + { + auto pointOfInterest = this->cameraPointOfInterest(); + + auto pointOfInterestDomain = diplayCoordTrans->scaleToDomainSize(pointOfInterest); + pointOfInterestDomain += offset; + + auto newPointOfInterest = diplayCoordTrans->transformToDisplayCoord(pointOfInterestDomain); + + viewerToViewInterface->setCameraPointOfInterest(newPointOfInterest); + } + + { + auto cameraPosition = this->cameraPosition(); + auto translation = cameraPosition.translation(); + + auto translationDomainCoord = diplayCoordTrans->scaleToDomainSize(translation); + translationDomainCoord += offset; + + auto newCameraPosition = diplayCoordTrans->transformToDisplayCoord(translationDomainCoord); + + cameraPosition.setTranslation(newCameraPosition); + viewerToViewInterface->setCameraPosition(cameraPosition); + } +*/ + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- RimGeoMechCase* RimGeoMechView::geoMechCase() { return m_geomechCase; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 2463ffdf51..316176001f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -99,6 +99,8 @@ class RimGeoMechView : public RimGridView const RigFemPartCollection* femParts() const; RigFemPartCollection* femParts(); + void updateDisplayModelCoordinates(); + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; From d7cffba9f18c253759f17d7ebda20e2633891016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 18 May 2018 21:38:49 +0200 Subject: [PATCH 1020/1027] #2940 Covert old project file geomech camera mx to new display offsetted regime --- .../Application/RiaApplication.cpp | 13 ++-- ApplicationCode/ProjectDataModel/Rim3dView.h | 6 +- .../ProjectDataModel/RimGeoMechView.cpp | 75 +++++++------------ .../ProjectDataModel/RimGeoMechView.h | 2 +- 4 files changed, 40 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index f51455bbdb..4a932fb6ca 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -560,15 +560,18 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi stimPlanColors[0]->updateConductivityResultName(); } } + + riv->loadDataAndUpdate(); - auto* geoView = dynamic_cast(riv); - if (geoView) + if ( m_project->isProjectFileVersionEqualOrOlderThan("2018.1.1.110") ) { - geoView->updateDisplayModelCoordinates(); + auto* geoView = dynamic_cast(riv); + if ( geoView ) + { + geoView->convertCameraPositionFromOldProjectFiles(); + } } - riv->loadDataAndUpdate(); - this->setActiveReservoirView(riv); RimGridView* rigv = dynamic_cast(riv); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 7846fec34b..d4d365f5da 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -141,15 +141,15 @@ class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface virtual RimCase* ownerCase() const = 0; virtual std::vector legendConfigs() const = 0; - cvf::Mat4d cameraPosition() const; - cvf::Vec3d cameraPointOfInterest() const; - protected: static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); virtual void setDefaultView(); void disableGridBoxField(); void disablePerspectiveProjectionField(); + cvf::Mat4d cameraPosition() const; + cvf::Vec3d cameraPointOfInterest() const; + RimWellPathCollection* wellPathCollection() const; void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 04464a4639..08e3fb3ab2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -20,7 +20,6 @@ #include "RimGeoMechView.h" #include "RiaApplication.h" -#include "RiaLogging.h" #include "RiaPreferences.h" #include "RigFemPartCollection.h" @@ -37,7 +36,6 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" #include "RimIntersectionCollection.h" -#include "RimProject.h" #include "RimRegularLegendConfig.h" #include "RimTensorResults.h" #include "RimViewLinker.h" @@ -129,8 +127,8 @@ void RimGeoMechView::onLoadDataAndUpdate() QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage); QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), - "File open error", - displayMessage); + "File open error", + displayMessage); m_geomechCase = nullptr; return; } @@ -564,62 +562,45 @@ RigFemPartCollection* RimGeoMechView::femParts() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechView::updateDisplayModelCoordinates() +void RimGeoMechView::convertCameraPositionFromOldProjectFiles() { - RimProject* proj = nullptr; - this->firstAncestorOrThisOfType(proj); - if (!proj) return; - - if (proj->isProjectFileVersionEqualOrOlderThan("2018.1.1.110")) + auto geoMechCase = this->geoMechCase(); + if ( geoMechCase ) { - auto geoMechCase = this->geoMechCase(); - if (geoMechCase) - { - std::string errorMessage; - if (!geoMechCase->openGeoMechCase(&errorMessage)) - { - QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + geoMechCase->caseFileName() - : QString::fromStdString(errorMessage); - - RiaLogging::error(displayMessage); - } - else - { - // Up-cast to get access to public interface for camera functions - RimCase* rimCase = geoMechCase; - RiuViewerToViewInterface* viewerToViewInterface = this; - auto offset = -rimCase->displayModelOffset(); + // Up-cast to get access to public interface for camera functions + RimCase* rimCase = geoMechCase; + RiuViewerToViewInterface* viewerToViewInterface = this; + cvf::Vec3d offset = rimCase->displayModelOffset(); + auto diplayCoordTrans = this->displayCoordTransform(); - auto diplayCoordTrans = this->displayCoordTransform(); + { + cvf::Mat4d cameraMx = this->cameraPosition().getInverted(); -/* Does not work as expected + cvf::Vec3d translation = cameraMx.translation(); - { - auto pointOfInterest = this->cameraPointOfInterest(); + cvf::Vec3d translationDomainCoord = diplayCoordTrans->scaleToDomainSize(translation); + translationDomainCoord -= offset; - auto pointOfInterestDomain = diplayCoordTrans->scaleToDomainSize(pointOfInterest); - pointOfInterestDomain += offset; + cvf::Vec3d newCameraTranslation = diplayCoordTrans->scaleToDisplaySize(translationDomainCoord); - auto newPointOfInterest = diplayCoordTrans->transformToDisplayCoord(pointOfInterestDomain); + cameraMx.setTranslation(newCameraTranslation); - viewerToViewInterface->setCameraPointOfInterest(newPointOfInterest); - } + viewerToViewInterface->setCameraPosition(cameraMx.getInverted()); + } - { - auto cameraPosition = this->cameraPosition(); - auto translation = cameraPosition.translation(); + { + cvf::Vec3d pointOfInterest = this->cameraPointOfInterest(); - auto translationDomainCoord = diplayCoordTrans->scaleToDomainSize(translation); - translationDomainCoord += offset; + cvf::Vec3d pointOfInterestDomain = diplayCoordTrans->scaleToDomainSize(pointOfInterest); + pointOfInterestDomain -= offset; - auto newCameraPosition = diplayCoordTrans->transformToDisplayCoord(translationDomainCoord); + cvf::Vec3d newPointOfInterest = diplayCoordTrans->scaleToDisplaySize(pointOfInterestDomain); - cameraPosition.setTranslation(newCameraPosition); - viewerToViewInterface->setCameraPosition(cameraPosition); - } -*/ - } + viewerToViewInterface->setCameraPointOfInterest(newPointOfInterest); } + + m_viewer->mainCamera()->setViewMatrix( this->cameraPosition()); + m_viewer->setPointOfInterest(this->cameraPointOfInterest()); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 316176001f..7448bae1f0 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -99,7 +99,7 @@ class RimGeoMechView : public RimGridView const RigFemPartCollection* femParts() const; RigFemPartCollection* femParts(); - void updateDisplayModelCoordinates(); + void convertCameraPositionFromOldProjectFiles(); protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; From 9b9f9b2bf121703dd15acaca522db138e2f37a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 21 May 2018 23:46:35 +0200 Subject: [PATCH 1021/1027] #2939 ProgressInfo: Reintroduce process envents, to update the progress dialog durig processing on linux/mac. Introduced isActive and used this info to block sheduled redraw/display model regen when progress bar is active, to avoid unintended recursive behaviour resulting in crashes. --- .../RiaCompletionTypeCalculationScheduler.cpp | 7 +++ .../Application/RiaViewRedrawScheduler.cpp | 29 ++++++++++-- .../Application/RiaViewRedrawScheduler.h | 7 ++- .../RicExportMultipleSnapshotsFeature.cpp | 2 +- .../ProjectDataModel/Rim3dView.cpp | 2 +- .../cafUserInterface/cafProgressInfo.cpp | 33 +++++++++----- .../cafUserInterface/cafProgressState.h | 45 +++++++++++++++++++ 7 files changed, 106 insertions(+), 19 deletions(-) create mode 100644 Fwk/AppFwk/cafUserInterface/cafProgressState.h diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 6a5dd39b71..95bdb29e3e 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -38,6 +38,7 @@ #include #include +#include "cafProgressState.h" //-------------------------------------------------------------------------------------------------- /// @@ -100,6 +101,12 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() { + if ( caf::ProgressState::isActive() ) + { + startTimer(); + return; + } + std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.cpp b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp index 4262ea9814..b1d31a499a 100644 --- a/ApplicationCode/Application/RiaViewRedrawScheduler.cpp +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp @@ -23,6 +23,7 @@ #include #include +#include "cafProgressState.h" //-------------------------------------------------------------------------------------------------- /// @@ -59,16 +60,24 @@ void RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resV { m_resViewsToUpdate.push_back(resViewToUpdate); + startTimer(0); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::startTimer(int msecs) +{ if (!m_resViewUpdateTimer) { m_resViewUpdateTimer = new QTimer(this); - connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels())); + connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateAndRedrawScheduledViewsWhenReady())); } if (!m_resViewUpdateTimer->isActive()) { m_resViewUpdateTimer->setSingleShot(true); - m_resViewUpdateTimer->start(0); + m_resViewUpdateTimer->start(msecs); } } @@ -76,7 +85,7 @@ void RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resV //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaViewRedrawScheduler::slotUpdateScheduledDisplayModels() +void RiaViewRedrawScheduler::updateAndRedrawScheduledViews() { // Compress to remove duplicates // and update dependent views after independent views @@ -113,6 +122,20 @@ void RiaViewRedrawScheduler::slotUpdateScheduledDisplayModels() m_resViewsToUpdate.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::slotUpdateAndRedrawScheduledViewsWhenReady() +{ + if ( caf::ProgressState::isActive() ) + { + startTimer(100); + return; + } + + updateAndRedrawScheduledViews(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.h b/ApplicationCode/Application/RiaViewRedrawScheduler.h index 52b4246b63..9a228a571f 100644 --- a/ApplicationCode/Application/RiaViewRedrawScheduler.h +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.h @@ -33,11 +33,14 @@ class RiaViewRedrawScheduler : public QObject static RiaViewRedrawScheduler* instance(); void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate); void clearViewsScheduledForUpdate(); + void updateAndRedrawScheduledViews(); -public slots: - void slotUpdateScheduledDisplayModels(); +private slots: + void slotUpdateAndRedrawScheduledViewsWhenReady(); private: + void startTimer(int msecs); + RiaViewRedrawScheduler() : m_resViewUpdateTimer(nullptr) {} ~RiaViewRedrawScheduler(); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp index e4411113e3..b5a21c50eb 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp @@ -230,7 +230,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimGridView // Force update of scheduled display models modifying the time step // This is required due to visualization structures updated by the update functions, // and this is not triggered by changing time step only - RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->updateAndRedrawScheduledViews(); viewer->setCurrentFrame(i); viewer->animationControl()->setCurrentFrameOnly(i); diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 4a6399938b..9bd8c48bb0 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -256,7 +256,7 @@ QImage Rim3dView::snapshotWindowContent() if (m_viewer) { // Force update of scheduled display models before snapshotting - RiaViewRedrawScheduler::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->updateAndRedrawScheduledViews(); m_viewer->repaint(); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 8bbff80361..b81453a92a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -37,6 +37,7 @@ #include "cafProgressInfo.h" #include "cafAssert.h" +#include "cafProgressState.h" #include #include @@ -317,6 +318,13 @@ namespace caf { return progressDialog()->thread() == QThread::currentThread(); } + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + bool ProgressState::isActive() + { + return !maxProgressStack().empty(); + } //-------------------------------------------------------------------------------------------------- /// @@ -426,8 +434,8 @@ namespace caf { progressDialog()->setValue(static_cast(currentTotalProgress())); progressDialog()->setLabelText(currentComposedLabel()); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -441,8 +449,8 @@ namespace caf { descriptionStack().back() = description; progressDialog()->setLabelText(currentComposedLabel()); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -483,8 +491,8 @@ namespace caf { progressDialog()->setMaximum(totalMaxProgress); progressDialog()->setValue(totalProgress); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -560,7 +568,7 @@ namespace caf { progressDialog()->setLabelText(currentComposedLabel()); // If we are finishing the last level, clean up - if (!maxProgressStack_v.size()) + if (maxProgressStack_v.empty()) { if (progressDialog() != nullptr) { @@ -568,11 +576,12 @@ namespace caf { progressDialog()->close(); } } - - // Make sure the Gui is repainted - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); - + else + { + // Make sure the Gui is repainted + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); + } } diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressState.h b/Fwk/AppFwk/cafUserInterface/cafProgressState.h new file mode 100644 index 0000000000..f84fb3c43f --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafProgressState.h @@ -0,0 +1,45 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +namespace caf { + +class ProgressState +{ +public: + static bool isActive(); +}; + +} \ No newline at end of file From 735524f342ae64914ffc5a94d8970fd79f39bf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 21 May 2018 23:48:56 +0200 Subject: [PATCH 1022/1027] Upped to 2018.01.1-devRC.112 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 0323edad9e..c77fc2ff24 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -10,7 +10,7 @@ set(RESINSIGHT_VERSION_TEXT "-devRC") # 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 ".111") +set(RESINSIGHT_DEV_VERSION ".112") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From ec9e2efef4a3342419e073794ea0893cb07ee2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 22 May 2018 00:16:03 +0200 Subject: [PATCH 1023/1027] Fix cotire build problem --- Fwk/AppFwk/cafUserInterface/cafProgressState.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressState.h b/Fwk/AppFwk/cafUserInterface/cafProgressState.h index f84fb3c43f..7dc47bd6f6 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressState.h +++ b/Fwk/AppFwk/cafUserInterface/cafProgressState.h @@ -34,6 +34,8 @@ // //################################################################################################## +#pragma once + namespace caf { class ProgressState From 0089e0c21894eefd212570a5c45d1bc1e3fbe0ed Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 16 May 2018 14:56:33 +0200 Subject: [PATCH 1024/1027] #2873 Delegate deletion of summary cases to separate thread. --- .../Commands/RicCloseSummaryCaseFeature.cpp | 7 +- .../Commands/RicCloseSummaryCaseFeature.h | 2 +- .../Summary/RimSummaryCaseCollection.cpp | 2 +- .../Summary/RimSummaryCaseMainCollection.cpp | 4 +- .../cafPdmCore/CMakeLists.txt | 3 + .../cafPdmCore/cafAsyncObjectDeleter.h | 64 +++++++++++++++ .../cafPdmCore/cafAsyncObjectDeleter.inl | 78 +++++++++++++++++++ .../cafPdmCore/cafPdmChildArrayField.h | 3 +- .../cafPdmCore/cafPdmChildArrayField.inl | 15 ++++ 9 files changed, 170 insertions(+), 8 deletions(-) create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h create mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp index 8471ef0cd7..b2d08b010e 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -30,6 +30,7 @@ #include "RiuPlotMainWindow.h" +#include "cafAsyncObjectDeleter.h" #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -50,7 +51,7 @@ void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vector& cases) +void RicCloseSummaryCaseFeature::deleteSummaryCases(std::vector& cases) { RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); @@ -66,13 +67,13 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vectorfirstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); summaryCaseMainCollection->removeCase(summaryCase); - delete summaryCase; - summaryCaseMainCollection->updateAllRequiredEditors(); } RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); + + caf::AsyncRawPointerVectorDeleter summaryCaseDeleter(std::move(cases)); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h index d987aba447..c0a45ce5f5 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h @@ -32,7 +32,7 @@ class RicCloseSummaryCaseFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; public: - static void deleteSummaryCases(const std::vector& cases); + static void deleteSummaryCases(std::vector& cases); protected: // Overrides diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 6d962faaff..5c70c6ca96 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -53,7 +53,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::~RimSummaryCaseCollection() { - m_cases.deleteAllChildObjects(); + m_cases.deleteAllChildObjectsAsync(); updateReferringCurveSets(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index 45b2a78c0c..e1db6de4c7 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -75,8 +75,8 @@ RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::~RimSummaryCaseMainCollection() { - m_cases.deleteAllChildObjects(); - m_caseCollections.deleteAllChildObjects(); + m_cases.deleteAllChildObjectsAsync(); + m_caseCollections.deleteAllChildObjectsAsync(); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 40e8db36b0..12068aa1f4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -45,6 +45,9 @@ set( PROJECT_FILES cafTristate.h cafFilePath.cpp cafFilePath.h + cafAsyncObjectDeleter.h + cafAsyncObjectDeleter.inl + ) add_library( ${PROJECT_NAME} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h new file mode 100644 index 0000000000..11865a7412 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h @@ -0,0 +1,64 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +namespace caf +{ + template + class AsyncRawPointerVectorDeleter + { + public: + AsyncRawPointerVectorDeleter(std::vector&& pointerVector); + ~AsyncRawPointerVectorDeleter(); + void start(); + private: + std::vector pointersToDelete_; + }; + + template + class AsyncPdmPointerVectorDeleter + { + public: + AsyncPdmPointerVectorDeleter(std::vector>&& pdmPointerVector); + ~AsyncPdmPointerVectorDeleter(); + void start(); + private: + std::vector> pointersToDelete_; + }; +} + +#include "cafAsyncObjectDeleter.inl" \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl new file mode 100644 index 0000000000..fb5f03e932 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl @@ -0,0 +1,78 @@ +#include + +namespace caf +{ + //-------------------------------------------------------------------------------------------------- + /// Constructor that takes ownership of the data in the provided vector + //-------------------------------------------------------------------------------------------------- + template + AsyncRawPointerVectorDeleter::AsyncRawPointerVectorDeleter(std::vector&& pointerVector) + : pointersToDelete_(std::move(pointerVector)) + { + } + + //-------------------------------------------------------------------------------------------------- + /// Destructor will launch the asynchronous deletion if start() hasn't already been run. + //-------------------------------------------------------------------------------------------------- + template + AsyncRawPointerVectorDeleter::~AsyncRawPointerVectorDeleter() + { + if (!pointersToDelete_.empty()) + { + start(); + } + } + + //-------------------------------------------------------------------------------------------------- + /// Perform deletion of the pointers in a separate thread. + //-------------------------------------------------------------------------------------------------- + template + void AsyncRawPointerVectorDeleter::start() + { + std::thread([](std::vector&& pointerVector) + { + for (T* pointerToDelete : pointerVector) + { + delete pointerToDelete; + } + }, std::move(pointersToDelete_)).detach(); + } + + + //-------------------------------------------------------------------------------------------------- + /// Constructor that takes ownership of the data in the provided vector + //-------------------------------------------------------------------------------------------------- + template + AsyncPdmPointerVectorDeleter::AsyncPdmPointerVectorDeleter(std::vector>&& pdmPointerVector) + : pointersToDelete_(std::move(pdmPointerVector)) + { + } + + //-------------------------------------------------------------------------------------------------- + /// Destructor will launch the asynchronous deletion if start() hasn't already been run. + //-------------------------------------------------------------------------------------------------- + template + AsyncPdmPointerVectorDeleter::~AsyncPdmPointerVectorDeleter() + { + if (!pointersToDelete_.empty()) + { + start(); + } + } + + //-------------------------------------------------------------------------------------------------- + /// Perform deletion of the pointers in a separate thread. + //-------------------------------------------------------------------------------------------------- + template + void caf::AsyncPdmPointerVectorDeleter::start() + { + std::thread([](std::vector>&& pointerVector) + { + for (PdmPointer& pointerToDelete : pointerVector) + { + delete pointerToDelete.rawPtr(); + } + }, std::move(pointersToDelete_)).detach(); + } + +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h index c3546cecd8..311b8dc182 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h @@ -61,7 +61,8 @@ class PdmChildArrayField : public PdmChildArrayFieldHandle virtual size_t size() const { return m_pointers.size(); } virtual bool empty() const { return m_pointers.empty(); } virtual void clear(); - virtual void deleteAllChildObjects(); + virtual void deleteAllChildObjects(); + virtual void deleteAllChildObjectsAsync(); virtual void insertAt(int indexAfter, PdmObjectHandle* obj); virtual PdmObjectHandle* at(size_t index); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl index 019111b2e5..1b5c73eba0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl @@ -1,3 +1,4 @@ +#include "cafAsyncObjectDeleter.h" #include "cafClassTypeName.h" #include "cafPdmObjectHandle.h" @@ -138,6 +139,20 @@ void PdmChildArrayField::deleteAllChildObjects() m_pointers.clear(); } +//-------------------------------------------------------------------------------------------------- +/// Transfers ownership of the objects pointed to a separate thread. +/// Then clears the container and lets the thread delete the objects. +//-------------------------------------------------------------------------------------------------- +template +void PdmChildArrayField::deleteAllChildObjectsAsync() +{ + CAF_ASSERT(isInitializedByInitFieldMacro()); + + AsyncPdmPointerVectorDeleter pointerDeleter(std::move(m_pointers)); + CAF_ASSERT(m_pointers.empty()); // Object storage for m_pointers should be empty immediately. +} + + //-------------------------------------------------------------------------------------------------- /// Removes the pointer at index from the container. Does not delete the object pointed to. /// Todo: This implementation can't be necessary in the new regime. Should be to just remove From 772e7ec7e65897f8cb70a09ed50bd4556ccb2cd9 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 22 May 2018 09:22:12 +0200 Subject: [PATCH 1025/1027] Revert "#2873 Delegate deletion of summary cases to separate thread." This reverts commit 0089e0c21894eefd212570a5c45d1bc1e3fbe0ed. Didn't intend this to go into dev now --- .../Commands/RicCloseSummaryCaseFeature.cpp | 7 +- .../Commands/RicCloseSummaryCaseFeature.h | 2 +- .../Summary/RimSummaryCaseCollection.cpp | 2 +- .../Summary/RimSummaryCaseMainCollection.cpp | 4 +- .../cafPdmCore/CMakeLists.txt | 3 - .../cafPdmCore/cafAsyncObjectDeleter.h | 64 --------------- .../cafPdmCore/cafAsyncObjectDeleter.inl | 78 ------------------- .../cafPdmCore/cafPdmChildArrayField.h | 3 +- .../cafPdmCore/cafPdmChildArrayField.inl | 15 ---- 9 files changed, 8 insertions(+), 170 deletions(-) delete mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h delete mode 100644 Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp index b2d08b010e..8471ef0cd7 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -30,7 +30,6 @@ #include "RiuPlotMainWindow.h" -#include "cafAsyncObjectDeleter.h" #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -51,7 +50,7 @@ void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicCloseSummaryCaseFeature::deleteSummaryCases(std::vector& cases) +void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vector& cases) { RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection(); @@ -67,13 +66,13 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases(std::vector summaryCase->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); summaryCaseMainCollection->removeCase(summaryCase); + delete summaryCase; + summaryCaseMainCollection->updateAllRequiredEditors(); } RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); - - caf::AsyncRawPointerVectorDeleter summaryCaseDeleter(std::move(cases)); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h index c0a45ce5f5..d987aba447 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.h @@ -32,7 +32,7 @@ class RicCloseSummaryCaseFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; public: - static void deleteSummaryCases(std::vector& cases); + static void deleteSummaryCases(const std::vector& cases); protected: // Overrides diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 5c70c6ca96..6d962faaff 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -53,7 +53,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::~RimSummaryCaseCollection() { - m_cases.deleteAllChildObjectsAsync(); + m_cases.deleteAllChildObjects(); updateReferringCurveSets(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index e1db6de4c7..45b2a78c0c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -75,8 +75,8 @@ RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::~RimSummaryCaseMainCollection() { - m_cases.deleteAllChildObjectsAsync(); - m_caseCollections.deleteAllChildObjectsAsync(); + m_cases.deleteAllChildObjects(); + m_caseCollections.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 12068aa1f4..40e8db36b0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -45,9 +45,6 @@ set( PROJECT_FILES cafTristate.h cafFilePath.cpp cafFilePath.h - cafAsyncObjectDeleter.h - cafAsyncObjectDeleter.inl - ) add_library( ${PROJECT_NAME} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h deleted file mode 100644 index 11865a7412..0000000000 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.h +++ /dev/null @@ -1,64 +0,0 @@ -//################################################################################################## -// -// Custom Visualization Core library -// Copyright (C) 2011-2013 Ceetron AS -// -// This library may be used under the terms of either the GNU General Public License or -// the GNU Lesser General Public License as follows: -// -// GNU General Public License Usage -// This library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at <> -// for more details. -// -// GNU Lesser General Public License Usage -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU Lesser General Public License at <> -// for more details. -// -//################################################################################################## - -#pragma once - -namespace caf -{ - template - class AsyncRawPointerVectorDeleter - { - public: - AsyncRawPointerVectorDeleter(std::vector&& pointerVector); - ~AsyncRawPointerVectorDeleter(); - void start(); - private: - std::vector pointersToDelete_; - }; - - template - class AsyncPdmPointerVectorDeleter - { - public: - AsyncPdmPointerVectorDeleter(std::vector>&& pdmPointerVector); - ~AsyncPdmPointerVectorDeleter(); - void start(); - private: - std::vector> pointersToDelete_; - }; -} - -#include "cafAsyncObjectDeleter.inl" \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl deleted file mode 100644 index fb5f03e932..0000000000 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAsyncObjectDeleter.inl +++ /dev/null @@ -1,78 +0,0 @@ -#include - -namespace caf -{ - //-------------------------------------------------------------------------------------------------- - /// Constructor that takes ownership of the data in the provided vector - //-------------------------------------------------------------------------------------------------- - template - AsyncRawPointerVectorDeleter::AsyncRawPointerVectorDeleter(std::vector&& pointerVector) - : pointersToDelete_(std::move(pointerVector)) - { - } - - //-------------------------------------------------------------------------------------------------- - /// Destructor will launch the asynchronous deletion if start() hasn't already been run. - //-------------------------------------------------------------------------------------------------- - template - AsyncRawPointerVectorDeleter::~AsyncRawPointerVectorDeleter() - { - if (!pointersToDelete_.empty()) - { - start(); - } - } - - //-------------------------------------------------------------------------------------------------- - /// Perform deletion of the pointers in a separate thread. - //-------------------------------------------------------------------------------------------------- - template - void AsyncRawPointerVectorDeleter::start() - { - std::thread([](std::vector&& pointerVector) - { - for (T* pointerToDelete : pointerVector) - { - delete pointerToDelete; - } - }, std::move(pointersToDelete_)).detach(); - } - - - //-------------------------------------------------------------------------------------------------- - /// Constructor that takes ownership of the data in the provided vector - //-------------------------------------------------------------------------------------------------- - template - AsyncPdmPointerVectorDeleter::AsyncPdmPointerVectorDeleter(std::vector>&& pdmPointerVector) - : pointersToDelete_(std::move(pdmPointerVector)) - { - } - - //-------------------------------------------------------------------------------------------------- - /// Destructor will launch the asynchronous deletion if start() hasn't already been run. - //-------------------------------------------------------------------------------------------------- - template - AsyncPdmPointerVectorDeleter::~AsyncPdmPointerVectorDeleter() - { - if (!pointersToDelete_.empty()) - { - start(); - } - } - - //-------------------------------------------------------------------------------------------------- - /// Perform deletion of the pointers in a separate thread. - //-------------------------------------------------------------------------------------------------- - template - void caf::AsyncPdmPointerVectorDeleter::start() - { - std::thread([](std::vector>&& pointerVector) - { - for (PdmPointer& pointerToDelete : pointerVector) - { - delete pointerToDelete.rawPtr(); - } - }, std::move(pointersToDelete_)).detach(); - } - -} \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h index 311b8dc182..c3546cecd8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h @@ -61,8 +61,7 @@ class PdmChildArrayField : public PdmChildArrayFieldHandle virtual size_t size() const { return m_pointers.size(); } virtual bool empty() const { return m_pointers.empty(); } virtual void clear(); - virtual void deleteAllChildObjects(); - virtual void deleteAllChildObjectsAsync(); + virtual void deleteAllChildObjects(); virtual void insertAt(int indexAfter, PdmObjectHandle* obj); virtual PdmObjectHandle* at(size_t index); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl index 1b5c73eba0..019111b2e5 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl @@ -1,4 +1,3 @@ -#include "cafAsyncObjectDeleter.h" #include "cafClassTypeName.h" #include "cafPdmObjectHandle.h" @@ -139,20 +138,6 @@ void PdmChildArrayField::deleteAllChildObjects() m_pointers.clear(); } -//-------------------------------------------------------------------------------------------------- -/// Transfers ownership of the objects pointed to a separate thread. -/// Then clears the container and lets the thread delete the objects. -//-------------------------------------------------------------------------------------------------- -template -void PdmChildArrayField::deleteAllChildObjectsAsync() -{ - CAF_ASSERT(isInitializedByInitFieldMacro()); - - AsyncPdmPointerVectorDeleter pointerDeleter(std::move(m_pointers)); - CAF_ASSERT(m_pointers.empty()); // Object storage for m_pointers should be empty immediately. -} - - //-------------------------------------------------------------------------------------------------- /// Removes the pointer at index from the container. Does not delete the object pointed to. /// Todo: This implementation can't be necessary in the new regime. Should be to just remove From 3a05abb42b5b36665e702f1da75344e76820a00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 22 May 2018 09:34:27 +0200 Subject: [PATCH 1026/1027] #2940 Fix crash due to missing guard in geomech camera conversion. --- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 08e3fb3ab2..bfbfbe501b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -599,8 +599,11 @@ void RimGeoMechView::convertCameraPositionFromOldProjectFiles() viewerToViewInterface->setCameraPointOfInterest(newPointOfInterest); } - m_viewer->mainCamera()->setViewMatrix( this->cameraPosition()); - m_viewer->setPointOfInterest(this->cameraPointOfInterest()); + if (m_viewer) + { + m_viewer->mainCamera()->setViewMatrix(this->cameraPosition()); + m_viewer->setPointOfInterest(this->cameraPointOfInterest()); + } } } From b35f31cafea89e25c9d092094c77b5a812870b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 22 May 2018 11:29:40 +0200 Subject: [PATCH 1027/1027] Upped to 2018.05.0 for release --- ResInsightVersion.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index c77fc2ff24..a65fff0741 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,16 +1,16 @@ set(RESINSIGHT_MAJOR_VERSION 2018) -set(RESINSIGHT_MINOR_VERSION 01) -set(RESINSIGHT_PATCH_VERSION 1) +set(RESINSIGHT_MINOR_VERSION 05) +set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-devRC") +#set(RESINSIGHT_VERSION_TEXT "-dev") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".112") +#set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")